Add session permission support to background agents for denying questions
Implements question-denied session permission rules when creating child
sessions via background task delegation. This prevents subagents from
asking questions by passing explicit permission configuration during
session creation.
🤖 GENERATED WITH ASSISTANCE OF OhMyOpenCode
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import { describe, expect, test } from "bun:test"
|
||||
|
||||
import { createSyncSession } from "./sync-session-creator"
|
||||
|
||||
describe("createSyncSession", () => {
|
||||
test("creates child session with question permission denied", async () => {
|
||||
// given
|
||||
const createCalls: Array<Record<string, unknown>> = []
|
||||
const client = {
|
||||
session: {
|
||||
get: async () => ({ data: { directory: "/parent" } }),
|
||||
create: async (input: Record<string, unknown>) => {
|
||||
createCalls.push(input)
|
||||
return { data: { id: "ses_child" } }
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// when
|
||||
const result = await createSyncSession(client as never, {
|
||||
parentSessionID: "ses_parent",
|
||||
agentToUse: "explore",
|
||||
description: "test task",
|
||||
defaultDirectory: "/fallback",
|
||||
})
|
||||
|
||||
// then
|
||||
expect(result).toEqual({ ok: true, sessionID: "ses_child", parentDirectory: "/parent" })
|
||||
expect(createCalls).toHaveLength(1)
|
||||
expect(createCalls[0]?.body).toEqual({
|
||||
parentID: "ses_parent",
|
||||
title: "test task (@explore subagent)",
|
||||
permission: [
|
||||
{ permission: "question", action: "deny", pattern: "*" },
|
||||
],
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user