Files
oh-my-opencode/src/tools/delegate-task/sync-session-creator.test.ts
T
YeonGyu-Kim 413e8b73b7 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
2026-03-11 19:42:46 +09:00

39 lines
1.1 KiB
TypeScript

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: "*" },
],
})
})
})