stitchkit 0.132.0 → 0.132.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/CHANGELOG.md +11 -0
- package/dist/agent-executor/acp/v1-probe.d.ts.map +1 -1
- package/dist/agent-executor/codex/event-routing.d.ts +8 -1
- package/dist/agent-executor/codex/event-routing.d.ts.map +1 -1
- package/dist/agent-executor/codex/handlers.d.ts +1 -0
- package/dist/agent-executor/codex/handlers.d.ts.map +1 -1
- package/dist/agent-executor/codex/limits.d.ts.map +1 -1
- package/dist/agent-executor/codex/session.d.ts.map +1 -1
- package/dist/agent-executor/codex/shared-server.d.ts.map +1 -1
- package/dist/agent-executor/codex/shared-thread.d.ts +1 -0
- package/dist/agent-executor/codex/shared-thread.d.ts.map +1 -1
- package/dist/agent-executor/codex/thread-open.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/acp.js +16 -2
- package/dist/entrypoints/agent-executor/codex.js +197 -54
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -15,6 +15,17 @@ additive**; the first breaking change landed in 0.10.0. Grep the file for
|
|
|
15
15
|
|
|
16
16
|
## [Unreleased]
|
|
17
17
|
|
|
18
|
+
## [0.132.1] - 2026-11-27
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
|
|
22
|
+
- `stitchkit/agent-executor/codex` — discard buffered pre-`turn/start` frames when a session or shared-server thread closes, disconnects, or aborts, and reject `CodexServerRequestEvent.respond` / `CodexTurn.respond` once the connection is no longer alive.
|
|
23
|
+
**Affects:** `stitchkit/agent-executor/codex` createCodexDriver(open, connectControl, openSharedServer), CodexServerRequestEvent, CodexTurn
|
|
24
|
+
- `stitchkit/agent-executor/codex` — preserve bucket `label`, `resetsAt`, and partially reported window durations when `rateLimitsByLimitId` merges over a sibling `rateLimits` view of the same bucket.
|
|
25
|
+
**Affects:** `stitchkit/agent-executor/codex` codexPlanLimits, codexPlanWindows, createCodexDriver
|
|
26
|
+
- `stitchkit/agent-executor/acp` — stop probe cleanup immediately when `timeoutMs` or `AbortSignal` fires during `session/close` or `session/delete`, rejecting with the original timeout or abort reason instead of a duplicate cleanup `AggregateError`.
|
|
27
|
+
**Affects:** `stitchkit/agent-executor/acp` createAcpDriver(probeCapabilities)
|
|
28
|
+
|
|
18
29
|
## [0.132.0] - 2026-11-27
|
|
19
30
|
|
|
20
31
|
### ⚠️ Breaking changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v1-probe.d.ts","sourceRoot":"","sources":["../../../src/agent-executor/acp/v1-probe.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"v1-probe.d.ts","sourceRoot":"","sources":["../../../src/agent-executor/acp/v1-probe.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,qBAAqB,EAAiB,MAAM,YAAY,CAAC;AAEvE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,eAAe,EAMrB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,mBAAmB,EAKzB,MAAM,eAAe,CAAC;AAIvB,qDAAqD;AACrD,MAAM,WAAW,yBAAyB;IACxC,+EAA+E;IAC/E,QAAQ,CAAC,OAAO,EAAE,qBAAqB,CAAC;IACxC,iDAAiD;IACjD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,gFAAgF;IAChF,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IAC1C,sGAAsG;IACtG,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,mGAAmG;IACnG,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;CAC/E;AAED,qFAAqF;AACrF,MAAM,WAAW,oBAAoB;IACnC,wDAAwD;IACxD,QAAQ,CAAC,WAAW,EAAE,mBAAmB,CAAC;IAC1C,gGAAgG;IAChG,QAAQ,CAAC,aAAa,EAAE,SAAS,eAAe,EAAE,CAAC;IACnD,6FAA6F;IAC7F,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,uGAAuG;IACvG,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CACpC;AA+ED,uGAAuG;AACvG,wBAAsB,cAAc,CAClC,MAAM,EAAE,eAAe,EACvB,UAAU,EAAE,aAAa,EACzB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,MAAM,EAAE,CAAC,CAGnB;AA8BD;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,eAAe,EACvB,KAAK,EAAE,yBAAyB,GAC/B,OAAO,CAAC,oBAAoB,CAAC,CAwD/B"}
|
|
@@ -7,8 +7,15 @@ export declare class CodexStartingTurn {
|
|
|
7
7
|
private readonly waiting;
|
|
8
8
|
private bytes;
|
|
9
9
|
private failure?;
|
|
10
|
+
private discarded;
|
|
11
|
+
private flushing;
|
|
12
|
+
get isBuffering(): boolean;
|
|
10
13
|
defer(params: JsonRpcValue | undefined, deliver: () => void): void;
|
|
11
|
-
|
|
14
|
+
/** Drop buffered pre-start events without delivery when a session closes or disconnects. */
|
|
15
|
+
discard(): void;
|
|
16
|
+
flush(shouldContinue?: () => boolean): void;
|
|
12
17
|
}
|
|
18
|
+
/** Detach and discard any pre-start buffer on `turn` without invoking observers. */
|
|
19
|
+
export declare function discardStartingTurn(turn: CodexTurnSlot | undefined): void;
|
|
13
20
|
export declare function codexEventTurn(current: CodexTurnSlot | undefined, params: unknown): CodexTurnSlot | undefined;
|
|
14
21
|
//# sourceMappingURL=event-routing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-routing.d.ts","sourceRoot":"","sources":["../../../src/agent-executor/codex/event-routing.ts"],"names":[],"mappings":"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ED,oFAAoF;AACpF,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,aAAa,GAAG,SAAS,GAAG,IAAI,CAKzE;AAED,wBAAgB,cAAc,CAC5B,OAAO,EAAE,aAAa,GAAG,SAAS,EAClC,MAAM,EAAE,OAAO,GACd,aAAa,GAAG,SAAS,CAiB3B"}
|
|
@@ -37,6 +37,7 @@ interface CodexHandlersState {
|
|
|
37
37
|
profileId: string;
|
|
38
38
|
limits: Map<string, PlanLimits>;
|
|
39
39
|
externalPending: Map<string, PendingExternalCodexRequest>;
|
|
40
|
+
ensureAlive: () => void;
|
|
40
41
|
getTurn: () => CodexTurnSlot | undefined;
|
|
41
42
|
clearTurn: () => void;
|
|
42
43
|
onNotification?: (event: CodexNotificationEvent) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/agent-executor/codex/handlers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAA2C,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAG9F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAInD,OAAO,EAGL,KAAK,wBAAwB,EAC7B,KAAK,aAAa,EAIlB,KAAK,2BAA2B,EAEjC,MAAM,mBAAmB,CAAC;AAK3B,sGAAsG;AACtG,MAAM,WAAW,sBAAsB;IACrC,0GAA0G;IAC1G,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,oEAAoE;IACpE,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG,SAAS,CAAC;IAC1C,kGAAkG;IAClG,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;IACnC,+FAA+F;IAC/F,QAAQ,CAAC,MAAM,EAAE,SAAS,aAAa,EAAE,CAAC;CAC3C;AAED,wIAAw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E,UAAU,CAAC,CAAC;IAChC,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,2BAA2B,CAAC,CAAC;IAC1D,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,OAAO,EAAE,MAAM,aAAa,GAAG,SAAS,CAAC;IACzC,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,IAAI,CAAC;IACzD,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,uBAAuB,KAAK,IAAI,CAAC;IAC3D,qBAAqB,CAAC,EAAE,eAAe,GAAG,KAAK,CAAC;CACjD;AAoRD,oGAAoG;AACpG,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,kBAAkB;IAIzD,cAAc,SAAS,MAAM,UAAU,YAAY,GAAG,SAAS;IAU/D,SAAS,SAAS,MAAM,UAAU,YAAY,GAAG,SAAS,MAAM,MAAM,GAAG,MAAM;EAoBlF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limits.d.ts","sourceRoot":"","sources":["../../../src/agent-executor/codex/limits.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,UAAU,EAEf,KAAK,UAAU,EAEhB,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"limits.d.ts","sourceRoot":"","sources":["../../../src/agent-executor/codex/limits.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,UAAU,EAEf,KAAK,UAAU,EAEhB,MAAM,UAAU,CAAC;AAyOlB;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,OAAO,GAAG,UAAU,EAAE,CAEhE;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,GAAE,IAAiB,GAAG,UAAU,CAQrF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../src/agent-executor/codex/session.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,sBAAsB,EAE5B,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../src/agent-executor/codex/session.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,sBAAsB,EAE5B,MAAM,kBAAkB,CAAC;AAiB1B,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EAEb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,KAAK,kBAAkB,EAKxB,MAAM,eAAe,CAAC;AAEvB;;;;;GAKG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,kBAAkB,EAC1B,KAAK,EAAE,cAAc,GACpB,OAAO,CAAC,YAAY,CAAC,CA+KvB;AAED,8GAA8G;AAC9G,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,kBAAkB,EAC1B,KAAK,EAAE,wBAAwB,GAC9B,OAAO,CAAC,sBAAsB,CAAC,CAqFjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-server.d.ts","sourceRoot":"","sources":["../../../src/agent-executor/codex/shared-server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shared-server.d.ts","sourceRoot":"","sources":["../../../src/agent-executor/codex/shared-server.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAC;AAC3D,OAAO,EAAE,KAAK,qBAAqB,EAAiB,MAAM,YAAY,CAAC;AAEvE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAE1D,OAAO,EAAE,KAAK,kBAAkB,EAA4B,MAAM,kBAAkB,CAAC;AAIrF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EACL,KAAK,4BAA4B,EAIlC,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,KAAK,kBAAkB,EAA2B,MAAM,eAAe,CAAC;AAKjF,oGAAoG;AACpG,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,OAAO,EAAE,qBAAqB,CAAC;IACxC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,kGAAkG;IAClG,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,wGAAwG;IACxG,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAC9E,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;CAC3C;AAED,4GAA4G;AAC5G,MAAM,WAAW,iBAAkB,SAAQ,kBAAkB;IAC3D,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,+FAA+F;IAC/F,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,YAAY,EAAE,0BAA0B,CAAC;IAClD,UAAU,CAAC,KAAK,EAAE,4BAA4B,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IACvE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAwBD,qGAAqG;AACrG,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,kBAAkB,EAC1B,gBAAgB,EAAE,0BAA0B,EAC5C,KAAK,EAAE,0BAA0B,GAChC,OAAO,CAAC,iBAAiB,CAAC,CAiJ5B"}
|
|
@@ -21,6 +21,7 @@ export interface SharedThreadSlot {
|
|
|
21
21
|
current: CodexTurnSlot | undefined;
|
|
22
22
|
readonly externalPending: Map<string, PendingExternalCodexRequest>;
|
|
23
23
|
readonly handlers: ReturnType<typeof createCodexHandlers>;
|
|
24
|
+
readonly ensureAlive: () => void;
|
|
24
25
|
closed: boolean;
|
|
25
26
|
dead: Error | undefined;
|
|
26
27
|
readonly abortThread: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared-thread.d.ts","sourceRoot":"","sources":["../../../src/agent-executor/codex/shared-thread.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAgB,MAAM,kBAAkB,CAAC;AAClE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"shared-thread.d.ts","sourceRoot":"","sources":["../../../src/agent-executor/codex/shared-thread.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAgB,MAAM,kBAAkB,CAAC;AAClE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAG1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAOjD,OAAO,EAEL,KAAK,aAAa,EAElB,KAAK,2BAA2B,EACjC,MAAM,mBAAmB,CAAC;AAG3B,OAAO,KAAK,EACV,oBAAoB,EACpB,YAAY,EAEb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,KAAK,kBAAkB,EAIxB,MAAM,eAAe,CAAC;AAIvB,iGAAiG;AACjG,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,0FAA0F;IAC1F,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7C,kHAAkH;IAClH,QAAQ,CAAC,QAAQ,CAAC,EAAE,oBAAoB,GAAG,SAAS,CAAC;IACrD,sFAAsF;IACtF,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,oBAA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AAE,oBAAoB,GAAG,SAAS,CAAC;CACtD,EACD,gBAAgB,EAAE,0BAA0B,GAAG,SAAS,GACvD,OAAO,CAAC,YAAY,CAAC,CA0BvB"}
|
|
@@ -51,6 +51,9 @@ import {
|
|
|
51
51
|
assertTimerMs,
|
|
52
52
|
withSignalDeadline
|
|
53
53
|
} from "../../index-agy5fqgf.js";
|
|
54
|
+
import {
|
|
55
|
+
abortReason
|
|
56
|
+
} from "../../index-rptj3qnc.js";
|
|
54
57
|
|
|
55
58
|
// src/agent-executor/acp/scenarios.ts
|
|
56
59
|
var session = "fake-session";
|
|
@@ -1027,29 +1030,40 @@ async function readProbeSession(config, connection, cwd, signal) {
|
|
|
1027
1030
|
mcpServers: [],
|
|
1028
1031
|
...meta !== undefined && { _meta: meta }
|
|
1029
1032
|
}, { signal });
|
|
1033
|
+
if (signal?.aborted)
|
|
1034
|
+
throw abortReason(signal);
|
|
1030
1035
|
const { sessionId } = ProbeSessionId.parse(reply);
|
|
1031
1036
|
const parsed = AcpNewSessionResultSchema.safeParse(reply);
|
|
1032
1037
|
const failures = parsed.success ? [] : [parsed.error];
|
|
1033
1038
|
const timeoutMs = closeRequestTimeoutMs(config);
|
|
1039
|
+
const cleanupOptions = { timeoutMs, ...signal !== undefined && { signal } };
|
|
1034
1040
|
const recordFailure = (method, cause) => failures.push(new Error(`${method} failed: ${cause instanceof Error ? cause.message : String(cause)}`, {
|
|
1035
1041
|
cause
|
|
1036
1042
|
}));
|
|
1037
1043
|
if (acpCan(connection, "close")) {
|
|
1038
1044
|
try {
|
|
1039
|
-
await connection.peer.request("session/close", { sessionId },
|
|
1045
|
+
await connection.peer.request("session/close", { sessionId }, cleanupOptions);
|
|
1040
1046
|
} catch (cause) {
|
|
1047
|
+
if (signal?.aborted)
|
|
1048
|
+
throw abortReason(signal);
|
|
1041
1049
|
const canFallBack = cause instanceof JsonRpcError2 && cause.code === JSON_RPC_METHOD_NOT_FOUND2 && acpCan(connection, "delete");
|
|
1042
1050
|
if (!canFallBack)
|
|
1043
1051
|
recordFailure("session/close", cause);
|
|
1044
1052
|
}
|
|
1045
1053
|
}
|
|
1054
|
+
if (signal?.aborted)
|
|
1055
|
+
throw abortReason(signal);
|
|
1046
1056
|
if (acpCan(connection, "delete")) {
|
|
1047
1057
|
try {
|
|
1048
|
-
await connection.peer.request("session/delete", { sessionId },
|
|
1058
|
+
await connection.peer.request("session/delete", { sessionId }, cleanupOptions);
|
|
1049
1059
|
} catch (cause) {
|
|
1060
|
+
if (signal?.aborted)
|
|
1061
|
+
throw abortReason(signal);
|
|
1050
1062
|
recordFailure("session/delete", cause);
|
|
1051
1063
|
}
|
|
1052
1064
|
}
|
|
1065
|
+
if (signal?.aborted)
|
|
1066
|
+
throw abortReason(signal);
|
|
1053
1067
|
if (failures.length > 1) {
|
|
1054
1068
|
throw new AggregateError(failures, failures.map((error) => error.message).join("; "), {
|
|
1055
1069
|
cause: failures[0]
|
|
@@ -1984,7 +1984,14 @@ class CodexStartingTurn {
|
|
|
1984
1984
|
waiting = [];
|
|
1985
1985
|
bytes = 0;
|
|
1986
1986
|
failure;
|
|
1987
|
+
discarded = false;
|
|
1988
|
+
flushing = false;
|
|
1989
|
+
get isBuffering() {
|
|
1990
|
+
return !this.discarded && !this.flushing;
|
|
1991
|
+
}
|
|
1987
1992
|
defer(params, deliver) {
|
|
1993
|
+
if (!this.isBuffering)
|
|
1994
|
+
return;
|
|
1988
1995
|
if (this.failure !== undefined)
|
|
1989
1996
|
throw this.failure;
|
|
1990
1997
|
this.bytes += JSON.stringify(params ?? null).length;
|
|
@@ -1994,12 +2001,36 @@ class CodexStartingTurn {
|
|
|
1994
2001
|
}
|
|
1995
2002
|
this.waiting.push(deliver);
|
|
1996
2003
|
}
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2004
|
+
discard() {
|
|
2005
|
+
this.discarded = true;
|
|
2006
|
+
this.waiting.length = 0;
|
|
2007
|
+
this.bytes = 0;
|
|
2008
|
+
this.failure = undefined;
|
|
2002
2009
|
}
|
|
2010
|
+
flush(shouldContinue) {
|
|
2011
|
+
this.flushing = true;
|
|
2012
|
+
try {
|
|
2013
|
+
for (const deliver of this.waiting.splice(0)) {
|
|
2014
|
+
if (this.discarded || shouldContinue?.() === false) {
|
|
2015
|
+
this.discard();
|
|
2016
|
+
return;
|
|
2017
|
+
}
|
|
2018
|
+
deliver();
|
|
2019
|
+
}
|
|
2020
|
+
if (!this.discarded && shouldContinue?.() !== false && this.failure !== undefined) {
|
|
2021
|
+
throw this.failure;
|
|
2022
|
+
}
|
|
2023
|
+
} finally {
|
|
2024
|
+
this.flushing = false;
|
|
2025
|
+
}
|
|
2026
|
+
}
|
|
2027
|
+
}
|
|
2028
|
+
function discardStartingTurn(turn) {
|
|
2029
|
+
if (turn?.starting === undefined)
|
|
2030
|
+
return;
|
|
2031
|
+
const starting = turn.starting;
|
|
2032
|
+
delete turn.starting;
|
|
2033
|
+
starting.discard();
|
|
2003
2034
|
}
|
|
2004
2035
|
function codexEventTurn(current, params) {
|
|
2005
2036
|
if (current === undefined)
|
|
@@ -2297,20 +2328,51 @@ function createCodexStartTurn(input) {
|
|
|
2297
2328
|
channel: createTurnDeltaChannel(),
|
|
2298
2329
|
pending: new Map
|
|
2299
2330
|
};
|
|
2331
|
+
const isAlive = () => {
|
|
2332
|
+
if (input.signal.aborted)
|
|
2333
|
+
return false;
|
|
2334
|
+
try {
|
|
2335
|
+
input.ensureAlive();
|
|
2336
|
+
return true;
|
|
2337
|
+
} catch {
|
|
2338
|
+
return false;
|
|
2339
|
+
}
|
|
2340
|
+
};
|
|
2300
2341
|
input.setTurn(turn);
|
|
2301
2342
|
let nativeTurnId;
|
|
2302
2343
|
try {
|
|
2303
|
-
const started = await input.peer.request("turn/start", turnParams
|
|
2344
|
+
const started = await input.peer.request("turn/start", turnParams, {
|
|
2345
|
+
signal: input.signal
|
|
2346
|
+
});
|
|
2347
|
+
if (!isAlive() || input.getTurn() !== turn) {
|
|
2348
|
+
if (input.getTurn() === turn)
|
|
2349
|
+
input.setTurn(undefined);
|
|
2350
|
+
discardStartingTurn(turn);
|
|
2351
|
+
input.ensureAlive();
|
|
2352
|
+
throw new Error("The Codex session is closed");
|
|
2353
|
+
}
|
|
2304
2354
|
nativeTurnId = parseCodexResponse("turn/start", CodexStartedTurnSchema, started).turn.id;
|
|
2305
2355
|
turn.codexTurnId = nativeTurnId;
|
|
2306
|
-
|
|
2307
|
-
|
|
2356
|
+
try {
|
|
2357
|
+
starting.flush(isAlive);
|
|
2358
|
+
} finally {
|
|
2359
|
+
if (turn.starting === starting)
|
|
2360
|
+
delete turn.starting;
|
|
2361
|
+
}
|
|
2308
2362
|
} catch (error) {
|
|
2309
2363
|
if (input.getTurn() === turn)
|
|
2310
2364
|
input.setTurn(undefined);
|
|
2311
2365
|
if (turn.starting !== undefined) {
|
|
2312
|
-
|
|
2313
|
-
|
|
2366
|
+
const pending = turn.starting;
|
|
2367
|
+
try {
|
|
2368
|
+
if (isAlive())
|
|
2369
|
+
pending.flush(isAlive);
|
|
2370
|
+
else
|
|
2371
|
+
pending.discard();
|
|
2372
|
+
} finally {
|
|
2373
|
+
if (turn.starting === pending)
|
|
2374
|
+
delete turn.starting;
|
|
2375
|
+
}
|
|
2314
2376
|
}
|
|
2315
2377
|
throw error;
|
|
2316
2378
|
}
|
|
@@ -2325,6 +2387,7 @@ function createCodexStartTurn(input) {
|
|
|
2325
2387
|
});
|
|
2326
2388
|
},
|
|
2327
2389
|
async respond(interactionId, rawReply) {
|
|
2390
|
+
input.ensureAlive();
|
|
2328
2391
|
answerActiveCodexTurnRequest(turn, interactionId, rawReply);
|
|
2329
2392
|
}
|
|
2330
2393
|
};
|
|
@@ -2519,32 +2582,62 @@ function resolveWindowFields(raw) {
|
|
|
2519
2582
|
const resetsAt = parseCodexResetsAt(window.resetsAt ?? window.resets_at);
|
|
2520
2583
|
return { usedPercent, mins, resetsAt };
|
|
2521
2584
|
}
|
|
2585
|
+
function findMatchingWindowIndex(windows, bucket, slot, mins, other, excludeIndex) {
|
|
2586
|
+
const exact = windows.findIndex((w, i) => i !== excludeIndex && w.bucket === bucket && w.slot === slot && w.mins === mins);
|
|
2587
|
+
if (exact >= 0)
|
|
2588
|
+
return exact;
|
|
2589
|
+
let partialIndex = -1;
|
|
2590
|
+
let partialCount = 0;
|
|
2591
|
+
for (let i = 0;i < windows.length; i += 1) {
|
|
2592
|
+
if (i === excludeIndex)
|
|
2593
|
+
continue;
|
|
2594
|
+
const candidate = windows[i];
|
|
2595
|
+
if (candidate !== undefined && candidate.bucket === bucket && candidate.slot === slot && (candidate.mins === undefined || mins === undefined)) {
|
|
2596
|
+
partialIndex = i;
|
|
2597
|
+
partialCount += 1;
|
|
2598
|
+
}
|
|
2599
|
+
}
|
|
2600
|
+
if (partialCount === 1)
|
|
2601
|
+
return partialIndex;
|
|
2602
|
+
if (mins !== undefined) {
|
|
2603
|
+
const otherSlot = slot === "primary" ? "secondary" : "primary";
|
|
2604
|
+
return windows.findIndex((w, i) => i !== excludeIndex && w.bucket === bucket && w.mins === mins && !(other !== undefined && w.slot === otherSlot && (other.mins === undefined || other.mins === w.mins)));
|
|
2605
|
+
}
|
|
2606
|
+
return -1;
|
|
2607
|
+
}
|
|
2522
2608
|
function mergeBucket(windows, bucket, snapshot) {
|
|
2523
|
-
const label = clampPlanName(snapshot.limitName ?? snapshot.limit_name, MAX_WINDOW_NAME_CHARS);
|
|
2524
2609
|
const primary = resolveWindowFields(snapshot.primary);
|
|
2525
2610
|
const secondary = resolveWindowFields(snapshot.secondary);
|
|
2526
|
-
const sharedDuration = primary?.mins !== undefined && primary.mins === secondary?.mins;
|
|
2527
2611
|
const slots = { primary, secondary };
|
|
2612
|
+
let claimedIndex = -1;
|
|
2528
2613
|
for (const slot of ["primary", "secondary"]) {
|
|
2529
2614
|
const measurement = slots[slot];
|
|
2530
2615
|
if (!measurement)
|
|
2531
2616
|
continue;
|
|
2532
|
-
const
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2617
|
+
const other = slots[slot === "primary" ? "secondary" : "primary"];
|
|
2618
|
+
const previous = findMatchingWindowIndex(windows, bucket, slot, measurement.mins, other, claimedIndex);
|
|
2619
|
+
const existing = previous >= 0 ? windows[previous] : undefined;
|
|
2620
|
+
const window = {
|
|
2621
|
+
usedPercent: measurement.usedPercent,
|
|
2622
|
+
mins: measurement.mins ?? existing?.mins,
|
|
2623
|
+
resetsAt: measurement.resetsAt ?? existing?.resetsAt,
|
|
2624
|
+
bucket,
|
|
2625
|
+
slot
|
|
2626
|
+
};
|
|
2627
|
+
if (previous >= 0) {
|
|
2539
2628
|
windows[previous] = window;
|
|
2540
|
-
|
|
2629
|
+
claimedIndex = previous;
|
|
2630
|
+
} else if (windows.length < MAX_PLAN_WINDOWS) {
|
|
2631
|
+
claimedIndex = windows.length;
|
|
2541
2632
|
windows.push(window);
|
|
2633
|
+
}
|
|
2542
2634
|
}
|
|
2543
2635
|
}
|
|
2544
|
-
function nameBucketWindows(windows) {
|
|
2636
|
+
function nameBucketWindows(windows, bucketLabels) {
|
|
2545
2637
|
const seen = new Set;
|
|
2546
2638
|
return windows.map((window) => {
|
|
2547
|
-
const { bucket, slot, usedPercent, mins, resetsAt
|
|
2639
|
+
const { bucket, slot, usedPercent, mins, resetsAt } = window;
|
|
2640
|
+
const label = bucketLabels.get(bucket);
|
|
2548
2641
|
const sharedDuration = mins !== undefined && windows.some((other) => other !== window && other.bucket === bucket && other.mins === mins);
|
|
2549
2642
|
const suffix = mins === undefined ? `:${slot}` : sharedDuration ? `:${mins}m:${slot}` : `:${mins}m`;
|
|
2550
2643
|
const name = clampUniqueWindowName(bucket, suffix, seen, `${bucket}:${slot}`, MAX_WINDOW_NAME_CHARS);
|
|
@@ -2561,6 +2654,7 @@ function parseCodexRateLimitsInternal(reported) {
|
|
|
2561
2654
|
if (!isRecord(reported))
|
|
2562
2655
|
return { windows: [], plan: undefined };
|
|
2563
2656
|
const windows = [];
|
|
2657
|
+
const bucketLabels = new Map;
|
|
2564
2658
|
let plan;
|
|
2565
2659
|
function readBucket(raw, fallbackId) {
|
|
2566
2660
|
const parsed = SnapshotSchema.safeParse(raw);
|
|
@@ -2569,6 +2663,9 @@ function parseCodexRateLimitsInternal(reported) {
|
|
|
2569
2663
|
const snapshot = parsed.data;
|
|
2570
2664
|
plan ??= clampPlanName(snapshot.planType ?? snapshot.plan_type, MAX_WINDOW_NAME_CHARS);
|
|
2571
2665
|
const id = nonEmptyString(snapshot.limitId ?? snapshot.limit_id)?.trim() ?? fallbackId;
|
|
2666
|
+
const label = clampPlanName(snapshot.limitName ?? snapshot.limit_name, MAX_WINDOW_NAME_CHARS);
|
|
2667
|
+
if (label !== undefined)
|
|
2668
|
+
bucketLabels.set(id, label);
|
|
2572
2669
|
mergeBucket(windows, id, snapshot);
|
|
2573
2670
|
return id;
|
|
2574
2671
|
}
|
|
@@ -2585,7 +2682,7 @@ function parseCodexRateLimitsInternal(reported) {
|
|
|
2585
2682
|
readBucket(byId[key], nonEmptyString(key)?.trim() ?? "limit");
|
|
2586
2683
|
}
|
|
2587
2684
|
}
|
|
2588
|
-
return { windows: nameBucketWindows(windows), plan };
|
|
2685
|
+
return { windows: nameBucketWindows(windows, bucketLabels), plan };
|
|
2589
2686
|
}
|
|
2590
2687
|
function codexPlanWindows(reported) {
|
|
2591
2688
|
return parseCodexRateLimitsInternal(reported).windows;
|
|
@@ -2699,6 +2796,14 @@ async function findCodexTurnByClientId(controls, params) {
|
|
|
2699
2796
|
// src/agent-executor/codex/handlers.ts
|
|
2700
2797
|
var JSON_RPC_INTERNAL_ERROR = -32603;
|
|
2701
2798
|
var MAX_EXTERNAL_PENDING_REQUESTS = 256;
|
|
2799
|
+
function isHandlersAlive(state) {
|
|
2800
|
+
try {
|
|
2801
|
+
state.ensureAlive();
|
|
2802
|
+
return true;
|
|
2803
|
+
} catch {
|
|
2804
|
+
return false;
|
|
2805
|
+
}
|
|
2806
|
+
}
|
|
2702
2807
|
function emitCodexNotification(state, method, params, duringActiveTurn, deltas) {
|
|
2703
2808
|
if (state.onNotification === undefined)
|
|
2704
2809
|
return;
|
|
@@ -2838,6 +2943,7 @@ function handleCodexRequest(state, method, params, id) {
|
|
|
2838
2943
|
duringActiveTurn: true,
|
|
2839
2944
|
delta,
|
|
2840
2945
|
async respond(reply) {
|
|
2946
|
+
state.ensureAlive();
|
|
2841
2947
|
answerActiveCodexTurnRequest(turn, interactionId, reply);
|
|
2842
2948
|
}
|
|
2843
2949
|
}));
|
|
@@ -2890,6 +2996,7 @@ function handleCodexRequest(state, method, params, id) {
|
|
|
2890
2996
|
duringActiveTurn: false,
|
|
2891
2997
|
delta,
|
|
2892
2998
|
async respond(reply) {
|
|
2999
|
+
state.ensureAlive();
|
|
2893
3000
|
answerCodexSessionRequest({
|
|
2894
3001
|
turn: undefined,
|
|
2895
3002
|
externalPending: state.externalPending,
|
|
@@ -2908,22 +3015,35 @@ function handleCodexRequest(state, method, params, id) {
|
|
|
2908
3015
|
});
|
|
2909
3016
|
}
|
|
2910
3017
|
function createCodexHandlers(state) {
|
|
3018
|
+
const dropClosedRequest = () => new Promise(() => {
|
|
3019
|
+
return;
|
|
3020
|
+
});
|
|
2911
3021
|
return {
|
|
2912
3022
|
onNotification(method, params) {
|
|
3023
|
+
if (!isHandlersAlive(state))
|
|
3024
|
+
return;
|
|
2913
3025
|
const starting = codexEventTurn(state.getTurn(), params)?.starting;
|
|
2914
|
-
const deliver = () =>
|
|
2915
|
-
|
|
3026
|
+
const deliver = () => {
|
|
3027
|
+
if (!isHandlersAlive(state))
|
|
3028
|
+
return;
|
|
3029
|
+
handleCodexNotification(state, method, params);
|
|
3030
|
+
};
|
|
3031
|
+
if (starting === undefined || !starting.isBuffering)
|
|
2916
3032
|
deliver();
|
|
2917
3033
|
else
|
|
2918
3034
|
starting.defer(params, deliver);
|
|
2919
3035
|
},
|
|
2920
3036
|
onRequest(method, params, id) {
|
|
3037
|
+
if (!isHandlersAlive(state))
|
|
3038
|
+
return dropClosedRequest();
|
|
2921
3039
|
const starting = codexEventTurn(state.getTurn(), params)?.starting;
|
|
2922
|
-
const deliver = () => handleCodexRequest(state, method, params, id);
|
|
2923
|
-
if (starting === undefined)
|
|
3040
|
+
const deliver = () => isHandlersAlive(state) ? handleCodexRequest(state, method, params, id) : dropClosedRequest();
|
|
3041
|
+
if (starting === undefined || !starting.isBuffering)
|
|
2924
3042
|
return deliver();
|
|
2925
3043
|
return new Promise((resolve, reject) => {
|
|
2926
3044
|
starting.defer(params, () => {
|
|
3045
|
+
if (!isHandlersAlive(state))
|
|
3046
|
+
return;
|
|
2927
3047
|
try {
|
|
2928
3048
|
resolve(deliver());
|
|
2929
3049
|
} catch (error) {
|
|
@@ -3026,12 +3146,21 @@ async function openCodexSession(config, input) {
|
|
|
3026
3146
|
let dead;
|
|
3027
3147
|
let opened = false;
|
|
3028
3148
|
let closing = false;
|
|
3149
|
+
const ensureAlive = () => {
|
|
3150
|
+
if (closing)
|
|
3151
|
+
throw new Error("The Codex session is closed");
|
|
3152
|
+
if (dead !== undefined)
|
|
3153
|
+
throw dead;
|
|
3154
|
+
if (linked.signal.aborted)
|
|
3155
|
+
throw abortReason(linked.signal);
|
|
3156
|
+
};
|
|
3029
3157
|
let connected;
|
|
3030
3158
|
try {
|
|
3031
3159
|
connected = await connectCodex(config, profile, input.cwd, linked.signal, createCodexHandlers({
|
|
3032
3160
|
profileId: profile.profileId,
|
|
3033
3161
|
limits: config.limits,
|
|
3034
3162
|
externalPending,
|
|
3163
|
+
ensureAlive,
|
|
3035
3164
|
getTurn: () => current,
|
|
3036
3165
|
clearTurn: () => {
|
|
3037
3166
|
current = undefined;
|
|
@@ -3048,6 +3177,7 @@ async function openCodexSession(config, input) {
|
|
|
3048
3177
|
dead = error;
|
|
3049
3178
|
const turn = current;
|
|
3050
3179
|
current = undefined;
|
|
3180
|
+
discardStartingTurn(turn);
|
|
3051
3181
|
externalPending.clear();
|
|
3052
3182
|
loseEngineTurn(turn, codexStopped, error);
|
|
3053
3183
|
linked.abort();
|
|
@@ -3059,14 +3189,9 @@ async function openCodexSession(config, input) {
|
|
|
3059
3189
|
throw error;
|
|
3060
3190
|
}
|
|
3061
3191
|
const { peer, providerPid, userAgent } = connected;
|
|
3062
|
-
const ensureAlive = () => {
|
|
3063
|
-
if (closing)
|
|
3064
|
-
throw new Error("The Codex session is closed");
|
|
3065
|
-
if (dead !== undefined)
|
|
3066
|
-
throw dead;
|
|
3067
|
-
};
|
|
3068
3192
|
const stop = async (primary) => {
|
|
3069
3193
|
closing = true;
|
|
3194
|
+
discardStartingTurn(current);
|
|
3070
3195
|
externalPending.clear();
|
|
3071
3196
|
try {
|
|
3072
3197
|
await stopConnection(connected, primary);
|
|
@@ -3169,12 +3294,21 @@ async function openCodexControlConnection(config, input) {
|
|
|
3169
3294
|
let dead;
|
|
3170
3295
|
let opened = false;
|
|
3171
3296
|
let closing = false;
|
|
3297
|
+
const ensureAlive = () => {
|
|
3298
|
+
if (closing)
|
|
3299
|
+
throw new Error("The Codex control connection is closed");
|
|
3300
|
+
if (dead !== undefined)
|
|
3301
|
+
throw dead;
|
|
3302
|
+
if (linked.signal.aborted)
|
|
3303
|
+
throw abortReason(linked.signal);
|
|
3304
|
+
};
|
|
3172
3305
|
let connected;
|
|
3173
3306
|
try {
|
|
3174
3307
|
connected = await connectCodex(config, profile, input.cwd, linked.signal, createCodexHandlers({
|
|
3175
3308
|
profileId: profile.profileId,
|
|
3176
3309
|
limits: config.limits,
|
|
3177
3310
|
externalPending,
|
|
3311
|
+
ensureAlive,
|
|
3178
3312
|
getTurn: () => {
|
|
3179
3313
|
return;
|
|
3180
3314
|
},
|
|
@@ -3212,12 +3346,6 @@ async function openCodexControlConnection(config, input) {
|
|
|
3212
3346
|
}
|
|
3213
3347
|
throw reason;
|
|
3214
3348
|
}
|
|
3215
|
-
const ensureAlive = () => {
|
|
3216
|
-
if (closing)
|
|
3217
|
-
throw new Error("The Codex control connection is closed");
|
|
3218
|
-
if (dead !== undefined)
|
|
3219
|
-
throw dead;
|
|
3220
|
-
};
|
|
3221
3349
|
const controlClient = createCodexControlClient({
|
|
3222
3350
|
peer: connected.peer,
|
|
3223
3351
|
imageOptions: config,
|
|
@@ -3260,14 +3388,7 @@ function bestEffortUnsubscribe(state, threadId) {
|
|
|
3260
3388
|
}
|
|
3261
3389
|
function buildSharedThreadSession(params) {
|
|
3262
3390
|
const { state, slot, threadContext, activeModelProvider, threadAbort } = params;
|
|
3263
|
-
const { threadId } = slot;
|
|
3264
|
-
const ensureThreadAlive = () => {
|
|
3265
|
-
if (slot.closed)
|
|
3266
|
-
throw new Error("The Codex session is closed");
|
|
3267
|
-
if (slot.dead !== undefined)
|
|
3268
|
-
throw slot.dead;
|
|
3269
|
-
state.ensureServerAlive();
|
|
3270
|
-
};
|
|
3391
|
+
const { threadId, ensureAlive: ensureThreadAlive } = slot;
|
|
3271
3392
|
const threadControlClient = createCodexControlClient({
|
|
3272
3393
|
peer: state.peer,
|
|
3273
3394
|
imageOptions: state.config,
|
|
@@ -3301,13 +3422,14 @@ function buildSharedThreadSession(params) {
|
|
|
3301
3422
|
slot.closed = true;
|
|
3302
3423
|
const turn = slot.current;
|
|
3303
3424
|
slot.current = undefined;
|
|
3425
|
+
discardStartingTurn(turn);
|
|
3304
3426
|
slot.externalPending.clear();
|
|
3305
3427
|
loseEngineTurn(turn, codexStopped, new Error("The Codex session closed"));
|
|
3306
3428
|
state.threads.delete(threadId);
|
|
3429
|
+
threadAbort.abort();
|
|
3307
3430
|
try {
|
|
3308
3431
|
await bestEffortUnsubscribe(state, threadId);
|
|
3309
3432
|
} finally {
|
|
3310
|
-
threadAbort.abort();
|
|
3311
3433
|
slot.releaseThreadSignal();
|
|
3312
3434
|
}
|
|
3313
3435
|
};
|
|
@@ -3319,6 +3441,7 @@ function buildSharedThreadSession(params) {
|
|
|
3319
3441
|
slot.dead = slot.dead ?? (reason instanceof Error ? reason : new Error(String(reason)));
|
|
3320
3442
|
const turn = slot.current;
|
|
3321
3443
|
slot.current = undefined;
|
|
3444
|
+
discardStartingTurn(turn);
|
|
3322
3445
|
slot.externalPending.clear();
|
|
3323
3446
|
loseEngineTurn(turn, codexStopped, slot.dead);
|
|
3324
3447
|
state.threads.delete(threadId);
|
|
@@ -3413,10 +3536,20 @@ async function openSharedCodexThread(state, threadInput) {
|
|
|
3413
3536
|
throw new Error(`[stitchkit] CodexSharedServer.openThread: thread ${threadId} is already open on this shared server`);
|
|
3414
3537
|
}
|
|
3415
3538
|
const externalPending = new Map;
|
|
3539
|
+
const ensureAlive = () => {
|
|
3540
|
+
if (slot.closed)
|
|
3541
|
+
throw new Error("The Codex session is closed");
|
|
3542
|
+
if (slot.dead !== undefined)
|
|
3543
|
+
throw slot.dead;
|
|
3544
|
+
state.ensureServerAlive();
|
|
3545
|
+
if (threadAbort.signal.aborted)
|
|
3546
|
+
throw abortReason(threadAbort.signal);
|
|
3547
|
+
};
|
|
3416
3548
|
const slot = {
|
|
3417
3549
|
threadId,
|
|
3418
3550
|
current: undefined,
|
|
3419
3551
|
externalPending,
|
|
3552
|
+
ensureAlive,
|
|
3420
3553
|
closed: false,
|
|
3421
3554
|
dead: undefined,
|
|
3422
3555
|
abortThread: () => threadAbort.abort(),
|
|
@@ -3425,6 +3558,7 @@ async function openSharedCodexThread(state, threadInput) {
|
|
|
3425
3558
|
profileId: state.profile.profileId,
|
|
3426
3559
|
limits: state.config.limits,
|
|
3427
3560
|
externalPending,
|
|
3561
|
+
ensureAlive,
|
|
3428
3562
|
getTurn: () => slot.current,
|
|
3429
3563
|
clearTurn: () => {
|
|
3430
3564
|
slot.current = undefined;
|
|
@@ -3465,6 +3599,11 @@ async function openSharedCodexThread(state, threadInput) {
|
|
|
3465
3599
|
});
|
|
3466
3600
|
} catch (error) {
|
|
3467
3601
|
if (registeredThreadId !== undefined) {
|
|
3602
|
+
const failedSlot = state.threads.get(registeredThreadId);
|
|
3603
|
+
if (failedSlot !== undefined) {
|
|
3604
|
+
failedSlot.closed = true;
|
|
3605
|
+
failedSlot.externalPending.clear();
|
|
3606
|
+
}
|
|
3468
3607
|
state.threads.delete(registeredThreadId);
|
|
3469
3608
|
await bestEffortUnsubscribe(state, registeredThreadId);
|
|
3470
3609
|
}
|
|
@@ -3502,10 +3641,19 @@ async function openCodexSharedServer(config, baseCapabilities, input) {
|
|
|
3502
3641
|
let serverDead;
|
|
3503
3642
|
let serverClosing = false;
|
|
3504
3643
|
let opened = false;
|
|
3644
|
+
const ensureServerAlive = () => {
|
|
3645
|
+
if (serverClosing)
|
|
3646
|
+
throw new Error("The Codex shared server is closed");
|
|
3647
|
+
if (serverDead !== undefined)
|
|
3648
|
+
throw serverDead;
|
|
3649
|
+
if (linked.signal.aborted)
|
|
3650
|
+
throw abortReason(linked.signal);
|
|
3651
|
+
};
|
|
3505
3652
|
const globalHandlers = createCodexHandlers({
|
|
3506
3653
|
profileId: profile.profileId,
|
|
3507
3654
|
limits: config.limits,
|
|
3508
3655
|
externalPending: globalExternalPending,
|
|
3656
|
+
ensureAlive: ensureServerAlive,
|
|
3509
3657
|
getTurn: () => {
|
|
3510
3658
|
return;
|
|
3511
3659
|
},
|
|
@@ -3524,6 +3672,7 @@ async function openCodexSharedServer(config, baseCapabilities, input) {
|
|
|
3524
3672
|
slot.dead = error;
|
|
3525
3673
|
const turn = slot.current;
|
|
3526
3674
|
slot.current = undefined;
|
|
3675
|
+
discardStartingTurn(turn);
|
|
3527
3676
|
slot.externalPending.clear();
|
|
3528
3677
|
loseEngineTurn(turn, codexStopped, error);
|
|
3529
3678
|
slot.abortThread();
|
|
@@ -3568,12 +3717,6 @@ async function openCodexSharedServer(config, baseCapabilities, input) {
|
|
|
3568
3717
|
throw error;
|
|
3569
3718
|
}
|
|
3570
3719
|
const { peer, providerPid, userAgent } = connected;
|
|
3571
|
-
const ensureServerAlive = () => {
|
|
3572
|
-
if (serverClosing)
|
|
3573
|
-
throw new Error("The Codex shared server is closed");
|
|
3574
|
-
if (serverDead !== undefined)
|
|
3575
|
-
throw serverDead;
|
|
3576
|
-
};
|
|
3577
3720
|
const onBeforeInterruptTurn = (targetThreadId, turnId) => {
|
|
3578
3721
|
interruptLocalCodexTurn(threads.get(targetThreadId)?.current, turnId);
|
|
3579
3722
|
};
|
package/package.json
CHANGED