@nodaro/cli 1.18.2 → 1.20.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 CHANGED
@@ -142,7 +142,6 @@ nodaro voice export --source <url> --tracks-file mix.json --watch # rende
142
142
  nodaro voice design --description "..." --text "..." --watch
143
143
  nodaro voice remix --description "..." --text "..." --watch
144
144
  nodaro voice dub --audio <url> --target-language es --watch
145
- nodaro voice clones create --name Me --file ./sample.wav
146
145
 
147
146
  # Media — social-video import, trim, save, metadata probe
148
147
  nodaro media download <url> [--max-height 720] [--section 30-90] --watch
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import { stdout, stdin } from 'process';
5
5
  import pc3 from 'picocolors';
6
6
  import { writeFileSync, readFileSync, existsSync, mkdirSync, chmodSync } from 'fs';
7
7
  import { hostname, platform, homedir } from 'os';
8
- import { extname, basename, join } from 'path';
8
+ import { join } from 'path';
9
9
  import { createServer } from 'http';
10
10
  import { randomBytes } from 'crypto';
11
11
  import { spawn } from 'child_process';
@@ -13,7 +13,7 @@ import { createClient, StaticTokenAuth, UnauthorizedError, NodaroError, LOCATION
13
13
  import select from '@inquirer/select';
14
14
  import checkbox from '@inquirer/checkbox';
15
15
  import input from '@inquirer/input';
16
- import { CHARACTER_STYLES } from '@nodaro/shared';
16
+ import { CHARACTER_STYLES, OVERLAY_ANCHORS, OVERLAY_PLATFORM_IDS } from '@nodaro/shared';
17
17
 
18
18
  var __getOwnPropNames = Object.getOwnPropertyNames;
19
19
  var __commonJS = (cb, mod) => function __require() {
@@ -29,7 +29,7 @@ var require_package = __commonJS({
29
29
  "package.json"(exports$1, module) {
30
30
  module.exports = {
31
31
  name: "@nodaro/cli",
32
- version: "1.18.2",
32
+ version: "1.20.0",
33
33
  description: "Command-line interface for Nodaro \u2014 list and run workflows, inspect jobs and executions, manage projects from the terminal.",
34
34
  type: "module",
35
35
  license: "Apache-2.0",
@@ -70,11 +70,11 @@ var require_package = __commonJS({
70
70
  "@inquirer/confirm": "^6.0.12",
71
71
  "@inquirer/input": "^5.0.12",
72
72
  "@inquirer/select": "^5.1.4",
73
- "@nodaro/sdk": "^2.0.0",
74
- "@nodaro/shared": "^3.0.0",
73
+ "@nodaro/sdk": "^2.11.0",
74
+ "@nodaro/shared": "^3.10.0",
75
75
  commander: "^12.1.0",
76
76
  picocolors: "^1.1.1",
77
- "@nodaro/prompts": "^1.17.2"
77
+ "@nodaro/prompts": "^1.20.0"
78
78
  },
79
79
  devDependencies: {
80
80
  tsup: "^8.5.0",
@@ -398,7 +398,7 @@ function saveWorkspace(profileName, workspaceId) {
398
398
  }
399
399
 
400
400
  // src/client.ts
401
- var CLI_VERSION = "1.18.2" ;
401
+ var CLI_VERSION = "1.20.0" ;
402
402
  function buildClient(profileName) {
403
403
  const { name, profile } = getProfile(profileName);
404
404
  if (!profile) {
@@ -1802,15 +1802,6 @@ function promptCommand() {
1802
1802
  return cmd;
1803
1803
  }
1804
1804
  var FX_PRESETS = "room|bathroom|car|hall|concert-hall|church|cave|arena|outdoor|telephone|megaphone|echo|custom";
1805
- var AUDIO_CONTENT_TYPES = {
1806
- ".mp3": "audio/mpeg",
1807
- ".wav": "audio/wav",
1808
- ".m4a": "audio/mp4",
1809
- ".aac": "audio/aac",
1810
- ".ogg": "audio/ogg",
1811
- ".flac": "audio/flac",
1812
- ".webm": "audio/webm"
1813
- };
1814
1805
  function buildVoiceFx(opts) {
1815
1806
  if ((opts.voiceFxMix !== void 0 || opts.voiceFxDelay !== void 0 || opts.voiceFxDecay !== void 0) && !opts.voiceFx) {
1816
1807
  warn("--voice-fx-mix / --voice-fx-delay / --voice-fx-decay require --voice-fx <preset>");
@@ -2251,7 +2242,7 @@ Example:
2251
2242
  handleError(err);
2252
2243
  }
2253
2244
  });
2254
- const clones = new Command("clones").description("manage your voice clones (list / create / delete)");
2245
+ const clones = new Command("clones").description("manage the voice clones you already have (list / delete) \u2014 cloning new voices is no longer offered");
2255
2246
  clones.command("list").description("list your voice clones").option("--profile <name>").option("--json").action(async (opts) => {
2256
2247
  try {
2257
2248
  const client = buildClient(opts.profile);
@@ -2269,37 +2260,6 @@ Example:
2269
2260
  handleError(err);
2270
2261
  }
2271
2262
  });
2272
- clones.command("create").description("clone a voice from a sample \u2014 an already-uploaded URL (--audio) or a local file (--file). Costs credits.").requiredOption("--name <name>", "name for the new clone").option("--audio <url>", "URL of an uploaded audio sample to clone from").option("--file <path>", "local audio file to upload and clone from (mp3/wav/m4a/aac/ogg/flac/webm)").option("--profile <name>").option("--json").addHelpText("after", `
2273
- Examples:
2274
- $ nodaro voice clones create --name "Narrator" --audio https://.../sample.mp3
2275
- $ nodaro voice clones create --name "Narrator" --file ./sample.wav`).action(async (opts) => {
2276
- try {
2277
- if (!opts.audio && !opts.file) {
2278
- warn("Provide --audio <url> or --file <path> (one is required)");
2279
- process.exit(1);
2280
- }
2281
- if (opts.audio && opts.file) {
2282
- warn("--audio and --file are mutually exclusive \u2014 pass one");
2283
- process.exit(1);
2284
- }
2285
- const client = buildClient(opts.profile);
2286
- const clone = opts.file ? await client.voices.createCloneFromFile({
2287
- name: opts.name,
2288
- file: readFileSync(opts.file),
2289
- filename: basename(opts.file),
2290
- contentType: AUDIO_CONTENT_TYPES[extname(opts.file).toLowerCase()] ?? "audio/mpeg"
2291
- }) : await client.voices.createClone({ name: opts.name, audioUrl: opts.audio });
2292
- if (opts.json) {
2293
- emit(clone, opts);
2294
- return;
2295
- }
2296
- success(`created voice clone "${clone.name}"`);
2297
- info(`voice_id: ${clone.elevenlabsVoiceId}`);
2298
- dim(`use it: nodaro voice changer --voice ${clone.elevenlabsVoiceId} --audio <url>`);
2299
- } catch (err) {
2300
- handleError(err);
2301
- }
2302
- });
2303
2263
  clones.command("delete <id>").description("delete one of your voice clones (the clone row id, not the voice_id)").option("--profile <name>").option("--json").action(async (id, opts) => {
2304
2264
  try {
2305
2265
  const client = buildClient(opts.profile);
@@ -2323,9 +2283,26 @@ function parseSection(raw) {
2323
2283
  }
2324
2284
  return { sectionStartSec: start, sectionEndSec: end };
2325
2285
  }
2286
+ function parseCanvas(raw) {
2287
+ const m = raw.match(/^([0-9]{2,4})x([0-9]{2,4})$/i);
2288
+ if (!m) {
2289
+ warn(`--canvas must be "<width>x<height>" in px, e.g. 1920x1080 (got "${raw}")`);
2290
+ process.exit(1);
2291
+ }
2292
+ return { width: parseInt(m[1], 10), height: parseInt(m[2], 10) };
2293
+ }
2294
+ function parseSafeArea(raw) {
2295
+ const parts = raw.split(",").map((n) => parseFloat(n.trim()));
2296
+ if (parts.length !== 4 || parts.some((n) => !Number.isFinite(n) || n < 0 || n > 1)) {
2297
+ warn(`--safe-area must be "x,y,w,h" as fractions 0..1, e.g. 0.05,0.05,0.9,0.9 (got "${raw}")`);
2298
+ process.exit(1);
2299
+ }
2300
+ const [x, y, w, h] = parts;
2301
+ return { x, y, w, h };
2302
+ }
2326
2303
  function mediaCommand() {
2327
2304
  const cmd = new Command("media").description(
2328
- "media ingestion + compositing \u2014 pull a social video into storage, trim video/audio, still-to-video, slideshow, collage images, save a URL to storage, probe metadata"
2305
+ "media ingestion + compositing \u2014 pull a social video into storage, trim video/audio, still-to-video, slideshow, collage images, overlay layers on an image, save a URL to storage, probe metadata"
2329
2306
  );
2330
2307
  cmd.command("download <url>").description("download a social video (YouTube / TikTok / Instagram / X / Facebook) into your storage").option("--max-height <px>", "cap the resolution (e.g. 720); omit for best available", (v) => parseInt(v, 10)).option("--section <a-b>", 'fetch ONLY this time range in seconds (e.g. "30-90"); the cut lands on keyframes, so pad and trim after').option("--watch", "stream the download's live progress until it completes").option("--profile <name>").option("--json").addHelpText("after", `
2331
2308
  Examples:
@@ -2590,6 +2567,124 @@ after the number ("3 \xB7 Close-up"); pass "" to skip a label for one image.`).a
2590
2567
  }
2591
2568
  }
2592
2569
  );
2570
+ cmd.command("overlay <imageUrl> [layerUrls...]").description("place layers on a base image, pixel-exactly (local compositor, no AI) \u2014 positional URLs are image layers; --layers-file for text/QR/shape layers").option("--layers-file <path>", "JSON file with the full layers array (every kind and per-layer option; mutually exclusive with positional layer URLs)").option("--anchor <anchor>", `the point each positional layer attaches to: ${OVERLAY_ANCHORS.join(" | ")} (default center)`).option("--x <percent>", "offset from the anchor in % of the base width (negative on a right anchor moves inward)", parseFloat).option("--y <percent>", "offset from the anchor in % of the base height (negative on a bottom anchor moves inward)", parseFloat).option("--width <percent>", "layer width in % of the base width (default 25; height follows the layer's aspect)", parseFloat).option("--opacity <0-1>", "layer opacity (default 1)", parseFloat).option("--platform <id>", `also render the composite at a platform's size; repeat for more (${OVERLAY_PLATFORM_IDS.length} available, e.g. youtube-thumbnail)`, collectVariadic).option("--qr-text <text>", "fills every QR layer that reads its link from the workflow (qr.fromInput)").option("--mask-mode <mode>", "mask the job also emits (white = may change): none | layers | around (default \u2014 the ring an AI finish repaints) | outside").option("--mask-spread <px>", "ring width in px for --mask-mode around (default 48)", (v) => parseInt(v, 10)).option("--canvas <WxH>", "output canvas in px (the base is placed into it); omit to keep the base's pixel size").option("--base-fit <fit>", "how the base fills --canvas: contain or cover").option("--background-color <hex>", "canvas background behind the base, #RRGGBB (with --canvas)").option("--output-format <fmt>", "png (default, keeps transparency), jpg or webp").option("--watch", "poll until the job completes").option("--poll-interval <ms>", "watch poll interval in ms", (v) => parseInt(v, 10), 2e3).option("--profile <name>").option("--json").addHelpText("after", `
2571
+ Examples:
2572
+ $ nodaro media overlay https://x/base.png https://x/logo.svg --anchor bottom-right --x -4 --y -6 --width 12 --watch
2573
+ $ nodaro media overlay https://x/base.png https://x/logo.png --platform youtube-thumbnail --platform x-header --watch
2574
+ $ cat > layers.json <<'JSON'
2575
+ [{"kind":"text","text":{"content":"50% OFF","fontId":"anton","fontSize":9,"color":"#ffffff"},"anchor":"top-left","x":5,"y":5},
2576
+ {"kind":"qr","qr":{"text":"https://nodaro.ai"},"anchor":"bottom-right","x":-4,"y":-4,"width":14}]
2577
+ JSON
2578
+ $ nodaro media overlay https://x/base.png --layers-file layers.json --watch
2579
+
2580
+ Placement is in PERCENT of the base image, so the same call works on a 1K
2581
+ preview and a 4K render. --anchor/--x/--y/--width/--opacity apply to EVERY
2582
+ positional layer (the watermark case); per-layer control \u2014 and the text, QR and
2583
+ shape kinds \u2014 goes through --layers-file.
2584
+
2585
+ Not sure where a layer should sit? \`nodaro media overlay-placement\` asks a
2586
+ vision model and answers in these same units.`).action(
2587
+ async (imageUrl, layerUrls, opts) => {
2588
+ try {
2589
+ if (opts.layersFile && layerUrls.length > 0) {
2590
+ warn("Pass layers EITHER as positional URLs OR with --layers-file, not both");
2591
+ process.exit(1);
2592
+ }
2593
+ if (!opts.layersFile && layerUrls.length === 0) {
2594
+ warn("Give at least one layer: a positional image URL, or --layers-file with the layers array");
2595
+ process.exit(1);
2596
+ }
2597
+ if (opts.anchor && !OVERLAY_ANCHORS.includes(opts.anchor)) {
2598
+ warn(`--anchor must be one of ${OVERLAY_ANCHORS.join(", ")} (got "${opts.anchor}")`);
2599
+ process.exit(1);
2600
+ }
2601
+ if (opts.maskMode && !["none", "layers", "around", "outside"].includes(opts.maskMode)) {
2602
+ warn(`--mask-mode must be none, layers, around or outside (got "${opts.maskMode}")`);
2603
+ process.exit(1);
2604
+ }
2605
+ if (opts.baseFit && !["contain", "cover"].includes(opts.baseFit)) {
2606
+ warn(`--base-fit must be contain or cover (got "${opts.baseFit}")`);
2607
+ process.exit(1);
2608
+ }
2609
+ if (opts.outputFormat && !["png", "jpg", "webp"].includes(opts.outputFormat)) {
2610
+ warn(`--output-format must be png, jpg or webp (got "${opts.outputFormat}")`);
2611
+ process.exit(1);
2612
+ }
2613
+ const unknownPlatforms = (opts.platform ?? []).filter(
2614
+ (p) => !OVERLAY_PLATFORM_IDS.includes(p)
2615
+ );
2616
+ if (unknownPlatforms.length > 0) {
2617
+ warn(`Unknown --platform: ${unknownPlatforms.join(", ")}. Available: ${OVERLAY_PLATFORM_IDS.join(", ")}`);
2618
+ process.exit(1);
2619
+ }
2620
+ let layers;
2621
+ if (opts.layersFile) {
2622
+ const parsed = JSON.parse(readFileSync(opts.layersFile, "utf8"));
2623
+ if (!Array.isArray(parsed) || parsed.length === 0) {
2624
+ warn(`--layers-file must contain a non-empty JSON array of layers (${opts.layersFile})`);
2625
+ process.exit(1);
2626
+ }
2627
+ layers = parsed;
2628
+ } else {
2629
+ const placement = {
2630
+ ...opts.anchor ? { anchor: opts.anchor } : {},
2631
+ ...opts.x !== void 0 ? { x: opts.x } : {},
2632
+ ...opts.y !== void 0 ? { y: opts.y } : {},
2633
+ ...opts.width !== void 0 ? { width: opts.width } : {},
2634
+ ...opts.opacity !== void 0 ? { opacity: opts.opacity } : {}
2635
+ };
2636
+ layers = layerUrls.map((url) => ({ imageUrl: url, ...placement }));
2637
+ }
2638
+ const canvas = opts.canvas ? parseCanvas(opts.canvas) : void 0;
2639
+ const client = buildClient(opts.profile);
2640
+ const result = await client.media.imageOverlay({
2641
+ imageUrl,
2642
+ layers,
2643
+ ...canvas ? { canvas: { ...canvas, ...opts.backgroundColor ? { backgroundColor: opts.backgroundColor } : {} } } : {},
2644
+ ...opts.baseFit ? { baseFit: opts.baseFit } : {},
2645
+ ...opts.outputFormat ? { outputFormat: opts.outputFormat } : {},
2646
+ ...opts.platform?.length ? { variants: opts.platform } : {},
2647
+ ...opts.qrText ? { qrText: opts.qrText } : {},
2648
+ ...opts.maskMode ? { maskMode: opts.maskMode } : {},
2649
+ ...opts.maskSpread !== void 0 ? { maskSpread: opts.maskSpread } : {}
2650
+ });
2651
+ await reportQueuedJob(result, () => client.jobs.get(result.jobId), { ...opts, note: "image overlay" });
2652
+ } catch (err) {
2653
+ handleError(err);
2654
+ }
2655
+ }
2656
+ );
2657
+ cmd.command("overlay-placement <imageUrl>").description("ask a vision model WHERE one overlay layer should sit \u2014 answers in `media overlay`'s own percent units").option("--intent <text>", 'what the layer is, in words \u2014 "a logo", "a price badge" (default a logo)').option("--aspect <ratio>", "the layer's width / height (1 = square, the default)", parseFloat).option("--safe-area <x,y,w,h>", "always-visible region as fractions 0..1; the placement is kept inside it").option("--profile <name>").option("--json").addHelpText("after", `
2658
+ Example:
2659
+ $ nodaro media overlay-placement https://x/base.png --intent "a logo" --aspect 2.5
2660
+
2661
+ Answers synchronously (no job to poll) with anchor, x, y and width \u2014 feed them
2662
+ straight to \`nodaro media overlay --anchor \u2026 --x \u2026 --y \u2026 --width \u2026\`. Billed as
2663
+ one image-to-text call.`).action(
2664
+ async (imageUrl, opts) => {
2665
+ try {
2666
+ const safeArea = opts.safeArea ? parseSafeArea(opts.safeArea) : void 0;
2667
+ const client = buildClient(opts.profile);
2668
+ const { placement } = await client.media.suggestOverlayPlacement({
2669
+ imageUrl,
2670
+ ...opts.intent ? { intent: opts.intent } : {},
2671
+ ...opts.aspect !== void 0 ? { layerAspect: opts.aspect } : {},
2672
+ ...safeArea ? { safeArea } : {}
2673
+ });
2674
+ if (opts.json) {
2675
+ emit(placement, opts);
2676
+ return;
2677
+ }
2678
+ success(`anchor ${placement.anchor}, x ${placement.x}%, y ${placement.y}%, width ${placement.width}%`);
2679
+ dim(placement.reason);
2680
+ info(
2681
+ `apply: nodaro media overlay ${imageUrl} <layerUrl> --anchor ${placement.anchor} --x ${placement.x} --y ${placement.y} --width ${placement.width} --watch`
2682
+ );
2683
+ } catch (err) {
2684
+ handleError(err);
2685
+ }
2686
+ }
2687
+ );
2593
2688
  cmd.command("save <url>").description("copy an external media URL into your Nodaro storage (server-side fetch)").option("--filename <name>", "filename to store it under").option("--type <type>", "media type hint: image, video, or audio").option("--watch", "poll until the job completes").option("--poll-interval <ms>", "watch poll interval in ms", (v) => parseInt(v, 10), 2e3).option("--profile <name>").option("--json").action(
2594
2689
  async (url, opts) => {
2595
2690
  try {