@openclaw/codex 2026.9.1 → 2026.9.3

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.
Files changed (109) hide show
  1. package/README.md +2 -0
  2. package/dist/api.js +18 -23
  3. package/dist/apply-B6el6hdO.js +357 -0
  4. package/dist/{attempt-client-cleanup-DYHcRQAa.js → attempt-client-cleanup-D6cR54TV.js} +113 -49
  5. package/dist/{attempt-context-DmQUNWwT.js → attempt-context-AO4DSjE0.js} +11 -9
  6. package/dist/{event-projector-usage-C5mcrGjp.js → attempt-notifications--H8zXR5-.js} +3 -89
  7. package/dist/auth-cache-key-Kq6oerr6.js +498 -0
  8. package/dist/auth-profile-CwzO4_RG.js +43 -0
  9. package/dist/auth-profile-selection-DFu9e167.js +45 -0
  10. package/dist/{binding-connection-E6uDsPlx.js → binding-connection-QqgcPCgk.js} +18 -3
  11. package/dist/{bounded-turn-wzJrwKKe.js → bounded-turn-lRpmZHFv.js} +54 -150
  12. package/dist/build-state-6RL6qohz.js +19 -0
  13. package/dist/{capabilities-dIjNVCYH.js → capabilities-BeqLPbtM.js} +2 -1
  14. package/dist/cli-metadata.js +1 -1
  15. package/dist/client-BEKu4yDx.js +3983 -0
  16. package/dist/command-dispatch-CisT9Jqq.js +21 -0
  17. package/dist/{command-formatters-CLHhEB1Q.js → command-formatters-DeTfrapr.js} +2 -2
  18. package/dist/{command-handlers-CTGb2csu.js → command-handlers-BfIsJEuA.js} +158 -76
  19. package/dist/command-rpc-BMqRQOFX.js +226 -0
  20. package/dist/{compact-_t0HQrUS.js → compact-CGJZ2rlb.js} +89 -49
  21. package/dist/config-JDfTI4VI.js +106 -0
  22. package/dist/{config-BhmfC1s6.js → config-options-jnIFvwxD.js} +208 -654
  23. package/dist/config-runtime-BWf6JLWG.js +11 -0
  24. package/dist/config-utils-C57JiJrU.js +69 -0
  25. package/dist/conversation-binding-CxOlHiix.js +889 -0
  26. package/dist/{plugin-marketplace-discovery-CfFlKqDl.js → conversation-control-CUCrSIQI.js} +36 -155
  27. package/dist/doctor-contract-api.js +8 -9
  28. package/dist/{dynamic-tools-BU9tmlYm.js → dynamic-tools-D-JBoaLt.js} +734 -698
  29. package/dist/{effective-mcp-catalog-DzYBW4h1.js → effective-mcp-catalog-J_5Ep5Um.js} +4 -3
  30. package/dist/{elicitation-input-DMkeki8d.js → elicitation-input-DPoK8F7w.js} +8 -22
  31. package/dist/ephemeral-turn-DSwzP8YY.js +101 -0
  32. package/dist/{event-projector-assistant-message-DHRFXKbS.js → event-projector-assistant-message-BmBM4qBV.js} +23 -27
  33. package/dist/event-projector-usage-CIyrYYid.js +102 -0
  34. package/dist/{harness-DXVZ5II5.js → harness-FR6eQgyO.js} +47 -17
  35. package/dist/harness.js +1 -1
  36. package/dist/history-rejection-B4nOXNXF.js +13 -0
  37. package/dist/{image-payload-sanitizer-CnfoUPCE.js → image-payload-sanitizer-tupAr-2o.js} +29 -15
  38. package/dist/incognito-session-uhrBF6wJ.js +15 -0
  39. package/dist/index.js +413 -2893
  40. package/dist/{isolated-completion-kg9kv4iH.js → isolated-completion-DHBefrzg.js} +12 -21
  41. package/dist/{managed-binary-4-Vjz5GH.js → managed-binary-DrjjRRUD.js} +17 -84
  42. package/dist/managed-thread-store-D1t5jh3G.js +66 -0
  43. package/dist/media-understanding-provider.js +4 -1
  44. package/dist/{model-catalog-CUM68Hkl.js → model-catalog-B_6M04Wo.js} +6 -5
  45. package/dist/{models-sYnEc0gd.js → models-P9k2qAof.js} +4 -4
  46. package/dist/native-execution-policy-umd0tgh4.js +128 -0
  47. package/dist/{native-subagent-monitor-CnH147jH.js → native-subagent-monitor-BbCUKRwC.js} +76 -48
  48. package/dist/node-cli-sessions-rj0ysJwM.js +527 -0
  49. package/dist/{node-exec-server.runtime-CstNHCmC.js → node-exec-server.runtime-BY_ctYnT.js} +54 -23
  50. package/dist/plan-BMJdMOEF.js +711 -0
  51. package/dist/plugin-activation-BQK-f5sV.js +133 -0
  52. package/dist/{thread-resume-C7pyVKeW.js → plugin-app-cache-key-CdSQzWyX.js} +5 -53
  53. package/dist/{plugin-approval-roundtrip-CNe-Xrjx.js → plugin-approval-roundtrip-DeW95wB5.js} +1 -1
  54. package/dist/plugin-inventory-CoRCzWW4.js +325 -0
  55. package/dist/plugin-marketplace-discovery-3akBizzF.js +134 -0
  56. package/dist/{plugin-metadata-cache-BFrPhb2c.js → plugin-metadata-cache-DgNfRAGA.js} +13 -9
  57. package/dist/protocol-CAAcVIKF.js +275 -0
  58. package/dist/{provider-capabilities-DW5p4k9w.js → provider-capabilities-W4tfK5Y5.js} +2 -2
  59. package/dist/{rate-limits-CawQJfUS.js → rate-limits-Bqnx1N4z.js} +1 -1
  60. package/dist/request-CGvGOpeR.js +198 -0
  61. package/dist/{run-attempt-D1hJO4fX.js → run-attempt-DwKds3DN.js} +1498 -1028
  62. package/dist/{runtime-artifact-C3jVimFn.js → runtime-artifact-T-NwqeSH.js} +28 -28
  63. package/dist/sandbox-guard-BcT66fWy.js +165 -0
  64. package/dist/{session-binding-BHuTCRZQ.js → session-binding-CKSepwIC.js} +118 -324
  65. package/dist/session-binding-record-CaZjYwNS.js +256 -0
  66. package/dist/session-catalog-HaDcp7Sv.js +1533 -0
  67. package/dist/session-catalog-adoption-BKLtSrwi.js +251 -0
  68. package/dist/session-catalog-archive-D0i2pGj2.js +56 -0
  69. package/dist/session-catalog-home-id-D7-aLiNt.js +190 -0
  70. package/dist/session-catalog-node-adoption-BUuDYY8R.js +182 -0
  71. package/dist/session-catalog-node-continue-CBtc4wkI.js +238 -0
  72. package/dist/session-catalog-parsing-CdD3JhdM.js +280 -0
  73. package/dist/session-catalog-provenance-DkJHo735.js +124 -0
  74. package/dist/{session-cli-CmFEXMAM.js → session-cli-CbgaHh0f.js} +3 -2
  75. package/dist/session-history-Cz-tOOYj.js +96 -0
  76. package/dist/{session-upstream-marker-C351-5Qw.js → session-history-import-DFN7sWRU.js} +5 -49
  77. package/dist/session-history-read-cxPUxyVV.js +50 -0
  78. package/dist/session-history-worker-runtime.js +60 -0
  79. package/dist/{settled-turn-context-D3SNWtUn.js → session-history.worker-CNEvGaU5.js} +75 -69
  80. package/dist/session-history.worker.js +2 -0
  81. package/dist/{session-initialization-BeWzjGiR.js → session-initialization-Jo86C60I.js} +2 -1
  82. package/dist/{session-permission-policy-DeWVTCMj.js → session-permission-policy-B22InTp_.js} +4 -7
  83. package/dist/{session-retirement-BujDjXVF.js → session-retirement-BSNG_mhf.js} +8 -7
  84. package/dist/session-upstream-marker-D15C9NHp.js +46 -0
  85. package/dist/settled-turn-context-Du6gdUDd.js +45 -0
  86. package/dist/{settled-turn-finalizer-BVJx4yoc.js → settled-turn-finalizer-BuLUrZl2.js} +54 -42
  87. package/dist/shared-client-CVhez2Uo.js +2911 -0
  88. package/dist/{side-question-BTZAII4l.js → side-question-DLbr2vUU.js} +135 -191
  89. package/dist/source-Da-h6f7e.js +518 -0
  90. package/dist/thread-archive-guard-D1bP04Tf.js +53 -0
  91. package/dist/{thread-lifecycle-DAcEJ_Om.js → thread-lifecycle-D1pzRwHB.js} +467 -977
  92. package/dist/{thread-ownership-zGokd8i1.js → thread-ownership-D6oASVRu.js} +15 -17
  93. package/dist/{thread-policy-g4KbJPzp.js → thread-policy-D8kI7yAO.js} +2 -2
  94. package/dist/thread-resume-T5cveyxA.js +52 -0
  95. package/dist/timeout-BVw8aaM1.js +33 -0
  96. package/dist/transcript-mirror-attestation-DibE0krH.js +89 -0
  97. package/dist/{transcript-mirror-DTUxFWa_.js → transcript-mirror-t5TOccct.js} +111 -379
  98. package/dist/{transport-stdio-CyPldczm.js → transport-stdio-BGjHoYLr.js} +80 -48
  99. package/dist/{upstream-session-fork-CYlBIGVt.js → upstream-session-fork-De-sLJ2r.js} +94 -166
  100. package/dist/{usage-Bj-rrzkR.js → usage-CPPTmBvZ.js} +4 -3
  101. package/dist/version-omm6IPI3.js +12 -0
  102. package/dist/{web-search-provider.runtime-D2FWSK4w.js → web-search-provider.runtime-CSVgQL0w.js} +3 -3
  103. package/openclaw.plugin.json +22 -1
  104. package/package.json +6 -6
  105. package/dist/request-DYAI5FQE.js +0 -475
  106. package/dist/session-catalog-yyvTWFOw.js +0 -3120
  107. package/dist/session-history-C5J1AKzG.js +0 -87
  108. package/dist/shared-client-DxcfF9KX.js +0 -7494
  109. package/dist/{auth-binding-Ds_QVm-X.js → auth-binding-Co2Vfcf_.js} +1 -1
@@ -0,0 +1,96 @@
1
+ import { n as readCodexNativeHistory, t as consumeCodexHistory } from "./session-history-read-cxPUxyVV.js";
2
+ import { SessionManager } from "openclaw/plugin-sdk/agent-sessions";
3
+ import { getSessionEntry, parseSqliteSessionFileMarker, resolveTranscriptSessionKeyBySessionId } from "openclaw/plugin-sdk/session-store-runtime";
4
+ //#region extensions/codex/src/app-server/session-history.ts
5
+ function resolveCodexHistoryTarget(target, admission) {
6
+ if (target.sessionTarget) {
7
+ const { agentId, sessionId, sessionKey, storePath } = target.sessionTarget;
8
+ if (!agentId || !sessionId || !sessionKey || !storePath || sessionId !== target.sessionId || target.agentId !== void 0 && agentId !== target.agentId || target.sessionKey !== void 0 && sessionKey !== target.sessionKey) return { kind: "empty" };
9
+ return {
10
+ kind: "sqlite",
11
+ target: {
12
+ agentId,
13
+ sessionId,
14
+ sessionKey,
15
+ storePath
16
+ }
17
+ };
18
+ }
19
+ const sqliteMarker = parseSqliteSessionFileMarker(target.sessionFile);
20
+ if (sqliteMarker) {
21
+ if (sqliteMarker.sessionId !== target.sessionId || target.agentId !== void 0 && sqliteMarker.agentId !== target.agentId) return { kind: "empty" };
22
+ const sessionKey = resolveSqliteMarkerSessionKey(target, sqliteMarker);
23
+ return sessionKey ? {
24
+ kind: "sqlite",
25
+ target: {
26
+ agentId: sqliteMarker.agentId,
27
+ sessionId: sqliteMarker.sessionId,
28
+ sessionKey,
29
+ storePath: sqliteMarker.storePath
30
+ }
31
+ } : { kind: "empty" };
32
+ }
33
+ if (admission) {
34
+ if (admission.sessionId !== target.sessionId || target.agentId !== void 0 && admission.agentId !== target.agentId || target.sessionKey !== void 0 && admission.sessionKey !== target.sessionKey) return { kind: "empty" };
35
+ return {
36
+ kind: "sqlite",
37
+ target: {
38
+ agentId: admission.agentId,
39
+ sessionId: admission.sessionId,
40
+ sessionKey: admission.sessionKey,
41
+ storePath: admission.storePath
42
+ }
43
+ };
44
+ }
45
+ return {
46
+ kind: "file",
47
+ sessionFile: target.sessionFile
48
+ };
49
+ }
50
+ /** Returns sanitized session-context messages for consumers that need an owned array. */
51
+ async function readCodexMirroredSessionHistoryMessages(target, admission, view = "native-evidence", signal) {
52
+ signal?.throwIfAborted();
53
+ try {
54
+ let result;
55
+ if (view === "native-evidence") {
56
+ const { readCodexHistoryMessagesInWorker } = await import("./session-history-worker-runtime.js");
57
+ result = await readCodexHistoryMessagesInWorker(target, admission, signal);
58
+ } else {
59
+ const resolved = resolveCodexHistoryTarget(target, admission);
60
+ const read = (messages) => Array.from(messages);
61
+ if (resolved.kind === "sqlite") {
62
+ const loaded = await SessionManager.openModelContextAsync(resolved.target, {
63
+ admission,
64
+ signal
65
+ });
66
+ result = consumeCodexHistory(loaded.buildSessionContext().messages, loaded.getHeader(), target.sessionId, read, "codex mirrored model context");
67
+ } else {
68
+ const history = await readCodexNativeHistory(resolved, target.sessionId, read, admission);
69
+ result = history.status === "ok" ? history.value : void 0;
70
+ }
71
+ }
72
+ signal?.throwIfAborted();
73
+ return result;
74
+ } catch {
75
+ signal?.throwIfAborted();
76
+ return;
77
+ }
78
+ }
79
+ function resolveSqliteMarkerSessionKey(target, marker) {
80
+ const explicitSessionKey = target.sessionKey?.trim();
81
+ if (explicitSessionKey) {
82
+ const explicitEntry = getSessionEntry({
83
+ agentId: marker.agentId,
84
+ sessionKey: explicitSessionKey,
85
+ storePath: marker.storePath
86
+ });
87
+ if (explicitEntry) return explicitEntry.sessionId === marker.sessionId ? explicitSessionKey : void 0;
88
+ }
89
+ return resolveTranscriptSessionKeyBySessionId({
90
+ agentId: marker.agentId,
91
+ sessionId: marker.sessionId,
92
+ storePath: marker.storePath
93
+ });
94
+ }
95
+ //#endregion
96
+ export { resolveCodexHistoryTarget as n, readCodexMirroredSessionHistoryMessages as t };
@@ -1,6 +1,7 @@
1
- import { d as sessionBindingIdentity } from "./session-binding-BHuTCRZQ.js";
2
- import { r as importCodexThreadHistoryToTranscript } from "./transcript-mirror-DTUxFWa_.js";
3
- import { n as prepareCodexSessionInitialization } from "./session-initialization-BeWzjGiR.js";
1
+ import { l as sessionBindingIdentity } from "./session-binding-record-CaZjYwNS.js";
2
+ import "./session-binding-CKSepwIC.js";
3
+ import { r as importCodexThreadHistoryToTranscript } from "./transcript-mirror-t5TOccct.js";
4
+ import { n as prepareCodexSessionInitialization } from "./session-initialization-Jo86C60I.js";
4
5
  import { resolveStorePath } from "openclaw/plugin-sdk/session-store-runtime";
5
6
  //#region extensions/codex/src/app-server/session-history-import.ts
6
7
  /** Creates a session whose transcript is derived from one verified Codex thread snapshot. */
@@ -49,49 +50,4 @@ async function createImportedCodexSession(params) {
49
50
  }) : await params.runtime.agent.session.createSessionEntry(createParams);
50
51
  }
51
52
  //#endregion
52
- //#region extensions/codex/src/session-upstream-marker.ts
53
- function lastIdentifiableTurn(thread, normalizeTurnId) {
54
- for (let index = (thread.turns?.length ?? 0) - 1; index >= 0; index -= 1) {
55
- const turn = thread.turns?.[index];
56
- const turnId = normalizeTurnId(turn?.id);
57
- if (turn && turnId) return {
58
- ...turn,
59
- id: turnId
60
- };
61
- }
62
- }
63
- function codexUpstreamBaseline(thread, normalizeTurnId) {
64
- const turn = lastIdentifiableTurn(thread, normalizeTurnId);
65
- return {
66
- turnId: turn?.id ?? null,
67
- userMessageCount: turn?.items.filter((item) => item.type === "userMessage").length ?? 0
68
- };
69
- }
70
- function codexLastTerminalTurnId(thread, normalizeTurnId) {
71
- for (let index = (thread.turns?.length ?? 0) - 1; index >= 0; index -= 1) {
72
- const turn = thread.turns?.[index];
73
- const turnId = normalizeTurnId(turn?.id);
74
- if (!turn || !turnId) continue;
75
- if (turn.status === "completed" || turn.status === "interrupted" || turn.status === "failed") return turnId;
76
- }
77
- }
78
- /** Build the upstream link seed for a continued Codex session, if a baseline exists. */
79
- function codexUpstreamContinueResult(sessionKey, threadId, baseline) {
80
- if (!baseline) return { sessionKey };
81
- return {
82
- sessionKey,
83
- upstream: {
84
- kind: "codex-app-server",
85
- ref: {
86
- connectionFingerprint: baseline.connectionFingerprint,
87
- threadId
88
- },
89
- marker: {
90
- turnId: baseline.turnId,
91
- userMessageCount: baseline.userMessageCount
92
- }
93
- }
94
- };
95
- }
96
- //#endregion
97
- export { createImportedCodexSession as i, codexUpstreamBaseline as n, codexUpstreamContinueResult as r, codexLastTerminalTurnId as t };
53
+ export { createImportedCodexSession };
@@ -0,0 +1,50 @@
1
+ import { n as codexHistoryRejectionReason, t as CodexHistoryRejection } from "./history-rejection-B4nOXNXF.js";
2
+ import { n as sanitizeCodexHistoryImagePayloads } from "./image-payload-sanitizer-tupAr-2o.js";
3
+ import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
4
+ import fs from "node:fs/promises";
5
+ import { SessionTranscriptReadFenceError, readCodexSessionContext } from "openclaw/plugin-sdk/codex-session-transcript-runtime";
6
+ //#region extensions/codex/src/app-server/session-history-read.ts
7
+ function consumeCodexHistory(messages, header, sessionId, read, imageLabel = "codex mirrored history") {
8
+ if (!isRecord(header) || header.type !== "session") return read([]);
9
+ if (typeof header.id !== "string") throw new CodexHistoryRejection("malformed_header");
10
+ if (header.id !== sessionId) return read([]);
11
+ return read((function* () {
12
+ for (const message of messages) yield sanitizeCodexHistoryImagePayloads(message, imageLabel);
13
+ })());
14
+ }
15
+ /** Keeps native evidence and its synchronous consumer inside the same readonly snapshot. */
16
+ async function readCodexNativeHistory(target, sessionId, read, admission, onSnapshot) {
17
+ const consume = (messages, header, version) => {
18
+ try {
19
+ onSnapshot?.(version);
20
+ return {
21
+ status: "ok",
22
+ value: consumeCodexHistory(messages, header, sessionId, read)
23
+ };
24
+ } catch (error) {
25
+ return {
26
+ status: "rejected",
27
+ reason: codexHistoryRejectionReason(error)
28
+ };
29
+ }
30
+ };
31
+ try {
32
+ if (target.kind === "empty") return consume([], void 0);
33
+ if (target.kind === "sqlite") return readCodexSessionContext(target.target, consume, admission);
34
+ const { buildSessionContext, migrateSessionEntries, parseSessionEntries } = await import("openclaw/plugin-sdk/agent-sessions");
35
+ const entries = parseSessionEntries(await fs.readFile(target.sessionFile, "utf-8"));
36
+ return consume((function* () {
37
+ migrateSessionEntries(entries);
38
+ const sessionEntries = entries.filter((entry) => isRecord(entry) && entry.type !== "session");
39
+ yield* buildSessionContext(sessionEntries).messages;
40
+ })(), entries[0]);
41
+ } catch (error) {
42
+ if (isRecord(error) && error.code === "ENOENT") return consume([], void 0);
43
+ return {
44
+ status: "rejected",
45
+ reason: error instanceof SessionTranscriptReadFenceError || isRecord(error) && (error.code === "EACCES" || error.code === "EPERM") ? "access_rejected" : codexHistoryRejectionReason(error)
46
+ };
47
+ }
48
+ }
49
+ //#endregion
50
+ export { readCodexNativeHistory as n, consumeCodexHistory as t };
@@ -0,0 +1,60 @@
1
+ import { n as codexHistoryRejectionReason } from "./history-rejection-B4nOXNXF.js";
2
+ import { n as runCodexHistoryWorkerInput, t as codexHistoryWorkerUrl } from "./session-history.worker-CNEvGaU5.js";
3
+ import { n as resolveCodexHistoryTarget } from "./session-history-Cz-tOOYj.js";
4
+ import { WorkerTaskPool } from "openclaw/plugin-sdk/process-runtime";
5
+ import { isIncognitoSessionKey } from "openclaw/plugin-sdk/session-key-runtime";
6
+ import { SessionTranscriptReadFenceError, captureCodexSessionTranscriptReadAdmission, validateCodexSessionTranscriptContextVersion, validateCodexSessionTranscriptReadAdmission } from "openclaw/plugin-sdk/codex-session-transcript-runtime";
7
+ //#region extensions/codex/session-history-worker-runtime.ts
8
+ const historyReads = new WorkerTaskPool({
9
+ workerUrl: codexHistoryWorkerUrl,
10
+ maxWorkers: 1
11
+ });
12
+ async function readHistory(target, operation, admission, signal) {
13
+ signal?.throwIfAborted();
14
+ const resolved = resolveCodexHistoryTarget(target, admission);
15
+ const receipt = admission ?? (resolved.kind === "sqlite" ? captureCodexSessionTranscriptReadAdmission(resolved.target) : void 0);
16
+ const input = {
17
+ ...operation,
18
+ target: resolved,
19
+ sessionId: target.sessionId,
20
+ ...receipt ? { admission: { ...receipt } } : {}
21
+ };
22
+ const result = resolved.kind === "sqlite" && isIncognitoSessionKey(resolved.target.sessionKey) ? await runCodexHistoryWorkerInput(input) : await historyReads.run(input, {
23
+ timeoutMs: 6e4,
24
+ signal
25
+ });
26
+ signal?.throwIfAborted();
27
+ if (resolved.kind === "sqlite") try {
28
+ if (input.admission) validateCodexSessionTranscriptReadAdmission(resolved.target, input.admission);
29
+ else validateCodexSessionTranscriptContextVersion(resolved.target, result.version);
30
+ } catch (error) {
31
+ return {
32
+ ...result,
33
+ result: {
34
+ status: "rejected",
35
+ reason: error instanceof SessionTranscriptReadFenceError ? "snapshot_invalidated" : codexHistoryRejectionReason(error)
36
+ }
37
+ };
38
+ }
39
+ return result;
40
+ }
41
+ async function readCodexHistoryMessagesInWorker(target, admission, signal) {
42
+ const result = await readHistory(target, { kind: "messages" }, admission, signal);
43
+ return result.kind === "messages" && result.result.status === "ok" ? result.result.value : void 0;
44
+ }
45
+ async function projectCodexSettledHistoryInWorker(target, signal) {
46
+ const result = await readHistory(target, {
47
+ kind: "settled",
48
+ evidence: {
49
+ mirroredMessages: target.mirroredMessages,
50
+ settledMessages: target.settledMessages,
51
+ turnId: target.turnId
52
+ }
53
+ }, void 0, signal);
54
+ return result.kind === "settled" ? result.result : {
55
+ status: "rejected",
56
+ reason: "history_read_failed"
57
+ };
58
+ }
59
+ //#endregion
60
+ export { projectCodexSettledHistoryInWorker, readCodexHistoryMessagesInWorker };
@@ -1,8 +1,9 @@
1
- import { d as serializeCodexMirrorSourceEvidence } from "./transcript-mirror-DTUxFWa_.js";
2
1
  import { i as readUpstreamUserText, r as readMirrorIdentity } from "./upstream-prompt-provenance-LphB8slG.js";
3
- import { t as readCodexMirroredSessionHistory } from "./session-history-C5J1AKzG.js";
2
+ import { t as CodexHistoryRejection } from "./history-rejection-B4nOXNXF.js";
3
+ import { n as readCodexNativeHistory } from "./session-history-read-cxPUxyVV.js";
4
+ import { l as serializeCodexMirrorSourceEvidence } from "./transcript-mirror-attestation-DibE0krH.js";
4
5
  import { isRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
5
- import { embeddedAgentLog, formatErrorMessage } from "openclaw/plugin-sdk/agent-harness-runtime";
6
+ import { serveWorkerTasks } from "openclaw/plugin-sdk/process-runtime";
6
7
  import { Buffer } from "node:buffer";
7
8
  //#region extensions/codex/src/app-server/settled-turn-projection.ts
8
9
  const MAX_RESPONSE_ITEMS = 200;
@@ -10,14 +11,14 @@ const MAX_PROJECTION_BYTES = 524288;
10
11
  const MAX_TEXT_BYTES = 65536;
11
12
  const TOOL_NAME_PATTERN = /^[a-zA-Z0-9._-]{1,128}$/u;
12
13
  const TOOL_ERROR_STATUS_PREFIX = "[Tool result status: error]\n";
13
- function readBoundedText(value, label, maxBytes = MAX_TEXT_BYTES) {
14
+ function readBoundedText(value, maxBytes = MAX_TEXT_BYTES) {
14
15
  if (typeof value !== "string" || !value.trim()) return;
15
- if (Buffer.byteLength(value, "utf8") > maxBytes) throw new Error(`Codex settled-turn projection found oversized ${label}`);
16
+ if (Buffer.byteLength(value, "utf8") > maxBytes) throw new CodexHistoryRejection("field_limit");
16
17
  return value;
17
18
  }
18
- function requireBoundedText(value, label, maxBytes = MAX_TEXT_BYTES) {
19
- const text = readBoundedText(value, label, maxBytes);
20
- if (!text) throw new Error(`Codex settled-turn projection found empty ${label}`);
19
+ function requireBoundedText(value, maxBytes = MAX_TEXT_BYTES) {
20
+ const text = readBoundedText(value, maxBytes);
21
+ if (!text) throw new CodexHistoryRejection("invalid_content");
21
22
  return text;
22
23
  }
23
24
  function responseItemBytes(item) {
@@ -25,12 +26,12 @@ function responseItemBytes(item) {
25
26
  }
26
27
  function requireCallId(value) {
27
28
  const callId = normalizeOptionalString(value);
28
- if (!callId || callId.length > 256) throw new Error("Codex settled-turn projection found an invalid tool call id");
29
+ if (!callId || callId.length > 256) throw new CodexHistoryRejection("invalid_content");
29
30
  return callId;
30
31
  }
31
32
  function requireToolName(value) {
32
33
  const name = normalizeOptionalString(value);
33
- if (!name || !TOOL_NAME_PATTERN.test(name)) throw new Error(`Codex settled-turn projection found an invalid tool name${name ? `: ${name.slice(0, 64)}` : ""}`);
34
+ if (!name || !TOOL_NAME_PATTERN.test(name)) throw new CodexHistoryRejection("invalid_content");
34
35
  return name;
35
36
  }
36
37
  function serializeToolArguments(value) {
@@ -39,19 +40,19 @@ function serializeToolArguments(value) {
39
40
  try {
40
41
  parsed = JSON.parse(value);
41
42
  } catch {
42
- throw new Error("Codex settled-turn projection found invalid JSON tool arguments");
43
+ throw new CodexHistoryRejection("invalid_content");
43
44
  }
44
- if (!isRecord(parsed)) throw new Error("Codex settled-turn projection requires object tool arguments");
45
- return requireBoundedText(value, "tool arguments");
45
+ if (!isRecord(parsed)) throw new CodexHistoryRejection("invalid_content");
46
+ return requireBoundedText(value);
46
47
  }
47
- if (!isRecord(value)) throw new Error("Codex settled-turn projection requires object tool arguments");
48
+ if (!isRecord(value)) throw new CodexHistoryRejection("invalid_content");
48
49
  let serialized;
49
50
  try {
50
51
  serialized = JSON.stringify(value);
51
52
  } catch {
52
- throw new Error("Codex settled-turn projection found unserializable tool arguments");
53
+ throw new CodexHistoryRejection("invalid_content");
53
54
  }
54
- return requireBoundedText(serialized, "tool arguments");
55
+ return requireBoundedText(serialized);
55
56
  }
56
57
  function projectUserMessage(message) {
57
58
  const upstreamUserText = readUpstreamUserText(message);
@@ -60,10 +61,10 @@ function projectUserMessage(message) {
60
61
  role: "user",
61
62
  content: [{
62
63
  type: "input_text",
63
- text: upstreamUserText ? requireBoundedText(upstreamUserText, "upstream user text", MAX_PROJECTION_BYTES) : requireBoundedText(message.content, "user message")
64
+ text: upstreamUserText ? requireBoundedText(upstreamUserText, MAX_PROJECTION_BYTES) : requireBoundedText(message.content)
64
65
  }]
65
66
  };
66
- if (!Array.isArray(message.content)) throw new Error("Codex settled-turn projection found unsupported user content");
67
+ if (!Array.isArray(message.content)) throw new CodexHistoryRejection("unsupported_content");
67
68
  const content = [];
68
69
  let bytes = responseItemBytes({
69
70
  type: "message",
@@ -71,20 +72,20 @@ function projectUserMessage(message) {
71
72
  content
72
73
  });
73
74
  for (const value of message.content) {
74
- if (!isRecord(value)) throw new Error("Codex settled-turn projection found malformed user content");
75
- if (value.type !== "text") throw new Error(`Codex settled-turn projection does not support user content ${value.type}`);
76
- const text = readBoundedText(value.text, "user text");
75
+ if (!isRecord(value)) throw new CodexHistoryRejection("invalid_content");
76
+ if (value.type !== "text") throw new CodexHistoryRejection(value.type === "image" ? "unsupported_user_image" : "unsupported_content");
77
+ const text = readBoundedText(value.text);
77
78
  if (text) {
78
79
  const part = {
79
80
  type: "input_text",
80
81
  text
81
82
  };
82
83
  bytes += responseItemBytes(part) + (content.length > 0 ? 1 : 0);
83
- if (bytes > MAX_PROJECTION_BYTES) throw new Error("Codex settled-turn projection exceeds the byte limit");
84
+ if (bytes > MAX_PROJECTION_BYTES) throw new CodexHistoryRejection("byte_limit");
84
85
  content.push(part);
85
86
  }
86
87
  }
87
- if (content.length === 0) throw new Error("Codex settled-turn projection found an empty user message");
88
+ if (content.length === 0) throw new CodexHistoryRejection("invalid_content");
88
89
  return {
89
90
  type: "message",
90
91
  role: "user",
@@ -96,11 +97,11 @@ function* projectAssistantMessage(message) {
96
97
  type: "text",
97
98
  text: message.content
98
99
  }] : message.content;
99
- if (!Array.isArray(values)) throw new Error("Codex settled-turn projection found unsupported assistant content");
100
+ if (!Array.isArray(values)) throw new CodexHistoryRejection("unsupported_content");
100
101
  for (const value of values) {
101
- if (!isRecord(value)) throw new Error("Codex settled-turn projection found malformed assistant content");
102
+ if (!isRecord(value)) throw new CodexHistoryRejection("invalid_content");
102
103
  if (value.type === "text") {
103
- const text = readBoundedText(value.text, "assistant text");
104
+ const text = readBoundedText(value.text);
104
105
  if (text) yield { item: {
105
106
  type: "message",
106
107
  role: "assistant",
@@ -129,35 +130,35 @@ function* projectAssistantMessage(message) {
129
130
  continue;
130
131
  }
131
132
  if (value.type === "thinking" || value.type === "reasoning") continue;
132
- throw new Error(`Codex settled-turn projection does not support assistant content ${String(value.type)}`);
133
+ throw new CodexHistoryRejection("unsupported_content");
133
134
  }
134
135
  }
135
136
  function projectToolResult(message) {
136
137
  const id = requireCallId(message.toolCallId);
137
138
  const name = requireToolName(message.toolName);
138
- if (!Array.isArray(message.content)) throw new Error("Codex settled-turn projection found unsupported tool result content");
139
+ if (!Array.isArray(message.content)) throw new CodexHistoryRejection("unsupported_content");
139
140
  const isErrorValue = message.isError;
140
- if (isErrorValue !== void 0 && typeof isErrorValue !== "boolean") throw new Error("Codex settled-turn projection found invalid tool result status");
141
+ if (isErrorValue !== void 0 && typeof isErrorValue !== "boolean") throw new CodexHistoryRejection("invalid_content");
141
142
  const isError = isErrorValue === true;
142
143
  const parts = [];
143
144
  let bytes = 0;
144
145
  const appendText = (text) => {
145
146
  bytes += Buffer.byteLength(text, "utf8") + (parts.length > 0 ? 1 : 0);
146
- if (bytes > MAX_TEXT_BYTES) throw new Error("Codex settled-turn projection found oversized tool result output");
147
+ if (bytes > MAX_TEXT_BYTES) throw new CodexHistoryRejection("field_limit");
147
148
  parts.push(text);
148
149
  };
149
150
  for (const value of message.content) {
150
- if (!isRecord(value)) throw new Error("Codex settled-turn projection found malformed tool result content");
151
+ if (!isRecord(value)) throw new CodexHistoryRejection("invalid_content");
151
152
  if (value.type === "image") {
152
153
  appendText(`[Image tool result: ${normalizeOptionalString(value.mimeType) ?? "unknown type"}]`);
153
154
  continue;
154
155
  }
155
- if (value.type !== "text" && value.type !== "toolResult") throw new Error("Codex settled-turn projection found malformed tool result content");
156
- const text = value.type === "text" ? readBoundedText(value.text, "tool result text") : readBoundedText(value.content ?? value.text, "tool result text");
156
+ if (value.type !== "text" && value.type !== "toolResult") throw new CodexHistoryRejection("invalid_content");
157
+ const text = value.type === "text" ? readBoundedText(value.text) : readBoundedText(value.content ?? value.text);
157
158
  if (text) appendText(text);
158
159
  }
159
160
  const resultText = parts.join("\n") || (isError ? "Tool failed without textual output." : "Tool completed without textual output.");
160
- const output = requireBoundedText(isError ? `${TOOL_ERROR_STATUS_PREFIX}${resultText}` : resultText, "tool result output", isError ? MAX_TEXT_BYTES + Buffer.byteLength(TOOL_ERROR_STATUS_PREFIX, "utf8") : MAX_TEXT_BYTES);
161
+ const output = requireBoundedText(isError ? `${TOOL_ERROR_STATUS_PREFIX}${resultText}` : resultText, isError ? MAX_TEXT_BYTES + Buffer.byteLength(TOOL_ERROR_STATUS_PREFIX, "utf8") : MAX_TEXT_BYTES);
161
162
  return {
162
163
  result: {
163
164
  id,
@@ -174,7 +175,7 @@ function* projectMessage(message) {
174
175
  if (message.role === "user") yield { item: projectUserMessage(message) };
175
176
  else if (message.role === "assistant") yield* projectAssistantMessage(message);
176
177
  else if (message.role === "toolResult") yield projectToolResult(message);
177
- else throw new Error(`Codex settled-turn projection does not support role ${message.role}`);
178
+ else throw new CodexHistoryRejection("unsupported_content");
178
179
  }
179
180
  /** Consumes complete evidence or rejects at the existing limits, never truncating its history. */
180
181
  function projectSettledCodexMessages(messages) {
@@ -184,41 +185,30 @@ function projectSettledCodexMessages(messages) {
184
185
  let bytes = 0;
185
186
  for (const message of messages) for (const { item, call, result } of projectMessage(message)) {
186
187
  if (call) {
187
- if (calls.has(call.id)) throw new Error("Codex settled-turn projection found a duplicate tool call");
188
+ if (calls.has(call.id)) throw new CodexHistoryRejection("invalid_pairing");
188
189
  calls.set(call.id, call.name);
189
190
  }
190
191
  if (result) {
191
- if (calls.get(result.id) !== result.name || results.has(result.id)) throw new Error("Codex settled-turn projection found an ambiguous tool transcript");
192
+ if (calls.get(result.id) !== result.name || results.has(result.id)) throw new CodexHistoryRejection("invalid_pairing");
192
193
  results.add(result.id);
193
194
  }
194
- if (items.length === MAX_RESPONSE_ITEMS) throw new Error("Codex settled-turn projection exceeds the item limit");
195
+ if (items.length === MAX_RESPONSE_ITEMS) throw new CodexHistoryRejection("item_limit");
195
196
  bytes += responseItemBytes(item);
196
- if (bytes > MAX_PROJECTION_BYTES) throw new Error("Codex settled-turn projection exceeds the byte limit");
197
+ if (bytes > MAX_PROJECTION_BYTES) throw new CodexHistoryRejection("byte_limit");
197
198
  items.push(item);
198
199
  }
199
- if (calls.size !== results.size) throw new Error("Codex settled-turn projection found an incomplete tool transcript");
200
- if (results.size === 0) throw new Error("Codex settled-turn projection found no completed tool result");
200
+ if (calls.size !== results.size) throw new CodexHistoryRejection("incomplete_pairing");
201
+ if (results.size === 0) throw new CodexHistoryRejection("incomplete_pairing");
201
202
  return items;
202
203
  }
203
204
  //#endregion
204
- //#region extensions/codex/src/app-server/settled-turn-context.ts
205
- function freezeProjection(value) {
206
- if (value !== null && typeof value === "object") {
207
- for (const child of Object.values(value)) freezeProjection(child);
208
- Object.freeze(value);
209
- }
210
- }
211
- /** Only the Codex owner interprets this bounded, detached replay projection. */
212
- var CodexSettledTurnContext = class {
213
- constructor(data) {
214
- this.data = data;
215
- this.source = "harness";
216
- freezeProjection(data);
217
- Object.freeze(this);
218
- }
219
- };
205
+ //#region extensions/codex/src/app-server/settled-turn-evidence.ts
220
206
  function rejectEvidence() {
221
- throw new Error("Codex settled-turn transcript does not match the settled turn");
207
+ throw new CodexHistoryRejection("provenance_rejected");
208
+ }
209
+ /** The worker consumes this verifier lazily; rejection never acquires the remaining payloads. */
210
+ function projectVerifiedSettledCodexMessages(history, params) {
211
+ return projectSettledCodexMessages(verifiedSettledMessages(history, params));
222
212
  }
223
213
  /** Yields only the settled prefix, but exhausts suffix identity checks before accepting it. */
224
214
  function* verifiedSettledMessages(history, params) {
@@ -252,17 +242,33 @@ function* verifiedSettledMessages(history, params) {
252
242
  }
253
243
  if (!throughBoundary || matched !== requiredIds.length) rejectEvidence();
254
244
  }
255
- /** Verifies and freezes a complete replay projection while reading the active branch. */
256
- async function captureCodexSettledTurnFinalizationContext(params) {
257
- try {
258
- return await readCodexMirroredSessionHistory(params, (messages) => new CodexSettledTurnContext(projectSettledCodexMessages(verifiedSettledMessages(messages, params))));
259
- } catch (error) {
260
- embeddedAgentLog.warn("codex settled-turn finalization context capture failed", {
261
- error: formatErrorMessage(error),
262
- turnId: params.turnId
263
- });
264
- return;
245
+ //#endregion
246
+ //#region extensions/codex/session-history.worker.ts
247
+ const codexHistoryWorkerUrl = new URL(import.meta.url);
248
+ async function runCodexHistoryWorkerInput(input) {
249
+ const request = input;
250
+ let version;
251
+ const onSnapshot = (value) => {
252
+ version = value;
253
+ };
254
+ if (request.kind === "messages") {
255
+ const result = await readCodexNativeHistory(request.target, request.sessionId, (messages) => Array.from(messages), request.admission, onSnapshot);
256
+ return {
257
+ kind: request.kind,
258
+ result,
259
+ version
260
+ };
261
+ }
262
+ if (request.kind === "settled") {
263
+ const result = await readCodexNativeHistory(request.target, request.sessionId, (messages) => projectVerifiedSettledCodexMessages(messages, request.evidence), request.admission, onSnapshot);
264
+ return {
265
+ kind: request.kind,
266
+ result,
267
+ version
268
+ };
265
269
  }
270
+ throw new Error("Invalid Codex history worker operation");
266
271
  }
272
+ serveWorkerTasks(runCodexHistoryWorkerInput);
267
273
  //#endregion
268
- export { captureCodexSettledTurnFinalizationContext as n, CodexSettledTurnContext as t };
274
+ export { runCodexHistoryWorkerInput as n, codexHistoryWorkerUrl as t };
@@ -0,0 +1,2 @@
1
+ import { n as runCodexHistoryWorkerInput, t as codexHistoryWorkerUrl } from "./session-history.worker-CNEvGaU5.js";
2
+ export { codexHistoryWorkerUrl, runCodexHistoryWorkerInput };
@@ -1,4 +1,5 @@
1
- import { p as validateBindingForWrite } from "./session-binding-BHuTCRZQ.js";
1
+ import { d as validateBindingForWrite } from "./session-binding-record-CaZjYwNS.js";
2
+ import "./session-binding-CKSepwIC.js";
2
3
  import { isDeepStrictEqual } from "node:util";
3
4
  import { deleteSessionUpstreamLink, upsertSessionUpstreamLink } from "openclaw/plugin-sdk/session-catalog";
4
5
  //#region extensions/codex/src/app-server/session-initialization.ts
@@ -1,11 +1,11 @@
1
- import { S as selectUserApprovalsReviewer, _ as parseAllowedApprovalsReviewersFromCodexRequirements, b as selectGuardianApprovalPolicy, g as parseAllowedApprovalPoliciesFromCodexRequirements, k as selectGuardianSandbox, m as canUseCodexModelBackedApprovalsReviewerForModel, u as resolveCodexAppServerNetworkProxy, v as parseAllowedSandboxModesFromCodexRequirements, x as selectGuardianApprovalsReviewer } from "./config-BhmfC1s6.js";
2
- import { isPathInside } from "openclaw/plugin-sdk/file-access-runtime";
1
+ import { C as selectUserApprovalsReviewer, S as selectGuardianApprovalsReviewer, _ as parseAllowedApprovalPoliciesFromCodexRequirements, l as resolveCodexAppServerNetworkProxy, v as parseAllowedApprovalsReviewersFromCodexRequirements, w as selectGuardianSandbox, x as selectGuardianApprovalPolicy, y as parseAllowedSandboxModesFromCodexRequirements } from "./config-options-jnIFvwxD.js";
2
+ import { t as canUseCodexModelBackedApprovalsReviewerForModel } from "./config-JDfTI4VI.js";
3
3
  import { hostname } from "node:os";
4
+ import { isPathInside } from "openclaw/plugin-sdk/file-access-runtime";
4
5
  //#region extensions/codex/src/app-server/app-server-policy.ts
5
6
  function resolveCodexAppServerForModelProvider(params) {
6
- const explicitProvider = normalizeModelBackedReviewerProvider(params.provider);
7
7
  if (!isCodexModelBackedApprovalsReviewer(params.appServer.approvalsReviewer) || canUseCodexModelBackedApprovalsReviewerForModel({
8
- modelProvider: explicitProvider,
8
+ modelProvider: params.provider,
9
9
  model: params.model,
10
10
  config: params.config,
11
11
  env: {
@@ -25,9 +25,6 @@ function resolveCodexAppServerForModelProvider(params) {
25
25
  function isCodexModelBackedApprovalsReviewer(value) {
26
26
  return value === "auto_review" || value === "guardian_subagent";
27
27
  }
28
- function normalizeModelBackedReviewerProvider(provider) {
29
- return provider?.trim().toLowerCase() || void 0;
30
- }
31
28
  //#endregion
32
29
  //#region extensions/codex/src/app-server/session-permission-policy.ts
33
30
  const CODEX_SESSION_PERMISSION_EXEC_MODES = {
@@ -1,8 +1,9 @@
1
- import { Et as isCodexAppServerLiveThreadClaimed, _ as retainSharedCodexAppServerClientByInstanceId, kt as releaseCodexAppServerLiveThread, wt as hasCodexAppServerLiveThread } from "./shared-client-DxcfF9KX.js";
2
- import { a as closeCodexStartupClientBestEffort, d as unsubscribeCodexThreadBestEffort, n as CODEX_APP_SERVER_UNSUBSCRIBE_TIMEOUT_MS, r as CodexAppServerUnsafeSubscriptionError } from "./attempt-client-cleanup-DYHcRQAa.js";
3
- import { l as isIncognitoSessionKey, o as withCodexAppServerThreadMutation, t as isSameCodexAppServerThreadOwner } from "./thread-ownership-zGokd8i1.js";
4
- import { t as getCodexSessionInitializationRollback } from "./session-initialization-BeWzjGiR.js";
5
- import { t as codexNativeSubagentMonitorRuntime } from "./native-subagent-monitor-CnH147jH.js";
1
+ import { n as withCodexAppServerThreadMutation, t as isIncognitoSessionKey } from "./incognito-session-uhrBF6wJ.js";
2
+ import { L as hasCodexAppServerLiveThread, U as releaseCodexAppServerLiveThread, _ as retainSharedCodexAppServerClientByInstanceId, z as isCodexAppServerLiveThreadClaimed } from "./shared-client-CVhez2Uo.js";
3
+ import { a as closeCodexStartupClientBestEffort, d as unsubscribeCodexThreadBestEffort, n as CODEX_APP_SERVER_UNSUBSCRIBE_TIMEOUT_MS, r as CodexAppServerUnsafeSubscriptionError } from "./attempt-client-cleanup-D6cR54TV.js";
4
+ import { t as isSameCodexAppServerThreadOwner } from "./thread-ownership-D6oASVRu.js";
5
+ import { t as codexNativeSubagentMonitorRuntime } from "./native-subagent-monitor-BbCUKRwC.js";
6
+ import { t as getCodexSessionInitializationRollback } from "./session-initialization-Jo86C60I.js";
6
7
  //#region extensions/codex/src/app-server/session-retirement.ts
7
8
  async function releaseSessionSubscription(client, binding, sessionKey, assertCurrent) {
8
9
  assertCurrent?.();
@@ -76,10 +77,10 @@ async function withCodexAppServerSessionDeletion(bindingStore, params, run) {
76
77
  /** Retire binding and native subscription under the same generation/physical-client ownership fence. */
77
78
  async function retireCodexAppServerSessionGeneration(params) {
78
79
  const retireGeneration = () => params.mode === "reset" ? params.bindingStore.resetSessionGeneration(params.identity) : params.bindingStore.retireSessionGeneration(params.identity);
79
- const expectedBinding = await params.bindingStore.read(params.identity);
80
+ const expectedBinding = params.bindingStore.read(params.identity);
80
81
  if (!expectedBinding) return await retireGeneration();
81
82
  return await withCodexAppServerThreadMutation(expectedBinding.threadId, () => params.bindingStore.withLease(params.identity, async () => {
82
- const binding = await params.bindingStore.read(params.identity);
83
+ const binding = params.bindingStore.read(params.identity);
83
84
  if (!binding || !isSameCodexAppServerThreadOwner(binding, expectedBinding)) return "conflict";
84
85
  const result = await retireGeneration();
85
86
  if (result !== "applied" || !binding?.clientId) return result;