import { SupabaseMcpCapabilityKind, SupabaseMcpLifecycleEvent, SupabaseMcpLifecycleOutcome } from "./types.js"; import { SupabaseClient } from "@supabase/supabase-js"; //#region src/insights.d.ts declare const SLOW_STEP_THRESHOLD_MS = 10000; declare const UNLINKED_CALL_BUCKET_MS: number; type InsightsLookbackDays = 7 | 30 | 90; type CapabilityLabelMap = Readonly>; interface RawRunEvent { occurredAt: string; capabilityKind: SupabaseMcpCapabilityKind; capabilityName: string; durationMs: number | null; outcome: SupabaseMcpLifecycleOutcome; runId?: string | null; runStartedAt?: string | null; runRejected?: string | null; errorCode?: string | null; clientLabel?: string | null; } interface RunStep { kind: "call" | "loop"; label: string; capabilityNames: string[]; capabilityKinds: SupabaseMcpCapabilityKind[]; callCount: number; cycleCount?: number; startedAt: string; endedAt: string; durationMs: number | null; outcome: SupabaseMcpLifecycleOutcome; friction: boolean; slow: boolean; inputRequired: boolean; errorCodes: string[]; } interface RunTimeline { runId: string; startedAt: string; endedAt: string; totalDurationMs: number; callCount: number; steps: RunStep[]; hasFriction: boolean; hasSlowStep: boolean; errorCount: number; inputRequiredCount: number; clientLabel?: string | null; } interface UnlinkedCallGroup { windowStart: string; windowEnd: string; callCount: number; rejectedHandleCount: number; totalDurationMs: number; steps: RunStep[]; hasFriction: boolean; hasSlowStep: boolean; } interface BuildRunTimelineOptions { labels?: CapabilityLabelMap; slowThresholdMs?: number; unlinkedBucketMs?: number; } type SupabaseMcpEventSink = (event: SupabaseMcpLifecycleEvent) => void | Promise; /** * Fan out each lifecycle event to every configured sink without letting one * failing sink block another. If any sink fails, throws after all sinks finish * so the runtime's `onError({ phase: "events" })` hook still observes it. */ declare function composeEventSinks(...sinks: ReadonlyArray): SupabaseMcpEventSink; interface CreateTelemetrySinkOptions { /** * Service-role Supabase client (or lazy factory) authorized to invoke * `public.chumbo_telemetry_ingest_v2`. */ supabase: SupabaseClient | (() => SupabaseClient); /** Stable installation identifier. Defaults to `"self-hosted"`. */ installationId?: string; /** Stable MCP surface identifier. Defaults to `"default"`. */ surfaceId?: string; /** * Optional bounded ASCII error-code extractor (`^[A-Za-z0-9_.:-]{1,64}$`). * Never return free-text error messages or caller arguments. */ resolveErrorCode?: (event: Extract) => string | null | undefined; } /** * Create a payload-free `onEvent` sink writing directly to `chumbo_telemetry` * (`chumbo-telemetry@2`) inside your own Supabase project. */ declare function createTelemetrySink(options: CreateTelemetrySinkOptions): SupabaseMcpEventSink; declare function humanizeCapabilityName(name: string, labels?: CapabilityLabelMap): string; declare function collapseStepRepeats(events: readonly RawRunEvent[], options?: { labels?: CapabilityLabelMap; slowThresholdMs?: number; }): RunStep[]; declare function buildRunTimeline(rawEvents: readonly RawRunEvent[], options?: BuildRunTimelineOptions): { runs: RunTimeline[]; unlinkedCalls: UnlinkedCallGroup[]; }; interface PrincipalIdentityOverride { displayName?: string; email?: string | null; } interface CreateSupabaseInsightsAdapterOptions { supabase: SupabaseClient; installationId?: string; surfaceId?: string; projectSlug?: string; projectLabel?: string; labels?: CapabilityLabelMap; resolvePrincipal?: (subjectIds: readonly string[]) => Readonly> | Promise>>; } /** * Create a client-safe `InsightsAdapter` backed by the `chumbo_insights_*` * RPCs installed by `chumbo-telemetry@2` (`chumbo setup --insights`). */ declare function createSupabaseInsightsAdapter(options: CreateSupabaseInsightsAdapterOptions): { loadAggregate(input: { lookbackDays: InsightsLookbackDays; }): Promise<{ schemaVersion: 1; project: { slug: string; label: string; }; servedAt: string; data: any; }>; loadPeople(input: { lookbackDays: InsightsLookbackDays; }): Promise<{ period: any; people: any[]; }>; loadMemberRuns(input: { memberId: string; lookbackDays: InsightsLookbackDays; before?: string; limit?: number; }): Promise<{ member: any; period: { lookbackDays: InsightsLookbackDays; from: string; to: string; }; runs: RunTimeline[]; unlinkedCalls: UnlinkedCallGroup[]; hasMore: boolean; nextBefore: any; }>; }; //#endregion export { BuildRunTimelineOptions, CapabilityLabelMap, CreateSupabaseInsightsAdapterOptions, CreateTelemetrySinkOptions, InsightsLookbackDays, PrincipalIdentityOverride, RawRunEvent, RunStep, RunTimeline, SLOW_STEP_THRESHOLD_MS, SupabaseMcpEventSink, UNLINKED_CALL_BUCKET_MS, UnlinkedCallGroup, buildRunTimeline, collapseStepRepeats, composeEventSinks, createSupabaseInsightsAdapter, createTelemetrySink, humanizeCapabilityName }; //# sourceMappingURL=insights.d.ts.map