import { type IncomingMessage, type ServerResponse } from 'node:http'; import { type RelayStats } from '@origintrail-official/dkg-core'; import type { DashboardDB } from './db.js'; import { type ChatMemoryManager } from './chat-memory.js'; import type { MetricsCollector } from './metrics-collector.js'; /** * Live relay-stats provider — wraps `DKGNode.getRelayStats()`. Returns * `null` when the node is not running a relay server (i.e. edge node) * so the route can respond 404. The `/api/relay/stats` route reads * this directly rather than going through the MetricsCollector path * because it needs the per-reservee detail array, which is too large * to persist in periodic snapshots. */ export type RelayStatsProvider = () => RelayStats | null; export interface LlmSettingsCallbacks { getLlm: () => { apiKey?: string; model?: string; baseURL?: string; } | undefined; setLlm: (llm: { apiKey: string; model?: string; baseURL?: string; } | null) => Promise; } export interface TelemetrySettingsCallbacks { getTelemetryEnabled: () => boolean; setTelemetryEnabled: (enabled: boolean) => Promise<{ ok: boolean; error?: string; }>; } /** * Handles all /api/metrics, /api/operations, /api/node-log, /api/query-history, * /api/saved-queries, and /ui routes. Returns true if the request was handled. */ export declare function handleNodeUIRequest(req: IncomingMessage, res: ServerResponse, url: URL, db: DashboardDB, staticDir: string, _legacyRemovedArg?: unknown, metricsCollector?: MetricsCollector, authToken?: string, memoryManager?: ChatMemoryManager, llmSettings?: LlmSettingsCallbacks, telemetrySettings?: TelemetrySettingsCallbacks, corsOrigin?: string | null, relayStatsProvider?: RelayStatsProvider, /** * Called when a metric-serving route (/api/metrics[/history]) is actually * served here — i.e. after the daemon's rate-limit/admission/auth gates have * accepted the request. Lets the metrics collector treat the caller as a live * consumer without the daemon duplicating route knowledge. (#1066 Item 1) */ markMetricsConsumer?: () => void): Promise; //# sourceMappingURL=api.d.ts.map