@mux/ai 0.7.4 → 0.7.6
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-Bavk1Y8-.d.ts → index-B0U9upb4.d.ts} +7 -3
- package/dist/{index-DZlygsvb.d.ts → index-Nxf6BaBO.d.ts} +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +72 -22
- package/dist/index.js.map +1 -1
- package/dist/primitives/index.d.ts +2 -2
- package/dist/primitives/index.js +55 -10
- 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 +71 -21
- package/dist/workflows/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -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)
|
|
@@ -738,6 +740,8 @@ type index_ChaptersResult = ChaptersResult;
|
|
|
738
740
|
type index_ChaptersType = ChaptersType;
|
|
739
741
|
type index_EmbeddingsOptions = EmbeddingsOptions;
|
|
740
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;
|
|
741
745
|
type index_HiveModerationOutput = HiveModerationOutput;
|
|
742
746
|
type index_HiveModerationSource = HiveModerationSource;
|
|
743
747
|
type index_ModerationOptions = ModerationOptions;
|
|
@@ -772,7 +776,7 @@ declare const index_translateAudio: typeof translateAudio;
|
|
|
772
776
|
declare const index_translateCaptions: typeof translateCaptions;
|
|
773
777
|
declare const index_translationSchema: typeof translationSchema;
|
|
774
778
|
declare namespace index {
|
|
775
|
-
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 };
|
|
776
780
|
}
|
|
777
781
|
|
|
778
|
-
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.6";
|
|
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.6";
|
|
9
9
|
|
|
10
10
|
// src/env.ts
|
|
11
11
|
import { z } from "zod";
|
|
@@ -30,6 +30,10 @@ var EnvSchema = z.object({
|
|
|
30
30
|
),
|
|
31
31
|
MUX_SIGNING_KEY: optionalString("Mux signing key ID for signed playback URLs.", "Used to sign playback URLs"),
|
|
32
32
|
MUX_PRIVATE_KEY: optionalString("Mux signing private key for signed playback URLs.", "Used to sign playback URLs"),
|
|
33
|
+
MUX_IMAGE_URL_OVERRIDE: optionalString(
|
|
34
|
+
"Override for Mux image base URL (defaults to https://image.mux.com).",
|
|
35
|
+
"Mux image URL override"
|
|
36
|
+
),
|
|
33
37
|
// Test-only helpers (used by this repo's integration tests)
|
|
34
38
|
MUX_TEST_ASSET_ID: optionalString("Mux asset ID used by integration tests.", "Mux test asset id"),
|
|
35
39
|
MUX_TEST_ASSET_ID_CHAPTERS: optionalString("Mux asset ID used by integration tests for chapters.", "Mux test asset id for chapters"),
|
|
@@ -378,12 +382,13 @@ function readString(record, key) {
|
|
|
378
382
|
function resolveDirectMuxCredentials(record) {
|
|
379
383
|
const tokenId = readString(record, "muxTokenId");
|
|
380
384
|
const tokenSecret = readString(record, "muxTokenSecret");
|
|
385
|
+
const authorizationToken = readString(record, "muxAuthorizationToken");
|
|
381
386
|
const signingKey = readString(record, "muxSigningKey");
|
|
382
387
|
const privateKey = readString(record, "muxPrivateKey");
|
|
383
|
-
if (!tokenId && !tokenSecret && !signingKey && !privateKey) {
|
|
388
|
+
if (!tokenId && !tokenSecret && !authorizationToken && !signingKey && !privateKey) {
|
|
384
389
|
return void 0;
|
|
385
390
|
}
|
|
386
|
-
if (!tokenId || !tokenSecret) {
|
|
391
|
+
if ((!tokenId || !tokenSecret) && !authorizationToken) {
|
|
387
392
|
throw new Error(
|
|
388
393
|
"Both muxTokenId and muxTokenSecret are required when passing direct Mux workflow credentials."
|
|
389
394
|
);
|
|
@@ -391,6 +396,7 @@ function resolveDirectMuxCredentials(record) {
|
|
|
391
396
|
return {
|
|
392
397
|
tokenId,
|
|
393
398
|
tokenSecret,
|
|
399
|
+
authorizationToken,
|
|
394
400
|
signingKey,
|
|
395
401
|
privateKey
|
|
396
402
|
};
|
|
@@ -401,7 +407,8 @@ function createWorkflowMuxClient(options) {
|
|
|
401
407
|
const { default: MuxClient } = await import("@mux/mux-node");
|
|
402
408
|
return new MuxClient({
|
|
403
409
|
tokenId: options.tokenId,
|
|
404
|
-
tokenSecret: options.tokenSecret
|
|
410
|
+
tokenSecret: options.tokenSecret,
|
|
411
|
+
authorizationToken: options.authorizationToken
|
|
405
412
|
});
|
|
406
413
|
},
|
|
407
414
|
getSigningKey() {
|
|
@@ -1029,6 +1036,44 @@ async function fetchHotspots(identifierType, id, options) {
|
|
|
1029
1036
|
return transformHotspotResponse(response);
|
|
1030
1037
|
}
|
|
1031
1038
|
|
|
1039
|
+
// src/lib/mux-image-url.ts
|
|
1040
|
+
var DEFAULT_MUX_IMAGE_ORIGIN = "https://image.mux.com";
|
|
1041
|
+
function normalizeMuxImageOrigin(value) {
|
|
1042
|
+
const trimmed = value.trim();
|
|
1043
|
+
const candidate = trimmed.includes("://") ? trimmed : `https://${trimmed}`;
|
|
1044
|
+
let parsed;
|
|
1045
|
+
try {
|
|
1046
|
+
parsed = new URL(candidate);
|
|
1047
|
+
} catch {
|
|
1048
|
+
throw new Error(
|
|
1049
|
+
`Invalid MUX_IMAGE_URL_OVERRIDE. Provide a hostname like "image.example.mux.com" (or a URL origin such as "https://image.example.mux.com").`
|
|
1050
|
+
);
|
|
1051
|
+
}
|
|
1052
|
+
if (parsed.username || parsed.password || parsed.search || parsed.hash || parsed.pathname && parsed.pathname !== "/") {
|
|
1053
|
+
throw new Error(
|
|
1054
|
+
"Invalid MUX_IMAGE_URL_OVERRIDE. Only a hostname/origin is allowed (no credentials, query params, hash fragments, or path)."
|
|
1055
|
+
);
|
|
1056
|
+
}
|
|
1057
|
+
return parsed.origin;
|
|
1058
|
+
}
|
|
1059
|
+
function getMuxImageOrigin() {
|
|
1060
|
+
const override = env_default.MUX_IMAGE_URL_OVERRIDE;
|
|
1061
|
+
if (!override) {
|
|
1062
|
+
return DEFAULT_MUX_IMAGE_ORIGIN;
|
|
1063
|
+
}
|
|
1064
|
+
return normalizeMuxImageOrigin(override);
|
|
1065
|
+
}
|
|
1066
|
+
function getMuxImageBaseUrl(playbackId, assetType) {
|
|
1067
|
+
const origin = getMuxImageOrigin();
|
|
1068
|
+
return `${origin}/${playbackId}/${assetType}.png`;
|
|
1069
|
+
}
|
|
1070
|
+
function getMuxStoryboardBaseUrl(playbackId) {
|
|
1071
|
+
return getMuxImageBaseUrl(playbackId, "storyboard");
|
|
1072
|
+
}
|
|
1073
|
+
function getMuxThumbnailBaseUrl(playbackId) {
|
|
1074
|
+
return getMuxImageBaseUrl(playbackId, "thumbnail");
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1032
1077
|
// src/lib/url-signing.ts
|
|
1033
1078
|
async function createSigningClient(context) {
|
|
1034
1079
|
const { default: MuxClient } = await import("@mux/mux-node");
|
|
@@ -1053,9 +1098,9 @@ async function signPlaybackId(playbackId, context, type = "video", params) {
|
|
|
1053
1098
|
params: stringParams
|
|
1054
1099
|
});
|
|
1055
1100
|
}
|
|
1056
|
-
async function signUrl(url, playbackId,
|
|
1101
|
+
async function signUrl(url, playbackId, type = "video", params, credentials) {
|
|
1057
1102
|
"use step";
|
|
1058
|
-
const resolvedContext =
|
|
1103
|
+
const resolvedContext = await resolveMuxSigningContext(credentials);
|
|
1059
1104
|
if (!resolvedContext) {
|
|
1060
1105
|
throw new Error(
|
|
1061
1106
|
"Signed playback ID requires signing credentials. Provide muxSigningKey and muxPrivateKey via workflow credentials or set MUX_SIGNING_KEY and MUX_PRIVATE_KEY environment variables."
|
|
@@ -1070,9 +1115,9 @@ async function signUrl(url, playbackId, context, type = "video", params, credent
|
|
|
1070
1115
|
var DEFAULT_STORYBOARD_WIDTH = 640;
|
|
1071
1116
|
async function getStoryboardUrl(playbackId, width = DEFAULT_STORYBOARD_WIDTH, shouldSign = false, credentials) {
|
|
1072
1117
|
"use step";
|
|
1073
|
-
const baseUrl =
|
|
1118
|
+
const baseUrl = getMuxStoryboardBaseUrl(playbackId);
|
|
1074
1119
|
if (shouldSign) {
|
|
1075
|
-
return signUrl(baseUrl, playbackId,
|
|
1120
|
+
return signUrl(baseUrl, playbackId, "storyboard", { width }, credentials);
|
|
1076
1121
|
}
|
|
1077
1122
|
return `${baseUrl}?width=${width}`;
|
|
1078
1123
|
}
|
|
@@ -1189,10 +1234,10 @@ async function getThumbnailUrls(playbackId, duration, options = {}) {
|
|
|
1189
1234
|
}
|
|
1190
1235
|
timestamps = newTimestamps;
|
|
1191
1236
|
}
|
|
1192
|
-
const baseUrl =
|
|
1237
|
+
const baseUrl = getMuxThumbnailBaseUrl(playbackId);
|
|
1193
1238
|
const urlPromises = timestamps.map(async (time) => {
|
|
1194
1239
|
if (shouldSign) {
|
|
1195
|
-
return signUrl(baseUrl, playbackId,
|
|
1240
|
+
return signUrl(baseUrl, playbackId, "thumbnail", { time, width }, credentials);
|
|
1196
1241
|
}
|
|
1197
1242
|
return `${baseUrl}?time=${time}&width=${width}`;
|
|
1198
1243
|
});
|
|
@@ -1321,7 +1366,7 @@ async function buildTranscriptUrl(playbackId, trackId, shouldSign = false, crede
|
|
|
1321
1366
|
"use step";
|
|
1322
1367
|
const baseUrl = `https://stream.mux.com/${playbackId}/text/${trackId}.vtt`;
|
|
1323
1368
|
if (shouldSign) {
|
|
1324
|
-
return signUrl(baseUrl, playbackId,
|
|
1369
|
+
return signUrl(baseUrl, playbackId, "video", void 0, credentials);
|
|
1325
1370
|
}
|
|
1326
1371
|
return baseUrl;
|
|
1327
1372
|
}
|
|
@@ -1379,6 +1424,8 @@ async function fetchTranscriptForAsset(asset, playbackId, options = {}) {
|
|
|
1379
1424
|
// src/workflows/index.ts
|
|
1380
1425
|
var workflows_exports = {};
|
|
1381
1426
|
__export(workflows_exports, {
|
|
1427
|
+
HIVE_SEXUAL_CATEGORIES: () => HIVE_SEXUAL_CATEGORIES,
|
|
1428
|
+
HIVE_VIOLENCE_CATEGORIES: () => HIVE_VIOLENCE_CATEGORIES,
|
|
1382
1429
|
SUMMARY_KEYWORD_LIMIT: () => SUMMARY_KEYWORD_LIMIT,
|
|
1383
1430
|
askQuestions: () => askQuestions,
|
|
1384
1431
|
burnedInCaptionsSchema: () => burnedInCaptionsSchema,
|
|
@@ -2603,11 +2650,10 @@ var DEFAULT_PROVIDER2 = "openai";
|
|
|
2603
2650
|
var HIVE_ENDPOINT = "https://api.thehive.ai/api/v2/task/sync";
|
|
2604
2651
|
var HIVE_SEXUAL_CATEGORIES = [
|
|
2605
2652
|
"general_nsfw",
|
|
2606
|
-
"general_suggestive",
|
|
2607
2653
|
"yes_sexual_activity",
|
|
2608
|
-
"
|
|
2609
|
-
"
|
|
2610
|
-
"
|
|
2654
|
+
"yes_sex_toy",
|
|
2655
|
+
"yes_female_nudity",
|
|
2656
|
+
"yes_male_nudity"
|
|
2611
2657
|
];
|
|
2612
2658
|
var HIVE_VIOLENCE_CATEGORIES = [
|
|
2613
2659
|
"gun_in_hand",
|
|
@@ -2618,10 +2664,8 @@ var HIVE_VIOLENCE_CATEGORIES = [
|
|
|
2618
2664
|
"hanging",
|
|
2619
2665
|
"noose",
|
|
2620
2666
|
"human_corpse",
|
|
2621
|
-
"
|
|
2622
|
-
"
|
|
2623
|
-
"animal_abuse",
|
|
2624
|
-
"fights",
|
|
2667
|
+
"yes_emaciated_body",
|
|
2668
|
+
"yes_self_harm",
|
|
2625
2669
|
"garm_death_injury_or_military_conflict"
|
|
2626
2670
|
];
|
|
2627
2671
|
async function processConcurrently(items, processor, maxConcurrent = 5) {
|
|
@@ -2765,6 +2809,12 @@ function getHiveCategoryScores(classes, categoryNames) {
|
|
|
2765
2809
|
const scoreMap = Object.fromEntries(
|
|
2766
2810
|
classes.map((c) => [c.class, c.score])
|
|
2767
2811
|
);
|
|
2812
|
+
const missingCategories = categoryNames.filter((category) => !(category in scoreMap));
|
|
2813
|
+
if (missingCategories.length > 0) {
|
|
2814
|
+
console.warn(
|
|
2815
|
+
`Hive response missing expected categories: ${missingCategories.join(", ")}`
|
|
2816
|
+
);
|
|
2817
|
+
}
|
|
2768
2818
|
const scores = categoryNames.map((category) => scoreMap[category] || 0);
|
|
2769
2819
|
return Math.max(...scores, 0);
|
|
2770
2820
|
}
|
|
@@ -2858,11 +2908,11 @@ async function requestHiveModeration(imageUrls, maxConcurrent = 5, submissionMod
|
|
|
2858
2908
|
async function getThumbnailUrlsFromTimestamps(playbackId, timestampsMs, options) {
|
|
2859
2909
|
"use step";
|
|
2860
2910
|
const { width, shouldSign, credentials } = options;
|
|
2861
|
-
const baseUrl =
|
|
2911
|
+
const baseUrl = getMuxThumbnailBaseUrl(playbackId);
|
|
2862
2912
|
const urlPromises = timestampsMs.map(async (tsMs) => {
|
|
2863
2913
|
const time = Number((tsMs / 1e3).toFixed(2));
|
|
2864
2914
|
if (shouldSign) {
|
|
2865
|
-
return signUrl(baseUrl, playbackId,
|
|
2915
|
+
return signUrl(baseUrl, playbackId, "thumbnail", { time, width }, credentials);
|
|
2866
2916
|
}
|
|
2867
2917
|
return `${baseUrl}?time=${time}&width=${width}`;
|
|
2868
2918
|
});
|
|
@@ -3923,7 +3973,7 @@ async function translateAudio(assetId, toLanguageCode, options = {}) {
|
|
|
3923
3973
|
}
|
|
3924
3974
|
let audioUrl = `https://stream.mux.com/${playbackId}/audio.m4a`;
|
|
3925
3975
|
if (policy === "signed") {
|
|
3926
|
-
audioUrl = await signUrl(audioUrl, playbackId,
|
|
3976
|
+
audioUrl = await signUrl(audioUrl, playbackId, "video", void 0, credentials);
|
|
3927
3977
|
}
|
|
3928
3978
|
console.warn("\u{1F399}\uFE0F Fetching audio from Mux...");
|
|
3929
3979
|
let audioBuffer;
|