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
A Buddy can send a proposal with attached files (#3402)
harness-for-autonomous[bot]830fc85a981b
diff --git a/cli/src/superTabs/command.spec.ts b/cli/src/superTabs/command.spec.tsindex 16584fd28..394e308df 100644--- a/cli/src/superTabs/command.spec.ts+++ b/cli/src/superTabs/command.spec.ts@@ -6,6 +6,10 @@ import type { Where } from '../agentClient/daemon.js'import { SWARM_TOOLS_SKILL } from '../lib/swarmTools.js'const where = { port: 14001, dataDir: '/fixture', machineId: 'machine' }const prefix = ['--tab', 'tab', '--agent', 'agent']+/** The service's answer for a proposal's files (service.ts proposalTarget) from a fixture's Swarm state: the chat named, the+ * calling agent's record, and the projects' chats. */+const proposalTarget = (state: { agents?: Array<Record<string, unknown>>; conversations?: Array<Record<string, unknown>>; projects?: Array<Record<string, unknown>> },+ conversationId: unknown) => ({ chat: state.conversations?.find(c => c.id === conversationId) ?? null, self: state.agents?.[0] ?? null, projects: state.projects ?? [] })it('keeps an explicit stable receipt for agent messages and arbitrary work commands', () => {expect(parseSuperTabArgs([...prefix, 'post', 'lead', 'Ready', 'op-1'], where).payload).toMatchObject({ action: 'command', operationId: 'op-1', command: { type: 'message.send', conversationId: 'lead', text: 'Ready' } })expect(parseSuperTabArgs([...prefix, 'command', 'op-2', '{"type":"work.assign"}'], where).payload).toMatchObject({ command: { type: 'work.assign' } })@@ -320,6 +324,71 @@ it('parses propose with up to 5 --attach files, always as a proposal', () => {expect(() => parseSuperTabArgs([...prefix, 'propose', 'op-1', json, ...tail], where)).toThrow('harness super-tab')}})+// Huy 11-06 (#3872): every Buddy proposal with a file was refused before upload, "Name your own chat". The upload read its chat,+// its record and the projects' chats from `status`, which a Buddy gets as a task summary with none of them. It reads them from+// the read made for it, as the service answers a Buddy.+it('sends a Buddy\'s proposal with a file, its status being the task summary a Buddy reads', async () => {+ const { mkdtempSync, writeFileSync, rmSync } = await import('node:fs')+ const { join } = await import('node:path')+ const { tmpdir } = await import('node:os')+ const folder = mkdtempSync(join(tmpdir(), 'buddy-folder-'))+ try {+ writeFileSync(join(folder, 'shot.png'), Buffer.from([1, 2, 3]))+ const calls: Array<Record<string, unknown>> = []+ const request = vi.fn(async (type: string, payload: Record<string, unknown> = {}): Promise<Record<string, unknown>> => {+ if (type === 'agents_list') return { agents: [{ id: 'buddy-harness', engine: 'claude', status: 'active', tmuxPane: '%7', project: { cwd: folder } }] }+ calls.push(payload)+ if (payload.action === 'status') return { ok: true, value: { lastChangedAt: 1, summary: { tasks: [] } } }+ if (payload.action === 'proposalTarget') return { ok: true, value: { chat: { id: 'chat', projectId: 'p', kind: 'buddy' }, self: { id: 'buddy' },+ projects: [{ id: 'p', leadConversationId: 'lead' }] } }+ if (payload.step === 'sent') return { ok: true, value: { agentId: 'buddy', attachmentIds: null } }+ return { ok: true, value: { revision: 9, result: { messageId: 'm' } } }+ })+ const fetch = vi.fn(async () => new Response(JSON.stringify({ success: true, data: { attachment: { id: 'f1' } } }), { status: 200 }))+ const deps = { where: () => where, open: async () => ({ request, close: vi.fn(), machineId: 'machine' }), print: vi.fn(), pane: '%7',+ fetch: fetch as unknown as typeof globalThis.fetch }+ const json = JSON.stringify({ conversationId: 'chat', ownerMessageId: 'ask', goal: 'G', scope: 'S', priority: 'normal' })+ expect(await superTabCommand([...prefix, 'propose', 'op', json, '--attach', join(folder, 'shot.png')], deps)).toBe(0)+ expect(calls.find(c => c.action === 'proposalTarget')).toMatchObject({ conversationId: 'chat' })+ expect(calls.at(-1)).toMatchObject({ operationId: 'op', command: { type: 'buddy.propose', attachmentIds: ['f1'] } })+ } finally { rmSync(folder, { recursive: true, force: true }) }+})++// Linuxtest4 on #3402: the Buddy's own record was looked up by its terminal's id, not its Swarm id, so a project session's project+// was never read: leaving the project out was refused, and naming another sent that project's PM a file. The read answers for+// the asking agent alone, so its record is the caller's.+it('sends a project session\'s file to its own project only, its terminal id not being its Swarm id', async () => {+ const { mkdtempSync, writeFileSync, rmSync } = await import('node:fs')+ const { join } = await import('node:path')+ const { tmpdir } = await import('node:os')+ const folder = mkdtempSync(join(tmpdir(), 'buddy-session-'))+ try {+ writeFileSync(join(folder, 'shot.png'), Buffer.from([1, 2, 3]))+ const calls: Array<Record<string, unknown>> = []+ const request = vi.fn(async (type: string, payload: Record<string, unknown> = {}): Promise<Record<string, unknown>> => {+ if (type === 'agents_list') return { agents: [{ id: 'session-harness', engine: 'claude', status: 'active', tmuxPane: '%7', project: { cwd: folder } }] }+ calls.push(payload)+ if (payload.action === 'proposalTarget') return { ok: true, value: { chat: { id: 'chat', kind: 'swarm-buddy' },+ self: { id: 'buddy-swarm-id', buddySession: { projectId: 'p-web' } },+ projects: [{ id: 'p-web', leadConversationId: 'web-chat' }, { id: 'p-secret', leadConversationId: 'secret-chat' }] } }+ if (payload.step === 'sent') return { ok: true, value: { agentId: 'buddy-swarm-id', attachmentIds: null } }+ return { ok: true, value: { revision: 9, result: { messageId: 'm' } } }+ })+ const fetch = vi.fn(async () => new Response(JSON.stringify({ success: true, data: { attachment: { id: 'f1' } } }), { status: 200 }))+ const deps = { where: () => where, open: async () => ({ request, close: vi.fn(), machineId: 'machine' }), print: vi.fn(), pane: '%7',+ fetch: fetch as unknown as typeof globalThis.fetch }+ const propose = (projectId?: string) => superTabCommand([...prefix, 'propose', 'op', JSON.stringify({ conversationId: 'chat', ownerMessageId: 'ask',+ ...(projectId ? { projectId } : {}), goal: 'G', scope: 'S', priority: 'normal' }), '--attach', join(folder, 'shot.png')], deps)+ expect(await propose()).toBe(0)+ expect(calls.filter(c => c.step === 'sent')).toEqual([expect.objectContaining({ conversationId: 'web-chat' })])+ calls.length = 0+ fetch.mockClear()+ expect(await propose('p-secret')).toBe(1)+ expect(JSON.parse(deps.print.mock.calls.at(-1)![0]).error).toContain('leave the project out')+ expect(fetch).not.toHaveBeenCalled()+ } finally { rmSync(folder, { recursive: true, force: true }) }+})+it('attaches to a proposal only files inside the Buddy\'s own folder, uploaded to its chat, beside the files its owner sent', async () => {const { mkdtempSync, mkdirSync, writeFileSync, symlinkSync, linkSync, rmSync } = await import('node:fs')const { join } = await import('node:path')@@ -344,8 +413,8 @@ it('attaches to a proposal only files inside the Buddy\'s own folder, uploaded tconst request = vi.fn(async (type: string, payload: Record<string, unknown> = {}): Promise<Record<string, unknown>> => {if (type === 'agents_list') return { agents: frames }calls.push(payload)- if (payload.action === 'status') return { ok: true, value: { state: { projects: [{ id: 'p', leadConversationId: 'lead' }],- conversations: [{ id: 'lead', projectId: 'p' }, { id: 'chat', projectId: 'p', kind: 'buddy' }] } } }+ if (payload.action === 'proposalTarget') return { ok: true, value: proposalTarget({ projects: [{ id: 'p', leadConversationId: 'lead' }],+ conversations: [{ id: 'lead', projectId: 'p' }, { id: 'chat', projectId: 'p', kind: 'buddy' }] }, payload.conversationId) }if (payload.step === 'sent') return { ok: true, value: { agentId: 'buddy', attachmentIds: null } }return { ok: true, value: { revision: 9, result: { messageId: 'm' } } }})@@ -393,7 +462,7 @@ it('attaches to a proposal only files inside the Buddy\'s own folder, uploaded trequest.mockImplementation(async (type: string, payload: Record<string, unknown> = {}) => {if (type === 'agents_list') return { agents: frames }calls.push(payload)- if (payload.action === 'status') return { ok: true, value: { state: { projects: [{ id: 'p', leadConversationId: 'lead' }], conversations: [{ id: 'chat', projectId: 'p' }] } } }+ if (payload.action === 'proposalTarget') return { ok: true, value: proposalTarget({ projects: [{ id: 'p', leadConversationId: 'lead' }], conversations: [{ id: 'chat', projectId: 'p' }] }, payload.conversationId) }if (payload.step === 'sent') return { ok: true, value: { agentId: 'buddy', attachmentIds: ['owner-log', 'f1', 'f2'] } }return { ok: true, value: { revision: 9, result: { messageId: 'm' } } }})@@ -422,8 +491,8 @@ it('sends a one Buddy\'s proposal file only from the named project\'s folder, anconst request = vi.fn(async (type: string, payload: Record<string, unknown> = {}): Promise<Record<string, unknown>> => {if (type === 'agents_list') return { agents: frames }if (payload.step === 'sent') { seen.push(String(payload.conversationId)); return { ok: true, value: { agentId: 'buddy', attachmentIds: null } } }- if (payload.action === 'status') return { ok: true, value: { state: { agents: [agent], conversations: [{ id: 'chat', kind: 'swarm-buddy' }],- projects: [{ id: 'p-web', leadConversationId: 'web-chat' }, { id: 'p-secret', leadConversationId: 'secret-chat' }, { id: 'p-away', leadConversationId: 'away-chat' }] } } }+ if (payload.action === 'proposalTarget') return { ok: true, value: proposalTarget({ agents: [agent], conversations: [{ id: 'chat', kind: 'swarm-buddy' }],+ projects: [{ id: 'p-web', leadConversationId: 'web-chat' }, { id: 'p-secret', leadConversationId: 'secret-chat' }, { id: 'p-away', leadConversationId: 'away-chat' }] }, payload.conversationId) }return { ok: true, value: { revision: 9, result: { messageId: 'm' } } }})const sent: string[] = []@@ -470,7 +539,7 @@ it('sends a proposal file\'s bytes as they were when checked, even if the path tconst frames = [{ id: 'buddy-harness', engine: 'claude', status: 'active', tmuxPane: '%7', project: { cwd: folder } }]const request = vi.fn(async (type: string, payload: Record<string, unknown> = {}): Promise<Record<string, unknown>> => {if (type === 'agents_list') return { agents: frames }- if (payload.action === 'status') return { ok: true, value: { state: { projects: [{ id: 'p', leadConversationId: 'lead' }], conversations: [{ id: 'chat', projectId: 'p' }] } } }+ if (payload.action === 'proposalTarget') return { ok: true, value: proposalTarget({ projects: [{ id: 'p', leadConversationId: 'lead' }], conversations: [{ id: 'chat', projectId: 'p' }] }, payload.conversationId) }if (payload.step === 'sent') {// After the check, before the upload: the checked name now points outside.unlinkSync(join(folder, 'plan.md'))diff --git a/cli/src/superTabs/command.ts b/cli/src/superTabs/command.tsindex 44db7e354..3421aa39c 100644--- a/cli/src/superTabs/command.ts+++ b/cli/src/superTabs/command.ts@@ -489,15 +489,20 @@ async function proposalFiles(paths: string[], operationId: string, command: Recoconst caller = callerOf(frames, deps.pane, String(daemon.machineId))const folder = frames.find(f => f.id === caller?.agentId)?.project?.cwdif (!folder) throw new Error('Attach files to a proposal from your Buddy\'s own terminal.')- const state = object(object((await scoped({ action: 'status' })).value).state)- const chat = (Array.isArray(state.conversations) ? state.conversations : []).map(object).find(c => c.id === target.conversationId)+ // Read for the upload (service.ts proposalTarget): a Buddy's status is a task summary with no chats, so reading it here refused+ // every Buddy proposal with a file (Huy 11-06, #3872).+ const read = object((await scoped({ action: 'proposalTarget', conversationId: target.conversationId })).value)+ const projects = Array.isArray(read.projects) ? read.projects.map(object) : []+ const chat = read.chat && object(read.chat).id === target.conversationId ? object(read.chat) : undefined// A person's one Buddy chat has no project (Dee, 10-31): a project session proposes into its own project, and the Swarm-wide// Buddy into the one its JSON names (Scholes, 11-02), with only that project's files: its folder holds every project's.- const self = (Array.isArray(state.agents) ? state.agents : []).map(object).find(a => a.id === caller?.agentId)+ // The read answers for the asking agent alone: its record is the caller's, under its Swarm id, not the terminal's id the pane+ // names (Linuxtest4 on #3402: matched by that id, a session's project was never read, and another project's PM got its file).+ const self = read.self ? object(read.self) : undefinedconst session = object(self?.buddySession).projectIdconst wide = chat?.kind === 'swarm-buddy' && typeof session !== 'string'const projectId = wide ? command.projectId : chat?.kind === 'swarm-buddy' ? session : chat?.projectId- const home = (Array.isArray(state.projects) ? state.projects : []).map(object).find(p => p.id === projectId)?.leadConversationId+ const home = projects.find(p => p.id === projectId)?.leadConversationId// Refused here too, before any upload: the backend would refuse it and leave the file behind.if (!wide && command.projectId && command.projectId !== projectId) throw new Error('A session sends only to its own project\'s PM: leave the project out.')if (typeof home !== 'string') throw new Error(wide ? 'Name the project to send this to, from your status.' : 'Name your own chat: a proposal comes from there.')diff --git a/cli/src/superTabs/service.spec.ts b/cli/src/superTabs/service.spec.tsindex 5dd9fd3ad..01d0662ae 100644--- a/cli/src/superTabs/service.spec.ts+++ b/cli/src/superTabs/service.spec.ts@@ -1633,6 +1633,19 @@ describe('a Buddy\'s status', () => {expect(t.call).toHaveBeenCalledWith('GET', `/api/super-tabs/tab/decisions?state=open&asAgentId=${t.agentId}`, undefined)})+ // Huy 11-06 (#3872): a proposal's files are uploaded to the Buddy's chat for its project's PM, which the summary never names.+ // This read answers just that: the chat it names when this Buddy reads it, its own record, and each project's chat.+ it('answers a proposal\'s files with its chat, its own record and the projects\' chats, and nothing else of the Swarm', async () => {+ const t = buddySetup()+ const value = object(object(await t.ask({ action: 'proposalTarget', tabId: 'tab', agentId: t.agentId, conversationId: 'app-chat' }, owner)).value)+ expect(value).toEqual({ chat: { id: 'app-chat', projectId: 'app' }, self: { id: t.agentId, projectId: 'app' },+ projects: [{ id: 'app', leadConversationId: 'app-chat' }] })+ expect(JSON.stringify(value)).not.toContain('Offline sync')+ // A chat it does not read is none.+ expect(object(object(await t.ask({ action: 'proposalTarget', tabId: 'tab', agentId: t.agentId, conversationId: 'elsewhere' }, owner)).value).chat).toBeNull()+ expect(await t.ask({ action: 'proposalTarget', tabId: 'tab', agentId: t.agentId, conversationId: 'not an id' }, owner)).toMatchObject({ error: 'INVALID_REQUEST' })+ })+it('reads its archived tasks a page at a time, in its own project only', async () => {const t = buddySetup()expect(await t.ask({ action: 'status', tabId: 'tab', agentId: t.agentId, archived: true, before: 'page-2' }, owner)).toMatchObject({ ok: true, value: { summary: { tasks: [], next: null } } })diff --git a/cli/src/superTabs/service.ts b/cli/src/superTabs/service.tsindex 2d0ab7177..898f8541a 100644--- a/cli/src/superTabs/service.ts+++ b/cli/src/superTabs/service.ts@@ -660,6 +660,21 @@ export function superTabService(core: CoreApi, options: SuperTabServiceOptions =for (const oldest of buddySince.keys()) { if (buddySince.size <= 64) break; buddySince.delete(oldest) }return { ok: true, value: { lastChangedAt: read.lastChangedAt, summary } }}+ // A proposal's files (command.ts proposalFiles, #3872): the chat they go up to and the project PM's chat it names. A Buddy's+ // status is a task summary with none of them, so every Buddy proposal with a file was refused. Only what the upload reads,+ // from this agent's own read: the chat when it reads that chat, its own record, and each project's id and chat.+ if (payload.action === 'proposalTarget') {+ if (!identifier(payload.conversationId)) return { error: 'INVALID_REQUEST' }+ const { state } = await swarm()+ const chat = list(state.conversations).find(c => c.id === payload.conversationId)+ const self = list(state.agents).find(a => a.id === agentId)+ const session = object(self?.buddySession).projectId+ return { ok: true, value: {+ chat: chat ? { id: chat.id, ...typeof chat.kind === 'string' ? { kind: chat.kind } : {}, ...typeof chat.projectId === 'string' ? { projectId: chat.projectId } : {} } : null,+ self: self ? { id: self.id, ...typeof self.projectId === 'string' ? { projectId: self.projectId } : {}, ...typeof session === 'string' ? { buddySession: { projectId: session } } : {} } : null,+ projects: list(state.projects).map(p => ({ id: p.id, leadConversationId: p.leadConversationId })),+ } }+ }// A Lead's terminal read or typing (`screen`, `type`): the backend answers only the agent that asked.if (payload.action === 'terminalResult') {if (!identifier(payload.terminalRequestId)) return { error: 'INVALID_REQUEST' }