@openclaw/codex 2026.9.2 → 2026.9.4

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 (120) hide show
  1. package/README.md +2 -0
  2. package/dist/api.js +29 -26
  3. package/dist/apply-CvT8tW5i.js +356 -0
  4. package/dist/{attempt-client-cleanup-Bp1ZOnk2.js → attempt-client-cleanup-DKHzbwt5.js} +38 -214
  5. package/dist/{attempt-context-CSazkWns.js → attempt-context-D44yeDII.js} +9 -7
  6. package/dist/{event-projector-usage-ZqEVbAEY.js → attempt-notifications-C9XufG6l.js} +3 -106
  7. package/dist/{auth-binding-Ds_QVm-X.js → auth-binding-CWlKVccJ.js} +2 -2
  8. package/dist/auth-cache-key-7orQae_j.js +498 -0
  9. package/dist/auth-profile-CwzO4_RG.js +43 -0
  10. package/dist/auth-profile-selection-DFu9e167.js +45 -0
  11. package/dist/binding-connection-D3udKbIE.js +60 -0
  12. package/dist/{bounded-turn-DxGJRYbY.js → bounded-turn-C_Hneydj.js} +28 -125
  13. package/dist/build-state-BCmg9-5p.js +19 -0
  14. package/dist/{capabilities-B1mgvpP8.js → capabilities-8vx68WLH.js} +1 -1
  15. package/dist/cli-metadata.js +1 -1
  16. package/dist/client-B57KWPQx.js +4005 -0
  17. package/dist/command-dispatch-BpduNGVf.js +21 -0
  18. package/dist/{command-formatters-DSbGMXA0.js → command-formatters-lxlkNZgU.js} +4 -3
  19. package/dist/{command-handlers-DOJvGv6-.js → command-handlers-tiL9iWj7.js} +788 -135
  20. package/dist/command-rpc-CR5EOEZX.js +233 -0
  21. package/dist/{compact-Y_xBqrHN.js → compact-B_H3AOd7.js} +19 -14
  22. package/dist/config-oIORaQ5T.js +106 -0
  23. package/dist/{config-CyapYSji.js → config-options-CXMq1T-C.js} +205 -593
  24. package/dist/config-runtime-D0zGNIHu.js +11 -0
  25. package/dist/{config-utils-C57JiJrU.js → config-utils-DujwEnhg.js} +2 -4
  26. package/dist/conversation-binding-DsB4-O7U.js +900 -0
  27. package/dist/{plugin-marketplace-discovery-B7gHXJ3d.js → conversation-control-CtUu1b3m.js} +11 -143
  28. package/dist/doctor-contract-api.js +5 -5
  29. package/dist/{dynamic-tools-BwpvTxaX.js → dynamic-tools-CmN5RAip.js} +133 -76
  30. package/dist/{effective-mcp-catalog-CY9Jn4bA.js → effective-mcp-catalog-Bd73bqA8.js} +3 -3
  31. package/dist/{elicitation-input-DMkeki8d.js → elicitation-input-DPoK8F7w.js} +8 -22
  32. package/dist/ephemeral-turn-D78_VmzO.js +101 -0
  33. package/dist/{event-projector-assistant-message-B9kp6iGC.js → event-projector-assistant-message-BmBM4qBV.js} +12 -25
  34. package/dist/event-projector-items-5VhsECCO.js +200 -0
  35. package/dist/event-projector-usage-BfXmpOec.js +102 -0
  36. package/dist/{harness-Czh2Sdoc.js → harness-C7rRa7bm.js} +48 -24
  37. package/dist/harness.js +1 -1
  38. package/dist/history-rejection-B4nOXNXF.js +13 -0
  39. package/dist/incognito-session-uhrBF6wJ.js +15 -0
  40. package/dist/index.js +406 -2915
  41. package/dist/inference-context-Dr_mzvk4.js +94 -0
  42. package/dist/inference-proxy-HGXKUIre.js +311 -0
  43. package/dist/{isolated-completion-CRh-51AK.js → isolated-completion-DWVb5U2J.js} +7 -4
  44. package/dist/launch-args-RXQwn8zV.js +90 -0
  45. package/dist/{managed-binary-DcpnJF9x.js → managed-binary-D22rNEcR.js} +13 -103
  46. package/dist/managed-thread-store-D1t5jh3G.js +66 -0
  47. package/dist/media-understanding-provider.js +4 -1
  48. package/dist/migration-provider-api.js +2 -0
  49. package/dist/{model-catalog-DT5vo6qo.js → model-catalog-Dq2n8f_p.js} +6 -5
  50. package/dist/{models-CcrgSMQR.js → models-PCKOim-h.js} +3 -3
  51. package/dist/native-execution-policy-umd0tgh4.js +128 -0
  52. package/dist/native-subagent-history-DjtPloaU.js +140 -0
  53. package/dist/native-subagent-history-owner-Pcp7JuVF.js +34 -0
  54. package/dist/{native-subagent-monitor-B3bvQGcg.js → native-subagent-monitor-fQ7eIXEf.js} +115 -460
  55. package/dist/native-subagent-task-ids-BzTdT0Uw.js +387 -0
  56. package/dist/node-cli-sessions-DKaOmVUh.js +527 -0
  57. package/dist/{node-exec-server.runtime-nfbUOtUB.js → node-exec-server.runtime-Cl2vapEi.js} +55 -24
  58. package/dist/plan-7uG-Fp36.js +947 -0
  59. package/dist/plugin-activation-BYQculil.js +138 -0
  60. package/dist/{thread-resume-BLgqkUc1.js → plugin-app-cache-key-d0eKxy7b.js} +4 -52
  61. package/dist/{plugin-approval-roundtrip-aQVdyL5g.js → plugin-approval-roundtrip-Bz3FT8W5.js} +1 -1
  62. package/dist/plugin-inventory-oL4Na1ZG.js +328 -0
  63. package/dist/plugin-marketplace-discovery-P-Vndfqq.js +137 -0
  64. package/dist/{plugin-metadata-cache-BwCLTY_U.js → plugin-metadata-cache-ClPJpRio.js} +17 -9
  65. package/dist/protocol-5bh1G-H7.js +275 -0
  66. package/dist/provider-MQ8PVkuE.js +50 -0
  67. package/dist/{provider-capabilities-BpG9Ltc5.js → provider-capabilities-BvCUL69A.js} +2 -2
  68. package/dist/{rate-limits-Fx_l4eNa.js → rate-limits-CBMmWBr9.js} +1 -1
  69. package/dist/request-B7hEkBGq.js +212 -0
  70. package/dist/rpc-error-ttN_QjEm.js +30 -0
  71. package/dist/{run-attempt-BzthFQSM.js → run-attempt-CvsAAGa0.js} +664 -377
  72. package/dist/{runtime-artifact-Bh_gf6-t.js → runtime-artifact-BJ0rXBZ_.js} +27 -27
  73. package/dist/sandbox-guard-BxgyoM8M.js +166 -0
  74. package/dist/{session-binding-4Ki04sW-.js → session-binding-CI8UuilT.js} +30 -48
  75. package/dist/{session-binding-record-CyaXZvTe.js → session-binding-record-Bcvslnhf.js} +12 -26
  76. package/dist/session-catalog-adoption-tcZi1IfX.js +251 -0
  77. package/dist/session-catalog-archive-CwKg8Xz2.js +56 -0
  78. package/dist/session-catalog-ct-AH01I.js +1477 -0
  79. package/dist/session-catalog-home-id-CwhLdC03.js +18 -0
  80. package/dist/session-catalog-node-adoption-B1tgDW-m.js +182 -0
  81. package/dist/session-catalog-node-continue-Ci-DXyJP.js +238 -0
  82. package/dist/session-catalog-provenance-D-dIfRAH.js +96 -0
  83. package/dist/{session-cli-BjLhpmS1.js → session-cli-DNN_jhGc.js} +3 -2
  84. package/dist/{session-history-DWmMqiqW.js → session-history-Cz-tOOYj.js} +6 -3
  85. package/dist/{session-upstream-marker-DReTpGz6.js → session-history-import-DwyijFI6.js} +5 -50
  86. package/dist/{session-history-read-LHldwvyh.js → session-history-read-cxPUxyVV.js} +21 -7
  87. package/dist/session-history-worker-runtime.js +18 -6
  88. package/dist/session-history.worker-BeK1YOyT.js +378 -0
  89. package/dist/session-history.worker.js +1 -1
  90. package/dist/{session-initialization-BCFVnLL4.js → session-initialization-Ct0_Hzmg.js} +2 -2
  91. package/dist/{session-permission-policy-BaueHmSj.js → session-permission-policy-BBmXA8Eg.js} +4 -7
  92. package/dist/{session-retirement-DNdmYdFc.js → session-retirement-B2YfbAAT.js} +6 -5
  93. package/dist/session-upstream-marker-D15C9NHp.js +46 -0
  94. package/dist/{settled-turn-context-BOM3Y1pl.js → settled-turn-context-Du6gdUDd.js} +9 -9
  95. package/dist/{settled-turn-finalizer-BI-b1sry.js → settled-turn-finalizer-Dn91stmc.js} +8 -7
  96. package/dist/shared-client-CscigXXL.js +3109 -0
  97. package/dist/{side-question-B6DWAw1A.js → side-question-BGMJQf4U.js} +65 -170
  98. package/dist/source-CElXU0Oy.js +518 -0
  99. package/dist/thread-archive-guard-DfpBr-Sz.js +53 -0
  100. package/dist/thread-history-page-D0JIp48V.js +361 -0
  101. package/dist/{thread-lifecycle-DPK30jad.js → thread-lifecycle-DXl1-I6b.js} +187 -639
  102. package/dist/{thread-ownership-CbucAmmp.js → thread-ownership-BsDRTsyp.js} +13 -15
  103. package/dist/thread-policy-BuEQfE0g.js +54 -0
  104. package/dist/thread-resume-DsDOZpFg.js +52 -0
  105. package/dist/timeout-BVw8aaM1.js +33 -0
  106. package/dist/transcript-history-projection-v17wXgdK.js +238 -0
  107. package/dist/{transcript-mirror-_njEB84z.js → transcript-mirror-C5CKgNy6.js} +50 -260
  108. package/dist/{transcript-mirror-attestation-Byl34PC-.js → transcript-mirror-attestation-DibE0krH.js} +17 -4
  109. package/dist/{transport-stdio-CzTngV0j.js → transport-stdio-BGjHoYLr.js} +73 -43
  110. package/dist/{upstream-session-fork-1fwbNKzQ.js → upstream-session-fork-BZerMte_.js} +27 -19
  111. package/dist/{usage-i9fv5-4m.js → usage-tCk-mg_x.js} +4 -3
  112. package/dist/version-omm6IPI3.js +12 -0
  113. package/dist/{web-search-provider.runtime-DKQn67A7.js → web-search-provider.runtime-B7bGbGWq.js} +3 -3
  114. package/openclaw.plugin.json +23 -1
  115. package/package.json +4 -4
  116. package/dist/request-C8H22rPi.js +0 -475
  117. package/dist/session-catalog-B47uwekb.js +0 -3272
  118. package/dist/session-history.worker-zZVcx0ME.js +0 -267
  119. package/dist/shared-client-CKhX2kFt.js +0 -7505
  120. package/dist/thread-policy-CTalhWFy.js +0 -105
@@ -1,196 +1,11 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
1
2
  import { i as readUpstreamUserText, n as attachUpstreamUserText, r as readMirrorIdentity, t as attachCodexMirrorIdentity } from "./upstream-prompt-provenance-LphB8slG.js";
2
- import { i as fingerprintCodexMirrorSourceMessage, n as attachCodexMirrorAttestation, o as readCodexMirrorSourceFingerprint, r as attachCodexMirrorRunId } from "./transcript-mirror-attestation-Byl34PC-.js";
3
+ import { t as projectBoundedCodexThreadHistory } from "./transcript-history-projection-v17wXgdK.js";
4
+ import { a as fingerprintCodexMirrorSourceMessage, c as readCodexMirrorSourceFingerprint, i as buildCodexMirrorDedupeIdentity, n as attachCodexMirrorAttestation, r as attachCodexMirrorRunId, s as isMirroredAgentMessage, t as applyCodexTranscriptTaint } from "./transcript-mirror-attestation-DibE0krH.js";
3
5
  import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
4
- import { createHash } from "node:crypto";
5
- import path from "node:path";
6
6
  import { deliverAgentHarnessUserInputPrompt, embeddedAgentLog, formatErrorMessage, projectAgentHarnessTranscriptMessageForDisplay, restorePreparedUserTurnOperationalMetaForRuntime, runAgentHarnessBeforeMessageWriteHook } from "openclaw/plugin-sdk/agent-harness-runtime";
7
- import fsSync from "node:fs";
8
- import { truncateUtf8Prefix } from "openclaw/plugin-sdk/text-utility-runtime";
9
7
  import { withCodexSessionTranscriptMirrorWriteLock } from "openclaw/plugin-sdk/codex-session-transcript-runtime";
10
8
  import { publishSessionTranscriptUpdateByIdentity } from "openclaw/plugin-sdk/session-transcript-runtime";
11
- import { Buffer } from "node:buffer";
12
- //#region extensions/codex/src/session-catalog-home-id.ts
13
- function canonicalCodexCatalogHome(value) {
14
- const resolved = path.resolve(value);
15
- try {
16
- return fsSync.realpathSync.native(resolved);
17
- } catch {
18
- return resolved;
19
- }
20
- }
21
- /** One canonical identity for catalog discovery and durable ownership rows. */
22
- function codexCatalogHomeId(codexHome) {
23
- return createHash("sha256").update("openclaw:codex-session-catalog-home:v1\0").update(canonicalCodexCatalogHome(codexHome)).digest("hex");
24
- }
25
- //#endregion
26
- //#region extensions/codex/src/app-server/transcript-history-projection.ts
27
- const CODEX_HISTORY_IMPORT_MAX_MESSAGES = 200;
28
- const CODEX_HISTORY_IMPORT_MAX_BYTES = 524288;
29
- const CODEX_HISTORY_IMPORT_MAX_MESSAGE_BYTES = 65536;
30
- const CODEX_HISTORY_TRUNCATION_SUFFIX = "\n\n[Message truncated during Codex history import.]";
31
- const CODEX_HISTORY_ASSISTANT_API = "openai-chatgpt-responses";
32
- const CODEX_HISTORY_ASSISTANT_PROVIDER = "openai";
33
- const CODEX_HISTORY_ASSISTANT_MODEL = "native-history";
34
- const CODEX_HISTORY_ZERO_USAGE = {
35
- input: 0,
36
- output: 0,
37
- cacheRead: 0,
38
- cacheWrite: 0,
39
- totalTokens: 0,
40
- cost: {
41
- input: 0,
42
- output: 0,
43
- cacheRead: 0,
44
- cacheWrite: 0,
45
- total: 0
46
- }
47
- };
48
- function normalizeImportedHistoryText(value) {
49
- if (typeof value !== "string") return;
50
- const text = value.trim();
51
- if (!text) return;
52
- if (Buffer.byteLength(text, "utf8") <= CODEX_HISTORY_IMPORT_MAX_MESSAGE_BYTES) return text;
53
- const suffixBytes = Buffer.byteLength(CODEX_HISTORY_TRUNCATION_SUFFIX, "utf8");
54
- const contentLimitBytes = Math.max(0, CODEX_HISTORY_IMPORT_MAX_MESSAGE_BYTES - suffixBytes);
55
- return `${truncateUtf8Prefix(text, contentLimitBytes)}${CODEX_HISTORY_TRUNCATION_SUFFIX}`;
56
- }
57
- function projectCodexUserItemText(item) {
58
- if (!Array.isArray(item.content)) return;
59
- const parts = [];
60
- for (const value of item.content) {
61
- if (!value || typeof value !== "object" || Array.isArray(value)) continue;
62
- const input = value;
63
- if (input.type === "text") {
64
- const text = normalizeImportedHistoryText(input.text);
65
- if (text) parts.push(text);
66
- continue;
67
- }
68
- if (input.type === "image" || input.type === "localImage") {
69
- parts.push("[Image attachment]");
70
- continue;
71
- }
72
- if (input.type === "audio" || input.type === "localAudio" || input.type === "local_audio") parts.push("[Audio attachment]");
73
- if (input.type === "skill" || input.type === "mention") {
74
- const name = normalizeOptionalString(input.name);
75
- if (name) parts.push(`${input.type === "skill" ? "$" : "@"}${name}`);
76
- }
77
- }
78
- return normalizeImportedHistoryText(parts.join("\n"));
79
- }
80
- function selectTurnsThroughBoundary(thread, throughTurnId) {
81
- if (throughTurnId === null) return [];
82
- const turns = thread.turns ?? [];
83
- const boundaryIndex = turns.findIndex((turn) => turn.id === throughTurnId);
84
- if (boundaryIndex < 0) throw new Error(`Codex history boundary turn not found: ${throughTurnId}`);
85
- const boundary = turns[boundaryIndex];
86
- if (boundary?.status !== "completed" && boundary?.status !== "interrupted" && boundary?.status !== "failed") throw new Error(`Codex history boundary turn is not terminal: ${throughTurnId}`);
87
- return turns.slice(0, boundaryIndex + 1);
88
- }
89
- function projectCodexThreadHistory(params) {
90
- const projected = [];
91
- const threadTimestamp = typeof params.thread.createdAt === "number" && Number.isFinite(params.thread.createdAt) ? params.thread.createdAt * 1e3 : params.importedAt;
92
- let itemOffset = 0;
93
- for (const turn of selectTurnsThroughBoundary(params.thread, params.throughTurnId)) for (const value of turn.items) {
94
- const item = value;
95
- const itemId = normalizeOptionalString(item.id);
96
- const identity = `${turn.id}:${itemId ?? itemOffset}`;
97
- const timestampSeconds = item.type === "agentMessage" ? turn.completedAt ?? turn.startedAt : turn.startedAt ?? turn.completedAt;
98
- const timestamp = typeof timestampSeconds === "number" && Number.isFinite(timestampSeconds) ? timestampSeconds * 1e3 + itemOffset : threadTimestamp + itemOffset;
99
- const text = item.type === "userMessage" ? projectCodexUserItemText(item) : item.type === "agentMessage" ? normalizeImportedHistoryText(item.text) : void 0;
100
- const role = item.type === "userMessage" ? "user" : item.type === "agentMessage" ? "assistant" : void 0;
101
- itemOffset += 1;
102
- if (!text || !role) continue;
103
- const phase = item.phase === "commentary" || item.phase === "final_answer" ? item.phase : void 0;
104
- const asyncDelivery = item.delivery === "async";
105
- const message = role === "assistant" ? attachCodexMirrorIdentity({
106
- role,
107
- content: [{
108
- type: "text",
109
- text
110
- }],
111
- api: CODEX_HISTORY_ASSISTANT_API,
112
- provider: normalizeOptionalString(params.modelProvider) ?? normalizeOptionalString(params.thread.modelProvider) ?? CODEX_HISTORY_ASSISTANT_PROVIDER,
113
- model: CODEX_HISTORY_ASSISTANT_MODEL,
114
- usage: CODEX_HISTORY_ZERO_USAGE,
115
- stopReason: turn.status === "interrupted" ? "aborted" : turn.status === "failed" ? "error" : "stop",
116
- ...turn.status === "failed" && turn.error?.message ? { errorMessage: turn.error.message } : {},
117
- ...phase ? { phase } : {},
118
- ...asyncDelivery && itemId ? { openclawAsyncDelivery: { itemId } } : {},
119
- timestamp
120
- }, identity) : attachCodexMirrorIdentity({
121
- role,
122
- content: text,
123
- timestamp
124
- }, identity);
125
- projected.push({
126
- message,
127
- responseItem: {
128
- type: "message",
129
- role,
130
- content: [{
131
- type: role === "assistant" ? "output_text" : "input_text",
132
- text
133
- }],
134
- ...role === "assistant" && phase ? { phase } : {}
135
- },
136
- textBytes: Buffer.byteLength(text, "utf8")
137
- });
138
- }
139
- return projected;
140
- }
141
- function selectBoundedCodexHistoryTail(projected) {
142
- const selected = [];
143
- let selectedBytes = 0;
144
- for (let index = projected.length - 1; index >= 0; index -= 1) {
145
- const candidate = projected[index];
146
- if (!candidate) continue;
147
- if (selected.length >= CODEX_HISTORY_IMPORT_MAX_MESSAGES || selectedBytes + candidate.textBytes > CODEX_HISTORY_IMPORT_MAX_BYTES) break;
148
- selected.push(candidate);
149
- selectedBytes += candidate.textBytes;
150
- }
151
- return selected.toReversed();
152
- }
153
- /** Projects one terminal Codex history prefix into transcript and Responses API items. */
154
- function projectBoundedCodexThreadHistory(params) {
155
- const projected = projectCodexThreadHistory({
156
- thread: params.thread,
157
- throughTurnId: params.throughTurnId,
158
- importedAt: params.importedAt,
159
- ...params.modelProvider ? { modelProvider: params.modelProvider } : {}
160
- });
161
- const selected = selectBoundedCodexHistoryTail(projected);
162
- return {
163
- importedMessages: selected.length,
164
- omittedMessages: projected.length - selected.length,
165
- responseItems: selected.filter(({ message }) => message.role !== "assistant" || message.stopReason !== "aborted" && message.stopReason !== "error" && !("openclawAsyncDelivery" in message)).map(({ responseItem }) => responseItem),
166
- transcriptMessages: selected.map(({ message }) => message)
167
- };
168
- }
169
- /** Projects only visible local user/assistant messages through the same bounded history policy. */
170
- function projectBoundedCodexVisibleSessionHistory(entries) {
171
- const projected = [];
172
- for (const entry of entries) {
173
- if (entry.role !== "user" && entry.role !== "assistant" || !("content" in entry.message)) continue;
174
- if (entry.role === "assistant" && ("stopReason" in entry.message && (entry.message.stopReason === "aborted" || entry.message.stopReason === "error") || "openclawAsyncDelivery" in entry.message)) continue;
175
- const content = entry.message.content;
176
- const text = normalizeImportedHistoryText(typeof content === "string" ? content : Array.isArray(content) ? content.flatMap((part) => part && typeof part === "object" && "text" in part && typeof part.text === "string" ? [part.text] : []).join("\n") : void 0);
177
- if (!text) continue;
178
- projected.push({
179
- message: entry.message,
180
- responseItem: {
181
- type: "message",
182
- role: entry.role,
183
- content: [{
184
- type: entry.role === "assistant" ? "output_text" : "input_text",
185
- text
186
- }]
187
- },
188
- textBytes: Buffer.byteLength(text, "utf8")
189
- });
190
- }
191
- return selectBoundedCodexHistoryTail(projected).map(({ responseItem }) => responseItem);
192
- }
193
- //#endregion
194
9
  //#region extensions/codex/src/app-server/user-prompt-message.ts
195
10
  function buildSenderLabel(params) {
196
11
  const label = params.senderName ?? params.senderUsername ?? params.senderE164 ?? params.senderId;
@@ -249,12 +64,15 @@ async function resolveFinalCodexMirrorMessages(params) {
249
64
  }
250
65
  //#endregion
251
66
  //#region extensions/codex/src/app-server/transcript-mirror.ts
252
- function isMirroredAgentMessage(message) {
253
- return message.role === "user" || message.role === "assistant" || message.role === "toolResult";
254
- }
67
+ var transcript_mirror_exports = /* @__PURE__ */ __exportAll({
68
+ codexTranscriptMirrorRuntime: () => codexTranscriptMirrorRuntime,
69
+ createCodexAppServerUserMessagePersistenceNotifier: () => createCodexAppServerUserMessagePersistenceNotifier,
70
+ importCodexThreadHistoryToTranscript: () => importCodexThreadHistoryToTranscript,
71
+ mirrorPromptAtTurnStartBestEffort: () => mirrorPromptAtTurnStartBestEffort,
72
+ projectBoundedCodexThreadHistory: () => projectBoundedCodexThreadHistory
73
+ });
255
74
  function readMirroredAssistantText(message) {
256
- if (message?.role !== "assistant") return;
257
- return message.content.flatMap((part) => part.type === "text" ? [part.text] : []).join("\n") || void 0;
75
+ return message?.role === "assistant" ? message.content.flatMap((part) => part.type === "text" ? [part.text] : []).join("\n") || void 0 : void 0;
258
76
  }
259
77
  /** Imports a bounded, user-visible Codex history tail into a new OpenClaw transcript. */
260
78
  async function importCodexThreadHistoryToTranscript(params) {
@@ -303,9 +121,10 @@ async function mirrorBestEffort(params) {
303
121
  idempotencyScope: `codex-app-server:${params.threadId}`,
304
122
  runId: params.params.runId,
305
123
  runMirrorIdentityPrefix: `${params.turnId}:`,
306
- terminalAssistantOwner: {
124
+ terminalAssistantOwner: params.params.deferTerminalLifecycle && params.result.terminal.kind === "failed" ? void 0 : {
307
125
  mirrorIdentity: `${params.turnId}:assistant`,
308
- runId: params.params.runId
126
+ runId: params.params.runId,
127
+ settlementWarning: params.settlementWarning
309
128
  },
310
129
  prepareAssistantTranscriptMessage: params.params.prepareAssistantTranscriptMessage,
311
130
  config: params.params.config
@@ -406,27 +225,16 @@ async function mirrorPromptAtTurnStartBestEffort(params) {
406
225
  });
407
226
  }
408
227
  }
409
- function fingerprintMirrorMessageContent(message) {
410
- const payload = JSON.stringify({
411
- role: message.role,
412
- content: message.content
413
- });
414
- return createHash("sha256").update(payload).digest("hex").slice(0, 16);
415
- }
416
- function buildMirrorDedupeIdentity(message) {
417
- return readMirrorIdentity(message) || `${message.role}:${fingerprintMirrorMessageContent(message)}`;
418
- }
419
228
  async function mirror(params) {
420
229
  const messages = params.messages.filter(isMirroredAgentMessage);
421
230
  if (messages.length === 0) return {
422
- assistantMirrorIdentitiesAppended: [],
423
231
  assistantMirrorIdentitiesOwned: [],
424
232
  anchorsByMirrorIdentity: /* @__PURE__ */ new Map(),
425
233
  messagesPresent: [],
426
234
  userMessageReceipts: []
427
235
  };
428
236
  const candidates = messages.map((message) => {
429
- const dedupeIdentity = buildMirrorDedupeIdentity(message);
237
+ const dedupeIdentity = buildCodexMirrorDedupeIdentity(message);
430
238
  const sourceFingerprint = fingerprintCodexMirrorSourceMessage(message);
431
239
  return {
432
240
  dedupeIdentity,
@@ -448,19 +256,20 @@ async function mirror(params) {
448
256
  }, async (transcript) => {
449
257
  assertWritable();
450
258
  const nextAppendedUpdates = [];
451
- const nextAssistantMirrorIdentitiesAppended = /* @__PURE__ */ new Set();
452
259
  const nextAssistantMirrorIdentitiesOwned = /* @__PURE__ */ new Set();
453
260
  const nextAnchorsByMirrorIdentity = /* @__PURE__ */ new Map();
454
261
  const nextMessagesPresent = [];
455
262
  const nextUserMessageReceipts = [];
456
263
  const mirrorFacts = await transcript.readMessageFacts({ idempotencyKeys: candidateIdempotencyKeys });
457
264
  assertWritable();
265
+ const taint = { tainted: false };
458
266
  for (const { dedupeIdentity, idempotencyKey, message, sourceFingerprint } of candidates) {
267
+ const sourceMessage = applyCodexTranscriptTaint(message, taint);
459
268
  const mirrorIdentity = readMirrorIdentity(message);
460
269
  const ownsRun = Boolean(params.runId && (!params.runMirrorIdentityPrefix || mirrorIdentity?.startsWith(params.runMirrorIdentityPrefix)));
461
270
  const terminalOwner = params.terminalAssistantOwner;
462
271
  const ownsTerminal = Boolean(ownsRun && terminalOwner && mirrorIdentity === terminalOwner.mirrorIdentity);
463
- const ownedMessage = ownsRun && params.runId ? attachCodexMirrorRunId(message, params.runId, ownsTerminal) : message;
272
+ const ownedMessage = ownsRun && params.runId ? attachCodexMirrorRunId(sourceMessage, params.runId, ownsTerminal, terminalOwner?.settlementWarning) : sourceMessage;
464
273
  const transcriptMessage = {
465
274
  ...attachCodexMirrorAttestation(ownedMessage, sourceFingerprint),
466
275
  ...idempotencyKey ? { idempotencyKey } : {}
@@ -509,8 +318,9 @@ async function mirror(params) {
509
318
  idempotencyKey
510
319
  } : attachCodexMirrorAttestation(restoredMessage, sourceFingerprint);
511
320
  if (mirrorIdentity) messageToAppend = attachCodexMirrorIdentity(messageToAppend, mirrorIdentity);
512
- if (ownsRun && params.runId) messageToAppend = attachCodexMirrorRunId(messageToAppend, params.runId, ownsTerminal);
321
+ if (ownsRun && params.runId) messageToAppend = attachCodexMirrorRunId(messageToAppend, params.runId, ownsTerminal, terminalOwner?.settlementWarning);
513
322
  if (message.role === "assistant" && message.openclawAsyncDelivery) messageToAppend = Object.assign(messageToAppend, { openclawAsyncDelivery: { itemId: message.openclawAsyncDelivery.itemId } });
323
+ messageToAppend = applyCodexTranscriptTaint(messageToAppend, taint);
514
324
  messageToAppend = projectAgentHarnessTranscriptMessageForDisplay({
515
325
  hidden: message.display === false,
516
326
  message: messageToAppend
@@ -539,14 +349,11 @@ async function mirror(params) {
539
349
  appended: appended.appended,
540
350
  message: appendedMessage
541
351
  });
542
- if (appended.appended) {
543
- if (message.role === "assistant") nextAssistantMirrorIdentitiesAppended.add(dedupeIdentity);
544
- nextAppendedUpdates.push({
545
- messageId,
546
- message: appendedMessage,
547
- ...messageSeq !== void 0 ? { messageSeq } : {}
548
- });
549
- }
352
+ if (appended.appended) nextAppendedUpdates.push({
353
+ messageId,
354
+ message: appendedMessage,
355
+ ...messageSeq !== void 0 ? { messageSeq } : {}
356
+ });
550
357
  if (idempotencyKey) {
551
358
  mirrorFacts.existingIdempotencyKeys.add(idempotencyKey);
552
359
  if (appended.anchor) mirrorFacts.anchorsByIdempotencyKey.set(idempotencyKey, appended.anchor);
@@ -554,7 +361,6 @@ async function mirror(params) {
554
361
  }
555
362
  return {
556
363
  appendedUpdates: nextAppendedUpdates,
557
- assistantMirrorIdentitiesAppended: [...nextAssistantMirrorIdentitiesAppended],
558
364
  assistantMirrorIdentitiesOwned: [...nextAssistantMirrorIdentitiesOwned],
559
365
  anchorsByMirrorIdentity: nextAnchorsByMirrorIdentity,
560
366
  messagesPresent: nextMessagesPresent,
@@ -562,7 +368,7 @@ async function mirror(params) {
562
368
  };
563
369
  });
564
370
  params.assertCurrent?.();
565
- const { appendedUpdates, assistantMirrorIdentitiesAppended, assistantMirrorIdentitiesOwned, anchorsByMirrorIdentity, messagesPresent, userMessageReceipts } = mirrorBatch;
371
+ const { appendedUpdates, ...result } = mirrorBatch;
566
372
  for (const update of appendedUpdates) try {
567
373
  const terminalOwner = params.terminalAssistantOwner;
568
374
  const terminalRunId = update.message.role === "assistant" && terminalOwner && readMirrorIdentity(update.message) === terminalOwner.mirrorIdentity ? terminalOwner.runId : void 0;
@@ -580,13 +386,7 @@ async function mirror(params) {
580
386
  } catch (error) {
581
387
  embeddedAgentLog.warn("failed to publish codex app-server transcript update", { error: formatErrorMessage(error) });
582
388
  }
583
- return {
584
- assistantMirrorIdentitiesAppended,
585
- assistantMirrorIdentitiesOwned,
586
- anchorsByMirrorIdentity,
587
- messagesPresent,
588
- userMessageReceipts
589
- };
389
+ return result;
590
390
  }
591
391
  async function deliverAsyncMessageBestEffort(params) {
592
392
  const mirrorIdentity = `${params.turnId}:async:${params.itemId}`;
@@ -596,13 +396,22 @@ async function deliverAsyncMessageBestEffort(params) {
596
396
  params.itemId
597
397
  ].map(encodeURIComponent).join(":")}`;
598
398
  const target = params.params.sessionTarget;
599
- if (!target) {
600
- if (!params.params.onBlockReply) return "retry";
399
+ let text;
400
+ if (target) {
401
+ let result;
601
402
  try {
602
- await deliverAsyncBlockReply(params.params.onBlockReply, params.text, deliveryIntentId);
603
- return "settled";
403
+ result = await mirror({
404
+ agentId: target.agentId ?? params.params.agentId,
405
+ sessionId: target.sessionId ?? params.params.sessionId,
406
+ sessionKey: target.sessionKey ?? params.params.sessionKey,
407
+ storePath: target.storePath,
408
+ cwd: params.cwd,
409
+ config: params.params.config,
410
+ messages: [attachCodexMirrorIdentity(params.message, mirrorIdentity)],
411
+ idempotencyScope: `codex-app-server:${params.threadId}`
412
+ });
604
413
  } catch (error) {
605
- embeddedAgentLog.warn("failed to deliver codex async agent message", {
414
+ embeddedAgentLog.warn("failed to persist codex async agent message", {
606
415
  error: formatErrorMessage(error),
607
416
  itemId: params.itemId,
608
417
  runId: params.params.runId,
@@ -611,35 +420,16 @@ async function deliverAsyncMessageBestEffort(params) {
611
420
  });
612
421
  return "retry";
613
422
  }
423
+ if (!result.assistantMirrorIdentitiesOwned.includes(mirrorIdentity)) return "retry";
424
+ text = readMirroredAssistantText(result.messagesPresent.find((message) => readMirrorIdentity(message) === mirrorIdentity));
425
+ } else {
426
+ if (!params.params.onBlockReply) return "retry";
427
+ text = params.text;
614
428
  }
615
- let result;
616
- try {
617
- result = await mirror({
618
- agentId: target.agentId ?? params.params.agentId,
619
- sessionId: target.sessionId ?? params.params.sessionId,
620
- sessionKey: target.sessionKey ?? params.params.sessionKey,
621
- storePath: target.storePath,
622
- cwd: params.cwd,
623
- config: params.params.config,
624
- messages: [attachCodexMirrorIdentity(params.message, mirrorIdentity)],
625
- idempotencyScope: `codex-app-server:${params.threadId}`
626
- });
627
- } catch (error) {
628
- embeddedAgentLog.warn("failed to persist codex async agent message", {
629
- error: formatErrorMessage(error),
630
- itemId: params.itemId,
631
- runId: params.params.runId,
632
- threadId: params.threadId,
633
- turnId: params.turnId
634
- });
635
- return "retry";
636
- }
637
- if (!result.assistantMirrorIdentitiesOwned.includes(mirrorIdentity)) return "retry";
638
- const persistedText = readMirroredAssistantText(result.messagesPresent.find((message) => readMirrorIdentity(message) === mirrorIdentity));
639
- if (params.params.onBlockReply && persistedText !== void 0) try {
640
- await deliverAsyncBlockReply(params.params.onBlockReply, persistedText, deliveryIntentId);
429
+ if (params.params.onBlockReply && text !== void 0) try {
430
+ await deliverAsyncBlockReply(params.params.onBlockReply, text, deliveryIntentId);
641
431
  } catch (error) {
642
- embeddedAgentLog.warn("failed to deliver persisted codex async agent message", {
432
+ embeddedAgentLog.warn(target ? "failed to deliver persisted codex async agent message" : "failed to deliver codex async agent message", {
643
433
  error: formatErrorMessage(error),
644
434
  itemId: params.itemId,
645
435
  runId: params.params.runId,
@@ -670,4 +460,4 @@ function resolveCodexMirrorTranscriptTarget(params) {
670
460
  };
671
461
  }
672
462
  //#endregion
673
- export { buildCodexUserPromptMessage as a, projectBoundedCodexVisibleSessionHistory as c, codexCatalogHomeId as d, mirrorPromptAtTurnStartBestEffort as i, projectCodexUserItemText as l, createCodexAppServerUserMessagePersistenceNotifier as n, promptSnapshot as o, importCodexThreadHistoryToTranscript as r, projectBoundedCodexThreadHistory as s, codexTranscriptMirrorRuntime as t, canonicalCodexCatalogHome as u };
463
+ export { transcript_mirror_exports as a, mirrorPromptAtTurnStartBestEffort as i, createCodexAppServerUserMessagePersistenceNotifier as n, buildCodexUserPromptMessage as o, importCodexThreadHistoryToTranscript as r, promptSnapshot as s, codexTranscriptMirrorRuntime as t };
@@ -1,7 +1,19 @@
1
- import { i as readUpstreamUserText } from "./upstream-prompt-provenance-LphB8slG.js";
1
+ import { i as readUpstreamUserText, r as readMirrorIdentity } from "./upstream-prompt-provenance-LphB8slG.js";
2
2
  import { asOptionalRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
3
3
  import { createHash } from "node:crypto";
4
4
  //#region extensions/codex/src/app-server/transcript-mirror-attestation.ts
5
+ function isMirroredAgentMessage(message) {
6
+ return message.role === "user" || message.role === "assistant" || message.role === "toolResult";
7
+ }
8
+ function buildCodexMirrorDedupeIdentity(message) {
9
+ const identity = readMirrorIdentity(message);
10
+ if (identity) return identity;
11
+ const payload = JSON.stringify({
12
+ role: message.role,
13
+ content: message.content
14
+ });
15
+ return `${message.role}:${createHash("sha256").update(payload).digest("hex").slice(0, 16)}`;
16
+ }
5
17
  const MIRROR_ORIGIN_META_KEY = "mirrorOrigin";
6
18
  const MIRROR_SOURCE_FINGERPRINT_META_KEY = "mirrorSourceFingerprint";
7
19
  const CODEX_APP_SERVER_MIRROR_ORIGIN = "codex-app-server";
@@ -34,7 +46,7 @@ function attachCodexMirrorAttestation(message, sourceFingerprint) {
34
46
  }
35
47
  };
36
48
  }
37
- function attachCodexMirrorRunId(message, runId, terminal = false) {
49
+ function attachCodexMirrorRunId(message, runId, terminal = false, settlementWarning) {
38
50
  const existing = CODEX_META_KEY in message ? message[CODEX_META_KEY] : void 0;
39
51
  const { runTerminal: _staleTerminal, ...current } = asOptionalRecord(existing) ?? {};
40
52
  return {
@@ -42,7 +54,8 @@ function attachCodexMirrorRunId(message, runId, terminal = false) {
42
54
  [CODEX_META_KEY]: {
43
55
  ...current,
44
56
  runId,
45
- ...terminal ? { runTerminal: true } : {}
57
+ ...terminal ? { runTerminal: true } : {},
58
+ ...terminal && settlementWarning ? { settlementWarning } : {}
46
59
  }
47
60
  };
48
61
  }
@@ -73,4 +86,4 @@ function fingerprintCodexMirrorSourceMessage(message) {
73
86
  return createHash("sha256").update(serializeCodexMirrorSourceEvidence(message)).digest("hex").slice(0, 32);
74
87
  }
75
88
  //#endregion
76
- export { hasCodexMirrorOrigin as a, fingerprintCodexMirrorSourceMessage as i, attachCodexMirrorAttestation as n, readCodexMirrorSourceFingerprint as o, attachCodexMirrorRunId as r, serializeCodexMirrorSourceEvidence as s, applyCodexTranscriptTaint as t };
89
+ export { fingerprintCodexMirrorSourceMessage as a, readCodexMirrorSourceFingerprint as c, buildCodexMirrorDedupeIdentity as i, serializeCodexMirrorSourceEvidence as l, attachCodexMirrorAttestation as n, hasCodexMirrorOrigin as o, attachCodexMirrorRunId as r, isMirroredAgentMessage as s, applyCodexTranscriptTaint as t };