/** * Provider-agnostic CGM source. * * wellness-cgm-mcp supports two real backends — Dexcom (Developer API) and * FreeStyle Libre (via LibreLink Up). Both produce the same {@link GlucoseReading} * shape, so the ADA TIR / GMI / hypo / meal-response engine is shared and the * MCP tools don't need to know which provider is active. * * Provider selection (in priority order): * 1. Explicit `CGM_PROVIDER` env var ("dexcom" | "libre"). * 2. Auto-detect: if LibreLink Up creds are set and Dexcom is not, use libre. * 3. Default: dexcom (preserves pre-0.4 behaviour). * * Mock mode is preserved: when the resolved provider has no auth configured, * `loadReadings` returns synthetic readings tagged `mock: true` — identical to * the original Dexcom mock path, so every tool still demos with zero setup. */ import { type CgmProvider } from "../constants.js"; import { DexcomClient } from "./dexcom-client.js"; import { LibreLinkUpClient } from "./librelink-client.js"; import { type GlucoseReading } from "./glucose-engine.js"; export interface LoadedReadings { readings: GlucoseReading[]; mock: boolean; } export interface CgmSourceStatus { ok: true; provider: CgmProvider; /** Why this provider was chosen. */ selected_by: "env" | "auto" | "default"; mode: "live" | "mock"; /** Provider-specific detail (env, region, configured flags). */ detail: Record; notes: string[]; } /** * A uniform CGM source over whichever provider is active. Construct with * `CgmSource.resolve()` to honour env-based provider selection, or pass an * explicit provider for tests. */ export declare class CgmSource { readonly provider: CgmProvider; readonly selectedBy: "env" | "auto" | "default"; private readonly dexcom?; private readonly libre?; private constructor(); static resolve(): CgmSource; /** Test/explicit constructor — pick a provider directly. */ static forProvider(provider: CgmProvider, clients?: { dexcom?: DexcomClient; libre?: LibreLinkUpClient; }): CgmSource; hasAuth(): boolean; mode(): "live" | "mock"; /** * Load readings over the last `hours`. Falls back to synthetic mock data when * the active provider has no auth configured. */ loadReadings(hours: number): Promise; /** * Load readings across an explicit [startMs, endMs] window (used by hypo * detection). Mock mode synthesises a span that covers the window. */ loadReadingsWindow(startMs: number, endMs: number): Promise; status(): CgmSourceStatus; }