mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-29 01:52:04 +00:00
fix(exec): skip gateway cwd injection for remote node host
When exec runs with host=node and no explicit cwd is provided, the gateway was injecting its own process.cwd() as the default working directory. In cross-platform setups (e.g. Linux gateway + Windows node), this gateway-local path does not exist on the node, causing "SYSTEM_RUN_DENIED: approval requires an existing canonical cwd". This change detects when no explicit workdir was provided (neither via the tool call params.workdir nor via agent defaults.cwd) and passes undefined instead of the gateway cwd. This lets the remote node use its own default working directory. Changes: - bash-tools.exec.ts: Track whether workdir was explicitly provided; when host=node and no explicit workdir, pass undefined instead of gateway process.cwd() - bash-tools.exec-host-node.ts: Accept workdir as string | undefined; only send cwd to system.run.prepare when defined - bash-tools.exec-approval-request.ts: Accept workdir as string | undefined in HostExecApprovalParams Fixes #58934 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
committed by
Peter Steinberger
parent
8aceaf5d0f
commit
3b3191ab3a
@@ -35,7 +35,7 @@ import { listNodes, resolveNodeIdFromList } from "./tools/nodes-utils.js";
|
||||
|
||||
export type ExecuteNodeHostCommandParams = {
|
||||
command: string;
|
||||
workdir: string;
|
||||
workdir: string | undefined;
|
||||
env: Record<string, string>;
|
||||
requestedEnv?: Record<string, string>;
|
||||
requestedNode?: string;
|
||||
@@ -108,7 +108,7 @@ export async function executeNodeHostCommand(
|
||||
params: {
|
||||
command: argv,
|
||||
rawCommand: params.command,
|
||||
cwd: params.workdir,
|
||||
...(params.workdir != null ? { cwd: params.workdir } : {}),
|
||||
agentId: params.agentId,
|
||||
sessionKey: params.sessionKey,
|
||||
},
|
||||
@@ -121,7 +121,7 @@ export async function executeNodeHostCommand(
|
||||
}
|
||||
const runArgv = prepared.plan.argv;
|
||||
const runRawCommand = prepared.plan.commandText;
|
||||
const runCwd = prepared.plan.cwd ?? params.workdir;
|
||||
const runCwd = prepared.plan.cwd ?? params.workdir ?? undefined;
|
||||
const runAgentId = prepared.plan.agentId ?? params.agentId;
|
||||
const runSessionKey = prepared.plan.sessionKey ?? params.sessionKey;
|
||||
|
||||
@@ -453,3 +453,4 @@ export async function executeNodeHostCommand(
|
||||
} satisfies ExecToolDetails,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user