Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

feat(voice): ui_ask tool + palette whitelist closes Ask Yourself slice (b)

Adam Eivy600734c9b792
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index a72f1aa924..230c91180b 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -2,6 +2,7 @@
## Added
+- **Ask Yourself — slice (b) closes: voice tool + ⌘K palette action.** The text-chat half of "Ask Yourself" shipped on 2026-04-24, and per-turn promotions shipped on 2026-04-28; the remaining slice-(b) item — voice integration — is now done. New `ui_ask` voice tool in `server/services/voice/tools.js` consumes `askService.runAsk`'s async iterable (`sources`/`delta`/`done`/`error` events), accumulates the answer, and returns `{ ok, content, sourceCount, sources, providerId, model, summary }`. The tool's description tells the voice LLM to speak `content` verbatim, so the existing sentence-boundary TTS path in `pipeline.js` reads it aloud — no new client-side wiring required. Tool is gated by a new `ask` intent group with a tight regex (`ask my ?self|advise me|coach me|draft (a|an|my|me|something)|what.* on my plate|what (did|do|should) i (decide|think|believe|say|want|do)|why did i|when did i|recall (my|that|when)`) so small tool-use models (qwen3-4b, granite, etc.) only see it on RAG-style turns and don't get tempted to call it on plain UI/capture phrasings. `pipeline.js` now propagates the voice turn's `AbortSignal` through `ctx.signal` so barge-in tears down the upstream askService stream instead of silently leaking tokens into a closed connection. The palette half: `ui_ask` added to `PALETTE_ACTIONS` in `server/routes/palette.js` under section `Ask`, label `Ask Yourself` — `⌘K` exposes it with description/parameters auto-hydrated from the voice tool registry, and `POST /api/palette/action/ui_ask { args: { question, mode? } }` returns the answer + source kinds/titles synchronously so non-voice callers (palette, scripts) get the same RAG pipeline. 17 new tests (7 ui_ask tool, 5 ask-intent classifier, 3 ui_ask spec gating, 2 palette manifest + dispatch) — full server suite green at 2785/2785. Closes the last item in the PLAN.md "Ask Yourself — slice (b)" backlog. Files: `server/services/voice/tools.js`, `server/services/voice/tools.test.js`, `server/services/voice/pipeline.js`, `server/routes/palette.js`, `server/routes/palette.test.js`, `PLAN.md`.
- **Ask Yourself: one-click promote each assistant turn into a Brain note, CoS task, or Goal progress entry.** Closes the second half of "Ask Yourself — slice (b)" — the Ask page's twin-flavored answers were trapped in the conversation. Each assistant turn now shows three buttons below its source chips: **Save to Brain** (calls `brainService.captureThought` with the answer text), **Create task** (creates a CoS task with the answer as the description, capped at 280 chars and tagged with a "Promoted from Ask Yourself <id>" context note), and **Attach to goal…** (inline goal picker → `identityService.addProgressEntry` writes the answer as a `progressLog` note dated today). After a successful promotion the button mutates to a green "Saved to Brain"/"Task created"/"Attached: <goal title>" chip that deep-links to the saved record (`/brain/inbox`, `/cos`, `/digital-twin/goals?id=…`). Server-side, every promotion also pins the conversation (`promoted = true`) so anything saved elsewhere survives the 30-day expiry sweep — without that, a saved brain note could outlive the conversation it cites. New endpoint `POST /api/ask/:id/turns/:turnId/promote` validates a discriminated zod union — `{ target: 'brain' }`, `{ target: 'task', priority? }`, `{ target: 'goal', goalId }` — fails fast with 400/404/409 on missing turns, user turns, empty content, missing goals, or duplicate tasks. 13 new route tests; the full server suite remains green at 2746/2746. The remaining slice-(b) item — the `ui_ask` voice tool + palette whitelist — is still pending. Files: `server/routes/ask.js`, `server/routes/ask.test.js`, `client/src/services/apiAsk.js`, `client/src/pages/Ask.jsx`, `PLAN.md`.
- **Voice agent: `feeds_mark_read` tool.** Pairs with the existing `feeds_digest` so the user can say "mark that one read" / "mark them all read" / "mark all of Hacker News as read" without leaving the conversation. Two ways to call: `query` fuzzy-matches a single unread item by title (exact → substring → all-tokens fallback) using titles the LLM just spoke from `feeds_digest`; `all: true` marks every unread item read, optionally scoped to one feed via `feedQuery` (fuzzy-matched against feed title). The `feeds` intent regex was loosened to also match phrasings like "mark that one read" / "mark them all as read" / "headlines" so the tool is offered to the LLM on the right turns; the bare word "read" alone is intentionally NOT a feeds trigger (it collides with "read my log"). 11 new tests in `server/services/voice/tools.test.js` cover ok/error paths, feed scoping, fuzzy matching, and the new regex behavior. Files: `server/services/voice/tools.js`, `server/services/voice/tools.test.js`.
- **Reimagined theme system — four named themes with full design tokens.** Replaced the five ad-hoc color-only themes (Midnight, Phosphor, Ember, Arctic, Synthwave) with a structured manifest of four themes that each carry a complete design system, not just a color palette: **Classic Midnight** (the existing baseline, kept stable), **Lumen Glass** (translucent glass panes with backdrop-blur), **Black ICE Terminal** (dense cyberpunk terminal with scanlines and monospace UI), and **Blueprint Ops** (drafting-grid systems-map aesthetic). Each theme manifest declares colors (`--port-bg`, `--port-card`, etc), per-channel "on-X" foreground colors for accessible contrast on accent/success/warning/error pills, and a tokens block covering radii, font stacks (UI/display/mono), motion durations, shadow variants, backdrop-filter, body gradient/texture, control surfaces, hover/active states, terminal styling, and chart colors. A new runtime layer in `client/src/index.css` keys off `html[data-port-theme="<id>"]` so theme switches restyle the entire UI in one paint — including transitions on inputs/buttons, toaster border/shadow tokens (`client/src/main.jsx`), per-theme card backgrounds, sidebar treatments, and theme-specific flourishes (Black ICE scanline overlay, Blueprint Ops grid-pattern card backgrounds + heading rules, Lumen Glass focus glows). The theme picker has two surfaces: a redesigned dropdown in the bottom-bar `ThemeSwitcher` (portal-rendered, viewport-clamped, rAF-throttled scroll/resize repositioning, with family icons + accent swatch) and a new card-grid `ThemePickerPanel` in Settings → General that shows each theme's concept, density, four-color swatch row, and an active-state check. Legacy theme ids stored in `localStorage` or server settings are normalized via `LEGACY_THEME_ALIASES` (`midnight` → `classic-midnight`, `phosphor`/`synthwave` → `black-ice-terminal`, `arctic` → `lumen-glass`, `ember` → `blueprint-ops`) so existing users don't lose their preference; the migrated id is written back so future loads are direct. A new `npm run theme:check` script (`scripts/check-themes.js`, runs at any time) enforces the theme contract: every theme must declare every required color/token var with valid RGB channels, must point at a doc under `docs/themes/<id>.md` containing the four required sections (`## Intent`, `## Integration Rules`, `## Component Notes`, `## Validation`), every legacy alias must resolve to a real theme, and `index.css` must include a theme-specific selector for each non-default theme. Files: `client/src/themes/portosThemes.js` (new), `client/src/themes/familyIcons.js` (new), `client/src/components/ThemePickerPanel.jsx` (new), `client/src/components/ThemeSwitcher.jsx`, `client/src/components/ThemeContext.jsx`, `client/src/components/settings/GeneralTab.jsx`, `client/src/hooks/useTheme.js`, `client/src/index.css`, `client/src/main.jsx`, `docs/themes/*.md` (new — one per theme + README), `scripts/check-themes.js` (new), `package.json` (new `theme:check` script).
diff --git a/PLAN.md b/PLAN.md
index 7ab3da14d3..3134e8f4b3 100644
--- a/PLAN.md
+++ b/PLAN.md
@@ -128,10 +128,11 @@ Three high-value work items drawn from an inventory of the current app surface (
## Backlog
-- [ ] **Ask Yourself — slice (b)** — voice integration on top of the shipped text chat + promotions:
+- [x] **Ask Yourself — slice (b)** — voice integration on top of the shipped text chat + promotions:
- **Promotions ✅ shipped 2026-04-28.** Per-turn buttons on each assistant turn fire `POST /api/ask/:id/turns/:turnId/promote` (discriminated body `{ target: 'brain' | 'task' | 'goal', goalId? }`). Brain target calls `brainService.captureThought`, task target creates a CoS task with description capped at 280 chars and a "promoted from Ask Yourself <id>" context note, goal target appends a `progressLog` entry via `identityService.addProgressEntry`. Server pins the conversation (`promoted = true`) on every successful promotion so anything saved elsewhere survives the 30-day expiry sweep. UI shows inline "Saved to Brain"/"Task created"/"Attached: <goal title>" confirmation chips that deep-link to the saved record. 13 new route tests — full server suite stays green at 2746/2746.
- - `ui_ask` voice tool that pipes a spoken question through `askService.runAsk` and reads the streamed answer aloud (reuses the existing voice widget's TTS path). **Pending.**
- - Add `Ask` to the palette action whitelist (`server/routes/palette.js`) once the voice tool exists, so `⌘K` → "ask: …" can fire a prompt without leaving the current page. **Pending.**
+ - **`ui_ask` voice tool ✅ shipped 2026-04-28.** New tool in `server/services/voice/tools.js` consumes `askService.runAsk`'s SSE-shaped async iterable (`sources` / `delta` / `done` / `error` events), accumulates the answer, and returns `{ ok, content, sourceCount, sources, providerId, model, summary }`. The voice LLM is told (via the tool description) to speak `content` verbatim, so the existing sentence-boundary TTS path in `pipeline.js` reads it aloud without further wiring. The tool is gated by a new `ask` intent group (`/ask my ?self|advise me|coach me|draft (a|an|my|me|something)|what.* on my plate|what (did|do|should) i (decide|think|believe|say|want|do)|why did i|when did i|recall (my|that|when)/i`) so it only ships in the spec list when the user phrasing actually wants RAG — small tool-use models don't see it on plain UI/capture turns. `pipeline.js` now passes the turn's `AbortSignal` through `ctx.signal` so barge-in cancels the upstream askService stream instead of leaking tokens.
+ - **Palette whitelist ✅ shipped 2026-04-28.** `ui_ask` added to `PALETTE_ACTIONS` in `server/routes/palette.js` under section `Ask`, label `Ask Yourself`. `⌘K` → action surfaces the action with `description` / `parameters` hydrated from the voice tool registry; `POST /api/palette/action/ui_ask { args: { question, mode? } }` returns the answer + sources synchronously.
+ - 17 new tests (7 ui_ask tool, 5 ask-intent classifier, 3 ui_ask spec gating, 2 palette manifest + dispatch) — full server suite stays green at 2785/2785.
- [ ] **Voice CoS tool expansion** — tools now include the original domain set plus `ui_navigate`, `ui_list_interactables`, `ui_click`, `ui_fill`, `ui_select`, `ui_check` for accessibility-style page driving, and `feeds_mark_read` (pairs with `feeds_digest` — fuzzy-matches an unread item by title or marks all read, optionally scoped to a feed). Remaining candidates:
- `calendar_today` / `calendar_next` — surface today's Google Calendar events through the existing Google MCP integration
diff --git a/server/routes/palette.js b/server/routes/palette.js
index d1783e4289..3cd109d8ec 100644
--- a/server/routes/palette.js
+++ b/server/routes/palette.js
@@ -39,6 +39,7 @@ const PALETTE_ACTIONS = [
{ id: 'pm2_restart', label: 'Restart a PM2 process', section: 'System', destructive: true },
{ id: 'daily_log_read', label: "Read today's log", section: 'Brain' },
{ id: 'daily_log_append', label: 'Append to daily log', section: 'Brain' },
+ { id: 'ui_ask', label: 'Ask Yourself', section: 'Ask' },
{ id: 'time_now', label: 'Current time', section: 'System' },
];
diff --git a/server/routes/palette.test.js b/server/routes/palette.test.js
index be2ef612dd..047f2a7b02 100644
--- a/server/routes/palette.test.js
+++ b/server/routes/palette.test.js
@@ -33,6 +33,19 @@ vi.mock('../services/feeds.js', () => ({
getItems: vi.fn(async () => []),
getFeeds: vi.fn(async () => []),
}));
+vi.mock('../services/askService.js', () => ({
+ VALID_MODES: new Set(['ask', 'advise', 'draft']),
+ runAsk: vi.fn(async function* () {
+ yield { type: 'sources', sources: [{ kind: 'memory', title: 'A note' }] };
+ yield {
+ type: 'done',
+ answer: 'Here is the answer.',
+ sources: [{ kind: 'memory', title: 'A note' }],
+ providerId: 'p1',
+ model: 'm1',
+ };
+ }),
+}));
const { default: paletteRoutes } = await import('./palette.js');
@@ -103,4 +116,24 @@ describe('POST /api/palette/action/:id', () => {
.send({ args: { label: 'Save' } });
expect(res.status).toBe(404);
});
+
+ it('exposes ui_ask in the manifest with description hydrated from voice tools', async () => {
+ const res = await request(makeApp()).get('/api/palette/manifest');
+ const askAction = res.body.actions.find((a) => a.id === 'ui_ask');
+ expect(askAction).toBeTruthy();
+ expect(askAction.label).toBe('Ask Yourself');
+ expect(askAction.section).toBe('Ask');
+ expect(askAction.description).toMatch(/digital twin|retrieval/i);
+ expect(askAction.parameters?.properties?.question).toBeTruthy();
+ });
+
+ it('dispatches ui_ask through the palette and returns the answer + sources', async () => {
+ const res = await request(makeApp())
+ .post('/api/palette/action/ui_ask')
+ .send({ args: { question: 'what did I decide about exercise?' } });
+ expect(res.status).toBe(200);
+ expect(res.body.ok).toBe(true);
+ expect(res.body.result.content).toBe('Here is the answer.');
+ expect(res.body.result.sourceCount).toBe(1);
+ });
});
diff --git a/server/services/voice/pipeline.js b/server/services/voice/pipeline.js
index ac7a746756..2c76ca812f 100644
--- a/server/services/voice/pipeline.js
+++ b/server/services/voice/pipeline.js
@@ -452,7 +452,7 @@ export const runTurn = async ({ audio, text, mimeType, source, history = [], emi
const t0 = Date.now();
let result;
let args = {};
- const ctx = { sideEffects: [], state };
+ const ctx = { sideEffects: [], state, signal };
try {
args = tc.function.arguments ? JSON.parse(tc.function.arguments) : {};
const argSummary = Object.keys(args).length ? Object.entries(args).map(([k, v]) => `${k}=${JSON.stringify(v).slice(0, 40)}`).join(' ') : '—';
diff --git a/server/services/voice/tools.js b/server/services/voice/tools.js
index 794b3b94f4..391112fc9c 100644
--- a/server/services/voice/tools.js
+++ b/server/services/voice/tools.js
@@ -12,6 +12,7 @@ import { getItems, getFeeds, markItemRead, markAllRead } from '../feeds.js';
import { getUserTimezone, todayInTimezone, getLocalParts } from '../../lib/timezone.js';
import * as journal from '../brainJournal.js';
import { resolveNavCommand, normalizeLabel } from '../../lib/navManifest.js';
+import { runAsk, VALID_MODES as ASK_VALID_MODES } from '../askService.js';
const DAILY_LOG_PATH = '/brain/daily-log';
@@ -64,6 +65,7 @@ const TOOL_GROUPS = {
ui_fill: 'ui',
ui_select: 'ui',
ui_check: 'ui',
+ ui_ask: 'ask',
// UNGROUPED = always-on: time_now, daily_log_append, ui_navigate.
// brain_capture used to be always-on, but that caused form-fill turns
// ("fill description with X") to be misrouted to brain_capture because
@@ -100,6 +102,12 @@ const GROUP_INTENT = {
// a familiar word), "daily logins" all gate the daily-log toolset on. The
// \b anchors keep it from matching inside unrelated words like "logging".
dailylog: /\b(daily ?logi?n?s?|journal|dictat|log entry|log something|to my log|read (?:back )?my log)\b/i,
+ // RAG questions answered by askService — phrasings that need cross-domain
+ // recall (Brain + Memory + Goals + Calendar + Autobiography). Tight on
+ // purpose: the tool is large (consumes a full LLM stream) and we don't
+ // want it stealing turns the cheaper tools handle. Catches "advise me",
+ // "draft a/an X", "what did I decide", "what's on my plate", "ask myself".
+ ask: /\b(?:ask my ?self|advise me|coach me|draft (?:a|an|my|me|something)|what(?:'s| is) on my plate|what (?:did|do|should) i (?:decide|think|believe|say|want|do)|why did i|when did i|recall (?:my|that|when))\b/i,
ui: UI_INTENT_RE,
};
@@ -973,6 +981,72 @@ const TOOLS = [
},
},
+ {
+ name: 'ui_ask',
+ description:
+ 'Ask the user\'s digital twin a question that needs retrieval-augmented recall across their Brain (notes, ideas, projects, inbox), Memory (semantic + BM25), Goals, Calendar, and Autobiography. Use for cross-domain questions the cheaper tools cannot answer: ' +
+ '"what did I decide about X?", "advise me on Y given my goals", "draft a status update as me", "what\'s on my plate this afternoon?", "why did I prioritize Z?". ' +
+ 'NOT for one-shot lookups (use brain_search / goal_list / feeds_digest / time_now); NOT for capture verbs (use brain_capture / daily_log_append). ' +
+ 'The tool returns the answer in `content` — speak `content` verbatim, do NOT summarize or rephrase. Citation markers like [1] [2] in the content should be omitted when reading aloud (they reference source chips on the Ask page).',
+ parameters: {
+ type: 'object',
+ properties: {
+ question: {
+ type: 'string',
+ description: 'The user\'s question, in their own words. Pass through the substantive question — strip leading filler like "hey, can you" but keep the actual content.',
+ },
+ mode: {
+ type: 'string',
+ enum: ['ask', 'advise', 'draft'],
+ description: '"ask" answers as the user (default). "advise" answers as a coach who knows the user. "draft" produces text in the user\'s voice for an external recipient (use for "draft a Slack message", "write an email as me").',
+ },
+ },
+ required: ['question'],
+ },
+ execute: async ({ question, mode = 'ask' } = {}, ctx = {}) => {
+ if (typeof question !== 'string' || !question.trim()) {
+ throw new Error('question is required');
+ }
+ const trimmed = question.trim();
+ const validMode = ASK_VALID_MODES.has(mode) ? mode : 'ask';
+ let answer = '';
+ let sources = [];
+ let providerId = null;
+ let model = null;
+ let errorMsg = null;
+ // runAsk yields { sources, delta, done, error }. Accumulate deltas in
+ // case the provider streams; the terminal `done` event delivers the
+ // canonical full answer + reranked sources, so prefer that when present.
+ for await (const evt of runAsk({ question: trimmed, mode: validMode, signal: ctx.signal })) {
+ if (evt.type === 'sources') sources = evt.sources;
+ else if (evt.type === 'delta') answer += evt.text;
+ else if (evt.type === 'error') { errorMsg = evt.error; break; }
+ else if (evt.type === 'done') {
+ answer = evt.answer;
+ sources = evt.sources;
+ providerId = evt.providerId;
+ model = evt.model;
+ }
+ }
+ if (errorMsg) {
+ return { ok: false, error: errorMsg, summary: `I couldn't answer that — ${errorMsg}` };
+ }
+ const finalAnswer = answer.trim();
+ if (!finalAnswer) {
+ return { ok: false, summary: 'I came up empty on that question.' };
+ }
+ return {
+ ok: true,
+ content: finalAnswer,
+ sourceCount: sources.length,
+ sources: sources.map((s) => ({ kind: s.kind, title: s.title })),
+ providerId,
+ model,
+ summary: `Answered "${trimmed.slice(0, 60)}${trimmed.length > 60 ? '…' : ''}" using ${sources.length} source${sources.length === 1 ? '' : 's'}.`,
+ };
+ },
+ },
+
{
name: 'time_now',
description:
diff --git a/server/services/voice/tools.test.js b/server/services/voice/tools.test.js
index b239be2acf..47dc4c9fec 100644
--- a/server/services/voice/tools.test.js
+++ b/server/services/voice/tools.test.js
@@ -32,6 +32,23 @@ vi.mock('../feeds.js', () => ({
markItemRead: vi.fn(async () => ({ updated: true })),
markAllRead: vi.fn(async () => ({ marked: 0 })),
}));
+// askService.runAsk is an async generator. Default mock yields a small
+// synthetic stream so ui_ask tests don't need to spin up real providers.
+vi.mock('../askService.js', () => ({
+ VALID_MODES: new Set(['ask', 'advise', 'draft']),
+ runAsk: vi.fn(async function* () {
+ yield { type: 'sources', sources: [{ kind: 'memory', title: 'A note' }] };
+ yield { type: 'delta', text: 'Hello ' };
+ yield { type: 'delta', text: 'world.' };
+ yield {
+ type: 'done',
+ answer: 'Hello world.',
+ sources: [{ kind: 'memory', title: 'A note' }],
+ providerId: 'p1',
+ model: 'm1',
+ };
+ }),
+}));
const { dispatchTool, getToolSpecs, getToolSpecsForIntent, classifyIntent } = await import('./tools.js');
@@ -289,3 +306,104 @@ describe('feeds_mark_read', () => {
expect(r.ok).toBe(false);
});
});
+
+describe('ui_ask', () => {
+ it('rejects missing question', async () => {
+ await expect(dispatchTool('ui_ask', {})).rejects.toThrow(/question is required/);
+ });
+
+ it('rejects whitespace-only question', async () => {
+ await expect(dispatchTool('ui_ask', { question: ' ' })).rejects.toThrow(/question is required/);
+ });
+
+ it('streams runAsk events into a content + sources result', async () => {
+ const r = await dispatchTool('ui_ask', { question: 'what did I decide about exercise?' });
+ expect(r.ok).toBe(true);
+ expect(r.content).toBe('Hello world.');
+ expect(r.sourceCount).toBe(1);
+ expect(r.sources[0]).toEqual({ kind: 'memory', title: 'A note' });
+ expect(r.providerId).toBe('p1');
+ expect(r.model).toBe('m1');
+ expect(r.summary).toMatch(/Answered "what did I decide about exercise/);
+ });
+
+ it('passes mode + signal through to runAsk', async () => {
+ const askService = await import('../askService.js');
+ const ctrl = new AbortController();
+ await dispatchTool('ui_ask', { question: 'draft a status update', mode: 'draft' }, { signal: ctrl.signal });
+ expect(askService.runAsk).toHaveBeenLastCalledWith(
+ expect.objectContaining({
+ question: 'draft a status update',
+ mode: 'draft',
+ signal: ctrl.signal,
+ }),
+ );
+ });
+
+ it('falls back to "ask" mode when given an invalid mode', async () => {
+ const askService = await import('../askService.js');
+ await dispatchTool('ui_ask', { question: 'hello', mode: 'rant' });
+ expect(askService.runAsk).toHaveBeenLastCalledWith(
+ expect.objectContaining({ mode: 'ask' }),
+ );
+ });
+
+ it('returns ok:false when runAsk yields an error event', async () => {
+ const askService = await import('../askService.js');
+ askService.runAsk.mockImplementationOnce(async function* () {
+ yield { type: 'error', error: 'No AI provider available' };
+ });
+ const r = await dispatchTool('ui_ask', { question: 'hello' });
+ expect(r.ok).toBe(false);
+ expect(r.error).toBe('No AI provider available');
+ expect(r.summary).toMatch(/No AI provider available/);
+ });
+
+ it('returns ok:false when the stream produces no answer text', async () => {
+ const askService = await import('../askService.js');
+ askService.runAsk.mockImplementationOnce(async function* () {
+ yield { type: 'sources', sources: [] };
+ yield { type: 'done', answer: '', sources: [], providerId: 'p1', model: 'm1' };
+ });
+ const r = await dispatchTool('ui_ask', { question: 'silent' });
+ expect(r.ok).toBe(false);
+ expect(r.summary).toMatch(/empty/i);
+ });
+});
+
+describe('classifyIntent — ask group', () => {
+ it('matches "advise me" phrasings', () => {
+ expect(classifyIntent('advise me on the next step').has('ask')).toBe(true);
+ });
+ it('matches "what did I decide" phrasings', () => {
+ expect(classifyIntent('what did I decide about my exercise routine').has('ask')).toBe(true);
+ });
+ it('matches "draft a Slack message"', () => {
+ expect(classifyIntent('draft a slack message to my team as me').has('ask')).toBe(true);
+ });
+ it('does NOT match plain UI turns', () => {
+ expect(classifyIntent('click the save button').has('ask')).toBe(false);
+ });
+ it('does NOT match plain capture turns', () => {
+ expect(classifyIntent('remember to buy milk').has('ask')).toBe(false);
+ });
+});
+
+describe('getToolSpecsForIntent — ui_ask gating', () => {
+ const names = (specs) => specs.map((s) => s.function.name);
+
+ it('exposes ui_ask on RAG-style turns', () => {
+ const { specs } = getToolSpecsForIntent('what did I decide about my exercise routine?');
+ expect(names(specs)).toContain('ui_ask');
+ });
+
+ it('hides ui_ask on plain UI-driving turns', () => {
+ const { specs } = getToolSpecsForIntent('click the save button');
+ expect(names(specs)).not.toContain('ui_ask');
+ });
+
+ it('hides ui_ask on plain capture turns', () => {
+ const { specs } = getToolSpecsForIntent('remember to buy milk');
+ expect(names(specs)).not.toContain('ui_ask');
+ });
+});