/**
 * handlers.ts — framework-agnostic feedback-receiver request handler.
 *
 * Faithful port of `handleSubmit` from the reference receiver
 * (the-portal/pages/api/instar/feedback.ts), lifted out of Next.js into a pure
 * request→response function over the FeedbackStore interface + the ported intake
 * defenses (defense.ts). The canonical front (Vercel function / Next route /
 * instar server) is a thin binding that maps its req/res to this. This is the
 * reusable "recipe"; the operated deploy supplies the framework binding + the
 * real (Prisma) store.
 *
 * Reproduces handleSubmit's EXACT order, status codes, and error messages so a
 * deployed agent's feedback sender behaves identically. Notably the reference
 * DEFAULTS an invalid `type` to 'other' (does NOT reject it) — see the note in
 * defense.ts about the superseded validateFeedbackInput helper.
 */
import { type RateLimiter } from './defense.js';
import type { FeedbackStore } from '../store/FeedbackStore.js';
export interface FeedbackRequest {
    headers: Record<string, string | string[] | undefined>;
    body: unknown;
    remoteAddress?: string;
}
export interface FeedbackResponse {
    status: number;
    headers?: Record<string, string>;
    json: unknown;
}
/**
 * The narrow store surface the SUBMIT path actually uses (dedup + write). The full
 * `FeedbackStore` satisfies it structurally; the canonical front's Blob-backed
 * inbox store implements it asynchronously (Vercel Blob is REST). Methods may be
 * sync or async — the handler awaits both, so decision order, status codes, and
 * messages are unchanged for the existing synchronous stores.
 */
export interface ReceiverStore {
    hasFeedback(feedbackId: string): boolean | Promise<boolean>;
    addFeedback(item: Parameters<FeedbackStore['addFeedback']>[0]): void | Promise<void>;
}
export interface FeedbackHandlerDeps {
    store: ReceiverStore;
    rateLimiter: RateLimiter;
    /** Normalized webhook secret (see normalizeWebhookSecret); undefined ⇒ unsigned-but-accepted. */
    secret: string | undefined;
    /** Injected clock (ms) for the HMAC replay window. */
    now: number;
    /** Injected id generator (defaults to the reference's `fb-<base36 time>-<rand>`). */
    generateFeedbackId?: () => string;
}
/**
 * Port of handleSubmit. Returns the status/headers/json the canonical front sends
 * back. Async because the canonical front's store is REST-backed (Vercel Blob);
 * for synchronous stores the awaits are no-ops and behavior is byte-identical.
 */
export declare function handleFeedbackSubmit(req: FeedbackRequest, deps: FeedbackHandlerDeps): Promise<FeedbackResponse>;
//# sourceMappingURL=handlers.d.ts.map