depicta 0.9.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.
Files changed (62) hide show
  1. package/bin/depicta.js +6 -0
  2. package/dist/client.d.ts +59 -0
  3. package/dist/client.d.ts.map +1 -0
  4. package/dist/client.js +163 -0
  5. package/dist/client.js.map +1 -0
  6. package/dist/commands/auth.d.ts +13 -0
  7. package/dist/commands/auth.d.ts.map +1 -0
  8. package/dist/commands/auth.js +188 -0
  9. package/dist/commands/auth.js.map +1 -0
  10. package/dist/commands/docs.d.ts +10 -0
  11. package/dist/commands/docs.d.ts.map +1 -0
  12. package/dist/commands/docs.js +165 -0
  13. package/dist/commands/docs.js.map +1 -0
  14. package/dist/commands/generate.d.ts +17 -0
  15. package/dist/commands/generate.d.ts.map +1 -0
  16. package/dist/commands/generate.js +254 -0
  17. package/dist/commands/generate.js.map +1 -0
  18. package/dist/commands/guidelines.d.ts +9 -0
  19. package/dist/commands/guidelines.d.ts.map +1 -0
  20. package/dist/commands/guidelines.js +58 -0
  21. package/dist/commands/guidelines.js.map +1 -0
  22. package/dist/commands/jobs.d.ts +9 -0
  23. package/dist/commands/jobs.d.ts.map +1 -0
  24. package/dist/commands/jobs.js +89 -0
  25. package/dist/commands/jobs.js.map +1 -0
  26. package/dist/commands/process.d.ts +16 -0
  27. package/dist/commands/process.d.ts.map +1 -0
  28. package/dist/commands/process.js +412 -0
  29. package/dist/commands/process.js.map +1 -0
  30. package/dist/commands/story.d.ts +18 -0
  31. package/dist/commands/story.d.ts.map +1 -0
  32. package/dist/commands/story.js +182 -0
  33. package/dist/commands/story.js.map +1 -0
  34. package/dist/commands/utility.d.ts +11 -0
  35. package/dist/commands/utility.d.ts.map +1 -0
  36. package/dist/commands/utility.js +118 -0
  37. package/dist/commands/utility.js.map +1 -0
  38. package/dist/config.d.ts +50 -0
  39. package/dist/config.d.ts.map +1 -0
  40. package/dist/config.js +103 -0
  41. package/dist/config.js.map +1 -0
  42. package/dist/download.d.ts +38 -0
  43. package/dist/download.d.ts.map +1 -0
  44. package/dist/download.js +98 -0
  45. package/dist/download.js.map +1 -0
  46. package/dist/errors.d.ts +41 -0
  47. package/dist/errors.d.ts.map +1 -0
  48. package/dist/errors.js +62 -0
  49. package/dist/errors.js.map +1 -0
  50. package/dist/flags.d.ts +41 -0
  51. package/dist/flags.d.ts.map +1 -0
  52. package/dist/flags.js +40 -0
  53. package/dist/flags.js.map +1 -0
  54. package/dist/index.d.ts +9 -0
  55. package/dist/index.d.ts.map +1 -0
  56. package/dist/index.js +80 -0
  57. package/dist/index.js.map +1 -0
  58. package/dist/output.d.ts +44 -0
  59. package/dist/output.d.ts.map +1 -0
  60. package/dist/output.js +125 -0
  61. package/dist/output.js.map +1 -0
  62. package/package.json +44 -0
@@ -0,0 +1,412 @@
1
+ /**
2
+ * Processing commands (19 total), all grouped under 'process'.
3
+ *
4
+ * All commands follow the same pattern:
5
+ * 1. Resolve input (file path or stdin via "-")
6
+ * 2. Upload file to /v1/upload
7
+ * 3. POST to processing endpoint with params
8
+ * 4. Download result from resp.image_url
9
+ * 5. Save and print via printProcessing
10
+ *
11
+ * overlay is the exception: it uploads two files before POSTing.
12
+ */
13
+ import { Command } from 'commander';
14
+ import { DepictaClient } from '../client.js';
15
+ import { resolveApiKey, resolveApiUrl } from '../config.js';
16
+ import { resolveInput, saveBytes } from '../download.js';
17
+ import { DepictaError, EXIT_AUTH } from '../errors.js';
18
+ import { addGlobalFlags, addOutputPathFlags } from '../flags.js';
19
+ import { detectMode, printProcessing, warnApiKeyFlag } from '../output.js';
20
+ /** Build an authenticated client from global opts. */
21
+ function makeClient(opts) {
22
+ const key = resolveApiKey(opts.apiKey);
23
+ if (!key) {
24
+ throw new DepictaError('No API key configured.', 'authentication_error', EXIT_AUTH);
25
+ }
26
+ const mode = detectMode({ forceJson: opts.json, forceHuman: opts.human });
27
+ if (opts.apiKey) {
28
+ warnApiKeyFlag(mode, opts.quiet ?? false);
29
+ }
30
+ return new DepictaClient(key, resolveApiUrl(opts.apiUrl));
31
+ }
32
+ /** Shared processing flow: upload → POST → download → save → print. */
33
+ async function runProcessing(client, endpoint, inputPath, body, opts, command) {
34
+ const mode = detectMode({ forceJson: opts.json, forceHuman: opts.human });
35
+ const uploadResp = await client.uploadFile('/v1/upload', inputPath);
36
+ body['input_image_url'] = uploadResp.image_url;
37
+ const result = await client.postJson(endpoint, body);
38
+ const resp = result[0];
39
+ const imageUrl = typeof resp['image_url'] === 'string' ? resp['image_url'] : '';
40
+ const imageData = await client.downloadBytes(imageUrl);
41
+ const filePath = saveBytes(imageData, command, 'png', opts.output, opts.outputDir);
42
+ printProcessing(filePath, mode, opts.quiet ?? false);
43
+ }
44
+ /** Register the 'process' command group with all 19 subcommands. */
45
+ export function registerProcessCommands(program) {
46
+ const proc = new Command('process')
47
+ .description('Image processing commands')
48
+ .addHelpCommand(false);
49
+ // --- crop ---
50
+ const cropCmd = new Command('crop')
51
+ .description('Crop image by coordinates')
52
+ .argument('<input>', 'Input image (or - for stdin)');
53
+ addGlobalFlags(cropCmd);
54
+ addOutputPathFlags(cropCmd);
55
+ cropCmd
56
+ .option('--x <n>', 'X coordinate of crop origin', '0')
57
+ .option('--y <n>', 'Y coordinate of crop origin', '0')
58
+ .option('--width <n>', 'Crop width in pixels', '100')
59
+ .option('--height <n>', 'Crop height in pixels', '100');
60
+ cropCmd.action(async (input, opts) => {
61
+ const client = makeClient(opts);
62
+ const resolved = resolveInput(input);
63
+ await runProcessing(client, '/v1/process/crop', resolved, {
64
+ x: parseInt(opts.x, 10),
65
+ y: parseInt(opts.y, 10),
66
+ width: parseInt(opts.width, 10),
67
+ height: parseInt(opts.height, 10),
68
+ }, opts, 'crop');
69
+ });
70
+ proc.addCommand(cropCmd);
71
+ // --- resize ---
72
+ const resizeCmd = new Command('resize')
73
+ .description('Resize image')
74
+ .argument('<input>', 'Input image (or - for stdin)');
75
+ addGlobalFlags(resizeCmd);
76
+ addOutputPathFlags(resizeCmd);
77
+ resizeCmd
78
+ .option('--width <n>', 'Target width in pixels')
79
+ .option('--height <n>', 'Target height in pixels');
80
+ resizeCmd.action(async (input, opts) => {
81
+ if (!opts.width && !opts.height) {
82
+ process.stderr.write('Error: resize requires at least one of --width or --height\n');
83
+ process.exit(1);
84
+ }
85
+ const client = makeClient(opts);
86
+ const resolved = resolveInput(input);
87
+ const body = {};
88
+ if (opts.width)
89
+ body['width'] = parseInt(opts.width, 10);
90
+ if (opts.height)
91
+ body['height'] = parseInt(opts.height, 10);
92
+ await runProcessing(client, '/v1/process/resize', resolved, body, opts, 'resize');
93
+ });
94
+ proc.addCommand(resizeCmd);
95
+ // --- convert ---
96
+ const convertCmd = new Command('convert')
97
+ .description('Convert image format')
98
+ .argument('<input>', 'Input image (or - for stdin)');
99
+ addGlobalFlags(convertCmd);
100
+ addOutputPathFlags(convertCmd);
101
+ convertCmd.option('-f, --format <fmt>', 'Target format: png, jpg, webp', 'png');
102
+ convertCmd.action(async (input, opts) => {
103
+ const client = makeClient(opts);
104
+ const resolved = resolveInput(input);
105
+ await runProcessing(client, '/v1/process/convert', resolved, { format: opts.format }, opts, 'convert');
106
+ });
107
+ proc.addCommand(convertCmd);
108
+ // --- optimize ---
109
+ const optimizeCmd = new Command('optimize')
110
+ .description('Optimize image compression')
111
+ .argument('<input>', 'Input image (or - for stdin)');
112
+ addGlobalFlags(optimizeCmd);
113
+ addOutputPathFlags(optimizeCmd);
114
+ optimizeCmd
115
+ .option('--colors <n>', 'Max colors 2-256 (optional, omit for auto PSNR-guided optimization)')
116
+ .option('--min-psnr <n>', 'Min PSNR quality floor (optional, default: 38.0)');
117
+ optimizeCmd.action(async (input, opts) => {
118
+ const client = makeClient(opts);
119
+ const resolved = resolveInput(input);
120
+ const body = {};
121
+ if (opts.colors)
122
+ body['colors'] = parseInt(opts.colors, 10);
123
+ if (opts.minPsnr)
124
+ body['min_psnr'] = parseFloat(opts.minPsnr);
125
+ await runProcessing(client, '/v1/process/optimize', resolved, body, opts, 'optimize');
126
+ });
127
+ proc.addCommand(optimizeCmd);
128
+ // --- remove-bg ---
129
+ const removeBgCmd = new Command('remove-bg')
130
+ .description('Remove image background')
131
+ .argument('<input>', 'Input image (or - for stdin)');
132
+ addGlobalFlags(removeBgCmd);
133
+ addOutputPathFlags(removeBgCmd);
134
+ removeBgCmd.action(async (input, opts) => {
135
+ const client = makeClient(opts);
136
+ const resolved = resolveInput(input);
137
+ await runProcessing(client, '/v1/process/remove-background', resolved, {}, opts, 'remove-bg');
138
+ });
139
+ proc.addCommand(removeBgCmd);
140
+ // --- blur ---
141
+ const blurCmd = new Command('blur')
142
+ .description('Apply Gaussian blur')
143
+ .argument('<input>', 'Input image (or - for stdin)');
144
+ addGlobalFlags(blurCmd);
145
+ addOutputPathFlags(blurCmd);
146
+ blurCmd.requiredOption('--radius <n>', 'Blur radius in pixels (required, e.g. 5.0)', parseFloat);
147
+ blurCmd.action(async (input, opts) => {
148
+ const client = makeClient(opts);
149
+ const resolved = resolveInput(input);
150
+ await runProcessing(client, '/v1/process/blur', resolved, { radius: opts.radius }, opts, 'blur');
151
+ });
152
+ proc.addCommand(blurCmd);
153
+ // --- sharpen ---
154
+ const sharpenCmd = new Command('sharpen')
155
+ .description('Sharpen image')
156
+ .argument('<input>', 'Input image (or - for stdin)');
157
+ addGlobalFlags(sharpenCmd);
158
+ addOutputPathFlags(sharpenCmd);
159
+ sharpenCmd
160
+ .option('--amount <n>', 'Sharpening amount (optional, API default: 1.5)')
161
+ .option('--threshold <n>', 'Sharpening threshold (optional, API default: 3)');
162
+ sharpenCmd.action(async (input, opts) => {
163
+ const client = makeClient(opts);
164
+ const resolved = resolveInput(input);
165
+ const body = {};
166
+ if (opts.amount)
167
+ body['amount'] = parseFloat(opts.amount);
168
+ if (opts.threshold)
169
+ body['threshold'] = parseFloat(opts.threshold);
170
+ await runProcessing(client, '/v1/process/sharpen', resolved, body, opts, 'sharpen');
171
+ });
172
+ proc.addCommand(sharpenCmd);
173
+ // --- denoise ---
174
+ const denoiseCmd = new Command('denoise')
175
+ .description('Reduce chroma noise')
176
+ .argument('<input>', 'Input image (or - for stdin)');
177
+ addGlobalFlags(denoiseCmd);
178
+ addOutputPathFlags(denoiseCmd);
179
+ denoiseCmd
180
+ .option('--strength <n>', 'Denoising intensity 1-40 (optional, default: 10)');
181
+ denoiseCmd.action(async (input, opts) => {
182
+ const client = makeClient(opts);
183
+ const resolved = resolveInput(input);
184
+ const body = {};
185
+ if (opts.strength)
186
+ body['strength'] = parseInt(opts.strength, 10);
187
+ await runProcessing(client, '/v1/process/denoise', resolved, body, opts, 'denoise');
188
+ });
189
+ proc.addCommand(denoiseCmd);
190
+ // --- adjust ---
191
+ const adjustCmd = new Command('adjust')
192
+ .description('Adjust brightness, contrast, saturation')
193
+ .argument('<input>', 'Input image (or - for stdin)');
194
+ addGlobalFlags(adjustCmd);
195
+ addOutputPathFlags(adjustCmd);
196
+ adjustCmd
197
+ .option('--brightness <n>', 'Brightness adjustment')
198
+ .option('--contrast <n>', 'Contrast adjustment')
199
+ .option('--saturation <n>', 'Saturation adjustment');
200
+ adjustCmd.action(async (input, opts) => {
201
+ const client = makeClient(opts);
202
+ const resolved = resolveInput(input);
203
+ const body = {};
204
+ if (opts.brightness)
205
+ body['brightness'] = parseFloat(opts.brightness);
206
+ if (opts.contrast)
207
+ body['contrast'] = parseFloat(opts.contrast);
208
+ if (opts.saturation)
209
+ body['saturation'] = parseFloat(opts.saturation);
210
+ await runProcessing(client, '/v1/process/adjust', resolved, body, opts, 'adjust');
211
+ });
212
+ proc.addCommand(adjustCmd);
213
+ // --- grayscale ---
214
+ const grayscaleCmd = new Command('grayscale')
215
+ .description('Convert to grayscale')
216
+ .argument('<input>', 'Input image (or - for stdin)');
217
+ addGlobalFlags(grayscaleCmd);
218
+ addOutputPathFlags(grayscaleCmd);
219
+ grayscaleCmd.action(async (input, opts) => {
220
+ const client = makeClient(opts);
221
+ const resolved = resolveInput(input);
222
+ await runProcessing(client, '/v1/process/grayscale', resolved, {}, opts, 'grayscale');
223
+ });
224
+ proc.addCommand(grayscaleCmd);
225
+ // --- invert ---
226
+ const invertCmd = new Command('invert')
227
+ .description('Invert image colors')
228
+ .argument('<input>', 'Input image (or - for stdin)');
229
+ addGlobalFlags(invertCmd);
230
+ addOutputPathFlags(invertCmd);
231
+ invertCmd.action(async (input, opts) => {
232
+ const client = makeClient(opts);
233
+ const resolved = resolveInput(input);
234
+ await runProcessing(client, '/v1/process/invert', resolved, {}, opts, 'invert');
235
+ });
236
+ proc.addCommand(invertCmd);
237
+ // --- flip ---
238
+ const flipCmd = new Command('flip')
239
+ .description('Flip image horizontally or vertically')
240
+ .argument('<input>', 'Input image (or - for stdin)');
241
+ addGlobalFlags(flipCmd);
242
+ addOutputPathFlags(flipCmd);
243
+ flipCmd.requiredOption('--direction <dir>', 'Flip direction: horizontal or vertical (required)');
244
+ flipCmd.action(async (input, opts) => {
245
+ const client = makeClient(opts);
246
+ const resolved = resolveInput(input);
247
+ await runProcessing(client, '/v1/process/flip', resolved, { direction: opts.direction }, opts, 'flip');
248
+ });
249
+ proc.addCommand(flipCmd);
250
+ // --- auto-orient ---
251
+ const autoOrientCmd = new Command('auto-orient')
252
+ .description('Auto-orient based on EXIF data')
253
+ .argument('<input>', 'Input image (or - for stdin)');
254
+ addGlobalFlags(autoOrientCmd);
255
+ addOutputPathFlags(autoOrientCmd);
256
+ autoOrientCmd.action(async (input, opts) => {
257
+ const client = makeClient(opts);
258
+ const resolved = resolveInput(input);
259
+ await runProcessing(client, '/v1/process/auto-orient', resolved, {}, opts, 'auto-orient');
260
+ });
261
+ proc.addCommand(autoOrientCmd);
262
+ // --- alpha-to-color ---
263
+ const alphaToColorCmd = new Command('alpha-to-color')
264
+ .description('Replace transparency with a solid color')
265
+ .argument('<input>', 'Input image (or - for stdin)');
266
+ addGlobalFlags(alphaToColorCmd);
267
+ addOutputPathFlags(alphaToColorCmd);
268
+ alphaToColorCmd.option('--color <hex>', 'Background color, #RRGGBB (optional, default: #FFFFFF)');
269
+ alphaToColorCmd.action(async (input, opts) => {
270
+ const client = makeClient(opts);
271
+ const resolved = resolveInput(input);
272
+ const body = {};
273
+ if (opts.color)
274
+ body['color'] = opts.color;
275
+ await runProcessing(client, '/v1/process/alpha-to-color', resolved, body, opts, 'alpha-to-color');
276
+ });
277
+ proc.addCommand(alphaToColorCmd);
278
+ // --- color-to-alpha ---
279
+ const colorToAlphaCmd = new Command('color-to-alpha')
280
+ .description('Make a color transparent')
281
+ .argument('<input>', 'Input image (or - for stdin)');
282
+ addGlobalFlags(colorToAlphaCmd);
283
+ addOutputPathFlags(colorToAlphaCmd);
284
+ colorToAlphaCmd
285
+ .option('--color <hex>', 'Color to make transparent (#RRGGBB hex)', '#FFFFFF')
286
+ .option('--tolerance <n>', 'Color matching tolerance');
287
+ colorToAlphaCmd.action(async (input, opts) => {
288
+ const client = makeClient(opts);
289
+ const resolved = resolveInput(input);
290
+ const body = { color: opts.color };
291
+ if (opts.tolerance)
292
+ body['tolerance'] = parseFloat(opts.tolerance);
293
+ await runProcessing(client, '/v1/process/color-to-alpha', resolved, body, opts, 'color-to-alpha');
294
+ });
295
+ proc.addCommand(colorToAlphaCmd);
296
+ // --- rotate ---
297
+ const rotateCmd = new Command('rotate')
298
+ .description('Rotate image by angle')
299
+ .argument('<input>', 'Input image (or - for stdin)');
300
+ addGlobalFlags(rotateCmd);
301
+ addOutputPathFlags(rotateCmd);
302
+ rotateCmd
303
+ .requiredOption('--angle <degrees>', 'Rotation angle in degrees, -360 to 360 (required)', parseFloat)
304
+ .option('--expand', 'Expand canvas to fit rotated image (optional, default: true)')
305
+ .option('--fill-color <hex>', 'Fill color for exposed areas, #RRGGBB (optional, default: #FFFFFF)');
306
+ rotateCmd.action(async (input, opts) => {
307
+ const client = makeClient(opts);
308
+ const resolved = resolveInput(input);
309
+ const body = { angle: opts.angle };
310
+ if (opts.expand !== undefined)
311
+ body['expand'] = opts.expand;
312
+ if (opts.fillColor)
313
+ body['fill_color'] = opts.fillColor;
314
+ await runProcessing(client, '/v1/process/rotate', resolved, body, opts, 'rotate');
315
+ });
316
+ proc.addCommand(rotateCmd);
317
+ // --- trim ---
318
+ const trimCmd = new Command('trim')
319
+ .description('Auto-trim borders')
320
+ .argument('<input>', 'Input image (or - for stdin)');
321
+ addGlobalFlags(trimCmd);
322
+ addOutputPathFlags(trimCmd);
323
+ trimCmd.option('--tolerance <n>', 'Border detection tolerance');
324
+ trimCmd.action(async (input, opts) => {
325
+ const client = makeClient(opts);
326
+ const resolved = resolveInput(input);
327
+ const body = {};
328
+ if (opts.tolerance)
329
+ body['tolerance'] = parseFloat(opts.tolerance);
330
+ await runProcessing(client, '/v1/process/trim', resolved, body, opts, 'trim');
331
+ });
332
+ proc.addCommand(trimCmd);
333
+ // --- pad ---
334
+ const padCmd = new Command('pad')
335
+ .description('Add padding around image')
336
+ .argument('<input>', 'Input image (or - for stdin)');
337
+ addGlobalFlags(padCmd);
338
+ addOutputPathFlags(padCmd);
339
+ padCmd
340
+ .requiredOption('--width <n>', 'Target width in pixels (required)', parseInt)
341
+ .requiredOption('--height <n>', 'Target height in pixels (required)', parseInt)
342
+ .option('--color <hex>', 'Padding color, #RRGGBB (optional, default: #FFFFFF)')
343
+ .option('--gravity <pos>', 'Image position within padded canvas');
344
+ padCmd.action(async (input, opts) => {
345
+ const client = makeClient(opts);
346
+ const resolved = resolveInput(input);
347
+ const body = {
348
+ width: opts.width,
349
+ height: opts.height,
350
+ };
351
+ if (opts.color)
352
+ body['color'] = opts.color;
353
+ if (opts.gravity)
354
+ body['gravity'] = opts.gravity;
355
+ await runProcessing(client, '/v1/process/pad', resolved, body, opts, 'pad');
356
+ });
357
+ proc.addCommand(padCmd);
358
+ // --- metadata-strip ---
359
+ const metadataStripCmd = new Command('metadata-strip')
360
+ .description('Strip image metadata')
361
+ .argument('<input>', 'Input image (or - for stdin)');
362
+ addGlobalFlags(metadataStripCmd);
363
+ addOutputPathFlags(metadataStripCmd);
364
+ metadataStripCmd.option('--keep-icc', 'Keep ICC color profile');
365
+ metadataStripCmd.action(async (input, opts) => {
366
+ const client = makeClient(opts);
367
+ const resolved = resolveInput(input);
368
+ const body = {};
369
+ if (opts.keepIcc !== undefined)
370
+ body['keep_icc'] = opts.keepIcc;
371
+ await runProcessing(client, '/v1/process/metadata-strip', resolved, body, opts, 'metadata-strip');
372
+ });
373
+ proc.addCommand(metadataStripCmd);
374
+ // --- overlay ---
375
+ // Special case: uploads two files (input + overlay) before POSTing.
376
+ const overlayCmd = new Command('overlay')
377
+ .description('Overlay an image on top of another')
378
+ .argument('<input>', 'Input image (or - for stdin)');
379
+ addGlobalFlags(overlayCmd);
380
+ addOutputPathFlags(overlayCmd);
381
+ overlayCmd
382
+ .option('--overlay <path>', 'Overlay image path', '')
383
+ .option('--x <n>', 'X position of overlay', '0')
384
+ .option('--y <n>', 'Y position of overlay', '0')
385
+ .option('--opacity <n>', 'Overlay opacity (0.0-1.0)');
386
+ overlayCmd.action(async (input, opts) => {
387
+ const mode = detectMode({ forceJson: opts.json, forceHuman: opts.human });
388
+ const client = makeClient(opts);
389
+ const resolved = resolveInput(input);
390
+ // Upload both images.
391
+ const inputResp = await client.uploadFile('/v1/upload', resolved);
392
+ const overlayResp = await client.uploadFile('/v1/upload', opts.overlay);
393
+ const body = {
394
+ input_image_url: inputResp.image_url,
395
+ overlay_image_url: overlayResp.image_url,
396
+ x: parseInt(opts.x, 10),
397
+ y: parseInt(opts.y, 10),
398
+ };
399
+ if (opts.opacity)
400
+ body['opacity'] = parseFloat(opts.opacity);
401
+ // Cannot use runProcessing helper (already uploaded both images).
402
+ const result = await client.postJson('/v1/process/overlay', body);
403
+ const resp = result[0];
404
+ const imageUrl = typeof resp['image_url'] === 'string' ? resp['image_url'] : '';
405
+ const imageData = await client.downloadBytes(imageUrl);
406
+ const filePath = saveBytes(imageData, 'overlay', 'png', opts.output, opts.outputDir);
407
+ printProcessing(filePath, mode, opts.quiet ?? false);
408
+ });
409
+ proc.addCommand(overlayCmd);
410
+ program.addCommand(proc);
411
+ }
412
+ //# sourceMappingURL=process.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process.js","sourceRoot":"","sources":["../../src/commands/process.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAA8B,MAAM,aAAa,CAAC;AAC7F,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE3E,sDAAsD;AACtD,SAAS,UAAU,CAAC,IAAgB;IAClC,MAAM,GAAG,GAAG,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvC,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,YAAY,CAAC,wBAAwB,EAAE,sBAAsB,EAAE,SAAS,CAAC,CAAC;IACtF,CAAC;IACD,MAAM,IAAI,GAAG,UAAU,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;IAC1E,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QAChB,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,IAAI,aAAa,CAAC,GAAG,EAAE,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;AAC5D,CAAC;AAED,uEAAuE;AACvE,KAAK,UAAU,aAAa,CAC1B,MAAqB,EACrB,QA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AM,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,qBAAqB,EAAE,IAAI,CAAC,CAAC;QAClE,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QACvB,MAAM,QAAQ,GAAG,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAChF,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QACvD,MAAM,QAAQ,GAAG,SAAS,CAAC,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QACrF,eAAe,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;IACH,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IAE5B,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Story commands: story run, story status.
3
+ *
4
+ * story run:
5
+ * 1. POST /v1/generate/story with storyboard JSON → 202 with job_id
6
+ * 2. Poll GET /v1/generate/story/{job_id} every 3 seconds
7
+ * 3. Download scene images as they complete
8
+ * 4. On Ctrl+C: print job_id to stderr for resume
9
+ * 5. On timeout: print job_id to stderr, exit 1
10
+ * 6. On completion: print story_result JSON (--json) or output dir path
11
+ *
12
+ * story status:
13
+ * GET /v1/generate/story/{job_id} and print raw status response.
14
+ */
15
+ import { Command } from 'commander';
16
+ /** Register story subcommands on the parent program. */
17
+ export declare function registerStoryCommands(program: Command): void;
18
+ //# sourceMappingURL=story.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"story.d.ts","sourceRoot":"","sources":["../../src/commands/story.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAuHpC,wDAAwD;AACxD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA2E5D"}
@@ -0,0 +1,182 @@
1
+ /**
2
+ * Story commands: story run, story status.
3
+ *
4
+ * story run:
5
+ * 1. POST /v1/generate/story with storyboard JSON → 202 with job_id
6
+ * 2. Poll GET /v1/generate/story/{job_id} every 3 seconds
7
+ * 3. Download scene images as they complete
8
+ * 4. On Ctrl+C: print job_id to stderr for resume
9
+ * 5. On timeout: print job_id to stderr, exit 1
10
+ * 6. On completion: print story_result JSON (--json) or output dir path
11
+ *
12
+ * story status:
13
+ * GET /v1/generate/story/{job_id} and print raw status response.
14
+ */
15
+ import { Command } from 'commander';
16
+ import fs from 'fs';
17
+ import path from 'path';
18
+ import { DepictaClient } from '../client.js';
19
+ import { resolveApiKey, resolveApiUrl } from '../config.js';
20
+ import { DepictaError, EXIT_AUTH, EXIT_GENERAL } from '../errors.js';
21
+ import { addGlobalFlags } from '../flags.js';
22
+ import { detectMode, warnApiKeyFlag } from '../output.js';
23
+ const POLL_INTERVAL_MS = 3000;
24
+ /** Build authenticated client. */
25
+ function makeClient(opts) {
26
+ const key = resolveApiKey(opts.apiKey);
27
+ if (!key) {
28
+ throw new DepictaError('No API key configured.', 'authentication_error', EXIT_AUTH);
29
+ }
30
+ const mode = detectMode({ forceJson: opts.json, forceHuman: opts.human });
31
+ if (opts.apiKey)
32
+ warnApiKeyFlag(mode, opts.quiet ?? false);
33
+ return new DepictaClient(key, resolveApiUrl(opts.apiUrl));
34
+ }
35
+ /** Sleep for ms milliseconds. */
36
+ function sleep(ms) {
37
+ return new Promise((resolve) => setTimeout(resolve, ms));
38
+ }
39
+ /** Poll the story job until completion, downloading scenes as they appear. */
40
+ async function pollStory(client, jobId, outputDir, opts) {
41
+ const mode = detectMode({ forceJson: opts.json, forceHuman: opts.human });
42
+ const quiet = opts.quiet ?? false;
43
+ const timeoutMs = (parseInt(opts.timeout ?? '600', 10)) * 1000;
44
+ const startTime = Date.now();
45
+ const downloaded = new Set();
46
+ // Ctrl+C handler — print job_id for resume, then exit.
47
+ let interrupted = false;
48
+ const sigintHandler = () => {
49
+ interrupted = true;
50
+ };
51
+ process.on('SIGINT', sigintHandler);
52
+ try {
53
+ while (true) {
54
+ if (interrupted) {
55
+ process.stderr.write(`\nInterrupted. Resume with: depicta story status ${jobId}\n`);
56
+ process.exit(1);
57
+ }
58
+ if (Date.now() - startTime > timeoutMs) {
59
+ process.stderr.write(`\nTimeout. Resume with: depicta story status ${jobId}\n`);
60
+ process.exit(1);
61
+ }
62
+ const status = await client.get(`/v1/generate/story/${jobId}`);
63
+ // Download newly completed scenes.
64
+ const result = status['result'];
65
+ const scenes = (result?.['scenes'] ?? []);
66
+ for (let i = 0; i < scenes.length; i++) {
67
+ const scene = scenes[i];
68
+ if (!downloaded.has(i) && scene?.image_url) {
69
+ const imgData = await client.downloadBytes(scene.image_url);
70
+ const scenePath = path.join(outputDir, `scene-${String(i + 1).padStart(2, '0')}.png`);
71
+ fs.writeFileSync(scenePath, imgData);
72
+ downloaded.add(i);
73
+ if (mode === 'human' && !quiet) {
74
+ const total = status['scenes_total'] ?? '?';
75
+ process.stderr.write(` Scene ${i + 1}/${total} downloaded\n`);
76
+ }
77
+ }
78
+ }
79
+ if (status['status'] === 'completed') {
80
+ if (!result) {
81
+ throw new DepictaError('Story completed but result is missing', 'general_error', EXIT_GENERAL);
82
+ }
83
+ const finalScenes = [];
84
+ const resultScenes = (result['scenes'] ?? []);
85
+ for (let i = 0; i < resultScenes.length; i++) {
86
+ const scenePath = path.resolve(outputDir, `scene-${String(i + 1).padStart(2, '0')}.png`);
87
+ finalScenes.push({
88
+ file: scenePath,
89
+ cost_eur: resultScenes[i]?.cost_eur ?? '0',
90
+ });
91
+ }
92
+ return {
93
+ job_id: jobId,
94
+ title: result['title'] ?? '',
95
+ scenes: finalScenes,
96
+ total_cost_eur: result['total_cost_eur'] ?? '0',
97
+ balance_eur: result['balance_eur'] ?? '0',
98
+ };
99
+ }
100
+ if (status['status'] === 'failed') {
101
+ throw new DepictaError('Story generation failed', 'general_error', EXIT_GENERAL);
102
+ }
103
+ await sleep(POLL_INTERVAL_MS);
104
+ }
105
+ }
106
+ finally {
107
+ process.removeListener('SIGINT', sigintHandler);
108
+ }
109
+ }
110
+ /** Register story subcommands on the parent program. */
111
+ export function registerStoryCommands(program) {
112
+ const story = new Command('story')
113
+ .description('Story generation')
114
+ .addHelpCommand(false);
115
+ // --- story run ---
116
+ const runCmd = new Command('run')
117
+ .description('Generate multi-scene story from storyboard JSON')
118
+ .argument('<storyboard>', 'Path to storyboard JSON file');
119
+ addGlobalFlags(runCmd);
120
+ runCmd
121
+ .option('-d, --output-dir <dir>', 'Directory for scene images')
122
+ .option('-f, --format <fmt>', 'Output format: png, jpg, webp', 'png')
123
+ .option('--quality <n>', 'JPEG/WebP quality 0-100', '85')
124
+ .option('--timeout <n>', 'Max wait time in seconds', '600');
125
+ runCmd.action(async (storyboard, opts) => {
126
+ const mode = detectMode({ forceJson: opts.json, forceHuman: opts.human });
127
+ const quiet = opts.quiet ?? false;
128
+ const client = makeClient(opts);
129
+ const board = JSON.parse(fs.readFileSync(storyboard, 'utf8'));
130
+ const result = await client.postJson('/v1/generate/story', board);
131
+ const resp = result[0];
132
+ const jobId = typeof resp['job_id'] === 'string' ? resp['job_id'] : '';
133
+ if (mode === 'human' && !quiet) {
134
+ process.stderr.write(`Story submitted (job ${jobId}). Polling...\n`);
135
+ }
136
+ const timestamp = Math.floor(Date.now() / 1000);
137
+ const outDir = opts.outputDir ?? `./depicta-story-${timestamp}`;
138
+ fs.mkdirSync(outDir, { recursive: true });
139
+ const storyResult = await pollStory(client, jobId, outDir, opts);
140
+ if (mode === 'json') {
141
+ process.stdout.write(JSON.stringify(storyResult) + '\n');
142
+ }
143
+ else if (mode === 'human') {
144
+ if (!quiet) {
145
+ const scenes = storyResult['scenes'];
146
+ process.stderr.write(`\u2713 Story complete: ${scenes.length} scenes\n`);
147
+ process.stderr.write(` Total cost: EUR ${storyResult['total_cost_eur']}\n`);
148
+ }
149
+ process.stdout.write(path.resolve(outDir) + '\n');
150
+ }
151
+ else {
152
+ process.stdout.write(path.resolve(outDir) + '\n');
153
+ }
154
+ });
155
+ // --- story status ---
156
+ const statusCmd = new Command('status')
157
+ .description('Poll status of an async story job')
158
+ .argument('<job_id>', 'Story job ID');
159
+ addGlobalFlags(statusCmd);
160
+ statusCmd.action(async (jobId, opts) => {
161
+ const mode = detectMode({ forceJson: opts.json, forceHuman: opts.human });
162
+ const client = makeClient(opts);
163
+ const status = await client.get(`/v1/generate/story/${jobId}`);
164
+ if (mode === 'json') {
165
+ process.stdout.write(JSON.stringify(status) + '\n');
166
+ }
167
+ else if (mode === 'human' && !(opts.quiet ?? false)) {
168
+ process.stderr.write(`Job: ${status['job_id'] ?? jobId}\n`);
169
+ process.stderr.write(`Status: ${status['status']}\n`);
170
+ const completed = status['scenes_completed'] ?? 0;
171
+ const total = status['scenes_total'] ?? '?';
172
+ process.stderr.write(`Progress: ${completed}/${total}\n`);
173
+ }
174
+ else {
175
+ process.stdout.write(JSON.stringify(status) + '\n');
176
+ }
177
+ });
178
+ story.addCommand(runCmd);
179
+ story.addCommand(statusCmd);
180
+ program.addCommand(story);
181
+ }
182
+ //# sourceMappingURL=story.js.map