{"version":3,"file":"index.mjs","names":[],"sources":["../../../../../../../../packages/ai-live/src/mock/index.ts"],"sourcesContent":["import type { Usage } from \"@warlock.js/ai\";\nimport type {\n  RealtimeConnectConfig,\n  RealtimeConnection,\n  RealtimeEvent,\n  RealtimeTransport,\n} from \"../contracts/realtime.contract\";\nimport type {\n  GeneratedVideo,\n  VideoGenerationResponse,\n  VideoModelContract,\n  VideoModelPricing,\n  VideoOptions,\n} from \"../contracts/video.contract\";\n\n/** One scripted response for a {@link MockVideoModel}. */\nexport type MockVideoResponse = {\n  video?: GeneratedVideo;\n  usage?: Usage;\n  durationSeconds?: number;\n  error?: Error;\n};\n\n/** Deterministic {@link VideoModelContract} double for tests — no HTTP, no polling. */\nexport class MockVideoModel implements VideoModelContract {\n  public readonly provider = \"mock\";\n  public readonly calls: { prompt: string; options: VideoOptions | undefined }[] = [];\n\n  private callIndex = 0;\n\n  public constructor(\n    public readonly name: string,\n    private readonly responses: MockVideoResponse[],\n    public readonly pricing?: VideoModelPricing,\n  ) {}\n\n  public async generate(prompt: string, options?: VideoOptions): Promise<VideoGenerationResponse> {\n    this.calls.push({ prompt, options });\n\n    const response = this.responses[Math.min(this.callIndex, this.responses.length - 1)] ?? {};\n    this.callIndex += 1;\n\n    if (response.error) {\n      throw response.error;\n    }\n\n    return {\n      video: response.video ?? {\n        type: \"url\",\n        url: \"https://mock/video.mp4\",\n        mediaType: \"video/mp4\",\n      },\n      usage: response.usage ?? { input: 0, output: 0, total: 0 },\n      durationSeconds: response.durationSeconds ?? options?.durationSeconds ?? 5,\n    };\n  }\n}\n\n/** A recording {@link RealtimeConnection} the mock transport hands back. */\nexport class MockRealtimeConnection implements RealtimeConnection {\n  public readonly sentAudio: { base64: string; mediaType: string }[] = [];\n  public readonly sentText: string[] = [];\n  public closed = false;\n\n  public constructor(private readonly scripted: RealtimeEvent[]) {}\n\n  public sendAudio(base64: string, mediaType: string): void {\n    this.sentAudio.push({ base64, mediaType });\n  }\n\n  public sendText(text: string): void {\n    this.sentText.push(text);\n  }\n\n  public async *events(): AsyncIterable<RealtimeEvent> {\n    for (const event of this.scripted) {\n      yield event;\n    }\n  }\n\n  public async close(): Promise<void> {\n    this.closed = true;\n  }\n}\n\n/** Deterministic {@link RealtimeTransport} double — scripts the event stream, records sends. */\nexport class MockRealtimeTransport implements RealtimeTransport {\n  public readonly connectConfigs: RealtimeConnectConfig[] = [];\n  public lastConnection?: MockRealtimeConnection;\n\n  public constructor(private readonly scriptedEvents: RealtimeEvent[] = []) {}\n\n  public async connect(config: RealtimeConnectConfig): Promise<RealtimeConnection> {\n    this.connectConfigs.push(config);\n    this.lastConnection = new MockRealtimeConnection(this.scriptedEvents);\n    return this.lastConnection;\n  }\n}\n"],"mappings":";;AAwBA,IAAa,iBAAb,MAA0D;CAMxD,AAAO,YACL,AAAgB,MAChB,AAAiB,WACjB,AAAgB,SAChB;EAHgB;EACC;EACD;kBARS;eACsD,CAAC;mBAE9D;CAMjB;CAEH,MAAa,SAAS,QAAgB,SAA0D;EAC9F,KAAK,MAAM,KAAK;GAAE;GAAQ;EAAQ,CAAC;EAEnC,MAAM,WAAW,KAAK,UAAU,KAAK,IAAI,KAAK,WAAW,KAAK,UAAU,SAAS,CAAC,MAAM,CAAC;EACzF,KAAK,aAAa;EAElB,IAAI,SAAS,OACX,MAAM,SAAS;EAGjB,OAAO;GACL,OAAO,SAAS,SAAS;IACvB,MAAM;IACN,KAAK;IACL,WAAW;GACb;GACA,OAAO,SAAS,SAAS;IAAE,OAAO;IAAG,QAAQ;IAAG,OAAO;GAAE;GACzD,iBAAiB,SAAS,mBAAmB,SAAS,mBAAmB;EAC3E;CACF;AACF;;AAGA,IAAa,yBAAb,MAAkE;CAKhE,AAAO,YAAY,AAAiB,UAA2B;EAA3B;mBAJiC,CAAC;kBACjC,CAAC;gBACtB;CAEgD;CAEhE,AAAO,UAAU,QAAgB,WAAyB;EACxD,KAAK,UAAU,KAAK;GAAE;GAAQ;EAAU,CAAC;CAC3C;CAEA,AAA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