import { INiceProcessRestartOptions, INiceProcessStopOptions, TNiceProcessKind, TNiceProcessReady, TNiceProcessRun, TNiceProcessShell } from "@nice-code/process"; //#region src/config/types.d.ts /** Ids appear in CLI selectors, URLs and ledger filenames — never option-shaped (edge 31). */ declare const COMMANDER_ID_PATTERN: RegExp; /** The built-in selection word a config may never redefine. */ declare const RESERVED_SELECTOR_NAME = "all"; /** The literal ids a config declared, or `never` once they widened to `string` (built at runtime). */ type TKnownIds = string extends TId ? never : TId; type TCommanderEndpointProtocol = "tcp" | "http"; type TCommanderEndpointOwnership = "exclusive" | "shared" | "observed"; interface ICommanderEndpointHealth { /** HTTP path probed for readiness sugar / health badges. Default "/". */ path?: string; /** Bounded body read must contain this marker. */ match?: string; } interface ICommanderEndpoint { /** Unique per process; referenced by `ready: { kind: "endpoint" }` and UI badges. */ name: TEndpointName; protocol: TCommanderEndpointProtocol; host?: string; port: number; /** * `exclusive` must resolve to this owned tree; `shared` must match a compatible explicit * sharing declaration; `observed` may be external and is never killed or claimed. */ ownership: TCommanderEndpointOwnership; url?: string; health?: ICommanderEndpointHealth; } /** * Readiness sugar: `ready: { kind: "endpoint", endpoint: "web" }` expands against the named * endpoint — tcp → `port` readiness, http → `httpOk` against `health.path` (+ `health.match`). */ type TCommanderReady = TNiceProcessReady | { kind: "endpoint"; endpoint: TEndpointName; timeoutMs?: number; healthProbeMs?: number; }; /** * A variable this process reads, declared so the UI and CLI can offer it. Declaring a knob is what * makes it settable at all: `nice-commander env` and the web UI can only touch names that appear * here, so no viewer can inject arbitrary environment into an arbitrary process. */ interface ICommanderEnvVar { /** The variable as the process reads it. */ name: string; /** One line — shown beside the value in `env` and in the UI. */ description?: string; /** Used when nothing overrides it. Declaring it here replaces writing it in `env`. */ default?: string; /** Closed set: the UI renders a picker, and a value outside it is refused. */ values?: readonly string[]; /** * Never leaves the daemon — not on the realm, not in CLI output, not in logs. * ⚠ Defaults to TRUE for names that look like credentials (see `looksSecret`); pass `false` * explicitly to publish one. The unsafe direction is the one you have to type. */ secret?: boolean; /** A start refuses unless a value is in hand (default, override, or inherited). */ required?: boolean; } /** * A switch a start may turn on to append arguments to `run` — one definition, several ways to run * it. Like `envVars`, declaring it is what makes it passable at all: the daemon appends only * declared flags, so a viewer can pick a variant but never inject an argument. */ interface ICommanderFlag { /** What a start names it by — `run dev-reset --with clean`, the UI's toggle. Same charset as ids. */ name: string; /** Appended to `run`, in declaration order, when the flag is on. Default `["--"]`. */ args?: readonly string[]; /** One line — shown beside the toggle and in `explain`. */ description?: string; } /** * The type parameters are what `defineCommanderConfig` infers from the whole config: every * declared process id and endpoint name, so a reference to one that does not exist is a type error. */ interface ICommanderProcessDefinition { id: TProcessId; /** Default from `defaults.kind`, else "service". */ kind?: TNiceProcessKind; /** Relative cwd resolves against the config file's realpath directory, never the shell's. */ cwd?: string; run: TNiceProcessRun; shell?: TNiceProcessShell; /** * Merged over the daemon's base env; `null` unsets. Values the operator is not meant to tune — * a knob goes in `envVars`, and a name may not appear in both. */ env?: Record; /** Variables this process reads, offered for setting in the UI/CLI. */ envVars?: readonly ICommanderEnvVar[]; /** * Switches a start may turn on (`--with `, or the UI's toggles). A plain start runs `run` * as written. ⚠ With a shell-string `run`, each arg must be shell-plain — it is appended unquoted. */ flags?: readonly ICommanderFlag[]; /** Default "pipe" (held open until stop); "ignore" is an instant EOF. */ stdin?: "pipe" | "ignore"; /** * Free-form; `role` and `project` are the house convention. A key may carry several values — * `project: ["api", "billing"]` matches both `project=api` and `project=billing`. */ tags?: Record; /** * Never swept up in bulk: a tag selection, a suite's `where` and `all` all skip it. It starts * only by exact id, by a suite's explicit `include`, or as a declared dependency. */ optIn?: boolean; /** * Transitive: starting this starts each dependency first and waits for it — service * dependencies until ready, task dependencies until succeeded. Acyclic, validated at load. */ dependsOn?: readonly NoInfer[]; endpoints?: ICommanderEndpoint[]; /** * A start that finds an `exclusive` endpoint held by a STRAY — this same command (argv + cwd) * running outside the daemon, typically started by hand in a terminal that has since gone — * stops that tree and takes the port, instead of refusing. A stranger on the port still * refuses. Default false; `up --replace-same` does the same for one invocation. */ replaceSame?: boolean; /** Primary "open" link when no endpoint owns it. */ url?: string; /** An `endpoint` readiness names an endpoint of this same process (checked at load). */ ready?: TCommanderReady>; stop?: INiceProcessStopOptions; /** Automatic restart is service-only in v1; a task is explicitly rerun. */ restart?: INiceProcessRestartOptions; /** Ring tuning only — the on-disk sink is daemon-anchored (D6), not config-addressable. */ log?: { ringLines?: number; ringBytes?: number; lineBytes?: number; }; /** Tasks only: hard cap on run time so a hung check can't hang a suite run forever. */ timeoutMs?: number; } /** Tag query: every entry must match (AND). An array of queries is OR'd. */ type TCommanderTagQuery = Record; type TCommanderTagQueryOr = TCommanderTagQuery | readonly TCommanderTagQuery[]; /** * A named run-unit: several processes you mean to run as ONE thing (`verify`, `dev`). A label is * a tag — a suite must resolve to at least two members. */ interface ICommanderSuiteDefinition { /** One line — shown on the suite's card and in `list`. */ description?: string; /** Tag-equality selection: OR of AND-maps. Skips `optIn` processes. */ where?: TCommanderTagQueryOr; /** Process ids and/or other suite names. Suite references must be acyclic. */ include?: readonly NoInfer[]; /** Excluded ids and/or tag queries, applied last. */ exclude?: readonly (NoInfer | TCommanderTagQuery)[] | TCommanderTagQuery; /** How many tasks run at once. Default 4. */ parallel?: number; /** Stop scheduling tasks after the first failure. Default false. */ failFast?: boolean; /** Delay between service spawns (no thundering herd of 17 tsc watchers). Default 100. */ staggerMs?: number; } interface ICommanderDefaults { kind?: TNiceProcessKind; /** See `ICommanderProcessDefinition.replaceSame`. */ replaceSame?: boolean; stop?: INiceProcessStopOptions; restart?: INiceProcessRestartOptions; log?: { ringLines?: number; ringBytes?: number; lineBytes?: number; }; tags?: Record; } /** One `key=value` selection term. */ type TCommanderTagTerm = `${string}=${string}`; interface ICommanderConfig { /** Config name — also the data-dir slug seed (D6). Same charset as ids. */ name: string; defaults?: ICommanderDefaults; processes: ICommanderProcessDefinition[]; /** Keyed by suite name — never `all` (the built-in selector) and never a process id. */ suites?: { [TName in TSuiteName]: TName extends typeof RESERVED_SELECTOR_NAME ? `'${TName}' is the built-in selector: pick another suite name` : TName extends TKnownIds ? `'${TName}' is already a process id: pick another suite name` : ICommanderSuiteDefinition }; /** * Selection used by a bare `up` — a suite name, a process id, or one `tag=value` term. Without * it, bare `up` prints the available suites and exits without mutating anything. */ defaultSelection?: NoInfer | TCommanderTagTerm; /** @deprecated Removed: organise processes with `tags`, and declare a run-unit under `suites`. */ groups?: "`groups` was removed: organise processes with `tags`, and declare run-units under `suites`"; /** Local config helpers the D2 loader cannot discover automatically (repo-relative). */ watchFiles?: readonly string[]; daemon?: { /** Base port for the bounded scan-up on collision. Default 4900. */port?: number; }; } //#endregion //#region src/config.d.ts /** * Identity helper so `commander.config.ts` files are typed end to end: an unknown or removed key is * a type error, and so is a `dependsOn`, suite `include`/`exclude`, `defaultSelection` or endpoint * `ready` that names something the config never declares. * * ⚠ The reference checks need literal ids. Processes built from a list typed `{ id: string }[]` * widen every id to `string` and switch those checks off — declare the list `as const` instead. * A `.map()` callback is not contextually typed, so write `dependsOn: [...] as const` there, as * with `kind`. */ declare function defineCommanderConfig(config: ICommanderConfig): ICommanderConfig; //#endregion export { COMMANDER_ID_PATTERN, type ICommanderConfig, type ICommanderDefaults, type ICommanderEndpoint, type ICommanderEndpointHealth, type ICommanderEnvVar, type ICommanderFlag, type ICommanderProcessDefinition, type ICommanderSuiteDefinition, type TCommanderEndpointOwnership, type TCommanderEndpointProtocol, type TCommanderReady, type TCommanderTagQuery, type TCommanderTagQueryOr, type TCommanderTagTerm, defineCommanderConfig }; //# sourceMappingURL=config.d.mts.map