@codeproxy/core 0.1.12 → 0.1.14
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 +46 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +46 -24
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
type ResponsesInputItem = string | ResponsesMessageItem | ResponsesReasoningItem | ResponsesFunctionCallItem | ResponsesFunctionCallOutputItem | ResponsesLocalShellCallItem | ResponsesCommandExecutionItem | ResponsesCommandExecutionOutputItem | ResponsesCustomToolCallItem | ResponsesCustomToolCallOutputItem | ResponsesFileChangeItem | ResponsesFileChangeOutputItem | ResponsesWebSearchCallItem | Record<string, unknown>;
|
|
7
7
|
interface ResponsesContentPart {
|
|
8
|
-
type: 'input_text' | 'text' | 'output_text' | 'reasoning_text' | 'input_image' | 'image' | 'image_url' | 'input_file' | 'file' | 'tool_result' | string;
|
|
8
|
+
type: 'input_text' | 'text' | 'output_text' | 'reasoning_text' | 'input_image' | 'image' | 'image_url' | 'input_file' | 'file' | 'input_audio' | 'tool_result' | string;
|
|
9
9
|
text?: string;
|
|
10
10
|
image_url?: string | {
|
|
11
11
|
url: string;
|
|
@@ -19,6 +19,11 @@ interface ResponsesContentPart {
|
|
|
19
19
|
file_url?: string | {
|
|
20
20
|
url: string;
|
|
21
21
|
};
|
|
22
|
+
input_audio?: {
|
|
23
|
+
data?: string;
|
|
24
|
+
format?: string;
|
|
25
|
+
};
|
|
26
|
+
format?: string;
|
|
22
27
|
tool_use_id?: string;
|
|
23
28
|
call_id?: string;
|
|
24
29
|
content?: unknown;
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
type ResponsesInputItem = string | ResponsesMessageItem | ResponsesReasoningItem | ResponsesFunctionCallItem | ResponsesFunctionCallOutputItem | ResponsesLocalShellCallItem | ResponsesCommandExecutionItem | ResponsesCommandExecutionOutputItem | ResponsesCustomToolCallItem | ResponsesCustomToolCallOutputItem | ResponsesFileChangeItem | ResponsesFileChangeOutputItem | ResponsesWebSearchCallItem | Record<string, unknown>;
|
|
7
7
|
interface ResponsesContentPart {
|
|
8
|
-
type: 'input_text' | 'text' | 'output_text' | 'reasoning_text' | 'input_image' | 'image' | 'image_url' | 'input_file' | 'file' | 'tool_result' | string;
|
|
8
|
+
type: 'input_text' | 'text' | 'output_text' | 'reasoning_text' | 'input_image' | 'image' | 'image_url' | 'input_file' | 'file' | 'input_audio' | 'tool_result' | string;
|
|
9
9
|
text?: string;
|
|
10
10
|
image_url?: string | {
|
|
11
11
|
url: string;
|
|
@@ -19,6 +19,11 @@ interface ResponsesContentPart {
|
|
|
19
19
|
file_url?: string | {
|
|
20
20
|
url: string;
|
|
21
21
|
};
|
|
22
|
+
input_audio?: {
|
|
23
|
+
data?: string;
|
|
24
|
+
format?: string;
|
|
25
|
+
};
|
|
26
|
+
format?: string;
|
|
22
27
|
tool_use_id?: string;
|
|
23
28
|
call_id?: string;
|
|
24
29
|
content?: unknown;
|
package/dist/index.js
CHANGED
|
@@ -1209,41 +1209,30 @@ 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
|
}
|
|
1237
1220
|
} else if (part.type === "input_file" || part.type === "file") {
|
|
1238
|
-
const
|
|
1239
|
-
const fileData = String(partFile.file_data ?? partFile.data ?? "");
|
|
1221
|
+
const fileData = String(contentPart.file_data ?? contentPart.data ?? "");
|
|
1240
1222
|
const mimeType = String(
|
|
1241
|
-
|
|
1223
|
+
contentPart.mime_type ?? contentPart.media_type ?? "application/pdf"
|
|
1242
1224
|
);
|
|
1243
1225
|
if (fileData) {
|
|
1244
1226
|
const url = fileData.startsWith("data:") ? fileData : `data:${mimeType};base64,${fileData}`;
|
|
1245
1227
|
contentBlocks.push({ type: "image_url", image_url: { url } });
|
|
1246
1228
|
}
|
|
1229
|
+
} else if (contentPart.type === "input_audio") {
|
|
1230
|
+
const ia = contentPart.input_audio;
|
|
1231
|
+
const data = String(ia?.data ?? contentPart.data ?? "");
|
|
1232
|
+
const format = String(ia?.format ?? contentPart.format ?? "mp3");
|
|
1233
|
+
if (data) {
|
|
1234
|
+
contentBlocks.push({ type: "input_audio", input_audio: { data, format } });
|
|
1235
|
+
}
|
|
1247
1236
|
}
|
|
1248
1237
|
}
|
|
1249
1238
|
}
|
|
@@ -1289,7 +1278,7 @@ function processInputItem(item, messages, options) {
|
|
|
1289
1278
|
return;
|
|
1290
1279
|
}
|
|
1291
1280
|
if (itemType === "function_call_output" || itemType === "commandExecutionOutput" || itemType === "fileChangeOutput" || itemType === "custom_tool_call_output") {
|
|
1292
|
-
processToolOutput(item, messages);
|
|
1281
|
+
processToolOutput(item, messages, options);
|
|
1293
1282
|
return;
|
|
1294
1283
|
}
|
|
1295
1284
|
}
|
|
@@ -1355,10 +1344,29 @@ function processToolCall(item, messages, getLastAssistant, fallbackThoughtSignat
|
|
|
1355
1344
|
amsg.reasoning_content = (amsg.reasoning_content ?? "") + thought;
|
|
1356
1345
|
}
|
|
1357
1346
|
}
|
|
1358
|
-
function
|
|
1347
|
+
function isImagePart(part) {
|
|
1348
|
+
return part.type === "input_image" || part.type === "image" || part.type === "image_url";
|
|
1349
|
+
}
|
|
1350
|
+
function imagePartToUrl(part) {
|
|
1351
|
+
const imgUrl = part.image_url;
|
|
1352
|
+
if (typeof imgUrl === "string") {
|
|
1353
|
+
return imgUrl;
|
|
1354
|
+
}
|
|
1355
|
+
if (imgUrl && typeof imgUrl === "object" && imgUrl.url) {
|
|
1356
|
+
return imgUrl.url;
|
|
1357
|
+
}
|
|
1358
|
+
const imgData = String(part.data ?? part.base64 ?? "");
|
|
1359
|
+
if (imgData) {
|
|
1360
|
+
const mimeType = String(part.mime_type ?? part.media_type ?? "image/png");
|
|
1361
|
+
return imgData.startsWith("data:") ? imgData : `data:${mimeType};base64,${imgData}`;
|
|
1362
|
+
}
|
|
1363
|
+
return "";
|
|
1364
|
+
}
|
|
1365
|
+
function processToolOutput(item, messages, options) {
|
|
1359
1366
|
const callId = item.call_id === void 0 ? void 0 : String(item.call_id);
|
|
1360
1367
|
const outputRaw = item.output ?? item.content ?? item.stdout ?? "";
|
|
1361
1368
|
let content = "";
|
|
1369
|
+
const imageBlocks = [];
|
|
1362
1370
|
if (typeof outputRaw === "string") {
|
|
1363
1371
|
content = outputRaw;
|
|
1364
1372
|
} else if (Array.isArray(outputRaw)) {
|
|
@@ -1369,6 +1377,11 @@ function processToolOutput(item, messages) {
|
|
|
1369
1377
|
const partItem = part;
|
|
1370
1378
|
if (partItem.type === "input_text" || partItem.type === "text") {
|
|
1371
1379
|
content += String(partItem.text ?? "");
|
|
1380
|
+
} else if (!options.dropImages && isImagePart(partItem)) {
|
|
1381
|
+
const url = imagePartToUrl(part);
|
|
1382
|
+
if (url) {
|
|
1383
|
+
imageBlocks.push({ type: "image_url", image_url: { url } });
|
|
1384
|
+
}
|
|
1372
1385
|
}
|
|
1373
1386
|
}
|
|
1374
1387
|
}
|
|
@@ -1387,6 +1400,15 @@ function processToolOutput(item, messages) {
|
|
|
1387
1400
|
tool_call_id: callId,
|
|
1388
1401
|
content
|
|
1389
1402
|
});
|
|
1403
|
+
if (imageBlocks.length > 0) {
|
|
1404
|
+
messages.push({
|
|
1405
|
+
role: "user",
|
|
1406
|
+
content: [
|
|
1407
|
+
{ type: "text", text: "[Image output returned by the preceding tool call]" },
|
|
1408
|
+
...imageBlocks
|
|
1409
|
+
]
|
|
1410
|
+
});
|
|
1411
|
+
}
|
|
1390
1412
|
}
|
|
1391
1413
|
function mapTools2(tools) {
|
|
1392
1414
|
const out = [];
|