main
12
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
0135b7b0ea |
agy-cli 0.1.32: the first model list after warming has agy's Claude and GPT models (#1064)
On a signed-in agy, `agy models` takes about 4.4s and `agy acp`'s
session/new about 3s. provider.models() needed three calls before
claude-opus-5-5, claude-sonnet-5-5 and gpt-oss-120b showed up, and
OpenCode 2.x calls it once.
What changed:
- packages/agy-cli/index.mjs:
- The offered-model probe now starts in listAgyModels' .then, as soon as
a non-empty list arrives and a caller asked for probeOffered. It no
longer waits for the next models() call. A hung or failed `agy models`
still never spawns the probe.
- probeSignedIn reuses the `agy models` stdout it already has. The same
parser (parseAgyModels, split out of listAgyModels) fills
cachedModelCatalog, and the probe starts. Sign-in waits for the probe
for at most 3s.
- The offer (acpOfferedModels, acpOfferedKey, offeredProbeAt and any
in-flight probe) is forgotten when agyPath changes and after a new
sign-in finishes. A generation counter drops the answer of a probe
that started before the reset.
- provider.warming() returns a promise while a list or probe is still
running, and null when nothing is.
- scripts/opencode2.mjs, copied byte for byte to every
packages/*/opencode2.mjs: after the first background refresh, the
adapter awaits hooks.provider.warming() once, for at most 60s, and then
refreshes once more. It does not loop. Plugins without warming() behave
as before.
- Not done: the issue's on-disk catalog cache (point 3), skipped as asked.
Known gap: agy-cli has no `config` hook, so under OpenCode 2.x the adapter
lists no provider for it. refresh() returns before it calls
provider.models(), so the follow-up refresh can't add agy's models on 2.x
until agy-cli gets a config hook.
Tests: test/testkit.mjs's fake agy takes a sessionNewDelayMs. The new
tests in test/catalog.mjs set 1.5s on both `agy models` and session/new
and wait for state through warming(), with no fixed sleeps:
- On a slow cold start, the first models() after warming lists Claude and
GPT, from one probe spawn.
- authorize() on a signed-in agy fills the catalog, and the next models()
runs no second `agy models`.
- The sign-in wait is bounded: with a 6s session/new, sign-in returns in
about 4.5s.
- Changing agyPath probes again.
The hang test now awaits warming() before it counts acp spawns.
scripts/opencode2.test.mjs: the warming list is read a second time when
warming ends, and only once when nothing is warming.
Run on Linux (a separate test Mac was over its load limit):
- packages/agy-cli bun test: 17 pass, 0 fail.
- bun scripts/check.mjs agy-cli: ok.
- bun scripts/check.mjs (all packages): ok.
- Root bun test in a temp HOME: 8530 pass, 19 skip, 0 fail.
Broken by hand on Linux, each red, then restored green:
- No probe in the .then: the slow cold-start test.
- probeSignedIn drops the list: the authorize and bounded-wait tests.
- agyPath change keeps the old offer: the agyPath test.
- Unbounded sign-in wait: the bounded-wait test (7514ms).
- Probe also on a failed listing: the hang test.
- origin/main's index.mjs with the new tests: all four #1064 tests.
- Adapter reads the list once: the warming adapter test, and the
copy-identity check.
Not tried: a real agy (no Google sign-in, no network). The reset after
login.finish has no unit test of its own.
Reported-by: hiee3
|
||
|
|
017cd73e87 |
catpaw: tests put back the fetch they found, and the rewrite keeps a Request's method, headers and body (#877, #988)
Fixes #877 (catpaw half). Test-only; no version bump. Change: catpaw's index.test.mjs saves the fetch it found and puts it back in afterAll (in a finally, so a failed server stop still restores it). Its URL-rewriting wrapper now builds `new Request(patched, input)` when handed a Request, so the method, headers and body survive the rewrite; init still applies on top. fake.mjs records each model-types request's method, an x-test-marker header and body, and a new test sends a POST Request through the wrapper and checks all three reach the fake. Kiro: its test files (usage, builderid, accounts, apikey, ...) already save and restore globalThis.fetch on main, unchanged since f379bf90; the per-file sweep below finds no kiro file leaving fetch changed. Ran (WSL magpie-desktop, Bun 1.4.2, HOME=$(mktemp -d)), at edecd806 and at edecd806 merged onto origin/main |
||
|
|
3e18b1a20d |
catpaw 0.2.2: out of credits is a 402 with the purchase link, not an answer (#933)
Out of credits, 妙手's gateway answers the turn HTTP 200 with the sentence "当前余额不足以完成本次操作。[去购买更多](https://credit.catpaw.meituan.com/#/plan), 即可继续使用全部功能。" as the assistant's text, in frames with no error field and no model / modelDisplayName. The plugin only read `error`, so the agent got the sentence as the model's answer (and with tools, the forced-tool retry spent a second turn on it). Now a frame that names no model and whose text, before anything was streamed, starts with "当前余额不足以完成本次操作" is the credit gate: the request fails 402 with {type: insufficient_quota, code: insufficient_credits, help_url, upstream_message}, the message with the markdown link spelled out as "去购买更多 (https://…)". magpie's gateway reads a 402 as failCredit: the account rests for credit and the next one is tried, not counted as broken. A head that could still grow into the sentence ("当前", "当前余额") is held until it does or doesn't; a model's answer quoting the sentence names its model and passes as text. "余额不足" in a round's msg, an SSE error frame or a non-200 body is a 402 too. Streaming requests now wait for the conversation's first event (up to 10s) before answering, so the 402, and a round or turn's bare 429 / 401, go out as their own status instead of an error chunk inside a 200. A slower turn streams as before. The bare 429 now says it is 妙手's rate limit with Retry-After: 45 (the reporter saw a ~41s cool-down), the bare 401 that the sign-in has expired; both keep the step and status. The fixture (testdata/issue-933.json) is the reporter's frames as the issue quotes them; the elided finishing frame is filled in, and the model fields of a normal answer are made up (the issue doesn't quote their values). Run in WSL (magpie-desktop) via wsl-run at this tree: - bun test packages/catpaw: 73 pass, 0 fail - bun scripts/check.mjs: exit 0, catpaw ✓ Broken by hand, each red, then restored: - no gate throw: 4 of the new tests red (both 402 paths, tools, split) - gate without the no-model condition: the quoting test red - plain stream not primed: 402-before-streaming, split and 429 red - tool stream not primed: the tools 402 and the 401 test red - held head never flushed: the held-head test red - 429 not mapped: the 429 test red Not tried: no real CatPaw account, so neither the gate nor the bare 429/401 was met against the real gateway; the 409/400 mapping the issue suggests for "会话未在执行中" is not done. Reported-by: LIEGU0317 |
||
|
|
46fef953c8 |
catpaw 0.2.1: the credits' refresh time is the window's reset, so Smart routing ranks the account (#867)
The 可用积分 window was always aside with no reset, so Smart routing never
ranked catpaw accounts by it. The credit/balance response the plugin
already reads carries userPlan.nextRefreshTime, a ms epoch string
("1796054400000"), when the plan's credits refresh. It is now the
window's resetsAt; magpie's Allowance.Renewal ranks by it, soonest first.
Why resetsAt and not runsOutAt (the issue's suggestion): 重置 is the
window's renewal; runsOutAt is for credits lost apart from a reset, and
with runsOut set the GUI would say "N credits expire", which nobody has
checked. Routing ranks both the same (Renewal takes the sooner).
used stays 0 and there is no limit: the vendor gives only the balance,
and a difference of balances would be made up. The GUI's rendering of
the window is unchanged (aside is not sent to it); it now shows the
reset line. A credit of 0 is not read as used 100: catpaw has free
models that may still answer.
No reason for aside was recorded (
|
||
|
|
087c36123d |
inkstone 0.1.3: image-caps preflight, a zero-prompt browser sign-in, key calls on the session cookie (#832)
inkstone 0.1.3 (#832, yunwang2442-creator): - Image requests are prechecked before they leave: 8 images, 10MB each, 40MB in all. - A request over a cap gets a local 400 shape refusal, so magpie asks the next account and rests none. - The plan's invalid_media / media_fetch_failed / unsupported_media_type errors become the same kind of refusal. - The body rewrite strips the reasoning fields and sets image detail to auto. - A zero-prompt browser sign-in comes first, and a second browser method reuses a pasted key. - Neither browser method is offered when no Chromium-family browser is found (#825). - The /keys calls ride the session cookie, without the pagination query. Key creation retries the console's -15100 "refresh page and retry". - The #826 metadata token read is kept, and its test is back. - The fake browser is built once per user and source hash (#824), and the title wait reads only on Windows. - maxConcurrency is 4. - The doubled comment line is dropped from every opencode2.mjs copy, agy-cli's included. Reviewed at 88e66bde, on mote (macOS, Bun 1.4.2) with a temp HOME: - full bun test: 6853 pass / 0 fail; both checks exit 0 - bun scripts/check.mjs and bun scripts/check.mjs inkstone: exit 0 - 21 hand breaks: 20 red, 1 not caught (the /keys pagination test calls protocol.listKeys directly; follow-up filed) Not tried: a real InkStone account or sign-in, Windows and Linux runs. |
||
|
|
e7004d9354 |
inkstone 0.1.0: Intern InkStone (书生·端砚) Token Plan, browser sign-in, credit card and ink-* key chat (#775)
New package @magpie-community/opencode-inkstone-auth 0.1.0 for Intern InkStone (书生·端砚, Shanghai AI Lab) Token Plan, provider id `intern-inkstone`. Community package by yunwang2442-creator. What it does: - Browser sign-in (Edge/Chrome, its own profile under $XDG_CONFIG_HOME or ~/.config/magpie/inkstone-browser, or %LOCALAPPDATA%\magpie\inkstone-browser). The login window has no debugging port. A headless CDP read takes the uaa-token cookie, and the same read renews it silently later. - Usage card: ink-credit balance, 5-hour and 7-day windows, credit packs. - Chat: a pasted ink-* API key, or one the sign-in creates, named ink-<host4>-<acct4>-<rand4> (18 of the console's 20 characters). An idempotency clash (-15109) retries with a fresh name, up to three times. Pruning is on by default. It only touches this machine's and account's prefix, keeps the newest two and the key this sign-in created, and never deletes manual keys or keys of unknown age. - Closing on Unix: SIGTERM, then SIGKILL only after a 15s grace. Leftover browsers are matched by --user-data-dir=<escaped profile>, and Windows uses .Contains(). - The login wait comes from an injected waitForLogin in tests. No env hook is left in production code. - Hosts: discovery.intern-ai.org.cn, discovery-api.intern-ai.org.cn, 127.0.0.1 (CDP). Outside the package: scripts/opencode2.mjs lets a prompt with `required: false` stay optional (`p.required !== false`). Every package's copy is synced byte for byte, so all 39 copies in the merged tree are blob |
||
|
|
73c56ec3c7 |
catpaw 0.2.0: tools over the flattened prompt, parsed back into tool_calls, one forced retry (#697)
catpaw 0.2.0 (gcdong, #697): the conversation protocol takes one flattened
text prompt, so a request with tools was refused with 400. Tools now ride as
an injected instruction and the reply is parsed back into OpenAI tool_calls:
only a reply that is wholly the call JSON (bare object or one fenced block)
counts, unknown names and calls missing a required arg are dropped, a
drifted name case is matched back. A forced tool_choice (required / named)
gets one retry with the failed reply in the prompt; streaming holds the
whole reply in that case, otherwise only a JSON-shaped head is held and
prose streams live. Tool results ride as text. Images are still refused.
The keep-alive interval is cleared wherever the stream closes.
Run at the reviewed head f72226f2, on mote:
- bun test packages/catpaw: 53 pass.
- Squashed onto origin/main
|
||
|
|
75cd0de91c |
catpaw 0.1.4: live models carry the client's multiplier and free badge
Reported by star21321321124 (Discord, 0.1.3): LongCat-2.5 showed no
multiplier and no free mark, while the table's LongCat-2.0 is named
"(限时免费)", so users may think it costs credits.
The desktop client (2026.1016.0032, renderer index chunk) draws each
model-types row as: name = description || extendedInfo.shortName ||
modelTypeName; badges = extendedInfo.marketingCopy split on commas;
multiplier = extendedInfo.rateMultiplier + "x". The plugin now reads those:
a live model is named with its badges ("LongCat-2.5 (限时免费)"), carries
magpie's existing `rate` (multiplier) and `free` (marketingCopy says 免费,
or a rate of 0), and a table model gets the list's rate/free unless the
user's config already set one. Ids are unchanged; a missing or unparsable
multiplier shows nothing, not 0.
Run: bun test packages/catpaw on mote (37 pass), bun run check ok. Broke
rateMultiplier parsing by hand: 3 tests red. Not tried: a real CatPaw
account; the fixture's extendedInfo values (string "0"/"1.5", marketingCopy
"限时免费") follow the client code, not a captured reply.
|
||
|
|
5d679712f0 |
catpaw 0.1.3: models the vendor adds appear without a release (LongCat 2.5)
star21321321124 (Discord, magpie v0.1.2862, catpaw 0.1.0/0.1.1): the vendor
added LongCat 2.5 and the plugin did not list it. The plugin's model list
was a hard-coded copy of an old proxy's table (9 models, each with its
modelType number). The desktop client keeps no such table: its main process
POSTs /api/agent/maas/model-types with {tenant: "CatDesk", scene:
"CATX_APP", env: "EXTERNAL"} on the gateway, caches the list 5 minutes, and
sends a model's modelTypeId as the round/turn body's modelType (read from
the 2026.1016.0032 client's dist-electron/main and catpawEnv chunks; items
carry modelTypeId, modelTypeName, provider, supportImage).
- index.mjs: provider.models reads that list with the account's own token
(desktop file or the stored web/paste token, as usage does) and adds what
the table lacks; a listed model whose type the table has keeps the
table's id and name, any other gets its modelTypeName lower-cased
(LongCat-2.5 -> longcat-2.5). Negative ids / USER_CUSTOM (the user's own
models) are left out. A chat on a table model costs no request; a chat on
any other id looks it up in the list and sends that modelType; an id in
neither is still a 400 naming what is known. A failed read leaves the
table. The headers are the plugin's gatewayHeaders, unchanged.
- fake.mjs: the list endpoint. 7 new tests: the request body, the extra
model offered, custom model left out, modelType sent on a chat, no
request for a table model, one read per 5 minutes, a failed read.
- README, version 0.1.3.
Run on mote at this tree: bun test packages/catpaw 35 pass 0 fail; bun
scripts/check.mjs exit 0; HOME=$(mktemp -d) bun test (root) 5303 pass, 19
skip, 0 fail.
Broken by hand, then restored: the lookup of an unlisted id returning null:
3 fail; provider.models ignoring the list: 2 fail.
Not tried: a real CatPaw account (none here), so the real response is
untested; the shape comes from the client's code. The id of LongCat 2.5
is whatever the vendor's modelTypeName is; if it differs from "LongCat-2.5"
the id will differ from longcat-2.5. Not the lists of the Windows client.
|
||
|
|
17e5ef7457 |
all: load on OpenCode 2.x through a default {id, setup} (#657)
nbczw8750 (#657): trae 0.2.26 on OpenCode 2.2.5 fails with "Plugin must export a default definition with an id and an effect or setup function. (cause: SchemaError(Missing key at ["default"]))". 2.x imports a package's exports["."] (a plugin dir and an npm install alike) and has no V1 path at all, so every package here that serves models failed the same way, not only trae. Every one of the 32 model packages now has: - opencode2.mjs, exports["."]: a copy of scripts/opencode2.mjs, an adapter that runs the package's V1 plugins inside 2.x's promise API. Config providers become 2.x providers (package pinned so the aisdk sdk hook runs), V1 auth methods become integration methods (oauth auto/code with forms; api without authorize as a key method), V1 credentials are kept in metadata.v1, the loader's baseURL, apiKey, headers and fetch are applied through the sdk hook, an auth.set renewal is stored per credential, and credential.switched /updated reload the account's own model list. - opencode.mjs, main: re-exports the V1 plugin functions only. OpenCode 1.x and magpie's host.js take main. On 1.x, trae 0.2.26's main exported a non-plugin (_internal) and 1.19.5 refused it ("Plugin export is not a function"); the new main fixes that too. - both files in "files"; patch version bumped. devin already had 2.x and is unchanged. scripts/check.mjs fails a model package whose 2.x entry has no default {id, setup}, whose opencode2.mjs differs from the canonical one, whose entry is missing from files, or whose main exports a non-plugin. Run at this head (mote): - HOME=$(mktemp -d) bun test, as CI runs it: 4900 pass, 0 fail (4914 tests, 374 files). A first run set globalThis.fetch for the whole process from opencode2.test and failed 528 tests in other packages; the block is now set and put back around that file's tests. - bun scripts/check.mjs: every package passes. With the network blocked cloudflare-workers-ai fails on its fetched catalog, the same on origin/main. - Real OpenCode 2.2.5 (npm opencode-ai), sandbox HOME, packed trae 0.2.27: loads with no error; /api/integration lists trae-cn "Trae CN" and trae-global "Trae Global" with their browser sign-ins; `auth login` starts the trae.cn authorization and waits (cancelled there); with a fake credential POSTed to /api/credential, `opencode models` lists trae-cn's six models. - Real 2.2.5 with a fake V1 key plugin through the same adapter against a local fake server: `auth login` with a key, `models`, `opencode run` reached /real/v1/chat/completions with the loader's "Bearer loader-sk-fake" and header, and printed the fake's reply; with @ai-sdk/anthropic it reached /real/v1/messages with x-api-key from the loader. This run found the key method missing after 2.x's second integration transform (a once-only flag outside the transform); fixed, and opencode2.test checks a rebuild. - Real OpenCode 1.19.5, sandbox HOME, trae 0.2.27: `opencode models` lists trae-cn and trae-global models; 0.2.26 failed there. Broken by hand (scratch copy, bun test scripts/ and check.mjs): - trae's exports back to "./index.mjs": the trae 2.x test fails (default.id undefined), check fails trae with "OpenCode 2.x: ./index.mjs has no default {id, setup} (plugins#657)". - zed's opencode2.mjs changed: the copies test fails, check fails zed "differs from scripts/opencode2.mjs". - the key flag back outside the transform: the 1.x plugin test fails on the rebuilt sign-ins (key missing). Not tried: a real sign-in with a real account on 2.x; Windows (the reporter's OS); chat.headers, chat.params, usage and tool hooks, which the adapter doesn't carry to 2.x; the tools/pages packages (calc, goanyapi, layerfs, search1api, aelios, agent-console, chat, fingerprint, nowledge-mem, kimi-desktop), which still load only on 1.x. |
||
|
|
8db0a0576a |
catpaw 0.1.1: round and turn send source CatX / mode CATX_APP; the gateway turned CatPawCLI off (#605)
Reported by 1007cordon-ux in #605: every chat with 0.1.0 failed at the round step with "妙手 round 失败:HTTP 200 code=400 msg=source 不存在或未启用: CatPawCLI". The 10-09 capture the package was built from was the CatPaw CLI's (source CatPawCLI, mode CLI, m-appkey com.sankuai.mcopilot.cli); the gateway no longer serves that source. The reporter changed both bodies to source CatX / mode CATX_APP, kept the headers, and got a normal completion from catpaw/glm-5.3-flashx through a real gateway request. That is the combination the package README documented from the start, and the same author's magpie-catpaw-auth 0.2.3 on npm sends it with these same headers. - index.mjs: one frozen BODY_IDENTITY ({source: "CatX", mode: "CATX_APP"}) spread into both the round and the turn body, so they can't differ. Headers unchanged (m-appkey com.sankuai.mcopilot.cli, x-agent-version 1.2.0-beta.6, axios UA). - fake.mjs: answers a disabled source (CatPawCLI) with HTTP 200 {code: 400, msg: "source 不存在或未启用: <source>"}, the body behind the report, and refuses a turn whose source/mode differ from its round's. - testdata/issue-605.json holds the reporter's line verbatim; a test checks that the fake's refusal, put through the plugin's round error format, is that line byte for byte. - README: the protocol note says why the body isn't the capture's. Not confirmed: whether the official CatX desktop app sends a different m-appkey or x-agent-version. No official client is on npm, and the CatPaw sites offer no download without signing in, so the headers stay the captured CLI's (the reporter's verified combination). Run on mote at this tree (mote-run -C the worktree): - bun test packages/catpaw: 28 pass, 0 fail - HOME=$(mktemp -d) bun test (root): 4550 pass, 9 skip, 0 fail, 352 files - bun scripts/check.mjs: exit 0 (catpaw ✓) Broken by hand, then restored: - BODY_IDENTITY back to CatPawCLI/CLI: 9 fail, each chat error the reporter's exact text ("妙手 round 失败:HTTP 200 code=400 msg=source 不存在或未启用: CatPawCLI"). - only the turn body back to CatPawCLI/CLI: 5 fail. Not tried: a real CatPaw account (none available); the fix rests on the reporter's real request. |
||
|
|
eeb344f174 |
catpaw: add the Meituan CatPaw plugin (#174)
Adds packages/catpaw (Meituan CatPaw): sign-in, paste-token sign-in, models, chat and usage. Hosts: ai.catpaw.meituan.com and catx.nocode.cn only; no dependencies or scripts; captures redacted. Answers the 10-17 review: the request body's source/mode is CatPawCLI/CLI, matching the captured CLI round (testdata/captured-round.json, captured-turn.json) and enforced by the fake; the non-stream usage block that wasn't in the capture is gone; a no-credit error keeps the sign-in; the paste method returns a callback as the host calls it. Run at 475979a (PR head 71f36ce with origin/main merged, loomy #175 included; registry.json conflict resolved keeping both entries), on mote with a sandbox HOME: - bun test packages/catpaw: 24 pass, 0 fail - bun scripts/check.mjs: exit 0 (catpaw ✓); bun test scripts: 3 pass, 0 fail - Broken by hand, then restored: identity reverted to CatX/CATX_APP (8 fail), paste callback reverted (1 fail). The no-credit signIn:"kept" has no test (removing it stays green). Not tried: a real CatPaw account. Not on npm yet: served from the dist branch until the first version is published by hand. |