Files
plugins/packages/kiro/rate.test.mjs
T
yetone 1aab125bf1 kiro 0.1.34: each model shows Kiro's credit multiplier
01huadalang on Discord: "kiro 加上积分倍率消耗". Kiro's
List-Available-Models gives each model rateMultiplier with rateUnit
"Credit"; listModels now carries it as the model's rate, which magpie's
plugin host reads (rateOf) as Model.Rate, on the account's list and on the
config's model. A null, non-number, zero or negative multiplier, or a unit
other than Credit, gives no rate.

Values from a real Free account on 11-09 (origin KIRO_CLI and AI_EDITOR
answer the same, and kiro-cli chat --list-models shows the same
rate_multiplier): auto 1, claude-sonnet-4.5 1.3, claude-haiku-4.5 0.4,
deepseek-3.2 0.25, minimax-m2.5 0.25, minimax-m2.1 0.15, glm-5 0.5,
qwen3-coder-next 0.05. rate.test.mjs keeps sonnet's and the default
model's objects as Kiro sent them.

Usage is not multiplied again: the credits a request's meteringEvent
reports (usage.credit) already include the rate. One prompt cost 0.005349
on haiku and 0.017385 on sonnet, 3.25x, which is 1.3/0.4. The README says so.

Run on mote: packages/kiro bun test with HOME under the temp dir, 170 pass
0 fail; bun scripts/check.mjs kiro ok. Real run: listModels with kiro-cli's
sign-in returned all eight rates and runtimeModel carries them.
Broken by hand: without the rate in listModels both rate tests go red;
without the unit check the "no rate" test goes red.
Not tried: a Pro account's list (only Free); the rate in magpie's GUI. The
full root suite at this head was cut off when mote dropped mid-run
(connection closed by the host); it was not run to the end.
2026-11-09 12:45:12 +08:00

53 lines
3.5 KiB
JavaScript

import { test, expect } from "bun:test"
import { _internal } from "./index.mjs"
// Discord (01huadalang, 11-09): "kiro 加上积分倍率消耗". Kiro charges each
// model at its own credit rate and says it in List-Available-Models
// (rateMultiplier, rateUnit). The fixture is a Free account's answer on
// 11-09, byte for byte for claude-sonnet-4.5 and the default model; the
// other models keep only the fields this reads.
const SONNET = {"additionalModelRequestFieldsSchema":null,"availableOrigins":null,"consentDescription":null,"consentStatus":null,"description":"Claude Sonnet 4.5 model","disclaimers":null,"modelId":"claude-sonnet-4.5","modelName":"claude-sonnet-4.5","modelProvider":null,"promptCaching":{"maximumCacheCheckpointsPerRequest":4,"minimumTokensPerCacheCheckpoint":1024,"supportsPromptCaching":true},"rateMultiplier":1.3,"rateUnit":"Credit","refusalFallbackModels":null,"status":null,"supportedInputTypes":["TEXT","IMAGE"],"termsUrl":null,"tokenLimits":{"maxInputTokens":200000,"maxOutputTokens":64000}}
const DEFAULT = {"additionalModelRequestFieldsSchema":null,"availableOrigins":null,"consentDescription":null,"consentStatus":null,"description":null,"disclaimers":null,"modelId":"auto","modelName":null,"modelProvider":null,"promptCaching":null,"rateMultiplier":null,"rateUnit":null,"refusalFallbackModels":null,"status":null,"supportedInputTypes":null,"termsUrl":null,"tokenLimits":null}
const rated = (modelId, rateMultiplier, rateUnit = "Credit") => ({ modelId, modelName: modelId, rateMultiplier, rateUnit,
tokenLimits: { maxInputTokens: 200000, maxOutputTokens: 64000 } })
const MODELS = [rated("auto", 1), SONNET, rated("claude-haiku-4.5", 0.4), rated("deepseek-3.2", 0.25), rated("minimax-m2.5", 0.25),
rated("minimax-m2.1", 0.15), rated("glm-5", 0.5), rated("qwen3-coder-next", 0.05)]
const listed = async (models) => {
const was = globalThis.fetch
globalThis.fetch = async (input) => {
if (new URL(String(input)).pathname !== "/List-Available-Models") throw new Error("no network in tests")
return Response.json({ defaultModel: DEFAULT, models, nextToken: null })
}
try {
return await _internal.listModels({ region: "us-east-1", token: "t", tokenType: "", profile: "arn:aws:codewhisperer:us-east-1:1:profile/P" })
} finally {
globalThis.fetch = was
}
}
test("each model carries the credit multiplier Kiro lists for it", async () => {
const list = await listed(MODELS)
expect(Object.fromEntries(list.map((m) => [m.id, m.rate]))).toEqual({
auto: 1, "claude-sonnet-4.5": 1.3, "claude-haiku-4.5": 0.4, "deepseek-3.2": 0.25, "minimax-m2.5": 0.25,
"minimax-m2.1": 0.15, "glm-5": 0.5, "qwen3-coder-next": 0.05,
})
// magpie reads it as m.rate on the account's list and on the config's
const sonnet = list.find((m) => m.id === "claude-sonnet-4.5")
expect(_internal.runtimeModel(sonnet).rate).toBe(1.3)
expect(_internal.configModel(sonnet).rate).toBe(1.3)
})
test("no rate is shown where Kiro gives none, or gives it in another unit", async () => {
const list = await listed([{ ...SONNET, rateMultiplier: null, rateUnit: null }, rated("glm-5", 0.5, "Request"), rated("deepseek-3.2", "0.25"),
rated("minimax-m2.1", 0), rated("qwen3-coder-next", -1), rated("claude-haiku-4.5", 0.4, "CREDIT")])
for (const m of list) {
if (m.id === "claude-haiku-4.5") continue
expect(m.rate).toBeUndefined()
expect("rate" in _internal.runtimeModel(m)).toBe(false)
expect("rate" in _internal.configModel(m)).toBe(false)
}
// the unit's case is Kiro's to choose
expect(list.find((m) => m.id === "claude-haiku-4.5").rate).toBe(0.4)
})