@mux/ai 0.4.2 → 0.5.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
@@ -8,7 +8,7 @@
8
8
  `@mux/ai` does this by providing:
9
9
 
10
10
  Easy to use, purpose-driven, cost effective, configurable **_workflow functions_** that integrate with a variety of popular AI/LLM providers (OpenAI, Anthropic, Google).
11
- - **Examples:** [`getSummaryAndTags`](#video-summarization), [`getModerationScores`](#content-moderation), [`hasBurnedInCaptions`](#burned-in-caption-detection), [`generateChapters`](#chapter-generation), [`generateVideoEmbeddings`](#video-search-with-embeddings), [`translateCaptions`](#caption-translation), [`translateAudio`](#audio-dubbing)
11
+ - **Examples:** [`getSummaryAndTags`](#video-summarization), [`getModerationScores`](#content-moderation), [`hasBurnedInCaptions`](#burned-in-caption-detection), [`generateChapters`](#chapter-generation), [`generateEmbeddings`](#search-with-embeddings), [`translateCaptions`](#caption-translation), [`translateAudio`](#audio-dubbing)
12
12
  - Workflows automatically ship with `"use workflow"` [compatability with Workflow DevKit](#compatability-with-workflow-devkit)
13
13
 
14
14
  Convenient, parameterized, commonly needed **_primitive functions_** backed by [Mux Video](https://www.mux.com/video-api) for building your own media-based AI workflows and integrations.
@@ -86,10 +86,10 @@ S3_SECRET_ACCESS_KEY=your-secret-key
86
86
  | [`getSummaryAndTags`](./docs/WORKFLOWS.md#video-summarization)<br/>[API](./docs/API.md#getsummaryandtagsassetid-options) · [Source](./src/workflows/summarization.ts) | Generate titles, descriptions, and tags for an asset | OpenAI, Anthropic, Google | `gpt-5.1` (OpenAI), `claude-sonnet-4-5` (Anthropic), `gemini-3-flash-preview` (Google) | Video (required), Captions (optional) | None |
87
87
  | [`getModerationScores`](./docs/WORKFLOWS.md#content-moderation)<br/>[API](./docs/API.md#getmoderationscoresassetid-options) · [Source](./src/workflows/moderation.ts) | Detect inappropriate (sexual or violent) content in an asset | OpenAI, Hive | `omni-moderation-latest` (OpenAI) or Hive visual moderation task | Video (required) | None |
88
88
  | [`hasBurnedInCaptions`](./docs/WORKFLOWS.md#burned-in-caption-detection)<br/>[API](./docs/API.md#hasburnedincaptionsassetid-options) · [Source](./src/workflows/burned-in-captions.ts) | Detect burned-in captions (hardcoded subtitles) in an asset | OpenAI, Anthropic, Google | `gpt-5.1` (OpenAI), `claude-sonnet-4-5` (Anthropic), `gemini-3-flash-preview` (Google) | Video (required) | None |
89
- | [`generateChapters`](./docs/WORKFLOWS.md#chapter-generation)<br/>[API](./docs/API.md#generatechaptersassetid-languagecode-options) · [Source](./src/workflows/chapters.ts) | Generate chapter markers for an asset using the transcript | OpenAI, Anthropic, Google | `gpt-5.1` (OpenAI), `claude-sonnet-4-5` (Anthropic), `gemini-3-flash-preview` (Google) | Video (required), Captions (required) | None |
90
- | [`generateVideoEmbeddings`](./docs/WORKFLOWS.md#video-embeddings)<br/>[API](./docs/API.md#generatevideoembeddingsassetid-options) · [Source](./src/workflows/embeddings.ts) | Generate vector embeddings for an asset's transcript chunks | OpenAI, Google | `text-embedding-3-small` (OpenAI), `gemini-embedding-001` (Google) | Video (required), Captions (required) | None |
91
- | [`translateCaptions`](./docs/WORKFLOWS.md#caption-translation)<br/>[API](./docs/API.md#translatecaptionsassetid-fromlanguagecode-tolanguagecode-options) · [Source](./src/workflows/translate-captions.ts) | Translate an asset's captions into different languages | OpenAI, Anthropic, Google | `gpt-5.1` (OpenAI), `claude-sonnet-4-5` (Anthropic), `gemini-3-flash-preview` (Google) | Video (required), Captions (required) | AWS S3 (if `uploadToMux=true`) |
92
- | [`translateAudio`](./docs/WORKFLOWS.md#audio-dubbing)<br/>[API](./docs/API.md#translateaudioassetid-tolanguagecode-options) · [Source](./src/workflows/translate-audio.ts) | Create AI-dubbed audio tracks in different languages for an asset | ElevenLabs only | ElevenLabs Dubbing API | Video (required), Audio (required) | AWS S3 (if `uploadToMux=true`) |
89
+ | [`generateChapters`](./docs/WORKFLOWS.md#chapter-generation)<br/>[API](./docs/API.md#generatechaptersassetid-languagecode-options) · [Source](./src/workflows/chapters.ts) | Generate chapter markers for an asset using the transcript | OpenAI, Anthropic, Google | `gpt-5.1` (OpenAI), `claude-sonnet-4-5` (Anthropic), `gemini-3-flash-preview` (Google) | Video or audio-only, Captions/Transcripts (required) | None |
90
+ | [`generateEmbeddings`](./docs/WORKFLOWS.md#embeddings)<br/>[API](./docs/API.md#generateembeddingsassetid-options) · [Source](./src/workflows/embeddings.ts) | Generate vector embeddings for an asset's transcript chunks | OpenAI, Google | `text-embedding-3-small` (OpenAI), `gemini-embedding-001` (Google) | Video or audio-only, Captions/Transcripts (required) | None |
91
+ | [`translateCaptions`](./docs/WORKFLOWS.md#caption-translation)<br/>[API](./docs/API.md#translatecaptionsassetid-fromlanguagecode-tolanguagecode-options) · [Source](./src/workflows/translate-captions.ts) | Translate an asset's captions into different languages | OpenAI, Anthropic, Google | `gpt-5.1` (OpenAI), `claude-sonnet-4-5` (Anthropic), `gemini-3-flash-preview` (Google) | Video or audio-only, Captions/Transcripts (required) | AWS S3 (if `uploadToMux=true`) |
92
+ | [`translateAudio`](./docs/WORKFLOWS.md#audio-dubbing)<br/>[API](./docs/API.md#translateaudioassetid-tolanguagecode-options) · [Source](./src/workflows/translate-audio.ts) | Create AI-dubbed audio tracks in different languages for an asset | ElevenLabs only | ElevenLabs Dubbing API | Video or audio-only, Audio (required) | AWS S3 (if `uploadToMux=true`) |
93
93
 
94
94
  ## Compatability with Workflow DevKit
95
95
 
@@ -108,6 +108,58 @@ const run = await start(getSummaryAndTags, [assetId]);
108
108
  // const result = await run.returnValue
109
109
  ```
110
110
 
111
+ ### Multi-tenant credentials with Workflow Dev Kit (interim encryption pattern)
112
+
113
+ Workflow Dev Kit serializes workflow inputs and step I/O. Do not pass plaintext secrets through
114
+ `start()`. Instead, encrypt credentials in userland and pass ciphertext only.
115
+ Set `MUX_AI_WORKFLOW_SECRET_KEY` to a base64-encoded 32-byte key on the workflow execution host.
116
+
117
+ ```ts
118
+ import { start } from "workflow/api";
119
+ import { encryptForWorkflow, getSummaryAndTags } from "@mux/ai/workflows";
120
+
121
+ const workflowKey = process.env.MUX_AI_WORKFLOW_SECRET_KEY!;
122
+ const encryptedCredentials = encryptForWorkflow(
123
+ {
124
+ muxTokenId: "mux-token-id",
125
+ muxTokenSecret: "mux-token-secret",
126
+ openaiApiKey: "openai-api-key",
127
+ },
128
+ workflowKey,
129
+ );
130
+
131
+ const run = await start(getSummaryAndTags, [
132
+ "your-asset-id",
133
+ { provider: "openai", credentials: encryptedCredentials },
134
+ ]);
135
+ ```
136
+
137
+ If you build custom steps, decrypt inside the step using the same workflow key:
138
+
139
+ ```ts
140
+ import { decryptFromWorkflow } from "@mux/ai/workflows";
141
+
142
+ async function resolveCredentials(encrypted: unknown) {
143
+ "use step";
144
+ return decryptFromWorkflow(
145
+ encrypted as any,
146
+ process.env.MUX_AI_WORKFLOW_SECRET_KEY!,
147
+ );
148
+ }
149
+ ```
150
+
151
+ You can also register a credential provider on the execution host to resolve secrets inside steps:
152
+
153
+ ```ts
154
+ import { setWorkflowCredentialsProvider } from "@mux/ai/workflows";
155
+
156
+ setWorkflowCredentialsProvider(async () => ({
157
+ muxTokenId: "mux-token-id",
158
+ muxTokenSecret: "mux-token-secret",
159
+ openaiApiKey: "openai-api-key",
160
+ }));
161
+ ```
162
+
111
163
  ### Features of Workflow DevKit
112
164
 
113
165
  - [Observability Dashboard](https://useworkflow.dev/docs/observability)
@@ -165,7 +217,7 @@ console.log(result.tags); // ["typescript", "tutorial", "programming"]
165
217
 
166
218
  ### Content Moderation
167
219
 
168
- Automatically detect inappropriate content in videos:
220
+ Automatically detect inappropriate content in videos (or audio-only assets with transcripts):
169
221
 
170
222
  ```typescript
171
223
  import { getModerationScores } from "@mux/ai/workflows";
@@ -201,14 +253,14 @@ player.addChapters(result.chapters);
201
253
  // ]
202
254
  ```
203
255
 
204
- ### Video Search with Embeddings
256
+ ### Search with Embeddings
205
257
 
206
- Generate embeddings for semantic video search:
258
+ Generate embeddings for semantic search over transcripts:
207
259
 
208
260
  ```typescript
209
- import { generateVideoEmbeddings } from "@mux/ai/workflows";
261
+ import { generateEmbeddings } from "@mux/ai/workflows";
210
262
 
211
- const result = await generateVideoEmbeddings("your-asset-id", {
263
+ const result = await generateEmbeddings("your-asset-id", {
212
264
  provider: "openai",
213
265
  languageCode: "en",
214
266
  chunkingStrategy: {
@@ -327,7 +379,7 @@ Different workflows support various AI providers. You only need to configure API
327
379
 
328
380
  ### OpenAI
329
381
 
330
- **Used by:** `getSummaryAndTags`, `getModerationScores`, `hasBurnedInCaptions`, `generateChapters`, `generateVideoEmbeddings`, `translateCaptions`
382
+ **Used by:** `getSummaryAndTags`, `getModerationScores`, `hasBurnedInCaptions`, `generateChapters`, `generateEmbeddings`, `translateCaptions`
331
383
 
332
384
  **Get your API key:** [OpenAI API Keys](https://platform.openai.com/api-keys)
333
385
 
@@ -347,7 +399,7 @@ ANTHROPIC_API_KEY=your_anthropic_api_key
347
399
 
348
400
  ### Google Generative AI
349
401
 
350
- **Used by:** `getSummaryAndTags`, `hasBurnedInCaptions`, `generateChapters`, `generateVideoEmbeddings`, `translateCaptions`
402
+ **Used by:** `getSummaryAndTags`, `hasBurnedInCaptions`, `generateChapters`, `generateEmbeddings`, `translateCaptions`
351
403
 
352
404
  **Get your API key:** [Google AI Studio](https://aistudio.google.com/app/apikey)
353
405
 
@@ -436,6 +488,8 @@ Please see our **[Contributing Guide](./CONTRIBUTING.md)** for details on:
436
488
  - Submitting pull requests
437
489
  - Reporting issues
438
490
 
491
+ > **Note on integration tests:** The integration suite runs against real Mux assets. If you want to run `npm run test:integration` with your own Mux credentials, you’ll also need to set Mux test asset IDs (see `env.test.example`, the “Integration test assets (Mux)” section in `CONTRIBUTING.md`, and `tests/helpers/mux-test-assets.ts` for the expected test asset IDs).
492
+
439
493
  For questions or discussions, feel free to [open an issue](https://github.com/muxinc/ai/issues).
440
494
 
441
495
  ## License
@@ -2,8 +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 { g as TokenUsage, M as MuxAIOptions, I as ImageSubmissionMode, C as ChunkingStrategy, f as VideoEmbeddingsResult, T as ToneType } from './types-DzOQNn9R.js';
6
- import { Buffer } from 'node:buffer';
5
+ import { k as TokenUsage, M as MuxAIOptions, I as ImageSubmissionMode, C as ChunkingStrategy, j as VideoEmbeddingsResult, T as ToneType } from './types-KcVfWtUl.js';
7
6
 
8
7
  interface ImageDownloadOptions {
9
8
  /** Request timeout in milliseconds (default: 10000) */
@@ -160,17 +159,58 @@ interface ChaptersResult {
160
159
  assetId: string;
161
160
  languageCode: string;
162
161
  chapters: Chapter[];
162
+ /** Token usage from the AI provider (for efficiency/cost analysis). */
163
+ usage?: TokenUsage;
163
164
  }
165
+ /**
166
+ * Sections of the chaptering user prompt that can be overridden.
167
+ * Use these to customize the AI's behavior for your specific use case.
168
+ */
169
+ type ChaptersPromptSections = "task" | "outputFormat" | "chapterGuidelines" | "titleGuidelines";
170
+ /**
171
+ * Override specific sections of the chaptering prompt.
172
+ * Each key corresponds to a section that can be customized.
173
+ *
174
+ * @example
175
+ * ```typescript
176
+ * const result = await generateChapters(assetId, "en", {
177
+ * promptOverrides: {
178
+ * titleGuidelines: "Use short, punchy titles under 6 words.",
179
+ * },
180
+ * });
181
+ * ```
182
+ */
183
+ type ChaptersPromptOverrides = PromptOverrides<ChaptersPromptSections>;
164
184
  /** Configuration accepted by `generateChapters`. */
165
185
  interface ChaptersOptions extends MuxAIOptions {
166
186
  /** AI provider used to interpret the transcript (defaults to 'openai'). */
167
187
  provider?: SupportedProvider;
168
188
  /** Provider-specific model identifier. */
169
189
  model?: ModelIdByProvider[SupportedProvider];
190
+ /**
191
+ * Override specific sections of the user prompt.
192
+ * Useful for customizing chaptering criteria for specific use cases.
193
+ */
194
+ promptOverrides?: ChaptersPromptOverrides;
195
+ /**
196
+ * Minimum number of chapters to generate per hour of content.
197
+ * Defaults to 3.
198
+ */
199
+ minChaptersPerHour?: number;
200
+ /**
201
+ * Maximum number of chapters to generate per hour of content.
202
+ * Defaults to 8.
203
+ */
204
+ maxChaptersPerHour?: number;
170
205
  }
206
+ /**
207
+ * Sections of the chaptering system prompt that can be overridden.
208
+ * Use these to customize the AI's persona and constraints.
209
+ */
210
+ type ChapterSystemPromptSections = "role" | "context" | "constraints" | "qualityGuidelines";
171
211
  declare function generateChapters(assetId: string, languageCode: string, options?: ChaptersOptions): Promise<ChaptersResult>;
172
212
 
173
- /** Configuration accepted by `generateVideoEmbeddings`. */
213
+ /** Configuration accepted by `generateEmbeddings`. */
174
214
  interface EmbeddingsOptions extends MuxAIOptions {
175
215
  /** AI provider used to generate embeddings (defaults to 'openai'). */
176
216
  provider?: SupportedEmbeddingProvider;
@@ -183,38 +223,13 @@ interface EmbeddingsOptions extends MuxAIOptions {
183
223
  /** Maximum number of chunks to process concurrently (defaults to 5). */
184
224
  batchSize?: number;
185
225
  }
226
+ /** Alias for embedding results (supports video or audio transcripts). */
227
+ type EmbeddingsResult = VideoEmbeddingsResult;
228
+ declare function generateEmbeddings(assetId: string, options?: EmbeddingsOptions): Promise<EmbeddingsResult>;
186
229
  /**
187
- * Generates vector embeddings for a video asset's transcript.
188
- *
189
- * This function:
190
- * 1. Fetches the video transcript from Mux
191
- * 2. Chunks the transcript according to the specified strategy
192
- * 3. Generates embeddings for each chunk using the specified AI provider
193
- * 4. Returns both individual chunk embeddings and an averaged embedding
194
- *
195
- * @param assetId - Mux asset ID
196
- * @param options - Configuration options
197
- * @returns Video embeddings result with chunks and averaged embedding
198
- *
199
- * @example
200
- * ```typescript
201
- * const embeddings = await generateVideoEmbeddings("asset-id", {
202
- * provider: "openai",
203
- * chunkingStrategy: { type: "token", maxTokens: 500, overlap: 100 },
204
- * });
205
- *
206
- * // Store in vector database
207
- * for (const chunk of embeddings.chunks) {
208
- * await db.insert({
209
- * assetId: embeddings.assetId,
210
- * chunkId: chunk.chunkId,
211
- * embedding: chunk.embedding,
212
- * metadata: chunk.metadata,
213
- * });
214
- * }
215
- * ```
230
+ * @deprecated Use {@link generateEmbeddings} instead. This name will be removed in a future release.
216
231
  */
217
- declare function generateVideoEmbeddings(assetId: string, options?: EmbeddingsOptions): Promise<VideoEmbeddingsResult>;
232
+ declare function generateVideoEmbeddings(assetId: string, options?: EmbeddingsOptions): Promise<EmbeddingsResult>;
218
233
 
219
234
  /** Per-thumbnail moderation result returned from `getModerationScores`. */
220
235
  interface ThumbnailModerationScore {
@@ -226,6 +241,10 @@ interface ThumbnailModerationScore {
226
241
  /** Aggregated moderation payload returned from `getModerationScores`. */
227
242
  interface ModerationResult {
228
243
  assetId: string;
244
+ /** Whether moderation ran on thumbnails (video) or transcript text (audio-only). */
245
+ mode: "thumbnails" | "transcript";
246
+ /** Convenience flag so callers can understand why `thumbnailScores` may contain a transcript entry. */
247
+ isAudioOnly: boolean;
229
248
  thumbnailScores: ThumbnailModerationScore[];
230
249
  maxScores: {
231
250
  sexual: number;
@@ -244,7 +263,7 @@ type HiveModerationSource = {
244
263
  value: string;
245
264
  } | {
246
265
  kind: "file";
247
- buffer: Buffer;
266
+ buffer: Uint8Array;
248
267
  contentType: string;
249
268
  };
250
269
  interface HiveModerationOutput {
@@ -259,6 +278,11 @@ interface ModerationOptions extends MuxAIOptions {
259
278
  provider?: ModerationProvider;
260
279
  /** OpenAI moderation model identifier (defaults to 'omni-moderation-latest'). */
261
280
  model?: string;
281
+ /**
282
+ * Optional transcript language code used when moderating audio-only assets.
283
+ * If omitted, the first ready text track will be used.
284
+ */
285
+ languageCode?: string;
262
286
  /** Override the default sexual/violence thresholds (0-1). */
263
287
  thresholds?: {
264
288
  sexual?: number;
@@ -276,8 +300,14 @@ interface ModerationOptions extends MuxAIOptions {
276
300
  imageDownloadOptions?: ImageDownloadOptions;
277
301
  }
278
302
  /**
279
- * Moderate a Mux asset's thumbnails.
303
+ * Moderate a Mux asset.
304
+ * - Video assets: moderates storyboard thumbnails (image moderation)
305
+ * - Audio-only assets: moderates transcript text (text moderation)
306
+ *
307
+ * Provider notes:
280
308
  * - provider 'openai' uses OpenAI's hosted moderation endpoint (requires OPENAI_API_KEY)
309
+ * Ref: https://platform.openai.com/docs/guides/moderation
310
+ * - provider 'hive' uses Hive's moderation API for thumbnails only (requires HIVE_API_KEY)
281
311
  */
282
312
  declare function getModerationScores(assetId: string, options?: ModerationOptions): Promise<ModerationResult>;
283
313
 
@@ -306,8 +336,8 @@ interface SummaryAndTagsResult {
306
336
  description: string;
307
337
  /** Up to 10 keywords extracted by the model. */
308
338
  tags: string[];
309
- /** Storyboard image URL that was analyzed. */
310
- storyboardUrl: string;
339
+ /** Storyboard image URL that was analyzed (undefined for audio-only assets). */
340
+ storyboardUrl?: string;
311
341
  /** Token usage from the AI provider (for efficiency/cost analysis). */
312
342
  usage?: TokenUsage;
313
343
  /** Raw transcript text used for analysis (when includeTranscript is true). */
@@ -550,10 +580,14 @@ type index_BurnedInCaptionsPromptOverrides = BurnedInCaptionsPromptOverrides;
550
580
  type index_BurnedInCaptionsPromptSections = BurnedInCaptionsPromptSections;
551
581
  type index_BurnedInCaptionsResult = BurnedInCaptionsResult;
552
582
  type index_Chapter = Chapter;
583
+ type index_ChapterSystemPromptSections = ChapterSystemPromptSections;
553
584
  type index_ChaptersOptions = ChaptersOptions;
585
+ type index_ChaptersPromptOverrides = ChaptersPromptOverrides;
586
+ type index_ChaptersPromptSections = ChaptersPromptSections;
554
587
  type index_ChaptersResult = ChaptersResult;
555
588
  type index_ChaptersType = ChaptersType;
556
589
  type index_EmbeddingsOptions = EmbeddingsOptions;
590
+ type index_EmbeddingsResult = EmbeddingsResult;
557
591
  type index_HiveModerationOutput = HiveModerationOutput;
558
592
  type index_HiveModerationSource = HiveModerationSource;
559
593
  type index_ModerationOptions = ModerationOptions;
@@ -573,6 +607,7 @@ declare const index_burnedInCaptionsSchema: typeof burnedInCaptionsSchema;
573
607
  declare const index_chapterSchema: typeof chapterSchema;
574
608
  declare const index_chaptersSchema: typeof chaptersSchema;
575
609
  declare const index_generateChapters: typeof generateChapters;
610
+ declare const index_generateEmbeddings: typeof generateEmbeddings;
576
611
  declare const index_generateVideoEmbeddings: typeof generateVideoEmbeddings;
577
612
  declare const index_getModerationScores: typeof getModerationScores;
578
613
  declare const index_getSummaryAndTags: typeof getSummaryAndTags;
@@ -582,7 +617,7 @@ declare const index_translateAudio: typeof translateAudio;
582
617
  declare const index_translateCaptions: typeof translateCaptions;
583
618
  declare const index_translationSchema: typeof translationSchema;
584
619
  declare namespace index {
585
- export { type index_AudioTranslationOptions as AudioTranslationOptions, type index_AudioTranslationResult as AudioTranslationResult, 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_Chapter as Chapter, type index_ChaptersOptions as ChaptersOptions, type index_ChaptersResult as ChaptersResult, type index_ChaptersType as ChaptersType, type index_EmbeddingsOptions as EmbeddingsOptions, 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, index_SUMMARY_KEYWORD_LIMIT as SUMMARY_KEYWORD_LIMIT, 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_TranslationOptions as TranslationOptions, type index_TranslationPayload as TranslationPayload, type index_TranslationResult as TranslationResult, index_burnedInCaptionsSchema as burnedInCaptionsSchema, index_chapterSchema as chapterSchema, index_chaptersSchema as chaptersSchema, index_generateChapters as generateChapters, index_generateVideoEmbeddings as generateVideoEmbeddings, index_getModerationScores as getModerationScores, index_getSummaryAndTags as getSummaryAndTags, index_hasBurnedInCaptions as hasBurnedInCaptions, index_summarySchema as summarySchema, index_translateAudio as translateAudio, index_translateCaptions as translateCaptions, index_translationSchema as translationSchema };
620
+ export { type index_AudioTranslationOptions as AudioTranslationOptions, type index_AudioTranslationResult as AudioTranslationResult, 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_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, type index_EmbeddingsOptions as EmbeddingsOptions, type index_EmbeddingsResult as EmbeddingsResult, 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, index_SUMMARY_KEYWORD_LIMIT as SUMMARY_KEYWORD_LIMIT, 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_TranslationOptions as TranslationOptions, type index_TranslationPayload as TranslationPayload, type index_TranslationResult as TranslationResult, index_burnedInCaptionsSchema as burnedInCaptionsSchema, index_chapterSchema as chapterSchema, index_chaptersSchema as chaptersSchema, 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_summarySchema as summarySchema, index_translateAudio as translateAudio, index_translateCaptions as translateCaptions, index_translationSchema as translationSchema };
586
621
  }
587
622
 
588
- export { type AudioTranslationResult as A, type BurnedInCaptionsResult as B, type Chapter as C, translateAudio as D, type EmbeddingsOptions as E, type TranslationResult as F, type TranslationOptions as G, type HiveModerationSource as H, translationSchema as I, type TranslationPayload as J, translateCaptions as K, type ModerationResult as M, SUMMARY_KEYWORD_LIMIT as S, type ThumbnailModerationScore as T, type BurnedInCaptionsPromptSections as a, type BurnedInCaptionsPromptOverrides as b, type BurnedInCaptionsOptions as c, burnedInCaptionsSchema as d, type BurnedInCaptionsAnalysis as e, chapterSchema as f, chaptersSchema as g, hasBurnedInCaptions as h, index as i, type ChaptersType as j, type ChaptersResult as k, type ChaptersOptions as l, generateChapters as m, generateVideoEmbeddings as n, type ModerationProvider as o, type HiveModerationOutput as p, type ModerationOptions as q, getModerationScores as r, summarySchema as s, type SummaryType as t, type SummaryAndTagsResult as u, type SummarizationPromptSections as v, type SummarizationPromptOverrides as w, type SummarizationOptions as x, getSummaryAndTags as y, type AudioTranslationOptions as z };
623
+ export { type SummarizationPromptSections as A, type BurnedInCaptionsResult as B, type Chapter as C, type SummarizationPromptOverrides as D, type EmbeddingsOptions as E, type SummarizationOptions as F, getSummaryAndTags as G, type HiveModerationSource as H, type AudioTranslationResult as I, type AudioTranslationOptions as J, translateAudio as K, type TranslationResult as L, type ModerationResult as M, type TranslationOptions as N, translationSchema as O, type TranslationPayload as P, translateCaptions as Q, SUMMARY_KEYWORD_LIMIT as S, type ThumbnailModerationScore as T, type BurnedInCaptionsPromptSections as a, type BurnedInCaptionsPromptOverrides as b, type BurnedInCaptionsOptions as c, burnedInCaptionsSchema as d, type BurnedInCaptionsAnalysis as e, chapterSchema as f, chaptersSchema as g, hasBurnedInCaptions as h, index as i, type ChaptersType as j, type ChaptersResult as k, type ChaptersPromptSections as l, type ChaptersPromptOverrides as m, type ChaptersOptions as n, type ChapterSystemPromptSections as o, generateChapters as p, type EmbeddingsResult as q, generateEmbeddings as r, generateVideoEmbeddings as s, type ModerationProvider as t, type HiveModerationOutput as u, type ModerationOptions as v, getModerationScores as w, summarySchema as x, type SummaryType as y, type SummaryAndTagsResult as z };
@@ -1,4 +1,4 @@
1
- import { A as AssetTextTrack, a as MuxAsset, d as TextChunk, C as ChunkingStrategy } from './types-DzOQNn9R.js';
1
+ import { b as WorkflowCredentialsInput, A as AssetTextTrack, c as MuxAsset, h as TextChunk, C as ChunkingStrategy } from './types-KcVfWtUl.js';
2
2
 
3
3
  declare const DEFAULT_STORYBOARD_WIDTH = 640;
4
4
  /**
@@ -10,7 +10,7 @@ declare const DEFAULT_STORYBOARD_WIDTH = 640;
10
10
  * @param shouldSign - Flag for whether or not to use signed playback IDs (default: false)
11
11
  * @returns Storyboard URL (signed if shouldSign is true)
12
12
  */
13
- declare function getStoryboardUrl(playbackId: string, width?: number, shouldSign?: boolean): Promise<string>;
13
+ declare function getStoryboardUrl(playbackId: string, width?: number, shouldSign?: boolean, credentials?: WorkflowCredentialsInput): Promise<string>;
14
14
 
15
15
  /** A single cue from a VTT file with timing info. */
16
16
  interface VTTCue {
@@ -23,6 +23,14 @@ interface TranscriptFetchOptions {
23
23
  cleanTranscript?: boolean;
24
24
  /** Optional signing context for signed playback IDs */
25
25
  shouldSign?: boolean;
26
+ credentials?: WorkflowCredentialsInput;
27
+ /**
28
+ * When true, throws if no usable transcript can be retrieved (no ready text track,
29
+ * missing track id, fetch error, or empty transcript).
30
+ *
31
+ * Default behavior is non-fatal and returns an empty `transcriptText`.
32
+ */
33
+ required?: boolean;
26
34
  }
27
35
  interface TranscriptResult {
28
36
  transcriptText: string;
@@ -33,6 +41,14 @@ declare function getReadyTextTracks(asset: MuxAsset): AssetTextTrack[];
33
41
  declare function findCaptionTrack(asset: MuxAsset, languageCode?: string): AssetTextTrack | undefined;
34
42
  declare function extractTextFromVTT(vttContent: string): string;
35
43
  declare function vttTimestampToSeconds(timestamp: string): number;
44
+ /**
45
+ * Converts seconds to a human-readable timestamp.
46
+ * Returns M:SS for durations under an hour, H:MM:SS for an hour or more.
47
+ *
48
+ * @param seconds - The number of seconds to convert
49
+ * @returns A formatted timestamp string (e.g., "2:05" or "01:02:05")
50
+ */
51
+ declare function secondsToTimestamp(seconds: number): string;
36
52
  declare function extractTimestampedTranscript(vttContent: string): string;
37
53
  /**
38
54
  * Parses VTT content into structured cues with timing.
@@ -50,7 +66,7 @@ declare function parseVTTCues(vttContent: string): VTTCue[];
50
66
  * @param shouldSign - Flag for whether or not to use signed playback IDs
51
67
  * @returns Transcript URL (signed if context provided)
52
68
  */
53
- declare function buildTranscriptUrl(playbackId: string, trackId: string, shouldSign?: boolean): Promise<string>;
69
+ declare function buildTranscriptUrl(playbackId: string, trackId: string, shouldSign?: boolean, credentials?: WorkflowCredentialsInput): Promise<string>;
54
70
  declare function fetchTranscriptForAsset(asset: MuxAsset, playbackId: string, options?: TranscriptFetchOptions): Promise<TranscriptResult>;
55
71
 
56
72
  /**
@@ -94,6 +110,8 @@ interface ThumbnailOptions {
94
110
  width?: number;
95
111
  /** Flag for whether or not to use signed playback IDs (default: false) */
96
112
  shouldSign?: boolean;
113
+ /** Workflow credentials for signing (optional). */
114
+ credentials?: WorkflowCredentialsInput;
97
115
  }
98
116
  /**
99
117
  * Generates thumbnail URLs at regular intervals based on video duration.
@@ -124,9 +142,10 @@ declare const index_getReadyTextTracks: typeof getReadyTextTracks;
124
142
  declare const index_getStoryboardUrl: typeof getStoryboardUrl;
125
143
  declare const index_getThumbnailUrls: typeof getThumbnailUrls;
126
144
  declare const index_parseVTTCues: typeof parseVTTCues;
145
+ declare const index_secondsToTimestamp: typeof secondsToTimestamp;
127
146
  declare const index_vttTimestampToSeconds: typeof vttTimestampToSeconds;
128
147
  declare namespace index {
129
- export { index_DEFAULT_STORYBOARD_WIDTH as DEFAULT_STORYBOARD_WIDTH, type index_ThumbnailOptions as ThumbnailOptions, type index_TranscriptFetchOptions as TranscriptFetchOptions, type index_TranscriptResult as TranscriptResult, type index_VTTCue as VTTCue, index_buildTranscriptUrl as buildTranscriptUrl, index_chunkByTokens as chunkByTokens, index_chunkText as chunkText, index_chunkVTTCues as chunkVTTCues, index_estimateTokenCount as estimateTokenCount, index_extractTextFromVTT as extractTextFromVTT, index_extractTimestampedTranscript as extractTimestampedTranscript, index_fetchTranscriptForAsset as fetchTranscriptForAsset, index_findCaptionTrack as findCaptionTrack, index_getReadyTextTracks as getReadyTextTracks, index_getStoryboardUrl as getStoryboardUrl, index_getThumbnailUrls as getThumbnailUrls, index_parseVTTCues as parseVTTCues, index_vttTimestampToSeconds as vttTimestampToSeconds };
148
+ export { index_DEFAULT_STORYBOARD_WIDTH as DEFAULT_STORYBOARD_WIDTH, type index_ThumbnailOptions as ThumbnailOptions, type index_TranscriptFetchOptions as TranscriptFetchOptions, type index_TranscriptResult as TranscriptResult, type index_VTTCue as VTTCue, index_buildTranscriptUrl as buildTranscriptUrl, index_chunkByTokens as chunkByTokens, index_chunkText as chunkText, index_chunkVTTCues as chunkVTTCues, index_estimateTokenCount as estimateTokenCount, index_extractTextFromVTT as extractTextFromVTT, index_extractTimestampedTranscript as extractTimestampedTranscript, index_fetchTranscriptForAsset as fetchTranscriptForAsset, index_findCaptionTrack as findCaptionTrack, index_getReadyTextTracks as getReadyTextTracks, index_getStoryboardUrl as getStoryboardUrl, index_getThumbnailUrls as getThumbnailUrls, index_parseVTTCues as parseVTTCues, index_secondsToTimestamp as secondsToTimestamp, index_vttTimestampToSeconds as vttTimestampToSeconds };
130
149
  }
131
150
 
132
- export { DEFAULT_STORYBOARD_WIDTH as D, type ThumbnailOptions as T, type VTTCue as V, chunkVTTCues as a, chunkText as b, chunkByTokens as c, getThumbnailUrls as d, estimateTokenCount as e, type TranscriptFetchOptions as f, getStoryboardUrl as g, type TranscriptResult as h, index as i, getReadyTextTracks as j, findCaptionTrack as k, extractTextFromVTT as l, extractTimestampedTranscript as m, buildTranscriptUrl as n, fetchTranscriptForAsset as o, parseVTTCues as p, vttTimestampToSeconds as v };
151
+ export { DEFAULT_STORYBOARD_WIDTH as D, type ThumbnailOptions as T, type VTTCue as V, chunkVTTCues as a, chunkText as b, chunkByTokens as c, getThumbnailUrls as d, estimateTokenCount as e, type TranscriptFetchOptions as f, getStoryboardUrl as g, type TranscriptResult as h, index as i, getReadyTextTracks as j, findCaptionTrack as k, extractTextFromVTT as l, extractTimestampedTranscript as m, buildTranscriptUrl as n, fetchTranscriptForAsset as o, parseVTTCues as p, secondsToTimestamp as s, vttTimestampToSeconds as v };
package/dist/index.d.ts CHANGED
@@ -1,13 +1,24 @@
1
- export { i as primitives } from './index-BcNDGOI6.js';
2
- export { A as AssetTextTrack, e as ChunkEmbedding, C as ChunkingStrategy, I as ImageSubmissionMode, M as MuxAIOptions, a as MuxAsset, b as PlaybackAsset, P as PlaybackPolicy, d as TextChunk, c as TokenChunkingConfig, g as TokenUsage, T as ToneType, V as VTTChunkingConfig, f as VideoEmbeddingsResult } from './types-DzOQNn9R.js';
3
- export { i as workflows } from './index-D3fZHu0h.js';
1
+ import { W as WorkflowCredentials } from './types-KcVfWtUl.js';
2
+ export { A as AssetTextTrack, i as ChunkEmbedding, C as ChunkingStrategy, E as Encrypted, a as EncryptedPayload, I as ImageSubmissionMode, M as MuxAIOptions, c as MuxAsset, f as PlaybackAsset, P as PlaybackPolicy, h as TextChunk, g as TokenChunkingConfig, k as TokenUsage, T as ToneType, V as VTTChunkingConfig, j as VideoEmbeddingsResult, b as WorkflowCredentialsInput, d as decryptFromWorkflow, e as encryptForWorkflow } from './types-KcVfWtUl.js';
3
+ export { i as primitives } from './index-Dmo55n-5.js';
4
+ export { i as workflows } from './index-BdpEVCbj.js';
4
5
  import '@mux/mux-node';
5
6
  import 'zod';
6
7
  import '@ai-sdk/anthropic';
7
8
  import '@ai-sdk/google';
8
9
  import '@ai-sdk/openai';
9
- import 'node:buffer';
10
10
 
11
- declare const version = "0.1.0";
11
+ var version = "0.5.0";
12
12
 
13
- export { version };
13
+ /**
14
+ * A function that returns workflow credentials, either synchronously or asynchronously.
15
+ * Used to inject credentials from external sources (e.g., a secrets manager).
16
+ */
17
+ type WorkflowCredentialsProvider = () => Promise<WorkflowCredentials | undefined> | WorkflowCredentials | undefined;
18
+ /**
19
+ * Registers a custom credentials provider for the module.
20
+ * The provider will be called whenever credentials need to be resolved.
21
+ */
22
+ declare function setWorkflowCredentialsProvider(provider?: WorkflowCredentialsProvider): void;
23
+
24
+ export { WorkflowCredentials, type WorkflowCredentialsProvider, setWorkflowCredentialsProvider, version };