@devries-cameron20 / t3code-1 / commits / f328db30da
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

chore(server): keep the legacy service entry point to the npm package only (#11770)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>

Julius Marminge committed Sep 14, 2026 at 11:21 UTC f328db30da063a7bce9a9d038fc583d3ff83673a
5 files changed +25 -92
apps/server/src/cloud/pinnedRuntime.test.ts
-48
@@ -1,4 +1,3 @@
1 -import { HostProcessPlatform } from "@t3tools/shared/hostProcess";
1 import * as NodeServices from "@effect/platform-node/NodeServices";
2 import { assert, it } from "@effect/vitest";
3 import * as Deferred from "effect/Deferred";
@@ -95,19 +94,6 @@ it.layer(NodeServices.layer)("ensurePinnedRuntimeInstalled", (it) => {
94 assert.deepEqual(commands, ["tar"]);
95 assert.equal(yield* fs.readFileString(paths.sentinelPath), `${version}\n`);
96 assert.isFalse(yield* fs.exists(path.join(paths.versionDir, "t3-runtime-archive")));
98 - if ((yield* HostProcessPlatform) !== "win32") {
99 - // The old launcher must still be able to start this archive after the
100 - // first npm-to-executable update, including from the final directory.
101 - yield* fs.writeFileString(paths.entryPath, '#!/bin/sh\nprintf "%s\\n" "$@"\n');
102 - yield* fs.chmod(paths.entryPath, 0o755);
103 - const runner = yield* ProcessRunner.make();
104 - const legacyStart = yield* runner.run({
105 - command: process.execPath,
106 - args: [path.join(paths.versionDir, "node_modules/t3/dist/bin.mjs"), "serve"],
107 - });
108 - assert.equal(Number(legacyStart.code), 0, legacyStart.stderr);
109 - assert.equal(legacyStart.stdout.trim(), "serve");
110 - }
97 }),
98 );
99
@@ -223,40 +209,6 @@ it.layer(NodeServices.layer)("ensurePinnedRuntimeInstalled", (it) => {
209 }),
210 );
211
226 - it.effect("backfills a cached archive without downloading or replacing it", () =>
227 - Effect.gen(function* () {
228 - const fs = yield* FileSystem.FileSystem;
229 - const path = yield* Path.Path;
230 - const baseDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-pinned-legacy-cache-" });
231 - const cached = pinnedRuntimePaths(path, baseDir, version, "linux");
232 - const legacyEntry = path.join(cached.versionDir, "node_modules/t3/dist/bin.mjs");
233 - yield* fs.makeDirectory(cached.versionDir, { recursive: true });
234 - yield* fs.writeFileString(cached.entryPath, "cached executable\n");
235 - yield* fs.writeFileString(cached.sentinelPath, `${version}\n`);
236 - const requests: string[] = [];
237 - const commands: string[] = [];
238 - yield* ensurePinnedRuntimeInstalled({
239 - baseDir,
240 - version,
241 - fs,
242 - path,
243 - platform: "linux",
244 - arch: "x64",
245 - httpClient: releaseHttpClient(yield* validChecksums, requests),
246 - runner: extractingRunner(fs, path, commands),
247 - validate: () =>
248 - fs.exists(legacyEntry).pipe(
249 - Effect.flatMap((exists) => (exists ? Effect.void : Effect.die("missing legacy entry"))),
250 - Effect.orDie,
251 - ),
252 - });
253 - assert.deepEqual(requests, []);
254 - assert.deepEqual(commands, []);
255 - assert.equal(yield* fs.readFileString(cached.entryPath), "cached executable\n");
256 - assert.equal(yield* fs.readFileString(cached.sentinelPath), `${version}\n`);
257 - }),
258 - );
259 -
212 it.effect("preserves a completed runtime when validation fails", () =>
213 Effect.gen(function* () {
214 const fs = yield* FileSystem.FileSystem;
apps/server/src/cloud/pinnedRuntime.ts
+1 -26
@@ -8,7 +8,6 @@ import * as Option from "effect/Option";
8 import * as Semaphore from "effect/Semaphore";
9 import { HttpClient, HttpClientRequest, HttpClientResponse } from "effect/unstable/http";
10
11 -import { legacyCliLauncherScript } from "@t3tools/shared/legacyCliLauncher";
11 import {
12 CLI_RELEASE_CHECKSUMS_FILE,
13 cliArchiveFileName,
@@ -230,24 +229,6 @@ const installPinnedRuntime = Effect.fn("cloud.pinned_runtime.ensure_installed")(
229 input: PinnedRuntimeInstallInput,
230 ) {
231 const { fs } = input;
233 - // Old service launchers still use the npm entry point, including when an
234 - // archive was cached before this compatibility wrapper existed.
235 - const ensureLegacyEntry = Effect.fn("cloud.pinned_runtime.ensure_legacy_entry")(
236 - function* (versionDir: string) {
237 - const legacyDir = input.path.join(versionDir, "node_modules", "t3", "dist");
238 - const entryPath = input.path.join(legacyDir, "bin.mjs");
239 - if (yield* fs.exists(entryPath)) return;
240 - yield* fs.makeDirectory(legacyDir, { recursive: true });
241 - yield* fs.writeFileString(entryPath, legacyCliLauncherScript("archive"));
242 - },
243 - Effect.mapError(
244 - (cause) =>
245 - new PinnedRuntimeInstallError({
246 - step: "writing the legacy service entry point",
247 - cause,
248 - }),
249 - ),
250 - );
232 const paths = pinnedRuntimePaths(input.path, input.baseDir, input.version, input.platform);
233 const [versionDirExists, entryExists, sentinel] = yield* Effect.all([
234 fs.exists(paths.versionDir),
@@ -261,7 +242,6 @@ const installPinnedRuntime = Effect.fn("cloud.pinned_runtime.ensure_installed")(
242 const alreadyPinned =
243 entryExists && Option.isSome(sentinel) && sentinel.value.trim() === input.version;
244 if (alreadyPinned) {
264 - yield* ensureLegacyEntry(paths.versionDir);
245 yield* input.validate(paths);
246 return paths;
247 }
@@ -310,8 +290,6 @@ const installPinnedRuntime = Effect.fn("cloud.pinned_runtime.ensure_installed")(
290 return yield* Effect.gen(function* () {
291 yield* installFromArchive(input, stagingDir);
292
313 - yield* ensureLegacyEntry(stagingDir);
314 -
293 yield* input.validate(stagingPaths);
294 yield* fs
295 .writeFileString(stagingPaths.sentinelPath, `${input.version}\n`)
@@ -350,10 +328,7 @@ const installPinnedRuntime = Effect.fn("cloud.pinned_runtime.ensure_installed")(
328 ),
329 ),
330 );
353 - if (!published) {
354 - yield* ensureLegacyEntry(paths.versionDir);
355 - yield* input.validate(paths);
356 - }
331 + if (!published) yield* input.validate(paths);
332 return paths;
333 }).pipe(
334 Effect.ensuring(fs.remove(stagingDir, { recursive: true, force: true }).pipe(Effect.ignore)),
packages/shared/src/legacyCliLauncher.test.ts
+8 -8
@@ -14,22 +14,22 @@ const hostPlatform = NodeOS.platform();
14 const hostArch = NodeOS.arch();
15
16 // The fixture executable uses a POSIX shebang. The wrapper itself also runs on Windows.
17 -it.skipIf(hostPlatform === "win32").each(["npm", "archive"] as const)(
18 - "keeps %s service IPC, arguments, and termination connected",
19 - async (distribution) => {
17 +it.skipIf(hostPlatform === "win32")(
18 + "keeps service IPC, arguments, and termination connected",
19 + async () => {
20 const root = await NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "t3-legacy-launcher-"));
21 const entry = NodePath.join(root, "node_modules/t3/dist/bin.mjs");
22 - const executable =
23 - distribution === "archive"
24 - ? NodePath.join(root, "t3")
25 - : NodePath.join(root, `node_modules/@t3code/t3-${hostPlatform}-${hostArch}/t3`);
22 + const executable = NodePath.join(
23 + root,
24 + `node_modules/@t3code/t3-${hostPlatform}-${hostArch}/t3`,
25 + );
26 await NodeFSP.mkdir(NodePath.dirname(entry), { recursive: true });
27 await NodeFSP.mkdir(NodePath.dirname(executable), { recursive: true });
28 await NodeFSP.writeFile(
29 NodePath.join(NodePath.dirname(executable), "package.json"),
30 '{"type":"commonjs"}',
31 );
32 - await NodeFSP.writeFile(entry, legacyCliLauncherScript(distribution));
32 + await NodeFSP.writeFile(entry, legacyCliLauncherScript());
33 await NodeFSP.writeFile(
34 executable,
35 `#!${process.execPath}
packages/shared/src/legacyCliLauncher.ts
+15 -9
@@ -1,17 +1,23 @@
1 -/** Node entry point for service launchers installed before executable releases. */
2 -export function legacyCliLauncherScript(distribution: "npm" | "archive"): string {
3 - const executable =
4 - distribution === "npm"
5 - ? 'join(dirname(require.resolve("@t3code/t3-" + process.platform + "-" + process.arch + "/package.json")), executableName)'
6 - : 'resolve(dirname(fileURLToPath(import.meta.url)), "../../..", executableName)';
1 +/**
2 + * `dist/bin.mjs` of the `t3` npm package: the entry point boot-service
3 + * launchers installed before 0.0.41 run with Node to start a new version they
4 + * just npm-installed. It forwards everything (arguments, stdio, the IPC
5 + * channel the launcher talks over, signals, exit status) to the platform
6 + * executable in the sibling `@t3code/t3-<platform>-<arch>` package.
7 + *
8 + * The first server started this way rewrites the service unit to run the
9 + * executable directly, so nothing depends on this file after one update.
10 + * Remove it once no supported release predates the executable (after the
11 + * first stable release that ships it).
12 + */
13 +export function legacyCliLauncherScript(): string {
14 return `import { spawn } from "node:child_process";
15 import { constants } from "node:os";
9 -import { dirname, join, resolve } from "node:path";
10 -import { fileURLToPath } from "node:url";
16 +import { dirname, join } from "node:path";
17 import { createRequire } from "node:module";
18 const require = createRequire(import.meta.url);
19 const executableName = process.platform === "win32" ? "t3.exe" : "t3";
14 -const executable = ${executable};
20 +const executable = join(dirname(require.resolve("@t3code/t3-" + process.platform + "-" + process.arch + "/package.json")), executableName);
21 const ipc = process.send !== undefined;
22 const child = spawn(executable, process.argv.slice(2), {
23 stdio: ipc ? ["inherit", "inherit", "inherit", "ipc"] : "inherit",
scripts/build-npm-platform-packages.ts
+1 -1
@@ -389,7 +389,7 @@ const stageLauncherPackage = Effect.fn("stageLauncherPackage")(function* (input:
389 // Older service updaters and launchers run this exact path with Node.
390 // Keep it in the package so they can preflight and start the new executable.
391 yield* fs.makeDirectory(path.join(stageDir, "dist"));
392 - yield* fs.writeFileString(path.join(stageDir, "dist/bin.mjs"), legacyCliLauncherScript("npm"));
392 + yield* fs.writeFileString(path.join(stageDir, "dist/bin.mjs"), legacyCliLauncherScript());
393 const readme = yield* path.fromFileUrl(new URL("../apps/server/README.md", import.meta.url));
394 if (yield* fs.exists(readme)) {
395 yield* fs.copyFile(readme, path.join(stageDir, "README.md"));