@javargasm/opencode-kiro-auth 0.2.1 → 0.3.0
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/dist/dashboard-stats.d.ts +13 -1
- package/dist/dashboard-stats.d.ts.map +1 -1
- package/dist/dashboard-ui.d.ts.map +1 -1
- package/dist/event-parser.d.ts.map +1 -1
- package/dist/index.js +168 -117
- package/dist/models.d.ts.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/stream.d.ts.map +1 -1
- package/dist/transform.d.ts +33 -0
- package/dist/transform.d.ts.map +1 -1
- package/package.json +2 -3
|
@@ -6,14 +6,26 @@ export interface RequestMetrics {
|
|
|
6
6
|
outputTokens: number;
|
|
7
7
|
credits: number;
|
|
8
8
|
stream: boolean;
|
|
9
|
+
effort?: string;
|
|
10
|
+
usd?: number;
|
|
9
11
|
}
|
|
12
|
+
interface TokenPrice {
|
|
13
|
+
input: number;
|
|
14
|
+
output: number;
|
|
15
|
+
}
|
|
16
|
+
export declare function getModelPricing(modelId: string): TokenPrice;
|
|
10
17
|
declare class DashboardStats {
|
|
11
18
|
private requests;
|
|
12
|
-
|
|
19
|
+
private totalRequests;
|
|
20
|
+
private totalTokens;
|
|
21
|
+
private totalCredits;
|
|
22
|
+
private totalUsd;
|
|
23
|
+
recordRequest(metrics: Omit<RequestMetrics, "timestamp" | "usd">): void;
|
|
13
24
|
getStats(): {
|
|
14
25
|
totalRequests: number;
|
|
15
26
|
totalTokens: number;
|
|
16
27
|
totalCredits: number;
|
|
28
|
+
totalUsd: number;
|
|
17
29
|
requests: RequestMetrics[];
|
|
18
30
|
};
|
|
19
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dashboard-stats.d.ts","sourceRoot":"","sources":["../src/dashboard-stats.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"dashboard-stats.d.ts","sourceRoot":"","sources":["../src/dashboard-stats.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAID,UAAU,UAAU;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AA2BD,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,CAgB3D;AAED,cAAM,cAAc;IAClB,OAAO,CAAC,QAAQ,CAAwB;IACxC,OAAO,CAAC,aAAa,CAAK;IAC1B,OAAO,CAAC,WAAW,CAAK;IACxB,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,QAAQ,CAAK;IAErB,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,cAAc,EAAE,WAAW,GAAG,KAAK,CAAC;IAehE,QAAQ;;;;;;;CAST;AAED,eAAO,MAAM,KAAK,gBAAuB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dashboard-ui.d.ts","sourceRoot":"","sources":["../src/dashboard-ui.ts"],"names":[],"mappings":"AAAA,wBAAgB,gBAAgB,IAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"dashboard-ui.d.ts","sourceRoot":"","sources":["../src/dashboard-ui.ts"],"names":[],"m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AAE,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GACxE;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GAC5D;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC;AAElD,8EAA8E;AAC9E,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CA2B/D;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,eAAe,EAAE,CA4ItF;AAqCD,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,GACb;IAAE,MAAM,EAAE,eAAe,EAAE,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAqElD"}
|
package/dist/index.js
CHANGED
|
@@ -248,23 +248,14 @@ var init_models = __esm(() => {
|
|
|
248
248
|
"claude-opus-4.8",
|
|
249
249
|
"claude-opus-4.7",
|
|
250
250
|
"claude-opus-4.6",
|
|
251
|
-
"claude-opus-4.6-1m",
|
|
252
251
|
"claude-sonnet-4.6",
|
|
253
|
-
"claude-sonnet-4.6-1m",
|
|
254
252
|
"claude-opus-4.5",
|
|
255
253
|
"claude-sonnet-4.5",
|
|
256
|
-
"claude-sonnet-4.5-1m",
|
|
257
254
|
"claude-sonnet-4",
|
|
258
255
|
"claude-haiku-4.5",
|
|
259
|
-
"deepseek-3.2",
|
|
260
|
-
"kimi-k2.5",
|
|
261
256
|
"minimax-m2.1",
|
|
262
257
|
"minimax-m2.5",
|
|
263
|
-
"glm-4.7",
|
|
264
|
-
"glm-4.7-flash",
|
|
265
258
|
"qwen3-coder-next",
|
|
266
|
-
"agi-nova-beta-1m",
|
|
267
|
-
"qwen3-coder-480b",
|
|
268
259
|
"auto"
|
|
269
260
|
]);
|
|
270
261
|
API_REGION_MAP = {
|
|
@@ -346,17 +337,6 @@ var init_models = __esm(() => {
|
|
|
346
337
|
supportedEfforts: ["low", "medium", "high", "max"],
|
|
347
338
|
supportsThinkingConfig: true
|
|
348
339
|
},
|
|
349
|
-
{
|
|
350
|
-
...KIRO_DEFAULTS,
|
|
351
|
-
id: "claude-opus-4-6-1m",
|
|
352
|
-
name: "Claude Opus 4.6 (1M)",
|
|
353
|
-
reasoning: true,
|
|
354
|
-
input: MULTIMODAL,
|
|
355
|
-
contextWindow: 1e6,
|
|
356
|
-
maxTokens: 64000,
|
|
357
|
-
supportedEfforts: ["low", "medium", "high", "max"],
|
|
358
|
-
supportsThinkingConfig: true
|
|
359
|
-
},
|
|
360
340
|
{
|
|
361
341
|
...KIRO_DEFAULTS,
|
|
362
342
|
id: "claude-sonnet-4-6",
|
|
@@ -368,17 +348,6 @@ var init_models = __esm(() => {
|
|
|
368
348
|
supportedEfforts: ["low", "medium", "high", "max"],
|
|
369
349
|
supportsThinkingConfig: true
|
|
370
350
|
},
|
|
371
|
-
{
|
|
372
|
-
...KIRO_DEFAULTS,
|
|
373
|
-
id: "claude-sonnet-4-6-1m",
|
|
374
|
-
name: "Claude Sonnet 4.6 (1M)",
|
|
375
|
-
reasoning: true,
|
|
376
|
-
input: MULTIMODAL,
|
|
377
|
-
contextWindow: 1e6,
|
|
378
|
-
maxTokens: 64000,
|
|
379
|
-
supportedEfforts: ["low", "medium", "high", "max"],
|
|
380
|
-
supportsThinkingConfig: true
|
|
381
|
-
},
|
|
382
351
|
{
|
|
383
352
|
...KIRO_DEFAULTS,
|
|
384
353
|
id: "claude-opus-4-5",
|
|
@@ -397,15 +366,6 @@ var init_models = __esm(() => {
|
|
|
397
366
|
contextWindow: 200000,
|
|
398
367
|
maxTokens: 65536
|
|
399
368
|
},
|
|
400
|
-
{
|
|
401
|
-
...KIRO_DEFAULTS,
|
|
402
|
-
id: "claude-sonnet-4-5-1m",
|
|
403
|
-
name: "Claude Sonnet 4.5 (1M)",
|
|
404
|
-
reasoning: true,
|
|
405
|
-
input: MULTIMODAL,
|
|
406
|
-
contextWindow: 1e6,
|
|
407
|
-
maxTokens: 65536
|
|
408
|
-
},
|
|
409
369
|
{
|
|
410
370
|
...KIRO_DEFAULTS,
|
|
411
371
|
id: "claude-sonnet-4",
|
|
@@ -424,24 +384,6 @@ var init_models = __esm(() => {
|
|
|
424
384
|
contextWindow: 200000,
|
|
425
385
|
maxTokens: 65536
|
|
426
386
|
},
|
|
427
|
-
{
|
|
428
|
-
...KIRO_DEFAULTS,
|
|
429
|
-
id: "deepseek-3-2",
|
|
430
|
-
name: "DeepSeek 3.2",
|
|
431
|
-
reasoning: true,
|
|
432
|
-
input: TEXT_ONLY,
|
|
433
|
-
contextWindow: 128000,
|
|
434
|
-
maxTokens: 8192
|
|
435
|
-
},
|
|
436
|
-
{
|
|
437
|
-
...KIRO_DEFAULTS,
|
|
438
|
-
id: "kimi-k2-5",
|
|
439
|
-
name: "Kimi K2.5",
|
|
440
|
-
reasoning: true,
|
|
441
|
-
input: TEXT_ONLY,
|
|
442
|
-
contextWindow: 200000,
|
|
443
|
-
maxTokens: 8192
|
|
444
|
-
},
|
|
445
387
|
{
|
|
446
388
|
...KIRO_DEFAULTS,
|
|
447
389
|
id: "minimax-m2-5",
|
|
@@ -460,24 +402,6 @@ var init_models = __esm(() => {
|
|
|
460
402
|
contextWindow: 196000,
|
|
461
403
|
maxTokens: 64000
|
|
462
404
|
},
|
|
463
|
-
{
|
|
464
|
-
...KIRO_DEFAULTS,
|
|
465
|
-
id: "glm-4-7",
|
|
466
|
-
name: "GLM 4.7",
|
|
467
|
-
reasoning: true,
|
|
468
|
-
input: TEXT_ONLY,
|
|
469
|
-
contextWindow: 128000,
|
|
470
|
-
maxTokens: 8192
|
|
471
|
-
},
|
|
472
|
-
{
|
|
473
|
-
...KIRO_DEFAULTS,
|
|
474
|
-
id: "glm-4-7-flash",
|
|
475
|
-
name: "GLM 4.7 Flash",
|
|
476
|
-
reasoning: false,
|
|
477
|
-
input: TEXT_ONLY,
|
|
478
|
-
contextWindow: 128000,
|
|
479
|
-
maxTokens: 8192
|
|
480
|
-
},
|
|
481
405
|
{
|
|
482
406
|
...KIRO_DEFAULTS,
|
|
483
407
|
id: "qwen3-coder-next",
|
|
@@ -487,24 +411,6 @@ var init_models = __esm(() => {
|
|
|
487
411
|
contextWindow: 256000,
|
|
488
412
|
maxTokens: 64000
|
|
489
413
|
},
|
|
490
|
-
{
|
|
491
|
-
...KIRO_DEFAULTS,
|
|
492
|
-
id: "qwen3-coder-480b",
|
|
493
|
-
name: "Qwen3 Coder 480B",
|
|
494
|
-
reasoning: true,
|
|
495
|
-
input: TEXT_ONLY,
|
|
496
|
-
contextWindow: 128000,
|
|
497
|
-
maxTokens: 8192
|
|
498
|
-
},
|
|
499
|
-
{
|
|
500
|
-
...KIRO_DEFAULTS,
|
|
501
|
-
id: "agi-nova-beta-1m",
|
|
502
|
-
name: "AGI Nova Beta (1M)",
|
|
503
|
-
reasoning: true,
|
|
504
|
-
input: MULTIMODAL,
|
|
505
|
-
contextWindow: 1e6,
|
|
506
|
-
maxTokens: 65536
|
|
507
|
-
},
|
|
508
414
|
{
|
|
509
415
|
...KIRO_DEFAULTS,
|
|
510
416
|
id: "auto",
|
|
@@ -1145,13 +1051,14 @@ function parseKiroEventMulti(parsed) {
|
|
|
1145
1051
|
}
|
|
1146
1052
|
});
|
|
1147
1053
|
}
|
|
1148
|
-
|
|
1149
|
-
|
|
1054
|
+
const usageBlock = parsed.usage || parsed.Usage;
|
|
1055
|
+
if (usageBlock !== undefined && typeof usageBlock === "object" && usageBlock !== null) {
|
|
1056
|
+
const u = usageBlock;
|
|
1150
1057
|
events.push({
|
|
1151
1058
|
type: "usage",
|
|
1152
1059
|
data: {
|
|
1153
|
-
inputTokens: u.inputTokens,
|
|
1154
|
-
outputTokens: u.outputTokens
|
|
1060
|
+
inputTokens: u.inputTokens ?? u.InputTokens,
|
|
1061
|
+
outputTokens: u.outputTokens ?? u.OutputTokens
|
|
1155
1062
|
}
|
|
1156
1063
|
});
|
|
1157
1064
|
}
|
|
@@ -1195,6 +1102,7 @@ var EVENT_PATTERNS = [
|
|
|
1195
1102
|
'{"contextUsagePercentage":',
|
|
1196
1103
|
'{"followupPrompt":',
|
|
1197
1104
|
'{"usage":',
|
|
1105
|
+
'{"Usage":',
|
|
1198
1106
|
'{"toolUseId":',
|
|
1199
1107
|
'{"unit":',
|
|
1200
1108
|
'{"error":',
|
|
@@ -2203,6 +2111,22 @@ var COMPACTION_THRESHOLD_PCT = 95;
|
|
|
2203
2111
|
function normalizeMessages(messages) {
|
|
2204
2112
|
return messages.filter((msg) => msg.role !== "assistant" || msg.stopReason !== "error" && msg.stopReason !== "aborted");
|
|
2205
2113
|
}
|
|
2114
|
+
var KIRO_PLACEHOLDER_TOOL = {
|
|
2115
|
+
toolSpecification: {
|
|
2116
|
+
name: "noop",
|
|
2117
|
+
description: "Placeholder tool. Do not call it. Present only to satisfy the toolConfig requirement when replayed history contains tool blocks.",
|
|
2118
|
+
inputSchema: { json: { type: "object", properties: {} } }
|
|
2119
|
+
}
|
|
2120
|
+
};
|
|
2121
|
+
function historyHasToolBlocks(history) {
|
|
2122
|
+
for (const entry of history) {
|
|
2123
|
+
if (entry.assistantResponseMessage?.toolUses?.length)
|
|
2124
|
+
return true;
|
|
2125
|
+
if (entry.userInputMessage?.userInputMessageContext?.toolResults?.length)
|
|
2126
|
+
return true;
|
|
2127
|
+
}
|
|
2128
|
+
return false;
|
|
2129
|
+
}
|
|
2206
2130
|
var TOOL_RESULT_LIMIT = 250000;
|
|
2207
2131
|
var MAX_KIRO_IMAGES = 4;
|
|
2208
2132
|
var MAX_KIRO_IMAGE_BYTES = 3750000;
|
|
@@ -2298,6 +2222,14 @@ function sanitizeSchema(obj) {
|
|
|
2298
2222
|
if (Math.abs(value) > 1e9)
|
|
2299
2223
|
continue;
|
|
2300
2224
|
}
|
|
2225
|
+
if (key === "properties" && value && typeof value === "object" && !Array.isArray(value)) {
|
|
2226
|
+
const props = {};
|
|
2227
|
+
for (const [propName, propSchema] of Object.entries(value)) {
|
|
2228
|
+
props[propName] = sanitizeSchema(propSchema);
|
|
2229
|
+
}
|
|
2230
|
+
result[key] = props;
|
|
2231
|
+
continue;
|
|
2232
|
+
}
|
|
2301
2233
|
result[key] = sanitizeSchema(value);
|
|
2302
2234
|
}
|
|
2303
2235
|
return result;
|
|
@@ -2485,7 +2417,38 @@ Tool results provided.`;
|
|
|
2485
2417
|
});
|
|
2486
2418
|
}
|
|
2487
2419
|
}
|
|
2488
|
-
return { history: collapseAgenticLoops(history), systemPrepended, currentMsgStartIdx };
|
|
2420
|
+
return { history: sanitizeHistory(collapseAgenticLoops(history)), systemPrepended, currentMsgStartIdx };
|
|
2421
|
+
}
|
|
2422
|
+
function sanitizeHistory(history) {
|
|
2423
|
+
for (let i = 0;i < history.length; i++) {
|
|
2424
|
+
const entry = history[i];
|
|
2425
|
+
const arm = entry?.assistantResponseMessage;
|
|
2426
|
+
if (!arm?.toolUses || arm.toolUses.length === 0)
|
|
2427
|
+
continue;
|
|
2428
|
+
const seen = new Set;
|
|
2429
|
+
arm.toolUses = arm.toolUses.filter((tu) => {
|
|
2430
|
+
if (seen.has(tu.toolUseId))
|
|
2431
|
+
return false;
|
|
2432
|
+
seen.add(tu.toolUseId);
|
|
2433
|
+
return true;
|
|
2434
|
+
});
|
|
2435
|
+
const next = i + 1 < history.length ? history[i + 1] : undefined;
|
|
2436
|
+
const toolResults = next?.userInputMessage?.userInputMessageContext?.toolResults;
|
|
2437
|
+
if (!toolResults) {
|
|
2438
|
+
delete arm.toolUses;
|
|
2439
|
+
continue;
|
|
2440
|
+
}
|
|
2441
|
+
const resultIdSet = new Set(toolResults.map((tr) => tr.toolUseId));
|
|
2442
|
+
const useIdSet = new Set(arm.toolUses.map((tu) => tu.toolUseId));
|
|
2443
|
+
arm.toolUses = arm.toolUses.filter((tu) => resultIdSet.has(tu.toolUseId));
|
|
2444
|
+
if (arm.toolUses.length === 0)
|
|
2445
|
+
delete arm.toolUses;
|
|
2446
|
+
const ctx = next.userInputMessage.userInputMessageContext;
|
|
2447
|
+
ctx.toolResults = toolResults.filter((tr) => useIdSet.has(tr.toolUseId));
|
|
2448
|
+
if (ctx.toolResults.length === 0)
|
|
2449
|
+
delete ctx.toolResults;
|
|
2450
|
+
}
|
|
2451
|
+
return history;
|
|
2489
2452
|
}
|
|
2490
2453
|
function collapseAgenticLoops(history) {
|
|
2491
2454
|
if (history.length < 4)
|
|
@@ -2610,7 +2573,7 @@ function emitToolCall(state, output, stream) {
|
|
|
2610
2573
|
const toolCall = { type: "toolCall", id: state.toolUseId, name: state.name, arguments: args };
|
|
2611
2574
|
output.content.push(toolCall);
|
|
2612
2575
|
stream.push({ type: "toolcall_start", contentIndex, partial: output });
|
|
2613
|
-
stream.push({ type: "toolcall_delta", contentIndex, delta:
|
|
2576
|
+
stream.push({ type: "toolcall_delta", contentIndex, delta: JSON.stringify(args), partial: output });
|
|
2614
2577
|
stream.push({ type: "toolcall_end", contentIndex, toolCall, partial: output });
|
|
2615
2578
|
return true;
|
|
2616
2579
|
}
|
|
@@ -2823,6 +2786,8 @@ ${currentContent}`;
|
|
|
2823
2786
|
uimc.toolResults = currentToolResults;
|
|
2824
2787
|
if (context.tools?.length) {
|
|
2825
2788
|
uimc.tools = convertToolsToKiro(context.tools);
|
|
2789
|
+
} else if (historyHasToolBlocks(history) || currentToolResults.length > 0) {
|
|
2790
|
+
uimc.tools = [KIRO_PLACEHOLDER_TOOL];
|
|
2826
2791
|
}
|
|
2827
2792
|
if (firstMsg?.role === "user") {
|
|
2828
2793
|
const imgs = extractImages(firstMsg);
|
|
@@ -3107,6 +3072,7 @@ ${currentContent}`;
|
|
|
3107
3072
|
const tc = output.content[contentIndex];
|
|
3108
3073
|
if (event.data.text) {
|
|
3109
3074
|
tc.thinking += event.data.text;
|
|
3075
|
+
totalContent += event.data.text;
|
|
3110
3076
|
stream.push({ type: "thinking_delta", contentIndex, delta: event.data.text, partial: output });
|
|
3111
3077
|
}
|
|
3112
3078
|
if (event.data.signature) {
|
|
@@ -3321,23 +3287,59 @@ init_models();
|
|
|
3321
3287
|
|
|
3322
3288
|
// src/dashboard-stats.ts
|
|
3323
3289
|
var MAX_HISTORY = 100;
|
|
3290
|
+
var MODEL_PRICING = {
|
|
3291
|
+
"claude-fable-5": { input: 10, output: 50 },
|
|
3292
|
+
"claude-opus-4-8": { input: 5, output: 25 },
|
|
3293
|
+
"claude-opus-4-7": { input: 5, output: 25 },
|
|
3294
|
+
"claude-opus-4-6": { input: 5, output: 25 },
|
|
3295
|
+
"claude-opus-4-5": { input: 5, output: 25 },
|
|
3296
|
+
"claude-sonnet-4-6": { input: 3, output: 15 },
|
|
3297
|
+
"claude-sonnet-4-5": { input: 3, output: 15 },
|
|
3298
|
+
"claude-sonnet-4": { input: 3, output: 15 },
|
|
3299
|
+
"claude-haiku-4-5": { input: 1, output: 5 },
|
|
3300
|
+
"minimax-m2-5": { input: 0.15, output: 1.2 },
|
|
3301
|
+
"minimax-m2-1": { input: 0.3, output: 1.2 },
|
|
3302
|
+
"qwen3-coder-next": { input: 0.3, output: 1 },
|
|
3303
|
+
auto: { input: 3, output: 15 }
|
|
3304
|
+
};
|
|
3305
|
+
function getModelPricing(modelId) {
|
|
3306
|
+
const normId = modelId.replace(/\./g, "-").toLowerCase();
|
|
3307
|
+
if (MODEL_PRICING[normId]) {
|
|
3308
|
+
return MODEL_PRICING[normId];
|
|
3309
|
+
}
|
|
3310
|
+
const sortedKeys = Object.keys(MODEL_PRICING).sort((a, b) => b.length - a.length);
|
|
3311
|
+
for (const key of sortedKeys) {
|
|
3312
|
+
if (normId.startsWith(key)) {
|
|
3313
|
+
return MODEL_PRICING[key];
|
|
3314
|
+
}
|
|
3315
|
+
}
|
|
3316
|
+
return { input: 3, output: 15 };
|
|
3317
|
+
}
|
|
3324
3318
|
|
|
3325
3319
|
class DashboardStats {
|
|
3326
3320
|
requests = [];
|
|
3321
|
+
totalRequests = 0;
|
|
3322
|
+
totalTokens = 0;
|
|
3323
|
+
totalCredits = 0;
|
|
3324
|
+
totalUsd = 0;
|
|
3327
3325
|
recordRequest(metrics) {
|
|
3328
|
-
|
|
3326
|
+
const pricing = getModelPricing(metrics.model);
|
|
3327
|
+
const usd = (metrics.inputTokens * pricing.input + metrics.outputTokens * pricing.output) / 1e6;
|
|
3328
|
+
this.totalRequests++;
|
|
3329
|
+
this.totalTokens += metrics.inputTokens + metrics.outputTokens;
|
|
3330
|
+
this.totalCredits += metrics.credits;
|
|
3331
|
+
this.totalUsd += usd;
|
|
3332
|
+
this.requests.unshift({ ...metrics, usd, timestamp: Date.now() });
|
|
3329
3333
|
if (this.requests.length > MAX_HISTORY) {
|
|
3330
3334
|
this.requests.pop();
|
|
3331
3335
|
}
|
|
3332
3336
|
}
|
|
3333
3337
|
getStats() {
|
|
3334
|
-
const totalRequests = this.requests.length;
|
|
3335
|
-
const totalTokens = this.requests.reduce((acc, r) => acc + r.inputTokens + r.outputTokens, 0);
|
|
3336
|
-
const totalCredits = this.requests.reduce((acc, r) => acc + r.credits, 0);
|
|
3337
3338
|
return {
|
|
3338
|
-
totalRequests,
|
|
3339
|
-
totalTokens,
|
|
3340
|
-
totalCredits,
|
|
3339
|
+
totalRequests: this.totalRequests,
|
|
3340
|
+
totalTokens: this.totalTokens,
|
|
3341
|
+
totalCredits: this.totalCredits,
|
|
3342
|
+
totalUsd: this.totalUsd,
|
|
3341
3343
|
requests: this.requests
|
|
3342
3344
|
};
|
|
3343
3345
|
}
|
|
@@ -3427,6 +3429,16 @@ function getDashboardHtml() {
|
|
|
3427
3429
|
gap: 8px;
|
|
3428
3430
|
}
|
|
3429
3431
|
|
|
3432
|
+
button.status-badge {
|
|
3433
|
+
color: var(--primary);
|
|
3434
|
+
transition: all 0.2s ease;
|
|
3435
|
+
}
|
|
3436
|
+
|
|
3437
|
+
button.status-badge:hover {
|
|
3438
|
+
background: rgba(0, 255, 65, 0.25);
|
|
3439
|
+
box-shadow: 0 0 10px rgba(0, 255, 65, 0.4);
|
|
3440
|
+
}
|
|
3441
|
+
|
|
3430
3442
|
.pulse {
|
|
3431
3443
|
width: 8px;
|
|
3432
3444
|
height: 8px;
|
|
@@ -3563,9 +3575,14 @@ function getDashboardHtml() {
|
|
|
3563
3575
|
<h1>KIRO_GATEWAY</h1>
|
|
3564
3576
|
<div style="font-size: 0.8rem; color: var(--text); margin-top: 5px;">LOCAL PROXY // TELEMETRY NODE</div>
|
|
3565
3577
|
</div>
|
|
3566
|
-
<div
|
|
3567
|
-
<
|
|
3568
|
-
|
|
3578
|
+
<div style="display: flex; align-items: center; gap: 15px;">
|
|
3579
|
+
<button id="toggle-currency" class="status-badge" style="cursor: pointer; font-family: var(--font-mono); outline: none;" onclick="toggleCurrency()">
|
|
3580
|
+
SHOW USD
|
|
3581
|
+
</button>
|
|
3582
|
+
<div class="status-badge">
|
|
3583
|
+
<div class="pulse"></div>
|
|
3584
|
+
SYS.ONLINE
|
|
3585
|
+
</div>
|
|
3569
3586
|
</div>
|
|
3570
3587
|
</header>
|
|
3571
3588
|
|
|
@@ -3579,8 +3596,8 @@ function getDashboardHtml() {
|
|
|
3579
3596
|
<div class="metric-value" id="val-tokens">0</div>
|
|
3580
3597
|
</div>
|
|
3581
3598
|
<div class="metric-card">
|
|
3582
|
-
<div class="metric-label">EST.CREDITS</div>
|
|
3583
|
-
<div class="metric-value" id="val-credits">0.
|
|
3599
|
+
<div class="metric-label" id="label-credits">EST.CREDITS</div>
|
|
3600
|
+
<div class="metric-value" id="val-credits">0.0</div>
|
|
3584
3601
|
</div>
|
|
3585
3602
|
</div>
|
|
3586
3603
|
|
|
@@ -3592,9 +3609,10 @@ function getDashboardHtml() {
|
|
|
3592
3609
|
<th>ID</th>
|
|
3593
3610
|
<th>MODEL</th>
|
|
3594
3611
|
<th>TYPE</th>
|
|
3612
|
+
<th>EFFORT</th>
|
|
3595
3613
|
<th>IN.TOKENS</th>
|
|
3596
3614
|
<th>OUT.TOKENS</th>
|
|
3597
|
-
<th>CREDITS</th>
|
|
3615
|
+
<th id="header-credits">CREDITS</th>
|
|
3598
3616
|
</tr>
|
|
3599
3617
|
</thead>
|
|
3600
3618
|
<tbody id="table-body">
|
|
@@ -3611,6 +3629,22 @@ function getDashboardHtml() {
|
|
|
3611
3629
|
return d.toLocaleTimeString('en-US', { hour12: false, hour: '2-digit', minute: '2-digit', second: '2-digit' }) + '.' + d.getMilliseconds().toString().padStart(3, '0');
|
|
3612
3630
|
}
|
|
3613
3631
|
|
|
3632
|
+
let showUsd = false;
|
|
3633
|
+
|
|
3634
|
+
function toggleCurrency() {
|
|
3635
|
+
showUsd = !showUsd;
|
|
3636
|
+
const btn = document.getElementById('toggle-currency');
|
|
3637
|
+
btn.innerText = showUsd ? 'SHOW CREDITS' : 'SHOW USD';
|
|
3638
|
+
|
|
3639
|
+
const labelCard = document.getElementById('label-credits');
|
|
3640
|
+
labelCard.innerText = showUsd ? 'EST.COST (USD)' : 'EST.CREDITS';
|
|
3641
|
+
|
|
3642
|
+
const headerTable = document.getElementById('header-credits');
|
|
3643
|
+
headerTable.innerText = showUsd ? 'COST (USD)' : 'CREDITS';
|
|
3644
|
+
|
|
3645
|
+
fetchStats();
|
|
3646
|
+
}
|
|
3647
|
+
|
|
3614
3648
|
async function fetchStats() {
|
|
3615
3649
|
try {
|
|
3616
3650
|
const res = await fetch('/dashboard/api/stats');
|
|
@@ -3618,7 +3652,12 @@ function getDashboardHtml() {
|
|
|
3618
3652
|
|
|
3619
3653
|
document.getElementById('val-requests').innerText = data.totalRequests;
|
|
3620
3654
|
document.getElementById('val-tokens').innerText = data.totalTokens.toLocaleString();
|
|
3621
|
-
|
|
3655
|
+
|
|
3656
|
+
if (showUsd) {
|
|
3657
|
+
document.getElementById('val-credits').innerText = '$' + data.totalUsd.toFixed(1);
|
|
3658
|
+
} else {
|
|
3659
|
+
document.getElementById('val-credits').innerText = data.totalCredits.toFixed(1);
|
|
3660
|
+
}
|
|
3622
3661
|
|
|
3623
3662
|
const tbody = document.getElementById('table-body');
|
|
3624
3663
|
|
|
@@ -3630,15 +3669,24 @@ function getDashboardHtml() {
|
|
|
3630
3669
|
currentIds.add(req.id);
|
|
3631
3670
|
const isNew = !lastRenderedIds.has(req.id) && lastRenderedIds.size > 0;
|
|
3632
3671
|
|
|
3672
|
+
const effortTag = req.effort
|
|
3673
|
+
? '<span class="tag" style="border-color: rgba(0, 255, 255, 0.3); color: var(--secondary); background: rgba(0, 255, 255, 0.05);">' + req.effort.toUpperCase() + '</span>'
|
|
3674
|
+
: '<span style="opacity: 0.3">-</span>';
|
|
3675
|
+
|
|
3676
|
+
const costDisplay = showUsd
|
|
3677
|
+
? '$' + (req.usd ?? 0).toFixed(4)
|
|
3678
|
+
: req.credits.toFixed(5);
|
|
3679
|
+
|
|
3633
3680
|
html += \`
|
|
3634
3681
|
<tr class="\${isNew ? 'new-row' : ''}">
|
|
3635
3682
|
<td style="color: var(--secondary)">\${formatTime(req.timestamp)}</td>
|
|
3636
3683
|
<td><span style="opacity: 0.5">msg_</span>\${req.id.split('_').pop().substring(0,8)}</td>
|
|
3637
3684
|
<td class="model-name">\${req.model}</td>
|
|
3638
3685
|
<td><span class="tag">\${req.stream ? 'STREAM' : 'SYNC'}</span></td>
|
|
3686
|
+
<td>\${effortTag}</td>
|
|
3639
3687
|
<td>\${req.inputTokens.toLocaleString()}</td>
|
|
3640
3688
|
<td>\${req.outputTokens.toLocaleString()}</td>
|
|
3641
|
-
<td>\${
|
|
3689
|
+
<td>\${costDisplay}</td>
|
|
3642
3690
|
</tr>
|
|
3643
3691
|
\`;
|
|
3644
3692
|
});
|
|
@@ -4025,7 +4073,8 @@ data: ` + JSON.stringify({
|
|
|
4025
4073
|
inputTokens,
|
|
4026
4074
|
outputTokens,
|
|
4027
4075
|
credits,
|
|
4028
|
-
stream: true
|
|
4076
|
+
stream: true,
|
|
4077
|
+
effort: reasoningEffort
|
|
4029
4078
|
});
|
|
4030
4079
|
controller.enqueue(`event: message_delta
|
|
4031
4080
|
data: ` + JSON.stringify({
|
|
@@ -4035,6 +4084,7 @@ data: ` + JSON.stringify({
|
|
|
4035
4084
|
stop_sequence: null
|
|
4036
4085
|
},
|
|
4037
4086
|
usage: {
|
|
4087
|
+
input_tokens: inputTokens,
|
|
4038
4088
|
output_tokens: outputTokens
|
|
4039
4089
|
}
|
|
4040
4090
|
}) + `
|
|
@@ -4107,7 +4157,8 @@ data: ` + JSON.stringify({
|
|
|
4107
4157
|
inputTokens,
|
|
4108
4158
|
outputTokens,
|
|
4109
4159
|
credits,
|
|
4110
|
-
stream: false
|
|
4160
|
+
stream: false,
|
|
4161
|
+
effort: reasoningEffort
|
|
4111
4162
|
});
|
|
4112
4163
|
const responseBody = {
|
|
4113
4164
|
id: msgId,
|
package/dist/models.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAOA,gEAAgE;AAChE,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAOA,gEAAgE;AAChE,eAAO,MAAM,cAAc,aAczB,CAAC;AAGH,sEAAsE;AACtE,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED,0EAA0E;AAC1E,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAMxD;AA8BD,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAGtE;AAaD,KAAK,KAAK,GAAG,CAAC,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC;AAIlC,M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AAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AA2BlC,wBAAgB,aAAa,IAAI,MAAM,CAA0C;AAEjF,kDAAkD;AAClD,wBAAsB,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC,CA+DrD;AAsBD,qEAAqE;AACrE,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,SAAc,QAQnE;AAwBD,wBAAgB,kBAAkB,CAAC,IAAI,GAAE,MAAU,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CA2ezE"}
|
package/dist/stream.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,GAAG,EAEH,OAAO,EAEP,KAAK,EACL,mBAAmB,EAKpB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,2BAA2B,EAAiB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,GAAG,EAEH,OAAO,EAEP,KAAK,EACL,mBAAmB,EAKpB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,2BAA2B,EAAiB,MAAM,SAAS,CAAC;AAgGrE;;;;;;;GAOG;AACH,eAAO,MAAM,6BAA6B,OAAO,CAAC;AAkGlD,wBAAgB,UAAU,CACxB,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,EACjB,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,2BAA2B,CA04B7B"}
|
package/dist/transform.d.ts
CHANGED
|
@@ -33,6 +33,21 @@ export interface KiroEnvState {
|
|
|
33
33
|
operatingSystem: string;
|
|
34
34
|
currentWorkingDirectory: string;
|
|
35
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Minimal placeholder tool injected when the conversation history contains
|
|
38
|
+
* toolUse/toolResult blocks but the current request supplies no tools.
|
|
39
|
+
* Bedrock returns TOOL_CONFIG_MISSING if toolUse/toolResult blocks appear
|
|
40
|
+
* without a toolConfig; this placeholder makes toolConfig non-empty without
|
|
41
|
+
* inviting the model to call anything meaningful on auxiliary turns (title
|
|
42
|
+
* generation, summarization, compaction) that legitimately omit tools.
|
|
43
|
+
*/
|
|
44
|
+
export declare const KIRO_PLACEHOLDER_TOOL: KiroToolSpec;
|
|
45
|
+
/**
|
|
46
|
+
* True when any history entry carries assistant toolUses or user toolResults.
|
|
47
|
+
* Used to decide whether a tools-less request still needs a toolConfig to
|
|
48
|
+
* avoid Bedrock's TOOL_CONFIG_MISSING validation error.
|
|
49
|
+
*/
|
|
50
|
+
export declare function historyHasToolBlocks(history: KiroHistoryEntry[]): boolean;
|
|
36
51
|
export interface KiroUserInputMessage {
|
|
37
52
|
content: string;
|
|
38
53
|
modelId?: string;
|
|
@@ -108,6 +123,24 @@ export declare function buildHistory(messages: Message[], _modelId: string, syst
|
|
|
108
123
|
systemPrepended: boolean;
|
|
109
124
|
currentMsgStartIdx: number;
|
|
110
125
|
};
|
|
126
|
+
/**
|
|
127
|
+
* Sanitize the Kiro history to prevent Bedrock validation errors:
|
|
128
|
+
*
|
|
129
|
+
* 1. **TOOL_DUPLICATE**: Deduplicate toolUseIds within each assistant
|
|
130
|
+
* message — keep the first occurrence, drop subsequent ones.
|
|
131
|
+
*
|
|
132
|
+
* 2. **TOOL_USE_RESULT_MISMATCH**: Every ASST with toolUses must be
|
|
133
|
+
* followed by a USER with toolResults whose IDs match. Remove
|
|
134
|
+
* orphan toolUses that have no matching toolResult in the next
|
|
135
|
+
* message, and remove orphan toolResults whose toolUse doesn't
|
|
136
|
+
* exist in the preceding assistant.
|
|
137
|
+
*
|
|
138
|
+
* This runs as a defensive last pass — upstream logic (buildHistory,
|
|
139
|
+
* stream.ts current-turn assembly) should produce correct output, but
|
|
140
|
+
* edge cases in retry / cross-provider handoff can violate the
|
|
141
|
+
* invariants Bedrock enforces.
|
|
142
|
+
*/
|
|
143
|
+
export declare function sanitizeHistory(history: KiroHistoryEntry[]): KiroHistoryEntry[];
|
|
111
144
|
/**
|
|
112
145
|
* Collapse consecutive tool-use loops in history. When the agent calls
|
|
113
146
|
* tools N times in sequence (ASST(toolUses) → USER(toolResults) pairs),
|
package/dist/transform.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../src/transform.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,YAAY,EACZ,OAAO,EAGP,IAAI,EAGL,MAAM,SAAS,CAAC;AAIjB;6BAC6B;AAC7B,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE,CAMhE;AAID,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CAC3B;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACjC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B,iBAAiB,EAAE;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,EAAE;YAAE,IAAI,EAAE,MAAM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AO,CAAC,CAQrE;AAID;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAIlD;AAiDD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,YAAY,EAAE,CAqBhE;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,KAAK,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,GAChD;IAAE,MAAM,EAAE,SAAS,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAsB1C;AAID;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,OAAO,EAAE,EACnB,QAAQ,EAAE,MAAM,EAChB,YAAY,CAAC,EAAE,MAAM,GACpB;IAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAAC,eAAe,EAAE,OAAO,CAAC;IAAC,kBAAkB,EAAE,MAAM,CAAA;CAAE,CA0JvF;AAID;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,gBAAgB,EAAE,GAAG,gBAAgB,EAAE,CAsC/E;AAID;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,gBAAgB,EAAE,GAAG,gBAAgB,EAAE,CA0DpF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@javargasm/opencode-kiro-auth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Kiro provider plugin for OpenCode: AWS Builder ID / Identity Center login and OpenAI compatible local gateway for CodeWhisperer streaming.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -54,14 +54,13 @@
|
|
|
54
54
|
"prepack": "bun run build",
|
|
55
55
|
"prepublishOnly": "bun run check"
|
|
56
56
|
},
|
|
57
|
-
"dependencies": {},
|
|
58
57
|
"devDependencies": {
|
|
59
58
|
"@changesets/changelog-github": "^0.5.0",
|
|
60
59
|
"@changesets/cli": "^2.27.0",
|
|
61
60
|
"@opencode-ai/plugin": "^1.17.3",
|
|
62
61
|
"@types/bun": "latest",
|
|
63
62
|
"typescript": "^5.0.0",
|
|
64
|
-
"vitest": "^
|
|
63
|
+
"vitest": "^4.1.9"
|
|
65
64
|
},
|
|
66
65
|
"peerDependencies": {
|
|
67
66
|
"@opencode-ai/plugin": "*"
|