/** * Local delivery (--deliver / --deliver-exec) * * Mirrors server-answered captures to the developer's own machine: an HTTP * POST to a local server, a shell command per request, or both. The cloud * endpoint has already answered the provider by the time an entry lands * here, so delivery is strictly best-effort - a dead local server or a * crashing command never affects the endpoint, and every capture stays in * the log for `otterkit replay`. */ import { RequestEntry } from './request-log.js'; /** * Normalize a --deliver target to a base URL. Accepts a bare port ("3000"), * host:port, or a full http(s) URL with an optional path prefix. * Returns null when the value parses to none of those. */ export declare function parseDeliverTarget(raw: string): string | null; export type DeliveryResult = { kind: 'http'; status: number; durationMs: number; } | { kind: 'exec'; exitCode: number | null; durationMs: number; timedOut?: boolean; } | { kind: 'skipped'; reason: 'unverified'; } | { kind: 'dropped'; count: number; } | { kind: 'failed'; via: 'http' | 'exec'; error: string; suppressedSinceLastNotice?: number; }; interface DelivererConfig { /** Base URL from parseDeliverTarget - HTTP delivery when set. */ target?: string; /** Shell command run per capture - exec delivery when set. */ exec?: string; /** Only deliver captures whose signature verified valid. */ verifiedOnly?: boolean; /** Endpoint subdomain, sent along as X-OtterKit-Endpoint / OTTERKIT_ENDPOINT. */ endpoint: string; /** Full public URL, sent to exec targets as OTTERKIT_PUBLIC_URL (derived from the tunnel server when absent). */ publicUrl?: string; onResult: (entry: RequestEntry, result: DeliveryResult) => void; } /** * Sequential delivery queue: one capture fully delivered (HTTP, then exec) * before the next starts. Ordering matches arrival, and a replay burst can * never stampede the local server. */ export declare class Deliverer { private config; private queue; private pumping; private droppedSinceNotice; private consecutiveHttpFailures; private suppressedSinceNotice; private lastFailureNoticeAt; constructor(config: DelivererConfig); push(entry: RequestEntry): void; /** Let in-flight work finish, up to graceMs. Pending queue is abandoned. */ drain(graceMs: number): Promise; private pump; private buildMetadata; private deliverHttp; private deliverExec; } export {};