A claude magpie spawns runs --dangerously-skip-permissions: the flag is
on the bridge's own arguments, a user's claude may be a wrapper that
adds it, and an account's default mode may be Bypass Permissions. Where
no settings source the run reads has skipDangerousModePermissionPrompt,
Claude Code 2.1.295 blocks on its disclaimer — "❯ No, exit / Yes, I
accept, Enter to confirm" — and no one was there to answer it: each run
sat on the dialog for 45s (ReadyWait), ended, and the next run asked
again, so interactive requests failed in a loop (502 or a hung restart)
until magpie fell back to claude -p.
- the helper tells the disclaimer yes where TrustEnv says so, with the
same ↓-until-"Yes"-then-Enter the trust question gets (its "No, exit"
pairs the same, and a key sent as it is first drawn is lost the same
way); Claude Code records the acceptance itself, and the next run is
shown none of it.
- where TrustEnv isn't set — the account Claude Code is signed in to, in
a caller's folder — the disclaimer is the user's to answer: the run
ends at once saying so, not after 45s.
- a disclaimer left unanswered at a run's deadline is named as such
("asked to accept running in Bypass Permissions mode, not answered"),
never "showed no prompt".
Generated-by: GLM-5.3-Flash (ZCode)
Reviewed and ported, narrowed: as written, the shim accepted the
disclaimer wherever TrustEnv was set, and the bridge sets TrustEnv for
magpie's own folder in the account Claude Code is signed in to
(configDir ""), as do the warmup and /usage runs. Accepting there makes
Claude Code write skipDangerousModePermissionPrompt into the user's own
~/.claude/settings.json, a consent for every run after that is the
user's to give. Now a separate claudetui.BypassEnv says yes, set only by
claudeBypassEnv for a tui run in an account folder of magpie's
(configDir != ""), at the bridge and both warmup sites; TrustEnv alone
ends the run at once with the "asks to accept" message. The subject's
"as the trust question is" holds for the keys sent, not for where.
On mote, with tui.go at the parent: TestShimAcceptsBypassDisclaimer FAIL
("the shim wrote 0 lines of 3 in 30s"), TestShimNeverPrints' bypass
cases FAIL ("neither answered nor ended in 30s"),
TestShimEndsAtItsCallersDeadline/bypass_disclaimer_unanswered FAIL
("showed no prompt"); green with the patch. Broken by hand: the gate
back on TrustEnv turns TestShimNeverPrints/bypass_disclaimer_with_the_
folder_trusted red, and claudeBypassEnv ignoring configDir turns
TestClaudeBypassOnlyInMagpiesAccountFolder red ("user's own account: got
[MAGPIE_CLAUDE_TUI_BYPASS=1]"). go test -timeout 45m ./internal/gateway
and ./internal/claudetui ok; GOOS=linux/windows/darwin go vet ok. Not
tried: a real Claude Code 2.1.295 showing the disclaimer under a saved
account (needs a wrapper adding the flag).
Co-authored-by: ggbdpq <ggbdpq@gmail.com>
27 lines
963 B
Go
27 lines
963 B
Go
package gateway
|
|
|
|
import (
|
|
"slices"
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/claudetui"
|
|
)
|
|
|
|
// Claude Code records an accepted Bypass Permissions disclaimer in its
|
|
// config folder's settings.json for good (#5042). The shim may accept it
|
|
// only in an account folder of magpie's; in the account Claude Code is
|
|
// signed in to (configDir "", the user's own config folder) it never does,
|
|
// though magpie's folder is trusted for the run there.
|
|
func TestClaudeBypassOnlyInMagpiesAccountFolder(t *testing.T) {
|
|
yes := claudetui.BypassEnv + "=1"
|
|
if got := claudeBypassEnv(true, ""); slices.Contains(got, yes) {
|
|
t.Fatalf("user's own account: got %v, want no %s", got, yes)
|
|
}
|
|
if got := claudeBypassEnv(false, "/x/accounts/a"); slices.Contains(got, yes) {
|
|
t.Fatalf("-p run: got %v, want no %s", got, yes)
|
|
}
|
|
if got := claudeBypassEnv(true, "/x/accounts/a"); !slices.Contains(got, yes) {
|
|
t.Fatalf("magpie's account folder: got %v, want %s", got, yes)
|
|
}
|
|
}
|