@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
package/package.json
CHANGED
|
@@ -1,613 +0,0 @@
|
|
|
1
|
-
import Mux from '@mux/ts';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Workflow Crypto
|
|
5
|
-
*
|
|
6
|
-
* Provides AES-256-GCM encryption for securely passing credentials to workflows.
|
|
7
|
-
* Encrypted payloads are JSON-serializable and include version/algorithm metadata
|
|
8
|
-
* for forward compatibility.
|
|
9
|
-
*/
|
|
10
|
-
declare const WORKFLOW_ENCRYPTION_VERSION = 1;
|
|
11
|
-
declare const WORKFLOW_ENCRYPTION_ALGORITHM: "aes-256-gcm";
|
|
12
|
-
/**
|
|
13
|
-
* Structure of an encrypted payload (all fields are base64-encoded where applicable).
|
|
14
|
-
*
|
|
15
|
-
* The optional `kid` (key ID) field supports key rotation scenarios:
|
|
16
|
-
* - Include a `kid` when encrypting to identify which key was used
|
|
17
|
-
* - On decryption, read `payload.kid` to look up the correct key
|
|
18
|
-
* - Keys should be invalidated/deleted after rotation, not kept indefinitely
|
|
19
|
-
*
|
|
20
|
-
* Security notes:
|
|
21
|
-
* - `kid` is stored in plaintext (not encrypted) - don't put sensitive data in it
|
|
22
|
-
* - Tampering with `kid` doesn't weaken security - wrong key = decryption fails
|
|
23
|
-
*/
|
|
24
|
-
interface EncryptedPayload {
|
|
25
|
-
v: typeof WORKFLOW_ENCRYPTION_VERSION;
|
|
26
|
-
alg: typeof WORKFLOW_ENCRYPTION_ALGORITHM;
|
|
27
|
-
kid?: string;
|
|
28
|
-
iv: string;
|
|
29
|
-
tag: string;
|
|
30
|
-
ciphertext: string;
|
|
31
|
-
}
|
|
32
|
-
/** Branded type that preserves the original type information for decryption */
|
|
33
|
-
type Encrypted<T> = EncryptedPayload & {
|
|
34
|
-
__type?: T;
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* Encrypts a value for secure transport to a workflow.
|
|
38
|
-
*
|
|
39
|
-
* @param value - Any JSON-serializable value (typically WorkflowCredentials)
|
|
40
|
-
* @param key - 32-byte secret key (base64 string or Uint8Array)
|
|
41
|
-
* @param keyId - Optional key identifier for rotation support (stored in plaintext)
|
|
42
|
-
* @returns Encrypted payload with metadata, safe to pass through untrusted channels
|
|
43
|
-
*/
|
|
44
|
-
declare function encryptForWorkflow<T>(value: T, key: Uint8Array | string, keyId?: string): Promise<Encrypted<T>>;
|
|
45
|
-
/**
|
|
46
|
-
* Decrypts and deserializes a workflow payload.
|
|
47
|
-
*
|
|
48
|
-
* @param payload - Encrypted payload from `encryptForWorkflow`
|
|
49
|
-
* @param key - Same 32-byte secret key used for encryption
|
|
50
|
-
* @returns The original decrypted value
|
|
51
|
-
* @throws If payload is invalid, tampered with, or key is wrong
|
|
52
|
-
*/
|
|
53
|
-
declare function decryptFromWorkflow<T>(payload: EncryptedPayload, key: Uint8Array | string): Promise<T>;
|
|
54
|
-
|
|
55
|
-
/** Input shape for uploading objects through a storage adapter. */
|
|
56
|
-
interface StoragePutObjectInput {
|
|
57
|
-
endpoint: string;
|
|
58
|
-
region: string;
|
|
59
|
-
bucket: string;
|
|
60
|
-
key: string;
|
|
61
|
-
body: string | Uint8Array;
|
|
62
|
-
contentType?: string;
|
|
63
|
-
accessKeyId?: string;
|
|
64
|
-
secretAccessKey?: string;
|
|
65
|
-
}
|
|
66
|
-
/** Input shape for presigning object download URLs through a storage adapter. */
|
|
67
|
-
interface StoragePresignGetObjectInput {
|
|
68
|
-
endpoint: string;
|
|
69
|
-
region: string;
|
|
70
|
-
bucket: string;
|
|
71
|
-
key: string;
|
|
72
|
-
expiresInSeconds: number;
|
|
73
|
-
accessKeyId?: string;
|
|
74
|
-
secretAccessKey?: string;
|
|
75
|
-
}
|
|
76
|
-
/** Optional pluggable storage backend for S3-compatible object operations. */
|
|
77
|
-
interface StorageAdapter {
|
|
78
|
-
putObject: (input: StoragePutObjectInput) => Promise<void>;
|
|
79
|
-
createPresignedGetUrl: (input: StoragePresignGetObjectInput) => Promise<string>;
|
|
80
|
-
}
|
|
81
|
-
interface WorkflowMuxClient {
|
|
82
|
-
createClient: () => Promise<Mux>;
|
|
83
|
-
getSigningKey: () => string | undefined;
|
|
84
|
-
getPrivateKey: () => string | undefined;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Base options mixed into every higher-level workflow configuration.
|
|
88
|
-
*/
|
|
89
|
-
interface MuxAIOptions {
|
|
90
|
-
/** Optional timeout (ms) for helper utilities that support request limits. */
|
|
91
|
-
timeout?: number;
|
|
92
|
-
/**
|
|
93
|
-
* Optional asset snapshot to reuse instead of retrieving the asset from Mux.
|
|
94
|
-
* The snapshot must belong to `assetId`; callers should capture it immediately
|
|
95
|
-
* before starting the workflow.
|
|
96
|
-
*/
|
|
97
|
-
assetSnapshot?: MuxAsset;
|
|
98
|
-
/**
|
|
99
|
-
* Optional credentials for workflow execution.
|
|
100
|
-
* Use encryptForWorkflow when running in Workflow Dev Kit environments.
|
|
101
|
-
*/
|
|
102
|
-
credentials?: WorkflowCredentialsInput;
|
|
103
|
-
/** Optional storage adapter for upload and presigning operations. */
|
|
104
|
-
storageAdapter?: StorageAdapter;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Asset-relative time range used to limit workflow analysis.
|
|
108
|
-
*
|
|
109
|
-
* Times are expressed in seconds. The start is inclusive and the end is
|
|
110
|
-
* exclusive. Either boundary may be omitted to analyze from the beginning or
|
|
111
|
-
* through the end of the asset, respectively.
|
|
112
|
-
*/
|
|
113
|
-
interface WorkflowScope {
|
|
114
|
-
/** Inclusive start offset from the beginning of the asset, in seconds. */
|
|
115
|
-
startTime?: number;
|
|
116
|
-
/** Exclusive end offset from the beginning of the asset, in seconds. */
|
|
117
|
-
endTime?: number;
|
|
118
|
-
}
|
|
119
|
-
/** Base options for workflows that can analyze a bounded part of an asset. */
|
|
120
|
-
interface ScopedMuxAIOptions extends MuxAIOptions {
|
|
121
|
-
/** Optional asset-relative time range to analyze. */
|
|
122
|
-
scope?: WorkflowScope;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Workflow credentials.
|
|
126
|
-
*
|
|
127
|
-
* Supports plain credential objects and primitive credential fields for
|
|
128
|
-
* per-request multi-tenant workflows.
|
|
129
|
-
*/
|
|
130
|
-
interface WorkflowCredentials {
|
|
131
|
-
/** Direct Mux API token ID for per-request credential injection. */
|
|
132
|
-
muxTokenId?: string;
|
|
133
|
-
/** Direct Mux API token secret for per-request credential injection. */
|
|
134
|
-
muxTokenSecret?: string;
|
|
135
|
-
/** Direct Mux API auth token secret for per-request credential injection. */
|
|
136
|
-
muxAuthorizationToken?: string;
|
|
137
|
-
/** Optional direct Mux signing key ID for signed playback URL generation. */
|
|
138
|
-
muxSigningKey?: string;
|
|
139
|
-
/** Optional direct Mux private key for signed playback URL generation. */
|
|
140
|
-
muxPrivateKey?: string;
|
|
141
|
-
/** Optional Mux custom domain (e.g. "media.example.com") used for image.* and stream.* playback URLs. */
|
|
142
|
-
muxCustomDomain?: string;
|
|
143
|
-
/** Optional direct OpenAI API key for per-request credential injection. */
|
|
144
|
-
openaiApiKey?: string;
|
|
145
|
-
/** Optional direct Baseten API key for per-request credential injection. */
|
|
146
|
-
basetenApiKey?: string;
|
|
147
|
-
/** Optional direct Baseten language endpoint URL (dedicated /sync/v1 deployment or shared OpenAI-compatible base URL). */
|
|
148
|
-
basetenUrl?: string;
|
|
149
|
-
/** Optional direct Baseten dedicated embedding deployment URL (/sync or /sync/v1). */
|
|
150
|
-
basetenEmbeddingUrl?: string;
|
|
151
|
-
/** Optional direct API key for OpenAI-compatible endpoints. */
|
|
152
|
-
openaiCompatibleApiKey?: string;
|
|
153
|
-
/** Optional direct base URL of an OpenAI-compatible API. */
|
|
154
|
-
openaiCompatibleBaseUrl?: string;
|
|
155
|
-
/** Optional direct embedding-specific OpenAI-compatible base URL. */
|
|
156
|
-
openaiCompatibleEmbeddingBaseUrl?: string;
|
|
157
|
-
/** Optional direct Anthropic API key for per-request credential injection. */
|
|
158
|
-
anthropicApiKey?: string;
|
|
159
|
-
/** Optional direct Google API key for per-request credential injection. */
|
|
160
|
-
googleApiKey?: string;
|
|
161
|
-
/** Optional direct Google Vision API key for per-request credential injection. */
|
|
162
|
-
googleVisionApiKey?: string;
|
|
163
|
-
/** Optional direct Hive API key for per-request credential injection. */
|
|
164
|
-
hiveApiKey?: string;
|
|
165
|
-
/** Optional direct ElevenLabs API key for per-request credential injection. */
|
|
166
|
-
elevenLabsApiKey?: string;
|
|
167
|
-
}
|
|
168
|
-
/** Credentials that are safe to serialize across workflow boundaries. */
|
|
169
|
-
type WorkflowCredentialsInput = WorkflowCredentials | Encrypted<WorkflowCredentials>;
|
|
170
|
-
/** Tone controls for the summarization helper. */
|
|
171
|
-
type ToneType = "neutral" | "playful" | "professional";
|
|
172
|
-
/** Common transport for image-based workflows. */
|
|
173
|
-
type ImageSubmissionMode = "url" | "base64";
|
|
174
|
-
/** Result of calling the Mux SDK asset retrieval helper. */
|
|
175
|
-
type MuxAsset = Awaited<ReturnType<Mux["video"]["assets"]["retrieve"]>>;
|
|
176
|
-
/** Single ready track extracted from a Mux asset. */
|
|
177
|
-
type AssetTextTrack = NonNullable<MuxAsset["tracks"]>[number];
|
|
178
|
-
/** Playback policy type for Mux assets. */
|
|
179
|
-
type PlaybackPolicy = "public" | "signed";
|
|
180
|
-
/** Convenience bundle returned by `getPlaybackIdForAsset`. */
|
|
181
|
-
interface PlaybackAsset {
|
|
182
|
-
asset: MuxAsset;
|
|
183
|
-
playbackId: string;
|
|
184
|
-
/** The policy type of the playback ID ('public' or 'signed'). */
|
|
185
|
-
policy: PlaybackPolicy;
|
|
186
|
-
}
|
|
187
|
-
/** Configuration for token-based chunking. */
|
|
188
|
-
interface TokenChunkingConfig {
|
|
189
|
-
type: "token";
|
|
190
|
-
/** Maximum tokens per chunk. */
|
|
191
|
-
maxTokens: number;
|
|
192
|
-
/** Number of overlapping tokens between chunks. */
|
|
193
|
-
overlap?: number;
|
|
194
|
-
}
|
|
195
|
-
/** Configuration for VTT-aware chunking that respects cue boundaries. */
|
|
196
|
-
interface VTTChunkingConfig {
|
|
197
|
-
type: "vtt";
|
|
198
|
-
/** Maximum tokens per chunk. */
|
|
199
|
-
maxTokens: number;
|
|
200
|
-
/** Number of cues to overlap between chunks (default: 2). */
|
|
201
|
-
overlapCues?: number;
|
|
202
|
-
}
|
|
203
|
-
/** Union type for all chunking strategy configurations. */
|
|
204
|
-
type ChunkingStrategy = TokenChunkingConfig | VTTChunkingConfig;
|
|
205
|
-
/** A single chunk of text extracted from a transcript. */
|
|
206
|
-
interface TextChunk {
|
|
207
|
-
/** Unique identifier for this chunk. */
|
|
208
|
-
id: string;
|
|
209
|
-
/** The text content of the chunk. */
|
|
210
|
-
text: string;
|
|
211
|
-
/** Number of tokens in this chunk. */
|
|
212
|
-
tokenCount: number;
|
|
213
|
-
/** Start time in seconds (if available from timestamped transcript). */
|
|
214
|
-
startTime?: number;
|
|
215
|
-
/** End time in seconds (if available from timestamped transcript). */
|
|
216
|
-
endTime?: number;
|
|
217
|
-
}
|
|
218
|
-
/** A chunk with its embedding vector. */
|
|
219
|
-
interface ChunkEmbedding {
|
|
220
|
-
/** Reference to the chunk ID. */
|
|
221
|
-
chunkId: string;
|
|
222
|
-
/** The embedding vector. */
|
|
223
|
-
embedding: number[];
|
|
224
|
-
/** Optional metadata for this chunk. */
|
|
225
|
-
metadata: {
|
|
226
|
-
startTime?: number;
|
|
227
|
-
endTime?: number;
|
|
228
|
-
tokenCount: number;
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
/** Result of generating embeddings for a video asset. */
|
|
232
|
-
interface VideoEmbeddingsResult {
|
|
233
|
-
/** The Mux asset ID. */
|
|
234
|
-
assetId: string;
|
|
235
|
-
/** Individual chunk embeddings. */
|
|
236
|
-
chunks: ChunkEmbedding[];
|
|
237
|
-
/** Averaged embedding across all chunks. */
|
|
238
|
-
averagedEmbedding: number[];
|
|
239
|
-
/** AI provider used. */
|
|
240
|
-
provider: string;
|
|
241
|
-
/** Model used for embedding generation. */
|
|
242
|
-
model: string;
|
|
243
|
-
/** Additional metadata about the generation. */
|
|
244
|
-
metadata: {
|
|
245
|
-
totalChunks: number;
|
|
246
|
-
totalTokens: number;
|
|
247
|
-
chunkingStrategy: string;
|
|
248
|
-
embeddingDimensions: number;
|
|
249
|
-
generatedAt: string;
|
|
250
|
-
};
|
|
251
|
-
/** Workflow usage metadata (asset duration, thumbnails, etc.). */
|
|
252
|
-
usage?: TokenUsage;
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* Metadata attached to usage objects for workflow context.
|
|
256
|
-
*/
|
|
257
|
-
interface UsageMetadata {
|
|
258
|
-
/** Total asset duration in seconds. */
|
|
259
|
-
assetDurationSeconds?: number;
|
|
260
|
-
/** Number of thumbnails sampled for workflows that use thumbnails. */
|
|
261
|
-
thumbnailCount?: number;
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* Token usage breakdown returned by AI SDK providers.
|
|
265
|
-
* Used for efficiency and cost analysis.
|
|
266
|
-
*/
|
|
267
|
-
interface TokenUsage {
|
|
268
|
-
/** Number of tokens in the input prompt (text + image). */
|
|
269
|
-
inputTokens?: number;
|
|
270
|
-
/** Number of tokens generated in the output. */
|
|
271
|
-
outputTokens?: number;
|
|
272
|
-
/** Total tokens consumed (input + output). */
|
|
273
|
-
totalTokens?: number;
|
|
274
|
-
/** Tokens used for chain-of-thought reasoning (if applicable). */
|
|
275
|
-
reasoningTokens?: number;
|
|
276
|
-
/** Input tokens served from cache (reduces cost). */
|
|
277
|
-
cachedInputTokens?: number;
|
|
278
|
-
/** Input tokens written to cache (may use a provider-specific rate). */
|
|
279
|
-
cacheWriteTokens?: number;
|
|
280
|
-
/** Workflow metadata (asset duration, thumbnails, etc.). */
|
|
281
|
-
metadata?: UsageMetadata;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
interface Hotspot {
|
|
285
|
-
/** Inclusive start time in milliseconds */
|
|
286
|
-
startMs: number;
|
|
287
|
-
/** Exclusive end time in milliseconds */
|
|
288
|
-
endMs: number;
|
|
289
|
-
/** Hotspot score using distribution-based normalization (0-1) */
|
|
290
|
-
score: number;
|
|
291
|
-
}
|
|
292
|
-
interface HotspotOptions {
|
|
293
|
-
/** Maximum number of hotspots to return (default: 5) */
|
|
294
|
-
limit?: number;
|
|
295
|
-
/** Sort order: 'asc' or 'desc' (default: 'desc') */
|
|
296
|
-
orderDirection?: "asc" | "desc";
|
|
297
|
-
/** @deprecated The API always orders by score; this option is ignored. */
|
|
298
|
-
orderBy?: "score";
|
|
299
|
-
/** Time window for results, e.g., '7:days' (default: '7:days') */
|
|
300
|
-
timeframe?: string;
|
|
301
|
-
/** Optional workflow credentials */
|
|
302
|
-
credentials?: WorkflowCredentialsInput;
|
|
303
|
-
}
|
|
304
|
-
interface HotspotResponse {
|
|
305
|
-
assetId?: string;
|
|
306
|
-
videoId?: string;
|
|
307
|
-
playbackId?: string;
|
|
308
|
-
hotspots: Hotspot[];
|
|
309
|
-
}
|
|
310
|
-
/**
|
|
311
|
-
* Fetches engagement hotspots for a Mux asset.
|
|
312
|
-
* Returns the top N "hot" time ranges based on engagement data.
|
|
313
|
-
*
|
|
314
|
-
* @param assetId - The Mux asset ID
|
|
315
|
-
* @param options - Hotspot query options
|
|
316
|
-
* @returns Array of hotspots with time ranges and scores
|
|
317
|
-
*/
|
|
318
|
-
declare function getHotspotsForAsset(assetId: string, options?: HotspotOptions): Promise<Hotspot[]>;
|
|
319
|
-
/**
|
|
320
|
-
* Fetches engagement hotspots for a Mux video ID.
|
|
321
|
-
* Returns the top N "hot" time ranges based on engagement data.
|
|
322
|
-
*
|
|
323
|
-
* @param videoId - The Mux video ID
|
|
324
|
-
* @param options - Hotspot query options
|
|
325
|
-
* @returns Array of hotspots with time ranges and scores
|
|
326
|
-
*/
|
|
327
|
-
declare function getHotspotsForVideo(videoId: string, options?: HotspotOptions): Promise<Hotspot[]>;
|
|
328
|
-
/**
|
|
329
|
-
* Fetches engagement hotspots for a Mux playback ID.
|
|
330
|
-
* Returns the top N "hot" time ranges based on engagement data.
|
|
331
|
-
*
|
|
332
|
-
* @param playbackId - The Mux playback ID
|
|
333
|
-
* @param options - Hotspot query options
|
|
334
|
-
* @returns Array of hotspots with time ranges and scores
|
|
335
|
-
*/
|
|
336
|
-
declare function getHotspotsForPlaybackId(playbackId: string, options?: HotspotOptions): Promise<Hotspot[]>;
|
|
337
|
-
|
|
338
|
-
interface Shot {
|
|
339
|
-
/** Start time of the shot in seconds from the beginning of the asset. */
|
|
340
|
-
startTime: number;
|
|
341
|
-
/** Signed URL for a representative image of the shot. */
|
|
342
|
-
imageUrl: string;
|
|
343
|
-
}
|
|
344
|
-
interface PendingShotsResult {
|
|
345
|
-
status: "pending";
|
|
346
|
-
createdAt: string;
|
|
347
|
-
}
|
|
348
|
-
interface ErroredShotsResult {
|
|
349
|
-
status: "errored";
|
|
350
|
-
createdAt: string;
|
|
351
|
-
error: {
|
|
352
|
-
type: string;
|
|
353
|
-
messages: string[];
|
|
354
|
-
};
|
|
355
|
-
}
|
|
356
|
-
interface CompletedShotsResult {
|
|
357
|
-
status: "completed";
|
|
358
|
-
createdAt: string;
|
|
359
|
-
shots: Shot[];
|
|
360
|
-
}
|
|
361
|
-
/** Mux declined to run shot detection, e.g. the asset has no video track. */
|
|
362
|
-
interface SkippedShotsResult {
|
|
363
|
-
status: "skipped";
|
|
364
|
-
createdAt: string;
|
|
365
|
-
}
|
|
366
|
-
interface DeletedShotsResult {
|
|
367
|
-
status: "deleted";
|
|
368
|
-
createdAt: string;
|
|
369
|
-
}
|
|
370
|
-
type ShotsResult = PendingShotsResult | ErroredShotsResult | CompletedShotsResult | SkippedShotsResult | DeletedShotsResult;
|
|
371
|
-
interface ShotRequestOptions {
|
|
372
|
-
/** Optional workflow credentials */
|
|
373
|
-
credentials?: WorkflowCredentialsInput;
|
|
374
|
-
}
|
|
375
|
-
interface WaitForShotsOptions extends ShotRequestOptions {
|
|
376
|
-
/** Polling interval in milliseconds (default: 2000, minimum enforced: 1000) */
|
|
377
|
-
pollIntervalMs?: number;
|
|
378
|
-
/** Maximum number of polling attempts (default: 60) */
|
|
379
|
-
maxAttempts?: number;
|
|
380
|
-
/** When true, request shot generation before polling (default: true) */
|
|
381
|
-
createIfMissing?: boolean;
|
|
382
|
-
}
|
|
383
|
-
/**
|
|
384
|
-
* Starts generating shots for an asset.
|
|
385
|
-
*
|
|
386
|
-
* @param assetId - The Mux asset ID
|
|
387
|
-
* @param options - Request options
|
|
388
|
-
* @returns Pending shot generation state
|
|
389
|
-
*/
|
|
390
|
-
declare function requestShotsForAsset(assetId: string, options?: ShotRequestOptions): Promise<PendingShotsResult>;
|
|
391
|
-
/**
|
|
392
|
-
* Gets the current shot generation status for an asset.
|
|
393
|
-
*
|
|
394
|
-
* @param assetId - The Mux asset ID
|
|
395
|
-
* @param options - Request options
|
|
396
|
-
* @returns Pending, errored, or completed shot result
|
|
397
|
-
*/
|
|
398
|
-
declare function getShotsForAsset(assetId: string, options?: ShotRequestOptions): Promise<ShotsResult>;
|
|
399
|
-
/**
|
|
400
|
-
* Requests shot generation if needed and polls until shots are completed.
|
|
401
|
-
*
|
|
402
|
-
* @param assetId - The Mux asset ID
|
|
403
|
-
* @param options - Polling options
|
|
404
|
-
* @returns Completed shot result
|
|
405
|
-
*/
|
|
406
|
-
declare function waitForShotsForAsset(assetId: string, options?: WaitForShotsOptions): Promise<CompletedShotsResult>;
|
|
407
|
-
|
|
408
|
-
/** A single cue from a VTT file with timing info. */
|
|
409
|
-
interface VTTCue {
|
|
410
|
-
startTime: number;
|
|
411
|
-
endTime: number;
|
|
412
|
-
text: string;
|
|
413
|
-
}
|
|
414
|
-
interface TranscriptFetchOptions {
|
|
415
|
-
languageCode?: string;
|
|
416
|
-
cleanTranscript?: boolean;
|
|
417
|
-
/** Optional asset-relative time range used to filter transcript cues. */
|
|
418
|
-
scope?: WorkflowScope;
|
|
419
|
-
/** Optional signing context for signed playback IDs */
|
|
420
|
-
shouldSign?: boolean;
|
|
421
|
-
credentials?: WorkflowCredentialsInput;
|
|
422
|
-
/**
|
|
423
|
-
* When true, throws a customer-safe `MuxAiError` if no usable transcript can
|
|
424
|
-
* be retrieved (no ready text track, missing track id, or empty transcript).
|
|
425
|
-
*
|
|
426
|
-
* Default behavior is non-fatal and returns an empty `transcriptText`.
|
|
427
|
-
*/
|
|
428
|
-
required?: boolean;
|
|
429
|
-
}
|
|
430
|
-
interface TranscriptResult {
|
|
431
|
-
transcriptText: string;
|
|
432
|
-
transcriptUrl?: string;
|
|
433
|
-
track?: AssetTextTrack;
|
|
434
|
-
}
|
|
435
|
-
declare function getReadyTextTracks(asset: MuxAsset): AssetTextTrack[];
|
|
436
|
-
declare function findCaptionTrack(asset: MuxAsset, languageCode?: string): AssetTextTrack | undefined;
|
|
437
|
-
/**
|
|
438
|
-
* Default minimum auto-detection confidence required to trust a track's language code.
|
|
439
|
-
* Below this threshold, the language is treated as undetermined.
|
|
440
|
-
*/
|
|
441
|
-
declare const LOW_CONFIDENCE_THRESHOLD = 0.5;
|
|
442
|
-
/**
|
|
443
|
-
* Extracts a trustworthy language code from a track, returning `undefined`
|
|
444
|
-
* when the language metadata shouldn't be used as an LLM output language.
|
|
445
|
-
*
|
|
446
|
-
* Returns `undefined` when:
|
|
447
|
-
* - The track or its language code is missing
|
|
448
|
-
* - The language code is undetermined (`und`, `mul`, `mis`, `zxx`)
|
|
449
|
-
* - The language was auto-detected with confidence below the threshold
|
|
450
|
-
*
|
|
451
|
-
* Trusts the language code when:
|
|
452
|
-
* - `auto_language_confidence` is absent (manually set or non-auto tracks)
|
|
453
|
-
* - `auto_language_confidence` meets the threshold
|
|
454
|
-
*
|
|
455
|
-
* @param track - The text track to inspect
|
|
456
|
-
* @param confidenceThreshold - Minimum confidence to trust auto-detected language (default: {@link LOW_CONFIDENCE_THRESHOLD})
|
|
457
|
-
*/
|
|
458
|
-
declare function getReliableLanguageCode(track: AssetTextTrack | undefined, confidenceThreshold?: number): string | undefined;
|
|
459
|
-
/**
|
|
460
|
-
* Sanitise untrusted text (typically a VTT cue or joined transcript)
|
|
461
|
-
* before it is interpolated into a prompt. Thin wrapper around the
|
|
462
|
-
* shared {@link normalizeUntrustedUnicode} helper, with a null/empty
|
|
463
|
-
* guard for convenience.
|
|
464
|
-
*/
|
|
465
|
-
declare function sanitizeUntrustedText(value: string): string;
|
|
466
|
-
/**
|
|
467
|
-
* Upper bound on individual cue text length before we consider the cue
|
|
468
|
-
* adversarial and truncate it.
|
|
469
|
-
*
|
|
470
|
-
* Legitimate captions are short — a long monologue cue rarely exceeds
|
|
471
|
-
* 500 characters, and most captioning standards recommend well under
|
|
472
|
-
* that for readability. We set the cap at 2000 to give comfortable
|
|
473
|
-
* headroom for edge cases (stage directions, speaker identification,
|
|
474
|
-
* multi-line blocks) while making "hide a multi-kilobyte injection
|
|
475
|
-
* payload inside a single cue" mechanically infeasible.
|
|
476
|
-
*/
|
|
477
|
-
declare const MAX_CUE_TEXT_CHARS = 2000;
|
|
478
|
-
/**
|
|
479
|
-
* Strip VTT metadata blocks that are never rendered by players but can
|
|
480
|
-
* still carry text through to an LLM when the raw VTT is used in a prompt:
|
|
481
|
-
*
|
|
482
|
-
* - NOTE blocks (VTT comments)
|
|
483
|
-
* - STYLE blocks (CSS for cue styling)
|
|
484
|
-
* - REGION blocks (positioning definitions)
|
|
485
|
-
*
|
|
486
|
-
* Viewers never see the contents of these blocks. That makes them an
|
|
487
|
-
* ideal hiding spot for prompt-injection payloads — an attacker-controlled
|
|
488
|
-
* caption file can carry hundreds of bytes of "NOTE ignore previous
|
|
489
|
-
* instructions…" that will be stripped from any player but will reach the
|
|
490
|
-
* model if the raw VTT is passed through. Removing them before sending
|
|
491
|
-
* the VTT to the model closes that channel without changing what the
|
|
492
|
-
* model sees for legitimate cue content.
|
|
493
|
-
*
|
|
494
|
-
* Cue identifiers, timing lines, and cue payload text are preserved.
|
|
495
|
-
* In particular: a cue whose first payload line happens to start with
|
|
496
|
-
* `NOTE `/`STYLE `/`REGION ` (plausible in legitimate captions — e.g.
|
|
497
|
-
* `"NOTE THAT..."`, `"STYLE GUIDE"`, `"NOTE how the villain plots..."`)
|
|
498
|
-
* is NOT treated as a metadata block. The scanner tracks cue-payload
|
|
499
|
-
* state: metadata headers are only recognised between cues (i.e. when
|
|
500
|
-
* the previous non-blank line was not a timing line).
|
|
501
|
-
*
|
|
502
|
-
* Example input:
|
|
503
|
-
*
|
|
504
|
-
* WEBVTT
|
|
505
|
-
*
|
|
506
|
-
* NOTE This is a comment with hidden instructions
|
|
507
|
-
* that span multiple lines until a blank line appears.
|
|
508
|
-
*
|
|
509
|
-
* STYLE
|
|
510
|
-
* ::cue(b) { font-weight: bold; }
|
|
511
|
-
*
|
|
512
|
-
* 00:00:01.000 --> 00:00:04.000
|
|
513
|
-
* Legitimate caption text
|
|
514
|
-
*
|
|
515
|
-
* 00:00:05.000 --> 00:00:08.000
|
|
516
|
-
* NOTE THAT the hero wins
|
|
517
|
-
*
|
|
518
|
-
* Returns:
|
|
519
|
-
*
|
|
520
|
-
* WEBVTT
|
|
521
|
-
*
|
|
522
|
-
* 00:00:01.000 --> 00:00:04.000
|
|
523
|
-
* Legitimate caption text
|
|
524
|
-
*
|
|
525
|
-
* 00:00:05.000 --> 00:00:08.000
|
|
526
|
-
* NOTE THAT the hero wins
|
|
527
|
-
*/
|
|
528
|
-
declare function stripVttMetadataBlocks(vttContent: string): string;
|
|
529
|
-
declare function extractTextFromVTT(vttContent: string): string;
|
|
530
|
-
/**
|
|
531
|
-
* Converts a WebVTT timestamp (`HH:MM:SS.mmm` or `MM:SS.mmm`) to seconds.
|
|
532
|
-
*
|
|
533
|
-
* @param timestamp - The timestamp to convert
|
|
534
|
-
* @returns The timestamp in seconds, or `undefined` if it is malformed
|
|
535
|
-
*/
|
|
536
|
-
declare function vttTimestampToSeconds(timestamp: string): number | undefined;
|
|
537
|
-
/**
|
|
538
|
-
* Converts seconds to a human-readable timestamp.
|
|
539
|
-
* Returns M:SS for durations under an hour, H:MM:SS for an hour or more.
|
|
540
|
-
*
|
|
541
|
-
* @param seconds - The number of seconds to convert
|
|
542
|
-
* @returns A formatted timestamp string (e.g., "2:05" or "01:02:05")
|
|
543
|
-
*/
|
|
544
|
-
declare function secondsToTimestamp(seconds: number): string;
|
|
545
|
-
declare function extractTimestampedTranscript(vttContent: string): string;
|
|
546
|
-
interface ParseVTTCuesOptions {
|
|
547
|
-
/**
|
|
548
|
-
* Truncate each cue's text to {@link MAX_CUE_TEXT_CHARS}. Defaults to
|
|
549
|
-
* `true`, which is right for any consumer that puts cue text into an LLM
|
|
550
|
-
* prompt. Pass `false` when the text goes to a classifier instead
|
|
551
|
-
* (e.g. moderation), where truncating would hide content from the check
|
|
552
|
-
* rather than defend against injection.
|
|
553
|
-
*/
|
|
554
|
-
capCueText?: boolean;
|
|
555
|
-
}
|
|
556
|
-
/**
|
|
557
|
-
* Parses VTT content into structured cues with timing.
|
|
558
|
-
*
|
|
559
|
-
* @param vttContent - Raw VTT file content
|
|
560
|
-
* @param options - See {@link ParseVTTCuesOptions}
|
|
561
|
-
* @returns Array of VTT cues with start/end times and text
|
|
562
|
-
*/
|
|
563
|
-
declare function parseVTTCues(vttContent: string, options?: ParseVTTCuesOptions): VTTCue[];
|
|
564
|
-
/**
|
|
565
|
-
* Keeps only VTT cues that overlap an asset-relative time range.
|
|
566
|
-
*
|
|
567
|
-
* Cue timestamps remain relative to the original asset; they are not rebased
|
|
568
|
-
* to the start of the scope.
|
|
569
|
-
*/
|
|
570
|
-
declare function filterVttByScope(vttContent: string, scope: WorkflowScope | undefined): string;
|
|
571
|
-
declare function splitVttPreambleAndCueBlocks(vttContent: string): {
|
|
572
|
-
preamble: string;
|
|
573
|
-
cueBlocks: string[];
|
|
574
|
-
};
|
|
575
|
-
declare function buildVttFromCueBlocks(cueBlocks: string[], preamble?: string): string;
|
|
576
|
-
declare function replaceCueText(cueBlock: string, translatedText: string): string;
|
|
577
|
-
declare function buildVttFromTranslatedCueBlocks(cueBlocks: string[], translatedTexts: string[], preamble?: string): string;
|
|
578
|
-
declare function concatenateVttSegments(segments: string[], preamble?: string): string;
|
|
579
|
-
/**
|
|
580
|
-
* Builds a transcript URL for the given playback ID and track ID.
|
|
581
|
-
* If a signing context is provided, the URL will be signed with a token.
|
|
582
|
-
*
|
|
583
|
-
* @param playbackId - The Mux playback ID
|
|
584
|
-
* @param trackId - The text track ID
|
|
585
|
-
* @param shouldSign - Flag for whether or not to use signed playback IDs
|
|
586
|
-
* @returns Transcript URL (signed if context provided)
|
|
587
|
-
*/
|
|
588
|
-
declare function buildTranscriptUrl(playbackId: string, trackId: string, shouldSign?: boolean, credentials?: WorkflowCredentialsInput): Promise<string>;
|
|
589
|
-
/**
|
|
590
|
-
* Why a fetched transcript had nothing usable:
|
|
591
|
-
* - `"empty_body"` — the VTT had no text at all.
|
|
592
|
-
* - `"no_scoped_cues"` — the VTT had cues, but none inside the requested `scope`.
|
|
593
|
-
*/
|
|
594
|
-
type TranscriptEmptyReason = "empty_body" | "no_scoped_cues";
|
|
595
|
-
interface TranscriptFetchStepResult {
|
|
596
|
-
transcriptText: string;
|
|
597
|
-
/** Set when `transcriptText` came back empty. */
|
|
598
|
-
emptyReason?: TranscriptEmptyReason;
|
|
599
|
-
}
|
|
600
|
-
/**
|
|
601
|
-
* Fetches and parses the VTT at an already-resolved transcript URL (see
|
|
602
|
-
* {@link buildTranscriptUrl}). An empty transcript is reported through
|
|
603
|
-
* `emptyReason` rather than thrown, so callers decide whether that is an
|
|
604
|
-
* error or a skip; {@link fetchTranscriptForAsset} is the wrapper that turns
|
|
605
|
-
* it into a customer-safe error when `required`.
|
|
606
|
-
*
|
|
607
|
-
* Throws on an HTTP/network failure while fetching the VTT file, so Workflow
|
|
608
|
-
* DevKit's normal step-retry applies to that genuinely-transient case.
|
|
609
|
-
*/
|
|
610
|
-
declare function fetchTranscriptDataForUrl(transcriptUrl: string, options?: Pick<TranscriptFetchOptions, "cleanTranscript" | "scope">): Promise<TranscriptFetchStepResult>;
|
|
611
|
-
declare function fetchTranscriptForAsset(asset: MuxAsset, playbackId: string, options?: TranscriptFetchOptions): Promise<TranscriptResult>;
|
|
612
|
-
|
|
613
|
-
export { fetchTranscriptDataForUrl as $, type AssetTextTrack as A, type ShotsResult as B, type ChunkEmbedding as C, type DeletedShotsResult as D, type Encrypted as E, type SkippedShotsResult as F, type TranscriptEmptyReason as G, type Hotspot as H, type ImageSubmissionMode as I, type TranscriptFetchOptions as J, type TranscriptFetchStepResult as K, LOW_CONFIDENCE_THRESHOLD as L, type MuxAsset as M, type TranscriptResult as N, type WaitForShotsOptions as O, type PlaybackAsset as P, buildTranscriptUrl as Q, buildVttFromCueBlocks as R, type StoragePutObjectInput as S, type TextChunk as T, type UsageMetadata as U, type VTTChunkingConfig as V, type WorkflowCredentials as W, buildVttFromTranslatedCueBlocks as X, concatenateVttSegments as Y, extractTextFromVTT as Z, extractTimestampedTranscript as _, type StoragePresignGetObjectInput as a, fetchTranscriptForAsset as a0, filterVttByScope as a1, findCaptionTrack as a2, getHotspotsForAsset as a3, getHotspotsForPlaybackId as a4, getHotspotsForVideo as a5, getReadyTextTracks as a6, getReliableLanguageCode as a7, getShotsForAsset as a8, parseVTTCues as a9, replaceCueText as aa, requestShotsForAsset as ab, sanitizeUntrustedText as ac, secondsToTimestamp as ad, splitVttPreambleAndCueBlocks as ae, stripVttMetadataBlocks as af, vttTimestampToSeconds as ag, waitForShotsForAsset as ah, type ChunkingStrategy as b, type EncryptedPayload as c, type MuxAIOptions as d, type PlaybackPolicy as e, type ScopedMuxAIOptions as f, type StorageAdapter as g, type TokenChunkingConfig as h, type TokenUsage as i, type ToneType as j, type VideoEmbeddingsResult as k, type WorkflowCredentialsInput as l, type WorkflowMuxClient as m, type WorkflowScope as n, decryptFromWorkflow as o, encryptForWorkflow as p, type VTTCue as q, type CompletedShotsResult as r, type ErroredShotsResult as s, type HotspotOptions as t, type HotspotResponse as u, MAX_CUE_TEXT_CHARS as v, type ParseVTTCuesOptions as w, type PendingShotsResult as x, type Shot as y, type ShotRequestOptions as z };
|