feat(openclaw): improve dispatcher and integration

🤖 Generated with assistance of OhMyOpenCode
This commit is contained in:
YeonGyu-Kim
2026-03-31 17:33:45 -07:00
parent 94a2b8ec2c
commit 366ebb33c4
3 changed files with 66 additions and 3 deletions
+23 -3
View File
@@ -141,18 +141,17 @@ export async function wakeCommandGateway(
return shellEscapeArg(value)
})
// Always use sh -c to handle the shell command string correctly
const proc = spawn(["sh", "-c", interpolated], {
env: { ...process.env },
stdout: "ignore",
stderr: "ignore",
detached: process.platform !== "win32",
})
// Handle timeout manually
let timeoutId: ReturnType<typeof setTimeout> | undefined
const timeoutPromise = new Promise<never>((_, reject) => {
timeoutId = setTimeout(() => {
proc.kill()
terminateCommandProcess(proc, "SIGKILL")
reject(new Error("Command timed out"))
}, timeout)
})
@@ -178,3 +177,24 @@ export async function wakeCommandGateway(
}
}
}
type KillableProcess = {
pid?: number
kill: (signal?: NodeJS.Signals) => void
}
export function terminateCommandProcess(proc: KillableProcess, signal: NodeJS.Signals): void {
try {
if (process.platform !== "win32" && proc.pid) {
try {
process.kill(-proc.pid, signal)
return
} catch {
proc.kill(signal)
return
}
}
proc.kill(signal)
} catch {}
}