fix(delegate-task): Wave 1 - fix polling timeout, resource cleanup, tool restrictions, idle dedup, auth-plugins JSONC, CLI runner hang
- fix(delegate-task): return error on poll timeout instead of silent null - fix(delegate-task): ensure toast and session cleanup on all error paths with try/finally - fix(delegate-task): apply agent tool restrictions in sync-prompt-sender - fix(plugin): add symmetric idle dedup to prevent double hook triggers - fix(cli): replace regex-based JSONC editing with jsonc-parser in auth-plugins - fix(cli): abort event stream after completion and restore no-timeout default All changes verified with tests and typecheck.
This commit is contained in:
@@ -0,0 +1,123 @@
|
||||
const { describe, test, expect, mock } = require("bun:test")
|
||||
|
||||
describe("sendSyncPrompt", () => {
|
||||
test("applies agent tool restrictions for explore agent", async () => {
|
||||
//#given
|
||||
const mockPromptWithModelSuggestionRetry = mock(async () => {})
|
||||
mock.module("../../shared/model-suggestion-retry", () => ({
|
||||
promptWithModelSuggestionRetry: mockPromptWithModelSuggestionRetry,
|
||||
}))
|
||||
|
||||
const { sendSyncPrompt } = require("./sync-prompt-sender")
|
||||
|
||||
const mockClient = {
|
||||
session: {
|
||||
prompt: mock(async () => ({ data: {} })),
|
||||
},
|
||||
}
|
||||
|
||||
const input = {
|
||||
sessionID: "test-session",
|
||||
agentToUse: "explore",
|
||||
args: {
|
||||
description: "test task",
|
||||
prompt: "test prompt",
|
||||
category: "quick",
|
||||
run_in_background: false,
|
||||
load_skills: [],
|
||||
},
|
||||
systemContent: undefined,
|
||||
categoryModel: undefined,
|
||||
toastManager: null,
|
||||
taskId: undefined,
|
||||
}
|
||||
|
||||
//#when
|
||||
await sendSyncPrompt(mockClient as any, input)
|
||||
|
||||
//#then
|
||||
expect(mockPromptWithModelSuggestionRetry).toHaveBeenCalled()
|
||||
const callArgs = mockPromptWithModelSuggestionRetry.mock.calls[0][1]
|
||||
expect(callArgs.body.tools.call_omo_agent).toBe(false)
|
||||
})
|
||||
|
||||
test("applies agent tool restrictions for librarian agent", async () => {
|
||||
//#given
|
||||
const mockPromptWithModelSuggestionRetry = mock(async () => {})
|
||||
mock.module("../../shared/model-suggestion-retry", () => ({
|
||||
promptWithModelSuggestionRetry: mockPromptWithModelSuggestionRetry,
|
||||
}))
|
||||
|
||||
const { sendSyncPrompt } = require("./sync-prompt-sender")
|
||||
|
||||
const mockClient = {
|
||||
session: {
|
||||
prompt: mock(async () => ({ data: {} })),
|
||||
},
|
||||
}
|
||||
|
||||
const input = {
|
||||
sessionID: "test-session",
|
||||
agentToUse: "librarian",
|
||||
args: {
|
||||
description: "test task",
|
||||
prompt: "test prompt",
|
||||
category: "quick",
|
||||
run_in_background: false,
|
||||
load_skills: [],
|
||||
},
|
||||
systemContent: undefined,
|
||||
categoryModel: undefined,
|
||||
toastManager: null,
|
||||
taskId: undefined,
|
||||
}
|
||||
|
||||
//#when
|
||||
await sendSyncPrompt(mockClient as any, input)
|
||||
|
||||
//#then
|
||||
expect(mockPromptWithModelSuggestionRetry).toHaveBeenCalled()
|
||||
const callArgs = mockPromptWithModelSuggestionRetry.mock.calls[0][1]
|
||||
expect(callArgs.body.tools.call_omo_agent).toBe(false)
|
||||
})
|
||||
|
||||
test("does not restrict call_omo_agent for sisyphus agent", async () => {
|
||||
//#given
|
||||
const mockPromptWithModelSuggestionRetry = mock(async () => {})
|
||||
mock.module("../../shared/model-suggestion-retry", () => ({
|
||||
promptWithModelSuggestionRetry: mockPromptWithModelSuggestionRetry,
|
||||
}))
|
||||
|
||||
const { sendSyncPrompt } = require("./sync-prompt-sender")
|
||||
|
||||
const mockClient = {
|
||||
session: {
|
||||
prompt: mock(async () => ({ data: {} })),
|
||||
},
|
||||
}
|
||||
|
||||
const input = {
|
||||
sessionID: "test-session",
|
||||
agentToUse: "sisyphus",
|
||||
args: {
|
||||
description: "test task",
|
||||
prompt: "test prompt",
|
||||
category: "quick",
|
||||
run_in_background: false,
|
||||
load_skills: [],
|
||||
},
|
||||
systemContent: undefined,
|
||||
categoryModel: undefined,
|
||||
toastManager: null,
|
||||
taskId: undefined,
|
||||
}
|
||||
|
||||
//#when
|
||||
await sendSyncPrompt(mockClient as any, input)
|
||||
|
||||
//#then
|
||||
expect(mockPromptWithModelSuggestionRetry).toHaveBeenCalled()
|
||||
const callArgs = mockPromptWithModelSuggestionRetry.mock.calls[0][1]
|
||||
expect(callArgs.body.tools.call_omo_agent).toBe(true)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user