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): align e2e assertions with intended agent changes (#1613)

0xken15b2ac191ea4f9
diff --git a/cli/e2e/agentClient.e2e.ts b/cli/e2e/agentClient.e2e.ts
index 98a7aeb0e..e0e728220 100644
--- a/cli/e2e/agentClient.e2e.ts
+++ b/cli/e2e/agentClient.e2e.ts
@@ -412,7 +412,7 @@ describe('Harness for agents, end to end', () => {
expect(hello.result.instructions).toContain('Never give work to, or close, a harness you did not start')
server.notify('notifications/initialized')
const tools = (await server.request('tools/list')).result.tools.map((t: { name: string }) => t.name)
- expect(tools).toEqual(['harness_whoami', 'harness_list', 'harness_start', 'harness_wait', 'harness_read', 'harness_close'])
+ expect(tools).toEqual(['harness_whoami', 'harness_list', 'harness_search', 'harness_machines', 'harness_start', 'harness_wait', 'harness_read', 'harness_close'])
// An empty folder of its own: refused, with the project it can ask for instead.
const scratch = join(d.root, 'tmp', 'mcp-scratch')
@@ -460,7 +460,7 @@ describe('Harness for agents, end to end', () => {
await d.start()
await until('Harness to allow its commands in Claude Code and Codex', () => existsSync(rules)
&& readFileSync(settings, 'utf8').includes('mcp__plugin_harness_harness__harness_send'), 30_000)
- const tools = { whoami: 'harness_whoami', ps: 'harness_list', show: 'harness_read', wait: 'harness_wait', new: 'harness_start', close: 'harness_close', send: 'harness_send' }
+ const tools = { whoami: 'harness_whoami', ps: 'harness_list', search: 'harness_search', machines: 'harness_machines', show: 'harness_read', wait: 'harness_wait', new: 'harness_start', close: 'harness_close', send: 'harness_send' }
const verbs = Object.keys(tools) as Array<keyof typeof tools>, launcher = join(d.env.HOME!, '.local', 'bin', 'harness')
// The person's deny of `harness close` is theirs: no allow for it in either spelling (Claude Code does not count the
// launcher's path as the same command). Its MCP tool is another tool, and is allowed by name. `harness --help`,
diff --git a/cli/e2e/eagerRepair.e2e.ts b/cli/e2e/eagerRepair.e2e.ts
index 388edaf8c..d044b765b 100644
--- a/cli/e2e/eagerRepair.e2e.ts
+++ b/cli/e2e/eagerRepair.e2e.ts
@@ -41,7 +41,7 @@ it.each(['missing', 'stalled'] as const)('discovers Muse and closes/resumes Pi w
writeFileSync(path, `#!${process.execPath}
const fs = require('node:fs'), path = require('node:path');
if (process.argv.includes('--version') || process.argv.includes('--help')) { console.log('1.0.0'); process.exit(0) }
-const id = process.argv.includes('--session') ? process.argv[process.argv.indexOf('--session') + 1] : (${JSON.stringify(piIds)})[path.basename(process.cwd())];
+const id = process.argv.includes('--session-id') ? process.argv[process.argv.indexOf('--session-id') + 1] : (${JSON.stringify(piIds)})[path.basename(process.cwd())];
process.title = (${JSON.stringify(engine)} === 'pi' ? 'pi --session-id ' + id : 'muse').padEnd(160);
fs.appendFileSync(${JSON.stringify(join(d.root, `${engine}-launches.jsonl`))}, JSON.stringify({ id, args: process.argv.slice(2) }) + '\\n');
${engine === 'muse' ? `const folder = path.join(process.env.MUSE_HOME, 'sessions', '2026', '10', '09', '${museId}');
@@ -98,7 +98,7 @@ console.log('fixture-${engine}-ready'); setInterval(() => {}, 1000);
await until('Pi resumes its exact preallocated conversation', async () =>
(await rows()).find(row => row.id === pi.id)?.status === 'active' || null, 30_000, 100)
await until('the private Pi process received the saved resume ID', () => readFileSync(join(d.root, 'pi-launches.jsonl'), 'utf8')
- .split('\n').filter(Boolean).map(line => JSON.parse(line)).some(row => row.id === id && row.args.includes('--session')) || null, 15_000, 100)
+ .split('\n').filter(Boolean).map(line => JSON.parse(line)).some(row => row.id === id && row.args.includes('--session-id')) || null, 15_000, 100)
}
expect((await fetch(`http://127.0.0.1:${d.port}/api/health`)).ok).toBe(true)
expect(d.coresStarted()).toBe(1)
diff --git a/cli/e2e/superTabRoute.e2e.ts b/cli/e2e/superTabRoute.e2e.ts
index 94fabbac4..ba8683522 100644
--- a/cli/e2e/superTabRoute.e2e.ts
+++ b/cli/e2e/superTabRoute.e2e.ts
@@ -1,5 +1,5 @@
/** `harness super-tab route` on the real native protocol: a private daemon, tmux and data dir, fake Claude
- * engines and the fake backend (its hosted Jev included). Database authorization is covered by the backend's tests. */
+ * engines and the fake backend (with Jev available to verify routing bypasses it). Database authorization is covered by the backend's tests. */
import { createHash } from 'node:crypto'
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
import { tmpdir } from 'node:os'
@@ -7,7 +7,7 @@ import { join } from 'node:path'
import { afterEach, expect, it, onTestFailed } from 'vitest'
import { superTabCommand } from '../src/superTabs/command.js'
import { LocalClient } from './harness/client.js'
-import { IsolatedDaemon } from './harness/daemon.js'
+import { IsolatedDaemon, until } from './harness/daemon.js'
import { FakeBackend, type FakeMachine } from './harness/fakeBackend.js'
const ME: FakeMachine = { machineId: 'c9'.repeat(16), computerId: 'e2e-super-tab-route-computer', name: 'Fixture', token: 'e2e-super-tab-route-token' }
@@ -28,10 +28,8 @@ afterEach(async () => {
async function setup(hostedJev: FakeBackend['jev'], options: { workerBusy?: boolean } = {}) {
const relay = await FakeBackend.start(); backend = relay; relay.addMachine(ME); relay.jev = hostedJev
- // The daemon asks Jev on an OpenRouter key when it finds one (jevClient resolveJevKey): the environment's
- // variable, ORI_CREDENTIALS_PATH or TYPESAFE_CREDENTIALS. This run must reach the fake backend and never
- // OpenRouter, so the variable is emptied and both files point at a folder that holds nothing. The
- // default locations are under the isolated HOME.
+ // A regression to Jev should reach the fake backend, never OpenRouter: empty the environment's key and
+ // point both credential locations at an empty folder. Defaults are under the isolated HOME.
nowhere = mkdtempSync(join(tmpdir(), 'route-e2e-no-key-'))
const d = await IsolatedDaemon.create({ submissionGate: true, env: {
BACKEND_WS_URL: relay.wsUrl, WEB_URL: relay.httpUrl, ADAPTER_COMPUTER_ID: ME.computerId,
@@ -105,10 +103,16 @@ async function setup(hostedJev: FakeBackend['jev'], options: { workerBusy?: bool
{ where: () => where, print: text => { answer = JSON.parse(text) } })
return { code, answer }
}
- return { route, start, records, commands, relay, client, cwd }
+ async function resume(startId: string) {
+ let answer: Record<string, any> = {}
+ const code = await superTabCommand(['--tab', TAB, '--agent', leadId, 'resume', startId],
+ { where: () => where, print: text => { answer = JSON.parse(text) } })
+ return { code, answer }
+ }
+ return { route, start, resume, records, commands, relay, client, cwd, leadHarness, workerHarness }
}
-it('routes to Jev’s pick and records the decision', async () => {
+it('routes by policy even when Jev is available and records the decision', async () => {
const asked: Array<Record<string, any>> = []
const { route, records } = await setup(body => {
asked.push(body)
@@ -117,10 +121,10 @@ it('routes to Jev’s pick and records the decision', async () => {
})
const { code, answer } = await route()
expect(code, JSON.stringify(answer)).toBe(0)
- expect(answer).toMatchObject({ ok: true, routeDecisionId: 'd-1', via: 'jev', pick: { id: 'c1' } })
- expect(asked).toHaveLength(1)
+ expect(answer).toMatchObject({ ok: true, routeDecisionId: 'd-1', via: 'order', pick: { id: 'c0' } })
+ expect(asked).toHaveLength(0)
expect(records).toHaveLength(1)
- expect(records[0].command.decision).toMatchObject({ via: 'jev', pick: 'c1' })
+ expect(records[0].command.decision).toMatchObject({ via: 'order', pick: 'c0' })
// The idle worker is a candidate; the Lead never is.
const titles = (records[0].command.decision.candidates as Array<{ title: string }>).map(c => c.title)
expect(titles.some(t => t.startsWith('Multiply ·'))).toBe(true)
@@ -130,17 +134,17 @@ it('routes to Jev’s pick and records the decision', async () => {
expect(titles.every(t => t.endsWith(` · ${ME.name}`))).toBe(true)
}, 180_000)
-it('falls back to the policy order when Jev is unavailable', async () => {
+it('uses the policy order when Jev is unavailable', async () => {
const { route, records, relay } = await setup(null)
const { code, answer } = await route()
expect(code, JSON.stringify(answer)).toBe(0)
- expect(relay.seen.some(line => line.startsWith('POST /api/route/jev'))).toBe(true)
+ expect(relay.seen.some(line => line.startsWith('POST /api/route/jev'))).toBe(false)
expect(answer).toMatchObject({ ok: true, routeDecisionId: 'd-1', via: 'order', pick: { id: 'c0' } })
expect(records[0].command.decision).toMatchObject({ via: 'order', pick: 'c0' })
}, 180_000)
it('starts the routed pick as a new agent with its decision, model and effort', async () => {
- const { route, start, commands, client, cwd } = await setup(null, { workerBusy: true })
+ const { route, start, resume, commands, client, cwd, leadHarness, workerHarness } = await setup(null, { workerBusy: true })
const routed = await route()
expect(routed.code, JSON.stringify(routed.answer)).toBe(0)
const pick = routed.answer.pick
@@ -148,9 +152,19 @@ it('starts the routed pick as a new agent with its decision, model and effort',
const request = { conversationId: 'g1', machineId: pick.machineId, engine: pick.engine, model: pick.model, effort: pick.effort, name: 'Builder',
cwd, worktree: false, permissionMode: 'auto', requirements: { memoryBytes: 0, diskBytes: 1, maxCpuPercent: 100, tools: [], devices: [], quotaRequired: false },
routeDecisionId: routed.answer.routeDecisionId }
- const started = await start('route-start', request)
+ let started = await start('route-start', request)
+ if (started.answer.error === 'START_PENDING') {
+ expect(started.answer).toMatchObject({ startId: 'start-route-start', creationId: 'super-start-route-start' })
+ await until('routed Claude Code session to bind', async () => {
+ const listed = await client.request('agents_list', {}, 30_000)
+ return (listed.agents as Array<{ id: string; sessionId?: string }>).some(a =>
+ a.id !== leadHarness && a.id !== workerHarness && !!a.sessionId) || null
+ }, 60_000, 250)
+ started = await resume(started.answer.startId)
+ }
expect(started.code, JSON.stringify(started.answer)).toBe(0)
expect(started.answer.harnessId).toBeTruthy()
+ expect(commands.filter(c => c.command.type === 'agent.start')).toHaveLength(1)
const command = commands.find(c => c.command.type === 'agent.start')!.command
// The decision rides on the command, never inside the machine-side request.
expect(command.routeDecisionId).toBe('d-1')
diff --git a/cli/e2e/windows.e2e.ts b/cli/e2e/windows.e2e.ts
index bc602fb1a..491d00d70 100644
--- a/cli/e2e/windows.e2e.ts
+++ b/cli/e2e/windows.e2e.ts
@@ -290,9 +290,8 @@ describe('many windows at once', () => {
// The stop was a stop, and every answer is the one its question asks for. A close asked for while
// another window's inspect of the same agent was still running was answered with that inspect's
- // `{ activity }` and the agent left running (measured: still active 10 s later), and an inspect that
- // ran beside a close came back as the close's `{ closed: true }`: the close service answered any
- // request for an agent with whatever job was running for it.
+ // `{ activity }` and the agent left running (measured: still active 10 s later). An inspect
+ // beside a close now receives `{ closed: true }` when the close wins (#1454).
expect(stopped, `${how} answered ${JSON.stringify(stopped)} while other windows asked about the agent`)
.toMatchObject(how === 'agent_close' ? { closed: true } : { deleted: true })
const shaped: Record<string, (answer: Row) => boolean> = {
@@ -300,7 +299,7 @@ describe('many windows at once', () => {
sessions_list: (answer) => Array.isArray(answer.sessions),
agents_list: (answer) => Array.isArray(answer.agents),
agent_update: (answer) => answer.agent?.id === agent.id,
- 'agent_close inspect': (answer) => typeof answer.activity === 'string',
+ 'agent_close inspect': (answer) => typeof answer.activity === 'string' || answer.closed === true,
terminal_info: (answer) => typeof answer.path === 'string',
}
const misshapen = answers.filter(({ type, answer }) => typeof answer.error !== 'string' && !shaped[type](answer))