@mux/ai 0.44.0 → 0.45.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.
@@ -3,7 +3,7 @@ import { S as SafetyReport, e as PromptOverrides, h as SceneContextItemV1, D as
3
3
  import { createAnthropic } from '@ai-sdk/anthropic';
4
4
  import { createGoogleGenerativeAI } from '@ai-sdk/google';
5
5
  import { createOpenAI } from '@ai-sdk/openai';
6
- import { l as WorkflowCredentialsInput, d as MuxAsset, A as AssetTextTrack, 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
+ import { l as WorkflowCredentialsInput, d as MuxAsset, A as AssetTextTrack, 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-B7G0IIF1.js';
7
7
 
8
8
  /**
9
9
  * 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-CUI09Ohe.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-B7G0IIF1.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,8 +1,8 @@
1
- export { I as ISO639_1, a as ISO639_3, L as LanguageCodePair, M as MUX_TRACK_PASSTHROUGH_MAX_CHARS, R as ReplaceAndCreateTextTrackInput, b as ReplaceAndCreateTextTrackResult, c as ReplaceAndCreateTrackInput, d as ReplaceExistingTracksPolicy, e as ReplaceableTrackType, S as SupportedISO639_1, f as SupportedISO639_3, T as TextTrackReplacementPlan, g as TextTrackSummary, h as TextTrackTarget, i as TrackSummary, j as TrackTarget, k as buildMuxAiTrackPassthrough, l as findNameCollisionTextTracks, m as findSameLanguageTextTracks, n as getLanguageCodePair, o as getLanguageName, p as isDuplicateTrackNameError, q as isMuxGeneratedTextTrack, r as isUndeterminedLanguageCode, s as isValidISO639_1, t as isValidISO639_3, u as normalizeTrackLanguageCode, v as normalizeTrackName, w as planTextTrackReplacement, x as replaceAndCreateTextTrack, y as replaceAndCreateTrack, z as summarizeTextTrack, A as toISO639_1, B as toISO639_3, C as validateTrackPassthrough, D as workflows } from './index-DigKByh7.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';
1
+ export { I as ISO639_1, a as ISO639_3, L as LanguageCodePair, M as MUX_TRACK_PASSTHROUGH_MAX_CHARS, R as ReplaceAndCreateTextTrackInput, b as ReplaceAndCreateTextTrackResult, c as ReplaceAndCreateTrackInput, d as ReplaceExistingTracksPolicy, e as ReplaceableTrackType, S as SupportedISO639_1, f as SupportedISO639_3, T as TextTrackReplacementPlan, g as TextTrackSummary, h as TextTrackTarget, i as TrackSummary, j as TrackTarget, k as buildMuxAiTrackPassthrough, l as findNameCollisionTextTracks, m as findSameLanguageTextTracks, n as getLanguageCodePair, o as getLanguageName, p as isDuplicateTrackNameError, q as isMuxGeneratedTextTrack, r as isUndeterminedLanguageCode, s as isValidISO639_1, t as isValidISO639_3, u as normalizeTrackLanguageCode, v as normalizeTrackName, w as planTextTrackReplacement, x as replaceAndCreateTextTrack, y as replaceAndCreateTrack, z as summarizeTextTrack, A as toISO639_1, B as toISO639_3, C as validateTrackPassthrough, D as workflows } from './index-BD4acrwt.js';
2
+ import { W as WorkflowCredentials, S as StoragePutObjectInput, a as StoragePresignGetObjectInput } from './shots-B7G0IIF1.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-B7G0IIF1.js';
4
4
  import { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE } from '@workflow/serde';
5
- export { i as primitives } from './index-C2Pk7bbF.js';
5
+ export { i as primitives } from './index-D6VGaoPm.js';
6
6
  import 'zod';
7
7
  import './summarization-BFmhXeAu.js';
8
8
  import '@ai-sdk/anthropic';
@@ -10,7 +10,7 @@ import '@ai-sdk/google';
10
10
  import '@ai-sdk/openai';
11
11
  import '@mux/mux-node';
12
12
 
13
- var version = "0.44.0";
13
+ var version = "0.45.0";
14
14
 
15
15
  type MuxAiErrorType = "validation_error" | "processing_error" | "timeout_error" | "content_policy_error";
16
16
  /**
@@ -43,6 +43,13 @@ declare class MuxAiError extends Error {
43
43
  }
44
44
  declare function wrapError(error: unknown, message: string): never;
45
45
 
46
+ type MuxPlaybackService = "image" | "stream";
47
+ /**
48
+ * Builds the playback origin for a Mux domain, matching Mux Player's `customDomain`
49
+ * expansion (e.g. "media.example.com" becomes "https://image.media.example.com").
50
+ */
51
+ declare function getMuxPlaybackOrigin(service: MuxPlaybackService, customDomain?: string): string;
52
+
46
53
  /**
47
54
  * A function that returns workflow credentials, either synchronously or asynchronously.
48
55
  * Used to inject credentials from external sources (e.g., a secrets manager).
@@ -77,4 +84,4 @@ declare class WorkflowStorageClient {
77
84
  }
78
85
  declare function createWorkflowStorageClient(options?: WorkflowStorageClientOptions): WorkflowStorageClient;
79
86
 
80
- export { MuxAiError, type MuxAiErrorType, StoragePresignGetObjectInput, StoragePutObjectInput, WorkflowCredentials, type WorkflowCredentialsProvider, WorkflowStorageClient, createWorkflowStorageClient, setWorkflowCredentialsProvider, version, wrapError };
87
+ export { MuxAiError, type MuxAiErrorType, type MuxPlaybackService, StoragePresignGetObjectInput, StoragePutObjectInput, WorkflowCredentials, type WorkflowCredentialsProvider, WorkflowStorageClient, createWorkflowStorageClient, getMuxPlaybackOrigin, setWorkflowCredentialsProvider, version, wrapError };
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.44.0";
8
+ var version = "0.45.0";
9
9
 
10
10
  // src/lib/language-codes.ts
11
11
  var ISO639_1_TO_3 = {
@@ -204,12 +204,16 @@ var EnvSchema = z.object({
204
204
  ),
205
205
  MUX_SIGNING_KEY: optionalString("Mux signing key ID for signed playback URLs.", "Used to sign playback URLs"),
206
206
  MUX_PRIVATE_KEY: optionalString("Mux signing private key for signed playback URLs.", "Used to sign playback URLs"),
207
+ MUX_CUSTOM_DOMAIN: optionalString(
208
+ "Mux domain for image.* and stream.* playback URLs, e.g. staging.mux.com or a custom domain (defaults to mux.com).",
209
+ "Mux custom domain"
210
+ ),
207
211
  MUX_IMAGE_URL_OVERRIDE: optionalString(
208
- "Override for Mux image base URL (defaults to https://image.mux.com).",
212
+ "Deprecated: use MUX_CUSTOM_DOMAIN. Override for Mux image base URL (defaults to https://image.mux.com).",
209
213
  "Mux image URL override"
210
214
  ),
211
215
  MUX_STREAM_URL_OVERRIDE: optionalString(
212
- "Override for Mux stream base URL (defaults to https://stream.mux.com).",
216
+ "Deprecated: use MUX_CUSTOM_DOMAIN. Override for Mux stream base URL (defaults to https://stream.mux.com).",
213
217
  "Mux stream URL override"
214
218
  ),
215
219
  MUX_BASE_URL: optionalString(
@@ -328,7 +332,18 @@ function parseEnv() {
328
332
  }
329
333
  return parsedEnv.data;
330
334
  }
335
+ var hasWarnedAboutDeprecatedUrlOverrides = false;
336
+ function warnOnDeprecatedUrlOverrides(parsed) {
337
+ if (hasWarnedAboutDeprecatedUrlOverrides || !parsed.MUX_IMAGE_URL_OVERRIDE && !parsed.MUX_STREAM_URL_OVERRIDE) {
338
+ return;
339
+ }
340
+ hasWarnedAboutDeprecatedUrlOverrides = true;
341
+ console.warn(
342
+ "MUX_IMAGE_URL_OVERRIDE and MUX_STREAM_URL_OVERRIDE are deprecated and will be removed in a future release. Set MUX_CUSTOM_DOMAIN instead (e.g. MUX_CUSTOM_DOMAIN=staging.mux.com for image.staging.mux.com and stream.staging.mux.com)."
343
+ );
344
+ }
331
345
  var env = parseEnv();
346
+ warnOnDeprecatedUrlOverrides(env);
332
347
  var env_default = env;
333
348
 
334
349
  // src/lib/prompt-fragments.ts
@@ -1354,6 +1369,82 @@ async function replaceAndCreateTextTrack(input) {
1354
1369
  return replaceAndCreateTrack({ ...input, target: { ...input.target, type: "text" } });
1355
1370
  }
1356
1371
 
1372
+ // src/lib/mux-url.ts
1373
+ var DEFAULT_MUX_DOMAIN = "mux.com";
1374
+ function normalizeOrigin(value, envVarName) {
1375
+ const trimmed = value.trim();
1376
+ const candidate = trimmed.includes("://") ? trimmed : `https://${trimmed}`;
1377
+ const exampleHostname = envVarName === "MUX_IMAGE_URL_OVERRIDE" ? "image.example.mux.com" : "stream.example.mux.com";
1378
+ let parsed;
1379
+ try {
1380
+ parsed = new URL(candidate);
1381
+ } catch {
1382
+ throw new Error(
1383
+ `Invalid ${envVarName}. Provide a hostname (e.g. "${exampleHostname}") or a URL origin (e.g. "https://${exampleHostname}").`
1384
+ );
1385
+ }
1386
+ if (parsed.username || parsed.password || parsed.search || parsed.hash || parsed.pathname && parsed.pathname !== "/") {
1387
+ throw new Error(
1388
+ `Invalid ${envVarName}. Only a hostname/origin is allowed (no credentials, query params, hash fragments, or path).`
1389
+ );
1390
+ }
1391
+ return parsed.origin;
1392
+ }
1393
+ function buildPlaybackOrigin(service, customDomain, source) {
1394
+ const invalidDomainError = new Error(
1395
+ `Invalid ${source}. Provide a bare hostname (e.g. "media.example.com") with no scheme, port, credentials, query params, hash fragments, or path.`
1396
+ );
1397
+ const trimmed = customDomain.trim();
1398
+ if (!trimmed) {
1399
+ throw invalidDomainError;
1400
+ }
1401
+ let parsed;
1402
+ try {
1403
+ parsed = new URL(`https://${service}.${trimmed}`);
1404
+ } catch {
1405
+ throw invalidDomainError;
1406
+ }
1407
+ if (parsed.port || parsed.username || parsed.password || parsed.search || parsed.hash || parsed.pathname !== "/") {
1408
+ throw invalidDomainError;
1409
+ }
1410
+ return parsed.origin;
1411
+ }
1412
+ function getMuxPlaybackOrigin(service, customDomain = DEFAULT_MUX_DOMAIN) {
1413
+ return buildPlaybackOrigin(service, customDomain, "custom domain");
1414
+ }
1415
+ async function resolveMuxPlaybackOrigin(service, credentials) {
1416
+ "use step";
1417
+ const { muxCustomDomain } = await resolveWorkflowCredentials(credentials);
1418
+ if (muxCustomDomain) {
1419
+ return buildPlaybackOrigin(service, muxCustomDomain, "muxCustomDomain");
1420
+ }
1421
+ const legacyOverrideEnvVarName = service === "image" ? "MUX_IMAGE_URL_OVERRIDE" : "MUX_STREAM_URL_OVERRIDE";
1422
+ const legacyOverride = env_default[legacyOverrideEnvVarName];
1423
+ if (legacyOverride) {
1424
+ return normalizeOrigin(legacyOverride, legacyOverrideEnvVarName);
1425
+ }
1426
+ if (env_default.MUX_CUSTOM_DOMAIN) {
1427
+ return buildPlaybackOrigin(service, env_default.MUX_CUSTOM_DOMAIN, "MUX_CUSTOM_DOMAIN");
1428
+ }
1429
+ return buildPlaybackOrigin(service, DEFAULT_MUX_DOMAIN, "custom domain");
1430
+ }
1431
+ async function getMuxImageOrigin(credentials) {
1432
+ return resolveMuxPlaybackOrigin("image", credentials);
1433
+ }
1434
+ async function getMuxStreamOrigin(credentials) {
1435
+ return resolveMuxPlaybackOrigin("stream", credentials);
1436
+ }
1437
+ async function getMuxImageBaseUrl(playbackId, assetType, credentials) {
1438
+ const origin = await getMuxImageOrigin(credentials);
1439
+ return `${origin}/${playbackId}/${assetType}.png`;
1440
+ }
1441
+ async function getMuxStoryboardBaseUrl(playbackId, credentials) {
1442
+ return getMuxImageBaseUrl(playbackId, "storyboard", credentials);
1443
+ }
1444
+ async function getMuxThumbnailBaseUrl(playbackId, credentials) {
1445
+ return getMuxImageBaseUrl(playbackId, "thumbnail", credentials);
1446
+ }
1447
+
1357
1448
  // node_modules/@workflow/serde/dist/index.js
1358
1449
  var WORKFLOW_SERIALIZE = /* @__PURE__ */ Symbol.for("workflow-serialize");
1359
1450
  var WORKFLOW_DESERIALIZE = /* @__PURE__ */ Symbol.for("workflow-deserialize");
@@ -2309,53 +2400,6 @@ async function waitForShotsForAsset(assetId, options = {}) {
2309
2400
  );
2310
2401
  }
2311
2402
 
2312
- // src/lib/mux-url.ts
2313
- var DEFAULT_MUX_IMAGE_ORIGIN = "https://image.mux.com";
2314
- var DEFAULT_MUX_STREAM_ORIGIN = "https://stream.mux.com";
2315
- function normalizeOrigin(value, envVarName) {
2316
- const trimmed = value.trim();
2317
- const candidate = trimmed.includes("://") ? trimmed : `https://${trimmed}`;
2318
- const exampleHostname = envVarName === "MUX_IMAGE_URL_OVERRIDE" ? "image.example.mux.com" : "stream.example.mux.com";
2319
- let parsed;
2320
- try {
2321
- parsed = new URL(candidate);
2322
- } catch {
2323
- throw new Error(
2324
- `Invalid ${envVarName}. Provide a hostname (e.g. "${exampleHostname}") or a URL origin (e.g. "https://${exampleHostname}").`
2325
- );
2326
- }
2327
- if (parsed.username || parsed.password || parsed.search || parsed.hash || parsed.pathname && parsed.pathname !== "/") {
2328
- throw new Error(
2329
- `Invalid ${envVarName}. Only a hostname/origin is allowed (no credentials, query params, hash fragments, or path).`
2330
- );
2331
- }
2332
- return parsed.origin;
2333
- }
2334
- function getMuxImageOrigin() {
2335
- const override = env_default.MUX_IMAGE_URL_OVERRIDE;
2336
- if (!override) {
2337
- return DEFAULT_MUX_IMAGE_ORIGIN;
2338
- }
2339
- return normalizeOrigin(override, "MUX_IMAGE_URL_OVERRIDE");
2340
- }
2341
- function getMuxStreamOrigin() {
2342
- const override = env_default.MUX_STREAM_URL_OVERRIDE;
2343
- if (!override) {
2344
- return DEFAULT_MUX_STREAM_ORIGIN;
2345
- }
2346
- return normalizeOrigin(override, "MUX_STREAM_URL_OVERRIDE");
2347
- }
2348
- function getMuxImageBaseUrl(playbackId, assetType) {
2349
- const origin = getMuxImageOrigin();
2350
- return `${origin}/${playbackId}/${assetType}.png`;
2351
- }
2352
- function getMuxStoryboardBaseUrl(playbackId) {
2353
- return getMuxImageBaseUrl(playbackId, "storyboard");
2354
- }
2355
- function getMuxThumbnailBaseUrl(playbackId) {
2356
- return getMuxImageBaseUrl(playbackId, "thumbnail");
2357
- }
2358
-
2359
2403
  // src/lib/url-signing.ts
2360
2404
  async function createSigningClient(context) {
2361
2405
  const { default: MuxClient } = await import("@mux/mux-node");
@@ -2397,7 +2441,7 @@ async function signUrl(url, playbackId, type = "video", params, credentials) {
2397
2441
  var DEFAULT_STORYBOARD_WIDTH = 640;
2398
2442
  async function getStoryboardUrl(playbackId, width = DEFAULT_STORYBOARD_WIDTH, shouldSign = false, credentials, scope) {
2399
2443
  "use step";
2400
- const baseUrl = getMuxStoryboardBaseUrl(playbackId);
2444
+ const baseUrl = await getMuxStoryboardBaseUrl(playbackId, credentials);
2401
2445
  const params = { width };
2402
2446
  if (scope?.startTime !== void 0) {
2403
2447
  params.asset_start_time = scope.startTime;
@@ -2746,7 +2790,7 @@ async function getThumbnailUrls(playbackId, duration, options = {}) {
2746
2790
  }
2747
2791
  timestamps = newTimestamps;
2748
2792
  }
2749
- const baseUrl = getMuxThumbnailBaseUrl(playbackId);
2793
+ const baseUrl = await getMuxThumbnailBaseUrl(playbackId, credentials);
2750
2794
  const urlPromises = timestamps.map(async (time) => {
2751
2795
  const url = shouldSign ? await signUrl(baseUrl, playbackId, "thumbnail", { time, width }, credentials) : `${baseUrl}?time=${time}&width=${width}`;
2752
2796
  return { url, time };
@@ -3189,7 +3233,7 @@ function concatenateVttSegments(segments, preamble = "WEBVTT") {
3189
3233
  }
3190
3234
  async function buildTranscriptUrl(playbackId, trackId, shouldSign = false, credentials) {
3191
3235
  "use step";
3192
- const baseUrl = `${getMuxStreamOrigin()}/${playbackId}/text/${trackId}.vtt`;
3236
+ const baseUrl = `${await getMuxStreamOrigin(credentials)}/${playbackId}/text/${trackId}.vtt`;
3193
3237
  if (shouldSign) {
3194
3238
  return signUrl(baseUrl, playbackId, "video", void 0, credentials);
3195
3239
  }
@@ -6115,7 +6159,7 @@ function mapShotsToHotspots(shots, hotspots) {
6115
6159
  }
6116
6160
  async function getThumbnailUrlsForHotspots(playbackId, hotspots, options = {}) {
6117
6161
  const { width = 640, shouldSign = false, credentials } = options;
6118
- const baseUrl = getMuxThumbnailBaseUrl(playbackId);
6162
+ const baseUrl = await getMuxThumbnailBaseUrl(playbackId, credentials);
6119
6163
  const urlPromises = hotspots.map(async (h) => {
6120
6164
  const time = Math.floor(h.startMs / 1e3);
6121
6165
  if (shouldSign) {
@@ -7639,7 +7683,7 @@ function filterTimestampsWithinExclusiveScope(timestampsMs, scope) {
7639
7683
  async function getThumbnailUrlsFromTimestamps(playbackId, timestampsMs, options) {
7640
7684
  "use step";
7641
7685
  const { width, shouldSign, credentials } = options;
7642
- const baseUrl = getMuxThumbnailBaseUrl(playbackId);
7686
+ const baseUrl = await getMuxThumbnailBaseUrl(playbackId, credentials);
7643
7687
  const times = [...new Set(timestampsMs.map(toThumbnailTimeSeconds))];
7644
7688
  const urlPromises = times.map(async (time) => {
7645
7689
  const url = shouldSign ? await signUrl(baseUrl, playbackId, "thumbnail", { time, width }, credentials) : `${baseUrl}?time=${time}&width=${width}`;
@@ -8823,7 +8867,7 @@ async function translateAudio(assetId, toLanguageCode, options = {}) {
8823
8867
  { type: "validation_error" }
8824
8868
  );
8825
8869
  }
8826
- let audioUrl = `${getMuxStreamOrigin()}/${playbackId}/audio.m4a`;
8870
+ let audioUrl = `${await getMuxStreamOrigin(credentials)}/${playbackId}/audio.m4a`;
8827
8871
  if (policy === "signed") {
8828
8872
  audioUrl = await signUrl(audioUrl, playbackId, "video", void 0, credentials);
8829
8873
  }
@@ -9848,6 +9892,7 @@ export {
9848
9892
  findSameLanguageTextTracks,
9849
9893
  getLanguageCodePair,
9850
9894
  getLanguageName,
9895
+ getMuxPlaybackOrigin,
9851
9896
  isDuplicateTrackNameError,
9852
9897
  isMuxGeneratedTextTrack,
9853
9898
  isUndeterminedLanguageCode,