@openclaw/codex 2026.9.5 → 2026.9.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/README.md +2 -0
  2. package/assets/icon.png +0 -0
  3. package/dist/.setup/{account-usage-runtime-C2MOIvfq.mjs → account-usage-runtime-DFhbh1zz.mjs} +6 -6
  4. package/dist/.setup/{apply-CJ0ZfmBG.mjs → apply-D3GcSoSa.mjs} +35 -55
  5. package/dist/.setup/{attempt-client-cleanup-BpYKdTA0.mjs → attempt-client-cleanup-DOP-cW5j.mjs} +179 -73
  6. package/dist/.setup/attempt-workspace-context-C5HigshI.mjs +164 -0
  7. package/dist/.setup/{auth-binding-DhLWa_7K.mjs → auth-binding-BLWz7stm.mjs} +14 -1
  8. package/dist/.setup/{auth-cache-key-QirmgiCo.mjs → auth-cache-key-Dbvq-QgB.mjs} +41 -111
  9. package/dist/.setup/{auth-profile-WqZtZfXN.mjs → auth-profile-B0okYl2D.mjs} +1 -2
  10. package/dist/.setup/auth-profile-health-oHizqgye.mjs +53 -0
  11. package/dist/.setup/auth-profile-recovery-BREezV0L.mjs +14 -0
  12. package/dist/.setup/auth-start-options-BPIPeEX8.mjs +44 -0
  13. package/dist/.setup/{binding-connection-Bm38niE8.mjs → binding-connection-DTtN1KrX.mjs} +2 -2
  14. package/dist/.setup/{binding-connection.runtime-CnRMC0ta.mjs → binding-connection.runtime-6TpgD1M6.mjs} +5 -5
  15. package/dist/.setup/{bounded-turn-BtlZcivC.mjs → bounded-turn-CbjoN2OW.mjs} +140 -37
  16. package/dist/.setup/bounded-turn-isolation-B8K_ylqk.mjs +14 -0
  17. package/dist/.setup/{build-state-Xx9ybZqa.mjs → build-state-Da1_z0kd.mjs} +1 -1
  18. package/dist/.setup/{capabilities-_vXcZGSx.mjs → capabilities-B3WEZl4e.mjs} +2 -10
  19. package/dist/.setup/{client-vXs2929Q.mjs → client-N0JpgSzF.mjs} +635 -872
  20. package/dist/.setup/client-catalog-response-5HHLdcde.mjs +285 -0
  21. package/dist/.setup/{command-dispatch-naHIZwwF.mjs → command-dispatch-BeAoaovI.mjs} +9 -8
  22. package/dist/.setup/{command-formatters-CGEkdawF.mjs → command-formatters-R3ckE3Co.mjs} +36 -64
  23. package/dist/.setup/{command-handlers-BtAJEW1X.mjs → command-handlers-ylTMS00z.mjs} +301 -488
  24. package/dist/.setup/{command-rpc-DHFpn4le.mjs → command-rpc-CGJGUQ6Y.mjs} +40 -28
  25. package/dist/.setup/compact-C2WamavS.mjs +776 -0
  26. package/dist/.setup/{config-CedDWjM-.mjs → config-DKhXquav.mjs} +26 -28
  27. package/dist/.setup/{config-options-BsanJ8QG.mjs → config-options-CzyWLTJt.mjs} +68 -65
  28. package/dist/.setup/{config-parsing-CcB9iPoq.mjs → config-parsing-b088LyhT.mjs} +57 -60
  29. package/dist/.setup/{config-runtime-CeAhl_h4.mjs → config-runtime-C0NbLms1.mjs} +2 -2
  30. package/dist/.setup/{config-security-BRQ2mgW9.mjs → config-security-CE-FcGw9.mjs} +51 -215
  31. package/dist/.setup/{config-utils-DujwEnhg.mjs → config-utils-D0CXecki.mjs} +3 -13
  32. package/dist/.setup/context-engine-projection-PezSESth.mjs +387 -0
  33. package/dist/.setup/{conversation-binding-DhzrpTM6.mjs → conversation-binding-3Min8qvP.mjs} +71 -105
  34. package/dist/.setup/{conversation-binding-data-CrcyZk6O.mjs → conversation-binding-data-C746z5Pn.mjs} +8 -12
  35. package/dist/.setup/{conversation-control-DN53ns41.mjs → conversation-control-CEP8X5JC.mjs} +30 -69
  36. package/dist/.setup/{cyber-failover-DYwbmf1o.mjs → cyber-failover-XV0nNRZu.mjs} +1 -1
  37. package/dist/.setup/{cyber-failover-notice-e9G3J9-e.mjs → cyber-failover-notice-RNpGpTyP.mjs} +1 -1
  38. package/dist/.setup/{dynamic-tools-D16lOp67.mjs → dynamic-tools-DzlsLUuS.mjs} +3136 -3167
  39. package/dist/.setup/{effective-mcp-catalog-K6kLCN8X.mjs → effective-mcp-catalog-CxUtC-xG.mjs} +8 -17
  40. package/dist/.setup/{ephemeral-turn-R1gA8Sn6.mjs → ephemeral-turn-CDsPJOa2.mjs} +9 -6
  41. package/dist/.setup/event-projector-assistant-message-CigreO4K.mjs +69 -0
  42. package/dist/.setup/{event-projector-usage-C7Ntzs-f.mjs → event-projector-usage-03R0I2dM.mjs} +4 -26
  43. package/dist/.setup/event-projector-values-DJSz8BTk.mjs +106 -0
  44. package/dist/.setup/incognito-session-DWYapfwf.mjs +2 -0
  45. package/dist/.setup/{inference-context-fulhZuz8.mjs → inference-context-D-9gWlTR.mjs} +16 -18
  46. package/dist/.setup/inference-dispatch-CMZtjQyz.mjs +359 -0
  47. package/dist/.setup/inference-metadata-CgIf7sOx.mjs +81 -0
  48. package/dist/.setup/inference-proxy-DhcXOgUE.mjs +561 -0
  49. package/dist/.setup/{isolated-completion-B6srt48J.mjs → isolated-completion-Dm3PzxJk.mjs} +15 -11
  50. package/dist/.setup/launch-args-DbFCehO7.mjs +196 -0
  51. package/dist/.setup/{managed-binary-DP6Rib3P.mjs → managed-binary-kiWRhNRE.mjs} +16 -9
  52. package/dist/.setup/{model-catalog-DkvUuBey.mjs → model-catalog-PAuZgJC6.mjs} +14 -14
  53. package/dist/.setup/model-runtime-BdqzOMkU.mjs +11 -0
  54. package/dist/.setup/{models-BDFgm_G-.mjs → models-DHXZtVVk.mjs} +9 -18
  55. package/dist/.setup/{native-auth-BLZGqFjw.mjs → native-auth-CuG53tu4.mjs} +5 -5
  56. package/dist/.setup/{native-execution-policy-YBMHSzC4.mjs → native-execution-policy-BxZJy5mP.mjs} +6 -31
  57. package/dist/.setup/{native-subagent-monitor-B1hxzIOy.mjs → native-subagent-monitor-Dpsmf2wz.mjs} +4422 -3808
  58. package/dist/.setup/native-subagent-pending-assignments-DwkCzLvD.mjs +203 -0
  59. package/dist/.setup/native-task-assignments-DMQ0g3hu.mjs +194 -0
  60. package/dist/.setup/{node-cli-sessions-Cl8b2ZF3.mjs → node-cli-sessions-HC4W6FLI.mjs} +99 -111
  61. package/dist/.setup/node-exec-server.runtime-BgBfWQqo.mjs +244 -0
  62. package/dist/.setup/{plan-xD7WKYTM.mjs → plan-Y-QIvrKB.mjs} +118 -163
  63. package/dist/.setup/{plugin-activation-r8nq5Jzp.mjs → plugin-activation-cNHRfaxU.mjs} +10 -47
  64. package/dist/.setup/{plugin-app-cache-key-BOxKP7db.mjs → plugin-app-cache-key-BL9B5H0L.mjs} +9 -42
  65. package/dist/.setup/{plugin-inventory-DUle8DLz.mjs → plugin-inventory-Cky2XJUw.mjs} +32 -23
  66. package/dist/.setup/{plugin-marketplace-discovery-P-Vndfqq.mjs → plugin-marketplace-discovery-D_dV9FXa.mjs} +22 -25
  67. package/dist/.setup/{plugin-metadata-cache-DsS5buNa.mjs → plugin-metadata-cache-DsjsL1dr.mjs} +328 -318
  68. package/dist/.setup/protocol-CANUwXJ3.mjs +17 -0
  69. package/dist/.setup/provider-DH8NSzGt.mjs +51 -0
  70. package/dist/.setup/{provider-capabilities-B8J4Dy-O.mjs → provider-capabilities-CAxoF-X1.mjs} +35 -12
  71. package/dist/.setup/{rate-limits-DOEGYRNs.mjs → rate-limits-B7-X2TgG.mjs} +123 -166
  72. package/dist/.setup/{request-BioXJLYa.mjs → request-BHZ1nz8d.mjs} +25 -16
  73. package/dist/.setup/responses-oauth-twnuTaAa.mjs +93 -0
  74. package/dist/.setup/rpc-error-BlD2vuzn.mjs +31 -0
  75. package/dist/.setup/{run-attempt-rlA07pUv.mjs → run-attempt-D8RZUOzY.mjs} +2046 -1454
  76. package/dist/.setup/{run-attempt-lifecycle-B7JbY4-F.mjs → run-attempt-lifecycle-C-6O3Exn.mjs} +10 -24
  77. package/dist/.setup/{runtime-artifact-Dy38Z5iU.mjs → runtime-artifact-DDQ-HGXf.mjs} +43 -47
  78. package/dist/.setup/runtime-artifact-connection-D68qQn1m.mjs +78 -0
  79. package/dist/.setup/sandbox-guard-DjCz2eOw.mjs +126 -0
  80. package/dist/.setup/scope-DOC1Xjc8.mjs +6 -0
  81. package/dist/.setup/session-binding-DGCYAfvD.mjs +443 -0
  82. package/dist/.setup/{session-binding-record-TH3xA0zj.mjs → session-binding-record-Oe9L-CNY.mjs} +73 -132
  83. package/dist/.setup/{session-binding-sidecars-CKYEcfNn.mjs → session-binding-sidecars-jo6H8dFr.mjs} +242 -60
  84. package/dist/.setup/{session-catalog-fUdWDx-U.mjs → session-catalog-4sCdv5qx.mjs} +598 -452
  85. package/dist/.setup/{session-catalog-adoption-CR_whkEW.mjs → session-catalog-adoption-BU_pHWG7.mjs} +59 -26
  86. package/dist/.setup/{session-catalog-archive-CwZaPacf.mjs → session-catalog-archive-spHfihri.mjs} +7 -7
  87. package/dist/.setup/session-catalog-events-DePDzzjc.mjs +139 -0
  88. package/dist/.setup/session-catalog-home-id-vlih0B_g.mjs +22 -0
  89. package/dist/.setup/{session-catalog-index-B141u15s.mjs → session-catalog-index-CZvDzC6z.mjs} +286 -182
  90. package/dist/.setup/{session-catalog-index-order-Cc5BzlQr.mjs → session-catalog-index-order-BcQpHks3.mjs} +2 -2
  91. package/dist/.setup/{session-catalog-index-state-BAuDztHN.mjs → session-catalog-index-state-TeO7EyO-.mjs} +6 -2
  92. package/dist/.setup/session-catalog-limits-DDxOsQeC.mjs +14 -0
  93. package/dist/.setup/session-catalog-list-request-CvtxrYSe.mjs +170 -0
  94. package/dist/.setup/session-catalog-native-projection-DjhwGL6x.mjs +178 -0
  95. package/dist/.setup/{session-catalog-node-adoption-BVRsYOSh.mjs → session-catalog-node-adoption-DgXvSGu0.mjs} +30 -35
  96. package/dist/.setup/{session-catalog-node-continue-Dowv8osw.mjs → session-catalog-node-continue-DjKXHBbi.mjs} +25 -18
  97. package/dist/.setup/session-catalog-node-lookup-CtAXI5W5.mjs +56 -0
  98. package/dist/.setup/{session-catalog-native-projection-ChV3cCtm.mjs → session-catalog-parsing-CPGaPYr-.mjs} +14 -180
  99. package/dist/.setup/{session-catalog-projection-C1Bj9Jl-.mjs → session-catalog-projection-Cr5qP5Dj.mjs} +15 -5
  100. package/dist/.setup/session-catalog-provenance-DoAvktcj.mjs +95 -0
  101. package/dist/.setup/{session-cli-DIj-IE-E.mjs → session-cli-Cn_nCqfq.mjs} +11 -24
  102. package/dist/.setup/{session-history-C--SrLI8.mjs → session-history-D83lJWHG.mjs} +16 -23
  103. package/dist/.setup/{session-history-import-JHXT5Xfi.mjs → session-history-import-WhX-X33a.mjs} +7 -10
  104. package/dist/.setup/session-history-read-Ov3StuL4.mjs +133 -0
  105. package/dist/.setup/{session-history.worker-CpNj7H_P.mjs → session-history.worker-MnPKncqP.mjs} +14 -23
  106. package/dist/.setup/session-initialization-6aveB9qb.mjs +22 -0
  107. package/dist/.setup/{session-permission-policy-DhurXY0l.mjs → session-permission-policy-Ci_fVX6y.mjs} +4 -8
  108. package/dist/.setup/{session-retirement-CU87AOg9.mjs → session-retirement-qMTxkNx2.mjs} +31 -12
  109. package/dist/.setup/{settled-turn-context-fmwouT5I.mjs → settled-turn-context-D4yj4rxf.mjs} +1 -1
  110. package/dist/.setup/{settled-turn-finalizer-CiY2bLFK.mjs → settled-turn-finalizer-BsvEabkw.mjs} +17 -13
  111. package/dist/.setup/{shared-client-BpTtuLQ5.mjs → shared-client-DqyTMYug.mjs} +826 -485
  112. package/dist/.setup/shared-client-lifecycle-DJIgqgMw.mjs +153 -0
  113. package/dist/.setup/{side-question-DSCZyoBD.mjs → side-question-C4kCmQy1.mjs} +206 -334
  114. package/dist/.setup/{source-Bjp4UQij.mjs → source-CS_7GFJZ.mjs} +82 -139
  115. package/dist/.setup/spawn-error-CL3n6MAa.mjs +57 -0
  116. package/dist/.setup/{thread-archive-guard-jmecf6OJ.mjs → thread-archive-guard-C9frICzX.mjs} +10 -3
  117. package/dist/.setup/thread-lifecycle-DPflntEJ.mjs +2362 -0
  118. package/dist/.setup/{incognito-session-uhrBF6wJ.mjs → thread-ownership-queue-Dp24d7-F.mjs} +1 -2
  119. package/dist/.setup/{thread-ownership-skomxnIt.mjs → thread-ownership-roNP0l1c.mjs} +47 -10
  120. package/dist/.setup/thread-policy-DTd-DtkX.mjs +109 -0
  121. package/dist/.setup/thread-requests-B_bRnMGN.mjs +2102 -0
  122. package/dist/.setup/{thread-resume-BkNpj9Pz.mjs → thread-resume-CdDaoc7T.mjs} +6 -6
  123. package/dist/.setup/timeout-CXOfNoaX.mjs +46 -0
  124. package/dist/.setup/transcript-history-projection-DRSifI-1.mjs +201 -0
  125. package/dist/.setup/{transcript-mirror-attestation-CzM-94NC.mjs → transcript-mirror-attestation-YSegaktH.mjs} +3 -4
  126. package/dist/.setup/{transcript-mirror-D4qp_leP.mjs → transcript-mirror-kxmCYsuF.mjs} +224 -206
  127. package/dist/.setup/{transport-stdio-Cmx94Oiy.mjs → transport-stdio-Bdegpn2V.mjs} +138 -75
  128. package/dist/.setup/transport-websocket-BTBE-LD9.mjs +211 -0
  129. package/dist/.setup/{upstream-prompt-provenance-LphB8slG.mjs → upstream-prompt-provenance-fXkKbPVC.mjs} +3 -9
  130. package/dist/.setup/{upstream-session-fork-D3UKxgVD.mjs → upstream-session-fork-CBeVjBpT.mjs} +48 -40
  131. package/dist/.setup/{usage-BOgBEKso.mjs → usage-BMzNxeR_.mjs} +5 -4
  132. package/dist/.setup/{usage-limit-error-C0ow7DOc.mjs → usage-limit-error-QXerDo3i.mjs} +5 -20
  133. package/dist/.setup/{web-search-provider.runtime-CTGuJt6i.mjs → web-search-provider.runtime-P77OUeoo.mjs} +10 -20
  134. package/dist/api.js +25 -16
  135. package/dist/catalog-page-worker-entrypoint.js +12 -0
  136. package/dist/catalog-page.worker.js +9 -0
  137. package/dist/cli-metadata.js +1 -1
  138. package/dist/doctor-contract-api.js +50 -8
  139. package/dist/harness.js +344 -1
  140. package/dist/index.js +345 -346
  141. package/dist/media-understanding-provider.js +9 -22
  142. package/dist/migration-provider-api.js +1 -1
  143. package/dist/provider-discovery.js +1 -1
  144. package/dist/session-history-worker-runtime.js +16 -33
  145. package/dist/session-history.worker.js +1 -1
  146. package/openclaw.plugin.json +14 -2
  147. package/package.json +11 -7
  148. package/dist/.setup/attempt-context-VXVwTCfS.mjs +0 -636
  149. package/dist/.setup/compact-C3i3qlzj.mjs +0 -687
  150. package/dist/.setup/event-projector-assistant-message-DNUR1s0A.mjs +0 -105
  151. package/dist/.setup/event-projector-items-DyTQ_XqL.mjs +0 -200
  152. package/dist/.setup/harness-rxaaoN-o.mjs +0 -349
  153. package/dist/.setup/history-rejection-B4nOXNXF.mjs +0 -13
  154. package/dist/.setup/image-payload-sanitizer-tupAr-2o.mjs +0 -79
  155. package/dist/.setup/inference-proxy-CC15HuSi.mjs +0 -311
  156. package/dist/.setup/launch-args-DnMak49W.mjs +0 -111
  157. package/dist/.setup/local-runtime-attribution-B_2mnqhb.mjs +0 -19
  158. package/dist/.setup/native-subagent-history-YXaL6dMd.mjs +0 -135
  159. package/dist/.setup/native-subagent-task-ids-DsuOonKv.mjs +0 -411
  160. package/dist/.setup/node-exec-server.runtime-BaViBKNz.mjs +0 -226
  161. package/dist/.setup/plugin-approval-roundtrip-CjfzafAZ.mjs +0 -122
  162. package/dist/.setup/provider-fFh_-VR3.mjs +0 -50
  163. package/dist/.setup/rolldown-runtime-8H4AJuhK.mjs +0 -14
  164. package/dist/.setup/sandbox-guard-BBP-RbTf.mjs +0 -166
  165. package/dist/.setup/session-binding-_0W_fHRr.mjs +0 -721
  166. package/dist/.setup/session-catalog-events-jMcYfQyd.mjs +0 -250
  167. package/dist/.setup/session-history-read-B3ZfSUbF.mjs +0 -50
  168. package/dist/.setup/session-initialization-DH1z6fXn.mjs +0 -75
  169. package/dist/.setup/thread-history-page-BTx-4xsg.mjs +0 -83
  170. package/dist/.setup/thread-lifecycle-Cik28qWn.mjs +0 -4904
  171. package/dist/.setup/thread-policy-Cjs4B8xf.mjs +0 -54
  172. package/dist/.setup/timeout-DZF05XrR.mjs +0 -63
  173. package/dist/.setup/transcript-history-projection-DHNBDhCU.mjs +0 -243
  174. package/dist/.setup/version-CoqzXPgK.mjs +0 -12
@@ -0,0 +1,164 @@
1
+ import { r as flattenCodexDynamicToolFunctions } from "./protocol-CANUwXJ3.mjs";
2
+ import { lt as isMessageOnlyCodexSourceReply } from "./thread-requests-B_bRnMGN.mjs";
3
+ import path from "node:path";
4
+ import { buildAgentWorkspaceInstructionSnapshot, buildBootstrapContextForFiles, embeddedAgentLog, prepareAgentWorkspaceContext } from "openclaw/plugin-sdk/agent-harness-runtime";
5
+ import { resolveAgentWorkspaceMemoryRouting, shouldIncludeAgentHarnessRuntimeContext } from "openclaw/plugin-sdk/agent-harness-attempt-runtime";
6
+ import { resolveBootstrapFilesForPreparation } from "openclaw/plugin-sdk/codex-mcp-projection";
7
+ //#region extensions/codex/src/app-server/attempt-workspace-context.ts
8
+ const CODEX_NATIVE_PROJECT_DOC_BASENAMES = /* @__PURE__ */ new Set(["agents.md"]);
9
+ const CODEX_MEMORY_CONTEXT_BASENAME = "memory.md";
10
+ const CODEX_MEMORY_TOOL_NAMES = /* @__PURE__ */ new Set(["memory_search", "memory_get"]);
11
+ const CODEX_BOOTSTRAP_CONTEXT_ORDER = /* @__PURE__ */ new Map([
12
+ ["soul.md", 10],
13
+ ["identity.md", 20],
14
+ ["user.md", 30],
15
+ ["bootstrap.md", 50],
16
+ ["memory.md", 60]
17
+ ]);
18
+ /** A child baseline reads the bounded workspace snapshot without invoking admission hooks. */
19
+ async function prepareCodexWorkspaceDeveloperInstructions(params) {
20
+ if (isSameCodexWorkspacePath(params.workspaceDir, params.cwd)) return;
21
+ const files = await resolveBootstrapFilesForPreparation(params);
22
+ const contextFiles = buildBootstrapContextForFiles(files, {
23
+ config: params.config,
24
+ agentId: params.agentId
25
+ });
26
+ return buildAgentWorkspaceInstructionSnapshot(contextFiles, params.workspaceDir).instructions;
27
+ }
28
+ async function buildCodexWorkspaceBootstrapContext(params) {
29
+ const availableToolNames = new Set(flattenCodexDynamicToolFunctions(params.tools).map((tool) => normalizeCodexDynamicToolName(tool.name)));
30
+ const inheritsAgentWorkspace = (params.executionWorkspace ?? params.resolvedWorkspace) !== params.resolvedWorkspace;
31
+ const injectOpenClawContext = shouldIncludeAgentHarnessRuntimeContext(params.params);
32
+ const restrictedProjectDocNeedsOpenClawCarrier = params.params.pluginHarnessToolPolicyRestricted === true && !params.params.disableTools && !isMessageOnlyCodexSourceReply(params.params) && params.params.bootstrapContextMode !== "lightweight";
33
+ const includeAgentWorkspaceInstructions = injectOpenClawContext && !params.ringZeroActive && (inheritsAgentWorkspace || restrictedProjectDocNeedsOpenClawCarrier);
34
+ try {
35
+ const promptWorkspace = inheritsAgentWorkspace ? params.resolvedWorkspace : params.effectiveWorkspace;
36
+ const { memoryToolNames, memoryToolRouted } = resolveAgentWorkspaceMemoryRouting({
37
+ config: params.params.config,
38
+ agentId: params.params.agentId ?? params.sessionAgentId,
39
+ workspaceDir: promptWorkspace,
40
+ toolNames: availableToolNames
41
+ });
42
+ const prepared = await prepareAgentWorkspaceContext({
43
+ scope: "full",
44
+ workspaceDir: params.resolvedWorkspace,
45
+ config: params.params.config,
46
+ sessionKey: params.sessionKey,
47
+ sessionId: params.params.sessionId,
48
+ bootstrapUserProfileId: params.params.bootstrapUserProfileId,
49
+ chatType: params.params.chatType,
50
+ agentId: params.params.agentId ?? params.sessionAgentId,
51
+ warn: (message) => embeddedAgentLog.warn(message),
52
+ contextMode: params.params.bootstrapContextMode,
53
+ runKind: params.params.bootstrapContextRunKind,
54
+ memoryToolRouted,
55
+ onMemoryPreparationError: (error) => embeddedAgentLog.warn("failed to prepare codex memory recall instructions", { error }),
56
+ memoryTools: injectOpenClawContext ? {
57
+ toolNames: [...availableToolNames],
58
+ citationsMode: params.params.config?.memory?.citations,
59
+ sandboxed: params.sandboxed
60
+ } : void 0,
61
+ projectPath: (filePath) => remapCodexContextFilePath({
62
+ filePath,
63
+ sourceWorkspaceDir: params.resolvedWorkspace,
64
+ targetWorkspaceDir: promptWorkspace
65
+ }),
66
+ nativeProjectDocBasenames: CODEX_NATIVE_PROJECT_DOC_BASENAMES,
67
+ contextFileOrder: CODEX_BOOTSTRAP_CONTEXT_ORDER,
68
+ promptMemoryWorkspaceDir: params.effectiveWorkspace
69
+ });
70
+ const { bootstrapFiles, contextFiles, promptContextFiles, memoryReferenceFiles, memoryToolRoutedBootstrapFiles } = prepared;
71
+ return {
72
+ bootstrapFiles,
73
+ contextFiles,
74
+ inheritsAgentWorkspace,
75
+ promptContextFiles,
76
+ threadDeveloperInstructionFiles: includeAgentWorkspaceInstructions ? prepared.instructionSnapshot.files : [],
77
+ turnScopedDeveloperInstructionFiles: injectOpenClawContext ? prepared.personaFiles : [],
78
+ memoryReferenceFiles,
79
+ memoryToolRoutedBootstrapFiles,
80
+ memoryToolNames,
81
+ memoryToolRouted,
82
+ promptContext: renderCodexWorkspaceBootstrapPromptContext(promptContextFiles),
83
+ threadDeveloperInstructions: includeAgentWorkspaceInstructions ? params.agentWorkspaceDeveloperInstructions ?? prepared.instructionSnapshot.instructions : void 0,
84
+ turnScopedDeveloperInstructions: injectOpenClawContext ? prepared.personaInstructions : void 0,
85
+ memoryCollaborationInstructions: injectOpenClawContext ? renderCodexWorkspaceMemoryCollaborationInstructions({
86
+ files: memoryReferenceFiles,
87
+ toolNames: memoryToolNames,
88
+ memoryRecallInstructions: prepared.memoryRecallInstructions
89
+ }) : void 0
90
+ };
91
+ } catch (error) {
92
+ embeddedAgentLog.warn("failed to load codex workspace bootstrap instructions", { error });
93
+ return {
94
+ bootstrapFiles: [],
95
+ contextFiles: [],
96
+ inheritsAgentWorkspace,
97
+ threadDeveloperInstructions: includeAgentWorkspaceInstructions ? params.agentWorkspaceDeveloperInstructions : void 0
98
+ };
99
+ }
100
+ }
101
+ function renderCodexWorkspaceBootstrapPromptContext(contextFiles) {
102
+ if (contextFiles.length === 0) return;
103
+ const lines = [
104
+ "OpenClaw loaded these user-editable workspace files for the current turn. Codex loads project-local AGENTS.md natively. When execution uses another folder, OpenClaw supplies the agent workspace AGENTS.md as thread-level developer instructions. SOUL.md, IDENTITY.md, and USER.md are prepared separately from user input and are not repeated here.",
105
+ "",
106
+ "# Project Context",
107
+ "",
108
+ "The following project context files have been loaded:",
109
+ ""
110
+ ];
111
+ for (const file of contextFiles) lines.push(`## ${file.path}`, "", file.content, "");
112
+ return lines.join("\n").trim();
113
+ }
114
+ function renderCodexWorkspaceMemoryReference(params) {
115
+ if (params.files.length === 0) return;
116
+ const lines = [
117
+ "## OpenClaw Workspace Memory",
118
+ "",
119
+ `MEMORY.md exists in the active agent workspace as a memory file, not an instruction file. OpenClaw does not paste its contents into native Codex turns; use ${(params.toolNames?.length ? params.toolNames : Array.from(CODEX_MEMORY_TOOL_NAMES)).join(" or ")} when durable memory is relevant and the tools are available.`,
120
+ ""
121
+ ];
122
+ for (const file of params.files) lines.push(`- ${file.path}`);
123
+ return lines.join("\n").trim();
124
+ }
125
+ function renderCodexWorkspaceMemoryCollaborationInstructions(params) {
126
+ const sections = [params.memoryRecallInstructions ? [params.memoryRecallInstructions, renderCodexMemoryToolSearchBridge(params.toolNames)].filter(isNonEmptyString).join("\n").trim() : void 0, renderCodexWorkspaceMemoryReference(params)].filter(isNonEmptyString);
127
+ return sections.length > 0 ? sections.join("\n\n") : void 0;
128
+ }
129
+ function renderCodexMemoryToolSearchBridge(toolNames) {
130
+ const memoryToolNames = toolNames.map((name) => normalizeCodexDynamicToolName(name)).filter((name) => CODEX_MEMORY_TOOL_NAMES.has(name)).toSorted();
131
+ if (memoryToolNames.length === 0) return;
132
+ return `Codex may expose ${memoryToolNames.join(" and ")} as deferred tools. When the memory guidance above calls for memory recall, use an already-loaded memory tool directly. If the needed memory tool is deferred and not currently callable, use \`tool_search\` to load it, then call that memory tool.`;
133
+ }
134
+ function isSameCodexWorkspacePath(left, right) {
135
+ return path.resolve(left) === path.resolve(right);
136
+ }
137
+ /**
138
+ * Remaps bootstrap file paths from the resolved workspace to the effective Codex
139
+ * workspace while preserving platform path separators.
140
+ */
141
+ function remapCodexContextFilePath(params) {
142
+ const relativePath = path.relative(params.sourceWorkspaceDir, params.filePath);
143
+ if (!relativePath || relativePath === ".." || relativePath.startsWith(`..${path.sep}`) || path.isAbsolute(relativePath) || params.sourceWorkspaceDir === params.targetWorkspaceDir) return params.filePath;
144
+ const targetUsesPosixSeparators = params.targetWorkspaceDir.includes("/") && !params.targetWorkspaceDir.includes("\\");
145
+ const normalizedRelativePath = targetUsesPosixSeparators ? relativePath.replaceAll("\\", "/") : relativePath.replaceAll("/", "\\");
146
+ return targetUsesPosixSeparators ? path.posix.join(params.targetWorkspaceDir, normalizedRelativePath) : path.win32.join(params.targetWorkspaceDir, normalizedRelativePath);
147
+ }
148
+ function normalizeCodexContextFilePath(filePath) {
149
+ return filePath.trim().replaceAll("\\", "/").toLowerCase();
150
+ }
151
+ function getCodexContextFileDisplayBasename(filePath) {
152
+ return filePath.trim().replaceAll("\\", "/").split("/").pop()?.trim() ?? "";
153
+ }
154
+ function getCodexContextFileBasename(filePath) {
155
+ return normalizeCodexContextFilePath(filePath).split("/").pop() ?? "";
156
+ }
157
+ function normalizeCodexDynamicToolName(name) {
158
+ return name.trim().toLowerCase();
159
+ }
160
+ function isNonEmptyString(value) {
161
+ return typeof value === "string" && value.length > 0;
162
+ }
163
+ //#endregion
164
+ export { getCodexContextFileDisplayBasename as a, normalizeCodexDynamicToolName as c, getCodexContextFileBasename as i, prepareCodexWorkspaceDeveloperInstructions as l, CODEX_NATIVE_PROJECT_DOC_BASENAMES as n, isNonEmptyString as o, buildCodexWorkspaceBootstrapContext as r, normalizeCodexContextFilePath as s, CODEX_MEMORY_CONTEXT_BASENAME as t };
@@ -1,4 +1,5 @@
1
- import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
1
+ import { i as isCodexResponsesOAuthCredential, o as resolveCodexResponsesOAuthProfileFingerprint } from "./responses-oauth-twnuTaAa.mjs";
2
+ import { t as __exportAll } from "./session-binding-sidecars-jo6H8dFr.mjs";
2
3
  import { resolveApiKeyForProfile } from "openclaw/plugin-sdk/agent-runtime";
3
4
  import { fingerprintResolvedAuthProfileCredential } from "openclaw/plugin-sdk/agent-harness-runtime";
4
5
  import { resolveOpenAICodexAuthIdentity } from "openclaw/plugin-sdk/provider-auth";
@@ -29,6 +30,18 @@ async function prepareCodexAppServerAuthBinding(params) {
29
30
  const credential = params.authProfileStore.profiles[params.authProfileId];
30
31
  if (!credential) return;
31
32
  if (credential.type === "oauth") {
33
+ if (isCodexResponsesOAuthCredential(credential)) {
34
+ const store = structuredClone(params.authProfileStore);
35
+ return {
36
+ fingerprint: await resolveCodexResponsesOAuthProfileFingerprint({
37
+ profileId: params.authProfileId,
38
+ store,
39
+ agentDir: params.agentDir,
40
+ config: params.config
41
+ }),
42
+ authProfileStore: store
43
+ };
44
+ }
32
45
  const fingerprint = fingerprintResolvedAuthProfileCredential({
33
46
  profileId: params.authProfileId,
34
47
  credential: {
@@ -1,23 +1,27 @@
1
- import { n as defineCodexBuildState } from "./build-state-Xx9ybZqa.mjs";
2
- import { c as resolveMacOSDesktopCodexAppPathCandidates } from "./managed-binary-DP6Rib3P.mjs";
3
- import { n as resolveCodexAppServerSpawnEnv } from "./transport-stdio-Cmx94Oiy.mjs";
1
+ import { n as defineCodexBuildState } from "./build-state-Da1_z0kd.mjs";
2
+ import { u as resolveMacOSDesktopCodexAppPathCandidates } from "./managed-binary-kiWRhNRE.mjs";
3
+ import { n as resolveCodexAppServerSpawnEnv } from "./transport-stdio-Bdegpn2V.mjs";
4
4
  import { createHash } from "node:crypto";
5
5
  import fs, { constants, existsSync, watch } from "node:fs";
6
6
  import path from "node:path";
7
7
  import os from "node:os";
8
8
  import fs$1 from "node:fs/promises";
9
+ import { extractErrorCode } from "openclaw/plugin-sdk/error-runtime";
10
+ import { sha256File } from "openclaw/plugin-sdk/file-access-runtime";
9
11
  import { readSecretFile } from "openclaw/plugin-sdk/secret-file";
10
12
  //#region extensions/codex/src/app-server/desktop-generation-fingerprint.ts
11
13
  const MAX_COMPUTER_USE_PLUGIN_TREE_ENTRIES = 4096;
12
14
  /** Fingerprints every desktop candidate that can own a managed fallback artifact. */
13
15
  async function readMacOSDesktopGenerationFingerprint(candidates = resolveMacOSDesktopCodexAppPathCandidates("darwin")) {
14
16
  const entries = [];
17
+ const bundles = /* @__PURE__ */ new Set();
15
18
  for (const candidate of candidates) {
16
19
  const command = await statFingerprint(candidate.appServerCommandPath);
17
20
  entries.push(`candidate:${candidate.appName}:${candidate.appServerCommandPath}:${command}`);
21
+ if (bundles.has(candidate.appBundlePath)) continue;
22
+ bundles.add(candidate.appBundlePath);
18
23
  for (const artifactPath of resolveMacOSDesktopGenerationPaths(candidate)) entries.push(`${artifactPath}\0${await statFingerprint(artifactPath)}`);
19
- const pluginRoot = resolveComputerUsePluginRoot(candidate);
20
- entries.push(`${pluginRoot}\0${await directoryTreeFingerprint(pluginRoot)}`);
24
+ for (const pluginRoot of resolveComputerUseArtifactRoots(candidate)) entries.push(`${pluginRoot}\0${await readCodexDesktopArtifactTreeFingerprint(pluginRoot)}`);
21
25
  }
22
26
  return createHash("sha256").update(entries.join("\0")).digest("hex");
23
27
  }
@@ -25,6 +29,8 @@ function resolveMacOSDesktopGenerationPaths(candidate) {
25
29
  return [
26
30
  candidate.appBundlePath,
27
31
  path.join(candidate.bundledMarketplacePath, ".agents", "plugins", "marketplace.json"),
32
+ path.join(candidate.appBundlePath, "Contents", "Resources", "cua_node", "bin", "node"),
33
+ path.join(candidate.appBundlePath, "Contents", "Resources", "cua_node", "bin", "node_repl"),
28
34
  ...candidate.computerUseServiceAppPaths.flatMap((servicePath) => [
29
35
  servicePath,
30
36
  path.join(servicePath, "Contents", "Info.plist"),
@@ -32,8 +38,15 @@ function resolveMacOSDesktopGenerationPaths(candidate) {
32
38
  ])
33
39
  ];
34
40
  }
35
- function resolveComputerUsePluginRoot(candidate) {
36
- return path.join(candidate.bundledMarketplacePath, "plugins", "computer-use");
41
+ function resolveComputerUseArtifactRoots(candidate) {
42
+ const modules = path.join(candidate.appBundlePath, "Contents", "Resources", "cua_node", "lib", "node_modules", "@oai");
43
+ return [
44
+ path.join(candidate.bundledMarketplacePath, "plugins", "computer-use"),
45
+ path.join(candidate.bundledMarketplacePath, "plugins", "unified-computer-use"),
46
+ path.join(modules, "cua-repl"),
47
+ path.join(modules, "cua"),
48
+ path.join(modules, "sky", "dist")
49
+ ];
37
50
  }
38
51
  /** Stable roots that cover bundle replacement and recursive artifact updates. */
39
52
  function resolveMacOSDesktopGenerationWatchPaths(candidates = resolveMacOSDesktopCodexAppPathCandidates("darwin")) {
@@ -41,12 +54,13 @@ function resolveMacOSDesktopGenerationWatchPaths(candidates = resolveMacOSDeskto
41
54
  for (const candidate of candidates) watched.add(candidate.appBundlePath);
42
55
  return [...watched];
43
56
  }
44
- async function directoryTreeFingerprint(root) {
57
+ async function readCodexDesktopArtifactTreeFingerprint(root) {
45
58
  let rootStat;
46
59
  try {
47
60
  rootStat = await fs$1.lstat(root, { bigint: true });
48
61
  } catch (error) {
49
- if (isNodeError(error, "ENOENT") || isNodeError(error, "ENOTDIR")) return "missing";
62
+ const code = extractErrorCode(error);
63
+ if (code === "ENOENT" || code === "ENOTDIR") return "missing";
50
64
  throw error;
51
65
  }
52
66
  if (!rootStat.isDirectory()) return statFingerprint(root);
@@ -84,7 +98,8 @@ async function statFingerprint(filePath) {
84
98
  const content = target.isFile() ? await readFileFingerprint(filePath, target, true) : "";
85
99
  return `${type}:${own}:${link}:${realPath}:${statTuple(target)}:${content}`;
86
100
  } catch (error) {
87
- if (isNodeError(error, "ENOENT") || isNodeError(error, "ENOTDIR")) return "missing";
101
+ const code = extractErrorCode(error);
102
+ if (code === "ENOENT" || code === "ENOTDIR") return "missing";
88
103
  throw error;
89
104
  }
90
105
  }
@@ -94,10 +109,10 @@ async function readFileFingerprint(filePath, expected, followsSymlink) {
94
109
  try {
95
110
  const before = await handle.stat({ bigint: true });
96
111
  if (!sameStat(before, expected)) throw new Error(`Codex desktop artifact changed while fingerprinting: ${filePath}`);
97
- const hash = createHash("sha256");
98
- for await (const chunk of handle.createReadStream({ autoClose: false })) hash.update(chunk);
99
- if (!sameStat(before, await handle.stat({ bigint: true }))) throw new Error(`Codex desktop artifact changed while fingerprinting: ${filePath}`);
100
- return hash.digest("hex");
112
+ const hash = await sha256File(handle, { maxBytes: Number(before.size) });
113
+ const after = await handle.stat({ bigint: true });
114
+ if (BigInt(hash.bytes) !== before.size || !sameStat(before, after)) throw new Error(`Codex desktop artifact changed while fingerprinting: ${filePath}`);
115
+ return hash.digest;
101
116
  } finally {
102
117
  await handle.close();
103
118
  }
@@ -115,9 +130,6 @@ function statTuple(stat) {
115
130
  stat.ctimeNs
116
131
  ].join(":");
117
132
  }
118
- function isNodeError(error, code) {
119
- return Boolean(error && typeof error === "object" && "code" in error && error.code === code);
120
- }
121
133
  //#endregion
122
134
  //#region extensions/codex/src/app-server/desktop-generation-owner.ts
123
135
  const SETTLE_DELAY_MS = 1e3;
@@ -203,12 +215,9 @@ function createCodexDesktopGenerationService(params, runtime = {
203
215
  if (runtime.platform !== "darwin") return;
204
216
  const current = state();
205
217
  current.context = ctx;
206
- current.readFingerprint = runtime.readFingerprint;
207
- current.resolveWatchPaths = runtime.resolveWatchPaths;
208
- current.pathExists = runtime.pathExists;
209
- current.watchPath = runtime.watchPath;
218
+ current.runtime = { ...runtime };
210
219
  current.owner = createCodexDesktopGenerationOwner({
211
- readFingerprint: current.readFingerprint,
220
+ readFingerprint: runtime.readFingerprint,
212
221
  onGenerationChange: params.onGenerationChange,
213
222
  initialGeneration: current.lastGeneration
214
223
  });
@@ -222,10 +231,7 @@ function createCodexDesktopGenerationService(params, runtime = {
222
231
  current.owner = void 0;
223
232
  current.armEpoch = (current.armEpoch ?? 0) + 1;
224
233
  current.context = void 0;
225
- current.readFingerprint = void 0;
226
- current.resolveWatchPaths = void 0;
227
- current.pathExists = void 0;
228
- current.watchPath = void 0;
234
+ current.runtime = void 0;
229
235
  current.watchHealthy = void 0;
230
236
  current.rearmDelayMs = void 0;
231
237
  if (current.rearmTimer) {
@@ -245,10 +251,10 @@ function armWatchers(current) {
245
251
  current.watchers = watchers;
246
252
  const candidateNames = new Set(resolveMacOSDesktopCodexAppPathCandidates("darwin").map((candidate) => candidate.appName));
247
253
  let complete = true;
248
- for (const watchedPath of current.resolveWatchPaths?.() ?? []) {
249
- if (!current.pathExists?.(watchedPath)) continue;
254
+ for (const watchedPath of current.runtime?.resolveWatchPaths() ?? []) {
255
+ if (!current.runtime?.pathExists(watchedPath)) continue;
250
256
  try {
251
- const watcher = current.watchPath?.(watchedPath, { recursive: watchedPath !== APPLICATIONS_PATH }, (_eventType, filename) => {
257
+ const watcher = current.runtime?.watchPath(watchedPath, { recursive: watchedPath !== APPLICATIONS_PATH }, (_eventType, filename) => {
252
258
  if (!isCurrentArm(current, owner, watchers, armEpoch)) return;
253
259
  if (watchedPath === APPLICATIONS_PATH && filename && !candidateNames.has(filename.toString().split(path.sep)[0] ?? "")) return;
254
260
  owner.markDirty();
@@ -303,17 +309,14 @@ function scheduleRearm(current, owner) {
303
309
  }, delayMs);
304
310
  current.rearmTimer.unref();
305
311
  }
306
- function logRefreshFailure(current, owner) {
307
- return (error) => {
308
- if (current.owner !== owner) return;
309
- current.context?.serviceHealth?.reportFailure(error);
310
- current.context?.logger.warn(`codex desktop generation refresh failed: ${String(error)}`);
311
- };
312
- }
313
312
  function refreshGeneration(current, owner, refresh) {
314
313
  refresh.then(() => {
315
314
  if (current.owner === owner && current.watchHealthy) current.context?.serviceHealth?.clearFailure();
316
- }).catch(logRefreshFailure(current, owner));
315
+ }).catch((error) => {
316
+ if (current.owner !== owner) return;
317
+ current.context?.serviceHealth?.reportFailure(error);
318
+ current.context?.logger.warn(`codex desktop generation refresh failed: ${String(error)}`);
319
+ });
317
320
  }
318
321
  function closeWatchers(current) {
319
322
  const watchers = current.watchers;
@@ -321,79 +324,6 @@ function closeWatchers(current) {
321
324
  for (const watcher of watchers ?? []) watcher.close();
322
325
  }
323
326
  //#endregion
324
- //#region extensions/codex/src/app-server/shared-client-lifecycle.ts
325
- /** Client ownership and synchronous retirement, independent of startup/auth execution. */
326
- const createCodexAppServerStartupLifetime = () => ({
327
- controller: new AbortController(),
328
- pending: /* @__PURE__ */ new Set()
329
- });
330
- const getSharedCodexAppServerClientState = defineCodexBuildState("openclaw.codexAppServerClientState", () => ({
331
- clients: /* @__PURE__ */ new Map(),
332
- liveClients: /* @__PURE__ */ new Set(),
333
- isolatedClients: /* @__PURE__ */ new Set(),
334
- entriesByClient: /* @__PURE__ */ new WeakMap(),
335
- desktopGenerationDrainChecks: /* @__PURE__ */ new Set(),
336
- startup: createCodexAppServerStartupLifetime(),
337
- startMetadata: /* @__PURE__ */ new WeakMap()
338
- }));
339
- function getCurrentSharedClientEntry(client) {
340
- const state = getSharedCodexAppServerClientState();
341
- const entry = client ? state.entriesByClient.get(client) : void 0;
342
- return entry && entry.client === client && state.clients.get(entry.key) === entry ? entry : void 0;
343
- }
344
- /**
345
- * Retires a matching shared client. Default is graceful: detach from the map
346
- * (future acquisitions get a fresh client) and close once leases drain.
347
- * `failActiveLeases` is for suspect clients only (timed-out turns): it closes
348
- * the physical connection immediately so co-leased attempts hit the normal
349
- * client-closed retry path, and pending acquires reject instead of leasing
350
- * the poisoned process. Routine cleanup must NOT use it — it would abort
351
- * healthy sibling turns on a working client.
352
- */
353
- function retireSharedCodexAppServerClientIfCurrent(client, opts) {
354
- if (!client) return;
355
- const state = getSharedCodexAppServerClientState();
356
- const currentEntry = getCurrentSharedClientEntry(client);
357
- const entry = currentEntry ?? state.entriesByClient.get(client);
358
- if (!entry || entry.client !== client && !entry.closeError) return;
359
- if (currentEntry) {
360
- state.clients.delete(entry.key);
361
- entry.closeWhenIdle = true;
362
- }
363
- if (opts?.failActiveLeases && (currentEntry || !entry.closeError)) {
364
- entry.closeError = /* @__PURE__ */ new Error("codex app-server client is closed");
365
- return {
366
- activeLeases: entry.activeLeases,
367
- closed: closeRetiredSharedClientEntry(entry)
368
- };
369
- }
370
- return {
371
- activeLeases: entry.activeLeases,
372
- closed: currentEntry ? closeRetiredSharedClientEntryIfIdle(entry) : false
373
- };
374
- }
375
- /** Gracefully retires exact clients attached to an older desktop generation. */
376
- function retireSharedCodexAppServerClientsBeforeDesktopGeneration(generation) {
377
- const state = getSharedCodexAppServerClientState();
378
- for (const entry of state.clients.values()) {
379
- const client = entry.client;
380
- const attached = client ? state.startMetadata.get(client) : void 0;
381
- if (client && attached?.desktopGeneration && attached.desktopGeneration.epoch < generation.epoch) retireSharedCodexAppServerClientIfCurrent(client);
382
- }
383
- }
384
- function closeRetiredSharedClientEntryIfIdle(entry) {
385
- if (!entry.closeWhenIdle || entry.activeLeases > 0 || entry.pendingAcquires > 0 || !entry.client) return false;
386
- entry.closeWhenIdle = false;
387
- return closeRetiredSharedClientEntry(entry);
388
- }
389
- function closeRetiredSharedClientEntry(entry) {
390
- const client = entry.client;
391
- if (!client) return false;
392
- entry.client = void 0;
393
- client.close();
394
- return true;
395
- }
396
- //#endregion
397
327
  //#region extensions/codex/src/app-server/auth-cache-key.ts
398
328
  /** Auth cache identity and native CLI credential reads, without login or refresh. */
399
329
  const CODEX_HOME_ENV_VAR = "CODEX_HOME";
@@ -495,4 +425,4 @@ function readFirstNonEmptyEnvEntry(env, keys) {
495
425
  }
496
426
  }
497
427
  //#endregion
498
- export { isCodexDesktopGenerationCurrent as _, readCodexCliAuthFileApiKey as a, resolveCodexAppServerPreparedApiKeyCacheKey as c, createCodexAppServerStartupLifetime as d, getCurrentSharedClientEntry as f, createCodexDesktopGenerationService as g, retireSharedCodexAppServerClientsBeforeDesktopGeneration as h, fingerprintTokenAuthProfileCacheKey as i, closeRetiredSharedClientEntry as l, retireSharedCodexAppServerClientIfCurrent as m, CODEX_AUTH_JSON_FILENAME as n, readFirstNonEmptyEnv as o, getSharedCodexAppServerClientState as p, fingerprintApiKeyAuthProfileCacheKey as r, resolveCodexAppServerFallbackApiKeyCacheKey as s, CODEX_APP_SERVER_API_KEY_ENV_VARS as t, closeRetiredSharedClientEntryIfIdle as u, waitForCodexDesktopGeneration as v };
428
+ export { readCodexCliAuthFileApiKey as a, resolveCodexAppServerPreparedApiKeyCacheKey as c, waitForCodexDesktopGeneration as d, readCodexDesktopArtifactTreeFingerprint as f, fingerprintTokenAuthProfileCacheKey as i, createCodexDesktopGenerationService as l, CODEX_AUTH_JSON_FILENAME as n, readFirstNonEmptyEnv as o, fingerprintApiKeyAuthProfileCacheKey as r, resolveCodexAppServerFallbackApiKeyCacheKey as s, CODEX_APP_SERVER_API_KEY_ENV_VARS as t, isCodexDesktopGenerationCurrent as u };
@@ -10,7 +10,6 @@ const { resolveCodexAppServerAuthProfileId, resolveCodexAppServerAuthProfileIdFo
10
10
  ensureAuthProfileStore,
11
11
  resolveAuthProfileOrder
12
12
  });
13
- /** Returns true when an auth profile uses native Codex/OpenAI app-server auth. */
14
13
  function isCodexAppServerNativeAuthProfile(lookup) {
15
14
  const authProfileId = lookup.authProfileId?.trim();
16
15
  if (!authProfileId) return false;
@@ -21,7 +20,7 @@ function isCodexAppServerNativeAuthProfile(lookup) {
21
20
  externalCliProviderIds: [CODEX_APP_SERVER_NATIVE_AUTH_PROVIDER],
22
21
  externalCliProfileIds: [authProfileId]
23
22
  })).profiles[authProfileId];
24
- if (!credential || credential.type === "api_key") return false;
23
+ if (!credential || credential.type === "api_key" || credential.type === "oauth" && (credential.authFlow === "chatgpt-token-sharing" || credential.authFlow === "chatgpt-identity")) return false;
25
24
  const provider = credential.provider?.trim();
26
25
  return Boolean(provider && resolveProviderIdForAuth(provider, { config: lookup.config }) === CODEX_APP_SERVER_NATIVE_AUTH_PROVIDER);
27
26
  } catch (error) {
@@ -0,0 +1,53 @@
1
+ import { r as formatCodexAuthProfileUnavailableMessage, t as CODEX_NATIVE_PROFILE_IMPORT_COMMAND } from "./auth-profile-recovery-BREezV0L.mjs";
2
+ //#region extensions/codex/src/auth-profile-health.ts
3
+ const CHECK_ID = "codex/native-profile-recovery";
4
+ const PROFILE_ID = "openai:default";
5
+ async function collectFindings(config, env) {
6
+ const declared = config.auth?.profiles?.[PROFILE_ID];
7
+ if (declared?.provider !== "openai" || declared.mode !== "oauth") return [];
8
+ const [{ loadAuthProfileStoreForRuntime }, { listAgentIds, resolveAgentDir }] = await Promise.all([import("openclaw/plugin-sdk/agent-runtime"), import("openclaw/plugin-sdk/agent-scope-runtime")]);
9
+ const findings = [];
10
+ const missing = [];
11
+ for (const agentId of listAgentIds(config)) try {
12
+ if (!loadAuthProfileStoreForRuntime(resolveAgentDir(config, agentId, env), {
13
+ readOnly: true,
14
+ config,
15
+ externalCli: { mode: "none" }
16
+ }, env).profiles[PROFILE_ID]) missing.push(agentId);
17
+ } catch (error) {
18
+ findings.push({
19
+ checkId: CHECK_ID,
20
+ source: "codex",
21
+ severity: "warning",
22
+ message: `Could not inspect OpenAI auth profiles for agent "${agentId}": ${error instanceof Error ? error.message : String(error)}`,
23
+ fixHint: "openclaw doctor --fix"
24
+ });
25
+ }
26
+ if (missing.length > 0) findings.push({
27
+ checkId: CHECK_ID,
28
+ source: "codex",
29
+ severity: "warning",
30
+ message: `${formatCodexAuthProfileUnavailableMessage(PROFILE_ID)} Affected agents: ${missing.join(", ")}.`,
31
+ fixHint: CODEX_NATIVE_PROFILE_IMPORT_COMMAND
32
+ });
33
+ return findings;
34
+ }
35
+ const codexNativeProfileRecoveryHealthCheck = {
36
+ id: CHECK_ID,
37
+ kind: "plugin",
38
+ source: "codex",
39
+ description: "Explain recovery for a configured profile formerly supplied by native Codex login.",
40
+ detect: (ctx) => collectFindings(ctx.cfg, ctx.env ?? process.env)
41
+ };
42
+ const codexNativeProfileRecoveryService = {
43
+ id: CHECK_ID,
44
+ async start(ctx) {
45
+ const findings = await collectFindings(ctx.config, {
46
+ ...process.env,
47
+ OPENCLAW_STATE_DIR: ctx.stateDir
48
+ });
49
+ for (const finding of findings) ctx.logger.warn(finding.message);
50
+ }
51
+ };
52
+ //#endregion
53
+ export { codexNativeProfileRecoveryService as n, codexNativeProfileRecoveryHealthCheck as t };
@@ -0,0 +1,14 @@
1
+ //#region extensions/codex/src/app-server/auth-profile-recovery.ts
2
+ const CODEX_NATIVE_PROFILE_IMPORT_COMMAND = "openclaw models auth login --provider openai --method device-code";
3
+ var CodexAppServerAuthProfileUnavailableError = class extends Error {
4
+ constructor(..._args) {
5
+ super(..._args);
6
+ this.code = "selected_auth_profile_unavailable";
7
+ }
8
+ };
9
+ function formatCodexAuthProfileUnavailableMessage(profileId) {
10
+ const missing = `Codex app-server auth profile "${profileId}" was not found in the OpenClaw credential store. This is a local credential lookup failure.`;
11
+ return profileId === "openai:default" ? `${missing} Since 2026.9.5, OpenClaw no longer supplies this profile from the native Codex login. Run \`${CODEX_NATIVE_PROFILE_IMPORT_COMMAND}\` to import that login or sign in through OpenClaw, then retry. For multiple agents, add \`--agent <id>\`.` : `${missing} Restore or select an existing OpenAI profile, then retry.`;
12
+ }
13
+ //#endregion
14
+ export { CodexAppServerAuthProfileUnavailableError as n, formatCodexAuthProfileUnavailableMessage as r, CODEX_NATIVE_PROFILE_IMPORT_COMMAND as t };
@@ -0,0 +1,44 @@
1
+ import { r as normalizeCodexAppServerArgs } from "./launch-args-DbFCehO7.mjs";
2
+ import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
3
+ import path from "node:path";
4
+ import { homedir } from "node:os";
5
+ //#region extensions/codex/src/app-server/auth-start-options.ts
6
+ const CODEX_APP_SERVER_HOME_DIRNAME = "codex-home";
7
+ const CODEX_EPHEMERAL_AUTH_STORE_OVERRIDE = "cli_auth_credentials_store=\"ephemeral\"";
8
+ function resolveCodexAppServerHomeDir(agentDir) {
9
+ if (!agentDir) throw new Error("Agent-scoped Codex requires an OpenClaw agent directory");
10
+ return path.join(path.resolve(agentDir), CODEX_APP_SERVER_HOME_DIRNAME);
11
+ }
12
+ /** Resolves the native user Codex home used by Desktop and the CLI. */
13
+ function resolveCodexAppServerUserHomeDir(env = process.env, homedir$1 = homedir) {
14
+ const configured = normalizeOptionalString(env.CODEX_HOME);
15
+ return path.resolve(configured ?? path.join(homedir$1(), ".codex"));
16
+ }
17
+ /** Resolves the local CODEX_HOME used when starting one app-server connection. */
18
+ function resolveCodexAppServerLocalHomeDir(startOptions, agentDir, env = process.env) {
19
+ if (startOptions.codexHome) return startOptions.codexHome;
20
+ const configured = startOptions.env?.CODEX_HOME;
21
+ if (configured?.trim()) return configured;
22
+ return startOptions.homeScope === "user" ? resolveCodexAppServerUserHomeDir(env) : resolveCodexAppServerHomeDir(agentDir);
23
+ }
24
+ /** Forces OpenClaw-owned Codex auth to remain process-local. */
25
+ function withEphemeralCodexAuthStore(params) {
26
+ const { startOptions } = params;
27
+ if (!params.preparedAuth && params.authProfileId === null) return startOptions;
28
+ const args = normalizeCodexAppServerArgs(startOptions.args, CODEX_EPHEMERAL_AUTH_STORE_OVERRIDE);
29
+ return args === startOptions.args ? startOptions : {
30
+ ...startOptions,
31
+ args
32
+ };
33
+ }
34
+ function withClearedEnvironmentVariables(startOptions, envVars) {
35
+ const clearEnv = startOptions.clearEnv ?? [];
36
+ const missingEnvVars = envVars.filter((envVar) => !clearEnv.includes(envVar));
37
+ if (missingEnvVars.length === 0) return startOptions;
38
+ return {
39
+ ...startOptions,
40
+ clearEnv: [...clearEnv, ...missingEnvVars]
41
+ };
42
+ }
43
+ //#endregion
44
+ export { withEphemeralCodexAuthStore as a, withClearedEnvironmentVariables as i, resolveCodexAppServerLocalHomeDir as n, resolveCodexAppServerUserHomeDir as r, resolveCodexAppServerHomeDir as t };
@@ -1,4 +1,4 @@
1
- import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
1
+ import { t as __exportAll } from "./session-binding-sidecars-jo6H8dFr.mjs";
2
2
  import { AgentHarnessPreflightError } from "openclaw/plugin-sdk/agent-harness-registration";
3
3
  import { createPluginRuntimeStore } from "openclaw/plugin-sdk/runtime-store";
4
4
  //#region extensions/codex/src/app-server/binding-connection.ts
@@ -44,7 +44,7 @@ function requireCodexSupervisionModelSelection(binding) {
44
44
  }
45
45
  /** Registration publishes the resolver; connection policy loads only for an actual request. */
46
46
  async function resolveCodexBindingAppServerConnection(params) {
47
- return (await import("./binding-connection.runtime-CnRMC0ta.mjs")).resolveCodexBindingAppServerConnection(params, catalogHomes.tryGetRuntime());
47
+ return (await import("./binding-connection.runtime-6TpgD1M6.mjs")).resolveCodexBindingAppServerConnection(params, catalogHomes.tryGetRuntime());
48
48
  }
49
49
  //#endregion
50
50
  export { setCodexCatalogConnectionHomeResolver as a, resolveCodexBindingAppServerConnection as i, binding_connection_exports as n, requireCodexSupervisionModelSelection as r, assertCodexSessionRuntimeOwnership as t };
@@ -1,7 +1,7 @@
1
- import { g as resolveCodexAppServerLocalHomeDir } from "./config-security-BRQ2mgW9.mjs";
2
- import { d as readCodexPluginConfig } from "./config-parsing-CcB9iPoq.mjs";
3
- import { t as buildCodexAppServerConnectionFingerprint } from "./plugin-app-cache-key-BOxKP7db.mjs";
4
- import { n as resolveCodexAppServerRuntimeOptions, r as resolveCodexSupervisionAppServerRuntimeOptions } from "./config-runtime-CeAhl_h4.mjs";
1
+ import { d as readCodexPluginConfig } from "./config-parsing-b088LyhT.mjs";
2
+ import { n as resolveCodexAppServerLocalHomeDir } from "./auth-start-options-BPIPeEX8.mjs";
3
+ import { t as buildCodexAppServerConnectionFingerprint } from "./plugin-app-cache-key-BL9B5H0L.mjs";
4
+ import { n as resolveCodexAppServerRuntimeOptions, r as resolveCodexSupervisionAppServerRuntimeOptions } from "./config-runtime-C0NbLms1.mjs";
5
5
  //#region extensions/codex/src/app-server/binding-connection.runtime.ts
6
6
  /** Resolves connection and auth ownership exclusively from the private thread binding. */
7
7
  async function resolveCodexBindingAppServerConnection(params, discoverHomes) {
@@ -41,7 +41,7 @@ async function resolveCodexBindingAppServerConnection(params, discoverHomes) {
41
41
  appServer,
42
42
  usesSupervisionConnection,
43
43
  requestAuthProfileId: usesSupervisionConnection ? void 0 : authProfileId,
44
- clientAuthProfileId: usesSupervisionConnection ? null : authProfileId
44
+ clientAuthProfileId: usesSupervisionConnection || appServer.start.homeScope === "user" ? null : authProfileId
45
45
  };
46
46
  }
47
47
  //#endregion