/** * useAgentConnectivity — single source of truth for "is this agent reachable". * * Reads from the workspace-wide `vibecontrolsAgentHealthProbes` GraphQL query * (the same probe the Targets & Agents page polls). The backend hits * /health/ready (deep check: ttyd + tunnel + session + db + lifecycle) * and reports a per-agent {healthy, errorMessage} payload. * * Why this hook exists: * - Multiple AI surfaces (AIPage, AgentManagerPage, AISessionDetailPage) * need to render a friendly "agent not connected" card before the * install-button surfaces (PluginGate, PluginHarnessPicker) try to * fetch plugin lists from the agent. * - Earlier this hook did its own raw-fetch probe via /health/ready * through the gateway. That created a race between mounts where the * initial render saw `agentId=''` (cache hydration mid-flight), * flipped status to "unreachable", and then never recovered for the * user even after the agent id became known. Worse, the per-mount * probe meant a sidenav navigate-back would re-run the fetch from * scratch and briefly show "Agent not connected" before settling. * - Routing through the cached GraphQL query eliminates both races: * Apollo's cache-and-network policy returns the last-known result * instantly on remount, and the 30s pollInterval keeps it fresh. */ export type AgentConnectivityStatus = 'unknown' | 'probing' | 'reachable' | 'unreachable'; export interface UseAgentConnectivityResult { status: AgentConnectivityStatus; /** True when at least one probe has settled (reachable or unreachable). */ hasProbed: boolean; /** True while an in-flight probe is running. */ probing: boolean; /** True iff the most recent probe says the agent is reachable. */ reachable: boolean; /** Sanitized, user-friendly hint for unreachable case. Never raw fetch text. */ hint: string | null; /** Re-runs the probe. Resolves once the new probe settles. */ retry: () => Promise; } export declare function isUnreachableError(message: string | null | undefined): boolean; /** * Translate a raw error message into a short, user-safe hint key. * The full technical detail goes to console.error elsewhere — return * value here is for direct UI rendering. */ export declare function sanitizeConnectivityHint(raw: string | null | undefined): string | null; export declare function useAgentConnectivity(agentId: string | null): UseAgentConnectivityResult;