Repository navigation
fix(permissions): force each CLI's ask mode under the opt-out - #51
Conversation
Under --ask or AGENTKIT_PERMISSIONS=ask, ak left the autonomy flag out but never set the CLI's permission mode, so an account whose own settings default to an autonomous mode (Claude's defaultMode, Codex's approval_policy) still started autonomous — verified live: `ak claude @Work1 --ask --trust-cwd` showed "auto mode on". `ak pick --json` reported launch.permissions "ask" without delivering it. - providers.toml gains per-CLI `ask` (the explicit ask flag; [] when the CLI has none) and `run.ask` for headless modes that differ: Claude and Grok `--permission-mode default`, Codex `--ask-for-approval on-request` (interactive; `codex exec` takes none). `{auto}` expands to `ask` under the opt-out. - `ask_conflicts` lists the flags that would set the permission mode (the autonomy flag included); under the opt-out a user argument after `--` matching one (or `<flag>=…`) is a usage error and launches nothing, so the opt-out cannot be undone from the tail. - pick-v2 under the opt-out appends `--ask` to launch.argv, so the suggested command asks where AGENTKIT_PERMISSIONS is not inherited. Tests: per-CLI ask flag (--ask and env), per-CLI refusal and the autonomy passthrough, headless claude, pick argv; grammar scopes use grammar_argv (the posture segment stripped; permissions owns it). Full suite 2749/0/1, public hygiene clean. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Round two of PR #51, from the independent review: - The refusal matched only exact tokens and `entry=` prefixes, so codex `--sandbox=danger-full-access`, `-sdanger-full-access`, `--config=approval_policy=never`, `-capproval_policy=never`, `-c 'approval_policy =never'` and cursor clusters (`-fw`) slipped through. The matcher now parses `--opt value`, `--opt=value`, `-o value`, `-ovalue`, and short clusters where the CLI accepts them (`ask_clusters`; `ask_value_opts` keeps a value such as `-pazure` from being read as flags). Plain words are never matched (a prompt saying `danger-full-access` passes) and a bare `--` ends the options. - Stricter modes were refused (a regression from main): `ask_values` now allows an option only with values no looser than ask — Claude `--permission-mode default|manual|plan`, Grok `default|plan`, Codex `--sandbox read-only|workspace-write`, Antigravity `--mode plan`. `ask_config` refuses codex config overrides of approval_policy and sandbox_mode. - kinds.py validates the new keys and forbids an ask flag on a CLI with standalone session modes (they return before `{auto}`). - Tests: the bypass spellings join the refusal table, an allowed table covers stricter modes, unrelated options, `-pazure`, prompt words and `-na`; placement asserted for codex -c / -r and grok -c. - Docs: pick-v2 schema no longer tells callers to append --ask; run.md notes the headless ask flag; permissions.md lists what stays allowed; providers.toml names Claude's `default` alias. Full suite 2824/0/1, public hygiene clean. Co-Authored-By: Claude Opus 5.5 <[email protected]>
From the independent re-review of 05ccb31: - Antigravity parses Go-style flags (`-opt` is `--opt`), so `-dangerously-skip-permissions` and `-mode auto` slipped through; `ask_single_dash_long` normalises them before matching. - clap reads `-c=KEY=VALUE` / `-s=VALUE` as the value after `=`; an attached short value now drops one leading `=` (refusing `-c=sandbox_mode=…`, allowing `-s=read-only`). - Codex config keys match on their last dotted segment too (`profiles.x.sandbox_mode`, `profiles.x.approval_policy`). - Codex's sandbox is now pinned under the opt-out (`--sandbox workspace-write`, interactive and `codex exec`), so an account config with sandbox_mode = "danger-full-access" cannot run unprompted commands unsandboxed; `ask_yield` lets a stricter `--sandbox`/`-s` the user passes replace ak's pair (codex refuses the option twice). - A bare `--` right after an option that may be waiting for its value is read as that value, not as the end of options (`--model -- <flag>`). - Claude and Grok `dontAsk` (stricter) join the allowed values. - kinds.py validates ask_yield and ask_single_dash_long. Full suite 2869/0/1, public hygiene clean. Co-Authored-By: Claude Opus 5.5 <[email protected]>
From the round-three re-review (approved; info items taken): - `-c sandbox_workspace_write.network_access=true` and `-c sandbox_permissions=[…]` widen the sandbox under the opt-out; both keys join ask_config, and a key now matches on any segment of its dotted path (profiles.x.sandbox_mode, sandbox_workspace_write.*). - permissions.md: the pinned workspace-write sandbox also applies to an account configured read-only; `-s read-only` keeps it. - run.md: codex exec's headless ask pin is named. Full suite 2879/0/1, public hygiene clean. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-flag Brings in #50 (token metering). Conflicts resolved by keeping both sides: providers.toml keeps codex run.ask inside [clis.codex.run] ahead of the new [clis.codex.run.tokens] table; CHANGELOG Unreleased carries Added (token metering) then Fixed (ask mode). Full suite 2896/0/1, hygiene clean. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Self-review — final head
|
From p2M's second read of the ask semantics:
- Claude: --allowedTools/--allowed-tools ('Bash(*)'), --settings (a file
or JSON whose permissions.allow or defaultMode loosens) and
--permission-prompt-tool (hands approvals to a tool that can say yes)
pre-approve without touching --permission-mode; all refused under the
opt-out. --permission-prompts is allowed only as `none`.
--disallowedTools (stricter) stays allowed.
- Grok: --allow and its aliases --allowedTools/--allowed-tools refused.
- docs/permissions.md: for CLIs without an ask flag (cursor, opencode,
pi, cline, antigravity) ask is the CLI's default, assumed not forced;
`dontAsk` denies silently, so a caller expecting prompts sees denials.
Full suite 2938/0/1, public hygiene clean.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Self-review update for final head
|
macOS CI failed twice in a row on ca7e87c (and twice on #45, once on #50) at the same pre-existing check: "the fake usage endpoint did not start (no port after 30s)" — the server's stderr was discarded, so a slow start and a crash looked the same. usage_server_start now keeps the server's stderr, stops waiting as soon as the process is gone, retries the start once, waits up to 60s per attempt, and puts the stderr tail in the failure message. Test-only; no runtime change. Full suite 2938/0/1, public hygiene clean, shellcheck clean. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Self-review: final head
|
Problem
Under
--ask/AGENTKIT_PERMISSIONS=ask, ak omitted the autonomy flag but never set the CLI's permission mode. An account whose own settings default to an autonomous mode still started autonomous — verified live:ak claude @work1 --ask --trust-cwdshowed "⏵⏵ auto mode on"; adding-- --permission-mode defaultshowed "⏸ manual mode on".ak pick --jsonreportedlaunch.permissions: "ask"without delivering it. This blocks the herdr-peers 2.0 brain, which must launch in ask mode.Fix
Explicit ask flag per CLI (
providers.tomlask,run.askfor headless).{auto}expands toaskunder the opt-out:ak run--permission-mode default--ask-for-approval on-requestcodex exectakes no-a)--permission-mode defaultValues were checked against the installed CLIs (claude 2.1.325 accepts
default; it documentsmanualtoo, sodefaultworks on older and newer versions; grok 1.0.77; codex 0.169.0, whereresumetakes-aandexecdoes not).Mode flags after
--can't undo the opt-out. Under the opt-out, a user argument matchingask_conflicts(the autonomy flag,--permission-mode, codex-a/--ask-for-approval/--approve-for-me/-c approval_policy=…/sandbox_mode=…/danger-full-access, cursor--force/-f/--yolo/--auto-review, agy--mode, …), in either--flag valueor--flag=valueform, is a usage error (exit 2) and launches nothing. Under autonomy these arguments pass through as before.pick-v2 delivers its claim. Under the opt-out,
launch.argvends with--ask, so the command still asks in a pane that doesn't inheritAGENTKIT_PERMISSIONS.Interface stays 1: the
ak rungrammar and envelope are unchanged; only the CLI argv built under the opt-out changes.Verification
permissionsscope: the exact ask flag for every CLI (via--askand via env, even with--auto); refusal for 22 conflict cases with exit 2 and no launch; the same arguments pass under autonomy; an unrelated-c model=o3passes; every CLI declaresask, and its autonomy flag is listed inask_conflicts; no ask flag is spelled inlib/.run: headless claude/grok carry the ask flag; codex exec carries none.pick-kinds:launch.argvends with--ask, and launching that argv yields--permission-mode default.dispatch,profiles) now usegrammar_argv, which strips the posture segment; thepermissionsscope owns the posture checks.bash tests/run.sh: 2749 passed / 0 failed / 1 skipped; public hygiene clean.Ships in 1.5.0 together with #50.
🤖 Generated with Claude Code