@mux/ai 0.12.0 → 0.13.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.
package/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Easy to use, purpose-driven, cost effective, configurable **_workflow functions_** in a TypeScript SDK for building AI-powered video and audio workflows on the server, powered by [Mux](https://www.mux.com), with support for popular AI/LLM providers (OpenAI, Anthropic, Google).
7
7
 
8
- - **Examples:** [`getSummaryAndTags`](#video-summarization), [`getModerationScores`](#content-moderation), [`hasBurnedInCaptions`](#burned-in-caption-detection), [`generateChapters`](#chapter-generation), [`generateEmbeddings`](#search-with-embeddings), [`translateCaptions`](#caption-translation), [`editCaptions`](#caption-editing), [`translateAudio`](#audio-dubbing)
8
+ - **Examples:** [`getSummaryAndTags`](#video-summarization), [`getModerationScores`](#content-moderation), [`hasBurnedInCaptions`](#burned-in-caption-detection), [`generateChapters`](#chapter-generation), [`generateEmbeddings`](#search-with-embeddings), [`generateEngagementInsights`](#engagement-insights), [`translateCaptions`](#caption-translation), [`editCaptions`](#caption-editing), [`translateAudio`](#audio-dubbing)
9
9
  - Workflows automatically ship with `"use workflow"` [compatability with Workflow DevKit](#compatability-with-workflow-devkit)
10
10
 
11
11
  Turn your Mux video and audio assets into structured, actionable data — summaries, chapters, moderation scores, translations, embeddings, and more — with a single function call. `@mux/ai` handles fetching media data from Mux, formatting it for AI providers, and returning typed results so you can focus on building your product instead of wrangling prompts and media pipelines.
@@ -2,7 +2,7 @@ import { z } from 'zod';
2
2
  import { createAnthropic } from '@ai-sdk/anthropic';
3
3
  import { createGoogleGenerativeAI } from '@ai-sdk/google';
4
4
  import { createOpenAI } from '@ai-sdk/openai';
5
- import { M as MuxAIOptions, I as ImageSubmissionMode, h as TokenUsage, b as ChunkingStrategy, j as VideoEmbeddingsResult, i as ToneType, f as StorageAdapter } from './types-BRbaGW3t.js';
5
+ import { M as MuxAIOptions, I as ImageSubmissionMode, h as TokenUsage, b as ChunkingStrategy, j as VideoEmbeddingsResult, H as Hotspot, t as Shot, i as ToneType, f as StorageAdapter } from './shots-BFYOfBgN.js';
6
6
 
7
7
  interface ImageDownloadOptions {
8
8
  /** Request timeout in milliseconds (default: 10000) */
@@ -43,8 +43,8 @@ interface Question {
43
43
  interface QuestionAnswer {
44
44
  /** The original question */
45
45
  question: string;
46
- /** Answer selected from the allowed options. Undefined when skipped. */
47
- answer?: string;
46
+ /** Answer selected from the allowed options. Null when skipped. */
47
+ answer: string | null;
48
48
  /** Confidence score between 0 and 1. Always 0 when skipped. */
49
49
  confidence: number;
50
50
  /** Reasoning explaining the answer, or why the question was skipped */
@@ -87,22 +87,22 @@ interface AskQuestionsResult {
87
87
  /** Zod schema for a single answer (matches the public QuestionAnswer interface). */
88
88
  declare const questionAnswerSchema: z.ZodObject<{
89
89
  question: z.ZodString;
90
- answer: z.ZodOptional<z.ZodString>;
90
+ answer: z.ZodNullable<z.ZodString>;
91
91
  confidence: z.ZodNumber;
92
92
  reasoning: z.ZodString;
93
93
  skipped: z.ZodBoolean;
94
94
  }, "strip", z.ZodTypeAny, {
95
95
  question: string;
96
+ answer: string | null;
96
97
  confidence: number;
97
98
  reasoning: string;
98
99
  skipped: boolean;
99
- answer?: string | undefined;
100
100
  }, {
101
101
  question: string;
102
+ answer: string | null;
102
103
  confidence: number;
103
104
  reasoning: string;
104
105
  skipped: boolean;
105
- answer?: string | undefined;
106
106
  }>;
107
107
  type QuestionAnswerType = z.infer<typeof questionAnswerSchema>;
108
108
  declare function createAskQuestionsSchema(allowedAnswers: [string, ...string[]]): z.ZodObject<{
@@ -492,6 +492,104 @@ declare function generateEmbeddings(assetId: string, options?: EmbeddingsOptions
492
492
  */
493
493
  declare function generateVideoEmbeddings(assetId: string, options?: EmbeddingsOptions): Promise<EmbeddingsResult>;
494
494
 
495
+ /**
496
+ * Sections of the engagement insights user prompt that can be overridden.
497
+ */
498
+ /** Configuration options for engagement insights workflow. */
499
+ interface EngagementInsightsOptions extends MuxAIOptions {
500
+ /** AI provider to run (defaults to 'openai'). */
501
+ provider?: SupportedProvider;
502
+ /** Provider-specific chat model identifier. */
503
+ model?: ModelIdByProvider[SupportedProvider];
504
+ /**
505
+ * Number of engagement moments to analyze per direction (default: 5, max: 10).
506
+ * Note: actual moment count may be up to 2x this value since both peaks and valleys are fetched.
507
+ */
508
+ hotspotLimit?: number;
509
+ /** Timeframe for engagement data (default: '7:days') */
510
+ timeframe?: string;
511
+ /**
512
+ * Skip shots integration and use basic thumbnails instead (default: false).
513
+ * Recommended for latency-sensitive use cases.
514
+ */
515
+ skipShots?: boolean;
516
+ }
517
+ /** A single moment insight for a specific engagement hotspot */
518
+ interface MomentInsight {
519
+ /** Start time in milliseconds */
520
+ startMs: number;
521
+ /** End time in milliseconds */
522
+ endMs: number;
523
+ /** Human-readable timestamp (e.g., "2:15") */
524
+ timestamp: string;
525
+ /** Normalized engagement score (0-1) */
526
+ engagementScore: number;
527
+ /** Primary insight explaining the engagement pattern */
528
+ insight: string;
529
+ }
530
+ /** Overall engagement analysis across the entire video */
531
+ interface OverallInsight {
532
+ /** Summary of overall engagement patterns */
533
+ summary: string;
534
+ /** Key trends identified across the video */
535
+ trends: string[];
536
+ }
537
+ /** Transcript segment aligned with a hotspot */
538
+ interface TranscriptSegment {
539
+ startMs: number;
540
+ endMs: number;
541
+ text: string;
542
+ timestamp: string;
543
+ }
544
+ /** Structured return payload for engagement insights workflow. */
545
+ interface EngagementInsightsResult {
546
+ /** Asset ID passed into the workflow. */
547
+ assetId: string;
548
+ /** Per-moment insights for each hotspot */
549
+ momentInsights: MomentInsight[];
550
+ /** Overall engagement analysis */
551
+ overallInsight: OverallInsight;
552
+ /** Token usage from the AI provider (for efficiency/cost analysis). */
553
+ usage?: TokenUsage;
554
+ }
555
+ /**
556
+ * Extracts transcript segments that align with hotspot time ranges.
557
+ */
558
+ declare function extractTranscriptSegmentsForHotspots(vttContent: string, hotspots: Hotspot[]): TranscriptSegment[];
559
+ /**
560
+ * Maps each hotspot to its nearest shot image.
561
+ *
562
+ * Algorithm: for each hotspot, find all shots whose startTime falls within
563
+ * [hotspot.startMs/1000, hotspot.endMs/1000]. If any exist, pick the one
564
+ * closest to the midpoint. Otherwise, pick the shot with the nearest
565
+ * startTime to hotspot.startMs/1000.
566
+ */
567
+ declare function mapShotsToHotspots(shots: Shot[], hotspots: Hotspot[]): string[];
568
+ /**
569
+ * Generate engagement insights for a Mux video asset.
570
+ *
571
+ * This workflow analyzes viewer engagement patterns to explain why certain moments
572
+ * are engaging or disengaging. It combines hotspot data, heatmap statistics, visual
573
+ * frames (from shots or thumbnails), and transcript analysis to generate AI-powered insights.
574
+ *
575
+ * @param assetId - The Mux asset ID to analyze
576
+ * @param options - Configuration options for the workflow
577
+ * @returns Structured insights with moment-by-moment and overall analysis
578
+ *
579
+ * @example
580
+ * ```typescript
581
+ * const result = await generateEngagementInsights("abc123", {
582
+ * insightType: 'both',
583
+ * hotspotLimit: 5,
584
+ * });
585
+ *
586
+ * result.momentInsights.forEach(m => {
587
+ * console.log(`${m.timestamp}: ${m.insight}`);
588
+ * });
589
+ * ```
590
+ */
591
+ declare function generateEngagementInsights(assetId: string, options?: EngagementInsightsOptions): Promise<EngagementInsightsResult>;
592
+
495
593
  /** Per-thumbnail moderation result returned from `getModerationScores`. */
496
594
  interface ThumbnailModerationScore {
497
595
  url: string;
@@ -919,6 +1017,8 @@ type index_EditCaptionsOptions<P extends SupportedProvider = SupportedProvider>
919
1017
  type index_EditCaptionsResult = EditCaptionsResult;
920
1018
  type index_EmbeddingsOptions = EmbeddingsOptions;
921
1019
  type index_EmbeddingsResult = EmbeddingsResult;
1020
+ type index_EngagementInsightsOptions = EngagementInsightsOptions;
1021
+ type index_EngagementInsightsResult = EngagementInsightsResult;
922
1022
  declare const index_HIVE_SEXUAL_CATEGORIES: typeof HIVE_SEXUAL_CATEGORIES;
923
1023
  declare const index_HIVE_VIOLENCE_CATEGORIES: typeof HIVE_VIOLENCE_CATEGORIES;
924
1024
  type index_HiveModerationOutput = HiveModerationOutput;
@@ -926,6 +1026,8 @@ type index_HiveModerationSource = HiveModerationSource;
926
1026
  type index_ModerationOptions = ModerationOptions;
927
1027
  type index_ModerationProvider = ModerationProvider;
928
1028
  type index_ModerationResult = ModerationResult;
1029
+ type index_MomentInsight = MomentInsight;
1030
+ type index_OverallInsight = OverallInsight;
929
1031
  type index_ProfanityDetectionPayload = ProfanityDetectionPayload;
930
1032
  type index_Question = Question;
931
1033
  type index_QuestionAnswer = QuestionAnswer;
@@ -952,12 +1054,15 @@ declare const index_chapterSchema: typeof chapterSchema;
952
1054
  declare const index_chaptersSchema: typeof chaptersSchema;
953
1055
  declare const index_createReplacer: typeof createReplacer;
954
1056
  declare const index_editCaptions: typeof editCaptions;
1057
+ declare const index_extractTranscriptSegmentsForHotspots: typeof extractTranscriptSegmentsForHotspots;
955
1058
  declare const index_generateChapters: typeof generateChapters;
956
1059
  declare const index_generateEmbeddings: typeof generateEmbeddings;
1060
+ declare const index_generateEngagementInsights: typeof generateEngagementInsights;
957
1061
  declare const index_generateVideoEmbeddings: typeof generateVideoEmbeddings;
958
1062
  declare const index_getModerationScores: typeof getModerationScores;
959
1063
  declare const index_getSummaryAndTags: typeof getSummaryAndTags;
960
1064
  declare const index_hasBurnedInCaptions: typeof hasBurnedInCaptions;
1065
+ declare const index_mapShotsToHotspots: typeof mapShotsToHotspots;
961
1066
  declare const index_profanityDetectionSchema: typeof profanityDetectionSchema;
962
1067
  declare const index_questionAnswerSchema: typeof questionAnswerSchema;
963
1068
  declare const index_shouldSplitChunkTranslationError: typeof shouldSplitChunkTranslationError;
@@ -967,7 +1072,7 @@ declare const index_translateAudio: typeof translateAudio;
967
1072
  declare const index_translateCaptions: typeof translateCaptions;
968
1073
  declare const index_translationSchema: typeof translationSchema;
969
1074
  declare namespace index {
970
- export { type index_AskQuestionsOptions as AskQuestionsOptions, type index_AskQuestionsResult as AskQuestionsResult, type index_AskQuestionsType as AskQuestionsType, type index_AudioTranslationOptions as AudioTranslationOptions, type index_AudioTranslationResult as AudioTranslationResult, type index_AutoCensorProfanityOptions as AutoCensorProfanityOptions, type index_BurnedInCaptionsAnalysis as BurnedInCaptionsAnalysis, type index_BurnedInCaptionsOptions as BurnedInCaptionsOptions, type index_BurnedInCaptionsPromptOverrides as BurnedInCaptionsPromptOverrides, type index_BurnedInCaptionsPromptSections as BurnedInCaptionsPromptSections, type index_BurnedInCaptionsResult as BurnedInCaptionsResult, type index_CaptionReplacement as CaptionReplacement, type index_CensorMode as CensorMode, type index_Chapter as Chapter, type index_ChapterSystemPromptSections as ChapterSystemPromptSections, type index_ChaptersOptions as ChaptersOptions, type index_ChaptersPromptOverrides as ChaptersPromptOverrides, type index_ChaptersPromptSections as ChaptersPromptSections, type index_ChaptersResult as ChaptersResult, type index_ChaptersType as ChaptersType, index_DEFAULT_DESCRIPTION_LENGTH as DEFAULT_DESCRIPTION_LENGTH, index_DEFAULT_SUMMARY_KEYWORD_LIMIT as DEFAULT_SUMMARY_KEYWORD_LIMIT, index_DEFAULT_TITLE_LENGTH as DEFAULT_TITLE_LENGTH, type index_EditCaptionsOptions as EditCaptionsOptions, type index_EditCaptionsResult as EditCaptionsResult, type index_EmbeddingsOptions as EmbeddingsOptions, type index_EmbeddingsResult as EmbeddingsResult, index_HIVE_SEXUAL_CATEGORIES as HIVE_SEXUAL_CATEGORIES, index_HIVE_VIOLENCE_CATEGORIES as HIVE_VIOLENCE_CATEGORIES, type index_HiveModerationOutput as HiveModerationOutput, type index_HiveModerationSource as HiveModerationSource, type index_ModerationOptions as ModerationOptions, type index_ModerationProvider as ModerationProvider, type index_ModerationResult as ModerationResult, type index_ProfanityDetectionPayload as ProfanityDetectionPayload, type index_Question as Question, type index_QuestionAnswer as QuestionAnswer, type index_QuestionAnswerType as QuestionAnswerType, type index_ReplacementRecord as ReplacementRecord, type index_SummarizationOptions as SummarizationOptions, type index_SummarizationPromptOverrides as SummarizationPromptOverrides, type index_SummarizationPromptSections as SummarizationPromptSections, type index_SummaryAndTagsResult as SummaryAndTagsResult, type index_SummaryType as SummaryType, type index_ThumbnailModerationScore as ThumbnailModerationScore, type index_TranslationChunkingOptions as TranslationChunkingOptions, type index_TranslationOptions as TranslationOptions, type index_TranslationPayload as TranslationPayload, type index_TranslationResult as TranslationResult, index_aggregateTokenUsage as aggregateTokenUsage, index_applyOverrideLists as applyOverrideLists, index_applyReplacements as applyReplacements, index_askQuestions as askQuestions, index_buildReplacementRegex as buildReplacementRegex, index_burnedInCaptionsSchema as burnedInCaptionsSchema, index_censorVttContent as censorVttContent, index_chapterSchema as chapterSchema, index_chaptersSchema as chaptersSchema, index_createReplacer as createReplacer, index_editCaptions as editCaptions, index_generateChapters as generateChapters, index_generateEmbeddings as generateEmbeddings, index_generateVideoEmbeddings as generateVideoEmbeddings, index_getModerationScores as getModerationScores, index_getSummaryAndTags as getSummaryAndTags, index_hasBurnedInCaptions as hasBurnedInCaptions, index_profanityDetectionSchema as profanityDetectionSchema, index_questionAnswerSchema as questionAnswerSchema, index_shouldSplitChunkTranslationError as shouldSplitChunkTranslationError, index_summarySchema as summarySchema, index_transformCueText as transformCueText, index_translateAudio as translateAudio, index_translateCaptions as translateCaptions, index_translationSchema as translationSchema };
1075
+ export { type index_AskQuestionsOptions as AskQuestionsOptions, type index_AskQuestionsResult as AskQuestionsResult, type index_AskQuestionsType as AskQuestionsType, type index_AudioTranslationOptions as AudioTranslationOptions, type index_AudioTranslationResult as AudioTranslationResult, type index_AutoCensorProfanityOptions as AutoCensorProfanityOptions, type index_BurnedInCaptionsAnalysis as BurnedInCaptionsAnalysis, type index_BurnedInCaptionsOptions as BurnedInCaptionsOptions, type index_BurnedInCaptionsPromptOverrides as BurnedInCaptionsPromptOverrides, type index_BurnedInCaptionsPromptSections as BurnedInCaptionsPromptSections, type index_BurnedInCaptionsResult as BurnedInCaptionsResult, type index_CaptionReplacement as CaptionReplacement, type index_CensorMode as CensorMode, type index_Chapter as Chapter, type index_ChapterSystemPromptSections as ChapterSystemPromptSections, type index_ChaptersOptions as ChaptersOptions, type index_ChaptersPromptOverrides as ChaptersPromptOverrides, type index_ChaptersPromptSections as ChaptersPromptSections, type index_ChaptersResult as ChaptersResult, type index_ChaptersType as ChaptersType, index_DEFAULT_DESCRIPTION_LENGTH as DEFAULT_DESCRIPTION_LENGTH, index_DEFAULT_SUMMARY_KEYWORD_LIMIT as DEFAULT_SUMMARY_KEYWORD_LIMIT, index_DEFAULT_TITLE_LENGTH as DEFAULT_TITLE_LENGTH, type index_EditCaptionsOptions as EditCaptionsOptions, type index_EditCaptionsResult as EditCaptionsResult, type index_EmbeddingsOptions as EmbeddingsOptions, type index_EmbeddingsResult as EmbeddingsResult, type index_EngagementInsightsOptions as EngagementInsightsOptions, type index_EngagementInsightsResult as EngagementInsightsResult, index_HIVE_SEXUAL_CATEGORIES as HIVE_SEXUAL_CATEGORIES, index_HIVE_VIOLENCE_CATEGORIES as HIVE_VIOLENCE_CATEGORIES, type index_HiveModerationOutput as HiveModerationOutput, type index_HiveModerationSource as HiveModerationSource, type index_ModerationOptions as ModerationOptions, type index_ModerationProvider as ModerationProvider, type index_ModerationResult as ModerationResult, type index_MomentInsight as MomentInsight, type index_OverallInsight as OverallInsight, type index_ProfanityDetectionPayload as ProfanityDetectionPayload, type index_Question as Question, type index_QuestionAnswer as QuestionAnswer, type index_QuestionAnswerType as QuestionAnswerType, type index_ReplacementRecord as ReplacementRecord, type index_SummarizationOptions as SummarizationOptions, type index_SummarizationPromptOverrides as SummarizationPromptOverrides, type index_SummarizationPromptSections as SummarizationPromptSections, type index_SummaryAndTagsResult as SummaryAndTagsResult, type index_SummaryType as SummaryType, type index_ThumbnailModerationScore as ThumbnailModerationScore, type index_TranslationChunkingOptions as TranslationChunkingOptions, type index_TranslationOptions as TranslationOptions, type index_TranslationPayload as TranslationPayload, type index_TranslationResult as TranslationResult, index_aggregateTokenUsage as aggregateTokenUsage, index_applyOverrideLists as applyOverrideLists, index_applyReplacements as applyReplacements, index_askQuestions as askQuestions, index_buildReplacementRegex as buildReplacementRegex, index_burnedInCaptionsSchema as burnedInCaptionsSchema, index_censorVttContent as censorVttContent, index_chapterSchema as chapterSchema, index_chaptersSchema as chaptersSchema, index_createReplacer as createReplacer, index_editCaptions as editCaptions, index_extractTranscriptSegmentsForHotspots as extractTranscriptSegmentsForHotspots, index_generateChapters as generateChapters, index_generateEmbeddings as generateEmbeddings, index_generateEngagementInsights as generateEngagementInsights, index_generateVideoEmbeddings as generateVideoEmbeddings, index_getModerationScores as getModerationScores, index_getSummaryAndTags as getSummaryAndTags, index_hasBurnedInCaptions as hasBurnedInCaptions, index_mapShotsToHotspots as mapShotsToHotspots, index_profanityDetectionSchema as profanityDetectionSchema, index_questionAnswerSchema as questionAnswerSchema, index_shouldSplitChunkTranslationError as shouldSplitChunkTranslationError, index_summarySchema as summarySchema, index_transformCueText as transformCueText, index_translateAudio as translateAudio, index_translateCaptions as translateCaptions, index_translationSchema as translationSchema };
971
1076
  }
972
1077
 
973
- export { askQuestions as $, type AskQuestionsOptions as A, type BurnedInCaptionsAnalysis as B, type CaptionReplacement as C, DEFAULT_DESCRIPTION_LENGTH as D, type EditCaptionsOptions as E, type ModerationProvider as F, type ModerationResult as G, HIVE_SEXUAL_CATEGORIES as H, type QuestionAnswer as I, type QuestionAnswerType as J, type SummarizationPromptOverrides as K, type SummarizationPromptSections as L, type ModerationOptions as M, type SummaryAndTagsResult as N, type SummaryType as O, type ProfanityDetectionPayload as P, type Question as Q, type ReplacementRecord as R, type SummarizationOptions as S, type ThumbnailModerationScore as T, type TranslationChunkingOptions as U, type TranslationOptions as V, type TranslationPayload as W, type TranslationResult as X, aggregateTokenUsage as Y, applyOverrideLists as Z, applyReplacements as _, type AskQuestionsResult as a, buildReplacementRegex as a0, burnedInCaptionsSchema as a1, censorVttContent as a2, chapterSchema as a3, chaptersSchema as a4, createReplacer as a5, editCaptions as a6, generateChapters as a7, generateEmbeddings as a8, generateVideoEmbeddings as a9, getModerationScores as aa, getSummaryAndTags as ab, hasBurnedInCaptions as ac, profanityDetectionSchema as ad, questionAnswerSchema as ae, shouldSplitChunkTranslationError as af, summarySchema as ag, transformCueText as ah, translateAudio as ai, translateCaptions as aj, translationSchema as ak, type AskQuestionsType as b, type AudioTranslationOptions as c, type AudioTranslationResult as d, type AutoCensorProfanityOptions as e, type BurnedInCaptionsOptions as f, type BurnedInCaptionsPromptOverrides as g, type BurnedInCaptionsPromptSections as h, index as i, type BurnedInCaptionsResult as j, type CensorMode as k, type Chapter as l, type ChapterSystemPromptSections as m, type ChaptersOptions as n, type ChaptersPromptOverrides as o, type ChaptersPromptSections as p, type ChaptersResult as q, type ChaptersType as r, DEFAULT_SUMMARY_KEYWORD_LIMIT as s, DEFAULT_TITLE_LENGTH as t, type EditCaptionsResult as u, type EmbeddingsOptions as v, type EmbeddingsResult as w, HIVE_VIOLENCE_CATEGORIES as x, type HiveModerationOutput as y, type HiveModerationSource as z };
1078
+ export { type TranslationResult as $, type AskQuestionsOptions as A, type BurnedInCaptionsAnalysis as B, type CaptionReplacement as C, DEFAULT_DESCRIPTION_LENGTH as D, type EditCaptionsOptions as E, type HiveModerationOutput as F, type HiveModerationSource as G, HIVE_SEXUAL_CATEGORIES as H, type ModerationProvider as I, type ModerationResult as J, type MomentInsight as K, type QuestionAnswer as L, type ModerationOptions as M, type QuestionAnswerType as N, type OverallInsight as O, type ProfanityDetectionPayload as P, type Question as Q, type ReplacementRecord as R, type SummarizationOptions as S, type SummarizationPromptOverrides as T, type SummarizationPromptSections as U, type SummaryAndTagsResult as V, type SummaryType as W, type ThumbnailModerationScore as X, type TranslationChunkingOptions as Y, type TranslationOptions as Z, type TranslationPayload as _, type AskQuestionsResult as a, aggregateTokenUsage as a0, applyOverrideLists as a1, applyReplacements as a2, askQuestions as a3, buildReplacementRegex as a4, burnedInCaptionsSchema as a5, censorVttContent as a6, chapterSchema as a7, chaptersSchema as a8, createReplacer as a9, editCaptions as aa, extractTranscriptSegmentsForHotspots as ab, generateChapters as ac, generateEmbeddings as ad, generateEngagementInsights as ae, generateVideoEmbeddings as af, getModerationScores as ag, getSummaryAndTags as ah, hasBurnedInCaptions as ai, mapShotsToHotspots as aj, profanityDetectionSchema as ak, questionAnswerSchema as al, shouldSplitChunkTranslationError as am, summarySchema as an, transformCueText as ao, translateAudio as ap, translateCaptions as aq, translationSchema as ar, type AskQuestionsType as b, type AudioTranslationOptions as c, type AudioTranslationResult as d, type AutoCensorProfanityOptions as e, type BurnedInCaptionsOptions as f, type BurnedInCaptionsPromptOverrides as g, type BurnedInCaptionsPromptSections as h, index as i, type BurnedInCaptionsResult as j, type CensorMode as k, type Chapter as l, type ChapterSystemPromptSections as m, type ChaptersOptions as n, type ChaptersPromptOverrides as o, type ChaptersPromptSections as p, type ChaptersResult as q, type ChaptersType as r, DEFAULT_SUMMARY_KEYWORD_LIMIT as s, DEFAULT_TITLE_LENGTH as t, type EditCaptionsResult as u, type EmbeddingsOptions as v, type EmbeddingsResult as w, type EngagementInsightsOptions as x, type EngagementInsightsResult as y, HIVE_VIOLENCE_CATEGORIES as z };
@@ -1,7 +1,7 @@
1
- import { k as WorkflowCredentialsInput, A as AssetTextTrack, d as MuxAsset, T as TextChunk, b as ChunkingStrategy } from './types-BRbaGW3t.js';
1
+ import { k as WorkflowCredentialsInput, A as AssetTextTrack, d as MuxAsset, T as TextChunk, b as ChunkingStrategy, o as CompletedShotsResult, p as ErroredShotsResult, H as Hotspot, q as HotspotOptions, r as HotspotResponse, s as PendingShotsResult, t as Shot, u as ShotRequestOptions, v as ShotsResult, w as WaitForShotsOptions, x as getHotspotsForAsset, y as getHotspotsForPlaybackId, z as getHotspotsForVideo, B as getShotsForAsset, D as requestShotsForAsset, F as waitForShotsForAsset } from './shots-BFYOfBgN.js';
2
2
 
3
3
  interface HeatmapOptions {
4
- /** Time window for results, e.g., ['7:days'] (default: ['7:days']) */
4
+ /** Time window for results, e.g., '7:days' (default: '7:days') */
5
5
  timeframe?: string;
6
6
  /** Optional workflow credentials */
7
7
  credentials?: WorkflowCredentialsInput;
@@ -45,121 +45,6 @@ declare function getHeatmapForVideo(videoId: string, options?: HeatmapOptions):
45
45
  */
46
46
  declare function getHeatmapForPlaybackId(playbackId: string, options?: HeatmapOptions): Promise<HeatmapResponse>;
47
47
 
48
- interface Hotspot {
49
- /** Inclusive start time in milliseconds */
50
- startMs: number;
51
- /** Exclusive end time in milliseconds */
52
- endMs: number;
53
- /** Hotspot score using distribution-based normalization (0-1) */
54
- score: number;
55
- }
56
- interface HotspotOptions {
57
- /** Maximum number of hotspots to return (default: 5) */
58
- limit?: number;
59
- /** Sort order: 'asc' or 'desc' (default: 'desc') */
60
- orderDirection?: "asc" | "desc";
61
- /** Order by field (default: 'score') */
62
- orderBy?: "score";
63
- /** Time window for results, e.g., ['7:days'] (default: ['7:days']) */
64
- timeframe?: string;
65
- /** Optional workflow credentials */
66
- credentials?: WorkflowCredentialsInput;
67
- }
68
- interface HotspotResponse {
69
- assetId?: string;
70
- videoId?: string;
71
- playbackId?: string;
72
- hotspots: Hotspot[];
73
- }
74
- /**
75
- * Fetches engagement hotspots for a Mux asset.
76
- * Returns the top N "hot" time ranges based on engagement data.
77
- *
78
- * @param assetId - The Mux asset ID
79
- * @param options - Hotspot query options
80
- * @returns Array of hotspots with time ranges and scores
81
- */
82
- declare function getHotspotsForAsset(assetId: string, options?: HotspotOptions): Promise<Hotspot[]>;
83
- /**
84
- * Fetches engagement hotspots for a Mux video ID.
85
- * Returns the top N "hot" time ranges based on engagement data.
86
- *
87
- * @param videoId - The Mux video ID
88
- * @param options - Hotspot query options
89
- * @returns Array of hotspots with time ranges and scores
90
- */
91
- declare function getHotspotsForVideo(videoId: string, options?: HotspotOptions): Promise<Hotspot[]>;
92
- /**
93
- * Fetches engagement hotspots for a Mux playback ID.
94
- * Returns the top N "hot" time ranges based on engagement data.
95
- *
96
- * @param playbackId - The Mux playback ID
97
- * @param options - Hotspot query options
98
- * @returns Array of hotspots with time ranges and scores
99
- */
100
- declare function getHotspotsForPlaybackId(playbackId: string, options?: HotspotOptions): Promise<Hotspot[]>;
101
-
102
- interface Shot {
103
- /** Start time of the shot in seconds from the beginning of the asset. */
104
- startTime: number;
105
- /** Signed URL for a representative image of the shot. */
106
- imageUrl: string;
107
- }
108
- interface PendingShotsResult {
109
- status: "pending";
110
- createdAt: string;
111
- }
112
- interface ErroredShotsResult {
113
- status: "errored";
114
- createdAt: string;
115
- error: {
116
- type: string;
117
- messages: string[];
118
- };
119
- }
120
- interface CompletedShotsResult {
121
- status: "completed";
122
- createdAt: string;
123
- shots: Shot[];
124
- }
125
- type ShotsResult = PendingShotsResult | ErroredShotsResult | CompletedShotsResult;
126
- interface ShotRequestOptions {
127
- /** Optional workflow credentials */
128
- credentials?: WorkflowCredentialsInput;
129
- }
130
- interface WaitForShotsOptions extends ShotRequestOptions {
131
- /** Polling interval in milliseconds (default: 2000, minimum enforced: 1000) */
132
- pollIntervalMs?: number;
133
- /** Maximum number of polling attempts (default: 60) */
134
- maxAttempts?: number;
135
- /** When true, request shot generation before polling (default: true) */
136
- createIfMissing?: boolean;
137
- }
138
- /**
139
- * Starts generating shots for an asset.
140
- *
141
- * @param assetId - The Mux asset ID
142
- * @param options - Request options
143
- * @returns Pending shot generation state
144
- */
145
- declare function requestShotsForAsset(assetId: string, options?: ShotRequestOptions): Promise<PendingShotsResult>;
146
- /**
147
- * Gets the current shot generation status for an asset.
148
- *
149
- * @param assetId - The Mux asset ID
150
- * @param options - Request options
151
- * @returns Pending, errored, or completed shot result
152
- */
153
- declare function getShotsForAsset(assetId: string, options?: ShotRequestOptions): Promise<ShotsResult>;
154
- /**
155
- * Requests shot generation if needed and polls until shots are completed.
156
- *
157
- * @param assetId - The Mux asset ID
158
- * @param options - Polling options
159
- * @returns Completed shot result
160
- */
161
- declare function waitForShotsForAsset(assetId: string, options?: WaitForShotsOptions): Promise<CompletedShotsResult>;
162
-
163
48
  declare const DEFAULT_STORYBOARD_WIDTH = 640;
164
49
  /**
165
50
  * Generates a storyboard URL for the given playback ID.
@@ -331,18 +216,18 @@ declare function getThumbnailUrls(playbackId: string, duration: number, options?
331
216
  time: number;
332
217
  }>>;
333
218
 
334
- type index_CompletedShotsResult = CompletedShotsResult;
219
+ declare const index_CompletedShotsResult: typeof CompletedShotsResult;
335
220
  declare const index_DEFAULT_STORYBOARD_WIDTH: typeof DEFAULT_STORYBOARD_WIDTH;
336
- type index_ErroredShotsResult = ErroredShotsResult;
221
+ declare const index_ErroredShotsResult: typeof ErroredShotsResult;
337
222
  type index_HeatmapOptions = HeatmapOptions;
338
223
  type index_HeatmapResponse = HeatmapResponse;
339
- type index_Hotspot = Hotspot;
340
- type index_HotspotOptions = HotspotOptions;
341
- type index_HotspotResponse = HotspotResponse;
342
- type index_PendingShotsResult = PendingShotsResult;
343
- type index_Shot = Shot;
344
- type index_ShotRequestOptions = ShotRequestOptions;
345
- type index_ShotsResult = ShotsResult;
224
+ declare const index_Hotspot: typeof Hotspot;
225
+ declare const index_HotspotOptions: typeof HotspotOptions;
226
+ declare const index_HotspotResponse: typeof HotspotResponse;
227
+ declare const index_PendingShotsResult: typeof PendingShotsResult;
228
+ declare const index_Shot: typeof Shot;
229
+ declare const index_ShotRequestOptions: typeof ShotRequestOptions;
230
+ declare const index_ShotsResult: typeof ShotsResult;
346
231
  type index_ThumbnailOptions = ThumbnailOptions;
347
232
  type index_TranscriptFetchOptions = TranscriptFetchOptions;
348
233
  type index_TranscriptResult = TranscriptResult;
@@ -350,7 +235,7 @@ type index_VTTCue = VTTCue;
350
235
  type index_VTTCueBudgetChunkingOptions = VTTCueBudgetChunkingOptions;
351
236
  type index_VTTDurationChunk = VTTDurationChunk;
352
237
  type index_VTTDurationChunkingOptions = VTTDurationChunkingOptions;
353
- type index_WaitForShotsOptions = WaitForShotsOptions;
238
+ declare const index_WaitForShotsOptions: typeof WaitForShotsOptions;
354
239
  declare const index_buildTranscriptUrl: typeof buildTranscriptUrl;
355
240
  declare const index_buildVttFromCueBlocks: typeof buildVttFromCueBlocks;
356
241
  declare const index_buildVttFromTranslatedCueBlocks: typeof buildVttFromTranslatedCueBlocks;
@@ -383,7 +268,7 @@ declare const index_splitVttPreambleAndCueBlocks: typeof splitVttPreambleAndCueB
383
268
  declare const index_vttTimestampToSeconds: typeof vttTimestampToSeconds;
384
269
  declare const index_waitForShotsForAsset: typeof waitForShotsForAsset;
385
270
  declare namespace index {
386
- export { type index_CompletedShotsResult as CompletedShotsResult, index_DEFAULT_STORYBOARD_WIDTH as DEFAULT_STORYBOARD_WIDTH, type index_ErroredShotsResult as ErroredShotsResult, type index_HeatmapOptions as HeatmapOptions, type index_HeatmapResponse as HeatmapResponse, type index_Hotspot as Hotspot, type index_HotspotOptions as HotspotOptions, type index_HotspotResponse as HotspotResponse, type index_PendingShotsResult as PendingShotsResult, type index_Shot as Shot, type index_ShotRequestOptions as ShotRequestOptions, type index_ShotsResult as ShotsResult, type index_ThumbnailOptions as ThumbnailOptions, type index_TranscriptFetchOptions as TranscriptFetchOptions, type index_TranscriptResult as TranscriptResult, type index_VTTCue as VTTCue, type index_VTTCueBudgetChunkingOptions as VTTCueBudgetChunkingOptions, type index_VTTDurationChunk as VTTDurationChunk, type index_VTTDurationChunkingOptions as VTTDurationChunkingOptions, type index_WaitForShotsOptions as WaitForShotsOptions, index_buildTranscriptUrl as buildTranscriptUrl, index_buildVttFromCueBlocks as buildVttFromCueBlocks, index_buildVttFromTranslatedCueBlocks as buildVttFromTranslatedCueBlocks, index_chunkByTokens as chunkByTokens, index_chunkText as chunkText, index_chunkVTTCues as chunkVTTCues, index_chunkVTTCuesByBudget as chunkVTTCuesByBudget, index_chunkVTTCuesByDuration as chunkVTTCuesByDuration, index_concatenateVttSegments as concatenateVttSegments, index_estimateTokenCount as estimateTokenCount, index_extractTextFromVTT as extractTextFromVTT, index_extractTimestampedTranscript as extractTimestampedTranscript, index_fetchTranscriptForAsset as fetchTranscriptForAsset, index_findCaptionTrack as findCaptionTrack, index_getHeatmapForAsset as getHeatmapForAsset, index_getHeatmapForPlaybackId as getHeatmapForPlaybackId, index_getHeatmapForVideo as getHeatmapForVideo, index_getHotspotsForAsset as getHotspotsForAsset, index_getHotspotsForPlaybackId as getHotspotsForPlaybackId, index_getHotspotsForVideo as getHotspotsForVideo, index_getReadyTextTracks as getReadyTextTracks, index_getShotsForAsset as getShotsForAsset, index_getStoryboardUrl as getStoryboardUrl, index_getThumbnailUrls as getThumbnailUrls, index_parseVTTCues as parseVTTCues, index_replaceCueText as replaceCueText, index_requestShotsForAsset as requestShotsForAsset, index_secondsToTimestamp as secondsToTimestamp, index_splitVttPreambleAndCueBlocks as splitVttPreambleAndCueBlocks, index_vttTimestampToSeconds as vttTimestampToSeconds, index_waitForShotsForAsset as waitForShotsForAsset };
271
+ export { index_CompletedShotsResult as CompletedShotsResult, index_DEFAULT_STORYBOARD_WIDTH as DEFAULT_STORYBOARD_WIDTH, index_ErroredShotsResult as ErroredShotsResult, type index_HeatmapOptions as HeatmapOptions, type index_HeatmapResponse as HeatmapResponse, index_Hotspot as Hotspot, index_HotspotOptions as HotspotOptions, index_HotspotResponse as HotspotResponse, index_PendingShotsResult as PendingShotsResult, index_Shot as Shot, index_ShotRequestOptions as ShotRequestOptions, index_ShotsResult as ShotsResult, type index_ThumbnailOptions as ThumbnailOptions, type index_TranscriptFetchOptions as TranscriptFetchOptions, type index_TranscriptResult as TranscriptResult, type index_VTTCue as VTTCue, type index_VTTCueBudgetChunkingOptions as VTTCueBudgetChunkingOptions, type index_VTTDurationChunk as VTTDurationChunk, type index_VTTDurationChunkingOptions as VTTDurationChunkingOptions, index_WaitForShotsOptions as WaitForShotsOptions, index_buildTranscriptUrl as buildTranscriptUrl, index_buildVttFromCueBlocks as buildVttFromCueBlocks, index_buildVttFromTranslatedCueBlocks as buildVttFromTranslatedCueBlocks, index_chunkByTokens as chunkByTokens, index_chunkText as chunkText, index_chunkVTTCues as chunkVTTCues, index_chunkVTTCuesByBudget as chunkVTTCuesByBudget, index_chunkVTTCuesByDuration as chunkVTTCuesByDuration, index_concatenateVttSegments as concatenateVttSegments, index_estimateTokenCount as estimateTokenCount, index_extractTextFromVTT as extractTextFromVTT, index_extractTimestampedTranscript as extractTimestampedTranscript, index_fetchTranscriptForAsset as fetchTranscriptForAsset, index_findCaptionTrack as findCaptionTrack, index_getHeatmapForAsset as getHeatmapForAsset, index_getHeatmapForPlaybackId as getHeatmapForPlaybackId, index_getHeatmapForVideo as getHeatmapForVideo, index_getHotspotsForAsset as getHotspotsForAsset, index_getHotspotsForPlaybackId as getHotspotsForPlaybackId, index_getHotspotsForVideo as getHotspotsForVideo, index_getReadyTextTracks as getReadyTextTracks, index_getShotsForAsset as getShotsForAsset, index_getStoryboardUrl as getStoryboardUrl, index_getThumbnailUrls as getThumbnailUrls, index_parseVTTCues as parseVTTCues, index_replaceCueText as replaceCueText, index_requestShotsForAsset as requestShotsForAsset, index_secondsToTimestamp as secondsToTimestamp, index_splitVttPreambleAndCueBlocks as splitVttPreambleAndCueBlocks, index_vttTimestampToSeconds as vttTimestampToSeconds, index_waitForShotsForAsset as waitForShotsForAsset };
387
272
  }
388
273
 
389
- export { getHeatmapForAsset as A, getHeatmapForPlaybackId as B, type CompletedShotsResult as C, DEFAULT_STORYBOARD_WIDTH as D, type ErroredShotsResult as E, getHeatmapForVideo as F, getHotspotsForAsset as G, type HeatmapOptions as H, getHotspotsForPlaybackId as I, getHotspotsForVideo as J, getReadyTextTracks as K, getShotsForAsset as L, getStoryboardUrl as M, getThumbnailUrls as N, parseVTTCues as O, type PendingShotsResult as P, replaceCueText as Q, requestShotsForAsset as R, type Shot as S, type ThumbnailOptions as T, secondsToTimestamp as U, type VTTCue as V, type WaitForShotsOptions as W, splitVttPreambleAndCueBlocks as X, vttTimestampToSeconds as Y, waitForShotsForAsset as Z, type HeatmapResponse as a, type Hotspot as b, type HotspotOptions as c, type HotspotResponse as d, type ShotRequestOptions as e, type ShotsResult as f, type TranscriptFetchOptions as g, type TranscriptResult as h, index as i, type VTTCueBudgetChunkingOptions as j, type VTTDurationChunk as k, type VTTDurationChunkingOptions as l, buildTranscriptUrl as m, buildVttFromCueBlocks as n, buildVttFromTranslatedCueBlocks as o, chunkByTokens as p, chunkText as q, chunkVTTCues as r, chunkVTTCuesByBudget as s, chunkVTTCuesByDuration as t, concatenateVttSegments as u, estimateTokenCount as v, extractTextFromVTT as w, extractTimestampedTranscript as x, fetchTranscriptForAsset as y, findCaptionTrack as z };
274
+ export { getThumbnailUrls as A, parseVTTCues as B, replaceCueText as C, DEFAULT_STORYBOARD_WIDTH as D, secondsToTimestamp as E, splitVttPreambleAndCueBlocks as F, vttTimestampToSeconds as G, type HeatmapOptions as H, type ThumbnailOptions as T, type VTTCue as V, type HeatmapResponse as a, type TranscriptFetchOptions as b, type TranscriptResult as c, type VTTCueBudgetChunkingOptions as d, type VTTDurationChunk as e, type VTTDurationChunkingOptions as f, buildTranscriptUrl as g, buildVttFromCueBlocks as h, index as i, buildVttFromTranslatedCueBlocks as j, chunkByTokens as k, chunkText as l, chunkVTTCues as m, chunkVTTCuesByBudget as n, chunkVTTCuesByDuration as o, concatenateVttSegments as p, estimateTokenCount as q, extractTextFromVTT as r, extractTimestampedTranscript as s, fetchTranscriptForAsset as t, findCaptionTrack as u, getHeatmapForAsset as v, getHeatmapForPlaybackId as w, getHeatmapForVideo as x, getReadyTextTracks as y, getStoryboardUrl as z };
package/dist/index.d.ts CHANGED
@@ -1,15 +1,15 @@
1
- import { W as WorkflowCredentials, S as StoragePutObjectInput, a as StoragePresignGetObjectInput } from './types-BRbaGW3t.js';
2
- export { A as AssetTextTrack, C as ChunkEmbedding, b as ChunkingStrategy, E as Encrypted, c as EncryptedPayload, I as ImageSubmissionMode, M as MuxAIOptions, d as MuxAsset, P as PlaybackAsset, e as PlaybackPolicy, f as StorageAdapter, T as TextChunk, g as TokenChunkingConfig, h as TokenUsage, i as ToneType, U as UsageMetadata, V as VTTChunkingConfig, j as VideoEmbeddingsResult, k as WorkflowCredentialsInput, l as WorkflowMuxClient, m as decryptFromWorkflow, n as encryptForWorkflow } from './types-BRbaGW3t.js';
1
+ import { W as WorkflowCredentials, S as StoragePutObjectInput, a as StoragePresignGetObjectInput } from './shots-BFYOfBgN.js';
2
+ export { A as AssetTextTrack, C as ChunkEmbedding, b as ChunkingStrategy, E as Encrypted, c as EncryptedPayload, I as ImageSubmissionMode, M as MuxAIOptions, d as MuxAsset, P as PlaybackAsset, e as PlaybackPolicy, f as StorageAdapter, T as TextChunk, g as TokenChunkingConfig, h as TokenUsage, i as ToneType, U as UsageMetadata, V as VTTChunkingConfig, j as VideoEmbeddingsResult, k as WorkflowCredentialsInput, l as WorkflowMuxClient, m as decryptFromWorkflow, n as encryptForWorkflow } from './shots-BFYOfBgN.js';
3
3
  import { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE } from '@workflow/serde';
4
- export { i as primitives } from './index-DLhfJsOd.js';
5
- export { i as workflows } from './index-DyzifniY.js';
4
+ export { i as primitives } from './index-CuBu_u5-.js';
5
+ export { i as workflows } from './index-BeX_4DL7.js';
6
6
  import '@mux/mux-node';
7
7
  import 'zod';
8
8
  import '@ai-sdk/anthropic';
9
9
  import '@ai-sdk/google';
10
10
  import '@ai-sdk/openai';
11
11
 
12
- var version = "0.12.0";
12
+ var version = "0.13.0";
13
13
 
14
14
  /**
15
15
  * A function that returns workflow credentials, either synchronously or asynchronously.