A personal assistant that lives on your desktop, remembers what matters, and can use your Mac for you.
TypeScript
fix(daemon): pass on only the Linux keyring reason and log it; correct the restart docs
Alan Buscaglia920455b1debb
diff --git a/docs/design.md b/docs/design.mdindex d6f5b2c..a352dfb 100644--- a/docs/design.md+++ b/docs/design.md@@ -288,7 +288,7 @@ The user changes the main assistant's model from the chat, in the panel and the- The daemon binds `127.0.0.1` only. A random 256-bit token is stored in `~/.gentle-dot/token` (mode 0600). The desktop app reads it; the browser receives it once by URL fragment.- WebSocket upgrades check `Origin` against an allowlist (`http://127.0.0.1:4317`, `tauri://localhost`).- The VPS guide requires HTTPS, a reverse proxy with authentication, and a dedicated Docker container with no access to personal machines.-- The assistant's engine runs as the user with a shell. Its file tools cannot read the token, sign-ins, or connector files, and the connector state lives in the daemon's memory (§4, Connectors), but shell checks are best effort: a determined command can still read what the user's account can read. Stage 2 (S25) moves connector tokens and enforcement into the daemon: the MCP proxy (S25.4, done) keeps every token, real address, and server environment out of the engine's `mcp.json`, and enforces mode, hidden tools, and approvals in the daemon. Connector changes and approvals come only from the desktop app that launched the daemon, over its private channel, and are answered in native dialogs (§4, App channel); the WebSocket's access key no longer reaches them. Connector secrets (tokens, client secrets, imported headers, sign-ins) are in Keychain items the signed app creates and reach the daemon only in memory over that channel (S25.5, §4 Secrets); without the app, connectors that need one fail closed. What the Keychain cannot check: `security-framework` exposes no item access list, so the app cannot tell an item it created from one a same-user process planted (before the first `put`, or after deleting the app's); the daemon only reads ids it recorded, and every `put` replaces the item. `connectors.json` is signed with a key in the Keychain, and a file changed while Gentle Dot was closed is set aside at the next start with the app (S25.6, §4 Integrity); without the app it is loaded unverified. On Linux the app keeps connector secrets in the Secret Service (GNOME Keyring or KWallet), encrypted at rest; the Secret Service has no per-caller access list, so any same-user process, the agent's shell included, can read the items while the keyring is unlocked (S25.7, documented limit). The app channel, the MCP proxy, and native approvals work as on macOS: no child of the daemon holds the channel (checked in containers by `scripts/package/linux-cargo-check.mjs` and the package smoke). Without a Secret Service, connectors that need a secret fail closed, and the assistant and `daemon.log` name the missing keyring. Still open: the proxy key is in the engine's `mcp.json`, so the agent's shell could call the proxy directly; that reaches only what the proxy allows, and every sending action still needs the user's approval.+- The assistant's engine runs as the user with a shell. Its file tools cannot read the token, sign-ins, or connector files, and the connector state lives in the daemon's memory (§4, Connectors), but shell checks are best effort: a determined command can still read what the user's account can read. Stage 2 (S25) moves connector tokens and enforcement into the daemon: the MCP proxy (S25.4, done) keeps every token, real address, and server environment out of the engine's `mcp.json`, and enforces mode, hidden tools, and approvals in the daemon. Connector changes and approvals come only from the desktop app that launched the daemon, over its private channel, and are answered in native dialogs (§4, App channel); the WebSocket's access key no longer reaches them. Connector secrets (tokens, client secrets, imported headers, sign-ins) are in Keychain items the signed app creates and reach the daemon only in memory over that channel (S25.5, §4 Secrets); without the app, connectors that need one fail closed. What the Keychain cannot check: `security-framework` exposes no item access list, so the app cannot tell an item it created from one a same-user process planted (before the first `put`, or after deleting the app's); the daemon only reads ids it recorded, and every `put` replaces the item. `connectors.json` is signed with a key in the Keychain, and a file changed while Gentle Dot was closed is set aside at the next start with the app (S25.6, §4 Integrity); without the app it is loaded unverified. On Linux the app keeps connector secrets in the Secret Service (GNOME Keyring or KWallet), encrypted at rest; the Secret Service has no per-caller access list, so any same-user process, the agent's shell included, can read the items while the keyring is unlocked (S25.7, documented limit). The app channel, the MCP proxy, and native approvals work as on macOS: no child of the daemon holds the channel (checked in containers by `scripts/package/linux-cargo-check.mjs` and the package smoke). Without a Secret Service at start, the connectors' integrity key cannot be read, so connectors that need a secret stay locked until Gentle Dot restarts (`daemon.log` names the missing keyring; the assistant is told to restart); if the keyring goes away later, the assistant and `daemon.log` (`connector <id> cannot get its secrets: …`) name it. Only the Linux keyring message is passed on this way; other store refusals keep their earlier wording. Still open: the proxy key is in the engine's `mcp.json`, so the agent's shell could call the proxy directly; that reaches only what the proxy allows, and every sending action still needs the user's approval.## 9. Desktop shell contract (Tauri 2 <-> UI)diff --git a/docs/install.md b/docs/install.mdindex b60c6e8..8dca2b6 100644--- a/docs/install.md+++ b/docs/install.md@@ -97,7 +97,7 @@ Keep the `./` with `apt`. The package manager adds WebKitGTK and tray support. T- Computer control is macOS only.- Connector secrets (tokens and sign-ins) are kept in your desktop keyring through the Secret Service (GNOME Keyring or KWallet), encrypted on disk, never in `~/.gentle-dot`. In Passwords and Keys (Seahorse) they show as "Gentle Dot connector: …" in the login keyring. Connector approvals and connector changes go through the app's own dialogs, which the assistant cannot answer.- **Limit on Linux:** while the keyring is unlocked (usually your whole session), any program running as your user can read those items, including commands the assistant runs in its shell (for example `secret-tool lookup service dev.gentleman.gentle-dot.connectors account <id>`). The Secret Service has no way to restrict which program reads an item. On macOS the Keychain lets only the signed app read them without asking; on Linux, protect the secrets by keeping the keyring locked when you are away and by connecting only the accounts you want the assistant to use.-- Without a keyring (no Secret Service in the session, common on minimal window-manager setups), connectors that need a secret do not run, and nothing is written to disk instead. `~/.gentle-dot/daemon.log` then says `no Secret Service in this desktop session (…); install and unlock a keyring such as GNOME Keyring or KWallet`. Install `gnome-keyring` (or KWallet), and make sure it runs in your session; the app looks for it again on every request, so no restart is needed. A locked keyring shows its unlock prompt when a connector needs a secret; dismissing it, or no answer within two minutes, refuses.+- Without a keyring (no Secret Service in the session, common on minimal window-manager setups), connectors that need a secret do not run, and nothing is written to disk instead. `~/.gentle-dot/daemon.log` then says `no Secret Service in this desktop session (…); install and unlock a keyring such as GNOME Keyring or KWallet`. Install `gnome-keyring` (or KWallet), make sure it runs and is unlocked in your session, then quit Gentle Dot from the tray and open it again. Gentle Dot checks its connectors with a key kept in the keyring when it starts, so a keyring that was missing then keeps those connectors locked, and the assistant says to restart, until the next start. If the keyring goes away while Gentle Dot runs, the assistant says the keyring is missing. A locked keyring shows its unlock prompt when Gentle Dot starts or a connector needs a secret; dismissing it, or no answer within two minutes, refuses (dismissed at start, connectors that need a secret stay locked until Gentle Dot restarts).- GNOME: add a custom shortcut that runs `/usr/bin/gentle-dot --toggle` (see docs/linux-testing.md, step 9). Debian needs the AppIndicator extension for the tray icon.- Hyprland / Omarchy: paste `scripts/linux/hyprland/gentle-dot.lua` (or `.conf`) into your Hyprland config; it already calls `/usr/bin/gentle-dot --toggle`.- Remove: `sudo apt remove gentle-dot` or `sudo pacman -R gentle-dot` (your data in `~/.gentle-dot` stays).diff --git a/docs/linux-testing.md b/docs/linux-testing.mdindex 27ba794..73ccaf9 100644--- a/docs/linux-testing.md+++ b/docs/linux-testing.md@@ -235,7 +235,7 @@ For a quick comparison on GNOME, you can start the app as a native Wayland clien| Symptom | Try ||---|---|| The panel or rose is blank, or the app prints `Failed to create GBM buffer` (often with NVIDIA) | Quit the app, then start it with `WEBKIT_DISABLE_DMABUF_RENDERER=1` before the app command, for example `WEBKIT_DISABLE_DMABUF_RENDERER=1 gentle-dot`. Note in the report whether it helped. |-| A connector that needs a sign-in or token never runs, and `daemon.log` says `no Secret Service in this desktop session` | Your session has no keyring. Install `gnome-keyring` (or KWallet) and make sure it runs in your session, then try the connector again. |+| A connector that needs a sign-in or token never runs, and `daemon.log` says `no Secret Service in this desktop session` | Your session has no keyring. Install `gnome-keyring` (or KWallet) and make sure it runs and is unlocked in your session, then quit Gentle Dot from the tray, open it again, and try the connector again. || The rose stays dimmed | Look at `~/.gentle-dot/daemon.log` and attach it (see below). || No tray icon on GNOME | Check that the AppIndicator extension is on: `gnome-extensions list --enabled` || `gentle-dot: command not found` | Use the full path: `/usr/bin/gentle-dot` with the package, `~/.local/bin/gentle-dot` from source |diff --git a/packages/daemon/src/mcp-proxy.ts b/packages/daemon/src/mcp-proxy.tsindex 5693477..c2957f6 100644--- a/packages/daemon/src/mcp-proxy.ts+++ b/packages/daemon/src/mcp-proxy.ts@@ -34,7 +34,7 @@ import {} from "@earendil-works/pi-mcp";import { McpOAuthAuthorizationRequiredError } from "@earendil-works/pi-mcp/oauth";import { type ConnectorMode, isReadOnlyTool } from "./extensions/approval-guard.ts";-import { SecretsUnavailableError } from "./secret-source.ts";+import { NO_APP, SecretsUnavailableError } from "./secret-source.ts";/** Where the engine reaches a connector: `/mcp/<id>`. */export const MCP_PREFIX = "/mcp/";@@ -409,7 +409,11 @@ export class McpProxy {private rpcError(connector: ProxiedConnector, error: unknown): { code: number; message: string } {if (error instanceof ProxyError) return { code: error.code, message: error.message };- if (error instanceof SecretsUnavailableError) return { code: REFUSED, message: error.message };+ if (error instanceof SecretsUnavailableError) {+ if (error.message !== NO_APP)+ this.log(`connector ${connector.id} cannot get its secrets: ${error.message}`);+ return { code: REFUSED, message: error.message };+ }// The server's own answer, passed on as it came.if (error instanceof McpError) return { code: error.code, message: error.message };const upstream = this.upstreams.get(connector.id);diff --git a/packages/daemon/src/secret-source.ts b/packages/daemon/src/secret-source.tsindex 360767b..659bc7e 100644--- a/packages/daemon/src/secret-source.ts+++ b/packages/daemon/src/secret-source.ts@@ -12,8 +12,11 @@ import { APPROVAL_WAIT_MS, type AppChannel } from "./app-channel.ts";/** Why a connector that needs a secret cannot run: the secrets are only in the app's store. */export const NO_APP = "Open the Gentle Dot app to use this connector.";-/** How the app starts its answer when its secret store cannot be reached (`StoreError::Unavailable`). */-const STORE_UNAVAILABLE = "the secret store is unavailable: ";+/**+ * The app's answer when Linux has no usable Secret Service (`StoreError::Unavailable` in `secure_store/linux.rs`).+ * Other platforms keep their earlier message.+ */+const NO_KEYRING = /^the secret store is unavailable: .*Secret Service/;/** The secret store is not reachable; `message` is safe to show. */export class SecretsUnavailableError extends Error {@@ -85,8 +88,8 @@ export class AppSecretSource implements SecretSource {} catch (error) {if (!channel.connected) throw new SecretsUnavailableError();const message = (error as Error).message;- // The app's own words for a store it cannot reach (no keyring on Linux), safe to show.- if (message.startsWith(STORE_UNAVAILABLE)) throw new SecretsUnavailableError(`T${message.slice(1)}`);+ // The app's own words for a missing keyring on Linux, safe to show (S25.7).+ if (NO_KEYRING.test(message)) throw new SecretsUnavailableError(`T${message.slice(1)}`);throw new Error(`The app's secure store refused it: ${message}`);}}diff --git a/packages/daemon/test/connector-secrets.test.ts b/packages/daemon/test/connector-secrets.test.tsindex b385a91..7dd0956 100644--- a/packages/daemon/test/connector-secrets.test.ts+++ b/packages/daemon/test/connector-secrets.test.ts@@ -149,12 +149,16 @@ describe("the app's secret store over its channel", () => {expect((unavailable as Error).message).toBe("The secret store is unavailable: no Secret Service in this desktop session (DBus error); install and unlock a keyring such as GNOME Keyring or KWallet",);- app.failSecrets("the user denied access to the secret store");- const refused = await source.get("connector/x").catch((error: unknown) => error);- expect(refused).not.toBeInstanceOf(SecretsUnavailableError);- expect((refused as Error).message).toBe(- "The app's secure store refused it: the user denied access to the secret store",- );+ for (const other of [+ "the user denied access to the secret store",+ // macOS: the same Rust variant, with its own words, keeps its earlier message (regression).+ "the secret store is unavailable: the keychain is locked and cannot ask",+ ]) {+ app.failSecrets(other);+ const refused = await source.get("connector/x").catch((error: unknown) => error);+ expect(refused).not.toBeInstanceOf(SecretsUnavailableError);+ expect((refused as Error).message).toBe(`The app's secure store refused it: ${other}`);+ }});});diff --git a/packages/daemon/test/mcp-proxy.test.ts b/packages/daemon/test/mcp-proxy.test.tsindex 878a204..87b6f52 100644--- a/packages/daemon/test/mcp-proxy.test.ts+++ b/packages/daemon/test/mcp-proxy.test.ts@@ -22,6 +22,7 @@ import {type ProxiedConnector,type UpstreamCredentials,} from "../src/mcp-proxy.ts";+import { SecretsUnavailableError } from "../src/secret-source.ts";import { tempDir, waitFor } from "./helpers.ts";const FAKE_SERVER = fileURLToPath(new URL("./fixtures/fake-mcp-server.ts", import.meta.url));@@ -379,6 +380,25 @@ describe("MCP proxy: upstream connections", () => {expect(logs.join("\n")).not.toContain("Bearer");});+ it("tells the model why the secret store is unavailable and keeps the reason in the log", async () => {+ const { open, upstream, logs } = await setup({+ credentials: async () => {+ throw new SecretsUnavailableError(+ "The secret store is unavailable: no Secret Service in this desktop session (bus); install and unlock a keyring such as GNOME Keyring or KWallet",+ );+ },+ });+ const client = await open();+ const failed = await rpcError(client.callTool("search", {}));+ expect(failed.message).toBe(+ "The secret store is unavailable: no Secret Service in this desktop session (bus); install and unlock a keyring such as GNOME Keyring or KWallet",+ );+ expect(upstream.state.connects).toBe(0);+ expect(logs).toContain(+ "connector notes cannot get its secrets: The secret store is unavailable: no Secret Service in this desktop session (bus); install and unlock a keyring such as GNOME Keyring or KWallet",+ );+ });+it("closes a connector's upstream when it is removed, turned off, or its server changed, and all of them on close", async () => {const { open, views, upstream, proxy } = await setup();const client = await open();