@javargasm/pi-kiro 0.4.8 → 0.4.10
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/CHANGELOG.md +30 -0
- package/dist/core.js +101 -120
- package/dist/event-parser.d.ts.map +1 -1
- package/dist/extension.js +101 -120
- package/dist/models.d.ts.map +1 -1
- package/dist/stream.d.ts.map +1 -1
- package/dist/transform.d.ts +36 -0
- package/dist/transform.d.ts.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Tool-call reliability fixes and stale-model cleanup.
|
|
8
|
+
|
|
9
|
+
- fix(stream): preserve tool parameter names during schema sanitization (replaces deepCleanSchema). Keys under `properties` are parameter names, not JSON Schema keywords, so they must not be filtered against the allowlist — the old behavior dropped every parameter while `required` still referenced them.
|
|
10
|
+
- fix(stream): stop leaking the internal `__tool_use_purpose` field in `toolcall_delta` — emit cleaned args so delta and toolcall_end agree.
|
|
11
|
+
- fix(stream): inject a placeholder toolConfig when replayed history contains toolUse/toolResult blocks but the current turn supplies no tools. Prevents Bedrock TOOL_CONFIG_MISSING 400 loops on auxiliary turns (title generation, summarization, compaction).
|
|
12
|
+
- fix(event-parser): don't treat metering frames (`{"unit":"credit","usage":<number>}`) as usage events, which clobbered real token counts.
|
|
13
|
+
- chore(models): drop stale static model ids (1M variants, deepseek-3.2, kimi-k2.5, glm-4.7/flash, qwen3-coder-480b, agi-nova-beta-1m) now resolved dynamically.
|
|
14
|
+
- test(debug): make log-level tests hermetic against ambient KIRO_LOG/KIRO_LOG_FILE env.
|
|
15
|
+
|
|
16
|
+
## 0.4.9
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- 8a547ef: fix: sanitize history to prevent Bedrock TOOL_DUPLICATE and TOOL_USE_RESULT_MISMATCH errors
|
|
21
|
+
|
|
22
|
+
Added `sanitizeHistory` defense-in-depth pass that runs after `collapseAgenticLoops`:
|
|
23
|
+
|
|
24
|
+
- Deduplicates toolUseIds within each assistant message (prevents TOOL_DUPLICATE)
|
|
25
|
+
- Removes orphan toolUses without matching toolResults (prevents TOOL_USE_RESULT_MISMATCH)
|
|
26
|
+
- Removes orphan toolResults without matching toolUses
|
|
27
|
+
|
|
28
|
+
These errors surfaced during retry loops where the same assistant message
|
|
29
|
+
with tool calls could be re-injected into the history.
|
|
30
|
+
|
|
31
|
+
- refactor: define `TestCase` type in smoke-live test to fix `TS2304` compilation error
|
|
32
|
+
|
|
3
33
|
## 0.4.8
|
|
4
34
|
|
|
5
35
|
### Patch Changes
|
package/dist/core.js
CHANGED
|
@@ -555,23 +555,14 @@ var KIRO_MODEL_IDS = new Set([
|
|
|
555
555
|
"claude-opus-4.8",
|
|
556
556
|
"claude-opus-4.7",
|
|
557
557
|
"claude-opus-4.6",
|
|
558
|
-
"claude-opus-4.6-1m",
|
|
559
558
|
"claude-sonnet-4.6",
|
|
560
|
-
"claude-sonnet-4.6-1m",
|
|
561
559
|
"claude-opus-4.5",
|
|
562
560
|
"claude-sonnet-4.5",
|
|
563
|
-
"claude-sonnet-4.5-1m",
|
|
564
561
|
"claude-sonnet-4",
|
|
565
562
|
"claude-haiku-4.5",
|
|
566
|
-
"deepseek-3.2",
|
|
567
|
-
"kimi-k2.5",
|
|
568
563
|
"minimax-m2.1",
|
|
569
564
|
"minimax-m2.5",
|
|
570
|
-
"glm-4.7",
|
|
571
|
-
"glm-4.7-flash",
|
|
572
565
|
"qwen3-coder-next",
|
|
573
|
-
"agi-nova-beta-1m",
|
|
574
|
-
"qwen3-coder-480b",
|
|
575
566
|
"auto"
|
|
576
567
|
]);
|
|
577
568
|
function dashToDot(modelId) {
|
|
@@ -620,23 +611,14 @@ var MODELS_BY_REGION = {
|
|
|
620
611
|
"claude-opus-4-8",
|
|
621
612
|
"claude-opus-4-7",
|
|
622
613
|
"claude-opus-4-6",
|
|
623
|
-
"claude-opus-4-6-1m",
|
|
624
614
|
"claude-sonnet-4-6",
|
|
625
|
-
"claude-sonnet-4-6-1m",
|
|
626
615
|
"claude-opus-4-5",
|
|
627
616
|
"claude-sonnet-4-5",
|
|
628
|
-
"claude-sonnet-4-5-1m",
|
|
629
617
|
"claude-sonnet-4",
|
|
630
618
|
"claude-haiku-4-5",
|
|
631
|
-
"deepseek-3-2",
|
|
632
|
-
"kimi-k2-5",
|
|
633
619
|
"minimax-m2-1",
|
|
634
620
|
"minimax-m2-5",
|
|
635
|
-
"glm-4-7",
|
|
636
|
-
"glm-4-7-flash",
|
|
637
621
|
"qwen3-coder-next",
|
|
638
|
-
"qwen3-coder-480b",
|
|
639
|
-
"agi-nova-beta-1m",
|
|
640
622
|
"auto"
|
|
641
623
|
]),
|
|
642
624
|
"eu-central-1": new Set([
|
|
@@ -728,17 +710,6 @@ var kiroModels = [
|
|
|
728
710
|
supportedEfforts: ["low", "medium", "high", "max"],
|
|
729
711
|
supportsThinkingConfig: true
|
|
730
712
|
},
|
|
731
|
-
{
|
|
732
|
-
...KIRO_DEFAULTS,
|
|
733
|
-
id: "claude-opus-4-6-1m",
|
|
734
|
-
name: "Claude Opus 4.6 (1M)",
|
|
735
|
-
reasoning: true,
|
|
736
|
-
input: MULTIMODAL,
|
|
737
|
-
contextWindow: 1e6,
|
|
738
|
-
maxTokens: 64000,
|
|
739
|
-
supportedEfforts: ["low", "medium", "high", "max"],
|
|
740
|
-
supportsThinkingConfig: true
|
|
741
|
-
},
|
|
742
713
|
{
|
|
743
714
|
...KIRO_DEFAULTS,
|
|
744
715
|
id: "claude-sonnet-4-6",
|
|
@@ -750,17 +721,6 @@ var kiroModels = [
|
|
|
750
721
|
supportedEfforts: ["low", "medium", "high", "max"],
|
|
751
722
|
supportsThinkingConfig: true
|
|
752
723
|
},
|
|
753
|
-
{
|
|
754
|
-
...KIRO_DEFAULTS,
|
|
755
|
-
id: "claude-sonnet-4-6-1m",
|
|
756
|
-
name: "Claude Sonnet 4.6 (1M)",
|
|
757
|
-
reasoning: true,
|
|
758
|
-
input: MULTIMODAL,
|
|
759
|
-
contextWindow: 1e6,
|
|
760
|
-
maxTokens: 64000,
|
|
761
|
-
supportedEfforts: ["low", "medium", "high", "max"],
|
|
762
|
-
supportsThinkingConfig: true
|
|
763
|
-
},
|
|
764
724
|
{
|
|
765
725
|
...KIRO_DEFAULTS,
|
|
766
726
|
id: "claude-opus-4-5",
|
|
@@ -779,15 +739,6 @@ var kiroModels = [
|
|
|
779
739
|
contextWindow: 200000,
|
|
780
740
|
maxTokens: 65536
|
|
781
741
|
},
|
|
782
|
-
{
|
|
783
|
-
...KIRO_DEFAULTS,
|
|
784
|
-
id: "claude-sonnet-4-5-1m",
|
|
785
|
-
name: "Claude Sonnet 4.5 (1M)",
|
|
786
|
-
reasoning: true,
|
|
787
|
-
input: MULTIMODAL,
|
|
788
|
-
contextWindow: 1e6,
|
|
789
|
-
maxTokens: 65536
|
|
790
|
-
},
|
|
791
742
|
{
|
|
792
743
|
...KIRO_DEFAULTS,
|
|
793
744
|
id: "claude-sonnet-4",
|
|
@@ -806,24 +757,6 @@ var kiroModels = [
|
|
|
806
757
|
contextWindow: 200000,
|
|
807
758
|
maxTokens: 65536
|
|
808
759
|
},
|
|
809
|
-
{
|
|
810
|
-
...KIRO_DEFAULTS,
|
|
811
|
-
id: "deepseek-3-2",
|
|
812
|
-
name: "DeepSeek 3.2",
|
|
813
|
-
reasoning: true,
|
|
814
|
-
input: TEXT_ONLY,
|
|
815
|
-
contextWindow: 128000,
|
|
816
|
-
maxTokens: 8192
|
|
817
|
-
},
|
|
818
|
-
{
|
|
819
|
-
...KIRO_DEFAULTS,
|
|
820
|
-
id: "kimi-k2-5",
|
|
821
|
-
name: "Kimi K2.5",
|
|
822
|
-
reasoning: true,
|
|
823
|
-
input: TEXT_ONLY,
|
|
824
|
-
contextWindow: 200000,
|
|
825
|
-
maxTokens: 8192
|
|
826
|
-
},
|
|
827
760
|
{
|
|
828
761
|
...KIRO_DEFAULTS,
|
|
829
762
|
id: "minimax-m2-5",
|
|
@@ -842,24 +775,6 @@ var kiroModels = [
|
|
|
842
775
|
contextWindow: 196000,
|
|
843
776
|
maxTokens: 64000
|
|
844
777
|
},
|
|
845
|
-
{
|
|
846
|
-
...KIRO_DEFAULTS,
|
|
847
|
-
id: "glm-4-7",
|
|
848
|
-
name: "GLM 4.7",
|
|
849
|
-
reasoning: true,
|
|
850
|
-
input: TEXT_ONLY,
|
|
851
|
-
contextWindow: 128000,
|
|
852
|
-
maxTokens: 8192
|
|
853
|
-
},
|
|
854
|
-
{
|
|
855
|
-
...KIRO_DEFAULTS,
|
|
856
|
-
id: "glm-4-7-flash",
|
|
857
|
-
name: "GLM 4.7 Flash",
|
|
858
|
-
reasoning: false,
|
|
859
|
-
input: TEXT_ONLY,
|
|
860
|
-
contextWindow: 128000,
|
|
861
|
-
maxTokens: 8192
|
|
862
|
-
},
|
|
863
778
|
{
|
|
864
779
|
...KIRO_DEFAULTS,
|
|
865
780
|
id: "qwen3-coder-next",
|
|
@@ -869,24 +784,6 @@ var kiroModels = [
|
|
|
869
784
|
contextWindow: 256000,
|
|
870
785
|
maxTokens: 64000
|
|
871
786
|
},
|
|
872
|
-
{
|
|
873
|
-
...KIRO_DEFAULTS,
|
|
874
|
-
id: "qwen3-coder-480b",
|
|
875
|
-
name: "Qwen3 Coder 480B",
|
|
876
|
-
reasoning: true,
|
|
877
|
-
input: TEXT_ONLY,
|
|
878
|
-
contextWindow: 128000,
|
|
879
|
-
maxTokens: 8192
|
|
880
|
-
},
|
|
881
|
-
{
|
|
882
|
-
...KIRO_DEFAULTS,
|
|
883
|
-
id: "agi-nova-beta-1m",
|
|
884
|
-
name: "AGI Nova Beta (1M)",
|
|
885
|
-
reasoning: true,
|
|
886
|
-
input: MULTIMODAL,
|
|
887
|
-
contextWindow: 1e6,
|
|
888
|
-
maxTokens: 65536
|
|
889
|
-
},
|
|
890
787
|
{
|
|
891
788
|
...KIRO_DEFAULTS,
|
|
892
789
|
id: "auto",
|
|
@@ -2007,7 +1904,7 @@ function parseKiroEvent(parsed) {
|
|
|
2007
1904
|
}
|
|
2008
1905
|
};
|
|
2009
1906
|
}
|
|
2010
|
-
if (parsed.usage !== undefined) {
|
|
1907
|
+
if (parsed.usage !== undefined && typeof parsed.usage === "object" && parsed.usage !== null) {
|
|
2011
1908
|
const u = parsed.usage;
|
|
2012
1909
|
return {
|
|
2013
1910
|
type: "usage",
|
|
@@ -2353,6 +2250,22 @@ import { createHash as createHash2 } from "node:crypto";
|
|
|
2353
2250
|
function normalizeMessages(messages) {
|
|
2354
2251
|
return messages.filter((msg) => msg.role !== "assistant" || msg.stopReason !== "error" && msg.stopReason !== "aborted");
|
|
2355
2252
|
}
|
|
2253
|
+
var KIRO_PLACEHOLDER_TOOL = {
|
|
2254
|
+
toolSpecification: {
|
|
2255
|
+
name: "noop",
|
|
2256
|
+
description: "Placeholder tool. Do not call it. Present only to satisfy the toolConfig requirement when replayed history contains tool blocks.",
|
|
2257
|
+
inputSchema: { json: { type: "object", properties: {} } }
|
|
2258
|
+
}
|
|
2259
|
+
};
|
|
2260
|
+
function historyHasToolBlocks(history) {
|
|
2261
|
+
for (const entry of history) {
|
|
2262
|
+
if (entry.assistantResponseMessage?.toolUses?.length)
|
|
2263
|
+
return true;
|
|
2264
|
+
if (entry.userInputMessage?.userInputMessageContext?.toolResults?.length)
|
|
2265
|
+
return true;
|
|
2266
|
+
}
|
|
2267
|
+
return false;
|
|
2268
|
+
}
|
|
2356
2269
|
var TOOL_RESULT_LIMIT = 250000;
|
|
2357
2270
|
var MAX_KIRO_IMAGES = 4;
|
|
2358
2271
|
var MAX_KIRO_IMAGE_BYTES = 3750000;
|
|
@@ -2566,7 +2479,38 @@ Tool results provided.`;
|
|
|
2566
2479
|
});
|
|
2567
2480
|
}
|
|
2568
2481
|
}
|
|
2569
|
-
return { history: collapseAgenticLoops(history), systemPrepended, currentMsgStartIdx };
|
|
2482
|
+
return { history: sanitizeHistory(collapseAgenticLoops(history)), systemPrepended, currentMsgStartIdx };
|
|
2483
|
+
}
|
|
2484
|
+
function sanitizeHistory(history) {
|
|
2485
|
+
for (let i = 0;i < history.length; i++) {
|
|
2486
|
+
const entry = history[i];
|
|
2487
|
+
const arm = entry?.assistantResponseMessage;
|
|
2488
|
+
if (!arm?.toolUses || arm.toolUses.length === 0)
|
|
2489
|
+
continue;
|
|
2490
|
+
const seen = new Set;
|
|
2491
|
+
arm.toolUses = arm.toolUses.filter((tu) => {
|
|
2492
|
+
if (seen.has(tu.toolUseId))
|
|
2493
|
+
return false;
|
|
2494
|
+
seen.add(tu.toolUseId);
|
|
2495
|
+
return true;
|
|
2496
|
+
});
|
|
2497
|
+
const next = i + 1 < history.length ? history[i + 1] : undefined;
|
|
2498
|
+
const toolResults = next?.userInputMessage?.userInputMessageContext?.toolResults;
|
|
2499
|
+
if (!toolResults) {
|
|
2500
|
+
delete arm.toolUses;
|
|
2501
|
+
continue;
|
|
2502
|
+
}
|
|
2503
|
+
const resultIdSet = new Set(toolResults.map((tr) => tr.toolUseId));
|
|
2504
|
+
const useIdSet = new Set(arm.toolUses.map((tu) => tu.toolUseId));
|
|
2505
|
+
arm.toolUses = arm.toolUses.filter((tu) => resultIdSet.has(tu.toolUseId));
|
|
2506
|
+
if (arm.toolUses.length === 0)
|
|
2507
|
+
delete arm.toolUses;
|
|
2508
|
+
const ctx = next.userInputMessage.userInputMessageContext;
|
|
2509
|
+
ctx.toolResults = toolResults.filter((tr) => useIdSet.has(tr.toolUseId));
|
|
2510
|
+
if (ctx.toolResults.length === 0)
|
|
2511
|
+
delete ctx.toolResults;
|
|
2512
|
+
}
|
|
2513
|
+
return history;
|
|
2570
2514
|
}
|
|
2571
2515
|
function collapseAgenticLoops(history) {
|
|
2572
2516
|
if (history.length < 4)
|
|
@@ -2729,7 +2673,7 @@ function emitToolCall(state, output, stream) {
|
|
|
2729
2673
|
const toolCall = { type: "toolCall", id: state.toolUseId, name: state.name, arguments: args };
|
|
2730
2674
|
output.content.push(toolCall);
|
|
2731
2675
|
stream.push({ type: "toolcall_start", contentIndex, partial: output });
|
|
2732
|
-
stream.push({ type: "toolcall_delta", contentIndex, delta:
|
|
2676
|
+
stream.push({ type: "toolcall_delta", contentIndex, delta: JSON.stringify(args), partial: output });
|
|
2733
2677
|
stream.push({ type: "toolcall_end", contentIndex, toolCall, partial: output });
|
|
2734
2678
|
return true;
|
|
2735
2679
|
}
|
|
@@ -2943,25 +2887,60 @@ ${currentContent}`;
|
|
|
2943
2887
|
if (currentToolResults.length > 0)
|
|
2944
2888
|
uimc.toolResults = currentToolResults;
|
|
2945
2889
|
if (context.tools?.length) {
|
|
2946
|
-
const
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2890
|
+
const ALLOWED_SCHEMA_KEYS = new Set([
|
|
2891
|
+
"type",
|
|
2892
|
+
"properties",
|
|
2893
|
+
"required",
|
|
2894
|
+
"description",
|
|
2895
|
+
"enum",
|
|
2896
|
+
"items",
|
|
2897
|
+
"default",
|
|
2898
|
+
"oneOf",
|
|
2899
|
+
"anyOf",
|
|
2900
|
+
"allOf",
|
|
2901
|
+
"minimum",
|
|
2902
|
+
"maximum",
|
|
2903
|
+
"minLength",
|
|
2904
|
+
"maxLength",
|
|
2905
|
+
"minItems",
|
|
2906
|
+
"maxItems",
|
|
2907
|
+
"pattern",
|
|
2908
|
+
"const",
|
|
2909
|
+
"title",
|
|
2910
|
+
"additionalProperties"
|
|
2911
|
+
]);
|
|
2912
|
+
const sanitizeSchema = (obj) => {
|
|
2913
|
+
if (obj === null || obj === undefined)
|
|
2914
|
+
return obj;
|
|
2915
|
+
if (Array.isArray(obj))
|
|
2916
|
+
return obj.map(sanitizeSchema);
|
|
2917
|
+
if (typeof obj !== "object")
|
|
2918
|
+
return obj;
|
|
2919
|
+
const result = {};
|
|
2920
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
2921
|
+
if (!ALLOWED_SCHEMA_KEYS.has(key) && key !== "__tool_use_purpose")
|
|
2922
|
+
continue;
|
|
2923
|
+
if (key === "required" && Array.isArray(value) && value.length === 0)
|
|
2924
|
+
continue;
|
|
2925
|
+
if ((key === "minimum" || key === "maximum") && typeof value === "number") {
|
|
2926
|
+
if (Math.abs(value) > 1e9)
|
|
2955
2927
|
continue;
|
|
2956
|
-
cleaned[k] = deepCleanSchema(v);
|
|
2957
2928
|
}
|
|
2958
|
-
|
|
2929
|
+
if (key === "properties" && value && typeof value === "object" && !Array.isArray(value)) {
|
|
2930
|
+
const props = {};
|
|
2931
|
+
for (const [name, sub] of Object.entries(value)) {
|
|
2932
|
+
props[name] = sanitizeSchema(sub);
|
|
2933
|
+
}
|
|
2934
|
+
result[key] = props;
|
|
2935
|
+
continue;
|
|
2936
|
+
}
|
|
2937
|
+
result[key] = sanitizeSchema(value);
|
|
2959
2938
|
}
|
|
2960
|
-
return
|
|
2939
|
+
return result;
|
|
2961
2940
|
};
|
|
2962
2941
|
uimc.tools = context.tools.map((t) => {
|
|
2963
|
-
const params =
|
|
2964
|
-
if (params.properties) {
|
|
2942
|
+
const params = sanitizeSchema(t.parameters);
|
|
2943
|
+
if (params.properties && typeof params.properties === "object" && !Array.isArray(params.properties)) {
|
|
2965
2944
|
params.properties.__tool_use_purpose = {
|
|
2966
2945
|
type: "string",
|
|
2967
2946
|
description: "A brief explanation why you are making this tool use."
|
|
@@ -2975,6 +2954,8 @@ ${currentContent}`;
|
|
|
2975
2954
|
}
|
|
2976
2955
|
};
|
|
2977
2956
|
});
|
|
2957
|
+
} else if (historyHasToolBlocks(history) || currentToolResults.length > 0) {
|
|
2958
|
+
uimc.tools = [KIRO_PLACEHOLDER_TOOL];
|
|
2978
2959
|
}
|
|
2979
2960
|
if (firstMsg?.role === "user") {
|
|
2980
2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,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,CAAC;AAEjE,8EAA8E;AAC9E,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CA2B/D;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,eAAe,GAAG,IAAI,CAgGtF;AAiCD,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,GACb;IAAE,MAAM,EAAE,eAAe,EAAE,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAqElD"}
|
package/dist/extension.js
CHANGED
|
@@ -557,23 +557,14 @@ var KIRO_MODEL_IDS = new Set([
|
|
|
557
557
|
"claude-opus-4.8",
|
|
558
558
|
"claude-opus-4.7",
|
|
559
559
|
"claude-opus-4.6",
|
|
560
|
-
"claude-opus-4.6-1m",
|
|
561
560
|
"claude-sonnet-4.6",
|
|
562
|
-
"claude-sonnet-4.6-1m",
|
|
563
561
|
"claude-opus-4.5",
|
|
564
562
|
"claude-sonnet-4.5",
|
|
565
|
-
"claude-sonnet-4.5-1m",
|
|
566
563
|
"claude-sonnet-4",
|
|
567
564
|
"claude-haiku-4.5",
|
|
568
|
-
"deepseek-3.2",
|
|
569
|
-
"kimi-k2.5",
|
|
570
565
|
"minimax-m2.1",
|
|
571
566
|
"minimax-m2.5",
|
|
572
|
-
"glm-4.7",
|
|
573
|
-
"glm-4.7-flash",
|
|
574
567
|
"qwen3-coder-next",
|
|
575
|
-
"agi-nova-beta-1m",
|
|
576
|
-
"qwen3-coder-480b",
|
|
577
568
|
"auto"
|
|
578
569
|
]);
|
|
579
570
|
function dashToDot(modelId) {
|
|
@@ -622,23 +613,14 @@ var MODELS_BY_REGION = {
|
|
|
622
613
|
"claude-opus-4-8",
|
|
623
614
|
"claude-opus-4-7",
|
|
624
615
|
"claude-opus-4-6",
|
|
625
|
-
"claude-opus-4-6-1m",
|
|
626
616
|
"claude-sonnet-4-6",
|
|
627
|
-
"claude-sonnet-4-6-1m",
|
|
628
617
|
"claude-opus-4-5",
|
|
629
618
|
"claude-sonnet-4-5",
|
|
630
|
-
"claude-sonnet-4-5-1m",
|
|
631
619
|
"claude-sonnet-4",
|
|
632
620
|
"claude-haiku-4-5",
|
|
633
|
-
"deepseek-3-2",
|
|
634
|
-
"kimi-k2-5",
|
|
635
621
|
"minimax-m2-1",
|
|
636
622
|
"minimax-m2-5",
|
|
637
|
-
"glm-4-7",
|
|
638
|
-
"glm-4-7-flash",
|
|
639
623
|
"qwen3-coder-next",
|
|
640
|
-
"qwen3-coder-480b",
|
|
641
|
-
"agi-nova-beta-1m",
|
|
642
624
|
"auto"
|
|
643
625
|
]),
|
|
644
626
|
"eu-central-1": new Set([
|
|
@@ -730,17 +712,6 @@ var kiroModels = [
|
|
|
730
712
|
supportedEfforts: ["low", "medium", "high", "max"],
|
|
731
713
|
supportsThinkingConfig: true
|
|
732
714
|
},
|
|
733
|
-
{
|
|
734
|
-
...KIRO_DEFAULTS,
|
|
735
|
-
id: "claude-opus-4-6-1m",
|
|
736
|
-
name: "Claude Opus 4.6 (1M)",
|
|
737
|
-
reasoning: true,
|
|
738
|
-
input: MULTIMODAL,
|
|
739
|
-
contextWindow: 1e6,
|
|
740
|
-
maxTokens: 64000,
|
|
741
|
-
supportedEfforts: ["low", "medium", "high", "max"],
|
|
742
|
-
supportsThinkingConfig: true
|
|
743
|
-
},
|
|
744
715
|
{
|
|
745
716
|
...KIRO_DEFAULTS,
|
|
746
717
|
id: "claude-sonnet-4-6",
|
|
@@ -752,17 +723,6 @@ var kiroModels = [
|
|
|
752
723
|
supportedEfforts: ["low", "medium", "high", "max"],
|
|
753
724
|
supportsThinkingConfig: true
|
|
754
725
|
},
|
|
755
|
-
{
|
|
756
|
-
...KIRO_DEFAULTS,
|
|
757
|
-
id: "claude-sonnet-4-6-1m",
|
|
758
|
-
name: "Claude Sonnet 4.6 (1M)",
|
|
759
|
-
reasoning: true,
|
|
760
|
-
input: MULTIMODAL,
|
|
761
|
-
contextWindow: 1e6,
|
|
762
|
-
maxTokens: 64000,
|
|
763
|
-
supportedEfforts: ["low", "medium", "high", "max"],
|
|
764
|
-
supportsThinkingConfig: true
|
|
765
|
-
},
|
|
766
726
|
{
|
|
767
727
|
...KIRO_DEFAULTS,
|
|
768
728
|
id: "claude-opus-4-5",
|
|
@@ -781,15 +741,6 @@ var kiroModels = [
|
|
|
781
741
|
contextWindow: 200000,
|
|
782
742
|
maxTokens: 65536
|
|
783
743
|
},
|
|
784
|
-
{
|
|
785
|
-
...KIRO_DEFAULTS,
|
|
786
|
-
id: "claude-sonnet-4-5-1m",
|
|
787
|
-
name: "Claude Sonnet 4.5 (1M)",
|
|
788
|
-
reasoning: true,
|
|
789
|
-
input: MULTIMODAL,
|
|
790
|
-
contextWindow: 1e6,
|
|
791
|
-
maxTokens: 65536
|
|
792
|
-
},
|
|
793
744
|
{
|
|
794
745
|
...KIRO_DEFAULTS,
|
|
795
746
|
id: "claude-sonnet-4",
|
|
@@ -808,24 +759,6 @@ var kiroModels = [
|
|
|
808
759
|
contextWindow: 200000,
|
|
809
760
|
maxTokens: 65536
|
|
810
761
|
},
|
|
811
|
-
{
|
|
812
|
-
...KIRO_DEFAULTS,
|
|
813
|
-
id: "deepseek-3-2",
|
|
814
|
-
name: "DeepSeek 3.2",
|
|
815
|
-
reasoning: true,
|
|
816
|
-
input: TEXT_ONLY,
|
|
817
|
-
contextWindow: 128000,
|
|
818
|
-
maxTokens: 8192
|
|
819
|
-
},
|
|
820
|
-
{
|
|
821
|
-
...KIRO_DEFAULTS,
|
|
822
|
-
id: "kimi-k2-5",
|
|
823
|
-
name: "Kimi K2.5",
|
|
824
|
-
reasoning: true,
|
|
825
|
-
input: TEXT_ONLY,
|
|
826
|
-
contextWindow: 200000,
|
|
827
|
-
maxTokens: 8192
|
|
828
|
-
},
|
|
829
762
|
{
|
|
830
763
|
...KIRO_DEFAULTS,
|
|
831
764
|
id: "minimax-m2-5",
|
|
@@ -844,24 +777,6 @@ var kiroModels = [
|
|
|
844
777
|
contextWindow: 196000,
|
|
845
778
|
maxTokens: 64000
|
|
846
779
|
},
|
|
847
|
-
{
|
|
848
|
-
...KIRO_DEFAULTS,
|
|
849
|
-
id: "glm-4-7",
|
|
850
|
-
name: "GLM 4.7",
|
|
851
|
-
reasoning: true,
|
|
852
|
-
input: TEXT_ONLY,
|
|
853
|
-
contextWindow: 128000,
|
|
854
|
-
maxTokens: 8192
|
|
855
|
-
},
|
|
856
|
-
{
|
|
857
|
-
...KIRO_DEFAULTS,
|
|
858
|
-
id: "glm-4-7-flash",
|
|
859
|
-
name: "GLM 4.7 Flash",
|
|
860
|
-
reasoning: false,
|
|
861
|
-
input: TEXT_ONLY,
|
|
862
|
-
contextWindow: 128000,
|
|
863
|
-
maxTokens: 8192
|
|
864
|
-
},
|
|
865
780
|
{
|
|
866
781
|
...KIRO_DEFAULTS,
|
|
867
782
|
id: "qwen3-coder-next",
|
|
@@ -871,24 +786,6 @@ var kiroModels = [
|
|
|
871
786
|
contextWindow: 256000,
|
|
872
787
|
maxTokens: 64000
|
|
873
788
|
},
|
|
874
|
-
{
|
|
875
|
-
...KIRO_DEFAULTS,
|
|
876
|
-
id: "qwen3-coder-480b",
|
|
877
|
-
name: "Qwen3 Coder 480B",
|
|
878
|
-
reasoning: true,
|
|
879
|
-
input: TEXT_ONLY,
|
|
880
|
-
contextWindow: 128000,
|
|
881
|
-
maxTokens: 8192
|
|
882
|
-
},
|
|
883
|
-
{
|
|
884
|
-
...KIRO_DEFAULTS,
|
|
885
|
-
id: "agi-nova-beta-1m",
|
|
886
|
-
name: "AGI Nova Beta (1M)",
|
|
887
|
-
reasoning: true,
|
|
888
|
-
input: MULTIMODAL,
|
|
889
|
-
contextWindow: 1e6,
|
|
890
|
-
maxTokens: 65536
|
|
891
|
-
},
|
|
892
789
|
{
|
|
893
790
|
...KIRO_DEFAULTS,
|
|
894
791
|
id: "auto",
|
|
@@ -2011,7 +1908,7 @@ function parseKiroEvent(parsed) {
|
|
|
2011
1908
|
}
|
|
2012
1909
|
};
|
|
2013
1910
|
}
|
|
2014
|
-
if (parsed.usage !== undefined) {
|
|
1911
|
+
if (parsed.usage !== undefined && typeof parsed.usage === "object" && parsed.usage !== null) {
|
|
2015
1912
|
const u = parsed.usage;
|
|
2016
1913
|
return {
|
|
2017
1914
|
type: "usage",
|
|
@@ -2357,6 +2254,22 @@ import { createHash as createHash2 } from "node:crypto";
|
|
|
2357
2254
|
function normalizeMessages(messages) {
|
|
2358
2255
|
return messages.filter((msg) => msg.role !== "assistant" || msg.stopReason !== "error" && msg.stopReason !== "aborted");
|
|
2359
2256
|
}
|
|
2257
|
+
var KIRO_PLACEHOLDER_TOOL = {
|
|
2258
|
+
toolSpecification: {
|
|
2259
|
+
name: "noop",
|
|
2260
|
+
description: "Placeholder tool. Do not call it. Present only to satisfy the toolConfig requirement when replayed history contains tool blocks.",
|
|
2261
|
+
inputSchema: { json: { type: "object", properties: {} } }
|
|
2262
|
+
}
|
|
2263
|
+
};
|
|
2264
|
+
function historyHasToolBlocks(history) {
|
|
2265
|
+
for (const entry of history) {
|
|
2266
|
+
if (entry.assistantResponseMessage?.toolUses?.length)
|
|
2267
|
+
return true;
|
|
2268
|
+
if (entry.userInputMessage?.userInputMessageContext?.toolResults?.length)
|
|
2269
|
+
return true;
|
|
2270
|
+
}
|
|
2271
|
+
return false;
|
|
2272
|
+
}
|
|
2360
2273
|
var TOOL_RESULT_LIMIT = 250000;
|
|
2361
2274
|
var MAX_KIRO_IMAGES = 4;
|
|
2362
2275
|
var MAX_KIRO_IMAGE_BYTES = 3750000;
|
|
@@ -2570,7 +2483,38 @@ Tool results provided.`;
|
|
|
2570
2483
|
});
|
|
2571
2484
|
}
|
|
2572
2485
|
}
|
|
2573
|
-
return { history: collapseAgenticLoops(history), systemPrepended, currentMsgStartIdx };
|
|
2486
|
+
return { history: sanitizeHistory(collapseAgenticLoops(history)), systemPrepended, currentMsgStartIdx };
|
|
2487
|
+
}
|
|
2488
|
+
function sanitizeHistory(history) {
|
|
2489
|
+
for (let i = 0;i < history.length; i++) {
|
|
2490
|
+
const entry = history[i];
|
|
2491
|
+
const arm = entry?.assistantResponseMessage;
|
|
2492
|
+
if (!arm?.toolUses || arm.toolUses.length === 0)
|
|
2493
|
+
continue;
|
|
2494
|
+
const seen = new Set;
|
|
2495
|
+
arm.toolUses = arm.toolUses.filter((tu) => {
|
|
2496
|
+
if (seen.has(tu.toolUseId))
|
|
2497
|
+
return false;
|
|
2498
|
+
seen.add(tu.toolUseId);
|
|
2499
|
+
return true;
|
|
2500
|
+
});
|
|
2501
|
+
const next = i + 1 < history.length ? history[i + 1] : undefined;
|
|
2502
|
+
const toolResults = next?.userInputMessage?.userInputMessageContext?.toolResults;
|
|
2503
|
+
if (!toolResults) {
|
|
2504
|
+
delete arm.toolUses;
|
|
2505
|
+
continue;
|
|
2506
|
+
}
|
|
2507
|
+
const resultIdSet = new Set(toolResults.map((tr) => tr.toolUseId));
|
|
2508
|
+
const useIdSet = new Set(arm.toolUses.map((tu) => tu.toolUseId));
|
|
2509
|
+
arm.toolUses = arm.toolUses.filter((tu) => resultIdSet.has(tu.toolUseId));
|
|
2510
|
+
if (arm.toolUses.length === 0)
|
|
2511
|
+
delete arm.toolUses;
|
|
2512
|
+
const ctx = next.userInputMessage.userInputMessageContext;
|
|
2513
|
+
ctx.toolResults = toolResults.filter((tr) => useIdSet.has(tr.toolUseId));
|
|
2514
|
+
if (ctx.toolResults.length === 0)
|
|
2515
|
+
delete ctx.toolResults;
|
|
2516
|
+
}
|
|
2517
|
+
return history;
|
|
2574
2518
|
}
|
|
2575
2519
|
function collapseAgenticLoops(history) {
|
|
2576
2520
|
if (history.length < 4)
|
|
@@ -2733,7 +2677,7 @@ function emitToolCall(state, output, stream) {
|
|
|
2733
2677
|
const toolCall = { type: "toolCall", id: state.toolUseId, name: state.name, arguments: args };
|
|
2734
2678
|
output.content.push(toolCall);
|
|
2735
2679
|
stream.push({ type: "toolcall_start", contentIndex, partial: output });
|
|
2736
|
-
stream.push({ type: "toolcall_delta", contentIndex, delta:
|
|
2680
|
+
stream.push({ type: "toolcall_delta", contentIndex, delta: JSON.stringify(args), partial: output });
|
|
2737
2681
|
stream.push({ type: "toolcall_end", contentIndex, toolCall, partial: output });
|
|
2738
2682
|
return true;
|
|
2739
2683
|
}
|
|
@@ -2947,25 +2891,60 @@ ${currentContent}`;
|
|
|
2947
2891
|
if (currentToolResults.length > 0)
|
|
2948
2892
|
uimc.toolResults = currentToolResults;
|
|
2949
2893
|
if (context.tools?.length) {
|
|
2950
|
-
const
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2894
|
+
const ALLOWED_SCHEMA_KEYS = new Set([
|
|
2895
|
+
"type",
|
|
2896
|
+
"properties",
|
|
2897
|
+
"required",
|
|
2898
|
+
"description",
|
|
2899
|
+
"enum",
|
|
2900
|
+
"items",
|
|
2901
|
+
"default",
|
|
2902
|
+
"oneOf",
|
|
2903
|
+
"anyOf",
|
|
2904
|
+
"allOf",
|
|
2905
|
+
"minimum",
|
|
2906
|
+
"maximum",
|
|
2907
|
+
"minLength",
|
|
2908
|
+
"maxLength",
|
|
2909
|
+
"minItems",
|
|
2910
|
+
"maxItems",
|
|
2911
|
+
"pattern",
|
|
2912
|
+
"const",
|
|
2913
|
+
"title",
|
|
2914
|
+
"additionalProperties"
|
|
2915
|
+
]);
|
|
2916
|
+
const sanitizeSchema = (obj) => {
|
|
2917
|
+
if (obj === null || obj === undefined)
|
|
2918
|
+
return obj;
|
|
2919
|
+
if (Array.isArray(obj))
|
|
2920
|
+
return obj.map(sanitizeSchema);
|
|
2921
|
+
if (typeof obj !== "object")
|
|
2922
|
+
return obj;
|
|
2923
|
+
const result = {};
|
|
2924
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
2925
|
+
if (!ALLOWED_SCHEMA_KEYS.has(key) && key !== "__tool_use_purpose")
|
|
2926
|
+
continue;
|
|
2927
|
+
if (key === "required" && Array.isArray(value) && value.length === 0)
|
|
2928
|
+
continue;
|
|
2929
|
+
if ((key === "minimum" || key === "maximum") && typeof value === "number") {
|
|
2930
|
+
if (Math.abs(value) > 1e9)
|
|
2959
2931
|
continue;
|
|
2960
|
-
cleaned[k] = deepCleanSchema(v);
|
|
2961
2932
|
}
|
|
2962
|
-
|
|
2933
|
+
if (key === "properties" && value && typeof value === "object" && !Array.isArray(value)) {
|
|
2934
|
+
const props = {};
|
|
2935
|
+
for (const [name, sub] of Object.entries(value)) {
|
|
2936
|
+
props[name] = sanitizeSchema(sub);
|
|
2937
|
+
}
|
|
2938
|
+
result[key] = props;
|
|
2939
|
+
continue;
|
|
2940
|
+
}
|
|
2941
|
+
result[key] = sanitizeSchema(value);
|
|
2963
2942
|
}
|
|
2964
|
-
return
|
|
2943
|
+
return result;
|
|
2965
2944
|
};
|
|
2966
2945
|
uimc.tools = context.tools.map((t) => {
|
|
2967
|
-
const params =
|
|
2968
|
-
if (params.properties) {
|
|
2946
|
+
const params = sanitizeSchema(t.parameters);
|
|
2947
|
+
if (params.properties && typeof params.properties === "object" && !Array.isArray(params.properties)) {
|
|
2969
2948
|
params.properties.__tool_use_purpose = {
|
|
2970
2949
|
type: "string",
|
|
2971
2950
|
description: "A brief explanation why you are making this tool use."
|
|
@@ -2979,6 +2958,8 @@ ${currentContent}`;
|
|
|
2979
2958
|
}
|
|
2980
2959
|
};
|
|
2981
2960
|
});
|
|
2961
|
+
} else if (historyHasToolBlocks(history) || currentToolResults.length > 0) {
|
|
2962
|
+
uimc.tools = [KIRO_PLACEHOLDER_TOOL];
|
|
2982
2963
|
}
|
|
2983
2964
|
if (firstMsg?.role === "user") {
|
|
2984
2965
|
const imgs = extractImages(firstMsg);
|
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;AAEH,0EAA0E;AAC1E,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED,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;AAwCD,wBAAgB,oBAAoB,CAAC,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EAC3D,MAAM,EAAE,CAAC,EAAE,EACX,SAAS,EAAE,MAAM,GAChB,CAAC,EAAE,CASL;AAQD,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE3D;AAaD,KAAK,KAAK,GAAG,CAAC,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC;AAIlC,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,UAAU,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,KAAK,CAAC;IACb,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CA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ACH,wBAAsB,oBAAoB,CACxC,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,YAAY,EAAE,CAAC,CA8BzB;AAqBD,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,CAAC,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,YAAY,EAAE,GAAG,YAAY,EAAE,CAiC5E;AAKD,wBAAgB,sBAAsB,IAAI,YAAY,EAAE,GAAG,IAAI,CAE9D;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,IAAI,GAAG,IAAI,CAE1E"}
|
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,2BAA2B,EAC3B,OAAO,EAEP,KAAK,EACL,mBAAmB,EAKpB,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,GAAG,EAEH,2BAA2B,EAC3B,OAAO,EAEP,KAAK,EACL,mBAAmB,EAKpB,MAAM,uBAAuB,CAAC;AA8F/B;;;;;;;GAOG;AACH,eAAO,MAAM,6BAA6B,OAAO,CAAC;AA6DlD,sDAAsD;AACtD,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C;AAED,wFAAwF;AACxF,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAEhD;AAED,kCAAkC;AAClC,wBAAgB,aAAa,IAAI,MAAM,GAAG,SAAS,CAElD;AA0DD,wBAAgB,UAAU,CACxB,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,EACjB,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,2BAA2B,CA23B7B"}
|
package/dist/transform.d.ts
CHANGED
|
@@ -58,6 +58,24 @@ export interface KiroHistoryEntry {
|
|
|
58
58
|
userInputMessage?: KiroUserInputMessage;
|
|
59
59
|
assistantResponseMessage?: KiroAssistantResponseMessage;
|
|
60
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Minimal placeholder tool injected when the conversation history contains
|
|
63
|
+
* toolUse/toolResult blocks but the current request supplies no tools.
|
|
64
|
+
* Bedrock returns TOOL_CONFIG_MISSING ("The toolConfig field must be defined
|
|
65
|
+
* when using toolUse and toolResult content blocks") if tool blocks appear
|
|
66
|
+
* without a toolConfig. pi sends auxiliary turns (title generation,
|
|
67
|
+
* summarization, compaction) WITHOUT tools, yet the replayed history still
|
|
68
|
+
* carries tool blocks from earlier turns — so the request 400s and retries
|
|
69
|
+
* identically in a loop. This placeholder makes toolConfig non-empty without
|
|
70
|
+
* inviting the model to call anything on those auxiliary turns.
|
|
71
|
+
*/
|
|
72
|
+
export declare const KIRO_PLACEHOLDER_TOOL: KiroToolSpec;
|
|
73
|
+
/**
|
|
74
|
+
* True when any history entry carries assistant toolUses or user toolResults.
|
|
75
|
+
* Used to decide whether a tools-less request still needs a toolConfig to
|
|
76
|
+
* avoid Bedrock's TOOL_CONFIG_MISSING validation error.
|
|
77
|
+
*/
|
|
78
|
+
export declare function historyHasToolBlocks(history: KiroHistoryEntry[]): boolean;
|
|
61
79
|
export declare const TOOL_RESULT_LIMIT = 250000;
|
|
62
80
|
/** Maximum images per message accepted by the Kiro API. */
|
|
63
81
|
export declare const MAX_KIRO_IMAGES = 4;
|
|
@@ -107,6 +125,24 @@ export declare function buildHistory(messages: Message[], _modelId: string, syst
|
|
|
107
125
|
systemPrepended: boolean;
|
|
108
126
|
currentMsgStartIdx: number;
|
|
109
127
|
};
|
|
128
|
+
/**
|
|
129
|
+
* Sanitize the Kiro history to prevent Bedrock validation errors:
|
|
130
|
+
*
|
|
131
|
+
* 1. **TOOL_DUPLICATE**: Deduplicate toolUseIds within each assistant
|
|
132
|
+
* message — keep the first occurrence, drop subsequent ones.
|
|
133
|
+
*
|
|
134
|
+
* 2. **TOOL_USE_RESULT_MISMATCH**: Every ASST with toolUses must be
|
|
135
|
+
* followed by a USER with toolResults whose IDs match. Remove
|
|
136
|
+
* orphan toolUses that have no matching toolResult in the next
|
|
137
|
+
* message, and remove orphan toolResults whose toolUse doesn't
|
|
138
|
+
* exist in the preceding assistant.
|
|
139
|
+
*
|
|
140
|
+
* This runs as a defensive last pass — upstream logic (buildHistory,
|
|
141
|
+
* stream.ts current-turn assembly) should produce correct output, but
|
|
142
|
+
* edge cases in retry / cross-provider handoff can violate the
|
|
143
|
+
* invariants Bedrock enforces.
|
|
144
|
+
*/
|
|
145
|
+
export declare function sanitizeHistory(history: KiroHistoryEntry[]): KiroHistoryEntry[];
|
|
110
146
|
/**
|
|
111
147
|
* Collapse consecutive tool-use loops in history. When the agent calls
|
|
112
148
|
* 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,EAKR,MAAM,uBAAuB,CAAC;AAI/B;6BAC6B;AAC7B,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,OAAO,E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wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAIlD;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,CAuJvF;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/pi-kiro",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.10",
|
|
4
4
|
"description": "Kiro provider for the pi coding agent: AWS Builder ID / IAM Identity Center login and the CodeWhisperer streaming API, exposing the Kiro Claude model family.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|