@@ -7,6 +7,8 @@ import { buildCmdExeCommandLine } from "../../../windows-cmd-helpers.mjs";
|
7 | 7 | |
8 | 8 | const args = process.argv.slice(2); |
9 | 9 | const command = args.shift(); |
| 10 | +export const CONFIG_COMMAND_TIMEOUT_MS = 120_000; |
| 11 | +export const CONFIG_COMMAND_MAX_BUFFER_BYTES = 4 * 1024 * 1024; |
10 | 12 | |
11 | 13 | function option(name, fallback) { |
12 | 14 | const index = args.indexOf(name); |
@@ -217,21 +219,34 @@ export function resolveUpgradeSurvivorOpenClawCommand(argv, params = {}) {
|
217 | 219 | }; |
218 | 220 | } |
219 | 221 | |
220 | | -function runOpenClaw(step) { |
| 222 | +function errorCode(error) { |
| 223 | +return error && typeof error === "object" && "code" in error ? String(error.code) : undefined; |
| 224 | +} |
| 225 | + |
| 226 | +export function runUpgradeSurvivorOpenClawStep(step, params = {}) { |
221 | 227 | const invocation = resolveUpgradeSurvivorOpenClawCommand(step.argv); |
222 | | -const result = spawnSync(invocation.command, invocation.args, { |
| 228 | +const run = params.spawnSyncCommand ?? spawnSync; |
| 229 | +const timeoutMs = params.timeoutMs ?? CONFIG_COMMAND_TIMEOUT_MS; |
| 230 | +const maxBuffer = params.maxBufferBytes ?? CONFIG_COMMAND_MAX_BUFFER_BYTES; |
| 231 | +const result = run(invocation.command, invocation.args, { |
223 | 232 | encoding: "utf8", |
224 | 233 | env: process.env, |
| 234 | +killSignal: "SIGTERM", |
| 235 | + maxBuffer, |
225 | 236 | shell: invocation.shell, |
| 237 | +timeout: timeoutMs, |
226 | 238 | windowsVerbatimArguments: invocation.windowsVerbatimArguments, |
227 | 239 | }); |
| 240 | +const code = errorCode(result.error); |
228 | 241 | return { |
229 | 242 | id: step.id, |
230 | 243 | intent: step.intent, |
231 | 244 | command: invocation.commandLabel, |
232 | 245 | status: result.status, |
233 | 246 | signal: result.signal, |
234 | | -ok: result.status === 0, |
| 247 | +ok: result.status === 0 && !result.error, |
| 248 | +errorCode: code, |
| 249 | +errorMessage: result.error?.message ? tail(result.error.message) : undefined, |
235 | 250 | stdout: tail(result.stdout), |
236 | 251 | stderr: tail(result.stderr), |
237 | 252 | }; |
@@ -268,11 +283,12 @@ function applyRecipe() {
|
268 | 283 | if (!adaptedStep) { |
269 | 284 | continue; |
270 | 285 | } |
271 | | -const outcome = runOpenClaw(adaptedStep); |
| 286 | +const outcome = runUpgradeSurvivorOpenClawStep(adaptedStep); |
272 | 287 | summary.steps.push(outcome); |
273 | 288 | writeJson(summaryPath, summary); |
274 | 289 | if (!outcome.ok) { |
275 | | -throw new Error(`baseline config recipe failed at ${step.id}`); |
| 290 | +const detail = outcome.errorCode ?? outcome.signal ?? outcome.status ?? "unknown"; |
| 291 | +throw new Error(`baseline config recipe failed at ${step.id}: ${detail}`); |
276 | 292 | } |
277 | 293 | } |
278 | 294 | } |
|