Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Other computers can open this one over Tailscale, and Connect says why not
Milind Sonifb7884e1c347
diff --git a/electron-builder.yml b/electron-builder.ymlindex 607dd7a7a5..f7c93fe1a2 100644--- a/electron-builder.yml+++ b/electron-builder.yml@@ -136,6 +136,9 @@ mac:NSMicrophoneUsageDescription: OpenMausBot uses the microphone for voice dictation into the composer.NSSpeechRecognitionUsageDescription: OpenMausBot transcribes your voice on-device to type messages for you.NSAccessibilityUsageDescription: OpenMausBot uses Accessibility when you let a bot control this Mac.+ NSLocalNetworkUsageDescription: OpenMausBot connects to your phones and your other computers on this network and on Tailscale.+ NSBonjourServices:+ - _openmausbot._tcpNSScreenCaptureUsageDescription: OpenMausBot uses Screen Recording so bots can see this Mac before acting.NSDownloadsFolderUsageDescription: OpenMausBot looks in Downloads for the file your Grok Bot saved when you move it here.# Notarization runs manually after the build (notarytool + staple),diff --git a/electron/companion-settings.mjs b/electron/companion-settings.mjsindex 0bfc589f3f..7583aa940d 100644--- a/electron/companion-settings.mjs+++ b/electron/companion-settings.mjs@@ -4,8 +4,8 @@ import path from "node:path";/** `companion-settings.json` in the app's user data: each way into this computer and whether the person turned it on.* `wifi` is Same Wi-Fi (the device port on the LAN, and Bonjour), `relay` is Anywhere, through MausBot, `tailscale`- * the tailnet address, `https` the HTTPS address (the managed tunnel). `notices` lists routes kept on by the update- * that the person has not seen yet. */+ * the tailnet address (with `computers` when the person's other computers may open this one's server over it), `https`+ * the HTTPS address (the managed tunnel). `notices` lists routes kept on by the update that the person has not seen yet. */export const COMPANION_SETTINGS_VERSION = 2;export const ROUTES = Object.freeze(["wifi", "relay", "tailscale", "https"]);/** A device seen this recently counts as using its routes. */@@ -20,7 +20,7 @@ export function defaultCompanionSettings() {function readRoute(value, route) {if (!value || typeof value !== "object" || value.on !== true) return off();const since = Number.isSafeInteger(value.since) ? value.since : null;- if (route === "tailscale") return { on: true, since, name: typeof value.name === "string" && /\.ts\.net$/i.test(value.name) ? value.name : null };+ if (route === "tailscale") return { on: true, since, name: typeof value.name === "string" && /\.ts\.net$/i.test(value.name) ? value.name : null, ...(value.computers === true ? { computers: true } : {}) };return { on: true, since };}@@ -62,10 +62,10 @@ export const anyRouteOn = (settings) => ROUTES.some((route) => settings?.routes?/** Same Wi-Fi and Tailscale are what the sidecar itself listens for; the relay and the HTTPS address reach it otherwise. */export const directRoutesOn = (settings) => ({ wifi: settings?.routes?.wifi?.on === true, tailscale: settings?.routes?.tailscale?.on === true });-export function setRoute(settings, route, on, { now = Date.now(), name } = {}) {+export function setRoute(settings, route, on, { now = Date.now(), name, computers } = {}) {if (!ROUTES.includes(route)) return settings;const current = settings.routes[route];- const next = on ? { on: true, since: current.on ? current.since : now, ...(route === "tailscale" ? { name: name !== undefined ? name : current.name ?? null } : {}) } : off();+ const next = on ? { on: true, since: current.on ? current.since : now, ...(route === "tailscale" ? { name: name !== undefined ? name : current.name ?? null, ...((computers ?? current.computers) === true ? { computers: true } : {}) } : {}) } : off();return { ...settings, routes: { ...settings.routes, [route]: next }, notices: on ? settings.notices : settings.notices.filter((notice) => notice !== route) };}diff --git a/electron/companion-settings.node-test.mjs b/electron/companion-settings.node-test.mjsindex 0480053282..793955b822 100644--- a/electron/companion-settings.node-test.mjs+++ b/electron/companion-settings.node-test.mjs@@ -102,3 +102,15 @@ test("Tailscale is seen by its own interface, never by a 100.64/10 address aloneassert.equal(hasTailnetAddress({ tailscale0: [{ family: "IPv4", address: "100.70.0.1" }] }), true);assert.equal(hasTailnetAddress({ Tailscale: [{ family: "IPv4", address: "100.70.0.1" }] }), true);});++test("the switch for other computers lives on the Tailscale route and goes with it", () => {+ const on = setRoute(defaultCompanionSettings(), "tailscale", true, { now: 5, name: "mac.tail1.ts.net" });+ assert.equal(on.routes.tailscale.computers, undefined, "off unless the person turns it on");+ const shared = setRoute(on, "tailscale", true, { now: 6, computers: true });+ assert.deepEqual(shared.routes.tailscale, { on: true, since: 5, name: "mac.tail1.ts.net", computers: true });+ assert.equal(setRoute(shared, "tailscale", true, { now: 7, name: "mac.tail1.ts.net" }).routes.tailscale.computers, true, "a name refresh keeps it");+ assert.equal(setRoute(shared, "tailscale", true, { now: 7, computers: false }).routes.tailscale.computers, undefined);+ assert.deepEqual(setRoute(shared, "tailscale", false).routes.tailscale, { on: false, since: null });+ const read = readCompanionSettings({ version: COMPANION_SETTINGS_VERSION, routes: { tailscale: { on: true, since: 5, name: "mac.tail1.ts.net", computers: "yes" } } });+ assert.equal(read.routes.tailscale.computers, undefined, "anything but true is off: this opens a listener");+});diff --git a/electron/main.mjs b/electron/main.mjsindex c759165e2d..6e9fa7088f 100644--- a/electron/main.mjs+++ b/electron/main.mjs@@ -87,7 +87,7 @@ import {} from "./companion-account-service.mjs";import capabilitiesModule from "./capabilities.cjs";import environmentsModule from "./environments.cjs";-import { pairingPageUrl } from "./server-address.mjs"; import { createServerConnect } from "./server-probe.mjs"; import { checkServer, createServerStatus, installServerStatus } from "./server-status.mjs";+import { pairingPageUrl } from "./server-address.mjs"; import { createServerConnect } from "./server-probe.mjs"; import { createTailnetShare } from "./tailnet-share.mjs"; import { checkTailscale } from "./tailscale-check.mjs"; import { onTailnet } from "./tailnet.mjs"; import { checkServer, createServerStatus, installServerStatus } from "./server-status.mjs";import localOriginModule from "./local-origin.cjs";import { buildApplicationMenu } from "./menu.mjs";import { createComputerSharing, isHomeFolder, validateSharedFolders } from "./computer-sharing.mjs"; import { installServerLending } from "./server-lending.mjs"; import { ownEnvironmentIds } from "./lent-mcp.mjs";@@ -461,7 +461,7 @@ const DESKTOP_CRASH_LOG_MAX_BYTES = 512 * 1024;let logStream = null;let desktopShutdownStarted = false;import { companionAdvertisedHostedUrl, companionEnabledAtRest, companionOriginTarget, companionPairing, companionPairingRenew, companionDeviceRoutes, companionStartsAtLaunch, companionCloudDesktopAccess, companionRouteOn, dismissCompanionNotice, rememberCompanionRoute, setCompanionMigrationFacts,- companionBrowserControlAccess, companionRevoke, companionRunning, companionState, rememberCompanionKeepAwake, setCompanionHostedUrl, setCompanionLifecycleListener, startCompanion, stopCompanion } from "./companion.mjs";+ companionBrowserControlAccess, companionRevoke, companionRunning, companionSettings, companionState, rememberCompanionKeepAwake, setCompanionHostedUrl, setCompanionLifecycleListener, startCompanion, stopCompanion } from "./companion.mjs";import { createDesktopCompanionE2E, deviceCounts } from "./companion-e2e-desktop.mjs";import { autoStartCompanion } from "./companion-autostart.mjs";import { createPhoneLinkRoutes } from "./phone-link-routes.mjs";@@ -581,7 +581,7 @@ function publicManagedCompanionState() {function decorateDesktopCompanionState(state) {syncCompanionKeepAwake(state.enabled && !state.error, state.keepAwake === true);- return { ...state, managedConnection: publicManagedCompanionState() };+ return { ...state, managedConnection: publicManagedCompanionState(), tailnetShare: tailnetShare.state() };}async function desktopCompanionState() {@@ -682,14 +682,14 @@ async function startDesktopCompanion({ waitForHosted = true, remember = true, roasync function stopDesktopCompanion({ remember = true } = {}) {companionDesiredThisLaunch = false;companionLaunchGeneration += 1;- if (remember) for (const route of ["wifi", "relay", "tailscale", "https"]) await rememberCompanionRoute(route, false);+ if (remember) { for (const route of ["wifi", "relay", "tailscale", "https"]) await rememberCompanionRoute(route, false); await tailnetShare.apply(companionSettings().routes.tailscale); }syncCompanionKeepAwake(false, false);await managedCompanionConnector?.stop();await stopCompanion();return desktopCompanionState();}-const phoneLinkRoutes = createPhoneLinkRoutes({ rememberRoute: rememberCompanionRoute, routeOn: companionRouteOn, dismissNotice: dismissCompanionNotice, state: () => desktopCompanionState(), running: companionRunning, log: slog, changed: (route, on) => (route !== "https" ? companionE2E?.reconcile() : on ? startManagedCompanionConnection({ waitForVerification: false }) : stopManagedCompanionEndpointLocally()),+const tailnetShare = createTailnetShare({ check: checkTailscale, allowed: () => !managedRemoteAccessRefusal(), log: slog }); const phoneLinkRoutes = createPhoneLinkRoutes({ shareChanged: () => tailnetShare.apply(companionSettings().routes.tailscale), rememberRoute: rememberCompanionRoute, routeOn: companionRouteOn, dismissNotice: dismissCompanionNotice, state: () => desktopCompanionState(), running: companionRunning, log: slog, changed: (route, on) => (route !== "https" ? companionE2E?.reconcile() : on ? startManagedCompanionConnection({ waitForVerification: false }) : stopManagedCompanionEndpointLocally()),wake: () => (!companionRunning() && companionStartsAtLaunch({ remoteClient: Boolean(desktopRemoteAccess), serverReady }) ? startDesktopCompanion({ waitForHosted: false, remember: false }) : null), sleep: () => stopDesktopCompanion({ remember: false }) });setCompanionMigrationFacts(() => ({ managedAddress: Boolean(managedCompanionTunnelAccess(secureCredentials)) }));@@ -1164,7 +1164,7 @@ async function startServerOn(port, dataDir = runningDataDir ?? startupEnvironmenif (trustedApprovalMode.receive(proc, message)) return;if (managedDesktopRelay.receive(proc, message)) return;if (orgLibrary?.receive(message)) return;- if (receivePhoneSecretSave(proc, message) || oneHome.receive(proc, message)) return;+ if (receivePhoneSecretSave(proc, message) || oneHome.receive(proc, message) || tailnetShare.receive(message)) return;} catch (error) {slog(`desktop private sync rejected: ${error?.message ?? error}`);}@@ -1172,7 +1172,7 @@ async function startServerOn(port, dataDir = runningDataDir ?? startupEnvironmenproc.once("spawn", () => {slog(`spawned pid=${proc.pid}`);if (!serverSupervisor.isCurrent(proc)) return;- syncDesktopMutationToken(proc);+ syncDesktopMutationToken(proc); void tailnetShare.attach(proc, port, companionSettings().routes.tailscale);syncPhoneSecretKey(proc); grantLocalComputer(proc, (child) => serverSupervisor.isCurrent(child));});let exited = false;@@ -1794,7 +1794,7 @@ async function addServerFromClipboard() {}}-const serverConnect = createServerConnect({ fetch: (...args) => session.defaultSession.fetch(...args), t: nativeT,+const serverConnect = createServerConnect({ fetch: (...args) => session.defaultSession.fetch(...args), t: nativeT, tailnet: () => onTailnet(os.networkInterfaces()),ownEnvironmentId: async () => (await (await localServerRequest("/.well-known/openmausbot/environment")).json())?.environmentId ?? null,ask: async (found) => (await dialog.showMessageBox({ type: "question", buttons: [nativeT("native.dialog.connect.button"), nativeT("native.common.cancel")], defaultId: 0, cancelId: 1,message: nativeT("native.dialog.connect.title", { host: found.label }), detail: nativeT(found.code || found.credential ? "native.dialog.connect.withCode" : "native.dialog.connect.noCode") })).response === 0,@@ -3171,5 +3171,5 @@ function releaseDesktopDataDirLease() {// before-quit is too early (this app defers it); will-quit is Electron's last boundary, and the process hook covers app.exit().app.on("will-quit", releaseDesktopDataDirLease);-app.on("will-quit", () => desktopTray?.destroy());+app.on("will-quit", () => { desktopTray?.destroy(); void tailnetShare.stop(); });process.once("exit", releaseDesktopDataDirLease);diff --git a/electron/phone-link-routes.mjs b/electron/phone-link-routes.mjsindex 80f5cb743e..e8cb99ef19 100644--- a/electron/phone-link-routes.mjs+++ b/electron/phone-link-routes.mjs@@ -11,30 +11,43 @@ const SLEEP_CHECK_MS = 60_000;** `wake()` starts the sidecar when the launch rule now holds (a way in is on and something is paired).*/-export function createPhoneLinkRoutes({ rememberRoute, routeOn, dismissNotice, state, running, wake, sleep, changed = () => {}, check = checkTailscale, now = Date.now, setTimer = setInterval, log = () => {} }) {+export function createPhoneLinkRoutes({ rememberRoute, routeOn, dismissNotice, state, running, wake, sleep, changed = () => {}, check = checkTailscale, shareChanged = async () => {}, now = Date.now, setTimer = setInterval, log = () => {} }) {let activeSince = 0;let timer = null;async function setTailscale(on) {if (!on) {await rememberRoute("tailscale", false);+ await shareChanged();return state();}const result = await check();if (result.state !== "ready") return { ...(await state()), tailscaleProblem: result.state };await rememberRoute("tailscale", true, { name: result.name });+ await shareChanged();await wake();return state();}+ /** Whether the person's other computers may open this one over Tailscale; a share needs the Tailscale route on. */+ async function setTailscaleComputers(on) {+ if (routeOn("tailscale")) {+ await rememberRoute("tailscale", true, { computers: on });+ await shareChanged();+ }+ return state();+ }+const api = {setTailscale,+ setTailscaleComputers,/** Check again: asks Tailscale for the name only while the route is on, and starts nothing. */async checkTailscale() {if (!routeOn("tailscale")) return state();const result = await check();if (result.state !== "ready") return { ...(await state()), tailscaleProblem: result.state };await rememberRoute("tailscale", true, { name: result.name });+ await shareChanged();return state();},async setRoute(route, on) {@@ -65,6 +78,7 @@ export function createPhoneLinkRoutes({ rememberRoute, routeOn, dismissNotice, sconst handle = (channel, run) => ipcMain.handle(channel, localOnly(channel, run));handle("companion:refresh-tailscale", () => api.checkTailscale());handle("companion:tailscale", (_event, on) => api.setTailscale(on === true));+ handle("companion:tailscale-computers", (_event, on) => api.setTailscaleComputers(on === true));handle("companion:route", (_event, route, on) => api.setRoute(String(route), on === true));handle("companion:notice-dismiss", (_event, route) => api.dismissNotice(String(route)));},diff --git a/electron/phone-link-routes.node-test.mjs b/electron/phone-link-routes.node-test.mjsindex 96c8844d4c..f9746be4c5 100644--- a/electron/phone-link-routes.node-test.mjs+++ b/electron/phone-link-routes.node-test.mjs@@ -2,12 +2,13 @@ import assert from "node:assert/strict";import test from "node:test";import { createPhoneLinkRoutes, PHONE_LINK_SLEEP_GRACE_MS } from "./phone-link-routes.mjs";-import { checkTailscale, readTailscaleStatus, TAILSCALE_CLI_PATHS, tailscaleEnvironment, tailscaleInstall } from "./tailscale-check.mjs";+import { checkTailscale, magicDnsName, readTailscaleStatus, TAILSCALE_CLI_PATHS, tailscaleEnvironment, tailscaleInstall } from "./tailscale-check.mjs";function world({ check = async () => ({ state: "ready", name: "mac.tail1.ts.net" }), tailscaleOn = false, sidecar = null } = {}) {- const w = { routes: { tailscale: tailscaleOn }, names: [], checks: 0, wakes: 0, sleeps: 0, changed: [], clock: 1_000_000, sidecar, running: sidecar !== null };+ const w = { routes: { tailscale: tailscaleOn }, names: [], computers: [], shares: 0, checks: 0, wakes: 0, sleeps: 0, changed: [], clock: 1_000_000, sidecar, running: sidecar !== null };w.links = createPhoneLinkRoutes({- rememberRoute: async (route, on, extra) => { w.routes[route] = on; if (extra?.name) w.names.push(extra.name); },+ rememberRoute: async (route, on, extra) => { w.routes[route] = on; if (extra?.name) w.names.push(extra.name); if (extra?.computers !== undefined) w.computers.push(extra.computers); },+ shareChanged: async () => { w.shares++; },routeOn: (route) => w.routes[route] === true,dismissNotice: () => {},state: async () => ({ routes: w.routes, ...(w.sidecar ?? { enabled: false }) }),@@ -58,6 +59,19 @@ test("turning Tailscale off runs nothing", async () => {assert.equal(w.routes.tailscale, false);});+test("the switch for other computers needs the Tailscale route, and every Tailscale change reaches the share", async () => {+ const off = world();+ await off.links.setTailscaleComputers(true);+ assert.deepEqual([off.computers, off.shares, off.routes.tailscale], [[], 0, false], "no route, no share");+ const on = world({ tailscaleOn: true });+ await on.links.setTailscaleComputers(true);+ assert.deepEqual([on.computers, on.shares], [[true], 1]);+ await on.links.checkTailscale();+ assert.equal(on.shares, 2);+ await on.links.setTailscale(false);+ assert.equal(on.shares, 3);+});+test("other routes switch on their own, tell main which changed, and wake only when turned on", async () => {const w = world();await w.links.setRoute("relay", true);@@ -92,12 +106,34 @@ test("Tailscale presence is checked by looking for files; nothing runs when nonelet runs = 0;const run = async () => { runs++; return { missing: false, stdout: "", stderr: "" }; };assert.deepEqual(await checkTailscale({ install: () => "none", run }), { state: "not-installed" });- assert.deepEqual(await checkTailscale({ install: () => "app-only", run }), { state: "no-cli" }, "the macOS app's executable is never run");+ const onTailnet = () => ({ utun4: [{ address: "100.101.102.103" }, { address: "fd7a:115c:a1e0::1" }] });+ assert.deepEqual(await checkTailscale({ install: () => "app-only", run, interfaces: onTailnet, reverse: async () => null }), { state: "no-cli" }, "the macOS app's executable is never run");+ assert.deepEqual(await checkTailscale({ install: () => "app-only", run, interfaces: () => ({}), reverse: async () => null }), { state: "not-running" });+ assert.equal(runs, 0);+});++test("a Mac with only the Tailscale app learns its name from MagicDNS, still running nothing", async () => {+ let runs = 0, asked = null;+ const result = await checkTailscale({+ install: () => "app-only",+ run: async () => { runs++; return { missing: false, stdout: "", stderr: "" }; },+ interfaces: () => ({ utun4: [{ address: "fd7a:115c:a1e0::1" }, { address: "100.101.102.103" }] }),+ reverse: async (address) => { asked = address; return "mac.tail1.ts.net"; },+ });+ assert.deepEqual(result, { state: "ready", name: "mac.tail1.ts.net", addresses: ["100.101.102.103", "fd7a:115c:a1e0::1"], https: false, cli: null });+ assert.equal(asked, "100.101.102.103");assert.equal(runs, 0);+ const servers = [];+ const resolver = (names) => ({ setServers: (list) => servers.push(...list), reverse: async () => { if (names instanceof Error) throw names; return names; } });+ assert.equal(await magicDnsName("100.101.102.103", { resolver: resolver(["Mac.tail1.ts.net."]) }), "mac.tail1.ts.net");+ assert.deepEqual(servers, ["100.100.100.100"]);+ assert.equal(await magicDnsName("100.101.102.103", { resolver: resolver(["mac.example.com."]) }), null);+ assert.equal(await magicDnsName("100.101.102.103", { resolver: resolver(new Error("ETIMEOUT")) }), null);+ assert.equal(await magicDnsName(undefined, { resolver: resolver([]) }), null);});test("one status reading tells ready, signed out, not running and not allowed apart", async () => {- assert.deepEqual(readTailscaleStatus(JSON.stringify({ BackendState: "Running", Self: { DNSName: "Mac.tail1.ts.net." } })), { state: "ready", name: "mac.tail1.ts.net" });+ assert.deepEqual(readTailscaleStatus(JSON.stringify({ BackendState: "Running", CertDomains: ["mac.tail1.ts.net"], Self: { DNSName: "Mac.tail1.ts.net.", TailscaleIPs: ["100.64.0.2"] } })), { state: "ready", name: "mac.tail1.ts.net", addresses: ["100.64.0.2"], https: true });assert.deepEqual(readTailscaleStatus(JSON.stringify({ BackendState: "NeedsLogin", Self: { DNSName: "" } })), { state: "signed-out" });assert.deepEqual(readTailscaleStatus(JSON.stringify({ BackendState: "Stopped" })), { state: "not-running" });assert.deepEqual(readTailscaleStatus("", "failed to connect to local tailscaled; it doesn't appear to be running"), { state: "not-running" });@@ -108,7 +144,7 @@ test("one status reading tells ready, signed out, not running and not allowed apcandidates: ["/opt/homebrew/bin/tailscale", "/usr/bin/tailscale"],run: async (cli) => { tried.push(cli); return cli === "/opt/homebrew/bin/tailscale" ? { missing: true, stdout: "", stderr: "" } : { missing: false, stdout: JSON.stringify({ BackendState: "Running", Self: { DNSName: "mac.tail1.ts.net." } }), stderr: "" }; },});- assert.deepEqual(result, { state: "ready", name: "mac.tail1.ts.net" });+ assert.deepEqual(result, { state: "ready", name: "mac.tail1.ts.net", addresses: [], https: false, cli: "/usr/bin/tailscale" });assert.deepEqual(tried, ["/opt/homebrew/bin/tailscale", "/usr/bin/tailscale"]);assert.ok(!TAILSCALE_CLI_PATHS.some((cli) => /Tailscale\.app/.test(cli)), "no app executable among the candidates");assert.equal(tailscaleEnvironment({ PATH: "" }).TAILSCALE_BE_CLI, "1");diff --git a/electron/preload.cjs b/electron/preload.cjsindex 837e217195..a7dfb62120 100644--- a/electron/preload.cjs+++ b/electron/preload.cjs@@ -268,6 +268,7 @@ const bridge = {keepAwake: (enabled) => ipcRenderer.invoke("companion:keep-awake", enabled),refreshTailscale: () => ipcRenderer.invoke("companion:refresh-tailscale"),setTailscale: (on) => ipcRenderer.invoke("companion:tailscale", on === true),+ setTailscaleComputers: (on) => ipcRenderer.invoke("companion:tailscale-computers", on === true),setRoute: (route, on) => ipcRenderer.invoke("companion:route", String(route), on === true),dismissNotice: (route) => ipcRenderer.invoke("companion:notice-dismiss", String(route)),pairing: (open, expectedToken) => ipcRenderer.invoke("companion:pairing", open, expectedToken),diff --git a/electron/server-address.d.mts b/electron/server-address.d.mtsindex 30096a93a4..479fd812bb 100644--- a/electron/server-address.d.mts+++ b/electron/server-address.d.mts@@ -1,5 +1,6 @@export declare const PAIRING_CODE_ALPHABET: string;export declare const PAIRING_CODE_LENGTH: number;+export declare const DEFAULT_PORT: number;export declare const EXAMPLE_ADDRESS: string;export type PairingCodeProblem = "emailCode" | "oldCode" | "scriptKey" | "notACode";diff --git a/electron/server-address.mjs b/electron/server-address.mjsindex 9b09004ce2..b92d640848 100644--- a/electron/server-address.mjs+++ b/electron/server-address.mjs@@ -1,11 +1,13 @@// What a person types or pastes to reach a MausBot server: a pairing link, an address, an address and a code typed// apart, or a code on its own. One reader for the desktop's Connect sheet, `openmausbot connect` and the MCP bridge.+import { isTailnetHost } from "./tailnet.mjs";export const PAIRING_CODE_ALPHABET = "23456789ABCDEFGHJKLMNPQRSTUVWXYZ";export const PAIRING_CODE_LENGTH = 12;const PAIRING_CREDENTIAL = /^omb_pair_[A-Za-z0-9_-]{43}$/;-/** The port `openmausbot serve` listens on, used in examples only. */-export const EXAMPLE_ADDRESS = "http://192.168.1.20:8799";+/** The port `openmausbot serve` and the desktop app listen on. */+export const DEFAULT_PORT = 8799;+export const EXAMPLE_ADDRESS = `http://192.168.1.20:${DEFAULT_PORT}`;const bareHost = (host) => String(host ?? "").trim().toLowerCase().replace(/^\[|\]$/g, "").replace(/\.$/, "");@@ -41,10 +43,12 @@ export function isPrivateHost(host) {return !name.includes(".") && /^[a-z0-9-]+$/.test(name);}-/** How a saved server is reached, for the line under its name. */+/** How a saved server is reached, for the line under its name. A tailnet address is Tailscale over http too: WireGuard+ * encrypts it. */export function serverTransport(origin) {const url = new URL(origin);- if (url.protocol === "https:") return url.hostname.endsWith(".ts.net") ? "tailscale" : "https";+ if (isTailnetHost(bareHost(url.hostname))) return "tailscale";+ if (url.protocol === "https:") return "https";return isLoopbackHost(url.hostname) ? "loopback" : "private-http";}@@ -149,7 +153,9 @@ export function parseServerInput(addressInput, codeInput = "") {const privateHost = isPrivateHost(url.hostname);if (url.protocol === "http:" && schemed && !privateHost) return { ok: false, problem: "publicHttp", host: url.host };const https = `https://${url.host}`, http = `http://${url.host}`;- const candidates = schemed ? [url.origin] : privateHost ? [https, http] : [https];+ // A tailnet name typed alone may be a computer sharing itself on the tailnet, which listens on its own port.+ const shared = !schemed && !url.port && isTailnetHost(bareHost(url.hostname)) ? [`http://${url.host}:${DEFAULT_PORT}`] : [];+ const candidates = schemed ? [url.origin] : privateHost ? [https, http, ...shared] : [https];return {ok: true,candidates,diff --git a/electron/server-address.node-test.mjs b/electron/server-address.node-test.mjsindex 0330c7cd1a..1d2f5062fd 100644--- a/electron/server-address.node-test.mjs+++ b/electron/server-address.node-test.mjs@@ -36,6 +36,9 @@ test("a bare address tries https first, then http only when the host is private"assert.deepEqual(parseServerInput("maus.example.com").candidates, ["https://maus.example.com"]);assert.deepEqual(parseServerInput(" https://maus.example.com/ ").candidates, ["https://maus.example.com"]);assert.deepEqual(parseServerInput("hetzner-1:8799").candidates, ["https://hetzner-1:8799", "http://hetzner-1:8799"]);+ // A tailnet name alone also tries the port a computer sharing itself on the tailnet listens on.+ assert.deepEqual(parseServerInput("macmini.tail1234.ts.net").candidates, ["https://macmini.tail1234.ts.net", "http://macmini.tail1234.ts.net", "http://macmini.tail1234.ts.net:8799"]);+ assert.deepEqual(parseServerInput("macmini.tail1234.ts.net:18799").candidates, ["https://macmini.tail1234.ts.net:18799", "http://macmini.tail1234.ts.net:18799"]);});test("an address and a code typed apart make one pairing", () => {@@ -84,6 +87,9 @@ test("anything that is not a server address is refused", () => {test("each transport is named for the line under a saved server", () => {assert.equal(serverTransport("https://maus.example.com"), "https");assert.equal(serverTransport("https://box.tail1234.ts.net"), "tailscale");+ // Inside WireGuard: encrypted although the scheme is http.+ assert.equal(serverTransport("http://box.tail1234.ts.net:8799"), "tailscale");+ assert.equal(serverTransport("http://100.101.102.103:8799"), "tailscale");assert.equal(serverTransport("http://192.168.1.20:8799"), "private-http");assert.equal(serverTransport("http://127.0.0.1:8799"), "loopback");});diff --git a/electron/server-probe.d.mts b/electron/server-probe.d.mtsindex 839f813b26..db6ae144fb 100644--- a/electron/server-probe.d.mts+++ b/electron/server-probe.d.mts@@ -1,6 +1,7 @@import type { ServerInputProblem, ServerTransport } from "./server-address.mjs";-export type ServerProbeProblem = ServerInputProblem | "unreachable" | "dns" | "certificate" | "notMausBot" | "desktopApp" | "loopback" | "localNetwork";+export type ServerProbeProblem = ServerInputProblem | "unreachable" | "dns" | "certificate" | "notMausBot" | "desktopApp" | "loopback" | "localNetwork"+ | "tailscaleOff" | "otherTailnet" | "tailnetBlocked" | "tailnetSilent";export type ServerProbe =| { outcome: "found"; origin: string; label: string; version: string | null; transport: ServerTransport; code: string | null; credential: string | null }| { outcome: "problem"; problem: ServerProbeProblem; host?: string; code?: string; reason?: "refused" | "timeout" };@@ -8,7 +9,7 @@ export type ServerProbe =/** What the Connect sheet's Connect resolves with. */export type ConnectOutcome = { outcome: "connected"; label: string } | Extract<ServerProbe, { outcome: "problem" }>;-export declare function probeServer(input: { address: string; code?: string; fetch: typeof fetch; ownEnvironmentId?: () => Promise<string | null>; timeoutMs?: number; platform?: string }): Promise<ServerProbe>;+export declare function probeServer(input: { address: string; code?: string; fetch: typeof fetch; ownEnvironmentId?: () => Promise<string | null>; timeoutMs?: number; platform?: string; tailnet?: () => boolean }): Promise<ServerProbe>;export declare const CONNECT_PROBLEM_KEYS: Readonly<Record<ServerProbeProblem, `native.connect.${ServerProbeProblem}`>>;@@ -18,6 +19,8 @@ export declare function createServerConnect(deps: {ask: (found: Extract<ServerProbe, { outcome: "found" }>) => Promise<boolean>;open: (found: Extract<ServerProbe, { outcome: "found" }>, name?: string) => void;t: (key: string, params?: Record<string, string>) => string;+ /** Whether this computer is on a tailnet; assumed so when absent. */+ tailnet?: () => boolean;}): {probe: (address: string, code?: string) => Promise<ServerProbe>;connect: (address: string, code?: string) => Promise<ConnectOutcome>;diff --git a/electron/server-probe.mjs b/electron/server-probe.mjsindex f3f2874984..801ec6e299 100644--- a/electron/server-probe.mjs+++ b/electron/server-probe.mjs@@ -1,6 +1,7 @@// Before connecting, the Connect sheet asks the address who it is: the server's public descriptor names it, and a// failure is sorted into one thing the person can fix.import { EXAMPLE_ADDRESS, isLoopbackHost, parseServerInput, serverTransport } from "./server-address.mjs";+import { isTailnetHost } from "./tailnet.mjs";const DESCRIPTOR = "/.well-known/openmausbot/environment";/** A MausBot desktop app's Remote access (companion/src/routes.ts) refuses the descriptor with this until a phone pairs. */@@ -24,8 +25,25 @@ export const CONNECT_PROBLEM_KEYS = Object.freeze({desktopApp: "native.connect.desktopApp",loopback: "native.connect.loopback",localNetwork: "native.connect.localNetwork",+ tailscaleOff: "native.connect.tailscaleOff",+ otherTailnet: "native.connect.otherTailnet",+ tailnetBlocked: "native.connect.tailnetBlocked",+ tailnetSilent: "native.connect.tailnetSilent",});+/**+ * Why an address only a tailnet reaches did not answer: Tailscale is off on this computer, the name is not on this+ * computer's tailnet (MagicDNS answers only names it knows), macOS refused at once (its Local Network permission covers+ * Tailscale's addresses too, and refuses with "no route to host" rather than letting the request time out), or the+ * computer there is asleep, offline or not sharing.+ */+function tailnetProblem(kind, platform, tailnet) {+ if (!tailnet) return "tailscaleOff";+ if (kind === "dns") return "otherTailnet";+ if (kind === "noRoute" && platform === "darwin") return "tailnetBlocked";+ return "tailnetSilent";+}+/** Chromium's net errors (Electron 43 `session.fetch`) and Node's (undici) for the same causes. */function failureKind(error) {const text = `${error?.message ?? ""} ${error?.cause?.code ?? ""} ${error?.cause?.message ?? ""} ${error?.name ?? ""}`;@@ -33,6 +51,7 @@ function failureKind(error) {if (/ERR_CERT|CERT_|SELF_SIGNED|UNABLE_TO_VERIFY|ALTNAME|certificate/i.test(text)) return "certificate";if (/TimeoutError|TIMED_OUT|ETIMEDOUT|aborted/i.test(text)) return "timeout";if (/CONNECTION_REFUSED|ECONNREFUSED/i.test(text)) return "refused";+ if (/ADDRESS_UNREACHABLE|EHOSTUNREACH|ENETUNREACH|NETWORK_ACCESS_DENIED/i.test(text)) return "noRoute";return "unreachable";}@@ -91,7 +110,7 @@ async function describe(origin, fetchImpl, timeoutMs) {* certificate, notMausBot, desktopApp (another computer's MausBot desktop app, which can't be a server), loopback (an address on this computer that is this app's own workspace, or nothing at all).* `ownEnvironmentId()`: this app's own local workspace, so a "this computer" link copied off a server is caught.*/-export async function probeServer({ address, code = "", fetch: fetchImpl, ownEnvironmentId = async () => null, timeoutMs = 6_000, platform = process.platform }) {+export async function probeServer({ address, code = "", fetch: fetchImpl, ownEnvironmentId = async () => null, timeoutMs = 6_000, platform = process.platform, tailnet = () => true }) {const parsed = parseServerInput(address, code);if (!parsed.ok) {const { ok: _ok, ...problem } = parsed;@@ -99,16 +118,20 @@ export async function probeServer({ address, code = "", fetch: fetchImpl, ownEnv}let failure = null;for (const origin of parsed.candidates) {- const host = new URL(origin).host;- const loopback = isLoopbackHost(new URL(origin).hostname);+ const { host, hostname } = new URL(origin);+ const loopback = isLoopbackHost(hostname);const found = await describe(origin, fetchImpl, timeoutMs);if (!found.ok) {+ const kind = found.kind === "noRoute" ? "unreachable" : found.kind;// macOS 15 blocks an app from the local network until the person allows it, and the request then just fails.- const blockedOnMac = platform === "darwin" && serverTransport(origin) === "private-http" && (found.kind === "unreachable" || found.kind === "timeout");+ const blockedOnMac = platform === "darwin" && serverTransport(origin) === "private-http" && (kind === "unreachable" || kind === "timeout");// Once a candidate turned out to be another computer's desktop app, that's the problem to report.if (failure?.problem === "desktopApp") continue;- failure = loopback ? { problem: "loopback", host } : blockedOnMac ? { problem: "localNetwork", host }- : { problem: found.kind === "refused" || found.kind === "timeout" ? "unreachable" : found.kind, host, ...(found.kind === "refused" || found.kind === "timeout" ? { reason: found.kind } : {}) };+ const tailnetHost = isTailnetHost(hostname.replace(/^\[|\]$/g, "")) && !["certificate", "notMausBot", "desktopApp"].includes(found.kind);+ const problem = loopback ? { problem: "loopback", host } : tailnetHost ? { problem: tailnetProblem(found.kind, platform, tailnet()), host } : blockedOnMac ? { problem: "localNetwork", host }+ : { problem: kind === "refused" || kind === "timeout" ? "unreachable" : kind, host, ...(kind === "refused" || kind === "timeout" ? { reason: kind } : {}) };+ // A later guess at a tailnet name that just didn't answer says less than whatever an earlier one said.+ if (!(failure && problem.problem === "tailnetSilent")) failure = problem;continue;}if (loopback && found.environmentId === await ownEnvironmentId().catch(() => null)) return { outcome: "problem", problem: "loopback", host };@@ -123,8 +146,8 @@ export async function probeServer({ address, code = "", fetch: fetchImpl, ownEnv* clipboard or Settings, which names the server in main's own dialog (`ask(found)`) first and throws a problem's sentence.* `open(found, name)` saves the server and opens its /pair page.*/-export function createServerConnect({ fetch: fetchImpl, ownEnvironmentId, ask, open, t }) {- const probe = (address, code = "") => probeServer({ address, code, fetch: fetchImpl, ownEnvironmentId });+export function createServerConnect({ fetch: fetchImpl, ownEnvironmentId, ask, open, t, tailnet }) {+ const probe = (address, code = "") => probeServer({ address, code, fetch: fetchImpl, ownEnvironmentId, tailnet });return {probe,async connect(address, code = "") {diff --git a/electron/server-probe.node-test.mjs b/electron/server-probe.node-test.mjsindex 8f5b9c1da0..896c2e8889 100644--- a/electron/server-probe.node-test.mjs+++ b/electron/server-probe.node-test.mjs@@ -51,6 +51,30 @@ test("on a Mac, a local address that never answers names the Local Network permiassert.equal((await probeServer({ address: "maus.example.com", fetch: fakeFetch({ "https://maus.example.com": blocked() }).fetch, platform: "darwin" })).problem, "unreachable");});+test("a tailnet address that doesn't answer says whose Tailscale to fix", async () => {+ const blocked = () => new Error("net::ERR_ADDRESS_UNREACHABLE");+ const silent = () => Object.assign(new Error("The operation was aborted due to timeout"), { name: "TimeoutError" });+ const unknownName = () => new Error("net::ERR_NAME_NOT_RESOLVED");+ const link = "http://macmini.tail1234.ts.net:8799/pair#code=ABCD-EFGH-JKLM";+ const at = (error) => fakeFetch({ "http://macmini.tail1234.ts.net:8799": error }).fetch;+ const probe = (fetch, tailnet = true, platform = "darwin") => probeServer({ address: link, fetch, platform, tailnet: () => tailnet });+ const host = "macmini.tail1234.ts.net:8799";+ assert.deepEqual(await probe(at(blocked()), false), { outcome: "problem", problem: "tailscaleOff", host });+ assert.deepEqual(await probe(at(unknownName())), { outcome: "problem", problem: "otherTailnet", host });+ assert.deepEqual(await probe(at(blocked())), { outcome: "problem", problem: "tailnetBlocked", host });+ assert.equal((await probe(at(blocked()), true, "linux")).problem, "tailnetSilent");+ assert.equal((await probe(at(silent()))).problem, "tailnetSilent");+ assert.equal((await probe(fakeFetch({}).fetch)).problem, "tailnetSilent");+ // A bare tailnet address and an https name are tailnet addresses too.+ assert.equal((await probeServer({ address: "http://100.101.102.103:8799", fetch: fakeFetch({ "http://100.101.102.103:8799": blocked() }).fetch, platform: "darwin", tailnet: () => true })).problem, "tailnetBlocked");+ // Typed alone, the name is tried three ways; the one that named a cause is the one shown.+ const typed = fakeFetch({ "https://macmini.tail1234.ts.net": new Error("net::ERR_CERT_COMMON_NAME_INVALID"), "http://macmini.tail1234.ts.net": refused(), "http://macmini.tail1234.ts.net:8799": refused() });+ assert.equal((await probeServer({ address: "macmini.tail1234.ts.net", fetch: typed.fetch, tailnet: () => true })).problem, "certificate");+ const shared = fakeFetch({ "http://macmini.tail1234.ts.net:8799": () => descriptor("env-mini", "Mac mini") });+ const found = await probeServer({ address: "macmini.tail1234.ts.net", code: "abcd-efgh-jklm", fetch: shared.fetch, tailnet: () => true });+ assert.deepEqual([found.outcome, found.origin, found.transport], ["found", "http://macmini.tail1234.ts.net:8799", "tailscale"]);+});+test("a link to this computer is caught: nothing there, or this app's own workspace", async () => {assert.deepEqual(await probeServer({ address: "http://127.0.0.1:8799/pair#code=ABCD-EFGH-JKLM", fetch: fakeFetch({}).fetch }), { outcome: "problem", problem: "loopback", host: "127.0.0.1:8799" });const own = fakeFetch({ "http://127.0.0.1:18799": () => descriptor("mine") });diff --git a/electron/tailnet-share.mjs b/electron/tailnet-share.mjsnew file mode 100644index 0000000000..55e32fc438--- /dev/null+++ b/electron/tailnet-share.mjs@@ -0,0 +1,170 @@+// This computer's own server for the person's other computers on the tailnet. `tailscale serve` fronts it with HTTPS when+// the tailnet hands out certificates and nothing else holds the port; otherwise the server listens on its tailnet+// addresses itself. Never Funnel: nothing here is reachable from outside the tailnet.+import { execFile, spawn as spawnChild } from "node:child_process";++import { tailnetOrigin } from "./tailnet.mjs";+import { tailscaleEnvironment } from "./tailscale-check.mjs";++const HTTPS_PORT = 443;+const OFF = Object.freeze({ on: false, origin: null, https: false, problem: null });++/** Whether `tailscale serve status --json` has anything on `port`, foreground sessions included. Unreadable counts as+ * taken: a share the person made themselves is never replaced on a guess. */+export function servePortTaken(stdout, port = HTTPS_PORT) {+ let parsed;+ try {+ parsed = JSON.parse(stdout);+ } catch {+ return true;+ }+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return true;+ const holds = (config) => Boolean(config?.TCP && Object.hasOwn(config.TCP, String(port)));+ return holds(parsed) || Object.values(parsed.Foreground ?? {}).some(holds);+}++const readServeStatus = (cli) =>+ new Promise((resolve) => {+ execFile(cli, ["serve", "status", "--json"], { timeout: 5_000, killSignal: "SIGKILL", maxBuffer: 4 * 1024 * 1024, env: tailscaleEnvironment(), windowsHide: true },+ (error, stdout) => resolve(error ? "" : String(stdout ?? "")));+ });++/**+ * `check()` is checkTailscale. `allowed()` is false while an organization's policy keeps remote access off. `apply` takes+ * the saved Tailscale route, `attach` each new server process; a server process forgets its share when it exits.+ */+export function createTailnetShare({ check, allowed = () => true, spawn = spawnChild, serveStatus = readServeStatus, settleMs = 2_500, answerMs = 5_000, log = () => {} }) {+ let server = null;+ let wanted = null;+ let serving = null;+ let shown = OFF;+ let answered = () => {};+ let httpsBroken = false;+ let queue = Promise.resolve();++ const enqueue = (work) => {+ const next = queue.then(work, work);+ queue = next.then(() => {}, () => {});+ return next;+ };++ /** Tells the server, and waits for what it managed to do. */+ function tell(share) {+ if (!server) return Promise.resolve(null);+ return new Promise((resolve) => {+ const timer = setTimeout(() => resolve(null), answerMs);+ timer.unref?.();+ answered = (reply) => { clearTimeout(timer); answered = () => {}; resolve(reply); };+ server.told ||= share !== null;+ try {+ server.proc.postMessage({ type: "openmausbot:tailnet-share", share });+ } catch {+ answered(null);+ }+ });+ }++ async function stopServing() {+ const current = serving;+ serving = null;+ if (!current) return;+ current.stopping = true;+ try {+ current.child.kill("SIGTERM");+ } catch {+ }+ await Promise.race([current.exited, new Promise((done) => setTimeout(done, 3_000).unref?.())]);+ }++ /** The HTTPS origin once `tailscale serve` is up and Tailscale lists it, else null. */+ async function startServing(cli, name, port) {+ if (servePortTaken(await serveStatus(cli))) {+ log("tailnet: port 443 already serves something; listening on the tailnet instead");+ return null;+ }+ let child;+ try {+ child = spawn(cli, ["serve", `--https=${HTTPS_PORT}`, `http://127.0.0.1:${port}`], { stdio: "ignore", env: tailscaleEnvironment(), windowsHide: true });+ } catch {+ return null;+ }+ const exited = new Promise((done) => { child.once("exit", () => done("exited")); child.once("error", () => done("exited")); });+ const early = await Promise.race([exited, new Promise((done) => setTimeout(() => done("running"), settleMs))]);+ if (early !== "running") {+ log("tailnet: tailscale serve stopped at once; listening on the tailnet instead");+ return null;+ }+ // Serve waits on an enablement link without saying so; only a listed port is a share.+ if (!servePortTaken(await serveStatus(cli))) {+ child.kill("SIGTERM");+ log("tailnet: tailscale serve did not take the port; listening on the tailnet instead");+ return null;+ }+ const entry = { child, port, name, exited, stopping: false };+ serving = entry;+ void exited.then(() => {+ if (entry.stopping || serving !== entry) return;+ log("tailnet: tailscale serve ended; listening on the tailnet instead");+ serving = null;+ httpsBroken = true;+ void enqueue(reconcile);+ });+ return tailnetOrigin(name, HTTPS_PORT, true);+ }++ async function reconcile() {+ const route = wanted;+ if (!server || !route?.on || route.computers !== true || !allowed()) {+ await stopServing();+ if (server?.told) await tell(null);+ shown = OFF;+ return shown;+ }+ const status = await check();+ const ready = status.state === "ready";+ const name = ready ? status.name : route.name;+ if (!name) {+ await stopServing();+ if (server.told) await tell(null);+ shown = { on: true, origin: null, https: false, problem: status.state };+ return shown;+ }+ if (serving && (serving.port !== server.port || serving.name !== name)) await stopServing();+ const origin = serving+ ? tailnetOrigin(name, HTTPS_PORT, true)+ : ready && status.https && status.cli && !httpsBroken ? await startServing(status.cli, name, server.port) : null;+ const reply = await tell(origin ? { name, served: origin } : { name });+ const reached = reply?.origin ?? null;+ shown = { on: true, origin: reached, https: Boolean(origin), problem: reached ? null : ready ? "not-listening" : status.state };+ return shown;+ }++ return {+ /** The person changed something, or asked to check again: HTTPS gets another try. */+ apply(route) {+ wanted = route ?? null;+ httpsBroken = false;+ return enqueue(reconcile);+ },+ /** A new server process has no share yet. */+ attach(proc, port, route) {+ server = { proc, port, told: false };+ wanted = route ?? null;+ httpsBroken = false;+ return enqueue(reconcile);+ },+ /** The server's answer, and its word when Tailscale's interface comes or goes. */+ receive(message) {+ if (message?.type !== "openmausbot:tailnet-share-state") return false;+ answered(message);+ if (shown.on) shown = { ...shown, origin: message.origin ?? null, problem: message.origin ? null : shown.problem ?? "not-listening" };+ return true;+ },+ state: () => shown,+ /** The app is quitting: `tailscale serve` must not outlive the server it fronts. */+ stop() {+ wanted = null;+ return stopServing();+ },+ };+}diff --git a/electron/tailnet-share.node-test.mjs b/electron/tailnet-share.node-test.mjsnew file mode 100644index 0000000000..6116e573da--- /dev/null+++ b/electron/tailnet-share.node-test.mjs@@ -0,0 +1,124 @@+import assert from "node:assert/strict";+import { EventEmitter } from "node:events";+import test from "node:test";++import { createTailnetShare, servePortTaken } from "./tailnet-share.mjs";++const NAME = "macmini.tail1234.ts.net";+const route = (over = {}) => ({ on: true, since: 1, name: NAME, computers: true, ...over });++function world({ status = { state: "ready", name: NAME, addresses: ["100.101.102.103"], https: false, cli: "/usr/bin/tailscale" }, serveStatus = ["{}", '{"TCP":{"443":{"HTTPS":true}}}'], serveExits = false, allowed = () => true } = {}) {+ const w = { posted: [], spawned: [], children: [], checks: 0, statuses: 0 };+ w.share = createTailnetShare({+ check: async () => { w.checks++; return status; },+ allowed,+ settleMs: 5,+ answerMs: 50,+ serveStatus: async () => serveStatus[Math.min(w.statuses++, serveStatus.length - 1)],+ spawn: (cli, args) => {+ w.spawned.push([cli, ...args]);+ const child = Object.assign(new EventEmitter(), { killed: [], kill(signal) { child.killed.push(signal); setImmediate(() => child.emit("exit", null)); } });+ w.children.push(child);+ if (serveExits) setImmediate(() => child.emit("exit", 1));+ return child;+ },+ });+ w.proc = {+ postMessage(message) {+ w.posted.push(message.share);+ const origin = message.share === null ? null : message.share.served ?? `http://${message.share.name}:8799`;+ setImmediate(() => w.share.receive({ type: "openmausbot:tailnet-share-state", origin, listening: [], error: null }));+ },+ };+ return w;+}++test("off, or with no switch for other computers, nothing runs and the server shares nothing", async () => {+ for (const saved of [route({ on: false }), route({ computers: false }), null]) {+ const w = world();+ await w.share.attach(w.proc, 8799, saved);+ assert.equal(w.checks, 0, "Tailscale is not asked");+ assert.deepEqual(w.spawned, []);+ assert.deepEqual(w.posted, [], "a server never told of a share hears nothing");+ assert.deepEqual(w.share.state(), { on: false, origin: null, https: false, problem: null });+ }+});++test("without HTTPS certificates the server listens on the tailnet by itself", async () => {+ const w = world();+ const shown = await w.share.attach(w.proc, 8799, route());+ assert.deepEqual(w.spawned, []);+ assert.deepEqual(w.posted, [{ name: NAME }]);+ assert.deepEqual(shown, { on: true, origin: `http://${NAME}:8799`, https: false, problem: null });+});++test("with certificates `tailscale serve` fronts the server, and the link is the https name", async () => {+ const w = world({ status: { state: "ready", name: NAME, addresses: [], https: true, cli: "/usr/bin/tailscale" } });+ const shown = await w.share.attach(w.proc, 18799, route());+ assert.deepEqual(w.spawned, [["/usr/bin/tailscale", "serve", "--https=443", "http://127.0.0.1:18799"]]);+ assert.ok(!w.spawned[0].some((arg) => /funnel|--bg/.test(arg)), "never Funnel, never left behind");+ assert.deepEqual(w.posted, [{ name: NAME, served: `https://${NAME}` }]);+ assert.deepEqual(shown, { on: true, origin: `https://${NAME}`, https: true, problem: null });+ await w.share.stop();+ assert.deepEqual(w.children[0].killed, ["SIGTERM"]);+});++test("a port the person already serves, or a serve that fails, falls back to listening and replaces nothing", async () => {+ const https = { state: "ready", name: NAME, addresses: [], https: true, cli: "/usr/bin/tailscale" };+ const taken = world({ status: https, serveStatus: ['{"TCP":{"443":{"HTTPS":true}}}'] });+ assert.equal((await taken.share.attach(taken.proc, 8799, route())).https, false);+ assert.deepEqual(taken.spawned, []);+ const failed = world({ status: https, serveExits: true });+ assert.equal((await failed.share.attach(failed.proc, 8799, route())).https, false);+ assert.deepEqual(failed.posted, [{ name: NAME }]);+ const waiting = world({ status: https, serveStatus: ["{}"] });+ assert.equal((await waiting.share.attach(waiting.proc, 8799, route())).https, false, "serve waiting on an enablement link is no share");+ assert.deepEqual(waiting.children[0].killed, ["SIGTERM"]);+ for (const unreadable of ["", "not json", "[]"]) assert.equal(servePortTaken(unreadable), true);+ assert.equal(servePortTaken('{"Foreground":{"abc":{"TCP":{"443":{}}}}}'), true);+ assert.equal(servePortTaken('{"TCP":{"8443":{}}}'), false);+});++test("a serve that ends later hands over to the listener", async () => {+ const w = world({ status: { state: "ready", name: NAME, addresses: [], https: true, cli: "/usr/bin/tailscale" } });+ await w.share.attach(w.proc, 8799, route());+ w.children[0].emit("exit", 1);+ await new Promise((resolve) => setImmediate(resolve));+ for (let i = 0; i < 100 && w.share.state().https; i++) await new Promise((resolve) => setTimeout(resolve, 5));+ assert.deepEqual(w.posted, [{ name: NAME, served: `https://${NAME}` }, { name: NAME }]);+ assert.equal(w.share.state().https, false);+ assert.equal(w.spawned.length, 1, "no retry loop");+});++test("an organization's policy keeps it off, whatever is saved", async () => {+ const w = world({ allowed: () => false });+ const shown = await w.share.attach(w.proc, 8799, route());+ assert.equal(shown.on, false);+ assert.equal(w.checks, 0);+ assert.deepEqual(w.posted, []);+});++test("Tailscale not answering keeps the saved name and says why nothing is there yet; no name at all shares nothing", async () => {+ const quiet = world({ status: { state: "not-running" } });+ quiet.proc.postMessage = (message) => { quiet.posted.push(message.share); setImmediate(() => quiet.share.receive({ type: "openmausbot:tailnet-share-state", origin: null, listening: [], error: "none" })); };+ assert.deepEqual(await quiet.share.attach(quiet.proc, 8799, route()), { on: true, origin: null, https: false, problem: "not-running" });+ assert.deepEqual(quiet.posted, [{ name: NAME }]);+ quiet.share.receive({ type: "openmausbot:tailnet-share-state", origin: `http://${NAME}:8799`, listening: ["100.101.102.103"], error: null });+ assert.deepEqual(quiet.share.state(), { on: true, origin: `http://${NAME}:8799`, https: false, problem: null }, "Tailscale came up by itself");+ const nameless = world({ status: { state: "signed-out" } });+ assert.deepEqual(await nameless.share.attach(nameless.proc, 8799, route({ name: null })), { on: true, origin: null, https: false, problem: "signed-out" });+ assert.deepEqual(nameless.posted, []);+ assert.equal(nameless.share.receive({ type: "other" }), false);+});++test("a new server port moves the serve; turning off stops it and clears the server's share", async () => {+ const w = world({ status: { state: "ready", name: NAME, addresses: [], https: true, cli: "/usr/bin/tailscale" }, serveStatus: ["{}", '{"TCP":{"443":{}}}', "{}", '{"TCP":{"443":{}}}'] });+ await w.share.attach(w.proc, 8799, route());+ await w.share.attach(w.proc, 18799, route());+ assert.deepEqual(w.spawned.map((call) => call.at(-1)), ["http://127.0.0.1:8799", "http://127.0.0.1:18799"]);+ assert.deepEqual(w.children[0].killed, ["SIGTERM"]);+ await w.share.apply(route({ computers: false }));+ assert.deepEqual(w.children[1].killed, ["SIGTERM"]);+ assert.equal(w.posted.at(-1), null);+ assert.equal(w.share.state().on, false);+});diff --git a/electron/tailscale-check.mjs b/electron/tailscale-check.mjsindex e62abde102..b075962912 100644--- a/electron/tailscale-check.mjs+++ b/electron/tailscale-check.mjs@@ -1,11 +1,14 @@-// Runs only when the person presses Turn on or Check again on the Tailscale route, and only Tailscale's command-line-// tool: never the macOS app's executable, so the app is never opened or signed in. Never logs Tailscale's raw output-// (it can carry auth keys and node names).+// Runs only when the person presses Turn on or Check again on the Tailscale route (or the app starts with its share for+// other computers on), and only Tailscale's command-line tool: never the macOS app's executable, so the app is never+// opened or signed in. Never logs Tailscale's raw output (it can carry auth keys and node names).import { execFile } from "node:child_process";+import { Resolver } from "node:dns/promises";import fs from "node:fs";import os from "node:os";import path from "node:path";+import { isTailnetName, readTailscaleStatusJson, tailnetInterfaceAddresses } from "./tailnet.mjs";+/** Tailscale's command-line tool where its installers put it, then PATH. */export const TAILSCALE_CLI_PATHS = Object.freeze(["/opt/homebrew/bin/tailscale",@@ -41,36 +44,49 @@ const runStatus = (cli) =>(error, stdout, stderr) => resolve({ missing: error?.code === "ENOENT", stdout: String(stdout ?? ""), stderr: String(stderr ?? "") }));});-/** What one `tailscale status --json` says, in the row's words: ready (with this computer's MagicDNS name), signed out,- * not running, or not allowed to ask. */+/** What one `tailscale status --json` says, in the row's words: ready (with this computer's MagicDNS name, its tailnet+ * addresses and whether the tailnet hands out HTTPS certificates), signed out, not running, or not allowed to ask. */export function readTailscaleStatus(stdout, stderr = "") {- let parsed = null;- try {- parsed = JSON.parse(stdout);- } catch {- }- if (!parsed) {+ const read = readTailscaleStatusJson(stdout);+ if (!read) {const text = stderr.toLowerCase();if (/access denied|permission denied|operator|not permitted/.test(text)) return { state: "needs-permission" };return { state: "not-running" };}- if (parsed.BackendState === "Stopped") return { state: "not-running" };- const dns = parsed?.Self?.DNSName;- const name = typeof dns === "string" ? dns.replace(/\.$/, "").toLowerCase() : "";- if (parsed.BackendState !== "Running" || !name.endsWith(".ts.net")) return { state: "signed-out" };- return { state: "ready", name };+ if (read.state === "not-running") return { state: "not-running" };+ if (read.state !== "ready" || !read.name) return { state: "signed-out" };+ return { state: "ready", name: read.name, addresses: read.addresses, https: read.https };+}++/** This computer's MagicDNS name, asked of Tailscale's own resolver (100.100.100.100) for its tailnet address: how a Mac+ * with only the Tailscale app, and no command-line tool, still learns it. Null when MagicDNS doesn't say. */+export async function magicDnsName(address, { resolver = new Resolver({ timeout: 2_000, tries: 1 }) } = {}) {+ if (!address) return null;+ try {+ resolver.setServers(["100.100.100.100"]);+ const names = await resolver.reverse(address);+ const name = names.map((found) => String(found).toLowerCase().replace(/\.$/, "")).find(isTailnetName);+ return name ?? null;+ } catch {+ return null;+ }}-export async function checkTailscale({ run = runStatus, install = () => tailscaleInstall(), candidates = TAILSCALE_CLI_PATHS } = {}) {+/** `cli` is the command-line tool that answered, for `tailscale serve`; null when the name came from MagicDNS. */+export async function checkTailscale({ run = runStatus, install = () => tailscaleInstall(), candidates = TAILSCALE_CLI_PATHS, interfaces = () => os.networkInterfaces(), reverse = magicDnsName } = {}) {const found = install();if (found === "none") return { state: "not-installed" };- if (found === "app-only") return { state: "no-cli" };+ if (found === "app-only") {+ const addresses = tailnetInterfaceAddresses(interfaces());+ const name = await reverse(addresses.find((address) => !address.includes(":")));+ return name ? { state: "ready", name, addresses, https: false, cli: null } : { state: addresses.length ? "no-cli" : "not-running" };+ }let last = { state: "not-installed" };for (const cli of candidates) {const result = await run(cli);if (result.missing) continue;last = readTailscaleStatus(result.stdout, result.stderr);- if (last.state === "ready") return last;+ if (last.state === "ready") return { ...last, cli };break;}return last;diff --git a/src/components/PhoneDevicesSection.tsx b/src/components/PhoneDevicesSection.tsxindex 27447f94cb..32ad442ae8 100644--- a/src/components/PhoneDevicesSection.tsx+++ b/src/components/PhoneDevicesSection.tsx@@ -19,6 +19,7 @@ import { companionPairingMode } from "../lib/phone-setup";import { revealPhonePairing } from "../lib/phone-pairing";import { PhonesList } from "./PhonesList";import { PairedPhones } from "./PairedPhones";+import { TailnetComputers } from "./TailnetComputers";import { Card, Switch } from "./SettingsPrimitives";import { productName } from "../lib/brand";import { useStore } from "@/state/store";@@ -421,6 +422,7 @@ export function PhoneDevicesSection({ profileEmail = "", focusRequest = 0, simpl</div></div>)}+ {tailscaleOn && state.routes?.tailscale?.name && <TailnetComputers c={c} state={state} blocked={managedBy} simple={simple} />}<div className="flex items-start justify-between gap-4 border-t border-hairline/30 pt-4" data-route-row="https"><div className="min-w-0"><div className="text-[13px] text-ink">{t("devices.route.https")}</div>diff --git a/src/components/ServerPairingCard.tsx b/src/components/ServerPairingCard.tsxindex c0f6cff74f..23cc6c8b17 100644--- a/src/components/ServerPairingCard.tsx+++ b/src/components/ServerPairingCard.tsx@@ -50,7 +50,7 @@ export function shownDevices(devices: PairedDevice[], cloudHome: boolean): Paireconst button = "ui-button ui-button-primary";const quiet = "ui-button";-export function ServerPairingCard({ initialSession = null, initialPairingCodes = true, cloudHome = false, focusRequest = 0, team, teamPhoneBlocked = null, simple = false }: { initialSession?: SessionState | null; initialPairingCodes?: boolean; cloudHome?: boolean; focusRequest?: number; team?: string; teamPhoneBlocked?: string | null; simple?: boolean }) {+export function ServerPairingCard({ initialSession = null, initialPairingCodes = true, cloudHome = false, focusRequest = 0, team, teamPhoneBlocked = null, simple = false, reveal = true }: { initialSession?: SessionState | null; initialPairingCodes?: boolean; cloudHome?: boolean; focusRequest?: number; team?: string; teamPhoneBlocked?: string | null; simple?: boolean; /** False where another pairing flow owns the page's focus. */ reveal?: boolean }) {const [session, setSession] = useState<SessionState | null>(initialSession);const [pairingCodes, setPairingCodes] = useState(initialPairingCodes);const [computerName, setComputerName] = useState<string | null>(null);@@ -198,7 +198,7 @@ export function ServerPairingCard({ initialSession = null, initialPairingCodes =<option value="client">{t("remote.serverPairing.scope.client")}</option></Select>)}- <button type="button" data-phone-pairing-action onClick={() => void create()} disabled={busy} className="ui-button">+ <button type="button" data-phone-pairing-action={reveal ? "" : undefined} onClick={() => void create()} disabled={busy} className="ui-button">{busy ? t("remote.serverPairing.creating") : t("settings.simple.computer.createCode")}</button></div>@@ -243,7 +243,7 @@ export function ServerPairingCard({ initialSession = null, initialPairingCodes ={t("remote.serverPairing.scope.client")}</label></>}- <button type="button" data-phone-pairing-action onClick={() => void create()} disabled={busy} className={button}>+ <button type="button" data-phone-pairing-action={reveal ? "" : undefined} onClick={() => void create()} disabled={busy} className={button}>{busy ? t("remote.serverPairing.creating") : t("remote.serverPairing.create")}</button></div> : <p data-server-pairing-portal className="mt-3 text-[13px] text-ink-secondary">{t("remote.serverPairing.portal")}</p>}diff --git a/src/components/TailnetComputers.test.ts b/src/components/TailnetComputers.test.tsnew file mode 100644index 0000000000..b3c8f7bc81--- /dev/null+++ b/src/components/TailnetComputers.test.ts@@ -0,0 +1,52 @@+import { createElement } from "react";+import { renderToStaticMarkup } from "react-dom/server";+import { describe, expect, it, vi } from "vitest";++import type { CompanionState, PhoneSetupController } from "./PhoneSetupFlow";+import { TailnetComputers, tailnetShareLine } from "./TailnetComputers";++vi.mock("../lib/session", async (original) => ({ ...await original<typeof import("../lib/session")>(), readSessionState: async () => ({ kind: "loopback" }) }));++const controller = { busy: false, accountBusy: false, act: async () => {} } as unknown as PhoneSetupController;+const row = (computers: boolean, tailnetShare?: CompanionState["tailnetShare"], blocked: string | null = null) => renderToStaticMarkup(createElement(TailnetComputers, {+ c: controller, blocked, simple: true,+ state: { routes: { tailscale: { on: true, since: 1, name: "macmini.tail1234.ts.net", computers } }, tailnetShare } as unknown as CompanionState,+}));++const off = { on: false, origin: null, https: false, problem: null };++describe("the line under Your other computers", () => {+ it("says nothing while the share is off", () => {+ expect(tailnetShareLine(undefined)).toBeNull();+ expect(tailnetShareLine(off)).toBeNull();+ });++ it("names the exact address another computer opens, and how it is protected", () => {+ const https = tailnetShareLine({ on: true, origin: "https://macmini.tail1234.ts.net", https: true, problem: null });+ expect(https).toContain("https://macmini.tail1234.ts.net");+ expect(https).toContain("HTTPS certificate");+ const http = tailnetShareLine({ on: true, origin: "http://macmini.tail1234.ts.net:8799", https: false, problem: null });+ expect(http).toContain("http://macmini.tail1234.ts.net:8799");+ expect(http).toContain("WireGuard");+ });++ it("says Tailscale isn't connected while nothing answers", () => {+ expect(tailnetShareLine({ on: true, origin: null, https: false, problem: "not-listening" })).toContain("isn't connected");+ });+});++describe("the row under the Tailscale route", () => {+ it("is off with a Turn on button until the person chooses, and an organization's policy disables it", () => {+ const off = row(false);+ expect(off).toContain("Turn on");+ expect(off).not.toContain("data-tailnet-share");+ expect(row(false, undefined, "Managed by Acme")).toContain("disabled");+ });++ it("shows the address and Turn off once it is on", () => {+ const on = row(true, { on: true, origin: "http://macmini.tail1234.ts.net:8799", https: false, problem: null });+ expect(on).toContain("Turn off");+ expect(on).toContain("data-tailnet-share");+ expect(on).toContain("http://macmini.tail1234.ts.net:8799");+ });+});diff --git a/src/components/TailnetComputers.tsx b/src/components/TailnetComputers.tsxnew file mode 100644index 0000000000..9721c3dc84--- /dev/null+++ b/src/components/TailnetComputers.tsx@@ -0,0 +1,36 @@+import { t } from "@/lib/i18n";+import { productName } from "../lib/brand";+import type { TailnetShareState } from "../lib/companion-types";+import type { CompanionState, PhoneSetupController } from "./PhoneSetupFlow";+import { ServerPairingCard } from "./ServerPairingCard";++const button = "rounded-lg border border-hairline/40 px-3 py-1.5 text-[12px] text-ink hover:bg-control disabled:opacity-40";++/** What the row says about the share right now; null while it is off. */+export function tailnetShareLine(share: TailnetShareState | undefined): string | null {+ if (!share?.on) return null;+ if (!share.origin) return t("devices.computers.waiting", { app: productName() });+ return t(share.https ? "devices.computers.https" : "devices.computers.http", { address: share.origin });+}++/** Under the Tailscale route: lets the person's other computers open this one, and makes them a pairing code. */+export function TailnetComputers({ c, state, blocked, simple }: { c: PhoneSetupController; state: CompanionState; blocked: string | null; simple: boolean }) {+ const on = state.routes?.tailscale?.computers === true;+ const line = tailnetShareLine(state.tailnetShare);+ return (+ <div className="flex flex-col gap-3 border-t border-hairline/30 pt-4" data-route-row="tailscale-computers">+ <div className="flex items-center justify-between gap-4">+ <div className="min-w-0">+ <div className="text-[13px] text-ink">{t("devices.computers.title")}</div>+ <div className="mt-0.5 text-[12px] leading-relaxed text-ink-secondary">{t("devices.computers.detail")}</div>+ {on && line && <div data-tailnet-share className="mt-1 break-words text-[12px] leading-relaxed text-ink" aria-live="polite">{line}</div>}+ </div>+ <button type="button" className={button} disabled={c.busy || c.accountBusy || (Boolean(blocked) && !on)} title={blocked ?? undefined}+ onClick={() => void c.act((companion) => companion.setTailscaleComputers?.(!on) ?? companion.state())}>+ {on ? t("devices.route.turnOff") : t("devices.route.turnOn")}+ </button>+ </div>+ {on && state.tailnetShare?.origin && <ServerPairingCard simple={simple} reveal={false} />}+ </div>+ );+}diff --git a/src/lib/companion-types.ts b/src/lib/companion-types.tsindex a5a62f06cb..403e5d6def 100644--- a/src/lib/companion-types.ts+++ b/src/lib/companion-types.ts@@ -20,6 +20,16 @@ export interface PhoneDevice {/** Same Wi-Fi, Anywhere through MausBot, Tailscale, and the HTTPS address. */export type CompanionRoute = "wifi" | "relay" | "tailscale" | "https";+export interface TailnetShareState {+ on: boolean;+ /** The address another computer opens; null while nothing answers there. */+ origin: string | null;+ /** Tailscale's own certificate fronts it; otherwise it is plain http inside WireGuard. */+ https: boolean;+ /** Why nothing answers: "not-listening", or the state Tailscale reported. */+ problem: string | null;+}+export interface CompanionState {enabled: boolean;keepAwake: boolean;@@ -31,11 +41,13 @@ export interface CompanionState {tailscale?: string;tailnetName?: string;/** Each way into this computer and whether the person turned it on. Absent on older builds. */- routes?: Record<CompanionRoute, { on: boolean; since: number | null; name?: string | null }>;+ routes?: Record<CompanionRoute, { on: boolean; since: number | null; name?: string | null; computers?: boolean }>;/** Routes the update kept on that the person has not been told about yet. */notices?: CompanionRoute[];/** Why Tailscale could not be turned on or checked just now. */tailscaleProblem?: "not-installed" | "no-cli" | "not-running" | "needs-permission" | "signed-out";+ /** This computer's own server on the tailnet, for the person's other computers. Absent on older builds. */+ tailnetShare?: TailnetShareState;lan?: string | null;hosts?: string[];endpoints?: CompanionEndpoint[];@@ -58,6 +70,8 @@ export type CompanionBridge = {refreshTailscale: () => Promise<CompanionState>;/** The rest are absent on an app build before per-route switches. */setTailscale?: (on: boolean) => Promise<CompanionState>;+ /** Whether the person's other computers may open this one over Tailscale. */+ setTailscaleComputers?: (on: boolean) => Promise<CompanionState>;setRoute?: (route: CompanionRoute, on: boolean) => Promise<CompanionState>;dismissNotice?: (route: CompanionRoute) => Promise<CompanionState>;pairing: (open: boolean, expectedToken?: string) => Promise<CompanionState>;diff --git a/src/locales/en.json b/src/locales/en.jsonindex 0caecda3d0..3964befafa 100644--- a/src/locales/en.json+++ b/src/locales/en.json@@ -9217,6 +9217,10 @@"native.connect.desktopApp": "{host} is a MausBot desktop app, and one desktop app can't connect to another. To use that computer from here, share it with My Cloud from its own app, or use My Cloud.","native.connect.loopback": "This points at this computer ({host}), not at the server. Use the server's own address.","native.connect.localNetwork": "Can't reach {host}. On a Mac, turn on OpenMausBot in System Settings → Privacy & Security → Local Network, then try again. Also check that the server is running on this network.",+ "native.connect.tailscaleOff": "{host} is on a Tailscale network, and Tailscale isn't connected on this computer. Open Tailscale here, sign in to the same tailnet, then try again.",+ "native.connect.otherTailnet": "{host} isn't on this computer's tailnet. Sign in to Tailscale here with the account that computer uses, keep MagicDNS on, then try again.",+ "native.connect.tailnetBlocked": "macOS blocked the connection to {host}. Allow OpenMausBot in System Settings → Privacy & Security → Local Network (Tailscale addresses count as local), then try again. If it's on already, turn it off and on again.",+ "native.connect.tailnetSilent": "{host} is on your tailnet but didn't answer. Check that the computer is awake with Tailscale connected, and that MausBot is shared on Tailscale there: in its Settings → Phone & devices, or with openmausbot serve --tailscale.","native.dialog.mic.allow": "Allow","native.dialog.mic.deny": "Don’t Allow","native.dialog.mic.title": "Allow “{name}” to use the microphone?",@@ -9925,6 +9929,11 @@"devices.pairedNone": "Nothing paired yet.","devices.howTheyReach": "How they reach this computer","devices.moreWays": "More ways in",+ "devices.computers.title": "Your other computers",+ "devices.computers.detail": "Off until you turn it on. On, a computer on your tailnet can open this one from Connect to a server, once you give it a pairing code.",+ "devices.computers.https": "Ready at {address}, with Tailscale's HTTPS certificate.",+ "devices.computers.http": "Ready at {address}. Only your tailnet reaches it, and WireGuard encrypts it. For an https address, turn on HTTPS Certificates in Tailscale's DNS settings, then check again.",+ "devices.computers.waiting": "Tailscale isn't connected on this computer yet. {app} answers here as soon as it is.","devices.route.wifi": "Same Wi-Fi","devices.route.wifiDetail": "Devices on this network. End-to-end encrypted.","devices.route.relay": "Anywhere, through {app}",diff --git a/src/locales/pt-br.json b/src/locales/pt-br.jsonindex 68fd1d7908..6977e77767 100644--- a/src/locales/pt-br.json+++ b/src/locales/pt-br.json@@ -9189,6 +9189,10 @@"native.connect.desktopApp": "{host} é um app de desktop do MausBot, e um app de desktop não pode se conectar a outro. Para usar esse computador daqui, compartilhe-o com o My Cloud pelo próprio app dele, ou use o My Cloud.","native.connect.loopback": "Isso aponta para este computador ({host}), não para o servidor. Use o endereço do próprio servidor.","native.connect.localNetwork": "Não foi possível acessar {host}. No Mac, ative o OpenMausBot em Ajustes do Sistema → Privacidade e Segurança → Rede Local e tente de novo. Verifique também se o servidor está rodando nesta rede.",+ "native.connect.tailscaleOff": "{host} está em uma rede Tailscale, e o Tailscale não está conectado neste computador. Abra o Tailscale aqui, entre na mesma tailnet e tente de novo.",+ "native.connect.otherTailnet": "{host} não está na tailnet deste computador. Entre no Tailscale aqui com a conta que aquele computador usa, mantenha o MagicDNS ativado e tente de novo.",+ "native.connect.tailnetBlocked": "O macOS bloqueou a conexão com {host}. Permita o OpenMausBot em Ajustes do Sistema → Privacidade e Segurança → Rede Local (endereços do Tailscale contam como locais) e tente de novo. Se já estiver ativado, desative e ative de novo.",+ "native.connect.tailnetSilent": "{host} está na sua tailnet, mas não respondeu. Verifique se o computador está ligado com o Tailscale conectado e se o MausBot está compartilhado no Tailscale lá: nas Configurações dele → Celular e dispositivos, ou com openmausbot serve --tailscale.","native.dialog.mic.allow": "Permitir","native.dialog.mic.deny": "Não permitir","native.dialog.mic.title": "Permitir que “{name}” use o microfone?",@@ -9925,6 +9929,11 @@"devices.pairedNone": "Nada pareado ainda.","devices.howTheyReach": "Como eles chegam a este computador","devices.moreWays": "Mais formas de acesso",+ "devices.computers.title": "Seus outros computadores",+ "devices.computers.detail": "Desligado até você ligar. Ligado, um computador da sua tailnet pode abrir este em Conectar a um servidor, depois que você der um código de pareamento.",+ "devices.computers.https": "Pronto em {address}, com o certificado HTTPS do Tailscale.",+ "devices.computers.http": "Pronto em {address}. Só a sua tailnet tem acesso, e o WireGuard criptografa a conexão. Para um endereço https, ative HTTPS Certificates nos ajustes de DNS do Tailscale e verifique de novo.",+ "devices.computers.waiting": "O Tailscale ainda não está conectado neste computador. O {app} responde aqui assim que estiver.","devices.route.wifi": "Mesmo Wi-Fi","devices.route.wifiDetail": "Dispositivos nesta rede. Criptografia de ponta a ponta.","devices.route.relay": "De qualquer lugar, pelo {app}",