3cfbc19b05270cd569f86ee6ca4d4ea3408d5ea2
7173
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
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 |
||
|
|
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.
|
||
|
|
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 (
|
||
|
|
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.
|
||
|
|
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
|
||
|
|
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. |
||
|
|
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). |
||
|
|
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. |
||
|
|
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. |
||
|
|
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 |
||
|
|
da8480326f |
agent: detection's remaining stats make no os.FileInfo on darwin and linux
After statKind ( |
||
|
|
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). |
||
|
|
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). |
||
|
|
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. |
||
|
|
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. |
||
|
|
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
|
||
|
|
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. |
||
|
|
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
|
||
|
|
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. |
||
|
|
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). |
||
|
|
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). |
||
|
|
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 |
||
|
|
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
|
||
|
|
4894332d79 |
gui: the core scripts back under their budget after b3a57b3d8
|
||
|
|
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
|
||
|
|
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. |
||
|
|
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 |
||
|
|
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 ( |
||
|
|
547585cd9c |
gateway: memory answers the agents on this computer alone
/mcp/magpie/memory ( |
||
|
|
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.
|
||
|
|
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.
|
||
|
|
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. |
||
|
|
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. |
||
|
|
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. |
||
|
|
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
|
||
|
|
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. |
||
|
|
eebb878977 |
cli: TestGroupSetID expects a renamed group's old id to find it
|
||
|
|
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.
|
||
|
|
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. |
||
|
|
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). |
||
|
|
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). |
||
|
|
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). |
||
|
|
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.
|
||
|
|
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. |
||
|
|
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. |
||
|
|
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. |
||
|
|
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. |
||
|
|
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.
|
||
|
|
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). |
||
|
|
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 ( |