@openclaw/codex 2026.9.2 → 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 (108) hide show
  1. package/README.md +2 -0
  2. package/dist/api.js +14 -19
  3. package/dist/apply-B6el6hdO.js +357 -0
  4. package/dist/{attempt-client-cleanup-Bp1ZOnk2.js → attempt-client-cleanup-D6cR54TV.js} +39 -19
  5. package/dist/{attempt-context-CSazkWns.js → attempt-context-AO4DSjE0.js} +8 -6
  6. package/dist/{event-projector-usage-ZqEVbAEY.js → attempt-notifications--H8zXR5-.js} +3 -106
  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-QqgcPCgk.js +60 -0
  11. package/dist/{bounded-turn-DxGJRYbY.js → bounded-turn-lRpmZHFv.js} +25 -122
  12. package/dist/build-state-6RL6qohz.js +19 -0
  13. package/dist/{capabilities-B1mgvpP8.js → capabilities-BeqLPbtM.js} +1 -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-DSbGMXA0.js → command-formatters-DeTfrapr.js} +2 -2
  18. package/dist/{command-handlers-DOJvGv6-.js → command-handlers-BfIsJEuA.js} +31 -21
  19. package/dist/command-rpc-BMqRQOFX.js +226 -0
  20. package/dist/{compact-Y_xBqrHN.js → compact-CGJZ2rlb.js} +19 -14
  21. package/dist/config-JDfTI4VI.js +106 -0
  22. package/dist/{config-CyapYSji.js → config-options-jnIFvwxD.js} +204 -592
  23. package/dist/config-runtime-BWf6JLWG.js +11 -0
  24. package/dist/conversation-binding-CxOlHiix.js +889 -0
  25. package/dist/{plugin-marketplace-discovery-B7gHXJ3d.js → conversation-control-CUCrSIQI.js} +10 -142
  26. package/dist/doctor-contract-api.js +5 -5
  27. package/dist/{dynamic-tools-BwpvTxaX.js → dynamic-tools-D-JBoaLt.js} +66 -70
  28. package/dist/{effective-mcp-catalog-CY9Jn4bA.js → effective-mcp-catalog-J_5Ep5Um.js} +3 -3
  29. package/dist/{elicitation-input-DMkeki8d.js → elicitation-input-DPoK8F7w.js} +8 -22
  30. package/dist/ephemeral-turn-DSwzP8YY.js +101 -0
  31. package/dist/{event-projector-assistant-message-B9kp6iGC.js → event-projector-assistant-message-BmBM4qBV.js} +12 -25
  32. package/dist/event-projector-usage-CIyrYYid.js +102 -0
  33. package/dist/{harness-Czh2Sdoc.js → harness-FR6eQgyO.js} +31 -24
  34. package/dist/harness.js +1 -1
  35. package/dist/history-rejection-B4nOXNXF.js +13 -0
  36. package/dist/incognito-session-uhrBF6wJ.js +15 -0
  37. package/dist/index.js +411 -2875
  38. package/dist/{isolated-completion-CRh-51AK.js → isolated-completion-DHBefrzg.js} +7 -4
  39. package/dist/launch-args-RXQwn8zV.js +90 -0
  40. package/dist/{managed-binary-DcpnJF9x.js → managed-binary-DrjjRRUD.js} +4 -103
  41. package/dist/managed-thread-store-D1t5jh3G.js +66 -0
  42. package/dist/media-understanding-provider.js +4 -1
  43. package/dist/{model-catalog-DT5vo6qo.js → model-catalog-B_6M04Wo.js} +6 -5
  44. package/dist/{models-CcrgSMQR.js → models-P9k2qAof.js} +3 -3
  45. package/dist/native-execution-policy-umd0tgh4.js +128 -0
  46. package/dist/{native-subagent-monitor-B3bvQGcg.js → native-subagent-monitor-BbCUKRwC.js} +69 -42
  47. package/dist/node-cli-sessions-rj0ysJwM.js +527 -0
  48. package/dist/{node-exec-server.runtime-nfbUOtUB.js → node-exec-server.runtime-BY_ctYnT.js} +53 -22
  49. package/dist/plan-BMJdMOEF.js +711 -0
  50. package/dist/plugin-activation-BQK-f5sV.js +133 -0
  51. package/dist/{thread-resume-BLgqkUc1.js → plugin-app-cache-key-CdSQzWyX.js} +4 -52
  52. package/dist/{plugin-approval-roundtrip-aQVdyL5g.js → plugin-approval-roundtrip-DeW95wB5.js} +1 -1
  53. package/dist/plugin-inventory-CoRCzWW4.js +325 -0
  54. package/dist/plugin-marketplace-discovery-3akBizzF.js +134 -0
  55. package/dist/{plugin-metadata-cache-BwCLTY_U.js → plugin-metadata-cache-DgNfRAGA.js} +13 -9
  56. package/dist/protocol-CAAcVIKF.js +275 -0
  57. package/dist/{provider-capabilities-BpG9Ltc5.js → provider-capabilities-W4tfK5Y5.js} +2 -2
  58. package/dist/{rate-limits-Fx_l4eNa.js → rate-limits-Bqnx1N4z.js} +1 -1
  59. package/dist/request-CGvGOpeR.js +198 -0
  60. package/dist/{run-attempt-BzthFQSM.js → run-attempt-DwKds3DN.js} +589 -373
  61. package/dist/{runtime-artifact-Bh_gf6-t.js → runtime-artifact-T-NwqeSH.js} +27 -27
  62. package/dist/sandbox-guard-BcT66fWy.js +165 -0
  63. package/dist/{session-binding-4Ki04sW-.js → session-binding-CKSepwIC.js} +29 -47
  64. package/dist/{session-binding-record-CyaXZvTe.js → session-binding-record-CaZjYwNS.js} +11 -25
  65. package/dist/session-catalog-HaDcp7Sv.js +1533 -0
  66. package/dist/session-catalog-adoption-BKLtSrwi.js +251 -0
  67. package/dist/session-catalog-archive-D0i2pGj2.js +56 -0
  68. package/dist/session-catalog-home-id-D7-aLiNt.js +190 -0
  69. package/dist/session-catalog-node-adoption-BUuDYY8R.js +182 -0
  70. package/dist/session-catalog-node-continue-CBtc4wkI.js +238 -0
  71. package/dist/session-catalog-parsing-CdD3JhdM.js +280 -0
  72. package/dist/session-catalog-provenance-DkJHo735.js +124 -0
  73. package/dist/{session-cli-BjLhpmS1.js → session-cli-CbgaHh0f.js} +3 -2
  74. package/dist/{session-history-DWmMqiqW.js → session-history-Cz-tOOYj.js} +6 -3
  75. package/dist/{session-upstream-marker-DReTpGz6.js → session-history-import-DFN7sWRU.js} +5 -50
  76. package/dist/{session-history-read-LHldwvyh.js → session-history-read-cxPUxyVV.js} +21 -7
  77. package/dist/session-history-worker-runtime.js +18 -6
  78. package/dist/{session-history.worker-zZVcx0ME.js → session-history.worker-CNEvGaU5.js} +58 -51
  79. package/dist/session-history.worker.js +1 -1
  80. package/dist/{session-initialization-BCFVnLL4.js → session-initialization-Jo86C60I.js} +2 -2
  81. package/dist/{session-permission-policy-BaueHmSj.js → session-permission-policy-B22InTp_.js} +4 -7
  82. package/dist/{session-retirement-DNdmYdFc.js → session-retirement-BSNG_mhf.js} +6 -5
  83. package/dist/session-upstream-marker-D15C9NHp.js +46 -0
  84. package/dist/{settled-turn-context-BOM3Y1pl.js → settled-turn-context-Du6gdUDd.js} +9 -9
  85. package/dist/{settled-turn-finalizer-BI-b1sry.js → settled-turn-finalizer-BuLUrZl2.js} +7 -6
  86. package/dist/shared-client-CVhez2Uo.js +2911 -0
  87. package/dist/{side-question-B6DWAw1A.js → side-question-DLbr2vUU.js} +64 -169
  88. package/dist/source-Da-h6f7e.js +518 -0
  89. package/dist/thread-archive-guard-D1bP04Tf.js +53 -0
  90. package/dist/{thread-lifecycle-DPK30jad.js → thread-lifecycle-D1pzRwHB.js} +112 -616
  91. package/dist/{thread-ownership-CbucAmmp.js → thread-ownership-D6oASVRu.js} +13 -15
  92. package/dist/thread-policy-D8kI7yAO.js +54 -0
  93. package/dist/thread-resume-T5cveyxA.js +52 -0
  94. package/dist/timeout-BVw8aaM1.js +33 -0
  95. package/dist/{transcript-mirror-attestation-Byl34PC-.js → transcript-mirror-attestation-DibE0krH.js} +17 -4
  96. package/dist/{transcript-mirror-_njEB84z.js → transcript-mirror-t5TOccct.js} +50 -260
  97. package/dist/{transport-stdio-CzTngV0j.js → transport-stdio-BGjHoYLr.js} +73 -43
  98. package/dist/{upstream-session-fork-1fwbNKzQ.js → upstream-session-fork-De-sLJ2r.js} +26 -18
  99. package/dist/{usage-i9fv5-4m.js → usage-CPPTmBvZ.js} +4 -3
  100. package/dist/version-omm6IPI3.js +12 -0
  101. package/dist/{web-search-provider.runtime-DKQn67A7.js → web-search-provider.runtime-CSVgQL0w.js} +3 -3
  102. package/openclaw.plugin.json +22 -1
  103. package/package.json +4 -4
  104. package/dist/request-C8H22rPi.js +0 -475
  105. package/dist/session-catalog-B47uwekb.js +0 -3272
  106. package/dist/shared-client-CKhX2kFt.js +0 -7505
  107. package/dist/thread-policy-CTalhWFy.js +0 -105
  108. package/dist/{auth-binding-Ds_QVm-X.js → auth-binding-Co2Vfcf_.js} +1 -1
@@ -1,14 +1,16 @@
1
- import { Mt as retainCodexAppServerLiveThread, Ot as isCodexAppServerLiveThreadClaimed, _ as retainSharedCodexAppServerClientByInstanceId, jt as releaseCodexAppServerLiveThread } from "./shared-client-CKhX2kFt.js";
2
- import { a as closeCodexStartupClientBestEffort, d as unsubscribeCodexThreadBestEffort, r as CodexAppServerUnsafeSubscriptionError } from "./attempt-client-cleanup-Bp1ZOnk2.js";
3
- import { resolveGlobalSingleton } from "openclaw/plugin-sdk/global-singleton";
4
- import { isIncognitoSessionKey } from "openclaw/plugin-sdk/routing";
5
- import { KeyedAsyncQueue } from "openclaw/plugin-sdk/keyed-async-queue";
1
+ import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
2
+ import { n as withCodexAppServerThreadMutation } from "./incognito-session-uhrBF6wJ.js";
3
+ import { U as releaseCodexAppServerLiveThread, W as retainCodexAppServerLiveThread, _ as retainSharedCodexAppServerClientByInstanceId, z as isCodexAppServerLiveThreadClaimed } from "./shared-client-CVhez2Uo.js";
4
+ import { a as closeCodexStartupClientBestEffort, d as unsubscribeCodexThreadBestEffort, r as CodexAppServerUnsafeSubscriptionError } from "./attempt-client-cleanup-D6cR54TV.js";
6
5
  //#region extensions/codex/src/app-server/thread-ownership.ts
7
- const nativeThreadOwners = resolveGlobalSingleton(Symbol.for("openclaw.codexNativeThreadOwners"), () => new KeyedAsyncQueue());
8
- /** Serialize OpenClaw-owned lifecycle changes, not native-internal thread controllers. */
9
- async function withCodexAppServerThreadMutation(threadId, run) {
10
- return await nativeThreadOwners.enqueue(`thread:${threadId}`, run);
11
- }
6
+ var thread_ownership_exports = /* @__PURE__ */ __exportAll({
7
+ isSameCodexAppServerThreadOwner: () => isSameCodexAppServerThreadOwner,
8
+ releaseCodexAppServerBindingSubscription: () => releaseCodexAppServerBindingSubscription,
9
+ retainCodexAppServerBindingSubscription: () => retainCodexAppServerBindingSubscription,
10
+ retireCodexConversationThreadBinding: () => retireCodexConversationThreadBinding,
11
+ rollbackCodexAppServerBindingSubscription: () => rollbackCodexAppServerBindingSubscription,
12
+ withExclusiveCodexAppServerThread: () => withExclusiveCodexAppServerThread
13
+ });
12
14
  /** Codex subscriptions belong to a physical connection, not the native thread ID alone. */
13
15
  function isSameCodexAppServerThreadOwner(current, expected) {
14
16
  return current !== void 0 && expected !== void 0 && current.threadId === expected.threadId && current.clientId === expected.clientId;
@@ -20,10 +22,6 @@ async function withExclusiveCodexAppServerThread(params) {
20
22
  return await params.run();
21
23
  });
22
24
  }
23
- /** Serializes bound turns and retirement so detach cannot unsubscribe an active turn. */
24
- async function withCodexConversationThreadActivity(bindingId, run) {
25
- return await nativeThreadOwners.enqueue(`conversation:${bindingId}`, run);
26
- }
27
25
  /** Publishes one owned subscription with its persistent or ephemeral retention lifetime. */
28
26
  async function retainCodexAppServerBindingSubscription(client, threadId, ownership) {
29
27
  return await retainCodexAppServerLiveThread(client, threadId, ownership?.release ?? (async (releasedThreadId, assertCurrent) => {
@@ -100,4 +98,4 @@ async function retireCodexConversationThreadBinding(params) {
100
98
  }));
101
99
  }
102
100
  //#endregion
103
- export { rollbackCodexAppServerBindingSubscription as a, withExclusiveCodexAppServerThread as c, retireCodexConversationThreadBinding as i, isIncognitoSessionKey as l, releaseCodexAppServerBindingSubscription as n, withCodexAppServerThreadMutation as o, retainCodexAppServerBindingSubscription as r, withCodexConversationThreadActivity as s, isSameCodexAppServerThreadOwner as t };
101
+ export { rollbackCodexAppServerBindingSubscription as a, retireCodexConversationThreadBinding as i, releaseCodexAppServerBindingSubscription as n, thread_ownership_exports as o, retainCodexAppServerBindingSubscription as r, withExclusiveCodexAppServerThread as s, isSameCodexAppServerThreadOwner as t };
@@ -0,0 +1,54 @@
1
+ import { l as isCodexAppServerOverloadError, u as isCodexAppServerPrewriteRequestCancellationError } from "./client-BEKu4yDx.js";
2
+ import { r as requestCodexAppServerClientJson, t as CodexAppServerScopedRequestRejectedError } from "./request-CGvGOpeR.js";
3
+ import { AgentHarnessPreflightError } from "openclaw/plugin-sdk/agent-harness-runtime";
4
+ //#region extensions/codex/src/app-server/thread-policy.ts
5
+ /** A refusal, not a failed native write: the ephemeral conversation must stay alive. */
6
+ var CodexIncognitoPolicyChangeError = class extends AgentHarnessPreflightError {
7
+ constructor() {
8
+ super("Codex cannot change generic instructions in a live incognito conversation. No turn was sent and the conversation is preserved. Restore the previous instructions to continue it, or start a new incognito conversation for the changed policy.");
9
+ this.name = "CodexIncognitoPolicyChangeError";
10
+ }
11
+ };
12
+ /** Never replay a handoff: native persistence can precede an unsuccessful RPC response. */
13
+ var CodexThreadPolicyHandoffError = class extends AgentHarnessPreflightError {
14
+ constructor(outcome, cause) {
15
+ super(`Codex session policy handoff failed: ${cause instanceof Error ? cause.message : String(cause)}. The conversation is preserved; reconnect before retrying.`, { cause });
16
+ this.outcome = outcome;
17
+ this.name = "CodexThreadPolicyHandoffError";
18
+ }
19
+ };
20
+ /** The complete body remains generic configuration for compaction and native child inheritance. */
21
+ async function refreshCodexThreadPolicy(params) {
22
+ const text = "The following is the complete current OpenClaw-supplied generic instruction policy. It replaces earlier OpenClaw-supplied generic policy, including OpenClaw-carried workspace text and sections now absent. Independently supplied native managed, guardian, security, collaboration, and project instructions retain their authority. User requests retain their own authority.\n\n" + (params.developerInstructions === "" ? "The current OpenClaw generic policy is empty; earlier OpenClaw generic policy is withdrawn." : params.developerInstructions);
23
+ let outcome = "unknown";
24
+ try {
25
+ await requestCodexAppServerClientJson({
26
+ ...params,
27
+ method: "thread/inject_items",
28
+ requestParams: {
29
+ threadId: params.threadId,
30
+ items: [{
31
+ type: "message",
32
+ role: "developer",
33
+ content: [{
34
+ type: "input_text",
35
+ text
36
+ }]
37
+ }]
38
+ }
39
+ });
40
+ outcome = "acknowledged";
41
+ params.assertCurrent();
42
+ params.signal?.throwIfAborted();
43
+ } catch (cause) {
44
+ if (outcome !== "acknowledged" && (cause instanceof CodexAppServerScopedRequestRejectedError || isCodexAppServerPrewriteRequestCancellationError(cause) || isCodexAppServerOverloadError(cause))) outcome = "not-written";
45
+ throw new CodexThreadPolicyHandoffError(outcome, cause);
46
+ }
47
+ }
48
+ /** Native lineage classifies the exact bound thread; it never grants session authority. */
49
+ function assertCodexSupervisionThreadLineage(binding, thread) {
50
+ if (binding.connectionScope !== "supervision" || binding.pendingSupervisionBranch) return;
51
+ if (thread.id !== binding.threadId || !binding.supervisionSourceThreadId || thread.forkedFromId !== null && (typeof thread.forkedFromId !== "string" || !thread.forkedFromId.trim() || thread.forkedFromId === thread.id)) throw new Error("Codex supervision lineage could not be verified; reconnect before continuing.");
52
+ }
53
+ //#endregion
54
+ export { refreshCodexThreadPolicy as i, CodexThreadPolicyHandoffError as n, assertCodexSupervisionThreadLineage as r, CodexIncognitoPolicyChangeError as t };
@@ -0,0 +1,52 @@
1
+ import { l as isCodexAppServerOverloadError, u as isCodexAppServerPrewriteRequestCancellationError, y as assertCodexThreadResumeResponse } from "./client-BEKu4yDx.js";
2
+ import { r as CodexAppServerRpcError } from "./session-catalog-provenance-DkJHo735.js";
3
+ import { t as CodexAppServerScopedRequestRejectedError } from "./request-CGvGOpeR.js";
4
+ import { I as forgetCodexWorkspaceReferences, k as isCodexAppServerStartupError, u as isCodexAppServerStartSelectionChangedError } from "./shared-client-CVhez2Uo.js";
5
+ import { d as unsubscribeCodexThreadBestEffort, i as assertCodexThreadResumeSubscription, r as CodexAppServerUnsafeSubscriptionError } from "./attempt-client-cleanup-D6cR54TV.js";
6
+ //#region extensions/codex/src/app-server/thread-resume.ts
7
+ /** Owns Codex thread/resume subscription safety. */
8
+ /** Resumes one thread, releasing or isolating every possible native subscription. */
9
+ async function resumeCodexAppServerThread(params) {
10
+ const threadId = params.request.threadId;
11
+ let response;
12
+ let ownershipRejected = false;
13
+ const assertCurrent = params.assertCurrent && (() => {
14
+ try {
15
+ params.assertCurrent?.();
16
+ } catch (error) {
17
+ ownershipRejected = true;
18
+ throw error;
19
+ }
20
+ });
21
+ try {
22
+ response = assertCodexThreadResumeResponse(await (params.requestResume ? params.requestResume(params.request) : params.client.request("thread/resume", params.request, {
23
+ ...params.timeoutMs !== void 0 ? { timeoutMs: params.timeoutMs } : {},
24
+ ...params.signal ? { signal: params.signal } : {},
25
+ assertCurrent
26
+ })));
27
+ assertCodexThreadResumeSubscription(threadId, response.thread.id);
28
+ forgetCodexWorkspaceReferences(params.client, threadId);
29
+ } catch (error) {
30
+ if (ownershipRejected || isCodexAppServerStartSelectionChangedError(error) || isCodexAppServerStartupError(error) || error instanceof CodexAppServerScopedRequestRejectedError || isCodexAppServerPrewriteRequestCancellationError(error) || isCodexAppServerOverloadError(error)) throw error;
31
+ if (error instanceof CodexAppServerRpcError) {
32
+ if (await unsubscribeCodexThreadBestEffort(params.client, {
33
+ threadId,
34
+ timeoutMs: 5e3,
35
+ assertCurrent: params.assertCurrent
36
+ }).catch(() => false)) {
37
+ params.onSubscriptionReleased?.();
38
+ throw error;
39
+ }
40
+ }
41
+ try {
42
+ await params.abandonClient();
43
+ } catch (abandonError) {
44
+ throw new CodexAppServerUnsafeSubscriptionError(`Codex thread/resume client could not be retired for ${threadId}`, { cause: abandonError });
45
+ }
46
+ if (error instanceof CodexAppServerUnsafeSubscriptionError) throw error;
47
+ throw new CodexAppServerUnsafeSubscriptionError(error instanceof Error ? error.message : `Codex thread/resume outcome is indeterminate for ${threadId}`, { cause: error });
48
+ }
49
+ return response;
50
+ }
51
+ //#endregion
52
+ export { resumeCodexAppServerThread as t };
@@ -0,0 +1,33 @@
1
+ import { withTimeout } from "openclaw/plugin-sdk/time-runtime";
2
+ //#region extensions/codex/src/app-server/timeout.ts
3
+ /**
4
+ * Thin Codex app-server timeout adapter around OpenClaw's shared timeout helper.
5
+ */
6
+ function resolveAbortError(signal) {
7
+ return signal.reason instanceof Error ? signal.reason : new Error("Codex app-server operation aborted", { cause: signal.reason });
8
+ }
9
+ /** Awaits a promise with a Codex-specific timeout error message. */
10
+ async function withTimeout$1(promise, timeoutMs, timeoutMessage, createError) {
11
+ return await withTimeout(promise, timeoutMs, {
12
+ message: timeoutMessage,
13
+ ...createError ? { createError } : {}
14
+ });
15
+ }
16
+ /** Bounds an operation by both its owner lifecycle and one total wall-clock budget. */
17
+ async function withAbortableTimeout(params) {
18
+ const signal = params.signal;
19
+ if (signal?.aborted) throw resolveAbortError(signal);
20
+ let removeAbortListener;
21
+ const operation = signal ? Promise.race([params.promise, new Promise((_, reject) => {
22
+ const onAbort = () => reject(resolveAbortError(signal));
23
+ signal.addEventListener("abort", onAbort, { once: true });
24
+ removeAbortListener = () => signal.removeEventListener("abort", onAbort);
25
+ })]) : params.promise;
26
+ try {
27
+ return await withTimeout$1(operation, params.timeoutMs, params.timeoutMessage, params.createTimeoutError);
28
+ } finally {
29
+ removeAbortListener?.();
30
+ }
31
+ }
32
+ //#endregion
33
+ export { withTimeout$1 as n, withAbortableTimeout 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 };
@@ -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 { r as projectBoundedCodexThreadHistory } from "./session-catalog-home-id-D7-aLiNt.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 };