fix(mcp): keep prompt completion within ready provider sessions

Avoid lazy provider startup for document and procedure completion. Propagate MCP cancellation through completers, cancel lookups during session transitions, and share provider result projection with ordinary operations. Cover cold, starting, warm, queued, cancelled, and closed sessions through MCP composition and provider boundaries.
This commit is contained in:
morluto
2026-10-12 16:27:51 +08:00
parent 0d5033ad12
commit 07b36c1489
16 changed files with 740 additions and 57 deletions
@@ -15,6 +15,26 @@ import {
} from "./hopperClient.fixture.js";
describe("HopperClient protocol", () => {
it("does not start cold and preserves normal dispatch once ready", async () => {
const launcher = new FixtureLauncher();
const client = new HopperClient({ launcher, startupTimeoutMs: 1_000 });
onTestFinished(async () => {
await client.close();
});
await expect(
client.callToolIfReady("echo", { label: "cold" }),
).resolves.toBe(undefined);
expect(launcher.processes).toEqual([]);
const started = await client.start();
if (!started.ok) throw started.error;
await expect(
client.callToolIfReady("echo", { label: "warm" }),
).resolves.toEqual({ ok: true, value: { label: "warm" } });
expect(launcher.processes).toHaveLength(1);
});
it("sanitizes unexpected owned-cleanup exceptions", () => {
expect(
providerCleanupFailure(