Files
plugins/packages/kiro
yetone d767d1c8e6 kiro 0.1.13: a Google and a GitHub sign-in of one email are two accounts, not one replacing the other (#309)
molvqingtai: Kiro keeps a GitHub and a Google sign-in that share an
email as two accounts, but only one could be added; the second replaced
the first. The plugin named each sign-in by its email alone, and magpie's
host.js settle (internal/plugin/host.js:1022) replaces an account whose
accountId is the new sign-in's, unless both carry a uid and the two
differ (the rule WorkBuddy's uid uses, #413).

Each browser sign-in now carries uid = its way in, lowercased (google,
github, builderid, enterprise, internal). accountId stays the email, so:
- Google and GitHub (or Builder ID) of one email are kept side by side;
  magpie labels the two rows apart by their slot.
- A sign-in again the same way still replaces its own account.
- An account saved before 0.1.13 (bare email, loginProvider kept, as the
  built-in's mover also saved it) still matches a sign-in again, so no
  duplicate appears. It is given its uid from loginProvider on its first
  request, model listing or usage read (one save per token), and on
  magpie's renewal (auth.refresh returns uid with the token). Until then,
  a sign-in the other way of the same email would still replace it, as
  before; magpie lists each account's models when its host starts, so
  that window is the time to the first listing.
Not changed: kiro-cli's and the IDE's sign-in (a pointer to whatever they
are signed in to; kiro-cli's social token doesn't say Google or GitHub)
keeps no uid and matches by email as before. Two Identity Center orgs
with one email are still one (both "enterprise"). Kiro's userInfo gives
no per-account id this plugin reads; none was assumed.

Run at this tree (origin/main 6219a71), sandbox HOME:
- bun test packages/kiro: 49 pass, 0 fail.
- bun test (whole repo): 2102 pass, 0 fail.
- bun scripts/check.mjs: ok.
- accounts.test.mjs on origin/main's index.mjs: 2 of 3 red (Google and
  GitHub sign-ins carry no uid, so magpie's rule keeps one; an old
  account is never given its uid). The third (no save for an account
  that has its uid or no known way) passes on both, as it should.
Not tried: a real Google and GitHub Kiro sign-in of one email (no such
accounts here); the reporter is asked to confirm on #309.
2026-10-22 14:03:15 +08:00
..
kiro 0.1.7: a Builder ID sign-in is asked with Builder ID's service profile, so its models are listed and served, as the built-in (#16, YuanZhe-99: a Kiro Student account moved to the plugin was offered no claude-opus-5.5 or claude-sonnet-5.5, which the built-in listed) — a Builder ID sign-in (kiro-cli's, the Kiro IDE's or one made here) names no profile, and Kiro won't list one for it: List-Available-Profiles answers 403 "AWS Builder ID is not supported for this operation" in both regions, so profileOf threw, provider.models fell back to Auto alone, and usage and chat failed. magpie's built-in has asked such a sign-in with the service profile kiro-cli and the IDE use (arn:aws:codewhisperer:us-east-1:638616132270:profile/AAAACCCCXXXX) since magpie 40102f74 (yetone/magpie#422); the plugin now does as it does: kiro-cli's odic sign-in with Builder ID's start URL or none, the IDE's with provider BuilderId, and one signed in here (or moved from the built-in) with loginProvider BuilderId take it without asking, and an AWS sign-in whose profile listing is that 403 takes it too. Identity Center sign-ins still have their profile listed. builderid.test.mjs (fake management and runtime API: one signed in here lists claude-opus-5.5 and chats under the service profile, the 403 found, Identity Center unchanged, kiro-cli's with and without a start URL, the IDE's) fails 4 of 5 on 0.1.6 and passes; bun test (28 pass) and bun scripts/check.mjs kiro pass under a temp HOME. Checked for real with a Google sign-in (profile listed, models listed, claude-sonnet-4.5 answers): unchanged. Not tried with a real Builder ID or Kiro Student account (none here).
2026-10-04 12:04:57 +08:00

@magpie-community/opencode-kiro-auth

Signs in to a Kiro subscription (Free, Pro, Pro+, Power) and makes its requests, in OpenCode and in magpie. Provider id: kiro.

Signing in

  • Kiro (Google, GitHub, AWS Builder ID, IAM Identity Center): the Kiro IDE's own sign-in.

    • Kiro's page (app.kiro.dev/signin) sends the browser back to one of the ports the IDE listens on (3128, 4649, 6588, 8008, 9091, 49153, 50153–53153) on 127.0.0.1. While the IDE is signing in, those ports may be busy.
    • Google and GitHub come back with a code. Kiro's auth service trades it for tokens.
    • Builder ID and Identity Center come back with an AWS sign-in URL and region. The plugin registers a client with AWS's OIDC service, sends the browser to AWS, and trades the code AWS returns.
    • The account is named by the email Kiro has for it (Get-Usage-Limits), and its plan is read from the same call.
    • Kiro keeps a Google, a GitHub, a Builder ID and an Identity Center sign-in of one email as different accounts. The sign-in carries a uid (google, github, builderid, enterprise), so magpie keeps each one beside the others, and a sign-in again the same way replaces only its own account. An account signed in before 0.1.13 is given its uid on its first request, model listing, usage read or renewal.
    • A company's own identity provider (external_idp) is not supported here. Sign in with kiro-cli login and use the next method instead.
  • Kiro CLI's or Kiro IDE's sign-in: uses the account kiro-cli is signed in to, or else the Kiro IDE's. Nothing is copied. It is read each time from where they keep it:

    • kiro-cli: its SQLite database's auth_kv table.
      • macOS: ~/Library/Application Support/kiro-cli/data.sqlite3
      • Linux: ~/.local/share/kiro-cli/data.sqlite3
      • Windows: %APPDATA%\kiro-cli\data.sqlite3
    • The IDE: ~/.aws/sso/cache/kiro-auth-token.json.

    kiro-cli refreshes its own token first (kiro-cli debug refresh-auth-token). A token the plugin refreshes itself is written back, so kiro-cli and the IDE go on with it.

  • Kiro API key (ksk_…): sent with tokentype: API_KEY. Its profile is found with GetProfile.

A browser sign-in is kept where OpenCode keeps sign-ins (auth.json; in magpie, plugin-auth.json) as an oauth entry. The entry holds the tokens, the profile ARN, the region and, for AWS, the registered client. Refreshing such a sign-in:

  • magpie renews the token 10 minutes before it expires, through the plugin's auth.refresh, once for the account and before its requests, models and usage need it. magpie saves the new token. A failed renewal, even one Kiro refused, doesn't mark the account: it is tried again.
  • OpenCode doesn't call that hook: there the token is refreshed 2 minutes before it expires, before a request, and saved.
  • Either way, a token Kiro turns down (a 403) is refreshed and the request tried once more.
  • Only one refresh runs at a time, magpie's renewal included, and a token refreshed but not yet saved is used rather than spending the old refresh token again.
  • kiro-cli's and the IDE's sign-ins aren't renewed by magpie: they are refreshed before a request, as above, and written back.

Tokens are refreshed through:

  • Google/GitHub: through prod.<region>.auth.desktop.kiro.dev/refreshToken.
  • Builder ID/Identity Center: through AWS's oidc.<region>.amazonaws.com/token.

Requests

Kiro has no API OpenCode speaks. The models are declared on Anthropic's Messages (@ai-sdk/anthropic), and the plugin's fetch handles each request:

  • It sends the request to runtime.<region>.kiro.dev/generateAssistantResponse, the API kiro-cli uses, with kiro-cli's headers. The region is the one the profile ARN names.
  • It turns the request into a Kiro conversation:
    • The system prompt goes at the head of the first message.
    • Tool calls and results are paired: an unanswered call gets an error result, and a result longer than 250,000 characters is cut.
    • Tool ids Kiro wouldn't take are rewritten. A tool name over 64 characters (an MCP plugin's, in Claude Code) is sent shortened with a hash and its calls come back under the full name.
    • A tool's images (a screenshot, Codex's view_image) go with the message that answers the call, as Kiro's tool results hold text alone.
    • Only the latest images are sent.
    • Tools the history used but the request doesn't offer are declared.
  • It turns the AWS event stream Kiro answers with back into Messages' events (streamed) or one message. The reply includes text, thinking, tool calls and usage. When Kiro reports only how full the context is, input tokens are estimated from that.
  • Thinking (Claude models and Auto) is asked for the way kiro-cli asks, in the prompt, with a budget: low 10k, medium 20k, high 30k, xhigh and max 50k (as magpie's built-in Kiro: #120). The <thinking> block of the reply comes back as thinking.
  • Kiro's failures keep their meaning:
    • input too long → 400
    • no capacity → 503
    • usage limit → 429
    • throttling → "rate limited"

Models

The config hook declares auto (Kiro picks the model). Once signed in, the provider.models hook replaces it with the account's own list from List-Available-Models, with the default first. Each model carries its context window, output limit and whether it takes images. Claude models and Auto have the thinking variants.

Not included

  • Usage and quota (credits, the monthly window).
  • Switching between several accounts. OpenCode keeps one sign-in per provider.
  • Signing in with a company's own identity provider in the browser (use kiro-cli's sign-in).
  • magpie's web-search stand-in for Kiro.