import { type OwnerPrivateLock } from "./owner-private-lock.js"; import type { ProcessIncarnation, SameProcessIncarnation } from "./process-incarnation.js"; export declare const PROCESS_JOBS_GENERATION_DRAIN_TIMEOUT_MS = 30000; export declare const AGENT_ROOT_OWNED_ELSEWHERE_ERROR = "Another mono-agent process is already using this agent root. Stop that local agent before trying again."; export declare const AGENT_ROOT_REQUIRED_ERROR = "A configured local runtime requires an explicit agent-root cwd."; export declare const AGENT_ROOT_WORKSPACE_REQUIRED_ERROR = "runtime.workspace must reference an existing directory before mono-agent starts. Create it or choose an existing workspace."; export declare const PROCESS_JOBS_GENERATION_CHANGED_ERROR = "Process-job private-state protection changed before provider execution."; export declare const PROCESS_JOBS_GENERATION_DRAIN_TIMEOUT_ERROR = "Process-job private-state protection could not safely finish the live configuration switch."; export interface AgentRootProtectionGeneration { readonly id: string; readonly rootKeys: readonly string[]; } export interface AgentRootRequestLease { readonly generation: AgentRootProtectionGeneration; releaseAfterSettlement(): void; } export interface AgentRootMutationGate { readonly generation: AgentRootProtectionGeneration; release(): void; } export interface AgentRootOwnership { readonly agentRoot: string; readonly coordinator: AgentRootCoordinator; /** Release this in-process reference; the OS lease remains until every request truly settles. */ release(): void; } export interface AcquireAgentRootOwnershipOptions { readonly homeDir?: string; readonly pid?: number; readonly now?: () => number; readonly randomToken?: () => string; readonly processIncarnation?: ProcessIncarnation; readonly isSameProcessIncarnation?: SameProcessIncarnation; readonly ownerlessGraceMs?: number; readonly hooks?: { readonly afterLeaseDirectoryCreated?: () => Promise; readonly beforeStaleLeaseRename?: () => Promise; /** Test-only fault seam for the final physical owner-lock release. */ readonly beforeLeaseRelease?: () => Promise; }; } /** Stable owner-record path for an already-canonical agent root. */ export declare function agentRootLeasePath(canonicalRoot: string, homeDir?: string): string; interface ActiveGeneration { readonly roots: ReadonlySet; count: number; } interface CoordinatorEntry { readonly agentRoot: string; readonly lease: OwnerPrivateLock; readonly leasePath: string; readonly beforeLeaseRelease?: () => Promise; readonly active: Map; readonly waiters: Set<() => void>; ownerRefs: number; current?: AgentRootProtectionGeneration; mutationPending: boolean; closing: boolean; closeError?: Error; closed: Promise; resolveClosed: () => void; } /** * One process-global coordinator per canonical agent root. It combines the * cross-process lifetime lease with in-process registry-generation settlement. */ export declare class AgentRootCoordinator { #private; constructor(entry: CoordinatorEntry); get agentRoot(): string; currentGeneration(): AgentRootProtectionGeneration | undefined; publishGeneration(generation: AgentRootProtectionGeneration): void; /** Adopt an already-durable generation without allowing a stale constructor to roll it back. */ synchronizeGeneration(generation: AgentRootProtectionGeneration): void; acquireRequestLease(generation: AgentRootProtectionGeneration): AgentRootRequestLease; /** * Publish the durable generation, then wait only for older leases which did * not cover the root about to be opened. Timeout is fail-closed: callers must * not open or create the ProcessJobs store after rejection. */ publishAndAcquireMutationGate(generation: AgentRootProtectionGeneration, requiredRootKey: string, options?: { readonly timeoutMs?: number; }): Promise; /** Test/coordination seam: resolves only when no request lease remains. */ waitForSettlement(): Promise; } /** Acquire the reentrant process lifetime owner for one canonical agent root. */ export declare function acquireAgentRootOwnership(agentRoot: string | undefined, options?: AcquireAgentRootOwnershipOptions): Promise; /** * Release one logical owner and, only when it was the already-idle final * reference, wait for the physical cross-process lease to disappear. * * Active request or mutation leases deliberately make this return `false` * immediately. They retain the physical lock until true settlement so bounded * app/harness teardown cannot create split ownership. */ export declare function releaseAgentRootOwnershipWhenIdle(ownership: AgentRootOwnership): Promise; /** Reject the exceptional case where the global coordination lease is model-workspace reachable. */ export declare function assertAgentRootLeaseOutsideWorkspace(ownership: AgentRootOwnership, workspace: string): void; export {}; //# sourceMappingURL=agent-root-coordinator.d.ts.map