Files
rea/src/server/mcpProgress.ts
T
morluto 5f27e02fae refactor(runtime): name all silent catch causes without changing diagnostics (#637)
* refactor(domain): split error taxonomy into thematic modules

Move each error family out of domain/errors.ts into its own module
(base, core, provider selection/adapter, browser observation,
artifact, evidence, unknown registry, hopper, configuration) and
relocate AnalysisErrorProjection to analysisErrorProjection.
Migrate all 162 importers to the owning modules and delete
errors.ts. No re-export shims; behavior is unchanged.

* refactor(runtime): name all silent catch causes without changing diagnostics

Bind cause in every bare catch and unhandled rejection across src/.
Real failures preserve the cause for logging; best-effort cleanup
carries an explicit comment. Caller-visible and Evidence strings are
byte-identical to before.
2026-10-06 05:58:46 +08:00

38 lines
1.2 KiB
TypeScript

import type { ServerContext } from "@modelcontextprotocol/server";
import type { ProgressReporter } from "../application/ProgressReporter.js";
import {
createProgressReporter,
silentProgressReporter,
} from "../application/ProgressReporter.js";
export interface McpProgressContext {
readonly mcpReq: Pick<ServerContext["mcpReq"], "_meta" | "notify">;
}
/** Adapt the request's negotiated MCP progress token to application progress. */
export const mcpProgressReporter = (
context: McpProgressContext,
): ProgressReporter => {
const token = context.mcpReq._meta?.progressToken;
if (token === undefined) return silentProgressReporter;
return createProgressReporter(
async (update) => {
try {
await context.mcpReq.notify({
method: "notifications/progress",
params: {
progressToken: token,
progress: update.completed,
...(update.total === null ? {} : { total: update.total }),
message: `${update.phase}: ${update.message}`,
},
});
} catch (cause: unknown) {
// Progress is observational; transport failure cannot change tool truth.
void cause;
}
},
{ minimumIntervalMs: 100 },
);
};