@@ -16,6 +16,7 @@ import { createMockPluginRegistry } from "openclaw/plugin-sdk/plugin-test-runtim
|
16 | 16 | import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; |
17 | 17 | import { runCopilotAttempt } from "./attempt.js"; |
18 | 18 | import type { CopilotClientPool } from "./runtime.js"; |
| 19 | +import type { CopilotToolBridgeInput } from "./tool-bridge.js"; |
19 | 20 | |
20 | 21 | const TINY_PNG_BASE64 = |
21 | 22 | "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACXBIWXMAAAsTAAALEwEAmpwYAAAADUlEQVR4nGP4////KwAJ5gPoxLp9owAAAABJRU5ErkJggg=="; |
@@ -182,15 +183,15 @@ function createFakeSession(cfg: Record<string, unknown>, id: string): FakeSessio
|
182 | 183 | } |
183 | 184 | |
184 | 185 | function makeFakePool(sdk: FakeSdk) { |
185 | | -const pool: CopilotClientPool = { |
| 186 | +const pool = { |
186 | 187 | acquire: vi.fn(async (key, _options) => ({ |
187 | 188 | client: sdk.client as unknown as CopilotClient, |
188 | 189 | key, |
189 | 190 | })), |
190 | 191 | dispose: vi.fn(async () => []), |
191 | 192 | release: vi.fn(async () => undefined), |
192 | 193 | size: vi.fn(() => 0), |
193 | | -}; |
| 194 | +} satisfies CopilotClientPool; |
194 | 195 | return pool; |
195 | 196 | } |
196 | 197 | |
@@ -324,26 +325,16 @@ describe("runCopilotAttempt", () => {
|
324 | 325 | session.sendAndWait.mockResolvedValueOnce(makeAssistantMessageEvent("done")); |
325 | 326 | }, |
326 | 327 | }); |
327 | | -const createToolBridge = vi.fn( |
328 | | -async (input: { |
329 | | -onToolCompleted?: (completion: { |
330 | | -args: Record<string, unknown>; |
331 | | -result: unknown; |
332 | | -startedAt: number; |
333 | | -toolCallId: string; |
334 | | -toolName: string; |
335 | | -}) => Promise<void>; |
336 | | -}) => { |
337 | | -await input.onToolCompleted?.({ |
338 | | -args: { path: "README.md" }, |
339 | | -result: { content: [{ text: "read result", type: "text" }] }, |
340 | | -startedAt: Date.now(), |
341 | | -toolCallId: "tool-call-1", |
342 | | -toolName: "read", |
343 | | -}); |
344 | | -return { sdkTools: [], sourceTools: [] }; |
345 | | -}, |
346 | | -); |
| 328 | +const createToolBridge = vi.fn(async (input: CopilotToolBridgeInput) => { |
| 329 | +await input.onToolCompleted?.({ |
| 330 | +args: { path: "README.md" }, |
| 331 | +result: { content: [{ text: "read result", type: "text" }] }, |
| 332 | +startedAt: Date.now(), |
| 333 | +toolCallId: "tool-call-1", |
| 334 | +toolName: "read", |
| 335 | +}); |
| 336 | +return { sdkTools: [], sourceTools: [] }; |
| 337 | +}); |
347 | 338 | |
348 | 339 | await runCopilotAttempt(makeParams(), { |
349 | 340 | createToolBridge, |
|