omp-kiro
v1.2.6
Published
Kiro OAuth, credits usage, model discovery, and streaming runtime for Oh My Pi.
Maintainers
Readme
omp-kiro
Kiro (AWS) provider plugin for Oh My Pi (omp), reusing the current kiro.dev runtime and management APIs. Built on the OMP extension interface: pi.registerProvider("kiro", config) with device-code OAuth (/login), profile-scoped model discovery (fetchDynamicModels), and a custom EventStream runtime (streamSimple).
Install
Directly from npm:
omp plugin install omp-kiroOr through this repository's OMP marketplace:
omp plugin marketplace add fanbaoyu1024/omp-kiro
omp plugin install omp-kiro@fanbaoyu-kiroOMP loads the entry declared in package.json#omp.extensions (./dist/extension.js). Then log in:
omp /login
# choose: Kiro (AWS Builder ID / IAM Identity Center plugin)The login prompts for your IAM Identity Center start URL (leave blank for AWS Builder ID), opens the device-code verification URL, and polls until you authorize. Credentials refresh automatically; the resolved profile ARN routes requests to the right Kiro profile.
Kiro CLI and OMP keep separate OAuth credentials. Switching accounts with kiro-cli does not switch the OMP account; run /login, choose Kiro again, and refresh the model catalog in OMP after an account change.
Check the authenticated account's current Kiro credits from OMP's standard usage surfaces (OMP builds with extension usage-provider support):
omp usage --provider kiroor the /usage panel in the OMP TUI. On OMP builds without extension usage support, the plugin's own command reports the same snapshot:
/kiro-usageBoth report the subscription, precise credits used and remaining, percentage used, and the next reset date. /kiro-usage is kept as the compatibility command and works on every supported OMP version.
Provider identity
The plugin registers the canonical Kiro surfaces:
- provider id:
kiro - stream API id:
kiro-api - display name:
Kiro (AWS Builder ID / IAM Identity Center plugin)
When enabled, this plugin replaces or extends OMP's built-in Kiro registration. Do not install another Kiro provider extension alongside it.
How it works
- OAuth: OIDC device authorization flow (
client/register→device_authorization→ token polling) againstoidc.<region>.amazonaws.com.oauth.getApiKeyreturns a structured JSON API key ({token, region, profileArn}) that the stream layer parses. - Dynamic catalog: only
fetchDynamicModelsis configured — nevermodels(OMP's registry ignoresfetchDynamicModelswhenmodelsis non-empty). The function returns the Kiro CLI 2.19.2 bootstrap catalog when unauthenticated. Once authenticated, the profile-scopedList-Available-Modelsresponse is authoritative: models omitted for the current account are removed rather than restored from an older bootstrap list. - Runtime:
streamSimpleposts tohttps://runtime.<region>.kiro.dev/generateAssistantResponseand decodes AWSapplication/vnd.amazon.eventstreamframes (CRC-checked prelude/message framing) into OMP assistant events. Kiro's V1 stream reports context percentage and credits but no output-token count, so the plugin estimates output tokens from the emitted UTF-8 content and records TTFT/duration; this enables OMP's standard⤵/⤴/⏱/⚡ tokens/srow. A transient fleet-only HTTP 400Invalid tool use format.is retried exactly once with the identical payload and a fresh request ID; all other validation errors fail immediately. - Credits usage: each completed Kiro turn records the service's native
{usage, unit: "credit"}event asKiro <turn> credits · Σ <session total>and persists one hiddenkiro-credit-meteringsession entry. On restart, resume, or branch switch, the total is rebuilt from the current branch only; malformed and abandoned-branch entries are ignored. OMP builds exposingExtensionUIContext.setStatusLinerender it inline in the main billing segment (replacing the bare(sub)marker); older OMP builds fall back to a separate hook-status row. The provider config also registers a standard OMPUsageProvider(usagefield), so/usageandomp usage --provider kiroshow the account-level used/limit/remaining balance and reset timestamp./kiro-usageremains the compatibility command for hosts without extension usage-provider support. - Cache safety: only standard
ProviderModelConfigfields are emitted. The region travels on the per-modelbaseUrl, the profile ARN in the standardx-amzn-kiro-profile-arnheader, and the thinking surface in the standardthinkingmetadata — custom fields would be dropped by OMP's SQLite model cache.
Known limitations
- OMP resolves the API key for
fetchDynamicModelsfrom the stored credential. When it is a plain bearer token (not the structured JSON this plugin'sgetApiKeyproduces for streaming), catalog discovery falls back to the defaultus-east-1management region. Structured keys — including the one produced byoauth.getApiKey— carry the region and are honored when present. - The raw Kiro request-field schema cannot survive OMP's model cache; the wire effort vocabulary is approximated by the standard low→max ladder and the
reasoning/output_configfield choice is encoded inthinking.mode. - If the structured API key carries no profile ARN yet, the first stream resolves one via
List-Available-Profiles; afterwards the resolved ARN is cached on the models' headers.
Development
bun install
bun run typecheck
bun run test
bun run build # dist/ with bun + declaration filesLicense
MIT
