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, 16:00 UTC
fix(devices): explain missing npm during tool updates (#27084)
Co-authored-by: maria-rcks <maria@kuuro.net> Co-authored-by: Julius Marminge <julius0216@outlook.com>
Kristof Katzenberger committed
Nov 14, 2026 at 11:40 UTC
060ac23d6f827f101d5c906f2ba2df51f14d66ce
3 files changed
+81
-60
apps/server/src/device/DeviceService.test.ts
+75
-58
@@ -1782,67 +1782,84 @@ it.effect("reconciles SSH host settings without publishing no-op changes", () =>
1782
),
1783
);
1784
1785
-it.effect("a failed tool update reports npm's exit code but not its output", () =>
1786
- Effect.gen(function* () {
1787
- const host: DeviceHost.DeviceHost["Service"] = {
1788
- id: LOCAL_DEVICE_HOST_ID,
1789
- label: "This machine",
1790
- summary: Effect.succeed({
1785
+it.effect.each(["exit", "missing"] as const)(
1786
+ "a failed tool update reports a safe %s failure",
1787
+ (failure) =>
1788
+ Effect.gen(function* () {
1789
+ const host: DeviceHost.DeviceHost["Service"] = {
1790
id: LOCAL_DEVICE_HOST_ID,
1792
- kind: "local",
1793
- label: "Test server",
1794
- platforms: [],
1795
- hubInstalled: false,
1796
- agentDeviceInstalled: false,
1797
- }),
1798
- platformAvailability: (platform) => Effect.succeed({ platform, available: false }),
1799
- ensureReady: () => Effect.die("Updating a tool does not start the hub"),
1800
- ensureAgentReady: () => Effect.die("Updating a tool does not start the agent"),
1801
- current: Effect.succeed(null),
1802
- stopAgent: Effect.void,
1803
- stop: Effect.void,
1804
- };
1805
- const npmFailure = {
1806
- code: ChildProcessSpawner.ExitCode(243),
1807
- stdout: "",
1808
- stderr: "npm error EACCES https://private:credential@registry.example.test/expo-device-hub",
1809
- timedOut: false,
1810
- stdoutTruncated: false,
1811
- stderrTruncated: false,
1812
- stdoutInvalidUtf8: false,
1813
- stderrInvalidUtf8: false,
1814
- };
1815
- const service = yield* DeviceService.make.pipe(
1816
- Effect.provideService(DeviceHost.DeviceHost, host),
1817
- Effect.provideService(ProcessRunner.ProcessRunner, {
1818
- run: () => Effect.succeed(npmFailure),
1819
- }),
1820
- Effect.provideService(
1821
- HttpClient.HttpClient,
1822
- HttpClient.make(() => Effect.die("Updating a tool makes no hub requests")),
1823
- ),
1824
- );
1791
+ label: "This machine",
1792
+ summary: Effect.succeed({
1793
+ id: LOCAL_DEVICE_HOST_ID,
1794
+ kind: "local",
1795
+ label: "Test server",
1796
+ platforms: [],
1797
+ hubInstalled: false,
1798
+ agentDeviceInstalled: false,
1799
+ }),
1800
+ platformAvailability: (platform) => Effect.succeed({ platform, available: false }),
1801
+ ensureReady: () => Effect.die("Updating a tool does not start the hub"),
1802
+ ensureAgentReady: () => Effect.die("Updating a tool does not start the agent"),
1803
+ current: Effect.succeed(null),
1804
+ stopAgent: Effect.void,
1805
+ stop: Effect.void,
1806
+ };
1807
+ const npmFailure = {
1808
+ code: ChildProcessSpawner.ExitCode(243),
1809
+ stdout: "",
1810
+ stderr: "npm error EACCES https://private:credential@registry.example.test/expo-device-hub",
1811
+ timedOut: false,
1812
+ stdoutTruncated: false,
1813
+ stderrTruncated: false,
1814
+ stdoutInvalidUtf8: false,
1815
+ stderrInvalidUtf8: false,
1816
+ };
1817
+ const service = yield* DeviceService.make.pipe(
1818
+ Effect.provideService(DeviceHost.DeviceHost, host),
1819
+ Effect.provideService(ProcessRunner.ProcessRunner, {
1820
+ run: ({ command, args }) =>
1821
+ failure === "exit"
1822
+ ? Effect.succeed(npmFailure)
1823
+ : Effect.fail(
1824
+ new ProcessRunner.ProcessSpawnError({
1825
+ command,
1826
+ argumentCount: args.length,
1827
+ cause: PlatformError.systemError({
1828
+ _tag: "NotFound",
1829
+ module: "ChildProcess",
1830
+ method: "spawn",
1831
+ description: "private diagnostic text",
1832
+ }),
1833
+ }),
1834
+ ),
1835
+ }),
1836
+ Effect.provideService(
1837
+ HttpClient.HttpClient,
1838
+ HttpClient.make(() => Effect.die("Updating a tool makes no hub requests")),
1839
+ ),
1840
+ );
1841
1826
- const error = yield* service.updateTool("hub").pipe(Effect.flip);
1827
- expect(error).toMatchObject({
1828
- _tag: "DeviceOperationError",
1829
- reason: "command_failed",
1830
- exitCode: 243,
1831
- });
1832
- expect(error.message).toBe(
1833
- "Device update device tool failed: The device command failed (exit code 243).",
1834
- );
1835
- }).pipe(
1836
- Effect.provide(
1837
- Layer.mergeAll(
1838
- ServerSettings.layerTest({ enableDeviceSupport: true }),
1839
- layerSecretResolver,
1840
- ServerConfig.layerTest(process.cwd(), { prefix: "t3-device-update-" }),
1841
- NodeCrypto.layer,
1842
- NetService.layer,
1843
- ).pipe(Layer.provideMerge(NodeServices.layer)),
1842
+ const error = yield* service.updateTool("hub").pipe(Effect.flip);
1843
+ expect(error).toMatchObject({
1844
+ _tag: "DeviceOperationError",
1845
+ reason: failure === "exit" ? "command_failed" : "package_manager_missing",
1846
+ });
1847
+ expect(error.message).toBe(
1848
+ failure === "exit"
1849
+ ? "Device update device tool failed: The device command failed (exit code 243)."
1850
+ : "Device update device tool failed: Device support needs npm, which is not on the T3 server's PATH. Install npm (it comes with Node.js from nodejs.org), restart T3 Code, then retry.",
1851
+ );
1852
+ }).pipe(
1853
+ Effect.provide(
1854
+ Layer.mergeAll(
1855
+ ServerSettings.layerTest({ enableDeviceSupport: true }),
1856
+ layerSecretResolver,
1857
+ ServerConfig.layerTest(process.cwd(), { prefix: "t3-device-update-" }),
1858
+ NodeCrypto.layer,
1859
+ NetService.layer,
1860
+ ).pipe(Layer.provideMerge(NodeServices.layer)),
1861
+ ),
1862
),
1845
- ),
1863
);
1864
1865
describe("agent session release on close", () => {
apps/server/src/device/DeviceService.ts
+3
-2
@@ -1430,8 +1430,9 @@ export const make = Effect.gen(function* () {
1430
(cause) =>
1431
new DeviceOperationError({
1432
operation: "update device tool",
1433
- reason: "command_failed",
1434
- // Only the exit code goes into the shown message; npm's stderr can carry registry credentials.
1433
+ reason:
1434
+ cause.reason === "npm_not_found" ? "package_manager_missing" : "command_failed",
1435
+ // npm's stderr can carry registry credentials; expose only the reason and exit code.
1436
...(cause.exitCode !== undefined ? { exitCode: cause.exitCode } : {}),
1437
cause,
1438
}),
packages/contracts/src/device.ts
+3
@@ -588,6 +588,7 @@ export class DeviceOperationError extends Schema.TaggedError<DeviceOperationErro
588
"invalid_payload",
589
"settings_failed",
590
"hub_rejected",
591
+ "package_manager_missing",
592
]),
593
exitCode: Schema.optional(Schema.Number),
594
cause: Schema.Defect(),
@@ -600,6 +601,8 @@ export class DeviceOperationError extends Schema.TaggedError<DeviceOperationErro
601
invalid_payload: "The device request could not be encoded.",
602
settings_failed: "Could not read or save device settings.",
603
hub_rejected: "The device hub could not complete the request.",
604
+ package_manager_missing:
605
+ "Device support needs npm, which is not on the T3 server's PATH. Install npm (it comes with Node.js from nodejs.org), restart T3 Code, then retry.",
606
}[this.reason];
607
return `Device ${this.operation} failed: ${explanation}`;
608
}