Commit Graph
21 Commits
Author SHA1 Message Date
yetone 20396784c7 kiro 0.1.15: an API key is used as kiro-cli uses it, with or without a profile GetProfile finds (Hollowhere on Discord)
Hollowhere (magpie 0.1.1319, kiro-cli 2.33.1, macOS) signed in to Kiro in
magpie with a Kiro API key. /v1/models listed kiro/auto alone, and every
request failed with "Kiro: Kiro didn't take the API key: 400 Bad Request",
while kiro-cli listed claude-opus-5.5 and claude-sonnet-5.5 and chatted
with the same key.

Cause: the plugin asked GetProfile in us-east-1 only and threw on any
answer but a profile, so a key GetProfile has no profile for never got
further: the model list fell back to Auto and every request failed with
that 400. kiro-cli 2.32.0 (installed here), traced with KIRO_API_KEY set
to a made-up key in a sandbox HOME, every host behind a local proxy that
refused all of them (nothing left the machine), and then with
api.cps.service/api.krs.service/api.codewhisperer.service pointed at a
local recorder:
- asks GetProfile (POST management/, X-Amz-Target
  AmazonCodeWhispererService.GetProfile, body {}) in us-east-1, then
  eu-central-1, then GovCloud and ISO, and with every one refused goes on
  to list models and chat in us-east-1 all the same;
- lists models with the control plane's ListAvailableModels (POST
  management/?origin=KIRO_CLI, X-Amz-Target
  KiroControlPlaneBearerService.ListAvailableModels, body
  {"origin":"KIRO_CLI"}, paged with nextToken), not the REST
  List-Available-Models with a profileArn;
- reads credits with GetUsageLimits (same shape, body {"origin":"KIRO_CLI"});
- names no profileArn in generateAssistantResponse, ListAvailableModels
  or GetUsageLimits, even when GetProfile gave one;
- sends each with Content-Type application/x-amz-json-1.0,
  Authorization: Bearer <key>, tokentype: API_KEY (as the plugin did).

The plugin now does the same for an API key: GetProfile in us-east-1 then
eu-central-1, once per key; a found profile only picks the region; none
found means us-east-1. Its models are ListAvailableModels as above, its
credits GetUsageLimits as above, and its chat names no profile. Sign-ins
other than an API key are unchanged.

Run, in packages/kiro, H=$(mktemp -d); HOME="$H" bun test: 55 pass at
this head (rebased on origin/main 4d73d22, kiro 0.1.14). The new
apikey.test.mjs (fake management and runtime API built from the recorded
shapes: GetProfile 400 in both regions, a key whose profile is in
eu-central-1, two pages of models, GetUsageLimits) fails 4 of 4 with
origin/main's index.mjs (0.1.14) and passes with this one.
bun scripts/check.mjs kiro passes.

Not tried: no real API key was tried. None was used anywhere; the traces
used a made-up key against a local recorder only. That Kiro answers a
real key's GetProfile with 400 when it has no profile, and serves its
ListAvailableModels and chat in us-east-1 without one, is what kiro-cli
2.32.0 does and Hollowhere's kiro-cli 2.33.1 succeeds with, not seen
here. kiro-cli's own handling of a 400 (rather than a refused host) per
region was not traced, since its TLS goes through the system's trust and
was not intercepted. GovCloud and ISO regions are not asked.
2026-10-22 20:00:05 +08:00
yetone 7fdc07f150 kiro 0.1.14: an account is named by its email and the way it was signed in to, "email (Google)", "email (GitHub)" (#309)
magpie names a plugin's account by its accountId (host.js whoOf) and,
when two read the same, adds the slot: molvqingtai's Google and GitHub
accounts of one email read "email (uid-slot)". The accountId is now the
email and the way, as Kiro's sign-in page names it: Google, GitHub,
Builder ID, IAM Identity Center, Internal. A way not known (kiro-cli's
or the Kiro IDE's sign-in, which carry no loginProvider) keeps the bare
email, and magpie's slot stays the fallback.

- browserSignIn's success names the account so.
- An account kept by its bare email, with a known loginProvider, is
  given the name the way the uid was in 0.1.13: by the save after a
  request, model listing or usage read (once per token), and in
  auth.refresh's result (host.js renew merges it over the old).
- Sibling: usage's user is the same name for a sign-in kept here
  (magpie's quota card shows it); kiro-cli's and the IDE's stay bare.

The window: magpie's settle (internal/plugin/host.js) replaces an account
only when whoOf (the accountId) is equal and the uids don't differ. An
old account still named "email", signed in again the same way before
its first use on 0.1.14, has "email (Google)" against "email" and is
kept beside it as a second account. The plugin can't close it: its
client.auth has set/remove for the account in scope only, and a sign-in
result is matched by name alone. Any use (magpie's usage read, a
request, a renewal) renames it first, after which the sign-in replaces
it. Said in the README.

Run at d767d1c + this change:
- accounts.test.mjs on the old index.mjs: 3 fail (the two existing
  tests' labelled expectations, and the bare-email rename), 2 pass (the
  kiro-cli bare-email guard, and the no-save case). On the new: 5 pass.
- HOME=$(mktemp -d) bun test: 2104 pass, 0 fail, 184 files.
- bun scripts/check.mjs: ok.
Not tried: a real Kiro sign-in; the names were checked only against the
tests' fake Kiro.
2026-10-22 15:31:02 +08:00
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
yetone 060bda8f65 kiro 0.1.12: a request's structured output (output_config.format) is told in the system prompt, as the built-in told it
Kiro's generateAssistantResponse has no field for the answer's format, so
magpie's built-in Kiro (internal/gateway/kiro.go, req.inSystem()) told
the model the schema at the end of the system prompt: "Respond with a
single JSON value and nothing else, matching this JSON schema:\n<schema>."
The plugin dropped output_config.format, and magpie's generic plugin path
falls back to inSystem only when an upstream answers 400 naming the
format, which the plugin never did, so a moved user asking for JSON got
prose. buildKiro now says the schema the same way, after the caller's
system prompt and before the thinking budget prefix. The AI SDK's
output_format is read too. A JSON object with no schema needs nothing
here: magpie's Anthropic body already tells it in the system prompt.

Run: HOME=$(mktemp -d) bun test in packages/kiro: 46 pass, 0 fail.
structured-output.test.mjs: 3 of its 4 tests red with the index.mjs
change taken out (the fourth checks a request with no format is
unchanged). bun scripts/check.mjs kiro: ok.
Not run: a real Kiro account, nor magpie end to end.
2026-10-16 17:32:22 +08:00
yetone 779e9b2368 kiro 0.1.11: a thinking model offers xhigh as its own level, so Claude Code's xhigh isn't routed as max (#120)
The variants came from BUDGETS (low, medium, high, max), while thinking()
already read xhigh. magpie fits an effort the model doesn't offer to the
nearest it does, so Claude Code's xhigh on a moved Kiro was recorded and
sent as max: 166 of the reporter's requests on 10-14, after the built-in,
which takes xhigh, had served it as xhigh the day before.

BUDGETS now has xhigh at 50k, the budget thinking() and the built-in's
kiroThinkingBudget give it, so what Kiro is asked is unchanged; only the
level magpie records and passes is. Both configModel and runtimeModel
read BUDGETS.

Run: bun test across the repo (TMPDIR+HOME in the scratchpad), all pass;
the new effort.test.mjs fails on the old BUDGETS. Not tried with a real
Kiro account (none signed in on this machine).
2026-10-14 17:28:46 +08:00
yetone 386a2ba5ad kiro 0.1.10: the caller's prompt-cache marks reach Kiro as cachePoints (#110)
What: buildKiro dropped every cache_control, so Kiro was never asked to
cache a prompt and its tokenUsage reported no cache reads ("kiro cli
cache 率为 0"). Kiro's generateAssistantResponse takes Bedrock's cachePoint
({"type":"default"}) on a userInputMessage, on an assistantResponseMessage
and as an entry of the tools: the CodeWhisperer streaming model's
UserInputMessage.cachePoint, AssistantResponseMessage.cachePoint and
Tool::CachePoint (aws/amazon-q-developer-cli's generated client), and
Kiro CLI 2.27's model list carries supportsPromptCaching and
maximumCacheCheckpointsPerRequest. A message holding a marked block now
gets a cachePoint on the entry it ends up in (merged turns included; a
marked system prompt marks the first message, where the instructions
go), and a marked tool is followed by a cachePoint entry, as kirocc and
AIClient2API send. Four at most, the last kept, as Anthropic allows.
conversationId is left per request: a cachePoint caches the prompt's
prefix, not a conversation.

Run: TMPDIR=<scratch> HOME=<scratch> bun test (1191 pass, 0 fail) and bun
scripts/check.mjs kiro. cache-points.test.mjs's first fixture places the
marks where a captured Claude Code 2.1.296 request had them (two system
blocks and the trailing system-role hook message; texts cut short); the
second is the shape magpie's buildAnthropic hands a plugin for a
translated request. With the two cachePoint lines taken out, 3 of its 4
tests fail. Not tried against a real Kiro account (none signed in here),
so whether Kiro then reports cacheReadInputTokens is not seen yet.
2026-10-14 12:54:44 +08:00
yetone 66facacf14 kiro 0.1.9: a tool's images reach the model, as the built-in sends them (yetone/magpie#1861)
What: buildKiro read a tool_result's content for its text alone, so an
image a tool returned (Codex's view_image, a computer-use screenshot,
Claude Code's Read of a PNG) never reached Kiro: the model got
"(no output)" and said it saw nothing. Its image blocks (base64) now go
with the message that answers the call, beside any image the user sent,
as magpie's built-in has sent them since yetone/magpie#369. Kiro's tool
results hold text alone. The "only the latest images" rule is unchanged;
an image named only by a URL still has no bytes to send and is left out.

Why: simonsmh reported Codex's view_image unreadable through Kiro on
magpie v0.1.1215 (#1861). A moved Kiro is served by this plugin, which
never got #369's fix.

Run: HOME=<scratch> TMPDIR=<scratch> bun test (1152 pass, 0 fail) and
bun scripts/check.mjs. tool-images.test.mjs's fixture is the Anthropic body
magpie's gateway hands the plugin for Codex 0.162's view_image output
([{"type":"input_image","image_url":"data:...","detail":"high"}]), dumped
from magpie's buildAnthropic; 3 of its 4 tests fail on 0.1.8. Not tried
against a real Kiro account (none signed in here); #369 checked the same
body shape on the built-in against a real account.
2026-10-13 03:40:07 +08:00
yetone e1efc3d623 kiro 0.1.8: a tool named past 64 characters is sent under a short name, and its calls come back under the caller's (yetone/magpie#1393)
Kiro answers a tool name longer than 64 characters "Invalid tool use
format." (REQUEST_BODY_INVALID), and has declined to raise the limit
(kirodotdev/Kiro#7684). Claude Code names a plugin's MCP tools
mcp__plugin_<plugin>_<server>__<tool>, e.g. the Cloudflare plugin's
mcp__plugin_cloudflare_cloudflare-docs__search_cloudflare_documentation
(71), so every turn that offered it failed. The plugin passed t.name
through as it was.

toolName keeps a name of [a-zA-Z0-9_-]{1,64} as it is; any other becomes
its head (other characters as _) plus _ and 12 hex of its sha256, at most
64 characters. It is the same each turn, so the declaration, the history's
toolUses and the tools declared for the history all agree without state.
toolNames maps each such name back from the request's tools and history,
and reply gives the caller's name on tool_use blocks, streamed and not.
Results pair by toolUseId, which is unchanged.

tool-names.test.mjs (the reporter's 71- and 70-character names) fails 3
of 3 without the change and passes; HOME=$(mktemp -d) bun test: 1003
pass, 0 fail across the repo; bun scripts/check.mjs kiro passes. Not
tried against Kiro itself: no Kiro sign-in on this machine.
2026-10-09 19:25:13 +08:00
yetone f35c18981c kiro tests: a turn's parallel tool_use split over two assistant messages keeps its results (yetone/magpie#1275)
buildKiro already joins consecutive assistant messages, so #1275's request
reaches Kiro with both calls in one assistantResponseMessage and both real
results after; a call that went unanswered is still answered for. The test
keeps it so. Test-only, no version bump; HOME=$(mktemp -d) bun test (30
pass, 0 fail) and bun scripts/check.mjs pass.
2026-10-08 16:54:49 +08:00
yetone b5fc67f0f4 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
yetone ce009e60c6 kiro 0.1.6: magpie renews the sign-in ahead of time through auth.refresh
auth.refresh with refreshLead 10 minutes (in-fetch: 2) for sign-ins kept in
magpie; kiro-cli's and the IDE's (expires 0) are renewed as before. It runs
under the request path's per-account lock, and an after map lets a request
holding the old token use the new one. Every failure, a refusal included,
throws plainly: the built-in never marked a Kiro account lapsed.

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
yetone ef81d34320 tests: a usage test's offline fetch is put back when its file is done, so the next file doesn't inherit it
bun test runs every file in one process, and three usage tests left
globalThis.fetch on a fake of theirs: zcode's (offline, set in a
beforeEach, never restored), kiro's and workbuddy's (offline, set at
import, never restored). A file run after them got that fake:

- minimax's tests (27/27 alone) failed 19 after zcode's usage test: the
  plugin's requests to the local fake MiniMax went to zcode's offline and
  threw "no network in tests".
- qoder's cn.test.mjs takes globalThis.fetch as the real one when it loads;
  after kiro's or workbuddy's usage test that was offline, so every request
  meant for its Bun.serve stand-in threw. The CN sign-in, which polls on
  through errors, timed out at 10 s and kept polling, and the job-token test
  timed out too, so a full bun test never finished.

Each of the three now keeps the fetch it found and puts it back in
afterAll. Test-only; no package version changes. HOME=$(mktemp -d) bun
test: 341 pass, 0 fail across 42 files (8.5 s); bun scripts/check.mjs
passes.
2026-10-02 23:13:06 +08:00
yetone 01aee5da28 all: a usage read says what it means for the sign-in, and a renewal clears the mark whatever follows, as the built-ins did (要保证插件跟内置的所有逻辑都要一模一样) — auth.usage returns signIn on every path: expired where the built-in's quota read marked the account (Zed's /users/me 401, Factory's and MiMo's refused renewals, Qoder's refused job refresh), renewed after a renewal, which took the mark off, kept everywhere else, so magpie no longer guesses from the words 'sign in again' (Kiro's, Devin's and ZCode's usage errors marked accounts their built-ins never did) nor clears on a clean read. A request after a renewal says renewed on any status; one without says kept, as the built-ins cleared only on renewal. Kiro, Cursor, Devin, Command Code, WorkBuddy, Grok and ZCode, whose built-ins never marked an account, say kept on every answer. New tests fail against 85d7dd0's index.mjs. 2026-10-01 04:53:29 +08:00
yetone 85d7dd0d0a all: each plugin fails with its built-in's status and marks the sign-in as it did, through X-Magpie-Sign-In (要保证插件跟内置的所有逻辑都要一模一样) — Factory's and MiMo's refused renewals are the built-ins' 502 marked expired, not 401s; Qoder's vendor 403 is the built-in's 401 kept, its model list's failure a 400, its job refresh refused marked expired; Zed's retried 401 is a 401 kept, not a 403; Kiro's unreachable refresh a 401 kept; Cursor's expired trial a 401 kept; a vendor 401 WorkBuddy, Grok, Devin, Command Code and ZCode passed on no longer marks the account, as their built-ins never did, and Grok and MiMo no longer retry what their built-ins sent once. Messages take the built-ins' words. New tests fail against the previous index.mjs. 2026-10-01 04:47:03 +08:00
yetone 8efe85163c kiro 0.1.4: an exception Kiro sends before any of the answer (a throttle, a quota, a server error) is a status, not a 200 stream holding an error event, as the built-in's relay answers it: a 429 when it reads as a quota or rate limit (magpie's quotaWords), else a 502, so magpie moves on to the next account exactly as it did; unstreamed, what was said before a later exception is the answer, as the built-in's collector gives it, where the plugin answered 502. errors.test.mjs fails without the change. 2026-10-01 03:45:12 +08:00
yetone 96b3ad276b kiro 0.1.3: only a sign-in that is gone (a refresh Kiro refused, no refresh token, no sign-in, a refused API key) answers a request with the 401 magpie marks the account lapsed on; a refresh that timed out, failed to connect or met a 5xx is a 502; errors no longer start with "Kiro: ", which magpie adds 2026-10-01 03:17:51 +08:00
yetone b3a3ae0887 kiro: a lost sign-in says what magpie's built-in says — add the subscription, sign in with kiro-cli or the IDE, or save an API key; a magpie-added account's is gone and is added again 2026-10-01 01:23:23 +08:00
yetone c8f4d448df Parity with magpie's built-ins: a failed sign-in says why, CLI-backed Command Code and Devin accounts follow the CLI's key, Factory's refused renewal is a 401 in the caller's API shape
- every {type:"failed"} carries an error reason magpie shows
- commandcode/devin: accounts taken from the CLI are marked metadata.cli and re-read its credentials on each request, usage and models
- factory: a refused refresh answers 401 authentication_error (Anthropic shape on /llm/a/, OpenAI's elsewhere) instead of throwing; the whoami back-off is per account; 403 hints name the account to sign in again
- versions: factory/devin/commandcode/cursor/kiro/mimo/zed/zcode 0.1.2, workbuddy 0.1.3
2026-10-01 00:55:50 +08:00
yetone 84e5e853ee kiro 0.1.1: usage shows as magpie's built-in did — plan, period, windows and what they count, balancekiro 2026-09-30 23:03:09 +08:00
yetone e08a374886 kiro: Kiro — the IDE's browser sign-in (social, Builder ID, Identity Center), kiro-cli's or the IDE's sign-in, or an API key; conversations and the event stream as magpie's gateway does them; tried with real requests 2026-09-30 17:12:09 +08:00