Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

fix(server): allow install scripts in npm-global provider updates (#5646)

JJdc0ff8f13eaa
diff --git a/apps/server/src/provider/providerMaintenance.test.ts b/apps/server/src/provider/providerMaintenance.test.ts
index 8937844f6..5683da2c1 100644
--- a/apps/server/src/provider/providerMaintenance.test.ts
+++ b/apps/server/src/provider/providerMaintenance.test.ts
@@ -176,7 +176,8 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
status: "behind_latest",
currentVersion: "2.1.110",
latestVersion: "2.1.117",
- updateCommand: "npm install -g @example/native-package-tool@latest",
+ updateCommand:
+ "npm install -g --allow-scripts=@example/native-package-tool @example/native-package-tool@latest",
canUpdate: true,
message: "Install the update now or review provider settings.",
});
@@ -482,11 +483,17 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
provider: driver("packageTool"),
packageName: "@example/package-tool",
update: {
- command: "npm install -g @example/package-tool@latest",
+ command:
+ "npm install -g --allow-scripts=@example/package-tool @example/package-tool@latest",
executable: "npm",
- args: ["install", "-g", "@example/package-tool@latest"],
+ args: [
+ "install",
+ "-g",
+ "--allow-scripts=@example/package-tool",
+ "@example/package-tool@latest",
+ ],
lockKey: "npm-global",
},
@@ -541,6 +548,40 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
}),
);
+ it("allows the package's own install scripts in npm global updates", () => {
+ const claudeUpdate = makePackageManagedProviderMaintenanceResolver({
+ provider: driver("claudeAgent"),
+ npmPackageName: "@anthropic-ai/claude-code",
+ homebrewFormula: "claude-code",
+ nativeUpdate: {
+ executable: "claude",
+ args: ["update"],
+ lockKey: "claude-native",
+ isCommandPath: isNativeTestCommandPath("/.local/bin/claude"),
+ },
+ });
+
+ expect(claudeUpdate.resolve()).toEqual({
+ provider: driver("claudeAgent"),
+ packageName: "@anthropic-ai/claude-code",
+ update: {
+ command:
+ "npm install -g --allow-scripts=@anthropic-ai/claude-code @anthropic-ai/claude-code@latest",
+
+ executable: "npm",
+
+ args: [
+ "install",
+ "-g",
+ "--allow-scripts=@anthropic-ai/claude-code",
+ "@anthropic-ai/claude-code@latest",
+ ],
+
+ lockKey: "npm-global",
+ },
+ });
+ });
+
it("disables one-click updates for explicit custom binary paths it cannot safely map", () => {
expect(
packageToolUpdate.resolve({
diff --git a/apps/server/src/provider/providerMaintenance.ts b/apps/server/src/provider/providerMaintenance.ts
index 8645f9f94..14d17cf36 100644
--- a/apps/server/src/provider/providerMaintenance.ts
+++ b/apps/server/src/provider/providerMaintenance.ts
@@ -137,7 +137,17 @@ function makeNpmGlobalProviderMaintenanceCapabilities(
provider: definition.provider,
packageName: definition.npmPackageName,
updateExecutable: "npm",
- updateArgs: ["install", "-g", `${definition.npmPackageName}@latest`],
+ // npm 12 blocks install scripts by default (empty allow-scripts allowlist)
+ // and still exits 0, so a package whose postinstall finishes the install
+ // (claude copies its native binary over a placeholder stub) is left broken
+ // while the update reports success. Allow this one package's scripts.
+ // Older npm warns about the unknown config and continues.
+ updateArgs: [
+ "install",
+ "-g",
+ `--allow-scripts=${definition.npmPackageName}`,
+ `${definition.npmPackageName}@latest`,
+ ],
updateLockKey: "npm-global",
});
}