fix: rename prompt_async to promptAsync for SDK compatibility
This commit is contained in:
parent
4fa234e5e1
commit
eb6067b6a6
@ -61,7 +61,7 @@ export async function runAggressiveTruncationStrategy(params: {
|
|||||||
clearSessionState(params.autoCompactState, params.sessionID)
|
clearSessionState(params.autoCompactState, params.sessionID)
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
try {
|
try {
|
||||||
await params.client.session.prompt_async({
|
await params.client.session.promptAsync({
|
||||||
path: { id: params.sessionID },
|
path: { id: params.sessionID },
|
||||||
body: { auto: true } as never,
|
body: { auto: true } as never,
|
||||||
query: { directory: params.directory },
|
query: { directory: params.directory },
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import type { PluginInput } from "@opencode-ai/plugin"
|
|||||||
|
|
||||||
export type Client = PluginInput["client"] & {
|
export type Client = PluginInput["client"] & {
|
||||||
session: {
|
session: {
|
||||||
prompt_async: (opts: {
|
promptAsync: (opts: {
|
||||||
path: { id: string }
|
path: { id: string }
|
||||||
body: { parts: Array<{ type: string; text: string }> }
|
body: { parts: Array<{ type: string; text: string }> }
|
||||||
query: { directory: string }
|
query: { directory: string }
|
||||||
|
|||||||
@ -99,7 +99,7 @@ describe("executeCompact lock management", () => {
|
|||||||
messages: mock(() => Promise.resolve({ data: [] })),
|
messages: mock(() => Promise.resolve({ data: [] })),
|
||||||
summarize: mock(() => Promise.resolve()),
|
summarize: mock(() => Promise.resolve()),
|
||||||
revert: mock(() => Promise.resolve()),
|
revert: mock(() => Promise.resolve()),
|
||||||
prompt_async: mock(() => Promise.resolve()),
|
promptAsync: mock(() => Promise.resolve()),
|
||||||
},
|
},
|
||||||
tui: {
|
tui: {
|
||||||
showToast: mock(() => Promise.resolve()),
|
showToast: mock(() => Promise.resolve()),
|
||||||
@ -283,9 +283,9 @@ describe("executeCompact lock management", () => {
|
|||||||
expect(autoCompactState.compactionInProgress.has(sessionID)).toBe(false)
|
expect(autoCompactState.compactionInProgress.has(sessionID)).toBe(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
test("clears lock when prompt_async in continuation throws", async () => {
|
test("clears lock when promptAsync in continuation throws", async () => {
|
||||||
// given: prompt_async will fail during continuation
|
// given: promptAsync will fail during continuation
|
||||||
mockClient.session.prompt_async = mock(() =>
|
mockClient.session.promptAsync = mock(() =>
|
||||||
Promise.reject(new Error("Prompt failed")),
|
Promise.reject(new Error("Prompt failed")),
|
||||||
)
|
)
|
||||||
autoCompactState.errorDataBySession.set(sessionID, {
|
autoCompactState.errorDataBySession.set(sessionID, {
|
||||||
@ -378,8 +378,8 @@ describe("executeCompact lock management", () => {
|
|||||||
// then: Summarize should NOT be called (early return from sufficient truncation)
|
// then: Summarize should NOT be called (early return from sufficient truncation)
|
||||||
expect(mockClient.session.summarize).not.toHaveBeenCalled()
|
expect(mockClient.session.summarize).not.toHaveBeenCalled()
|
||||||
|
|
||||||
// then: prompt_async should be called (Continue after successful truncation)
|
// then: promptAsync should be called (Continue after successful truncation)
|
||||||
expect(mockClient.session.prompt_async).toHaveBeenCalled()
|
expect(mockClient.session.promptAsync).toHaveBeenCalled()
|
||||||
|
|
||||||
// then: Lock should be cleared
|
// then: Lock should be cleared
|
||||||
expect(autoCompactState.compactionInProgress.has(sessionID)).toBe(false)
|
expect(autoCompactState.compactionInProgress.has(sessionID)).toBe(false)
|
||||||
|
|||||||
@ -53,7 +53,7 @@ describe("createAnthropicContextWindowLimitRecoveryHook", () => {
|
|||||||
messages: mock(() => Promise.resolve({ data: [] })),
|
messages: mock(() => Promise.resolve({ data: [] })),
|
||||||
summarize: mock(() => summarizePromise),
|
summarize: mock(() => summarizePromise),
|
||||||
revert: mock(() => Promise.resolve()),
|
revert: mock(() => Promise.resolve()),
|
||||||
prompt_async: mock(() => Promise.resolve()),
|
promptAsync: mock(() => Promise.resolve()),
|
||||||
},
|
},
|
||||||
tui: {
|
tui: {
|
||||||
showToast: mock(() => Promise.resolve()),
|
showToast: mock(() => Promise.resolve()),
|
||||||
@ -97,7 +97,7 @@ describe("createAnthropicContextWindowLimitRecoveryHook", () => {
|
|||||||
messages: mock(() => Promise.resolve({ data: [] })),
|
messages: mock(() => Promise.resolve({ data: [] })),
|
||||||
summarize: mock(() => Promise.resolve()),
|
summarize: mock(() => Promise.resolve()),
|
||||||
revert: mock(() => Promise.resolve()),
|
revert: mock(() => Promise.resolve()),
|
||||||
prompt_async: mock(() => Promise.resolve()),
|
promptAsync: mock(() => Promise.resolve()),
|
||||||
},
|
},
|
||||||
tui: {
|
tui: {
|
||||||
showToast: mock(() => Promise.resolve()),
|
showToast: mock(() => Promise.resolve()),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user