@nodaro/cli 1.29.0 → 1.31.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/dist/index.js CHANGED
@@ -9,11 +9,19 @@ import { join } from 'path';
9
9
  import { createServer } from 'http';
10
10
  import { randomBytes } from 'crypto';
11
11
  import { spawn } from 'child_process';
12
- import { createClient, StaticTokenAuth, UnauthorizedError, NodaroError, LOCATION_ASSET_TYPES, LOCATION_ATTACH_COLUMNS, OBJECT_ASSET_TYPES, OBJECT_ATTACH_COLUMNS } from '@nodaro/sdk';
12
+ import { ContinuationRefusedError, createClient, StaticTokenAuth, UnauthorizedError, NodaroError, LOCATION_ASSET_TYPES, LOCATION_ATTACH_COLUMNS, OBJECT_ASSET_TYPES, OBJECT_ATTACH_COLUMNS } from '@nodaro/sdk';
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, TRANSCRIBE_PROVIDERS, transcribeLaneSupportsWordTimestamps, DIALOGUE_PROVIDERS, dialogueStabilityAccepted, dialogueProviderOf, getDialogueCapabilities, 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, VIDEO_OVERLAY_PRESET_IDS, VIDEO_OVERLAY_CORNERS, VIDEO_OVERLAY_OUTPUT_ASPECTS, isVideoOverlayPresetId, isVideoOverlayCorner, isVideoOverlayOutputAspect, VIDEO_OVERLAY_FITS, DEFAULT_VIDEO_MASK_PROVIDER, VIDEO_MASK_PROVIDERS, VIDEO_MASK_LIMITS, MASK_COMPOSITE_BOUNDS, MASK_COMPOSITE_DEFAULTS, MASK_COMPOSITE_BACKGROUND_FITS, MASK_COMPOSITE_AUDIO_SOURCES, DEFAULT_TRANSCRIBE_PROVIDER, SOCIAL_PLATFORMS, collectionRecordHeadline, COMPETITOR_ACCOUNT_KEYS, isMeasurableCard, EDIT_PLAN_MODES, isSocialPost, COMPETITOR_ABOUT_PLATFORMS, COMPETITOR_SCHEDULES, RECAST_SEGMENT_PACKS } from '@nodaro/shared';
16
+ import { CHARACTER_STYLES } from '@nodaro/shared/entities';
17
+ import { TRANSCRIBE_PROVIDERS, transcribeLaneSupportsWordTimestamps, DIALOGUE_PROVIDERS, dialogueStabilityAccepted, dialogueProviderOf, getDialogueCapabilities, TRANSCRIBE_LANES, DEFAULT_TRANSCRIBE_PROVIDER } from '@nodaro/shared/models';
18
+ import { OVERLAY_ANCHORS, OVERLAY_PLATFORM_IDS, DEFAULT_VIDEO_MASK_PROVIDER, VIDEO_MASK_PROVIDERS, VIDEO_MASK_LIMITS, MASK_COMPOSITE_BOUNDS, MASK_COMPOSITE_DEFAULTS, MASK_COMPOSITE_BACKGROUND_FITS, MASK_COMPOSITE_AUDIO_SOURCES } from '@nodaro/shared/media';
19
+ import { ALL_CAPTION_STYLES, DEFAULT_CAPTION_LOOK, CAPTION_LOOK_IDS, CAPTION_MAX_WORDS_PER_LINE_MIN, CAPTION_MAX_WORDS_PER_LINE_MAX, SUPPORTED_FONT_NAMES } from '@nodaro/shared/captions';
20
+ import { VIDEO_OVERLAY_PRESET_IDS, VIDEO_OVERLAY_CORNERS, VIDEO_OVERLAY_OUTPUT_ASPECTS, isVideoOverlayPresetId, isVideoOverlayCorner, isVideoOverlayOutputAspect, VIDEO_OVERLAY_FITS } from '@nodaro/shared/video';
21
+ import { SOCIAL_PLATFORMS, COMPETITOR_ACCOUNT_KEYS, isMeasurableCard, isSocialPost, COMPETITOR_ABOUT_PLATFORMS, COMPETITOR_SCHEDULES } from '@nodaro/shared/social';
22
+ import { collectionRecordHeadline } from '@nodaro/shared/nodes';
23
+ import { RECAST_SEGMENT_PACKS } from '@nodaro/shared/apps';
24
+ import { SPEAKER_LAYOUT_IDS, EDL_TARGET_ASPECTS, EDIT_PLAN_TIERS, EDIT_PLAN_MODES } from '@nodaro/shared/edl';
17
25
 
18
26
  var __getOwnPropNames = Object.getOwnPropertyNames;
19
27
  var __commonJS = (cb, mod) => function __require() {
@@ -29,7 +37,7 @@ var require_package = __commonJS({
29
37
  "package.json"(exports$1, module) {
30
38
  module.exports = {
31
39
  name: "@nodaro/cli",
32
- version: "1.29.0",
40
+ version: "1.31.0",
33
41
  description: "Command-line interface for Nodaro \u2014 list and run workflows, inspect jobs and executions, manage projects from the terminal.",
34
42
  type: "module",
35
43
  license: "Apache-2.0",
@@ -70,11 +78,11 @@ var require_package = __commonJS({
70
78
  "@inquirer/confirm": "^6.0.12",
71
79
  "@inquirer/input": "^5.0.12",
72
80
  "@inquirer/select": "^5.1.4",
73
- "@nodaro/sdk": "^2.26.0",
74
- "@nodaro/shared": "^3.31.0",
81
+ "@nodaro/sdk": "^2.28.0",
82
+ "@nodaro/shared": "^3.32.0",
75
83
  commander: "^12.1.0",
76
84
  picocolors: "^1.1.1",
77
- "@nodaro/prompts": "^1.37.1"
85
+ "@nodaro/prompts": "^1.38.0"
78
86
  },
79
87
  devDependencies: {
80
88
  tsup: "^8.5.0",
@@ -398,7 +406,7 @@ function saveWorkspace(profileName, workspaceId) {
398
406
  }
399
407
 
400
408
  // src/client.ts
401
- var CLI_VERSION = "1.29.0" ;
409
+ var CLI_VERSION = "1.31.0" ;
402
410
  function buildClient(profileName) {
403
411
  const { name, profile } = getProfile(profileName);
404
412
  if (!profile) {
@@ -522,6 +530,146 @@ function projectsCommand() {
522
530
  });
523
531
  return cmd;
524
532
  }
533
+ function idList(value) {
534
+ return value.split(/[\s,]+/).filter(Boolean);
535
+ }
536
+ function sessionsCommand() {
537
+ const cmd = new Command("sessions").description(
538
+ "generation sessions inside projects: list, read, create, rename, archive, import, remove, delete"
539
+ );
540
+ cmd.command("list").description("your sessions, newest first").option("--project <id>", "only this project's sessions").option("--tool <tool>", "only this tool's sessions, e.g. create-image").option("--archived", "include archived sessions").option("--limit <n>", "page size (1-100)").option("--cursor <cursor>", "the previous page's next").option("--profile <name>").option("--json").action(async (opts) => {
541
+ try {
542
+ const client = buildClient(opts.profile);
543
+ const page = await client.sessions.list({
544
+ projectId: opts.project,
545
+ tool: opts.tool,
546
+ includeArchived: opts.archived,
547
+ limit: opts.limit ? Number(opts.limit) : void 0,
548
+ cursor: opts.cursor
549
+ });
550
+ if (opts.json) {
551
+ emit(page, opts);
552
+ return;
553
+ }
554
+ table(
555
+ page.data.map((s) => ({
556
+ id: s.id,
557
+ title: s.title ?? "(untitled)",
558
+ tool: s.tool,
559
+ items: s.itemCount,
560
+ updatedAt: s.updatedAt
561
+ })),
562
+ ["id", "title", "tool", "items", "updatedAt"]
563
+ );
564
+ if (page.next) dim(`next: --cursor ${page.next}`);
565
+ } catch (err) {
566
+ handleError(err);
567
+ }
568
+ });
569
+ cmd.command("get <id>").description("show one session").option("--profile <name>").option("--json").action(async (id, opts) => {
570
+ try {
571
+ const result = await buildClient(opts.profile).sessions.get(id);
572
+ if (opts.json) emit(result.data, opts);
573
+ else detail(result.data);
574
+ } catch (err) {
575
+ handleError(err);
576
+ }
577
+ });
578
+ cmd.command("items <id>").description("a session's items, born-in and imported, newest first").option("--limit <n>", "page size (1-100)").option("--cursor <cursor>", "the previous page's next").option("--profile <name>").option("--json").action(async (id, opts) => {
579
+ try {
580
+ const page = await buildClient(opts.profile).sessions.items(id, {
581
+ limit: opts.limit ? Number(opts.limit) : void 0,
582
+ cursor: opts.cursor
583
+ });
584
+ if (opts.json) {
585
+ emit(page, opts);
586
+ return;
587
+ }
588
+ table(
589
+ page.data.map((i) => ({
590
+ jobId: i.jobId,
591
+ status: i.job.status,
592
+ imported: i.imported ? `from ${i.importedFrom?.title ?? i.importedFrom?.sessionId ?? "?"}` : "",
593
+ addedAt: i.addedAt
594
+ })),
595
+ ["jobId", "status", "imported", "addedAt"]
596
+ );
597
+ if (page.next) dim(`next: --cursor ${page.next}`);
598
+ } catch (err) {
599
+ handleError(err);
600
+ }
601
+ });
602
+ cmd.command("create").description("open a session (its project is fixed once set)").requiredOption("--tool <tool>", "the creation tool, e.g. create-image").option("--project <id>", "one of your projects").option("--title <title>").option("--profile <name>").option("--json").action(async (opts) => {
603
+ try {
604
+ const result = await buildClient(opts.profile).sessions.create({
605
+ tool: opts.tool,
606
+ projectId: opts.project,
607
+ title: opts.title
608
+ });
609
+ if (opts.json) {
610
+ emit(result.data, opts);
611
+ return;
612
+ }
613
+ success(`created session ${result.data.id}`);
614
+ } catch (err) {
615
+ handleError(err);
616
+ }
617
+ });
618
+ cmd.command("update <id>").description("rename or archive a session").option("--title <title>", "new title").option("--untitled", "clear the title").option("--archive", "archive it").option("--unarchive", "bring it back").option("--profile <name>").option("--json").action(async (id, opts) => {
619
+ try {
620
+ const title = opts.untitled ? null : opts.title;
621
+ const archived = opts.archive ? true : opts.unarchive ? false : void 0;
622
+ if (title === void 0 && archived === void 0) {
623
+ throw new Error("nothing to update \u2014 provide --title, --untitled, --archive or --unarchive");
624
+ }
625
+ const result = await buildClient(opts.profile).sessions.update(id, { title, archived });
626
+ if (opts.json) {
627
+ emit(result.data, opts);
628
+ return;
629
+ }
630
+ success(`updated session ${result.data.id}`);
631
+ } catch (err) {
632
+ handleError(err);
633
+ }
634
+ });
635
+ cmd.command("import <id>").description("import some of your jobs into a session \u2014 links, not copies; all-or-nothing").requiredOption("--jobs <ids>", "job ids, comma- or space-separated (up to 100)").option("--profile <name>").option("--json").action(async (id, opts) => {
636
+ try {
637
+ const result = await buildClient(opts.profile).sessions.importItems(id, { jobIds: idList(opts.jobs) });
638
+ if (opts.json) {
639
+ emit(result.data, opts);
640
+ return;
641
+ }
642
+ success(`imported ${result.data.imported} of ${result.data.requested}`);
643
+ } catch (err) {
644
+ handleError(err);
645
+ }
646
+ });
647
+ cmd.command("remove <id> <jobId>").description("remove one item from a session (the link only \u2014 the job stays)").option("--profile <name>").option("--json").action(async (id, jobId, opts) => {
648
+ try {
649
+ await buildClient(opts.profile).sessions.removeItem(id, jobId);
650
+ if (opts.json) {
651
+ emit({ success: true, id, jobId }, opts);
652
+ return;
653
+ }
654
+ success(`removed ${jobId} from session ${id}`);
655
+ } catch (err) {
656
+ handleError(err);
657
+ }
658
+ });
659
+ cmd.command("delete <id>").description("delete a session and its links (its jobs are kept)").option("--profile <name>").option("--json").action(async (id, opts) => {
660
+ try {
661
+ await buildClient(opts.profile).sessions.delete(id);
662
+ if (opts.json) {
663
+ emit({ success: true, id }, opts);
664
+ return;
665
+ }
666
+ success(`Deleted session ${id}`);
667
+ } catch (err) {
668
+ handleError(err);
669
+ }
670
+ });
671
+ return cmd;
672
+ }
525
673
 
526
674
  // src/util.ts
527
675
  function collectVariadic(value, previous) {
@@ -5822,6 +5970,11 @@ var SOURCE_LABELS = {
5822
5970
  function isEditPlanMode(v) {
5823
5971
  return EDIT_PLAN_MODES.includes(v);
5824
5972
  }
5973
+ var CONTINUATION_NEXT_STEP = {
5974
+ already_running: (id) => ` \u2014 follow it: nodaro jobs get ${id}`,
5975
+ continuation_superseded: (id) => ` \u2014 continue that one: nodaro edit continue-use-case ${id} --mode from-failed`,
5976
+ render_final_already_rendered: (id) => ` \u2014 its result is the one to use: nodaro jobs get ${id}`
5977
+ };
5825
5978
  function readJsonFile(path) {
5826
5979
  let raw;
5827
5980
  try {
@@ -5950,6 +6103,92 @@ function editCommand() {
5950
6103
  }
5951
6104
  }
5952
6105
  );
6106
+ const framingLayouts = ["auto", ...SPEAKER_LAYOUT_IDS];
6107
+ cmd.command("tighten-episode").description("tighten a podcast recording in one step (transcribe, cut silences, render; optional captions, music and framing)").requiredOption("--media <url>", "the recording (video or audio URL, up to 3 hours)").option("--music <url>", "optional music bed, ducked under the voice").option("--output <kind>", "video | audio (an audio recording always makes an audio episode)").option("--framing <aspect>", `frame a video episode on its speakers: ${EDL_TARGET_ASPECTS.join(" | ")}`).option("--layout <layout>", `layout with --framing (default auto): ${framingLayouts.join(" | ")}`).option("--no-captions", "no captions on a video episode").option("--review", "stop at a preview to review (render the final with `nodaro edit continue-use-case <jobId> --mode render-final`)").option("--plan-tier <tier>", EDIT_PLAN_TIERS.join(" | ")).option("--instructions <text>", "editing instructions for the planner").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(
6108
+ async (opts) => {
6109
+ if (opts.output !== void 0 && opts.output !== "video" && opts.output !== "audio") {
6110
+ warn(`--output must be "video" or "audio" (got "${opts.output}")`);
6111
+ process.exit(1);
6112
+ }
6113
+ if (opts.planTier !== void 0 && !EDIT_PLAN_TIERS.includes(opts.planTier)) {
6114
+ warn(`--plan-tier must be ${EDIT_PLAN_TIERS.join(", ")} (got "${opts.planTier}")`);
6115
+ process.exit(1);
6116
+ }
6117
+ if (opts.framing !== void 0 && !EDL_TARGET_ASPECTS.includes(opts.framing)) {
6118
+ warn(`--framing must be ${EDL_TARGET_ASPECTS.join(", ")} (got "${opts.framing}")`);
6119
+ process.exit(1);
6120
+ }
6121
+ if (opts.layout !== void 0 && opts.framing === void 0) {
6122
+ warn("--layout applies with --framing only (it picks the framed layout)");
6123
+ process.exit(1);
6124
+ }
6125
+ if (opts.layout !== void 0 && !framingLayouts.includes(opts.layout)) {
6126
+ warn(`--layout must be ${framingLayouts.join(", ")} (got "${opts.layout}")`);
6127
+ process.exit(1);
6128
+ }
6129
+ try {
6130
+ const client = buildClient(opts.profile);
6131
+ const result = await client.edit.tightenEpisode({
6132
+ mediaUrl: opts.media,
6133
+ ...opts.music ? { musicUrl: opts.music } : {},
6134
+ ...opts.output ? { output: opts.output } : {},
6135
+ ...opts.framing ? { framing: { aspect: opts.framing, layout: opts.layout ?? "auto" } } : {},
6136
+ // commander's --no-captions defaults `captions` to true: send it only when turned off.
6137
+ ...opts.captions === false ? { captions: false } : {},
6138
+ ...opts.review ? { reviewBeforeRender: true } : {},
6139
+ ...opts.planTier ? { planTier: opts.planTier } : {},
6140
+ ...opts.instructions ? { instructions: opts.instructions } : {}
6141
+ });
6142
+ await reportQueuedJob(result, () => client.jobs.getStatus(result.jobId), {
6143
+ json: opts.json,
6144
+ watch: opts.watch,
6145
+ pollInterval: opts.pollInterval,
6146
+ note: "tighten-episode"
6147
+ });
6148
+ } catch (err) {
6149
+ handleError(err);
6150
+ }
6151
+ }
6152
+ );
6153
+ cmd.command("continue-use-case <jobId>").description("continue a Tighten Episode run as a new job: from where it failed, or its Render final after a review").requiredOption("--mode <mode>", "from-failed | render-final").option("--edit <file>", "render-final only: a JSON file holding the reviewer's edit of the plan (an EDL)").option("--idempotency-key <key>", "sent as Idempotency-Key: a retry with the same key answers the run already started").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(async (jobId, opts) => {
6154
+ if (opts.mode !== "from-failed" && opts.mode !== "render-final") {
6155
+ warn(`--mode must be "from-failed" or "render-final" (got "${opts.mode}")`);
6156
+ process.exit(1);
6157
+ }
6158
+ if (opts.edit !== void 0 && opts.mode !== "render-final") {
6159
+ warn("--edit applies to --mode render-final only");
6160
+ process.exit(1);
6161
+ }
6162
+ try {
6163
+ const client = buildClient(opts.profile);
6164
+ const result = await client.edit.continueUseCase(
6165
+ {
6166
+ jobId,
6167
+ mode: opts.mode,
6168
+ ...opts.edit !== void 0 ? { editedEdl: readJsonFile(opts.edit) } : {}
6169
+ },
6170
+ opts.idempotencyKey ? { idempotencyKey: opts.idempotencyKey } : void 0
6171
+ );
6172
+ await reportQueuedJob(result, () => client.jobs.getStatus(result.jobId), {
6173
+ json: opts.json,
6174
+ watch: opts.watch,
6175
+ pollInterval: opts.pollInterval,
6176
+ note: `continue-use-case (${opts.mode})`
6177
+ });
6178
+ } catch (err) {
6179
+ if (err instanceof ContinuationRefusedError) {
6180
+ if (opts.json) {
6181
+ emit({ error: { code: err.code, message: err.message }, jobId: err.jobId }, opts);
6182
+ } else {
6183
+ console.error(pc3.red(`\u2717 ${err.message}`));
6184
+ console.error(pc3.dim(` code: ${err.code}`));
6185
+ console.error(pc3.dim(` job: ${err.jobId}${CONTINUATION_NEXT_STEP[err.code]?.(err.jobId) ?? ""}`));
6186
+ }
6187
+ process.exit(1);
6188
+ }
6189
+ handleError(err);
6190
+ }
6191
+ });
5953
6192
  cmd.command("plan").description("plan a transcript-driven cut / clips / chapters / trailer (Cloud edition)").requiredOption("--mode <mode>", EDIT_PLAN_MODES.join(" | ")).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(
5954
6193
  "--source <url>",
5955
6194
  "a media source as [id=]url[@audio|@video] (repeatable); id defaults to source-N, kind to video",
@@ -6059,6 +6298,7 @@ program.hook("preAction", () => {
6059
6298
  });
6060
6299
  program.addCommand(authCommand());
6061
6300
  program.addCommand(projectsCommand());
6301
+ program.addCommand(sessionsCommand());
6062
6302
  program.addCommand(workflowsCommand());
6063
6303
  program.addCommand(appsCommand());
6064
6304
  program.addCommand(nodesCommand());