@nodaro/cli 1.9.0 → 1.12.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
@@ -29,7 +29,7 @@ var require_package = __commonJS({
29
29
  "package.json"(exports$1, module) {
30
30
  module.exports = {
31
31
  name: "@nodaro/cli",
32
- version: "1.9.0",
32
+ version: "1.12.0",
33
33
  description: "Command-line interface for Nodaro \u2014 list and run workflows, inspect jobs and executions, manage projects from the terminal.",
34
34
  type: "module",
35
35
  license: "Apache-2.0",
@@ -70,11 +70,11 @@ var require_package = __commonJS({
70
70
  "@inquirer/confirm": "^6.0.12",
71
71
  "@inquirer/input": "^5.0.12",
72
72
  "@inquirer/select": "^5.1.4",
73
- "@nodaro/sdk": "^1.17.0",
74
- "@nodaro/shared": "^2.6.0",
73
+ "@nodaro/sdk": "^1.20.0",
74
+ "@nodaro/shared": "^2.11.0",
75
75
  commander: "^12.1.0",
76
76
  picocolors: "^1.1.1",
77
- "@nodaro/prompts": "^1.7.1"
77
+ "@nodaro/prompts": "^1.8.0"
78
78
  },
79
79
  devDependencies: {
80
80
  tsup: "^8.5.0",
@@ -373,7 +373,32 @@ function maskToken(token) {
373
373
  if (token.length <= 12) return "****";
374
374
  return token.slice(0, 8) + "\u2026" + token.slice(-4);
375
375
  }
376
- var CLI_VERSION = "1.9.0" ;
376
+
377
+ // src/workspace.ts
378
+ var flagOverride;
379
+ function setWorkspaceFlag(workspaceId) {
380
+ flagOverride = workspaceId?.trim() || void 0;
381
+ }
382
+ function resolveWorkspace(profile) {
383
+ if (flagOverride) return { workspaceId: flagOverride, source: "flag" };
384
+ const env = process.env.NODARO_WORKSPACE?.trim();
385
+ if (env) return { workspaceId: env, source: "env" };
386
+ const saved = profile?.workspace?.trim();
387
+ if (saved) return { workspaceId: saved, source: "profile" };
388
+ return { workspaceId: void 0, source: "none" };
389
+ }
390
+ function saveWorkspace(profileName, workspaceId) {
391
+ const { name, profile } = getProfile(profileName);
392
+ if (!profile) throw new Error(`no credentials for profile "${name}" \u2014 run: nodaro auth login`);
393
+ const next = { ...profile };
394
+ if (workspaceId) next.workspace = workspaceId;
395
+ else delete next.workspace;
396
+ setProfile(name, next);
397
+ return name;
398
+ }
399
+
400
+ // src/client.ts
401
+ var CLI_VERSION = "1.12.0" ;
377
402
  function buildClient(profileName) {
378
403
  const { name, profile } = getProfile(profileName);
379
404
  if (!profile) {
@@ -381,9 +406,12 @@ function buildClient(profileName) {
381
406
  console.error(pc3.dim(` run: nodaro auth login${profileName ? ` --profile ${profileName}` : ""}`));
382
407
  process.exit(1);
383
408
  }
409
+ const { workspaceId } = resolveWorkspace(profile);
384
410
  return createClient({
385
411
  baseUrl: profile.baseUrl,
386
412
  auth: new StaticTokenAuth(profile.token),
413
+ // Scope, not access — see ./workspace.ts. Absent means the personal space.
414
+ ...workspaceId ? { workspaceId } : {},
387
415
  // Without this the CLI is indistinguishable from any other SDK consumer:
388
416
  // it IS an SDK consumer, so it would otherwise report `sdk/<sdk version>`
389
417
  // and every CLI-created job would be filed under the wrong surface.
@@ -716,6 +744,110 @@ function workflowsCommand() {
716
744
  handleError(err);
717
745
  }
718
746
  });
747
+ cmd.command("share <id>").description("set a workflow's visibility: workspace (everyone in its workspace) or private (creator + named collaborators)").option("--visibility <level>", "workspace | private", "workspace").option("--profile <name>").option("--json").action(async (id, opts) => {
748
+ try {
749
+ if (opts.visibility !== "workspace" && opts.visibility !== "private") {
750
+ throw new Error("--visibility must be `workspace` or `private`");
751
+ }
752
+ const client = buildClient(opts.profile);
753
+ const result = await client.workflows.setVisibility(id, opts.visibility);
754
+ if (opts.json) emit(result.data, opts);
755
+ else success(`workflow ${id} is now ${opts.visibility}`);
756
+ } catch (err) {
757
+ handleError(err);
758
+ }
759
+ });
760
+ cmd.command("move <id>").description("move a workflow to another project").requiredOption("--project <projectId>", "destination project id").option("--profile <name>").option("--json").action(async (id, opts) => {
761
+ try {
762
+ const client = buildClient(opts.profile);
763
+ const result = await client.workflows.move(id, { projectId: opts.project });
764
+ if (opts.json) {
765
+ emit(result, opts);
766
+ return;
767
+ }
768
+ success(`moved workflow ${id} \u2192 project ${opts.project}`);
769
+ if (result.droppedCollaborators.length > 0) {
770
+ dim(
771
+ `${result.droppedCollaborators.length} collaborator grant(s) were dropped \u2014 they came from the workspace this workflow just left`
772
+ );
773
+ }
774
+ } catch (err) {
775
+ handleError(err);
776
+ }
777
+ });
778
+ cmd.command("shared-with-me").description("list workflows other people shared with you").option("--profile <name>").option("--json").action(async (opts) => {
779
+ try {
780
+ const client = buildClient(opts.profile);
781
+ const result = await client.workflows.sharedWithMe();
782
+ if (opts.json) {
783
+ emit(result.data, opts);
784
+ return;
785
+ }
786
+ table(
787
+ result.data.map((w) => ({ id: w.id, name: w.name, role: w.grantedRole, updatedAt: w.updatedAt })),
788
+ ["id", "name", "role", "updatedAt"]
789
+ );
790
+ } catch (err) {
791
+ handleError(err);
792
+ }
793
+ });
794
+ cmd.addCommand(collaboratorsCommand());
795
+ return cmd;
796
+ }
797
+ function collaboratorsCommand() {
798
+ const cmd = new Command("collaborators").description("manage who a workflow is shared with");
799
+ cmd.command("list <id>").description("list a workflow's collaborators").option("--profile <name>").option("--json").action(async (id, opts) => {
800
+ try {
801
+ const client = buildClient(opts.profile);
802
+ const result = await client.workflows.collaborators.list(id);
803
+ if (opts.json) emit(result.data, opts);
804
+ else table(result.data.map((c) => ({ userId: c.userId, name: c.name ?? "", role: c.role })), ["userId", "name", "role"]);
805
+ } catch (err) {
806
+ handleError(err);
807
+ }
808
+ });
809
+ cmd.command("add <id>").description("share a workflow with a person by user id or email").option("--user <userId>", "the collaborator's user id").option("--email <email>", "the collaborator's email (any address; they need not have an account yet)").requiredOption("--role <role>", "viewer | editor").option("--profile <name>").option("--json").action(async (id, opts) => {
810
+ try {
811
+ if (opts.user === void 0 === (opts.email === void 0)) {
812
+ throw new Error("provide exactly one of --user or --email");
813
+ }
814
+ if (opts.role !== "viewer" && opts.role !== "editor") {
815
+ throw new Error("--role must be `viewer` or `editor`");
816
+ }
817
+ const client = buildClient(opts.profile);
818
+ const result = await client.workflows.collaborators.add(id, {
819
+ ...opts.user ? { userId: opts.user } : { email: opts.email },
820
+ role: opts.role
821
+ });
822
+ if (opts.json) emit(result.data, opts);
823
+ else success(`shared workflow ${id} with ${opts.user ?? opts.email} as ${opts.role}`);
824
+ } catch (err) {
825
+ handleError(err);
826
+ }
827
+ });
828
+ cmd.command("update <id> <userId>").description("change a collaborator's role").requiredOption("--role <role>", "viewer | editor").option("--profile <name>").option("--json").action(async (id, userId, opts) => {
829
+ try {
830
+ if (opts.role !== "viewer" && opts.role !== "editor") {
831
+ throw new Error("--role must be `viewer` or `editor`");
832
+ }
833
+ const client = buildClient(opts.profile);
834
+ const result = await client.workflows.collaborators.update(id, userId, { role: opts.role });
835
+ if (opts.json) emit(result.data, opts);
836
+ else success(`${userId} is now ${opts.role} on workflow ${id}`);
837
+ } catch (err) {
838
+ handleError(err);
839
+ }
840
+ });
841
+ cmd.command("remove <id> <userId>").description("remove a collaborator (or yourself)").option("--profile <name>").option("--json").action(async (id, userId, opts) => {
842
+ try {
843
+ const client = buildClient(opts.profile);
844
+ await client.workflows.collaborators.remove(id, userId);
845
+ if (opts.json) emit({ workflowId: id, userId, removed: true }, opts);
846
+ else success(`removed ${userId} from workflow ${id}`);
847
+ } catch (err) {
848
+ handleError(err);
849
+ }
850
+ });
719
851
  return cmd;
720
852
  }
721
853
  async function watchExecution(client, executionId, opts) {
@@ -837,10 +969,10 @@ function parseParamPairs(pairs) {
837
969
  if (eq < 0) {
838
970
  throw new Error(`invalid param "${raw}": expected key=value`);
839
971
  }
840
- const key = raw.slice(0, eq).trim();
972
+ const key2 = raw.slice(0, eq).trim();
841
973
  const value = raw.slice(eq + 1);
842
- if (!key) throw new Error(`invalid param "${raw}": empty key`);
843
- out[key] = coerce(value);
974
+ if (!key2) throw new Error(`invalid param "${raw}": empty key`);
975
+ out[key2] = coerce(value);
844
976
  }
845
977
  return out;
846
978
  }
@@ -2082,7 +2214,7 @@ function parseSection(raw) {
2082
2214
  }
2083
2215
  function mediaCommand() {
2084
2216
  const cmd = new Command("media").description(
2085
- "media ingestion + compositing \u2014 pull a social video into storage, trim video/audio, collage images, save a URL to storage, probe metadata"
2217
+ "media ingestion + compositing \u2014 pull a social video into storage, trim video/audio, still-to-video, slideshow, collage images, save a URL to storage, probe metadata"
2086
2218
  );
2087
2219
  cmd.command("download <url>").description("download a social video (YouTube / TikTok / Instagram / X / Facebook) into your storage").option("--max-height <px>", "cap the resolution (e.g. 720); omit for best available", (v) => parseInt(v, 10)).option("--section <a-b>", 'fetch ONLY this time range in seconds (e.g. "30-90"); the cut lands on keyframes, so pad and trim after').option("--watch", "stream the download's live progress until it completes").option("--profile <name>").option("--json").addHelpText("after", `
2088
2220
  Examples:
@@ -2179,6 +2311,66 @@ Examples:
2179
2311
  }
2180
2312
  }
2181
2313
  );
2314
+ cmd.command("still-to-video").description("one still image + one audio track -> MP4 (local FFmpeg, zero credits; length = the audio's length)").requiredOption("--image <url>", "still image URL").requiredOption("--audio <url>", "audio URL - sets the output length (no duration option by design)").option("--motion <preset>", "none|zoom-in|zoom-out|pan-left|pan-right|ken-burns", "none").option("--intensity <1-10>", "motion strength (ignored for none)", (v) => parseInt(v, 10)).option("--resolution <res>", "720p|1080p|4K", "1080p").option("--aspect-ratio <ratio>", "16:9|9:16|1:1|4:3", "16:9").option("--fps <fps>", "24|30", (v) => parseInt(v, 10)).option("--fit <mode>", "cover (crop to fill) | contain (letterbox)", "cover").option("--pad-color <hex>", "letterbox color when --fit contain (#RRGGBB)").option("--watch", "poll until the job completes").option("--poll-interval <ms>", "watch poll interval in ms", (v) => parseInt(v, 10), 2e3).option("--profile <name>").option("--json").addHelpText("after", `
2315
+ Examples:
2316
+ $ nodaro media still-to-video --image https://.../cover.png --audio https://.../track.mp3 --watch
2317
+ $ nodaro media still-to-video --image https://.../photo.png --audio https://.../vo.wav --motion ken-burns --intensity 4 --watch`).action(
2318
+ async (opts) => {
2319
+ try {
2320
+ const client = buildClient(opts.profile);
2321
+ const result = await client.media.stillToVideo({
2322
+ imageUrl: opts.image,
2323
+ audioUrl: opts.audio,
2324
+ ...opts.motion !== void 0 ? { motion: opts.motion } : {},
2325
+ ...opts.intensity !== void 0 ? { intensity: opts.intensity } : {},
2326
+ ...opts.resolution !== void 0 ? { resolution: opts.resolution } : {},
2327
+ ...opts.aspectRatio !== void 0 ? { aspectRatio: opts.aspectRatio } : {},
2328
+ ...opts.fps !== void 0 ? { fps: opts.fps } : {},
2329
+ ...opts.fit !== void 0 ? { fit: opts.fit } : {},
2330
+ ...opts.padColor !== void 0 ? { padColor: opts.padColor } : {}
2331
+ });
2332
+ await reportQueuedJob(result, () => client.jobs.get(result.jobId), { ...opts, note: "still to video" });
2333
+ } catch (err) {
2334
+ handleError(err);
2335
+ }
2336
+ }
2337
+ );
2338
+ cmd.command("slideshow").description("2-100 images + one optional audio track -> MP4 slideshow (local FFmpeg, zero credits)").requiredOption("--images <urls...>", "2-100 image URLs, in slide order").option("--audio <url>", "audio URL - wired, it sets the output length (never cropped)").option("--durations <secs>", 'comma-separated per-slide seconds; use "auto" for unpinned rows (e.g. "10,4,auto,auto")').option("--per-image <sec>", "seconds per slide when NO audio is wired (default 3)", parseFloat).option("--transition <id>", "xfade id or transition-picker id (cut, fade, dissolve, dip-to-black, ...); unknown -> cut", "cut").option("--transition-duration <sec>", "seconds (default 0.5)", parseFloat).option("--motion <preset>", "none|zoom-in|zoom-out|ken-burns|alternate", "none").option("--intensity <1-10>", "motion strength", (v) => parseInt(v, 10)).option("--resolution <res>", "720p|1080p|4K", "1080p").option("--aspect-ratio <ratio>", "16:9|9:16|1:1|4:3", "16:9").option("--fps <fps>", "24|30", (v) => parseInt(v, 10)).option("--fit <mode>", "cover|contain", "cover").option("--pad-color <hex>", "letterbox color when --fit contain (#RRGGBB)").option("--watch", "poll until the job completes").option("--poll-interval <ms>", "watch poll interval in ms", (v) => parseInt(v, 10), 2e3).option("--profile <name>").option("--json").addHelpText("after", `
2339
+ Examples:
2340
+ $ nodaro media slideshow --images https://.../a.png https://.../b.png https://.../c.png --audio https://.../track.mp3 --transition dissolve --watch
2341
+ $ nodaro media slideshow --images https://.../a.png https://.../b.png --per-image 2.5 --motion alternate --watch`).action(
2342
+ async (opts) => {
2343
+ try {
2344
+ if (opts.images.length < 2) {
2345
+ warn("Slideshow needs at least 2 images. For a single still, use: nodaro media still-to-video");
2346
+ process.exit(1);
2347
+ }
2348
+ const imageDurations = opts.durations ? opts.durations.split(",").map((d) => {
2349
+ const t = d.trim().toLowerCase();
2350
+ return t === "auto" || t === "" ? null : parseFloat(t);
2351
+ }) : void 0;
2352
+ const client = buildClient(opts.profile);
2353
+ const result = await client.media.slideshow({
2354
+ imageUrls: opts.images,
2355
+ ...opts.audio !== void 0 ? { audioUrl: opts.audio } : {},
2356
+ ...imageDurations !== void 0 ? { imageDurations } : {},
2357
+ ...opts.perImage !== void 0 ? { perImageDuration: opts.perImage } : {},
2358
+ ...opts.transition !== void 0 ? { transition: opts.transition } : {},
2359
+ ...opts.transitionDuration !== void 0 ? { transitionDuration: opts.transitionDuration } : {},
2360
+ ...opts.motion !== void 0 ? { motion: opts.motion } : {},
2361
+ ...opts.intensity !== void 0 ? { intensity: opts.intensity } : {},
2362
+ ...opts.resolution !== void 0 ? { resolution: opts.resolution } : {},
2363
+ ...opts.aspectRatio !== void 0 ? { aspectRatio: opts.aspectRatio } : {},
2364
+ ...opts.fps !== void 0 ? { fps: opts.fps } : {},
2365
+ ...opts.fit !== void 0 ? { fit: opts.fit } : {},
2366
+ ...opts.padColor !== void 0 ? { padColor: opts.padColor } : {}
2367
+ });
2368
+ await reportQueuedJob(result, () => client.jobs.get(result.jobId), { ...opts, note: "slideshow" });
2369
+ } catch (err) {
2370
+ handleError(err);
2371
+ }
2372
+ }
2373
+ );
2182
2374
  cmd.command("trim-audio").description("trim (and extract) audio from a video or audio source").option("--video <url>", "video URL to extract + trim audio from").option("--audio <url>", "audio URL to trim").option("--start <sec>", "range start in seconds", parseFloat).option("--end <sec>", "range end in seconds", parseFloat).option("--format <fmt>", "output format: mp3 (default), wav, or aac").option("--watch", "poll until the job completes").option("--poll-interval <ms>", "watch poll interval in ms", (v) => parseInt(v, 10), 2e3).option("--profile <name>").option("--json").addHelpText("after", `
2183
2375
  Example:
2184
2376
  $ nodaro media trim-audio --video https://.../clip.mp4 --start 0 --end 30 --format wav --watch`).action(
@@ -2777,7 +2969,7 @@ Examples:
2777
2969
  }
2778
2970
  }
2779
2971
  );
2780
- cmd.command("get <nodeType>").description("show one picker's catalog of valid values").option("--full", "include description + the prompt fragment each id injects").option("--category <name>", "single-dim pickers: filter to one category").option("--field <name>", "multi-dim pickers (person/styling/framing): only this dimension").option("--profile <name>").option("--json").addHelpText(
2972
+ cmd.command("get <nodeType>").description("show one picker's catalog of valid values").option("--full", "add description + the prompt fragment each id injects (compact already carries each id's `term`)").option("--category <name>", "single-dim pickers: filter to one category").option("--field <name>", "multi-dim pickers (person/styling/framing): only this dimension").option("--profile <name>").option("--json").addHelpText(
2781
2973
  "after",
2782
2974
  `
2783
2975
  Examples:
@@ -2803,6 +2995,105 @@ Examples:
2803
2995
  );
2804
2996
  return cmd;
2805
2997
  }
2998
+
2999
+ // src/lib/catalog-snapshot.ts
3000
+ function buildCatalogSnapshot(projected, sidecars) {
3001
+ const seen = /* @__PURE__ */ new Map();
3002
+ const push = (opts) => {
3003
+ for (const o of opts ?? []) if (!seen.has(o.id)) seen.set(o.id, o);
3004
+ };
3005
+ if (projected.kind === "single") push(projected.options);
3006
+ else for (const d of projected.dimensions ?? []) push(d.options);
3007
+ const entries = [...seen.values()].sort((a, b) => a.id.localeCompare(b.id));
3008
+ return { catalogId: projected.catalogId, kind: projected.kind, entries, sidecars };
3009
+ }
3010
+
3011
+ // src/lib/catalog-diff.ts
3012
+ var key = (e) => JSON.stringify({ l: e.label, d: e.description, c: e.category, p: e.promptHint, t: e.term });
3013
+ var index = (s) => new Map(s.entries.map((e) => [e.id, e]));
3014
+ function threeWayMergeCatalog(baseline, upstreamNow, pack) {
3015
+ const B = index(baseline), U = index(upstreamNow), P = index(pack);
3016
+ const carried = [];
3017
+ const conflicts = [];
3018
+ const newUpstream = [];
3019
+ const removedUpstream = [];
3020
+ const sidecarsCarried = {};
3021
+ for (const [id, u] of U) {
3022
+ const b = B.get(id), p = P.get(id);
3023
+ if (!b) {
3024
+ newUpstream.push(u);
3025
+ continue;
3026
+ }
3027
+ if (!p) continue;
3028
+ const saiModified = key(p) !== key(b);
3029
+ const upstreamChanged = key(u) !== key(b);
3030
+ if (!upstreamChanged) continue;
3031
+ if (saiModified) {
3032
+ conflicts.push({ id, upstream: u, pack: p });
3033
+ continue;
3034
+ }
3035
+ carried.push(u);
3036
+ for (const [locale, map] of Object.entries(upstreamNow.sidecars)) {
3037
+ if (map[id]) (sidecarsCarried[locale] ??= []).push(id);
3038
+ }
3039
+ }
3040
+ for (const [id] of B) if (!U.has(id) && P.has(id)) removedUpstream.push(id);
3041
+ return { carried, conflicts, newUpstream, removedUpstream, sidecarsCarried, nextBaseline: upstreamNow };
3042
+ }
3043
+
3044
+ // src/lib/catalog-validate.ts
3045
+ function validatePackSidecars(snapshot, locales, exemptLocales) {
3046
+ const exempt = new Set(exemptLocales);
3047
+ const missing = [];
3048
+ const exempted = [];
3049
+ for (const locale of locales) {
3050
+ if (exempt.has(locale)) {
3051
+ exempted.push(locale);
3052
+ continue;
3053
+ }
3054
+ const map = snapshot.sidecars[locale] ?? {};
3055
+ for (const e of snapshot.entries) if (!map[e.id]) missing.push({ id: e.id, locale });
3056
+ }
3057
+ return { catalogId: snapshot.catalogId, missing, exempted, ok: missing.length === 0 };
3058
+ }
3059
+
3060
+ // src/commands/catalog.ts
3061
+ var LOCALES = ["es", "fr", "de", "pt-BR", "ru", "hi", "ja", "ko", "zh-CN", "he", "ar"];
3062
+ var read = (p) => JSON.parse(readFileSync(p, "utf8"));
3063
+ function catalogCommand() {
3064
+ const cmd = new Command("catalog").description(
3065
+ "vendored-pack maintenance: snapshot, diff against upstream, validate sidecars (offline, file-based)"
3066
+ );
3067
+ cmd.command("snapshot").description(
3068
+ "build a catalog snapshot (the diff-upstream/validate input shape) from a detail=full /v1/catalogs projection + its sidecars"
3069
+ ).requiredOption(
3070
+ "--in <file>",
3071
+ 'JSON { "projected": <detail=full /v1/catalogs catalog>, "sidecars"?: <locale -> id -> {label?,description?}> }'
3072
+ ).action((o) => {
3073
+ const input2 = JSON.parse(readFileSync(o.in, "utf8"));
3074
+ const snapshot = buildCatalogSnapshot(input2.projected, input2.sidecars ?? {});
3075
+ process.stdout.write(JSON.stringify(snapshot, null, 2) + "\n");
3076
+ });
3077
+ cmd.command("diff-upstream").description(
3078
+ "three-way merge: carry upstream edits for entries you left unmodified; never auto-admit new upstream entries"
3079
+ ).requiredOption("--baseline <file>", "upstream snapshot at vendoring time").requiredOption("--upstream <file>", "current upstream snapshot").requiredOption("--pack <file>", "your vendored pack snapshot").option("--write <file>", "write the merge plan + next baseline to this path").action((o) => {
3080
+ const plan = threeWayMergeCatalog(read(o.baseline), read(o.upstream), read(o.pack));
3081
+ const out = JSON.stringify(plan, null, 2);
3082
+ if (o.write) writeFileSync(o.write, out);
3083
+ else process.stdout.write(out + "\n");
3084
+ if (plan.conflicts.length) process.exitCode = 2;
3085
+ });
3086
+ cmd.command("validate").description("check a pack snapshot has sidecar coverage across 11 locales (or declared exemptions)").requiredOption("--pack <file>", "your vendored pack snapshot").option("--exempt <locales>", "comma-separated locales exempted from translation", "").action((o) => {
3087
+ const r = validatePackSidecars(
3088
+ read(o.pack),
3089
+ LOCALES,
3090
+ o.exempt.split(",").map((s) => s.trim()).filter(Boolean)
3091
+ );
3092
+ process.stdout.write(JSON.stringify(r, null, 2) + "\n");
3093
+ if (!r.ok) process.exitCode = 1;
3094
+ });
3095
+ return cmd;
3096
+ }
2806
3097
  function modelsCommand() {
2807
3098
  const cmd = new Command("models").description(
2808
3099
  "browse the model catalog \u2014 capability sheets, per-variant credit pricing, prompt tips"
@@ -3727,6 +4018,316 @@ function objectsCommand() {
3727
4018
  function registerObjectsCommands(program2) {
3728
4019
  program2.addCommand(objectsCommand());
3729
4020
  }
4021
+ function orgCommand() {
4022
+ const cmd = new Command("org").description("organizations, their members, and invitations");
4023
+ cmd.command("list").description("the organizations this account belongs to").option("--profile <name>").option("--json").action(async (opts) => {
4024
+ try {
4025
+ const client = buildClient(opts.profile);
4026
+ const { data } = await client.organizations.list();
4027
+ if (opts.json) {
4028
+ emit(data, opts);
4029
+ return;
4030
+ }
4031
+ if (data.length === 0) {
4032
+ info("this account belongs to no organizations");
4033
+ return;
4034
+ }
4035
+ table(
4036
+ data.map((o) => ({ id: o.id, name: o.name, kind: o.kind, status: o.status, role: o.role ?? "" })),
4037
+ ["id", "name", "kind", "status", "role"]
4038
+ );
4039
+ } catch (err) {
4040
+ handleError(err);
4041
+ }
4042
+ });
4043
+ cmd.command("get <id>").description("show one organization").option("--profile <name>").option("--json").action(async (id, opts) => {
4044
+ try {
4045
+ const client = buildClient(opts.profile);
4046
+ const { data } = await client.organizations.get(id);
4047
+ if (opts.json) emit(data, opts);
4048
+ else detail(data);
4049
+ } catch (err) {
4050
+ handleError(err);
4051
+ }
4052
+ });
4053
+ cmd.command("create").description("create an organization").requiredOption("--name <name>", "organization name").requiredOption("--kind <kind>", "school or team").option("--slug <slug>", "url slug (derived from the name when omitted)").option("--accept-terms", "accept the terms, where the instance requires it").option("--profile <name>").option("--json").action(async (opts) => {
4054
+ try {
4055
+ if (opts.kind !== "school" && opts.kind !== "team") {
4056
+ throw new Error("--kind must be school or team");
4057
+ }
4058
+ const client = buildClient(opts.profile);
4059
+ const { data } = await client.organizations.create({
4060
+ name: opts.name,
4061
+ kind: opts.kind,
4062
+ ...opts.slug ? { slug: opts.slug } : {},
4063
+ ...opts.acceptTerms ? { acceptTerms: true } : {}
4064
+ });
4065
+ if (opts.json) {
4066
+ emit(data, opts);
4067
+ return;
4068
+ }
4069
+ success(`created ${data.name} (${data.id})`);
4070
+ if (data.status === "pending") {
4071
+ warn("status is pending \u2014 it grants nothing until a platform admin approves it");
4072
+ }
4073
+ } catch (err) {
4074
+ handleError(err);
4075
+ }
4076
+ });
4077
+ cmd.command("members <orgId>").description("who is in an organization").option("--limit <n>", "page size", (v) => Number(v)).option("--cursor <cursor>", "continue a previous page").option("--profile <name>").option("--json").action(async (orgId, opts) => {
4078
+ try {
4079
+ const client = buildClient(opts.profile);
4080
+ const page = await client.organizations.listMembers(orgId, { limit: opts.limit, cursor: opts.cursor });
4081
+ if (opts.json) {
4082
+ emit(page, opts);
4083
+ return;
4084
+ }
4085
+ table(
4086
+ page.data.map((m) => ({
4087
+ userId: m.userId,
4088
+ name: m.displayName ?? "",
4089
+ email: m.email ?? "",
4090
+ role: m.role,
4091
+ status: m.status
4092
+ })),
4093
+ ["userId", "name", "email", "role", "status"]
4094
+ );
4095
+ if (page.nextCursor) dim(`more: --cursor ${page.nextCursor}`);
4096
+ } catch (err) {
4097
+ handleError(err);
4098
+ }
4099
+ });
4100
+ cmd.command("invite <orgId>").description("invite people by email (repeat --email, or pass a comma-separated list)").option("--email <email...>", "one or more addresses").option("--role <role>", "org role: admin or member", "member").option("--workspace <id>", "also place them in this workspace on accept").option("--workspace-role <role>", "workspace role: admin or member").option("--profile <name>").option("--json").action(
4101
+ async (orgId, opts) => {
4102
+ try {
4103
+ const emails = (opts.email ?? []).flatMap((e) => e.split(",")).map((e) => e.trim()).filter(Boolean);
4104
+ if (emails.length === 0) throw new Error("no addresses \u2014 pass --email at least once");
4105
+ if (opts.role !== "admin" && opts.role !== "member") {
4106
+ throw new Error("--role must be admin or member");
4107
+ }
4108
+ if (opts.workspaceRole && opts.workspaceRole !== "admin" && opts.workspaceRole !== "member") {
4109
+ throw new Error("--workspace-role must be admin or member");
4110
+ }
4111
+ const client = buildClient(opts.profile);
4112
+ const { data } = await client.organizations.invite(orgId, {
4113
+ emails,
4114
+ orgRole: opts.role,
4115
+ ...opts.workspace ? { workspaceId: opts.workspace } : {},
4116
+ ...opts.workspaceRole ? { workspaceRole: opts.workspaceRole } : {}
4117
+ });
4118
+ if (opts.json) {
4119
+ emit(data, opts);
4120
+ return;
4121
+ }
4122
+ for (const row of data) {
4123
+ if (row.status === "sent") success(`${row.email} \u2014 emailed`);
4124
+ else if (row.link) {
4125
+ warn(`${row.email} \u2014 not emailed (${row.status}); send this link yourself:`);
4126
+ info(` ${row.link}`);
4127
+ } else {
4128
+ warn(`${row.email} \u2014 ${row.status}, and no link was returned`);
4129
+ }
4130
+ }
4131
+ } catch (err) {
4132
+ handleError(err);
4133
+ }
4134
+ }
4135
+ );
4136
+ cmd.command("invitations <orgId>").description("outstanding invitations").option("--status <status>", "open, accepted, revoked or expired").option("--limit <n>", "page size", (v) => Number(v)).option("--cursor <cursor>", "continue a previous page").option("--profile <name>").option("--json").action(async (orgId, opts) => {
4137
+ try {
4138
+ const client = buildClient(opts.profile);
4139
+ const page = await client.organizations.listInvitations(orgId, {
4140
+ ...opts.status ? { status: opts.status } : {},
4141
+ limit: opts.limit,
4142
+ cursor: opts.cursor
4143
+ });
4144
+ if (opts.json) {
4145
+ emit(page, opts);
4146
+ return;
4147
+ }
4148
+ table(
4149
+ page.data.map((i) => ({
4150
+ id: i.id,
4151
+ email: i.email,
4152
+ role: i.orgRole,
4153
+ state: i.state,
4154
+ expiresAt: i.expiresAt
4155
+ })),
4156
+ ["id", "email", "role", "state", "expiresAt"]
4157
+ );
4158
+ if (page.nextCursor) dim(`more: --cursor ${page.nextCursor}`);
4159
+ } catch (err) {
4160
+ handleError(err);
4161
+ }
4162
+ });
4163
+ cmd.command("revoke <invitationId>").description("revoke an invitation").option("--profile <name>").option("--json").action(async (id, opts) => {
4164
+ try {
4165
+ const client = buildClient(opts.profile);
4166
+ const { data } = await client.organizations.revokeInvitation(id);
4167
+ if (opts.json) emit(data, opts);
4168
+ else success(`revoked invitation ${id}`);
4169
+ } catch (err) {
4170
+ handleError(err);
4171
+ }
4172
+ });
4173
+ cmd.command("audit <orgId>").description("what happened in an organization, newest first").option("--limit <n>", "page size", (v) => Number(v)).option("--cursor <cursor>", "continue a previous page").option("--profile <name>").option("--json").action(async (orgId, opts) => {
4174
+ try {
4175
+ const client = buildClient(opts.profile);
4176
+ const page = await client.organizations.audit(orgId, { limit: opts.limit, cursor: opts.cursor });
4177
+ if (opts.json) {
4178
+ emit(page, opts);
4179
+ return;
4180
+ }
4181
+ table(
4182
+ page.data.map((e) => ({
4183
+ at: e.createdAt,
4184
+ action: e.action,
4185
+ actor: e.actor?.displayName ?? e.actor?.email ?? e.actor?.userId ?? "system",
4186
+ target: e.targetId ?? ""
4187
+ })),
4188
+ ["at", "action", "actor", "target"]
4189
+ );
4190
+ if (page.nextCursor) dim(`more: --cursor ${page.nextCursor}`);
4191
+ } catch (err) {
4192
+ handleError(err);
4193
+ }
4194
+ });
4195
+ return cmd;
4196
+ }
4197
+ function workspaceCommand() {
4198
+ const cmd = new Command("workspace").description("choose which workspace the CLI works in");
4199
+ cmd.command("list").description("the workspaces this account belongs to").option("--profile <name>").option("--json").action(async (opts) => {
4200
+ try {
4201
+ const client = buildClient(opts.profile);
4202
+ const { data, lastWorkspaceId } = await client.workspaces.list();
4203
+ if (opts.json) {
4204
+ emit({ data, lastWorkspaceId }, opts);
4205
+ return;
4206
+ }
4207
+ if (data.length === 0) {
4208
+ info("this account belongs to no workspaces \u2014 everything happens in its personal space");
4209
+ return;
4210
+ }
4211
+ const active = resolveWorkspace(getProfile(opts.profile).profile).workspaceId;
4212
+ table(
4213
+ data.map((w) => ({
4214
+ id: w.id,
4215
+ name: w.name,
4216
+ role: w.role,
4217
+ archived: w.archived ? "yes" : "",
4218
+ active: w.id === active ? "\u2190" : ""
4219
+ })),
4220
+ ["id", "name", "role", "archived", "active"]
4221
+ );
4222
+ } catch (err) {
4223
+ handleError(err);
4224
+ }
4225
+ });
4226
+ cmd.command("current").description("which workspace this profile is working in, and why").option("--profile <name>").option("--json").action((opts) => {
4227
+ const { name, profile } = getProfile(opts.profile);
4228
+ const { workspaceId, source } = resolveWorkspace(profile);
4229
+ if (opts.json) {
4230
+ emit({ profile: name, workspaceId: workspaceId ?? null, source }, opts);
4231
+ return;
4232
+ }
4233
+ info(`profile: ${pc3.cyan(name)}`);
4234
+ info(`workspace: ${workspaceId ?? "(personal space)"}`);
4235
+ if (!profile) {
4236
+ warn(`no credentials for profile "${name}" \u2014 run: nodaro auth login`);
4237
+ return;
4238
+ }
4239
+ if (!workspaceId) return;
4240
+ dim(`from: ${SOURCE_LABELS[source]}`);
4241
+ });
4242
+ cmd.command("use <id>").description("remember this workspace for the profile").option("--profile <name>").option("--json").action(async (id, opts) => {
4243
+ try {
4244
+ const client = buildClient(opts.profile);
4245
+ const { data: mine } = await client.workspaces.list();
4246
+ const data = mine.find((w) => w.id === id);
4247
+ if (!data) {
4248
+ throw new Error(
4249
+ `${id} is not one of the workspaces this account can work in \u2014 run: nodaro workspace list`
4250
+ );
4251
+ }
4252
+ const name = saveWorkspace(opts.profile, id);
4253
+ if (opts.json) {
4254
+ emit({ profile: name, workspaceId: id, workspace: data }, opts);
4255
+ return;
4256
+ }
4257
+ success(`profile "${name}" now works in ${data.name} (${id})`);
4258
+ if (data.archived) warn("this workspace is archived \u2014 reads work, new work does not");
4259
+ const { source } = resolveWorkspace(getProfile(opts.profile).profile);
4260
+ if (source !== "profile") {
4261
+ warn(`saved, but ${SOURCE_LABELS[source]} still wins for now`);
4262
+ }
4263
+ } catch (err) {
4264
+ handleError(err);
4265
+ }
4266
+ });
4267
+ cmd.command("clear").description("go back to the personal space").option("--profile <name>").action((opts) => {
4268
+ try {
4269
+ const name = saveWorkspace(opts.profile, null);
4270
+ success(`profile "${name}" now works in its personal space`);
4271
+ const { source } = resolveWorkspace(getProfile(opts.profile).profile);
4272
+ if (source !== "none") warn(`cleared, but ${SOURCE_LABELS[source]} still wins`);
4273
+ } catch (err) {
4274
+ handleError(err);
4275
+ }
4276
+ });
4277
+ cmd.command("members <id>").description("who is in a workspace").option("--limit <n>", "page size", (v) => Number(v)).option("--cursor <cursor>", "continue a previous page").option("--profile <name>").option("--json").action(async (id, opts) => {
4278
+ try {
4279
+ const client = buildClient(opts.profile);
4280
+ const page = await client.workspaces.listMembers(id, { limit: opts.limit, cursor: opts.cursor });
4281
+ if (opts.json) {
4282
+ emit(page, opts);
4283
+ return;
4284
+ }
4285
+ table(
4286
+ page.data.map((m) => ({
4287
+ userId: m.userId,
4288
+ name: m.displayName ?? "",
4289
+ role: m.role,
4290
+ status: m.status ?? ""
4291
+ })),
4292
+ ["userId", "name", "role", "status"]
4293
+ );
4294
+ if (page.nextCursor) dim(`more: --cursor ${page.nextCursor}`);
4295
+ } catch (err) {
4296
+ handleError(err);
4297
+ }
4298
+ });
4299
+ cmd.command("join <code>").description("join a workspace with a join code").option("--profile <name>").option("--json").action(async (code, opts) => {
4300
+ try {
4301
+ const client = buildClient(opts.profile);
4302
+ const { data } = await client.workspaces.join(code);
4303
+ if (opts.json) {
4304
+ emit(data, opts);
4305
+ return;
4306
+ }
4307
+ success(`joined workspace ${data.workspaceId}`);
4308
+ dim(`work in it: nodaro workspace use ${data.workspaceId}`);
4309
+ } catch (err) {
4310
+ handleError(err);
4311
+ }
4312
+ });
4313
+ cmd.command("get <id>").description("show one workspace").option("--profile <name>").option("--json").action(async (id, opts) => {
4314
+ try {
4315
+ const client = buildClient(opts.profile);
4316
+ const { data } = await client.workspaces.get(id);
4317
+ if (opts.json) emit(data, opts);
4318
+ else detail(data);
4319
+ } catch (err) {
4320
+ handleError(err);
4321
+ }
4322
+ });
4323
+ return cmd;
4324
+ }
4325
+ var SOURCE_LABELS = {
4326
+ flag: "--workspace on this command",
4327
+ env: "the NODARO_WORKSPACE environment variable",
4328
+ profile: "the profile's saved workspace",
4329
+ none: "nothing \u2014 the personal space"
4330
+ };
3730
4331
 
3731
4332
  // src/index.ts
3732
4333
  function readVersion() {
@@ -3736,7 +4337,10 @@ function readVersion() {
3736
4337
  return "0.0.0-dev";
3737
4338
  }
3738
4339
  }
3739
- var program = new Command().name("nodaro").description("Nodaro command-line interface \u2014 list and run workflows, inspect jobs and executions, manage projects.").version(readVersion(), "-v, --version");
4340
+ var program = new Command().name("nodaro").description("Nodaro command-line interface \u2014 list and run workflows, inspect jobs and executions, manage projects.").version(readVersion(), "-v, --version").option("--workspace <id>", "work in this workspace for this command only");
4341
+ program.hook("preAction", () => {
4342
+ setWorkspaceFlag(program.opts().workspace);
4343
+ });
3740
4344
  program.addCommand(authCommand());
3741
4345
  program.addCommand(projectsCommand());
3742
4346
  program.addCommand(workflowsCommand());
@@ -3753,9 +4357,12 @@ program.addCommand(audioCommand());
3753
4357
  program.addCommand(presetsCommand());
3754
4358
  program.addCommand(communityCommand());
3755
4359
  program.addCommand(pickerCatalogsCommand());
4360
+ program.addCommand(catalogCommand());
3756
4361
  program.addCommand(modelsCommand());
3757
4362
  program.addCommand(shotsCommand());
3758
4363
  program.addCommand(recastCommand());
4364
+ program.addCommand(orgCommand());
4365
+ program.addCommand(workspaceCommand());
3759
4366
  registerLocationsCommands(program);
3760
4367
  registerObjectsCommands(program);
3761
4368
  program.parseAsync().catch((err) => {