@openclaw/codex 2026.7.2-beta.7 → 2026.7.33

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 (64) hide show
  1. package/README.md +3 -27
  2. package/dist/{command-formatters-C336eRVS.js → .setup/app-server-policy-C_qTMEMy.mjs} +51 -9
  3. package/dist/{attempt-notifications-AP-a-Q5k.js → .setup/attempt-notifications-F8krwWL4.mjs} +6 -3
  4. package/dist/{command-handlers-DAHUSry9.js → .setup/command-handlers-DSRFfor4.mjs} +1156 -1319
  5. package/dist/.setup/command-rpc-BvYsfQ7G.mjs +786 -0
  6. package/dist/{compact-D_uvHurS.js → .setup/compact-BNgh7I4t.mjs} +10 -40
  7. package/dist/.setup/computer-use-C3QkmSO3.mjs +377 -0
  8. package/dist/.setup/config-CYEDnLJ2.mjs +1138 -0
  9. package/dist/{conversation-binding-data-BHRpYbX3.js → .setup/conversation-binding-data-CrRxtDBu.mjs} +1 -1
  10. package/dist/{bounded-turn-D2ZAgZVz.js → .setup/media-understanding-provider-EbJCyDqe.mjs} +203 -109
  11. package/dist/{models-BBMKU4jA.js → .setup/models-C_aZk03A.mjs} +11 -6
  12. package/dist/.setup/notification-correlation-iYs4WieS.mjs +35 -0
  13. package/dist/.setup/plugin-app-cache-key-DR8jV9oS.mjs +99 -0
  14. package/dist/.setup/protocol-2POPqAY4.mjs +13 -0
  15. package/dist/{transcript-mirror-DzsdNCf5.js → .setup/protocol-validators-dZQ-UTOa.mjs} +112 -922
  16. package/dist/{rate-limits-CU-gVCCS.js → .setup/provider-DGxDs6g8.mjs} +269 -13
  17. package/dist/{dynamic-tools-D2gYkSBO.js → .setup/provider-capabilities-DS2N_zc1.mjs} +5632 -3953
  18. package/dist/.setup/request-DFR0JyoV.mjs +36 -0
  19. package/dist/.setup/run-attempt-C7xEKFVB.mjs +8180 -0
  20. package/dist/{sandbox-guard-NuhpXmPB.js → .setup/sandbox-guard-DA2TQfZW.mjs} +1 -14
  21. package/dist/.setup/session-binding-DuihlMJc.mjs +628 -0
  22. package/dist/.setup/shared-client-B2KmLPRw.mjs +1854 -0
  23. package/dist/{side-question-_ulBk1AL.js → .setup/side-question-Cv6JXWCS.mjs} +84 -159
  24. package/dist/.setup/thread-lifecycle-u6CZdOOH.mjs +2593 -0
  25. package/dist/{web-search-provider.runtime-CCFhg2z5.js → .setup/web-search-provider.runtime-Ce2zOHxW.mjs} +3 -3
  26. package/dist/doctor-contract-api.js +122 -88
  27. package/dist/harness.js +20 -89
  28. package/dist/index.js +436 -1615
  29. package/dist/media-understanding-provider.js +1 -173
  30. package/dist/prompt-overlay.js +15 -0
  31. package/dist/provider-catalog.js +79 -0
  32. package/dist/provider-discovery.js +34 -0
  33. package/dist/provider.js +2 -0
  34. package/dist/web-search-contract-api.js +1 -1
  35. package/openclaw.plugin.json +178 -221
  36. package/package.json +8 -9
  37. package/dist/app-server-policy-BSaO2JIT.js +0 -49
  38. package/dist/auth-binding-B4FfbcCg.js +0 -62
  39. package/dist/capabilities-BFDTVYr4.js +0 -36
  40. package/dist/cli-metadata.js +0 -20
  41. package/dist/computer-use-CYEc8U3w.js +0 -693
  42. package/dist/conversation-control-xsIeXbo4.js +0 -287
  43. package/dist/effective-mcp-catalog-Bbd98Inw.js +0 -114
  44. package/dist/event-projector-assistant-message-DTgnPPVF.js +0 -101
  45. package/dist/event-projector-usage-Xp4AlR2k.js +0 -86
  46. package/dist/incognito-session-ET_ufDH-.js +0 -2
  47. package/dist/notification-correlation-CU6_AnOb.js +0 -67
  48. package/dist/plugin-app-cache-key-DztPafOA.js +0 -408
  49. package/dist/request-qKh331yu.js +0 -157
  50. package/dist/run-attempt-CY9WlDLc.js +0 -12413
  51. package/dist/runtime-artifact-CmtG_t1L.js +0 -554
  52. package/dist/session-binding-BXpo9ymA.js +0 -2214
  53. package/dist/session-catalog-DyOgR4WH.js +0 -2668
  54. package/dist/session-cli-2PZaFLRh.js +0 -175
  55. package/dist/session-upstream-marker-B6U7tLw5.js +0 -82
  56. package/dist/settled-turn-finalizer-CXY2Z9dT.js +0 -316
  57. package/dist/shared-client-DTbvH-XV.js +0 -3069
  58. package/dist/thread-lifecycle-DF53ogiA.js +0 -3987
  59. package/dist/transport-stdio-DXgGZ7Ib.js +0 -88
  60. package/dist/upstream-session-fork-Dy4Xvuoj.js +0 -320
  61. package/dist/usage-CQ6GhD5-.js +0 -25
  62. /package/dist/{rolldown-runtime-8H4AJuhK.js → .setup/rolldown-runtime-8H4AJuhK.mjs} +0 -0
  63. /package/dist/{session-binding-meta-B7aEMU7g.js → .setup/session-binding-meta-B7aEMU7g.mjs} +0 -0
  64. /package/dist/{web-search-provider.shared-BrZmlqyR.js → .setup/web-search-provider.shared-BrZmlqyR.mjs} +0 -0
@@ -0,0 +1,1138 @@
1
+ import path from "node:path";
2
+ import { resolvePositiveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
3
+ import { createHash, createHmac, randomBytes } from "node:crypto";
4
+ import { readFileSync } from "node:fs";
5
+ import { homedir, hostname } from "node:os";
6
+ import { resolveProviderIdForAuth } from "openclaw/plugin-sdk/agent-runtime";
7
+ import { resolveExecApprovalsFromFile } from "openclaw/plugin-sdk/exec-approvals-runtime";
8
+ import { normalizeAgentId } from "openclaw/plugin-sdk/routing";
9
+ import { buildSecretInputSchema, normalizeResolvedSecretInputString } from "openclaw/plugin-sdk/secret-input";
10
+ import { normalizeTrimmedStringList } from "openclaw/plugin-sdk/string-coerce-runtime";
11
+ import { detectWindowsSpawnCommandInlineArgs } from "openclaw/plugin-sdk/windows-spawn";
12
+ import { z } from "zod";
13
+ //#region extensions/codex/src/app-server/config.ts
14
+ const START_OPTIONS_KEY_SECRET_SYMBOL = Symbol.for("openclaw.codexAppServerStartOptionsKeySecret");
15
+ const START_OPTIONS_KEY_SECRET = getStartOptionsKeySecret();
16
+ const UNIX_CODEX_REQUIREMENTS_PATH = "/etc/codex/requirements.toml";
17
+ const WINDOWS_CODEX_REQUIREMENTS_SUFFIX = "\\OpenAI\\Codex\\requirements.toml";
18
+ const CODEX_APP_SERVER_HOME_DIRNAME = "codex-home";
19
+ const CODEX_CONFIG_TOML_FILENAME = "config.toml";
20
+ const PLAIN_DECIMAL_NUMBER_RE = /^[+-]?(?:(?:\d+\.?\d*)|(?:\.\d+))$/;
21
+ const CODEX_PLUGINS_MARKETPLACE_NAME = "openai-curated";
22
+ function shouldAutoApproveCodexAppServerApprovals(appServer) {
23
+ return appServer.networkProxy === void 0 && appServer.approvalPolicy === "never" && appServer.sandbox === "danger-full-access";
24
+ }
25
+ const DEFAULT_CODEX_COMPUTER_USE_PLUGIN_NAME = "computer-use";
26
+ const DEFAULT_CODEX_COMPUTER_USE_MCP_SERVER_NAME = "computer-use";
27
+ const DEFAULT_CODEX_COMPUTER_USE_MARKETPLACE_DISCOVERY_TIMEOUT_MS = 6e4;
28
+ const DEFAULT_CODEX_APP_SERVER_NETWORK_PROXY_PROFILE_PREFIX = "openclaw-network";
29
+ const codexAppServerTransportSchema = z.enum(["stdio", "websocket"]);
30
+ const codexAppServerHomeScopeSchema = z.enum(["agent", "user"]);
31
+ const SecretInputSchema = buildSecretInputSchema();
32
+ const codexAppServerPolicyModeSchema = z.enum(["yolo", "guardian"]);
33
+ const codexAppServerApprovalPolicySchema = z.preprocess((value) => value === "on-failure" ? "on-request" : value, z.enum([
34
+ "never",
35
+ "on-request",
36
+ "untrusted"
37
+ ]));
38
+ const codexAppServerSandboxSchema = z.enum([
39
+ "read-only",
40
+ "workspace-write",
41
+ "danger-full-access"
42
+ ]);
43
+ const codexAppServerApprovalsReviewerSchema = z.enum([
44
+ "user",
45
+ "auto_review",
46
+ "guardian_subagent"
47
+ ]);
48
+ const codexDynamicToolsLoadingSchema = z.enum(["searchable", "direct"]);
49
+ const codexPluginDestructivePolicySchema = z.union([
50
+ z.boolean(),
51
+ z.literal("auto"),
52
+ z.literal("ask")
53
+ ]);
54
+ const codexAppServerServiceTierSchema = z.preprocess((value) => value === null ? null : normalizeCodexServiceTier(value), z.string().trim().min(1).nullable().optional()).optional();
55
+ const codexAppServerExperimentalSchema = z.object({ sandboxExecServer: z.boolean().optional() }).strict();
56
+ const codexAppServerRemoteWorkspaceRootSchema = z.string().trim().min(1);
57
+ const codexAppServerNetworkProxyDomainPermissionSchema = z.enum(["allow", "deny"]);
58
+ const codexAppServerNetworkProxyUnixSocketPermissionSchema = z.enum(["allow", "none"]);
59
+ const codexAppServerNetworkProxySchema = z.object({
60
+ enabled: z.boolean().optional(),
61
+ profileName: z.string().trim().min(1).optional(),
62
+ baseProfile: z.enum(["read-only", "workspace"]).optional(),
63
+ mode: z.enum(["limited", "full"]).optional(),
64
+ domains: z.record(z.string(), codexAppServerNetworkProxyDomainPermissionSchema).optional(),
65
+ unixSockets: z.record(z.string(), codexAppServerNetworkProxyUnixSocketPermissionSchema).optional(),
66
+ proxyUrl: z.string().trim().min(1).optional(),
67
+ socksUrl: z.string().trim().min(1).optional(),
68
+ enableSocks5: z.boolean().optional(),
69
+ enableSocks5Udp: z.boolean().optional(),
70
+ allowUpstreamProxy: z.boolean().optional(),
71
+ allowLocalBinding: z.boolean().optional(),
72
+ dangerouslyAllowNonLoopbackProxy: z.boolean().optional(),
73
+ dangerouslyAllowAllUnixSockets: z.boolean().optional()
74
+ }).strict();
75
+ const codexPluginEntryConfigSchema = z.object({
76
+ enabled: z.boolean().optional(),
77
+ marketplaceName: z.literal(CODEX_PLUGINS_MARKETPLACE_NAME).optional(),
78
+ pluginName: z.string().trim().min(1).optional(),
79
+ allow_destructive_actions: codexPluginDestructivePolicySchema.optional()
80
+ }).strict();
81
+ const codexPluginsConfigSchema = z.object({
82
+ enabled: z.boolean().optional(),
83
+ allow_all_plugins: z.boolean().optional(),
84
+ allow_destructive_actions: codexPluginDestructivePolicySchema.optional(),
85
+ plugins: z.record(z.string(), codexPluginEntryConfigSchema).optional()
86
+ }).strict();
87
+ const codexPluginConfigSchema = z.object({
88
+ codexDynamicToolsLoading: codexDynamicToolsLoadingSchema.optional(),
89
+ codexDynamicToolsExclude: z.array(z.string()).optional(),
90
+ discovery: z.object({
91
+ enabled: z.boolean().optional(),
92
+ timeoutMs: z.number().positive().optional()
93
+ }).strict().optional(),
94
+ computerUse: z.object({
95
+ enabled: z.boolean().optional(),
96
+ autoInstall: z.boolean().optional(),
97
+ marketplaceDiscoveryTimeoutMs: z.number().positive().optional(),
98
+ marketplaceSource: z.string().optional(),
99
+ marketplacePath: z.string().optional(),
100
+ marketplaceName: z.string().optional(),
101
+ pluginName: z.string().optional(),
102
+ mcpServerName: z.string().optional()
103
+ }).strict().optional(),
104
+ codexPlugins: z.unknown().optional(),
105
+ appServer: z.object({
106
+ mode: codexAppServerPolicyModeSchema.optional(),
107
+ transport: codexAppServerTransportSchema.optional(),
108
+ homeScope: codexAppServerHomeScopeSchema.optional(),
109
+ command: z.string().optional(),
110
+ args: z.union([z.array(z.string()), z.string()]).optional(),
111
+ url: z.string().optional(),
112
+ authToken: SecretInputSchema.optional(),
113
+ headers: z.record(z.string(), SecretInputSchema).optional(),
114
+ clearEnv: z.array(z.string()).optional(),
115
+ remoteWorkspaceRoot: codexAppServerRemoteWorkspaceRootSchema.optional(),
116
+ codeModeOnly: z.boolean().optional(),
117
+ requestTimeoutMs: z.number().positive().optional(),
118
+ turnCompletionIdleTimeoutMs: z.number().positive().optional(),
119
+ postToolRawAssistantCompletionIdleTimeoutMs: z.number().positive().optional(),
120
+ approvalPolicy: codexAppServerApprovalPolicySchema.optional(),
121
+ sandbox: codexAppServerSandboxSchema.optional(),
122
+ approvalsReviewer: codexAppServerApprovalsReviewerSchema.optional(),
123
+ serviceTier: codexAppServerServiceTierSchema,
124
+ networkProxy: codexAppServerNetworkProxySchema.optional(),
125
+ defaultWorkspaceDir: z.string().optional(),
126
+ experimental: codexAppServerExperimentalSchema.optional()
127
+ }).strict().optional()
128
+ }).strict();
129
+ function readCodexPluginConfig(value) {
130
+ const parsed = codexPluginConfigSchema.safeParse(value);
131
+ if (!parsed.success) return {};
132
+ const { codexPlugins: rawCodexPlugins, ...config } = parsed.data;
133
+ const plugins = codexPluginsConfigSchema.safeParse(rawCodexPlugins);
134
+ if (!plugins.success) return config;
135
+ return {
136
+ ...config,
137
+ ...plugins.data ? { codexPlugins: plugins.data } : {}
138
+ };
139
+ }
140
+ function isCodexSandboxExecServerEnabled(pluginConfig) {
141
+ return readCodexPluginConfig(pluginConfig).appServer?.experimental?.sandboxExecServer === true;
142
+ }
143
+ function assertCodexAppServerCommandHasNoInlineArgs(params) {
144
+ const inlineArgs = detectWindowsSpawnCommandInlineArgs(params.command);
145
+ if (!inlineArgs) return;
146
+ const sourceLabel = params.source === "env" ? "OPENCLAW_CODEX_APP_SERVER_BIN" : "plugins.entries.codex.config.appServer.command";
147
+ const argsLabel = params.source === "env" ? "OPENCLAW_CODEX_APP_SERVER_ARGS" : "plugins.entries.codex.config.appServer.args";
148
+ 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.`);
149
+ }
150
+ function resolveCodexPluginsPolicy(pluginConfig) {
151
+ const config = readCodexPluginConfig(pluginConfig).codexPlugins;
152
+ const configured = config !== void 0;
153
+ const enabled = config?.enabled === true;
154
+ const destructivePolicy = resolveCodexPluginDestructivePolicy(config?.allow_destructive_actions ?? true);
155
+ const pluginPolicies = Object.entries(config?.plugins ?? {}).flatMap(([configKey, entry]) => {
156
+ if (entry.marketplaceName !== "openai-curated" || !entry.pluginName) return [];
157
+ const entryDestructivePolicy = resolveCodexPluginDestructivePolicy(entry.allow_destructive_actions ?? config?.allow_destructive_actions ?? true);
158
+ return [{
159
+ configKey,
160
+ marketplaceName: CODEX_PLUGINS_MARKETPLACE_NAME,
161
+ pluginName: entry.pluginName,
162
+ enabled: enabled && entry.enabled !== false,
163
+ allowDestructiveActions: entryDestructivePolicy.allowDestructiveActions,
164
+ destructiveApprovalMode: entryDestructivePolicy.destructiveApprovalMode
165
+ }];
166
+ }).toSorted((left, right) => left.configKey.localeCompare(right.configKey));
167
+ return {
168
+ configured,
169
+ enabled,
170
+ allowAllPlugins: enabled && config?.allow_all_plugins === true,
171
+ allowDestructiveActions: destructivePolicy.allowDestructiveActions,
172
+ destructiveApprovalMode: destructivePolicy.destructiveApprovalMode,
173
+ pluginPolicies
174
+ };
175
+ }
176
+ function resolveCodexPluginDestructivePolicy(policy) {
177
+ if (policy === "auto" || policy === "ask") return {
178
+ allowDestructiveActions: true,
179
+ destructiveApprovalMode: policy
180
+ };
181
+ return {
182
+ allowDestructiveActions: policy,
183
+ destructiveApprovalMode: policy ? "allow" : "deny"
184
+ };
185
+ }
186
+ function resolveCodexAppServerRuntimeOptions(params = {}) {
187
+ const env = params.env ?? process.env;
188
+ const config = readCodexPluginConfig(params.pluginConfig).appServer ?? {};
189
+ const transport = resolveTransport(config.transport);
190
+ const homeScope = config.homeScope === "user" ? "user" : "agent";
191
+ const configCommand = readNonEmptyString(config.command);
192
+ const envCommand = readNonEmptyString(env.OPENCLAW_CODEX_APP_SERVER_BIN);
193
+ const command = configCommand ?? envCommand ?? "codex";
194
+ const commandSource = configCommand ? "config" : envCommand ? "env" : "managed";
195
+ if (commandSource === "config" || commandSource === "env") assertCodexAppServerCommandHasNoInlineArgs({
196
+ command,
197
+ source: commandSource
198
+ });
199
+ const args = resolveArgs(config.args, env.OPENCLAW_CODEX_APP_SERVER_ARGS);
200
+ const headers = normalizeHeaders(config.headers);
201
+ const clearEnv = normalizeStringList(config.clearEnv);
202
+ const authToken = normalizeCodexAppServerSecretInput({
203
+ value: config.authToken,
204
+ path: "plugins.entries.codex.config.appServer.authToken"
205
+ });
206
+ const url = readNonEmptyString(config.url);
207
+ const connectionClass = inferCodexAppServerConnectionClass({
208
+ transport,
209
+ url
210
+ });
211
+ const remoteAppsSubstrate = "preconfigured";
212
+ const remoteWorkspaceRoot = normalizeRemoteWorkspaceRoot(config.remoteWorkspaceRoot);
213
+ const execMode = resolveEffectiveOpenClawExecModeForCodexAppServer({
214
+ execMode: params.execMode,
215
+ execPolicy: params.execPolicy
216
+ });
217
+ assertCodexAppServerAllowedForOpenClawExecMode(execMode);
218
+ const explicitPolicyMode = resolvePolicyMode(config.mode) ?? resolvePolicyMode(env.OPENCLAW_CODEX_APP_SERVER_MODE);
219
+ const configuredSandbox = resolveSandbox(config.sandbox) ?? resolveSandbox(env.OPENCLAW_CODEX_APP_SERVER_SANDBOX);
220
+ const explicitApprovalsReviewer = resolveApprovalsReviewer(config.approvalsReviewer);
221
+ const normalizedPolicyMode = resolveCodexPolicyModeForOpenClawExecMode(execMode);
222
+ const ignoreLegacyYoloPolicyMode = normalizedPolicyMode === "guardian" && explicitPolicyMode === "yolo";
223
+ const canUseModelBackedReviewer = canUseCodexModelBackedApprovalsReviewerForModel({
224
+ modelProvider: params.modelProvider,
225
+ model: params.model,
226
+ config: params.config,
227
+ env,
228
+ agentDir: params.agentDir,
229
+ codexConfigToml: params.codexConfigToml,
230
+ homeScope
231
+ });
232
+ const forceUserReviewer = !canUseModelBackedReviewer && (explicitApprovalsReviewer === "auto_review" || explicitApprovalsReviewer === "guardian_subagent" || explicitPolicyMode === "guardian" && explicitApprovalsReviewer !== "user") || execMode !== void 0 && execMode !== "full" && (execMode !== "auto" || !canUseModelBackedReviewer);
233
+ const forceGuardianReviewer = execMode === "auto" && canUseModelBackedReviewer;
234
+ const execModeRequiringPromptingApprovals = execMode === "auto" || execMode === "ask" ? execMode : forceUserReviewer ? "ask" : void 0;
235
+ const forceDangerFullAccessSandbox = params.execPolicy?.touched === true && params.execPolicy.security === "full" && params.execPolicy.ask === "always";
236
+ const forceRuntimePolicy = forceUserReviewer || forceGuardianReviewer || forceDangerFullAccessSandbox;
237
+ const defaultPolicy = explicitPolicyMode && !forceRuntimePolicy && !ignoreLegacyYoloPolicyMode ? void 0 : resolveDefaultCodexAppServerPolicy({
238
+ transport,
239
+ env,
240
+ forceGuardian: normalizedPolicyMode === "guardian",
241
+ forceUserReviewer: forceUserReviewer || !canUseModelBackedReviewer,
242
+ execModeRequiringPromptingApprovals,
243
+ requirementsToml: params.requirementsToml,
244
+ requirementsPath: params.requirementsPath,
245
+ readRequirementsFile: params.readRequirementsFile,
246
+ platform: params.platform,
247
+ hostName: params.hostName,
248
+ execModeRequiringUserReviewer: forceUserReviewer ? execMode : void 0
249
+ });
250
+ const preserveExplicitAutoSandbox = forceGuardianReviewer && configuredSandbox === "read-only";
251
+ const forcedPolicy = forceRuntimePolicy ? {
252
+ approvalPolicy: defaultPolicy?.approvalPolicy ?? "on-request",
253
+ sandbox: preserveExplicitAutoSandbox ? void 0 : forceDangerFullAccessSandbox ? selectForcedDangerFullAccessSandbox({
254
+ configuredSandbox,
255
+ defaultPolicy,
256
+ openClawSandboxActive: Boolean(params.openClawSandboxActive)
257
+ }) : selectForcedPromptingSandbox({
258
+ configuredSandbox,
259
+ defaultSandbox: defaultPolicy?.sandbox
260
+ }),
261
+ approvalsReviewer: defaultPolicy?.approvalsReviewer ?? (forceUserReviewer ? "user" : "auto_review")
262
+ } : void 0;
263
+ const policyMode = ignoreLegacyYoloPolicyMode ? normalizedPolicyMode : explicitPolicyMode ?? normalizedPolicyMode ?? defaultPolicy?.mode ?? "yolo";
264
+ const serviceTier = normalizeCodexServiceTier(config.serviceTier);
265
+ const resolvedSandbox = forcedPolicy?.sandbox ?? configuredSandbox ?? defaultPolicy?.sandbox ?? (policyMode === "guardian" ? "workspace-write" : "danger-full-access");
266
+ if (transport === "websocket" && !url) throw new Error("plugins.entries.codex.config.appServer.url is required when appServer.transport is websocket");
267
+ if (transport === "websocket" && homeScope === "user") throw new Error("plugins.entries.codex.config.appServer.homeScope=user requires appServer.transport=stdio");
268
+ assertCodexAppServerConnectionClassConfig({
269
+ connectionClass,
270
+ authToken,
271
+ headers
272
+ });
273
+ const configApprovalPolicy = resolveApprovalPolicy(config.approvalPolicy);
274
+ const envApprovalPolicy = resolveApprovalPolicy(env.OPENCLAW_CODEX_APP_SERVER_APPROVAL_POLICY);
275
+ const approvalPolicy = configApprovalPolicy ?? envApprovalPolicy ?? defaultPolicy?.approvalPolicy ?? (policyMode === "guardian" ? "on-request" : "never");
276
+ const approvalPolicySource = configApprovalPolicy ? "config" : envApprovalPolicy ? "env" : defaultPolicy?.approvalPolicy ? "requirements" : "implicit";
277
+ return {
278
+ start: {
279
+ transport,
280
+ homeScope,
281
+ command,
282
+ commandSource,
283
+ args: args.length > 0 ? args : [
284
+ "app-server",
285
+ "--listen",
286
+ "stdio://"
287
+ ],
288
+ ...url ? { url } : {},
289
+ ...authToken ? { authToken } : {},
290
+ headers,
291
+ ...transport === "stdio" && clearEnv.length > 0 ? { clearEnv } : {}
292
+ },
293
+ connectionClass,
294
+ remoteAppsSubstrate,
295
+ ...remoteWorkspaceRoot ? { remoteWorkspaceRoot } : {},
296
+ codeModeOnly: config.codeModeOnly === true,
297
+ requestTimeoutMs: normalizePositiveNumber(config.requestTimeoutMs, 6e4),
298
+ turnCompletionIdleTimeoutMs: normalizePositiveNumber(config.turnCompletionIdleTimeoutMs, 6e4),
299
+ ...config.postToolRawAssistantCompletionIdleTimeoutMs !== void 0 ? { postToolRawAssistantCompletionIdleTimeoutMs: normalizePositiveNumber(config.postToolRawAssistantCompletionIdleTimeoutMs, 6e4) } : {},
300
+ approvalPolicy: forcedPolicy?.approvalPolicy ?? approvalPolicy,
301
+ approvalPolicySource,
302
+ sandbox: resolvedSandbox,
303
+ approvalsReviewer: forcedPolicy?.approvalsReviewer ?? explicitApprovalsReviewer ?? defaultPolicy?.approvalsReviewer ?? (policyMode === "guardian" ? "auto_review" : "user"),
304
+ ...serviceTier ? { serviceTier } : {},
305
+ ...resolveCodexAppServerNetworkProxy(config.networkProxy, resolvedSandbox)
306
+ };
307
+ }
308
+ function isCodexAppServerApprovalPolicyAllowedByRequirements(policy, params = {}) {
309
+ const content = readCodexRequirementsToml(params);
310
+ if (content === void 0) return true;
311
+ const allowedApprovalPolicies = parseAllowedApprovalPoliciesFromCodexRequirements(content);
312
+ return allowedApprovalPolicies === void 0 || allowedApprovalPolicies.has(policy);
313
+ }
314
+ function canUseCodexModelBackedApprovalsReviewerForModel(params) {
315
+ const explicitProvider = params.modelProvider?.trim().toLowerCase();
316
+ const inferredProvider = inferProviderFromModelRef(params.model);
317
+ if (explicitProvider && explicitProvider !== "codex") return isTrustedCodexModelBackedApprovalsReviewerProvider(explicitProvider, params) && (inferredProvider === void 0 || isTrustedCodexModelBackedApprovalsReviewerProvider(inferredProvider, params));
318
+ if (inferredProvider !== void 0) return isTrustedCodexModelBackedApprovalsReviewerProvider(inferredProvider, params);
319
+ return isTrustedCodexModelBackedApprovalsReviewerProvider(explicitProvider, params);
320
+ }
321
+ function isTrustedCodexModelBackedOpenAIProvider(params) {
322
+ if (!openAIBaseUrlEnvOverridesAreTrustedForModelBackedReview(params.env)) return false;
323
+ const codexBaseUrlOverrides = readCodexBaseUrlOverridesForModelBackedReview(params);
324
+ if (codexBaseUrlOverrides === false || !codexBaseUrlOverrides.openAI.every(isNativeOpenAIBaseUrl) || !codexBaseUrlOverrides.chatGPT.every(isNativeChatGPTBaseUrl)) return false;
325
+ const openAIProviders = readConfiguredOpenAIProvidersForModelBackedReview(params.config);
326
+ if (openAIProviders.length === 0) return true;
327
+ return openAIProviders.every((openAIProvider) => configuredOpenAIProviderIsTrustedForModelBackedReview(openAIProvider, params.model));
328
+ }
329
+ function resolveCodexModelBackedReviewerPolicyContext(params) {
330
+ const provider = params.provider?.trim();
331
+ if (provider && provider.toLowerCase() !== "codex") return {
332
+ modelProvider: normalizeCodexModelBackedReviewerPolicyProvider(provider),
333
+ model: params.model
334
+ };
335
+ const bindingModelProvider = params.bindingModelProvider?.trim();
336
+ const currentModel = params.model?.trim();
337
+ const bindingModel = params.bindingModel?.trim();
338
+ if (bindingModelProvider && currentModel && bindingModel && currentModel === bindingModel) return {
339
+ modelProvider: normalizeCodexModelBackedReviewerPolicyProvider(bindingModelProvider),
340
+ model: params.model ?? params.bindingModel
341
+ };
342
+ const currentModelProvider = inferProviderFromModelRef(params.model);
343
+ if (currentModelProvider) return {
344
+ modelProvider: normalizeCodexModelBackedReviewerPolicyProvider(currentModelProvider),
345
+ model: params.model
346
+ };
347
+ if (bindingModelProvider) return {
348
+ modelProvider: normalizeCodexModelBackedReviewerPolicyProvider(bindingModelProvider),
349
+ model: params.model ?? params.bindingModel
350
+ };
351
+ return {
352
+ modelProvider: params.nativeAuthProfile === true ? "openai" : void 0,
353
+ model: params.model ?? params.bindingModel
354
+ };
355
+ }
356
+ function resolveCodexComputerUseConfig(params = {}) {
357
+ const env = params.env ?? process.env;
358
+ const config = readCodexPluginConfig(params.pluginConfig).computerUse ?? {};
359
+ const marketplaceSource = readNonEmptyString(params.overrides?.marketplaceSource) ?? readNonEmptyString(config.marketplaceSource) ?? readNonEmptyString(env.OPENCLAW_CODEX_COMPUTER_USE_MARKETPLACE_SOURCE);
360
+ const marketplacePath = readNonEmptyString(params.overrides?.marketplacePath) ?? readNonEmptyString(config.marketplacePath) ?? readNonEmptyString(env.OPENCLAW_CODEX_COMPUTER_USE_MARKETPLACE_PATH);
361
+ const marketplaceName = readNonEmptyString(params.overrides?.marketplaceName) ?? readNonEmptyString(config.marketplaceName) ?? readNonEmptyString(env.OPENCLAW_CODEX_COMPUTER_USE_MARKETPLACE_NAME);
362
+ const autoInstall = params.overrides?.autoInstall ?? config.autoInstall ?? readBooleanEnv(env.OPENCLAW_CODEX_COMPUTER_USE_AUTO_INSTALL) ?? false;
363
+ const marketplaceDiscoveryTimeoutMs = normalizePositiveNumber(params.overrides?.marketplaceDiscoveryTimeoutMs ?? config.marketplaceDiscoveryTimeoutMs ?? readNumberEnv(env.OPENCLAW_CODEX_COMPUTER_USE_MARKETPLACE_DISCOVERY_TIMEOUT_MS), DEFAULT_CODEX_COMPUTER_USE_MARKETPLACE_DISCOVERY_TIMEOUT_MS);
364
+ return {
365
+ enabled: params.overrides?.enabled ?? config.enabled ?? readBooleanEnv(env.OPENCLAW_CODEX_COMPUTER_USE) ?? Boolean(autoInstall || marketplaceSource || marketplacePath || marketplaceName),
366
+ autoInstall,
367
+ marketplaceDiscoveryTimeoutMs,
368
+ pluginName: readNonEmptyString(params.overrides?.pluginName) ?? readNonEmptyString(config.pluginName) ?? readNonEmptyString(env.OPENCLAW_CODEX_COMPUTER_USE_PLUGIN_NAME) ?? DEFAULT_CODEX_COMPUTER_USE_PLUGIN_NAME,
369
+ mcpServerName: readNonEmptyString(params.overrides?.mcpServerName) ?? readNonEmptyString(config.mcpServerName) ?? readNonEmptyString(env.OPENCLAW_CODEX_COMPUTER_USE_MCP_SERVER_NAME) ?? DEFAULT_CODEX_COMPUTER_USE_MCP_SERVER_NAME,
370
+ ...marketplaceSource ? { marketplaceSource } : {},
371
+ ...marketplacePath ? { marketplacePath } : {},
372
+ ...marketplaceName ? { marketplaceName } : {}
373
+ };
374
+ }
375
+ function codexAppServerStartOptionsKey(options, params = {}) {
376
+ return JSON.stringify({
377
+ transport: options.transport,
378
+ command: options.command,
379
+ commandSource: options.commandSource ?? null,
380
+ managedFallbackCommandPaths: [...options.managedFallbackCommandPaths ?? []],
381
+ args: options.args,
382
+ url: options.url ?? null,
383
+ authToken: hashSecretForKey(options.authToken, "authToken"),
384
+ headers: Object.entries(options.headers).toSorted(([left], [right]) => left.localeCompare(right)).map(([key, value]) => [key, hashSecretForKey(value, `header:${key}`)]),
385
+ env: Object.entries(options.env ?? {}).toSorted(([left], [right]) => left.localeCompare(right)).map(([key, value]) => [key, hashSecretForKey(value, `env:${key}`)]),
386
+ clearEnv: [...options.clearEnv ?? []].toSorted(),
387
+ authProfileId: params.authProfileId ?? null,
388
+ agentDir: params.agentDir ?? null,
389
+ fallbackApiKeyCacheKey: params.fallbackApiKeyCacheKey ?? null
390
+ });
391
+ }
392
+ function codexSandboxPolicyForTurn(mode, cwd) {
393
+ if (mode === "danger-full-access") return { type: "dangerFullAccess" };
394
+ if (mode === "read-only") return {
395
+ type: "readOnly",
396
+ networkAccess: false
397
+ };
398
+ return {
399
+ type: "workspaceWrite",
400
+ writableRoots: [cwd],
401
+ networkAccess: false,
402
+ excludeTmpdirEnvVar: false,
403
+ excludeSlashTmp: false
404
+ };
405
+ }
406
+ function resolveCodexAppServerNetworkProxy(config, sandbox) {
407
+ if (config?.enabled !== true) return {};
408
+ const fileSystemMode = config.baseProfile === "read-only" || !config.baseProfile && sandbox === "read-only" ? "read" : "write";
409
+ const networkConfig = removeUndefinedJsonFields({
410
+ enabled: true,
411
+ mode: config.mode,
412
+ domains: normalizeNetworkProxyPermissionMap(config.domains),
413
+ unix_sockets: normalizeNetworkProxyPermissionMap(config.unixSockets),
414
+ proxy_url: readNonEmptyString(config.proxyUrl),
415
+ socks_url: readNonEmptyString(config.socksUrl),
416
+ enable_socks5: config.enableSocks5,
417
+ enable_socks5_udp: config.enableSocks5Udp,
418
+ allow_upstream_proxy: config.allowUpstreamProxy,
419
+ allow_local_binding: config.allowLocalBinding,
420
+ dangerously_allow_non_loopback_proxy: config.dangerouslyAllowNonLoopbackProxy,
421
+ dangerously_allow_all_unix_sockets: config.dangerouslyAllowAllUnixSockets
422
+ });
423
+ const profile = {
424
+ filesystem: {
425
+ ":minimal": "read",
426
+ ":project_roots": { ".": fileSystemMode }
427
+ },
428
+ network: networkConfig
429
+ };
430
+ const profileName = resolveNetworkProxyPermissionProfileName(config, profile);
431
+ const configPatch = {
432
+ "features.network_proxy.enabled": true,
433
+ default_permissions: profileName,
434
+ permissions: { [profileName]: profile }
435
+ };
436
+ return { networkProxy: {
437
+ profileName,
438
+ configFingerprint: fingerprintCodexAppServerNetworkProxyConfigPatch(configPatch),
439
+ configPatch
440
+ } };
441
+ }
442
+ function resolveNetworkProxyPermissionProfileName(config, profile) {
443
+ const explicitProfileName = readNonEmptyString(config.profileName);
444
+ if (explicitProfileName) return explicitProfileName;
445
+ const suffix = createHash("sha256").update(stableStringifyJson({
446
+ version: 1,
447
+ profile
448
+ })).digest("hex").slice(0, 16);
449
+ return `${DEFAULT_CODEX_APP_SERVER_NETWORK_PROXY_PROFILE_PREFIX}-${suffix}`;
450
+ }
451
+ function fingerprintCodexAppServerNetworkProxyConfigPatch(configPatch) {
452
+ return createHash("sha256").update(stableStringifyJson(configPatch)).digest("hex");
453
+ }
454
+ function normalizeNetworkProxyPermissionMap(value) {
455
+ const entries = Object.entries(value ?? {}).map(([key, permission]) => [key.trim(), permission]).filter(([key]) => key.length > 0);
456
+ return entries.length > 0 ? Object.fromEntries(entries) : void 0;
457
+ }
458
+ function removeUndefinedJsonFields(value) {
459
+ return Object.fromEntries(Object.entries(value).filter((entry) => entry[1] !== void 0));
460
+ }
461
+ function stableStringifyJson(value) {
462
+ if (Array.isArray(value)) return `[${value.map((item) => stableStringifyJson(item)).join(",")}]`;
463
+ if (value && typeof value === "object") return `{${Object.entries(value).toSorted(([left], [right]) => left.localeCompare(right)).map(([key, item]) => `${JSON.stringify(key)}:${stableStringifyJson(item)}`).join(",")}}`;
464
+ return JSON.stringify(value);
465
+ }
466
+ function withMcpElicitationsApprovalPolicy(policy) {
467
+ if (typeof policy !== "string") return { granular: {
468
+ ...policy.granular,
469
+ mcp_elicitations: true
470
+ } };
471
+ if (policy === "never") return { granular: {
472
+ mcp_elicitations: true,
473
+ rules: false,
474
+ sandbox_approval: false,
475
+ request_permissions: false,
476
+ skill_approval: false
477
+ } };
478
+ return { granular: {
479
+ mcp_elicitations: true,
480
+ rules: true,
481
+ sandbox_approval: true,
482
+ request_permissions: true,
483
+ skill_approval: true
484
+ } };
485
+ }
486
+ function resolveTransport(value) {
487
+ return value === "websocket" ? "websocket" : "stdio";
488
+ }
489
+ function normalizeRemoteWorkspaceRoot(value) {
490
+ return readNonEmptyString(value);
491
+ }
492
+ function inferCodexAppServerConnectionClass(params) {
493
+ if (params.transport !== "websocket") return "local-loopback";
494
+ return params.url && isLoopbackWebSocketUrl(params.url) ? "local-loopback" : "remote";
495
+ }
496
+ function assertCodexAppServerConnectionClassConfig(params) {
497
+ if (params.connectionClass === "remote" && !hasIdentityBearingWebSocketAuth({
498
+ authToken: params.authToken,
499
+ headers: params.headers
500
+ })) throw new Error("remote Codex app-server WebSocket URLs require appServer.authToken or an Authorization header");
501
+ }
502
+ function isLoopbackWebSocketUrl(value) {
503
+ let parsed;
504
+ try {
505
+ parsed = new URL(value);
506
+ } catch {
507
+ return false;
508
+ }
509
+ if (parsed.protocol !== "ws:" && parsed.protocol !== "wss:") return false;
510
+ const host = parsed.hostname.toLowerCase();
511
+ return host === "localhost" || host === "127.0.0.1" || host === "::1" || host === "[::1]" || host.startsWith("127.");
512
+ }
513
+ function hasIdentityBearingWebSocketAuth(params) {
514
+ if (readNonEmptyString(params.authToken)) return true;
515
+ return Object.entries(params.headers).some(([key, value]) => key.trim().toLowerCase() === "authorization" && Boolean(readNonEmptyString(value)));
516
+ }
517
+ function resolvePolicyMode(value) {
518
+ return value === "guardian" || value === "yolo" ? value : void 0;
519
+ }
520
+ function resolveDefaultCodexAppServerPolicy(params) {
521
+ if (params.transport !== "stdio") return {
522
+ mode: "yolo",
523
+ dangerFullAccessAllowed: true
524
+ };
525
+ const content = readCodexRequirementsToml(params);
526
+ if (content === void 0) {
527
+ if (!params.forceGuardian) return {
528
+ mode: "yolo",
529
+ dangerFullAccessAllowed: true
530
+ };
531
+ return {
532
+ mode: "guardian",
533
+ dangerFullAccessAllowed: true,
534
+ approvalPolicy: selectGuardianApprovalPolicy(void 0, params.execModeRequiringPromptingApprovals),
535
+ approvalsReviewer: params.forceUserReviewer ? selectUserApprovalsReviewer(void 0, params.execModeRequiringUserReviewer) : selectGuardianApprovalsReviewer(void 0, params.execModeRequiringPromptingApprovals === "auto" ? "auto" : void 0),
536
+ sandbox: selectGuardianSandbox(void 0)
537
+ };
538
+ }
539
+ const allowedSandboxModes = parseAllowedSandboxModesFromCodexRequirements(content, readNonEmptyString(params.hostName) ?? hostname());
540
+ const allowedApprovalPolicies = parseAllowedApprovalPoliciesFromCodexRequirements(content);
541
+ const allowedApprovalsReviewers = parseAllowedApprovalsReviewersFromCodexRequirements(content);
542
+ const yoloSandboxAllowed = allowedSandboxModes === void 0 || allowedSandboxModes.has("danger-full-access");
543
+ const yoloApprovalAllowed = allowedApprovalPolicies === void 0 || allowedApprovalPolicies.has("never");
544
+ const yoloReviewerAllowed = allowedApprovalsReviewers === void 0 || allowedApprovalsReviewers.has("user");
545
+ if (!params.forceGuardian && yoloSandboxAllowed && yoloApprovalAllowed && yoloReviewerAllowed) return {
546
+ mode: "yolo",
547
+ dangerFullAccessAllowed: true
548
+ };
549
+ return {
550
+ mode: "guardian",
551
+ dangerFullAccessAllowed: yoloSandboxAllowed,
552
+ approvalPolicy: selectGuardianApprovalPolicy(allowedApprovalPolicies, params.execModeRequiringPromptingApprovals),
553
+ approvalsReviewer: params.forceUserReviewer ? selectUserApprovalsReviewer(allowedApprovalsReviewers, params.execModeRequiringUserReviewer) : selectGuardianApprovalsReviewer(allowedApprovalsReviewers, params.execModeRequiringPromptingApprovals === "auto" ? "auto" : void 0),
554
+ sandbox: selectGuardianSandbox(allowedSandboxModes)
555
+ };
556
+ }
557
+ function readCodexRequirementsToml(params) {
558
+ if (params.requirementsToml !== void 0) return params.requirementsToml ?? void 0;
559
+ const requirementsPath = readNonEmptyString(params.requirementsPath) ?? resolveCodexRequirementsPath(params.env ?? process.env, params.platform ?? process.platform);
560
+ try {
561
+ if (params.readRequirementsFile) return params.readRequirementsFile(requirementsPath);
562
+ return readFileSync(requirementsPath, "utf8");
563
+ } catch {
564
+ return;
565
+ }
566
+ }
567
+ function resolveCodexRequirementsPath(env, platform) {
568
+ if (platform === "win32") return `${(readNonEmptyString(env.ProgramData) ?? "C:\\ProgramData").replace(/[\\/]+$/, "")}${WINDOWS_CODEX_REQUIREMENTS_SUFFIX}`;
569
+ return UNIX_CODEX_REQUIREMENTS_PATH;
570
+ }
571
+ function parseAllowedSandboxModesFromCodexRequirements(content, hostName) {
572
+ const remoteSandboxModes = parseMatchingRemoteSandboxModesFromCodexRequirements(content, hostName);
573
+ if (remoteSandboxModes !== void 0) return remoteSandboxModes;
574
+ return parseRequirementsSandboxModes(parseTopLevelRequirementsStringArray(content, "allowed_sandbox_modes"));
575
+ }
576
+ function parseAllowedApprovalPoliciesFromCodexRequirements(content) {
577
+ const values = parseTopLevelRequirementsStringArray(content, "allowed_approval_policies");
578
+ if (values === void 0) return;
579
+ const normalizedPolicies = values.map((entry) => normalizeRequirementsApprovalPolicy(entry)).filter((entry) => entry !== void 0);
580
+ return normalizedPolicies.length > 0 ? new Set(normalizedPolicies) : void 0;
581
+ }
582
+ function parseAllowedApprovalsReviewersFromCodexRequirements(content) {
583
+ const values = parseTopLevelRequirementsStringArray(content, "allowed_approvals_reviewers");
584
+ if (values === void 0) return;
585
+ const normalizedReviewers = values.map((entry) => normalizeRequirementsApprovalsReviewer(entry)).filter((entry) => entry !== void 0);
586
+ return normalizedReviewers.length > 0 ? new Set(normalizedReviewers) : void 0;
587
+ }
588
+ function parseMatchingRemoteSandboxModesFromCodexRequirements(content, hostName) {
589
+ const normalizedHostName = normalizeRequirementsHostName(hostName);
590
+ if (normalizedHostName === void 0) return;
591
+ for (const section of parseTomlArrayTableSections(content, "remote_sandbox_config")) {
592
+ const patterns = parseRequirementsStringArray(section, "hostname_patterns");
593
+ if (!patterns || !requirementsHostNameMatchesAnyPattern(normalizedHostName, patterns)) continue;
594
+ return parseRequirementsSandboxModes(parseRequirementsStringArray(section, "allowed_sandbox_modes"));
595
+ }
596
+ }
597
+ function parseRequirementsSandboxModes(values) {
598
+ if (values === void 0) return;
599
+ const normalizedModes = values.map((entry) => normalizeRequirementsSandboxMode(entry)).filter((entry) => entry !== void 0);
600
+ return normalizedModes.length > 0 ? new Set(normalizedModes) : void 0;
601
+ }
602
+ function parseTopLevelRequirementsStringArray(content, key) {
603
+ return parseRequirementsStringArray(stripTomlLineComments(content).slice(0, firstTomlTableOffset(content)), key);
604
+ }
605
+ function parseTomlStringValue(content, key) {
606
+ const match = parseTomlStringAssignment(content, tomlDottedKeyPattern(key));
607
+ return match ? match[1] ?? match[2] ?? "" : void 0;
608
+ }
609
+ function parseInlineOpenAIModelProviderBaseUrl(content) {
610
+ const match = parseTomlStringAssignment(content, `${tomlKeyPattern("model_providers")}\\s*=\\s*\\{[\\s\\S]*?${tomlKeyPattern("openai")}\\s*=\\s*\\{[\\s\\S]*?${tomlKeyPattern("base_url")}`);
611
+ return match ? match[1] ?? match[2] ?? "" : void 0;
612
+ }
613
+ function parseTomlStringAssignment(content, keyPattern) {
614
+ return content.match(new RegExp(`(?:^|\\n)\\s*${keyPattern}\\s*=\\s*(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|'([^']*)')`));
615
+ }
616
+ function tomlDottedKeyPattern(key) {
617
+ return key.split(".").map(tomlKeyPattern).join("\\s*\\.\\s*");
618
+ }
619
+ function tomlKeyPattern(key) {
620
+ const escaped = key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
621
+ return `(?:"${escaped}"|'${escaped}'|${escaped})`;
622
+ }
623
+ function parseRequirementsStringArray(content, key) {
624
+ const match = content.match(new RegExp(`(?:^|\\n)\\s*${key}\\s*=\\s*\\[([\\s\\S]*?)\\]`));
625
+ if (!match) return;
626
+ const arrayBody = match[1] ?? "";
627
+ const stringMatches = [...arrayBody.matchAll(/"([^"\\]*(?:\\.[^"\\]*)*)"|'([^']*)'/g)];
628
+ if (stringMatches.length === 0 && arrayBody.trim().length > 0) return;
629
+ return stringMatches.map((entry) => entry[1] ?? entry[2] ?? "");
630
+ }
631
+ function parseTomlTableSection(content, table) {
632
+ const strippedContent = stripTomlLineComments(content);
633
+ const tablePattern = tomlDottedKeyPattern(table);
634
+ const match = new RegExp(`^\\s*\\[\\s*${tablePattern}\\s*\\]\\s*$`, "m").exec(strippedContent);
635
+ if (!match) return;
636
+ const sectionStart = match.index + match[0].length;
637
+ const rest = strippedContent.slice(sectionStart);
638
+ const nextTableOffset = rest.search(/^\s*\[/m);
639
+ return nextTableOffset === -1 ? rest : rest.slice(0, nextTableOffset);
640
+ }
641
+ function parseTomlArrayTableSections(content, table) {
642
+ const strippedContent = stripTomlLineComments(content);
643
+ const escapedTable = table.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
644
+ const headerPattern = new RegExp(`^\\s*\\[\\[\\s*${escapedTable}\\s*\\]\\]\\s*$`, "gm");
645
+ const sections = [];
646
+ for (let match = headerPattern.exec(strippedContent); match; match = headerPattern.exec(strippedContent)) {
647
+ const sectionStart = headerPattern.lastIndex;
648
+ const rest = strippedContent.slice(sectionStart);
649
+ const nextTableOffset = rest.search(/^\s*\[/m);
650
+ sections.push(nextTableOffset === -1 ? rest : rest.slice(0, nextTableOffset));
651
+ }
652
+ return sections;
653
+ }
654
+ function firstTomlTableOffset(content) {
655
+ return content.match(/^\s*\[[^\]\n]/m)?.index ?? content.length;
656
+ }
657
+ function stripTomlLineComments(value) {
658
+ let output = "";
659
+ let quote;
660
+ let escaped = false;
661
+ for (let index = 0; index < value.length; index += 1) {
662
+ const char = value[index] ?? "";
663
+ if (quote) {
664
+ output += char;
665
+ if (quote === "\"" && escaped) {
666
+ escaped = false;
667
+ continue;
668
+ }
669
+ if (quote === "\"" && char === "\\") {
670
+ escaped = true;
671
+ continue;
672
+ }
673
+ if (char === quote) quote = void 0;
674
+ continue;
675
+ }
676
+ if (char === "\"" || char === "'") {
677
+ quote = char;
678
+ output += char;
679
+ continue;
680
+ }
681
+ if (char === "#") {
682
+ while (index < value.length && value[index] !== "\n") index += 1;
683
+ if (value[index] === "\n") output += "\n";
684
+ continue;
685
+ }
686
+ output += char;
687
+ }
688
+ return output;
689
+ }
690
+ function normalizeRequirementsSandboxMode(value) {
691
+ const compact = value.replace(/[\s_-]/g, "").toLowerCase();
692
+ if (compact === "readonly") return "read-only";
693
+ if (compact === "workspacewrite") return "workspace-write";
694
+ if (compact === "dangerfullaccess") return "danger-full-access";
695
+ }
696
+ function normalizeRequirementsHostName(value) {
697
+ const normalized = value.trim().replace(/\.+$/g, "").toLowerCase();
698
+ return normalized.length > 0 ? normalized : void 0;
699
+ }
700
+ function requirementsHostNameMatchesAnyPattern(hostName, patterns) {
701
+ return patterns.some((pattern) => {
702
+ const normalizedPattern = normalizeRequirementsHostName(pattern);
703
+ return normalizedPattern !== void 0 && globPatternMatches(hostName, normalizedPattern);
704
+ });
705
+ }
706
+ function globPatternMatches(value, pattern) {
707
+ let regex = "^";
708
+ for (const char of pattern) if (char === "*") regex += ".*";
709
+ else if (char === "?") regex += ".";
710
+ else regex += char.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
711
+ regex += "$";
712
+ return new RegExp(regex).test(value);
713
+ }
714
+ function normalizeRequirementsApprovalPolicy(value) {
715
+ const normalized = value.trim().toLowerCase();
716
+ if (normalized === "on-failure") return "on-request";
717
+ return resolveApprovalPolicy(normalized);
718
+ }
719
+ function normalizeRequirementsApprovalsReviewer(value) {
720
+ return resolveApprovalsReviewer(value.trim().toLowerCase());
721
+ }
722
+ function selectGuardianApprovalPolicy(allowedApprovalPolicies, execModeRequiringPromptingApprovals) {
723
+ if (allowedApprovalPolicies === void 0 || allowedApprovalPolicies.has("on-request")) return "on-request";
724
+ if (execModeRequiringPromptingApprovals) throw new Error(`tools.exec.mode=${execModeRequiringPromptingApprovals} requires Codex app-server prompting approvals`);
725
+ if (allowedApprovalPolicies.has("untrusted")) return "untrusted";
726
+ if (allowedApprovalPolicies.has("never")) return "never";
727
+ return "on-request";
728
+ }
729
+ function selectGuardianApprovalsReviewer(allowedApprovalsReviewers, execModeRequiringAutoReviewer) {
730
+ if (allowedApprovalsReviewers === void 0 || allowedApprovalsReviewers.has("auto_review")) return "auto_review";
731
+ if (allowedApprovalsReviewers.has("guardian_subagent")) return "guardian_subagent";
732
+ if (execModeRequiringAutoReviewer) throw new Error(`tools.exec.mode=${execModeRequiringAutoReviewer} requires Codex app-server auto approvals`);
733
+ if (allowedApprovalsReviewers.has("user")) return "user";
734
+ return "auto_review";
735
+ }
736
+ function selectUserApprovalsReviewer(allowedApprovalsReviewers, execModeRequiringUserReviewer) {
737
+ if (allowedApprovalsReviewers === void 0 || allowedApprovalsReviewers.has("user")) return "user";
738
+ throw new Error(`tools.exec.mode=${execModeRequiringUserReviewer ?? "ask"} requires Codex app-server user approvals`);
739
+ }
740
+ function isCodexModelBackedApprovalsReviewerProvider(provider) {
741
+ return provider?.trim().toLowerCase() === "openai";
742
+ }
743
+ function isTrustedCodexModelBackedApprovalsReviewerProvider(provider, params) {
744
+ return isCodexModelBackedApprovalsReviewerProvider(provider) && isTrustedCodexModelBackedOpenAIProvider({
745
+ config: params.config,
746
+ env: params.env,
747
+ model: params.model,
748
+ agentDir: params.agentDir,
749
+ codexConfigToml: params.codexConfigToml,
750
+ homeScope: params.homeScope
751
+ });
752
+ }
753
+ function readCodexBaseUrlOverridesForModelBackedReview(params) {
754
+ const configToml = readCodexAppServerConfigToml(params);
755
+ if (configToml === false) return false;
756
+ if (configToml === void 0) return {
757
+ openAI: [],
758
+ chatGPT: []
759
+ };
760
+ const topLevelContent = stripTomlLineComments(configToml).slice(0, firstTomlTableOffset(configToml));
761
+ const modelProviderOpenAISection = parseTomlTableSection(configToml, "model_providers.openai");
762
+ return {
763
+ openAI: [
764
+ parseTomlStringValue(topLevelContent, "openai_base_url"),
765
+ parseTomlStringValue(topLevelContent, "model_providers.openai.base_url"),
766
+ parseInlineOpenAIModelProviderBaseUrl(topLevelContent),
767
+ modelProviderOpenAISection ? parseTomlStringValue(modelProviderOpenAISection, "base_url") : void 0
768
+ ].filter((entry) => entry !== void 0),
769
+ chatGPT: [parseTomlStringValue(topLevelContent, "chatgpt_base_url")].filter((entry) => entry !== void 0)
770
+ };
771
+ }
772
+ function readCodexAppServerConfigToml(params) {
773
+ if (params.codexConfigToml !== void 0) return params.codexConfigToml ?? void 0;
774
+ const configPath = resolveCodexAppServerConfigPath(params);
775
+ if (!configPath) return;
776
+ try {
777
+ return readFileSync(configPath, "utf8");
778
+ } catch (error) {
779
+ return readErrorCode(error) === "ENOENT" ? void 0 : false;
780
+ }
781
+ }
782
+ function resolveCodexAppServerConfigPath(params) {
783
+ if (params.homeScope === "user") return path.join(resolveCodexAppServerUserHomeDir(params.env), CODEX_CONFIG_TOML_FILENAME);
784
+ const agentDir = readNonEmptyString(params.agentDir);
785
+ const codexHome = agentDir ? path.join(path.resolve(agentDir), CODEX_APP_SERVER_HOME_DIRNAME) : void 0;
786
+ return codexHome ? path.join(codexHome, CODEX_CONFIG_TOML_FILENAME) : void 0;
787
+ }
788
+ /** Resolves the native user Codex home used by Desktop and the CLI. */
789
+ function resolveCodexAppServerUserHomeDir(env = process.env, homedir$1 = homedir) {
790
+ const configured = readNonEmptyString(env.CODEX_HOME);
791
+ return path.resolve(configured ?? path.join(homedir$1(), ".codex"));
792
+ }
793
+ function readErrorCode(error) {
794
+ return error && typeof error === "object" && "code" in error ? String(error.code) : void 0;
795
+ }
796
+ function readConfiguredOpenAIProvidersForModelBackedReview(config) {
797
+ const providerRecords = readRecord(readRecord(readRecord(config)?.models)?.providers);
798
+ if (!providerRecords) return [];
799
+ const openAIProviders = [];
800
+ for (const [providerId, providerConfig] of Object.entries(providerRecords)) {
801
+ if (resolveProviderIdForAuth(providerId, { config }) !== "openai") continue;
802
+ const record = readRecord(providerConfig);
803
+ if (record) openAIProviders.push(record);
804
+ }
805
+ return openAIProviders;
806
+ }
807
+ function configuredOpenAIProviderIsTrustedForModelBackedReview(openAIProvider, modelInput) {
808
+ if (readRecord(openAIProvider.localService) || hasNonEmptyRecord(openAIProvider.headers) || hasNonEmptyRecord(openAIProvider.request) || typeof openAIProvider.authHeader === "boolean" || !isNativeOpenAIBaseUrl(openAIProvider.baseUrl)) return false;
809
+ const models = openAIProvider.models;
810
+ if (!Array.isArray(models)) return true;
811
+ const modelId = normalizeOpenAIModelBackedReviewerModelId(modelInput);
812
+ if (!modelId) return false;
813
+ for (const entry of models) {
814
+ const model = readRecord(entry);
815
+ if (typeof model?.id !== "string" || !matchesConfiguredOpenAIModelId(modelId, model.id)) continue;
816
+ if (hasNonEmptyRecord(model.headers) || hasNonEmptyRecord(model.request) || !isNativeOpenAIBaseUrl(model.baseUrl)) return false;
817
+ }
818
+ return true;
819
+ }
820
+ function normalizeOpenAIModelBackedReviewerModelId(modelInput) {
821
+ const normalized = modelInput?.trim() ?? "";
822
+ const authProfileIndex = normalized.indexOf("@");
823
+ const withoutAuthProfile = authProfileIndex > 0 ? normalized.slice(0, authProfileIndex) : normalized;
824
+ const slashIndex = withoutAuthProfile.indexOf("/");
825
+ return slashIndex > 0 ? withoutAuthProfile.slice(slashIndex + 1).trim() : withoutAuthProfile;
826
+ }
827
+ function matchesConfiguredOpenAIModelId(modelId, configuredModelId) {
828
+ const configured = normalizeOpenAIModelBackedReviewerModelId(configuredModelId);
829
+ return Boolean(configured) && (modelId === configured || modelId.startsWith(`${configured}@`));
830
+ }
831
+ function hasNonEmptyRecord(value) {
832
+ const record = readRecord(value);
833
+ return record !== void 0 && Object.keys(record).length > 0;
834
+ }
835
+ function isNativeOpenAIBaseUrl(value) {
836
+ if (typeof value !== "string" || !value.trim()) return true;
837
+ try {
838
+ const url = new URL(value);
839
+ return url.protocol === "https:" && url.hostname.toLowerCase() === "api.openai.com";
840
+ } catch {
841
+ return false;
842
+ }
843
+ }
844
+ function openAIBaseUrlEnvOverridesAreTrustedForModelBackedReview(env) {
845
+ return [env?.OPENAI_BASE_URL, env?.OPENAI_API_BASE].every(isNativeOpenAIBaseUrl);
846
+ }
847
+ function isNativeChatGPTBaseUrl(value) {
848
+ if (typeof value !== "string" || !value.trim()) return true;
849
+ try {
850
+ const url = new URL(value);
851
+ return url.protocol === "https:" && url.hostname.toLowerCase() === "chatgpt.com";
852
+ } catch {
853
+ return false;
854
+ }
855
+ }
856
+ function normalizeCodexModelBackedReviewerPolicyProvider(provider) {
857
+ return provider.toLowerCase() === "openai" ? "openai" : provider;
858
+ }
859
+ function inferProviderFromModelRef(model) {
860
+ const normalized = model?.trim().toLowerCase();
861
+ const slashIndex = normalized?.indexOf("/") ?? -1;
862
+ return slashIndex > 0 ? normalized?.slice(0, slashIndex) : void 0;
863
+ }
864
+ function selectForcedPromptingSandbox(params) {
865
+ if (params.configuredSandbox === "read-only" || params.defaultSandbox === "read-only") return "read-only";
866
+ return params.defaultSandbox ?? "workspace-write";
867
+ }
868
+ function selectForcedDangerFullAccessSandbox(params) {
869
+ if (params.configuredSandbox === "read-only") return "read-only";
870
+ if (params.defaultPolicy?.dangerFullAccessAllowed === false) {
871
+ if (params.openClawSandboxActive) return params.defaultPolicy.sandbox ?? "workspace-write";
872
+ throw new Error("legacy full exec security with ask requires Codex app-server danger-full-access");
873
+ }
874
+ return "danger-full-access";
875
+ }
876
+ function selectGuardianSandbox(allowedSandboxModes) {
877
+ if (allowedSandboxModes === void 0 || allowedSandboxModes.has("workspace-write")) return "workspace-write";
878
+ if (allowedSandboxModes.has("read-only")) return "read-only";
879
+ if (allowedSandboxModes.has("danger-full-access")) return "danger-full-access";
880
+ return "workspace-write";
881
+ }
882
+ function resolveApprovalPolicy(value) {
883
+ if (value === "on-failure") return "on-request";
884
+ return value === "on-request" || value === "untrusted" || value === "never" ? value : void 0;
885
+ }
886
+ function resolveSandbox(value) {
887
+ return value === "read-only" || value === "workspace-write" || value === "danger-full-access" ? value : void 0;
888
+ }
889
+ function resolveApprovalsReviewer(value) {
890
+ return value === "auto_review" || value === "guardian_subagent" || value === "user" ? value : void 0;
891
+ }
892
+ function resolveOpenClawExecPolicyFromConfig(params) {
893
+ const root = readRecord(params.config);
894
+ const globalExec = readRecord(readRecord(root?.tools)?.exec);
895
+ const globalPolicy = applyOpenClawExecPolicyLayer(createDefaultOpenClawExecPolicy(), globalExec);
896
+ const agentId = params.agentId?.trim();
897
+ if (!agentId) return globalPolicy;
898
+ const agents = readRecord(root?.agents);
899
+ const agentList = Array.isArray(agents?.list) ? agents.list : [];
900
+ const normalizedAgentId = normalizeAgentId(agentId);
901
+ return applyOpenClawExecPolicyLayer(globalPolicy, readRecord(readRecord(readRecord(agentList.find((entry) => {
902
+ const id = readRecord(entry)?.id;
903
+ return typeof id === "string" && normalizeAgentId(id) === normalizedAgentId;
904
+ }))?.tools)?.exec));
905
+ }
906
+ function resolveOpenClawExecPolicyForCodexAppServer(params) {
907
+ const overridePolicy = applyOpenClawExecPolicyLayer(resolveOpenClawExecPolicyFromConfig({
908
+ config: params.config,
909
+ agentId: params.agentId
910
+ }), params.execOverrides);
911
+ return applyOpenClawExecApprovalFloors(overridePolicy, resolveOpenClawExecApprovalFloorsForCodexAppServer({
912
+ approvals: params.approvals,
913
+ agentId: params.agentId,
914
+ policy: overridePolicy
915
+ }));
916
+ }
917
+ function resolveEffectiveOpenClawExecModeForCodexAppServer(params) {
918
+ if (params.execPolicy?.touched === true) return params.execPolicy.mode;
919
+ return params.execMode;
920
+ }
921
+ function resolveCodexPolicyModeForOpenClawExecMode(mode) {
922
+ if (!mode || mode === "full") return;
923
+ return "guardian";
924
+ }
925
+ function assertCodexAppServerAllowedForOpenClawExecMode(mode) {
926
+ if (mode === "deny" || mode === "allowlist") throw new Error(`Codex app-server local execution is not available when tools.exec.mode=${mode}`);
927
+ }
928
+ function createDefaultOpenClawExecPolicy() {
929
+ return {
930
+ security: "full",
931
+ ask: "off",
932
+ touched: false
933
+ };
934
+ }
935
+ function applyOpenClawExecPolicyLayer(base, exec) {
936
+ if (!exec) return base;
937
+ const mode = readExecMode(exec.mode);
938
+ if (mode !== void 0) return {
939
+ ...resolveOpenClawExecPolicyForMode(mode),
940
+ touched: true
941
+ };
942
+ const security = readExecSecurity(exec.security);
943
+ const ask = readExecAsk(exec.ask);
944
+ if (security === void 0 && ask === void 0) return base;
945
+ const nextSecurity = security ?? base.security;
946
+ const nextAsk = ask ?? base.ask;
947
+ return {
948
+ mode: resolveOpenClawExecModeFromPolicy({
949
+ security: nextSecurity,
950
+ ask: nextAsk
951
+ }),
952
+ security: nextSecurity,
953
+ ask: nextAsk,
954
+ touched: true
955
+ };
956
+ }
957
+ function resolveOpenClawExecApprovalFloorsForCodexAppServer(params) {
958
+ if (!params.approvals) return;
959
+ return resolveExecApprovalsFromFile({
960
+ file: params.approvals,
961
+ agentId: params.agentId,
962
+ overrides: {
963
+ security: params.policy.security,
964
+ ask: params.policy.ask
965
+ }
966
+ }).agent;
967
+ }
968
+ function applyOpenClawExecApprovalFloors(base, approvalFloors) {
969
+ if (!approvalFloors) return base;
970
+ const nextSecurity = approvalFloors.security ? minOpenClawExecSecurity(base.security, approvalFloors.security) : base.security;
971
+ const nextAsk = approvalFloors.ask ? maxOpenClawExecAsk(base.ask, approvalFloors.ask) : base.ask;
972
+ if (nextSecurity === base.security && nextAsk === base.ask) return base;
973
+ return {
974
+ mode: resolveOpenClawExecModeFromPolicy({
975
+ security: nextSecurity,
976
+ ask: nextAsk
977
+ }),
978
+ security: nextSecurity,
979
+ ask: nextAsk,
980
+ touched: true
981
+ };
982
+ }
983
+ function resolveOpenClawExecPolicyForMode(mode) {
984
+ switch (mode) {
985
+ case "deny": return {
986
+ mode,
987
+ security: "deny",
988
+ ask: "off"
989
+ };
990
+ case "allowlist": return {
991
+ mode,
992
+ security: "allowlist",
993
+ ask: "off"
994
+ };
995
+ case "ask":
996
+ case "auto": return {
997
+ mode,
998
+ security: "allowlist",
999
+ ask: "on-miss"
1000
+ };
1001
+ case "full": return {
1002
+ mode,
1003
+ security: "full",
1004
+ ask: "off"
1005
+ };
1006
+ }
1007
+ return mode;
1008
+ }
1009
+ function resolveOpenClawExecModeFromPolicy(params) {
1010
+ if (params.security === "deny") return "deny";
1011
+ if (params.security === "allowlist" && params.ask === "off") return "allowlist";
1012
+ if (params.security === "full" && params.ask !== "always") return "full";
1013
+ return "ask";
1014
+ }
1015
+ function minOpenClawExecSecurity(left, right) {
1016
+ const order = {
1017
+ deny: 0,
1018
+ allowlist: 1,
1019
+ full: 2
1020
+ };
1021
+ return order[left] <= order[right] ? left : right;
1022
+ }
1023
+ function maxOpenClawExecAsk(left, right) {
1024
+ const order = {
1025
+ off: 0,
1026
+ "on-miss": 1,
1027
+ always: 2
1028
+ };
1029
+ return order[left] >= order[right] ? left : right;
1030
+ }
1031
+ function readExecMode(value) {
1032
+ return value === "deny" || value === "allowlist" || value === "ask" || value === "auto" || value === "full" ? value : void 0;
1033
+ }
1034
+ function readRecord(value) {
1035
+ return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
1036
+ }
1037
+ function normalizeCodexServiceTier(value) {
1038
+ if (typeof value !== "string") return;
1039
+ const trimmed = value.trim();
1040
+ if (!trimmed) return;
1041
+ const normalized = trimmed.toLowerCase();
1042
+ if (normalized === "fast" || normalized === "priority") return "priority";
1043
+ if (normalized === "flex") return "flex";
1044
+ return trimmed;
1045
+ }
1046
+ function isCodexFastServiceTier(value) {
1047
+ return normalizeCodexServiceTier(value) === "priority";
1048
+ }
1049
+ function normalizePositiveNumber(value, fallback) {
1050
+ return resolvePositiveTimerTimeoutMs(value, fallback);
1051
+ }
1052
+ function normalizeHeaders(value) {
1053
+ if (!value || typeof value !== "object" || Array.isArray(value)) return {};
1054
+ return Object.fromEntries(Object.entries(value).map(([key, child]) => [key.trim(), normalizeCodexAppServerSecretInput({
1055
+ value: child,
1056
+ path: `plugins.entries.codex.config.appServer.headers.${key}`
1057
+ })]).filter((entry) => Boolean(entry[0] && entry[1])));
1058
+ }
1059
+ function normalizeCodexAppServerSecretInput(params) {
1060
+ return normalizeResolvedSecretInputString(params);
1061
+ }
1062
+ function normalizeStringList(value) {
1063
+ return normalizeTrimmedStringList(value);
1064
+ }
1065
+ function readBooleanEnv(value) {
1066
+ if (value === void 0) return;
1067
+ const normalized = value.trim().toLowerCase();
1068
+ if ([
1069
+ "1",
1070
+ "true",
1071
+ "yes",
1072
+ "on"
1073
+ ].includes(normalized)) return true;
1074
+ if ([
1075
+ "0",
1076
+ "false",
1077
+ "no",
1078
+ "off"
1079
+ ].includes(normalized)) return false;
1080
+ }
1081
+ function readExecSecurity(value) {
1082
+ return value === "deny" || value === "allowlist" || value === "full" ? value : void 0;
1083
+ }
1084
+ function readExecAsk(value) {
1085
+ return value === "off" || value === "on-miss" || value === "always" ? value : void 0;
1086
+ }
1087
+ function readNumberEnv(value) {
1088
+ const trimmed = value?.trim();
1089
+ if (!trimmed || !PLAIN_DECIMAL_NUMBER_RE.test(trimmed)) return;
1090
+ const parsed = Number(trimmed);
1091
+ return Number.isFinite(parsed) ? parsed : void 0;
1092
+ }
1093
+ function resolveArgs(configArgs, envArgs) {
1094
+ if (Array.isArray(configArgs)) return configArgs.map((entry) => readNonEmptyString(entry)).filter((entry) => entry !== void 0);
1095
+ if (typeof configArgs === "string") return splitShellWords(configArgs);
1096
+ return splitShellWords(envArgs ?? "");
1097
+ }
1098
+ function readNonEmptyString(value) {
1099
+ if (typeof value !== "string") return;
1100
+ return value.trim() || void 0;
1101
+ }
1102
+ function hashSecretForKey(value, label) {
1103
+ if (!value) return null;
1104
+ return createHmac("sha256", START_OPTIONS_KEY_SECRET).update(label).update("\0").update(value).digest("hex");
1105
+ }
1106
+ function getStartOptionsKeySecret() {
1107
+ const globalState = globalThis;
1108
+ globalState[START_OPTIONS_KEY_SECRET_SYMBOL] ??= randomBytes(32);
1109
+ return globalState[START_OPTIONS_KEY_SECRET_SYMBOL];
1110
+ }
1111
+ function splitShellWords(value) {
1112
+ const words = [];
1113
+ let current = "";
1114
+ let quote = null;
1115
+ for (const char of value) {
1116
+ if (quote) {
1117
+ if (char === quote) quote = null;
1118
+ else current += char;
1119
+ continue;
1120
+ }
1121
+ if (char === "\"" || char === "'") {
1122
+ quote = char;
1123
+ continue;
1124
+ }
1125
+ if (/\s/.test(char)) {
1126
+ if (current) {
1127
+ words.push(current);
1128
+ current = "";
1129
+ }
1130
+ continue;
1131
+ }
1132
+ current += char;
1133
+ }
1134
+ if (current) words.push(current);
1135
+ return words;
1136
+ }
1137
+ //#endregion
1138
+ export { shouldAutoApproveCodexAppServerApprovals as _, isCodexAppServerApprovalPolicyAllowedByRequirements as a, isTrustedCodexModelBackedOpenAIProvider as c, resolveCodexAppServerRuntimeOptions as d, resolveCodexAppServerUserHomeDir as f, resolveOpenClawExecPolicyForCodexAppServer as g, resolveCodexPluginsPolicy as h, codexSandboxPolicyForTurn as i, normalizeCodexServiceTier as l, resolveCodexModelBackedReviewerPolicyContext as m, canUseCodexModelBackedApprovalsReviewerForModel as n, isCodexFastServiceTier as o, resolveCodexComputerUseConfig as p, codexAppServerStartOptionsKey as r, isCodexSandboxExecServerEnabled as s, CODEX_PLUGINS_MARKETPLACE_NAME as t, readCodexPluginConfig as u, withMcpElicitationsApprovalPolicy as v };