Compare commits
2 Commits
fix/google
...
fix/backgr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
95491675e8 | ||
|
|
03f7643ee1 |
@@ -3941,3 +3941,96 @@ describe("BackgroundManager regression fixes - resume and aborted notification",
|
|||||||
manager.shutdown()
|
manager.shutdown()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe("BackgroundManager - tool permission spread order", () => {
|
||||||
|
test("startTask respects explore agent restrictions", async () => {
|
||||||
|
//#given
|
||||||
|
let capturedTools: Record<string, unknown> | undefined
|
||||||
|
const client = {
|
||||||
|
session: {
|
||||||
|
get: async () => ({ data: { directory: "/test/dir" } }),
|
||||||
|
create: async () => ({ data: { id: "session-1" } }),
|
||||||
|
promptAsync: async (args: { path: { id: string }; body: Record<string, unknown> }) => {
|
||||||
|
capturedTools = args.body.tools as Record<string, unknown>
|
||||||
|
return {}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
const manager = new BackgroundManager({ client, directory: tmpdir() } as unknown as PluginInput)
|
||||||
|
const task: BackgroundTask = {
|
||||||
|
id: "task-1",
|
||||||
|
status: "pending",
|
||||||
|
queuedAt: new Date(),
|
||||||
|
description: "test task",
|
||||||
|
prompt: "test prompt",
|
||||||
|
agent: "explore",
|
||||||
|
parentSessionID: "parent-session",
|
||||||
|
parentMessageID: "parent-message",
|
||||||
|
}
|
||||||
|
const input: import("./types").LaunchInput = {
|
||||||
|
description: task.description,
|
||||||
|
prompt: task.prompt,
|
||||||
|
agent: task.agent,
|
||||||
|
parentSessionID: task.parentSessionID,
|
||||||
|
parentMessageID: task.parentMessageID,
|
||||||
|
}
|
||||||
|
|
||||||
|
//#when
|
||||||
|
await (manager as unknown as { startTask: (item: { task: BackgroundTask; input: import("./types").LaunchInput }) => Promise<void> })
|
||||||
|
.startTask({ task, input })
|
||||||
|
|
||||||
|
//#then
|
||||||
|
expect(capturedTools).toBeDefined()
|
||||||
|
expect(capturedTools?.call_omo_agent).toBe(false)
|
||||||
|
expect(capturedTools?.task).toBe(false)
|
||||||
|
expect(capturedTools?.write).toBe(false)
|
||||||
|
expect(capturedTools?.edit).toBe(false)
|
||||||
|
|
||||||
|
manager.shutdown()
|
||||||
|
})
|
||||||
|
|
||||||
|
test("resume respects explore agent restrictions", async () => {
|
||||||
|
//#given
|
||||||
|
let capturedTools: Record<string, unknown> | undefined
|
||||||
|
const client = {
|
||||||
|
session: {
|
||||||
|
promptAsync: async (args: { path: { id: string }; body: Record<string, unknown> }) => {
|
||||||
|
capturedTools = args.body.tools as Record<string, unknown>
|
||||||
|
return {}
|
||||||
|
},
|
||||||
|
abort: async () => ({}),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
const manager = new BackgroundManager({ client, directory: tmpdir() } as unknown as PluginInput)
|
||||||
|
const task: BackgroundTask = {
|
||||||
|
id: "task-2",
|
||||||
|
sessionID: "session-2",
|
||||||
|
parentSessionID: "parent-session",
|
||||||
|
parentMessageID: "parent-message",
|
||||||
|
description: "resume task",
|
||||||
|
prompt: "resume prompt",
|
||||||
|
agent: "explore",
|
||||||
|
status: "completed",
|
||||||
|
startedAt: new Date(),
|
||||||
|
completedAt: new Date(),
|
||||||
|
}
|
||||||
|
getTaskMap(manager).set(task.id, task)
|
||||||
|
|
||||||
|
//#when
|
||||||
|
await manager.resume({
|
||||||
|
sessionId: "session-2",
|
||||||
|
prompt: "continue",
|
||||||
|
parentSessionID: "parent-session",
|
||||||
|
parentMessageID: "parent-message",
|
||||||
|
})
|
||||||
|
|
||||||
|
//#then
|
||||||
|
expect(capturedTools).toBeDefined()
|
||||||
|
expect(capturedTools?.call_omo_agent).toBe(false)
|
||||||
|
expect(capturedTools?.task).toBe(false)
|
||||||
|
expect(capturedTools?.write).toBe(false)
|
||||||
|
expect(capturedTools?.edit).toBe(false)
|
||||||
|
|
||||||
|
manager.shutdown()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|||||||
@@ -355,10 +355,10 @@ export class BackgroundManager {
|
|||||||
system: input.skillContent,
|
system: input.skillContent,
|
||||||
tools: (() => {
|
tools: (() => {
|
||||||
const tools = {
|
const tools = {
|
||||||
...getAgentToolRestrictions(input.agent),
|
|
||||||
task: false,
|
task: false,
|
||||||
call_omo_agent: true,
|
call_omo_agent: true,
|
||||||
question: false,
|
question: false,
|
||||||
|
...getAgentToolRestrictions(input.agent),
|
||||||
}
|
}
|
||||||
setSessionTools(sessionID, tools)
|
setSessionTools(sessionID, tools)
|
||||||
return tools
|
return tools
|
||||||
@@ -628,10 +628,10 @@ export class BackgroundManager {
|
|||||||
...(resumeVariant ? { variant: resumeVariant } : {}),
|
...(resumeVariant ? { variant: resumeVariant } : {}),
|
||||||
tools: (() => {
|
tools: (() => {
|
||||||
const tools = {
|
const tools = {
|
||||||
...getAgentToolRestrictions(existingTask.agent),
|
|
||||||
task: false,
|
task: false,
|
||||||
call_omo_agent: true,
|
call_omo_agent: true,
|
||||||
question: false,
|
question: false,
|
||||||
|
...getAgentToolRestrictions(existingTask.agent),
|
||||||
}
|
}
|
||||||
setSessionTools(existingTask.sessionID!, tools)
|
setSessionTools(existingTask.sessionID!, tools)
|
||||||
return tools
|
return tools
|
||||||
|
|||||||
@@ -141,10 +141,10 @@ export async function startTask(
|
|||||||
...(launchVariant ? { variant: launchVariant } : {}),
|
...(launchVariant ? { variant: launchVariant } : {}),
|
||||||
system: input.skillContent,
|
system: input.skillContent,
|
||||||
tools: {
|
tools: {
|
||||||
...getAgentToolRestrictions(input.agent),
|
|
||||||
task: false,
|
task: false,
|
||||||
call_omo_agent: true,
|
call_omo_agent: true,
|
||||||
question: false,
|
question: false,
|
||||||
|
...getAgentToolRestrictions(input.agent),
|
||||||
},
|
},
|
||||||
parts: [{ type: "text", text: input.prompt }],
|
parts: [{ type: "text", text: input.prompt }],
|
||||||
},
|
},
|
||||||
@@ -225,10 +225,10 @@ export async function resumeTask(
|
|||||||
...(resumeModel ? { model: resumeModel } : {}),
|
...(resumeModel ? { model: resumeModel } : {}),
|
||||||
...(resumeVariant ? { variant: resumeVariant } : {}),
|
...(resumeVariant ? { variant: resumeVariant } : {}),
|
||||||
tools: {
|
tools: {
|
||||||
...getAgentToolRestrictions(task.agent),
|
|
||||||
task: false,
|
task: false,
|
||||||
call_omo_agent: true,
|
call_omo_agent: true,
|
||||||
question: false,
|
question: false,
|
||||||
|
...getAgentToolRestrictions(task.agent),
|
||||||
},
|
},
|
||||||
parts: [{ type: "text", text: input.prompt }],
|
parts: [{ type: "text", text: input.prompt }],
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user