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.

Add isolated physical-machine viewer test peers

Dee47f85d529d46
diff --git a/cli/scripts/remote-viewer-live.ts b/cli/scripts/remote-viewer-live.ts
new file mode 100644
index 000000000..8052398a2
--- /dev/null
+++ b/cli/scripts/remote-viewer-live.ts
@@ -0,0 +1,153 @@
+/** Real-host client. `init <dir>` prints a disposable public key; `run <dir> <peer-info.json>` tests it. */
+import assert from 'node:assert/strict'
+import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'
+import { dirname, join, resolve } from 'node:path'
+import { fileURLToPath } from 'node:url'
+import { hostname, arch } from 'node:os'
+import { createRequire } from 'node:module'
+import { createHash, randomUUID } from 'node:crypto'
+
+if (process.env.HARNESS_VIEWER_LIVE_TEST !== '1') throw new Error('Opt in with HARNESS_VIEWER_LIVE_TEST=1')
+const root = resolve(process.argv[3] || 'viewer-client')
+process.env.ADAPTER_DATA_DIR = join(root, 'data')
+process.env.ADAPTER_RUNTIME_DIR = join(root, 'runtime')
+process.env.DSH_DIR = join(root, 'dsh')
+const { E2eeStore } = await import('../src/lib/e2ee/store.js')
+const { b64e } = await import('../src/lib/e2ee/core.js')
+const identity = new E2eeStore().init()
+if (process.argv[2] === 'init') {
+ console.log(b64e(identity.pub))
+ process.exit(0)
+}
+assert.equal(process.argv[2], 'run')
+const peer = JSON.parse(readFileSync(process.argv[4]!, 'utf8'))
+const { MachinePeerStore } = await import('../src/lib/e2ee/machinePeers.js')
+const { RemoteRelayPool } = await import('../src/lib/remoteRelay.js')
+const { AuthSessionManager, readAuthSession } = await import('../src/lib/authSession.js')
+const { decodeTerminalLocal, TerminalBinaryKind } = await import('../src/lib/terminalBinary.js')
+const peers = new MachinePeerStore()
+peers.pin(peer.machineId, peer.pub, 'Disposable physical viewer test')
+const auth = new AuthSessionManager(peer.base)
+const pool = new RemoteRelayPool(auth, peer.base.replace(/^http/, 'ws'), identity, peers)
+const frames: any[] = []
+const checks: string[] = []
+const checkpoint = (s: string) => { checks.push(s); console.log(`PASS ${s}`) }
+async function until(label: string, fn: () => unknown | Promise<unknown>, ms = 60_000) {
+ const deadline = Date.now() + ms
+ while (!await fn()) {
+ if (Date.now() > deadline) throw new Error(`Timed out: ${label}`)
+ await new Promise(resolve => setTimeout(resolve, 100))
+ }
+}
+let terminalText = ''
+let link = await pool.acquire(peer.machineId, readAuthSession()!.autonomousEnv,
+ { type: 'machine_select', payload: { machineId: peer.machineId, localProtocolVersion: 1 } }, {
+ sendFrame: f => { frames.push(f); return true },
+ sendBinary: bytes => {
+ const f = decodeTerminalLocal(bytes)
+ if (f) { terminalText += Buffer.from(f.bytes).toString(); void link?.send({ type: 'terminal_ack', payload: { streamId: f.streamId, seq: f.seq } }) }
+ return true
+ },
+ }, (code, reason) => console.log(`Relay closed ${code}: ${reason}`))
+async function rpc(type: string, payload: object = {}) {
+ const requestId = randomUUID()
+ await link.send({ type, payload: { ...payload, requestId } })
+ await until(type, () => frames.some(f => f.payload?.requestId === requestId))
+ const result = frames.find(f => f.payload?.requestId === requestId).payload
+ assert.ok(!result.error && !result.code, `${type}: ${JSON.stringify(result)}`)
+ return result
+}
+async function viewerUrl(id: string) {
+ let url: string | undefined
+ await until('forwarded viewer URL', async () => {
+ const agent = (await rpc('agents_list')).agents.find((a: any) => a.id === id)
+ assert.ok(!agent?.viewerError, agent?.viewerError)
+ url = agent?.viewerUrl
+ return url
+ })
+ assert.ok(url!.includes('/__harness_viewer/'))
+ return url!
+}
+const repo = resolve(dirname(fileURLToPath(import.meta.url)), '../..')
+const { chromium } = createRequire(join(repo, 'store/agents/godogen/package.json'))('playwright')
+const browser = await chromium.launch({ headless: true,
+ executablePath: process.env.HARNESS_VIEWER_BROWSER || '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
+ args: ['--enable-unsafe-swiftshader'],
+})
+const context = await browser.newContext({ viewport: { width: 1100, height: 800 } })
+const agents: string[] = []
+let complete = false
+try {
+ for (const [name, workspace] of Object.entries(peer.workspaces) as Array<[string, any]>) {
+ const created = await rpc('agent_create', { creationId: randomUUID(), engine: workspace.engine, cwd: workspace.path, dsh: `autonomous/${name}` })
+ assert.ok(created.agent?.id)
+ const id = created.agent.id
+ agents.push(id)
+ const url = await viewerUrl(id)
+ const page = await context.newPage()
+ const errors: string[] = []
+ page.on('pageerror', (e: Error) => errors.push(e.message))
+ const response = await page.goto(url)
+ assert.equal(response.status(), 200)
+ if (name === 'blender') {
+ await page.waitForFunction(() => document.querySelector('#model-name')?.textContent === 'triangle.gltf' && !!document.querySelector('#tree .row'))
+ const terminal = await rpc('terminal_open', { protocolVersion: 3, agentId: id, cols: 100, rows: 30, compression: [] })
+ const heartbeat = setInterval(() => { void link.send({ type: 'terminal_alive', payload: { streamId: terminal.streamId } }) }, 5000)
+ try {
+ const download = page.request.get(new URL('/ws/out/large.bin', page.url()).href, { timeout: 120_000 })
+ await link.sendBinary({ kind: TerminalBinaryKind.input, streamId: terminal.streamId, seq: 0, compressed: false,
+ bytes: Buffer.from('remote-viewer-concurrent-terminal\r') })
+ await until('concurrent terminal input echoed', () => terminalText.includes('ECHO:remote-viewer-concurrent-terminal'))
+ const result = await download
+ assert.equal(result.status(), 200)
+ assert.equal(createHash('sha256').update(await result.body()).digest('hex'), createHash('sha256').update(Buffer.alloc(12 * 1024 * 1024 + 17, 0x5a)).digest('hex'))
+ const range = await page.request.get(new URL('/ws/out/large.bin', page.url()).href, { headers: { Range: 'bytes=17-1048592' } })
+ assert.equal(range.status(), 206)
+ assert.equal((await range.body()).length, 1048576)
+ } finally {
+ clearInterval(heartbeat)
+ await link.send({ type: 'terminal_close', payload: { streamId: terminal.streamId } })
+ }
+ checkpoint('12 MiB hashed download, Range response and simultaneous real remote terminal echo')
+ } else if (name === 'marp') {
+ await page.waitForFunction(() => document.querySelectorAll('#stage svg').length > 0)
+ const before = await page.locator('#counter').innerText()
+ await page.locator('#next').click()
+ assert.notEqual(await page.locator('#counter').innerText(), before)
+ await rpc('agent_restart', { agentId: id })
+ const restarted = await viewerUrl(id)
+ assert.notEqual(restarted, url)
+ await assert.rejects(fetch(url))
+ await page.goto(restarted)
+ await page.waitForFunction(() => document.querySelectorAll('#stage svg').length > 0)
+ checkpoint('remote Marp navigation and real agent restart; old local gateway refuses access')
+ } else if (name === 'manim') {
+ await page.waitForFunction(() => (document.querySelector('#video') as HTMLVideoElement)?.readyState >= 2)
+ await page.evaluate(() => { const v = document.querySelector('#video') as HTMLVideoElement; v.currentTime = 1.5; return v.play() })
+ await page.waitForFunction(() => (document.querySelector('#video') as HTMLVideoElement)?.currentTime > 1.6)
+ } else if (name === 'godogen') {
+ await page.waitForFunction(() => document.querySelector('#frames iframe.active') && !(document.querySelector('#play') as HTMLButtonElement)?.disabled, null, { timeout: 90_000 })
+ await page.locator('#play').click()
+ await page.waitForTimeout(500)
+ await page.keyboard.down('KeyD'); await page.waitForTimeout(500); await page.keyboard.up('KeyD')
+ const src = await page.locator('#frames iframe.active').getAttribute('src')
+ const frame = page.frames().find((f: any) => f.url() === new URL(src, page.url()).href)
+ assert.ok(await frame.evaluate(() => (window as any).harnessGame.stats().positionX > 0))
+ }
+ assert.deepEqual(errors, [])
+ await page.screenshot({ path: join(root, `${name}-${peer.host}.png`) })
+ checkpoint(`${name} browser viewer on ${peer.host} (${peer.arch}) → ${hostname()} (${arch()}) through ${peer.base}`)
+ }
+ complete = true
+} finally {
+ if (!complete) for (const [i, page] of context.pages().entries()) {
+ await page.screenshot({ path: join(root, `failure-${i}.png`), timeout: 5000 }).catch(() => {})
+ writeFileSync(join(root, `failure-${i}.html`), await page.content().catch(() => 'unavailable'))
+ }
+ for (const id of agents) { try { await rpc('agent_delete', { agentId: id }) } catch (error) { console.error(`Test agent cleanup failed: ${id}`, error) } }
+ await browser.close()
+ pool.invalidate(peer.machineId)
+ writeFileSync(join(root, 'results.json'), JSON.stringify({ complete, local: { hostname: hostname(), arch: arch() },
+ remote: { hostname: peer.host, arch: peer.arch }, relay: peer.base, checks,
+ limitations: ['fixture model CLI and media', 'temporary identity pins', 'Chrome; native desktop not exercised'] }, null, 2))
+}
diff --git a/cli/scripts/remote-viewer-peer.ts b/cli/scripts/remote-viewer-peer.ts
new file mode 100644
index 000000000..3a472ab67
--- /dev/null
+++ b/cli/scripts/remote-viewer-peer.ts
@@ -0,0 +1,125 @@
+/** Disposable real-machine peer for remote-viewer-live.ts. Requires explicit opt-in. */
+import { readFileSync, writeFileSync, mkdirSync, existsSync, cpSync, createWriteStream, rmSync } from 'node:fs'
+import { homedir, hostname, arch } from 'node:os'
+import { dirname, join, resolve } from 'node:path'
+import { fileURLToPath } from 'node:url'
+import { randomUUID } from 'node:crypto'
+import { createServer } from 'node:net'
+import { spawn, execFileSync } from 'node:child_process'
+import { once } from 'node:events'
+import { newIdentity, b64e } from '../src/lib/e2ee/core.js'
+
+if (process.env.HARNESS_VIEWER_LIVE_TEST !== '1') throw new Error('Opt in with HARNESS_VIEWER_LIVE_TEST=1')
+const clientPub = process.argv[2]
+if (!clientPub || Buffer.from(clientPub, 'base64').length !== 32) throw new Error('Provide the disposable test client public key')
+const root = resolve(process.argv[3] || 'viewer-peer')
+if (existsSync(root)) throw new Error('Use a new peer directory')
+mkdirSync(root, { recursive: true, mode: 0o700 })
+const cli = resolve(dirname(fileURLToPath(import.meta.url)), '..')
+const originalAuth = JSON.parse(readFileSync(join(homedir(), '.harness/auth/session.json'), 'utf8'))
+const status = await fetch('http://127.0.0.1:18473/api/status', { headers: { 'x-adapter-local': '1' } }).then(r => r.json()) as any
+const base = String(status.backendUrl).replace(/^ws/, 'http').replace(/\/$/, '')
+if (!base.startsWith('https://')) throw new Error('Expected the existing authenticated hosted backend')
+const headers = { authorization: `Bearer ${originalAuth.accessToken}`, 'content-type': 'application/json', 'x-autonomous-env': originalAuth.autonomousEnv }
+const computerId = randomUUID()
+const registered = await fetch(`${base}/api/machines/resolve-computer`, { method: 'POST', headers,
+ body: JSON.stringify({ computerId, label: `Viewer QA ${hostname()}` }) })
+const registration = await registered.json() as any
+if (!registered.ok || !registration.data?.machine?.machineId) throw new Error(`Test machine registration failed (${registered.status})`)
+const machineId = registration.data.machine.machineId as string
+writeFileSync(join(root, 'registration.json'), JSON.stringify({ machineId, base, computerId }))
+const identity = newIdentity()
+const socket = join(root, 'tmux.sock')
+let child: ReturnType<typeof spawn> | undefined
+let stopping = false
+async function cleanup() {
+ if (stopping) return
+ stopping = true
+ if (child?.pid && child.exitCode == null && child.signalCode == null) {
+ const exited = once(child, 'exit')
+ try { process.kill(-child.pid, 'SIGTERM') } catch {}
+ const timer = setTimeout(() => { try { process.kill(-child!.pid!, 'SIGKILL') } catch {} }, 8000)
+ await exited
+ clearTimeout(timer)
+ }
+ try { execFileSync('tmux', ['-S', socket, 'kill-server'], { stdio: 'ignore' }) } catch {}
+ const removed = await fetch(`${base}/api/machines/${machineId}`, { method: 'DELETE', headers })
+ console.log(JSON.stringify({ cleanup: true, machineId, deleted: removed.ok, status: removed.status }))
+ rmSync(join(root, 'auth'), { recursive: true, force: true })
+ process.exit(removed.ok ? 0 : 1)
+}
+process.on('SIGTERM', () => { void cleanup() })
+process.on('SIGINT', () => { void cleanup() })
+try {
+ for (const path of ['data/e2e', 'auth', 'runtime', 'dsh', 'claude', 'workspaces']) mkdirSync(join(root, path), { recursive: true })
+ writeFileSync(join(root, 'data/e2e/identity.json'), JSON.stringify({ priv: b64e(identity.priv), pub: b64e(identity.pub) }), { mode: 0o600 })
+ writeFileSync(join(root, 'data/e2e/paired.json'), JSON.stringify([{ identityPub: clientPub, label: 'Disposable viewer QA client', pairedAt: Date.now(), role: 'web' }]), { mode: 0o600 })
+ // No refresh token is copied. The test borrows this already-authorized access token without rotating
+ // the running app's session. Trust keys, computer id, registry and terminal socket are independent.
+ writeFileSync(join(root, 'auth/session.json'), JSON.stringify({ ...originalAuth, refreshToken: undefined,
+ computerId, machineId, updatedAt: Date.now() }), { mode: 0o600 })
+ const installed = JSON.parse(readFileSync(join(homedir(), '.harness/dsh/installed.json'), 'utf8'))
+ writeFileSync(join(root, 'dsh/installed.json'), JSON.stringify(installed))
+ const workspaces: Record<string, { path: string; engine: string }> = {}
+ for (const name of ['blender', 'marp', 'manim', 'godogen']) {
+ const pkg = installed.find((p: any) => p.id === `autonomous/${name}`)
+ if (!pkg) throw new Error(`${name} must already be installed on the selected test machine`)
+ const manifest = JSON.parse(readFileSync(join(pkg.dir, 'harness.json'), 'utf8'))
+ const workspace = join(root, 'workspaces', name)
+ cpSync(join(pkg.dir, manifest.workspace.template), workspace, { recursive: true })
+ mkdirSync(join(workspace, 'out'), { recursive: true })
+ if (name === 'blender') {
+ const data = Buffer.from(new Float32Array([-1, 0, 0, 1, 0, 0, 0, 2, 0]).buffer)
+ writeFileSync(join(workspace, 'out/triangle.gltf'), JSON.stringify({ asset: { version: '2.0' }, scene: 0,
+ scenes: [{ nodes: [0] }], nodes: [{ mesh: 0, name: 'Remote triangle' }], meshes: [{ primitives: [{ attributes: { POSITION: 0 } }] }],
+ buffers: [{ uri: `data:application/octet-stream;base64,${data.toString('base64')}`, byteLength: data.length }],
+ bufferViews: [{ buffer: 0, byteLength: data.length }],
+ accessors: [{ bufferView: 0, componentType: 5126, count: 3, type: 'VEC3', min: [-1, 0, 0], max: [1, 2, 0] }] }))
+ writeFileSync(join(workspace, 'out/large.bin'), Buffer.alloc(12 * 1024 * 1024 + 17, 0x5a))
+ }
+ if (name === 'manim') execFileSync('ffmpeg', ['-y', '-f', 'lavfi', '-i', 'testsrc=size=320x180:rate=15',
+ '-t', '3', '-c:v', 'libx264', '-pix_fmt', 'yuv420p', '-movflags', '+faststart', join(workspace, 'out/sample.mp4')], { stdio: 'ignore' })
+ if (name === 'godogen') {
+ const { symlinkSync } = await import('node:fs')
+ symlinkSync(join(pkg.dir, 'node_modules'), join(workspace, 'node_modules'))
+ }
+ workspaces[name] = { path: workspace, engine: manifest.engine }
+ }
+ const engine = join(root, 'claude-fixture')
+ writeFileSync(engine, `#!${process.execPath}
+if(process.argv.includes('--version')){console.log('2.1.0 (Claude Code)');process.exit(0)}
+process.title='claude';process.stdin.setRawMode?.(true);console.log('VIEWER_REMOTE_READY');
+process.stdin.on('data',c=>process.stdout.write('ECHO:'+c+'\\r\\n'));setInterval(()=>{},1000);
+`, { mode: 0o700 })
+ const probe = createServer().listen(0, '127.0.0.1')
+ await once(probe, 'listening')
+ const port = (probe.address() as { port: number }).port
+ await new Promise<void>(resolve => probe.close(() => resolve()))
+ execFileSync('tmux', ['-S', socket, '-f', '/dev/null', 'new-session', '-d', '-s', 'fixture-keeper'])
+ const env = { ...process.env, TMUX: `${socket},0,0`, PORT: String(port), HARNESS_AUTH_DIR: join(root, 'auth'),
+ ADAPTER_COMPUTER_ID: computerId, ADAPTER_COMPUTER_ID_FILE: join(root, 'computer-id'), ADAPTER_DATA_DIR: join(root, 'data'),
+ ADAPTER_RUNTIME_DIR: join(root, 'runtime'), DSH_DIR: join(root, 'dsh'), CLAUDE_PATH: engine,
+ CLAUDE_CONFIG_DIR: join(root, 'claude'), CLAUDE_PROJECTS_DIR: join(root, 'claude/projects'),
+ BACKEND_WS_URL: status.backendUrl, WEB_URL: status.webUrl, HARNESS_STORE_CATALOG_URL: 'http://127.0.0.1:9/catalog.json',
+ DISABLE_HOOK_INSTALL: 'true', ADAPTER_UPDATE_DISABLE: 'true', ANALYTICS_ENABLED: 'false', RECAP_FORCE: 'false',
+ RECAP_WITHOUT_DEVICE: 'false', CABLE_DISABLE: 'true', CABLE_FW_DISABLE: 'true', TERMINAL_BACKENDS: 'tmux' }
+ child = spawn(process.execPath, ['dist/cli.js', '__run'], { cwd: cli, env, detached: true, stdio: ['ignore', 'pipe', 'pipe'] })
+ const log = createWriteStream(join(root, 'daemon.log'))
+ child.stdout!.pipe(log); child.stderr!.pipe(log)
+ const deadline = Date.now() + 60_000
+ while (true) {
+ const ready = await fetch(`http://127.0.0.1:${port}/api/status`, { headers: { 'x-adapter-local': '1' } })
+ .then(r => r.json()).then((s: any) => s.connected && s.discoveryReady).catch(() => false)
+ if (ready) break
+ if (Date.now() > deadline) throw new Error('Test daemon did not become ready')
+ await new Promise(resolve => setTimeout(resolve, 250))
+ }
+ const info = { machineId, pub: b64e(identity.pub), host: hostname(), arch: arch(), port, root, base, workspaces }
+ writeFileSync(join(root, 'peer-info.json'), JSON.stringify(info, null, 2))
+ console.log(JSON.stringify({ ready: true, ...info }))
+ const expires = Date.now() + 60 * 60_000
+ setInterval(() => { if (existsSync(join(root, 'stop')) || Date.now() > expires) void cleanup() }, 500)
+} catch (error) {
+ console.error(error instanceof Error ? error.message : String(error))
+ await cleanup()
+}
diff --git a/cli/scripts/remote-viewers-stack.ts b/cli/scripts/remote-viewers-stack.ts
index 67d47c698..6c8ffecf4 100644
--- a/cli/scripts/remote-viewers-stack.ts
+++ b/cli/scripts/remote-viewers-stack.ts
@@ -31,6 +31,7 @@ const exec = promisify(execFile)
const root = await mkdtemp(join(tmpdir(), 'harness-viewer-stack-'))
const cleanups: Array<() => unknown | Promise<unknown>> = []
const checks: string[] = []
+let completed = false
const checkpoint = (message: string) => { checks.push(message); console.log(`PASS ${message}`) }
console.log(`Artifacts and logs: ${root}`)
async function until(label: string, check: () => unknown | Promise<unknown>, ms = 45_000) {
@@ -145,7 +146,7 @@ console.log('VIEWER_STACK_READY');
process.stdin.on('data', chunk => process.stdout.write('ECHO:' + chunk.toString() + '\\r\\n'));
setInterval(() => {}, 1000);
`, { mode: 0o700 })
- const harnesses = ['godogen', 'blender', 'marp', 'manim']
+ const harnesses = ['blender', 'marp', 'manim', 'godogen']
const packages = [...harnesses.map(name => `agents/${name}`), ...['game', 'model', 'video'].map(name => `viewers/${name}-viewer`)]
async function machine(name: string, index: number) {
const dir = join(root, name), data = join(dir, 'data'), auth = join(dir, 'auth')
@@ -201,6 +202,12 @@ setInterval(() => {}, 1000);
})
cleanups.push(() => browser.close())
const context = await browser.newContext({ viewport: { width: 1100, height: 800 } })
+ cleanups.push(async () => {
+ if (!completed) for (const [index, page] of context.pages().entries()) {
+ await page.screenshot({ path: join(root, `failure-${index}.png`), timeout: 5000 }).catch(() => {})
+ await writeFile(join(root, `failure-${index}.html`), await page.content().catch(() => 'page unavailable'))
+ }
+ })
const agents = new Map<string, { id: string; workspace: string; page: any; localUrl: string; remoteUrl: string }>()
async function agentUrl(client: Awaited<ReturnType<typeof desktop>>, id: string) {
let url: string | undefined
@@ -225,6 +232,11 @@ setInterval(() => {}, 1000);
accessors: [{ bufferView: 0, componentType: 5126, count: 3, type: 'VEC3', min: [-1, 0, 0], max: [1, 2, 0] }] }))
await writeFile(join(workspace, 'out/large.bin'), Buffer.alloc(12 * 1024 * 1024 + 17, 0x5a))
}
+ if (name === 'manim') {
+ await mkdir(join(workspace, 'out'), { recursive: true })
+ await exec(process.env.HARNESS_E2E_FFMPEG || 'ffmpeg', ['-y', '-f', 'lavfi', '-i', 'testsrc=size=320x180:rate=15',
+ '-t', '3', '-c:v', 'libx264', '-pix_fmt', 'yuv420p', '-movflags', '+faststart', join(workspace, 'out/sample.mp4')], { timeout: 30_000 })
+ }
const created = await remoteDesktop.rpc('agent_create', { engine: 'claude', cwd: workspace,
dsh: `autonomous/${name}`, creationId: randomUUID() })
assert.ok(created.agent?.id, JSON.stringify(created))
@@ -249,7 +261,7 @@ setInterval(() => {}, 1000);
const frame = page.frames().find((f: any) => f.url() === new URL(activeSrc, page.url()).href)
assert.ok(await frame.evaluate(() => (window as any).harnessGame.stats().positionX > 0), 'the active game responds to keyboard input')
} else if (name === 'blender') {
- await page.waitForFunction(() => document.querySelector('#model-name')?.textContent === 'triangle.gltf' && !!document.querySelector('#tree [role="treeitem"]'), null, { timeout: 45_000 })
+ await page.waitForFunction(() => document.querySelector('#model-name')?.textContent === 'triangle.gltf' && !!document.querySelector('#tree .row'), null, { timeout: 45_000 })
const expected = createHash('sha256').update(await import('node:fs/promises').then(fs => fs.readFile(join(workspace, 'out/large.bin')))).digest('hex')
const response = await page.request.get(new URL('/ws/out/large.bin', page.url()).href)
assert.equal(createHash('sha256').update(await response.body()).digest('hex'), expected)
@@ -262,10 +274,14 @@ setInterval(() => {}, 1000);
const deck = join(workspace, 'deck.md')
await writeFile(deck, readFileSync(deck, 'utf8') + '\n---\n\n# Remote edit arrived\n')
await page.waitForFunction(() => document.body.textContent?.includes('Remote edit arrived'))
- await page.locator('#next').click()
+ const counter = await page.locator('#counter').innerText()
+ await page.locator('#prev').click()
+ assert.notEqual(await page.locator('#counter').innerText(), counter)
} else {
- await page.waitForFunction(() => document.readyState === 'complete' && !!document.querySelector('main'))
+ await page.waitForFunction(() => (document.querySelector('#video') as HTMLVideoElement)?.readyState >= 2)
assert.equal((await page.request.get(new URL('/api/library', page.url()).href)).status(), 200)
+ await page.evaluate(() => { const video = document.querySelector('#video') as HTMLVideoElement; video.currentTime = 1.5; return video.play() })
+ await page.waitForFunction(() => (document.querySelector('#video') as HTMLVideoElement)?.currentTime > 1.6)
}
assert.deepEqual(errors, [], `${name} browser exceptions`)
await page.screenshot({ path: join(root, `${name}-forwarded.png`) })
@@ -313,9 +329,10 @@ setInterval(() => {}, 1000);
for (const agent of agents.values()) await directDesktop.rpc('agent_delete', { agentId: agent.id })
assert.equal((await directDesktop.rpc('agents_list')).agents.length, 0)
checkpoint('all test agents deleted through real daemon RPC')
+ completed = true
} finally {
for (const cleanup of cleanups.reverse()) { try { await cleanup() } catch (error) { console.error('Cleanup:', error) } }
await writeFile(join(root, 'results.json'), JSON.stringify({ host: hostname(), os: `${process.platform} ${release()}`,
topology: 'one physical host; two CLIs; two backend instances; real Redis and MongoDB; fixture SSO/model CLI',
- checks, nativeDesktopTested: false, physicalRemoteTested: false }, null, 2))
+ completed, checks, nativeDesktopTested: false, physicalRemoteTested: false }, null, 2))
}
diff --git a/cli/tsconfig.viewer-tests.json b/cli/tsconfig.viewer-tests.json
new file mode 100644
index 000000000..72ff1981c
--- /dev/null
+++ b/cli/tsconfig.viewer-tests.json
@@ -0,0 +1,9 @@
+{
+ "extends": "./tsconfig.json",
+ "compilerOptions": {
+ "rootDir": ".",
+ "lib": ["ES2023", "DOM"],
+ "incremental": false
+ },
+ "include": ["scripts/remote-viewer-peer.ts", "scripts/remote-viewer-live.ts", "scripts/remote-viewers-stack.ts"]
+}