@nodaro/cli 1.8.1 → 1.11.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.8.1",
32
+ version: "1.11.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.13.1",
74
- "@nodaro/shared": "^2.0.0",
73
+ "@nodaro/sdk": "^1.19.0",
74
+ "@nodaro/shared": "^2.10.0",
75
75
  commander: "^12.1.0",
76
76
  picocolors: "^1.1.1",
77
- "@nodaro/prompts": "^1.5.0"
77
+ "@nodaro/prompts": "^1.7.3"
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.8.1" ;
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.11.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.
@@ -2082,7 +2110,7 @@ function parseSection(raw) {
2082
2110
  }
2083
2111
  function mediaCommand() {
2084
2112
  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"
2113
+ "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
2114
  );
2087
2115
  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
2116
  Examples:
@@ -2179,6 +2207,66 @@ Examples:
2179
2207
  }
2180
2208
  }
2181
2209
  );
2210
+ 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", `
2211
+ Examples:
2212
+ $ nodaro media still-to-video --image https://.../cover.png --audio https://.../track.mp3 --watch
2213
+ $ nodaro media still-to-video --image https://.../photo.png --audio https://.../vo.wav --motion ken-burns --intensity 4 --watch`).action(
2214
+ async (opts) => {
2215
+ try {
2216
+ const client = buildClient(opts.profile);
2217
+ const result = await client.media.stillToVideo({
2218
+ imageUrl: opts.image,
2219
+ audioUrl: opts.audio,
2220
+ ...opts.motion !== void 0 ? { motion: opts.motion } : {},
2221
+ ...opts.intensity !== void 0 ? { intensity: opts.intensity } : {},
2222
+ ...opts.resolution !== void 0 ? { resolution: opts.resolution } : {},
2223
+ ...opts.aspectRatio !== void 0 ? { aspectRatio: opts.aspectRatio } : {},
2224
+ ...opts.fps !== void 0 ? { fps: opts.fps } : {},
2225
+ ...opts.fit !== void 0 ? { fit: opts.fit } : {},
2226
+ ...opts.padColor !== void 0 ? { padColor: opts.padColor } : {}
2227
+ });
2228
+ await reportQueuedJob(result, () => client.jobs.get(result.jobId), { ...opts, note: "still to video" });
2229
+ } catch (err) {
2230
+ handleError(err);
2231
+ }
2232
+ }
2233
+ );
2234
+ 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", `
2235
+ Examples:
2236
+ $ nodaro media slideshow --images https://.../a.png https://.../b.png https://.../c.png --audio https://.../track.mp3 --transition dissolve --watch
2237
+ $ nodaro media slideshow --images https://.../a.png https://.../b.png --per-image 2.5 --motion alternate --watch`).action(
2238
+ async (opts) => {
2239
+ try {
2240
+ if (opts.images.length < 2) {
2241
+ warn("Slideshow needs at least 2 images. For a single still, use: nodaro media still-to-video");
2242
+ process.exit(1);
2243
+ }
2244
+ const imageDurations = opts.durations ? opts.durations.split(",").map((d) => {
2245
+ const t = d.trim().toLowerCase();
2246
+ return t === "auto" || t === "" ? null : parseFloat(t);
2247
+ }) : void 0;
2248
+ const client = buildClient(opts.profile);
2249
+ const result = await client.media.slideshow({
2250
+ imageUrls: opts.images,
2251
+ ...opts.audio !== void 0 ? { audioUrl: opts.audio } : {},
2252
+ ...imageDurations !== void 0 ? { imageDurations } : {},
2253
+ ...opts.perImage !== void 0 ? { perImageDuration: opts.perImage } : {},
2254
+ ...opts.transition !== void 0 ? { transition: opts.transition } : {},
2255
+ ...opts.transitionDuration !== void 0 ? { transitionDuration: opts.transitionDuration } : {},
2256
+ ...opts.motion !== void 0 ? { motion: opts.motion } : {},
2257
+ ...opts.intensity !== void 0 ? { intensity: opts.intensity } : {},
2258
+ ...opts.resolution !== void 0 ? { resolution: opts.resolution } : {},
2259
+ ...opts.aspectRatio !== void 0 ? { aspectRatio: opts.aspectRatio } : {},
2260
+ ...opts.fps !== void 0 ? { fps: opts.fps } : {},
2261
+ ...opts.fit !== void 0 ? { fit: opts.fit } : {},
2262
+ ...opts.padColor !== void 0 ? { padColor: opts.padColor } : {}
2263
+ });
2264
+ await reportQueuedJob(result, () => client.jobs.get(result.jobId), { ...opts, note: "slideshow" });
2265
+ } catch (err) {
2266
+ handleError(err);
2267
+ }
2268
+ }
2269
+ );
2182
2270
  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
2271
  Example:
2184
2272
  $ nodaro media trim-audio --video https://.../clip.mp4 --start 0 --end 30 --format wav --watch`).action(
@@ -2752,6 +2840,31 @@ function pickerCatalogsCommand() {
2752
2840
  handleError(err);
2753
2841
  }
2754
2842
  });
2843
+ cmd.command("analyze <text>").description("AI Fill: choose picker values from a free-text description (credit-billed LLM call)").option("--target <types>", "comma-separated picker node types to fill (default: all analyzable)").option("--instructions <text>", "extra guidance for the analyzer").option("--model <id>", "LLM model override").option("--effort <level>", "reasoning effort override").option("--profile <name>").option("--json").addHelpText(
2844
+ "after",
2845
+ `
2846
+ Examples:
2847
+ $ nodaro pickers analyze "rainy neon alley at night, low tracking shot"
2848
+ $ nodaro pickers analyze "sunlit kitchen, warm morning" --target setting,mood`
2849
+ ).action(
2850
+ async (text, opts) => {
2851
+ try {
2852
+ const client = buildClient(opts.profile);
2853
+ const result = await client.pickerCatalogs.analyzeText({
2854
+ text,
2855
+ targetPickers: opts.target?.split(",").map((t) => t.trim()).filter(Boolean),
2856
+ instructions: opts.instructions,
2857
+ origin: "cli",
2858
+ llmModel: opts.model,
2859
+ reasoningEffort: opts.effort
2860
+ });
2861
+ if (opts.json) emit(result, opts);
2862
+ else detail(result.pickerJson);
2863
+ } catch (err) {
2864
+ handleError(err);
2865
+ }
2866
+ }
2867
+ );
2755
2868
  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(
2756
2869
  "after",
2757
2870
  `
@@ -2778,6 +2891,249 @@ Examples:
2778
2891
  );
2779
2892
  return cmd;
2780
2893
  }
2894
+ function modelsCommand() {
2895
+ const cmd = new Command("models").description(
2896
+ "browse the model catalog \u2014 capability sheets, per-variant credit pricing, prompt tips"
2897
+ );
2898
+ 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(
2899
+ "after",
2900
+ `
2901
+ Examples:
2902
+ $ nodaro models list --kind video --mode i2v
2903
+ $ nodaro models list --family Google --json`
2904
+ ).action(
2905
+ async (opts) => {
2906
+ try {
2907
+ const client = buildClient(opts.profile);
2908
+ const result = await client.models.list({
2909
+ kind: opts.kind,
2910
+ mode: opts.mode,
2911
+ family: opts.family,
2912
+ featuredOnly: opts.featured
2913
+ });
2914
+ if (opts.json) {
2915
+ emit(result, opts);
2916
+ return;
2917
+ }
2918
+ const rows = result.sections.flatMap(
2919
+ (section) => section.families.flatMap(
2920
+ (group) => group.models.map((m) => ({
2921
+ id: m.id,
2922
+ kind: section.kind,
2923
+ family: group.family,
2924
+ modes: m.modes.join(","),
2925
+ credits: (m.pricing ?? []).map((p) => p.credits).join("/") || "-",
2926
+ featured: m.featured ? "\u2605" : "",
2927
+ doctrine: m.doctrineCovered ? "\u2713" : ""
2928
+ }))
2929
+ )
2930
+ );
2931
+ table(rows, ["id", "kind", "family", "modes", "credits", "featured", "doctrine"]);
2932
+ } catch (err) {
2933
+ handleError(err);
2934
+ }
2935
+ }
2936
+ );
2937
+ return cmd;
2938
+ }
2939
+ function readJsonObject2(path, flag) {
2940
+ let raw;
2941
+ try {
2942
+ raw = readFileSync(path, "utf8");
2943
+ } catch {
2944
+ throw new Error(`${flag}: cannot read ${path}`);
2945
+ }
2946
+ const parsed = JSON.parse(raw);
2947
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
2948
+ throw new Error(`${flag}: expected a JSON object`);
2949
+ }
2950
+ return parsed;
2951
+ }
2952
+ function shotsCommand() {
2953
+ const cmd = new Command("shots").description(
2954
+ "Cine share \u2192 remix records \u2014 create, inspect, toggle visibility, delete"
2955
+ );
2956
+ cmd.command("get <id>").description("read a shot (public shots resolve for anyone holding the id)").option("--profile <name>").option("--json").action(async (id, opts) => {
2957
+ try {
2958
+ const client = buildClient(opts.profile);
2959
+ const result = await client.shots.get(id);
2960
+ if (opts.json) emit(result.shot, opts);
2961
+ else detail(result.shot);
2962
+ } catch (err) {
2963
+ handleError(err);
2964
+ }
2965
+ });
2966
+ cmd.command("create").description("create a shot record from a JSON file (CreateShotInput shape)").option("--file <jsonPath>", "path to a JSON file with the shot fields").option("--visibility <v>", "private | public (default private)").option("--profile <name>").option("--json").addHelpText(
2967
+ "after",
2968
+ `
2969
+ Examples:
2970
+ $ nodaro shots create --file shot.json
2971
+ $ nodaro shots create --file shot.json --visibility public`
2972
+ ).action(async (opts) => {
2973
+ try {
2974
+ const input2 = opts.file ? readJsonObject2(opts.file, "--file") : {};
2975
+ if (opts.visibility) input2.visibility = opts.visibility;
2976
+ const client = buildClient(opts.profile);
2977
+ const result = await client.shots.create(input2);
2978
+ if (opts.json) emit(result, opts);
2979
+ else success(`created shot ${result.id}`);
2980
+ } catch (err) {
2981
+ handleError(err);
2982
+ }
2983
+ });
2984
+ cmd.command("update <id>").description("update an owned shot (any subset of fields, e.g. a visibility toggle)").option("--file <jsonPath>", "path to a JSON file with the fields to change").option("--visibility <v>", "private | public").option("--profile <name>").option("--json").action(async (id, opts) => {
2985
+ try {
2986
+ const input2 = opts.file ? readJsonObject2(opts.file, "--file") : {};
2987
+ if (opts.visibility) input2.visibility = opts.visibility;
2988
+ if (Object.keys(input2).length === 0) {
2989
+ throw new Error("nothing to update \u2014 pass --visibility and/or --file");
2990
+ }
2991
+ const client = buildClient(opts.profile);
2992
+ const result = await client.shots.update(id, input2);
2993
+ if (opts.json) emit(result.shot, opts);
2994
+ else detail(result.shot);
2995
+ } catch (err) {
2996
+ handleError(err);
2997
+ }
2998
+ });
2999
+ cmd.command("delete <id>").description("delete an owned shot").option("--profile <name>").action(async (id, opts) => {
3000
+ try {
3001
+ const client = buildClient(opts.profile);
3002
+ await client.shots.delete(id);
3003
+ success(`deleted shot ${id}`);
3004
+ } catch (err) {
3005
+ handleError(err);
3006
+ }
3007
+ });
3008
+ return cmd;
3009
+ }
3010
+ function readScript(path) {
3011
+ let raw;
3012
+ try {
3013
+ raw = readFileSync(path, "utf8");
3014
+ } catch {
3015
+ throw new Error(`--file: cannot read ${path}`);
3016
+ }
3017
+ const parsed = JSON.parse(raw);
3018
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
3019
+ throw new Error("--file: expected a JSON object (the authored script document)");
3020
+ }
3021
+ return parsed;
3022
+ }
3023
+ function recastCommand() {
3024
+ const cmd = new Command("recast").description(
3025
+ "recast runs + authored-script import (movie as JSON) \u2014 Cloud edition"
3026
+ );
3027
+ cmd.command("skill").description("print the authoring guide for writing a script (markdown, free)").option("--profile <name>").action(async (opts) => {
3028
+ try {
3029
+ const client = buildClient(opts.profile);
3030
+ process.stdout.write(await client.recast.authoringSkill());
3031
+ } catch (err) {
3032
+ handleError(err);
3033
+ }
3034
+ });
3035
+ cmd.command("validate").description("validate an authored script JSON (free; loop until valid)").requiredOption("--file <jsonPath>", "path to the authored script document").option("--profile <name>").option("--json").action(async (opts) => {
3036
+ try {
3037
+ const client = buildClient(opts.profile);
3038
+ const result = await client.recast.validateScript(readScript(opts.file));
3039
+ if (opts.json) {
3040
+ emit(result, opts);
3041
+ return;
3042
+ }
3043
+ if (result.valid) success("valid");
3044
+ else {
3045
+ warn(`invalid \u2014 ${result.errors.length} error(s)`);
3046
+ for (const e of result.errors) {
3047
+ console.log(` ${e.path}: ${e.message}${e.hint ? ` (hint: ${e.hint})` : ""}`);
3048
+ }
3049
+ }
3050
+ for (const w of result.warnings) warn(w);
3051
+ if (!result.valid) process.exitCode = 1;
3052
+ } catch (err) {
3053
+ handleError(err);
3054
+ }
3055
+ });
3056
+ cmd.command("import").description("import a VALIDATED authored script as a completed analysis (free)").requiredOption("--file <jsonPath>", "path to the authored script document").option(
3057
+ "--rights-attested",
3058
+ "assert the script is your own work (required \u2014 authored recasts render Faithful, exactly as written)"
3059
+ ).option("--profile <name>").option("--json").action(async (opts) => {
3060
+ try {
3061
+ if (!opts.rightsAttested) {
3062
+ throw new Error(
3063
+ "authored imports require --rights-attested: confirm the script is your own work (it renders exactly as written)"
3064
+ );
3065
+ }
3066
+ const client = buildClient(opts.profile);
3067
+ const result = await client.recast.importScript(readScript(opts.file), {
3068
+ rightsAttested: true
3069
+ });
3070
+ if (opts.json) emit(result, opts);
3071
+ else {
3072
+ success(`${result.created ? "imported" : "already imported"} \u2014 analysis job ${result.jobId}`);
3073
+ for (const w of result.warnings) warn(w);
3074
+ }
3075
+ } catch (err) {
3076
+ handleError(err);
3077
+ }
3078
+ });
3079
+ cmd.command("estimate").description("quote a run in credits before creating it").requiredOption("--analysis-job <id>", "the source analysis job id").option("--fidelity <f>", "render fidelity", "faithful").option("--resolution <r>").option("--segment-sec <n>", "segment length in seconds", parseFloat).option("--profile <name>").option("--json").action(
3080
+ async (opts) => {
3081
+ try {
3082
+ const client = buildClient(opts.profile);
3083
+ const result = await client.recast.estimate({
3084
+ analysisJobId: opts.analysisJob,
3085
+ fidelity: opts.fidelity,
3086
+ resolution: opts.resolution,
3087
+ segmentSec: opts.segmentSec
3088
+ });
3089
+ if (opts.json) emit(result, opts);
3090
+ else detail(result);
3091
+ } catch (err) {
3092
+ handleError(err);
3093
+ }
3094
+ }
3095
+ );
3096
+ cmd.command("create").description("create a run \u2014 BUYS THE PLAN (credits); run `estimate` first").requiredOption("--workflow <id>", "workflow the run attaches to").requiredOption("--analysis-job <id>", "the source analysis job id").option("--fidelity <f>", "render fidelity", "faithful").option("--rights-attested", "required for faithful renders of authored scripts").option("--resolution <r>").option("--segment-sec <n>", "segment length in seconds", parseFloat).option("--profile <name>").option("--json").action(
3097
+ async (opts) => {
3098
+ try {
3099
+ const client = buildClient(opts.profile);
3100
+ const result = await client.recast.create({
3101
+ workflowId: opts.workflow,
3102
+ analysisJobId: opts.analysisJob,
3103
+ fidelity: opts.fidelity,
3104
+ rightsAttested: opts.rightsAttested,
3105
+ resolution: opts.resolution,
3106
+ segmentSec: opts.segmentSec
3107
+ });
3108
+ if (opts.json) emit(result, opts);
3109
+ else success(`run ${result.recastId} created (planning) \u2014 poll: nodaro recast status ${result.recastId}`);
3110
+ } catch (err) {
3111
+ handleError(err);
3112
+ }
3113
+ }
3114
+ );
3115
+ cmd.command("start <recastId>").description("start rendering a planned run (idempotent)").option("--segment-sec <n>", "segment length in seconds", parseFloat).option("--profile <name>").option("--json").action(async (recastId, opts) => {
3116
+ try {
3117
+ const client = buildClient(opts.profile);
3118
+ const result = await client.recast.start(recastId, { segmentSec: opts.segmentSec });
3119
+ if (opts.json) emit(result, opts);
3120
+ else success(`rendering${result.gvpJobId ? ` \u2014 gvp job ${result.gvpJobId}` : ""}`);
3121
+ } catch (err) {
3122
+ handleError(err);
3123
+ }
3124
+ });
3125
+ cmd.command("status <recastId>").description("poll a run \u2014 status plus any pending interactive step").option("--profile <name>").option("--json").action(async (recastId, opts) => {
3126
+ try {
3127
+ const client = buildClient(opts.profile);
3128
+ const result = await client.recast.get(recastId);
3129
+ if (opts.json) emit(result, opts);
3130
+ else detail(result);
3131
+ } catch (err) {
3132
+ handleError(err);
3133
+ }
3134
+ });
3135
+ return cmd;
3136
+ }
2781
3137
  var ASSET_TYPE_TO_COLUMN = {
2782
3138
  timeOfDay: "time_of_day",
2783
3139
  weather: "weather",
@@ -3459,6 +3815,316 @@ function objectsCommand() {
3459
3815
  function registerObjectsCommands(program2) {
3460
3816
  program2.addCommand(objectsCommand());
3461
3817
  }
3818
+ function orgCommand() {
3819
+ const cmd = new Command("org").description("organizations, their members, and invitations");
3820
+ cmd.command("list").description("the organizations this account belongs to").option("--profile <name>").option("--json").action(async (opts) => {
3821
+ try {
3822
+ const client = buildClient(opts.profile);
3823
+ const { data } = await client.organizations.list();
3824
+ if (opts.json) {
3825
+ emit(data, opts);
3826
+ return;
3827
+ }
3828
+ if (data.length === 0) {
3829
+ info("this account belongs to no organizations");
3830
+ return;
3831
+ }
3832
+ table(
3833
+ data.map((o) => ({ id: o.id, name: o.name, kind: o.kind, status: o.status, role: o.role ?? "" })),
3834
+ ["id", "name", "kind", "status", "role"]
3835
+ );
3836
+ } catch (err) {
3837
+ handleError(err);
3838
+ }
3839
+ });
3840
+ cmd.command("get <id>").description("show one organization").option("--profile <name>").option("--json").action(async (id, opts) => {
3841
+ try {
3842
+ const client = buildClient(opts.profile);
3843
+ const { data } = await client.organizations.get(id);
3844
+ if (opts.json) emit(data, opts);
3845
+ else detail(data);
3846
+ } catch (err) {
3847
+ handleError(err);
3848
+ }
3849
+ });
3850
+ 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) => {
3851
+ try {
3852
+ if (opts.kind !== "school" && opts.kind !== "team") {
3853
+ throw new Error("--kind must be school or team");
3854
+ }
3855
+ const client = buildClient(opts.profile);
3856
+ const { data } = await client.organizations.create({
3857
+ name: opts.name,
3858
+ kind: opts.kind,
3859
+ ...opts.slug ? { slug: opts.slug } : {},
3860
+ ...opts.acceptTerms ? { acceptTerms: true } : {}
3861
+ });
3862
+ if (opts.json) {
3863
+ emit(data, opts);
3864
+ return;
3865
+ }
3866
+ success(`created ${data.name} (${data.id})`);
3867
+ if (data.status === "pending") {
3868
+ warn("status is pending \u2014 it grants nothing until a platform admin approves it");
3869
+ }
3870
+ } catch (err) {
3871
+ handleError(err);
3872
+ }
3873
+ });
3874
+ 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) => {
3875
+ try {
3876
+ const client = buildClient(opts.profile);
3877
+ const page = await client.organizations.listMembers(orgId, { limit: opts.limit, cursor: opts.cursor });
3878
+ if (opts.json) {
3879
+ emit(page, opts);
3880
+ return;
3881
+ }
3882
+ table(
3883
+ page.data.map((m) => ({
3884
+ userId: m.userId,
3885
+ name: m.displayName ?? "",
3886
+ email: m.email ?? "",
3887
+ role: m.role,
3888
+ status: m.status
3889
+ })),
3890
+ ["userId", "name", "email", "role", "status"]
3891
+ );
3892
+ if (page.nextCursor) dim(`more: --cursor ${page.nextCursor}`);
3893
+ } catch (err) {
3894
+ handleError(err);
3895
+ }
3896
+ });
3897
+ 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(
3898
+ async (orgId, opts) => {
3899
+ try {
3900
+ const emails = (opts.email ?? []).flatMap((e) => e.split(",")).map((e) => e.trim()).filter(Boolean);
3901
+ if (emails.length === 0) throw new Error("no addresses \u2014 pass --email at least once");
3902
+ if (opts.role !== "admin" && opts.role !== "member") {
3903
+ throw new Error("--role must be admin or member");
3904
+ }
3905
+ if (opts.workspaceRole && opts.workspaceRole !== "admin" && opts.workspaceRole !== "member") {
3906
+ throw new Error("--workspace-role must be admin or member");
3907
+ }
3908
+ const client = buildClient(opts.profile);
3909
+ const { data } = await client.organizations.invite(orgId, {
3910
+ emails,
3911
+ orgRole: opts.role,
3912
+ ...opts.workspace ? { workspaceId: opts.workspace } : {},
3913
+ ...opts.workspaceRole ? { workspaceRole: opts.workspaceRole } : {}
3914
+ });
3915
+ if (opts.json) {
3916
+ emit(data, opts);
3917
+ return;
3918
+ }
3919
+ for (const row of data) {
3920
+ if (row.status === "sent") success(`${row.email} \u2014 emailed`);
3921
+ else if (row.link) {
3922
+ warn(`${row.email} \u2014 not emailed (${row.status}); send this link yourself:`);
3923
+ info(` ${row.link}`);
3924
+ } else {
3925
+ warn(`${row.email} \u2014 ${row.status}, and no link was returned`);
3926
+ }
3927
+ }
3928
+ } catch (err) {
3929
+ handleError(err);
3930
+ }
3931
+ }
3932
+ );
3933
+ 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) => {
3934
+ try {
3935
+ const client = buildClient(opts.profile);
3936
+ const page = await client.organizations.listInvitations(orgId, {
3937
+ ...opts.status ? { status: opts.status } : {},
3938
+ limit: opts.limit,
3939
+ cursor: opts.cursor
3940
+ });
3941
+ if (opts.json) {
3942
+ emit(page, opts);
3943
+ return;
3944
+ }
3945
+ table(
3946
+ page.data.map((i) => ({
3947
+ id: i.id,
3948
+ email: i.email,
3949
+ role: i.orgRole,
3950
+ state: i.state,
3951
+ expiresAt: i.expiresAt
3952
+ })),
3953
+ ["id", "email", "role", "state", "expiresAt"]
3954
+ );
3955
+ if (page.nextCursor) dim(`more: --cursor ${page.nextCursor}`);
3956
+ } catch (err) {
3957
+ handleError(err);
3958
+ }
3959
+ });
3960
+ cmd.command("revoke <invitationId>").description("revoke an invitation").option("--profile <name>").option("--json").action(async (id, opts) => {
3961
+ try {
3962
+ const client = buildClient(opts.profile);
3963
+ const { data } = await client.organizations.revokeInvitation(id);
3964
+ if (opts.json) emit(data, opts);
3965
+ else success(`revoked invitation ${id}`);
3966
+ } catch (err) {
3967
+ handleError(err);
3968
+ }
3969
+ });
3970
+ 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) => {
3971
+ try {
3972
+ const client = buildClient(opts.profile);
3973
+ const page = await client.organizations.audit(orgId, { limit: opts.limit, cursor: opts.cursor });
3974
+ if (opts.json) {
3975
+ emit(page, opts);
3976
+ return;
3977
+ }
3978
+ table(
3979
+ page.data.map((e) => ({
3980
+ at: e.createdAt,
3981
+ action: e.action,
3982
+ actor: e.actor?.displayName ?? e.actor?.email ?? e.actor?.userId ?? "system",
3983
+ target: e.targetId ?? ""
3984
+ })),
3985
+ ["at", "action", "actor", "target"]
3986
+ );
3987
+ if (page.nextCursor) dim(`more: --cursor ${page.nextCursor}`);
3988
+ } catch (err) {
3989
+ handleError(err);
3990
+ }
3991
+ });
3992
+ return cmd;
3993
+ }
3994
+ function workspaceCommand() {
3995
+ const cmd = new Command("workspace").description("choose which workspace the CLI works in");
3996
+ cmd.command("list").description("the workspaces this account belongs to").option("--profile <name>").option("--json").action(async (opts) => {
3997
+ try {
3998
+ const client = buildClient(opts.profile);
3999
+ const { data, lastWorkspaceId } = await client.workspaces.list();
4000
+ if (opts.json) {
4001
+ emit({ data, lastWorkspaceId }, opts);
4002
+ return;
4003
+ }
4004
+ if (data.length === 0) {
4005
+ info("this account belongs to no workspaces \u2014 everything happens in its personal space");
4006
+ return;
4007
+ }
4008
+ const active = resolveWorkspace(getProfile(opts.profile).profile).workspaceId;
4009
+ table(
4010
+ data.map((w) => ({
4011
+ id: w.id,
4012
+ name: w.name,
4013
+ role: w.role,
4014
+ archived: w.archived ? "yes" : "",
4015
+ active: w.id === active ? "\u2190" : ""
4016
+ })),
4017
+ ["id", "name", "role", "archived", "active"]
4018
+ );
4019
+ } catch (err) {
4020
+ handleError(err);
4021
+ }
4022
+ });
4023
+ cmd.command("current").description("which workspace this profile is working in, and why").option("--profile <name>").option("--json").action((opts) => {
4024
+ const { name, profile } = getProfile(opts.profile);
4025
+ const { workspaceId, source } = resolveWorkspace(profile);
4026
+ if (opts.json) {
4027
+ emit({ profile: name, workspaceId: workspaceId ?? null, source }, opts);
4028
+ return;
4029
+ }
4030
+ info(`profile: ${pc3.cyan(name)}`);
4031
+ info(`workspace: ${workspaceId ?? "(personal space)"}`);
4032
+ if (!profile) {
4033
+ warn(`no credentials for profile "${name}" \u2014 run: nodaro auth login`);
4034
+ return;
4035
+ }
4036
+ if (!workspaceId) return;
4037
+ dim(`from: ${SOURCE_LABELS[source]}`);
4038
+ });
4039
+ cmd.command("use <id>").description("remember this workspace for the profile").option("--profile <name>").option("--json").action(async (id, opts) => {
4040
+ try {
4041
+ const client = buildClient(opts.profile);
4042
+ const { data: mine } = await client.workspaces.list();
4043
+ const data = mine.find((w) => w.id === id);
4044
+ if (!data) {
4045
+ throw new Error(
4046
+ `${id} is not one of the workspaces this account can work in \u2014 run: nodaro workspace list`
4047
+ );
4048
+ }
4049
+ const name = saveWorkspace(opts.profile, id);
4050
+ if (opts.json) {
4051
+ emit({ profile: name, workspaceId: id, workspace: data }, opts);
4052
+ return;
4053
+ }
4054
+ success(`profile "${name}" now works in ${data.name} (${id})`);
4055
+ if (data.archived) warn("this workspace is archived \u2014 reads work, new work does not");
4056
+ const { source } = resolveWorkspace(getProfile(opts.profile).profile);
4057
+ if (source !== "profile") {
4058
+ warn(`saved, but ${SOURCE_LABELS[source]} still wins for now`);
4059
+ }
4060
+ } catch (err) {
4061
+ handleError(err);
4062
+ }
4063
+ });
4064
+ cmd.command("clear").description("go back to the personal space").option("--profile <name>").action((opts) => {
4065
+ try {
4066
+ const name = saveWorkspace(opts.profile, null);
4067
+ success(`profile "${name}" now works in its personal space`);
4068
+ const { source } = resolveWorkspace(getProfile(opts.profile).profile);
4069
+ if (source !== "none") warn(`cleared, but ${SOURCE_LABELS[source]} still wins`);
4070
+ } catch (err) {
4071
+ handleError(err);
4072
+ }
4073
+ });
4074
+ 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) => {
4075
+ try {
4076
+ const client = buildClient(opts.profile);
4077
+ const page = await client.workspaces.listMembers(id, { limit: opts.limit, cursor: opts.cursor });
4078
+ if (opts.json) {
4079
+ emit(page, opts);
4080
+ return;
4081
+ }
4082
+ table(
4083
+ page.data.map((m) => ({
4084
+ userId: m.userId,
4085
+ name: m.displayName ?? "",
4086
+ role: m.role,
4087
+ status: m.status ?? ""
4088
+ })),
4089
+ ["userId", "name", "role", "status"]
4090
+ );
4091
+ if (page.nextCursor) dim(`more: --cursor ${page.nextCursor}`);
4092
+ } catch (err) {
4093
+ handleError(err);
4094
+ }
4095
+ });
4096
+ cmd.command("join <code>").description("join a workspace with a join code").option("--profile <name>").option("--json").action(async (code, opts) => {
4097
+ try {
4098
+ const client = buildClient(opts.profile);
4099
+ const { data } = await client.workspaces.join(code);
4100
+ if (opts.json) {
4101
+ emit(data, opts);
4102
+ return;
4103
+ }
4104
+ success(`joined workspace ${data.workspaceId}`);
4105
+ dim(`work in it: nodaro workspace use ${data.workspaceId}`);
4106
+ } catch (err) {
4107
+ handleError(err);
4108
+ }
4109
+ });
4110
+ cmd.command("get <id>").description("show one workspace").option("--profile <name>").option("--json").action(async (id, opts) => {
4111
+ try {
4112
+ const client = buildClient(opts.profile);
4113
+ const { data } = await client.workspaces.get(id);
4114
+ if (opts.json) emit(data, opts);
4115
+ else detail(data);
4116
+ } catch (err) {
4117
+ handleError(err);
4118
+ }
4119
+ });
4120
+ return cmd;
4121
+ }
4122
+ var SOURCE_LABELS = {
4123
+ flag: "--workspace on this command",
4124
+ env: "the NODARO_WORKSPACE environment variable",
4125
+ profile: "the profile's saved workspace",
4126
+ none: "nothing \u2014 the personal space"
4127
+ };
3462
4128
 
3463
4129
  // src/index.ts
3464
4130
  function readVersion() {
@@ -3468,7 +4134,10 @@ function readVersion() {
3468
4134
  return "0.0.0-dev";
3469
4135
  }
3470
4136
  }
3471
- 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");
4137
+ 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");
4138
+ program.hook("preAction", () => {
4139
+ setWorkspaceFlag(program.opts().workspace);
4140
+ });
3472
4141
  program.addCommand(authCommand());
3473
4142
  program.addCommand(projectsCommand());
3474
4143
  program.addCommand(workflowsCommand());
@@ -3485,6 +4154,11 @@ program.addCommand(audioCommand());
3485
4154
  program.addCommand(presetsCommand());
3486
4155
  program.addCommand(communityCommand());
3487
4156
  program.addCommand(pickerCatalogsCommand());
4157
+ program.addCommand(modelsCommand());
4158
+ program.addCommand(shotsCommand());
4159
+ program.addCommand(recastCommand());
4160
+ program.addCommand(orgCommand());
4161
+ program.addCommand(workspaceCommand());
3488
4162
  registerLocationsCommands(program);
3489
4163
  registerObjectsCommands(program);
3490
4164
  program.parseAsync().catch((err) => {