Surface Cursor approvals as Needs input
Summary
- add regression coverage for Cursor shell approval versus sandboxed shell payloads
- route real Cursor approval waits through the shared agent Needs input notification lifecycle
- clear the pending state when Cursor reports shell completion
Protocol finding
Cursor CLI 2026.07.23-e383d2b invokes beforeShellExecution before its native permission evaluator. The payload contains command, cwd, and sandbox, but no approval-required decision, and this release exposes no separate permission hook. The implementation therefore asks Cursor to use its native approval prompt for unsandboxed executions; sandboxed executions remain telemetry-only. This conservative fallback is required to create an observable approval wait without terminal-text heuristics.
Closes #9315
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.
Summary by cubic
Marks unsandboxed Cursor shell executions as Needs input and replies with {"permission":"ask"} to trigger Cursor’s native approval prompt. Previously these runs didn’t surface a wait; now they do, and state only clears when the matching command completes or is denied.
-
New Features
-
Reads approval config from ~/.cursor/cli-config.json and project .cursor/cli.json; honors CLI --mode overrides and --disable-project-configs; defaults to allowlist when missing.
-
Supports allow/deny via Shell(...) entries (exact, prefix, wildcard, and base:args forms).
-
Treats sandboxed or malformed shell payloads as telemetry and maps shell-exec/done/failed to PreToolUse/PostToolUse/PostToolUseFailure; failures emit error tool results and keep the session Working.
-
Manages concurrent approvals; dedupes retries; caps 16 pending; limits previews to 64 KB; expires after 1 hour; stop/new turn/session end clears; expirations restore Running.
-
Propagates response timeouts and hook deadlines to agent_journal_append and surface.resume.clear; preserves state on transport failure.
-
Redacts credentials, emails, paths, headers, and tokens in command previews and telemetry.
-
Bounds persisted approval state and prevents stale or duplicate responses from affecting new commands.
-
Migration
-
Run: cmux hooks cursor install --yes to add beforeShellExecution (shell-exec), afterShellExecution (shell-done), and postToolUseFailure (shell-failed, matcher Shell); user-defined hooks are preserved and setup is idempotent.
Summary by CodeRabbit
-
New Features
- Added native approval prompts for unsandboxed Cursor shell commands.
- Displays requested commands and returns the appropriate approval response.
- Supports command, executable, argument, and wildcard allowlist matching.
- Added telemetry for shell execution, completion, and failure events.
-
Bug Fixes
- Correctly tracks shell completion, failure, and cancellation responses.
- Respects approval modes and allowed-command settings.
- Prevents prompts for sandboxed or malformed requests.
- Preserves existing hook settings while removing stale or duplicate entries.