Repository navigation
Conversation
Add a user-action JSON-RPC request that sets the approval mode of the current project (or the store-wide default) in projects.json, behind the new supports_approval_mode_set capability. - Writes through ProjectsPolicyStore (0600, atomic); other entries kept. - Refused with -32602 and error.data.source when --approval-mode or CODELIA_APPROVAL_MODE decides the mode, so a change that cannot take effect is never reported as applied. - An unparseable policy file is never overwritten. - Idle-only under the run admission lock; a changed file drops the cached agent so the next run rebuilds sandbox/PermissionService. - Result reports the post-write resolved mode (a default write shadowed by a project entry stays visible). Specs: ui-protocol 4.2/5.18, approval-mode 5.2/5.3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GUI clients (the GPUI desktop composer's approval-mode chip) need to change the approval mode for the current project. Until now the resolved mode was read-only over RPC (
permissions.list). This PR adds a GUI-facing management RPC, following the pattern of the other 5.16+ requests. It is a user action over JSON-RPC and is never exposed as a model tool.approval_mode.set { value: "minimal" | "trusted" | "full-access", scope: "project" | "default" }→{ scope, value, path, changed, approval_mode: { value, source }, applies: "next_run" }, behind the newserver_capabilities.supports_approval_mode_set.packages/runtime/src/rpc/approval-mode.ts):projects.jsonentry throughProjectsPolicyStore(0600, atomic) and keeps the other entries. Theprojectscope uses the same workspace key the agent factory resolves.--approval-modeorCODELIA_APPROVAL_MODEdecides the mode (or holds an invalid value), the request is rejected with-32602anderror.data = { source, value }, and nothing is written. The runtime never reports a write as applied when it cannot take effect.-32000, and the file contents are not echoed).-32001during a run) and is rechecked under the run admission lock. A write that changes the file invalidates the cached agent, so the next run rebuilds the sandbox context andPermissionServicewith the new mode.defaultwrite that is still shadowed by a project entry shows up (source: "project").minimal.resolveApprovalModeOverride()andwriteApprovalModePolicy()inpermissions/approval-mode.ts, andisLocalRuntimeEnabled()inenvironment.ts, which the agent factory now uses too. Resolution order is unchanged.ui-protocol.md§4.2 and §5.18,approval-mode.md§5.2 and the new §5.3, plus the AGENTS.md notes.The desktop app (
crates/desktop/crates/agent-host) is not touched and will use this in a follow-up.Test plan
bun test packages/runtime/tests: 781 pass, 13 skip, 0 fail. New file:approval-mode-rpc.test.ts, which covers the capability, project/default writes with 0600 mode, no-op writes, shadowing, CLI/env/invalid overrides, bad params, busy runs, admission lock, a broken store, and host config.bun test packages/protocol/testsbun run typecheck,bun run lint(exit 0, warnings only, none in the changed files)bun run fmt. On main it also reformats an unrelated line inpackages/core/src/agent/agent.ts, which is left out of this PR.🤖 Generated with Claude Code