Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@anthropic-ai/claude-agent-sdk": "^0.3.260",
"@effect/platform-bun": "catalog:",
"@effect/platform-node": "catalog:",
"@effect/platform-node-shared": "catalog:",
"@effect/sql-sqlite-bun": "catalog:",
"@ff-labs/fff-node": "0.9.4",
"@opencode-ai/sdk": "^1.3.15",
Expand Down
16 changes: 8 additions & 8 deletions docs/user/rtvision-wsl-ssh.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,14 @@ enter a hostname that is not in the list.

## Troubleshooting

| Symptom | What to check |
| ------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| SSH credentials selector is missing | It is hidden in WSL-only mode, where WSL is already selected automatically. Otherwise enable a WSL backend to expose it. |
| Error says `via Windows OpenSSH` | The attempt is using Windows credentials. Select WSL, confirm the restart, and recreate a saved environment if it retained the old credentials source. |
| `Permission denied (publickey)` followed by a password prompt | The offered key was not accepted. Check the remote username, selected credentials source, key, and agent. A remote login password cannot fix a connection where the server permits only public-key authentication. |
| `No matching version found for @rtvision/t3@0.0.41` | Check the exact version in the RTVision mirror. If unavailable, use the matching release attachment and complete both fallback installation commands. |
| `t3 --version` works but adding still tries to download a missing version | A global executable is insufficient for the packaged 0.0.41 launcher. Run the exact `npx --package` verification from the remote home directory. |
| Adding stays busy for about a minute | Remote startup can wait about 60 seconds before reporting an installation or readiness failure. Read the resulting error; retries alone will not resolve it. Close and reopen the dialog after the attempt finishes. |
| Symptom | What to check |
| ------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| SSH credentials selector is missing | It is hidden in WSL-only mode, where WSL is already selected automatically. Otherwise enable a WSL backend to expose it. |
| Error says `via Windows OpenSSH` | The attempt is using Windows credentials. Select WSL, confirm the restart, and recreate a saved environment if it retained the old credentials source. |
| `Permission denied (publickey)` followed by a password prompt | The offered key was not accepted. Check the remote username, selected credentials source, key, and agent. A remote login password cannot fix a connection where the server permits only public-key authentication. |
| `No matching version found for @rtvision/t3@0.0.41` | Check the exact version in the RTVision mirror. If unavailable, use the matching release attachment and complete both fallback installation commands. |
| `t3 --version` works but adding still tries to download a missing version | A global executable is insufficient. Current desktops can reuse a complete service installation at the same version. The older 0.0.41 launcher requires the exact `npx --package` verification from the remote home directory. |
| Adding stays busy for about a minute | Remote startup can wait about 60 seconds before reporting an installation or readiness failure. Read the resulting error; retries alone will not resolve it. Close and reopen the dialog after the attempt finishes. |

For more detail, inspect the remote account's
`~/.t3/ssh-launch/<connection-id>/server.log`. Logs may contain older attempts;
Expand Down
7 changes: 6 additions & 1 deletion knip.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@
"src/provider/testFixtures/*.mjs",
],
// Native msgpack acceleration and the Vite+ web build prerequisite.
"ignoreDependencies": ["msgpackr-extract", "@t3tools/web"],
"ignoreDependencies": [
"msgpackr-extract",
"@t3tools/web",
// Pins npm resolution; npm ignores overrides inside installed dependencies.
"@effect/platform-node-shared",
],
},
"apps/desktop": {
// Electron loads these bundles by filename rather than importing them.
Expand Down
127 changes: 127 additions & 0 deletions packages/ssh/src/installedRuntime.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
// @effect-diagnostics nodeBuiltinImport:off - Executes generated shell scripts against real runtime installations on disk.
import * as NodeChildProcess from "node:child_process";
import * as NodeFSP from "node:fs/promises";
import * as NodeOS from "node:os";
import * as NodePath from "node:path";
import * as NodeUtil from "node:util";

import { describe, expect, it } from "vite-plus/test";

import { HostProcessPlatform } from "@t3tools/shared/hostProcess";

import { buildRemoteT3RunnerScript } from "./tunnel.ts";

const execFile = NodeUtil.promisify(NodeChildProcess.execFile);
const version = "1.2.3";
const packageName = "@rtvision/t3";

/** Runs the generated runner against isolated installed-runtime and npm-fallback fixtures. */
async function fixture(
run: (input: {
root: string;
runtime: string;
packageDir: string;
execute: (options?: Parameters<typeof buildRemoteT3RunnerScript>[0]) => Promise<string>;
}) => Promise<void>,
) {
const root = await NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "t3 installed runtime "));
const runtime = NodePath.join(root, ".t3", "runtime", "versions", version);
const packageDir = NodePath.join(runtime, "node_modules", "t3");
const bin = NodePath.join(root, "bin");
try {
await NodeFSP.mkdir(NodePath.join(packageDir, "dist"), { recursive: true });
await NodeFSP.mkdir(bin);
await NodeFSP.symlink(process.execPath, NodePath.join(bin, "node"));
await NodeFSP.writeFile(
NodePath.join(packageDir, "package.json"),
JSON.stringify({ name: packageName, version }),
);
await NodeFSP.writeFile(NodePath.join(runtime, ".install-complete"), `${version}\n`);
await NodeFSP.writeFile(
NodePath.join(packageDir, "dist", "bin.mjs"),
'process.stdout.write(JSON.stringify({ source: "installed", args: process.argv.slice(2) }));',
);
const fallback = NodePath.join(root, "fallback");
await NodeFSP.writeFile(fallback, '#!/bin/sh\nprintf "npm fallback"\n', { mode: 0o700 });
await NodeFSP.writeFile(
NodePath.join(bin, "npx"),
"#!/usr/bin/env node\nprocess.stdout.write(process.env.T3_TEST_FALLBACK);\n",
{ mode: 0o700 },
);
await run({
root,
runtime,
packageDir,
execute: async (options) => {
const script = NodePath.join(root, "runner.sh");
await NodeFSP.writeFile(
script,
buildRemoteT3RunnerScript({ packageSpec: `${packageName}@${version}`, ...options }),
);
const result = await execFile(
"/bin/sh",
[script, "auth", "pairing", "create", "--base-dir", root, "--json"],
{ env: { ...process.env, HOME: root, PATH: bin, T3_TEST_FALLBACK: fallback } },
);
return result.stdout;
},
});
} finally {
await NodeFSP.rm(root, { recursive: true, force: true });
}
}

describe.skipIf(HostProcessPlatform.defaultValue() === "win32")("installed remote CLI", () => {
it("pairs using the complete matching runtime without npm, preserving arguments and spaces", () =>
fixture(async ({ root, execute }) => {
expect(JSON.parse(await execute())).toEqual({
source: "installed",
args: ["auth", "pairing", "create", "--base-dir", root, "--json"],
});
}));

it.each([
"incomplete",
"wrong-sentinel",
"invalid-manifest",
"wrong-package",
"wrong-version",
"missing-entry",
] as const)("falls back to npm for a %s installation", (state) =>
fixture(async ({ runtime, packageDir, execute }) => {
if (state === "incomplete") await NodeFSP.rm(NodePath.join(runtime, ".install-complete"));
if (state === "wrong-sentinel")
await NodeFSP.writeFile(NodePath.join(runtime, ".install-complete"), "1.2.2\n");
if (state === "invalid-manifest")
await NodeFSP.writeFile(NodePath.join(packageDir, "package.json"), "{");
if (state === "wrong-package" || state === "wrong-version") {
await NodeFSP.writeFile(
NodePath.join(packageDir, "package.json"),
JSON.stringify({
name: state === "wrong-package" ? "t3" : packageName,
version: state === "wrong-version" ? "1.2.2" : version,
}),
);
}
if (state === "missing-entry") await NodeFSP.rm(NodePath.join(packageDir, "dist", "bin.mjs"));
expect(await execute()).toBe("npm fallback");
}),
);

it("does not reuse an older installation after a desktop update", () =>
fixture(async ({ execute }) => {
expect(await execute({ packageSpec: `${packageName}@1.2.4` })).toBe("npm fallback");
}));

it("keeps explicit script overrides ahead of installed runtimes", () =>
fixture(async ({ root, execute }) => {
const override = NodePath.join(root, "override.mjs");
await NodeFSP.writeFile(override, 'process.stdout.write("explicit override");');
expect(await execute({ nodeScriptPath: override })).toBe("explicit override");
}));

it("resolves dist-tags through npm", () =>
fixture(async ({ execute }) => {
expect(await execute({ packageSpec: `${packageName}@latest` })).toBe("npm fallback");
}));
});
34 changes: 34 additions & 0 deletions packages/ssh/src/tunnel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,40 @@ if [ -n "$T3_NODE_SCRIPT_PATH" ]; then
fi
exec node "$T3_NODE_SCRIPT_PATH" "$@"
fi
# Service updates install a complete, versioned runtime without adding it to
# PATH or npm's cache. Reuse that exact package for pairing as well as startup.
resolve_installed_cli() {
node - @@T3_PACKAGE_SPEC@@ <<'NODE'
const fs = require("node:fs");
const path = require("node:path");
try {
const spec = process.argv[2];
const separator = spec.lastIndexOf("@");
const name = spec.slice(0, separator);
const version = spec.slice(separator + 1);
if (separator <= 0 || !/^\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?(?:\\+[0-9A-Za-z.-]+)?$/.test(version)) {
process.exit(1);
}
const runtimeDir = path.join(process.env.HOME, ".t3", "runtime", "versions", version);
if (fs.readFileSync(path.join(runtimeDir, ".install-complete"), "utf8").trim() !== version) {
process.exit(1);
}
const packageDir = path.join(runtimeDir, "node_modules", "t3");
const manifest = JSON.parse(fs.readFileSync(path.join(packageDir, "package.json"), "utf8"));
const entry = path.join(packageDir, "dist", "bin.mjs");
if (manifest.name !== name || manifest.version !== version || !fs.statSync(entry).isFile()) {
process.exit(1);
}
process.stdout.write(entry);
} catch {
process.exit(1);
}
NODE
}
T3_INSTALLED_CLI="$(resolve_installed_cli)" || true
if [ -n "$T3_INSTALLED_CLI" ]; then
exec node "$T3_INSTALLED_CLI" "$@"
fi
# npm extracts a package before it runs the native builds of its dependencies,
# so a failed build (t3 depends on node-pty, which needs a C toolchain) leaves
# the npx cache without a t3 executable. \`npx --yes\` then exits 0 without
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading