@escapeaihq/client-core 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +122 -0
  3. package/dist/api.d.ts +836 -0
  4. package/dist/api.d.ts.map +1 -0
  5. package/dist/api.js +781 -0
  6. package/dist/api.js.map +1 -0
  7. package/dist/audio.d.ts +278 -0
  8. package/dist/audio.d.ts.map +1 -0
  9. package/dist/audio.js +758 -0
  10. package/dist/audio.js.map +1 -0
  11. package/dist/audioProtocol.d.ts +101 -0
  12. package/dist/audioProtocol.d.ts.map +1 -0
  13. package/dist/audioProtocol.js +62 -0
  14. package/dist/audioProtocol.js.map +1 -0
  15. package/dist/index.d.ts +28 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +28 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/visemeGeometry.d.ts +198 -0
  20. package/dist/visemeGeometry.d.ts.map +1 -0
  21. package/dist/visemeGeometry.js +297 -0
  22. package/dist/visemeGeometry.js.map +1 -0
  23. package/dist/visemeScheduler.d.ts +28 -0
  24. package/dist/visemeScheduler.d.ts.map +1 -0
  25. package/dist/visemeScheduler.js +94 -0
  26. package/dist/visemeScheduler.js.map +1 -0
  27. package/dist/websocket.d.ts +196 -0
  28. package/dist/websocket.d.ts.map +1 -0
  29. package/dist/websocket.js +250 -0
  30. package/dist/websocket.js.map +1 -0
  31. package/package.json +40 -0
  32. package/src/__tests__/api-pollers.test.ts +524 -0
  33. package/src/__tests__/audio.test.ts +714 -0
  34. package/src/__tests__/visemeGeometry.test.ts +465 -0
  35. package/src/__tests__/visemeScheduler.test.ts +256 -0
  36. package/src/api.ts +1577 -0
  37. package/src/audio.ts +934 -0
  38. package/src/audioProtocol.ts +163 -0
  39. package/src/index.ts +28 -0
  40. package/src/visemeGeometry.ts +353 -0
  41. package/src/visemeScheduler.ts +133 -0
  42. package/src/websocket.ts +385 -0
package/dist/api.d.ts ADDED
@@ -0,0 +1,836 @@
1
+ /**
2
+ * API client for the Seer Agent backend
3
+ */
4
+ import type { AudioFormat } from './audioProtocol';
5
+ import type { Citation } from './websocket';
6
+ export interface IngestionJob {
7
+ jobId: string;
8
+ videoId: string;
9
+ status: 'PENDING' | 'RUNNING' | 'SUCCEEDED' | 'FAILED';
10
+ startedAt?: string;
11
+ updatedAt?: string;
12
+ completedAt?: string;
13
+ shotsDetected?: number;
14
+ videoEmbeddingWritten?: boolean;
15
+ pegasusEnrichmentWritten?: boolean;
16
+ graphNodesWritten?: number;
17
+ graphEdgesWritten?: number;
18
+ s3Bucket?: string;
19
+ s3Key?: string;
20
+ errorMessage?: string;
21
+ videoDurationSeconds?: number;
22
+ transcribeJobName?: string;
23
+ transcriptWritten?: boolean;
24
+ transcriptFailed?: boolean;
25
+ transcriptS3Uri?: string;
26
+ dialogLinesWritten?: number;
27
+ }
28
+ export interface ListJobsResponse {
29
+ traceId: string;
30
+ results: IngestionJob[];
31
+ nextToken?: string | null;
32
+ }
33
+ export interface ApiError {
34
+ detail: string;
35
+ traceId?: string;
36
+ }
37
+ export interface UploadResponse {
38
+ traceId: string;
39
+ videoId: string;
40
+ s3Bucket: string;
41
+ s3Key: string;
42
+ jobStatusUrl: string;
43
+ uploadedAt: string;
44
+ }
45
+ export interface VideoListingEntry {
46
+ videoId: string;
47
+ filename: string;
48
+ key: string;
49
+ size: number;
50
+ etag?: string | null;
51
+ lastModified: string;
52
+ downloadUrl?: string | null;
53
+ streamUrl?: string | null;
54
+ durationSeconds?: number | null;
55
+ }
56
+ export interface ListVideosResponse {
57
+ traceId: string;
58
+ results: VideoListingEntry[];
59
+ nextToken?: string | null;
60
+ }
61
+ export type UploadProgressCallback = (progress: {
62
+ loaded: number;
63
+ total: number;
64
+ percentage: number;
65
+ }) => void;
66
+ export interface PegasusConfig {
67
+ pegasusPrompt?: string;
68
+ pegasusTemperature?: number;
69
+ pegasusMaxTokens?: number;
70
+ }
71
+ export interface EnrichVideoResponse {
72
+ traceId: string;
73
+ enrichmentId: string;
74
+ videoId: string;
75
+ jobId: string;
76
+ status: string;
77
+ }
78
+ export interface EnrichmentRecord {
79
+ enrichmentId: string;
80
+ videoId: string;
81
+ jobId: string;
82
+ status: string;
83
+ pegasusPrompt?: string;
84
+ pegasusTemperature?: number;
85
+ pegasusMaxTokens?: number;
86
+ result?: Record<string, unknown>;
87
+ createdAt: string;
88
+ completedAt?: string;
89
+ errorMessage?: string;
90
+ }
91
+ export interface ListEnrichmentsResponse {
92
+ traceId: string;
93
+ results: EnrichmentRecord[];
94
+ }
95
+ export interface VideoDeletionStats {
96
+ qdrant: boolean;
97
+ neo4jNodes: number;
98
+ neo4jRelationships: number;
99
+ s3Objects: number;
100
+ dynamodbRecords: number;
101
+ }
102
+ export interface VideoDeletionResponse {
103
+ traceId: string;
104
+ videoId: string;
105
+ deleted: VideoDeletionStats;
106
+ errors?: string[] | null;
107
+ }
108
+ export interface ChatMessage {
109
+ role: 'user' | 'assistant';
110
+ content: string;
111
+ }
112
+ export interface ChatStreamRequest {
113
+ prompt: string;
114
+ messages?: ChatMessage[];
115
+ videoId?: string;
116
+ systemPrompt?: string;
117
+ modelId?: string;
118
+ }
119
+ export interface PersonaConfig {
120
+ persona_id: string;
121
+ user_id: string;
122
+ name: string;
123
+ description?: string | null;
124
+ voice_id: string;
125
+ tts_model_id: string;
126
+ temperature: number;
127
+ speaking_rate: number;
128
+ audio_format: AudioFormat;
129
+ enable_markups: boolean;
130
+ chat_model_id: string;
131
+ custom_system_prompt?: string | null;
132
+ system_prompt_override: boolean;
133
+ heartbeat_interval: number;
134
+ idle_timeout: number;
135
+ video_id?: string | null;
136
+ /** ID of the rest-pose character image used as the source for viseme
137
+ * bundle generation. Set server-side by
138
+ * ``POST /api/v1/personas/{id}/character`` (generate-and-link) or
139
+ * via PATCH /api/v1/personas/{id} from a pre-existing tracked
140
+ * character image (the persona PATCH handler validates user image
141
+ * ownership before persisting). When absent, the chat-ws "Generate
142
+ * vectorized face" flow prompts the user to generate one first. */
143
+ character_image_id?: string | null;
144
+ viseme_bundle_id?: string | null;
145
+ viseme_prompt_overrides?: Record<string, string> | null;
146
+ /** Per-persona renderer tuning blob. Effective shape is
147
+ * ``Partial<TuningOverrides>`` (see web/app/chat-ws/CharacterFace.tsx)
148
+ * — every field optional, camelCase keys, validated server-side.
149
+ * Typed loosely as ``Record<string, unknown>`` here so this lib/
150
+ * file doesn't take a dependency on the chat-ws app/ tree; chat-ws
151
+ * code that consumes this casts to ``TuningOverrides``. Set via
152
+ * the dedicated PUT /visual-overrides endpoint, not PATCH /personas. */
153
+ visual_overrides?: Record<string, unknown> | null;
154
+ template_fields?: Record<string, string> | null;
155
+ prompt_addon_ids?: string[] | null;
156
+ is_default: boolean;
157
+ status: 'pending' | 'approved';
158
+ created_at: string;
159
+ updated_at: string;
160
+ }
161
+ export type VisemeBundleStatus = 'pending' | 'complete' | 'failed';
162
+ export type VisemeRegenStatusValue = 'pending' | 'complete' | 'failed';
163
+ export interface VisemeRegenStatus {
164
+ status: VisemeRegenStatusValue;
165
+ started_at: string;
166
+ error_message?: string | null;
167
+ }
168
+ export interface VisemeBundleRecord {
169
+ bundle_id: string;
170
+ persona_id: string;
171
+ user_id: string;
172
+ status: VisemeBundleStatus;
173
+ viewbox_width?: number | null;
174
+ viewbox_height?: number | null;
175
+ lip_fill?: string | null;
176
+ body_svg_s3_key?: string | null;
177
+ viseme_png_s3_keys?: Record<string, string> | null;
178
+ body_svg?: string | null;
179
+ mouth_paths?: Record<string, string> | null;
180
+ error_message?: string | null;
181
+ model_version?: string | null;
182
+ viseme_regen_status?: Record<string, VisemeRegenStatus> | null;
183
+ created_at: string;
184
+ updated_at: string;
185
+ }
186
+ export interface RegenerateVisemeAccept {
187
+ bundle_id: string;
188
+ viseme: string;
189
+ status: VisemeRegenStatusValue;
190
+ status_url: string;
191
+ traceId: string;
192
+ }
193
+ export type ImageCategory = 'extracted' | 'regenerated' | 'character';
194
+ /** Async-generation lifecycle. Existing rows written before the async
195
+ * conversion deserialize as ``complete`` (the backend default). */
196
+ export type ImageStatus = 'pending' | 'complete' | 'failed';
197
+ export interface ImageRecord {
198
+ image_id: string;
199
+ user_id: string;
200
+ s3_key: string;
201
+ s3_bucket: string;
202
+ category: ImageCategory;
203
+ content_type: string;
204
+ image_url?: string | null;
205
+ file_size_bytes?: number | null;
206
+ source_video_id?: string | null;
207
+ source_entity?: string | null;
208
+ source_timestamp?: number | null;
209
+ prompt?: string | null;
210
+ model?: string | null;
211
+ parent_image_id?: string | null;
212
+ persona_id?: string | null;
213
+ tags?: string[] | null;
214
+ grid_columns?: number | null;
215
+ grid_rows?: number | null;
216
+ /** Async-generation lifecycle. ``pending`` rows are still being
217
+ * generated (Gemini call in flight); the gallery hides them. Existing
218
+ * rows written before the async conversion default to ``complete``. */
219
+ status?: ImageStatus;
220
+ /** Diagnostic message when ``status === 'failed'`` (truncated to
221
+ * 500 chars server-side). */
222
+ error_message?: string | null;
223
+ created_at: string;
224
+ updated_at: string;
225
+ }
226
+ export interface ImageListResponse {
227
+ images: ImageRecord[];
228
+ total: number;
229
+ next_token?: string | null;
230
+ }
231
+ export interface UpdateImageRequest {
232
+ persona_id?: string | null;
233
+ tags?: string[] | null;
234
+ source_video_id?: string | null;
235
+ source_entity?: string | null;
236
+ }
237
+ /** Metadata describing the origin system for a response payload. Mirrors
238
+ * `api/tools/schemas.py::SourceMetadata`. */
239
+ export interface SourceMetadata {
240
+ system: string;
241
+ details?: Record<string, unknown> | null;
242
+ }
243
+ export interface ExtractImageRequest {
244
+ videoId: string;
245
+ entity: string;
246
+ /** Optional explicit timestamp (seconds). If omitted the backend looks
247
+ * up the entity's first occurrence via Neo4j entity_timeline. */
248
+ timestamp?: number | null;
249
+ }
250
+ export interface ExtractImageResponse {
251
+ traceId: string;
252
+ /** Presigned S3 URL for immediate display only. The URL has a short
253
+ * TTL (typically 1h) and will 403 once expired — persist `imageS3Key`
254
+ * if you need a stable handle and re-presign on read. */
255
+ imageUrl: string;
256
+ imageS3Key: string;
257
+ sourceTimestamp: number;
258
+ entity: string;
259
+ citation: Citation;
260
+ source: SourceMetadata;
261
+ }
262
+ export interface RegenerateImageRequest {
263
+ videoId: string;
264
+ entity: string;
265
+ /** Style prompt fed to Gemini Flash Image. 1-2000 chars. */
266
+ prompt: string;
267
+ timestamp?: number | null;
268
+ /** Optional model override. Backend description in
269
+ * `api/tools/schemas.py::RegenerateImageRequest` lists these two
270
+ * values; omit for backend default with auto-fallback on 503. The
271
+ * union is intentionally strict — extend it here when the backend
272
+ * adds a new model. */
273
+ model?: 'gemini-3.1-flash-image-preview' | 'gemini-2.5-flash-image' | null;
274
+ }
275
+ export interface RegenerateImageResponse {
276
+ traceId: string;
277
+ /** Presigned S3 URL for immediate display only. The URL has a short
278
+ * TTL (typically 1h) and will 403 once expired — persist `imageS3Key`
279
+ * if you need a stable handle and re-presign on read. */
280
+ imageUrl: string;
281
+ imageS3Key: string;
282
+ sourceTimestamp: number;
283
+ entity: string;
284
+ prompt: string;
285
+ citation: Citation;
286
+ source: SourceMetadata;
287
+ }
288
+ export interface GenerateCharacterRequest {
289
+ videoId?: string | null;
290
+ entity?: string | null;
291
+ timestamp?: number | null;
292
+ sourceImageId?: string | null;
293
+ style?: string | null;
294
+ model?: string | null;
295
+ }
296
+ /** 202 Accepted envelope for async character generation.
297
+ *
298
+ * Gemini takes up to 150s; CloudFront's `OriginReadTimeout` is 60s
299
+ * (quota-locked). The endpoint returns this envelope immediately and
300
+ * the caller polls `statusUrl` (== `/api/v1/images/{characterImageId}`)
301
+ * via `getImage()` until `status` flips to `'complete'` or `'failed'`.
302
+ * `pollImageUntilDone()` wraps that loop. */
303
+ export interface GenerateCharacterResponse {
304
+ traceId: string;
305
+ characterImageId: string;
306
+ status: 'pending';
307
+ statusUrl: string;
308
+ }
309
+ export interface CreatePersonaRequest {
310
+ name: string;
311
+ description?: string | null;
312
+ voice_id?: string;
313
+ tts_model_id?: string;
314
+ temperature?: number;
315
+ speaking_rate?: number;
316
+ audio_format?: AudioFormat;
317
+ enable_markups?: boolean;
318
+ chat_model_id?: string;
319
+ custom_system_prompt?: string | null;
320
+ system_prompt_override?: boolean;
321
+ heartbeat_interval?: number;
322
+ idle_timeout?: number;
323
+ video_id?: string | null;
324
+ /** Optional rest-pose character image ID set at creation time. The
325
+ * server validates ownership the same way the PATCH handler does. See
326
+ * PersonaConfig.character_image_id for the read shape. */
327
+ character_image_id?: string | null;
328
+ template_fields?: Record<string, string>;
329
+ prompt_addon_ids?: string[];
330
+ is_default?: boolean;
331
+ status?: 'pending' | 'approved';
332
+ }
333
+ export interface UpdatePersonaRequest {
334
+ name?: string | null;
335
+ description?: string | null;
336
+ voice_id?: string | null;
337
+ tts_model_id?: string | null;
338
+ temperature?: number | null;
339
+ speaking_rate?: number | null;
340
+ audio_format?: AudioFormat | null;
341
+ enable_markups?: boolean | null;
342
+ chat_model_id?: string | null;
343
+ custom_system_prompt?: string | null;
344
+ system_prompt_override?: boolean | null;
345
+ heartbeat_interval?: number | null;
346
+ idle_timeout?: number | null;
347
+ video_id?: string | null;
348
+ /** Server-side image ownership is validated by the persona PATCH handler.
349
+ * **To CLEAR an existing image, send an empty string `""`, not `null`.**
350
+ * The store contract treats `null`/`undefined` as "skip this field" and
351
+ * only an empty string as "remove it" — sending `null` from a clear UI
352
+ * silently no-ops and leaves the old image attached. See
353
+ * web/lib/api.ts PersonaConfig for the read shape. */
354
+ character_image_id?: string | null;
355
+ template_fields?: Record<string, string> | null;
356
+ prompt_addon_ids?: string[] | null;
357
+ is_default?: boolean | null;
358
+ status?: 'pending' | 'approved';
359
+ }
360
+ export interface PersonaListResponse {
361
+ personas: PersonaConfig[];
362
+ total: number;
363
+ next_token?: string | null;
364
+ }
365
+ export interface SynthesizedPersona {
366
+ name: string;
367
+ description: string;
368
+ entity_type: string;
369
+ custom_system_prompt: string;
370
+ }
371
+ export interface SynthesizePersonasResponse {
372
+ personas: SynthesizedPersona[];
373
+ model_id: string;
374
+ video_id: string;
375
+ }
376
+ export interface VoiceInfo {
377
+ voiceId: string;
378
+ displayName: string;
379
+ description: string;
380
+ languages: string[];
381
+ tags: string[];
382
+ isCustom: boolean;
383
+ }
384
+ export interface SessionMessage {
385
+ role: string;
386
+ content: string;
387
+ timestamp?: string;
388
+ metadata?: Record<string, unknown>;
389
+ }
390
+ export interface ChatSession {
391
+ session_id: string;
392
+ user_id: string;
393
+ persona_id?: string | null;
394
+ video_id?: string | null;
395
+ messages: SessionMessage[];
396
+ title?: string | null;
397
+ created_at: string;
398
+ updated_at: string;
399
+ last_message_at?: string | null;
400
+ }
401
+ export interface CreateSessionRequest {
402
+ persona_id?: string | null;
403
+ video_id?: string | null;
404
+ title?: string | null;
405
+ }
406
+ export interface AddMessageRequest {
407
+ role: string;
408
+ content: string;
409
+ metadata?: Record<string, unknown>;
410
+ }
411
+ export interface SessionListResponse {
412
+ sessions: ChatSession[];
413
+ total: number;
414
+ next_token?: string | null;
415
+ }
416
+ export interface TranscriptLine {
417
+ text: string;
418
+ speaker: string;
419
+ t0: number;
420
+ t1: number;
421
+ shotId?: string;
422
+ }
423
+ export interface GetTranscriptResponse {
424
+ traceId: string;
425
+ videoId: string;
426
+ lines: TranscriptLine[];
427
+ }
428
+ export interface DialogSearchResult {
429
+ dialogId: string;
430
+ text: string;
431
+ speaker: string;
432
+ t0: number;
433
+ t1: number;
434
+ shotId?: string;
435
+ videoId: string;
436
+ }
437
+ export interface DialogSearchResponse {
438
+ traceId: string;
439
+ results: DialogSearchResult[];
440
+ }
441
+ export interface NarrativeAct {
442
+ act: number;
443
+ timeRange: string;
444
+ description: string;
445
+ }
446
+ export interface NarrativeData {
447
+ summary: string;
448
+ acts: NarrativeAct[];
449
+ mainCharacters: string[];
450
+ themes: string[];
451
+ }
452
+ export interface GraphNode {
453
+ id: string;
454
+ label: string;
455
+ properties: Record<string, unknown>;
456
+ }
457
+ export interface GraphEdge {
458
+ id: string;
459
+ source: string;
460
+ target: string;
461
+ type: string;
462
+ properties: Record<string, unknown>;
463
+ }
464
+ export interface VideoGraphResponse {
465
+ traceId: string;
466
+ videoId: string;
467
+ nodes: GraphNode[];
468
+ edges: GraphEdge[];
469
+ }
470
+ export interface UpdateNodeRequest {
471
+ nodeLabel: string;
472
+ idProperty: string;
473
+ idValue: string;
474
+ properties: Record<string, unknown>;
475
+ }
476
+ export interface UpdateNodeResponse {
477
+ traceId: string;
478
+ properties: Record<string, unknown>;
479
+ }
480
+ export interface DeleteNodeRequest {
481
+ nodeLabel: string;
482
+ idProperty: string;
483
+ idValue: string;
484
+ }
485
+ export interface DeleteNodeResponse {
486
+ traceId: string;
487
+ deleted: number;
488
+ }
489
+ export interface UpdateRelationshipRequest {
490
+ sourceId: string;
491
+ targetId: string;
492
+ relType: string;
493
+ properties: Record<string, unknown>;
494
+ }
495
+ export interface UpdateRelationshipResponse {
496
+ traceId: string;
497
+ properties: Record<string, unknown>;
498
+ }
499
+ export interface DeleteRelationshipRequest {
500
+ sourceId: string;
501
+ targetId: string;
502
+ relType: string;
503
+ }
504
+ export interface DeleteRelationshipResponse {
505
+ traceId: string;
506
+ deleted: number;
507
+ }
508
+ export declare class ApiClient {
509
+ private baseURL;
510
+ private sessionToken?;
511
+ private chatApiBaseUrl;
512
+ constructor(baseURL: string, sessionToken: string | undefined, chatBaseUrl: string);
513
+ setSessionToken(token: string | undefined): void;
514
+ private request;
515
+ private chatRequest;
516
+ private makeRequest;
517
+ /**
518
+ * List all ingestion jobs with optional filtering
519
+ */
520
+ listJobs(params?: {
521
+ status?: string;
522
+ limit?: number;
523
+ nextToken?: string;
524
+ }): Promise<ListJobsResponse>;
525
+ /**
526
+ * Get a specific ingestion job by video ID
527
+ */
528
+ getJob(videoId: string): Promise<{
529
+ traceId: string;
530
+ job: IngestionJob;
531
+ }>;
532
+ /**
533
+ * List succeeded videos (for chat selector)
534
+ */
535
+ listSucceededVideos(params?: {
536
+ limit?: number;
537
+ nextToken?: string;
538
+ }): Promise<ListJobsResponse>;
539
+ /**
540
+ * List staged videos in the ingestion bucket
541
+ */
542
+ listVideos(params?: {
543
+ prefix?: string;
544
+ pageSize?: number;
545
+ continuationToken?: string;
546
+ }): Promise<ListVideosResponse>;
547
+ /**
548
+ * Upload a video file with progress tracking
549
+ */
550
+ uploadVideo(file: File, onProgress?: UploadProgressCallback): Promise<UploadResponse>;
551
+ /**
552
+ * Trigger Pegasus enrichment analysis on an ingested video
553
+ */
554
+ enrichVideo(videoId: string, config?: PegasusConfig): Promise<EnrichVideoResponse>;
555
+ /**
556
+ * List all enrichment runs for a video
557
+ */
558
+ getEnrichments(videoId: string): Promise<ListEnrichmentsResponse>;
559
+ /**
560
+ * Get a specific enrichment result
561
+ */
562
+ getEnrichment(enrichmentId: string): Promise<EnrichmentRecord>;
563
+ /**
564
+ * Delete a video and all associated data across all systems
565
+ */
566
+ deleteVideo(videoId: string, s3Key?: string): Promise<VideoDeletionResponse>;
567
+ /**
568
+ * Stream chat responses with Server-Sent Events
569
+ * Returns a ReadableStreamDefaultReader for processing SSE events
570
+ */
571
+ streamChat(request: ChatStreamRequest, signal?: AbortSignal): Promise<ReadableStreamDefaultReader<Uint8Array>>;
572
+ /**
573
+ * Create a new persona
574
+ */
575
+ createPersona(data: CreatePersonaRequest): Promise<PersonaConfig>;
576
+ /**
577
+ * List all personas for the current user
578
+ */
579
+ listPersonas(params?: {
580
+ limit?: number;
581
+ nextToken?: string;
582
+ status?: 'pending' | 'approved';
583
+ }): Promise<PersonaListResponse>;
584
+ /**
585
+ * Get the default persona for the current user
586
+ */
587
+ getDefaultPersona(): Promise<PersonaConfig | null>;
588
+ /**
589
+ * Get a specific persona by ID
590
+ */
591
+ getPersona(personaId: string): Promise<PersonaConfig>;
592
+ /**
593
+ * Update a persona
594
+ */
595
+ updatePersona(personaId: string, data: UpdatePersonaRequest): Promise<PersonaConfig>;
596
+ /**
597
+ * Delete a persona
598
+ */
599
+ deletePersona(personaId: string): Promise<void>;
600
+ /**
601
+ * AI-synthesize persona definitions from enrichment data.
602
+ * Does NOT persist — returns suggestions to create individually.
603
+ */
604
+ synthesizePersonas(videoId: string, enrichmentData: Record<string, unknown>, maxPersonas?: number): Promise<SynthesizePersonasResponse>;
605
+ listImages(params?: {
606
+ category?: ImageCategory;
607
+ videoId?: string;
608
+ limit?: number;
609
+ nextToken?: string;
610
+ }): Promise<ImageListResponse>;
611
+ getImage(imageId: string, options?: {
612
+ signal?: AbortSignal;
613
+ }): Promise<ImageRecord>;
614
+ updateImage(imageId: string, data: UpdateImageRequest): Promise<ImageRecord>;
615
+ deleteImage(imageId: string): Promise<void>;
616
+ uploadImage(file: File, metadata?: {
617
+ category?: string;
618
+ tags?: string;
619
+ sourceVideoId?: string;
620
+ sourceEntity?: string;
621
+ }): Promise<ImageRecord>;
622
+ /**
623
+ * Kick off async character generation. Returns a 202 envelope with
624
+ * `characterImageId` and `statusUrl`. Caller must poll
625
+ * `getImage(characterImageId)` (or use `pollImageUntilDone()`) until
626
+ * `status` flips from `'pending'` to `'complete'` or `'failed'`.
627
+ *
628
+ * Converted from synchronous because Gemini regularly exceeds
629
+ * CloudFront's 60s `OriginReadTimeout` and the browser would see a
630
+ * 504 even though the backend completed.
631
+ */
632
+ generateCharacter(params: GenerateCharacterRequest): Promise<GenerateCharacterResponse>;
633
+ /**
634
+ * Extract a raw video frame at an entity's location or a specific
635
+ * timestamp. Synchronous (no polling) — the path is ffmpeg-only with
636
+ * no AI generation, so it returns 201 with the result inline.
637
+ *
638
+ * Pass `options.signal` to abort the in-flight request when the
639
+ * consumer component unmounts.
640
+ */
641
+ extractImage(req: ExtractImageRequest, options?: {
642
+ signal?: AbortSignal;
643
+ }): Promise<ExtractImageResponse>;
644
+ /**
645
+ * Extract an entity frame and regenerate it with a Gemini Flash Image
646
+ * style prompt. Synchronous from the client's perspective; backend
647
+ * runs ffmpeg + Gemini in one request and returns 201 with the result.
648
+ *
649
+ * Gemini calls regularly take several seconds — pass `options.signal`
650
+ * so a component unmount mid-call cancels the underlying fetch instead
651
+ * of leaving a dangling Promise.
652
+ */
653
+ regenerateImage(req: RegenerateImageRequest, options?: {
654
+ signal?: AbortSignal;
655
+ }): Promise<RegenerateImageResponse>;
656
+ /**
657
+ * Poll `GET /api/v1/images/{imageId}` until the row's `status` flips
658
+ * away from `'pending'`. Resolves with the completed record (status
659
+ * `'complete'`); throws on `'failed'` (with the row's
660
+ * `error_message`) or after `timeoutMs` elapses.
661
+ *
662
+ * Pass `signal` to cancel cleanly when the page unmounts. AbortError
663
+ * is rethrown so callers can distinguish cancellation from real
664
+ * failures.
665
+ *
666
+ * Cadence is 5s — character generation runs ~30-60s, so a 2s poll
667
+ * (the per-viseme cadence) would burn 25 wasted requests per
668
+ * generation. The 5s cadence still surfaces completion within one
669
+ * user-perceived "tick" past the actual finish.
670
+ */
671
+ pollImageUntilDone(imageId: string, options?: {
672
+ intervalMs?: number;
673
+ timeoutMs?: number;
674
+ signal?: AbortSignal;
675
+ }): Promise<ImageRecord>;
676
+ /**
677
+ * Create a new chat session
678
+ */
679
+ createSession(data: CreateSessionRequest): Promise<ChatSession>;
680
+ /**
681
+ * List all sessions for the current user
682
+ */
683
+ listSessions(params?: {
684
+ limit?: number;
685
+ nextToken?: string;
686
+ personaId?: string;
687
+ }): Promise<SessionListResponse>;
688
+ /**
689
+ * Get a specific session by ID
690
+ */
691
+ getSession(sessionId: string): Promise<ChatSession>;
692
+ /**
693
+ * Add a message to a session
694
+ */
695
+ addMessageToSession(sessionId: string, data: AddMessageRequest): Promise<ChatSession>;
696
+ /**
697
+ * Clear all messages from a session
698
+ */
699
+ clearSessionMessages(sessionId: string): Promise<void>;
700
+ /**
701
+ * Delete a session
702
+ */
703
+ deleteSession(sessionId: string): Promise<void>;
704
+ /**
705
+ * Get transcript for a video, optionally filtered by time range
706
+ */
707
+ getTranscript(videoId: string, t0?: number, t1?: number): Promise<GetTranscriptResponse>;
708
+ /**
709
+ * Search dialog within a video by keyword or phrase
710
+ */
711
+ searchDialog(videoId: string, query: string, limit?: number): Promise<DialogSearchResponse>;
712
+ getVideoGraph(videoId: string): Promise<VideoGraphResponse>;
713
+ updateGraphNode(data: UpdateNodeRequest): Promise<UpdateNodeResponse>;
714
+ deleteGraphNode(data: DeleteNodeRequest): Promise<DeleteNodeResponse>;
715
+ updateGraphEdge(data: UpdateRelationshipRequest): Promise<UpdateRelationshipResponse>;
716
+ deleteGraphEdge(data: DeleteRelationshipRequest): Promise<DeleteRelationshipResponse>;
717
+ /**
718
+ * Fetch a persona's viseme bundle by ID. Returns the full record including
719
+ * inline body_svg and mouth_paths when status === 'complete'.
720
+ *
721
+ * Pass `signal` to abort the in-flight request — used by the
722
+ * persona-tuner poll loop so a drawer-close mid-fetch unblocks
723
+ * immediately rather than waiting for the response.
724
+ */
725
+ getVisemeBundle(personaId: string, bundleId: string, options?: {
726
+ signal?: AbortSignal;
727
+ }): Promise<VisemeBundleRecord>;
728
+ /**
729
+ * Fetch a bundle's body SVG bytes from the backend's S3 proxy. Used as a
730
+ * fallback when the bundle row's inline body_svg is null because the SVG
731
+ * exceeded the DynamoDB inline cap.
732
+ */
733
+ getVisemeBundleBodySvg(personaId: string, bundleId: string): Promise<string>;
734
+ /**
735
+ * Fetch a single viseme PNG and return a blob URL for use as `<img src>`.
736
+ * The backend proxy adds the auth header; <img> tags can't, so we hop
737
+ * through fetch + URL.createObjectURL. Caller is responsible for revoking
738
+ * the URL when the bundle is no longer in use.
739
+ */
740
+ getVisemeBundleVisemePng(personaId: string, bundleId: string, viseme: string,
741
+ /** Optional cache-bust suffix appended as a query string. */
742
+ cacheKey?: string): Promise<string>;
743
+ /**
744
+ * Persona-tuner: GET defaults for the 11 viseme prompt descriptions.
745
+ */
746
+ getVisemePromptDefaults(): Promise<Record<string, string>>;
747
+ /**
748
+ * Persona-tuner: per-persona prompts as
749
+ * `{viseme: {default, override, effective}}`. Returns 11 entries.
750
+ */
751
+ getPersonaVisemePrompts(personaId: string): Promise<{
752
+ prompts: Record<string, {
753
+ default: string;
754
+ override: string | null;
755
+ effective: string;
756
+ }>;
757
+ traceId: string;
758
+ }>;
759
+ /**
760
+ * Persona-tuner: set or clear ONE viseme's description override.
761
+ * Pass `description: null` (or empty string) to clear the override.
762
+ * Does NOT trigger regeneration — call regenerateBundleViseme for that.
763
+ */
764
+ patchPersonaVisemePrompts(personaId: string, body: {
765
+ viseme: string;
766
+ description: string | null;
767
+ }): Promise<{
768
+ prompts: Record<string, {
769
+ default: string;
770
+ override: string | null;
771
+ effective: string;
772
+ }>;
773
+ traceId: string;
774
+ }>;
775
+ /**
776
+ * Persona-tuner: replace (or clear) the persona's full visual
777
+ * overrides blob. PUT semantics: the body IS the new full state.
778
+ * Pass `null` to clear. Backend validates per-field bounds + rejects
779
+ * unknown keys (422 on bad input).
780
+ */
781
+ putPersonaVisualOverrides(personaId: string, overrides: Record<string, unknown> | null): Promise<{
782
+ visual_overrides: Record<string, unknown> | null;
783
+ traceId: string;
784
+ }>;
785
+ /**
786
+ * Persona-tuner: kick off async regeneration of ONE viseme's PNG (and
787
+ * its mouth path). Optional `description` sets the override before the
788
+ * BackgroundTask starts. Returns 202 immediately with a status_url —
789
+ * poll `getVisemeBundle` and watch `viseme_regen_status[viseme]` until
790
+ * it transitions to `complete` or `failed`.
791
+ */
792
+ regenerateBundleViseme(personaId: string, bundleId: string, viseme: string, body?: {
793
+ description?: string;
794
+ }): Promise<RegenerateVisemeAccept>;
795
+ /**
796
+ * Poll `getVisemeBundle` until `viseme_regen_status[viseme]` reaches
797
+ * a terminal state (`complete` or `failed`). Resolves with the final
798
+ * bundle record. Times out after `timeoutMs` (default 240s — covers
799
+ * the worst observed Gemini wall-clock plus retries).
800
+ *
801
+ * Pass `signal` to cancel cleanly when the drawer closes or the user
802
+ * switches personas mid-poll. AbortError is rethrown so callers can
803
+ * distinguish cancellation from real failures.
804
+ */
805
+ pollVisemeRegenUntilDone(personaId: string, bundleId: string, viseme: string, options?: {
806
+ intervalMs?: number;
807
+ timeoutMs?: number;
808
+ signal?: AbortSignal;
809
+ }): Promise<VisemeBundleRecord>;
810
+ /**
811
+ * Kick off async generation of a viseme bundle for a persona.
812
+ * Returns 202 with a bundle_id; poll getVisemeBundle until status='complete'.
813
+ */
814
+ createVisemeBundle(personaId: string, sourceImageId: string): Promise<{
815
+ bundle_id: string;
816
+ status: VisemeBundleStatus;
817
+ status_url: string;
818
+ }>;
819
+ /**
820
+ * Poll `getVisemeBundle` until the bundle's overall `status` reaches a
821
+ * terminal state (`'complete'` or `'failed'`). Use after
822
+ * `createVisemeBundle` for whole-bundle generation;
823
+ * `pollVisemeRegenUntilDone` covers single-viseme regeneration.
824
+ *
825
+ * Cadence is 5s — bundle assembly runs ~40-60s, so a 2s poll (the
826
+ * per-viseme cadence) would burn ~25 wasted requests per bundle.
827
+ * Mirrors `pollImageUntilDone`'s shape; `signal` cancels cleanly when
828
+ * the page unmounts.
829
+ */
830
+ pollVisemeBundleUntilDone(personaId: string, bundleId: string, options?: {
831
+ intervalMs?: number;
832
+ timeoutMs?: number;
833
+ signal?: AbortSignal;
834
+ }): Promise<VisemeBundleRecord>;
835
+ }
836
+ //# sourceMappingURL=api.d.ts.map