@mux/ai 0.7.3 → 0.7.5
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 +113 -390
- package/dist/{index-BMqnP1RV.d.ts → index-B0U9upb4.d.ts} +13 -3
- package/dist/{index-DZlygsvb.d.ts → index-Nxf6BaBO.d.ts} +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +133 -22
- package/dist/index.js.map +1 -1
- package/dist/primitives/index.d.ts +2 -2
- package/dist/primitives/index.js +96 -8
- package/dist/primitives/index.js.map +1 -1
- package/dist/{types-BQVi_wnh.d.ts → types-BRbaGW3t.d.ts} +2 -0
- package/dist/workflows/index.d.ts +2 -2
- package/dist/workflows/index.js +132 -21
- package/dist/workflows/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -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-
|
|
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';
|
|
6
6
|
|
|
7
7
|
interface ImageDownloadOptions {
|
|
8
8
|
/** Request timeout in milliseconds (default: 10000) */
|
|
@@ -436,6 +436,8 @@ interface ModerationOptions extends MuxAIOptions {
|
|
|
436
436
|
/** Download tuning used when `imageSubmissionMode` === 'base64'. */
|
|
437
437
|
imageDownloadOptions?: ImageDownloadOptions;
|
|
438
438
|
}
|
|
439
|
+
declare const HIVE_SEXUAL_CATEGORIES: string[];
|
|
440
|
+
declare const HIVE_VIOLENCE_CATEGORIES: string[];
|
|
439
441
|
/**
|
|
440
442
|
* Moderate a Mux asset.
|
|
441
443
|
* - Video assets: moderates storyboard thumbnails (image moderation)
|
|
@@ -639,6 +641,12 @@ interface AudioTranslationResult {
|
|
|
639
641
|
interface AudioTranslationOptions extends MuxAIOptions {
|
|
640
642
|
/** Audio dubbing provider (currently ElevenLabs only). */
|
|
641
643
|
provider?: "elevenlabs";
|
|
644
|
+
/**
|
|
645
|
+
* Optional source language code for ElevenLabs `source_lang`.
|
|
646
|
+
* Accepts ISO 639-1 (e.g. "en") or ISO 639-3 (e.g. "eng").
|
|
647
|
+
* Defaults to auto-detect when omitted.
|
|
648
|
+
*/
|
|
649
|
+
fromLanguageCode?: string;
|
|
642
650
|
/** Number of speakers supplied to ElevenLabs (0 = auto-detect, default). */
|
|
643
651
|
numSpeakers?: number;
|
|
644
652
|
/** Optional override for the S3-compatible endpoint used for uploads. */
|
|
@@ -732,6 +740,8 @@ type index_ChaptersResult = ChaptersResult;
|
|
|
732
740
|
type index_ChaptersType = ChaptersType;
|
|
733
741
|
type index_EmbeddingsOptions = EmbeddingsOptions;
|
|
734
742
|
type index_EmbeddingsResult = EmbeddingsResult;
|
|
743
|
+
declare const index_HIVE_SEXUAL_CATEGORIES: typeof HIVE_SEXUAL_CATEGORIES;
|
|
744
|
+
declare const index_HIVE_VIOLENCE_CATEGORIES: typeof HIVE_VIOLENCE_CATEGORIES;
|
|
735
745
|
type index_HiveModerationOutput = HiveModerationOutput;
|
|
736
746
|
type index_HiveModerationSource = HiveModerationSource;
|
|
737
747
|
type index_ModerationOptions = ModerationOptions;
|
|
@@ -766,7 +776,7 @@ declare const index_translateAudio: typeof translateAudio;
|
|
|
766
776
|
declare const index_translateCaptions: typeof translateCaptions;
|
|
767
777
|
declare const index_translationSchema: typeof translationSchema;
|
|
768
778
|
declare namespace index {
|
|
769
|
-
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_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, type index_Question as Question, type index_QuestionAnswer as QuestionAnswer, type index_QuestionAnswerType as QuestionAnswerType, 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_askQuestions as askQuestions, 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_questionAnswerSchema as questionAnswerSchema, index_summarySchema as summarySchema, index_translateAudio as translateAudio, index_translateCaptions as translateCaptions, index_translationSchema as translationSchema };
|
|
779
|
+
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_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, 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_Question as Question, type index_QuestionAnswer as QuestionAnswer, type index_QuestionAnswerType as QuestionAnswerType, 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_askQuestions as askQuestions, 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_questionAnswerSchema as questionAnswerSchema, index_summarySchema as summarySchema, index_translateAudio as translateAudio, index_translateCaptions as translateCaptions, index_translationSchema as translationSchema };
|
|
770
780
|
}
|
|
771
781
|
|
|
772
|
-
export { type AskQuestionsOptions as A, type BurnedInCaptionsAnalysis as B, type Chapter as C, type
|
|
782
|
+
export { translateCaptions as $, type AskQuestionsOptions as A, type BurnedInCaptionsAnalysis as B, type Chapter as C, type SummaryAndTagsResult as D, type EmbeddingsOptions as E, type SummaryType as F, type TranslationOptions as G, HIVE_SEXUAL_CATEGORIES as H, type TranslationPayload as I, type TranslationResult as J, askQuestions as K, burnedInCaptionsSchema as L, type ModerationOptions as M, chapterSchema as N, chaptersSchema as O, generateChapters as P, type Question as Q, generateEmbeddings as R, SUMMARY_KEYWORD_LIMIT as S, type ThumbnailModerationScore as T, generateVideoEmbeddings as U, getModerationScores as V, getSummaryAndTags as W, hasBurnedInCaptions as X, questionAnswerSchema as Y, summarySchema as Z, translateAudio as _, type AskQuestionsResult as a, translationSchema as a0, type AskQuestionsType as b, type AudioTranslationOptions as c, type AudioTranslationResult as d, type BurnedInCaptionsOptions as e, type BurnedInCaptionsPromptOverrides as f, type BurnedInCaptionsPromptSections as g, type BurnedInCaptionsResult as h, index as i, type ChapterSystemPromptSections as j, type ChaptersOptions as k, type ChaptersPromptOverrides as l, type ChaptersPromptSections as m, type ChaptersResult as n, type ChaptersType as o, type EmbeddingsResult as p, HIVE_VIOLENCE_CATEGORIES as q, type HiveModerationOutput as r, type HiveModerationSource as s, type ModerationProvider as t, type ModerationResult as u, type QuestionAnswer as v, type QuestionAnswerType as w, type SummarizationOptions as x, type SummarizationPromptOverrides as y, type SummarizationPromptSections as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { k as WorkflowCredentialsInput, A as AssetTextTrack, d as MuxAsset, T as TextChunk, b as ChunkingStrategy } from './types-
|
|
1
|
+
import { k as WorkflowCredentialsInput, A as AssetTextTrack, d as MuxAsset, T as TextChunk, b as ChunkingStrategy } from './types-BRbaGW3t.js';
|
|
2
2
|
|
|
3
3
|
interface HeatmapOptions {
|
|
4
4
|
/** Time window for results, e.g., ['7:days'] (default: ['7:days']) */
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { W as WorkflowCredentials, S as StoragePutObjectInput, a as StoragePresignGetObjectInput } from './types-
|
|
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-
|
|
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';
|
|
3
3
|
import { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE } from '@workflow/serde';
|
|
4
|
-
export { i as primitives } from './index-
|
|
5
|
-
export { i as workflows } from './index-
|
|
4
|
+
export { i as primitives } from './index-Nxf6BaBO.js';
|
|
5
|
+
export { i as workflows } from './index-B0U9upb4.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.7.
|
|
12
|
+
var version = "0.7.5";
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* A function that returns workflow credentials, either synchronously or asynchronously.
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ var __export = (target, all) => {
|
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
// package.json
|
|
8
|
-
var version = "0.7.
|
|
8
|
+
var version = "0.7.5";
|
|
9
9
|
|
|
10
10
|
// src/env.ts
|
|
11
11
|
import { z } from "zod";
|
|
@@ -48,6 +48,9 @@ var EnvSchema = z.object({
|
|
|
48
48
|
),
|
|
49
49
|
MUX_TEST_ASSET_ID_AUDIO_ONLY: optionalString("Mux test asset ID for audio-only assets.", "Mux test asset id for audio-only assets for testing"),
|
|
50
50
|
MUX_TEST_ASSET_ID_VIOLENT_AUDIO_ONLY: optionalString("Mux test asset ID for audio-only assets with violent content.", "Mux test asset id for audio-only assets with violent content for testing"),
|
|
51
|
+
// Eval config
|
|
52
|
+
MUX_AI_EVAL_MODEL_SET: optionalString("Eval model selection mode.", "Choose between 'default' (provider defaults only) or 'all' (all configured models)"),
|
|
53
|
+
MUX_AI_EVAL_MODELS: optionalString("Comma-separated eval model pairs.", "Comma-separated provider:model pairs (e.g. 'openai:gpt-5.1,anthropic:claude-sonnet-4-5,google:gemini-3-flash-preview')"),
|
|
51
54
|
// AI Providers
|
|
52
55
|
OPENAI_API_KEY: optionalString("OpenAI API key for OpenAI-backed workflows.", "OpenAI API key"),
|
|
53
56
|
ANTHROPIC_API_KEY: optionalString("Anthropic API key for Claude-backed workflows.", "Anthropic API key"),
|
|
@@ -375,12 +378,13 @@ function readString(record, key) {
|
|
|
375
378
|
function resolveDirectMuxCredentials(record) {
|
|
376
379
|
const tokenId = readString(record, "muxTokenId");
|
|
377
380
|
const tokenSecret = readString(record, "muxTokenSecret");
|
|
381
|
+
const authorizationToken = readString(record, "muxAuthorizationToken");
|
|
378
382
|
const signingKey = readString(record, "muxSigningKey");
|
|
379
383
|
const privateKey = readString(record, "muxPrivateKey");
|
|
380
|
-
if (!tokenId && !tokenSecret && !signingKey && !privateKey) {
|
|
384
|
+
if (!tokenId && !tokenSecret && !authorizationToken && !signingKey && !privateKey) {
|
|
381
385
|
return void 0;
|
|
382
386
|
}
|
|
383
|
-
if (!tokenId || !tokenSecret) {
|
|
387
|
+
if ((!tokenId || !tokenSecret) && !authorizationToken) {
|
|
384
388
|
throw new Error(
|
|
385
389
|
"Both muxTokenId and muxTokenSecret are required when passing direct Mux workflow credentials."
|
|
386
390
|
);
|
|
@@ -388,6 +392,7 @@ function resolveDirectMuxCredentials(record) {
|
|
|
388
392
|
return {
|
|
389
393
|
tokenId,
|
|
390
394
|
tokenSecret,
|
|
395
|
+
authorizationToken,
|
|
391
396
|
signingKey,
|
|
392
397
|
privateKey
|
|
393
398
|
};
|
|
@@ -398,7 +403,8 @@ function createWorkflowMuxClient(options) {
|
|
|
398
403
|
const { default: MuxClient } = await import("@mux/mux-node");
|
|
399
404
|
return new MuxClient({
|
|
400
405
|
tokenId: options.tokenId,
|
|
401
|
-
tokenSecret: options.tokenSecret
|
|
406
|
+
tokenSecret: options.tokenSecret,
|
|
407
|
+
authorizationToken: options.authorizationToken
|
|
402
408
|
});
|
|
403
409
|
},
|
|
404
410
|
getSigningKey() {
|
|
@@ -808,6 +814,81 @@ var DEFAULT_EMBEDDING_MODELS = {
|
|
|
808
814
|
openai: "text-embedding-3-small",
|
|
809
815
|
google: "gemini-embedding-001"
|
|
810
816
|
};
|
|
817
|
+
var LANGUAGE_MODELS = {
|
|
818
|
+
openai: ["gpt-5.1", "gpt-5-mini"],
|
|
819
|
+
anthropic: ["claude-sonnet-4-5"],
|
|
820
|
+
google: ["gemini-3-flash-preview", "gemini-2.5-flash"]
|
|
821
|
+
};
|
|
822
|
+
function getDefaultEvalModelConfigs() {
|
|
823
|
+
return Object.entries(DEFAULT_LANGUAGE_MODELS).map(([provider, modelId]) => ({ provider, modelId }));
|
|
824
|
+
}
|
|
825
|
+
function getAllEvalModelConfigs() {
|
|
826
|
+
return Object.entries(LANGUAGE_MODELS).flatMap(([provider, models]) => models.map((modelId) => ({ provider, modelId })));
|
|
827
|
+
}
|
|
828
|
+
function isSupportedProvider(value) {
|
|
829
|
+
return value === "openai" || value === "anthropic" || value === "google";
|
|
830
|
+
}
|
|
831
|
+
function parseEvalModelPair(value) {
|
|
832
|
+
const trimmed = value.trim();
|
|
833
|
+
const [providerRaw, modelIdRaw] = trimmed.split(":", 2);
|
|
834
|
+
const provider = providerRaw?.trim();
|
|
835
|
+
const modelId = modelIdRaw?.trim();
|
|
836
|
+
if (!provider || !modelId) {
|
|
837
|
+
throw new Error(
|
|
838
|
+
`Invalid eval model pair "${value}". Use "provider:model" (example: "openai:gpt-5.1").`
|
|
839
|
+
);
|
|
840
|
+
}
|
|
841
|
+
if (!isSupportedProvider(provider)) {
|
|
842
|
+
throw new Error(
|
|
843
|
+
`Unsupported eval provider "${provider}" in "${value}". Supported providers: ${Object.keys(LANGUAGE_MODELS).join(", ")}.`
|
|
844
|
+
);
|
|
845
|
+
}
|
|
846
|
+
const supportedModels = LANGUAGE_MODELS[provider];
|
|
847
|
+
if (!supportedModels.includes(modelId)) {
|
|
848
|
+
throw new Error(
|
|
849
|
+
`Unsupported eval model "${modelId}" for provider "${provider}". Supported models: ${supportedModels.join(", ")}.`
|
|
850
|
+
);
|
|
851
|
+
}
|
|
852
|
+
return {
|
|
853
|
+
provider,
|
|
854
|
+
modelId
|
|
855
|
+
};
|
|
856
|
+
}
|
|
857
|
+
function resolveEvalModelConfigs(options = {}) {
|
|
858
|
+
const explicitPairs = options.modelPairs?.map((value) => value.trim()).filter(Boolean) ?? [];
|
|
859
|
+
if (explicitPairs.length > 0) {
|
|
860
|
+
const dedupedPairs = Array.from(new Set(explicitPairs));
|
|
861
|
+
return dedupedPairs.map(parseEvalModelPair);
|
|
862
|
+
}
|
|
863
|
+
const selection = options.selection ?? "default";
|
|
864
|
+
if (selection === "all") {
|
|
865
|
+
return getAllEvalModelConfigs();
|
|
866
|
+
}
|
|
867
|
+
return getDefaultEvalModelConfigs();
|
|
868
|
+
}
|
|
869
|
+
function resolveEvalModelConfigsFromEnv(environment = env_default) {
|
|
870
|
+
const rawSelection = environment.MUX_AI_EVAL_MODEL_SET?.trim();
|
|
871
|
+
const rawModelPairs = environment.MUX_AI_EVAL_MODELS?.trim();
|
|
872
|
+
let selection;
|
|
873
|
+
if (!rawSelection || rawSelection === "default") {
|
|
874
|
+
selection = "default";
|
|
875
|
+
} else if (rawSelection === "all") {
|
|
876
|
+
selection = "all";
|
|
877
|
+
} else {
|
|
878
|
+
throw new Error(
|
|
879
|
+
`Invalid MUX_AI_EVAL_MODEL_SET="${rawSelection}". Expected "default" or "all".`
|
|
880
|
+
);
|
|
881
|
+
}
|
|
882
|
+
let modelPairs;
|
|
883
|
+
if (rawModelPairs) {
|
|
884
|
+
modelPairs = rawModelPairs.split(",").map((value) => value.trim()).filter(Boolean);
|
|
885
|
+
}
|
|
886
|
+
return resolveEvalModelConfigs({
|
|
887
|
+
selection,
|
|
888
|
+
modelPairs
|
|
889
|
+
});
|
|
890
|
+
}
|
|
891
|
+
var EVAL_MODEL_CONFIGS = resolveEvalModelConfigsFromEnv();
|
|
811
892
|
function resolveLanguageModelConfig(options = {}) {
|
|
812
893
|
const provider = options.provider || "openai";
|
|
813
894
|
const modelId = options.model || DEFAULT_LANGUAGE_MODELS[provider];
|
|
@@ -975,9 +1056,9 @@ async function signPlaybackId(playbackId, context, type = "video", params) {
|
|
|
975
1056
|
params: stringParams
|
|
976
1057
|
});
|
|
977
1058
|
}
|
|
978
|
-
async function signUrl(url, playbackId,
|
|
1059
|
+
async function signUrl(url, playbackId, type = "video", params, credentials) {
|
|
979
1060
|
"use step";
|
|
980
|
-
const resolvedContext =
|
|
1061
|
+
const resolvedContext = await resolveMuxSigningContext(credentials);
|
|
981
1062
|
if (!resolvedContext) {
|
|
982
1063
|
throw new Error(
|
|
983
1064
|
"Signed playback ID requires signing credentials. Provide muxSigningKey and muxPrivateKey via workflow credentials or set MUX_SIGNING_KEY and MUX_PRIVATE_KEY environment variables."
|
|
@@ -994,7 +1075,7 @@ async function getStoryboardUrl(playbackId, width = DEFAULT_STORYBOARD_WIDTH, sh
|
|
|
994
1075
|
"use step";
|
|
995
1076
|
const baseUrl = `https://image.mux.com/${playbackId}/storyboard.png`;
|
|
996
1077
|
if (shouldSign) {
|
|
997
|
-
return signUrl(baseUrl, playbackId,
|
|
1078
|
+
return signUrl(baseUrl, playbackId, "storyboard", { width }, credentials);
|
|
998
1079
|
}
|
|
999
1080
|
return `${baseUrl}?width=${width}`;
|
|
1000
1081
|
}
|
|
@@ -1114,7 +1195,7 @@ async function getThumbnailUrls(playbackId, duration, options = {}) {
|
|
|
1114
1195
|
const baseUrl = `https://image.mux.com/${playbackId}/thumbnail.png`;
|
|
1115
1196
|
const urlPromises = timestamps.map(async (time) => {
|
|
1116
1197
|
if (shouldSign) {
|
|
1117
|
-
return signUrl(baseUrl, playbackId,
|
|
1198
|
+
return signUrl(baseUrl, playbackId, "thumbnail", { time, width }, credentials);
|
|
1118
1199
|
}
|
|
1119
1200
|
return `${baseUrl}?time=${time}&width=${width}`;
|
|
1120
1201
|
});
|
|
@@ -1243,7 +1324,7 @@ async function buildTranscriptUrl(playbackId, trackId, shouldSign = false, crede
|
|
|
1243
1324
|
"use step";
|
|
1244
1325
|
const baseUrl = `https://stream.mux.com/${playbackId}/text/${trackId}.vtt`;
|
|
1245
1326
|
if (shouldSign) {
|
|
1246
|
-
return signUrl(baseUrl, playbackId,
|
|
1327
|
+
return signUrl(baseUrl, playbackId, "video", void 0, credentials);
|
|
1247
1328
|
}
|
|
1248
1329
|
return baseUrl;
|
|
1249
1330
|
}
|
|
@@ -1301,6 +1382,8 @@ async function fetchTranscriptForAsset(asset, playbackId, options = {}) {
|
|
|
1301
1382
|
// src/workflows/index.ts
|
|
1302
1383
|
var workflows_exports = {};
|
|
1303
1384
|
__export(workflows_exports, {
|
|
1385
|
+
HIVE_SEXUAL_CATEGORIES: () => HIVE_SEXUAL_CATEGORIES,
|
|
1386
|
+
HIVE_VIOLENCE_CATEGORIES: () => HIVE_VIOLENCE_CATEGORIES,
|
|
1304
1387
|
SUMMARY_KEYWORD_LIMIT: () => SUMMARY_KEYWORD_LIMIT,
|
|
1305
1388
|
askQuestions: () => askQuestions,
|
|
1306
1389
|
burnedInCaptionsSchema: () => burnedInCaptionsSchema,
|
|
@@ -2525,11 +2608,10 @@ var DEFAULT_PROVIDER2 = "openai";
|
|
|
2525
2608
|
var HIVE_ENDPOINT = "https://api.thehive.ai/api/v2/task/sync";
|
|
2526
2609
|
var HIVE_SEXUAL_CATEGORIES = [
|
|
2527
2610
|
"general_nsfw",
|
|
2528
|
-
"general_suggestive",
|
|
2529
2611
|
"yes_sexual_activity",
|
|
2530
|
-
"
|
|
2531
|
-
"
|
|
2532
|
-
"
|
|
2612
|
+
"yes_sex_toy",
|
|
2613
|
+
"yes_female_nudity",
|
|
2614
|
+
"yes_male_nudity"
|
|
2533
2615
|
];
|
|
2534
2616
|
var HIVE_VIOLENCE_CATEGORIES = [
|
|
2535
2617
|
"gun_in_hand",
|
|
@@ -2540,10 +2622,8 @@ var HIVE_VIOLENCE_CATEGORIES = [
|
|
|
2540
2622
|
"hanging",
|
|
2541
2623
|
"noose",
|
|
2542
2624
|
"human_corpse",
|
|
2543
|
-
"
|
|
2544
|
-
"
|
|
2545
|
-
"animal_abuse",
|
|
2546
|
-
"fights",
|
|
2625
|
+
"yes_emaciated_body",
|
|
2626
|
+
"yes_self_harm",
|
|
2547
2627
|
"garm_death_injury_or_military_conflict"
|
|
2548
2628
|
];
|
|
2549
2629
|
async function processConcurrently(items, processor, maxConcurrent = 5) {
|
|
@@ -2687,6 +2767,12 @@ function getHiveCategoryScores(classes, categoryNames) {
|
|
|
2687
2767
|
const scoreMap = Object.fromEntries(
|
|
2688
2768
|
classes.map((c) => [c.class, c.score])
|
|
2689
2769
|
);
|
|
2770
|
+
const missingCategories = categoryNames.filter((category) => !(category in scoreMap));
|
|
2771
|
+
if (missingCategories.length > 0) {
|
|
2772
|
+
console.warn(
|
|
2773
|
+
`Hive response missing expected categories: ${missingCategories.join(", ")}`
|
|
2774
|
+
);
|
|
2775
|
+
}
|
|
2690
2776
|
const scores = categoryNames.map((category) => scoreMap[category] || 0);
|
|
2691
2777
|
return Math.max(...scores, 0);
|
|
2692
2778
|
}
|
|
@@ -2784,7 +2870,7 @@ async function getThumbnailUrlsFromTimestamps(playbackId, timestampsMs, options)
|
|
|
2784
2870
|
const urlPromises = timestampsMs.map(async (tsMs) => {
|
|
2785
2871
|
const time = Number((tsMs / 1e3).toFixed(2));
|
|
2786
2872
|
if (shouldSign) {
|
|
2787
|
-
return signUrl(baseUrl, playbackId,
|
|
2873
|
+
return signUrl(baseUrl, playbackId, "thumbnail", { time, width }, credentials);
|
|
2788
2874
|
}
|
|
2789
2875
|
return `${baseUrl}?time=${time}&width=${width}`;
|
|
2790
2876
|
});
|
|
@@ -3597,6 +3683,18 @@ function getReadyAudioStaticRendition(asset) {
|
|
|
3597
3683
|
);
|
|
3598
3684
|
}
|
|
3599
3685
|
var hasReadyAudioStaticRendition = (asset) => Boolean(getReadyAudioStaticRendition(asset));
|
|
3686
|
+
function getAudioStaticRenditionStatus(asset) {
|
|
3687
|
+
const files = asset.static_renditions?.files;
|
|
3688
|
+
const audioRendition = files?.find((rendition) => rendition.name === "audio.m4a");
|
|
3689
|
+
if (typeof audioRendition?.status === "string" && audioRendition.status.length > 0) {
|
|
3690
|
+
return audioRendition.status;
|
|
3691
|
+
}
|
|
3692
|
+
const aggregateStatus = asset.static_renditions?.status;
|
|
3693
|
+
if (typeof aggregateStatus === "string" && aggregateStatus.length > 0) {
|
|
3694
|
+
return aggregateStatus;
|
|
3695
|
+
}
|
|
3696
|
+
return asset.static_renditions ? "requested" : "not_requested";
|
|
3697
|
+
}
|
|
3600
3698
|
async function requestStaticRenditionCreation(assetId, credentials) {
|
|
3601
3699
|
"use step";
|
|
3602
3700
|
const muxClient = await resolveMuxClient(credentials);
|
|
@@ -3642,7 +3740,7 @@ async function waitForAudioStaticRendition({
|
|
|
3642
3740
|
if (hasReadyAudioStaticRendition(currentAsset)) {
|
|
3643
3741
|
return currentAsset;
|
|
3644
3742
|
}
|
|
3645
|
-
const currentStatus = currentAsset
|
|
3743
|
+
const currentStatus = getAudioStaticRenditionStatus(currentAsset);
|
|
3646
3744
|
console.warn(
|
|
3647
3745
|
`\u231B Waiting for static rendition (attempt ${attempt}/${STATIC_RENDITION_MAX_ATTEMPTS}) \u2192 ${currentStatus}`
|
|
3648
3746
|
);
|
|
@@ -3668,6 +3766,7 @@ async function createElevenLabsDubbingJob({
|
|
|
3668
3766
|
audioBuffer,
|
|
3669
3767
|
assetId,
|
|
3670
3768
|
elevenLabsLangCode,
|
|
3769
|
+
elevenLabsSourceLangCode,
|
|
3671
3770
|
numSpeakers,
|
|
3672
3771
|
credentials
|
|
3673
3772
|
}) {
|
|
@@ -3677,8 +3776,14 @@ async function createElevenLabsDubbingJob({
|
|
|
3677
3776
|
const formData = new FormData();
|
|
3678
3777
|
formData.append("file", audioBlob);
|
|
3679
3778
|
formData.append("target_lang", elevenLabsLangCode);
|
|
3779
|
+
if (elevenLabsSourceLangCode) {
|
|
3780
|
+
formData.append("source_lang", elevenLabsSourceLangCode);
|
|
3781
|
+
}
|
|
3680
3782
|
formData.append("num_speakers", numSpeakers.toString());
|
|
3681
|
-
formData.append(
|
|
3783
|
+
formData.append(
|
|
3784
|
+
"name",
|
|
3785
|
+
`Mux Asset ${assetId} - ${elevenLabsSourceLangCode ?? "auto"} to ${elevenLabsLangCode}`
|
|
3786
|
+
);
|
|
3682
3787
|
const dubbingResponse = await fetch("https://api.elevenlabs.io/v1/dubbing", {
|
|
3683
3788
|
method: "POST",
|
|
3684
3789
|
headers: {
|
|
@@ -3787,6 +3892,7 @@ async function translateAudio(assetId, toLanguageCode, options = {}) {
|
|
|
3787
3892
|
"use workflow";
|
|
3788
3893
|
const {
|
|
3789
3894
|
provider = "elevenlabs",
|
|
3895
|
+
fromLanguageCode,
|
|
3790
3896
|
numSpeakers = 0,
|
|
3791
3897
|
// 0 = auto-detect
|
|
3792
3898
|
uploadToMux = true,
|
|
@@ -3825,7 +3931,7 @@ async function translateAudio(assetId, toLanguageCode, options = {}) {
|
|
|
3825
3931
|
}
|
|
3826
3932
|
let audioUrl = `https://stream.mux.com/${playbackId}/audio.m4a`;
|
|
3827
3933
|
if (policy === "signed") {
|
|
3828
|
-
audioUrl = await signUrl(audioUrl, playbackId,
|
|
3934
|
+
audioUrl = await signUrl(audioUrl, playbackId, "video", void 0, credentials);
|
|
3829
3935
|
}
|
|
3830
3936
|
console.warn("\u{1F399}\uFE0F Fetching audio from Mux...");
|
|
3831
3937
|
let audioBuffer;
|
|
@@ -3836,13 +3942,18 @@ async function translateAudio(assetId, toLanguageCode, options = {}) {
|
|
|
3836
3942
|
}
|
|
3837
3943
|
console.warn("\u{1F399}\uFE0F Creating dubbing job in ElevenLabs...");
|
|
3838
3944
|
const elevenLabsLangCode = toISO639_3(toLanguageCode);
|
|
3839
|
-
|
|
3945
|
+
const normalizedFromLanguageCode = fromLanguageCode?.trim();
|
|
3946
|
+
const elevenLabsSourceLangCode = normalizedFromLanguageCode ? toISO639_3(normalizedFromLanguageCode) : void 0;
|
|
3947
|
+
console.warn(
|
|
3948
|
+
`\u{1F50D} Creating dubbing job for asset ${assetId}: ${elevenLabsSourceLangCode ?? "auto"} -> ${elevenLabsLangCode}`
|
|
3949
|
+
);
|
|
3840
3950
|
let dubbingId;
|
|
3841
3951
|
try {
|
|
3842
3952
|
dubbingId = await createElevenLabsDubbingJob({
|
|
3843
3953
|
audioBuffer,
|
|
3844
3954
|
assetId,
|
|
3845
3955
|
elevenLabsLangCode,
|
|
3956
|
+
elevenLabsSourceLangCode,
|
|
3846
3957
|
numSpeakers,
|
|
3847
3958
|
credentials
|
|
3848
3959
|
});
|