




















@@ -430,6 +430,19 @@ function resolveCodexPluginAppCacheCodexHome(
430430return appServer.start.transport === "stdio" ? resolveCodexAppServerHomeDir(agentDir) : undefined;
431431}
432432433+function restrictCodexAppServerSandboxForOpenClawSandbox(
434+appServer: CodexAppServerRuntimeOptions,
435+sandbox: Awaited<ReturnType<typeof resolveSandboxContext>>,
436+): CodexAppServerRuntimeOptions {
437+if (!sandbox?.enabled || appServer.sandbox !== "danger-full-access") {
438+return appServer;
439+}
440+return {
441+ ...appServer,
442+sandbox: "workspace-write",
443+};
444+}
445+433446export async function runCodexAppServerAttempt(
434447params: EmbeddedRunAttemptParams,
435448options: {
@@ -449,12 +462,7 @@ export async function runCodexAppServerAttempt(
449462const attemptStartedAt = Date.now();
450463const attemptClientFactory = resolveCodexAppServerClientFactory();
451464const pluginConfig = readCodexPluginConfig(options.pluginConfig);
452-const appServer = resolveCodexAppServerRuntimeOptions({ pluginConfig });
453-let pluginAppServer: CodexAppServerRuntimeOptions = appServer;
454-const nativeHookRelayEvents = resolveCodexNativeHookRelayEvents({
455-configuredEvents: options.nativeHookRelay?.events,
456- appServer,
457-});
465+const configuredAppServer = resolveCodexAppServerRuntimeOptions({ pluginConfig });
458466const resolvedWorkspace = resolveUserPath(params.workspaceDir);
459467await fs.mkdir(resolvedWorkspace, { recursive: true });
460468const sandboxSessionKey =
@@ -470,6 +478,12 @@ export async function runCodexAppServerAttempt(
470478 : sandbox.workspaceDir
471479 : resolvedWorkspace;
472480await fs.mkdir(effectiveWorkspace, { recursive: true });
481+const appServer = restrictCodexAppServerSandboxForOpenClawSandbox(configuredAppServer, sandbox);
482+let pluginAppServer: CodexAppServerRuntimeOptions = appServer;
483+const nativeHookRelayEvents = resolveCodexNativeHookRelayEvents({
484+configuredEvents: options.nativeHookRelay?.events,
485+ appServer,
486+});
473487474488const runAbortController = new AbortController();
475489const abortFromUpstream = () => {
@@ -2955,6 +2969,7 @@ export const __testing = {
29552969 handleDynamicToolCallWithTimeout,
29562970 resolveDynamicToolCallTimeoutMs,
29572971 resolveCodexPluginAppCacheEndpoint,
2972+ restrictCodexAppServerSandboxForOpenClawSandbox,
29582973 resolveOpenClawCodingToolsSessionKeys,
29592974 shouldForceMessageTool,
29602975setOpenClawCodingToolsFactoryForTests(factory: OpenClawCodingToolsFactory): void {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。