/** * interactive-query — per-call deadline wrappers for user-facing tools. * * The MCP's tools were written for a fast local dev TSDB and inherited a fetch * layer tuned for batch reliability (30s timeout). Against a real, possibly * slow/remote customer backend a single slow query stalls the whole tool. The * GA bar: an interactive tool must never stall the agent on a wedged backend — * it returns what resolved in time and marks the rest unavailable. * * Two layers of defense, because they cover different backends: * 1. The threaded `timeoutMs` reaches `backend-fetch` and aborts the in-flight * request via AbortController (frees the connection) — for the prom-shaped * backends (log10x, prometheus/mimir/cortex, grafana_cloud_prom, demo). * 2. A client-side race (`withTimeout`) bounds the wait even for backends that * bypass `backend-fetch` (Datadog, GCP, Elastic/OpenSearch, CloudWatch). * The client race deadline is slightly longer than the threaded one so the * cleaner backend-level abort fires first whenever it can. * * On timeout or any error the wrappers resolve to `null`; callers map `null` to * their existing no_signal / no_data / partial-result path. * * Budgets are Tal's GA decision (split, not uniform): * - cheap: env probes, count(), hash→name, light instant reads (~3-4s) * - heavy: increase[7d]/[30d] magnitude legs that surface EXACT bytes/$ to the * user (~15-20s) — these legitimately need longer on a cold backend, * and the alternative is dropping the headline number. * Override via env for ops tuning. */ import type { EnvConfig } from './environments.js'; import { type PrometheusResponse } from './api.js'; /** Interactive per-call query budgets. Pick the tier by query cost. */ export declare const QUERY_BUDGET: { readonly cheap: number; readonly heavy: number; }; /** * Bounded instant query. Resolves to the response, or `null` if it does not * complete within `timeoutMs` (or errors). Pick `timeoutMs` from QUERY_BUDGET. */ export declare function iQueryInstant(env: EnvConfig, promql: string, timeoutMs: number): Promise; /** * Bounded range query. Resolves to the response, or `null` on timeout/error. */ export declare function iQueryRange(env: EnvConfig, promql: string, startSec: number, endSec: number, stepSec: number, timeoutMs: number): Promise;