Skip to content

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.

test(cli): cover the Pro voice → Swarm chat request in the core gate (#1656)

0xdiego250eecdef7ff1f
diff --git a/cli/src/core/devicesLink.spec.ts b/cli/src/core/devicesLink.spec.ts
index 06db49cfa..6627ba1e8 100644
--- a/cli/src/core/devicesLink.spec.ts
+++ b/cli/src/core/devicesLink.spec.ts
@@ -231,6 +231,7 @@ describe('the devices\' Swarm card requests to the Super Tab service', () => {
expect(await devices.answer('super_tabs', { action: 'cardsWanted', on: 'yes' })).toMatchObject({ echoed: { action: 'cardsWanted', on: false } })
expect(await devices.answer('super_tabs', { action: 'cardRecap', tabId: 't1', leadId: 'l1', extra: 1 })).toMatchObject({ echoed: { action: 'cardRecap', tabId: 't1', leadId: 'l1' } })
expect(await devices.answer('super_tabs', { action: 'cardOpen', session: 'c1', tabId: 't1', leadId: null })).toMatchObject({ echoed: { action: 'cardOpen', session: 'c1', tabId: 't1', leadId: null } })
+ expect((await devices.answer('super_tabs', { action: 'cardSay', harnessId: 'h1', text: 'ship it', tabId: 't1' })).echoed).toEqual({ action: 'cardSay', harnessId: 'h1', text: 'ship it' })
// A core with no way to the service says so.
const bare = createDevicesLink({ core: fakeCore(), notify: () => true, call: vi.fn(), state: () => STATE })
expect(await bare.answer('super_tabs', { action: 'cardsWanted', on: true })).toEqual({ error: 'SERVICE_UNAVAILABLE' })
diff --git a/cli/src/core/superTabCards.spec.ts b/cli/src/core/superTabCards.spec.ts
index 306796602..9afad1bb5 100644
--- a/cli/src/core/superTabCards.spec.ts
+++ b/cli/src/core/superTabCards.spec.ts
@@ -152,7 +152,9 @@ describe('whether the Swarm cards are wanted, which the core owns', () => {
request.mockClear()
await cards.ask({ action: 'cardRecap', tabId: 't1', leadId: 'l1', extra: 1 })
await cards.ask({ action: 'cardOpen', session: 's1', tabId: 't1', leadId: null, extra: 1 })
- expect(request.mock.calls).toEqual([[{ action: 'cardRecap', tabId: 't1', leadId: 'l1' }], [{ action: 'cardOpen', session: 's1', tabId: 't1', leadId: null }]])
+ await cards.ask({ action: 'cardSay', harnessId: 'h1', text: 'ship it', extra: 1 })
+ expect(request.mock.calls).toEqual([[{ action: 'cardRecap', tabId: 't1', leadId: 'l1' }], [{ action: 'cardOpen', session: 's1', tabId: 't1', leadId: null }],
+ [{ action: 'cardSay', harnessId: 'h1', text: 'ship it' }]])
request.mockClear()
for (const action of ['backend', 'command', 'wake', 'prepareContribution', undefined]) expect(await cards.ask({ action, path: '/api/super-tabs' })).toEqual({ error: 'INVALID_REQUEST' })
expect(request).not.toHaveBeenCalled()
diff --git a/cli/src/services/devices.spec.ts b/cli/src/services/devices.spec.ts
index b66770d29..42ed02b26 100644
--- a/cli/src/services/devices.spec.ts
+++ b/cli/src/services/devices.spec.ts
@@ -627,6 +627,15 @@ describe('what the windows say, reaching the dial', () => {
for (let i = 0; i < 6; i++) expect(await seen.host.swarmCardRecap!('st1', 'lead1')).toBeNull()
})
+ it('posts words for a Lead through the service; anything but said: true sends the turn instead', async () => {
+ const answers: Array<Record<string, unknown> | 'throw'> = [{ ok: true, said: true }, { ok: true, said: false }, { error: 'NOT_FOUND' }, 'throw']
+ const superTabRequest = vi.fn(async () => { const next = answers.shift()!; if (next === 'throw') throw new Error('gone'); return next })
+ withRequest(superTabRequest)
+ expect(await seen.host.swarmSay!('h1', 'ship it')).toBe(true)
+ expect(superTabRequest).toHaveBeenCalledWith({ action: 'cardSay', harnessId: 'h1', text: 'ship it' })
+ for (let i = 0; i < 3; i++) expect(await seen.host.swarmSay!('h1', 'ship it')).toBe(false)
+ })
+
it('answers no recap when the core has no service to ask', async () => {
start()
expect(await seen.host.swarmCardRecap!('st1', 'lead1')).toBeNull()