google-veo3-1-mcp-server 1.0.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 +257 -0
- package/dist/cli/batch.d.ts +8 -0
- package/dist/cli/batch.d.ts.map +1 -0
- package/dist/cli/batch.js +289 -0
- package/dist/cli/batch.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +372 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/extend.d.ts +14 -0
- package/dist/tools/extend.d.ts.map +1 -0
- package/dist/tools/extend.js +153 -0
- package/dist/tools/extend.js.map +1 -0
- package/dist/tools/generate.d.ts +10 -0
- package/dist/tools/generate.d.ts.map +1 -0
- package/dist/tools/generate.js +210 -0
- package/dist/tools/generate.js.map +1 -0
- package/dist/tools/interpolate.d.ts +12 -0
- package/dist/tools/interpolate.d.ts.map +1 -0
- package/dist/tools/interpolate.js +170 -0
- package/dist/tools/interpolate.js.map +1 -0
- package/dist/types/batch.d.ts +121 -0
- package/dist/types/batch.d.ts.map +1 -0
- package/dist/types/batch.js +37 -0
- package/dist/types/batch.js.map +1 -0
- package/dist/types/tools.d.ts +154 -0
- package/dist/types/tools.d.ts.map +1 -0
- package/dist/types/tools.js +134 -0
- package/dist/types/tools.js.map +1 -0
- package/dist/utils/batch-config.d.ts +26 -0
- package/dist/utils/batch-config.d.ts.map +1 -0
- package/dist/utils/batch-config.js +283 -0
- package/dist/utils/batch-config.js.map +1 -0
- package/dist/utils/batch-manager.d.ts +43 -0
- package/dist/utils/batch-manager.d.ts.map +1 -0
- package/dist/utils/batch-manager.js +310 -0
- package/dist/utils/batch-manager.js.map +1 -0
- package/dist/utils/debug.d.ts +16 -0
- package/dist/utils/debug.d.ts.map +1 -0
- package/dist/utils/debug.js +44 -0
- package/dist/utils/debug.js.map +1 -0
- package/dist/utils/path.d.ts +36 -0
- package/dist/utils/path.d.ts.map +1 -0
- package/dist/utils/path.js +97 -0
- package/dist/utils/path.js.map +1 -0
- package/dist/utils/video.d.ts +44 -0
- package/dist/utils/video.d.ts.map +1 -0
- package/dist/utils/video.js +261 -0
- package/dist/utils/video.js.map +1 -0
- package/docs/GOOGLE_VEO_3.1_API_SPECIFICATION.md +392 -0
- package/examples/batch-config.json +44 -0
- package/package.json +48 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Batch Execution Manager
|
|
3
|
+
*/
|
|
4
|
+
import { type BatchConfig, type BatchExecutionOptions, type BatchResult, type BatchCostEstimate } from '../types/batch.js';
|
|
5
|
+
export declare class BatchManager {
|
|
6
|
+
private config;
|
|
7
|
+
private options;
|
|
8
|
+
private configDir;
|
|
9
|
+
constructor(config: BatchConfig, options: BatchExecutionOptions, configDir: string);
|
|
10
|
+
/**
|
|
11
|
+
* Estimate costs for the batch without executing
|
|
12
|
+
*/
|
|
13
|
+
estimateBatchCost(): BatchCostEstimate;
|
|
14
|
+
/**
|
|
15
|
+
* Estimate cost for a single job
|
|
16
|
+
*/
|
|
17
|
+
private estimateJobCost;
|
|
18
|
+
/**
|
|
19
|
+
* Execute all jobs in the batch
|
|
20
|
+
*/
|
|
21
|
+
executeBatch(): Promise<BatchResult>;
|
|
22
|
+
/**
|
|
23
|
+
* Execute a single job with retry logic
|
|
24
|
+
*/
|
|
25
|
+
private executeJobWithRetry;
|
|
26
|
+
/**
|
|
27
|
+
* Execute a single job
|
|
28
|
+
*/
|
|
29
|
+
private executeJob;
|
|
30
|
+
/**
|
|
31
|
+
* Check if an error is retryable based on patterns
|
|
32
|
+
*/
|
|
33
|
+
private isRetryableError;
|
|
34
|
+
/**
|
|
35
|
+
* Create timeout promise
|
|
36
|
+
*/
|
|
37
|
+
private timeoutPromise;
|
|
38
|
+
/**
|
|
39
|
+
* Sleep utility
|
|
40
|
+
*/
|
|
41
|
+
private sleep;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=batch-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch-manager.d.ts","sourceRoot":"","sources":["../../src/utils/batch-manager.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EACL,KAAK,WAAW,EAEhB,KAAK,qBAAqB,EAC1B,KAAK,WAAW,EAEhB,KAAK,iBAAiB,EAMvB,MAAM,mBAAmB,CAAC;AAwD3B,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,OAAO,CAAwB;IACvC,OAAO,CAAC,SAAS,CAAS;gBAEd,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM;IAMlF;;OAEG;IACH,iBAAiB,IAAI,iBAAiB;IAqBtC;;OAEG;IACH,OAAO,CAAC,eAAe;IA6CvB;;OAEG;IACG,YAAY,IAAI,OAAO,CAAC,WAAW,CAAC;IA6D1C;;OAEG;YACW,mBAAmB;IA2EjC;;OAEG;YACW,UAAU;IAyCxB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAexB;;OAEG;IACH,OAAO,CAAC,cAAc;IAQtB;;OAEG;IACH,OAAO,CAAC,KAAK;CAGd"}
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Batch Execution Manager
|
|
3
|
+
*/
|
|
4
|
+
import { DEFAULT_MODEL, DEFAULT_RESOLUTION, DEFAULT_DURATION, EXTENSION_DURATION, EXTENSION_RESOLUTION, calculateCost } from '../types/tools.js';
|
|
5
|
+
import { generateVideo } from '../tools/generate.js';
|
|
6
|
+
import { extendVideo } from '../tools/extend.js';
|
|
7
|
+
import { interpolateFrames } from '../tools/interpolate.js';
|
|
8
|
+
import { applyJobDefaults, resolveOutputPath } from './batch-config.js';
|
|
9
|
+
import { ensureDirectoryExists } from './path.js';
|
|
10
|
+
import { debugLog, errorLog, infoLog } from './debug.js';
|
|
11
|
+
// =============================================================================
|
|
12
|
+
// Semaphore for Concurrency Control
|
|
13
|
+
// =============================================================================
|
|
14
|
+
class Semaphore {
|
|
15
|
+
permits;
|
|
16
|
+
waiting = [];
|
|
17
|
+
constructor(permits) {
|
|
18
|
+
this.permits = permits;
|
|
19
|
+
}
|
|
20
|
+
async acquire() {
|
|
21
|
+
if (this.permits > 0) {
|
|
22
|
+
this.permits--;
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
return new Promise((resolve) => {
|
|
26
|
+
this.waiting.push(resolve);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
release() {
|
|
30
|
+
this.permits++;
|
|
31
|
+
const next = this.waiting.shift();
|
|
32
|
+
if (next) {
|
|
33
|
+
this.permits--;
|
|
34
|
+
next();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// =============================================================================
|
|
39
|
+
// Batch Manager
|
|
40
|
+
// =============================================================================
|
|
41
|
+
export class BatchManager {
|
|
42
|
+
config;
|
|
43
|
+
options;
|
|
44
|
+
configDir;
|
|
45
|
+
constructor(config, options, configDir) {
|
|
46
|
+
this.config = config;
|
|
47
|
+
this.options = options;
|
|
48
|
+
this.configDir = configDir;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Estimate costs for the batch without executing
|
|
52
|
+
*/
|
|
53
|
+
estimateBatchCost() {
|
|
54
|
+
const estimates = [];
|
|
55
|
+
let totalCost = 0;
|
|
56
|
+
let totalDuration = 0;
|
|
57
|
+
this.config.jobs.forEach((job, index) => {
|
|
58
|
+
const jobWithDefaults = applyJobDefaults(job, this.config);
|
|
59
|
+
const jobType = job.type || 'generate';
|
|
60
|
+
const estimate = this.estimateJobCost(jobWithDefaults, jobType, index);
|
|
61
|
+
estimates.push(estimate);
|
|
62
|
+
totalCost += estimate.estimated_cost;
|
|
63
|
+
totalDuration += estimate.duration_seconds;
|
|
64
|
+
});
|
|
65
|
+
return {
|
|
66
|
+
jobs: estimates,
|
|
67
|
+
total_estimated_cost: totalCost,
|
|
68
|
+
total_duration_seconds: totalDuration
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Estimate cost for a single job
|
|
73
|
+
*/
|
|
74
|
+
estimateJobCost(job, jobType, index) {
|
|
75
|
+
let model;
|
|
76
|
+
let resolution;
|
|
77
|
+
let durationSeconds;
|
|
78
|
+
let generateAudio;
|
|
79
|
+
switch (jobType) {
|
|
80
|
+
case 'extend': {
|
|
81
|
+
model = DEFAULT_MODEL;
|
|
82
|
+
resolution = EXTENSION_RESOLUTION;
|
|
83
|
+
durationSeconds = EXTENSION_DURATION;
|
|
84
|
+
generateAudio = false; // Extensions don't generate audio
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
case 'interpolate': {
|
|
88
|
+
const intJob = job;
|
|
89
|
+
model = DEFAULT_MODEL;
|
|
90
|
+
resolution = DEFAULT_RESOLUTION;
|
|
91
|
+
durationSeconds = intJob.duration_seconds || DEFAULT_DURATION;
|
|
92
|
+
generateAudio = intJob.generate_audio ?? !this.options.noAudio;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
default: {
|
|
96
|
+
const genJob = job;
|
|
97
|
+
model = genJob.model || DEFAULT_MODEL;
|
|
98
|
+
resolution = genJob.resolution || DEFAULT_RESOLUTION;
|
|
99
|
+
durationSeconds = genJob.duration_seconds || DEFAULT_DURATION;
|
|
100
|
+
generateAudio = genJob.generate_audio ?? !this.options.noAudio;
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const cost = calculateCost(model, resolution, durationSeconds, generateAudio);
|
|
105
|
+
return {
|
|
106
|
+
index,
|
|
107
|
+
job_type: jobType,
|
|
108
|
+
model,
|
|
109
|
+
resolution,
|
|
110
|
+
duration_seconds: durationSeconds,
|
|
111
|
+
generate_audio: generateAudio,
|
|
112
|
+
estimated_cost: cost
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Execute all jobs in the batch
|
|
117
|
+
*/
|
|
118
|
+
async executeBatch() {
|
|
119
|
+
const startedAt = new Date();
|
|
120
|
+
const results = [];
|
|
121
|
+
// Ensure output directory exists
|
|
122
|
+
ensureDirectoryExists(this.options.outputDir);
|
|
123
|
+
const semaphore = new Semaphore(this.options.maxConcurrent);
|
|
124
|
+
const totalJobs = this.config.jobs.length;
|
|
125
|
+
infoLog(`Starting batch execution: ${totalJobs} jobs, ${this.options.maxConcurrent} concurrent`);
|
|
126
|
+
// Execute jobs with concurrency control
|
|
127
|
+
const promises = this.config.jobs.map(async (job, index) => {
|
|
128
|
+
await semaphore.acquire();
|
|
129
|
+
try {
|
|
130
|
+
infoLog(`Starting job ${index + 1}/${totalJobs}`);
|
|
131
|
+
const result = await this.executeJobWithRetry(job, index);
|
|
132
|
+
results[index] = result;
|
|
133
|
+
if (result.success) {
|
|
134
|
+
infoLog(`Job ${index + 1} completed successfully`);
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
errorLog(`Job ${index + 1} failed: ${result.error}`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
finally {
|
|
141
|
+
semaphore.release();
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
// Wait for all jobs with timeout
|
|
145
|
+
await Promise.race([
|
|
146
|
+
Promise.all(promises),
|
|
147
|
+
this.timeoutPromise()
|
|
148
|
+
]);
|
|
149
|
+
const completedAt = new Date();
|
|
150
|
+
// Calculate summary
|
|
151
|
+
const successful = results.filter(r => r?.success).length;
|
|
152
|
+
const failed = results.filter(r => r && !r.success).length;
|
|
153
|
+
const cancelled = totalJobs - results.filter(r => r).length;
|
|
154
|
+
const totalCost = results
|
|
155
|
+
.filter(r => r?.estimated_cost)
|
|
156
|
+
.reduce((sum, r) => sum + (r.estimated_cost || 0), 0);
|
|
157
|
+
return {
|
|
158
|
+
total_jobs: totalJobs,
|
|
159
|
+
successful,
|
|
160
|
+
failed,
|
|
161
|
+
cancelled,
|
|
162
|
+
total_estimated_cost: totalCost,
|
|
163
|
+
jobs: results,
|
|
164
|
+
started_at: startedAt,
|
|
165
|
+
completed_at: completedAt,
|
|
166
|
+
duration_ms: completedAt.getTime() - startedAt.getTime()
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Execute a single job with retry logic
|
|
171
|
+
*/
|
|
172
|
+
async executeJobWithRetry(job, index) {
|
|
173
|
+
const jobWithDefaults = applyJobDefaults(job, this.config);
|
|
174
|
+
const jobType = job.type || 'generate';
|
|
175
|
+
const outputPath = resolveOutputPath(job, index, this.options.outputDir, this.configDir);
|
|
176
|
+
const startedAt = new Date();
|
|
177
|
+
let lastError;
|
|
178
|
+
let retries = 0;
|
|
179
|
+
const { max_retries, retry_delay_ms, retry_on_errors } = this.options.retryPolicy;
|
|
180
|
+
for (let attempt = 0; attempt <= max_retries; attempt++) {
|
|
181
|
+
try {
|
|
182
|
+
debugLog(`Job ${index + 1} attempt ${attempt + 1}`);
|
|
183
|
+
const result = await this.executeJob(jobWithDefaults, jobType, outputPath);
|
|
184
|
+
if (result.success) {
|
|
185
|
+
const completedAt = new Date();
|
|
186
|
+
return {
|
|
187
|
+
index,
|
|
188
|
+
job: jobWithDefaults,
|
|
189
|
+
success: true,
|
|
190
|
+
operation_name: result.operation_name,
|
|
191
|
+
video_url: result.video_url,
|
|
192
|
+
video_path: result.video_path,
|
|
193
|
+
estimated_cost: result.estimated_cost,
|
|
194
|
+
started_at: startedAt,
|
|
195
|
+
completed_at: completedAt,
|
|
196
|
+
duration_ms: completedAt.getTime() - startedAt.getTime(),
|
|
197
|
+
retries
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
lastError = result.error || result.failure_reason;
|
|
201
|
+
// Check if error is retryable
|
|
202
|
+
const shouldRetry = this.isRetryableError(lastError, retry_on_errors);
|
|
203
|
+
if (shouldRetry && attempt < max_retries) {
|
|
204
|
+
retries++;
|
|
205
|
+
debugLog(`Job ${index + 1} failed with retryable error, waiting ${retry_delay_ms}ms before retry`);
|
|
206
|
+
await this.sleep(retry_delay_ms);
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
catch (error) {
|
|
213
|
+
lastError = error instanceof Error ? error.message : String(error);
|
|
214
|
+
const shouldRetry = this.isRetryableError(lastError, retry_on_errors);
|
|
215
|
+
if (shouldRetry && attempt < max_retries) {
|
|
216
|
+
retries++;
|
|
217
|
+
debugLog(`Job ${index + 1} threw retryable error, waiting ${retry_delay_ms}ms before retry`);
|
|
218
|
+
await this.sleep(retry_delay_ms);
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
break;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
const completedAt = new Date();
|
|
226
|
+
return {
|
|
227
|
+
index,
|
|
228
|
+
job: jobWithDefaults,
|
|
229
|
+
success: false,
|
|
230
|
+
error: lastError,
|
|
231
|
+
started_at: startedAt,
|
|
232
|
+
completed_at: completedAt,
|
|
233
|
+
duration_ms: completedAt.getTime() - startedAt.getTime(),
|
|
234
|
+
retries
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Execute a single job
|
|
239
|
+
*/
|
|
240
|
+
async executeJob(job, jobType, outputPath) {
|
|
241
|
+
switch (jobType) {
|
|
242
|
+
case 'extend': {
|
|
243
|
+
const extJob = job;
|
|
244
|
+
return extendVideo({
|
|
245
|
+
video: extJob.video,
|
|
246
|
+
prompt: extJob.prompt,
|
|
247
|
+
output_path: outputPath
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
case 'interpolate': {
|
|
251
|
+
const intJob = job;
|
|
252
|
+
return interpolateFrames({
|
|
253
|
+
first_frame: intJob.first_frame,
|
|
254
|
+
last_frame: intJob.last_frame,
|
|
255
|
+
prompt: intJob.prompt,
|
|
256
|
+
duration_seconds: intJob.duration_seconds,
|
|
257
|
+
generate_audio: this.options.noAudio ? false : intJob.generate_audio,
|
|
258
|
+
output_path: outputPath
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
default: {
|
|
262
|
+
const genJob = job;
|
|
263
|
+
return generateVideo({
|
|
264
|
+
prompt: genJob.prompt,
|
|
265
|
+
model: genJob.model,
|
|
266
|
+
aspect_ratio: genJob.aspect_ratio,
|
|
267
|
+
resolution: genJob.resolution,
|
|
268
|
+
duration_seconds: genJob.duration_seconds,
|
|
269
|
+
generate_audio: this.options.noAudio ? false : genJob.generate_audio,
|
|
270
|
+
negative_prompt: genJob.negative_prompt,
|
|
271
|
+
image: genJob.image,
|
|
272
|
+
reference_images: genJob.reference_images,
|
|
273
|
+
output_path: outputPath
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Check if an error is retryable based on patterns
|
|
280
|
+
*/
|
|
281
|
+
isRetryableError(error, patterns) {
|
|
282
|
+
if (!error)
|
|
283
|
+
return false;
|
|
284
|
+
const errorLower = error.toLowerCase();
|
|
285
|
+
for (const pattern of patterns) {
|
|
286
|
+
const patternLower = pattern.toLowerCase();
|
|
287
|
+
if (errorLower.includes(patternLower)) {
|
|
288
|
+
return true;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return false;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Create timeout promise
|
|
295
|
+
*/
|
|
296
|
+
timeoutPromise() {
|
|
297
|
+
return new Promise((_, reject) => {
|
|
298
|
+
setTimeout(() => {
|
|
299
|
+
reject(new Error(`Batch execution timed out after ${this.options.timeout}ms`));
|
|
300
|
+
}, this.options.timeout);
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Sleep utility
|
|
305
|
+
*/
|
|
306
|
+
sleep(ms) {
|
|
307
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
//# sourceMappingURL=batch-manager.js.map
|
|
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,EAAE,QAAkB;QACpE,IAAI,CAAC,KAAK;YAAE,OAAO,KAAK,CAAC;QAEzB,MAAM,UAAU,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;QAEvC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC/B,MAAM,YAAY,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;YAC3C,IAAI,UAAU,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;gBACtC,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;OAEG;IACK,cAAc;QACpB,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE;YAC/B,UAAU,CAAC,GAAG,EAAE;gBACd,MAAM,CAAC,IAAI,KAAK,CAAC,mCAAmC,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC;YACjF,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,EAAU;QACtB,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IACzD,CAAC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Debug logging utilities
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Log a debug message (only if DEBUG=true)
|
|
6
|
+
*/
|
|
7
|
+
export declare function debugLog(message: string, data?: unknown): void;
|
|
8
|
+
/**
|
|
9
|
+
* Log an error message (always logs)
|
|
10
|
+
*/
|
|
11
|
+
export declare function errorLog(message: string, error?: unknown): void;
|
|
12
|
+
/**
|
|
13
|
+
* Log an info message (always logs)
|
|
14
|
+
*/
|
|
15
|
+
export declare function infoLog(message: string): void;
|
|
16
|
+
//# sourceMappingURL=debug.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../src/utils/debug.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAS9D;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI,CAY/D;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAG7C"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Debug logging utilities
|
|
3
|
+
*/
|
|
4
|
+
const DEBUG = process.env.DEBUG === 'true';
|
|
5
|
+
/**
|
|
6
|
+
* Log a debug message (only if DEBUG=true)
|
|
7
|
+
*/
|
|
8
|
+
export function debugLog(message, data) {
|
|
9
|
+
if (!DEBUG)
|
|
10
|
+
return;
|
|
11
|
+
const timestamp = new Date().toISOString();
|
|
12
|
+
if (data !== undefined) {
|
|
13
|
+
console.error(`[DEBUG ${timestamp}] ${message}`, JSON.stringify(data, null, 2));
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
console.error(`[DEBUG ${timestamp}] ${message}`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Log an error message (always logs)
|
|
21
|
+
*/
|
|
22
|
+
export function errorLog(message, error) {
|
|
23
|
+
const timestamp = new Date().toISOString();
|
|
24
|
+
if (error instanceof Error) {
|
|
25
|
+
console.error(`[ERROR ${timestamp}] ${message}: ${error.message}`);
|
|
26
|
+
if (DEBUG && error.stack) {
|
|
27
|
+
console.error(error.stack);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
else if (error !== undefined) {
|
|
31
|
+
console.error(`[ERROR ${timestamp}] ${message}:`, error);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
console.error(`[ERROR ${timestamp}] ${message}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Log an info message (always logs)
|
|
39
|
+
*/
|
|
40
|
+
export function infoLog(message) {
|
|
41
|
+
const timestamp = new Date().toISOString();
|
|
42
|
+
console.error(`[INFO ${timestamp}] ${message}`);
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=debug.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug.js","sourceRoot":"","sources":["../../src/utils/debug.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK,MAAM,CAAC;AAE3C;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAe,EAAE,IAAc;IACtD,IAAI,CAAC,KAAK;QAAE,OAAO;IAEnB,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC3C,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,CAAC,KAAK,CAAC,UAAU,SAAS,KAAK,OAAO,EAAE,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAClF,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,KAAK,CAAC,UAAU,SAAS,KAAK,OAAO,EAAE,CAAC,CAAC;IACnD,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAe,EAAE,KAAe;IACvD,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC3C,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,CAAC,KAAK,CAAC,UAAU,SAAS,KAAK,OAAO,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACnE,IAAI,KAAK,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;YACzB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;SAAM,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,CAAC,KAAK,CAAC,UAAU,SAAS,KAAK,OAAO,GAAG,EAAE,KAAK,CAAC,CAAC;IAC3D,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,KAAK,CAAC,UAAU,SAAS,KAAK,OAAO,EAAE,CAAC,CAAC;IACnD,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,OAAe;IACrC,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC3C,OAAO,CAAC,KAAK,CAAC,SAAS,SAAS,KAAK,OAAO,EAAE,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Path handling utilities
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Normalize and validate output path
|
|
6
|
+
* - Resolves relative paths
|
|
7
|
+
* - Creates parent directories if needed
|
|
8
|
+
* - Returns absolute path
|
|
9
|
+
*/
|
|
10
|
+
export declare function normalizeAndValidatePath(outputPath: string, baseDir?: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Generate a unique file path to avoid overwriting
|
|
13
|
+
* If file.mp4 exists, returns file_1.mp4, file_2.mp4, etc.
|
|
14
|
+
*/
|
|
15
|
+
export declare function generateUniqueFilePath(filePath: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* Get a display-friendly relative path
|
|
18
|
+
*/
|
|
19
|
+
export declare function getDisplayPath(absolutePath: string, baseDir?: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Generate a default output path with timestamp
|
|
22
|
+
*/
|
|
23
|
+
export declare function generateDefaultOutputPath(outputDir: string, prefix?: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Ensure file has .mp4 extension
|
|
26
|
+
*/
|
|
27
|
+
export declare function ensureVideoExtension(filePath: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* Check if path is within a base directory
|
|
30
|
+
*/
|
|
31
|
+
export declare function isPathWithinBase(targetPath: string, baseDir: string): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Ensure directory exists
|
|
34
|
+
*/
|
|
35
|
+
export declare function ensureDirectoryExists(dirPath: string): void;
|
|
36
|
+
//# sourceMappingURL=path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../src/utils/path.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAgBrF;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAkB/D;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAU7E;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,GAAE,MAAgB,GAAG,MAAM,CAI7F;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAU7D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAI7E;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAI3D"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Path handling utilities
|
|
3
|
+
*/
|
|
4
|
+
import * as fs from 'fs';
|
|
5
|
+
import * as path from 'path';
|
|
6
|
+
/**
|
|
7
|
+
* Normalize and validate output path
|
|
8
|
+
* - Resolves relative paths
|
|
9
|
+
* - Creates parent directories if needed
|
|
10
|
+
* - Returns absolute path
|
|
11
|
+
*/
|
|
12
|
+
export function normalizeAndValidatePath(outputPath, baseDir) {
|
|
13
|
+
// Resolve relative paths
|
|
14
|
+
let resolvedPath;
|
|
15
|
+
if (path.isAbsolute(outputPath)) {
|
|
16
|
+
resolvedPath = outputPath;
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
resolvedPath = path.resolve(baseDir || process.cwd(), outputPath);
|
|
20
|
+
}
|
|
21
|
+
// Ensure parent directory exists
|
|
22
|
+
const parentDir = path.dirname(resolvedPath);
|
|
23
|
+
if (!fs.existsSync(parentDir)) {
|
|
24
|
+
fs.mkdirSync(parentDir, { recursive: true });
|
|
25
|
+
}
|
|
26
|
+
return resolvedPath;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Generate a unique file path to avoid overwriting
|
|
30
|
+
* If file.mp4 exists, returns file_1.mp4, file_2.mp4, etc.
|
|
31
|
+
*/
|
|
32
|
+
export function generateUniqueFilePath(filePath) {
|
|
33
|
+
if (!fs.existsSync(filePath)) {
|
|
34
|
+
return filePath;
|
|
35
|
+
}
|
|
36
|
+
const dir = path.dirname(filePath);
|
|
37
|
+
const ext = path.extname(filePath);
|
|
38
|
+
const base = path.basename(filePath, ext);
|
|
39
|
+
let counter = 1;
|
|
40
|
+
let uniquePath = filePath;
|
|
41
|
+
while (fs.existsSync(uniquePath)) {
|
|
42
|
+
uniquePath = path.join(dir, `${base}_${counter}${ext}`);
|
|
43
|
+
counter++;
|
|
44
|
+
}
|
|
45
|
+
return uniquePath;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Get a display-friendly relative path
|
|
49
|
+
*/
|
|
50
|
+
export function getDisplayPath(absolutePath, baseDir) {
|
|
51
|
+
const base = baseDir || process.cwd();
|
|
52
|
+
const relativePath = path.relative(base, absolutePath);
|
|
53
|
+
// If the relative path goes up too many levels, use absolute
|
|
54
|
+
if (relativePath.startsWith('..\\..\\..') || relativePath.startsWith('../../..')) {
|
|
55
|
+
return absolutePath;
|
|
56
|
+
}
|
|
57
|
+
return relativePath.startsWith('.') ? relativePath : `./${relativePath}`;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Generate a default output path with timestamp
|
|
61
|
+
*/
|
|
62
|
+
export function generateDefaultOutputPath(outputDir, prefix = 'video') {
|
|
63
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19);
|
|
64
|
+
const filename = `${prefix}_${timestamp}.mp4`;
|
|
65
|
+
return path.join(outputDir, filename);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Ensure file has .mp4 extension
|
|
69
|
+
*/
|
|
70
|
+
export function ensureVideoExtension(filePath) {
|
|
71
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
72
|
+
if (ext === '.mp4') {
|
|
73
|
+
return filePath;
|
|
74
|
+
}
|
|
75
|
+
if (ext === '') {
|
|
76
|
+
return `${filePath}.mp4`;
|
|
77
|
+
}
|
|
78
|
+
// Replace other extensions with .mp4
|
|
79
|
+
return `${filePath.slice(0, -ext.length)}.mp4`;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Check if path is within a base directory
|
|
83
|
+
*/
|
|
84
|
+
export function isPathWithinBase(targetPath, baseDir) {
|
|
85
|
+
const resolvedTarget = path.resolve(targetPath);
|
|
86
|
+
const resolvedBase = path.resolve(baseDir);
|
|
87
|
+
return resolvedTarget.startsWith(resolvedBase);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Ensure directory exists
|
|
91
|
+
*/
|
|
92
|
+
export function ensureDirectoryExists(dirPath) {
|
|
93
|
+
if (!fs.existsSync(dirPath)) {
|
|
94
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
|
95
|
+
}
|
|
96
|
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,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAC;IACjD,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC;QACnB,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,IAAI,GAAG,KAAK,EAAE,EAAE,CAAC;QACf,OAAO,GAAG,QAAQ,MAAM,CAAC;IAC3B,CAAC;IACD,qCAAqC;IACrC,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC;AACjD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,UAAkB,EAAE,OAAe;IAClE,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAChD,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3C,OAAO,cAAc,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;AACjD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAAe;IACnD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5B,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7C,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Video polling and download utilities for Veo 3.1 API
|
|
3
|
+
*/
|
|
4
|
+
import { type VeoOperationResponse } from '../types/tools.js';
|
|
5
|
+
/**
|
|
6
|
+
* Get API key from environment
|
|
7
|
+
*/
|
|
8
|
+
export declare function getApiKey(): string;
|
|
9
|
+
/**
|
|
10
|
+
* Check operation status
|
|
11
|
+
*/
|
|
12
|
+
export declare function getOperationStatus(operationName: string, apiKey: string): Promise<VeoOperationResponse>;
|
|
13
|
+
/**
|
|
14
|
+
* Poll for video generation completion
|
|
15
|
+
*/
|
|
16
|
+
export declare function pollVideoResult(operationName: string, apiKey: string, pollInterval?: number, maxAttempts?: number): Promise<VeoOperationResponse>;
|
|
17
|
+
/**
|
|
18
|
+
* Download video from URL
|
|
19
|
+
*/
|
|
20
|
+
export declare function downloadVideo(url: string, apiKey?: string): Promise<Buffer>;
|
|
21
|
+
/**
|
|
22
|
+
* Save video buffer to file
|
|
23
|
+
*/
|
|
24
|
+
export declare function saveVideo(videoData: Buffer | string, outputPath: string): Promise<string>;
|
|
25
|
+
/**
|
|
26
|
+
* Download video and save to file
|
|
27
|
+
*/
|
|
28
|
+
export declare function downloadAndSaveVideo(url: string | undefined, base64Data: string | undefined, outputPath: string, apiKey?: string): Promise<string>;
|
|
29
|
+
/**
|
|
30
|
+
* Extract video from operation response
|
|
31
|
+
*/
|
|
32
|
+
export declare function extractVideoFromResponse(response: VeoOperationResponse): {
|
|
33
|
+
url?: string;
|
|
34
|
+
base64?: string;
|
|
35
|
+
} | null;
|
|
36
|
+
/**
|
|
37
|
+
* Read image file and convert to base64
|
|
38
|
+
*/
|
|
39
|
+
export declare function readImageAsBase64(imagePath: string): Promise<string>;
|
|
40
|
+
/**
|
|
41
|
+
* Read video file and convert to base64
|
|
42
|
+
*/
|
|
43
|
+
export declare function readVideoAsBase64(videoPath: string): Promise<string>;
|
|
44
|
+
//# sourceMappingURL=video.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"video.d.ts","sourceRoot":"","sources":["../../src/utils/video.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAIL,KAAK,oBAAoB,EAE1B,MAAM,mBAAmB,CAAC;AAI3B;;GAEG;AACH,wBAAgB,SAAS,IAAI,MAAM,CAMlC;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,oBAAoB,CAAC,CAkC/B;AAED;;GAEG;AACH,wBAAsB,eAAe,CACnC,aAA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