@mux/ai 0.1.5 → 0.2.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.
@@ -308,6 +308,10 @@ interface SummaryAndTagsResult {
308
308
  tags: string[];
309
309
  /** Storyboard image URL that was analyzed. */
310
310
  storyboardUrl: string;
311
+ /** Token usage from the AI provider (for efficiency/cost analysis). */
312
+ usage?: TokenUsage;
313
+ /** Raw transcript text used for analysis (when includeTranscript is true). */
314
+ transcriptText?: string;
311
315
  }
312
316
  /**
313
317
  * Sections of the summarization user prompt that can be overridden.
@@ -353,10 +357,111 @@ interface SummarizationOptions extends MuxAIOptions {
353
357
  }
354
358
  declare function getSummaryAndTags(assetId: string, options?: SummarizationOptions): Promise<SummaryAndTagsResult>;
355
359
 
360
+ /**
361
+ * Language Code Conversion Utilities
362
+ *
363
+ * Provides bidirectional mapping between:
364
+ * - ISO 639-1 (2-letter codes) - Used by browsers, BCP-47, most video players
365
+ * - ISO 639-3 (3-letter codes) - Used by various APIs and language processing systems
366
+ *
367
+ * This is essential for interoperability between different systems:
368
+ * - Mux uses ISO 639-1 for track language codes
369
+ * - Browser players expect BCP-47 compliant codes (based on ISO 639-1)
370
+ * - Some APIs require ISO 639-3 (3-letter) codes
371
+ */
372
+ /**
373
+ * Mapping from ISO 639-1 (2-letter) to ISO 639-3 (3-letter) codes.
374
+ * Covers the most common languages used in video translation.
375
+ *
376
+ * Reference: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
377
+ */
378
+ declare const ISO639_1_TO_3: {
379
+ readonly en: "eng";
380
+ readonly es: "spa";
381
+ readonly fr: "fra";
382
+ readonly de: "deu";
383
+ readonly it: "ita";
384
+ readonly pt: "por";
385
+ readonly ru: "rus";
386
+ readonly zh: "zho";
387
+ readonly ja: "jpn";
388
+ readonly ko: "kor";
389
+ readonly ar: "ara";
390
+ readonly hi: "hin";
391
+ readonly nl: "nld";
392
+ readonly pl: "pol";
393
+ readonly sv: "swe";
394
+ readonly da: "dan";
395
+ readonly no: "nor";
396
+ readonly fi: "fin";
397
+ readonly el: "ell";
398
+ readonly cs: "ces";
399
+ readonly hu: "hun";
400
+ readonly ro: "ron";
401
+ readonly bg: "bul";
402
+ readonly hr: "hrv";
403
+ readonly sk: "slk";
404
+ readonly sl: "slv";
405
+ readonly uk: "ukr";
406
+ readonly tr: "tur";
407
+ readonly th: "tha";
408
+ readonly vi: "vie";
409
+ readonly id: "ind";
410
+ readonly ms: "msa";
411
+ readonly tl: "tgl";
412
+ readonly he: "heb";
413
+ readonly fa: "fas";
414
+ readonly bn: "ben";
415
+ readonly ta: "tam";
416
+ readonly te: "tel";
417
+ readonly mr: "mar";
418
+ readonly gu: "guj";
419
+ readonly kn: "kan";
420
+ readonly ml: "mal";
421
+ readonly pa: "pan";
422
+ readonly ur: "urd";
423
+ readonly sw: "swa";
424
+ readonly af: "afr";
425
+ readonly ca: "cat";
426
+ readonly eu: "eus";
427
+ readonly gl: "glg";
428
+ readonly is: "isl";
429
+ readonly et: "est";
430
+ readonly lv: "lav";
431
+ readonly lt: "lit";
432
+ };
433
+ /**
434
+ * Supported ISO 639-1 two-letter language codes.
435
+ * These are the language codes supported for translation workflows.
436
+ */
437
+ type SupportedISO639_1 = keyof typeof ISO639_1_TO_3;
438
+ /**
439
+ * Supported ISO 639-3 three-letter language codes.
440
+ * These are the language codes supported for translation workflows.
441
+ */
442
+ type SupportedISO639_3 = (typeof ISO639_1_TO_3)[SupportedISO639_1];
443
+ /** ISO 639-1 two-letter language code (e.g., "en", "fr", "es") */
444
+ type ISO639_1 = SupportedISO639_1 | (string & {});
445
+ /** ISO 639-3 three-letter language code (e.g., "eng", "fra", "spa") */
446
+ type ISO639_3 = SupportedISO639_3 | (string & {});
447
+ /** Structured language code result containing both formats */
448
+ interface LanguageCodePair {
449
+ /** ISO 639-1 two-letter code (BCP-47 compatible) */
450
+ iso639_1: ISO639_1;
451
+ /** ISO 639-3 three-letter code */
452
+ iso639_3: ISO639_3;
453
+ }
454
+
356
455
  /** Output returned from `translateAudio`. */
357
456
  interface AudioTranslationResult {
358
457
  assetId: string;
359
- targetLanguageCode: string;
458
+ /** Target language code (ISO 639-1 two-letter format). */
459
+ targetLanguageCode: SupportedISO639_1;
460
+ /**
461
+ * Target language codes in both ISO 639-1 (2-letter) and ISO 639-3 (3-letter) formats.
462
+ * Use `iso639_1` for browser players (BCP-47 compliant) and `iso639_3` for ElevenLabs API.
463
+ */
464
+ targetLanguage: LanguageCodePair;
360
465
  dubbingId: string;
361
466
  uploadedTrackId?: string;
362
467
  presignedUrl?: string;
@@ -390,12 +495,26 @@ declare function translateAudio(assetId: string, toLanguageCode: string, options
390
495
  /** Output returned from `translateCaptions`. */
391
496
  interface TranslationResult {
392
497
  assetId: string;
393
- sourceLanguageCode: string;
394
- targetLanguageCode: string;
498
+ /** Source language code (ISO 639-1 two-letter format). */
499
+ sourceLanguageCode: SupportedISO639_1;
500
+ /** Target language code (ISO 639-1 two-letter format). */
501
+ targetLanguageCode: SupportedISO639_1;
502
+ /**
503
+ * Source language codes in both ISO 639-1 (2-letter) and ISO 639-3 (3-letter) formats.
504
+ * Use `iso639_1` for browser players (BCP-47 compliant) and `iso639_3` for APIs that require it.
505
+ */
506
+ sourceLanguage: LanguageCodePair;
507
+ /**
508
+ * Target language codes in both ISO 639-1 (2-letter) and ISO 639-3 (3-letter) formats.
509
+ * Use `iso639_1` for browser players (BCP-47 compliant) and `iso639_3` for APIs that require it.
510
+ */
511
+ targetLanguage: LanguageCodePair;
395
512
  originalVtt: string;
396
513
  translatedVtt: string;
397
514
  uploadedTrackId?: string;
398
515
  presignedUrl?: string;
516
+ /** Token usage from the AI provider (for efficiency/cost analysis). */
517
+ usage?: TokenUsage;
399
518
  }
400
519
  /** Configuration accepted by `translateCaptions`. */
401
520
  interface TranslationOptions<P extends SupportedProvider = SupportedProvider> extends MuxAIOptions {
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { i as primitives } from './index-DyTSka2R.js';
2
2
  export { A as AssetTextTrack, f as ChunkEmbedding, C as ChunkingStrategy, I as ImageSubmissionMode, M as MuxAIConfig, a as MuxAIOptions, b as MuxAsset, c as PlaybackAsset, P as PlaybackPolicy, e as TextChunk, d as TokenChunkingConfig, h as TokenUsage, T as ToneType, V as VTTChunkingConfig, g as VideoEmbeddingsResult } from './types-ktXDZ93V.js';
3
- export { i as workflows } from './index-Bnv7tv90.js';
3
+ export { i as workflows } from './index-CMZYZcj6.js';
4
4
  import '@mux/mux-node';
5
5
  import 'zod';
6
6
  import '@ai-sdk/anthropic';