efbacd4e54798ef50e73c5b79f2dcdc8f812096c
3332
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
efbacd4e54 |
gui tests: session-terminal clicks Theme only once the Ghostty save has drawn the page again
The Theme click resolved its button before the Ghostty save came back.
When the save then redrew Settings, the click landed on the button from
before, whose handler still holds the page as it was drawn
(sessionTerminal ""). Against the new prefsBase that "" reads as a change,
so the theme save sent the terminal back to System default, and line 119
saw "". It failed 1 to 2 runs in 5 when 5 ran in parallel, on origin/main
|
||
|
|
82f3befd29 |
daemon: magpie daemon install --web serves the browser page from the service, with a link that lasts (HuanCheng Bai)
HuanCheng Bai on Discord runs `magpie daemon` on a Linux server and asked
for the daemon to serve the web page too, or for an option to turn it on.
`magpie web` run beside it is a second process, and he read it as not
seeing the daemon's state.
- `magpie serve --web[=host:port]` serves the gateway and `magpie web`'s
page from one process (stats, StartWeb, Wait). The default page address
is 127.0.0.1:3430. Any other argument is refused, where before it was
ignored.
- `magpie daemon install --web | --lan | --addr host:port | --no-web` and
`magpie daemon web [on|off] [--lan] [--addr host:port]`. The unit's
ExecStart and the plist's ProgramArguments become `serve --web=<addr>`,
and the key goes into the 0600 file's environment as MAGPIE_WEB_KEY. The
key is made once. A reinstall with no flags keeps the page and its key
(read back from the file by daemon.Web), so the link survives restarts
and reinstalls. `web off` drops it. MAGPIE_WEB_KEY in the shell, when
set, is used and checked like magpie web's. The page defaults to
loopback; --lan or a non-loopback --addr prints the network links and
magpie web --lan's warning.
- `magpie daemon status`, install and `daemon web` print the page's link.
- `magpie web` while the service serves a page prints that page's link and
exits. Beside a gateway another magpie serves, it says so and points to
`magpie daemon web on`.
- docs/reference.md (the service section and the Use list), and the
site's start page (en, zh, ja). The READMEs don't cover the daemon.
Run:
- Tests: TestInstallWithWeb (systemd and launchd, plutil lint, read back,
reinstall without the page, the shell's key not carried, no key
refused), TestWebNotInstalled, TestParseDaemon, TestWebOptions,
TestDaemonStatusPrintsPage and TestServeArgs. Each of these went red
with its line reverted by hand: withKey, prevKey in webOptions, and the
status page line.
- Sandbox HOME with a fake launchctl:
- `daemon install --web --lan` wrote a 0600 plist with
`serve --web=0.0.0.0:3430` and the key. plutil said OK, and it printed
the link, the network links and the warning.
- Reinstalling with no flags kept the key. `daemon status` showed the
link.
- `daemon web off` / `daemon web` / `daemon web on` behaved as above,
with a new key after off.
- `daemon web bogus` and `serve --lan` gave the usage errors.
- `serve --web=127.0.0.1:3462` served the gateway (3461) and the page in
one process. The page answered 200 with the key and 401 without, and the
page and /v1/models both showed 3 models. `magpie web --no-open` beside
it printed the service's link and exited 0.
- gofmt -l; go vet (gui), and go vet -tags nogui for darwin, linux and
windows; go test -tags nogui ./... in a sandbox HOME.
Not tried: a real systemd on Linux. The unit text is checked by test only.
|
||
|
|
a39e675d2a |
gui: magpie web beside a busy gateway waits for the port instead of failing to bind it (K.Liu)
K.Liu on Discord: `magpie web` next to the systemd `magpie daemon` logged
"gateway: listen tcp 0.0.0.0:3425: bind: address already in use".
Cause: before listening, serveGatewayLocked asks the gateway's address
whether a magpie serves it (ServedBy, one GET with a 700ms timeout). A
magpie that holds the port but doesn't answer in time (busy on a small
server, or still starting) reads as "nobody", so the page's process
listened itself and the bind failed. With the service answering, no
second gateway was started and the page's state matched.
Now, after ServedBy says no, gateway.Taken() dials the address (500ms).
When something accepts, this magpie doesn't listen; it logs once that the
port is taken and leaves it to the 15s watch, which serves the gateway
once the port is free.
Run:
- Sandbox HOME, settings {"port":3461,"lan":true}: `magpie serve`, then
`kill -STOP` it, then `magpie web --no-open --addr 127.0.0.1:3462`. The
old binary printed the exact bind error. The new one logs "is taken but
doesn't answer as magpie yet" and doesn't bind. After SIGCONT,
/v1/models and the page's /api/state show the same 3 models. With the
serve killed, the page's process took 3461 over in about 16s.
- TestGatewayNotServedBesideASlowOne (a listener whose handler blocks):
it goes red with the Taken check reverted by hand.
- gofmt -l; go vet (gui), and go vet -tags nogui for darwin, linux and
windows, on cli, daemon, gui and gateway; go test -tags nogui ./... in a
sandbox HOME.
|
||
|
|
2d8f2a86a5 |
sessions: Kimi Code sessions open as a transcript (#2056)
infinitr0us: a Kimi Code session on the Sessions page had no transcript
to open. HasTranscript now lists kimi, and kimiTranscript reads the
session's main wire.jsonl:
- protocol 1.4/1.5: turn.prompt and turn.steer (a prompt not from the
user, a skill's activation or a background task's news, is folded as
context), and the loop events content.part (text, think), tool.call
and tool.result, a result named for its call. These are there for
every session, finished or running; agent.message.appended (1.5, only
at a turn's end) and the timed context.append_message records say the
same again and are passed over.
- kimi-cli imports (1.0, and the head of a ses_* session Kimi Code
reopened): the untimed context.append_message records, with an
assistant's toolCalls in both shapes (name/arguments and OpenAI's
function.{name,arguments}).
Search and markdown export read the same parts.
Run:
- TestKimiCodeTranscript on the #1607 reporter's wire files in testdata
(1.4, a cancelled 1.4, an early 1.5 started by a skill, a failed 1.5,
a kimi-cli import), and TestKimiCodeTranscriptOrder on a synthetic
file in the same record shapes, exact part order plus SearchSession.
- Broken by hand: kimi out of HasTranscript fails both tests; reading
the timed context.append_message records fails both (user/text 9,
not 3).
- A nogui build's `magpie web` under a sandbox HOME, KIMI_CODE_HOME on
the reporter's whole zip (8 sessions, the July subagent session and
a reopened ses_* among them): all 8 listed with a transcript;
/api/sessions/transcript gave 105, 13 and 205 parts for June, the
reopened ses_* and July; the markdown export worked.
- gofmt -l clean; go vet darwin, linux -tags nogui, windows;
go test -tags nogui ./internal/sessions/ ./internal/gui/.
Not tried: a live Kimi Code session on this machine (none here; the kimi
installed is kimi-cli 1.52.0), the GUI's look of the transcript, WSL.
A subagent's own wire file isn't shown; the main agent's is.
|
||
|
|
75cbc7e1e5 |
provider: a subscription switched off or removed makes no background requests, no claude auth status every minute (Riko on Discord)
Riko switched Claude off in Providers, and magpie still ran `claude auth status --json` about every minute. Off only kept the gateway from routing to it. Every page and request lists accounts, which re-asked the CLI, and the background loops went on reading allowances, renewing, switching, warming, checking in and fetching lists. The same held for each sibling with a CLI or account check: Cursor (`cursor-agent about`), Devin (`devin auth status`) and the rest. What changed: - left_alone.go: leftAlone(id), true for a provider that is Off or Hidden (account removed). - account.go claudeIdentity and cli_identity.go get (Cursor, Devin): the CLI isn't asked; what it said last (memory or cli-identity.json) is served, so the account stays listed to switch on again. - subscription_usage.go: claude, cursor and grok are checked as hidden before their account is looked up (the look-up ran the CLI). - login_usage.go loginUsageAt, keepalive.go RenewLogins, codex_switch.go NextLogin, codex_warmup.go keepWarm: leftAlone where only accountRemoved (or nothing) was checked. - models.go newDue: a provider that is off has no list fetched. - checkin.go: each check-in account knows its card's provider; the loop skips one that is left alone, a press still checks it in (minimax, trae, qoder, workbuddy, plugin check-ins set it). - docs/subsystems/providers-accounts.md says so. Not covered: KeepPluginsListed lists every plugin at once in the host. A Cursor switched off that was never asked who is signed in isn't listed until switched on. What was run: - TestLeftAloneRunsNoCLI: fake claude, cursor-agent and devin on PATH log each run; with claude and cursor off and devin removed, All, Hidden, fetchSubscriptionUsage, LoginUsage, RenewLogins, SwitchWhenSpent and FetchNew run three times over stale caches and no CLI is run; switched back on, all three are asked again. - Break check: with the source changes reverted it fails with "switched off or removed, the CLIs were run: [claude_auth_status_--json cursor-agent_about_--format_json devin_auth_status ...]"; with only the claude gate removed only claude is logged, with only cliIdentity's only cursor and devin. - go test -tags nogui -timeout 45m ./internal/provider ./internal/gateway: ok (399s, 1271s). - gofmt -l: clean. go vet (darwin), GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...: clean, under set -o pipefail. |
||
|
|
195a1009b0 |
gui: a routing group's Slow to start takes minutes of your own, beside Wait, 30 s, 1 min and 2 min (Kismet Alan on Discord)
The group editor's "Slow to start" (迟迟不出字) row offered only Wait,
30 s, 1 min and 2 min. Kismet Alan wanted a longer time of their own.
What changed:
- routing.js: the row gets a Custom segment, the same pattern as the
Context row's Custom: picking it shows a small minutes box beside the
segments (5 from Wait, else what was picked), focused to type in.
Decimals are taken (2.5 is 150 s; a comma is read as a point). Anything
else marks the box aria-invalid and the hint says "{v} is not a number
of minutes"; the last good value is kept. A saved time that is none of
the presets opens as Custom with its minutes. firstToken is still sent
in seconds, and the card's "Next after 150 s without a first token"
and the gateway are unchanged (provider.Group.FirstToken takes any
seconds >= 0).
- routing.css: the box and its "min" unit inside the existing ctx-wrap.
- i18n.js: Custom was already there; "e.g. 5", "Minutes", "min" and the
error in zh, zh-TW, ja and de.
- group-first-token.test.cjs: now five languages (en, zh, zh-TW, ja, de)
at 1100 and 420 wide in Chromium and WebKit. It adds the Custom flow:
no box until Custom, 5 to start and focused, "abc" refused with the
hint naming it, 2.5 saved as 150 and shown on the card, reopened as
Custom 2.5, back to 1 min hides the box, and the row stays inside the
editor with no horizontal scroll. At 420 the editor runs past the
window's foot and WebKit doesn't scroll the page's scroller to a
click, so the test wheels each control into view.
What was run:
- NODE_PATH=<playwright@1.62.0> node --test group-first-token.test.cjs:
20 of 20 pass (2 engines x 5 languages x 2 widths).
- Break check: with routing.js at the old code the test fails waiting
for the Custom segment.
|
||
|
|
c9af654b26 |
gateway: Kimi Code takes a Claude Code session that loaded a deferred tool, and DeepSeek one that dropped a tool (#2042, davisjiahao)
Claude Code's deferred tools (ToolSearch, MCP tools that come and go) put blocks of their own in a message: tool_addition (its tool a tool_reference naming the tool, or a tool_definition), tool_removal, and tool_reference. magpie relays an Anthropic body as it is, so they reached vendors' Anthropic endpoints. Checked against the real endpoints on 2026-10-14 (a Kimi Code CN key, a DeepSeek key; shapes read from Claude Code 2.1.296's own builder): - Kimi Code refuses any of them, in any role and either tool shape, with a whole-request 400 "Invalid request Error" that names nothing; a tool_reference inside a tool_result passes. - DeepSeek takes a tool_addition naming a tool, but refuses one defining it, a tool_removal and a message's tool_reference: 422 "messages[1]. content: unknown variant `tool_removal`, expected one of ...". What changed: - withoutDeferredTools (anthropic_shapes.go) drops those message blocks and a message they leave empty. The tools stay in the request's tools, and ToolSearch's answer (a tool_reference inside a tool_result) stays. - Kimi (isKimi) is never sent them: its 400 says nothing to learn from. - Any provider that refuses one in DeepSeek's words is marked (shapeDeferred, refuseShapes) and asked again at once without them, and not sent them again while magpie runs. The shape-retry loop in forward now reads a 422 as well as a 400 (refuseShapes and refuseBetas only act on wording they recognise). - Anthropic and every provider that takes them get them as Claude Code wrote them. Kimi's bare "Invalid request Error" is not added to shapeWords: it names no field, and with the blocks gone there is nothing left for it to cover. - docs/subsystems/gateway-routing.md: a paragraph on the above. Builds on lu123bing's fork branch (c4a0564), widened from Kimi to the learned refusal after the DeepSeek check; this keeps a tool_addition naming a tool for providers that take it. Run: - TestKimiIsSentNoDeferredToolBlocks (the reporter's literal body plus Claude Code's real shapes, through Handler) and TestDeferredToolBlocksRefusedOnceLeftOut (DeepSeek's literal 422, learned once; a provider that takes them keeps getting them). - Break checks, each red: without the Kimi drop, 5 subtests "status 400: Kimi Code: Invalid request Error"; with the loop on 400 only, and without the mark, "status 422: DeepSeek: ... unknown variant `tool_removal`". Restored: green. - Real use: a nogui build served from a sandbox HOME on 127.0.0.1:35211 with copies of the Kimi Code CN and DeepSeek providers. The reporter's body to kimi-for-coding now reaches Kimi's account check (403, the test key's plan has lapsed) instead of the 400; a tool_removal to DeepSeek reaches its balance check (402) instead of the 422. A full successful Kimi turn wasn't possible on this key. - gofmt -l clean; go vet, GOOS=linux go vet -tags nogui, GOOS=windows go vet on internal/gateway; go test -tags nogui ./internal/gateway/ in a sandbox HOME: ok (1516s). An earlier run of the same suite, with five other gateway.test binaries running on the machine, ended FAIL after 1484s; its output was cut to the last 30 lines, which held no test name, so the failing test is not known. Co-authored-by: lu123bing <12312702@mail.sustech.edu.cn> |
||
|
|
8f03b78069 |
cli, gateway: magpie statusline prints the session's model and each account's windows for Claude Code's status line (#1997, kensenzhao)
kensenzhao asked for magpie's routing and quota in Claude Code's status
line. Claude Code runs the statusLine command on every update and cancels
the run that is still going, so the command must answer fast. It must never
make a vendor read.
- `magpie statusline [<provider|account>]` reads Claude Code's statusLine
JSON from stdin. It prints "→ <served model>" from
/v1/magpie/route?session=<session_id>, then each subscription account's
windows ("claude a@x* 5h 62% 7d 41%"). `*` marks the account that served
last. A window whose reset has passed shows 0%. With the gateway off it
prints an empty line. Each request times out after 1s.
- /v1/magpie/quotas?kept=1 (provider.KeptQuotaReport) builds the same
report from the kept cards (CachedCards) and never starts a vendor read.
The plain endpoint can take up to 12s.
- magpie never writes statusLine into Claude Code's settings. The user
adds `"statusLine": {"type": "command", "command": "magpie statusline"}`
themselves (magpie statusline's help, docs/reference.md).
Run: go test -tags nogui ./internal/cli ./internal/provider
./internal/gateway in a sandbox HOME; gofmt -l; go vet natively and with
GOOS=linux and GOOS=windows.
Broken by hand, each went red:
- the CLI asking without kept=1 (TestStatuslineTellsRouteAndEveryAccount);
- dropping the route line (same test);
- KeptQuotaReport calling QuotaReport (TestKeptQuotaReportAsksNobody).
Real use: a built binary against a sandbox gateway on 127.0.0.1:3517.
- kept=1 answered in 0.07s and route in under 1ms.
- `magpie statusline` with Claude-style stdin printed an empty line, since
the sandbox has no accounts.
- Its ~1.1s wall time matches `magpie version`, so that is process start.
Not tried: real accounts, or the line inside a real Claude Code statusLine.
|
||
|
|
a5d72a095b |
gateway, gui, cli: a search API's keys take turns, a refused one rests, and each Tavily key shows what it has used (SlouchyQuill)
SlouchyQuill on Discord asked for a Tavily key pool after dsh-tavily-pool: several keys, each key's quota shown, keys rotated. Before this, the comma-separated keys (#1477) always started from the key that last answered, so one key took every search until it was refused, a refused key kept no rest of its own, and nothing showed what a key had left. What changed: - Turns (internal/gateway/search_keys.go). Searches take turns over the keys by default (round robin, a counter per vendor). pick=order (CLI) or In order (Settings) always starts from the first key; the pick is saved in SearchAPI.Pick. - Rests. A refused key rests: 401/403 for 10m ("turned away"), 402 for 1h ("out of credit"), 429 for its Retry-After held to 30s-10m (1m without one). 432/433 count as out of credit from Tavily only; from any other vendor they rest as a rate limit. A resting key is asked after the others, soonest back first, so failover is kept, and it wakes when it answers. Rests are keyed by a hash of the key. - Quota (internal/gateway/search_quota.go). Each Tavily key's quota is read from GET /usage with that key. The fixture is the documented reply from docs.tavily.com. The key's own limit is used when it has one; otherwise its plan's plan_limit/plan_usage, which the account's keys share. A failed read, or a reply missing those fields, says unknown and why, never 0. A read is kept 2m unless asked fresh. A key found used up with no pay-as-you-go credit rests 1h; a later read with credit wakes it. - Keys never appear in full. The vendor's error has the key masked (tvly-…abcd), and errors name "key N (tvly-…abcd)". - GUI. Settings › Models › Web search adds a "Keys of <API>" row under an API with several keys or with Tavily's: In turn / In order, each key masked with what it has used and why it is asked last, and Check again. There is an API for it (POST /api/settings/search-quota), and 13 strings in zh, zh-TW, ja and de. - CLI. `magpie search` lists the pick and each Tavily key's quota, read fresh; `magpie search add … pick=turns|order`. - Docs. gateway-routing.md has a new section "A search API's keys"; both READMEs have a line on web search. What was run: - go test -tags nogui ./internal/gateway ./internal/provider ./internal/cli ./internal/gui: ok. After the last rebase, provider and cli again, and gateway -race -run Search. - New tests: TestReadTavilyUsage, TestSearchKeysTakeTurnsRoundRobin, TestSearchKeyRefusedRests, TestSearchRestFor, TestSearchQuotas and TestSearchKeyNeverInFull. Each guarantee was broken by hand and its tests went red: - turns pinned to the first key: RoundRobin and RefusedRests; - rests ignored: TestSearchAPIKeysTakeTurns, RefusedRests and TestSearchQuotas; - key masking removed: NeverInFull; - a failed read reported as known: TestSearchQuotas. - gofmt -l; go vet -tags nogui for darwin, linux and windows on the four packages. - GUI: search-keys.test.cjs covers en, zh, zh-TW, ja and de × Chromium and WebKit × 1100 and 420px: 20/20. Without the new .search-keys .val wrap rule, de at 420px fails ("Erneut prüfen" went past the window's edge). - search-api, search-first, search-instead, search-mcp, searcher-pick, settings-search, provider-search, gui-de, gui-ja and i18n-keys: 56/56 in each engine. - Full suite in Chromium (concurrency 6, load ~40): 4498/4504. The files that failed (gateway-key-groups, rest-try-now, routing-wb-restricted, text-size, usage-sum-whole) were rerun alone. All pass except usage-sum-whole, which fails now and then on an origin/main worktree too under the same load (#1864, #2023; rest-try-now and routing-wb-restricted are #1905). None of them touch search. - Real Tavily API with two invalid keys: /search returns 401 {"detail":{"error":"Unauthorized: missing or invalid API key."}}, which counts as a refusal. Both keys rest 10m as turned away, the error names them only masked, and both quotas read "unknown · 401". Checked through a test and through the nogui CLI binary in a sandbox HOME. Not tried: a valid key's /usage against the real API. No Tavily key was at hand, so the quota parsing is checked against the documented bytes only. |
||
|
|
1555cddfa0 |
agent: with Claude Desktop on magpie, Claude Code runs each model at its own window, not the least of them all (#2025, 6.1sol)
Claude Desktop's Code tab runs Claude Code on ~/.claude/settings.json with every model Desktop lists. Claude Code takes one window (CLAUDE_CODE_MAX_CONTEXT_TOKENS) for every model it doesn't know, and magpie told it the least of Desktop's (#1458), so one small model held a 500K or 1M one to its 131K. Now, while Desktop is on magpie, magpie tells Claude Code the largest window of Desktop's models and of Claude Code's own main and tier models, and holds each model below it to its own with modelSettings.<id>.autoCompactWindow (claudePlan, claude_budget.go). CLAUDE_CODE_AUTO_COMPACT_WINDOW would take precedence over those, so in this mode magpie's working window goes in the top-level autoCompactWindow instead, and an entry is written only where a model's window or threshold differs from what it would run at without one. Claude models (and groups of them) are left out as before. magpie's entries and top-level value are stashed and go when Desktop leaves magpie. The user's own entries, top-level value and variables are never written over: an entry of theirs past its model's window (or "auto") holds the largest to that window, and with a CLAUDE_CODE_AUTO_COMPACT_WINDOW of theirs the least window is told as before. Desktop off is unchanged. Verified with real Claude Code 2.1.296 in a sandbox CLAUDE_CONFIG_DIR, on a settings.json written through magpie's editor: /context shows 256k for mythos-magpie-2's entry, 131k for magpie/v/gpt-6.1-sol (dotted key, with and without [1m]), and the top-level 272k for a model without an entry, under a 1M MAX_CONTEXT_TOKENS. Tests: TestClaudePlan and TestBudgetPath (new), and TestClaudeDesktopContextWindow / TestClaudeDesktopAloneContextWindow rewritten (largest window, per-model entries, Full window, the user's entry and top-level kept, Desktop off removing only magpie's). They fail on the old claude.go (256000 told), and with the skip of the user's entries removed from claudePlan. Run: go test ./internal/agent (full), gofmt -l, go vet for darwin, GOOS=linux -tags nogui and GOOS=windows. |
||
|
|
8a4cfe0e4e |
proc: a command that isn't installed is answered from each PATH folder's listing, not a stat per extension, so a Library change after a start no longer looks for ~100 agents' commands one file at a time on Windows (#1624, Hipple)
On every Library create, switch or delete, Targets() asks agent.Detected for about a hundred agents. Each one's command is looked up with exec.LookPath, and on Windows with FindTool's findDirs as well. A command that isn't installed costs a stat of name+each PATHEXT extension in every folder. The answers are cached (looked), but that cache is empty after a start and is dropped whenever any PATH folder's mtime changes. With an antivirus slowing every stat, that is the slow first change Hipple sees. Each folder's listing is now read once (lower-cased names, also each name up to every dot) and read again only when the folder's mtime changes. A command that no folder has a name for is not found without a stat. One a folder may hold, and any folder that can't be read, goes to exec.LookPath and toolIn as before. On Windows the current folder is included unless NoDefaultCurrentDirectoryInExePath is set, as exec.LookPath does. Measured on the Windows test box (47 PATH folders, WSL agents off, library ops through a throwaway test in a sandbox HOME): - the first create after a start went from 486ms to 285ms; the old CPU profile was mostly exec.LookPath/GetFileAttributesEx; - warm ops ~10ms either way. With WSL agents on, the first op costs ~3.0s on both builds, about 2.7s of it in wsl.exe list and probe spawns. This commit doesn't change that. On the box, wsl -l -q, wsl -l --running -q and a docker-desktop probe each take 40-75ms, so a failed-probe retry every 10 min doesn't explain the report there. The 5-8s after 10 min idle wasn't reproduced: ops after 4, 8 and 12 min idle took ~120ms. Run: go test ./internal/proc ./internal/agent ./internal/library (ok); gofmt -l; GOOS=linux and GOOS=windows go vet on the three packages. I broke the fix by hand (look.go/find.go back to exec.LookPath, mayBeIn check off), and TestMissingCommandsReadEachFolderOnce failed: "100 missing commands were looked for on PATH 200 times, want 0". |
||
|
|
f71155591e |
provider: a provider at a vendor's own endpoint is priced from that endpoint's models.dev catalog (#2052, mengyianx)
A custom provider added by its address alone, with no catalog named, was priced only by the model's maker. Qwen3.8-27B, whose maker (Alibaba) sells no such model on any of its seven models.dev catalogs, read "no price is known for it" even at AMD's own endpoint, where models.dev's amd lists it at $0, a price. - catalog: models.dev's provider "api" is read; AtEndpoint names the catalogs at a base URL (trailing slash and case ignored). - provider: EndpointCatalog is the one catalog models.dev lists at one of a key's provider's endpoints (an Anthropic base, kept as its root, also with /v1), used by ListPrice when the provider has no catalog of its own. Never for a subscription's account, never when two catalogs share the address (minimax / minimax-coding-plan), never a plan's catalog (an id with -plan, or membershipCatalogs), whose $0 is the membership's. A user's price and a named catalog still come first; a relay's endpoint matches nothing and its model stays unpriced (no reseller guess). - cli: `magpie model price p/m` with no price gives the two commands that set one (p/m and */m); a price from an endpoint's catalog names it. - gui: the Catalog field's hint says it also sets list prices (en, zh, zh-TW, ja, de). - docs: reference.md's "What a model costs", providers-accounts.md row. What was run: - Reporter's exact case, built binary (go build -tags nogui), sandbox HOME with a copy of this machine's models.dev cache (2026-10-14, same amd entry as the report), providers 001 (relay), 002 and amd at https://developer.amd.com.cn/radeon/api/v1: 001/gpt-5.5 $5/$30, tiers, as before 001/Qwen3.8-27B no price, now with the two commands to set one 002/Qwen3.8-27B $0/$0, "what models.dev's amd lists at its endpoint" amd/Qwen3.8-27B $0/$0 The two suggested commands were run and took effect. - TestEndpointCatalogPrices / TestEndpointCatalogOnlyItsOwn, fixture testdata/endpoint_catalog.json trimmed from the real models.dev cache. Break checks, each FAILs with the case named: ListPrice not using EndpointCatalog -> 002/amd/001 at AMD unpriced, EffectivePrice(002, Qwen3.8-27B) unpriced plan exclusion removed -> "a plan's endpoint: EndpointCatalog() = alibaba-coding-plan", qwen3.5-plus at $0 instead of $0.4/$2.4 single-match rule removed -> "an endpoint two catalogs share: EndpointCatalog() = minimax" Account check removed -> "a subscription's account ... = amd" Anthropic /v1 match removed -> thinkingmachines unmatched - GUI: internal/gui/tests/catalog-hint.test.cjs, chromium and webkit, en zh zh-TW ja de, widths 1100 and 420: 20/20 pass, plus i18n-keys; with the old app.js/i18n.js it fails "one hint names list prices". - go test -tags nogui -timeout 45m ./internal/catalog ./internal/provider ./internal/cli: ok (provider 244s, cli 125s, catalog 3s). gofmt -l clean; go vet (darwin), GOOS=linux go vet -tags nogui and GOOS=windows go vet -tags nogui on those packages: clean. |
||
|
|
8f34bbcd11 |
library: Grok Build and Grok App can be given hooks (#1790)
The Hooks tab said "Grok App has no hooks magpie can write" and RTK said
"No rtk hook". RTK stays correct for now (rtk init has no Grok agent), but
the hooks message was wrong: the Grok CLI keeps hooks as [[hooks.<Event>]]
array tables in its config.toml, which Grok App reads from agent-home on a
custom route. Hindsight already ships three hooks into both configs.
Add grok and grok-app to hookAgents with a TOML hook spec. A hook is written
as a [[hooks.<Event>]] table with a [[hooks.<Event>.hooks]] child, the same
find/claim/drop logic as a JSON agent's: the block text is recorded entry by
entry, so only a block still exactly as magpie wrote it is ever taken out,
and the user's own blocks around it stay as they are. Portable events map to
Stop / PostToolUse / PreToolUse / UserPromptSubmit / SessionStart; a tool
matcher uses Grok's own tool names (run_terminal_command, search_replace).
Grok Build and Grok App run the one CLI, so a grok:<Event> own event goes to
both (sameHookFamily).
edit gains WriteTOMLFile and SplitLines so the library can round-trip a
config's lines through the same validating write the other TOML editors use.
Verification (branch grokapp-hooks):
- TestHooksGrokConfigTables fails on the pre-change code with a real FAIL
("Grok Build has no hooks magpie can write"); passes with the change.
Broke the matcher map, the drop and the event map by hand; each break is
caught by the test.
- go test ./internal/library ./internal/edit: 811 passed (was 828 before the
two new grok cases and the hookAgents additions).
- gofmt -l clean; go vet on mac, GOOS=linux -tags nogui, and GOOS=windows all
clean; go build, GOOS=linux go build -tags nogui and GOOS=windows go build
all succeed.
- go test -tags nogui ./... has three pre-existing failures on base
|
||
|
|
c1e354245d |
agent, gui: connecting an agent whose model list holds none of magpie's models says so, in the reader's language (#1989, znuaibot)
znuaibot's case: OpenCode shown only its one picked model, whose provider was switched off. connect() found no field to set, and since the catalog still held models (shown 0, hidden 7) it said only "OpenCode can't be connected to magpie", which sent the user looking at the agent rather than at the model list that emptied it. znuaibot's patch (74160e1f) told the case apart in connect(). Changed on review: the plain English error would have reached the GUI untranslated (NoModelsError beside it is said by code), so the case is a typed AllHiddenError, fail() answers it with code all_hidden, and the GUI says it in en/zh/zh-TW/ja/de, pointing at the agent's Model list → Pick (the names the Agents page uses). Run: TestConnectWithEveryModelTakenOut (agent) reproduces the case with a provider switched off under OpenCode's picked list: on the old connect it FAILs with "OpenCode can't be connected to magpie"; passes now, and connects once the provider is on again. TestAgentConnectAllHidden (gui) checks the code. agent-connect-no-models.test.cjs now runs both codes in Chromium and WebKit, en/zh/ja/de: 16/16 pass, and with app.js's all_hidden line removed the 8 all_hidden cases FAIL. gui-de, gui-ja, gui-zh-tw, i18n-keys: pass. Full internal/agent and internal/gui: see the push record on #1989. |
||
|
|
c8392cf7d5 |
cli: a magpie model picked for an agent not connected connects it first (#1900)
GUI 的 Pick/ConnectHow 会先 connect()(把用户原有模型记进 stash),CLI 的 set 直接 Apply,绕过了 stash:magpie opencode a/m 接上后,magpie opencode default 无从恢复用户自己的 model/small_model。CLI set 改走 a.Pick——与 Agents 页选择器同一入口,未接线时先连接,已接线与空值行为不变。 对所有以此方式接线的 agent 一致生效(issue 要求的不只 OpenCode/DevEco)。 验证:新测试 TestAgentOpenCodeDefaultPutsBackTheModel——用户自有模型 + small_model + theme,CLI 接线再 default,旧代码 model 丢失,修复后完整 还原;其相连的 claude/snow default 测试不回归。基线(无此改动)6 个 agent 包失败(Aside×4、版本检测×2)与改动无关,在干净 worktree 同样失败。 Rebased onto main's set (which now keeps `wired` for #2000's notice); the test now also runs DevEco Code, OpenCode's fork in its own folder, as the issue asked for both. Run: TestAgentOpenCodeDefaultPutsBackTheModel opencode+deveco pass; with set put back on a.Apply both subtests FAIL (model lost). Full internal/cli -count=1: ok. a.Pick is the GUI's picker path, so every agent the CLI sets a magpie model on is connected (and stashed) the way the Agents page connects it; a Native agent still goes to its Apply. Not changed here: profile.Apply also writes a field with a.Apply. |
||
|
|
7bdd3904cd |
tests: the cache-fields record test starts from a log of its own (#1897)
TestRecordAlwaysCarriesCacheTokens 无自己的 config 目录,-count>1(race job 的 -count=3 同样)第二次运行会读到上一次运行写的行,在行数断言失败。 给它自己的 XDG_CONFIG_HOME(包内兄弟测试同款),每次运行从空日志开始。 验证:-count=2 修复前 FAIL(lines 持 3+ 条),修复后 -count=3 与全包 -count=1 均通过。 Reviewed and run before landing: at origin/main the test alone with -count=2 FAILs; with the fix -count=3 ok. Siblings: the whole internal/usage package with -count=2, and with -count=2 -shuffle=1,2,3, all ok, so no other test in the package reads a log another run left. |
||
|
|
3857376a2f |
tests: the slow-read list's immediate re-ask is asked within its own retry window (#1889)
TestTaggedReposSlowRead 在负载下(load ~28)误报一次:晚到读取的轮询上限 10s 与 taggedRetry=1s 重叠,轮询加首次调用超过 retry 窗口后,被截断的列表 被(正确地)再问,测试把它当成 bug。按 LESSONS 注入 1.2s 延迟复现 ("asked again at once: 3"),随后修复并保持延迟下通过。 修法:把「不重问」断言放在它自己的 retry 窗口内——断言前将 taggedAt 移到 now,断言后(含 Fatal 分支)还原。窗口与轮询耗时不重叠,测试两边留余量 (code standards: a timing test leaves room on both sides)。「past taggedRetry」步骤仍用还原后的真实窗口,sleep 与断言语义不变。 验证:注入延迟下旧代码 FAIL(asked again at once: 3)、新代码 PASS; -count=3 通过;TestTaggedRepos 不受影响。 Changed on review: moving taggedAt to now made the step ask about a whole list (held ten minutes), so a cut-short list no longer held for taggedRetry passed the test. The step now marks the list cut short now, as TaggedRepos does, and the hold itself is checked right after the cut-short ask: held till between ask-start+taggedRetry and ask-end+taggedRetry, bounds from the clock with no slack to outgrow. Run: old test + 1.2s injected before the step: FAIL "asked again at once: 3"; new test + the same delay: ok. Hold broken by hand (-taggedTTL) and doubled (2*taggedRetry): both FAIL at the new bound. -count=5 TestTaggedRepos*: ok. Full internal/plugin (-tags nogui): ok, 649s under load. |
||
|
|
4fbb75c3a8 |
gateway: Codex's 507 "exceeded request buffer limit" is asked again and told as a 503, not relayed as it came (#2034, sparrowu93)
sparrowu93's pi, on a ChatGPT account, stopped on "Codex: 507 Insufficient Storage: exceeded request buffer limit while retrying upstream". That text is Envoy's (ChatGPT's front): its first try at the backend failed, and the body was more than it buffers to try again. It is the same backend failure as #1628's 503 "reset before headers", which magpie already asks again for without resting anybody, only for a body the front couldn't retry itself. magpie relayed the 507 as it came; pi's _isRetryableError (pi-coding-agent 0.73.0, agent-session.js) matches 503 but not 507 or these words, so the turn just ended. codexDropped now reads that 507 (by Envoy's words alone, any size, since the 507 itself says the body was large) the way it reads the large request's 503: the accounts loop asks the next account and the last one again, nobody rests, and the agent is told a 503 with Envoy's words and what may help (/compact, fewer or smaller images). The relayed path (codexUpstreamOn, Codex's own sign-in) asks again the same way: the two share edgeMayDrop/edgeSaidDrop. A 507 in other words is relayed as it came. gateway-routing.md says so. Run: - New TestCodexUnbufferedAskedAgain, TestCodexUnbufferedTold503, TestCodexUnbufferedRelayed, TestCodexOther507Stays, with the reporter's literal Envoy text as the fixture. On the old code the first three fail: "status 507, want 200 pong: {...\"message\":\"Codex: 507 Insufficient Storage: exceeded request buffer limit while retrying upstream\"...}" (the reporter's message byte for byte), and "507 once: 507 ... tried [acct-1]". With edgeSaidDrop matching every 507, TestCodexOther507Stays fails. Restored, all pass, with #1628's TestCodexReset* tests. - go test -tags nogui ./internal/gateway/ (sandbox HOME, pinned caches), gofmt -l, go vet, GOOS=linux go vet -tags nogui, GOOS=windows go vet (with and without nogui) on internal/gateway. Not tried: a real 507 from ChatGPT (it needs the backend to fail a request over Envoy's buffer, which can't be made to happen on purpose). |
||
|
|
ea3ea11729 |
gateway: an image request to a routing group moves on to the next member when one answers 5xx (#2005, tianxia3111)
/v1/images/generations sent to a routing:"order" group only ever drew on the member the model resolved to; a 502 from it went straight back to the caller even though the group had other members that could draw. draw.go: when the asked model names a group (group/<id>, or a bare id whose group holds the resolved member), drawingTries lists the members in planGroup's order and the request moves on with chat's retryable rule (5xx, 429, auth and quota refusals). A request the caller got wrong (plain 400) still stops at once. Pause rules and a gateway key's model holds apply per group as in chat. Drawing still rests no account. The recent call records the skipped members as Fallback, and the final error says "(tried first: ...)", as embeddings do. video.go: /v1/videos had the same single-member path. Its start logic moved into startVideo, and videosCreate walks the same tries; a member that can't make videos moves on too. Run: TestImageGroupMovesOnToTheNextMember and TestVideoGroupMovesOnToTheNextMember go red (502) with either loop forced to stop after the first member, and the image test goes red with the retryable check removed. go test -tags nogui ./... (full suite), gofmt -l, go vet for darwin, GOOS=linux and GOOS=windows on internal/gateway. Not tried against the reporter's real providers. |
||
|
|
56fcd1dc27 |
usage: each account picks a recorded allowance cycle beside its curve, meters and legend following it (#2009, NorethSea)
Let each account choose completed cycles beside its allowance curve. The meters, sampling dates, plot and legend follow that cycle. Missing readings stay unknown, and current account actions and whole-window estimates are not presented as historical data. Fixed-deadline refills preserve cycle boundaries alongside natural and early resets. Keep the upstream whole-window estimate for the current view; no separate price endpoint or duplicate estimation is added. Verified on the integrated tree based on origin/main |
||
|
|
59a8aec5df |
agent: Claude Code's /model takes models added in magpie again when the picker magpie wrote has lost its mark (#2046, cjyrainbow)
cjyrainbow's WSL Claude Code (Ubuntu) kept an old /model list: a model added in magpie was in the gateway's /v1/models but not in modelPicker. settings.json held the picker magpie wrote (every row "… · via magpie"), but stash.json had no claude@wsl:Ubuntu.model_picker mark for it, so writePicker took it for the user's own and never wrote it again. An older magpie's stash lost keys (concurrent writes / a stash that didn't parse, fixed in |
||
|
|
b6cf5e3eab |
gui: magpie web keeps its sign-in when another service on the same address fills or clears the host's cookies, and a page opened without it says why and takes the key (#2033, 321sssrt-bit)
A browser keeps cookies per host, not per port. magpie web's sign-in cookie on http://<tailscale-ip>:3430 is the same host's as every other service on that IP's other ports, so one of them could take it away, and a bookmark then answered only "open the link magpie web printed when it started". Reproduced in Docker (linux/arm64, MAGPIE_WEB_KEY fixed, as the reporter runs it) with Chromium and WebKit on the old binary: - docker restart, recreate (an update), browser restart: still signed in (the key, its derivation and the 400-day cookie are fine); - another port on the same host setting ~400 cookies: Chromium evicts the sign-in (401), WebKit keeps it; - another port answering Clear-Site-Data: "cookies" (a sign-out often does): 401 in both; - the page opened by another name for the host (localhost vs IP): 401. Changed: - the sign-in cookie is sent with Priority=High, so Chrome evicts it last when the host's cookies overflow (with it, the flood case stays signed in); - every magpie_web_<port> cookie the browser sends is tried, so a stale one sent first no longer hides the right one; - an HTML page opened without the sign-in gets a page that says which case it is (no cookie sent for this address, or a cookie holding another key) and a field to paste MAGPIE_WEB_KEY into; POST /_magpie/sign-in sets the cookie and goes back to the page asked for (local paths only: no scheme, host, //, /\ or the sign-in itself). The key is never in the page. API calls get a plain 401 that now says the reason too, and the turn-away is logged with it. - docs/reference.md's Docker web section says how long a sign-in lasts and what can take it away. Run: - TestWebGuardBookmark (link cookie has Priority=High; stale cookie first still passes; both reasons; API 401; wrong key 401 with no cookie; right key 303 to /?view=usage with a 400-day cookie; external, //, /\, javascript:, empty, sign-in-path and CRLF back values all go to /). Broken by hand: the old guard fails it (link without Priority), dropping Priority alone fails it, reading only the first cookie fails it (stale cookie: 401). - The Docker matrix above again on the new binary: the flood keeps the sign-in in Chromium; Clear-Site-Data and the other name get the form, and the form signs in (wrong key turned away, right key back to /?view=usage, 200) in Chromium and WebKit; the log says "turned away ... no cookie sent". - go test -tags nogui ./internal/gui (ok, 173s), gofmt -l, go vet darwin, GOOS=linux -tags nogui, GOOS=windows. Not tried: the reporter's own browser and Tailscale address; which service on their host takes the cookie is not known. |
||
|
|
1e654d8ce7 |
agent: T3 Code keeps the name, auto-compact and other settings the user gave magpie's provider across a restart (#2030, Kanscape)
T3 Code's sync wrote providerInstances.magpie whole on every start, so
what the user changed on it in T3 Code (Display Name, Auto-compact
after, its switch, colour, launch args, an env var of their own) went
back to magpie's defaults when magpie restarted or updated.
Sync and the field setter now merge into what is there (t3Merged):
magpie's own parts are written as before (driver, customModels, the
gateway's ANTHROPIC_BASE_URL / ANTHROPIC_AUTH_TOKEN and the review
switch), every other key under the instance and its config is the
user's and kept (mergeTheirs), a non-empty displayName and the enabled
switch are theirs, and the environment list keeps the user's own
variables beside magpie's. T3's own claudeAgent instance is never
touched, so it and magpie's keep their settings apart.
Run:
- TestT3CodeKeepsTheUsersSettings: T3's claudeAgent instance beside
magpie's; the user edits magpie's (name, enabled, accentColor,
autoCompactWindow "300000", launchArgs, a stale model, a changed base
URL, an added HTTPS_PROXY), then three syncs. Against the old
t3code.go it fails on the name, the switch, the colour, the config
and the env.
- go test -tags nogui ./internal/agent (whole package, ok, 1555s on
4c746ab39; T3 tests again after rebasing on
|
||
|
|
812ca5a5c6 |
gateway: a video request's other fields reach a provider's own videos API as sent, so Agnes gets its mode (#1399, shen-joe)
shen-joe's request to a model marked a Video model on an Agnes provider,
{"model":"agnes-cn/agnes-video-2.5-flash","mode":"text","aspect_ratio":"16:9",
"size":"720P","seconds":"10","prompt":"…"}, came back 400 from
api.agnes-ai.cn: "mode 不能为空". remoteVideoBody sent only model, prompt,
seconds, size and the images, so every field a vendor's own videos API
needs beyond OpenAI's was dropped.
readFilming now keeps the request's other fields (JSON, or a multipart
form's text values), and the body for a provider's OpenAI-shaped videos API
or another magpie's carries them as they came, under magpie's model and
prompt. Grok's and Volcengine's bodies are unchanged. Strings in them are
masked as the prompt is (a negative_prompt is the user's text too), and the
answer is unmasked when they were.
Polling stays at GET /v1/videos/{id}: api.agnes-ai.cn answers that route 401
on a bad key where an unknown route is 404 "Invalid URL", so the route
exists; the /agnesapi?video_id= query the reporter used wasn't needed.
TestCustomProviderVideoKeepsTheCallersFields sends the reporter's body and
checks mode, aspect_ratio, size and seconds reach the upstream, then that a
redacted word in negative_prompt and a nested field doesn't. It fails on
the old video.go, and with the masking taken out by hand. go test -run
'Video|Film|Redact' ./internal/gateway passes; gofmt clean; GOOS=linux and
windows go vet -tags nogui pass. Not tried against Agnes itself (no Agnes
account here).
|
||
|
|
66b8999e0d |
dsh: Reconnect puts magpie's key over one in dsh's key store that magpie refuses, and Disconnect puts it back (#1419, DannyJRu)
DannyJRu (dsh desktop 0.2.0-rc.2 on Windows, magpie 0.1.1226): the row said "已不经过 magpie:配置已变更", its tooltip that ~/.dsh/.credentials.yaml holds another MAGPIE_GATEWAY_KEY; Reconnect showed its success toast and the row stayed red. dshCreds left any value there that isn't magpie's own token or LAN secret, so Apply again could never fix what the check reported, and the check sent the user to dsh's Models page instead. The store wins over .env in dsh, and MAGPIE_GATEWAY_KEY is the name only magpie's route reads, so a value there the gateway refuses fails every turn through magpie. Now a model picked here, which is what Reconnect (Apply again) does, replaces such a value with magpie's key and stashes it; Disconnect puts it back. The sync and the serving round still leave it (no silent overwrite of a value the user set), a caller key the gateway takes stays (#1332), and so does any key when dsh points at a magpie on another machine, which only that one can judge. The check now says Apply again fixes it (Disconnect puts the old one back), except for a gateway on another machine, where the old advice stands. TestDshApplyReplacesAKeyTheGatewayRefuses: the sync leaves a refused key and the check reports it; a model set replaces it, keeps the store's other refs, and the check is quiet; Disconnect puts it back; a caller key the gateway takes isn't replaced. It fails on the old dsh.go. go test -run Dsh ./internal/agent passes; gofmt clean; GOOS=linux and windows go vet -tags nogui pass. Not tried with the real dsh desktop app on Windows; why the reporter's store holds a refused value isn't known (an old caller key, or one typed in dsh's Models page), and they are asked to confirm. |
||
|
|
3aa22f9d9c |
gateway: a translated Responses reply keeps the web search that ran, with its query and sources (#2044, BussanQ)
What changed: responsesEncoder.event gets a KSearch case and
renderResponses a Search case. Both emit a completed web_search_call
item (ws_ id, action.type "search", query plus queries, and the
nonempty source URLs in action.sources) through the shared
responsesSearchItem. The stream adds the item, sends
response.web_search_call.completed {item_id, output_index} and
output_item.done, and the same item stays in the terminal response's
output, in order with text, reasoning and client tool calls.
Why: a search magpie ran for a model that can't search (searchRounds),
or one decoded from an upstream Responses or Anthropic reply, reached
the client only as answer text. Anthropic clients already got
server_tool_use / web_search_tool_result; Responses clients (bqAgent)
had no record that a search ran or what it found. No earlier progress
events or url_citation offsets are invented.
From BussanQ's reference commit b1a4e7b, reviewed line by line and
applied onto origin/main. Added on review:
TestResponsesSearchItemReplayed (the item sent back as the next input,
as Codex does, parses and leaves the turn's messages unchanged) and a
docs line saying so.
What was run (sandbox HOME, pinned caches, go1.26.8):
- go test -tags nogui -count=1 ./internal/gateway -run
'TestResponsesSearch.*|TestWebSearchForAModelThatCannot|
TestSearchToldAsAnthropics|TestWebSearchAskedOfEachAPI|
TestAnthropicServerToolLeftOut|TestParallelToolCallIDs|
TestResponsesStreamToolThenHiddenThinking': ok
- Break check: origin/main's responses.go put back with the new tests:
TestResponsesSearchResults "search output lost or reordered: got
[message message function_call]", TestResponsesSearchDecodedResults
"decoded provider search missing", TestResponsesSearchFollowedByFailure
"completed search or subsequent error lost", and
TestWebSearchForAModelThatCannot "delegated search missing from
Responses output" all FAIL; pass with the change restored.
- go test -tags nogui ./internal/gateway (whole package)
- gofmt -l; go vet -tags nogui for darwin, GOOS=linux, GOOS=windows
Not run: a live provider; the full repository suite.
Co-authored-by: BussanQ <bussanq@gmail.com>
|
||
|
|
27956002c3 |
agent: OmO's update runs the npm of the node it was installed with, not a system one first on magpie's PATH (#2021, ggbdpq)
OmO updates itself: magpie runs `omo update`, and omo-ai 5.1.32's updateTarget (bin/lib/package-paths.js) then runs a bare `npm i -g omo-ai@<v>` (or `bun add -g` for a bun install). The updater for a self-updating CLI had no path, so that npm was whichever came first on magpie's PATH. With OmO installed under an fnm/nvm node and a system npm in /usr/local/bin, the update went to the system prefix (or failed on its permissions), and the omo the agent runs stayed old. howInstalled's self branch now gives the updater the bin dir of the package manager that holds the CLI (selfPath): for an npm install, the prefix's bin that fromNodeModules already finds for npm-installed CLIs; for bun or pnpm, the dir of that manager's binary. That dir goes first on the update's PATH, as it does for npm updates. Run: TestOmoUpdateTakesItsOwnNpm (new: a fake system npm that fails and an fnm prefix's npm that records; on the old code the update ran the system npm and failed with exit status 1), TestOmo*, TestHowInstalled*, go test ./internal/agent (ok in 1783s at load average ~100; a 15m timeout ran out under that load, on no failure), gofmt -l, GOOS=linux and GOOS=windows go vet -tags nogui ./internal/agent. |
||
|
|
45e77b61f7 |
library: Claude Code's hooks can go on every event it has, StopFailure, PostCompact and FileChanged among them (#2020, emo172)
The claude branch of hookSpecOf knew 12 of Claude Code's events, so a
hook on StopFailure, PostCompact, CwdChanged, WorktreeCreate and the
rest was refused ("it has no event called StopFailure") and could only
be written into settings.json by hand, outside magpie's record and
backups. The list is now claudeHookEvents: all 33 names of the
HOOK_EVENTS enum in the real claude 2.1.296 binary, read from it with
strings (read only, ~/.claude untouched). That is the 14 the issue
lists plus six it didn't (PostToolBatch, UserPromptExpansion,
PermissionDenied, Elicitation, ElicitationResult, DirectoryAdded). The
page's event picker takes the agent's list from the same table, so it
offers them too. Codex's, Gemini's and Cursor's tables are not
changed here: each of Codex's 12 names is in codex 0.162.1's strings,
but its full enum wasn't extracted.
Run: go test ./internal/library (TestHooksClaudeEventsAll new; on the
old table it fails with "it has no event called StopFailure"), gofmt
-l, GOOS=linux and GOOS=windows go vet -tags nogui ./internal/library.
|
||
|
|
bf25842714 |
gateway: a provider's own cap on how long a key that keeps failing rests (#2008, Gaudi-XIX)
A key that keeps failing doubles its rest from a minute up to 10 minutes, and one rate limited again as soon as its rest is over up to 30; both caps were fixed, so a free key down for hours was asked again every 10 or 30 minutes all the while. `magpie provider rest-cap <id> 4h` (Provider.RestCap, minutes, at most MaxQuotaRest, 8 days) sets where both ladders stop for that provider's keys and accounts (RestCapOr in restAfterMarked's default branch and in rateRest); `default` gives back the gateway's own. A time the vendor names still stands over it. Unset, nothing differs. It is kept by the editor's save, the account copy and normalize. Run: go test -tags nogui ./internal/provider ./internal/gateway ./internal/cli ./internal/gui (temp HOME). Broken by hand: both ladders back on the fixed caps fail TestOwnRestCap (rate-long #6: 30m, want 32m); the GUI keep removed fails TestSaveKeepsQuotaResetAt. Not tried against a real vendor's outage. |
||
|
|
064cffdbfd |
gateway: a key out of a daily allowance rests until the time of day it comes back (#2008, Gaudi-XIX)
A free tier's "You've reached today's free-model token quota" says nothing of when it is back, so it rested 15 minutes (or the provider's own quota-rest), and was asked again all day. A vendor Retry-After over an hour was cut to the hour, and that hour then stood over the user's own longer rest. - Provider.QuotaResetAt: "08:00" on this computer's clock, or "00:00+08:00" on the vendor's. `magpie provider quota-rest <id> until 08:00` sets it; a number of minutes set after it replaces it, and default clears both. normalize drops one that isn't a time of day. It is kept by the editor's save and the account copy. - restAfterMarked's quota branch rests until its next occurrence (OwnQuotaRest). A time the vendor names, or a window's end, still stands over it; a Retry-After stands unless it was cut to longestWait while the user's own rest is longer. - Defaults are unchanged: nothing set, nothing differs. Run: go test -tags nogui ./internal/provider ./internal/gateway ./internal/cli ./internal/gui (temp HOME). Broken by hand, each fails: OwnQuotaRest replaced by QuotaRestFor (TestQuotaRestsUntilTheTimeOfDaySet, 3 asserts), the Retry-After guard removed (the 7200 case), the GUI keep removed (TestSaveKeepsQuotaResetAt), default not clearing it (TestQuotaRestUntil). Not tried against a real free-tier vendor. |
||
|
|
77f90fd84f |
gateway: a plugin whose config hook says searches: true is sent the client's web_search as sent (#2027, yudaleng)
A plugin in front of Anthropic's or OpenAI's own API (a CPA or sub2api relay whose quota the plugin reads) had no way to say its upstream runs the hosted web search tool: searchesItself returned at once for any signed-in account, letting only Codex and Grok through, so Claude Code's WebSearch and Codex's web_search always went through magpie's own search. Now a plugin's config hook can set `searches: true` on its provider, as it sets `decide` (#1514). The host passes it through (plugin.Provider.Searches), pluginProvider sets the provider's Searches, and searchesItself honours it for a plugin's provider only, on Anthropic or Responses and only where the plugin has a model on that API, the same rule a custom provider's "Searches the web by itself" has (#359). Another sign-in's Searches is never read; Codex and Grok are unchanged. As with a relay, searchRank leaves it out, so magpie never picks it to search for other models; Settings can name it by hand. Documented in docs/subsystems/provider-plugins.md and the plugin guide (site/public/docs plugins.html, en/zh/ja). Verified: - TestPluginSaidToSearch (new, gateway, through the real fake plugin on bun and New().Handler()): with FAKE_SEARCHES the plugin's upstream gets web_search_20250305; without it, it gets no search tool; Chat doesn't search and searchRank is -1 either way. - Broken by hand, each red: search.go reverted, plugins.go reverted, host.js reverted (each "searches by itself on Anthropic: false"); with the searchesItself assertion disabled and search.go reverted, the wire check fails "said to search true, the plugin was sent []". - TestMovedGrokSearchesItself, TestGrokPluginSearchesItself, TestWebSearch* pass. - go test -tags nogui ./internal/plugin ./internal/provider ok, and ./internal/gateway (see the run noted on #2027) under a sandbox HOME with pinned caches; gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui on the three packages clean. - Not tried with a real CPA/sub2api plugin. |
||
|
|
0337ce4bc7 |
factory: Haiku 5.5 and Mistral Large 4, in droid 0.240.0's picker, are offered, and moved users get plugin 0.1.25 (JL on Discord)
JL (Windows, droid 0.240.0, Factory desktop 0.197.1, magpie 0.1.1226, opencode-factory-auth 0.1.24): droid and Factory desktop offer claude-haiku-5-5; droid through magpie couldn't pick it. droid's models are the registry bundled in its npm binary (@factory/cli-<platform> 0.240.0, bin/droid). Against 0.233.0's registry, 0.240.0 adds claude-haiku-5-5, mistral-large-4 and gpt-6-astra-ultrafast. The plugin (magpie-community/plugins e4023d9, published as 0.1.25, npm view checked) now offers Haiku 5.5 (Anthropic Messages, 872000/128000, efforts low..max) and Mistral Large 4 (chat completions, x-api-provider mistral, Droid Core, 524288/64000, images). GPT-6 Astra Ultra Fast stays out: droid offers it only once the user accepts Factory's high-cost terms. - migrate_factory.go: the mover's min is 0.1.25, so keepMovedCurrent updates moved users (JL is on the plugin). - factory.go: the built-in had the same gap; its table gets the same two rows for users who haven't moved. - factory_pool_rest_test.go: the plugin's Core list, copied from its usage, gains Mistral Large 4. - TestFactoryDroid0240Models is new; its fixture is droid 0.240.0's registry bytes (the same as the plugin's models.test.mjs). It fails with the Haiku 5.5 row removed. Run, under a temp HOME: go test -tags nogui ./... with the machine at load 35-190 (other sessions). Every package passed except five that hit the 10m timeout mid-test (agent, gateway, library, plugin, provider, in tests that don't touch Factory). Rerun with -timeout 40m: provider ok; gateway still timed out at load ~130 (TestCodexHeardWithinItsIdleTimeout failed on its timing, unrelated); -run 'Factory|Moved' on gateway ok. agent, library and plugin were not rerun to the end; this change doesn't touch them. gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui on internal/provider and internal/gateway ok. Not tried against Factory itself (no Factory account here); droid was read, not run. |
||
|
|
eb22f6355a |
davsync: a computer joining a sync folder keeps the gateway keys the folder's store has never seen (#1737, #1714, ggbdpq)
The gateway-key store rides the settings part, and a first sync brings a part changed only on the server in whole. So a computer with its own gateway keys that joined a folder another computer had set up first had every key replaced by the folder's store (8ugMak1r on #1714 got them back only from the -this-computer copy in the sync folder). On the first sync, before the settings are brought in, the keys this computer holds that the store has neither by id nor by value are added to the store brought in; that merged store is restored here and pushed for the others. A key the folder holds wins; the LAN default key follows the folder's settings as before. After the join a key missing from a store this computer has seen is a removal, as before. ggbdpq's patch (a9605c8a), cherry-picked unchanged. Run (reviewer): TestGatewayKeysJoinKeepsUnseenKeys fails on the old davsync.go (the joining computer's keys are gone, the pushed store holds only the folder's default key, computer B never gets A's key) and passes with it, -race -count=3; TestGatewayKeysJoinWithoutStoreKeepsKeys passes on both. go test ./internal/davsync/... ok. Not tried against a real WebDAV server. |
||
|
|
94e3b3f529 |
sessions: a gateway-sessions-hidden.json that doesn't parse is kept aside before the next delete or Restore writes over it (#1722, ggbdpq)
readHidden read a file that didn't parse as no deletions, and the next
DeleteGateway or Restore wrote that empty list (plus the new entry)
over it, or removed it, so every earlier deletion record was gone for
good. writeHidden now copies such a file to
gateway-sessions-hidden.json.bad-<time> first, as stash.json's and
logins.json's unread files are kept, and doesn't write when the copy
can't be made.
ggbdpq's patch (1ec0def6, marked wip and unverified on its branch).
Reviewer's changes: "doesn't parse" is decided by unmarshalling into
the list (json.Valid let an object through to be written over), and a
copy that fails stops the write instead of only logging, as
|
||
|
|
1a7aa76b4b |
mcpauth: an MCP sign-in canceled while its token is being fetched no longer saves the late token or replaces the server's sign-in (#1750, ggbdpq)
Cancel set the flow canceled, but a callback already trading its code
went on to write mcp-signins.json and call Changed when the token came
back, so a sign-in the user had ended was saved, and an existing
sign-in to that server was replaced. The callback's write now happens
under the flow's lock only while the flow is live (flow.keep), so
Cancel or the timeout and the commit can't both win; a commit that wins
still tells the agents before the flow says done.
ggbdpq's patch (46440adc), cherry-picked unchanged.
Run (reviewer): TestCanceledMCPCallbackDoesNotSave (real discovery,
registration, PKCE and loopback callback against mcpauthtest, the token
reply held until Cancel) fails on the old mcpauth.go in both cases
("saved credentials", "redistributed credentials 1 times") and passes
with it, -race -count=5; go test -race ./internal/mcpauth/... ok.
Not tried with a real MCP server's OAuth.
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
|
||
|
|
509328ccb0 |
provider: a Codex reset spent while an allowance read is in flight is never undone by that read, even on Windows' coarse clock (#1754, ggbdpq)
Allowances took time.Now() when its background read began, and
forgetAllowance stamped the reset with time.Now(); a reading was dropped
only when the reset was After the start. On Windows two events in one
clock tick get the same time, so a read begun before a spent reset could
put the account's 100% back right after it. Reads and resets are now
ordered by a generation counter under usedCache's lock.
ggbdpq's patch (e07232ef), cherry-picked unchanged.
Run (reviewer): TestResetAllowanceKnownAtOnce, Windows test binary on
the Windows box (sandbox USERPROFILE/APPDATA), -count=10: old code FAIL
4 of 10 ("routing reads 100 used (known true), want 0"), this change
PASS 10 of 10. macOS -race -count=20 of the Allowance/Renewed tests ok.
Full provider package, gofmt, linux and windows vet: see the push.
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
|
||
|
|
591ed58b53 |
provider: Nous Portal is a vendor preset, Nous Research's API with a Portal key (#392, Vocllum, laojianzi)
Nous Research makes the Hermes models and serves them, with other makers' models, through Nous Portal. #392 was wrongly answered as a relay. A new preset, nous ("Nous Portal", KindVendor with Hosts, lobe-icons nousresearch icon), points chat completions at https://inference-api.nousresearch.com/v1. A Portal API key goes in as a Bearer, the way Hermes Agent's own nous-api provider uses NOUS_API_KEY. The model list is the Portal's /v1/models, which uses vendor/model ids. An entry another app has at that URL, such as Hermes Agent's base_url, now imports as the preset. The preset sets no Anthropic endpoint. The Portal's /v1/messages serves only its anthropic/* models (Hermes Agent's test_nous_portal_anthropic_wire.py), so Claude Code's requests are translated to chat completions for every model. It sets no Responses endpoint either, because none is documented. The preset is added to the README (en, zh), docs/reference.md, and the site's import pages and icon. Sources: - hermes-agent docs: integrations/nous-portal, integrations/providers, features/subscription-proxy. - hermes-agent source at 6e7b83a2: hermes_cli/auth_constants.py (DEFAULT_NOUS_INFERENCE_URL), plugins/model-providers/nous, cli-config.yaml.example ("nous-api - Nous Portal API key (requires: NOUS_API_KEY)"), agent/anthropic_endpoints.py, and tests/e2e/core/live/_helpers.py, whose live run calls the Portal with NOUS_API_KEY. Probed without a key: - /v1/models answers 200 with 423 models. - /v1/chat/completions with a bad Bearer answers 401 "Your API key is invalid, blocked or out of funds". - /v1/messages answers an Anthropic-shaped 401. Not tried: a real Portal key or a real request, since no key was available. Also not built: OAuth sign-in with the 1-hour token and its refresh (Hermes Agent's ~/.hermes/auth.json). Run: - TestNousPortalPreset fails without the preset (no preset "nous") and with an Anthropic endpoint added (endpoints: … "https://inference-api.nousresearch.com"). - go test -tags nogui of internal/provider, internal/gui and internal/catalog passes. - gofmt -l is clean. - go vet, GOOS=linux go vet and GOOS=windows go vet -tags nogui on ./internal/provider pass. - add-sheet and add-button GUI tests pass in Chromium and WebKit (6/6). |
||
|
|
4c746ab390 |
gui: Azure OpenAI says its models are the deployments magpie lists with the key (#1995, parkavenue9639)
Adding Azure OpenAI asked only for the endpoint and key. Nothing said that, once it is saved, magpie asks the resource for its deployments with that key (Provider.azureModels), so people took the page for one where model ids must be typed. A saved one whose list hadn't come back yet said "The vendor's list is empty", the same as one asked and empty. - The endpoint hint (presets.go) now says magpie asks the resource for its deployments with this key once added, and the deployments' names are the model ids. - The add page has a Models row for Azure: nothing to type; a deployment's name is typed as a model id only if the list can't be fetched. - A saved Azure provider with an empty list says it is asking the resource with this key while the background fetch runs (providers.fetching, not yet fetched, no list error), and after it that no deployments came back, with Fetch again or a deployment's name. Every other provider's empty text is unchanged. - New strings in zh, zh-TW, ja and de. azureModels itself is unchanged. Run: azure-endpoint.test.cjs (24 pass, Chromium and WebKit, en and zh), extended with the add page's Models row and four empty-list cases (asking, asked and none, asked and failed, OpenRouter unchanged). With the old app.js put back it fails 10 of 12 on Chromium (no .azure-models row, the generic empty text). With the old i18n.js the zh cases fail (6 of 12). gui-de, gui-ja, gui-zh-tw, i18n-keys, provider-fetch-again, provider-picks-stay, add-sheet: 34 pass in each engine. go test -tags nogui ./internal/provider ./internal/gui ok under a sandbox HOME; gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui on both packages clean. Not tried against a real Azure resource (no account): only the text changed, not the fetch. |
||
|
|
80211e7075 |
provider: a balance field sums, maxes or counts a list's items, and one amount it can't read is "—" (#1993, RicardoWYP)
A relay's /api/subscription/self tells usage per subscription, a list.
A balance path could only name one index (subscriptions.0), so several
active subscriptions read as the first, ".0 + .1" failed whole when only
one existed, and a weekly cap of 0 ("divides by 0") hid every amount of
the field.
Now a path goes through a list's items with "*" (a.*.used), or those
that match with "[key=value]" / "[key!=value]" (a[status=active].used,
also on an object: a.*.subscription[status=active].used). Such a path is
several values, made one by sum(), max(), min() or count(); arithmetic
between two of them goes item by item, so max(a.*.used / a.*.cap) is the
fullest window. Several values left outside a function are an error
naming the functions, not a guessed sum. Within a list an item without
the path, or divided by 0, is left out; max/min of nothing is an error.
In a field of several ";" amounts, one that can't be read shows "—"
(BalancePart.Error says why, as the card's hover on the Usage page and
in the panel) and the others still show; the read fails only when none
can be read. A single amount alone still fails as before.
The GUI hint (zh, zh-TW, ja, de) and `magpie provider` help say the new
syntax.
Run:
- TestBalancePathLists, with the reporter's literal JSON: against the
old balance.go it fails ("nothing at \"sum\" in the reply", and the
"—" cases error); passes now. TestReadBalancePath's one case that
expected a whole-field failure with one bad amount now expects it
only when every amount fails.
- go test -tags nogui ./internal/provider ./internal/cli ./internal/gui
under a temp HOME: ok.
- balance-parts, gui-de, gui-ja, gui-zh-tw, i18n-keys in Chromium and
WebKit: 14 pass. With the title lines removed, balance-parts fails on
the missing hover text.
- gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui on
provider and cli.
Not tried against the reporter's real relay.
|
||
|
|
9bfbd6e45e |
sessions: Sessions loads again with a large Cursor store, which every listing read whole from disk (#1988, kangxi94)
v0.1.1227 (
|
||
|
|
bede73c34d |
gateway: concurrent tasks of an agent that sends no session id are told apart by their conversation (#2001, CnsMaple)
Task done 通知按 agent+session 分桶,turnState.start 建桶时定死:同一
agent 不带 session 头的多个并发任务共享一个桶,先结束的任务的通知读的
是仍在跑的最长任务的时间(且 going>0 时不发通知)。convOf 生成的
Conv(首个用户轮次的摘要)已存在于 Route 且只在无 session 时填充——
sessionTurnKey 在 Session 为空时用 Conv 兜底,并发任务各归各的桶。
同一 session 的多个请求仍共享一个 turn,等待全部结束、跨度和原来一致。
验证:TestTurnDoneConcurrentTasksByTheirConversation(短任务通知读自己的
一分钟、长任务不受影响各自报自己的跨度)与
TestTurnDoneSameSessionStillOneTurn(同 session 行为不变);未修复基线
前者 FAIL(等了 10s 无通知,因 going>0 被压住)。TestTurnDone* 全组通过。
Root cause and fix by AwadYoo (comment on #2001), landed as their commit.
Reviewed on main: both routes that mark a request as a turn
(gateway.go, codex_backend.go) set Conv, convOf is "" whenever a session
header is present, and begin/end read the key off the same Route, so a
request's begin and end always meet one bucket.
Run (sandbox HOME, pinned caches, rebased on
|
||
|
|
cc43e9893c |
provider: a plugin subscription put first on one computer is first on the other too, once sync has named it by both ids (#1940, Sun1090)
Sun1090, on v0.1.1225 (which had |
||
|
|
e10b7f92a1 |
usage: a window whose calls may have been paid from credits shows no whole (#2010, NorethSea)
Once a Codex account's window read 100% used, ChatGPT kept answering its calls from credits; once the credits ran out the card had no Balance, so holdsBounds let the whole-window estimate back in and counted those calls as the subscription's. The reporter's fixture (5 hours at 100%, week at 50%, a 100k subscription call and a 900k credits call) gave routed 1000000 / whole 2000000 for the week. Claude's extra usage after a dry window is the same case. dryRuns builds each account's dry runs from its kept quota history plus the card's own reading: from the last reading with some left (unknown = zero) through the first reading of none, to the first with some again. A window that counted a call in a run is not reckoned when the vendor answered a call after the run's first dry reading, or when no earlier reading with some left is known. A run where everything after the dry reading was turned away (no credits) leaves the estimate as it was, and a run before the window began doesn't touch it. Run: go test -tags nogui ./internal/usage ./internal/gui (HOME sandbox), gofmt, GOOS=linux/windows go vet. TestWindowHoldsLeavesOutCallsPaidOtherwise goes red with the exclusion disabled (prints the reporter's 1000000 / 2000000) and with the "answered after the dry reading" condition dropped. Not tried against a real account that spent credits. |
||
|
|
916e30a4f8 |
docs: every file in ~/.config/magpie says what it is for (#2028, emo172)
#2028 asked to sort ~/.config/magpie into subfolders. It stays flat: backups, sync, Docker volume mounts and older magpies all find each file by its name there, and moving them would break each of those for a cosmetic gain. What the report really lacked is knowing what each file is, so the reference's Files section now lists every file magpie writes, grouped by what it holds (what you set, accounts and sign-ins, what magpie set on agents, the gateway and usage, the window's state, and ~/.cache/magpie), with which are written 0600 and what .lock and .bak files are. Each line was checked against the code that writes the file (the path helpers and their doc comments). Docs only; nothing was run. |
||
|
|
1aadd2167c |
gui: a proxy's own error page is said by its title, not as raw HTML (#2032, precisionz)
When an answer isn't JSON, api() showed its first 200 characters. For a proxy's or tunnel's own HTML page that was markup, e.g. Cloudflare's 524 page as "<!DOCTYPE html> <!--[if lt IE 7]> <html class=…" in precisionz's screenshot. An HTML answer (by Content-Type, or a body that starts as a page) is now said as "A proxy in front of magpie answered, not magpie (<title>)". For 504 and 524 it says that the proxy stopped waiting, magpie may still be finishing, and to check again in a minute. The status pill shows one line, so the words that matter come first. Plain-text errors are shown as before. Strings in zh, zh-TW, ja and de. Verified: - internal/gui/tests/plugin-proxy-page.test.cjs (new). It installs from the Discover field at 420px, with plugins/add answering Cloudflare's 524 page (its head as in the screenshot, the rest from Cloudflare's template, not captured live) and a 502 with no Content-Type, in en, zh, ja and de, plus a plain-text 500. Chromium and WebKit: 12 pass. With api()'s old line put back, every language fails on the raw markup. - gui-ja, gui-de, gui-zh-tw, i18n-keys and every plugin-*.test.cjs, both engines: 396 pass, 0 fail. |
||
|
|
c55395df9e |
gui: a plugin install goes on when the proxy in front of magpie web gives up (#2032, precisionz)
precisionz installed Zed from magpie web on a phone; the page spun for a
while and then showed Cloudflare's own error page ("<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js ie…"). A tunnel or proxy in front of
magpie web stops waiting after its own limit (Cloudflare: 100 seconds,
then 524), closes the connection, and /api/plugins/{op} ran bun under the
request's context, so the install was cancelled halfway.
/api/plugins/{op} now runs under context.WithoutCancel(r.Context()) with
the same 5-minute cap, as moveContext already does for a move. add,
remove, update and upgrade go through test seams (addPlugin, ...).
Verified:
- TestPluginOpsOutliveRequest (new) cancels each request before serving
it. With r.Context() put back it fails: "got [add: stopped with the
page remove: stopped with the page update: stopped with the page
upgrade: stopped with the page]". With the fix it passes.
- HOME=<temp> go test -tags nogui ./internal/gui/: ok (107s).
- gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui
./internal/gui/: clean.
Not tried: a real Cloudflare tunnel in front of magpie web.
|
||
|
|
17d4283a5a |
library, gui: a hook has a description in any language, shown under its name (#2011, emo172)
A hook's name is letters, digits, - and _ (checkName), so a Chinese user had to translate "auto-format-queue" back in their head; 编辑后格式化 was refused. Hook now has an optional Description: one line (whitespace and line breaks folded into single spaces) of at most 200 characters, kept in library.json only and never written into an agent's hooks file. The Hooks tab shows it under the name; the editor has a Description field (maxlength 200) under Name. The library's text fields no longer save or close on an Enter or Escape that only ends an input method's composition (isComposing / keyCode 229), which a Chinese description would hit. Strings in zh, zh-TW, ja and de; docs/subsystems/library.md says it. The reporter's other option, non-ASCII names, wasn't taken: the description says more than a name can, and names stay one rule across servers, skills and hooks. Run: TestHookDescription (kept through a save, an agents change and a rename, read by the page, no agent file has it, 201 characters refused, 200 kept) fails with the folding and the length check removed. library-hooks.test.cjs (a description under the name, none for a hook without, the field's placeholder and hint, an IME Enter posts nothing, Save posts the description) fails on the old library.js and with the IME guard removed. library-*, gui-de, gui-ja, gui-zh-tw, i18n-keys and click-scroll pass in Chromium and WebKit (263/263 each). go test -tags nogui ./internal/library ./internal/gui under a temp HOME, gofmt -l, GOOS=linux and GOOS=windows go vet -tags nogui ./internal/library pass. |
||
|
|
c48c49488d |
lessons: the review of 10-11 to 10-13; failed reads, locks, another app's values, guarantee tests, network-free tests, tags and commit bodies move to the code standards
The nightly fold of the review of 10-11 05:20 to 10-14 04:00 (602 commits, tags v0.1.1173 to v0.1.1228, 54 of 56 published). Moved to docs/code-standards.md, each seen a third day or more: - a failed read means unknown ( |
||
|
|
e297a8ab27 |
provider: a codex-autoreset.json that can't be read no longer lets a Codex account's auto-use spend a second reset the same week (#2017, ggbdpq)
What changed: - autoResets.load read a codex-autoreset.json that didn't parse (a crash leaving it zeroed, as #1505's files were) as "none spent this week", so the next week-used-up look spent another reset, and the write after it took the unreadable bytes with it. Now a file that can't be read or parsed is unknown: the bytes are copied aside as .bad-<ts> (as noteResetUsed keeps codex-resets-used.json's), and what was spent is rebuilt from codex-resets-used.json, which records every reset used for a week used up. When that file can't be read either, no account spends one by itself for a week (the longest a lost spend could still count), kept past restarts under a "*" entry. - autoResets.save writes through steady.WriteFile, as every write of magpie's own state does since #1505, and logs a failed write. ggbdpq's patch kept the file aside and made the write durable, but still read the unreadable file as none spent, so its own scenario (a crash, then a restart) still spent a second reset. This takes their patch and fixes the read at the cause. Run: - TestAutoResetUnreadableKeptAside (ggbdpq's) fails on main: "the unreadable file was written over with nothing kept aside". - TestAutoResetUnreadableReadsResetsUsed and TestAutoResetNothingKnownSpendsNone fail on main and on ggbdpq's patch alone: "spent 1 resets, want 0" / "spent 1 resets with nothing known of the week". Cases: an auto-use an hour ago holds off; one 8 days ago, one by hand, or another account's doesn't. - go test -tags nogui ./internal/provider under a temp HOME passes; -race -count=10 -run TestAutoReset passes; gofmt -l clean; go vet, GOOS=linux and GOOS=windows go vet -tags nogui ./internal/provider pass. - Not tried: a real corrupted file from a user (none reported); a real Codex account (checked against the fake ChatGPT server only). Co-authored-by: ggbdpq <ggbdpq@gmail.com> |
||
|
|
b26c083c84 |
cli: setting Claude Code's sonnet/opus/haiku/fable while it is on magpie says magpie is out, and help says the aliases take it out (#2000, marshalys)
`magpie claude sonnet` sets Claude Code's model to its own alias. That isn't a model magpie serves, so magpie steps out (unroute) and puts back the endpoint Claude Code had before magpie. In #2000 that endpoint was DeepSeek's, which refused Sonnet with a 400. The command printed only "✓ Claude Code model sonnet". An agent had run it as a read-only query of the sonnet tier, and nothing in the output said the routing had changed. set() now checks whether the agent was wired into magpie before the write. When a non-empty value leaves it unwired, set() prints "disconnected from magpie: <model> is <agent>'s own, sent to the endpoint it had before magpie; magpie <agent> <model> with one of magpie's models connects it again". This covers every agent and field set through `magpie <agent> …`, not only Claude's aliases. Setting a field back to default (empty) is left as it was. `magpie <agent> default` already says it disconnects. The behaviour itself is unchanged. On an Anthropic sign-in or a Claude relay the aliases are a deliberate one-word way back to Claude Code's own models. `magpie claude help` now has a line under the aliases: "they are Claude Code's own models, not magpie's: setting one takes magpie out; magpie claude alone shows each". Verified: - TestClaudeAliasSaysItTookMagpieOut covers opus, sonnet, haiku and fable. It starts from a DeepSeek-style own endpoint (.invalid host), wires Claude Code to group/advanced and sets the alias. It checks the notice, that the old endpoint is back, that nothing is printed when the alias is set again while off magpie, and the help line. - With the notice disabled by hand, the test fails: "magpie claude opus: <nil> "✓ Claude Code model opus\n", want it to say magpie is out" (and the same for the other three). - TestAgentDefaultInAnyCase first went red on "codex model DEFAULT", so empty values are excluded. - HOME=<sandbox> go test -tags nogui ./internal/cli: ok. - gofmt -l clean. go vet and GOOS=linux/windows go vet -tags nogui ./internal/cli: clean. |