Ensure Grok and Claude ACP sessions report usable custom-tool bridge outcomes and model labels. - Copy the MCP schema server into runtime build output and fail custom-tool setup with stable diagnostics. - Record bridge failure metadata safely and normalize ACP string model markers. - Add bridge smoke coverage, adapter regressions, documentation, and a patch changeset. Files changed: .changeset/fn-8422-mcp-bridge.md | 7 ++++ docs/grok-cli-contract.md | 8 +++++ .../src/__tests__/agent-session-helpers.test.ts | 37 ++++++++++++++++++++++ packages/engine/src/__tests__/pi.test.ts | 16 ++++++++++ packages/engine/src/agent-session-helpers.ts | 20 ++++++++++++ packages/engine/src/pi.ts | 27 ++++++++++++++-- plugins/fusion-plugin-claude-runtime/README.md | 6 ++++ plugins/fusion-plugin-claude-runtime/package.json | 2 +- .../src/__tests__/runtime-adapter.test.ts | 30 ++++++++++++++++++ .../src/__tests__/tool-bridge.test.ts | 33 ++++++++++++++++++- .../src/runtime-adapter.ts | 30 ++++++++++++++++-- .../src/tool-bridge.ts | 24 +++++++++++--- plugins/fusion-plugin-claude-runtime/src/types.ts | 2 ++ plugins/fusion-plugin-grok-runtime/package.json | 2 +- .../src/__tests__/runtime-adapter.test.ts | 24 ++++++++++++++ .../src/__tests__/tool-bridge.test.ts | 33 ++++++++++++++++++- .../src/runtime-adapter.ts | 30 ++++++++++++++++-- .../fusion-plugin-grok-runtime/src/tool-bridge.ts | 24 +++++++++++--- plugins/fusion-plugin-grok-runtime/src/types.ts | 2 ++ 19 files changed, 338 insertions(+), 19 deletions(-) Fusion-Task-Id: FN-8422 Fusion-Task-Lineage: 6738f1bd-23f7-4fd3-8490-178d956b362d Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
38 lines
2.5 KiB
TypeScript
38 lines
2.5 KiB
TypeScript
import { describe, expect, it, vi } from "vitest";
|
|
import { ClaudeRuntimeAdapter } from "../runtime-adapter.js";
|
|
import type { AgentSession } from "../types.js";
|
|
const options={cwd:"/tmp",systemPrompt:"",onText:vi.fn()};
|
|
describe("ClaudeRuntimeAdapter", () => {
|
|
it("returns a visible diagnostic instead of rejecting on ACP create failure", async () => { const adapter=new ClaudeRuntimeAdapter({createAcpAdapter:()=>({createSession:async()=>{throw new Error("bridge unavailable")},promptWithFallback:async()=>undefined,describeModel:()=>"claude/default"})}); const result=await adapter.createSession(options); expect(result.session.state.errorMessage).toContain("Claude ACP failed"); expect(options.onText).toHaveBeenCalled(); });
|
|
it("returns a visible diagnostic for follow-up prompts without a live connection", async () => { const adapter=new ClaudeRuntimeAdapter({createAcpAdapter:()=>({createSession:async()=>{throw new Error("bridge unavailable")},promptWithFallback:async()=>undefined,describeModel:()=>"claude/default"})}); const {session}=await adapter.createSession(options); await adapter.promptWithFallback(session,"again"); expect(options.onText).toHaveBeenLastCalledWith(expect.stringContaining("no live connection")); });
|
|
});
|
|
|
|
|
|
it("surfaces a fixed diagnostic and omits the broken MCP entry when the tool bridge fails", async () => {
|
|
let captured: Record<string, unknown> | undefined;
|
|
const onText = vi.fn();
|
|
const adapter = new ClaudeRuntimeAdapter({
|
|
createAcpAdapter: () => ({
|
|
createSession: async (sessionOptions) => {
|
|
captured = sessionOptions as Record<string, unknown>;
|
|
return { session: {
|
|
model: "claude/default", messages: [], state: { messages: [] },
|
|
lastModelDescription: "claude/default", callbacks: {}, connection: {}, dispose: vi.fn(),
|
|
} as AgentSession };
|
|
},
|
|
promptWithFallback: async () => undefined,
|
|
describeModel: () => "claude/default",
|
|
}),
|
|
startToolBridge: async () => { throw new Error("bind failed"); },
|
|
});
|
|
|
|
const { session } = await adapter.createSession({
|
|
cwd: "/tmp", systemPrompt: "", onText,
|
|
customTools: [{ name: "fn_task_list", execute: async () => ({}) }],
|
|
});
|
|
|
|
expect(onText).toHaveBeenCalledWith("FUSION_TOOL_BRIDGE_FAILED: bridge-start-failed");
|
|
expect(session.fusionToolBridgeError).toEqual({ reasonCode: "bridge-start-failed" });
|
|
expect((captured?.mcpServers as Array<{ name: string }>).some((server) => server.name === "fusion-custom-tools")).toBe(false);
|
|
});
|