@janole/ai-sdk-provider-codex-asp 0.3.4 → 0.3.6

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/README.md CHANGED
@@ -126,6 +126,11 @@ codex.chat(modelId) // explicit alias
126
126
  codex.shutdown() // clean up persistent workers
127
127
  ```
128
128
 
129
+ Approval callback notes:
130
+
131
+ - `approvals.onCommandApproval(request)` receives the raw generated Codex protocol payload: `CommandExecutionRequestApprovalParams`.
132
+ - `approvals.onFileChangeApproval(request)` receives the raw generated Codex protocol payload: `FileChangeRequestApprovalParams`.
133
+
129
134
  Rich sandbox policy example (turn-level):
130
135
 
131
136
  ```ts
package/dist/index.cjs CHANGED
@@ -8,13 +8,6 @@ var path = require('path');
8
8
  var url = require('url');
9
9
  var provider = require('@ai-sdk/provider');
10
10
 
11
- // src/utils/object.ts
12
- function stripUndefined(obj) {
13
- return Object.fromEntries(
14
- Object.entries(obj).filter(([, value]) => value !== void 0)
15
- );
16
- }
17
-
18
11
  // src/approvals.ts
19
12
  var ApprovalsDispatcher = class {
20
13
  onCommandApproval;
@@ -27,37 +20,14 @@ var ApprovalsDispatcher = class {
27
20
  const unsubCommand = client.onRequest(
28
21
  "item/commandExecution/requestApproval",
29
22
  async (params, _request) => {
30
- const p = params;
31
- const request = stripUndefined({
32
- threadId: p.threadId,
33
- turnId: p.turnId,
34
- itemId: p.itemId,
35
- approvalId: p.approvalId,
36
- reason: p.reason,
37
- networkApprovalContext: p.networkApprovalContext,
38
- command: p.command,
39
- cwd: p.cwd,
40
- commandActions: p.commandActions,
41
- additionalPermissions: p.additionalPermissions,
42
- proposedExecpolicyAmendment: p.proposedExecpolicyAmendment,
43
- proposedNetworkPolicyAmendments: p.proposedNetworkPolicyAmendments
44
- });
45
- const decision = await this.onCommandApproval(request);
23
+ const decision = await this.onCommandApproval(params);
46
24
  return { decision };
47
25
  }
48
26
  );
49
27
  const unsubFileChange = client.onRequest(
50
28
  "item/fileChange/requestApproval",
51
29
  async (params, _request) => {
52
- const p = params;
53
- const request = stripUndefined({
54
- threadId: p.threadId,
55
- turnId: p.turnId,
56
- itemId: p.itemId,
57
- reason: p.reason,
58
- grantRoot: p.grantRoot
59
- });
60
- const decision = await this.onFileChangeApproval(request);
30
+ const decision = await this.onFileChangeApproval(params);
61
31
  return { decision };
62
32
  }
63
33
  );
@@ -82,6 +52,13 @@ var CodexNotImplementedError = class extends CodexProviderError {
82
52
  }
83
53
  };
84
54
 
55
+ // src/utils/object.ts
56
+ function stripUndefined(obj) {
57
+ return Object.fromEntries(
58
+ Object.entries(obj).filter(([, value]) => value !== void 0)
59
+ );
60
+ }
61
+
85
62
  // src/client/app-server-client.ts
86
63
  var JsonRpcError = class extends CodexProviderError {
87
64
  code;
@@ -958,7 +935,7 @@ var DynamicToolsDispatcher = class {
958
935
  // package.json
959
936
  var package_default = {
960
937
  name: "@janole/ai-sdk-provider-codex-asp",
961
- version: "0.3.4"};
938
+ version: "0.3.6"};
962
939
 
963
940
  // src/package-info.ts
964
941
  var PACKAGE_NAME = package_default.name;
@@ -1030,7 +1007,7 @@ var CodexEventMapper = class {
1030
1007
  "item/reasoning/textDelta": (p) => this.handleReasoningDelta(p),
1031
1008
  "item/reasoning/summaryTextDelta": (p) => this.handleReasoningDelta(p),
1032
1009
  "item/plan/delta": (p) => this.handleReasoningDelta(p),
1033
- "item/fileChange/outputDelta": (p) => this.handleReasoningDelta(p),
1010
+ "item/fileChange/outputDelta": (p) => this.handleFileChangeOutputDelta(p),
1034
1011
  "item/reasoning/summaryPartAdded": (p) => this.handleSummaryPartAdded(p),
1035
1012
  "turn/plan/updated": (p) => this.handlePlanUpdated(p),
1036
1013
  "item/commandExecution/outputDelta": (p) => this.handleCommandOutputDelta(p),
@@ -1166,12 +1143,38 @@ ${output}`;
1166
1143
  parts.push(...this.startDynamicToolCall(item));
1167
1144
  break;
1168
1145
  }
1146
+ case "fileChange": {
1147
+ this.ensureStreamStarted(parts);
1148
+ const toolName = "codex_file_change";
1149
+ this.openToolCalls.set(item.id, { toolName, output: "", droppedChars: 0 });
1150
+ parts.push(this.withMeta({
1151
+ type: "tool-call",
1152
+ toolCallId: item.id,
1153
+ toolName,
1154
+ input: JSON.stringify({ changes: item.changes, status: item.status }),
1155
+ providerExecuted: true,
1156
+ dynamic: true
1157
+ }));
1158
+ break;
1159
+ }
1160
+ case "webSearch": {
1161
+ this.ensureStreamStarted(parts);
1162
+ const toolName = "codex_web_search";
1163
+ this.openToolCalls.set(item.id, { toolName, output: "", droppedChars: 0 });
1164
+ parts.push(this.withMeta({
1165
+ type: "tool-call",
1166
+ toolCallId: item.id,
1167
+ toolName,
1168
+ input: JSON.stringify({ query: item.query, action: item.action ?? void 0 }),
1169
+ providerExecuted: true,
1170
+ dynamic: true
1171
+ }));
1172
+ break;
1173
+ }
1169
1174
  case "reasoning":
1170
1175
  case "plan":
1171
- case "fileChange":
1172
1176
  case "mcpToolCall":
1173
1177
  case "collabAgentToolCall":
1174
- case "webSearch":
1175
1178
  case "imageView":
1176
1179
  case "contextCompaction":
1177
1180
  case "enteredReviewMode":
@@ -1252,22 +1255,40 @@ ${output}`;
1252
1255
  }
1253
1256
  }));
1254
1257
  this.openToolCalls.delete(item.id);
1255
- } else if (item.type === "webSearch") {
1258
+ } else if (item.type === "fileChange" && this.openToolCalls.has(item.id)) {
1259
+ const tracked = this.openToolCalls.get(item.id);
1260
+ const toolName = tracked?.toolName ?? "codex_file_change";
1261
+ const output = tracked ? this.formatToolOutput(tracked.output, tracked.droppedChars) : "";
1262
+ parts.push(this.withMeta({
1263
+ type: "tool-result",
1264
+ toolCallId: item.id,
1265
+ toolName,
1266
+ result: { output, status: item.status, changes: item.changes }
1267
+ }));
1268
+ this.openToolCalls.delete(item.id);
1269
+ } else if (item.type === "webSearch" && this.openToolCalls.has(item.id)) {
1256
1270
  const webSearchSummary = this.formatWebSearchItemSummary(item);
1257
- if (webSearchSummary) {
1258
- this.emitReasoningDelta(parts, item.id, webSearchSummary);
1259
- }
1260
- if (this.openReasoningParts.has(item.id)) {
1261
- parts.push(this.withMeta({ type: "reasoning-end", id: item.id }));
1262
- this.openReasoningParts.delete(item.id);
1263
- }
1271
+ const tracked = this.openToolCalls.get(item.id);
1272
+ const toolName = tracked?.toolName ?? "codex_web_search";
1273
+ parts.push(this.withMeta({
1274
+ type: "tool-result",
1275
+ toolCallId: item.id,
1276
+ toolName,
1277
+ result: {
1278
+ output: webSearchSummary || "",
1279
+ query: item.query,
1280
+ action: item.action ?? void 0,
1281
+ summary: webSearchSummary || void 0
1282
+ }
1283
+ }));
1284
+ this.openToolCalls.delete(item.id);
1264
1285
  } else if (this.openReasoningParts.has(item.id)) {
1265
1286
  parts.push(this.withMeta({ type: "reasoning-end", id: item.id }));
1266
1287
  this.openReasoningParts.delete(item.id);
1267
1288
  }
1268
1289
  return parts;
1269
1290
  }
1270
- // item/reasoning/textDelta, item/reasoning/summaryTextDelta, item/plan/delta, item/fileChange/outputDelta
1291
+ // item/reasoning/textDelta, item/reasoning/summaryTextDelta, item/plan/delta
1271
1292
  handleReasoningDelta(params) {
1272
1293
  const delta = params ?? {};
1273
1294
  if (!delta.itemId || !delta.delta) {
@@ -1277,6 +1298,22 @@ ${output}`;
1277
1298
  this.emitReasoningDelta(parts, delta.itemId, delta.delta);
1278
1299
  return parts;
1279
1300
  }
1301
+ // item/fileChange/outputDelta
1302
+ handleFileChangeOutputDelta(params) {
1303
+ const delta = params ?? {};
1304
+ if (!delta.itemId || !delta.delta || !this.openToolCalls.has(delta.itemId)) {
1305
+ return [];
1306
+ }
1307
+ const tracked = this.openToolCalls.get(delta.itemId);
1308
+ this.appendTrackedOutput(tracked, delta.delta);
1309
+ return [this.withMeta({
1310
+ type: "tool-result",
1311
+ toolCallId: delta.itemId,
1312
+ toolName: tracked.toolName,
1313
+ result: { output: this.formatToolOutput(tracked.output, tracked.droppedChars) },
1314
+ preliminary: true
1315
+ })];
1316
+ }
1280
1317
  // item/reasoning/summaryPartAdded
1281
1318
  handleSummaryPartAdded(params) {
1282
1319
  const p = params ?? {};