feat: support Claude Code 'auto' permission mode#879
Merged
Conversation
Add 'auto' as a first-class HAPI permission mode for claude-flavored sessions, enforced by Claude's classifier rather than emulated in canCallTool. Includes mode configuration, CLI respawn on auto transitions, plan-exit targeting, API extensions, and documentation updates.
Deploying hapi with
|
| Latest commit: |
b64905b
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://b2f4dfd4.hapi-bqd.pages.dev |
| Branch Preview URL: | https://feat-claude-auto-mode.hapi-bqd.pages.dev |
There was a problem hiding this comment.
Findings
- No high-confidence findings on the added/modified lines.
Summary
Review mode: initial
No correctness, security, regression, data-loss, performance, or maintainability issues found in the reviewed diff. Residual risk: I did not execute the suite; the most relevant remaining gap is no direct test for the Claude plan-exit fake restart targeting auto.
Testing
- Not run (automation review only)
HAPI Bot
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.
Closes #858
What
Adds Claude Code's auto mode (
--permission-mode auto) as a first-class HAPI permission mode for claude-flavored sessions. Auto mode runs without routine permission prompts while a classifier blocks anything irreversible, destructive, or aimed outside the environment — a safer alternative to Yolo (bypassPermissions).How
autodiffers fromacceptEdits/bypassPermissionsin one important way: those are emulated by HAPI inside itscanCallToolhandler, whileauto(likeplan) is enforced inside Claude itself by the classifier. That drives the two non-mechanical changes:shared/src/modes.ts— addautotoCLAUDE_PERMISSION_MODESandPERMISSION_MODES(label Auto, tone warning). CLI flag parsing, hub validation, runner spawn args, and the web mode dropdown all derive from these lists, so they pick it up automatically.cli/src/claude/runClaude.ts— the message-queue batch hash previously only trackedisPlan. It now treatsautothe same way, so switching to/fromautomid-session starts a new Claude process with the matching--permission-modeflag (otherwise the switch would silently not take effect until the next respawn).cli/src/claude/utils/permissionHandler.ts— allowautoas a plan-exit target mode, matching Claude Code's own "Approve and start in auto mode" plan-approval option.web/src/api/client.ts— extend theapprovePermissionmode union.Permission escalations in auto mode (classifier blocks, explicit ask rules) still arrive through the existing
--permission-prompt-tool stdio→canCallToolpath and surface in the web UI as normal — no local auto-approval is added forauto, since Claude's classifier is the decision-maker.Notes
clauderejects the flag at spawn and the error surfaces in the session, same as any unsupported flag.autostays claude-only: codex/gemini/cursor/kimi/opencode keep their own mode lists and validation rejects it for them (covered by the new shared test).dontAskmode is intentionally out of scope.Testing
bun typecheck— clean (cli/web/hub)bun run test— cli, hub, web, shared all pass (one pre-existingapiMachine.test.tsfailure on macOS, reproduces on cleanmain, unrelated)shared/src/modes.test.ts(auto is claude-only + label/tone)