Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Say when a pairing link works only on the same Wi-Fi
Bugfixer 27486c1bf87b0
diff --git a/docs/phone-web-app.md b/docs/phone-web-app.mdindex 1de8c1be21..567cb32462 100644--- a/docs/phone-web-app.md+++ b/docs/phone-web-app.md@@ -19,5 +19,12 @@ The installed start address is the workspace root; pairing codes and URL tokensare not saved in the manifest. Use a new pairing invitation if access expiresor the device is revoked.+A plain `http://` link on your home network (such as `http://192.168.1.20:8799`)+works only while the phone is on the same Wi-Fi as the computer; the pairing+screen says so. To use it away from home, give the computer an HTTPS address+(Tailscale or your own proxy), or use the MausBot phone app, which can connect+**Anywhere** through an end-to-end encrypted relay (start the server with+`openmausbot serve --relay`).+Your server must be running and reachable. This web app does not add offlinechat, push notifications or native phone computer control.diff --git a/src/components/ServerPairingCard.test.ts b/src/components/ServerPairingCard.test.tsindex bea42a8763..7dc2febe21 100644--- a/src/components/ServerPairingCard.test.ts+++ b/src/components/ServerPairingCard.test.ts@@ -3,7 +3,7 @@ import { renderToStaticMarkup } from "react-dom/server";import { describe, expect, it } from "vitest";import { codeUntil, lastSeen } from "../lib/pairing-time";-import { canPairDevices, pairingBlockedReason, phoneSecretNote, ServerPairingCard, shownDevices } from "./ServerPairingCard";+import { canPairDevices, pairingBlockedReason, phoneSecretNote, sameWifiOnlyLink, ServerPairingCard, shownDevices } from "./ServerPairingCard";describe("pairing devices from a hosted server's settings", () => {it("is offered to the owner on the box and to admin sessions, never to chat-only sessions", () => {@@ -93,4 +93,17 @@ describe("pairing devices from a hosted server's settings", () => {expect(phoneSecretNote({ phoneSecrets: true })).toBeNull();expect(phoneSecretNote({})).toBeNull();});++ it("says a pairing link works on the same Wi-Fi only when it is a plain http address on this network", () => {+ expect(sameWifiOnlyLink("http://192.168.1.20:5199/pair#code=ABCD-EFGH-IJKL")).toBe(true);+ expect(sameWifiOnlyLink("http://10.0.0.5:5199/pair#code=ABCD-EFGH-IJKL")).toBe(true);+ expect(sameWifiOnlyLink("http://my-pc.local:5199/pair#code=ABCD-EFGH-IJKL")).toBe(true);+ expect(sameWifiOnlyLink("https://bots.example.com/pair#code=ABCD-EFGH-IJKL")).toBe(false);+ expect(sameWifiOnlyLink("http://my-pc.tail1234.ts.net:5199/pair#code=ABCD-EFGH-IJKL")).toBe(false);+ expect(sameWifiOnlyLink("http://100.101.102.103:5199/pair#code=ABCD-EFGH-IJKL")).toBe(false);+ expect(sameWifiOnlyLink("http://[fd7a:115c:a1e0::1]:5199/pair#code=ABCD-EFGH-IJKL")).toBe(false);+ expect(sameWifiOnlyLink("http://bots.example.com/pair#code=ABCD-EFGH-IJKL")).toBe(false);+ expect(sameWifiOnlyLink(null)).toBe(false);+ expect(sameWifiOnlyLink("not a link")).toBe(false);+ });});diff --git a/src/components/ServerPairingCard.tsx b/src/components/ServerPairingCard.tsxindex d86d8784a3..102b44a2ab 100644--- a/src/components/ServerPairingCard.tsx+++ b/src/components/ServerPairingCard.tsx@@ -17,6 +17,7 @@ import { Select } from "./Select";import { cn } from "@/lib/cn";import { TeamPhoneCard } from "./TeamPhoneCard";import { ComputerNameRow } from "./ComputerNameRow";+import { isPrivateHost, serverTransport } from "../../electron/server-address.mjs";export interface PairingOffer {id: string;@@ -54,6 +55,20 @@ export function phoneSecretNote(offer: Pick<PairingOffer, "phoneSecrets">): strireturn offer.phoneSecrets === false ? t("remote.serverPairing.noPhoneSecrets") : null;}+/** True when a pairing link is a plain http address on a home network: a phone away from that Wi-Fi cannot open it.+ * Tailscale addresses (100.64/10, fd7a:115c:a1e0::/48, `*.ts.net`) work from anywhere on the tailnet, so they get no note. */+export function sameWifiOnlyLink(url: string | null): boolean {+ if (!url) return false;+ try {+ const { hostname } = new URL(url);+ if (serverTransport(url) !== "private-http" || !isPrivateHost(hostname)) return false;+ const [a, b] = hostname.split(".").map(Number);+ return !(a === 100 && b >= 64 && b <= 127) && !hostname.startsWith("[fd7a:115c:a1e0:");+ } catch {+ return false;+ }+}+export function shownDevices(devices: PairedDevice[], cloudHome: boolean): PairedDevice[] {return cloudHome ? devices.filter((device) => device.scopes.includes("admin")) : devices;}@@ -169,6 +184,7 @@ export function ServerPairingCard({ initialSession = null, initialPairingCodes =}const secretNote = offer ? phoneSecretNote(offer) : null;+ const sameWifiOnly = sameWifiOnlyLink(offer?.url ?? null);const offerPanel = pairingCodes && offer ? (<Layer modal><div role="dialog" aria-modal="true" aria-label={t("phone.pair.dialogTitle", { place: placeName })} data-settings-look="simple" data-pair-dialog="code"@@ -198,6 +214,7 @@ export function ServerPairingCard({ initialSession = null, initialPairingCodes =</div><p className="text-[12px] leading-4 text-ink-secondary">{t(cloudHome ? "phone.pair.cloudPersonal" : "remote.serverPairing.subtitle", { app: productName() })}</p>{secretNote ? <p data-pair-no-phone-secrets="" className="text-[12px] leading-4 text-ink-secondary">{secretNote}</p> : null}+ {sameWifiOnly ? <p data-pair-same-wifi="" className="text-[12px] leading-4 text-ink-secondary">{t("remote.serverPairing.sameWifiOnly", { app: productName() })}</p> : null}</div>)}<div className="flex items-center justify-end gap-2">diff --git a/src/locales/en.json b/src/locales/en.jsonindex e38ca6e735..7506da0e24 100644--- a/src/locales/en.json+++ b/src/locales/en.json@@ -6124,6 +6124,7 @@"remote.serverPairing.title": "Pair a phone or another computer","remote.serverPairing.subtitle": "Create a one-time code, then scan it with the {app} app or open the link in a browser. Codes work once and expire after five minutes.","remote.serverPairing.noPhoneSecrets": "This phone can chat and approve here, but secrets must be entered on the web or computer.",+ "remote.serverPairing.sameWifiOnly": "This link works only on the same Wi-Fi as this computer. To use it away from home, pair the {app} phone app and choose Anywhere (this computer needs {app} Relay on), or give this computer an HTTPS address, for example with Tailscale.","remote.serverPairing.scope.admin": "Full access","remote.serverPairing.scope.client": "Chat and approvals only","remote.serverPairing.create": "Create pairing code",diff --git a/src/locales/pt-br.json b/src/locales/pt-br.jsonindex 296c7aca00..41622200e6 100644--- a/src/locales/pt-br.json+++ b/src/locales/pt-br.json@@ -5816,6 +5816,7 @@"remote.serverPairing.copied": "Copiado","remote.serverPairing.noLink": "Este servidor ainda não tem um endereço público para o link: abra /pair no endereço que você usa e digite o código.","remote.serverPairing.noPhoneSecrets": "Este celular pode conversar e aprovar aqui, mas os segredos precisam ser inseridos na web ou no computador.",+ "remote.serverPairing.sameWifiOnly": "Este link só funciona no mesmo Wi-Fi deste computador. Para usar fora de casa, pareie o app {app} no celular e escolha Qualquer lugar (este computador precisa do {app} Relay ligado), ou dê a este computador um endereço HTTPS, por exemplo com o Tailscale.","remote.serverPairing.chatOnly": "Este dispositivo está conectado só com chat e aprovações, então não pode parear outros. No computador que roda o servidor, rode `openmausbot pair` (ou abra as Configurações lá) para gerar um código com acesso total e conecte este dispositivo novamente com ele.","remote.serverPairing.devices": "Dispositivos pareados","remote.serverPairing.noDevices": "Nenhum dispositivo pareado ainda.",