/** * Z.AI Monitor API client — Provider-local transport (DESIGN.md §13, P4-02). * * This Module owns the Z.AI monitor endpoint fetch mechanics moved here * from `lib/monitor-client.ts`. It performs direct HTTP against * `https://api.z.ai` (overridable via `ZAI_MONITOR_BASE_URL`) with an * auth quirk: try the raw key first, and on 401 retry the same request * with a `Bearer` prefix. Every transport dependency (fetch, timer, * environment) is injectable so tests drive auth fallback and timeout * deterministically without touching globals. * * Boundary rules (ARCHITECTURE.md §2): * - May import Provider identity types, normalized errors. * - Must NOT import command presentation or another Provider's Adapter. * * Raw response text NEVER enters public errors. A non-2xx response is * mapped to a stable normalized error (`AuthError` for 401/403, `ApiError` * otherwise) whose message carries no response body. Transport failures * map to `TimeoutError`/`NetworkError`. * * This transport performs ONE logical attempt (including the auth-scheme * fallback). Shared execution owns retry policy. */ import type { ProviderQuotaFetch } from "../types.js"; /** Injectable fetch signature (shared duck-typed port). */ export type ZaiMonitorFetch = ProviderQuotaFetch; /** Fetch response shape this transport consumes. */ export type ZaiMonitorFetchResponse = Awaited>; /** Injectable transport dependencies. */ export interface ZaiMonitorDeps { readonly fetch?: ZaiMonitorFetch; readonly setTimeout?: typeof setTimeout; readonly clearTimeout?: typeof clearTimeout; readonly env?: NodeJS.ProcessEnv; } /** Raw Z.AI quota-limit response shape (monitor endpoint). */ export interface ZaiRawQuotaLimit { level?: string; limits?: unknown[]; } export declare function resolveTimeoutMs(env: NodeJS.ProcessEnv): number; /** * Perform one authenticated GET against the monitor API with the raw-key * then Bearer auth fallback. Returns the unwrapped `data` payload (or the * whole body when no `data` envelope is present). * * `path` is appended to the monitor base; `params` become query params. */ export declare function fetchZaiMonitorPath(apiKey: string, path: string, params: Record | undefined, deps?: ZaiMonitorDeps): Promise; /** * Fetch the Z.AI quota-limit payload (one attempt, auth-scheme fallback). */ export declare function fetchZaiQuotaLimit(apiKey: string, deps?: ZaiMonitorDeps): Promise; //# sourceMappingURL=monitor-client.d.ts.map