



























@@ -1910,6 +1910,7 @@ describe("runCopilotAttempt", () => {
19101910it("retains a timed-out session until later compaction reaches session.idle", async () => {
19111911const afterCompaction = vi.fn();
19121912const onDeferredCompaction = vi.fn();
1913+const cleanupToolBridge = vi.fn();
19131914initializeGlobalHookRunner(
19141915createMockPluginRegistry([{ hookName: "after_compaction", handler: afterCompaction }]),
19151916);
@@ -1922,8 +1923,14 @@ describe("runCopilotAttempt", () => {
19221923);
19231924},
19241925});
1926+const createToolBridge = vi.fn(async () => ({
1927+cleanup: cleanupToolBridge,
1928+sdkTools: [],
1929+sourceTools: [],
1930+}));
1925193119261932const result = await runCopilotAttempt(makeParams(), {
1933+ createToolBridge,
19271934 onDeferredCompaction,
19281935pool: makeFakePool(sdk),
19291936});
@@ -1933,6 +1940,7 @@ describe("runCopilotAttempt", () => {
19331940expect(onDeferredCompaction).toHaveBeenCalledWith(
19341941expect.objectContaining({ sdkSessionId: "sess-1" }),
19351942);
1943+expect(cleanupToolBridge).not.toHaveBeenCalled();
19361944expect(activeSession?.disconnect).not.toHaveBeenCalled();
1937194519381946activeSession?.emit("session.compaction_start", {});
@@ -1946,6 +1954,7 @@ describe("runCopilotAttempt", () => {
19461954await vi.waitFor(() => {
19471955expect(activeSession?.disconnect).toHaveBeenCalledTimes(1);
19481956});
1957+expect(cleanupToolBridge).toHaveBeenCalledTimes(1);
19491958});
1950195919511960it("does not mark a timeout after SDK compaction has completed as active compaction", async () => {
@@ -3150,7 +3159,6 @@ describe("runCopilotAttempt", () => {
31503159expect(readAvailableTools(sdk.createSession.mock.calls[0])).toEqual([
31513160"read",
31523161"edit",
3153-"ask_user",
31543162"builtin:ask_user",
31553163]);
31563164});
@@ -3168,10 +3176,7 @@ describe("runCopilotAttempt", () => {
3168317631693177await runCopilotAttempt(makeParams(), { createToolBridge, pool });
317031783171-expect(readAvailableTools(sdk.createSession.mock.calls[0])).toEqual([
3172-"ask_user",
3173-"builtin:ask_user",
3174-]);
3179+expect(readAvailableTools(sdk.createSession.mock.calls[0])).toEqual(["builtin:ask_user"]);
31753180});
3176318131773182it("forwards the full bridged set when the run is unrestricted (no toolsAllow)", async () => {
@@ -3197,7 +3202,6 @@ describe("runCopilotAttempt", () => {
31973202"edit",
31983203"exec",
31993204"message",
3200-"ask_user",
32013205"builtin:ask_user",
32023206]);
32033207});
@@ -3224,7 +3228,7 @@ describe("runCopilotAttempt", () => {
3224322832253229const resumeCall = sdk.resumeSession.mock.calls[0] as unknown[] | undefined;
32263230const resumeCfg = resumeCall?.[1] as { availableTools?: string[] };
3227-expect(resumeCfg?.availableTools).toEqual(["read", "ask_user", "builtin:ask_user"]);
3231+expect(resumeCfg?.availableTools).toEqual(["read", "builtin:ask_user"]);
32283232});
3229323332303234it("forwards `[]` to resumeSession when the bridge returns no tools", async () => {
@@ -3243,7 +3247,7 @@ describe("runCopilotAttempt", () => {
3243324732443248const resumeCall = sdk.resumeSession.mock.calls[0] as unknown[] | undefined;
32453249const resumeCfg = resumeCall?.[1] as { availableTools?: string[] };
3246-expect(resumeCfg?.availableTools).toEqual(["ask_user", "builtin:ask_user"]);
3250+expect(resumeCfg?.availableTools).toEqual(["builtin:ask_user"]);
32473251});
32483252});
32493253此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。