A personal assistant that lives on your desktop, remembers what matters, and can use your Mac for you.
TypeScript
feat(daemon): white-label the agent with a product identity and a UI sanitizer
Alan Buscaglia194721dc79aa
diff --git a/docs/design.md b/docs/design.mdindex f833aa0..275f2df 100644--- a/docs/design.md+++ b/docs/design.md@@ -77,7 +77,7 @@ Client to daemon:| type | fields | maps to Pi RPC ||---|---|---|-| `send` | `text`, `requestId` | `prompt` (or `follow_up` while busy) |+| `send` | `text`, `requestId` | `prompt` (with `streamingBehavior: "steer"` while busy); a repeated `requestId` is ignored || `steer` | `text` | `steer` || `abort` | — | `abort` || `ui_response` | `requestId`, `value` \| `confirmed` \| `cancelled` | `extension_ui_response` |@@ -90,11 +90,15 @@ Daemon to client:| type | meaning ||---|---|-| `ready` | `agentState`, `conversationId`, `model` (display name only) |+| `ready` | `agentState`, `conversationId`, `model` (display name only); pending asks and an `interrupted` notice follow it |+| `user_message` | a user message entered from any client || `agent_state` | `starting` \| `idle` \| `thinking` \| `working` \| `needs_you` \| `restarting` \| `error` || `message_delta` | assistant text delta for message `messageId` || `message_done` | final assistant message |-| `activity` | sanitized tool activity: `id`, `kind` (`read`, `edit`, `run`, `search`, `memory`, `delegate`, `other`), `title`, `status` |+| `ask_resolved` | an ask was answered or timed out |+| `conversations` | `conversations` (`id`, `title`, `updatedAt`) and `activeId` |+| `interrupted` | the agent restarted while a run was active |+| `activity` | `messageId` plus sanitized tool activity: `id`, `kind` (`read`, `edit`, `run`, `search`, `memory`, `delegate`, `other`), `title`, `status` || `ask` | sanitized `extension_ui_request` dialog: `requestId`, `method` (`select`, `confirm`, `input`, `editor`), `title`, `message`, `options`, `timeoutMs` || `toast` | sanitized `notify` || `history` | conversation messages for rendering |@@ -105,8 +109,8 @@ Every daemon message carries `seq` (monotonic per connection) so the UI can dete## 5. White-label layer- **Identity**: `--append-system-prompt` with `identity.md`: the assistant is "Gentle Dot", a personal assistant; it must not mention Gentle Shell, Pi, el Gentleman, ODD, or Engram by name, and describes them as "my workflow" and "my memory" when needed. It keeps every behavior.-- **Event sanitizer** (pure function, unit-tested): renames or drops branding in `notify`, `setStatus`, `setWidget`, `setTitle`; drops terminal-only requests; maps tool names to activity kinds and neutral titles (for example `mem_search` -> `memory` "Checking my notes").-- **Commands**: `gentle:*` slash commands are never exposed; the UI has no command palette in this version.+- **Event sanitizer** (`packages/daemon/src/white-label.ts`, unit-tested): rewrites internal names in toasts, ask titles, messages, and options (answers are mapped back to the agent's original option strings), final assistant text, and history. Informational `notify` records are harness chatter and are hidden; warnings and errors are shown. `setStatus`, `setWidget`, `setTitle`, and terminal-only requests are dropped. Tool names map to activity kinds and neutral titles (for example `mem_search` -> `memory` "Checking my notes"). Streamed deltas are not rewritten; the UI replaces them with the final text.+- **Commands**: `gentle:*` slash commands are never exposed, and a message starting with `/gentle:` is refused with `unsupported`; the UI has no command palette in this version.- **Errors**: provider or process errors become neutral messages; raw details go to the daemon log only.## 6. User experience@@ -175,4 +179,4 @@ Every daemon message carries `seq` (monotonic per connection) so the UI can dete{ "port": 4317, "workspace": "~", "shortcut": "Alt+Space", "launchAtLogin": false }```-Environment overrides: `GENTLE_DOT_PORT`, `GENTLE_DOT_DATA_DIR`, `GENTLE_DOT_AGENT_BIN`, `GENTLE_DOT_WORKSPACE`.+Environment overrides: `GENTLE_DOT_PORT`, `GENTLE_DOT_HOST` (default `127.0.0.1`; `0.0.0.0` only inside a container), `GENTLE_DOT_DATA_DIR`, `GENTLE_DOT_WORKSPACE`, `GENTLE_DOT_UI_DIR`, `GENTLE_DOT_AGENT_BIN`, `GENTLE_DOT_AGENT_ARGS` (JSON array), `GENTLE_DOT_ALLOWED_ORIGINS` (JSON array).diff --git a/odd/tasks/gentle-dot.md b/odd/tasks/gentle-dot.mdindex 300f627..50b910d 100644--- a/odd/tasks/gentle-dot.md+++ b/odd/tasks/gentle-dot.md@@ -38,7 +38,7 @@ Branch: `feat/gentle-dot` · Delivery strategy: `single-pr` (user choice, L7; fo| T0 | S8 | inline | done | `5ec596c` readback OK | Design (`docs/design.md`) and this plan || T1 | S3, S6 | inline | done | `605b6c2` typecheck, lint, 2 tests green | Scaffold the pnpm workspace (`packages/protocol`, `packages/daemon`, `packages/ui`, `apps/desktop` placeholder), TypeScript strict, Vitest, lint, README || T2 | S3, S5 | inline | done | `c199fef` RED (missing modules) → GREEN 14 daemon tests, 3 consecutive runs | Agent supervisor: spawn, strict JSONL framing, id correlation, fake agent for tests, restart with backoff, reopen last session |-| T3 | S2, S6 | inline | pending | — | Gateway: HTTP static + `/health`, WebSocket protocol v1, token + Origin checks, Pi RPC mapping (design §4) |+| T3 | S2, S6 | inline | done | `64e25fb` RED (missing daemon) → GREEN 39 tests; `node packages/daemon/src/cli.ts` smoke: health OK, token 0600 | Gateway: HTTP static + `/health`, WebSocket protocol v1, token + Origin checks, Pi RPC mapping (design §4) || T4 | S4 | inline | pending | — | White-label: verify `--append-system-prompt` passthrough, `identity.md`, event sanitizer, tool-kind mapping, error neutralization || T5 | S2 | inline (writer only if parallel with T7) | pending | — | Web UI: chat, streaming Markdown, activity rows, conversations, composer with Stop/steer, visual tokens || T6 | S2, S4, S5 | inline | pending | — | Ask cards (select/confirm/input/editor with timeout), toasts, interrupted-run Continue prompt, reconnect with `seq` gap recovery |@@ -58,4 +58,6 @@ Environment notes: Node v24.14.1 and pnpm are present. `cargo` is on PATH but `r- **L6 (2026-10-08, decision):** Pi Durable deferred. Recovery relies on persisted Pi sessions plus Engram, per L2; it is reconsidered only for unattended or scheduled work.- **L7 (2026-10-08, user):** "Un solo pr, instala lo que necesites y dale nomás" — plan approved, delivery `single-pr` with size exception, installs authorized (Rust stable via rustup).- **L8 (2026-10-08, evidence):** Rust stable 1.99.0 installed via rustup (Homebrew); the nix `cargo` precedes it on PATH, so Tauri commands prepend `/opt/homebrew/opt/rustup/bin`. Toolchain versions: TypeScript 7, Vitest 5, Biome 2, pnpm 11.5. T2 risk tier: medium (process supervision covered by integration tests with a fake agent; the fake delays `crash` exit because macOS pipes are asynchronous).-- **Next step:** T3.+- **L9 (2026-10-08, T3 evidence):** 18 gateway tests cover the token (4401), protocol (4400), Origin (403), seq numbering, streaming, broadcast, requestId dedupe, tool activity, asks and late joiners, conversations and history, id traversal refusal, malformed frames, interruption after restart, static UI with traversal block, and health. Exception: `parseClientMessage` was written before its unit test (the test passed on first run). Design §4 updated: `send` while busy steers, plus `user_message`, `ask_resolved`, `conversations`, `interrupted` payloads. Risk tier: high (auth on a local socket); independent verification in T9.+- **L10 (2026-10-08, T4 evidence):** the launcher forwards unknown args to Pi (`runtime/gentle-shell-launcher.mjs:153,971`), so `--append-system-prompt` works; the S4 assumption holds. `pnpm test:real` (opt-in through `GENTLE_DOT_REAL_AGENT=1` so ordinary runs cost no model calls) passed 2/2. Answer: "I’m Gentle Dot, a personal assistant that lives on your desktop and in your browser. I can work with your files, run tasks, remember things across conversations, and bring in focused helpers when needed." No hidden names appeared in any UI-bound message. Info toasts are hidden as harness chatter.+- **Next step:** T5.diff --git a/package.json b/package.jsonindex e8d9233..05dae3c 100644--- a/package.json+++ b/package.json@@ -14,7 +14,8 @@"e2e": "playwright test","typecheck": "tsc -b","lint": "biome check .",- "format": "biome format --write ."+ "format": "biome format --write .",+ "test:real": "GENTLE_DOT_REAL_AGENT=1 vitest run packages/daemon/test/real-agent.test.ts"},"devDependencies": {"@biomejs/biome": "^2.5.15",diff --git a/packages/daemon/src/bridge.ts b/packages/daemon/src/bridge.tsindex 4971ff9..390b4b5 100644--- a/packages/daemon/src/bridge.ts+++ b/packages/daemon/src/bridge.ts@@ -8,6 +8,7 @@ import {} from "./conversations.ts";import { describeTool, textOf } from "./presentation.ts";import type { AgentRecord, AgentSupervisor, SupervisorEvent } from "./supervisor.ts";+import { isBlockedInput, presentText, shouldShowToast } from "./white-label.ts";export interface BridgeClient {send(payload: ServerPayload): void;@@ -16,11 +17,12 @@ export interface BridgeClient {export interface BridgeOptions {dataDir: string;log?: (line: string) => void;- /** Rewrites or drops UI-bound payloads (white-label layer). Identity by default. */- filter?: (payload: ServerPayload) => ServerPayload | undefined;}const DIALOG_METHODS = new Set(["select", "confirm", "input", "editor"]);++/** An open dialog; `options` keeps the agent's original option strings for the answer. */+type PendingAsk = { ask: Ask; options?: string[]; timer?: NodeJS.Timeout };const REMEMBERED_REQUEST_IDS = 500;/**@@ -30,7 +32,7 @@ const REMEMBERED_REQUEST_IDS = 500;*/export class DotBridge {private readonly clients = new Set<BridgeClient>();- private readonly asks = new Map<string, { ask: Ask; timer?: NodeJS.Timeout }>();+ private readonly asks = new Map<string, PendingAsk>();private readonly runningTools = new Set<string>();private readonly seenRequestIds: string[] = [];private readonly sessionDir: string;@@ -87,6 +89,14 @@ export class DotBridge {case "hello":return;case "send": {+ if (isBlockedInput(message.text)) {+ this.deliver(client, {+ type: "error",+ code: "unsupported",+ message: "I can't run that command here.",+ });+ return;+ }if (message.requestId && this.alreadySeen(message.requestId)) return;this.interrupted = false;const busy = this.supervisor.busy;@@ -113,9 +123,16 @@ export class DotBridge {});return;}- const { requestId, ...answer } = message;- const { type: _type, ...fields } = answer;- this.supervisor.send({ type: "extension_ui_response", id: requestId, ...fields });+ const { requestId } = message;+ const answer: Record<string, unknown> = {};+ if (message.cancelled) answer.cancelled = true;+ else if (message.confirmed !== undefined) answer.confirmed = message.confirmed;+ else if (message.value !== undefined) {+ // Options are shown rewritten; answer with the agent's original string.+ const index = pending.ask.options?.indexOf(message.value) ?? -1;+ answer.value = index >= 0 ? (pending.options?.[index] ?? message.value) : message.value;+ }+ this.supervisor.send({ type: "extension_ui_response", id: requestId, ...answer });this.resolveAsk(requestId);return;}@@ -230,7 +247,7 @@ export class DotBridge {| undefined;if (message?.role !== "assistant") return;const messageId = this.assistantId ?? `m${++this.nextMessage}`;- this.broadcast({ type: "message_done", messageId, text: textOf(message) });+ this.broadcast({ type: "message_done", messageId, text: presentText(textOf(message)) });if (message.stopReason === "error") {this.log(`assistant error: ${message.errorMessage ?? "unknown"}`);this.broadcast({ type: "toast", level: "error", message: "Something went wrong while answering." });@@ -256,16 +273,24 @@ export class DotBridge {if (method === "notify") {const level =event.notifyType === "error" ? "error" : event.notifyType === "warning" ? "warning" : "info";- this.broadcast({ type: "toast", level, message: String(event.message ?? "") });+ if (shouldShowToast(level))+ this.broadcast({ type: "toast", level, message: presentText(String(event.message ?? "")) });return;}if (!DIALOG_METHODS.has(method) || !requestId) return;- const ask: Ask = { requestId, method: method as Ask["method"], title: String(event.title ?? "") };- if (typeof event.message === "string") ask.message = event.message;- if (Array.isArray(event.options)) ask.options = event.options.map(String);- if (typeof event.placeholder === "string") ask.placeholder = event.placeholder;+ const ask: Ask = {+ requestId,+ method: method as Ask["method"],+ title: presentText(String(event.title ?? "")),+ };+ const entry: PendingAsk = { ask };+ if (typeof event.message === "string") ask.message = presentText(event.message);+ if (Array.isArray(event.options)) {+ entry.options = event.options.map(String);+ ask.options = entry.options.map(presentText);+ }+ if (typeof event.placeholder === "string") ask.placeholder = presentText(event.placeholder);if (typeof event.prefill === "string") ask.prefill = event.prefill;- const entry: { ask: Ask; timer?: NodeJS.Timeout } = { ask };if (typeof event.timeout === "number" && event.timeout > 0) {ask.timeoutMs = event.timeout;// Pi resolves the dialog by itself when it times out; drop it here too.@@ -323,8 +348,7 @@ export class DotBridge {}private deliver(client: BridgeClient, payload: ServerPayload): void {- const filtered = this.options.filter ? this.options.filter(payload) : payload;- if (filtered) client.send(filtered);+ client.send(payload);}private log(line: string): void {diff --git a/packages/daemon/src/conversations.ts b/packages/daemon/src/conversations.tsindex f94b903..338a644 100644--- a/packages/daemon/src/conversations.ts+++ b/packages/daemon/src/conversations.ts@@ -2,6 +2,7 @@ import { closeSync, existsSync, openSync, readdirSync, readSync, statSync } fromimport { join, relative, resolve, sep } from "node:path";import type { Activity, ConversationSummary, HistoryMessage } from "@gentle-dot/protocol";import { describeTool, textOf } from "./presentation.ts";+import { presentText } from "./white-label.ts";const TITLE_SCAN_BYTES = 256 * 1024;const TITLE_LENGTH = 60;@@ -98,7 +99,7 @@ export function historyFromMessages(messages: unknown[]): HistoryMessage[] {turn = { id: `h${++index}`, role: "assistant", text: "", activities: [] };history.push(turn);}- const text = textOf(m);+ const text = presentText(textOf(m));if (text) turn.text = turn.text ? `${turn.text}\n\n${text}` : text;turn.activities.push(...activitiesOf(m, failed));}diff --git a/packages/daemon/src/daemon.ts b/packages/daemon/src/daemon.tsindex 556b5b2..ddc1c3f 100644--- a/packages/daemon/src/daemon.ts+++ b/packages/daemon/src/daemon.ts@@ -3,16 +3,11 @@ import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "noimport { createServer, type IncomingMessage, type ServerResponse } from "node:http";import type { AddressInfo } from "node:net";import { extname, join, resolve, sep } from "node:path";-import {- type ClientMessage,- CloseCode,- PROTOCOL_VERSION,- parseClientMessage,- type ServerPayload,-} from "@gentle-dot/protocol";+import { type ClientMessage, CloseCode, PROTOCOL_VERSION, parseClientMessage } from "@gentle-dot/protocol";import { type WebSocket, WebSocketServer } from "ws";import { type BridgeClient, DotBridge } from "./bridge.ts";import { AgentSupervisor } from "./supervisor.ts";+import { identityArgs } from "./white-label.ts";export interface DaemonOptions {port: number;@@ -28,7 +23,6 @@ export interface DaemonOptions {/** Origins allowed to open the WebSocket, besides the daemon's own and the desktop app's. */allowedOrigins?: string[];backoffMs?: number[];- filter?: (payload: ServerPayload) => ServerPayload | undefined;log?: (line: string) => void;}@@ -72,18 +66,14 @@ export async function startDaemon(options: DaemonOptions): Promise<DotDaemon> {const supervisor = new AgentSupervisor({command: options.agentCommand,args: options.agentArgs ?? [],- extraArgs: options.agentExtraArgs ?? [],+ extraArgs: [...identityArgs(options.dataDir), ...(options.agentExtraArgs ?? [])],cwd: options.workspace,dataDir: options.dataDir,env: options.agentEnv ?? process.env,...(options.backoffMs ? { backoffMs: options.backoffMs } : {}),log: (line) => log(`[agent] ${line}`),});- const bridge = new DotBridge(supervisor, {- dataDir: options.dataDir,- log,- ...(options.filter ? { filter: options.filter } : {}),- });+ const bridge = new DotBridge(supervisor, { dataDir: options.dataDir, log });const server = createServer((req, res) => handleHttp(req, res, options.uiDir, bridge));const wss = new WebSocketServer({ noServer: true, maxPayload: 1024 * 1024 });diff --git a/packages/daemon/src/identity.md b/packages/daemon/src/identity.mdnew file mode 100644index 0000000..0466748--- /dev/null+++ b/packages/daemon/src/identity.md@@ -0,0 +1,10 @@+# Product identity: Gentle Dot++This section defines your product identity and overrides every other identity statement in this prompt, earlier or later, including any instruction to introduce yourself as "el Gentleman", a harness, or a coding-agent harness.++- You are Gentle Dot, a personal assistant that lives on the user's desktop and in their browser.+- When the user asks who or what you are, answer as Gentle Dot: a personal assistant that can work with their files, run tasks, remember things across conversations, and bring in focused helpers.+- Never say these internal names to the user: Gentle Shell, gentle-shell, Gentle AI, gentle-ai, gentle-pi, Pi, el Gentleman, ODD, Organic Driven Development, Engram, RDD. When you need to refer to them, say "my workflow", "my memory", or "my helpers".+- Keep every working behavior from the rest of this prompt: the workflow, memory, helpers, verification, and safety rules all still apply.+- The user talks to you through a chat window, not a terminal. Never ask them to type slash commands or terminal-only commands; do the work yourself or explain it in plain words.+- Reply in the user's language.diff --git a/packages/daemon/src/white-label.ts b/packages/daemon/src/white-label.tsnew file mode 100644index 0000000..836d869--- /dev/null+++ b/packages/daemon/src/white-label.ts@@ -0,0 +1,56 @@+import { mkdirSync, readFileSync, writeFileSync } from "node:fs";+import { join } from "node:path";++/** Internal names that must never reach the user (docs/design.md §5). */+export const HIDDEN_NAMES: RegExp[] = [+ /gentle[ -]?shell/i,+ /el gentleman/i,+ /gentle[ -]?ai/i,+ /gentle[ -]?pi/i,+ /\bengram\b/i,+ /\bODD\b/,+ /organic driven development/i,+ /\/gentle:/i,+ /\bRDD\b/,+ /\bpi[ -]coding[ -]agent\b/i,+];++const REWRITES: [RegExp, string][] = [+ [/\/gentle:[\w:-]+/gi, ""],+ [/\bel gentleman\b/gi, "Gentle Dot"],+ [/\bgentle[ -]?(?:shell|ai|pi)\b/gi, "Gentle Dot"],+ [/\bpi[ -]coding[ -]agent\b/gi, "assistant"],+ [/\bPi (?:coding agent|agent|runtime|harness)\b/g, "assistant"],+ [/\borganic driven development\b/gi, "my workflow"],+ [/\bODD\b/g, "workflow"],+ [/\bengram\b/gi, "memory"],+ [/\breceipt-driven development\b/gi, "review"],+ [/\bRDD\b/g, "review"],+];++/** Rewrites internal names in harness-generated text shown to the user. */+export function presentText(text: string): string {+ let shown = text;+ for (const [pattern, replacement] of REWRITES) shown = shown.replace(pattern, replacement);+ return shown.replace(/ {2,}/g, " ").replace(/ +([.,;:!?])/g, "$1");+}++/** Informational notifications are harness chatter; warnings and errors still reach the user. */+export function shouldShowToast(level: "info" | "warning" | "error"): boolean {+ return level !== "info";+}++/** Internal slash commands are not part of the product. */+export function isBlockedInput(text: string): boolean {+ return /^\s*\/gentle:/i.test(text);+}++const IDENTITY_SOURCE = new URL("./identity.md", import.meta.url);++/** Writes the identity prompt to `<dataDir>/identity.md` and returns the agent arguments that load it. */+export function identityArgs(dataDir: string): string[] {+ mkdirSync(dataDir, { recursive: true });+ const path = join(dataDir, "identity.md");+ writeFileSync(path, readFileSync(IDENTITY_SOURCE, "utf8"));+ return ["--append-system-prompt", path];+}diff --git a/packages/daemon/test/gateway.test.ts b/packages/daemon/test/gateway.test.tsindex 605c6e7..1e59a1e 100644--- a/packages/daemon/test/gateway.test.ts+++ b/packages/daemon/test/gateway.test.ts@@ -1,9 +1,10 @@-import { mkdirSync, writeFileSync } from "node:fs";+import { mkdirSync, readFileSync, writeFileSync } from "node:fs";import { join } from "node:path";import type { ServerMessage } from "@gentle-dot/protocol";import { afterEach, describe, expect, it } from "vitest";import WebSocket from "ws";import { type DotDaemon, startDaemon } from "../src/daemon.ts";+import { HIDDEN_NAMES } from "../src/white-label.ts";import { FAKE_AGENT, tempDir, waitFor } from "./helpers.ts";const daemons: DotDaemon[] = [];@@ -233,6 +234,44 @@ describe("gateway", () => {});});+describe("white label", () => {+ it("passes the product identity to the agent", async () => {+ const argsFile = join(tempDir(), "argv.json");+ const d = await daemon({ ...process.env, FAKE_AGENT_ARGS_FILE: argsFile });+ const argv = JSON.parse(readFileSync(argsFile, "utf8")) as string[];+ const at = argv.indexOf("--append-system-prompt");+ expect(at).toBeGreaterThan(-1);+ const identity = readFileSync(argv[at + 1] ?? "", "utf8");+ expect(identity).toContain("You are Gentle Dot");+ expect(d.supervisor.state).toBe("ready");+ });++ it("hides branded startup chatter", async () => {+ const d = await daemon({ ...process.env, FAKE_AGENT_BRANDING: "1" });+ const client = await authed(d);+ send(client, { type: "get_history" });+ await find(client, "history");+ const text = JSON.stringify(client.messages);+ for (const name of HIDDEN_NAMES) expect(text).not.toMatch(name);+ });++ it("rewrites branded ask text", async () => {+ const d = await daemon();+ const client = await authed(d);+ send(client, { type: "send", text: "ask:confirm" });+ const ask = await find(client, "ask");+ expect(ask.ask.message).toBe("Gentle Dot wants to continue");+ });++ it("refuses internal slash commands", async () => {+ const d = await daemon();+ const client = await authed(d);+ send(client, { type: "send", text: "/gentle:yolo" });+ expect((await find(client, "error")).code).toBe("unsupported");+ expect(client.messages.some((m) => m.type === "user_message")).toBe(false);+ });+});+describe("http", () => {it("serves the UI, falls back to index.html, and blocks path traversal", async () => {const d = await daemon();diff --git a/packages/daemon/test/real-agent.test.ts b/packages/daemon/test/real-agent.test.tsnew file mode 100644index 0000000..e177759--- /dev/null+++ b/packages/daemon/test/real-agent.test.ts@@ -0,0 +1,65 @@+// @real-agent: starts the real `gentle-shell` and calls the configured model.+// Opt-in with GENTLE_DOT_REAL_AGENT=1 (`pnpm test:real`) so ordinary runs cost nothing.+import { execFileSync } from "node:child_process";+import type { ServerMessage } from "@gentle-dot/protocol";+import { afterAll, describe, expect, it } from "vitest";+import WebSocket from "ws";+import { type DotDaemon, startDaemon } from "../src/daemon.ts";+import { HIDDEN_NAMES } from "../src/white-label.ts";+import { tempDir, waitFor } from "./helpers.ts";++function hasGentleShell(): boolean {+ try {+ execFileSync("which", ["gentle-shell"], { stdio: "ignore" });+ return true;+ } catch {+ return false;+ }+}++const enabled = process.env.GENTLE_DOT_REAL_AGENT === "1" && hasGentleShell();++describe.skipIf(!enabled)("@real-agent gentle-shell", () => {+ let daemon: DotDaemon | undefined;+ afterAll(async () => {+ await daemon?.close();+ });++ it("starts gentle-shell in RPC mode with the Gentle extensions loaded", { timeout: 120_000 }, async () => {+ const dataDir = tempDir();+ daemon = await startDaemon({+ port: 0,+ host: "127.0.0.1",+ dataDir,+ workspace: dataDir,+ uiDir: dataDir,+ agentCommand: "gentle-shell",+ });+ expect(daemon.supervisor.state).toBe("ready");+ const response = await daemon.supervisor.request({ type: "get_commands" });+ const names = (response.data as { commands: { name: string }[] }).commands.map((c) => c.name);+ expect(names.some((name) => name.startsWith("gentle:"))).toBe(true);+ });++ it("answers as Gentle Dot without internal names", { timeout: 300_000 }, async () => {+ if (!daemon) throw new Error("daemon not started");+ const ws = new WebSocket(`ws://127.0.0.1:${daemon.port}/ws`);+ const messages: ServerMessage[] = [];+ ws.on("message", (data) => messages.push(JSON.parse(String(data)) as ServerMessage));+ await new Promise((resolve) => ws.on("open", resolve));+ ws.send(JSON.stringify({ type: "hello", token: daemon.token, protocol: 1 }));+ await waitFor(() => messages.some((m) => m.type === "ready"));+ ws.send(JSON.stringify({ type: "send", text: "Who are you? Answer in one or two sentences." }));+ await waitFor(() => messages.some((m) => m.type === "agent_state" && m.state === "thinking"), 30_000);+ await waitFor(() => messages.some((m) => m.type === "agent_state" && m.state === "idle"), 280_000);+ const answer = messages+ .flatMap((m) => (m.type === "message_done" ? [m.text] : []))+ .filter(Boolean)+ .at(-1);+ console.log(`identity answer: ${answer}`);+ expect(answer).toMatch(/Gentle Dot/);+ const shown = JSON.stringify(messages);+ for (const name of HIDDEN_NAMES) expect(shown).not.toMatch(name);+ ws.close();+ });+});diff --git a/packages/daemon/test/white-label.test.ts b/packages/daemon/test/white-label.test.tsnew file mode 100644index 0000000..179e762--- /dev/null+++ b/packages/daemon/test/white-label.test.ts@@ -0,0 +1,54 @@+import { describe, expect, it } from "vitest";+import { HIDDEN_NAMES, isBlockedInput, presentText, shouldShowToast } from "../src/white-label.ts";++describe("presentText", () => {+ it.each([+ ["Gentle Shell ready", "Gentle Dot ready"],+ ["gentle-shell is loading", "Gentle Dot is loading"],+ ["I am el Gentleman.", "I am Gentle Dot."],+ ["Gentle AI review mode is on", "Gentle Dot review mode is on"],+ ["Saved to Engram", "Saved to memory"],+ ["Following ODD", "Following workflow"],+ ["Organic Driven Development keeps it tidy", "my workflow keeps it tidy"],+ ["Run /gentle:status to check", "Run to check"],+ ["Started the Pi coding agent", "Started the assistant"],+ ["RDD is enabled", "review is enabled"],+ ])("rewrites %j", (input, expected) => {+ expect(presentText(input)).toBe(expected);+ });++ it("leaves ordinary text alone", () => {+ const text = "Pick a color: Pi is 3.14, odd numbers are fine, and gentle reminders help.";+ expect(presentText(text)).toBe(text);+ });++ it("leaves none of the hidden names in recorded startup events", () => {+ const recorded = [+ "Gentle Shell ready",+ "el Gentleman loaded ODD",+ "gentle-ai: review mode on (decided by global)",+ "Engram connected · project gentle-pi",+ ];+ for (const text of recorded) {+ const shown = presentText(text);+ for (const name of HIDDEN_NAMES) expect(shown, shown).not.toMatch(name);+ }+ });+});++describe("shouldShowToast", () => {+ it("hides informational chatter and keeps warnings and errors", () => {+ expect(shouldShowToast("info")).toBe(false);+ expect(shouldShowToast("warning")).toBe(true);+ expect(shouldShowToast("error")).toBe(true);+ });+});++describe("isBlockedInput", () => {+ it("blocks internal slash commands only", () => {+ expect(isBlockedInput("/gentle:yolo")).toBe(true);+ expect(isBlockedInput(" /gentle:status now")).toBe(true);+ expect(isBlockedInput("What does /gentle mean?")).toBe(false);+ expect(isBlockedInput("hello")).toBe(false);+ });+});