import { type Secrets } from "./env.js"; import type { Paths } from "./paths.js"; import type { ScheduleStatus } from "./scheduler.js"; import type { ServerState } from "./server.js"; export declare function readServerState(paths: Paths): ServerState | undefined; export declare function localBaseUrl(state: { host: string; port: number; }): string; export interface HealthResponse { ok: boolean; version: string; uptime_seconds?: number; /** Only present for admin/local callers. */ queue?: { running: number; queued: number; running_ids: string[]; }; /** The cloud link's status (admin/local callers of a server that runs one); null when the server has no link. */ cloud?: import("./cloud/link.js").LinkStatusView | null; /** Only present for admin/local callers, and only when the server runs the scheduler. */ schedules?: ScheduleStatus[]; } /** Returns the health payload when a server answers at `baseUrl`, otherwise undefined. */ export declare function probeServer(baseUrl: string, timeoutMs?: number): Promise; /** Polls `${baseUrl}/health` until it answers. A fresh Tailscale Funnel URL needs a few seconds for its TLS certificate. */ export declare function waitForUrl(baseUrl: string, timeoutMs?: number, intervalMs?: number): Promise<{ reachable: boolean; attempts: number; elapsedMs: number; }>; /** The running server for this skillhook directory, if its state file is present and it answers. */ export declare function findRunningServer(paths: Paths): Promise<{ state: ServerState; baseUrl: string; health: HealthResponse; } | undefined>; export interface AdminResponse { status: number; body: T; } /** One server-sent event: `data` is the raw (JSON) text of its `data:` lines joined with newlines. */ export interface StreamedEvent { id?: string; event?: string; data: string; } /** Incremental `text/event-stream` parser: feed it chunks, take the complete events. */ export declare class SseParser { private buffer; private current; push(chunk: string): StreamedEvent[]; /** The event under construction, if it has data (a stream that ends without a blank line). */ flush(): StreamedEvent | undefined; } /** * Opens an admin SSE route (`/events`, `/jobs//events`) and calls `onEvent` for each message until the server * ends the stream or `signal` aborts. Resolves with the HTTP status; a non-2xx status ends the call at once. */ export declare function openAdminEventStream(baseUrl: string, secrets: Secrets, path: string, onEvent: (event: StreamedEvent) => void, signal?: AbortSignal): Promise<{ status: number; }>; export declare function adminRequest(baseUrl: string, secrets: Secrets, path: string, init?: { method?: string; body?: unknown; timeoutMs?: number; }): Promise>;