import type { RemoteWorkerCapabilities } from '../protocol.ts'; import type { WorkerHealth, WorkerSummary } from './types.ts'; /** * Minimal read-only snapshot of a single worker's state, as held by the * registry. The projection functions below operate on this shape so they * remain pure and independently testable without a live registry instance. */ export type WorkerSnapshot = { id: string; queue: string; activities: readonly string[]; concurrency: number; inFlight: number; connectedAt: number; lastHeartbeat: number; startedAt: number; capabilities: RemoteWorkerCapabilities; health: WorkerHealth; deploymentName?: string | undefined; buildId?: string | undefined; runtimeVersion?: string | undefined; }; /** * Project a single worker snapshot into a {@link WorkerSummary}. * * `now` should be the same timestamp used for all workers in a single response * so heartbeat ages are consistent across the payload. */ export declare function projectWorkerSummary(snapshot: WorkerSnapshot, now: number): WorkerSummary; /** * Project an array of worker snapshots into sorted {@link WorkerSummary} entries. * * Output is sorted ascending by worker id so the list is stable across calls. */ export declare function projectWorkerSummaries(snapshots: WorkerSnapshot[], now: number): WorkerSummary[]; /** * Deployment-level summary for operator views. Workers without deployment * metadata are grouped under `null` identity fields. */ export type WorkerDeploymentSummary = { deploymentName: string | null; buildId: string | null; runtimeVersion: string | null; health: WorkerHealth; workers: number; activeWorkers: number; drainingWorkers: number; drainedWorkers: number; inFlight: number; oldestStartedAt: number | null; }; type WorkerDeploymentIdentity = { deploymentName?: string | null | undefined; buildId?: string | null | undefined; runtimeVersion?: string | null | undefined; }; /** Stable composite key for grouping workers by deployment identity. */ export declare function deploymentIdentityKey(identity: WorkerDeploymentIdentity): string; /** Count workers per health state. */ export declare function countWorkerHealth(healthValues: WorkerHealth[]): Record; /** * Compute the aggregate health of a deployment from its individual worker health values. * * `drainActive` should be `true` when the deployment-level drain marker is set * and there are no connected workers, so the result reports `'drained'` rather * than `'active'` for a pre-drained empty deployment. */ export declare function deploymentHealth(healthValues: WorkerHealth[], drainActive?: boolean): WorkerHealth; /** Comparator for sorting deployment summaries by their identity key. */ export declare function compareDeploymentSummaries(left: WorkerDeploymentSummary, right: WorkerDeploymentSummary): number; /** * Project a group of worker snapshots that share the same deployment identity * into a single {@link WorkerDeploymentSummary}. */ export declare function projectDeploymentSummary(workers: WorkerSnapshot[], drainActive: boolean): WorkerDeploymentSummary; /** * Project a flat list of worker snapshots into grouped, sorted * {@link WorkerDeploymentSummary} entries. * * `isDrainActive` receives the deployment name and returns whether a * deployment-level drain marker is set for it. */ export declare function projectDeploymentSummaries(snapshots: WorkerSnapshot[], isDrainActive: (deploymentName: string) => boolean): WorkerDeploymentSummary[]; export {};