The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
feat: add recap headline to agents.list response and enhance turn handling for bash-mode lines
e295e0c1f15531be644a1fcecfc7
diff --git a/cli/src/lib/autonomous-device/service.spec.ts b/cli/src/lib/autonomous-device/service.spec.tsindex de370b7cc..c96d36436 100644--- a/cli/src/lib/autonomous-device/service.spec.ts+++ b/cli/src/lib/autonomous-device/service.spec.ts@@ -181,6 +181,41 @@ describe('Autonomous device turn.summary carries the complete answer', () => {})})+describe('Autonomous device agents.list carries the newest recap headline', () => {+ const build = (recent: (agentId: string, n: number) => unknown[]) => new AutonomousDeviceService({ machineId: 'machine',+ agents: () => [{ agentId: 'a', name: 'Alpha', engine: 'claude', state: 'idle' }, { agentId: 'b', name: 'Beta', engine: 'codex', state: 'running' }],+ submit: vi.fn(), stop: async () => true, answer: async () => true, cancelDelivery: () => true, recent })+ const list = (service: AutonomousDeviceService) => service.request('device', { type: 'agents.list', requestId: randomUUID() })++ it('inlines each agent\'s latest recap, and only the headline', async () => {+ const recent = vi.fn((agentId: string) => agentId === 'a'+ ? [{ kind: 'summary', recap: 'Fixed the retry path', text: 'Fixed the retry path in client.ts and server.ts.', fullText: 'Fixed the retry path…\n\n- client.ts\n- server.ts' }]+ : [])+ const result = await list(build(recent))+ expect(result.agents).toEqual([+ { machineId: 'machine', agentId: 'a', name: 'Alpha', engine: 'claude', state: 'idle', recap: 'Fixed the retry path' },+ // No summarised turn yet → no field at all, not an empty string.+ { machineId: 'machine', agentId: 'b', name: 'Beta', engine: 'codex', state: 'running' },+ ])+ // One turn per agent is all the list needs; the fuller views stay behind `recap`, where n ≤ 5 bounds them.+ expect(recent).toHaveBeenCalledWith('a', 1)+ expect(recent).toHaveBeenCalledWith('b', 1)+ })++ it('flattens and caps the headline so the list stays inside the socket\'s frame budget', async () => {+ const long = 'word '.repeat(80).trim()+ const result = await list(build(() => [{ kind: 'summary', recap: `two\n lines ${long}`, text: '' }]))+ const rows = result.agents as Array<{ recap?: string }>+ expect(rows[0].recap!.startsWith('two lines word')).toBe(true)+ expect(rows[0].recap!.length).toBe(200)+ })++ it('treats a malformed recent row as no recap', async () => {+ const result = await list(build(() => ['not an object', { kind: 'summary', recap: 42 }]))+ expect((result.agents as Array<Record<string, unknown>>)[0]).not.toHaveProperty('recap')+ })+})+describe('Autonomous device app focus', () => {it('exposes revisions, remote focus, owner-aware clear and server identity', async () => {const f = fixture()diff --git a/cli/src/lib/autonomous-device/service.ts b/cli/src/lib/autonomous-device/service.tsindex e64ae8496..7d86414ad 100644--- a/cli/src/lib/autonomous-device/service.ts+++ b/cli/src/lib/autonomous-device/service.ts@@ -8,6 +8,8 @@ export interface AutonomousDeviceReceipt {error: { code: string; message: string } | null; at: number}export interface AutonomousDeviceAgent { agentId: string; name: string; engine: string; state: string }++const AGENT_RECAP_MAX_CHARS = 200export interface AutonomousDeviceDelivery { deliveryId: string; sessionId: string; state: ReceiptState; reason?: string }export interface AutonomousDeviceServiceOptions {machineId: string; serverInstanceId?: string; now?: () => number@@ -112,6 +114,12 @@ export class AutonomousDeviceService {this.now = options.now ?? Date.now}private key(deviceId: string, key: string): string { return `${deviceId}:${key}` }+ /** The newest `recap` turn's headline for an agent, or undefined when no turn has been summarised. */+ private latestRecap(agentId: string): string | undefined {+ const first = this.options.recent(agentId, 1)[0]+ const recap = object(first) && typeof first.recap === 'string' ? first.recap.replace(/\s+/g, ' ').trim() : ''+ return recap ? recap.slice(0, AGENT_RECAP_MAX_CHARS) : undefined+ }receipt(deviceId: string, key: string): AutonomousDeviceReceipt | null {this.prune()const value = this.entries.get(this.key(deviceId, key))?.receipt@@ -225,7 +233,12 @@ export class AutonomousDeviceService {if (type === 'focus.get') return response(this.focusSnapshot())if (type === 'focus.ensure') return response(await this.ensureFocus())if ('focusRevision' in req && (typeof req.focusRevision !== 'string' || !req.focusRevision)) fail('INVALID_REQUEST', 'focusRevision must be a nonempty string')- if (type === 'agents.list') return response({ machineId: this.options.machineId, agents: this.options.agents().map(a => ({ ...a, machineId: this.options.machineId })) })+ if (type === 'agents.list') {+ return response({ machineId: this.options.machineId, agents: this.options.agents().map(a => {+ const recap = this.latestRecap(a.agentId)+ return { ...a, machineId: this.options.machineId, ...(recap ? { recap } : {}) }+ }) })+ }if (typeof req.agentId !== 'string' || !req.agentId || typeof req.machineId !== 'string') fail('MISSING_TARGET', 'machineId and agentId are required')if (req.machineId !== this.options.machineId) fail('MACHINE_MISMATCH', 'Only the paired machine is available')const agentId = req.agentId as stringdiff --git a/cli/src/lib/normalize.test.ts b/cli/src/lib/normalize.test.tsindex 54c868646..52e95ff11 100644--- a/cli/src/lib/normalize.test.ts+++ b/cli/src/lib/normalize.test.ts@@ -86,6 +86,36 @@ describe('lastTurnTextFromRawLines', () => {})})+ it('keeps the last REAL ask when bash-mode (!command) lines follow it', () => {+ // Bash mode writes the command + its output back as a user line. It is the person running a shell,+ // not a prompt, so the recap must stay on the real task instead of drifting to shell mechanics.+ const lines = [+ userPrompt('u1', 'scan the network for loginable OrangePis'),+ asstText('a1', 'Found .143 — orangepi/orangepi works and it has passwordless sudo.'),+ userPrompt('b1', "<bash-input>ssh [email protected] echo hi</bash-input>"),+ userPrompt('b2', '<bash-stdout></bash-stdout><bash-stderr>unsupported option "no...".</bash-stderr>'),+ asstText('a2', 'That paste dropped a space; put it on one line.'),+ ]+ // The ask is the task, and the assistant text stays attributed to it (bash lines opened no new turn).+ expect(lastTurnTextFromRawLines(lines)).toEqual({+ userMessage: 'scan the network for loginable OrangePis',+ assistantText: 'Found .143 — orangepi/orangepi works and it has passwordless sudo.\n\nThat paste dropped a space; put it on one line.',+ })+ })++ it('still counts a user line that carries prose alongside a bash block', () => {+ const lines = [+ userPrompt('u1', 'old ask'),+ asstText('a1', 'old answer'),+ userPrompt('u2', 'here is the output, what now?\n<bash-stdout>port 22 open</bash-stdout>'),+ asstText('a2', 'It is reachable — try the default creds next.'),+ ]+ expect(lastTurnTextFromRawLines(lines)).toEqual({+ userMessage: 'here is the output, what now?\n<bash-stdout>port 22 open</bash-stdout>',+ assistantText: 'It is reachable — try the default creds next.',+ })+ })+it('skips compact metadata, platform prompts, and tool_result user echoes', () => {const lines = [line({ type: 'system', subtype: 'compact_boundary', compactMetadata: { trigger: 'auto' } }),@@ -166,6 +196,28 @@ describe('turn close on terminal stop reasons', () => {})})+describe('bash-mode lines are not turns', () => {+ it('a !command line opens no turn and leaves an open one untouched', () => {+ const state = newTurnState()+ // A bash-only line before any prompt: nothing opens.+ expect(lineToEvents(userPrompt('b0', '<bash-input>ls</bash-input>'), state)).toEqual([])+ expect(state.turnOpen).toBe(false)+ // Open a real turn, then a bash exchange mid-turn: it neither ends nor starts a turn.+ lineToEvents(userPrompt('u1', 'scan the network'), state)+ expect(state.turnOpen).toBe(true)+ expect(lineToEvents(userPrompt('b1', '<bash-input>ssh box echo hi</bash-input>'), state)).toEqual([])+ expect(lineToEvents(userPrompt('b2', '<bash-stdout>hi</bash-stdout><bash-stderr></bash-stderr>'), state)).toEqual([])+ expect(state.turnOpen).toBe(true)+ })++ it('a line with real prose beside a bash block still starts a turn', () => {+ const state = newTurnState()+ const events = lineToEvents(userPrompt('u1', 'what does this mean?\n<bash-stderr>boom</bash-stderr>'), state)+ expect(events).toContainEqual({ type: 'turn_started', payload: { userMessage: 'what does this mean?\n<bash-stderr>boom</bash-stderr>' } })+ expect(state.turnOpen).toBe(true)+ })+})+describe('slash-command prompts', () => {// Claude Code records a typed command ONLY as these tags; the expansion it sends to the model is a// separate `isMeta` line we suppress. Before the fix both normalized to "" and NO turn ever opened,diff --git a/cli/src/lib/normalize.ts b/cli/src/lib/normalize.tsindex b4c989946..de1c247eb 100644--- a/cli/src/lib/normalize.ts+++ b/cli/src/lib/normalize.ts@@ -103,6 +103,24 @@ export function stripSystemBlocks(text: string): string {.trim()}+/**+ * Bash mode (`!command` in Claude Code) writes the command and its output back into the transcript as a+ * `type:'user'` line — `<bash-input>…</bash-input>` and the `<bash-stdout>`/`<bash-stderr>` that follow.+ * It is the person running a local shell, NOT a prompt to the agent, so it must not open a turn: if it+ * did, the per-turn recap would summarise shell mechanics ("paste the command on one line") instead of+ * what the agent is actually working on, and the tile would drift off-task with every `!`. Stripped ONLY+ * for the turn-detection decision (see `realUserText`), never for display — the transcript still shows+ * the commands. A line carrying real prose ALONGSIDE a bash block keeps counting; only a bash-only line+ * is skipped.+ */+export function stripBashModeBlocks(text: string): string {+ return text+ .replace(/<bash-input>[\s\S]*?<\/bash-input>\s*/g, '')+ .replace(/<bash-stdout>[\s\S]*?<\/bash-stdout>\s*/g, '')+ .replace(/<bash-stderr>[\s\S]*?<\/bash-stderr>\s*/g, '')+ .trim()+}+// Built-in CLI commands that only drive the local TUI and never dispatch an agent turn. Surfacing// them as a user prompt would open a turn nothing ever closes (device tile stuck busy), so they stay// invisible — same as before. Anything else (a custom `~/.claude/commands/*.md`, `/goal`, `/review`,@@ -403,6 +421,9 @@ function isInterruptLine(msg: NormalizedMessage): boolean {function realUserText(msg: NormalizedMessage): string | null {const text = userTextRaw(msg)if (text === null || INTERRUPT_MARKER.test(text)) return null+ // A `!command` line is not a prompt — skip it so the turn (and its recap) stays anchored to the last+ // real ask. Only when nothing but bash blocks remain: a message that also carries prose still counts.+ if (!stripBashModeBlocks(text)) return nullreturn text}diff --git a/docs/autonomous-device-integration.md b/docs/autonomous-device-integration.mdindex 0c6136248..0f2371f45 100644--- a/docs/autonomous-device-integration.md+++ b/docs/autonomous-device-integration.md@@ -127,7 +127,7 @@ a duplicate may return any retained receipt state. Supported operations:|---|---|---|| `focus.ensure` | none | Same snapshot as `focus.get`; enable-time first-agent fallback acknowledged by Desktop || `focus.get` | none | `focus:null\|{machineId,agentId,name?},focusRevision` |-| `agents.list` | none | `machineId,agents:[{machineId,agentId,name,engine,state}]` |+| `agents.list` | none | `machineId,agents:[{machineId,agentId,name,engine,state,recap?}]` — `recap` is the agent's newest turn headline (≤200 chars, the same string `recap` returns as `turns[0].recap`); absent until a turn has been summarised || `status` | `machineId,agentId` | `machineId,agentId,state,openQuestion:null\|{requestId,questions}` || `recap` | `machineId,agentId,n?` (default 3, integer 1–5) | `machineId,agentId,turns:[{kind,text,recap?,fullText?}]` || `turn.send` | `machineId,agentId,idempotencyKey,text,focusRevision?` | `status,receipt` |@@ -203,6 +203,10 @@ prefer `turns[].fullText`, then `turn.summary.fullText`, then `text`:| `text` | 250 chars | the answer flattened to one line and clipped — a glance || `fullText` | 8192 bytes UTF-8 | the assistant's final message as shown on screen, markdown and line breaks intact |+`agents.list` inlines only the first of the three, so a list view has a status line per agent without one+`recap` round-trip each. Only the headline, by arithmetic again: the list is uncapped, and `text` or+`fullText` on every row would put a machine with a few dozen agents over the socket's frame limit.+`fullText` is optional and absent when no answer was recorded, so read it defensively. It holds only thefinal user-facing response — never tool transcripts, hidden reasoning or terminal output — and it costsno extra model call: it is the same text the local summarizer already receives.