import { type CommandReader, type LivenessProbe, type ProcessRecord, type ProcessRecordState } from "@cotal-ai/workspace"; /** The `--max-sessions` value a live `cotal supervise` argv is actually serving. * * The manager reads that flag only at start. A refresh that records a different number while this * process stays up is a durable lie: MeshEntry claims a ceiling the live plane is not enforcing. * Absent from argv means the plane default of 64, not a recorded decision. */ export declare function maxSessionsFromSuperviseArgv(command: string): number | undefined; /** True only when the live supervisor argv is proven to already be serving `requested`. * An unreadable command line cannot prove that, so it is a refusal — persist would guess. */ export declare function liveManagerWouldApplyMaxSessions(command: string | undefined, requested: number): boolean; /** The exact logfile the detached-manager writer opens. Exported so operator guidance names the * writer-owned path instead of copying its filename template into command output. */ export declare const managerLogPath: (space: string, root?: string) => string; /** The manager logfile as an operator-facing path relative to the selected mesh root. */ export declare const managerLogDisplayPath: (space: string, root?: string) => string; /** The recorded manager, attributed by {@link readProcessRecord} to a `cotal supervise` process. */ export declare function managerRecordState(probe?: LivenessProbe, readCommand?: CommandReader, space?: string, root?: string): ProcessRecord; /** {@link managerRecordState}'s verdict alone, for the callers that only branch on it. */ export declare function managerLiveness(probe?: LivenessProbe, readCommand?: CommandReader, space?: string): ProcessRecordState; /** One line describing what was found behind the record, for a caller that has to explain itself. */ export declare function describeManagerRecord(r: ProcessRecord): string; /** True only if the manager is PROVABLY running. `unknown` is not up, and neither is `foreign` — a * live process that is not a manager answers no control plane. Callers that would ACT on that * answer must use {@link managerRecordState} instead: this boolean cannot express the difference * between "not running", "cannot tell" and "someone else's process", and acting on the difference * is the whole point. */ export declare function managerUp(space?: string): boolean; /** Whether a live `cotal supervise` process on this machine may be serving `space`. A supervisor * records its pid under whatever folder it was started from, so no one root's record can rule it * out; the process table can. One whose argv names no space serves what its folder or environment * selects, so it counts, and a process table that cannot be listed proves nothing. */ export declare function supervisorMayServe(space: string): boolean; /** True if the manager at `pid` carries a delivery-aware marker BOUND to it (i.e. it's THIS build, * non-hosting). `pid` comes from the caller's own record read: the manager removes its record on exit * and a start replaces it, so reading the pidfile again here would answer about a different process * than the one the caller judged. Fail-closed: the marker stores the pid it was written for, and a * stale marker left by a crash, a mismatch, or an unparseable file all read as NOT delivery-aware, so * a live old hosting manager can't be mistaken for non-hosting and the delivery preflight stops it. */ export declare function managerHasDeliveryMarker(pid: number, space?: string): boolean; /** Start the control-plane manager detached (pid in `.cotal/manager..pid`, output to * `.cotal/manager..log`), stopped by `cotal down`. Re-execs this same CLI's hidden * `__daemon-manager`, the `supervise` entry without its deprecation warning — the composed `cotal` * binary registers it; `process.execArgv` carries the tsx loader in dev and is empty in prod. Its * auto runtime resolves to pty when detached, which answers the control plane * (`cotal_spawn`/`despawn`/`purge`/`persona`) with no tmux/cmux needed. */ export type ManagerStartOpts = { space?: string; server?: string; spawn?: string[]; launch?: string; runtime?: string; attachHost?: string; resumeAttempt?: string; /** The protected commit-token handoff file: path and digest only. A new launch * never passes the token itself on argv. */ resumeCommit?: { path: string; sha256: string; }; wsPort?: number; /** Live-session ceiling forwarded as `supervise --max-sessions`. */ maxSessions?: number; }; export declare function startManagerDetached(o?: ManagerStartOpts): number; /** Refuse to stand a manager up OVER a record we cannot read or attribute. * * Exported because `ensureManager` is not the only path that starts one: `cotal spawn -f` calls * `startManagerDetached` directly after its own lease checks, and so skipped this entirely. A lease * says nobody is ANSWERING; it does not say the recorded pid is dead. Overwriting an unknown or * unattributable record is the same defect as deleting it, reached through a different verb, which * is the third time that shape has appeared in this change. Any future starter calls this first. */ export declare function assertManagerRecordReplaceable(probe?: LivenessProbe, readCommand?: CommandReader, space?: string): void; /** Make the control plane available: reuse a manager already running for this folder, else start * one detached and wait for it to come up, throwing when it exits or loses its record first. * Best-effort — callers treat it as non-fatal. A caller that needs THE manager to carry a * runtime/launch spec (`up -f`) must stop any leftover manager first — a reused one is taken as-is. */ export declare function ensureManager(o?: ManagerStartOpts, probe?: LivenessProbe, readCommand?: CommandReader): Promise<{ running: boolean; started: boolean; pid?: number; }>; /** A signal, injectable for the same reason the probe is: `EPERM` from `kill` is producible only by * another user's process or by kernel policy, so the branch that handles it is otherwise unreachable * from a test. Production passes nothing. */ export type SignalFn = (pid: number, signal: NodeJS.Signals) => void; /** The manager as `cotal down` registers it: its pidfile, and the records that die with its process. */ export declare const MANAGER_PROCESS: { kind: "local-process"; name: string; label: string; order: number; pidFile: string; cooperativeStop: true; artifacts: string[]; }; /** Stop the space's manager. This is the one manager stop: `cotal down`, every `cotal up` teardown and * the delivery cutover preflight run it, so each holds the stop reservation, refuses a concurrent stop, * and escalates a wedged manager to SIGKILL. A default stop signals only a manager that published the * capability to spare its managed agents, and reports the agents it left; `withAgents` arms their reap * instead. `pid` binds the stop to the manager the caller judged: a record a successor published since * is left whole and the stop returns false. Throws, with the records kept, when the stop is refused or * the death is not confirmed. The artifacts stay: `down` removes them only after every selected * component stopped, and every other caller through {@link clearManagerArtifacts}. */ export declare function stopManager(space?: string, { withAgents, pid }?: { withAgents?: boolean; pid?: number; }): Promise; /** Remove the records that die with the space's manager process, once a stop outside `down` returned. */ export declare function clearManagerArtifacts(space: string): void; //# sourceMappingURL=manager-proc.d.ts.map