@openclaw/codex 2026.9.1 → 2026.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/README.md +2 -0
  2. package/dist/api.js +18 -23
  3. package/dist/apply-B6el6hdO.js +357 -0
  4. package/dist/{attempt-client-cleanup-DYHcRQAa.js → attempt-client-cleanup-D6cR54TV.js} +113 -49
  5. package/dist/{attempt-context-DmQUNWwT.js → attempt-context-AO4DSjE0.js} +11 -9
  6. package/dist/{event-projector-usage-C5mcrGjp.js → attempt-notifications--H8zXR5-.js} +3 -89
  7. package/dist/auth-cache-key-Kq6oerr6.js +498 -0
  8. package/dist/auth-profile-CwzO4_RG.js +43 -0
  9. package/dist/auth-profile-selection-DFu9e167.js +45 -0
  10. package/dist/{binding-connection-E6uDsPlx.js → binding-connection-QqgcPCgk.js} +18 -3
  11. package/dist/{bounded-turn-wzJrwKKe.js → bounded-turn-lRpmZHFv.js} +54 -150
  12. package/dist/build-state-6RL6qohz.js +19 -0
  13. package/dist/{capabilities-dIjNVCYH.js → capabilities-BeqLPbtM.js} +2 -1
  14. package/dist/cli-metadata.js +1 -1
  15. package/dist/client-BEKu4yDx.js +3983 -0
  16. package/dist/command-dispatch-CisT9Jqq.js +21 -0
  17. package/dist/{command-formatters-CLHhEB1Q.js → command-formatters-DeTfrapr.js} +2 -2
  18. package/dist/{command-handlers-CTGb2csu.js → command-handlers-BfIsJEuA.js} +158 -76
  19. package/dist/command-rpc-BMqRQOFX.js +226 -0
  20. package/dist/{compact-_t0HQrUS.js → compact-CGJZ2rlb.js} +89 -49
  21. package/dist/config-JDfTI4VI.js +106 -0
  22. package/dist/{config-BhmfC1s6.js → config-options-jnIFvwxD.js} +208 -654
  23. package/dist/config-runtime-BWf6JLWG.js +11 -0
  24. package/dist/config-utils-C57JiJrU.js +69 -0
  25. package/dist/conversation-binding-CxOlHiix.js +889 -0
  26. package/dist/{plugin-marketplace-discovery-CfFlKqDl.js → conversation-control-CUCrSIQI.js} +36 -155
  27. package/dist/doctor-contract-api.js +8 -9
  28. package/dist/{dynamic-tools-BU9tmlYm.js → dynamic-tools-D-JBoaLt.js} +734 -698
  29. package/dist/{effective-mcp-catalog-DzYBW4h1.js → effective-mcp-catalog-J_5Ep5Um.js} +4 -3
  30. package/dist/{elicitation-input-DMkeki8d.js → elicitation-input-DPoK8F7w.js} +8 -22
  31. package/dist/ephemeral-turn-DSwzP8YY.js +101 -0
  32. package/dist/{event-projector-assistant-message-DHRFXKbS.js → event-projector-assistant-message-BmBM4qBV.js} +23 -27
  33. package/dist/event-projector-usage-CIyrYYid.js +102 -0
  34. package/dist/{harness-DXVZ5II5.js → harness-FR6eQgyO.js} +47 -17
  35. package/dist/harness.js +1 -1
  36. package/dist/history-rejection-B4nOXNXF.js +13 -0
  37. package/dist/{image-payload-sanitizer-CnfoUPCE.js → image-payload-sanitizer-tupAr-2o.js} +29 -15
  38. package/dist/incognito-session-uhrBF6wJ.js +15 -0
  39. package/dist/index.js +413 -2893
  40. package/dist/{isolated-completion-kg9kv4iH.js → isolated-completion-DHBefrzg.js} +12 -21
  41. package/dist/{managed-binary-4-Vjz5GH.js → managed-binary-DrjjRRUD.js} +17 -84
  42. package/dist/managed-thread-store-D1t5jh3G.js +66 -0
  43. package/dist/media-understanding-provider.js +4 -1
  44. package/dist/{model-catalog-CUM68Hkl.js → model-catalog-B_6M04Wo.js} +6 -5
  45. package/dist/{models-sYnEc0gd.js → models-P9k2qAof.js} +4 -4
  46. package/dist/native-execution-policy-umd0tgh4.js +128 -0
  47. package/dist/{native-subagent-monitor-CnH147jH.js → native-subagent-monitor-BbCUKRwC.js} +76 -48
  48. package/dist/node-cli-sessions-rj0ysJwM.js +527 -0
  49. package/dist/{node-exec-server.runtime-CstNHCmC.js → node-exec-server.runtime-BY_ctYnT.js} +54 -23
  50. package/dist/plan-BMJdMOEF.js +711 -0
  51. package/dist/plugin-activation-BQK-f5sV.js +133 -0
  52. package/dist/{thread-resume-C7pyVKeW.js → plugin-app-cache-key-CdSQzWyX.js} +5 -53
  53. package/dist/{plugin-approval-roundtrip-CNe-Xrjx.js → plugin-approval-roundtrip-DeW95wB5.js} +1 -1
  54. package/dist/plugin-inventory-CoRCzWW4.js +325 -0
  55. package/dist/plugin-marketplace-discovery-3akBizzF.js +134 -0
  56. package/dist/{plugin-metadata-cache-BFrPhb2c.js → plugin-metadata-cache-DgNfRAGA.js} +13 -9
  57. package/dist/protocol-CAAcVIKF.js +275 -0
  58. package/dist/{provider-capabilities-DW5p4k9w.js → provider-capabilities-W4tfK5Y5.js} +2 -2
  59. package/dist/{rate-limits-CawQJfUS.js → rate-limits-Bqnx1N4z.js} +1 -1
  60. package/dist/request-CGvGOpeR.js +198 -0
  61. package/dist/{run-attempt-D1hJO4fX.js → run-attempt-DwKds3DN.js} +1498 -1028
  62. package/dist/{runtime-artifact-C3jVimFn.js → runtime-artifact-T-NwqeSH.js} +28 -28
  63. package/dist/sandbox-guard-BcT66fWy.js +165 -0
  64. package/dist/{session-binding-BHuTCRZQ.js → session-binding-CKSepwIC.js} +118 -324
  65. package/dist/session-binding-record-CaZjYwNS.js +256 -0
  66. package/dist/session-catalog-HaDcp7Sv.js +1533 -0
  67. package/dist/session-catalog-adoption-BKLtSrwi.js +251 -0
  68. package/dist/session-catalog-archive-D0i2pGj2.js +56 -0
  69. package/dist/session-catalog-home-id-D7-aLiNt.js +190 -0
  70. package/dist/session-catalog-node-adoption-BUuDYY8R.js +182 -0
  71. package/dist/session-catalog-node-continue-CBtc4wkI.js +238 -0
  72. package/dist/session-catalog-parsing-CdD3JhdM.js +280 -0
  73. package/dist/session-catalog-provenance-DkJHo735.js +124 -0
  74. package/dist/{session-cli-CmFEXMAM.js → session-cli-CbgaHh0f.js} +3 -2
  75. package/dist/session-history-Cz-tOOYj.js +96 -0
  76. package/dist/{session-upstream-marker-C351-5Qw.js → session-history-import-DFN7sWRU.js} +5 -49
  77. package/dist/session-history-read-cxPUxyVV.js +50 -0
  78. package/dist/session-history-worker-runtime.js +60 -0
  79. package/dist/{settled-turn-context-D3SNWtUn.js → session-history.worker-CNEvGaU5.js} +75 -69
  80. package/dist/session-history.worker.js +2 -0
  81. package/dist/{session-initialization-BeWzjGiR.js → session-initialization-Jo86C60I.js} +2 -1
  82. package/dist/{session-permission-policy-DeWVTCMj.js → session-permission-policy-B22InTp_.js} +4 -7
  83. package/dist/{session-retirement-BujDjXVF.js → session-retirement-BSNG_mhf.js} +8 -7
  84. package/dist/session-upstream-marker-D15C9NHp.js +46 -0
  85. package/dist/settled-turn-context-Du6gdUDd.js +45 -0
  86. package/dist/{settled-turn-finalizer-BVJx4yoc.js → settled-turn-finalizer-BuLUrZl2.js} +54 -42
  87. package/dist/shared-client-CVhez2Uo.js +2911 -0
  88. package/dist/{side-question-BTZAII4l.js → side-question-DLbr2vUU.js} +135 -191
  89. package/dist/source-Da-h6f7e.js +518 -0
  90. package/dist/thread-archive-guard-D1bP04Tf.js +53 -0
  91. package/dist/{thread-lifecycle-DAcEJ_Om.js → thread-lifecycle-D1pzRwHB.js} +467 -977
  92. package/dist/{thread-ownership-zGokd8i1.js → thread-ownership-D6oASVRu.js} +15 -17
  93. package/dist/{thread-policy-g4KbJPzp.js → thread-policy-D8kI7yAO.js} +2 -2
  94. package/dist/thread-resume-T5cveyxA.js +52 -0
  95. package/dist/timeout-BVw8aaM1.js +33 -0
  96. package/dist/transcript-mirror-attestation-DibE0krH.js +89 -0
  97. package/dist/{transcript-mirror-DTUxFWa_.js → transcript-mirror-t5TOccct.js} +111 -379
  98. package/dist/{transport-stdio-CyPldczm.js → transport-stdio-BGjHoYLr.js} +80 -48
  99. package/dist/{upstream-session-fork-CYlBIGVt.js → upstream-session-fork-De-sLJ2r.js} +94 -166
  100. package/dist/{usage-Bj-rrzkR.js → usage-CPPTmBvZ.js} +4 -3
  101. package/dist/version-omm6IPI3.js +12 -0
  102. package/dist/{web-search-provider.runtime-D2FWSK4w.js → web-search-provider.runtime-CSVgQL0w.js} +3 -3
  103. package/openclaw.plugin.json +22 -1
  104. package/package.json +6 -6
  105. package/dist/request-DYAI5FQE.js +0 -475
  106. package/dist/session-catalog-yyvTWFOw.js +0 -3120
  107. package/dist/session-history-C5J1AKzG.js +0 -87
  108. package/dist/shared-client-DxcfF9KX.js +0 -7494
  109. package/dist/{auth-binding-Ds_QVm-X.js → auth-binding-Co2Vfcf_.js} +1 -1
@@ -0,0 +1,226 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
2
+ import { o as isJsonObject } from "./protocol-CAAcVIKF.js";
3
+ import { n as describeControlFailure, t as CODEX_CONTROL_METHODS } from "./capabilities-BeqLPbtM.js";
4
+ import { i as requestCodexAppServerJson, o as withCodexAppServerJsonClient } from "./request-CGvGOpeR.js";
5
+ import "./config-JDfTI4VI.js";
6
+ import { n as resolveCodexAppServerRuntimeOptions, r as resolveCodexSupervisionAppServerRuntimeOptions } from "./config-runtime-BWf6JLWG.js";
7
+ import { n as prepareCodexAppServerAuthBinding } from "./auth-binding-Co2Vfcf_.js";
8
+ import { a as resolveCodexAppServerAuthProfileStore, r as resolveCodexAppServerAuthProfileId } from "./auth-profile-CwzO4_RG.js";
9
+ import { Z as resolveCodexAppServerPreparedAuthHandoff } from "./shared-client-CVhez2Uo.js";
10
+ import { a as closeCodexStartupClientBestEffort } from "./attempt-client-cleanup-D6cR54TV.js";
11
+ import { n as listCodexAppServerModels } from "./models-P9k2qAof.js";
12
+ import { n as createCodexSessionGenerationSupersededError } from "./session-binding-CKSepwIC.js";
13
+ import { t as resumeCodexAppServerThread } from "./thread-resume-T5cveyxA.js";
14
+ import { resolveAgentDir, resolveSessionAgentIdsStrict } from "openclaw/plugin-sdk/agent-scope-runtime";
15
+ import { resolveAgentWorkspaceDir } from "openclaw/plugin-sdk/agent-runtime";
16
+ import { prepareAgentRuntimeAuth } from "openclaw/plugin-sdk/agent-harness-runtime";
17
+ import { getSessionEntry, resolveStorePath } from "openclaw/plugin-sdk/session-store-runtime";
18
+ import { resolveSessionModelRef } from "openclaw/plugin-sdk/model-session-runtime";
19
+ import { resolveApiKeyForProvider } from "openclaw/plugin-sdk/provider-auth-runtime";
20
+ //#region extensions/codex/src/command-rpc.ts
21
+ var command_rpc_exports = /* @__PURE__ */ __exportAll({
22
+ codexControlRequest: () => codexControlRequest,
23
+ readCodexStatusProbes: () => readCodexStatusProbes,
24
+ requestOptions: () => requestOptions,
25
+ safeCodexControlRequest: () => safeCodexControlRequest
26
+ });
27
+ async function prepareControlAuth(options, startOptions) {
28
+ if (!options.onResponse) return {
29
+ authProfileId: options.authProfileId ?? void 0,
30
+ clientOptions: { authProfileId: options.authProfileId }
31
+ };
32
+ if (!options.config || !options.sessionKey || !options.sessionId) throw new Error("Codex control subscription requires admitted session authority.");
33
+ const config = options.config;
34
+ const { sessionAgentId } = resolveSessionAgentIdsStrict({
35
+ config,
36
+ sessionKey: options.sessionKey,
37
+ agentId: options.agentId
38
+ });
39
+ const agentDir = options.agentDir ?? resolveAgentDir(config, sessionAgentId);
40
+ const workspaceDir = resolveAgentWorkspaceDir(config, sessionAgentId);
41
+ const entry = getSessionEntry({
42
+ agentId: sessionAgentId,
43
+ storePath: options.storePath?.trim() || resolveStorePath(config.session?.store, { agentId: sessionAgentId }),
44
+ sessionKey: options.sessionKey,
45
+ hydrateSkillPromptRefs: false,
46
+ readConsistency: "latest"
47
+ });
48
+ if (entry?.sessionId !== options.sessionId) throw createCodexSessionGenerationSupersededError(options.sessionId);
49
+ if (options.authProfileId === null || startOptions.homeScope === "user") return {
50
+ authProfileId: options.authProfileId ?? void 0,
51
+ clientOptions: { authProfileId: options.authProfileId }
52
+ };
53
+ const model = resolveSessionModelRef(config, entry, sessionAgentId);
54
+ const authProfileId = entry?.authProfileOverride ?? options.authProfileId;
55
+ const store = resolveCodexAppServerAuthProfileStore({
56
+ agentDir,
57
+ config,
58
+ authProfileId
59
+ });
60
+ const { plan, attempts } = prepareAgentRuntimeAuth({
61
+ provider: model.provider,
62
+ modelId: model.model,
63
+ config,
64
+ agentDir,
65
+ workspaceDir,
66
+ authProfileStore: store,
67
+ sessionAuthProfileId: authProfileId,
68
+ sessionAuthProfileSource: entry?.authProfileOverrideSource,
69
+ harnessId: "codex",
70
+ harnessAuthBootstrap: "harness"
71
+ });
72
+ const route = plan.modelRoute;
73
+ const resolvedAuth = route ? await resolveApiKeyForProvider({
74
+ provider: route.provider,
75
+ modelId: route.modelId,
76
+ modelApi: route.api,
77
+ cfg: config,
78
+ agentDir,
79
+ workspaceDir,
80
+ store,
81
+ profileId: attempts[0]?.profileId,
82
+ lockedProfile: plan.forwardedAuthProfileSource === "user",
83
+ allowAuthProfileFallback: attempts[0]?.allowAuthProfileFallback,
84
+ skipSetupProviderFallback: true
85
+ }) : void 0;
86
+ const handoff = await resolveCodexAppServerPreparedAuthHandoff({
87
+ authRequirement: route?.authRequirement,
88
+ resolvedApiKey: resolvedAuth?.apiKey,
89
+ authProfileId: route ? plan.forwardedAuthProfileId : resolveCodexAppServerAuthProfileId({
90
+ authProfileId: plan.forwardedAuthProfileId,
91
+ store,
92
+ config
93
+ }),
94
+ authProfileStore: store,
95
+ agentDir,
96
+ homeScope: startOptions.homeScope ?? "agent",
97
+ config,
98
+ subscriptionProfileRequiredError: "Prepared Codex subscription route requires a forwarded OpenAI OAuth or token profile.",
99
+ subscriptionProfileUnusableError: "Prepared Codex subscription auth profile is unusable."
100
+ });
101
+ const binding = handoff.authProfileId ? await prepareCodexAppServerAuthBinding({
102
+ authProfileId: handoff.authProfileId,
103
+ authProfileStore: store,
104
+ agentDir,
105
+ config
106
+ }) : void 0;
107
+ return {
108
+ authProfileId: handoff.authProfileId,
109
+ clientOptions: {
110
+ ...handoff.preparedAuth ? { preparedAuth: handoff.preparedAuth } : { authProfileId: handoff.authProfileId },
111
+ authRequirement: route?.authRequirement,
112
+ authProfileStore: binding?.authProfileStore ?? store,
113
+ authBindingFingerprint: binding?.fingerprint,
114
+ agentDir
115
+ }
116
+ };
117
+ }
118
+ function requestOptions(pluginConfig, limit, config, agentDir) {
119
+ const runtime = resolveCodexAppServerRuntimeOptions({ pluginConfig });
120
+ return {
121
+ limit,
122
+ timeoutMs: runtime.requestTimeoutMs,
123
+ startOptions: runtime.start,
124
+ config,
125
+ agentDir
126
+ };
127
+ }
128
+ async function codexControlRequest(pluginConfig, method, requestParams, options = {}) {
129
+ const runtime = options.startOptions ? resolveCodexSupervisionAppServerRuntimeOptions({ pluginConfig }) : resolveCodexAppServerRuntimeOptions({ pluginConfig });
130
+ const startOptions = options.startOptions ?? runtime.start;
131
+ const auth = await prepareControlAuth(options, startOptions);
132
+ const controlRequestOptions = {
133
+ timeoutMs: options.timeoutMs ?? runtime.requestTimeoutMs,
134
+ assertCurrent: options.assertCurrent,
135
+ startOptions,
136
+ config: options.config,
137
+ sessionKey: options.sessionKey,
138
+ sessionId: options.sessionId,
139
+ agentDir: options.agentDir,
140
+ isolated: options.isolated,
141
+ ...auth.clientOptions
142
+ };
143
+ if (options.onResponse || options.beforeRequest) return await withCodexAppServerJsonClient(controlRequestOptions, async (request, client, scope) => {
144
+ await options.beforeRequest?.(request, client, scope);
145
+ scope.assertCurrent();
146
+ let response;
147
+ if (method === "thread/resume") {
148
+ if (!isJsonObject(requestParams) || typeof requestParams.threadId !== "string") throw new Error("Codex thread/resume requires a thread id.");
149
+ response = await resumeCodexAppServerThread({
150
+ client,
151
+ request: {
152
+ ...requestParams,
153
+ threadId: requestParams.threadId
154
+ },
155
+ requestResume: () => request({
156
+ method,
157
+ requestParams
158
+ }),
159
+ abandonClient: () => closeCodexStartupClientBestEffort(client)
160
+ });
161
+ } else response = await request({
162
+ method,
163
+ requestParams
164
+ });
165
+ await options.onResponse?.(response, client, {
166
+ authProfileId: auth.authProfileId,
167
+ assertCurrent: scope.assertCurrent
168
+ });
169
+ scope.assertCurrent();
170
+ return response;
171
+ });
172
+ return await requestCodexAppServerJson({
173
+ method,
174
+ requestParams,
175
+ ...controlRequestOptions
176
+ });
177
+ }
178
+ async function safeCodexControlRequest(pluginConfig, method, requestParams, options = {}) {
179
+ return await safeValue(async () => await codexControlRequest(pluginConfig, method, requestParams, options));
180
+ }
181
+ async function safeCodexModelList(pluginConfig, limit, config, agentDir) {
182
+ return await safeValue(async () => await listCodexAppServerModels(requestOptions(pluginConfig, limit, config, agentDir)));
183
+ }
184
+ async function readCodexStatusProbes(pluginConfig, config, agentDir) {
185
+ const [models, account, limits, mcps, skills] = await Promise.all([
186
+ safeCodexModelList(pluginConfig, 20, config, agentDir),
187
+ safeCodexControlRequest(pluginConfig, CODEX_CONTROL_METHODS.account, { refreshToken: false }, {
188
+ config,
189
+ agentDir
190
+ }),
191
+ safeCodexControlRequest(pluginConfig, CODEX_CONTROL_METHODS.rateLimits, void 0, {
192
+ config,
193
+ agentDir
194
+ }),
195
+ safeCodexControlRequest(pluginConfig, CODEX_CONTROL_METHODS.listMcpServers, { limit: 100 }, {
196
+ config,
197
+ agentDir
198
+ }),
199
+ safeCodexControlRequest(pluginConfig, CODEX_CONTROL_METHODS.listSkills, {}, {
200
+ config,
201
+ agentDir
202
+ })
203
+ ]);
204
+ return {
205
+ models,
206
+ account,
207
+ limits,
208
+ mcps,
209
+ skills
210
+ };
211
+ }
212
+ async function safeValue(read) {
213
+ try {
214
+ return {
215
+ ok: true,
216
+ value: await read()
217
+ };
218
+ } catch (error) {
219
+ return {
220
+ ok: false,
221
+ error: describeControlFailure(error)
222
+ };
223
+ }
224
+ }
225
+ //#endregion
226
+ export { safeCodexControlRequest as a, requestOptions as i, command_rpc_exports as n, readCodexStatusProbes as r, codexControlRequest as t };
@@ -1,20 +1,26 @@
1
- import { $t as isJsonObject, At as retainCodexAppServerLiveThread, St as consumeCodexAppServerLiveThread, c as getLeasedSharedCodexAppServerClient, h as releaseLeasedSharedCodexAppServerClient, q as CodexAppServerRpcError } from "./shared-client-DxcfF9KX.js";
2
- import { d as sessionBindingIdentity, t as CODEX_APP_SERVER_BINDING_GUARDED_REQUEST_TIMEOUT_MS } from "./session-binding-BHuTCRZQ.js";
3
- import { _ as readCodexNotificationTurnId, a as closeCodexStartupClientBestEffort, d as unsubscribeCodexThreadBestEffort, g as readCodexNotificationThreadId, r as CodexAppServerUnsafeSubscriptionError, s as isCodexAlreadyTerminalInterruptError } from "./attempt-client-cleanup-DYHcRQAa.js";
4
- import { f as readCodexNotificationItem, i as readCodexThreadContextSnapshot } from "./event-projector-usage-C5mcrGjp.js";
5
- import { t as resumeCodexAppServerThread } from "./thread-resume-C7pyVKeW.js";
6
- import { l as isIncognitoSessionKey, o as withCodexAppServerThreadMutation, t as isSameCodexAppServerThreadOwner } from "./thread-ownership-zGokd8i1.js";
7
- import { s as resolveCodexNativeExecutionBlock } from "./request-DYAI5FQE.js";
8
- import { r as assertCodexSupervisionThreadLineage } from "./thread-policy-g4KbJPzp.js";
9
- import { n as resolveCodexBindingAppServerConnection } from "./binding-connection-E6uDsPlx.js";
1
+ import { l as sessionBindingIdentity } from "./session-binding-record-CaZjYwNS.js";
2
+ import { o as isJsonObject } from "./protocol-CAAcVIKF.js";
3
+ import { u as isCodexAppServerPrewriteRequestCancellationError } from "./client-BEKu4yDx.js";
4
+ import { n as withCodexAppServerThreadMutation, t as isIncognitoSessionKey } from "./incognito-session-uhrBF6wJ.js";
5
+ import { r as CodexAppServerRpcError } from "./session-catalog-provenance-DkJHo735.js";
6
+ import { i as resolveCodexBindingAppServerConnection } from "./binding-connection-QqgcPCgk.js";
7
+ import { P as consumeCodexAppServerLiveThread, W as retainCodexAppServerLiveThread, c as getLeasedSharedCodexAppServerClient, h as releaseLeasedSharedCodexAppServerClient } from "./shared-client-CVhez2Uo.js";
8
+ import { _ as readCodexNotificationTurnId, a as closeCodexStartupClientBestEffort, c as isCodexNoActiveTurnInterruptError, d as unsubscribeCodexThreadBestEffort, g as readCodexNotificationThreadId, r as CodexAppServerUnsafeSubscriptionError } from "./attempt-client-cleanup-D6cR54TV.js";
9
+ import { s as readCodexNotificationItem } from "./attempt-notifications--H8zXR5-.js";
10
+ import { n as readCodexThreadContextSnapshot } from "./event-projector-usage-CIyrYYid.js";
11
+ import { o as resolveCodexSessionBinding, t as CODEX_APP_SERVER_BINDING_GUARDED_REQUEST_TIMEOUT_MS } from "./session-binding-CKSepwIC.js";
12
+ import { r as assertCodexSupervisionThreadLineage } from "./thread-policy-D8kI7yAO.js";
13
+ import { t as resumeCodexAppServerThread } from "./thread-resume-T5cveyxA.js";
14
+ import { t as isSameCodexAppServerThreadOwner } from "./thread-ownership-D6oASVRu.js";
10
15
  import { t as persistCodexContextCompactionActivity } from "./context-compaction-activity-CMla5FPJ.js";
16
+ import { t as resolveCodexNativeExecutionBlock } from "./sandbox-guard-BcT66fWy.js";
11
17
  import { asOptionalRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
18
+ import { resolveDefaultAgentId } from "openclaw/plugin-sdk/agent-scope-runtime";
19
+ import { coerceErrorMessage } from "openclaw/plugin-sdk/error-runtime";
12
20
  import { createDeferred } from "openclaw/plugin-sdk/extension-shared";
13
- import { embeddedAgentLog, resolveCompactionTimeoutMs } from "openclaw/plugin-sdk/agent-harness-runtime";
14
21
  import { resolveAgentDir as resolveAgentDir$1 } from "openclaw/plugin-sdk/agent-runtime";
15
- import { resolveDefaultAgentId as resolveDefaultAgentId$1 } from "openclaw/plugin-sdk/agent-scope-runtime";
22
+ import { embeddedAgentLog, resolveCompactionTimeoutMs } from "openclaw/plugin-sdk/agent-harness-runtime";
16
23
  import { AsyncLocalStorage } from "node:async_hooks";
17
- import { coerceErrorMessage } from "openclaw/plugin-sdk/error-runtime";
18
24
  import { createDedupeCache } from "openclaw/plugin-sdk/dedupe-runtime";
19
25
  //#region extensions/codex/src/app-server/compact.ts
20
26
  const warnedIgnoredCompactionOverrides = createDedupeCache({
@@ -77,7 +83,7 @@ function watchCodexNativeCompactionCompletion(params) {
77
83
  threadId: params.threadId,
78
84
  turnId: compactionTurnId
79
85
  }, { timeoutMs: Math.max(1, params.interruptGraceMs) }).catch((error) => {
80
- if (isCodexAlreadyTerminalInterruptError(error)) {
86
+ if (isCodexNoActiveTurnInterruptError(error)) {
81
87
  if (compactionItemCompleted) {
82
88
  complete();
83
89
  return;
@@ -292,7 +298,33 @@ async function compactCodexNativeThread(params, options) {
292
298
  agentId: params.agentId,
293
299
  config: params.config
294
300
  });
295
- const initialBinding = await options.bindingStore.read(bindingIdentity);
301
+ const abortedResult = (expectedThreadId, currentThreadId = expectedThreadId) => options.allowNonManualNativeRequest ? skippedCodexNativeCompactionResult(params, {
302
+ reason: "codex app-server compaction aborted before native compaction",
303
+ code: "aborted_before_native_compaction",
304
+ request: options.nativeCompactionRequest ?? "after_context_engine",
305
+ ...expectedThreadId ? {
306
+ expectedThreadId,
307
+ currentThreadId
308
+ } : {}
309
+ }) : {
310
+ ok: false,
311
+ compacted: false,
312
+ reason: "codex app-server compaction aborted while waiting to start"
313
+ };
314
+ let resolvedBinding;
315
+ try {
316
+ resolvedBinding = await resolveCodexSessionBinding({
317
+ bindingStore: options.bindingStore,
318
+ identity: bindingIdentity,
319
+ config: params.config,
320
+ storePath: params.sessionTarget?.storePath,
321
+ signal: params.abortSignal
322
+ });
323
+ } catch (error) {
324
+ if (!params.abortSignal?.aborted) throw error;
325
+ return abortedResult(options.bindingStore.read(bindingIdentity)?.threadId);
326
+ }
327
+ const { binding: initialBinding, assertCurrent } = resolvedBinding;
296
328
  if (!initialBinding?.threadId) return failedCodexThreadBindingCompactionResult(params, {
297
329
  reason: "no codex app-server thread binding",
298
330
  recovery: "missing_thread_binding"
@@ -312,7 +344,7 @@ async function compactCodexNativeThread(params, options) {
312
344
  let connection;
313
345
  try {
314
346
  const config = params.config ?? {};
315
- const agentId = params.agentId ?? readAgentIdFromSessionKey(params.sessionKey) ?? resolveDefaultAgentId$1(config);
347
+ const agentId = params.agentId ?? readAgentIdFromSessionKey(params.sessionKey) ?? resolveDefaultAgentId(config);
316
348
  connection = resolveCodexBindingAppServerConnection({
317
349
  binding,
318
350
  authProfileId: requestedAuthProfileId ?? binding.authProfileId,
@@ -345,6 +377,7 @@ async function compactCodexNativeThread(params, options) {
345
377
  };
346
378
  try {
347
379
  return await runExclusiveCodexNativeCompaction(binding.threadId, params.abortSignal, async () => {
380
+ assertCurrent();
348
381
  const client = await clientFactory({
349
382
  startOptions: appServer.start,
350
383
  ...preparedApiKey ? { preparedAuth: {
@@ -352,7 +385,8 @@ async function compactCodexNativeThread(params, options) {
352
385
  apiKey: preparedApiKey
353
386
  } } : { authProfileId: connection.clientAuthProfileId },
354
387
  agentDir: params.agentDir,
355
- config: params.config
388
+ config: params.config,
389
+ assertCurrent
356
390
  });
357
391
  let releaseThreadSubscription;
358
392
  let retainedThreadOwnership;
@@ -380,15 +414,15 @@ async function compactCodexNativeThread(params, options) {
380
414
  forceKillDelayMs: 250
381
415
  });
382
416
  if (appServer.start.transport === "stdio") {
383
- if (transportStopped) return;
417
+ if (transportStopped.exited) return;
384
418
  throw new Error("failed to stop unconfirmed codex app-server process");
385
419
  }
386
420
  if (usesSupervisionConnection) throw new Error("cannot detach an unconfirmed supervised codex thread");
387
421
  if (await options.bindingStore.mutate(bindingIdentity, {
388
422
  kind: "clear",
389
423
  threadId: binding.threadId
390
- })) return;
391
- if ((await options.bindingStore.read(bindingIdentity))?.threadId !== binding.threadId) return;
424
+ }, assertCurrent)) return;
425
+ if (options.bindingStore.read(bindingIdentity)?.threadId !== binding.threadId) return;
392
426
  throw new Error("failed to detach unconfirmed codex app-server thread binding");
393
427
  }
394
428
  });
@@ -404,6 +438,7 @@ async function compactCodexNativeThread(params, options) {
404
438
  excludeTurns: true
405
439
  },
406
440
  timeoutMs: timeoutMs ?? appServer.requestTimeoutMs,
441
+ assertCurrent,
407
442
  ...params.abortSignal ? { signal: params.abortSignal } : {}
408
443
  });
409
444
  releaseThreadSubscription = async () => releaseCompactionThread(binding.threadId);
@@ -413,7 +448,8 @@ async function compactCodexNativeThread(params, options) {
413
448
  const { thread } = await client.request("thread/read", {
414
449
  threadId: binding.threadId,
415
450
  includeTurns: false
416
- });
451
+ }, { assertCurrent });
452
+ assertCurrent();
417
453
  retainedThreadOwnership.assertCurrent();
418
454
  assertCodexSupervisionThreadLineage(binding, thread);
419
455
  }
@@ -422,7 +458,7 @@ async function compactCodexNativeThread(params, options) {
422
458
  };
423
459
  try {
424
460
  const guardedResult = await options.bindingStore.withLease(bindingIdentity, async () => {
425
- const currentBinding = await options.bindingStore.read(bindingIdentity);
461
+ const currentBinding = options.bindingStore.read(bindingIdentity);
426
462
  if (params.abortSignal?.aborted) {
427
463
  if (!options.allowNonManualNativeRequest) params.abortSignal.throwIfAborted();
428
464
  return {
@@ -436,6 +472,7 @@ async function compactCodexNativeThread(params, options) {
436
472
  })
437
473
  };
438
474
  }
475
+ assertCurrent();
439
476
  if (!currentBinding || !isSameNativeCompactionBinding(currentBinding, binding)) {
440
477
  embeddedAgentLog.warn("codex app-server compaction could not use the thread binding because it changed", {
441
478
  sessionId: params.sessionId,
@@ -466,23 +503,38 @@ async function compactCodexNativeThread(params, options) {
466
503
  sessionId: params.sessionId,
467
504
  bindingStore: options.bindingStore,
468
505
  identity: bindingIdentity,
469
- binding
506
+ binding,
507
+ assertCurrent
470
508
  });
509
+ assertCurrent();
471
510
  try {
472
511
  completionWatch.beginRequest();
473
- if (guardedRequestTimeoutMs === void 0) await client.request("thread/compact/start", { threadId: binding.threadId });
474
- else await client.request("thread/compact/start", { threadId: binding.threadId }, { timeoutMs: guardedRequestTimeoutMs });
512
+ await client.request("thread/compact/start", { threadId: binding.threadId }, {
513
+ ...guardedRequestTimeoutMs === void 0 ? {} : { timeoutMs: guardedRequestTimeoutMs },
514
+ assertCurrent: () => {
515
+ try {
516
+ assertCurrent();
517
+ } catch (error) {
518
+ compactionRequestDefinitelyRejected = true;
519
+ throw error;
520
+ }
521
+ }
522
+ });
475
523
  return {
476
524
  started: true,
477
525
  accepted: true
478
526
  };
479
527
  } catch (error) {
480
- if (error instanceof CodexAppServerRpcError) {
481
- await options.bindingStore.mutate(bindingIdentity, {
482
- kind: "set",
483
- binding
484
- });
485
- compactionRequestDefinitelyRejected = !isCodexThreadNotFoundError(error);
528
+ compactionRequestDefinitelyRejected ||= isCodexAppServerPrewriteRequestCancellationError(error);
529
+ if (compactionRequestDefinitelyRejected || error instanceof CodexAppServerRpcError) {
530
+ completionWatch.confirmRequestRejected();
531
+ if (!compactionRequestDefinitelyRejected) {
532
+ await options.bindingStore.mutate(bindingIdentity, {
533
+ kind: "set",
534
+ binding
535
+ }, assertCurrent);
536
+ compactionRequestDefinitelyRejected = !isCodexThreadNotFoundError(error);
537
+ }
486
538
  }
487
539
  return {
488
540
  started: true,
@@ -493,8 +545,7 @@ async function compactCodexNativeThread(params, options) {
493
545
  });
494
546
  if (!guardedResult.started) return guardedResult.result;
495
547
  if (!guardedResult.accepted) {
496
- if (guardedResult.error instanceof CodexAppServerRpcError) completionWatch.confirmRequestRejected();
497
- else await completionWatch.retireUnconfirmedRequest(`codex app-server compaction start was unconfirmed: ${coerceErrorMessage(guardedResult.error)}`);
548
+ if (!compactionRequestDefinitelyRejected && !(guardedResult.error instanceof CodexAppServerRpcError)) await completionWatch.retireUnconfirmedRequest(`codex app-server compaction start was unconfirmed: ${coerceErrorMessage(guardedResult.error)}`);
498
549
  throw guardedResult.error;
499
550
  }
500
551
  embeddedAgentLog.info("started codex app-server compaction", {
@@ -502,6 +553,7 @@ async function compactCodexNativeThread(params, options) {
502
553
  threadId: binding.threadId
503
554
  });
504
555
  const completion = await completionWatch.completion;
556
+ assertCurrent();
505
557
  if (!completion.completed) throw new Error(completion.reason);
506
558
  tokensAfter = completion.tokensAfter;
507
559
  if (completion.turnId && completion.itemId) await persistCodexContextCompactionActivity({
@@ -514,6 +566,7 @@ async function compactCodexNativeThread(params, options) {
514
566
  itemId: completion.itemId,
515
567
  timestamp: Date.now()
516
568
  });
569
+ assertCurrent();
517
570
  embeddedAgentLog.info("completed codex app-server compaction", {
518
571
  sessionId: params.sessionId,
519
572
  threadId: binding.threadId
@@ -541,9 +594,9 @@ async function compactCodexNativeThread(params, options) {
541
594
  try {
542
595
  if ((compactionSucceeded || compactionRequestDefinitelyRejected) && retainedThreadOwnership) {
543
596
  const ownership = retainedThreadOwnership;
544
- const currentBinding = await options.bindingStore.read(bindingIdentity);
597
+ const currentBinding = options.bindingStore.read(bindingIdentity);
545
598
  if (!(isSameCodexAppServerThreadOwner(currentBinding, binding) && await options.bindingStore.withLease(bindingIdentity, async () => {
546
- const leasedBinding = await options.bindingStore.read(bindingIdentity);
599
+ const leasedBinding = options.bindingStore.read(bindingIdentity);
547
600
  if (!isSameCodexAppServerThreadOwner(leasedBinding, binding)) return false;
548
601
  return await retainCodexAppServerLiveThread(client, binding.threadId, ownership.release, ownership.configFingerprint, ownership.serviceTier);
549
602
  }))) await releaseThreadSubscription?.();
@@ -570,20 +623,7 @@ async function compactCodexNativeThread(params, options) {
570
623
  });
571
624
  });
572
625
  } catch (error) {
573
- if (params.abortSignal?.aborted) {
574
- if (options.allowNonManualNativeRequest) return skippedCodexNativeCompactionResult(params, {
575
- reason: "codex app-server compaction aborted before native compaction",
576
- code: "aborted_before_native_compaction",
577
- request: options.nativeCompactionRequest ?? "after_context_engine",
578
- expectedThreadId: initialBinding.threadId,
579
- currentThreadId: binding.threadId
580
- });
581
- return {
582
- ok: false,
583
- compacted: false,
584
- reason: "codex app-server compaction aborted while waiting to start"
585
- };
586
- }
626
+ if (params.abortSignal?.aborted) return abortedResult(initialBinding.threadId, binding.threadId);
587
627
  throw error;
588
628
  }
589
629
  }
@@ -644,7 +684,7 @@ async function clearContextEngineProjectionBeforeNativeCompaction(params) {
644
684
  ...contextEngineBinding,
645
685
  projection: void 0
646
686
  } }
647
- });
687
+ }, params.assertCurrent);
648
688
  embeddedAgentLog.info("cleared codex context-engine projection before native compaction", {
649
689
  sessionId: params.sessionId,
650
690
  threadId: params.binding.threadId,
@@ -0,0 +1,106 @@
1
+ import { c as readExecAsk, f as readRecord, l as readExecSecurity } from "./config-utils-C57JiJrU.js";
2
+ import { p as canUseCodexModelBackedApprovalsReviewerForModel$1 } from "./config-options-jnIFvwxD.js";
3
+ import "./protocol-CAAcVIKF.js";
4
+ import "./config-runtime-BWf6JLWG.js";
5
+ import { resolveAgentConfig } from "openclaw/plugin-sdk/agent-scope-runtime";
6
+ import { execPolicy } from "openclaw/plugin-sdk/agent-harness-runtime";
7
+ import { resolveExecApprovalsFromFile } from "openclaw/plugin-sdk/exec-approvals-runtime";
8
+ import { resolveProviderIdForAuth } from "openclaw/plugin-sdk/provider-auth-aliases";
9
+ //#region extensions/codex/src/app-server/config-exec-approvals.ts
10
+ function resolveOpenClawExecPolicyFromConfig(params) {
11
+ const globalExec = readRecord(params.config?.tools?.exec);
12
+ const globalPolicy = applyOpenClawExecPolicyLayer(createDefaultOpenClawExecPolicy(), globalExec);
13
+ const agentId = params.agentId?.trim();
14
+ return applyOpenClawExecPolicyLayer(globalPolicy, agentId ? readRecord(resolveAgentConfig(params.config ?? {}, agentId)?.tools?.exec) : void 0);
15
+ }
16
+ function resolveOpenClawExecPolicyForCodexAppServer(params) {
17
+ if (params.permissionMode === "full") return {
18
+ ...resolveOpenClawExecPolicyForMode("full"),
19
+ touched: true
20
+ };
21
+ const overridePolicy = applyOpenClawExecPolicyLayer(resolveOpenClawExecPolicyFromConfig({
22
+ config: params.config,
23
+ agentId: params.agentId
24
+ }), params.execOverrides);
25
+ return applyOpenClawExecApprovalFloors(overridePolicy, resolveOpenClawExecApprovalFloorsForCodexAppServer({
26
+ approvals: params.approvals,
27
+ agentId: params.agentId,
28
+ policy: overridePolicy
29
+ }));
30
+ }
31
+ function createDefaultOpenClawExecPolicy() {
32
+ return {
33
+ ...resolveOpenClawExecPolicyForMode("full"),
34
+ touched: false
35
+ };
36
+ }
37
+ function applyOpenClawExecPolicyLayer(base, exec) {
38
+ if (!exec) return base;
39
+ const mode = readExecMode(exec.mode);
40
+ if (mode !== void 0) return {
41
+ ...resolveOpenClawExecPolicyForMode(mode),
42
+ touched: true
43
+ };
44
+ const security = readExecSecurity(exec.security);
45
+ const ask = readExecAsk(exec.ask);
46
+ if (security === void 0 && ask === void 0) return base;
47
+ const nextSecurity = security ?? base.security;
48
+ const nextAsk = ask ?? base.ask;
49
+ return {
50
+ mode: execPolicy.resolveExecModePolicy({
51
+ security: nextSecurity,
52
+ ask: nextAsk
53
+ }).mode,
54
+ security: nextSecurity,
55
+ ask: nextAsk,
56
+ touched: true
57
+ };
58
+ }
59
+ function resolveOpenClawExecApprovalFloorsForCodexAppServer(params) {
60
+ if (!params.approvals) return;
61
+ return resolveExecApprovalsFromFile({
62
+ file: params.approvals,
63
+ agentId: params.agentId,
64
+ overrides: {
65
+ security: params.policy.security,
66
+ ask: params.policy.ask
67
+ }
68
+ }).agent;
69
+ }
70
+ function applyOpenClawExecApprovalFloors(base, approvalFloors) {
71
+ if (!approvalFloors) return base;
72
+ const nextSecurity = approvalFloors.security ? execPolicy.minSecurity(base.security, approvalFloors.security) : base.security;
73
+ const nextAsk = approvalFloors.ask ? execPolicy.maxAsk(base.ask, approvalFloors.ask) : base.ask;
74
+ if (nextSecurity === base.security && nextAsk === base.ask) return base;
75
+ return {
76
+ mode: execPolicy.resolveExecModePolicy({
77
+ security: nextSecurity,
78
+ ask: nextAsk
79
+ }).mode,
80
+ security: nextSecurity,
81
+ ask: nextAsk,
82
+ touched: true
83
+ };
84
+ }
85
+ function resolveOpenClawExecPolicyForMode(mode) {
86
+ const { security, ask } = execPolicy.resolveExecModePolicy({
87
+ mode,
88
+ security: "full",
89
+ ask: "off"
90
+ });
91
+ return {
92
+ mode,
93
+ security,
94
+ ask
95
+ };
96
+ }
97
+ function readExecMode(value) {
98
+ return value === "deny" || value === "allowlist" || value === "ask" || value === "auto" || value === "full" ? value : void 0;
99
+ }
100
+ //#endregion
101
+ //#region extensions/codex/src/app-server/config-reviewer.ts
102
+ function canUseCodexModelBackedApprovalsReviewerForModel(params) {
103
+ return canUseCodexModelBackedApprovalsReviewerForModel$1(params, resolveProviderIdForAuth);
104
+ }
105
+ //#endregion
106
+ export { resolveOpenClawExecPolicyForCodexAppServer as n, canUseCodexModelBackedApprovalsReviewerForModel as t };