feat: --auto flag to unlock auto/bypassPermissions modes#22
Open
BenSheridanEdwards wants to merge 2 commits into
Open
feat: --auto flag to unlock auto/bypassPermissions modes#22BenSheridanEdwards wants to merge 2 commits into
BenSheridanEdwards wants to merge 2 commits into
Conversation
launch_claude now starts proxy/start-proxy.js and points ANTHROPIC_BASE_URL at the local proxy. Previously only --remote did this. Without it, plain deepclaude pointed Claude Code straight at the backend URL, bypassing the proxy entirely. start_proxy is a shared helper that sets PROXY_PID/PROXY_PORT/PROXY_LOG as script globals; must be called WITHOUT command substitution because the EXIT trap depends on PROXY_PID reaching the parent shell. SCRIPT_DIR is symlink-resolved so deepclaude works when installed via a ~/.local/bin symlink. The exec on `claude` is dropped so the EXIT trap fires and the node child is cleaned up. ANTHROPIC_AUTH_TOKEN is left untouched — whatever the user has in their environment flows through. start-proxy.js legacy mode accepts an optional [defaultMode] third arg so state.mode resolves to e.g. \`deepseek\` rather than \`_single\` and MODEL_REMAP[state.mode] fires. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Claude Code disables `auto` and `bypassPermissions` for any ANTHROPIC_DEFAULT_*_MODEL value that isn't a `claude-*` name. Default deepclaude exports the resolved backend name (`deepseek-v4-pro` etc.) so the gate stays locked and `Shift+Tab` reports "auto mode isn't available for this model". This PR adds `--auto`. When passed, set_model_env exports canonical `claude-opus-4-7` / `claude-sonnet-4-6` / `claude-haiku-4-5-20251001` in place of the resolved backend names. The proxy translates them back to the backend on the wire via MODEL_REMAP. The TUI welcome chip will show the canonical name — `print_auto_mode_tip` surfaces this as an explicit tradeoff at launch alongside the actual backend routing and points at /_proxy/cost as the truth source for spend. Default behaviour is unchanged: backend names in env vars and TUI, no auto/bypassPermissions, no model remap fires (the body's model is already a backend name, not a key in MODEL_REMAP). Two adjacent additions this PR also lands: - `MODEL_REMAP['fireworks']` block, mirroring the deepseek/openrouter entries, so `--auto` works on the fireworks backend. - A `console.warn` line in the existing remap branch when an inbound `claude-*` name has no MODEL_REMAP entry — drift detector for when Anthropic ships a new model and the table falls behind. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5 tasks
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.
Claude Code disables
autoandbypassPermissionspermission modes whenANTHROPIC_DEFAULT_*_MODELis not aclaude-*value. Default deepclaude exports the resolved backend name (deepseek-v4-proetc.) so the gate stays locked andShift+Tabreports "auto mode isn't available for this model".This PR adds an opt-in
--autoflag. When passed,set_model_envexports canonicalclaude-opus-4-7/claude-sonnet-4-6/claude-haiku-4-5-20251001in place of the backend names. The proxy translates them back to the configured backend on the wire viaMODEL_REMAP. The TUI's welcome chip will display the canonical name — that's the explicit, opt-in tradeoff for unlocking the gate.Default behaviour is unchanged: backend names in env vars and TUI, no auto/bypassPermissions, no model remap fires.
Why opt-in
Surfacing the right tradeoff at launch matters because deepclaude's premise is cost savings — silently lying about the model in the TUI would mislead users about where their tokens are landing. With
--auto, the user is asking for the gate to be unlocked; they accept the TUI showing a Claude name in exchange. With--autooff, everything stays honest by default.The launch banner makes the tradeoff explicit either way:
A future PR will add a Claude Code statusLine integration so the actual backend (and live cost) is also visible at the bottom of the terminal — the natural counterpart to a TUI chip that lies under
--auto.What's in the diff
--autocore:AUTO_MODEglobal +--auto)arg parsing.set_model_envbranched on$AUTO_MODE: canonicalclaude-*names under--auto,$RESOLVED_*otherwise.print_auto_mode_tiphelper surfacing the tradeoff and the actual routing destination at launch (called from bothlaunch_claudeandlaunch_remote).--autodocumented inshow_help.Proxy / launch foundation (active in both modes — not auto-mode-specific, but required for
--autoto function):launch_claudenow starts the local proxy and pointsANTHROPIC_BASE_URLat it. Previously only--remotedid this.start_proxyshared helper setsPROXY_PID/PROXY_PORT/PROXY_LOGas script globals; must be called without$()or the EXIT trap leaks the node child.SCRIPT_DIRis symlink-resolved so deepclaude works when installed via a~/.local/binsymlink.start-proxy.jslegacy mode accepts an optional[defaultMode]third argv sostate.moderesolves to e.g.deepseekrather than_singleandMODEL_REMAP[state.mode]actually fires.launch_claudedeliberately does not touchANTHROPIC_AUTH_TOKEN— whatever Claude Code is already carrying flows through; the proxy injects backend auth itself for non-image, non-Anthropic calls.Adjacent proxy additions:
MODEL_REMAP['fireworks']block, mirroring the deepseek/openrouter entries, so--autoworks on the fireworks backend.console.warnline in the existing remap branch when an inboundclaude-*name has noMODEL_REMAPentry — drift detector for when Anthropic ships a new model and the table falls behind.Test plan
deepclaude(no--auto): TUI showsdeepseek-v4-pro,Shift+Tabdoesn't include auto/bypassPermissions, requests route through the proxy to DeepSeek.deepclaude --auto: TUI showsclaude-opus-4-7,Shift+Tabcycles default → auto → plan → bypassPermissions, requests still route to DeepSeek (proxy log:model remap: claude-opus-4-7 → deepseek-v4-pro).curl http://127.0.0.1:$PROXY_PORT/_proxy/statusreports"mode": "deepseek"(i.e. thedefaultModeargv plumbing works);/_proxy/costaccumulates adeepseekbucket on each turn.Notes
This PR overlaps with #21 on the proxy-in-path foundation (
start_proxy, symlink-resolvedSCRIPT_DIR,launch_clauderouting through proxy,start-proxy.js[defaultMode]argv). When either PR merges first, the other can rebase onto main; git will recognise the duplicate patches and drop them. The auto-mode-only delta (~50 lines acrossdeepclaude.shandproxy/model-proxy.js) is what survives in this PR after such a rebase.