@janole/ai-sdk-provider-codex-asp 0.3.6 → 0.4.1
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 +60 -227
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +54 -25
- package/dist/index.d.ts +54 -25
- package/dist/index.js +60 -228
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -933,7 +933,7 @@ var DynamicToolsDispatcher = class {
|
|
|
933
933
|
// package.json
|
|
934
934
|
var package_default = {
|
|
935
935
|
name: "@janole/ai-sdk-provider-codex-asp",
|
|
936
|
-
version: "0.
|
|
936
|
+
version: "0.4.1"};
|
|
937
937
|
|
|
938
938
|
// src/package-info.ts
|
|
939
939
|
var PACKAGE_NAME = package_default.name;
|
|
@@ -947,12 +947,16 @@ function codexProviderMetadata(threadId, turnId) {
|
|
|
947
947
|
}
|
|
948
948
|
return { [CODEX_PROVIDER_ID]: stripUndefined({ threadId, turnId }) };
|
|
949
949
|
}
|
|
950
|
+
function codexCallOptions(options) {
|
|
951
|
+
return { [CODEX_PROVIDER_ID]: options };
|
|
952
|
+
}
|
|
950
953
|
function withProviderMetadata(part, threadId, turnId) {
|
|
951
954
|
const meta = codexProviderMetadata(threadId, turnId);
|
|
952
955
|
return meta ? { ...part, providerMetadata: meta } : part;
|
|
953
956
|
}
|
|
954
957
|
|
|
955
958
|
// src/protocol/event-mapper.ts
|
|
959
|
+
var NATIVE_TOOL_RESULT_TYPES = /* @__PURE__ */ new Set(["commandExecution", "dynamicToolCall", "fileChange", "mcpToolCall", "webSearch"]);
|
|
956
960
|
var EMPTY_USAGE = {
|
|
957
961
|
inputTokens: {
|
|
958
962
|
total: void 0,
|
|
@@ -979,7 +983,6 @@ function toFinishReason(status) {
|
|
|
979
983
|
}
|
|
980
984
|
}
|
|
981
985
|
var NOOP = () => [];
|
|
982
|
-
var DEFAULT_MAX_TOOL_RESULT_OUTPUT_CHARS = 32768;
|
|
983
986
|
var CodexEventMapper = class {
|
|
984
987
|
options;
|
|
985
988
|
streamStarted = false;
|
|
@@ -994,8 +997,7 @@ var CodexEventMapper = class {
|
|
|
994
997
|
handlers;
|
|
995
998
|
constructor(options) {
|
|
996
999
|
this.options = {
|
|
997
|
-
emitPlanUpdates: options?.emitPlanUpdates ?? true
|
|
998
|
-
maxToolResultOutputChars: options?.maxToolResultOutputChars ?? DEFAULT_MAX_TOOL_RESULT_OUTPUT_CHARS
|
|
1000
|
+
emitPlanUpdates: options?.emitPlanUpdates ?? true
|
|
999
1001
|
};
|
|
1000
1002
|
this.handlers = {
|
|
1001
1003
|
"turn/started": (p) => this.handleTurnStarted(p),
|
|
@@ -1005,12 +1007,8 @@ var CodexEventMapper = class {
|
|
|
1005
1007
|
"item/reasoning/textDelta": (p) => this.handleReasoningDelta(p),
|
|
1006
1008
|
"item/reasoning/summaryTextDelta": (p) => this.handleReasoningDelta(p),
|
|
1007
1009
|
"item/plan/delta": (p) => this.handleReasoningDelta(p),
|
|
1008
|
-
"item/fileChange/outputDelta": (p) => this.handleFileChangeOutputDelta(p),
|
|
1009
1010
|
"item/reasoning/summaryPartAdded": (p) => this.handleSummaryPartAdded(p),
|
|
1010
1011
|
"turn/plan/updated": (p) => this.handlePlanUpdated(p),
|
|
1011
|
-
"item/commandExecution/outputDelta": (p) => this.handleCommandOutputDelta(p),
|
|
1012
|
-
"codex/event/mcp_tool_call_begin": (p) => this.handleMcpToolCallBegin(p),
|
|
1013
|
-
"codex/event/mcp_tool_call_end": (p) => this.handleMcpToolCallEnd(p),
|
|
1014
1012
|
"item/mcpToolCall/progress": (p) => this.handleMcpToolCallProgress(p),
|
|
1015
1013
|
"item/tool/callStarted": (p) => this.handleToolCallStarted(p),
|
|
1016
1014
|
"item/tool/callDelta": (p) => this.handleToolCallDelta(p),
|
|
@@ -1022,10 +1020,15 @@ var CodexEventMapper = class {
|
|
|
1022
1020
|
"codex/event/agent_reasoning": NOOP,
|
|
1023
1021
|
"codex/event/agent_reasoning_section_break": NOOP,
|
|
1024
1022
|
"codex/event/plan_update": NOOP,
|
|
1025
|
-
// Intentionally ignored: web search wrappers mirror item events.
|
|
1026
|
-
// We emit web-search reasoning only from item/started + item/completed.
|
|
1023
|
+
// Intentionally ignored: web search and MCP wrappers mirror item events.
|
|
1027
1024
|
"codex/event/web_search_begin": NOOP,
|
|
1028
1025
|
"codex/event/web_search_end": NOOP,
|
|
1026
|
+
"codex/event/mcp_tool_call_begin": NOOP,
|
|
1027
|
+
"codex/event/mcp_tool_call_end": NOOP,
|
|
1028
|
+
// Intentionally ignored: streaming output deltas — the full output arrives
|
|
1029
|
+
// in item/completed (aggregatedOutput), making these redundant.
|
|
1030
|
+
"item/commandExecution/outputDelta": NOOP,
|
|
1031
|
+
"item/fileChange/outputDelta": NOOP,
|
|
1029
1032
|
// Intentionally ignored: full diffs (often 50-100 KB) crash/freeze frontend renderers.
|
|
1030
1033
|
// If these need to surface, they should use a dedicated part type with lazy rendering.
|
|
1031
1034
|
"turn/diff/updated": NOOP,
|
|
@@ -1070,33 +1073,6 @@ var CodexEventMapper = class {
|
|
|
1070
1073
|
this.planSequenceByTurnId.set(turnId, next);
|
|
1071
1074
|
return next;
|
|
1072
1075
|
}
|
|
1073
|
-
applyOutputLimit(output) {
|
|
1074
|
-
const limit = this.options.maxToolResultOutputChars;
|
|
1075
|
-
if (limit <= 0) {
|
|
1076
|
-
return { output, droppedChars: 0 };
|
|
1077
|
-
}
|
|
1078
|
-
if (output.length <= limit) {
|
|
1079
|
-
return { output, droppedChars: 0 };
|
|
1080
|
-
}
|
|
1081
|
-
const droppedChars = output.length - limit;
|
|
1082
|
-
return { output: output.slice(droppedChars), droppedChars };
|
|
1083
|
-
}
|
|
1084
|
-
appendTrackedOutput(tracked, delta) {
|
|
1085
|
-
if (!delta) {
|
|
1086
|
-
return;
|
|
1087
|
-
}
|
|
1088
|
-
const combined = tracked.output + delta;
|
|
1089
|
-
const limited = this.applyOutputLimit(combined);
|
|
1090
|
-
tracked.output = limited.output;
|
|
1091
|
-
tracked.droppedChars += limited.droppedChars;
|
|
1092
|
-
}
|
|
1093
|
-
formatToolOutput(output, droppedChars) {
|
|
1094
|
-
if (droppedChars <= 0) {
|
|
1095
|
-
return output;
|
|
1096
|
-
}
|
|
1097
|
-
return `[output truncated: ${droppedChars} chars omitted]
|
|
1098
|
-
${output}`;
|
|
1099
|
-
}
|
|
1100
1076
|
// ── Handlers ─────────────────────────────────────────────────────────────
|
|
1101
1077
|
// turn/started
|
|
1102
1078
|
handleTurnStarted(params) {
|
|
@@ -1126,7 +1102,7 @@ ${output}`;
|
|
|
1126
1102
|
case "commandExecution": {
|
|
1127
1103
|
this.ensureStreamStarted(parts);
|
|
1128
1104
|
const toolName = "codex_command_execution";
|
|
1129
|
-
this.openToolCalls.set(item.id, { toolName
|
|
1105
|
+
this.openToolCalls.set(item.id, { toolName });
|
|
1130
1106
|
parts.push(this.withMeta({
|
|
1131
1107
|
type: "tool-call",
|
|
1132
1108
|
toolCallId: item.id,
|
|
@@ -1144,7 +1120,7 @@ ${output}`;
|
|
|
1144
1120
|
case "fileChange": {
|
|
1145
1121
|
this.ensureStreamStarted(parts);
|
|
1146
1122
|
const toolName = "codex_file_change";
|
|
1147
|
-
this.openToolCalls.set(item.id, { toolName
|
|
1123
|
+
this.openToolCalls.set(item.id, { toolName });
|
|
1148
1124
|
parts.push(this.withMeta({
|
|
1149
1125
|
type: "tool-call",
|
|
1150
1126
|
toolCallId: item.id,
|
|
@@ -1158,7 +1134,7 @@ ${output}`;
|
|
|
1158
1134
|
case "webSearch": {
|
|
1159
1135
|
this.ensureStreamStarted(parts);
|
|
1160
1136
|
const toolName = "codex_web_search";
|
|
1161
|
-
this.openToolCalls.set(item.id, { toolName
|
|
1137
|
+
this.openToolCalls.set(item.id, { toolName });
|
|
1162
1138
|
parts.push(this.withMeta({
|
|
1163
1139
|
type: "tool-call",
|
|
1164
1140
|
toolCallId: item.id,
|
|
@@ -1169,9 +1145,22 @@ ${output}`;
|
|
|
1169
1145
|
}));
|
|
1170
1146
|
break;
|
|
1171
1147
|
}
|
|
1148
|
+
case "mcpToolCall": {
|
|
1149
|
+
this.ensureStreamStarted(parts);
|
|
1150
|
+
const toolName = `mcp:${item.server}/${item.tool}`;
|
|
1151
|
+
this.openToolCalls.set(item.id, { toolName });
|
|
1152
|
+
parts.push(this.withMeta({
|
|
1153
|
+
type: "tool-call",
|
|
1154
|
+
toolCallId: item.id,
|
|
1155
|
+
toolName,
|
|
1156
|
+
input: JSON.stringify(item.arguments ?? {}),
|
|
1157
|
+
providerExecuted: true,
|
|
1158
|
+
dynamic: true
|
|
1159
|
+
}));
|
|
1160
|
+
break;
|
|
1161
|
+
}
|
|
1172
1162
|
case "reasoning":
|
|
1173
1163
|
case "plan":
|
|
1174
|
-
case "mcpToolCall":
|
|
1175
1164
|
case "collabAgentToolCall":
|
|
1176
1165
|
case "imageView":
|
|
1177
1166
|
case "contextCompaction":
|
|
@@ -1220,64 +1209,13 @@ ${output}`;
|
|
|
1220
1209
|
parts.push(this.withMeta({ type: "text-end", id: item.id }));
|
|
1221
1210
|
this.openTextParts.delete(item.id);
|
|
1222
1211
|
}
|
|
1223
|
-
} else if (item.type
|
|
1212
|
+
} else if (NATIVE_TOOL_RESULT_TYPES.has(item.type) && this.openToolCalls.has(item.id)) {
|
|
1224
1213
|
const tracked = this.openToolCalls.get(item.id);
|
|
1225
|
-
const outputSource = item.aggregatedOutput ?? tracked.output;
|
|
1226
|
-
const limitedOutput = this.applyOutputLimit(outputSource);
|
|
1227
|
-
const output = this.formatToolOutput(
|
|
1228
|
-
limitedOutput.output,
|
|
1229
|
-
item.aggregatedOutput !== void 0 && item.aggregatedOutput !== null ? limitedOutput.droppedChars : tracked.droppedChars
|
|
1230
|
-
);
|
|
1231
|
-
const exitCode = item.exitCode;
|
|
1232
|
-
const status = item.status;
|
|
1233
1214
|
parts.push(this.withMeta({
|
|
1234
1215
|
type: "tool-result",
|
|
1235
1216
|
toolCallId: item.id,
|
|
1236
1217
|
toolName: tracked.toolName,
|
|
1237
|
-
result: {
|
|
1238
|
-
}));
|
|
1239
|
-
this.openToolCalls.delete(item.id);
|
|
1240
|
-
} else if (item.type === "dynamicToolCall") {
|
|
1241
|
-
const dynamic = item;
|
|
1242
|
-
const tracked = this.openToolCalls.get(item.id);
|
|
1243
|
-
const toolName = tracked?.toolName ?? dynamic.tool ?? "dynamic_tool_call";
|
|
1244
|
-
const rawOutput = this.stringifyDynamicToolResult(dynamic);
|
|
1245
|
-
const limitedOutput = this.applyOutputLimit(rawOutput);
|
|
1246
|
-
parts.push(this.withMeta({
|
|
1247
|
-
type: "tool-result",
|
|
1248
|
-
toolCallId: item.id,
|
|
1249
|
-
toolName,
|
|
1250
|
-
result: {
|
|
1251
|
-
output: this.formatToolOutput(limitedOutput.output, limitedOutput.droppedChars),
|
|
1252
|
-
success: dynamic.success ?? void 0
|
|
1253
|
-
}
|
|
1254
|
-
}));
|
|
1255
|
-
this.openToolCalls.delete(item.id);
|
|
1256
|
-
} else if (item.type === "fileChange" && this.openToolCalls.has(item.id)) {
|
|
1257
|
-
const tracked = this.openToolCalls.get(item.id);
|
|
1258
|
-
const toolName = tracked?.toolName ?? "codex_file_change";
|
|
1259
|
-
const output = tracked ? this.formatToolOutput(tracked.output, tracked.droppedChars) : "";
|
|
1260
|
-
parts.push(this.withMeta({
|
|
1261
|
-
type: "tool-result",
|
|
1262
|
-
toolCallId: item.id,
|
|
1263
|
-
toolName,
|
|
1264
|
-
result: { output, status: item.status, changes: item.changes }
|
|
1265
|
-
}));
|
|
1266
|
-
this.openToolCalls.delete(item.id);
|
|
1267
|
-
} else if (item.type === "webSearch" && this.openToolCalls.has(item.id)) {
|
|
1268
|
-
const webSearchSummary = this.formatWebSearchItemSummary(item);
|
|
1269
|
-
const tracked = this.openToolCalls.get(item.id);
|
|
1270
|
-
const toolName = tracked?.toolName ?? "codex_web_search";
|
|
1271
|
-
parts.push(this.withMeta({
|
|
1272
|
-
type: "tool-result",
|
|
1273
|
-
toolCallId: item.id,
|
|
1274
|
-
toolName,
|
|
1275
|
-
result: {
|
|
1276
|
-
output: webSearchSummary || "",
|
|
1277
|
-
query: item.query,
|
|
1278
|
-
action: item.action ?? void 0,
|
|
1279
|
-
summary: webSearchSummary || void 0
|
|
1280
|
-
}
|
|
1218
|
+
result: { item }
|
|
1281
1219
|
}));
|
|
1282
1220
|
this.openToolCalls.delete(item.id);
|
|
1283
1221
|
} else if (this.openReasoningParts.has(item.id)) {
|
|
@@ -1296,22 +1234,6 @@ ${output}`;
|
|
|
1296
1234
|
this.emitReasoningDelta(parts, delta.itemId, delta.delta);
|
|
1297
1235
|
return parts;
|
|
1298
1236
|
}
|
|
1299
|
-
// item/fileChange/outputDelta
|
|
1300
|
-
handleFileChangeOutputDelta(params) {
|
|
1301
|
-
const delta = params ?? {};
|
|
1302
|
-
if (!delta.itemId || !delta.delta || !this.openToolCalls.has(delta.itemId)) {
|
|
1303
|
-
return [];
|
|
1304
|
-
}
|
|
1305
|
-
const tracked = this.openToolCalls.get(delta.itemId);
|
|
1306
|
-
this.appendTrackedOutput(tracked, delta.delta);
|
|
1307
|
-
return [this.withMeta({
|
|
1308
|
-
type: "tool-result",
|
|
1309
|
-
toolCallId: delta.itemId,
|
|
1310
|
-
toolName: tracked.toolName,
|
|
1311
|
-
result: { output: this.formatToolOutput(tracked.output, tracked.droppedChars) },
|
|
1312
|
-
preliminary: true
|
|
1313
|
-
})];
|
|
1314
|
-
}
|
|
1315
1237
|
// item/reasoning/summaryPartAdded
|
|
1316
1238
|
handleSummaryPartAdded(params) {
|
|
1317
1239
|
const p = params ?? {};
|
|
@@ -1354,74 +1276,24 @@ ${output}`;
|
|
|
1354
1276
|
}));
|
|
1355
1277
|
return parts;
|
|
1356
1278
|
}
|
|
1357
|
-
// item/
|
|
1358
|
-
|
|
1359
|
-
const delta = params ?? {};
|
|
1360
|
-
if (!delta.itemId || !delta.delta || !this.openToolCalls.has(delta.itemId)) {
|
|
1361
|
-
return [];
|
|
1362
|
-
}
|
|
1363
|
-
const tracked = this.openToolCalls.get(delta.itemId);
|
|
1364
|
-
this.appendTrackedOutput(tracked, delta.delta);
|
|
1365
|
-
return [this.withMeta({
|
|
1366
|
-
type: "tool-result",
|
|
1367
|
-
toolCallId: delta.itemId,
|
|
1368
|
-
toolName: tracked.toolName,
|
|
1369
|
-
result: { output: this.formatToolOutput(tracked.output, tracked.droppedChars) },
|
|
1370
|
-
preliminary: true
|
|
1371
|
-
})];
|
|
1372
|
-
}
|
|
1373
|
-
// codex/event/mcp_tool_call_begin
|
|
1374
|
-
handleMcpToolCallBegin(params) {
|
|
1279
|
+
// item/mcpToolCall/progress
|
|
1280
|
+
handleMcpToolCallProgress(params) {
|
|
1375
1281
|
const p = params ?? {};
|
|
1376
|
-
|
|
1377
|
-
const inv = p.msg?.invocation;
|
|
1378
|
-
if (!callId || !inv) {
|
|
1282
|
+
if (!p.itemId || !p.message) {
|
|
1379
1283
|
return [];
|
|
1380
1284
|
}
|
|
1381
|
-
const
|
|
1382
|
-
|
|
1383
|
-
const toolName = `mcp:${inv.server}/${inv.tool}`;
|
|
1384
|
-
this.openToolCalls.set(callId, { toolName, output: "", droppedChars: 0 });
|
|
1385
|
-
parts.push(this.withMeta({
|
|
1386
|
-
type: "tool-call",
|
|
1387
|
-
toolCallId: callId,
|
|
1388
|
-
toolName,
|
|
1389
|
-
input: JSON.stringify(inv.arguments ?? {}),
|
|
1390
|
-
providerExecuted: true,
|
|
1391
|
-
dynamic: true
|
|
1392
|
-
}));
|
|
1393
|
-
return parts;
|
|
1394
|
-
}
|
|
1395
|
-
// codex/event/mcp_tool_call_end
|
|
1396
|
-
handleMcpToolCallEnd(params) {
|
|
1397
|
-
const p = params ?? {};
|
|
1398
|
-
const callId = p.msg?.call_id;
|
|
1399
|
-
if (!callId || !this.openToolCalls.has(callId)) {
|
|
1285
|
+
const tracked = this.openToolCalls.get(p.itemId);
|
|
1286
|
+
if (!tracked) {
|
|
1400
1287
|
return [];
|
|
1401
1288
|
}
|
|
1402
|
-
const tracked = this.openToolCalls.get(callId);
|
|
1403
|
-
const result = p.msg?.result;
|
|
1404
|
-
const textParts = result?.Ok?.content?.filter((c) => c.type === "text").map((c) => c.text) ?? [];
|
|
1405
|
-
const rawOutput = textParts.join("\n") || (result?.Err ? JSON.stringify(result.Err) : "");
|
|
1406
|
-
const limitedOutput = this.applyOutputLimit(rawOutput);
|
|
1407
|
-
this.openToolCalls.delete(callId);
|
|
1408
1289
|
return [this.withMeta({
|
|
1409
1290
|
type: "tool-result",
|
|
1410
|
-
toolCallId:
|
|
1291
|
+
toolCallId: p.itemId,
|
|
1411
1292
|
toolName: tracked.toolName,
|
|
1412
|
-
result: { output:
|
|
1293
|
+
result: { output: p.message },
|
|
1294
|
+
preliminary: true
|
|
1413
1295
|
})];
|
|
1414
1296
|
}
|
|
1415
|
-
// item/mcpToolCall/progress
|
|
1416
|
-
handleMcpToolCallProgress(params) {
|
|
1417
|
-
const p = params ?? {};
|
|
1418
|
-
if (!p.itemId || !p.message) {
|
|
1419
|
-
return [];
|
|
1420
|
-
}
|
|
1421
|
-
const parts = [];
|
|
1422
|
-
this.emitReasoningDelta(parts, p.itemId, p.message);
|
|
1423
|
-
return parts;
|
|
1424
|
-
}
|
|
1425
1297
|
// item/tool/callStarted
|
|
1426
1298
|
handleToolCallStarted(params) {
|
|
1427
1299
|
const p = params ?? {};
|
|
@@ -1470,7 +1342,7 @@ ${output}`;
|
|
|
1470
1342
|
}
|
|
1471
1343
|
const parts = [];
|
|
1472
1344
|
this.ensureStreamStarted(parts);
|
|
1473
|
-
this.openToolCalls.set(item.id, { toolName: item.tool
|
|
1345
|
+
this.openToolCalls.set(item.id, { toolName: item.tool });
|
|
1474
1346
|
parts.push(this.withMeta({
|
|
1475
1347
|
type: "tool-call",
|
|
1476
1348
|
toolCallId: item.id,
|
|
@@ -1481,50 +1353,6 @@ ${output}`;
|
|
|
1481
1353
|
}));
|
|
1482
1354
|
return parts;
|
|
1483
1355
|
}
|
|
1484
|
-
stringifyDynamicToolResult(item) {
|
|
1485
|
-
const contentItems = item.contentItems ?? [];
|
|
1486
|
-
if (!contentItems.length) {
|
|
1487
|
-
return "";
|
|
1488
|
-
}
|
|
1489
|
-
const chunks = [];
|
|
1490
|
-
for (const contentItem of contentItems) {
|
|
1491
|
-
if (contentItem.type === "inputText" && contentItem.text) {
|
|
1492
|
-
chunks.push(contentItem.text);
|
|
1493
|
-
continue;
|
|
1494
|
-
}
|
|
1495
|
-
if (contentItem.type === "inputImage" && contentItem.imageUrl) {
|
|
1496
|
-
chunks.push(`[image] ${contentItem.imageUrl}`);
|
|
1497
|
-
}
|
|
1498
|
-
}
|
|
1499
|
-
return chunks.join("\n");
|
|
1500
|
-
}
|
|
1501
|
-
formatWebSearchItemSummary(item) {
|
|
1502
|
-
const query = item.query?.trim();
|
|
1503
|
-
const actionType = item.action?.type;
|
|
1504
|
-
if (actionType === "search") {
|
|
1505
|
-
if (query) {
|
|
1506
|
-
return `Web search: ${query}`;
|
|
1507
|
-
}
|
|
1508
|
-
const actionQuery = item.action?.query?.trim();
|
|
1509
|
-
return actionQuery ? `Web search: ${actionQuery}` : "Web search";
|
|
1510
|
-
}
|
|
1511
|
-
if (actionType === "openPage" || actionType === "open_page") {
|
|
1512
|
-
const url = item.action?.url?.trim();
|
|
1513
|
-
return url ? `Open page: ${url}` : "Open page";
|
|
1514
|
-
}
|
|
1515
|
-
if (actionType === "findInPage" || actionType === "find_in_page") {
|
|
1516
|
-
const pattern = item.action?.pattern?.trim();
|
|
1517
|
-
const url = item.action?.url?.trim();
|
|
1518
|
-
if (pattern && url) {
|
|
1519
|
-
return `Find in page: "${pattern}" (${url})`;
|
|
1520
|
-
}
|
|
1521
|
-
if (pattern) {
|
|
1522
|
-
return `Find in page: "${pattern}"`;
|
|
1523
|
-
}
|
|
1524
|
-
return url ? `Find in page: ${url}` : "Find in page";
|
|
1525
|
-
}
|
|
1526
|
-
return query ? `Web search: ${query}` : "";
|
|
1527
|
-
}
|
|
1528
1356
|
// thread/tokenUsage/updated
|
|
1529
1357
|
handleTokenUsageUpdated(params) {
|
|
1530
1358
|
const p = params ?? {};
|
|
@@ -1563,7 +1391,8 @@ ${output}`;
|
|
|
1563
1391
|
type: "tool-result",
|
|
1564
1392
|
toolCallId: itemId,
|
|
1565
1393
|
toolName: tracked.toolName,
|
|
1566
|
-
result: {
|
|
1394
|
+
result: { error: "Tool call did not complete before turn ended" },
|
|
1395
|
+
isError: true
|
|
1567
1396
|
}));
|
|
1568
1397
|
}
|
|
1569
1398
|
this.openToolCalls.clear();
|
|
@@ -2071,6 +1900,7 @@ var CodexLanguageModel = class {
|
|
|
2071
1900
|
}
|
|
2072
1901
|
doStream(options) {
|
|
2073
1902
|
const resumeThreadId = extractResumeThreadId(options.prompt);
|
|
1903
|
+
const callOptions = options.providerOptions?.[CODEX_PROVIDER_ID];
|
|
2074
1904
|
const transport = this.config.providerSettings.transportFactory ? this.config.providerSettings.transportFactory(stripUndefined({ signal: options.abortSignal, threadId: resumeThreadId })) : this.config.providerSettings.transport?.type === "websocket" ? new WebSocketTransport(this.config.providerSettings.transport.websocket) : new StdioTransport(this.config.providerSettings.transport?.stdio);
|
|
2075
1905
|
const packetLogger = this.config.providerSettings.debug?.logPackets === true ? this.config.providerSettings.debug.logger ?? ((packet) => {
|
|
2076
1906
|
if (packet.direction === "inbound") {
|
|
@@ -2087,8 +1917,7 @@ var CodexLanguageModel = class {
|
|
|
2087
1917
|
onPacket: packetLogger
|
|
2088
1918
|
}));
|
|
2089
1919
|
const mapper = new CodexEventMapper(stripUndefined({
|
|
2090
|
-
emitPlanUpdates: this.config.providerSettings.emitPlanUpdates
|
|
2091
|
-
maxToolResultOutputChars: this.config.providerSettings.maxToolResultOutputChars
|
|
1920
|
+
emitPlanUpdates: this.config.providerSettings.emitPlanUpdates
|
|
2092
1921
|
}));
|
|
2093
1922
|
let activeThreadId;
|
|
2094
1923
|
let activeTurnId;
|
|
@@ -2282,7 +2111,11 @@ var CodexLanguageModel = class {
|
|
|
2282
2111
|
const resumeParams = stripUndefined({
|
|
2283
2112
|
threadId: resumeThreadId,
|
|
2284
2113
|
persistExtendedHistory: false,
|
|
2285
|
-
developerInstructions
|
|
2114
|
+
developerInstructions,
|
|
2115
|
+
cwd: callOptions?.cwd ?? this.config.providerSettings.defaultThreadSettings?.cwd,
|
|
2116
|
+
approvalPolicy: callOptions?.approvalPolicy ?? this.config.providerSettings.defaultThreadSettings?.approvalPolicy,
|
|
2117
|
+
sandbox: callOptions?.sandbox ?? this.config.providerSettings.defaultThreadSettings?.sandbox,
|
|
2118
|
+
model: callOptions?.model ?? this.config.providerSettings.defaultModel
|
|
2286
2119
|
});
|
|
2287
2120
|
debugLog?.("outbound", "thread/resume", resumeParams);
|
|
2288
2121
|
const resumeResult = await client.request(
|
|
@@ -2342,9 +2175,9 @@ var CodexLanguageModel = class {
|
|
|
2342
2175
|
dynamicTools,
|
|
2343
2176
|
developerInstructions,
|
|
2344
2177
|
config,
|
|
2345
|
-
cwd: this.config.providerSettings.defaultThreadSettings?.cwd,
|
|
2346
|
-
approvalPolicy: this.config.providerSettings.defaultThreadSettings?.approvalPolicy,
|
|
2347
|
-
sandbox: this.config.providerSettings.defaultThreadSettings?.sandbox
|
|
2178
|
+
cwd: callOptions?.cwd ?? this.config.providerSettings.defaultThreadSettings?.cwd,
|
|
2179
|
+
approvalPolicy: callOptions?.approvalPolicy ?? this.config.providerSettings.defaultThreadSettings?.approvalPolicy,
|
|
2180
|
+
sandbox: callOptions?.sandbox ?? this.config.providerSettings.defaultThreadSettings?.sandbox
|
|
2348
2181
|
});
|
|
2349
2182
|
debugLog?.("outbound", "thread/start", threadStartParams);
|
|
2350
2183
|
const threadStartResult = await client.request(
|
|
@@ -2368,12 +2201,12 @@ var CodexLanguageModel = class {
|
|
|
2368
2201
|
const turnStartParams = stripUndefined({
|
|
2369
2202
|
threadId,
|
|
2370
2203
|
input: turnInput,
|
|
2371
|
-
cwd: this.config.providerSettings.defaultTurnSettings?.cwd,
|
|
2372
|
-
approvalPolicy: this.config.providerSettings.defaultTurnSettings?.approvalPolicy,
|
|
2373
|
-
sandboxPolicy: this.config.providerSettings.defaultTurnSettings?.sandboxPolicy,
|
|
2374
|
-
model: this.config.providerSettings.defaultTurnSettings?.model,
|
|
2375
|
-
effort: this.config.providerSettings.defaultTurnSettings?.effort,
|
|
2376
|
-
summary: this.config.providerSettings.defaultTurnSettings?.summary,
|
|
2204
|
+
cwd: callOptions?.cwd ?? this.config.providerSettings.defaultTurnSettings?.cwd,
|
|
2205
|
+
approvalPolicy: callOptions?.approvalPolicy ?? this.config.providerSettings.defaultTurnSettings?.approvalPolicy,
|
|
2206
|
+
sandboxPolicy: callOptions?.sandboxPolicy ?? this.config.providerSettings.defaultTurnSettings?.sandboxPolicy,
|
|
2207
|
+
model: callOptions?.model ?? this.config.providerSettings.defaultTurnSettings?.model,
|
|
2208
|
+
effort: callOptions?.effort ?? this.config.providerSettings.defaultTurnSettings?.effort,
|
|
2209
|
+
summary: callOptions?.summary ?? this.config.providerSettings.defaultTurnSettings?.summary,
|
|
2377
2210
|
outputSchema: options.responseFormat?.type === "json" ? options.responseFormat.schema : void 0
|
|
2378
2211
|
});
|
|
2379
2212
|
debugLog?.("outbound", "turn/start", turnStartParams);
|
|
@@ -2541,7 +2374,6 @@ function createCodexAppServer(settings = {}) {
|
|
|
2541
2374
|
approvals: settings.approvals ? { ...settings.approvals } : void 0,
|
|
2542
2375
|
debug: settings.debug ? { ...settings.debug } : void 0,
|
|
2543
2376
|
emitPlanUpdates: settings.emitPlanUpdates,
|
|
2544
|
-
maxToolResultOutputChars: settings.maxToolResultOutputChars,
|
|
2545
2377
|
onSessionCreated: settings.onSessionCreated
|
|
2546
2378
|
}));
|
|
2547
2379
|
const createLanguageModel = (modelId, modelSettings = {}) => new CodexLanguageModel(modelId, modelSettings, {
|
|
@@ -2607,6 +2439,6 @@ function createCodexAppServer(settings = {}) {
|
|
|
2607
2439
|
var codexAppServer = createCodexAppServer();
|
|
2608
2440
|
var createCodexProvider = createCodexAppServer;
|
|
2609
2441
|
|
|
2610
|
-
export { AppServerClient, ApprovalsDispatcher, CODEX_PROVIDER_ID, CodexEventMapper, CodexLanguageModel, CodexNotImplementedError, CodexProviderError, CodexWorker, CodexWorkerPool, DynamicToolsDispatcher, JsonRpcError, LocalFileWriter, PACKAGE_NAME, PACKAGE_VERSION, PersistentTransport, PromptFileResolver, StdioTransport, WebSocketTransport, codexAppServer, codexProviderMetadata, createCodexAppServer, createCodexProvider, mapSystemPrompt, withProviderMetadata };
|
|
2442
|
+
export { AppServerClient, ApprovalsDispatcher, CODEX_PROVIDER_ID, CodexEventMapper, CodexLanguageModel, CodexNotImplementedError, CodexProviderError, CodexWorker, CodexWorkerPool, DynamicToolsDispatcher, JsonRpcError, LocalFileWriter, PACKAGE_NAME, PACKAGE_VERSION, PersistentTransport, PromptFileResolver, StdioTransport, WebSocketTransport, codexAppServer, codexCallOptions, codexProviderMetadata, createCodexAppServer, createCodexProvider, mapSystemPrompt, withProviderMetadata };
|
|
2611
2443
|
//# sourceMappingURL=index.js.map
|
|
2612
2444
|
//# sourceMappingURL=index.js.map
|