fix: check workdir before spawn (#221)

The workdir used to spawn a agent command is provide by the agent tool,
we need to ensure its existence and fallback to process.cwd when not.

fix #212
This commit is contained in:
LouisLv
2025-04-17 22:14:12 +08:00
committed by GitHub
parent 4926cab476
commit af69e793e7

View File

@@ -204,11 +204,20 @@ async function execCommand(
runInSandbox: boolean,
abortSignal?: AbortSignal,
): Promise<ExecCommandSummary> {
let { workdir } = execInput;
if (workdir) {
try {
await access(workdir);
} catch (e) {
log(`EXEC workdir=${workdir} not found, use process.cwd() instead`);
workdir = process.cwd();
}
}
if (isLoggingEnabled()) {
if (applyPatchCommand != null) {
log("EXEC running apply_patch command");
} else {
const { cmd, workdir, timeoutInMillis } = execInput;
const { cmd, timeoutInMillis } = execInput;
// Seconds are a bit easier to read in log messages and most timeouts
// are specified as multiples of 1000, anyway.
const timeout =