@openclaw/codex 2026.9.5 → 2026.9.7
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 +2 -0
- package/assets/icon.png +0 -0
- package/dist/.setup/{account-usage-runtime-C2MOIvfq.mjs → account-usage-runtime-DFhbh1zz.mjs} +6 -6
- package/dist/.setup/{apply-CJ0ZfmBG.mjs → apply-D3GcSoSa.mjs} +35 -55
- package/dist/.setup/{attempt-client-cleanup-BpYKdTA0.mjs → attempt-client-cleanup-DOP-cW5j.mjs} +179 -73
- package/dist/.setup/attempt-workspace-context-C5HigshI.mjs +164 -0
- package/dist/.setup/{auth-binding-DhLWa_7K.mjs → auth-binding-BLWz7stm.mjs} +14 -1
- package/dist/.setup/{auth-cache-key-QirmgiCo.mjs → auth-cache-key-Dbvq-QgB.mjs} +41 -111
- package/dist/.setup/{auth-profile-WqZtZfXN.mjs → auth-profile-B0okYl2D.mjs} +1 -2
- package/dist/.setup/auth-profile-health-oHizqgye.mjs +53 -0
- package/dist/.setup/auth-profile-recovery-BREezV0L.mjs +14 -0
- package/dist/.setup/auth-start-options-BPIPeEX8.mjs +44 -0
- package/dist/.setup/{binding-connection-Bm38niE8.mjs → binding-connection-DTtN1KrX.mjs} +2 -2
- package/dist/.setup/{binding-connection.runtime-CnRMC0ta.mjs → binding-connection.runtime-6TpgD1M6.mjs} +5 -5
- package/dist/.setup/{bounded-turn-BtlZcivC.mjs → bounded-turn-CbjoN2OW.mjs} +140 -37
- package/dist/.setup/bounded-turn-isolation-B8K_ylqk.mjs +14 -0
- package/dist/.setup/{build-state-Xx9ybZqa.mjs → build-state-Da1_z0kd.mjs} +1 -1
- package/dist/.setup/{capabilities-_vXcZGSx.mjs → capabilities-B3WEZl4e.mjs} +2 -10
- package/dist/.setup/{client-vXs2929Q.mjs → client-N0JpgSzF.mjs} +635 -872
- package/dist/.setup/client-catalog-response-5HHLdcde.mjs +285 -0
- package/dist/.setup/{command-dispatch-naHIZwwF.mjs → command-dispatch-BeAoaovI.mjs} +9 -8
- package/dist/.setup/{command-formatters-CGEkdawF.mjs → command-formatters-R3ckE3Co.mjs} +36 -64
- package/dist/.setup/{command-handlers-BtAJEW1X.mjs → command-handlers-ylTMS00z.mjs} +301 -488
- package/dist/.setup/{command-rpc-DHFpn4le.mjs → command-rpc-CGJGUQ6Y.mjs} +40 -28
- package/dist/.setup/compact-C2WamavS.mjs +776 -0
- package/dist/.setup/{config-CedDWjM-.mjs → config-DKhXquav.mjs} +26 -28
- package/dist/.setup/{config-options-BsanJ8QG.mjs → config-options-CzyWLTJt.mjs} +68 -65
- package/dist/.setup/{config-parsing-CcB9iPoq.mjs → config-parsing-b088LyhT.mjs} +57 -60
- package/dist/.setup/{config-runtime-CeAhl_h4.mjs → config-runtime-C0NbLms1.mjs} +2 -2
- package/dist/.setup/{config-security-BRQ2mgW9.mjs → config-security-CE-FcGw9.mjs} +51 -215
- package/dist/.setup/{config-utils-DujwEnhg.mjs → config-utils-D0CXecki.mjs} +3 -13
- package/dist/.setup/context-engine-projection-PezSESth.mjs +387 -0
- package/dist/.setup/{conversation-binding-DhzrpTM6.mjs → conversation-binding-3Min8qvP.mjs} +71 -105
- package/dist/.setup/{conversation-binding-data-CrcyZk6O.mjs → conversation-binding-data-C746z5Pn.mjs} +8 -12
- package/dist/.setup/{conversation-control-DN53ns41.mjs → conversation-control-CEP8X5JC.mjs} +30 -69
- package/dist/.setup/{cyber-failover-DYwbmf1o.mjs → cyber-failover-XV0nNRZu.mjs} +1 -1
- package/dist/.setup/{cyber-failover-notice-e9G3J9-e.mjs → cyber-failover-notice-RNpGpTyP.mjs} +1 -1
- package/dist/.setup/{dynamic-tools-D16lOp67.mjs → dynamic-tools-DzlsLUuS.mjs} +3136 -3167
- package/dist/.setup/{effective-mcp-catalog-K6kLCN8X.mjs → effective-mcp-catalog-CxUtC-xG.mjs} +8 -17
- package/dist/.setup/{ephemeral-turn-R1gA8Sn6.mjs → ephemeral-turn-CDsPJOa2.mjs} +9 -6
- package/dist/.setup/event-projector-assistant-message-CigreO4K.mjs +69 -0
- package/dist/.setup/{event-projector-usage-C7Ntzs-f.mjs → event-projector-usage-03R0I2dM.mjs} +4 -26
- package/dist/.setup/event-projector-values-DJSz8BTk.mjs +106 -0
- package/dist/.setup/incognito-session-DWYapfwf.mjs +2 -0
- package/dist/.setup/{inference-context-fulhZuz8.mjs → inference-context-D-9gWlTR.mjs} +16 -18
- package/dist/.setup/inference-dispatch-CMZtjQyz.mjs +359 -0
- package/dist/.setup/inference-metadata-CgIf7sOx.mjs +81 -0
- package/dist/.setup/inference-proxy-DhcXOgUE.mjs +561 -0
- package/dist/.setup/{isolated-completion-B6srt48J.mjs → isolated-completion-Dm3PzxJk.mjs} +15 -11
- package/dist/.setup/launch-args-DbFCehO7.mjs +196 -0
- package/dist/.setup/{managed-binary-DP6Rib3P.mjs → managed-binary-kiWRhNRE.mjs} +16 -9
- package/dist/.setup/{model-catalog-DkvUuBey.mjs → model-catalog-PAuZgJC6.mjs} +14 -14
- package/dist/.setup/model-runtime-BdqzOMkU.mjs +11 -0
- package/dist/.setup/{models-BDFgm_G-.mjs → models-DHXZtVVk.mjs} +9 -18
- package/dist/.setup/{native-auth-BLZGqFjw.mjs → native-auth-CuG53tu4.mjs} +5 -5
- package/dist/.setup/{native-execution-policy-YBMHSzC4.mjs → native-execution-policy-BxZJy5mP.mjs} +6 -31
- package/dist/.setup/{native-subagent-monitor-B1hxzIOy.mjs → native-subagent-monitor-Dpsmf2wz.mjs} +4422 -3808
- package/dist/.setup/native-subagent-pending-assignments-DwkCzLvD.mjs +203 -0
- package/dist/.setup/native-task-assignments-DMQ0g3hu.mjs +194 -0
- package/dist/.setup/{node-cli-sessions-Cl8b2ZF3.mjs → node-cli-sessions-HC4W6FLI.mjs} +99 -111
- package/dist/.setup/node-exec-server.runtime-BgBfWQqo.mjs +244 -0
- package/dist/.setup/{plan-xD7WKYTM.mjs → plan-Y-QIvrKB.mjs} +118 -163
- package/dist/.setup/{plugin-activation-r8nq5Jzp.mjs → plugin-activation-cNHRfaxU.mjs} +10 -47
- package/dist/.setup/{plugin-app-cache-key-BOxKP7db.mjs → plugin-app-cache-key-BL9B5H0L.mjs} +9 -42
- package/dist/.setup/{plugin-inventory-DUle8DLz.mjs → plugin-inventory-Cky2XJUw.mjs} +32 -23
- package/dist/.setup/{plugin-marketplace-discovery-P-Vndfqq.mjs → plugin-marketplace-discovery-D_dV9FXa.mjs} +22 -25
- package/dist/.setup/{plugin-metadata-cache-DsS5buNa.mjs → plugin-metadata-cache-DsjsL1dr.mjs} +328 -318
- package/dist/.setup/protocol-CANUwXJ3.mjs +17 -0
- package/dist/.setup/provider-DH8NSzGt.mjs +51 -0
- package/dist/.setup/{provider-capabilities-B8J4Dy-O.mjs → provider-capabilities-CAxoF-X1.mjs} +35 -12
- package/dist/.setup/{rate-limits-DOEGYRNs.mjs → rate-limits-B7-X2TgG.mjs} +123 -166
- package/dist/.setup/{request-BioXJLYa.mjs → request-BHZ1nz8d.mjs} +25 -16
- package/dist/.setup/responses-oauth-twnuTaAa.mjs +93 -0
- package/dist/.setup/rpc-error-BlD2vuzn.mjs +31 -0
- package/dist/.setup/{run-attempt-rlA07pUv.mjs → run-attempt-D8RZUOzY.mjs} +2046 -1454
- package/dist/.setup/{run-attempt-lifecycle-B7JbY4-F.mjs → run-attempt-lifecycle-C-6O3Exn.mjs} +10 -24
- package/dist/.setup/{runtime-artifact-Dy38Z5iU.mjs → runtime-artifact-DDQ-HGXf.mjs} +43 -47
- package/dist/.setup/runtime-artifact-connection-D68qQn1m.mjs +78 -0
- package/dist/.setup/sandbox-guard-DjCz2eOw.mjs +126 -0
- package/dist/.setup/scope-DOC1Xjc8.mjs +6 -0
- package/dist/.setup/session-binding-DGCYAfvD.mjs +443 -0
- package/dist/.setup/{session-binding-record-TH3xA0zj.mjs → session-binding-record-Oe9L-CNY.mjs} +73 -132
- package/dist/.setup/{session-binding-sidecars-CKYEcfNn.mjs → session-binding-sidecars-jo6H8dFr.mjs} +242 -60
- package/dist/.setup/{session-catalog-fUdWDx-U.mjs → session-catalog-4sCdv5qx.mjs} +598 -452
- package/dist/.setup/{session-catalog-adoption-CR_whkEW.mjs → session-catalog-adoption-BU_pHWG7.mjs} +59 -26
- package/dist/.setup/{session-catalog-archive-CwZaPacf.mjs → session-catalog-archive-spHfihri.mjs} +7 -7
- package/dist/.setup/session-catalog-events-DePDzzjc.mjs +139 -0
- package/dist/.setup/session-catalog-home-id-vlih0B_g.mjs +22 -0
- package/dist/.setup/{session-catalog-index-B141u15s.mjs → session-catalog-index-CZvDzC6z.mjs} +286 -182
- package/dist/.setup/{session-catalog-index-order-Cc5BzlQr.mjs → session-catalog-index-order-BcQpHks3.mjs} +2 -2
- package/dist/.setup/{session-catalog-index-state-BAuDztHN.mjs → session-catalog-index-state-TeO7EyO-.mjs} +6 -2
- package/dist/.setup/session-catalog-limits-DDxOsQeC.mjs +14 -0
- package/dist/.setup/session-catalog-list-request-CvtxrYSe.mjs +170 -0
- package/dist/.setup/session-catalog-native-projection-DjhwGL6x.mjs +178 -0
- package/dist/.setup/{session-catalog-node-adoption-BVRsYOSh.mjs → session-catalog-node-adoption-DgXvSGu0.mjs} +30 -35
- package/dist/.setup/{session-catalog-node-continue-Dowv8osw.mjs → session-catalog-node-continue-DjKXHBbi.mjs} +25 -18
- package/dist/.setup/session-catalog-node-lookup-CtAXI5W5.mjs +56 -0
- package/dist/.setup/{session-catalog-native-projection-ChV3cCtm.mjs → session-catalog-parsing-CPGaPYr-.mjs} +14 -180
- package/dist/.setup/{session-catalog-projection-C1Bj9Jl-.mjs → session-catalog-projection-Cr5qP5Dj.mjs} +15 -5
- package/dist/.setup/session-catalog-provenance-DoAvktcj.mjs +95 -0
- package/dist/.setup/{session-cli-DIj-IE-E.mjs → session-cli-Cn_nCqfq.mjs} +11 -24
- package/dist/.setup/{session-history-C--SrLI8.mjs → session-history-D83lJWHG.mjs} +16 -23
- package/dist/.setup/{session-history-import-JHXT5Xfi.mjs → session-history-import-WhX-X33a.mjs} +7 -10
- package/dist/.setup/session-history-read-Ov3StuL4.mjs +133 -0
- package/dist/.setup/{session-history.worker-CpNj7H_P.mjs → session-history.worker-MnPKncqP.mjs} +14 -23
- package/dist/.setup/session-initialization-6aveB9qb.mjs +22 -0
- package/dist/.setup/{session-permission-policy-DhurXY0l.mjs → session-permission-policy-Ci_fVX6y.mjs} +4 -8
- package/dist/.setup/{session-retirement-CU87AOg9.mjs → session-retirement-qMTxkNx2.mjs} +31 -12
- package/dist/.setup/{settled-turn-context-fmwouT5I.mjs → settled-turn-context-D4yj4rxf.mjs} +1 -1
- package/dist/.setup/{settled-turn-finalizer-CiY2bLFK.mjs → settled-turn-finalizer-BsvEabkw.mjs} +17 -13
- package/dist/.setup/{shared-client-BpTtuLQ5.mjs → shared-client-DqyTMYug.mjs} +826 -485
- package/dist/.setup/shared-client-lifecycle-DJIgqgMw.mjs +153 -0
- package/dist/.setup/{side-question-DSCZyoBD.mjs → side-question-C4kCmQy1.mjs} +206 -334
- package/dist/.setup/{source-Bjp4UQij.mjs → source-CS_7GFJZ.mjs} +82 -139
- package/dist/.setup/spawn-error-CL3n6MAa.mjs +57 -0
- package/dist/.setup/{thread-archive-guard-jmecf6OJ.mjs → thread-archive-guard-C9frICzX.mjs} +10 -3
- package/dist/.setup/thread-lifecycle-DPflntEJ.mjs +2362 -0
- package/dist/.setup/{incognito-session-uhrBF6wJ.mjs → thread-ownership-queue-Dp24d7-F.mjs} +1 -2
- package/dist/.setup/{thread-ownership-skomxnIt.mjs → thread-ownership-roNP0l1c.mjs} +47 -10
- package/dist/.setup/thread-policy-DTd-DtkX.mjs +109 -0
- package/dist/.setup/thread-requests-B_bRnMGN.mjs +2102 -0
- package/dist/.setup/{thread-resume-BkNpj9Pz.mjs → thread-resume-CdDaoc7T.mjs} +6 -6
- package/dist/.setup/timeout-CXOfNoaX.mjs +46 -0
- package/dist/.setup/transcript-history-projection-DRSifI-1.mjs +201 -0
- package/dist/.setup/{transcript-mirror-attestation-CzM-94NC.mjs → transcript-mirror-attestation-YSegaktH.mjs} +3 -4
- package/dist/.setup/{transcript-mirror-D4qp_leP.mjs → transcript-mirror-kxmCYsuF.mjs} +224 -206
- package/dist/.setup/{transport-stdio-Cmx94Oiy.mjs → transport-stdio-Bdegpn2V.mjs} +138 -75
- package/dist/.setup/transport-websocket-BTBE-LD9.mjs +211 -0
- package/dist/.setup/{upstream-prompt-provenance-LphB8slG.mjs → upstream-prompt-provenance-fXkKbPVC.mjs} +3 -9
- package/dist/.setup/{upstream-session-fork-D3UKxgVD.mjs → upstream-session-fork-CBeVjBpT.mjs} +48 -40
- package/dist/.setup/{usage-BOgBEKso.mjs → usage-BMzNxeR_.mjs} +5 -4
- package/dist/.setup/{usage-limit-error-C0ow7DOc.mjs → usage-limit-error-QXerDo3i.mjs} +5 -20
- package/dist/.setup/{web-search-provider.runtime-CTGuJt6i.mjs → web-search-provider.runtime-P77OUeoo.mjs} +10 -20
- package/dist/api.js +25 -16
- package/dist/catalog-page-worker-entrypoint.js +12 -0
- package/dist/catalog-page.worker.js +9 -0
- package/dist/cli-metadata.js +1 -1
- package/dist/doctor-contract-api.js +50 -8
- package/dist/harness.js +344 -1
- package/dist/index.js +345 -346
- package/dist/media-understanding-provider.js +9 -22
- package/dist/migration-provider-api.js +1 -1
- package/dist/provider-discovery.js +1 -1
- package/dist/session-history-worker-runtime.js +16 -33
- package/dist/session-history.worker.js +1 -1
- package/openclaw.plugin.json +14 -2
- package/package.json +11 -7
- package/dist/.setup/attempt-context-VXVwTCfS.mjs +0 -636
- package/dist/.setup/compact-C3i3qlzj.mjs +0 -687
- package/dist/.setup/event-projector-assistant-message-DNUR1s0A.mjs +0 -105
- package/dist/.setup/event-projector-items-DyTQ_XqL.mjs +0 -200
- package/dist/.setup/harness-rxaaoN-o.mjs +0 -349
- package/dist/.setup/history-rejection-B4nOXNXF.mjs +0 -13
- package/dist/.setup/image-payload-sanitizer-tupAr-2o.mjs +0 -79
- package/dist/.setup/inference-proxy-CC15HuSi.mjs +0 -311
- package/dist/.setup/launch-args-DnMak49W.mjs +0 -111
- package/dist/.setup/local-runtime-attribution-B_2mnqhb.mjs +0 -19
- package/dist/.setup/native-subagent-history-YXaL6dMd.mjs +0 -135
- package/dist/.setup/native-subagent-task-ids-DsuOonKv.mjs +0 -411
- package/dist/.setup/node-exec-server.runtime-BaViBKNz.mjs +0 -226
- package/dist/.setup/plugin-approval-roundtrip-CjfzafAZ.mjs +0 -122
- package/dist/.setup/provider-fFh_-VR3.mjs +0 -50
- package/dist/.setup/rolldown-runtime-8H4AJuhK.mjs +0 -14
- package/dist/.setup/sandbox-guard-BBP-RbTf.mjs +0 -166
- package/dist/.setup/session-binding-_0W_fHRr.mjs +0 -721
- package/dist/.setup/session-catalog-events-jMcYfQyd.mjs +0 -250
- package/dist/.setup/session-history-read-B3ZfSUbF.mjs +0 -50
- package/dist/.setup/session-initialization-DH1z6fXn.mjs +0 -75
- package/dist/.setup/thread-history-page-BTx-4xsg.mjs +0 -83
- package/dist/.setup/thread-lifecycle-Cik28qWn.mjs +0 -4904
- package/dist/.setup/thread-policy-Cjs4B8xf.mjs +0 -54
- package/dist/.setup/timeout-DZF05XrR.mjs +0 -63
- package/dist/.setup/transcript-history-projection-DHNBDhCU.mjs +0 -243
- package/dist/.setup/version-CoqzXPgK.mjs +0 -12
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
import { i as adoptCodexNativeSubagentSubmissions, n as mutateNativePendingAssignments, o as mutateCodexNativeSubagentSubmissions } from "./native-subagent-pending-assignments-DwkCzLvD.mjs";
|
|
2
|
+
import { _ as readStoredCodexAppServerBinding, a as matchesPendingSupervisionBranch, b as validateBindingForWrite, c as preserveNativePendingAssignments, d as readCodexBindingTimestamp, f as readCurrentCodexAppServerBinding, g as readPluginAppPolicyContext, h as readCurrentNativePendingAssignments, i as matchesCodexNativeSubagentSubmissionBinding, l as preserveNativeTaskImport, m as readCurrentCodexNativeSubagentSubmissions, n as assertCodexBindingMayBeReplaced, o as ownsStoredSessionGeneration, p as readCurrentCodexAppServerBindings, r as bindingStoreKey, s as preserveCodexNativeSubagentSubmissions, t as CodexSupervisionBindingReplacementError, u as readCodexAppServerThreadBinding, v as sessionBindingIdentity, y as stripUndefinedBinding } from "./session-binding-record-Oe9L-CNY.mjs";
|
|
3
|
+
import { n as CODEX_APP_SERVER_BINDING_NAMESPACE, t as CODEX_APP_SERVER_BINDING_MAX_ENTRIES } from "./session-binding-meta-B7aEMU7g.mjs";
|
|
4
|
+
import { n as normalizeCodexAppServerBindingModelProvider } from "./auth-profile-B0okYl2D.mjs";
|
|
5
|
+
import { t as __exportAll } from "./session-binding-sidecars-jo6H8dFr.mjs";
|
|
6
|
+
import { asOptionalRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
7
|
+
import { createHash } from "node:crypto";
|
|
8
|
+
import { AgentHarnessSessionSupersededError, embeddedAgentLog } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
9
|
+
import { captureNativeSessionGenerationAuthority, createNativeSessionBindingLifecycle, reclaimNativeSessionGeneration, resolveNativeSessionBinding } from "openclaw/plugin-sdk/agent-harness-session-runtime";
|
|
10
|
+
//#region extensions/codex/src/app-server/session-binding-native-mutations.ts
|
|
11
|
+
/** The caller supplies the transaction's freshly parsed row and current-authority closure. */
|
|
12
|
+
function mutateNativeSubagentBinding({ identity, current, mutation, assertCurrent }) {
|
|
13
|
+
if (mutation.kind === "record-native-subagent-assignment" || mutation.kind === "consume-native-subagent-assignment") {
|
|
14
|
+
if (!assertCurrent) throw new Error("Codex native assignment mutation requires current authority.");
|
|
15
|
+
assertCurrent();
|
|
16
|
+
if (current?.state !== "active" || !ownsStoredSessionGeneration(identity, current) || identity.kind === "session" && mutation.owner.sessionId !== identity.sessionId || !matchesCodexNativeSubagentSubmissionBinding(current.binding, mutation.owner)) return { result: false };
|
|
17
|
+
const changed = mutateNativePendingAssignments({
|
|
18
|
+
current: current.nativeSubagentAssignments,
|
|
19
|
+
owner: mutation.owner,
|
|
20
|
+
assignment: mutation.assignment,
|
|
21
|
+
consume: mutation.kind === "consume-native-subagent-assignment"
|
|
22
|
+
});
|
|
23
|
+
if (!changed.applied) return { result: false };
|
|
24
|
+
const { nativeSubagentAssignments: _previous, ...bindingOwner } = current;
|
|
25
|
+
return {
|
|
26
|
+
result: true,
|
|
27
|
+
next: {
|
|
28
|
+
...bindingOwner,
|
|
29
|
+
...changed.next ? { nativeSubagentAssignments: changed.next } : {}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
if (!assertCurrent) throw new Error("Codex native subagent submission mutation requires current authority.");
|
|
34
|
+
assertCurrent();
|
|
35
|
+
if (current?.state !== "active" || !ownsStoredSessionGeneration(identity, current) || identity.kind === "session" && mutation.owner.sessionId !== identity.sessionId || !matchesCodexNativeSubagentSubmissionBinding(current.binding, mutation.owner)) return { result: false };
|
|
36
|
+
const changed = mutateCodexNativeSubagentSubmissions({
|
|
37
|
+
current: current.nativeSubagentSubmissions,
|
|
38
|
+
owner: mutation.owner,
|
|
39
|
+
receipt: mutation.receipt,
|
|
40
|
+
consume: mutation.kind === "consume-native-subagent-submission"
|
|
41
|
+
});
|
|
42
|
+
if (!changed.applied) return { result: false };
|
|
43
|
+
const { nativeSubagentSubmissions: _previous, ...bindingOwner } = current;
|
|
44
|
+
return {
|
|
45
|
+
result: true,
|
|
46
|
+
next: {
|
|
47
|
+
...bindingOwner,
|
|
48
|
+
...changed.next ? { nativeSubagentSubmissions: changed.next } : {}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region extensions/codex/src/app-server/session-binding.ts
|
|
54
|
+
/** SQLite-backed Codex app-server thread bindings. */
|
|
55
|
+
var session_binding_exports = /* @__PURE__ */ __exportAll({
|
|
56
|
+
CODEX_APP_SERVER_BINDING_GUARDED_REQUEST_TIMEOUT_MS: () => CODEX_APP_SERVER_BINDING_GUARDED_REQUEST_TIMEOUT_MS,
|
|
57
|
+
CODEX_APP_SERVER_BINDING_MAX_ENTRIES: () => CODEX_APP_SERVER_BINDING_MAX_ENTRIES,
|
|
58
|
+
CODEX_APP_SERVER_BINDING_NAMESPACE: () => CODEX_APP_SERVER_BINDING_NAMESPACE,
|
|
59
|
+
CodexSupervisionBindingReplacementError: () => CodexSupervisionBindingReplacementError,
|
|
60
|
+
assertCodexBindingMayBeReplaced: () => assertCodexBindingMayBeReplaced,
|
|
61
|
+
bindingStoreKey: () => bindingStoreKey,
|
|
62
|
+
createCodexAppServerBindingStore: () => createCodexAppServerBindingStore,
|
|
63
|
+
createCodexSessionGenerationSupersededError: () => createCodexSessionGenerationSupersededError,
|
|
64
|
+
createStoredCodexAppServerBinding: () => createStoredCodexAppServerBinding,
|
|
65
|
+
hashCodexAppServerBindingFingerprint: () => hashCodexAppServerBindingFingerprint,
|
|
66
|
+
normalizeStoredCodexAppServerBindingFingerprints: () => normalizeStoredCodexAppServerBindingFingerprints,
|
|
67
|
+
readCodexAppServerThreadBinding: () => readCodexAppServerThreadBinding,
|
|
68
|
+
readStoredCodexAppServerBinding: () => readStoredCodexAppServerBinding,
|
|
69
|
+
reclaimCurrentCodexSessionGeneration: () => reclaimCurrentCodexSessionGeneration,
|
|
70
|
+
resolveCodexRunSessionBindingAuthority: () => resolveCodexRunSessionBindingAuthority,
|
|
71
|
+
resolveCodexSessionBinding: () => resolveCodexSessionBinding,
|
|
72
|
+
sessionBindingIdentity: () => sessionBindingIdentity,
|
|
73
|
+
validateBindingForWrite: () => validateBindingForWrite
|
|
74
|
+
});
|
|
75
|
+
const BINDING_LEASE_RETRY_INTERVAL_MS = 1e3;
|
|
76
|
+
const BOUNDED_BINDING_FINGERPRINT_PATTERN = /^sha256:[a-f0-9]{64}$/i;
|
|
77
|
+
const CODEX_APP_SERVER_BINDING_GUARDED_REQUEST_TIMEOUT_MS = 6e4;
|
|
78
|
+
const BINDING_LEASE_STALE_MS = 65e3;
|
|
79
|
+
const BINDING_LEASE_WAIT_MS = 7e4;
|
|
80
|
+
const BINDING_LEASE_RENEW_INTERVAL_MS = Math.floor(BINDING_LEASE_STALE_MS / 3);
|
|
81
|
+
const PHYSICAL_SESSION_RETIRE_TTL_MS = BINDING_LEASE_WAIT_MS;
|
|
82
|
+
/** Decides whether a run may share the durable stable-key binding owner. */
|
|
83
|
+
function resolveCodexRunSessionBindingAuthority(params) {
|
|
84
|
+
return captureNativeSessionGenerationAuthority({
|
|
85
|
+
...params,
|
|
86
|
+
target: params.identity,
|
|
87
|
+
createSupersededError: createCodexSessionGenerationSupersededError
|
|
88
|
+
}).state;
|
|
89
|
+
}
|
|
90
|
+
/** Builds the terminal coordination error used when a newer OpenClaw session owns the binding. */
|
|
91
|
+
function createCodexSessionGenerationSupersededError(sessionId) {
|
|
92
|
+
return new AgentHarnessSessionSupersededError(`Codex session generation is no longer current: ${sessionId}`);
|
|
93
|
+
}
|
|
94
|
+
function hashCodexAppServerBindingFingerprint(canonical) {
|
|
95
|
+
return `sha256:${createHash("sha256").update(canonical).digest("hex")}`;
|
|
96
|
+
}
|
|
97
|
+
function normalizeLegacyBindingFingerprint(value) {
|
|
98
|
+
if (typeof value !== "string" || value === "" || value === "[]" || BOUNDED_BINDING_FINGERPRINT_PATTERN.test(value)) return value;
|
|
99
|
+
return hashCodexAppServerBindingFingerprint(value);
|
|
100
|
+
}
|
|
101
|
+
function normalizeLegacyBindingFingerprints(record) {
|
|
102
|
+
let normalized = record;
|
|
103
|
+
for (const key of ["dynamicToolsFingerprint", "userMcpServersFingerprint"]) {
|
|
104
|
+
const value = record[key];
|
|
105
|
+
const next = normalizeLegacyBindingFingerprint(value);
|
|
106
|
+
if (next === value) continue;
|
|
107
|
+
if (normalized === record) normalized = { ...record };
|
|
108
|
+
Object.assign(normalized, { [key]: next });
|
|
109
|
+
}
|
|
110
|
+
return normalized;
|
|
111
|
+
}
|
|
112
|
+
function normalizeStoredCodexAppServerBindingFingerprints(value) {
|
|
113
|
+
const stored = readStoredCodexAppServerBinding(value);
|
|
114
|
+
if (!stored || stored.state !== "active") return stored;
|
|
115
|
+
const binding = normalizeLegacyBindingFingerprints(stored.binding);
|
|
116
|
+
return binding === stored.binding ? stored : readStoredCodexAppServerBinding({
|
|
117
|
+
...stored,
|
|
118
|
+
binding
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
/** Encodes a migrated sidecar binding as one canonical plugin-state row. */
|
|
122
|
+
function createStoredCodexAppServerBinding(value, options = {}) {
|
|
123
|
+
const rawRecord = asOptionalRecord(value);
|
|
124
|
+
if (!rawRecord) return;
|
|
125
|
+
const record = normalizeLegacyBindingFingerprints(rawRecord);
|
|
126
|
+
if (record.schemaVersion !== 1 && record.schemaVersion !== 2) return;
|
|
127
|
+
const pluginAppPolicyContext = readPluginAppPolicyContext(record.pluginAppPolicyContext, record.schemaVersion);
|
|
128
|
+
const historyCoveredThrough = readCodexBindingTimestamp(record.historyCoveredThrough) ?? readCodexBindingTimestamp(record.updatedAt) ?? readCodexBindingTimestamp(record.createdAt) ?? readCodexBindingTimestamp(options.now) ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
129
|
+
const authProfileId = typeof record.authProfileId === "string" ? record.authProfileId : void 0;
|
|
130
|
+
const binding = readCodexAppServerThreadBinding({
|
|
131
|
+
...record,
|
|
132
|
+
modelProvider: normalizeCodexAppServerBindingModelProvider({
|
|
133
|
+
...options.lookup,
|
|
134
|
+
authProfileId,
|
|
135
|
+
modelProvider: typeof record.modelProvider === "string" ? record.modelProvider : void 0
|
|
136
|
+
}),
|
|
137
|
+
cwd: typeof record.cwd === "string" ? record.cwd : "",
|
|
138
|
+
pluginAppPolicyContext,
|
|
139
|
+
historyCoveredThrough
|
|
140
|
+
});
|
|
141
|
+
return binding ? {
|
|
142
|
+
version: 1,
|
|
143
|
+
state: "active",
|
|
144
|
+
binding: stripUndefinedBinding(binding)
|
|
145
|
+
} : void 0;
|
|
146
|
+
}
|
|
147
|
+
function bindingLeaseLostError(key, cause) {
|
|
148
|
+
return new Error(`Lost Codex binding lease: ${key}`, cause === void 0 ? void 0 : { cause });
|
|
149
|
+
}
|
|
150
|
+
/** Lets the authoritative OpenClaw session generation claim a stale stable binding row. */
|
|
151
|
+
async function reclaimCurrentCodexSessionGeneration(params) {
|
|
152
|
+
return await reclaimNativeSessionGeneration({
|
|
153
|
+
...params,
|
|
154
|
+
target: params.identity,
|
|
155
|
+
generation: codexSessionGenerationOperations(params.bindingStore, params.identity),
|
|
156
|
+
createSupersededError: createCodexSessionGenerationSupersededError
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
/** Resolve continuity before selecting native queues, catalogs, or connections. */
|
|
160
|
+
async function resolveCodexSessionBinding(params) {
|
|
161
|
+
const identity = params.identity;
|
|
162
|
+
return await resolveNativeSessionBinding({
|
|
163
|
+
...params,
|
|
164
|
+
...identity.kind === "session" ? {
|
|
165
|
+
target: identity,
|
|
166
|
+
generation: codexSessionGenerationOperations(params.bindingStore, identity)
|
|
167
|
+
} : {},
|
|
168
|
+
readBinding: (sessionId) => params.bindingStore.read(sessionId && identity.kind === "session" ? {
|
|
169
|
+
...identity,
|
|
170
|
+
sessionId
|
|
171
|
+
} : identity),
|
|
172
|
+
createSupersededError: createCodexSessionGenerationSupersededError
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
/** Creates the single binding facade owned by the Codex plugin runtime. */
|
|
176
|
+
function createCodexAppServerBindingStore(state) {
|
|
177
|
+
const lifecycle = createNativeSessionBindingLifecycle(state, {
|
|
178
|
+
readRecord: readStoredCodexAppServerBinding,
|
|
179
|
+
lease: {
|
|
180
|
+
staleMs: BINDING_LEASE_STALE_MS,
|
|
181
|
+
waitMs: BINDING_LEASE_WAIT_MS,
|
|
182
|
+
retryIntervalMs: BINDING_LEASE_RETRY_INTERVAL_MS,
|
|
183
|
+
renewIntervalMs: BINDING_LEASE_RENEW_INTERVAL_MS
|
|
184
|
+
},
|
|
185
|
+
releaseTtlMs: (key, current) => current.nativeSubagentTaskImport !== void 0 || current.state === "active" || current.retired === true && !key.startsWith("session:") ? void 0 : current.retired === true ? PHYSICAL_SESSION_RETIRE_TTL_MS : 1,
|
|
186
|
+
onReleaseFailure: (key, error) => embeddedAgentLog.warn("failed to release codex app-server binding lease", {
|
|
187
|
+
key,
|
|
188
|
+
error
|
|
189
|
+
}),
|
|
190
|
+
errors: {
|
|
191
|
+
atomicUpdatesRequired: "Codex app-server bindings require atomic plugin-state updates",
|
|
192
|
+
invalidRow: (key) => /* @__PURE__ */ new Error(`Invalid Codex app-server binding row: ${key}`),
|
|
193
|
+
lostLease: bindingLeaseLostError,
|
|
194
|
+
leaseTimeout: (key) => /* @__PURE__ */ new Error(`Timed out waiting for Codex binding lease: ${key}`),
|
|
195
|
+
acquisitionRejected: (key) => /* @__PURE__ */ new Error(`Codex binding generation was retired: ${key}`),
|
|
196
|
+
mutationBlocked: "Codex binding mutation blocked while a native archive is in progress; retry",
|
|
197
|
+
conditionalDeletionRequired: "Codex session deletion requires conditional plugin-state deletion",
|
|
198
|
+
deletionChanged: "Codex binding changed before session deletion",
|
|
199
|
+
rollbackChanged: "Codex binding changed before session deletion rollback"
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
const prepareLease = (identity, options = {}) => ({
|
|
203
|
+
assertCurrent: options.assertCurrent,
|
|
204
|
+
prepareLease(current, lease) {
|
|
205
|
+
if (current?.state === "cleared" && current.retired === true && ownsStoredSessionGeneration(identity, current) && !options.allowRetired) return;
|
|
206
|
+
if (current?.state === "active") return {
|
|
207
|
+
...current,
|
|
208
|
+
...preservedSessionGeneration(identity, current),
|
|
209
|
+
lease
|
|
210
|
+
};
|
|
211
|
+
if (current?.state === "cleared" && current.retired === true) return {
|
|
212
|
+
...current,
|
|
213
|
+
lease
|
|
214
|
+
};
|
|
215
|
+
return {
|
|
216
|
+
version: 1,
|
|
217
|
+
state: "cleared",
|
|
218
|
+
...preservedSessionGeneration(identity, current),
|
|
219
|
+
...preserveNativeTaskImport(current),
|
|
220
|
+
lease
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
const transitionSessionGeneration = async (identity, mode) => {
|
|
225
|
+
return await lifecycle.withMutation(async () => {
|
|
226
|
+
const key = bindingStoreKey(identity);
|
|
227
|
+
const ttlMs = mode === "reset" ? lifecycle.hasLease(key) ? void 0 : 1 : identity.sessionKey?.trim() ? void 0 : PHYSICAL_SESSION_RETIRE_TTL_MS;
|
|
228
|
+
return await lifecycle.transact(key, (current, leaseToken) => {
|
|
229
|
+
if (!current) return { result: "absent" };
|
|
230
|
+
if (!ownsStoredSessionGeneration(identity, current)) return { result: "conflict" };
|
|
231
|
+
if (current.state === "cleared" && current.retired === true) return { result: mode === "retire" ? "applied" : "conflict" };
|
|
232
|
+
return {
|
|
233
|
+
result: "applied",
|
|
234
|
+
next: {
|
|
235
|
+
version: 1,
|
|
236
|
+
state: "cleared",
|
|
237
|
+
...mode === "retire" ? { retired: true } : {},
|
|
238
|
+
...storedSessionGeneration(identity, current),
|
|
239
|
+
...preserveNativeTaskImport(current),
|
|
240
|
+
...current.lease && current.lease.token === leaseToken ? { lease: current.lease } : {}
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
}, (next) => next.nativeSubagentTaskImport !== void 0 ? void 0 : ttlMs);
|
|
244
|
+
});
|
|
245
|
+
};
|
|
246
|
+
return {
|
|
247
|
+
read: (identity) => readCurrentCodexAppServerBinding(state, identity),
|
|
248
|
+
...state.lookupMany ? { readMany: (identities) => readCurrentCodexAppServerBindings(state, identities) } : {},
|
|
249
|
+
readNativeSubagentAssignments: (identity, owner) => readCurrentNativePendingAssignments(state, identity, owner),
|
|
250
|
+
readNativeSubagentSubmissions: (identity, owner) => readCurrentCodexNativeSubagentSubmissions(state, identity, owner),
|
|
251
|
+
async hasOtherThreadOwner(threadId, currentIdentity) {
|
|
252
|
+
const currentKey = currentIdentity ? bindingStoreKey(currentIdentity) : void 0;
|
|
253
|
+
return state.entries().some(({ key, value }) => {
|
|
254
|
+
const stored = readStoredCodexAppServerBinding(value);
|
|
255
|
+
if (!stored) throw new Error(`Invalid Codex app-server binding row: ${key}`);
|
|
256
|
+
const isCurrentOwner = currentIdentity !== void 0 && key === currentKey && (currentIdentity.kind === "conversation" || stored.sessionId === currentIdentity.sessionId.trim());
|
|
257
|
+
return stored.state === "active" && stored.binding.threadId === threadId && !isCurrentOwner;
|
|
258
|
+
});
|
|
259
|
+
},
|
|
260
|
+
async prepareSessionGenerationReclaim(identity) {
|
|
261
|
+
const key = bindingStoreKey(identity);
|
|
262
|
+
const raw = state.lookup(key);
|
|
263
|
+
const current = readStoredCodexAppServerBinding(raw);
|
|
264
|
+
if (raw !== void 0 && !current) throw new Error(`Invalid Codex app-server binding row: ${key}`);
|
|
265
|
+
if (!current) return {
|
|
266
|
+
kind: "resolved",
|
|
267
|
+
result: true
|
|
268
|
+
};
|
|
269
|
+
const currentSessionId = current.sessionId;
|
|
270
|
+
if (!currentSessionId) return {
|
|
271
|
+
kind: "resolved",
|
|
272
|
+
result: current.state !== "cleared" || current.retired !== true
|
|
273
|
+
};
|
|
274
|
+
if (currentSessionId === identity.sessionId) return current.state === "cleared" && current.retired === true ? {
|
|
275
|
+
kind: "verify",
|
|
276
|
+
expectedPreviousSessionId: currentSessionId
|
|
277
|
+
} : {
|
|
278
|
+
kind: "resolved",
|
|
279
|
+
result: true
|
|
280
|
+
};
|
|
281
|
+
return {
|
|
282
|
+
kind: "verify",
|
|
283
|
+
expectedPreviousSessionId: currentSessionId
|
|
284
|
+
};
|
|
285
|
+
},
|
|
286
|
+
async mutate(identity, mutation, assertCurrent) {
|
|
287
|
+
return await lifecycle.withMutation(async () => {
|
|
288
|
+
const key = bindingStoreKey(identity);
|
|
289
|
+
const retainLegacyClear = mutation.kind === "clear" && key.startsWith("conversation:legacy-");
|
|
290
|
+
return await lifecycle.transact(key, (current, leaseToken) => {
|
|
291
|
+
if (mutation.kind === "record-native-subagent-assignment" || mutation.kind === "consume-native-subagent-assignment" || mutation.kind === "record-native-subagent-submission" || mutation.kind === "consume-native-subagent-submission") return mutateNativeSubagentBinding({
|
|
292
|
+
identity,
|
|
293
|
+
current,
|
|
294
|
+
mutation,
|
|
295
|
+
assertCurrent
|
|
296
|
+
});
|
|
297
|
+
const ownsGeneration = ownsStoredSessionGeneration(identity, current);
|
|
298
|
+
const ownedLease = current?.lease && current.lease.token === leaseToken ? { lease: current.lease } : {};
|
|
299
|
+
if (mutation.kind === "reclaim-generation") {
|
|
300
|
+
if (identity.kind !== "session" || !identity.sessionKey?.trim()) return { result: false };
|
|
301
|
+
if (!current) return { result: true };
|
|
302
|
+
if (ownsGeneration) {
|
|
303
|
+
if (current.state === "cleared" && current.retired === true && current.sessionId === mutation.expectedPreviousSessionId) return {
|
|
304
|
+
result: true,
|
|
305
|
+
next: {
|
|
306
|
+
version: 1,
|
|
307
|
+
state: "cleared",
|
|
308
|
+
sessionId: identity.sessionId,
|
|
309
|
+
...preserveNativeTaskImport(current),
|
|
310
|
+
...ownedLease
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
return { result: current.state !== "cleared" || current.retired !== true };
|
|
314
|
+
}
|
|
315
|
+
if (current.sessionId !== mutation.expectedPreviousSessionId) return { result: false };
|
|
316
|
+
if (current.state === "active" && current.binding.connectionScope === "supervision") return { result: false };
|
|
317
|
+
return {
|
|
318
|
+
result: true,
|
|
319
|
+
next: {
|
|
320
|
+
version: 1,
|
|
321
|
+
state: "cleared",
|
|
322
|
+
sessionId: identity.sessionId,
|
|
323
|
+
...preserveNativeTaskImport(current),
|
|
324
|
+
...ownedLease
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
const storedActive = current?.state === "active" ? current : void 0;
|
|
329
|
+
const active = ownsGeneration ? storedActive : void 0;
|
|
330
|
+
const retiredGeneration = current?.state === "cleared" && current.retired === true && ownsGeneration;
|
|
331
|
+
const preservesSupervisionOwner = mutation.kind === "set" && active?.binding.connectionScope === "supervision" && isSameSupervisionOwner(active.binding, mutation.binding);
|
|
332
|
+
const replacesExpectedOrdinaryOwner = mutation.kind === "replace-thread" && active?.binding.threadId === mutation.expectedThreadId && active.binding.connectionScope !== "supervision" && mutation.binding.connectionScope !== "supervision" && mutation.binding.threadId !== mutation.expectedThreadId;
|
|
333
|
+
if (mutation.kind === "set" && (mutation.if?.kind === "absent" && storedActive || current !== void 0 && !ownsGeneration || retiredGeneration || active?.binding.connectionScope === "supervision" && !preservesSupervisionOwner) || mutation.kind === "patch" && active?.binding.threadId !== mutation.threadId || mutation.kind === "replace-thread" && !replacesExpectedOrdinaryOwner || (mutation.kind === "patch-pending-supervision-branch" || mutation.kind === "commit-pending-supervision-branch") && !matchesPendingSupervisionBranch(active?.binding, mutation.expected) || mutation.kind === "clear" && (!ownsGeneration || mutation.threadId !== void 0 && active?.binding.threadId !== mutation.threadId || active?.binding.connectionScope === "supervision")) return { result: false };
|
|
334
|
+
if (mutation.kind === "clear" && retiredGeneration) return { result: true };
|
|
335
|
+
if (mutation.kind === "clear") return {
|
|
336
|
+
result: true,
|
|
337
|
+
next: {
|
|
338
|
+
version: 1,
|
|
339
|
+
state: "cleared",
|
|
340
|
+
...storedSessionGeneration(identity, current),
|
|
341
|
+
...preserveNativeTaskImport(current),
|
|
342
|
+
...ownedLease
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
let binding;
|
|
346
|
+
if (mutation.kind === "set" || mutation.kind === "replace-thread") binding = validateBindingForWrite(mutation.binding);
|
|
347
|
+
else if (mutation.kind === "patch-pending-supervision-branch") binding = validateBindingForWrite({
|
|
348
|
+
...active.binding,
|
|
349
|
+
pendingSupervisionBranch: mutation.pending
|
|
350
|
+
});
|
|
351
|
+
else if (mutation.kind === "commit-pending-supervision-branch") binding = validateBindingForWrite({
|
|
352
|
+
...active.binding,
|
|
353
|
+
...mutation.patch,
|
|
354
|
+
threadId: mutation.threadId,
|
|
355
|
+
pendingSupervisionBranch: void 0
|
|
356
|
+
});
|
|
357
|
+
else binding = validateBindingForWrite({
|
|
358
|
+
...active.binding,
|
|
359
|
+
...mutation.patch,
|
|
360
|
+
threadId: mutation.threadId
|
|
361
|
+
});
|
|
362
|
+
const nativeSubagentSubmissions = active ? preserveCodexNativeSubagentSubmissions(active.binding, binding, active.nativeSubagentSubmissions) : void 0;
|
|
363
|
+
const nativeSubagentAssignments = active ? preserveNativePendingAssignments(active.binding, binding, active.nativeSubagentAssignments) : void 0;
|
|
364
|
+
return {
|
|
365
|
+
result: true,
|
|
366
|
+
next: {
|
|
367
|
+
version: 1,
|
|
368
|
+
state: "active",
|
|
369
|
+
binding,
|
|
370
|
+
...nativeSubagentAssignments !== void 0 ? { nativeSubagentAssignments } : {},
|
|
371
|
+
...nativeSubagentSubmissions !== void 0 ? { nativeSubagentSubmissions } : {},
|
|
372
|
+
...storedSessionGeneration(identity, current),
|
|
373
|
+
...preserveNativeTaskImport(current),
|
|
374
|
+
...ownedLease
|
|
375
|
+
}
|
|
376
|
+
};
|
|
377
|
+
}, (next) => mutation.kind === "clear" && next.nativeSubagentTaskImport === void 0 && !retainLegacyClear && !lifecycle.hasLease(key) ? 1 : void 0, assertCurrent);
|
|
378
|
+
});
|
|
379
|
+
},
|
|
380
|
+
async adoptSessionGeneration(identity, expectedPreviousSessionId, assertCurrent) {
|
|
381
|
+
return await lifecycle.withMutation(async () => {
|
|
382
|
+
const key = bindingStoreKey(identity);
|
|
383
|
+
const expectedSessionId = expectedPreviousSessionId.trim();
|
|
384
|
+
const targetSessionId = identity.sessionId.trim();
|
|
385
|
+
if (!expectedSessionId) throw new Error("Codex session generation adoption requires the previous session id");
|
|
386
|
+
return await lifecycle.transact(key, (current) => {
|
|
387
|
+
if (current?.state !== "active") return { result: "absent" };
|
|
388
|
+
if (current.sessionId === targetSessionId) return { result: "current" };
|
|
389
|
+
if (current.sessionId !== expectedSessionId) return { result: "conflict" };
|
|
390
|
+
const { nativeSubagentSubmissions, nativeSubagentAssignments: _assignments, ...bindingOwner } = current;
|
|
391
|
+
const adoptedSubmissions = adoptCodexNativeSubagentSubmissions(nativeSubagentSubmissions);
|
|
392
|
+
return {
|
|
393
|
+
result: "adopted",
|
|
394
|
+
next: {
|
|
395
|
+
...bindingOwner,
|
|
396
|
+
sessionId: targetSessionId,
|
|
397
|
+
...adoptedSubmissions !== void 0 ? { nativeSubagentSubmissions: adoptedSubmissions } : {}
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
}, void 0, assertCurrent);
|
|
401
|
+
});
|
|
402
|
+
},
|
|
403
|
+
resetSessionGeneration: (identity) => transitionSessionGeneration(identity, "reset"),
|
|
404
|
+
retireSessionGeneration: (identity) => transitionSessionGeneration(identity, "retire"),
|
|
405
|
+
withThreadArchiveFence: lifecycle.withExclusiveMutationFence,
|
|
406
|
+
async withSessionDeletion(identity, assertCurrent, run) {
|
|
407
|
+
return await lifecycle.withDeletion(bindingStoreKey(identity), {
|
|
408
|
+
...prepareLease(identity, {
|
|
409
|
+
allowRetired: true,
|
|
410
|
+
assertCurrent
|
|
411
|
+
}),
|
|
412
|
+
assertCurrent,
|
|
413
|
+
assertRecordCurrent(stored) {
|
|
414
|
+
if (!stored || !ownsStoredSessionGeneration(identity, stored)) throw new Error("Codex binding generation changed before session deletion");
|
|
415
|
+
}
|
|
416
|
+
}, (stored, mutation) => run(stored?.state === "active" ? stored.binding : void 0, mutation));
|
|
417
|
+
},
|
|
418
|
+
withLease: (identity, run) => lifecycle.withLease(bindingStoreKey(identity), run, prepareLease(identity))
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
function codexSessionGenerationOperations(store, identity) {
|
|
422
|
+
return {
|
|
423
|
+
prepareReclaim: () => store.prepareSessionGenerationReclaim(identity),
|
|
424
|
+
adopt: (expectedPreviousSessionId, assertCurrent) => store.adoptSessionGeneration(identity, expectedPreviousSessionId, assertCurrent),
|
|
425
|
+
reclaim: (expectedPreviousSessionId, assertCurrent) => store.mutate(identity, {
|
|
426
|
+
kind: "reclaim-generation",
|
|
427
|
+
expectedPreviousSessionId
|
|
428
|
+
}, assertCurrent)
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
function isSameSupervisionOwner(current, replacement) {
|
|
432
|
+
return replacement.connectionScope === "supervision" && replacement.threadId === current.threadId && replacement.supervisionSourceThreadId === current.supervisionSourceThreadId;
|
|
433
|
+
}
|
|
434
|
+
function storedSessionGeneration(identity, current) {
|
|
435
|
+
if (identity.kind === "session") return { sessionId: identity.sessionId };
|
|
436
|
+
return current?.sessionId ? { sessionId: current.sessionId } : {};
|
|
437
|
+
}
|
|
438
|
+
function preservedSessionGeneration(identity, current) {
|
|
439
|
+
if (current?.sessionId) return { sessionId: current.sessionId };
|
|
440
|
+
return storedSessionGeneration(identity, current);
|
|
441
|
+
}
|
|
442
|
+
//#endregion
|
|
443
|
+
export { resolveCodexRunSessionBindingAuthority as a, reclaimCurrentCodexSessionGeneration as i, createCodexSessionGenerationSupersededError as n, resolveCodexSessionBinding as o, hashCodexAppServerBindingFingerprint as r, session_binding_exports as s, CODEX_APP_SERVER_BINDING_GUARDED_REQUEST_TIMEOUT_MS as t };
|