mirror of
https://github.com/garrytan/gstack.git
synced 2026-06-17 23:30:09 +02:00
f5f7e32505
Single source of truth for Conductor host detection in TS consumers (CONDUCTOR_WORKSPACE_PATH / CONDUCTOR_PORT). Reads the passed env at call time, not a module-load snapshot, so unit tests can pin the env inline without Bun --preload (esm-hoist-breaks-env-pin-bootstrap). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
20 lines
1012 B
TypeScript
20 lines
1012 B
TypeScript
/**
|
|
* Conductor host detection — single source of truth for TS consumers.
|
|
*
|
|
* Conductor (the Mac app that runs many coding agents in parallel) sets
|
|
* CONDUCTOR_WORKSPACE_PATH / CONDUCTOR_PORT in the session env. The same two
|
|
* vars are what `bin/gstack-session-kind` keys on (it collapses Conductor into
|
|
* `interactive`, so it can't be reused to distinguish Conductor specifically —
|
|
* hence this dedicated helper).
|
|
*
|
|
* IMPORTANT: detection is a CALL-TIME read of the passed-in env (default
|
|
* `process.env`), never a module-load-time snapshot. ESM hoists static imports
|
|
* above any in-file `process.env.X = ...`, so a load-time read can't be pinned
|
|
* by a test without Bun --preload. Reading at call time lets unit tests set
|
|
* `process.env.CONDUCTOR_WORKSPACE_PATH` inline before invoking. See the
|
|
* `esm-hoist-breaks-env-pin-bootstrap` learning.
|
|
*/
|
|
export function isConductor(env: NodeJS.ProcessEnv = process.env): boolean {
|
|
return !!(env.CONDUCTOR_WORKSPACE_PATH || env.CONDUCTOR_PORT);
|
|
}
|