@magpie-community/opencode-kiro-auth 0.1.28 → 0.1.29
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 +7 -0
- package/index.mjs +9 -1
- package/opencode2.mjs +4 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -253,6 +253,13 @@ With overage on (`overageConfiguration.overageStatus` `ENABLED`), the
|
|
|
253
253
|
month's window counts against the overage cap (`overageCap`), which is the
|
|
254
254
|
month's whole limit; with it off, against the plan's credits.
|
|
255
255
|
|
|
256
|
+
Each request's cost is what Kiro's `meteringEvent`s say, in credits, summed
|
|
257
|
+
over the request (a web search's turns included). It goes on as
|
|
258
|
+
`usage.credit` in the last `message_delta`, or in the message's `usage`, for
|
|
259
|
+
magpie's ledger (yetone/magpie#4328). Kiro gives no token counts, so the
|
|
260
|
+
input is reckoned from how full the context is, and the cache is unknown
|
|
261
|
+
(`magpie_cache_unknown`).
|
|
262
|
+
|
|
256
263
|
### Identity Center credit regions
|
|
257
264
|
|
|
258
265
|
An IAM Identity Center account has a profile, and its own month of credits
|
package/index.mjs
CHANGED
|
@@ -1542,7 +1542,9 @@ async function* events(body, model, budget) {
|
|
|
1542
1542
|
// kiro-cli 2.32's own trace log shows its MetadataEvent with every token
|
|
1543
1543
|
// count None, while a repeated prompt is billed about half the credits,
|
|
1544
1544
|
// so Kiro does cache and doesn't say how much
|
|
1545
|
-
|
|
1545
|
+
// credits: what Kiro's meteringEvents say the request cost, summed;
|
|
1546
|
+
// undefined when it sent none
|
|
1547
|
+
const usage = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, reported: false, credits: undefined }
|
|
1546
1548
|
let pct = 0
|
|
1547
1549
|
let said = 0
|
|
1548
1550
|
let failed = ""
|
|
@@ -1601,6 +1603,8 @@ async function* events(body, model, budget) {
|
|
|
1601
1603
|
}
|
|
1602
1604
|
} else if (kind === "contextUsageEvent") {
|
|
1603
1605
|
if (m.contextUsagePercentage > 0) pct = m.contextUsagePercentage
|
|
1606
|
+
} else if (kind === "meteringEvent") {
|
|
1607
|
+
if (Number.isFinite(m.usage) && m.usage >= 0 && (!m.unit || /^credit/i.test(m.unit))) usage.credits = (usage.credits ?? 0) + m.usage
|
|
1604
1608
|
} else if (["error", "throttlingError", "validationError", "serviceUnavailableError", "internalServerException"].includes(kind)) {
|
|
1605
1609
|
failed = exception(kind, f.payload)
|
|
1606
1610
|
break
|
|
@@ -1656,6 +1660,9 @@ const anthropicUsage = (u) => ({
|
|
|
1656
1660
|
: { input_tokens: u.input, output_tokens: u.output, magpie_cache_unknown: true }),
|
|
1657
1661
|
// the hosted web searches made (searching)
|
|
1658
1662
|
...(u.searches ? { server_tool_use: { web_search_requests: u.searches } } : {}),
|
|
1663
|
+
// what Kiro said the request cost in credits (its meteringEvents), as
|
|
1664
|
+
// magpie reads a plan's credits (yetone/magpie#4328)
|
|
1665
|
+
...(u.credits !== undefined ? { credit: u.credits } : {}),
|
|
1659
1666
|
})
|
|
1660
1667
|
|
|
1661
1668
|
// quotaWords are magpie's (internal/gateway/fallback.go): how a vendor says
|
|
@@ -2155,6 +2162,7 @@ async function* searching(creds, auth, req, model, budget, signal, hosted, first
|
|
|
2155
2162
|
usage.cacheRead += stop.usage.cacheRead
|
|
2156
2163
|
usage.cacheWrite += stop.usage.cacheWrite
|
|
2157
2164
|
usage.reported ||= stop.usage.reported
|
|
2165
|
+
if (stop.usage.credits !== undefined) usage.credits = (usage.credits ?? 0) + stop.usage.credits
|
|
2158
2166
|
for (const b of said)
|
|
2159
2167
|
if (b.type === "tool_use")
|
|
2160
2168
|
try {
|
package/opencode2.mjs
CHANGED
|
@@ -86,7 +86,10 @@ export function fieldsOf(prompts) {
|
|
|
86
86
|
if (p.type === "select" && Array.isArray(p.options))
|
|
87
87
|
f.options = p.options.map((o) => ({ value: String(o.value), label: String(o.label ?? o.value), ...(o.hint ? { description: String(o.hint) } : {}) }))
|
|
88
88
|
// a prompt shown only when another answer says so can't be required
|
|
89
|
-
|
|
89
|
+
// a prompt shown only when another answer says so can't be required, and
|
|
90
|
+
// neither can one whose own validate() accepts an empty answer (the
|
|
91
|
+
// browser sign-in's optional API key)
|
|
92
|
+
if (!p.condition && p.required !== false) f.required = true
|
|
90
93
|
out.push(f)
|
|
91
94
|
}
|
|
92
95
|
return out.length ? out : undefined
|