@nodaro/cli 1.20.0 → 1.21.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
@@ -23,28 +23,37 @@ Requires Node.js ≥ 20.
23
23
 
24
24
  ### Option B — standalone binary (no Node required, ~10ms cold start)
25
25
 
26
- Download a pre-built binary from the [Releases page](https://github.com/nodaroai/app.nodaro.ai/releases?q=cli-v):
26
+ CLI releases are tagged `cli-vX.Y.Z`. This repository's **"latest" release is the app's**, not the CLI's, so a `releases/latest/download/…` link never reaches a CLI binary. Resolve the newest `cli-v*` tag first, then download from it:
27
27
 
28
28
  ```bash
29
- # macOS (Apple Silicon)
30
- curl -L https://github.com/nodaroai/app.nodaro.ai/releases/latest/download/nodaro-darwin-arm64 \
31
- -o /usr/local/bin/nodaro && chmod +x /usr/local/bin/nodaro
29
+ # 1. The newest CLI version (e.g. 1.20.0)
30
+ NODARO_CLI_VERSION=$(curl -fsSL "https://api.github.com/repos/nodaroai/app.nodaro.ai/git/matching-refs/tags/cli-v?per_page=100" \
31
+ | grep -o '"refs/tags/cli-v[0-9][0-9.]*"' | tr -d '"' | sed 's#refs/tags/cli-v##' \
32
+ | sort -t. -k1,1n -k2,2n -k3,3n | tail -n 1)
33
+ echo "Installing @nodaro/cli $NODARO_CLI_VERSION"
32
34
 
33
- # macOS (Intel)
34
- curl -L https://github.com/nodaroai/app.nodaro.ai/releases/latest/download/nodaro-darwin-x64 \
35
- -o /usr/local/bin/nodaro && chmod +x /usr/local/bin/nodaro
35
+ # 2. Your platform: darwin-arm64 (Apple Silicon) · darwin-x64 (Intel Mac) · linux-x64 · linux-arm64
36
+ NODARO_CLI_PLATFORM=darwin-arm64
36
37
 
37
- # Linux (x86_64)
38
- curl -L https://github.com/nodaroai/app.nodaro.ai/releases/latest/download/nodaro-linux-x64 \
38
+ # 3. Download. -f fails on an HTTP error instead of saving the error page as the binary.
39
+ curl -fL "https://github.com/nodaroai/app.nodaro.ai/releases/download/cli-v$NODARO_CLI_VERSION/nodaro-$NODARO_CLI_PLATFORM" \
39
40
  -o /usr/local/bin/nodaro && chmod +x /usr/local/bin/nodaro
41
+ nodaro --version
42
+ ```
40
43
 
41
- # Linux (ARM64)
42
- curl -L https://github.com/nodaroai/app.nodaro.ai/releases/latest/download/nodaro-linux-arm64 \
43
- -o /usr/local/bin/nodaro && chmod +x /usr/local/bin/nodaro
44
+ Windows (PowerShell):
44
45
 
45
- # Windows (x86_64) — download nodaro-windows-x64.exe and rename to nodaro.exe
46
+ ```powershell
47
+ $v = (Invoke-RestMethod "https://api.github.com/repos/nodaroai/app.nodaro.ai/git/matching-refs/tags/cli-v?per_page=100") |
48
+ ForEach-Object { $_.ref -replace '^refs/tags/cli-v', '' } |
49
+ Where-Object { $_ -match '^\d+\.\d+\.\d+$' } |
50
+ Sort-Object { [version]$_ } | Select-Object -Last 1
51
+ Invoke-WebRequest "https://github.com/nodaroai/app.nodaro.ai/releases/download/cli-v$v/nodaro-windows-x64.exe" -OutFile nodaro.exe
52
+ .\nodaro.exe --version
46
53
  ```
47
54
 
55
+ To pin a version, skip step 1 and set `NODARO_CLI_VERSION` yourself. Every CLI release and its binaries: [releases tagged `cli-v`](https://github.com/nodaroai/app.nodaro.ai/releases?q=cli-v).
56
+
48
57
  Binaries are ~60 MB single-file executables compiled with [`bun build --compile`](https://bun.com/docs/bundler/executables) — no dependencies, no Node runtime needed. Cold-start is ~15× faster than the npm version.
49
58
 
50
59
  ## Authentication
package/dist/index.js CHANGED
@@ -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, OVERLAY_ANCHORS, OVERLAY_PLATFORM_IDS } from '@nodaro/shared';
16
+ import { CHARACTER_STYLES, TRANSCRIBE_PROVIDERS, transcribeLaneSupportsWordTimestamps, ALL_CAPTION_STYLES, DEFAULT_CAPTION_LOOK, CAPTION_LOOK_IDS, CAPTION_MAX_WORDS_PER_LINE_MIN, CAPTION_MAX_WORDS_PER_LINE_MAX, TRANSCRIBE_LANES, SUPPORTED_FONT_NAMES, OVERLAY_ANCHORS, OVERLAY_PLATFORM_IDS, DEFAULT_TRANSCRIBE_PROVIDER } 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.20.0",
32
+ version: "1.21.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.11.0",
74
- "@nodaro/shared": "^3.10.0",
73
+ "@nodaro/sdk": "^2.13.0",
74
+ "@nodaro/shared": "^3.12.0",
75
75
  commander: "^12.1.0",
76
76
  picocolors: "^1.1.1",
77
- "@nodaro/prompts": "^1.20.0"
77
+ "@nodaro/prompts": "^1.22.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.20.0" ;
401
+ var CLI_VERSION = "1.21.0" ;
402
402
  function buildClient(profileName) {
403
403
  const { name, profile } = getProfile(profileName);
404
404
  if (!profile) {
@@ -2283,6 +2283,16 @@ function parseSection(raw) {
2283
2283
  }
2284
2284
  return { sectionStartSec: start, sectionEndSec: end };
2285
2285
  }
2286
+ function parseMaxWordsPerLine(raw) {
2287
+ const n = Number(raw);
2288
+ if (!Number.isInteger(n) || n < CAPTION_MAX_WORDS_PER_LINE_MIN || n > CAPTION_MAX_WORDS_PER_LINE_MAX) {
2289
+ warn(
2290
+ `--max-words-per-line must be a whole number ${CAPTION_MAX_WORDS_PER_LINE_MIN}-${CAPTION_MAX_WORDS_PER_LINE_MAX} (got "${raw}")`
2291
+ );
2292
+ process.exit(1);
2293
+ }
2294
+ return n;
2295
+ }
2286
2296
  function parseCanvas(raw) {
2287
2297
  const m = raw.match(/^([0-9]{2,4})x([0-9]{2,4})$/i);
2288
2298
  if (!m) {
@@ -2291,6 +2301,20 @@ function parseCanvas(raw) {
2291
2301
  }
2292
2302
  return { width: parseInt(m[1], 10), height: parseInt(m[2], 10) };
2293
2303
  }
2304
+ function readJsonArrayFile(path, flag) {
2305
+ let parsed;
2306
+ try {
2307
+ parsed = JSON.parse(readFileSync(path, "utf8"));
2308
+ } catch (err) {
2309
+ warn(`${flag} ${path} could not be read as JSON: ${err.message}`);
2310
+ process.exit(1);
2311
+ }
2312
+ if (!Array.isArray(parsed) || parsed.length === 0) {
2313
+ warn(`${flag} must contain a non-empty JSON array (${path})`);
2314
+ process.exit(1);
2315
+ }
2316
+ return parsed;
2317
+ }
2294
2318
  function parseSafeArea(raw) {
2295
2319
  const parts = raw.split(",").map((n) => parseFloat(n.trim()));
2296
2320
  if (parts.length !== 4 || parts.some((n) => !Number.isFinite(n) || n < 0 || n > 1)) {
@@ -2302,7 +2326,7 @@ function parseSafeArea(raw) {
2302
2326
  }
2303
2327
  function mediaCommand() {
2304
2328
  const cmd = new Command("media").description(
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
+ "media ingestion + compositing \u2014 pull a social video into storage, trim video/audio, burn captions, still-to-video, slideshow, collage images, overlay layers on an image, save a URL to storage, probe metadata"
2306
2330
  );
2307
2331
  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", `
2308
2332
  Examples:
@@ -2486,6 +2510,113 @@ Example:
2486
2510
  }
2487
2511
  }
2488
2512
  );
2513
+ cmd.command("add-captions <videoUrl>").description(
2514
+ "burn captions into a video \u2014 static subtitles, or a kinetic word-highlight / karaoke / tiktok-words / word-pop / bouncy render"
2515
+ ).option("--text <text>", "the caption text \u2014 spaced evenly across the video when no word timings are given").option(
2516
+ "--captions-file <path>",
2517
+ "JSON array of word-timed entries [{ text, startMs, endMs }] \u2014 one per WORD for the kinetic styles; a transcribe job's output_data.words drops in verbatim"
2518
+ ).option("--style <style>", `caption style: ${ALL_CAPTION_STYLES.join(" | ")} (default subtitle)`).option(
2519
+ "--look <look>",
2520
+ `kinetic look preset: ${CAPTION_LOOK_IDS.join(" | ")} \u2014 an unset look renders as ${DEFAULT_CAPTION_LOOK}; the levers below override its individual fields`
2521
+ ).option("--position <pos>", "bottom (default) | top | center").option("--position-y <pct>", "the caption block's CENTRE as % of height (0-100) \u2014 overrides --position", parseFloat).option("--font-size <px>", "font size in px (12-200)", parseFloat).option("--font-family <name>", "font face \u2014 see the list below").option("--font-weight <n>", "CSS font weight, 100-900 in 100s", (v) => parseInt(v, 10)).option("--color <color>", "caption text colour").option("--background-color <color>", "caption background colour").option("--stroke-color <color>", "outline colour").option("--stroke-width <px>", "outline width in px, 0-40", parseFloat).option("--highlight-color <color>", "colour of the word being spoken (kinetic styles only)").option("--uppercase", "force UPPERCASE captions").option("--no-uppercase", "keep mixed case (the default outline look is UPPERCASE)").option(
2522
+ "--max-words-per-line <n>",
2523
+ `cap the words on one caption line (or tiktok-words page), ${CAPTION_MAX_WORDS_PER_LINE_MIN}-${CAPTION_MAX_WORDS_PER_LINE_MAX} \u2014 unset fits the frame width`
2524
+ ).option("--animate", "animate per-word motion on the kinetic styles (the default)").option(
2525
+ "--no-animate",
2526
+ "freeze per-word motion on the kinetic styles \u2014 keeps grouping, line-holding and the spoken-word highlight (kinetic styles only)"
2527
+ ).option("--no-auto-transcribe", "do NOT transcribe the video's audio when no --text / --captions-file is given").option("--transcribe-provider <name>", `engine for the auto-transcription: ${TRANSCRIBE_LANES.join(" | ")}`).option(
2528
+ "--segments-file <path>",
2529
+ "JSON array of caption SEGMENTS \u2014 non-overlapping { startMs, endMs } ranges, each with its own style/look/position overrides and optional own words"
2530
+ ).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", `
2531
+ Fonts: ${SUPPORTED_FONT_NAMES.join(", ")}
2532
+
2533
+ The styling levers (--look, --font-family, --font-weight, --stroke-*, --uppercase,
2534
+ --position-y, --max-words-per-line) now apply to the static subtitle style too \u2014 a
2535
+ subtitle carrying any of them renders via Remotion. Only --highlight-color and
2536
+ --animate are kinetic-only; the subtitle style rejects them with a 400.
2537
+
2538
+ --animate is on by default; --no-animate freezes the per-word motion on the kinetic
2539
+ styles (the grouping, line-holding and spoken-word highlight stay).
2540
+
2541
+ --max-words-per-line caps a line (or a tiktok-words page) ON TOP of the width budget,
2542
+ sentence ends and pauses that already close one \u2014 1-2 gives the punchy CapCut read.
2543
+ It is inert on word-pop, which is always one word, and a --segments-file entry that
2544
+ names its own overrides it for that range.
2545
+
2546
+ Examples:
2547
+ $ nodaro media add-captions https://.../clip.mp4 --style word-highlight --look outline --watch
2548
+ $ nodaro media add-captions https://.../clip.mp4 --captions-file words.json --style karaoke \\
2549
+ --no-auto-transcribe --highlight-color '#FFE600' --watch`).action(
2550
+ async (videoUrl, opts) => {
2551
+ try {
2552
+ if (opts.style && !ALL_CAPTION_STYLES.includes(opts.style)) {
2553
+ warn(`--style must be one of ${ALL_CAPTION_STYLES.join(", ")} (got "${opts.style}")`);
2554
+ process.exit(1);
2555
+ }
2556
+ if (opts.look && !CAPTION_LOOK_IDS.includes(opts.look)) {
2557
+ warn(`--look must be one of ${CAPTION_LOOK_IDS.join(", ")} (got "${opts.look}")`);
2558
+ process.exit(1);
2559
+ }
2560
+ if (opts.position && !["bottom", "top", "center"].includes(opts.position)) {
2561
+ warn(`--position must be bottom, top, or center (got "${opts.position}")`);
2562
+ process.exit(1);
2563
+ }
2564
+ if (opts.fontFamily && !SUPPORTED_FONT_NAMES.includes(opts.fontFamily)) {
2565
+ warn(`--font-family must be one of ${SUPPORTED_FONT_NAMES.join(", ")} (got "${opts.fontFamily}")`);
2566
+ process.exit(1);
2567
+ }
2568
+ if (opts.fontWeight !== void 0 && (!Number.isInteger(opts.fontWeight) || opts.fontWeight < 100 || opts.fontWeight > 900 || opts.fontWeight % 100 !== 0)) {
2569
+ warn(`--font-weight must be 100-900 in steps of 100 (got "${opts.fontWeight}")`);
2570
+ process.exit(1);
2571
+ }
2572
+ if (opts.transcribeProvider && !TRANSCRIBE_LANES.includes(opts.transcribeProvider)) {
2573
+ warn(`--transcribe-provider must be one of ${TRANSCRIBE_LANES.join(", ")} (got "${opts.transcribeProvider}")`);
2574
+ process.exit(1);
2575
+ }
2576
+ const maxWordsPerLine = opts.maxWordsPerLine !== void 0 ? parseMaxWordsPerLine(opts.maxWordsPerLine) : void 0;
2577
+ const captions = opts.captionsFile ? readJsonArrayFile(opts.captionsFile, "--captions-file") : void 0;
2578
+ const segments = opts.segmentsFile ? readJsonArrayFile(opts.segmentsFile, "--segments-file") : void 0;
2579
+ const client = buildClient(opts.profile);
2580
+ const result = await client.media.addCaptions({
2581
+ videoUrl,
2582
+ ...opts.text !== void 0 ? { text: opts.text } : {},
2583
+ ...captions ? { captions } : {},
2584
+ ...segments ? { segments } : {},
2585
+ ...opts.style ? { style: opts.style } : {},
2586
+ ...opts.look ? { look: opts.look } : {},
2587
+ ...opts.position ? { position: opts.position } : {},
2588
+ ...opts.positionY !== void 0 ? { positionY: opts.positionY } : {},
2589
+ ...opts.fontSize !== void 0 ? { fontSize: opts.fontSize } : {},
2590
+ ...opts.fontFamily ? { fontFamily: opts.fontFamily } : {},
2591
+ ...opts.fontWeight !== void 0 ? { fontWeight: opts.fontWeight } : {},
2592
+ ...opts.color ? { color: opts.color } : {},
2593
+ ...opts.backgroundColor ? { backgroundColor: opts.backgroundColor } : {},
2594
+ ...opts.strokeColor ? { strokeColor: opts.strokeColor } : {},
2595
+ ...opts.strokeWidth !== void 0 ? { strokeWidth: opts.strokeWidth } : {},
2596
+ ...opts.highlightColor ? { highlightColor: opts.highlightColor } : {},
2597
+ ...maxWordsPerLine !== void 0 ? { maxWordsPerLine } : {},
2598
+ // Tri-state: commander leaves it undefined unless --uppercase / --no-uppercase
2599
+ // was passed, so an untouched flag keeps the look's own casing.
2600
+ ...opts.uppercase !== void 0 ? { uppercase: opts.uppercase } : {},
2601
+ // Same tri-state as --uppercase: undefined unless --animate / --no-animate
2602
+ // was passed, so an untouched flag keeps the server default (animate: true).
2603
+ ...opts.animate !== void 0 ? { animate: opts.animate } : {},
2604
+ // Commander defaults a lone `--no-x` flag to TRUE, so only an
2605
+ // explicit `--no-auto-transcribe` may reach the wire — otherwise
2606
+ // every call would pin auto_transcribe and the route could never
2607
+ // see an absent flag.
2608
+ ...opts.autoTranscribe === false ? { autoTranscribe: false } : {},
2609
+ ...opts.transcribeProvider ? { transcribeProvider: opts.transcribeProvider } : {}
2610
+ });
2611
+ await reportQueuedJob(result, () => client.jobs.get(result.jobId), {
2612
+ ...opts,
2613
+ note: opts.style ?? "subtitle"
2614
+ });
2615
+ } catch (err) {
2616
+ handleError(err);
2617
+ }
2618
+ }
2619
+ );
2489
2620
  cmd.command("collage <imageUrls...>").description("composite 2\u201330 images into ONE large 2K/4K collage (smart justified layout \u2014 no cropping \u2014 or uniform grid)").option(
2490
2621
  "--sizes <list>",
2491
2622
  "comma-separated per-image size hints aligned with the images: 0 auto (default), 1 big (~2\xD7 linear), 2 medium, 3 small (~\xBD). Relative \u2014 smart layout only"
@@ -2706,6 +2837,7 @@ one image-to-text call.`).action(
2706
2837
  );
2707
2838
  return cmd;
2708
2839
  }
2840
+ var WORD_TIMESTAMP_PROVIDERS = TRANSCRIBE_PROVIDERS.filter((p) => transcribeLaneSupportsWordTimestamps(p));
2709
2841
  var FX_PRESETS2 = "room|bathroom|car|hall|concert-hall|church|cave|arena|outdoor|telephone|megaphone|echo|custom";
2710
2842
  function parseSegment(raw) {
2711
2843
  const at = raw.lastIndexOf("@");
@@ -2722,7 +2854,7 @@ function parseSegment(raw) {
2722
2854
  }
2723
2855
  function audioCommand() {
2724
2856
  const cmd = new Command("audio").description(
2725
- "audio primitives \u2014 the building blocks Voice Changer Pro composes: separate, isolate, fx, mix, level, combine"
2857
+ "audio primitives \u2014 the building blocks Voice Changer Pro composes: separate, isolate, fx, mix, level, combine, transcribe"
2726
2858
  );
2727
2859
  cmd.command("separate").description("separate an audio track into stems (Demucs) \u2014 voice vs music/SFX, or the full stem breakdown").requiredOption("--audio <url>", "audio URL to separate").option("--mode <mode>", "vocal_instrumental (default) or stems (drums/bass/other/\u2026)").option("--quality <q>", "separation quality: auto (default), fast, or best").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(
2728
2860
  async (opts) => {
@@ -2850,6 +2982,51 @@ Example:
2850
2982
  }
2851
2983
  }
2852
2984
  );
2985
+ cmd.command("transcribe").description("transcribe an audio (or video) track to text \u2014 elevenlabs-stt is always word-level and can diarize + tag audio events").requiredOption("--audio <url>", "audio (or video) URL to transcribe").option(
2986
+ "--provider <name>",
2987
+ `transcription engine: ${TRANSCRIBE_PROVIDERS.join(" | ")} \u2014 "${DEFAULT_TRANSCRIBE_PROVIDER}" returns NO word timings, named or reached by omitting this flag`
2988
+ ).option("--language <code>", "language code to force (default: auto-detect)").option("--diarize", "label which speaker said each word (elevenlabs-stt)").option("--tag-audio-events", "tag laughter / applause / other non-speech events (elevenlabs-stt)").option("--word-timestamps", "ask for per-word timings \u2014 rejected up front on a lane that cannot produce them").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", `
2989
+ The completed job's output_data carries: text (the whole transcript), words
2990
+ (one entry per word, in MILLISECONDS) and json (the normalized transcript, also
2991
+ ms). A top-level segments array (SECONDS) exists only on the legacy lanes \u2014
2992
+ elevenlabs-stt returns none, so read words.
2993
+
2994
+ Feed the words straight into a kinetic caption render:
2995
+ $ nodaro audio transcribe --audio https://.../talk.mp3 --provider elevenlabs-stt --watch
2996
+ $ nodaro jobs get <jobId> --json | jq '.output_data.words' > words.json
2997
+ $ nodaro media add-captions https://.../talk.mp4 --captions-file words.json \\
2998
+ --style word-highlight --no-auto-transcribe --watch
2999
+
3000
+ Example:
3001
+ $ nodaro audio transcribe --audio https://.../interview.mp3 --provider elevenlabs-stt --diarize --watch`).action(
3002
+ async (opts) => {
3003
+ try {
3004
+ if (opts.provider && !TRANSCRIBE_PROVIDERS.includes(opts.provider)) {
3005
+ warn(`--provider must be one of ${TRANSCRIBE_PROVIDERS.join(", ")} (got "${opts.provider}")`);
3006
+ process.exit(1);
3007
+ }
3008
+ const resolvedLane = opts.provider ?? DEFAULT_TRANSCRIBE_PROVIDER;
3009
+ if (opts.wordTimestamps && !transcribeLaneSupportsWordTimestamps(resolvedLane)) {
3010
+ warn(
3011
+ `--word-timestamps is not supported by "${resolvedLane}"${opts.provider ? "" : " (the default when --provider is omitted)"} \u2014 pass --provider ${WORD_TIMESTAMP_PROVIDERS.join(" or ")}`
3012
+ );
3013
+ process.exit(1);
3014
+ }
3015
+ const client = buildClient(opts.profile);
3016
+ const result = await client.audio.transcribe({
3017
+ audioUrl: opts.audio,
3018
+ ...opts.provider ? { provider: opts.provider } : {},
3019
+ ...opts.language ? { language: opts.language } : {},
3020
+ ...opts.diarize ? { diarize: true } : {},
3021
+ ...opts.tagAudioEvents ? { tagAudioEvents: true } : {},
3022
+ ...opts.wordTimestamps ? { wordTimestamps: true } : {}
3023
+ });
3024
+ await reportQueuedJob(result, () => client.jobs.get(result.jobId), { ...opts, note: resolvedLane });
3025
+ } catch (err) {
3026
+ handleError(err);
3027
+ }
3028
+ }
3029
+ );
2853
3030
  return cmd;
2854
3031
  }
2855
3032
  function presetsCommand() {
@@ -4692,6 +4869,147 @@ var SOURCE_LABELS = {
4692
4869
  profile: "the profile's saved workspace",
4693
4870
  none: "nothing \u2014 the personal space"
4694
4871
  };
4872
+ function readJsonFile(path) {
4873
+ let raw;
4874
+ try {
4875
+ raw = readFileSync(path, "utf8");
4876
+ } catch (err) {
4877
+ throw new Error(`cannot read ${path}: ${err.message}`);
4878
+ }
4879
+ try {
4880
+ return JSON.parse(raw);
4881
+ } catch (err) {
4882
+ throw new Error(`${path} is not valid JSON: ${err.message}`);
4883
+ }
4884
+ }
4885
+ function parseSourceSpec(spec, index2) {
4886
+ const at = spec.lastIndexOf("@");
4887
+ if (at > 0) {
4888
+ const suffix = spec.slice(at + 1);
4889
+ if (suffix === "audio" || suffix === "video") {
4890
+ return { id: `source-${index2 + 1}`, url: spec.slice(0, at), kind: suffix };
4891
+ }
4892
+ }
4893
+ return { id: `source-${index2 + 1}`, url: spec, kind: "video" };
4894
+ }
4895
+ function editCommand() {
4896
+ const cmd = new Command("edit").description(
4897
+ "editorial primitives for podcast / long-form video \u2014 detect silence, apply an EDL, plan a cut"
4898
+ );
4899
+ cmd.command("silence-detect <audioUrl>").description("detect silence ranges in an audio or video source (ffmpeg, keyless)").option("--threshold-db <dbfs>", "dBFS threshold, \u2264 0 (write a negative as --threshold-db=-35)", (v) => Number(v)).option("--min-silence-ms <ms>", "minimum silence length to report", (v) => parseInt(v, 10)).option("--pad-ms <ms>", "padding kept around speech", (v) => parseInt(v, 10)).option("--watch", "poll the job until it finishes").option("--poll-interval <ms>", "poll interval with --watch", (v) => parseInt(v, 10)).option("--profile <name>").option("--json").action(
4900
+ async (audioUrl, opts) => {
4901
+ try {
4902
+ const client = buildClient(opts.profile);
4903
+ const result = await client.edit.silenceDetect({
4904
+ audioUrl,
4905
+ ...opts.thresholdDb !== void 0 ? { thresholdDb: opts.thresholdDb } : {},
4906
+ ...opts.minSilenceMs !== void 0 ? { minSilenceMs: opts.minSilenceMs } : {},
4907
+ ...opts.padMs !== void 0 ? { padMs: opts.padMs } : {}
4908
+ });
4909
+ await reportQueuedJob(result, () => client.jobs.getStatus(result.jobId), {
4910
+ json: opts.json,
4911
+ watch: opts.watch,
4912
+ pollInterval: opts.pollInterval,
4913
+ note: "silence-detect"
4914
+ });
4915
+ } catch (err) {
4916
+ handleError(err);
4917
+ }
4918
+ }
4919
+ );
4920
+ cmd.command("apply-edl").description("render an edit decision list into a video or audio cut").requiredOption("--edl <file>", "path to a JSON file holding the EDL").option("--transcript <file>", "optional transcript JSON to remap through the cut").option("--source <url>", "positional media-URL override for edl.sources[i] (repeatable)", collectVariadic).option("--output <kind>", "video | audio", "video").option("--quality <q>", "proxy | final", "final").option("--crossfade-ms <ms>", "default crossfade on boundaries with no transition", (v) => parseInt(v, 10)).option("--watch", "poll the job until it finishes").option("--poll-interval <ms>", "poll interval with --watch", (v) => parseInt(v, 10)).option("--profile <name>").option("--json").action(
4921
+ async (opts) => {
4922
+ if (opts.output !== "video" && opts.output !== "audio") {
4923
+ warn(`--output must be "video" or "audio" (got "${opts.output}")`);
4924
+ process.exit(1);
4925
+ }
4926
+ if (opts.quality !== "proxy" && opts.quality !== "final") {
4927
+ warn(`--quality must be "proxy" or "final" (got "${opts.quality}")`);
4928
+ process.exit(1);
4929
+ }
4930
+ try {
4931
+ const client = buildClient(opts.profile);
4932
+ const result = await client.edit.applyEdl({
4933
+ edl: readJsonFile(opts.edl),
4934
+ ...opts.source && opts.source.length > 0 ? { sources: opts.source } : {},
4935
+ ...opts.transcript ? { transcript: readJsonFile(opts.transcript) } : {},
4936
+ output: opts.output,
4937
+ quality: opts.quality,
4938
+ ...opts.crossfadeMs !== void 0 ? { crossfadeMs: opts.crossfadeMs } : {}
4939
+ });
4940
+ await reportQueuedJob(result, () => client.jobs.getStatus(result.jobId), {
4941
+ json: opts.json,
4942
+ watch: opts.watch,
4943
+ pollInterval: opts.pollInterval,
4944
+ note: `apply-edl (${opts.output})`
4945
+ });
4946
+ } catch (err) {
4947
+ handleError(err);
4948
+ }
4949
+ }
4950
+ );
4951
+ cmd.command("plan").description("plan a transcript-driven cut / clips / chapters (Cloud edition)").requiredOption("--mode <mode>", "tighten | clips | chapters").requiredOption("--plan-tier <tier>", "economy | standard | premium").requiredOption("--transcript <file>", "path to a timed transcript JSON file").option("--silence <file>", "optional silence JSON \u2014 the silence-detect job's output_data.json ({ version, ranges, durationMs })").option(
4952
+ "--source <url>",
4953
+ "a media source as url or url@audio / url@video (repeatable); id + kind are minted",
4954
+ collectVariadic
4955
+ ).option("--sources-file <file>", "JSON array of full EditPlanSource rows (overrides --source)").option("--instructions <text>", "free-text editing steer").option("--style-guide <text>", "style guide applied to the plan").option("--count <n>", "clips mode: how many clips to cut", (v) => parseInt(v, 10)).option("--target-duration-sec <n>", "clips mode: target duration per clip (seconds)", (v) => parseInt(v, 10)).option("--target-aspect <ratio>", "clips aspect: 16:9 | 9:16 | 1:1 | 4:5").option("--platform <name>", "target platform hint").option("--watch", "poll the job until it finishes").option("--poll-interval <ms>", "poll interval with --watch", (v) => parseInt(v, 10)).option("--profile <name>").option("--json").action(
4956
+ async (opts) => {
4957
+ if (opts.mode !== "tighten" && opts.mode !== "clips" && opts.mode !== "chapters") {
4958
+ warn(`--mode must be "tighten", "clips" or "chapters" (got "${opts.mode}")`);
4959
+ process.exit(1);
4960
+ }
4961
+ if (opts.planTier !== "economy" && opts.planTier !== "standard" && opts.planTier !== "premium") {
4962
+ warn(`--plan-tier must be "economy", "standard" or "premium" (got "${opts.planTier}")`);
4963
+ process.exit(1);
4964
+ }
4965
+ if (opts.targetAspect !== void 0 && !["16:9", "9:16", "1:1", "4:5"].includes(opts.targetAspect)) {
4966
+ warn(`--target-aspect must be one of 16:9, 9:16, 1:1, 4:5 (got "${opts.targetAspect}")`);
4967
+ process.exit(1);
4968
+ }
4969
+ let sources;
4970
+ if (opts.sourcesFile) {
4971
+ const parsed = readJsonFile(opts.sourcesFile);
4972
+ if (!Array.isArray(parsed)) {
4973
+ warn(`--sources-file ${opts.sourcesFile} must contain a JSON array of source rows`);
4974
+ process.exit(1);
4975
+ }
4976
+ sources = parsed;
4977
+ } else {
4978
+ sources = (opts.source ?? []).map(parseSourceSpec);
4979
+ }
4980
+ if (sources.length === 0) {
4981
+ warn("at least one source is required \u2014 pass --source <url> (repeatable) or --sources-file <file>");
4982
+ process.exit(1);
4983
+ }
4984
+ try {
4985
+ const client = buildClient(opts.profile);
4986
+ const input2 = {
4987
+ mode: opts.mode,
4988
+ planTier: opts.planTier,
4989
+ transcript: readJsonFile(opts.transcript),
4990
+ sources,
4991
+ ...opts.silence ? { silence: readJsonFile(opts.silence) } : {},
4992
+ ...opts.instructions !== void 0 ? { instructions: opts.instructions } : {},
4993
+ ...opts.styleGuide !== void 0 ? { styleGuide: opts.styleGuide } : {},
4994
+ ...opts.count !== void 0 ? { count: opts.count } : {},
4995
+ ...opts.targetDurationSec !== void 0 ? { targetDurationSec: opts.targetDurationSec } : {},
4996
+ ...opts.targetAspect !== void 0 ? { targetAspect: opts.targetAspect } : {},
4997
+ ...opts.platform !== void 0 ? { platform: opts.platform } : {}
4998
+ };
4999
+ const result = await client.edit.editPlan(input2);
5000
+ await reportQueuedJob(result, () => client.jobs.getStatus(result.jobId), {
5001
+ json: opts.json,
5002
+ watch: opts.watch,
5003
+ pollInterval: opts.pollInterval,
5004
+ note: `edit-plan (${opts.mode})`
5005
+ });
5006
+ } catch (err) {
5007
+ handleError(err);
5008
+ }
5009
+ }
5010
+ );
5011
+ return cmd;
5012
+ }
4695
5013
 
4696
5014
  // src/index.ts
4697
5015
  function readVersion() {
@@ -4727,6 +5045,7 @@ program.addCommand(shotsCommand());
4727
5045
  program.addCommand(recastCommand());
4728
5046
  program.addCommand(orgCommand());
4729
5047
  program.addCommand(workspaceCommand());
5048
+ program.addCommand(editCommand());
4730
5049
  registerLocationsCommands(program);
4731
5050
  registerObjectsCommands(program);
4732
5051
  program.parseAsync().catch((err) => {