@openclaw/codex 2026.9.2 → 2026.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/api.js +14 -19
- package/dist/apply-B6el6hdO.js +357 -0
- package/dist/{attempt-client-cleanup-Bp1ZOnk2.js → attempt-client-cleanup-D6cR54TV.js} +39 -19
- package/dist/{attempt-context-CSazkWns.js → attempt-context-AO4DSjE0.js} +8 -6
- package/dist/{event-projector-usage-ZqEVbAEY.js → attempt-notifications--H8zXR5-.js} +3 -106
- 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-QqgcPCgk.js +60 -0
- package/dist/{bounded-turn-DxGJRYbY.js → bounded-turn-lRpmZHFv.js} +25 -122
- package/dist/build-state-6RL6qohz.js +19 -0
- package/dist/{capabilities-B1mgvpP8.js → capabilities-BeqLPbtM.js} +1 -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-DSbGMXA0.js → command-formatters-DeTfrapr.js} +2 -2
- package/dist/{command-handlers-DOJvGv6-.js → command-handlers-BfIsJEuA.js} +31 -21
- package/dist/command-rpc-BMqRQOFX.js +226 -0
- package/dist/{compact-Y_xBqrHN.js → compact-CGJZ2rlb.js} +19 -14
- package/dist/config-JDfTI4VI.js +106 -0
- package/dist/{config-CyapYSji.js → config-options-jnIFvwxD.js} +204 -592
- package/dist/config-runtime-BWf6JLWG.js +11 -0
- package/dist/conversation-binding-CxOlHiix.js +889 -0
- package/dist/{plugin-marketplace-discovery-B7gHXJ3d.js → conversation-control-CUCrSIQI.js} +10 -142
- package/dist/doctor-contract-api.js +5 -5
- package/dist/{dynamic-tools-BwpvTxaX.js → dynamic-tools-D-JBoaLt.js} +66 -70
- package/dist/{effective-mcp-catalog-CY9Jn4bA.js → effective-mcp-catalog-J_5Ep5Um.js} +3 -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-B9kp6iGC.js → event-projector-assistant-message-BmBM4qBV.js} +12 -25
- package/dist/event-projector-usage-CIyrYYid.js +102 -0
- package/dist/{harness-Czh2Sdoc.js → harness-FR6eQgyO.js} +31 -24
- package/dist/harness.js +1 -1
- package/dist/history-rejection-B4nOXNXF.js +13 -0
- package/dist/incognito-session-uhrBF6wJ.js +15 -0
- package/dist/index.js +411 -2875
- package/dist/{isolated-completion-CRh-51AK.js → isolated-completion-DHBefrzg.js} +7 -4
- package/dist/launch-args-RXQwn8zV.js +90 -0
- package/dist/{managed-binary-DcpnJF9x.js → managed-binary-DrjjRRUD.js} +4 -103
- package/dist/managed-thread-store-D1t5jh3G.js +66 -0
- package/dist/media-understanding-provider.js +4 -1
- package/dist/{model-catalog-DT5vo6qo.js → model-catalog-B_6M04Wo.js} +6 -5
- package/dist/{models-CcrgSMQR.js → models-P9k2qAof.js} +3 -3
- package/dist/native-execution-policy-umd0tgh4.js +128 -0
- package/dist/{native-subagent-monitor-B3bvQGcg.js → native-subagent-monitor-BbCUKRwC.js} +69 -42
- package/dist/node-cli-sessions-rj0ysJwM.js +527 -0
- package/dist/{node-exec-server.runtime-nfbUOtUB.js → node-exec-server.runtime-BY_ctYnT.js} +53 -22
- package/dist/plan-BMJdMOEF.js +711 -0
- package/dist/plugin-activation-BQK-f5sV.js +133 -0
- package/dist/{thread-resume-BLgqkUc1.js → plugin-app-cache-key-CdSQzWyX.js} +4 -52
- package/dist/{plugin-approval-roundtrip-aQVdyL5g.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-BwCLTY_U.js → plugin-metadata-cache-DgNfRAGA.js} +13 -9
- package/dist/protocol-CAAcVIKF.js +275 -0
- package/dist/{provider-capabilities-BpG9Ltc5.js → provider-capabilities-W4tfK5Y5.js} +2 -2
- package/dist/{rate-limits-Fx_l4eNa.js → rate-limits-Bqnx1N4z.js} +1 -1
- package/dist/request-CGvGOpeR.js +198 -0
- package/dist/{run-attempt-BzthFQSM.js → run-attempt-DwKds3DN.js} +589 -373
- package/dist/{runtime-artifact-Bh_gf6-t.js → runtime-artifact-T-NwqeSH.js} +27 -27
- package/dist/sandbox-guard-BcT66fWy.js +165 -0
- package/dist/{session-binding-4Ki04sW-.js → session-binding-CKSepwIC.js} +29 -47
- package/dist/{session-binding-record-CyaXZvTe.js → session-binding-record-CaZjYwNS.js} +11 -25
- 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-BjLhpmS1.js → session-cli-CbgaHh0f.js} +3 -2
- package/dist/{session-history-DWmMqiqW.js → session-history-Cz-tOOYj.js} +6 -3
- package/dist/{session-upstream-marker-DReTpGz6.js → session-history-import-DFN7sWRU.js} +5 -50
- package/dist/{session-history-read-LHldwvyh.js → session-history-read-cxPUxyVV.js} +21 -7
- package/dist/session-history-worker-runtime.js +18 -6
- package/dist/{session-history.worker-zZVcx0ME.js → session-history.worker-CNEvGaU5.js} +58 -51
- package/dist/session-history.worker.js +1 -1
- package/dist/{session-initialization-BCFVnLL4.js → session-initialization-Jo86C60I.js} +2 -2
- package/dist/{session-permission-policy-BaueHmSj.js → session-permission-policy-B22InTp_.js} +4 -7
- package/dist/{session-retirement-DNdmYdFc.js → session-retirement-BSNG_mhf.js} +6 -5
- package/dist/session-upstream-marker-D15C9NHp.js +46 -0
- package/dist/{settled-turn-context-BOM3Y1pl.js → settled-turn-context-Du6gdUDd.js} +9 -9
- package/dist/{settled-turn-finalizer-BI-b1sry.js → settled-turn-finalizer-BuLUrZl2.js} +7 -6
- package/dist/shared-client-CVhez2Uo.js +2911 -0
- package/dist/{side-question-B6DWAw1A.js → side-question-DLbr2vUU.js} +64 -169
- package/dist/source-Da-h6f7e.js +518 -0
- package/dist/thread-archive-guard-D1bP04Tf.js +53 -0
- package/dist/{thread-lifecycle-DPK30jad.js → thread-lifecycle-D1pzRwHB.js} +112 -616
- package/dist/{thread-ownership-CbucAmmp.js → thread-ownership-D6oASVRu.js} +13 -15
- package/dist/thread-policy-D8kI7yAO.js +54 -0
- package/dist/thread-resume-T5cveyxA.js +52 -0
- package/dist/timeout-BVw8aaM1.js +33 -0
- package/dist/{transcript-mirror-attestation-Byl34PC-.js → transcript-mirror-attestation-DibE0krH.js} +17 -4
- package/dist/{transcript-mirror-_njEB84z.js → transcript-mirror-t5TOccct.js} +50 -260
- package/dist/{transport-stdio-CzTngV0j.js → transport-stdio-BGjHoYLr.js} +73 -43
- package/dist/{upstream-session-fork-1fwbNKzQ.js → upstream-session-fork-De-sLJ2r.js} +26 -18
- package/dist/{usage-i9fv5-4m.js → usage-CPPTmBvZ.js} +4 -3
- package/dist/version-omm6IPI3.js +12 -0
- package/dist/{web-search-provider.runtime-DKQn67A7.js → web-search-provider.runtime-CSVgQL0w.js} +3 -3
- package/openclaw.plugin.json +22 -1
- package/package.json +4 -4
- package/dist/request-C8H22rPi.js +0 -475
- package/dist/session-catalog-B47uwekb.js +0 -3272
- package/dist/shared-client-CKhX2kFt.js +0 -7505
- package/dist/thread-policy-CTalhWFy.js +0 -105
- package/dist/{auth-binding-Ds_QVm-X.js → auth-binding-Co2Vfcf_.js} +1 -1
package/dist/request-C8H22rPi.js
DELETED
|
@@ -1,475 +0,0 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
|
|
2
|
-
import { E as isCodexRemoteExecPlacementSandbox } from "./config-CyapYSji.js";
|
|
3
|
-
import { Ft as withTimeout, c as getLeasedSharedCodexAppServerClient, h as releaseLeasedSharedCodexAppServerClient, s as createIsolatedCodexAppServerClient, u as isCodexAppServerStartSelectionChangedError, y as retireSharedCodexAppServerClientIfCurrent } from "./shared-client-CKhX2kFt.js";
|
|
4
|
-
import { resolveAgentConfig, tryResolveDefaultAgentId } from "openclaw/plugin-sdk/agent-scope-runtime";
|
|
5
|
-
import { getSessionEntry } from "openclaw/plugin-sdk/session-store-runtime";
|
|
6
|
-
import { normalizeAgentId, parseAgentSessionKey } from "openclaw/plugin-sdk/routing";
|
|
7
|
-
import { resolveSandboxRuntimeStatus } from "openclaw/plugin-sdk/sandbox";
|
|
8
|
-
//#region extensions/codex/src/app-server/native-execution-policy.ts
|
|
9
|
-
/** Projects node execution ownership into the runtime tool factory options. */
|
|
10
|
-
function resolveCodexNodeExecToolOverrides(policy) {
|
|
11
|
-
if (policy.effectiveExecHost !== "node") return;
|
|
12
|
-
const node = policy.node?.trim();
|
|
13
|
-
return {
|
|
14
|
-
host: "node",
|
|
15
|
-
...node ? { node } : {}
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
/** Resolves node/gateway/sandbox execution ownership from overrides, session, agent, and config. */
|
|
19
|
-
function resolveCodexNativeExecutionPolicy(params) {
|
|
20
|
-
const config = params.config ?? {};
|
|
21
|
-
const sessionKey = params.sessionKey?.trim() || params.sessionId?.trim() || void 0;
|
|
22
|
-
const agentId = resolvePolicyAgentId({
|
|
23
|
-
config,
|
|
24
|
-
sessionKey,
|
|
25
|
-
agentId: params.agentId
|
|
26
|
-
});
|
|
27
|
-
const canReadSessionEntry = Boolean(agentId) && params.readRuntimeSessionEntry && shouldReadRuntimeSessionEntry({
|
|
28
|
-
config,
|
|
29
|
-
sessionKey,
|
|
30
|
-
agentId
|
|
31
|
-
});
|
|
32
|
-
const sessionEntry = params.sessionEntry ?? (canReadSessionEntry && sessionKey && agentId ? readRuntimeSessionEntryBestEffort({
|
|
33
|
-
sessionKey,
|
|
34
|
-
agentId
|
|
35
|
-
}) : void 0);
|
|
36
|
-
const sandboxAgentId = parseAgentSessionKey(sessionKey)?.agentId ?? agentId;
|
|
37
|
-
const sandboxAvailable = params.sandboxAvailable ?? (sessionKey && sandboxAgentId ? resolveSandboxRuntimeStatus({
|
|
38
|
-
cfg: config,
|
|
39
|
-
sessionKey,
|
|
40
|
-
agentId: sandboxAgentId,
|
|
41
|
-
classificationAgentId: sandboxAgentId
|
|
42
|
-
}).sandboxed : false);
|
|
43
|
-
const agentExec = agentId ? resolvePolicyAgentExec({
|
|
44
|
-
config,
|
|
45
|
-
agentId
|
|
46
|
-
}) : void 0;
|
|
47
|
-
const globalExec = config.tools?.exec;
|
|
48
|
-
const requestedExecHost = normalizeExecTarget(params.execOverrides?.host) ?? normalizeExecTarget(sessionEntry?.execHost) ?? normalizeExecTarget(agentExec?.host) ?? normalizeExecTarget(globalExec?.host) ?? "auto";
|
|
49
|
-
const effectiveExecHost = resolveEffectiveExecHost({
|
|
50
|
-
requestedExecHost,
|
|
51
|
-
sandboxAvailable
|
|
52
|
-
});
|
|
53
|
-
const node = params.execOverrides?.node ?? sessionEntry?.execNode ?? agentExec?.node ?? globalExec?.node;
|
|
54
|
-
if (effectiveExecHost !== "node") return {
|
|
55
|
-
nativeToolSurfaceAllowed: true,
|
|
56
|
-
requestedExecHost,
|
|
57
|
-
effectiveExecHost,
|
|
58
|
-
node
|
|
59
|
-
};
|
|
60
|
-
return {
|
|
61
|
-
nativeToolSurfaceAllowed: false,
|
|
62
|
-
requestedExecHost,
|
|
63
|
-
effectiveExecHost,
|
|
64
|
-
node,
|
|
65
|
-
blockReason: "OpenClaw exec host=node is active for this session. Codex app-server native execution cannot route shell, filesystem, MCP, or app-backed work through the selected OpenClaw node."
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
/** Formats the user-facing explanation shown when native tools are blocked by exec host=node. */
|
|
69
|
-
function formatCodexNativeNodeExecBlock(params) {
|
|
70
|
-
return [
|
|
71
|
-
`Codex-native ${params.surface} is unavailable because OpenClaw exec host=node is active for this session.`,
|
|
72
|
-
params.reason ?? "Codex app-server native execution cannot route execution through the selected OpenClaw node.",
|
|
73
|
-
"Use a normal Codex harness turn so OpenClaw exec/process tools run on the node, or switch exec host to gateway for native Codex app-server execution."
|
|
74
|
-
].join(" ");
|
|
75
|
-
}
|
|
76
|
-
function resolvePolicyAgentId(params) {
|
|
77
|
-
const explicitAgentId = normalizeAgentIdOrDefault(params.agentId);
|
|
78
|
-
if (explicitAgentId) return explicitAgentId;
|
|
79
|
-
const sessionAgentId = parseAgentIdFromSessionKey(params.sessionKey);
|
|
80
|
-
if (sessionAgentId) return sessionAgentId;
|
|
81
|
-
return tryResolveDefaultAgentId(params.config);
|
|
82
|
-
}
|
|
83
|
-
function resolvePolicyAgentExec(params) {
|
|
84
|
-
return resolveAgentConfig(params.config, params.agentId)?.tools?.exec;
|
|
85
|
-
}
|
|
86
|
-
function parseAgentIdFromSessionKey(sessionKey) {
|
|
87
|
-
const raw = sessionKey?.trim();
|
|
88
|
-
if (!raw) return;
|
|
89
|
-
const parts = raw.toLowerCase().split(":").filter(Boolean);
|
|
90
|
-
if (parts.length < 3 || parts[0] !== "agent" || !parts[2]) return;
|
|
91
|
-
return normalizeAgentIdOrDefault(parts[1]);
|
|
92
|
-
}
|
|
93
|
-
function shouldReadRuntimeSessionEntry(params) {
|
|
94
|
-
if (!params.sessionKey) return false;
|
|
95
|
-
const explicitAgentId = normalizeAgentIdOrDefault(params.agentId);
|
|
96
|
-
if (!explicitAgentId) return true;
|
|
97
|
-
const sessionAgentId = parseAgentIdFromSessionKey(params.sessionKey);
|
|
98
|
-
if (!sessionAgentId) return isDefaultAgentSessionKeyForAgent({
|
|
99
|
-
config: params.config,
|
|
100
|
-
agentId: explicitAgentId
|
|
101
|
-
});
|
|
102
|
-
return sessionAgentId === explicitAgentId;
|
|
103
|
-
}
|
|
104
|
-
function isDefaultAgentSessionKeyForAgent(params) {
|
|
105
|
-
return normalizeAgentId(params.agentId) === tryResolveDefaultAgentId(params.config);
|
|
106
|
-
}
|
|
107
|
-
function normalizeAgentIdOrDefault(value) {
|
|
108
|
-
const normalized = normalizeAgentId(value);
|
|
109
|
-
return normalized === "main" && !(value ?? "").trim() ? void 0 : normalized;
|
|
110
|
-
}
|
|
111
|
-
function normalizeExecTarget(value) {
|
|
112
|
-
const normalized = value?.trim().toLowerCase();
|
|
113
|
-
if (normalized === "auto" || normalized === "sandbox" || normalized === "gateway" || normalized === "node") return normalized;
|
|
114
|
-
}
|
|
115
|
-
function resolveEffectiveExecHost(params) {
|
|
116
|
-
if (params.requestedExecHost === "auto") return params.sandboxAvailable ? "sandbox" : "gateway";
|
|
117
|
-
return params.requestedExecHost;
|
|
118
|
-
}
|
|
119
|
-
function readRuntimeSessionEntryBestEffort(params) {
|
|
120
|
-
try {
|
|
121
|
-
return getSessionEntry({
|
|
122
|
-
sessionKey: params.sessionKey,
|
|
123
|
-
agentId: params.agentId,
|
|
124
|
-
hydrateSkillPromptRefs: false
|
|
125
|
-
});
|
|
126
|
-
} catch {
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
//#endregion
|
|
131
|
-
//#region extensions/codex/src/app-server/sandbox-guard.ts
|
|
132
|
-
/**
|
|
133
|
-
* Blocks direct Codex app-server requests that would bypass OpenClaw sandbox or
|
|
134
|
-
* node-exec routing guarantees.
|
|
135
|
-
*/
|
|
136
|
-
const DIRECT_METHOD_POLICIES = /* @__PURE__ */ new Map([
|
|
137
|
-
["account/rateLimits/read", "allowed-control-plane"],
|
|
138
|
-
["account/read", "allowed-control-plane"],
|
|
139
|
-
["app/installed", "allowed-control-plane"],
|
|
140
|
-
["app/list", "allowed-control-plane"],
|
|
141
|
-
["app/read", "allowed-control-plane"],
|
|
142
|
-
["config/batchWrite", "allowed-control-plane"],
|
|
143
|
-
["config/mcpServer/reload", "allowed-control-plane"],
|
|
144
|
-
["config/read", "allowed-control-plane"],
|
|
145
|
-
["config/value/write", "allowed-control-plane"],
|
|
146
|
-
["environment/add", "allowed-control-plane"],
|
|
147
|
-
["experimentalFeature/enablement/set", "allowed-control-plane"],
|
|
148
|
-
["feedback/upload", "allowed-control-plane"],
|
|
149
|
-
["hooks/list", "allowed-control-plane"],
|
|
150
|
-
["initialize", "allowed-control-plane"],
|
|
151
|
-
["marketplace/add", "allowed-control-plane"],
|
|
152
|
-
["mcpServerStatus/list", "allowed-control-plane"],
|
|
153
|
-
["model/list", "allowed-control-plane"],
|
|
154
|
-
["plugin/install", "allowed-control-plane"],
|
|
155
|
-
["plugin/installed", "allowed-control-plane"],
|
|
156
|
-
["plugin/list", "allowed-control-plane"],
|
|
157
|
-
["plugin/read", "allowed-control-plane"],
|
|
158
|
-
["skills/list", "allowed-control-plane"],
|
|
159
|
-
["thread/archive", "allowed-control-plane"],
|
|
160
|
-
["thread/inject_items", "allowed-control-plane"],
|
|
161
|
-
["thread/list", "allowed-control-plane"],
|
|
162
|
-
["thread/metadata/update", "allowed-control-plane"],
|
|
163
|
-
["thread/name/set", "allowed-control-plane"],
|
|
164
|
-
["thread/read", "allowed-control-plane"],
|
|
165
|
-
["thread/rollback", "allowed-control-plane"],
|
|
166
|
-
["thread/start", "requires-openclaw-environment"],
|
|
167
|
-
["thread/unarchive", "allowed-control-plane"],
|
|
168
|
-
["thread/unsubscribe", "allowed-control-plane"],
|
|
169
|
-
["turn/interrupt", "allowed-control-plane"],
|
|
170
|
-
["turn/steer", "allowed-control-plane"],
|
|
171
|
-
["command/exec", "blocked-native-bypass"],
|
|
172
|
-
["command/resize", "blocked-native-bypass"],
|
|
173
|
-
["command/terminate", "blocked-native-bypass"],
|
|
174
|
-
["command/write", "blocked-native-bypass"],
|
|
175
|
-
["fuzzyFileSearch", "blocked-native-bypass"],
|
|
176
|
-
["mcpServer/resource/read", "blocked-native-bypass"],
|
|
177
|
-
["mcpServer/tool/call", "blocked-native-bypass"],
|
|
178
|
-
["process/kill", "blocked-native-bypass"],
|
|
179
|
-
["process/resizePty", "blocked-native-bypass"],
|
|
180
|
-
["process/spawn", "blocked-native-bypass"],
|
|
181
|
-
["process/writeStdin", "blocked-native-bypass"],
|
|
182
|
-
["review/start", "blocked-native-bypass"],
|
|
183
|
-
["thread/compact/start", "blocked-native-bypass"],
|
|
184
|
-
["thread/fork", "blocked-native-bypass"],
|
|
185
|
-
["thread/resume", "blocked-native-bypass"],
|
|
186
|
-
["thread/shellCommand", "blocked-native-bypass"],
|
|
187
|
-
["turn/start", "blocked-native-bypass"]
|
|
188
|
-
]);
|
|
189
|
-
const BLOCKED_DIRECT_METHOD_PREFIXES = [
|
|
190
|
-
"command/",
|
|
191
|
-
"fs/",
|
|
192
|
-
"windowsSandbox/"
|
|
193
|
-
];
|
|
194
|
-
const NODE_EXEC_BLOCKED_CONTROL_PLANE_METHODS = /* @__PURE__ */ new Set(["config/mcpServer/reload"]);
|
|
195
|
-
/** Returns a block message when a direct app-server method would bypass OpenClaw execution policy. */
|
|
196
|
-
function resolveCodexAppServerDirectSandboxBypassBlock(params) {
|
|
197
|
-
const policy = resolveDirectMethodPolicy(params.method);
|
|
198
|
-
if (NODE_EXEC_BLOCKED_CONTROL_PLANE_METHODS.has(params.method)) {
|
|
199
|
-
const nodeExecBlock = resolveCodexNativeNodeExecBlock({
|
|
200
|
-
config: params.config,
|
|
201
|
-
sessionKey: params.sessionKey,
|
|
202
|
-
sessionId: params.sessionId,
|
|
203
|
-
surface: `app-server method \`${params.method}\``
|
|
204
|
-
});
|
|
205
|
-
if (nodeExecBlock) return nodeExecBlock;
|
|
206
|
-
}
|
|
207
|
-
if (policy === "allowed-control-plane") return;
|
|
208
|
-
const nodeExecBlock = resolveCodexNativeNodeExecBlock({
|
|
209
|
-
config: params.config,
|
|
210
|
-
sessionKey: params.sessionKey,
|
|
211
|
-
sessionId: params.sessionId,
|
|
212
|
-
surface: `app-server method \`${params.method}\``
|
|
213
|
-
});
|
|
214
|
-
if (nodeExecBlock) return nodeExecBlock;
|
|
215
|
-
const sessionKey = params.sessionKey?.trim() || params.sessionId?.trim();
|
|
216
|
-
if (!sessionKey) return;
|
|
217
|
-
const sandboxBlock = resolveCodexNativeSandboxBlock({
|
|
218
|
-
config: params.config,
|
|
219
|
-
sessionKey,
|
|
220
|
-
sandbox: params.sandbox,
|
|
221
|
-
surface: `app-server method \`${params.method}\``
|
|
222
|
-
});
|
|
223
|
-
if (!sandboxBlock) return;
|
|
224
|
-
if (policy === "requires-openclaw-environment" && hasOpenClawSandboxEnvironmentSelection(params.requestParams)) return;
|
|
225
|
-
return sandboxBlock;
|
|
226
|
-
}
|
|
227
|
-
/** Resolves the generic native-execution block for sandboxed or node-hosted sessions. */
|
|
228
|
-
function resolveCodexNativeExecutionBlock(params) {
|
|
229
|
-
return resolveCodexNativeSandboxBlock(params) ?? resolveCodexNativeNodeExecBlock(params);
|
|
230
|
-
}
|
|
231
|
-
/** Returns a block message when native Codex execution cannot honor active sandboxing. */
|
|
232
|
-
function resolveCodexNativeSandboxBlock(params) {
|
|
233
|
-
if (params.sandboxEnvironmentSelected) return;
|
|
234
|
-
const sessionKey = params.sessionKey?.trim() || params.sessionId?.trim();
|
|
235
|
-
if (!sessionKey) return;
|
|
236
|
-
if (isCodexRemoteExecPlacementSandbox(params.sandbox) || params.sandbox?.enabled === true) return formatCodexNativeSandboxBlock({ surface: params.surface });
|
|
237
|
-
const sandboxAgentId = parseAgentSessionKey(sessionKey)?.agentId ?? params.agentId ?? tryResolveDefaultAgentId(params.config ?? {});
|
|
238
|
-
if (!sandboxAgentId) return;
|
|
239
|
-
if (!resolveSandboxRuntimeStatus({
|
|
240
|
-
cfg: params.config,
|
|
241
|
-
sessionKey,
|
|
242
|
-
agentId: sandboxAgentId,
|
|
243
|
-
classificationAgentId: sandboxAgentId
|
|
244
|
-
}).sandboxed) return;
|
|
245
|
-
return formatCodexNativeSandboxBlock({ surface: params.surface });
|
|
246
|
-
}
|
|
247
|
-
function resolveDirectMethodPolicy(method) {
|
|
248
|
-
const exact = DIRECT_METHOD_POLICIES.get(method);
|
|
249
|
-
if (exact) return exact;
|
|
250
|
-
if (BLOCKED_DIRECT_METHOD_PREFIXES.some((prefix) => method.startsWith(prefix))) return "blocked-native-bypass";
|
|
251
|
-
return "blocked-native-bypass";
|
|
252
|
-
}
|
|
253
|
-
function hasOpenClawSandboxEnvironmentSelection(value) {
|
|
254
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
255
|
-
const environments = value.environments;
|
|
256
|
-
return Array.isArray(environments) && environments.length > 0 && environments.every((entry) => {
|
|
257
|
-
if (!entry || typeof entry !== "object" || Array.isArray(entry)) return false;
|
|
258
|
-
const environment = entry;
|
|
259
|
-
return typeof environment.environmentId === "string" && environment.environmentId.startsWith("openclaw-sandbox-") && typeof environment.cwd === "string" && environment.cwd.trim().length > 0;
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
function formatCodexNativeSandboxBlock(params) {
|
|
263
|
-
return [
|
|
264
|
-
`Codex-native ${params.surface} is unavailable because OpenClaw sandboxing is active for this session.`,
|
|
265
|
-
"This mode cannot route execution through the OpenClaw sandbox backend.",
|
|
266
|
-
"Use a normal Codex harness turn, or run an intentionally unsandboxed session."
|
|
267
|
-
].join(" ");
|
|
268
|
-
}
|
|
269
|
-
function resolveCodexNativeNodeExecBlock(params) {
|
|
270
|
-
const sessionKey = params.sessionKey?.trim() || params.sessionId?.trim();
|
|
271
|
-
const policy = resolveCodexNativeExecutionPolicy({
|
|
272
|
-
config: params.config,
|
|
273
|
-
sessionKey,
|
|
274
|
-
agentId: params.agentId,
|
|
275
|
-
readRuntimeSessionEntry: Boolean(sessionKey)
|
|
276
|
-
});
|
|
277
|
-
if (policy.nativeToolSurfaceAllowed) return;
|
|
278
|
-
return formatCodexNativeNodeExecBlock({
|
|
279
|
-
surface: params.surface,
|
|
280
|
-
reason: policy.blockReason
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
//#endregion
|
|
284
|
-
//#region extensions/codex/src/app-server/request.ts
|
|
285
|
-
var request_exports = /* @__PURE__ */ __exportAll({
|
|
286
|
-
CodexAppServerScopedRequestRejectedError: () => CodexAppServerScopedRequestRejectedError,
|
|
287
|
-
readCodexAppServerUsage: () => readCodexAppServerUsage,
|
|
288
|
-
requestCodexAppServerClientJson: () => requestCodexAppServerClientJson,
|
|
289
|
-
requestCodexAppServerJson: () => requestCodexAppServerJson,
|
|
290
|
-
withCodexAppServerJsonClient: () => withCodexAppServerJsonClient
|
|
291
|
-
});
|
|
292
|
-
/** Sends one guarded request over a client lease owned by the caller. */
|
|
293
|
-
async function requestCodexAppServerClientJson(params) {
|
|
294
|
-
const sandboxBlock = resolveCodexAppServerDirectSandboxBypassBlock({
|
|
295
|
-
method: params.method,
|
|
296
|
-
requestParams: params.requestParams,
|
|
297
|
-
config: params.config,
|
|
298
|
-
sessionKey: params.sessionKey,
|
|
299
|
-
sessionId: params.sessionId
|
|
300
|
-
});
|
|
301
|
-
if (sandboxBlock) throw new Error(sandboxBlock);
|
|
302
|
-
const timeoutMs = params.timeoutMs ?? 6e4;
|
|
303
|
-
return await withTimeout(params.client.request(params.method, params.requestParams, {
|
|
304
|
-
timeoutMs,
|
|
305
|
-
signal: params.signal,
|
|
306
|
-
...params.assertCurrent ? { assertCurrent: () => assertRequestOwnerCurrent(params.assertCurrent) } : {}
|
|
307
|
-
}), timeoutMs, `codex app-server ${params.method} timed out`);
|
|
308
|
-
}
|
|
309
|
-
async function requestCodexAppServerJson(params) {
|
|
310
|
-
const sandboxBlock = resolveCodexAppServerDirectSandboxBypassBlock({
|
|
311
|
-
method: params.method,
|
|
312
|
-
requestParams: params.requestParams,
|
|
313
|
-
config: params.config,
|
|
314
|
-
sessionKey: params.sessionKey,
|
|
315
|
-
sessionId: params.sessionId
|
|
316
|
-
});
|
|
317
|
-
if (sandboxBlock) throw new Error(sandboxBlock);
|
|
318
|
-
return await withCodexAppServerJsonClient({
|
|
319
|
-
...params,
|
|
320
|
-
timeoutMessage: `codex app-server ${params.method} timed out`
|
|
321
|
-
}, async (request) => await request({
|
|
322
|
-
method: params.method,
|
|
323
|
-
requestParams: params.requestParams
|
|
324
|
-
}));
|
|
325
|
-
}
|
|
326
|
-
/** A scoped guard rejected the request before a physical write. */
|
|
327
|
-
var CodexAppServerScopedRequestRejectedError = class extends Error {
|
|
328
|
-
constructor(message, options) {
|
|
329
|
-
super(message, options);
|
|
330
|
-
this.name = "CodexAppServerScopedRequestRejectedError";
|
|
331
|
-
}
|
|
332
|
-
};
|
|
333
|
-
function assertRequestOwnerCurrent(assertCurrent) {
|
|
334
|
-
try {
|
|
335
|
-
assertCurrent?.();
|
|
336
|
-
} catch (cause) {
|
|
337
|
-
throw new CodexAppServerScopedRequestRejectedError(cause instanceof Error ? cause.message : String(cause), { cause });
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
const CODEX_USAGE_ISOLATED_SHUTDOWN = {
|
|
341
|
-
forceKillDelayMs: 200,
|
|
342
|
-
exitTimeoutMs: 300
|
|
343
|
-
};
|
|
344
|
-
const CODEX_ACCOUNT_READ_MAX_TIMEOUT_MS = 4e3;
|
|
345
|
-
const CODEX_USAGE_DEADLINE_RESERVE_MS = CODEX_USAGE_ISOLATED_SHUTDOWN.forceKillDelayMs + CODEX_USAGE_ISOLATED_SHUTDOWN.exitTimeoutMs + 250;
|
|
346
|
-
/** Reads rate limits and best-effort account identity from one isolated app-server session. */
|
|
347
|
-
async function readCodexAppServerUsage(options) {
|
|
348
|
-
const deadline = Date.now() + options.timeoutMs;
|
|
349
|
-
return await withCodexAppServerJsonClient({
|
|
350
|
-
timeoutMs: options.timeoutMs,
|
|
351
|
-
timeoutMessage: "codex app-server usage read timed out",
|
|
352
|
-
agentDir: options.agentDir,
|
|
353
|
-
...options.authProfileId ? { authProfileId: options.authProfileId } : {},
|
|
354
|
-
config: options.config,
|
|
355
|
-
startOptions: options.startOptions,
|
|
356
|
-
isolated: true,
|
|
357
|
-
isolatedShutdown: CODEX_USAGE_ISOLATED_SHUTDOWN
|
|
358
|
-
}, async (request) => {
|
|
359
|
-
const rateLimits = await request({ method: "account/rateLimits/read" });
|
|
360
|
-
const accountEmail = await readCodexAccountEmailBestEffort(request, deadline);
|
|
361
|
-
return {
|
|
362
|
-
rateLimits,
|
|
363
|
-
...accountEmail ? { accountEmail } : {}
|
|
364
|
-
};
|
|
365
|
-
});
|
|
366
|
-
}
|
|
367
|
-
function extractCodexAccountEmail(value) {
|
|
368
|
-
if (!value || typeof value !== "object") return;
|
|
369
|
-
const record = value;
|
|
370
|
-
const account = record.account && typeof record.account === "object" ? record.account : record;
|
|
371
|
-
const email = account.email ?? account.accountEmail;
|
|
372
|
-
return typeof email === "string" && email.trim() ? email.trim() : void 0;
|
|
373
|
-
}
|
|
374
|
-
async function readCodexAccountEmailBestEffort(request, deadline) {
|
|
375
|
-
const boundMs = Math.min(CODEX_ACCOUNT_READ_MAX_TIMEOUT_MS, deadline - Date.now() - CODEX_USAGE_DEADLINE_RESERVE_MS);
|
|
376
|
-
if (boundMs <= 0) return;
|
|
377
|
-
const read = request({
|
|
378
|
-
method: "account/read",
|
|
379
|
-
requestParams: {}
|
|
380
|
-
}).then((account) => extractCodexAccountEmail(account), () => void 0);
|
|
381
|
-
let timer;
|
|
382
|
-
const timeout = new Promise((resolve) => {
|
|
383
|
-
timer = setTimeout(() => resolve(void 0), boundMs);
|
|
384
|
-
timer.unref?.();
|
|
385
|
-
});
|
|
386
|
-
try {
|
|
387
|
-
return await Promise.race([read, timeout]);
|
|
388
|
-
} finally {
|
|
389
|
-
if (timer) clearTimeout(timer);
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
/**
|
|
393
|
-
* Runs several guarded requests over one acquired client (shared lease or
|
|
394
|
-
* isolated child) so related reads see the same app-server session. The whole
|
|
395
|
-
* callback re-runs once when the client's start selection changed underneath it.
|
|
396
|
-
*/
|
|
397
|
-
async function withCodexAppServerJsonClient(params, run) {
|
|
398
|
-
const timeoutMs = params.timeoutMs ?? 6e4;
|
|
399
|
-
const timeoutMessage = params.timeoutMessage ?? "codex app-server request timed out";
|
|
400
|
-
const timeoutController = new AbortController();
|
|
401
|
-
const deadline = Number.isFinite(timeoutMs) && timeoutMs > 0 ? Date.now() + timeoutMs : void 0;
|
|
402
|
-
const isPastDeadline = () => deadline !== void 0 && Date.now() >= deadline;
|
|
403
|
-
const throwIfAbandoned = () => {
|
|
404
|
-
if (timeoutController.signal.aborted || isPastDeadline()) throw new CodexAppServerScopedRequestRejectedError(timeoutMessage);
|
|
405
|
-
};
|
|
406
|
-
const remainingTimeoutMs = () => {
|
|
407
|
-
throwIfAbandoned();
|
|
408
|
-
return deadline === void 0 ? timeoutMs : Math.max(1, deadline - Date.now());
|
|
409
|
-
};
|
|
410
|
-
try {
|
|
411
|
-
return await withTimeout((async () => {
|
|
412
|
-
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
413
|
-
throwIfAbandoned();
|
|
414
|
-
const client = await (params.isolated ? createIsolatedCodexAppServerClient : getLeasedSharedCodexAppServerClient)({
|
|
415
|
-
startOptions: params.startOptions,
|
|
416
|
-
pluginConfig: params.pluginConfig,
|
|
417
|
-
timeoutMs: remainingTimeoutMs(),
|
|
418
|
-
authProfileId: params.authProfileId,
|
|
419
|
-
authProfileStore: params.authProfileStore,
|
|
420
|
-
authBindingFingerprint: params.authBindingFingerprint,
|
|
421
|
-
preparedAuth: params.preparedAuth,
|
|
422
|
-
authRequirement: params.authRequirement,
|
|
423
|
-
agentDir: params.agentDir,
|
|
424
|
-
config: params.config,
|
|
425
|
-
abandonSignal: timeoutController.signal
|
|
426
|
-
});
|
|
427
|
-
let scopeActive = true;
|
|
428
|
-
const assertCurrent = () => {
|
|
429
|
-
throwIfAbandoned();
|
|
430
|
-
if (!scopeActive) throw new CodexAppServerScopedRequestRejectedError("Codex app-server request scope is closed");
|
|
431
|
-
assertRequestOwnerCurrent(params.assertCurrent);
|
|
432
|
-
};
|
|
433
|
-
try {
|
|
434
|
-
assertCurrent();
|
|
435
|
-
const scopedRequest = async (request) => {
|
|
436
|
-
const sandboxBlock = resolveCodexAppServerDirectSandboxBypassBlock({
|
|
437
|
-
method: request.method,
|
|
438
|
-
requestParams: request.requestParams,
|
|
439
|
-
config: params.config,
|
|
440
|
-
sessionKey: params.sessionKey,
|
|
441
|
-
sessionId: params.sessionId
|
|
442
|
-
});
|
|
443
|
-
if (sandboxBlock) throw new CodexAppServerScopedRequestRejectedError(sandboxBlock);
|
|
444
|
-
assertCurrent();
|
|
445
|
-
return await client.request(request.method, request.requestParams, {
|
|
446
|
-
timeoutMs: remainingTimeoutMs(),
|
|
447
|
-
signal: timeoutController.signal,
|
|
448
|
-
assertCurrent
|
|
449
|
-
});
|
|
450
|
-
};
|
|
451
|
-
return await run(scopedRequest, client, { assertCurrent });
|
|
452
|
-
} catch (error) {
|
|
453
|
-
if (!isCodexAppServerStartSelectionChangedError(error) || attempt > 0) throw error;
|
|
454
|
-
if (!params.isolated) retireSharedCodexAppServerClientIfCurrent(client);
|
|
455
|
-
throwIfAbandoned();
|
|
456
|
-
} finally {
|
|
457
|
-
scopeActive = false;
|
|
458
|
-
if (params.isolated) await client.closeAndWait({
|
|
459
|
-
exitTimeoutMs: params.isolatedShutdown?.exitTimeoutMs ?? 2e3,
|
|
460
|
-
forceKillDelayMs: params.isolatedShutdown?.forceKillDelayMs ?? 250
|
|
461
|
-
});
|
|
462
|
-
else releaseLeasedSharedCodexAppServerClient(client);
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
throw new Error("Codex app-server selection retry loop exited unexpectedly");
|
|
466
|
-
})(), timeoutMs, timeoutMessage);
|
|
467
|
-
} catch (error) {
|
|
468
|
-
if (isPastDeadline()) throw new Error(timeoutMessage, { cause: error });
|
|
469
|
-
throw error;
|
|
470
|
-
} finally {
|
|
471
|
-
timeoutController.abort();
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
//#endregion
|
|
475
|
-
export { request_exports as a, resolveCodexNativeSandboxBlock as c, requestCodexAppServerJson as i, resolveCodexNativeExecutionPolicy as l, readCodexAppServerUsage as n, withCodexAppServerJsonClient as o, requestCodexAppServerClientJson as r, resolveCodexNativeExecutionBlock as s, CodexAppServerScopedRequestRejectedError as t, resolveCodexNodeExecToolOverrides as u };
|