@mux/ai 0.65.0 → 0.66.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.
@@ -1,4 +1,4 @@
1
- export { D as DEFAULT_STORYBOARD_WIDTH, H as HeatmapOptions, a as HeatmapResponse, T as ThumbnailOptions, V as VTTCueBudgetChunkingOptions, b as VTTDurationChunk, c as VTTDurationChunkingOptions, d as chunkByTokens, e as chunkText, f as chunkVTTCues, g as chunkVTTCuesByBudget, h as chunkVTTCuesByDuration, j as estimateTokenCount, k as getHeatmapForAsset, l as getHeatmapForPlaybackId, m as getHeatmapForVideo, n as getStoryboardUrl, o as getThumbnailUrls } from '../index-DtZUwuCb.js';
2
- export { a6 as CompletedShotsResult, a7 as DeletedShotsResult, a8 as ErroredShotsResult, a9 as Hotspot, aa as HotspotOptions, ab as HotspotResponse, ac as LOW_CONFIDENCE_THRESHOLD, ad as MAX_CUE_TEXT_CHARS, ae as ParseVTTCuesOptions, af as PendingShotsResult, ag as Shot, ah as ShotRequestOptions, ai as ShotsResult, aj as SkippedShotsResult, ak as TranscriptEmptyReason, al as TranscriptFetchOptions, am as TranscriptFetchStepResult, an as TranscriptResult, a5 as VTTCue, ao as WaitForShotsOptions, ap as buildTranscriptUrl, aq as buildVttFromCueBlocks, ar as buildVttFromTranslatedCueBlocks, as as concatenateVttSegments, at as extractTextFromVTT, au as extractTimestampedTranscript, av as fetchTranscriptDataForUrl, aw as fetchTranscriptForAsset, ax as filterVttByScope, ay as findCaptionTrack, az as getHotspotsForAsset, aA as getHotspotsForPlaybackId, aB as getHotspotsForVideo, aC as getReadyTextTracks, aD as getReliableLanguageCode, aE as getShotsForAsset, aF as parseVTTCues, aG as replaceCueText, aH as requestShotsForAsset, aI as sanitizeUntrustedText, aJ as secondsToTimestamp, aK as splitVttPreambleAndCueBlocks, aL as stripVttMetadataBlocks, aM as vttTimestampToSeconds, aN as waitForShotsForAsset } from '../transcripts-qZm-RokR.js';
1
+ export { D as DEFAULT_STORYBOARD_WIDTH, H as HeatmapOptions, a as HeatmapResponse, T as ThumbnailOptions, V as VTTCueBudgetChunkingOptions, b as VTTDurationChunk, c as VTTDurationChunkingOptions, d as chunkByTokens, e as chunkText, f as chunkVTTCues, g as chunkVTTCuesByBudget, h as chunkVTTCuesByDuration, j as estimateTokenCount, k as getHeatmapForAsset, l as getHeatmapForPlaybackId, m as getHeatmapForVideo, n as getStoryboardUrl, o as getThumbnailUrls } from '../index-D_kEPGJj.js';
2
+ export { ab as CompletedShotsResult, ac as DeletedShotsResult, ad as ErroredShotsResult, ae as Hotspot, af as HotspotOptions, ag as HotspotResponse, ah as LOW_CONFIDENCE_THRESHOLD, ai as MAX_CUE_TEXT_CHARS, aj as ParseVTTCuesOptions, ak as PendingShotsResult, al as Shot, am as ShotRequestOptions, an as ShotsResult, ao as SkippedShotsResult, ap as TranscriptEmptyReason, aq as TranscriptFetchOptions, ar as TranscriptFetchStepResult, as as TranscriptResult, aa as VTTCue, at as WaitForShotsOptions, au as buildTranscriptUrl, av as buildVttFromCueBlocks, aw as buildVttFromTranslatedCueBlocks, ax as concatenateVttSegments, ay as extractTextFromVTT, az as extractTimestampedTranscript, aA as fetchTranscriptDataForUrl, aB as fetchTranscriptForAsset, aC as filterVttByScope, aD as findCaptionTrack, aE as getHotspotsForAsset, aF as getHotspotsForPlaybackId, aG as getHotspotsForVideo, aH as getReadyTextTracks, aI as getReliableLanguageCode, aJ as getShotsForAsset, aK as parseVTTCues, aL as replaceCueText, aM as requestShotsForAsset, aN as sanitizeUntrustedText, aO as secondsToTimestamp, aP as splitVttPreambleAndCueBlocks, aQ as stripVttMetadataBlocks, aR as vttTimestampToSeconds, aS as waitForShotsForAsset } from '../transcripts-DYpx6Mac.js';
3
3
  import '@workflow/serde';
4
4
  import '@mux/ts';
@@ -1029,7 +1029,49 @@ var MUX_AI_ERROR_CODES = {
1029
1029
  /** The asset's static rendition settings changed while waiting for its rendition. A new job uses the new settings. Facts: `assetId`. */
1030
1030
  STATIC_RENDITION_CHANGED: "static_rendition_changed",
1031
1031
  /** Mux didn't finish the static rendition within the polling budget. Facts: `assetId`, `attempts`, `pollIntervalMs`, `lastStatus`. */
1032
- STATIC_RENDITION_TIMEOUT: "static_rendition_timeout"
1032
+ STATIC_RENDITION_TIMEOUT: "static_rendition_timeout",
1033
+ /**
1034
+ * The provider says the account the service running the SDK uses is out of credits or
1035
+ * quota, or hit a spend or usage limit. Retrying won't help until someone changes the
1036
+ * account. The site names the dependency. Facts: `call`, `status`, `providerCode`.
1037
+ */
1038
+ PROVIDER_QUOTA_EXHAUSTED: "provider_quota_exhausted",
1039
+ /** The provider rejected the key the service running the SDK uses, or the key lacks permission for this model or feature. The site names the dependency. Facts: `call`, `status`, `providerCode`. */
1040
+ PROVIDER_CREDENTIALS_REJECTED: "provider_credentials_rejected",
1041
+ /** The provider says requests are over its rate or concurrency limit. The site names the dependency. Facts: `call`, `status`, `providerCode`. */
1042
+ PROVIDER_RATE_LIMITED: "provider_rate_limited",
1043
+ /** The provider says it's overloaded or down for maintenance. The site names the dependency. Facts: `call`, `status`, `providerCode`. */
1044
+ PROVIDER_UNAVAILABLE: "provider_unavailable",
1045
+ /** The provider can't process the asset's audio. The site names the dependency. Facts: `call`, `status`, `providerCode`, `reason` (`corrupt`, `unsupported_format`, `too_long`, `too_short`). */
1046
+ AUDIO_UNPROCESSABLE: "audio_unprocessable",
1047
+ /** Mux rejected the caller's access token (401), or the token lacks permission for this call (403), e.g. Mux Data access. Facts: `call`, `status`, `inputs` (`credentials`). */
1048
+ ACCOUNT_CREDENTIALS_REJECTED: "account_credentials_rejected",
1049
+ /** Mux answered 404 for something belonging to the asset (a track, a rendition, an image, its engagement data): gone, or not ready yet. A missing asset itself is `asset_not_found`. Facts: `call`, `status`. */
1050
+ ASSET_RESOURCE_NOT_FOUND: "asset_resource_not_found",
1051
+ /** Mux denied delivery of the asset's media (a transcript, a caption file, an image), e.g. a signing key or playback restriction in the Mux account rejected the request. Facts: `call`, `status`. */
1052
+ PLAYBACK_ACCESS_DENIED: "playback_access_denied",
1053
+ // Fallback codes (see MUX_AI_DEPENDENCY_STATUS_CODES): what a remote call's failure looked
1054
+ // like, when no per-dependency rule recognized it. The site names the dependency.
1055
+ /** No response arrived, and the call didn't time out (e.g. a connection failure). Facts: `call`. */
1056
+ DEPENDENCY_NO_RESPONSE: "dependency_no_response",
1057
+ /** The call timed out, or the dependency answered 408. Facts: `call`, `status`. */
1058
+ DEPENDENCY_TIMEOUT: "dependency_timeout",
1059
+ /** The dependency answered 429. Facts: `call`, `status`. */
1060
+ DEPENDENCY_RATE_LIMITED: "dependency_rate_limited",
1061
+ /** The dependency answered 425. Facts: `call`, `status`. */
1062
+ DEPENDENCY_TOO_EARLY: "dependency_too_early",
1063
+ /** The dependency answered with a 5xx status. Facts: `call`, `status`. */
1064
+ DEPENDENCY_SERVER_ERROR: "dependency_server_error",
1065
+ /** The dependency answered 401 or 403 to a request made with the service's own credentials. Facts: `call`, `status`. */
1066
+ DEPENDENCY_AUTH_REJECTED: "dependency_auth_rejected",
1067
+ /** The dependency answered 404 to a request the SDK built. Facts: `call`, `status`. */
1068
+ DEPENDENCY_NOT_FOUND: "dependency_not_found",
1069
+ /** The dependency answered with another 4xx status. Facts: `call`, `status`. */
1070
+ DEPENDENCY_REQUEST_REJECTED: "dependency_request_rejected",
1071
+ /** The dependency answered with a status that isn't an error (1xx-3xx) where a result was expected. Facts: `call`, `status`. */
1072
+ DEPENDENCY_OTHER_STATUS: "dependency_other_status",
1073
+ /** The dependency answered without a failing status, but with an error of its own or a response that can't be used. Facts: `call`, `providerCode` when it gave one. */
1074
+ DEPENDENCY_RESPONSE_FAILED: "dependency_response_failed"
1033
1075
  };
1034
1076
  var MUX_AI_ERROR_CODE_VALUES = Object.values(MUX_AI_ERROR_CODES);
1035
1077
  var MUX_AI_ERROR_CATALOG = {
@@ -1087,7 +1129,39 @@ var MUX_AI_ERROR_CATALOG = {
1087
1129
  [MUX_AI_ERROR_CODES.AUDIO_TRACK_MISSING]: { type: MUX_AI_ERROR_TYPES.VALIDATION_ERROR, source: MUX_AI_ERROR_SOURCES.ASSET },
1088
1130
  [MUX_AI_ERROR_CODES.PRIMARY_AUDIO_TRACK_CONFLICT]: { type: MUX_AI_ERROR_TYPES.VALIDATION_ERROR, source: MUX_AI_ERROR_SOURCES.ASSET },
1089
1131
  // Retryable although asset-sourced: the asset changed mid-run, and a new job uses the new settings.
1090
- [MUX_AI_ERROR_CODES.STATIC_RENDITION_CHANGED]: { type: MUX_AI_ERROR_TYPES.PROCESSING_ERROR, source: MUX_AI_ERROR_SOURCES.ASSET, retryable: true }
1132
+ [MUX_AI_ERROR_CODES.STATIC_RENDITION_CHANGED]: { type: MUX_AI_ERROR_TYPES.PROCESSING_ERROR, source: MUX_AI_ERROR_SOURCES.ASSET, retryable: true },
1133
+ // Conditions a remote service reports in its own terms (see the per-dependency modules,
1134
+ // e.g. elevenlabs-errors.ts), so the code holds whichever dependency the site names.
1135
+ // A provider's key and quota are the configuration of the service running the SDK, like
1136
+ // its signing keys and storage: `internal`. (`account` is the caller's Mux account.)
1137
+ // Neither step-retried nor resubmittable: the provider says retrying won't restore access.
1138
+ [MUX_AI_ERROR_CODES.PROVIDER_QUOTA_EXHAUSTED]: { type: MUX_AI_ERROR_TYPES.SERVER_ERROR, source: MUX_AI_ERROR_SOURCES.INTERNAL, siteDependency: true, transient: false, retryable: false },
1139
+ [MUX_AI_ERROR_CODES.PROVIDER_CREDENTIALS_REJECTED]: { type: MUX_AI_ERROR_TYPES.SERVER_ERROR, source: MUX_AI_ERROR_SOURCES.INTERNAL, siteDependency: true },
1140
+ [MUX_AI_ERROR_CODES.PROVIDER_RATE_LIMITED]: { type: MUX_AI_ERROR_TYPES.CAPACITY_ERROR, source: MUX_AI_ERROR_SOURCES.UPSTREAM, siteDependency: true, transient: true, retryable: true },
1141
+ [MUX_AI_ERROR_CODES.PROVIDER_UNAVAILABLE]: { type: MUX_AI_ERROR_TYPES.CAPACITY_ERROR, source: MUX_AI_ERROR_SOURCES.UPSTREAM, siteDependency: true, transient: true, retryable: true },
1142
+ [MUX_AI_ERROR_CODES.AUDIO_UNPROCESSABLE]: { type: MUX_AI_ERROR_TYPES.VALIDATION_ERROR, source: MUX_AI_ERROR_SOURCES.ASSET, siteDependency: true },
1143
+ // Mux's own responses, where the call says whose they are (see mux-video-errors.ts).
1144
+ // The access token is the caller's: only its permissions decide what Mux allows.
1145
+ [MUX_AI_ERROR_CODES.ACCOUNT_CREDENTIALS_REJECTED]: { type: MUX_AI_ERROR_TYPES.VALIDATION_ERROR, source: MUX_AI_ERROR_SOURCES.ACCOUNT, siteDependency: true },
1146
+ [MUX_AI_ERROR_CODES.ASSET_RESOURCE_NOT_FOUND]: { type: MUX_AI_ERROR_TYPES.VALIDATION_ERROR, source: MUX_AI_ERROR_SOURCES.ASSET, siteDependency: true },
1147
+ // Media requests carry no access token. Mux denies them for an expired signed token or a
1148
+ // playback restriction; the SDK signs fresh tokens, so it's the account's keys or restrictions.
1149
+ [MUX_AI_ERROR_CODES.PLAYBACK_ACCESS_DENIED]: { type: MUX_AI_ERROR_TYPES.VALIDATION_ERROR, source: MUX_AI_ERROR_SOURCES.ACCOUNT, siteDependency: true },
1150
+ // Fallback codes: each implies the classification the status rules give it
1151
+ // (`classifyDependencyFailure` with its default sources). A site that knows more raises
1152
+ // a more specific code instead. Transient ones are step-retried unless the call isn't
1153
+ // idempotent (see `dependencyError`).
1154
+ [MUX_AI_ERROR_CODES.DEPENDENCY_NO_RESPONSE]: { type: MUX_AI_ERROR_TYPES.PROCESSING_ERROR, source: MUX_AI_ERROR_SOURCES.UPSTREAM, siteDependency: true, transient: true, retryable: true },
1155
+ [MUX_AI_ERROR_CODES.DEPENDENCY_TIMEOUT]: { type: MUX_AI_ERROR_TYPES.TIMEOUT_ERROR, source: MUX_AI_ERROR_SOURCES.UPSTREAM, siteDependency: true, transient: true, retryable: true },
1156
+ [MUX_AI_ERROR_CODES.DEPENDENCY_RATE_LIMITED]: { type: MUX_AI_ERROR_TYPES.CAPACITY_ERROR, source: MUX_AI_ERROR_SOURCES.UPSTREAM, siteDependency: true, transient: true, retryable: true },
1157
+ [MUX_AI_ERROR_CODES.DEPENDENCY_TOO_EARLY]: { type: MUX_AI_ERROR_TYPES.PROCESSING_ERROR, source: MUX_AI_ERROR_SOURCES.UPSTREAM, siteDependency: true, transient: true, retryable: true },
1158
+ [MUX_AI_ERROR_CODES.DEPENDENCY_SERVER_ERROR]: { type: MUX_AI_ERROR_TYPES.PROCESSING_ERROR, source: MUX_AI_ERROR_SOURCES.UPSTREAM, siteDependency: true, transient: true, retryable: true },
1159
+ [MUX_AI_ERROR_CODES.DEPENDENCY_AUTH_REJECTED]: { type: MUX_AI_ERROR_TYPES.SERVER_ERROR, source: MUX_AI_ERROR_SOURCES.INTERNAL, siteDependency: true },
1160
+ [MUX_AI_ERROR_CODES.DEPENDENCY_NOT_FOUND]: { type: MUX_AI_ERROR_TYPES.SERVER_ERROR, source: MUX_AI_ERROR_SOURCES.INTERNAL, siteDependency: true },
1161
+ [MUX_AI_ERROR_CODES.DEPENDENCY_REQUEST_REJECTED]: { type: MUX_AI_ERROR_TYPES.SERVER_ERROR, source: MUX_AI_ERROR_SOURCES.INTERNAL, siteDependency: true },
1162
+ [MUX_AI_ERROR_CODES.DEPENDENCY_OTHER_STATUS]: { type: MUX_AI_ERROR_TYPES.SERVER_ERROR, source: MUX_AI_ERROR_SOURCES.INTERNAL, siteDependency: true },
1163
+ // Not step-retried: the dependency answered, and would answer the same way. Resubmittable.
1164
+ [MUX_AI_ERROR_CODES.DEPENDENCY_RESPONSE_FAILED]: { type: MUX_AI_ERROR_TYPES.PROCESSING_ERROR, source: MUX_AI_ERROR_SOURCES.UPSTREAM, siteDependency: true, transient: false, retryable: true }
1091
1165
  };
1092
1166
  function isTransientStatus(status) {
1093
1167
  return status === void 0 || status === 408 || status === 425 || status === 429 || status >= 500;
@@ -1104,6 +1178,19 @@ function defaultRetryable(type, source, transient) {
1104
1178
  }
1105
1179
  return source === MUX_AI_ERROR_SOURCES.UPSTREAM;
1106
1180
  }
1181
+ var MUX_AI_DEPENDENCY_STATUS_CODES = {
1182
+ NO_RESPONSE: MUX_AI_ERROR_CODES.DEPENDENCY_NO_RESPONSE,
1183
+ TIMEOUT: MUX_AI_ERROR_CODES.DEPENDENCY_TIMEOUT,
1184
+ RATE_LIMITED: MUX_AI_ERROR_CODES.DEPENDENCY_RATE_LIMITED,
1185
+ TOO_EARLY: MUX_AI_ERROR_CODES.DEPENDENCY_TOO_EARLY,
1186
+ SERVER_ERROR: MUX_AI_ERROR_CODES.DEPENDENCY_SERVER_ERROR,
1187
+ AUTH_REJECTED: MUX_AI_ERROR_CODES.DEPENDENCY_AUTH_REJECTED,
1188
+ NOT_FOUND: MUX_AI_ERROR_CODES.DEPENDENCY_NOT_FOUND,
1189
+ REQUEST_REJECTED: MUX_AI_ERROR_CODES.DEPENDENCY_REQUEST_REJECTED,
1190
+ OTHER_STATUS: MUX_AI_ERROR_CODES.DEPENDENCY_OTHER_STATUS,
1191
+ RESPONSE_FAILED: MUX_AI_ERROR_CODES.DEPENDENCY_RESPONSE_FAILED
1192
+ };
1193
+ var MUX_AI_DEPENDENCY_STATUS_CODE_VALUES = Object.values(MUX_AI_DEPENDENCY_STATUS_CODES);
1107
1194
  var MAX_CAUSE_DEPTH = 3;
1108
1195
  var MAX_CAUSE_MESSAGE_LENGTH = 500;
1109
1196
  function statusOf(value) {
@@ -2023,10 +2110,63 @@ function classifyDependencyFailure(init) {
2023
2110
  ...init.retryable !== void 0 && { retryable: init.retryable }
2024
2111
  };
2025
2112
  }
2113
+ function dependencyFailureCode({ status, timedOut }) {
2114
+ if (timedOut || status === 408) {
2115
+ return MUX_AI_DEPENDENCY_STATUS_CODES.TIMEOUT;
2116
+ }
2117
+ if (status === void 0) {
2118
+ return MUX_AI_DEPENDENCY_STATUS_CODES.NO_RESPONSE;
2119
+ }
2120
+ if (status === 429) {
2121
+ return MUX_AI_DEPENDENCY_STATUS_CODES.RATE_LIMITED;
2122
+ }
2123
+ if (status === 425) {
2124
+ return MUX_AI_DEPENDENCY_STATUS_CODES.TOO_EARLY;
2125
+ }
2126
+ if (status >= 500 && status < 600) {
2127
+ return MUX_AI_DEPENDENCY_STATUS_CODES.SERVER_ERROR;
2128
+ }
2129
+ if (status === 401 || status === 403) {
2130
+ return MUX_AI_DEPENDENCY_STATUS_CODES.AUTH_REJECTED;
2131
+ }
2132
+ if (status === 404) {
2133
+ return MUX_AI_DEPENDENCY_STATUS_CODES.NOT_FOUND;
2134
+ }
2135
+ return status >= 400 && status < 500 ? MUX_AI_DEPENDENCY_STATUS_CODES.REQUEST_REJECTED : MUX_AI_DEPENDENCY_STATUS_CODES.OTHER_STATUS;
2136
+ }
2137
+ function attributedFailureCode({ status, timedOut, notFoundSource, authSource }) {
2138
+ if (timedOut) {
2139
+ return void 0;
2140
+ }
2141
+ if (status === 404 && notFoundSource === MUX_AI_ERROR_SOURCES.ASSET) {
2142
+ return MUX_AI_ERROR_CODES.ASSET_RESOURCE_NOT_FOUND;
2143
+ }
2144
+ if ((status === 401 || status === 403) && authSource === MUX_AI_ERROR_SOURCES.ACCOUNT) {
2145
+ return MUX_AI_ERROR_CODES.ACCOUNT_CREDENTIALS_REJECTED;
2146
+ }
2147
+ return void 0;
2148
+ }
2026
2149
  function dependencyError(message, init) {
2027
- const { source, ...classification } = classifyDependencyFailure(init);
2028
- const where = { source, dependency: init.dependency };
2029
- return new MuxAiError(message, { ...classification, ...where, cause: init.cause });
2150
+ const { facts, transient } = classifyDependencyFailure(
2151
+ init.authSource === MUX_AI_ERROR_SOURCES.ACCOUNT && !init.authInputs?.length ? { ...init, authInputs: ["credentials"] } : init
2152
+ );
2153
+ const code = init.code ?? attributedFailureCode(init) ?? dependencyFailureCode(init);
2154
+ const entry = MUX_AI_ERROR_CATALOG[code];
2155
+ const mayHaveTakenEffect = init.timedOut === true || (init.status === void 0 ? code === MUX_AI_ERROR_CODES.DEPENDENCY_NO_RESPONSE : init.status >= 500);
2156
+ const retryable = init.retryable ?? entry.retryable;
2157
+ return new MuxAiError(message, {
2158
+ code,
2159
+ type: entry.type,
2160
+ source: entry.source,
2161
+ dependency: init.dependency,
2162
+ facts,
2163
+ // The site's override wins, then a non-idempotent call that may have taken effect,
2164
+ // then the code's policy, then the status rules. A code other than no response or a
2165
+ // timeout means the dependency answered, so a missing status isn't "no response" here.
2166
+ transient: init.transient ?? (init.idempotent === false && mayHaveTakenEffect ? false : void 0) ?? entry.transient ?? (init.status === void 0 && !init.timedOut ? false : transient),
2167
+ ...retryable !== void 0 && { retryable },
2168
+ cause: init.cause
2169
+ });
2030
2170
  }
2031
2171
  function requestIdOf(headers) {
2032
2172
  if (!headers || typeof headers !== "object") {
@@ -2206,10 +2346,7 @@ function muxVideoError(message, init) {
2206
2346
  ...init,
2207
2347
  dependency: MUX_AI_ERROR_DEPENDENCIES.MUX_VIDEO,
2208
2348
  notFoundSource: MUX_AI_ERROR_SOURCES.ASSET,
2209
- authSource: MUX_AI_ERROR_SOURCES.ACCOUNT,
2210
- authInputs: ["credentials"],
2211
- // A create may have taken effect despite the failure; retrying could duplicate the track.
2212
- idempotent: init.call !== "create_track"
2349
+ ...!init.timedOut && (init.status === 401 || init.status === 403) && { code: MUX_AI_ERROR_CODES.PLAYBACK_ACCESS_DENIED }
2213
2350
  });
2214
2351
  }
2215
2352