Files
plugins/packages/cline
我是一条没有名字的区 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
..

@magpie-community/opencode-cline-auth

Cline (cline.bot) on your own Cline account: the models Cline's gateway serves — usage-billed models, ClinePass's and Cline's free models alike. Provider id: cline.

Signing in

  • Cline device sign-in — the flow Cline's own client runs: the plugin asks WorkOS for a device code and opens the approval page, polls until you approve, then trades the WorkOS tokens at Cline's /api/v1/auth/register for the account's own token pair.
  • Cline API key — create one at app.cline.bot → Settings → API Keys and paste it. Sent as a plain Bearer key.

The sign-in is kept where OpenCode keeps auth (auth.json under the data directory); magpie keeps plugin sign-ins in its own store (~/.config/magpie/plugin-auth.json).

Refreshing:

  • Access tokens are renewed through /api/v1/auth/refresh. Cline rotates the refresh token and refuses one already spent, so the rotated pair is kept in memory beside the store the moment it arrives: a save that fails can't leave the next request spending the token that was already spent.
  • magpie renews the token ten minutes before it ends, through the plugin's auth.refresh, once for the account and before its requests, models and usage need it; magpie saves the new pair. OpenCode doesn't call that hook: there the token is refreshed five minutes before it ends, before a request, and the new pair is saved.
  • Refreshes are serialized, magpie's renewal included, so two at once can't spend one token and lose the other; one that finds the token already renewed uses that pair.
  • A refresh that fails for a while keeps the token that is still good, as Cline's own client does (magpie tries its renewal again shortly); only a refresh Cline refuses, or a token that has actually expired, is treated as the sign-in gone.

Requests

Chat completions go to https://api.cline.bot/api/v1/chat/completions in OpenAI's format (streaming included), with Authorization: Bearer workos:<access token> for a signed-in account or the raw API key, and the full client-identity header set Cline's own clients send (HTTP-Referer, X-Title, User-Agent: Cline/<version>, X-CLIENT-TYPE: cline-cli, X-CLIENT-VERSION, X-PLATFORM, X-PLATFORM-VERSION, X-CORE-VERSION, X-IS-MULTIROOT) — pinned to Cline's current CLI release, which is also what the free models' gate reads; when Cline ships a new release, move the pinned numbers in index.mjs along. All models use one X-Task-ID per named chat session, derived as a UUID from the session. With no named session (including magpie's synthetic id from the first user message), no task id is sent. The session crosses the plugin's hooks in a private header that is removed before the request goes to Cline. Auth and account requests carry the same identity. A finished non-streaming answer rides in a {"data": …} envelope the official clients take apart; the plugin takes it apart too. The model list is read from /api/v1/ai/cline/recommended-models and /api/v1/ai/cline/models (neither needs a sign-in); usage reads /api/v1/users/me and the account's /balance (its balance is counted in millionths of a dollar), and ClinePass's 5-hour, weekly and monthly limits from /api/v1/users/me/plan/usage-limits ({limits: [{type, percentUsed, resetsAt}]}, what app.cline.bot's subscription page shows). An account without ClinePass (a 404 there) has none; limits that fail to read for any other reason say so on the card beside the balance, and limits read are kept when the balance can't be.

Upstream pinning and Cline's routing policy

Cline's gateway picks among the providers that serve a model. A request can ask for the maker's own API, but Cline changed what it accepts:

  • Since 2026-11-06, Cline refuses providerOptions routing. A request carrying "providerOptions" is answered with 403: client-supplied "providerOptions" model routing is not supported (magpie#5442). This applies to ClinePass DeepSeek models and to the usage-billed DeepSeek/GLM models that Cline sends through Vercel's AI Gateway.
  • glm-5.3-flash still works, but is not actually pinned. Cline sends it through OpenRouter, so the plugin writes a top-level "provider": {"only": ["z-ai"]} rather than providerOptions (since 0.1.10). Cline does not reject that field; it ignores it. In five live requests with the Upstream tick on, provider_metadata.gateway.routing.finalProvider stayed "openai-compatible-private" (and canonicalSlug was private/cw-glm-53-flash), so the request succeeds but stays on Cline's own route. Check finalProvider, not the displayed model name. That is why it still works while DeepSeek fails.

The plugin therefore sends no pin by default. With the pinUpstream option on, a request for a ClinePass DeepSeek model (cline-pass/deepseek-…) carries:

"providerOptions": {"gateway": {"only": ["deepseek"], "has": ["vision", "implicit-caching"]}}

has is the gateway's capability filter: the upstream must cache a repeated prefix by itself, and take images — vision is asked only of a model Cline's catalog says takes images (or a request carrying one), never of the text-only deepseek-v4-pro. Other DeepSeek models carry only: ["deepseek"], and a GLM model (cline-pass/glm-…) carries only: ["zai"], as before.

If Cline answers that exact 403, the plugin keeps the failure and says to turn the pin off; it does not retry unpinned. This preserves the meaning of the option: a pin that Cline cannot honour is an error, not a silent downgrade. If Cline restores providerOptions routing, the same option works again without a plugin change. A request with provider or providerOptions of its own — magpie's extra body, say — goes as sent.

The option is off by default. Turn it on (or back off, with false):

  • in magpie: magpie plugin options @magpie-community/opencode-cline-auth '{"pinUpstream": true}', which keeps it in magpie's plugins.json. The provider editor's Upstream tick ("DeepSeek and GLM models only from their makers' own APIs") is magpie's own setting and never sets this option; since Cline refuses providerOptions, magpie no longer writes that field for the tick either;
  • in OpenCode: "provider": {"cline": {"options": {"pinUpstream": true}}} in opencode.json, or the plugin's own options: "plugin": [["@magpie-community/opencode-cline-auth", {"pinUpstream": true}]].

Models

The list is Cline's own, merged from the two feeds its clients read: the recommended-models feed (its recommended picks, its free models and ClinePass's) and the whole cloud catalog (/ai/cline/models, where the usage-billed models the recommended feed doesn't name live). Refreshed from the live feeds whenever they answer; until then a bundled snapshot of the recommended list, Cline's own default (anthropic/claude-sonnet-5) among it. Cline's clineCloud group is left out, as Cline's own clients leave it out unless they opt in.

Each model's context window is the cloud catalog's (context_length). Its reply limit is left unsaid: the catalog's max_completion_tokens can be most of the window, and an agent keeps that much free for the reply. The cline-free/… and cline-pass/… models aren't in that catalog, so they say none, and magpie takes the window models.dev gives the model after the prefix (cline-free/mimo-v2.6-flash is mimo-v2.6-flash).

  • The free group (cline-free/…, stealth/…) costs nothing — the names say "(free)". They are gated on the client surface a request claims; the plugin claims what it is, and the gate takes it. If Cline ever narrows that gate to its own apps, those models go away.
  • The ClinePass group (cline-pass/…) needs a ClinePass subscription — the names say so, and asking without one answers 403.
  • The rest are usage-billed against the account's Credits balance.

Not included

  • Cline's MCP and web-search endpoints — a chat provider only.
  • Team/organization account switching.