diff --git a/scripts/crabbox-wrapper.mjs b/scripts/crabbox-wrapper.mjs index 7385c0ea390..f96bdbebd0c 100755 --- a/scripts/crabbox-wrapper.mjs +++ b/scripts/crabbox-wrapper.mjs @@ -2675,6 +2675,20 @@ function assertFullCheckoutAvailableBeforeExit(dir) { return false; } +function injectFullCheckoutLeaseReclaim(commandArgs) { + if ( + commandArgs[0] !== "run" || + !hasOption(commandArgs, "--id") || + hasOption(commandArgs, "--reclaim") + ) { + return commandArgs; + } + const normalizedArgs = [...commandArgs]; + const { optionEnd } = runCommandBounds(normalizedArgs); + normalizedArgs.splice(optionEnd, 0, "--reclaim"); + return normalizedArgs; +} + const version = checkedOutput(binary, ["--version"]); const help = checkedOutput(binary, ["run", "--help"]); const providerAliases = new Map([ @@ -2856,6 +2870,7 @@ try { const changedGateBase = isChangedGateCommand(runWords) ? mergeBaseForChangedGate() : ""; const checkout = prepareFullCheckoutForSync({ changedGateBase }); fullCheckout = checkout; + normalizedArgs = injectFullCheckoutLeaseReclaim(normalizedArgs); childCwd = checkout.dir; cleanupChildCwd = () => checkout.cleanup(); remoteChangedGateBase = checkout.changedGateBase; diff --git a/test/scripts/crabbox-wrapper.test.ts b/test/scripts/crabbox-wrapper.test.ts index d65440d94b5..6327c06efa0 100644 --- a/test/scripts/crabbox-wrapper.test.ts +++ b/test/scripts/crabbox-wrapper.test.ts @@ -3720,6 +3720,7 @@ describe.concurrent("scripts/crabbox-wrapper", () => { expect(result.status).toBe(0); expect(result.stderr).toContain("syncing from temporary full checkout"); + expect(parseFakeCrabboxOutput(result).args).toContain("--reclaim"); expect(parseFakeCrabboxOutput(result).cwd).toContain("openclaw-crabbox-sync-"); });