@ai-sdk/harness-codex 1.0.102 → 1.0.104

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/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @ai-sdk/harness-codex
2
2
 
3
+ ## 1.0.104
4
+
5
+ ### Patch Changes
6
+
7
+ - eeed977: feat(harness): allow passing arbitrary headers with inference requests via `headers` property in `HarnessAgentSettings`
8
+ - a39c8bf: chore(harness): clarify `writeSkills` helper intent to require materializing skills in HOME directory
9
+ - Updated dependencies [fe86f8f]
10
+ - Updated dependencies [255cccf]
11
+ - Updated dependencies [eeed977]
12
+ - Updated dependencies [a39c8bf]
13
+ - @ai-sdk/harness@1.0.102
14
+
15
+ ## 1.0.103
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies [951c54d]
20
+ - @ai-sdk/harness@1.0.101
21
+
3
22
  ## 1.0.102
4
23
 
5
24
  ### Patch Changes
@@ -214,6 +214,7 @@ async function runBridge(options) {
214
214
  }
215
215
  }
216
216
  const pendingToolResults = /* @__PURE__ */ new Map();
217
+ const bufferedToolResults = [];
217
218
  const pendingToolApprovals = /* @__PURE__ */ new Map();
218
219
  const writeBridgeMeta = async (state) => {
219
220
  try {
@@ -393,9 +394,23 @@ async function runBridge(options) {
393
394
  const userMessages = createBridgeUserMessageQueue({ respond: emit });
394
395
  const turn = {
395
396
  emit,
396
- requestToolResult: (toolCallId) => new Promise((resolve) => {
397
- pendingToolResults.set(toolCallId, resolve);
398
- }),
397
+ requestToolResult: (requestInput) => {
398
+ const request = typeof requestInput === "string" ? { toolCallId: requestInput } : requestInput;
399
+ const bufferedIndex = bufferedToolResults.findIndex(
400
+ (buffered) => buffered.toolCallId === request.toolCallId || request.matches?.(buffered.result) === true
401
+ );
402
+ if (bufferedIndex >= 0) {
403
+ return Promise.resolve(
404
+ bufferedToolResults.splice(bufferedIndex, 1)[0].result
405
+ );
406
+ }
407
+ return new Promise((resolve) => {
408
+ pendingToolResults.set(request.toolCallId, {
409
+ resolve,
410
+ matches: request.matches
411
+ });
412
+ });
413
+ },
399
414
  requestToolApproval: (approvalId) => new Promise((resolve) => {
400
415
  pendingToolApprovals.set(approvalId, resolve);
401
416
  }),
@@ -437,10 +452,25 @@ async function runBridge(options) {
437
452
  return;
438
453
  }
439
454
  case "tool-result": {
440
- const resolver = pendingToolResults.get(msg.toolCallId);
441
- if (resolver) {
442
- pendingToolResults.delete(msg.toolCallId);
443
- resolver({ output: msg.output, isError: msg.isError });
455
+ const result = {
456
+ output: msg.output,
457
+ isError: msg.isError,
458
+ toolResult: msg.toolResult
459
+ };
460
+ const exactPending = pendingToolResults.get(msg.toolCallId);
461
+ const matchingPending = exactPending == null ? Array.from(pendingToolResults.entries()).find(
462
+ ([, pending2]) => pending2.matches?.(result) === true
463
+ ) : void 0;
464
+ const pending = exactPending ?? matchingPending?.[1];
465
+ const pendingId = exactPending != null ? msg.toolCallId : matchingPending?.[0];
466
+ if (pending != null && pendingId != null) {
467
+ pendingToolResults.delete(pendingId);
468
+ pending.resolve(result);
469
+ } else {
470
+ bufferedToolResults.push({
471
+ toolCallId: msg.toolCallId,
472
+ result
473
+ });
444
474
  }
445
475
  return;
446
476
  }
@@ -1331,7 +1361,7 @@ async function runTurn(start, turn) {
1331
1361
  "AI Gateway auth was selected but AI_GATEWAY_BASE_URL is missing from the Codex bridge environment."
1332
1362
  );
1333
1363
  }
1334
- const apiBaseUrl = hasGatewayAuth ? gatewayBaseUrl : procEnv2.OPENAI_BASE_URL;
1364
+ const apiBaseUrl = hasGatewayAuth ? gatewayBaseUrl : procEnv2.OPENAI_BASE_URL ?? (start.headers != null ? "https://api.openai.com/v1" : void 0);
1335
1365
  const codexModel = start.model && hasGatewayAuth && !start.model.includes("/") ? `openai/${start.model}` : start.model;
1336
1366
  if (hasGatewayAuth && codexModel?.startsWith("openai/")) {
1337
1367
  codexConfig.model_supports_reasoning_summaries = true;
@@ -1346,10 +1376,13 @@ async function runTurn(start, turn) {
1346
1376
  env_key: "CODEX_API_KEY",
1347
1377
  wire_api: "responses",
1348
1378
  supports_websockets: false,
1349
- ...hasGatewayAuth && HARNESS_CLIENT_APP ? {
1379
+ ...start.headers != null || hasGatewayAuth && HARNESS_CLIENT_APP ? {
1350
1380
  http_headers: {
1351
- "User-Agent": HARNESS_CLIENT_APP,
1352
- "x-client-app": HARNESS_CLIENT_APP
1381
+ ...start.headers,
1382
+ ...hasGatewayAuth && HARNESS_CLIENT_APP ? {
1383
+ "User-Agent": HARNESS_CLIENT_APP,
1384
+ "x-client-app": HARNESS_CLIENT_APP
1385
+ } : {}
1353
1386
  }
1354
1387
  } : {}
1355
1388
  }