@nodaro/cli 1.30.0 → 1.32.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,7 +9,7 @@ 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 { ContinuationRefusedError, 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, CallbackAuth, 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';
@@ -18,8 +18,8 @@ import { TRANSCRIBE_PROVIDERS, transcribeLaneSupportsWordTimestamps, DIALOGUE_PR
18
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
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
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 { collectionRecordHeadline, parseNodePresetExport } from '@nodaro/shared/nodes';
21
22
  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
23
  import { RECAST_SEGMENT_PACKS } from '@nodaro/shared/apps';
24
24
  import { SPEAKER_LAYOUT_IDS, EDL_TARGET_ASPECTS, EDIT_PLAN_TIERS, EDIT_PLAN_MODES } from '@nodaro/shared/edl';
25
25
 
@@ -37,7 +37,7 @@ var require_package = __commonJS({
37
37
  "package.json"(exports$1, module) {
38
38
  module.exports = {
39
39
  name: "@nodaro/cli",
40
- version: "1.30.0",
40
+ version: "1.32.0",
41
41
  description: "Command-line interface for Nodaro \u2014 list and run workflows, inspect jobs and executions, manage projects from the terminal.",
42
42
  type: "module",
43
43
  license: "Apache-2.0",
@@ -78,11 +78,11 @@ var require_package = __commonJS({
78
78
  "@inquirer/confirm": "^6.0.12",
79
79
  "@inquirer/input": "^5.0.12",
80
80
  "@inquirer/select": "^5.1.4",
81
- "@nodaro/sdk": "^2.27.0",
82
- "@nodaro/shared": "^3.32.0",
81
+ "@nodaro/sdk": "^2.29.0",
82
+ "@nodaro/shared": "^3.33.0",
83
83
  commander: "^12.1.0",
84
84
  picocolors: "^1.1.1",
85
- "@nodaro/prompts": "^1.38.0"
85
+ "@nodaro/prompts": "^1.39.0"
86
86
  },
87
87
  devDependencies: {
88
88
  tsup: "^8.5.0",
@@ -102,6 +102,7 @@ var require_package = __commonJS({
102
102
  };
103
103
  }
104
104
  });
105
+ var DEFAULT_BASE_URL = "https://app.nodaro.ai";
105
106
  function configDir() {
106
107
  return process.env.NODARO_CONFIG_DIR ?? join(homedir(), ".config", "nodaro");
107
108
  }
@@ -155,6 +156,9 @@ function deleteProfile(name) {
155
156
  saveConfig(config);
156
157
  return true;
157
158
  }
159
+ function terminalSafe(text) {
160
+ return text.replace(/[\u0000-\u001f\u007f-\u009f]/g, "\uFFFD");
161
+ }
158
162
  function emit(value, opts = {}) {
159
163
  if (opts.json) {
160
164
  const indent = process.stdout.isTTY ? 2 : void 0;
@@ -203,7 +207,7 @@ function table(rows2, columns) {
203
207
  }
204
208
  function format(value) {
205
209
  if (value === null || value === void 0) return "";
206
- if (typeof value === "string") return value;
210
+ if (typeof value === "string") return terminalSafe(value);
207
211
  if (typeof value === "number" || typeof value === "boolean") return String(value);
208
212
  if (value instanceof Date) return value.toISOString();
209
213
  return JSON.stringify(value);
@@ -319,7 +323,6 @@ function escapeHtml(s) {
319
323
  }
320
324
 
321
325
  // src/commands/auth.ts
322
- var DEFAULT_BASE_URL = "https://app.nodaro.ai";
323
326
  function authCommand() {
324
327
  const cmd = new Command("auth").description("manage credentials for one or more Nodaro instances");
325
328
  cmd.command("login").description("save a token for a profile (browser flow by default; --token or --no-browser for paste)").option("--profile <name>", "profile name", "production").option("--token <token>", "API token (skips browser flow and prompt)").option("--base-url <url>", "Nodaro base URL", DEFAULT_BASE_URL).option("--no-browser", "skip the browser flow and prompt for a pasted token instead").action(async (opts) => {
@@ -406,7 +409,15 @@ function saveWorkspace(profileName, workspaceId) {
406
409
  }
407
410
 
408
411
  // src/client.ts
409
- var CLI_VERSION = "1.30.0" ;
412
+ var CLI_VERSION = "1.32.0" ;
413
+ function buildPublicClient(opts = {}) {
414
+ const { profile } = getProfile(opts.profile);
415
+ return createClient({
416
+ baseUrl: opts.baseUrl ?? profile?.baseUrl ?? DEFAULT_BASE_URL,
417
+ auth: new CallbackAuth(() => null),
418
+ clientLabel: `cli/${CLI_VERSION}`
419
+ });
420
+ }
410
421
  function buildClient(profileName) {
411
422
  const { name, profile } = getProfile(profileName);
412
423
  if (!profile) {
@@ -530,8 +541,146 @@ function projectsCommand() {
530
541
  });
531
542
  return cmd;
532
543
  }
533
-
534
- // src/util.ts
544
+ function idList(value) {
545
+ return value.split(/[\s,]+/).filter(Boolean);
546
+ }
547
+ function sessionsCommand() {
548
+ const cmd = new Command("sessions").description(
549
+ "generation sessions inside projects: list, read, create, rename, archive, import, remove, delete"
550
+ );
551
+ 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) => {
552
+ try {
553
+ const client = buildClient(opts.profile);
554
+ const page = await client.sessions.list({
555
+ projectId: opts.project,
556
+ tool: opts.tool,
557
+ includeArchived: opts.archived,
558
+ limit: opts.limit ? Number(opts.limit) : void 0,
559
+ cursor: opts.cursor
560
+ });
561
+ if (opts.json) {
562
+ emit(page, opts);
563
+ return;
564
+ }
565
+ table(
566
+ page.data.map((s) => ({
567
+ id: s.id,
568
+ title: s.title ?? "(untitled)",
569
+ tool: s.tool,
570
+ items: s.itemCount,
571
+ updatedAt: s.updatedAt
572
+ })),
573
+ ["id", "title", "tool", "items", "updatedAt"]
574
+ );
575
+ if (page.next) dim(`next: --cursor ${page.next}`);
576
+ } catch (err) {
577
+ handleError(err);
578
+ }
579
+ });
580
+ cmd.command("get <id>").description("show one session").option("--profile <name>").option("--json").action(async (id, opts) => {
581
+ try {
582
+ const result = await buildClient(opts.profile).sessions.get(id);
583
+ if (opts.json) emit(result.data, opts);
584
+ else detail(result.data);
585
+ } catch (err) {
586
+ handleError(err);
587
+ }
588
+ });
589
+ 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) => {
590
+ try {
591
+ const page = await buildClient(opts.profile).sessions.items(id, {
592
+ limit: opts.limit ? Number(opts.limit) : void 0,
593
+ cursor: opts.cursor
594
+ });
595
+ if (opts.json) {
596
+ emit(page, opts);
597
+ return;
598
+ }
599
+ table(
600
+ page.data.map((i) => ({
601
+ jobId: i.jobId,
602
+ status: i.job.status,
603
+ imported: i.imported ? `from ${i.importedFrom?.title ?? i.importedFrom?.sessionId ?? "?"}` : "",
604
+ addedAt: i.addedAt
605
+ })),
606
+ ["jobId", "status", "imported", "addedAt"]
607
+ );
608
+ if (page.next) dim(`next: --cursor ${page.next}`);
609
+ } catch (err) {
610
+ handleError(err);
611
+ }
612
+ });
613
+ 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) => {
614
+ try {
615
+ const result = await buildClient(opts.profile).sessions.create({
616
+ tool: opts.tool,
617
+ projectId: opts.project,
618
+ title: opts.title
619
+ });
620
+ if (opts.json) {
621
+ emit(result.data, opts);
622
+ return;
623
+ }
624
+ success(`created session ${result.data.id}`);
625
+ } catch (err) {
626
+ handleError(err);
627
+ }
628
+ });
629
+ 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) => {
630
+ try {
631
+ const title = opts.untitled ? null : opts.title;
632
+ const archived = opts.archive ? true : opts.unarchive ? false : void 0;
633
+ if (title === void 0 && archived === void 0) {
634
+ throw new Error("nothing to update \u2014 provide --title, --untitled, --archive or --unarchive");
635
+ }
636
+ const result = await buildClient(opts.profile).sessions.update(id, { title, archived });
637
+ if (opts.json) {
638
+ emit(result.data, opts);
639
+ return;
640
+ }
641
+ success(`updated session ${result.data.id}`);
642
+ } catch (err) {
643
+ handleError(err);
644
+ }
645
+ });
646
+ 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) => {
647
+ try {
648
+ const result = await buildClient(opts.profile).sessions.importItems(id, { jobIds: idList(opts.jobs) });
649
+ if (opts.json) {
650
+ emit(result.data, opts);
651
+ return;
652
+ }
653
+ success(`imported ${result.data.imported} of ${result.data.requested}`);
654
+ } catch (err) {
655
+ handleError(err);
656
+ }
657
+ });
658
+ 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) => {
659
+ try {
660
+ await buildClient(opts.profile).sessions.removeItem(id, jobId);
661
+ if (opts.json) {
662
+ emit({ success: true, id, jobId }, opts);
663
+ return;
664
+ }
665
+ success(`removed ${jobId} from session ${id}`);
666
+ } catch (err) {
667
+ handleError(err);
668
+ }
669
+ });
670
+ cmd.command("delete <id>").description("delete a session and its links (its jobs are kept)").option("--profile <name>").option("--json").action(async (id, opts) => {
671
+ try {
672
+ await buildClient(opts.profile).sessions.delete(id);
673
+ if (opts.json) {
674
+ emit({ success: true, id }, opts);
675
+ return;
676
+ }
677
+ success(`Deleted session ${id}`);
678
+ } catch (err) {
679
+ handleError(err);
680
+ }
681
+ });
682
+ return cmd;
683
+ }
535
684
  function collectVariadic(value, previous) {
536
685
  return [...previous ?? [], value];
537
686
  }
@@ -599,6 +748,101 @@ async function reportQueuedJob(result, fetchJob, opts) {
599
748
  json: opts.json
600
749
  });
601
750
  }
751
+ var TRAINING_IN_FLIGHT = /* @__PURE__ */ new Set(["queued", "training"]);
752
+ function isTransientPollError(err) {
753
+ if (!(err instanceof NodaroError)) return true;
754
+ if (err.status === 408 || err.status === 429) return true;
755
+ return !(err.status >= 400 && err.status < 500);
756
+ }
757
+ async function watchTraining(opts) {
758
+ const intervalMs = opts.intervalMs ?? 1e4;
759
+ const start = Date.now();
760
+ let lastStatus = "";
761
+ let lastInFlight;
762
+ for (; ; ) {
763
+ let result;
764
+ try {
765
+ result = await opts.fetch();
766
+ } catch (err) {
767
+ if (!isTransientPollError(err)) throw err;
768
+ const errMsg = err instanceof Error ? err.message : String(err);
769
+ info(`[${elapsed(start)}s] poll failed (will retry): ${errMsg}`);
770
+ await sleep(intervalMs);
771
+ continue;
772
+ }
773
+ const status = result.status;
774
+ if (status !== lastStatus) {
775
+ info(`[${elapsed(start)}s] ${opts.label} \u2192 ${status}`);
776
+ lastStatus = status;
777
+ }
778
+ if (TRAINING_IN_FLIGHT.has(status)) {
779
+ lastInFlight = status;
780
+ await sleep(intervalMs);
781
+ continue;
782
+ }
783
+ if (opts.json) {
784
+ emit(result, opts);
785
+ return result;
786
+ }
787
+ if (status === "succeeded") {
788
+ success("training succeeded");
789
+ return result;
790
+ }
791
+ if (status === "failed") {
792
+ if (result.error) info(`reason: ${result.error}`);
793
+ process.exit(2);
794
+ }
795
+ if (status === "cancelled") process.exit(130);
796
+ if (status === "untrained") {
797
+ if (lastInFlight === "training") {
798
+ info("the training was removed before it finished");
799
+ process.exit(130);
800
+ }
801
+ if (lastInFlight === "queued") {
802
+ info("the training could not be started (nothing was charged), or was removed before it started");
803
+ process.exit(2);
804
+ }
805
+ info("no training in flight");
806
+ }
807
+ return result;
808
+ }
809
+ }
810
+ async function watchJobsUntilTerminal(opts) {
811
+ const intervalMs = opts.intervalMs ?? 2e3;
812
+ const start = Date.now();
813
+ const lastStatus = /* @__PURE__ */ new Map();
814
+ const settled = /* @__PURE__ */ new Map();
815
+ for (; ; ) {
816
+ for (const jobId of opts.jobIds) {
817
+ if (settled.has(jobId)) continue;
818
+ try {
819
+ const { data } = await opts.fetchStatus(jobId);
820
+ if (data.status !== lastStatus.get(jobId)) {
821
+ info(`[${elapsed(start)}s] ${jobId} \u2192 ${data.status}`);
822
+ lastStatus.set(jobId, data.status);
823
+ }
824
+ if (TERMINAL.has(data.status) || data.status === "pending_review") settled.set(jobId, data);
825
+ } catch (err) {
826
+ const errMsg = err instanceof Error ? err.message : String(err);
827
+ info(`[${elapsed(start)}s] ${jobId} poll failed (will retry): ${errMsg}`);
828
+ }
829
+ }
830
+ if (settled.size === opts.jobIds.length) break;
831
+ await sleep(intervalMs);
832
+ }
833
+ const finals = opts.jobIds.map((jobId) => settled.get(jobId));
834
+ if (opts.json) {
835
+ emit(finals, opts);
836
+ return finals;
837
+ }
838
+ const completed = finals.filter((job) => job.status === "completed").length;
839
+ if (completed === finals.length) {
840
+ success(`all ${finals.length} completed in ${elapsed(start)}s`);
841
+ return finals;
842
+ }
843
+ info(`${completed} of ${finals.length} completed`);
844
+ process.exit(finals.some((job) => job.status === "failed" || job.status === "cancelled") ? 2 : 3);
845
+ }
602
846
  function elapsed(startMs) {
603
847
  return ((Date.now() - startMs) / 1e3).toFixed(1);
604
848
  }
@@ -874,8 +1118,59 @@ async function watchExecution(client, executionId, opts) {
874
1118
  ...opts
875
1119
  });
876
1120
  }
1121
+ var RATING_FILTERS = ["good", "bad", "rated", "unrated"];
1122
+ function list(value) {
1123
+ if (value === void 0) return void 0;
1124
+ const values = value.split(",").map((v) => v.trim()).filter(Boolean);
1125
+ return values.length > 0 ? values : void 0;
1126
+ }
1127
+ function ratingFilter(value) {
1128
+ if (value === void 0) return void 0;
1129
+ if (!RATING_FILTERS.includes(value)) {
1130
+ throw new Error(`--rating takes ${RATING_FILTERS.join(", ")} (got "${value}")`);
1131
+ }
1132
+ return value;
1133
+ }
1134
+ function ratingArg(value) {
1135
+ if (value === "clear") return null;
1136
+ if (value === "good" || value === "bad") return value;
1137
+ throw new Error(`a rating is good, bad or clear (got "${value}")`);
1138
+ }
877
1139
  function jobsCommand() {
878
- const cmd = new Command("jobs").description("inspect and cancel individual jobs");
1140
+ const cmd = new Command("jobs").description("list, inspect, rate and cancel jobs");
1141
+ cmd.command("list").description("your jobs, newest first").option("--status <statuses>", "only these statuses, comma-separated (e.g. failed,cancelled)").option("--type <types>", "only these input_data.type values, comma-separated (e.g. generate-image)").option("--origin <origin>", "only jobs this client app sent").option("--favorited", "only jobs you favorited").option("--no-favorited", "only jobs you did not favorite").option("--rating <rating>", "good, bad, rated (any) or unrated").option("--limit <n>", "page size (1-100)").option("--cursor <cursor>", "the previous page's next").option("--profile <name>").option("--json").action(async (opts) => {
1142
+ try {
1143
+ const rating = ratingFilter(opts.rating);
1144
+ const client = buildClient(opts.profile);
1145
+ const page = await client.jobs.list({
1146
+ status: list(opts.status),
1147
+ type: list(opts.type),
1148
+ origin: opts.origin,
1149
+ favorited: opts.favorited,
1150
+ rating,
1151
+ limit: opts.limit ? Number(opts.limit) : void 0,
1152
+ cursor: opts.cursor
1153
+ });
1154
+ if (opts.json) {
1155
+ emit(page, opts);
1156
+ return;
1157
+ }
1158
+ table(
1159
+ page.data.map((job) => ({
1160
+ id: job.id,
1161
+ status: job.status,
1162
+ type: job.input_data?.type ?? job.job_type ?? "",
1163
+ favorited: job.favorited ? "yes" : "",
1164
+ rating: job.rating ?? "",
1165
+ created: job.created_at
1166
+ })),
1167
+ ["id", "status", "type", "favorited", "rating", "created"]
1168
+ );
1169
+ if (page.next) dim(`next: --cursor ${page.next}`);
1170
+ } catch (err) {
1171
+ handleError(err);
1172
+ }
1173
+ });
879
1174
  cmd.command("get <id>").description("show one job by id").option("--profile <name>").option("--json").action(async (id, opts) => {
880
1175
  try {
881
1176
  const client = buildClient(opts.profile);
@@ -886,6 +1181,17 @@ function jobsCommand() {
886
1181
  handleError(err);
887
1182
  }
888
1183
  });
1184
+ cmd.command("rate <id> <rating>").description("rate one of your jobs: good, bad, or clear to remove the rating").option("--profile <name>").option("--json").action(async (id, value, opts) => {
1185
+ try {
1186
+ const rating = ratingArg(value);
1187
+ const client = buildClient(opts.profile);
1188
+ const result = await client.jobs.rate(id, rating);
1189
+ if (opts.json) emit(result, opts);
1190
+ else success(rating ? `rated job ${id} ${rating}` : `cleared the rating of job ${id}`);
1191
+ } catch (err) {
1192
+ handleError(err);
1193
+ }
1194
+ });
889
1195
  cmd.command("cancel <id>").description("cancel a pending or running job").option("--profile <name>").option("--json").action(async (id, opts) => {
890
1196
  try {
891
1197
  const client = buildClient(opts.profile);
@@ -898,6 +1204,62 @@ function jobsCommand() {
898
1204
  });
899
1205
  return cmd;
900
1206
  }
1207
+ var MEDIA_TYPES = ["image", "video", "audio"];
1208
+ function mediaType(value) {
1209
+ if (value === void 0) return void 0;
1210
+ if (!MEDIA_TYPES.includes(value)) {
1211
+ throw new Error(`--type takes ${MEDIA_TYPES.join(", ")} (got "${value}")`);
1212
+ }
1213
+ return value;
1214
+ }
1215
+ function galleryCommand() {
1216
+ const cmd = new Command("gallery").description("the public gallery, and your favorites");
1217
+ cmd.command("browse").description("the public gallery, newest first \u2014 or one person's work with --user, or your favorites with --favorites").option("--type <type>", "image, video or audio").option("--user <id>", "only this person's work (your own id includes your private items)").option("--favorites", "only your own items that you favorited").option("--limit <n>", "page size (1-50)").option("--cursor <cursor>", "the previous page's nextCursor").option("--profile <name>").option("--json").action(async (opts) => {
1218
+ try {
1219
+ const type = mediaType(opts.type);
1220
+ if (opts.favorites && opts.user) throw new Error("--favorites lists your own favorites: drop --user");
1221
+ const client = buildClient(opts.profile);
1222
+ const userId = opts.favorites ? (await client.me()).id : opts.user;
1223
+ const page = await client.gallery.browse({
1224
+ type,
1225
+ userId,
1226
+ favoritesOnly: opts.favorites,
1227
+ limit: opts.limit ? Number(opts.limit) : void 0,
1228
+ cursor: opts.cursor
1229
+ });
1230
+ if (opts.json) {
1231
+ emit(page, opts);
1232
+ return;
1233
+ }
1234
+ table(
1235
+ page.data.map((item) => ({ id: item.id, type: item.type, url: item.outputUrl, created: item.createdAt })),
1236
+ ["id", "type", "url", "created"]
1237
+ );
1238
+ if (page.nextCursor) dim(`next: --cursor ${page.nextCursor}`);
1239
+ } catch (err) {
1240
+ handleError(err);
1241
+ }
1242
+ });
1243
+ cmd.command("favorite <jobId>").description("favorite a job (your own, or a public one) \u2014 or remove it from your favorites when it is one").option("--profile <name>").option("--json").action(async (jobId, opts) => {
1244
+ try {
1245
+ const result = await buildClient(opts.profile).gallery.toggleFavorite(jobId);
1246
+ if (opts.json) emit(result, opts);
1247
+ else success(result.favorited ? `favorited job ${jobId}` : `removed job ${jobId} from your favorites`);
1248
+ } catch (err) {
1249
+ handleError(err);
1250
+ }
1251
+ });
1252
+ cmd.command("favorites").description("your favorited job ids, newest first").option("--profile <name>").option("--json").action(async (opts) => {
1253
+ try {
1254
+ const ids = await buildClient(opts.profile).gallery.favorites();
1255
+ if (opts.json) emit(ids, opts);
1256
+ else for (const id of ids) info(id);
1257
+ } catch (err) {
1258
+ handleError(err);
1259
+ }
1260
+ });
1261
+ return cmd;
1262
+ }
901
1263
  function videoProCommand() {
902
1264
  const cmd = new Command("video-pro").description(
903
1265
  "stop / continue generate-video-pro runs (segmented long-video engine)"
@@ -1236,6 +1598,27 @@ Tip: \`nodaro apps get <slug>\` shows the input schema for that app.`).action(as
1236
1598
  });
1237
1599
  return cmd;
1238
1600
  }
1601
+ var BATCH_NODE_TYPE = "generate-image";
1602
+ function withBatchFlags(type, params, flags) {
1603
+ if (flags.count === void 0 && flags.models === void 0) return params;
1604
+ if (type !== BATCH_NODE_TYPE) {
1605
+ throw new Error(`--count / --models are ${BATCH_NODE_TYPE} options (several images in one call)`);
1606
+ }
1607
+ const out = { ...params };
1608
+ if (flags.count !== void 0) {
1609
+ const count = Number(flags.count);
1610
+ if (!/^\d+$/.test(flags.count.trim()) || count < 1) throw new Error(`--count must be a whole number of images, 1 or more (got "${flags.count}")`);
1611
+ out.count = count;
1612
+ }
1613
+ if (flags.models !== void 0) {
1614
+ out.models = flags.models.split(/[\s,]+/).filter(Boolean);
1615
+ }
1616
+ return out;
1617
+ }
1618
+ function batchOf(result) {
1619
+ const r = result;
1620
+ return r && Array.isArray(r.jobIds) && Array.isArray(r.groups) && typeof r.batchId === "string" ? r : null;
1621
+ }
1239
1622
  async function pickNodeInteractively(client) {
1240
1623
  if (!isInteractive()) {
1241
1624
  warn("missing <type> and stdin is not a TTY \u2014 provide a node type or pipe input");
@@ -1305,12 +1688,15 @@ function nodesCommand() {
1305
1688
  handleError(err);
1306
1689
  }
1307
1690
  });
1308
- cmd.command("run [type] [extras...]").description("run a single node directly \u2014 no workflow, no DAG. Inputs go through --param k=v (repeat) or --params-file body.json. Omit <type> for an interactive picker.").option("--param <pairs...>", `input value, repeat or space-separate; JSON arrays/objects supported (e.g. --param prompt="a leopard" --param 'targetPickers=["person"]')`, collectVariadic).option("--params-file <path>", "JSON file with the full input body (--param flags override matching keys)").option("--watch", "if the response includes a jobId, 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", `
1691
+ cmd.command("run [type] [extras...]").description("run a single node directly \u2014 no workflow, no DAG. Inputs go through --param k=v (repeat) or --params-file body.json. Omit <type> for an interactive picker.").option("--param <pairs...>", `input value, repeat or space-separate; JSON arrays/objects supported (e.g. --param prompt="a leopard" --param 'targetPickers=["person"]')`, collectVariadic).option("--params-file <path>", "JSON file with the full input body (--param flags override matching keys)").option("--watch", "if the response includes a jobId, poll until the job completes (every job of a batch)").option("--poll-interval <ms>", "watch poll interval in ms", (v) => parseInt(v, 10), 2e3).option("--count <n>", "generate-image: how many images (1-4), each its own job; with --models, per model").option("--models <ids>", "generate-image: run the same request on 2-4 models at once (comma-separated), instead of provider").option("--profile <name>").option("--json").addHelpText("after", `
1309
1692
  Examples:
1310
1693
  $ nodaro nodes run generate-image --param prompt="a snow leopard" --watch
1311
1694
  $ nodaro nodes run generate-image --param prompt="hi" --param provider=flux --param resolution=2K --watch
1695
+ $ nodaro nodes run generate-image --param prompt="a snow leopard" --count 4 --watch
1696
+ $ nodaro nodes run generate-image --param prompt="a snow leopard" --models gpt-image-2,flux-2-max --count 2 --watch
1312
1697
  $ echo '{"prompt":"hi","provider":"flux"}' > body.json
1313
1698
  $ nodaro nodes run generate-image --params-file body.json --watch
1699
+ $ nodaro nodes run generate-image --param presetId=generate-image/logo-wordmark --param presetVariables='{"BRAND":"Acme"}' --watch
1314
1700
  $ nodaro nodes run text-to-speech --param text="And so it begins." --param previousText="The night before, nobody slept." --param nextText="By noon the harbour was empty." --watch
1315
1701
  $ nodaro nodes run video-depth --param videoUrl=https://cdn.example/clip.mp4 --param colormap=turbo --watch
1316
1702
 
@@ -1329,13 +1715,31 @@ Tip: \`nodaro nodes get <type>\` shows the full input schema (required fields, p
1329
1715
  try {
1330
1716
  const client = buildClient(opts.profile);
1331
1717
  const resolvedType = type ?? await pickNodeInteractively(client);
1332
- const params = resolveParams(opts.param, opts.paramsFile);
1718
+ const params = withBatchFlags(resolvedType, resolveParams(opts.param, opts.paramsFile), opts);
1333
1719
  const result = await client.nodes.run(resolvedType, params);
1334
1720
  const jobId = typeof result === "object" && result && "jobId" in result ? result.jobId : null;
1335
1721
  if (opts.json && !opts.watch) {
1336
1722
  emit(result, opts);
1337
1723
  return;
1338
1724
  }
1725
+ const batch = batchOf(result);
1726
+ if (batch) {
1727
+ success(`${batch.jobIds.length} jobs queued (batch ${batch.batchId})${batch.deduped ? " \u2014 already created by an earlier request with this key" : ""}`);
1728
+ for (const group of batch.groups) {
1729
+ info(` ${group.model}: ${group.jobIds.join(", ")}${group.credits !== void 0 ? ` (${group.credits} credits)` : ""}`);
1730
+ }
1731
+ if (!opts.watch) {
1732
+ dim(`follow: nodaro jobs get <id> for each id above, or run with --watch`);
1733
+ return;
1734
+ }
1735
+ await watchJobsUntilTerminal({
1736
+ jobIds: batch.jobIds,
1737
+ fetchStatus: (id) => client.jobs.getStatus(id),
1738
+ intervalMs: opts.pollInterval,
1739
+ json: opts.json
1740
+ });
1741
+ return;
1742
+ }
1339
1743
  if (!jobId) {
1340
1744
  success(`${resolvedType} completed (inline)`);
1341
1745
  detail(result);
@@ -1364,7 +1768,7 @@ function charactersCommand() {
1364
1768
  const cmd = new Command("characters").description(
1365
1769
  "list, inspect, and manage characters; trigger portrait / asset / motion generation"
1366
1770
  );
1367
- cmd.command("list").description("list characters (active by default)").option("--project <projectId>", "filter to one project").option("--archived", "show archived characters instead of active ones").option("--limit <n>", "max characters to return (default 100, max 500)").option("--profile <name>").option("--json").action(
1771
+ cmd.command("list").description("list characters (active by default)").option("--project <projectId>", "filter to one project").option("--archived", "show archived characters instead of active ones").option("--search <words>", "only characters whose name or description contains every word (up to 5, any case)").addOption(new Option("--q <words>", "same as --search").conflicts("search")).option("--limit <n>", "max characters to return (default 100, max 500)").option("--profile <name>").option("--json").action(
1368
1772
  async (opts) => {
1369
1773
  try {
1370
1774
  const client = buildClient(opts.profile);
@@ -1375,6 +1779,7 @@ function charactersCommand() {
1375
1779
  const result = await client.characters.list({
1376
1780
  projectId: opts.project,
1377
1781
  archived: opts.archived,
1782
+ q: opts.search ?? opts.q,
1378
1783
  limit: limitNum
1379
1784
  });
1380
1785
  if (opts.json) {
@@ -1678,6 +2083,76 @@ function charactersCommand() {
1678
2083
  handleError(err);
1679
2084
  }
1680
2085
  });
2086
+ cmd.command("train <id>").description(
2087
+ "train a high-fidelity model of the character on its own images (Nodaro Cloud; paid, about 15 minutes)"
2088
+ ).option(
2089
+ "--image <url>",
2090
+ "train on this image only \u2014 repeat for each (at least 4); default: every eligible image",
2091
+ collectVariadic
2092
+ ).option("--watch", "poll the training's job until it completes").option("--poll-interval <ms>", "watch poll interval in ms", (v) => parseInt(v, 10), 1e4).option("--profile <name>").option("--json").action(
2093
+ async (id, opts) => {
2094
+ try {
2095
+ const client = buildClient(opts.profile);
2096
+ const result = await client.characters.train(
2097
+ id,
2098
+ opts.image?.length ? { selectedImageUrls: opts.image } : {}
2099
+ );
2100
+ if (opts.json && !opts.watch) {
2101
+ emit(result, opts);
2102
+ return;
2103
+ }
2104
+ success(`training started \u2014 job ${result.jobId} (trigger word ${result.triggerWord})`);
2105
+ if (!opts.watch) {
2106
+ dim(`follow: nodaro characters training ${id} --watch`);
2107
+ return;
2108
+ }
2109
+ await watchUntilTerminal({
2110
+ fetch: () => client.jobs.get(result.jobId),
2111
+ label: result.jobId,
2112
+ intervalMs: opts.pollInterval,
2113
+ json: opts.json
2114
+ });
2115
+ } catch (err) {
2116
+ handleError(err);
2117
+ }
2118
+ }
2119
+ );
2120
+ cmd.command("training <id>").description(
2121
+ "show where the character's training stands: untrained | queued | training | succeeded | failed | cancelled (Nodaro Cloud)"
2122
+ ).option("--watch", "poll until the training stops moving (exit 0 succeeded, 2 failed, 130 cancelled)").option("--poll-interval <ms>", "watch poll interval in ms", (v) => parseInt(v, 10), 1e4).option("--profile <name>").option("--json").action(async (id, opts) => {
2123
+ try {
2124
+ const client = buildClient(opts.profile);
2125
+ if (opts.watch) {
2126
+ await watchTraining({
2127
+ fetch: () => client.characters.trainingStatus(id),
2128
+ label: id,
2129
+ intervalMs: opts.pollInterval,
2130
+ json: opts.json
2131
+ });
2132
+ return;
2133
+ }
2134
+ const result = await client.characters.trainingStatus(id);
2135
+ if (opts.json) emit(result, opts);
2136
+ else detail(result);
2137
+ } catch (err) {
2138
+ handleError(err);
2139
+ }
2140
+ });
2141
+ cmd.command("delete-lora <id>").description(
2142
+ "remove the character's trained model: cancels a training in flight (refunded) and deletes the model \u2014 cannot be undone (Nodaro Cloud)"
2143
+ ).option("--profile <name>").option("--json").action(async (id, opts) => {
2144
+ try {
2145
+ const client = buildClient(opts.profile);
2146
+ await client.characters.deleteLora(id);
2147
+ if (opts.json) {
2148
+ emit({ ok: true }, opts);
2149
+ return;
2150
+ }
2151
+ success(`removed the trained model of character ${id}`);
2152
+ } catch (err) {
2153
+ handleError(err);
2154
+ }
2155
+ });
1681
2156
  return cmd;
1682
2157
  }
1683
2158
  function commonWizardFields(opts) {
@@ -3299,9 +3774,57 @@ Example:
3299
3774
  );
3300
3775
  return cmd;
3301
3776
  }
3777
+ function collect(value, previous = []) {
3778
+ return [...previous, value];
3779
+ }
3780
+ function readJsonFile(path) {
3781
+ let raw;
3782
+ try {
3783
+ raw = readFileSync(path === "-" ? 0 : path, "utf8");
3784
+ } catch (err) {
3785
+ throw new Error(`cannot read ${path}: ${err.message}`);
3786
+ }
3787
+ try {
3788
+ return JSON.parse(raw);
3789
+ } catch (err) {
3790
+ throw new Error(`${path} is not valid JSON: ${err.message}`);
3791
+ }
3792
+ }
3793
+ function presetData(opts) {
3794
+ if (opts.data !== void 0 && opts.dataFile !== void 0) throw new Error("pass --data or --data-file, not both");
3795
+ let value;
3796
+ if (opts.data !== void 0) {
3797
+ try {
3798
+ value = JSON.parse(opts.data);
3799
+ } catch (err) {
3800
+ throw new Error(`--data is not valid JSON: ${err.message}`);
3801
+ }
3802
+ } else if (opts.dataFile !== void 0) {
3803
+ value = readJsonFile(opts.dataFile);
3804
+ } else {
3805
+ return void 0;
3806
+ }
3807
+ if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error("the preset data must be a JSON object");
3808
+ return value;
3809
+ }
3810
+ function presetsToImport(value) {
3811
+ if (Array.isArray(value)) return value;
3812
+ return parseNodePresetExport(value).presets;
3813
+ }
3814
+ function intOption(raw, flag) {
3815
+ if (raw === void 0) return void 0;
3816
+ if (!/^-?\d+$/.test(raw.trim())) throw new Error(`${flag} must be a whole number`);
3817
+ return Number(raw);
3818
+ }
3819
+ function groupKind(raw) {
3820
+ if (raw === void 0) return void 0;
3821
+ if (raw !== "folder" && raw !== "section") throw new Error("--kind must be folder or section");
3822
+ return raw;
3823
+ }
3824
+ var plural = (n, word) => `${n} ${word}${n === 1 ? "" : "s"}`;
3302
3825
  function presetsCommand() {
3303
3826
  const cmd = new Command("presets").description(
3304
- "list saved node presets \u2014 your custom presets plus the built-in factory catalog"
3827
+ "node presets \u2014 your own (create, update, delete, import, favorites, folders) plus the built-in factory catalog"
3305
3828
  );
3306
3829
  cmd.command("list").description("list your custom presets (or the built-in factory catalog with --factory)").option("--node-type <type>", "filter to one node type, e.g. generate-image").option("--factory", "list the built-in factory catalog instead of your custom presets").option("--profile <name>").option("--json").action(async (opts) => {
3307
3830
  try {
@@ -3320,9 +3843,11 @@ function presetsCommand() {
3320
3843
  result.data.map((p) => ({
3321
3844
  id: p.id,
3322
3845
  name: p.name,
3323
- group: p.group ?? ""
3846
+ group: p.group ?? "",
3847
+ photos: p.minReferences ? p.minReferences : "",
3848
+ preview: p.previewUrl ? "yes" : ""
3324
3849
  })),
3325
- ["id", "name", "group"]
3850
+ ["id", "name", "group", "photos", "preview"]
3326
3851
  );
3327
3852
  return;
3328
3853
  }
@@ -3332,25 +3857,97 @@ function presetsCommand() {
3332
3857
  return;
3333
3858
  }
3334
3859
  table(
3335
- presets.map((p) => ({ id: p.id, nodeType: p.nodeType, name: p.name, updatedAt: p.updatedAt })),
3336
- ["id", "nodeType", "name", "updatedAt"]
3860
+ presets.map((p) => ({
3861
+ id: p.id,
3862
+ nodeType: p.nodeType,
3863
+ name: p.name,
3864
+ photos: p.minReferences ? p.minReferences : "",
3865
+ updatedAt: p.updatedAt
3866
+ })),
3867
+ ["id", "nodeType", "name", "photos", "updatedAt"]
3337
3868
  );
3338
3869
  } catch (err) {
3339
3870
  handleError(err);
3340
3871
  }
3341
3872
  });
3342
- cmd.command("groups").description("list your preset folders and sections").option("--node-type <type>", "filter to one node type").option("--profile <name>").option("--json").action(async (opts) => {
3873
+ cmd.command("create").description("save a preset: a node type, a name and its node config (data)").requiredOption("--node-type <type>", "the node type it configures, e.g. generate-image").requiredOption("--name <name>", "unique per node type").option("--data <json>", "the node config as a JSON object").option("--data-file <path>", "the node config from a JSON file (- for stdin)").option("--description <text>").option("--group <id>", "one of your preset folders").option("--tag <tag>", "a tag (repeatable)", collect).option("--preview-url <url>", "an example picture: an image already stored on this platform").option("--profile <name>").option("--json").action(
3874
+ async (opts) => {
3875
+ try {
3876
+ const data = presetData(opts);
3877
+ if (!data) throw new Error("pass the preset's node config with --data or --data-file");
3878
+ const preset = await buildClient(opts.profile).presets.create({
3879
+ nodeType: opts.nodeType,
3880
+ name: opts.name,
3881
+ data,
3882
+ ...opts.description !== void 0 ? { description: opts.description } : {},
3883
+ ...opts.group !== void 0 ? { groupId: opts.group } : {},
3884
+ ...opts.tag !== void 0 ? { tags: opts.tag } : {},
3885
+ ...opts.previewUrl !== void 0 ? { previewUrl: opts.previewUrl } : {}
3886
+ });
3887
+ if (opts.json) {
3888
+ emit(preset, opts);
3889
+ return;
3890
+ }
3891
+ success(`created preset ${preset.name} (${preset.id})`);
3892
+ } catch (err) {
3893
+ handleError(err);
3894
+ }
3895
+ }
3896
+ );
3897
+ cmd.command("update <id>").description("rename a preset, replace its config, move it, or set / remove its preview").option("--name <name>").option("--description <text>").option("--data <json>", "replace the node config with this JSON object").option("--data-file <path>", "replace the node config from a JSON file (- for stdin)").option("--group <id>", "move it into one of your preset folders").option("--no-group", "move it out of its folder").option("--tag <tag>", "replace the tags (repeatable)", collect).option("--preview-url <url>", "set the example picture: an image already stored on this platform").option("--no-preview-url", "remove the example picture").option("--expected-updated-at <iso>", "refuse if the preset changed since this updatedAt").option("--profile <name>").option("--json").action(
3898
+ async (id, opts) => {
3899
+ try {
3900
+ const data = presetData(opts);
3901
+ const patch = {
3902
+ ...opts.name !== void 0 ? { name: opts.name } : {},
3903
+ ...opts.description !== void 0 ? { description: opts.description } : {},
3904
+ ...data !== void 0 ? { data } : {},
3905
+ ...opts.group !== void 0 ? { groupId: opts.group === false ? null : opts.group } : {},
3906
+ ...opts.tag !== void 0 ? { tags: opts.tag } : {},
3907
+ ...opts.previewUrl !== void 0 ? { previewUrl: opts.previewUrl === false ? null : opts.previewUrl } : {}
3908
+ };
3909
+ if (Object.keys(patch).length === 0) {
3910
+ throw new Error("nothing to update \u2014 pass --name, --description, --data, --group, --tag or --preview-url");
3911
+ }
3912
+ const preset = await buildClient(opts.profile).presets.update(
3913
+ id,
3914
+ patch,
3915
+ opts.expectedUpdatedAt ? { expectedUpdatedAt: opts.expectedUpdatedAt } : {}
3916
+ );
3917
+ if (opts.json) {
3918
+ emit(preset, opts);
3919
+ return;
3920
+ }
3921
+ success(`updated preset ${preset.name} (${preset.id})`);
3922
+ } catch (err) {
3923
+ handleError(err);
3924
+ }
3925
+ }
3926
+ );
3927
+ cmd.command("delete <id>").description("delete one of your presets").option("--expected-updated-at <iso>", "refuse if the preset changed since this updatedAt").option("--profile <name>").option("--json").action(async (id, opts) => {
3343
3928
  try {
3344
- const client = buildClient(opts.profile);
3345
- const groups = await client.presets.listGroups(opts.nodeType);
3929
+ const result = await buildClient(opts.profile).presets.delete(
3930
+ id,
3931
+ opts.expectedUpdatedAt ? { expectedUpdatedAt: opts.expectedUpdatedAt } : {}
3932
+ );
3346
3933
  if (opts.json) {
3347
- emit(groups, opts);
3934
+ emit(result, opts);
3348
3935
  return;
3349
3936
  }
3350
- table(
3351
- groups.map((g) => ({ id: g.id, nodeType: g.nodeType, name: g.name, kind: g.kind })),
3352
- ["id", "nodeType", "name", "kind"]
3353
- );
3937
+ success(`deleted preset ${id}`);
3938
+ } catch (err) {
3939
+ handleError(err);
3940
+ }
3941
+ });
3942
+ cmd.command("import <file>").description("import presets from a file: what `presets export` writes, or a JSON list of presets (- for stdin)").option("--profile <name>").option("--json").action(async (path, opts) => {
3943
+ try {
3944
+ const presets = presetsToImport(readJsonFile(path));
3945
+ const result = await buildClient(opts.profile).presets.import(presets);
3946
+ if (opts.json) {
3947
+ emit(result, opts);
3948
+ return;
3949
+ }
3950
+ success(`imported ${plural(result.imported, "preset")}`);
3354
3951
  } catch (err) {
3355
3952
  handleError(err);
3356
3953
  }
@@ -3373,7 +3970,7 @@ function presetsCommand() {
3373
3970
  const json = JSON.stringify(envelope, null, 2);
3374
3971
  if (opts.output) {
3375
3972
  writeFileSync(opts.output, json);
3376
- success(`exported ${presets.length} preset${presets.length === 1 ? "" : "s"} to ${opts.output}`);
3973
+ success(`exported ${plural(presets.length, "preset")} to ${opts.output}`);
3377
3974
  } else {
3378
3975
  process.stdout.write(`${json}
3379
3976
  `);
@@ -3382,6 +3979,111 @@ function presetsCommand() {
3382
3979
  handleError(err);
3383
3980
  }
3384
3981
  });
3982
+ cmd.command("favorites").description("list your favorite preset ids for a node type, newest first").requiredOption("--node-type <type>", "e.g. generate-image").option("--profile <name>").option("--json").action(async (opts) => {
3983
+ try {
3984
+ const ids = await buildClient(opts.profile).presets.favorites(opts.nodeType);
3985
+ if (opts.json) {
3986
+ emit(ids, opts);
3987
+ return;
3988
+ }
3989
+ table(ids.map((presetId) => ({ presetId })), ["presetId"]);
3990
+ } catch (err) {
3991
+ handleError(err);
3992
+ }
3993
+ });
3994
+ cmd.command("favorite <presetId>").description("add a preset (a factory id such as generate-image/character-board, or one of yours) to your favorites").requiredOption("--node-type <type>", "e.g. generate-image").option("--profile <name>").option("--json").action(async (presetId, opts) => {
3995
+ try {
3996
+ const result = await buildClient(opts.profile).presets.addFavorite({ nodeType: opts.nodeType, presetId });
3997
+ if (opts.json) {
3998
+ emit(result, opts);
3999
+ return;
4000
+ }
4001
+ success(`added ${presetId} to your favorites`);
4002
+ } catch (err) {
4003
+ handleError(err);
4004
+ }
4005
+ });
4006
+ cmd.command("unfavorite <presetId>").description("remove a preset from your favorites").requiredOption("--node-type <type>", "e.g. generate-image").option("--profile <name>").option("--json").action(async (presetId, opts) => {
4007
+ try {
4008
+ const result = await buildClient(opts.profile).presets.removeFavorite({ nodeType: opts.nodeType, presetId });
4009
+ if (opts.json) {
4010
+ emit(result, opts);
4011
+ return;
4012
+ }
4013
+ success(`removed ${presetId} from your favorites`);
4014
+ } catch (err) {
4015
+ handleError(err);
4016
+ }
4017
+ });
4018
+ cmd.addCommand(groupsCommand());
4019
+ return cmd;
4020
+ }
4021
+ function groupsCommand() {
4022
+ const cmd = new Command("groups").description("your preset folders and sections: list (default), create, update, delete");
4023
+ cmd.command("list", { isDefault: true }).description("list your preset folders and sections").option("--node-type <type>", "filter to one node type").option("--profile <name>").option("--json").action(async (opts) => {
4024
+ try {
4025
+ const client = buildClient(opts.profile);
4026
+ const groups = await client.presets.listGroups(opts.nodeType);
4027
+ if (opts.json) {
4028
+ emit(groups, opts);
4029
+ return;
4030
+ }
4031
+ table(
4032
+ groups.map((g) => ({ id: g.id, nodeType: g.nodeType, name: g.name, kind: g.kind })),
4033
+ ["id", "nodeType", "name", "kind"]
4034
+ );
4035
+ } catch (err) {
4036
+ handleError(err);
4037
+ }
4038
+ });
4039
+ cmd.command("create").description("create a folder (collapsible) or a section (a flat header)").requiredOption("--node-type <type>", "e.g. generate-image").requiredOption("--name <name>").option("--kind <kind>", "folder (default) or section").option("--sort-order <n>", "its position").option("--profile <name>").option("--json").action(async (opts) => {
4040
+ try {
4041
+ const kind = groupKind(opts.kind);
4042
+ const sortOrder = intOption(opts.sortOrder, "--sort-order");
4043
+ const group = await buildClient(opts.profile).presets.createGroup({
4044
+ nodeType: opts.nodeType,
4045
+ name: opts.name,
4046
+ ...kind !== void 0 ? { kind } : {},
4047
+ ...sortOrder !== void 0 ? { sortOrder } : {}
4048
+ });
4049
+ if (opts.json) {
4050
+ emit(group, opts);
4051
+ return;
4052
+ }
4053
+ success(`created ${group.kind} ${group.name} (${group.id})`);
4054
+ } catch (err) {
4055
+ handleError(err);
4056
+ }
4057
+ });
4058
+ cmd.command("update <id>").description("rename or move a folder or section").option("--name <name>").option("--sort-order <n>", "its position").option("--profile <name>").option("--json").action(async (id, opts) => {
4059
+ try {
4060
+ const sortOrder = intOption(opts.sortOrder, "--sort-order");
4061
+ if (opts.name === void 0 && sortOrder === void 0) throw new Error("nothing to update \u2014 pass --name or --sort-order");
4062
+ const group = await buildClient(opts.profile).presets.updateGroup(id, {
4063
+ ...opts.name !== void 0 ? { name: opts.name } : {},
4064
+ ...sortOrder !== void 0 ? { sortOrder } : {}
4065
+ });
4066
+ if (opts.json) {
4067
+ emit(group, opts);
4068
+ return;
4069
+ }
4070
+ success(`updated ${group.kind} ${group.name} (${group.id})`);
4071
+ } catch (err) {
4072
+ handleError(err);
4073
+ }
4074
+ });
4075
+ cmd.command("delete <id>").description("delete a folder or section \u2014 its presets move out of it, none are deleted").option("--profile <name>").option("--json").action(async (id, opts) => {
4076
+ try {
4077
+ const result = await buildClient(opts.profile).presets.deleteGroup(id);
4078
+ if (opts.json) {
4079
+ emit(result, opts);
4080
+ return;
4081
+ }
4082
+ success(`deleted preset group ${id}`);
4083
+ } catch (err) {
4084
+ handleError(err);
4085
+ }
4086
+ });
3385
4087
  return cmd;
3386
4088
  }
3387
4089
  function postFromJson(value, index2 = 0) {
@@ -3644,90 +4346,269 @@ function collectionsCommand() {
3644
4346
  handleError(err);
3645
4347
  }
3646
4348
  }
3647
- );
3648
- cmd.command("mark-used <id> <recordId>").description("mark a record used (--not-used marks it not used again)").option("--not-used", "undo: the record is not used").option("--profile <name>").option("--json").action(async (id, recordId, opts) => {
4349
+ );
4350
+ cmd.command("mark-used <id> <recordId>").description("mark a record used (--not-used marks it not used again)").option("--not-used", "undo: the record is not used").option("--profile <name>").option("--json").action(async (id, recordId, opts) => {
4351
+ try {
4352
+ const client = buildClient(opts.profile);
4353
+ const record = await client.collections.setUsed(id, recordId, !opts.notUsed);
4354
+ if (opts.json) {
4355
+ emit(record, opts);
4356
+ return;
4357
+ }
4358
+ success(record.usedAt ? `used ${record.usedAt.slice(0, 16).replace("T", " ")}: ${collectionRecordHeadline(record)}` : `not used: ${collectionRecordHeadline(record)}`);
4359
+ } catch (err) {
4360
+ handleError(err);
4361
+ }
4362
+ });
4363
+ cmd.command("add <id>").description("save one record: give the fields, or --file with any JSON item (a post, a search result) to map").option("--title <text>").option("--text <text>").option("--url <link>", "an http(s) link; the default dedupe key").option("--file <path>", "an item as JSON (- reads stdin); a list with --index picks one").option("--index <n>", "which item of a list to save (default 0)").option("--dedupe-key <key>", "overrides the link as the dedupe key").option("--idempotency-key <key>", "the same key twice saves once").option("--profile <name>").option("--json").action(
4364
+ async (id, opts) => {
4365
+ try {
4366
+ const input2 = {
4367
+ title: opts.title,
4368
+ text: opts.text,
4369
+ url: opts.url,
4370
+ dedupeKey: opts.dedupeKey,
4371
+ ...opts.file ? { item: itemFromJson(readJson2(opts.file), opts.index ? Number(opts.index) : 0) } : {}
4372
+ };
4373
+ if (!opts.file && opts.title === void 0 && opts.text === void 0 && opts.url === void 0) {
4374
+ throw new Error("nothing to save: give --title, --text, --url or --file");
4375
+ }
4376
+ const client = buildClient(opts.profile);
4377
+ const result = await client.collections.addRecord(id, input2, { idempotencyKey: opts.idempotencyKey });
4378
+ if (opts.json) {
4379
+ emit(result, opts);
4380
+ return;
4381
+ }
4382
+ if (result.outcome === "inserted") {
4383
+ success(`saved ${result.record.id}${result.evicted > 0 ? ` (${result.evicted} oldest evicted past the cap)` : ""}`);
4384
+ } else if (result.outcome === "duplicate") {
4385
+ info(`already there as ${result.record.id} (same link or key, saved ${result.record.createdAt.slice(0, 10)})`);
4386
+ } else {
4387
+ info(`already saved by this same write: ${result.record.id}`);
4388
+ }
4389
+ } catch (err) {
4390
+ handleError(err);
4391
+ }
4392
+ }
4393
+ );
4394
+ cmd.command("remove <id> <recordId>").description("move one record to the collection's Trash (restore brings it back); --forever deletes a record already in the Trash for good").option("--forever", "delete for good \u2014 the record must already be in the Trash").option("--profile <name>").action(async (id, recordId, opts) => {
4395
+ try {
4396
+ const client = buildClient(opts.profile);
4397
+ if (opts.forever) {
4398
+ await client.collections.deleteRecordForever(id, recordId);
4399
+ success(`deleted ${recordId} for good`);
4400
+ return;
4401
+ }
4402
+ await client.collections.deleteRecord(id, recordId);
4403
+ success(`moved ${recordId} to the Trash`);
4404
+ } catch (err) {
4405
+ handleError(err);
4406
+ }
4407
+ });
4408
+ cmd.command("restore <id> <recordId>").description("bring one record back from the collection's Trash").option("--profile <name>").option("--json").action(async (id, recordId, opts) => {
4409
+ try {
4410
+ const client = buildClient(opts.profile);
4411
+ const record = await client.collections.restoreRecord(id, recordId);
4412
+ if (opts.json) {
4413
+ emit(record, opts);
4414
+ return;
4415
+ }
4416
+ success(`restored: ${collectionRecordHeadline(record)}`);
4417
+ } catch (err) {
4418
+ handleError(err);
4419
+ }
4420
+ });
4421
+ cmd.command("export <id>").description("the whole collection as CSV (default) or JSON, to stdout or a file").option("--format <format>", "csv or json (default csv)").option("--since <iso>", "only records saved at or after this time (ISO)").option("--until <iso>", "only records saved before this time (ISO)").option("--usage <which>", "all (default), unused (not used yet) or used").option("--q <words>", "words in the title, text or link").option("--out <path>", "write to this file instead of stdout").option("--profile <name>").action(async (id, opts) => {
4422
+ try {
4423
+ const format2 = parseFormat(opts.format);
4424
+ const usage = parseUsage(opts.usage);
4425
+ const client = buildClient(opts.profile);
4426
+ const body = await client.collections.export(id, { format: format2, since: opts.since, until: opts.until, usage, q: opts.q });
4427
+ if (opts.out) {
4428
+ writeFileSync(opts.out, body, "utf8");
4429
+ success(`wrote ${opts.out}`);
4430
+ return;
4431
+ }
4432
+ process.stdout.write(body);
4433
+ } catch (err) {
4434
+ handleError(err);
4435
+ }
4436
+ });
4437
+ return cmd;
4438
+ }
4439
+ function colorList(value) {
4440
+ return value.split(/[\s,]+/).filter(Boolean);
4441
+ }
4442
+ function palettesCommand() {
4443
+ const cmd = new Command("palettes").description(
4444
+ 'your colour palettes \u2014 use one on generate-image as direction.colorLook "palette:<id>"'
4445
+ );
4446
+ cmd.command("list").description("your palettes, newest first").option("--limit <n>", "page size (1-100)").option("--cursor <cursor>", "the previous page's nextCursor").option("--profile <name>").option("--json").action(async (opts) => {
4447
+ try {
4448
+ const page = await buildClient(opts.profile).palettes.list({
4449
+ limit: opts.limit ? Number(opts.limit) : void 0,
4450
+ cursor: opts.cursor
4451
+ });
4452
+ if (opts.json) {
4453
+ emit(page, opts);
4454
+ return;
4455
+ }
4456
+ table(
4457
+ page.data.map((p) => ({ id: p.id, name: p.name, colors: p.colors.join(" "), updatedAt: p.updatedAt })),
4458
+ ["id", "name", "colors", "updatedAt"]
4459
+ );
4460
+ if (page.nextCursor) dim(`next: --cursor ${page.nextCursor}`);
4461
+ } catch (err) {
4462
+ handleError(err);
4463
+ }
4464
+ });
4465
+ cmd.command("get <id>").description("show one palette").option("--profile <name>").option("--json").action(async (id, opts) => {
3649
4466
  try {
3650
- const client = buildClient(opts.profile);
3651
- const record = await client.collections.setUsed(id, recordId, !opts.notUsed);
4467
+ const palette = await buildClient(opts.profile).palettes.get(id);
4468
+ if (opts.json) emit(palette, opts);
4469
+ else detail(palette);
4470
+ } catch (err) {
4471
+ handleError(err);
4472
+ }
4473
+ });
4474
+ cmd.command("create").description("create a palette (2-12 #RRGGBB colours)").requiredOption("--name <name>", "1-80 characters").requiredOption("--colors <hex...>", 'colours, comma- or space-separated, e.g. "#0F4C5C,#E3B23C"').option("--description <text>", "your own note (not put into the prompt)").option("--profile <name>").option("--json").action(async (opts) => {
4475
+ try {
4476
+ const palette = await buildClient(opts.profile).palettes.create({
4477
+ name: opts.name,
4478
+ colors: [].concat(opts.colors).flatMap(colorList),
4479
+ ...opts.description !== void 0 ? { description: opts.description } : {}
4480
+ });
3652
4481
  if (opts.json) {
3653
- emit(record, opts);
4482
+ emit(palette, opts);
3654
4483
  return;
3655
4484
  }
3656
- success(record.usedAt ? `used ${record.usedAt.slice(0, 16).replace("T", " ")}: ${collectionRecordHeadline(record)}` : `not used: ${collectionRecordHeadline(record)}`);
4485
+ success(`created palette ${palette.id} \u2014 use it as direction.colorLook "palette:${palette.id}"`);
3657
4486
  } catch (err) {
3658
4487
  handleError(err);
3659
4488
  }
3660
4489
  });
3661
- cmd.command("add <id>").description("save one record: give the fields, or --file with any JSON item (a post, a search result) to map").option("--title <text>").option("--text <text>").option("--url <link>", "an http(s) link; the default dedupe key").option("--file <path>", "an item as JSON (- reads stdin); a list with --index picks one").option("--index <n>", "which item of a list to save (default 0)").option("--dedupe-key <key>", "overrides the link as the dedupe key").option("--idempotency-key <key>", "the same key twice saves once").option("--profile <name>").option("--json").action(
4490
+ cmd.command("update <id>").description("change a palette: only what you pass is written").option("--name <name>").option("--colors <hex...>", "replace the colours (2-12, comma- or space-separated)").option("--description <text>").option("--clear-description", "remove the note").option("--profile <name>").option("--json").action(
3662
4491
  async (id, opts) => {
3663
4492
  try {
3664
4493
  const input2 = {
3665
- title: opts.title,
3666
- text: opts.text,
3667
- url: opts.url,
3668
- dedupeKey: opts.dedupeKey,
3669
- ...opts.file ? { item: itemFromJson(readJson2(opts.file), opts.index ? Number(opts.index) : 0) } : {}
4494
+ ...opts.name !== void 0 ? { name: opts.name } : {},
4495
+ ...opts.colors !== void 0 ? { colors: [].concat(opts.colors).flatMap(colorList) } : {},
4496
+ ...opts.clearDescription ? { description: null } : opts.description !== void 0 ? { description: opts.description } : {}
3670
4497
  };
3671
- if (!opts.file && opts.title === void 0 && opts.text === void 0 && opts.url === void 0) {
3672
- throw new Error("nothing to save: give --title, --text, --url or --file");
4498
+ if (Object.keys(input2).length === 0) {
4499
+ throw new Error("nothing to update \u2014 provide --name, --colors, --description or --clear-description");
3673
4500
  }
3674
- const client = buildClient(opts.profile);
3675
- const result = await client.collections.addRecord(id, input2, { idempotencyKey: opts.idempotencyKey });
4501
+ const palette = await buildClient(opts.profile).palettes.update(id, input2);
3676
4502
  if (opts.json) {
3677
- emit(result, opts);
4503
+ emit(palette, opts);
3678
4504
  return;
3679
4505
  }
3680
- if (result.outcome === "inserted") {
3681
- success(`saved ${result.record.id}${result.evicted > 0 ? ` (${result.evicted} oldest evicted past the cap)` : ""}`);
3682
- } else if (result.outcome === "duplicate") {
3683
- info(`already there as ${result.record.id} (same link or key, saved ${result.record.createdAt.slice(0, 10)})`);
3684
- } else {
3685
- info(`already saved by this same write: ${result.record.id}`);
3686
- }
4506
+ success(`updated palette ${palette.id}`);
3687
4507
  } catch (err) {
3688
4508
  handleError(err);
3689
4509
  }
3690
4510
  }
3691
4511
  );
3692
- cmd.command("remove <id> <recordId>").description("move one record to the collection's Trash (restore brings it back); --forever deletes a record already in the Trash for good").option("--forever", "delete for good \u2014 the record must already be in the Trash").option("--profile <name>").action(async (id, recordId, opts) => {
4512
+ cmd.command("delete <id>").description("delete a palette (a run that still names it answers 404)").option("--profile <name>").option("--json").action(async (id, opts) => {
3693
4513
  try {
3694
- const client = buildClient(opts.profile);
3695
- if (opts.forever) {
3696
- await client.collections.deleteRecordForever(id, recordId);
3697
- success(`deleted ${recordId} for good`);
4514
+ await buildClient(opts.profile).palettes.delete(id);
4515
+ if (opts.json) {
4516
+ emit({ success: true, id }, opts);
3698
4517
  return;
3699
4518
  }
3700
- await client.collections.deleteRecord(id, recordId);
3701
- success(`moved ${recordId} to the Trash`);
4519
+ success(`deleted palette ${id}`);
3702
4520
  } catch (err) {
3703
4521
  handleError(err);
3704
4522
  }
3705
4523
  });
3706
- cmd.command("restore <id> <recordId>").description("bring one record back from the collection's Trash").option("--profile <name>").option("--json").action(async (id, recordId, opts) => {
4524
+ return cmd;
4525
+ }
4526
+ function imageOf(value) {
4527
+ const bar = value.indexOf("|");
4528
+ if (bar === -1) return { url: value.trim() };
4529
+ const url = value.slice(0, bar).trim();
4530
+ const caption = value.slice(bar + 1).trim();
4531
+ return caption ? { url, caption } : { url };
4532
+ }
4533
+ function moodboardsCommand() {
4534
+ const cmd = new Command("moodboards").description(
4535
+ 'your moodboards \u2014 use one on generate-image as direction.style "moodboard:<id>" (its description joins the prompt, its images go as style references)'
4536
+ );
4537
+ cmd.command("list").description("your moodboards, newest first").option("--limit <n>", "page size (1-100)").option("--cursor <cursor>", "the previous page's nextCursor").option("--profile <name>").option("--json").action(async (opts) => {
3707
4538
  try {
3708
- const client = buildClient(opts.profile);
3709
- const record = await client.collections.restoreRecord(id, recordId);
4539
+ const page = await buildClient(opts.profile).moodboards.list({
4540
+ limit: opts.limit ? Number(opts.limit) : void 0,
4541
+ cursor: opts.cursor
4542
+ });
3710
4543
  if (opts.json) {
3711
- emit(record, opts);
4544
+ emit(page, opts);
3712
4545
  return;
3713
4546
  }
3714
- success(`restored: ${collectionRecordHeadline(record)}`);
4547
+ table(
4548
+ page.data.map((m) => ({ id: m.id, name: m.name, images: m.images.length, updatedAt: m.updatedAt })),
4549
+ ["id", "name", "images", "updatedAt"]
4550
+ );
4551
+ if (page.nextCursor) dim(`next: --cursor ${page.nextCursor}`);
3715
4552
  } catch (err) {
3716
4553
  handleError(err);
3717
4554
  }
3718
4555
  });
3719
- cmd.command("export <id>").description("the whole collection as CSV (default) or JSON, to stdout or a file").option("--format <format>", "csv or json (default csv)").option("--since <iso>", "only records saved at or after this time (ISO)").option("--until <iso>", "only records saved before this time (ISO)").option("--usage <which>", "all (default), unused (not used yet) or used").option("--q <words>", "words in the title, text or link").option("--out <path>", "write to this file instead of stdout").option("--profile <name>").action(async (id, opts) => {
4556
+ cmd.command("get <id>").description("show one moodboard with its images").option("--profile <name>").option("--json").action(async (id, opts) => {
3720
4557
  try {
3721
- const format2 = parseFormat(opts.format);
3722
- const usage = parseUsage(opts.usage);
3723
- const client = buildClient(opts.profile);
3724
- const body = await client.collections.export(id, { format: format2, since: opts.since, until: opts.until, usage, q: opts.q });
3725
- if (opts.out) {
3726
- writeFileSync(opts.out, body, "utf8");
3727
- success(`wrote ${opts.out}`);
4558
+ const board = await buildClient(opts.profile).moodboards.get(id);
4559
+ if (opts.json) emit(board, opts);
4560
+ else detail(board);
4561
+ } catch (err) {
4562
+ handleError(err);
4563
+ }
4564
+ });
4565
+ cmd.command("create").description("create a moodboard (1-12 images)").requiredOption("--name <name>", "1-80 characters").option("--image <url[|caption]>", 'image link, repeat per image (1-12); add "|caption" to describe it', collectVariadic).option("--description <text>", "the words a run puts into the prompt (up to 1000 characters)").option("--profile <name>").option("--json").action(async (opts) => {
4566
+ try {
4567
+ if (!opts.image || opts.image.length === 0) throw new Error("a moodboard needs at least one --image");
4568
+ const board = await buildClient(opts.profile).moodboards.create({
4569
+ name: opts.name,
4570
+ ...opts.description !== void 0 ? { description: opts.description } : {},
4571
+ images: opts.image.map(imageOf)
4572
+ });
4573
+ if (opts.json) {
4574
+ emit(board, opts);
3728
4575
  return;
3729
4576
  }
3730
- process.stdout.write(body);
4577
+ success(`created moodboard ${board.id} \u2014 use it as direction.style "moodboard:${board.id}"`);
4578
+ } catch (err) {
4579
+ handleError(err);
4580
+ }
4581
+ });
4582
+ cmd.command("update <id>").description("change a moodboard: only what you pass is written; --image replaces every image").option("--name <name>").option("--description <text>").option("--clear-description", "remove the description").option("--image <url[|caption]>", "replace the images (repeat per image, 1-12)", collectVariadic).option("--profile <name>").option("--json").action(
4583
+ async (id, opts) => {
4584
+ try {
4585
+ const input2 = {
4586
+ ...opts.name !== void 0 ? { name: opts.name } : {},
4587
+ ...opts.clearDescription ? { description: null } : opts.description !== void 0 ? { description: opts.description } : {},
4588
+ ...opts.image && opts.image.length > 0 ? { images: opts.image.map(imageOf) } : {}
4589
+ };
4590
+ if (Object.keys(input2).length === 0) {
4591
+ throw new Error("nothing to update \u2014 provide --name, --description, --clear-description or --image");
4592
+ }
4593
+ const board = await buildClient(opts.profile).moodboards.update(id, input2);
4594
+ if (opts.json) {
4595
+ emit(board, opts);
4596
+ return;
4597
+ }
4598
+ success(`updated moodboard ${board.id}`);
4599
+ } catch (err) {
4600
+ handleError(err);
4601
+ }
4602
+ }
4603
+ );
4604
+ cmd.command("delete <id>").description("delete a moodboard (the images it links to are untouched)").option("--profile <name>").option("--json").action(async (id, opts) => {
4605
+ try {
4606
+ await buildClient(opts.profile).moodboards.delete(id);
4607
+ if (opts.json) {
4608
+ emit({ success: true, id }, opts);
4609
+ return;
4610
+ }
4611
+ success(`deleted moodboard ${id}`);
3731
4612
  } catch (err) {
3732
4613
  handleError(err);
3733
4614
  }
@@ -3817,8 +4698,8 @@ function outcomeLine(o) {
3817
4698
  function recordLines(record) {
3818
4699
  return record.filter((r) => r.shown).map((r) => `${FAMILY_LABEL[r.family]}: ${r.worked} of ${r.tried} worked for you (on average ${r.avgRatio}x your usual)`);
3819
4700
  }
3820
- function rows(list) {
3821
- return list.map((c) => ({
4701
+ function rows(list2) {
4702
+ return list2.map((c) => ({
3822
4703
  id: c.id,
3823
4704
  brand: c.isOwn ? `${c.brand} (yours)` : c.brand,
3824
4705
  searches: c.searches,
@@ -3831,9 +4712,9 @@ function competitorsCommand() {
3831
4712
  const cmd = new Command("competitors").description("brands you track (competitors or your own), their scans and action cards (Nodaro Cloud)");
3832
4713
  cmd.command("list").description("list tracked brands").option("--profile <name>").option("--json").action(async (opts) => {
3833
4714
  try {
3834
- const list = await buildClient(opts.profile).competitors.list();
3835
- if (opts.json) return emit(list, opts);
3836
- table(rows(list), ["id", "brand", "searches", "schedule", "lastScan", "note"]);
4715
+ const list2 = await buildClient(opts.profile).competitors.list();
4716
+ if (opts.json) return emit(list2, opts);
4717
+ table(rows(list2), ["id", "brand", "searches", "schedule", "lastScan", "note"]);
3837
4718
  } catch (err) {
3838
4719
  handleError(err);
3839
4720
  }
@@ -4462,7 +5343,7 @@ function catalogCommand() {
4462
5343
  }
4463
5344
  function modelsCommand() {
4464
5345
  const cmd = new Command("models").description(
4465
- "browse the model catalog \u2014 capability sheets, per-variant credit pricing, prompt tips"
5346
+ "browse the model catalog \u2014 makers, capability sheets, per-variant credit pricing, prompt tips"
4466
5347
  );
4467
5348
  cmd.command("list").description("list available models (grouped by kind and family)").option("--kind <kind>", "image | video | audio").option("--mode <mode>", 'operation filter, e.g. "t2v", "i2v", "t2i", "tts"').option("--family <name>", 'vendor / lab name, e.g. "Google", "Bytedance"').option("--featured", "featured models only").option("--profile <name>").option("--json").addHelpText(
4468
5349
  "after",
@@ -4490,6 +5371,9 @@ Examples:
4490
5371
  id: m.id,
4491
5372
  kind: section.kind,
4492
5373
  family: group.family,
5374
+ // The company behind the model (a family can name a lab or a
5375
+ // product line); an older server sends none.
5376
+ maker: m.maker?.name ?? "-",
4493
5377
  modes: m.modes.join(","),
4494
5378
  credits: (m.pricing ?? []).map((p) => p.credits).join("/") || "-",
4495
5379
  featured: m.featured ? "\u2605" : "",
@@ -4497,7 +5381,7 @@ Examples:
4497
5381
  }))
4498
5382
  )
4499
5383
  );
4500
- table(rows2, ["id", "kind", "family", "modes", "credits", "featured", "doctrine"]);
5384
+ table(rows2, ["id", "kind", "family", "maker", "modes", "credits", "featured", "doctrine"]);
4501
5385
  } catch (err) {
4502
5386
  handleError(err);
4503
5387
  }
@@ -4720,11 +5604,11 @@ function locationsCommand() {
4720
5604
  const cmd = new Command("locations").description(
4721
5605
  "list, inspect, and manage locations; trigger main-image / asset generation"
4722
5606
  );
4723
- cmd.command("list").description("list locations (active by default)").option("--archived", "show archived locations instead of active ones").option("--profile <name>").option("--json").action(
5607
+ cmd.command("list").description("list locations (active by default)").option("--archived", "show archived locations instead of active ones").option("--search <words>", "only locations whose name or description contains every word (up to 5, any case)").addOption(new Option("--q <words>", "same as --search").conflicts("search")).option("--profile <name>").option("--json").action(
4724
5608
  async (opts) => {
4725
5609
  try {
4726
5610
  const client = buildClient(opts.profile);
4727
- const result = await client.locations.list({ archived: opts.archived });
5611
+ const result = await client.locations.list({ archived: opts.archived, q: opts.search ?? opts.q });
4728
5612
  if (opts.json) {
4729
5613
  emit(result.locations, opts);
4730
5614
  return;
@@ -5058,13 +5942,14 @@ function objectsCommand() {
5058
5942
  const cmd = new Command("objects").description(
5059
5943
  "list, inspect, and manage objects; trigger main-image / asset generation"
5060
5944
  );
5061
- cmd.command("list").description("list objects (active by default)").option("--project <id>", "scope to a specific project").option("--archived", "show archived objects instead of active ones").option("--profile <name>").option("--json").action(
5945
+ cmd.command("list").description("list objects (active by default)").option("--project <id>", "scope to a specific project").option("--archived", "show archived objects instead of active ones").option("--search <words>", "only objects whose name or description contains every word (up to 5, any case)").addOption(new Option("--q <words>", "same as --search").conflicts("search")).option("--profile <name>").option("--json").action(
5062
5946
  async (opts) => {
5063
5947
  try {
5064
5948
  const client = buildClient(opts.profile);
5065
5949
  const result = await client.objects.list({
5066
5950
  archived: opts.archived,
5067
- projectId: opts.project
5951
+ projectId: opts.project,
5952
+ q: opts.search ?? opts.q
5068
5953
  });
5069
5954
  if (opts.json) {
5070
5955
  emit(result.objects, opts);
@@ -5835,7 +6720,7 @@ var CONTINUATION_NEXT_STEP = {
5835
6720
  continuation_superseded: (id) => ` \u2014 continue that one: nodaro edit continue-use-case ${id} --mode from-failed`,
5836
6721
  render_final_already_rendered: (id) => ` \u2014 its result is the one to use: nodaro jobs get ${id}`
5837
6722
  };
5838
- function readJsonFile(path) {
6723
+ function readJsonFile2(path) {
5839
6724
  let raw;
5840
6725
  try {
5841
6726
  raw = readFileSync(path, "utf8");
@@ -5898,7 +6783,7 @@ function editCommand() {
5898
6783
  async (opts) => {
5899
6784
  let sources;
5900
6785
  if (opts.sourcesFile) {
5901
- const parsed = readJsonFile(opts.sourcesFile);
6786
+ const parsed = readJsonFile2(opts.sourcesFile);
5902
6787
  if (!Array.isArray(parsed)) {
5903
6788
  warn(`--sources-file ${opts.sourcesFile} must contain a JSON array of { id, url } rows`);
5904
6789
  process.exit(1);
@@ -5944,9 +6829,9 @@ function editCommand() {
5944
6829
  try {
5945
6830
  const client = buildClient(opts.profile);
5946
6831
  const result = await client.edit.applyEdl({
5947
- edl: readJsonFile(opts.edl),
6832
+ edl: readJsonFile2(opts.edl),
5948
6833
  ...opts.source && opts.source.length > 0 ? { sources: opts.source } : {},
5949
- ...opts.transcript ? { transcript: readJsonFile(opts.transcript) } : {},
6834
+ ...opts.transcript ? { transcript: readJsonFile2(opts.transcript) } : {},
5950
6835
  output: opts.output,
5951
6836
  quality: opts.quality,
5952
6837
  ...opts.crossfadeMs !== void 0 ? { crossfadeMs: opts.crossfadeMs } : {},
@@ -6025,7 +6910,7 @@ function editCommand() {
6025
6910
  {
6026
6911
  jobId,
6027
6912
  mode: opts.mode,
6028
- ...opts.edit !== void 0 ? { editedEdl: readJsonFile(opts.edit) } : {}
6913
+ ...opts.edit !== void 0 ? { editedEdl: readJsonFile2(opts.edit) } : {}
6029
6914
  },
6030
6915
  opts.idempotencyKey ? { idempotencyKey: opts.idempotencyKey } : void 0
6031
6916
  );
@@ -6072,7 +6957,7 @@ function editCommand() {
6072
6957
  }
6073
6958
  let sources;
6074
6959
  if (opts.sourcesFile) {
6075
- const parsed = readJsonFile(opts.sourcesFile);
6960
+ const parsed = readJsonFile2(opts.sourcesFile);
6076
6961
  if (!Array.isArray(parsed)) {
6077
6962
  warn(`--sources-file ${opts.sourcesFile} must contain a JSON array of source rows`);
6078
6963
  process.exit(1);
@@ -6090,10 +6975,10 @@ function editCommand() {
6090
6975
  const input2 = {
6091
6976
  mode: opts.mode,
6092
6977
  planTier: opts.planTier,
6093
- transcript: readJsonFile(opts.transcript),
6978
+ transcript: readJsonFile2(opts.transcript),
6094
6979
  sources,
6095
- ...opts.silence ? { silence: readJsonFile(opts.silence) } : {},
6096
- ...opts.offsets ? { offsets: readJsonFile(opts.offsets) } : {},
6980
+ ...opts.silence ? { silence: readJsonFile2(opts.silence) } : {},
6981
+ ...opts.offsets ? { offsets: readJsonFile2(opts.offsets) } : {},
6097
6982
  ...opts.transcriptSource ? { transcriptSourceId: opts.transcriptSource } : {},
6098
6983
  ...opts.instructions !== void 0 ? { instructions: opts.instructions } : {},
6099
6984
  ...opts.styleGuide !== void 0 ? { styleGuide: opts.styleGuide } : {},
@@ -6119,10 +7004,10 @@ function editCommand() {
6119
7004
  try {
6120
7005
  const client = buildClient(opts.profile);
6121
7006
  const input2 = {
6122
- edl: readJsonFile(opts.edl),
6123
- transcript: readJsonFile(opts.transcript),
6124
- ...opts.speakerMap ? { speakerMap: readJsonFile(opts.speakerMap) } : {},
6125
- ...opts.speakerNames ? { speakerNames: readJsonFile(opts.speakerNames) } : {},
7007
+ edl: readJsonFile2(opts.edl),
7008
+ transcript: readJsonFile2(opts.transcript),
7009
+ ...opts.speakerMap ? { speakerMap: readJsonFile2(opts.speakerMap) } : {},
7010
+ ...opts.speakerNames ? { speakerNames: readJsonFile2(opts.speakerNames) } : {},
6126
7011
  ...opts.minShotMs !== void 0 ? { minShotMs: opts.minShotMs } : {},
6127
7012
  ...opts.leadMs !== void 0 ? { leadMs: opts.leadMs } : {},
6128
7013
  ...opts.maxShotMs !== void 0 ? { maxShotMs: opts.maxShotMs } : {},
@@ -6143,6 +7028,322 @@ function editCommand() {
6143
7028
  );
6144
7029
  return cmd;
6145
7030
  }
7031
+ var GIB = 1024 * 1024 * 1024;
7032
+ function money(m) {
7033
+ try {
7034
+ return new Intl.NumberFormat("en", { style: "currency", currency: m.currency }).format(m.amount);
7035
+ } catch {
7036
+ return `${m.amount} ${m.currency}`;
7037
+ }
7038
+ }
7039
+ function priceCell(plan, slot) {
7040
+ if (plan.prices === null) return "free";
7041
+ if (slot === "monthly") return plan.prices.monthly ? money(plan.prices.monthly) : "unavailable";
7042
+ const yearly = plan.prices.yearly;
7043
+ if (!yearly) return "unavailable";
7044
+ return yearly.perMonth === null ? money(yearly) : `${money(yearly)} (${money({ amount: yearly.perMonth, currency: yearly.currency })} a month)`;
7045
+ }
7046
+ function grant(credits) {
7047
+ return `${credits.amount.toLocaleString("en")} / ${credits.per}`;
7048
+ }
7049
+ function creditsCell(plan) {
7050
+ if (plan.signupCredits !== null) return `${plan.signupCredits.toLocaleString("en")} once`;
7051
+ const monthly = plan.prices?.monthly?.credits ?? null;
7052
+ const yearly = plan.prices?.yearly?.credits ?? null;
7053
+ if (monthly && yearly) {
7054
+ return monthly.amount === yearly.amount && monthly.per === yearly.per ? grant(monthly) : `${grant(monthly)} (yearly: ${grant(yearly)})`;
7055
+ }
7056
+ if (monthly) return grant(monthly);
7057
+ return yearly ? `yearly: ${grant(yearly)}` : "-";
7058
+ }
7059
+ function storageCell(bytes) {
7060
+ const gb = bytes / GIB;
7061
+ return `${Number.isInteger(gb) ? gb : gb.toFixed(1)} GB`;
7062
+ }
7063
+ function billingCommand() {
7064
+ const cmd = new Command("billing").description(
7065
+ "plans and prices, your subscription, and how this deployment bills (buying stays in the app)"
7066
+ );
7067
+ cmd.command("plans").description("the plans and credit packs on sale, with their prices (Nodaro Cloud; no sign-in needed)").option("--profile <name>", "ask this profile's instance (its token is not sent)").option("--base-url <url>", "ask this instance instead (default: the profile's, else https://app.nodaro.ai)").option("--json").addHelpText(
7068
+ "after",
7069
+ `
7070
+ Examples:
7071
+ $ nodaro billing plans
7072
+ $ nodaro billing plans --json`
7073
+ ).action(async (opts) => {
7074
+ try {
7075
+ const client = buildPublicClient({ profile: opts.profile, baseUrl: opts.baseUrl });
7076
+ const result = await client.billing.plans();
7077
+ if (opts.json) {
7078
+ emit(result, opts);
7079
+ return;
7080
+ }
7081
+ table(
7082
+ result.data.map((plan) => ({
7083
+ id: plan.id,
7084
+ name: plan.name,
7085
+ monthly: priceCell(plan, "monthly"),
7086
+ yearly: priceCell(plan, "yearly"),
7087
+ credits: creditsCell(plan),
7088
+ parallel: plan.parallelism,
7089
+ storage: storageCell(plan.storageBytes)
7090
+ })),
7091
+ ["id", "name", "monthly", "yearly", "credits", "parallel", "storage"]
7092
+ );
7093
+ info("");
7094
+ table(
7095
+ result.topUps.map((pack) => ({
7096
+ id: pack.id,
7097
+ credits: pack.credits.toLocaleString("en"),
7098
+ price: pack.price ? money(pack.price) : "unavailable"
7099
+ })),
7100
+ ["id", "credits", "price"]
7101
+ );
7102
+ const { min, max, currency } = result.topUpRange;
7103
+ dim(`Or load any whole amount from ${money({ amount: min, currency })} to ${money({ amount: max, currency })} in the app.`);
7104
+ } catch (err) {
7105
+ handleError(err);
7106
+ }
7107
+ });
7108
+ cmd.command("subscription").description("your subscription, and the plan your account's entitlements follow (Nodaro Cloud)").option("--profile <name>").option("--json").action(async (opts) => {
7109
+ try {
7110
+ const client = buildClient(opts.profile);
7111
+ const result = await client.billing.subscription();
7112
+ if (opts.json) {
7113
+ emit(result, opts);
7114
+ return;
7115
+ }
7116
+ if (!result.data) {
7117
+ info(`No subscription. Plan in force: ${result.effectiveTier}`);
7118
+ return;
7119
+ }
7120
+ detail(result);
7121
+ } catch (err) {
7122
+ handleError(err);
7123
+ }
7124
+ });
7125
+ cmd.command("account").description("your plan and balance as this deployment's billing provider reports them, in its unit").option("--profile <name>").option("--json").action(async (opts) => {
7126
+ try {
7127
+ const client = buildClient(opts.profile);
7128
+ const account = await client.billing.account();
7129
+ if (opts.json) {
7130
+ emit(account, opts);
7131
+ return;
7132
+ }
7133
+ if (account === null) {
7134
+ info("The billing provider could not answer right now; this is not a zero balance.");
7135
+ return;
7136
+ }
7137
+ detail(account);
7138
+ } catch (err) {
7139
+ handleError(err);
7140
+ }
7141
+ });
7142
+ cmd.command("surface").description("how this deployment bills: whether it meters usage, and the unit costs display in (no sign-in needed)").option("--profile <name>", "ask this profile's instance (its token is not sent)").option("--base-url <url>", "ask this instance instead (default: the profile's, else https://app.nodaro.ai)").option("--json").action(async (opts) => {
7143
+ try {
7144
+ const client = buildPublicClient({ profile: opts.profile, baseUrl: opts.baseUrl });
7145
+ const surface = await client.billing.surface();
7146
+ if (opts.json) {
7147
+ emit(surface, opts);
7148
+ return;
7149
+ }
7150
+ detail(surface);
7151
+ } catch (err) {
7152
+ handleError(err);
7153
+ }
7154
+ });
7155
+ return cmd;
7156
+ }
7157
+ var JOB_EVENTS = ["job.completed", "job.failed"];
7158
+ var DELIVERY_STATUSES = ["pending", "delivered", "failed"];
7159
+ function eventList(value) {
7160
+ if (value === void 0) return void 0;
7161
+ const events = value.split(/[\s,]+/).filter(Boolean);
7162
+ const unknown = events.filter((e) => !JOB_EVENTS.includes(e));
7163
+ if (unknown.length > 0) throw new Error(`unknown event ${unknown.join(", ")} \u2014 use ${JOB_EVENTS.join(" or ")}`);
7164
+ return events;
7165
+ }
7166
+ function printSecret(secret, what) {
7167
+ info("");
7168
+ info(`Signing secret (${what} \u2014 shown this once, store it now):`);
7169
+ info(` ${secret}`);
7170
+ info("");
7171
+ }
7172
+ function deliveryRow(d) {
7173
+ return {
7174
+ id: d.id,
7175
+ event: d.event,
7176
+ status: d.status,
7177
+ attempts: d.attempts,
7178
+ response: d.responseStatus ?? "",
7179
+ error: d.error ?? "",
7180
+ createdAt: d.createdAt
7181
+ };
7182
+ }
7183
+ var sleep2 = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
7184
+ function webhooksCommand() {
7185
+ const cmd = new Command("webhooks").description(
7186
+ "outbound webhooks: endpoints that receive your job.completed / job.failed, signed \u2014 create, rotate the secret, delivery log, test"
7187
+ );
7188
+ cmd.command("list").description("your webhook endpoints").option("--profile <name>").option("--json").action(async (opts) => {
7189
+ try {
7190
+ const client = buildClient(opts.profile);
7191
+ const result = await client.webhooks.list();
7192
+ if (opts.json) {
7193
+ emit(result.data, opts);
7194
+ return;
7195
+ }
7196
+ table(
7197
+ result.data.map((e) => ({
7198
+ id: e.id,
7199
+ url: e.url,
7200
+ events: e.events.join(","),
7201
+ active: e.isActive ? "yes" : e.disabledReason ? `no (${e.disabledReason})` : "no",
7202
+ app: e.appId ?? ""
7203
+ })),
7204
+ ["id", "url", "events", "active", "app"]
7205
+ );
7206
+ } catch (err) {
7207
+ handleError(err);
7208
+ }
7209
+ });
7210
+ cmd.command("get <id>").description("show one endpoint").option("--profile <name>").option("--json").action(async (id, opts) => {
7211
+ try {
7212
+ const client = buildClient(opts.profile);
7213
+ const result = await client.webhooks.get(id);
7214
+ if (opts.json) emit(result.data, opts);
7215
+ else detail(result.data);
7216
+ } catch (err) {
7217
+ handleError(err);
7218
+ }
7219
+ });
7220
+ cmd.command("create").description("register an https endpoint; prints its signing secret once").requiredOption("--url <url>", "https address on a public host").option("--events <events>", `comma-separated: ${JOB_EVENTS.join(",")} (default: both)`).option("--description <text>").option("--profile <name>").option("--json").action(async (opts) => {
7221
+ try {
7222
+ const events = eventList(opts.events);
7223
+ const client = buildClient(opts.profile);
7224
+ const result = await client.webhooks.create({ url: opts.url, events, description: opts.description });
7225
+ if (opts.json) {
7226
+ emit(result, opts);
7227
+ return;
7228
+ }
7229
+ success(`created webhook endpoint ${result.data.id}`);
7230
+ printSecret(result.secret, "new endpoint");
7231
+ } catch (err) {
7232
+ handleError(err);
7233
+ }
7234
+ });
7235
+ cmd.command("update <id>").description("change the address, events or description; switch on or off").option("--url <url>").option("--events <events>", `comma-separated: ${JOB_EVENTS.join(",")}`).option("--description <text>").option("--clear-description").option("--enable", "switch on (clears an automatic switch-off)").option("--disable", "switch off").option("--profile <name>").option("--json").action(
7236
+ async (id, opts) => {
7237
+ try {
7238
+ if (opts.enable && opts.disable) throw new Error("choose one of --enable or --disable");
7239
+ const events = eventList(opts.events);
7240
+ const isActive = opts.enable ? true : opts.disable ? false : void 0;
7241
+ const description = opts.clearDescription ? null : opts.description;
7242
+ if (opts.url === void 0 && events === void 0 && isActive === void 0 && description === void 0) {
7243
+ throw new Error("nothing to update \u2014 provide --url, --events, --description, --clear-description, --enable or --disable");
7244
+ }
7245
+ const client = buildClient(opts.profile);
7246
+ const result = await client.webhooks.update(id, { url: opts.url, events, isActive, description });
7247
+ if (opts.json) {
7248
+ emit(result.data, opts);
7249
+ return;
7250
+ }
7251
+ success(`updated webhook endpoint ${result.data.id}`);
7252
+ } catch (err) {
7253
+ handleError(err);
7254
+ }
7255
+ }
7256
+ );
7257
+ cmd.command("delete <id>").description("delete an endpoint and its delivery log").option("--profile <name>").option("--json").action(async (id, opts) => {
7258
+ try {
7259
+ const client = buildClient(opts.profile);
7260
+ await client.webhooks.delete(id);
7261
+ if (opts.json) {
7262
+ emit({ success: true, id }, opts);
7263
+ return;
7264
+ }
7265
+ success(`deleted webhook endpoint ${id}`);
7266
+ } catch (err) {
7267
+ handleError(err);
7268
+ }
7269
+ });
7270
+ cmd.command("rotate-secret <id>").description("replace the signing secret; the old one keeps signing beside it for a grace period (a day by default); prints the new one once").option("--grace <seconds>", "how long the old secret keeps signing (0 = stop it now; at most 604800)").option("--profile <name>").option("--json").action(async (id, opts) => {
7271
+ try {
7272
+ let input2 = {};
7273
+ if (opts.grace !== void 0) {
7274
+ const seconds = Number(opts.grace);
7275
+ if (!Number.isInteger(seconds) || seconds < 0 || seconds > 604800) {
7276
+ throw new Error(`--grace must be whole seconds from 0 to 604800, not ${opts.grace}`);
7277
+ }
7278
+ input2 = { gracePeriodSeconds: seconds };
7279
+ }
7280
+ const client = buildClient(opts.profile);
7281
+ const result = await client.webhooks.rotateSecret(id, input2);
7282
+ if (opts.json) {
7283
+ emit(result, opts);
7284
+ return;
7285
+ }
7286
+ success(`rotated the signing secret of ${id}`);
7287
+ printSecret(result.secret, "rotated");
7288
+ info(
7289
+ result.previousSecretExpiresAt ? `The old secret keeps signing too until ${result.previousSecretExpiresAt}: update your receiver before then.` : "The old secret no longer signs: update your receiver now."
7290
+ );
7291
+ } catch (err) {
7292
+ handleError(err);
7293
+ }
7294
+ });
7295
+ cmd.command("deliveries <id>").description("the endpoint's delivery log, newest first (kept 30 days)").option("--status <status>", DELIVERY_STATUSES.join("|")).option("--limit <n>", "page size (1-100)").option("--cursor <cursor>", "the previous page's next").option("--profile <name>").option("--json").action(async (id, opts) => {
7296
+ try {
7297
+ if (opts.status && !DELIVERY_STATUSES.includes(opts.status)) {
7298
+ throw new Error(`unknown status ${opts.status} \u2014 use ${DELIVERY_STATUSES.join(", ")}`);
7299
+ }
7300
+ const client = buildClient(opts.profile);
7301
+ const page = await client.webhooks.deliveries(id, {
7302
+ status: opts.status,
7303
+ limit: opts.limit ? Number(opts.limit) : void 0,
7304
+ cursor: opts.cursor
7305
+ });
7306
+ if (opts.json) {
7307
+ emit(page, opts);
7308
+ return;
7309
+ }
7310
+ table(page.data.map(deliveryRow), ["id", "event", "status", "attempts", "response", "error", "createdAt"]);
7311
+ if (page.next) dim(`next: --cursor ${page.next}`);
7312
+ } catch (err) {
7313
+ handleError(err);
7314
+ }
7315
+ });
7316
+ cmd.command("test <id>").description("send a ping to the endpoint (tried once); --wait shows how it answered").option("--wait", "wait for the result (up to 60 s)").option("--poll-interval <ms>", "how often to look (default 1000)").option("--profile <name>").option("--json").action(async (id, opts) => {
7317
+ try {
7318
+ const client = buildClient(opts.profile);
7319
+ const queued = await client.webhooks.test(id);
7320
+ if (!opts.wait) {
7321
+ if (opts.json) emit(queued.data, opts);
7322
+ else success(`queued ping ${queued.data.id} \u2014 follow it with: nodaro webhooks deliveries ${id}`);
7323
+ return;
7324
+ }
7325
+ const interval = Math.max(1, Number(opts.pollInterval ?? 1e3) || 1e3);
7326
+ const deadline = Date.now() + 6e4;
7327
+ let last = queued.data;
7328
+ for (; ; ) {
7329
+ last = (await client.webhooks.getDelivery(id, queued.data.id)).data;
7330
+ if (last.status !== "pending" || Date.now() > deadline) break;
7331
+ await sleep2(interval);
7332
+ }
7333
+ if (opts.json) {
7334
+ emit(last, opts);
7335
+ return;
7336
+ }
7337
+ if (last.status === "delivered") success(`ping delivered: ${last.responseStatus} in ${last.durationMs ?? "?"} ms`);
7338
+ else if (last.status === "failed") {
7339
+ warn(terminalSafe(`ping failed: ${last.error ?? "no answer"}${last.responseBody ? ` \u2014 ${last.responseBody}` : ""}`));
7340
+ } else warn(`ping still pending after 60 s \u2014 check: nodaro webhooks deliveries ${id}`);
7341
+ } catch (err) {
7342
+ handleError(err);
7343
+ }
7344
+ });
7345
+ return cmd;
7346
+ }
6146
7347
 
6147
7348
  // src/index.ts
6148
7349
  function readVersion() {
@@ -6158,10 +7359,12 @@ program.hook("preAction", () => {
6158
7359
  });
6159
7360
  program.addCommand(authCommand());
6160
7361
  program.addCommand(projectsCommand());
7362
+ program.addCommand(sessionsCommand());
6161
7363
  program.addCommand(workflowsCommand());
6162
7364
  program.addCommand(appsCommand());
6163
7365
  program.addCommand(nodesCommand());
6164
7366
  program.addCommand(jobsCommand());
7367
+ program.addCommand(galleryCommand());
6165
7368
  program.addCommand(videoProCommand());
6166
7369
  program.addCommand(executionsCommand());
6167
7370
  program.addCommand(charactersCommand());
@@ -6172,6 +7375,8 @@ program.addCommand(audioCommand());
6172
7375
  program.addCommand(presetsCommand());
6173
7376
  program.addCommand(savedPostsCommand());
6174
7377
  program.addCommand(collectionsCommand());
7378
+ program.addCommand(palettesCommand());
7379
+ program.addCommand(moodboardsCommand());
6175
7380
  program.addCommand(competitorsCommand());
6176
7381
  program.addCommand(communityCommand());
6177
7382
  program.addCommand(pickerCatalogsCommand());
@@ -6182,6 +7387,8 @@ program.addCommand(recastCommand());
6182
7387
  program.addCommand(orgCommand());
6183
7388
  program.addCommand(workspaceCommand());
6184
7389
  program.addCommand(editCommand());
7390
+ program.addCommand(billingCommand());
7391
+ program.addCommand(webhooksCommand());
6185
7392
  registerLocationsCommands(program);
6186
7393
  registerObjectsCommands(program);
6187
7394
  program.parseAsync().catch((err) => {