/** * TUI refresh helpers for reading loop states from KV. * * This module provides testable helpers for accessing loop state * from the shared project KV store. */ import type { GraphStatusPayload } from './graph-status-store'; export type LoopInfo = { name: string; phase: string; iteration: number; maxIterations: number; sessionId: string; active: boolean; startedAt?: string; completedAt?: string; terminationReason?: string; worktreeBranch?: string; worktree?: boolean; worktreeDir?: string; executionModel?: string; auditorModel?: string; totalTokens?: number; totalCostUsd?: number; modelFailed?: boolean; }; /** * Gets the database path used by the memory plugin. * Exported for testing purposes. */ export declare function getDbPath(): string; /** * Reads loop states from the shared KV store. * * @param projectId - The project ID (git commit hash) * @param dbPathOverride - Optional database path override (for testing) * @returns Array of loop states */ export declare function readLoopStates(projectId: string, dbPathOverride?: string): LoopInfo[]; /** * Reads a single loop's current state by name from KV. * Used by LoopDetailsDialog to avoid stale snapshots. * * @param projectId - The project ID (git commit hash) * @param loopName - The loop name to read * @param dbPathOverride - Optional database path override (for testing) * @returns The loop state or null if not found */ export declare function readLoopByName(projectId: string, loopName: string, dbPathOverride?: string): LoopInfo | null; /** * Computes whether the sidebar should poll for updates based on * active worktree loops and transient graph status. * * Polling continues when: * - There is at least one active worktree loop, OR * - The graph status is in a transient state (initializing or indexing) * * Polling stops when: * - No active worktree loops AND graph status is terminal (ready, error, unavailable) * * @param loops - Array of loop states * @param graphStatus - Current graph status payload * @returns true if polling should continue, false otherwise */ export declare function shouldPollSidebar(loops: LoopInfo[], graphStatus: GraphStatusPayload | null): boolean; export type BackgroundTaskSummary = { id: string; targetAgent: string; status: string; summary: string; }; /** * Reads a lightweight summary of running/pending background tasks from the DB. * Returns an empty array if the table doesn't exist or the DB is unavailable. */ export declare function readBackgroundTasks(dbPathOverride?: string): BackgroundTaskSummary[]; export type BudgetSnapshotSummary = { agent: string; sessionId: string; state: { turns: number; toolFailures: number; requests: number; tokensUsed: number; }; budget: { maxTurns?: number; maxToolFailuresPerTurn?: number; maxRequestsPerTurn?: number; maxTokensPerSession?: number; } | null; warnings: string[]; violations: string[]; updatedAt: number; }; /** * Reads current budget snapshots (one per agent+session pair) from the * project KV store. Only returns entries updated within the last 10 min * to avoid stale indicators. Empty array if DB/store unavailable. * * Optional sessionId filter narrows to one session. */ export declare function readBudgetSnapshots(projectId: string, sessionId?: string, dbPathOverride?: string): BudgetSnapshotSummary[]; //# sourceMappingURL=tui-refresh-helpers.d.ts.map