

















@@ -64,10 +64,8 @@ describe("pi tool definition adapter logging", () => {
64646565await def.execute("call-edit-1", { path: "notes.txt" }, undefined, undefined, extensionContext);
666667-expect(logError).toHaveBeenCalledWith(
68-expect.stringContaining(
69-'[tools] edit failed: Missing required parameter: edits (received: path). Supply correct parameters before retrying. raw_params={"path":"notes.txt"}',
70-),
67+expect(vi.mocked(logError).mock.calls[0]?.[0]).toContain(
68+'[tools] edit failed: Missing required parameter: edits (received: path). Supply correct parameters before retrying. raw_params={"path":"notes.txt"}',
7169);
7270});
7371@@ -96,15 +94,12 @@ describe("pi tool definition adapter logging", () => {
9694extensionContext,
9795);
989699-expect(result).toEqual(
100-expect.objectContaining({
101-details: expect.objectContaining({
102-status: "blocked",
103-deniedReason: "plugin-before-tool-call",
104-reason: "blocked by policy",
105-}),
106-}),
107-);
97+const details = result.details as
98+| { status?: string; deniedReason?: string; reason?: string }
99+| undefined;
100+expect(details?.status).toBe("blocked");
101+expect(details?.deniedReason).toBe("plugin-before-tool-call");
102+expect(details?.reason).toBe("blocked by policy");
108103expect(logError).not.toHaveBeenCalled();
109104expect(mocks.logDebug).toHaveBeenCalledWith(
110105"tools: exec blocked by before_tool_call: blocked by policy",
@@ -138,17 +133,14 @@ describe("pi tool definition adapter logging", () => {
138133extensionContext,
139134);
140135141-expect(result).toEqual(
142-expect.objectContaining({
143-details: expect.objectContaining({
144-status: "error",
145-tool: "web_search",
146-error: "This operation was aborted",
147-}),
148-}),
149-);
150-expect(logError).toHaveBeenCalledWith(
151-expect.stringContaining("[tools] web_search failed: This operation was aborted"),
136+const details = result.details as
137+| { status?: string; tool?: string; error?: string }
138+| undefined;
139+expect(details?.status).toBe("error");
140+expect(details?.tool).toBe("web_search");
141+expect(details?.error).toBe("This operation was aborted");
142+expect(vi.mocked(logError).mock.calls[0]?.[0]).toContain(
143+"[tools] web_search failed: This operation was aborted",
152144);
153145});
154146@@ -173,18 +165,21 @@ describe("pi tool definition adapter logging", () => {
173165const controller = new AbortController();
174166controller.abort();
175167176-await expect(
177-def.execute(
168+let thrown: unknown;
169+try {
170+await def.execute(
178171"call-web-search-agent-abort",
179172{ query: "OpenClaw" },
180173controller.signal,
181174undefined,
182175extensionContext,
183-),
184-).rejects.toMatchObject({
185-name: "AbortError",
186-message: "This operation was aborted",
187-});
176+);
177+} catch (error) {
178+thrown = error;
179+}
180+expect(thrown).toBeInstanceOf(Error);
181+expect((thrown as Error).name).toBe("AbortError");
182+expect((thrown as Error).message).toBe("This operation was aborted");
188183expect(logError).not.toHaveBeenCalled();
189184});
190185此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。