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 blobafe074cb. 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/maine7cb9dc5: 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.
@magpie-community/opencode-nous-auth
Signs in to Nous Portal with its OAuth
Device Authorization flow and sends model requests in
magpie and OpenCode. Provider id:
nous-portal. This is separate from magpie's nous API-key preset.
Signing in
Once the package is available from magpie's plugin registry:
magpie plugin add @magpie-community/opencode-nous-auth
magpie plugin login nous-portal
Magpie displays a verification URL and a code. Open the page, sign in and approve the code there; finish any CAPTCHA in your browser. The plugin polls for approval and completes sign-in without a local callback server. Hermes Agent does not need to be installed or running.
In OpenCode, add "@magpie-community/opencode-nous-auth" to the plugin
array in opencode.json, then run opencode auth login.
The flow uses Nous Portal's /api/oauth/device/code and /api/oauth/token
with public client hermes-cli, scope inference:invoke, and no client
secret. Device polling follows RFC 8628,
including the server's interval and slow_down responses. Nous has not
confirmed whether independent clients may use the public hermes-cli
OAuth client ID.
For ChatGPT plan sharing, see Nous Portal's documentation.
Where the sign-in is kept
Magpie keeps the account in its plugin credential store; OpenCode uses its own
sign-in store. The saved OAuth fields are access (inference JWT), expires
(epoch milliseconds) and refresh (versioned JSON containing the refresh
token, scope, token type and inference endpoint). The entire refresh value
is secret, even though it looks like JSON.
Expiry uses the earlier of the token response's lifetime and the JWT's exp.
If both are absent, renewal is scheduled one hour after the exchange, with
the same two-minute lead. This is a local fallback, not a Nous lifetime
guarantee; a 401 can still trigger renewal sooner. Explicitly expired or
malformed lifetimes are not extended.
Nothing is read from or written to ~/.hermes/auth.json. A separate device
sign-in is intentional: Nous refresh tokens are single-use, and copying one
from Hermes could invalidate Hermes's session when either program renews it.
Magpie uses auth.refresh with a two-minute lead and saves the rotated
tokens. OpenCode does not call that hook, so the plugin also checks before
each request and persists renewals through client.auth.set. Concurrent
refreshes within one plugin instance share one exchange. A rotated pair is
kept in memory before a save is attempted, so a failed save does not cause
that instance to reuse the old refresh token.
Do not run multiple hosts against the same saved account. The per-request
save is not an atomic cross-process operation; a crash during an unsaved
rotation may require signing in again. Only explicit invalid_grant,
invalid_token or refresh_token_reused errors mark the grant expired.
Other refresh refusals, including HTML or empty 401/403 responses, keep the
credentials and allow a later retry.
Requests
Models use OpenAI Chat Completions (@ai-sdk/openai-compatible) at
https://inference-api.nousresearch.com/v1. Magpie translates requests from
other agent protocols. Every request uses the current inference JWT as a
Bearer token; the refresh token is sent only to Portal's token endpoint in
x-nous-refresh-token, never to inference.
The plugin accepts only known inference paths (/models, /chat/completions,
/completions, /embeddings) at the production Nous inference or welcome
host. A Portal response cannot redirect Bearer tokens to an arbitrary host;
HTTP redirects are refused. Caller-supplied credentials and magpie-internal
headers are removed before forwarding.
A 401 triggers at most one refresh and retry. Other upstream errors keep
their status, and streaming responses pass through without buffering or
rewriting their content. The upstream content-encoding and content-length
headers are removed because fetch may already have decoded the body.
Models
After sign-in, the account's live /v1/models list replaces the single
bootstrap entry (Hermes-4-70B). Model ids are preserved, including the
vendor prefix such as openai/gpt-6-luna. In magpie an exposed model is
addressed as nous-portal/openai/gpt-6-luna.
Magpie may initially expose only part of the catalog. To choose a model listed for your account and test it:
magpie provider refresh nous-portal
magpie provider models nous-portal +openai/gpt-6-luna
magpie provider test nous-portal openai/gpt-6-luna
The provider test command takes the upstream id (openai/gpt-6-luna), not
the magpie-prefixed id. Model availability and billing depend on the account;
a model appearing in /models does not guarantee access. The plugin does
not guess model prices, context limits or vision/reasoning capabilities when
the catalog does not provide them. A failed catalog read does not become an
empty entitlement list.
Not included
- Nous Portal API keys (
nousremains magpie's separate built-in preset). - Importing Hermes credentials or running Hermes's subscription proxy.
- Direct ChatGPT/Codex OAuth, billing or quota reporting, or daily check-in.
- An arbitrary inference URL override or cross-process token coordination.
Test
Run the offline checks from the repository root with a temporary HOME:
h=$(mktemp -d)
HOME="$h" node --test packages/nous/index.test.mjs
HOME="$h" bun test
rm -rf "$h"
bun scripts/check.mjs
Before publication, try the local package with magpie's isolated test script:
export MAGPIE=/absolute/path/to/magpie
sh scripts/try.sh nous
sh scripts/try.sh nous login nous-portal
sh scripts/try.sh nous provider refresh nous-portal
sh scripts/try.sh nous provider test nous-portal openai/gpt-6-luna
try.sh uses .sandbox/nous rather than your real magpie sign-ins. It clears
ordinary environment variables, including proxy settings; configure a proxy
inside the sandbox if needed. Do not use a portable Windows magpie binary
that ignores HOME isolation. Sign-in and provider test contact Nous Portal;
the latter may consume account credits. Test a model your account can use,
and never share the sandbox's credential files.
Protocol reference: Hermes Agent's device flow, refresh handling and Nous Portal proxy adapter.