@mux/ai 0.7.4 → 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.
@@ -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-BQVi_wnh.js';
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 TranslationOptions as D, type EmbeddingsOptions as E, type TranslationPayload as F, type TranslationResult as G, type HiveModerationOutput as H, askQuestions as I, burnedInCaptionsSchema as J, chapterSchema as K, chaptersSchema as L, type ModerationOptions as M, generateChapters as N, generateEmbeddings as O, generateVideoEmbeddings as P, type Question as Q, getModerationScores as R, SUMMARY_KEYWORD_LIMIT as S, type ThumbnailModerationScore as T, getSummaryAndTags as U, hasBurnedInCaptions as V, questionAnswerSchema as W, summarySchema as X, translateAudio as Y, translateCaptions as Z, translationSchema as _, type AskQuestionsResult as a, 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, type HiveModerationSource as q, type ModerationProvider as r, type ModerationResult as s, type QuestionAnswer as t, type QuestionAnswerType as u, type SummarizationOptions as v, type SummarizationPromptOverrides as w, type SummarizationPromptSections as x, type SummaryAndTagsResult as y, type SummaryType as z };
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-BQVi_wnh.js';
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-BQVi_wnh.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-BQVi_wnh.js';
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-DZlygsvb.js';
5
- export { i as workflows } from './index-Bavk1Y8-.js';
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.4";
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.4";
8
+ var version = "0.7.5";
9
9
 
10
10
  // src/env.ts
11
11
  import { z } from "zod";
@@ -378,12 +378,13 @@ function readString(record, key) {
378
378
  function resolveDirectMuxCredentials(record) {
379
379
  const tokenId = readString(record, "muxTokenId");
380
380
  const tokenSecret = readString(record, "muxTokenSecret");
381
+ const authorizationToken = readString(record, "muxAuthorizationToken");
381
382
  const signingKey = readString(record, "muxSigningKey");
382
383
  const privateKey = readString(record, "muxPrivateKey");
383
- if (!tokenId && !tokenSecret && !signingKey && !privateKey) {
384
+ if (!tokenId && !tokenSecret && !authorizationToken && !signingKey && !privateKey) {
384
385
  return void 0;
385
386
  }
386
- if (!tokenId || !tokenSecret) {
387
+ if ((!tokenId || !tokenSecret) && !authorizationToken) {
387
388
  throw new Error(
388
389
  "Both muxTokenId and muxTokenSecret are required when passing direct Mux workflow credentials."
389
390
  );
@@ -391,6 +392,7 @@ function resolveDirectMuxCredentials(record) {
391
392
  return {
392
393
  tokenId,
393
394
  tokenSecret,
395
+ authorizationToken,
394
396
  signingKey,
395
397
  privateKey
396
398
  };
@@ -401,7 +403,8 @@ function createWorkflowMuxClient(options) {
401
403
  const { default: MuxClient } = await import("@mux/mux-node");
402
404
  return new MuxClient({
403
405
  tokenId: options.tokenId,
404
- tokenSecret: options.tokenSecret
406
+ tokenSecret: options.tokenSecret,
407
+ authorizationToken: options.authorizationToken
405
408
  });
406
409
  },
407
410
  getSigningKey() {
@@ -1053,9 +1056,9 @@ async function signPlaybackId(playbackId, context, type = "video", params) {
1053
1056
  params: stringParams
1054
1057
  });
1055
1058
  }
1056
- async function signUrl(url, playbackId, context, type = "video", params, credentials) {
1059
+ async function signUrl(url, playbackId, type = "video", params, credentials) {
1057
1060
  "use step";
1058
- const resolvedContext = context ?? await resolveMuxSigningContext(credentials);
1061
+ const resolvedContext = await resolveMuxSigningContext(credentials);
1059
1062
  if (!resolvedContext) {
1060
1063
  throw new Error(
1061
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."
@@ -1072,7 +1075,7 @@ async function getStoryboardUrl(playbackId, width = DEFAULT_STORYBOARD_WIDTH, sh
1072
1075
  "use step";
1073
1076
  const baseUrl = `https://image.mux.com/${playbackId}/storyboard.png`;
1074
1077
  if (shouldSign) {
1075
- return signUrl(baseUrl, playbackId, void 0, "storyboard", { width }, credentials);
1078
+ return signUrl(baseUrl, playbackId, "storyboard", { width }, credentials);
1076
1079
  }
1077
1080
  return `${baseUrl}?width=${width}`;
1078
1081
  }
@@ -1192,7 +1195,7 @@ async function getThumbnailUrls(playbackId, duration, options = {}) {
1192
1195
  const baseUrl = `https://image.mux.com/${playbackId}/thumbnail.png`;
1193
1196
  const urlPromises = timestamps.map(async (time) => {
1194
1197
  if (shouldSign) {
1195
- return signUrl(baseUrl, playbackId, void 0, "thumbnail", { time, width }, credentials);
1198
+ return signUrl(baseUrl, playbackId, "thumbnail", { time, width }, credentials);
1196
1199
  }
1197
1200
  return `${baseUrl}?time=${time}&width=${width}`;
1198
1201
  });
@@ -1321,7 +1324,7 @@ async function buildTranscriptUrl(playbackId, trackId, shouldSign = false, crede
1321
1324
  "use step";
1322
1325
  const baseUrl = `https://stream.mux.com/${playbackId}/text/${trackId}.vtt`;
1323
1326
  if (shouldSign) {
1324
- return signUrl(baseUrl, playbackId, void 0, "video", void 0, credentials);
1327
+ return signUrl(baseUrl, playbackId, "video", void 0, credentials);
1325
1328
  }
1326
1329
  return baseUrl;
1327
1330
  }
@@ -1379,6 +1382,8 @@ async function fetchTranscriptForAsset(asset, playbackId, options = {}) {
1379
1382
  // src/workflows/index.ts
1380
1383
  var workflows_exports = {};
1381
1384
  __export(workflows_exports, {
1385
+ HIVE_SEXUAL_CATEGORIES: () => HIVE_SEXUAL_CATEGORIES,
1386
+ HIVE_VIOLENCE_CATEGORIES: () => HIVE_VIOLENCE_CATEGORIES,
1382
1387
  SUMMARY_KEYWORD_LIMIT: () => SUMMARY_KEYWORD_LIMIT,
1383
1388
  askQuestions: () => askQuestions,
1384
1389
  burnedInCaptionsSchema: () => burnedInCaptionsSchema,
@@ -2603,11 +2608,10 @@ var DEFAULT_PROVIDER2 = "openai";
2603
2608
  var HIVE_ENDPOINT = "https://api.thehive.ai/api/v2/task/sync";
2604
2609
  var HIVE_SEXUAL_CATEGORIES = [
2605
2610
  "general_nsfw",
2606
- "general_suggestive",
2607
2611
  "yes_sexual_activity",
2608
- "sex_toys",
2609
- "nudity_female",
2610
- "nudity_male"
2612
+ "yes_sex_toy",
2613
+ "yes_female_nudity",
2614
+ "yes_male_nudity"
2611
2615
  ];
2612
2616
  var HIVE_VIOLENCE_CATEGORIES = [
2613
2617
  "gun_in_hand",
@@ -2618,10 +2622,8 @@ var HIVE_VIOLENCE_CATEGORIES = [
2618
2622
  "hanging",
2619
2623
  "noose",
2620
2624
  "human_corpse",
2621
- "emaciated_body",
2622
- "self_harm",
2623
- "animal_abuse",
2624
- "fights",
2625
+ "yes_emaciated_body",
2626
+ "yes_self_harm",
2625
2627
  "garm_death_injury_or_military_conflict"
2626
2628
  ];
2627
2629
  async function processConcurrently(items, processor, maxConcurrent = 5) {
@@ -2765,6 +2767,12 @@ function getHiveCategoryScores(classes, categoryNames) {
2765
2767
  const scoreMap = Object.fromEntries(
2766
2768
  classes.map((c) => [c.class, c.score])
2767
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
+ }
2768
2776
  const scores = categoryNames.map((category) => scoreMap[category] || 0);
2769
2777
  return Math.max(...scores, 0);
2770
2778
  }
@@ -2862,7 +2870,7 @@ async function getThumbnailUrlsFromTimestamps(playbackId, timestampsMs, options)
2862
2870
  const urlPromises = timestampsMs.map(async (tsMs) => {
2863
2871
  const time = Number((tsMs / 1e3).toFixed(2));
2864
2872
  if (shouldSign) {
2865
- return signUrl(baseUrl, playbackId, void 0, "thumbnail", { time, width }, credentials);
2873
+ return signUrl(baseUrl, playbackId, "thumbnail", { time, width }, credentials);
2866
2874
  }
2867
2875
  return `${baseUrl}?time=${time}&width=${width}`;
2868
2876
  });
@@ -3923,7 +3931,7 @@ async function translateAudio(assetId, toLanguageCode, options = {}) {
3923
3931
  }
3924
3932
  let audioUrl = `https://stream.mux.com/${playbackId}/audio.m4a`;
3925
3933
  if (policy === "signed") {
3926
- audioUrl = await signUrl(audioUrl, playbackId, void 0, "video", void 0, credentials);
3934
+ audioUrl = await signUrl(audioUrl, playbackId, "video", void 0, credentials);
3927
3935
  }
3928
3936
  console.warn("\u{1F399}\uFE0F Fetching audio from Mux...");
3929
3937
  let audioBuffer;