@mux/ai 0.62.0 → 0.63.0-canary.99
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-BN5yOn9o.d.ts → index-CA8sRSVJ.d.ts} +2 -534
- package/dist/{index-CHA2jigS.d.ts → index-eEZfpEP7.d.ts} +1 -1
- package/dist/index.d.ts +6 -7
- package/dist/index.js +168 -78
- package/dist/index.js.map +1 -1
- package/dist/primitives/index.d.ts +3 -2
- package/dist/primitives/index.js +195 -30
- package/dist/primitives/index.js.map +1 -1
- package/dist/transcripts-So1KIXSI.d.ts +1152 -0
- package/dist/workflows/index.d.ts +3 -3
- package/dist/workflows/index.js +165 -77
- package/dist/workflows/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/transcripts-DuNI058z.d.ts +0 -613
|
@@ -0,0 +1,1152 @@
|
|
|
1
|
+
import { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE } from '@workflow/serde';
|
|
2
|
+
import Mux from '@mux/ts';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Workflow Crypto
|
|
6
|
+
*
|
|
7
|
+
* Provides AES-256-GCM encryption for securely passing credentials to workflows.
|
|
8
|
+
* Encrypted payloads are JSON-serializable and include version/algorithm metadata
|
|
9
|
+
* for forward compatibility.
|
|
10
|
+
*/
|
|
11
|
+
declare const WORKFLOW_ENCRYPTION_VERSION = 1;
|
|
12
|
+
declare const WORKFLOW_ENCRYPTION_ALGORITHM: "aes-256-gcm";
|
|
13
|
+
/**
|
|
14
|
+
* Structure of an encrypted payload (all fields are base64-encoded where applicable).
|
|
15
|
+
*
|
|
16
|
+
* The optional `kid` (key ID) field supports key rotation scenarios:
|
|
17
|
+
* - Include a `kid` when encrypting to identify which key was used
|
|
18
|
+
* - On decryption, read `payload.kid` to look up the correct key
|
|
19
|
+
* - Keys should be invalidated/deleted after rotation, not kept indefinitely
|
|
20
|
+
*
|
|
21
|
+
* Security notes:
|
|
22
|
+
* - `kid` is stored in plaintext (not encrypted) - don't put sensitive data in it
|
|
23
|
+
* - Tampering with `kid` doesn't weaken security - wrong key = decryption fails
|
|
24
|
+
*/
|
|
25
|
+
interface EncryptedPayload {
|
|
26
|
+
v: typeof WORKFLOW_ENCRYPTION_VERSION;
|
|
27
|
+
alg: typeof WORKFLOW_ENCRYPTION_ALGORITHM;
|
|
28
|
+
kid?: string;
|
|
29
|
+
iv: string;
|
|
30
|
+
tag: string;
|
|
31
|
+
ciphertext: string;
|
|
32
|
+
}
|
|
33
|
+
/** Branded type that preserves the original type information for decryption */
|
|
34
|
+
type Encrypted<T> = EncryptedPayload & {
|
|
35
|
+
__type?: T;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Encrypts a value for secure transport to a workflow.
|
|
39
|
+
*
|
|
40
|
+
* @param value - Any JSON-serializable value (typically WorkflowCredentials)
|
|
41
|
+
* @param key - 32-byte secret key (base64 string or Uint8Array)
|
|
42
|
+
* @param keyId - Optional key identifier for rotation support (stored in plaintext)
|
|
43
|
+
* @returns Encrypted payload with metadata, safe to pass through untrusted channels
|
|
44
|
+
*/
|
|
45
|
+
declare function encryptForWorkflow<T>(value: T, key: Uint8Array | string, keyId?: string): Promise<Encrypted<T>>;
|
|
46
|
+
/**
|
|
47
|
+
* Decrypts and deserializes a workflow payload.
|
|
48
|
+
*
|
|
49
|
+
* @param payload - Encrypted payload from `encryptForWorkflow`
|
|
50
|
+
* @param key - Same 32-byte secret key used for encryption
|
|
51
|
+
* @returns The original decrypted value
|
|
52
|
+
* @throws If payload is invalid, tampered with, or key is wrong
|
|
53
|
+
*/
|
|
54
|
+
declare function decryptFromWorkflow<T>(payload: EncryptedPayload, key: Uint8Array | string): Promise<T>;
|
|
55
|
+
|
|
56
|
+
/** Input shape for uploading objects through a storage adapter. */
|
|
57
|
+
interface StoragePutObjectInput {
|
|
58
|
+
endpoint: string;
|
|
59
|
+
region: string;
|
|
60
|
+
bucket: string;
|
|
61
|
+
key: string;
|
|
62
|
+
body: string | Uint8Array;
|
|
63
|
+
contentType?: string;
|
|
64
|
+
accessKeyId?: string;
|
|
65
|
+
secretAccessKey?: string;
|
|
66
|
+
}
|
|
67
|
+
/** Input shape for presigning object download URLs through a storage adapter. */
|
|
68
|
+
interface StoragePresignGetObjectInput {
|
|
69
|
+
endpoint: string;
|
|
70
|
+
region: string;
|
|
71
|
+
bucket: string;
|
|
72
|
+
key: string;
|
|
73
|
+
expiresInSeconds: number;
|
|
74
|
+
accessKeyId?: string;
|
|
75
|
+
secretAccessKey?: string;
|
|
76
|
+
}
|
|
77
|
+
/** Optional pluggable storage backend for S3-compatible object operations. */
|
|
78
|
+
interface StorageAdapter {
|
|
79
|
+
putObject: (input: StoragePutObjectInput) => Promise<void>;
|
|
80
|
+
createPresignedGetUrl: (input: StoragePresignGetObjectInput) => Promise<string>;
|
|
81
|
+
}
|
|
82
|
+
interface WorkflowMuxClient {
|
|
83
|
+
createClient: () => Promise<Mux>;
|
|
84
|
+
getSigningKey: () => string | undefined;
|
|
85
|
+
getPrivateKey: () => string | undefined;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Base options mixed into every higher-level workflow configuration.
|
|
89
|
+
*/
|
|
90
|
+
interface MuxAIOptions {
|
|
91
|
+
/** Optional timeout (ms) for helper utilities that support request limits. */
|
|
92
|
+
timeout?: number;
|
|
93
|
+
/**
|
|
94
|
+
* Optional asset snapshot to reuse instead of retrieving the asset from Mux.
|
|
95
|
+
* The snapshot must belong to `assetId`; callers should capture it immediately
|
|
96
|
+
* before starting the workflow.
|
|
97
|
+
*/
|
|
98
|
+
assetSnapshot?: MuxAsset;
|
|
99
|
+
/**
|
|
100
|
+
* Optional credentials for workflow execution.
|
|
101
|
+
* Use encryptForWorkflow when running in Workflow Dev Kit environments.
|
|
102
|
+
*/
|
|
103
|
+
credentials?: WorkflowCredentialsInput;
|
|
104
|
+
/** Optional storage adapter for upload and presigning operations. */
|
|
105
|
+
storageAdapter?: StorageAdapter;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Asset-relative time range used to limit workflow analysis.
|
|
109
|
+
*
|
|
110
|
+
* Times are expressed in seconds. The start is inclusive and the end is
|
|
111
|
+
* exclusive. Either boundary may be omitted to analyze from the beginning or
|
|
112
|
+
* through the end of the asset, respectively.
|
|
113
|
+
*/
|
|
114
|
+
interface WorkflowScope {
|
|
115
|
+
/** Inclusive start offset from the beginning of the asset, in seconds. */
|
|
116
|
+
startTime?: number;
|
|
117
|
+
/** Exclusive end offset from the beginning of the asset, in seconds. */
|
|
118
|
+
endTime?: number;
|
|
119
|
+
}
|
|
120
|
+
/** Base options for workflows that can analyze a bounded part of an asset. */
|
|
121
|
+
interface ScopedMuxAIOptions extends MuxAIOptions {
|
|
122
|
+
/** Optional asset-relative time range to analyze. */
|
|
123
|
+
scope?: WorkflowScope;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Workflow credentials.
|
|
127
|
+
*
|
|
128
|
+
* Supports plain credential objects and primitive credential fields for
|
|
129
|
+
* per-request multi-tenant workflows.
|
|
130
|
+
*/
|
|
131
|
+
interface WorkflowCredentials {
|
|
132
|
+
/** Direct Mux API token ID for per-request credential injection. */
|
|
133
|
+
muxTokenId?: string;
|
|
134
|
+
/** Direct Mux API token secret for per-request credential injection. */
|
|
135
|
+
muxTokenSecret?: string;
|
|
136
|
+
/** Direct Mux API auth token secret for per-request credential injection. */
|
|
137
|
+
muxAuthorizationToken?: string;
|
|
138
|
+
/** Optional direct Mux signing key ID for signed playback URL generation. */
|
|
139
|
+
muxSigningKey?: string;
|
|
140
|
+
/** Optional direct Mux private key for signed playback URL generation. */
|
|
141
|
+
muxPrivateKey?: string;
|
|
142
|
+
/** Optional Mux custom domain (e.g. "media.example.com") used for image.* and stream.* playback URLs. */
|
|
143
|
+
muxCustomDomain?: string;
|
|
144
|
+
/** Optional direct OpenAI API key for per-request credential injection. */
|
|
145
|
+
openaiApiKey?: string;
|
|
146
|
+
/** Optional direct Baseten API key for per-request credential injection. */
|
|
147
|
+
basetenApiKey?: string;
|
|
148
|
+
/** Optional direct Baseten language endpoint URL (dedicated /sync/v1 deployment or shared OpenAI-compatible base URL). */
|
|
149
|
+
basetenUrl?: string;
|
|
150
|
+
/** Optional direct Baseten dedicated embedding deployment URL (/sync or /sync/v1). */
|
|
151
|
+
basetenEmbeddingUrl?: string;
|
|
152
|
+
/** Optional direct API key for OpenAI-compatible endpoints. */
|
|
153
|
+
openaiCompatibleApiKey?: string;
|
|
154
|
+
/** Optional direct base URL of an OpenAI-compatible API. */
|
|
155
|
+
openaiCompatibleBaseUrl?: string;
|
|
156
|
+
/** Optional direct embedding-specific OpenAI-compatible base URL. */
|
|
157
|
+
openaiCompatibleEmbeddingBaseUrl?: string;
|
|
158
|
+
/** Optional direct Anthropic API key for per-request credential injection. */
|
|
159
|
+
anthropicApiKey?: string;
|
|
160
|
+
/** Optional direct Google API key for per-request credential injection. */
|
|
161
|
+
googleApiKey?: string;
|
|
162
|
+
/** Optional direct Google Vision API key for per-request credential injection. */
|
|
163
|
+
googleVisionApiKey?: string;
|
|
164
|
+
/** Optional direct Hive API key for per-request credential injection. */
|
|
165
|
+
hiveApiKey?: string;
|
|
166
|
+
/** Optional direct ElevenLabs API key for per-request credential injection. */
|
|
167
|
+
elevenLabsApiKey?: string;
|
|
168
|
+
}
|
|
169
|
+
/** Credentials that are safe to serialize across workflow boundaries. */
|
|
170
|
+
type WorkflowCredentialsInput = WorkflowCredentials | Encrypted<WorkflowCredentials>;
|
|
171
|
+
/** Tone controls for the summarization helper. */
|
|
172
|
+
type ToneType = "neutral" | "playful" | "professional";
|
|
173
|
+
/** Common transport for image-based workflows. */
|
|
174
|
+
type ImageSubmissionMode = "url" | "base64";
|
|
175
|
+
/** Result of calling the Mux SDK asset retrieval helper. */
|
|
176
|
+
type MuxAsset = Awaited<ReturnType<Mux["video"]["assets"]["retrieve"]>>;
|
|
177
|
+
/** Single ready track extracted from a Mux asset. */
|
|
178
|
+
type AssetTextTrack = NonNullable<MuxAsset["tracks"]>[number];
|
|
179
|
+
/** Playback policy type for Mux assets. */
|
|
180
|
+
type PlaybackPolicy = "public" | "signed";
|
|
181
|
+
/** Convenience bundle returned by `getPlaybackIdForAsset`. */
|
|
182
|
+
interface PlaybackAsset {
|
|
183
|
+
asset: MuxAsset;
|
|
184
|
+
playbackId: string;
|
|
185
|
+
/** The policy type of the playback ID ('public' or 'signed'). */
|
|
186
|
+
policy: PlaybackPolicy;
|
|
187
|
+
}
|
|
188
|
+
/** Configuration for token-based chunking. */
|
|
189
|
+
interface TokenChunkingConfig {
|
|
190
|
+
type: "token";
|
|
191
|
+
/** Maximum tokens per chunk. */
|
|
192
|
+
maxTokens: number;
|
|
193
|
+
/** Number of overlapping tokens between chunks. */
|
|
194
|
+
overlap?: number;
|
|
195
|
+
}
|
|
196
|
+
/** Configuration for VTT-aware chunking that respects cue boundaries. */
|
|
197
|
+
interface VTTChunkingConfig {
|
|
198
|
+
type: "vtt";
|
|
199
|
+
/** Maximum tokens per chunk. */
|
|
200
|
+
maxTokens: number;
|
|
201
|
+
/** Number of cues to overlap between chunks (default: 2). */
|
|
202
|
+
overlapCues?: number;
|
|
203
|
+
}
|
|
204
|
+
/** Union type for all chunking strategy configurations. */
|
|
205
|
+
type ChunkingStrategy = TokenChunkingConfig | VTTChunkingConfig;
|
|
206
|
+
/** A single chunk of text extracted from a transcript. */
|
|
207
|
+
interface TextChunk {
|
|
208
|
+
/** Unique identifier for this chunk. */
|
|
209
|
+
id: string;
|
|
210
|
+
/** The text content of the chunk. */
|
|
211
|
+
text: string;
|
|
212
|
+
/** Number of tokens in this chunk. */
|
|
213
|
+
tokenCount: number;
|
|
214
|
+
/** Start time in seconds (if available from timestamped transcript). */
|
|
215
|
+
startTime?: number;
|
|
216
|
+
/** End time in seconds (if available from timestamped transcript). */
|
|
217
|
+
endTime?: number;
|
|
218
|
+
}
|
|
219
|
+
/** A chunk with its embedding vector. */
|
|
220
|
+
interface ChunkEmbedding {
|
|
221
|
+
/** Reference to the chunk ID. */
|
|
222
|
+
chunkId: string;
|
|
223
|
+
/** The embedding vector. */
|
|
224
|
+
embedding: number[];
|
|
225
|
+
/** Optional metadata for this chunk. */
|
|
226
|
+
metadata: {
|
|
227
|
+
startTime?: number;
|
|
228
|
+
endTime?: number;
|
|
229
|
+
tokenCount: number;
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
/** Result of generating embeddings for a video asset. */
|
|
233
|
+
interface VideoEmbeddingsResult {
|
|
234
|
+
/** The Mux asset ID. */
|
|
235
|
+
assetId: string;
|
|
236
|
+
/** Individual chunk embeddings. */
|
|
237
|
+
chunks: ChunkEmbedding[];
|
|
238
|
+
/** Averaged embedding across all chunks. */
|
|
239
|
+
averagedEmbedding: number[];
|
|
240
|
+
/** AI provider used. */
|
|
241
|
+
provider: string;
|
|
242
|
+
/** Model used for embedding generation. */
|
|
243
|
+
model: string;
|
|
244
|
+
/** Additional metadata about the generation. */
|
|
245
|
+
metadata: {
|
|
246
|
+
totalChunks: number;
|
|
247
|
+
totalTokens: number;
|
|
248
|
+
chunkingStrategy: string;
|
|
249
|
+
embeddingDimensions: number;
|
|
250
|
+
generatedAt: string;
|
|
251
|
+
};
|
|
252
|
+
/** Workflow usage metadata (asset duration, thumbnails, etc.). */
|
|
253
|
+
usage?: TokenUsage;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Metadata attached to usage objects for workflow context.
|
|
257
|
+
*/
|
|
258
|
+
interface UsageMetadata {
|
|
259
|
+
/** Total asset duration in seconds. */
|
|
260
|
+
assetDurationSeconds?: number;
|
|
261
|
+
/** Number of thumbnails sampled for workflows that use thumbnails. */
|
|
262
|
+
thumbnailCount?: number;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Token usage breakdown returned by AI SDK providers.
|
|
266
|
+
* Used for efficiency and cost analysis.
|
|
267
|
+
*/
|
|
268
|
+
interface TokenUsage {
|
|
269
|
+
/** Number of tokens in the input prompt (text + image). */
|
|
270
|
+
inputTokens?: number;
|
|
271
|
+
/** Number of tokens generated in the output. */
|
|
272
|
+
outputTokens?: number;
|
|
273
|
+
/** Total tokens consumed (input + output). */
|
|
274
|
+
totalTokens?: number;
|
|
275
|
+
/** Tokens used for chain-of-thought reasoning (if applicable). */
|
|
276
|
+
reasoningTokens?: number;
|
|
277
|
+
/** Input tokens served from cache (reduces cost). */
|
|
278
|
+
cachedInputTokens?: number;
|
|
279
|
+
/** Input tokens written to cache (may use a provider-specific rate). */
|
|
280
|
+
cacheWriteTokens?: number;
|
|
281
|
+
/** Workflow metadata (asset duration, thumbnails, etc.). */
|
|
282
|
+
metadata?: UsageMetadata;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* What a legacy error carries across a Workflow step boundary: the pre-classification
|
|
287
|
+
* shape, so it revives with its end-user message.
|
|
288
|
+
*/
|
|
289
|
+
interface LegacySerializedMuxAiError {
|
|
290
|
+
message: string;
|
|
291
|
+
publicType: MuxAiErrorType;
|
|
292
|
+
retryable: boolean;
|
|
293
|
+
stack?: string;
|
|
294
|
+
usage?: TokenUsage;
|
|
295
|
+
finishReason?: string;
|
|
296
|
+
rawFinishReason?: string;
|
|
297
|
+
diagnostics?: ModelCallDiagnostics;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Public error categories for job outcomes. One list for the SDK and its consumers,
|
|
302
|
+
* which may extend it with their own types (e.g. request-time HTTP errors). Treat
|
|
303
|
+
* `type` as an open string, so adding a value is not a breaking change.
|
|
304
|
+
*/
|
|
305
|
+
declare const MUX_AI_ERROR_TYPES: {
|
|
306
|
+
/** The request, the asset or the account can't be used as it is. */
|
|
307
|
+
readonly VALIDATION_ERROR: "validation_error";
|
|
308
|
+
/** The work was attempted and failed. */
|
|
309
|
+
readonly PROCESSING_ERROR: "processing_error";
|
|
310
|
+
/** The work didn't finish in time. */
|
|
311
|
+
readonly TIMEOUT_ERROR: "timeout_error";
|
|
312
|
+
/** Content was refused by a content policy. */
|
|
313
|
+
readonly CONTENT_POLICY_ERROR: "content_policy_error";
|
|
314
|
+
/** A service is rate limiting or over capacity. */
|
|
315
|
+
readonly CAPACITY_ERROR: "capacity_error";
|
|
316
|
+
/** A fault in this code or its configuration. */
|
|
317
|
+
readonly SERVER_ERROR: "server_error";
|
|
318
|
+
};
|
|
319
|
+
type MuxAiErrorType = typeof MUX_AI_ERROR_TYPES[keyof typeof MUX_AI_ERROR_TYPES];
|
|
320
|
+
declare const MUX_AI_ERROR_TYPE_VALUES: readonly MuxAiErrorType[];
|
|
321
|
+
/** Whose problem a failure is, judged from the SDK caller's side. A consumer may re-attribute it. */
|
|
322
|
+
declare const MUX_AI_ERROR_SOURCES: {
|
|
323
|
+
/** The caller's input, e.g. a scope past the end of the asset. */
|
|
324
|
+
readonly REQUEST: "request";
|
|
325
|
+
/** The Mux asset's state, e.g. no caption track in the requested language. */
|
|
326
|
+
readonly ASSET: "asset";
|
|
327
|
+
/** The Mux account or environment, e.g. missing permissions. */
|
|
328
|
+
readonly ACCOUNT: "account";
|
|
329
|
+
/** A remote service failed, e.g. the dubbing provider reported a failed dub. */
|
|
330
|
+
readonly UPSTREAM: "upstream";
|
|
331
|
+
/** This code, or the configuration of the service running it, e.g. missing signing keys. */
|
|
332
|
+
readonly INTERNAL: "internal";
|
|
333
|
+
};
|
|
334
|
+
type MuxAiErrorSource = typeof MUX_AI_ERROR_SOURCES[keyof typeof MUX_AI_ERROR_SOURCES];
|
|
335
|
+
declare const MUX_AI_ERROR_SOURCE_VALUES: readonly MuxAiErrorSource[];
|
|
336
|
+
/** A remote service reached over the network. Libraries in this process are not dependencies. */
|
|
337
|
+
declare const MUX_AI_ERROR_DEPENDENCIES: {
|
|
338
|
+
/** Mux Video: the API, stream and image delivery, and its static renditions and tracks. */
|
|
339
|
+
readonly MUX_VIDEO: "mux_video";
|
|
340
|
+
/** Mux Data: its API, e.g. engagement data (heatmaps and hotspots). */
|
|
341
|
+
readonly MUX_DATA: "mux_data";
|
|
342
|
+
/** A model or AI service provider, e.g. a language model API or the dubbing provider. */
|
|
343
|
+
readonly AI_PROVIDER: "ai_provider";
|
|
344
|
+
/** Object storage the SDK writes to or reads from, e.g. an S3-compatible bucket. */
|
|
345
|
+
readonly STORAGE: "storage";
|
|
346
|
+
};
|
|
347
|
+
type MuxAiErrorDependency = typeof MUX_AI_ERROR_DEPENDENCIES[keyof typeof MUX_AI_ERROR_DEPENDENCIES];
|
|
348
|
+
declare const MUX_AI_ERROR_DEPENDENCY_VALUES: readonly MuxAiErrorDependency[];
|
|
349
|
+
type MuxAiErrorFactValue = string | number | boolean | null | MuxAiErrorFactValue[] | {
|
|
350
|
+
[key: string]: MuxAiErrorFactValue;
|
|
351
|
+
};
|
|
352
|
+
/**
|
|
353
|
+
* Details of one occurrence, JSON-safe so they survive step boundaries. Internal by
|
|
354
|
+
* default: a consumer chooses what, if anything, to show. Dependency errors always
|
|
355
|
+
* carry `call` (the outside call's snake_case name), plus `status` and `requestId`
|
|
356
|
+
* when there was a response. A failure blamed on an input the caller passed carries
|
|
357
|
+
* `inputs`: the input names involved (e.g. `credentials`), so a caller that set that
|
|
358
|
+
* input itself, rather than passing on its end user's, can re-attribute the failure.
|
|
359
|
+
*/
|
|
360
|
+
type MuxAiErrorFacts = Readonly<Record<string, MuxAiErrorFactValue>>;
|
|
361
|
+
/**
|
|
362
|
+
* Opts a shared helper into raising classified errors. A workflow passes it once it has
|
|
363
|
+
* moved onto the classified model; without it, the helper fails exactly as it did
|
|
364
|
+
* before, so workflows that haven't moved see no change. It goes away once every
|
|
365
|
+
* caller has moved and classified errors become the only behavior.
|
|
366
|
+
*/
|
|
367
|
+
interface ClassifiedErrorsOption {
|
|
368
|
+
classifiedErrors?: boolean;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* What a code implies, in any catalog built on {@link ClassifiedError}: its type,
|
|
372
|
+
* source and dependency, and retry overrides that hold for every occurrence.
|
|
373
|
+
*/
|
|
374
|
+
/**
|
|
375
|
+
* A failure's source and the remote service involved, if any. An `upstream` failure is a
|
|
376
|
+
* remote service's, so it always names the dependency; any other source names one when a
|
|
377
|
+
* remote call was involved (e.g. Mux's 404 for the caller's asset).
|
|
378
|
+
*/
|
|
379
|
+
type SourceAndDependency<TDependency extends string = string> = {
|
|
380
|
+
source: typeof MUX_AI_ERROR_SOURCES.UPSTREAM;
|
|
381
|
+
dependency: TDependency;
|
|
382
|
+
} | {
|
|
383
|
+
source: Exclude<MuxAiErrorSource, typeof MUX_AI_ERROR_SOURCES.UPSTREAM>;
|
|
384
|
+
dependency?: TDependency;
|
|
385
|
+
};
|
|
386
|
+
type ErrorCatalogEntry<TType extends string = string, TDependency extends string = string> = {
|
|
387
|
+
type: TType;
|
|
388
|
+
/** Overrides the default from {@link defaultRetryable} for every error with this code. */
|
|
389
|
+
retryable?: boolean;
|
|
390
|
+
/** Overrides the default from {@link defaultTransient} for every error with this code. */
|
|
391
|
+
transient?: boolean;
|
|
392
|
+
} & SourceAndDependency<TDependency>;
|
|
393
|
+
/**
|
|
394
|
+
* Codes for conditions precise enough to name. A code implies its type, source and
|
|
395
|
+
* dependency (see {@link MUX_AI_ERROR_CATALOG}), so a site raising it can't contradict
|
|
396
|
+
* them. Codes name the condition, never the vendor.
|
|
397
|
+
*/
|
|
398
|
+
declare const MUX_AI_ERROR_CODES: {
|
|
399
|
+
/** The requested time range is invalid, or has nothing to work with. Facts: `reason` (`invalid_start_time`, `invalid_end_time`, `exceeds_duration`, `empty_range`, `no_video`, `no_transcript`, `no_scenes`) and the bounds involved. */
|
|
400
|
+
readonly INVALID_SCOPE: "invalid_scope";
|
|
401
|
+
/** Existing tracks block writing the output track under the chosen replacement policy. Facts: `reason` (`policy_fail`, `not_generated`, `name_collision`, `primary_audio`), `conflictingTracks` and the target track, plus `sourceRestored` and `restoredTrackId` when a source track was deleted first. */
|
|
402
|
+
readonly TRACK_REPLACEMENT_BLOCKED: "track_replacement_blocked";
|
|
403
|
+
/** An option's value can't be used. Facts: `parameter` (the caller's option name), `reason` (`too_many`, `empty`, `too_long`, `disallowed_characters`, `not_normalized`, `multiline`, `required_with`, `conflicts_with`, `not_allowed`, `one_of_required`) and the values the reason names: `count` and `max`, `index` (0-based entry), `length` and `maxLength`, `characters`, `with` and `withValue` (the other option), `allowed` and `value`, `parameters` (the options to choose from). */
|
|
404
|
+
readonly INVALID_PARAMETER: "invalid_parameter";
|
|
405
|
+
/** A numeric option is outside its allowed range. Facts: `parameter` (the caller's option name), `value`, `min`, `max`, and `integer` when it must be a whole number. */
|
|
406
|
+
readonly PARAMETER_OUT_OF_RANGE: "parameter_out_of_range";
|
|
407
|
+
/** No ready caption track matches the requested track or language. Facts: `trackId` or `languageCode`, and what is available. */
|
|
408
|
+
readonly CAPTION_TRACK_NOT_FOUND: "caption_track_not_found";
|
|
409
|
+
/** The caption track has no language, so its source language can't be determined. Facts: `trackId`. */
|
|
410
|
+
readonly CAPTION_TRACK_LANGUAGE_MISSING: "caption_track_language_missing";
|
|
411
|
+
/** The asset has no public or signed playback ID (DRM-only assets included). */
|
|
412
|
+
readonly PLAYBACK_ID_NOT_FOUND: "playback_id_not_found";
|
|
413
|
+
/** Mux has no asset with the requested ID in this environment. Facts: `assetId`. */
|
|
414
|
+
readonly ASSET_NOT_FOUND: "asset_not_found";
|
|
415
|
+
/** The transcript has no usable content. */
|
|
416
|
+
readonly TRANSCRIPT_EMPTY: "transcript_empty";
|
|
417
|
+
/** The asset has no valid duration, so work that depends on it can't run. Facts: `assetId`. */
|
|
418
|
+
readonly ASSET_DURATION_UNAVAILABLE: "asset_duration_unavailable";
|
|
419
|
+
/** Mux won't add an audio track to this asset. Facts: `reason` (`clip`, `live_stream`, `audio_only`). */
|
|
420
|
+
readonly AUDIO_TRACK_UNSUPPORTED: "audio_track_unsupported";
|
|
421
|
+
/** The asset's existing static rendition can't be used as a source. Facts: `reason` (`unusable`, `too_large`) and the rendition's details. */
|
|
422
|
+
readonly STATIC_RENDITION_UNSUPPORTED: "static_rendition_unsupported";
|
|
423
|
+
/** Signed playback needs signing keys the service running the SDK didn't provide. */
|
|
424
|
+
readonly SIGNING_CREDENTIALS_MISSING: "signing_credentials_missing";
|
|
425
|
+
/** Storage is needed but the service running the SDK didn't configure it. */
|
|
426
|
+
readonly STORAGE_NOT_CONFIGURED: "storage_not_configured";
|
|
427
|
+
/** A track write failed, but the opted-in result carried no classified error: a bug in the SDK's track-write path. Facts: `reason`, the raw failure's message. */
|
|
428
|
+
readonly TRACK_WRITE_UNCLASSIFIED: "track_write_unclassified";
|
|
429
|
+
/** Mux answered a track create without a track id. The track may exist, so it isn't step-retried. Facts: `call`, `assetId`. */
|
|
430
|
+
readonly TRACK_ID_MISSING: "track_id_missing";
|
|
431
|
+
/** The asset's ready caption track has no id, so its transcript can't be fetched. Facts: `assetId`, `languageCode`. */
|
|
432
|
+
readonly CAPTION_TRACK_ID_MISSING: "caption_track_id_missing";
|
|
433
|
+
/** The asset snapshot the service running the SDK passed in is for a different asset than the one requested. Facts: `assetId`, `snapshotAssetId`. */
|
|
434
|
+
readonly ASSET_SNAPSHOT_MISMATCH: "asset_snapshot_mismatch";
|
|
435
|
+
/** Mux answered an asset fetch with a different asset than the one requested. Facts: `assetId`, `returnedAssetId`. */
|
|
436
|
+
readonly ASSET_ID_MISMATCH: "asset_id_mismatch";
|
|
437
|
+
/** Translation needed to split a chunk of fewer than two cues: a bug in the SDK's chunking. Facts: `chunkId`, `cueCount`. */
|
|
438
|
+
readonly TRANSLATION_CHUNK_UNSPLITTABLE: "translation_chunk_unsplittable";
|
|
439
|
+
/** The model provider refused the content. Facts: `reason` and `category`. */
|
|
440
|
+
readonly CONTENT_POLICY_BLOCKED: "content_policy_blocked";
|
|
441
|
+
/** The model returned no output, or a required field was empty. Facts: `call`, `provider`, `model`, and `assetId` when there is one. */
|
|
442
|
+
readonly MODEL_OUTPUT_MISSING: "model_output_missing";
|
|
443
|
+
/** The model's output breaks the expected shape or constraints (counts, allowed values, limits). Facts: `call`, `provider`, `model`, and `assetId` when there is one. */
|
|
444
|
+
readonly MODEL_OUTPUT_INVALID: "model_output_invalid";
|
|
445
|
+
/** The model's output was withheld by the SDK's output safety filter (a suspected prompt leak). */
|
|
446
|
+
readonly MODEL_OUTPUT_SUPPRESSED: "model_output_suppressed";
|
|
447
|
+
/** The model stopped early for a reason other than the length limit. */
|
|
448
|
+
readonly MODEL_OUTPUT_INCOMPLETE: "model_output_incomplete";
|
|
449
|
+
/** The model hit the output length limit. */
|
|
450
|
+
readonly MODEL_OUTPUT_TRUNCATED: "model_output_truncated";
|
|
451
|
+
/** Mux reported the static rendition a workflow needs as errored. */
|
|
452
|
+
readonly STATIC_RENDITION_FAILED: "static_rendition_failed";
|
|
453
|
+
/** The dubbing provider doesn't support the requested language. Facts: `language` and `which` (`target` or `source`). */
|
|
454
|
+
readonly DUBBING_LANGUAGE_UNSUPPORTED: "dubbing_language_unsupported";
|
|
455
|
+
/** The dubbing provider ran the dub and reported it failed. Facts: `providerError`, the provider's display text, when it gave one. */
|
|
456
|
+
readonly DUBBING_FAILED: "dubbing_failed";
|
|
457
|
+
/** The dubbing provider didn't finish the dub within the polling budget. Facts: `dubbingId`, `timeoutSeconds`, `lastStatus`. */
|
|
458
|
+
readonly DUBBING_TIMEOUT: "dubbing_timeout";
|
|
459
|
+
/** The asset has no audio track, so there is no audio to work with. Facts: `assetId`. */
|
|
460
|
+
readonly AUDIO_TRACK_MISSING: "audio_track_missing";
|
|
461
|
+
/** Writing an audio track would replace the asset's primary audio track, which can't be replaced. Facts: `languageCode`, `conflictingTracks`. */
|
|
462
|
+
readonly PRIMARY_AUDIO_TRACK_CONFLICT: "primary_audio_track_conflict";
|
|
463
|
+
/** The asset's static rendition settings changed while waiting for its rendition. A new job uses the new settings. Facts: `assetId`. */
|
|
464
|
+
readonly STATIC_RENDITION_CHANGED: "static_rendition_changed";
|
|
465
|
+
/** Mux didn't finish the static rendition within the polling budget. Facts: `assetId`, `attempts`, `pollIntervalMs`, `lastStatus`. */
|
|
466
|
+
readonly STATIC_RENDITION_TIMEOUT: "static_rendition_timeout";
|
|
467
|
+
};
|
|
468
|
+
type MuxAiErrorCode = typeof MUX_AI_ERROR_CODES[keyof typeof MUX_AI_ERROR_CODES];
|
|
469
|
+
declare const MUX_AI_ERROR_CODE_VALUES: readonly MuxAiErrorCode[];
|
|
470
|
+
/** The classification and retry policy each code implies. */
|
|
471
|
+
declare const MUX_AI_ERROR_CATALOG: {
|
|
472
|
+
readonly invalid_scope: {
|
|
473
|
+
readonly type: "validation_error";
|
|
474
|
+
readonly source: "request";
|
|
475
|
+
};
|
|
476
|
+
readonly track_replacement_blocked: {
|
|
477
|
+
readonly type: "validation_error";
|
|
478
|
+
readonly source: "request";
|
|
479
|
+
};
|
|
480
|
+
readonly invalid_parameter: {
|
|
481
|
+
readonly type: "validation_error";
|
|
482
|
+
readonly source: "request";
|
|
483
|
+
};
|
|
484
|
+
readonly parameter_out_of_range: {
|
|
485
|
+
readonly type: "validation_error";
|
|
486
|
+
readonly source: "request";
|
|
487
|
+
};
|
|
488
|
+
readonly asset_not_found: {
|
|
489
|
+
readonly type: "validation_error";
|
|
490
|
+
readonly source: "request";
|
|
491
|
+
readonly dependency: "mux_video";
|
|
492
|
+
};
|
|
493
|
+
readonly caption_track_not_found: {
|
|
494
|
+
readonly type: "validation_error";
|
|
495
|
+
readonly source: "asset";
|
|
496
|
+
};
|
|
497
|
+
readonly playback_id_not_found: {
|
|
498
|
+
readonly type: "validation_error";
|
|
499
|
+
readonly source: "asset";
|
|
500
|
+
};
|
|
501
|
+
readonly asset_duration_unavailable: {
|
|
502
|
+
readonly type: "validation_error";
|
|
503
|
+
readonly source: "asset";
|
|
504
|
+
};
|
|
505
|
+
readonly transcript_empty: {
|
|
506
|
+
readonly type: "validation_error";
|
|
507
|
+
readonly source: "asset";
|
|
508
|
+
};
|
|
509
|
+
readonly audio_track_unsupported: {
|
|
510
|
+
readonly type: "validation_error";
|
|
511
|
+
readonly source: "asset";
|
|
512
|
+
};
|
|
513
|
+
readonly static_rendition_unsupported: {
|
|
514
|
+
readonly type: "validation_error";
|
|
515
|
+
readonly source: "asset";
|
|
516
|
+
};
|
|
517
|
+
readonly signing_credentials_missing: {
|
|
518
|
+
readonly type: "server_error";
|
|
519
|
+
readonly source: "internal";
|
|
520
|
+
};
|
|
521
|
+
readonly storage_not_configured: {
|
|
522
|
+
readonly type: "server_error";
|
|
523
|
+
readonly source: "internal";
|
|
524
|
+
};
|
|
525
|
+
readonly asset_snapshot_mismatch: {
|
|
526
|
+
readonly type: "server_error";
|
|
527
|
+
readonly source: "internal";
|
|
528
|
+
};
|
|
529
|
+
readonly track_write_unclassified: {
|
|
530
|
+
readonly type: "server_error";
|
|
531
|
+
readonly source: "internal";
|
|
532
|
+
};
|
|
533
|
+
readonly translation_chunk_unsplittable: {
|
|
534
|
+
readonly type: "server_error";
|
|
535
|
+
readonly source: "internal";
|
|
536
|
+
};
|
|
537
|
+
readonly caption_track_language_missing: {
|
|
538
|
+
readonly type: "validation_error";
|
|
539
|
+
readonly source: "asset";
|
|
540
|
+
};
|
|
541
|
+
readonly track_id_missing: {
|
|
542
|
+
readonly type: "processing_error";
|
|
543
|
+
readonly source: "upstream";
|
|
544
|
+
readonly dependency: "mux_video";
|
|
545
|
+
};
|
|
546
|
+
readonly caption_track_id_missing: {
|
|
547
|
+
readonly type: "processing_error";
|
|
548
|
+
readonly source: "upstream";
|
|
549
|
+
readonly dependency: "mux_video";
|
|
550
|
+
};
|
|
551
|
+
readonly asset_id_mismatch: {
|
|
552
|
+
readonly type: "processing_error";
|
|
553
|
+
readonly source: "upstream";
|
|
554
|
+
readonly dependency: "mux_video";
|
|
555
|
+
};
|
|
556
|
+
readonly content_policy_blocked: {
|
|
557
|
+
readonly type: "content_policy_error";
|
|
558
|
+
readonly source: "asset";
|
|
559
|
+
readonly dependency: "ai_provider";
|
|
560
|
+
};
|
|
561
|
+
readonly model_output_missing: {
|
|
562
|
+
readonly type: "processing_error";
|
|
563
|
+
readonly source: "upstream";
|
|
564
|
+
readonly dependency: "ai_provider";
|
|
565
|
+
readonly transient: false;
|
|
566
|
+
readonly retryable: false;
|
|
567
|
+
};
|
|
568
|
+
readonly model_output_invalid: {
|
|
569
|
+
readonly type: "processing_error";
|
|
570
|
+
readonly source: "upstream";
|
|
571
|
+
readonly dependency: "ai_provider";
|
|
572
|
+
readonly transient: false;
|
|
573
|
+
readonly retryable: false;
|
|
574
|
+
};
|
|
575
|
+
readonly model_output_suppressed: {
|
|
576
|
+
readonly type: "processing_error";
|
|
577
|
+
readonly source: "upstream";
|
|
578
|
+
readonly dependency: "ai_provider";
|
|
579
|
+
readonly transient: false;
|
|
580
|
+
readonly retryable: false;
|
|
581
|
+
};
|
|
582
|
+
readonly model_output_incomplete: {
|
|
583
|
+
readonly type: "processing_error";
|
|
584
|
+
readonly source: "upstream";
|
|
585
|
+
readonly dependency: "ai_provider";
|
|
586
|
+
readonly transient: false;
|
|
587
|
+
readonly retryable: true;
|
|
588
|
+
};
|
|
589
|
+
readonly model_output_truncated: {
|
|
590
|
+
readonly type: "processing_error";
|
|
591
|
+
readonly source: "internal";
|
|
592
|
+
readonly dependency: "ai_provider";
|
|
593
|
+
};
|
|
594
|
+
readonly static_rendition_failed: {
|
|
595
|
+
readonly type: "processing_error";
|
|
596
|
+
readonly source: "upstream";
|
|
597
|
+
readonly dependency: "mux_video";
|
|
598
|
+
readonly transient: false;
|
|
599
|
+
readonly retryable: false;
|
|
600
|
+
};
|
|
601
|
+
readonly dubbing_language_unsupported: {
|
|
602
|
+
readonly type: "validation_error";
|
|
603
|
+
readonly source: "request";
|
|
604
|
+
readonly dependency: "ai_provider";
|
|
605
|
+
};
|
|
606
|
+
readonly dubbing_failed: {
|
|
607
|
+
readonly type: "processing_error";
|
|
608
|
+
readonly source: "upstream";
|
|
609
|
+
readonly dependency: "ai_provider";
|
|
610
|
+
readonly transient: false;
|
|
611
|
+
readonly retryable: true;
|
|
612
|
+
};
|
|
613
|
+
readonly dubbing_timeout: {
|
|
614
|
+
readonly type: "timeout_error";
|
|
615
|
+
readonly source: "upstream";
|
|
616
|
+
readonly dependency: "ai_provider";
|
|
617
|
+
readonly transient: false;
|
|
618
|
+
readonly retryable: true;
|
|
619
|
+
};
|
|
620
|
+
readonly static_rendition_timeout: {
|
|
621
|
+
readonly type: "timeout_error";
|
|
622
|
+
readonly source: "upstream";
|
|
623
|
+
readonly dependency: "mux_video";
|
|
624
|
+
readonly transient: false;
|
|
625
|
+
readonly retryable: true;
|
|
626
|
+
};
|
|
627
|
+
readonly audio_track_missing: {
|
|
628
|
+
readonly type: "validation_error";
|
|
629
|
+
readonly source: "asset";
|
|
630
|
+
};
|
|
631
|
+
readonly primary_audio_track_conflict: {
|
|
632
|
+
readonly type: "validation_error";
|
|
633
|
+
readonly source: "asset";
|
|
634
|
+
};
|
|
635
|
+
readonly static_rendition_changed: {
|
|
636
|
+
readonly type: "processing_error";
|
|
637
|
+
readonly source: "asset";
|
|
638
|
+
readonly retryable: true;
|
|
639
|
+
};
|
|
640
|
+
};
|
|
641
|
+
interface ModelCallDiagnostics {
|
|
642
|
+
phase: "brief" | "draft" | "format_repair" | "length_repair";
|
|
643
|
+
provider: string;
|
|
644
|
+
modelId: string;
|
|
645
|
+
maxOutputTokens?: number;
|
|
646
|
+
}
|
|
647
|
+
/**
|
|
648
|
+
* No response, a timeout, "too early", rate limiting or a server error: worth retrying.
|
|
649
|
+
* A 409 is not: unlike the AI SDK's own retry loop, a conflict here means state that
|
|
650
|
+
* a retry would hit again.
|
|
651
|
+
*/
|
|
652
|
+
declare function isTransientStatus(status: number | undefined): boolean;
|
|
653
|
+
/** A short record of one raw cause, kept across step boundaries in place of the cause itself. */
|
|
654
|
+
interface ErrorCauseSummary {
|
|
655
|
+
name: string;
|
|
656
|
+
message: string;
|
|
657
|
+
status?: number;
|
|
658
|
+
}
|
|
659
|
+
/**
|
|
660
|
+
* The classification a coded site states: the code, and the type, source and dependency
|
|
661
|
+
* its catalog entry implies. Each code accepts only its own, so a site reads on its own
|
|
662
|
+
* and can't contradict the catalog.
|
|
663
|
+
*/
|
|
664
|
+
type CodedClassification<TCatalog extends Readonly<Record<string, ErrorCatalogEntry>>> = {
|
|
665
|
+
[C in keyof TCatalog & string]: {
|
|
666
|
+
code: C;
|
|
667
|
+
type: TCatalog[C]["type"];
|
|
668
|
+
source: TCatalog[C]["source"];
|
|
669
|
+
} & (TCatalog[C] extends {
|
|
670
|
+
dependency: infer D extends string;
|
|
671
|
+
} ? {
|
|
672
|
+
dependency: D;
|
|
673
|
+
} : {
|
|
674
|
+
dependency?: never;
|
|
675
|
+
});
|
|
676
|
+
}[keyof TCatalog & string];
|
|
677
|
+
/**
|
|
678
|
+
* How a site classifies an error: always a type and source (with the dependency for an
|
|
679
|
+
* `upstream` failure), plus a code when the condition has one, plus what varies. With a
|
|
680
|
+
* catalog type (`TCatalog`), a code accepts only the type, source and dependency its
|
|
681
|
+
* catalog entry implies.
|
|
682
|
+
*/
|
|
683
|
+
type ClassifiedErrorInit<TType extends string, TCode extends string, TDependency extends string, TCatalog extends Readonly<Record<string, ErrorCatalogEntry>> = never> = (([TCatalog] extends [never] ? ({
|
|
684
|
+
code: TCode;
|
|
685
|
+
type: TType;
|
|
686
|
+
} & SourceAndDependency<TDependency>) : CodedClassification<TCatalog>) | ({
|
|
687
|
+
code?: never;
|
|
688
|
+
type: TType;
|
|
689
|
+
} & SourceAndDependency<TDependency>)) & {
|
|
690
|
+
facts?: MuxAiErrorFacts;
|
|
691
|
+
/**
|
|
692
|
+
* Whether submitting the same job again, unchanged, may succeed. Not "fixable":
|
|
693
|
+
* whether the caller can change something first is what `source` and `code` say.
|
|
694
|
+
* Defaults from the classification ({@link defaultRetryable}); set it only to
|
|
695
|
+
* override, with a comment saying why. Ignored when the error is transient.
|
|
696
|
+
*/
|
|
697
|
+
retryable?: boolean;
|
|
698
|
+
/**
|
|
699
|
+
* Whether the step runner should retry the step. Defaults from the classification
|
|
700
|
+
* ({@link defaultTransient}); set it only to override, with a comment saying why
|
|
701
|
+
* (e.g. a call that isn't idempotent).
|
|
702
|
+
*/
|
|
703
|
+
transient?: boolean;
|
|
704
|
+
/** The raw cause. Kept locally only; a bounded summary crosses step boundaries. */
|
|
705
|
+
cause?: unknown;
|
|
706
|
+
};
|
|
707
|
+
type MuxAiErrorInit = ClassifiedErrorInit<MuxAiErrorType, MuxAiErrorCode, MuxAiErrorDependency, typeof MUX_AI_ERROR_CATALOG>;
|
|
708
|
+
/**
|
|
709
|
+
* A classified error's fields as JSON-safe data, for a subclass's Workflow serializer
|
|
710
|
+
* (see {@link serializeClassification} and {@link restoreClassification}).
|
|
711
|
+
*/
|
|
712
|
+
interface SerializedClassification<TType extends string = string, TCode extends string = string, TDependency extends string = string> {
|
|
713
|
+
message: string;
|
|
714
|
+
type: TType;
|
|
715
|
+
source: MuxAiErrorSource;
|
|
716
|
+
dependency?: TDependency;
|
|
717
|
+
code?: TCode;
|
|
718
|
+
facts: MuxAiErrorFacts;
|
|
719
|
+
retryable: boolean;
|
|
720
|
+
transient: boolean;
|
|
721
|
+
causes: ErrorCauseSummary[];
|
|
722
|
+
stack?: string;
|
|
723
|
+
}
|
|
724
|
+
/**
|
|
725
|
+
* What crosses a Workflow step boundary. A run replays the events it already wrote,
|
|
726
|
+
* so `v` is bumped on a shape change and earlier versions stay readable.
|
|
727
|
+
*/
|
|
728
|
+
interface SerializedMuxAiError extends SerializedClassification<MuxAiErrorType, MuxAiErrorCode, MuxAiErrorDependency> {
|
|
729
|
+
v: 2;
|
|
730
|
+
usage?: TokenUsage;
|
|
731
|
+
finishReason?: string;
|
|
732
|
+
rawFinishReason?: string;
|
|
733
|
+
diagnostics?: ModelCallDiagnostics;
|
|
734
|
+
}
|
|
735
|
+
/**
|
|
736
|
+
* The shared error model: a `type` and `source` on every instance, a `dependency`
|
|
737
|
+
* for remote failures, a `code` for conditions precise enough to name, JSON-safe
|
|
738
|
+
* `facts`, and a retry policy derived from the classification. `message` is internal
|
|
739
|
+
* detail, never end-user text (see `createPublicErrorView()`).
|
|
740
|
+
*
|
|
741
|
+
* `MuxAiError` is built on it, and consumers can build their own errors on it with
|
|
742
|
+
* their own type list, code catalog and dependencies, so policy, serialization and
|
|
743
|
+
* the public view work the same way everywhere. A subclass supplies its catalog,
|
|
744
|
+
* a brand for its own `is()`, and Workflow serializer hooks built from
|
|
745
|
+
* {@link serializeClassification} and {@link restoreClassification}.
|
|
746
|
+
*/
|
|
747
|
+
declare class ClassifiedError<TType extends string = string, TCode extends string = string, TDependency extends string = string> extends Error {
|
|
748
|
+
/** Structural brand shared by every classified error, for duck-type identification across realms. */
|
|
749
|
+
readonly __classified_error = true;
|
|
750
|
+
readonly type: TType;
|
|
751
|
+
readonly source: MuxAiErrorSource;
|
|
752
|
+
readonly dependency?: TDependency;
|
|
753
|
+
readonly code?: TCode;
|
|
754
|
+
readonly facts: MuxAiErrorFacts;
|
|
755
|
+
/** Whether submitting the same job again, unchanged, may succeed. Always true when transient. */
|
|
756
|
+
readonly retryable: boolean;
|
|
757
|
+
/**
|
|
758
|
+
* Whether the step runner should retry the step. Workflow DevKit skips retries
|
|
759
|
+
* for errors named `FatalError`, so only non-transient errors take that name.
|
|
760
|
+
*/
|
|
761
|
+
readonly transient: boolean;
|
|
762
|
+
/** Raw cause; non-enumerable, local only. */
|
|
763
|
+
readonly cause?: unknown;
|
|
764
|
+
/** Bounded summary of the cause chain; non-enumerable, crosses step boundaries. */
|
|
765
|
+
readonly causes: ErrorCauseSummary[];
|
|
766
|
+
constructor(message: string, init: ClassifiedErrorInit<TType, TCode, TDependency>, catalog: Readonly<Partial<Record<TCode, ErrorCatalogEntry<TType, TDependency>>>>);
|
|
767
|
+
/** Whether `value` is any classified error, from this copy of the SDK or another. */
|
|
768
|
+
static isClassified(value: unknown): value is ClassifiedError;
|
|
769
|
+
}
|
|
770
|
+
/** The classification of `error`, for a subclass's `WORKFLOW_SERIALIZE` hook. */
|
|
771
|
+
declare function serializeClassification<TType extends string, TCode extends string, TDependency extends string>(error: ClassifiedError<TType, TCode, TDependency>): SerializedClassification<TType, TCode, TDependency>;
|
|
772
|
+
/**
|
|
773
|
+
* The constructor options that rebuild a serialized classification, for a
|
|
774
|
+
* subclass's `WORKFLOW_DESERIALIZE` hook; follow with {@link restoreClassification}.
|
|
775
|
+
* The stored classification wins over the catalog's current mapping for a code.
|
|
776
|
+
*/
|
|
777
|
+
declare function classificationInit<TType extends string, TCode extends string, TDependency extends string>(record: SerializedClassification<TType, TCode, TDependency>): ClassifiedErrorInit<TType, TCode, TDependency>;
|
|
778
|
+
/** Restores what the constructor can't take back: the code, the cause summaries and the stack. */
|
|
779
|
+
declare function restoreClassification<T extends ClassifiedError>(error: T, record: SerializedClassification): T;
|
|
780
|
+
/**
|
|
781
|
+
* A classified @mux/ai failure, built on {@link ClassifiedError} with the SDK's
|
|
782
|
+
* catalog. `message` is internal detail for developers and logs, never end-user
|
|
783
|
+
* text: render what end users see with `toPublicError()`, which only exposes
|
|
784
|
+
* allowlisted codes and facts. See docs/ERRORS.md.
|
|
785
|
+
*
|
|
786
|
+
* Fields, not subclasses, carry the classification: a custom Workflow codec keeps
|
|
787
|
+
* them across step boundaries, and every subclass revives as `MuxAiError`.
|
|
788
|
+
*/
|
|
789
|
+
declare class MuxAiError extends ClassifiedError<MuxAiErrorType, MuxAiErrorCode, MuxAiErrorDependency> {
|
|
790
|
+
/** Structural brand for duck-type identification across copies of the SDK. */
|
|
791
|
+
readonly __mux_ai_error = true;
|
|
792
|
+
usage?: TokenUsage;
|
|
793
|
+
diagnostics?: ModelCallDiagnostics;
|
|
794
|
+
constructor(message: string, init: MuxAiErrorInit);
|
|
795
|
+
static is(value: unknown): value is MuxAiError;
|
|
796
|
+
static [WORKFLOW_SERIALIZE](instance: MuxAiError): SerializedMuxAiError | LegacySerializedMuxAiError;
|
|
797
|
+
static [WORKFLOW_DESERIALIZE](value: SerializedMuxAiError): MuxAiError;
|
|
798
|
+
}
|
|
799
|
+
/**
|
|
800
|
+
* Prepares free text from a dependency (a provider's failure reason, a raw error
|
|
801
|
+
* message) for an error's facts: URL tokens stripped, high-confidence prompt leaks
|
|
802
|
+
* suppressed, length capped.
|
|
803
|
+
*/
|
|
804
|
+
declare function errorDetailFact(text: string, maxLength?: number): string;
|
|
805
|
+
/**
|
|
806
|
+
* Re-throws a classified error unchanged, merging any `facts` into it (its own
|
|
807
|
+
* values win). Anything else becomes an `internal` error: a remote failure would
|
|
808
|
+
* already have been classified where the call was made, so what reaches here
|
|
809
|
+
* unclassified is this code's own failure.
|
|
810
|
+
*
|
|
811
|
+
* Use this in catch blocks that re-throw, so a classified error from a callee
|
|
812
|
+
* keeps its classification. Token usage carries over either way.
|
|
813
|
+
*/
|
|
814
|
+
declare function wrapError(error: unknown, message: string, facts?: MuxAiErrorFacts): never;
|
|
815
|
+
/**
|
|
816
|
+
* This code's own failure: a broken invariant, an unexpected shape it produced, or
|
|
817
|
+
* an in-process library throwing. Use it instead of `throw new Error(...)`.
|
|
818
|
+
*/
|
|
819
|
+
declare function internalError(message: string, facts?: MuxAiErrorFacts, cause?: unknown): MuxAiError;
|
|
820
|
+
/** Exhaustiveness guard for switch statements over closed unions. */
|
|
821
|
+
declare function assertNever(value: never, what?: string): never;
|
|
822
|
+
|
|
823
|
+
interface Hotspot {
|
|
824
|
+
/** Inclusive start time in milliseconds */
|
|
825
|
+
startMs: number;
|
|
826
|
+
/** Exclusive end time in milliseconds */
|
|
827
|
+
endMs: number;
|
|
828
|
+
/** Hotspot score using distribution-based normalization (0-1) */
|
|
829
|
+
score: number;
|
|
830
|
+
}
|
|
831
|
+
interface HotspotOptions {
|
|
832
|
+
/** Maximum number of hotspots to return (default: 5) */
|
|
833
|
+
limit?: number;
|
|
834
|
+
/** Sort order: 'asc' or 'desc' (default: 'desc') */
|
|
835
|
+
orderDirection?: "asc" | "desc";
|
|
836
|
+
/** @deprecated The API always orders by score; this option is ignored. */
|
|
837
|
+
orderBy?: "score";
|
|
838
|
+
/** Time window for results, e.g., '7:days' (default: '7:days') */
|
|
839
|
+
timeframe?: string;
|
|
840
|
+
/** Optional workflow credentials */
|
|
841
|
+
credentials?: WorkflowCredentialsInput;
|
|
842
|
+
}
|
|
843
|
+
interface HotspotResponse {
|
|
844
|
+
assetId?: string;
|
|
845
|
+
videoId?: string;
|
|
846
|
+
playbackId?: string;
|
|
847
|
+
hotspots: Hotspot[];
|
|
848
|
+
}
|
|
849
|
+
/**
|
|
850
|
+
* Fetches engagement hotspots for a Mux asset.
|
|
851
|
+
* Returns the top N "hot" time ranges based on engagement data.
|
|
852
|
+
*
|
|
853
|
+
* @param assetId - The Mux asset ID
|
|
854
|
+
* @param options - Hotspot query options
|
|
855
|
+
* @returns Array of hotspots with time ranges and scores
|
|
856
|
+
*/
|
|
857
|
+
declare function getHotspotsForAsset(assetId: string, options?: HotspotOptions): Promise<Hotspot[]>;
|
|
858
|
+
/**
|
|
859
|
+
* Fetches engagement hotspots for a Mux video ID.
|
|
860
|
+
* Returns the top N "hot" time ranges based on engagement data.
|
|
861
|
+
*
|
|
862
|
+
* @param videoId - The Mux video ID
|
|
863
|
+
* @param options - Hotspot query options
|
|
864
|
+
* @returns Array of hotspots with time ranges and scores
|
|
865
|
+
*/
|
|
866
|
+
declare function getHotspotsForVideo(videoId: string, options?: HotspotOptions): Promise<Hotspot[]>;
|
|
867
|
+
/**
|
|
868
|
+
* Fetches engagement hotspots for a Mux playback ID.
|
|
869
|
+
* Returns the top N "hot" time ranges based on engagement data.
|
|
870
|
+
*
|
|
871
|
+
* @param playbackId - The Mux playback ID
|
|
872
|
+
* @param options - Hotspot query options
|
|
873
|
+
* @returns Array of hotspots with time ranges and scores
|
|
874
|
+
*/
|
|
875
|
+
declare function getHotspotsForPlaybackId(playbackId: string, options?: HotspotOptions): Promise<Hotspot[]>;
|
|
876
|
+
|
|
877
|
+
interface Shot {
|
|
878
|
+
/** Start time of the shot in seconds from the beginning of the asset. */
|
|
879
|
+
startTime: number;
|
|
880
|
+
/** Signed URL for a representative image of the shot. */
|
|
881
|
+
imageUrl: string;
|
|
882
|
+
}
|
|
883
|
+
interface PendingShotsResult {
|
|
884
|
+
status: "pending";
|
|
885
|
+
createdAt: string;
|
|
886
|
+
}
|
|
887
|
+
interface ErroredShotsResult {
|
|
888
|
+
status: "errored";
|
|
889
|
+
createdAt: string;
|
|
890
|
+
error: {
|
|
891
|
+
type: string;
|
|
892
|
+
messages: string[];
|
|
893
|
+
};
|
|
894
|
+
}
|
|
895
|
+
interface CompletedShotsResult {
|
|
896
|
+
status: "completed";
|
|
897
|
+
createdAt: string;
|
|
898
|
+
shots: Shot[];
|
|
899
|
+
}
|
|
900
|
+
/** Mux declined to run shot detection, e.g. the asset has no video track. */
|
|
901
|
+
interface SkippedShotsResult {
|
|
902
|
+
status: "skipped";
|
|
903
|
+
createdAt: string;
|
|
904
|
+
}
|
|
905
|
+
interface DeletedShotsResult {
|
|
906
|
+
status: "deleted";
|
|
907
|
+
createdAt: string;
|
|
908
|
+
}
|
|
909
|
+
type ShotsResult = PendingShotsResult | ErroredShotsResult | CompletedShotsResult | SkippedShotsResult | DeletedShotsResult;
|
|
910
|
+
interface ShotRequestOptions {
|
|
911
|
+
/** Optional workflow credentials */
|
|
912
|
+
credentials?: WorkflowCredentialsInput;
|
|
913
|
+
}
|
|
914
|
+
interface WaitForShotsOptions extends ShotRequestOptions {
|
|
915
|
+
/** Polling interval in milliseconds (default: 2000, minimum enforced: 1000) */
|
|
916
|
+
pollIntervalMs?: number;
|
|
917
|
+
/** Maximum number of polling attempts (default: 60) */
|
|
918
|
+
maxAttempts?: number;
|
|
919
|
+
/** When true, request shot generation before polling (default: true) */
|
|
920
|
+
createIfMissing?: boolean;
|
|
921
|
+
}
|
|
922
|
+
/**
|
|
923
|
+
* Starts generating shots for an asset.
|
|
924
|
+
*
|
|
925
|
+
* @param assetId - The Mux asset ID
|
|
926
|
+
* @param options - Request options
|
|
927
|
+
* @returns Pending shot generation state
|
|
928
|
+
*/
|
|
929
|
+
declare function requestShotsForAsset(assetId: string, options?: ShotRequestOptions): Promise<PendingShotsResult>;
|
|
930
|
+
/**
|
|
931
|
+
* Gets the current shot generation status for an asset.
|
|
932
|
+
*
|
|
933
|
+
* @param assetId - The Mux asset ID
|
|
934
|
+
* @param options - Request options
|
|
935
|
+
* @returns Pending, errored, or completed shot result
|
|
936
|
+
*/
|
|
937
|
+
declare function getShotsForAsset(assetId: string, options?: ShotRequestOptions): Promise<ShotsResult>;
|
|
938
|
+
/**
|
|
939
|
+
* Requests shot generation if needed and polls until shots are completed.
|
|
940
|
+
*
|
|
941
|
+
* @param assetId - The Mux asset ID
|
|
942
|
+
* @param options - Polling options
|
|
943
|
+
* @returns Completed shot result
|
|
944
|
+
*/
|
|
945
|
+
declare function waitForShotsForAsset(assetId: string, options?: WaitForShotsOptions): Promise<CompletedShotsResult>;
|
|
946
|
+
|
|
947
|
+
/** A single cue from a VTT file with timing info. */
|
|
948
|
+
interface VTTCue {
|
|
949
|
+
startTime: number;
|
|
950
|
+
endTime: number;
|
|
951
|
+
text: string;
|
|
952
|
+
}
|
|
953
|
+
interface TranscriptFetchOptions extends ClassifiedErrorsOption {
|
|
954
|
+
languageCode?: string;
|
|
955
|
+
cleanTranscript?: boolean;
|
|
956
|
+
/** Optional asset-relative time range used to filter transcript cues. */
|
|
957
|
+
scope?: WorkflowScope;
|
|
958
|
+
/** Optional signing context for signed playback IDs */
|
|
959
|
+
shouldSign?: boolean;
|
|
960
|
+
credentials?: WorkflowCredentialsInput;
|
|
961
|
+
/**
|
|
962
|
+
* When true, throws a customer-safe `MuxAiError` if no usable transcript can
|
|
963
|
+
* be retrieved (no ready text track, missing track id, or empty transcript).
|
|
964
|
+
*
|
|
965
|
+
* Default behavior is non-fatal and returns an empty `transcriptText`.
|
|
966
|
+
*/
|
|
967
|
+
required?: boolean;
|
|
968
|
+
}
|
|
969
|
+
interface TranscriptResult {
|
|
970
|
+
transcriptText: string;
|
|
971
|
+
transcriptUrl?: string;
|
|
972
|
+
track?: AssetTextTrack;
|
|
973
|
+
}
|
|
974
|
+
declare function getReadyTextTracks(asset: MuxAsset): AssetTextTrack[];
|
|
975
|
+
declare function findCaptionTrack(asset: MuxAsset, languageCode?: string): AssetTextTrack | undefined;
|
|
976
|
+
/**
|
|
977
|
+
* Default minimum auto-detection confidence required to trust a track's language code.
|
|
978
|
+
* Below this threshold, the language is treated as undetermined.
|
|
979
|
+
*/
|
|
980
|
+
declare const LOW_CONFIDENCE_THRESHOLD = 0.5;
|
|
981
|
+
/**
|
|
982
|
+
* Extracts a trustworthy language code from a track, returning `undefined`
|
|
983
|
+
* when the language metadata shouldn't be used as an LLM output language.
|
|
984
|
+
*
|
|
985
|
+
* Returns `undefined` when:
|
|
986
|
+
* - The track or its language code is missing
|
|
987
|
+
* - The language code is undetermined (`und`, `mul`, `mis`, `zxx`)
|
|
988
|
+
* - The language was auto-detected with confidence below the threshold
|
|
989
|
+
*
|
|
990
|
+
* Trusts the language code when:
|
|
991
|
+
* - `auto_language_confidence` is absent (manually set or non-auto tracks)
|
|
992
|
+
* - `auto_language_confidence` meets the threshold
|
|
993
|
+
*
|
|
994
|
+
* @param track - The text track to inspect
|
|
995
|
+
* @param confidenceThreshold - Minimum confidence to trust auto-detected language (default: {@link LOW_CONFIDENCE_THRESHOLD})
|
|
996
|
+
*/
|
|
997
|
+
declare function getReliableLanguageCode(track: AssetTextTrack | undefined, confidenceThreshold?: number): string | undefined;
|
|
998
|
+
/**
|
|
999
|
+
* Sanitise untrusted text (typically a VTT cue or joined transcript)
|
|
1000
|
+
* before it is interpolated into a prompt. Thin wrapper around the
|
|
1001
|
+
* shared {@link normalizeUntrustedUnicode} helper, with a null/empty
|
|
1002
|
+
* guard for convenience.
|
|
1003
|
+
*/
|
|
1004
|
+
declare function sanitizeUntrustedText(value: string): string;
|
|
1005
|
+
/**
|
|
1006
|
+
* Upper bound on individual cue text length before we consider the cue
|
|
1007
|
+
* adversarial and truncate it.
|
|
1008
|
+
*
|
|
1009
|
+
* Legitimate captions are short — a long monologue cue rarely exceeds
|
|
1010
|
+
* 500 characters, and most captioning standards recommend well under
|
|
1011
|
+
* that for readability. We set the cap at 2000 to give comfortable
|
|
1012
|
+
* headroom for edge cases (stage directions, speaker identification,
|
|
1013
|
+
* multi-line blocks) while making "hide a multi-kilobyte injection
|
|
1014
|
+
* payload inside a single cue" mechanically infeasible.
|
|
1015
|
+
*/
|
|
1016
|
+
declare const MAX_CUE_TEXT_CHARS = 2000;
|
|
1017
|
+
/**
|
|
1018
|
+
* Strip VTT metadata blocks that are never rendered by players but can
|
|
1019
|
+
* still carry text through to an LLM when the raw VTT is used in a prompt:
|
|
1020
|
+
*
|
|
1021
|
+
* - NOTE blocks (VTT comments)
|
|
1022
|
+
* - STYLE blocks (CSS for cue styling)
|
|
1023
|
+
* - REGION blocks (positioning definitions)
|
|
1024
|
+
*
|
|
1025
|
+
* Viewers never see the contents of these blocks. That makes them an
|
|
1026
|
+
* ideal hiding spot for prompt-injection payloads — an attacker-controlled
|
|
1027
|
+
* caption file can carry hundreds of bytes of "NOTE ignore previous
|
|
1028
|
+
* instructions…" that will be stripped from any player but will reach the
|
|
1029
|
+
* model if the raw VTT is passed through. Removing them before sending
|
|
1030
|
+
* the VTT to the model closes that channel without changing what the
|
|
1031
|
+
* model sees for legitimate cue content.
|
|
1032
|
+
*
|
|
1033
|
+
* Cue identifiers, timing lines, and cue payload text are preserved.
|
|
1034
|
+
* In particular: a cue whose first payload line happens to start with
|
|
1035
|
+
* `NOTE `/`STYLE `/`REGION ` (plausible in legitimate captions — e.g.
|
|
1036
|
+
* `"NOTE THAT..."`, `"STYLE GUIDE"`, `"NOTE how the villain plots..."`)
|
|
1037
|
+
* is NOT treated as a metadata block. The scanner tracks cue-payload
|
|
1038
|
+
* state: metadata headers are only recognised between cues (i.e. when
|
|
1039
|
+
* the previous non-blank line was not a timing line).
|
|
1040
|
+
*
|
|
1041
|
+
* Example input:
|
|
1042
|
+
*
|
|
1043
|
+
* WEBVTT
|
|
1044
|
+
*
|
|
1045
|
+
* NOTE This is a comment with hidden instructions
|
|
1046
|
+
* that span multiple lines until a blank line appears.
|
|
1047
|
+
*
|
|
1048
|
+
* STYLE
|
|
1049
|
+
* ::cue(b) { font-weight: bold; }
|
|
1050
|
+
*
|
|
1051
|
+
* 00:00:01.000 --> 00:00:04.000
|
|
1052
|
+
* Legitimate caption text
|
|
1053
|
+
*
|
|
1054
|
+
* 00:00:05.000 --> 00:00:08.000
|
|
1055
|
+
* NOTE THAT the hero wins
|
|
1056
|
+
*
|
|
1057
|
+
* Returns:
|
|
1058
|
+
*
|
|
1059
|
+
* WEBVTT
|
|
1060
|
+
*
|
|
1061
|
+
* 00:00:01.000 --> 00:00:04.000
|
|
1062
|
+
* Legitimate caption text
|
|
1063
|
+
*
|
|
1064
|
+
* 00:00:05.000 --> 00:00:08.000
|
|
1065
|
+
* NOTE THAT the hero wins
|
|
1066
|
+
*/
|
|
1067
|
+
declare function stripVttMetadataBlocks(vttContent: string): string;
|
|
1068
|
+
declare function extractTextFromVTT(vttContent: string): string;
|
|
1069
|
+
/**
|
|
1070
|
+
* Converts a WebVTT timestamp (`HH:MM:SS.mmm` or `MM:SS.mmm`) to seconds.
|
|
1071
|
+
*
|
|
1072
|
+
* @param timestamp - The timestamp to convert
|
|
1073
|
+
* @returns The timestamp in seconds, or `undefined` if it is malformed
|
|
1074
|
+
*/
|
|
1075
|
+
declare function vttTimestampToSeconds(timestamp: string): number | undefined;
|
|
1076
|
+
/**
|
|
1077
|
+
* Converts seconds to a human-readable timestamp.
|
|
1078
|
+
* Returns M:SS for durations under an hour, H:MM:SS for an hour or more.
|
|
1079
|
+
*
|
|
1080
|
+
* @param seconds - The number of seconds to convert
|
|
1081
|
+
* @returns A formatted timestamp string (e.g., "2:05" or "01:02:05")
|
|
1082
|
+
*/
|
|
1083
|
+
declare function secondsToTimestamp(seconds: number): string;
|
|
1084
|
+
declare function extractTimestampedTranscript(vttContent: string): string;
|
|
1085
|
+
interface ParseVTTCuesOptions {
|
|
1086
|
+
/**
|
|
1087
|
+
* Truncate each cue's text to {@link MAX_CUE_TEXT_CHARS}. Defaults to
|
|
1088
|
+
* `true`, which is right for any consumer that puts cue text into an LLM
|
|
1089
|
+
* prompt. Pass `false` when the text goes to a classifier instead
|
|
1090
|
+
* (e.g. moderation), where truncating would hide content from the check
|
|
1091
|
+
* rather than defend against injection.
|
|
1092
|
+
*/
|
|
1093
|
+
capCueText?: boolean;
|
|
1094
|
+
}
|
|
1095
|
+
/**
|
|
1096
|
+
* Parses VTT content into structured cues with timing.
|
|
1097
|
+
*
|
|
1098
|
+
* @param vttContent - Raw VTT file content
|
|
1099
|
+
* @param options - See {@link ParseVTTCuesOptions}
|
|
1100
|
+
* @returns Array of VTT cues with start/end times and text
|
|
1101
|
+
*/
|
|
1102
|
+
declare function parseVTTCues(vttContent: string, options?: ParseVTTCuesOptions): VTTCue[];
|
|
1103
|
+
/**
|
|
1104
|
+
* Keeps only VTT cues that overlap an asset-relative time range.
|
|
1105
|
+
*
|
|
1106
|
+
* Cue timestamps remain relative to the original asset; they are not rebased
|
|
1107
|
+
* to the start of the scope.
|
|
1108
|
+
*/
|
|
1109
|
+
declare function filterVttByScope(vttContent: string, scope: WorkflowScope | undefined): string;
|
|
1110
|
+
declare function splitVttPreambleAndCueBlocks(vttContent: string): {
|
|
1111
|
+
preamble: string;
|
|
1112
|
+
cueBlocks: string[];
|
|
1113
|
+
};
|
|
1114
|
+
declare function buildVttFromCueBlocks(cueBlocks: string[], preamble?: string): string;
|
|
1115
|
+
declare function replaceCueText(cueBlock: string, translatedText: string): string;
|
|
1116
|
+
declare function buildVttFromTranslatedCueBlocks(cueBlocks: string[], translatedTexts: string[], preamble?: string): string;
|
|
1117
|
+
declare function concatenateVttSegments(segments: string[], preamble?: string): string;
|
|
1118
|
+
/**
|
|
1119
|
+
* Builds a transcript URL for the given playback ID and track ID.
|
|
1120
|
+
* If a signing context is provided, the URL will be signed with a token.
|
|
1121
|
+
*
|
|
1122
|
+
* @param playbackId - The Mux playback ID
|
|
1123
|
+
* @param trackId - The text track ID
|
|
1124
|
+
* @param shouldSign - Flag for whether or not to use signed playback IDs
|
|
1125
|
+
* @returns Transcript URL (signed if context provided)
|
|
1126
|
+
*/
|
|
1127
|
+
declare function buildTranscriptUrl(playbackId: string, trackId: string, shouldSign?: boolean, credentials?: WorkflowCredentialsInput): Promise<string>;
|
|
1128
|
+
/**
|
|
1129
|
+
* Why a fetched transcript had nothing usable:
|
|
1130
|
+
* - `"empty_body"` — the VTT had no text at all.
|
|
1131
|
+
* - `"no_scoped_cues"` — the VTT had cues, but none inside the requested `scope`.
|
|
1132
|
+
*/
|
|
1133
|
+
type TranscriptEmptyReason = "empty_body" | "no_scoped_cues";
|
|
1134
|
+
interface TranscriptFetchStepResult {
|
|
1135
|
+
transcriptText: string;
|
|
1136
|
+
/** Set when `transcriptText` came back empty. */
|
|
1137
|
+
emptyReason?: TranscriptEmptyReason;
|
|
1138
|
+
}
|
|
1139
|
+
/**
|
|
1140
|
+
* Fetches and parses the VTT at an already-resolved transcript URL (see
|
|
1141
|
+
* {@link buildTranscriptUrl}). An empty transcript is reported through
|
|
1142
|
+
* `emptyReason` rather than thrown, so callers decide whether that is an
|
|
1143
|
+
* error or a skip; {@link fetchTranscriptForAsset} is the wrapper that turns
|
|
1144
|
+
* it into a customer-safe error when `required`.
|
|
1145
|
+
*
|
|
1146
|
+
* Throws on an HTTP/network failure while fetching the VTT file, so Workflow
|
|
1147
|
+
* DevKit's normal step-retry applies to that genuinely-transient case.
|
|
1148
|
+
*/
|
|
1149
|
+
declare function fetchTranscriptDataForUrl(transcriptUrl: string, options?: Pick<TranscriptFetchOptions, "cleanTranscript" | "scope" | "classifiedErrors">): Promise<TranscriptFetchStepResult>;
|
|
1150
|
+
declare function fetchTranscriptForAsset(asset: MuxAsset, playbackId: string, options?: TranscriptFetchOptions): Promise<TranscriptResult>;
|
|
1151
|
+
|
|
1152
|
+
export { errorDetailFact as $, type AssetTextTrack as A, type PlaybackPolicy as B, ClassifiedError as C, type ScopedMuxAIOptions as D, type Encrypted as E, type SerializedClassification as F, type SourceAndDependency as G, type StorageAdapter as H, type ImageSubmissionMode as I, type TokenChunkingConfig as J, type TokenUsage as K, type ToneType as L, type MuxAiErrorDependency as M, type VideoEmbeddingsResult as N, type WorkflowCredentialsInput as O, type PlaybackAsset as P, type WorkflowMuxClient as Q, type WorkflowScope as R, type StoragePutObjectInput as S, type TextChunk as T, type UsageMetadata as U, type VTTChunkingConfig as V, type WorkflowCredentials as W, assertNever as X, classificationInit as Y, decryptFromWorkflow as Z, encryptForWorkflow as _, type MuxAiErrorFacts as a, internalError as a0, isTransientStatus as a1, restoreClassification as a2, serializeClassification as a3, wrapError as a4, type VTTCue as a5, type CompletedShotsResult as a6, type DeletedShotsResult as a7, type ErroredShotsResult as a8, type Hotspot as a9, getHotspotsForPlaybackId as aA, getHotspotsForVideo as aB, getReadyTextTracks as aC, getReliableLanguageCode as aD, getShotsForAsset as aE, parseVTTCues as aF, replaceCueText as aG, requestShotsForAsset as aH, sanitizeUntrustedText as aI, secondsToTimestamp as aJ, splitVttPreambleAndCueBlocks as aK, stripVttMetadataBlocks as aL, vttTimestampToSeconds as aM, waitForShotsForAsset as aN, type ClassifiedErrorsOption as aO, type HotspotOptions as aa, type HotspotResponse as ab, LOW_CONFIDENCE_THRESHOLD as ac, MAX_CUE_TEXT_CHARS as ad, type ParseVTTCuesOptions as ae, type PendingShotsResult as af, type Shot as ag, type ShotRequestOptions as ah, type ShotsResult as ai, type SkippedShotsResult as aj, type TranscriptEmptyReason as ak, type TranscriptFetchOptions as al, type TranscriptFetchStepResult as am, type TranscriptResult as an, type WaitForShotsOptions as ao, buildTranscriptUrl as ap, buildVttFromCueBlocks as aq, buildVttFromTranslatedCueBlocks as ar, concatenateVttSegments as as, extractTextFromVTT as at, extractTimestampedTranscript as au, fetchTranscriptDataForUrl as av, fetchTranscriptForAsset as aw, filterVttByScope as ax, findCaptionTrack as ay, getHotspotsForAsset as az, type MuxAiErrorSource as b, type MuxAiErrorType as c, MuxAiError as d, type MuxAsset as e, type MuxAiErrorFactValue as f, type MuxAiErrorCode as g, type StoragePresignGetObjectInput as h, type ChunkEmbedding as i, type ChunkingStrategy as j, type ClassifiedErrorInit as k, type CodedClassification as l, type EncryptedPayload as m, type ErrorCatalogEntry as n, type ErrorCauseSummary as o, MUX_AI_ERROR_CATALOG as p, MUX_AI_ERROR_CODES as q, MUX_AI_ERROR_CODE_VALUES as r, MUX_AI_ERROR_DEPENDENCIES as s, MUX_AI_ERROR_DEPENDENCY_VALUES as t, MUX_AI_ERROR_SOURCES as u, MUX_AI_ERROR_SOURCE_VALUES as v, MUX_AI_ERROR_TYPES as w, MUX_AI_ERROR_TYPE_VALUES as x, type MuxAIOptions as y, type MuxAiErrorInit as z };
|