@magpie-community/opencode-kiro-auth 0.1.33 → 0.1.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -3
- package/index.mjs +22 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -237,8 +237,10 @@ own search used instead.
|
|
|
237
237
|
The `config` hook declares `auto` (Kiro picks the model). Once signed in,
|
|
238
238
|
the `provider.models` hook replaces it with the account's own list from
|
|
239
239
|
`List-Available-Models`, with the default first. Each model carries its
|
|
240
|
-
context window, output limit and whether it takes images
|
|
241
|
-
|
|
240
|
+
context window, output limit and whether it takes images, and its credit
|
|
241
|
+
multiplier as `rate` (Kiro's `rateMultiplier` when `rateUnit` is `Credit`:
|
|
242
|
+
1.3 for claude-sonnet-4.5, 0.4 for claude-haiku-4.5), which magpie shows
|
|
243
|
+
beside the model. Claude models and Auto have the thinking variants.
|
|
242
244
|
|
|
243
245
|
## Usage in magpie
|
|
244
246
|
|
|
@@ -254,7 +256,8 @@ month's window counts against the overage cap (`overageCap`), which is the
|
|
|
254
256
|
month's whole limit; with it off, against the plan's credits.
|
|
255
257
|
|
|
256
258
|
Each request's cost is what Kiro's `meteringEvent`s say, in credits, summed
|
|
257
|
-
over the request (a web search's turns included).
|
|
259
|
+
over the request (a web search's turns included). Kiro has already applied
|
|
260
|
+
the model's multiplier to it, so it isn't multiplied again. It goes on as
|
|
258
261
|
`usage.credit` in the last `message_delta`, or in the message's `usage`, for
|
|
259
262
|
magpie's ledger (yetone/magpie#4328). Kiro gives no token counts, so the
|
|
260
263
|
input is reckoned from how full the context is, and the cache is unknown
|
package/index.mjs
CHANGED
|
@@ -782,6 +782,8 @@ function configModel(m) {
|
|
|
782
782
|
? { reasoning: true, variants: Object.fromEntries(Object.entries(BUDGETS).map(([k, b]) => [k, { thinking: { type: "enabled", budgetTokens: b } }])) }
|
|
783
783
|
: {}),
|
|
784
784
|
tool_call: true,
|
|
785
|
+
// magpie's own: the credit multiplier Kiro lists for the model
|
|
786
|
+
...(m.rate ? { rate: m.rate } : {}),
|
|
785
787
|
}
|
|
786
788
|
}
|
|
787
789
|
|
|
@@ -807,6 +809,8 @@ function runtimeModel(m) {
|
|
|
807
809
|
interleaved: false,
|
|
808
810
|
},
|
|
809
811
|
release_date: "",
|
|
812
|
+
// magpie's own: the credit multiplier Kiro lists for the model
|
|
813
|
+
...(m.rate ? { rate: m.rate } : {}),
|
|
810
814
|
variants: thinks(m.id) ? Object.fromEntries(Object.entries(BUDGETS).map(([k, b]) => [k, { thinking: { type: "enabled", budgetTokens: b } }])) : {},
|
|
811
815
|
}
|
|
812
816
|
}
|
|
@@ -831,6 +835,21 @@ async function keyModels(a) {
|
|
|
831
835
|
return out
|
|
832
836
|
}
|
|
833
837
|
|
|
838
|
+
// rateOf is the credits a model's request costs as a multiple, as Kiro's
|
|
839
|
+
// list says it (rateMultiplier with rateUnit "Credit": on 11-09 a Free
|
|
840
|
+
// account's list had auto 1, claude-sonnet-4.5 1.3, claude-haiku-4.5 0.4,
|
|
841
|
+
// glm-5 0.5, deepseek-3.2 and minimax-m2.5 0.25, minimax-m2.1 0.15 and
|
|
842
|
+
// qwen3-coder-next 0.05, which kiro-cli 2.x reads as its rate_multiplier).
|
|
843
|
+
// Nothing is the rate when Kiro gives none, or gives it in another unit.
|
|
844
|
+
// It is only shown: what a request cost is the meteringEvent's credits,
|
|
845
|
+
// which Kiro has already multiplied (the same prompt metered 0.00535 on
|
|
846
|
+
// claude-haiku-4.5 and 0.01739 on claude-sonnet-4.5, 0.4 to 1.3).
|
|
847
|
+
function rateOf(m) {
|
|
848
|
+
const n = m?.rateMultiplier
|
|
849
|
+
if (typeof n !== "number" || !Number.isFinite(n) || n <= 0) return undefined
|
|
850
|
+
return String(m.rateUnit ?? "").toLowerCase() === "credit" ? n : undefined
|
|
851
|
+
}
|
|
852
|
+
|
|
834
853
|
// listModels is List-Available-Models, the default first.
|
|
835
854
|
async function listModels(a) {
|
|
836
855
|
const out = a.tokenType === "API_KEY" ? await keyModels(a) : await managementCall(a.region, a, "List-Available-Models", { origin: "KIRO_CLI", profileArn: a.profile })
|
|
@@ -839,8 +858,9 @@ async function listModels(a) {
|
|
|
839
858
|
if (!m?.modelId) continue
|
|
840
859
|
let name = m.modelName
|
|
841
860
|
if (!name || name === m.modelId) name = m.modelId === "auto" ? "Auto" : m.modelId
|
|
861
|
+
const rate = rateOf(m)
|
|
842
862
|
const model = { id: m.modelId, name, context: m.tokenLimits?.maxInputTokens ?? 0, output: m.tokenLimits?.maxOutputTokens ?? 0,
|
|
843
|
-
images: (m.supportedInputTypes ?? []).some((t) => String(t).toUpperCase() === "IMAGE") }
|
|
863
|
+
images: (m.supportedInputTypes ?? []).some((t) => String(t).toUpperCase() === "IMAGE"), ...(rate ? { rate } : {}) }
|
|
844
864
|
if (m.modelId === out?.defaultModel?.modelId) list.unshift(model)
|
|
845
865
|
else list.push(model)
|
|
846
866
|
}
|
|
@@ -3133,4 +3153,4 @@ export async function KiroAuthPlugin({ client } = {}) {
|
|
|
3133
3153
|
}
|
|
3134
3154
|
|
|
3135
3155
|
// for tests
|
|
3136
|
-
export const _internal = { generate, responsesBody, crMessages, crRefusal, features, FEATURES, featureKey, waitOf, timing, TRIES, refresh, usageOf, buildKiro, kiroBody, IMAGE_LIMIT, events, reply, failure, toolID, toolName, toolNames, thinking, nativeFields, listModels, contextFirst, configModel, runtimeModel, readCLI, readIDE, regionOf, planName, frames }
|
|
3156
|
+
export const _internal = { generate, responsesBody, crMessages, crRefusal, features, FEATURES, featureKey, waitOf, timing, TRIES, refresh, usageOf, buildKiro, kiroBody, IMAGE_LIMIT, events, reply, failure, toolID, toolName, toolNames, thinking, nativeFields, listModels, rateOf, contextFirst, configModel, runtimeModel, readCLI, readIDE, regionOf, planName, frames }
|