import { z } from 'zod'; import type { FastifyInstance } from 'fastify'; import type { DB } from '../../storage/db.js'; import { type Config } from '../../config/config.js'; export declare const TranscriptTurnSchema: z.ZodObject<{ role: z.ZodEnum<{ user: "user"; assistant: "assistant"; }>; text: z.ZodString; ts: z.ZodOptional; speaker: z.ZodOptional; }, z.core.$strip>; export declare const CanonicalEventItemSchema: z.ZodObject<{ type: z.ZodEnum<{ event: "event"; decision: "decision"; fact: "fact"; lesson: "lesson"; command: "command"; todo: "todo"; note: "note"; }>; text: z.ZodString; importance: z.ZodOptional; confidence: z.ZodOptional; evidence: z.ZodOptional; occurred_at: z.ZodOptional; }, z.core.$strip>; export declare const CanonicalIngestSchema: z.ZodObject<{ event: z.ZodEnum<{ subagent_stop: "subagent_stop"; session_end: "session_end"; pre_compact: "pre_compact"; }>; session_id: z.ZodString; project_id: z.ZodString; agent_type: z.ZodOptional; cwd: z.ZodOptional; captured_at: z.ZodString; kind: z.ZodDefault>>; turns: z.ZodOptional; text: z.ZodString; ts: z.ZodOptional; speaker: z.ZodOptional; }, z.core.$strip>>>; events: z.ZodOptional; text: z.ZodString; importance: z.ZodOptional; confidence: z.ZodOptional; evidence: z.ZodOptional; occurred_at: z.ZodOptional; }, z.core.$strip>>>; tool: z.ZodOptional; capture_source: z.ZodOptional>; platform: z.ZodOptional; meeting_id: z.ZodOptional; consent_disclosed: z.ZodOptional; extract_profile: z.ZodOptional>; proxy_usage: z.ZodOptional; model: z.ZodNullable; input_tokens: z.ZodNullable; output_tokens: z.ZodNullable; total_tokens: z.ZodNullable; cache_creation_input_tokens: z.ZodNullable; cache_read_input_tokens: z.ZodNullable; stop_reason: z.ZodNullable; truncated: z.ZodBoolean; }, z.core.$strip>>; client_scrub_applied: z.ZodBoolean; client_scrub_hits: z.ZodNumber; client_version: z.ZodString; client_scrub_version: z.ZodString; client_scrub_hits_by_label: z.ZodOptional>; wire_version: z.ZodString; }, z.core.$strip>; export declare class IdempotentReplayError extends Error { readonly replayId: string; constructor(replayId: string); } export declare class IdempotencyConflictError extends Error { readonly idempotencyKey: string; constructor(idempotencyKey: string); } /** * ADR-017 decision 3 / FEAT-491: a meeting-captions envelope is rejected * unless the OPERATOR RUNNING THIS DAEMON has also explicitly opted in * (`captureSource.meetingCaptions.enabled: true`, default `false`) — * defense-in-depth on top of the plugin's own client-side opt-in gate and * the schema-level `consent_disclosed` requirement (zod superRefine above, * which zod cannot cross-reference runtime config for). Thrown, not a zod * issue, because config is only available here, not inside the pure schema. */ export declare class MeetingCaptionsDisabledError extends Error { constructor(); } export interface CanonicalTranscriptIngestResult { transcriptId: string; jobId: string; /** Server-side redaction hit count (SEC-3/5) — surfaced in the HTTP * response's scrub_hits.server field. */ serverRedactionHits: number; } /** * Insert one canonical transcript-kind envelope: stage-0 redact -> session * upsert -> transcripts insert -> distill job enqueue, honoring the same * Idempotency-Key semantics `POST /ingest/transcript` applies (D-B1/B2/B3). * * Throws `IdempotentReplayError` when `idempotencyKey` already resolved to a * still-live transcript/memory with a matching body hash (valid replay), and * `IdempotencyConflictError` when the same key was reused with a DIFFERENT * body. Callers decide how to surface those — the HTTP route maps them to * 200/409; the spool drain worker (src/ingest/spool-drain.ts) treats a * replay as a successful drain (delete the spool file, move on) and a * conflict as a quarantine reason (a spooled envelope's key is a content * hash, so a genuine conflict means the row was independently created with a * different body under the same key — not self-healing via retry). * * Statements are prepared per call rather than hoisted like the route's * factory-scoped ones (D-B6) — this path runs once per HTTP request (already * dominated by redaction + a DB transaction) or once per spool-drain tick * (seconds-scale cadence), never in a tight loop, so the prepare cost is * immaterial; the SQL text below is a direct mirror of the route's own * statements (single source of truth for the shape). */ export declare function ingestCanonicalTranscript(db: DB, config: Config, data: z.infer, idempotencyKey: string | null, resolvedRepo?: string | null): CanonicalTranscriptIngestResult; export declare function ingestRoute(db: DB, config?: Config): (app: FastifyInstance) => Promise;