import type { ExtensionContext } from "@earendil-works/pi-coding-agent"; import { type RalphLoopAgentWorkload, type RalphLoopEvaluationOptions, type RalphLoopEvaluationResult, type SlackBridgeSettings } from "./helpers.js"; import type { ActivityLogEntry } from "./activity-log.js"; import type { BrokerControlPlaneDashboardSnapshot } from "./broker/control-plane-dashboard.js"; import type { BrokerMaintenanceResult } from "./broker/maintenance.js"; import type { BrokerDB, TaskAssignmentAwaitingReplyInfo } from "./broker/schema.js"; export type RalphSnoozeSource = "manual" | "auto"; export interface RalphSnoozeStatus { active: boolean; until: string | null; remainingMs: number; reason: string | null; source: RalphSnoozeSource | null; emptyCycleCount: number; } export interface RalphLoopState { timer: ReturnType | null; running: boolean; nudges: Map; reportedGhosts: Set; ghostBaselineHydrated: boolean; nonGhostSignature: string; hadOutstandingAnomalies: boolean; followUpAt: number; followUpPending: boolean; followUpSignature: string; taskAssignmentReportSignature: string; pendingTaskAssignmentReport: { message: string; signature: string; } | null; snoozeUntilMs: number; snoozeReason: string | null; snoozeSource: RalphSnoozeSource | null; snoozeEmptyCycleCount: number; } export declare function createRalphLoopState(): RalphLoopState; export declare function resetRalphLoopState(state: RalphLoopState): void; export declare function getRalphLoopSnoozeStatus(state: Pick, now?: number): RalphSnoozeStatus; export declare function setRalphLoopSnooze(state: Pick, input: { durationMs: number; reason?: string | null; source?: RalphSnoozeSource; now?: number; }): RalphSnoozeStatus; export declare function clearRalphLoopSnooze(state: Pick): void; export declare function buildTrackedAssignmentReplyNudgeMessage(issueNumbers: readonly number[], cycleStartedAt?: string): string; export declare function applyTrackedAssignmentIdleReplyStalls(evaluation: RalphLoopEvaluationResult, workloads: ReadonlyArray>, awaitingReplyAssignments: ReadonlyArray, options?: Pick): Map; export declare function hydrateRalphLoopReportedGhosts(state: Pick, recentCycles: Array<{ ghostAgentIds: string[]; }>): void; export interface RalphLoopDeps { getBrokerDb: () => BrokerDB | null; getBrokerAgentId: () => string | null; heartbeatTimerActive: () => boolean; maintenanceTimerActive: () => boolean; runMaintenance: (ctx: ExtensionContext) => void; sendMaintenanceMessage: (targetAgentId: string, body: string) => void; trySendFollowUp: (body: string, onDelivered: () => void) => void; logActivity: (entry: ActivityLogEntry) => void; formatTrackedAgent: (agentId: string) => string; summarizeTrackedAssignmentStatus: (status: string, prNumber: number | null, branch: string | null) => { summary: string; tone?: string; }; refreshHomeTabs: (ctx: ExtensionContext, snapshot: BrokerControlPlaneDashboardSnapshot, refreshedAt: string) => Promise; getLastMaintenance: () => BrokerMaintenanceResult | null; getSettings?: () => SlackBridgeSettings; buildControlPlaneDashboardSnapshot: (input: Record) => BrokerControlPlaneDashboardSnapshot; setLastHomeTabSnapshot: (snapshot: BrokerControlPlaneDashboardSnapshot) => void; getLastHomeTabError: () => string | null; setLastHomeTabError: (err: string | null) => void; } export declare function runRalphLoopCycle(ctx: ExtensionContext, state: RalphLoopState, deps: RalphLoopDeps): Promise; export declare function startRalphLoop(ctx: ExtensionContext, state: RalphLoopState, deps: RalphLoopDeps): void; export declare function stopRalphLoop(state: RalphLoopState): void;