Commit Graph
7173 Commits
Author SHA1 Message Date
yetone 3cfbc19b05 gui: the wheel over a short model list scrolls the provider editor on
A provider's model chips held the wheel with overscroll-behavior:
contain on .mchips itself. Chromium holds the wheel in such a box even
when it doesn't overflow, so with the pointer over a short list (the
chips fit) the editor's body never scrolled on to the Advanced fields
under it. The chips now hold the wheel only while they overflow, through
the app's :where(.holds) (set by holds() on pointerover and wheel), like
every other scrolling list. A long list still scrolls on its own and
keeps the wheel at its ends.

Test: editor-chips-wheel.test.cjs, Chromium and WebKit at 900x700. Three
chips: the wheel over them scrolls the editor's body, the page never.
Two hundred: the chips scroll to their end, then three more wheels leave
the body where it was.

Broken by hand, each red, then put back:
- the old .mchips rule: Chromium red, the body stayed at 0 under the
  short list.
- .holds not given to the chips (contain removed with nothing in its
  place): red both engines, the body ran on 173 -> 353 past the long
  list's end.

Run (mote, at this tree on e364d27fc):
- the 53 GUI files the editor's models reach, Chromium and WebKit: 885
  pass, 111 red. All but two are red the same at b03a37476 without this
  change and filed: model-chip-steady #4388, model-copy-id #4621,
  zero-priced-free #5262, remote-magpie #4398, provider-fetch-again
  #5057/#5232, models-works-only #4391, provider-models-rest #4396,
  provider-picks-stay #4397, provider-typed #4673, the full-suite reds
  #4600 #5475 #5559, plugin-move-unserved #4392 #4410. The two: models-
  fold's WebKit "let out and folded back" (red in another language at
  the base; #4071, red on main) and model-api-preset's Chromium page
  error, red 4 of 4 at b03a37476 and at origin/main 16a2dfac9 (#5838).
- at the rebased head: editor-chips-wheel green in both engines in each of 11
  runs beside settings-groups, models-fold and provider-models-rest. settings-groups'
  thumb check went red 3 of 13 under load and passes alone (#5839; the
  thumb is placed by a ResizeObserver after the editor opens, fixed in
  the test next).
- go test ./internal/gui -run 'TestCoreScriptBudget|TestI18n|TestCSS': ok.

Not tried: the real app window.
2026-11-10 07:51:04 +08:00
yetone 216ac6f850 edit, agent: Grok Build's own model tables are read in one pass with nothing built, and its efforts read the shared list
What /api/state still allocated for Grok Build with real accounts, forty
polls on mote (t30):

- grokOwnOptions asked GetTOMLTable for each [model."<id>"] table of
  ~/.grok/config.toml: a stat and a fresh map a table on every look
  (4.6 MB). edit.EachTOMLTable walks the file's kept parse once and
  hands each ordinary table, in TOMLTables' order, with Scalar reading
  a key as GetTOMLTable's map has it (the last of a key written twice).
- the model field's efforts took magpieModels("grok"), a copy of the
  whole list per look, to read one entry (4.5 MB). It reads
  sharedModels; catalog.Efforts already returned a slice of the shared
  entry.

Measured on mote, sandbox HOME with the owner's real account data, 5
warm-up then 40 calls, paired runs:
  /api/state  t30 42.3 / 43.2 MB  ->  t31 33.2 / 38.1 MB  (-16%)
No GetTOMLTable, grokOwnOptions or magpieModels frame is left in t31's
top list.

Tests:
- TestEachTOMLTableAgreesWithGetTOMLTable: 200 model tables, an array
  table and a plain one; names match TOMLTables, every Scalar matches
  GetTOMLTable's map, a look allocates at most 5 times, a missing file
  has no tables and no error.

Run on mote at this tree: gofmt -l clean; go vet of edit and agent;
go test -count=1 of internal/edit and internal/agent (247s): ok.
Not run: the full ./... suite and the GUI suite; no JS changed.
2026-11-10 07:46:15 +08:00
yetone ca5e537ecb usage: traffic over time in Requests' chart, and how fast it flows now (songlairui on X)
songlairui on X asked for the gateway's bandwidth: many LLM calls, base64
images above all, weigh on the network. Each request's row already kept
its bytes up (UpBytes) and down (DownBytes), shown in its details and as
the period's "↑ · ↓" under the Requests card. What was missing was
bandwidth over time and right now.

- The Requests chart's metrics take Traffic: each hour's/day's bytes up and
  down, stacked by model, provider or agent. Its axis is in bytes ("4 MB"),
  its tooltip splits a column into "↑ up · ↓ down", and the ranking's
  values are bytes with the same split under each. A period with none
  says "No traffic counted in this period". A chart point's Part now
  carries up_bytes/down_bytes, from rows (Part.add) and from the request
  page's cells (Part.plus). The cells already kept Totals, so no cache
  version bump is needed.
- While requests are in flight, the Requests card says how fast traffic
  flows now: "↑ 1.0 MB/s · ↓ 40 KB/s", over the last ~3s, read from the
  new GET /api/usage/traffic a second apart. That route reports the
  gateway's running totals (Server.Traffic) and its requests in flight.
  The totals are atomics added where a row's bytes are added (sentUp,
  downCount.Read). So a stream counts as it arrives, nothing is buffered
  or scanned, and the totals and rows count the same bytes once. Polling
  runs only while Usage → Requests is shown and the window is visible.
  The line goes when nothing is in flight and nothing flowed. When another
  magpie serves the gateway, the route answers {} and the page shows no
  rate.

A Codex turn on the Responses WebSocket (7c1dc198d) is in the totals as
its row is: what the socket was written. The HTTP body sentUp counted is
taken back when the transport chooses the socket (toSocket) and given back
if the turn falls to HTTP after all (toHTTP), so the totals equal the sum
of the rows either way (TestTrafficCountsWhatTheSocketSent, kept and
refused).

Not counted, as before: Claude bridge turns (no HTTP to the vendor). A
plugin's row counts the local hop to the plugin host. An upload is counted
when its try is sent, so a large body shows as a burst in the live rate.
docs/subsystems/gateway-sessions.md has a Bandwidth section.

Run (mote; first at this change on da8480326, then again on 16a2dfac9):
- go test -count=1 -run 'Traffic|Socket|UpBytes|Ledger|Series'
  ./internal/gateway ./internal/usage ./internal/gui: ok.
- Broken by hand, each red, then restored: the down tally in downCount,
  the up tally in addUp, Part.plus's bytes, Part.add's bytes, the
  toSocket call (kept socket: traffic 151020, rows 50469) and the toHTTP
  call (refused: traffic 50360, rows 100551).
- gofmt -l clean; go vet -tags production ./..., GOOS=linux and
  GOOS=windows go vet ./...: ok; darwin, linux and windows builds: ok.
- GUI (mote, this tree): i18n-keys, i18n-en-no-cjk, usage-traffic and
  request-archive-usage, 54/54 in Chromium and WebKit (usage-traffic in
  en, zh, zh-TW, ja and de); usage-traffic red with the rate line broken
  by hand. "Traffic" is in i18n.js, not the Usage plugin's: Go says it
  too, and i18n-keys was red with it in the plugin's file.
- internal/cli TestEveryRouteHasACommandOrIsNamed: ok, with GET
  /api/usage/traffic named in notYet (the full run found it red).
- On 16a2dfac9 (the pushed base): gofmt -l internal clean; go test
  -count=1 -run 'Traffic|Socket|UpBytes|Ledger|Series|
  TestEveryRouteHasACommandOrIsNamed|Budget' ./internal/gateway
  ./internal/usage ./internal/gui ./internal/cli ok; i18n-keys and
  usage-traffic 40/40.
- Not finished at the tag, still running on mote: go test ./... -timeout
  45m and the whole GUI suite (under suite.lock), and the whole
  internal/gui, internal/usage and internal/gateway packages with every
  usage* GUI file. What they find is fixed in follow-ups.
2026-11-10 07:37:34 +08:00
yetone e364d27fce agent, provider, profile: a state poll builds no agents per profile, keys dsh entries without joining them, and works out renames once a change
What /api/state still allocated with real accounts, forty polls on mote
(t29, 76 and 83 MB):

- profile.Details built every agent again for each profile listed
  (7 MB). DetailsIn takes the agents the page already holds for its
  request; Details keeps its signature for other callers.
- dshNodeShared joined an entry's lines into a string to key its parsed
  node (5.7 MB). It now hashes the lines with maphash and checks them
  against its own copy, so a hit allocates nothing; a caller changing
  its slice in place still gets the new text.
- dsh's Joined check read and parsed the first profile's list each poll
  (5.2 MB). It uses dshLook, the parse shared until the file changes;
  dshOver only changes a copy of the items.
- provider.UsageRenames parsed the whole providers.json for each
  profile's in-use check (5.1 MB). It is worked out through filememo
  once per change; a file that doesn't decode goes through read's own
  last-good path as before.

Measured on mote, sandbox HOME with the owner's real account data, 5
warm-up then 40 calls, paired runs:
  /api/state  t29 82.9 / 76.0 MB  ->  t30 38.1 / 47.4 MB  (-46%)
  /api/drift  t29 7.3 / 5.5 MB    ->  t30 9.7 / 7.1 MB (512 kB sampling
              noise: no dsh or renames frame in either top list)

Tests:
- TestUsageRenamesParsedOnceAChange: 60 providers, a look at unchanged
  renames allocates at most 10 times, a rename since shows at once.
  Red on the old rename.go (424 allocations).
- TestDshLookParsesAnEntryOnce now asks dshNodeShared alone for 0
  allocations and checks a slice changed in place. Red on the old
  dsh.go (1 allocation).

Run on mote at this tree: gofmt -l clean; go vet of agent, provider,
profile, gui; go test -count=1 of internal/agent (390s), provider
(256s), profile, gui (174s) and usage: all ok.
Not run: the full ./... suite and the GUI (JS) suite; no JS changed.
2026-11-10 07:36:19 +08:00
yetone 16a2dfac9c lan: a LazyCat app offers the box's LAN address, or says how to forward the port
mtoolstec on X (after v0.1.3432) runs magpie from the magpie-lzcapp
package on a LazyCat box. Settings -> Share on local network offered
https://magpie.<box>.heiyu.space/v1, which only devices with LazyCat's
client reach, and http://172.28.3.65:3425/v1, the container bridge,
named "Other containers on this host", which nothing off the box
reaches. Other devices on his LAN wanted http://192.168.0.100:3425/v1.
The package runs magpie on the app's bridge network, and LazyCat
publishes an app's ports only on heiyu.space, not on the box's LAN
address. Its env names the app's domain, never the box's LAN IP.

- On the box's own network (network_mode: host, as LazyCat's Emby, Lucky
  and LAN Sheriff run), magpie now finds the box's LAN addresses. It sees
  the box's bridges/veths, or host.lzcapp is one of its own addresses, and
  takes the IPv4 of the default route's interface, minus host.lzcapp.
  LANURLs lists them first and the app domain after. A MAGPIE_PUBLIC_URL
  of the user's own (not the domain) stays first, and a pinned
  MAGPIE_ADDR still serves only that address. The sidebar names the box
  address, not the domain.
- On a bridge network that address can't be known. The domain is listed
  alone, named "LazyCat client", and the container-bridge address is no
  longer offered under LazyCat (ContainerHostURL ""). The row under the
  address, in Settings and on the Gateway page, says to forward the port
  with LazyCat's "LAN port forwarding" app (局域网端口转发工具). The CLI
  banner (serve, web) says the same.
- New settings/gateway fields: lanLazyCat, lanLazyCatBox; lazyCat,
  lazyCatBox (and boot.js's sideGateway). Strings are in zh, zh-TW, ja
  and de.
- host.lzcapp is looked up only under LAZYCAT_APP_DOMAIN, with a 2s
  timeout and no lock held. An answer is kept; a failure is retried after
  a minute.

Package side: the magpie-lzcapp package (lazycat-contrib, czyt) needs
network_mode: host plus host.lzcapp upstreams and the net.* permissions,
or its usage needs the port-forward steps. An issue is filed there.

Run (mote, macOS, at this tree on origin/main ce6ae593c; then rebased
onto ab084fdf2; api.go, providers.go and i18n.js changed there too and
merged clean):
- gofmt -l: clean. go vet: darwin for gateway/gui/cli; CGO_ENABLED=0
  GOOS=linux -tags nogui ./... and GOOS=windows ./...: ok.
- go test -timeout 45m ./...: ok (before the string reword; after it,
  internal/cli and internal/gateway again: ok).
- wsl-run (Ubuntu 24.04): the LazyCat/default-route/LAN tests in
  internal/gateway and internal/cli: ok.
- GUI: lan-lazycat (new: 2 engines x 5 languages x 1100/420px, 20 tests),
  i18n-keys, i18n-en-no-cjk, gui-de/ja/zh-tw, lan-docker and
  side-gateway-lan: 85 pass, 0 fail. A wider set (lan-*, gateway-*, connect-*,
  key-page, sidebar, phone-*, remote-magpie and others; 835 tests) was
  run before the reword. Its reds were the i18n placeholder check
  (fixed: no <box IP> in the string), and phone-connect-menu 420 (#4706,
  #4707) and remote-magpie (#4398). Those last two are red the same alone
  on origin/main b03a37476 on mote.
- Real Linux containers (Docker on xiaomi-gpu), with a test binary
  printing what the real functions find. LAZYCAT_APP_DOMAIN was set and
  host.lzcapp added as host-gateway.
  - bridge: ifaces [lo eth0], LANURLs [https://magpie.snyht3.heiyu.space],
    ContainerHostURL "".
  - --network host: ifaces [lo services1 eth0 docker0], defaultIfaces
    [eth0], LANURLs [http://192.168.65.3:3425 https://magpie...],
    ContainerHostURL "".
- Broken by hand: LANURLs without the box branch and ContainerHostURL
  without the LazyCat check turn TestLazyCatOffersTheBoxAddress red (6
  failures). The old settings.js turns lan-lazycat red (10 of 10,
  chromium).

Not tried: no LazyCat box is at hand. Not checked on a real box: lzcos's
interface names on the host network, where host.lzcapp points in host
mode, and which interface holds the default route.

At the rebased head: gofmt clean; go vet of internal/gui, gateway and
cli; their Budget/LazyCat/LAN/Container/PublicURL/Parity tests ok; GUI
lan-lazycat, i18n-keys, i18n-en-no-cjk, lan-docker, side-gateway-lan:
76 pass, 0 fail.
2026-11-10 07:34:29 +08:00
yetone ab084fdf25 gateway: a model's own system prompt, added after the agent's on every route (liucl on X)
liucl asked for a system prompt per model rather than per agent. A
provider's editor now has a System prompt box in each model's Model
settings row (Providers > a provider > Model settings). The gateway adds
the text after the agent's own system prompt on every request for that
model, whatever agent sends it. Empty, the default, sends the body byte
for byte as before.

It is only ever appended. Codex's base_instructions, Claude Code's
identity block and any agent's prompt stay first and unchanged
(withModelSystem in internal/gateway/model_system.go), in the agent's
protocol, in serve's candidate loop after triedOn, so before translation
and before a plugin's fetch:
- Anthropic: string system + "\n\n" + text; a block array gets one more
  text block; none gets system.
- Chat: the last leading system/developer message gets it after a blank
  line (or one more text part); none gets a system message first.
- Responses: a developer message after the leading system/developer
  items, instructions untouched; a string input becomes that message plus
  the user's; none when previous_response_id is set (the turn it follows
  had it).
- Gemini: systemInstruction / system_instruction gets one more part.
count_tokens counts it (countOn). magpie's own asks (search and vision
side calls, Codex titles, the router's classifier) get none. A fallback
to another model gets that model's own, or none.

Stored as settings.modelSystemPrompts["pid/model"] (SetModelSystemPrompt:
trimmed, at most 64KB, no NUL, a model the provider serves), saved through
modelPrefs[id].system; renames carry it (perModelFields). The Restore
default title now says it takes the system prompt away too; the four
tests that pin that title follow it. app.js stays in its budget with one
comment cut, no raise.

Run, on mote at this head:
- TestModelSystem* (every wire format with exact bytes, empty unchanged,
  own asks skipped, messages/chat/responses/gemini/count_tokens routes,
  another model sent byte for byte as before, a plugin's model),
  TestProviderSaveModelPrefs, settings keep test.
- Broken by hand, each red then restored: no call in serve, no call in
  countOn, prepend in Anthropic, empty not guarded, own asks included, any
  model of the provider; SetModelPrefs ignoring system; the GUI not
  staging it.
- GUI: model-system-prompt.test.cjs (Chromium and WebKit, en zh zh-TW ja
  de, 1200 and 420px), model-limits, model-headers, provider-same-as,
  provider-detect, provider-listed-as, i18n-keys.
- Real run: Claude Code 2.1.321 -p in a sandbox HOME and
  CLAUDE_CONFIG_DIR, through a sandbox `magpie serve` built from this
  tree, to a fake Anthropic upstream recording bodies. Its /v1/messages
  system had 3 blocks, Claude Code's own first, the prompt once, at the
  end of the last block; count_tokens sent "Be terse.\n\nAlways answer in
  Chinese."
- gofmt; go vet ./...; GOOS=linux go vet -tags nogui ./...;
  GOOS=windows go vet ./...: clean.
- The full go test -timeout 45m ./... and the whole GUI suite were
  queued on mote at this head and run after the tag (the owner's ship-now
  rule); what they find goes in follow-up commits.

Not tried: Codex or any agent other than Claude Code for real; a real
vendor upstream; the Responses, chat and Gemini shapes only through the
gateway tests' fake upstreams.
2026-11-10 07:25:54 +08:00
yetone fdc96dfe4d library: a billion-context tab switches its plugin on per agent and restores each file exactly
@Kling__Lab on X asked for billion-context (npm billion-context, CLI bili,
github.com/ranxianglei/billion-context) beside RTK. The Library gets a
billion-context tab after RTK, a card like RTK's:

- No bili: its README's `npm install -g billion-context --prefix=~/.local`
  and Install billion-context (InstallBili; biliPath finds bili in
  ~/.local/bin when it isn't on PATH).
- Installed: its version, a note that an agent switched on here can't also
  run billion-context-pi or opencode-acp, and a switch per agent that runs
  `bili plugin install|remove <agent>` (SetBili), read back from
  `bili plugin list`.
- Offered for Pi, omp, OpenCode and Claude Code, the lanes that keep
  magpie in front: Pi/omp/OpenCode load it in process and still send to
  magpie; Claude Code goes through bili's proxy, which forwards to
  magpie's gateway. Not offered: Codex (MCP only), ZCode (routes only its
  own provider), Kimi Code (renames default_model to bili-kimi), dsh (its
  install failed through dsh's pnpm), Hermes (can't be tried in a sandbox
  HOME), and agents in WSL.

bili's remove doesn't restore a file: it leaves `"packages": []` in Pi's
settings and `extensions:` in omp's config, and after magpie rewrote
Claude Code's settings.json it deleted ANTHROPIC_BASE_URL (Claude Code
then went to Anthropic, not magpie) and put back DISABLE_AUTO_COMPACT.
So switching on records each file before and after (bili-plugins.json in
magpie's config folder), and off writes the before bytes back when the
file is unchanged since, else merges JSON three ways; with no record
(bili set up outside magpie) only a Claude Code ANTHROPIC_BASE_URL the
remove took out is put back. bili's .bili-bak/.bili-last files go too.
`GET/POST /api/library/bili`, `POST /api/library/bili/install` are
named in the CLI parity list beside RTK's. Docs: site library pages
(en, zh, ja) and docs/subsystems/library.md.

Run:
- go test ./internal/library -run 'TestBili|TestParseBiliList' on mote:
  ok (a fake bili mimicking pi/claude lanes, .bili-bak re-backup and
  claude's buggy remove; a fake npm for the install).
- Full `go test -timeout 45m ./...` on mote at 16c67965f (this commit
  before the body was written, same tree): every package ok but
  internal/gateway's TestBurstTellsNoSpeed/responses_from_chat_burst
  (804ms burst read as a speed, load ~50 after a mote reboot); passes
  -count=3 alone at the same head; recorded on #2719, same test. An
  earlier full run at 8c8c63537 was all ok.
- GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...,
  go vet ./... at 16c67965f: ok. gofmt -l: nothing.
- GUI at 16c67965f: library-bili, i18n-keys, i18n-en-no-cjk,
  library-memory, library-rtk-gain, library-pi-extensions, Chromium and
  WebKit (library-bili: every language, 1100 and 420 wide).
  80 of 80 pass.
- The whole GUI suite is still running on mote at this head, started
  before the tag; two earlier whole-suite runs were cut short (mote ran
  out of disk mid-run, then rebooted), so their reds are not a record.
  Its result goes in a follow-up.
- Real, in a sandbox HOME (named dir, bili 0.1.213 installed there,
  magpie web built from this branch on 3486/3487): through magpie's API,
  Pi and Claude Code switched on; `claude -p` and `pi -p` each answered
  "pong" through magpie's gateway (Claude Code via bili's proxy on
  18788 -> 127.0.0.1:3486); switched off: Pi's settings.json, Claude
  Code's settings.json and .claude.json byte-identical to before, no
  .bili-* files left, commands/acp-cache.md gone; claude -p answered
  again straight to the gateway. Earlier, with bili run by hand, Pi,
  OpenCode, omp, Claude Code and Kimi each sent a request through a
  recording relay with bili's tools/headers on it.

Broken by hand: skipping biliRestore turned TestBiliOnOffExact,
TestBiliClaudeKeepsMagpiesRoute and TestBiliOffWithoutRecord red;
dropping the no-record URL fix turned TestBiliOffWithoutRecord red;
removing the tab turned all 22 library-bili cases red; removing the zh
note string turned the zh cases red in both engines. Each put back.

Not tried: Kimi, dsh, Hermes, Codex, ZCode lanes (not offered); WSL;
Windows (the %APPDATA%\npm lookup and npm without --prefix are untried
on the Windows box); OpenCode and omp switched through magpie's API
(switched by hand with bili before); a real npm install from the button
(sandbox had bili already; the test fakes npm).
2026-11-10 07:24:26 +08:00
yetone 5e1a6a20bd agent: Grok Build's model list keeps magpie's rows and reads models_cache.json once a change
Grok Build's model field cloned magpie's rows for every look to mark
the ones on its own account Same, appended them onto its own models,
and read and walked models_cache.json again each time. The marked list
is now kept as viaMagpieShared keeps its own (grokVia, under the same
stamp), joined with Grok's own models through joinedVia, and the
cache's shown models are read through filememo.

TestGrokFoldsItsOwnAccount now has a models_cache.json of 300 hidden
models beside a shown one, checks only the shown one is offered, and
that a look again within a request gives the list kept. Broken by hand
(grok.go as before): "a look again made the list again", red; green
restored. Run on mote: go vet ./internal/agent, go test -run TestGrok.
2026-11-10 07:18:50 +08:00
yetone e99993fcac gui, provider: a page builds the agents once a request, and preset hosts are gathered once
The Providers page built agent.All for Detected beside the one
accountLabel looks names up in (provider.Held), and the state built it
twice (Clients, Detected). They now share the request's held list
(heldAgents; agent.DetectedIn, agent.ClientsIn), as /api/drift does.
notProbed gathered every vendor and local preset's bases for each
provider of each poll; it now asks a set made once (presetHosts).

Run on mote (darwin): go vet and go test of internal/agent, internal/gui
and internal/provider: agent and gui ok; provider red only in
TestMoveToPlugin's TempDir cleanup (#5524, passes alone).
TestNotProbedSetMatchesThePresets: broken by hand (set rebuilt per
ask) it measured 44 allocations an ask, red; 0 restored.
2026-11-10 07:18:50 +08:00
yetone b03a374763 gui: a subscription's resets, warm-up, check-in and Claude run are its editor's own fields under Advanced
The owner (11-09): the block of cards these lists made under Routing took
most of the provider editor. Each list is now a field of the editor's
Advanced, beside its own label (Resets, Warm up, Check in, Claude Code),
first in it, and a field with nothing to show is hidden from the first
draw, before the prefs have loaded. Settings' search still finds them:
the hit opens the editor with Advanced open, brings the row into sight
and lights it.

In the editor's narrower column a row's name and control share the first
line and its description goes under both (a grid), so a description that
grows after a click moves nothing under the pointer. An account's own
warm-up time goes under its Same/Own/Off picks, not before them, so
picking Own at 440 wide no longer pushes the picks a line down.

Tests:
- In the editor a click holds what was pressed where it was (modalHold),
  and the editor may scroll to do it, so checkin-account, warm-at-own and
  codex-reset-lead check the pressed row's place on the screen, and that
  the page itself never scrolls, instead of every scrollTop. Each target
  is brought into sight first, so Playwright's own scroll before a click
  isn't counted.
- reader.cjs's inEditor scrolls the editor's body with the wheel until
  the element is inside it and not covered, and checks again after the
  editor draws anew.
- settings-groups: Claude's editor has Claude Code's run row too; the
  Usage part names alertHead and alertList (missed by 7d177985f).
- codex-reset-lead's "lead set outside the choices" brings the pick into
  sight before opening it (red on origin/main too, #5054).

Paid for in the core budget by seven long comments cut to two lines each,
no raise.

Run (mote, at this tree):
- the 42 GUI files this reaches, plus settings-back, i18n-keys and gui-de,
  Chromium and WebKit: 855 pass, 8 red, each red on origin/main too and
  filed: plugin-move-unserved "Try again takes the models unticked"
  (#4392, #4410) and tencent-cloud's region strip (#4321, #4399).
- go test ./internal/gui -run 'TestCoreScriptBudget|TestI18n': ok.
Seen red on origin/main 53b2773d7 while checking and filed:
claude-tui-setting's "Route is already handled" (#5836) and
claude-lean-prompt-setting's WebKit page error (#5832).

Again after the rebase onto da8480326, at this commit: TestCoreScriptBudget
and TestI18n ok; provider-prefs, warm-at-own, checkin-account,
codex-reset-lead, settings-groups and i18n-keys 120 of 120.

Broken by hand, each red, then put back:
- the editor rows' grid rule removed: 16 red, warm-at-own 11 (both
  engines) and checkin-account 5 (WebKit), the pressed control moved.
- the own time's wrap-reverse removed: warm-at-own 8 red at 440 (Chromium
  and WebKit, a pick moved a line down).
- the search hit not opening Advanced: provider-prefs and settings-search
  32 of 38 red.
- the fields put before Advanced instead of in it: provider-prefs
  20 of 20 red.

Not tried: the real app window.
2026-11-10 07:08:02 +08:00
yetone da8480326f agent: detection's remaining stats make no os.FileInfo on darwin and linux
After statKind (e3ab7f3bf), os.Stat was still a fifth of what forty
/api/drift asks allocated with real accounts: Agent.Detected's look at
the agent's file, bundleInfo's and folderSubs' size-and-time stamps for
every desktop app, and qoderApp's status files. Each os.Stat makes an
os.FileInfo on the heap. They now go through the system call into a
Stat_t on the stack:
- Detected: statKind (exists, followed through links, as os.Stat).
- qoderApp: statFile, a regular file as Mode().IsRegular() says.
- bundleInfo, folderSubs: statStamp, mtime and size as ModTime/Size
  say (Mtimespec on darwin, Mtim on linux; os.Stat elsewhere).
Windows and other systems keep os.Stat.

Run (at this tree):
- mote: go test -count=1 ./internal/agent ok (518s, load high after a
  reboot); go vet darwin; linux and windows vet clean
- wsl-run (Linux): TestStatStamp|TestStatKind|TestQoder ok
- win-run (Windows): same set; TestQoderSettingsFromAnIDEPluginIsNotTheCLI
  red, and red the same on origin/main 783cd0f84 (#1827: the fixture is
  an extensionless #!/bin/sh on PATH); the rest ok
- TestStatStampAndFileSayWhatStatSays compares with os.Stat for a file,
  a folder, a link, a gone path and a path under a file; with darwin's
  statStamp put back on os.Stat by hand it is red (3 allocations for
  two looks), restored
- Real accounts (sandbox HOME copy), 40 /api/drift calls, paired runs:
  os.Stat 2.0/3.1 MB before, 1.5/0 MB after (left: pencilApp, a glob,
  provider.stampOf); totals 20.2/19.1 MB before, 18.5/17.5 MB after.
2026-11-10 06:46:50 +08:00
yetone 783cd0f840 agent: OpenClaw's file is made plain JSON once a change for a look
The model's Get and Check are asked on every drift poll, and each one
copied openclaw.json (edit.Read clones it), copied it again, blanked its
comments, ran json.Valid and parsed it to see it is an object. They now
go through openClawLook: filememo.Read keeps the checked plain JSON
while the file is unchanged, shared and read only. A not-there file is
nil, as before. Wire, unwire, connect, Set and Sync still read the file
fresh (openClawRead), since they write from it.

Run (mote, at this tree):
- go test -count=1 ./internal/agent: ok (207s)
- go vet ./internal/agent for darwin, linux, windows: clean
- TestOpenClawLookReadsAnUnchangedFileOnce: green (0 allocations held,
  another program's write and a broken file seen, a gone file nil);
  with openClawLook put back on openClawRead by hand it is red
  (5 allocations), restored
- Real accounts (sandbox HOME copy), 40 /api/drift calls, paired runs:
  openClawRead 0.5/0.5 MB before, gone after; totals 17.4/21.4 MB
  before, 17.5/15.5 MB after (sampling noise is about +-15%).

Not tried: Windows and Linux runs of the package (vet only).
2026-11-10 06:28:13 +08:00
yetone ce6ae593c5 agent: applied.json is parsed once a change for drift
appliedOf is asked for every agent on every drift poll (the GUI asks
/api/drift every 15s while visible), and each ask read and decoded the
whole applied.json. It now goes through filememo.Read: an unchanged file
is parsed once and its map shared (every appliedOf caller only reads it).
appliedSave calls filememo.Look so magpie's own record is read at once,
even inside a held request. Writers (record, appliedLoad's other callers)
still decode a fresh map.

Run (mote, at this tree):
- go test -count=1 ./internal/agent ./internal/filememo: ok (227s)
- go vet ./internal/agent for darwin, linux, windows: clean
- TestAppliedOfParsesAnUnchangedFileOnce: green; with appliedOf put back
  on appliedLoad by hand it is red (25 allocations), restored
- Real accounts (sandbox HOME copy), 40 /api/drift calls, paired runs:
  appliedLoad 2.0/3.1 MB before, gone after; totals 26.1/20.6 MB before,
  18.9/18.2 MB after.

Not tried: Windows and Linux runs of the package (vet only).
2026-11-10 06:19:23 +08:00
yetone e3ab7f3bf7 agent: isDir, isFile and Taken make no os.FileInfo on unix
Detection asks isDir, isFile and Taken of about a thousand paths on each
of the window's 15s /api/drift asks. os.Stat made an os.FileInfo on the
heap for each, a fifth of what forty asks allocated with real accounts.
statKind calls syscall.Stat into a Stat_t on the stack (retrying EINTR,
following links as os.Stat does); only the path made a C string is
left. Windows keeps os.Stat (statkind_other.go).

Run:
- TestStatKindAnswersWithoutAFileInfo: folder, file, gone, a path under
  a file, "" and a link to a folder answer as os.Stat did; two looks
  take 2 allocations. Broken by hand (statKind through os.Stat): red, 4.
- go test ./internal/agent on mote; go vet ./internal/agent for darwin,
  windows and linux.
- Real accounts (sandbox HOME on mote, 40 /api/drift asks), paired:
  os.Stat's allocations 4.6 and 4.1 MB before (t24), 1.0 and 1.5 MB
  after (t25); totals 25.0 and 22.6 MB before, 18.4 and 22.0 MB after.
2026-11-10 06:00:10 +08:00
yetone b93dd12441 github: bug and feature issue templates, with a known-issues link
A bug report asks for the version, surface (GUI/TUI/CLI), OS, agent and
provider, steps and the exact error, so a report can be reproduced
without a round of questions. config.yml links open bug issues as the
known-issues list, and Discord for questions. Asked for on X by
AskarKerey (2119903378700403104).

Run: the three files parse as YAML (python yaml.safe_load); the labels
bug and enhancement exist. No code changes, nothing else to run.
2026-11-10 05:44:26 +08:00
yetone 91fb441843 antigravity: effort stays selectable in the app's own picker
YujunT46308 on X: "antigravity 接入 magpie 会导致模型的 effort 不可选".
Antigravity's picker (main.js served by its 2.29.0 language server)
offers effort only by grouping catalog entries named "<name> (Low)",
"(Medium)", "(High)", "(XHigh)", "(Max)" under one row with an effort
submenu, two levels or more. magpie's listSource catalog listed each
model once, so no model of magpie's had an effort control.

Now /v1/models?format=antigravity lists a model with two or more of
those levels once a level, "<id>:<level>" named "<name> (<Level>)".
The app sends the chosen entry's id, and the gateway's existing
":level" suffix handling sends that level upstream, ahead of the row's
pick and of the app's own reasoning_effort (low whatever was chosen,
in a 2.29.0 run). models.defaultModelId names one of those entries
(gateway.AntigravityModel: the row's effort fitted, else medium, else
the lowest), since an id the catalog doesn't list starts the app on
its first model; Sync moves a file written before onto a level. The
row's effort sets the start level and still applies to models with
fewer than two levels. The model field shows the id without the level.

Run:
- Real Antigravity 2.29.0 language server + its UI in Playwright
  Chromium on mote, sandbox HOME, magpie built from this tree serving
  a fake upstream listing g3 with low/medium/high: `magpie provider
  add`, `magpie antigravity magpie/up/g3` wrote defaultModelId
  "up/g3:medium"; the picker shows one "g3 · up" row with Low, Medium,
  High (starts on Medium); picking High and sending "ping" reached the
  upstream as model g3 with reasoning_effort "high" (the app's title
  call went at medium, the start level). `magpie antigravity default`
  left {} as before.
- go test -tags nogui ./internal/agent ./internal/gateway -run
  Antigravity on mote; gofmt -l; go vet of both packages;
  GOOS=linux go vet -tags nogui ./...; GOOS=windows go vet ./...
- Full suite on mote, go test -tags nogui -timeout 45m ./... at this
  commit on origin/main 53b2773d7 (load ~500): 92 packages ok,
  internal/agent and internal/gateway among them; internal/plugin red
  at TestHostEndedEndsWhatItsPluginStarted/own_end ("the plugin never
  started its child", #5515, already filed, commented), ok alone after.
- Rebased on origin/main 8d9254729 (dsh, Fable 5.2, site): go build,
  go vet of agent and gateway, and their Antigravity tests again, ok.

Broken by hand: listing every model once (antigravityLevels(nil))
turns TestAntigravityCatalog red; not writing the level into
defaultModelId (Set, Sync and the effort Set) turns
TestAntigravityEffort red at all four checks. TestAntigravityAgentEffort's
new ":low over the row's high" case guards the suffix order, which
was already so.

Not tried: a real Antigravity account against a real vendor, the
packaged desktop app itself (the UI was its bundled main.js served by
its own language server), and the Windows and Linux apps.

Reported-by: YujunT46308 (X)
2026-11-10 05:21:40 +08:00
yetone 8d9254729a agent: dsh's patch lists are parsed once a change for a look
The window asks /api/drift every 15s while it is up, and each ask read
and parsed every dsh profile's patch list again, several times over
(dshGet, dshGetEffort, dshOver for the home layer, dshCheck). With real
accounts, forty asks allocated 38 MB, 13 MB of it dshRead and its parse.

dshLook is dshRead through filememo.Read: parsed once each time the file
changes and shared, so only the paths that look and write nothing use it
(dshGet, dshGetEffort, dshOver, dshGetLegacy, dshCheck,
dshSearchesHere). Every write path keeps dshRead, whose items it edits.
A gone file reads as empty, as edit.Read made it for dshRead.

Run:
- TestDshLookParsesAnUnchangedListOnce: 0 allocations a look under a
  request's hold, dsh's own later save read, a gone list empty. Broken
  by hand (dshLook returning dshRead): red, 12 allocations a look.
- go test ./internal/agent ./internal/edit ./internal/filememo on mote;
  go vet ./internal/agent for darwin, windows and linux.
- Real accounts (sandbox HOME on mote, 40 /api/drift asks): see below.
  before (t23) 35.6 and 38.4 MB, 12.7 and 13.2 MB of it dshRead; after
  (t24) 26.0 and 15.7 MB, no dshRead or dshParse left in the profile.
2026-11-10 05:13:34 +08:00
yetone b27b660467 provider: Fable 5.2 counts in the Claude card's Fable week
aipha2025 on X asked to see Fable 5.2's allowance. Claude Code 2.1.321's
/usage, run for real on a Team account in a sandbox config dir (the
token it renewed written back to the account's keychain item), tells
one Fable week ("Current week (Fable): 0% used · resets Nov 11 at 6am"),
which magpie already shows as "7 days · Fable" and which claude-fable-*
counts against. The test holds those bytes and checks 5.2 and 5.1 both
stop at a spent Fable week while Opus doesn't.

The launch's limit resets are not shown and can't be used from magpie:
- /usage -p prints no reset; Claude Code reads them from its own usage
  call (cedar_ember) and spends them with /limit-reset, a hidden,
  interactive-only command behind a per-account flag, which POSTs
  /api/organizations/<org>/reset_rate_limits.
- On the three accounts tried (Team, two Max 20x) the Fable reset
  program is off: /limit-reset said "A 5-hour limit reset isn't
  available right now", Team's said "Unknown command".
- magpie never calls Anthropic's endpoints as Claude Code, and a spend
  can't be tried without a reset to spend, so nothing is offered; the
  user spends one in claude.ai Settings > Usage or Claude Code's
  /limit-reset.

Run at this tree (mote): the provider package's Claude tests with
the agent and gateway runs in the commit before; gofmt and the three
vets clean.

Rebased onto b681b036d (53b2773d7 changed provider pricing) and run
again at this tree on mote: gofmt clean, vet ok; agent 121s, gateway
175s, provider 46s ok with -run
"Fable|Claude|Fast|Vertex|Bedrock|Effort|Thinking|Xhigh|XHigh|Desktop|Sampling|Adaptive|Price|Catalog".
The full ./... suite runs after the push; a red gets an issue.
2026-11-10 05:03:10 +08:00
yetone 6fe754cb20 claude: Fable 5.2 on Vertex, Bedrock, Desktop's fable tier and Anthropic's fast mode
Anthropic launched Claude Fable 5.2 (claude-fable-5-2) on 11-09
(thelegendof2414 on X: not in magpie's list). Checked against
Anthropic's "What's new in Fable 5.2" page, AWS's model card, models.dev
and Claude Code 2.1.321's own bundle:

- Claude subscription and Anthropic API: the list follows models.dev,
  which already has claude-fable-5-2 (8/40, cache read 0.2, write 10,
  1M context, 128k out), so it shows once the catalog syncs (at most
  24h). TestClaudeAccountListsFable52 holds that with the literal
  models.dev row: listed first, priced, 1M window, low to max efforts.
- Vertex global and Bedrock presets list it
  (global.anthropic.claude-fable-5-2 is on AWS's card).
- Claude Desktop's fable tier now behaves as claude-fable-5-2 (2.1.321's
  latest_per_family); Desktop's own catalog v4371 still ends at 5.1.
- Fast mode on Anthropic's API key: Fable 5.2 has it ($16/$80; 2.1.321's
  fast-mode opt-in set is fable-5-2 and mythos-5-2). Fable 5.1 never had
  it and stays off. A Claude subscription account still gets no fast
  mode in magpie, as before.
- Claude Code's effort: 2.1.321 reads the top-level effortLevel only for
  models up to Fable 5.1 and Mythos 5.1, so 5.2 goes in modelSettings,
  as Opus 5.5 does (claudeReadsTop unchanged, test added).
- Gateway: adaptive-only thinking, no sampling, thinking off never sent,
  xhigh kept: the version rules already cover 5.2; tests now name it.

Run at this tree (mote): gofmt -l clean; go vet ./... (darwin),
GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./... ok;
go test -count=1 ./internal/agent ./internal/gateway ./internal/provider
-run 'Fable|Claude|Fast|Vertex|Bedrock|Effort|Thinking|Xhigh|XHigh|Desktop|Sampling|Adaptive'
ok (84s, 178s, 36s).
Not run before the push: the full go test ./... (mote had six suites
queued on suite.lock at load 420); it runs after, and a red is filed.
Not tried: a real Fable 5.2 request through magpie; fast mode on a real
API key.
2026-11-10 04:58:30 +08:00
yetone b681b036d2 site: Mistral and Ollama pages in en, zh and ja
/docs/mistral and /docs/ollama (with zh/ and ja/) answer "how do I use
Mistral / Ollama in Claude Code, Codex, Gemini CLI and OpenCode".

Facts come from the source: the mistral, ollama and ollama-cloud
presets in internal/provider/presets.go, chattidy.go (thinking parts,
#483, #494), mistral_plan.go, ollama_usage.go, local_address.go,
gateway/ollama.go, and the usage text of internal/cli/providers_cli.go
and model_cli.go for every CLI example (provider add, fallback, models
+id, model price, model efforts).

Every docs page with a "By provider" line now lists both, in one order;
sitemap.xml, llms.txt and llms-full.txt (rebuilt) carry them.

Run on mote: node --test worker.test.mjs install.test.mjs (fail 0);
JSON-LD of the six pages parsed. Deployed (e33573b9) and every new URL
answers 200.
Not tried: the CLI examples against a live magpie (read from the
source's usage text instead).
2026-11-10 04:54:13 +08:00
yetone 53b2773d77 providers: each model priced once, on catalogs worked out once per provider
The Providers page asked PricedFree and ListPrice of every model of
every provider on each ask. Each ran listPrice, which worked out the
provider's catalogs again (Catalogs' split, EndpointCatalog, the
membership filter, kimiCodeMember's split once more), made the names
to look up on the heap, and built userPrice's three keys as strings.
A heap profile of 40 /api/providers asks with real accounts put 4MB
there (2MB catalogs, 1.5MB names).

provider.Pricer works the catalogs out once per provider (priceCats,
kimiCodeMember included), and Prices gives a model its list price and
its free mark from one listPrice. The names go into a stack buffer,
userPrice skips its keys when the user set no prices and otherwise
looks them up from a stack buffer without a copy, and PricedFree's
plan filter copies the list only when a plan's catalog is in it.
ListPrice and PricedFree keep their answers; they now share listPriceIn.

Under the request's holds, two models priced went from 6 allocations
and 10.5us to 0 and ~4us (213us to 4us outside a hold, where
plugin.Cached stats plugins.json for each unpriced model).

TestPricerAllocatesNothingPerModel: 0 allocations for a model, priced,
at $0 or unpriced, under the holds; red (7) when Prices works the
catalogs out per model again. TestPricedFreeIsTheProvidersOwnZero now
also checks Pricer.Prices against ListPrice and PricedFree for every
case, with and without the user's prices.

Run on mote: go test ./internal/provider ./internal/gui
./internal/catalog ok; vet gui and provider for darwin and windows,
provider for linux, ok. Real accounts (sandbox HOME copy), 40 asks
paired twice with the build before: listPrice/PricedFree (~1.5MB a run
there) no longer show in the profile; the totals are within the
+-15MB run-to-run noise (95.7/90.5MB before, 97.0/98.4MB after).
2026-11-10 04:47:19 +08:00
yetone 98c4b2e814 usage: a request opens on a page of its own
geesehowardt7 on X clicked a request on the Usage page to see where it
came from. The click on its time opened Routing, which they hadn't
asked for, and the row's details had no source address.

A row's click, or Enter or Space on it, now pushes that request's own
page (#ledReqPane, ledReqOpen/renderLedReq) over the list. The page
gives the model and status, then ledDetail: time, agent, source IP
(the previous commit's client_ip: loopback reads "This computer ·
127.0.0.1", a gateway row from before the field "Not recorded", rows
read from session files, other computers and magpie's own calls none),
requested, provider, account, sent, served, effort, then status,
error, duration, tokens, cost, credits, speed and the archive. Routing
is the View routing link in it, and the time cell no longer links
there. "Requests ‹" or Escape (not while a menu, dialog or field takes
it) goes back to the list where it was left, with the row focused
(ledReqClose). Leaving the Usage page closes it (ledLeave(true)), and
a refresh keeps it. The in-table expanding row (ledOpen, tr.led-detail)
and its narrow-window lc-opt copies are gone, since the page shows
every field at every width. It slides in 200ms with the ease-out
curve, and only fades with reduced motion. "Source IP" and "Not
recorded" are added in zh, zh-TW, ja and de. The 20 ledger test files
that opened a row's details now open the page. usage-request-page.test.cjs
covers the page, the address, the way back, focus and a 560px window.
docs/subsystems/gui-shell.md describes it.

Run at this commit's tree (rebased on origin/main b4a0a2a1a, with the
two commits beside it):
- mote (macOS 27): gofmt -l clean; go vet ./..., GOOS=linux -tags
  nogui go vet and GOOS=windows go vet ok. go test internal/gui (with
  TestCoreScriptBudget) ok in 164s, internal/usage, internal/usageapi,
  internal/cli and the root package ok, internal/gateway -run
  "Usage|ClientIP" ok, internal/provider -race -count=5 -run Workspace
  ok.
- WSL VM (magpie-desktop), whole suite through the suite lock at
  be9dbce02 plus this change: go test ./... -timeout 45m ok apart from
  the GTK packages, which need a display the VM run lacks (they pass
  on mote), TestGrokInstalled (#3548) and the provider workspace test
  the next commit fixes (#5800). GUI suite: 540 of 23297 red in 114
  files, WebKit timeouts mostly (#4121); those 114 files run again
  give 378 reds here and 365 at be9dbce02, the same files, and
  own-requests was the one this change broke (fixed: a row's click now
  opens the page, and its way back keeps the list's place).
- WSL VM, the 119 Usage and Routing GUI files at the rebased head,
  both engines: 21 red, 20 of them red the same at origin/main
  b4a0a2a1a: click-scroll (#4385), routing-cline-route and
  routing-upstream (#5156), usage-agents-hide (#2276, #3414),
  usage-heatmap (#4718), usage-ledger-ttft (#4489), usage-ledger-chart
  (#4263), usage-focus-steady (#3501), usage-fold (#3415, #2163),
  usage-ledger Requests (#3104, #5048), account-refresh-holds (#5814)
  and usage-speed-all-models (#5834, red since the 24 hours period).
  The 21st, usage-compact-counts chromium "zh 万 at 420px", is the
  flake in #5648 and passes 3 of 3 alone.
Again after rebasing on origin/main b3a57b3d8 (main's WebSocket row in
the ledger, 7c1dc198d): mote go vet, internal/gui, internal/usage,
internal/usageapi, internal/cli, the root package, internal/provider
and gateway -run "Usage|ClientIP|Socket|Memory" ok, apart from
TestCoreScriptBudget, red on main since b3a57b3d8 and fixed there by
4894332d7, which this is now rebased on; the VM's 119 files plus usage-ledger-bytes and
codex-app-back: 1708 of 1782 pass, no red that isn't in the list
above, usage-ledger-bytes passing with the request page.
Not tried: a request from another device over a real LAN share.
2026-11-10 04:44:13 +08:00
yetone 68865032c3 usage: a gateway row keeps the address its request came from, on this computer only
geesehowardt7 on X asked to see a request's source IP. No usage row
kept it.

Record.ClientIP (json client_ip) is set in appendUsage from peerAddr:
the connection's own address, never a forwarding header (the gateway
trusts none), so behind a reverse proxy it is the proxy's. Loopback is
127.0.0.1/::1. Rows kept before this, reported calls and magpie's own
calls have none. rowText packs it, or the ledger cache gave it back
empty (the cache's file is keyed on this package's source, so it is
rebuilt once).

It stays here:
- sync's OwnDays blanks it, as it does Archive and Computer;
- GET /v1/magpie/usage/requests (other computers, Remote magpie, key
  holders) takes it out for every caller (withoutClientIPs);
- the CSV export, OTel and middleware points name their own columns
  and don't carry it; telemetry sends ids only.
The window's /api/usage/requests keeps it for the Usage page.

Run (mote, at base e3f1efdaa):
- go test -count=1 -timeout 45m ./internal/usage ./internal/usageapi: ok
- go test -run 'TestUsageRowsKeepTheClientsAddress|TestUsageOverGateway'
  ./internal/gateway: ok
- go vet, GOOS=linux go vet -tags nogui, GOOS=windows go vet on
  gateway and usage: ok; gofmt -l clean.
Broken by hand, each restored:
- no ClientIP in appendUsage: TestUsageRowsKeepTheClientsAddress red
  (addresses kept: map[:true]).
- no withoutClientIPs: the same test red (the API told 127.0.0.1:5000
  the address).
- OwnDays not blanking it: TestClientIPKeptHereNotShared red.
- before rowText packed it: TestClientIPKeptHereNotShared red (empty
  from the ledger).
The full suite runs with the GUI commit that shows it.
2026-11-10 04:44:07 +08:00
yetone 4894332d79 gui: the core scripts back under their budget after b3a57b3d8
b3a57b3d8 named the ChatGPT projects and chats in the Codex reset note
(en, zh, zh-TW, ja, de), and the core's scripts came to 1,533,812 bytes
against a budget of 1,533,802, so TestCoreScriptBudget was red on main.
appBackSaid's comment is cut to two lines (the string it heads says the
rest), paying for the note with no raise.

Run on mote at 682a1e392 with this change: go test ./internal/gui ok.
2026-11-10 04:33:22 +08:00
yetone f3d8a09d24 providers: another vendor's base isn't parsed to look for Tencent or OpenCode Go
The Providers page asks tencentPlanRegion and openCodeGateway of every
provider on each list. Both url.Parse'd every base, a heap profile of 40
/api/providers asks put 3MB of url.Parse there (2.5MB Tencent, 0.5MB
OpenCode). Every host either takes holds "tencentmaas.com" or
"opencode.ai", so a base without it (case folded; ToLower copies nothing
for an already lower-case base) returns at once.

TestOtherVendorsBasesAreNotParsed: 0 allocations for another vendor's
provider and base, and mixed-case Tencent and OpenCode Go bases still
resolve (ap-guangzhou, go). Red on the old code (3 and 1 allocations).

Run on mote at 682a1e392: go test ./internal/provider ./internal/gui ok;
vet provider for darwin, linux and windows ok.
2026-11-10 04:33:22 +08:00
yetone 682a1e3925 site: Gemini and Grok pages in en, zh and ja
New docs pages /docs/gemini and /docs/grok (with zh/ and ja/), each
linked from every "By provider" line (the four agent guides, OpenRouter
and Copilot in all three languages), sitemap.xml and llms.txt;
llms-full.txt rebuilt.

Gemini facts and their sources:
- preset "google", AI Studio keys, models.dev google catalog
  (internal/provider/presets.go); Chat and native Gemini endpoints,
  only Gemini clients on the native API (provider/gemini_api.go).
- thinking_config with include_thoughts, Gemini 2 budgets, xhigh/max
  sent as high (gateway/chat.go aiStudioThinking); a refused level is
  retried at the nearest one, a refused thinking_config falls back to
  reasoning_effort (gateway.go geminiRefusedLevel, refusesThinkingConfig).
- thought signatures kept 90 days and returned only to their provider
  (gemini_sigstore.go sigKeep, gemini_signature.go); tool schema clean-up
  (gemini_schema.go); search only without function tools (search.go
  geminiKeySearches); per-minute 429s as rate limits (routing.go).
- Vertex AI preset and options (provider/vertex.go, cli/providers_cli.go).
- Code Assist and Antigravity worded as docs/subscriptions.

Grok facts and their sources:
- xai preset: Chat and Responses at api.x.ai/v1, Messages at api.x.ai
  (presets.go); Claude Code, Codex, OpenCode go as they are, Gemini CLI
  translated to Chat (provider.go Speaks, gateway.go usable).
- fixes for xAI: xai_body.go, grok_schema.go (#2317), object_root.go
  (#1271), lone tool_choice (#378), additional_tools (#350),
  grok_integral.go (#1431), custom_tool.go.
- effort fitting (decide.go fitFor), search (search.go), cache stickiness
  (affinity.go cacheWorth/cacheCold), errors (gateway.go tooLongRe,
  fallback.go shapeRefused). Grok Build's ~/.grok/config.toml (agent/grok.go).
- The Grok subscription and its community plugin are left out on purpose.

Run: mote-run `node --test worker.test.mjs install.test.mjs` in site/,
71 pass; JSON-LD of all six pages parsed with node on mote. Deployed
(version f785815d) and curl-checked: all six pages 200, sitemap lists them.

Not tried: no real Gemini or xAI request was made for this page; header
names, vendor terms, free-tier numbers and xAI's own rate limits are left
out because the source doesn't state them.
2026-11-10 04:27:16 +08:00
yetone 954977d1a4 provider: the workspace-switch test's fake counts its asks under a lock (#5819)
LoginUsage reads every account at once, so TestCodexAppWorkspaceSwitch-
ReadsEachWorkspace's fake handled ws-personal and ws-team together and
wrote asked[ws]++ from two handlers unguarded. That is #5819's red
("workspaces read: map[ws-personal:1]", no per-account error: the
team's reading was right, its count was lost) and, in the full run at
d3fc6f2bf on mote, "fatal error: concurrent map writes" at
codex_workspace_switch_test.go:90, which took the whole provider
package down. The count is now taken under a mutex.

Run on mote: go test -race -count=3 on the old test, DATA RACE at :90
and FAIL; with this change -race -count=20 -cpu 1,4 ok, gofmt and vet
clean. The full ./... run at d3fc6f2bf had two more reds, both filed
already: gui TestOpenInRexSelectsTheTab/remote_control_off (#5565,
asked []) and plugin TestCancelledSignInEndsItsFetch (#5264).
2026-11-10 04:23:37 +08:00
yetone b3a57b3d8f codex: turning the takeover off restarts the Codex app, so its ChatGPT projects come back
Herzz____ on X, the Windows Codex app: with Codex through magpie the
sidebar's project list is empty; they use magpie only when their
subscription runs out, and want to switch between magpie and the native
sign-in with the projects whole each way.

What happens. When the ChatGPT account is used up, magpie becomes
Codex's provider (codex.out) without requires_openai_auth: on that
account the app's composer gate greys Send for every model, magpie's
too (#540). Checked again in ChatGPT.app 26.1029's bundle: the gate
picks the account's own snapshot (limitName null) whenever it is
blocked, before any per-model additional_rate_limits, so keeping the
account during the takeover would still grey Send. The app-server then
answers account/read with no account and the app hides its ChatGPT
projects and chats (72ca3d593). magpie never touches projects,
project_roots or a thread's cwd: its thread moves only rewrite
threads.model_provider (sessions/codex_provider.go), so path case or
backslashes on Windows play no part.

What was wrong. Turning the takeover off by hand (the takeover note's
Keep on ChatGPT, the sign-in's Always ChatGPT, or Disconnect) looked
the same to codexAppStep as the reset, magpie's own end of it: with
Restart the Codex app to follow off (the default) the app's app-server
was left running on no account, so the projects stayed gone after the
user switched back to have them, until they restarted the app (the
Windows app has no Restart of its own).

Now Agent.AppOutOff (Always ChatGPT, or Codex not routed through
magpie) reaches the step through provider.CodexTakeoverOff, asked only
as out goes false, and a takeover ended so counts as the user's change:
the app-server is restarted once no Codex turn runs, as for a Connect,
and the Windows app reopened if none comes back (existing path). The
reset itself still leaves the app running and says so (CodexAppBack);
that note now names the ChatGPT projects and chats it lacks (en, zh,
zh-TW, ja, de). agent-wiring.md says the same.

Switching back to native is already in magpie: Agents > Codex > sign-in
> Always ChatGPT (`magpie codex login chatgpt`), or Keep on ChatGPT on
the takeover note; ChatGPT (the default) lets magpie take over again.

Tests: TestCodexAppRestartedWhenTheTakeoverIsTurnedOff (turned off with
a request in flight: held, then restarted; CodexAppBack not said; the
hook asked once; the reset still left running and said);
TestCodexOwnModelOutThenKeptOnChatGPT and
TestCodexOwnModelGoesThroughMagpieWhileUsedUp assert AppOutOff for Keep
on ChatGPT, Disconnect and the reset; codex-app-back.test.cjs checks
the note names the projects in every language.
Broken by hand: offByHand out of byHand, the provider test red (ended
[], want [100]); the login half of AppOutOff false, the Keep on ChatGPT
test red; the routed half false, the Disconnect check red.

Run (mote-run at b87783fbb (this change's tree) on origin/main 547585cd9): gofmt -l clean;
go build ./...; go vet linux -tags nogui ./... and windows ./...,
darwin ./internal/agent ./internal/provider ./internal/gui;
go test -tags nogui ./internal/provider ./internal/agent ok;
GUI codex-app-back, codex-app-out, i18n-keys, i18n-en-no-cjk, gui-ja,
Chromium and WebKit, every language, 155 of 155 pass.
Windows (win-run on xiaomi-gpu): the provider and agent Codex app tests
ok; the box's running Windows Codex app (26.1029) app-server command
line has the shape TestCodexAppOwnServer already holds.
Not run: a real used-up ChatGPT account (none at hand), so the restart
after Keep on ChatGPT is tried with the stubbed step, not the real app;
the full go test ./... waits behind mote's suite lock and runs after the
push, any red filed.
2026-11-10 04:14:40 +08:00
yetone 547585cd9c gateway: memory answers the agents on this computer alone
/mcp/magpie/memory (a28744c32) was served like the search server: from
another computer, while magpie is shared, with any enabled gateway key.
A key uses every MCP server unless it is held to some, and keys are
given to other people. Such a key could read every memory (who the user
is, their preferences), forget them, and save a global "rule" that the
digest (79decfe71) writes into every agent's instructions on this
computer, so a friend's key could plant instructions in the owner's own
agents. The hub already gave memory to this computer only (HereOnly,
isMemory); this direct route didn't.

memoryMCP now refuses !local(r) || fromBrowser(r) before serveMCP: no
other computer, keyed or not, and no web page, one Settings lists and
that sends a key included. `magpie mcp memory` (stdio, posts to loopback)
and the hub are unchanged. docs/subsystems/memory.md says so.

Run: on mote at b4a0a2a1a + this change: go test -count=1 -timeout 45m
./internal/gateway/ (ok 1169s) ./internal/library/ (ok 193s)
./internal/browsermcp/ (ok); go vet of the three, and GOOS=linux and
GOOS=windows go vet ./internal/gateway/; gofmt -l clean. Rebased onto
795cab91f, whose commits touch no file here; at the rebased head,
go test -run 'TestMemoryMCP|TestSearchMCPGuarded|TestHub'
./internal/gateway/ is ok.

Broken by hand: with memoryMCP's check reverted, TestMemoryMCPGuarded is
red: "shared, with its key: 200 ... The user's bank PIN hint is the cat's
name". The test covers another computer unshared and shared with its key,
an unlisted page, a listed page with a key and a Chrome fetch with no
Origin, each for memory_search and memory_save, checks nothing was saved,
and that an agent here still finds the memory.

Not tried: the real app with a second computer on the LAN.
2026-11-10 04:07:34 +08:00
yetone 795cab91ff site: OpenRouter and GitHub Copilot pages in en, zh and ja
Two provider guides beside DeepSeek, Kimi, GLM, Qwen and MiniMax, at
/docs/{,zh/,ja/}{openrouter,copilot}, linked from each agent guide's
"By provider" line, from each other, the sitemap and llms.txt
(llms-full.txt rebuilt).

Facts come from source. OpenRouter: the preset's Chat and Anthropic
bases in presets.go, the relay path that sends Claude Code's requests
as they are, Messages for Claude models (MessagesFirst) so cache_control
survives, skipOpenRouterAnthropic for the model list, readOpenRouter's
credits, MaxRPM on free models and openRouterSharedPool, creditRest.
Copilot: device sign-in and the three read-only login sources
(copilot_accounts.go, copilot_cli.go), GHE.com hosts, /models and
copilot_refused.go, copilot_auto.go's pick and fallback, the plan names
(copilot_accounts.go: Free, Pro, Pro+, Max, Education, Business,
Enterprise), copilotSubscriptionUsage's windows, cacheWritesAlike.
Header names, GitHub's terms and env variables are left out.

Run: mote-run sh -c 'cd site && node --test worker.test.mjs
install.test.mjs': 71 pass, 0 fail. JSON-LD of the six pages parses.
Deployed (1a513b7d); the six pages answer with their titles.
Not tried: a real OpenRouter key or Copilot seat through the pages'
commands.
2026-11-10 04:01:09 +08:00
yetone d3fc6f2bfa provider: FileError and groupsKeeping read providers.json's kept parse
Each Providers page asked FileError whether providers.json reads, and
groupsKeeping whether any group unlists models; outside a held request
both parsed the whole file again (6.7MB growslice of 112MB per 40
/api/providers asks on the real-account copy). Both now use the parse
filememo keeps until the file changes (storedFile); FileError falls
back to read() only when that parse fails, so a broken file still says
so with read's own error. Both are read-only uses.

Run: TestFileErrorReadsParsedFileOnce red with the memo path taken out
("parsed the file 3 more times"), green with it; TestFileError* and
the unlist tests on mote.
2026-11-10 03:48:24 +08:00
yetone fda52fe5dd providers: the page finds each routing group's members once
providersState asked GroupFinder for a group's members once for every
agent on that group, and again for the gateway's group list, and each
ask built every member anew (a Member is 1408 bytes). groupsOnce keeps
what was found for the page's build; the page only reads it.
2026-11-10 03:48:24 +08:00
yetone 0ec28be0d4 provider: a look at the accounts for sign-in alerts is held, built once
signInStates ran twice every two minutes all day: once for the app's
notification (WatchSignIns) and once for the gateway's hooks
(tellHooksOfSignIns). Outside a request nothing is held, so each
account's PluginOf built the plugins' list again (plugin.Cached reads
plugins.json and the plugins' auth) and Logins read every login again.
The look now holds the catalog (provider.Hold), as a request does, so
each is built once a look.
2026-11-10 03:48:24 +08:00
yetone b3791e8a6a providers: the page's model, provider, preset and group-member lists are made at their size
/api/providers grew five lists by append, each of large elements:
a group's members (Member, 1408 bytes) in membersFound, the picks a
vendor list lacks (catalog.Model) in providerInfoWith, and the
Providers and Presets lists of providersState. Each is now made once
at its count. membersFound also clones a member's path and builds its
key only after the checks that pass it over, and a group with no
member found still gives nil.
2026-11-10 03:48:24 +08:00
yetone 7c1dc198d1 usage: a turn over the Responses WebSocket counts what the socket was sent, and says so
A Codex turn kept on a Responses WebSocket sends only the new items as a
delta, but the row's ↑ was the whole HTTP body magpie built before the
transport ran, so a long conversation read as ~13MB up per turn
(matrix0487 on Discord). overSocket now records what each socket write
carried (wroteSocket) and, when the turn went out on the socket alone,
replaces the HTTP figure with those bytes (sentOnSocket); a turn that fell
back to HTTP keeps the HTTP body and adds any socket write made before the
fallback. errCodexSocketAgain's retry on a new socket counts both writes.

The row remembers that it went over the socket: Record.Socket (json "ws"),
packed as Flags bit 16384 (rowSocket, added to TestRowFlagsApart). The
Requests table's protocol badge says "Responses · WS" and the details'
Protocol line "Responses · WebSocket".

Run on mote at this commit (rebased on origin/main b4a0a2a1a): gofmt -l
clean; GOOS=linux and GOOS=windows go vet of internal/gateway and
internal/usage; go test ./internal/usage ./internal/gui ok; go test
./internal/gateway -run 'Codex|UpBytes|Ledger|Socket' ok; node --test of
every ledger-*, usage-ledger* GUI file and i18n-keys, 502 of 511, both
engines. The reds are filed and untouched by this change: ledger-swipe
webkit (#5223) and usage-ledger's "newest live route needs no
return-to-live button" (#3104, #4078, #4626, #5048).

Broken by hand: without the deferred sentOnSocket,
TestCodexSocketRowCountsWhatTheSocketSent reads 50,360 B for a 253 B
delta; without the Flags set, TestRowKeepsSocket's packed rows lose
Socket.

Not tried: a real Codex Pro account over the socket, and the full suite
(it runs after the tag). There is no "saved by the socket" figure yet,
since PlainBytes isn't packed.

Reported-by: matrix0487 (Discord)
2026-11-10 03:44:19 +08:00
yetone b4a0a2a1ab cli: the Memory tab's routes wait for the library's stage of #4745
TestEveryRouteHasACommandOrIsNamed was red on this stack: the routes of
/api/memory, /api/memory/distill and /api/memory/dream have no
`magpie` command yet. They are the Library's Memory tab, so they are
listed in notYet as L (stage 3: the library), as the other library
routes are. Agents already reach memory without the GUI through
`magpie mcp memory`.

Run on mote: go test -count=3 -run TestEveryRouteHasACommandOrIsNamed
./internal/cli ok.
2026-11-10 03:25:45 +08:00
yetone eebb878977 cli: TestGroupSetID expects a renamed group's old id to find it
00af08e7b (01:08 today) let a renamed routing group still answer to its
old id, through Former. TestGroupSetID still asserted that group/auto-m
finds nothing after `group set auto-m id=m`, so internal/cli has been
red on main since then; it fails at c02a491e8 on a clean checkout.
Bisected on mote from b855cfee9 (ok) to 00af08e7b. The test now asserts
what 00af08e7b intends: the old id finds the renamed group "m", never a
second group of its own.

Run on mote: go test -count=3 -run TestGroupSetID ./internal/cli ok.
Broken by hand (expecting another id): red.
2026-11-10 03:25:45 +08:00
yetone 2c2bd15d71 memory: Tidy up every night, a switch in the Memory tab
The Memory tab gets a second row under Learn from conversations. It is
off by default. Switched on, the first tidy is due at the next 03:00.
Tidy now runs one at once, and Undo puts the last one back. While
distillation is off, the row has its own model picker; both rows share
one model.
Routes: POST /api/memory/dream {on}, /dream/run and /dream/undo.
GET /api/memory/distill carries "dreaming", so a tidy no longer shows
as conversations being read.

The prompt's stale rule is narrower. On the first real run it set aside
two decisions because "the work is done". Now only a note that later
notes contradict, one past its date, or one about a finished one-off
task is stale; a decision, direction or preference stays.
docs/subsystems/memory.md gets a Dreaming section.

Real run: a sandbox memory.json of 62 real distilled memories, 12 active
and one each user-written and pinned, with auto/claude-haiku-5-5 through
the live gateway.
- Before the prompt change: 12 changes in 48s, 10 merges and 2 set aside.
  Both set-aside notes were decisions.
- After: 12 merges in 46s, none set aside. Each merge joins real
  duplicates (three ~/.codex/sessions cleanup rules into one, the
  TestFlight 1.66/1.68 pair). One went into the fixed memory, whose text
  was kept word for word.
- Undo: 25 restored. memory.json's ids and statuses equal the backup
  taken before the run, and every merged memory is gone.

Broken by hand, each red:
- Undo not reloading the list: library-memory 22 failed.
- Ignoring DreamSince: TestDreamsOnceANight.
- A plan applied after an error: TestDreamFailureChangesNothing.
- Tidy's fixed guard and Untidy's status check: their memory tests.

Run on mote at this tree:
- go test internal/memory, memdistill, library: ok.
- internal/gui -run 'Distill|Dream|I18n|Budget': ok.
- library-memory.test.cjs: 22/22 in both engines.
- i18n-keys and i18n-en-no-cjk: 4/4 each.
- go vet (darwin), GOOS=linux -tags nogui, GOOS=windows: ok.
Not run yet: the full suite at this head.
2026-11-10 03:25:45 +08:00
yetone 408db02bf2 memory: the automatic model's empty note uses the core "No models"
370d2fd5f gave the Library plugin its own "no model" string, and
internal/agent's antigravity_test.go says those words too, so i18n-keys'
"a plugin's words are its own" went red. The note now uses the core
"No models", which is already translated.

Run on mote: i18n-keys 4/4, i18n-en-no-cjk 4/4 and library-memory 22/22,
all with the P3 GUI change in the tree too.
2026-11-10 03:25:45 +08:00
yetone 8c4c313eb7 memdistill: a nightly tidy of memory (Dreaming), undone in one step
Switched on (off by default), once a day from 03:00 local time the
hourly loop shows a model each scope's memories, 120 at a time under
short names, the user's own and pinned ones marked fixed, and asks which
say the same thing and which are no longer true. memory.Tidy merges and
sets aside what it names; candidates distilled from conversations and
left unreviewed for 30 days are set aside too, with no request when
nothing else could change. A request that fails changes nothing: the
error is kept and the tidy is tried on the next tick. What the last tidy
did is kept in distill.json and Undo puts it back once.

The prompt names neither magpie nor a vendor.

Run: mote-run go test -count=1 ./internal/memdistill ./internal/memory: ok.
Broken by hand: applying the plan after a failed request turns
TestDreamFailureChangesNothing red; ignoring when it was switched on
turns TestDreamsOnceANight red.
Not tried yet: a real model (next, with the GUI).
2026-11-10 03:25:45 +08:00
yetone 0a08c37080 memory: Tidy merges and sets aside, Untidy undoes it
The store side of the nightly tidy (Dreaming). Tidy takes a plan: merges
of memories that say the same thing, memories to set aside, and a date
before which unreviewed distilled candidates are set aside. What the user
wrote or pinned is never rewritten or set aside; merged with others it is
the one kept, word for word, and two of them are never merged. A merge
across scopes or of a memory no longer in use isn't done. Each change is
returned with the states it replaced, and Untidy puts back only what is
still as Tidy left it; a merged memory the user edited since stays.

Run: mote-run go test -count=1 ./internal/memory: ok.
Broken by hand: dropping the user/pinned guard on stale turns
TestTidyNeverChangesTheUsers red; dropping Untidy's "still archived"
check turns TestUntidyKeepsWhatTheUserChanged red (undo: 3).
2026-11-10 03:25:45 +08:00
yetone 3445d8384e memdistill: a proposal stands on words the user wrote
A real run (Haiku through the live gateway, 10 of this Mac's Claude Code
conversations, magpie's config/cache/state in a sandbox, HOME real)
proposed 38 candidates. The ones without a quote were the assistant's
own standing instructions said back (run heavy commands on mote, no
git add -A, ask before deleting), not anything the user said. Now the
prompt asks for the user's words copied exactly and leaves out what
only the assistant said, and keep drops a proposal whose quote is
missing or isn't in the user's text (letters and digits compared,
case aside).

Same 10 conversations again: 24 candidates, every one quoting the
user, none of the echoes.

Run (mote): go test ./internal/memdistill: ok. Broken by hand: the
check off, TestReadsQuietSessionsOnce red (Added 5, want 3).
2026-11-10 03:25:45 +08:00
yetone 4d12d44163 memory: Learn from conversations, a switch in the Memory tab
The Memory tab gets a row that reads finished conversations into
candidate memories (To review). It is off until switched on; switched
on it reads at once, then hourly (5 minutes after start, then every
hour), through the gateway this process serves under the agent
"memory", with the automatic model unless one is picked through the
app's menu. Read now runs it again; a run that stopped says why.

- memdistill: Keep (the hourly loop) and Running.
- gui: /api/memory/distill (GET, POST {on, model}), /distill/run;
  distillComplete posts /v1/messages to the served gateway's handler
  with the memory agent's token.
- library client: the row, its poll while a run goes, and the
  memories reloaded when it ends; strings in zh, zh-TW, ja, de.
- docs/subsystems/memory.md: a Distillation section.

Run (mote, at this tree):
- go vet ./internal/gui ./internal/memdistill ./internal/memory; GOOS=linux
  -tags nogui and GOOS=windows vet of gui and memdistill: clean.
- go test ./internal/gui ./internal/memdistill ./internal/memory
  ./internal/library: ok.
- node --test internal/gui/tests/library-memory.test.cjs: 22/22, Chromium
  and WebKit, 5 languages, 980 and 420.

Broken by hand:
- the memories not reloaded after a run: the GUI test is red waiting
  for the proposed memory.
- the token not the memory agent's (earlier): TestDistillCompleteThroughGateway
  red on the Trace's agent.

Not tried yet: a real model's run (next), the whole GUI suite (queued
behind the suite lock on mote), the full Go suite.
2026-11-10 03:25:45 +08:00
yetone 60cd7367c2 memdistill: finished conversations proposed as memories to review
A model reads an agent's session once it has been quiet for 30 minutes
and writes down what will hold beyond it: a stated preference, a rule
from a correction, a project fact the code doesn't say. Each one waits
in memory as a candidate (To review), with the session, folder and the
user's words it came from; nothing reaches an agent until kept.

- Off until switched on (distill.json); switched on, it looks back 7 days.
- Main sessions only: no subagents, gateway-only or read-only sessions,
  none of its own (agent "memory"), and two user turns at least.
- At most 10 sessions a run, the latest first; a session is read again
  only once it goes on. A model that fails stops the run and says why;
  the sessions not read are read next time.
- The model is sent user and assistant text alone (no thinking, tool
  calls or results), cut to 24k characters (start and end), with the
  memories already known so they aren't proposed again. Its
  instructions name neither the app nor a vendor.
- A distilled memory the user deleted isn't proposed again (2e0058330).
- An unreadable distill.json is never written over, and nothing runs.

Not wired to the gateway or the GUI yet (next commit).

Run: mote-run go test ./internal/memdistill (ok), go vet (ok).
Broken by hand, each red then green restored: the quiet check
(ReadsQuietSessionsOnce), the read-once mark (three tests), the
text-only filter (WhatIsSent), the on switch (OffReadsNothing), skipping
gateway-only/own sessions (ReadsQuietSessionsOnce).
Not tried: a real model; that comes with the wiring.
2026-11-10 03:25:45 +08:00
yetone d61171d245 memory: a distilled memory the user threw away isn't proposed again
Distilling sessions (next) will propose candidates. One the user deletes
or archives is remembered by its text (Dismissed, the last 1000), and a
save from a conversation of the same text is skipped. An agent's own save
of that text is still kept. A memory an agent forgot in a scope isn't
proposed again in that scope.

Run: mote-run go test ./internal/memory (ok).
Broken by hand: Remove without dismiss, and Save without the Dismissed
check, each red in TestDismissedNotProposedAgain; restored, green.
Not tried: the distiller itself, which isn't built yet.
2026-11-10 03:25:45 +08:00
yetone 2b2ee49ded gui: the Library's Memory tab
A tab after Instructions lists what the agents remember, in use, to
review (what an agent only guessed) and archived, pinned first then
newest; searches it, narrows it by where it applies, and adds, edits,
pins, keeps, archives and deletes memories (Delete asks with a second
click). Kind and scope are picked from the app's menu, never a <select>.
A card on top switches the digest in the ticked agents' instructions on
or off and names those agents, and offers Magpie Memory while it isn't
in the Library.

/api/memory (GET; POST saves the user's own or edits by id),
/api/memory/remove and /api/memory/digest; a change publishes the digest
at once and its reply carries `problem` when that failed.

Words other code also says (Archived, Pin, Keep, the kinds…) are in core
i18n.js; the rest in the library plugin's, in zh, zh-TW, ja and de.
docs/subsystems/memory.md describes the layer.

Run (mote-run):
- node --test internal/gui/tests/library-memory.test.cjs, Chromium and
  WebKit, 5 languages, 980 and 420 wide: ok
- whole GUI suite: not run at this commit; it is queued on mote for the stack head (034f249af before the rebase)
- go vet ./internal/gui, GOOS darwin, linux, windows: ok
Broken by hand: the pinned sort read `b.pinned - a.pinned` (NaN for an
unpinned one) and the test was red in every language until `!!`.
Looked at: screenshots en light 980, zh dark 980, en 420.
2026-11-10 03:25:44 +08:00
yetone a28744c325 gateway: memory is an MCP server every agent can mount
memory_search, memory_save and memory_forget at /mcp/magpie/memory,
served and guarded as the search server is (serveMCP): another computer
reaches it only while magpie is shared, with a gateway key. A save
through it is active at once, origin agent, kept everywhere, for the
project (the git repository the agent works in, by its remote) or for
the agent alone; without a folder or a client name it says it can't
know rather than guess.

- The Library's market offers it as magpie-memory, run as
  `magpie mcp memory` (browsermcp.RunMemory): stdio relayed to the
  gateway with the folder it was started in (X-Magpie-Cwd) and the
  client name from initialize (X-Magpie-Mcp-Client).
- Behind the MCP router the hub keeps it on this computer (hereOnly)
  and passes the caller's roots and client in _meta (wantsCaller), as
  it does for magpie's own server.
- OwnMCPPath lists it among magpie's own servers.
- Judged as its sibling servers are: a gateway key's MaxConcurrency
  doesn't hold it (a tool call of a turn already held), and a read-only
  key is refused (memory_save writes). The first full gateway run was
  red on TestKeySlotEveryRoute and TestReadOnlyKeyEveryRoute until the
  route was listed.

Run (mote-run):
- go test -tags nogui ./internal/gateway: ok (881.5s)
- go test ./internal/browsermcp ./internal/cli ./internal/memory: ok
- go test ./internal/library: ok (130.9s)
- go vet, GOOS darwin, linux, windows: ok; gofmt -l clean
Broken by hand, each red, then green restored:
- the hub not sending memory its caller (wantsCaller without isMemory):
  TestHubTellsMagpieMemoryItsCaller "roots asked false"
- the relay not setting X-Magpie-Cwd: TestMemoryBridgeSendsFolderAndClient
- the gateway ignoring X-Magpie-Cwd: TestMemoryMCPSharedAcrossAgents
  (a project fact kept everywhere)
Not tried: a real Claude Code or Codex mounting magpie-memory.
2026-11-10 03:25:44 +08:00
yetone 79decfe71a library: the agents ticked for instructions are given memory's digest
The agents ticked under Library → Instructions get a "## Memory" part in
their instructions: the global memories, the agent's own, and each
project's under the folders it was seen in (memory.Digest), unless
Instructions.NoMemory. The digest changes only when published, so an
agent's instructions (and the prompt cache on them) change mid-session
only then: at once when the user changes memory (PublishMemory(false),
called by the GUI), and once a day from KeepLinked's loop for what
agents saved meanwhile (PublishMemory(true) -> memory.PublishDue).
PublishDue writes nothing while memory has never held anything, so a
user who never uses memory gets no memory.json.

Run (mote-run, whole worktree, with the rest of the memory layer):
- go test ./internal/memory ./internal/library: ok (library 130.9s)
- go vet ./internal/memory ./internal/library ./internal/gui, GOOS
  darwin, linux, windows: ok
- gofmt -l: clean
Broken by hand (mote-run -run TestMemoryDigestInInstructions):
- memoryDigest's NoMemory check removed: red. It first stayed green,
  since the test switched NoMemory on with memory.json deleted; the test
  now gives memory back and sees the part return before switching it off.
- PublishDue's "nothing kept" guard removed: red ("a due publish with
  nothing kept wrote memory.json").
Not tried: a real agent reading the digest in its instructions.
2026-11-10 03:25:44 +08:00
yetone 4f0c587306 memory: a store of what agents learn about the user, shared by every agent
The first part of the memory layer: internal/memory keeps memories in
memory.json (lastgood + atomic writes under a file lock; a file that can't
be read is unknown and never written over). Each memory has a scope
(global, project:<git remote key>, agent:<id>), a kind (profile,
preference, rule, reference, fact, procedure, episode), free tags, an
origin and a status. Saving the same text in the same scope merges into
the memory already there; an agent's save never changes the kind or why
of a memory the user wrote or pinned.

A project is keyed by its origin remote, so every clone and worktree of a
repository shares its memories. Search is word-matched with CJK split
into characters and pairs. The digest agents will be given is published
on demand (a user's change, or once a day), never at an agent's save, so
instructions don't change mid-session; its text names no app or vendor.

Nothing uses the package yet: the MCP server, the Library's digest and
the GUI come next.

Run (on mote): go test -tags nogui ./internal/memory, -race -count=3,
TZ=Asia/Shanghai; go vet for darwin, linux, windows; gofmt -l clean.
Broken by hand: an agent's save allowed to change a user's memory
(TestUsersMemoryNotChangedByAnAgentsSave red) and a digest computed live
instead of published (TestDigestChangesOnlyWhenPublished red).
2026-11-10 03:25:44 +08:00
yetone e369d587c3 dsh: a round hashes dsh's files through a buffer, not read whole
dshFilesSum, which says whether anything a dsh round reads changed, read
every profile's patch list, the home layer, settings, .env, keys and old
config into memory with os.ReadFile only to hash them. Both dsh homes do
a round every 30s at rest, and a patch list names every model magpie
serves (39KB each in the real account here, two profiles), so each round
allocated each file's size again. Now each file is streamed into the
maphash through a pooled 32KB buffer (dshSumFile); the sum is the same as
for the bytes written at once, so a round after the update still matches
the one before.

Measured on mote with a copy of the real accounts (acidle.sh, alloc
between 60s and 180s at rest, the heap dump's own allocations left out):
- t18 (c02a491e8): 9.4MB, of it dshFilesSum 2.1MB
- t19 (this): 7.7MB, dshFilesSum gone from the profile

Test: TestDshFilesSumReadsNoFileWhole (the sum equals the one for files
read whole, a change at the end of a 1.1MB list moves it, and a sum
allocates under 64KB). Broken by hand: with os.ReadFile back it is red,
1149490 bytes a sum for a 1140000-byte list.

Run on mote at this tree (rebased on c02a491e8): go vet ./internal/agent,
gofmt -l clean, go test -timeout 45m ./internal/agent ok (246s).
Not tried: Windows and Linux (os.Open/Read only, no OS-specific code).
2026-11-10 03:20:04 +08:00