Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: require Tailcat ≥0.6.0 for managed install/detect (PSK) (#6493)

atomanticagenta33212d51a3e
diff --git a/docs/features/tailcat-peers.md b/docs/features/tailcat-peers.md
index 24a5add42b..17072f0e76 100644
--- a/docs/features/tailcat-peers.md
+++ b/docs/features/tailcat-peers.md
@@ -58,12 +58,18 @@ do not hardcode any particular host.
`ensureTailcatInstalled` first looks for a runnable binary — PATH, then
`$GOBIN`/`$GOPATH/bin`, then the Homebrew prefix, since a long-running server
does not necessarily have a package manager's bin directory on its inherited
-PATH. When none is found it runs the package managers the operator already has,
-in order, and stops at the first that produces a working binary:
+PATH. A candidate only counts when `tailcat version` parses to
+**≥ `MIN_TAILCAT_VERSION` (`0.6.0`)**. Older binaries are treated as unusable
+(see [Minimum Tailcat version (PSK)](#minimum-tailcat-version-psk) below): PortOS
+tries to install/upgrade rather than proceeding into a TCP timeout.
+
+When no usable binary is found it runs the package managers the operator already
+has, in order, and stops at the first that produces a **≥0.6.0** binary. After
+every installer it re-checks the version before returning success.
| Order | Command | Available when |
| --- | --- | --- |
-| 1 | `brew install tailcat` (with `HOMEBREW_NO_AUTO_UPDATE=1`) | `brew` on PATH |
+| 1 | `brew install tailcat` then `brew upgrade tailcat` (with `HOMEBREW_NO_AUTO_UPDATE=1`) | `brew` on PATH |
| 2 | `go install github.com/tailscale/tailcat/cmd/tailcat@latest` | `go` on PATH |
Homebrew is tried first for two reasons. **Tailcat publishes release binaries
@@ -73,9 +79,33 @@ proxy through Go's own dialer, which a local network filter can break in a way
that surfaces only as `dial tcp …:443: connect: bad file descriptor` — Homebrew
downloads over plain HTTPS and is unaffected.
+Hypothesis (non-binding): Homebrew often leaves an older bottle (e.g. **0.5.0**)
+when the index is stale or `install` is a no-op for an already-present formula —
+that is why PortOS follows `install` with `upgrade`, then falls through to
+`go install @latest`, and **refuses to report success** if the binary is still
+below 0.6.0 (`TAILCAT_VERSION_TOO_OLD` with upgrade instructions).
+
If every strategy fails, the error names each command and the first line of what
-it said, followed by platform-appropriate manual guidance (`brew install
-tailcat` on macOS, the releases page elsewhere).
+it said (or the leftover version), followed by platform-appropriate manual
+guidance (`brew upgrade tailcat` on macOS, the releases page / `go install`
+elsewhere). Dial-them, They-dial-us / managed serve, and Instances UI surfaces
+all share this gate via `ensureTailcatInstalled` — failures become API errors
+and `lastError` on forwards/serve, not a later silent timeout.
+
+### Minimum Tailcat version (PSK)
+
+PortOS requires **Tailcat ≥ 0.6.0** for managed install/detect.
+
+| Symptom | Cause |
+| --- | --- |
+| DERP discovery ping works (`--key=new` pong) but TCP `forward` / PortOS health probes time out (`context deadline exceeded`) | Client on **≤0.5.x** talking to a serve that defaults **`--psk` true** (documented since v0.6.0 `serve --help`; set `--psk=false` only for compatibility with clients v0.5.0 and earlier) |
+
+**Do not** “fix” this by auto-setting `--psk=false` on serve. Upgrade the
+client (Homebrew / `go install …@latest`) so both sides share modern PSK
+defaults. Confirmed in the wild: a home host on Homebrew **v0.5.0** against a
+sandbox serve on **v0.6.0** showed exactly the ping-ok / TCP-timeout split;
+upgrading the home client to 0.6.0 restored bidirectional HTTP health
+immediately — not a firewall or identity collision.
HTTP is the default; HTTPS runs through the same loopback tunnel. Remote
announcements cannot replace the managed local host or forwarding port.
@@ -302,6 +332,7 @@ tailcat forward <tcADDR> 15555:5555
- [ ] PortOS up on sandbox `:5555`
- [ ] Prefer **Instances → Tailcat serve** (or CLI `tailcat serve --key=… 5555`) — not `serve all`, not exit-node
+- [ ] Both sides on Tailcat **≥0.6.0** (`tailcat version`); upgrade if Dial-them / serve fails with `TAILCAT_VERSION_TOO_OLD` or ping-ok / TCP-timeout PSK mismatch
- [ ] Hand operator `<tcADDR>` out of band only (Copy from UI)
- [ ] Operator uses **Dial them** (local **15555 → 5555**), *or* if home dials time out, home uses **They dial us** and the sandbox Dials them
- [ ] Never write real `tc…` values into git, PR text, or federated logs
diff --git a/server/lib/README.md b/server/lib/README.md
index e16263ee36..b39d0344d3 100644
--- a/server/lib/README.md
+++ b/server/lib/README.md
@@ -373,6 +373,7 @@ pm` default, `NPM_CONFIG_PREFIX`, nvm/Volta) installed `codex` successfully and
| `syncIntegrity.js` | Pure diff of local vs remote manifest lists. `INTEGRITY_STATUS` constants + `computeRecordIntegrity(localList, remoteList)` — classifies each record as `in-parity`, `local-only`, `peer-only`, `diverged`, or `assets-missing`. No I/O. |
| `syncWire.js` | Single source of truth for what fields cross the federated-peer wire (snapshot loop + per-record push agree). |
| `tailscale.js` | Locate the Tailscale CLI binary, flag the sandboxed macOS App-bundle build, and return a normalized backend/MagicDNS/peer snapshot (`getTailscaleStatus` / `isTailscaleUp`). |
+| `tailcatVersion.js` | Tailcat CLI version floor for managed install/detect: `MIN_TAILCAT_VERSION` (`0.6.0` — PSK on by default in modern `serve`), `parseTailcatVersion` (handles the CLI's `v0.6.0` banner that `parseHarnessVersion` cannot), `isTailcatVersionAtLeast`, and `tailcatVersionTooOldMessage` for operator-facing upgrade guidance. Consumed by `services/tailcatPeer.js` so Dial-them and They-dial-us refuse ≤0.5.x rather than silently timing out on TCP. |
| `httpsState.js` | Captures whether PortOS booted with HTTPS active. |
| `bareUrl.js` | `parseBareUrl(text)` — returns the normalized URL when a captured string is nothing *but* a URL (bare host gets `https://`), else null. Drives the brain-capture short-circuit that files a pasted URL straight to Links instead of running the classifier. Stricter than the client's `urlNormalize.js` `isUrl` (needs a plausible TLD; http/https/`git@` only) because it picks a storage destination rather than a hint. |
| `isSafeHref.js` | Pure http(s)-only scheme check (`isSafeHref`) for user-supplied URL fields that get rendered as a clickable `<a href>` — rejects `javascript:`/`data:`/etc. stored-XSS payloads. `client/src/lib/isSafeHref.js` re-exports it, and `client/src/utils/urlNormalize.js` re-exports that as `isHttpUrl`. |
diff --git a/server/lib/index.js b/server/lib/index.js
index 94f19f9f7e..7f025219a4 100644
--- a/server/lib/index.js
+++ b/server/lib/index.js
@@ -353,6 +353,7 @@ export * from './sharingOrigin.js';
export * from './syncIntegrity.js';
export * from './syncWire.js';
export * from './tailscale.js';
+export * from './tailcatVersion.js';
// === Search & indexing ===
export * from './bm25.js';
diff --git a/server/lib/tailcatVersion.js b/server/lib/tailcatVersion.js
new file mode 100644
index 0000000000..5b1268bc94
--- /dev/null
+++ b/server/lib/tailcatVersion.js
@@ -0,0 +1,67 @@
+/**
+ * Tailcat CLI version floor for PortOS-managed install/detect.
+ *
+ * Modern `tailcat serve` defaults `--psk` to true (documented since v0.6.0).
+ * Clients on ≤0.5.x can still DERP-ping (`--key=new` pong) while TCP
+ * `forward` / PortOS health probes time out with `context deadline exceeded`.
+ * PortOS refuses to drive forward/serve with an older binary rather than
+ * silently disabling PSK.
+ */
+
+import { compareSemver } from './versionUtils.js';
+
+/** Lowest Tailcat release PortOS will use for managed forward/serve. */
+export const MIN_TAILCAT_VERSION = '0.6.0';
+
+/**
+ * Parse a `tailcat version` banner into a bare semver string, or `null`.
+ *
+ * Real CLI output is typically `v0.6.0` (leading `v`). Also accepts bare
+ * `0.6.0` and banners that embed the token among other text. Leading `v` is
+ * stripped so the result is safe for {@link compareSemver}.
+ *
+ * @param {string|null|undefined} text
+ * @returns {string|null}
+ */
+export function parseTailcatVersion(text) {
+ if (typeof text !== 'string') return null;
+ // `v?` must be in the match: a word-boundary alone cannot split `v0.6.0`
+ // (both `v` and `0` are word chars), so parseHarnessVersion would return null.
+ const match = text.match(/v?(\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?)/i);
+ return match ? match[1] : null;
+}
+
+/**
+ * True when `version` is a parseable semver ≥ `minimum` (default
+ * {@link MIN_TAILCAT_VERSION}).
+ *
+ * @param {string|null|undefined} version
+ * @param {string} [minimum]
+ * @returns {boolean}
+ */
+export function isTailcatVersionAtLeast(version, minimum = MIN_TAILCAT_VERSION) {
+ if (typeof version !== 'string' || !version) return false;
+ if (typeof minimum !== 'string' || !minimum) return false;
+ return compareSemver(version, minimum) >= 0;
+}
+
+/**
+ * Operator-facing upgrade guidance when detect/install cannot produce a
+ * PSK-compatible Tailcat.
+ *
+ * @param {{ version?: string|null, platform?: string }} [opts]
+ * @returns {string}
+ */
+export function tailcatVersionTooOldMessage({
+ version = null,
+ platform = process.platform,
+} = {}) {
+ const found = version ? `found ${version}` : 'could not determine version';
+ const upgrade = platform === 'darwin'
+ ? '`brew upgrade tailcat` (or `brew install tailcat` / `go install github.com/tailscale/tailcat/cmd/tailcat@latest`)'
+ : '`go install github.com/tailscale/tailcat/cmd/tailcat@latest` or a release binary from https://github.com/tailscale/tailcat/releases';
+ return (
+ `tailcat ${MIN_TAILCAT_VERSION}+ is required for PSK-compatible forward/serve (${found}). `
+ + `Upgrade with ${upgrade}, then retry. Do not set --psk=false to paper over an old client.`
+ );
+}
diff --git a/server/lib/tailcatVersion.test.js b/server/lib/tailcatVersion.test.js
new file mode 100644
index 0000000000..2216638b86
--- /dev/null
+++ b/server/lib/tailcatVersion.test.js
@@ -0,0 +1,59 @@
+import { describe, it, expect } from 'vitest';
+import {
+ MIN_TAILCAT_VERSION,
+ parseTailcatVersion,
+ isTailcatVersionAtLeast,
+ tailcatVersionTooOldMessage,
+} from './tailcatVersion.js';
+
+describe('tailcatVersion', () => {
+ it('exposes the PSK-compatible floor', () => {
+ expect(MIN_TAILCAT_VERSION).toBe('0.6.0');
+ });
+
+ it.each([
+ ['v0.6.0', '0.6.0'],
+ ['0.6.0', '0.6.0'],
+ ['v0.5.0', '0.5.0'],
+ ['tailcat version v0.6.0\n', '0.6.0'],
+ ['v0.6.0-rc.1', '0.6.0-rc.1'],
+ ['v0.6.0+build.1', '0.6.0+build.1'],
+ ])('parseTailcatVersion(%j) → %j', (input, expected) => {
+ expect(parseTailcatVersion(input)).toBe(expected);
+ });
+
+ it('parseTailcatVersion returns null for garbage', () => {
+ expect(parseTailcatVersion(null)).toBeNull();
+ expect(parseTailcatVersion(undefined)).toBeNull();
+ expect(parseTailcatVersion('')).toBeNull();
+ expect(parseTailcatVersion('not-a-version')).toBeNull();
+ expect(parseTailcatVersion(42)).toBeNull();
+ });
+
+ it('rejects versions below the floor', () => {
+ expect(isTailcatVersionAtLeast('0.5.0')).toBe(false);
+ expect(isTailcatVersionAtLeast('0.5.9')).toBe(false);
+ expect(isTailcatVersionAtLeast('0.6.0-rc.1')).toBe(false);
+ expect(isTailcatVersionAtLeast(null)).toBe(false);
+ expect(isTailcatVersionAtLeast('')).toBe(false);
+ });
+
+ it('accepts versions at or above the floor', () => {
+ expect(isTailcatVersionAtLeast('0.6.0')).toBe(true);
+ expect(isTailcatVersionAtLeast('0.6.1')).toBe(true);
+ expect(isTailcatVersionAtLeast('1.0.0')).toBe(true);
+ });
+
+ it('names the floor and upgrade path in the operator error', () => {
+ const darwin = tailcatVersionTooOldMessage({ version: '0.5.0', platform: 'darwin' });
+ expect(darwin).toContain('0.6.0+');
+ expect(darwin).toContain('found 0.5.0');
+ expect(darwin).toContain('brew upgrade tailcat');
+ expect(darwin).toContain('Do not set --psk=false');
+
+ const linux = tailcatVersionTooOldMessage({ version: null, platform: 'linux' });
+ expect(linux).toContain('could not determine version');
+ expect(linux).toContain('go install');
+ expect(linux).toContain('https://github.com/tailscale/tailcat/releases');
+ });
+});
diff --git a/server/services/tailcatPeer.js b/server/services/tailcatPeer.js
index 2eac188a4a..b0e2e3219f 100644
--- a/server/services/tailcatPeer.js
+++ b/server/services/tailcatPeer.js
@@ -19,7 +19,15 @@ import { stat } from 'node:fs/promises';
import { homedir } from 'node:os';
import { delimiter, join, posix, win32 } from 'node:path';
import { spawn } from '../lib/childProcess.js';
-import { commandExists } from '../lib/commandExists.js';
+import { commandOutput } from '../lib/commandExists.js';
+import {
+ MIN_TAILCAT_VERSION,
+ parseTailcatVersion,
+ isTailcatVersionAtLeast,
+ tailcatVersionTooOldMessage,
+} from '../lib/tailcatVersion.js';
+
+export { MIN_TAILCAT_VERSION };
import { bufferedSpawn, spawnFailureDetail } from '../lib/bufferedSpawn.js';
import { dataPath, readJSONFile, ensureDir, PATHS, atomicWrite } from '../lib/fileUtils.js';
import { createMutex } from '../lib/asyncMutex.js';
@@ -327,15 +335,55 @@ export function listCandidateTailcatBins({ env = process.env, home = homedir() }
}
/**
- * Resolve an installed `tailcat` binary, or null when none is runnable.
+ * Read `tailcat version` and return a bare semver, or null when the binary
+ * cannot run / the banner cannot be parsed.
+ */
+export async function readTailcatBinaryVersion(
+ bin,
+ { readOutput = (b) => commandOutput(b, ['version'], { timeoutMs: 5_000 }) } = {},
+) {
+ if (!bin) return null;
+ const raw = await readOutput(bin);
+ return parseTailcatVersion(raw);
+}
+
+/**
+ * Resolve an installed `tailcat` binary that meets {@link MIN_TAILCAT_VERSION},
+ * or null when none is both runnable and new enough. Older binaries are
+ * skipped (not returned) so install/upgrade can still try to replace them —
+ * use {@link findTooOldTailcat} when the operator needs a version-gate error.
* Injected deps keep unit tests off the real PATH / child_process.
*/
export async function detectTailcat({
candidates = listCandidateTailcatBins(),
- probe = (bin) => commandExists(bin, ['version'], { timeoutMs: 5_000 }),
+ readOutput = (bin) => commandOutput(bin, ['version'], { timeoutMs: 5_000 }),
+ minimum = MIN_TAILCAT_VERSION,
+} = {}) {
+ for (const bin of candidates) {
+ const raw = await readOutput(bin);
+ if (raw === null) continue;
+ const version = parseTailcatVersion(raw);
+ if (isTailcatVersionAtLeast(version, minimum)) return bin;
+ }
+ return null;
+}
+
+/**
+ * First runnable candidate that is below the version floor (or unparseable).
+ * Used to turn a silent "no usable binary" into a clear upgrade error.
+ */
+export async function findTooOldTailcat({
+ candidates = listCandidateTailcatBins(),
+ readOutput = (bin) => commandOutput(bin, ['version'], { timeoutMs: 5_000 }),
+ minimum = MIN_TAILCAT_VERSION,
} = {}) {
for (const bin of candidates) {
- if (await probe(bin)) return bin;
+ const raw = await readOutput(bin);
+ if (raw === null) continue;
+ const version = parseTailcatVersion(raw);
+ if (!isTailcatVersionAtLeast(version, minimum)) {
+ return { bin, version };
+ }
}
return null;
}
@@ -347,9 +395,16 @@ export async function detectTailcat({
*/
export function manualInstallHint(platform = process.platform) {
if (platform === 'darwin') {
- return `Install it with \`brew install ${BREW_FORMULA}\` (Tailcat ships no macOS release binary), then retry.`;
+ return (
+ `Install or upgrade to tailcat ${MIN_TAILCAT_VERSION}+ with `
+ + `\`brew upgrade ${BREW_FORMULA}\` / \`brew install ${BREW_FORMULA}\` `
+ + `(Tailcat ships no macOS release binary), then retry.`
+ );
}
- return `Install a release binary from ${RELEASES_URL}, then retry.`;
+ return (
+ `Install tailcat ${MIN_TAILCAT_VERSION}+ from ${RELEASES_URL} `
+ + `or \`go install ${GO_INSTALL_PKG}\`, then retry.`
+ );
}
/**
@@ -368,14 +423,22 @@ export function listTailcatInstallers({
} = {}) {
const installers = [];
if (brewBin) {
- installers.push({
- label: `brew install ${BREW_FORMULA}`,
+ const brewEnv = {
// Auto-update pulls the whole formula index before installing a ~10MB
// bottle; the operator asked to add a peer, not to refresh Homebrew.
- run: () => runInstall(brewBin, ['install', BREW_FORMULA], {
- HOMEBREW_NO_AUTO_UPDATE: '1',
- HOMEBREW_NO_INSTALL_CLEANUP: '1',
- }),
+ HOMEBREW_NO_AUTO_UPDATE: '1',
+ HOMEBREW_NO_INSTALL_CLEANUP: '1',
+ };
+ installers.push({
+ label: `brew install/upgrade ${BREW_FORMULA}`,
+ // `install` is a no-op when an older bottle is already present; follow
+ // with `upgrade` so a 0.5.x Homebrew install can still reach the floor.
+ // An "already up-to-date" upgrade failure is fine — the post-install
+ // version gate decides whether we are done (and go install may still run).
+ run: async () => {
+ await runInstall(brewBin, ['install', BREW_FORMULA], brewEnv);
+ await runInstall(brewBin, ['upgrade', BREW_FORMULA], brewEnv).catch(() => undefined);
+ },
});
}
if (goBin) {
@@ -395,17 +458,36 @@ export function listTailcatInstallers({
*/
export async function ensureTailcatInstalled({
detect = detectTailcat,
+ findTooOld = findTooOldTailcat,
installers = listTailcatInstallers(),
platform = process.platform,
} = {}) {
const existing = await detect();
if (existing) return { bin: existing, installed: false };
- if (installers.length === 0) {
+ const rejectTooOldOrMissing = async (failures = []) => {
+ const tooOld = await findTooOld();
+ if (tooOld) {
+ const detail = failures.length ? ` Install attempts: ${failures.join('; ')}.` : '';
+ throw new ServerError(
+ `${tailcatVersionTooOldMessage({ version: tooOld.version, platform })}${detail}`,
+ { status: 503, code: 'TAILCAT_VERSION_TOO_OLD' },
+ );
+ }
+ if (failures.length) {
+ throw new ServerError(
+ `Could not install tailcat — ${failures.join('; ')}. ${manualInstallHint(platform)}`,
+ { status: 503, code: 'TAILCAT_INSTALL_FAILED' },
+ );
+ }
throw new ServerError(
`tailcat is not installed, and neither Homebrew nor Go was found on PATH. ${manualInstallHint(platform)}`,
- { status: 503, code: 'TAILCAT_MISSING' }
+ { status: 503, code: 'TAILCAT_MISSING' },
);
+ };
+
+ if (installers.length === 0) {
+ await rejectTooOldOrMissing();
}
const failures = [];
@@ -420,13 +502,20 @@ export async function ensureTailcatInstalled({
}
const bin = await detect();
if (bin) return { bin, installed: true };
- failures.push(`${installer.label} finished but no tailcat binary was found`);
+ // Installer exited 0 but left only an old / unparseable binary — keep
+ // trying other strategies, then fail with the version gate (not "success").
+ const leftover = await findTooOld();
+ if (leftover) {
+ failures.push(
+ `${installer.label} finished but tailcat is still below ${MIN_TAILCAT_VERSION}`
+ + (leftover.version ? ` (found ${leftover.version})` : ' (version unknown)'),
+ );
+ } else {
+ failures.push(`${installer.label} finished but no tailcat binary was found`);
+ }
}
- throw new ServerError(
- `Could not install tailcat — ${failures.join('; ')}. ${manualInstallHint(platform)}`,
- { status: 503, code: 'TAILCAT_INSTALL_FAILED' }
- );
+ await rejectTooOldOrMissing(failures);
}
/** One line of an installer's diagnostics, bounded so a toast stays readable. */
diff --git a/server/services/tailcatPeer.test.js b/server/services/tailcatPeer.test.js
index 3608737739..41ec507d84 100644
--- a/server/services/tailcatPeer.test.js
+++ b/server/services/tailcatPeer.test.js
@@ -5,6 +5,8 @@ import {
redactTcAddress,
isValidTcAddress,
ensureTailcatInstalled,
+ detectTailcat,
+ findTooOldTailcat,
listTailcatInstallers,
listCandidateTailcatBins,
manualInstallHint,
@@ -20,6 +22,7 @@ import {
redactTailcatDiagnostics,
derpMapCachePath,
primeDerpMapCache,
+ MIN_TAILCAT_VERSION,
_resetLiveForwardsForTests,
_liveForwardCountForTests,
stopAllForwards,
@@ -128,6 +131,7 @@ describe('tailcatPeer helpers', () => {
it('reports what every installer said when they all fail', async () => {
const error = await ensureTailcatInstalled({
detect: async () => null,
+ findTooOld: async () => null,
platform: 'linux',
installers: [
{ label: 'brew install tailcat', run: async () => { throw new Error('brew boom'); } },
@@ -161,6 +165,7 @@ describe('tailcatPeer helpers', () => {
it('treats an installer that leaves no binary as a failure, not a success', async () => {
await expect(ensureTailcatInstalled({
detect: async () => null,
+ findTooOld: async () => null,
installers: [{ label: 'go install', run: async () => {} }],
})).rejects.toMatchObject({
code: 'TAILCAT_INSTALL_FAILED',
@@ -171,20 +176,88 @@ describe('tailcatPeer helpers', () => {
it('ensureTailcatInstalled fails clearly when no package manager is present', async () => {
await expect(ensureTailcatInstalled({
detect: async () => null,
+ findTooOld: async () => null,
installers: [],
})).rejects.toMatchObject({ code: 'TAILCAT_MISSING', status: 503 });
});
+ it('detectTailcat skips binaries below the minimum version', async () => {
+ expect(MIN_TAILCAT_VERSION).toBe('0.6.0');
+ const readOutput = vi.fn(async (bin) => {
+ if (bin === '/old/tailcat') return 'v0.5.0';
+ if (bin === '/new/tailcat') return 'v0.6.0';
+ return null;
+ });
+ await expect(detectTailcat({
+ candidates: ['/old/tailcat', '/new/tailcat'],
+ readOutput,
+ })).resolves.toBe('/new/tailcat');
+ await expect(detectTailcat({
+ candidates: ['/old/tailcat'],
+ readOutput,
+ })).resolves.toBeNull();
+ });
+
+ it('findTooOldTailcat reports a runnable but outdated binary', async () => {
+ await expect(findTooOldTailcat({
+ candidates: ['/old/tailcat'],
+ readOutput: async () => 'v0.5.0',
+ })).resolves.toEqual({ bin: '/old/tailcat', version: '0.5.0' });
+ });
+
+ it('ensureTailcatInstalled refuses a leftover 0.5.x after brew claims success', async () => {
+ const run = vi.fn(async () => {});
+ const error = await ensureTailcatInstalled({
+ detect: async () => null,
+ findTooOld: async () => ({ bin: '/opt/homebrew/bin/tailcat', version: '0.5.0' }),
+ platform: 'darwin',
+ installers: [{ label: 'brew install/upgrade tailcat', run }],
+ }).catch((err) => err);
+ expect(run).toHaveBeenCalledOnce();
+ expect(error).toMatchObject({ code: 'TAILCAT_VERSION_TOO_OLD', status: 503 });
+ expect(error.message).toContain('0.6.0+');
+ expect(error.message).toContain('found 0.5.0');
+ expect(error.message).toContain('brew upgrade tailcat');
+ expect(error.message).toContain('Do not set --psk=false');
+ });
+
+ it('ensureTailcatInstalled upgrades via installers when only an old binary is present', async () => {
+ let detectCalls = 0;
+ const run = vi.fn(async () => {});
+ const result = await ensureTailcatInstalled({
+ detect: async () => {
+ detectCalls += 1;
+ return detectCalls === 1 ? null : '/example/go/bin/tailcat';
+ },
+ findTooOld: async () => ({ bin: '/opt/homebrew/bin/tailcat', version: '0.5.0' }),
+ installers: [{ label: 'go install', run }],
+ });
+ expect(run).toHaveBeenCalledOnce();
+ expect(result).toEqual({ bin: '/example/go/bin/tailcat', installed: true });
+ });
+
+ it('ensureTailcatInstalled reports VERSION_TOO_OLD when no package manager and only 0.5.x exists', async () => {
+ await expect(ensureTailcatInstalled({
+ detect: async () => null,
+ findTooOld: async () => ({ bin: '/usr/local/bin/tailcat', version: '0.5.0' }),
+ installers: [],
+ platform: 'linux',
+ })).rejects.toMatchObject({ code: 'TAILCAT_VERSION_TOO_OLD', status: 503 });
+ });
+
it('points macOS at Homebrew, since tailcat ships no darwin release binary', () => {
+ expect(manualInstallHint('darwin')).toContain('brew upgrade tailcat');
expect(manualInstallHint('darwin')).toContain('brew install tailcat');
+ expect(manualInstallHint('darwin')).toContain('0.6.0+');
expect(manualInstallHint('darwin')).not.toContain('/releases');
expect(manualInstallHint('linux')).toContain('https://github.com/tailscale/tailcat/releases');
+ expect(manualInstallHint('linux')).toContain('0.6.0+');
});
it('lists brew before go, and only for package managers that exist', () => {
const runInstall = vi.fn(async () => {});
expect(listTailcatInstallers({ brewBin: '/opt/homebrew/bin/brew', goBin: '/usr/bin/go', runInstall })
- .map((i) => i.label)).toEqual(['brew install tailcat', 'go install']);
+ .map((i) => i.label)).toEqual(['brew install/upgrade tailcat', 'go install']);
expect(listTailcatInstallers({ brewBin: null, goBin: '/usr/bin/go', runInstall })
.map((i) => i.label)).toEqual(['go install']);
expect(listTailcatInstallers({ brewBin: null, goBin: null, runInstall })).toEqual([]);
@@ -196,6 +269,8 @@ describe('tailcatPeer helpers', () => {
await brew.run();
expect(runInstall).toHaveBeenCalledWith('/opt/homebrew/bin/brew', ['install', 'tailcat'],
expect.objectContaining({ HOMEBREW_NO_AUTO_UPDATE: '1' }));
+ expect(runInstall).toHaveBeenCalledWith('/opt/homebrew/bin/brew', ['upgrade', 'tailcat'],
+ expect.objectContaining({ HOMEBREW_NO_AUTO_UPDATE: '1' }));
});
// The default runner maps a bufferedSpawn result onto the message the operator
@@ -214,11 +289,15 @@ describe('tailcatPeer helpers', () => {
});
it('treats a clean install-command exit as success', async () => {
- bufferedSpawn.mockResolvedValueOnce({ success: true, code: 0, stdout: '', stderr: '', timedOut: false });
+ bufferedSpawn
+ .mockResolvedValueOnce({ success: true, code: 0, stdout: '', stderr: '', timedOut: false })
+ .mockResolvedValueOnce({ success: true, code: 0, stdout: '', stderr: '', timedOut: false });
const [installer] = listTailcatInstallers({ brewBin: '/example/brew', goBin: null });
await expect(installer.run()).resolves.toBeUndefined();
expect(bufferedSpawn).toHaveBeenCalledWith('/example/brew', ['install', 'tailcat'],
expect.objectContaining({ env: expect.objectContaining({ HOMEBREW_NO_AUTO_UPDATE: '1' }) }));
+ expect(bufferedSpawn).toHaveBeenCalledWith('/example/brew', ['upgrade', 'tailcat'],
+ expect.objectContaining({ env: expect.objectContaining({ HOMEBREW_NO_AUTO_UPDATE: '1' }) }));
});
it('looks for tailcat in the GOBIN and Homebrew prefixes a server may not have on PATH', () => {