f2eb56c6bbde1300dddc402861b59cd4e45e0215
37
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
9474eaf9cb |
sessions: Raft's Pi agents' sessions are listed as Raft's, with their prompts, calls and delete
Raft (slock's raft-computer) runs its agents on Pi and keeps each one's Pi SDK session files in that agent's folder: <slock>/agents/<id>/ .pi-sessions/<ts>_<id>.jsonl, or .builtin-sessions/ for its built-in runtime. <slock> is $SLOCK_HOME or ~/.slock (%USERPROFILE%\.slock on Windows, the distro's ~/.slock under WSL). Read from raft-computer 1.0.14's PiDriver (buildPiSessionDir), BuiltInDriver and resolveSlockHome, and a read-only listing of ~/.slock here. runtime-sessions/ holds handoff notes, no sessions, and is not read. - The Sessions page lists them as Raft's (agent "raft", in agent.Clients' others), titled and opened with their prompts as Pi's are. - Their calls count on the Usage page as Raft's; calls through magpie stay the gateway's, as Pi's do. - Raft's Pi uses the user's own ~/.pi/agent, so a request it sends through magpie reaches the gateway as Pi's under the same session id. sessions.GatewayKeys gives a Raft session both "raft|ID" and "pi|ID", so the gateway's copy is not listed twice nor counted twice (Merge, stats, NativeIDs, the GUI's Via). - Delete and restore work as Pi's: the one file goes to the trash, and a folder beside it is left (the agent's workspace is not the session's). A session written in the last minutes is refused as active. - No resume command, no carry and no trace export: Raft starts its own agents, and nothing outside it can resume one. - SLOCK_HOME is passed through agentenv like the other agents' homes. Run (at 958ad9f10 on |
||
|
|
3c6b7d585f |
agent: OpenClaw is wired up like the other agents
arthur041691 (Discord #help) runs OpenClaw for WhatsApp and asked for it in
Agents. Connecting writes magpie as a custom provider of OpenClaw's own, in
openclaw.json, and makes the picked model agents.defaults.model's primary.
What is written, from OpenClaw's source at 5bab0c14 (npm 2026.10.8, dc2523e):
- the file: OPENCLAW_CONFIG_PATH, else $OPENCLAW_STATE_DIR/openclaw.json,
else ~/.openclaw-<profile> for a named OPENCLAW_PROFILE, else
~/.openclaw; ~ is OPENCLAW_HOME when set (src/config/paths.ts,
src/config/state-dir.ts, src/cli/profile-utils.ts). OPENCLAW_PROFILE is
a name, not a path (agentenv.NotPaths); the other three expand a
leading ~, as resolveUserPath does (appdir.usable).
- models.providers.magpie: baseUrl (the gateway's /v1), apiKey (the
OpenClaw-named gateway key), api "openai-completions", and every model
magpie serves with id, name, input, reasoning and contextWindow
(src/config/zod-schema.core.ts, docs/gateway/config-tools/custom-providers.md).
A user's own keys on a model entry (headers, maxTokens…) stay on Sync.
- agents.defaults.model keeps its shape (string or {primary, fallbacks});
agents.defaults.models gets the ref's {} entry as `openclaw models set`
adds it (src/commands/models/shared.ts), only when that map exists; a
non-empty modelPolicy.allow gets "magpie/*" when nothing there lets
magpie's models in (src/agents/model-selection-normalize.ts).
- Model changes are hot-reloaded (docs/gateway/configuration/hot-reload.md);
a chat that already has a model keeps it (docs/concepts/models.md), so
the notice says to send /model default there. Translated in every
language.
- The file is written through temp-and-rename; a new one is 0600 in a
0700 folder, as OpenClaw makes it (src/config/io.write.ts). A file that
isn't JSON after comments are blanked (JSON5's bare keys) is left alone
with an error, never read as empty.
- Disconnect puts back the model there was, removes magpie's provider,
its {} entries, the allow entry and any object magpie made, and the
file itself if magpie made it.
Icon: a mask drawn from OpenClaw's ui/public/favicon.svg (MIT).
Run, on mote at this tree:
- go test -tags nogui ./internal/agent -run OpenClaw plus the every-agent
tests (drift, port move, sync on another machine, reverse proxy, LAN,
pinned key per writer, notices translated), ./internal/appdir,
./internal/agentenv: ok.
- Broken by hand, each red then green again: no stash restore
(TestOpenClaw, Shapes, AllowList), user keys dropped
(SyncKeepsTheirs), no allow entry (AllowList), no JSON5 guard
(JSON5LeftAlone), profile ignored (Paths), OPENCLAW_PROFILE back as a
path variable (Paths).
- Real OpenClaw 2026.10.8 from npm, Node 24.22.2, sandbox HOME on mote:
onboard --non-interactive made the file (its bytes are the test
fixture); magpie's code connected it; `openclaw config validate` ok;
`openclaw models list` shows magpie/kimi/k2 as default; `openclaw agent
--local` sent POST /v1/chat/completions with Bearer magpie-openclaw and
model kimi/k2 to a fake gateway on 3425 and showed its reply; no
agents/*/models.json override was written; Disconnect gave the file
back byte for byte and it validates.
- GUI: i18n-keys, agent-notice-lang, icon-tile, about-notices,
agent-connect (Chromium and WebKit): 53/53.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows ok.
- Full suite, go test -tags nogui -timeout 45m ./... at
|
||
|
|
3116b8f58a |
agentenv: every sandbox clears CARGO_HOME, where the Library finds rtk (#3884)
TestFolderVarsAreListed (internal/agent) is red on main since |
||
|
|
e7173958e9 |
agent: NewMax, magpie's models in its model picker (jwaitq on Discord)
jwaitq asked in #general (10-27) for NewMax (newmax.cc), an Electron app
built on the Claude Agent SDK. NewMax keeps its settings in
~/.newmax/newmax.db ($NEWMAX_USER_DATA_DIR wins), a SQLite table
settings(key, value) whose "app" row is JSON.stringify of every setting.
Connect adds one Anthropic-format provider, id magpie-gateway, with
magpie's gateway root (NewMax adds /v1/messages itself), its key and up to
20 models (NewMax's MAX_MODELS), appends it to providerOrder and, when
the user had kept NewMax's default, picks it. The row is edited by
splicing raw JSON in one immediate transaction, so every other byte the
user has stays as written. Disconnect removes the entry and its order id,
puts providerId/model back to "default" when they were magpie's, and
deletes the row when magpie made it. NewMax holds settings in memory and
writes the whole row on any change, so magpie refuses to write while
NewMax runs (macOS/Linux, matched on the program, not on a folder named
newmax) and says why in every language.
Run:
- go test -tags nogui -count=1 -timeout 45m ./internal/agent
./internal/agentenv ./internal/appdir ./internal/sessions at this head
(rebased on
|
||
|
|
3fd7e16983 |
agent: PenguinHarness is installed from the Agents page and served by magpie with nothing to set up
rankyurky asked on Discord #feedback for PenguinHarness (npm @prismshadow/penguin-cli, command penguin). Every value comes from Penguin's own source (0.2.17): - Config: $PENGUIN_HOME (else ~/.penguin/data, every OS) / $PENGUIN_PROJECT_ID (else default_project) /.project_config.toml. magpie writes [providers.magpie] (base_url, client_type, api_key), one [[models]] entry per magpie model (context_window, vision, max_tokens, [models.pricing] in usd_per_mtok) and default_model in Penguin's own inline spelling. Penguin's server reads the file again when its mtime changes, so no restart; a default naming no entry is refused by Penguin, so Check fails when one is missing. - A file magpie creates is 0600 in a 0700 folder, as Penguin keeps it. Disconnect restores the user's own default_model (or none), drops a magpie vision model, and removes the file when magpie made it. Penguin's own entries, providers and command_policy rules are kept. - A sync that changes nothing writes nothing (bytes and mtime kept), so Penguin's watcher isn't woken. - Install: curl -fsSL https://penguin.ooo/install.sh | sh, or irm https://penguin.ooo/install.ps1 | iex on Windows; update: npm, or penguin update --yes for the tarball, except on Windows where update.ts refuses it. - WSL: a penguin kind with no restart notice; the WSL test now expects an empty Notice for a kind with no restart. - agentenv: PENGUIN_HOME, PENGUIN_PROJECT_ID; the project id is in NotPaths, or appdir dropped a value like "work" as a relative path. - edit.SetTOMLArrayTables: replaces every [[name]] entry with key = value (with child tables) by blocks, or removes them; blank lines between replaced entries go with them, and an unchanged result isn't written. - GUI: penguin-color.svg icon; README (en, zh-CN), docs/reference.md and docs/subsystems/agent-wiring.md. Run (worktree at |
||
|
|
b5d46acbed |
agent: Kiro Crew runs on a harness connected to magpie
Vincent on Discord asked for Kiro Crew (kirodotdev/KiroCrew v0.9.0: the KiroCrew.app desktop app, the kirocrew CLI, its dashboard and the Gateway on :5476). Crew has no model provider of its own. It runs each session on an ACP harness picked by agent.acp_backend (and dispatched members by agent.member_acp_backend) in $KIROCREW_HOME/config.json, default ~/.kiro/crew (src/kiro_crew/config/paths.py, loader.py, sections.py; ACP_BACKENDS_MEMBER_DISPATCH in agent_sdk/backends.py). Connecting sets those keys to an agent already connected to magpie, tried in this order: Codex, Claude Code, OpenCode, Pi, Goose. One whose ACP adapter is installed (codex-acp, claude-agent-acp, pi-acp) wins, so one click is enough. magpie looks for the adapter where Crew does and installs nothing; when it's missing, the notice gives the npm command. With no harness connected the connect is refused with a message naming which agents to connect. A harness set in config.local.json wins over config.json, so magpie doesn't write it and the row says so. The previous values are stashed. On Disconnect they are put back, but only for keys that still hold what magpie wrote, and a file magpie created is removed once it's empty. The row reads as connected only while its harness is still wired to magpie. deepseek is not offered: Crew runs it as dsh --profile acp, which magpie's dsh wiring doesn't reach. KIROCREW_HOME and the adapter path variables are read from the login shell (agentenv). Run (Go and the GUI files at base |
||
|
|
9228bd443f |
library: skills are grouped by source when the skills CLI keeps its lock under $XDG_STATE_HOME (@_yukirock on X)
skills 1.7 writes its global lock to $XDG_STATE_HOME/skills/.skill-lock.json
when that variable is set, and only to ~/.agents/.skill-lock.json otherwise.
The Library read only the ~/.agents one, so with XDG_STATE_HOME set every
`npx skills add` skill had no repository and the "By source" view could not
group them. Both locks are now read, the XDG one winning per skill, since a
lock written before the variable was set still names older skills.
XDG_STATE_HOME joins agentenv.Vars, so the desktop app takes it from the
login shell like the other folder variables (TestFolderVarsAreListed).
Not handled: a project install's ./skills-lock.json.
Run (worktree at origin/main
|
||
|
|
5c0049a38c |
agent: MothX is an Agents-page row, wired into ~/.mothx/settings.json, and Disconnect puts it back (#2353, zhenruyan)
MothX (oschina/mothx, formerly vibecoding; npm mothx-installer) reads its providers and start-up model from one settings.json: $MOTHX_DIR, else %APPDATA%\mothx on Windows, else ~/.mothx. This follows zhenruyan's fork (#2353) and the jcode/Prime Agent pattern. What changed - internal/agent/mothx.go: the agent. Connect writes provider "magpie" (openai-chat at the gateway's /v1, key magpie-mothx, one entry per magpie model with reasoning, input, contextWindow, maxTokens, cost) beside the user's own providers, and sets defaultProvider/defaultModel; "thinking" is defaultThinkingLevel, narrowed to the levels magpie knows for the model (none → off). thinkingFormat "openai" makes MothX send reasoning_effort for every model; without it MothX guesses Qwen's enable_thinking/thinking_budget or DeepSeek's thinking from the model id. A thinkingFormat or headers the user put in magpie's block are kept. Model options: the user's own providers' models, the current built-in pick (deepseek-openai/…), then magpie's. - Disconnect: settings.json is copied aside before magpie's first write (beforeMagpie) and put back byte for byte when nothing else changed; a file that wasn't there goes again. When MothX rewrote it meanwhile (/model, /statusline … global: SaveGlobalSettings marshals the whole struct), only magpie's provider, the pick and a providers object left empty go; the user's changes stay. - Detection, the restart notice (mothx or vibecoding running; translated in zh-CN, zh-TW, ja, de), WSL distros (~/.mothx), MOTHX_DIR in agentenv and the WSL dir moves, CLI updates through npm mothx-installer. - usage names its requests: the User-Agent is "Vibecoding Client/<ver>", matched by the alias vibecoding (usage.AgentOf takes the first word). - GUI: the icon (upstream docs/assets/mothx-small.png, MIT). - Docs: README en/zh lists, docs/reference.md (table row, provider-scoped list, notes), docs/subsystems/agent-wiring.md. - Not in this commit: MothX as a Library skills target (its own goal). Run - go test -p 1 -tags nogui: TestMothX* (real first-run settings.json as the fixture; user keys, headers and thinkingFormat kept; no-op Sync and same-value Set leave bytes and mtime alone; Disconnect byte-identical; no-file round trip x2; changes while connected kept; MOTHX_DIR/Windows/ WSL dirs; thinking levels), TestAgentOf, TestEveryNoticeIsTranslated, TestEveryAgentNamedByItsKey, TestWSLMore*; then ./internal/agent (1120s at load ~100; an earlier run hit the default 10m timeout inside TestReasonixConcurrentEditsAndSync at load ~50, not a failure), ./internal/agentenv, ./internal/usage: ok. - Broken by hand, each red then restored: no take() (TestMothX and RoundTripNoFile red), user thinkingFormat not kept, thinkingFormat "openai" dropped, the vibecoding alias dropped (TestAgentOf: got "Vibecoding"), the empty-providers cleanup (KeepsWhatChanged red). - gofmt -l clean; GOOS=darwin/linux/windows go vet -tags nogui ./... clean. - GUI (playwright 1.62.0, chromium and webkit): agent-notice-lang, models-add-and-icons, pi-default-note 30/30; a scratch check of the MothX row (icon loads, connect, notice in the window's language, fits) in en/zh/zh-TW/ja/de at 1100 and 420: 22/22. - Real binary, MothX 1.3.104 (npm mothx-installer) in a sandbox HOME against a sandbox `magpie serve` and a fake OpenAI upstream: - `magpie mothx magpie/fake/echo-1` wrote the block; `mothx doctor` showed provider magpie, model fake/echo-1. - `mothx -P "Say PONG"` answered from the fake; usage.jsonl recorded agent mothx, provider fake. - Adding qwen3.7-plus to the provider live-synced the block (context, maxTokens, cost, reasoning). With thinking high, MothX sent reasoning_effort "high"; with thinkingFormat removed by hand it sent enable_thinking/thinking_budget instead, and `magpie provider refresh` put "openai" back. - The interactive TUI (tmux) started on "magpie | Qwen3.7 Plus · fake" and got the fake's reply; `magpie mothx effort medium` while it ran printed the restart notice. - `/statusline refresh 5 global` in the TUI rewrote the whole file (dropped reasoning:false, added responses:{…} to magpie's block); `magpie mothx` still read connected. `magpie mothx default` then left the original plus the user's refreshInterval, and (after the cleanup above) no empty providers. - Not tried: Windows and WSL with the real binary; a real vendor key. Full suite: SUITE_LINE |
||
|
|
79fec406c6 |
agent, gui: a Claude Code provider switch (CLAUDE_CODE_USE_BEDROCK, …) steps aside while magpie is wired in and comes back after; one magpie can't take out is said (jw1dev on X)
jw1dev's ~/.claude/settings.json had CLAUDE_CODE_USE_BEDROCK=1. magpie wrote
ANTHROPIC_BASE_URL and its model ids beside it. Bedrock ignores the base URL,
so Claude Code went to AWS, Bedrock refused magpie's model, and magpie still
showed Claude Code as connected.
Claude Code 2.1.300's six switches (agentenv.ClaudeProviders: BEDROCK,
VERTEX, FOUNDRY, ANTHROPIC_AWS, ANTHROPIC_GOOGLE_CLOUD, MANTLE; on = 1, true,
yes or on, any case, trimmed):
- In a settings file magpie writes (user settings, WSL twins), a switch
that is on is taken out on every route that writes the wiring: connect,
model pick and Rewire/Reapply through writeTiers, and Sync. Its raw JSON
value is stashed (claude.cloud.<var>, under the distro id for WSL). It is
put back as written when magpie steps out (Disconnect, or the model set
back to default), unless the user set it again since. AWS_*/GCP
variables and a switch that is off stay.
- Where magpie doesn't write it (managed settings, ~/.claude.json's env,
the login shell's env), Check names the variable, the cloud and the
file. It reads them in Claude Code's own order: managed wins, then the
user's settings, then ~/.claude.json, then the shell. Two notice
templates, translated in zh, zh-TW, ja and de. The row's line and its
Reconnect pill now show a drift detail through tNotice.
- proc.LoginEnv reads the switches but never sets them in magpie's env,
and testenv unsets them.
- T3 Code: a switch is never carried onto magpie's instance. Its Check
says when the user's ~/.claude settings have one on. That Check first
checks the instance's ANTHROPIC_BASE_URL against the gateway (t3EnvOf),
as every agent's Check must for TestDriftUnwiredEveryAgent,
TestPortMovesEveryAgent and TestReverseProxyIsStillMagpie.
- Claude Desktop's Code tab runs with CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST,
under which Claude Code ignores these switches in settings, so nothing
changes there.
Run:
- gofmt -l: clean.
- go vet: native ./..., GOOS=linux -tags nogui, GOOS=windows: clean.
- go test -tags nogui ./...: every package ok except internal/agent, where
t3code's first Check (cloud only) failed the three every-agent tests
above. Fixed with the wiring check, then the whole internal/agent package
was rerun: ok (368s).
- GUI, Chromium and WebKit, 102/102 each: new claude-cloud-drift (5
languages, 1100 and 420px, file and shell notices), gui-de, gui-ja,
gui-zh-tw, i18n-keys, agent-notice-lang, agent-proxied,
agent-unreachable, cli-behind, menu-scroll, agent-connect,
agent-disconnect.
- Sandbox HOME (scratchpad dir, live ~/.claude untouched):
- Setup: real claude 2.1.300 with settings.json
{CLAUDE_CODE_USE_BEDROCK:"1", AWS_REGION, AWS_PROFILE}, a magpie-cloud
binary from this tree serving on 127.0.0.1:3487, a fake OpenAI
upstream on 3486.
- `magpie claude fake/fake-model` took the switch out and stashed "1".
- `claude -p "say hi"` printed PONG-FROM-FAKE-UPSTREAM, and the fake
logged POST /v1/chat/completions model=fake-model.
- `magpie claude default` left settings.json byte-for-byte the same as
before connect (cmp).
- Control: the switch put back by hand beside the wiring (the reported
state). Claude Code never reached magpie: the fake logged nothing.
Broken by hand, each went red:
- no dropClouds in writeTiers, then in Sync;
- putClouds returning at once, and putClouds writing over the user's own;
- no claudeCloud in Check;
- the T3 filter and the T3 Check;
- shellVars without ClaudeProviders;
- the tNotice calls taken out of the line and pill: claude-cloud-drift
went 17 red.
Not tried:
- A project's .claude/settings.json(.local) isn't read, because magpie
doesn't know where Claude Code runs.
- WSL and Windows were not run for real; tests only.
- Real Vertex, Foundry and AWS accounts.
- T3 Code and Claude Desktop with a switch, run for real.
- The drift shown in the real app window. The CLI has no drift output.
- The user's own ANTHROPIC_MODEL being lost across connect/disconnect is a
separate gap, fixed in its own commit.
|
||
|
|
c6de0d2a54 |
daemon, agentenv: the service tools run through proc, and PI_DESKTOP_DATA_DIR is cleared in every sandbox
main has been red on ubuntu and macOS since 692a779d3's run (38376844048),
with two guards that each caught a commit run on chosen packages only:
- TestNoCommandBypassesProc: 5617281f5's daemon.run called exec.Command,
so on Windows the service tools would open a console window. It now uses
proc.Command.
- TestFolderVarsAreListed:
|
||
|
|
24146c0314 |
agentenv: REASONIX_STATE_HOME is cleared in every sandbox, as Library reads Reasonix's REASONIX.md from it
|
||
|
|
e528aeb3ce |
agent: DevEco Code, Huawei's OpenCode, as an agent (#1885)
foobra asked for DevEco Code (npm @deveco/deveco-code), Huawei's
HarmonyOS coding agent. It is OpenCode underneath, so it joins through
openCodeLike as MiMo Code did (
|
||
|
|
ee7a9b24a6 |
agent: Grok App is an agent magpie connects: a magpie provider channel with magpie's models and their efforts (#1625, fjrtdk)
fjrtdk asked for Grok App (RongleCat/grok-app, a desktop GUI over the Grok
Build CLI) as a full agent: MCP, skills, RTK, models and effort.
What was already there, read in the App's source:
- MCP: the App reads ~/.grok/config.toml's [mcp_servers] in both of its
modes and hands them to the CLI it starts, so the Grok Build row's MCP
sync already reaches it.
- Skills: Grok Build's ~/.agents/skills, synced from the Grok Build row.
- RTK: rtk has no installer for Grok Build, so there is nothing to wire.
What was missing is models, and that is what changed:
- internal/agent/grokapp.go: a new agent, "grok-app" (alias grokapp), for
the App's agent-home/config.toml under its data folder: GROK_APP_HOME,
else ~/Library/Application Support/com.grokapp.grok-app or ~/.grok-app
on a Mac, %APPDATA%\grokapp\grok-app\data (and two older places) on
Windows, $XDG_DATA_HOME/grok-app or ~/.grok-app on Linux; the first
that exists.
- Connecting writes a [model.magpie] channel in the App's own format
(its custom routes): model, base_url = the gateway's /v1, name,
api_key (magpie-grok-app, so usage says the App), api_backend =
"chat_completions", app_provider_mode = "generic", app_models and
app_efforts as JSON strings (the App unquotes them with serde_json),
supports_reasoning_effort, app_supports_vision for a model that takes
images, and context_window when magpie knows it. app_models lists
magpie's models with their effort levels ("none" left out), so the
App's model and effort pickers show them.
- It sets [models] default = "magpie"; what was there is stashed, and
Disconnect puts it back and drops the channel: the file is
byte-identical to before (TestGrokApp).
- A sync keeps the model and the default effort the user picked in the
App while magpie still serves them, and writes nothing when nothing
changed.
- Picking one of the App's own routes (the official "grok", or a
channel of the user's with a base_url) takes magpie out.
- The notice says to start a new chat or restart the App, which reads
its providers when it starts an agent; translated in i18n.js (zh-CN,
zh-TW, ja, de) and listed in NOTICES.
- agents.go, agentenv.go (GROK_APP_HOME), docs/reference.md,
docs/subsystems/agent-wiring.md, both READMEs' agent lists.
Picking magpie in the App is a custom route, so the App runs that agent in
its independent mode (its own #557): it clears agent-home's auth.json
rather than syncing the official sign-in. ~/.grok is never written.
What was run:
- go test -tags nogui ./internal/agent ./internal/agentenv ./internal/gui:
ok. Full go test -tags nogui ./... under a temp HOME: ok.
- gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui: ok.
- Broken by hand, each red: context_window written quoted (TestGrokApp);
the user's picked model ignored (TestGrokAppSyncKeepsTheirs); their
default effort dropped (SyncKeepsTheirs); Disconnect not unstashing
(TestGrokApp); a no-op sync writing (SyncKeepsTheirs); "none" listed
as an effort (TestGrokApp).
- Real use in a sandbox HOME: a built magpie on 127.0.0.1:3681 with a
fake upstream; `magpie grok-app magpie/fake/echo-1` wrote the channel;
the real grok 1.0.50, started as the App starts it on a custom route
(GROK_HOME=agent-home, --model magpie), answered through magpie, the
upstream saw echo-1 and usage.jsonl counted agent "grok-app". `magpie
grok-app default` restored the file (the only difference was grok's own
[marketplace] line written while it ran). ~/.grok/config.toml untouched.
Not tried: the real Grok App GUI (it would sign in through the keychain
and ~/.grok), a model with effort levels end to end, Windows and Linux
paths beyond TestGrokAppDir.
|
||
|
|
e2b3eb7406 |
agent: an npm -g agent under mise's Node says its version and updates with that Node's npm, not "can't tell how it was installed" (flp on Discord)
On Windows with Node managed by mise, the Agents page read "无法判断安装方式" for an agent installed with npm install -g. howInstalled decided from the binary's path, and a mise shim leads nowhere near node_modules: on a Mac or Linux it is a symlink to the mise binary; on Windows a copy of mise-shim.exe (exe mode, the default), a .cmd plus a bash script running `mise x --` (file), or a hard or symbolic link to mise.exe. A shim is now recognised (a link to mise, or a file in mise's shims folder: parent "mise", a .mode file, or MISE_DATA_DIR/shims) and mise is asked which program it runs, `mise which <cmd>` from the home folder; how it was installed is read from that program. On Windows mise names npm's extensionless sh script, so the .cmd beside it is used. The update runs that Node version's own npm with --prefix, then `mise reshim`: on Windows npm install -g makes no shim for a new command (seen on the box), mise's Unix npm wrapper reshims itself, so it is harmless there. Siblings: - asdf shims (scripts with "# asdf-plugin:" and `exec asdf exec`) are asked with `asdf which` the same way; asdf-nodejs's npm reshims itself and asdf has no Windows build. - proc.UserBinDirs on Windows also looks in mise's shims folder (MISE_DATA_DIR, else XDG_DATA_HOME\mise, which mise follows on Windows, else %LOCALAPPDATA%\mise) for an agent PATH doesn't reach. - Install side: npmIn accepts npm.exe beside node as well as npm.cmd. - WSL agents get no update path (CLI skips them) and wsl.go's probe already lists mise/asdf shims: unchanged. - MISE_DATA_DIR and ASDF_DIR join agentenv.Vars, so a test sandbox clears them (TestFolderVarsAreListed). Fixtures are real bytes: internal/agent/testdata/mise-windows from mise 2026.10.7 on the Windows box (file-mode snow.cmd and snow, .mode files, npm's snow.cmd/snow in the Node folder); the Mac layout and the asdf shim's text from mise 2026.10.7 and asdf 0.20.2 release binaries in a sandbox home. Run: - flp's own layout (where.exe claude: installs\node\24.20.0\claude, claude.cmd, shims\claude.exe; mise which claude names the extensionless script): TestMiseShimWindowsFiveAgents covers claude, pi, codex, opencode and codebuddy through shims\<cmd>.exe; run on the Windows box, red with the fix removed by hand, green restored. - go test -tags nogui ./internal/agent ./internal/proc -run 'Shim|HowInstalled|UpdateCLI|NpmIn|InstalledVersion'; with installedAt skipping the shim by hand TestMiseShimIsNodesNpm, TestUpdateCLIThroughMiseShim and TestAsdfShimIsNodesNpm go red, green again restored. - Real mise on the Mac (sandbox home, mise 2026.10.7, node 22.23.3, snow-ai): detection through the real shim and `mise which`, and a real update 0.9.1 -> 0.9.2 through UpdateCLI. - Real mise on Windows (the box, sandbox USERPROFILE/LOCALAPPDATA, mise 2026.10.7, node 22.23.3, snow-ai): the Windows test binary's unit tests (TestMiseShimWindows, TestHowInstalledWindowsShim, TestNpmIn) pass; a temporary test through the real shim in exe, file and hardlink modes found npm.cmd --prefix <node>, version 0.9.2; after npm install -g snow-ai@0.9.1 a real UpdateCLI took it to 0.9.2 and reshimmed; snow.exe ran 0.9.2. Symlink mode was not tried (needs developer mode); it is the link-to-mise case the Mac covers. flp's own machine was not tried. - go test -tags nogui -timeout 40m ./...; gofmt -l; GOOS=linux and GOOS=windows go vet -tags nogui ./... |
||
|
|
6b8dc4cdd8 |
proc, agent: magpie finds an agent CLI under the Node nvm's default names, not the folder whose name sorts last (v9 after v22)
proc.UserPath added "the newest-looking" nvm Node to magpie's PATH, the
last folder of ~/.nvm/versions/node/*/bin in string order. That isn't
the Node a terminal gets, and string order puts v9.11.2 after v22.12.0
and v22.3.0 after v22.12.0. So magpie could find, run and update a
codex/claude/gemini under a Node the user's terminal doesn't use (found
while answering 悠悠哥 on Discord,
|
||
|
|
9c11abbd00 |
agent: jcode is an agent magpie connects: a magpie profile with magpie's models, jcode started on the one picked (wani on Discord)
wani asked on Discord for jcode (1jehuang/jcode, a coding agent in Rust)
as an agent magpie connects. There was no earlier request in issues or
history.
What changed:
- internal/agent/jcode.go: a new agent for jcode's config.toml in
$JCODE_HOME, else ~/.jcode (jcode-storage's jcode_dir). Detected by the
file, the folder, or `jcode` on PATH.
- Connecting adds a named profile, [providers.magpie], with the keys
`jcode provider add` writes: type "openai-compatible", the gateway's
/v1, an inline api_key naming jcode (magpie-jcode; jcode's requests
carry nothing else that tells it apart) and requires_api_key = true.
Without that key, jcode sends no key to a loopback base URL.
- Its models list has one entry per model of magpie's: context_window
(128000 when magpie doesn't know it; jcode would assume 200k), input
text/image, and reasoning = true for a model with effort levels, so
jcode's /effort offers them.
- It sets [provider] default_provider = "magpie" and default_model, the
model picked. What was there is stashed, and Disconnect puts it back.
- Picking a model of jcode's own while it is on magpie takes magpie
out: the profile goes and the user's provider comes back with that
model.
- Each key is set alone, so the user's other keys and tables stay, as
do their own keys in magpie's profile (headers, extra_body) and a
reasoning_effort they set on one of its models while the model has
that level.
- jcode writes a profile's models as [[providers.magpie.models]]
tables when it rewrites the file itself (Config::save,
to_string_pretty). Those are replaced by the one list.
- A sync with nothing to change doesn't write.
- Disconnect drops the profile whole, sub-tables included.
- Check says when the profile is gone while jcode still starts on it,
or when its base_url or key is off.
- While jcode runs, the notice says to restart open jcode sessions,
since it reads the file when it starts. The notice is a newNotice
template, translated in i18n.js (zh-CN, zh-TW, ja, de) and listed in
NOTICES, as TestEveryNoticeIsTranslated asks.
- agents.go, agentenv.go: registers it; JCODE_HOME joins the agent env.
- icons/jcode.svg: jcode's halftone mark (jcode.sh/favicon.svg) as a
mask icon, every other dot of its lattice.
- docs/reference.md, docs/subsystems/agent-wiring.md, README.md,
README.zh-CN.md: jcode's row and its place in the agent list.
- WSL isn't covered: jcodeAt reads the place's home and JCODE_HOME, but
it isn't added to the WSL agent list (another session has wsl.go open).
What was run:
- go test -tags nogui ./internal/agent -run '^TestJcode'. The fixture is
the bytes jcode 0.94.0 wrote for `jcode provider add`. The tests went
red when, by hand, I:
- made a no-op sync write;
- dropped the user's reasoning_effort;
- skipped the stash, so Disconnect wasn't byte-identical;
- left jcode's [[providers.magpie.models]] tables in, which makes
invalid TOML;
- dropped requires_api_key.
- Real use:
- jcode v0.94.0 (release binary, sha256 checked) ran under a sandbox
HOME with JCODE_HOME set and JCODE_NO_TELEMETRY=1. Its config.toml
was the one jcode wrote for its own "probe" profile.
- A sandbox magpie (MAGPIE_ADDR 127.0.0.1:3671) with a fake OpenAI
upstream on 3672 ran `magpie jcode magpie/fake/org/echo-1`, a model id
with two slashes.
- `jcode run 'Say hello in one word.'` answered with the upstream's
reply, streamed. The upstream saw model org/echo-1, and usage.jsonl
recorded the turn under agent "jcode".
- `jcode provider add two …` while connected appended its own profile
and left magpie's as it was.
- `magpie jcode default` then gave back the file jcode wrote,
byte-identical, with jcode's new [providers.two] kept.
- The icon rendered as a mask in Chromium and WebKit. The only GUI
change is the notice's translations; TestEveryNoticeIsTranslated and
internal/gui pass, and node --check accepts i18n.js.
- gofmt -l; go vet (darwin, GOOS=linux, GOOS=windows) on internal/agent
and internal/agentenv; go test -tags nogui ./internal/agent
./internal/agentenv ./internal/gui; go test -tags nogui ./... under a
temp HOME (load ~80): every package passed. After rebasing on
origin/main, internal/agent and internal/agentenv were run again,
along with internal/gui, gofmt and the linux/windows vet.
|
||
|
|
8b393938f5 |
agent: StepCode can be connected to magpie, and Disconnect puts back its own model (#1526, BUKOWSKIREAL)
StepCode (StepFun's coding CLI, `step`) is a Pi fork that keeps Pi's settings as TOML in ~/.stepcode/config.toml and Pi's models.json beside it. It is now an agent target: Connect sets defaultProvider/defaultModel to magpie, appends the magpie pattern to enabledModels when the user scopes models, and writes providers.magpie into models.json with the per-agent key. Disconnect puts back the user's own provider, model and scope (only the patterns magpie added are taken out if the user changed the scope since), restores or removes providers.magpie, and removes a models.json magpie created. STEP_CODING_AGENT_DIR and STEPCODE_CONFIG_DIR move the folder as StepCode's own resolveStepConfigRoot does; WSL is covered. The patch is BUKOWSKIREAL's (7cc88463 in their fork), reviewed line by line: no network, telemetry or credential reads, writes only to the two StepCode files and magpie's stash. Added here: a test that StepCode's real User-Agent, "step (darwin 25.2.0; arm64)", counts as StepCode, and the real-CLI test now looks for a "magpie" row in `step --list-models` rather than the word anywhere (the docs path step prints can contain it). Run: - Config format checked against stepfun-ai/Step-Code at 3d70bae5 and the official 0.1.3 darwin-arm64 binary (sha256 matches latest.json): `step config path --json` names ~/.stepcode/config.toml and models.json. - Sandbox HOME, sandbox gateway on 127.0.0.1:3647: a user config with defaultProvider "step", step-3.7-flash, thinking high, two scoped models, telemetry off. `magpie stepcode magpie/deepseek/deepseek-flash`, then `step -p` answered PONG through the gateway (usage record: agent stepcode, deepseek-flash, 200). `magpie stepcode default` put config.toml back value for value, removed models.json, and `step --list-models` no longer listed magpie. - The same round trip from the real web page (sandbox `magpie web`), switch on, then off through the disconnect preview, which listed the three values it puts back; config.toml came back byte-identical. The row and icon checked in Chromium and WebKit, en and zh; no GUI assets change. - Broke the guarantee: with unwire never restoring the defaults, TestStepCodeLifecycle, ...NativeChangedAndPreexisting and ...StrictValidationAndRollback go red. Without the "step" alias the new UA check goes red. - MAGPIE_TEST_STEPCODE_BIN=<0.1.3> go test -run TestStepCodeRealCLISandbox passes (it failed before the row check above). - go test -tags nogui ./... ; gofmt -l; go vet (darwin, GOOS=linux, GOOS=windows) on internal/agent and internal/agentenv; go build for darwin, linux (nogui) and windows. Not tried on a real Windows, Linux or WSL machine. Co-authored-by: BUKOWSKIREAL <233685554+BUKOWSKIREAL@users.noreply.github.com> |
||
|
|
64262a19f0 |
agent: Prime Agent is an Agents-page row, wired like Pi into ~/.prime/agent, and Disconnect puts its files back (#1528, takltc)
What changed
- internal/agent/primeagent.go: Prime Agent (PrimeIntellect-ai/prime-agent,
CLI prime-agent) through the piLike path, as OmO was added. Its folder is
~/.prime/agent or PRIME_AGENT_CODING_AGENT_DIR (~ expands, as upstream's
agent_dir does; appdir now lets that variable carry ~). models.json and
settings.json were checked against upstream v0.10.0 (pa-core settings and
models registry): Pi's camelCase fields, the same thinking levels and
enabledModels rules. Connect writes providers.magpie, defaultProvider and
defaultModel and keeps the user's providers and settings. Only the global
settings.json is written; allowedModels and subagentDefaultModel are left
alone.
- Prime Agent sends no User-Agent, so its provider block carries the key
magpie-prime-agent and the usage log names it (piLikeKeyed). The block is
Pi's otherwise, compat.sendSessionAffinityHeaders included (Prime Agent's
openai_completions honours it), kept as the user set it (piBlockKept).
- Disconnect restores both files byte-for-byte: before magpie's first write
a copy is kept (*.before-magpie, or a note that the file was absent), and
Disconnect puts it back when nothing else changed since (Agent.Restore). A
file changed while connected is left with only magpie's part taken out.
- WSL kind, agentenv, the icon, PICKS_ITSELF in the GUI, docs and READMEs.
Run
- go test -tags nogui ./internal/agent ./internal/appdir ./internal/agentenv
./internal/library ./internal/usage; the new tests went red with the key,
the restore, the ~ expansion, PICKS_ITSELF and the icon each taken out.
- pi-default-note.test.cjs in chromium and webkit.
- Real use: prime-agent 0.10.0 installed into a sandbox HOME, a sandbox
gateway on 127.0.0.1:3651 and a fake upstream on 3652. The interactive
TUI with no flags started on magpie/fake/echo-1, the fake got the request
and usage.jsonl recorded agent "prime-agent". `magpie prime-agent default`
put models.json back byte-for-byte; settings.json got its values back, but
Prime Agent rewrites the whole file when it runs (every key, nulls), so
that file is equal in content, not bytes. Reconnecting over that
null-filled file and disconnecting again left it byte-identical. After
the rebase onto
|
||
|
|
2c75d89827 |
agent: AstrBot is an agent magpie connects: its default chat model one of magpie's, its own providers kept (orange27 on Discord)
orange27 asked on Discord for AstrBot (AstrBotDevs/AstrBot) as an agent.
What changed:
- internal/agent/astrbot.go: a new agent for AstrBot's data/cmd_config.json
under its root ($ASTRBOT_ROOT, else ~/.astrbot, the desktop app's, else
~/astrbot / ~/AstrBot when it holds an install).
- Connecting adds one "magpie" entry to provider_sources
(openai_chat_completion at the gateway, key magpie-astrbot) and one
"magpie/<model>" entry per model of magpie's to provider.
- It sets the default chat model:
agent_runner.config.model.provider_id on 4.28+, or
provider_settings.default_provider_id on older layouts.
- Field types are taken from AstrBot's own defaults and validator: key is
a list, timeout and max_context_tokens are ints, modalities lists
text/image/tool_use, and custom_headers / custom_extra_body are objects.
- The user's own sources and models are kept byte for byte. What they
change in magpie's entries (timeout, proxy, enable) stays through a
sync, and a sync with nothing new doesn't rewrite the file.
- The UTF-8 BOM AstrBot writes is kept.
- The first connect copies the file to cmd_config.json.before-magpie.
- Disconnect takes magpie's entries out and puts back the pick it found,
so the file comes back byte for byte.
- A pick the user makes while connected is theirs and stands.
- Without the file it says to start AstrBot once (or set ASTRBOT_ROOT).
Without provider_sources (before 4.10) it says to update.
- The notice says to restart AstrBot, before saving in its WebUI: it
reads the file only at start-up and its WebUI writes the whole file
back on save.
- Docker installs aren't reached: their root is inside the container.
- agents.go, agentenv.go: registers it; ASTRBOT_ROOT joins the agent env.
- icons/astrbot.svg: AstrBot's logo, as a mask icon.
- applied_test.go, rewire_test.go: the every-agent tests seed AstrBot's
settings, as they do Hanako's.
- docs/subsystems/agent-wiring.md, docs/reference.md: AstrBot's row.
What was run:
- go test -tags nogui ./internal/agent -run '^TestAstrBot'. The tests went
red when, by hand, I dropped the BOM, rewrote the user's entries, left
the pick unrestored, overwrote the user's own pick, made a no-op sync
write, rewrote the backup on a switch, or broke the legacy layout.
- Real use:
- AstrBot 4.28.2 installed with uv into a scratch venv (Python 3.12),
run from an isolated root under a sandbox HOME.
- A sandbox magpie (MAGPIE_ADDR 127.0.0.1:3617, ASTRBOT_ROOT set) with a
fake OpenAI upstream on 3618 ran `magpie astrbot magpie/fake/echo-1`.
- AstrBot restarted, logged "Selected openai_chat_completion(magpie/
fake/echo-1) as default chat model provider", and answered a WebUI
chat (/api/chat/send) with the upstream's reply.
- usage.jsonl recorded the turn under agent "astrbot".
- `magpie astrbot default` gave back the file AstrBot wrote,
byte-identical, and AstrBot started clean on it.
- The icon rendered as a mask in Chromium and WebKit. No GUI strings were
added: the notice is the agent's own English line, like the others'.
- gofmt -l; go vet (darwin, GOOS=linux, GOOS=windows) on internal/agent and
internal/agentenv; go test -tags nogui ./... under a temp HOME (load
~170-240): every package passed but internal/gateway. That package
doesn't import internal/agent. It timed out at 10m, then with -timeout
30m failed TestQueuedStreamWaitedOutIsTheStreamsError (its 400ms idle
read and the 100ms "the first has the slot" sleep; a delay injected
before the first request reproduces it). internal/agent and
internal/agentenv were rerun green after rebasing on origin/main.
|
||
|
|
5a27b924e2 |
providers, gateway: Google Vertex AI is a preset, Gemini in the user's own Google Cloud project, signed with their Google credentials rather than a key
Gemini on Vertex AI was reachable only through a proxy of the user's own
in front of Vertex AI's OpenAI-compatible endpoint, added as a custom
provider. The Google Vertex AI preset (google-vertex) asks Vertex AI
itself.
* The provider holds a project, a location (global when none is given;
us, eu or a region), an optional credentials file and an optional
service account to go as (provider.Vertex). It has no key and no
URL: Save refuses a key, normalize clears a key and the four URLs
kept by hand, and its one address is
https://<host>/v1/projects/<project>/locations/<location>, the host
following the location (vertexHost). It is ready when it has a
project, never for a key or an account, and an import link can't add
it.
* Each request is signed with a Google token (Sign), and the token goes
to no other address. The credentials are found as Google's libraries
find Application Default Credentials: the provider's file, else
GOOGLE_APPLICATION_CREDENTIALS's, else gcloud's
application_default_credentials.json. A GOOGLE_APPLICATION_CREDENTIALS
that isn't a full path is an error, not unset, since gcloud's file
read in its place may be another account's. authorized_user,
service_account and gcloud's impersonated_service_account are read;
external_account and another universe are refused by name. With a
service account set, the token is traded at IAM Credentials'
generateAccessToken for one of that account's, as gcloud's
--impersonate-service-account does. Tokens are kept in memory per
file and account, minted once for requests made together, again 5
minutes before they expire or when the file changes (gcloud signed
in again). A mint is given 30 seconds; one that fails fails the
requests that waited through it too, and a request given up on
stops waiting. A sign-in Google refuses says the command that makes
that file again: gcloud's for its own files, impersonating as it
did.
* The gateway speaks Gemini to it alone. A Gemini client's request is
relayed as it came, its thinkingConfig, safetySettings and schema
with it: streamed to
publishers/google/models/<model>:streamGenerateContent?alt=sse, or
asked whole to :generateContent. Every other API's is translated
(buildVertex), streamed, and read back with thoughts as reasoning,
never as the answer. The path names a model by its upstream name
when one is set, as the usage log's endpoint does. Gemini 3 is sent a thinkingLevel fitted to the
model's levels, 2.5 a thinkingBudget in the model's range, off
included (Pro's least, as Pro can't stop). A call's thought
signature goes to the client in its id and comes back on the call;
a 400 "Invalid thought signature." is asked again with every call
waved through, for that request, and a 400 refusing minimal is asked
again at the model's lowest level, kept until restart. Neither is
tried for another provider.
* Vertex AI has no list of the models a location serves, so each
location has the ones it answered with on 2026-10-06: 12 at global,
6 Flash at us and eu, the 2.5 trio at a region.
* The preset offers Priority PayGo's and Flex PayGo's request headers
(HeaderHints). GOOGLE_APPLICATION_CREDENTIALS and CLOUDSDK_CONFIG are
in agentenv.Vars, so the desktop app takes them from the login shell
and the tests clear them.
Not read: the metadata server of Compute Engine, Cloud Run and GKE;
workload identity federation; Vertex AI's express-mode API keys. No
quota project is sent.
Reference: docs/subsystems/providers-accounts.md (Google Vertex AI,
Vertex AI tokens, four constraints) and gateway-routing.md (Vertex AI).
Verified: go test ./... (nogui), -race -count=5 on the Vertex tests,
gofmt and vet. A fake Google (token endpoint, IAM Credentials, Vertex
AI) checks each credentials type, the mint shared, bounded and
re-minted, every refusal's advice and that no token reaches another
host. Each of 24 mutations made after review, of the mint, the key
rules, the advice, the upstream path and the retries, fails a test.
Live, against a real project through an impersonated service account,
with magpie in a sandboxed HOME: Chat, Anthropic Messages, Responses and
Gemini clients, streamed and whole, with thinking and with tool calls, a
whole Gemini call and its signature sent back streamed, at global, us
and us-central1, and with Flex PayGo's header. No token was found in its
files or logs afterwards.
|
||
|
|
9bb2a467e4 |
agent: Snow CLI is an agent magpie sets up: a magpie profile in ~/.snow, made the active one, that Snow App takes in with "Sync Snow CLI API config" (#1457)
Snow CLI (npm snow-ai, MIT, MayDay-wpf/snow-cli) keeps one profile per file under ~/.snow/profiles (or $SNOW_CONFIG_DIR), names the active one in active-profile.json, and copies it over config.json at every start, headless `snow --ask` included. Each profile is the whole snowcfg: base URL, key, request method and models. Snow App (MayDay-wpf/snow-app) reads ~/.snow/profiles/*.json when "Sync Snow CLI API config" is pressed. magpie writes profiles/magpie.json from the profile the user was on (their settings kept, Snow's OAuth sign-in left out): baseUrlMode base at the gateway's /v1, requestMethod chat, the agent's key, the model as advancedModel and basicModel, and the catalog's window and output (200000 and 64000 when not known, the output cut to the window). It makes that profile active and copies it to config.json. The profile the user was on, whether there was an active-profile.json at all, and a magpie.json of their own are stashed; Disconnect, `magpie snow default`, or picking a model of one of the user's profiles puts those back. A Snow from before profiles (config.json alone) gets the default.json Snow itself would make, so its next start doesn't take magpie's config for the user's. Check reports a base URL, key or request method moved off magpie's; Sync rewrites the profile on a port move. A WSL distro's ~/.snow is found and written the same way. Registered: agents.go, the WSL kinds, SNOW_CONFIG_DIR in agentenv, the npm update spec (snow-ai), the icon (Snow App's own, trimmed to 96px), README, docs/reference.md, docs/subsystems/agent-wiring.md, the site's agent list and start.html (en, zh, ja). Run: - go test -tags nogui ./... in a scratch HOME: 44 packages ok. New: TestSnow, TestSnowOwnProfile, TestSnowNoProfiles, TestSnowUsersMagpieProfile, TestSnowCheckSync, TestAgentSnowDefault; snow added to TestOwnProviderNamedAsMagpies, the WSL more-agents tests and TestMaxTokensWithinContextWindow. All fail before this commit (no agent "snow"). - go vet -tags nogui for darwin, linux and windows; gofmt -l clean. - Real Snow CLI 0.9.2 in a sandbox HOME against a sandbox magpie (`magpie serve` on 127.0.0.1:3571, a fake OpenAI upstream on 3561): `magpie snow fake/pro` made the magpie profile active, `snow --ask` answered through the gateway (POST /v1/chat/completions, model pro, logged as agent snow), and `magpie snow default` left profiles, active-profile.json and config.json byte-identical to before. - GUI: agent-layout, agent-connect, agent-models-picker, agent-field-names and models-add-and-icons in Chromium and WebKit; a Snow CLI row checked at 520-960px in en, zh, zh-TW, ja and de in both engines. No new GUI strings. |
||
|
|
ae39bc8ec8 |
agents: Qwen Code (qwen) as a managed agent (#1311)
* agents: Qwen Code (qwen) as a managed agent (#1279) Qwen Code (QwenLM/qwen-code, a Gemini CLI fork) keeps custom model providers in ~/.qwen/settings.json modelProviders.<protocol> entries ({baseUrl, envKey, id, name}, envKey naming a variable in the same file's env object) and its session model in settings.model {name, baseUrl}. magpie writes one modelProviders.openai entry per catalog model — wire id the gateway takes, name magpie/<provider>/<model>, every one on env.MAGPIE_API_KEY holding the gateway's key, which is how an entry of magpie's is told from the user's own — and points settings.model at a pick. Stash, Check/drift, Sync, port-move Rewire and disconnect work as for the other JSON-config agents; on disconnect the user's entries, model and key are restored, the file byte-identical to before. Verified: go build, GOOS=linux nogui + GOOS=windows builds, go vet ./...; go test -tags nogui ./internal/agent (TestQwen* pass; TestDriftUnwiredEveryAgent/qwen and TestPortMovesEveryAgent pass after binding drift identity to the entry, not the address), go test -race -count=3 -run TestQwen, go test . (TestAgentQwenDefault: set then 'default' restores the settings byte-for-byte). TestQwen fails with 'unknown agent' when the registration is reverted. Real use: a copy of a live 341-line settings.json in a sandbox HOME — wire, then 'qwen default' left it byte-identical. Not run: GUI suite (no gui/assets change); TestReasonixCLI* and TestPluginHTTP2TakesTheProxy fail on main too (fixture/network), unchanged by this. * agents: qwen honors QWEN_HOME, sets auth type, owns a qwen-specific key name, carries context windows (#1279 review) - $QWEN_HOME stands for ~/.qwen, resolved as the other agents' (via place.getenv, appdir.Getenv; a distro's isn't read), and is in agentenv.Vars so the sandbox clears it - wiring sets security.auth.selectedType openai so qwen skips the /auth prompt; the user's own (including a pre-existing "openai", told from magpie's by a stash marker) is restored on disengage - envKey is MAGPIE_QWEN_API_KEY: a shell-exported or ~/.qwen/.env value wins over the settings' env, so the magpie-generic name is not used - entries carry generationConfig.contextWindowSize from the catalog - a settings.json without modelProviders reads as no models of anyone, instead of gjson's 'cannot use null as iterable' Verified: TestQwen* incl. TestQwenAuthOpenAIOfTheUsersOwn and TestQwenHomeOverride, TestAgentQwenDefault (CLI), -race -count=3; unwired-drift and port-move generic tests pass. Real end-to-end: dev gateway on 127.0.0.1:3999 in a sandbox HOME, real qwen binary in a sandbox QWEN_HOME ran a prompt through the gateway (PONG), and wire → default left the settings byte-identical. Reasonix fixture tests fail on main too (environment). * agents: qwen's requests are attributed by their QwenCode/<version> User-Agent |
||
|
|
cf10394527 |
agent: alma-server on Linux is found and wired as Alma, so its requests show as Alma, not "ai-sdk" (Lutra.x on Discord)
alma-server (Alma without a desktop, Linux x64/arm64) keeps its data in
$ALMA_DATA_DIR, else $XDG_DATA_HOME/alma, else ~/.local/share/alma
(Alma's electron/headless/electron-shim.ts getDefaultUserDataPath), and
answers on the same localhost:23001. magpie looked only in the desktop's
folder (os.UserConfigDir()/alma), so on such a machine Alma's Sync never
ran, its magpie provider kept the old shared key, and the gateway read its
requests by their User-Agent alone, the AI SDK's
("ai-sdk/openai/4.0.15 ai-sdk/provider-utils/5.0.10 runtime/node.js/22",
@ai-sdk/openai 4.0.15 and provider-utils 5.0.10 as alma-server bundles
them; Alma sends no header of its own). almaDir now also looks in
alma-server's folders on systems other than macOS and Windows, the
desktop's first; ALMA_DATA_DIR is in agentenv's Vars.
Verified: TestAlmaServerKeyed (a Linux home with only
~/.local/share/alma and a fake Alma whose magpie provider has the old
key): Sync re-keys it to magpie-alma; XDG_DATA_HOME and ALMA_DATA_DIR are
followed, the desktop's folder wins, and macOS/Windows look only in the
desktop's. It fails without the change ("Alma's folder:
.../.config/alma, want alma-server's .../.local/share/alma").
TestAgentOf has alma-server's real User-Agent bytes: Alma with magpie's
Alma key, "ai-sdk" without. Go tests ran on Linux (golang:1.26 in Docker;
this Mac's syspolicyd held every new test binary at launch).
Not tried with a real alma-server, and an alma-server on another
computer, reaching magpie with a gateway key, still reads as the AI SDK:
its User-Agent says nothing of Alma.
|
||
|
|
e5e87d980a |
支持 Ante:把 magpie 作为 provider 写进 ~/.ante/catalog.json (#1210)
* agent: Ante takes magpie as a provider in ~/.ante/catalog.json Ante (antigma.ai, AntigmaLabs/ante) is asked for in #1179. Its catalog is ~/.ante/catalog.json ($ANTE_HOME moves the folder), merged on top of the providers it ships: a providers map keyed by the id --provider takes, each with base_url, wire_style (AnthropicMessage, OpenAiCompatible, OpenAiResponse or Gemini), an optional auth, and preferred_models, the ids its model picker shows (docs.antigma.ai, reference/catalog-reference). magpie adds the entry "magpie" at the gateway's /v1 on OpenAiCompatible, which is the wire style Ante speaks Chat Completions with and what the gateway takes every model on, and lists magpie's models in its preferred_models. The user's own providers and the models section are left as they are, and magpie's entry goes again when magpie steps out; a file magpie made goes with it. No auth block is written. The gateway listens on loopback and lets any token in from this machine (gateway.Token's own comment, lan.go's identifyCaller: "Loopback takes any token"), and Ante counts a provider with no auth as authenticated. A bearer env_key would mean putting the gateway's key into Ante's environment, which the user would have to do themselves -- the same decision Empryo's entry makes, which sends no key of the user's either. A gateway shared on the local network is another matter, and the same one every agent magpie wires has. Two things are deliberately left off a model's entry. A routing group is not told what it reasons at: which member answers, and what that member takes, is the group's own to decide per turn, and magpieModels sets no APIs for a group for the same reason. And support_vision is never written: Ante takes a model as seeing images unless told otherwise, and what magpie knows is only as good as a provider's own list -- a relay's models are often not described at all, so writing false would have Ante drop the reader's images before the gateway, which describes them to a model that can't see them itself (provider.Described). No other agent magpie wires declares it either. Ante ships macOS and Linux builds alone and suggests WSL on Windows, so the Windows machine's Ante is usually the one in a distro: wslKinds gains it beside Empryo, which also means the gateway address Ante is pointed at is the one that distro reaches magpie on (place.base), and a distro not known to be in mirrored networking gets the notice it already gets for the others. TestAnte covers a user's own providers and models section kept as they are, magpie's entry added and taken away, Sync repointing it, and a file magpie made going again. TestAnteKeepsTheUsersFile covers a catalog magpie can't parse costing magpie's provider and not the user's. TestAnteGroupSaysNoCapab ilities covers a group declaring neither effort nor support_vision. TestAnteEfforts covers the ladder: Ante's has no "none" or "minimal", its two lowest, so both are its "min", and the rungs come out in Ante's order whatever order magpie lists them in. Tried with a real Ante 0.2.9 in WSL Ubuntu: magpie wrote the catalog, and `ante catalog` then read 16 providers with magpie's among them, 39 models, and Ante filled in support_vision: true for each itself. Ante then ran a real turn through the gateway — `ante --provider magpie --model group/auto-deepseek-v4-1-flash -p …` answered, and magpie's own usage log has the request (ep /v1/chat/completions, req the group's id, served by one of its members, out 10) — and so did a second model on another provider. The gateway was reached over the Windows host's address from the distro (172.17.128.1), this machine's own being on 127.0.0.1 alone, which is what notMirrored tells the user about. go vet, gofmt -l and go build (linux nogui, windows) pass. go test -tags nogui ./internal/agent: 12 failures here, the same 12 on unmodified main (the Windows ones AGENTS.md lists). ./internal/gui and ./internal/provider: TestGatewayFixQuitsOnlyAMagpie, TestPurposeAssetMatchesUsage, TestUpdateThatWontStart and TestLoginUsageClaudeAskedMeanwhile, all four on unmodified main here too. docs/reference.md's adapter table gains Ante. * agent: Ante keeps the user's own keys, reads ANTE_HOME, sends no effort it wasn't told to, and starts Ante on magpie (#1210) Seven points from the review, each with a test that fails without it. 1. ANTE_HOME was in the file's own comment and in docs/reference.md but never read: the path was fixed to $HOME/.ante, so a user who set it had magpie write a catalog Ante does not look at. anteDir reads it through place.getenv, the way MiniMax Code reads MINIMAX_DATA_DIR, so a distro's own ANTE_HOME - which magpie can't read - still means ~/.ante there. "ANTE_HOME" joins agentenv.Vars so a sandbox clears it. 2. providers.magpie was written whole, so every key of the user's that magpie doesn't write - the auth block a gateway shared on the LAN or reached from WSL needs to send a key, http_headers, extra_body, stream_idle_timeout_secs, thinking_display - went at the next sync, and an unchanged catalog was rewritten every round. It goes through theirsKept and syncJSON now, as #1103 did for the others: the user's keys in magpie's entry stay, preferred_models is magpie's list alone, and a file that says the same as it does is left as it is. 3. The two files were written in separate steps, so a change that failed halfway left Ante's catalog without magpie's entry and its settings still naming magpie. Each field's Set and its Sync are wrapped in atomic(), as empryo, minimax and kimi do. 4. The comment said Ante's "min" was the rung it sends no effort at, and folded both magpie's "none" and its "minimal" into it. Ante's reference says what min is: "OpenAI-compatible providers send the selected level as the same-named reasoning_effort (min is sent as minimal)" - so min is a sent level, and magpie's "none" has no rung of Ante's to fold into. Ante's "min" is magpie's "minimal"; a model magpie knows only "none" of comes out as the empty list, which is Ante's own way of saying it takes no effort setting at all. 5. The default was the highest rung the model takes, so every model magpie listed ran at Ante's slowest and dearest level. No effort is written: "Omit for models with no reasoning knob (Ante then sends no effort parameter and hides the effort slider)". 6. Having magpie in the catalog never meant Ante used it. What a session starts on is the provider and the model of ~/.ante/settings.json; with neither set Ante "uses the first authenticated provider in catalog order", and Ante's own presets come before magpie's entry - so while the user has any of those signed in, that is the one picked and magpie is not. (Measured: nothing named in settings, two keyless providers ordered aaa_other then magpie, and the request went to aaa_other's port; settings provider=magpie and it went to magpie's.) magpie sets that pair now and saves what it found there, so Disconnect hands it back; a provider the user picks in Ante's own /providers while magpie is wired is theirs and stands, and Check says so instead of keeping quiet. Ante's settings name the model apart from the provider, so magpie writes the catalog id it put in preferred_models, un-prefixed, and reads a bare id as magpie's only beside magpie's provider. Tests lean on the package's own testenv, not a real ~/.ante. TestAnteSyncKeepsTheUsersKeys is modelled on ad3b7fe5's TestAirProviderWritesKeepCustomFields and goes both ways - sync and pick - and wants an unchanged file to keep its mtime. Tried with a real Ante 0.2.9 in WSL Ubuntu on this machine (Ante ships macOS and Linux builds alone; there is no Windows Ante here). The strongest of these is the whole of it: magpie's own Go code - ante(home).Connect(), then the model field - wrote a catalog.json and settings.json into a temp folder, that folder was handed to the real Ante as ANTE_HOME, and Ante ran a turn through it with no --provider, no --model and nothing typed by hand. - `ante doctor` read `home ok /tmp/ante-e2e` and `16 providers (1 authed), 108 models` from ANTE_HOME, and magpie's entry came back with the base_url it was given: ANTE_HOME really moves the folder, and a base_url already ending in /v1 is not doubled (the request went to /v1/chat/completions). - What a session starts on is settings.json's provider, measured against two keyless providers each answering on its own port, so the logged port names the one Ante asked. Catalog ordered aaa_other then magpie, nothing named in settings: Ante asked 44331, aaa_other - the first authenticated in catalog order, exactly the review's "很可能选不到 magpie". settings provider=magpie: it asked 44220, magpie. settings provider=aaa_other: 44331 again, so a pick the user makes in Ante's own /providers overrules what magpie wrote, which is why stepping out leaves it rather than handing back the one magpie found. And with magpie the only authenticated provider, auto-detection does reach it - so the catalog entry is not useless, it is simply not enough while the user has any other provider signed in, which is every real install. - What Ante sends for effort, from the same files: no reasoning_effort at all for a model with no effort written (item 5, as its reference says omitting it sends none); `--effort min` on a model sent `reasoning_effort: "minimal"` - Ante's min is magpie's minimal, exactly item 4; and a model Ante was told `"supported_efforts": []` for sent no reasoning_effort even when asked `--effort low`, which is what a none-only model now gets instead of a level that refuses it. - The user's own keys inside magpie's entry are ones Ante reads, not decoration: `ante catalog` hands back the entry's auth, http_headers, extra_body, stream_idle_timeout_secs and thinking_display unchanged, and a bearer env_key there makes `ante doctor` count the provider as the one authed. That is item 2. - The no-auth decision holds on Ante's side, isolated by doctor's counts: Ante's own presets alone read `15 providers (0 authed)`; a magpie with no auth block reads `(1 authed)`; the same magpie given a bearer env_key that isn't set drops back to `(0 authed)`; with the key set, `(1 authed)`. So an entry with no auth is authenticated and one that asks for a key the user doesn't have is not - writing an env_key, which the first version's comment considered, would have made magpie the one provider Ante refuses to auto-detect. - Ante fills `support_vision: true` in for itself, as the PR's own note said, and a routing group declared with no capabilities at all still worked. Not covered by that run: the stand-in server answered inside the distro, so this proves Ante's config handling end to end, not a live magpie gateway relay (the first commit's message records a real turn through one). Every probe used ANTE_HOME into a temp folder; this machine's real ~/.ante gained no catalog.json or settings.json. What each fix failed without it, one test each: taking ANTE_HOME out -> TestAnteHome "$ANTE_HOME ignored"; theirsKept out -> "the user's auth lost or changed"; syncJSON out -> "an unchanged catalog was rewritten"; atomic out -> "settings.json kept half of a change that failed"; the old min mapping -> "anteEfforts([minimal high]) = [high], want [min high]"; a written default -> "deepseek/pro: effort written"; settings never pointed at magpie -> TestAnte; a model never written -> TestAnteModelField; Check left quiet -> "moved off magpie: \"\""; handing magpie back over a pick the user made while wired -> TestAnteKeepsWhatTheUserPickedWhileWired; never restoring the model -> TestAnteConnectDisconnect "not put back"; Connect picking the model field instead of magpie as provider -> "Connect left the user's model beside magpie's provider"; ANTE_HOME kept out of agentenv.Vars -> TestFolderVarsAreListed. Taking preferred_models out of the whole list is the one mutation no test turns red on: mergeTheirs cannot merge a JSON array (sync.go returns want for it), so the file behaves the same either way and the argument is there for intent and for the other keys, not for behaviour. go vet ./... and go build ./... pass, as do GOOS=linux go build -tags nogui ./... and GOOS=windows go build ./..., and gofmt is clean on LF content (this clone has core.autocrlf and no .gitattributes, so gofmt -l reports every file). go test -tags nogui ./internal/agent fails twelve tests, and an untouched worktree of origin/main run the same command on this machine fails the same twelve, test for test; ./internal/agentenv, ./internal/appdir and ./internal/edit pass, and every Ante test passes at -count=5. The whole ./... was run on both: the failing sets are alike, origin/main having one more, TestLoginUsageClaudeAskedMeanwhile, already filed as #1228. None of those twelve is this change's, and none is fixed here. * docs: agent-wiring records that Ante keeps the user's keys in magpie's entry and starts on settings.json's provider (#1210) The two rules the review asked for, written where the repo keeps them - the same lines |
||
|
|
efd501ec74 |
agent: add Reasonix Studio with separate Executor and Plan models (#427)
* feat(agent): add Reasonix Studio 2.x integration
* agent: select Reasonix planner independently from executor
* agent: restore Reasonix when its credential file was initially absent
* agent: preserve Reasonix planner choices and model controls
Keep configured and saved native planner references selectable, and retain full model picker behavior and role labels. Exercise native planner restoration and both browser layouts. Separate temporary CLI first-launch work from version and intentional timeout assertions.
* test(gui): follow the current Reasonix connection flow
* test(gui): open connected Reasonix details before checking roles
* agentenv: isolate Reasonix configuration in test sandboxes
* gui: restore Reasonix roles without disconnecting the other
* gui: Reasonix's role labels read in every language, and its confirm names them
The review found four things on the Reasonix roles' strings.
"executor" and "planner" are field labels like any other, so t() translates
them; they had no i18n entry in any language, so the zh, ja and de windows
showed the English key. They now read 执行模型/规划模型, 実行モデル/計画モデル
and Executor-Modell/Planner-Modell, beside model/effort/thinking in each block.
The confirm said "neither Executor nor Plan" — names that appear nowhere in
the UI — and its zh text said "Executor 和 Plan", while the fields are labelled
executor and planner. It now names the labels, and each language names its own
translation of them (zh 执行模型和规划模型, ja 実行モデルも計画モデル, de vom
Executor- bzw. Planner-Modell).
Both new strings had a zh entry and no ja or de entry, which is what turned
gui-ja and gui-de red: every zh key needs its ja and de with the same
placeholders. "restore the previous {field} selection" also started at column
0 in i18n.js; it is indented with the lines around it now.
reasonix-roles.test.cjs asserts the rendered label, so its zh expectations name
执行模型/规划模型; the en ones stay as they were, the en label being the key.
Its en assertions on the confirm's first sentence are unchanged, and the
reworded second sentence is not asserted.
Verified on this head: gui-ja passes 3/3 and gui-de 3/3 (every zh string has
its ja and de, same placeholders and tags); reasonix-roles.test.cjs passes 8/8
in Chromium and WebKit, en and zh, window (1000px) and panel (440px); go vet
./... and the four builds pass. The rest of internal/gui/tests was run and
compared against a clean main worktree at
|
||
|
|
a711f428ad |
agent: CodeBuddy Code (Tencent's CLI, codebuddy/cbc, the China edition too) is an agent that uses magpie's models (#980, yujianbinm) — the CLI (npm @tencent-ai/codebuddy-code 2.161.4, one package for codebuddy.ai and codebuddy.cn, CODEBUDDY_INTERNET_ENVIRONMENT=internal) takes models of one's own from ~/.codebuddy/models.json ($CODEBUDDY_CONFIG_DIR), the format WorkBuddy reads, hot-reloaded, and starts a session on settings.json's "model". magpie now writes its models there as WorkBuddy's are written (vendor magpie, key magpie-codebuddy, url the gateway's /v1/chat/completions), keeping the user's own entries, their order, a model turned off and availableModels (magpie's ids added when the list is there), and sets "model" to the pick, the user's other settings kept; one of CodeBuddy's own models, or default, takes magpie's models out again. A new models.json is {"models":[…]} as CodeBuddy's docs give it. workbuddyWrite becomes buddyWrite(agent), the same writer for both. CODEBUDDY_CONFIG_DIR joins agentenv.Vars; cliupdate knows the npm package. TestCodeBuddyCode (user's model, availableModels and settings kept; magpie pick; sync; back to own; default) and TestCodeBuddyCodeNewFile fail without the agent ("no codebuddy agent") and pass; -race -count=5 on the CodeBuddy/WorkBuddy tests. End to end, the real CLI 2.161.4 under a temp HOME with CODEBUDDY_INTERNET_ENVIRONMENT=internal and no CodeBuddy sign-in: magpie codebuddy magpie/mock/pro against a sandbox gateway on 3462, then codebuddy -p with no --model, answered through the gateway from a mock upstream, and magpie's usage counted it under CodeBuddy Code (the CLI sends "CLI/2.161.4 CodeBuddy/2.161.4", so it is told by its key); magpie codebuddy default took it out. A bare-list models.json is read by the CLI too. Not tried with a real CodeBuddy account or a real model vendor. go test ./internal/agent/ ./internal/agentenv/ ./internal/usage/ ., go vet, darwin, linux (nogui) and windows builds pass.
|
||
|
|
5115f0eea6 |
feat: configure Zed-compatible Agent paths (#922)
* feat: configure Zed-compatible agent paths * fix: honor custom Zed bundle paths * fix: classify Zed path overrides correctly --------- Co-authored-by: yetone <yetoneful@gmail.com> |
||
|
|
055f17883f | gateway: a Claude subscription conversation the client sends back rewritten goes on in the run that had its last turn, and Claude Code's temp images go with their session (#912, margbug01) — Alma takes the [Context: …] block out of its last user message once the turn is over, the <alma_notification> block out of the end of the reply, and picks the tools for each turn, so turnKey, which hashes all of it, never matched and every turn started a new claude -p told the whole conversation, written to the prompt cache again with its images. ended keeps a looseTurn beside the key: the settings without the tools, the conversation before the last turn hashed, and the last turn's messages one by one. When the exact key misses, rewritten takes the one idle run or saved session whose looseTurn has the same owner, settings and earlier turns, the same roles, tool calls and results in the last turn, where a user message only had one part taken out (cutFrom) and the reply is a non-empty start of what the run said. Two that could be it start a new run, as does an idle run not told a tool offered now (offers) or a saved session one of whose tools is gone (toolsCover). Claude Code's <CLAUDE_CODE_TMPDIR or /tmp>/claude-<uid>/<work project>/<session> folder, where it keeps the images it was given, is removed with the session (removeSession), and the sweep removes those a stopped gateway left once their session file is gone and nothing in them changed for a day; CLAUDE_CODE_TMPDIR joins agentenv.Vars. Old images are still sent to a new run: replacing them would change what the model sees. docs/subsystems/claude-subscription-bridge.md is new. claude_rewritten_test.go has a case for each relaxation (failing before the change) and one for each rule that keeps another conversation out (each failing with that rule taken out). Tested for real with the owner's Claude Max account in a sandbox HOME: turn one asked with a [Context] block and two tools, turn two sent it back with the block taken out, the reply cut short and one tool, and went on in the same claude process ("goes on in its run", cache_read 1932). go vet, go build (darwin, GOOS=linux nogui, GOOS=windows) and go test -tags nogui ./... under a temp HOME pass. | ||
|
|
585f7f7dfa | sessions, gui: Codex sessions made with another provider are moved to Codex's own from the Sessions page, and back (#887, cjyrainbow) — Codex's history lists only the sessions of the provider it uses now, so sessions made through CC Switch (model_provider "custom") vanished from it once Codex used magpie, though their files were still there and the Sessions page listed them. The Codex tab now reads each session's provider from its session_meta (cached with the rest) and the one Codex in that session's home uses (config.toml's model_provider, or its profile's; "openai" when none), says how many were made with another and which, and tags each. "Move to <provider>…" opens magpie's own dialog listing them, each ticked; Move rewrites only the model_provider string in each session's files (.jsonl and .jsonl.zst, in its own Codex home, so WSL's too, mtime kept) and in Codex's state_*.sqlite threads row: messages, id, title and archive are left as they are. A copy of the files goes to magpie's trash folder (trash/codex-provider, with a move.json) first, a failed rewrite is put back from it, and a session written to in the last minute is left alone and said so. Undo moves each back to the provider it had, byte for byte. Nothing is moved by itself. POST /api/sessions/codex-provider; en/zh/ja/de. TestMoveCodexProvider (listing, bytes, mtime, the DB row and nothing else, backup, byte-identical undo, an active session, a bad id), TestMoveCodexProviderPacked and TestCodexProviderIn fail without the change, as does sessions-codex-provider.test.cjs (WebKit, en and zh: magpie's dialog, Cancel posts nothing, an unticked one stays, Undo, no click moves the page, no left border, translations); sessions-manage, -toolbar, -purge, -folder-delete, -wsl-delete and click-scroll pass. Not tried against a real CC Switch history. go vet, go build (darwin, GOOS=linux nogui, GOOS=windows) and go test -tags nogui ./... under a temp HOME pass. | ||
|
|
21702d01ff |
Add German translation; harden paths against unset env vars (#770)
* Add German translation and harden paths against unset env vars Add a German locale to the GUI, tray menu, usage alerts and website home page, and refuse to start when the home folder is unset or relative so nothing is written under the working folder; the pi plugin no longer adopts the user's PI_CODING_AGENT_DIR, and an inherited APPIMAGE no longer selects portable mode. Scripts refuse to run from the wrong folder or empty a shared out folder, and a new internal/testenv sandboxes every test package from the user's real files, which also fixes the Claude picker and Termux installer tests on Windows. * Makefile: know magpie's folder by its go.mod, so paths with spaces work The check compared $(CURDIR) with $(dir $(abspath …)), which make splits on spaces, so a checkout under 'My Projects' or 'John Doe' refused every target. It now reads go.mod relative to the working folder and wants magpie's module there: make -C and a symlinked Makefile work, make -f from another folder still stops before any recipe runs. * i18n: German for the strings main added since, with a parity test 75 strings main added (group order, patterns, slow-start wait, usage caps, RTK savings …) get their German, and two that main dropped go. gui-de.test.cjs checks, as gui-ja does, that de has every zh string with its placeholders and tags, and that the window reads in German when picked or on a German system. * appdir: ignore relative folder variables when reading, keep them for children CheckEnv no longer unsets anything. magpie reads the XDG folders, APPDATA/LOCALAPPDATA and every agent's folder variable through appdir.Getenv/LookupEnv, which pass over a relative value; the environment stays as it is, so the agents magpie starts get the variable as the user set it. That covers what proc.UserPath lends from the login shell too, which is set after main's check and reached the desktop app unchecked. On Windows a path rooted on the current drive (\Users\x, Git Bash's /c/x) counts as usable, and magpie version and help answer without a home, before run makes any folder. * Sandbox the tests main added since internal/wslrun gets testenv's TestMain, and four tests main added that set HOME alone set their home with testenv.SetHome, so on Windows they don't read the runner's profile through USERPROFILE. * agentenv: PI_CONFIG_DIR and OPENCODE_DB take relative names on purpose omp puts $PI_CONFIG_DIR under the home and OpenCode a relative $OPENCODE_DB in its data folder, so neither depends on the working folder: appdir no longer passes them over. * i18n: German for the Library's multi-select and System One's decision API The 19 strings main added since (#791's skill multi-select, the decision API snippets) get their German; the one main replaced (four APIs → five APIs) goes. * appdir: tidy the import into magpie's group; say what Go makes of /c/x The appdir import joins the group of magpie's own imports where a file has one. rooted's comment now says that Go takes a Git Bash path like /c/x as \c\x on the current drive, not C:\x. |
||
|
|
8031edc78b |
agent: AtomCode support — one provider account, one model table per catalog model, as its own sign-in writes (#736)
* agent: AtomCode is wired like its own CodingPlan sign-in — one provider account, one model table per catalog model
AtomCode (atomgit.com/atomgit_atomcode/atomcode, AtomGit's open Rust terminal agent) keeps its settings in ~/.atomcode/config.toml ($ATOMCODE_HOME). Its account schema, what its own CodingPlan sign-in writes, is one [provider_accounts."magpie"] table at the gateway's /v1 (protocol openai, gateway.TokenFor("atomcode") as the key, so a request is its agent's even when the UA is overridden) and one [models."magpie/<provider>/<model>"] table per catalog model: the model string goes to the gateway as it is to resolve, with the model's context window (AtomCode compacts as it nears it; a 128000 one is told when the model's isn't known, and an output above the told window is cut to it), its output limit, vision and reasoning_effort_levels; reasoning_effort rides on the table once the user picks one. Picking a model points default_provider and default_model at it — default_model wins when both are set, as atomcode reads it — and stashes the defaults the user had; stepping out puts them back. The picker offers the user's own model tables and the catalog via magpie; the Library gives AtomCode its ATOMCODE.md, its mcp.json (omp's shape) and skills/; its UA is atomcode/<version>.
Found against a real atomcode 5.2.1: the documented legacy [providers.*] tables work, but its own sign-in writes the account schema, so magpie writes that; reasoning_effort, max_tokens and supports_vision were verified to reach the request from the model table, and default_model to win over default_provider. Verified end to end on a real install: atomcode --provider "magpie/…" answered through the gateway, and the Agents page shows the tile, its picker and the Usage attribution. TestAtomcodeWiring, TestAtomcodeRestoresOwnDefaults and TestAtomcodeSync fail on the old code; TestDriftUnwiredEveryAgent and TestUnsetAgentsReadEmpty cover it from All(). go vet, builds (darwin, GOOS=linux, GOOS=windows) and go test -tags nogui -count=1 ./internal/agent ./internal/library ./internal/agentenv pass; the plugin-host and timing failures of the full ./... run fail on main without this change too.
* tweak
* agent: AtomCode's config is matched by its own spellings, and Sync keeps the effort — AtomCode rewrites its config through serde on every /model and /cd, and that writes the account header bare ([provider_accounts.magpie]) where magpie wrote it quoted, so after the first rewrite Check read the wiring as gone, Sync and every pick appended a second account table (edited TOML is invalid: table magpie already exists) and clearing left the unquoted table and its api_key behind. The account is now matched by exact name in its three spellings (quoted, bare, literal — magpie-2 stays out) and the model tables by their decoded keys (kimiModelKey, replacing atomcodeModelName), through a new SetTOMLTablesMatching that takes exact names beside prefixes; SetTOMLTables delegates with none, unchanged. Sync carries each magpie model table's reasoning_effort over when rewriting — it ran at every gateway start and catalog change and dropped both an effort picked in magpie and one picked with AtomCode's /effort, and picking another model cleared every table's. The effort Set validates against the levels AtomCode knows (low, medium, high, xhigh, max — its clamp_effort_to_levels drops none, minimal and ultra), a model without levels offers none now, and the low/medium/high fallback is gone with it. supports_vision is written explicitly false, where AtomCode otherwise guesses from the model name. The user's legacy [providers.*] entries join the picker, a stashed default_model naming one comes back on Disconnect, and picking one sets default_provider and takes default_model out, as the legacy shape reads. site docs (en, zh, ja) list AtomCode. TestAtomcodeSync rewrites the config into the bare and single-quoted spellings before Sync and again before clearing and fails on the old code (drift reported, effort dropped, unquoted table left behind); TestAtomcodeLegacyProvidersArePickableAndRestored and TestAtomcodeEffortLevelsMatchAgentSupport are new. Reported by yetone on #736. go vet, builds (darwin, GOOS=linux, GOOS=windows) and go test -tags nogui -count=1 ./internal/agent ./internal/edit pass.
* agent: TestAtomcodeWiring picks an effort through the field too — the write side of the validation the last commit added (a level AtomCode knows lands as reasoning_effort on the model table, one it does not know is refused) had no coverage left: the test only read back what AtomCode's own /effort had written. provider.SetModelEfforts gives fake/m1 levels to offer.
* agent: Disconnect puts AtomCode's default_provider back only where AtomCode still has it — the restore checked the stash's value was not magpie's but not that the table it names was still there, so a table the user had deleted in between came back as a dangling default (the account schema's default_provider names a model table, the legacy shape a [providers.*] one; own answers for both). The default_model branch checked already. TestAtomcodeRestoresOwnDefaults deletes the stashed provider's model table before clearing and fails on the old code.
* agent: AtomCode joins the CLI updates — npm @atomgit.com/atomcode, the brew cask atomcode, and the curl script's ~/.local/bin/atomcode updating itself with atomcode upgrade, so the Agents page shows its version and a newer one as the other agents' do (#736). TestHowInstalled covers the npm prefix, the cask and the self-updating installer.
* agent: AtomCode's self-updater waits for its install paths to be confirmed — the branch recognized a binary under ~/.local/bin as `atomcode upgrade`, on a docs page, while the README shows another path and the command has not been driven outside the help text; the reviewer asked for it removed until the standalone command and the script's real default are settled. npm and the brew cask stay, with their tests; a comment marks what is pending.
---------
Co-authored-by: googya <118465+googya@users.noreply.github.com>
|
||
|
|
5fb7799b11 |
agents: Mister Morph (morph) — picking a magpie model points ~/.morph/config.yaml's llm at the gateway ($MISTER_MORPH_CONFIG names another file) (#728)
Morph has no list of providers to add magpie to, so magpie takes llm over: inference_provider openai_response_compatible (the Responses API, morph's own default), endpoint the gateway's /v1 (morph adds no second /v1), api_key magpie's token, model the catalog id, context_window_tokens the window magpie knows (morph knows one only from its own list), and headers.User-Agent mistermorph so the gateway credits its requests to morph. llm.provider is left alone: morph derives it from inference_provider. What the user had under those keys is stashed and put back when they pick a model of their own or reset; comments, other headers and other keys stay. An effort field sets llm.reasoning_effort. Found by ~/.morph, not by the morph command (a common name). Also on WSL. In NO_PICKER, as morph's /models switches profiles, not models. TestMorph and TestMorphContextWindow. go vet, builds (GOOS=linux/darwin -tags nogui, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass, but for TestPluginProxy, TestPluginSOCKSProxy and TestCodexArchivedSameSizeRewriteInvalidatesDiscovery, which fail on main too. With the installed morph against a sandbox gateway and a mock vendor, morph run's requests went to /v1/responses, were relayed as chat completions and were credited to morph; magpie morph default restored the user's file. Not run against a real model. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
38b4a9d984 | feat: export gateway and agent conversation waterfalls to Langfuse (#581) | ||
|
|
ff36a2994f | agents: T3 Code gets magpie as a provider of its own, every magpie model in it (KevinXC on Discord: T3 Code's Settings → Providers lists Codex, Claude, Cursor… each with "Add custom model"; magpie's models should be there without adding them one by one) — T3 Code (pingdotgg/t3code) keeps its settings in ~/.t3/userdata/settings.json ($T3CODE_HOME/userdata), sparse JSON its server watches and reloads on an outside edit, and besides its built-in providers takes provider instances of one's own: {"providerInstances":{"<id>":{"driver","displayName","enabled","environment":[{name,value,sensitive}],"config":{"customModels":[{slug,name}]}}}}. A claudeAgent instance runs Claude Code (the Agent SDK, ~/.claude settings read as Claude Code reads them) with its environment added, and sends a custom model's slug as Claude Code's model. The new t3code agent (t3code.go) adds the instance "magpie": driver claudeAgent, displayName magpie, ANTHROPIC_BASE_URL the gateway and ANTHROPIC_AUTH_TOKEN the token Claude Code is routed with (so its requests are Claude Code's to the gateway, haiku tier and all), not sensitive so T3 keeps them in the file rather than its secret store, and every magpie model shown to T3 Code as a custom model, a 1M one marked [1m] as for Claude Code (claude1MFor). The binary path and Claude home the user gave T3's own Claude (its instance, else the legacy providers.claudeAgent) are carried over. It is magpie's alone: the user's instances, their custom models and T3's other keys stay, off takes only it out, and the catalog sync rewrites it only where it is. T3's Codex lists Codex's model/list, which is magpie's catalog once Codex is routed through magpie, so it needs nothing; T3's own Claude asks for Claude's models by their full ids, which the gateway already sends to Claude Code's tiers (claudeTierStandIn). Found by ~/.t3 or, on a Mac, T3 Code (Alpha).app / T3 Code.app; T3CODE_HOME is in agentenv.Vars. Its icon is T3's mark (assets/prod/logo.svg, MIT), its letters alone so it draws as a mask; the option's note has its Chinese. Checked against T3 Code's own schema (effect 4.0.0-rc.115, packages/contracts at 54084ae1): the file magpie writes decodes as ServerSettings, magpie's config as ClaudeSettings, and encodes back to the same instance. Not run against a live T3 Code. TestT3CodeInstance (the user's instance, legacy Claude binary path and T3's key kept through on, sync and off; magpie's instance decoded strictly; found only with ~/.t3; among All()), TestT3CodeHomeAndInstance ($T3CODE_HOME, a file made, the Claude home carried from the user's claudeAgent instance) and TestStateListsT3Code are new. go vet ./internal/..., go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui -count=1 ./... under a temp HOME pass. | ||
|
|
1e4174cada |
sessions: Cursor CLI's chats are on the Sessions page, each listed, opened, resumed and deleted to magpie's trash as another agent's sessions are (@ownsh1p on X: why doesn't the Sessions page show cursor-agent's sessions?) — magpie read the session files of Claude Code, Codex, OpenCode, Pi and the rest, and none of Cursor's. cursor-agent (2026.10.01) keeps a chat in its config folder ($CURSOR_CONFIG_DIR, else $XDG_CONFIG_HOME/cursor, else ~/.cursor) at chats/<md5 of the cwd>/<chat id>/store.db, a SQLite file of two tables as its run store (cursor-sdk-local-runtime's sqlite-blob-store) makes them: meta, whose row "0" is the chat's metadata as JSON in hex (agentId, name — "New Agent" until it has a title — createdAt, lastUsedModel, latestRootBlobId and, for a subagent's chat, subagentInfo with its parent's id), and blobs, content-addressed by the hex of their SHA-256. The root blob is a ConversationStateStructure (protobuf): field 1 the ids of the conversation's messages in order, field 13 the archives a compaction summed up (each one's field 1 the messages it summed up), field 26 when the conversation started. Each message is the AI SDK's JSON ({role, content: a string or parts — text, reasoning, tool-call, tool-result, image, file}). Newer builds also write meta.json beside store.db: title, createdAtMs, updatedAtMs, isSubagent and cwd, the one place the chat's folder is said in words (the folder's name is only its hash). This was read from the installed bundle and matches what other projects that read these stores found; no real chat was opened.
internal/sessions/cursor.go reads it: a chat is a session with the title meta.json or the store gives it (not "New Agent"), else its first typed prompt (the text in <user_query>, with Cursor's context tags — user_info, rules, system_reminder and the rest — left out, as Cursor's own transcript writer leaves them out); its cwd from meta.json; its start and last from meta.json and the store; prompts, replies and tool calls counted on the day it was last at work, since a message carries no time of its own. A subagent's chat, a sibling folder whose subagentInfo names its parent, is counted in its parent's session. Its resume line is cd '<cwd>' && cursor-agent --resume <id> — cursor-agent looks a chat up by the cwd's hash, so a chat whose cwd isn't known (no meta.json) gets none. There are no tokens or cost: Cursor counts and bills them on its servers and keeps none in the chat. A chat's WAL log and meta.json count in its size and time, so a chat Cursor is writing is read again and is never deleted mid-run. Reading writes nothing in Cursor's folder: SQLite opening a WAL store even read-only makes -wal and -shm files beside it and writes its read marks in -shm, which would also make every chat look written a moment ago and refuse its delete; a store with no log is opened immutable, and one with a log is read from a copy of store.db and its -wal in a temp folder that is removed after. Delete moves the chat's folder, its subagents' and its transcripts (~/.cursor/projects/<cwd slug>/agent-transcripts/<id>, .jsonl, .txt) to magpie's trash, and Restore puts them back. CURSOR_CONFIG_DIR and CURSOR_DATA_DIR join internal/agentenv's list, and the sessions tests' setup clears XDG_CONFIG_HOME, so no test reads a developer's own chats. Cursor's ACP sessions (acp-sessions/) and the editor's chats are not read. cursor_test.go builds stores as Cursor writes them in a temp folder — hex meta, SHA-256 blobs, a hand-encoded root with a compaction archive, a subagent's chat, one kept open by its writer so all of it is in -wal, one with its meta as plain JSON and no meta.json, one never spoken in — and checks the listing (two sessions, the subagent's in its parent's, the title from the typed prompt, cwd, start and last, no tokens, the resume line, none without a cwd), the counts and the tools, that reading leaves every file in Cursor's folder as it was (it made store.db-wal and store.db-shm before the immutable open and the copy), that a chat just written is refused, and Delete and Restore of the chat, its subagent's and its transcripts. go vet ./internal/..., go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui -count=1 ./... under a temp HOME pass. |
||
|
|
7586df4400 | test: usage's and provider's TestMains clear the agents' variables too, and a new agent's variable left out of the list now fails (yetone, reviewing #543: internal/usage/main_test.go's TestMain still clears no agent variables, so a CLAUDE_CONFIG_DIR left in the shell reaches the real ~/.claude there too; nothing fails yet when a new agent's variable is left out of Vars) — both TestMains gave their package a home of its own and cleared no agent variable, the provider one as much as the usage one that was named. A CLAUDE_CONFIG_DIR left in the shell reached the real ~/.claude through the ledger's sessions.Calls (usage/ledger.go:122): with a canary Claude folder holding three of the sessions package's fixtures, six usage tests fail — TestLedger, TestSubscriptionListPrice, TestLedgerUsesTheStatedPrice, TestLedgerConfiguredPricesAndRefresh and the two Antigravity ledger ones — and pass with the clearing; provider passes with the same canary either way, but its Accounts read what an agent keeps on the machine too. #543 missed these by how it looked for its sites: by the clearing loops a sandbox already had, which one with no loop at all has no way to answer. TestFolderVarsAreListed reads the sources of the four packages an agent's folder variable is read in — this one, sessions, provider and library, the rest of the repository reading only magpie's own variables, the process' and the desktop's — and fails on a name that is neither in agentenv.Vars nor excused here with a reason, so a new agent's variable no longer waits for a developer's shell to meet one. It reads them as files, since a test in sessions or provider cannot import this package, which imports them; it asks for one name each way its pattern matches, so a change in how a variable is read empties the scan loudly instead of passing it, and for every name excused, so no excuse outlives its variable. What it cannot see is a name the sources build at runtime, as omoDir reads its two out of a slice (omo.go:33); both are listed, and a third taken the same way would not be caught. The package doc's VarsTest is TestVarsAreRead. TestFolderVarsAreListed fails without the change when KIMI_CODE_HOME is taken out of Vars, or when a pretend NEWAGENT_HOME is read in agents.go, and names the file that reads it; the six usage tests fail without theirs. On Windows 11 the whole suite answers as it did before the change: 31 packages pass, and the same 15 tests in internal/library, internal/gateway and internal/agent fail for what they failed for before. go vet ./..., go build -tags nogui (windows, GOOS=linux, GOOS=darwin), go vet -tags nogui for linux and darwin over every package touched, and gofmt pass. (#549) | ||
|
|
d8ebf2b893 | test: one list of the agent folders a sandbox clears, so no sandbox misses an agent (yetone, on #522: A shared list of env vars for the other sandboxes would be a welcome follow-up) — every sandbox kept its own list of the variables that point at an agent's folder, and each had drifted: the gateway's cleared 5 of the 32 magpie reads, the provider package's 2, the tui's 10, the library's 20. A sandbox clearing 2 meets whatever Grok, Kimi, Hermes, MiniMax, Qoder or ZCode the developer has installed, which is how #522 came about — Qoder's two were in the library's list and in none of the four that failed. internal/agentenv is now the one list, and the 21 sandboxes that fake an environment with no agent in it clear it, each keeping beside it the variables that are not an agent's: APPDATA and LOCALAPPDATA, which a sandbox sets to a folder of its own rather than clearing, VISUAL and EDITOR. A name in the list is one magpie reads, and TestVarsAreRead walks the sources to say so, which is how two names a sandbox had been clearing turned out to be read by nothing at all — GEMINI_CLI_HOME and OPENCODE_CONFIG in internal/backup's, while OPENCODE_CONFIG_DIR, the one internal/agent reads (agents.go:545), was not in it. Where a sandbox set an agent's folder to a fixture of its own, the clearing now comes first, since a list of 32 wipes what a list of 5 left standing. Not converted: the omp tests' four variables, which are the ones omp's own lookup consults (a Pi fork) rather than every agent's, and the warm-up's Claude Code traffic flags, which are not folders — CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC stays out of the list for that reason too, its one test setting it on purpose. On Windows 11 the whole suite answers as it did before the change: 31 packages pass, and the same 15 tests in internal/library, internal/gateway and internal/agent fail for what they failed for before (symlinks this machine has no privilege for, and TestSuffixModesReachAgentFiles). go vet ./..., go build -tags nogui (windows, GOOS=linux, GOOS=darwin), and go vet -tags nogui for linux and darwin over every package touched pass. (#543) |