@openclaw/codex 2026.9.1 → 2026.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/api.js +18 -23
- package/dist/apply-B6el6hdO.js +357 -0
- package/dist/{attempt-client-cleanup-DYHcRQAa.js → attempt-client-cleanup-D6cR54TV.js} +113 -49
- package/dist/{attempt-context-DmQUNWwT.js → attempt-context-AO4DSjE0.js} +11 -9
- package/dist/{event-projector-usage-C5mcrGjp.js → attempt-notifications--H8zXR5-.js} +3 -89
- package/dist/auth-cache-key-Kq6oerr6.js +498 -0
- package/dist/auth-profile-CwzO4_RG.js +43 -0
- package/dist/auth-profile-selection-DFu9e167.js +45 -0
- package/dist/{binding-connection-E6uDsPlx.js → binding-connection-QqgcPCgk.js} +18 -3
- package/dist/{bounded-turn-wzJrwKKe.js → bounded-turn-lRpmZHFv.js} +54 -150
- package/dist/build-state-6RL6qohz.js +19 -0
- package/dist/{capabilities-dIjNVCYH.js → capabilities-BeqLPbtM.js} +2 -1
- package/dist/cli-metadata.js +1 -1
- package/dist/client-BEKu4yDx.js +3983 -0
- package/dist/command-dispatch-CisT9Jqq.js +21 -0
- package/dist/{command-formatters-CLHhEB1Q.js → command-formatters-DeTfrapr.js} +2 -2
- package/dist/{command-handlers-CTGb2csu.js → command-handlers-BfIsJEuA.js} +158 -76
- package/dist/command-rpc-BMqRQOFX.js +226 -0
- package/dist/{compact-_t0HQrUS.js → compact-CGJZ2rlb.js} +89 -49
- package/dist/config-JDfTI4VI.js +106 -0
- package/dist/{config-BhmfC1s6.js → config-options-jnIFvwxD.js} +208 -654
- package/dist/config-runtime-BWf6JLWG.js +11 -0
- package/dist/config-utils-C57JiJrU.js +69 -0
- package/dist/conversation-binding-CxOlHiix.js +889 -0
- package/dist/{plugin-marketplace-discovery-CfFlKqDl.js → conversation-control-CUCrSIQI.js} +36 -155
- package/dist/doctor-contract-api.js +8 -9
- package/dist/{dynamic-tools-BU9tmlYm.js → dynamic-tools-D-JBoaLt.js} +734 -698
- package/dist/{effective-mcp-catalog-DzYBW4h1.js → effective-mcp-catalog-J_5Ep5Um.js} +4 -3
- package/dist/{elicitation-input-DMkeki8d.js → elicitation-input-DPoK8F7w.js} +8 -22
- package/dist/ephemeral-turn-DSwzP8YY.js +101 -0
- package/dist/{event-projector-assistant-message-DHRFXKbS.js → event-projector-assistant-message-BmBM4qBV.js} +23 -27
- package/dist/event-projector-usage-CIyrYYid.js +102 -0
- package/dist/{harness-DXVZ5II5.js → harness-FR6eQgyO.js} +47 -17
- package/dist/harness.js +1 -1
- package/dist/history-rejection-B4nOXNXF.js +13 -0
- package/dist/{image-payload-sanitizer-CnfoUPCE.js → image-payload-sanitizer-tupAr-2o.js} +29 -15
- package/dist/incognito-session-uhrBF6wJ.js +15 -0
- package/dist/index.js +413 -2893
- package/dist/{isolated-completion-kg9kv4iH.js → isolated-completion-DHBefrzg.js} +12 -21
- package/dist/{managed-binary-4-Vjz5GH.js → managed-binary-DrjjRRUD.js} +17 -84
- package/dist/managed-thread-store-D1t5jh3G.js +66 -0
- package/dist/media-understanding-provider.js +4 -1
- package/dist/{model-catalog-CUM68Hkl.js → model-catalog-B_6M04Wo.js} +6 -5
- package/dist/{models-sYnEc0gd.js → models-P9k2qAof.js} +4 -4
- package/dist/native-execution-policy-umd0tgh4.js +128 -0
- package/dist/{native-subagent-monitor-CnH147jH.js → native-subagent-monitor-BbCUKRwC.js} +76 -48
- package/dist/node-cli-sessions-rj0ysJwM.js +527 -0
- package/dist/{node-exec-server.runtime-CstNHCmC.js → node-exec-server.runtime-BY_ctYnT.js} +54 -23
- package/dist/plan-BMJdMOEF.js +711 -0
- package/dist/plugin-activation-BQK-f5sV.js +133 -0
- package/dist/{thread-resume-C7pyVKeW.js → plugin-app-cache-key-CdSQzWyX.js} +5 -53
- package/dist/{plugin-approval-roundtrip-CNe-Xrjx.js → plugin-approval-roundtrip-DeW95wB5.js} +1 -1
- package/dist/plugin-inventory-CoRCzWW4.js +325 -0
- package/dist/plugin-marketplace-discovery-3akBizzF.js +134 -0
- package/dist/{plugin-metadata-cache-BFrPhb2c.js → plugin-metadata-cache-DgNfRAGA.js} +13 -9
- package/dist/protocol-CAAcVIKF.js +275 -0
- package/dist/{provider-capabilities-DW5p4k9w.js → provider-capabilities-W4tfK5Y5.js} +2 -2
- package/dist/{rate-limits-CawQJfUS.js → rate-limits-Bqnx1N4z.js} +1 -1
- package/dist/request-CGvGOpeR.js +198 -0
- package/dist/{run-attempt-D1hJO4fX.js → run-attempt-DwKds3DN.js} +1498 -1028
- package/dist/{runtime-artifact-C3jVimFn.js → runtime-artifact-T-NwqeSH.js} +28 -28
- package/dist/sandbox-guard-BcT66fWy.js +165 -0
- package/dist/{session-binding-BHuTCRZQ.js → session-binding-CKSepwIC.js} +118 -324
- package/dist/session-binding-record-CaZjYwNS.js +256 -0
- package/dist/session-catalog-HaDcp7Sv.js +1533 -0
- package/dist/session-catalog-adoption-BKLtSrwi.js +251 -0
- package/dist/session-catalog-archive-D0i2pGj2.js +56 -0
- package/dist/session-catalog-home-id-D7-aLiNt.js +190 -0
- package/dist/session-catalog-node-adoption-BUuDYY8R.js +182 -0
- package/dist/session-catalog-node-continue-CBtc4wkI.js +238 -0
- package/dist/session-catalog-parsing-CdD3JhdM.js +280 -0
- package/dist/session-catalog-provenance-DkJHo735.js +124 -0
- package/dist/{session-cli-CmFEXMAM.js → session-cli-CbgaHh0f.js} +3 -2
- package/dist/session-history-Cz-tOOYj.js +96 -0
- package/dist/{session-upstream-marker-C351-5Qw.js → session-history-import-DFN7sWRU.js} +5 -49
- package/dist/session-history-read-cxPUxyVV.js +50 -0
- package/dist/session-history-worker-runtime.js +60 -0
- package/dist/{settled-turn-context-D3SNWtUn.js → session-history.worker-CNEvGaU5.js} +75 -69
- package/dist/session-history.worker.js +2 -0
- package/dist/{session-initialization-BeWzjGiR.js → session-initialization-Jo86C60I.js} +2 -1
- package/dist/{session-permission-policy-DeWVTCMj.js → session-permission-policy-B22InTp_.js} +4 -7
- package/dist/{session-retirement-BujDjXVF.js → session-retirement-BSNG_mhf.js} +8 -7
- package/dist/session-upstream-marker-D15C9NHp.js +46 -0
- package/dist/settled-turn-context-Du6gdUDd.js +45 -0
- package/dist/{settled-turn-finalizer-BVJx4yoc.js → settled-turn-finalizer-BuLUrZl2.js} +54 -42
- package/dist/shared-client-CVhez2Uo.js +2911 -0
- package/dist/{side-question-BTZAII4l.js → side-question-DLbr2vUU.js} +135 -191
- package/dist/source-Da-h6f7e.js +518 -0
- package/dist/thread-archive-guard-D1bP04Tf.js +53 -0
- package/dist/{thread-lifecycle-DAcEJ_Om.js → thread-lifecycle-D1pzRwHB.js} +467 -977
- package/dist/{thread-ownership-zGokd8i1.js → thread-ownership-D6oASVRu.js} +15 -17
- package/dist/{thread-policy-g4KbJPzp.js → thread-policy-D8kI7yAO.js} +2 -2
- package/dist/thread-resume-T5cveyxA.js +52 -0
- package/dist/timeout-BVw8aaM1.js +33 -0
- package/dist/transcript-mirror-attestation-DibE0krH.js +89 -0
- package/dist/{transcript-mirror-DTUxFWa_.js → transcript-mirror-t5TOccct.js} +111 -379
- package/dist/{transport-stdio-CyPldczm.js → transport-stdio-BGjHoYLr.js} +80 -48
- package/dist/{upstream-session-fork-CYlBIGVt.js → upstream-session-fork-De-sLJ2r.js} +94 -166
- package/dist/{usage-Bj-rrzkR.js → usage-CPPTmBvZ.js} +4 -3
- package/dist/version-omm6IPI3.js +12 -0
- package/dist/{web-search-provider.runtime-D2FWSK4w.js → web-search-provider.runtime-CSVgQL0w.js} +3 -3
- package/openclaw.plugin.json +22 -1
- package/package.json +6 -6
- package/dist/request-DYAI5FQE.js +0 -475
- package/dist/session-catalog-yyvTWFOw.js +0 -3120
- package/dist/session-history-C5J1AKzG.js +0 -87
- package/dist/shared-client-DxcfF9KX.js +0 -7494
- package/dist/{auth-binding-Ds_QVm-X.js → auth-binding-Co2Vfcf_.js} +1 -1
|
@@ -1,137 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { readFileSync } from "node:fs";
|
|
8
|
-
import { homedir, hostname } from "node:os";
|
|
9
|
-
import { resolveProviderIdForAuth } from "openclaw/plugin-sdk/agent-runtime";
|
|
10
|
-
import { resolveAgentConfig as resolveAgentConfig$1 } from "openclaw/plugin-sdk/agent-scope-runtime";
|
|
11
|
-
import { resolveExecApprovalsFromFile } from "openclaw/plugin-sdk/exec-approvals-runtime";
|
|
12
|
-
import { buildSecretInputSchema, normalizeResolvedSecretInputString } from "openclaw/plugin-sdk/secret-input";
|
|
13
|
-
import { detectWindowsSpawnCommandInlineArgs } from "openclaw/plugin-sdk/windows-spawn";
|
|
14
|
-
import { z } from "zod";
|
|
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";
|
|
5
|
+
import { createHash } from "node:crypto";
|
|
6
|
+
import { AgentHarnessPreflightError } from "openclaw/plugin-sdk/agent-harness-registration";
|
|
15
7
|
import { parse } from "smol-toml";
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
function resolveCodexAppServerHomeDir(agentDir) {
|
|
21
|
-
return path.join(path.resolve(agentDir), CODEX_APP_SERVER_HOME_DIRNAME);
|
|
22
|
-
}
|
|
23
|
-
/** Resolves the native user Codex home used by Desktop and the CLI. */
|
|
24
|
-
function resolveCodexAppServerUserHomeDir(env = process.env, homedir$1 = homedir) {
|
|
25
|
-
const configured = normalizeOptionalString(env.CODEX_HOME);
|
|
26
|
-
return path.resolve(configured ?? path.join(homedir$1(), ".codex"));
|
|
27
|
-
}
|
|
28
|
-
/** Resolves the local CODEX_HOME used when starting one app-server connection. */
|
|
29
|
-
function resolveCodexAppServerLocalHomeDir(startOptions, agentDir, env = process.env) {
|
|
30
|
-
const configured = startOptions.env?.CODEX_HOME;
|
|
31
|
-
if (configured?.trim()) return configured;
|
|
32
|
-
return startOptions.homeScope === "user" ? resolveCodexAppServerUserHomeDir(env) : resolveCodexAppServerHomeDir(agentDir);
|
|
33
|
-
}
|
|
34
|
-
/** Forces OpenClaw-owned Codex auth to remain process-local. */
|
|
35
|
-
function withEphemeralCodexAuthStore(params) {
|
|
36
|
-
const { startOptions } = params;
|
|
37
|
-
if (!params.preparedAuth && params.authProfileId === null) return startOptions;
|
|
38
|
-
const args = normalizeCodexAppServerArgs(startOptions.args, CODEX_EPHEMERAL_AUTH_STORE_OVERRIDE);
|
|
39
|
-
return args === startOptions.args ? startOptions : {
|
|
40
|
-
...startOptions,
|
|
41
|
-
args
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
//#endregion
|
|
45
|
-
//#region extensions/codex/src/app-server/config-contracts.ts
|
|
46
|
-
const CODEX_PLUGINS_MARKETPLACE_NAME = "openai-curated";
|
|
47
|
-
const CODEX_PLUGINS_WORKSPACE_MARKETPLACE_NAME = "workspace-directory";
|
|
48
|
-
const CODEX_PLUGIN_MARKETPLACE_NAME_PATTERN = /^[A-Za-z0-9_-]+$/;
|
|
49
|
-
//#endregion
|
|
50
|
-
//#region extensions/codex/src/app-server/config-utils.ts
|
|
51
|
-
const START_OPTIONS_KEY_SECRET_SYMBOL = Symbol.for("openclaw.codexAppServerStartOptionsKeySecret");
|
|
52
|
-
const START_OPTIONS_KEY_SECRET = getStartOptionsKeySecret();
|
|
53
|
-
const PLAIN_DECIMAL_NUMBER_RE = /^[+-]?(?:(?:\d+\.?\d*)|(?:\.\d+))$/;
|
|
54
|
-
function normalizeCodexServiceTier(value) {
|
|
55
|
-
if (typeof value !== "string") return;
|
|
56
|
-
const trimmed = value.trim();
|
|
57
|
-
if (!trimmed) return;
|
|
58
|
-
const normalized = trimmed.toLowerCase();
|
|
59
|
-
if (normalized === "fast" || normalized === "priority") return "priority";
|
|
60
|
-
if (normalized === "flex") return "flex";
|
|
61
|
-
return trimmed;
|
|
62
|
-
}
|
|
63
|
-
function isCodexFastServiceTier(value) {
|
|
64
|
-
return normalizeCodexServiceTier(value) === "priority";
|
|
65
|
-
}
|
|
66
|
-
function normalizePositiveNumber(value, fallback) {
|
|
67
|
-
return resolvePositiveTimerTimeoutMs(value, fallback);
|
|
68
|
-
}
|
|
69
|
-
function normalizeHeaders(value) {
|
|
70
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return {};
|
|
71
|
-
return Object.fromEntries(Object.entries(value).map(([key, child]) => [key.trim(), normalizeCodexAppServerSecretInput({
|
|
72
|
-
value: child,
|
|
73
|
-
path: `plugins.entries.codex.config.appServer.headers.${key}`
|
|
74
|
-
})]).filter((entry) => Boolean(entry[0] && entry[1])));
|
|
75
|
-
}
|
|
76
|
-
function normalizeCodexAppServerSecretInput(params) {
|
|
77
|
-
return normalizeResolvedSecretInputString(params);
|
|
78
|
-
}
|
|
79
|
-
function readBooleanEnv(value) {
|
|
80
|
-
return parseBooleanValue(value);
|
|
81
|
-
}
|
|
82
|
-
function readExecSecurity(value) {
|
|
83
|
-
return value === "deny" || value === "allowlist" || value === "full" ? value : void 0;
|
|
84
|
-
}
|
|
85
|
-
function readExecAsk(value) {
|
|
86
|
-
return value === "off" || value === "on-miss" || value === "always" ? value : void 0;
|
|
87
|
-
}
|
|
88
|
-
function readNumberEnv(value) {
|
|
89
|
-
const trimmed = value?.trim();
|
|
90
|
-
if (!trimmed || !PLAIN_DECIMAL_NUMBER_RE.test(trimmed)) return;
|
|
91
|
-
const parsed = Number(trimmed);
|
|
92
|
-
return Number.isFinite(parsed) ? parsed : void 0;
|
|
93
|
-
}
|
|
94
|
-
function resolveArgs(configArgs, envArgs) {
|
|
95
|
-
if (Array.isArray(configArgs)) return configArgs.map((entry) => readNonEmptyString(entry)).filter((entry) => entry !== void 0);
|
|
96
|
-
if (typeof configArgs === "string") return splitShellWords(configArgs);
|
|
97
|
-
return splitShellWords(envArgs ?? "");
|
|
98
|
-
}
|
|
99
|
-
function hashSecretForKey(value, label) {
|
|
100
|
-
if (!value) return null;
|
|
101
|
-
return createHmac("sha256", START_OPTIONS_KEY_SECRET).update(label).update("\0").update(value).digest("hex");
|
|
102
|
-
}
|
|
103
|
-
function getStartOptionsKeySecret() {
|
|
104
|
-
const globalState = globalThis;
|
|
105
|
-
globalState[START_OPTIONS_KEY_SECRET_SYMBOL] ??= randomBytes(32);
|
|
106
|
-
return globalState[START_OPTIONS_KEY_SECRET_SYMBOL];
|
|
107
|
-
}
|
|
108
|
-
function splitShellWords(value) {
|
|
109
|
-
const words = [];
|
|
110
|
-
let current = "";
|
|
111
|
-
let quote = null;
|
|
112
|
-
for (const char of value) {
|
|
113
|
-
if (quote) {
|
|
114
|
-
if (char === quote) quote = null;
|
|
115
|
-
else current += char;
|
|
116
|
-
continue;
|
|
117
|
-
}
|
|
118
|
-
if (char === "\"" || char === "'") {
|
|
119
|
-
quote = char;
|
|
120
|
-
continue;
|
|
121
|
-
}
|
|
122
|
-
if (/\s/.test(char)) {
|
|
123
|
-
if (current) {
|
|
124
|
-
words.push(current);
|
|
125
|
-
current = "";
|
|
126
|
-
}
|
|
127
|
-
continue;
|
|
128
|
-
}
|
|
129
|
-
current += char;
|
|
130
|
-
}
|
|
131
|
-
if (current) words.push(current);
|
|
132
|
-
return words;
|
|
133
|
-
}
|
|
134
|
-
//#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";
|
|
135
12
|
//#region extensions/codex/src/app-server/config-exec-policy.ts
|
|
136
13
|
function selectForcedPromptingSandbox(params) {
|
|
137
14
|
if (params.configuredSandbox === "read-only" || params.defaultSandbox === "read-only") return "read-only";
|
|
@@ -162,27 +39,6 @@ function resolveSandbox(value) {
|
|
|
162
39
|
function resolveApprovalsReviewer(value) {
|
|
163
40
|
return value === "auto_review" || value === "guardian_subagent" || value === "user" ? value : void 0;
|
|
164
41
|
}
|
|
165
|
-
function resolveOpenClawExecPolicyFromConfig(params) {
|
|
166
|
-
const globalExec = readRecord(params.config?.tools?.exec);
|
|
167
|
-
const globalPolicy = applyOpenClawExecPolicyLayer(createDefaultOpenClawExecPolicy(), globalExec);
|
|
168
|
-
const agentId = params.agentId?.trim();
|
|
169
|
-
return applyOpenClawExecPolicyLayer(globalPolicy, agentId ? readRecord(resolveAgentConfig$1(params.config ?? {}, agentId)?.tools?.exec) : void 0);
|
|
170
|
-
}
|
|
171
|
-
function resolveOpenClawExecPolicyForCodexAppServer(params) {
|
|
172
|
-
if (params.permissionMode === "full") return {
|
|
173
|
-
...resolveOpenClawExecPolicyForMode("full"),
|
|
174
|
-
touched: true
|
|
175
|
-
};
|
|
176
|
-
const overridePolicy = applyOpenClawExecPolicyLayer(resolveOpenClawExecPolicyFromConfig({
|
|
177
|
-
config: params.config,
|
|
178
|
-
agentId: params.agentId
|
|
179
|
-
}), params.execOverrides);
|
|
180
|
-
return applyOpenClawExecApprovalFloors(overridePolicy, resolveOpenClawExecApprovalFloorsForCodexAppServer({
|
|
181
|
-
approvals: params.approvals,
|
|
182
|
-
agentId: params.agentId,
|
|
183
|
-
policy: overridePolicy
|
|
184
|
-
}));
|
|
185
|
-
}
|
|
186
42
|
function resolveEffectiveOpenClawExecModeForCodexAppServer(params) {
|
|
187
43
|
if (params.execPolicy?.touched === true) return params.execPolicy.mode;
|
|
188
44
|
return params.execMode;
|
|
@@ -194,331 +50,6 @@ function resolveCodexPolicyModeForOpenClawExecMode(mode) {
|
|
|
194
50
|
function assertCodexAppServerAllowedForOpenClawExecMode(mode) {
|
|
195
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" });
|
|
196
52
|
}
|
|
197
|
-
function createDefaultOpenClawExecPolicy() {
|
|
198
|
-
return {
|
|
199
|
-
...resolveOpenClawExecPolicyForMode("full"),
|
|
200
|
-
touched: false
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
function applyOpenClawExecPolicyLayer(base, exec) {
|
|
204
|
-
if (!exec) return base;
|
|
205
|
-
const mode = readExecMode(exec.mode);
|
|
206
|
-
if (mode !== void 0) return {
|
|
207
|
-
...resolveOpenClawExecPolicyForMode(mode),
|
|
208
|
-
touched: true
|
|
209
|
-
};
|
|
210
|
-
const security = readExecSecurity(exec.security);
|
|
211
|
-
const ask = readExecAsk(exec.ask);
|
|
212
|
-
if (security === void 0 && ask === void 0) return base;
|
|
213
|
-
const nextSecurity = security ?? base.security;
|
|
214
|
-
const nextAsk = ask ?? base.ask;
|
|
215
|
-
return {
|
|
216
|
-
mode: resolveOpenClawExecModeFromPolicy({
|
|
217
|
-
security: nextSecurity,
|
|
218
|
-
ask: nextAsk
|
|
219
|
-
}),
|
|
220
|
-
security: nextSecurity,
|
|
221
|
-
ask: nextAsk,
|
|
222
|
-
touched: true
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
function resolveOpenClawExecApprovalFloorsForCodexAppServer(params) {
|
|
226
|
-
if (!params.approvals) return;
|
|
227
|
-
return resolveExecApprovalsFromFile({
|
|
228
|
-
file: params.approvals,
|
|
229
|
-
agentId: params.agentId,
|
|
230
|
-
overrides: {
|
|
231
|
-
security: params.policy.security,
|
|
232
|
-
ask: params.policy.ask
|
|
233
|
-
}
|
|
234
|
-
}).agent;
|
|
235
|
-
}
|
|
236
|
-
function applyOpenClawExecApprovalFloors(base, approvalFloors) {
|
|
237
|
-
if (!approvalFloors) return base;
|
|
238
|
-
const nextSecurity = approvalFloors.security ? minOpenClawExecSecurity(base.security, approvalFloors.security) : base.security;
|
|
239
|
-
const nextAsk = approvalFloors.ask ? maxOpenClawExecAsk(base.ask, approvalFloors.ask) : base.ask;
|
|
240
|
-
if (nextSecurity === base.security && nextAsk === base.ask) return base;
|
|
241
|
-
return {
|
|
242
|
-
mode: resolveOpenClawExecModeFromPolicy({
|
|
243
|
-
security: nextSecurity,
|
|
244
|
-
ask: nextAsk
|
|
245
|
-
}),
|
|
246
|
-
security: nextSecurity,
|
|
247
|
-
ask: nextAsk,
|
|
248
|
-
touched: true
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
function resolveOpenClawExecPolicyForMode(mode) {
|
|
252
|
-
switch (mode) {
|
|
253
|
-
case "deny": return {
|
|
254
|
-
mode,
|
|
255
|
-
security: "deny",
|
|
256
|
-
ask: "off"
|
|
257
|
-
};
|
|
258
|
-
case "allowlist": return {
|
|
259
|
-
mode,
|
|
260
|
-
security: "allowlist",
|
|
261
|
-
ask: "off"
|
|
262
|
-
};
|
|
263
|
-
case "ask":
|
|
264
|
-
case "auto": return {
|
|
265
|
-
mode,
|
|
266
|
-
security: "allowlist",
|
|
267
|
-
ask: "on-miss"
|
|
268
|
-
};
|
|
269
|
-
case "full": return {
|
|
270
|
-
mode,
|
|
271
|
-
security: "full",
|
|
272
|
-
ask: "off"
|
|
273
|
-
};
|
|
274
|
-
}
|
|
275
|
-
return mode;
|
|
276
|
-
}
|
|
277
|
-
function resolveOpenClawExecModeFromPolicy(params) {
|
|
278
|
-
if (params.security === "deny") return "deny";
|
|
279
|
-
if (params.security === "allowlist" && params.ask === "off") return "allowlist";
|
|
280
|
-
if (params.security === "full" && params.ask !== "always") return "full";
|
|
281
|
-
return "ask";
|
|
282
|
-
}
|
|
283
|
-
function minOpenClawExecSecurity(left, right) {
|
|
284
|
-
const order = {
|
|
285
|
-
deny: 0,
|
|
286
|
-
allowlist: 1,
|
|
287
|
-
full: 2
|
|
288
|
-
};
|
|
289
|
-
return order[left] <= order[right] ? left : right;
|
|
290
|
-
}
|
|
291
|
-
function maxOpenClawExecAsk(left, right) {
|
|
292
|
-
const order = {
|
|
293
|
-
off: 0,
|
|
294
|
-
"on-miss": 1,
|
|
295
|
-
always: 2
|
|
296
|
-
};
|
|
297
|
-
return order[left] >= order[right] ? left : right;
|
|
298
|
-
}
|
|
299
|
-
function readExecMode(value) {
|
|
300
|
-
return value === "deny" || value === "allowlist" || value === "ask" || value === "auto" || value === "full" ? value : void 0;
|
|
301
|
-
}
|
|
302
|
-
//#endregion
|
|
303
|
-
//#region extensions/codex/src/app-server/session-discovery-config.ts
|
|
304
|
-
const codexSessionCatalogHomeSchema = z.union([z.string().trim().min(1), z.object({
|
|
305
|
-
path: z.string().trim().min(1),
|
|
306
|
-
label: z.string().trim().min(1).optional()
|
|
307
|
-
}).strict()]);
|
|
308
|
-
const codexSessionCatalogConfigSchema = z.object({
|
|
309
|
-
enabled: z.boolean().optional(),
|
|
310
|
-
homes: z.array(codexSessionCatalogHomeSchema).optional()
|
|
311
|
-
}).strict();
|
|
312
|
-
const codexDiscoveryConfigSchema = z.object({
|
|
313
|
-
enabled: z.boolean().optional(),
|
|
314
|
-
timeoutMs: z.number().positive().optional()
|
|
315
|
-
}).strict();
|
|
316
|
-
//#endregion
|
|
317
|
-
//#region extensions/codex/src/app-server/config-parsing.ts
|
|
318
|
-
const DEFAULT_CODEX_COMPUTER_USE_PLUGIN_NAME = "computer-use";
|
|
319
|
-
const DEFAULT_CODEX_COMPUTER_USE_MARKETPLACE_DISCOVERY_TIMEOUT_MS = 6e4;
|
|
320
|
-
const DEFAULT_CODEX_COMPUTER_USE_LIVE_TEST_TIMEOUT_MS = 6e4;
|
|
321
|
-
const DEFAULT_CODEX_COMPUTER_USE_TOOL_CALL_TIMEOUT_MS = 6e4;
|
|
322
|
-
const DEFAULT_CODEX_APP_SERVER_NETWORK_PROXY_PROFILE_PREFIX = "openclaw-network";
|
|
323
|
-
const codexAppServerTransportSchema = z.enum([
|
|
324
|
-
"stdio",
|
|
325
|
-
"websocket",
|
|
326
|
-
"unix"
|
|
327
|
-
]);
|
|
328
|
-
const codexAppServerHomeScopeSchema = z.enum(["agent", "user"]);
|
|
329
|
-
const SecretInputSchema = buildSecretInputSchema();
|
|
330
|
-
const codexAppServerPolicyModeSchema = z.enum(["yolo", "guardian"]);
|
|
331
|
-
const codexAppServerApprovalPolicySchema = z.preprocess((value) => value === "on-failure" ? "on-request" : value, z.enum(["never", "on-request"]));
|
|
332
|
-
const codexAppServerSandboxSchema = z.enum([
|
|
333
|
-
"read-only",
|
|
334
|
-
"workspace-write",
|
|
335
|
-
"danger-full-access"
|
|
336
|
-
]);
|
|
337
|
-
const codexAppServerApprovalsReviewerSchema = z.enum([
|
|
338
|
-
"user",
|
|
339
|
-
"auto_review",
|
|
340
|
-
"guardian_subagent"
|
|
341
|
-
]);
|
|
342
|
-
const codexDynamicToolsLoadingSchema = z.enum(["searchable", "direct"]);
|
|
343
|
-
const codexComputerUseHealthIntervalSchema = z.union([
|
|
344
|
-
z.literal(30),
|
|
345
|
-
z.literal(60),
|
|
346
|
-
z.literal(120),
|
|
347
|
-
z.literal(240)
|
|
348
|
-
]);
|
|
349
|
-
const codexComputerUsePluginCacheModeSchema = z.enum(["shared", "independent"]);
|
|
350
|
-
const codexPluginDestructivePolicySchema = z.union([
|
|
351
|
-
z.boolean(),
|
|
352
|
-
z.literal("auto"),
|
|
353
|
-
z.literal("ask")
|
|
354
|
-
]);
|
|
355
|
-
const codexAppServerServiceTierSchema = z.preprocess((value) => value === null ? null : normalizeCodexServiceTier(value), z.string().trim().min(1).nullable().optional()).optional();
|
|
356
|
-
const codexAppServerExperimentalSchema = z.object({ sandboxExecServer: z.boolean().optional() }).strict();
|
|
357
|
-
const codexAppServerRemoteWorkspaceRootSchema = z.string().trim().min(1);
|
|
358
|
-
const codexAppServerNetworkProxyDomainPermissionSchema = z.enum(["allow", "deny"]);
|
|
359
|
-
const codexAppServerNetworkProxyUnixSocketPermissionSchema = z.enum(["allow", "none"]);
|
|
360
|
-
const codexAppServerNetworkProxySchema = z.object({
|
|
361
|
-
enabled: z.boolean().optional(),
|
|
362
|
-
profileName: z.string().trim().min(1).optional(),
|
|
363
|
-
baseProfile: z.enum(["read-only", "workspace"]).optional(),
|
|
364
|
-
mode: z.enum(["limited", "full"]).optional(),
|
|
365
|
-
domains: z.record(z.string(), codexAppServerNetworkProxyDomainPermissionSchema).optional(),
|
|
366
|
-
unixSockets: z.record(z.string(), codexAppServerNetworkProxyUnixSocketPermissionSchema).optional(),
|
|
367
|
-
proxyUrl: z.string().trim().min(1).optional(),
|
|
368
|
-
socksUrl: z.string().trim().min(1).optional(),
|
|
369
|
-
enableSocks5: z.boolean().optional(),
|
|
370
|
-
enableSocks5Udp: z.boolean().optional(),
|
|
371
|
-
allowUpstreamProxy: z.boolean().optional(),
|
|
372
|
-
allowLocalBinding: z.boolean().optional(),
|
|
373
|
-
dangerouslyAllowNonLoopbackProxy: z.boolean().optional(),
|
|
374
|
-
dangerouslyAllowAllUnixSockets: z.boolean().optional()
|
|
375
|
-
}).strict();
|
|
376
|
-
const codexPluginEntryConfigSchema = z.object({
|
|
377
|
-
enabled: z.boolean().optional(),
|
|
378
|
-
marketplaceName: z.string().regex(CODEX_PLUGIN_MARKETPLACE_NAME_PATTERN).optional(),
|
|
379
|
-
pluginName: z.string().trim().min(1).optional(),
|
|
380
|
-
allow_destructive_actions: codexPluginDestructivePolicySchema.optional()
|
|
381
|
-
}).strict();
|
|
382
|
-
const codexPluginsConfigSchema = z.object({
|
|
383
|
-
enabled: z.boolean().optional(),
|
|
384
|
-
allow_all_plugins: z.boolean().optional(),
|
|
385
|
-
allow_destructive_actions: codexPluginDestructivePolicySchema.optional(),
|
|
386
|
-
plugins: z.record(z.string(), codexPluginEntryConfigSchema).optional()
|
|
387
|
-
}).strict();
|
|
388
|
-
const codexSupervisionEndpointSchema = z.union([z.object({
|
|
389
|
-
id: z.string().optional(),
|
|
390
|
-
label: z.string().optional(),
|
|
391
|
-
transport: z.literal("stdio-proxy").optional(),
|
|
392
|
-
command: z.string().optional(),
|
|
393
|
-
args: z.array(z.string()).optional(),
|
|
394
|
-
cwd: z.string().optional()
|
|
395
|
-
}).strict(), z.object({
|
|
396
|
-
id: z.string().optional(),
|
|
397
|
-
label: z.string().optional(),
|
|
398
|
-
transport: z.literal("websocket"),
|
|
399
|
-
url: z.string(),
|
|
400
|
-
authTokenEnv: z.string().optional()
|
|
401
|
-
}).strict()]);
|
|
402
|
-
const codexSupervisionConfigSchema = z.object({
|
|
403
|
-
enabled: z.boolean().optional(),
|
|
404
|
-
endpoints: z.array(codexSupervisionEndpointSchema).optional(),
|
|
405
|
-
allowRawTranscripts: z.boolean().optional(),
|
|
406
|
-
allowWriteControls: z.boolean().optional()
|
|
407
|
-
}).strict();
|
|
408
|
-
const codexPluginConfigSchema = z.object({
|
|
409
|
-
codexDynamicToolsLoading: codexDynamicToolsLoadingSchema.optional(),
|
|
410
|
-
codexDynamicToolsExclude: z.array(z.string()).optional(),
|
|
411
|
-
sessionCatalog: codexSessionCatalogConfigSchema.optional(),
|
|
412
|
-
discovery: codexDiscoveryConfigSchema.optional(),
|
|
413
|
-
computerUse: z.object({
|
|
414
|
-
enabled: z.boolean().optional(),
|
|
415
|
-
autoInstall: z.boolean().optional(),
|
|
416
|
-
marketplaceDiscoveryTimeoutMs: z.number().positive().optional(),
|
|
417
|
-
liveTestTimeoutMs: z.number().positive().optional(),
|
|
418
|
-
toolCallTimeoutMs: z.number().positive().optional(),
|
|
419
|
-
healthCheckEnabled: z.boolean().optional(),
|
|
420
|
-
healthCheckIntervalMinutes: codexComputerUseHealthIntervalSchema.optional(),
|
|
421
|
-
pluginCacheMode: codexComputerUsePluginCacheModeSchema.optional(),
|
|
422
|
-
strictReadiness: z.boolean().optional(),
|
|
423
|
-
autoRepair: z.boolean().optional(),
|
|
424
|
-
marketplaceSource: z.string().optional(),
|
|
425
|
-
marketplacePath: z.string().optional(),
|
|
426
|
-
marketplaceName: z.string().optional(),
|
|
427
|
-
pluginName: z.string().optional(),
|
|
428
|
-
mcpServerName: z.string().optional()
|
|
429
|
-
}).strict().optional(),
|
|
430
|
-
codexPlugins: z.unknown().optional(),
|
|
431
|
-
supervision: codexSupervisionConfigSchema.optional(),
|
|
432
|
-
appServer: z.object({
|
|
433
|
-
mode: codexAppServerPolicyModeSchema.optional(),
|
|
434
|
-
transport: codexAppServerTransportSchema.optional(),
|
|
435
|
-
homeScope: codexAppServerHomeScopeSchema.optional(),
|
|
436
|
-
command: z.string().optional(),
|
|
437
|
-
args: z.union([z.array(z.string()), z.string()]).optional(),
|
|
438
|
-
url: z.string().optional(),
|
|
439
|
-
authToken: SecretInputSchema.optional(),
|
|
440
|
-
headers: z.record(z.string(), SecretInputSchema).optional(),
|
|
441
|
-
clearEnv: z.array(z.string()).optional(),
|
|
442
|
-
remoteWorkspaceRoot: codexAppServerRemoteWorkspaceRootSchema.optional(),
|
|
443
|
-
codeModeOnly: z.boolean().optional(),
|
|
444
|
-
loopDetectionPreToolUseRelay: z.boolean().optional(),
|
|
445
|
-
requestTimeoutMs: z.number().positive().optional(),
|
|
446
|
-
approvalPolicy: codexAppServerApprovalPolicySchema.optional(),
|
|
447
|
-
sandbox: codexAppServerSandboxSchema.optional(),
|
|
448
|
-
approvalsReviewer: codexAppServerApprovalsReviewerSchema.optional(),
|
|
449
|
-
serviceTier: codexAppServerServiceTierSchema,
|
|
450
|
-
networkProxy: codexAppServerNetworkProxySchema.optional(),
|
|
451
|
-
defaultWorkspaceDir: z.string().optional(),
|
|
452
|
-
experimental: codexAppServerExperimentalSchema.optional()
|
|
453
|
-
}).strict().optional()
|
|
454
|
-
}).strict();
|
|
455
|
-
function readCodexPluginConfig(value) {
|
|
456
|
-
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\".");
|
|
457
|
-
const parsed = codexPluginConfigSchema.safeParse(value);
|
|
458
|
-
if (!parsed.success) return {};
|
|
459
|
-
const { codexPlugins: rawCodexPlugins, ...config } = parsed.data;
|
|
460
|
-
const plugins = codexPluginsConfigSchema.safeParse(rawCodexPlugins);
|
|
461
|
-
if (!plugins.success) return config;
|
|
462
|
-
return {
|
|
463
|
-
...config,
|
|
464
|
-
...plugins.data ? { codexPlugins: plugins.data } : {}
|
|
465
|
-
};
|
|
466
|
-
}
|
|
467
|
-
function isCodexSandboxExecServerEnabled(pluginConfig, sandbox) {
|
|
468
|
-
return isCodexRemoteExecPlacementSandbox(sandbox) || readCodexPluginConfig(pluginConfig).appServer?.experimental?.sandboxExecServer === true;
|
|
469
|
-
}
|
|
470
|
-
function isCodexRemoteExecPlacementSandbox(sandbox) {
|
|
471
|
-
return typeof sandbox === "object" && sandbox !== null && "placementExecutionMode" in sandbox && sandbox.placementExecutionMode === "remote-exec";
|
|
472
|
-
}
|
|
473
|
-
function isCodexPairedNodeRemoteExecPlacementSandbox(sandbox) {
|
|
474
|
-
return isCodexRemoteExecPlacementSandbox(sandbox) && typeof sandbox === "object" && sandbox !== null && "placementNodeId" in sandbox && typeof sandbox.placementNodeId === "string" && sandbox.placementNodeId.length > 0;
|
|
475
|
-
}
|
|
476
|
-
function assertCodexAppServerCommandHasNoInlineArgs(params) {
|
|
477
|
-
const inlineArgs = detectWindowsSpawnCommandInlineArgs(params.command);
|
|
478
|
-
if (!inlineArgs) return;
|
|
479
|
-
const sourceLabel = params.source === "env" ? "OPENCLAW_CODEX_APP_SERVER_BIN" : "plugins.entries.codex.config.appServer.command";
|
|
480
|
-
const argsLabel = params.source === "env" ? "OPENCLAW_CODEX_APP_SERVER_ARGS" : "plugins.entries.codex.config.appServer.args";
|
|
481
|
-
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.`);
|
|
482
|
-
}
|
|
483
|
-
function resolveCodexPluginsPolicy(pluginConfig) {
|
|
484
|
-
const config = readCodexPluginConfig(pluginConfig).codexPlugins;
|
|
485
|
-
const configured = config !== void 0;
|
|
486
|
-
const enabled = config?.enabled === true;
|
|
487
|
-
const destructivePolicy = resolveCodexPluginDestructivePolicy(config?.allow_destructive_actions ?? true);
|
|
488
|
-
const pluginPolicies = Object.entries(config?.plugins ?? {}).flatMap(([configKey, entry]) => {
|
|
489
|
-
if (!isCodexPluginMarketplaceName(entry.marketplaceName) || !entry.pluginName) return [];
|
|
490
|
-
const entryDestructivePolicy = resolveCodexPluginDestructivePolicy(entry.allow_destructive_actions ?? config?.allow_destructive_actions ?? true);
|
|
491
|
-
return [{
|
|
492
|
-
configKey,
|
|
493
|
-
marketplaceName: entry.marketplaceName,
|
|
494
|
-
pluginName: entry.pluginName,
|
|
495
|
-
enabled: enabled && entry.enabled !== false,
|
|
496
|
-
allowDestructiveActions: entryDestructivePolicy.allowDestructiveActions,
|
|
497
|
-
destructiveApprovalMode: entryDestructivePolicy.destructiveApprovalMode
|
|
498
|
-
}];
|
|
499
|
-
}).toSorted((left, right) => left.configKey.localeCompare(right.configKey));
|
|
500
|
-
return {
|
|
501
|
-
configured,
|
|
502
|
-
enabled,
|
|
503
|
-
allowAllPlugins: enabled && config?.allow_all_plugins === true,
|
|
504
|
-
allowDestructiveActions: destructivePolicy.allowDestructiveActions,
|
|
505
|
-
destructiveApprovalMode: destructivePolicy.destructiveApprovalMode,
|
|
506
|
-
pluginPolicies
|
|
507
|
-
};
|
|
508
|
-
}
|
|
509
|
-
function isCodexPluginMarketplaceName(value) {
|
|
510
|
-
return typeof value === "string" && CODEX_PLUGIN_MARKETPLACE_NAME_PATTERN.test(value);
|
|
511
|
-
}
|
|
512
|
-
function resolveCodexPluginDestructivePolicy(policy) {
|
|
513
|
-
if (policy === "auto" || policy === "ask") return {
|
|
514
|
-
allowDestructiveActions: true,
|
|
515
|
-
destructiveApprovalMode: policy
|
|
516
|
-
};
|
|
517
|
-
return {
|
|
518
|
-
allowDestructiveActions: policy,
|
|
519
|
-
destructiveApprovalMode: policy ? "allow" : "deny"
|
|
520
|
-
};
|
|
521
|
-
}
|
|
522
53
|
//#endregion
|
|
523
54
|
//#region extensions/codex/src/app-server/config-requirements.ts
|
|
524
55
|
const UNIX_CODEX_REQUIREMENTS_PATH = "/etc/codex/requirements.toml";
|
|
@@ -714,38 +245,55 @@ function selectUserApprovalsReviewer(allowedApprovalsReviewers, execModeRequirin
|
|
|
714
245
|
throw new Error(`tools.exec.mode=${execModeRequiringUserReviewer ?? "ask"} requires Codex app-server user approvals`);
|
|
715
246
|
}
|
|
716
247
|
//#endregion
|
|
717
|
-
//#region extensions/codex/src/app-server/config-
|
|
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
|
|
718
269
|
const CODEX_CONFIG_TOML_FILENAME = "config.toml";
|
|
719
270
|
/** Cloud/system config can redirect reviews after local home/profile checks have passed. */
|
|
720
271
|
async function assertCodexModelBackedReviewerEffectiveConfig(params) {
|
|
721
272
|
if (params.approvalsReviewer !== "auto_review" && params.approvalsReviewer !== "guardian_subagent") return;
|
|
722
|
-
const response = await params.client.
|
|
723
|
-
|
|
724
|
-
includeLayers: false
|
|
725
|
-
}, { signal: params.signal });
|
|
726
|
-
const effectiveConfig = readRecord(readRecord(response)?.config);
|
|
727
|
-
if (!effectiveConfig) throw new Error("Codex config/read returned an invalid model-backed reviewer config");
|
|
273
|
+
const response = await readCodexEffectiveConfig(params.client, params.cwd, params.signal);
|
|
274
|
+
const effectiveConfig = response.config;
|
|
728
275
|
const modelProvider = effectiveConfig.model_provider;
|
|
729
276
|
const providers = effectiveConfig.model_providers;
|
|
730
277
|
const providerRecords = providers == null ? void 0 : readRecord(providers);
|
|
731
278
|
const provider = providerRecords?.openai;
|
|
732
279
|
const openAIProvider = provider == null ? void 0 : readRecord(provider);
|
|
733
280
|
if (modelProvider != null && modelProvider !== "openai" || providers != null && !providerRecords || provider != null && !openAIProvider || !isTrustedOptionalReviewerEndpoint(effectiveConfig.openai_base_url, isNativeOpenAIBaseUrl) || !isTrustedOptionalReviewerEndpoint(effectiveConfig.chatgpt_base_url, isNativeChatGPTBaseUrl) || !isTrustedOptionalReviewerEndpoint(openAIProvider?.base_url, isNativeOpenAIBaseUrl)) throw new Error("Codex model-backed approval reviewer requires the running server to use a trusted OpenAI endpoint");
|
|
281
|
+
return response;
|
|
734
282
|
}
|
|
735
283
|
function isTrustedOptionalReviewerEndpoint(value, isTrusted) {
|
|
736
284
|
return value == null || typeof value === "string" && isTrusted(value);
|
|
737
285
|
}
|
|
738
|
-
function canUseCodexModelBackedApprovalsReviewerForModel(params) {
|
|
286
|
+
function canUseCodexModelBackedApprovalsReviewerForModel(params, resolveAuthProviderId) {
|
|
739
287
|
const explicitProvider = params.modelProvider?.trim().toLowerCase();
|
|
740
288
|
const inferredProvider = inferProviderFromModelRef(params.model);
|
|
741
289
|
if (explicitProvider && explicitProvider !== "codex" && explicitProvider !== "openai") return false;
|
|
742
|
-
return (inferredProvider ?? explicitProvider) === "openai" && isTrustedCodexModelBackedOpenAIProvider(params);
|
|
290
|
+
return (inferredProvider ?? explicitProvider) === "openai" && isTrustedCodexModelBackedOpenAIProvider(params, resolveAuthProviderId);
|
|
743
291
|
}
|
|
744
|
-
function isTrustedCodexModelBackedOpenAIProvider(params) {
|
|
292
|
+
function isTrustedCodexModelBackedOpenAIProvider(params, resolveAuthProviderId) {
|
|
745
293
|
if (!openAIBaseUrlEnvOverridesAreTrustedForModelBackedReview(params.env)) return false;
|
|
746
294
|
const codexBaseUrlOverrides = readCodexBaseUrlOverridesForModelBackedReview(params);
|
|
747
295
|
if (codexBaseUrlOverrides === false || !codexBaseUrlOverrides.openAI.every(isNativeOpenAIBaseUrl) || !codexBaseUrlOverrides.chatGPT.every(isNativeChatGPTBaseUrl)) return false;
|
|
748
|
-
const openAIProviders = readConfiguredOpenAIProvidersForModelBackedReview(params.config);
|
|
296
|
+
const openAIProviders = readConfiguredOpenAIProvidersForModelBackedReview(params.config, resolveAuthProviderId);
|
|
749
297
|
if (openAIProviders.length === 0) return true;
|
|
750
298
|
return openAIProviders.every((openAIProvider) => configuredOpenAIProviderIsTrustedForModelBackedReview(openAIProvider, params.model));
|
|
751
299
|
}
|
|
@@ -861,12 +409,12 @@ function resolveCodexAppServerConfigPath(params) {
|
|
|
861
409
|
function readErrorCode(error) {
|
|
862
410
|
return error && typeof error === "object" && "code" in error ? String(error.code) : void 0;
|
|
863
411
|
}
|
|
864
|
-
function readConfiguredOpenAIProvidersForModelBackedReview(config) {
|
|
412
|
+
function readConfiguredOpenAIProvidersForModelBackedReview(config, resolveAuthProviderId) {
|
|
865
413
|
const providerRecords = readRecord(readRecord(readRecord(config)?.models)?.providers);
|
|
866
414
|
if (!providerRecords) return [];
|
|
867
415
|
const openAIProviders = [];
|
|
868
416
|
for (const [providerId, providerConfig] of Object.entries(providerRecords)) {
|
|
869
|
-
if (
|
|
417
|
+
if (resolveAuthProviderId(providerId, { config }) !== "openai") continue;
|
|
870
418
|
const record = readRecord(providerConfig);
|
|
871
419
|
if (record) openAIProviders.push(record);
|
|
872
420
|
}
|
|
@@ -1104,7 +652,7 @@ function resolveDefaultCodexAppServerPolicy(params) {
|
|
|
1104
652
|
};
|
|
1105
653
|
}
|
|
1106
654
|
//#endregion
|
|
1107
|
-
//#region extensions/codex/src/app-server/config-
|
|
655
|
+
//#region extensions/codex/src/app-server/config-options.ts
|
|
1108
656
|
/**
|
|
1109
657
|
* Sole owner of the app-server home-scope decision. Ordinary harness connections
|
|
1110
658
|
* default to the isolated agent home; the supervision connection owns the operator's
|
|
@@ -1117,148 +665,173 @@ function resolveCodexAppServerHomeScope(params) {
|
|
|
1117
665
|
if (configured) return configured;
|
|
1118
666
|
return params.connectionScope === "supervision" && resolveTransport(params.appServer?.transport) !== "websocket" ? "user" : "agent";
|
|
1119
667
|
}
|
|
1120
|
-
function
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
source: commandSource
|
|
1134
|
-
});
|
|
1135
|
-
const args = resolveArgs(config.args, env.OPENCLAW_CODEX_APP_SERVER_ARGS);
|
|
1136
|
-
const headers = normalizeHeaders(config.headers);
|
|
1137
|
-
const clearEnv = normalizeTrimmedStringList(config.clearEnv);
|
|
1138
|
-
const authToken = normalizeCodexAppServerSecretInput({
|
|
1139
|
-
value: config.authToken,
|
|
1140
|
-
path: "plugins.entries.codex.config.appServer.authToken"
|
|
1141
|
-
});
|
|
1142
|
-
const url = readNonEmptyString(config.url) ?? (transport === "unix" ? "unix://" : void 0);
|
|
1143
|
-
const connectionClass = inferCodexAppServerConnectionClass({
|
|
1144
|
-
transport,
|
|
1145
|
-
url
|
|
1146
|
-
});
|
|
1147
|
-
const remoteAppsSubstrate = "preconfigured";
|
|
1148
|
-
const remoteWorkspaceRoot = normalizeRemoteWorkspaceRoot(config.remoteWorkspaceRoot);
|
|
1149
|
-
const execMode = resolveEffectiveOpenClawExecModeForCodexAppServer({
|
|
1150
|
-
execMode: params.execMode,
|
|
1151
|
-
execPolicy: params.execPolicy
|
|
1152
|
-
});
|
|
1153
|
-
if (!params.sessionPermissionMode) assertCodexAppServerAllowedForOpenClawExecMode(execMode);
|
|
1154
|
-
const explicitPolicyMode = resolvePolicyMode(config.mode) ?? resolvePolicyMode(env.OPENCLAW_CODEX_APP_SERVER_MODE);
|
|
1155
|
-
const configuredSandbox = resolveSandbox(config.sandbox) ?? resolveSandbox(env.OPENCLAW_CODEX_APP_SERVER_SANDBOX);
|
|
1156
|
-
const explicitApprovalsReviewer = resolveApprovalsReviewer(config.approvalsReviewer);
|
|
1157
|
-
const normalizedPolicyMode = resolveCodexPolicyModeForOpenClawExecMode(execMode);
|
|
1158
|
-
const ignoreLegacyYoloPolicyMode = normalizedPolicyMode === "guardian" && explicitPolicyMode === "yolo";
|
|
1159
|
-
const canUseModelBackedReviewer = canUseCodexModelBackedApprovalsReviewerForModel({
|
|
1160
|
-
modelProvider: params.modelProvider,
|
|
1161
|
-
model: params.model,
|
|
1162
|
-
config: params.config,
|
|
1163
|
-
env,
|
|
1164
|
-
agentDir: params.agentDir,
|
|
1165
|
-
codexConfigToml: params.codexConfigToml,
|
|
1166
|
-
homeScope
|
|
1167
|
-
});
|
|
1168
|
-
const forceUserReviewer = !canUseModelBackedReviewer && (explicitApprovalsReviewer === "auto_review" || explicitApprovalsReviewer === "guardian_subagent" || explicitPolicyMode === "guardian" && explicitApprovalsReviewer !== "user") || execMode !== void 0 && execMode !== "full" && (execMode !== "auto" || !canUseModelBackedReviewer);
|
|
1169
|
-
const forceGuardianReviewer = execMode === "auto" && canUseModelBackedReviewer;
|
|
1170
|
-
const execModeRequiringPromptingApprovals = execMode === "auto" || execMode === "ask" ? execMode : forceUserReviewer ? "ask" : void 0;
|
|
1171
|
-
const forceDangerFullAccessSandbox = params.execPolicy?.touched === true && params.execPolicy.security === "full" && params.execPolicy.ask === "always";
|
|
1172
|
-
const forcePerCommandApprovals = params.execPolicy?.ask === "always";
|
|
1173
|
-
const requirementsToml = forcePerCommandApprovals ? readCodexRequirementsToml({
|
|
1174
|
-
env,
|
|
1175
|
-
requirementsToml: params.requirementsToml,
|
|
1176
|
-
requirementsPath: params.requirementsPath,
|
|
1177
|
-
readRequirementsFile: params.readRequirementsFile,
|
|
1178
|
-
platform: params.platform
|
|
1179
|
-
}) ?? null : params.requirementsToml;
|
|
1180
|
-
if (forcePerCommandApprovals && requirementsToml && parseAllowedApprovalPoliciesFromCodexRequirements(requirementsToml)?.has("untrusted") === false) throw new Error("tools.exec.ask=always requires Codex app-server per-command approvals");
|
|
1181
|
-
const forceRuntimePolicy = forceUserReviewer || forceGuardianReviewer || forceDangerFullAccessSandbox;
|
|
1182
|
-
const defaultPolicy = explicitPolicyMode && !forceRuntimePolicy && !ignoreLegacyYoloPolicyMode ? void 0 : resolveDefaultCodexAppServerPolicy({
|
|
1183
|
-
transport,
|
|
1184
|
-
env,
|
|
1185
|
-
forceGuardian: normalizedPolicyMode === "guardian",
|
|
1186
|
-
forceUserReviewer: forceUserReviewer || !canUseModelBackedReviewer,
|
|
1187
|
-
execModeRequiringPromptingApprovals,
|
|
1188
|
-
requirementsToml,
|
|
1189
|
-
requirementsPath: params.requirementsPath,
|
|
1190
|
-
readRequirementsFile: params.readRequirementsFile,
|
|
1191
|
-
platform: params.platform,
|
|
1192
|
-
hostName: params.hostName,
|
|
1193
|
-
execModeRequiringUserReviewer: forceUserReviewer ? execMode : void 0
|
|
1194
|
-
});
|
|
1195
|
-
const preserveExplicitAutoSandbox = forceGuardianReviewer && configuredSandbox === "read-only";
|
|
1196
|
-
const forcedPolicy = forceRuntimePolicy ? {
|
|
1197
|
-
approvalPolicy: forcePerCommandApprovals ? "untrusted" : defaultPolicy?.approvalPolicy ?? "on-request",
|
|
1198
|
-
sandbox: preserveExplicitAutoSandbox ? void 0 : forceDangerFullAccessSandbox ? selectForcedDangerFullAccessSandbox({
|
|
1199
|
-
configuredSandbox,
|
|
1200
|
-
defaultPolicy,
|
|
1201
|
-
openClawSandboxActive: Boolean(params.openClawSandboxActive)
|
|
1202
|
-
}) : selectForcedPromptingSandbox({
|
|
1203
|
-
configuredSandbox,
|
|
1204
|
-
defaultSandbox: defaultPolicy?.sandbox
|
|
1205
|
-
}),
|
|
1206
|
-
approvalsReviewer: defaultPolicy?.approvalsReviewer ?? (forceUserReviewer ? "user" : "auto_review")
|
|
1207
|
-
} : void 0;
|
|
1208
|
-
const policyMode = ignoreLegacyYoloPolicyMode ? normalizedPolicyMode : explicitPolicyMode ?? normalizedPolicyMode ?? defaultPolicy?.mode ?? "yolo";
|
|
1209
|
-
const serviceTier = normalizeCodexServiceTier(config.serviceTier);
|
|
1210
|
-
const resolvedSandbox = forcedPolicy?.sandbox ?? configuredSandbox ?? defaultPolicy?.sandbox ?? (policyMode === "guardian" ? "workspace-write" : "danger-full-access");
|
|
1211
|
-
if (transport === "websocket" && !url) throw new Error("plugins.entries.codex.config.appServer.url is required when appServer.transport is websocket");
|
|
1212
|
-
if (transport === "websocket" && homeScope === "user") throw new Error("plugins.entries.codex.config.appServer.homeScope=user requires appServer.transport=stdio or unix");
|
|
1213
|
-
if (transport === "unix" && homeScope !== "user") throw new Error("plugins.entries.codex.config.appServer.transport=unix requires appServer.homeScope=user");
|
|
1214
|
-
if (transport === "unix" && !url?.startsWith("unix://")) throw new Error("plugins.entries.codex.config.appServer.url must use unix:// when appServer.transport is unix");
|
|
1215
|
-
assertCodexAppServerConnectionSecurity({
|
|
1216
|
-
transport,
|
|
1217
|
-
url,
|
|
1218
|
-
authToken,
|
|
1219
|
-
headers
|
|
1220
|
-
});
|
|
1221
|
-
const configApprovalPolicy = resolveApprovalPolicy(config.approvalPolicy);
|
|
1222
|
-
const envApprovalPolicy = resolveApprovalPolicy(env.OPENCLAW_CODEX_APP_SERVER_APPROVAL_POLICY);
|
|
1223
|
-
const approvalPolicy = configApprovalPolicy ?? envApprovalPolicy ?? defaultPolicy?.approvalPolicy ?? (policyMode === "guardian" ? "on-request" : "never");
|
|
1224
|
-
const approvalPolicySource = configApprovalPolicy ? "config" : envApprovalPolicy ? "env" : defaultPolicy?.approvalPolicy ? "requirements" : "implicit";
|
|
1225
|
-
const computerUseConfig = resolveCodexComputerUseConfig({
|
|
1226
|
-
pluginConfig: params.pluginConfig,
|
|
1227
|
-
env
|
|
1228
|
-
});
|
|
1229
|
-
const managedCommandOrder = params.managedCommandOrder ?? (homeScope === "user" || computerUseConfig.enabled ? "desktop-first" : "package-first");
|
|
1230
|
-
const includeManagedCommandOrder = commandSource === "managed" && (managedCommandOrder === "desktop-first" || params.managedCommandOrder === "package-first");
|
|
1231
|
-
const managedComputerUsePluginNames = [.../* @__PURE__ */ new Set([DEFAULT_CODEX_COMPUTER_USE_PLUGIN_NAME, computerUseConfig.pluginName])];
|
|
1232
|
-
return {
|
|
1233
|
-
start: {
|
|
1234
|
-
transport,
|
|
1235
|
-
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({
|
|
1236
681
|
command,
|
|
1237
|
-
commandSource
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
remoteAppsSubstrate
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
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
|
|
1262
835
|
};
|
|
1263
836
|
}
|
|
1264
837
|
/**
|
|
@@ -1378,24 +951,5 @@ function codexSandboxPolicyForTurn(mode, cwd, nativeArgs = []) {
|
|
|
1378
951
|
excludeSlashTmp
|
|
1379
952
|
};
|
|
1380
953
|
}
|
|
1381
|
-
/** Resolves the passive supervision control connection without changing harness defaults. */
|
|
1382
|
-
function resolveCodexSupervisionAppServerRuntimeOptions(params = {}) {
|
|
1383
|
-
const pluginConfig = readCodexPluginConfig(params.pluginConfig);
|
|
1384
|
-
const appServer = pluginConfig.appServer ?? {};
|
|
1385
|
-
const homeScope = resolveCodexAppServerHomeScope({
|
|
1386
|
-
appServer,
|
|
1387
|
-
connectionScope: "supervision"
|
|
1388
|
-
});
|
|
1389
|
-
return resolveCodexAppServerRuntimeOptions({
|
|
1390
|
-
...params,
|
|
1391
|
-
pluginConfig: {
|
|
1392
|
-
...pluginConfig,
|
|
1393
|
-
appServer: {
|
|
1394
|
-
...appServer,
|
|
1395
|
-
homeScope
|
|
1396
|
-
}
|
|
1397
|
-
}
|
|
1398
|
-
});
|
|
1399
|
-
}
|
|
1400
954
|
//#endregion
|
|
1401
|
-
export {
|
|
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 };
|