@javargasm/opencode-kiro-auth 0.2.0 → 0.2.2
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/file-logger.d.ts +47 -0
- package/dist/file-logger.d.ts.map +1 -0
- package/dist/index.js +171 -11
- package/dist/stream.d.ts.map +1 -1
- package/dist/transform.d.ts +18 -0
- package/dist/transform.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/** Log the full request body sent to Kiro API. */
|
|
2
|
+
export declare function logRequest(meta: {
|
|
3
|
+
endpoint: string;
|
|
4
|
+
model: string;
|
|
5
|
+
historyLength: number;
|
|
6
|
+
requestBodyChars: number;
|
|
7
|
+
attempt: number;
|
|
8
|
+
conversationId: string;
|
|
9
|
+
}, requestBody: string): void;
|
|
10
|
+
/** Log a parsed response event from the Kiro stream. */
|
|
11
|
+
export declare function logResponseEvent(event: {
|
|
12
|
+
type: string;
|
|
13
|
+
data: unknown;
|
|
14
|
+
eventSeq: number;
|
|
15
|
+
}): void;
|
|
16
|
+
/** Log the final response summary when the stream completes. */
|
|
17
|
+
export declare function logResponseDone(meta: {
|
|
18
|
+
stopReason: string;
|
|
19
|
+
emittedToolCalls: number;
|
|
20
|
+
usage: unknown;
|
|
21
|
+
contentBlocks: number;
|
|
22
|
+
model: string;
|
|
23
|
+
}): void;
|
|
24
|
+
/** Log HTTP error responses from the Kiro API. */
|
|
25
|
+
export declare function logHttpError(meta: {
|
|
26
|
+
status: number;
|
|
27
|
+
statusText: string;
|
|
28
|
+
body: string;
|
|
29
|
+
endpoint: string;
|
|
30
|
+
model: string;
|
|
31
|
+
attempt: number;
|
|
32
|
+
historyLength: number;
|
|
33
|
+
}): void;
|
|
34
|
+
/** Log stream-level errors (timeouts, parse errors, etc). */
|
|
35
|
+
export declare function logStreamError(meta: {
|
|
36
|
+
error: string;
|
|
37
|
+
context: string;
|
|
38
|
+
model: string;
|
|
39
|
+
attempt: number;
|
|
40
|
+
}): void;
|
|
41
|
+
/** Log caught exceptions from the top-level try/catch. */
|
|
42
|
+
export declare function logCaughtError(meta: {
|
|
43
|
+
stopReason: string;
|
|
44
|
+
errorMessage: string;
|
|
45
|
+
model: string;
|
|
46
|
+
}): void;
|
|
47
|
+
//# sourceMappingURL=file-logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-logger.d.ts","sourceRoot":"","sources":["../src/file-logger.ts"],"names":[],"mappings":"AA4CA,kDAAkD;AAClD,wBAAgB,UAAU,CAAC,IAAI,EAAE;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;CACxB,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAM5B;AAED,wDAAwD;AACxD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,IAAI,CAOP;AAED,gEAAgE;AAChE,wBAAgB,eAAe,CAAC,IAAI,EAAE;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;IACzB,KAAK,EAAE,OAAO,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;CACf,GAAG,IAAI,CAKP;AAED,kDAAkD;AAClD,wBAAgB,YAAY,CAAC,IAAI,EAAE;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;CACvB,GAAG,IAAI,CAKP;AAED,6DAA6D;AAC7D,wBAAgB,cAAc,CAAC,IAAI,EAAE;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB,GAAG,IAAI,CAKP;AAED,0DAA0D;AAC1D,wBAAgB,cAAc,CAAC,IAAI,EAAE;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;CACf,GAAG,IAAI,CAKP"}
|
package/dist/index.js
CHANGED
|
@@ -2094,6 +2094,84 @@ async function startSocialLogin() {
|
|
|
2094
2094
|
return { signInUrl, waitForCredentials };
|
|
2095
2095
|
}
|
|
2096
2096
|
|
|
2097
|
+
// src/file-logger.ts
|
|
2098
|
+
import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync2 } from "node:fs";
|
|
2099
|
+
var LOG_DIR = "/tmp/kiro-logs";
|
|
2100
|
+
var REQUESTS_FILE = `${LOG_DIR}/requests.log`;
|
|
2101
|
+
var RESPONSES_FILE = `${LOG_DIR}/responses.log`;
|
|
2102
|
+
var ERRORS_FILE = `${LOG_DIR}/errors.log`;
|
|
2103
|
+
var dirEnsured = false;
|
|
2104
|
+
function isEnabled() {
|
|
2105
|
+
return true;
|
|
2106
|
+
}
|
|
2107
|
+
function ensureDir() {
|
|
2108
|
+
if (dirEnsured)
|
|
2109
|
+
return;
|
|
2110
|
+
try {
|
|
2111
|
+
mkdirSync2(LOG_DIR, { recursive: true });
|
|
2112
|
+
dirEnsured = true;
|
|
2113
|
+
} catch {}
|
|
2114
|
+
}
|
|
2115
|
+
function writeLine(file, data) {
|
|
2116
|
+
if (!isEnabled())
|
|
2117
|
+
return;
|
|
2118
|
+
ensureDir();
|
|
2119
|
+
const entry = {
|
|
2120
|
+
ts: new Date().toISOString(),
|
|
2121
|
+
...data
|
|
2122
|
+
};
|
|
2123
|
+
try {
|
|
2124
|
+
appendFileSync2(file, JSON.stringify(entry) + `
|
|
2125
|
+
`);
|
|
2126
|
+
} catch {}
|
|
2127
|
+
}
|
|
2128
|
+
function logRequest(meta, requestBody) {
|
|
2129
|
+
writeLine(REQUESTS_FILE, {
|
|
2130
|
+
type: "request",
|
|
2131
|
+
...meta,
|
|
2132
|
+
body: safeParseJson(requestBody)
|
|
2133
|
+
});
|
|
2134
|
+
}
|
|
2135
|
+
function logResponseEvent(event) {
|
|
2136
|
+
writeLine(RESPONSES_FILE, {
|
|
2137
|
+
type: "response_event",
|
|
2138
|
+
eventType: event.type,
|
|
2139
|
+
seq: event.eventSeq,
|
|
2140
|
+
data: event.data
|
|
2141
|
+
});
|
|
2142
|
+
}
|
|
2143
|
+
function logResponseDone(meta) {
|
|
2144
|
+
writeLine(RESPONSES_FILE, {
|
|
2145
|
+
type: "response_done",
|
|
2146
|
+
...meta
|
|
2147
|
+
});
|
|
2148
|
+
}
|
|
2149
|
+
function logHttpError(meta) {
|
|
2150
|
+
writeLine(ERRORS_FILE, {
|
|
2151
|
+
type: "http_error",
|
|
2152
|
+
...meta
|
|
2153
|
+
});
|
|
2154
|
+
}
|
|
2155
|
+
function logStreamError(meta) {
|
|
2156
|
+
writeLine(ERRORS_FILE, {
|
|
2157
|
+
type: "stream_error",
|
|
2158
|
+
...meta
|
|
2159
|
+
});
|
|
2160
|
+
}
|
|
2161
|
+
function logCaughtError(meta) {
|
|
2162
|
+
writeLine(ERRORS_FILE, {
|
|
2163
|
+
type: "caught_error",
|
|
2164
|
+
...meta
|
|
2165
|
+
});
|
|
2166
|
+
}
|
|
2167
|
+
function safeParseJson(s) {
|
|
2168
|
+
try {
|
|
2169
|
+
return JSON.parse(s);
|
|
2170
|
+
} catch {
|
|
2171
|
+
return s;
|
|
2172
|
+
}
|
|
2173
|
+
}
|
|
2174
|
+
|
|
2097
2175
|
// src/transform.ts
|
|
2098
2176
|
import { createHash as createHash2 } from "node:crypto";
|
|
2099
2177
|
|
|
@@ -2313,15 +2391,18 @@ ${uim.content}`;
|
|
|
2313
2391
|
}
|
|
2314
2392
|
if (msg.role === "assistant") {
|
|
2315
2393
|
let armContent = "";
|
|
2394
|
+
let armReasoningText = "";
|
|
2395
|
+
let armReasoningSignature = "";
|
|
2316
2396
|
const armToolUses = [];
|
|
2317
2397
|
if (Array.isArray(msg.content)) {
|
|
2318
2398
|
for (const block of msg.content) {
|
|
2319
2399
|
if (block.type === "text") {
|
|
2320
2400
|
armContent += block.text;
|
|
2321
2401
|
} else if (block.type === "thinking") {
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2402
|
+
const tb = block;
|
|
2403
|
+
armReasoningText += tb.thinking;
|
|
2404
|
+
if (tb.thinkingSignature)
|
|
2405
|
+
armReasoningSignature = tb.thinkingSignature;
|
|
2325
2406
|
} else if (block.type === "toolCall") {
|
|
2326
2407
|
const tc = block;
|
|
2327
2408
|
armToolUses.push({
|
|
@@ -2332,12 +2413,15 @@ ${armContent}`;
|
|
|
2332
2413
|
}
|
|
2333
2414
|
}
|
|
2334
2415
|
}
|
|
2335
|
-
|
|
2416
|
+
const hasReasoning = armReasoningText.length > 0;
|
|
2417
|
+
if (!armContent && armToolUses.length === 0 && !hasReasoning)
|
|
2336
2418
|
continue;
|
|
2419
|
+
const reasoningContent = hasReasoning && armReasoningSignature ? { reasoningText: { text: armReasoningText, signature: armReasoningSignature } } : undefined;
|
|
2337
2420
|
history.push({
|
|
2338
2421
|
assistantResponseMessage: {
|
|
2339
2422
|
content: armContent,
|
|
2340
|
-
...armToolUses.length > 0 ? { toolUses: armToolUses } : {}
|
|
2423
|
+
...armToolUses.length > 0 ? { toolUses: armToolUses } : {},
|
|
2424
|
+
...reasoningContent ? { reasoningContent } : {}
|
|
2341
2425
|
}
|
|
2342
2426
|
});
|
|
2343
2427
|
continue;
|
|
@@ -2401,7 +2485,38 @@ Tool results provided.`;
|
|
|
2401
2485
|
});
|
|
2402
2486
|
}
|
|
2403
2487
|
}
|
|
2404
|
-
return { history: collapseAgenticLoops(history), systemPrepended, currentMsgStartIdx };
|
|
2488
|
+
return { history: sanitizeHistory(collapseAgenticLoops(history)), systemPrepended, currentMsgStartIdx };
|
|
2489
|
+
}
|
|
2490
|
+
function sanitizeHistory(history) {
|
|
2491
|
+
for (let i = 0;i < history.length; i++) {
|
|
2492
|
+
const entry = history[i];
|
|
2493
|
+
const arm = entry?.assistantResponseMessage;
|
|
2494
|
+
if (!arm?.toolUses || arm.toolUses.length === 0)
|
|
2495
|
+
continue;
|
|
2496
|
+
const seen = new Set;
|
|
2497
|
+
arm.toolUses = arm.toolUses.filter((tu) => {
|
|
2498
|
+
if (seen.has(tu.toolUseId))
|
|
2499
|
+
return false;
|
|
2500
|
+
seen.add(tu.toolUseId);
|
|
2501
|
+
return true;
|
|
2502
|
+
});
|
|
2503
|
+
const next = i + 1 < history.length ? history[i + 1] : undefined;
|
|
2504
|
+
const toolResults = next?.userInputMessage?.userInputMessageContext?.toolResults;
|
|
2505
|
+
if (!toolResults) {
|
|
2506
|
+
delete arm.toolUses;
|
|
2507
|
+
continue;
|
|
2508
|
+
}
|
|
2509
|
+
const resultIdSet = new Set(toolResults.map((tr) => tr.toolUseId));
|
|
2510
|
+
const useIdSet = new Set(arm.toolUses.map((tu) => tu.toolUseId));
|
|
2511
|
+
arm.toolUses = arm.toolUses.filter((tu) => resultIdSet.has(tu.toolUseId));
|
|
2512
|
+
if (arm.toolUses.length === 0)
|
|
2513
|
+
delete arm.toolUses;
|
|
2514
|
+
const ctx = next.userInputMessage.userInputMessageContext;
|
|
2515
|
+
ctx.toolResults = toolResults.filter((tr) => useIdSet.has(tr.toolUseId));
|
|
2516
|
+
if (ctx.toolResults.length === 0)
|
|
2517
|
+
delete ctx.toolResults;
|
|
2518
|
+
}
|
|
2519
|
+
return history;
|
|
2405
2520
|
}
|
|
2406
2521
|
function collapseAgenticLoops(history) {
|
|
2407
2522
|
if (history.length < 4)
|
|
@@ -2594,9 +2709,9 @@ ${systemPrompt}` : ""}`;
|
|
|
2594
2709
|
const normalized = normalizeMessages(context.messages);
|
|
2595
2710
|
const {
|
|
2596
2711
|
history,
|
|
2597
|
-
systemPrepended,
|
|
2712
|
+
systemPrepended: _systemPrepended,
|
|
2598
2713
|
currentMsgStartIdx
|
|
2599
|
-
} = buildHistory(normalized, kiroModelId
|
|
2714
|
+
} = buildHistory(normalized, kiroModelId);
|
|
2600
2715
|
const seedInstruction = SYSTEM_SEED_INSTRUCTION.replace("{{modelId}}", kiroModelId);
|
|
2601
2716
|
const seedPair = [
|
|
2602
2717
|
{ userInputMessage: { content: seedInstruction, origin: "KIRO_CLI" } },
|
|
@@ -2636,7 +2751,7 @@ ${systemPrompt}` : ""}`;
|
|
|
2636
2751
|
const hasReasoning = armReasoningText.length > 0;
|
|
2637
2752
|
if (armContent || armToolUses.length > 0 || hasReasoning) {
|
|
2638
2753
|
const last = history[history.length - 1];
|
|
2639
|
-
const reasoningContent = hasReasoning ? { reasoningText: { text: armReasoningText, signature: armReasoningSignature } } : undefined;
|
|
2754
|
+
const reasoningContent = hasReasoning && armReasoningSignature ? { reasoningText: { text: armReasoningText, signature: armReasoningSignature } } : undefined;
|
|
2640
2755
|
if (last && !last.userInputMessage && last.assistantResponseMessage) {
|
|
2641
2756
|
last.assistantResponseMessage.content += `
|
|
2642
2757
|
|
|
@@ -2712,7 +2827,7 @@ ${armContent}`;
|
|
|
2712
2827
|
currentContent = "Tool results provided.";
|
|
2713
2828
|
} else if (firstMsg?.role === "user") {
|
|
2714
2829
|
currentContent = typeof firstMsg.content === "string" ? firstMsg.content : getContentText(firstMsg);
|
|
2715
|
-
if (systemPrompt
|
|
2830
|
+
if (systemPrompt) {
|
|
2716
2831
|
currentContent = `${systemPrompt}
|
|
2717
2832
|
|
|
2718
2833
|
${currentContent}`;
|
|
@@ -2810,6 +2925,14 @@ ${currentContent}`;
|
|
|
2810
2925
|
__require("fs").writeFileSync("/tmp/kiro-last-request.json", requestBody);
|
|
2811
2926
|
} catch {}
|
|
2812
2927
|
}
|
|
2928
|
+
logRequest({
|
|
2929
|
+
endpoint,
|
|
2930
|
+
model: model.id,
|
|
2931
|
+
historyLength: history.length,
|
|
2932
|
+
requestBodyChars: requestBody.length,
|
|
2933
|
+
attempt: retryCount,
|
|
2934
|
+
conversationId
|
|
2935
|
+
}, requestBody);
|
|
2813
2936
|
response = await fetch(endpoint, {
|
|
2814
2937
|
method: "POST",
|
|
2815
2938
|
headers: {
|
|
@@ -2841,6 +2964,15 @@ ${currentContent}`;
|
|
|
2841
2964
|
status: response.status,
|
|
2842
2965
|
body: errText
|
|
2843
2966
|
});
|
|
2967
|
+
logHttpError({
|
|
2968
|
+
status: response.status,
|
|
2969
|
+
statusText: response.statusText,
|
|
2970
|
+
body: errText,
|
|
2971
|
+
endpoint,
|
|
2972
|
+
model: model.id,
|
|
2973
|
+
attempt: retryCount,
|
|
2974
|
+
historyLength: history.length
|
|
2975
|
+
});
|
|
2844
2976
|
if (isCapacityError(errText) && capacityRetryCount < CAPACITY_MAX_RETRIES) {
|
|
2845
2977
|
capacityRetryCount++;
|
|
2846
2978
|
const delayMs = exponentialBackoff(capacityRetryCount - 1, CAPACITY_BASE_DELAY_MS, CAPACITY_MAX_DELAY_MS);
|
|
@@ -2984,6 +3116,9 @@ ${currentContent}`;
|
|
|
2984
3116
|
log.debug("stream.event", { seq: eventSeq++, event: ev });
|
|
2985
3117
|
}
|
|
2986
3118
|
}
|
|
3119
|
+
for (const ev of events) {
|
|
3120
|
+
logResponseEvent({ type: ev.type, data: ev.data, eventSeq });
|
|
3121
|
+
}
|
|
2987
3122
|
for (const event of events) {
|
|
2988
3123
|
switch (event.type) {
|
|
2989
3124
|
case "contextUsage": {
|
|
@@ -3074,6 +3209,12 @@ ${currentContent}`;
|
|
|
3074
3209
|
}
|
|
3075
3210
|
case "error": {
|
|
3076
3211
|
streamError = event.data.message ? `${event.data.error}: ${event.data.message}` : event.data.error;
|
|
3212
|
+
logStreamError({
|
|
3213
|
+
error: streamError,
|
|
3214
|
+
context: "stream_event",
|
|
3215
|
+
model: model.id,
|
|
3216
|
+
attempt: retryCount
|
|
3217
|
+
});
|
|
3077
3218
|
reader.cancel().catch(() => {});
|
|
3078
3219
|
break;
|
|
3079
3220
|
}
|
|
@@ -3088,7 +3229,14 @@ ${currentContent}`;
|
|
|
3088
3229
|
if (retryCount < MAX_RETRIES) {
|
|
3089
3230
|
retryCount++;
|
|
3090
3231
|
const delayMs = exponentialBackoff(retryCount - 1, 1000, MAX_RETRY_DELAY_MS);
|
|
3091
|
-
|
|
3232
|
+
const streamErrDesc = firstTokenTimedOut ? "first-token timed out" : idleCancelled ? "idle timed out" : `error: ${streamError}`;
|
|
3233
|
+
logStreamError({
|
|
3234
|
+
error: streamErrDesc,
|
|
3235
|
+
context: "retry",
|
|
3236
|
+
model: model.id,
|
|
3237
|
+
attempt: retryCount
|
|
3238
|
+
});
|
|
3239
|
+
log.info(`stream ${streamErrDesc} — retrying (${retryCount}/${MAX_RETRIES})`);
|
|
3092
3240
|
cancelHiddenShim();
|
|
3093
3241
|
await abortableDelay(delayMs, options?.signal);
|
|
3094
3242
|
output.content = [];
|
|
@@ -3163,6 +3311,13 @@ ${currentContent}`;
|
|
|
3163
3311
|
sawAnyToolCalls,
|
|
3164
3312
|
usage: output.usage
|
|
3165
3313
|
});
|
|
3314
|
+
logResponseDone({
|
|
3315
|
+
stopReason: output.stopReason,
|
|
3316
|
+
emittedToolCalls,
|
|
3317
|
+
usage: output.usage,
|
|
3318
|
+
contentBlocks: output.content.length,
|
|
3319
|
+
model: model.id
|
|
3320
|
+
});
|
|
3166
3321
|
stream.end();
|
|
3167
3322
|
return;
|
|
3168
3323
|
}
|
|
@@ -3170,6 +3325,11 @@ ${currentContent}`;
|
|
|
3170
3325
|
output.stopReason = options?.signal?.aborted ? "aborted" : "error";
|
|
3171
3326
|
output.errorMessage = error instanceof Error ? error.message : String(error);
|
|
3172
3327
|
log.debug("response.caught", { stopReason: output.stopReason, error: output.errorMessage });
|
|
3328
|
+
logCaughtError({
|
|
3329
|
+
stopReason: output.stopReason,
|
|
3330
|
+
errorMessage: output.errorMessage,
|
|
3331
|
+
model: model.id
|
|
3332
|
+
});
|
|
3173
3333
|
if (hiddenShimTimer) {
|
|
3174
3334
|
clearTimeout(hiddenShimTimer);
|
|
3175
3335
|
hiddenShimTimer = null;
|
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;AA8FrE;;;;;;;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,CA+3B7B"}
|
package/dist/transform.d.ts
CHANGED
|
@@ -108,6 +108,24 @@ export declare function buildHistory(messages: Message[], _modelId: string, syst
|
|
|
108
108
|
systemPrepended: boolean;
|
|
109
109
|
currentMsgStartIdx: number;
|
|
110
110
|
};
|
|
111
|
+
/**
|
|
112
|
+
* Sanitize the Kiro history to prevent Bedrock validation errors:
|
|
113
|
+
*
|
|
114
|
+
* 1. **TOOL_DUPLICATE**: Deduplicate toolUseIds within each assistant
|
|
115
|
+
* message — keep the first occurrence, drop subsequent ones.
|
|
116
|
+
*
|
|
117
|
+
* 2. **TOOL_USE_RESULT_MISMATCH**: Every ASST with toolUses must be
|
|
118
|
+
* followed by a USER with toolResults whose IDs match. Remove
|
|
119
|
+
* orphan toolUses that have no matching toolResult in the next
|
|
120
|
+
* message, and remove orphan toolResults whose toolUse doesn't
|
|
121
|
+
* exist in the preceding assistant.
|
|
122
|
+
*
|
|
123
|
+
* This runs as a defensive last pass — upstream logic (buildHistory,
|
|
124
|
+
* stream.ts current-turn assembly) should produce correct output, but
|
|
125
|
+
* edge cases in retry / cross-provider handoff can violate the
|
|
126
|
+
* invariants Bedrock enforces.
|
|
127
|
+
*/
|
|
128
|
+
export declare function sanitizeHistory(history: KiroHistoryEntry[]): KiroHistoryEntry[];
|
|
111
129
|
/**
|
|
112
130
|
* Collapse consecutive tool-use loops in history. When the agent calls
|
|
113
131
|
* 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,C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B,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.2.
|
|
3
|
+
"version": "0.2.2",
|
|
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",
|