diff --git a/README.md b/README.md
index 3119f427c..f24961506 100644
--- a/README.md
+++ b/README.md
@@ -75,7 +75,7 @@ magpie finds the subscriptions your agents are signed in to by reading their sig
|
-Claude Code · Claude Desktop · Codex · Gemini CLI · Antigravity CLI · OpenCode · OpenChamber · MiMo Code · DevEco Code · Pi · oh-my-pi · StepCode · Aside · OmO · Prime Agent · Goose · Cursor CLI · Cursor Private Inference · Zed · VS Code Chat · VS Code Insiders · VSCodium Chat · JetBrains Air · Copilot (JetBrains) · Copilot CLI · Crush · DeepSeek Harness · Reasonix Studio · Command Code · fx · Devin · Hermes Agent · Mister Morph · Kimi Code · jcode · Qwen Code · Muse Code · Empryo · MiniMax Code · Droid · Cline · Qoder · Qoder CN · Grok Build · Grok App · ZCode · WorkBuddy · WorkBuddy AI · CodeBuddy Code · Pencil · T3 Code · OpenHanako · AtomCode · Snow CLI · Alma · Cindy · Ante · AstrBot
+Claude Code · Claude Desktop · Claude Science · Codex · Gemini CLI · Antigravity CLI · OpenCode · OpenChamber · MiMo Code · DevEco Code · Pi · oh-my-pi · StepCode · Aside · OmO · Prime Agent · Goose · Cursor CLI · Cursor Private Inference · Zed · VS Code Chat · VS Code Insiders · VSCodium Chat · JetBrains Air · Copilot (JetBrains) · Copilot CLI · Crush · DeepSeek Harness · Reasonix Studio · Command Code · fx · Devin · Hermes Agent · Mister Morph · Kimi Code · jcode · Qwen Code · Muse Code · Empryo · MiniMax Code · Droid · Cline · Qoder · Qoder CN · Grok Build · Grok App · ZCode · WorkBuddy · WorkBuddy AI · CodeBuddy Code · Pencil · T3 Code · OpenHanako · AtomCode · Snow CLI · Alma · Cindy · Ante · AstrBot
|
diff --git a/README.zh-CN.md b/README.zh-CN.md
index 01dca1299..17464c6d3 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -75,7 +75,7 @@ magpie 通过读取智能体的登录信息(Claude Code 和 Codex 的文件、
|
-Claude Code · Claude Desktop · Codex · Gemini CLI · Antigravity CLI · OpenCode · OpenChamber · MiMo Code · DevEco Code · Pi · oh-my-pi · StepCode · Aside · OmO · Prime Agent · Goose · Cursor CLI · Cursor Private Inference · Zed · VS Code Chat · VS Code Insiders · VSCodium Chat · JetBrains Air · Copilot (JetBrains) · Copilot CLI · Crush · DeepSeek Harness · Reasonix Studio · Command Code · fx · Devin · Hermes Agent · Mister Morph · Kimi Code · jcode · Qwen Code · Muse Code · Empryo · MiniMax Code · Droid · Cline · Qoder · Qoder CN · Grok Build · Grok App · ZCode · WorkBuddy · WorkBuddy AI · CodeBuddy Code · Pencil · T3 Code · OpenHanako · AtomCode · Snow CLI · Alma · Cindy · Ante · AstrBot
+Claude Code · Claude Desktop · Claude Science · Codex · Gemini CLI · Antigravity CLI · OpenCode · OpenChamber · MiMo Code · DevEco Code · Pi · oh-my-pi · StepCode · Aside · OmO · Prime Agent · Goose · Cursor CLI · Cursor Private Inference · Zed · VS Code Chat · VS Code Insiders · VSCodium Chat · JetBrains Air · Copilot (JetBrains) · Copilot CLI · Crush · DeepSeek Harness · Reasonix Studio · Command Code · fx · Devin · Hermes Agent · Mister Morph · Kimi Code · jcode · Qwen Code · Muse Code · Empryo · MiniMax Code · Droid · Cline · Qoder · Qoder CN · Grok Build · Grok App · ZCode · WorkBuddy · WorkBuddy AI · CodeBuddy Code · Pencil · T3 Code · OpenHanako · AtomCode · Snow CLI · Alma · Cindy · Ante · AstrBot
|
diff --git a/docs/subsystems/agent-wiring.md b/docs/subsystems/agent-wiring.md
index d4a0b2045..4962b0e2d 100644
--- a/docs/subsystems/agent-wiring.md
+++ b/docs/subsystems/agent-wiring.md
@@ -25,6 +25,7 @@ something else shows up as drift.
| Settings tuned from use | Usage › Context's "Tuned for you" advises, per agent, the settings that would have spent the fewest tokens on the user's own calls of the range, and puts one in on a click. Package `tune` replays the calls `sessions.Calls` reads from the agents' session files under each candidate value (`Compact`, `CacheTTL`); `tuneOf` picks the agents and models (Claude Code per model, Codex pooled). `TuneRead`, `TuneApply` and `TuneUndo` know where each setting lives: Claude Code's `modelSettings..autoCompactWindow` (where its `/autocompact` saves), `promptCacheTtl` and `subagentPromptCacheTtl` in `~/.claude/settings.json`; Codex's top-level `model_auto_compact_token_limit`. The advice is weighed by tokens alone: it is labelled "Fewest tokens", and a compaction window it would change says it doesn't measure how well the agent keeps the task after a compaction, and that a lower window compacts more often (#1854, `context-tune.test.cjs`). A compaction row's "Other window…" opens the app menu with every value of the curve, each with its estimated extra tokens over the fewest and about how many compactions it would have made (`Point.compacts`, from the same replay), and puts the one picked in like Use (#1860). An agent whose files time its compactions also has their wait weighed (HirotaNagai on X): Claude Code's `compact_boundary` line says `compactMetadata.durationMs`, which `sessions` puts on the first call after it, and Codex compacts by a call of its own (the record a `compacted` line names, in rollouts since 2026-09), whose time is the compaction's (`Call.Compact`; an older rollout's compaction has no call and stays untimed). With 3 or more timed for a model (`minTimed`), `Facts.took` is their median seconds, each window says its wait (`Point.wait`, its compactions × `took`), and the row says what a compaction took, the wait at the advice against the window now, and the cheaper window the advice passed over for waiting longer (`Compaction.cheapest`, `wait_cheapest`) when it saves 3% or more; the advice is labelled "Tokens + wait", its caveat says tokens and waiting only, and the picker says each window's wait with "Fewest tokens" on the cheapest (`context-tune.test.cjs`). An agent or model with fewer timed reads and is advised as before. | [`internal/tune`](../../internal/tune/tune.go), [`tune.go`](../../internal/agent/tune.go), [`internal/gui/tune.go`](../../internal/gui/tune.go) |
| Agents a plugin adds | A plugin's `magpie.agent` module (or a `*.agent.js` file) says where an agent magpie has no setup of its own keeps its model (`config`, `format`, `model`, `prefix`), and its `connect` returns the other keys to write. `agentplug` compiles each in moejs (via `jsmod`, as gateway middleware is), reloads it when plugins.json or the file changes, and keeps why one didn't load. `plugged` makes each an `Agent` with `Plugin` set, listed after magpie's own; an id one of magpie's own agents has is refused (`PluginErrors`). | [`agentplug.go`](../../internal/agentplug/agentplug.go), [`plugged.go`](../../internal/agent/plugged.go) |
| Environment-only agents | Agents that read the gateway only from the environment get a `Launch` command. Cursor Private Inference instead gets user-level variables (`cursorLocalOn`, `KeepCursorLocalEnv`), and magpie writes none of Cursor's own files. It is found by its product.json in the apps folders, in the folder Windows' list of installed programs names (`cursorLocalInstalls`, any folder picked in its installer), or as its Linux AppImage (`Cursor_Private_Inference-…AppImage`) in the folders downloads are kept in (#1254). Its effort field is kept in magpie (`provider.AgentEffort`) and asked by the gateway, its levels those of the models it lists (`cursorLocalEfforts`, #1003). | [`cursorlocal.go`](../../internal/agent/cursorlocal.go) |
+| Claude Science | Its daemon (`claude-science`) reads the API's address only from its environment's `ANTHROPIC_BASE_URL` and has no setting for it. Connect restarts the daemon with that variable set to the gateway (`scienceOn`: `stop`, then `serve --detached --no-browser` on the port `status` said it was on) and notes the daemon in `claude-science.json` (url, pid, port); Disconnect restarts it without the variable, one in magpie's own environment taken out too. No variable is set for the user and no file of the app's is written. Setting it again while magpie's daemon runs on this gateway does nothing (`Pick` sets the field after `connect`). `KeepClaudeScience` starts it again on the gateway, on its port, when it isn't running (a restart of the computer), each minute while magpie serves; it never stops one running. `Check` reads the daemon's `operon.lock`, not `status` (seconds for a 130 MB Bun program), and calls a daemon with another pid drift: the app's window, opened while none ran, starts its own without the variable. It is found in the Mac app's bundle (`Claude Science.app/Contents/Resources/bin`), `%LOCALAPPDATA%\Programs\ClaudeScience` on Windows, `~/.local/bin`, else on PATH. The app still needs its own Claude sign-in; the gateway never passes it on (see gateway-routing). | [`claudescience.go`](../../internal/agent/claudescience.go), [`science.go`](../../internal/gateway/science.go) |
## Runtime path
@@ -108,6 +109,8 @@ go test -tags nogui ./internal/agent -run '^TestAnte'
go test -tags nogui ./internal/agent -run '^TestAstrBot'
go test -tags nogui ./internal/agent -run '^TestJcode'
go test -tags nogui ./internal/agent -run '^TestGrokApp'
+go test -tags nogui ./internal/agent -run 'ClaudeScience'
+go test -tags nogui ./internal/gateway -run 'TestClaudeScience'
go test -tags nogui ./internal/agent -run '^TestPlugged'
go test -tags nogui ./internal/agent -run 'TestCodexFailoverOnlyKeepsOwnModels|TestCodexOwnModelThroughMagpieWhileAccountsOn|TestCodexHandWrittenBaseURLStays|TestCodexProxyFor|TestRealProxyProbe|TestCodexEnvTakesLoginShell|TestCodexFailoverHeldWhileProxyDoesNotPassOn|TestCodexProxiedDrift|TestCodexFailoverEndsWithMagpie|TestCodexMirrorFailoverHeldAndEndsWithMagpie'
go test -tags nogui ./internal/agent -run 'TestDisconnectStaysThroughSync|TestCodexDisconnectStaysWithAccountsOn|TestCodexAPIDisconnectStays'
diff --git a/docs/subsystems/gateway-routing.md b/docs/subsystems/gateway-routing.md
index d1ea63fea..bc42c8fb0 100644
--- a/docs/subsystems/gateway-routing.md
+++ b/docs/subsystems/gateway-routing.md
@@ -15,7 +15,7 @@ served by a plugin are in [Provider and plugin ownership](provider-plugins.md).
| Part | Responsibility | Source |
| --- | --- | --- |
-| Address and caller | `DefaultAddr`. The local token `magpie` and the per-agent `magpie-` (`TokenFor`). `agentOf` tells which agent asked, first by token, then by User-Agent. | [`gateway.go`](../../internal/gateway/gateway.go) |
+| Address and caller | `DefaultAddr`. The local token `magpie` and the per-agent `magpie-` (`TokenFor`). `agentOf` tells which agent asked, first by token, then by User-Agent. Claude Science, whose User-Agent is the Anthropic SDK's, is told by its client's `X-Anthropic-Surface: operon` (`isClaudeScience`). It is listed every model as `claude-magpie-` (`scienceModels`; its picker keeps only a `claude-` id whose name isn't a lower-case slug), and a Claude id magpie doesn't serve (its default before a pick, its haiku side tasks) goes to the model its last turn with tools was on, else the first it is listed (`scienceTurn`, kept in `claude-science.model`). | [`gateway.go`](../../internal/gateway/gateway.go) |
| TLS | `--tls-cert`/`--tls-key` (`MAGPIE_TLS_CERT`, `MAGPIE_TLS_KEY`) make `ListenAndServe`, `Relisten` (both through `Server.listen`) and `magpie web`'s page (`ServeTLS`) wrap the listener in `tlsListener`. A connection from another computer is `tls.Server` at once, so its plain HTTP gets net/http's 400. One from this computer (`fromThisComputer`: loopback, or a peer address equal to the local one) is sniffed on its own goroutine, 10s at most (`sniffWait`), and 0x16 makes it TLS, so `URL()`, the agents, MCP servers, `ServedBy` and the healthcheck keep `http://127.0.0.1`. `certFiles.get` reloads the pair when either file's mtime or size changes; a pair that doesn't load keeps the one served (logged once per change). `tlsConfig` refuses half a pair or files that don't load before binding. HTTP/1.1 only over TLS (hijack, Codex's websocket). `Scheme()` gives the scheme of `LANURLs`, a scheme-less `MAGPIE_PUBLIC_URL` and the page's network links. Host and Origin checks (`foreignPage`, `rebound`) don't depend on the scheme. | [`tls.go`](../../internal/gateway/tls.go), [`lan.go`](../../internal/gateway/lan.go) |
| HTTP surface | `Handler` routes `/v1/chat/completions`, `/v1/responses`, `/v1/messages` (each also without `/v1`), `/v1/models`, Gemini's `/v1beta/models/…`, the Codex backend path, `/v1/codex/models` (Codex's catalog shape for a Codex elsewhere with a gateway key, `codexCatalog`, kept to the key's models by `keyAllowed`; #1281), `/mcp/{name}`, `/mcp/magpie/web-search` and `/mcp/magpie/vision` (magpie's own web search and image recognition as MCP servers, below) and the `/v1/magpie/*` status endpoints. `/v1/alpha/search` (also without `/v1`, and on the Codex backend path for a magpie model) is Codex's web.run search (`alphaSearch`, `codex_search.go`): a ChatGPT account's model goes to the ChatGPT backend's `/alpha/search` on the account's sign-in, the next account asked on 401, 403, 429 or 5xx; any other model's `search_query` is searched by `webSearch`, and when nothing answers the reason is a 200 with `output`, since Codex ends the turn on any failed web.run (anton on Discord). A GET on `/v1/responses` (a client opening Responses over a WebSocket) is answered 426, a plain one 405: Responses is relayed over HTTP only. Every route is wrapped in `counted`, `corsGuard`, `callerGuard`, `withCaller` and `keyLimited`; `/v1/messages`, `/messages` and `/v1/messages/count_tokens` in `keepsSignIn` too. `corsGuard` (#1051) serves CORS only to the origins listed in Settings › Network › Web pages (`settings.CORSOrigins`, cleaned to `scheme://host[:port]` by `settings.CleanOrigins`, which refuses a wildcard). A browser extension's own pages, popup and service worker are listed the same way by their origin, which is the browser's scheme and the extension's id: `chrome-extension://` (Chromium, the id 32 letters a–p), `moz-extension://` (Firefox, the Internal UUID about:debugging shows, not the add-on id) and `safari-web-extension://` (Safari, which picks a new UUID on each launch, so a listing lasts until Safari restarts); the id must have that browser's shape, cased any way, and nothing else is taken — no bare scheme, no wildcard, no path (SkyAerope on Discord: an extension without host permissions is held to CORS like a page). A content script's fetch carries the page's origin, not the extension's. A listed extension is treated exactly as a listed page, below; one not listed passes as before (other schemes, below) with no CORS headers. For a listed origin it answers the preflight (204) and adds `Access-Control-Allow-Origin`, and every other request from it needs an enabled gateway key (`access.Authenticate`), even on loopback, or gets a 401. It takes the key from the caller `lanGuard` recorded too, since on the running server `lanGuard` has already put magpie's own token in the key's place. Any other web page is refused 403 on every route (`foreignPage`): on loopback a call needs no key and the body's Content-Type isn't checked, so a page the user visits could otherwise send a "simple" `text/plain` POST and spend their subscriptions blind. Only an `http`/`https` Origin is judged, and one on this computer (`localhost`, `*.localhost`, `127.0.0.0/8`, `[::1]`, any port) or the request's own origin (its host and port equal to `Host`, such as a page on the gateway's LAN address) passes, as does usemagpie.ai on `/v1/magpie/omarchy`. `null` and other schemes (`app://`, `file://`, `tauri://`, `vscode-webview://`, `chrome-extension://`) come from desktop apps, webviews and extensions that don't enforce CORS, and pass. A request with no Origin (every agent's) passes through with no CORS headers, as before. A page whose own name resolves to 127.0.0.1 (DNS rebinding) would count as same-origin here, so `lanGuard` refuses it first (`rebound`, 403): a loopback request carrying a browser's marks (`Origin`, `Sec-Fetch-Site`/`Sec-Fetch-Mode`, a `Mozilla/` user agent) whose `Host` isn't this computer's (an IP, `localhost`, `*.localhost`, a container runtime's name for the host such as `host.docker.internal`, `MAGPIE_PUBLIC_URL`'s or `MAGPIE_ADDR`'s host, the machine's own name) needs an enabled gateway key. Agents send none of those marks and pass under any name. Before any of that, `lanGuard` lets in one request without a key from anywhere: `POST /_magpie/claude-mcp/` with the token of a Claude subscription run now live (`ownCallback`, see [the Claude subscription bridge](claude-subscription-bridge.md)), the run's MCP helper calling back to a `MAGPIE_ADDR` that isn't loopback (#1546). Next, before the key or `rebound` is looked at, the allow list (lc on Discord, magpie in Docker on a public host): with `MAGPIE_ALLOW_IPS` or Settings › Network › Allowed addresses (`settings.AllowIPs`; the variable wins and the page then only shows it) naming IPs and CIDR ranges, a request whose connection (`RemoteAddr`, IPv4-mapped IPv6 unmapped, zone dropped) is outside them is refused 403 naming its address, even with an enabled gateway key (`refuseNotAllowed`). Loopback and this computer's own interface addresses always pass. A forwarding header is never taken for the address, so a proxy or tunnel on this computer passes (it arrives from loopback) and its clients are limited at the proxy. An entry that doesn't parse lets nothing in and is logged once; the list stays on. Settings' list is read with `settings.LoadChecked`: a settings.json that can't be read, or doesn't parse with no last good generation, is unknown, never "no list", so the list read last in this process stays in force (`lastAllow`), and with none read yet only this computer passes, the 403 saying settings.json couldn't be read; logged once. No file, or an empty one, is no list. The Settings page's saves read with `LoadChecked` too and refuse such a file, as `settings.Save` does. `magpie web`'s server is wrapped in the same check (`AllowGuard`). Settings refuses a list that would leave out the address the page saving it is open from (`KeepsOut`); the page names that address, which behind Docker or a proxy is the proxy's, and offers to add it to the refused list (`allowSays`, Mathresearcher on Discord). | [`gateway.go`](../../internal/gateway/gateway.go), [`allow.go`](../../internal/gateway/allow.go), [`internal/settings/allowips.go`](../../internal/settings/allowips.go), [`cors.go`](../../internal/gateway/cors.go), [`codex_catalog.go`](../../internal/gateway/codex_catalog.go), [`internal/settings/origins.go`](../../internal/settings/origins.go) |
| Model resolution | `serve` resolves the model the agent asked for: Claude tier stand-ins, a routing group (`provider.GroupFor`: its id, the model's id however a vendor spells it, else the one group whose name it is, unless a provider serves a model by that id), auto stand-ins, the agent's own stand-in (`StandIn`: Codex's config.toml `model` when magpie is its provider, for a name it sends that magpie doesn't serve, such as its auto-review's `codex-auto-review`), itself taken through `GroupFor` and auto stand-ins so a config naming a group bare reaches it, then `provider.Resolve`. A Codex memory call or auto-review (`x-openai-subagent: guardian`, or `codex-auto-review`) that still names no served model goes to the model Codex's last turn was answered on (`codexMemoryStandIn`, per agent and gateway key), so a Codex on magpie through another provider table, a profile or another computer isn't answered 404 (Adam on Discord, `TestCodexAutoReviewReachesItsTurnsModel`). A bare model id several providers serve (MOMO on Discord: `glm-5.3` under opencode-go and a6api) is never refused: with found groups on (the default) `GroupFor` takes it to the group magpie found for it (`auto-`), its members in the Providers order, routed and failed over as any group, a conversation staying with the member that answered it while its cache is worth it (affinity); with them off, `Resolve` takes the first provider in the Providers order that exposes it, with no fallback. magpie writes only `provider/model` ids into agents' configs (`magpieModels`), so a bare id is one the user wrote. `/v1/models` lists bare ids only when the user asks for them ([Model ids without the provider](#model-ids-without-the-provider)). Every reply says who answered in `X-Magpie-Provider` and `X-Magpie-Model` (`noteMember`), and the usage log and the Routing page keep it. A model id with `~` and no slash that resolves as nothing else is the one served id (a provider's model or a group) whose slashes it spells as `~` (`unflat`, `provider.Unflat`; MiniMax Code's spelling, #1387), taken back in `validateModel` before key limits, middleware and usage see it; two ids spelled alike are neither. A Claude model id whose version is dashed (`relay/claude-opus-4-6-us`, with or without `:level` and `[1m]`) that is not served as spelled is the one served id it dashes (`provider.ClaudeUndashed`; the spelling magpie gives Claude Code, which reads a dotted version as Claude Opus 4), taken back in `validateModel` and `unprefixed` the same way. An unknown model gets a 404 naming why: a switched-off provider, a disabled group or an empty group. Otherwise it names up to three ids nearest to what was asked (`provider.Closest`: words of a model's display name count before words of its id, and a provider's id or name only alongside them, so "Zen-Space-Bunny" is told `opencode-zen-free/space-bunny-free`, MOMO on Discord), then the ways a model can be named, then every id (`unknownModel`; chat and embeddings). | [`gateway.go`](../../internal/gateway/gateway.go), [`internal/provider/group.go`](../../internal/provider/group.go), [`internal/provider/flat.go`](../../internal/provider/flat.go), [`internal/provider/claudedash.go`](../../internal/provider/claudedash.go) |
diff --git a/internal/agent/agents.go b/internal/agent/agents.go
index a06109acc..cb5db9a32 100644
--- a/internal/agent/agents.go
+++ b/internal/agent/agents.go
@@ -90,6 +90,7 @@ func builtins(home, cfg string) []*Agent {
return append([]*Agent{
claude(home),
claudeDesktop(home),
+ claudeScience(),
codex(home),
gemini(home),
agy(home),
diff --git a/internal/agent/claudescience.go b/internal/agent/claudescience.go
new file mode 100644
index 000000000..8ea50f582
--- /dev/null
+++ b/internal/agent/claudescience.go
@@ -0,0 +1,408 @@
+package agent
+
+// Claude Science is Anthropic's research app (0.1.62, "operon" inside): a
+// daemon, claude-science, that serves its UI on localhost, and a window
+// that shows it (a Swift launcher on the Mac, Electron on Windows, a
+// browser on Linux) and attaches to the daemon running, else starts one.
+// The daemon asks Anthropic's Messages API at its environment's
+// ANTHROPIC_BASE_URL (ky() in its bundle: https, or http on a loopback
+// address) and has no setting for it, so magpie connects it by starting
+// the daemon itself with that variable set to the gateway — `stop`, then
+// `serve --detached --no-browser`, on the port it was on — and nothing
+// else: no variable set for the user, no file of its written. Disconnect
+// restarts it without the variable. The app still needs its own Claude
+// sign-in, which it sends as its bearer and the gateway never passes on
+// (see gateway/science.go); with none it asks nothing at all.
+//
+// The daemon lives till it is stopped or the computer restarts, so while
+// it is connected magpie starts it again when it isn't running
+// (KeepClaudeScience), and says so when another one runs in its place —
+// the window, opened while none ran, starts its own without the variable
+// (Check).
+
+import (
+ "context"
+ "encoding/json"
+ "errors"
+ "fmt"
+ "log"
+ "os"
+ "path/filepath"
+ "runtime"
+ "strconv"
+ "strings"
+ "sync"
+ "time"
+
+ "github.com/yetone/magpie/internal/appdir"
+ "github.com/yetone/magpie/internal/gateway"
+ "github.com/yetone/magpie/internal/proc"
+)
+
+// ScienceID is the agent's id.
+const ScienceID = gateway.ScienceID
+
+const scienceName = "Claude Science"
+
+// scienceVar is the variable its daemon reads the API's address from.
+const scienceVar = "ANTHROPIC_BASE_URL"
+
+// scienceBin is the daemon's program, "" when it isn't installed. A var so
+// tests point it elsewhere.
+var scienceBin = func() string {
+ scienceSeen.Lock()
+ defer scienceSeen.Unlock()
+ if time.Since(scienceSeen.at) > 30*time.Second {
+ home, _ := os.UserHomeDir()
+ scienceSeen.bin, scienceSeen.at = findScience(home), time.Now()
+ }
+ return scienceSeen.bin
+}
+
+var scienceSeen struct {
+ sync.Mutex
+ bin string
+ at time.Time
+}
+
+// findScience is where claude-science is installed for home: in the Mac
+// app's bundle, Windows' per-user Programs folder, or the ~/.local/bin the
+// installers link it into (the only place on Linux), else on PATH.
+func findScience(home string) string {
+ var at []string
+ switch runtime.GOOS {
+ case "darwin":
+ for _, d := range macAppFolders(home) {
+ at = append(at, filepath.Join(d, scienceName+".app", "Contents", "Resources", "bin", "claude-science"))
+ }
+ case "windows":
+ if d := os.Getenv("LOCALAPPDATA"); d != "" {
+ at = append(at, filepath.Join(d, "Programs", "ClaudeScience", "claude-science.exe"))
+ }
+ at = append(at, filepath.Join(home, "AppData", "Local", "Programs", "ClaudeScience", "claude-science.exe"))
+ }
+ exe := "claude-science"
+ if runtime.GOOS == "windows" {
+ exe += ".exe"
+ }
+ at = append(at, filepath.Join(home, ".local", "bin", exe))
+ for _, p := range at {
+ if isFile(p) {
+ return p
+ }
+ }
+ if p, err := proc.LookPath("claude-science"); err == nil {
+ return p
+ }
+ return ""
+}
+
+// scienceRun runs the daemon's program bin with args, its environment env
+// (nil: magpie's own), and is what it printed. A var so tests never start
+// the real one. serve --detached returns once its daemon is up; the
+// daemon keeps none of the pipes, which go to no file at all.
+var scienceRun = func(env []string, bin string, args ...string) ([]byte, error) {
+ ctx, cancel := context.WithTimeout(context.Background(), 90*time.Second)
+ defer cancel()
+ cmd := proc.CommandContext(ctx, bin, args...)
+ cmd.Env = env
+ if len(args) > 0 && args[0] == "serve" {
+ // a detached daemon holding a pipe would hold Output till it quits
+ return nil, cmd.Run()
+ }
+ return cmd.Output()
+}
+
+// scienceStatus is what `claude-science status` says of its daemon.
+type scienceStatus struct {
+ Running bool `json:"running"`
+ PID int `json:"pid"`
+ Port int `json:"port"`
+ Version string `json:"version"`
+}
+
+// scienceDir is the daemon's data folder, ~/.claude-science. A var so
+// tests point it elsewhere.
+var scienceDir = func() string {
+ home, _ := os.UserHomeDir()
+ return filepath.Join(home, ".claude-science")
+}
+
+// scienceLock is the daemon running as its lock file says (operon.lock:
+// its pid, port and start), false when there is none. It is read where
+// status would take seconds — the program is a 130 MB Bun build — as the
+// Agents page is drawn; a lock a crash left is taken for the daemon,
+// which only Check reads it for.
+func scienceLock() (scienceStatus, bool) {
+ var st scienceStatus
+ b, err := os.ReadFile(filepath.Join(scienceDir(), "operon.lock"))
+ if err != nil || json.Unmarshal(b, &st) != nil || st.PID == 0 {
+ return st, false
+ }
+ st.Running = true
+ return st, true
+}
+
+func scienceState(bin string) (scienceStatus, error) {
+ var st scienceStatus
+ out, err := scienceRun(nil, bin, "status")
+ if err != nil {
+ return st, fmt.Errorf("claude-science status: %w", err)
+ }
+ if err := json.Unmarshal(out, &st); err != nil {
+ return st, fmt.Errorf("claude-science status said %q: %w", strings.TrimSpace(string(out)), err)
+ }
+ return st, nil
+}
+
+// scienceMark is magpie's note of the daemon it started on the gateway,
+// which the row reads as connected.
+type scienceMark struct {
+ URL string `json:"url"`
+ PID int `json:"pid"`
+ Port int `json:"port,omitempty"` // the UI's, which a start again keeps
+}
+
+func scienceMarkPath() string { return filepath.Join(appdir.Config(), "claude-science.json") }
+
+func readScienceMark() (scienceMark, bool) {
+ var m scienceMark
+ b, err := os.ReadFile(scienceMarkPath())
+ if err != nil {
+ return m, false
+ }
+ // one that doesn't parse is still magpie's note that it is connected
+ _ = json.Unmarshal(b, &m)
+ return m, true
+}
+
+func scienceWired() bool { _, ok := readScienceMark(); return ok }
+
+// scienceEnv is magpie's environment with the variable set to gw, or
+// without it for "".
+func scienceEnv(gw string) []string {
+ env := make([]string, 0, len(os.Environ())+1)
+ for _, kv := range os.Environ() {
+ if k, _, _ := strings.Cut(kv, "="); !strings.EqualFold(k, scienceVar) {
+ env = append(env, kv)
+ }
+ }
+ if gw != "" {
+ env = append(env, scienceVar+"="+gw)
+ }
+ return env
+}
+
+// scienceMu holds one start or stop of the daemon at a time.
+var scienceMu sync.Mutex
+
+// scienceRestart stops the daemon when it runs and starts it on gw ("":
+// without the variable), on the port it was on; only stops it for !start.
+// It is the daemon now running.
+func scienceRestart(bin, gw string, start bool) (scienceStatus, error) {
+ was, err := scienceState(bin)
+ if err != nil {
+ return was, err
+ }
+ if was.Running {
+ if out, err := scienceRun(nil, bin, "stop"); err != nil {
+ return was, fmt.Errorf("claude-science stop: %w %s", err, strings.TrimSpace(string(out)))
+ }
+ }
+ if !start {
+ return scienceStatus{}, nil
+ }
+ return scienceServe(bin, gw, was.Port)
+}
+
+// scienceServe starts the daemon on gw ("": without the variable), on
+// port when it isn't 0, and waits till status says it runs.
+func scienceServe(bin, gw string, port int) (scienceStatus, error) {
+ args := []string{"serve", "--detached", "--no-browser"}
+ if port > 0 {
+ args = append(args, "--port", strconv.Itoa(port))
+ }
+ if _, err := scienceRun(scienceEnv(gw), bin, args...); err != nil {
+ return scienceStatus{}, fmt.Errorf("claude-science serve: %w", err)
+ }
+ var st scienceStatus
+ for deadline := time.Now().Add(scienceWait); ; {
+ var err error
+ if st, err = scienceState(bin); err == nil && st.Running {
+ return st, nil
+ }
+ if time.Now().After(deadline) {
+ return st, errors.New("claude-science serve: its daemon isn't running (see claude-science logs)")
+ }
+ time.Sleep(scienceWait / 60)
+ }
+}
+
+// scienceWait is how long a daemon started may take to say it runs.
+var scienceWait = 30 * time.Second
+
+// scienceOn restarts the daemon on the gateway, and notes it; off
+// restarts it without the variable, when it ran, and drops the note.
+func scienceOn(on bool) error {
+ scienceMu.Lock()
+ defer scienceMu.Unlock()
+ bin := scienceBin()
+ if !on {
+ if _, wired := readScienceMark(); wired && bin != "" {
+ st, err := scienceState(bin)
+ if err != nil {
+ return err
+ }
+ if st.Running {
+ if _, err := scienceRestart(bin, "", true); err != nil {
+ return err
+ }
+ }
+ }
+ if err := os.Remove(scienceMarkPath()); err != nil && !os.IsNotExist(err) {
+ return err
+ }
+ return nil
+ }
+ if bin == "" {
+ return errors.New(scienceName + " isn't installed (no claude-science found)")
+ }
+ gw := gateway.URL()
+ // the daemon magpie started, on this gateway, is left running: Connect
+ // sets the field it connected by again (Pick)
+ if m, wired := readScienceMark(); wired && m.URL == gw {
+ if st, err := scienceState(bin); err == nil && st.Running && st.PID == m.PID {
+ return nil
+ }
+ }
+ st, err := scienceRestart(bin, gw, true)
+ if err != nil {
+ return err
+ }
+ return writeScienceMark(scienceMark{URL: gw, PID: st.PID, Port: st.Port})
+}
+
+func writeScienceMark(m scienceMark) error {
+ b, _ := json.Marshal(m)
+ if err := os.MkdirAll(filepath.Dir(scienceMarkPath()), 0o700); err != nil {
+ return err
+ }
+ return os.WriteFile(scienceMarkPath(), b, 0o600)
+}
+
+// scienceCheck is what of the wiring is gone, by the daemon's lock file: a
+// daemon running that magpie
+// didn't start (the window, opened while none ran, starts its own), or one
+// started for the gateway's old address. One not running is no drift:
+// KeepClaudeScience starts it.
+func scienceCheck() string {
+ m, wired := readScienceMark()
+ if !wired {
+ return ""
+ }
+ st, running := scienceLock()
+ if !running {
+ return ""
+ }
+ if st.PID != m.PID {
+ return fmt.Sprintf("%s's daemon (pid %d) was started without magpie's gateway", scienceName, st.PID)
+ }
+ if m.URL != gateway.URL() {
+ return fmt.Sprintf("%s's daemon was started for the gateway at %s", scienceName, m.URL)
+ }
+ return ""
+}
+
+// KeepClaudeScience starts the daemon on the gateway, while Claude Science
+// is connected, whenever it isn't running: after a restart of the
+// computer, or after it was stopped. It never stops one running — one
+// magpie didn't start may be in the middle of a session — which Check
+// tells as drift instead.
+func KeepClaudeScience(ctx context.Context) {
+ keepScienceOnce()
+ tick := time.NewTicker(time.Minute)
+ defer tick.Stop()
+ for {
+ select {
+ case <-ctx.Done():
+ return
+ case <-tick.C:
+ keepScienceOnce()
+ }
+ }
+}
+
+func keepScienceOnce() {
+ if !scienceWired() {
+ return
+ }
+ scienceMu.Lock()
+ defer scienceMu.Unlock()
+ bin := scienceBin()
+ if bin == "" {
+ return
+ }
+ if st, err := scienceState(bin); err != nil || st.Running {
+ return
+ }
+ gw := gateway.URL()
+ m, _ := readScienceMark()
+ st, err := scienceServe(bin, gw, m.Port)
+ if err != nil {
+ log.Printf("%s: starting its daemon on magpie's gateway: %v", scienceName, err)
+ return
+ }
+ if err := writeScienceMark(scienceMark{URL: gw, PID: st.PID, Port: st.Port}); err != nil {
+ log.Printf("%s: %v", scienceName, err)
+ }
+}
+
+// ScienceLaunch is the command that starts the daemon at bin on the
+// gateway at gw, in the shell of this system.
+func ScienceLaunch(bin, gw string) string {
+ if runtime.GOOS == "windows" {
+ return `& '` + strings.ReplaceAll(bin, "'", "''") + `' stop; $env:` + scienceVar + `="` + gw + `"; & '` + strings.ReplaceAll(bin, "'", "''") + `' serve --detached`
+ }
+ q := "'" + strings.ReplaceAll(bin, "'", `'\''`) + "'"
+ return q + " stop; " + scienceVar + "=" + gw + " " + q + " serve --detached"
+}
+
+func claudeScience() *Agent {
+ return &Agent{
+ ID: ScienceID, Name: scienceName, Icon: "claude-color", Aliases: []string{"operon", "science"},
+ // its picker lists the gateway's /v1/models as it is shown them
+ // (gateway/science.go), which the row's Models button picks
+ ListsModels: true,
+ detect: func() bool { return scienceBin() != "" },
+ Launch: func() string {
+ if bin := scienceBin(); bin != "" && scienceWired() {
+ return ScienceLaunch(bin, gateway.URL())
+ }
+ return ""
+ },
+ Fields: []Field{{
+ Key: "provider", Label: "provider",
+ Get: func() string {
+ if scienceWired() {
+ return magpieID
+ }
+ return ""
+ },
+ Set: func(v string) error { return scienceOn(v != "") },
+ Options: func(map[string]string) []Option {
+ return []Option{{Value: magpieID, Label: "magpie", Icon: "magpie",
+ Note: "magpie restarts its daemon with ANTHROPIC_BASE_URL set to the gateway; a session running in it is cut off"}}
+ },
+ }},
+ Check: scienceCheck,
+ Notice: func() string {
+ if !scienceWired() {
+ return ""
+ }
+ return noticeScience.say("agent", scienceName)
+ },
+ }
+}
+
+// what Claude Science says after a change (notice.go)
+var noticeScience = newNotice("{agent}'s daemon runs on magpie's gateway: open {agent} again (reload its window if it is open). It still needs you signed in with your Claude account, which magpie never sends on; pick a model of magpie's in its model menu.")
diff --git a/internal/agent/claudescience_test.go b/internal/agent/claudescience_test.go
new file mode 100644
index 000000000..36ca36967
--- /dev/null
+++ b/internal/agent/claudescience_test.go
@@ -0,0 +1,194 @@
+package agent
+
+import (
+ "encoding/json"
+ "os"
+ "path/filepath"
+ "runtime"
+ "slices"
+ "strings"
+ "testing"
+ "time"
+
+ "github.com/yetone/magpie/internal/gateway"
+)
+
+// fakeScience is claude-science's daemon as its CLI tells it: status,
+// stop and serve --detached, each one noted.
+type fakeScience struct {
+ dir string // its data folder, where its lock file is
+ running bool
+ pid, port int
+ env []string // the environment the daemon running was started in
+ calls []string
+}
+
+func (f *fakeScience) run(env []string, _ string, args ...string) ([]byte, error) {
+ f.calls = append(f.calls, strings.Join(args, " "))
+ switch args[0] {
+ case "status":
+ if !f.running {
+ return []byte(`{"running":false}`), nil
+ }
+ return json.Marshal(map[string]any{"running": true, "pid": f.pid, "port": f.port, "version": "0.1.62", "data_dir": "/x"})
+ case "stop":
+ f.running, f.env = false, nil
+ case "serve":
+ f.running, f.pid, f.env, f.port = true, f.pid+1, env, 8000
+ if i := slices.Index(args, "--port"); i > 0 {
+ f.port = 0
+ json.Unmarshal([]byte(args[i+1]), &f.port)
+ }
+ }
+ f.lock()
+ return nil, nil
+}
+
+// lock writes its lock file as the daemon does, removed when it stops.
+func (f *fakeScience) lock() {
+ path := filepath.Join(f.dir, "operon.lock")
+ if !f.running {
+ os.Remove(path)
+ return
+ }
+ b, _ := json.Marshal(map[string]any{"pid": f.pid, "version": "0.1.62", "port": f.port, "sandbox_port": f.port + 1})
+ os.WriteFile(path, b, 0o600)
+}
+
+func (f *fakeScience) base() (string, bool) {
+ for _, kv := range f.env {
+ if v, ok := strings.CutPrefix(kv, scienceVar+"="); ok {
+ return v, true
+ }
+ }
+ return "", false
+}
+
+// Claude Science is connected by restarting its daemon with
+// ANTHROPIC_BASE_URL set to the gateway, on the port it was on, and by
+// nothing else; disconnected by restarting it without the variable, one
+// set in magpie's own environment too. A daemon magpie didn't start is
+// drift, never stopped behind the user's back; one not running is started
+// while it is connected.
+func TestClaudeScienceRestartsItsDaemon(t *testing.T) {
+ t.Setenv("XDG_CONFIG_HOME", t.TempDir())
+ t.Setenv(scienceVar, "https://elsewhere.example")
+ f := &fakeScience{dir: t.TempDir(), running: true, pid: 40, port: 8123}
+ f.lock()
+ oldRun, oldBin, oldWait, oldDir := scienceRun, scienceBin, scienceWait, scienceDir
+ t.Cleanup(func() { scienceRun, scienceBin, scienceWait, scienceDir = oldRun, oldBin, oldWait, oldDir })
+ scienceRun, scienceBin, scienceWait = f.run, func() string { return "/bin/claude-science" }, time.Second
+ scienceDir = func() string { return f.dir }
+ a, err := Find(ScienceID)
+ if err != nil {
+ t.Fatal(err)
+ }
+ field := a.Fields[0]
+ if field.Get() != "" || a.Check() != "" || a.Notice() != "" {
+ t.Fatal("connected before Connect")
+ }
+
+ if err := field.Set(magpieID); err != nil {
+ t.Fatal(err)
+ }
+ if got, ok := f.base(); !ok || got != gateway.URL() {
+ t.Errorf("its daemon was started on %q (set %v), want %s", got, ok, gateway.URL())
+ }
+ if want := []string{"status", "stop", "serve --detached --no-browser --port 8123", "status"}; !slices.Equal(f.calls, want) {
+ t.Errorf("ran %q, want %q", f.calls, want)
+ }
+ if field.Get() != magpieID || a.Check() != "" || !strings.Contains(a.Notice(), "Claude account") {
+ t.Errorf("after Connect: %q, check %q, notice %q", field.Get(), a.Check(), a.Notice())
+ }
+ // set again, as Connect does after connecting (Pick): left running
+ f.calls = nil
+ if err := field.Set(magpieID); err != nil || !slices.Equal(f.calls, []string{"status"}) {
+ t.Errorf("set again: %v, ran %q", err, f.calls)
+ }
+ if !strings.Contains(a.Launch(), scienceVar+"="+gateway.URL()) && !strings.Contains(a.Launch(), `$env:`+scienceVar+`="`+gateway.URL()) {
+ t.Errorf("launch %q", a.Launch())
+ }
+
+ // the window, opened while none ran, started its own: drift, and the
+ // keeper leaves it running
+ f.pid, f.env, f.calls = 77, nil, nil
+ f.lock()
+ if d := a.Check(); !strings.Contains(d, "without magpie's gateway") {
+ t.Errorf("a daemon magpie didn't start: check %q", d)
+ }
+ f.calls = nil
+ keepScienceOnce()
+ if !slices.Equal(f.calls, []string{"status"}) || f.pid != 77 {
+ t.Errorf("the keeper touched a daemon running: %q", f.calls)
+ }
+ // none running (the computer restarted): started on the gateway
+ f.running, f.calls = false, nil
+ f.lock()
+ keepScienceOnce()
+ if got, _ := f.base(); !f.running || got != gateway.URL() || a.Check() != "" {
+ t.Errorf("not started again on the gateway: %q, %q", f.calls, got)
+ }
+ if f.port != 8123 {
+ t.Errorf("started again on port %d, not the 8123 it was on", f.port)
+ }
+
+ // disconnected: running again, without the variable even where
+ // magpie's own environment has it
+ f.calls = nil
+ if err := field.Set(""); err != nil {
+ t.Fatal(err)
+ }
+ if got, ok := f.base(); !f.running || ok {
+ t.Errorf("after Disconnect: running %v, %s=%q", f.running, scienceVar, got)
+ }
+ if field.Get() != "" || a.Check() != "" || a.Notice() != "" {
+ t.Errorf("still connected after Disconnect")
+ }
+ if _, err := os.Stat(scienceMarkPath()); !os.IsNotExist(err) {
+ t.Errorf("the note is left: %v", err)
+ }
+ // and the keeper starts nothing now
+ f.running, f.calls = false, nil
+ f.lock()
+ keepScienceOnce()
+ if f.running || len(f.calls) != 0 {
+ t.Errorf("started while disconnected: %q", f.calls)
+ }
+ // a disconnect with none running starts none
+ writeScienceMark(scienceMark{URL: gateway.URL(), PID: 1})
+ if err := field.Set(""); err != nil || f.running {
+ t.Errorf("a disconnect started one: %v %q", err, f.calls)
+ }
+ // and with none installed there is nothing to connect
+ scienceBin = func() string { return "" }
+ if err := field.Set(magpieID); err == nil || field.Get() != "" || a.detect() {
+ t.Errorf("connected with none installed: %v", err)
+ }
+}
+
+// It is found where its installers put it: the Mac app's bundle, Windows'
+// per-user Programs folder, ~/.local/bin.
+func TestFindClaudeScience(t *testing.T) {
+ home := t.TempDir()
+ t.Setenv("PATH", "")
+ t.Setenv("LOCALAPPDATA", filepath.Join(home, "AppData", "Local"))
+ if got := findScience(home); got != "" {
+ t.Fatalf("found %q in an empty home", got)
+ }
+ var want string
+ switch runtime.GOOS {
+ case "darwin":
+ want = filepath.Join(home, "Applications", "Claude Science.app", "Contents", "Resources", "bin", "claude-science")
+ case "windows":
+ want = filepath.Join(home, "AppData", "Local", "Programs", "ClaudeScience", "claude-science.exe")
+ default:
+ want = filepath.Join(home, ".local", "bin", "claude-science")
+ }
+ os.MkdirAll(filepath.Dir(want), 0o755)
+ if err := os.WriteFile(want, []byte("x"), 0o755); err != nil {
+ t.Fatal(err)
+ }
+ if got := findScience(home); got != want {
+ t.Errorf("found %q, want %q", got, want)
+ }
+}
diff --git a/internal/agent/rewire.go b/internal/agent/rewire.go
index 6c0bd84c3..477853112 100644
--- a/internal/agent/rewire.go
+++ b/internal/agent/rewire.go
@@ -33,7 +33,9 @@ func OnGateway() []*Agent {
// again, an agent joined to magpie beside its own models (Codex signed in
// with ChatGPT) joined again. It says the names of those it moved, and
// what one it couldn't move failed with. Cursor Private Inference's
-// variables and dsh's routes, which magpie keeps on its own, follow too.
+// variables and dsh's routes, which magpie keeps on its own, follow too;
+// Claude Science's daemon, started for the old address, is drift
+// (scienceCheck) and is started again with the rest.
func Rewire(as []*Agent) (moved []string, err error) {
var off []*Agent
for _, a := range as {
diff --git a/internal/cli/main.go b/internal/cli/main.go
index 7be71fa23..37e014c39 100644
--- a/internal/cli/main.go
+++ b/internal/cli/main.go
@@ -268,6 +268,9 @@ func run(args []string) error {
// and Cursor Private Inference's variables, which the Mac's launchd
// forgets at a restart, for the gateway's address now
gateway.WhileServing = append(gateway.WhileServing, agent.KeepCursorLocalEnv)
+ // and Claude Science's daemon, which a restart of the computer ends,
+ // started on the gateway again while it is connected
+ gateway.WhileServing = append(gateway.WhileServing, agent.KeepClaudeScience)
// and the request archive, when it is on, goes to the bucket sync is to
gateway.ArchiveBucket = func() (gateway.Putter, bool) {
if b, ok := davsync.S3Bucket(); ok {
diff --git a/internal/gateway/desktop.go b/internal/gateway/desktop.go
index 4554685da..5a29ece3f 100644
--- a/internal/gateway/desktop.go
+++ b/internal/gateway/desktop.go
@@ -336,7 +336,8 @@ func desktopNames(entries []provider.Entry) []string {
// aliased is the catalog id an alias Claude Desktop was given stands for:
// anthropic/magpie- (as it was listed before too),
// mythos-magpie- or magpie-.anthropic., with
-// or without Claude Code's "[1m]".
+// or without Claude Code's "[1m]"; or Claude Science's,
+// claude-magpie-.
func aliased(id string) (string, bool) {
id = strings.TrimSuffix(id, "[1m]")
var number string
@@ -344,6 +345,9 @@ func aliased(id string) (string, bool) {
number = n
} else if n, ok := strings.CutPrefix(id, desktopEffortAlias); ok {
number = n
+ } else if n, ok := strings.CutPrefix(id, scienceAlias); ok {
+ // Claude Science's (science.go)
+ number = n
} else if rest, ok := strings.CutPrefix(id, "magpie-"); ok {
if i := strings.Index(rest, desktopClaudeInfix); i > 0 {
number = rest[:i]
diff --git a/internal/gateway/gateway.go b/internal/gateway/gateway.go
index 2f1f812e7..e32c3bd23 100644
--- a/internal/gateway/gateway.go
+++ b/internal/gateway/gateway.go
@@ -60,6 +60,10 @@ func agentOf(r *http.Request) string {
if isClaudeDesktop(r) {
return "claude-desktop"
}
+ if isClaudeScience(r) {
+ // Claude Science's client, an Anthropic SDK's User-Agent
+ return ScienceID
+ }
ua := r.Header.Get("User-Agent")
if strings.HasPrefix(strings.ToLower(strings.TrimSpace(ua)), "cursor") {
// cursor-agent talks to Cursor's backend alone, never to a
@@ -80,7 +84,7 @@ func startedByAgent(r *http.Request, agent string) bool {
if _, ok := strings.CutPrefix(callerKey(r), Token+"-"); ok {
return false
}
- return agent != "claude-desktop" && agent != "cursor-local" && !usage.IsAgent(agent)
+ return agent != "claude-desktop" && agent != "cursor-local" && agent != ScienceID && !usage.IsAgent(agent)
}
// StandIn is the model an agent is set to use in place of one it named that
@@ -903,8 +907,10 @@ func catalogFor(r *http.Request) []provider.Entry {
func (s *Server) models(w http.ResponseWriter, r *http.Request) {
data := []map[string]any{}
shown := catalogFor(r)
- if agentOf(r) == "claude-desktop" {
+ if agent := agentOf(r); agent == "claude-desktop" {
data = desktopModels(shown)
+ } else if agent == ScienceID {
+ data = scienceModels(shown)
} else {
labels := provider.Labels(shown)
// for another magpie: how it searches the web for each model
@@ -1012,6 +1018,12 @@ func (s *Server) model(w http.ResponseWriter, r *http.Request) {
shown := keyAllowed(r, provider.Catalog())
for _, e := range shown {
if e.ID == id {
+ if agentOf(r) == ScienceID {
+ // by the alias it asked by, which it keeps what it reads
+ // under
+ writeJSON(w, 200, scienceObject(e, provider.Labels([]provider.Entry{e})[0]))
+ return
+ }
writeJSON(w, 200, modelObject(e))
return
}
@@ -1491,6 +1503,8 @@ func (s *Server) serve(w http.ResponseWriter, r *http.Request, from provider.Pro
if agent == "claude-desktop" {
sub, _ := subagentOf(r.Header)
asked = desktopTurn(asked, body, fromClaudeCode(r.Header), sub != "")
+ } else if agent == ScienceID {
+ asked = scienceTurn(asked, body)
}
// a stand-in that is a tier at an effort of its own (":",
// #536) is that model at that level, as were it asked for so
diff --git a/internal/gateway/science.go b/internal/gateway/science.go
new file mode 100644
index 000000000..539ffeb86
--- /dev/null
+++ b/internal/gateway/science.go
@@ -0,0 +1,133 @@
+package gateway
+
+import (
+ "net/http"
+ "os"
+ "path/filepath"
+ "regexp"
+ "strings"
+ "sync"
+ "unicode"
+ "unicode/utf8"
+
+ "github.com/yetone/magpie/internal/provider"
+ "github.com/yetone/magpie/internal/settings"
+)
+
+// Claude Science (Anthropic's research app, 0.1.62, "operon" inside) is a
+// daemon that serves its UI on localhost and asks Anthropic's Messages API
+// at the base URL its environment's ANTHROPIC_BASE_URL names (ky() in its
+// bundle: https anywhere, http only on a loopback address), else at
+// api.anthropic.com. Magpie starts the daemon with that variable set to
+// the gateway (package agent, claudescience.go). It still needs its own
+// Claude sign-in: with none it asks nothing ("This build requires signing
+// in with your Claude account. API keys are not supported.", yz()), and
+// with one it sends Authorization: Bearer sk-ant-oat…, which magpie never
+// passes on (claudeSignIn), beside its client's default headers
+// X-Anthropic-Surface: operon and anthropic-beta: oauth-2025-04-20. That
+// header is how its requests are known here: its User-Agent is the
+// Anthropic SDK's, which says nothing of the app.
+//
+// Its model picker (ops.system.models) lists from GET /v1/models only an
+// id that starts with "claude-" whose display_name isn't a lower-case
+// slug (H7 and kor in its bundle), so every model is listed to it by an
+// alias, claude-magpie- (aliasNumber, as Claude Desktop's), named
+// as the agents' lists name it. And it asks for Claude models by their own
+// ids where no pick of the user's is in play — its default model before
+// one is picked (claude-opus-5), claude-haiku-… for its small tasks — so a
+// model magpie doesn't serve goes to the one its last turn was on
+// (scienceTurn).
+
+// ScienceID is Claude Science's agent id.
+const ScienceID = "claude-science"
+
+// scienceSurface is the X-Anthropic-Surface Claude Science's client sends
+// on every request (YYe in its bundle).
+const scienceSurface = "operon"
+
+// scienceAlias is the prefix of the id a model is listed to Claude Science
+// by: claude-magpie-, the number a hash of magpie's id.
+const scienceAlias = "claude-magpie-"
+
+// isClaudeScience is a request from Claude Science's own client.
+func isClaudeScience(r *http.Request) bool {
+ return strings.EqualFold(strings.TrimSpace(r.Header.Get("X-Anthropic-Surface")), scienceSurface)
+}
+
+// scienceSlug is a name Claude Science takes for an internal model's id
+// and leaves out of its picker (kor in its bundle).
+var scienceSlug = regexp.MustCompile(`^[a-z][a-z0-9]*(?:-[a-z0-9]+)+$`)
+
+// scienceName is a model's name as Claude Science is shown it: a slug's
+// first letter in upper case, which its picker keeps.
+func scienceName(name string) string {
+ if !scienceSlug.MatchString(name) {
+ return name
+ }
+ r, n := utf8.DecodeRuneInString(name)
+ return string(unicode.ToUpper(r)) + name[n:]
+}
+
+// scienceObject is e as Claude Science is shown it: by its alias and a
+// name its picker keeps, with the reply limit as max_tokens, which is
+// what it reads one by (c5t in its bundle).
+func scienceObject(e provider.Entry, name string) map[string]any {
+ m := modelObject(e)
+ m["id"], m["display_name"] = scienceAlias+aliasNumber(e.ID), scienceName(name)
+ if out := e.PublishedOutput(); out > 0 {
+ m["max_tokens"] = out
+ }
+ return m
+}
+
+// scienceModels is /v1/models as Claude Science is shown it: every model
+// picked for it (provider.CatalogFor) by its alias, named as Claude
+// Desktop's are (desktopNames), no two alike.
+func scienceModels(entries []provider.Entry) []map[string]any {
+ names := desktopNames(entries)
+ data := make([]map[string]any, 0, len(entries))
+ for i, e := range entries {
+ data = append(data, scienceObject(e, names[i]))
+ }
+ return data
+}
+
+// sciencePicked is the model Claude Science's latest turn was on, kept on
+// disk so a request after a restart goes there too.
+var sciencePicked struct {
+ sync.Mutex
+ model string
+ from string // the file it was read from
+}
+
+func sciencePickedPath() string { return filepath.Join(settings.Dir(), "claude-science.model") }
+
+// scienceTurn is the model a Claude Science request for asked is served
+// by: asked when magpie serves it, a turn's (it carries tools) noted as
+// the one picked; else the model picked last, else the first one listed
+// to it.
+func scienceTurn(asked string, body []byte) string {
+ sciencePicked.Lock()
+ defer sciencePicked.Unlock()
+ if path := sciencePickedPath(); sciencePicked.from != path {
+ b, _ := os.ReadFile(path)
+ sciencePicked.model, sciencePicked.from = strings.TrimSpace(string(b)), path
+ }
+ picked := sciencePicked.model
+ if unserved(asked) {
+ if picked != "" && !unserved(picked) {
+ return picked
+ }
+ if shown, _ := provider.CatalogFor(ScienceID); len(shown) > 0 {
+ return shown[0].ID
+ }
+ return asked
+ }
+ if asked != picked && hasTools(body) {
+ sciencePicked.model = asked
+ if os.MkdirAll(settings.Dir(), 0o755) == nil {
+ os.WriteFile(sciencePickedPath(), []byte(asked+"\n"), 0o600)
+ }
+ }
+ return asked
+}
diff --git a/internal/gateway/science_test.go b/internal/gateway/science_test.go
new file mode 100644
index 000000000..cd9727dec
--- /dev/null
+++ b/internal/gateway/science_test.go
@@ -0,0 +1,130 @@
+package gateway
+
+import (
+ "encoding/json"
+ "net/http/httptest"
+ "strings"
+ "testing"
+
+ "github.com/yetone/magpie/internal/provider"
+)
+
+// Claude Science, started on magpie's gateway, sends what its client sends
+// once signed in (its bundle's yz(): its Claude sign-in as a bearer,
+// X-Anthropic-Surface: operon, anthropic-beta: oauth-2025-04-20). It is
+// known by that header, listed every model by a claude-… alias its picker
+// keeps, and served the model it picked on a third-party provider, with
+// the provider's key: its sign-in goes nowhere. A Claude model it asks for
+// by Anthropic's id that magpie doesn't serve (its default before a pick,
+// its haiku for small tasks) goes to the model it was last on.
+func TestClaudeScienceIsServedMagpiesModels(t *testing.T) {
+ f := &fake{t: t, reply: sse(
+ `data: {"id":"c1","model":"m1","choices":[{"delta":{"role":"assistant","content":"ok"}}]}`,
+ `data: {"id":"c1","choices":[{"delta":{},"finish_reason":"stop"}]}`,
+ `data: {"id":"c1","choices":[],"usage":{"prompt_tokens":3,"completion_tokens":1}}`,
+ `data: [DONE]`)}
+ up := setup(t, provider.Chat, f)
+ p := provider.Provider{ID: "fake", Name: "Fake", Key: "k", Chat: up.URL + "/v1", Models: []string{"m1", "deepseek-v4-pro"}}
+ if err := provider.Save(p); err != nil {
+ t.Fatal(err)
+ }
+ signIn := "Bearer sk-ant-oat01-" + strings.Repeat("s", 24) // made up, of a sign-in's shape
+ s := New()
+ send := func(method, path, body string) *httptest.ResponseRecorder {
+ t.Helper()
+ rec := httptest.NewRecorder()
+ req := httptest.NewRequest(method, path, strings.NewReader(body))
+ req.Header.Set("User-Agent", "Anthropic/JS 0.71.0")
+ req.Header.Set("Authorization", signIn)
+ req.Header.Set("X-Anthropic-Surface", "operon")
+ req.Header.Set("Anthropic-Beta", "oauth-2025-04-20,server-side-fallback-2026-06-01")
+ req.Header.Set("Anthropic-Version", "2023-06-01")
+ if body != "" {
+ req.Header.Set("Content-Type", "application/json")
+ }
+ s.Handler().ServeHTTP(rec, req)
+ return rec
+ }
+
+ // its list: only ids its picker keeps (claude-…, a name that isn't a
+ // slug), each one magpie's model by its alias
+ rec := send("GET", "/v1/models?limit=1000", "")
+ var list struct {
+ Data []struct {
+ ID string `json:"id"`
+ DisplayName string `json:"display_name"`
+ } `json:"data"`
+ HasMore bool `json:"has_more"`
+ }
+ if rec.Code != 200 || json.Unmarshal(rec.Body.Bytes(), &list) != nil || len(list.Data) != 2 || list.HasMore {
+ t.Fatalf("models: %d %s", rec.Code, rec.Body.String())
+ }
+ alias := map[string]string{}
+ for _, m := range list.Data {
+ if !strings.HasPrefix(m.ID, "claude-") || scienceSlug.MatchString(m.DisplayName) {
+ t.Errorf("listed %q named %q, which Claude Science's picker leaves out", m.ID, m.DisplayName)
+ }
+ real, ok := aliased(m.ID)
+ if !ok {
+ t.Errorf("%q is no alias of magpie's", m.ID)
+ }
+ alias[real] = m.ID
+ }
+ m1 := alias["fake/m1"]
+ if m1 == "" || alias["fake/deepseek-v4-pro"] == "" {
+ t.Fatalf("aliases: %v", alias)
+ }
+ // one model, as its caps are read, by the id it asked by
+ if rec := send("GET", "/v1/models/"+m1, ""); rec.Code != 200 || !strings.Contains(rec.Body.String(), `"id":"`+m1+`"`) {
+ t.Errorf("model: %d %s", rec.Code, rec.Body.String())
+ }
+
+ turn := func(model string, tools bool) map[string]any {
+ t.Helper()
+ body := `{"model":"` + model + `","max_tokens":50,"stream":true,"messages":[{"role":"user","content":"hi"}]`
+ if tools {
+ body += `,"tools":[{"name":"run_python","description":"run a cell","input_schema":{"type":"object"}}]`
+ }
+ f.got, f.head = nil, nil
+ rec := send("POST", "/v1/messages", body+"}")
+ if rec.Code != 200 || !strings.Contains(rec.Body.String(), "message_stop") {
+ t.Fatalf("%s: %d %s", model, rec.Code, rec.Body.String())
+ }
+ for k, vs := range f.head {
+ for _, v := range vs {
+ if strings.Contains(v, "sk-ant-oat") {
+ t.Errorf("%s: its sign-in went to the provider in %s", model, k)
+ }
+ }
+ }
+ if got := f.head.Get("Authorization"); got != "Bearer k" {
+ t.Errorf("%s: the provider was sent %q, want its own key", model, got)
+ }
+ if got := s.Recent()[0].Agent; got != ScienceID {
+ t.Errorf("%s: recorded as %q, want %s", model, got, ScienceID)
+ }
+ var up map[string]any
+ json.Unmarshal(f.got, &up)
+ return up
+ }
+ // before any pick, its default goes to the first model it is listed
+ if up := turn("claude-opus-5", true); up["model"] != "m1" {
+ t.Errorf("its default went to %v, want m1", up["model"])
+ }
+ // a turn on a model it picked, which is then the one picked
+ if up := turn(alias["fake/deepseek-v4-pro"], true); up["model"] != "deepseek-v4-pro" {
+ t.Errorf("its pick went to %v", up["model"])
+ }
+ // its small task on Anthropic's haiku goes there too
+ if up := turn("claude-haiku-4-5-20251001", false); up["model"] != "deepseek-v4-pro" {
+ t.Errorf("its haiku went to %v, want the model picked", up["model"])
+ }
+ // and a request without its header is no Claude Science's
+ rec = httptest.NewRecorder()
+ req := httptest.NewRequest("GET", "/v1/models", nil)
+ req.Header.Set("User-Agent", "Anthropic/JS 0.71.0")
+ s.Handler().ServeHTTP(rec, req)
+ if strings.Contains(rec.Body.String(), scienceAlias) {
+ t.Errorf("another Anthropic SDK client was listed Claude Science's aliases: %s", rec.Body.String())
+ }
+}
diff --git a/internal/gui/assets/i18n.js b/internal/gui/assets/i18n.js
index b79f58711..7493c4ade 100644
--- a/internal/gui/assets/i18n.js
+++ b/internal/gui/assets/i18n.js
@@ -4209,6 +4209,7 @@ const I18N = {
"{agent} in WSL {distro} uses this for new tasks in its Console — restart open morph chats to use it there.": "WSL {distro} 中的 {agent} 会在 Console 的新任务中使用这项设置;已打开的 morph 对话需重启才会生效。",
"{agent} in WSL {distro} wants its own sign-in there (cmd login) even for models through magpie, and reads its settings at start-up — restart open Command Code sessions to use this.": "即使通过 magpie 使用模型,WSL {distro} 中的 {agent} 也要求在那里完成它自己的登录(cmd login);它启动时读取设置,需重启已打开的 Command Code 会话才会生效。",
"{agent} reads its settings as a session starts — open sessions keep the model they have; new ones use this.": "{agent} 在会话开始时读取设置:已打开的会话保留原来的模型,新会话使用这项设置。",
+ "{agent}'s daemon runs on magpie's gateway: open {agent} again (reload its window if it is open). It still needs you signed in with your Claude account, which magpie never sends on; pick a model of magpie's in its model menu.": "{agent} 的后台进程已在 magpie 的网关上运行:请重新打开 {agent}(窗口已打开的话请刷新)。它仍需要你登录 Claude 账号,magpie 不会把这个登录转发出去;请在它的模型菜单里选择 magpie 的模型。",
"{agent} reads magpie's gateway from CURSOR_LOCAL_AGENT_BASE_URL and CURSOR_LOCAL_AGENT_API_KEY, now set for your user: quit it (the app, not only its window) and open it again, as it keeps the model list it was first given until it quits. A base URL or API key set in its Open configuration or a model's settings comes first, so leave both empty (or set the base URL to {url} and the key to {key}).": "{agent} 从 CURSOR_LOCAL_AGENT_BASE_URL 和 CURSOR_LOCAL_AGENT_API_KEY 读取 magpie 的网关,这两个变量现已为当前用户设置:请退出它(整个应用,不只是窗口)再重新打开,因为退出前它一直沿用最初拿到的模型列表。它的 Open configuration 或某个模型设置里填写的 Base URL 或 API Key 优先,所以请把两者留空(或把 Base URL 设为 {url}、Key 设为 {key})。",
"{agent}'s Chat features must be enabled (chat.disableAIFeatures=false) and its product.json must include defaultChatAgent and trustedExtensionAuthAccess for GitHub.copilot-chat. Then run Developer: Reload Window in {agent}.": "{agent} 需开启 Chat 功能(chat.disableAIFeatures=false),且它的 product.json 需为 GitHub.copilot-chat 包含 defaultChatAgent 和 trustedExtensionAuthAccess。然后在 {agent} 中运行 Developer: Reload Window。",
"{agent}'s GitHub Copilot Chat {version} has neither a Custom Endpoint nor an OpenAI Compatible provider, so it can't list magpie's models.": "{agent} 的 GitHub Copilot Chat {version} 既没有 Custom Endpoint 也没有 OpenAI Compatible 供应商,因此无法列出 magpie 的模型。",
@@ -8405,6 +8406,7 @@ const I18N = {
"{agent} in WSL {distro} uses this for new tasks in its Console — restart open morph chats to use it there.": "WSL {distro} 中的 {agent} 會在 Console 的新任務中使用這項設定;已打開的 morph 對話需重啟才會生效。",
"{agent} in WSL {distro} wants its own sign-in there (cmd login) even for models through magpie, and reads its settings at start-up — restart open Command Code sessions to use this.": "即使通過 magpie 使用模型,WSL {distro} 中的 {agent} 也要求在那裡完成它自己的登入(cmd login);它啟動時讀取設定,需重啟已打開的 Command Code 會話才會生效。",
"{agent} reads its settings as a session starts — open sessions keep the model they have; new ones use this.": "{agent} 在會話開始時讀取設定:已打開的會話保留原來的模型,新會話使用這項設定。",
+ "{agent}'s daemon runs on magpie's gateway: open {agent} again (reload its window if it is open). It still needs you signed in with your Claude account, which magpie never sends on; pick a model of magpie's in its model menu.": "{agent} 的背景程序已在 magpie 的閘道上執行:請重新打開 {agent}(視窗已打開的話請重新整理)。它仍需要你登入 Claude 帳號,magpie 不會把這個登入轉發出去;請在它的模型選單裡選擇 magpie 的模型。",
"{agent} reads magpie's gateway from CURSOR_LOCAL_AGENT_BASE_URL and CURSOR_LOCAL_AGENT_API_KEY, now set for your user: quit it (the app, not only its window) and open it again, as it keeps the model list it was first given until it quits. A base URL or API key set in its Open configuration or a model's settings comes first, so leave both empty (or set the base URL to {url} and the key to {key}).": "{agent} 從 CURSOR_LOCAL_AGENT_BASE_URL 和 CURSOR_LOCAL_AGENT_API_KEY 讀取 magpie 的閘道,這兩個變數現已為目前使用者設定:請退出它(整個應用,不只是視窗)再重新打開,因為退出前它一直沿用最初拿到的模型列表。它的 Open configuration 或某個模型設定裡填寫的 Base URL 或 API Key 優先,所以請把兩者留空(或把 Base URL 設為 {url}、Key 設為 {key})。",
"{agent}'s Chat features must be enabled (chat.disableAIFeatures=false) and its product.json must include defaultChatAgent and trustedExtensionAuthAccess for GitHub.copilot-chat. Then run Developer: Reload Window in {agent}.": "{agent} 需開啟 Chat 功能(chat.disableAIFeatures=false),且它的 product.json 需為 GitHub.copilot-chat 包含 defaultChatAgent 和 trustedExtensionAuthAccess。然後在 {agent} 中執行 Developer: Reload Window。",
"{agent}'s GitHub Copilot Chat {version} has neither a Custom Endpoint nor an OpenAI Compatible provider, so it can't list magpie's models.": "{agent} 的 GitHub Copilot Chat {version} 既沒有 Custom Endpoint 也沒有 OpenAI Compatible 供應商,因此無法列出 magpie 的模型。",
@@ -12603,6 +12605,7 @@ const I18N = {
"{agent} in WSL {distro} uses this for new tasks in its Console — restart open morph chats to use it there.": "WSL {distro} の {agent} は Console の新しいタスクでこれを使います。開いている morph チャットに反映するには再起動してください。",
"{agent} in WSL {distro} wants its own sign-in there (cmd login) even for models through magpie, and reads its settings at start-up — restart open Command Code sessions to use this.": "WSL {distro} の {agent} は magpie 経由のモデルでもそこで自身のサインイン(cmd login)が必要で、起動時に設定を読み込みます。反映するには開いている Command Code セッションを再起動してください。",
"{agent} reads its settings as a session starts — open sessions keep the model they have; new ones use this.": "{agent} はセッション開始時に設定を読み込みます。開いているセッションは今のモデルのままで、新しいセッションからこれを使います。",
+ "{agent}'s daemon runs on magpie's gateway: open {agent} again (reload its window if it is open). It still needs you signed in with your Claude account, which magpie never sends on; pick a model of magpie's in its model menu.": "{agent} のデーモンは magpie のゲートウェイで動いています。{agent} を開き直してください(ウィンドウが開いていれば再読み込み)。引き続き Claude アカウントでのサインインが必要ですが、magpie がそれを転送することはありません。モデルメニューで magpie のモデルを選んでください。",
"{agent} reads magpie's gateway from CURSOR_LOCAL_AGENT_BASE_URL and CURSOR_LOCAL_AGENT_API_KEY, now set for your user: quit it (the app, not only its window) and open it again, as it keeps the model list it was first given until it quits. A base URL or API key set in its Open configuration or a model's settings comes first, so leave both empty (or set the base URL to {url} and the key to {key}).": "{agent} は magpie のゲートウェイを CURSOR_LOCAL_AGENT_BASE_URL と CURSOR_LOCAL_AGENT_API_KEY から読み込みます。これらは今のユーザーに設定済みです。終了するまで最初に受け取ったモデル一覧を使い続けるため、(ウィンドウだけでなくアプリごと)終了して開き直してください。Open configuration やモデルの設定にある Base URL や API Key が優先されるので、どちらも空にしてください(または Base URL を {url}、Key を {key} に)。",
"{agent}'s Chat features must be enabled (chat.disableAIFeatures=false) and its product.json must include defaultChatAgent and trustedExtensionAuthAccess for GitHub.copilot-chat. Then run Developer: Reload Window in {agent}.": "{agent} の Chat 機能が有効(chat.disableAIFeatures=false)で、product.json に GitHub.copilot-chat 用の defaultChatAgent と trustedExtensionAuthAccess が含まれている必要があります。そのあと {agent} で Developer: Reload Window を実行してください。",
"{agent}'s GitHub Copilot Chat {version} has neither a Custom Endpoint nor an OpenAI Compatible provider, so it can't list magpie's models.": "{agent} の GitHub Copilot Chat {version} には Custom Endpoint も OpenAI Compatible プロバイダもないため、magpie のモデルを一覧に出せません。",
@@ -16801,6 +16804,7 @@ const I18N = {
"{agent} in WSL {distro} uses this for new tasks in its Console — restart open morph chats to use it there.": "{agent} in WSL {distro} nutzt dies für neue Aufgaben in seiner Console – offene morph-Chats neu starten, damit es dort gilt.",
"{agent} in WSL {distro} wants its own sign-in there (cmd login) even for models through magpie, and reads its settings at start-up — restart open Command Code sessions to use this.": "{agent} in WSL {distro} verlangt dort auch für Modelle über magpie eine eigene Anmeldung (cmd login) und liest seine Einstellungen beim Start – offene Command-Code-Sitzungen neu starten, damit es gilt.",
"{agent} reads its settings as a session starts — open sessions keep the model they have; new ones use this.": "{agent} liest seine Einstellungen beim Start einer Sitzung – offene Sitzungen behalten ihr Modell, neue nutzen dies.",
+ "{agent}'s daemon runs on magpie's gateway: open {agent} again (reload its window if it is open). It still needs you signed in with your Claude account, which magpie never sends on; pick a model of magpie's in its model menu.": "Der Daemon von {agent} läuft über magpies Gateway: {agent} erneut öffnen (ein offenes Fenster neu laden). Es braucht weiterhin Ihre Anmeldung mit Ihrem Claude-Konto, die magpie nie weitergibt; wählen Sie im Modellmenü ein Modell von magpie.",
"{agent} reads magpie's gateway from CURSOR_LOCAL_AGENT_BASE_URL and CURSOR_LOCAL_AGENT_API_KEY, now set for your user: quit it (the app, not only its window) and open it again, as it keeps the model list it was first given until it quits. A base URL or API key set in its Open configuration or a model's settings comes first, so leave both empty (or set the base URL to {url} and the key to {key}).": "{agent} liest magpies Gateway aus CURSOR_LOCAL_AGENT_BASE_URL und CURSOR_LOCAL_AGENT_API_KEY, die nun für Ihren Benutzer gesetzt sind: beenden (die App, nicht nur das Fenster) und neu öffnen, denn es behält die zuerst erhaltene Modellliste, bis es beendet wird. Eine Base URL oder ein API Key in seiner Open configuration oder den Einstellungen eines Modells geht vor, also beide leer lassen (oder die Base URL auf {url} und den Key auf {key} setzen).",
"{agent}'s Chat features must be enabled (chat.disableAIFeatures=false) and its product.json must include defaultChatAgent and trustedExtensionAuthAccess for GitHub.copilot-chat. Then run Developer: Reload Window in {agent}.": "Die Chat-Funktionen von {agent} müssen aktiviert sein (chat.disableAIFeatures=false), und seine product.json muss defaultChatAgent und trustedExtensionAuthAccess für GitHub.copilot-chat enthalten. Danach in {agent} Developer: Reload Window ausführen.",
"{agent}'s GitHub Copilot Chat {version} has neither a Custom Endpoint nor an OpenAI Compatible provider, so it can't list magpie's models.": "GitHub Copilot Chat {version} in {agent} hat weder einen Custom Endpoint noch einen OpenAI-Compatible-Anbieter und kann magpies Modelle daher nicht auflisten.",
@@ -16897,6 +16901,7 @@ const NOTICES = [
"{agent} reads magpie's gateway from CURSOR_LOCAL_AGENT_BASE_URL and CURSOR_LOCAL_AGENT_API_KEY, now set for your user: quit it (the app, not only its window) and open it again, as it keeps the model list it was first given until it quits. A base URL or API key set in its Open configuration or a model's settings comes first, so leave both empty (or set the base URL to {url} and the key to {key}).",
"{agent}'s Chat features must be enabled (chat.disableAIFeatures=false) and its product.json must include defaultChatAgent and trustedExtensionAuthAccess for GitHub.copilot-chat. Then run Developer: Reload Window in {agent}.",
"{agent}'s GitHub Copilot Chat {version} has neither a Custom Endpoint nor an OpenAI Compatible provider, so it can't list magpie's models.",
+ "{agent}'s daemon runs on magpie's gateway: open {agent} again (reload its window if it is open). It still needs you signed in with your Claude account, which magpie never sends on; pick a model of magpie's in its model menu.",
"~/.dsh/settings.yaml sets its own DeepSeek endpoint or key, which dsh puts over magpie's; clear it in dsh's Models page to go through magpie.",
];