MCPcopy
hub / github.com/garrytan/gstack / readTerminalPort

Function readTerminalPort

browse/src/server.ts:405–411  ·  view source on GitHub ↗

* Terminal-agent discovery. The non-compiled bun process at * `browse/src/terminal-agent.ts` writes its chosen port to * ` /terminal-port` and the loopback handshake token to * ` /terminal-internal-token` once it boots. Read on demand — * lazy so we don't break tests that don't

()

Source from the content-addressed store, hash-verified

403 * lazy so we don't break tests that don't spawn the agent.
404 */
405function readTerminalPort(): number | null {
406 try {
407 const f = path.join(path.dirname(config.stateFile), 'terminal-port');
408 const v = parseInt(fs.readFileSync(f, 'utf-8').trim(), 10);
409 return Number.isFinite(v) && v > 0 ? v : null;
410 } catch { return null; }
411}
412function readTerminalInternalToken(): string | null {
413 try {
414 const f = path.join(path.dirname(config.stateFile), 'terminal-internal-token');

Callers 3

grantPtyTokenFunction · 0.85
restartPtySessionFunction · 0.85
makeFetchHandlerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected