@mux/ai 0.52.0 → 0.53.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/dist/{index-sqJ9PpHw.d.ts → index-BbxJ0X25.d.ts} +154 -17
- package/dist/index-cbaPe-aE.d.ts +225 -0
- package/dist/index.d.ts +8 -5
- package/dist/index.js +441 -175
- package/dist/index.js.map +1 -1
- package/dist/primitives/index.d.ts +2 -2
- package/dist/primitives/index.js +47 -33
- package/dist/primitives/index.js.map +1 -1
- package/dist/{shots-3wmvZnUV.d.ts → transcripts-BCtzC8hZ.d.ts} +200 -1
- package/dist/workflows/index.d.ts +2 -2
- package/dist/workflows/index.js +439 -174
- package/dist/workflows/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/index-nu1UOAMW.d.ts +0 -387
|
@@ -405,4 +405,203 @@ declare function getShotsForAsset(assetId: string, options?: ShotRequestOptions)
|
|
|
405
405
|
*/
|
|
406
406
|
declare function waitForShotsForAsset(assetId: string, options?: WaitForShotsOptions): Promise<CompletedShotsResult>;
|
|
407
407
|
|
|
408
|
-
|
|
408
|
+
/** A single cue from a VTT file with timing info. */
|
|
409
|
+
interface VTTCue {
|
|
410
|
+
startTime: number;
|
|
411
|
+
endTime: number;
|
|
412
|
+
text: string;
|
|
413
|
+
}
|
|
414
|
+
interface TranscriptFetchOptions {
|
|
415
|
+
languageCode?: string;
|
|
416
|
+
cleanTranscript?: boolean;
|
|
417
|
+
/** Optional asset-relative time range used to filter transcript cues. */
|
|
418
|
+
scope?: WorkflowScope;
|
|
419
|
+
/** Optional signing context for signed playback IDs */
|
|
420
|
+
shouldSign?: boolean;
|
|
421
|
+
credentials?: WorkflowCredentialsInput;
|
|
422
|
+
/**
|
|
423
|
+
* When true, throws a customer-safe `MuxAiError` if no usable transcript can
|
|
424
|
+
* be retrieved (no ready text track, missing track id, or empty transcript).
|
|
425
|
+
*
|
|
426
|
+
* Default behavior is non-fatal and returns an empty `transcriptText`.
|
|
427
|
+
*/
|
|
428
|
+
required?: boolean;
|
|
429
|
+
}
|
|
430
|
+
interface TranscriptResult {
|
|
431
|
+
transcriptText: string;
|
|
432
|
+
transcriptUrl?: string;
|
|
433
|
+
track?: AssetTextTrack;
|
|
434
|
+
}
|
|
435
|
+
declare function getReadyTextTracks(asset: MuxAsset): AssetTextTrack[];
|
|
436
|
+
declare function findCaptionTrack(asset: MuxAsset, languageCode?: string): AssetTextTrack | undefined;
|
|
437
|
+
/**
|
|
438
|
+
* Default minimum auto-detection confidence required to trust a track's language code.
|
|
439
|
+
* Below this threshold, the language is treated as undetermined.
|
|
440
|
+
*/
|
|
441
|
+
declare const LOW_CONFIDENCE_THRESHOLD = 0.5;
|
|
442
|
+
/**
|
|
443
|
+
* Extracts a trustworthy language code from a track, returning `undefined`
|
|
444
|
+
* when the language metadata shouldn't be used as an LLM output language.
|
|
445
|
+
*
|
|
446
|
+
* Returns `undefined` when:
|
|
447
|
+
* - The track or its language code is missing
|
|
448
|
+
* - The language code is undetermined (`und`, `mul`, `mis`, `zxx`)
|
|
449
|
+
* - The language was auto-detected with confidence below the threshold
|
|
450
|
+
*
|
|
451
|
+
* Trusts the language code when:
|
|
452
|
+
* - `auto_language_confidence` is absent (manually set or non-auto tracks)
|
|
453
|
+
* - `auto_language_confidence` meets the threshold
|
|
454
|
+
*
|
|
455
|
+
* @param track - The text track to inspect
|
|
456
|
+
* @param confidenceThreshold - Minimum confidence to trust auto-detected language (default: {@link LOW_CONFIDENCE_THRESHOLD})
|
|
457
|
+
*/
|
|
458
|
+
declare function getReliableLanguageCode(track: AssetTextTrack | undefined, confidenceThreshold?: number): string | undefined;
|
|
459
|
+
/**
|
|
460
|
+
* Sanitise untrusted text (typically a VTT cue or joined transcript)
|
|
461
|
+
* before it is interpolated into a prompt. Thin wrapper around the
|
|
462
|
+
* shared {@link normalizeUntrustedUnicode} helper, with a null/empty
|
|
463
|
+
* guard for convenience.
|
|
464
|
+
*/
|
|
465
|
+
declare function sanitizeUntrustedText(value: string): string;
|
|
466
|
+
/**
|
|
467
|
+
* Upper bound on individual cue text length before we consider the cue
|
|
468
|
+
* adversarial and truncate it.
|
|
469
|
+
*
|
|
470
|
+
* Legitimate captions are short — a long monologue cue rarely exceeds
|
|
471
|
+
* 500 characters, and most captioning standards recommend well under
|
|
472
|
+
* that for readability. We set the cap at 2000 to give comfortable
|
|
473
|
+
* headroom for edge cases (stage directions, speaker identification,
|
|
474
|
+
* multi-line blocks) while making "hide a multi-kilobyte injection
|
|
475
|
+
* payload inside a single cue" mechanically infeasible.
|
|
476
|
+
*/
|
|
477
|
+
declare const MAX_CUE_TEXT_CHARS = 2000;
|
|
478
|
+
/**
|
|
479
|
+
* Strip VTT metadata blocks that are never rendered by players but can
|
|
480
|
+
* still carry text through to an LLM when the raw VTT is used in a prompt:
|
|
481
|
+
*
|
|
482
|
+
* - NOTE blocks (VTT comments)
|
|
483
|
+
* - STYLE blocks (CSS for cue styling)
|
|
484
|
+
* - REGION blocks (positioning definitions)
|
|
485
|
+
*
|
|
486
|
+
* Viewers never see the contents of these blocks. That makes them an
|
|
487
|
+
* ideal hiding spot for prompt-injection payloads — an attacker-controlled
|
|
488
|
+
* caption file can carry hundreds of bytes of "NOTE ignore previous
|
|
489
|
+
* instructions…" that will be stripped from any player but will reach the
|
|
490
|
+
* model if the raw VTT is passed through. Removing them before sending
|
|
491
|
+
* the VTT to the model closes that channel without changing what the
|
|
492
|
+
* model sees for legitimate cue content.
|
|
493
|
+
*
|
|
494
|
+
* Cue identifiers, timing lines, and cue payload text are preserved.
|
|
495
|
+
* In particular: a cue whose first payload line happens to start with
|
|
496
|
+
* `NOTE `/`STYLE `/`REGION ` (plausible in legitimate captions — e.g.
|
|
497
|
+
* `"NOTE THAT..."`, `"STYLE GUIDE"`, `"NOTE how the villain plots..."`)
|
|
498
|
+
* is NOT treated as a metadata block. The scanner tracks cue-payload
|
|
499
|
+
* state: metadata headers are only recognised between cues (i.e. when
|
|
500
|
+
* the previous non-blank line was not a timing line).
|
|
501
|
+
*
|
|
502
|
+
* Example input:
|
|
503
|
+
*
|
|
504
|
+
* WEBVTT
|
|
505
|
+
*
|
|
506
|
+
* NOTE This is a comment with hidden instructions
|
|
507
|
+
* that span multiple lines until a blank line appears.
|
|
508
|
+
*
|
|
509
|
+
* STYLE
|
|
510
|
+
* ::cue(b) { font-weight: bold; }
|
|
511
|
+
*
|
|
512
|
+
* 00:00:01.000 --> 00:00:04.000
|
|
513
|
+
* Legitimate caption text
|
|
514
|
+
*
|
|
515
|
+
* 00:00:05.000 --> 00:00:08.000
|
|
516
|
+
* NOTE THAT the hero wins
|
|
517
|
+
*
|
|
518
|
+
* Returns:
|
|
519
|
+
*
|
|
520
|
+
* WEBVTT
|
|
521
|
+
*
|
|
522
|
+
* 00:00:01.000 --> 00:00:04.000
|
|
523
|
+
* Legitimate caption text
|
|
524
|
+
*
|
|
525
|
+
* 00:00:05.000 --> 00:00:08.000
|
|
526
|
+
* NOTE THAT the hero wins
|
|
527
|
+
*/
|
|
528
|
+
declare function stripVttMetadataBlocks(vttContent: string): string;
|
|
529
|
+
declare function extractTextFromVTT(vttContent: string): string;
|
|
530
|
+
declare function vttTimestampToSeconds(timestamp: string): number;
|
|
531
|
+
/**
|
|
532
|
+
* Converts seconds to a human-readable timestamp.
|
|
533
|
+
* Returns M:SS for durations under an hour, H:MM:SS for an hour or more.
|
|
534
|
+
*
|
|
535
|
+
* @param seconds - The number of seconds to convert
|
|
536
|
+
* @returns A formatted timestamp string (e.g., "2:05" or "01:02:05")
|
|
537
|
+
*/
|
|
538
|
+
declare function secondsToTimestamp(seconds: number): string;
|
|
539
|
+
declare function extractTimestampedTranscript(vttContent: string): string;
|
|
540
|
+
interface ParseVTTCuesOptions {
|
|
541
|
+
/**
|
|
542
|
+
* Truncate each cue's text to {@link MAX_CUE_TEXT_CHARS}. Defaults to
|
|
543
|
+
* `true`, which is right for any consumer that puts cue text into an LLM
|
|
544
|
+
* prompt. Pass `false` when the text goes to a classifier instead
|
|
545
|
+
* (e.g. moderation), where truncating would hide content from the check
|
|
546
|
+
* rather than defend against injection.
|
|
547
|
+
*/
|
|
548
|
+
capCueText?: boolean;
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* Parses VTT content into structured cues with timing.
|
|
552
|
+
*
|
|
553
|
+
* @param vttContent - Raw VTT file content
|
|
554
|
+
* @param options - See {@link ParseVTTCuesOptions}
|
|
555
|
+
* @returns Array of VTT cues with start/end times and text
|
|
556
|
+
*/
|
|
557
|
+
declare function parseVTTCues(vttContent: string, options?: ParseVTTCuesOptions): VTTCue[];
|
|
558
|
+
/**
|
|
559
|
+
* Keeps only VTT cues that overlap an asset-relative time range.
|
|
560
|
+
*
|
|
561
|
+
* Cue timestamps remain relative to the original asset; they are not rebased
|
|
562
|
+
* to the start of the scope.
|
|
563
|
+
*/
|
|
564
|
+
declare function filterVttByScope(vttContent: string, scope: WorkflowScope | undefined): string;
|
|
565
|
+
declare function splitVttPreambleAndCueBlocks(vttContent: string): {
|
|
566
|
+
preamble: string;
|
|
567
|
+
cueBlocks: string[];
|
|
568
|
+
};
|
|
569
|
+
declare function buildVttFromCueBlocks(cueBlocks: string[], preamble?: string): string;
|
|
570
|
+
declare function replaceCueText(cueBlock: string, translatedText: string): string;
|
|
571
|
+
declare function buildVttFromTranslatedCueBlocks(cueBlocks: string[], translatedTexts: string[], preamble?: string): string;
|
|
572
|
+
declare function concatenateVttSegments(segments: string[], preamble?: string): string;
|
|
573
|
+
/**
|
|
574
|
+
* Builds a transcript URL for the given playback ID and track ID.
|
|
575
|
+
* If a signing context is provided, the URL will be signed with a token.
|
|
576
|
+
*
|
|
577
|
+
* @param playbackId - The Mux playback ID
|
|
578
|
+
* @param trackId - The text track ID
|
|
579
|
+
* @param shouldSign - Flag for whether or not to use signed playback IDs
|
|
580
|
+
* @returns Transcript URL (signed if context provided)
|
|
581
|
+
*/
|
|
582
|
+
declare function buildTranscriptUrl(playbackId: string, trackId: string, shouldSign?: boolean, credentials?: WorkflowCredentialsInput): Promise<string>;
|
|
583
|
+
/**
|
|
584
|
+
* Why a fetched transcript had nothing usable:
|
|
585
|
+
* - `"empty_body"` — the VTT had no text at all.
|
|
586
|
+
* - `"no_scoped_cues"` — the VTT had cues, but none inside the requested `scope`.
|
|
587
|
+
*/
|
|
588
|
+
type TranscriptEmptyReason = "empty_body" | "no_scoped_cues";
|
|
589
|
+
interface TranscriptFetchStepResult {
|
|
590
|
+
transcriptText: string;
|
|
591
|
+
/** Set when `transcriptText` came back empty. */
|
|
592
|
+
emptyReason?: TranscriptEmptyReason;
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* Fetches and parses the VTT at an already-resolved transcript URL (see
|
|
596
|
+
* {@link buildTranscriptUrl}). An empty transcript is reported through
|
|
597
|
+
* `emptyReason` rather than thrown, so callers decide whether that is an
|
|
598
|
+
* error or a skip; {@link fetchTranscriptForAsset} is the wrapper that turns
|
|
599
|
+
* it into a customer-safe error when `required`.
|
|
600
|
+
*
|
|
601
|
+
* Throws on an HTTP/network failure while fetching the VTT file, so Workflow
|
|
602
|
+
* DevKit's normal step-retry applies to that genuinely-transient case.
|
|
603
|
+
*/
|
|
604
|
+
declare function fetchTranscriptDataForUrl(transcriptUrl: string, options?: Pick<TranscriptFetchOptions, "cleanTranscript" | "scope">): Promise<TranscriptFetchStepResult>;
|
|
605
|
+
declare function fetchTranscriptForAsset(asset: MuxAsset, playbackId: string, options?: TranscriptFetchOptions): Promise<TranscriptResult>;
|
|
606
|
+
|
|
607
|
+
export { fetchTranscriptDataForUrl as $, type AssetTextTrack as A, type ShotsResult as B, type ChunkEmbedding as C, type DeletedShotsResult as D, type Encrypted as E, type SkippedShotsResult as F, type TranscriptEmptyReason as G, type Hotspot as H, type ImageSubmissionMode as I, type TranscriptFetchOptions as J, type TranscriptFetchStepResult as K, LOW_CONFIDENCE_THRESHOLD as L, type MuxAsset as M, type TranscriptResult as N, type WaitForShotsOptions as O, type PlaybackAsset as P, buildTranscriptUrl as Q, buildVttFromCueBlocks as R, type StoragePutObjectInput as S, type TextChunk as T, type UsageMetadata as U, type VTTChunkingConfig as V, type WorkflowCredentials as W, buildVttFromTranslatedCueBlocks as X, concatenateVttSegments as Y, extractTextFromVTT as Z, extractTimestampedTranscript as _, type StoragePresignGetObjectInput as a, fetchTranscriptForAsset as a0, filterVttByScope as a1, findCaptionTrack as a2, getHotspotsForAsset as a3, getHotspotsForPlaybackId as a4, getHotspotsForVideo as a5, getReadyTextTracks as a6, getReliableLanguageCode as a7, getShotsForAsset as a8, parseVTTCues as a9, replaceCueText as aa, requestShotsForAsset as ab, sanitizeUntrustedText as ac, secondsToTimestamp as ad, splitVttPreambleAndCueBlocks as ae, stripVttMetadataBlocks as af, vttTimestampToSeconds as ag, waitForShotsForAsset as ah, type ChunkingStrategy as b, type EncryptedPayload as c, type MuxAIOptions as d, type PlaybackPolicy as e, type ScopedMuxAIOptions as f, type StorageAdapter as g, type TokenChunkingConfig as h, type TokenUsage as i, type ToneType as j, type VideoEmbeddingsResult as k, type WorkflowCredentialsInput as l, type WorkflowMuxClient as m, type WorkflowScope as n, decryptFromWorkflow as o, encryptForWorkflow as p, type VTTCue as q, type CompletedShotsResult as r, type ErroredShotsResult as s, type HotspotOptions as t, type HotspotResponse as u, MAX_CUE_TEXT_CHARS as v, type ParseVTTCuesOptions as w, type PendingShotsResult as x, type Shot as y, type ShotRequestOptions as z };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { J as ASK_QUESTIONS_DEFAULT_MAX_ANSWER_OPTION_LENGTH, K as ASK_QUESTIONS_DEFAULT_MAX_FREE_FORM_ANSWER_LENGTH, N as ASK_QUESTIONS_MAX_QUESTIONS_PER_CALL, O as ASK_QUESTIONS_MAX_QUESTION_LENGTH, P as AskQuestionsOptions, Q as AskQuestionsResult, U as AskQuestionsType, V as AudioTranslationOptions, W as AudioTranslationResult, X as AutoCensorProfanityOptions, Y as BurnedInCaptionsAnalysis, Z as BurnedInCaptionsOptions, _ as BurnedInCaptionsPromptOverrides, $ as BurnedInCaptionsPromptSections, a0 as BurnedInCaptionsResult, a1 as CaptionReplacement, a2 as CensorMode, a3 as Chapter, a4 as ChapterSystemPromptSections, a5 as ChaptersOptions, a6 as ChaptersPromptOverrides, a7 as ChaptersPromptSections, a8 as ChaptersResult, a9 as ChaptersType, aa as
|
|
1
|
+
export { J as ASK_QUESTIONS_DEFAULT_MAX_ANSWER_OPTION_LENGTH, K as ASK_QUESTIONS_DEFAULT_MAX_FREE_FORM_ANSWER_LENGTH, N as ASK_QUESTIONS_MAX_QUESTIONS_PER_CALL, O as ASK_QUESTIONS_MAX_QUESTION_LENGTH, P as AskQuestionsOptions, Q as AskQuestionsResult, U as AskQuestionsType, V as AudioTranslationOptions, W as AudioTranslationResult, X as AutoCensorProfanityOptions, Y as BurnedInCaptionsAnalysis, Z as BurnedInCaptionsOptions, _ as BurnedInCaptionsPromptOverrides, $ as BurnedInCaptionsPromptSections, a0 as BurnedInCaptionsResult, a1 as CaptionReplacement, a2 as CensorMode, a3 as Chapter, a4 as ChapterSystemPromptSections, a5 as ChaptersOptions, a6 as ChaptersPromptOverrides, a7 as ChaptersPromptSections, a8 as ChaptersResult, a9 as ChaptersType, aa as DEFAULT_TRANSCRIPT_WINDOWING, ab as EditCaptionsOptions, ac as EditCaptionsResult, ad as EmbeddingsOptions, ae as EmbeddingsResult, af as EngagementInsightsOptions, ag as EngagementInsightsResult, ah as GENERATE_TEXT_CALLS_TO_ACTION, ai as GENERATE_TEXT_CHANNELS, aj as GENERATE_TEXT_CHANNEL_CEILINGS, ak as GENERATE_TEXT_FORMATS, al as GENERATE_TEXT_LENGTH_BOUNDS, am as GENERATE_TEXT_MAX_ARTIFACTS, an as GENERATE_TEXT_MAX_AUDIENCE_CHARS, ao as GENERATE_TEXT_MAX_BRAND_TERMS, ap as GENERATE_TEXT_MAX_BRAND_TERMS_TOTAL_CHARS, aq as GENERATE_TEXT_MAX_BRAND_TERM_CHARS, ar as GENERATE_TEXT_MAX_CONCURRENT_GENERATIONS, as as GENERATE_TEXT_MAX_INSTRUCTIONS_CHARS, at as GENERATE_TEXT_MAX_SHOT_FRAMES, au as GENERATE_TEXT_MAX_VARIANTS, av as GENERATE_TEXT_VOICES, aw as GOOGLE_VISION_LIKELIHOOD_TO_SCORE, ax as GenerateTextArtifact, ay as GenerateTextCallToAction, az as GenerateTextChannel, aA as GenerateTextFormat, aB as GenerateTextKeyedItem, aC as GenerateTextLengthLimit, aD as GenerateTextOptions, aE as GenerateTextResult, aF as GenerateTextVariant, aG as GenerateTextVoice, aH as GeneratedTextArtifact, aI as GeneratedTextVariant, aJ as HIVE_SEXUAL_CATEGORIES, aK as HIVE_VIOLENCE_CATEGORIES, aL as HiveModerationOutput, aM as HiveModerationSource, aN as ModerationOptions, aO as ModerationProvider, aP as ModerationResult, aQ as ModerationSurfaceStatus, aR as MomentInsight, aS as OverallInsight, aT as ProfanityDetectionPayload, aU as Question, aV as QuestionAnswer, aW as QuestionAnswerType, aX as RepairAttempt, aY as RepairCall, aZ as RepairOptions, a_ as RepairPlan, a$ as RepairResult, b0 as RepairSpan, b1 as ReplacementRecord, b2 as SpeakerReplacement, b3 as StaticRenditionCleanupOutcome, b4 as SummarizationOptions, b5 as SummarizationPromptOverrides, b6 as SummarizationPromptSections, b7 as SummaryAndTagsResult, b8 as SummaryType, b9 as TextLengthLimit, ba as TextRepairModelOptions, bb as ThumbnailModerationScore, bc as ThumbnailModerationSkipReason, bd as ThumbnailModerationStatus, be as TranscriptModerationScore, bf as TranscriptModerationSkipReason, bg as TranscriptModerationStatus, bh as TranslationChunkingOptions, bi as TranslationOptions, bj as TranslationPayload, bk as TranslationResult, bl as aggregateTokenUsage, bm as applyOverrideLists, bn as applyReplacements, bo as applySpeakerReplacements, bp as applyTextRepair, bq as askQuestions, br as buildReplacementRegex, bs as buildTranscriptWindows, bt as burnedInCaptionsSchema, bu as censorVttContent, bv as chapterSchema, bw as chaptersSchema, bx as createReplacer, by as createTextRepairGenerator, bz as editCaptions, bA as extractTranscriptSegmentsForHotspots, bB as findGenerateTextLengthViolation, bC as generateChapters, bD as generateEmbeddings, bE as generateEngagementInsights, bF as generateText, bG as generateVideoEmbeddings, bH as getModerationScores, bI as getSummaryAndTags, bJ as hasBurnedInCaptions, bK as mapShotsToHotspots, bL as measureGenerateTextLength, bM as normalizeTranslatedVtt, bN as planTextRepair, bO as profanityDetectionSchema, bP as questionAnswerSchema, bQ as repairJsonSchema, bR as repairText, bS as resolveGenerateTextLengthLimit, bT as resolveGenerateTextLengthLimits, bU as resolveGenerateTextOptions, bV as runTextRepairLoop, bW as selectGenerateTextShotFrames, bX as shouldSplitChunkTranslationError, bY as summarySchema, bZ as transformCueText, b_ as translateAudio, b$ as translateCaptions, c0 as translationSchema, c1 as validateNeverTranslateTerms, c2 as verifyNeverTranslateTerms } from '../index-BbxJ0X25.js';
|
|
2
2
|
export { D as DEFAULT_DESCRIPTION_LENGTH, a as DEFAULT_SUMMARY_KEYWORD_LIMIT, b as DEFAULT_TITLE_LENGTH } from '../summarization-BFmhXeAu.js';
|
|
3
3
|
import 'ai';
|
|
4
|
-
import '../
|
|
4
|
+
import '../transcripts-BCtzC8hZ.js';
|
|
5
5
|
import '@mux/ts';
|
|
6
6
|
import 'zod';
|
|
7
7
|
import '@ai-sdk/anthropic';
|