/** * HTTP client wrapper for the OpenCode headless server API. * Supports retry, Basic auth, SSE streaming, and health checks. */ export interface OpenCodeClientOptions { baseUrl: string; username?: string; password?: string; } /** Structured error categories for actionable user guidance. */ export type OpenCodeErrorCategory = 'connection_refused' | 'dns_resolution' | 'auth_failed' | 'not_found' | 'rate_limited' | 'server_error' | 'timeout' | 'network_error' | 'invalid_response'; export declare class OpenCodeError extends Error { readonly status: number; readonly method: string; readonly path: string; readonly body: string; readonly category: OpenCodeErrorCategory; constructor(message: string, status: number, method: string, path: string, body: string, category?: OpenCodeErrorCategory); private static categorizeStatus; get isTransient(): boolean; get isNotFound(): boolean; get isAuth(): boolean; get isRateLimit(): boolean; /** User-facing guidance for this error. */ get guidance(): string; } export declare class OpenCodeClient { private baseUrl; private authHeader?; constructor(options: OpenCodeClientOptions); getBaseUrl(): string; private buildUrl; private headers; private request; get(path: string, query?: Record, directory?: string): Promise; post(path: string, body?: unknown, opts?: { timeout?: number; directory?: string; }): Promise; /** * Dispatch a POST request without waiting for ANY response (not even headers). * * OpenCode's POST /session/:id/message holds the connection open until the * LLM finishes generating. The Go HTTP handler doesn't send response headers * until it has a result, so even `await fetch()` blocks for the full LLM duration. * * This method calls `fetch()` (which dispatches the request immediately over the wire) * but does NOT await the returned Promise. The response is consumed in the background * to prevent resource leaks. Errors are logged but not thrown — the polling loop * independently detects issues via GET /session/status. * * Use this for fire-and-forget message sends where you'll poll for results separately. */ postFireAndForget(path: string, body?: unknown, opts?: { directory?: string; }): void; patch(path: string, body?: unknown, directory?: string): Promise; delete(path: string, query?: Record, directory?: string): Promise; /** * Check if the OpenCode server is healthy. * Uses the /global/health endpoint which returns {healthy: true, version: "..."}. */ isHealthy(): Promise; /** Fallback health check for older OpenCode versions without /global/health. */ private isHealthyFallback; /** * Get a diagnostic summary of connection state for error messages. */ diagnose(): Promise; } //# sourceMappingURL=opencode-client.d.ts.map