@ai-sdk/harness-codex 1.0.176 → 1.0.178
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 +22 -0
- package/dist/bridge/index.mjs +23 -2
- package/dist/bridge/index.mjs.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/bridge/codex-app-server-driver.ts +7 -0
- package/src/bridge/index.ts +10 -0
- package/src/codex-harness.ts +7 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @ai-sdk/harness-codex
|
|
2
2
|
|
|
3
|
+
## 1.0.178
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- e4a6112: fix(harness): enforce workDir / project-level config isolation where possible and clearly document the gap otherwise
|
|
8
|
+
- Updated dependencies [6400cf8]
|
|
9
|
+
- Updated dependencies [f608c05]
|
|
10
|
+
- Updated dependencies [cab9c1f]
|
|
11
|
+
- Updated dependencies [c70adf6]
|
|
12
|
+
- @ai-sdk/provider-utils@5.0.76
|
|
13
|
+
- @ai-sdk/provider@4.0.37
|
|
14
|
+
- @ai-sdk/harness@1.0.176
|
|
15
|
+
|
|
16
|
+
## 1.0.177
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- a54f0fd: fix(harness): abort a running turn when its host disconnects for good
|
|
21
|
+
- Updated dependencies [8e8033a]
|
|
22
|
+
- Updated dependencies [a54f0fd]
|
|
23
|
+
- @ai-sdk/harness@1.0.175
|
|
24
|
+
|
|
3
25
|
## 1.0.176
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/dist/bridge/index.mjs
CHANGED
|
@@ -200,6 +200,12 @@ const WS_OPEN = 1;
|
|
|
200
200
|
async function runBridge(options) {
|
|
201
201
|
const { bridgeType, bridgeStateDir, onStart, onStop, onDestroy } = options;
|
|
202
202
|
const teardownGraceMs = options.turnTeardownGraceMs ?? 1e4;
|
|
203
|
+
const hostDisconnectTimeoutMs = options.hostDisconnectTimeoutMs != null && Number.isFinite(options.hostDisconnectTimeoutMs) && options.hostDisconnectTimeoutMs > 0 ? Math.min(options.hostDisconnectTimeoutMs, 2147483647) : void 0;
|
|
204
|
+
let hostDisconnectTimer;
|
|
205
|
+
const clearHostDisconnectTimer = () => {
|
|
206
|
+
clearTimeout(hostDisconnectTimer);
|
|
207
|
+
hostDisconnectTimer = void 0;
|
|
208
|
+
};
|
|
203
209
|
const expectedToken = options.token ?? env.BRIDGE_CHANNEL_TOKEN ?? "";
|
|
204
210
|
const bridgeWsPort = options.port ?? parseInt(env.BRIDGE_WS_PORT ?? "0", 10);
|
|
205
211
|
const bridgeMetaPath = `${bridgeStateDir}/bridge-meta.json`;
|
|
@@ -387,6 +393,7 @@ async function runBridge(options) {
|
|
|
387
393
|
const thisTurn = new Promise((resolve) => turnFinished = resolve);
|
|
388
394
|
activeTurn = thisTurn;
|
|
389
395
|
activeSocket = ws;
|
|
396
|
+
clearHostDisconnectTimer();
|
|
390
397
|
const firstTurn = isFirstTurn;
|
|
391
398
|
isFirstTurn = false;
|
|
392
399
|
eventLog = [];
|
|
@@ -453,6 +460,7 @@ async function runBridge(options) {
|
|
|
453
460
|
activeTurn = void 0;
|
|
454
461
|
currentTurnState = "waiting";
|
|
455
462
|
writeBridgeMeta("waiting");
|
|
463
|
+
clearHostDisconnectTimer();
|
|
456
464
|
}
|
|
457
465
|
turnFinished();
|
|
458
466
|
}
|
|
@@ -519,6 +527,7 @@ async function runBridge(options) {
|
|
|
519
527
|
return;
|
|
520
528
|
case "resume":
|
|
521
529
|
activeSocket = ws;
|
|
530
|
+
clearHostDisconnectTimer();
|
|
522
531
|
replay(ws, msg.lastSeenEventId);
|
|
523
532
|
return;
|
|
524
533
|
case "destroy":
|
|
@@ -606,8 +615,18 @@ async function runBridge(options) {
|
|
|
606
615
|
}
|
|
607
616
|
handleInbound(parsed, ws);
|
|
608
617
|
});
|
|
609
|
-
ws.on("close", () => {
|
|
610
|
-
if (activeSocket === ws)
|
|
618
|
+
ws.on("close", (_code, reason) => {
|
|
619
|
+
if (activeSocket === ws) {
|
|
620
|
+
activeSocket = void 0;
|
|
621
|
+
if (hostDisconnectTimeoutMs != null && activeTurn != null && reason.toString() !== "suspended") {
|
|
622
|
+
clearHostDisconnectTimer();
|
|
623
|
+
hostDisconnectTimer = setTimeout(() => {
|
|
624
|
+
hostDisconnectTimer = void 0;
|
|
625
|
+
if (activeSocket == null) turnAbort?.abort();
|
|
626
|
+
}, hostDisconnectTimeoutMs);
|
|
627
|
+
hostDisconnectTimer.unref?.();
|
|
628
|
+
}
|
|
629
|
+
}
|
|
611
630
|
});
|
|
612
631
|
ws.on("error", () => {});
|
|
613
632
|
});
|
|
@@ -2129,6 +2148,7 @@ const appServer = createCodexAppServerRuntime();
|
|
|
2129
2148
|
await runBridge({
|
|
2130
2149
|
bridgeType: "codex",
|
|
2131
2150
|
bridgeStateDir,
|
|
2151
|
+
...args.hostDisconnectTimeoutMs !== void 0 ? { hostDisconnectTimeoutMs: args.hostDisconnectTimeoutMs } : {},
|
|
2132
2152
|
onStart: runTurn,
|
|
2133
2153
|
onStop: async () => {
|
|
2134
2154
|
const data = threadState.id ? { threadId: threadState.id } : {};
|
|
@@ -2220,6 +2240,7 @@ function parseArgs(args) {
|
|
|
2220
2240
|
const out = {};
|
|
2221
2241
|
for (let i = 0; i < args.length; i++) if (args[i] === "--workdir" && i + 1 < args.length) out.workdir = args[++i];
|
|
2222
2242
|
else if (args[i] === "--bridge-state-dir" && i + 1 < args.length) out.bridgeStateDir = args[++i];
|
|
2243
|
+
else if (args[i] === "--host-disconnect-timeout-ms" && i + 1 < args.length) out.hostDisconnectTimeoutMs = Number(args[++i]);
|
|
2223
2244
|
return out;
|
|
2224
2245
|
}
|
|
2225
2246
|
function emitFatal(message) {
|