Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Boat sign-in: one accessor for every Boat call, its store, routes and callback
milind-soni2576853d67f1
diff --git a/electron/boat-sign-in-store.mjs b/electron/boat-sign-in-store.mjsnew file mode 100644index 0000000000..5c83a0a1d0--- /dev/null+++ b/electron/boat-sign-in-store.mjs@@ -0,0 +1,60 @@+// The desktop app keeps a "Sign in with Boat" connection where it keeps the pasted Boat key: in the operating system's+// encrypted credential document, written only by this process. The embedded server reads it at start (its environment,+// like the key) and asks for every later read and write over the private utility-process port.+export const BOAT_SIGN_IN_CREDENTIAL = "boatSignIn";+export const BOAT_SIGN_IN_ENV = "OMB_BOAT_SIGN_IN";+const REQUEST = "openmausbot:boat-sign-in-store";+const RESULT = "openmausbot:boat-sign-in-store-result";+const MAX_BYTES = 16_384;++const stored = (credentials) => {+ const value = credentials?.[BOAT_SIGN_IN_CREDENTIAL];+ return typeof value === "string" && value ? value : null;+};++/** Set, even when empty, only by a packaged app: its presence tells the server the connection is kept here. */+export function boatSignInEnv(credentials, packaged) {+ return packaged ? { [BOAT_SIGN_IN_ENV]: stored(credentials) ?? "" } : {};+}++export function decodeBoatSignInStoreRequest(rawMessage) {+ const message = rawMessage?.data ?? rawMessage;+ if (!message || typeof message !== "object" || Array.isArray(message) || message.type !== REQUEST) return null;+ if (typeof message.requestId !== "string" || !/^[A-Za-z0-9_-]{1,80}$/.test(message.requestId)) return null;+ if (message.op === "read") return { requestId: message.requestId, op: "read" };+ if (message.op !== "write") return null;+ const value = message.value;+ if (value !== null && (typeof value !== "string" || !value || Buffer.byteLength(value) > MAX_BYTES)) return null;+ return { requestId: message.requestId, op: "write", value };+}++/** `read()` is the current credential document; `update(derive)` is the app's one serialized, encrypted writer. */+export function createBoatSignInStore({ packaged, read, update, log }) {+ const answer = async (request) => {+ if (!packaged) return { type: RESULT, requestId: request.requestId, ok: false };+ try {+ if (request.op === "read") return { type: RESULT, requestId: request.requestId, ok: true, value: stored(read()) };+ await update((credentials) => {+ if (request.value === null) delete credentials[BOAT_SIGN_IN_CREDENTIAL];+ else credentials[BOAT_SIGN_IN_CREDENTIAL] = request.value;+ return credentials;+ });+ return { type: RESULT, requestId: request.requestId, ok: true };+ } catch (error) {+ // The reason only: a credential never reaches the log.+ log(`boat sign-in ${request.op} failed: ${error?.message ?? "error"}`);+ return { type: RESULT, requestId: request.requestId, ok: false };+ }+ };+ return {+ /** True when the message was a store request (then answered on the same port). */+ receive(proc, rawMessage) {+ const request = decodeBoatSignInStoreRequest(rawMessage);+ if (!request) return false;+ void answer(request).then((result) => {+ try { proc.postMessage(result); } catch (error) { log(`boat sign-in result failed: ${error?.message ?? "error"}`); }+ });+ return true;+ },+ };+}diff --git a/electron/diagnostics.mjs b/electron/diagnostics.mjsindex f33621cab2..f5b5559b6c 100644--- a/electron/diagnostics.mjs+++ b/electron/diagnostics.mjs@@ -20,7 +20,7 @@ export const CREDENTIAL_ENV_NAMES = ["OPENAI_COMPAT_URL","OMB_OPENAI_API_KEY","OMB_OPENROUTER_API_KEY",- "BOX_TOKEN",+ "BOX_TOKEN", "OMB_BOAT_SIGN_IN","OPENCODE_API_KEY","OMB_TTS_KEY","OMB_FISH_AUDIO_API_KEY",diff --git a/electron/main.mjs b/electron/main.mjsindex b0ea932f53..ff8a405191 100644--- a/electron/main.mjs+++ b/electron/main.mjs@@ -114,7 +114,7 @@ import { createHomePlaces } from "./home-places.mjs"; import { openStartPlace }import { createWindowStateFile } from "./window-state-file.mjs"; import { createSystemProxyCache } from "./system-proxy.mjs"; import { createBootHeadStart } from "./boot-head-start.mjs";import { createEnvironmentsFile, ENVIRONMENTS_SAVE_FAILED } from "./environments-file.mjs";import { createOrgLibrary } from "./org-library.mjs";-import { createCompanyBackups } from "./company-backups.mjs";+import { createCompanyBackups } from "./company-backups.mjs"; import { boatSignInEnv, createBoatSignInStore } from "./boat-sign-in-store.mjs";import { createCompanyBackupSchedule } from "./company-backup-schedule.mjs";import { installServerSessions, reportOwnListeners } from "./server-session.mjs";@@ -1082,6 +1082,7 @@ const savePhoneSecretOnce = createPhoneSecretSaveCoordinator((target, value) =>saveWorkspaceCredential(target, value),);+const boatSignInStore = createBoatSignInStore({ packaged: app.isPackaged, read: () => secureCredentialState?.read() ?? secureCredentials, update: (derive) => updateSecureCredentialDocument(derive), log: slog });function receivePhoneSecretSave(proc, rawMessage) {const request = decodePhoneSecretSaveRequest(rawMessage);if (!request) return false;@@ -1118,7 +1119,7 @@ async function startServerOn(port, dataDir = runningDataDir ?? startupEnvironmen? { COMPOSIO_API_KEY: secureCredentials.composioApiKey }: {}),OMB_CREDENTIAL_STORE: credentialStoreUnavailable ? "unavailable" : "ok",- ...workspaceCredentialEnv(secureCredentials),+ ...workspaceCredentialEnv(secureCredentials), ...boatSignInEnv(secureCredentials, app.isPackaged),});delete childEnv.OMB_BROWSER_CONNECTION; if (app.isPackaged) delete childEnv.OMB_TEST_COOKIE_KEY; // a live test's fixture key; never a packaged app'sdelete childEnv.OMB_SERVER_COMPILE_CACHE;@@ -1144,7 +1145,7 @@ async function startServerOn(port, dataDir = runningDataDir ?? startupEnvironmenif (browserPanes.receive(proc, message) || trustedApprovalMode.receive(proc, message)) return;if (managedDesktopRelay.receive(proc, message)) return;if (orgLibrary?.receive(message)) return;- if (receivePhoneSecretSave(proc, message) || oneHome.receive(proc, message) || tailnetShare.receive(message)) return;+ if (boatSignInStore.receive(proc, message) || receivePhoneSecretSave(proc, message) || oneHome.receive(proc, message) || tailnetShare.receive(message)) return;} catch (error) {slog(`desktop private sync rejected: ${error?.message ?? error}`);}diff --git a/server/boat-account-change.ts b/server/boat-account-change.tsnew file mode 100644index 0000000000..3b103df882--- /dev/null+++ b/server/boat-account-change.ts@@ -0,0 +1,67 @@+// Before "Sign in with Boat" replaces, or stops being, the Boat credential in use: the same checks a changed API key+// gets in Settings (server/routes/config.ts). The cloud computers this installation remembers must be reachable with+// what comes next, so none is left running on an account the app can no longer reach.+import * as boat from "./boat.ts";+import { boatCreateRecoverySnapshot, retireDeletedBoatCreate } from "./boat-create-idempotency.ts";+import { boatDeletionSnapshot } from "./boat-delete-journal.ts";+import { boatAccountResourceChangeError } from "./cloud-backend.ts";+import type { AppConfig } from "./config.ts";++type Identity = { boxId: string; name: string };++/** `current` and `next` each name one credential (`{ box: { token } }`); null is none. A refusal in words, or null. */+export async function boatAccountChangeRefusal(+ current: AppConfig | null,+ next: AppConfig | null,+ owners: boat.ManagedBoatOwner[],+): Promise<string | null> {+ if (boatDeletionSnapshot().length > 0) {+ if (!next) return "finish or retry pending cloud computer deletion before removing the Boat account";+ try {+ await boat.verifyBoatDeletionCredential(next);+ } catch (error) {+ return error instanceof Error ? error.message : "a cloud computer being deleted could not be verified";+ }+ }+ const deleting = new Set(boatDeletionSnapshot().map((entry) => entry.boxId));+ const recoveries = boatCreateRecoverySnapshot();++ let kept: Map<string, Identity> | null = null;+ if (current) {+ const inventory = await boat.listManagedBoats(current, owners);+ if (inventory.available) {+ kept = new Map(inventory.instances.map((instance) => [instance.boxId, { boxId: instance.boxId, name: instance.name }]));+ for (const recovery of recoveries) {+ if (!recovery.boxId || deleting.has(recovery.boxId)) continue;+ const inspected = await boat.inspectBoatIdentity(current, recovery.boxId);+ if (!inspected.available) return `${inspected.problem ?? "a remembered cloud computer could not be verified"}. Keep the current Boat account and retry`;+ // A receipt for a computer that is gone is retired while the current credential still proves it.+ if (!inspected.identity) retireDeletedBoatCreate(recovery.boxId);+ else kept.set(inspected.identity.boxId, inspected.identity);+ }+ } else if (!(inventory.credentialRejected === true && next)) {+ // A credential Boat no longer accepts cannot vouch for anything; one that could not be asked must be asked again.+ return `${inventory.problem ?? "cloud computer inventory is unavailable"}. Keep the current Boat account and retry`;+ }+ }++ if (!next) {+ if (kept) return boatAccountResourceChangeError([...kept.values()], null);+ return boatCreateRecoverySnapshot().length > 0 ? "restore the Boat account that owns the remembered cloud computers before clearing it" : null;+ }++ const replacement = await boat.listManagedBoats(next, owners, { adoptLegacy: false });+ if (!replacement.available) return replacement.problem ?? "Could not verify the Boat account. Nothing was changed.";+ const reached = new Map(replacement.instances.map((instance) => [instance.boxId, { boxId: instance.boxId, name: instance.name }]));+ for (const recovery of boatCreateRecoverySnapshot()) {+ if (!recovery.boxId) return "finish reconciling pending cloud computer creation before changing the Boat account";+ if (deleting.has(recovery.boxId)) continue;+ const inspected = await boat.inspectBoatIdentity(next, recovery.boxId);+ if (!inspected.available) return `${inspected.problem ?? "a remembered cloud computer could not be verified"}. Retry with the Boat account that created it`;+ if (!inspected.identity || !(await boat.boatNameMatchesBot(recovery.botId, inspected.identity.name))) {+ return "that Boat account cannot access the remembered cloud computers from this installation";+ }+ reached.set(inspected.identity.boxId, inspected.identity);+ }+ return kept ? boatAccountResourceChangeError([...kept.values()], [...reached.values()]) : null;+}diff --git a/server/boat-call.ts b/server/boat-call.tsnew file mode 100644index 0000000000..523eb29e11--- /dev/null+++ b/server/boat-call.ts@@ -0,0 +1,100 @@+// The one place a Boat API call gets its bearer. A pasted key and the plan's included token are sent as they are; a+// "Sign in with Boat" connection gives a current access token (renewed by one caller at a time, server/boat-sign-in.ts),+// and what Boat refuses a sign-in for is put in the person's words here, so no caller reads it as a rejected API key.+import { BOAT_SIGN_IN_MARK } from "../shared/boat-sign-in.ts";+import { relayPath } from "./boat-relay.ts";+import { BOAT_SIGN_IN_PROBLEM, BoatSignInError, type BoatScope } from "./boat-sign-in.ts";+import { boatSignIn } from "./boat-sign-in-use.ts";+import { boatProviderApi, type ServiceCredential } from "./included-services.ts";++const SETTINGS = "Settings → AI → Other services";+const AGAIN = `Sign in to Boat again in ${SETTINGS} and keep it ticked, or paste an API key there`;++/** What each scope the app asks for is used for (the PR lists why each is needed). */+export const BOAT_SCOPE_USE: Record<BoatScope, string> = {+ "account.read": "show which Boat account is signed in",+ "sandbox.read": "see your cloud computers",+ "sandbox.create": "create a cloud computer",+ "sandbox.resume": "wake a cloud computer",+ "sandbox.stop": "stop a cloud computer",+ "sandbox.update": "name a cloud computer and set when it stops by itself",+ "sandbox.delete-own": "delete a cloud computer it created",+ exec: "run commands on a cloud computer",+ "file.read": "read files and the screen of a cloud computer",+ "file.write": "copy files to a cloud computer",+ desktop: "show a cloud computer's desktop",+};++export const boatScopeRefusal = (scope: BoatScope): string =>+ `Your Boat account sign-in does not let this app ${BOAT_SCOPE_USE[scope]}: "${scope}" was not allowed. ${AGAIN}`;++const refusal = (status: number, error: string, message: string): Response =>+ new Response(JSON.stringify({ ok: false, error, message, boatSignIn: true }), { status, headers: { "content-type": "application/json" } });++function words(status: number, code: string, method: string, scope: BoatScope | null): string | null {+ if (status === 400) {+ return code === "org_required"+ ? `Your Boat account sign-in covers several organizations and none of them is your default. Sign in to Boat again in ${SETTINGS} and tick one place, or set a default organization in boat.dev`+ : null;+ }+ if (status === 401) return BOAT_SIGN_IN_PROBLEM["needs-sign-in"];+ if (code === "api_key_sandbox_forbidden") {+ return `Your Boat account sign-in does not reach this cloud computer: its organization or environment was not ticked when you signed in. Sign in to Boat again in ${SETTINGS} and tick it, or paste an API key there`;+ }+ if (method === "DELETE") {+ return `Your Boat account sign-in may delete only the cloud computers it created, and boat.dev did not let it delete this one. Delete it in boat.dev, or paste an API key in ${SETTINGS}`;+ }+ if (scope) return boatScopeRefusal(scope);+ return `boat.dev refused this for your Boat account sign-in. ${AGAIN}`;+}++/** Boat's refusal of a sign-in, with the same status and body plus `message` in plain words and `boatSignIn: true`. */+async function explained(response: Response, method: string, path: string): Promise<Response> {+ let body: any = null;+ try { body = await response.json(); } catch { /* no JSON: read by its status */ }+ const found = typeof body?.error === "string" ? body.error : body?.error?.code ?? body?.code;+ const code = typeof found === "string" ? found : "";+ const message = words(response.status, code, method, boatSignIn()?.scopeOf(method, path) ?? null);+ const next = message ? { ...(body && typeof body === "object" ? body : {}), message, boatSignIn: true } : body;+ return new Response(JSON.stringify(next), { status: response.status, statusText: response.statusText, headers: { "content-type": "application/json" } });+}++/** The words for a refused sign-in call, when `body` is one; else null and the caller's own words apply. */+export const boatSignInWords = (body: any): string | null =>+ body?.boatSignIn === true && typeof body.message === "string" ? body.message : null;++/** An own token goes to Boat; Cloud Pro's included token only to its relay. */+export async function boatCall(account: ServiceCredential | null, path: string, opts: RequestInit = {}): Promise<Response> {+ const url = `${account?.api ?? boatProviderApi()}${relayPath(account, path)}`;+ const send = (bearer: string | undefined) => fetch(url, {+ ...opts,+ headers: { authorization: `Bearer ${bearer}`, "content-type": "application/json", ...opts.headers },+ });+ if (account?.token !== BOAT_SIGN_IN_MARK) return send(account?.token);++ const signIn = boatSignIn();+ if (!signIn) return refusal(401, "boat_sign_in_ended", BOAT_SIGN_IN_PROBLEM["signed-out"]);+ const method = (opts.method ?? "GET").toUpperCase();+ const missing = signIn.missingScope(method, path);+ // Not sent: Boat would refuse it, and the person is told which permission is missing.+ if (missing) return refusal(403, "api_key_action_forbidden", boatScopeRefusal(missing));+ let bearer: string;+ try {+ bearer = await signIn.accessToken();+ } catch (error) {+ if (error instanceof BoatSignInError && (error.problem === "needs-sign-in" || error.problem === "signed-out")) {+ return refusal(401, "boat_sign_in_ended", error.message);+ }+ // Not reached or not saved: like a network failure, the call did not happen and may be tried again.+ throw error instanceof BoatSignInError ? new Error(error.message) : error;+ }+ let response = await send(bearer);+ if (response.status === 401 && (opts.body === undefined || opts.body === null || typeof opts.body === "string")) {+ const renewed = await signIn.afterRefusal(bearer);+ if (renewed) {+ void response.body?.cancel().catch(() => undefined);+ response = await send(renewed);+ }+ }+ return response.status === 400 || response.status === 401 || response.status === 403 ? explained(response, method, path) : response;+}diff --git a/server/boat-sign-in-host.ts b/server/boat-sign-in-host.tsnew file mode 100644index 0000000000..344acde161--- /dev/null+++ b/server/boat-sign-in-host.ts@@ -0,0 +1,134 @@+// "Sign in with Boat" on this server: where it is offered, its three routes, the public callback Boat sends the browser+// back to, and what Settings is told. Offered only by the desktop app's own local server on one of the three ports+// registered with Boat, and never where cloud computers are included with a plan; everywhere else nothing here answers+// and a pasted API key is the only way, exactly as before.+import type { IncomingMessage, ServerResponse } from "node:http";++import { BOAT_SIGN_IN_MARK, type BoatSignInStatus } from "../shared/boat-sign-in.ts";+import { boatAccountChangeRefusal } from "./boat-account-change.ts";+import * as boat from "./boat.ts";+import { BOAT_SIGN_IN_CALLBACK_PATH, BOAT_SIGN_IN_PORTS, BoatSignIn } from "./boat-sign-in.ts";+import { createBoatSignInStore, type BoatSignInStoreRequest } from "./boat-sign-in-store.ts";+import { setBoatSignIn } from "./boat-sign-in-use.ts";+import type { AppConfig } from "./config.ts";+import { boatProviderApi } from "./included-services.ts";+import { fromPairedDevice, type RequestAuth } from "./request-auth.ts";+import { PASS, type RouteHandler } from "./routes/table.ts";++export interface BoatSignInHostDeps {+ /** The desktop app started this server (OMB_DESKTOP_PARENT). */+ desktop: boolean;+ /** A Cloud home or hosted workspace: cloud computers come with the plan, and the key field is hidden too. */+ hosted: boolean;+ /** The port this server really listens on. */+ port: number;+ dataDir: string;+ cfg: AppConfig;+ /** Reads the config again (the sign-in may now be, or no longer be, the credential in use) and tells every page. */+ refresh(): void;+ managedBoatOwners(): boat.ManagedBoatOwner[];+ /** A cloud computer operation is under way: its words, or null. */+ operationConflict(): string | null;+ /** Holds "box" while the Boat credential in use changes, so no cloud computer operation starts meanwhile. */+ transitions: Pick<Set<"box" | "vps">, "add" | "delete" | "has">;+ post(message: BoatSignInStoreRequest): boolean;+ env?: NodeJS.ProcessEnv;+}++export interface BoatSignInHost {+ signIn: BoatSignIn;+ /** For configStatus `box`: whether a key is saved, and the sign-in's state where it is offered. */+ statusPart(): { keySaved: boolean; signIn?: BoatSignInStatus };+ /** Answers Boat's redirect; false when the request is not that. Runs before the sign-in gate: the state is the credential. */+ callback(req: IncomingMessage, res: ServerResponse, url: URL): Promise<boolean>;+ routes: RouteHandler;+ receive(message: unknown): boolean;+}++const escapeHtml = (text: string) => text.replace(/[&<>"']/g, (char) => `&#${char.charCodeAt(0)};`);++/** A small fixed page: no script, no link, nothing from the request, and never the code or a token. */+function page(title: string, text: string): string {+ return `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>${escapeHtml(title)}</title>`+ + `<style>body{font:16px/1.5 system-ui,sans-serif;margin:15vh auto;max-width:28rem;padding:0 1.5rem;color:#1a1a1a;background:#fff}h1{font-size:1.25rem;margin:0 0 .5rem}p{margin:0;color:#555}@media(prefers-color-scheme:dark){body{color:#eee;background:#151515}p{color:#aaa}}</style>`+ + `</head><body><h1>${escapeHtml(title)}</h1><p>${escapeHtml(text)}</p></body></html>`;+}++const localOwner = (req: IncomingMessage, auth: RequestAuth): boolean =>+ auth.kind === "loopback" && auth.trust !== "service" && !fromPairedDevice(req, auth);++export function createBoatSignInHost(deps: BoatSignInHostDeps): BoatSignInHost {+ const enabled = deps.desktop && !deps.hosted && BOAT_SIGN_IN_PORTS.includes(deps.port);+ const store = createBoatSignInStore({ dataDir: deps.dataDir, post: deps.post, ...(deps.env ? { env: deps.env } : {}) });+ const keySaved = () => Boolean(deps.cfg.box?.token?.trim());+ const inUse = (): AppConfig | null => (boat.boatConfigured(deps.cfg) ? { box: { ...deps.cfg.box } } : null);++ const BUSY = "another change to the Boat account is under way — try again in a moment";+ /** The check and nothing else: the caller makes the change right after it. */+ const checked = async (check: () => Promise<string | null>): Promise<string | null> => {+ if (deps.transitions.has("box")) return BUSY;+ const conflict = deps.operationConflict();+ if (conflict) return conflict;+ deps.transitions.add("box");+ try {+ return await check();+ } finally {+ deps.transitions.delete("box");+ }+ };++ const signIn = new BoatSignIn({+ enabled,+ persistence: store.persistence,+ api: () => boatProviderApi(),+ onChange: () => deps.refresh(),+ // A raw bearer names the account being connected: it is checked like a replacement key, before anything is saved.+ beforeConnect: (bearer) => checked(() => boatAccountChangeRefusal(inUse(), { box: { token: bearer } }, deps.managedBoatOwners())),+ });+ setBoatSignIn(enabled ? signIn : null);++ return {+ signIn,+ statusPart: () => ({ keySaved: keySaved(), ...(enabled ? { signIn: signIn.status(keySaved()) } : {}) }),+ receive: (message) => store.receive(message),+ async callback(req, res, url) {+ if (url.pathname !== BOAT_SIGN_IN_CALLBACK_PATH) return false;+ const headers = { "cache-control": "no-store", "referrer-policy": "no-referrer", "x-content-type-options": "nosniff", "content-security-policy": "default-src 'none'; style-src 'unsafe-inline'" };+ const answer = !enabled ? { status: 404, title: "Not found", text: "Nothing is here." }+ : req.method !== "GET" ? { status: 405, title: "Sign-in link not valid", text: "This sign-in link is not valid. Return to the app and start again." }+ : await signIn.callback(req.headers.host, url.search);+ res.writeHead(answer.status, { ...headers, "content-type": "text/html; charset=utf-8", ...(answer.status === 405 ? { allow: "GET" } : {}) });+ res.end(page(answer.title, answer.text));+ return true;+ },+ routes: async ({ req, res, path, method, auth, json }) => {+ if (!path.startsWith("/api/boat/sign-in")) return PASS;+ if (!enabled || !localOwner(req, auth)) return json(res, 403, { error: "Sign in with your Boat account from the desktop app on this computer; elsewhere, paste a Boat API key." });+ if (method === "POST" && path === "/api/boat/sign-in/start") {+ try {+ return json(res, 200, { url: signIn.start("owner", deps.port).url });+ } catch {+ return json(res, 503, { error: "Sign-in with a Boat account is not available here." });+ }+ }+ if (method === "POST" && path === "/api/boat/sign-in/cancel") {+ signIn.cancel("owner");+ return json(res, 200, { ok: true });+ }+ if (method === "DELETE" && path === "/api/boat/sign-in") {+ // Disconnecting changes the credential in use only when the sign-in is that credential.+ const refusal = signIn.used(keySaved())+ ? await checked(() => boatAccountChangeRefusal({ box: { token: BOAT_SIGN_IN_MARK } }, keySaved() ? { box: { token: deps.cfg.box?.token } } : null, deps.managedBoatOwners()))+ : null;+ if (refusal) return json(res, 409, { error: refusal });+ try {+ const { revoked } = await signIn.signOut();+ return json(res, 200, { ok: true, revoked });+ } catch {+ return json(res, 503, { error: "The Boat account sign-in could not be removed from this computer. Try again." });+ }+ }+ return json(res, 404, { error: "not found" });+ },+ };+}diff --git a/server/boat-sign-in-store.ts b/server/boat-sign-in-store.tsnew file mode 100644index 0000000000..4438b76d72--- /dev/null+++ b/server/boat-sign-in-store.ts@@ -0,0 +1,107 @@+// Where a "Sign in with Boat" connection is kept: wherever the pasted Boat key is.+// - Packaged desktop app: the operating system's encrypted credential document, owned by the app's main process+// (electron/boat-sign-in-store.mjs). It arrives in OMB_BOAT_SIGN_IN at start, as the key arrives in BOX_TOKEN, and is+// dropped from the environment at once; later reads and writes go over the private parent port and a write counts+// only when the main process says it is saved.+// - Anywhere else (the app run from source): boat-sign-in.json in the data folder, owner-only like config.json.+// Neither is in a backup or a move: backups carry no credential (server/workspace-backup-policy.ts).+import { randomUUID } from "node:crypto";+import { readFileSync, rmSync } from "node:fs";+import { join } from "node:path";++import { writeFileAtomic } from "./atomic.ts";+import type { BoatSignInPersistence } from "./boat-sign-in.ts";++export const BOAT_SIGN_IN_FILE = "boat-sign-in.json";+export const BOAT_SIGN_IN_ENV = "OMB_BOAT_SIGN_IN";+const REQUEST = "openmausbot:boat-sign-in-store";+const RESULT = "openmausbot:boat-sign-in-store-result";+const ANSWER_TIMEOUT_MS = 20_000;++export interface BoatSignInStoreRequest {+ type: typeof REQUEST;+ requestId: string;+ op: "read" | "write";+ value?: string | null;+}++export interface BoatSignInStore {+ persistence: BoatSignInPersistence;+ /** True when the message was the main process's answer to a request made here. */+ receive(message: unknown): boolean;+}++export function createBoatSignInStore(options: {+ dataDir: string;+ env?: NodeJS.ProcessEnv;+ /** Sends to the desktop main process; false when there is none. */+ post: (message: BoatSignInStoreRequest) => boolean;+}): BoatSignInStore {+ const env = options.env ?? process.env;+ const fromEnv = env[BOAT_SIGN_IN_ENV];+ // Nothing this server starts may inherit it.+ delete env[BOAT_SIGN_IN_ENV];+ const file = join(options.dataDir, BOAT_SIGN_IN_FILE);+ const waiting = new Map<string, { settle: (answer: { ok: boolean; value?: string | null }) => void; timer: ReturnType<typeof setTimeout> }>();++ const ask = (op: "read" | "write", value?: string | null) => new Promise<{ ok: boolean; value?: string | null }>((settle) => {+ const requestId = randomUUID();+ const timer = setTimeout(() => { waiting.delete(requestId); settle({ ok: false }); }, ANSWER_TIMEOUT_MS);+ timer.unref?.();+ waiting.set(requestId, { settle, timer });+ if (!options.post({ type: REQUEST, requestId, op, ...(op === "write" ? { value: value ?? null } : {}) })) {+ clearTimeout(timer);+ waiting.delete(requestId);+ settle({ ok: false });+ }+ });++ const receive = (raw: unknown): boolean => {+ if (!raw || typeof raw !== "object" || (raw as { type?: unknown }).type !== RESULT) return false;+ const { requestId, ok, value } = raw as { requestId?: unknown; ok?: unknown; value?: unknown };+ const pending = typeof requestId === "string" ? waiting.get(requestId) : undefined;+ if (pending) {+ clearTimeout(pending.timer);+ waiting.delete(requestId as string);+ pending.settle({ ok: ok === true, value: typeof value === "string" && value ? value : null });+ }+ return true;+ };++ if (fromEnv !== undefined) {+ return {+ receive,+ persistence: {+ read: () => fromEnv || null,+ async latest() {+ const answer = await ask("read");+ if (!answer.ok) throw new Error("the credential store did not answer");+ return answer.value ?? null;+ },+ async write(value) {+ if (!(await ask("write", value)).ok) throw new Error("the credential store did not save");+ },+ },+ };+ }++ const readFile = (): string | null => {+ try {+ return readFileSync(file, "utf8") || null;+ } catch (error) {+ if ((error as NodeJS.ErrnoException).code === "ENOENT") return null;+ throw error;+ }+ };+ return {+ receive,+ persistence: {+ read: () => { try { return readFile(); } catch { return null; } },+ latest: async () => readFile(),+ async write(value) {+ if (value === null) rmSync(file, { force: true });+ else writeFileAtomic(file, value, { mode: 0o600 });+ },+ },+ };+}diff --git a/server/boat-sign-in-use.ts b/server/boat-sign-in-use.tsnew file mode 100644index 0000000000..93c0f64cf1--- /dev/null+++ b/server/boat-sign-in-use.ts@@ -0,0 +1,15 @@+// The one "Sign in with Boat" connection of this server process, for the modules that only need to ask about it+// (server/config.ts marks a loaded config with it; server/boat-call.ts takes its bearer). Null wherever sign-in is not+// offered, and then every Boat call uses the pasted key or the plan's included computers exactly as before.+import type { BoatSignIn } from "./boat-sign-in.ts";++let active: BoatSignIn | null = null;++export function setBoatSignIn(signIn: BoatSignIn | null): void {+ active = signIn;+}++export const boatSignIn = (): BoatSignIn | null => active;++/** The sign-in, not the pasted key, is the credential in use: alone, or set after the key. */+export const boatSignInUsed = (keySaved: boolean): boolean => active?.used(keySaved) === true;diff --git a/server/boat-sign-in.ts b/server/boat-sign-in.tsindex 8775053de0..0596338e1d 100644--- a/server/boat-sign-in.ts+++ b/server/boat-sign-in.ts@@ -249,6 +249,10 @@ export class BoatSignIn {};}+ scopeOf(method: string, path: string): BoatScope | null {+ return boatScopeFor(method, path);+ }+/** The scope this call needs and the person unticked; null when it may go ahead. */missingScope(method: string, path: string): BoatScope | null {const needed = boatScopeFor(method, path);diff --git a/server/boat.ts b/server/boat.tsindex 2b3f29d06e..0c2a7c2359 100644--- a/server/boat.ts+++ b/server/boat.ts@@ -7,7 +7,7 @@ import { createHash } from "node:crypto";import { DATA_DIR, type AppConfig } from "./config.ts";import { loadEnvironmentId } from "./environment.ts";import { boatCredential, boatProviderApi, type ServiceCredential } from "./included-services.ts";-import { relayBody, relayPath } from "./boat-relay.ts"; import { COMMAND_WALL, runToEnd, type CommandOutcome } from "./boat-command.ts";+import { relayBody } from "./boat-relay.ts"; import { boatCall, boatSignInWords } from "./boat-call.ts"; import { BOAT_SIGN_IN_MARK } from "../shared/boat-sign-in.ts"; import { COMMAND_WALL, runToEnd, type CommandOutcome } from "./boat-command.ts";import { boatHealth, DEAD_COMPUTER, unansweredStatus } from "./boat-health.ts";import { CLOUD_COMPUTER_NO_ANSWER } from "../shared/cloud-computer-recovery.ts";import { cloudLimitFromBody, type CloudLimit } from "../shared/place-view.ts";@@ -135,21 +135,11 @@ export type ManagedBoatMutationClaim = (/** One credential for the whole operation, even if Settings swaps the config mid-request. */function snapshotBoatConfig(cfg: AppConfig): AppConfig {- return { box: cfg.box ? { token: cfg.box.token } : undefined };+ return { box: cfg.box ? { token: cfg.box.token, signIn: cfg.box.signIn } : undefined };}-/** An own token goes to Boat; Cloud Pro's included token only to its relay. */-export function boatFetch(cfg: AppConfig, path: string, opts: RequestInit = {}) {- const account = boatAccount(cfg);- return fetch(`${account?.api ?? boatProviderApi()}${relayPath(account, path)}`, {- ...opts,- headers: {- authorization: `Bearer ${account?.token}`,- "content-type": "application/json",- ...opts.headers,- },- });-}+/** Every Boat call goes through boatCall (server/boat-call.ts): the key, the included token or the sign-in's bearer. */+export const boatFetch = (cfg: AppConfig, path: string, opts: RequestInit = {}) => boatCall(boatAccount(cfg), path, opts);async function boatJson(cfg: AppConfig, path: string, opts: RequestInit = {}) {const res = await boatFetch(cfg, path, opts);@@ -428,7 +418,7 @@ export const deadBoatOf = (owner: string) => deadBoats.get(owner) ?? null, boatIfunction boatInventoryProblem(status: number, body: any, included = false): string {if (status === 401 || status === 403) {- return included ? INCLUDED_BOAT_UNAVAILABLE : "boat.dev rejected the Boat API key — update it in Settings → AI → Other services";+ return included ? INCLUDED_BOAT_UNAVAILABLE : boatSignInWords(body) ?? "boat.dev rejected the Boat API key — update it in Settings → AI → Other services";}const service = boatServiceName(included);if (status === 429) return `${service} is rate-limiting this account — wait a minute and refresh`;@@ -464,7 +454,7 @@ async function listBoatPages(return { ok: false, unreachable: true, problem: `Could not reach ${boatServiceName(usesIncludedBoat(cfg))} to list cloud computers — check your connection and refresh` };}if (!listed.ok || !Array.isArray(listed.body?.sandboxes)) {- const credentialRejected = listed.status === 401 || listed.status === 403;+ const credentialRejected = listed.status === 401 || (listed.status === 403 && !/^api_key_(?:action|sandbox)_forbidden$/.test(listed.body?.error));return { ok: false, problem: boatInventoryProblem(listed.status, listed.body, usesIncludedBoat(cfg)), credentialRejected };}boats.push(...listed.body.sandboxes);@@ -887,7 +877,7 @@ export async function readyBoat(cfg: AppConfig, botId: string, budgetMs = 60_000return waitReady(cfg, boat.id, budgetMs);}-export const boatAccount = (cfg: AppConfig): ServiceCredential | null => boatCredential(cfg.box?.token);+export const boatAccount = (cfg: AppConfig): ServiceCredential | null => boatCredential(cfg.box?.signIn ? BOAT_SIGN_IN_MARK : cfg.box?.token);export const boatConfigured = (cfg: AppConfig) => Boolean(boatAccount(cfg));@@ -929,8 +919,7 @@ export function boatErrorMessage(status: number, what: string, body?: any, inclureturn [theirs || "boat.dev needs a paid Boat plan before it will create a computer.", link].filter(Boolean).join(" ");}if (status === 401 || status === 403) {- if (included) return INCLUDED_BOAT_UNAVAILABLE;- return "boat.dev rejected your Boat API key — paste a current one in Settings → AI → Other services";+ return included ? INCLUDED_BOAT_UNAVAILABLE : boatSignInWords(body) ?? "boat.dev rejected your Boat API key — paste a current one in Settings → AI → Other services";}if (status === 429) {return theirs || "boat.dev is rate-limiting this account — wait a minute and try again";diff --git a/server/bot-box/env.test.ts b/server/bot-box/env.test.tsindex 5c7a3fa72c..6ca3c00ddd 100644--- a/server/bot-box/env.test.ts+++ b/server/bot-box/env.test.ts@@ -11,7 +11,7 @@ const SERVER_ONLY_OMB: ReadonlySet<string> = new Set(["OMB_ACP_QUIET_TICK_MS", "OMB_TASK_WORKSPACE_RETENTION", "OMB_CONVERSATION_FOLDER_CLEANUP", "OMB_ORPHAN_SWEEP", "OMB_ORPHAN_SWEEP_MAX_SHARE", "OMB_IDLE_RECLAIM", "OMB_ACP_SESSION_IDLE_", "OMB_ACP_SHARED_RECYCLE_MS", "OMB_ADMIN_", "OMB_ADMIN_MEMBERSHIP","OMB_ADMIN_URL", "OMB_ADMIN_WORKSPACE", "OMB_AGENT_BROWSER_PATH", "OMB_AGY_RUNTIMES", "OMB_AGY_STOP", "OMB_AI_CHECKS", "OMB_ANTHROPIC_API_KEY", "OMB_ANTIGRAVITY_NATIVE_CLI","OMB_ANTHROPIC_API_URL", "OMB_APP_VERSION", "OMB_ATTACHMENTS_MAX_BYTES", "OMB_AZURE_OPENAI_LIVE_DEPLOYMENT",- "OMB_AZURE_OPENAI_LIVE_ENDPOINT", "OMB_BACKGROUND_TEXT_MAX", "OMB_BENCH", "OMB_BOAT_API", "OMB_CLOUD_FOCUS_WAKE", "OMB_ENGINE_PRESTART", "OMB_BOTS_FULL_SAVE", "OMB_BOTS_SAVE_CHECK", "OMB_BOT_BOX", "OMB_BOT_MEMORY_MAX_MB", "OMB_BOX_CANARY", "OMB_BRAND_FILE",+ "OMB_AZURE_OPENAI_LIVE_ENDPOINT", "OMB_BACKGROUND_TEXT_MAX", "OMB_BENCH", "OMB_BOAT_API", "OMB_BOAT_SIGN_IN", "OMB_CLOUD_FOCUS_WAKE", "OMB_ENGINE_PRESTART", "OMB_BOTS_FULL_SAVE", "OMB_BOTS_SAVE_CHECK", "OMB_BOT_BOX", "OMB_BOT_MEMORY_MAX_MB", "OMB_BOX_CANARY", "OMB_BRAND_FILE","OMB_BROWSER_CGROUP", "OMB_BROWSER_CONNECTION", "OMB_BROWSER_HOLD_IDLE_MS", "OMB_BROWSER_IDLE_HANDOVER_MS", "OMB_BROWSER_LANG", "OMB_BROWSER_LEGACY_SHELL","OMB_BROWSER_MAX_RUNNING", "OMB_BROWSER_MEMORY_MAX", "OMB_BROWSER_SANDBOX", "OMB_BROWSER_SCREEN", "OMB_BROWSER_TIMEZONE", "OMB_BROWSER_TIMING","OMB_BUG_REPORT_URL", "OMB_CACHE_CAP_APP", "OMB_CACHE_CAP_TOOLS", "OMB_CACHE_ROOT", "OMB_CACHE_SWEEP", "OMB_CADDY_PATH", "OMB_CARTESIA_API_KEY", "OMB_CHECKPOINT_GIT_MAX", "OMB_CHROME_PATH", "OMB_CLAUDE_AUTOCOMPACT",diff --git a/server/config.ts b/server/config.tsindex 6258cbde5a..c7ceb9eae1 100644--- a/server/config.ts+++ b/server/config.ts@@ -2,7 +2,7 @@import { readFileSync, mkdirSync, existsSync, renameSync } from "node:fs";import { dataHome, defaultDataDir } from "./data-dir.ts";import { signInFromEnv } from "./sign-in-env.ts";-export { signInFromEnv };+export { signInFromEnv }; import { boatSignInUsed } from "./boat-sign-in-use.ts";import { join } from "node:path";import { isDeepStrictEqual } from "node:util";import { z } from "zod";@@ -424,7 +424,7 @@ export interface AppConfig extends HelperConfig, Pick<z.output<typeof appConfigSopenaiCompat?: { key?: string; url?: string; model?: string; provider?: string; customHeaders?: OpenAICompatCustomHeadersConfig };composio?: { apiKey?: string; userId?: string; sessionId?: string };/** Boat token (ascii.dev renamed Box to Boat); config key "box", env BOX_TOKEN. */- box?: { token?: string };+ box?: { token?: string; /** Set by loadConfig, never saved: "Sign in with Boat" is the credential in use. */ signIn?: boolean };vps?: VpsConfig;vpsServers?: VpsServer[];opencodeGo?: { apiKey?: string; providerKeys?: Record<string, string> };@@ -697,8 +697,8 @@ export function loadConfig(): AppConfig {if (process.env.OPENAI_COMPAT_PROVIDER !== undefined) cfg.openaiCompat.provider = process.env.OPENAI_COMPAT_PROVIDER;cfg.composio = { ...cfg.composio };if (process.env.COMPOSIO_API_KEY !== undefined) cfg.composio.apiKey = process.env.COMPOSIO_API_KEY;- cfg.box = { ...cfg.box };- if (process.env.BOX_TOKEN !== undefined) cfg.box.token = process.env.BOX_TOKEN;+ cfg.box = { ...cfg.box, ...(process.env.BOX_TOKEN !== undefined ? { token: process.env.BOX_TOKEN } : {}) };+ if (boatSignInUsed(Boolean(cfg.box.token?.trim()))) cfg.box.signIn = true; else delete cfg.box.signIn;cfg.opencodeGo = { ...cfg.opencodeGo };if (process.env.OPENCODE_API_KEY !== undefined) cfg.opencodeGo.apiKey = process.env.OPENCODE_API_KEY;cfg.tts = { ...cfg.tts };diff --git a/server/credential-env.ts b/server/credential-env.tsindex 9cfeb83996..0779c972af 100644--- a/server/credential-env.ts+++ b/server/credential-env.ts@@ -19,7 +19,7 @@ export const WORKSPACE_CREDENTIAL_ENV = ["OPENAI_COMPAT_URL","OMB_OPENAI_API_KEY","OMB_OPENROUTER_API_KEY",- "BOX_TOKEN",+ "BOX_TOKEN", "OMB_BOAT_SIGN_IN","OPENCODE_API_KEY","OMB_TTS_KEY","OMB_FISH_AUDIO_API_KEY",diff --git a/server/doctor/checks/secret-modes.ts b/server/doctor/checks/secret-modes.tsindex f2778deaa8..d95ef11266 100644--- a/server/doctor/checks/secret-modes.ts+++ b/server/doctor/checks/secret-modes.ts@@ -13,6 +13,8 @@ export const SECRET_FILES = ["logins-key", "logins.json.enc", "member-secrets.json.enc",// Plaintext OAuth tokens for the MCP servers a person signed in to."mcp-oauth.json",+ // A "Sign in with Boat" connection, where the app is run from source.+ "boat-sign-in.json",] as const;type Loose = { name: string; path: string; mode: number };diff --git a/server/index.ts b/server/index.tsindex d0b5cf8727..31910fc9cb 100644--- a/server/index.ts+++ b/server/index.ts@@ -617,7 +617,7 @@ import { DESKTOP_VIEWER_TARGET, viewerTargetId } from "../shared/desktop-viewer.import { createComputerPreviews } from "./computer-previews.ts";import { createAntigravityLeftoverRoutes } from "./routes/antigravity-leftovers.ts";import { createAntigravityAccountRoutes } from "./routes/antigravity-accounts.ts";-import { createConfigRoutes } from "./routes/config.ts"; import { roomFeedSince } from "./room-feed-since.ts";+import { createConfigRoutes } from "./routes/config.ts"; import { createBoatSignInHost } from "./boat-sign-in-host.ts"; import { roomFeedSince } from "./room-feed-since.ts";import { createInstanceRoutes } from "./routes/instances.ts";import { createMcpConfig } from "./host/mcp-config.ts";import { createMcpServerRoutes } from "./routes/mcp-servers.ts";@@ -1469,13 +1469,14 @@ const browserCleanup: BrowserCleanupCoordinator = new BrowserCleanupCoordinator(},});const phoneSecrets = new PhoneSecretBridge(postDesktopPrivateMessage, undefined, undefined, DESKTOP_MANAGED); const phonePushAccess = new PhonePushAccessSource({ tunnelFile: join(DATA_DIR, TUNNEL_CREDENTIALS_FILE), defaultControlPlane: DEFAULT_COMPANION_CONTROL_PLANE_URL, cloudHome: CLOUD_HOME });+const boatSignInHost = createBoatSignInHost({ desktop: DESKTOP_MANAGED, hosted: Boolean(CLOUD_HOME) || HOSTED_WORKSPACE, port: PORT, dataDir: DATA_DIR, cfg, refresh: () => { Object.assign(cfg, loadConfig()); broadcast({ kind: "config", ...configStatus() }); }, managedBoatOwners: () => managedBoatOwners(), operationConflict: () => providerOperationConflict("box"), transitions: { add: (provider) => computerProviderConfigTransitions.add(provider), delete: (provider) => computerProviderConfigTransitions.delete(provider), has: (provider) => computerProviderConfigTransitions.has(provider) }, post: (message) => postDesktopPrivateMessage(message as unknown as DesktopPrivateMessage) }); Object.assign(cfg, loadConfig()); ROUTES.push(boatSignInHost.routes);utilityParentPort?.on("message", (event) => {const message = event?.data;try {if (applyDesktopMutationTokenMessage(message) || desktopComputer.receive(message) || tailnetShare.receive(message, (answer) => utilityParentPort?.postMessage(answer))) return;if (handleDesktopTrustedApprovalMessage(message) || linkLimits.receive(message)) return;if (browserCleanup.receive(message)) return;- if (phoneSecrets.receive(message) || botLogins.receiveHandoff(message, postDesktopPrivateMessage, (what) => cloudConnections.handoff(what))) return;+ if (boatSignInHost.receive(message) || phoneSecrets.receive(message) || botLogins.receiveHandoff(message, postDesktopPrivateMessage, (what) => cloudConnections.handoff(what))) return;if (applyIncludedPagesMessage(message)) return; if (applyIncludedXMessage(message)) return void broadcast({ kind: "config", ...configStatus() }); if (applyPhoneLinkMessage(message) || phonePushAccess.receive(message)) return;composio.applyManagedBrokerMessage(message);} catch (error) {@@ -11557,7 +11558,7 @@ function configStatus() {...(composio.connectionMode(cfg) === "self-hosted" ? keyHint(cfg.composio?.apiKey) : {}),configured: composio.configured(cfg), mode: composio.connectionMode(cfg),},- box: { ...boat.describeBoatAccount(cfg), ...(boat.boatAccount(cfg)?.included ? {} : keyHint(cfg.box?.token)) },+ box: { ...boat.describeBoatAccount(cfg), ...(boat.boatAccount(cfg)?.included ? {} : keyHint(cfg.box?.token)), ...boatSignInHost.statusPart() },vps: { configured: Boolean(vpsSshAlias(cfg)), sshAlias: vpsSshAlias(cfg) ?? "", servers: cfg.vpsServers ?? [], ...vpsResources(cfg) },opencodeGo: { ...keyStatus(cfg.opencodeGo?.apiKey), providerKeys: Object.keys(openCodeProviderKeys(cfg)) },tts: tts.describeVoice(cfg),@@ -12395,6 +12396,7 @@ const handleRequest = async (req: IncomingMessage, res: ServerResponse) => {if (refusal) return json(res, 403, { error: refusal, code: "managed_policy" });}// Public like the loopback listener it stands in for: the state is the credential, checked once.+ if (await boatSignInHost.callback(req, res, url)) return;if (path === MCP_OAUTH_CALLBACK_PATH) {const answer = method === "GET"? await teamConnections.mcpCallback(req.headers.host, url.search)diff --git a/server/routes/config.ts b/server/routes/config.tsindex e8a6027ce2..a47a3a129b 100644--- a/server/routes/config.ts+++ b/server/routes/config.ts@@ -2,6 +2,8 @@ import { liveSavePatch } from "../live-config.ts";import { signInEnvRefusal } from "../sign-in-env.ts";import { seatInviteRefusal } from "../license-seats.ts";import * as boat from "../boat.ts";+import { BOAT_SIGN_IN_MARK } from "../../shared/boat-sign-in.ts";+import { boatSignIn } from "../boat-sign-in-use.ts";import { boatCreateRecoverySnapshot, retireDeletedBoatCreate } from "../boat-create-idempotency.ts";import { boatDeletionSnapshot } from "../boat-delete-journal.ts";import { browserEngineStatus, browserSessionId } from "../browser-engine.ts";@@ -290,8 +292,11 @@ export function createConfigRoutes(deps: ConfigRouteDeps): RouteHandler {}}if (patch.box?.token !== undefined) patch.box.token = patch.box.token.trim();- const currentBoatToken = cfg.box?.token?.trim() ?? "";- const nextBoatToken = patch.box?.token === undefined ? currentBoatToken : patch.box.token;+ if (patch.box?.token === BOAT_SIGN_IN_MARK) return json(res, 400, { error: "That doesn't look like a Boat API key: they start with boat_.", code: "key_rejected" });+ // "Sign in with Boat" may be the credential in use, with or without a saved key: it is named by its mark, so a key+ // saved over it, or removed from beside it, is checked as the change of account it is.+ const currentBoatToken = cfg.box?.signIn ? BOAT_SIGN_IN_MARK : cfg.box?.token?.trim() ?? "";+ const nextBoatToken = patch.box?.token === undefined ? currentBoatToken : patch.box.token || (boatSignIn()?.connected() ? BOAT_SIGN_IN_MARK : "");const changingBoatToken = patch.box?.token !== undefined && nextBoatToken !== currentBoatToken;const currentVpsAlias = vpsSshAlias(cfg);const nextVpsAlias = patch.vps === undefined@@ -656,6 +661,11 @@ export function createConfigRoutes(deps: ConfigRouteDeps): RouteHandler {}throw error;}+ if (patch.box?.token) {+ // The key was set last, so it is the one used from now on; if that cannot be saved the sign-in stays in use, and Settings shows which.+ await boatSignIn()?.preferKey().catch(() => undefined);+ Object.assign(cfg, loadConfig());+ }for (const key of resetKeys) if (key) forgetKey(key);localVmModeChanged?.();postiz?.configSaved(patch);diff --git a/server/workspace-backup-policy.ts b/server/workspace-backup-policy.tsindex f0dd7795d6..62e2c62074 100644--- a/server/workspace-backup-policy.ts+++ b/server/workspace-backup-policy.ts@@ -44,6 +44,8 @@ export function excludedWorkspaceAuthPath(path: string): boolean {if (inSecretFolder(path)) return true;if (/^command-allowlist\.json(?:$|\.\d+\.[0-9a-f-]+\.tmp$)/.test(path)) return true;if (/^mcp-oauth\.json(?:$|\.\d+\.[0-9a-f-]+\.tmp$)/.test(path)) return true;+ // A "Sign in with Boat" connection kept by an app run from source: like the pasted key, it never leaves this computer.+ if (/^boat-sign-in\.json(?:$|\.\d+\.[0-9a-f-]+\.tmp$)/.test(path)) return true;// Bot API keys saved for teammates on other servers stay on the server they were saved on, like any other credential.if (/^remote-teammates\.json(?:$|\.\d+\.[0-9a-f-]+\.tmp$)/.test(path)) return true;// Saved website logins and their key never leave the computer they were saved on, nor does the key sealing webhook secrets.