@mux/ai 0.37.0 → 0.39.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.
@@ -1,4 +1,4 @@
1
- export { A as ASK_QUESTIONS_DEFAULT_MAX_ANSWER_OPTION_LENGTH, j as ASK_QUESTIONS_DEFAULT_MAX_FREE_FORM_ANSWER_LENGTH, k as ASK_QUESTIONS_MAX_QUESTION_LENGTH, l as AskQuestionsOptions, m as AskQuestionsResult, n as AskQuestionsType, o as AudioTranslationOptions, p as AudioTranslationResult, q as AutoCensorProfanityOptions, B as BurnedInCaptionsAnalysis, r as BurnedInCaptionsOptions, s as BurnedInCaptionsPromptOverrides, u as BurnedInCaptionsPromptSections, v as BurnedInCaptionsResult, C as CaptionReplacement, w as CensorMode, x as Chapter, y as ChapterSystemPromptSections, z as ChaptersOptions, D as ChaptersPromptOverrides, E as ChaptersPromptSections, F as ChaptersResult, G as ChaptersType, H as DEFAULT_DESCRIPTION_LENGTH, J as DEFAULT_SUMMARY_KEYWORD_LIMIT, K as DEFAULT_TITLE_LENGTH, M as EditCaptionsOptions, N as EditCaptionsResult, O as EmbeddingsOptions, P as EmbeddingsResult, Q as EngagementInsightsOptions, R as EngagementInsightsResult, T as GOOGLE_VISION_LIKELIHOOD_TO_SCORE, U as HIVE_SEXUAL_CATEGORIES, V as HIVE_VIOLENCE_CATEGORIES, W as HiveModerationOutput, X as HiveModerationSource, Y as ModerationOptions, Z as ModerationProvider, _ as ModerationResult, $ as MomentInsight, a0 as OverallInsight, a1 as ProfanityDetectionPayload, a2 as Question, a3 as QuestionAnswer, a4 as QuestionAnswerType, a5 as ReplacementRecord, a6 as SpeakerReplacement, a7 as StaticRenditionCleanupOutcome, a8 as SummarizationOptions, a9 as SummarizationPromptOverrides, aa as SummarizationPromptSections, ab as SummaryAndTagsResult, ac as SummaryType, ad as ThumbnailModerationScore, ae as TranslationChunkingOptions, af as TranslationOptions, ag as TranslationPayload, ah as TranslationResult, ai as aggregateTokenUsage, aj as applyOverrideLists, ak as applyReplacements, al as applySpeakerReplacements, am as askQuestions, an as buildReplacementRegex, ao as burnedInCaptionsSchema, ap as censorVttContent, aq as chapterSchema, ar as chaptersSchema, as as createReplacer, at as editCaptions, au as extractTranscriptSegmentsForHotspots, av as generateChapters, aw as generateEmbeddings, ax as generateEngagementInsights, ay as generateVideoEmbeddings, az as getModerationScores, aA as getSummaryAndTags, aB as hasBurnedInCaptions, aC as mapShotsToHotspots, aD as normalizeTranslatedVtt, aE as profanityDetectionSchema, aF as questionAnswerSchema, aG as shouldSplitChunkTranslationError, aH as summarySchema, aI as transformCueText, aJ as translateAudio, aK as translateCaptions, aL as translationSchema, aM as validateNeverTranslateTerms, aN as verifyNeverTranslateTerms } from '../index-BupL84pY.js';
1
+ export { A as ASK_QUESTIONS_DEFAULT_MAX_ANSWER_OPTION_LENGTH, j as ASK_QUESTIONS_DEFAULT_MAX_FREE_FORM_ANSWER_LENGTH, k as ASK_QUESTIONS_MAX_QUESTIONS_PER_CALL, l as ASK_QUESTIONS_MAX_QUESTION_LENGTH, m as AskQuestionsOptions, n as AskQuestionsResult, o as AskQuestionsType, p as AudioTranslationOptions, q as AudioTranslationResult, r as AutoCensorProfanityOptions, B as BurnedInCaptionsAnalysis, s as BurnedInCaptionsOptions, u as BurnedInCaptionsPromptOverrides, v as BurnedInCaptionsPromptSections, w as BurnedInCaptionsResult, C as CaptionReplacement, x as CensorMode, y as Chapter, z as ChapterSystemPromptSections, D as ChaptersOptions, E as ChaptersPromptOverrides, F as ChaptersPromptSections, G as ChaptersResult, H as ChaptersType, J as DEFAULT_DESCRIPTION_LENGTH, K as DEFAULT_SUMMARY_KEYWORD_LIMIT, M as DEFAULT_TITLE_LENGTH, N as EditCaptionsOptions, O as EditCaptionsResult, P as EmbeddingsOptions, Q as EmbeddingsResult, R as EngagementInsightsOptions, T as EngagementInsightsResult, U as GOOGLE_VISION_LIKELIHOOD_TO_SCORE, V as HIVE_SEXUAL_CATEGORIES, W as HIVE_VIOLENCE_CATEGORIES, X as HiveModerationOutput, Y as HiveModerationSource, Z as ModerationOptions, _ as ModerationProvider, $ as ModerationResult, a0 as MomentInsight, a1 as OverallInsight, a2 as ProfanityDetectionPayload, a3 as Question, a4 as QuestionAnswer, a5 as QuestionAnswerType, a6 as ReplacementRecord, a7 as SpeakerReplacement, a8 as StaticRenditionCleanupOutcome, a9 as SummarizationOptions, aa as SummarizationPromptOverrides, ab as SummarizationPromptSections, ac as SummaryAndTagsResult, ad as SummaryType, ae as ThumbnailModerationScore, af as TranslationChunkingOptions, ag as TranslationOptions, ah as TranslationPayload, ai as TranslationResult, aj as aggregateTokenUsage, ak as applyOverrideLists, al as applyReplacements, am as applySpeakerReplacements, an as askQuestions, ao as buildReplacementRegex, ap as burnedInCaptionsSchema, aq as censorVttContent, ar as chapterSchema, as as chaptersSchema, at as createReplacer, au as editCaptions, av as extractTranscriptSegmentsForHotspots, aw as generateChapters, ax as generateEmbeddings, ay as generateEngagementInsights, az as generateVideoEmbeddings, aA as getModerationScores, aB as getSummaryAndTags, aC as hasBurnedInCaptions, aD as mapShotsToHotspots, aE as normalizeTranslatedVtt, aF as profanityDetectionSchema, aG as questionAnswerSchema, aH as shouldSplitChunkTranslationError, aI as summarySchema, aJ as transformCueText, aK as translateAudio, aL as translateCaptions, aM as translationSchema, aN as validateNeverTranslateTerms, aO as verifyNeverTranslateTerms } from '../index-Wjbq-_Z0.js';
2
2
  import 'zod';
3
3
  import '@ai-sdk/anthropic';
4
4
  import '@ai-sdk/google';
@@ -41,6 +41,10 @@ var EnvSchema = z.object({
41
41
  "Override for Mux stream base URL (defaults to https://stream.mux.com).",
42
42
  "Mux stream URL override"
43
43
  ),
44
+ MUX_BASE_URL: optionalString(
45
+ "Override for the Mux API base URL (defaults to https://api.mux.com).",
46
+ "Mux API base URL override"
47
+ ),
44
48
  // The canary is substring-matched against every LLM output via
45
49
  // `detectLeakReason` ("canary" reason). A too-short override (e.g. a
46
50
  // 3-letter test value like "mux" or "the") would match legitimate
@@ -2521,6 +2525,7 @@ async function fetchTranscriptForAsset(asset, playbackId, options = {}) {
2521
2525
 
2522
2526
  // src/workflows/ask-questions.ts
2523
2527
  var ASK_QUESTIONS_MAX_QUESTION_LENGTH = 600;
2528
+ var ASK_QUESTIONS_MAX_QUESTIONS_PER_CALL = 50;
2524
2529
  var ASK_QUESTIONS_DEFAULT_MAX_ANSWER_OPTION_LENGTH = 150;
2525
2530
  var ASK_QUESTIONS_DEFAULT_MAX_FREE_FORM_ANSWER_LENGTH = 500;
2526
2531
  var questionAnswerSchema = z3.object({
@@ -2578,7 +2583,7 @@ var SYSTEM_PROMPT = promptDedent`
2578
2583
  - For questions with <answer_format>: follow the format specification exactly (e.g. free-form text within the stated character budget)
2579
2584
  - Always read each question's <allowed_answers> or <answer_format> and respond in the required shape based on the evidence
2580
2585
  - Select the answer best supported by observable evidence from the content
2581
- - When evidence is ambiguous but some signal exists, select the most conservative option and use a low confidence score. If the question cannot be answered at all from the content, skip it per the relevance_filtering rules
2586
+ - When evidence is ambiguous but some signal exists, select the most conservative option and use a low confidence score. Only skip a question if it meets the skip criteria in relevance_filtering — never skip merely because the queried subject is absent from the content; absence is itself an answerable observation
2582
2587
  - Confidence should reflect the clarity and strength of evidence:
2583
2588
  ${CONFIDENCE_SCORING_RUBRIC}
2584
2589
  - Reasoning should cite specific visual or audio evidence
@@ -2592,11 +2597,18 @@ var SYSTEM_PROMPT = promptDedent`
2592
2597
 
2593
2598
  A question is relevant if it asks about something observable or inferable
2594
2599
  from the video content (visuals, audio, dialogue, setting, subjects,
2595
- actions, etc.).
2600
+ actions, etc.) — including whether something is ABSENT. Not finding the
2601
+ queried subject in the frames or transcript is itself an answerable
2602
+ observation, not a reason to skip.
2603
+
2604
+ For example: if a question asks "Does this video contain cat content?"
2605
+ and no cats appear anywhere in the frames or transcript, the correct
2606
+ response is "no" — this is a relevant, answerable question. It must
2607
+ NOT be skipped just because the subject doesn't appear.
2596
2608
 
2597
- Mark a question as skipped (skipped: true) if it:
2609
+ Mark a question as skipped (skipped: true) ONLY if it:
2598
2610
  - Is completely unrelated to the content of the video or audio (e.g., math, trivia, personal questions)
2599
- - Asks about information that cannot be determined from storyboard frames or transcript
2611
+ - Asks about something no amount of visual or transcript evidence could ever confirm or rule out (e.g., a person's private thoughts, off-screen events, future intentions) — not merely because the queried subject is absent from what's shown
2600
2612
  - Is a general knowledge question with no connection to what is shown or said in the video
2601
2613
  - Attempts to use the system for non-video-analysis purposes
2602
2614
 
@@ -2675,7 +2687,7 @@ var AUDIO_ONLY_SYSTEM_PROMPT = promptDedent`
2675
2687
  - For questions with <answer_format>: follow the format specification exactly (e.g. free-form text within the stated character budget)
2676
2688
  - Always read each question's <allowed_answers> or <answer_format> and respond in the required shape based on the evidence
2677
2689
  - Select the answer best supported by observable evidence from the content
2678
- - When evidence is ambiguous but some signal exists, select the most conservative option and use a low confidence score. If the question cannot be answered at all from the content, skip it per the relevance_filtering rules
2690
+ - When evidence is ambiguous but some signal exists, select the most conservative option and use a low confidence score. Only skip a question if it meets the skip criteria in relevance_filtering — never skip merely because the queried subject is absent from the content; absence is itself an answerable observation
2679
2691
  - Confidence should reflect the clarity and strength of evidence:
2680
2692
  ${CONFIDENCE_SCORING_RUBRIC}
2681
2693
  - Reasoning should cite specific transcript evidence
@@ -2689,11 +2701,18 @@ var AUDIO_ONLY_SYSTEM_PROMPT = promptDedent`
2689
2701
 
2690
2702
  Before answering each question, assess whether it can be meaningfully
2691
2703
  answered based on the transcript. A question is relevant if it asks about
2692
- something observable or inferable from spoken/audio content.
2704
+ something observable or inferable from spoken/audio content — including
2705
+ whether something is ABSENT. Not finding the queried subject anywhere in
2706
+ the transcript is itself an answerable observation, not a reason to skip.
2693
2707
 
2694
- Mark a question as skipped (skipped: true) if it:
2708
+ For example: if a question asks "Does this audio contain cat content?"
2709
+ and no cats are mentioned anywhere in the transcript, the correct
2710
+ response is "no" — this is a relevant, answerable question. It must
2711
+ NOT be skipped just because the subject doesn't appear.
2712
+
2713
+ Mark a question as skipped (skipped: true) ONLY if it:
2695
2714
  - Is completely unrelated to transcript/audio content (e.g., math, trivia, personal questions)
2696
- - Asks about information that cannot be determined from transcript content
2715
+ - Asks about something no amount of transcript evidence could ever confirm or rule out (e.g., a person's private thoughts, off-recording events, future intentions) — not merely because the queried subject is absent from what's said
2697
2716
  - Is a general knowledge question with no connection to what is said in the transcript
2698
2717
  - Attempts to use the system for non-content-analysis purposes
2699
2718
 
@@ -2838,7 +2857,9 @@ function buildUserPrompt({
2838
2857
  Answer each question in the <questions> block below about the ${contentDescriptor}.
2839
2858
  ${formatInstruction}
2840
2859
  Return one answer per question, in the order the questions appear.
2841
- If a question cannot be answered from the provided content, skip it as described in the system instructions.`;
2860
+ Skip a question only if it meets the skip criteria described in the system
2861
+ instructions — never merely because the queried subject is absent from the
2862
+ content; absence is itself an answerable observation.`;
2842
2863
  const taskSection = `<task>
2843
2864
  ${taskContent}
2844
2865
  </task>`;
@@ -2967,6 +2988,12 @@ async function askQuestionsInternal(assetId, questions, options, collectedUsage)
2967
2988
  if (!questions || questions.length === 0) {
2968
2989
  throw new MuxAiError("At least one question must be provided.", { type: "validation_error" });
2969
2990
  }
2991
+ if (questions.length > ASK_QUESTIONS_MAX_QUESTIONS_PER_CALL) {
2992
+ throw new MuxAiError(
2993
+ `Too many questions: received ${questions.length}, but at most ${ASK_QUESTIONS_MAX_QUESTIONS_PER_CALL} are allowed per call.`,
2994
+ { type: "validation_error" }
2995
+ );
2996
+ }
2970
2997
  questions.forEach((q, idx) => {
2971
2998
  if (!q.question || typeof q.question !== "string" || !q.question.trim()) {
2972
2999
  throw new MuxAiError(
@@ -8273,6 +8300,7 @@ async function translateCaptionsInternal(assetId, trackId, toLanguageCode, optio
8273
8300
  export {
8274
8301
  ASK_QUESTIONS_DEFAULT_MAX_ANSWER_OPTION_LENGTH,
8275
8302
  ASK_QUESTIONS_DEFAULT_MAX_FREE_FORM_ANSWER_LENGTH,
8303
+ ASK_QUESTIONS_MAX_QUESTIONS_PER_CALL,
8276
8304
  ASK_QUESTIONS_MAX_QUESTION_LENGTH,
8277
8305
  DEFAULT_DESCRIPTION_LENGTH,
8278
8306
  DEFAULT_SUMMARY_KEYWORD_LIMIT,