@mux/ai 0.35.0 → 0.36.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.
@@ -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 { f as ScopedMuxAIOptions, I as ImageSubmissionMode, i as TokenUsage, M as MuxAIOptions, b as ChunkingStrategy, k as VideoEmbeddingsResult, H as Hotspot, v as Shot, j as ToneType, g as StorageAdapter } from './shots-BMbViFbZ.js';
5
+ import { f as ScopedMuxAIOptions, I as ImageSubmissionMode, i as TokenUsage, M as MuxAIOptions, b as ChunkingStrategy, k as VideoEmbeddingsResult, H as Hotspot, v as Shot, j as ToneType, g as StorageAdapter } from './shots-CUI09Ohe.js';
6
6
 
7
7
  /**
8
8
  * Language Code Conversion Utilities
@@ -1,4 +1,4 @@
1
- import { l as WorkflowCredentialsInput, n as WorkflowScope, A as AssetTextTrack, d as MuxAsset, T as TextChunk, b as ChunkingStrategy, q as CompletedShotsResult, r as ErroredShotsResult, H as Hotspot, s as HotspotOptions, t as HotspotResponse, u as PendingShotsResult, v as Shot, w as ShotRequestOptions, x as ShotsResult, y as WaitForShotsOptions, z as getHotspotsForAsset, B as getHotspotsForPlaybackId, D as getHotspotsForVideo, F as getShotsForAsset, G as requestShotsForAsset, J as waitForShotsForAsset } from './shots-BMbViFbZ.js';
1
+ import { l as WorkflowCredentialsInput, n as WorkflowScope, A as AssetTextTrack, d as MuxAsset, T as TextChunk, b as ChunkingStrategy, q as CompletedShotsResult, r as ErroredShotsResult, H as Hotspot, s as HotspotOptions, t as HotspotResponse, u as PendingShotsResult, v as Shot, w as ShotRequestOptions, x as ShotsResult, y as WaitForShotsOptions, z as getHotspotsForAsset, B as getHotspotsForPlaybackId, D as getHotspotsForVideo, F as getShotsForAsset, G as requestShotsForAsset, J as waitForShotsForAsset } from './shots-CUI09Ohe.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
- export { I as ISO639_1, a as ISO639_3, L as LanguageCodePair, S as SupportedISO639_1, b as SupportedISO639_3, g as getLanguageCodePair, c as getLanguageName, i as isUndeterminedLanguageCode, d as isValidISO639_1, e as isValidISO639_3, t as toISO639_1, f as toISO639_3, h as workflows } from './index-fU3hmKZu.js';
2
- import { W as WorkflowCredentials, S as StoragePutObjectInput, a as StoragePresignGetObjectInput } from './shots-BMbViFbZ.js';
3
- 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 ScopedMuxAIOptions, g as StorageAdapter, T as TextChunk, h as TokenChunkingConfig, i as TokenUsage, j as ToneType, U as UsageMetadata, V as VTTChunkingConfig, k as VideoEmbeddingsResult, l as WorkflowCredentialsInput, m as WorkflowMuxClient, n as WorkflowScope, o as decryptFromWorkflow, p as encryptForWorkflow } from './shots-BMbViFbZ.js';
1
+ export { I as ISO639_1, a as ISO639_3, L as LanguageCodePair, S as SupportedISO639_1, b as SupportedISO639_3, g as getLanguageCodePair, c as getLanguageName, i as isUndeterminedLanguageCode, d as isValidISO639_1, e as isValidISO639_3, t as toISO639_1, f as toISO639_3, h as workflows } from './index-C2FORyvQ.js';
2
+ import { W as WorkflowCredentials, S as StoragePutObjectInput, a as StoragePresignGetObjectInput } from './shots-CUI09Ohe.js';
3
+ 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 ScopedMuxAIOptions, g as StorageAdapter, T as TextChunk, h as TokenChunkingConfig, i as TokenUsage, j as ToneType, U as UsageMetadata, V as VTTChunkingConfig, k as VideoEmbeddingsResult, l as WorkflowCredentialsInput, m as WorkflowMuxClient, n as WorkflowScope, o as decryptFromWorkflow, p as encryptForWorkflow } from './shots-CUI09Ohe.js';
4
4
  import { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE } from '@workflow/serde';
5
- export { i as primitives } from './index-SjpXUdXl.js';
5
+ export { i as primitives } from './index-C2Pk7bbF.js';
6
6
  import 'zod';
7
7
  import '@ai-sdk/anthropic';
8
8
  import '@ai-sdk/google';
9
9
  import '@ai-sdk/openai';
10
10
  import '@mux/mux-node';
11
11
 
12
- var version = "0.35.0";
12
+ var version = "0.36.0";
13
13
 
14
14
  type MuxAiErrorType = "validation_error" | "processing_error" | "timeout_error" | "content_policy_error";
15
15
  /**
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.35.0";
8
+ var version = "0.36.0";
9
9
 
10
10
  // src/lib/language-codes.ts
11
11
  var ISO639_1_TO_3 = {
@@ -2534,9 +2534,12 @@ function toPlaybackAsset(asset) {
2534
2534
  const { id: playbackId, policy } = getPlaybackId(asset);
2535
2535
  return { asset, playbackId, policy };
2536
2536
  }
2537
- async function getPlaybackIdForAsset(assetId, credentials) {
2537
+ async function getPlaybackIdForAsset(assetId, credentials, assetSnapshot) {
2538
2538
  "use step";
2539
- const asset = await getMuxAsset(assetId, credentials);
2539
+ const asset = assetSnapshot ?? await getMuxAsset(assetId, credentials);
2540
+ if (asset.id !== assetId) {
2541
+ throw new MuxAiError("Asset snapshot does not match the requested asset ID.", { type: "validation_error" });
2542
+ }
2540
2543
  return toPlaybackAsset(asset);
2541
2544
  }
2542
2545
  async function getMuxAsset(assetId, credentials) {
@@ -3990,7 +3993,7 @@ async function askQuestionsInternal(assetId, questions, options, collectedUsage)
3990
3993
  model,
3991
3994
  provider
3992
3995
  });
3993
- const { asset: assetData, playbackId, policy } = await getPlaybackIdForAsset(assetId, credentials);
3996
+ const { asset: assetData, playbackId, policy } = await getPlaybackIdForAsset(assetId, credentials, options?.assetSnapshot);
3994
3997
  const assetDurationSeconds = getAssetDurationSecondsFromAsset(assetData);
3995
3998
  const isAudioOnly = isAudioOnlyAsset(assetData);
3996
3999
  const effectiveScope = hasWorkflowScopeBoundaries(scope) ? scope : void 0;
@@ -4344,7 +4347,7 @@ async function hasBurnedInCaptionsInternal(assetId, options, collectedUsage) {
4344
4347
  model,
4345
4348
  provider
4346
4349
  });
4347
- const { asset: assetData, playbackId, policy } = await getPlaybackIdForAsset(assetId, credentials);
4350
+ const { asset: assetData, playbackId, policy } = await getPlaybackIdForAsset(assetId, credentials, options.assetSnapshot);
4348
4351
  const assetDurationSeconds = getAssetDurationSecondsFromAsset(assetData);
4349
4352
  const storyboardScope = resolveRenderableVideoScope(
4350
4353
  scope,
@@ -4609,7 +4612,7 @@ async function generateChaptersInternal(assetId, options, collectedUsage) {
4609
4612
  model,
4610
4613
  provider
4611
4614
  });
4612
- const { asset: assetData, playbackId, policy } = await getPlaybackIdForAsset(assetId, credentials);
4615
+ const { asset: assetData, playbackId, policy } = await getPlaybackIdForAsset(assetId, credentials, options.assetSnapshot);
4613
4616
  const assetDurationSeconds = getAssetDurationSecondsFromAsset(assetData);
4614
4617
  const effectiveScope = hasWorkflowScopeBoundaries(scope) ? scope : void 0;
4615
4618
  const resolvedScope = effectiveScope ? resolveWorkflowScope(effectiveScope, assetDurationSeconds) : void 0;
@@ -5093,7 +5096,7 @@ async function editCaptionsInternal(assetId, trackId, options, collectedUsage) {
5093
5096
  { type: "validation_error" }
5094
5097
  );
5095
5098
  }
5096
- const { asset: assetData, playbackId, policy } = await getPlaybackIdForAsset(assetId, credentials);
5099
+ const { asset: assetData, playbackId, policy } = await getPlaybackIdForAsset(assetId, credentials, options.assetSnapshot);
5097
5100
  const assetDurationSeconds = getAssetDurationSecondsFromAsset(assetData);
5098
5101
  const signingContext = await resolveMuxSigningContext(credentials);
5099
5102
  if (policy === "signed" && !signingContext) {
@@ -5289,7 +5292,7 @@ async function generateEmbeddingsInternal(assetId, options, collectedUsage) {
5289
5292
  scope
5290
5293
  } = options;
5291
5294
  const embeddingModel = resolveEmbeddingModelConfig({ ...options, provider, model });
5292
- const { asset: assetData, playbackId, policy } = await getPlaybackIdForAsset(assetId, credentials);
5295
+ const { asset: assetData, playbackId, policy } = await getPlaybackIdForAsset(assetId, credentials, options.assetSnapshot);
5293
5296
  const assetDurationSeconds = getAssetDurationSecondsFromAsset(assetData);
5294
5297
  const effectiveScope = hasWorkflowScopeBoundaries(scope) ? scope : void 0;
5295
5298
  if (effectiveScope) {
@@ -5763,7 +5766,7 @@ async function generateEngagementInsightsInternal(assetId, options, collectedUsa
5763
5766
  model,
5764
5767
  provider
5765
5768
  });
5766
- const { asset, playbackId, policy } = await getPlaybackIdForAsset(assetId, credentials);
5769
+ const { asset, playbackId, policy } = await getPlaybackIdForAsset(assetId, credentials, options.assetSnapshot);
5767
5770
  const assetDurationSeconds = getAssetDurationSecondsFromAsset(asset);
5768
5771
  if (!assetDurationSeconds) {
5769
5772
  throw new MuxAiError(`Asset ${assetId} has no valid duration.`, { type: "validation_error" });
@@ -6480,7 +6483,7 @@ async function getModerationScores(assetId, options = {}) {
6480
6483
  scope
6481
6484
  } = options;
6482
6485
  const credentials = providedCredentials;
6483
- const { asset, playbackId, policy } = await getPlaybackIdForAsset(assetId, credentials);
6486
+ const { asset, playbackId, policy } = await getPlaybackIdForAsset(assetId, credentials, options.assetSnapshot);
6484
6487
  const videoTrackDurationSeconds = getVideoTrackDurationSecondsFromAsset(asset);
6485
6488
  const videoTrackFps = getVideoTrackMaxFrameRateFromAsset(asset);
6486
6489
  const assetDurationSeconds = getAssetDurationSecondsFromAsset(asset);
@@ -7094,7 +7097,7 @@ async function getSummaryAndTagsInternal(assetId, options, collectedUsage) {
7094
7097
  provider
7095
7098
  });
7096
7099
  const workflowCredentials = credentials;
7097
- const { asset: assetData, playbackId, policy } = await getPlaybackIdForAsset(assetId, workflowCredentials);
7100
+ const { asset: assetData, playbackId, policy } = await getPlaybackIdForAsset(assetId, workflowCredentials, options?.assetSnapshot);
7098
7101
  const assetDurationSeconds = getAssetDurationSecondsFromAsset(assetData);
7099
7102
  const isAudioOnly = isAudioOnlyAsset(assetData);
7100
7103
  const effectiveScope = hasWorkflowScopeBoundaries(scope) ? scope : void 0;
@@ -7541,7 +7544,7 @@ async function translateAudio(assetId, toLanguageCode, options = {}) {
7541
7544
  if (uploadToS3 && (!s3Endpoint || !s3Bucket || !effectiveStorageAdapter && (!s3AccessKeyId || !s3SecretAccessKey))) {
7542
7545
  throw new MuxAiError("Storage configuration is required for uploading. Provide s3Endpoint and s3Bucket. If no storageAdapter is supplied, also provide s3AccessKeyId and s3SecretAccessKey in options or set S3_ENDPOINT, S3_BUCKET, S3_ACCESS_KEY_ID, and S3_SECRET_ACCESS_KEY environment variables.", { type: "validation_error" });
7543
7546
  }
7544
- const { asset: initialAsset, playbackId, policy } = await getPlaybackIdForAsset(assetId, credentials);
7547
+ const { asset: initialAsset, playbackId, policy } = await getPlaybackIdForAsset(assetId, credentials, options.assetSnapshot);
7545
7548
  const assetDurationSeconds = getAssetDurationSecondsFromAsset(initialAsset);
7546
7549
  let currentAsset = initialAsset;
7547
7550
  let createdStaticRenditionId;
@@ -8411,7 +8414,7 @@ async function translateCaptionsInternal(assetId, trackId, toLanguageCode, optio
8411
8414
  if (uploadToS3 && (!s3Endpoint || !s3Bucket || !effectiveStorageAdapter && (!s3AccessKeyId || !s3SecretAccessKey))) {
8412
8415
  throw new MuxAiError("Storage configuration is required for uploading. Provide s3Endpoint and s3Bucket. If no storageAdapter is supplied, also provide s3AccessKeyId and s3SecretAccessKey in options or set S3_ENDPOINT, S3_BUCKET, S3_ACCESS_KEY_ID, and S3_SECRET_ACCESS_KEY environment variables.", { type: "validation_error" });
8413
8416
  }
8414
- const { asset: assetData, playbackId, policy } = await getPlaybackIdForAsset(assetId, credentials);
8417
+ const { asset: assetData, playbackId, policy } = await getPlaybackIdForAsset(assetId, credentials, options.assetSnapshot);
8415
8418
  const assetDurationSeconds = getAssetDurationSecondsFromAsset(assetData);
8416
8419
  const signingContext = await resolveMuxSigningContext(credentials);
8417
8420
  if (policy === "signed" && !signingContext) {