@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,62 +1,14 @@
1
- import { a as normalizeHeaders, c as readExecAsk, d as readNumberEnv, f as readRecord, g as CODEX_PLUGIN_MARKETPLACE_NAME_PATTERN, i as normalizeCodexServiceTier, l as readExecSecurity, o as normalizePositiveNumber, p as resolveArgs, r as normalizeCodexAppServerSecretInput, s as readBooleanEnv, t as hashSecretForKey, u as readNonEmptyString } from "./config-utils-C57JiJrU.js";
2
- import { m as readCodexAppServerConfigOptions, p as normalizeCodexAppServerArgs } from "./managed-binary-DcpnJF9x.js";
3
- import { asNullableRecord, isRecord, normalizeOptionalString, normalizeTrimmedStringList } from "openclaw/plugin-sdk/string-coerce-runtime";
1
+ import { a as normalizeHeaders, d as readNumberEnv, f as readRecord, i as normalizeCodexServiceTier, o as normalizePositiveNumber, p as resolveArgs, r as normalizeCodexAppServerSecretInput, s as readBooleanEnv, t as hashSecretForKey, u as readNonEmptyString } from "./config-utils-C57JiJrU.js";
2
+ import { _ as assertCodexAppServerCommandHasNoInlineArgs, d as DEFAULT_CODEX_APP_SERVER_NETWORK_PROXY_PROFILE_PREFIX, f as DEFAULT_CODEX_COMPUTER_USE_LIVE_TEST_TIMEOUT_MS, g as DEFAULT_CODEX_COMPUTER_USE_TOOL_CALL_TIMEOUT_MS, h as DEFAULT_CODEX_COMPUTER_USE_PLUGIN_NAME, l as resolveCodexAppServerUserHomeDir, o as isJsonObject, p as DEFAULT_CODEX_COMPUTER_USE_MARKETPLACE_DISCOVERY_TIMEOUT_MS, s as resolveCodexAppServerHomeDir, x as readCodexPluginConfig } from "./protocol-CAAcVIKF.js";
3
+ import { r as readCodexAppServerConfigOptions } from "./launch-args-RXQwn8zV.js";
4
+ import { normalizeTrimmedStringList } from "openclaw/plugin-sdk/string-coerce-runtime";
4
5
  import { createHash } from "node:crypto";
5
- import { resolveAgentConfig } from "openclaw/plugin-sdk/agent-scope-runtime";
6
- import { z } from "zod";
7
- import { buildSecretInputSchema } from "openclaw/plugin-sdk/secret-input";
8
- import path from "node:path";
9
- import { AgentHarnessPreflightError } from "openclaw/plugin-sdk/agent-harness-runtime";
10
- import { readFileSync } from "node:fs";
11
- import { homedir, hostname } from "node:os";
12
- import { resolveProviderIdForAuth } from "openclaw/plugin-sdk/agent-runtime";
13
- import { resolveExecApprovalsFromFile } from "openclaw/plugin-sdk/exec-approvals-runtime";
14
- import { detectWindowsSpawnCommandInlineArgs } from "openclaw/plugin-sdk/windows-spawn";
6
+ import { AgentHarnessPreflightError } from "openclaw/plugin-sdk/agent-harness-registration";
15
7
  import { parse } from "smol-toml";
16
- import { isLoopbackHost } from "openclaw/plugin-sdk/ssrf-runtime";
17
- //#region extensions/codex/src/app-server/protocol.ts
18
- /** Namespace Codex keeps directly model-visible without exposing it to Code Mode guests. */
19
- const CODEX_OPENCLAW_DIRECT_DYNAMIC_TOOL_NAMESPACE = "openclaw_direct";
20
- function flattenCodexDynamicToolFunctions(tools) {
21
- return (tools ?? []).flatMap((tool) => tool.type === "namespace" ? tool.tools : [tool]);
22
- }
23
- const CODEX_INTERACTIVE_THREAD_SOURCE_KINDS = ["cli", "vscode"];
24
- const CODEX_INTERACTIVE_CUSTOM_THREAD_SOURCES = ["atlas", "chatgpt"];
25
- function isJsonObject(value) {
26
- return isRecord(value);
27
- }
28
- function isRpcResponse(message) {
29
- return "id" in message && !("method" in message);
30
- }
31
- //#endregion
32
- //#region extensions/codex/src/app-server/auth-start-options.ts
33
- const CODEX_APP_SERVER_HOME_DIRNAME = "codex-home";
34
- const CODEX_EPHEMERAL_AUTH_STORE_OVERRIDE = "cli_auth_credentials_store=\"ephemeral\"";
35
- function resolveCodexAppServerHomeDir(agentDir) {
36
- return path.join(path.resolve(agentDir), CODEX_APP_SERVER_HOME_DIRNAME);
37
- }
38
- /** Resolves the native user Codex home used by Desktop and the CLI. */
39
- function resolveCodexAppServerUserHomeDir(env = process.env, homedir$1 = homedir) {
40
- const configured = normalizeOptionalString(env.CODEX_HOME);
41
- return path.resolve(configured ?? path.join(homedir$1(), ".codex"));
42
- }
43
- /** Resolves the local CODEX_HOME used when starting one app-server connection. */
44
- function resolveCodexAppServerLocalHomeDir(startOptions, agentDir, env = process.env) {
45
- const configured = startOptions.env?.CODEX_HOME;
46
- if (configured?.trim()) return configured;
47
- return startOptions.homeScope === "user" ? resolveCodexAppServerUserHomeDir(env) : resolveCodexAppServerHomeDir(agentDir);
48
- }
49
- /** Forces OpenClaw-owned Codex auth to remain process-local. */
50
- function withEphemeralCodexAuthStore(params) {
51
- const { startOptions } = params;
52
- if (!params.preparedAuth && params.authProfileId === null) return startOptions;
53
- const args = normalizeCodexAppServerArgs(startOptions.args, CODEX_EPHEMERAL_AUTH_STORE_OVERRIDE);
54
- return args === startOptions.args ? startOptions : {
55
- ...startOptions,
56
- args
57
- };
58
- }
59
- //#endregion
8
+ import { readFileSync } from "node:fs";
9
+ import path from "node:path";
10
+ import { hostname } from "node:os";
11
+ import { isLoopbackHost } from "openclaw/plugin-sdk/request-url";
60
12
  //#region extensions/codex/src/app-server/config-exec-policy.ts
61
13
  function selectForcedPromptingSandbox(params) {
62
14
  if (params.configuredSandbox === "read-only" || params.defaultSandbox === "read-only") return "read-only";
@@ -87,27 +39,6 @@ function resolveSandbox(value) {
87
39
  function resolveApprovalsReviewer(value) {
88
40
  return value === "auto_review" || value === "guardian_subagent" || value === "user" ? value : void 0;
89
41
  }
90
- function resolveOpenClawExecPolicyFromConfig(params) {
91
- const globalExec = readRecord(params.config?.tools?.exec);
92
- const globalPolicy = applyOpenClawExecPolicyLayer(createDefaultOpenClawExecPolicy(), globalExec);
93
- const agentId = params.agentId?.trim();
94
- return applyOpenClawExecPolicyLayer(globalPolicy, agentId ? readRecord(resolveAgentConfig(params.config ?? {}, agentId)?.tools?.exec) : void 0);
95
- }
96
- function resolveOpenClawExecPolicyForCodexAppServer(params) {
97
- if (params.permissionMode === "full") return {
98
- ...resolveOpenClawExecPolicyForMode("full"),
99
- touched: true
100
- };
101
- const overridePolicy = applyOpenClawExecPolicyLayer(resolveOpenClawExecPolicyFromConfig({
102
- config: params.config,
103
- agentId: params.agentId
104
- }), params.execOverrides);
105
- return applyOpenClawExecApprovalFloors(overridePolicy, resolveOpenClawExecApprovalFloorsForCodexAppServer({
106
- approvals: params.approvals,
107
- agentId: params.agentId,
108
- policy: overridePolicy
109
- }));
110
- }
111
42
  function resolveEffectiveOpenClawExecModeForCodexAppServer(params) {
112
43
  if (params.execPolicy?.touched === true) return params.execPolicy.mode;
113
44
  return params.execMode;
@@ -119,351 +50,6 @@ function resolveCodexPolicyModeForOpenClawExecMode(mode) {
119
50
  function assertCodexAppServerAllowedForOpenClawExecMode(mode) {
120
51
  if (mode === "deny" || mode === "allowlist") throw new AgentHarnessPreflightError(`Codex app-server local execution is unavailable because effective tools.exec.mode=${mode}. Execution-host approvals are authoritative. For gateway turns, inspect them with \`openclaw approvals get --gateway\` and update that same target with \`openclaw approvals set --gateway --stdin\`; for local \`agent exec\`, omit \`--gateway\`. Intentionally align that host policy before retrying.`, { scope: "harness" });
121
52
  }
122
- function createDefaultOpenClawExecPolicy() {
123
- return {
124
- ...resolveOpenClawExecPolicyForMode("full"),
125
- touched: false
126
- };
127
- }
128
- function applyOpenClawExecPolicyLayer(base, exec) {
129
- if (!exec) return base;
130
- const mode = readExecMode(exec.mode);
131
- if (mode !== void 0) return {
132
- ...resolveOpenClawExecPolicyForMode(mode),
133
- touched: true
134
- };
135
- const security = readExecSecurity(exec.security);
136
- const ask = readExecAsk(exec.ask);
137
- if (security === void 0 && ask === void 0) return base;
138
- const nextSecurity = security ?? base.security;
139
- const nextAsk = ask ?? base.ask;
140
- return {
141
- mode: resolveOpenClawExecModeFromPolicy({
142
- security: nextSecurity,
143
- ask: nextAsk
144
- }),
145
- security: nextSecurity,
146
- ask: nextAsk,
147
- touched: true
148
- };
149
- }
150
- function resolveOpenClawExecApprovalFloorsForCodexAppServer(params) {
151
- if (!params.approvals) return;
152
- return resolveExecApprovalsFromFile({
153
- file: params.approvals,
154
- agentId: params.agentId,
155
- overrides: {
156
- security: params.policy.security,
157
- ask: params.policy.ask
158
- }
159
- }).agent;
160
- }
161
- function applyOpenClawExecApprovalFloors(base, approvalFloors) {
162
- if (!approvalFloors) return base;
163
- const nextSecurity = approvalFloors.security ? minOpenClawExecSecurity(base.security, approvalFloors.security) : base.security;
164
- const nextAsk = approvalFloors.ask ? maxOpenClawExecAsk(base.ask, approvalFloors.ask) : base.ask;
165
- if (nextSecurity === base.security && nextAsk === base.ask) return base;
166
- return {
167
- mode: resolveOpenClawExecModeFromPolicy({
168
- security: nextSecurity,
169
- ask: nextAsk
170
- }),
171
- security: nextSecurity,
172
- ask: nextAsk,
173
- touched: true
174
- };
175
- }
176
- function resolveOpenClawExecPolicyForMode(mode) {
177
- switch (mode) {
178
- case "deny": return {
179
- mode,
180
- security: "deny",
181
- ask: "off"
182
- };
183
- case "allowlist": return {
184
- mode,
185
- security: "allowlist",
186
- ask: "off"
187
- };
188
- case "ask":
189
- case "auto": return {
190
- mode,
191
- security: "allowlist",
192
- ask: "on-miss"
193
- };
194
- case "full": return {
195
- mode,
196
- security: "full",
197
- ask: "off"
198
- };
199
- }
200
- return mode;
201
- }
202
- function resolveOpenClawExecModeFromPolicy(params) {
203
- if (params.security === "deny") return "deny";
204
- if (params.security === "allowlist" && params.ask === "off") return "allowlist";
205
- if (params.security === "full" && params.ask !== "always") return "full";
206
- return "ask";
207
- }
208
- function minOpenClawExecSecurity(left, right) {
209
- const order = {
210
- deny: 0,
211
- allowlist: 1,
212
- full: 2
213
- };
214
- return order[left] <= order[right] ? left : right;
215
- }
216
- function maxOpenClawExecAsk(left, right) {
217
- const order = {
218
- off: 0,
219
- "on-miss": 1,
220
- always: 2
221
- };
222
- return order[left] >= order[right] ? left : right;
223
- }
224
- function readExecMode(value) {
225
- return value === "deny" || value === "allowlist" || value === "ask" || value === "auto" || value === "full" ? value : void 0;
226
- }
227
- //#endregion
228
- //#region extensions/codex/src/app-server/session-discovery-config.ts
229
- const codexSessionCatalogHomeSchema = z.union([z.string().trim().min(1), z.object({
230
- path: z.string().trim().min(1),
231
- label: z.string().trim().min(1).optional()
232
- }).strict()]);
233
- const codexSessionCatalogConfigSchema = z.object({
234
- enabled: z.boolean().optional(),
235
- homes: z.array(codexSessionCatalogHomeSchema).optional()
236
- }).strict();
237
- const codexDiscoveryConfigSchema = z.object({
238
- enabled: z.boolean().optional(),
239
- timeoutMs: z.number().positive().optional()
240
- }).strict();
241
- //#endregion
242
- //#region extensions/codex/src/app-server/config-parsing.ts
243
- const DEFAULT_CODEX_COMPUTER_USE_PLUGIN_NAME = "computer-use";
244
- const DEFAULT_CODEX_COMPUTER_USE_MARKETPLACE_DISCOVERY_TIMEOUT_MS = 6e4;
245
- const DEFAULT_CODEX_COMPUTER_USE_LIVE_TEST_TIMEOUT_MS = 6e4;
246
- const DEFAULT_CODEX_COMPUTER_USE_TOOL_CALL_TIMEOUT_MS = 6e4;
247
- const DEFAULT_CODEX_APP_SERVER_NETWORK_PROXY_PROFILE_PREFIX = "openclaw-network";
248
- const codexAppServerTransportSchema = z.enum([
249
- "stdio",
250
- "websocket",
251
- "unix"
252
- ]);
253
- const codexAppServerHomeScopeSchema = z.enum(["agent", "user"]);
254
- const SecretInputSchema = buildSecretInputSchema();
255
- const codexAppServerPolicyModeSchema = z.enum(["yolo", "guardian"]);
256
- const codexAppServerApprovalPolicySchema = z.preprocess((value) => value === "on-failure" ? "on-request" : value, z.enum(["never", "on-request"]));
257
- const codexAppServerSandboxSchema = z.enum([
258
- "read-only",
259
- "workspace-write",
260
- "danger-full-access"
261
- ]);
262
- const codexAppServerApprovalsReviewerSchema = z.enum([
263
- "user",
264
- "auto_review",
265
- "guardian_subagent"
266
- ]);
267
- const codexDynamicToolsLoadingSchema = z.enum(["searchable", "direct"]);
268
- const codexComputerUseHealthIntervalSchema = z.union([
269
- z.literal(30),
270
- z.literal(60),
271
- z.literal(120),
272
- z.literal(240)
273
- ]);
274
- const codexComputerUsePluginCacheModeSchema = z.enum(["shared", "independent"]);
275
- const codexPluginDestructivePolicySchema = z.union([
276
- z.boolean(),
277
- z.literal("auto"),
278
- z.literal("ask")
279
- ]);
280
- const codexAppServerServiceTierSchema = z.preprocess((value) => value === null ? null : normalizeCodexServiceTier(value), z.string().trim().min(1).nullable().optional()).optional();
281
- const codexAppServerExperimentalSchema = z.object({ sandboxExecServer: z.boolean().optional() }).strict();
282
- const codexAppServerRemoteWorkspaceRootSchema = z.string().trim().min(1);
283
- const codexAppServerNetworkProxyDomainPermissionSchema = z.enum(["allow", "deny"]);
284
- const codexAppServerNetworkProxyUnixSocketPermissionSchema = z.enum(["allow", "none"]);
285
- const codexAppServerNetworkProxySchema = z.object({
286
- enabled: z.boolean().optional(),
287
- profileName: z.string().trim().min(1).optional(),
288
- baseProfile: z.enum(["read-only", "workspace"]).optional(),
289
- mode: z.enum(["limited", "full"]).optional(),
290
- domains: z.record(z.string(), codexAppServerNetworkProxyDomainPermissionSchema).optional(),
291
- unixSockets: z.record(z.string(), codexAppServerNetworkProxyUnixSocketPermissionSchema).optional(),
292
- proxyUrl: z.string().trim().min(1).optional(),
293
- socksUrl: z.string().trim().min(1).optional(),
294
- enableSocks5: z.boolean().optional(),
295
- enableSocks5Udp: z.boolean().optional(),
296
- allowUpstreamProxy: z.boolean().optional(),
297
- allowLocalBinding: z.boolean().optional(),
298
- dangerouslyAllowNonLoopbackProxy: z.boolean().optional(),
299
- dangerouslyAllowAllUnixSockets: z.boolean().optional()
300
- }).strict();
301
- const codexPluginEntryConfigSchema = z.object({
302
- enabled: z.boolean().optional(),
303
- marketplaceName: z.string().regex(CODEX_PLUGIN_MARKETPLACE_NAME_PATTERN).optional(),
304
- pluginName: z.string().trim().min(1).optional(),
305
- allow_destructive_actions: codexPluginDestructivePolicySchema.optional()
306
- }).strict();
307
- const codexPluginsConfigSchema = z.object({
308
- enabled: z.boolean().optional(),
309
- allow_all_plugins: z.boolean().optional(),
310
- allow_destructive_actions: codexPluginDestructivePolicySchema.optional(),
311
- plugins: z.record(z.string(), codexPluginEntryConfigSchema).optional()
312
- }).strict();
313
- const codexSupervisionEndpointSchema = z.union([z.object({
314
- id: z.string().optional(),
315
- label: z.string().optional(),
316
- transport: z.literal("stdio-proxy").optional(),
317
- command: z.string().optional(),
318
- args: z.array(z.string()).optional(),
319
- cwd: z.string().optional()
320
- }).strict(), z.object({
321
- id: z.string().optional(),
322
- label: z.string().optional(),
323
- transport: z.literal("websocket"),
324
- url: z.string(),
325
- authTokenEnv: z.string().optional()
326
- }).strict()]);
327
- const codexSupervisionConfigSchema = z.object({
328
- enabled: z.boolean().optional(),
329
- endpoints: z.array(codexSupervisionEndpointSchema).optional(),
330
- allowRawTranscripts: z.boolean().optional(),
331
- allowWriteControls: z.boolean().optional()
332
- }).strict();
333
- const codexPluginConfigSchema = z.object({
334
- codexDynamicToolsLoading: codexDynamicToolsLoadingSchema.optional(),
335
- codexDynamicToolsExclude: z.array(z.string()).optional(),
336
- sessionCatalog: codexSessionCatalogConfigSchema.optional(),
337
- discovery: codexDiscoveryConfigSchema.optional(),
338
- computerUse: z.object({
339
- enabled: z.boolean().optional(),
340
- autoInstall: z.boolean().optional(),
341
- marketplaceDiscoveryTimeoutMs: z.number().positive().optional(),
342
- liveTestTimeoutMs: z.number().positive().optional(),
343
- toolCallTimeoutMs: z.number().positive().optional(),
344
- healthCheckEnabled: z.boolean().optional(),
345
- healthCheckIntervalMinutes: codexComputerUseHealthIntervalSchema.optional(),
346
- pluginCacheMode: codexComputerUsePluginCacheModeSchema.optional(),
347
- strictReadiness: z.boolean().optional(),
348
- autoRepair: z.boolean().optional(),
349
- marketplaceSource: z.string().optional(),
350
- marketplacePath: z.string().optional(),
351
- marketplaceName: z.string().optional(),
352
- pluginName: z.string().optional(),
353
- mcpServerName: z.string().optional()
354
- }).strict().optional(),
355
- codexPlugins: z.unknown().optional(),
356
- supervision: codexSupervisionConfigSchema.optional(),
357
- appServer: z.object({
358
- mode: codexAppServerPolicyModeSchema.optional(),
359
- transport: codexAppServerTransportSchema.optional(),
360
- homeScope: codexAppServerHomeScopeSchema.optional(),
361
- command: z.string().optional(),
362
- args: z.union([z.array(z.string()), z.string()]).optional(),
363
- url: z.string().optional(),
364
- authToken: SecretInputSchema.optional(),
365
- headers: z.record(z.string(), SecretInputSchema).optional(),
366
- clearEnv: z.array(z.string()).optional(),
367
- remoteWorkspaceRoot: codexAppServerRemoteWorkspaceRootSchema.optional(),
368
- codeModeOnly: z.boolean().optional(),
369
- loopDetectionPreToolUseRelay: z.boolean().optional(),
370
- requestTimeoutMs: z.number().positive().optional(),
371
- approvalPolicy: codexAppServerApprovalPolicySchema.optional(),
372
- sandbox: codexAppServerSandboxSchema.optional(),
373
- approvalsReviewer: codexAppServerApprovalsReviewerSchema.optional(),
374
- serviceTier: codexAppServerServiceTierSchema,
375
- networkProxy: codexAppServerNetworkProxySchema.optional(),
376
- defaultWorkspaceDir: z.string().optional(),
377
- experimental: codexAppServerExperimentalSchema.optional()
378
- }).strict().optional()
379
- }).strict();
380
- function readCodexPluginConfig(value) {
381
- if (asNullableRecord(asNullableRecord(value)?.appServer)?.approvalPolicy === "untrusted") throw new Error("plugins.entries.codex.config.appServer.approvalPolicy=\"untrusted\" is retired; run \"openclaw doctor --fix\" to migrate it to \"on-request\".");
382
- const parsed = codexPluginConfigSchema.safeParse(value);
383
- if (!parsed.success) return {};
384
- const { codexPlugins: rawCodexPlugins, ...config } = parsed.data;
385
- const plugins = codexPluginsConfigSchema.safeParse(rawCodexPlugins);
386
- if (!plugins.success) return config;
387
- return {
388
- ...config,
389
- ...plugins.data ? { codexPlugins: plugins.data } : {}
390
- };
391
- }
392
- function isCodexSandboxExecServerEnabled(pluginConfig, sandbox) {
393
- return isCodexRemoteExecPlacementSandbox(sandbox) || readCodexPluginConfig(pluginConfig).appServer?.experimental?.sandboxExecServer === true;
394
- }
395
- function isCodexRemoteExecPlacementSandbox(sandbox) {
396
- return typeof sandbox === "object" && sandbox !== null && "placementExecutionMode" in sandbox && sandbox.placementExecutionMode === "remote-exec";
397
- }
398
- function isCodexPairedNodeRemoteExecPlacementSandbox(sandbox) {
399
- return isCodexRemoteExecPlacementSandbox(sandbox) && typeof sandbox === "object" && sandbox !== null && "placementNodeId" in sandbox && typeof sandbox.placementNodeId === "string" && sandbox.placementNodeId.length > 0;
400
- }
401
- function assertCodexAppServerCommandHasNoInlineArgs(params) {
402
- const inlineArgs = detectWindowsSpawnCommandInlineArgs(params.command);
403
- if (!inlineArgs) return;
404
- const sourceLabel = params.source === "env" ? "OPENCLAW_CODEX_APP_SERVER_BIN" : "plugins.entries.codex.config.appServer.command";
405
- const argsLabel = params.source === "env" ? "OPENCLAW_CODEX_APP_SERVER_ARGS" : "plugins.entries.codex.config.appServer.args";
406
- throw new Error(`${sourceLabel} must be only the Codex app-server executable path; "${inlineArgs.executable}" was configured with inline arguments "${inlineArgs.arguments}". Move those arguments to ${argsLabel}, or remove the override to use the managed Codex startup path.`);
407
- }
408
- function resolveCodexPluginsPolicy(pluginConfig) {
409
- const config = readCodexPluginConfig(pluginConfig).codexPlugins;
410
- const configured = config !== void 0;
411
- const enabled = config?.enabled === true;
412
- const destructivePolicy = resolveCodexPluginDestructivePolicy(config?.allow_destructive_actions ?? true);
413
- const pluginPolicies = Object.entries(config?.plugins ?? {}).flatMap(([configKey, entry]) => {
414
- if (!isCodexPluginMarketplaceName(entry.marketplaceName) || !entry.pluginName) return [];
415
- const entryDestructivePolicy = resolveCodexPluginDestructivePolicy(entry.allow_destructive_actions ?? config?.allow_destructive_actions ?? true);
416
- return [{
417
- configKey,
418
- marketplaceName: entry.marketplaceName,
419
- pluginName: entry.pluginName,
420
- enabled: enabled && entry.enabled !== false,
421
- allowDestructiveActions: entryDestructivePolicy.allowDestructiveActions,
422
- destructiveApprovalMode: entryDestructivePolicy.destructiveApprovalMode
423
- }];
424
- }).toSorted((left, right) => left.configKey.localeCompare(right.configKey));
425
- return {
426
- configured,
427
- enabled,
428
- allowAllPlugins: enabled && config?.allow_all_plugins === true,
429
- allowDestructiveActions: destructivePolicy.allowDestructiveActions,
430
- destructiveApprovalMode: destructivePolicy.destructiveApprovalMode,
431
- pluginPolicies
432
- };
433
- }
434
- function isCodexPluginMarketplaceName(value) {
435
- return typeof value === "string" && CODEX_PLUGIN_MARKETPLACE_NAME_PATTERN.test(value);
436
- }
437
- function resolveCodexPluginDestructivePolicy(policy) {
438
- if (policy === "auto" || policy === "ask") return {
439
- allowDestructiveActions: true,
440
- destructiveApprovalMode: policy
441
- };
442
- return {
443
- allowDestructiveActions: policy,
444
- destructiveApprovalMode: policy ? "allow" : "deny"
445
- };
446
- }
447
- //#endregion
448
- //#region extensions/codex/src/app-server/config-layer-policy.ts
449
- const CODEX_SESSION_OVERRIDABLE_LAYER_TYPES = /* @__PURE__ */ new Set([
450
- "packagedDefaults",
451
- "mdm",
452
- "system",
453
- "enterpriseManaged",
454
- "user",
455
- "project",
456
- "sessionFlags"
457
- ]);
458
- /** Read one effective snapshot for the current boundary's reviewer and tool-policy checks. */
459
- async function readCodexEffectiveConfig(client, cwd, signal) {
460
- const response = await client.request("config/read", {
461
- cwd: path.resolve(cwd),
462
- includeLayers: true
463
- }, { signal });
464
- if (!isJsonObject(response) || !isJsonObject(response.config)) throw new Error("Codex config/read returned an invalid effective config");
465
- return response;
466
- }
467
53
  //#endregion
468
54
  //#region extensions/codex/src/app-server/config-requirements.ts
469
55
  const UNIX_CODEX_REQUIREMENTS_PATH = "/etc/codex/requirements.toml";
@@ -659,7 +245,27 @@ function selectUserApprovalsReviewer(allowedApprovalsReviewers, execModeRequirin
659
245
  throw new Error(`tools.exec.mode=${execModeRequiringUserReviewer ?? "ask"} requires Codex app-server user approvals`);
660
246
  }
661
247
  //#endregion
662
- //#region extensions/codex/src/app-server/config-reviewer.ts
248
+ //#region extensions/codex/src/app-server/config-layer-policy.ts
249
+ const CODEX_SESSION_OVERRIDABLE_LAYER_TYPES = /* @__PURE__ */ new Set([
250
+ "packagedDefaults",
251
+ "mdm",
252
+ "system",
253
+ "enterpriseManaged",
254
+ "user",
255
+ "project",
256
+ "sessionFlags"
257
+ ]);
258
+ /** Read one effective snapshot for the current boundary's reviewer and tool-policy checks. */
259
+ async function readCodexEffectiveConfig(client, cwd, signal) {
260
+ const response = await client.request("config/read", {
261
+ cwd: path.resolve(cwd),
262
+ includeLayers: true
263
+ }, { signal });
264
+ if (!isJsonObject(response) || !isJsonObject(response.config)) throw new Error("Codex config/read returned an invalid effective config");
265
+ return response;
266
+ }
267
+ //#endregion
268
+ //#region extensions/codex/src/app-server/config-reviewer-policy.ts
663
269
  const CODEX_CONFIG_TOML_FILENAME = "config.toml";
664
270
  /** Cloud/system config can redirect reviews after local home/profile checks have passed. */
665
271
  async function assertCodexModelBackedReviewerEffectiveConfig(params) {
@@ -677,17 +283,17 @@ async function assertCodexModelBackedReviewerEffectiveConfig(params) {
677
283
  function isTrustedOptionalReviewerEndpoint(value, isTrusted) {
678
284
  return value == null || typeof value === "string" && isTrusted(value);
679
285
  }
680
- function canUseCodexModelBackedApprovalsReviewerForModel(params) {
286
+ function canUseCodexModelBackedApprovalsReviewerForModel(params, resolveAuthProviderId) {
681
287
  const explicitProvider = params.modelProvider?.trim().toLowerCase();
682
288
  const inferredProvider = inferProviderFromModelRef(params.model);
683
289
  if (explicitProvider && explicitProvider !== "codex" && explicitProvider !== "openai") return false;
684
- return (inferredProvider ?? explicitProvider) === "openai" && isTrustedCodexModelBackedOpenAIProvider(params);
290
+ return (inferredProvider ?? explicitProvider) === "openai" && isTrustedCodexModelBackedOpenAIProvider(params, resolveAuthProviderId);
685
291
  }
686
- function isTrustedCodexModelBackedOpenAIProvider(params) {
292
+ function isTrustedCodexModelBackedOpenAIProvider(params, resolveAuthProviderId) {
687
293
  if (!openAIBaseUrlEnvOverridesAreTrustedForModelBackedReview(params.env)) return false;
688
294
  const codexBaseUrlOverrides = readCodexBaseUrlOverridesForModelBackedReview(params);
689
295
  if (codexBaseUrlOverrides === false || !codexBaseUrlOverrides.openAI.every(isNativeOpenAIBaseUrl) || !codexBaseUrlOverrides.chatGPT.every(isNativeChatGPTBaseUrl)) return false;
690
- const openAIProviders = readConfiguredOpenAIProvidersForModelBackedReview(params.config);
296
+ const openAIProviders = readConfiguredOpenAIProvidersForModelBackedReview(params.config, resolveAuthProviderId);
691
297
  if (openAIProviders.length === 0) return true;
692
298
  return openAIProviders.every((openAIProvider) => configuredOpenAIProviderIsTrustedForModelBackedReview(openAIProvider, params.model));
693
299
  }
@@ -803,12 +409,12 @@ function resolveCodexAppServerConfigPath(params) {
803
409
  function readErrorCode(error) {
804
410
  return error && typeof error === "object" && "code" in error ? String(error.code) : void 0;
805
411
  }
806
- function readConfiguredOpenAIProvidersForModelBackedReview(config) {
412
+ function readConfiguredOpenAIProvidersForModelBackedReview(config, resolveAuthProviderId) {
807
413
  const providerRecords = readRecord(readRecord(readRecord(config)?.models)?.providers);
808
414
  if (!providerRecords) return [];
809
415
  const openAIProviders = [];
810
416
  for (const [providerId, providerConfig] of Object.entries(providerRecords)) {
811
- if (resolveProviderIdForAuth(providerId, { config }) !== "openai") continue;
417
+ if (resolveAuthProviderId(providerId, { config }) !== "openai") continue;
812
418
  const record = readRecord(providerConfig);
813
419
  if (record) openAIProviders.push(record);
814
420
  }
@@ -1046,7 +652,7 @@ function resolveDefaultCodexAppServerPolicy(params) {
1046
652
  };
1047
653
  }
1048
654
  //#endregion
1049
- //#region extensions/codex/src/app-server/config-runtime.ts
655
+ //#region extensions/codex/src/app-server/config-options.ts
1050
656
  /**
1051
657
  * Sole owner of the app-server home-scope decision. Ordinary harness connections
1052
658
  * default to the isolated agent home; the supervision connection owns the operator's
@@ -1059,148 +665,173 @@ function resolveCodexAppServerHomeScope(params) {
1059
665
  if (configured) return configured;
1060
666
  return params.connectionScope === "supervision" && resolveTransport(params.appServer?.transport) !== "websocket" ? "user" : "agent";
1061
667
  }
1062
- function resolveCodexAppServerRuntimeOptions(params = {}) {
1063
- const env = params.env ?? process.env;
1064
- const pluginConfig = readCodexPluginConfig(params.pluginConfig);
1065
- const config = pluginConfig.appServer ?? {};
1066
- const transport = resolveTransport(config.transport);
1067
- const homeScope = resolveCodexAppServerHomeScope({ appServer: config });
1068
- if (transport !== "stdio" && pluginConfig.sessionCatalog?.homes?.length) throw new Error("plugins.entries.codex.config.sessionCatalog.homes requires appServer.transport=stdio");
1069
- const configCommand = readNonEmptyString(config.command);
1070
- const envCommand = readNonEmptyString(env.OPENCLAW_CODEX_APP_SERVER_BIN);
1071
- const command = configCommand ?? envCommand ?? "codex";
1072
- const commandSource = configCommand ? "config" : envCommand ? "env" : "managed";
1073
- if (commandSource === "config" || commandSource === "env") assertCodexAppServerCommandHasNoInlineArgs({
1074
- command,
1075
- source: commandSource
1076
- });
1077
- const args = resolveArgs(config.args, env.OPENCLAW_CODEX_APP_SERVER_ARGS);
1078
- const headers = normalizeHeaders(config.headers);
1079
- const clearEnv = normalizeTrimmedStringList(config.clearEnv);
1080
- const authToken = normalizeCodexAppServerSecretInput({
1081
- value: config.authToken,
1082
- path: "plugins.entries.codex.config.appServer.authToken"
1083
- });
1084
- const url = readNonEmptyString(config.url) ?? (transport === "unix" ? "unix://" : void 0);
1085
- const connectionClass = inferCodexAppServerConnectionClass({
1086
- transport,
1087
- url
1088
- });
1089
- const remoteAppsSubstrate = "preconfigured";
1090
- const remoteWorkspaceRoot = normalizeRemoteWorkspaceRoot(config.remoteWorkspaceRoot);
1091
- const execMode = resolveEffectiveOpenClawExecModeForCodexAppServer({
1092
- execMode: params.execMode,
1093
- execPolicy: params.execPolicy
1094
- });
1095
- if (!params.sessionPermissionMode) assertCodexAppServerAllowedForOpenClawExecMode(execMode);
1096
- const explicitPolicyMode = resolvePolicyMode(config.mode) ?? resolvePolicyMode(env.OPENCLAW_CODEX_APP_SERVER_MODE);
1097
- const configuredSandbox = resolveSandbox(config.sandbox) ?? resolveSandbox(env.OPENCLAW_CODEX_APP_SERVER_SANDBOX);
1098
- const explicitApprovalsReviewer = resolveApprovalsReviewer(config.approvalsReviewer);
1099
- const normalizedPolicyMode = resolveCodexPolicyModeForOpenClawExecMode(execMode);
1100
- const ignoreLegacyYoloPolicyMode = normalizedPolicyMode === "guardian" && explicitPolicyMode === "yolo";
1101
- const canUseModelBackedReviewer = canUseCodexModelBackedApprovalsReviewerForModel({
1102
- modelProvider: params.modelProvider,
1103
- model: params.model,
1104
- config: params.config,
1105
- env,
1106
- agentDir: params.agentDir,
1107
- codexConfigToml: params.codexConfigToml,
1108
- homeScope
1109
- });
1110
- const forceUserReviewer = !canUseModelBackedReviewer && (explicitApprovalsReviewer === "auto_review" || explicitApprovalsReviewer === "guardian_subagent" || explicitPolicyMode === "guardian" && explicitApprovalsReviewer !== "user") || execMode !== void 0 && execMode !== "full" && (execMode !== "auto" || !canUseModelBackedReviewer);
1111
- const forceGuardianReviewer = execMode === "auto" && canUseModelBackedReviewer;
1112
- const execModeRequiringPromptingApprovals = execMode === "auto" || execMode === "ask" ? execMode : forceUserReviewer ? "ask" : void 0;
1113
- const forceDangerFullAccessSandbox = params.execPolicy?.touched === true && params.execPolicy.security === "full" && params.execPolicy.ask === "always";
1114
- const forcePerCommandApprovals = params.execPolicy?.ask === "always";
1115
- const requirementsToml = forcePerCommandApprovals ? readCodexRequirementsToml({
1116
- env,
1117
- requirementsToml: params.requirementsToml,
1118
- requirementsPath: params.requirementsPath,
1119
- readRequirementsFile: params.readRequirementsFile,
1120
- platform: params.platform
1121
- }) ?? null : params.requirementsToml;
1122
- if (forcePerCommandApprovals && requirementsToml && parseAllowedApprovalPoliciesFromCodexRequirements(requirementsToml)?.has("untrusted") === false) throw new Error("tools.exec.ask=always requires Codex app-server per-command approvals");
1123
- const forceRuntimePolicy = forceUserReviewer || forceGuardianReviewer || forceDangerFullAccessSandbox;
1124
- const defaultPolicy = explicitPolicyMode && !forceRuntimePolicy && !ignoreLegacyYoloPolicyMode ? void 0 : resolveDefaultCodexAppServerPolicy({
1125
- transport,
1126
- env,
1127
- forceGuardian: normalizedPolicyMode === "guardian",
1128
- forceUserReviewer: forceUserReviewer || !canUseModelBackedReviewer,
1129
- execModeRequiringPromptingApprovals,
1130
- requirementsToml,
1131
- requirementsPath: params.requirementsPath,
1132
- readRequirementsFile: params.readRequirementsFile,
1133
- platform: params.platform,
1134
- hostName: params.hostName,
1135
- execModeRequiringUserReviewer: forceUserReviewer ? execMode : void 0
1136
- });
1137
- const preserveExplicitAutoSandbox = forceGuardianReviewer && configuredSandbox === "read-only";
1138
- const forcedPolicy = forceRuntimePolicy ? {
1139
- approvalPolicy: forcePerCommandApprovals ? "untrusted" : defaultPolicy?.approvalPolicy ?? "on-request",
1140
- sandbox: preserveExplicitAutoSandbox ? void 0 : forceDangerFullAccessSandbox ? selectForcedDangerFullAccessSandbox({
1141
- configuredSandbox,
1142
- defaultPolicy,
1143
- openClawSandboxActive: Boolean(params.openClawSandboxActive)
1144
- }) : selectForcedPromptingSandbox({
1145
- configuredSandbox,
1146
- defaultSandbox: defaultPolicy?.sandbox
1147
- }),
1148
- approvalsReviewer: defaultPolicy?.approvalsReviewer ?? (forceUserReviewer ? "user" : "auto_review")
1149
- } : void 0;
1150
- const policyMode = ignoreLegacyYoloPolicyMode ? normalizedPolicyMode : explicitPolicyMode ?? normalizedPolicyMode ?? defaultPolicy?.mode ?? "yolo";
1151
- const serviceTier = normalizeCodexServiceTier(config.serviceTier);
1152
- const resolvedSandbox = forcedPolicy?.sandbox ?? configuredSandbox ?? defaultPolicy?.sandbox ?? (policyMode === "guardian" ? "workspace-write" : "danger-full-access");
1153
- if (transport === "websocket" && !url) throw new Error("plugins.entries.codex.config.appServer.url is required when appServer.transport is websocket");
1154
- if (transport === "websocket" && homeScope === "user") throw new Error("plugins.entries.codex.config.appServer.homeScope=user requires appServer.transport=stdio or unix");
1155
- if (transport === "unix" && homeScope !== "user") throw new Error("plugins.entries.codex.config.appServer.transport=unix requires appServer.homeScope=user");
1156
- if (transport === "unix" && !url?.startsWith("unix://")) throw new Error("plugins.entries.codex.config.appServer.url must use unix:// when appServer.transport is unix");
1157
- assertCodexAppServerConnectionSecurity({
1158
- transport,
1159
- url,
1160
- authToken,
1161
- headers
1162
- });
1163
- const configApprovalPolicy = resolveApprovalPolicy(config.approvalPolicy);
1164
- const envApprovalPolicy = resolveApprovalPolicy(env.OPENCLAW_CODEX_APP_SERVER_APPROVAL_POLICY);
1165
- const approvalPolicy = configApprovalPolicy ?? envApprovalPolicy ?? defaultPolicy?.approvalPolicy ?? (policyMode === "guardian" ? "on-request" : "never");
1166
- const approvalPolicySource = configApprovalPolicy ? "config" : envApprovalPolicy ? "env" : defaultPolicy?.approvalPolicy ? "requirements" : "implicit";
1167
- const computerUseConfig = resolveCodexComputerUseConfig({
1168
- pluginConfig: params.pluginConfig,
1169
- env
1170
- });
1171
- const managedCommandOrder = params.managedCommandOrder ?? (homeScope === "user" || computerUseConfig.enabled ? "desktop-first" : "package-first");
1172
- const includeManagedCommandOrder = commandSource === "managed" && (managedCommandOrder === "desktop-first" || params.managedCommandOrder === "package-first");
1173
- const managedComputerUsePluginNames = [.../* @__PURE__ */ new Set([DEFAULT_CODEX_COMPUTER_USE_PLUGIN_NAME, computerUseConfig.pluginName])];
1174
- return {
1175
- start: {
1176
- transport,
1177
- homeScope,
668
+ function createCodexAppServerConfig({ resolveProviderIdForAuth }) {
669
+ function resolveCodexAppServerRuntimeOptions(params = {}) {
670
+ const env = params.env ?? process.env;
671
+ const pluginConfig = readCodexPluginConfig(params.pluginConfig);
672
+ const config = pluginConfig.appServer ?? {};
673
+ const transport = resolveTransport(config.transport);
674
+ const homeScope = resolveCodexAppServerHomeScope({ appServer: config });
675
+ if (transport !== "stdio" && pluginConfig.sessionCatalog?.homes?.length) throw new Error("plugins.entries.codex.config.sessionCatalog.homes requires appServer.transport=stdio");
676
+ const configCommand = readNonEmptyString(config.command);
677
+ const envCommand = readNonEmptyString(env.OPENCLAW_CODEX_APP_SERVER_BIN);
678
+ const command = configCommand ?? envCommand ?? "codex";
679
+ const commandSource = configCommand ? "config" : envCommand ? "env" : "managed";
680
+ if (commandSource === "config" || commandSource === "env") assertCodexAppServerCommandHasNoInlineArgs({
1178
681
  command,
1179
- commandSource,
1180
- ...includeManagedCommandOrder ? { managedCommandOrder } : {},
1181
- ...commandSource === "managed" ? { managedComputerUsePluginNames } : {},
1182
- args: args.length > 0 ? args : [
1183
- "app-server",
1184
- "--listen",
1185
- "stdio://"
1186
- ],
1187
- ...url ? { url } : {},
1188
- ...authToken ? { authToken } : {},
1189
- headers,
1190
- ...transport === "stdio" && clearEnv.length > 0 ? { clearEnv } : {}
1191
- },
1192
- connectionClass,
1193
- remoteAppsSubstrate,
1194
- ...remoteWorkspaceRoot ? { remoteWorkspaceRoot } : {},
1195
- codeModeOnly: config.codeModeOnly === true,
1196
- loopDetectionPreToolUseRelay: config.loopDetectionPreToolUseRelay !== false,
1197
- requestTimeoutMs: normalizePositiveNumber(config.requestTimeoutMs, 6e4),
1198
- approvalPolicy: forcedPolicy?.approvalPolicy ?? approvalPolicy,
1199
- approvalPolicySource,
1200
- sandbox: resolvedSandbox,
1201
- approvalsReviewer: forcedPolicy?.approvalsReviewer ?? explicitApprovalsReviewer ?? defaultPolicy?.approvalsReviewer ?? (policyMode === "guardian" ? "auto_review" : "user"),
1202
- ...serviceTier ? { serviceTier } : {},
1203
- ...resolveCodexAppServerNetworkProxy(config.networkProxy, resolvedSandbox)
682
+ source: commandSource
683
+ });
684
+ const args = resolveArgs(config.args, env.OPENCLAW_CODEX_APP_SERVER_ARGS);
685
+ const headers = normalizeHeaders(config.headers);
686
+ const clearEnv = normalizeTrimmedStringList(config.clearEnv);
687
+ const authToken = normalizeCodexAppServerSecretInput({
688
+ value: config.authToken,
689
+ path: "plugins.entries.codex.config.appServer.authToken"
690
+ });
691
+ const url = readNonEmptyString(config.url) ?? (transport === "unix" ? "unix://" : void 0);
692
+ const connectionClass = inferCodexAppServerConnectionClass({
693
+ transport,
694
+ url
695
+ });
696
+ const remoteAppsSubstrate = "preconfigured";
697
+ const remoteWorkspaceRoot = normalizeRemoteWorkspaceRoot(config.remoteWorkspaceRoot);
698
+ const execMode = resolveEffectiveOpenClawExecModeForCodexAppServer({
699
+ execMode: params.execMode,
700
+ execPolicy: params.execPolicy
701
+ });
702
+ if (!params.sessionPermissionMode) assertCodexAppServerAllowedForOpenClawExecMode(execMode);
703
+ const explicitPolicyMode = resolvePolicyMode(config.mode) ?? resolvePolicyMode(env.OPENCLAW_CODEX_APP_SERVER_MODE);
704
+ const configuredSandbox = resolveSandbox(config.sandbox) ?? resolveSandbox(env.OPENCLAW_CODEX_APP_SERVER_SANDBOX);
705
+ const explicitApprovalsReviewer = resolveApprovalsReviewer(config.approvalsReviewer);
706
+ const normalizedPolicyMode = resolveCodexPolicyModeForOpenClawExecMode(execMode);
707
+ const ignoreLegacyYoloPolicyMode = normalizedPolicyMode === "guardian" && explicitPolicyMode === "yolo";
708
+ const canUseModelBackedReviewer = canUseCodexModelBackedApprovalsReviewerForModel({
709
+ modelProvider: params.modelProvider,
710
+ model: params.model,
711
+ config: params.config,
712
+ env,
713
+ agentDir: params.agentDir,
714
+ codexConfigToml: params.codexConfigToml,
715
+ homeScope
716
+ }, resolveProviderIdForAuth);
717
+ const forceUserReviewer = !canUseModelBackedReviewer && (explicitApprovalsReviewer === "auto_review" || explicitApprovalsReviewer === "guardian_subagent" || explicitPolicyMode === "guardian" && explicitApprovalsReviewer !== "user") || execMode !== void 0 && execMode !== "full" && (execMode !== "auto" || !canUseModelBackedReviewer);
718
+ const forceGuardianReviewer = execMode === "auto" && canUseModelBackedReviewer;
719
+ const execModeRequiringPromptingApprovals = execMode === "auto" || execMode === "ask" ? execMode : forceUserReviewer ? "ask" : void 0;
720
+ const forceDangerFullAccessSandbox = params.execPolicy?.touched === true && params.execPolicy.security === "full" && params.execPolicy.ask === "always";
721
+ const forcePerCommandApprovals = params.execPolicy?.ask === "always";
722
+ const requirementsToml = forcePerCommandApprovals ? readCodexRequirementsToml({
723
+ env,
724
+ requirementsToml: params.requirementsToml,
725
+ requirementsPath: params.requirementsPath,
726
+ readRequirementsFile: params.readRequirementsFile,
727
+ platform: params.platform
728
+ }) ?? null : params.requirementsToml;
729
+ if (forcePerCommandApprovals && requirementsToml && parseAllowedApprovalPoliciesFromCodexRequirements(requirementsToml)?.has("untrusted") === false) throw new Error("tools.exec.ask=always requires Codex app-server per-command approvals");
730
+ const forceRuntimePolicy = forceUserReviewer || forceGuardianReviewer || forceDangerFullAccessSandbox;
731
+ const defaultPolicy = explicitPolicyMode && !forceRuntimePolicy && !ignoreLegacyYoloPolicyMode ? void 0 : resolveDefaultCodexAppServerPolicy({
732
+ transport,
733
+ env,
734
+ forceGuardian: normalizedPolicyMode === "guardian",
735
+ forceUserReviewer: forceUserReviewer || !canUseModelBackedReviewer,
736
+ execModeRequiringPromptingApprovals,
737
+ requirementsToml,
738
+ requirementsPath: params.requirementsPath,
739
+ readRequirementsFile: params.readRequirementsFile,
740
+ platform: params.platform,
741
+ hostName: params.hostName,
742
+ execModeRequiringUserReviewer: forceUserReviewer ? execMode : void 0
743
+ });
744
+ const preserveExplicitAutoSandbox = forceGuardianReviewer && configuredSandbox === "read-only";
745
+ const forcedPolicy = forceRuntimePolicy ? {
746
+ approvalPolicy: forcePerCommandApprovals ? "untrusted" : defaultPolicy?.approvalPolicy ?? "on-request",
747
+ sandbox: preserveExplicitAutoSandbox ? void 0 : forceDangerFullAccessSandbox ? selectForcedDangerFullAccessSandbox({
748
+ configuredSandbox,
749
+ defaultPolicy,
750
+ openClawSandboxActive: Boolean(params.openClawSandboxActive)
751
+ }) : selectForcedPromptingSandbox({
752
+ configuredSandbox,
753
+ defaultSandbox: defaultPolicy?.sandbox
754
+ }),
755
+ approvalsReviewer: defaultPolicy?.approvalsReviewer ?? (forceUserReviewer ? "user" : "auto_review")
756
+ } : void 0;
757
+ const policyMode = ignoreLegacyYoloPolicyMode ? normalizedPolicyMode : explicitPolicyMode ?? normalizedPolicyMode ?? defaultPolicy?.mode ?? "yolo";
758
+ const serviceTier = normalizeCodexServiceTier(config.serviceTier);
759
+ const resolvedSandbox = forcedPolicy?.sandbox ?? configuredSandbox ?? defaultPolicy?.sandbox ?? (policyMode === "guardian" ? "workspace-write" : "danger-full-access");
760
+ if (transport === "websocket" && !url) throw new Error("plugins.entries.codex.config.appServer.url is required when appServer.transport is websocket");
761
+ if (transport === "websocket" && homeScope === "user") throw new Error("plugins.entries.codex.config.appServer.homeScope=user requires appServer.transport=stdio or unix");
762
+ if (transport === "unix" && homeScope !== "user") throw new Error("plugins.entries.codex.config.appServer.transport=unix requires appServer.homeScope=user");
763
+ if (transport === "unix" && !url?.startsWith("unix://")) throw new Error("plugins.entries.codex.config.appServer.url must use unix:// when appServer.transport is unix");
764
+ assertCodexAppServerConnectionSecurity({
765
+ transport,
766
+ url,
767
+ authToken,
768
+ headers
769
+ });
770
+ const configApprovalPolicy = resolveApprovalPolicy(config.approvalPolicy);
771
+ const envApprovalPolicy = resolveApprovalPolicy(env.OPENCLAW_CODEX_APP_SERVER_APPROVAL_POLICY);
772
+ const approvalPolicy = configApprovalPolicy ?? envApprovalPolicy ?? defaultPolicy?.approvalPolicy ?? (policyMode === "guardian" ? "on-request" : "never");
773
+ const approvalPolicySource = configApprovalPolicy ? "config" : envApprovalPolicy ? "env" : defaultPolicy?.approvalPolicy ? "requirements" : "implicit";
774
+ const computerUseConfig = resolveCodexComputerUseConfig({
775
+ pluginConfig: params.pluginConfig,
776
+ env
777
+ });
778
+ const managedCommandOrder = params.managedCommandOrder ?? (homeScope === "user" || computerUseConfig.enabled ? "desktop-first" : "package-first");
779
+ const includeManagedCommandOrder = commandSource === "managed" && (managedCommandOrder === "desktop-first" || params.managedCommandOrder === "package-first");
780
+ const managedComputerUsePluginNames = [.../* @__PURE__ */ new Set([DEFAULT_CODEX_COMPUTER_USE_PLUGIN_NAME, computerUseConfig.pluginName])];
781
+ return {
782
+ start: {
783
+ transport,
784
+ homeScope,
785
+ command,
786
+ commandSource,
787
+ ...includeManagedCommandOrder ? { managedCommandOrder } : {},
788
+ ...commandSource === "managed" ? { managedComputerUsePluginNames } : {},
789
+ args: args.length > 0 ? args : [
790
+ "app-server",
791
+ "--listen",
792
+ "stdio://"
793
+ ],
794
+ ...url ? { url } : {},
795
+ ...authToken ? { authToken } : {},
796
+ headers,
797
+ ...transport === "stdio" && clearEnv.length > 0 ? { clearEnv } : {}
798
+ },
799
+ connectionClass,
800
+ remoteAppsSubstrate,
801
+ ...remoteWorkspaceRoot ? { remoteWorkspaceRoot } : {},
802
+ codeModeOnly: config.codeModeOnly === true,
803
+ loopDetectionPreToolUseRelay: config.loopDetectionPreToolUseRelay !== false,
804
+ requestTimeoutMs: normalizePositiveNumber(config.requestTimeoutMs, 6e4),
805
+ approvalPolicy: forcedPolicy?.approvalPolicy ?? approvalPolicy,
806
+ approvalPolicySource,
807
+ sandbox: resolvedSandbox,
808
+ approvalsReviewer: forcedPolicy?.approvalsReviewer ?? explicitApprovalsReviewer ?? defaultPolicy?.approvalsReviewer ?? (policyMode === "guardian" ? "auto_review" : "user"),
809
+ ...serviceTier ? { serviceTier } : {},
810
+ ...resolveCodexAppServerNetworkProxy(config.networkProxy, resolvedSandbox)
811
+ };
812
+ }
813
+ /** Resolves the passive supervision control connection without changing harness defaults. */
814
+ function resolveCodexSupervisionAppServerRuntimeOptions(params = {}) {
815
+ const pluginConfig = readCodexPluginConfig(params.pluginConfig);
816
+ const appServer = pluginConfig.appServer ?? {};
817
+ const homeScope = resolveCodexAppServerHomeScope({
818
+ appServer,
819
+ connectionScope: "supervision"
820
+ });
821
+ return resolveCodexAppServerRuntimeOptions({
822
+ ...params,
823
+ pluginConfig: {
824
+ ...pluginConfig,
825
+ appServer: {
826
+ ...appServer,
827
+ homeScope
828
+ }
829
+ }
830
+ });
831
+ }
832
+ return {
833
+ resolveCodexAppServerRuntimeOptions,
834
+ resolveCodexSupervisionAppServerRuntimeOptions
1204
835
  };
1205
836
  }
1206
837
  /**
@@ -1320,24 +951,5 @@ function codexSandboxPolicyForTurn(mode, cwd, nativeArgs = []) {
1320
951
  excludeSlashTmp
1321
952
  };
1322
953
  }
1323
- /** Resolves the passive supervision control connection without changing harness defaults. */
1324
- function resolveCodexSupervisionAppServerRuntimeOptions(params = {}) {
1325
- const pluginConfig = readCodexPluginConfig(params.pluginConfig);
1326
- const appServer = pluginConfig.appServer ?? {};
1327
- const homeScope = resolveCodexAppServerHomeScope({
1328
- appServer,
1329
- connectionScope: "supervision"
1330
- });
1331
- return resolveCodexAppServerRuntimeOptions({
1332
- ...params,
1333
- pluginConfig: {
1334
- ...pluginConfig,
1335
- appServer: {
1336
- ...appServer,
1337
- homeScope
1338
- }
1339
- }
1340
- });
1341
- }
1342
954
  //#endregion
1343
- export { resolveOpenClawExecPolicyForCodexAppServer as A, isJsonObject as B, CODEX_SESSION_OVERRIDABLE_LAYER_TYPES as C, isCodexSandboxExecServerEnabled as D, isCodexRemoteExecPlacementSandbox as E, withEphemeralCodexAuthStore as F, CODEX_INTERACTIVE_CUSTOM_THREAD_SOURCES as I, CODEX_INTERACTIVE_THREAD_SOURCE_KINDS as L, resolveCodexAppServerHomeDir as M, resolveCodexAppServerLocalHomeDir as N, readCodexPluginConfig as O, resolveCodexAppServerUserHomeDir as P, CODEX_OPENCLAW_DIRECT_DYNAMIC_TOOL_NAMESPACE as R, selectUserApprovalsReviewer as S, isCodexPairedNodeRemoteExecPlacementSandbox as T, isRpcResponse as V, parseAllowedApprovalsReviewersFromCodexRequirements as _, resolveCodexAppServerStartOptionsForAgent as a, selectGuardianApprovalPolicy as b, assertCodexAppServerConnectionSecurity as c, shouldAutoApproveCodexAppServerApprovals as d, withMcpElicitationsApprovalPolicy as f, parseAllowedApprovalPoliciesFromCodexRequirements as g, resolveCodexModelBackedReviewerPolicyContext as h, resolveCodexAppServerRuntimeOptions as i, selectGuardianSandbox as j, resolveCodexPluginsPolicy as k, hasCodexMcpToolApprovalOverrides as l, canUseCodexModelBackedApprovalsReviewerForModel as m, codexSandboxPolicyForTurn as n, resolveCodexComputerUseConfig as o, assertCodexModelBackedReviewerEffectiveConfig as p, resolveCodexAppServerHomeScope as r, resolveCodexSupervisionAppServerRuntimeOptions as s, codexAppServerStartOptionsKey as t, resolveCodexAppServerNetworkProxy as u, parseAllowedSandboxModesFromCodexRequirements as v, readCodexEffectiveConfig as w, selectGuardianApprovalsReviewer as x, readCodexRequirementsToml as y, flattenCodexDynamicToolFunctions as z };
955
+ export { selectUserApprovalsReviewer as C, selectGuardianApprovalsReviewer as S, parseAllowedApprovalPoliciesFromCodexRequirements as _, resolveCodexAppServerStartOptionsForAgent as a, readCodexRequirementsToml as b, hasCodexMcpToolApprovalOverrides as c, withMcpElicitationsApprovalPolicy as d, assertCodexModelBackedReviewerEffectiveConfig as f, readCodexEffectiveConfig as g, CODEX_SESSION_OVERRIDABLE_LAYER_TYPES as h, resolveCodexAppServerHomeScope as i, resolveCodexAppServerNetworkProxy as l, resolveCodexModelBackedReviewerPolicyContext as m, codexSandboxPolicyForTurn as n, resolveCodexComputerUseConfig as o, canUseCodexModelBackedApprovalsReviewerForModel as p, createCodexAppServerConfig as r, assertCodexAppServerConnectionSecurity as s, codexAppServerStartOptionsKey as t, shouldAutoApproveCodexAppServerApprovals as u, parseAllowedApprovalsReviewersFromCodexRequirements as v, selectGuardianSandbox as w, selectGuardianApprovalPolicy as x, parseAllowedSandboxModesFromCodexRequirements as y };