import { i as OpenClawConfig } from "./types.openclaw-fYj4Ft14.js"; import { t as ChannelId } from "./channel-id.types-DjYEl-_2.js"; import { c as ChatRunState, s as ChatRunEntry, v as ChatAbortControllerEntry } from "./types-OyG7XoEB.js"; import { WebSocketServer } from "ws"; import { Server } from "node:http"; //#region src/infra/heartbeat-runner.d.ts type HeartbeatRunner = { stop: () => void; updateConfig: (cfg: OpenClawConfig) => void; }; //#endregion //#region src/plugins/services.d.ts type PluginServicesHandle = { stop: () => Promise; }; //#endregion //#region src/gateway/server-startup-post-attach.d.ts type Awaitable = T | Promise; type GatewayPostReadySidecarHandle = { stop: () => Awaitable; }; //#endregion //#region src/gateway/server-close.d.ts type ShutdownResult = { durationMs: number; warnings: string[]; }; type RestartRunAbortParams = { chatAbortControllers: Map; chatRunState: ChatRunState; removeChatRun: (sessionId: string, clientRunId: string, sessionKey?: string) => ChatRunEntry | undefined; agentRunSeq: Map; broadcast: (event: string, payload: unknown, opts?: { dropIfSlow?: boolean; }) => void; nodeSendToSession: (sessionKey: string, event: string, payload: unknown) => void; }; declare function runGatewayClosePrelude(params: { stopDiagnostics?: () => void; clearSkillsRefreshTimer?: () => void; skillsChangeUnsub?: () => void; disposeAuthRateLimiter?: () => void; disposeBrowserAuthRateLimiter: () => void; stopModelPricingRefresh?: () => void; stopChannelHealthMonitor?: () => void; stopReadinessEventLoopHealth?: () => void; clearSecretsRuntimeSnapshot?: () => void; closeMcpServer?: () => Promise; }): Promise; declare function createGatewayCloseHandler(params: { bonjourStop: (() => Promise) | null; tailscaleCleanup: (() => Promise) | null; releasePluginRouteRegistry?: (() => void) | null; channelIds?: readonly ChannelId[]; stopChannel: (name: ChannelId, accountId?: string) => Promise; pluginServices: PluginServicesHandle | null; postReadySidecars?: readonly GatewayPostReadySidecarHandle[]; disposeSessionMcpRuntimes?: () => Promise; disposeBundleLspRuntimes?: () => Promise; cron: { stop: () => void; }; heartbeatRunner: HeartbeatRunner; updateCheckStop?: (() => void) | null; stopTaskRegistryMaintenance?: (() => Promise | void) | null; nodePresenceTimers: Map>; tickInterval: ReturnType; healthInterval: ReturnType; dedupeCleanup: ReturnType; mediaCleanup: ReturnType | null; agentUnsub: (() => void) | null; heartbeatUnsub: (() => void) | null; transcriptUnsub: (() => void) | null; lifecycleUnsub: (() => void) | null; getPendingReplyCount?: () => number; clients: Set<{ socket: { close: (code: number, reason: string) => void; }; }>; configReloader: { stop: () => Promise; }; wss: WebSocketServer; httpServer: Server; httpServers?: Server[]; drainActiveSessionsForShutdown?: (params: { reason: "shutdown" | "restart"; totalTimeoutMs?: number; }) => Promise<{ emittedSessionIds: string[]; timedOut: boolean; }>; } & RestartRunAbortParams): (opts?: { reason?: string; restartExpectedMs?: number | null; drainTimeoutMs?: number | null; }) => Promise; //#endregion //#region src/gateway/session-reset-service.d.ts type DrainActiveSessionsForShutdownResult = { emittedSessionIds: string[]; timedOut: boolean; }; /** * Emit a typed `session_end` for every session that received `session_start` * but did not yet receive a paired `session_end`. The bounded total timeout * mirrors the gateway lifecycle hook timeout so a slow plugin cannot block * SIGTERM/SIGINT past the runtime's overall shutdown grace window. * * Sessions that have already been finalized through replace / reset / delete / * compaction are forgotten from the tracker by `emitGatewaySessionEndPluginHook` * before this drain runs, so they will not be double-fired here. */ declare function drainActiveSessionsForShutdown(params: { reason: "shutdown" | "restart"; totalTimeoutMs?: number; }): Promise; //#endregion export { ShutdownResult, createGatewayCloseHandler, drainActiveSessionsForShutdown, runGatewayClosePrelude };