import { i as OpenClawConfig } from "./types.openclaw-DPoGrEjf.js";
import "./logs-chat-ahnQcKVd.js";
import "./types-UEAAk3YJ.js";
import "./index-DJXrBfkw.js";
import "./channel-contract-D5K0dYZr.js";
import "./templating-yfrEF539.js";
import { _n as ChatRunEntry, bn as QueuedChatTurnMap, cn as TaskStatus, gn as RestartRecoveryCandidate, hn as ChatAbortControllerEntry, mn as HealthSummary, pn as DedupeEntry, sn as TaskRecord, vn as ChatRunState } from "./types-BK7bELXN.js";
import "./manager.core-D9IJqwF9.js";
import "./hook-runner-global-APeVeunr.js";
import "./get-reply-Dc1WD5ra.js";
import "./index-sRLqT6eI.js";
import "./subagent-registry.types-1pNCxNW1.js";
//#region src/tasks/task-restart-blocker.d.ts
type ActiveTaskRestartBlocker = {
  taskId: string;
  status: Extract<TaskStatus, "running">;
  runtime: TaskRecord["runtime"];
  runId?: string;
  label?: string;
  title?: string;
};
//#endregion
//#region src/infra/gateway-active-work.d.ts
type GatewayActiveWorkCounts = {
  queueSize: number;
  pendingReplies: number;
  embeddedRuns: number;
  backgroundExecSessions: number;
  cronRuns: number;
  activeTasks: number;
  rootRequests: number;
  sessionAdmissions: number;
  sessionMutations: number;
  chatRuns: number;
  queuedTurns: number;
  terminalPersistence: number;
  terminalSessions: number;
  /** Compatibility aggregate. Categories can overlap; use individual counts for diagnostics. */
  totalActive: number;
};
type GatewayActiveWorkBlocker = {
  kind: "queue" | "reply" | "embedded-run" | "background-exec" | "cron-run" | "task" | "root-request" | "session-admission" | "session-mutation" | "chat-run" | "queued-turn" | "terminal-persistence" | "terminal-session";
  count: number;
  message: string;
  task?: ActiveTaskRestartBlocker;
};
type GatewayActiveWorkSnapshot = {
  idle: boolean;
  counts: GatewayActiveWorkCounts;
  blockers: GatewayActiveWorkBlocker[];
};
type GatewayActiveWorkWaitResult = {
  drained: boolean;
  snapshot: GatewayActiveWorkSnapshot;
};
type GatewayActiveWorkInspectors = {
  getQueueSize: () => number;
  getPendingReplies: () => number;
  getEmbeddedRuns: () => number;
  getBackgroundExecSessions: () => number;
  getCronRuns: () => number;
  getActiveTasks: () => number;
  getTaskBlockers: () => ActiveTaskRestartBlocker[];
  getRootRequests: () => number;
  getSessionAdmissions: () => number;
  getSessionMutations: () => number;
  getChatRuns: () => number;
  getQueuedTurns: () => number;
  getTerminalPersistence: () => number;
  getTerminalSessions: () => number;
};
declare function createGatewayActiveWorkSnapshot(inspectors?: Partial<GatewayActiveWorkInspectors>, options?: {
  ignoreTerminalSessions?: boolean;
}): GatewayActiveWorkSnapshot;
/** Waits for the complete process-wide active-work inventory to become idle. */
declare function waitForGatewayActiveWork(timeoutMs?: number, options?: {
  onSnapshot?: (snapshot: GatewayActiveWorkSnapshot) => void;
}): Promise<GatewayActiveWorkWaitResult>;
//#endregion
//#region src/infra/heartbeat-runner-scheduler.d.ts
type HeartbeatRunner = {
  stop: () => void;
  updateConfig: (cfg: OpenClawConfig) => void;
};
//#endregion
//#region src/gateway/server-media-cleanup-lifecycle.d.ts
type MediaCleanupStopResult = "drained" | "timed-out";
//#endregion
//#region src/gateway/server-maintenance.d.ts
declare function startGatewayMaintenanceTimers(params: {
  broadcast: (event: string, payload: unknown, opts?: {
    dropIfSlow?: boolean;
    stateVersion?: {
      presence?: number;
      health?: number;
    };
  }) => void;
  nodeSendToAllSubscribed: (event: string, payload: unknown) => void;
  getPresenceVersion: () => number;
  getHealthVersion: () => number;
  refreshGatewayHealthSnapshot: (opts?: {
    probe?: boolean;
    includeSensitive?: boolean;
  }) => Promise<HealthSummary>;
  logHealth: {
    info: (msg: string) => void;
    error: (msg: string) => void;
  };
  restartRunningChannels: (mode: "new-thaw" | "deferred-retry", shouldContinue?: () => boolean) => Promise<boolean>;
  activeWorkInspectors: Partial<GatewayActiveWorkInspectors>;
  refreshPresence: () => void;
  resetEventLoopHealth: () => void;
  dedupe: Map<string, DedupeEntry>;
  chatAbortControllers: Map<string, ChatAbortControllerEntry>;
  chatQueuedTurns: QueuedChatTurnMap;
  restartRecoveryCandidates: Map<string, RestartRecoveryCandidate>;
  chatRunState: ChatRunState;
  removeChatRun: (sessionId: string, clientRunId: string, sessionKey?: string) => ChatRunEntry | undefined;
  agentRunSeq: Map<string, number>;
  nodeSendToSession: (sessionKey: string, event: string, payload: unknown) => void;
  isNixMode?: boolean;
  mediaCleanupTtlMs?: number;
  getRuntimeConfig: () => OpenClawConfig;
  runWorktreeGc?: () => Promise<unknown>;
  runDeliveryQueueMediaGc?: () => Promise<unknown>;
  runManagedOutgoingMediaGc?: () => Promise<unknown>;
}): {
  tickInterval: ReturnType<typeof setInterval>;
  healthInterval: ReturnType<typeof setInterval>;
  dedupeCleanup: ReturnType<typeof setInterval>;
  startMediaCleanup: () => void;
  stopMediaCleanup: () => Promise<MediaCleanupStopResult>;
  worktreeCleanup: ReturnType<typeof setInterval>;
  skillUsageCleanup: () => void;
};
//#endregion
//#region src/gateway/server-runtime-services.d.ts
type GatewayMaintenanceHandles = NonNullable<Awaited<ReturnType<typeof startGatewayMaintenanceTimers>>>;
//#endregion
//#region src/plugins/services.d.ts
type PluginServicesHandle = {
  stop: (options?: {
    strict: true;
    deadlineAtMs: number;
  }) => Promise<void>;
};
//#endregion
export { createGatewayActiveWorkSnapshot as a, HeartbeatRunner as i, GatewayMaintenanceHandles as n, waitForGatewayActiveWork as o, MediaCleanupStopResult as r, PluginServicesHandle as t };