Files
wehub-resource-sync dfb0b33892
Workflow Lint / actionlint (push) Waiting to run
Build CI Image / build (push) Waiting to run
Skill Docs Freshness / check-freshness (push) Waiting to run
chore: import upstream snapshot with attribution
2026-07-13 11:59:46 +08:00

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);
}