20 Commits
Author SHA1 Message Date
yetone 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
2026-11-13 10:59:13 +08:00
zhou.han 92c20ffef6 Eight auth hooks declare rotating refresh tokens (#1027)
Eight auth hooks declare `rotating: true`: cline, codearts (and OfficeAce),
factory, minimax, nous, qoder, sensenova, workbuddy. Each package's own
code says the vendor refuses a spent refresh token. magpie then stops
carrying these sign-ins to another computer through Sync, a backup or a
Restore (internal/provider/signins_carry.go). Trae was dropped: its refresh
keeps the old token when the answer has none, and there is no evidence it
rotates. Each package's patch version is bumped (cline 0.1.15, codearts
0.3.13, factory 0.1.46, minimax 0.2.9, nous 0.1.3, qoder 0.2.66, sensenova
0.2.3, workbuddy 0.2.30). Each was checked against npm, or against
origin/dist for the dist-only packages, before the merge.

Fixes #884.

Run at cc2f9199 (a fast-forward of origin/main), on mica with a temp HOME:
bun test over the eight packages gave 1588 pass, 0 fail, and
scripts/check.mjs exited 0. CI's test and on-npm jobs pass. At 45c8fdb4,
mote gave 1834 pass with Trae included.
Not tried: a real refresh against each vendor.

Co-authored-by: yetihan <yetihan@users.noreply.github.com>
2026-11-12 10:52:16 +08:00
我是一条没有名字的区 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.
2026-11-07 22:24:56 +08:00
我是一条没有名字的区 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
afe074cb. No other package sets `required: false` on a prompt, so this
changes nothing for them. Also a root README row and a registry entry.

Review at 36412a15, on mote, HOME=$(mktemp -d), Bun 1.4.2:
- bun test packages/inkstone: 68 pass, 0 fail in Asia/Shanghai, UTC,
  America/Los_Angeles and Pacific/Kiritimati.
- bun scripts/check.mjs inkstone and bun scripts/check.mjs: ok.
- bun test (repo), on 36412a15 merged with origin/main e7cb9dc5:
  6743 pass, 20 skip, 0 fail. main has since moved by cline 0.1.14 and
  zcode 0.1.55 only, and none of the adapter copies changed.
- Broken by hand, each red: no protectName protection; prune_keys default
  off; no post-sign-in prune; no SIGTERM on close; the -15109 retry keeping
  its name.

Not tried: a real InkStone account sign-in on macOS, Linux or Windows (no
account here); a live chat request; magpie end to end with the plugin.
2026-11-07 15:07:06 +08:00
yetone fa310fa9c3 cline 0.1.14: the own-routing test runs with the pin on; the pin is turned on by plugin option, not magpie's tick
Follow-up to #819 (0.1.13).

Changed:
- index.test.mjs: "the user's own provider or providerOptions on a
  ClinePass DeepSeek request is left as they set it" and "a client's own
  providerOptions refused by Cline is passed through" now run with
  `{ pinUpstream: true }`. Without the pin on they passed whether or not
  fetch kept the client's own routing field.
- README and the 403 hint: the pin is turned on and off by the plugin's
  pinUpstream option (`magpie plugin options
  @magpie-community/opencode-cline-auth '{"pinUpstream": false}'`, or the
  OpenCode plugin/provider.cline options). magpie's Upstream tick is
  magpie's own setting; it never set this option, and magpie no longer
  writes providerOptions for it (yetone/magpie#5442).
- 0.1.14. A client-sent providerOptions is handled as in 0.1.13.

Run on mote, HOME=$(mktemp -d), Bun 1.4.2, at this tree on 39f59971:
- bun test packages/cline: 92 pass, 0 fail.
- bun test (repo): 6569 pass, 20 skip, 0 fail.
- bun scripts/check.mjs cline: ok (registry.json, cline).
- Broken by hand: fetch's `ownsRouting(chat) ? null :` removed, both
  own-routing tests red (2), green with it back.

Not tried: a live Cline request (no Cline key here).
2026-11-07 14:58:19 +08:00
Xyfer 39f59971c0 cline 0.1.13: no default DeepSeek pin; a refused providerOptions pin says how to turn it off (#819)
Since 2026-11-06 Cline answers any client-supplied `providerOptions` with
403 `client-supplied "providerOptions" model routing is not supported`
(yetone/magpie#5442). 0.1.12 pinned ClinePass's DeepSeek models with
`providerOptions` by default, so every such request failed unless the user
set `pinUpstream: false`.

Changed:
- No pin by default. `providerOptions` / `provider` is written only with
  `pinUpstream` on, and the pins themselves are the same as 0.1.12. The
  default pin's unpinned retry (`unpinWorthy`) is gone with it.
- A pin this plugin wrote that Cline refuses with that exact 403 comes back as
  a 403 that says to turn the pin off. It is not retried unpinned. A client's
  own `providerOptions` refusal is passed through as Cline sent it.
- README and comments: the 11-06 refusal, and glm-5.3-flash's top-level
  `provider.only` being accepted but ignored (finalProvider stayed
  `openai-compatible-private` in the author's live checks).
- 0.1.13.

Author's live checks (Cline API key): default Pass DeepSeek 200; pinned 403
with the hint and no retry; glm-5.3-flash 5/5 200 with the pin on or off,
finalProvider `openai-compatible-private`.

Review run at a2d43859 (on main 367edb50), on mote, HOME=$(mktemp -d),
Bun 1.4.2:
- bun test packages/cline: 92 pass, 0 fail.
- bun scripts/check.mjs cline: ok.
- bun test (repo): 6563 pass, 20 skip, 0 fail.
- Broken by hand, each red: the default pin back; the hint for any
  providerOptions 403; ROUTING_REJECTION unanchored; a retry on the refusal;
  no JSON-envelope read. Dropping ownsRouting on fetch's pin stays green: the
  own-routing test runs without pinUpstream now (follow-up).

Not tried by the review: a live Cline request (no key), magpie's gateway with
0.1.13 end to end. Follow-ups in magpie: ClinePassAsked still assumes a
default plugin pin, and the Upstream tick still sends providerOptions
(yetone/magpie#5442 stays open).
2026-11-07 09:54:22 +08:00
yetone 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.
2026-11-03 13:54:26 +08:00
yetone 61d058f6cf cline 0.1.11: ClinePass's DeepSeek models are pinned to DeepSeek's own API by default, with only + has, and go once more unpinned if the pin can't be served (hy125245 on X)
hy125245 (X, 10-23) pinned Cline Pass to DeepSeek by hand with magpie's
extra body, `"!providerOptions": {"gateway": {"only": ["deepseek"],
"has": ["vision", "implicit-caching"]}}` on a plain API provider for
https://api.cline.bot/api/v1, model cline-pass/deepseek-v4.1-flash-1017.
Their finding: on ClinePass the server's virtual model config wins over
`only` alone (a fake upstream was served too); with `has` beside it the
request went to DeepSeek (finalProvider "deepseek", magpie's Requests
list "vmc/deepseek-v4p1-flash … 上游: de…", ~200-246 tok/s, 3 of 3) and
a fake upstream was refused with "no matching upstream". The bill showed
creditsUsed 0.

What changed
- A request for a cline-pass/deepseek-… model now carries
  providerOptions.gateway {only: ["deepseek"], has: [...]} by default,
  written in before the body's last } so the cached prefix is the
  client's byte for byte.
- `has` is "implicit-caching", plus "vision" only for a model that takes
  images: Cline's catalog (/ai/cline/models input_modalities, read by
  the models hook; the bundled list says so for deepseek-v4.1-flash and
  -1017 until it answers) or a request carrying an image part. The
  catalog lists deepseek-v4-pro as text-only, and asking vision of it
  would rule out every upstream.
- A request that already has provider or providerOptions (the client's,
  or the user's extra body in magpie) goes as sent, as before: magpie's
  default never overrides a value the user set.
- The default pin never fails a request that would have worked: a
  pinned request answered with no matching upstream (or "no available
  provider/endpoint") or any 5xx goes once more exactly as sent, same
  account and headers. Once only. A 400 of another kind, 401, 402, 403
  and 429 are the request's or the account's, answered as they are.
- pinUpstream: false (or "false") turns it off. pinUpstream on keeps its
  meaning ("only from the makers' own APIs"): ClinePass DeepSeek models
  get the only + has pin with no unpinned retry; other DeepSeek and GLM
  models are pinned as in 0.1.10.
- Non-DeepSeek ClinePass models, cline-free/deepseek-…, usage-billed
  deepseek/… (without pinUpstream) and every other model go as sent.

Decision (owner delegated product calls): default on for ClinePass's
DeepSeek models. The reporter measured DeepSeek's own API faster than
the private landing, credits unchanged (0), and DeepSeek's API caches by
itself; the retry removes the one downside (a pin that can't be served).
Not made per model: nothing measured says another default is right for
some users.

Run (at this commit, rebased on origin/main)
- bun test packages/cline: 93 pass (11 new).
- HOME=$(mktemp -d) bun test (whole repo, as pr.yml): 0 fail.
- bun scripts/check.mjs: all packages ok.

Broken by hand, each red:
- no default pin: 8 fail (pin, catalog vision, three fallback cases,
  retry-once, pinUpstream off/on, glm-5.3-flash table test).
- the user's providerOptions overridden: 3 fail, incl. the reporter's
  extra body kept word for word.
- no fallback: 4 fail.
- every cline-pass/ model pinned: 6 fail, incl. "other models go as sent".
- vision asked always: 2 fail.

Not tried
- No real Cline account: magpie has no Cline sign-in (plugin-auth.json
  has none, providers.json none; ~/.cline holds only other vendors'
  keys), and api.cline.bot answers 401 before routing, so none of
  finalProvider, speed, creditsUsed, caching, the text-only
  deepseek-v4-pro under has: ["implicit-caching"], or the exact wording
  of the no-upstream refusal was measured here. Built from the
  reporter's description; the fallback covers a wrong guess about
  what the gateway refuses.
- Other Pass models (GLM, Kimi, Qwen, MiMo, MiniMax) may have private
  vs official upstreams too; unmeasured, left unpinned.
- magpie's own ClinePass tick still writes `only` alone before the
  plugin sees the body; fixed in magpie separately.
2026-10-23 22:14:18 +08:00
yetone 7a74416a4d cline 0.1.10: pinUpstream pins glm-5.3-flash through OpenRouter's provider.only (sdytman on Discord)
The plugin's side of magpie d2c434b5a. Cline sends glm-5.3-flash through
OpenRouter directly, not Vercel's AI Gateway, and OpenRouter ignores
providerOptions.gateway.only, so pinned() gave it ["zai"] where nothing
reads it. OpenRouter reads a top-level provider.only with its own slug,
"z-ai" for Z.AI. MAKERS is now magpie's clineMakers table: glm-5.3-flash
by exact name -> provider.only ["z-ai"]; deepseek* -> providerOptions
["deepseek"] (deepseek-v4.1-flash and -1017 go through Vercel); glm* ->
providerOptions ["zai"] (glm-5.3-flashx, glm-5.3 stay there). pinned()
returns {upstream, openRouter} or null. pinBody appends the field at the
body's end so the cached prefix is unchanged, and leaves a body naming
provider or providerOptions itself as sent.

Tests: "pinBody pins glm-5.3-flash by OpenRouter's provider.only" and the
loader test now sending glm-5.3-flash; both red on the old index.mjs
(providerOptions zai, no provider), green with the change. Not tried with
a real ClinePass request: no account here.

Run on origin/main 6fd976a: TMPDIR=<scratch> HOME=<scratch>/home bun test
(whole repo) 1919 pass 0 fail across 173 files; bun scripts/check.mjs ok.
2026-10-21 01:52:44 +08:00
yetone ff13aac87d cline 0.1.9: pinUpstream pins GLM models to Z.ai's own API too (sdytman on Discord)
sdytman (#feedback, 10-19): "clinepass供应商现在可以勾选deepseek模型只走deepseek官方上游,建议glm也加一个勾选选项,只走z.ai上游".

With pinUpstream on, a request for a GLM model (cline-pass/glm-5.3,
cline-pass/glm-5.3-flash, any non-free id whose name starts with glm)
now carries "providerOptions":{"gateway":{"only":["zai"]}}, as a
DeepSeek one carries ["deepseek"]. cline-free/ models, other makers'
models and a body with providerOptions of its own go as sent. One
option covers both: it means "the maker's own API" for each.

The slug: Cline's gateway is Vercel's AI Gateway (the ProviderPin
author on linux.do/t/topic/2918145: "锁在Vercel的DeepSeek官转上";
providerOptions.gateway.only is that gateway's option).
ai-gateway.vercel.sh/v1/models/zai/glm-5.3/endpoints and
.../zai/glm-5.3-flash/endpoints list provider_name "zai" (and
deepseek/deepseek-v4-pro lists "deepseek", the slug already pinned).
Not tried with a real ClinePass key (none on this machine).

Run: bun test packages/cline/index.test.mjs, 75 pass; the whole suite
(TMPDIR and HOME under a scratch dir) 1825 pass, 0 fail; bun
scripts/check.mjs ok. Broken by hand, each goes red: no glm entry (3
tests), cline-free/ not skipped (1), every maker pinned to zai (3), the
client's providerOptions overwritten (1).
2026-10-19 18:40:54 +08:00
yetone e8fdbdb616 cline 0.1.8: a model takes images where Cline's catalog says it does, not "text only" for every model (silent on Discord)
runtimeModel said input.image false for every model, so magpie, which
takes a plugin's said capability over models.dev's, treated ClinePass's
DeepSeek V4.1 Flash and GLM 5.3 Flash as text-only: the image tick stayed
off and images went to a describer model.

/ai/cline/models already carries architecture.input_modalities (Cline's own
client reads images from it). fetchCloudModels now keeps it; a feed model
gets its own entry's, else the entry of the model after its prefix
(cline-pass/deepseek-v4.1-flash is deepseek/deepseek-v4.1-flash; :batch
variants count as the model) when every such entry agrees. Where the
catalog says nothing, image is left unsaid, so magpie asks models.dev
instead of being told no. attachment follows image.

Run: bun test packages/cline (80 pass); the new hook test fails with the
old hardcoded input (79 pass, 1 fail); bun scripts/check.mjs cline passes.
The models hook against Cline's live public catalog (no sign-in) gives
cline-pass/deepseek-v4.1-flash and glm-5.3-flash image true, glm-5.3 and
deepseek-v4-pro false, qwen3.8-max unsaid. Not tried with a signed-in
ClinePass account sending a real image.
2026-10-14 23:10:01 +08:00
yetone d335db0a6e cline 0.1.7: ClinePass limits that fail to read say why on the card, and limits read are kept when the balance fails (#79, AkaChou)
usage read /users/me/plan/usage-limits with .catch(() => null), so every
failure there (401, 403, 429, 5xx, a timeout, a {success:false} envelope)
looked like an account without ClinePass: the card showed the balance
alone and said nothing. Only a 404 means no ClinePass (AxonHub's Cline
checker reads it the same way); any other failure now sets the usage
error "ClinePass limits couldn't be read (HTTP n: ...)" beside the balance,
the sign-in kept. clineApi's errors carry the HTTP status for this.

When /users/me or the balance failed, usage returned an error alone and
dropped the limits already read. Now the windows read are returned with
no error when the balance can't be; a failed /users/me still tries the
signed-in account's uid for the balance, and only a lapsed /users/me is
the sign-in gone. With nothing read at all, the balance's failure is the
error as before.

Tests (real reply shape {success, data: {limits: [{type, percentUsed,
resetsAt}]}}, 404 for no ClinePass): limits failing with 403, 401, 500,
429, a refused envelope and a network error; balance failing with
limits read; /users/me failing with limits read; neither read. The 8 new
cases fail on 0.1.6 (bun test: 70 pass, 8 fail) and pass now (78 pass);
bun scripts/check.mjs passes. Not tried against a real Cline account
(none at hand).
2026-10-10 20:14:47 +08:00
moxuun 7e79ad90b0 cline: reuse task ID per chat session for prompt caching (#69)
* cline: preserve ClinePass prompt cache across requests

* cline: limit task ID omission to affected models

* cline: reuse one task ID per chat session
2026-10-10 15:06:48 +08:00
wizzy-yangandwizzy-yang f791646a91 cline 0.1.5: a balance with no whole is the card's balance, not a meter — an account Cline serves only {balance} got a Credits window with used 0, so the card read a full bar and "100% left" whatever the balance ($0.48 in the report). The balance now goes to the card's balance field, as magpie's built-in Cline says it; a whole still makes a window, carrying amount of limit (#659). "a balance with no whole is the card's balance, not a meter" fails on 0.1.4; bun test packages/cline (67 pass) and bun scripts/check.mjs cline pass. (#36)
Co-authored-by: wizzy-yang <wizzy-yang@users.noreply.github.com>
2026-10-07 18:45:30 +08:00
yetone 838f6470dc cline 0.1.4: usage shows ClinePass's 5-hour, weekly and monthly limits (zRain on Discord) — ClinePass counts usage against a rolling 5 hours, the calendar week and the calendar month, but the plugin's usage showed only the credit balance. It now also reads /api/v1/users/me/plan/usage-limits, what app.cline.bot's subscription page reads ({limits: [{type: five_hour|weekly|monthly, percentUsed, resetsAt}]}), with the same bearer, as 5 hours / Weekly / Month windows with their spans and resets. An account the limits can't be read for (no ClinePass) keeps its balance and its sign-in. bun test and check.mjs pass. 2026-10-05 16:17:38 +08:00
yetone 98ce4a8dc0 cline 0.1.3: a pinUpstream option sends DeepSeek's models through DeepSeek's own API only, as magpie's built-in ClinePass tick does (ARNO on magpie's Discord) — with it on (the plugin's own options, or OpenCode's provider.cline.options.pinUpstream), a chat request for a DeepSeek model (cline-pass/deepseek-…, not cline-free/) carries "providerOptions":{"gateway":{"only":["deepseek"]}}, written in before the body's last } so the cached prefix is the client's byte for byte. Other models, and a request with providerOptions of its own, go as sent; off by default. README says how to turn it on in magpie and OpenCode. 5 new tests fail on 0.1.2; bun test (63 pass) and bun scripts/check.mjs cline pass. 2026-10-05 12:42:21 +08:00
yetone 3ad0e49baf cline 0.1.2: each model says the context window Cline's catalog gives it, rather than none (Discord, ARNO on magpie v0.1.815: cline插件的模型都没有默认的上下文窗口大小) — configModel and runtimeModel wrote limit {context: m.context ?? 0, output: 0} and nothing ever set m.context, so every Cline model came to magpie and OpenCode with a window of 0. Cline's /api/v1/ai/cline/models (the cloud catalog the plugin already merges in) gives each entry OpenRouter's context_length and top_provider.{context_length, max_completion_tokens}: fetchCloudModels now keeps the window as context (tokens(): a positive count, strings read as numbers), and fetchFeed gives a recommended-feed model the catalog's window for its id, as the recommended feed has none. The reply limit stays 0: max_completion_tokens can be most of the window (kimi-k3 943718 of 1048576), and OpenCode keeps a model's output limit free of its window, so it would compact a tenth of the way in. The cline-free/… and cline-pass/… ids aren't in that catalog and still say 0; magpie takes models.dev's window for the id after the prefix there (README says so). index.test.mjs gains "the models hook gives each model the window Cline's catalog has for it, and no reply limit" (fails on 0.1.1); bun test (59 pass) and bun scripts/check.mjs cline under a temp HOME pass. Against the live api.cline.bot (no sign-in): 466 of 484 models now carry a window (claude-sonnet-5.5 1000000/128000, gpt-6.1-sol 1050000/128000, kimi-k3 1048576/943718 as Cline gives it), cline-free/mimo-v2.6-flash 0. Not tried with a signed-in Cline account. 2026-10-04 13:36:38 +08:00
yetone c64f555ebd cline 0.1.1: magpie renews the sign-in ahead of time through auth.refresh
auth.refresh with refreshLead 10 minutes (in-fetch: 5). It spends the
refresh token under the same lock as a request's refresh and records what
each refresh gave, so the two never spend one token twice. Cline refusing
the refresh token is signIn "expired"; anything else throws and is retried.

The check before each request stays for OpenCode, which doesn't call the
hook (magpie 0.1.684+ does). refresh.test.mjs fails without the change;
HOME=$(mktemp -d) bun test passes (396 across the repo).
2026-10-03 12:07:22 +08:00
yetone 8f25b63718 publish from GitHub Actions with npm's trusted publishing, no one-time password [skip ci]
.github/workflows/publish.yml runs the tests (in a throwaway HOME) and
scripts/publish.sh on each package.json change pushed to main, or by hand;
npm's OIDC exchange stands in for a token and an OTP. Every package now
names magpie-community/plugins' publish.yml as its trusted publisher on
npmjs.com, and gets the repository field npm checks it against.
2026-10-03 00:00:23 +08:00
volcanic 8b4f759455 Cline: usage billing, ClinePass and the free models, with Cline's own device sign-in or an API key (#2)
* Cline: usage-billed models, ClinePass's and Cline's free ones, on your own Cline account — Cline's device sign-in (WorkOS device code, traded at /auth/register) or an API key; chat completions on api.cline.bot with Cline's own client-identity headers (pinned to the current CLI release — what the free models' gate reads), the non-stream data envelope unwrapped, the model list from Cline's recommended-models feed, usage from the account's balance (counted in millionths of a dollar). cline-pass answers 403 ENTITLEMENT_ERROR without the subscription and the message says so; so does an empty balance, with the top-up URL.

* cline 0.1.0: the pinned CLI version and the workos: prefix move to Cline's current client — apps/cli is at 3.0.68, and provider-auth-registry's formatProviderOAuthApiKey lowercases before it startsWith("workos:") so a token stored as WorkOS: is not double-prefixed here either; bearerOf's "once" test fails against 0.1.0.

* cline 0.1.0: the model list is Cline's whole catalog, not just the recommended feed — the title promised usage-billed models but the plugin read only recommended-models (6 paid models), while Cline's own clients also load /api/v1/ai/cline/models (loadCloudModels), so most usage-billed models were missing. The four feed arrays are now read by name instead of walking every value (a tag or description could become a model, and one in both recommended and free lost its "(free)"), clineCloud stays out as the client leaves it out, a raw-id name is prettified, and the bundled snapshot drops gemini-2.5-pro and minimax-m2.5 (not in cline-recommended.generated.ts) and gains the missing cline-pass/* entries; the parseFeed, snapshot and models-merge tests fail against 0.1.0.

* cline 0.1.0: a refresh failure no longer fails a request that still has a good token, and a rotated pair survives a failing auth.set — a 4-minute token plus a 500 from /auth/refresh answered the chat 502 and never sent it, and with auth.set throwing the next request re-spent the old refresh token, got invalid_grant and marked the account expired. fresh now keeps the current token on a transient failure while it is still good (Cline's getValidClineCredentials), failing only once it has expired, and the latest rotated pair is held in memory beside the save (kiro's held), used when getAuth still hands back the spent token; the still-good-token and rotated-pair tests fail against 0.1.0.

* cline 0.1.0: failure() keys on Cline's error codes and whole phrases, not loose substrings — a 403 whose text mentioned "tokens" (max_tokens exceeds…) became "the sign-in lapsed — sign in again" and lost the real message, and any message containing "credit" became a 429 usage limit. The 401/403 token check, the out-of-credits and entitlement checks and the 429 check now match what Cline's client matches (ENTITLEMENT_ERROR, insufficient_credits, SPEND_LIMIT_EXCEEDED, the not-subscribed wording), and a renewed token clears the lapse mark through the error path too as qoder's renewed() does; the codes-and-phrases and renewed-mark tests fail against 0.1.0.

* cline 0.1.0: device polling grows the interval for good and rides out a bad poll — slow_down raised it for one poll only (RFC 8628 and Cline's pollWorkOSTokens do interval += 1 permanently), the minimum was 0.25s where the client clamps to 1s, and a single 5xx, non-JSON reply or network error ended the sign-in with "the token answer had no access token". The poll now keeps polling through those; the slow_down, one-second and bad-poll tests fail against 0.1.0.

* cline 0.1.0: the held pair covers every refresh token this run has spent, not only the last — when auth.set goes on failing (which a store that failed once usually does) getAuth keeps handing back the first pair, and a second rotation overwrote held.from, so the third request refreshed the already-spent r1 again: /auth/refresh went r1, r2, r1 and the chat answered 401 expired. held.from is a Set every rotation adds to now, and the held pair is used whenever the refresh token getAuth hands back is in it; the two-rotation test fails against 0.1.0 (200, 200, 401).

* cline 0.1.0: X-CORE-VERSION moves to 0.0.90 with the CLI release — the header set pinned 3.0.68 beside 0.0.89, but cline@3.0.68 depends on @cline/core 0.0.90 (0.0.89 is what 3.0.67 shipped) and resolveProviderRequestHeaders sends X-CORE-VERSION from that dependency, so the number the comment calls the one that has to match was a release behind; the client-header test pins the pair now and fails against 0.1.0.

* cline 0.1.0: a poll reply that isn't JSON and isn't a 5xx fails the sign-in at once — a body that wouldn't parse was read as WorkOS having a moment, so an HTML 400 (a proxy's error page, say) kept the poll going to the deadline, ten minutes, before failing there anyway. Only a network error and a 5xx are a poll to try again now; a 4xx that isn't JSON is the poll refused. The refusal test fails against 0.1.0.

* cline 0.1.0: a renewal's mark survives a network error on the chat itself — the 502 the fetch throws after a renewal returned without signed(..., renewed(cred)), so the request that never left the machine dropped the mark while the request that came back refused kept it; it is wrapped the way the !res.ok path is. The network-error test fails against 0.1.0.

* cline 0.1.0: the held pair is kept per rotation chain, so no account is sent on another's token — magpie calls ClinePlugin once for the provider and hands every account its own getAuth, so the one `held` pair outlived them: with two accounts, a save failing every time and every token wanting renewal, A, B, A went out as A-jwt1, B-jwt1, B-jwt2 and A's third request refreshed with B's token, spending it and billing B (yetone's two-loader repro, page-for-page the same). A spent refresh token now maps to the newest pair its own chain reached — the token getAuth handed back and the one the refresh spent both point at that chain — so a request offering either finds its own account's pair; the per-chain test fails against 0.1.0 on the third request's Authorization, with the 51 before it passing.
2026-10-02 23:03:54 +08:00