@mux/ai 0.1.1 → 0.1.2
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.cjs +1773 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +164 -0
- package/dist/index.d.ts +164 -9
- package/dist/index.js +1757 -8
- package/dist/index.js.map +1 -1
- package/package.json +8 -6
- package/dist/audio-translation.d.ts +0 -21
- package/dist/audio-translation.d.ts.map +0 -1
- package/dist/audio-translation.js +0 -229
- package/dist/audio-translation.js.map +0 -1
- package/dist/burned-in-captions.d.ts +0 -19
- package/dist/burned-in-captions.d.ts.map +0 -1
- package/dist/burned-in-captions.js +0 -243
- package/dist/burned-in-captions.js.map +0 -1
- package/dist/chapters.d.ts +0 -18
- package/dist/chapters.d.ts.map +0 -1
- package/dist/chapters.js +0 -255
- package/dist/chapters.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/moderation.d.ts +0 -39
- package/dist/moderation.d.ts.map +0 -1
- package/dist/moderation.js +0 -341
- package/dist/moderation.js.map +0 -1
- package/dist/summarization.d.ts +0 -26
- package/dist/summarization.d.ts.map +0 -1
- package/dist/summarization.js +0 -337
- package/dist/summarization.js.map +0 -1
- package/dist/translation.d.ts +0 -22
- package/dist/translation.d.ts.map +0 -1
- package/dist/translation.js +0 -196
- package/dist/translation.js.map +0 -1
- package/dist/types.d.ts +0 -12
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/utils/image-download.d.ts +0 -65
- package/dist/utils/image-download.d.ts.map +0 -1
- package/dist/utils/image-download.js +0 -150
- package/dist/utils/image-download.js.map +0 -1
- package/dist/utils/storyboard-processor.d.ts +0 -40
- package/dist/utils/storyboard-processor.d.ts.map +0 -1
- package/dist/utils/storyboard-processor.js +0 -202
- package/dist/utils/storyboard-processor.js.map +0 -1
- package/dist/utils/vtt-parser.d.ts +0 -8
- package/dist/utils/vtt-parser.d.ts.map +0 -1
- package/dist/utils/vtt-parser.js +0 -43
- package/dist/utils/vtt-parser.js.map +0 -1
package/dist/types.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export interface MuxAIConfig {
|
|
2
|
-
muxTokenId?: string;
|
|
3
|
-
muxTokenSecret?: string;
|
|
4
|
-
openaiApiKey?: string;
|
|
5
|
-
anthropicApiKey?: string;
|
|
6
|
-
baseUrl?: string;
|
|
7
|
-
}
|
|
8
|
-
export interface MuxAIOptions extends MuxAIConfig {
|
|
9
|
-
timeout?: number;
|
|
10
|
-
}
|
|
11
|
-
export type ToneType = 'normal' | 'sassy' | 'professional';
|
|
12
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,YAAa,SAAQ,WAAW;IAC/C,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,cAAc,CAAC"}
|
package/dist/types.js
DELETED
package/dist/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
export interface ImageDownloadOptions {
|
|
2
|
-
/** Request timeout in milliseconds (default: 10000) */
|
|
3
|
-
timeout?: number;
|
|
4
|
-
/** Maximum number of retry attempts (default: 3) */
|
|
5
|
-
retries?: number;
|
|
6
|
-
/** Base delay between retries in milliseconds (default: 1000) */
|
|
7
|
-
retryDelay?: number;
|
|
8
|
-
/** Maximum delay between retries in milliseconds (default: 10000) */
|
|
9
|
-
maxRetryDelay?: number;
|
|
10
|
-
/** Whether to use exponential backoff (default: true) */
|
|
11
|
-
exponentialBackoff?: boolean;
|
|
12
|
-
}
|
|
13
|
-
export interface ImageDownloadResult {
|
|
14
|
-
/** Base64 encoded image data with data URI prefix (e.g., "data:image/png;base64,iVBORw0K...") */
|
|
15
|
-
base64Data: string;
|
|
16
|
-
/** Raw image buffer for multipart/form-data uploads */
|
|
17
|
-
buffer: Buffer;
|
|
18
|
-
/** Original image URL */
|
|
19
|
-
url: string;
|
|
20
|
-
/** Content type of the downloaded image */
|
|
21
|
-
contentType: string;
|
|
22
|
-
/** Size of the downloaded image in bytes */
|
|
23
|
-
sizeBytes: number;
|
|
24
|
-
/** Number of retry attempts made (0 if successful on first try) */
|
|
25
|
-
attempts: number;
|
|
26
|
-
}
|
|
27
|
-
export interface AnthropicFileUploadResult {
|
|
28
|
-
/** Anthropic Files API file ID */
|
|
29
|
-
fileId: string;
|
|
30
|
-
/** Original image URL */
|
|
31
|
-
url: string;
|
|
32
|
-
/** Content type of the uploaded image */
|
|
33
|
-
contentType: string;
|
|
34
|
-
/** Size of the uploaded image in bytes */
|
|
35
|
-
sizeBytes: number;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Downloads an image from a URL and converts it to base64 with robust retry logic
|
|
39
|
-
*
|
|
40
|
-
* @param url - The image URL to download
|
|
41
|
-
* @param options - Download configuration options
|
|
42
|
-
* @returns Promise resolving to ImageDownloadResult with base64 data and metadata
|
|
43
|
-
* @throws Error if download fails after all retries
|
|
44
|
-
*/
|
|
45
|
-
export declare function downloadImageAsBase64(url: string, options?: ImageDownloadOptions): Promise<ImageDownloadResult>;
|
|
46
|
-
/**
|
|
47
|
-
* Downloads multiple images concurrently with controlled concurrency
|
|
48
|
-
*
|
|
49
|
-
* @param urls - Array of image URLs to download
|
|
50
|
-
* @param options - Download configuration options
|
|
51
|
-
* @param maxConcurrent - Maximum concurrent downloads (default: 5)
|
|
52
|
-
* @returns Promise resolving to array of ImageDownloadResult (in same order as input URLs)
|
|
53
|
-
*/
|
|
54
|
-
export declare function downloadImagesAsBase64(urls: string[], options?: ImageDownloadOptions, maxConcurrent?: number): Promise<ImageDownloadResult[]>;
|
|
55
|
-
/**
|
|
56
|
-
* Uploads an image to Anthropic Files API for use in messages
|
|
57
|
-
*
|
|
58
|
-
* @param url - The image URL to download and upload
|
|
59
|
-
* @param anthropicApiKey - Anthropic API key
|
|
60
|
-
* @param options - Download configuration options
|
|
61
|
-
* @returns Promise resolving to AnthropicFileUploadResult with file ID and metadata
|
|
62
|
-
* @throws Error if download or upload fails
|
|
63
|
-
*/
|
|
64
|
-
export declare function uploadImageToAnthropicFiles(url: string, anthropicApiKey: string, options?: ImageDownloadOptions): Promise<AnthropicFileUploadResult>;
|
|
65
|
-
//# sourceMappingURL=image-download.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"image-download.d.ts","sourceRoot":"","sources":["../../src/utils/image-download.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,oBAAoB;IACnC,uDAAuD;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oDAAoD;IACpD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iEAAiE;IACjE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qEAAqE;IACrE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,yDAAyD;IACzD,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,MAAM,WAAW,mBAAmB;IAClC,iGAAiG;IACjG,UAAU,EAAE,MAAM,CAAC;IACnB,uDAAuD;IACvD,MAAM,EAAE,MAAM,CAAC;IACf,yBAAyB;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,2CAA2C;IAC3C,WAAW,EAAE,MAAM,CAAC;IACpB,4CAA4C;IAC5C,SAAS,EAAE,MAAM,CAAC;IAClB,mEAAmE;IACnE,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,yBAAyB;IACxC,kCAAkC;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,yBAAyB;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,yCAAyC;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,0CAA0C;IAC1C,SAAS,EAAE,MAAM,CAAC;CACnB;AAUD;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,mBAAmB,CAAC,CAsF9B;AAED;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,GAAE,oBAAyB,EAClC,aAAa,GAAE,MAAU,GACxB,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAWhC;AAED;;;;;;;;GAQG;AACH,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,MAAM,EACX,eAAe,EAAE,MAAM,EACvB,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,yBAAyB,CAAC,CAyCpC"}
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import pRetry, { AbortError } from 'p-retry';
|
|
2
|
-
const DEFAULT_OPTIONS = {
|
|
3
|
-
timeout: 10000,
|
|
4
|
-
retries: 3,
|
|
5
|
-
retryDelay: 1000,
|
|
6
|
-
maxRetryDelay: 10000,
|
|
7
|
-
exponentialBackoff: true,
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* Downloads an image from a URL and converts it to base64 with robust retry logic
|
|
11
|
-
*
|
|
12
|
-
* @param url - The image URL to download
|
|
13
|
-
* @param options - Download configuration options
|
|
14
|
-
* @returns Promise resolving to ImageDownloadResult with base64 data and metadata
|
|
15
|
-
* @throws Error if download fails after all retries
|
|
16
|
-
*/
|
|
17
|
-
export async function downloadImageAsBase64(url, options = {}) {
|
|
18
|
-
const opts = { ...DEFAULT_OPTIONS, ...options };
|
|
19
|
-
let attemptCount = 0;
|
|
20
|
-
return pRetry(async () => {
|
|
21
|
-
attemptCount++;
|
|
22
|
-
const controller = new AbortController();
|
|
23
|
-
const timeoutId = setTimeout(() => controller.abort(), opts.timeout);
|
|
24
|
-
try {
|
|
25
|
-
const response = await fetch(url, {
|
|
26
|
-
signal: controller.signal,
|
|
27
|
-
headers: {
|
|
28
|
-
'User-Agent': '@mux/ai image downloader',
|
|
29
|
-
},
|
|
30
|
-
});
|
|
31
|
-
clearTimeout(timeoutId);
|
|
32
|
-
if (!response.ok) {
|
|
33
|
-
// Don't retry 4xx errors (except 429 rate limiting)
|
|
34
|
-
if (response.status >= 400 && response.status < 500 && response.status !== 429) {
|
|
35
|
-
throw new AbortError(`HTTP ${response.status}: ${response.statusText}`);
|
|
36
|
-
}
|
|
37
|
-
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
38
|
-
}
|
|
39
|
-
const contentType = response.headers.get('content-type');
|
|
40
|
-
if (!contentType?.startsWith('image/')) {
|
|
41
|
-
throw new AbortError(`Invalid content type: ${contentType}. Expected image/*`);
|
|
42
|
-
}
|
|
43
|
-
const arrayBuffer = await response.arrayBuffer();
|
|
44
|
-
const buffer = Buffer.from(arrayBuffer);
|
|
45
|
-
if (buffer.length === 0) {
|
|
46
|
-
throw new AbortError('Downloaded image is empty');
|
|
47
|
-
}
|
|
48
|
-
// Convert to base64 with data URI prefix
|
|
49
|
-
const base64Data = `data:${contentType};base64,${buffer.toString('base64')}`;
|
|
50
|
-
return {
|
|
51
|
-
base64Data,
|
|
52
|
-
buffer,
|
|
53
|
-
url,
|
|
54
|
-
contentType,
|
|
55
|
-
sizeBytes: buffer.length,
|
|
56
|
-
attempts: attemptCount,
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
catch (error) {
|
|
60
|
-
clearTimeout(timeoutId);
|
|
61
|
-
// If it's an AbortError (non-retryable), re-throw it
|
|
62
|
-
if (error instanceof AbortError) {
|
|
63
|
-
throw error;
|
|
64
|
-
}
|
|
65
|
-
// For network errors, timeout errors, etc., wrap in retryable error
|
|
66
|
-
if (error instanceof Error) {
|
|
67
|
-
if (error.name === 'AbortError') {
|
|
68
|
-
throw new Error(`Request timeout after ${opts.timeout}ms`);
|
|
69
|
-
}
|
|
70
|
-
throw new Error(`Download failed: ${error.message}`);
|
|
71
|
-
}
|
|
72
|
-
throw new Error('Unknown download error');
|
|
73
|
-
}
|
|
74
|
-
}, {
|
|
75
|
-
retries: opts.retries,
|
|
76
|
-
minTimeout: opts.retryDelay,
|
|
77
|
-
maxTimeout: opts.maxRetryDelay,
|
|
78
|
-
factor: opts.exponentialBackoff ? 2 : 1,
|
|
79
|
-
randomize: true, // Add jitter to prevent thundering herd
|
|
80
|
-
onFailedAttempt: (error) => {
|
|
81
|
-
console.warn(`Image download attempt ${error.attemptNumber} failed for ${url}`);
|
|
82
|
-
if (error.retriesLeft > 0) {
|
|
83
|
-
console.warn(`Retrying... (${error.retriesLeft} attempts left)`);
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Downloads multiple images concurrently with controlled concurrency
|
|
90
|
-
*
|
|
91
|
-
* @param urls - Array of image URLs to download
|
|
92
|
-
* @param options - Download configuration options
|
|
93
|
-
* @param maxConcurrent - Maximum concurrent downloads (default: 5)
|
|
94
|
-
* @returns Promise resolving to array of ImageDownloadResult (in same order as input URLs)
|
|
95
|
-
*/
|
|
96
|
-
export async function downloadImagesAsBase64(urls, options = {}, maxConcurrent = 5) {
|
|
97
|
-
const results = [];
|
|
98
|
-
for (let i = 0; i < urls.length; i += maxConcurrent) {
|
|
99
|
-
const batch = urls.slice(i, i + maxConcurrent);
|
|
100
|
-
const batchPromises = batch.map(url => downloadImageAsBase64(url, options));
|
|
101
|
-
const batchResults = await Promise.all(batchPromises);
|
|
102
|
-
results.push(...batchResults);
|
|
103
|
-
}
|
|
104
|
-
return results;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Uploads an image to Anthropic Files API for use in messages
|
|
108
|
-
*
|
|
109
|
-
* @param url - The image URL to download and upload
|
|
110
|
-
* @param anthropicApiKey - Anthropic API key
|
|
111
|
-
* @param options - Download configuration options
|
|
112
|
-
* @returns Promise resolving to AnthropicFileUploadResult with file ID and metadata
|
|
113
|
-
* @throws Error if download or upload fails
|
|
114
|
-
*/
|
|
115
|
-
export async function uploadImageToAnthropicFiles(url, anthropicApiKey, options = {}) {
|
|
116
|
-
// First download the image
|
|
117
|
-
const downloadResult = await downloadImageAsBase64(url, options);
|
|
118
|
-
// Create form data for Files API upload
|
|
119
|
-
const formData = new FormData();
|
|
120
|
-
// Create a Blob from the buffer for form data
|
|
121
|
-
const imageBlob = new Blob([downloadResult.buffer], {
|
|
122
|
-
type: downloadResult.contentType
|
|
123
|
-
});
|
|
124
|
-
// Get file extension from content type
|
|
125
|
-
const extension = downloadResult.contentType.split('/')[1] || 'png';
|
|
126
|
-
formData.append('file', imageBlob, `image.${extension}`);
|
|
127
|
-
// Upload to Anthropic Files API
|
|
128
|
-
const response = await fetch('https://api.anthropic.com/v1/files', {
|
|
129
|
-
method: 'POST',
|
|
130
|
-
headers: {
|
|
131
|
-
'x-api-key': anthropicApiKey,
|
|
132
|
-
'anthropic-version': '2023-06-01',
|
|
133
|
-
'anthropic-beta': 'files-api-2025-04-14',
|
|
134
|
-
// Don't set Content-Type header - let fetch set it with boundary for multipart
|
|
135
|
-
},
|
|
136
|
-
body: formData
|
|
137
|
-
});
|
|
138
|
-
if (!response.ok) {
|
|
139
|
-
const errorText = await response.text();
|
|
140
|
-
throw new Error(`Anthropic Files API error: ${response.status} ${response.statusText} - ${errorText}`);
|
|
141
|
-
}
|
|
142
|
-
const fileResult = await response.json();
|
|
143
|
-
return {
|
|
144
|
-
fileId: fileResult.id,
|
|
145
|
-
url: downloadResult.url,
|
|
146
|
-
contentType: downloadResult.contentType,
|
|
147
|
-
sizeBytes: downloadResult.sizeBytes,
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
//# sourceMappingURL=image-download.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"image-download.js","sourceRoot":"","sources":["../../src/utils/image-download.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAyC7C,MAAM,eAAe,GAAmC;IACtD,OAAO,EAAE,KAAK;IACd,OAAO,EAAE,CAAC;IACV,UAAU,EAAE,IAAI;IAChB,aAAa,EAAE,KAAK;IACpB,kBAAkB,EAAE,IAAI;CACzB,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,GAAW,EACX,UAAgC,EAAE;IAElC,MAAM,IAAI,GAAG,EAAE,GAAG,eAAe,EAAE,GAAG,OAAO,EAAE,CAAC;IAChD,IAAI,YAAY,GAAG,CAAC,CAAC;IAErB,OAAO,MAAM,CACX,KAAK,IAAI,EAAE;QACT,YAAY,EAAE,CAAC;QAEf,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;QACzC,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAErE,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;gBAChC,MAAM,EAAE,UAAU,CAAC,MAAM;gBACzB,OAAO,EAAE;oBACP,YAAY,EAAE,0BAA0B;iBACzC;aACF,CAAC,CAAC;YAEH,YAAY,CAAC,SAAS,CAAC,CAAC;YAExB,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;gBACjB,oDAAoD;gBACpD,IAAI,QAAQ,CAAC,MAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,MAAM,G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,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,8BAA8B,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,MAAM,SAAS,EAAE,CAAC,CAAC;IACzG,CAAC;IAED,MAAM,UAAU,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAoB,CAAC;IAE3D,OAAO;QACL,MAAM,EAAE,UAAU,CAAC,EAAE;QACrB,GAAG,EAAE,cAAc,CAAC,GAAG;QACvB,WAAW,EAAE,cAAc,CAAC,WAAW;QACvC,SAAS,EAAE,cAAc,CAAC,SAAS;KACpC,CAAC;AACJ,CAAC"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { ImageDownloadOptions } from './image-download';
|
|
2
|
-
export interface StoryboardProcessorOptions {
|
|
3
|
-
muxTokenId?: string;
|
|
4
|
-
muxTokenSecret?: string;
|
|
5
|
-
openaiApiKey?: string;
|
|
6
|
-
anthropicApiKey?: string;
|
|
7
|
-
imageSubmissionMode?: 'url' | 'base64';
|
|
8
|
-
imageDownloadOptions?: ImageDownloadOptions;
|
|
9
|
-
}
|
|
10
|
-
export interface AssetInfo {
|
|
11
|
-
playbackId: string;
|
|
12
|
-
duration?: number;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Retrieves asset information from Mux including playback ID and duration
|
|
16
|
-
*/
|
|
17
|
-
export declare function getAssetInfo(assetId: string, options: StoryboardProcessorOptions): Promise<AssetInfo>;
|
|
18
|
-
/**
|
|
19
|
-
* Processes a storyboard image with OpenAI
|
|
20
|
-
*/
|
|
21
|
-
export declare function processStoryboardWithOpenAI<T>(imageUrl: string, prompt: string, systemPrompt: string, options: {
|
|
22
|
-
apiKey: string;
|
|
23
|
-
model: string;
|
|
24
|
-
responseParser: (response: any) => T;
|
|
25
|
-
imageSubmissionMode?: 'url' | 'base64';
|
|
26
|
-
imageDownloadOptions?: ImageDownloadOptions;
|
|
27
|
-
maxRetries?: number;
|
|
28
|
-
}): Promise<T>;
|
|
29
|
-
/**
|
|
30
|
-
* Processes a storyboard image with Anthropic
|
|
31
|
-
*/
|
|
32
|
-
export declare function processStoryboardWithAnthropic<T>(imageUrl: string, prompt: string, options: {
|
|
33
|
-
apiKey: string;
|
|
34
|
-
model: string;
|
|
35
|
-
responseParser: (response: any) => T;
|
|
36
|
-
imageSubmissionMode?: 'url' | 'base64';
|
|
37
|
-
imageDownloadOptions?: ImageDownloadOptions;
|
|
38
|
-
maxRetries?: number;
|
|
39
|
-
}): Promise<T>;
|
|
40
|
-
//# sourceMappingURL=storyboard-processor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storyboard-processor.d.ts","sourceRoot":"","sources":["../../src/utils/storyboard-processor.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAsD,MAAM,kBAAkB,CAAC;AAE5G,MAAM,WAAW,0BAA0B;IACzC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,mBAAmB,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;IACvC,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;CAC7C;AAED,MAAM,WAAW,SAAS;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,SAAS,CAAC,CA4B3G;AAED;;GAEG;AACH,wBAAsB,2BAA2B,CAAC,CAAC,EACjD,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE;IACP,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,CAAC,QAAQ,EAAE,GAAG,KAAK,CAAC,CAAC;IACrC,mBAAmB,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;IACvC,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAC5C,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GACA,OAAO,CAAC,CAAC,CAAC,CAwFZ;AAED;;GAEG;AACH,wBAAsB,8BAA8B,CAAC,CAAC,EACpD,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE;IACP,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,CAAC,QAAQ,EAAE,GAAG,KAAK,CAAC,CAAC;IACrC,mBAAmB,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;IACvC,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAC5C,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GACA,OAAO,CAAC,CAAC,CAAC,CAsFZ"}
|
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
import Mux from '@mux/mux-node';
|
|
2
|
-
import OpenAI from 'openai';
|
|
3
|
-
import Anthropic from '@anthropic-ai/sdk';
|
|
4
|
-
import { downloadImageAsBase64, uploadImageToAnthropicFiles } from './image-download';
|
|
5
|
-
/**
|
|
6
|
-
* Retrieves asset information from Mux including playback ID and duration
|
|
7
|
-
*/
|
|
8
|
-
export async function getAssetInfo(assetId, options) {
|
|
9
|
-
const muxId = options.muxTokenId || process.env.MUX_TOKEN_ID;
|
|
10
|
-
const muxSecret = options.muxTokenSecret || process.env.MUX_TOKEN_SECRET;
|
|
11
|
-
if (!muxId || !muxSecret) {
|
|
12
|
-
throw new Error('Mux credentials are required. Provide muxTokenId and muxTokenSecret in options or set MUX_TOKEN_ID and MUX_TOKEN_SECRET environment variables.');
|
|
13
|
-
}
|
|
14
|
-
const mux = new Mux({
|
|
15
|
-
tokenId: muxId,
|
|
16
|
-
tokenSecret: muxSecret,
|
|
17
|
-
});
|
|
18
|
-
try {
|
|
19
|
-
const asset = await mux.video.assets.retrieve(assetId);
|
|
20
|
-
const playbackId = asset.playback_ids?.[0]?.id;
|
|
21
|
-
if (!playbackId) {
|
|
22
|
-
throw new Error('No playback ID found for this asset');
|
|
23
|
-
}
|
|
24
|
-
return {
|
|
25
|
-
playbackId,
|
|
26
|
-
duration: asset.duration || undefined
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
catch (error) {
|
|
30
|
-
throw new Error(`Failed to fetch asset from Mux: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Processes a storyboard image with OpenAI
|
|
35
|
-
*/
|
|
36
|
-
export async function processStoryboardWithOpenAI(imageUrl, prompt, systemPrompt, options) {
|
|
37
|
-
const { apiKey, model, responseParser, imageSubmissionMode = 'url', imageDownloadOptions, maxRetries = 3 } = options;
|
|
38
|
-
const openaiClient = new OpenAI({ apiKey });
|
|
39
|
-
let retryAttempt = 0;
|
|
40
|
-
if (imageSubmissionMode === 'base64') {
|
|
41
|
-
try {
|
|
42
|
-
const downloadResult = await downloadImageAsBase64(imageUrl, imageDownloadOptions);
|
|
43
|
-
const response = await openaiClient.chat.completions.create({
|
|
44
|
-
model,
|
|
45
|
-
messages: [
|
|
46
|
-
{
|
|
47
|
-
role: "system",
|
|
48
|
-
content: systemPrompt,
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
role: "user",
|
|
52
|
-
content: [
|
|
53
|
-
{
|
|
54
|
-
type: "text",
|
|
55
|
-
text: prompt,
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
type: "image_url",
|
|
59
|
-
image_url: {
|
|
60
|
-
url: downloadResult.base64Data,
|
|
61
|
-
detail: "high",
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
],
|
|
65
|
-
},
|
|
66
|
-
],
|
|
67
|
-
});
|
|
68
|
-
return responseParser(response);
|
|
69
|
-
}
|
|
70
|
-
catch (error) {
|
|
71
|
-
throw new Error(`Failed to process storyboard with OpenAI in base64 mode: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
// URL-based submission with retry logic
|
|
76
|
-
while (retryAttempt <= maxRetries) {
|
|
77
|
-
try {
|
|
78
|
-
const response = await openaiClient.chat.completions.create({
|
|
79
|
-
model,
|
|
80
|
-
messages: [
|
|
81
|
-
{
|
|
82
|
-
role: "system",
|
|
83
|
-
content: systemPrompt,
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
role: "user",
|
|
87
|
-
content: [
|
|
88
|
-
{
|
|
89
|
-
type: "text",
|
|
90
|
-
text: prompt,
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
type: "image_url",
|
|
94
|
-
image_url: {
|
|
95
|
-
url: imageUrl,
|
|
96
|
-
detail: "high",
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
],
|
|
100
|
-
},
|
|
101
|
-
],
|
|
102
|
-
});
|
|
103
|
-
return responseParser(response);
|
|
104
|
-
}
|
|
105
|
-
catch (error) {
|
|
106
|
-
const isTimeoutError = error instanceof Error && error.message && error.message.includes('Timeout while downloading');
|
|
107
|
-
if (isTimeoutError && retryAttempt < maxRetries) {
|
|
108
|
-
await new Promise(resolve => setTimeout(resolve, 5000));
|
|
109
|
-
retryAttempt++;
|
|
110
|
-
continue;
|
|
111
|
-
}
|
|
112
|
-
throw new Error(`Failed to process storyboard with OpenAI: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
throw new Error('All retry attempts failed');
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Processes a storyboard image with Anthropic
|
|
120
|
-
*/
|
|
121
|
-
export async function processStoryboardWithAnthropic(imageUrl, prompt, options) {
|
|
122
|
-
const { apiKey, model, responseParser, imageSubmissionMode = 'url', imageDownloadOptions, maxRetries = 3 } = options;
|
|
123
|
-
const anthropicClient = new Anthropic({ apiKey });
|
|
124
|
-
let retryAttempt = 0;
|
|
125
|
-
if (imageSubmissionMode === 'base64') {
|
|
126
|
-
try {
|
|
127
|
-
// Upload to Files API instead of using base64 inline (no 5MB limit)
|
|
128
|
-
const fileUploadResult = await uploadImageToAnthropicFiles(imageUrl, apiKey, imageDownloadOptions);
|
|
129
|
-
const response = await anthropicClient.messages.create({
|
|
130
|
-
model,
|
|
131
|
-
max_tokens: 1000,
|
|
132
|
-
messages: [
|
|
133
|
-
{
|
|
134
|
-
role: "user",
|
|
135
|
-
content: [
|
|
136
|
-
{
|
|
137
|
-
type: "image",
|
|
138
|
-
source: {
|
|
139
|
-
type: "file",
|
|
140
|
-
file_id: fileUploadResult.fileId,
|
|
141
|
-
}, // Type assertion for Files API support
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
type: "text",
|
|
145
|
-
text: prompt,
|
|
146
|
-
},
|
|
147
|
-
],
|
|
148
|
-
},
|
|
149
|
-
],
|
|
150
|
-
}, {
|
|
151
|
-
headers: {
|
|
152
|
-
'anthropic-beta': 'files-api-2025-04-14'
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
return responseParser(response);
|
|
156
|
-
}
|
|
157
|
-
catch (error) {
|
|
158
|
-
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
159
|
-
throw new Error(`Failed to process storyboard with Anthropic Files API: ${errorMessage}`);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
// URL-based submission with retry logic
|
|
164
|
-
while (retryAttempt <= maxRetries) {
|
|
165
|
-
try {
|
|
166
|
-
const response = await anthropicClient.messages.create({
|
|
167
|
-
model,
|
|
168
|
-
max_tokens: 1000,
|
|
169
|
-
messages: [
|
|
170
|
-
{
|
|
171
|
-
role: "user",
|
|
172
|
-
content: [
|
|
173
|
-
{
|
|
174
|
-
type: "image",
|
|
175
|
-
source: {
|
|
176
|
-
type: "url",
|
|
177
|
-
url: imageUrl,
|
|
178
|
-
}, // Type assertion to work around SDK type definitions
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
type: "text",
|
|
182
|
-
text: prompt,
|
|
183
|
-
},
|
|
184
|
-
],
|
|
185
|
-
},
|
|
186
|
-
],
|
|
187
|
-
});
|
|
188
|
-
return responseParser(response);
|
|
189
|
-
}
|
|
190
|
-
catch (error) {
|
|
191
|
-
if (retryAttempt < maxRetries) {
|
|
192
|
-
await new Promise(resolve => setTimeout(resolve, 5000));
|
|
193
|
-
retryAttempt++;
|
|
194
|
-
continue;
|
|
195
|
-
}
|
|
196
|
-
throw new Error(`Failed to process storyboard with Anthropic: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
throw new Error('All retry attempts failed');
|
|
201
|
-
}
|
|
202
|
-
//# sourceMappingURL=storyboard-processor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storyboard-processor.js","sourceRoot":"","sources":["../../src/utils/storyboard-processor.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,eAAe,CAAC;AAChC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAwB,qBAAqB,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAgB5G;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAAe,EAAE,OAAmC;IACrF,MAAM,KAAK,GAAG,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;IAC7D,MAAM,SAAS,GAAG,OAAO,CAAC,cAAc,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;IAEzE,IAAI,CAAC,KAAK,IAAI,CAAC,SAAS,EAAE,CAAC;QACzB,MAA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BACxB,IAAI,YAAY,GAAG,UAAU,EAAE,CAAC;oBAC9B,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;oBACxD,YAAY,EAAE,CAAC;oBACf,SAAS;gBACX,CAAC;gBAED,MAAM,IAAI,KAAK,CAAC,gDAAgD,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC,CAAC;YAC9H,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Parses WebVTT content and extracts clean text for AI processing
|
|
3
|
-
*
|
|
4
|
-
* @param vttContent - Raw WebVTT content
|
|
5
|
-
* @returns Clean transcript text without timestamps and markers
|
|
6
|
-
*/
|
|
7
|
-
export declare function extractTextFromVTT(vttContent: string): string;
|
|
8
|
-
//# sourceMappingURL=vtt-parser.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vtt-parser.d.ts","sourceRoot":"","sources":["../../src/utils/vtt-parser.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAwC7D"}
|
package/dist/utils/vtt-parser.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Parses WebVTT content and extracts clean text for AI processing
|
|
3
|
-
*
|
|
4
|
-
* @param vttContent - Raw WebVTT content
|
|
5
|
-
* @returns Clean transcript text without timestamps and markers
|
|
6
|
-
*/
|
|
7
|
-
export function extractTextFromVTT(vttContent) {
|
|
8
|
-
if (!vttContent.trim()) {
|
|
9
|
-
return '';
|
|
10
|
-
}
|
|
11
|
-
const lines = vttContent.split('\n');
|
|
12
|
-
const textLines = [];
|
|
13
|
-
for (let i = 0; i < lines.length; i++) {
|
|
14
|
-
const line = lines[i].trim();
|
|
15
|
-
// Skip empty lines
|
|
16
|
-
if (!line)
|
|
17
|
-
continue;
|
|
18
|
-
// Skip WEBVTT header
|
|
19
|
-
if (line === 'WEBVTT')
|
|
20
|
-
continue;
|
|
21
|
-
// Skip NOTE lines
|
|
22
|
-
if (line.startsWith('NOTE '))
|
|
23
|
-
continue;
|
|
24
|
-
// Skip timestamp lines (contain -->)
|
|
25
|
-
if (line.includes('-->'))
|
|
26
|
-
continue;
|
|
27
|
-
// Skip cue identifiers (numeric or UUID-like patterns)
|
|
28
|
-
if (/^[\d\w-]+$/.test(line) && !line.includes(' '))
|
|
29
|
-
continue;
|
|
30
|
-
// Skip style/formatting tags
|
|
31
|
-
if (line.startsWith('STYLE') || line.startsWith('REGION'))
|
|
32
|
-
continue;
|
|
33
|
-
// This should be subtitle text
|
|
34
|
-
// Remove any inline formatting tags like <c.color> or <b>
|
|
35
|
-
const cleanLine = line.replace(/<[^>]*>/g, '').trim();
|
|
36
|
-
if (cleanLine) {
|
|
37
|
-
textLines.push(cleanLine);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
// Join all text lines with spaces and clean up multiple spaces
|
|
41
|
-
return textLines.join(' ').replace(/\s+/g, ' ').trim();
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=vtt-parser.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vtt-parser.js","sourceRoot":"","sources":["../../src/utils/vtt-parser.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,UAAkB;IACnD,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC;QACvB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACrC,MAAM,SAAS,GAAa,EAA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