@ai-sdk/harness-codex 1.0.190 → 1.0.191

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,16 @@
1
1
  # @ai-sdk/harness-codex
2
2
 
3
+ ## 1.0.191
4
+
5
+ ### Patch Changes
6
+
7
+ - 04a8f38: fix(harness): keep silent sandbox bridge connections alive with WebSocket pings and reconnect when a peer stops responding, controllable via `keepAliveMs` option for bridge-backed harness adapters
8
+ - ef6a950: fix(harness-codex): wait for background terminals before finishing turn
9
+ - Updated dependencies [1d2c2ff]
10
+ - Updated dependencies [04a8f38]
11
+ - @ai-sdk/provider-utils@5.0.83
12
+ - @ai-sdk/harness@1.0.189
13
+
3
14
  ## 1.0.190
4
15
 
5
16
  ### Patch Changes
@@ -1430,6 +1430,7 @@ function asRecord$1(value) {
1430
1430
  //#endregion
1431
1431
  //#region src/bridge/codex-app-server-driver.ts
1432
1432
  const CODEX_CLI_PATH = fileURLToPath(new URL("./node_modules/@openai/codex/bin/codex.js", import.meta.url));
1433
+ const BACKGROUND_TERMINAL_POLL_INTERVAL_MS = 1e3;
1433
1434
  function createCodexAppServerRuntime() {
1434
1435
  let client;
1435
1436
  let loadedThreadId;
@@ -1562,6 +1563,27 @@ function createCodexAppServerRuntime() {
1562
1563
  clientFailure,
1563
1564
  exitFailure
1564
1565
  ]);
1566
+ const waitForBackgroundTerminals = async () => {
1567
+ while (true) {
1568
+ const terminals = asRecord(await raceWithProcess({ operation: runningClient.request({
1569
+ method: "thread/backgroundTerminals/list",
1570
+ params: {
1571
+ threadId: currentTurn.threadId,
1572
+ limit: 1
1573
+ }
1574
+ }) }))?.data;
1575
+ if (!Array.isArray(terminals)) throw new Error("Codex app-server thread/backgroundTerminals/list returned an invalid response.");
1576
+ if (terminals.length === 0) return;
1577
+ let timer;
1578
+ try {
1579
+ await raceWithProcess({ operation: new Promise((resolve) => {
1580
+ timer = setTimeout(resolve, BACKGROUND_TERMINAL_POLL_INTERVAL_MS);
1581
+ }) });
1582
+ } finally {
1583
+ clearTimeout(timer);
1584
+ }
1585
+ }
1586
+ };
1565
1587
  let stopSteering = () => {};
1566
1588
  const steeringStopped = new Promise((resolve) => {
1567
1589
  stopSteering = resolve;
@@ -1671,8 +1693,12 @@ function createCodexAppServerRuntime() {
1671
1693
  handler.setTurnId(currentTurn.turnId);
1672
1694
  userMessageLoop();
1673
1695
  const result = await raceWithProcess({ operation: handler.waitForCompletion() });
1696
+ if (result.status !== "completed") {
1697
+ keepClient = true;
1698
+ assertSuccessfulTurn(result);
1699
+ }
1700
+ await waitForBackgroundTerminals();
1674
1701
  keepClient = true;
1675
- assertSuccessfulTurn(result);
1676
1702
  } catch (error) {
1677
1703
  if (turn.abortSignal.aborted && currentTurn.turnId != null) {
1678
1704
  let timer;