/** * The project **context document** — `GET /api/v1/context` (ADR 0051 §5, design * sketch §E.1). * * Agents start blind. They know the *shape* of the read surface from the metric * registry, but nothing about the project in front of them: what its scenes are * called, which regions have names, which capture channels are even on, what the * application calls its own events, whether raw retention is enabled, or how * fresh the data is. Every one of those is a guess an agent would otherwise make * badly — asking for `scene=lobby` when the scene is `main-hall`, reporting a * zero from a disabled channel as a finding, filtering on a custom event name * that does not exist. * * This route answers all of it in one read, assembled entirely from aggregates * and registry rows the collector already serves. It is: * * - **bounded** — every list is capped (see the `MAX_*` constants), so the whole * document stays comfortably inside the budget a small local model can carry * in its system prompt; `context.test.ts` asserts the fixture project's * document is under 16 KB; * - **cached** — briefly, per project ({@link CONTEXT_CACHE_TTL_MS}), because an * assistant re-reads it on every session start and it costs half a dozen * aggregate queries to build; * - **read-only and aggregate-only** — no raw event, no session id, no prop * value, nothing a caller could not already read through the query API * (ADR 0003). * * It is deliberately **not** a registry metric: it is not an aggregation over * the event stream with a row grain, it is a description of the project. It is * described in the OpenAPI document by hand, alongside the other non-metric * routes (`routes/meta.ts`). */ import type { FastifyPluginAsync } from "fastify"; import { z } from "zod"; import type { CollectorConfig } from "../config.js"; import type { CollectorStore } from "../store.js"; import { type ProjectMetadataProvider } from "../projectMetadata.js"; export interface ContextRoutesOptions { store: CollectorStore; config: CollectorConfig; /** * Source of the glossary and recent annotations. Defaults to the empty * provider until the metadata write path exists (see `projectMetadata.ts`). */ metadata?: ProjectMetadataProvider; } /** How long a built document is reused for the same project. */ export declare const CONTEXT_CACHE_TTL_MS = 30000; /** * The context document. Declared as Zod so it validates on the way out like * every other response, and so the OpenAPI description in `meta.ts` and this * shape cannot drift apart silently. */ export declare const projectContextSchema: z.ZodObject<{ project: z.ZodObject<{ id: z.ZodString; store: z.ZodString; schemaVersion: z.ZodString; collectorVersion: z.ZodString; }, z.core.$strip>; dataQuality: z.ZodObject<{ lastEventAt: z.ZodNullable; sessions24h: z.ZodNumber; events24h: z.ZodNumber; retention: z.ZodObject<{ rawSessions: z.ZodBoolean; }, z.core.$strip>; }, z.core.$strip>; capture: z.ZodObject<{ channels: z.ZodRecord; }, z.core.$strip>>; }, z.core.$strip>; scenes: z.ZodArray; regions: z.ZodArray>; proxy: z.ZodBoolean; events28d: z.ZodNumber; }, z.core.$strip>>; vocabulary: z.ZodObject<{ customEvents: z.ZodArray; }, z.core.$strip>>; meshes: z.ZodObject<{ count: z.ZodNumber; top: z.ZodArray; }, z.core.$strip>; inputActions: z.ZodArray; }, z.core.$strip>; definitions: z.ZodObject<{ funnels: z.ZodArray; segments: z.ZodArray; glossary: z.ZodArray>; }, z.core.$strip>; annotations: z.ZodObject<{ recent: z.ZodArray; }, z.core.$strip>; text: z.ZodString; at: z.ZodNumber; }, z.core.$strip>>; }, z.core.$strip>; metrics: z.ZodObject<{ available: z.ZodArray; disabledByCapture: z.ZodArray; }, z.core.$strip>; window: z.ZodObject<{ since: z.ZodNumber; until: z.ZodNumber; }, z.core.$strip>; generatedAt: z.ZodNumber; }, z.core.$strip>; /** The project context document, as the route serves it. */ export type ProjectContext = z.infer; /** * The project context route. Registered as its own plugin so the query plugin — * which is the registry-metric surface, and is asserted against the registry * route by route — stays exactly that. */ export declare const contextRoutes: FastifyPluginAsync; //# sourceMappingURL=context.d.ts.map