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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
feat([voice-code-agent-status-query]): add code_agent_status voice tool for mid-task check-ins
[._.]/ Adam Eivydca51a2808ba
diff --git a/server/routes/palette.js b/server/routes/palette.jsindex 6b0844aee6..223e67acf8 100644--- a/server/routes/palette.js+++ b/server/routes/palette.js@@ -51,6 +51,7 @@ const PALETTE_ACTIONS = [{ id: 'ui_ask', label: 'Ask Yourself', section: 'Ask' },{ id: 'image_generate', label: 'Generate Image', section: 'Create' },{ id: 'dispatch_code_agent', label: 'Dispatch coding agent', section: 'Agents' },+ { id: 'code_agent_status', label: 'Coding agent status', section: 'Agents' },{ id: 'time_now', label: 'Current time', section: 'System' },];diff --git a/server/services/voice/tools.js b/server/services/voice/tools.jsindex 7e7adf735f..c3c1114bf2 100644--- a/server/services/voice/tools.js+++ b/server/services/voice/tools.js@@ -203,6 +203,7 @@ const TOOL_GROUPS = {pipeline_prev_stage: 'pipeline',pipeline_open_stage: 'pipeline',dispatch_code_agent: 'code',+ code_agent_status: 'code',// 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@@ -294,7 +295,7 @@ const GROUP_INTENT = {// in speech). A false positive only OFFERS the tool to the LLM (which still// has to choose it), and the tool is a no-op unless codeAgent.enabled// (pipeline.js strips it from the spec list when off).- code: /\b(?:have (?:claude|codex|gemini|the agent|an agent)\b|dispatch (?:a |an )?(?:coding |code )?agent|spin up an agent|code (?:it )?up|open a pr|pull request|refactor|(?:implement|debug|rewrite|patch)\b[^.!?\n]{0,40}\b(?:bug|tests?|function|method|build|lint|type ?error|error|code|file|module|endpoint|route|component|class|api|schema|migration|script|flag|regression|handler|parser|service|hook|query|registry|config)\b|fix (?:the |a |an |my )?(?:bug|test|tests|failing|function|method|build|lint|type|error|code|file|module|endpoint|route|component)|write (?:a |the |some )?(?:unit |integration )?tests?|add (?:a |an |the )?(?:flag|function|method|endpoint|route|test|migration)\b)/i,+ code: /\b(?:have (?:claude|codex|gemini|the agent|an agent)\b|dispatch (?:a |an )?(?:coding |code )?agent|spin up an agent|code (?:it )?up|open a pr|pull request|refactor|(?:implement|debug|rewrite|patch)\b[^.!?\n]{0,40}\b(?:bug|tests?|function|method|build|lint|type ?error|error|code|file|module|endpoint|route|component|class|api|schema|migration|script|flag|regression|handler|parser|service|hook|query|registry|config)\b|fix (?:the |a |an |my )?(?:bug|test|tests|failing|function|method|build|lint|type|error|code|file|module|endpoint|route|component)|write (?:a |the |some )?(?:unit |integration )?tests?|add (?:a |an |the )?(?:flag|function|method|endpoint|route|test|migration)\b|(?:how(?:'s| is| are)?|status of|progress on|what(?:'s| is)? happening (?:with|on)|where (?:are|is) (?:we|it|that|the))\b[^.!?\n]{0,40}\b(?:coding (?:task|agent|job)|code agent|coding|agent|pr|pull request|dispatched (?:task|job))\b|\bis (?:the |that |my )?(?:coding |code )?(?:agent|task) (?:still |yet )?(?:running|going|working|done|finished))/i,ui: UI_INTENT_RE,};@@ -1954,6 +1955,83 @@ const TOOLS = [return { ok: true, taskId: created?.id, running, app: resolvedAppId, summary };},},++ {+ name: 'code_agent_status',+ description:+ "Report the status of in-flight coding tasks the user dispatched by voice (via dispatch_code_agent). Use when the user asks how a coding agent / dispatched task is doing — e.g. \"how's that coding task going?\", \"is the agent still running?\", \"status of the PR\", \"what's happening with the refactor?\". Reads live agent state and reports phase + elapsed per running task. The completion announcement covers the done case proactively; this tool is for mid-task check-ins. Returns an empty-but-ok result when nothing is running — speak the summary verbatim.",+ parameters: {+ type: 'object',+ properties: {},+ },+ execute: async () => {+ const { loadState } = await import('../cosState.js');+ const { getTaskById } = await import('../cos.js');++ const state = await loadState();+ const runningAgents = Object.values(state?.agents || {}).filter((a) => a?.status === 'running');++ // task.metadata.voiceDispatch round-trips through TASKS.md, so it can+ // be either boolean true or the literal string 'true'. Mirror the+ // proactiveTriggers convention rather than coupling to it.+ const isMetaTrue = (v) => v === true || v === 'true';+ const matched = [];+ for (const agent of runningAgents) {+ if (!agent?.taskId) continue;+ const task = await getTaskById(agent.taskId).catch(() => null);+ if (!task) continue;+ if (!isMetaTrue(task.metadata?.voiceDispatch)) continue;+ const startedAt = agent.startedAt ? Date.parse(agent.startedAt) : NaN;+ const elapsedMs = Number.isFinite(startedAt) ? Math.max(0, Date.now() - startedAt) : null;+ matched.push({+ taskId: task.id,+ agentId: agent.id,+ description: (task.description || '').split('\n')[0].trim(),+ phase: agent.metadata?.phase || 'working',+ app: agent.metadata?.taskAppName || agent.metadata?.taskApp || null,+ elapsedMs,+ });+ }++ if (matched.length === 0) {+ return {+ ok: true,+ count: 0,+ agents: [],+ summary: 'No coding tasks are running right now.',+ };+ }++ const phaseText = (phase) => (phase === 'initializing' ? 'spinning up' : 'working');+ const elapsedSpoken = (ms) => {+ if (!Number.isFinite(ms) || ms < 60_000) return 'less than a minute';+ const mins = Math.floor(ms / 60_000);+ if (mins < 60) return `${mins} minute${mins === 1 ? '' : 's'}`;+ const hours = Math.floor(mins / 60);+ const rem = mins % 60;+ const h = `${hours} hour${hours === 1 ? '' : 's'}`;+ return rem === 0 ? h : `${h} ${rem} minute${rem === 1 ? '' : 's'}`;+ };+ const clipDesc = (s) => (s.length > 80 ? `${s.slice(0, 77)}…` : s);++ let summary;+ if (matched.length === 1) {+ const a = matched[0];+ const appSuffix = a.app ? ` in ${a.app}` : '';+ const descPart = a.description ? `: ${clipDesc(a.description)}` : '';+ summary = `One coding task is ${phaseText(a.phase)}${appSuffix} — ${elapsedSpoken(a.elapsedMs)} in${descPart}.`;+ } else {+ const lines = matched.map((a) => {+ const appSuffix = a.app ? ` in ${a.app}` : '';+ const descPart = a.description ? ` "${clipDesc(a.description)}"` : '';+ return `${phaseText(a.phase)}${appSuffix}${descPart}, ${elapsedSpoken(a.elapsedMs)} in`;+ });+ summary = `${matched.length} coding tasks are running: ${lines.join('; ')}.`;+ }++ return { ok: true, count: matched.length, agents: matched, summary };+ },+ },];const toSpec = (t) => ({diff --git a/server/services/voice/tools.test.js b/server/services/voice/tools.test.jsindex 0d424f5ea7..d4fd04730c 100644--- a/server/services/voice/tools.test.js+++ b/server/services/voice/tools.test.js@@ -139,9 +139,18 @@ vi.mock('../askService.js', () => ({vi.mock('./config.js', () => ({getVoiceConfig: vi.fn(async () => ({ llm: { codeAgent: { enabled: true, provider: '', model: '' } } })),}));+// code_agent_status reads agent state and looks up each agent's task by id.+// loadState comes from cosState.js; getTaskById comes from cos.js. Default to+// empty/no-op so tests that don't care can ignore it.+const cosStateRef = { value: { agents: {} } };+const tasksRef = { value: [] };+vi.mock('../cosState.js', () => ({+ loadState: vi.fn(async () => cosStateRef.value),+}));vi.mock('../cos.js', () => ({addTask: vi.fn(async (data) => ({ id: 'task-test', ...data })),isRunning: vi.fn(() => true),+ getTaskById: vi.fn(async (id) => tasksRef.value.find((t) => t.id === id) || null),}));// dispatch_code_agent fuzzy-resolves the optional `app` parameter against the// user's configured managed apps; default to two apps so the resolve / not-@@ -319,6 +328,86 @@ describe('dispatch_code_agent', () => {});});+describe('code_agent_status', () => {+ afterEach(() => {+ cosStateRef.value = { agents: {} };+ tasksRef.value = [];+ });++ it('reports zero tasks when no agents are running', async () => {+ const r = await dispatchTool('code_agent_status', {});+ expect(r.ok).toBe(true);+ expect(r.count).toBe(0);+ expect(r.summary).toMatch(/no coding tasks/i);+ });++ it('ignores running agents whose task is NOT voice-dispatched', async () => {+ cosStateRef.value = { agents: { 'a1': { id: 'a1', taskId: 't1', status: 'running', startedAt: new Date().toISOString(), metadata: { phase: 'working' } } } };+ tasksRef.value = [{ id: 't1', description: 'manual task', metadata: {} }];+ const r = await dispatchTool('code_agent_status', {});+ expect(r.count).toBe(0);+ });++ it('ignores agents that are not in running status', async () => {+ cosStateRef.value = { agents: { 'a1': { id: 'a1', taskId: 't1', status: 'completed', startedAt: new Date().toISOString() } } };+ tasksRef.value = [{ id: 't1', description: 'done', metadata: { voiceDispatch: true } }];+ const r = await dispatchTool('code_agent_status', {});+ expect(r.count).toBe(0);+ });++ it('reports a single voice-dispatched running task with phase, app, and elapsed', async () => {+ const startedAt = new Date(Date.now() - 5 * 60 * 1000).toISOString();+ cosStateRef.value = { agents: { 'a1': { id: 'a1', taskId: 't1', status: 'running', startedAt, metadata: { phase: 'working', taskAppName: 'BookLoom' } } } };+ tasksRef.value = [{ id: 't1', description: 'fix the failing backup test\nmore detail', metadata: { voiceDispatch: true } }];+ const r = await dispatchTool('code_agent_status', {});+ expect(r.ok).toBe(true);+ expect(r.count).toBe(1);+ expect(r.agents[0]).toMatchObject({ taskId: 't1', phase: 'working', app: 'BookLoom' });+ expect(r.agents[0].description).toBe('fix the failing backup test');+ expect(r.summary).toMatch(/working in BookLoom/);+ expect(r.summary).toMatch(/5 minutes/);+ expect(r.summary).toMatch(/fix the failing backup test/);+ });++ it('accepts the string "true" voiceDispatch flag (TASKS.md round-trip)', async () => {+ cosStateRef.value = { agents: { 'a1': { id: 'a1', taskId: 't1', status: 'running', startedAt: new Date().toISOString() } } };+ tasksRef.value = [{ id: 't1', description: 'x', metadata: { voiceDispatch: 'true' } }];+ const r = await dispatchTool('code_agent_status', {});+ expect(r.count).toBe(1);+ });++ it('reports "spinning up" while phase=initializing', async () => {+ cosStateRef.value = { agents: { 'a1': { id: 'a1', taskId: 't1', status: 'running', startedAt: new Date().toISOString(), metadata: { phase: 'initializing' } } } };+ tasksRef.value = [{ id: 't1', description: 'add a flag', metadata: { voiceDispatch: true } }];+ const r = await dispatchTool('code_agent_status', {});+ expect(r.summary).toMatch(/spinning up/);+ });++ it('summarizes multiple running voice-dispatched tasks', async () => {+ const t = (sec) => new Date(Date.now() - sec * 1000).toISOString();+ cosStateRef.value = { agents: {+ a1: { id: 'a1', taskId: 't1', status: 'running', startedAt: t(120), metadata: { phase: 'working' } },+ a2: { id: 'a2', taskId: 't2', status: 'running', startedAt: t(30), metadata: { phase: 'initializing', taskAppName: 'BookLoom' } },+ } };+ tasksRef.value = [+ { id: 't1', description: 'fix the build', metadata: { voiceDispatch: true } },+ { id: 't2', description: 'add a flag', metadata: { voiceDispatch: true } },+ ];+ const r = await dispatchTool('code_agent_status', {});+ expect(r.count).toBe(2);+ expect(r.summary).toMatch(/^2 coding tasks/);+ expect(r.summary).toMatch(/fix the build/);+ expect(r.summary).toMatch(/add a flag/);+ });++ it('reports "less than a minute" for fresh starts', async () => {+ cosStateRef.value = { agents: { a1: { id: 'a1', taskId: 't1', status: 'running', startedAt: new Date(Date.now() - 5_000).toISOString(), metadata: { phase: 'working' } } } };+ tasksRef.value = [{ id: 't1', description: 'x', metadata: { voiceDispatch: true } }];+ const r = await dispatchTool('code_agent_status', {});+ expect(r.summary).toMatch(/less than a minute/);+ });+});+describe('code intent classification', () => {it('routes coding requests to the code group', () => {expect([...classifyIntent('have the agent fix the failing test')]).toContain('code');@@ -326,6 +415,13 @@ describe('code intent classification', () => {expect([...classifyIntent('write a unit test for the echo filter')]).toContain('code');});+ it('routes status-check phrasings to the code group (so code_agent_status reaches the LLM)', () => {+ expect([...classifyIntent("how's that coding task going?")]).toContain('code');+ expect([...classifyIntent('status of the agent')]).toContain('code');+ expect([...classifyIntent('is the agent still running')]).toContain('code');+ expect([...classifyIntent("what's happening with the PR")]).toContain('code');+ });+it('does not route plain reminders/notes/ambiguous-verb phrases to the code group', () => {expect([...classifyIntent('remind me to call mom')]).not.toContain('code');expect([...classifyIntent('what is on my calendar today')]).not.toContain('code');