Commit Graph
37 Commits
Author SHA1 Message Date
yetone 32fc5809e1 agents: OpenMausBot gets magpie as an engine of its own, written as its own Claude endpoints are (a user on X)
A user on X asked for OpenMausBot (github.com/milind-soni/OpenMausBot,
read at 516ca75; released 0.1.145). Its bots run on engines from
`instances` in ~/.openmausbot/config.json ($OMB_DATA_DIR,
server/config.ts:713). Without this, a Claude bot reached magpie only
through ~/.claude/settings.json, and its picker listed Claude's static
models alone: OpenMausBot doesn't read the model from env
(readClaudeModelCatalog, claude.ts:296-316).

- openmausbot.go writes `instances.magpie` in the shape of OpenMausBot's
  own "Claude endpoint" (newClaudeEndpoint, claude-endpoints.ts:91-139):
  - driver claudeAgent, access custom
  - config.configDir is <data>/providers/magpie. Given that,
    OpenMausBot starts Claude Code with that CLAUDE_CONFIG_DIR and
    strips account keys the engine doesn't set (claudeEnvironment,
    claude.ts:111-136, 158-179), so the engine owns its routing.
  - requireApiKey
  - ANTHROPIC_BASE_URL, AUTH_TOKEN, API_KEY and MODEL point at the
    gateway
  - endpointModels holds magpie's models, kept to the ids
    CLAUDE_MODEL_ID accepts. One bad id makes OpenMausBot refuse the
    whole engine (claude.ts:636).
- A non-empty `instances` is the whole fleet (config.ts:1173). With
  none saved, magpie writes DEFAULT_FLEET (instance-fleets.ts) beside
  magpie, stashed as openmausbot.fleet. Off takes the fleet out again
  if the user hasn't changed it.
- What stays the user's: the engine's name, a model they picked from
  the list, their other env and an inherited `cli`.
- Check reports the base URL drifting away from the gateway.
- OpenMausBot reads config.json once at start (index.ts:780), and an
  engine edited in it writes back the fleet it holds
  (routes/instances.ts:132, config.ts:997-1012). So Set is refused
  while it runs (errOMBRunning), and the notice asks to quit it first,
  since Windows can't tell.
- ListOnly, ListsModels, OMB_DATA_DIR in agentenv. The icon is
  OpenMausBot's build/icon.svg (Apache-2.0).
- i18n in zh, zh-TW, ja and de. Docs: reference, agent-wiring, both
  READMEs.
- Codex bots use ~/.codex (codex.ts:373-386), which the Codex wiring
  already covers.
- The agent package's TestMain holds ombRunning false. An OpenMausBot
  open on the test machine refused every test that turns magpie on for
  each agent: my own sandbox OpenMausBot on mote turned
  TestSyncKeepsAnAddressOnAnotherMachine, TestListOnlyAgentsReadConnected
  and TestReverseProxyIsStillMagpie red. With a process named
  openmausbot running, they now pass. LiveAgent's, OpenPencil's and
  NewMax's running checks have the same hole and are left to #5587.

Run (all on mote):
- gofmt -l: clean
- go vet ./... on darwin, GOOS=linux -tags nogui and GOOS=windows: ok
- go build for the same three targets: ok
- go test -tags nogui ./... -timeout 45m at e1453a168 (this change on
  origin/main 30ae0e3f9): 88 packages ok, none failed. Rebased after
  it onto e932cd258, which changes internal/library and adds one GUI
  test only. At the pushed head: go vet of internal/agent and
  internal/library, and go test of internal/agent, agentenv and
  appdir, all ok.
- GUI: the 71 files this change reaches, in chromium and webkit, every
  language they cover: agent-*, agents-*, i18n-*, icon-*, gui-de,
  gui-ja, gui-zh-tw, about-notices, deprecation-notice, header-relang,
  market-icon-corners. 1145 of 1146 pass. The one red is i18n-keys'
  "a plugin's words are its own" for plugins' "Use the library's",
  "No session ID" and "View routing", the same on main and filed
  (#5332, #5426, #5482). The whole GUI suite was started too and
  stopped at 369 ok, 0 failed: at ~5h on mote it runs after this push.

Real OpenMausBot: 0.1.145's arm64 app was run on mote, its own server
(ELECTRON_RUN_AS_NODE, Resources/server/index.js) with HOME and
OMB_DATA_DIR in a sandbox, on a free port, against a config.json
magpie's Set wrote. /api/instances listed 28 engines, among them
`magpie`: access custom, claudeEndpoint at http://127.0.0.1:3425, and
models relay/glm-4.6 and relay/gpt-5.5 in its picker, with the first as
default. It read "unavailable: `claude` CLI not found" only because the
sandbox PATH had no claude. The file was left as magpie wrote it.

Broken by hand:
- The fleet not written: TestOpenMausBotEngine red.
- The model-id filter taken out: TestOpenMausBotEngine and
  TestOpenMausBotKeepsTheUsers red ("relay/glm 4.6 (beta)"). Green
  before a bad id was added to the fixture, so one was added.

Not tried:
- A bot turn through Claude Code to a gateway. No claude CLI or
  account on mote.
- The desktop app's window, Linux and Windows builds.
- An OpenMausBot running while magpie writes. The refusal is
  unit-tested only.
2026-11-07 13:13:36 +08:00
yetone 49f207c784 agents: DS Bot, wired in the DSH home it runs on
DS Bot (github.com/Fei2411/DS-Bot, Apache-2.0, dsbot.app) is a DSH plugin
and an Electron app built on it. The app ships its own DSH (0.2.2-rc.1 in
0.3.0) and runs it with DSH_HOME at a data folder of its own, booting the
profile ds-bot, and never reads ~/.dsh: magpie's dsh row didn't reach it.

It is a row of its own now, ds-bot (dsbot.go), wired by dsh's code on its
folder (dshOn, split out of dshAt): magpie's routes and start in
profiles/ds-bot/cordis.patch.yml, the key in that folder's .env and
.credentials.yaml. The folder is $DS_BOT_HOME, else locations.json's
dataDir in the app's userData ($DS_BOT_SHELL_DATA, else <config>/DS Bot,
or the legacy DeepSeek Bot), else ~/.ds-bot, as the app's first-run.mjs and
legacy.mjs choose it. A locations.json that can't be read or names no
folder is unknown: nothing is read or written. The routes there list the
models shown for DS Bot on the Agents page (dshListFor), and the serving
round fills a profile the app makes there as it does ~/.dsh's
(dshHomesRounds). Found by DS Bot.app (io.github.fei2411.dsbot) or its
Windows per-user install (guid from its electron-builder.yml). Three
notices, translated into zh, zh-TW, ja and de. DS_BOT_HOME and
DS_BOT_SHELL_DATA are in agentenv's sandbox list.

Run:
- go test ./internal/agent/ ./internal/agentenv/ ./internal/gui/
  ./internal/cli/ ./internal/appdir/ on mote: ok but
  internal/gui TestMainWindowCorners/macOS_26_SDK, red on mote's macOS 27
  whatever the change (#3949).
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
  ./... on mote: ok. gofmt -l: clean.
- node --test i18n-keys, i18n-en-no-cjk, agent-notice-lang (chromium), and
  agent-notice-lang in webkit: all pass but i18n-keys "a plugin's words
  are its own", red on main for three plugin words (#5332, #5426, #5482).
- Real DS Bot 0.3.0 (DS-Bot-0.3.0-mac-arm64.zip) on mote, all in a sandbox
  HOME with DS_BOT_HOME, DS_BOT_SHELL_DATA and DS_BOT_WORKSPACE under it:
  a magpie built from this tree (nogui), MAGPIE_ADDR 127.0.0.1:3572, a
  fake OpenAI upstream on 3571 added as a provider. `magpie ds-bot
  magpie/fake/m1` before the app was ever opened wrote the profile; the
  app's first start kept it (agent-default-model still magpie's) and added
  its own files beside it. Its Chief Bot offered "Magpie: m1 · fake, m2 ·
  fake"; picking m1 and sending "ping" over CDP went through magpie to the
  fake (POST /v1/chat/completions model m1, stream) and "pong from fake"
  showed. `magpie ds-bot default` then took every magpie entry out and the
  .env with it. Only my own pids (app, serve, fake) were stopped.

Broken by hand, each red, then put back:
- dsbot's desktopApps entry out: TestDsBotWired (not detected).
- dshListFor always "dsh": TestDsBotOwnModels.
- dshHomesRounds without DS Bot's home: TestDsBotProfileMadeWhileServing.
- a bad locations.json taken for ~/.ds-bot: TestDsBotDataFolder.
On the old code the tests don't build (no ds-bot row at all).

Not tried: the Windows app (install path and registry guid read from its
electron-builder.yml, not from an installed copy); Linux (its AppImage and
deb aren't looked for; the data folder its first start makes finds it);
a real vendor behind magpie; a default Bot model set in DS Bot (the notice
says it wins, per its models.js). Not done: usage gives DS Bot no
User-Agent of its own (its DSH's requests likely count as dsh's), and the
Sessions page doesn't read its data folder's sessions.

Reported-by: rnhung
2026-11-07 05:43:04 +08:00
yetone 34116ec012 gateway: Codex signed in to one account lists another account's models
bigfisheatsmall on X: Codex was kept signed in to ChatGPT account A, on
the Free plan. Account B (Team) was the only account on in magpie. dsh
listed B's models and Codex didn't. codexMerged added CodexListed(),
which leaves out every ChatGPT account's own models because it assumes
the backend lists them. But the backend list is fetched with Codex's own
sign-in (A, Free), so B's plan-only models were listed nowhere. Routing
already sent codex/<model> to B (codexAccounts).

- provider.CodexListedBeside(backend) lists an account's own model by
  magpie's id (codex/<slug>) when the sign-in's backend list lacks it.
  codexMerged uses it, and FitOwn keeps those entries.
- spawnChoices (spawn_agent's models) had the same gap. It now uses the
  same rule with the slugs in Codex's models cache.
- buildCodexListTag covers the accounts' own models, so another account
  gaining or losing one has Codex ask for the list again. Every Codex
  asks once after the update.
- TestSyncCatalogAgesCodexCache built its "current" tag by hand from
  CodexListed(). It now uses provider.CodexListTag(), the tag SyncCatalog
  compares against.

Tests (sandbox HOME, fake backend with per-plan lists):
TestCodexListHasAnotherAccountsModels covers the list, routing of
codex/gpt-6.1-sol to the Pro account, and spawn_agent's choices.
TestCodexListOneAccountNoneTwice checks that a single account gets no
codex/ duplicates.

Run on mote at this tree: go vet (darwin, windows, linux) on gateway,
provider and agent: ok. go test -count=1 on provider, agent and
codexcat: ok. go test -run 'Codex|Spawn' on gateway and gui: ok. Run at
the tree before the sync_test change and the buildCodexListTag tidy: the
full gateway package was ok (1224s). Agent was red only in
TestSyncCatalogAgesCodexCache, fixed above.

Broken by hand: on the old codexMerged, the new test fails with "Codex's
list lacks codex/gpt-6.1-sol: [gpt-6-luna gpt-5.6-terra gpt-5.6-luna]".
With only codex_spawn_models.go reverted, it fails with "spawn_agent's
models lack codex/gpt-6.1-sol".

Not tried: real accounts or a real Codex. Not a full go test ./... run.
Not tried: models the backend marks hidden. A Codex here for failover
alone (codexOwnOnly) is unchanged.
2026-11-04 22:00:42 +08:00
JoeyWu-tech d3de7e8f3e agent: a provider of the user's own at magpie's gateway, under OpenCode 2's providers, stays theirs (#3915)
Found while fixing #3883. OpenCode 2 keeps a provider under providers,
its base URL in settings.baseURL, and reads it there before the same
name under provider, OpenCode 1's spelling: the one under providers is
taken whole, and the other is only a WARN, "retained native value over
legacy value" (packages/core/src/config/normalize.ts, mergeMaps, at
v2.1.4). OpenChamber's provider form saves a provider there and takes
it out of provider (packages/web/server/lib/opencode/config-v2.js,
writeSectionEntry). magpie read the user's own providers under provider
only, in the two places that look for them:

- ownGatewayProvider: a provider of the user's own at magpie's gateway
  that lists the model, as a layout of one provider per family of
  magpie's models has, gets a pick of that model of magpie's as
  <theirs>/<model>, with no provider.magpie beside it. One under
  providers wasn't seen, so the pick went to magpie/<model> and
  magpie's provider was added beside the user's.
- openCodeSpelled: a model on a provider named as one of magpie's and
  at the gateway (relay/glm-4.6 on the user's own relay) counts as
  magpie's. Under providers it didn't, so Agent.Models left it out.

On origin/main e056779a, the same provider under each spelling:
  provider:  pick -> magpie-relay/relay/glm-4.6, no provider.magpie
  providers: pick -> magpie/relay/glm-4.6, provider.magpie added
  provider:  Spelled=true  Models=[relay/glm-4.6]
  providers: Spelled=false Models=[]

Both now read a provider under providers as OpenCode 2 reads it: the
base URL from settings.baseURL (openCodeBaseURL), and a name under both
is the one under providers. They serve OpenCode, OpenChamber's pickers
on OpenCode's config, MiMo Code and DevEco Code; a config without
providers, as OpenCode 1 and the forks on it write, is read as before.
This changes what magpie reads, not what it writes, so there is no old
data to bring up. agent-wiring.md says so beside DevEco Code.

What was run (tree 77e2237e, on origin/main 2b038757, go1.26.8,
linux/amd64, Linux 5.15), outside graftcp, umask 077:
- TestOpenCodeKeepsItsOwnGatewayProvidersUnderProviders, new: a pick
  of magpie/relay/glm-4.6 with the user's magpie-relay under providers
  is written as magpie-relay/relay/glm-4.6 with no provider.magpie; a
  model on relay under providers at the gateway is in Models; with
  relay under both, the one under providers is read, for Models and
  for a pick: ok
- broken by hand, one at a time, with
  TestOpenCodeKeepsItsOwnGatewayProviders (the same under provider)
  green under each:
  - openCodeSpelled reading provider only, as on main: red, "models =
    []"
  - ownGatewayProvider reading provider only, as on main: red, "model
    = "magpie/relay/glm-4.6""
  - the one under provider read over the one under providers, in
    openCodeBaseURL: red, "the provider under provider read over the
    one under providers: [relay/glm-4.6]"; in ownGatewayProvider: red,
    "picked on the provider under provider: model =
    "mine/relay/glm-4.6""
- the 26 internal/agent tests matching OpenCode, OpenChamber, MiMo,
  DevEco or Spelled: ok
- OpenCode 2.1.4 itself (opencode models, sandbox HOME): with
  magpie-relay under providers as the test writes it, it lists
  magpie-relay/relay/glm-4.6; with relay under both, it logs "retained
  native value over legacy value" for $.providers.relay and lists only
  the models under providers (a model only under provider is gone)
- go test -tags nogui -count=1 -timeout 45m ./... (log kept), Bun
  1.4.2: 68 packages ok and 8 red, none in what this changes; in
  internal/agent every test this adds or touches passes. The reds: agent
  TestFolderVarsAreListed (#3884, fixed on main since in 3116b8f5),
  TestCodexDriftReached (#3398), TestInstalledVersion,
  TestCursorFolderFromTheEditorIsNotTheCLI,
  TestCopilotFolderFromAnIDEPluginIsNotTheCLI,
  TestQoderSettingsFromAnIDEPluginIsNotTheCLI and
  TestOmpDetectedWithPiDir (#3141),
  TestReasonixCLIRequiresSupportedNativeVersion and
  TestReasonixCLIRecoversAfterProbeTimeout (#3641); edit
  TestWriteAtomicReadOnlyHardLink and testenv TestProgram (umask 077,
  #3640); gateway TestPluginToldWhereTheAgentWorks (#3675); gui
  TestGatewayHeldByAContainer and TestGatewayFixQuitsOnlyAMagpie
  (#3649); proc TestEnvOfChild and provider TestCodexAppServersOnHome
  (#3906), then "close of synctest channel from outside bubble" from
  TestUnreadLoginsWriteErrorsKeepCredentials (#3632); tui
  TestTUIFetchesSubscriptionModels/agent (#3919).
- gofmt -l clean. go vet -tags nogui and go build -tags nogui for linux,
  windows and darwin, and go vet and go build for windows without the
  tag: exit 0 each. go vet and go build without the tag on linux: exit 1
  (this box has no GTK or WebKitGTK dev packages).

Not tried: OpenChamber's app itself, a request sent through such a
provider, Windows and macOS.

Batch run, at tree 104d75f0a (the twelve coffemon ports together, on
origin/main 7d022bdb6), mote, macOS, go1.26.8:
- go test -tags nogui -count=1 -timeout 45m on the packages the batch
  changes (agent, autostart, daemon, gateway, library, proc, provider,
  sessions, testenv, tui, gui): ok each.
- GUI, node --test with Playwright 1.62.0, Chromium and WebKit:
  library-*.test.cjs and i18n-keys.test.cjs, 1044 of 1044 pass.
- gofmt -l: nothing. go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./... and go build ./...: ok at cdd7c8e46, the same
  batch on origin/main 00098f12b one rebase before.
- The whole go test ./... at cdd7c8e46: 86 packages ok, one red,
  internal/cli TestEveryRouteHasACommandOrIsNamed (GET
  /api/context/reply has no command), red on main too (#5026).
- Linux (wsl-run, Ubuntu 24.04, at 339055896, the batch on f4c664a09):
  proc, autostart, testenv, tui ok; agent: only TestGrokInstalled red
  (#3548); #4033's proc.Look reds (Zed, Copilot, Qoder, Cursor, Omp)
  pass.
- Windows (win-run, Windows 11, at 339055896): proc, autostart, testenv,
  tui ok; library and agent red in the same tests as on origin/main
  f4c664a09 (#4115, #1827, #4786; #5068, #5069, #5070 filed now).
- Rebased onto origin/main fb1f4856a (three commits, no file in
  common with the batch) and run again at the pushed tree: gofmt -l
  nothing, go build ./... and go vet ./... ok; go test -tags nogui
  sessions, agent, autostart, tui, proc, testenv ok; i18n-keys and
  library-* 1044 of 1044 pass.
- Not run before the push: the whole GUI suite (a run at cdd7c8e46 was
  cut off at 1170 of ~1174 tests when mote rebooted; it runs again after
  the tag and any red is filed).
2026-11-03 20:38:11 +08:00
ggbdpq cdd470ce9f agent: opencode.json lists magpie's models in the order the user set
The models of magpie's provider in opencode.json were a
map[string]any, whose keys encoding/json marshals sorted: the order the
user dragged to on the Agents page reached magpieModels and died at the
last step, the file listing the models A to Z (#4575). A pure
re-ordering wasn't even written — syncJSONInOrder's sameOrder compared
two alphabetical lists and found them alike. The variants under each
model kept their order since #713 (orderedJSON); the models keep theirs
the same way now, and openCodeKept looks a model up in the ordered
block to put a variant of the user's on it.

Every config in OpenCode's shape moves with the one fix: OpenCode,
OpenChamber, Air, MiMo Code and DevEco Code (openCodeLike and the
openCodeKept calls in air.go and openchamber.go). Pi, Crush and Codex
list models in arrays and were never touched.

Run: TestOpenCodeModelsInOrder in internal/agent (written first) fails
on the unmodified code — the fresh block lands alphabetical and a
dragged order is never written — and passes with the fix. The
models-as-map assertions in TestInferredGroupImagesReachAgentCatalogs,
TestMiMoCodeCatalogNarrowedSeparately and
TestGroupModelsCarryTheirFirstMembersPrice read the ordered block now.
go test -tags nogui -count=1 ./internal/agent ok (150s) but for
TestMothX, which fails the same on unmodified main cac655c14 on this
machine (mothx_test.go:154) — pre-existing, not this fix's. gofmt
clean; go vet -tags nogui clean on darwin, linux and windows; go build
-tags nogui ./... ok on the three.

Generated-by: GLM-5.3-Flash (ZCode)

Broken by hand: with the agents.go hunks reverted,
TestOpenCodeModelsInOrder is red (written: [aaa/m1 relay/glm-4.6]).
Not changed: Cline's models.json is built from a map too (cline.go
clineModelsAt and clineKept). Filed as #4594.
2026-11-01 02:45:01 +08:00
yetone 70a0c387cb agent: a provider named magpie written by hand is the user's, not connected (JFunfunfun on X)
Pi set up by hand on a provider of its own named magpie (magpie/<model>
at the gateway) read as connected in magpie: every catalog change wrote
magpie's list over that provider, RenameProvider rewrote its refs, Drift
offered Reconnect, and Disconnect took the provider out.

0911a65e7 (yyddbds, MiMo) already holds a ListOnly agent's sync until
it is Wired; that still let a hand-written config that names a magpie
model (JFunfunfun's Pi) read as Wired. Both gates now apply.
Its test's last case said a magpie model picked by hand on MiMo's own
magpie provider connects it; that is JFunfunfun's case, so it now
stays the user's until connected in magpie (listonly_test.go, and the
doc's ListOnly line says so).

An agent whose magpie is a provider of its own config (Spelled, not
Native) is now connected only when magpie set it up (setUp): a field in
applied.json, the new applied.Kept that Keep leaves instead of deleting
the record, or the <id>.connect.was stash Connect has written since
10-03. Otherwise (handWired) it isn't Wired, has no Drift, and
SyncCatalog, RenameProvider and renameRefs skip it; Disconnect is a
no-op as it is for any unwired agent. Connecting it in magpie takes it
on as before; Disconnect after that skips putting back "was" values
that were themselves magpie's (dsh errored on them). RenameLegacy
records the dial/ -> magpie/ values it writes, and moveEfforts (the
Cursor/Antigravity effort ids, at start-up) leaves a hand-written
magpie/<ref> alone. Aside keeps its own
key-based ownership. OpenCode's own-gateway-provider test now connects
through Apply as `magpie opencode` does.

Run (on mote, at this head, rebased on f2c6831a3): go test -tags nogui
-count=1 ./internal/agent ./internal/cli ./internal/library
./internal/gui; go vet darwin/linux/windows of internal/agent and
internal/cli; gofmt -l. internal/agent again after the ListOnly test
change: ok. Pushed on ceef9e943, whose five commits since touch usage,
sessions, library, provider movers and gui only.
New tests: TestPiHandWiredMagpieProviderIsTheirs (pi's literal
settings.json/models.json in a sandbox HOME, files byte-identical after
SyncCatalog, RenameProvider and Disconnect), TestPiConnectedBefore-
StaysConnected (applied record, gone model, connect.was, applied then
Keep), TestHandWiredMagpieProviderSiblings (29 Spelled agents). All fail
on the old code.
Tests that wrote a connected agent's files by hand (Pi, OpenCode,
Hermes, omp, dsh, the Kilo plugin, Cursor efforts, and the cli's
save-then-sync test) now also mark it as Connect leaves it
(setUpInMagpie, the connect.was stash); without it they read as
hand-written, which is what this change is about.

Broken by hand, each red: the Sync gate, the rename gates, the Drift
gate, Keep deleting the record, the was-skip in Disconnect, the
moveEfforts gate (TestMoveCursorEfforts' hand-wired case).

Not tried: a real pi binary against the gateway. Users connected
between 09-23 and 10-03 who pressed Keep (record deleted before this)
read as not connected; one Connect brings them back and pi keeps
working meanwhile. Agents without Spelled (Claude Code, Codex, Gemini
and others) decide by their own checks and are unchanged.
2026-10-30 14:45:56 +08:00
yetone 0911a65e7d agent: a catalog sync leaves a magpie provider the user wrote alone while the agent isn't connected
yyddbds on Discord: in Xiaomi MiMo they added a custom provider pointing
at magpie and picked a few models by hand. MiMo's switch on the Agents
page was off, yet after an update the provider held every one of
magpie's models. SyncCatalog runs at each start and update and on every
catalog change, and MiMo Code's Sync (openCodeLike) brought any
provider.magpie block up to the catalog whether magpie wrote it or not.
magpie's default went over a list the user set.

An Agent whose Sync does nothing but keep a block of magpie's name up
to the catalog is now ListOnly, and SyncCatalog runs it only while the
agent is Wired, which is what the Agents page's switch shows. The same
sync was in every sibling, so ListOnly is on all of them: openCodeLike
(OpenCode, MiMo Code and their WSL forms), piLikeKeyed (Pi and forks),
Goose, Crush, Air, AtomCode, Command Code, Droid, Fx, jcode, Kimi,
MiniMax, Mothx, omp, OpenChamber, OpenClaw, OpenPencil, Penguin, Qwen
Code and T3 Code. Left out on purpose: Codex, Claude, Grok and Hermes,
whose Syncs also repair while not connected (Hermes keeps its bots'
magpie provider current) and have their own gates.

Trade-off: a list magpie wrote while connected doesn't follow the
catalog while the agent runs a model of its own (switch off); it does
again once a model of magpie's is picked. Users whose list was already
written over: magpie keeps no copy of the old list, so it stays full;
from this release on it is left alone, and they trim it once by hand
(or connect the agent in magpie and use its model list's Pick).

Tests: TestCatalogSyncLeavesAHandWrittenMagpieBlock (MiMo, Pi and Crush
with a hand-written magpie block stay byte for byte; connected, MiMo's
list follows the catalog; disconnected and written by hand again, left
alone; a magpie model picked in MiMo, followed again).
TestListOnlyAgentsReadConnected: every ListOnly agent magpie connects
reads as Wired (n >= 15), so none of them loses catalog updates.
Fixtures of TestSyncCatalogRewritesAgentLists,
TestModelNameAndLevelsReachAgentFiles, TestSuffixModesReachAgentFiles
and TestPiKeepsTheirKeysInMagpiesProvider, and internal/cli's
TestSaveAnswersBeforeTheAgentsSync (its Pi settings were {}), now have
Pi connected (settings.json defaultProvider magpie), as a block magpie
wrote implies.
docs/subsystems/agent-wiring.md says the rule.

Run (mote, sandbox HOME via the tests' syncHome/codexHome):
- old code + the new test: red (MiMo, Pi, Crush written over; after
  Disconnect written over).
- broken by hand: ListOnly dropped from openCodeLike: red on MiMo
  (lines 52, 82); the Wired gate in SyncCatalog replaced with true: red
  on all three.
- go test -tags nogui -count=1 ./internal/agent: ok.
- gofmt -l clean; go vet ./... for darwin, GOOS=linux and GOOS=windows:
  ok.
- full suite, go test -tags nogui -count=1 -timeout 45m ./... at base
  3bebc3839 (logs kept in the worktree): every package ok but
  internal/cli (TestSaveAnswersBeforeTheAgentsSync, mine, fixture fixed
  above, then ok alone) and internal/gateway: TestAntigravityTurned*,
  TestAntigravityTurnsCodexsGPT5ThreadAwayOnce and
  TestCodexSpentGrokFailingIsTold, red the same on a fresh origin/main
  b26fa0903 copy, filed as #4362.
- rebased on e8d42c02d: vet (darwin, linux, windows) of internal/agent and
  internal/cli, and go test of internal/agent, internal/cli,
  internal/library and internal/gui: all ok. Pushed on 764a032f6,
  whose three commits since touch gateway, usage, provider and chat only.

Not tried: the real Xiaomi MiMo desktop app (the fixture is the OpenCode
shape MiMo Code writes; whether the reporter's provider id is literally
"magpie" is unconfirmed: a provider of another id was never touched).
Lists already written over are not restored.
2026-10-30 14:25:38 +08:00
yetone 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 ca9b5048e, GOMODCACHE/GOCACHE pinned):
- go test -tags nogui -timeout 45m ./internal/agent ./internal/edit
  ./internal/agentenv ./internal/appdir ./internal/usage: all ok but
  TestWSLMoreAgentsPick (penguin has no restart notice), fixed in the
  test; rerun -run 'TestWSL|TestPenguin|TestEveryAgent|TestFolderVars|
  TestEveryNotice' ok.
- internal/gui: TestCoreScriptBudget, TestAssetTypesHoldAgainstTheRegistry,
  icon and i18n guards ok; no budget raised.
- GUI Playwright, chromium and webkit: i18n-keys, getting-started,
  agent-cli-missing, agent-update-all, gui-ja, gui-de, gui-zh-tw:
  123 tests, 123 pass. The icon renders in colour in both engines.
- gofmt -l internal/ clean; go vet -tags nogui ./... with GOOS linux,
  windows and darwin clean.
- Real Penguin 0.2.17 (npm, Node 25) in a sandbox HOME against a sandbox
  magpie serve and a fake upstream: penguin run -m "Say PONG" answered
  "PONG from fake" through magpie (usage agent "penguin",
  /v1/responses -> /v1/chat/completions); switching the model in magpie
  took effect with no Penguin restart; a no-op sync kept bytes and
  mtime; magpie penguin default restored the user's custom/my-own and
  left no magpie line; with no prior file it was created 0600 and
  removed on disconnect. The fixture is the file Penguin itself wrote.

- Rebased on origin/main d9a8148d7 and run again there: internal/agent -run
  'TestPenguin|TestWSL|TestEveryAgent|TestFolderVars|TestEveryNotice|
  TestSync', internal/edit, internal/agentenv and the internal/gui
  guards ok; gofmt clean.

Broken by hand, each went red: the no-op skip (mtime test), the 0600
create, the inline default_model spelling, the own-default restore,
removing magpie's file, dropping the vision model, the NotPaths entry,
and both SetTOMLArrayTables fixes (blank-line growth, unchanged write).

Not tried: the full ./... suite (machine load ~190-200, as asked); a
Windows or WSL real binary; Penguin's desktop app; a real vendor key
through Penguin. Penguin sends the openai SDK's User-Agent, so the
agent is named from its key, not its UA.
2026-10-27 01:38:45 +08:00
yetone ca4a1cde0d dsh: maxTokens leaves dsh half its window, or a quarter for output where that is more (#3298 item 3)
822f2b304 (#2823) held the maxTokens magpie lists for dsh to a quarter
of the window, because dsh reserves it, plus 65536 of headroom, before
it compacts (compaction-basic's resolveCompactSpec: threshold = min(0.8W,
W - maxTokens - 65536)). On a large window the quarter cut more than
compaction needs: DeepSeek's own deepseek-flash, 1000000/393216, was
listed at 250000, though all 393216 leaves dsh 541248 (54%).

Now the cap is max(W/4, W/2 - 65536): the output may take what leaves
dsh half the window to compact in, or a quarter of the window where that
is more (every window under 262144, where there is no half to spare
beside the headroom). A Max output the user set is still written as set
(outputOr), and contextWindow and /v1/models don't change.

dsh 0.2.0-rc.2's own resolveCompactSpec, run on the installed
compaction-basic over each figure (threshold tokens):

| window / output | vendor | quarter (main) | now |
| 524288 / 524288 | no message budget | 131072 -> 327680 | 196608 -> 262144 |
| 500000 / 393216 (#2823) | 41248 | 125000 -> 309464 | 184464 -> 250000 |
| 131072 / 65536 | no pressure budget | 32768 -> 32768 | 32768 -> 32768 |
| 1000000 / 393216 | 541248 | 250000 -> 684464 | 393216 -> 541248 |
| 400000 / 128000 | 206464 | 100000 -> 234464 | 128000 -> 206464 |
| 200000 / 393216 | no message budget | 50000 -> 84464 | 50000 -> 84464 |
| 128000 / 393216 | no message budget | 32000 -> 30464 | 32000 -> 30464 |

#2823's case stays fixed: 250000 is half its 500000 window (its
reporter's own plan A), against 41248 before 822f2b304; it is lower than
the quarter's 309464, which is the trade. The 128K and 200K windows
#3298 names don't change: any output above the quarter there takes it
straight out of what dsh compacts at, and a user who wants more sets Max
output.

Tests: TestDshOutputLeavesCompactionRoom's table takes the new figures
and adds DeepSeek's 1000000/393216 (393216), 200000 and 128000 windows;
its check now holds dsh's threshold at half the window where the window
has one, never under what a quarter leaves. TestDshModelLimits'
400000/128000 is now 128000; TestMaxTokensWithinContextWindow's dsh
figure follows the formula (its windows are all under 262144). Broken by
hand: the quarter alone (main) is red on 4 cases ("maxTokens 250000;
want ... 393216"), W/2 - 65536 alone on 3 (131072 gets 1), no cap
(pre-#2823) on #2823's own cases (524288/524288, 524288/1048576,
500000/393216, 131072/65536) and the 200K and 128K windows. docs/subsystems/agent-wiring.md says the new rule.

Run at 5adad1877 (this commit on top of item 4's): gofmt -l (nothing),
go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
./... (all clean), go build for darwin, linux (nogui) and windows (ok),
and go test -tags nogui -timeout 45m ./...: all 69 packages ok, exit 0
(gateway 505s, agent 401s, provider 197s).

Not tried: a real DSH session against a 1M DeepSeek model through
magpie; the thresholds above come from dsh's resolveCompactSpec run
directly. Windows under ~87K (64000/384000 -> 16000) still leave dsh no
pressure budget, on main too; that needs a policy of its own and isn't
changed here.
2026-10-23 01:20:37 +08:00
yetoneandLoKi 822f2b3042 agent: dsh lists a vendor's reply limit at most a quarter of the window, so it has room to compact (#2823, LoKi on Discord)
dsh takes a model entry's maxTokens as the output of every request. Before
deciding when to compact, it reserves that output plus 65536 of headroom
out of contextWindow (dsh-compaction-basic resolveCompactSpec). When a
vendor's reply limit is close to its window, dsh compacts at a sliver of
the window, or can't compact at all. magpie now lists a vendor's figure
held to a quarter of the window (dshMaxTokens). It does this on every
pi-ai route and in the legacy llm-deepseek entry, the same rule VS Code
and Copilot in JetBrains already use. A Max output the user set stays as
they set it (outputOr).

LoKi's patch capped only an output >= the window. That misses #2823's own
case (a group at 500000 / 393216) and outputs above window - 65536, such
as 131072 / 65536. The quarter rule covers all of them, and a cap can only
lower the reservation.

Run: real dsh 0.2.0-rc.2 headless, sandbox HOME/DSH_HOME, a fake OpenAI
SSE server with a tool-call step so pre-step compaction runs, and an
observe-only loader hook on resolveCompactSpec.

  origin/main e5b57794e:
    524288/524288   "leaving no message budget"
    500000/393216   threshold 41248
    131072/65536    "leaving no pressure budget"
    1000000/393216  threshold 541248

  this change (maxTokens / threshold / retain):
    524288   131072 / 327680 / 62914
    500000   125000 / 309464 / 60000
    131072    32768 /  32768 / 15728
    1000000  250000 / 684464 / 120000

  The request's max_tokens matches each new value.

Tests: TestDshOutputLeavesCompactionRoom (every route plus legacy;
vendor, user-set, unknown window and unknown output cases).
TestDshModelLimits now expects 100000 for 400000/128000, and
TestMaxTokensWithinContextWindow (the every-agent guard, which the first
full run caught) holds dsh to a quarter of a known window.
Broken by hand:
  - dsh.go reverted: 4 vendor cases and TestDshModelLimits red.
  - Only the legacy writer reverted: 4 llm-deepseek failures.
  - outputOr dropped: the user-output cases red.
  - Old dsh.go under the new TestMaxTokensWithinContextWindow: 3 dsh rows
    red (32000, 51200, 16000).

Checks: gofmt -l clean. go vet darwin, linux -tags nogui and windows ok.
go test -timeout 45m ./... at e5b57794e plus this change, before the
sync_test fix: every package ok except internal/agent, where
TestMaxTokensWithinContextWindow was red (fixed here), and
internal/gateway, where TestDesktopSubagentUnsetDoesNotDecode was red (1
alloc, want 0). That is #2699, an allocation counted from another
goroutine in a whole-package run. It passes alone -count=3, and this
change touches no gateway code. After the fix, internal/agent ran whole
and was ok (2084s), and vet on all 3 OSes was ok again.

The Windows TempDir flake LoKi saw in
TestDshSetEffortWritesALegacyEntryWithTheCatalog did not reproduce: 10
runs of ^TestDsh on the Windows box passed. A goroutine/file probe at
each TestDsh cleanup (macOS and Windows) found no late writer. Filed as
#2982.

Co-authored-by: LoKi <317300729+lokic7123-star@users.noreply.github.com>
2026-10-20 03:12:29 +08:00
yetone 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
2026-10-15 23:08:03 +08:00
yetone 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 (03a01a548):

- Config in ~/.config/deveco. magpie writes the first of deveco.jsonc,
  deveco.json, config.json there (the one DevEco reads last wins its
  merge), or DEVECO_CONFIG_DIR when that is an absolute folder; agentenv
  carries DEVECO_CONFIG_DIR. Auth at ~/.local/share/deveco/auth.json.
- Its provider block carries the key magpie-deveco, not the plain one.
  0.2.3 sends "deveco/0.2.3 ai-sdk/provider-utils/4.0.23 runtime/bun/1.4.2"
  on chat, but parts of its code still send opencode/<version>, so the key
  keeps its usage DevEco's whichever it sends. Check flags the plain key,
  and Sync writes DevEco's back. OpenCode's own key is unchanged.
- The user's own provider, small_model, $schema and comments stay; the
  model they were on comes back on Disconnect.
- Library: AGENTS.md instructions (with the "reads Claude Code's
  CLAUDE.md" note, as OpenCode and MiMo Code), MCP in OpenCode's shape,
  skills. No WSL folder.
- Install/update: npm @deveco/deveco-code on macOS and Windows only, as the
  package has no Linux binary (new cliSpec.only); the self installer under
  ~/.local/share/deveco/versions updates with `deveco upgrade`.
- Icon: DevEco's own logo, byte for byte from its IntelliJ plugin's
  pluginIcon.svg. Model picker /models. Route hue, READMEs (en, zh), site
  agent lists (en, zh, ja), docs/reference.md, subsystem pages, CLI help.

What was run
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.
- go test -tags nogui: internal/library, agentenv, proc, cli, gui, usage
  pass; internal/agent passes in 559s with -timeout 40m;
  its first run, at the default 10m with load average ~40 from other
  sessions, was cut off by the timeout (no test had failed).
- New deveco_test.go: config lookup and DEVECO_CONFIG_DIR, the key, and
  Connect/Check/Sync/Disconnect against a deveco.jsonc holding the user's
  own model, provider, small_model, $schema and a comment. Made
  openCodeKeyAt return the plain key by hand: TestDevEcoKeyNamesIt and
  TestDevEcoConnectKeepsTheUsersOwn go red.
- GUI: new library-deveco.test.cjs (the note in en, zh, zh-TW, ja, de,
  and the icon draws), chromium and webkit; red with deveco taken out of
  library.js's note. library-instr-sets, library-instr-busy,
  panel-routing, agent-connect, library-desktop-skills, getting-started,
  filter-ime, routing-account-identity pass in both engines.
- Real use, sandbox HOME: npm-installed @deveco/deveco-code 0.2.3,
  `deveco auth consent --accept` (sandbox only, no Huawei sign-in). magpie
  serve on 127.0.0.1:3592 with a fake upstream; `magpie deveco fake/fake-1`
  wrote provider magpie (magpie-deveco, http://127.0.0.1:3592/v1) beside
  the user's own and kept the file's comment; `deveco run "Reply with one
  word: ping"` answered from the fake, and `magpie usage today` counted it
  under DevEco Code. The User-Agent above is what it sent.

Not tried
- Windows, and DevEco Studio's plugin mode; a Huawei-signed-in DevEco.
- `magpie deveco <model>` then `magpie deveco default` doesn't bring back
  the model the user was on before: the CLI set path doesn't stash. It is
  the same for OpenCode today; Connect/Disconnect in the GUI does.

Reported-by: foobra
2026-10-13 10:57:32 +08:00
RaykieLee 5cb5b6b7ae tests: syncHome scopes APPDATA and LOCALAPPDATA into the per-test home 2026-10-13 05:48:39 +08:00
yetone 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 7a5536793 (compat in Pi's block) the turn was run again:
  same result, and both files byte-identical after Disconnect.
  `prime-agent -p` ignores the saved default upstream (print mode picks a
  featured model); with --provider magpie --model it goes through magpie.
- gofmt -l, GOOS=linux and GOOS=windows go vet, full go test ./...
2026-10-11 03:11:33 +08:00
yetone 6ad5dc5855 agent: Snow CLI's window, output and image support follow magpie's model until the user sets them in Snow, and a vision model of theirs that would reach the gateway is left out (#1457)
zRain (#1457, Discord #feedback) asked that maxContextTokens / maxTokens
be synced when the model changes, and for Snow's vision settings.

magpie's profile (profiles/magpie.json) already took maxContextTokens and
maxTokens from the catalog on every pick and catalog sync, which also
wrote over a value the user had set on that profile in Snow's own
settings. Now what magpie last wrote of maxContextTokens, maxTokens and
supportsVision is stashed (snow:<dir>:wrote), and a value that differs
from it is the user's and is kept through later picks and syncs; the
others follow the new model. Leaving magpie's profile forgets the stash,
so connecting again starts from the user's profile.

supportsVision is now set as every agent is told a model sees (fx,
Copilot): true while magpie's Vision describes images at the gateway,
else the catalog's word; it used to be copied from the user's profile,
where it described their own model. Snow 0.9.2 sends images to the main
model only when supportsVision !== false (agents/visionAgent.ts).

The user's profile is copied into magpie's, vision settings included.
Snow's vision model takes visionBaseUrl || baseUrl and visionApiKey ||
apiKey (buildVisionConfigOverride), so one with no endpoint of its own
went to the gateway, which doesn't know it, and one with its own endpoint
but no key sent magpie's key there. snowOwnVision keeps only a vision
model with both, on the requestMethod and baseUrlMode it was asked with.

Checked against Snow CLI 0.9.2's source (6ef56454: utils/config/
apiConfig.ts ApiConfig, agents/visionAgent.ts, api/chat.ts).

Tests (temp HOME, pinned caches): TestSnowSyncedKeepsTheUsers,
TestSnowVisionThroughMagpie, TestSnowUsersVisionModel, with Snow's own
profile layout. With the stash check disabled TestSnowSyncedKeepsTheUsers
fails "the user's window was written over: 65536"; without
supportsVision TestSnowVisionThroughMagpie fails "supportsVision <nil>";
without snowOwnVision TestSnowUsersVisionModel fails "visionModel kept:
glm-4.5v". go vet (darwin, linux, windows) clean, gofmt clean.
2026-10-10 18:20:56 +08:00
yetone 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.
2026-10-10 11:46:44 +08:00
yetone 06420a7121 tests: a fake program is a file macOS has already let run (testenv.Program), so a fake's first start no longer eats a test's wait under load
macOS checks a newly written executable before its first exec: 0.27s
alone, 2-5s while other new programs start (a go test ./... starting its
test binaries). The same file again takes 0.009s, and the pass is kept
across a rename and an in-place rewrite. 108852b4 worked round this for one
test with /bin/sh -c; the class was every test that writes a `#!/bin/sh`
fake and times its answer.

testenv.Program(t, path, script) replaces os.WriteFile(path, script, 0o755)
for fakes. On macOS it renames a file that has run once from a pool to path
and writes the script into it in place; at the test's cleanup the file goes
back to the pool (only a path the test created; a stand-in it wrote over
stays). Fakes still end with their tests: nothing about how they are
started or waited on changed. Run (and gateway's TestMain) remove the pool
at the end. TestMain's PATH stand-ins are run once in the background
(testenv.StandIns). Other systems write the file as before.

Converted every `#!/bin/sh` fake written by tests under internal/ (agent,
gateway, gui, library, plugin, proc, provider, update). Windows, binary
and node/bun fakes are unchanged.

Under the same load (3 loops each starting 8 freshly written scripts at a
time), 4 rounds each, before (108852b4 / origin/main) vs after:
- provider TestSavedButSignedOutClaudeServed: 4/4 fail (8.01s) -> 4/4 pass
- provider TestClaudeSignInOverStaleCredentials: 4/4 fail (5.00s) -> 4/4 pass
- provider TestDevinSignedInOnlyInMagpie: 3/4 fail ("CLI's own []") -> 4/4 pass
- gateway TestClaudeRunEndsWhenTheClientLeaves: 4/4 fail -> 4/4 pass
  (and 3/3 fail -> 3/3 pass at a third of that load)
- gateway TestClientGoneRecordedAsCanceled: 4/4 fail -> 4/4 pass
- gui TestProvidersAnswerWhileListsComeIn ("cursor found false" at 3.03s):
  4/4 fail -> 4/4 pass. The same class, not bfe8bcaf's test order.
- proc TestUserPath (login shell's PATH never came, 7.01s): 4/4 fail ->
  4/4 pass
Unloaded, every touched package passes; no pool directory or process is
left after a run.
2026-10-07 03:00:47 +08:00
Leslieandgoogya 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>
2026-10-04 14:11:14 +08:00
yetone 04d4bae323 agent: ZCode's magpie provider pointed at a magpie on another machine keeps that address and key when magpie syncs its models (Discord, 悠悠哥: ZCode connected in a local magpie for its model list, then its base URL and API key changed by hand in ZCode to a magpie deployed on a NAS, kept going back to the local gateway's, they guessed on each update) — ZCode's Sync, which runs whenever magpie's models change and brings the provider in ~/.zcode/v2/config.json and the rule in provider_config.json up to date, wrote options.baseURL/apiKey and config.api.baseUrl/access.apiKey as gateway.URL() and gateway.Token every time. A sync now keeps an address the provider holds whose host isn't this machine's loopback (onAnotherMachine: an http(s) URL with a host other than localhost, a loopback or unspecified IP), with its key (magpie's token where it has none), and refreshes only the models; one on loopback still follows the gateway, so a magpie on another port keeps rewiring it. Picking magpie in the agent's provider field (Set) points it at this magpie as before. TestZCodeKeepsRemoteAddress: a NAS address kept by a sync in both files while a new model arrives, a loopback one moved to the gateway, connecting in magpie resets a NAS one, and onAnotherMachine's cases. go vet, builds (darwin, GOOS=linux, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass. Not tried in ZCode itself with the reporter's NAS; the models listed are this magpie's, so one the NAS's magpie doesn't serve is refused there. 2026-10-04 11:45:08 +08:00
yetone 6953627b10 agents: DeepSeek Harness in a WSL distro (lgtm on Discord: wsl中安装的dsh,目前magpie还是扫描不到,可以添加上吗?) — dsh was this machine's only: dsh(home) read DSH_HOME and wrote the gateway's own address. It is now dshAt(place), as Empryo and the others are: its home is the distro's ~/.dsh (a distro's DSH_HOME can't be read), and the gateway it names in a profile's route, the legacy llm-deepseek entry and Check is the place's (gw threaded through dshSync, dshSet, dshSetEffort, dshCheck and the route writers). wslKinds lists it (dir .dsh, bin dsh); a stopped distro's thinking options come from magpie alone, as its patch lists can't be looked at. KeepDshWired stays this machine's: a distro's route is written again on a sync. TestWSLDshProfiles (a profile's route names 172.20.0.1, a sync and dshWiredOnce leave it) and dsh in wslMore (probe, pick, stopped) fail without it. 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. 2026-10-03 11:17:55 +08:00
yetone 9845e3af51 dsh: magpie's route keeps the protocol picked for it in dsh's Models page, OpenAI Responses or Anthropic Messages, where each round put Chat Completions back (01huadalang on Discord: 这些协议怎么改 responses,在 dsh 改了一会就会被 magpie 接管) — the route was written whole each round, api: openai-completions included (dshRouteConfig), so a route switched to OpenAI Responses in dsh's Models page went back to Chat Completions within the 30 s the loop takes. Each round now reads the route's api from the profile's patch list and keeps it when it is one of the three llm-pi-ai protocols the gateway serves (dshAPI: openai-completions at /v1/chat/completions, openai-responses at /v1/responses, anthropic-messages at /v1/messages); none, or one the gateway has no endpoint for (google-generative-ai), goes back to openai-completions. The base goes with the protocol (dshBaseURL): pi-ai hands it to the vendor's SDK as it is, and Anthropic's adds /v1/messages itself, so anthropic-messages is at the gateway's root and the two OpenAI ones at its /v1 (as omp and Pi have it); dshCheck asks for the same base, so a route on Messages isn't reported as pointed elsewhere. On Messages a Claude that thinks only adaptively gets compat.forceAdaptiveThinking, which llm-pi-ai offers there, since pi-ai asks every other model for a thinking budget it turns away. reasoningEfforts are as before on all three: llm-pi-ai (0.2.0-rc.2) makes them pi-ai's thinkingLevelMap, sent as reasoning_effort on Chat, reasoning.effort on Responses (off as the map's none, a model without none having off hidden) and output_config.effort for an adaptive Claude on Messages. TestDshRouteKeepsTheAPIPickedInDsh (a loop round and a sync on a route set to openai-responses, to anthropic-messages at the /v1 base, to google-generative-ai and to none; dsh's check clean, a second round writing nothing) fails without the change (openai-responses written back as openai-completions). TestDshResponsesReachChatVendor sends pi-ai's Responses request, with dsh's User-Agent, to the gateway for a model served on Chat Completions alone: it is asked in Chat with reasoning_effort high, the image, tool call and output carried over, and the reply comes back as Responses events. Read from the installed dsh's llm-pi-ai and pi-ai only; no dsh profile, live agent config or running magpie was touched. 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 (TestFXInState failed once on its TempDir cleanup, passes alone). 2026-10-02 19:41:21 +08:00
Snowyy d5322cfbf1 agents: dsh's route is written again while magpie serves, not only when magpie starts (#528)
dsh resolves a session's model from the patch list before it contacts the gateway, so a
route that lists a model magpie no longer gives dsh fails every session, with nothing
reaching magpie to show for it.

While magpie serves the gateway it now writes the fields it manages on existing dsh
magpie routes again every 30s where they are not what magpie would write now, from
gateway.WhileServing next to the WebDAV sync. A route the user removed stays removed,
agent-default-model stays the user's choice, and an empty catalog writes nothing.
2026-10-02 15:37:07 +08:00
yetone 0361189f9e test: every package's tests pass on Windows, and none writes outside its sandbox (the user: 把 Windows 上那几个失败的测试修掉) — on a Windows box the suite failed in most packages, and the root package hung for 25 minutes. Tests set HOME, which os.UserHomeDir ignores on Windows (it reads USERPROFILE), so they read and wrote the runner's own home; each now sets USERPROFILE beside HOME, and Devin's, Goose's, Crush's and Claude Desktop's tests set APPDATA/LOCALAPPDATA, where those keep their files there. said() read the command's output only once it returned, and a pipe holds a few KB on Windows, so magpie model --help blocked forever; it reads while the command writes. Unix permission bits (the gateway key store's 0600 too), exec bits and symlinks Windows lacks are checked only off Windows; TOML strings hold Windows paths as literal strings, JSON as marshalled ones; a URL's path is compared as one. The provider and usage packages run in a home of their own (TestMain, as the gateway's already does), since a CLI's identity kept by a refresh still going when its test ended landed in the runner's ~/.config/magpie — and on a Mac in the user's own. Two product fixes came out of it: imagemcp took a file:///C:/… root or image for the path /C:/…, which doesn't exist on Windows, and now makes a Windows path of it (a host for a UNC share); and session discovery could keep a new Cowork session hidden on Linux, where a folder's mtime is a kernel tick and its size doesn't change, so an entry added within the tick of the last listing left both as they were — a listing made within 2s of its folder's last change is read again, as git does for racy files. TestFilePath and TestRacyDirectoryListedAgain fail without the change. On Windows 11 every package passes (32 of 32) and a run of each package in a fresh home leaves nothing in home, APPDATA or LOCALAPPDATA; on Linux (WSL) and macOS go test -tags nogui ./... passes. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build pass. 2026-10-01 23:15:07 +08:00
yetone 471956c837 agents: dsh takes magpie as a custom provider of its own, Magpie, not by taking over its DeepSeek one (01huadalang on Discord: 集成进 dsh 会有 bug,会被 dsh 覆写,应该走 dsh 的那个另外的供应商) — magpie rewrote dsh's llm-deepseek entry in every profile to point at the gateway with the key MAGPIE_API_KEY. dsh's Models page showed it as DeepSeek, so a DeepSeek key typed there went into dsh's key store under that name, which dsh reads before .env: the next request carried the DeepSeek key and failed, magpie seemingly overwritten; dsh's own DeepSeek models were gone meanwhile. magpie now adds a magpie provider under llm-pi-ai, as dsh's Add model provider → Custom model API writes one (gateway URL, openai-completions, MAGPIE_GATEWAY_KEY, magpie's models with their limits, images and effort levels), and points the default model at it; llm-deepseek and the user's other providers are left alone, a profile wired the old way is moved on sync with its model and effort kept, new profiles get it, switching to a dsh model or clearing takes it out, and the check says when dsh's key store holds another MAGPIE_GATEWAY_KEY. Verified with dsh 0.2.0-rc.2 in a sandbox HOME against a fake gateway: headless and web requests carry magpie's token, a DeepSeek key saved in dsh's Models page no longer displaces it. TestDshCustomProvider and TestDshMovesOffDeepSeekRow fail without the change. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass. 2026-10-01 06:34:13 +08:00
Comic Chang 49f40b463f Configure per-model context windows and output limits (#279)
A provider that serves a model the catalogue does not list, or lists at the
wrong size, has a window and a reply limit magpie cannot know: both fall
back to whatever the catalogue says about the model's maker, which for such
a provider is nothing at all.

  magpie model context relay-a/gpt-5.5 262144
  magpie model output  relay-a/gpt-5.5 131072
  magpie model context 'relay-a/*' 200000
  magpie model output  relay-a/gpt-5.5 --reset

Both are looked for in the same order as each other: this model, then
`<provider id>/*`, then the provider's own list, then the catalogue. A
model's own value wins over its provider's. The reply limit is new; the
window is not — `Provider.Contexts` has been there, with a `"*"` of its own,
settable through `magpie provider set <id> context.<model>=`, and this
reuses it rather than shadowing it.

That reuse is the point rather than a detail. A context is a routing input
and not only a number agents are shown: at 95% of a held member's window a
request moves to a member that takes more, so two sources of truth would
mean the gateway routing on one number while agents are told another.
`magpie model context` is a second way to set the same field, not a second
field.

Both reach the agents. Pi keeps a model's window and reply limit in its own
models.json, OpenCode keeps its limit, and Crush, Droid, Cline, Qoder and
Zcode keep their own; an agent reads those files when it starts, so a limit
set here that never reaches them is a limit that does not take effect.
`magpie provider set` has always told the agents, and this behaves the same
way rather than introducing a second, quieter path. The test asserts each
setter reaches them exactly once — the two paths differ (one saves the
provider file, the other settings and then says so) and that difference is
worth pinning. An end-to-end pass confirms it: with a Pi models.json in
place, `magpie model context relay-a/sol 999999` writes `contextWindow:
999999` into `providers.magpie.models`.

A `0` is refused rather than read as a reset, naming `--reset`; a mistyped
model id is refused the way `magpie model name` refuses the same id; a reset
says what is actually in force instead of claiming to be back to the
vendor's list while a provider-wide value still applies; and
`magpie model context <provider>/*` reports that value rather than saying
the provider serves no such model. Validation happens where the entry is
written, so one hand-edited bad key cannot stop a theme or a window size
from saving, and #288's walk moves these on a provider rename without a
line here.
2026-10-01 02:14:22 +08:00
cyxer000 f3b45634a3 agents: Droid, Qoder, OpenHanako, WorkBuddy, OpenCode and ZCode no longer get an output limit above the model's context window (#347) 2026-10-01 00:27:00 +08:00
cyxer000 b60cfa6787 agents: omp, Pi, Cline and dsh are no longer told a model writes more than its window holds (#338)
models.dev lists some models' output above their context (deepseek-chat:
384000 out, 128000 in), and magpie handed that on as maxTokens. The limit
is now kept within the contextWindow written beside it; a model whose
window isn't known keeps its output as before. Follow-up to the review of
2026-09-30 22:58:08 +08:00
yetone 953bce2cfb agents: Codex signed in with only an API key gets magpie as its provider, its picker listing magpie's models (#322, dakango: switching the Codex app to one of its own models went to OpenAI, 502) — magpie counted an API key in auth.json as a ChatGPT sign-in and only set openai_base_url, counting on Codex to ask the gateway for its models; but Codex asks for none with an API key (models-manager refresh_available_models returns early), so the picker showed Codex's built-in models and the one magpie model, and a built-in one went to OpenAI with the relay's key. Now only a ChatGPT sign-in takes that route; with an API key alone magpie is the model_provider with model_catalog_json listing every magpie model on for Codex, as when signed out, and a sync moves a setup an older magpie wrote; going back to Codex's own model restores the user's model_provider. A Codex model whose OpenAI can't be reached now fails naming the model and what to do instead of a bare 502. TestCodexAPIKeyUsesProvider, TestCodexAPIKeyBaseURLMoved and TestCodexOwnModelUnreached fail without the change. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass. 2026-09-30 20:08:27 +08:00
yetone 98cbea0ffb agents: Pi's models go to PI_CODING_AGENT_DIR (#304), and the Codex app offers magpie's models' efforts (#310) — Pi keeps settings.json and models.json in PI_CODING_AGENT_DIR when set (~ expanded; @earendil-works/pi-coding-agent config.js), and magpie wrote ~/.pi/agent regardless; omp is read by its own rules (PI_CONFIG_DIR, OMP_PROFILE/PI_PROFILE, then PI_CODING_AGENT_DIR), and the library's Pi and omp targets follow. The Codex app's model picker offers only the efforts in [desktop] enabled-reasoning-efforts of config.toml (ChatGPT.app 26.924: default low…xhigh, ultra, persistent), so a magpie model's max or minimal was never offered; routed through magpie, the efforts its models take are added to the user's list (or the default), nothing else changed, only values the app knows (it drops the setting for any other), comments kept, nothing written when nothing is missing. TestPiAgentDir, TestOmpAgentDir and TestCodexDesktopEfforts fail without the change. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass. 2026-09-30 18:09:09 +08:00
yetone 04f374fa8c agent: OmO (oh-my-openagent, omo-ai), a fork of Pi that keeps its own ~/.omo/agent, gets its own row: a magpie model sets settings.json's defaultProvider/defaultModel and magpie's provider in models.json there as Pi's does, $OMO_CODING_AGENT_DIR / $SENPI_CODING_AGENT_DIR are honoured, the Library writes its AGENTS.md, mcp.json and skills, and omo update updates it (#264 rhyme227). Pi's own ~/.pi is left alone. piIn becomes piLike(at, id, name, dir) so both share one wiring. Tested with omo_test.go in agent and library (fail without the change); go vet, go build -tags nogui (darwin, GOOS=linux, GOOS=windows), go test -tags nogui ./... pass. 2026-09-30 11:38:07 +08:00
yetone 899ddf594c mimo: a Xiaomi MiMo account (the one MiMo's app signs in to) is signed in inside magpie and its models served through the gateway to any agent, and MiMo Code is an agent magpie configures (#249 thedavidweng) — magpie had neither. The subscription (id mimo-app, shown as Xiaomi MiMo) signs in with Xiaomi's long-poll login (account.xiaomi.com/longPolling/loginUrl, sid mimosgp) and keeps the MiMo server's cookie session (serviceToken, userId) in logins.json at 0600; the passToken is replayed to renew the session after a day or on a 401. Requests go to POST <base>/route/chat/completions on mimo-server-{sgp,ru,in}.xiaomimimo.com/api with X-Mimo-Source mimocode-cli-free and X-Client-Version; mimo-auto is sent as mimo-pro; the models are mimo-pro and mimo-flash. Usage from /user/usage and /user/xiaomi/subscription/self. Several accounts, switched, on/off and forgotten as the other subscriptions. The add list has a Xiaomi MiMo tile (Free · Starter · Plus · Pro · Ultra) that says Xiaomi may treat this as third-party use before anything is posted; en and zh. magpie accounts takes mimo. MiMo Code (agent mimocode, OpenCode-like) is configured in its config dir (MIMOCODE_HOME/config when set), reading mimocode.jsonc, mimocode.json or config.json, whichever is there. Tested with internal/provider/mimo_test.go against fake Xiaomi SSO and MiMo servers in a temp HOME, internal/agent tests for MiMo Code's config, and internal/gui/tests/mimo-sub.test.cjs, Chromium and WebKit, en and zh; they fail without the change. factory-sub, click-scroll, old-webkit, zed-sub and add-sheet pass; go vet, go build -tags nogui (and GOOS=linux, GOOS=windows) and go test -tags nogui ./... pass. Not tried with a real Xiaomi account: the long-poll's success payload, the SSO cookie chain, whether /route accepts magpie's requests, the UTC+8 times, and whether MiMo Code picks up the config; not tried in the real Wails window. 2026-09-30 07:43:58 +08:00
yetone 6c9a0aa4d7 agents: OpenHanako — magpie is a provider there, chat completions at the gateway's /v1 under the key magpie-hanako with every model it serves, their windows, output, images and reasoning said; picking one makes it the primary agent's chat model, and default puts back the one it had and removes the provider, marked deleted as OpenHanako marks one it removes. While OpenHanako runs it goes through its local API (server-info.json's port and token), which reloads at once; otherwise into provider-catalog.json and agents/<id>/config.yaml for its next start. Asked on Discord; checked with OpenHanako's own provider registry and model manager, which list magpie's models and resolve the chat model to the gateway 2026-09-28 01:12:46 +08:00
smallnest 03a01a548d agent: MiMo Code — Xiaomi's fork of OpenCode, sharing its config shape (#98)
* agent: MiMo Code — a terminal coding assistant that is Xiaomi's fork of OpenCode, whose config keeps OpenCode's shape: its own mimocode.json(c) under ~/.config/mimocode, its auth beside it, and a magpie provider block with npm/@ai-sdk/openai-compatible, model and small_model fields. opencode() becomes openCodeLike() for the two to share it, and magpieProviderJSON splits shape from the catalog id (magpieProviderJSONFor), so a visibility narrowed on mimocode (magpie visible mimocode …) narrows its list and leaves OpenCode's alone. The library gives it the same instructions, MCP servers (its mcp key) and skills as OpenCode, except the shared skills go into its own skills/ folder: it reads Claude Code's skills only behind a flag, though it reads its CLAUDE.md like OpenCode, and the page says so. Its requests are told by the mimocode/ User-Agent. Checked against XiaomiMiMo/MiMo-Code

* icon: MiMo Code's own favicon, from packages/ui/src/assets/favicon — its frame with the bottom bar, in the monochrome the app masks to the text colour
2026-09-27 08:42:44 +08:00
yetone 9b1641a493 opencode: a model chosen for OpenCode that a provider of the config's own already sends to magpie's gateway is named under that provider — a layout of one provider per family (magpie-relay, magpie-claude, …) is no longer doubled by magpie's flat provider with the same models, nor the default model moved onto it, by magpie opencode <model> 2026-09-27 02:26:12 +08:00
796dac8de9 agent(pi): a magpie model tells Pi how long a reply may be — maxTokens from the model's output limit, where Pi otherwise capped every reply at 16384 tokens (#91)
* agent(pi): a model through magpie tells Pi how long a reply may be — Pi's models.json got contextWindow but no maxTokens, so Pi capped every reply at its default 16384 tokens, Claude Opus and GPT groups that can write 128K included; each model now carries maxTokens when its output is known (a group's is the smallest of its members'), as DSH and OpenCode's limit.output already do

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* drop internal/provider/devin/config.json, a file a provider test leaves behind

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: yetone <kumw95ya25@gmail.com>
2026-09-26 22:57:15 +08:00
yetone d05763a5dc opencode: each model of magpie's carries its window (limit.context), a group's context= with it, so OpenCode compacts when the model needs it and not at its own guess; and magpie sync puts magpie's provider back into opencode.json when a model of magpie's is chosen there but the provider is gone. /v1/models says each model's window too (context_window, context_length, max_input_tokens, max_output_tokens). Asked on Discord 2026-09-26 18:50:04 +08:00
yetone 09c635cf03 agents: a model through magpie tells Pi, Crush, omp and Codex how much it holds, and a provider added, edited or removed reaches the model lists agents keep in files of their own — the catalog carried no context window, so Pi took every model through magpie for a 128K one (a CLIProxyAPI's gpt-5.5 holds 922K) and Crush for a 200K one; each model now carries models.dev's input limit, else its context, looked up by bare id as most of the providers serving it give it (a proxy's "openai/gpt-5.4", "gpt-5.4(high)", "glm-4.6:free" find it too; a group holds the least of its members'). And those lists were written only when a model was picked: Codex's magpie-models.json, Pi's models.json, OpenCode's, Crush's, Command Code's, omp's and Hermes' provider blocks and dsh's llm-deepseek entry kept the catalog as it was then, so a provider added later never showed. Saving a provider, a vendor's list fetched anew or models.dev synced now rewrites each one magpie wrote, where it differs, and the app does once at start-up; a Codex signed in to ChatGPT, which asks the gateway, kept its cached list under the backend's ETag, which a change of magpie's never changed — the ETag (and a reply's X-Models-Etag) now carries a tag of magpie's models, and a cache from before a change is aged so the next Codex asks again 2026-09-25 12:32:14 +08:00