claude: with the interactive mode on, nothing ever runs as -p; the editor switches TUI and claude -p

The owner (11-01): the interactive mode falling back to -p is dangerous,
for the account (a -p request counts as another client's) and for the
cache (a -p run starts without the interactive mode's), so it goes
entirely. With Settings › Models › Replies' interactive mode on:

- a request it can't take (safeguards, client cache marks, a JSON
  schema, an image by URL, words over 400KB, a branch of a -p session,
  a WSL Claude Code whose home or transcripts magpie can't reach) is
  refused before any Claude Code starts, saying why and naming the
  setting (claudeTUIErr), never run as -p;
- a helper that can't start the interactive mode (sign-in asked,
  first-run notes, an untrusted folder, no prompt within ReadyWait)
  ends saying why (claudetui fail); printMode, OnlyEnv and the
  claude-tui-broken mark that sent every run to -p for a day are gone;
- a helper that never answers initialize fails the turn
  (tuiNoStart), and the next turn tries again.

Off still runs every request as -p. The "Interactive only" choice of
v0.1.2448 (claudeTUIOnly) is what On is now; the setting is no longer
read or sent.

The Claude Code provider editor's "Claude Code runs as" row is a
switch between Interactive mode (TUI) and claude -p (owner, 11-01),
saving claudePrintMode and reading /api/claude/mode again; disabled in
magpie web. It reads the settings first when the Settings page was
never opened (prefs null crashed the switch; found by the GUI test).
Chromium has no onfocusin property, so the card on keyboard focus
listens for focusin/focusout. Words in en, zh, zh-TW, ja and de.
Docs: claude-subscription-bridge.md describes refusal, not fallback.

Not covered yet, now refused under On rather than run as -p (follow-
ups, each to be done inside the interactive mode): an image by URL, a
JSON schema, safeguards, client cache marks, over 400KB, a -p
session's branch, WSL transcripts Windows can't read. /usage reads
the allowance with claude -p /usage (no model request) either way.

Run (worktree at df0320156 + this):
- mote: gofmt -l clean; go vet darwin/windows/linux of claudetui,
  gateway (gui for windows); go test claudetui, settings, settingsapi
  ok; gateway -run "TUI|Warm|Claude|AskClaude|Cache|Mode" ok (110s);
  gui -run "Budget|I18n|Settings|Claude" ok.
- mote GUI: claude-mode, claude-tui-setting, i18n-keys: 64/64 pass in
  Chromium and WebKit, 900 and 420 wide, en zh zh-TW ja de.
- wsl-run go vet -tags nogui ./internal/gui ./internal/claudetui ok;
  win-run go test ./internal/claudetui ok.
- Real Claude Code 2.1.316 on macOS through this build's
  claude-tui-helper, sandbox HOME, CLAUDE_CODE_OAUTH_TOKEN: trusted
  folder -> interactive run, streamed (message_start, 4 deltas,
  message_stop), result success in 5.2s; untrusted folder -> exit 1
  "Claude Code's interactive mode didn't run: Claude Code asks whether
  to trust the folder", no -p run; config without onboarding -> exit
  1 naming the first-run notes, no -p run.
Seen red: claude-mode's save test with prefs null before the fix, and
its focus test in Chromium before the listeners; TestClaudeModeLast
while it still read a helper's "this run is -p" line.
Not tried: a real gateway request refused in the GUI (covered by the
Go tests with the fake Claude Code); the new gateway tests run
against the old fallback code; Windows and WSL real runs of this
build; no full suite.
This commit is contained in:
yetone
2026-11-01 17:43:17 +08:00
parent bd5152ce3b
commit e5f66f8a61
21 changed files with 455 additions and 830 deletions
+51 -70
View File
@@ -239,102 +239,83 @@ yes only when the bridge sets `MAGPIE_CLAUDE_TUI_TRUST=1`, which it does
for magpie's own working folder or a saved account's config directory,
both magpie's. In the caller's folder under the account Claude Code is
signed in to, the question is the user's: a folder the user has not
trusted makes that run `-p`. The question opens on "No, exit", and a key
trusted fails that run, saying so. The question opens on "No, exit", and a key
sent as it is first drawn can be lost to its being drawn again, so the
helper presses ↓ until "Yes" is the last choice drawn and Enter only once
it has stayed so for 300ms (`ready`, `trustSettle`). Pressing Enter blind
chose "No, exit" in the real gateway, and every run went `-p`.
chose "No, exit" in the real gateway, and no run started.
A run is `-p`, as before, when (`claudeTUI`):
Every run is `-p` only when Settings › Models › Replies › Claude Code's
interactive mode is Off (`claudePrintMode`), or in the gateway's own
tests, whose fake Claude Codes are `-p` ones (`claudeTUIRuns`, code
`no-shim`). With it On, nothing ever runs as `-p` (the owner, 11-01): the
plan counts a `-p` request as another client's, at about twice the
interactive mode's, and a `-p` run starts without the interactive mode's
cache. A run the interactive mode can't take is refused before any Claude
Code starts (`startRun`), and the request gets an error naming why and
the setting (`claudeTUIErr`, `claudeNotTUIWhy`). That is when
(`claudeTUI`, `claudePrint`):
- Settings › Models › Replies › Claude Code's interactive mode is Off
(`claudePrintMode`); (with Interactive only, each case below fails instead:
see [Interactive only](#interactive-only-claudetuionly));
- it is Claude Code in WSL whose home the probe didn't find, or, in
the distro user's own folder, one Windows can't read;
the distro user's own folder, one Windows can't read (`wslread`);
- the request has safeguards, client cache marks, a JSON schema, an image
known only by its URL (`urlImages`: the helper pastes files, and has no
bytes of it), or words over 400KB (`tuiPromptMost`, images not counted),
which a paste can't carry as `-p` does;
which a paste can't carry;
- it is a branch of a `-p` run's session (`branch`: see
[Tool results another request answers first](#tool-results-another-request-answers-first));
a branch of an interactive run's session is interactive too.
The gateway's log says which (`claude: this run is -p: …`,
`claudePrintWhy`), and the helper's own line when it becomes `-p` (below)
is logged from the run's stderr (`lockedWriter`).
The gateway's log says which (`claude: not the interactive mode: …`).
A refused request never ran, so it isn't the editor's last request
(`noteClaudeRun`). The model test's and warm-up's "hi" (`askClaude`) goes
through the helper too (`askClaudeTUI`), in stream-json, and its stdin is
closed at the first result. Reading the plan's allowance (`/usage`) asks
no model and is still `claude -p /usage`.
The Claude Code provider page says under its accounts whether runs are
the interactive mode (TUI) or `-p` (CLI), with why when every run is
`-p`, and opens what tells the two apart (`claudeModeRow` in app.js, drawn by
claudemode.js, which it loads with its first read).
It reads `GET /api/claude/mode` (`gateway.ClaudeModeNow`) as the page
The Claude Code provider editor's "Claude Code runs as" row
(`claudeModeRow` in app.js, drawn by claudemode.js, which it loads with
its first read) is a switch between Interactive mode (TUI) and claude
-p: pressing one saves `claudePrintMode` as Settings' row does
(`savePrefs`) and reads the mode again. In magpie web it is the
gateway's, and only its own Settings change it, so the switch is
disabled. Hovering or focusing it opens what tells the two apart. It
reads `GET /api/claude/mode` (`gateway.ClaudeModeNow`) as the page
opens, kept 30 seconds and dropped when the setting changes, not in
`/api/providers`' polls. What decides it for every run on the machine is
`claudeMachineWhy`, whose codes the page words: `off` (the setting),
`broken` (failed to start lately), `wsl-home`, `missing` (no Claude Code
found), `os` and `no-shim`. What only a request decides (safeguards and
the rest above) the page names as still `-p`; the WSL folder Windows
can't read is per account, so the page doesn't know it. A subscription
with Only switch serves nothing through magpie and shows no row.
`wsl-home`, `missing` (no Claude Code found), `os` and `no-shim`. Beside
the switch: turned off, that every request runs as claude -p; on where
the interactive mode can't run, that Claude requests fail, and why;
otherwise the last request, when it was the interactive mode's. A
subscription with Only switch serves nothing through magpie and shows no
row.
A turn the interactive mode can't take ends the run, and the next starts
anew: a turn with an image known by its URL, one that takes earlier turns
back, an effort change. A run given up on (`letGo`) is not taken back, since the
interactive mode can't answer a control request to stop a turn.
anew: a turn with an image known by its URL (refused, as above), one
that takes earlier turns back, an effort change. A run given up on
(`letGo`) is not taken back, since the interactive mode can't answer a
control request to stop a turn.
If the interactive Claude Code doesn't start or show its prompt within 45
seconds (`claudetui.ReadyWait`), or asks how to sign in (`signIn`: a
Claude Code signed in for `-p` only, as in a container given
`CLAUDE_CODE_OAUTH_TOKEN`), or shows its first-run notes (`firstRun`:
"Security notes", a config folder whose onboarding isn't done), the helper becomes `claude -p` with the same
arguments (`printMode`, `exec` on the same pid, its input still unread),
so the turn is answered all the same, and it writes
`<cache>/magpie/claude-tui-broken`, which holds the number of failed
starts in a row. For 30 minutes after one, doubled with each one after
to a day (`brokenFor`), every run goes to `-p` at once: the helper is
not started (`claudePrintWhy`, "the interactive mode failed to start
lately"). A start that shows its prompt removes the mark. A folder not
trusted goes to `-p` without the mark.
`CLAUDE_CODE_OAUTH_TOKEN`), shows its first-run notes (`firstRun`:
"Security notes", a config folder whose onboarding isn't done) or asks
about a folder the user hasn't trusted, the helper ends, saying why on
its stderr and in its exit (`fail` in `Run`). It never becomes `claude
-p`. Until 11-01 it did, and wrote `<cache>/magpie/claude-tui-broken`,
after which every run went `-p` for up to a day; that mark is no longer
written or read, and one left on disk does nothing.
The helper answers the bridge's `initialize` only once the prompt is
shown, or as `-p` after the fallback, so the bridge waits for it
`tuiInitWait` (`ReadyWait` and twice a control request's 10s), not the
10s of any other control request. With 10s, a Claude Code slower than
that to start (2 vCPU in Docker) was ended as the helper waited, before
it could become `-p`, and every try was answered 502 "Claude Code has
shown, so the bridge waits for it `tuiInitWait` (`ReadyWait` and twice a
control request's 10s), not the 10s of any other control request. With
10s, a Claude Code slower than that to start (2 vCPU in Docker) was ended
as the helper waited, and every try was answered 502 "Claude Code has
not answered magpie's initialize request in 10s" (#4504). A helper that
answers nothing even then is ended, the mark is written, and `start`
starts the turn again as `-p`.
### Interactive only (`claudeTUIOnly`)
The setting has a third choice, Interactive only, for users who would
rather a request fail than go out as `-p`. With it (`claudeTUIOnly()`,
which `claudePrintMode` set too overrides):
- a run that `claudeTUI` would make `-p` (any reason above) is not
started; the request gets an error naming the reason and the setting
(`claudeOnlyErr`, `claudeNotTUIWhy`);
- the helper is handed `MAGPIE_CLAUDE_TUI_ONLY=1` (`claudetui.OnlyEnv`,
`claudeCLI.tuiEnv`). Where it would become `-p` (no start, `ready`'s
sign-in, first-run notes, untrusted folder or timeout) it exits with
the reason instead (`fallBack` in `Run`), and it ignores the broken mark;
- a helper that never answers `initialize` ends the turn with an error,
not a `-p` try. The mark is still written, but the `broken` code is
not counted under Interactive only (`claudeMachineWhy`), so the next
run tries the interactive mode again;
- the model test's and warm-up's "hi" (`askClaude`) goes through the
helper too (`askClaudeTUI`), in stream-json, and its stdin is closed at
the first result.
Reading the plan's allowance (`/usage`) asks no model and stays `-p`.
The provider page's "Claude Code runs as" row reads `ClaudeMode.Only`:
with the interactive mode in use it says a request it can't take fails,
and its card says nothing runs as `-p`; where the interactive mode can't
run, the pill names Interactive only, never `claude -p`, and says Claude
requests fail and why, with Change in Settings. A request refused this
way never ran, so it isn't the row's last request (`noteClaudeRun`).
answers nothing even then is ended (`tuiNoStart`), and the turn fails
saying the interactive mode didn't start; the next turn tries it again.
## Why turns go on in one run
-7
View File
@@ -69,10 +69,3 @@ func (s *shim) stop() {
_ = syscall.Kill(-s.cmd.Process.Pid, syscall.SIGKILL)
}
}
// printMode becomes Claude Code at path, run with the -p arguments pargs:
// the same process, so the bridge's input, output and process tree go on
// as they were.
func printMode(path string, pargs []string) error {
return unix.Exec(path, append([]string{path}, pargs...), os.Environ())
}
+1 -17
View File
@@ -1,10 +1,8 @@
package claudetui
import (
"errors"
"fmt"
"os"
"os/exec"
"sync"
"syscall"
"time"
@@ -35,7 +33,7 @@ func (s *shim) start(path string, args []string) error {
return fmt.Errorf("no pseudo console on this Windows: %w", err)
}
// a .cmd (npm's shim) is run by cmd.exe, its arguments quoted as
// the -p run's are
// Claude Code is run with elsewhere (proc)
cmd := proc.Command(path, args...)
if cmd.Err != nil {
return cmd.Err
@@ -170,17 +168,3 @@ func (s *shim) stop() {
_ = windows.TerminateProcess(s.proc, 1)
}
}
// printMode runs Claude Code at path with the -p arguments pargs, on the
// helper's own input and output, and exits as it does: Windows has no
// exec, so the helper stays its parent.
func printMode(path string, pargs []string) error {
cmd := proc.Command(path, pargs...)
cmd.Stdin, cmd.Stdout, cmd.Stderr = os.Stdin, os.Stdout, os.Stderr
err := cmd.Run()
var exit *exec.ExitError
if errors.As(err, &exit) {
os.Exit(exit.ExitCode())
}
return err
}
+1 -6
View File
@@ -7,14 +7,9 @@ const Command = "claude-tui-helper"
// to trust the folder it runs in: the bridge sets it for magpie's own
// folder, and for a caller's in an account folder of magpie's, whose
// Claude Code no one else runs. Otherwise the question is the user's to
// answer in their own Claude Code, and the run is -p.
// answer in their own Claude Code, and the run ends, saying so.
const TrustEnv = "MAGPIE_CLAUDE_TUI_TRUST"
// OnlyEnv, "1", has the shim never become -p: a run whose interactive
// mode doesn't come up ends with why (the user's "Interactive only",
// settings.ClaudeTUIOnly), and one after a failure tries it again.
const OnlyEnv = "MAGPIE_CLAUDE_TUI_ONLY"
// WSLEnv holds, as JSON (WSL), how to run a Claude Code that is in a WSL
// distro: the helper, on Windows, runs wsl.exe in its pseudo console.
const WSLEnv = "MAGPIE_CLAUDE_TUI_WSL"
+12 -102
View File
@@ -41,10 +41,10 @@ import (
)
// ReadyWait is how long Claude Code may take to show its prompt before
// the helper becomes -p (printMode). The bridge's wait for the helper's
// answer to its initialize request is longer by as much as -p takes to
// answer it (#4504): a wait shorter than this one ended the helper as it
// waited, before it became -p, and the turn was answered 502.
// the helper ends, saying why. The bridge's wait for the helper's answer
// to its initialize request is longer (#4504): a wait shorter than this
// one ended the helper as it waited, and the turn was answered 502 with
// no reason.
const ReadyWait = 45 * time.Second
// how long Claude Code may take to show its prompt, a pasted message to
@@ -104,9 +104,9 @@ type shim struct {
// Run runs Claude Code at path, args being the bridge's `claude -p` ones,
// with stream-json on standard input and output: interactive, with the
// same model, tools and settings (interactiveArgs). One that doesn't come
// up becomes the -p run it stands for (printMode), reading the input
// still unread, unless the user has it never be -p (OnlyEnv): then it
// ends, saying why.
// up ends, saying why: it never becomes the -p run it stands for, as a -p
// request counts against the plan as another client's would, and starts
// without the interactive mode's cache.
func Run(args []string) error {
if len(args) < 1 {
return errors.New("usage: magpie " + Command + " <claude> [claude -p's arguments]")
@@ -121,19 +121,9 @@ func Run(args []string) error {
// wsl.exe's own arguments, then Claude Code's
pargs = append(slices.Clone(wsl.Args), pargs...)
}
only := os.Getenv(OnlyEnv) == "1"
// fallBack is the -p run, or with OnlyEnv the end, for why
fallBack := func(why string) error {
if only {
fmt.Fprintf(os.Stderr, "claude-tui: %s; the interactive mode only is set, so this run doesn't fall back to -p\n", why)
return fmt.Errorf("Claude Code's interactive mode didn't run, and magpie is set to use only it: %s", why)
}
fmt.Fprintf(os.Stderr, "claude-tui: %s; this run is -p\n", why)
return printMode(path, pargs)
}
if since, ok := BrokenSince(); ok && !only {
fmt.Fprintf(os.Stderr, "claude-tui: Claude Code's interactive mode failed to start %s ago; this run is -p\n", time.Since(since).Round(time.Second))
return printMode(path, pargs)
fail := func(why string) error {
fmt.Fprintf(os.Stderr, "claude-tui: %s\n", why)
return fmt.Errorf("Claude Code's interactive mode didn't run: %s", why)
}
args = interactiveArgs(pargs[len(wslArgs(wsl)):])
s := &shim{out: os.Stdout, changed: make(chan struct{}, 1), rowsCh: make(chan struct{}, 1), exited: make(chan struct{}), wsl: wsl}
@@ -167,8 +157,7 @@ func Run(args []string) error {
defer s.tap.drop()
if err := s.start(path, append(slices.Clone(wslArgs(wsl)), args...)); err != nil {
s.tap.drop()
MarkBroken()
return fallBack(fmt.Sprintf("Claude Code's interactive mode could not start (%v)", err))
return fail(fmt.Sprintf("Claude Code's interactive mode could not start (%v)", err))
}
defer s.stop()
defer s.dropImages()
@@ -183,15 +172,11 @@ func Run(args []string) error {
os.Exit(1)
}()
if err := s.ready(); err != nil {
if !errors.Is(err, errUntrusted) {
MarkBroken()
}
signal.Reset()
s.stop()
s.tap.drop()
return fallBack(err.Error())
return fail(err.Error())
}
clearBroken()
s.emit(map[string]any{"type": "system", "subtype": "init", "session_id": s.sid})
go s.tail(from)
return s.input(os.Stdin)
@@ -867,78 +852,3 @@ func interactiveArgs(pargs []string) []string {
}
return append(out, "--permission-mode", "default", "--allowedTools", strings.Join(allowed, ","), "--no-chrome")
}
// broken is where a failed start is kept: for a while after it
// (brokenFor), runs go straight to -p, rather than each waiting out
// readyWait. It holds how many starts in a row failed.
func broken() string {
dir, err := os.UserCacheDir()
if err != nil {
return ""
}
return filepath.Join(dir, "magpie", "claude-tui-broken")
}
// brokenFor is how long runs go to -p after the interactive mode failed
// to start n times in a row: 30 minutes, doubled with each failure after,
// to a day. A machine where it never starts (a container whose Claude Code
// is signed in for -p only, #4504) waits out readyWait about once a day.
func brokenFor(n int) time.Duration {
d := 30 * time.Minute
for i := 1; i < n && d < 24*time.Hour; i++ {
d *= 2
}
return min(d, 24*time.Hour)
}
func brokenRead() (time.Time, int, bool) {
p := broken()
if p == "" {
return time.Time{}, 0, false
}
fi, err := os.Stat(p)
if err != nil {
return time.Time{}, 0, false
}
b, _ := os.ReadFile(p)
n, err := strconv.Atoi(strings.TrimSpace(string(b)))
if err != nil || n < 1 {
// a mark from before the count, or one half written
n = 1
}
return fi.ModTime(), n, true
}
// BrokenSince is when the interactive mode last failed to start, while
// runs go to -p for it.
func BrokenSince() (time.Time, bool) {
at, n, ok := brokenRead()
if !ok || time.Since(at) > brokenFor(n) {
return time.Time{}, false
}
return at, true
}
// MarkBroken notes that the interactive mode failed to start: by the
// helper, and by the bridge when the helper didn't answer in time.
func MarkBroken() {
p := broken()
if p == "" {
return
}
n := 1
if _, was, ok := brokenRead(); ok {
n = was + 1
}
_ = os.MkdirAll(filepath.Dir(p), 0o700)
_ = os.WriteFile(p, []byte(strconv.Itoa(n)), 0o600)
now := time.Now()
_ = os.Chtimes(p, now, now)
}
// clearBroken forgets failed starts once one shows its prompt.
func clearBroken() {
if p := broken(); p != "" {
_ = os.Remove(p)
}
}
+23 -117
View File
@@ -398,43 +398,16 @@ func TestDropLeft(t *testing.T) {
}
}
func TestShimFallsBackToPrint(t *testing.T) {
for _, c := range []struct {
name string
env []string
broken bool
}{
{"failed start", []string{"FAKE_FAIL=1"}, true},
{"untrusted folder", []string{"FAKE_TRUST=1"}, false},
// at once, not after readyWait: runShim waits 30s (#4504)
{"asks to sign in", []string{"FAKE_LOGIN=1"}, true},
{"first-run notes", []string{"FAKE_NOTES=1"}, true},
} {
t.Run(c.name, func(t *testing.T) {
out := runShim(t, c.env, append([]string{fakePath(t)}, pArgs...), []string{"hello"}, 1)
if out[0]["result"] != "print mode" {
t.Fatalf("got %v, want the -p run's answer", out)
}
home := filepath.Dir(os.Getenv("MAGPIE_TUI_TEST_CFG"))
m, _ := filepath.Glob(filepath.Join(home, "*", "*", "magpie", "claude-tui-broken"))
m2, _ := filepath.Glob(filepath.Join(home, "*", "magpie", "claude-tui-broken"))
if got := len(m)+len(m2) > 0; got != c.broken {
t.Fatalf("marked broken: %v, want %v", got, c.broken)
}
})
}
}
// runOnly runs the shim with OnlyEnv, in home, told "hello", until it
// runEnds runs the shim in home, told "hello", until it
// exits or answers: what it wrote, its stderr, and how it ended.
func runOnly(t *testing.T, home string, env []string) (out, stderr string, err error) {
func runEnds(t *testing.T, home string, env []string) (out, stderr string, err error) {
t.Helper()
exe, _ := os.Executable()
cfg := filepath.Join(home, "claude")
tmp := filepath.Join(home, "tmp")
_ = os.Mkdir(tmp, 0o700)
cmd := exec.Command(exe, append([]string{fakePath(t)}, pArgs...)...)
cmd.Env = append(os.Environ(), "MAGPIE_TUI_TEST=shim", OnlyEnv+"=1", "HOME="+home, "XDG_CACHE_HOME="+filepath.Join(home, "cache"), "LOCALAPPDATA="+filepath.Join(home, "cache"),
cmd.Env = append(os.Environ(), "MAGPIE_TUI_TEST=shim", "HOME="+home, "XDG_CACHE_HOME="+filepath.Join(home, "cache"), "LOCALAPPDATA="+filepath.Join(home, "cache"),
"TMPDIR="+tmp, "TMP="+tmp, "TEMP="+tmp, "CLAUDE_CONFIG_DIR="+cfg)
cmd.Env = append(cmd.Env, env...)
stdin, _ := cmd.StdinPipe()
@@ -473,104 +446,37 @@ func runOnly(t *testing.T, home string, env []string) (out, stderr string, err e
return out, errb.String(), err
}
// With OnlyEnv (the user's "Interactive only"), an interactive mode that
// doesn't come up ends the run, saying why, and never becomes -p; a
// machine marked broken tries it again.
func TestShimOnlyNeverPrints(t *testing.T) {
// An interactive mode that doesn't come up ends the run, saying why, and
// never becomes -p: a -p request counts against the plan as another
// client's would, and starts without the interactive mode's cache. Nothing
// is kept for the next run, which tries the interactive mode again.
func TestShimNeverPrints(t *testing.T) {
for _, c := range []struct {
name string
env []string
name, why string
env []string
}{
{"failed start", []string{"FAKE_FAIL=1"}},
{"untrusted folder", []string{"FAKE_TRUST=1"}},
{"asks to sign in", []string{"FAKE_LOGIN=1"}},
{"first-run notes", []string{"FAKE_NOTES=1"}},
{"failed start", "something went wrong", []string{"FAKE_FAIL=1"}},
{"untrusted folder", "trust the folder", []string{"FAKE_TRUST=1"}},
// at once, not after readyWait: runEnds waits 30s (#4504)
{"asks to sign in", "sign", []string{"FAKE_LOGIN=1"}},
{"first-run notes", "notes", []string{"FAKE_NOTES=1"}},
} {
t.Run(c.name, func(t *testing.T) {
out, stderr, err := runOnly(t, t.TempDir(), c.env)
home := t.TempDir()
out, stderr, err := runEnds(t, home, c.env)
if err == nil || strings.Contains(out, "print mode") {
t.Fatalf("ended %v, wrote %q", err, out)
}
if !strings.Contains(stderr, "doesn't fall back to -p") || !strings.Contains(stderr, "magpie is set to use only it") {
if !strings.Contains(stderr, "claude-tui: ") || !strings.Contains(strings.ToLower(stderr), c.why) || strings.Contains(stderr, "-p") {
t.Fatalf("stderr %q", stderr)
}
// the next run, Claude Code fixed, is the interactive mode
out, stderr, err = runEnds(t, home, nil)
if err != nil || strings.Contains(out, "print mode") || !strings.Contains(out, "echo: hello") {
t.Fatalf("the next run ended %v, wrote %q, stderr %q", err, out, stderr)
}
})
}
t.Run("marked broken", func(t *testing.T) {
home := t.TempDir()
t.Setenv("HOME", home)
t.Setenv("XDG_CACHE_HOME", filepath.Join(home, "cache"))
t.Setenv("LOCALAPPDATA", filepath.Join(home, "cache"))
MarkBroken()
if _, ok := BrokenSince(); !ok {
t.Fatal("no mark")
}
out, stderr, err := runOnly(t, home, nil)
if err != nil || strings.Contains(out, "print mode") || !strings.Contains(out, "echo: hello") {
t.Fatalf("ended %v, wrote %q, stderr %q", err, out, stderr)
}
})
}
// Each failed start in a row keeps runs on -p longer, to a day; one that
// shows its prompt forgets them.
func TestBrokenGrows(t *testing.T) {
home := t.TempDir()
t.Setenv("HOME", home)
t.Setenv("XDG_CACHE_HOME", filepath.Join(home, "cache"))
t.Setenv("LOCALAPPDATA", filepath.Join(home, "cache"))
for n, want := range map[int]time.Duration{1: 30 * time.Minute, 2: time.Hour, 3: 2 * time.Hour, 6: 16 * time.Hour, 7: 24 * time.Hour, 40: 24 * time.Hour} {
if got := brokenFor(n); got != want {
t.Errorf("brokenFor(%d) = %s, want %s", n, got, want)
}
}
if _, ok := BrokenSince(); ok {
t.Fatal("broken with no mark")
}
MarkBroken()
MarkBroken()
if _, n, _ := brokenRead(); n != 2 {
t.Fatalf("count %d, want 2", n)
}
// 45 minutes ago: past one failure's 30 minutes, within two's hour
old := time.Now().Add(-45 * time.Minute)
_ = os.Chtimes(broken(), old, old)
if _, ok := BrokenSince(); !ok {
t.Fatal("two failures 45 minutes ago went back to the interactive mode")
}
_ = os.WriteFile(broken(), nil, 0o600) // a mark from before the count
_ = os.Chtimes(broken(), old, old)
if _, ok := BrokenSince(); ok {
t.Fatal("an old mark 45 minutes ago still holds")
}
clearBroken()
if _, _, ok := brokenRead(); ok {
t.Fatal("cleared, the mark stayed")
}
}
// A start that shows its prompt removes the mark of earlier failures, so
// the next failure counts from one.
func TestShimStartClearsBroken(t *testing.T) {
home := t.TempDir()
env := []string{"HOME=" + home, "XDG_CACHE_HOME=" + filepath.Join(home, "cache"), "LOCALAPPDATA=" + filepath.Join(home, "cache")}
for _, e := range env {
k, v, _ := strings.Cut(e, "=")
t.Setenv(k, v)
}
// three failures, the last a day and a half ago: past its 2 hours
MarkBroken()
MarkBroken()
MarkBroken()
old := time.Now().Add(-36 * time.Hour)
_ = os.Chtimes(broken(), old, old)
out := runShim(t, env, append([]string{fakePath(t)}, pArgs...), []string{"hello"}, 3)
if out[0]["subtype"] != "init" {
t.Fatalf("got %v, want an interactive turn", out)
}
if _, _, ok := brokenRead(); ok {
t.Fatal("a start that showed its prompt left the mark")
}
}
func TestShimTrustsWhenTold(t *testing.T) {
+10 -9
View File
@@ -5,27 +5,28 @@ import (
)
// The provider editor's row says how the last run went: the interactive
// mode, -p with claudeTUI's code, or -p after the helper couldn't start
// the interactive mode.
// mode, or -p with claudeTUI's code. A helper that couldn't start the
// interactive mode doesn't become -p, and says nothing that reads as a -p
// run.
func TestClaudeModeLast(t *testing.T) {
claudeLast.Lock()
before := claudeLast.run
claudeLast.Unlock()
t.Cleanup(func() { claudeLast.Lock(); claudeLast.run = before; claudeLast.Unlock() })
noteClaudeRun("schema")
if m := ClaudeModeNow(); m.Last == nil || m.Last.TUI || m.Last.Why != "schema" || m.Last.At.IsZero() {
t.Fatalf("after a schema run: %+v", m.Last)
noteClaudeRun("off")
if m := ClaudeModeNow(); m.Last == nil || m.Last.TUI || m.Last.Why != "off" || m.Last.At.IsZero() {
t.Fatalf("after a -p run: %+v", m.Last)
}
noteClaudeRun("")
if m := ClaudeModeNow(); m.Last == nil || !m.Last.TUI || m.Last.Why != "" {
t.Fatalf("after an interactive run: %+v", m.Last)
}
// the helper becoming -p after it started is the last run's mode too
// the helper failing to start is no -p run
w := &lockedWriter{run: &subscriptionRun{}}
_, _ = w.Write([]byte("claude-tui: Claude Code ended before it showed its prompt (exit status 1): B; this run is -p\n"))
if m := ClaudeModeNow(); m.Last == nil || m.Last.TUI || m.Last.Why != "start" {
t.Fatalf("after the helper became -p: %+v", m.Last)
_, _ = w.Write([]byte("claude-tui: Claude Code's interactive mode didn't run: Claude Code ended before it showed its prompt (exit status 1): B\n"))
if m := ClaudeModeNow(); m.Last == nil || !m.Last.TUI {
t.Fatalf("after the helper failed: %+v", m.Last)
}
}
+70 -88
View File
@@ -745,14 +745,9 @@ const claudeMCPPath = "/_magpie/claude-mcp/"
func (b *subscriptionBridge) start(ctx context.Context, req *Request, model, configDir, owner string, from *savedSession) (*subscriptionRun, <-chan Event, error) {
run, events, err := b.startRun(ctx, req, model, configDir, owner, from)
var noStart *tuiNoStart
if errors.As(err, &noStart) && claudeTUIOnly() {
return nil, nil, claudeOnlyErr("Claude Code's interactive mode didn't start: " + err.Error())
}
if errors.As(err, &noStart) && ctx.Err() == nil {
// marked broken, the next run is -p (claudePrintWhy); from was let
// go with the run
log.Printf("claude: Claude Code's interactive mode did not start (%v); the turn goes to -p", err)
return b.startRun(ctx, req, model, configDir, owner, nil)
if errors.As(err, &noStart) {
// never tried again as -p (claudeTUIErr)
return nil, nil, claudeTUIErr("Claude Code's interactive mode didn't start: " + err.Error())
}
var full *claudeFull
var refused *cliSchemaRefused
@@ -926,22 +921,20 @@ func (b *subscriptionBridge) startRun(ctx context.Context, req *Request, model,
prefix = promptCachePrefix(prompt)
}
}
// Claude Code's interactive mode, where a run allows it (claudeTUI):
// the shim (claudetui) is handed the -p arguments, and becomes that -p
// run when the interactive one doesn't start
// Claude Code's interactive mode unless the user turned it off
// (claudeTUI): the shim (claudetui) is handed the -p arguments, and
// runs them interactively. A run it can't take is refused, never made
// -p: a refused request never ran, and isn't the last run
tui, code := claudeTUI(req, binary, prompt)
if tui && binary.wsl != nil {
// the helper would wait for a transcript it can't see
if dir := binary.tuiWSLUnread(configDir); dir != "" {
log.Printf("claude: this run is -p: Windows can't read %s, where Claude Code in WSL writes its transcripts", dir)
tui, code = false, "wslread"
}
}
// a request refused under Interactive only never ran: it isn't the
// last run
if !tui && claudeTUIOnly() {
if !tui && code != "off" && code != "no-shim" {
cleanup()
return nil, nil, claudeOnlyErr(claudeNotTUIWhy(req, binary, prompt, configDir))
return nil, nil, claudeTUIErr(claudeNotTUIWhy(req, binary, prompt, configDir))
}
noteClaudeRun(code)
var cmd *exec.Cmd
@@ -1049,10 +1042,10 @@ func (b *subscriptionBridge) startRun(ctx context.Context, req *Request, model,
// (start tells a new one the whole conversation): told the turn
// first, it ended with no reply.
// The interactive mode's helper answers it once Claude Code shows
// its prompt, or, when it doesn't in claudetui.ReadyWait, once
// the helper has become -p: the wait is that long and -p's after
// it. 10s ended the helper as it waited, before it became -p, and
// every try of the turn was answered 502 (#4504).
// its prompt, and ends saying why when it doesn't in
// claudetui.ReadyWait: the wait is longer. 10s ended the helper
// as it waited, and every try of the turn was answered 502 with
// no reason (#4504).
wait := controlWait
if tui {
wait = tuiInitWait
@@ -1061,9 +1054,7 @@ func (b *subscriptionBridge) startRun(ctx context.Context, req *Request, model,
run.abort()
var unanswered *controlUnanswered
if tui && errors.As(err, &unanswered) {
// the helper hung: runs here are -p for a while, this
// turn's next try too (start)
claudetui.MarkBroken()
// the helper hung: the turn fails (start)
return nil, nil, &tuiNoStart{err}
}
return nil, nil, err
@@ -1096,8 +1087,8 @@ var claudeTUIHelper string
// controlWait is how long Claude Code may take to answer a control
// request; tuiInitWait the interactive mode's helper its initialize: as
// long as Claude Code may take to show its prompt, and then -p's
// controlWait with room, for the helper become -p to answer it.
// long as Claude Code may take to show its prompt, with controlWait's
// room twice over.
var (
controlWait = 10 * time.Second
tuiInitWait = claudetui.ReadyWait + 2*controlWait
@@ -1110,35 +1101,39 @@ type controlUnanswered struct{ what string }
func (e *controlUnanswered) Error() string { return "Claude Code has not " + e.what }
// tuiNoStart is a run whose interactive mode's helper never answered its
// initialize request: start tries the turn again as -p, unless the user
// has model requests never be (ClaudeTUIOnly).
// initialize request: start fails the turn, saying so.
type tuiNoStart struct{ err error }
func (e *tuiNoStart) Error() string { return e.err.Error() }
func (e *tuiNoStart) Unwrap() error { return e.err }
// claudeTUIRuns is false where magpie's executable has no shim to run:
// the gateway's tests, whose fake Claude Codes are -p ones.
// the gateway's tests, whose fake Claude Codes are -p ones. It is the one
// case besides the setting turned off (ClaudePrintMode) where a model
// request runs as -p.
var claudeTUIRuns = true
// tuiPromptMost is the longest first message a run in Claude Code's
// interactive mode is pasted, its words without its images (each pasted
// as its file's path); a longer one is a -p run's.
// as its file's path); a longer one is refused (claudeTUIErr).
const tuiPromptMost = 400 << 10
// claudeTUI says whether a run is Claude Code's interactive mode, as a
// person runs it (claudetui), rather than -p: the plan counts a -p
// request, its entrypoint sdk-cli, at about twice the interactive mode's
// (anthropics/claude-code#97074). On unless the user turned it off
// (ClaudePrintMode), on macOS, Linux and Windows, Claude Code in WSL too (its home
// known, so its transcripts are found); not for what only -p takes: safeguards and a client's
// cache marks (control requests and an extra body), a JSON schema, and
// images. prompt is the run's first message. The code is claudePrint's,
// for the provider editor's last run (ClaudeMode.Last).
// (anthropics/claude-code#97074), and a -p run starts without the
// interactive mode's cache. On unless the user turned it off
// (ClaudePrintMode), on macOS, Linux and Windows, Claude Code in WSL too
// (its home known, so its transcripts are found); not for what only -p
// takes: safeguards and a client's cache marks (control requests and an
// extra body), a JSON schema, and images by URL. With it on, such a run is
// refused (startRun), never made -p. prompt is the run's first message.
// The code is claudePrint's, for the provider editor's last run
// (ClaudeMode.Last).
func claudeTUI(req *Request, binary claudeCLI, prompt []map[string]any) (bool, string) {
code, why := claudePrint(req, binary, prompt)
if why != "" && claudeTUIRuns {
log.Printf("claude: this run is -p: %s", why)
if why != "" && code != "no-shim" {
log.Printf("claude: not the interactive mode: %s", why)
}
return why == "", code
}
@@ -1194,8 +1189,6 @@ func claudeMachineWhy(binary claudeCLI) (code, why string) {
{binary.wsl != nil && binary.wsl.Home == "", "wsl-home", "Claude Code in WSL, its home unknown"},
{binary.wsl == nil && binary.path == "", "missing", "no Claude Code path"},
{settings.Load().ClaudePrintMode, "off", "the interactive mode is turned off"},
// the user's "Interactive only" tries it again each run
{!claudeTUIOnly() && tuiBroken(), "broken", "the interactive mode failed to start lately"},
} {
if c.is {
return c.code, c.why
@@ -1206,23 +1199,20 @@ func claudeMachineWhy(binary claudeCLI) (code, why string) {
// ClaudeMode is how a Claude subscription's runs are made on this
// machine, for the Claude Code provider page: TUI when Claude Code's
// interactive mode, else -p, Why the code of claudeMachineWhy. A run can
// still be -p for what only it asks (safeguards, a client's cache marks,
// a JSON schema, an image known by its URL, a first message over 400KB).
// interactive mode, else -p (turned off) or none (it can't run here), Why
// the code of claudeMachineWhy. With it on, a request only -p takes
// (safeguards, a client's cache marks, a JSON schema, an image known by
// its URL, a first message over 400KB) is refused.
type ClaudeMode struct {
TUI bool `json:"tui"`
Why string `json:"why,omitempty"`
Broken time.Time `json:"broken,omitzero"` // since when, for "broken"
WSL bool `json:"wsl,omitempty"` // Claude Code in WSL
TUI bool `json:"tui"`
Why string `json:"why,omitempty"`
WSL bool `json:"wsl,omitempty"` // Claude Code in WSL
// how the last run since magpie started went (noteClaudeRun)
Last *ClaudeLastRun `json:"last,omitempty"`
// Only: the user has model requests never be -p (ClaudeTUIOnly)
Only bool `json:"only,omitempty"`
}
// ClaudeLastRun is how one run went: Why is claudePrint's code when it was
// -p, wslread when Windows couldn't read Claude Code in WSL's transcripts,
// start when the interactive mode didn't start and the helper became -p.
// ClaudeLastRun is how one run went: Why is claudePrint's code ("off")
// when it was -p.
type ClaudeLastRun struct {
TUI bool `json:"tui"`
Why string `json:"why,omitempty"`
@@ -1245,13 +1235,10 @@ func noteClaudeRun(why string) {
// ClaudeModeNow is ClaudeMode as of now.
func ClaudeModeNow() ClaudeMode {
m := ClaudeMode{Why: "missing", Only: claudeTUIOnly()}
m := ClaudeMode{Why: "missing"}
if binary, err := claudeBinary(); err == nil {
code, _ := claudeMachineWhy(binary)
m = ClaudeMode{TUI: code == "", Why: code, WSL: binary.wsl != nil, Only: m.Only}
if code == "broken" {
m.Broken, _ = claudetui.BrokenSince()
}
m = ClaudeMode{TUI: code == "", Why: code, WSL: binary.wsl != nil}
}
claudeLast.Lock()
if !claudeLast.run.At.IsZero() {
@@ -1330,23 +1317,19 @@ func (c claudeCLI) tuiCommand(ctx context.Context, args ...string) (*exec.Cmd, e
}
// tuiEnv is env with what the helper is told: how to run Claude Code in
// WSL, and to never become -p where the user has it so (ClaudeTUIOnly).
// WSL.
func (c claudeCLI) tuiEnv(env []string, configDir string) []string {
if c.wsl != nil {
env = append(env, claudetui.WSLEnv+"="+c.tuiWSL(configDir))
}
if claudeTUIOnly() {
env = append(env, claudetui.OnlyEnv+"=1")
}
return env
}
// claudeTUIOnly is whether the user has a Claude subscription's model
// requests never run as -p (settings.ClaudeTUIOnly), the interactive
// mode not turned off.
func claudeTUIOnly() bool {
st := settings.Load()
return st.ClaudeTUIOnly && !st.ClaudePrintMode
// claudeTUIOn is whether a Claude subscription's model requests run in
// Claude Code's interactive mode, and never as -p: the user hasn't turned
// it off (ClaudePrintMode), and magpie has its shim (claudeTUIRuns).
func claudeTUIOn() bool {
return claudeTUIRuns && !settings.Load().ClaudePrintMode
}
// claudeNotTUIWhy is why a run isn't the interactive mode.
@@ -1362,18 +1345,12 @@ func claudeNotTUIWhy(req *Request, binary claudeCLI, prompt []map[string]any, co
return "the interactive mode can't run here"
}
// claudeOnlyErr is the error a request gets that would be -p, where the
// user has model requests never be (ClaudeTUIOnly).
func claudeOnlyErr(why string) error {
return fmt.Errorf("this request would run as claude -p (%s), and magpie is set to use only Claude Code's interactive mode; set Claude Code's interactive mode in Settings to On to let it run as -p", why)
}
// tuiBroken is whether the interactive mode failed to start on this
// machine lately (claudetui.BrokenSince): a run is -p at once, rather
// than its helper's finding so after it starts.
func tuiBroken() bool {
_, ok := claudetui.BrokenSince()
return ok
// claudeTUIErr is the error a request gets that Claude Code's interactive
// mode can't take, or didn't start for: it never falls back to -p, which
// the plan counts as another client's request and which starts without
// the interactive mode's cache.
func claudeTUIErr(why string) error {
return fmt.Errorf("Claude Code's interactive mode can't answer this request (%s), and magpie never runs it as claude -p instead; turning the interactive mode off in Settings › Models › Replies runs every request as -p", why)
}
// cliControl shares the SDK reply dispatcher with rewind, so unrelated or
@@ -1476,6 +1453,12 @@ func (b *subscriptionBridge) resume(req *Request, owner string) (*subscriptionRu
if run == nil {
return nil, nil
}
if !run.tui && claudeTUIOn() {
// a -p run from before the interactive mode was turned on goes
// on with no turn more
run.abortFor("Claude Code's interactive mode is on, and this run is -p")
return nil, nil
}
req.clientCache.selected(false)
if run.tui && back != "" && urlImages(since) == 0 {
// the interactive mode can't be taken back: a run of its own goes
@@ -2120,8 +2103,8 @@ func (r *subscriptionRun) noteLines(uuid, model string, ids []string) {
// unshelve is. nil when the run is gone, the conversation before the reply
// isn't the one it answered, or the run can't be resumed so: a client's
// own cache marks, Claude Code in WSL (no session on disk), a session
// taken back since (rewound), or, where runs must be the interactive mode,
// a -p run's session, as its branch is -p too.
// taken back since (rewound), or, with the interactive mode on, a -p
// run's session, as its branch is -p too.
func (b *subscriptionBridge) branch(req *Request, owner string) *savedSession {
if req.clientCache != nil {
return nil
@@ -2168,7 +2151,7 @@ func (b *subscriptionBridge) branch(req *Request, owner string) *savedSession {
}
}
sid, sessions := run.sessionID, slices.Clone(run.sessions)
usable := !run.closed && !run.rewound && run.lean == req.leanPrompt && !run.clientMarks && (run.tui || !claudeTUIOnly())
usable := !run.closed && !run.rewound && run.lean == req.leanPrompt && !run.clientMarks && (run.tui || !claudeTUIOn())
run.mu.Unlock()
if at == "" {
continue
@@ -2804,15 +2787,12 @@ func cleanClaudeEnv(env []string) []string {
type lockedWriter struct{ run *subscriptionRun }
func (w *lockedWriter) Write(p []byte) (int, error) {
// the interactive mode's helper says on its own line why it became -p
// (claudetui.Run), which no error carries
// the interactive mode's helper says on its own line why it ended
// (claudetui.Run)
if bytes.Contains(p, []byte("claude-tui: ")) {
for _, l := range strings.Split(string(p), "\n") {
if why, ok := strings.CutPrefix(l, "claude-tui: "); ok {
log.Printf("claude: %s", why)
if strings.HasSuffix(why, "this run is -p") {
noteClaudeRun("start")
}
}
}
}
@@ -5389,10 +5369,12 @@ func (s *Server) serveSubscription(w http.ResponseWriter, r *http.Request, from
var err error
if name == "Claude Code" && wantsClientCache(r, from) {
req, err = parseAnthropicRequest(body, true)
} else if name == "Claude Code" && classifierClientCache(from, body) {
} else if name == "Claude Code" && classifierClientCache(from, body) && !claudeTUIOn() {
// the classifier never asked for its marks through magpie's
// header: a set the bridge can't keep (a TTL order Anthropic
// would refuse) goes the default way, as before, not refused
// would refuse) goes the default way, as before, not refused; in
// the interactive mode, which can't place them, it goes the
// default way always, Claude Code placing its own
if req, err = parseAnthropicRequest(body, true); err != nil {
req, err = parse(from, body)
}
@@ -217,10 +217,10 @@ wait
// stays the lead's. The cut is a copy of the session's lines as far as
// that reply, a session of its own (bbfatx on X): Claude Code's
// interactive mode doesn't take --resume-session-at, so a branch was -p,
// and read none of the conversation its interactive lead had cached, and
// with "Interactive only" there was no branch.
// and read none of the conversation its interactive lead had cached; with
// the interactive mode on, a -p branch is never run.
func TestClaudeForkBranchesOffTheLeadsSession(t *testing.T) {
for _, mode := range []string{"print", "interactive", "interactive only"} {
for _, mode := range []string{"print", "interactive"} {
t.Run(mode, func(t *testing.T) { forkBranches(t, mode) })
}
}
@@ -328,9 +328,6 @@ FAKE_TUI=interactive exec "$claude" "$@"
claudeTUIHelper = helper
t.Cleanup(func() { claudeTUIHelper = "" })
}
if mode == "interactive only" {
tuiOnly(t, false)
}
provider.ForgetAccounts()
t.Cleanup(provider.ForgetAccounts)
if err := provider.SaveGroup(provider.Group{ID: "orchestrator", Name: "Orchestrator", Members: []string{"claude/claude-opus-5-5"}}); err != nil {
@@ -0,0 +1,100 @@
package gateway
import (
"context"
"os"
"path/filepath"
"strings"
"testing"
"time"
"github.com/yetone/magpie/internal/claudetui"
"github.com/yetone/magpie/internal/settings"
"github.com/yetone/magpie/internal/testenv"
)
// printMode sets the user's ClaudePrintMode (the interactive mode turned
// off) as print says, put back as it was after the test.
func printMode(t *testing.T, print bool) {
t.Helper()
// settings are the package's, not the test's (cleanups run last first,
// so the first call's is the last)
was := settings.Load()
t.Cleanup(func() { _ = settings.Save(was) })
st := settings.Load()
st.ClaudePrintMode = print
if err := settings.Save(st); err != nil {
t.Fatal(err)
}
}
// With the interactive mode on, a request it can't take is refused,
// saying why, and no Claude Code starts: it never runs as -p (the owner,
// 11-01). Turned off, the same request runs as -p.
func TestClaudeTUIOnRefusesPrint(t *testing.T) {
h, started := tuiHelperHarness(t, "")
big := strings.Repeat("the codebase as read so far. ", 15000) // over tuiPromptMost
code, msg := h.askCode("rules", big)
if code == 200 || !strings.Contains(msg, "a first message over 400KB") || !strings.Contains(msg, "never runs it as claude -p") {
t.Fatalf("%d %.300s", code, msg)
}
if runs := h.runs(); len(runs) != 0 {
t.Fatalf("Claude Code ran: %v", runs)
}
if n := helperStarts(started); n != 0 {
t.Fatalf("the helper started %d times for a refused request", n)
}
printMode(t, true)
if code, msg := h.askCode("rules", big); code != 200 {
t.Fatalf("turned off, -p: %d %.300s", code, msg)
}
if n := helperStarts(started); n != 0 {
t.Fatalf("turned off, the helper started %d times", n)
}
}
// With the interactive mode on, a test's or a warm-up's "hi" is said
// through the interactive mode's helper, in stream-json, and its run ends
// at the result; turned off, it runs as -p, with no helper.
func TestAskClaudeTUIOn(t *testing.T) {
h := newReplyHarness(t, "ok")
claudeTUIRuns = true
t.Cleanup(func() { claudeTUIRuns = false })
env := filepath.Join(t.TempDir(), "env")
helper := filepath.Join(t.TempDir(), "magpie")
testenv.Program(t, helper, `#!/bin/sh
[ "$1" = "`+claudetui.Command+`" ] || exit 9
echo "trust=$`+claudetui.TrustEnv+`" >> '`+env+`'
shift; claude=$1; shift
exec "$claude" "$@"
`)
claudeTUIHelper = helper
t.Cleanup(func() { claudeTUIHelper = "" })
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
defer cancel()
if err := askClaude(ctx, "", "haiku"); err != nil {
t.Fatal(err)
}
b, _ := os.ReadFile(env)
if strings.TrimSpace(string(b)) != "trust=1" {
t.Fatalf("the helper was told %q", b)
}
var args, told string
for _, l := range h.runs() {
args, _, _ = strings.Cut(l, "\n")
told = l
}
if want := "-p --output-format stream-json --input-format stream-json --verbose --model haiku --tools --strict-mcp-config --setting-sources "; !strings.Contains(args, want) {
t.Fatalf("Claude Code ran with %q", args)
}
if !strings.Contains(told, `told {"message":{"content":[{"text":"hi","type":"text"}],"role":"user"},"type":"user"}`) {
t.Fatalf("Claude Code was told:\n%s", told)
}
printMode(t, true)
if err := askClaude(ctx, "", "haiku"); err != nil {
t.Fatal(err)
}
if b, _ := os.ReadFile(env); strings.Count(string(b), "trust=") != 1 {
t.Fatalf("turned off, the helper ran again: %q", b)
}
}
-145
View File
@@ -1,145 +0,0 @@
package gateway
import (
"context"
"os"
"path/filepath"
"strings"
"testing"
"time"
"github.com/yetone/magpie/internal/claudetui"
"github.com/yetone/magpie/internal/settings"
"github.com/yetone/magpie/internal/testenv"
)
// tuiOnly sets the user's "Interactive only" (ClaudeTUIOnly), and
// ClaudePrintMode as print says.
func tuiOnly(t *testing.T, print bool) {
t.Helper()
// settings are the package's, not the test's: put back as they were
// (cleanups run last first, so the first call's is the last)
was := settings.Load()
t.Cleanup(func() { _ = settings.Save(was) })
st := settings.Load()
st.ClaudeTUIOnly, st.ClaudePrintMode = true, print
if err := settings.Save(st); err != nil {
t.Fatal(err)
}
}
// With "Interactive only", a request that would run as -p is refused,
// saying why, and no Claude Code starts; the interactive mode turned off
// too, -p wins.
func TestClaudeTUIOnlyRefusesPrint(t *testing.T) {
h := newReplyHarness(t, "ok")
// no shim: every run here would be -p (claudeMachineWhy)
claudeTUIRuns = false
tuiOnly(t, false)
code, msg := h.askCode("rules", "hi")
if code == 200 || !strings.Contains(msg, "would run as claude -p (no shim)") || !strings.Contains(msg, "only Claude Code's interactive mode") {
t.Fatalf("%d %s", code, msg)
}
if runs := h.runs(); len(runs) != 0 {
t.Fatalf("Claude Code ran: %v", runs)
}
tuiOnly(t, true)
if code, msg := h.askCode("rules", "hi"); code != 200 {
t.Fatalf("turned off, -p: %d %s", code, msg)
}
}
// With "Interactive only", the helper is told never to become -p, and one
// that never answers initialize ends the turn with an error rather than
// a -p try; the next run tries the interactive mode again, marked broken
// or not.
func TestClaudeTUIOnlyHungHelperNoPrint(t *testing.T) {
was := tuiInitWait
tuiInitWait = time.Second
t.Cleanup(func() { tuiInitWait = was })
h, started := tuiHelperHarness(t, "exec sleep 600")
tuiOnly(t, false)
code, msg := h.askCode("rules", "hi")
if code == 200 || !strings.Contains(msg, "interactive mode didn't start") {
t.Fatalf("%d %s", code, msg)
}
if runs := h.runs(); len(runs) != 0 {
t.Fatalf("a -p Claude Code ran: %v", runs)
}
if n := helperStarts(started); n != 1 {
t.Fatalf("the helper started %d times, want once", n)
}
h.askCode("other rules", "hello")
if n := helperStarts(started); n != 2 {
t.Fatalf("the helper started %d times, want twice: a run after the mark went to -p", n)
}
}
// The helper is handed OnlyEnv with "Interactive only", and not without.
func TestClaudeTUIOnlyTellsHelper(t *testing.T) {
h := newReplyHarness(t, "ok")
claudeTUIRuns = true
t.Cleanup(func() { claudeTUIRuns = false })
env := filepath.Join(t.TempDir(), "env")
helper := filepath.Join(t.TempDir(), "magpie")
testenv.Program(t, helper, `#!/bin/sh
echo "only=$`+claudetui.OnlyEnv+` trust=$`+claudetui.TrustEnv+`" >> '`+env+`'
shift; claude=$1; shift
exec "$claude" "$@"
`)
claudeTUIHelper = helper
t.Cleanup(func() { claudeTUIHelper = "" })
h.ask("rules", "hi")
tuiOnly(t, false)
h.ask("other rules", "hello")
b, _ := os.ReadFile(env)
if got := strings.Split(strings.TrimSpace(string(b)), "\n"); len(got) != 2 || got[0] != "only= trust=1" || got[1] != "only=1 trust=1" {
t.Fatalf("the helper was told %q", got)
}
}
// With "Interactive only", a test's or a warm-up's "hi" is said through
// the interactive mode's helper, in stream-json, and its run ends at the
// result; one the machine can't run interactively is refused.
func TestAskClaudeTUIOnly(t *testing.T) {
h := newReplyHarness(t, "ok")
claudeTUIRuns = true
t.Cleanup(func() { claudeTUIRuns = false })
env := filepath.Join(t.TempDir(), "env")
helper := filepath.Join(t.TempDir(), "magpie")
testenv.Program(t, helper, `#!/bin/sh
[ "$1" = "`+claudetui.Command+`" ] || exit 9
echo "only=$`+claudetui.OnlyEnv+` trust=$`+claudetui.TrustEnv+`" >> '`+env+`'
shift; claude=$1; shift
exec "$claude" "$@"
`)
claudeTUIHelper = helper
t.Cleanup(func() { claudeTUIHelper = "" })
tuiOnly(t, false)
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
defer cancel()
if err := askClaude(ctx, "", "haiku"); err != nil {
t.Fatal(err)
}
b, _ := os.ReadFile(env)
if strings.TrimSpace(string(b)) != "only=1 trust=1" {
t.Fatalf("the helper was told %q", b)
}
var args, told string
for _, l := range h.runs() {
args, _, _ = strings.Cut(l, "\n")
told = l
}
for _, want := range []string{"-p --output-format stream-json --input-format stream-json --verbose --model haiku --tools --strict-mcp-config --setting-sources "} {
if !strings.Contains(args, want) {
t.Fatalf("Claude Code ran with %q", args)
}
}
if !strings.Contains(told, `told {"message":{"content":[{"text":"hi","type":"text"}],"role":"user"},"type":"user"}`) {
t.Fatalf("Claude Code was told:\n%s", told)
}
claudeTUIRuns = false
if err := askClaude(ctx, "", "haiku"); err == nil || !strings.Contains(err.Error(), "would run as claude -p (no shim)") {
t.Fatalf("got %v", err)
}
}
+17 -16
View File
@@ -14,8 +14,7 @@ import (
// tuiHelperHarness is a script harness whose runs in Claude Code's
// interactive mode start a stand-in for magpie's claude-tui-helper: it
// notes each start in started, waits as hold says (a shell command), and
// becomes the -p Claude Code it was handed, as the helper does when the
// interactive Claude Code doesn't show its prompt in time.
// runs the stand-in Claude Code it was handed.
func tuiHelperHarness(t *testing.T, hold string) (*resumeHarness, string) {
t.Helper()
h := newReplyHarness(t, "ok")
@@ -52,28 +51,30 @@ func TestClaudeTUISlowStartAnswered(t *testing.T) {
if n := helperStarts(started); n != 1 {
t.Fatalf("the helper started %d times, want once", n)
}
if _, ok := claudetui.BrokenSince(); ok {
t.Fatal("a slow start that answered was marked broken")
}
}
// A helper that never answers initialize is let go, the machine is marked
// as one whose interactive mode doesn't start, and the turn is answered by
// -p: the turn, and the next, never wait on the interactive mode again.
func TestClaudeTUIHungHelperGoesPrint(t *testing.T) {
// A helper that never answers initialize is let go, and the turn fails
// saying the interactive mode didn't start: it is never answered by -p,
// which the plan counts as another client's and which has none of the
// interactive mode's cache (the owner, 11-01). Nothing is marked: the next
// turn tries the interactive mode again.
func TestClaudeTUIHungHelperNeverPrint(t *testing.T) {
was := tuiInitWait
tuiInitWait = time.Second
t.Cleanup(func() { tuiInitWait = was })
h, started := tuiHelperHarness(t, "exec sleep 600")
h.ask("rules", "hi")
code, msg := h.askCode("rules", "hi")
if code == 200 || !strings.Contains(msg, "interactive mode didn't start") || !strings.Contains(msg, "never runs it as claude -p") {
t.Fatalf("%d %s", code, msg)
}
if runs := h.runs(); len(runs) != 0 {
t.Fatalf("a -p Claude Code ran: %v", runs)
}
if n := helperStarts(started); n != 1 {
t.Fatalf("the helper started %d times, want once", n)
}
if _, ok := claudetui.BrokenSince(); !ok {
t.Fatal("a helper that never answered left no mark")
}
h.ask("other rules", "hello")
if n := helperStarts(started); n != 1 {
t.Fatalf("the helper started %d times, want once: a run after the mark went to the interactive mode", n)
h.askCode("other rules", "hello")
if n := helperStarts(started); n != 2 {
t.Fatalf("the helper started %d times, want twice: the next turn didn't try the interactive mode", n)
}
}
+5 -5
View File
@@ -43,7 +43,7 @@ func askClaude(ctx context.Context, configDir, model string) error {
if err != nil {
return err
}
if claudeTUIOnly() {
if claudeTUIOn() {
return askClaudeTUI(ctx, binary, configDir, model)
}
tmp, err := os.MkdirTemp("", "magpie-claude-")
@@ -78,17 +78,17 @@ func askClaude(ctx context.Context, configDir, model string) error {
return nil
}
// askClaudeTUI is askClaude where the user has model requests never be
// -p (ClaudeTUIOnly): the "hi" is said in Claude Code's interactive mode,
// askClaudeTUI is askClaude with the interactive mode on (claudeTUIOn),
// whose model requests are never -p: the "hi" is said in it,
// through its helper as the bridge runs it, and the run ends at its
// result.
func askClaudeTUI(ctx context.Context, binary claudeCLI, configDir, model string) error {
if _, why := claudeMachineWhy(binary); why != "" {
return claudeOnlyErr(why)
return claudeTUIErr(why)
}
if binary.wsl != nil {
if dir := binary.tuiWSLUnread(configDir); dir != "" {
return claudeOnlyErr("Windows can't read " + dir + ", where Claude Code in WSL writes its transcripts")
return claudeTUIErr("Windows can't read " + dir + ", where Claude Code in WSL writes its transcripts")
}
}
tmp, err := os.MkdirTemp("", "magpie-claude-")
+2 -5
View File
@@ -2671,12 +2671,9 @@ body.window .ag-sk-icon { width: 22px; height: 22px; border-radius: 6px; }
/* Claude Code's interactive mode or -p, with why (claudeModeRow) */
.claude-mode { display: contents; }
.cc-run { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; min-height: 26px; }
.cc-pill { display: inline-flex; align-items: center; gap: 7px; height: 26px; padding: 0 10px 0 9px; border-radius: 7px; border: 1px solid var(--line); background: var(--card); font-size: 12px; color: var(--fg); cursor: default; }
.cc-pill:hover { border-color: var(--muted); }
.cc-pill:focus-visible { border-color: var(--muted); }
.cc-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.cc-pill.tui i { background: var(--green); }
.cc-pick .opt { flex: none; }
.cc-said { font-size: 12px; color: var(--muted); }
.cc-said.bad { color: var(--red); }
.cc-tip { position: fixed; z-index: 1000; width: min(400px, calc(100vw - 16px)); padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--card); box-shadow: 0 12px 32px rgba(0, 0, 0, .18); font-size: 12px; line-height: 1.5; color: var(--fg); pointer-events: none; animation: mask-tip .16s var(--ease); }
.cc-m + .cc-m { margin-top: 9px; padding-top: 9px; border-top: 1px solid var(--line-2); }
.cc-m .h { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
+4 -5
View File
@@ -21643,11 +21643,10 @@ function renderReplies(s, keep) {
t("A Claude subscription answers with the agent's own instructions as its system prompt, in place of Claude Code's, about 1K fewer tokens each request. Still the real Claude Code, but its requests look less like Claude Code's own, which can put the account more at risk"),
onOff, s.claudeLeanPrompt ? "on" : "off", (v) => savePrefs({ ...keep, claudeLeanPrompt: v === "on" }));
// a Claude run as Claude Code's interactive mode, -p when off (the plan
// counts a -p request at about twice); only: never -p, failing instead
// counts a -p request at about twice); on, nothing is ever -p
const u = segRow("claudeTuiRow", t("Claude Code's interactive mode"),
t("A Claude subscription runs Claude Code as a person does, in its interactive mode, where the plan counts a request at about half of what -p uses. Off runs it as claude -p. Interactive only never sends a model request as -p: one the interactive mode can't take fails, saying why (reading the plan's allowance asks no model and stays -p)"),
[...onOff, ["only", t("Interactive only")]], s.claudePrintMode ? "off" : s.claudeTUIOnly ? "only" : "on",
(v) => { claudeMode = null; savePrefs({ ...keep, claudePrintMode: v === "off", claudeTUIOnly: v === "only" }); });
t("A Claude subscription runs Claude Code as a person does, in its interactive mode, where the plan counts a request at about half of what -p uses. On, no request ever runs as -p. Off runs every request as claude -p"),
onOff, s.claudePrintMode ? "off" : "on", (v) => { claudeMode = null; savePrefs({ ...keep, claudePrintMode: v === "off" }); });
box.append(r, l, f, k, c, u);
}
@@ -22657,7 +22656,7 @@ function prefsKeep(s) {
redact: !!s.redact, redactPersonal: !!s.redactPersonal, redactKinds: s.redactKinds || {}, redactWords: s.redactWords || [], redactWordsAnyCase: !!s.redactWordsAnyCase, redactWordsWhole: !!s.redactWordsWhole, redactShape: !!s.redactShape, codexWarmup: s.codexWarmup || "",
claudeWarmup: s.claudeWarmup || "", codexWarmAt: s.codexWarmAt || "", claudeWarmAt: s.claudeWarmAt || "",
codexWarmAts: warmTimes(s.codexWarmAts, s.codexWarmAt), claudeWarmAts: warmTimes(s.claudeWarmAts, s.claudeWarmAt), workbuddyCheckin: !!s.workbuddyCheckin, traeCheckin: !!s.traeCheckin, minimaxCheckin: !!s.minimaxCheckin, qoderCheckin: !!s.qoderCheckin, noStats: !!s.noStats, noUsageStats: !!s.noUsageStats, signInLinkOnly: !!s.signInLinkOnly,
memberModel: !!s.memberModel, noLoopGuard: !!s.noLoopGuard, claudeLeanPrompt: !!s.claudeLeanPrompt, claudePrintMode: !!s.claudePrintMode, claudeTUIOnly: !!s.claudeTUIOnly, refusalRetries: s.refusalRetries ?? null,
memberModel: !!s.memberModel, noLoopGuard: !!s.noLoopGuard, claudeLeanPrompt: !!s.claudeLeanPrompt, claudePrintMode: !!s.claudePrintMode, refusalRetries: s.refusalRetries ?? null,
noUpdatePill: !!s.noUpdatePill, noAutoUpdate: !!s.noAutoUpdate, updateEvery: s.updateEvery || 360, autoRestart: !!s.autoRestart, noAutoDownload: !!s.noAutoDownload, updateChannel: s.updateChannel || "",
trayUsage: s.trayUsage || "", trayUsageEvery: s.trayUsageEvery || 3, trayNoLogos: !!s.trayNoLogos, trayNoBird: !!s.trayNoBird, trayPace: !!s.trayPace, trayNoCost: !!s.trayNoCost, trayWindows: s.trayWindows || {}, vision: s.vision || "", visionEffort: s.visionEffort || "", searcherEffort: s.searcherEffort || "", imageGen: s.imageGen || "", imageTimeout: s.imageTimeout || 0, classifyTimeout: s.classifyTimeout || 0, searcher: s.searcher || "", searchFirst: s.searchFirst || "", currency: s.currency || "usd",
chineseUnits: !!s.chineseUnits, usageAlert: s.usageAlert || 0, balanceAlert: s.balanceAlert || 0, resetReminder: s.resetReminder || 0,
+40 -40
View File
@@ -1,31 +1,25 @@
// The Claude Code provider editor's "Claude Code runs as" row: whether a
// Claude subscription's runs are Claude Code's interactive mode (TUI) or
// claude -p, why -p, how the last request went, and on hover what each is
// and what it is good for (the owner, 10-31). app.js imports this with the
// row's first read of /api/claude/mode (claudeModeRow), so it weighs
// nothing on the core.
// claude -p, switched right there, how the last request went, and on hover
// what each is and what it is good for (the owner, 10-31, 11-01). With the
// interactive mode on nothing runs as -p: a request it can't take fails,
// saying why (the owner, 11-01). app.js imports this with the row's first
// read of /api/claude/mode (claudeModeRow), so it weighs nothing on the
// core.
// why a run is -p, by the gateway's code (claudeMachineWhy, claudePrint)
// why the interactive mode can't run here, or is off, by the gateway's
// code (claudeMachineWhy)
const CC_WHY = {
off: "the interactive mode is off in Settings",
broken: "the interactive mode failed to start lately, and is tried again later",
os: "this system can't run the interactive mode",
"wsl-home": "magpie couldn't find the home folder of Claude Code in WSL",
missing: "Claude Code isn't installed on this computer",
start: "the interactive mode didn't start",
safeguards: "the request carried safeguards",
cache: "the client marked its own cache points",
schema: "the request asked for a JSON schema",
image: "the request had an image by its URL",
big: "its first message was over 400KB",
branch: "it branched off another request's conversation, which a sub-agent's first request does",
wslread: "Windows can't read the transcripts of Claude Code in WSL",
};
const ccWhy = (code) => t(CC_WHY[code] || CC_WHY.os);
// ccTip: the two modes side by side, the one in use marked
// ccTip: the two modes side by side, the one chosen marked
let ccTipEl = null;
function ccTip(anchor, tui, only) {
function ccTip(anchor, tui) {
ccTipOff();
const tip = ccTipEl = el("div", "cc-tip");
tip.setAttribute("role", "tooltip");
@@ -44,11 +38,9 @@ function ccTip(anchor, tui, only) {
t("Your plan counts these requests as Claude Code's own use, at about half of the 5-hour allowance that -p uses for the same work.")),
mode(!tui, "claude -p",
t("Claude Code's print mode, the one scripts and the Agent SDK use: a request in, its reply out."),
t("It starts at once, and takes what the interactive mode can't: a JSON schema, an image by its URL, safeguards, a client's own cache points, a first message over 400KB. Such a request runs as -p even with the interactive mode on."),
t("It starts at once, and takes what the interactive mode can't: a JSON schema, an image by its URL, safeguards, a client's own cache points, a first message over 400KB."),
t("The plan counts a -p request at about twice the interactive mode's.")),
el("div", "foot", t(only
? "Interactive only is set in Settings › Models › Replies: nothing runs as -p, and a request the interactive mode can't take, or one it fails to start for, fails saying why."
: "Turned on or off in Settings › Models › Replies. When the interactive mode fails to start, requests run as -p for a while and it is tried again later.")));
el("div", "foot", t("Switched here or in Settings › Models › Replies. With the interactive mode on, nothing ever runs as -p: a request it can't take, or one it fails to start for, fails saying why.")));
document.body.append(tip);
const a = anchor.getBoundingClientRect(), b = tip.getBoundingClientRect();
tip.style.left = Math.max(8, Math.min(a.left, innerWidth - b.width - 8)) + "px";
@@ -64,29 +56,37 @@ function ccTipOff() {
window.claudeModeDraw = function (box, m) {
if (!m) return;
const v = el("div", "cc-run");
const pill = el("span", "cc-pill" + (m.tui ? " tui" : ""));
pill.tabIndex = 0;
// Interactive only where it can't run: nothing runs, as -p or not
pill.append(el("i"), el("span", "", m.tui ? t("Interactive mode (TUI)") : m.only ? t("Interactive only") : "claude -p"));
pill.onmouseenter = pill.onfocus = () => ccTip(pill, m.tui, m.only);
pill.onmouseleave = pill.onblur = ccTipOff;
v.append(pill);
// on unless turned off, whether or not this machine can run it: on where
// it can't, Claude requests fail
const on = m.why !== "off";
const pick = segs([["tui", t("Interactive mode (TUI)")], ["p", "claude -p"]], on ? "tui" : "p", async (id) => {
ccTipOff();
if ((id === "tui") === on) return;
// the settings are read with the Settings page: one not opened yet has
// none to keep
if (!prefs) prefs = state.settings = await api("settings");
await savePrefs({ ...prefsKeep(prefs), claudePrintMode: id === "p" });
claudeMode = await api("claude/mode").catch(() => null);
claudeModeAt = Date.now();
if (box.isConnected) window.claudeModeDraw(box, claudeMode);
});
pick.classList.add("cc-pick");
pick.classList.toggle("tui", m.tui);
// magpie web shows the gateway's, which only its own Settings change
for (const b of pick.querySelectorAll(".opt")) b.disabled = gatewayMode;
// Chromium has no onfocusin property: the events are listened for
pick.onmouseenter = () => ccTip(pick, on);
pick.addEventListener("focusin", () => ccTip(pick, on));
pick.onmouseleave = () => ccTipOff();
pick.addEventListener("focusout", (e) => { if (!pick.contains(e.relatedTarget)) ccTipOff(); });
v.append(pick);
const last = m.last;
let said = "";
if (!m.tui && m.only) said = t("Claude requests fail: {why}", { why: ccWhy(m.why) });
else if (!m.tui) said = ccWhy(m.why);
if (on && !m.tui) said = t("Claude requests fail: {why}", { why: ccWhy(m.why) });
else if (!on) said = t("Every request runs as claude -p");
else if (last && last.tui) said = t("Last request {ago}: interactive mode", { ago: ago(last.at) });
else if (last) said = t("Last request {ago} ran as -p: {why}", { ago: ago(last.at), why: ccWhy(last.why) });
else if (m.only) said = t("Interactive only: a request it can't take fails instead of running as -p");
if (said) v.append(el("span", "cc-said", said));
if (m.why === "off" || (!m.tui && m.only)) {
const b = el("button", "text action", t("Change in Settings"));
b.type = "button";
b.hidden = gatewayMode; // Settings has no such row then
b.onclick = (e) => { ccTipOff(); openSettingsAt(e, "models", "#claudeTuiRow"); };
v.append(b);
}
if (said) v.append(el("span", "cc-said" + (on && !m.tui ? " bad" : ""), said));
box.replaceChildren(...field(t("Claude Code runs as"), v, ""));
};
// the editor going away takes its tip with it
addEventListener("pointerdown", ccTipOff, true);
addEventListener("pointerdown", (e) => { if (!e.target.closest?.(".cc-pick")) ccTipOff(); }, true);
+16 -64
View File
@@ -7,24 +7,15 @@ const I18N = {
"Claude Code runs as": "Claude Code 运行方式",
"Interactive mode (TUI)": "交互模式(TUI)",
"Last request {ago}: interactive mode": "上次请求 {ago}:交互模式",
"Last request {ago} ran as -p: {why}": "上次请求 {ago} 用了 -p:{why}",
"the interactive mode is off in Settings": "设置里关闭了交互模式",
"the interactive mode failed to start lately, and is tried again later": "交互模式最近启动失败,稍后会再试",
"this system can't run the interactive mode": "这个系统不能运行交互模式",
"the interactive mode didn't start": "交互模式没能启动",
"the request carried safeguards": "请求带有安全护栏",
"the client marked its own cache points": "客户端自己标了缓存点",
"the request asked for a JSON schema": "请求要求按 JSON schema 回复",
"the request had an image by its URL": "请求里有按 URL 给的图片",
"its first message was over 400KB": "第一条消息超过 400KB",
"it branched off another request's conversation, which a sub-agent's first request does": "它从另一个请求的对话分出,子代理的第一个请求就是这样",
"Windows can't read the transcripts of Claude Code in WSL": "Windows 读不到 WSL 里 Claude Code 的会话记录",
"magpie opens Claude Code as a person does, in a terminal of its own that you don't see, types each request in and reads the reply from its transcript.": "magpie 像人一样打开 Claude Code:在一个你看不到的终端里输入每个请求,再从它的会话记录里读出回复。",
"Your plan counts these requests as Claude Code's own use, at about half of the 5-hour allowance that -p uses for the same work.": "套餐把这些请求算作 Claude Code 自身的使用,同样的工作只消耗 -p 约一半的 5 小时额度。",
"Claude Code's print mode, the one scripts and the Agent SDK use: a request in, its reply out.": "Claude Code 的打印模式,脚本和 Agent SDK 用的就是它:一个请求进去,一个回复出来。",
"It starts at once, and takes what the interactive mode can't: a JSON schema, an image by its URL, safeguards, a client's own cache points, a first message over 400KB. Such a request runs as -p even with the interactive mode on.": "启动即用,并且支持交互模式做不到的:JSON schema、按 URL 给的图片、安全护栏、客户端自己的缓存点、超过 400KB 的第一条消息。这类请求即使开着交互模式也会用 -p。",
"It starts at once, and takes what the interactive mode can't: a JSON schema, an image by its URL, safeguards, a client's own cache points, a first message over 400KB.": "启动即用,并且支持交互模式做不到的:JSON schema、按 URL 给的图片、安全护栏、客户端自己的缓存点、超过 400KB 的第一条消息。",
"The plan counts a -p request at about twice the interactive mode's.": "套餐对 -p 请求的计量约为交互模式的两倍。",
"Turned on or off in Settings › Models › Replies. When the interactive mode fails to start, requests run as -p for a while and it is tried again later.": "在 设置 › 模型 › 回复 里开关。交互模式启动失败时,请求会先用 -p 一段时间,之后再试交互模式。",
"Switched here or in Settings › Models › Replies. With the interactive mode on, nothing ever runs as -p: a request it can't take, or one it fails to start for, fails saying why.": "可在这里或 设置 › 模型 › 回复 里切换。开着交互模式时,任何请求都不会走 -p:交互模式接不了或启动失败的请求会报错并说明原因。",
"Every request runs as claude -p": "每个请求都以 claude -p 运行",
"MCP router": "MCP 路由",
"in {agents}": "用于 {agents}",
"Browser access": "浏览器访问",
@@ -361,11 +352,8 @@ const I18N = {
"Claude Code's interactive mode": "Claude Code 交互模式",
"magpie couldn't find the home folder of Claude Code in WSL": "magpie 找不到 WSL 里 Claude Code 的主目录",
"Claude Code isn't installed on this computer": "这台电脑上没有安装 Claude Code",
"A Claude subscription runs Claude Code as a person does, in its interactive mode, where the plan counts a request at about half of what -p uses. Off runs it as claude -p. Interactive only never sends a model request as -p: one the interactive mode can't take fails, saying why (reading the plan's allowance asks no model and stays -p)": "Claude 订阅像人一样以交互模式运行 Claude Code,套餐对每次请求的计量约为 -p 的一半。关闭则以 claude -p 运行。仅交互则从不以 -p 发送模型请求:交互模式接不了的请求直接报错并说明原因(读取套餐额度不调用模型,仍走 -p)",
"Interactive only": "仅交互",
"A Claude subscription runs Claude Code as a person does, in its interactive mode, where the plan counts a request at about half of what -p uses. On, no request ever runs as -p. Off runs every request as claude -p": "Claude 订阅像人一样以交互模式运行 Claude Code,套餐对每次请求的计量约为 -p 的一半。开启时,任何请求都不会走 -p。关闭则每个请求都以 claude -p 运行",
"Claude requests fail: {why}": "Claude 请求会报错:{why}",
"Interactive only: a request it can't take fails instead of running as -p": "仅交互:它接不了的请求会直接报错,不会改走 -p",
"Interactive only is set in Settings › Models › Replies: nothing runs as -p, and a request the interactive mode can't take, or one it fails to start for, fails saying why.": "已在 设置 › 模型 › 回复 里设为仅交互:不会有请求走 -p,交互模式接不了或启动失败的请求会报错并说明原因。",
"A Claude subscription answers with the agent's own instructions as its system prompt, in place of Claude Code's, about 1K fewer tokens each request. Still the real Claude Code, but its requests look less like Claude Code's own, which can put the account more at risk": "Claude 订阅以智能体自己的指令作为系统提示词,代替 Claude Code 的,每次请求约少 1K token。仍是真正的 Claude Code,但请求不再那么像 Claude Code 自己发出的,账号风险可能更高",
"Ask again after a refusal": "被拒答后再问",
"When a vendor's safety filter refuses a request before anything is said, how many more accounts or routing group members are asked. Never ask again hands the refusal straight back: Claude Code then switches to its own fallback model, as it does on Anthropic's API": "供应商的安全过滤在还没说出任何内容前拒绝请求时,再换多少个账号或路由组成员去问。选“不再问”会直接把拒答交回:Claude Code 随后会像直连 Anthropic API 时一样,自己换到它的备用模型",
@@ -4363,24 +4351,15 @@ const I18N = {
"Claude Code runs as": "Claude Code 執行方式",
"Interactive mode (TUI)": "互動模式(TUI)",
"Last request {ago}: interactive mode": "上次請求 {ago}:互動模式",
"Last request {ago} ran as -p: {why}": "上次請求 {ago} 用了 -p:{why}",
"the interactive mode is off in Settings": "設定裡關閉了互動模式",
"the interactive mode failed to start lately, and is tried again later": "互動模式最近啟動失敗,稍後會再試",
"this system can't run the interactive mode": "這個系統無法執行互動模式",
"the interactive mode didn't start": "互動模式沒能啟動",
"the request carried safeguards": "請求帶有安全護欄",
"the client marked its own cache points": "用戶端自己標了快取點",
"the request asked for a JSON schema": "請求要求依 JSON schema 回覆",
"the request had an image by its URL": "請求裡有以 URL 提供的圖片",
"its first message was over 400KB": "第一則訊息超過 400KB",
"it branched off another request's conversation, which a sub-agent's first request does": "它從另一個請求的對話分出,子代理的第一個請求就是這樣",
"Windows can't read the transcripts of Claude Code in WSL": "Windows 讀不到 WSL 裡 Claude Code 的對話記錄",
"magpie opens Claude Code as a person does, in a terminal of its own that you don't see, types each request in and reads the reply from its transcript.": "magpie 像人一樣開啟 Claude Code:在一個你看不到的終端機裡輸入每個請求,再從它的對話記錄讀出回覆。",
"Your plan counts these requests as Claude Code's own use, at about half of the 5-hour allowance that -p uses for the same work.": "方案把這些請求算作 Claude Code 本身的使用,同樣的工作只消耗 -p 約一半的 5 小時額度。",
"Claude Code's print mode, the one scripts and the Agent SDK use: a request in, its reply out.": "Claude Code 的列印模式,腳本和 Agent SDK 用的就是它:一個請求進去,一個回覆出來。",
"It starts at once, and takes what the interactive mode can't: a JSON schema, an image by its URL, safeguards, a client's own cache points, a first message over 400KB. Such a request runs as -p even with the interactive mode on.": "啟動即用,並且支援互動模式做不到的:JSON schema、以 URL 提供的圖片、安全護欄、用戶端自己的快取點、超過 400KB 的第一則訊息。這類請求即使開著互動模式也會用 -p。",
"It starts at once, and takes what the interactive mode can't: a JSON schema, an image by its URL, safeguards, a client's own cache points, a first message over 400KB.": "啟動即用,並且支援互動模式做不到的:JSON schema、以 URL 提供的圖片、安全護欄、用戶端自己的快取點、超過 400KB 的第一則訊息。",
"The plan counts a -p request at about twice the interactive mode's.": "方案對 -p 請求的計量約為互動模式的兩倍。",
"Turned on or off in Settings › Models › Replies. When the interactive mode fails to start, requests run as -p for a while and it is tried again later.": "在 設定 › 模型 › 回覆 裡開關。互動模式啟動失敗時,請求會先用 -p 一段時間,之後再試互動模式。",
"Switched here or in Settings › Models › Replies. With the interactive mode on, nothing ever runs as -p: a request it can't take, or one it fails to start for, fails saying why.": "可在這裡或 設定 › 模型 › 回覆 裡切換。開著互動模式時,任何請求都不會走 -p:互動模式接不了或啟動失敗的請求會報錯並說明原因。",
"Every request runs as claude -p": "每個請求都以 claude -p 執行",
"MCP router": "MCP 路由",
"in {agents}": "用於 {agents}",
"Browser access": "瀏覽器存取",
@@ -4725,11 +4704,8 @@ const I18N = {
"Claude Code's interactive mode": "Claude Code 互動模式",
"magpie couldn't find the home folder of Claude Code in WSL": "magpie 找不到 WSL 中 Claude Code 的主目錄",
"Claude Code isn't installed on this computer": "這台電腦上沒有安裝 Claude Code",
"A Claude subscription runs Claude Code as a person does, in its interactive mode, where the plan counts a request at about half of what -p uses. Off runs it as claude -p. Interactive only never sends a model request as -p: one the interactive mode can't take fails, saying why (reading the plan's allowance asks no model and stays -p)": "Claude 訂閱像人一樣以互動模式執行 Claude Code,方案對每次請求的計量約為 -p 的一半。關閉則以 claude -p 執行。僅互動則從不以 -p 傳送模型請求:互動模式接不了的請求直接報錯並說明原因(讀取方案額度不呼叫模型,仍走 -p)",
"Interactive only": "僅互動",
"A Claude subscription runs Claude Code as a person does, in its interactive mode, where the plan counts a request at about half of what -p uses. On, no request ever runs as -p. Off runs every request as claude -p": "Claude 訂閱像人一樣以互動模式執行 Claude Code,方案對每次請求的計量約為 -p 的一半。開啟時,任何請求都不會走 -p。關閉則每個請求都以 claude -p 執行",
"Claude requests fail: {why}": "Claude 請求會報錯:{why}",
"Interactive only: a request it can't take fails instead of running as -p": "僅互動:它接不了的請求會直接報錯,不會改走 -p",
"Interactive only is set in Settings › Models › Replies: nothing runs as -p, and a request the interactive mode can't take, or one it fails to start for, fails saying why.": "已在 設定 › 模型 › 回覆 裡設為僅互動:不會有請求走 -p,互動模式接不了或啟動失敗的請求會報錯並說明原因。",
"A Claude subscription answers with the agent's own instructions as its system prompt, in place of Claude Code's, about 1K fewer tokens each request. Still the real Claude Code, but its requests look less like Claude Code's own, which can put the account more at risk": "Claude 訂閱以代理自己的指令作為系統提示詞,取代 Claude Code 的,每次請求約少 1K token。仍是真正的 Claude Code,但請求不再那麼像 Claude Code 自己發出的,帳號風險可能更高",
"Ask again after a refusal": "被拒答後再問",
"When a vendor's safety filter refuses a request before anything is said, how many more accounts or routing group members are asked. Never ask again hands the refusal straight back: Claude Code then switches to its own fallback model, as it does on Anthropic's API": "供應商的安全過濾在還沒說出任何內容前拒絕請求時,再換多少個帳號或路由組成員去問。選「不再問」會直接把拒答交回:Claude Code 隨後會像直連 Anthropic API 時一樣,自己換到它的備用模型",
@@ -8704,24 +8680,15 @@ const I18N = {
"Claude Code runs as": "Claude Code の実行方式",
"Interactive mode (TUI)": "対話モード(TUI)",
"Last request {ago}: interactive mode": "前回のリクエスト({ago}):対話モード",
"Last request {ago} ran as -p: {why}": "前回のリクエスト({ago})は -p で実行:{why}",
"the interactive mode is off in Settings": "設定で対話モードがオフになっています",
"the interactive mode failed to start lately, and is tried again later": "対話モードが最近起動に失敗しました。後でもう一度試します",
"this system can't run the interactive mode": "このシステムでは対話モードを実行できません",
"the interactive mode didn't start": "対話モードが起動しませんでした",
"the request carried safeguards": "リクエストにセーフガードが含まれていました",
"the client marked its own cache points": "クライアントが独自のキャッシュ位置を指定しました",
"the request asked for a JSON schema": "リクエストが JSON schema での応答を求めました",
"the request had an image by its URL": "リクエストに URL で指定された画像がありました",
"its first message was over 400KB": "最初のメッセージが 400KB を超えていました",
"it branched off another request's conversation, which a sub-agent's first request does": "別のリクエストの会話から分岐しました(サブエージェントの最初のリクエストがそうします)",
"Windows can't read the transcripts of Claude Code in WSL": "Windows から WSL の Claude Code のトランスクリプトを読めません",
"magpie opens Claude Code as a person does, in a terminal of its own that you don't see, types each request in and reads the reply from its transcript.": "magpie は人と同じように Claude Code を開きます。見えない専用のターミナルで各リクエストを入力し、トランスクリプトから応答を読み取ります。",
"Your plan counts these requests as Claude Code's own use, at about half of the 5-hour allowance that -p uses for the same work.": "プランはこれらのリクエストを Claude Code 自身の利用として数え、同じ作業で -p の約半分の 5 時間枠しか使いません。",
"Claude Code's print mode, the one scripts and the Agent SDK use: a request in, its reply out.": "Claude Code の print モードで、スクリプトや Agent SDK が使うものです。リクエストを渡し、応答を受け取ります。",
"It starts at once, and takes what the interactive mode can't: a JSON schema, an image by its URL, safeguards, a client's own cache points, a first message over 400KB. Such a request runs as -p even with the interactive mode on.": "すぐに起動し、対話モードにできないものも扱えます:JSON schema、URL で指定された画像、セーフガード、クライアント独自のキャッシュ位置、400KB を超える最初のメッセージ。こうしたリクエストは対話モードがオンでも -p で実行されます。",
"It starts at once, and takes what the interactive mode can't: a JSON schema, an image by its URL, safeguards, a client's own cache points, a first message over 400KB.": "すぐに起動し、対話モードにできないものも扱えます:JSON schema、URL で指定された画像、セーフガード、クライアント独自のキャッシュ位置、400KB を超える最初のメッセージ。",
"The plan counts a -p request at about twice the interactive mode's.": "プランは -p のリクエストを対話モードの約 2 倍として数えます。",
"Turned on or off in Settings › Models › Replies. When the interactive mode fails to start, requests run as -p for a while and it is tried again later.": "設定 › モデル › 応答 でオン・オフできます。対話モードが起動に失敗すると、しばらく -p で実行し、後でもう一度試します。",
"Switched here or in Settings › Models › Replies. With the interactive mode on, nothing ever runs as -p: a request it can't take, or one it fails to start for, fails saying why.": "ここか 設定 › モデル › 応答 で切り替えられます。対話モードがオンのときは、何も -p では実行しません。対話モードで扱えないリクエストや起動に失敗したリクエストは理由を添えてエラーになります。",
"Every request runs as claude -p": "すべてのリクエストを claude -p で実行します",
"MCP router": "MCP ルーター",
"in {agents}": "{agents} で使用",
"Browser access": "ブラウザからのアクセス",
@@ -9058,11 +9025,8 @@ const I18N = {
"Claude Code's interactive mode": "Claude Code の対話モード",
"magpie couldn't find the home folder of Claude Code in WSL": "magpie は WSL 内の Claude Code のホームフォルダを見つけられませんでした",
"Claude Code isn't installed on this computer": "このコンピュータには Claude Code がインストールされていません",
"A Claude subscription runs Claude Code as a person does, in its interactive mode, where the plan counts a request at about half of what -p uses. Off runs it as claude -p. Interactive only never sends a model request as -p: one the interactive mode can't take fails, saying why (reading the plan's allowance asks no model and stays -p)": "Claude サブスクリプションは人と同じように Claude Code を対話モードで実行し、プランはリクエストを -p の約半分として数えます。オフにすると claude -p で実行します。対話のみにすると、モデルへのリクエストを -p で送ることはありません。対話モードで扱えないリクエストは理由を示してエラーになります(プランの残量の読み取りはモデルを呼ばないため -p のままです)",
"Interactive only": "対話のみ",
"A Claude subscription runs Claude Code as a person does, in its interactive mode, where the plan counts a request at about half of what -p uses. On, no request ever runs as -p. Off runs every request as claude -p": "Claude サブスクリプションは人と同じように Claude Code を対話モードで実行し、プランはリクエストを -p の約半分として数えます。オンのときは、どのリクエストも -p では実行しません。オフにするとすべてのリクエストを claude -p で実行します",
"Claude requests fail: {why}": "Claude へのリクエストはエラーになります:{why}",
"Interactive only: a request it can't take fails instead of running as -p": "対話のみ:扱えないリクエストは -p で実行せず、エラーになります",
"Interactive only is set in Settings › Models › Replies: nothing runs as -p, and a request the interactive mode can't take, or one it fails to start for, fails saying why.": "設定 › モデル › 応答 で対話のみに設定されています:-p では何も実行せず、対話モードで扱えないリクエストや起動に失敗したリクエストは理由を添えてエラーになります。",
"A Claude subscription answers with the agent's own instructions as its system prompt, in place of Claude Code's, about 1K fewer tokens each request. Still the real Claude Code, but its requests look less like Claude Code's own, which can put the account more at risk": "Claude サブスクリプションは Claude Code のものの代わりにエージェント自身の指示をシステムプロンプトとして応答し、リクエストごとに約 1K トークン少なくなります。本物の Claude Code のままですが、リクエストが Claude Code 自身のものらしくなくなるため、アカウントのリスクが高まる可能性があります",
"Ask again after a refusal": "拒否のあと聞き直す",
"When a vendor's safety filter refuses a request before anything is said, how many more accounts or routing group members are asked. Never ask again hands the refusal straight back: Claude Code then switches to its own fallback model, as it does on Anthropic's API": "ベンダーの安全フィルターが何も言わないうちにリクエストを拒否したとき、ほかのアカウントやルーティンググループのメンバーにあと何回聞くか。「聞き直さない」は拒否をそのまま返します。Claude Code は Anthropic の API のときと同じく、自分のフォールバックモデルに切り替えます",
@@ -13047,24 +13011,15 @@ const I18N = {
"Claude Code runs as": "Claude Code läuft als",
"Interactive mode (TUI)": "Interaktiver Modus (TUI)",
"Last request {ago}: interactive mode": "Letzte Anfrage {ago}: interaktiver Modus",
"Last request {ago} ran as -p: {why}": "Letzte Anfrage {ago} lief als -p: {why}",
"the interactive mode is off in Settings": "der interaktive Modus ist in den Einstellungen aus",
"the interactive mode failed to start lately, and is tried again later": "der interaktive Modus ist zuletzt nicht gestartet und wird später erneut versucht",
"this system can't run the interactive mode": "dieses System kann den interaktiven Modus nicht ausführen",
"the interactive mode didn't start": "der interaktive Modus ist nicht gestartet",
"the request carried safeguards": "die Anfrage enthielt Safeguards",
"the client marked its own cache points": "der Client hat eigene Cache-Punkte gesetzt",
"the request asked for a JSON schema": "die Anfrage verlangte ein JSON-Schema",
"the request had an image by its URL": "die Anfrage enthielt ein Bild per URL",
"its first message was over 400KB": "die erste Nachricht war größer als 400 KB",
"it branched off another request's conversation, which a sub-agent's first request does": "sie zweigte vom Gespräch einer anderen Anfrage ab, wie die erste Anfrage eines Sub-Agenten",
"Windows can't read the transcripts of Claude Code in WSL": "Windows kann die Transkripte von Claude Code in WSL nicht lesen",
"magpie opens Claude Code as a person does, in a terminal of its own that you don't see, types each request in and reads the reply from its transcript.": "magpie öffnet Claude Code wie ein Mensch, in einem eigenen Terminal, das du nicht siehst, tippt jede Anfrage ein und liest die Antwort aus dem Transkript.",
"Your plan counts these requests as Claude Code's own use, at about half of the 5-hour allowance that -p uses for the same work.": "Dein Plan zählt diese Anfragen als Claude Codes eigene Nutzung, mit etwa der Hälfte des 5-Stunden-Kontingents, das -p für dieselbe Arbeit braucht.",
"Claude Code's print mode, the one scripts and the Agent SDK use: a request in, its reply out.": "Der Print-Modus von Claude Code, den Skripte und das Agent SDK nutzen: eine Anfrage hinein, ihre Antwort heraus.",
"It starts at once, and takes what the interactive mode can't: a JSON schema, an image by its URL, safeguards, a client's own cache points, a first message over 400KB. Such a request runs as -p even with the interactive mode on.": "Er startet sofort und kann, was der interaktive Modus nicht kann: ein JSON-Schema, ein Bild per URL, Safeguards, eigene Cache-Punkte des Clients, eine erste Nachricht über 400 KB. Solche Anfragen laufen auch bei eingeschaltetem interaktivem Modus als -p.",
"It starts at once, and takes what the interactive mode can't: a JSON schema, an image by its URL, safeguards, a client's own cache points, a first message over 400KB.": "Er startet sofort und kann, was der interaktive Modus nicht kann: ein JSON-Schema, ein Bild per URL, Safeguards, eigene Cache-Punkte des Clients, eine erste Nachricht über 400 KB.",
"The plan counts a -p request at about twice the interactive mode's.": "Der Plan zählt eine -p-Anfrage etwa doppelt so hoch wie eine im interaktiven Modus.",
"Turned on or off in Settings › Models › Replies. When the interactive mode fails to start, requests run as -p for a while and it is tried again later.": "Ein- und ausgeschaltet unter Einstellungen › Modelle › Antworten. Startet der interaktive Modus nicht, laufen Anfragen eine Weile als -p, und er wird später erneut versucht.",
"Switched here or in Settings › Models › Replies. With the interactive mode on, nothing ever runs as -p: a request it can't take, or one it fails to start for, fails saying why.": "Hier oder unter Einstellungen › Modelle › Antworten umschaltbar. Mit eingeschaltetem interaktivem Modus läuft nie etwas als -p: Eine Anfrage, die er nicht annehmen kann oder für die er nicht startet, schlägt mit dem Grund fehl.",
"Every request runs as claude -p": "Jede Anfrage läuft als claude -p",
"MCP router": "MCP-Router",
"in {agents}": "in {agents}",
"Browser access": "Browserzugriff",
@@ -13401,11 +13356,8 @@ const I18N = {
"Claude Code's interactive mode": "Interaktiver Modus von Claude Code",
"magpie couldn't find the home folder of Claude Code in WSL": "magpie hat den Home-Ordner von Claude Code in WSL nicht gefunden",
"Claude Code isn't installed on this computer": "Claude Code ist auf diesem Computer nicht installiert",
"A Claude subscription runs Claude Code as a person does, in its interactive mode, where the plan counts a request at about half of what -p uses. Off runs it as claude -p. Interactive only never sends a model request as -p: one the interactive mode can't take fails, saying why (reading the plan's allowance asks no model and stays -p)": "Ein Claude-Abo führt Claude Code wie ein Mensch im interaktiven Modus aus, wo der Plan eine Anfrage mit etwa der Hälfte von -p anrechnet. Aus führt es als claude -p aus. Nur interaktiv sendet nie eine Modellanfrage als -p: Eine, die der interaktive Modus nicht annehmen kann, schlägt mit Grund fehl (das Lesen des Plan-Kontingents fragt kein Modell und bleibt -p)",
"Interactive only": "Nur interaktiv",
"A Claude subscription runs Claude Code as a person does, in its interactive mode, where the plan counts a request at about half of what -p uses. On, no request ever runs as -p. Off runs every request as claude -p": "Ein Claude-Abo führt Claude Code wie ein Mensch im interaktiven Modus aus, wo der Plan eine Anfrage mit etwa der Hälfte von -p anrechnet. Ein: Keine Anfrage läuft je als -p. Aus führt jede Anfrage als claude -p aus",
"Claude requests fail: {why}": "Claude-Anfragen schlagen fehl: {why}",
"Interactive only: a request it can't take fails instead of running as -p": "Nur interaktiv: Eine Anfrage, die er nicht annehmen kann, schlägt fehl, statt als -p zu laufen",
"Interactive only is set in Settings › Models › Replies: nothing runs as -p, and a request the interactive mode can't take, or one it fails to start for, fails saying why.": "Nur interaktiv ist unter Einstellungen › Modelle › Antworten eingestellt: Nichts läuft als -p, und eine Anfrage, die der interaktive Modus nicht annehmen kann oder für die er nicht startet, schlägt mit dem Grund fehl.",
"A Claude subscription answers with the agent's own instructions as its system prompt, in place of Claude Code's, about 1K fewer tokens each request. Still the real Claude Code, but its requests look less like Claude Code's own, which can put the account more at risk": "Ein Claude-Abo antwortet mit den eigenen Anweisungen des Agenten als Systemprompt statt mit dem von Claude Code, etwa 1K Token weniger pro Anfrage. Weiterhin das echte Claude Code, aber seine Anfragen sehen Claude Codes eigenen weniger ähnlich, was das Konto stärker gefährden kann",
"Ask again after a refusal": "Nach einer Ablehnung erneut fragen",
"When a vendor's safety filter refuses a request before anything is said, how many more accounts or routing group members are asked. Never ask again hands the refusal straight back: Claude Code then switches to its own fallback model, as it does on Anthropic's API": "Lehnt der Sicherheitsfilter eines Anbieters eine Anfrage ab, bevor etwas gesagt wurde: wie viele weitere Konten oder Mitglieder der Routing-Gruppe gefragt werden. Nie gibt die Ablehnung direkt zurück: Claude Code wechselt dann selbst zu seinem Ausweichmodell, wie bei Anthropics API",
+76 -97
View File
@@ -1,22 +1,21 @@
// Run with Node's test runner and Playwright on the module path; see README.md.
// A Claude subscription's editor says whether its requests run Claude
// Code's interactive mode (TUI) or claude -p, and hovering it shows what
// each is and what each is good for (the owner, 10-31). Here:
// - on, its last request interactive: a green pill naming the interactive
// mode, and the last request said;
// - on, its last request -p for a JSON schema: why that one was -p;
// - turned off: the pill says claude -p and why, and Change in Settings
// opens Settings › Models at the row that turns it on;
// - hovering or focusing the pill shows both modes, the one in use marked,
// each with its advantage, inside the window; moving away hides it;
// - Claude Code in WSL whose home wasn't found says so;
// - Interactive only: a request it can't take fails, and the card says
// nothing runs as -p; where it can't run, the pill names Interactive
// only (never claude -p), says Claude requests fail and why, and
// Change in Settings goes to the row;
// Code's interactive mode (TUI) or claude -p, switches between them right
// there (the owner, 11-01), and hovering it shows what each is and what
// each is good for (the owner, 10-31). Here:
// - on, its last request interactive: TUI pressed, the last request said;
// - hovering or focusing the switch shows both modes, the one chosen
// marked, each with its advantage, inside the window, and says nothing
// ever runs as -p with the interactive mode on; moving away hides it;
// - turned off: claude -p pressed, every request said to run as it;
// pressing TUI saves claudePrintMode false with the rest kept, reads the
// mode again and draws TUI pressed; pressing claude -p turns it back;
// - on where it can't run (Claude Code in WSL whose home wasn't found):
// TUI pressed, and Claude requests are said to fail, and why;
// - another subscription (Codex), and Only switch, which serves nothing,
// have no such row, and /api/claude/mode isn't read for them.
// The mode is read from /api/claude/mode once as the editor opens.
// The mode is read from /api/claude/mode as the editor opens, and again
// after a switch.
// Chromium and WebKit, 900 and 420 wide, in every language, the API faked.
const assert = require("node:assert/strict");
const fs = require("node:fs/promises");
@@ -34,31 +33,41 @@ const codex = { id: "codex", name: "Codex", icon: "codex", models: [{ id: "gpt-6
const RUNS = {
tui: { tui: true, last: { tui: true, at: ago(3) } },
schema: { tui: true, last: { tui: false, why: "schema", at: ago(3) } },
off: { tui: false, why: "off", last: { tui: false, why: "off", at: ago(3) } },
wsl: { tui: false, why: "wsl-home", wsl: true },
only: { tui: true, only: true },
onlyBroken: { tui: false, why: "broken", only: true },
};
// each language's words, as the i18n table has them
const W = {
en: { row: "Claude Code runs as", tui: "Interactive mode (TUI)", inUse: "In use", lastTui: "interactive mode", schema: "the request asked for a JSON schema", off: "the interactive mode is off in Settings", change: "Change in Settings", wsl: "WSL" },
zh: { row: "Claude Code 运行方式", tui: "交互模式(TUI)", inUse: "使用中", lastTui: "交互模式", schema: "请求要求按 JSON schema 回复", off: "设置里关闭了交互模式", change: "在设置中修改", wsl: "WSL" },
"zh-TW": { row: "Claude Code 執行方式", tui: "互動模式(TUI)", inUse: "使用中", lastTui: "互動模式", schema: "請求要求依 JSON schema 回覆", off: "設定裡關閉了互動模式", change: "在設定中修改", wsl: "WSL" },
ja: { row: "Claude Code の実行方式", tui: "対話モード(TUI)", inUse: "使用中", lastTui: "対話モード", schema: "リクエストが JSON schema での応答を求めました", off: "設定で対話モードがオフになっています", change: "設定で変更", wsl: "WSL" },
de: { row: "Claude Code läuft als", tui: "Interaktiver Modus (TUI)", inUse: "In Verwendung", lastTui: "interaktiver Modus", schema: "die Anfrage verlangte ein JSON-Schema", off: "der interaktive Modus ist in den Einstellungen aus", change: "In den Einstellungen ändern", wsl: "WSL" },
en: { row: "Claude Code runs as", tui: "Interactive mode (TUI)", inUse: "In use", lastTui: "interactive mode", allP: "Every request runs as claude -p", wsl: "WSL" },
zh: { row: "Claude Code 运行方式", tui: "交互模式(TUI)", inUse: "使用中", lastTui: "交互模式", allP: "每个请求都以 claude -p 运行", wsl: "WSL" },
"zh-TW": { row: "Claude Code 執行方式", tui: "互動模式(TUI)", inUse: "使用中", lastTui: "互動模式", allP: "每個請求都以 claude -p 執行", wsl: "WSL" },
ja: { row: "Claude Code の実行方式", tui: "対話モード(TUI)", inUse: "使用中", lastTui: "対話モード", allP: "すべてのリクエストを claude -p で実行します", wsl: "WSL" },
de: { row: "Claude Code läuft als", tui: "Interaktiver Modus (TUI)", inUse: "In Verwendung", lastTui: "interaktiver Modus", allP: "Jede Anfrage läuft als claude -p", wsl: "WSL" },
};
function serve(lang, run, switchOnly, reads) {
const settings = { lang, theme: "light", redact: true, claudePrintMode: run.why === "off" };
return async (route) => {
const url = new URL(route.request().url());
const json = (data) => route.fulfill({ json: data });
if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:false};` });
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
if (url.pathname === "/api/state") return json({ agents: [], profiles: [], settings: { lang, theme: "light", claudePrintMode: run.why === "off" } });
if (url.pathname === "/api/state") return json({ agents: [], profiles: [], settings });
if (url.pathname === "/api/settings") {
if (route.request().method() === "POST") {
reads.saved.push(JSON.parse(route.request().postData()));
Object.assign(settings, reads.saved.at(-1));
}
return json(settings);
}
if (url.pathname === "/api/providers") return json({ providers: [claude(switchOnly), codex], presets: [], excluded: [], gateway: { running: true, window: true }, plugins: [] });
if (url.pathname === "/api/claude/mode") { reads.n++; return json(run); }
// the mode as the setting has it now: turned on, the machine's own
if (url.pathname === "/api/claude/mode") {
reads.n++;
if (settings.claudePrintMode) return json(RUNS.off);
return json(run.why === "off" ? { tui: true } : run);
}
if (url.pathname === "/api/groups") return json({ groups: [], pools: [] });
if (url.pathname.startsWith("/api/")) return json({});
if (!/^\/[\w./-]*$/.test(url.pathname) || url.host !== "magpie.test") return route.fulfill({ status: 404, body: "" });
@@ -72,7 +81,7 @@ async function openEditor(browser, lang, run, { id = "claude", width = 900, swit
const page = await (await browser.newContext({ viewport: { width, height: 760 } })).newPage();
page.setDefaultTimeout(5000);
page.setDefaultNavigationTimeout(60000);
const errors = [], reads = { n: 0 };
const errors = [], reads = { n: 0, saved: [] };
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang, run, switchOnly, reads));
await page.goto("http://magpie.test/?view=providers");
@@ -96,15 +105,16 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
const { page, errors, reads } = await openEditor(browser, lang, RUNS.tui, { width });
const row = runRow(page);
await row.waitFor();
const tr = (k, v) => page.evaluate(([k, v]) => t(k, v), [k, v]);
assert.equal((await row.locator(":scope > label").textContent()).trim(), w.row);
assert(await row.locator(":scope > label").evaluate((l) => l.compareDocumentPosition(document.querySelector("#modal .accts")) & Node.DOCUMENT_POSITION_FOLLOWING), "the row is above the accounts");
const pill = row.locator(".cc-pill");
assert.equal(await pill.evaluate((e) => e.classList.contains("tui")), true, "the pill is the interactive mode's");
assert.equal((await pill.textContent()).trim(), w.tui);
const pick = row.locator(".cc-pick");
assert.deepEqual(await pick.locator(".opt").evaluateAll((bs) => bs.map((b) => [b.textContent.trim(), b.getAttribute("aria-pressed"), b.disabled])),
[[w.tui, "true", false], ["claude -p", "false", false]], "TUI pressed, both can be pressed");
assert(await pick.evaluate((e) => { const r = e.getBoundingClientRect(); return r.width > 0 && r.right <= innerWidth + 1; }), `the switch fits at ${width}`);
assert.match(await row.locator(".cc-said").textContent(), new RegExp(w.lastTui.replace(/[()]/g, "\\$&") + "$"));
assert.equal(await row.locator("button", { hasText: w.change }).count(), 0, "nothing to change while it's on");
assert.equal(await page.locator(".cc-tip").count(), 0);
await pill.hover();
await pick.hover();
const tip = page.locator(".cc-tip");
await tip.waitFor();
const modes = await tip.locator(".cc-m").evaluateAll((ms) => ms.map((m) => ({ on: m.classList.contains("on"), name: m.querySelector(".h b").textContent, now: m.querySelector(".now")?.textContent || "", good: m.querySelectorAll("p.good").length, bad: m.querySelectorAll("p.bad").length })));
@@ -112,100 +122,69 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
{ on: true, name: w.tui, now: w.inUse, good: 1, bad: 0 },
{ on: false, name: "claude -p", now: "", good: 1, bad: 1 },
]);
// nothing in the card says a request falls back to -p (the owner, 11-01)
assert.equal((await tip.locator(".foot").textContent()).trim(), await tr("Switched here or in Settings › Models › Replies. With the interactive mode on, nothing ever runs as -p: a request it can't take, or one it fails to start for, fails saying why."));
assert.equal((await tip.locator(".cc-m").nth(1).locator("p.good").textContent()).trim(), await tr("It starts at once, and takes what the interactive mode can't: a JSON schema, an image by its URL, safeguards, a client's own cache points, a first message over 400KB."));
const box = await tip.boundingBox();
assert(box.x >= 0 && box.y >= 0 && box.x + box.width <= width && box.y + box.height <= 760, `the card is inside the window: ${JSON.stringify(box)}`);
if (lang !== "en") {
// every line of the card is in the reader's language
const text = await tip.textContent();
assert(!/magpie opens Claude Code as a person does|Your plan counts|It starts at once|Turned on or off in Settings/.test(text), `English left in the card: ${text}`);
assert(!/magpie opens Claude Code as a person does|Your plan counts|It starts at once|Switched here/.test(text), `English left in the card: ${text}`);
}
await page.mouse.move(5, 5);
await tip.waitFor({ state: "detached" });
// the keyboard reaches it too
await pill.focus();
await pick.locator(".opt").first().focus();
await tip.waitFor();
assert.equal(reads.n, 1, "the mode is read once, not on each draw");
assert.deepEqual(errors, []);
});
if (width !== 900) continue;
test(`${engine} ${lang}: a request that was -p for a JSON schema says so`, async (t) => {
test(`${engine} ${lang}: turned off, it says every request is -p, and switches to TUI and back right there`, async (t) => {
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
t.after(() => browser.close());
const { page, errors } = await openEditor(browser, lang, RUNS.schema);
const { page, errors, reads } = await openEditor(browser, lang, RUNS.off);
const row = runRow(page);
await row.waitFor();
assert.equal(await row.locator(".cc-pill.tui").count(), 1, "still the interactive mode");
assert((await row.locator(".cc-said").textContent()).endsWith(w.schema), "why the last one was -p");
assert.deepEqual(errors, []);
});
test(`${engine} ${lang}: turned off, it says claude -p and why, and goes to the setting`, async (t) => {
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
t.after(() => browser.close());
const { page, errors } = await openEditor(browser, lang, RUNS.off);
const row = runRow(page);
await row.waitFor();
const pill = row.locator(".cc-pill");
assert.equal(await pill.evaluate((e) => e.classList.contains("tui")), false);
assert.equal((await pill.textContent()).trim(), "claude -p");
assert.equal((await row.locator(".cc-said").textContent()).trim(), w.off);
await pill.hover();
const opt = (i) => row.locator(".cc-pick .opt").nth(i);
const pressed = () => row.locator(".cc-pick .opt").evaluateAll((bs) => bs.map((b) => b.getAttribute("aria-pressed")));
assert.deepEqual(await pressed(), ["false", "true"], "claude -p pressed");
assert.equal((await row.locator(".cc-said").textContent()).trim(), w.allP);
await opt(1).hover();
await page.locator(".cc-tip").waitFor();
assert.deepEqual(await page.locator(".cc-tip .cc-m").evaluateAll((ms) => ms.map((m) => m.classList.contains("on"))), [false, true], "-p is the one in use");
await row.locator("button", { hasText: w.change }).click();
await page.locator("#view-settings").waitFor();
// the row that turns it on, lit, and still the page's after it lit
await page.locator("#view-settings #claudeTuiRow.flash").waitFor();
await page.waitForTimeout(300);
assert(await page.locator("#claudeTuiRow.flash").isVisible(), "the interactive mode's row is shown, lit");
assert.equal(await page.locator(".cc-tip").count(), 0, "the card went with the editor");
await opt(0).click();
for (let i = 0; i < 100 && reads.n < 2; i++) await page.waitForTimeout(50);
await page.waitForFunction(() => document.querySelector("#modal .cc-pick .opt")?.getAttribute("aria-pressed") === "true");
assert.equal(reads.saved.length, 1, "saved once");
assert.equal(reads.saved[0].claudePrintMode, false);
assert.equal(reads.saved[0].redact, true, "the rest of the settings kept");
assert(!("claudeTUIOnly" in reads.saved[0]), "the retired setting isn't sent");
assert.equal(reads.n, 2, "the mode is read again after the switch");
assert.equal(await row.locator(".cc-said").count(), 0, "nothing to say before a request has run");
assert.equal(await page.locator("#modal").count(), 1, "the editor stays open");
await opt(1).click();
for (let i = 0; i < 100 && reads.n < 3; i++) await page.waitForTimeout(50);
assert.equal(reads.saved[1]?.claudePrintMode, true, "and back to -p");
await page.waitForFunction(() => document.querySelectorAll("#modal .cc-pick .opt")[1]?.getAttribute("aria-pressed") === "true");
assert.equal((await row.locator(".cc-said").textContent()).trim(), w.allP);
assert.deepEqual(errors, []);
});
test(`${engine} ${lang}: Interactive only says a request fails rather than running as -p`, async (t) => {
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
t.after(() => browser.close());
const { page, errors } = await openEditor(browser, lang, RUNS.only);
const row = runRow(page);
await row.waitFor();
const tr = (k, v) => page.evaluate(([k, v]) => t(k, v), [k, v]);
assert.equal(await row.locator(".cc-pill.tui").count(), 1);
assert.equal((await row.locator(".cc-said").textContent()).trim(), await tr("Interactive only: a request it can't take fails instead of running as -p"));
assert.equal(await row.locator("button", { hasText: w.change }).count(), 0);
await row.locator(".cc-pill").hover();
const foot = await tr("Interactive only is set in Settings › Models › Replies: nothing runs as -p, and a request the interactive mode can't take, or one it fails to start for, fails saying why.");
assert.equal((await page.locator(".cc-tip .foot").textContent()).trim(), foot);
if (lang !== "en") assert(!/^Interactive only/.test(foot), `not translated: ${foot}`);
assert.deepEqual(errors, []);
});
test(`${engine} ${lang}: Interactive only where it can't run says Claude requests fail, and why`, async (t) => {
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
t.after(() => browser.close());
const { page, errors } = await openEditor(browser, lang, RUNS.onlyBroken);
const row = runRow(page);
await row.waitFor();
const tr = (k, v) => page.evaluate(([k, v]) => t(k, v), [k, v]);
const pill = row.locator(".cc-pill");
assert.equal(await pill.evaluate((e) => e.classList.contains("tui")), false);
assert.equal((await pill.textContent()).trim(), await tr("Interactive only"), "never claude -p: nothing runs as it");
const why = await tr("the interactive mode failed to start lately, and is tried again later");
assert.equal((await row.locator(".cc-said").textContent()).trim(), await tr("Claude requests fail: {why}", { why }));
if (lang !== "en") assert(!/Claude requests fail/.test(await row.locator(".cc-said").textContent()));
// the way out is the setting
await row.locator("button", { hasText: w.change }).click();
await page.locator("#view-settings #claudeTuiRow.flash").waitFor();
assert.deepEqual(errors, []);
});
test(`${engine} ${lang}: Claude Code in WSL whose home wasn't found says so`, async (t) => {
test(`${engine} ${lang}: on where it can't run, Claude requests are said to fail, and why`, async (t) => {
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
t.after(() => browser.close());
const { page, errors } = await openEditor(browser, lang, RUNS.wsl);
const row = runRow(page);
await row.waitFor();
assert.match(await row.locator(".cc-said").textContent(), new RegExp(w.wsl));
assert.equal(await row.locator("button", { hasText: w.change }).count(), 0);
const tr = (k, v) => page.evaluate(([k, v]) => t(k, v), [k, v]);
assert.equal(await row.locator(".cc-pick .opt").first().getAttribute("aria-pressed"), "true", "TUI is still the one chosen: never -p");
const said = (await row.locator(".cc-said.bad").textContent()).trim();
assert.equal(said, await tr("Claude requests fail: {why}", { why: await tr("magpie couldn't find the home folder of Claude Code in WSL") }));
assert.match(said, new RegExp(w.wsl));
if (lang !== "en") assert(!/Claude requests fail|couldn't find/.test(said), said);
assert.deepEqual(errors, []);
});
}
+15 -19
View File
@@ -1,10 +1,10 @@
// Run with Node's test runner and Playwright on the module path; see README.md.
// Settings › Models › Replies: Claude Code's interactive mode is On, says
// what it saves, that Off is -p and that Interactive only never is; Off
// saves claudePrintMode with the rest of the settings kept, the page not
// moved by the click, and Interactive only saves claudeTUIOnly with -p
// turned back on. In English, Chinese, Japanese and German, 1100 and 420
// wide.
// what it saves, that On never runs -p and Off always does; Off saves
// claudePrintMode with the rest of the settings kept, the page not moved
// by the click, and On turns -p back off. There is no third choice: the
// interactive mode on never falls back to -p (the owner, 11-01). In
// English, Chinese, Japanese and German, 1100 and 420 wide.
const assert = require("node:assert/strict");
const fs = require("node:fs/promises");
const path = require("node:path");
@@ -14,10 +14,10 @@ const { watchSettingsReads, settingsDrawn } = require("./reader.cjs");
const assets = path.resolve(__dirname, "../assets");
const words = {
en: { name: "Claude Code's interactive mode", head: "Replies", off: "Off", on: "On", only: "Interactive only", sub: "about half", risk: "claude -p" },
zh: { name: "Claude Code 交互模式", head: "回复", off: "关闭", on: "开启", only: "仅交互", sub: "约为 -p 的一半", risk: "claude -p" },
ja: { name: "Claude Code の対話モード", head: "応答", off: "オフ", on: "オン", only: "対話のみ", sub: "-p の約半分", risk: "claude -p" },
de: { name: "Interaktiver Modus von Claude Code", head: "Antworten", off: "Aus", on: "An", only: "Nur interaktiv", sub: "Hälfte von -p", risk: "claude -p" },
en: { name: "Claude Code's interactive mode", head: "Replies", off: "Off", on: "On", sub: "about half", risk: "claude -p" },
zh: { name: "Claude Code 交互模式", head: "回复", off: "关闭", on: "开启", sub: "约为 -p 的一半", risk: "claude -p" },
ja: { name: "Claude Code の対話モード", head: "応答", off: "オフ", on: "オン", sub: "-p の約半分", risk: "claude -p" },
de: { name: "Interaktiver Modus von Claude Code", head: "Antworten", off: "Aus", on: "An", sub: "Hälfte von -p", risk: "claude -p" },
};
function serve(lang, saved) {
@@ -83,10 +83,9 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert(fit, `${part} fits at ${width}`);
}
assert.equal(await page.locator("#replyList").evaluate((l) => l.previousElementSibling.textContent.trim()), w.head);
// exact: "On" is in "Interactive only" too
const seg = (text) => row.locator(".segs button", { hasText: new RegExp(`^${text}$`) });
const on = seg(w.on), off = seg(w.off), only = seg(w.only);
assert.equal(await row.locator(".segs button").count(), 3);
const on = seg(w.on), off = seg(w.off);
assert.equal(await row.locator(".segs button").count(), 2, "On and Off, nothing between");
assert.equal(await on.getAttribute("aria-pressed"), "true", "On at first");
const before = await page.evaluate(() => [scrollX, scrollY, document.scrollingElement.scrollTop]);
@@ -100,20 +99,17 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert.equal(saved[0].claudeLeanPrompt, false, "the row beside it kept");
assert.equal(saved[0].redact, true, "the rest kept");
assert.equal(saved[0].lang, lang);
assert.equal(saved[0].claudeTUIOnly, false);
assert(!("claudeTUIOnly" in saved[0]), "the retired setting isn't sent");
assert.deepEqual(await page.evaluate(() => [scrollX, scrollY, document.scrollingElement.scrollTop]), before, "the click moved nothing");
// the save draws the page again: the buttons are the new row's
await page.waitForFunction(() => { const r = document.querySelector("#replyList #claudeTuiRow"); return r && !r.dataset.drawn; });
assert.equal(await seg(w.off).getAttribute("aria-pressed"), "true", "Off once saved");
assert(await only.evaluate((e) => { const r = e.getBoundingClientRect(); return r.width > 0 && r.right <= innerWidth + 1 && e.scrollWidth <= e.clientWidth + 1; }), `Interactive only fits at ${width}`);
await only.click();
await seg(w.on).click();
for (let i = 0; i < 50 && saved.length < 2; i++) await page.waitForTimeout(50);
assert.equal(saved.length, 2, "saved again");
assert.equal(saved[1].claudeTUIOnly, true);
assert.equal(saved[1].claudePrintMode, false, "-p turned back on with it");
assert.equal(await seg(w.only).getAttribute("aria-pressed"), "true", "Interactive only once saved");
assert.equal(await seg(w.on).getAttribute("aria-pressed"), "false");
assert.equal(saved[1].claudePrintMode, false, "-p turned back off");
assert.equal(await seg(w.on).getAttribute("aria-pressed"), "true", "On once saved");
assert.deepEqual(errors, []);
});
}
+8 -11
View File
@@ -369,18 +369,15 @@ type Settings struct {
// default, the run is the shape every Claude Code run has.
ClaudeLeanPrompt bool `json:"claudeLeanPrompt,omitempty"`
// ClaudePrintMode runs a Claude subscription's Claude Code as `claude
// -p` always. Off, as by default, a run is Claude Code's interactive
// mode, as a person runs it, where it can be (macOS and Linux, no
// images, safeguards or client cache marks): the plan counts a -p
// request at about twice an interactive one.
// -p` always. Off, as by default, a model request runs in Claude
// Code's interactive mode, as a person runs it, and never as -p: the
// plan counts a -p request at about twice an interactive one, and a -p
// run starts without the interactive mode's cache. A request it can't
// take (safeguards, a JSON schema, …), or one it doesn't start for,
// fails saying why. Reading the plan's allowance (/usage, no model
// request) is -p either way. (An "Interactive only" claudeTUIOnly,
// v0.1.2448, is what Off is now, and is no longer read.)
ClaudePrintMode bool `json:"claudePrintMode,omitempty"`
// ClaudeTUIOnly has a Claude subscription's model requests never run
// as `claude -p`: one the interactive mode can't take (safeguards, a
// JSON schema, …), or whose interactive mode doesn't come up, fails,
// saying why, where it would otherwise be -p. Reading the plan's
// allowance (/usage, no model request) is still -p. ClaudePrintMode,
// when set too, wins.
ClaudeTUIOnly bool `json:"claudeTUIOnly,omitempty"`
// ClaudeRunsMost is how many Claude Code processes a Claude
// subscription may have running at once: conversations' runs, those
// waiting for a next turn or on tool results, and one-off tests and
+1 -1
View File
@@ -45,7 +45,7 @@ var Keys = []string{
"codexWarmup", "claudeWarmup", "codexWarmAt", "claudeWarmAt", "codexWarmAts", "claudeWarmAts",
"workbuddyCheckin", "traeCheckin", "minimaxCheckin", "qoderCheckin",
// models: replies, vision, images, search
"memberModel", "noLoopGuard", "claudeLeanPrompt", "claudePrintMode", "claudeTUIOnly", "refusalRetries",
"memberModel", "noLoopGuard", "claudeLeanPrompt", "claudePrintMode", "refusalRetries",
"vision", "visionEffort", "imageGen", "imageTimeout", "classifyTimeout",
"searcher", "searcherThen", "searcherEffort", "searchFirst",
// updates