#!/usr/bin/env node // A stand-in agent for CI's smoke run of the built app (.github/workflows/app.yml). // Point PLAN2CODE_APP_AGENT_BIN at this file. Like a real agent, it opens a web // console dashboard, with the environment the app gave it, so the console // announces itself to the window and the dashboard frame has something to // connect to (smoke-frame.mjs then checks it did). The repo's fake-agent opens // no console, so it cannot stand in for this. // // It needs PLAN2CODE_CONSOLE_DIR (the folder holding console.mjs), ignores the // arguments the app passes a real agent, and then waits on its input until it // closes. It starts nothing else: the console server is detached, and the // smoke run stops it with `console.mjs stop --all`. import { spawnSync } from 'node:child_process'; import { join } from 'node:path'; const consoleDir = process.env.PLAN2CODE_CONSOLE_DIR; if (!consoleDir) { console.error('smoke-agent: PLAN2CODE_CONSOLE_DIR is not set; it names the folder holding console.mjs'); process.exit(2); } const open = spawnSync(process.execPath, [join(consoleDir, 'console.mjs'), 'open', '--workflow', 'dashboard'], { stdio: ['ignore', 'inherit', 'inherit'], }); if (open.error || open.status !== 0) { console.error(`smoke-agent: console.mjs open failed (${open.error ? open.error.message : `exit ${open.status}`})`); process.exit(1); } console.log('smoke-agent: dashboard open; waiting on input'); process.stdin.resume(); process.stdin.on('end', () => process.exit(0));