@mux/ai 0.1.6 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +346 -86
- package/dist/{index-DyTSka2R.d.ts → index-BcNDGOI6.d.ts} +12 -24
- package/dist/{index-Bnv7tv90.d.ts → index-D3fZHu0h.d.ts} +124 -13
- package/dist/index.d.ts +3 -3
- package/dist/index.js +989 -669
- package/dist/index.js.map +1 -1
- package/dist/primitives/index.d.ts +2 -2
- package/dist/primitives/index.js +37 -79
- package/dist/primitives/index.js.map +1 -1
- package/dist/{types-ktXDZ93V.d.mts → types-DzOQNn9R.d.ts} +3 -25
- package/dist/workflows/index.d.ts +2 -2
- package/dist/workflows/index.js +987 -683
- package/dist/workflows/index.js.map +1 -1
- package/package.json +34 -36
- package/dist/index-BNnz9P_5.d.mts +0 -144
- package/dist/index-vJ5r2FNm.d.mts +0 -477
- package/dist/index.d.mts +0 -13
- package/dist/index.mjs +0 -2205
- package/dist/index.mjs.map +0 -1
- package/dist/primitives/index.d.mts +0 -3
- package/dist/primitives/index.mjs +0 -358
- package/dist/primitives/index.mjs.map +0 -1
- package/dist/types-ktXDZ93V.d.ts +0 -137
- package/dist/workflows/index.d.mts +0 -8
- package/dist/workflows/index.mjs +0 -2168
- package/dist/workflows/index.mjs.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mux/ai",
|
|
3
|
-
"
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.3.0",
|
|
4
5
|
"description": "AI library for Mux",
|
|
5
6
|
"author": "Mux",
|
|
6
7
|
"license": "Apache-2.0",
|
|
@@ -39,63 +40,58 @@
|
|
|
39
40
|
"exports": {
|
|
40
41
|
".": {
|
|
41
42
|
"types": {
|
|
42
|
-
"import": "./dist/index.d.
|
|
43
|
-
"require": "./dist/index.d.ts"
|
|
43
|
+
"import": "./dist/index.d.ts"
|
|
44
44
|
},
|
|
45
|
-
"import": "./dist/index.
|
|
46
|
-
"require": "./dist/index.js"
|
|
45
|
+
"import": "./dist/index.js"
|
|
47
46
|
},
|
|
48
47
|
"./primitives": {
|
|
49
48
|
"types": {
|
|
50
|
-
"import": "./dist/primitives/index.d.
|
|
51
|
-
"require": "./dist/primitives/index.d.ts"
|
|
49
|
+
"import": "./dist/primitives/index.d.ts"
|
|
52
50
|
},
|
|
53
|
-
"import": "./dist/primitives/index.
|
|
54
|
-
"require": "./dist/primitives/index.js"
|
|
51
|
+
"import": "./dist/primitives/index.js"
|
|
55
52
|
},
|
|
56
53
|
"./workflows": {
|
|
57
54
|
"types": {
|
|
58
|
-
"import": "./dist/workflows/index.d.
|
|
59
|
-
"require": "./dist/workflows/index.d.ts"
|
|
55
|
+
"import": "./dist/workflows/index.d.ts"
|
|
60
56
|
},
|
|
61
|
-
"import": "./dist/workflows/index.
|
|
62
|
-
"require": "./dist/workflows/index.js"
|
|
57
|
+
"import": "./dist/workflows/index.js"
|
|
63
58
|
}
|
|
64
59
|
},
|
|
65
60
|
"main": "./dist/index.js",
|
|
66
|
-
"module": "./dist/index.
|
|
61
|
+
"module": "./dist/index.js",
|
|
67
62
|
"types": "./dist/index.d.ts",
|
|
68
63
|
"files": [
|
|
69
64
|
"dist"
|
|
70
65
|
],
|
|
71
66
|
"engines": {
|
|
72
|
-
"node": ">=
|
|
67
|
+
"node": ">=21.0.0"
|
|
73
68
|
},
|
|
74
69
|
"scripts": {
|
|
75
70
|
"build": "tsup",
|
|
76
71
|
"dev": "tsup --watch",
|
|
77
|
-
"test": "vitest run",
|
|
78
|
-
"test:watch": "vitest",
|
|
79
|
-
"test:ui": "vitest --ui",
|
|
80
|
-
"test:integration": "vitest run tests/integration",
|
|
81
|
-
"test:
|
|
82
|
-
"test:
|
|
72
|
+
"test": "DOTENV_CONFIG_PATH=.env.test vitest run",
|
|
73
|
+
"test:watch": "DOTENV_CONFIG_PATH=.env.test vitest",
|
|
74
|
+
"test:ui": "DOTENV_CONFIG_PATH=.env.test vitest --ui",
|
|
75
|
+
"test:integration": "DOTENV_CONFIG_PATH=.env.test vitest run tests/integration",
|
|
76
|
+
"test:integration-workflowdevkit": "DOTENV_CONFIG_PATH=.env.test vitest run --config vitest.workflowdevkit.config.ts",
|
|
77
|
+
"test:unit": "DOTENV_CONFIG_PATH=.env.test vitest run tests/unit",
|
|
78
|
+
"test:eval": "DOTENV_CONFIG_PATH=.env.test evalite serve tests/eval",
|
|
83
79
|
"lint": "eslint .",
|
|
84
80
|
"lint:fix": "eslint . --fix",
|
|
85
81
|
"typecheck": "tsc --noEmit",
|
|
86
|
-
"example:chapters": "npx
|
|
87
|
-
"example:chapters:compare": "npx
|
|
88
|
-
"example:burned-in": "npx
|
|
89
|
-
"example:burned-in:compare": "npx
|
|
90
|
-
"example:summarization": "npx
|
|
91
|
-
"example:summarization:compare": "npx
|
|
92
|
-
"example:signed-playback": "npx
|
|
93
|
-
"example:signed-playback:summarization": "npx
|
|
94
|
-
"example:moderation": "npx
|
|
95
|
-
"example:moderation:compare": "npx
|
|
96
|
-
"example:embeddings": "npx
|
|
97
|
-
"example:translate-captions": "npx
|
|
98
|
-
"example:translate-audio": "npx
|
|
82
|
+
"example:chapters": "npx tsx examples/chapters/basic-example.ts",
|
|
83
|
+
"example:chapters:compare": "npx tsx examples/chapters/provider-comparison.ts",
|
|
84
|
+
"example:burned-in": "npx tsx examples/burned-in-captions/basic-example.ts",
|
|
85
|
+
"example:burned-in:compare": "npx tsx examples/burned-in-captions/provider-comparison.ts",
|
|
86
|
+
"example:summarization": "npx tsx examples/summarization/basic-example.ts",
|
|
87
|
+
"example:summarization:compare": "npx tsx examples/summarization/provider-comparison.ts",
|
|
88
|
+
"example:signed-playback": "npx tsx examples/signed-playback/signed-playback.ts",
|
|
89
|
+
"example:signed-playback:summarization": "npx tsx examples/signed-playback/signed-summarization.ts",
|
|
90
|
+
"example:moderation": "npx tsx examples/moderation/basic-example.ts",
|
|
91
|
+
"example:moderation:compare": "npx tsx examples/moderation/provider-comparison.ts",
|
|
92
|
+
"example:embeddings": "npx tsx examples/embeddings/basic-example.ts",
|
|
93
|
+
"example:translate-captions": "npx tsx examples/translate-captions/basic-example.ts",
|
|
94
|
+
"example:translate-audio": "npx tsx examples/translate-audio/basic-example.ts",
|
|
99
95
|
"prepare": "husky"
|
|
100
96
|
},
|
|
101
97
|
"dependencies": {
|
|
@@ -107,6 +103,7 @@
|
|
|
107
103
|
"@aws-sdk/s3-request-presigner": "^3.0.0",
|
|
108
104
|
"@mux/mux-node": "^12.5.0",
|
|
109
105
|
"ai": "^5.0.98",
|
|
106
|
+
"dedent": "^1.7.0",
|
|
110
107
|
"dotenv": "^17.2.2",
|
|
111
108
|
"dotenv-expand": "^12.0.3",
|
|
112
109
|
"p-retry": "^7.0.0",
|
|
@@ -121,11 +118,12 @@
|
|
|
121
118
|
"eslint-plugin-format": "^1.0.2",
|
|
122
119
|
"evalite": "1.0.0-beta.2",
|
|
123
120
|
"husky": "^9.1.7",
|
|
124
|
-
"
|
|
121
|
+
"nitro": "^3.0.1-alpha.1",
|
|
125
122
|
"ts-node": "^10.9.2",
|
|
126
123
|
"tsconfig-paths": "^4.2.0",
|
|
127
124
|
"tsup": "^8.5.0",
|
|
128
125
|
"typescript": "^5.0.0",
|
|
129
|
-
"vitest": "^4.0.13"
|
|
126
|
+
"vitest": "^4.0.13",
|
|
127
|
+
"workflow": "^4.0.1-beta.28"
|
|
130
128
|
}
|
|
131
129
|
}
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { A as AssetTextTrack, b as MuxAsset, e as TextChunk, C as ChunkingStrategy } from './types-ktXDZ93V.mjs';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Context required to sign URLs for signed playback IDs.
|
|
5
|
-
*/
|
|
6
|
-
interface SigningContext {
|
|
7
|
-
/** The signing key ID from Mux dashboard. */
|
|
8
|
-
keyId: string;
|
|
9
|
-
/** The base64-encoded private key from Mux dashboard. */
|
|
10
|
-
keySecret: string;
|
|
11
|
-
/** Token expiration time (e.g. '1h', '1d'). Defaults to '1h'. */
|
|
12
|
-
expiration?: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
declare const DEFAULT_STORYBOARD_WIDTH = 640;
|
|
16
|
-
/**
|
|
17
|
-
* Generates a storyboard URL for the given playback ID.
|
|
18
|
-
* If a signing context is provided, the URL will be signed with a token.
|
|
19
|
-
*
|
|
20
|
-
* @param playbackId - The Mux playback ID
|
|
21
|
-
* @param width - Width of the storyboard in pixels (default: 640)
|
|
22
|
-
* @param signingContext - Optional signing context for signed playback IDs
|
|
23
|
-
* @returns Storyboard URL (signed if context provided)
|
|
24
|
-
*/
|
|
25
|
-
declare function getStoryboardUrl(playbackId: string, width?: number, signingContext?: SigningContext): Promise<string>;
|
|
26
|
-
|
|
27
|
-
/** A single cue from a VTT file with timing info. */
|
|
28
|
-
interface VTTCue {
|
|
29
|
-
startTime: number;
|
|
30
|
-
endTime: number;
|
|
31
|
-
text: string;
|
|
32
|
-
}
|
|
33
|
-
interface TranscriptFetchOptions {
|
|
34
|
-
languageCode?: string;
|
|
35
|
-
cleanTranscript?: boolean;
|
|
36
|
-
/** Optional signing context for signed playback IDs */
|
|
37
|
-
signingContext?: SigningContext;
|
|
38
|
-
}
|
|
39
|
-
interface TranscriptResult {
|
|
40
|
-
transcriptText: string;
|
|
41
|
-
transcriptUrl?: string;
|
|
42
|
-
track?: AssetTextTrack;
|
|
43
|
-
}
|
|
44
|
-
declare function getReadyTextTracks(asset: MuxAsset): AssetTextTrack[];
|
|
45
|
-
declare function findCaptionTrack(asset: MuxAsset, languageCode?: string): AssetTextTrack | undefined;
|
|
46
|
-
declare function extractTextFromVTT(vttContent: string): string;
|
|
47
|
-
declare function vttTimestampToSeconds(timestamp: string): number;
|
|
48
|
-
declare function extractTimestampedTranscript(vttContent: string): string;
|
|
49
|
-
/**
|
|
50
|
-
* Parses VTT content into structured cues with timing.
|
|
51
|
-
*
|
|
52
|
-
* @param vttContent - Raw VTT file content
|
|
53
|
-
* @returns Array of VTT cues with start/end times and text
|
|
54
|
-
*/
|
|
55
|
-
declare function parseVTTCues(vttContent: string): VTTCue[];
|
|
56
|
-
/**
|
|
57
|
-
* Builds a transcript URL for the given playback ID and track ID.
|
|
58
|
-
* If a signing context is provided, the URL will be signed with a token.
|
|
59
|
-
*
|
|
60
|
-
* @param playbackId - The Mux playback ID
|
|
61
|
-
* @param trackId - The text track ID
|
|
62
|
-
* @param signingContext - Optional signing context for signed playback IDs
|
|
63
|
-
* @returns Transcript URL (signed if context provided)
|
|
64
|
-
*/
|
|
65
|
-
declare function buildTranscriptUrl(playbackId: string, trackId: string, signingContext?: SigningContext): Promise<string>;
|
|
66
|
-
declare function fetchTranscriptForAsset(asset: MuxAsset, playbackId: string, options?: TranscriptFetchOptions): Promise<TranscriptResult>;
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Simple token counter that approximates tokens by word count.
|
|
70
|
-
* For production use with OpenAI, consider using a proper tokenizer like tiktoken.
|
|
71
|
-
* This approximation is generally close enough for chunking purposes (1 token ≈ 0.75 words).
|
|
72
|
-
*/
|
|
73
|
-
declare function estimateTokenCount(text: string): number;
|
|
74
|
-
/**
|
|
75
|
-
* Chunks text into overlapping segments based on token count.
|
|
76
|
-
*
|
|
77
|
-
* @param text - The text to chunk
|
|
78
|
-
* @param maxTokens - Maximum tokens per chunk
|
|
79
|
-
* @param overlapTokens - Number of tokens to overlap between chunks
|
|
80
|
-
* @returns Array of text chunks with metadata
|
|
81
|
-
*/
|
|
82
|
-
declare function chunkByTokens(text: string, maxTokens: number, overlapTokens?: number): TextChunk[];
|
|
83
|
-
/**
|
|
84
|
-
* Chunks VTT cues into groups that respect natural cue boundaries.
|
|
85
|
-
* Splits at cue boundaries rather than mid-sentence, preserving accurate timestamps.
|
|
86
|
-
*
|
|
87
|
-
* @param cues - Array of VTT cues to chunk
|
|
88
|
-
* @param maxTokens - Maximum tokens per chunk
|
|
89
|
-
* @param overlapCues - Number of cues to overlap between chunks (default: 2)
|
|
90
|
-
* @returns Array of text chunks with accurate start/end times
|
|
91
|
-
*/
|
|
92
|
-
declare function chunkVTTCues(cues: VTTCue[], maxTokens: number, overlapCues?: number): TextChunk[];
|
|
93
|
-
/**
|
|
94
|
-
* Chunks text according to the specified strategy.
|
|
95
|
-
*
|
|
96
|
-
* @param text - The text to chunk
|
|
97
|
-
* @param strategy - The chunking strategy to use
|
|
98
|
-
* @returns Array of text chunks
|
|
99
|
-
*/
|
|
100
|
-
declare function chunkText(text: string, strategy: ChunkingStrategy): TextChunk[];
|
|
101
|
-
|
|
102
|
-
interface ThumbnailOptions {
|
|
103
|
-
/** Interval between thumbnails in seconds (default: 10) */
|
|
104
|
-
interval?: number;
|
|
105
|
-
/** Width of the thumbnail in pixels (default: 640) */
|
|
106
|
-
width?: number;
|
|
107
|
-
/** Optional signing context for signed playback IDs */
|
|
108
|
-
signingContext?: SigningContext;
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Generates thumbnail URLs at regular intervals based on video duration.
|
|
112
|
-
* If a signing context is provided, the URLs will be signed with tokens.
|
|
113
|
-
*
|
|
114
|
-
* @param playbackId - The Mux playback ID
|
|
115
|
-
* @param duration - Video duration in seconds
|
|
116
|
-
* @param options - Thumbnail generation options
|
|
117
|
-
* @returns Array of thumbnail URLs (signed if context provided)
|
|
118
|
-
*/
|
|
119
|
-
declare function getThumbnailUrls(playbackId: string, duration: number, options?: ThumbnailOptions): Promise<string[]>;
|
|
120
|
-
|
|
121
|
-
declare const index_DEFAULT_STORYBOARD_WIDTH: typeof DEFAULT_STORYBOARD_WIDTH;
|
|
122
|
-
type index_ThumbnailOptions = ThumbnailOptions;
|
|
123
|
-
type index_TranscriptFetchOptions = TranscriptFetchOptions;
|
|
124
|
-
type index_TranscriptResult = TranscriptResult;
|
|
125
|
-
type index_VTTCue = VTTCue;
|
|
126
|
-
declare const index_buildTranscriptUrl: typeof buildTranscriptUrl;
|
|
127
|
-
declare const index_chunkByTokens: typeof chunkByTokens;
|
|
128
|
-
declare const index_chunkText: typeof chunkText;
|
|
129
|
-
declare const index_chunkVTTCues: typeof chunkVTTCues;
|
|
130
|
-
declare const index_estimateTokenCount: typeof estimateTokenCount;
|
|
131
|
-
declare const index_extractTextFromVTT: typeof extractTextFromVTT;
|
|
132
|
-
declare const index_extractTimestampedTranscript: typeof extractTimestampedTranscript;
|
|
133
|
-
declare const index_fetchTranscriptForAsset: typeof fetchTranscriptForAsset;
|
|
134
|
-
declare const index_findCaptionTrack: typeof findCaptionTrack;
|
|
135
|
-
declare const index_getReadyTextTracks: typeof getReadyTextTracks;
|
|
136
|
-
declare const index_getStoryboardUrl: typeof getStoryboardUrl;
|
|
137
|
-
declare const index_getThumbnailUrls: typeof getThumbnailUrls;
|
|
138
|
-
declare const index_parseVTTCues: typeof parseVTTCues;
|
|
139
|
-
declare const index_vttTimestampToSeconds: typeof vttTimestampToSeconds;
|
|
140
|
-
declare namespace index {
|
|
141
|
-
export { index_DEFAULT_STORYBOARD_WIDTH as DEFAULT_STORYBOARD_WIDTH, type index_ThumbnailOptions as ThumbnailOptions, type index_TranscriptFetchOptions as TranscriptFetchOptions, type index_TranscriptResult as TranscriptResult, type index_VTTCue as VTTCue, index_buildTranscriptUrl as buildTranscriptUrl, index_chunkByTokens as chunkByTokens, index_chunkText as chunkText, index_chunkVTTCues as chunkVTTCues, index_estimateTokenCount as estimateTokenCount, index_extractTextFromVTT as extractTextFromVTT, index_extractTimestampedTranscript as extractTimestampedTranscript, index_fetchTranscriptForAsset as fetchTranscriptForAsset, index_findCaptionTrack as findCaptionTrack, index_getReadyTextTracks as getReadyTextTracks, index_getStoryboardUrl as getStoryboardUrl, index_getThumbnailUrls as getThumbnailUrls, index_parseVTTCues as parseVTTCues, index_vttTimestampToSeconds as vttTimestampToSeconds };
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
export { DEFAULT_STORYBOARD_WIDTH as D, type ThumbnailOptions as T, type VTTCue as V, chunkVTTCues as a, chunkText as b, chunkByTokens as c, getThumbnailUrls as d, estimateTokenCount as e, type TranscriptFetchOptions as f, getStoryboardUrl as g, type TranscriptResult as h, index as i, getReadyTextTracks as j, findCaptionTrack as k, extractTextFromVTT as l, extractTimestampedTranscript as m, buildTranscriptUrl as n, fetchTranscriptForAsset as o, parseVTTCues as p, vttTimestampToSeconds as v };
|