@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,203 @@
|
|
|
1
|
+
import { i as isJsonObject } from "./protocol-CANUwXJ3.mjs";
|
|
2
|
+
import { asOptionalRecord, readStringField } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
4
|
+
import { isDeepStrictEqual } from "node:util";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
//#region extensions/codex/src/app-server/native-subagent-history-owner.ts
|
|
7
|
+
const nonBlankString = z.string().refine((value) => Boolean(value.trim()));
|
|
8
|
+
const codexNativeSubagentHistoryOwnerSchema = z.object({
|
|
9
|
+
parentThreadId: nonBlankString,
|
|
10
|
+
sessionId: nonBlankString,
|
|
11
|
+
lifecycleRevision: nonBlankString.optional(),
|
|
12
|
+
connectionFingerprint: z.string().regex(/^[a-f0-9]{64}$/u)
|
|
13
|
+
});
|
|
14
|
+
/** Automatic recovery may follow native rotation only within the same host lifecycle and connection. */
|
|
15
|
+
function matchesCodexNativeSubagentHistoryOwner(stored, current) {
|
|
16
|
+
return stored.connectionFingerprint === current.connectionFingerprint && stored.lifecycleRevision === current.lifecycleRevision && (stored.lifecycleRevision !== void 0 || stored.sessionId === current.sessionId);
|
|
17
|
+
}
|
|
18
|
+
function codexNativeSubagentHistoryConnectionFingerprint(binding) {
|
|
19
|
+
if (!binding.appServerRuntimeFingerprint) return;
|
|
20
|
+
return createHash("sha256").update(JSON.stringify([
|
|
21
|
+
binding.appServerRuntimeFingerprint,
|
|
22
|
+
binding.connectionScope ?? null,
|
|
23
|
+
binding.authProfileId ?? null
|
|
24
|
+
])).digest("hex");
|
|
25
|
+
}
|
|
26
|
+
function createCodexNativeSubagentHistoryOwner(params) {
|
|
27
|
+
const connectionFingerprint = codexNativeSubagentHistoryConnectionFingerprint(params.binding);
|
|
28
|
+
return connectionFingerprint ? {
|
|
29
|
+
parentThreadId: params.parentThreadId,
|
|
30
|
+
sessionId: params.sessionId,
|
|
31
|
+
...params.lifecycleRevision ? { lifecycleRevision: params.lifecycleRevision } : {},
|
|
32
|
+
connectionFingerprint
|
|
33
|
+
} : void 0;
|
|
34
|
+
}
|
|
35
|
+
function readCodexNativeSubagentHistoryOwner(detail) {
|
|
36
|
+
const value = asOptionalRecord(detail)?.nativeHistory;
|
|
37
|
+
if (value === void 0) return;
|
|
38
|
+
const owner = codexNativeSubagentHistoryOwnerSchema.safeParse(value);
|
|
39
|
+
if (!owner.success) throw new Error("Subagent history owner is invalid.");
|
|
40
|
+
const { lifecycleRevision, ...required } = owner.data;
|
|
41
|
+
return lifecycleRevision === void 0 ? required : {
|
|
42
|
+
...required,
|
|
43
|
+
lifecycleRevision
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function assertHistoryOwnerMatchesRegistration(saved, current, parentThreadId, requireSaved = false) {
|
|
47
|
+
if (requireSaved && !saved) throw new Error("Subagent completion history owner is missing.");
|
|
48
|
+
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.");
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region extensions/codex/src/app-server/native-subagent-assignment.ts
|
|
52
|
+
/**
|
|
53
|
+
* Shared identifiers for Codex native subagent execution and completion receipts.
|
|
54
|
+
*/
|
|
55
|
+
/** Run ID prefix for native child thread assignments. */
|
|
56
|
+
const CODEX_NATIVE_SUBAGENT_RUN_ID_PREFIX = "codex-thread:";
|
|
57
|
+
/** Initial assignments use the thread locator; follow-ups belong to a native turn. */
|
|
58
|
+
function codexNativeSubagentRunId(threadId, turnId) {
|
|
59
|
+
return `${CODEX_NATIVE_SUBAGENT_RUN_ID_PREFIX}${threadId.trim()}${turnId ? `:turn:${turnId}` : ""}`;
|
|
60
|
+
}
|
|
61
|
+
function readCodexNativeSubagentRunId(runId) {
|
|
62
|
+
if (!runId?.startsWith(CODEX_NATIVE_SUBAGENT_RUN_ID_PREFIX)) return;
|
|
63
|
+
const [threadId, turnId] = runId.slice(13).split(":turn:");
|
|
64
|
+
return threadId?.trim() ? {
|
|
65
|
+
threadId,
|
|
66
|
+
...turnId ? { turnId } : {}
|
|
67
|
+
} : void 0;
|
|
68
|
+
}
|
|
69
|
+
function readNativeSubagentThreadIds(value) {
|
|
70
|
+
if (!Array.isArray(value)) return [];
|
|
71
|
+
return value.filter((entry) => typeof entry === "string" && entry.trim() !== "");
|
|
72
|
+
}
|
|
73
|
+
function readThreadParentThreadId(thread) {
|
|
74
|
+
return readStringField(thread, "parentThreadId")?.trim() ?? readStringField(readThreadSpawnSource(thread), "parent_thread_id")?.trim();
|
|
75
|
+
}
|
|
76
|
+
function readThreadSpawnSource(thread) {
|
|
77
|
+
const source = isJsonObject(thread?.source) ? thread.source : void 0;
|
|
78
|
+
const subAgent = isJsonObject(source?.subAgent) ? source.subAgent : void 0;
|
|
79
|
+
return isJsonObject(subAgent?.thread_spawn) ? subAgent.thread_spawn : void 0;
|
|
80
|
+
}
|
|
81
|
+
function normalizeIdentifier(value) {
|
|
82
|
+
return value?.replace(/[^a-z0-9]/giu, "").toLowerCase();
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region extensions/codex/src/app-server/native-subagent-submission.ts
|
|
86
|
+
const identifier$1 = z.string().refine((value) => Boolean(value.trim()));
|
|
87
|
+
const submissionSchema = z.object({
|
|
88
|
+
parentTurnId: identifier$1,
|
|
89
|
+
callId: identifier$1,
|
|
90
|
+
childThreadId: identifier$1,
|
|
91
|
+
submissionId: identifier$1,
|
|
92
|
+
predecessorRunId: identifier$1,
|
|
93
|
+
predecessorNativeTurnId: identifier$1
|
|
94
|
+
}).strict();
|
|
95
|
+
const submissionsSchema = z.object({
|
|
96
|
+
version: z.literal(1),
|
|
97
|
+
owner: codexNativeSubagentHistoryOwnerSchema,
|
|
98
|
+
receipts: z.array(submissionSchema)
|
|
99
|
+
}).strict().refine(({ receipts }) => new Set(receipts.map(({ parentTurnId, callId }) => JSON.stringify([parentTurnId, callId]))).size === receipts.length);
|
|
100
|
+
function matchesCodexNativeSubagentSubmissionOwner(stored, current) {
|
|
101
|
+
return stored.parentThreadId === current.parentThreadId && matchesCodexNativeSubagentHistoryOwner(stored, current);
|
|
102
|
+
}
|
|
103
|
+
function readCodexNativeSubagentSubmissions(value) {
|
|
104
|
+
if (value === void 0) return;
|
|
105
|
+
const parsed = submissionsSchema.safeParse(value);
|
|
106
|
+
if (!parsed.success) throw new Error("Invalid Codex native subagent submission metadata.");
|
|
107
|
+
return parsed.data;
|
|
108
|
+
}
|
|
109
|
+
function mutateCodexNativeSubagentSubmissions(params) {
|
|
110
|
+
const current = readCodexNativeSubagentSubmissions(params.current);
|
|
111
|
+
const owner = codexNativeSubagentHistoryOwnerSchema.parse(params.owner);
|
|
112
|
+
const receipt = submissionSchema.parse(params.receipt);
|
|
113
|
+
if (current && !matchesCodexNativeSubagentSubmissionOwner(current.owner, owner)) return { applied: false };
|
|
114
|
+
const receipts = current?.receipts ?? [];
|
|
115
|
+
const existing = receipts.find((entry) => entry.parentTurnId === receipt.parentTurnId && entry.callId === receipt.callId);
|
|
116
|
+
if (existing && !isDeepStrictEqual(existing, receipt)) return { applied: false };
|
|
117
|
+
if (params.consume) {
|
|
118
|
+
if (!current) return { applied: false };
|
|
119
|
+
const remaining = receipts.filter((entry) => entry !== existing);
|
|
120
|
+
return {
|
|
121
|
+
applied: true,
|
|
122
|
+
...remaining.length ? { next: {
|
|
123
|
+
version: 1,
|
|
124
|
+
owner: current.owner,
|
|
125
|
+
receipts: remaining
|
|
126
|
+
} } : {}
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
applied: true,
|
|
131
|
+
next: {
|
|
132
|
+
version: 1,
|
|
133
|
+
owner: current?.owner ?? owner,
|
|
134
|
+
receipts: existing ? receipts : [...receipts, receipt]
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
/** Physical adoption cannot establish continuity for an unstamped receipt. */
|
|
139
|
+
function adoptCodexNativeSubagentSubmissions(value) {
|
|
140
|
+
if (value === void 0) return;
|
|
141
|
+
const parsed = submissionsSchema.safeParse(value);
|
|
142
|
+
return !parsed.success || parsed.data.owner.lifecycleRevision ? value : void 0;
|
|
143
|
+
}
|
|
144
|
+
//#endregion
|
|
145
|
+
//#region extensions/codex/src/app-server/native-subagent-pending-assignments.ts
|
|
146
|
+
const identifier = z.string().trim().min(1);
|
|
147
|
+
const assignmentSchema = z.object({
|
|
148
|
+
runId: identifier,
|
|
149
|
+
childThreadId: identifier,
|
|
150
|
+
nativeTurnId: identifier.optional(),
|
|
151
|
+
nativeParentThreadId: identifier,
|
|
152
|
+
owner: codexNativeSubagentHistoryOwnerSchema,
|
|
153
|
+
submission: submissionSchema.optional(),
|
|
154
|
+
recordedCompletion: z.object({
|
|
155
|
+
childThreadId: identifier,
|
|
156
|
+
status: z.enum([
|
|
157
|
+
"succeeded",
|
|
158
|
+
"failed",
|
|
159
|
+
"cancelled"
|
|
160
|
+
]),
|
|
161
|
+
statusLabel: z.literal("recorded_task_result"),
|
|
162
|
+
result: z.string().min(1),
|
|
163
|
+
completedAt: z.number().finite().optional()
|
|
164
|
+
}).strict().optional()
|
|
165
|
+
}).strict().refine((entry) => !entry.recordedCompletion || entry.recordedCompletion.childThreadId === entry.childThreadId).refine((entry) => !entry.submission || entry.submission.childThreadId === entry.childThreadId && entry.nativeTurnId === entry.submission.submissionId && entry.runId === codexNativeSubagentRunId(entry.childThreadId, entry.submission.submissionId)).refine((entry) => entry.runId === codexNativeSubagentRunId(entry.childThreadId) || entry.nativeTurnId !== void 0 && readCodexNativeSubagentRunId(entry.runId)?.threadId === entry.childThreadId);
|
|
166
|
+
const inventorySchema = z.object({
|
|
167
|
+
version: z.literal(1),
|
|
168
|
+
assignments: z.array(assignmentSchema)
|
|
169
|
+
}).strict().refine(({ assignments }) => new Set(assignments.map((entry) => entry.runId)).size === assignments.length);
|
|
170
|
+
/** Native parent rotation is not physical requester or connection adoption. */
|
|
171
|
+
function matchesNativeAssignmentLifecycle(saved, current) {
|
|
172
|
+
return saved.sessionId === current.sessionId && saved.lifecycleRevision === current.lifecycleRevision && saved.connectionFingerprint === current.connectionFingerprint;
|
|
173
|
+
}
|
|
174
|
+
function readNativePendingAssignments(value) {
|
|
175
|
+
if (value === void 0) return;
|
|
176
|
+
const parsed = inventorySchema.safeParse(value);
|
|
177
|
+
if (!parsed.success) throw new Error("Invalid Codex native pending assignment metadata.");
|
|
178
|
+
return parsed.data;
|
|
179
|
+
}
|
|
180
|
+
function mutateNativePendingAssignments(params) {
|
|
181
|
+
const current = readNativePendingAssignments(params.current);
|
|
182
|
+
const assignment = assignmentSchema.parse(params.assignment);
|
|
183
|
+
const owner = codexNativeSubagentHistoryOwnerSchema.parse(params.owner);
|
|
184
|
+
if (!matchesNativeAssignmentLifecycle(assignment.owner, owner)) return { applied: false };
|
|
185
|
+
const assignments = current?.assignments ?? [];
|
|
186
|
+
const existing = assignments.find((entry) => entry.runId === assignment.runId);
|
|
187
|
+
if (existing && (!isDeepStrictEqual(existing.owner, assignment.owner) || existing.nativeParentThreadId !== assignment.nativeParentThreadId || existing.childThreadId !== assignment.childThreadId)) return { applied: false };
|
|
188
|
+
if (params.consume && (!existing || existing.nativeTurnId !== assignment.nativeTurnId)) return { applied: false };
|
|
189
|
+
const remaining = assignments.filter((entry) => entry !== existing);
|
|
190
|
+
if (!params.consume) remaining.push(existing?.recordedCompletion && !assignment.recordedCompletion ? {
|
|
191
|
+
...assignment,
|
|
192
|
+
recordedCompletion: existing.recordedCompletion
|
|
193
|
+
} : assignment);
|
|
194
|
+
return {
|
|
195
|
+
applied: true,
|
|
196
|
+
next: remaining.length ? {
|
|
197
|
+
version: 1,
|
|
198
|
+
assignments: remaining
|
|
199
|
+
} : void 0
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
//#endregion
|
|
203
|
+
export { readCodexNativeSubagentHistoryOwner as _, matchesCodexNativeSubagentSubmissionOwner as a, codexNativeSubagentRunId as c, readNativeSubagentThreadIds as d, readThreadParentThreadId as f, createCodexNativeSubagentHistoryOwner as g, codexNativeSubagentHistoryConnectionFingerprint as h, adoptCodexNativeSubagentSubmissions as i, normalizeIdentifier as l, assertHistoryOwnerMatchesRegistration as m, mutateNativePendingAssignments as n, mutateCodexNativeSubagentSubmissions as o, readThreadSpawnSource as p, readNativePendingAssignments as r, readCodexNativeSubagentSubmissions as s, matchesNativeAssignmentLifecycle as t, readCodexNativeSubagentRunId as u };
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { _ as readCodexNativeSubagentHistoryOwner, h as codexNativeSubagentHistoryConnectionFingerprint, r as readNativePendingAssignments, u as readCodexNativeSubagentRunId } from "./native-subagent-pending-assignments-DwkCzLvD.mjs";
|
|
2
|
+
import { _ as readStoredCodexAppServerBinding, r as bindingStoreKey } 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 { isDeepStrictEqual } from "node:util";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import fs from "node:fs/promises";
|
|
8
|
+
import { extractErrorCode } from "openclaw/plugin-sdk/error-runtime";
|
|
9
|
+
import { getSessionEntry, resolveStorePath } from "openclaw/plugin-sdk/session-store-runtime";
|
|
10
|
+
import { executeSqliteQuerySync, getNodeSqliteKysely, openNodeSqliteDatabase, prepareSqliteReadOnlyLocation, tableExists } from "openclaw/plugin-sdk/sqlite-runtime";
|
|
11
|
+
//#region extensions/codex/src/migration/native-task-assignments.ts
|
|
12
|
+
const importSchema = z.object({
|
|
13
|
+
version: z.literal(1),
|
|
14
|
+
taskIds: z.array(z.string().min(1))
|
|
15
|
+
}).strict();
|
|
16
|
+
const detailSchema = z.object({ nativeTurnId: z.string().trim().min(1).optional() });
|
|
17
|
+
function databasePath(params) {
|
|
18
|
+
return path.join(params.stateDir, "state", "openclaw.sqlite");
|
|
19
|
+
}
|
|
20
|
+
const missingOwnerMessage = "missing original requester session, lifecycle and connection facts (nativeHistory); inspect the original child in its native Codex account, or restore the pre-upgrade backup with its matching OpenClaw version to finish delivery";
|
|
21
|
+
function taskIdentity(task) {
|
|
22
|
+
try {
|
|
23
|
+
const owner = readCodexNativeSubagentHistoryOwner(task.detail_json ? JSON.parse(task.detail_json) : {});
|
|
24
|
+
return task.agent_id && task.requester_session_key && owner ? {
|
|
25
|
+
kind: "session",
|
|
26
|
+
agentId: task.agent_id,
|
|
27
|
+
sessionKey: task.requester_session_key,
|
|
28
|
+
sessionId: owner.sessionId
|
|
29
|
+
} : void 0;
|
|
30
|
+
} catch {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async function inspect(params) {
|
|
35
|
+
const source = databasePath(params);
|
|
36
|
+
try {
|
|
37
|
+
await fs.access(source);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
if (extractErrorCode(error) === "ENOENT") return [];
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
const snapshot = await prepareSqliteReadOnlyLocation(source, { preserveSourceArtifacts: true });
|
|
43
|
+
try {
|
|
44
|
+
const db = openNodeSqliteDatabase(snapshot.location, { readOnly: true });
|
|
45
|
+
try {
|
|
46
|
+
if (!tableExists(db, "task_runs") || !tableExists(db, "plugin_state_entries")) return [];
|
|
47
|
+
const sql = getNodeSqliteKysely(db);
|
|
48
|
+
return executeSqliteQuerySync(db, sql.selectFrom("task_runs").select([
|
|
49
|
+
"task_id",
|
|
50
|
+
"runtime",
|
|
51
|
+
"task_kind",
|
|
52
|
+
"run_id",
|
|
53
|
+
"agent_id",
|
|
54
|
+
"requester_session_key",
|
|
55
|
+
"owner_key",
|
|
56
|
+
"scope_kind",
|
|
57
|
+
"status",
|
|
58
|
+
"delivery_status",
|
|
59
|
+
"ended_at",
|
|
60
|
+
"terminal_summary",
|
|
61
|
+
"detail_json"
|
|
62
|
+
]).select((eb) => eb.selectFrom("task_runs as all_runs").select((count) => count.fn.countAll().as("count")).whereRef("all_runs.run_id", "=", "task_runs.run_id").where("all_runs.runtime", "=", "subagent").where("all_runs.task_kind", "=", "codex-native").as("run_count")).where("runtime", "=", "subagent").where("task_kind", "=", "codex-native").where("delivery_status", "!=", "delivered").where((eb) => eb.or([
|
|
63
|
+
eb("status", "in", ["queued", "running"]),
|
|
64
|
+
eb("delivery_status", "=", "pending"),
|
|
65
|
+
eb.and([eb("delivery_status", "=", "not_applicable"), eb("ended_at", ">=", Date.now() - 6e4)])
|
|
66
|
+
]))).rows.filter((row) => {
|
|
67
|
+
const identity = taskIdentity(row);
|
|
68
|
+
if (!identity) return true;
|
|
69
|
+
const binding = executeSqliteQuerySync(db, sql.selectFrom("plugin_state_entries").select("value_json").where("plugin_id", "=", "codex").where("namespace", "=", CODEX_APP_SERVER_BINDING_NAMESPACE).where("entry_key", "=", bindingStoreKey(identity)).where((eb) => eb.or([eb("expires_at", "is", null), eb("expires_at", ">", Date.now())]))).rows[0];
|
|
70
|
+
try {
|
|
71
|
+
const stored = binding && readStoredCodexAppServerBinding(JSON.parse(binding.value_json));
|
|
72
|
+
const imported = importSchema.safeParse(stored?.nativeSubagentTaskImport);
|
|
73
|
+
return !imported.success || !imported.data.taskIds.includes(row.task_id);
|
|
74
|
+
} catch {
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
} finally {
|
|
79
|
+
db.close();
|
|
80
|
+
}
|
|
81
|
+
} finally {
|
|
82
|
+
await snapshot.cleanupAsync();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function prepareAssignment(task, stored, params) {
|
|
86
|
+
const identity = taskIdentity(task);
|
|
87
|
+
const native = readCodexNativeSubagentRunId(task.run_id ?? void 0);
|
|
88
|
+
const detail = task.detail_json ? JSON.parse(task.detail_json) : {};
|
|
89
|
+
const owner = readCodexNativeSubagentHistoryOwner(detail);
|
|
90
|
+
if (!owner) throw new Error(missingOwnerMessage);
|
|
91
|
+
if (!identity || !native || !task.run_id || stored.state !== "active" || stored.binding.pendingSupervisionBranch) throw new Error("current requester binding is unavailable; reconnect the original requester and run openclaw doctor --fix");
|
|
92
|
+
const session = getSessionEntry({
|
|
93
|
+
agentId: identity.agentId,
|
|
94
|
+
sessionKey: identity.sessionKey,
|
|
95
|
+
env: params.env,
|
|
96
|
+
storePath: resolveStorePath(params.config.session?.store, {
|
|
97
|
+
agentId: identity.agentId,
|
|
98
|
+
env: params.env
|
|
99
|
+
}),
|
|
100
|
+
readConsistency: "latest"
|
|
101
|
+
});
|
|
102
|
+
if (!session || session.sessionId !== owner.sessionId || stored.sessionId !== owner.sessionId || session.lifecycleRevision !== owner.lifecycleRevision || session.agentHarnessId !== void 0 && session.agentHarnessId !== "codex" || codexNativeSubagentHistoryConnectionFingerprint(stored.binding) !== owner.connectionFingerprint) throw new Error("requester session, lifecycle, or connection ownership no longer matches; inspect the original child in its native Codex account");
|
|
103
|
+
if (task.scope_kind !== "session" || task.owner_key !== identity.sessionKey) throw new Error("Task requester ownership does not match its session; inspect the original child in its native Codex account");
|
|
104
|
+
const nativeTurnId = detailSchema.parse(detail).nativeTurnId ?? native.turnId;
|
|
105
|
+
return {
|
|
106
|
+
runId: task.run_id,
|
|
107
|
+
childThreadId: native.threadId,
|
|
108
|
+
...nativeTurnId ? { nativeTurnId } : {},
|
|
109
|
+
nativeParentThreadId: owner.parentThreadId,
|
|
110
|
+
owner,
|
|
111
|
+
...(task.status === "succeeded" || task.status === "failed" || task.status === "cancelled") && task.terminal_summary ? { recordedCompletion: {
|
|
112
|
+
childThreadId: native.threadId,
|
|
113
|
+
status: task.status,
|
|
114
|
+
statusLabel: "recorded_task_result",
|
|
115
|
+
result: task.terminal_summary,
|
|
116
|
+
...task.ended_at !== null ? { completedAt: task.ended_at } : {}
|
|
117
|
+
} } : {}
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
const codexNativeTaskAssignmentMigration = {
|
|
121
|
+
id: "codex-native-task-assignments",
|
|
122
|
+
label: "Codex native pending assignments",
|
|
123
|
+
collectBackupResources: (params) => [{
|
|
124
|
+
path: databasePath(params),
|
|
125
|
+
kind: "sqlite"
|
|
126
|
+
}],
|
|
127
|
+
async detectLegacyState(params) {
|
|
128
|
+
return (await inspect(params)).length > 0 ? { preview: ["- Preserve native Codex child recovery before retiring Tasks"] } : null;
|
|
129
|
+
},
|
|
130
|
+
async migrateLegacyState(params) {
|
|
131
|
+
const rows = await inspect(params);
|
|
132
|
+
const warnings = [];
|
|
133
|
+
if (rows.length === 0) return {
|
|
134
|
+
changes: [],
|
|
135
|
+
warnings
|
|
136
|
+
};
|
|
137
|
+
let imported = 0;
|
|
138
|
+
const store = params.context.openPluginStateKeyedStore({
|
|
139
|
+
namespace: CODEX_APP_SERVER_BINDING_NAMESPACE,
|
|
140
|
+
maxEntries: CODEX_APP_SERVER_BINDING_MAX_ENTRIES,
|
|
141
|
+
overflowPolicy: "reject-new",
|
|
142
|
+
env: params.env
|
|
143
|
+
});
|
|
144
|
+
for (const task of rows) try {
|
|
145
|
+
const identity = taskIdentity(task);
|
|
146
|
+
if (!identity) throw new Error(missingOwnerMessage);
|
|
147
|
+
if (!store.observe || !store.compareAndApply || !store.withCurrent) throw new Error("current requester identity or atomic binding storage is unavailable; run openclaw doctor --fix with the current version");
|
|
148
|
+
if (task.run_count !== 1) throw new Error("duplicate native assignment identity; inspect the retained Task records before repairing them");
|
|
149
|
+
const key = bindingStoreKey(identity);
|
|
150
|
+
const observed = await store.observe(key);
|
|
151
|
+
const stored = readStoredCodexAppServerBinding(observed.value);
|
|
152
|
+
if (!stored) throw new Error("original requester binding is unavailable; inspect the child in its native Codex account");
|
|
153
|
+
const marker = stored.nativeSubagentTaskImport === void 0 ? {
|
|
154
|
+
version: 1,
|
|
155
|
+
taskIds: []
|
|
156
|
+
} : importSchema.parse(stored.nativeSubagentTaskImport);
|
|
157
|
+
if (marker.taskIds.includes(task.task_id)) continue;
|
|
158
|
+
const assignment = prepareAssignment(task, stored, params);
|
|
159
|
+
if (stored.state !== "active" || observed.value?.state !== "active") continue;
|
|
160
|
+
const assignments = readNativePendingAssignments(stored.nativeSubagentAssignments)?.assignments ?? [];
|
|
161
|
+
const existing = assignments.find((value) => value.runId === assignment.runId);
|
|
162
|
+
if (existing && !isDeepStrictEqual(existing, assignment)) throw new Error("a newer binding assignment already owns this result; preserve both records for inspection");
|
|
163
|
+
const next = {
|
|
164
|
+
...stored,
|
|
165
|
+
...observed.value,
|
|
166
|
+
nativeSubagentAssignments: {
|
|
167
|
+
version: 1,
|
|
168
|
+
assignments: existing ? assignments : [...assignments, assignment]
|
|
169
|
+
},
|
|
170
|
+
nativeSubagentTaskImport: {
|
|
171
|
+
version: 1,
|
|
172
|
+
taskIds: [...marker.taskIds, task.task_id]
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
if ((await store.withCurrent({ assertCurrent: () => {
|
|
176
|
+
prepareAssignment(task, stored, params);
|
|
177
|
+
} }).compareAndApply(key, observed.comparison, {
|
|
178
|
+
operation: "update",
|
|
179
|
+
action: "set",
|
|
180
|
+
value: next
|
|
181
|
+
})).status === "conflict") throw new Error("binding changed during import; run openclaw doctor --fix again");
|
|
182
|
+
imported += 1;
|
|
183
|
+
} catch (error) {
|
|
184
|
+
warnings.push(`Native Codex task ${task.task_id} (${task.run_id ?? "unknown child"}) was preserved without migration: ${String(error)}`);
|
|
185
|
+
}
|
|
186
|
+
return {
|
|
187
|
+
changes: imported ? [`Preserved ${imported} native Codex assignment(s) in their existing parent bindings`] : [],
|
|
188
|
+
warnings,
|
|
189
|
+
...warnings.length ? { warningDisposition: "recoverable" } : {}
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
//#endregion
|
|
194
|
+
export { codexNativeTaskAssignmentMigration };
|