@mux/ai 0.13.1 → 0.15.1
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 +2 -2
- package/dist/{index-BeX_4DL7.d.ts → index-yn3fUDgv.d.ts} +67 -16
- package/dist/index.d.ts +40 -3
- package/dist/index.js +678 -461
- package/dist/index.js.map +1 -1
- package/dist/primitives/index.js +48 -12
- package/dist/primitives/index.js.map +1 -1
- package/dist/workflows/index.d.ts +1 -1
- package/dist/workflows/index.js +622 -408
- package/dist/workflows/index.js.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -71,7 +71,7 @@ Workflows are high-level functions that handle complete media AI tasks end-to-en
|
|
|
71
71
|
| [`getSummaryAndTags`](./docs/WORKFLOWS.md#video-summarization) | Generate titles, descriptions, and tags | OpenAI, Anthropic, Google | Yes |
|
|
72
72
|
| [`getModerationScores`](./docs/WORKFLOWS.md#content-moderation) | Detect inappropriate content | OpenAI, Hive | Yes |
|
|
73
73
|
| [`hasBurnedInCaptions`](./docs/WORKFLOWS.md#burned-in-caption-detection) | Detect hardcoded subtitles in video frames | OpenAI, Anthropic, Google | — |
|
|
74
|
-
| [`askQuestions`](./docs/WORKFLOWS.md#ask-questions) | Answer yes/no questions about asset content | OpenAI, Anthropic, Google |
|
|
74
|
+
| [`askQuestions`](./docs/WORKFLOWS.md#ask-questions) | Answer yes/no questions about asset content | OpenAI, Anthropic, Google | Yes |
|
|
75
75
|
| [`generateChapters`](./docs/WORKFLOWS.md#chapter-generation) | Create chapter markers from transcripts | OpenAI, Anthropic, Google | Yes |
|
|
76
76
|
| [`generateEmbeddings`](./docs/WORKFLOWS.md#embeddings) | Generate vector embeddings for semantic search | OpenAI, Google | Yes |
|
|
77
77
|
| [`translateCaptions`](./docs/WORKFLOWS.md#caption-translation) | Translate captions into other languages | OpenAI, Anthropic, Google | Yes |
|
|
@@ -102,7 +102,7 @@ if (result.exceedsThreshold) {
|
|
|
102
102
|
```ts
|
|
103
103
|
import { generateChapters } from "@mux/ai/workflows";
|
|
104
104
|
|
|
105
|
-
const result = await generateChapters("your-asset-id",
|
|
105
|
+
const result = await generateChapters("your-asset-id", {
|
|
106
106
|
provider: "anthropic"
|
|
107
107
|
});
|
|
108
108
|
|
|
@@ -34,7 +34,7 @@ interface EmbeddingModelIdByProvider {
|
|
|
34
34
|
google: GoogleEmbeddingModelId;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
/** A single yes/no question to be answered about
|
|
37
|
+
/** A single yes/no question to be answered about asset content. */
|
|
38
38
|
interface Question {
|
|
39
39
|
/** The question text */
|
|
40
40
|
question: string;
|
|
@@ -49,7 +49,7 @@ interface QuestionAnswer {
|
|
|
49
49
|
confidence: number;
|
|
50
50
|
/** Reasoning explaining the answer, or why the question was skipped */
|
|
51
51
|
reasoning: string;
|
|
52
|
-
/** Whether the question was skipped due to irrelevance to the
|
|
52
|
+
/** Whether the question was skipped due to irrelevance to the asset content */
|
|
53
53
|
skipped: boolean;
|
|
54
54
|
}
|
|
55
55
|
/** Configuration options for askQuestions workflow. */
|
|
@@ -58,9 +58,11 @@ interface AskQuestionsOptions extends MuxAIOptions {
|
|
|
58
58
|
provider?: SupportedProvider;
|
|
59
59
|
/** Provider-specific chat model identifier. */
|
|
60
60
|
model?: ModelIdByProvider[SupportedProvider];
|
|
61
|
+
/** BCP 47 language code of the caption track to use (e.g. "en", "fr"). When omitted, prefers English if available. */
|
|
62
|
+
languageCode?: string;
|
|
61
63
|
/** Allowed answers for each question (defaults to ["yes", "no"]). */
|
|
62
64
|
answerOptions?: string[];
|
|
63
|
-
/** Fetch transcript alongside storyboard (defaults to true). */
|
|
65
|
+
/** Fetch transcript alongside storyboard (defaults to true, required for audio-only assets). */
|
|
64
66
|
includeTranscript?: boolean;
|
|
65
67
|
/** Strip timestamps/markup from transcripts (defaults to true). */
|
|
66
68
|
cleanTranscript?: boolean;
|
|
@@ -77,8 +79,8 @@ interface AskQuestionsResult {
|
|
|
77
79
|
assetId: string;
|
|
78
80
|
/** Array of answers for each question. */
|
|
79
81
|
answers: QuestionAnswer[];
|
|
80
|
-
/** Storyboard image URL that was analyzed. */
|
|
81
|
-
storyboardUrl
|
|
82
|
+
/** Storyboard image URL that was analyzed (undefined for audio-only assets). */
|
|
83
|
+
storyboardUrl?: string;
|
|
82
84
|
/** Token usage from the AI provider (for efficiency/cost analysis). */
|
|
83
85
|
usage?: TokenUsage;
|
|
84
86
|
/** Raw transcript text used for analysis (when includeTranscript is true). */
|
|
@@ -146,7 +148,8 @@ declare function createAskQuestionsSchema(allowedAnswers: [string, ...string[]])
|
|
|
146
148
|
type AskQuestionsSchema = ReturnType<typeof createAskQuestionsSchema>;
|
|
147
149
|
type AskQuestionsType = z.infer<AskQuestionsSchema>;
|
|
148
150
|
/**
|
|
149
|
-
* Answer questions about a Mux
|
|
151
|
+
* Answer questions about a Mux asset by analyzing storyboard frames and transcript.
|
|
152
|
+
* For audio-only assets, this workflow analyzes transcript content only.
|
|
150
153
|
* Defaults to yes/no answers unless `answerOptions` are provided.
|
|
151
154
|
*
|
|
152
155
|
* This workflow takes a list of questions and returns structured answers with confidence
|
|
@@ -315,7 +318,7 @@ type ChaptersPromptSections = "task" | "outputFormat" | "chapterGuidelines" | "t
|
|
|
315
318
|
*
|
|
316
319
|
* @example
|
|
317
320
|
* ```typescript
|
|
318
|
-
* const result = await generateChapters(assetId,
|
|
321
|
+
* const result = await generateChapters(assetId, {
|
|
319
322
|
* promptOverrides: {
|
|
320
323
|
* titleGuidelines: "Use short, punchy titles under 6 words.",
|
|
321
324
|
* },
|
|
@@ -325,6 +328,8 @@ type ChaptersPromptSections = "task" | "outputFormat" | "chapterGuidelines" | "t
|
|
|
325
328
|
type ChaptersPromptOverrides = PromptOverrides<ChaptersPromptSections>;
|
|
326
329
|
/** Configuration accepted by `generateChapters`. */
|
|
327
330
|
interface ChaptersOptions extends MuxAIOptions {
|
|
331
|
+
/** BCP 47 language code of the caption track to use (e.g. "en", "fr"). When omitted, prefers English if available. */
|
|
332
|
+
languageCode?: string;
|
|
328
333
|
/** AI provider used to interpret the transcript (defaults to 'openai'). */
|
|
329
334
|
provider?: SupportedProvider;
|
|
330
335
|
/** Provider-specific model identifier. */
|
|
@@ -356,7 +361,7 @@ interface ChaptersOptions extends MuxAIOptions {
|
|
|
356
361
|
* Use these to customize the AI's persona and constraints.
|
|
357
362
|
*/
|
|
358
363
|
type ChapterSystemPromptSections = "role" | "context" | "constraints" | "qualityGuidelines";
|
|
359
|
-
declare function generateChapters(assetId: string,
|
|
364
|
+
declare function generateChapters(assetId: string, options?: ChaptersOptions): Promise<ChaptersResult>;
|
|
360
365
|
|
|
361
366
|
/** Replacement strategy for censored words. */
|
|
362
367
|
type CensorMode = "blank" | "remove" | "mask";
|
|
@@ -387,8 +392,17 @@ interface EditCaptionsOptions<P extends SupportedProvider = SupportedProvider> e
|
|
|
387
392
|
/** Delete the original track after creating the edited one. Defaults to true. */
|
|
388
393
|
deleteOriginalTrack?: boolean;
|
|
389
394
|
/**
|
|
390
|
-
* When true
|
|
391
|
-
* bucket and
|
|
395
|
+
* When `true` the edited VTT is uploaded to the configured
|
|
396
|
+
* S3-compatible bucket and a `presignedUrl` is returned.
|
|
397
|
+
* Defaults to the value of `uploadToMux` when omitted.
|
|
398
|
+
* Ignored (treated as `true`) when `uploadToMux` is `true`,
|
|
399
|
+
* since Mux track creation requires a presigned URL.
|
|
400
|
+
*/
|
|
401
|
+
uploadToS3?: boolean;
|
|
402
|
+
/**
|
|
403
|
+
* When true (default) the edited VTT is attached as a track on the
|
|
404
|
+
* Mux asset. Implies `uploadToS3: true` because a presigned URL is
|
|
405
|
+
* required for track creation.
|
|
392
406
|
*/
|
|
393
407
|
uploadToMux?: boolean;
|
|
394
408
|
/** Optional override for the S3-compatible endpoint used for uploads. */
|
|
@@ -608,6 +622,22 @@ interface ModerationResult {
|
|
|
608
622
|
/** Convenience flag so callers can understand why `thumbnailScores` may contain a transcript entry. */
|
|
609
623
|
isAudioOnly: boolean;
|
|
610
624
|
thumbnailScores: ThumbnailModerationScore[];
|
|
625
|
+
/** Coverage metadata describing how many requested moderation samples actually succeeded. */
|
|
626
|
+
coverage: {
|
|
627
|
+
requestedSampleCount: number;
|
|
628
|
+
successfulSampleCount: number;
|
|
629
|
+
failedSampleCount: number;
|
|
630
|
+
/** Fraction of requested samples that produced a usable moderation result. */
|
|
631
|
+
sampleCoverage: number;
|
|
632
|
+
/** True when at least one sample failed but the workflow still returned a result. */
|
|
633
|
+
isPartial: boolean;
|
|
634
|
+
/**
|
|
635
|
+
* True when threshold interpretation should be treated cautiously.
|
|
636
|
+
* For thumbnail moderation, this means we either covered less than half of planned samples
|
|
637
|
+
* or ended up with fewer than 3 successful thumbnails.
|
|
638
|
+
*/
|
|
639
|
+
isLowConfidence: boolean;
|
|
640
|
+
};
|
|
611
641
|
/** Workflow usage metadata (asset duration, thumbnails, etc.). */
|
|
612
642
|
usage?: TokenUsage;
|
|
613
643
|
maxScores: {
|
|
@@ -656,7 +686,7 @@ interface ModerationOptions extends MuxAIOptions {
|
|
|
656
686
|
thumbnailInterval?: number;
|
|
657
687
|
/** Width of storyboard thumbnails in pixels (defaults to 640). */
|
|
658
688
|
thumbnailWidth?: number;
|
|
659
|
-
/** Maximum number of thumbnails to sample (defaults to unlimited).
|
|
689
|
+
/** Maximum number of thumbnails to sample (defaults to unlimited). Acts as a cap: if `thumbnailInterval` produces fewer samples than this limit the interval is respected; otherwise samples are evenly distributed with first and last frames pinned. */
|
|
660
690
|
maxSamples?: number;
|
|
661
691
|
/** Max concurrent moderation requests (defaults to 5). */
|
|
662
692
|
maxConcurrent?: number;
|
|
@@ -739,6 +769,8 @@ interface SummarizationOptions extends MuxAIOptions {
|
|
|
739
769
|
provider?: SupportedProvider;
|
|
740
770
|
/** Provider-specific chat model identifier. */
|
|
741
771
|
model?: ModelIdByProvider[SupportedProvider];
|
|
772
|
+
/** BCP 47 language code of the caption track to use (e.g. "en", "fr"). When omitted, prefers English if available. */
|
|
773
|
+
languageCode?: string;
|
|
742
774
|
/** Prompt tone shim applied to the system instruction (defaults to 'neutral'). */
|
|
743
775
|
tone?: ToneType;
|
|
744
776
|
/** Fetch the transcript and send it alongside the storyboard (defaults to true). */
|
|
@@ -899,8 +931,17 @@ interface AudioTranslationOptions extends MuxAIOptions {
|
|
|
899
931
|
/** Bucket that will store dubbed audio files. */
|
|
900
932
|
s3Bucket?: string;
|
|
901
933
|
/**
|
|
902
|
-
* When true
|
|
903
|
-
* bucket and
|
|
934
|
+
* When `true` the dubbed audio is uploaded to the configured
|
|
935
|
+
* S3-compatible bucket and a `presignedUrl` is returned.
|
|
936
|
+
* Defaults to the value of `uploadToMux` when omitted.
|
|
937
|
+
* Ignored (treated as `true`) when `uploadToMux` is `true`,
|
|
938
|
+
* since Mux track creation requires a presigned URL.
|
|
939
|
+
*/
|
|
940
|
+
uploadToS3?: boolean;
|
|
941
|
+
/**
|
|
942
|
+
* When true (default) the dubbed audio is attached as a track on the
|
|
943
|
+
* Mux asset. Implies `uploadToS3: true` because a presigned URL is
|
|
944
|
+
* required for track creation.
|
|
904
945
|
*/
|
|
905
946
|
uploadToMux?: boolean;
|
|
906
947
|
/** Optional storage adapter override for upload + presign operations. */
|
|
@@ -913,6 +954,7 @@ declare function translateAudio(assetId: string, toLanguageCode: string, options
|
|
|
913
954
|
/** Output returned from `translateCaptions`. */
|
|
914
955
|
interface TranslationResult {
|
|
915
956
|
assetId: string;
|
|
957
|
+
trackId: string;
|
|
916
958
|
/** Source language code (ISO 639-1 two-letter format). */
|
|
917
959
|
sourceLanguageCode: SupportedISO639_1;
|
|
918
960
|
/** Target language code (ISO 639-1 two-letter format). */
|
|
@@ -947,8 +989,17 @@ interface TranslationOptions<P extends SupportedProvider = SupportedProvider> ex
|
|
|
947
989
|
/** Bucket that will store translated VTT files. */
|
|
948
990
|
s3Bucket?: string;
|
|
949
991
|
/**
|
|
950
|
-
* When true
|
|
951
|
-
* bucket and
|
|
992
|
+
* When `true` the translated VTT is uploaded to the configured
|
|
993
|
+
* S3-compatible bucket and a `presignedUrl` is returned.
|
|
994
|
+
* Defaults to the value of `uploadToMux` when omitted.
|
|
995
|
+
* Ignored (treated as `true`) when `uploadToMux` is `true`,
|
|
996
|
+
* since Mux track creation requires a presigned URL.
|
|
997
|
+
*/
|
|
998
|
+
uploadToS3?: boolean;
|
|
999
|
+
/**
|
|
1000
|
+
* When true (default) the translated VTT is attached as a track on the
|
|
1001
|
+
* Mux asset. Implies `uploadToS3: true` because a presigned URL is
|
|
1002
|
+
* required for track creation.
|
|
952
1003
|
*/
|
|
953
1004
|
uploadToMux?: boolean;
|
|
954
1005
|
/** Optional storage adapter override for upload + presign operations. */
|
|
@@ -988,7 +1039,7 @@ declare const translationSchema: z.ZodObject<{
|
|
|
988
1039
|
type TranslationPayload = z.infer<typeof translationSchema>;
|
|
989
1040
|
declare function shouldSplitChunkTranslationError(error: unknown): boolean;
|
|
990
1041
|
declare function aggregateTokenUsage(usages: TokenUsage[]): TokenUsage;
|
|
991
|
-
declare function translateCaptions<P extends SupportedProvider = SupportedProvider>(assetId: string,
|
|
1042
|
+
declare function translateCaptions<P extends SupportedProvider = SupportedProvider>(assetId: string, trackId: string, toLanguageCode: string, options: TranslationOptions<P>): Promise<TranslationResult>;
|
|
992
1043
|
|
|
993
1044
|
type index_AskQuestionsOptions = AskQuestionsOptions;
|
|
994
1045
|
type index_AskQuestionsResult = AskQuestionsResult;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,14 +2,51 @@ import { W as WorkflowCredentials, S as StoragePutObjectInput, a as StoragePresi
|
|
|
2
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
4
|
export { i as primitives } from './index-CuBu_u5-.js';
|
|
5
|
-
export { i as workflows } from './index-
|
|
5
|
+
export { i as workflows } from './index-yn3fUDgv.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
|
+
var version = "0.15.1";
|
|
13
|
+
|
|
14
|
+
type MuxAiErrorType = "validation_error" | "processing_error" | "timeout_error";
|
|
15
|
+
/**
|
|
16
|
+
* An error whose message is safe to surface verbatim to the customer.
|
|
17
|
+
*
|
|
18
|
+
* Uses a structural brand (`__robots_error = true`) so that downstream
|
|
19
|
+
* consumers can identify customer-safe errors via duck typing — no
|
|
20
|
+
* shared dependency required. Errors from @mux/ai that DON'T carry
|
|
21
|
+
* this brand (unexpected SDK failures, upstream provider errors, etc.)
|
|
22
|
+
* should be treated as internal and obfuscated.
|
|
23
|
+
*
|
|
24
|
+
* Own properties (`publicMessage`, `publicType`, `retryable`) survive
|
|
25
|
+
* JSON serialization across workflow step boundaries, unlike inherited
|
|
26
|
+
* `Error.message`.
|
|
27
|
+
*/
|
|
28
|
+
declare class MuxAiError extends Error {
|
|
29
|
+
/** Structural brand for duck-type identification. */
|
|
30
|
+
readonly __robots_error = true;
|
|
31
|
+
/** Error category shown in the API response. */
|
|
32
|
+
readonly publicType: MuxAiErrorType;
|
|
33
|
+
/** Customer-facing message. Must be safe to show verbatim. */
|
|
34
|
+
readonly publicMessage: string;
|
|
35
|
+
/** Whether the customer should retry the job. */
|
|
36
|
+
readonly retryable: boolean;
|
|
37
|
+
constructor(message: string, opts?: {
|
|
38
|
+
type?: MuxAiErrorType;
|
|
39
|
+
retryable?: boolean;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Re-throws {@link MuxAiError} instances to preserve the structural brand,
|
|
44
|
+
* wraps everything else in a plain `Error` with a contextual message.
|
|
45
|
+
*
|
|
46
|
+
* Use this in catch blocks that re-throw so a customer-safe error from a
|
|
47
|
+
* callee isn't accidentally converted into an internal error.
|
|
48
|
+
*/
|
|
49
|
+
declare function wrapError(error: unknown, message: string): never;
|
|
13
50
|
|
|
14
51
|
/**
|
|
15
52
|
* A function that returns workflow credentials, either synchronously or asynchronously.
|
|
@@ -45,4 +82,4 @@ declare class WorkflowStorageClient {
|
|
|
45
82
|
}
|
|
46
83
|
declare function createWorkflowStorageClient(options?: WorkflowStorageClientOptions): WorkflowStorageClient;
|
|
47
84
|
|
|
48
|
-
export { StoragePresignGetObjectInput, StoragePutObjectInput, WorkflowCredentials, type WorkflowCredentialsProvider, WorkflowStorageClient, createWorkflowStorageClient, setWorkflowCredentialsProvider, version };
|
|
85
|
+
export { MuxAiError, type MuxAiErrorType, StoragePresignGetObjectInput, StoragePutObjectInput, WorkflowCredentials, type WorkflowCredentialsProvider, WorkflowStorageClient, createWorkflowStorageClient, setWorkflowCredentialsProvider, version, wrapError };
|