Files
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
..

opencode-warp-auth

Warp (the terminal, warp.dev) AI credits as an OpenCode/magpie provider, through the Warp app's own sign-in. Provider id: warp.

Warp's agent mode speaks its own protocol — a protobuf Request POSTed to https://app.warp.dev/ai/multi-agent over HTTP/2, answered as SSE whose data: lines are base64 protobuf ResponseEvents — and this plugin answers OpenAI-style chat completions on it, in OpenCode and in magpie.

Sign in

  • Use the Warp app's sign-in reads the account the Warp terminal is signed in to, using the stable GUI app's native credential store:
    • Windows: DPAPI CurrentUser, from %LOCALAPPDATA%\warp\Warp\data\dev.warp.Warp-User (with the standard home-directory fallback when LOCALAPPDATA is unset). PowerShell runs from its System32 absolute path and decrypts encrypted bytes supplied on stdin; file contents are hashed to cache decryption safely across file replacements and clock changes.
    • macOS: the default Keychain's generic password with service dev.warp.Warp-Stable and account User, read using /usr/bin/security. macOS may ask you to allow access to this item or unlock the keychain; the reader waits up to two minutes for confirmation. Sign in from the Mac desktop session: SSH sessions can be denied access even when the desktop can read the item. Headless sessions can use a refresh token.
    • Linux: Secret Service attributes service=dev.warp.Warp, key=User, read using secret-tool (usually provided by libsecret-tools). When unavailable, the plugin reads Warp's AES-256-GCM disk fallback at $XDG_STATE_HOME/warp-terminal/dev.warp.Warp-User, or ~/.local/state/warp-terminal/dev.warp.Warp-User when unset. The plugin only reads these stores; it never changes Warp's credentials.
  • Warp refresh token takes a refresh token pasted by hand, for machines without the app or an accessible system credential store. The field in Warp's stored account is id_token.refresh_token. This method works on Windows, macOS and Linux and never follows the local app's account. It uses one prompt and an automatic OAuth callback, so magpie does not ask for an additional API key.

The sign-in is Firebase Auth: the id token lasts an hour, and the plugin refreshes it itself at securetoken.googleapis.com (magpie's auth.refresh renews it ahead of expiry too). Refresh tokens may rotate; the plugin saves the returned refresh token, or keeps the existing one when none is returned, and never writes back to Warp's store. Chat, usage, models and the refresh hook share one refresh operation. App sign-in only adopts newer credentials belonging to the original account, and re-reads the app once after a refused refresh to recover a concurrent rotation. Switching the app to another account does not switch this plugin's account. Sign-ins created by older plugin versions keep using their saved refresh token; sign in again to opt into following the app. Preview, development and TUI credential namespaces are not auto-selected.

When Google's refresh endpoint is unreachable or temporarily fails, the plugin retries through Warp's official app.warp.dev/proxy/token proxy. Definitive invalid-token/account-disabled responses are not retried. An anonymous app account is identified as anonymous; a stored Firebase custom token is exchanged at Warp's /proxy/customToken endpoint, then the returned refresh token is used for later renewals. These exchanges do not create a new anonymous account.

Requests

  • Chat completions are turned into one multi-agent conversation whose user query carries the whole transcript so far as JSON records (system prompt, prior turns, tool call IDs/arguments and their results), since Warp's conversation state lives in tasks the client is meant to round-trip whole. Every request therefore starts a fresh conversation. There is no server-side prompt cache between turns; the trade for not rebuilding Warp's client conversation model. JSON preserves record boundaries when content contains role markers. This remains a text transcript, so native model role isolation is not available and untrusted content still requires normal agent safeguards.
  • The agent's tools are declared as one MCP server's tools (mcp_context.servers[].tools, JSON schema as a protobuf Struct) and supported_tools is pinned to CALL_MCP_TOOL, so the only tool calls that come back are calls to those tools — Warp's own shell/file tools are never run and never asked for.
  • Replies stream as SSE chat.completion.chunks: AppendToMessageContent with mask agent_output.text becomes content deltas, AgentReasoning becomes reasoning_content, tool calls arrive whole (CallMCPTool args as a Struct → JSON).
  • A data-URL image in the last user message rides as one of InputContext.images (the base64 text itself in the bytes field, as Warp's own client sends it); images of earlier turns are gone with the text.
  • The turn's end maps by reason: done → stop (or tool_calls), max_token_limit → length, quota_limit → an error with status 429, context_window_exceeded → 400, llm_unavailable → 503, internal errors or missing completion events → 502. Errors before any output use HTTP status codes; errors after streamed output use an SSE error. Non-streamed partial output never hides an error. Usage reports total_input_tokens when present; overlapping deprecated per-model totals are not added or misreported as input tokens. Output comes from per-request TokenUsage.output. Public accounts may receive only context_window_usage, without exact token counts. In that case the plugin derives an approximate input count from that fraction and the model's advertised context window, for client context meters. The response preserves the upstream fraction in usage.context_window_usage and marks the derived count in usage.prompt_tokens_details with estimated: true and source: "warp_context_window_usage". Exact input counts always take precedence. Derived counts are not billing measurements; output remains zero when Warp omits it. A short conversation can still round to 0%.
  • OS headers and request context follow the current platform and shell. Client version uses MAGPIE_WARP_CLIENT_VERSION when set, then Warp's own WARP_CLIENT_VERSION environment variable (exported in Warp shells). Outside Warp, without an override, it falls back to the last tested version v0.2026.09.02.08.27.stable_01; set the override to your installed version if the service retires that fallback.
  • HTTP/2 pauses reading at 4 MiB or 512 queued chunks and resumes below 2 MiB and 256 chunks, so slow callers can receive long answers without buffering the entire response. An 8 MiB / 1024 chunk safety cap remains for oversized chunks or a source ignoring pause. Individual SSE lines are limited to 8 MiB; malformed responses release the connection.

Models

The config hook declares a handful of ids (auto, auto-efficient, auto-genius, …) for the pre-sign-in list. Signed in, provider.models lists the account's own (~120: the auto routers plus every family-and-effort variant) from the GetWorkspacesMetadataForUser GraphQL, with each model's context window and vision support; cached 10 minutes. A reasoning_effort on a family id picks that effort's variant when the account has it.

Usage

magpie's card shows the request allowance (GetRequestLimitInfo: used/limit of the period, when it resets — monthly on the free plan), and any bonus credits left beside it.

Not included

  • Server-side conversation continuation (Task.messages round-trip): the transcript carries the history instead.
  • Warp's own tools (shell, file edits, computer use): never exposed.
  • Web search; images in tool results (only the last user message's images ride).
  • Several accounts. OpenCode keeps one sign-in per provider.

Install

Once the package is published to npm:

magpie plugin add @magpie-community/opencode-warp-auth
magpie plugin login warp

For OpenCode, add @magpie-community/opencode-warp-auth to the plugin array in opencode.json, then run opencode auth login.

To try a checkout before publication: magpie plugin add <this folder>. Edits on disk are picked up by toggling the plugin off/on (or restarting the host).