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
harness ps and show print an ask without the markers around a paste (#1252)
Deec3180125e24a
diff --git a/cli/src/agentClient/commands.spec.ts b/cli/src/agentClient/commands.spec.tsindex 2db5d76eb..017caa084 100644--- a/cli/src/agentClient/commands.spec.ts+++ b/cli/src/agentClient/commands.spec.ts@@ -158,6 +158,17 @@ describe('harness ps', () => {expect(h.out.join('\n')).toContain(' asked: the ask')})+ it('lists an ask without the markers around a paste', async () => {+ const d = new FakeDaemon()+ d.frames = [frame('a')]+ // As the daemon keeps it: on one line, the markers still in it.+ d.extra.agent_recent = () => ({ events: [], asks: ['read this: <pasted_content id="1c18"> #1242 is merged </pasted_content id="1c18">'] })+ const h = harness(d)+ expect(await psCommand([], h.deps)).toBe(EXIT.ok)+ expect(h.out.join('\n')).toContain(' asked: read this: #1242 is merged')+ expect(h.out.join('\n')).not.toContain('pasted_content')+ })+it('refuses names and unknown options with the usage, and prints the usage for --help', async () => {const h = harness(new FakeDaemon())expect(await psCommand(['kid'], h.deps)).toBe(EXIT.usage)diff --git a/cli/src/agentClient/commands.ts b/cli/src/agentClient/commands.tsindex 5fcfcdf48..29c44e5b4 100644--- a/cli/src/agentClient/commands.ts+++ b/cli/src/agentClient/commands.ts@@ -23,7 +23,7 @@ import { engineName } from '../messages/model.js'import { AgentClientError, openDaemon, whereFor, type Daemon, type Where } from './daemon.js'import { Ledger, ledgerPath, type Pending, type Started } from './ledger.js'import { messagesRpc, type Rpc } from '../messages/rpc.js'-import { callerOf, clip, isAgent, lastTurn, matching, outsideCaller, rowsOf, stateOf, STOPPED_WITHIN_MS, type Caller, type Frame, type HistoryEvent, type Row, type State } from './model.js'+import { asSaid, callerOf, clip, isAgent, lastTurn, matching, outsideCaller, rowsOf, stateOf, STOPPED_WITHIN_MS, type Caller, type Frame, type HistoryEvent, type Row, type State } from './model.js'export interface ClientDeps {pane?: string | undefined@@ -409,7 +409,7 @@ export function psCommand(argv: readonly string[], deps: ClientDeps = {}): Promiconst about = (Array.isArray(recent.events) ? recent.events as Array<Record<string, unknown>> : []).map((e) => (typeof e.recap === 'string' && e.recap ? e.recap : typeof e.text === 'string' ? e.text : '').replace(/\s+/g, ' ').trim()).filter(Boolean).slice(0, 3).map((t) => clip(t, 140))- if (asks.length) row.asks = asks.map((a) => clip(a.replace(/\s+/g, ' ').trim(), 200))+ if (asks.length) row.asks = asks.map((a) => clip(asSaid(a).replace(/\s+/g, ' ').trim(), 200))if (about.length) row.about = about.join(' / ')}))// Asked for and not started yet: listed by the name it was given, and what it waits for.diff --git a/cli/src/agentClient/model.spec.ts b/cli/src/agentClient/model.spec.tsindex fdd65abfe..5e9b56a5e 100644--- a/cli/src/agentClient/model.spec.ts+++ b/cli/src/agentClient/model.spec.ts@@ -3,7 +3,7 @@ import { tmpdir } from 'node:os'import { join } from 'node:path'import { afterEach, describe, expect, it } from 'vitest'import { Ledger, ledgerPath } from './ledger.js'-import { callerOf, clip, lastTurn, matching, outsideCaller, rowsOf, stateOf, STOPPED_WITHIN_MS, type Frame } from './model.js'+import { asSaid, callerOf, clip, lastTurn, matching, outsideCaller, rowsOf, stateOf, STOPPED_WITHIN_MS, type Frame } from './model.js'const dirs: string[] = []const ledger = (): Ledger => {@@ -128,6 +128,18 @@ describe('a harness as the agent verbs show it', () => {expect(lastTurn([ev('user_message', { content: 'x' }), ev('text_delta', { content: 7 })])).toEqual({ ask: 'x', answer: '', tools: 0, answered: false })})+ it('reads an ask without the markers around a paste, and keeps what was pasted', () => {+ const ev = (type: string, payload: Record<string, unknown> = {}) => ({ type, payload })+ const pasted = 'another agent release: \n\n<pasted_content id="1c18">\n#1242 is merged\n and released\n</pasted_content id="1c18">\n'+ expect(lastTurn([ev('user_message', { content: pasted }), ev('text_delta', { content: 'ok' })])?.ask)+ .toBe('another agent release: \n\n#1242 is merged\n and released')+ expect(asSaid('<pasted_content id="aa">\nfirst\n</pasted_content id="aa">\n\n\n<pasted_content id="bb">\nsecond\n</pasted_content id="bb">')).toBe('first\n\nsecond')+ expect(asSaid('<pasted_content id="aa"> one line </pasted_content id="aa"> then more')).toBe('one line then more')+ // Only a paste's markers: an ask that is nothing else is no ask, and other tags were said.+ expect(lastTurn([ev('user_message', { content: '<pasted_content id="aa">\n</pasted_content id="aa">' })])?.ask).toBeNull()+ expect(asSaid('make <b>this</b> bold, in a pasted_content test')).toBe('make <b>this</b> bold, in a pasted_content test')+ })+it('clips long text with an ellipsis', () => {expect(clip('abcdef', 4)).toBe('abc…')expect(clip('abc', 4)).toBe('abc')diff --git a/cli/src/agentClient/model.ts b/cli/src/agentClient/model.tsindex 1526264c9..0f6c304e2 100644--- a/cli/src/agentClient/model.ts+++ b/cli/src/agentClient/model.ts@@ -176,6 +176,17 @@ export interface LastTurn {const text = (value: unknown): string => (typeof value === 'string' ? value : '')+/**+ * What a harness was asked, as the person said it: without the markers Claude Code puts around a paste. `ps` and+ * `show` printed `asked: another agent release: <pasted_content id="1c18"> #1242 is merged…` (October 12, 2026).+ * What was pasted stays: it was said. A marker on a line of its own goes with its line; one inside a line, as the+ * daemon keeps an ask (on one line), leaves a space.+ */+const PASTE_TAG = '<\\/?pasted_content\\b[^>]*>'+const PASTE_LINE = new RegExp(`^[^\\S\\n]*${PASTE_TAG}[^\\S\\n]*\\n?`, 'gm')+const PASTE_INLINE = new RegExp(`[^\\S\\n]*${PASTE_TAG}[^\\S\\n]*`, 'g')+export const asSaid = (ask: string): string => ask.replace(PASTE_LINE, '').replace(PASTE_INLINE, ' ').replace(/\n{3,}/g, '\n\n').trim()+/*** The last turn in [events], oldest first: the last ask, and the answer, which is the text after the turn's last* tool call (the narration before it is the working, not the result). Null when the page holds no ask.@@ -194,7 +205,7 @@ export function lastTurn(events: HistoryEvent[]): LastTurn | null {turn.forEach((e, i) => { if (e.type === 'tool_start') tools++; if (e.type === 'tool_end' || e.type === 'tool_start') lastTool = i })const said = (from: number) => turn.slice(from).filter((e) => e.type === 'text_delta').map((e) => text(e.payload?.content)).join('').trim()const final = said(lastTool + 1)- return { ask: text(events[start].payload?.content).trim() || null, answer: final || said(0), tools, answered: !!final }+ return { ask: asSaid(text(events[start].payload?.content)) || null, answer: final || said(0), tools, answered: !!final }}export const clip = (value: string, max: number): string => (value.length > max ? `${value.slice(0, max - 1)}…` : value)