@mux/ai 0.58.0 → 0.59.1-canary.90

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.d.ts CHANGED
@@ -1,8 +1,9 @@
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 ReplaceSourceTrackInput, f as ReplaceableTrackType, S as SourceTrackReplacementPolicy, g as SupportedISO639_1, h as SupportedISO639_3, T as TextTrackReplacementPlan, i as TextTrackSummary, j as TextTrackTarget, k as TrackSummary, l as TrackTarget, m as buildMuxAiTrackPassthrough, n as findNameCollisionTextTracks, o as findSameLanguageTextTracks, p as getLanguageCodePair, q as getLanguageName, r as isDuplicateTrackNameError, s as isMuxGeneratedTextTrack, t as isUndeterminedLanguageCode, u as isValidISO639_1, v as isValidISO639_3, w as normalizeTrackLanguageCode, x as normalizeTrackName, y as planSourceTrackReplacement, z as planTextTrackReplacement, A as replaceAndCreateTextTrack, B as replaceAndCreateTrack, C as replaceSourceTrack, D as summarizeTextTrack, E as toISO639_1, F as toISO639_3, G as validateTrackPassthrough, H as workflows } from './index-bdbFMlhA.js';
1
+ import { M as MuxAiErrorDependency, a as MuxAiErrorFacts, b as MuxAiErrorSource, c as MuxAiErrorType, d as MuxAiError, e as MuxAiErrorFactValue, f as MuxAiErrorCode, C as ClassifiedError } from './index-BPZEKSNp.js';
2
+ export { g as ClassifiedErrorInit, h as CodedClassification, E as ErrorCatalogEntry, i as ErrorCauseSummary, I as ISO639_1, j as ISO639_3, L as LanguageCodePair, k as MUX_AI_ERROR_CATALOG, l as MUX_AI_ERROR_CODES, m as MUX_AI_ERROR_CODE_VALUES, n as MUX_AI_ERROR_DEPENDENCIES, o as MUX_AI_ERROR_DEPENDENCY_VALUES, p as MUX_AI_ERROR_SOURCES, q as MUX_AI_ERROR_SOURCE_VALUES, r as MUX_AI_ERROR_TYPES, s as MUX_AI_ERROR_TYPE_VALUES, t as MUX_TRACK_PASSTHROUGH_MAX_CHARS, u as MuxAiErrorInit, R as ReplaceAndCreateTextTrackInput, v as ReplaceAndCreateTextTrackResult, w as ReplaceAndCreateTrackInput, x as ReplaceExistingTracksPolicy, y as ReplaceSourceTrackInput, z as ReplaceableTrackType, S as SerializedClassification, A as SourceAndDependency, B as SourceTrackReplacementPolicy, D as SupportedISO639_1, F as SupportedISO639_3, T as TextTrackReplacementPlan, G as TextTrackSummary, H as TextTrackTarget, J as TrackReplacementBlocked, K as TrackReplacementBlockedReason, N as TrackSummary, O as TrackTarget, P as assertNever, Q as buildMuxAiTrackPassthrough, U as classificationInit, V as errorDetailFact, W as findNameCollisionTextTracks, X as findSameLanguageTextTracks, Y as getLanguageCodePair, Z as getLanguageName, _ as internalError, $ as isDuplicateTrackNameError, a0 as isMuxGeneratedTextTrack, a1 as isTransientStatus, a2 as isUndeterminedLanguageCode, a3 as isValidISO639_1, a4 as isValidISO639_3, a5 as normalizeTrackLanguageCode, a6 as normalizeTrackName, a7 as planSourceTrackReplacement, a8 as planTextTrackReplacement, a9 as replaceAndCreateTextTrack, aa as replaceAndCreateTrack, ab as replaceSourceTrack, ac as restoreClassification, ad as serializeClassification, ae as summarizeTextTrack, af as toISO639_1, ag as toISO639_3, ah as trackReplacementBlockedError, ai as trackTargetFacts, aj as validateTrackPassthrough, ak as workflows, al as wrapError } from './index-BPZEKSNp.js';
3
+ import { M as MuxAsset, W as WorkflowCredentials, S as StoragePutObjectInput, a as StoragePresignGetObjectInput } from './transcripts-DuNI058z.js';
4
+ export { A as AssetTextTrack, C as ChunkEmbedding, b as ChunkingStrategy, E as Encrypted, c as EncryptedPayload, I as ImageSubmissionMode, d as MuxAIOptions, 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 './transcripts-DuNI058z.js';
2
5
  import { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE } from '@workflow/serde';
3
- import { T as TokenUsage, M as MuxAsset, W as WorkflowCredentials, S as StoragePutObjectInput, a as StoragePresignGetObjectInput } from './transcripts-Brw74qlV.js';
4
- export { A as AssetTextTrack, C as ChunkEmbedding, b as ChunkingStrategy, E as Encrypted, c as EncryptedPayload, I as ImageSubmissionMode, d as MuxAIOptions, P as PlaybackAsset, e as PlaybackPolicy, f as ScopedMuxAIOptions, g as StorageAdapter, h as TextChunk, i as TokenChunkingConfig, 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 './transcripts-Brw74qlV.js';
5
- export { i as primitives } from './index-DiuqBw6I.js';
6
+ export { i as primitives } from './index-CHA2jigS.js';
6
7
  import 'ai';
7
8
  import 'zod';
8
9
  import './summarization-BFmhXeAu.js';
@@ -11,60 +12,60 @@ import '@ai-sdk/google';
11
12
  import '@ai-sdk/openai';
12
13
  import '@mux/ts';
13
14
 
14
- var version = "0.58.0";
15
+ var version = "0.59.1-canary.90";
15
16
 
16
- type MuxAiErrorType = "validation_error" | "processing_error" | "timeout_error" | "content_policy_error";
17
- interface ModelCallDiagnostics {
18
- phase: "brief" | "draft" | "format_repair" | "length_repair";
19
- provider: string;
20
- modelId: string;
21
- maxOutputTokens?: number;
22
- }
23
- interface SerializedMuxAiError {
24
- message: string;
25
- publicType: MuxAiErrorType;
26
- retryable: boolean;
27
- stack?: string;
28
- usage?: TokenUsage;
29
- finishReason?: string;
30
- rawFinishReason?: string;
31
- diagnostics?: ModelCallDiagnostics;
17
+ interface DependencyErrorInit {
18
+ dependency: MuxAiErrorDependency;
19
+ /** Snake_case name of the outside call, e.g. `fetch_transcript`. */
20
+ call: string;
21
+ /** HTTP status, when there was a response. */
22
+ status?: number;
23
+ requestId?: string;
24
+ facts?: MuxAiErrorFacts;
25
+ cause?: unknown;
26
+ /** Source for a 404. Defaults to `internal` (we built the request). */
27
+ notFoundSource?: MuxAiErrorSource;
28
+ /** Source for a 401/403. Defaults to `internal` (our own credentials). */
29
+ authSource?: MuxAiErrorSource;
30
+ /** The call timed out before a response arrived. */
31
+ timedOut?: boolean;
32
+ /**
33
+ * False for a call that isn't safe to repeat (e.g. a create): even a transient
34
+ * failure is then not retried by the step runner, since the first attempt may
35
+ * have taken effect. The job stays retryable.
36
+ */
37
+ idempotent?: boolean;
38
+ /** Site override, as on `MuxAiError`, e.g. for a failure the caller already retried. */
39
+ transient?: boolean;
40
+ /** Site override, as on `MuxAiError`, e.g. when the dependency says whether a new attempt may succeed. */
41
+ retryable?: boolean;
32
42
  }
43
+
33
44
  /**
34
- * An error whose message is safe to surface verbatim to the customer.
35
- *
36
- * Uses a structural brand (`__robots_error = true`) so that downstream
37
- * consumers can identify customer-safe errors via duck typing — no
38
- * shared dependency required. Errors from @mux/ai that DON'T carry
39
- * this brand (unexpected SDK failures, upstream provider errors, etc.)
40
- * should be treated as internal and obfuscated.
41
- *
42
- * Custom Workflow serializers preserve safe metadata across step boundaries.
43
- * The runtime's built-in Error serializer drops arbitrary own properties.
45
+ * The classification of a failed call to a remote service, from its HTTP status:
46
+ * no response, a timeout, 408/425/429 and 5xx are `upstream` and transient (408 and
47
+ * timeouts as `timeout_error`, 429 as `capacity_error`); 404 and 401/403 take the
48
+ * caller's chosen source; any other status is `internal`, a request we built. Shared
49
+ * by {@link dependencyError} and by consumers building their own errors on the same
50
+ * model, so remote failures are classified the same way everywhere.
44
51
  */
45
- declare class MuxAiError extends Error {
46
- /** Structural brand for duck-type identification. */
47
- readonly __robots_error = true;
48
- /** Error category shown in the API response. */
49
- readonly publicType: MuxAiErrorType;
50
- /** Customer-facing message. Must be safe to show verbatim. */
51
- readonly publicMessage: string;
52
- /** Whether the customer should retry the job. */
53
- readonly retryable: boolean;
54
- usage?: TokenUsage;
55
- diagnostics?: ModelCallDiagnostics;
56
- /** Internal diagnostic failure; non-enumerable and excluded from JSON. */
57
- readonly cause?: unknown;
58
- constructor(message: string, opts?: {
59
- type?: MuxAiErrorType;
60
- retryable?: boolean;
61
- cause?: unknown;
62
- });
63
- static is(value: unknown): value is MuxAiError;
64
- static [WORKFLOW_SERIALIZE](instance: MuxAiError): SerializedMuxAiError;
65
- static [WORKFLOW_DESERIALIZE](value: SerializedMuxAiError): MuxAiError;
66
- }
67
- declare function wrapError(error: unknown, message: string): never;
52
+ declare function classifyDependencyFailure(init: Pick<DependencyErrorInit, "call" | "status" | "requestId" | "facts" | "notFoundSource" | "authSource" | "timedOut" | "idempotent" | "transient" | "retryable">): {
53
+ type: MuxAiErrorType;
54
+ source: MuxAiErrorSource;
55
+ facts: MuxAiErrorFacts;
56
+ transient: boolean;
57
+ retryable?: boolean;
58
+ };
59
+ /**
60
+ * Classifies a failed call to a remote service from its HTTP status (see
61
+ * {@link classifyDependencyFailure}). Transient failures are retried by the Workflow
62
+ * step runner; everything else is fatal.
63
+ */
64
+ declare function dependencyError(message: string, init: DependencyErrorInit): MuxAiError;
65
+ /** Reads the HTTP status off an SDK error (`status` or `statusCode`), if it has one. */
66
+ declare function httpStatusOf(error: unknown): number | undefined;
67
+ /** Reads a request id from response headers (a `Headers` instance or a plain record). */
68
+ declare function requestIdOf(headers: unknown): string | undefined;
68
69
 
69
70
  /**
70
71
  * Which file to read from an asset whose static renditions come from the
@@ -72,7 +73,8 @@ declare function wrapError(error: unknown, message: string): never;
72
73
  *
73
74
  * - `ready`: serve `name`. `filesizeBytes` is set when Mux reports it.
74
75
  * - `preparing`: Mux is still generating the files; check again later.
75
- * - `unusable`: the files will never be usable as-is. `reason` is customer-safe.
76
+ * - `unusable`: the files will never be usable as-is. `reason` is customer-safe;
77
+ * `status` is the renditions' status when they aren't `ready`.
76
78
  */
77
79
  type LegacyMp4SupportRendition = {
78
80
  kind: "ready";
@@ -83,6 +85,8 @@ type LegacyMp4SupportRendition = {
83
85
  } | {
84
86
  kind: "unusable";
85
87
  reason: string;
88
+ mp4Support: string;
89
+ status?: string;
86
90
  };
87
91
  /** Guide for the Static Renditions API that replaces `mp4_support`. */
88
92
  declare const STATIC_RENDITIONS_GUIDE_URL = "https://www.mux.com/docs/guides/enable-static-mp4-renditions";
@@ -117,6 +121,132 @@ type MuxPlaybackService = "image" | "stream";
117
121
  */
118
122
  declare function getMuxPlaybackOrigin(service: MuxPlaybackService, customDomain?: string): string;
119
123
 
124
+ /**
125
+ * What end users may see about a failure. `type` and `retryable` are always public;
126
+ * `code` and `facts` only for codes with a public mapping. The error's own `message`
127
+ * never appears here.
128
+ */
129
+ interface PublicError<TType extends string = string, TCode extends string = string> {
130
+ type: TType;
131
+ /** Present only for codes with a public mapping. */
132
+ code?: TCode;
133
+ message: string;
134
+ retryable: boolean;
135
+ /** Only the facts the code's mapping allows. */
136
+ facts?: MuxAiErrorFacts;
137
+ }
138
+ /** The public view of a `MuxAiError`. */
139
+ type MuxAiPublicError = PublicError<MuxAiErrorType, MuxAiErrorCode>;
140
+ /** How one code is shown to end users. */
141
+ interface PublicErrorMapping {
142
+ /** Facts that may reach end users. Every other fact is dropped. */
143
+ facts?: readonly string[];
144
+ /** End-user text, built only from the allowed facts. */
145
+ message: string | ((facts: MuxAiErrorFacts, error: {
146
+ retryable: boolean;
147
+ }) => string);
148
+ }
149
+ /**
150
+ * Wording for a failure whose code has no public mapping (or that has no code):
151
+ * by source for failures the caller can act on, otherwise by type.
152
+ */
153
+ declare const MUX_AI_ERROR_GENERIC_MESSAGES: {
154
+ readonly request: "The request's parameters can't be used for this operation.";
155
+ readonly asset: "The asset can't be processed by this operation.";
156
+ readonly account: "The Mux account or environment can't be used for this operation.";
157
+ readonly timeout: "The operation timed out.";
158
+ readonly capacity: "A required service is over capacity.";
159
+ readonly contentPolicy: "The content was blocked by a content policy.";
160
+ readonly unavailable: "A required service was temporarily unavailable.";
161
+ readonly failed: "The operation failed.";
162
+ };
163
+ declare function blockedTrackMessage(facts: MuxAiErrorFacts): string;
164
+ declare function scopeMessage(facts: MuxAiErrorFacts): string;
165
+ /**
166
+ * The codes end users may see, and how. A code absent here is internal: it renders
167
+ * through {@link MUX_AI_ERROR_GENERIC_MESSAGES} and its code and facts are dropped.
168
+ * Add a code only when its condition is something an end user can act on or needs
169
+ * to know, and allow only facts that are safe to show (never URLs, credentials,
170
+ * provider internals or model output).
171
+ */
172
+ declare const MUX_AI_ERROR_PUBLIC_MAPPINGS: {
173
+ readonly invalid_scope: {
174
+ readonly facts: readonly ["reason", "received", "startTime", "endTime", "assetDurationSeconds"];
175
+ readonly message: typeof scopeMessage;
176
+ };
177
+ readonly track_replacement_blocked: {
178
+ readonly facts: readonly ["reason", "trackType", "languageCode", "trackName", "conflictingTracks"];
179
+ readonly message: typeof blockedTrackMessage;
180
+ };
181
+ readonly caption_track_not_found: {
182
+ readonly facts: readonly ["trackId", "availableTrackIds", "languageCode", "availableLanguages"];
183
+ readonly message: (facts: Readonly<Record<string, MuxAiErrorFactValue>>) => string;
184
+ };
185
+ readonly playback_id_not_found: {
186
+ readonly message: "The asset has no public or signed playback ID. DRM playback IDs aren't supported.";
187
+ };
188
+ readonly transcript_empty: {
189
+ readonly message: "The transcript has no usable content.";
190
+ };
191
+ readonly parameter_out_of_range: {
192
+ readonly facts: readonly ["parameter", "value", "min", "max", "integer"];
193
+ readonly message: (facts: Readonly<Record<string, MuxAiErrorFactValue>>) => string;
194
+ };
195
+ readonly asset_duration_unavailable: {
196
+ readonly facts: readonly ["assetId"];
197
+ readonly message: (facts: Readonly<Record<string, MuxAiErrorFactValue>>) => string;
198
+ };
199
+ readonly model_output_missing: {
200
+ readonly facts: readonly ["assetId"];
201
+ readonly message: (facts: Readonly<Record<string, MuxAiErrorFactValue>>) => string;
202
+ };
203
+ readonly model_output_invalid: {
204
+ readonly facts: readonly ["assetId"];
205
+ readonly message: (facts: Readonly<Record<string, MuxAiErrorFactValue>>) => string;
206
+ };
207
+ readonly audio_track_unsupported: {
208
+ readonly facts: readonly ["reason"];
209
+ readonly message: (facts: Readonly<Record<string, MuxAiErrorFactValue>>) => string;
210
+ };
211
+ readonly static_rendition_unsupported: {
212
+ readonly facts: readonly ["reason", "mp4Support", "renditionStatus", "renditionName", "sizeBytes", "maxBytes"];
213
+ readonly message: (facts: Readonly<Record<string, MuxAiErrorFactValue>>) => string;
214
+ };
215
+ readonly static_rendition_failed: {
216
+ readonly message: "Mux failed to create the static rendition this operation needs. Check the asset's static renditions in the Mux dashboard.";
217
+ };
218
+ readonly content_policy_blocked: {
219
+ readonly facts: readonly ["reason", "category"];
220
+ readonly message: (facts: Readonly<Record<string, MuxAiErrorFactValue>>) => string;
221
+ };
222
+ readonly dubbing_language_unsupported: {
223
+ readonly facts: readonly ["language", "which"];
224
+ readonly message: (facts: Readonly<Record<string, MuxAiErrorFactValue>>) => string;
225
+ };
226
+ readonly dubbing_failed: {
227
+ readonly facts: readonly ["providerError"];
228
+ readonly message: (facts: Readonly<Record<string, MuxAiErrorFactValue>>, { retryable }: {
229
+ retryable: boolean;
230
+ }) => string;
231
+ };
232
+ };
233
+ /** The SDK's wording for a failure without a public code: by source, then by type. */
234
+ declare function genericPublicMessage(error: ClassifiedError): string;
235
+ /**
236
+ * Builds the end-user view for errors on the shared model ({@link ClassifiedError}):
237
+ * a code with a public mapping keeps its code and allowed facts and renders the
238
+ * mapping's text; anything else renders `genericMessage`. Never includes the error's
239
+ * own `message`, except for a legacy error (raised before classification), whose
240
+ * message is end-user text and is shown as it always was. Consumers build one with their own mappings (which may include the
241
+ * SDK's) and their own generic wording.
242
+ */
243
+ declare function createPublicErrorView<TType extends string, TCode extends string>(config: {
244
+ mappings: Readonly<Partial<Record<TCode, PublicErrorMapping>>>;
245
+ genericMessage: (error: ClassifiedError<TType, TCode>) => string;
246
+ }): (error: ClassifiedError<TType, TCode>) => PublicError<TType, TCode>;
247
+ /** The end-user view of a `MuxAiError`, with the SDK's public mappings and generic wording. */
248
+ declare const toPublicError: (error: ClassifiedError<MuxAiErrorType, MuxAiErrorCode>) => MuxAiPublicError;
249
+
120
250
  /**
121
251
  * A function that returns workflow credentials, either synchronously or asynchronously.
122
252
  * Used to inject credentials from external sources (e.g., a secrets manager).
@@ -150,4 +280,4 @@ declare class WorkflowStorageClient {
150
280
  }
151
281
  declare function createWorkflowStorageClient(options?: WorkflowStorageClientOptions): WorkflowStorageClient;
152
282
 
153
- export { type LegacyMp4SupportRendition, MuxAiError, type MuxAiErrorType, MuxAsset, type MuxPlaybackService, STATIC_RENDITIONS_GUIDE_URL, StoragePresignGetObjectInput, StoragePutObjectInput, TokenUsage, WorkflowCredentials, type WorkflowCredentialsProvider, WorkflowStorageClient, createWorkflowStorageClient, getLegacyMp4SupportRenditionSizeError, getMuxPlaybackOrigin, resolveLegacyMp4SupportRendition, setWorkflowCredentialsProvider, usesLegacyMp4Support, version, wrapError };
283
+ export { ClassifiedError, type DependencyErrorInit, type LegacyMp4SupportRendition, MUX_AI_ERROR_GENERIC_MESSAGES, MUX_AI_ERROR_PUBLIC_MAPPINGS, MuxAiError, MuxAiErrorCode, MuxAiErrorDependency, MuxAiErrorFactValue, MuxAiErrorFacts, MuxAiErrorSource, MuxAiErrorType, type MuxAiPublicError, MuxAsset, type MuxPlaybackService, type PublicError, type PublicErrorMapping, STATIC_RENDITIONS_GUIDE_URL, StoragePresignGetObjectInput, StoragePutObjectInput, WorkflowCredentials, type WorkflowCredentialsProvider, WorkflowStorageClient, classifyDependencyFailure, createPublicErrorView, createWorkflowStorageClient, dependencyError, genericPublicMessage, getLegacyMp4SupportRenditionSizeError, getMuxPlaybackOrigin, httpStatusOf, requestIdOf, resolveLegacyMp4SupportRendition, setWorkflowCredentialsProvider, toPublicError, usesLegacyMp4Support, version };