Files
plugins/packages
yetone 1d3b537c0d kiro: chat calls go as the Kiro IDE 1.4.121 sends them, not as kiro-cli
onemezao on Discord (Builder ID, Kiro Pro for students, claude-haiku-5.5,
pi): every request was answered 429 USER_REQUEST_RATE_EXCEEDED, and
kiro-cli on the same account is too, while the Kiro IDE goes on working
there. Kiro is limiting the CLI's identity on that account, not the IDE's,
and the plugin called as kiro-cli: aws-sdk-rust's user agent with
AmazonQ-For-CLI and a random suffix on every request, origin KIRO_CLI,
and a new conversationId per request.

A generateAssistantResponse call now carries what the IDE's own
extension.js (Kiro 1.4.121, agent KAS 0.66.89, Electron 44 / Node
24.22.1, downloaded from prod.download.desktop.kiro.dev) sends through
its KiroRuntime client:

- User-Agent: the AWS SDK for JavaScript's, "aws-sdk-js/1.0.0 ua/2.1
  os/<platform>#<release> lang/js md/nodejs#24.22.1 api/kiroruntime#1.0.0
  m/N", then the IDE's "KiroIDE-1.4.121-<machine id>-KAS/0.66.89
  acp-client/kiro-ide"; x-amz-user-agent is "aws-sdk-js/1.0.0" and that
  last part. The machine id is one 64-hex per install (the hash the
  plugin already names itself with to Kiro's auth service), never a
  random one per request. m/N is the SDK's feature for the endpoint the
  IDE names; its retry strategy has no mode, so no E.
- x-amzn-kiro-client-attribution: kiro-ide; x-amzn-kiro-attempt:
  1;max=3 and amz-sdk-request attempt=1; max=3 (the IDE's budget at a
  conversation's start); TokenType SSO_OIDC for a Builder ID or Identity
  Center token, as the IDE says it.
- Each message's origin is AI_EDITOR. agentMode leaves the body: the
  IDE's client binds it to x-amzn-kiro-agent-mode, which stays.
- conversationId is one per session: a UUID made from magpie's
  X-Magpie-Conversation (or X-Magpie-Session, or OpenCode's session
  header), the same on every turn; a call that names no session gets a
  new one, as before. The session's own name never goes to Kiro.

This holds for every account and every call, not only after a 429: the
IDE's identity is the one that works where the CLI's is limited, waiting
for a refusal first would spend one, and one identity per account is
simpler than two. Prompts are unchanged. The usage, model-list and
API-key control calls keep kiro-cli's origin (unchanged here).

Run on mote: bun test in packages/kiro (150 pass) and bun scripts/check.mjs
kiro, and the repo's bun test (6815 pass, 20 skip, 0 fail) with
bun scripts/check.mjs, each in a temp HOME.
Broken by hand: ide-identity.test.mjs against the old index.mjs, 4 of 4
red; with a random suffix put back on the user agent and the Headers
lookup taken out, 2 red.
Real use (the owner's existing kiro-cli sign-in, a Google account,
copied into a sandbox HOME, no sign-in or refresh): auto and
claude-sonnet-4.5 answered 200 twice each under the new identity, one
conversationId across both turns. It showed auto, called as the IDE,
ending a reply with a reasoning event that carries its signature; the
next commit keeps that signature.
Not tried: a Builder ID account or the reporter's account (the owner's
is Google; claude-haiku-5.5 is not on it, INVALID_MODEL_ID), whether
this ends the reporter's 429, and the IDE's A/B user agent
(AB_USER_AGENT_REFACTORING), whose control form is used here.

Reported-by: onemezao
2026-11-07 20:43:30 +08:00
..
middleware: param-override, model-map, system-prompt, word-guard and think-tags — gateway middleware that magpie runs on every agent's requests and replies, mostly New API's channel settings with the same JSON (the owner) — magpie can now run a plugin as gateway middleware (onRequest, onEvent, onResponse, in-process on moejs), and these are the first ones: param-override is New API's param_override (both forms, operations with gjson paths and conditions, return_error); model-map is model_mapping (chains, /regex/ keys with $1) and puts the asked-for name back into replies; system-prompt adds a prompt in each API's own place, keeping an agent's own unless override (New API's semantics), by agent or model; word-guard is the sensitive-word filter (reject or mask the user's text, optionally replies); think-tags strips a leading <think>…</think> from replies across stream chunks, or puts Chat reasoning_content into the text (thinking_to_content). Each is one file with no imports, named @magpie-community/middleware-<name>, with magpie.options as the example the app's editor starts from; registry.json lists them with "kind": "middleware" and no providers; check.mjs skips middleware-only packages. scripts/middleware.mjs calls the hooks as the gateway does (events split, [DONE] passed by) and runs each package's cases.json. Tested with a real DeepSeek account and real Claude Code through magpie's gateway: a mapped model named back in message_start, max_tokens capped, a system prompt appended for claude only, a word turned away as a 400 in Anthropic's shape, return_error as a 403 in Chat's, <think> stripped from Chat and Responses streams and an Anthropic whole reply, reasoning_content moved into the text. bun test (61 for these five) and bun scripts/check.mjs pass; packages/devin's two image tests fail on this machine only, as on main. Their first npm version has to be published by hand (trusted publishing can't create a package); until then magpie shows them as Coming soon.
2026-10-05 20:49:42 +08:00
middleware: param-override, model-map, system-prompt, word-guard and think-tags — gateway middleware that magpie runs on every agent's requests and replies, mostly New API's channel settings with the same JSON (the owner) — magpie can now run a plugin as gateway middleware (onRequest, onEvent, onResponse, in-process on moejs), and these are the first ones: param-override is New API's param_override (both forms, operations with gjson paths and conditions, return_error); model-map is model_mapping (chains, /regex/ keys with $1) and puts the asked-for name back into replies; system-prompt adds a prompt in each API's own place, keeping an agent's own unless override (New API's semantics), by agent or model; word-guard is the sensitive-word filter (reject or mask the user's text, optionally replies); think-tags strips a leading <think>…</think> from replies across stream chunks, or puts Chat reasoning_content into the text (thinking_to_content). Each is one file with no imports, named @magpie-community/middleware-<name>, with magpie.options as the example the app's editor starts from; registry.json lists them with "kind": "middleware" and no providers; check.mjs skips middleware-only packages. scripts/middleware.mjs calls the hooks as the gateway does (events split, [DONE] passed by) and runs each package's cases.json. Tested with a real DeepSeek account and real Claude Code through magpie's gateway: a mapped model named back in message_start, max_tokens capped, a system prompt appended for claude only, a word turned away as a 400 in Anthropic's shape, return_error as a 403 in Chat's, <think> stripped from Chat and Responses streams and an Anthropic whole reply, reasoning_content moved into the text. bun test (61 for these five) and bun scripts/check.mjs pass; packages/devin's two image tests fail on this machine only, as on main. Their first npm version has to be published by hand (trusted publishing can't create a package); until then magpie shows them as Coming soon.
2026-10-05 20:49:42 +08:00