import { AmplitudeAI } from "./client.js";

//#region src/middleware.d.ts

/** A static value or a `(req) => value` resolver for per-request values. */
type ValueOrResolver<T> = T | ((req: unknown) => T | null) | null;
interface MiddlewareOptions {
  amplitudeAI: AmplitudeAI;
  userIdResolver: (req: unknown) => string | null;
  sessionIdResolver?: (req: unknown) => string;
  agentId?: string | null;
  env?: string | null;
  /** Agent code version applied to every request's session. */
  agentVersion?: string | null;
  /** End-customer org for multi-tenant platforms (static or per-request). */
  customerOrgId?: ValueOrResolver<string>;
  /** Segmentation context dict (static or per-request). */
  context?: ValueOrResolver<Record<string, unknown>>;
  /** Group-analytics dict (static or per-request). */
  groups?: ValueOrResolver<Record<string, unknown>>;
  trackSessionEvents?: boolean;
  flushOnResponse?: boolean;
}
interface ExpressLikeRequest {
  headers: Record<string, string | string[] | undefined>;
}
interface ExpressLikeResponse {
  on: (event: string, callback: () => void) => void;
}
/**
 * Creates Express-compatible middleware.
 *
 * Usage:
 *   app.use(createAmplitudeAIMiddleware({
 *     amplitudeAI: ai,
 *     userIdResolver: (req) => req.headers['x-user-id'],
 *   }));
 */
declare function createAmplitudeAIMiddleware(options: MiddlewareOptions): (req: ExpressLikeRequest, res: ExpressLikeResponse, next: () => void) => void;
//#endregion
export { MiddlewareOptions, createAmplitudeAIMiddleware };
//# sourceMappingURL=middleware.d.ts.map