

























@@ -46,22 +46,24 @@ describe("pi tool definition adapter", () => {
4646it("wraps tool errors into a tool result", async () => {
4747const result = await executeThrowingTool("boom", "call1");
484849-expect(result.details).toMatchObject({
50-status: "error",
51-tool: "boom",
52-});
53-expect(result.details).toMatchObject({ error: "nope" });
49+const details = result.details as
50+| { status?: string; tool?: string; error?: string }
51+| undefined;
52+expect(details?.status).toBe("error");
53+expect(details?.tool).toBe("boom");
54+expect(details?.error).toBe("nope");
5455expect(JSON.stringify(result.details)).not.toContain("\n at ");
5556});
56575758it("normalizes exec tool aliases in error results", async () => {
5859const result = await executeThrowingTool("bash", "call2");
596060-expect(result.details).toMatchObject({
61-status: "error",
62-tool: "exec",
63-error: "nope",
64-});
61+const details = result.details as
62+| { status?: string; tool?: string; error?: string }
63+| undefined;
64+expect(details?.status).toBe("error");
65+expect(details?.tool).toBe("exec");
66+expect(details?.error).toBe("nope");
6567});
66686769it("coerces details-only tool results to include content", async () => {
@@ -81,7 +83,7 @@ describe("pi tool definition adapter", () => {
8183expect(result.details).toEqual({
8284hits: [{ id: "a1", score: 0.9 }],
8385});
84-expect(result.content[0]).toMatchObject({ type: "text" });
86+expect(result.content[0]?.type).toBe("text");
8587expect((result.content[0] as { text?: string }).text).toContain('"hits"');
8688});
8789@@ -102,7 +104,7 @@ describe("pi tool definition adapter", () => {
102104count: 2,
103105ids: ["m1", "m2"],
104106});
105-expect(result.content[0]).toMatchObject({ type: "text" });
107+expect(result.content[0]?.type).toBe("text");
106108expect((result.content[0] as { text?: string }).text).toContain('"count"');
107109});
108110});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。