Write server-info to file so agents can find URL after background launch

The server now writes its startup JSON to $SCREEN_DIR/.server-info.
Agents that launch the server via background execution (where stdout is
hidden) can read this file to get the URL, port, and screen_dir.
This commit is contained in:
Jesse Vincent
2026-03-09 20:46:34 -07:00
parent 81acbcd51e
commit 7f8edd9c12
2 changed files with 10 additions and 2 deletions

View File

@@ -130,12 +130,18 @@ chokidar.watch(SCREEN_DIR, { ignoreInitial: true })
});
server.listen(PORT, HOST, () => {
console.log(JSON.stringify({
const info = JSON.stringify({
type: 'server-started',
port: PORT,
host: HOST,
url_host: URL_HOST,
url: `http://${URL_HOST}:${PORT}`,
screen_dir: SCREEN_DIR
}));
});
console.log(info);
// Write to .server-info so agents can find connection details
// even when stdout is hidden (e.g. background execution)
const fs = require('fs');
const path = require('path');
fs.writeFileSync(path.join(SCREEN_DIR, '.server-info'), info + '\n');
});