From eb6067b6a63f413be90394ba50a4333236308228 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Mon, 16 Feb 2026 16:52:06 +0900 Subject: [PATCH] fix: rename prompt_async to promptAsync for SDK compatibility --- .../aggressive-truncation-strategy.ts | 2 +- .../client.ts | 2 +- .../executor.test.ts | 12 ++++++------ .../recovery-deduplication.test.ts | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/hooks/anthropic-context-window-limit-recovery/aggressive-truncation-strategy.ts b/src/hooks/anthropic-context-window-limit-recovery/aggressive-truncation-strategy.ts index 2c159486..29a8d394 100644 --- a/src/hooks/anthropic-context-window-limit-recovery/aggressive-truncation-strategy.ts +++ b/src/hooks/anthropic-context-window-limit-recovery/aggressive-truncation-strategy.ts @@ -61,7 +61,7 @@ export async function runAggressiveTruncationStrategy(params: { clearSessionState(params.autoCompactState, params.sessionID) setTimeout(async () => { try { - await params.client.session.prompt_async({ + await params.client.session.promptAsync({ path: { id: params.sessionID }, body: { auto: true } as never, query: { directory: params.directory }, diff --git a/src/hooks/anthropic-context-window-limit-recovery/client.ts b/src/hooks/anthropic-context-window-limit-recovery/client.ts index c323dafe..0ecaa263 100644 --- a/src/hooks/anthropic-context-window-limit-recovery/client.ts +++ b/src/hooks/anthropic-context-window-limit-recovery/client.ts @@ -2,7 +2,7 @@ import type { PluginInput } from "@opencode-ai/plugin" export type Client = PluginInput["client"] & { session: { - prompt_async: (opts: { + promptAsync: (opts: { path: { id: string } body: { parts: Array<{ type: string; text: string }> } query: { directory: string } diff --git a/src/hooks/anthropic-context-window-limit-recovery/executor.test.ts b/src/hooks/anthropic-context-window-limit-recovery/executor.test.ts index 4c2f2d2d..8efb76de 100644 --- a/src/hooks/anthropic-context-window-limit-recovery/executor.test.ts +++ b/src/hooks/anthropic-context-window-limit-recovery/executor.test.ts @@ -99,7 +99,7 @@ describe("executeCompact lock management", () => { messages: mock(() => Promise.resolve({ data: [] })), summarize: mock(() => Promise.resolve()), revert: mock(() => Promise.resolve()), - prompt_async: mock(() => Promise.resolve()), + promptAsync: mock(() => Promise.resolve()), }, tui: { showToast: mock(() => Promise.resolve()), @@ -283,9 +283,9 @@ describe("executeCompact lock management", () => { expect(autoCompactState.compactionInProgress.has(sessionID)).toBe(false) }) - test("clears lock when prompt_async in continuation throws", async () => { - // given: prompt_async will fail during continuation - mockClient.session.prompt_async = mock(() => + test("clears lock when promptAsync in continuation throws", async () => { + // given: promptAsync will fail during continuation + mockClient.session.promptAsync = mock(() => Promise.reject(new Error("Prompt failed")), ) autoCompactState.errorDataBySession.set(sessionID, { @@ -378,8 +378,8 @@ describe("executeCompact lock management", () => { // then: Summarize should NOT be called (early return from sufficient truncation) expect(mockClient.session.summarize).not.toHaveBeenCalled() - // then: prompt_async should be called (Continue after successful truncation) - expect(mockClient.session.prompt_async).toHaveBeenCalled() + // then: promptAsync should be called (Continue after successful truncation) + expect(mockClient.session.promptAsync).toHaveBeenCalled() // then: Lock should be cleared expect(autoCompactState.compactionInProgress.has(sessionID)).toBe(false) diff --git a/src/hooks/anthropic-context-window-limit-recovery/recovery-deduplication.test.ts b/src/hooks/anthropic-context-window-limit-recovery/recovery-deduplication.test.ts index 2e877277..65db7298 100644 --- a/src/hooks/anthropic-context-window-limit-recovery/recovery-deduplication.test.ts +++ b/src/hooks/anthropic-context-window-limit-recovery/recovery-deduplication.test.ts @@ -53,7 +53,7 @@ describe("createAnthropicContextWindowLimitRecoveryHook", () => { messages: mock(() => Promise.resolve({ data: [] })), summarize: mock(() => summarizePromise), revert: mock(() => Promise.resolve()), - prompt_async: mock(() => Promise.resolve()), + promptAsync: mock(() => Promise.resolve()), }, tui: { showToast: mock(() => Promise.resolve()), @@ -97,7 +97,7 @@ describe("createAnthropicContextWindowLimitRecoveryHook", () => { messages: mock(() => Promise.resolve({ data: [] })), summarize: mock(() => Promise.resolve()), revert: mock(() => Promise.resolve()), - prompt_async: mock(() => Promise.resolve()), + promptAsync: mock(() => Promise.resolve()), }, tui: { showToast: mock(() => Promise.resolve()),