@codeproxy/core 0.1.12 → 0.1.13
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.cjs +37 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +37 -21
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1209,28 +1209,11 @@ function processInputItem(item, messages, options) {
|
|
|
1209
1209
|
contentBlocks.push({ type: "text", text: String(contentPart.text ?? "") });
|
|
1210
1210
|
} else if (contentPart.type === "reasoning_text") {
|
|
1211
1211
|
reasoningContent += String(contentPart.text ?? "");
|
|
1212
|
-
} else if (contentPart
|
|
1212
|
+
} else if (isImagePart(contentPart)) {
|
|
1213
1213
|
if (options.dropImages) {
|
|
1214
1214
|
continue;
|
|
1215
1215
|
}
|
|
1216
|
-
|
|
1217
|
-
const partWithImage = part;
|
|
1218
|
-
const imgUrl = partWithImage.image_url;
|
|
1219
|
-
if (typeof imgUrl === "string") {
|
|
1220
|
-
url = imgUrl;
|
|
1221
|
-
} else if (imgUrl && typeof imgUrl === "object" && imgUrl.url) {
|
|
1222
|
-
url = imgUrl.url;
|
|
1223
|
-
} else {
|
|
1224
|
-
const partWithData = part;
|
|
1225
|
-
const imgData = String(partWithData.data ?? partWithData.base64 ?? "");
|
|
1226
|
-
if (imgData) {
|
|
1227
|
-
const partWithMime = part;
|
|
1228
|
-
const mimeType = String(
|
|
1229
|
-
partWithMime.mime_type ?? partWithMime.media_type ?? "image/png"
|
|
1230
|
-
);
|
|
1231
|
-
url = imgData.startsWith("data:") ? imgData : `data:${mimeType};base64,${imgData}`;
|
|
1232
|
-
}
|
|
1233
|
-
}
|
|
1216
|
+
const url = imagePartToUrl(part);
|
|
1234
1217
|
if (url) {
|
|
1235
1218
|
contentBlocks.push({ type: "image_url", image_url: { url } });
|
|
1236
1219
|
}
|
|
@@ -1289,7 +1272,7 @@ function processInputItem(item, messages, options) {
|
|
|
1289
1272
|
return;
|
|
1290
1273
|
}
|
|
1291
1274
|
if (itemType === "function_call_output" || itemType === "commandExecutionOutput" || itemType === "fileChangeOutput" || itemType === "custom_tool_call_output") {
|
|
1292
|
-
processToolOutput(item, messages);
|
|
1275
|
+
processToolOutput(item, messages, options);
|
|
1293
1276
|
return;
|
|
1294
1277
|
}
|
|
1295
1278
|
}
|
|
@@ -1355,10 +1338,29 @@ function processToolCall(item, messages, getLastAssistant, fallbackThoughtSignat
|
|
|
1355
1338
|
amsg.reasoning_content = (amsg.reasoning_content ?? "") + thought;
|
|
1356
1339
|
}
|
|
1357
1340
|
}
|
|
1358
|
-
function
|
|
1341
|
+
function isImagePart(part) {
|
|
1342
|
+
return part.type === "input_image" || part.type === "image" || part.type === "image_url";
|
|
1343
|
+
}
|
|
1344
|
+
function imagePartToUrl(part) {
|
|
1345
|
+
const imgUrl = part.image_url;
|
|
1346
|
+
if (typeof imgUrl === "string") {
|
|
1347
|
+
return imgUrl;
|
|
1348
|
+
}
|
|
1349
|
+
if (imgUrl && typeof imgUrl === "object" && imgUrl.url) {
|
|
1350
|
+
return imgUrl.url;
|
|
1351
|
+
}
|
|
1352
|
+
const imgData = String(part.data ?? part.base64 ?? "");
|
|
1353
|
+
if (imgData) {
|
|
1354
|
+
const mimeType = String(part.mime_type ?? part.media_type ?? "image/png");
|
|
1355
|
+
return imgData.startsWith("data:") ? imgData : `data:${mimeType};base64,${imgData}`;
|
|
1356
|
+
}
|
|
1357
|
+
return "";
|
|
1358
|
+
}
|
|
1359
|
+
function processToolOutput(item, messages, options) {
|
|
1359
1360
|
const callId = item.call_id === void 0 ? void 0 : String(item.call_id);
|
|
1360
1361
|
const outputRaw = item.output ?? item.content ?? item.stdout ?? "";
|
|
1361
1362
|
let content = "";
|
|
1363
|
+
const imageBlocks = [];
|
|
1362
1364
|
if (typeof outputRaw === "string") {
|
|
1363
1365
|
content = outputRaw;
|
|
1364
1366
|
} else if (Array.isArray(outputRaw)) {
|
|
@@ -1369,6 +1371,11 @@ function processToolOutput(item, messages) {
|
|
|
1369
1371
|
const partItem = part;
|
|
1370
1372
|
if (partItem.type === "input_text" || partItem.type === "text") {
|
|
1371
1373
|
content += String(partItem.text ?? "");
|
|
1374
|
+
} else if (!options.dropImages && isImagePart(partItem)) {
|
|
1375
|
+
const url = imagePartToUrl(part);
|
|
1376
|
+
if (url) {
|
|
1377
|
+
imageBlocks.push({ type: "image_url", image_url: { url } });
|
|
1378
|
+
}
|
|
1372
1379
|
}
|
|
1373
1380
|
}
|
|
1374
1381
|
}
|
|
@@ -1387,6 +1394,15 @@ function processToolOutput(item, messages) {
|
|
|
1387
1394
|
tool_call_id: callId,
|
|
1388
1395
|
content
|
|
1389
1396
|
});
|
|
1397
|
+
if (imageBlocks.length > 0) {
|
|
1398
|
+
messages.push({
|
|
1399
|
+
role: "user",
|
|
1400
|
+
content: [
|
|
1401
|
+
{ type: "text", text: "[Image output returned by the preceding tool call]" },
|
|
1402
|
+
...imageBlocks
|
|
1403
|
+
]
|
|
1404
|
+
});
|
|
1405
|
+
}
|
|
1390
1406
|
}
|
|
1391
1407
|
function mapTools2(tools) {
|
|
1392
1408
|
const out = [];
|