Skip to content

Commit fe50a3e

Browse files
committed
fix: preserve computer-use consent and provider question overlays
1 parent b94ea1e commit fe50a3e

15 files changed

Lines changed: 355 additions & 15 deletions

‎AGENTS.md‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,26 @@ Update corresponding Docs in [CrewCode Docs](/docs/), and [AGENTS.md](/AGENTS.md
2424

2525
## Agent Notes
2626

27+
Codex Full Access must keep `on-request` so MCP computer-use consent can reach
28+
the bridge's approval rules. CrewCoder's nested Codex adapter must also answer
29+
MCP elicitations explicitly; native Full access does not erase a service's own
30+
consent. Preserve Never/Sandboxed and hosted-tool lockdown. Configured native
31+
computer-use tools are provider-specific, not a universal backend. See
32+
`docs/crewcoder-provider.md` and `docs/chat-artifacts.md`.
33+
Reuse provider-specific computer-use integrations where available; a universal
34+
layer is deferred. Claude's built-in CLI computer use is documented as
35+
macOS-only and interactive-only, so it cannot currently be reused through
36+
CrewCoder's non-interactive Agent SDK transport. Do not imply Claude Desktop
37+
Windows support applies to the SDK or relax MCP isolation as a workaround.
38+
2739
Image files open read-only in Code Editor tabs; chat attachments and agent
2840
Markdown images/image links open the shared in-app viewer. Use the typed
2941
`fsReadDataUrl` boundary for workspace images, retaining the bounded local/SSH
3042
read path. Render SVG only as an inert image; never turn it into an active app
3143
document or persist image bytes in editor-session state. Keep generated-code
32-
artifact sandboxing separate. See `docs/image-viewer.md`.
44+
artifact sandboxing separate. Clear composer attachments only after the send
45+
captures them and asynchronous placement accepts; cancellation must preserve the
46+
unsent files. See `docs/image-viewer.md`.
3347

3448
Chat artifacts use the sandboxed Artifacts panel for HTML/SVG fences and supported
3549
workspace/HTTP links. Keep generated scripts in an opaque iframe without native
@@ -171,6 +185,11 @@ reconciliation, startup, or session switching. Preserve global delivery for
171185
newly appended live errors and active-scope delivery for live agent-exit
172186
warnings. See `docs/notifications.md`.
173187

188+
CrewCoder negotiates `_crewcoder/request_question` for nested provider questions
189+
and permission details. Keep questions separate from permission-option filtering
190+
and Full Access auto-approval; preserve free text, choices, and cancellation.
191+
Never remains an explicit non-interactive approval policy.
192+
174193
Provider questions use the shared `AgentRequestCard` overlay: option buttons for
175194
choice questions (short Yes/No sets on one row), toggles for multi-select, and an
176195
input plus send-reply button whenever free text is allowed. Map only structured

‎docs/agent-activity-overlay.md‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,22 @@ Provider mapping — only structured, provider-issued questions reach this card:
7878
| Codex | app-server `item/tool/requestUserInput` (legacy `tool/requestUserInput` alias), one card per question | when the question sets `isOther` or has no options |
7979
| OpenCode | `question` SSE request | unless `custom: false` |
8080
| Pi | extension UI `select` / `input` / `editor` | per method |
81-
| CrewCoder | `crewcoder_clarify` workflow card (above) | reply box |
81+
| CrewCoder | negotiated `_crewcoder/request_question` for provider questions; `crewcoder_clarify` workflow card (above) | provider free text/Other and clarify reply box |
82+
83+
CrewCode advertises `_meta["crewcoder/questions"].version: 1` on ACP initialize.
84+
Updated CrewCoder forwards nested Codex `requestUserInput` and Claude
85+
`AskUserQuestion` through `_crewcoder/request_question`, retaining original
86+
option values, descriptions, free-text availability, multi-select toggles, and
87+
secret input flags.
88+
Questions use `select`/`prompt` cards and remain interactive in Ask/Plan/Full;
89+
they never pass through permission-option filtering or Full Access auto-approval.
90+
Actual provider approval requests carry `kind: permission`, show the requested
91+
command or filesystem/network scope, and retain read-only mode restrictions.
92+
CrewCode returns only once/turn permission choices, never session-wide grants.
93+
Stop, process exit, turn completion, and the exact
94+
`_crewcoder/question_cancelled` notification abort the pending card. Empty or
95+
cancelled responses never become answers. Older ACP clients without the
96+
capability retain option-only permission transport; they cannot collect free text.
8297

8398
Codex answers are returned as `{ answers: { [questionId]: { answers: string[] } } }`. A cancelled, empty, or out-of-contract answer (typed text where Codex offered no "Other") fails the whole request with an explicit JSON-RPC error; Codex never receives a fabricated or empty answer. When Codex settles a request itself (`serverRequest/resolved`, e.g. non-blocking questions) or the app-server exits, the bridge aborts the pending `RequestUserFn` signal: the promise settles as `cancel` and the card is retracted with `user_request_resolved`.
8499

‎docs/chat-artifacts.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ For SSH workspaces, loopback HTTP previews require explicit port forwarding:
3232
workspace host. The panel explains this rather than loading the wrong machine.
3333

3434
Codex browser automation is separate from this panel and the Electron browser.
35+
Full Access uses Codex's `on-request` approval policy so MCP consent can reach
36+
the bridge. The bridge applies the mode's automatic approval rules; `never`
37+
would prevent the service from asking for consent in the first place.
3538
The app-server bridge handles `mcpServer/elicitation/request` using MCP's
3639
`action`/`content` response. Full Access automatically accepts consent-only forms;
3740
forms requesting data and URL-based authentication remain interactive. Structured

‎docs/crewcoder-provider.md‎

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ session-scoped approval picker for **General**, **CrewCoder**, **Plugin**,
4343
- **Review** (`review`) lets safe calls proceed and asks for mutations and dangerous calls.
4444
- **Always** (`always`) asks for every non-safe call.
4545
- **Never** (`never`) shows no prompts while continuing to block dangerous calls.
46-
- **Full access** (`full-access`) accepts calls without prompts.
46+
- **Full access** (`full-access`) accepts tool calls; external services may still request consent.
4747
- **Sandboxed** (`sandboxed`) shows no prompts and runs non-dangerous calls through the sandbox policy where supported.
4848

4949
The selected policy survives profile changes, including Configured default.
@@ -52,7 +52,29 @@ drops only the idle CrewCoder bridge and native-resumes it on the next prompt;
5252
both controls are disabled during a running turn. Full access is an explicit
5353
authority escalation: CrewCoder stops emitting approval requests and permits
5454
dangerous commands, so CrewCode's permission overlay and dangerous-command
55-
tripwire cannot interpose on those provider-native calls.
55+
tripwire cannot interpose on those provider-native calls. Updated CrewCoder
56+
versions keep Codex MCP computer-use consent and additional-permission requests
57+
interactive even under Full access; these are separate from tool-call approval.
58+
59+
CrewCoder's nested Codex adapter must answer MCP elicitations explicitly, just
60+
like CrewCode's direct Codex bridge. Use Review for interactive approval, or
61+
Full access when automatic tool approval is intended. Never and Sandboxed can
62+
auto-reject service consent upstream. The installed CrewCoder runtime must
63+
include this fix; editing CrewCode alone cannot update the child process.
64+
This repairs configured Codex computer-use tools. A common computer-use backend
65+
for Claude and other providers is a separate integration; it is not supplied by
66+
changing an approval policy. See CrewCoder's `docs/CODEX_CLI_PROVIDER.md`.
67+
68+
The current direction is to reuse each provider's existing computer-use
69+
integration where available. A universal CrewCode/CrewCoder computer-use layer
70+
is deferred. Model capability alone does not establish availability: the active
71+
adapter must expose the tools and route consent. Claude's native computer-use
72+
integration cannot currently be reused through CrewCoder's non-interactive
73+
Agent SDK transport. Anthropic documents the CLI feature as macOS-only and
74+
interactive-only; Windows support in Claude Desktop does not expose it through
75+
the Agent SDK. See [Claude Code computer use](https://code.claude.com/docs/en/computer-use).
76+
Do not enable all MCP servers or broaden native tools to work around this limit.
77+
A separately configured automation service would be a different integration.
5678

5779
A concrete CrewCoder profile also owns the agent's behavioral mode, so CrewCode
5880
locks its separate execution policy to **Build** and disables the
@@ -221,6 +243,19 @@ CrewCoder TUI, including active → pending → completed ordering.
221243

222244
## Mode and permission enforcement
223245

246+
Provider questions use the negotiated `_crewcoder/request_question` extension
247+
and the shared agent request card, separately from ACP tool approvals. They
248+
remain answerable in every composer mode and are never automatically answered
249+
by Full Access. Provider permission requests still obey the active write policy
250+
and show their exact command or requested access. See
251+
[Agent activity overlay](agent-activity-overlay.md).
252+
253+
Never deliberately prevents native sandbox escalation and may reject
254+
computer-use consent before a card can be shown. Select Review for interactive
255+
approvals or Full access for automatic tool approval with service consent.
256+
Do not reinterpret an explicit Never selection or automatically make `.git`
257+
writable to bypass that policy.
258+
224259
CrewCoder starts with the session's selected `--approval` policy in every agent
225260
profile, defaulting to `review`. CrewCode applies the current composer mode
226261
when a `session/request_permission` arrives; policies that emit no request

‎docs/image-viewer.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ tabs are read-only: they never decode binary bytes as text or expose formatting
55
and saving. Restored tabs retain their file identity and reload the image through
66
the workspace client; image data is not stored in editor-session persistence.
77

8+
Chat attachments stay in the draft while delegation placement is pending or
9+
cancelled. Once a send is accepted, its images are captured in the visible user
10+
message and workspace attachment references are included in the agent prompt
11+
before the composer clears its chips.
12+
813
Chat attachment thumbnails open an image modal. Agent replies can provide
914
Markdown image syntax (`![Preview](renders/preview.png)`) or a normal image link
1015
(`[Preview](renders/preview.png)`); both open the image inside the app. Markdown

‎src/main/agents/codex-bridge.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ describe('codex bridge mode config', () => {
88
['ask', 'read-only', 'untrusted', true],
99
['plan', 'read-only', 'untrusted', true],
1010
['build', 'workspace-write', 'on-request', false],
11-
['full', 'workspace-write', 'never', false],
11+
['full', 'workspace-write', 'on-request', false],
1212
] as const)('maps %s to the expected sandbox and approval policy', (mode, sandbox, approvalPolicy, readOnlyTools) => {
1313
const config = getModeConfig(mode)
1414

‎src/main/agents/codex-bridge.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ export function getModeConfig(mode?: ModeLevel, toolPolicy?: BridgeStartOpts['to
5656
case 'build':
5757
return { sandbox: 'workspace-write' as const, approvalPolicy: 'on-request' as const, allowTools: null }
5858
case 'full':
59-
return { sandbox: 'workspace-write' as const, approvalPolicy: 'never' as const, allowTools: null }
59+
// The bridge handles approvals; never would suppress MCP computer-use consent upstream.
60+
return { sandbox: 'workspace-write' as const, approvalPolicy: 'on-request' as const, allowTools: null }
6061
default:
6162
return { sandbox: 'workspace-write' as const, approvalPolicy: 'on-request' as const, allowTools: null }
6263
}

‎src/main/agents/crewcoder-bridge.test.ts‎

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe('CrewCoder filesystem custody handshake', () => {
3535
it('keeps ACP file capabilities separate from virtual custody', () => {
3636
expect(crewCoderInitializeParams()).toEqual(expect.objectContaining({
3737
clientCapabilities: { fs: { readTextFile: true, writeTextFile: true }, terminal: false },
38-
_meta: { 'crewcode/virtualFilesystem': false },
38+
_meta: { 'crewcode/virtualFilesystem': false, 'crewcoder/questions': { version: 1 } },
3939
}))
4040
})
4141

@@ -131,6 +131,43 @@ function crewCoderAcpHarness(options: { directoryError?: string; compact?: boole
131131
return { proc, sent }
132132
}
133133

134+
describe('CrewCoder question transport', () => {
135+
it.each(['full', 'ask'] as const)('shows questions without permission filtering in %s mode', async mode => {
136+
const harness = crewCoderAcpHarness()
137+
spawnAgentProcess.mockResolvedValue({ proc: harness.proc, dir: '/repo', remote: false })
138+
const requestUser = vi.fn().mockResolvedValue({ requestId: 'ui', action: 'submit', optionId: 'choice-0' })
139+
const events: BridgeEvent[] = []
140+
const bridge = await createCrewCoderBridge('crewcoder', { bridgeId: 'q', provider: 'crewcoder', cwd: '/repo', mode }, event => events.push(event), requestUser)
141+
await bridge.prompt('work')
142+
harness.proc.stdout.write(`${JSON.stringify({ jsonrpc: '2.0', id: 'question-rpc', method: '_crewcoder/request_question', params: {
143+
sessionId: 'session-1', version: 1, requestId: 'q1', kind: 'question', title: 'Which approach?', options: [{ label: 'Small change', value: 'minimal' }],
144+
} })}\n`)
145+
await vi.waitFor(() => expect(harness.sent.find(frame => frame.id === 'question-rpc')?.result).toEqual({ cancelled: false, value: 'minimal' }))
146+
expect(requestUser).toHaveBeenCalledWith(expect.objectContaining({ kind: 'select', title: 'Which approach?', options: [{ id: 'choice-0', label: 'Small change', description: undefined }] }), expect.any(AbortSignal))
147+
const prompt = harness.sent.find(frame => frame.method === 'session/prompt')!
148+
harness.proc.stdout.write(`${JSON.stringify({ jsonrpc: '2.0', id: prompt.id, result: { stopReason: 'end_turn' } })}\n`)
149+
await vi.waitFor(() => expect(events.some(event => event.type === 'turn_end')).toBe(true))
150+
})
151+
152+
it('withdraws the exact pending card on provider cancellation', async () => {
153+
const harness = crewCoderAcpHarness()
154+
spawnAgentProcess.mockResolvedValue({ proc: harness.proc, dir: '/repo', remote: false })
155+
const requestUser = vi.fn((_request, signal?: AbortSignal) => new Promise<{ requestId: string; action: 'cancel' }>(resolve => {
156+
signal?.addEventListener('abort', () => resolve({ requestId: 'ui', action: 'cancel' }), { once: true })
157+
}))
158+
const bridge = await createCrewCoderBridge('crewcoder', { bridgeId: 'q', provider: 'crewcoder', cwd: '/repo', mode: 'build' }, () => {}, requestUser)
159+
await bridge.prompt('work')
160+
harness.proc.stdout.write(`${JSON.stringify({ jsonrpc: '2.0', id: 900, method: '_crewcoder/request_question', params: {
161+
sessionId: 'session-1', version: 1, requestId: 'q1', kind: 'question', title: 'Anything else?',
162+
} })}\n`)
163+
await vi.waitFor(() => expect(requestUser).toHaveBeenCalledOnce())
164+
harness.proc.stdout.write(`${JSON.stringify({ jsonrpc: '2.0', method: '_crewcoder/question_cancelled', params: { sessionId: 'session-1', requestId: 'q1' } })}\n`)
165+
await vi.waitFor(() => expect(harness.sent.find(frame => frame.id === 900)?.result).toEqual({ cancelled: true }))
166+
const prompt = harness.sent.find(frame => frame.method === 'session/prompt')!
167+
harness.proc.stdout.write(`${JSON.stringify({ jsonrpc: '2.0', id: prompt.id, result: { stopReason: 'cancelled' } })}\n`)
168+
})
169+
})
170+
134171
describe('CrewCoder native compaction', () => {
135172
it('exposes compact only when advertised and calls session/compact without fabricating a turn', async () => {
136173
const harness = crewCoderAcpHarness({ compact: true })

0 commit comments

Comments
 (0)