From e66c36df37bc5578fed87ad9c981afe1300007be Mon Sep 17 00:00:00 2001 From: Vincent Koc <25068+vincentkoc@users.noreply.github.com> Date: Sun, 21 Jun 2026 06:36:30 +0800 Subject: [PATCH] test(copilot): fix harness test typings --- .../run-attempt.context-engine.test.ts | 2 +- extensions/copilot/harness.test.ts | 4 +-- extensions/copilot/src/attempt.test.ts | 35 +++++++------------ 3 files changed, 16 insertions(+), 25 deletions(-) diff --git a/extensions/codex/src/app-server/run-attempt.context-engine.test.ts b/extensions/codex/src/app-server/run-attempt.context-engine.test.ts index 2f51824492fb..5d1e643d5fdd 100644 --- a/extensions/codex/src/app-server/run-attempt.context-engine.test.ts +++ b/extensions/codex/src/app-server/run-attempt.context-engine.test.ts @@ -505,7 +505,7 @@ describe("runCodexAppServerAttempt context-engine lifecycle", () => { { hookName: "before_prompt_build", handler: async (event) => ({ - appendContext: `${event.prompt}\n\nhook append marker`, + appendContext: `${(event as { prompt: string }).prompt}\n\nhook append marker`, prependContext: "hook prefix context", }), }, diff --git a/extensions/copilot/harness.test.ts b/extensions/copilot/harness.test.ts index 9504d8668645..dd0013c8c2a2 100644 --- a/extensions/copilot/harness.test.ts +++ b/extensions/copilot/harness.test.ts @@ -43,13 +43,13 @@ const TEST_SESSION_CONFIG = { workingDirectory: "/workspace", }; -function makePoolMock(): CopilotClientPool { +function makePoolMock() { return { acquire: vi.fn(), release: vi.fn(), dispose: vi.fn().mockResolvedValue([]), size: vi.fn().mockReturnValue(0), - }; + } satisfies CopilotClientPool; } function makeSessionStoreMock() { diff --git a/extensions/copilot/src/attempt.test.ts b/extensions/copilot/src/attempt.test.ts index 22ffcb4832db..3169c8dc121a 100644 --- a/extensions/copilot/src/attempt.test.ts +++ b/extensions/copilot/src/attempt.test.ts @@ -16,6 +16,7 @@ import { createMockPluginRegistry } from "openclaw/plugin-sdk/plugin-test-runtim import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { runCopilotAttempt } from "./attempt.js"; import type { CopilotClientPool } from "./runtime.js"; +import type { CopilotToolBridgeInput } from "./tool-bridge.js"; const TINY_PNG_BASE64 = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACXBIWXMAAAsTAAALEwEAmpwYAAAADUlEQVR4nGP4////KwAJ5gPoxLp9owAAAABJRU5ErkJggg=="; @@ -182,7 +183,7 @@ function createFakeSession(cfg: Record, id: string): FakeSessio } function makeFakePool(sdk: FakeSdk) { - const pool: CopilotClientPool = { + const pool = { acquire: vi.fn(async (key, _options) => ({ client: sdk.client as unknown as CopilotClient, key, @@ -190,7 +191,7 @@ function makeFakePool(sdk: FakeSdk) { dispose: vi.fn(async () => []), release: vi.fn(async () => undefined), size: vi.fn(() => 0), - }; + } satisfies CopilotClientPool; return pool; } @@ -324,26 +325,16 @@ describe("runCopilotAttempt", () => { session.sendAndWait.mockResolvedValueOnce(makeAssistantMessageEvent("done")); }, }); - const createToolBridge = vi.fn( - async (input: { - onToolCompleted?: (completion: { - args: Record; - result: unknown; - startedAt: number; - toolCallId: string; - toolName: string; - }) => Promise; - }) => { - await input.onToolCompleted?.({ - args: { path: "README.md" }, - result: { content: [{ text: "read result", type: "text" }] }, - startedAt: Date.now(), - toolCallId: "tool-call-1", - toolName: "read", - }); - return { sdkTools: [], sourceTools: [] }; - }, - ); + const createToolBridge = vi.fn(async (input: CopilotToolBridgeInput) => { + await input.onToolCompleted?.({ + args: { path: "README.md" }, + result: { content: [{ text: "read result", type: "text" }] }, + startedAt: Date.now(), + toolCallId: "tool-call-1", + toolName: "read", + }); + return { sdkTools: [], sourceTools: [] }; + }); await runCopilotAttempt(makeParams(), { createToolBridge,