diff --git a/examples/acp-agent/tests/acp.snapshot.ts b/examples/acp-agent/tests/acp.snapshot.ts index 582df37b82..9f99ce9913 100644 --- a/examples/acp-agent/tests/acp.snapshot.ts +++ b/examples/acp-agent/tests/acp.snapshot.ts @@ -37,6 +37,7 @@ interface Scenario { const SCENARIOS: Scenario[] = [ { name: 'handshake', hasModelTurn: false, recorded: false }, + { name: 'reject-extra-dirs', hasModelTurn: false, recorded: false }, { name: 'text-turn', hasModelTurn: true, recorded: true }, { name: 'tool-call-turn', hasModelTurn: true, recorded: true }, { name: 'workspace-edit', hasModelTurn: true, recorded: true }, diff --git a/examples/acp-agent/tests/snapshot-harness.ts b/examples/acp-agent/tests/snapshot-harness.ts index de05c8ca98..d66ee45d7f 100644 --- a/examples/acp-agent/tests/snapshot-harness.ts +++ b/examples/acp-agent/tests/snapshot-harness.ts @@ -55,6 +55,7 @@ const repoTsconfig = fileURLToPath(new URL('../../../tsconfig.json', import.meta type InputStep = | { op: 'initialize'; terminalOutput?: boolean } | { op: 'newSession' } + | { op: 'newSessionExpectError'; additionalDirectories?: string[] } | { op: 'prompt'; text: string } | { op: 'promptExpectError'; text: string } | { op: 'promptAndCancel'; text: string } @@ -228,6 +229,21 @@ async function runStep( setSessionId(sessionId) return } + case 'newSessionExpectError': { + // The bridge rejects a session/new that widens the workspace scope + // (non-empty additionalDirectories / mcpServers — unimplemented). The SDK + // surfaces that as a rejected RPC; swallow it so the run completes and the + // error frame is captured in the transcript. + await client.newSession({ + cwd, + mcpServers: [], + ...step.additionalDirectories !== undefined ? { additionalDirectories: step.additionalDirectories } : {}, + }).then( + () => { throw new Error('snapshot-harness: expected session/new to be rejected but it succeeded') }, + () => { /* expected: the bridge rejected the unsupported workspace scope */ }, + ) + return + } case 'prompt': { const sessionId = getSessionId() if (sessionId === undefined) throw new Error('snapshot-harness: prompt before newSession') diff --git a/examples/acp-agent/tests/snapshots/reject-extra-dirs/input.json b/examples/acp-agent/tests/snapshots/reject-extra-dirs/input.json new file mode 100644 index 0000000000..6a10f9a40c --- /dev/null +++ b/examples/acp-agent/tests/snapshots/reject-extra-dirs/input.json @@ -0,0 +1,6 @@ +{ + "steps": [ + { "op": "initialize" }, + { "op": "newSessionExpectError", "additionalDirectories": ["/extra-dir"] } + ] +} diff --git a/examples/acp-agent/tests/snapshots/reject-extra-dirs/session.jsonl b/examples/acp-agent/tests/snapshots/reject-extra-dirs/session.jsonl new file mode 100644 index 0000000000..ab44090be6 --- /dev/null +++ b/examples/acp-agent/tests/snapshots/reject-extra-dirs/session.jsonl @@ -0,0 +1 @@ +{"type":"session","version":1,"id":"00000000-0000-0000-0000-000000000000","createdAt":0} diff --git a/examples/acp-agent/tests/snapshots/reject-extra-dirs/stdout.golden.jsonl b/examples/acp-agent/tests/snapshots/reject-extra-dirs/stdout.golden.jsonl new file mode 100644 index 0000000000..4b864fe7f3 --- /dev/null +++ b/examples/acp-agent/tests/snapshots/reject-extra-dirs/stdout.golden.jsonl @@ -0,0 +1,2 @@ +{"jsonrpc":"2.0","id":1,"result":{"protocolVersion":1,"agentInfo":{"name":"deepseek-harness-acp","version":"0.0.1"},"agentCapabilities":{"loadSession":true,"promptCapabilities":{"image":false,"audio":false,"embeddedContext":false}},"authMethods":[]}} +{"jsonrpc":"2.0","id":2,"error":{"code":-32602,"message":"Invalid params: additionalDirectories is not supported in this MVP"}}