ns-omp-provider-kiro 0.3.5 → 0.3.7
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/index.js +62 -14
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2420,8 +2420,52 @@ function convertToolsToKiro(tools) {
|
|
|
2420
2420
|
}
|
|
2421
2421
|
}));
|
|
2422
2422
|
}
|
|
2423
|
+
var KIRO_IMAGE_FORMAT_ALIASES = {
|
|
2424
|
+
png: "png",
|
|
2425
|
+
"x-png": "png",
|
|
2426
|
+
jpeg: "jpeg",
|
|
2427
|
+
jpg: "jpeg",
|
|
2428
|
+
pjpeg: "jpeg",
|
|
2429
|
+
gif: "gif",
|
|
2430
|
+
webp: "webp"
|
|
2431
|
+
};
|
|
2432
|
+
function toKiroImageFormat(mimeType) {
|
|
2433
|
+
const subtype = mimeType.trim().toLowerCase().split("/").pop()?.split(";")[0]?.trim() ?? "";
|
|
2434
|
+
return KIRO_IMAGE_FORMAT_ALIASES[subtype];
|
|
2435
|
+
}
|
|
2436
|
+
function toKiroImageBytes(data) {
|
|
2437
|
+
const trimmed = data.trim();
|
|
2438
|
+
const marker = "base64,";
|
|
2439
|
+
if (!trimmed.startsWith("data:") || !trimmed.includes(marker))
|
|
2440
|
+
return trimmed;
|
|
2441
|
+
return trimmed.slice(trimmed.indexOf(marker) + marker.length);
|
|
2442
|
+
}
|
|
2423
2443
|
function convertImagesToKiro(images) {
|
|
2424
|
-
|
|
2444
|
+
const out = [];
|
|
2445
|
+
for (const img of images) {
|
|
2446
|
+
const format = toKiroImageFormat(img.mimeType);
|
|
2447
|
+
const bytes = toKiroImageBytes(img.data);
|
|
2448
|
+
if (!format || !bytes)
|
|
2449
|
+
continue;
|
|
2450
|
+
out.push({ format, source: { bytes } });
|
|
2451
|
+
}
|
|
2452
|
+
return out;
|
|
2453
|
+
}
|
|
2454
|
+
function toKiroToolInput(input) {
|
|
2455
|
+
if (isPlainObject(input))
|
|
2456
|
+
return input;
|
|
2457
|
+
if (typeof input === "string") {
|
|
2458
|
+
try {
|
|
2459
|
+
const parsed = JSON.parse(input);
|
|
2460
|
+
if (isPlainObject(parsed))
|
|
2461
|
+
return parsed;
|
|
2462
|
+
} catch {
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2465
|
+
return {};
|
|
2466
|
+
}
|
|
2467
|
+
function isPlainObject(value) {
|
|
2468
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
2425
2469
|
}
|
|
2426
2470
|
function toolResultOf(msg) {
|
|
2427
2471
|
return {
|
|
@@ -2453,12 +2497,12 @@ function buildHistory(messages, modelId, systemPrompt) {
|
|
|
2453
2497
|
${content}`;
|
|
2454
2498
|
systemPrepended = true;
|
|
2455
2499
|
}
|
|
2456
|
-
const images = extractImages(msg);
|
|
2500
|
+
const images = convertImagesToKiro(extractImages(msg));
|
|
2457
2501
|
const uim = {
|
|
2458
2502
|
content: sanitizeSurrogates(content),
|
|
2459
2503
|
modelId,
|
|
2460
2504
|
origin: "KIRO_CLI",
|
|
2461
|
-
...images.length > 0 ? { images
|
|
2505
|
+
...images.length > 0 ? { images } : {}
|
|
2462
2506
|
};
|
|
2463
2507
|
const prevUim = history[history.length - 1]?.userInputMessage;
|
|
2464
2508
|
if (prevUim) {
|
|
@@ -2484,7 +2528,7 @@ ${uim.content}` : prevUim.content || uim.content;
|
|
|
2484
2528
|
armToolUses.push({
|
|
2485
2529
|
name: toKiroToolName(block.name),
|
|
2486
2530
|
toolUseId: toKiroToolUseId(block.id),
|
|
2487
|
-
input: block.arguments
|
|
2531
|
+
input: toKiroToolInput(block.arguments)
|
|
2488
2532
|
});
|
|
2489
2533
|
armHadBlocks = true;
|
|
2490
2534
|
}
|
|
@@ -2509,8 +2553,9 @@ ${uim.content}` : prevUim.content || uim.content;
|
|
|
2509
2553
|
i = j - 1;
|
|
2510
2554
|
const prevTr = history[history.length - 1]?.userInputMessage;
|
|
2511
2555
|
if (prevTr) {
|
|
2512
|
-
|
|
2513
|
-
|
|
2556
|
+
const images = convertImagesToKiro(trImages);
|
|
2557
|
+
if (images.length > 0)
|
|
2558
|
+
prevTr.images = [...prevTr.images || [], ...images];
|
|
2514
2559
|
if (!prevTr.userInputMessageContext)
|
|
2515
2560
|
prevTr.userInputMessageContext = {};
|
|
2516
2561
|
prevTr.userInputMessageContext.toolResults = [
|
|
@@ -2518,6 +2563,7 @@ ${uim.content}` : prevUim.content || uim.content;
|
|
|
2518
2563
|
...toolResults
|
|
2519
2564
|
];
|
|
2520
2565
|
} else {
|
|
2566
|
+
const images = convertImagesToKiro(trImages);
|
|
2521
2567
|
history.push({
|
|
2522
2568
|
userInputMessage: {
|
|
2523
2569
|
// Empty by design: `toolResults` is this turn's payload. See
|
|
@@ -2525,7 +2571,7 @@ ${uim.content}` : prevUim.content || uim.content;
|
|
|
2525
2571
|
content: "",
|
|
2526
2572
|
modelId,
|
|
2527
2573
|
origin: "KIRO_CLI",
|
|
2528
|
-
...
|
|
2574
|
+
...images.length > 0 ? { images } : {},
|
|
2529
2575
|
userInputMessageContext: { toolResults }
|
|
2530
2576
|
}
|
|
2531
2577
|
});
|
|
@@ -3078,7 +3124,7 @@ function buildKiroRequest(params) {
|
|
|
3078
3124
|
armToolUses.push({
|
|
3079
3125
|
name: toKiroToolName(block.name),
|
|
3080
3126
|
toolUseId: toKiroToolUseId(block.id),
|
|
3081
|
-
input: block.arguments
|
|
3127
|
+
input: toKiroToolInput(block.arguments)
|
|
3082
3128
|
});
|
|
3083
3129
|
}
|
|
3084
3130
|
}
|
|
@@ -3107,8 +3153,9 @@ ${armContent}` : prevArm.content || armContent;
|
|
|
3107
3153
|
currentToolResults.push(toolResultOf2(m));
|
|
3108
3154
|
toolResultImages.push(...extractImages(m));
|
|
3109
3155
|
}
|
|
3110
|
-
|
|
3111
|
-
|
|
3156
|
+
const convertedToolImages = convertImagesToKiro(toolResultImages);
|
|
3157
|
+
if (convertedToolImages.length > 0)
|
|
3158
|
+
currentImages = convertedToolImages;
|
|
3112
3159
|
currentContent = "";
|
|
3113
3160
|
} else if (firstMsg?.role === "toolResult") {
|
|
3114
3161
|
const toolResultImages = [];
|
|
@@ -3118,8 +3165,9 @@ ${armContent}` : prevArm.content || armContent;
|
|
|
3118
3165
|
currentToolResults.push(toolResultOf2(m));
|
|
3119
3166
|
toolResultImages.push(...extractImages(m));
|
|
3120
3167
|
}
|
|
3121
|
-
|
|
3122
|
-
|
|
3168
|
+
const convertedToolImages = convertImagesToKiro(toolResultImages);
|
|
3169
|
+
if (convertedToolImages.length > 0)
|
|
3170
|
+
currentImages = convertedToolImages;
|
|
3123
3171
|
currentContent = "";
|
|
3124
3172
|
} else if (firstMsg?.role === "user") {
|
|
3125
3173
|
currentContent = getContentText(firstMsg);
|
|
@@ -3145,9 +3193,9 @@ ${currentContent}`;
|
|
|
3145
3193
|
uimc.tools = finalTools;
|
|
3146
3194
|
}
|
|
3147
3195
|
if (firstMsg?.role === "user") {
|
|
3148
|
-
const imgs = extractImages(firstMsg);
|
|
3196
|
+
const imgs = convertImagesToKiro(extractImages(firstMsg));
|
|
3149
3197
|
if (imgs.length > 0)
|
|
3150
|
-
currentImages =
|
|
3198
|
+
currentImages = imgs;
|
|
3151
3199
|
}
|
|
3152
3200
|
if (currentContent === "" && currentToolResults.length === 0)
|
|
3153
3201
|
currentContent = EMPTY_CONTENT_PLACEHOLDER;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ns-omp-provider-kiro",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.7",
|
|
4
4
|
"description": "OMP (oh-my-pi) provider plugin: adds Kiro (AWS CodeWhisperer/Q) models via your kiro-cli login",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"README.md"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"ns-kiro-core": "0.3.
|
|
40
|
+
"ns-kiro-core": "0.3.7"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"@oh-my-pi/pi-ai": ">=18.2.0",
|