The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 08:30 UTC
fix(provider-grok): grok update keeps a script install on Grok's own updater under npx (#37917)
Julius Marminge committed
Nov 16, 2026 at 21:01 UTC
90a098bb4b5f22bb9178f1e4d129a0e09bedccbb
2 files changed
+46
-1
packages/provider-grok/src/server/driver.test.ts
+39
@@ -172,6 +172,45 @@ it.layer(layerTest)("GrokDriver", (it) => {
172
});
173
}
174
175
+ // An `npx t3` server inherits npm_config_user_agent, which Grok ranks above `[cli] installer`.
176
+ it.effect.skipIf(windowsHost)("keeps a script install off the npm updater under npx", () =>
177
+ Effect.gen(function* () {
178
+ const fs = yield* FileSystem.FileSystem;
179
+ const path = yield* Path.Path;
180
+ const home = yield* fs.realPath(yield* fs.makeTempDirectoryScoped({ prefix: "t3-grok-" }));
181
+ const downloaded = path.join(home, ".grok", "downloads", "grok-linux-x86_64");
182
+ const binaryPath = path.join(home, ".grok", "bin", "grok");
183
+ yield* fs.makeDirectory(path.dirname(downloaded), { recursive: true });
184
+ yield* fs.makeDirectory(path.dirname(binaryPath), { recursive: true });
185
+ yield* fs.writeFileString(downloaded, "#!/bin/sh\n");
186
+ yield* fs.chmod(downloaded, 0o755);
187
+ yield* fs.symlink(downloaded, binaryPath);
188
+
189
+ const instance = yield* GrokDriver.create({
190
+ instanceId: ProviderInstanceId.make("grok-script"),
191
+ displayName: "Grok test",
192
+ enabled: false,
193
+ environment: [
194
+ {
195
+ name: "npm_config_user_agent",
196
+ value: "npm/11.6.2 node/v24.11.0 linux x64 workspaces/false",
197
+ sensitive: false,
198
+ },
199
+ ],
200
+ config: { ...GrokDriver.defaultConfig(), binaryPath },
201
+ });
202
+ const updateEnv = (yield* instance.snapshot.resolveMaintenance()).update?.env ?? {};
203
+ // The maintenance runner spawns with extendEnv, layering this over the server's process.env.
204
+ const env: NodeJS.ProcessEnv = {
205
+ npm_config_user_agent: "npm/11.6.2 node/v24.11.0",
206
+ ...updateEnv,
207
+ };
208
+ expect(env.GROK_INSTALLER === "internal" || env.npm_config_user_agent === undefined).toBe(
209
+ true,
210
+ );
211
+ }).pipe(Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, noSpawner)),
212
+ );
213
+
214
it.effect("stays manual-only when the configured executable does not exist", () =>
215
Effect.gen(function* () {
216
const fs = yield* FileSystem.FileSystem;
packages/provider-grok/src/server/driver.ts
+7
-1
@@ -99,7 +99,13 @@ const UPDATE: ProviderMaintenanceCapabilitiesResolver = {
99
updateArgs: ["update"],
100
updateLockKey: "grok",
101
platform: context.platform,
102
- env: { ...context.env, npm_config_allow_scripts: GROK_NPM_PACKAGE },
102
+ env: {
103
+ ...context.env,
104
+ npm_config_allow_scripts: GROK_NPM_PACKAGE,
105
+ // An npx-launched server's npm_config_user_agent outranks Grok's `[cli] installer`, steering
106
+ // a script install to npm. The runner extends process.env; only undefined removes a key.
107
+ npm_config_user_agent: undefined,
108
+ },
109
});
110
}),
111
};