@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
package/dist/.setup/{session-binding-record-TH3xA0zj.mjs → session-binding-record-Oe9L-CNY.mjs}
RENAMED
|
@@ -1,115 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { d as CODEX_PLUGIN_MARKETPLACE_NAME_PATTERN, r as normalizeCodexServiceTier } from "./config-utils-D0CXecki.mjs";
|
|
2
|
+
import { a as matchesCodexNativeSubagentSubmissionOwner, h as codexNativeSubagentHistoryConnectionFingerprint, r as readNativePendingAssignments, s as readCodexNativeSubagentSubmissions, t as matchesNativeAssignmentLifecycle } from "./native-subagent-pending-assignments-DwkCzLvD.mjs";
|
|
2
3
|
import { asOptionalRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
3
4
|
import { createHash } from "node:crypto";
|
|
4
5
|
import { isDeepStrictEqual } from "node:util";
|
|
5
6
|
import { AgentHarnessPreflightError } from "openclaw/plugin-sdk/agent-harness-registration";
|
|
6
7
|
import { resolveSessionAgentIdsStrict } from "openclaw/plugin-sdk/agent-scope-runtime";
|
|
7
8
|
import { z } from "zod";
|
|
8
|
-
//#region extensions/codex/src/app-server/native-subagent-history-owner.ts
|
|
9
|
-
const nonBlankString = z.string().refine((value) => Boolean(value.trim()));
|
|
10
|
-
const codexNativeSubagentHistoryOwnerSchema = z.object({
|
|
11
|
-
parentThreadId: nonBlankString,
|
|
12
|
-
sessionId: nonBlankString,
|
|
13
|
-
lifecycleRevision: nonBlankString.optional(),
|
|
14
|
-
connectionFingerprint: z.string().regex(/^[a-f0-9]{64}$/u)
|
|
15
|
-
});
|
|
16
|
-
/** Automatic recovery may follow native rotation only within the same host lifecycle and connection. */
|
|
17
|
-
function matchesCodexNativeSubagentHistoryOwner(stored, current) {
|
|
18
|
-
return stored.connectionFingerprint === current.connectionFingerprint && stored.lifecycleRevision === current.lifecycleRevision && (stored.lifecycleRevision !== void 0 || stored.sessionId === current.sessionId);
|
|
19
|
-
}
|
|
20
|
-
function codexNativeSubagentHistoryConnectionFingerprint(binding) {
|
|
21
|
-
if (!binding.appServerRuntimeFingerprint) return;
|
|
22
|
-
return createHash("sha256").update(JSON.stringify([
|
|
23
|
-
binding.appServerRuntimeFingerprint,
|
|
24
|
-
binding.connectionScope ?? null,
|
|
25
|
-
binding.authProfileId ?? null
|
|
26
|
-
])).digest("hex");
|
|
27
|
-
}
|
|
28
|
-
function createCodexNativeSubagentHistoryOwner(params) {
|
|
29
|
-
const connectionFingerprint = codexNativeSubagentHistoryConnectionFingerprint(params.binding);
|
|
30
|
-
return connectionFingerprint ? {
|
|
31
|
-
parentThreadId: params.parentThreadId,
|
|
32
|
-
sessionId: params.sessionId,
|
|
33
|
-
...params.lifecycleRevision ? { lifecycleRevision: params.lifecycleRevision } : {},
|
|
34
|
-
connectionFingerprint
|
|
35
|
-
} : void 0;
|
|
36
|
-
}
|
|
37
|
-
function readCodexNativeSubagentHistoryOwner(detail) {
|
|
38
|
-
const value = asOptionalRecord(detail)?.nativeHistory;
|
|
39
|
-
if (value === void 0) return;
|
|
40
|
-
const owner = codexNativeSubagentHistoryOwnerSchema.safeParse(value);
|
|
41
|
-
if (!owner.success) throw new Error("Subagent history owner is invalid.");
|
|
42
|
-
const { lifecycleRevision, ...required } = owner.data;
|
|
43
|
-
return lifecycleRevision === void 0 ? required : {
|
|
44
|
-
...required,
|
|
45
|
-
lifecycleRevision
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
function assertHistoryOwnerMatchesRegistration(saved, current, parentThreadId, requireSaved = false) {
|
|
49
|
-
if (requireSaved && !saved) throw new Error("Subagent completion history owner is missing.");
|
|
50
|
-
if (saved && (!current || saved.parentThreadId !== parentThreadId || saved.connectionFingerprint !== current.connectionFingerprint || saved.sessionId !== current.sessionId || saved.lifecycleRevision !== current.lifecycleRevision)) throw new Error("Subagent completion history owner is contradictory.");
|
|
51
|
-
}
|
|
52
|
-
//#endregion
|
|
53
|
-
//#region extensions/codex/src/app-server/native-subagent-submission.ts
|
|
54
|
-
const identifier = z.string().refine((value) => Boolean(value.trim()));
|
|
55
|
-
const submissionSchema = z.object({
|
|
56
|
-
parentTurnId: identifier,
|
|
57
|
-
callId: identifier,
|
|
58
|
-
childThreadId: identifier,
|
|
59
|
-
submissionId: identifier,
|
|
60
|
-
predecessorRunId: identifier,
|
|
61
|
-
predecessorNativeTurnId: identifier
|
|
62
|
-
}).strict();
|
|
63
|
-
const submissionsSchema = z.object({
|
|
64
|
-
version: z.literal(1),
|
|
65
|
-
owner: codexNativeSubagentHistoryOwnerSchema,
|
|
66
|
-
receipts: z.array(submissionSchema)
|
|
67
|
-
}).strict().refine(({ receipts }) => new Set(receipts.map(({ parentTurnId, callId }) => JSON.stringify([parentTurnId, callId]))).size === receipts.length);
|
|
68
|
-
function matchesCodexNativeSubagentSubmissionOwner(stored, current) {
|
|
69
|
-
return stored.parentThreadId === current.parentThreadId && matchesCodexNativeSubagentHistoryOwner(stored, current);
|
|
70
|
-
}
|
|
71
|
-
function readCodexNativeSubagentSubmissions(value) {
|
|
72
|
-
if (value === void 0) return;
|
|
73
|
-
const parsed = submissionsSchema.safeParse(value);
|
|
74
|
-
if (!parsed.success) throw new Error("Invalid Codex native subagent submission metadata.");
|
|
75
|
-
return parsed.data;
|
|
76
|
-
}
|
|
77
|
-
function mutateCodexNativeSubagentSubmissions(params) {
|
|
78
|
-
const current = readCodexNativeSubagentSubmissions(params.current);
|
|
79
|
-
const owner = codexNativeSubagentHistoryOwnerSchema.parse(params.owner);
|
|
80
|
-
const receipt = submissionSchema.parse(params.receipt);
|
|
81
|
-
if (current && !matchesCodexNativeSubagentSubmissionOwner(current.owner, owner)) return { applied: false };
|
|
82
|
-
const receipts = current?.receipts ?? [];
|
|
83
|
-
const existing = receipts.find((entry) => entry.parentTurnId === receipt.parentTurnId && entry.callId === receipt.callId);
|
|
84
|
-
if (existing && !isDeepStrictEqual(existing, receipt)) return { applied: false };
|
|
85
|
-
if (params.consume) {
|
|
86
|
-
if (!current) return { applied: false };
|
|
87
|
-
const remaining = receipts.filter((entry) => entry !== existing);
|
|
88
|
-
return {
|
|
89
|
-
applied: true,
|
|
90
|
-
...remaining.length ? { next: {
|
|
91
|
-
version: 1,
|
|
92
|
-
owner: current.owner,
|
|
93
|
-
receipts: remaining
|
|
94
|
-
} } : {}
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
return {
|
|
98
|
-
applied: true,
|
|
99
|
-
next: {
|
|
100
|
-
version: 1,
|
|
101
|
-
owner: current?.owner ?? owner,
|
|
102
|
-
receipts: existing ? receipts : [...receipts, receipt]
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
/** Physical adoption cannot establish continuity for an unstamped receipt. */
|
|
107
|
-
function adoptCodexNativeSubagentSubmissions(value) {
|
|
108
|
-
if (value === void 0) return;
|
|
109
|
-
const parsed = submissionsSchema.safeParse(value);
|
|
110
|
-
return !parsed.success || parsed.data.owner.lifecycleRevision ? value : void 0;
|
|
111
|
-
}
|
|
112
|
-
//#endregion
|
|
113
9
|
//#region extensions/codex/src/app-server/session-binding-record.ts
|
|
114
10
|
/** Canonical binding codec and synchronous generation-aware reads; no lifecycle or auth loading. */
|
|
115
11
|
/** Resolves the same agent scope OpenClaw uses for transcript/session ownership. */
|
|
@@ -184,6 +80,7 @@ const pluginAppPolicyContextSchema = z.object({
|
|
|
184
80
|
apps: z.record(z.string(), z.union([accountAppPolicyEntrySchema, pluginAppPolicyEntrySchema])),
|
|
185
81
|
pluginAppIds: z.record(z.string(), z.array(z.string())).default({})
|
|
186
82
|
}).strict();
|
|
83
|
+
const legacyAppPolicyEntrySchema = z.union([accountAppPolicyEntrySchema.strip(), pluginAppPolicyEntrySchema.strip()]);
|
|
187
84
|
const threadBindingSchema = z.object({
|
|
188
85
|
threadId: z.string().refine((value) => Boolean(value.trim())),
|
|
189
86
|
clientId: optionalStringSchema,
|
|
@@ -192,7 +89,7 @@ const threadBindingSchema = z.object({
|
|
|
192
89
|
connectionScope: z.literal("supervision").optional(),
|
|
193
90
|
supervisionSourceThreadId: z.string().trim().min(1).optional(),
|
|
194
91
|
authProfileId: optionalStringSchema,
|
|
195
|
-
agentWorkspaceDeveloperInstructions:
|
|
92
|
+
agentWorkspaceDeveloperInstructions: optionalStringSchema,
|
|
196
93
|
model: optionalStringSchema,
|
|
197
94
|
preserveNativeModel: z.literal(true).optional().catch(void 0),
|
|
198
95
|
pendingSupervisionBranch: pendingSupervisionBranchSchema.optional(),
|
|
@@ -277,6 +174,12 @@ const threadBindingSchema = z.object({
|
|
|
277
174
|
message: "pending supervision bindings require supervision connection ownership"
|
|
278
175
|
});
|
|
279
176
|
});
|
|
177
|
+
function matchesPendingSupervisionBranch(binding, expected) {
|
|
178
|
+
const pending = binding?.pendingSupervisionBranch;
|
|
179
|
+
const cleanup = pending?.cleanupThreadIds ?? [];
|
|
180
|
+
const expectedCleanup = expected.cleanupThreadIds ?? [];
|
|
181
|
+
return binding?.threadId === expected.sourceThreadId && pending?.sourceThreadId === expected.sourceThreadId && pending.connectionFingerprint === expected.connectionFingerprint && pending.lastTurnId === expected.lastTurnId && cleanup.length === expectedCleanup.length && cleanup.every((threadId, index) => threadId === expectedCleanup[index]);
|
|
182
|
+
}
|
|
280
183
|
const bindingLeaseSchema = z.object({
|
|
281
184
|
token: z.string().refine((value) => Boolean(value.trim())),
|
|
282
185
|
expiresAt: z.number().finite()
|
|
@@ -288,13 +191,16 @@ const storedBindingSchema = z.discriminatedUnion("state", [z.object({
|
|
|
288
191
|
binding: threadBindingSchema,
|
|
289
192
|
sessionId: storedSessionIdSchema,
|
|
290
193
|
lease: bindingLeaseSchema.optional().catch(void 0),
|
|
291
|
-
nativeSubagentSubmissions: z.unknown().optional()
|
|
194
|
+
nativeSubagentSubmissions: z.unknown().optional(),
|
|
195
|
+
nativeSubagentAssignments: z.unknown().optional(),
|
|
196
|
+
nativeSubagentTaskImport: z.unknown().optional()
|
|
292
197
|
}), z.object({
|
|
293
198
|
version: z.literal(1),
|
|
294
199
|
state: z.literal("cleared"),
|
|
295
200
|
sessionId: storedSessionIdSchema,
|
|
296
201
|
lease: bindingLeaseSchema.optional().catch(void 0),
|
|
297
|
-
retired: z.literal(true).optional().catch(void 0)
|
|
202
|
+
retired: z.literal(true).optional().catch(void 0),
|
|
203
|
+
nativeSubagentTaskImport: z.unknown().optional()
|
|
298
204
|
})]);
|
|
299
205
|
/** Stable plugin-state key for one current binding owner. */
|
|
300
206
|
function bindingStoreKey(identity) {
|
|
@@ -345,11 +251,30 @@ function readCodexBindingTimestamp(value) {
|
|
|
345
251
|
/** The same physical-generation check serves execution and read-only projections. */
|
|
346
252
|
function readCurrentCodexAppServerBinding(state, identity) {
|
|
347
253
|
const key = bindingStoreKey(identity);
|
|
348
|
-
|
|
254
|
+
return decodeCurrentCodexAppServerBinding(key, state.lookup(key), identity);
|
|
255
|
+
}
|
|
256
|
+
function decodeCurrentCodexAppServerBinding(key, raw, identity) {
|
|
349
257
|
const stored = readStoredCodexAppServerBinding(raw);
|
|
350
258
|
if (raw !== void 0 && !stored) throw new Error(`Invalid Codex app-server binding row: ${key}`);
|
|
351
259
|
return stored?.state === "active" && ownsStoredSessionGeneration(identity, stored) ? stored.binding : void 0;
|
|
352
260
|
}
|
|
261
|
+
/** Consume synchronously so each list phase acquires fresh binding authority. */
|
|
262
|
+
function* readCurrentCodexAppServerBindings(state, identities) {
|
|
263
|
+
let keys;
|
|
264
|
+
if (state.lookupMany && identities.length > 1 && identities.length <= 1e4) try {
|
|
265
|
+
keys = identities.map(bindingStoreKey);
|
|
266
|
+
} catch {}
|
|
267
|
+
if (!keys || !state.lookupMany) {
|
|
268
|
+
for (const identity of identities) yield readCurrentCodexAppServerBinding(state, identity);
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
const values = state.lookupMany(keys);
|
|
272
|
+
for (let index = 0; index < identities.length; index++) {
|
|
273
|
+
const value = values[index];
|
|
274
|
+
if (!value.ok) throw value.error;
|
|
275
|
+
yield decodeCurrentCodexAppServerBinding(keys[index], value.value, identities[index]);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
353
278
|
function matchesCodexNativeSubagentSubmissionBinding(binding, owner) {
|
|
354
279
|
return binding.threadId === owner.parentThreadId && !binding.pendingSupervisionBranch && codexNativeSubagentHistoryConnectionFingerprint(binding) === owner.connectionFingerprint;
|
|
355
280
|
}
|
|
@@ -366,6 +291,21 @@ function readCurrentCodexNativeSubagentSubmissions(state, identity, owner) {
|
|
|
366
291
|
const submissions = readCodexNativeSubagentSubmissions(stored.nativeSubagentSubmissions);
|
|
367
292
|
return submissions && matchesCodexNativeSubagentSubmissionOwner(submissions.owner, owner) ? submissions.receipts : [];
|
|
368
293
|
}
|
|
294
|
+
function readCurrentNativePendingAssignments(state, identity, owner) {
|
|
295
|
+
const key = bindingStoreKey(identity);
|
|
296
|
+
const raw = state.lookup(key);
|
|
297
|
+
const stored = readStoredCodexAppServerBinding(raw);
|
|
298
|
+
if (raw !== void 0 && !stored) throw new Error(`Invalid Codex app-server binding row: ${key}`);
|
|
299
|
+
if (stored?.state !== "active" || !ownsStoredSessionGeneration(identity, stored) || identity.kind === "session" && owner.sessionId !== identity.sessionId || !matchesCodexNativeSubagentSubmissionBinding(stored.binding, owner)) return [];
|
|
300
|
+
return (readNativePendingAssignments(stored.nativeSubagentAssignments)?.assignments ?? []).filter((entry) => matchesNativeAssignmentLifecycle(entry.owner, owner));
|
|
301
|
+
}
|
|
302
|
+
function preserveNativeTaskImport(current) {
|
|
303
|
+
return current?.nativeSubagentTaskImport !== void 0 ? { nativeSubagentTaskImport: current.nativeSubagentTaskImport } : {};
|
|
304
|
+
}
|
|
305
|
+
/** Preserve inventory through native rotation, never across a connection-policy change. */
|
|
306
|
+
function preserveNativePendingAssignments(current, next, value) {
|
|
307
|
+
return codexNativeSubagentHistoryConnectionFingerprint(current) === codexNativeSubagentHistoryConnectionFingerprint(next) && isDeepStrictEqual(current.pendingSupervisionBranch, next.pendingSupervisionBranch) ? value : void 0;
|
|
308
|
+
}
|
|
369
309
|
var CodexSupervisionBindingReplacementError = class extends Error {
|
|
370
310
|
constructor(threadId, operation) {
|
|
371
311
|
super(`Refusing to replace supervised Codex thread ${threadId} while ${operation}; its native user-home connection and model ownership must be preserved`);
|
|
@@ -386,28 +326,29 @@ function readPluginAppPolicyContext(value, bindingSchemaVersion) {
|
|
|
386
326
|
const entry = asOptionalRecord(rawEntry);
|
|
387
327
|
if (!entry) return;
|
|
388
328
|
const destructiveApprovalMode = readDestructiveApprovalMode(entry.destructiveApprovalMode, bindingSchemaVersion);
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
};
|
|
400
|
-
continue;
|
|
401
|
-
}
|
|
402
|
-
if ("appId" in entry || entry.source !== void 0 && entry.source !== "plugin" || typeof entry.configKey !== "string" || typeof entry.marketplaceName !== "string" || !CODEX_PLUGIN_MARKETPLACE_NAME_PATTERN.test(entry.marketplaceName) || typeof entry.pluginName !== "string" || typeof entry.allowDestructiveActions !== "boolean" || entry.allowOpenWorld !== void 0 && typeof entry.allowOpenWorld !== "boolean" || destructiveApprovalMode === "invalid" || !mcpServerNames) return;
|
|
403
|
-
parsedApps[appId] = {
|
|
404
|
-
configKey: entry.configKey,
|
|
405
|
-
marketplaceName: entry.marketplaceName,
|
|
406
|
-
pluginName: entry.pluginName,
|
|
407
|
-
allowDestructiveActions: entry.allowDestructiveActions,
|
|
408
|
-
...typeof entry.allowOpenWorld === "boolean" ? { allowOpenWorld: entry.allowOpenWorld } : {},
|
|
329
|
+
if ("appId" in entry || destructiveApprovalMode === "invalid") return;
|
|
330
|
+
const parsed = legacyAppPolicyEntrySchema.safeParse({
|
|
331
|
+
...entry,
|
|
332
|
+
destructiveApprovalMode
|
|
333
|
+
});
|
|
334
|
+
if (!parsed.success) return;
|
|
335
|
+
const validated = parsed.data;
|
|
336
|
+
const policy = {
|
|
337
|
+
allowDestructiveActions: validated.allowDestructiveActions,
|
|
338
|
+
...validated.allowOpenWorld !== void 0 ? { allowOpenWorld: validated.allowOpenWorld } : {},
|
|
409
339
|
...destructiveApprovalMode ? { destructiveApprovalMode } : {},
|
|
410
|
-
mcpServerNames
|
|
340
|
+
mcpServerNames: validated.mcpServerNames
|
|
341
|
+
};
|
|
342
|
+
if (validated.source === "account") parsedApps[appId] = {
|
|
343
|
+
source: "account",
|
|
344
|
+
appName: validated.appName,
|
|
345
|
+
...policy
|
|
346
|
+
};
|
|
347
|
+
else parsedApps[appId] = {
|
|
348
|
+
configKey: validated.configKey,
|
|
349
|
+
marketplaceName: validated.marketplaceName,
|
|
350
|
+
pluginName: validated.pluginName,
|
|
351
|
+
...policy
|
|
411
352
|
};
|
|
412
353
|
}
|
|
413
354
|
const parsedPluginAppIds = {};
|
|
@@ -431,4 +372,4 @@ function readDestructiveApprovalMode(value, bindingSchemaVersion) {
|
|
|
431
372
|
return "invalid";
|
|
432
373
|
}
|
|
433
374
|
//#endregion
|
|
434
|
-
export {
|
|
375
|
+
export { readStoredCodexAppServerBinding as _, matchesPendingSupervisionBranch as a, validateBindingForWrite as b, preserveNativePendingAssignments as c, readCodexBindingTimestamp as d, readCurrentCodexAppServerBinding as f, readPluginAppPolicyContext as g, readCurrentNativePendingAssignments as h, matchesCodexNativeSubagentSubmissionBinding as i, preserveNativeTaskImport as l, readCurrentCodexNativeSubagentSubmissions as m, assertCodexBindingMayBeReplaced as n, ownsStoredSessionGeneration as o, readCurrentCodexAppServerBindings as p, bindingStoreKey as r, preserveCodexNativeSubagentSubmissions as s, CodexSupervisionBindingReplacementError as t, readCodexAppServerThreadBinding as u, sessionBindingIdentity as v, stripUndefinedBinding as y };
|
package/dist/.setup/{session-binding-sidecars-CKYEcfNn.mjs → session-binding-sidecars-jo6H8dFr.mjs}
RENAMED
|
@@ -1,15 +1,243 @@
|
|
|
1
1
|
import { n as CODEX_APP_SERVER_BINDING_NAMESPACE, t as CODEX_APP_SERVER_BINDING_MAX_ENTRIES } from "./session-binding-meta-B7aEMU7g.mjs";
|
|
2
|
+
import "node:module";
|
|
2
3
|
import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
3
4
|
import { isDeepStrictEqual } from "node:util";
|
|
4
5
|
import { listAgentIds, resolveAgentDir, resolveSessionAgentIdsStrict } from "openclaw/plugin-sdk/agent-scope-runtime";
|
|
5
6
|
import path from "node:path";
|
|
6
7
|
import fs from "node:fs/promises";
|
|
8
|
+
import { extractErrorCode } from "openclaw/plugin-sdk/error-runtime";
|
|
7
9
|
import { canonicalPathFromExistingAncestor, isPathInside } from "openclaw/plugin-sdk/file-access-runtime";
|
|
8
|
-
import { pathExists } from "openclaw/plugin-sdk/security-runtime";
|
|
9
10
|
import { normalizeAgentId } from "openclaw/plugin-sdk/routing";
|
|
11
|
+
import { pathExists } from "openclaw/plugin-sdk/security-runtime";
|
|
10
12
|
import { withFileLock } from "openclaw/plugin-sdk/file-lock";
|
|
11
|
-
import { archiveLegacyStateSource, legacyStateFileExists } from "openclaw/plugin-sdk/runtime-doctor-migrations";
|
|
12
13
|
import { resolveStorePath } from "openclaw/plugin-sdk/session-store-paths";
|
|
14
|
+
//#region \0rolldown/runtime.js
|
|
15
|
+
var __defProp = Object.defineProperty;
|
|
16
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
17
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
18
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
19
|
+
var __exportAll = (all, no_symbols) => {
|
|
20
|
+
let target = {};
|
|
21
|
+
for (var name in all) __defProp(target, name, {
|
|
22
|
+
get: all[name],
|
|
23
|
+
enumerable: true
|
|
24
|
+
});
|
|
25
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
26
|
+
return target;
|
|
27
|
+
};
|
|
28
|
+
var __copyProps = (to, from, except, desc) => {
|
|
29
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
30
|
+
key = keys[i];
|
|
31
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
32
|
+
get: ((k) => from[k]).bind(null, key),
|
|
33
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return to;
|
|
37
|
+
};
|
|
38
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region packages/normalization-core/src/record-coerce.ts
|
|
41
|
+
/** Type guard for non-array object records at browser-safe boundaries. */
|
|
42
|
+
function isRecord$1(value) {
|
|
43
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
44
|
+
}
|
|
45
|
+
/** Returns a non-array record or null. */
|
|
46
|
+
function asNullableRecord$1(value) {
|
|
47
|
+
return isRecord$1(value) ? value : null;
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region src/config/channel-config-normalization.ts
|
|
51
|
+
/** Applies one channel-specific doctor migration to every object-shaped account. */
|
|
52
|
+
function normalizeChannelAccounts(params) {
|
|
53
|
+
const rawAccounts = asNullableRecord$1(params.entry.accounts);
|
|
54
|
+
if (!rawAccounts) return {
|
|
55
|
+
entry: params.entry,
|
|
56
|
+
changed: false
|
|
57
|
+
};
|
|
58
|
+
let changed = false;
|
|
59
|
+
const accounts = { ...rawAccounts };
|
|
60
|
+
for (const [accountId, value] of Object.entries(rawAccounts)) {
|
|
61
|
+
const account = asNullableRecord$1(value);
|
|
62
|
+
if (!account) continue;
|
|
63
|
+
const normalized = params.normalizeAccount({
|
|
64
|
+
account,
|
|
65
|
+
accountId,
|
|
66
|
+
pathPrefix: `${params.pathPrefix}.accounts.${accountId}`,
|
|
67
|
+
changes: params.changes
|
|
68
|
+
});
|
|
69
|
+
if (normalized.changed) {
|
|
70
|
+
accounts[accountId] = normalized.entry;
|
|
71
|
+
changed = true;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return changed ? {
|
|
75
|
+
entry: {
|
|
76
|
+
...params.entry,
|
|
77
|
+
accounts
|
|
78
|
+
},
|
|
79
|
+
changed: true
|
|
80
|
+
} : {
|
|
81
|
+
entry: params.entry,
|
|
82
|
+
changed: false
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/** Applies the same channel-specific doctor migration at root and account scope. */
|
|
86
|
+
function normalizeChannelConfigEntries(params) {
|
|
87
|
+
const changes = params.changes ?? [];
|
|
88
|
+
const channels = params.cfg.channels;
|
|
89
|
+
const entry = asNullableRecord$1(channels?.[params.channelId]);
|
|
90
|
+
if (!entry) return {
|
|
91
|
+
config: params.cfg,
|
|
92
|
+
changes
|
|
93
|
+
};
|
|
94
|
+
const channelPath = `channels.${params.channelId}`;
|
|
95
|
+
const root = params.normalizeEntry({
|
|
96
|
+
entry,
|
|
97
|
+
pathPrefix: channelPath,
|
|
98
|
+
changes
|
|
99
|
+
});
|
|
100
|
+
const accounts = normalizeChannelAccounts({
|
|
101
|
+
entry: root.entry,
|
|
102
|
+
pathPrefix: channelPath,
|
|
103
|
+
changes,
|
|
104
|
+
normalizeAccount: (accountParams) => params.normalizeEntry({
|
|
105
|
+
entry: accountParams.account,
|
|
106
|
+
accountId: accountParams.accountId,
|
|
107
|
+
pathPrefix: accountParams.pathPrefix,
|
|
108
|
+
changes: accountParams.changes
|
|
109
|
+
})
|
|
110
|
+
});
|
|
111
|
+
if (!root.changed && !accounts.changed) return {
|
|
112
|
+
config: params.cfg,
|
|
113
|
+
changes
|
|
114
|
+
};
|
|
115
|
+
return {
|
|
116
|
+
config: {
|
|
117
|
+
...params.cfg,
|
|
118
|
+
channels: {
|
|
119
|
+
...channels,
|
|
120
|
+
[params.channelId]: accounts.entry
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
changes
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
//#endregion
|
|
127
|
+
//#region src/plugin-sdk/legacy-webhook-listener-migration.ts
|
|
128
|
+
/** Preserve explicitly configured webhook listeners while moving ingress onto Gateway routes. */
|
|
129
|
+
function createLegacyWebhookListenerDoctorContract(params) {
|
|
130
|
+
const portKey = params.portKey ?? "webhookPort";
|
|
131
|
+
const hostKey = params.hostKey === void 0 ? "webhookHost" : params.hostKey;
|
|
132
|
+
const source = (entry) => params.webhookKey ? asNullableRecord$1(entry[params.webhookKey]) : entry;
|
|
133
|
+
const hasLegacy = (value) => {
|
|
134
|
+
const entry = asNullableRecord$1(value);
|
|
135
|
+
const listener = entry && source(entry);
|
|
136
|
+
return Boolean(listener && (Object.hasOwn(listener, portKey) || hostKey && Object.hasOwn(listener, hostKey)));
|
|
137
|
+
};
|
|
138
|
+
const prefix = `channels.${params.channelKey}`;
|
|
139
|
+
return {
|
|
140
|
+
legacyConfigRules: [{
|
|
141
|
+
path: ["channels", params.channelKey],
|
|
142
|
+
message: `${prefix} webhook listeners moved to Gateway routes. Run "openclaw doctor --fix" to preserve explicitly configured listener settings as legacyWebhook.`,
|
|
143
|
+
match: (value) => {
|
|
144
|
+
const accounts = asNullableRecord$1(asNullableRecord$1(value)?.accounts);
|
|
145
|
+
return hasLegacy(value) || Object.values(accounts ?? {}).some(hasLegacy);
|
|
146
|
+
}
|
|
147
|
+
}],
|
|
148
|
+
normalizeCompatibilityConfig: ({ cfg }) => {
|
|
149
|
+
const root = asNullableRecord$1(asNullableRecord$1(cfg.channels)?.[params.channelKey]);
|
|
150
|
+
const inherited = root && source(root);
|
|
151
|
+
const canonicalRoot = asNullableRecord$1(root?.legacyWebhook);
|
|
152
|
+
return normalizeChannelConfigEntries({
|
|
153
|
+
cfg,
|
|
154
|
+
channelId: params.channelKey,
|
|
155
|
+
normalizeEntry: ({ entry, accountId, pathPrefix, changes }) => {
|
|
156
|
+
const listener = source(entry);
|
|
157
|
+
if (!listener || !hasLegacy(entry)) return {
|
|
158
|
+
entry,
|
|
159
|
+
changed: false
|
|
160
|
+
};
|
|
161
|
+
const next = { ...entry };
|
|
162
|
+
const port = Object.hasOwn(listener, portKey) ? listener[portKey] : (accountId ? canonicalRoot?.port ?? inherited?.[portKey] : void 0) ?? params.defaultPort;
|
|
163
|
+
const inheritedHost = accountId ? canonicalRoot ? canonicalRoot.host : (hostKey ? inherited?.[hostKey] : void 0) ?? params.defaultHost : params.defaultHost;
|
|
164
|
+
const host = hostKey ? listener[hostKey] ?? inheritedHost : inheritedHost;
|
|
165
|
+
const legacyPath = [pathPrefix, params.webhookKey].filter(Boolean).join(".");
|
|
166
|
+
if (Object.hasOwn(entry, "legacyWebhook")) changes.push(`Removed ${legacyPath} legacy listener keys; ${pathPrefix}.legacyWebhook is already configured.`);
|
|
167
|
+
else if (accountId && root?.legacyWebhook === false) changes.push(`Removed ${legacyPath} legacy listener keys; ${prefix}.legacyWebhook: false keeps this account's inherited listener disabled.`);
|
|
168
|
+
else {
|
|
169
|
+
next.legacyWebhook = {
|
|
170
|
+
port,
|
|
171
|
+
...host !== void 0 ? { host } : {}
|
|
172
|
+
};
|
|
173
|
+
changes.push(`Moved ${legacyPath} listener settings to ${pathPrefix}.legacyWebhook. Point the external callback or reverse proxy at the Gateway port and webhook path, verify delivery, then set legacyWebhook: false to disable legacy forwarding.`);
|
|
174
|
+
}
|
|
175
|
+
const updated = params.webhookKey ? { ...listener } : next;
|
|
176
|
+
delete updated[portKey];
|
|
177
|
+
if (hostKey) delete updated[hostKey];
|
|
178
|
+
if (params.webhookKey) {
|
|
179
|
+
if (Object.keys(updated).length) next[params.webhookKey] = updated;
|
|
180
|
+
else delete next[params.webhookKey];
|
|
181
|
+
}
|
|
182
|
+
return {
|
|
183
|
+
entry: next,
|
|
184
|
+
changed: true
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
//#endregion
|
|
192
|
+
//#region \0openclaw:bundled-sdk:openclaw/plugin-sdk/runtime-doctor-migrations
|
|
193
|
+
var runtime_doctor_migrations_exports = /* @__PURE__ */ __exportAll({ createLegacyWebhookListenerDoctorContract: () => createLegacyWebhookListenerDoctorContract });
|
|
194
|
+
import * as import_openclaw_plugin_sdk_runtime_doctor_migrations from "openclaw/plugin-sdk/runtime-doctor-migrations";
|
|
195
|
+
__reExport(runtime_doctor_migrations_exports, import_openclaw_plugin_sdk_runtime_doctor_migrations);
|
|
196
|
+
//#endregion
|
|
197
|
+
//#region extensions/codex/src/migration/session-binding-legacy-index.ts
|
|
198
|
+
async function readLegacySessionIndex(storePath) {
|
|
199
|
+
let contents;
|
|
200
|
+
try {
|
|
201
|
+
contents = await fs.readFile(storePath, "utf8");
|
|
202
|
+
} catch (error) {
|
|
203
|
+
const code = extractErrorCode(error);
|
|
204
|
+
return code === "ENOENT" ? { entries: [] } : { failure: `session index ${storePath} could not be read${code ? ` (${code})` : ""}` };
|
|
205
|
+
}
|
|
206
|
+
let raw;
|
|
207
|
+
try {
|
|
208
|
+
raw = JSON.parse(contents);
|
|
209
|
+
} catch {
|
|
210
|
+
return { failure: `session index ${storePath} could not be read (invalid JSON)` };
|
|
211
|
+
}
|
|
212
|
+
if (!isRecord(raw)) return { failure: `session index ${storePath} has invalid entries` };
|
|
213
|
+
const entries = [];
|
|
214
|
+
for (const [sessionKey, value] of Object.entries(raw)) {
|
|
215
|
+
if (!isRecord(value)) return { failure: `session index ${storePath} has invalid entries` };
|
|
216
|
+
if (value.sessionId === void 0) continue;
|
|
217
|
+
const sessionId = typeof value.sessionId === "string" ? value.sessionId.trim() : "";
|
|
218
|
+
const sessionFile = value.sessionFile;
|
|
219
|
+
const lifecycleRevision = value.lifecycleRevision;
|
|
220
|
+
const agentHarnessId = value.agentHarnessId;
|
|
221
|
+
if (!isSafeLegacySessionId(value.sessionId) || sessionFile !== void 0 && typeof sessionFile !== "string" || lifecycleRevision !== void 0 && typeof lifecycleRevision !== "string" || agentHarnessId !== void 0 && typeof agentHarnessId !== "string") return { failure: `session index ${storePath} has invalid entries` };
|
|
222
|
+
entries.push({
|
|
223
|
+
sessionKey,
|
|
224
|
+
entry: {
|
|
225
|
+
sessionId,
|
|
226
|
+
...typeof sessionFile === "string" ? { sessionFile } : {},
|
|
227
|
+
...typeof lifecycleRevision === "string" ? { lifecycleRevision } : {},
|
|
228
|
+
...typeof agentHarnessId === "string" ? { agentHarnessId } : {},
|
|
229
|
+
...typeof value.updatedAt === "number" && Number.isFinite(value.updatedAt) && value.updatedAt >= 0 ? { updatedAt: value.updatedAt } : {}
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
return { entries };
|
|
234
|
+
}
|
|
235
|
+
function isSafeLegacySessionId(value) {
|
|
236
|
+
if (typeof value !== "string") return false;
|
|
237
|
+
const trimmed = value.trim();
|
|
238
|
+
return trimmed.length > 0 && trimmed.length <= 255 && /^[A-Za-z0-9][A-Za-z0-9._:@-]*$/.test(trimmed);
|
|
239
|
+
}
|
|
240
|
+
//#endregion
|
|
13
241
|
//#region extensions/codex/src/migration/session-binding-sidecars.ts
|
|
14
242
|
const LEGACY_BINDING_SUFFIX = ".codex-app-server.json";
|
|
15
243
|
const CODEX_AGENT_HARNESS_ID = "codex";
|
|
@@ -35,7 +263,7 @@ async function collectSessionSurfaces(params) {
|
|
|
35
263
|
agentIds: /* @__PURE__ */ new Set()
|
|
36
264
|
};
|
|
37
265
|
surface.scan ||= scan;
|
|
38
|
-
surface.storePaths.add(path.resolve(storePath));
|
|
266
|
+
if (!storePath.endsWith(".sqlite")) surface.storePaths.add(path.resolve(storePath));
|
|
39
267
|
if (agentId) surface.agentIds.add(agentId);
|
|
40
268
|
surfaces.set(canonicalRoot, surface);
|
|
41
269
|
};
|
|
@@ -96,43 +324,6 @@ async function collectLegacyBindingSources(params, options = {}) {
|
|
|
96
324
|
surfaces
|
|
97
325
|
};
|
|
98
326
|
}
|
|
99
|
-
async function readLegacySessionIndex(storePath) {
|
|
100
|
-
let contents;
|
|
101
|
-
try {
|
|
102
|
-
contents = await fs.readFile(storePath, "utf8");
|
|
103
|
-
} catch (error) {
|
|
104
|
-
const code = error.code;
|
|
105
|
-
return code === "ENOENT" ? { entries: [] } : { failure: `session index ${storePath} could not be read${code ? ` (${code})` : ""}` };
|
|
106
|
-
}
|
|
107
|
-
let raw;
|
|
108
|
-
try {
|
|
109
|
-
raw = JSON.parse(contents);
|
|
110
|
-
} catch {
|
|
111
|
-
return { failure: `session index ${storePath} could not be read (invalid JSON)` };
|
|
112
|
-
}
|
|
113
|
-
if (!isRecord(raw)) return { failure: `session index ${storePath} has invalid entries` };
|
|
114
|
-
const entries = [];
|
|
115
|
-
for (const [sessionKey, value] of Object.entries(raw)) {
|
|
116
|
-
if (!isRecord(value)) return { failure: `session index ${storePath} has invalid entries` };
|
|
117
|
-
if (value.sessionId === void 0) continue;
|
|
118
|
-
const sessionId = typeof value.sessionId === "string" ? value.sessionId.trim() : "";
|
|
119
|
-
const sessionFile = value.sessionFile;
|
|
120
|
-
const lifecycleRevision = value.lifecycleRevision;
|
|
121
|
-
const agentHarnessId = value.agentHarnessId;
|
|
122
|
-
if (!isSafeLegacySessionId(value.sessionId) || sessionFile !== void 0 && typeof sessionFile !== "string" || lifecycleRevision !== void 0 && typeof lifecycleRevision !== "string" || agentHarnessId !== void 0 && typeof agentHarnessId !== "string") return { failure: `session index ${storePath} has invalid entries` };
|
|
123
|
-
entries.push({
|
|
124
|
-
sessionKey,
|
|
125
|
-
entry: {
|
|
126
|
-
sessionId,
|
|
127
|
-
...typeof sessionFile === "string" ? { sessionFile } : {},
|
|
128
|
-
...typeof lifecycleRevision === "string" ? { lifecycleRevision } : {},
|
|
129
|
-
...typeof agentHarnessId === "string" ? { agentHarnessId } : {},
|
|
130
|
-
...typeof value.updatedAt === "number" && Number.isFinite(value.updatedAt) && value.updatedAt >= 0 ? { updatedAt: value.updatedAt } : {}
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
return { entries };
|
|
135
|
-
}
|
|
136
327
|
async function* iterateIndexedSidecars(surface) {
|
|
137
328
|
for (const storePath of surface.storePaths) {
|
|
138
329
|
const index = await readLegacySessionIndex(storePath);
|
|
@@ -146,7 +337,7 @@ async function* iterateIndexedSidecars(surface) {
|
|
|
146
337
|
continue;
|
|
147
338
|
}
|
|
148
339
|
const sidecarPath = `${transcriptPath}${LEGACY_BINDING_SUFFIX}`;
|
|
149
|
-
if (await legacyStateFileExists(sidecarPath)) yield sidecarPath;
|
|
340
|
+
if (await (0, runtime_doctor_migrations_exports.legacyStateFileExists)(sidecarPath)) yield sidecarPath;
|
|
150
341
|
}
|
|
151
342
|
}
|
|
152
343
|
}
|
|
@@ -277,22 +468,17 @@ function copyBindingForSession(stored, sessionId) {
|
|
|
277
468
|
}
|
|
278
469
|
async function migrateSource(source, candidates, params, store) {
|
|
279
470
|
let importedKeys = 0;
|
|
280
|
-
const retain = (reason) => ({
|
|
471
|
+
const retain = (reason, level = "warning") => ({
|
|
281
472
|
archived: false,
|
|
282
473
|
importedKeys,
|
|
283
|
-
|
|
284
|
-
});
|
|
285
|
-
const retainNotice = (reason) => ({
|
|
286
|
-
archived: false,
|
|
287
|
-
importedKeys,
|
|
288
|
-
notice: `Left Codex binding sidecar in place because ${reason}: ${source.sidecarPath}`
|
|
474
|
+
[level]: `Left Codex binding sidecar in place because ${reason}: ${source.sidecarPath}`
|
|
289
475
|
});
|
|
290
476
|
const owner = candidates.length === 1 ? candidates[0] : void 0;
|
|
291
477
|
try {
|
|
292
478
|
return await withFileLock(source.sidecarPath, LEGACY_BINDING_LOCK_OPTIONS, async () => {
|
|
293
479
|
const [contents, stat] = await Promise.all([fs.readFile(source.sidecarPath, "utf8"), fs.stat(source.sidecarPath)]);
|
|
294
480
|
const raw = JSON.parse(contents);
|
|
295
|
-
const [{ bindingStoreKey, createStoredCodexAppServerBinding, normalizeStoredCodexAppServerBindingFingerprints, readStoredCodexAppServerBinding }, { legacyCodexConversationBindingId }] = await Promise.all([import("./session-binding-
|
|
481
|
+
const [{ bindingStoreKey, createStoredCodexAppServerBinding, normalizeStoredCodexAppServerBindingFingerprints, readStoredCodexAppServerBinding }, { legacyCodexConversationBindingId }] = await Promise.all([import("./session-binding-DGCYAfvD.mjs").then((n) => n.s), import("./conversation-binding-data-C746z5Pn.mjs").then((n) => n.t)]);
|
|
296
482
|
const agentId = owner?.agentId ?? (source.agentIds.size === 1 ? [...source.agentIds][0] : void 0);
|
|
297
483
|
const baseStored = createStoredCodexAppServerBinding(raw, {
|
|
298
484
|
now: stat.mtime.toISOString(),
|
|
@@ -303,15 +489,16 @@ async function migrateSource(source, candidates, params, store) {
|
|
|
303
489
|
});
|
|
304
490
|
if (!baseStored) return retain("its binding is invalid");
|
|
305
491
|
if (candidates.length > 1) return retain(`${candidates.length} matching session owners make ownership ambiguous`);
|
|
306
|
-
if (owner?.agentHarnessId && owner.agentHarnessId !== CODEX_AGENT_HARNESS_ID) return
|
|
492
|
+
if (owner?.agentHarnessId && owner.agentHarnessId !== CODEX_AGENT_HARNESS_ID) return retain(`its session is owned by agent harness ${owner.agentHarnessId}`, "notice");
|
|
307
493
|
const readEvidence = params.context.readSessionIdentityEvidenceBatch;
|
|
308
494
|
const canonicalOwner = owner && readEvidence ? (await readEvidence([{
|
|
309
495
|
agentId: owner.agentId,
|
|
310
496
|
sessionId: owner.sessionId
|
|
311
497
|
}]))[0] : void 0;
|
|
312
498
|
const canCreateOwner = !readEvidence || canonicalOwner?.state === "unknown";
|
|
313
|
-
const
|
|
314
|
-
const
|
|
499
|
+
const storedSessionFile = typeof raw.sessionFile === "string" && raw.sessionFile.trim() ? raw.sessionFile : void 0;
|
|
500
|
+
const sourceSessionFile = storedSessionFile ?? source.transcriptPath;
|
|
501
|
+
const ownerSessionFile = storedSessionFile ?? owner?.transcriptPath;
|
|
315
502
|
const conversationKeys = [sourceSessionFile, ...ownerSessionFile && ownerSessionFile !== sourceSessionFile ? [ownerSessionFile] : []].map((sessionFile) => bindingStoreKey({
|
|
316
503
|
kind: "conversation",
|
|
317
504
|
bindingId: legacyCodexConversationBindingId(sessionFile)
|
|
@@ -398,11 +585,11 @@ async function migrateSource(source, candidates, params, store) {
|
|
|
398
585
|
});
|
|
399
586
|
if (hasExpected(await store.lookup(sessionEntry.key), sessionEntry.value)) return retain(`${ownershipWarning}; its stale session binding could not be retired`);
|
|
400
587
|
}
|
|
401
|
-
if (typeof ownershipResult === "string") return
|
|
588
|
+
if (typeof ownershipResult === "string") return retain(ownershipWarning, "notice");
|
|
402
589
|
} else for (const entry of entries) if (!hasExpected(await store.lookup(entry.key), entry.value)) return retain(`canonical plugin state changed at ${entry.key}`);
|
|
403
590
|
}
|
|
404
591
|
const archiveWarnings = [];
|
|
405
|
-
await archiveLegacyStateSource({
|
|
592
|
+
await (0, runtime_doctor_migrations_exports.archiveLegacyStateSource)({
|
|
406
593
|
filePath: source.sidecarPath,
|
|
407
594
|
label: "Codex app-server binding",
|
|
408
595
|
changes: [],
|
|
@@ -491,11 +678,6 @@ async function readDirectoryEntries(directory) {
|
|
|
491
678
|
throw error;
|
|
492
679
|
}
|
|
493
680
|
}
|
|
494
|
-
function isSafeLegacySessionId(value) {
|
|
495
|
-
if (typeof value !== "string") return false;
|
|
496
|
-
const trimmed = value.trim();
|
|
497
|
-
return trimmed.length > 0 && trimmed.length <= 255 && /^[A-Za-z0-9][A-Za-z0-9._:@-]*$/.test(trimmed);
|
|
498
|
-
}
|
|
499
681
|
async function detectLegacySessionBindingSidecars(params) {
|
|
500
682
|
const { sources } = await collectLegacyBindingSources(params, { firstOnly: true });
|
|
501
683
|
return sources.length > 0 ? { preview: [`- Codex app-server bindings: legacy sidecar -> plugin state (${CODEX_APP_SERVER_BINDING_NAMESPACE})`] } : null;
|
|
@@ -540,4 +722,4 @@ async function migrateLegacySessionBindingSidecars(params) {
|
|
|
540
722
|
};
|
|
541
723
|
}
|
|
542
724
|
//#endregion
|
|
543
|
-
export { detectLegacySessionBindingSidecars, migrateLegacySessionBindingSidecars };
|
|
725
|
+
export { detectLegacySessionBindingSidecars, migrateLegacySessionBindingSidecars, __exportAll as t };
|