import { Journal } from "./journal.js";
import { Fixture, HandlerDefaults, VideoResponse } from "./types.js";
import { VideoStateMap } from "./video.js";
import * as http$1 from "node:http";

//#region src/grok-video.d.ts
declare const GROK_VIDEO_MAX_ENTRIES = 10000;
type GrokVideoStatus = "pending" | "in_progress" | "completed" | "failed";
interface GrokVideoReplayJob {
  kind: "replay";
  requestId: string;
  status: GrokVideoStatus;
  /** Number of status polls the caller has made against this job. */
  pollCount: number;
  /** Poll-count threshold for `pending → in_progress` transition. */
  pollsBeforeInProgress: number;
  /** Poll-count threshold for the transition to the terminal status. */
  pollsBeforeCompleted: number;
  /** The matched fixture's video object (terminal status, url, duration, cost, error). */
  video: VideoResponse["video"];
  /** Latch for the empty-`error` authoring warn on failed polls (once per job). */
  emptyErrorWarned?: boolean;
}
/**
 * A job whose lifecycle is proxied live upstream (record mode, no fixture
 * matched at submit). Every client poll is forwarded 1:1 to
 * `upstreamPollingUrl`; when the upstream reports a terminal status (`done`/
 * `failed`) the entry is captured as a fixture and MUTATED into a terminal
 * GrokVideoReplayJob. `expired` (and any unrepresentable status) pass through
 * with a warn and keep proxying. Under `record.proxyOnly` nothing is ever
 * captured or mutated.
 */
interface GrokVideoRecordJob {
  kind: "record";
  /** The mock-issued requestId the client polls with. */
  requestId: string;
  /** Last upstream status relayed to the client. */
  status: GrokVideoStatus;
  /** Upstream's own request id (recorded as the fixture's video.id). */
  upstreamRequestId: string;
  /** Origin-validated absolute upstream URL proxied on every client poll. */
  upstreamPollingUrl: string;
  /** Match snapshot built at submit time (post requestTransform). */
  match: Fixture["match"];
  /**
   * Set synchronously before the first await of the eager-capture sequence so
   * a concurrent terminal poll relays the upstream body instead of starting a
   * second capture/persist.
   */
  capturing?: boolean;
}
type GrokVideoJob = GrokVideoReplayJob | GrokVideoRecordJob;
/**
 * Per-testId job state for the Grok video handler. Mirrors OpenRouterVideoJobMap
 * (openrouter-video.ts): lazy TTL eviction on `get`, FIFO eviction of the
 * oldest entries on `set` when over capacity, delete-before-set TTL refresh,
 * monotonic world-generation counter for reset-mid-flight detection, no
 * background sweep timer. Keys are `${testId}:${requestId}`.
 */
declare class GrokVideoJobMap {
  private readonly entries;
  private worldGeneration;
  get generation(): number;
  get(key: string): GrokVideoJob | undefined;
  set(key: string, job: GrokVideoJob): void;
  delete(key: string): boolean;
  clear(): void;
  get size(): number;
}
declare function handleGrokVideoCreate(req: http$1.IncomingMessage, res: http$1.ServerResponse, raw: string, fixtures: Fixture[], journal: Journal, defaults: HandlerDefaults, setCorsHeaders: (res: http$1.ServerResponse) => void, jobs: GrokVideoJobMap): Promise<void>;
declare function handleGrokVideoStatus(req: http$1.IncomingMessage, res: http$1.ServerResponse, id: string, fixtures: Fixture[], journal: Journal, defaults: HandlerDefaults, setCorsHeaders: (res: http$1.ServerResponse) => void, grokJobs: GrokVideoJobMap, videoStates: VideoStateMap): Promise<void>;
//#endregion
export { GROK_VIDEO_MAX_ENTRIES, GrokVideoJobMap, handleGrokVideoCreate, handleGrokVideoStatus };
//# sourceMappingURL=grok-video.d.ts.map