import { ServerProcessRegistry } from "./processes.js"; export type WorkflowServerOptions = { /** Retained for callers; the server itself is global to the state database. */ cwd?: string; runnerId?: string; databasePath?: string; registry?: ServerProcessRegistry; piArgs?: string[]; env?: Record; claimPollMs?: number; /** Combined capacity for workflow runner and resource runner processes. */ maxRunners?: number; serverLeaseMs?: number; serverRenewMs?: number; runClaimLeaseMs?: number; runnerEntryPath?: string; runnerStartupTimeoutMs?: number; resourceRunnerEntryPath?: string; channelAdapterEntryPath?: string; onLog?: (message: string) => void; }; /** Global package-owned server. It writes state and supervises code-only runners. */ export declare class WorkflowServer { private readonly options; private readonly serverId; private readonly databasePath; private readonly stateDirectory; private readonly socketPath; private readonly lockPath; private readonly state; private readonly serverState; private readonly recovery; private readonly queue; private readonly decisions; private readonly channelEffects; private readonly runStore; private readonly views; private readonly registry; private readonly activeRuns; private readonly runnerDescendants; private readonly activeResourceManagers; private readonly activeChannels; private readonly controlClaims; private readonly activationTasks; private readonly maintenanceCommands; private readonly pendingRunClaims; private readonly blockedRuns; private readonly pendingTerminalMessageReconciliations; private readonly sessionCoordinators; private readonly sockets; private readonly connections; private server; /** The socket path this server actually bound, or null while it has not. */ private boundSocketPath; /** The live holder's lock record this start displaced, if any. */ private displacedLock; private claim; private heartbeatTimer; private pollTimer; private viewTimer; private stopping; private started; private schedulerActive; private preferResourceManager; private readonly maxRunners; private decisionTimeoutActive; private decisionChannelConfig; private decisionChannelError; private channelReloading; private automaticStatePruneTask; private automaticStatePruneTimer; private automaticStatePruneScheduled; private automaticStatePruneDue; private rebindingSocket; private lastAutomaticStatePruneAt; private nextAutomaticStatePruneAttemptAt; private nextTerminalMessageReconciliationAt; constructor(options?: WorkflowServerOptions); get endpoint(): string; private get runClaimLeaseMs(); start(): Promise; stop(): Promise; /** * Re-create the socket file when a superseded predecessor's exit removed it: * a process that exits unlinks the socket path its own listener bound, and * after a takeover that path belongs to this server. The claim row must * still name this server, or a newer server owns the path now. */ private ensureSocketFile; private closeServer; private recoverPreviousServer; private startTimers; private listen; /** * Put back the lock record a fenced start displaced: the holder that kept * serving must keep its lock file, or the version-mismatch stop path and * later recovery lose track of it. A record another starter already wrote * stays in place. */ private restoreDisplacedLock; /** Remove the socket file only when this server bound it. */ private removeBoundSocket; private handleConnection; private detachSessionCoordinators; private handleClientRequest; private executeMaintenanceCommand; private addSubscription; private sessionCoordinatorView; private requireSessionCoordinator; private requireSessionCommand; private reportWorkflowBranch; private reportWorkflowTurn; private applyWorkflowTurnEnd; private reconcileSubmissionReminders; private publishViews; private publishConnection; /** * The one writer for every outbound frame: the hello message, direct responses, * subscription events, and subscription failures. It measures the complete * frame, so a frame above the client limit never leaves this server. The caller * decides what that means for its own message, and which failures it can see. */ private writeClientFrame; private failSubscription; private publishSubscription; private submitInteractionAndWait; private handleRequest; private executeOperation; private restartRun; private queueSessionFollowUp; private removeSessionFollowUp; private changeSessionWorkflowSettings; private recordSessionBatch; private executeResourceManagerOperation; private statusReceipt; private activeRunnerContentHashes; private requestAutomaticStatePrune; private resumeAutomaticStatePruneIfDue; private startAutomaticStatePrune; private runAutomaticStatePrune; private scheduleAutomaticStatePruneTimer; private automaticStatePruneCanContinue; private waitForAutomaticStatePrune; private stateStatusReceipt; private answerCheckpoint; private answerDecision; private acceptDecisionAnswer; private scheduleInteractionResume; private startRun; private publishInteractionUpdate; private submitInteraction; private decisionChannelStatus; private markApplyingChannelEffectsAmbiguous; private recoverDecisionChannel; private reloadDecisionChannels; private startDecisionChannel; private ensureChannelResource; private handleChannelExit; private handleChannelMessage; private applyChannelMessage; private nextChannelCommand; private ensureApplyingChannelEffect; private recordChannelEffectResult; private confirmedChannelMessageReferences; private saveChannelCursor; private channelCursor; private channelEventExists; private recordChannelEvent; private recordChannelMutation; private recordChannelResourceMutation; private channelRevision; private claimResourceManagerOne; private activateResourceManager; private handleResourceRunnerMessage; private resourceManagerWorkflowScheduler; private changeResourceManagerWorkflowSettings; private ensureResourceManagerWorkflow; private finishResourceManagerSuccess; private finishResourceManagerFailure; private expireTimedOutDecision; private claimExpiredInteraction; private markPendingStart; private clearPendingStart; private executionRunnerCount; private claimOne; private claimEligibleRun; private activateRun; private activateRunNow; private handleRunnerMessage; private handleFreshRunnerMessage; private handleRunnerProcessOperation; private reapRunnerDescendants; private acceptRunnerInteraction; private rejectRunnerInteraction; private requireRunnerInteraction; private settleRejectedInteraction; private enqueueRunnerNotification; private parkForInteraction; private prepareInteractionResume; private applyLifecycleProjection; private ensureTerminalWorkflowMessage; private tryEnsureTerminalWorkflowMessage; private terminalWorkflowMessageRequired; private terminalWorkflowMessageMissing; private discoverMissingTerminalWorkflowMessages; private scheduleTerminalWorkflowMessageReconciliation; private reconcilePendingTerminalWorkflowMessages; private terminalAncestorOutcomes; private completeResourceManagerWorkflow; private commitActivePause; private recoverRunnerExit; private releaseLock; private log; }