惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
Microsoft Azure Blog
Microsoft Azure Blog
aimingoo的专栏
aimingoo的专栏
Vercel News
Vercel News
U
Unit 42
L
LangChain Blog
J
Java Code Geeks
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
The Cloudflare Blog
F
Fortinet All Blogs
小众软件
小众软件
I
InfoQ
P
Proofpoint News Feed
D
DataBreaches.Net
Martin Fowler
Martin Fowler
H
Help Net Security
T
Tailwind CSS Blog
N
Netflix TechBlog - Medium
有赞技术团队
有赞技术团队
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
B
Blog RSS Feed
酷 壳 – CoolShell
酷 壳 – CoolShell
B
Blog

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix: restore npm shims on swap failure · openclaw/opencla...
shakkernerd · 2026-04-27 · via Recent Commits to openclaw:main

@@ -38,6 +38,15 @@ type StagedNpmInstall = {

3838

packageRoot: string;

3939

};

404041+

type NpmBinShimBackup = {

42+

backupDir: string;

43+

targetBinDir: string;

44+

entries: Array<{

45+

name: string;

46+

hadExisting: boolean;

47+

}>;

48+

};

49+4150

function formatError(err: unknown): string {

4251

return err instanceof Error ? err.message : String(err);

4352

}

@@ -51,6 +60,17 @@ async function pathExists(targetPath: string): Promise<boolean> {

5160

}

5261

}

536263+

async function readPackageVersionIfPresent(packageRoot: string | null): Promise<string | null> {

64+

if (!packageRoot) {

65+

return null;

66+

}

67+

try {

68+

return await readPackageVersion(packageRoot);

69+

} catch {

70+

return null;

71+

}

72+

}

73+5474

async function createStagedNpmInstall(

5575

installTarget: ResolvedGlobalInstallTarget,

5676

packageName: string,

@@ -152,12 +172,47 @@ async function replaceNpmBinShims(params: {

152172

return;

153173

}

154174155-

await fs.mkdir(params.targetLayout.binDir, { recursive: true });

156-

for (const entry of shimEntries) {

157-

await copyPathEntry(

158-

path.join(params.stageLayout.binDir, entry),

159-

path.join(params.targetLayout.binDir, entry),

160-

);

175+

const backup: NpmBinShimBackup = {

176+

backupDir: await fs.mkdtemp(

177+

path.join(params.targetLayout.globalRoot, ".openclaw-shim-backup-"),

178+

),

179+

targetBinDir: params.targetLayout.binDir,

180+

entries: [],

181+

};

182+183+

try {

184+

await fs.mkdir(params.targetLayout.binDir, { recursive: true });

185+

for (const entry of shimEntries) {

186+

const destination = path.join(params.targetLayout.binDir, entry);

187+

const hadExisting = await pathExists(destination);

188+

backup.entries.push({ name: entry, hadExisting });

189+

if (hadExisting) {

190+

await copyPathEntry(destination, path.join(backup.backupDir, entry));

191+

}

192+

}

193+194+

for (const entry of shimEntries) {

195+

await copyPathEntry(

196+

path.join(params.stageLayout.binDir, entry),

197+

path.join(params.targetLayout.binDir, entry),

198+

);

199+

}

200+

} catch (err) {

201+

await restoreNpmBinShimBackup(backup);

202+

throw err;

203+

} finally {

204+

await fs.rm(backup.backupDir, { recursive: true, force: true }).catch(() => undefined);

205+

}

206+

}

207+208+

async function restoreNpmBinShimBackup(backup: NpmBinShimBackup): Promise<void> {

209+

await fs.mkdir(backup.targetBinDir, { recursive: true });

210+

for (const entry of backup.entries) {

211+

const destination = path.join(backup.targetBinDir, entry.name);

212+

await fs.rm(destination, { recursive: true, force: true }).catch(() => undefined);

213+

if (entry.hadExisting) {

214+

await copyPathEntry(path.join(backup.backupDir, entry.name), destination);

215+

}

161216

}

162217

}

163218

@@ -318,34 +373,39 @@ export async function runGlobalPackageUpdateSteps(params: {

318373

}

319374

}

320375321-

let verifiedPackageRoot =

322-

stagedInstall?.packageRoot ??

376+

const livePackageRoot =

377+

params.installTarget.packageRoot ??

378+

params.packageRoot ??

323379

(

324380

await resolveGlobalInstallTarget({

325381

manager: params.installTarget,

326382

runCommand: params.runCommand,

327383

timeoutMs: params.timeoutMs,

328384

})

329385

).packageRoot ??

330-

params.packageRoot ??

331386

null;

387+

const verificationPackageRoot = stagedInstall?.packageRoot ?? livePackageRoot;

388+

let verifiedPackageRoot = livePackageRoot ?? verificationPackageRoot;

332389333390

let afterVersion: string | null = null;

334-

if (finalInstallStep.exitCode === 0 && verifiedPackageRoot) {

335-

afterVersion = await readPackageVersion(verifiedPackageRoot);

391+

if (finalInstallStep.exitCode === 0 && verificationPackageRoot) {

392+

const candidateVersion = await readPackageVersion(verificationPackageRoot);

393+

if (!stagedInstall) {

394+

afterVersion = candidateVersion;

395+

}

336396

const expectedVersion = resolveExpectedInstalledVersionFromSpec(

337397

params.packageName,

338398

params.installSpec,

339399

);

340400

const verificationErrors = await collectInstalledGlobalPackageErrors({

341-

packageRoot: verifiedPackageRoot,

401+

packageRoot: verificationPackageRoot,

342402

expectedVersion,

343403

});

344404

if (verificationErrors.length > 0) {

345405

steps.push({

346406

name: "global install verify",

347-

command: `verify ${verifiedPackageRoot}`,

348-

cwd: verifiedPackageRoot,

407+

command: `verify ${verificationPackageRoot}`,

408+

cwd: verificationPackageRoot,

349409

durationMs: 0,

350410

exitCode: 1,

351411

stderrTail: verificationErrors.join("\n"),

@@ -362,6 +422,7 @@ export async function runGlobalPackageUpdateSteps(params: {

362422

steps.push(swapStep);

363423

if (swapStep.exitCode === 0) {

364424

verifiedPackageRoot = params.installTarget.packageRoot ?? verifiedPackageRoot;

425+

afterVersion = candidateVersion;

365426

}

366427

}

367428

@@ -372,10 +433,15 @@ export async function runGlobalPackageUpdateSteps(params: {

372433

);

373434

const postVerifyStep = failedVerifyOrSwap

374435

? null

375-

: await params.postVerifyStep?.(verifiedPackageRoot);

436+

: verifiedPackageRoot

437+

? await params.postVerifyStep?.(verifiedPackageRoot)

438+

: null;

376439

if (postVerifyStep) {

377440

steps.push(postVerifyStep);

378441

}

442+

if (failedVerifyOrSwap && stagedInstall) {

443+

afterVersion = await readPackageVersionIfPresent(livePackageRoot);

444+

}

379445

}

380446381447

const failedStep =