import type { FleetConfig, ResolvedRole } from './config.js'; import type { InstallOutcome as BackendInstallOutcome, SupervisorBackend } from './supervisor/types.js'; import { type Exec } from './exec.js'; import { type IdentityProvisioner } from './creation.js'; /** An install outcome tagged with the role it belongs to. */ export interface InstallOutcome extends BackendInstallOutcome { role: string; } export interface OpsDeps { backend: SupervisorBackend; binPath: string; log(line: string): void; /** Process/service inspection for exact temporary-supervisor lifecycle commands. */ exec?: Exec; /** Test seam for exact detached-supervisor signaling/liveness. */ kill?(pid: number, signal: NodeJS.Signals | 0): void; sleep?(ms: number): Promise; /** Permanent identity reconciliation seam; temporary roles never use this lifecycle. */ identityProvisioner?: IdentityProvisioner; /** * Called the INSTANT a registration is created, before anything else can * fail. A creation transaction that learns about registrations only from * `up()`'s return value learns nothing when `up()` throws — and the service * it just registered is then invisible to rollback. Optional: plain * `ours-fleet up` has no transaction to tell. */ onInstalled?(outcome: InstallOutcome): void; /** * Optional: supervises the single watchdog-scheduler process. * Absent for callers that predate watchdogs — `up`/`down` must never throw * just because this hook is missing. */ watchdogService?: { /** `changed` is true when the unit/plist content itself differs from what's on disk (or was absent). */ install(binPath: string, configPath?: string): Promise<{ changed: boolean; }>; start(): Promise; stop(): Promise; /** Bounces an already-running scheduler so a config change actually reaches it — `start()` is a no-op on an active unit. */ restart(): Promise; supervised(): boolean; }; } /** Materialize a role's state dir from config: briefing + markers. Returns the dir. */ export declare function applyRole(role: ResolvedRole, opts?: { fresh?: boolean; temp?: boolean; configPath?: string; identityGuarantee?: 'verified' | 'created' | 'unverified'; }): string; /** Create/start roles declaratively. Idempotent; active roles keep their context. */ export declare function up(cfg: FleetConfig, names: string[], deps: OpsDeps, configPath?: string, identityGuarantee?: 'verified' | 'created' | 'unverified'): Promise; export declare function down(cfg: FleetConfig, names: string[], deps: OpsDeps): Promise; /** Re-sync from config + bounce. mode 'keep' resumes context; 'fresh' wipes it. */ export declare function restartRoles(cfg: FleetConfig, names: string[], deps: OpsDeps, mode: 'keep' | 'fresh', configPath?: string): Promise; /** Stop + forget a role: unit, state dir, and its fleet.d file when spawned. */ export declare function rmRole(cfg: FleetConfig, name: string, deps: OpsDeps): Promise;