@nodaro/cli 1.1.2

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 ADDED
@@ -0,0 +1,2677 @@
1
+ #!/usr/bin/env node
2
+ import { Command, Option } from 'commander';
3
+ import { createInterface } from 'readline/promises';
4
+ import { stdout, stdin } from 'process';
5
+ import pc3 from 'picocolors';
6
+ import { writeFileSync, readFileSync, existsSync, mkdirSync, chmodSync } from 'fs';
7
+ import { hostname, platform, homedir } from 'os';
8
+ import { join } from 'path';
9
+ import { createServer } from 'http';
10
+ import { randomBytes } from 'crypto';
11
+ import { spawn } from 'child_process';
12
+ import { createClient, StaticTokenAuth, UnauthorizedError, NodaroError, LOCATION_ASSET_TYPES, LOCATION_ATTACH_COLUMNS, OBJECT_ASSET_TYPES, OBJECT_ATTACH_COLUMNS } from '@nodaro/sdk';
13
+ import select from '@inquirer/select';
14
+ import checkbox from '@inquirer/checkbox';
15
+ import input from '@inquirer/input';
16
+ import { CHARACTER_STYLES } from '@nodaro/shared';
17
+
18
+ var __getOwnPropNames = Object.getOwnPropertyNames;
19
+ var __commonJS = (cb, mod) => function __require() {
20
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
21
+ };
22
+
23
+ // package.json
24
+ var require_package = __commonJS({
25
+ "package.json"(exports$1, module) {
26
+ module.exports = {
27
+ name: "@nodaro/cli",
28
+ version: "1.1.2",
29
+ description: "Command-line interface for Nodaro \u2014 list and run workflows, inspect jobs and executions, manage projects from the terminal.",
30
+ type: "module",
31
+ license: "Apache-2.0",
32
+ repository: {
33
+ type: "git",
34
+ url: "git+https://github.com/nodaroai/app.nodaro.ai.git",
35
+ directory: "packages/cli"
36
+ },
37
+ homepage: "https://github.com/nodaroai/app.nodaro.ai/tree/main/packages/cli#readme",
38
+ bugs: "https://github.com/nodaroai/app.nodaro.ai/issues",
39
+ bin: {
40
+ nodaro: "dist/index.js"
41
+ },
42
+ main: "./dist/index.js",
43
+ types: "./dist/index.d.ts",
44
+ files: [
45
+ "dist",
46
+ "README.md",
47
+ "LICENSE"
48
+ ],
49
+ publishConfig: {
50
+ access: "public"
51
+ },
52
+ scripts: {
53
+ build: "tsup",
54
+ dev: "tsup --watch",
55
+ test: "vitest run",
56
+ "test:watch": "vitest",
57
+ "compile:darwin-arm64": "bun build src/index.ts --compile --target=bun-darwin-arm64 --outfile=dist/binaries/nodaro-darwin-arm64",
58
+ "compile:darwin-x64": "bun build src/index.ts --compile --target=bun-darwin-x64 --outfile=dist/binaries/nodaro-darwin-x64",
59
+ "compile:linux-arm64": "bun build src/index.ts --compile --target=bun-linux-arm64 --outfile=dist/binaries/nodaro-linux-arm64",
60
+ "compile:linux-x64": "bun build src/index.ts --compile --target=bun-linux-x64 --outfile=dist/binaries/nodaro-linux-x64",
61
+ "compile:windows-x64": "bun build src/index.ts --compile --target=bun-windows-x64 --outfile=dist/binaries/nodaro-windows-x64.exe",
62
+ "compile:all": "npm run compile:darwin-arm64 && npm run compile:darwin-x64 && npm run compile:linux-arm64 && npm run compile:linux-x64 && npm run compile:windows-x64"
63
+ },
64
+ dependencies: {
65
+ "@inquirer/checkbox": "^5.1.4",
66
+ "@inquirer/confirm": "^6.0.12",
67
+ "@inquirer/input": "^5.0.12",
68
+ "@inquirer/select": "^5.1.4",
69
+ "@nodaro/sdk": "^1.1.1",
70
+ "@nodaro/shared": "^1.4.1",
71
+ commander: "^12.1.0",
72
+ picocolors: "^1.1.1",
73
+ "@nodaro/prompts": "^1.0.1"
74
+ },
75
+ devDependencies: {
76
+ tsup: "^8.5.0",
77
+ typescript: "^5.7.3",
78
+ vitest: "^4.1.2"
79
+ },
80
+ engines: {
81
+ node: ">=20"
82
+ },
83
+ keywords: [
84
+ "nodaro",
85
+ "ai",
86
+ "workflow",
87
+ "cli",
88
+ "command-line"
89
+ ]
90
+ };
91
+ }
92
+ });
93
+ function configDir() {
94
+ return process.env.NODARO_CONFIG_DIR ?? join(homedir(), ".config", "nodaro");
95
+ }
96
+ function configPath() {
97
+ return join(configDir(), "config.json");
98
+ }
99
+ function emptyConfig() {
100
+ return { default: "production", profiles: {} };
101
+ }
102
+ function loadConfig() {
103
+ const file = configPath();
104
+ if (!existsSync(file)) return emptyConfig();
105
+ try {
106
+ const raw = readFileSync(file, "utf8");
107
+ const parsed = JSON.parse(raw);
108
+ return {
109
+ default: parsed.default ?? "production",
110
+ profiles: parsed.profiles ?? {}
111
+ };
112
+ } catch {
113
+ return emptyConfig();
114
+ }
115
+ }
116
+ function saveConfig(config) {
117
+ mkdirSync(configDir(), { recursive: true, mode: 448 });
118
+ const file = configPath();
119
+ writeFileSync(file, JSON.stringify(config, null, 2) + "\n", { mode: 384 });
120
+ chmodSync(file, 384);
121
+ }
122
+ function getProfile(name) {
123
+ const config = loadConfig();
124
+ const resolved = name ?? config.default;
125
+ return { name: resolved, profile: config.profiles[resolved] };
126
+ }
127
+ function setProfile(name, profile) {
128
+ const config = loadConfig();
129
+ config.profiles[name] = profile;
130
+ if (Object.keys(config.profiles).length === 1) {
131
+ config.default = name;
132
+ }
133
+ saveConfig(config);
134
+ }
135
+ function deleteProfile(name) {
136
+ const config = loadConfig();
137
+ if (!(name in config.profiles)) return false;
138
+ delete config.profiles[name];
139
+ if (config.default === name) {
140
+ const remaining = Object.keys(config.profiles);
141
+ config.default = remaining[0] ?? "production";
142
+ }
143
+ saveConfig(config);
144
+ return true;
145
+ }
146
+ function emit(value, opts = {}) {
147
+ if (opts.json) {
148
+ const indent = process.stdout.isTTY ? 2 : void 0;
149
+ process.stdout.write(JSON.stringify(value, null, indent) + "\n");
150
+ }
151
+ }
152
+ function detail(value) {
153
+ console.log(JSON.stringify(value, null, 2));
154
+ }
155
+ function success(line) {
156
+ console.log(pc3.green("\u2713") + " " + line);
157
+ }
158
+ function info(line) {
159
+ console.log(line);
160
+ }
161
+ function dim(line) {
162
+ console.log(pc3.dim(line));
163
+ }
164
+ function warn(line) {
165
+ console.error(pc3.yellow("\u26A0") + " " + line);
166
+ }
167
+ function table(rows, columns) {
168
+ if (rows.length === 0) {
169
+ console.log(pc3.dim("(empty)"));
170
+ return;
171
+ }
172
+ const widths = {};
173
+ for (const col of columns) widths[col] = col.length;
174
+ for (const row of rows) {
175
+ for (const col of columns) {
176
+ const cell = format(row[col]);
177
+ if (cell.length > widths[col]) widths[col] = cell.length;
178
+ }
179
+ }
180
+ for (const col of columns) widths[col] = Math.min(widths[col], 60);
181
+ console.log(columns.map((c) => pc3.bold(c.padEnd(widths[c]))).join(" "));
182
+ console.log(columns.map((c) => "-".repeat(widths[c])).join(" "));
183
+ for (const row of rows) {
184
+ console.log(
185
+ columns.map((c) => {
186
+ const cell = format(row[c]);
187
+ return cell.length > widths[c] ? cell.slice(0, widths[c] - 1) + "\u2026" : cell.padEnd(widths[c]);
188
+ }).join(" ")
189
+ );
190
+ }
191
+ }
192
+ function format(value) {
193
+ if (value === null || value === void 0) return "";
194
+ if (typeof value === "string") return value;
195
+ if (typeof value === "number" || typeof value === "boolean") return String(value);
196
+ if (value instanceof Date) return value.toISOString();
197
+ return JSON.stringify(value);
198
+ }
199
+ async function loginViaBrowser(opts) {
200
+ const state = randomBytes(16).toString("hex");
201
+ const device = opts.device ?? hostname();
202
+ const timeoutMs = opts.timeoutMs ?? 5 * 60 * 1e3;
203
+ return new Promise((resolve, reject) => {
204
+ let settled = false;
205
+ let server = null;
206
+ let timeoutHandle = null;
207
+ function settle(action) {
208
+ if (settled) return;
209
+ settled = true;
210
+ if (timeoutHandle) clearTimeout(timeoutHandle);
211
+ if (server) server.close();
212
+ action();
213
+ }
214
+ server = createServer((req, res) => {
215
+ const url = new URL(req.url ?? "/", "http://127.0.0.1");
216
+ if (url.pathname !== "/callback") {
217
+ res.writeHead(404, { "Content-Type": "text/plain" });
218
+ res.end("not found");
219
+ return;
220
+ }
221
+ const error = url.searchParams.get("error");
222
+ const echoedState = url.searchParams.get("state");
223
+ const token = url.searchParams.get("token");
224
+ if (echoedState !== state) {
225
+ res.writeHead(400, { "Content-Type": "text/plain" });
226
+ res.end("state mismatch");
227
+ settle(() => reject(new Error("state mismatch \u2014 possible CSRF; aborting")));
228
+ return;
229
+ }
230
+ if (error) {
231
+ res.writeHead(200, { "Content-Type": "text/html" });
232
+ res.end(htmlPage("Authorization cancelled.", "You can close this tab and return to your terminal."));
233
+ settle(() => reject(new Error(`browser flow rejected: ${error}`)));
234
+ return;
235
+ }
236
+ if (!token) {
237
+ res.writeHead(400, { "Content-Type": "text/plain" });
238
+ res.end("missing token");
239
+ settle(() => reject(new Error("callback missing token")));
240
+ return;
241
+ }
242
+ res.writeHead(200, { "Content-Type": "text/html" });
243
+ res.end(htmlPage("Login successful.", "You can close this tab and return to your terminal."));
244
+ settle(() => resolve({ token }));
245
+ });
246
+ server.on("error", (err) => {
247
+ settle(() => reject(err));
248
+ });
249
+ server.listen(0, "127.0.0.1", () => {
250
+ const address = server.address();
251
+ if (typeof address !== "object" || address === null) {
252
+ settle(() => reject(new Error("could not bind loopback port")));
253
+ return;
254
+ }
255
+ const port = address.port;
256
+ const callback = `http://127.0.0.1:${port}/callback`;
257
+ const target = new URL("/auth/cli", opts.baseUrl);
258
+ target.searchParams.set("callback", callback);
259
+ target.searchParams.set("state", state);
260
+ target.searchParams.set("device", device);
261
+ info(`Opening browser to ${stripQuery(target.toString())} \u2026`);
262
+ dim(`(local listener: ${callback}, state: ${state.slice(0, 8)}\u2026)`);
263
+ const opened = openBrowser(target.toString());
264
+ if (!opened) {
265
+ warn("Could not auto-open browser. Open this URL manually:");
266
+ console.log(target.toString());
267
+ }
268
+ timeoutHandle = setTimeout(() => {
269
+ settle(() => reject(new Error(`timed out after ${Math.round(timeoutMs / 1e3)}s waiting for browser callback`)));
270
+ }, timeoutMs);
271
+ });
272
+ });
273
+ }
274
+ function stripQuery(url) {
275
+ const idx = url.indexOf("?");
276
+ return idx >= 0 ? url.slice(0, idx) : url;
277
+ }
278
+ function openBrowser(url) {
279
+ const cmd = platform() === "darwin" ? "open" : platform() === "win32" ? "cmd" : "xdg-open";
280
+ const args = platform() === "win32" ? ["/c", "start", "", url] : [url];
281
+ try {
282
+ const child = spawn(cmd, args, { stdio: "ignore", detached: true });
283
+ child.unref();
284
+ return true;
285
+ } catch {
286
+ return false;
287
+ }
288
+ }
289
+ function htmlPage(title, detail2) {
290
+ return `<!doctype html>
291
+ <html><head><meta charset="utf-8"><title>${escapeHtml(title)}</title>
292
+ <style>body{font-family:system-ui,sans-serif;background:#0a0a0f;color:#f0f0f5;display:flex;align-items:center;justify-content:center;min-height:100vh;margin:0}
293
+ .card{max-width:420px;padding:32px;border:1px solid #2d2d2d;border-radius:12px;background:#16161f;text-align:center}
294
+ h1{margin:0 0 8px;font-size:18px}
295
+ p{margin:0;color:#8888aa;font-size:14px}
296
+ .dot{display:inline-block;width:8px;height:8px;border-radius:50%;background:#ff0073;margin-right:8px;vertical-align:middle}</style>
297
+ </head><body><div class="card"><h1><span class="dot"></span>${escapeHtml(title)}</h1><p>${escapeHtml(detail2)}</p></div></body></html>`;
298
+ }
299
+ function escapeHtml(s) {
300
+ return s.replace(/[&<>"']/g, (c) => {
301
+ if (c === "&") return "&amp;";
302
+ if (c === "<") return "&lt;";
303
+ if (c === ">") return "&gt;";
304
+ if (c === '"') return "&quot;";
305
+ return "&#39;";
306
+ });
307
+ }
308
+
309
+ // src/commands/auth.ts
310
+ var DEFAULT_BASE_URL = "https://app.nodaro.ai";
311
+ function authCommand() {
312
+ const cmd = new Command("auth").description("manage credentials for one or more Nodaro instances");
313
+ 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) => {
314
+ let token = opts.token?.trim();
315
+ if (!token && opts.browser) {
316
+ try {
317
+ const result = await loginViaBrowser({ baseUrl: opts.baseUrl });
318
+ token = result.token;
319
+ } catch (err) {
320
+ const detail2 = err instanceof Error ? err.message : String(err);
321
+ warn(`browser flow failed: ${detail2}`);
322
+ warn("falling back to manual token paste");
323
+ token = (await promptToken()).trim();
324
+ }
325
+ } else if (!token) {
326
+ token = (await promptToken()).trim();
327
+ }
328
+ if (!token) {
329
+ warn("no token provided \u2014 aborting");
330
+ process.exit(1);
331
+ }
332
+ setProfile(opts.profile, { baseUrl: opts.baseUrl, token });
333
+ success(`saved profile "${opts.profile}" \u2192 ${opts.baseUrl}`);
334
+ dim(`config: ${configPath()} (chmod 0600)`);
335
+ });
336
+ cmd.command("status").description("show the current profile (token is masked)").option("--profile <name>", "profile name (defaults to the configured default)").option("--json", "machine-readable output").action((opts) => {
337
+ const { name, profile } = getProfile(opts.profile);
338
+ if (!profile) {
339
+ if (opts.json) emit({ profile: name, signedIn: false }, opts);
340
+ else warn(`no credentials for profile "${name}"`);
341
+ process.exit(1);
342
+ }
343
+ if (opts.json) {
344
+ emit({ profile: name, baseUrl: profile.baseUrl, tokenMasked: maskToken(profile.token), signedIn: true }, opts);
345
+ } else {
346
+ info(`profile: ${pc3.cyan(name)}`);
347
+ info(`baseUrl: ${profile.baseUrl}`);
348
+ info(`token: ${maskToken(profile.token)}`);
349
+ }
350
+ });
351
+ cmd.command("logout").description("delete a stored profile").option("--profile <name>", "profile name", "production").action((opts) => {
352
+ if (deleteProfile(opts.profile)) {
353
+ success(`removed profile "${opts.profile}"`);
354
+ } else {
355
+ warn(`profile "${opts.profile}" not found`);
356
+ process.exit(1);
357
+ }
358
+ });
359
+ return cmd;
360
+ }
361
+ async function promptToken() {
362
+ const rl = createInterface({ input: stdin, output: stdout, terminal: true });
363
+ process.stdout.write("token: ");
364
+ const line = await rl.question("");
365
+ rl.close();
366
+ return line;
367
+ }
368
+ function maskToken(token) {
369
+ if (token.length <= 12) return "****";
370
+ return token.slice(0, 8) + "\u2026" + token.slice(-4);
371
+ }
372
+ function buildClient(profileName) {
373
+ const { name, profile } = getProfile(profileName);
374
+ if (!profile) {
375
+ console.error(pc3.red(`\u2717 no credentials for profile "${name}"`));
376
+ console.error(pc3.dim(` run: nodaro auth login${profileName ? ` --profile ${profileName}` : ""}`));
377
+ process.exit(1);
378
+ }
379
+ return createClient({
380
+ baseUrl: profile.baseUrl,
381
+ auth: new StaticTokenAuth(profile.token)
382
+ });
383
+ }
384
+ function handleError(err) {
385
+ if (err instanceof UnauthorizedError) {
386
+ console.error(pc3.red("\u2717 unauthorized \u2014 token missing, expired, or invalid"));
387
+ console.error(pc3.dim(" run: nodaro auth login"));
388
+ process.exit(1);
389
+ }
390
+ if (err instanceof NodaroError) {
391
+ console.error(pc3.red(`\u2717 ${err.message}`));
392
+ if (err.code) console.error(pc3.dim(` code: ${err.code}`));
393
+ process.exit(1);
394
+ }
395
+ if (err instanceof Error) {
396
+ console.error(pc3.red(`\u2717 ${err.message}`));
397
+ process.exit(1);
398
+ }
399
+ console.error(pc3.red("\u2717 unknown error"), err);
400
+ process.exit(1);
401
+ }
402
+
403
+ // src/commands/projects.ts
404
+ function projectsCommand() {
405
+ const cmd = new Command("projects").description("list, inspect, and manage projects");
406
+ cmd.command("list").description("list all projects accessible to the current token").option("--profile <name>").option("--json").action(async (opts) => {
407
+ try {
408
+ const client = buildClient(opts.profile);
409
+ const result = await client.projects.list();
410
+ if (opts.json) {
411
+ emit(result.data, opts);
412
+ return;
413
+ }
414
+ table(
415
+ result.data.map((p) => ({
416
+ id: p.id,
417
+ name: p.name,
418
+ createdAt: p.createdAt
419
+ })),
420
+ ["id", "name", "createdAt"]
421
+ );
422
+ } catch (err) {
423
+ handleError(err);
424
+ }
425
+ });
426
+ cmd.command("get <id>").description("show one project by id").option("--profile <name>").option("--json").action(async (id, opts) => {
427
+ try {
428
+ const client = buildClient(opts.profile);
429
+ const result = await client.projects.get(id);
430
+ if (opts.json) emit(result.data, opts);
431
+ else detail(result.data);
432
+ } catch (err) {
433
+ handleError(err);
434
+ }
435
+ });
436
+ cmd.command("create").description("create a new project").requiredOption("--name <name>", "project name").option("--description <desc>", "project description").option("--profile <name>").option("--json").action(async (opts) => {
437
+ try {
438
+ const client = buildClient(opts.profile);
439
+ const result = await client.projects.create({
440
+ name: opts.name,
441
+ description: opts.description
442
+ });
443
+ if (opts.json) {
444
+ emit(result.data, opts);
445
+ return;
446
+ }
447
+ success(`created project ${result.data.id}`);
448
+ detail(result.data);
449
+ } catch (err) {
450
+ handleError(err);
451
+ }
452
+ });
453
+ cmd.command("update <id>").description("update a project's name and/or description").option("--name <name>", "new project name").option("--description <desc>", "new project description").option("--profile <name>").option("--json").action(async (id, opts) => {
454
+ try {
455
+ if (opts.name === void 0 && opts.description === void 0) {
456
+ throw new Error("nothing to update \u2014 provide --name and/or --description");
457
+ }
458
+ const client = buildClient(opts.profile);
459
+ const result = await client.projects.update(id, {
460
+ name: opts.name,
461
+ description: opts.description
462
+ });
463
+ if (opts.json) {
464
+ emit(result.data, opts);
465
+ return;
466
+ }
467
+ success(`updated project ${result.data.id}`);
468
+ detail(result.data);
469
+ } catch (err) {
470
+ handleError(err);
471
+ }
472
+ });
473
+ cmd.command("delete <id>").description("delete a project").option("--profile <name>").option("--json").action(async (id, opts) => {
474
+ try {
475
+ const client = buildClient(opts.profile);
476
+ await client.projects.delete(id);
477
+ if (opts.json) {
478
+ emit({ success: true, id }, opts);
479
+ return;
480
+ }
481
+ success(`Deleted project ${id}`);
482
+ } catch (err) {
483
+ handleError(err);
484
+ }
485
+ });
486
+ return cmd;
487
+ }
488
+
489
+ // src/util.ts
490
+ function collectVariadic(value, previous) {
491
+ return [...previous ?? [], value];
492
+ }
493
+ function parseCount(raw) {
494
+ if (raw === "2") return 2;
495
+ if (raw === "4") return 4;
496
+ return 1;
497
+ }
498
+ var TERMINAL = /* @__PURE__ */ new Set([
499
+ "completed",
500
+ "failed",
501
+ "cancelled"
502
+ ]);
503
+ async function watchUntilTerminal(opts) {
504
+ const intervalMs = opts.intervalMs ?? 2e3;
505
+ const start = Date.now();
506
+ let lastStatus = "";
507
+ for (; ; ) {
508
+ let result;
509
+ try {
510
+ result = await opts.fetch();
511
+ } catch (err) {
512
+ const errMsg = err instanceof Error ? err.message : String(err);
513
+ info(`[${elapsed(start)}s] poll failed (will retry): ${errMsg}`);
514
+ await sleep(intervalMs);
515
+ continue;
516
+ }
517
+ const status = result.data.status;
518
+ if (status !== lastStatus) {
519
+ info(`[${elapsed(start)}s] ${opts.label} \u2192 ${status}`);
520
+ lastStatus = status;
521
+ }
522
+ if (TERMINAL.has(status)) {
523
+ if (opts.json) emit(result.data, opts);
524
+ else if (status === "completed") success(`completed in ${elapsed(start)}s`);
525
+ else process.exit(status === "failed" ? 2 : 130);
526
+ return;
527
+ }
528
+ await sleep(intervalMs);
529
+ }
530
+ }
531
+ function elapsed(startMs) {
532
+ return ((Date.now() - startMs) / 1e3).toFixed(1);
533
+ }
534
+ function sleep(ms) {
535
+ return new Promise((resolve) => setTimeout(resolve, ms));
536
+ }
537
+
538
+ // src/commands/workflows.ts
539
+ function readJsonObject(path, flag) {
540
+ let raw;
541
+ try {
542
+ raw = readFileSync(path, "utf8");
543
+ } catch (err) {
544
+ throw new Error(`cannot read ${flag} ${path}: ${err.message}`);
545
+ }
546
+ let parsed;
547
+ try {
548
+ parsed = JSON.parse(raw);
549
+ } catch (err) {
550
+ throw new Error(`${flag} ${path} is not valid JSON: ${err.message}`);
551
+ }
552
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
553
+ throw new Error(`${flag} ${path} must contain a JSON object at the top level`);
554
+ }
555
+ return parsed;
556
+ }
557
+ function workflowsCommand() {
558
+ const cmd = new Command("workflows").description("list, run, and manage workflows");
559
+ cmd.command("list").description("list workflows in a project").requiredOption("--project <projectId>", "project id (run `nodaro projects list` to find it)").option("--profile <name>").option("--json").action(async (opts) => {
560
+ try {
561
+ const client = buildClient(opts.profile);
562
+ const result = await client.workflows.list({ projectId: opts.project });
563
+ if (opts.json) {
564
+ emit(result.data, opts);
565
+ return;
566
+ }
567
+ table(
568
+ result.data.map((w) => ({
569
+ id: w.id,
570
+ name: w.name,
571
+ updatedAt: w.updatedAt
572
+ })),
573
+ ["id", "name", "updatedAt"]
574
+ );
575
+ } catch (err) {
576
+ handleError(err);
577
+ }
578
+ });
579
+ cmd.command("get <id>").description("show one workflow by id (includes nodes/edges)").option("--profile <name>").option("--json").action(async (id, opts) => {
580
+ try {
581
+ const client = buildClient(opts.profile);
582
+ const result = await client.workflows.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("create").description("create a workflow in a project (optionally from an exported JSON bundle)").requiredOption("--project <projectId>", "project id (run `nodaro projects list` to find it)").requiredOption("--name <name>", "workflow name").option("--file <jsonPath>", "path to a WorkflowExport JSON bundle to import as the new workflow").option("--profile <name>").option("--json").action(async (opts) => {
590
+ try {
591
+ const client = buildClient(opts.profile);
592
+ let result;
593
+ if (opts.file) {
594
+ const bundle = readJsonObject(opts.file, "--file");
595
+ result = await client.workflows.import({
596
+ ...bundle,
597
+ name: opts.name,
598
+ projectId: opts.project
599
+ });
600
+ } else {
601
+ result = await client.workflows.create({ projectId: opts.project, name: opts.name });
602
+ }
603
+ if (opts.json) {
604
+ emit(result.data, opts);
605
+ return;
606
+ }
607
+ success(`created workflow ${result.data.id} (${result.data.name})`);
608
+ } catch (err) {
609
+ handleError(err);
610
+ }
611
+ });
612
+ cmd.command("update <id>").description("update a workflow's name and/or its nodes/edges/settings from a JSON file").option("--name <name>", "new workflow name").option("--file <jsonPath>", "path to a JSON file with `nodes`/`edges`/`settings` to write").option("--profile <name>").option("--json").action(async (id, opts) => {
613
+ try {
614
+ if (opts.name === void 0 && !opts.file) {
615
+ throw new Error("nothing to update \u2014 pass --name and/or --file");
616
+ }
617
+ const client = buildClient(opts.profile);
618
+ const body = {};
619
+ if (opts.name !== void 0) body.name = opts.name;
620
+ if (opts.file) {
621
+ const parsed = readJsonObject(opts.file, "--file");
622
+ if (parsed.nodes !== void 0) body.nodes = parsed.nodes;
623
+ if (parsed.edges !== void 0) body.edges = parsed.edges;
624
+ if (parsed.settings !== void 0) body.settings = parsed.settings;
625
+ }
626
+ const result = await client.workflows.update(id, body);
627
+ if (opts.json) emit(result.data, opts);
628
+ else success(`updated workflow ${result.data.id} (${result.data.name})`);
629
+ } catch (err) {
630
+ handleError(err);
631
+ }
632
+ });
633
+ cmd.command("delete <id>").description("delete a workflow").option("--profile <name>").option("--json").action(async (id, opts) => {
634
+ try {
635
+ const client = buildClient(opts.profile);
636
+ await client.workflows.delete(id);
637
+ if (opts.json) emit({ id, deleted: true }, opts);
638
+ else success(`deleted workflow ${id}`);
639
+ } catch (err) {
640
+ handleError(err);
641
+ }
642
+ });
643
+ cmd.command("export <id>").description("export a workflow as a portable JSON bundle").option("--with-assets", "include character/object/location entity data in the bundle").option("--output <path>", "write the bundle to this file instead of stdout").option("--profile <name>").option("--json").action(async (id, opts) => {
644
+ try {
645
+ const client = buildClient(opts.profile);
646
+ const result = await client.workflows.export(id, { assets: opts.withAssets ?? false });
647
+ if (opts.output) {
648
+ writeFileSync(opts.output, JSON.stringify(result.data, null, 2) + "\n");
649
+ success(`exported workflow ${id} \u2192 ${opts.output}`);
650
+ return;
651
+ }
652
+ detail(result.data);
653
+ } catch (err) {
654
+ handleError(err);
655
+ }
656
+ });
657
+ cmd.command("import <file>").description("import a WorkflowExport JSON bundle into a project").requiredOption("--project <projectId>", "project id (run `nodaro projects list` to find it)").option("--profile <name>").option("--json").action(async (file, opts) => {
658
+ try {
659
+ const client = buildClient(opts.profile);
660
+ const bundle = readJsonObject(file, "<file>");
661
+ const result = await client.workflows.import({
662
+ ...bundle,
663
+ projectId: opts.project
664
+ });
665
+ if (opts.json) {
666
+ emit(result.data, opts);
667
+ return;
668
+ }
669
+ success(`imported workflow ${result.data.id} (${result.data.name})`);
670
+ } catch (err) {
671
+ handleError(err);
672
+ }
673
+ });
674
+ cmd.command("run <id>").description("trigger a workflow run; prints execution id (use --watch to follow)").option("--profile <name>").option("--json").option("--watch", "poll execution status until completion").option("--node <ids...>", "execute only these node ids (space-separated)").action(async (id, opts) => {
675
+ try {
676
+ const client = buildClient(opts.profile);
677
+ const params = opts.node ? { nodeIds: opts.node } : {};
678
+ const result = await client.workflows.run(id, params);
679
+ if (opts.json && !opts.watch) {
680
+ emit(result, opts);
681
+ return;
682
+ }
683
+ success(`execution ${result.executionId} (${result.status})`);
684
+ if (!opts.watch) {
685
+ dim(`follow: nodaro executions get ${result.executionId} --watch`);
686
+ return;
687
+ }
688
+ await watchExecution(client, result.executionId, opts);
689
+ } catch (err) {
690
+ handleError(err);
691
+ }
692
+ });
693
+ return cmd;
694
+ }
695
+ async function watchExecution(client, executionId, opts) {
696
+ return watchUntilTerminal({
697
+ fetch: () => client.executions.get(executionId),
698
+ label: executionId,
699
+ ...opts
700
+ });
701
+ }
702
+ function jobsCommand() {
703
+ const cmd = new Command("jobs").description("inspect and cancel individual jobs");
704
+ cmd.command("get <id>").description("show one job by id").option("--profile <name>").option("--json").action(async (id, opts) => {
705
+ try {
706
+ const client = buildClient(opts.profile);
707
+ const result = await client.jobs.get(id);
708
+ if (opts.json) emit(result.data, opts);
709
+ else detail(result.data);
710
+ } catch (err) {
711
+ handleError(err);
712
+ }
713
+ });
714
+ cmd.command("cancel <id>").description("cancel a pending or running job").option("--profile <name>").option("--json").action(async (id, opts) => {
715
+ try {
716
+ const client = buildClient(opts.profile);
717
+ const result = await client.jobs.cancel(id);
718
+ if (opts.json) emit(result, opts);
719
+ else success(`cancelled job ${id}`);
720
+ } catch (err) {
721
+ handleError(err);
722
+ }
723
+ });
724
+ return cmd;
725
+ }
726
+ function executionsCommand() {
727
+ const cmd = new Command("executions").description("inspect and cancel workflow executions");
728
+ cmd.command("get <id>").description("show one execution by id (use --watch to follow until completion)").option("--profile <name>").option("--json").option("--watch", "poll until terminal status (completed/failed/cancelled)").action(async (id, opts) => {
729
+ try {
730
+ const client = buildClient(opts.profile);
731
+ if (opts.watch) {
732
+ await watchExecution(client, id, opts);
733
+ return;
734
+ }
735
+ const result = await client.executions.get(id);
736
+ if (opts.json) emit(result.data, opts);
737
+ else detail(result.data);
738
+ } catch (err) {
739
+ handleError(err);
740
+ }
741
+ });
742
+ cmd.command("cancel <id>").description("cancel an active execution").option("--profile <name>").option("--json").option("--mode <mode>", "cancellation mode: cancelled (immediate) or stopping (finish current level)", "cancelled").action(async (id, opts) => {
743
+ try {
744
+ const client = buildClient(opts.profile);
745
+ const params = opts.mode === "stopping" ? { mode: "after_current" } : {};
746
+ const result = await client.executions.cancel(id, params);
747
+ if (opts.json) emit(result, opts);
748
+ else success(`cancelled execution ${id} (mode: ${opts.mode ?? "cancelled"})`);
749
+ } catch (err) {
750
+ handleError(err);
751
+ }
752
+ });
753
+ return cmd;
754
+ }
755
+ function parseBoolFlag(raw, flagName) {
756
+ if (raw === "true") return true;
757
+ if (raw === "false") return false;
758
+ throw new Error(`--${flagName} must be "true" or "false" (got "${raw}")`);
759
+ }
760
+ function parseParamPairs(pairs) {
761
+ if (!pairs || pairs.length === 0) return {};
762
+ const out = {};
763
+ for (const raw of pairs) {
764
+ const eq = raw.indexOf("=");
765
+ if (eq < 0) {
766
+ throw new Error(`invalid param "${raw}": expected key=value`);
767
+ }
768
+ const key = raw.slice(0, eq).trim();
769
+ const value = raw.slice(eq + 1);
770
+ if (!key) throw new Error(`invalid param "${raw}": empty key`);
771
+ out[key] = coerce(value);
772
+ }
773
+ return out;
774
+ }
775
+ function parseSelectionPairs(pairs) {
776
+ if (!pairs || pairs.length === 0) return [];
777
+ const out = [];
778
+ for (const raw of pairs) {
779
+ const eq = raw.indexOf("=");
780
+ if (eq < 0) throw new Error(`invalid --selection "${raw}": expected category=value`);
781
+ const category = raw.slice(0, eq).trim();
782
+ const value = raw.slice(eq + 1);
783
+ if (!category) throw new Error(`invalid --selection "${raw}": empty category`);
784
+ out.push({ category, value, isCustom: false });
785
+ }
786
+ return out;
787
+ }
788
+ function coerce(value) {
789
+ if (value === "true") return true;
790
+ if (value === "false") return false;
791
+ if (value === "null") return null;
792
+ if (/^-?\d+$/.test(value)) return Number(value);
793
+ if (/^-?\d*\.\d+$/.test(value)) return Number(value);
794
+ const first = value.trimStart()[0];
795
+ if (first === "[" || first === "{" || first === '"') {
796
+ try {
797
+ return JSON.parse(value);
798
+ } catch {
799
+ return value;
800
+ }
801
+ }
802
+ return value;
803
+ }
804
+ function loadParamsFile(path) {
805
+ let raw;
806
+ try {
807
+ raw = readFileSync(path, "utf8");
808
+ } catch (err) {
809
+ throw new Error(`cannot read --params-file ${path}: ${err.message}`);
810
+ }
811
+ let parsed;
812
+ try {
813
+ parsed = JSON.parse(raw);
814
+ } catch (err) {
815
+ throw new Error(`--params-file ${path} is not valid JSON: ${err.message}`);
816
+ }
817
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
818
+ throw new Error(`--params-file ${path} must contain a JSON object at the top level`);
819
+ }
820
+ return parsed;
821
+ }
822
+ function mergeParams(fromFile, fromFlags) {
823
+ return { ...fromFile, ...fromFlags };
824
+ }
825
+ function resolveParams(pairs, filePath) {
826
+ const fromFile = filePath ? loadParamsFile(filePath) : {};
827
+ const fromFlags = parseParamPairs(pairs);
828
+ return mergeParams(fromFile, fromFlags);
829
+ }
830
+ function isInteractive() {
831
+ return Boolean(stdin.isTTY) && Boolean(stdout.isTTY);
832
+ }
833
+ async function pickFromList(opts) {
834
+ return select({
835
+ message: opts.message,
836
+ choices: opts.choices,
837
+ pageSize: opts.pageSize ?? 12,
838
+ loop: false,
839
+ default: opts.default
840
+ });
841
+ }
842
+ async function ask(opts) {
843
+ const value = await input({
844
+ message: opts.message,
845
+ default: opts.default,
846
+ validate: (v) => {
847
+ if (!v.trim()) return "this field is required";
848
+ return true;
849
+ }
850
+ });
851
+ return value.trim();
852
+ }
853
+ async function pickManyFromList(opts) {
854
+ return checkbox({
855
+ message: opts.message,
856
+ choices: opts.choices,
857
+ pageSize: opts.pageSize ?? 12,
858
+ loop: false
859
+ });
860
+ }
861
+
862
+ // src/commands/apps.ts
863
+ async function pickAppInteractively(client) {
864
+ if (!isInteractive()) {
865
+ warn("missing <slug> and stdin is not a TTY \u2014 provide a slug or pipe input");
866
+ process.exit(2);
867
+ }
868
+ const result = await client.apps.list({ limit: 50 });
869
+ if (result.data.length === 0) {
870
+ warn("no published apps available");
871
+ process.exit(1);
872
+ }
873
+ return pickFromList({
874
+ message: "Pick an app to run:",
875
+ choices: result.data.map((a) => ({
876
+ name: `${a.name} (${a.slug})`,
877
+ value: a.slug,
878
+ description: a.creatorName ?? a.creatorId
879
+ }))
880
+ });
881
+ }
882
+ function rejectPositionalInputs(extras, slug) {
883
+ if (!extras || extras.length === 0) return;
884
+ const looksLikeObject = extras[0].trim().startsWith("{");
885
+ if (looksLikeObject) {
886
+ warn(`Unexpected positional argument: ${JSON.stringify(extras[0])}`);
887
+ warn(`Pass inputs via --input flags or a JSON file:`);
888
+ warn(` nodaro apps run ${slug} --input prompt="..."`);
889
+ warn(` nodaro apps run ${slug} --params-file inputs.json`);
890
+ } else {
891
+ warn(`Unexpected positional argument(s): ${extras.map((e) => JSON.stringify(e)).join(" ")}`);
892
+ warn(`Did you forget --input? Try: nodaro apps run ${slug} --input prompt=...`);
893
+ }
894
+ process.exit(1);
895
+ }
896
+ function appsCommand() {
897
+ const cmd = new Command("apps").description("browse and run published apps (workflows wrapped in a curated UI)");
898
+ cmd.command("list").description("browse published apps (paginated)").option("--search <query>", "substring match on name/description").option("--limit <n>", "page size (max 50)", (v) => parseInt(v, 10)).option("--cursor <token>", "pagination cursor from a previous page").option("--category <slug>", "filter to a single category").option("--profile <name>").option("--json").action(async (opts) => {
899
+ try {
900
+ const client = buildClient(opts.profile);
901
+ const result = await client.apps.list({
902
+ search: opts.search,
903
+ limit: opts.limit,
904
+ cursor: opts.cursor,
905
+ category: opts.category
906
+ });
907
+ if (opts.json) {
908
+ emit(result, opts);
909
+ return;
910
+ }
911
+ table(
912
+ result.data.map((a) => ({
913
+ slug: a.slug,
914
+ name: a.name,
915
+ creator: a.creatorName ?? a.creatorId,
916
+ runs: a.runCount ?? 0
917
+ })),
918
+ ["slug", "name", "creator", "runs"]
919
+ );
920
+ if (result.nextCursor) dim(`next page: --cursor ${result.nextCursor}`);
921
+ } catch (err) {
922
+ handleError(err);
923
+ }
924
+ });
925
+ cmd.command("get <slug>").description("show one app's metadata + input schema").option("--profile <name>").option("--json").action(async (slug, opts) => {
926
+ try {
927
+ const client = buildClient(opts.profile);
928
+ const result = await client.apps.get(slug);
929
+ if (opts.json) emit(result.data, opts);
930
+ else detail(result.data);
931
+ } catch (err) {
932
+ handleError(err);
933
+ }
934
+ });
935
+ cmd.command("run [slug] [extras...]").description("trigger an app run. Inputs go through --input k=v (repeat) or --params-file inputs.json. Omit <slug> for an interactive picker.").option("--input <pairs...>", `input value, repeat or space-separate; JSON arrays/objects supported (e.g. --input prompt="hi" --input 'tags=["a","b"]')`, collectVariadic).option("--params-file <path>", "JSON file with the full inputs object (--input flags override matching keys)").option("--watch", "follow the resulting execution until completion").option("--profile <name>").option("--json").addHelpText("after", `
936
+ Examples:
937
+ $ nodaro apps run hair-styler-dd3erw --input prompt="curly red hair" --watch
938
+ $ echo '{"prompt":"hi","duration":8}' > inputs.json
939
+ $ nodaro apps run hair-styler-dd3erw --params-file inputs.json --watch
940
+
941
+ Tip: \`nodaro apps get <slug>\` shows the input schema for that app.`).action(async (slug, extras, opts) => {
942
+ rejectPositionalInputs(extras, slug ?? "<slug>");
943
+ try {
944
+ const client = buildClient(opts.profile);
945
+ const resolvedSlug = slug ?? await pickAppInteractively(client);
946
+ const inputs = resolveParams(opts.input, opts.paramsFile);
947
+ const result = await client.apps.run(resolvedSlug, inputs);
948
+ if (opts.json && !opts.watch) {
949
+ emit(result, opts);
950
+ return;
951
+ }
952
+ success(`execution ${result.executionId} (${result.status})`);
953
+ if (!opts.watch) {
954
+ dim(`follow: nodaro executions get ${result.executionId} --watch`);
955
+ return;
956
+ }
957
+ await watchExecution(client, result.executionId, opts);
958
+ } catch (err) {
959
+ handleError(err);
960
+ }
961
+ });
962
+ cmd.command("runs <slug>").description("list past runs of an app (caller must own the app or the runs)").option("--limit <n>", "page size", (v) => parseInt(v, 10)).option("--cursor <token>").option("--profile <name>").option("--json").action(async (slug, opts) => {
963
+ try {
964
+ const client = buildClient(opts.profile);
965
+ const result = await client.apps.listRuns(slug, { limit: opts.limit, cursor: opts.cursor });
966
+ if (opts.json) {
967
+ emit(result, opts);
968
+ return;
969
+ }
970
+ table(
971
+ result.data.map((r) => ({
972
+ id: r.id,
973
+ status: r.status,
974
+ executionId: r.executionId,
975
+ startedAt: r.startedAt
976
+ })),
977
+ ["id", "status", "executionId", "startedAt"]
978
+ );
979
+ if (result.nextCursor) dim(`next page: --cursor ${result.nextCursor}`);
980
+ } catch (err) {
981
+ handleError(err);
982
+ }
983
+ });
984
+ cmd.command("run-get <slug> <runId>").description("show one app-run by id").option("--profile <name>").option("--json").action(async (slug, runId, opts) => {
985
+ try {
986
+ const client = buildClient(opts.profile);
987
+ const result = await client.apps.getRun(slug, runId);
988
+ if (opts.json) emit(result.data, opts);
989
+ else detail(result.data);
990
+ } catch (err) {
991
+ handleError(err);
992
+ }
993
+ });
994
+ return cmd;
995
+ }
996
+ async function pickNodeInteractively(client) {
997
+ if (!isInteractive()) {
998
+ warn("missing <type> and stdin is not a TTY \u2014 provide a node type or pipe input");
999
+ process.exit(2);
1000
+ }
1001
+ const result = await client.nodes.list();
1002
+ if (result.data.length === 0) {
1003
+ warn("no node types available (server returned an empty list)");
1004
+ process.exit(1);
1005
+ }
1006
+ return pickFromList({
1007
+ message: "Pick a node type to run:",
1008
+ choices: result.data.map((n) => ({
1009
+ name: `${n.label} \u2014 ${n.type}`,
1010
+ value: n.type,
1011
+ description: `${n.category} \u2192 ${n.outputType}${n.creditCost ? ` (${n.creditCost} cr)` : ""}`
1012
+ }))
1013
+ });
1014
+ }
1015
+ function rejectPositionalParams(extras, example) {
1016
+ if (!extras || extras.length === 0) return;
1017
+ const looksLikeObject = extras[0].trim().startsWith("{");
1018
+ if (looksLikeObject) {
1019
+ warn(`Unexpected positional argument: ${JSON.stringify(extras[0])}`);
1020
+ warn(`Pass parameters via --param flags or a JSON file:`);
1021
+ warn(` ${example.cmd} --param ${example.key}="..."`);
1022
+ warn(` ${example.cmd} --params-file body.json`);
1023
+ } else {
1024
+ warn(`Unexpected positional argument(s): ${extras.map((e) => JSON.stringify(e)).join(" ")}`);
1025
+ warn(`Did you forget --param? Try: ${example.cmd} --param ${example.key}=...`);
1026
+ }
1027
+ process.exit(1);
1028
+ }
1029
+ function nodesCommand() {
1030
+ const cmd = new Command("nodes").description("list available node types and run a single node directly (no workflow)");
1031
+ cmd.command("list").description("list all known node types \u2014 same data the editor uses").option("--category <name>", "filter to one category (input, parameter, ai-image, ai-video, ai-audio, ai-text, processing, composition, output, control, entity, trigger, utility)").option("--profile <name>").option("--json").action(async (opts) => {
1032
+ try {
1033
+ const client = buildClient(opts.profile);
1034
+ const result = await client.nodes.list();
1035
+ const filtered = opts.category ? result.data.filter((n) => n.category === opts.category) : result.data;
1036
+ if (opts.json) {
1037
+ emit(filtered, opts);
1038
+ return;
1039
+ }
1040
+ table(
1041
+ filtered.map((n) => ({
1042
+ type: n.type,
1043
+ label: n.label,
1044
+ category: n.category,
1045
+ outputType: n.outputType,
1046
+ credits: n.creditCost ?? "",
1047
+ providers: n.providers ? n.providers.length : ""
1048
+ })),
1049
+ ["type", "label", "category", "outputType", "credits", "providers"]
1050
+ );
1051
+ } catch (err) {
1052
+ handleError(err);
1053
+ }
1054
+ });
1055
+ cmd.command("get <type>").description("show one node descriptor (full input schema, providers, capabilities)").option("--profile <name>").option("--json").action(async (type, opts) => {
1056
+ try {
1057
+ const client = buildClient(opts.profile);
1058
+ const result = await client.nodes.get(type);
1059
+ if (opts.json) emit(result.data, opts);
1060
+ else detail(result.data);
1061
+ } catch (err) {
1062
+ handleError(err);
1063
+ }
1064
+ });
1065
+ 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", `
1066
+ Examples:
1067
+ $ nodaro nodes run generate-image --param prompt="a snow leopard" --watch
1068
+ $ nodaro nodes run generate-image --param prompt="hi" --param provider=flux --param resolution=2K --watch
1069
+ $ echo '{"prompt":"hi","provider":"flux"}' > body.json
1070
+ $ nodaro nodes run generate-image --params-file body.json --watch
1071
+
1072
+ Structured references (the editor's wired-reference shape) \u2014 let a {image:N} prompt
1073
+ token bind a labeled reference, assembled server-side into @image_N (same as the
1074
+ canvas/API/MCP/SDK). Pass them via --params-file (arrays need the JSON file, not --param):
1075
+ $ cat > body.json <<'JSON'
1076
+ {"prompt":"the {image:1:hero} runs","provider":"seedance-2",
1077
+ "connectedReferences":[{"id":"h1","defaultName":"hero","source":"manual","url":"https://cdn.example/hero.png"}]}
1078
+ JSON
1079
+ $ nodaro nodes run generate-video --params-file body.json --watch
1080
+
1081
+ Tip: \`nodaro nodes get <type>\` shows the full input schema (required fields, providers, capabilities).`).action(
1082
+ async (type, extras, opts) => {
1083
+ rejectPositionalParams(extras, { cmd: `nodaro nodes run ${type ?? "<type>"}`, key: "prompt" });
1084
+ try {
1085
+ const client = buildClient(opts.profile);
1086
+ const resolvedType = type ?? await pickNodeInteractively(client);
1087
+ const params = resolveParams(opts.param, opts.paramsFile);
1088
+ const result = await client.nodes.run(resolvedType, params);
1089
+ const jobId = typeof result === "object" && result && "jobId" in result ? result.jobId : null;
1090
+ if (opts.json && !opts.watch) {
1091
+ emit(result, opts);
1092
+ return;
1093
+ }
1094
+ if (!jobId) {
1095
+ success(`${resolvedType} completed (inline)`);
1096
+ detail(result);
1097
+ return;
1098
+ }
1099
+ success(`job ${jobId} queued`);
1100
+ if (!opts.watch) {
1101
+ dim(`follow: nodaro jobs get ${jobId}`);
1102
+ return;
1103
+ }
1104
+ await watchUntilTerminal({
1105
+ fetch: () => client.jobs.get(jobId),
1106
+ label: jobId,
1107
+ intervalMs: opts.pollInterval,
1108
+ ...opts
1109
+ });
1110
+ } catch (err) {
1111
+ handleError(err);
1112
+ }
1113
+ }
1114
+ );
1115
+ return cmd;
1116
+ }
1117
+ var STYLE_DESCRIPTION = `one of ${CHARACTER_STYLES.join("|")}`;
1118
+ function charactersCommand() {
1119
+ const cmd = new Command("characters").description(
1120
+ "list, inspect, and manage characters; trigger portrait / asset / motion generation"
1121
+ );
1122
+ 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(
1123
+ async (opts) => {
1124
+ try {
1125
+ const client = buildClient(opts.profile);
1126
+ const limitNum = opts.limit !== void 0 ? Number.parseInt(opts.limit, 10) : void 0;
1127
+ if (limitNum !== void 0 && (!Number.isFinite(limitNum) || limitNum <= 0)) {
1128
+ throw new Error(`--limit must be a positive integer (got ${opts.limit})`);
1129
+ }
1130
+ const result = await client.characters.list({
1131
+ projectId: opts.project,
1132
+ archived: opts.archived,
1133
+ limit: limitNum
1134
+ });
1135
+ if (opts.json) {
1136
+ emit(result.characters, opts);
1137
+ return;
1138
+ }
1139
+ table(
1140
+ result.characters.map((c) => ({
1141
+ id: c.id,
1142
+ name: c.name,
1143
+ portrait: c.sourceImageUrl ? "yes" : "no",
1144
+ updatedAt: c.updatedAt
1145
+ })),
1146
+ ["id", "name", "portrait", "updatedAt"]
1147
+ );
1148
+ } catch (err) {
1149
+ handleError(err);
1150
+ }
1151
+ }
1152
+ );
1153
+ cmd.command("get <id>").description("show one character by id (full asset arrays + pending jobs)").option("--profile <name>").option("--json").action(async (id, opts) => {
1154
+ try {
1155
+ const client = buildClient(opts.profile);
1156
+ const result = await client.characters.get(id);
1157
+ if (opts.json) emit(result, opts);
1158
+ else detail(result);
1159
+ } catch (err) {
1160
+ handleError(err);
1161
+ }
1162
+ });
1163
+ cmd.command("create").description("create a new character row (no portrait yet \u2014 call `generate` next)").requiredOption("--name <name>", "display name (unique per user)").option("--description <desc>", "freeform identity notes").option("--gender <gender>").option("--style <style>", STYLE_DESCRIPTION).option("--base-outfit <outfit>", "default wardrobe description").option("--seed-prompt <prompt>", "scaffold prompt for portrait generation").option("--node-id <id>", "canvas node id to bind to", "mcp-managed").option("--project <projectId>", "drop the row into this project").option("--profile <name>").option("--json").action(
1164
+ async (opts) => {
1165
+ try {
1166
+ const client = buildClient(opts.profile);
1167
+ const result = await client.characters.create({
1168
+ nodeId: opts.nodeId,
1169
+ projectId: opts.project,
1170
+ name: opts.name,
1171
+ description: opts.description,
1172
+ gender: opts.gender,
1173
+ // Style is validated server-side; we pass through as-is.
1174
+ style: opts.style,
1175
+ baseOutfit: opts.baseOutfit,
1176
+ seedPrompt: opts.seedPrompt
1177
+ });
1178
+ if (opts.json) {
1179
+ emit(result, opts);
1180
+ return;
1181
+ }
1182
+ success(`created character ${result.id} (${result.name ?? opts.name})`);
1183
+ } catch (err) {
1184
+ handleError(err);
1185
+ }
1186
+ }
1187
+ );
1188
+ cmd.command("update <id>").description("update identity fields on an existing character").option("--name <name>").option("--description <desc>").option("--gender <gender>").option("--style <style>", STYLE_DESCRIPTION).option("--base-outfit <outfit>").option("--seed-prompt <prompt>").option("--node-id <id>", "canvas node id (required on update too)", "mcp-managed").option("--profile <name>").option("--json").action(
1189
+ async (id, opts) => {
1190
+ try {
1191
+ const has = [
1192
+ opts.name,
1193
+ opts.description,
1194
+ opts.gender,
1195
+ opts.style,
1196
+ opts.baseOutfit,
1197
+ opts.seedPrompt
1198
+ ].some((v) => v !== void 0);
1199
+ if (!has) {
1200
+ throw new Error(
1201
+ "nothing to update \u2014 provide at least one of --name / --description / --gender / --style / --base-outfit / --seed-prompt"
1202
+ );
1203
+ }
1204
+ const client = buildClient(opts.profile);
1205
+ const patch = {
1206
+ nodeId: opts.nodeId
1207
+ };
1208
+ if (opts.name !== void 0) patch.name = opts.name;
1209
+ if (opts.description !== void 0) patch.description = opts.description;
1210
+ if (opts.gender !== void 0) patch.gender = opts.gender;
1211
+ if (opts.style !== void 0) {
1212
+ patch.style = opts.style;
1213
+ }
1214
+ if (opts.baseOutfit !== void 0) patch.baseOutfit = opts.baseOutfit;
1215
+ if (opts.seedPrompt !== void 0) patch.seedPrompt = opts.seedPrompt;
1216
+ const result = await client.characters.update(id, patch);
1217
+ if (opts.json) {
1218
+ emit(result, opts);
1219
+ return;
1220
+ }
1221
+ success(`updated character ${result.id}`);
1222
+ } catch (err) {
1223
+ handleError(err);
1224
+ }
1225
+ }
1226
+ );
1227
+ cmd.command("delete <id>").description("soft-delete (archive) a character \u2014 restore with `characters restore <id>`").option("--profile <name>").option("--json").action(async (id, opts) => {
1228
+ try {
1229
+ const client = buildClient(opts.profile);
1230
+ const result = await client.characters.delete(id);
1231
+ if (opts.json) {
1232
+ emit(result, opts);
1233
+ return;
1234
+ }
1235
+ success(`archived character ${id}`);
1236
+ } catch (err) {
1237
+ handleError(err);
1238
+ }
1239
+ });
1240
+ cmd.command("restore <id>").description("un-archive a soft-deleted character (auto-suffixes name on conflict)").option("--profile <name>").option("--json").action(async (id, opts) => {
1241
+ try {
1242
+ const client = buildClient(opts.profile);
1243
+ const result = await client.characters.restore(id);
1244
+ if (opts.json) {
1245
+ emit(result, opts);
1246
+ return;
1247
+ }
1248
+ success(`restored character ${result.id} (${result.name})`);
1249
+ } catch (err) {
1250
+ handleError(err);
1251
+ }
1252
+ });
1253
+ cmd.command("duplicate <id>").description("fork a character to a new row with a (copy) suffix").option("--node-id <id>", "canvas node id for the new row").option("--project <projectId>", "drop the copy into this project").option("--profile <name>").option("--json").action(
1254
+ async (id, opts) => {
1255
+ try {
1256
+ const client = buildClient(opts.profile);
1257
+ const result = await client.characters.duplicate(id, {
1258
+ nodeId: opts.nodeId,
1259
+ projectId: opts.project
1260
+ });
1261
+ if (opts.json) {
1262
+ emit(result, opts);
1263
+ return;
1264
+ }
1265
+ success(`duplicated character ${id} \u2192 ${result.id} (${result.name})`);
1266
+ } catch (err) {
1267
+ handleError(err);
1268
+ }
1269
+ }
1270
+ );
1271
+ cmd.command("usage <id>").description("show which workflows reference this character").option("--profile <name>").option("--json").action(async (id, opts) => {
1272
+ try {
1273
+ const client = buildClient(opts.profile);
1274
+ const result = await client.characters.usage(id);
1275
+ if (opts.json) {
1276
+ emit(result, opts);
1277
+ return;
1278
+ }
1279
+ console.log(`${result.workflowCount} workflows reference this character`);
1280
+ if (result.workflows.length > 0) {
1281
+ table(result.workflows, ["id", "name"]);
1282
+ }
1283
+ } catch (err) {
1284
+ handleError(err);
1285
+ }
1286
+ });
1287
+ cmd.command("generate <id>").description("trigger portrait generation for a character").option("--seed-prompt <prompt>").option("--description <desc>").option("--provider <provider>", "image provider (defaults to nano-banana)").option("--count <n>", "1, 2, or 4 candidate portraits", "1").option("--name <name>", "override the character's display name in the prompt").option("--profile <name>").option("--json").option("--watch", "poll the first job until it completes").action(
1288
+ async (id, opts) => {
1289
+ try {
1290
+ const client = buildClient(opts.profile);
1291
+ const char = await client.characters.get(id);
1292
+ const fallbackSeed = char.sourceImageUrl ? void 0 : char.description ?? void 0;
1293
+ const result = await client.characters.generate({
1294
+ name: opts.name ?? char.name,
1295
+ seedPrompt: opts.seedPrompt ?? fallbackSeed,
1296
+ description: opts.description ?? char.description ?? void 0,
1297
+ provider: opts.provider,
1298
+ count: parseCount(opts.count),
1299
+ attachToCharacterId: id
1300
+ });
1301
+ if (opts.json && !opts.watch) {
1302
+ emit(result, opts);
1303
+ return;
1304
+ }
1305
+ success(`generation started \u2014 ${result.jobIds.length} job(s)`);
1306
+ for (const jobId of result.jobIds) {
1307
+ console.log(` ${jobId}`);
1308
+ }
1309
+ if (!opts.watch) {
1310
+ dim(`follow: nodaro jobs get ${result.jobId}`);
1311
+ return;
1312
+ }
1313
+ await watchUntilTerminal({
1314
+ fetch: () => client.jobs.get(result.jobId),
1315
+ label: result.jobId,
1316
+ ...opts
1317
+ });
1318
+ } catch (err) {
1319
+ handleError(err);
1320
+ }
1321
+ }
1322
+ );
1323
+ cmd.command("generate-asset <id>").description("trigger a single expression / pose / lighting / angle asset generation").requiredOption(
1324
+ "--asset-type <type>",
1325
+ "expressions | poses | lighting | angles | headAngles | bodyAngles | custom"
1326
+ ).requiredOption("--variant <name>", "the named variant (e.g. 'smile', 'standing')").option("--provider <provider>").option("--user-prompt <prompt>", "additional free-text prompt for the asset").option("--description <desc>").option("--column <col>", "expressions | poses | angles | body_angles | lighting_variations").option("--attach-name <name>", "display name to store on the asset entry").option("--profile <name>").option("--json").option("--watch", "poll until completion").action(
1327
+ async (id, opts) => {
1328
+ try {
1329
+ const client = buildClient(opts.profile);
1330
+ const char = await client.characters.get(id);
1331
+ const ASSET_TYPE_TO_COLUMN3 = {
1332
+ expressions: "expressions",
1333
+ poses: "poses",
1334
+ angles: "angles",
1335
+ headAngles: "angles",
1336
+ bodyAngles: "body_angles",
1337
+ lighting: "lighting_variations"
1338
+ // custom: caller must pass --column explicitly; no default.
1339
+ };
1340
+ const inferredColumn = ASSET_TYPE_TO_COLUMN3[opts.assetType];
1341
+ const result = await client.characters.generateAsset({
1342
+ assetType: opts.assetType,
1343
+ variant: opts.variant,
1344
+ name: char.name,
1345
+ description: opts.description ?? char.description ?? void 0,
1346
+ userPrompt: opts.userPrompt,
1347
+ provider: opts.provider,
1348
+ attachToCharacterId: id,
1349
+ attachToColumn: opts.column ?? inferredColumn,
1350
+ attachName: opts.attachName ?? opts.variant
1351
+ });
1352
+ if (opts.json && !opts.watch) {
1353
+ emit(result, opts);
1354
+ return;
1355
+ }
1356
+ success(`generation started \u2014 job ${result.jobId}`);
1357
+ if (!opts.watch) {
1358
+ dim(`follow: nodaro jobs get ${result.jobId}`);
1359
+ return;
1360
+ }
1361
+ await watchUntilTerminal({
1362
+ fetch: () => client.jobs.get(result.jobId),
1363
+ label: result.jobId,
1364
+ ...opts
1365
+ });
1366
+ } catch (err) {
1367
+ handleError(err);
1368
+ }
1369
+ }
1370
+ );
1371
+ cmd.command("generate-motion <id>").description("animate the character's portrait into a motion clip").requiredOption("--motion-prompt <prompt>").option("--attach-name <name>", "display name for the motion entry").option("--provider <provider>", "i2v provider; defaults to kling").option("--description <desc>").option("--motion-description <desc>", "tight description of WHAT moves and HOW").option("--profile <name>").option("--json").option("--watch", "poll the motion job until completion").action(
1372
+ async (id, opts) => {
1373
+ try {
1374
+ const client = buildClient(opts.profile);
1375
+ const char = await client.characters.get(id);
1376
+ const result = await client.characters.generateMotion({
1377
+ motionPrompt: opts.motionPrompt,
1378
+ name: char.name,
1379
+ attachToCharacterId: id,
1380
+ attachName: opts.attachName,
1381
+ provider: opts.provider,
1382
+ description: opts.description ?? char.description ?? void 0,
1383
+ motionDescription: opts.motionDescription
1384
+ });
1385
+ if (opts.json && !opts.watch) {
1386
+ emit(result, opts);
1387
+ return;
1388
+ }
1389
+ success(`motion generation started \u2014 job ${result.jobId}`);
1390
+ if (!opts.watch) {
1391
+ dim(`follow: nodaro jobs get ${result.jobId}`);
1392
+ return;
1393
+ }
1394
+ await watchUntilTerminal({
1395
+ fetch: () => client.jobs.get(result.jobId),
1396
+ label: result.jobId,
1397
+ ...opts
1398
+ });
1399
+ } catch (err) {
1400
+ handleError(err);
1401
+ }
1402
+ }
1403
+ );
1404
+ cmd.command("approve-portrait <id>").description("approve a completed generate-character job as the character's portrait").requiredOption("--job <jobId>", "the candidate job id from `generate`").option("--profile <name>").option("--json").action(async (id, opts) => {
1405
+ try {
1406
+ const client = buildClient(opts.profile);
1407
+ const result = await client.characters.approvePortrait(id, opts.job);
1408
+ if (opts.json) {
1409
+ emit(result, opts);
1410
+ return;
1411
+ }
1412
+ success(`portrait approved \u2192 ${result.portraitUrl}`);
1413
+ if (result.canonicalDescription) {
1414
+ console.log(`caption: ${result.canonicalDescription}`);
1415
+ } else {
1416
+ dim("(LLM caption sub-failed \u2014 run `characters recaption <id>` to retry)");
1417
+ }
1418
+ } catch (err) {
1419
+ handleError(err);
1420
+ }
1421
+ });
1422
+ cmd.command("recaption <id>").description("re-run the LLM caption against the character's current portrait").option("--profile <name>").option("--json").action(async (id, opts) => {
1423
+ try {
1424
+ const client = buildClient(opts.profile);
1425
+ const result = await client.characters.recaption(id);
1426
+ if (opts.json) {
1427
+ emit(result, opts);
1428
+ return;
1429
+ }
1430
+ success(`caption refreshed`);
1431
+ console.log(result.canonicalDescription);
1432
+ } catch (err) {
1433
+ handleError(err);
1434
+ }
1435
+ });
1436
+ return cmd;
1437
+ }
1438
+ function commonWizardFields(opts) {
1439
+ return {
1440
+ provider: opts.provider,
1441
+ style: opts.style,
1442
+ aspectRatio: opts.aspectRatio,
1443
+ duration: opts.duration,
1444
+ llmModel: opts.llmModel
1445
+ };
1446
+ }
1447
+ function promptCommand() {
1448
+ const cmd = new Command("prompt").description(
1449
+ "AI prompt wizard \u2014 analyze, generate, and enhance prompts for generation nodes"
1450
+ );
1451
+ cmd.command("wizard").description("interactive: answer guided questions and get an optimized prompt").option("--node-type <type>", "target node type (omit for an interactive picker)").option("--prompt <text>", "your rough idea (optional)").option("--provider <name>").option("--style <name>").option("--aspect-ratio <ratio>").option("--duration <seconds>", "clip duration in seconds", (v) => parseInt(v, 10)).option("--llm-model <id>").option("--profile <name>").action(async (opts) => {
1452
+ try {
1453
+ if (!isInteractive()) {
1454
+ warn("`prompt wizard` needs an interactive terminal \u2014 use `prompt analyze` + `prompt generate`, or `prompt enhance`, in scripts.");
1455
+ process.exit(2);
1456
+ }
1457
+ const client = buildClient(opts.profile);
1458
+ const nodeType = opts.nodeType ?? await pickNodeInteractively(client);
1459
+ const common = commonWizardFields(opts);
1460
+ const { questions } = await client.promptHelper.analyze({ nodeType, prompt: opts.prompt, ...common });
1461
+ const CUSTOM = "__custom__";
1462
+ const selections = [];
1463
+ for (const q of questions) {
1464
+ if (q.multi) {
1465
+ const picked = await pickManyFromList({
1466
+ message: q.label,
1467
+ choices: q.options.map((o) => ({
1468
+ name: o.label,
1469
+ value: o.value,
1470
+ description: o.description,
1471
+ checked: Array.isArray(q.selected) ? q.selected.includes(o.value) : false
1472
+ }))
1473
+ });
1474
+ for (const v of picked) selections.push({ category: q.category, value: v, isCustom: false });
1475
+ } else {
1476
+ const choices = q.options.map((o) => ({ name: o.label, value: o.value, description: o.description }));
1477
+ if (q.allowCustom) choices.push({ name: "Custom\u2026", value: CUSTOM, description: "type your own" });
1478
+ const chosen = await pickFromList({
1479
+ message: q.label,
1480
+ choices,
1481
+ default: typeof q.selected === "string" ? q.selected : void 0
1482
+ });
1483
+ if (chosen === CUSTOM) {
1484
+ const custom = await ask({ message: `${q.label} (custom)`, required: true });
1485
+ selections.push({ category: q.category, value: custom, isCustom: true });
1486
+ } else {
1487
+ selections.push({ category: q.category, value: chosen, isCustom: false });
1488
+ }
1489
+ }
1490
+ }
1491
+ const result = await client.promptHelper.generate({ nodeType, selections, originalPrompt: opts.prompt, ...common });
1492
+ success("optimized prompt:");
1493
+ info(result.prompt);
1494
+ if (result.recommendedModel) {
1495
+ dim(`recommended: ${result.recommendedModel.label} \u2014 ${result.recommendedModel.reason}`);
1496
+ }
1497
+ } catch (err) {
1498
+ handleError(err);
1499
+ }
1500
+ });
1501
+ cmd.command("analyze").description("return guided questions for a rough prompt idea").requiredOption("--node-type <type>").option("--prompt <text>").option("--provider <name>").option("--style <name>").option("--aspect-ratio <ratio>").option("--duration <seconds>", "clip duration in seconds", (v) => parseInt(v, 10)).option("--llm-model <id>").option("--profile <name>").option("--json").action(async (opts) => {
1502
+ try {
1503
+ const client = buildClient(opts.profile);
1504
+ const { jobId, questions } = await client.promptHelper.analyze({
1505
+ nodeType: opts.nodeType,
1506
+ prompt: opts.prompt,
1507
+ ...commonWizardFields(opts)
1508
+ });
1509
+ if (opts.json) {
1510
+ emit({ jobId, questions }, opts);
1511
+ return;
1512
+ }
1513
+ table(
1514
+ questions.map((q) => ({
1515
+ category: q.category,
1516
+ label: q.label,
1517
+ options: q.options.map((o) => o.value).join(", "),
1518
+ multi: q.multi ?? false
1519
+ })),
1520
+ ["category", "label", "options", "multi"]
1521
+ );
1522
+ } catch (err) {
1523
+ handleError(err);
1524
+ }
1525
+ });
1526
+ cmd.command("generate").description("build an optimized prompt from --selection category=value flags").requiredOption("--node-type <type>").option("--selection <pairs...>", "category=value (repeat); custom answers are wizard-only", collectVariadic).option("--original-prompt <text>").option("--provider <name>").option("--style <name>").option("--aspect-ratio <ratio>").option("--duration <seconds>", "clip duration in seconds", (v) => parseInt(v, 10)).option("--llm-model <id>").option("--profile <name>").option("--json").action(async (opts) => {
1527
+ try {
1528
+ const client = buildClient(opts.profile);
1529
+ const selections = parseSelectionPairs(opts.selection);
1530
+ if (selections.length === 0) throw new Error("at least one --selection category=value is required");
1531
+ const result = await client.promptHelper.generate({
1532
+ nodeType: opts.nodeType,
1533
+ selections,
1534
+ originalPrompt: opts.originalPrompt,
1535
+ ...commonWizardFields(opts)
1536
+ });
1537
+ if (opts.json) {
1538
+ emit(result, opts);
1539
+ return;
1540
+ }
1541
+ info(result.prompt);
1542
+ } catch (err) {
1543
+ handleError(err);
1544
+ }
1545
+ });
1546
+ cmd.command("enhance").description("rewrite a rough idea into one optimized prompt (no questions)").requiredOption("--node-type <type>").option("--prompt <text>").option("--provider <name>").option("--style <name>").option("--aspect-ratio <ratio>").option("--duration <seconds>", "clip duration in seconds", (v) => parseInt(v, 10)).option("--llm-model <id>").option("--profile <name>").option("--json").action(async (opts) => {
1547
+ try {
1548
+ const client = buildClient(opts.profile);
1549
+ const result = await client.promptHelper.enhance({
1550
+ nodeType: opts.nodeType,
1551
+ prompt: opts.prompt,
1552
+ ...commonWizardFields(opts)
1553
+ });
1554
+ if (opts.json) {
1555
+ emit(result, opts);
1556
+ return;
1557
+ }
1558
+ info(result.prompt);
1559
+ } catch (err) {
1560
+ handleError(err);
1561
+ }
1562
+ });
1563
+ return cmd;
1564
+ }
1565
+ function voiceCommand() {
1566
+ const cmd = new Command("voice").description("voice tools \u2014 revoice an audio track or a whole talking video");
1567
+ cmd.command("changer").alias("change").description("replace the voice in an audio track (--audio) or a talking video (--video) with a different voice").requiredOption("--voice <id>", "target voice \u2014 premade name (Rachel, Aria, Roger, ...) or an ElevenLabs clone UUID").option("--audio <url>", "audio URL to revoice (audio \u2192 audio)").option("--video <url>", "video URL to revoice (returns the video + the new audio track). Wins over --audio when both are given.").option("--stability <n>", "voice stability 0..1", parseFloat).option("--similarity <n>", "similarity boost 0..1", parseFloat).option("--style <n>", "style exaggeration 0..1 \u2014 amplifies the source's delivery (default 0; higher adds latency / less stable)", parseFloat).option("--remove-background-noise", "clean, voice-only output; omit to keep the music/SFX bed under the new voice").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", `
1568
+ Examples:
1569
+ $ nodaro voice changer --audio https://.../speech.mp3 --voice Rachel --watch
1570
+ $ nodaro voice changer --video https://.../talking.mp4 --voice Aria --watch
1571
+ $ nodaro voice changer --video https://.../talking.mp4 --voice Roger --remove-background-noise --watch`).action(
1572
+ async (opts) => {
1573
+ try {
1574
+ if (!opts.audio && !opts.video) {
1575
+ warn("Provide --audio <url> or --video <url> (one is required)");
1576
+ process.exit(1);
1577
+ }
1578
+ const client = buildClient(opts.profile);
1579
+ const result = await client.voices.change({
1580
+ voiceId: opts.voice,
1581
+ audioUrl: opts.audio,
1582
+ videoUrl: opts.video,
1583
+ stability: opts.stability,
1584
+ similarityBoost: opts.similarity,
1585
+ style: opts.style,
1586
+ removeBackgroundNoise: opts.removeBackgroundNoise
1587
+ });
1588
+ const jobId = result.jobId;
1589
+ if (opts.json && !opts.watch) {
1590
+ emit(result, opts);
1591
+ return;
1592
+ }
1593
+ success(`job ${jobId} queued (${opts.video ? "video" : "audio"} mode)`);
1594
+ if (!opts.watch) {
1595
+ dim(`follow: nodaro jobs get ${jobId}`);
1596
+ return;
1597
+ }
1598
+ await watchUntilTerminal({
1599
+ fetch: () => client.jobs.get(jobId),
1600
+ label: jobId,
1601
+ intervalMs: opts.pollInterval,
1602
+ ...opts
1603
+ });
1604
+ } catch (err) {
1605
+ handleError(err);
1606
+ }
1607
+ }
1608
+ );
1609
+ return cmd;
1610
+ }
1611
+ function presetsCommand() {
1612
+ const cmd = new Command("presets").description(
1613
+ "list saved node presets \u2014 your custom presets plus the built-in factory catalog"
1614
+ );
1615
+ 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) => {
1616
+ try {
1617
+ const client = buildClient(opts.profile);
1618
+ if (opts.factory) {
1619
+ if (!opts.nodeType) {
1620
+ handleError(new Error("--node-type is required with --factory (e.g. --node-type generate-image)"));
1621
+ return;
1622
+ }
1623
+ const result = await client.presets.listFactory(opts.nodeType);
1624
+ if (opts.json) {
1625
+ emit(result, opts);
1626
+ return;
1627
+ }
1628
+ table(
1629
+ result.data.map((p) => ({
1630
+ id: p.id,
1631
+ name: p.name,
1632
+ group: p.group ?? ""
1633
+ })),
1634
+ ["id", "name", "group"]
1635
+ );
1636
+ return;
1637
+ }
1638
+ const presets = await client.presets.list(opts.nodeType);
1639
+ if (opts.json) {
1640
+ emit(presets, opts);
1641
+ return;
1642
+ }
1643
+ table(
1644
+ presets.map((p) => ({ id: p.id, nodeType: p.nodeType, name: p.name, updatedAt: p.updatedAt })),
1645
+ ["id", "nodeType", "name", "updatedAt"]
1646
+ );
1647
+ } catch (err) {
1648
+ handleError(err);
1649
+ }
1650
+ });
1651
+ 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) => {
1652
+ try {
1653
+ const client = buildClient(opts.profile);
1654
+ const groups = await client.presets.listGroups(opts.nodeType);
1655
+ if (opts.json) {
1656
+ emit(groups, opts);
1657
+ return;
1658
+ }
1659
+ table(
1660
+ groups.map((g) => ({ id: g.id, nodeType: g.nodeType, name: g.name, kind: g.kind })),
1661
+ ["id", "nodeType", "name", "kind"]
1662
+ );
1663
+ } catch (err) {
1664
+ handleError(err);
1665
+ }
1666
+ });
1667
+ cmd.command("export").description("export your custom presets as an import-compatible JSON envelope (stdout, or --output file)").option("--node-type <type>", "filter to one node type").option("--output <file>", "write to a file instead of stdout").option("--profile <name>").action(async (opts) => {
1668
+ try {
1669
+ const client = buildClient(opts.profile);
1670
+ const presets = await client.presets.list(opts.nodeType);
1671
+ const envelope = {
1672
+ kind: "nodaro.node-presets",
1673
+ version: 1,
1674
+ exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
1675
+ presets: presets.map((p) => ({
1676
+ nodeType: p.nodeType,
1677
+ name: p.name,
1678
+ description: p.description,
1679
+ data: p.data
1680
+ }))
1681
+ };
1682
+ const json = JSON.stringify(envelope, null, 2);
1683
+ if (opts.output) {
1684
+ writeFileSync(opts.output, json);
1685
+ success(`exported ${presets.length} preset${presets.length === 1 ? "" : "s"} to ${opts.output}`);
1686
+ } else {
1687
+ process.stdout.write(`${json}
1688
+ `);
1689
+ }
1690
+ } catch (err) {
1691
+ handleError(err);
1692
+ }
1693
+ });
1694
+ return cmd;
1695
+ }
1696
+ function parseList(value) {
1697
+ return value.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
1698
+ }
1699
+ var ENTITY_TYPES = [
1700
+ "character",
1701
+ "location",
1702
+ "object",
1703
+ "creature"
1704
+ ];
1705
+ var SORTS = ["newest", "popular"];
1706
+ var REPORT_REASONS = [
1707
+ "real_person_no_consent",
1708
+ "inappropriate",
1709
+ "ip_violation",
1710
+ "other"
1711
+ ];
1712
+ var CARD_COLUMNS = ["slug", "type", "title", "creator", "clones"];
1713
+ function cardRow(c) {
1714
+ return {
1715
+ slug: c.slug,
1716
+ type: c.entity_type,
1717
+ title: c.title,
1718
+ creator: c.creator_display_name,
1719
+ clones: c.clone_count
1720
+ };
1721
+ }
1722
+ function parseEntityType(value) {
1723
+ if (!ENTITY_TYPES.includes(value)) {
1724
+ throw new Error(
1725
+ `invalid --type "${value}" \u2014 must be one of: ${ENTITY_TYPES.join(", ")}`
1726
+ );
1727
+ }
1728
+ return value;
1729
+ }
1730
+ function communityCommand() {
1731
+ const cmd = new Command("community").description(
1732
+ "browse, clone, favorite, report, publish, and unpublish community assets"
1733
+ );
1734
+ cmd.command("browse").description("list public community listings (paged via --cursor)").option("--entity-type <type>", "filter by kind: character|location|object|creature").option("--q <text>", "free-text search query").option("--category <cat>", "filter by category").option("--sort <sort>", "ordering: newest|popular").option("--limit <n>", "max results per page", (v) => parseInt(v, 10)).option("--cursor <token>", "pagination cursor from a previous page").option("--profile <name>").option("--json").action(
1735
+ async (opts) => {
1736
+ try {
1737
+ const entityType = opts.entityType === void 0 ? void 0 : parseEntityType(opts.entityType);
1738
+ if (opts.sort !== void 0 && !SORTS.includes(opts.sort)) {
1739
+ throw new Error(
1740
+ `invalid --sort "${opts.sort}" \u2014 must be one of: ${SORTS.join(", ")}`
1741
+ );
1742
+ }
1743
+ const client = buildClient(opts.profile);
1744
+ const result = await client.community.browse({
1745
+ entityType,
1746
+ q: opts.q,
1747
+ category: opts.category,
1748
+ sort: opts.sort,
1749
+ limit: opts.limit,
1750
+ cursor: opts.cursor
1751
+ });
1752
+ if (opts.json) {
1753
+ emit(result, opts);
1754
+ return;
1755
+ }
1756
+ table(result.data.map(cardRow), [...CARD_COLUMNS]);
1757
+ if (result.nextCursor) {
1758
+ dim(`next page: --cursor ${result.nextCursor}`);
1759
+ }
1760
+ } catch (err) {
1761
+ handleError(err);
1762
+ }
1763
+ }
1764
+ );
1765
+ cmd.command("get <slug>").description("show one community listing by its slug").option("--profile <name>").option("--json").action(async (slug, opts) => {
1766
+ try {
1767
+ const client = buildClient(opts.profile);
1768
+ const result = await client.community.get(slug);
1769
+ if (opts.json) emit(result, opts);
1770
+ else detail(result.data);
1771
+ } catch (err) {
1772
+ handleError(err);
1773
+ }
1774
+ });
1775
+ cmd.command("favorites").description("list the community listings you've favorited").option("--profile <name>").option("--json").action(async (opts) => {
1776
+ try {
1777
+ const client = buildClient(opts.profile);
1778
+ const result = await client.community.favorites();
1779
+ if (opts.json) {
1780
+ emit(result, opts);
1781
+ return;
1782
+ }
1783
+ table(result.data.map(cardRow), [...CARD_COLUMNS]);
1784
+ } catch (err) {
1785
+ handleError(err);
1786
+ }
1787
+ });
1788
+ cmd.command("clone <id>").description("copy a community listing into your library").requiredOption("--type <entityType>", "kind of asset: character|location|object|creature").option("--profile <name>").option("--json").action(async (id, opts) => {
1789
+ try {
1790
+ const entityType = parseEntityType(opts.type);
1791
+ const client = buildClient(opts.profile);
1792
+ const result = await client.community.clone(id, entityType);
1793
+ if (opts.json) {
1794
+ emit(result, opts);
1795
+ return;
1796
+ }
1797
+ success(`cloned \u2192 ${result.entityType} ${result.id}`);
1798
+ } catch (err) {
1799
+ handleError(err);
1800
+ }
1801
+ });
1802
+ cmd.command("favorite <id>").description("toggle a favorite on a community listing").option("--profile <name>").option("--json").action(async (id, opts) => {
1803
+ try {
1804
+ const client = buildClient(opts.profile);
1805
+ const result = await client.community.favorite(id);
1806
+ if (opts.json) {
1807
+ emit(result, opts);
1808
+ return;
1809
+ }
1810
+ success(result.favorited ? "favorited" : "unfavorited");
1811
+ } catch (err) {
1812
+ handleError(err);
1813
+ }
1814
+ });
1815
+ cmd.command("report <id>").description("flag a community listing for moderation").requiredOption(
1816
+ "--reason <reason>",
1817
+ "real_person_no_consent|inappropriate|ip_violation|other"
1818
+ ).option("--profile <name>").option("--json").action(async (id, opts) => {
1819
+ try {
1820
+ if (!REPORT_REASONS.includes(opts.reason)) {
1821
+ throw new Error(
1822
+ `invalid --reason "${opts.reason}" \u2014 must be one of: ${REPORT_REASONS.join(", ")}`
1823
+ );
1824
+ }
1825
+ const client = buildClient(opts.profile);
1826
+ const result = await client.community.report(
1827
+ id,
1828
+ opts.reason
1829
+ );
1830
+ if (opts.json) {
1831
+ emit(result, opts);
1832
+ return;
1833
+ }
1834
+ success("reported");
1835
+ } catch (err) {
1836
+ handleError(err);
1837
+ }
1838
+ });
1839
+ cmd.command("publish <entityType> <id>").description(
1840
+ "share one of YOUR entities to the community (admin token); requires --consent"
1841
+ ).requiredOption("--title <t>", "public listing title").option("--description <d>", "public listing description").option("--category <c>", "listing category").option("--style <s>", "listing style tag").option("--tags <list>", "comma-separated tags", parseList).option(
1842
+ "--consent",
1843
+ "attest you have the rights to share this publicly (required)"
1844
+ ).option(
1845
+ "--likeness-consent",
1846
+ "attest to rights/consent of any real person depicted, 18+ (required for characters)"
1847
+ ).option("--profile <name>").option("--json").action(
1848
+ async (entityType, id, opts) => {
1849
+ try {
1850
+ const parsedEntityType = parseEntityType(entityType);
1851
+ if (!opts.consent) {
1852
+ throw new Error(
1853
+ "publishing requires --consent (you attest you have the rights to share this publicly)"
1854
+ );
1855
+ }
1856
+ if (parsedEntityType === "character" && !opts.likenessConsent) {
1857
+ throw new Error(
1858
+ "characters require --likeness-consent (rights/consent of any real person depicted, 18+)"
1859
+ );
1860
+ }
1861
+ const client = buildClient(opts.profile);
1862
+ const result = await client.community.publish(parsedEntityType, id, {
1863
+ title: opts.title,
1864
+ description: opts.description,
1865
+ category: opts.category,
1866
+ style: opts.style,
1867
+ tags: opts.tags,
1868
+ attestation: true,
1869
+ likenessAttestation: opts.likenessConsent
1870
+ });
1871
+ if (opts.json) {
1872
+ emit(result, opts);
1873
+ return;
1874
+ }
1875
+ success(`shared \u2192 ${result.slug}`);
1876
+ emit(result, { json: true });
1877
+ } catch (err) {
1878
+ handleError(err);
1879
+ }
1880
+ }
1881
+ );
1882
+ cmd.command("unpublish <listingId>").description("unshare (deactivate) a listing you published (admin token)").option("--profile <name>").option("--json").action(async (listingId, opts) => {
1883
+ try {
1884
+ const client = buildClient(opts.profile);
1885
+ const result = await client.community.unpublish(listingId);
1886
+ if (opts.json) {
1887
+ emit(result, opts);
1888
+ return;
1889
+ }
1890
+ success(`unshared listing ${listingId}`);
1891
+ } catch (err) {
1892
+ handleError(err);
1893
+ }
1894
+ });
1895
+ cmd.command("shared-status <entityType> <sourceId>").description(
1896
+ "look up YOUR existing listing (if any) for a source entity (admin token)"
1897
+ ).option("--profile <name>").option("--json").action(async (entityType, sourceId, opts) => {
1898
+ try {
1899
+ const parsedEntityType = parseEntityType(entityType);
1900
+ const client = buildClient(opts.profile);
1901
+ const result = await client.community.sharedListing(parsedEntityType, sourceId);
1902
+ if (opts.json) {
1903
+ emit(result, opts);
1904
+ return;
1905
+ }
1906
+ if (result.data) detail(result.data);
1907
+ else success("not shared");
1908
+ } catch (err) {
1909
+ handleError(err);
1910
+ }
1911
+ });
1912
+ return cmd;
1913
+ }
1914
+ function pickerCatalogsCommand() {
1915
+ const cmd = new Command("pickers").description(
1916
+ "list parameter-picker node types and their value catalogs (valid ids for setting, mood, person, \u2026)"
1917
+ );
1918
+ cmd.command("list").description("list all picker node types + option counts").option("--profile <name>").option("--json").action(async (opts) => {
1919
+ try {
1920
+ const client = buildClient(opts.profile);
1921
+ const result = await client.pickerCatalogs.list();
1922
+ if (opts.json) {
1923
+ emit(result.data, opts);
1924
+ return;
1925
+ }
1926
+ table(
1927
+ result.data.map((c) => ({
1928
+ nodeType: c.nodeType,
1929
+ label: c.label,
1930
+ kind: c.kind,
1931
+ field: c.valueField ?? (c.fields?.join("+") ?? ""),
1932
+ options: c.optionCount
1933
+ })),
1934
+ ["nodeType", "label", "kind", "field", "options"]
1935
+ );
1936
+ } catch (err) {
1937
+ handleError(err);
1938
+ }
1939
+ });
1940
+ 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(
1941
+ "after",
1942
+ `
1943
+ Examples:
1944
+ $ nodaro pickers list
1945
+ $ nodaro pickers get setting
1946
+ $ nodaro pickers get setting --full --category Urban
1947
+ $ nodaro pickers get person --field hairColor`
1948
+ ).action(
1949
+ async (nodeType, opts) => {
1950
+ try {
1951
+ const client = buildClient(opts.profile);
1952
+ const result = await client.pickerCatalogs.get(nodeType, {
1953
+ detail: opts.full ? "full" : "compact",
1954
+ category: opts.category,
1955
+ field: opts.field
1956
+ });
1957
+ if (opts.json) emit(result.data, opts);
1958
+ else detail(result.data);
1959
+ } catch (err) {
1960
+ handleError(err);
1961
+ }
1962
+ }
1963
+ );
1964
+ return cmd;
1965
+ }
1966
+ var ASSET_TYPE_TO_COLUMN = {
1967
+ timeOfDay: "time_of_day",
1968
+ weather: "weather",
1969
+ seasons: "seasons",
1970
+ angles: "angles",
1971
+ lighting: "lighting"
1972
+ };
1973
+ function locationsCommand() {
1974
+ const cmd = new Command("locations").description(
1975
+ "list, inspect, and manage locations; trigger main-image / asset generation"
1976
+ );
1977
+ cmd.command("list").description("list locations (active by default)").option("--archived", "show archived locations instead of active ones").option("--profile <name>").option("--json").action(
1978
+ async (opts) => {
1979
+ try {
1980
+ const client = buildClient(opts.profile);
1981
+ const result = await client.locations.list({ archived: opts.archived });
1982
+ if (opts.json) {
1983
+ emit(result.locations, opts);
1984
+ return;
1985
+ }
1986
+ table(
1987
+ result.locations.map((l) => ({
1988
+ id: l.id,
1989
+ name: l.name,
1990
+ category: l.category ?? "",
1991
+ mainImage: l.sourceImageUrl ? "yes" : "no",
1992
+ updatedAt: l.updatedAt
1993
+ })),
1994
+ ["id", "name", "category", "mainImage", "updatedAt"]
1995
+ );
1996
+ } catch (err) {
1997
+ handleError(err);
1998
+ }
1999
+ }
2000
+ );
2001
+ cmd.command("get <id>").description("show one location by id (full asset arrays + pending jobs)").option("--profile <name>").option("--json").action(async (id, opts) => {
2002
+ try {
2003
+ const client = buildClient(opts.profile);
2004
+ const result = await client.locations.get(id);
2005
+ if (opts.json) emit(result, opts);
2006
+ else detail(result);
2007
+ } catch (err) {
2008
+ handleError(err);
2009
+ }
2010
+ });
2011
+ cmd.command("create <name>").description("create a new location row (no main image yet \u2014 call `generate` next)").requiredOption("--node-id <id>", "canvas node id to bind to").option("--description <desc>", "freeform identity notes").option("--category <category>", "indoor | outdoor | urban | nature | fantasy | sci-fi | historical | futuristic | other").option("--style <style>", "realistic | anime | 3d-pixar | illustration").option("--project <projectId>", "drop the row into this project").option("--profile <name>").option("--json").action(
2012
+ async (name, opts) => {
2013
+ try {
2014
+ const client = buildClient(opts.profile);
2015
+ const result = await client.locations.create({
2016
+ nodeId: opts.nodeId,
2017
+ projectId: opts.project,
2018
+ name,
2019
+ description: opts.description,
2020
+ category: opts.category,
2021
+ style: opts.style
2022
+ });
2023
+ if (opts.json) {
2024
+ emit(result, opts);
2025
+ return;
2026
+ }
2027
+ success(`created location ${result.id} (${name})`);
2028
+ } catch (err) {
2029
+ handleError(err);
2030
+ }
2031
+ }
2032
+ );
2033
+ cmd.command("update <id>").description("update identity fields on an existing location").option("--name <name>").option("--description <desc>").option("--category <category>").option("--style <style>").option("--style-lock <bool>", "lock asset gens to the canonical style (true/false)").option("--canonical-description <desc>", "manually set the LLM-style caption (skips recaption)").option("--expected-updated-at <iso>", "optimistic-concurrency token \u2014 fail with 409 on mismatch").option("--profile <name>").option("--json").action(
2034
+ async (id, opts) => {
2035
+ try {
2036
+ const has = [
2037
+ opts.name,
2038
+ opts.description,
2039
+ opts.category,
2040
+ opts.style,
2041
+ opts.styleLock,
2042
+ opts.canonicalDescription
2043
+ ].some((v) => v !== void 0);
2044
+ if (!has) {
2045
+ throw new Error(
2046
+ "nothing to update \u2014 provide at least one of --name / --description / --category / --style / --style-lock / --canonical-description"
2047
+ );
2048
+ }
2049
+ const client = buildClient(opts.profile);
2050
+ const patch = {};
2051
+ if (opts.name !== void 0) patch.name = opts.name;
2052
+ if (opts.description !== void 0) patch.description = opts.description;
2053
+ if (opts.category !== void 0) patch.category = opts.category;
2054
+ if (opts.style !== void 0) patch.style = opts.style;
2055
+ if (opts.styleLock !== void 0) {
2056
+ patch.styleLock = parseBoolFlag(opts.styleLock, "style-lock");
2057
+ }
2058
+ if (opts.canonicalDescription !== void 0) {
2059
+ patch.canonicalDescription = opts.canonicalDescription;
2060
+ }
2061
+ if (opts.expectedUpdatedAt !== void 0) {
2062
+ patch.expectedUpdatedAt = opts.expectedUpdatedAt;
2063
+ }
2064
+ const result = await client.locations.update(id, patch);
2065
+ if (opts.json) {
2066
+ emit(result, opts);
2067
+ return;
2068
+ }
2069
+ success(`updated location ${result.id} (updatedAt ${result.updatedAt})`);
2070
+ } catch (err) {
2071
+ handleError(err);
2072
+ }
2073
+ }
2074
+ );
2075
+ cmd.command("delete <id>").description("soft-delete (archive) a location \u2014 restore with `locations restore <id>`").option("--profile <name>").option("--json").action(async (id, opts) => {
2076
+ try {
2077
+ const client = buildClient(opts.profile);
2078
+ const result = await client.locations.delete(id);
2079
+ if (opts.json) {
2080
+ emit(result, opts);
2081
+ return;
2082
+ }
2083
+ success(`archived location ${id}`);
2084
+ } catch (err) {
2085
+ handleError(err);
2086
+ }
2087
+ });
2088
+ cmd.command("restore <id>").description("un-archive a soft-deleted location (auto-suffixes name on conflict)").option("--profile <name>").option("--json").action(async (id, opts) => {
2089
+ try {
2090
+ const client = buildClient(opts.profile);
2091
+ const result = await client.locations.restore(id);
2092
+ if (opts.json) {
2093
+ emit(result, opts);
2094
+ return;
2095
+ }
2096
+ success(`restored location ${result.id} (${result.name})`);
2097
+ } catch (err) {
2098
+ handleError(err);
2099
+ }
2100
+ });
2101
+ cmd.command("generate").description("trigger main-image generation for a location").requiredOption("--name <name>", "the location's display name (used in the prompt)").option("--description <desc>").option("--user-prompt <prompt>", "additional free-text prompt").option("--category <category>").option("--style <style>").option("--provider <provider>", "image provider (defaults to nano-banana)").option("--count <n>", "1, 2, or 4 candidate main images", "1").option("--attach-to-location-id <id>", "auto-attach result to this location row (count=1 only)").option("--profile <name>").option("--json").option("--watch", "poll the first job until it completes").action(
2102
+ async (opts) => {
2103
+ try {
2104
+ const client = buildClient(opts.profile);
2105
+ const result = await client.locations.generate({
2106
+ name: opts.name,
2107
+ description: opts.description,
2108
+ userPrompt: opts.userPrompt,
2109
+ category: opts.category,
2110
+ style: opts.style,
2111
+ provider: opts.provider,
2112
+ count: parseCount(opts.count),
2113
+ attachToLocationId: opts.attachToLocationId
2114
+ });
2115
+ const jobIds = result.jobIds ?? (result.jobId ? [result.jobId] : []);
2116
+ if (opts.json && !opts.watch) {
2117
+ emit(result, opts);
2118
+ return;
2119
+ }
2120
+ success(`generation started \u2014 ${jobIds.length} job(s)`);
2121
+ for (const jobId of jobIds) {
2122
+ console.log(` ${jobId}`);
2123
+ }
2124
+ if (!opts.watch) {
2125
+ dim(`follow: nodaro jobs get ${jobIds[0]}`);
2126
+ return;
2127
+ }
2128
+ await watchUntilTerminal({
2129
+ fetch: () => client.jobs.get(jobIds[0]),
2130
+ label: jobIds[0],
2131
+ ...opts
2132
+ });
2133
+ } catch (err) {
2134
+ handleError(err);
2135
+ }
2136
+ }
2137
+ );
2138
+ cmd.command("generate-asset <id>").description("trigger a single timeOfDay / weather / season / angle / lighting / custom asset generation").requiredOption(
2139
+ "--asset-type <type>",
2140
+ `one of ${LOCATION_ASSET_TYPES.join(" | ")}`
2141
+ ).requiredOption("--variant <name>", "the named variant (e.g. 'dawn', 'clear', 'wide')").option("--provider <provider>").option("--user-prompt <prompt>").option("--description <desc>").option(
2142
+ "--column <col>",
2143
+ `override the attach column (required for --asset-type custom): ${LOCATION_ATTACH_COLUMNS.join(" | ")}`
2144
+ ).option("--attach-name <name>", "display name to store on the asset entry").option("--profile <name>").option("--json").option("--watch", "poll until completion").action(
2145
+ async (id, opts) => {
2146
+ try {
2147
+ const client = buildClient(opts.profile);
2148
+ const loc = await client.locations.get(id);
2149
+ const inferredColumn = ASSET_TYPE_TO_COLUMN[opts.assetType];
2150
+ const resolvedColumn = opts.column ?? inferredColumn;
2151
+ if (!resolvedColumn) {
2152
+ throw new Error(
2153
+ `--column is required for --asset-type ${opts.assetType} (no inferred column)`
2154
+ );
2155
+ }
2156
+ const result = await client.locations.generateAsset({
2157
+ assetType: opts.assetType,
2158
+ variant: opts.variant,
2159
+ name: loc.name,
2160
+ description: opts.description ?? loc.description ?? void 0,
2161
+ userPrompt: opts.userPrompt,
2162
+ provider: opts.provider,
2163
+ attachToLocationId: id,
2164
+ attachToColumn: resolvedColumn,
2165
+ attachName: opts.attachName ?? opts.variant
2166
+ });
2167
+ if (opts.json && !opts.watch) {
2168
+ emit(result, opts);
2169
+ return;
2170
+ }
2171
+ success(`generation started \u2014 job ${result.jobId}`);
2172
+ if (!opts.watch) {
2173
+ dim(`follow: nodaro jobs get ${result.jobId}`);
2174
+ return;
2175
+ }
2176
+ await watchUntilTerminal({
2177
+ fetch: () => client.jobs.get(result.jobId),
2178
+ label: result.jobId,
2179
+ ...opts
2180
+ });
2181
+ } catch (err) {
2182
+ handleError(err);
2183
+ }
2184
+ }
2185
+ );
2186
+ cmd.command("generate-motion").description(
2187
+ "animate the location's establishing shot into an atmospheric motion clip"
2188
+ ).requiredOption("--name <name>", "the location's display name (used in the prompt)").requiredOption("--motion-prompt <prompt>", "describe WHAT moves and HOW (drift, sway, fall)").requiredOption(
2189
+ "--source-image-url <url>",
2190
+ "URL of the establishing shot to animate"
2191
+ ).option(
2192
+ "--provider <provider>",
2193
+ "i2v provider \u2014 one of kling | kling-turbo | kling-3.0 | wan-i2v | wan-2.7-i2v | seedance-2",
2194
+ "kling"
2195
+ ).option("--style <style>", "realistic | anime | 3d-pixar | illustration", "realistic").option("--canonical-description <desc>", "LLM caption to anchor the prompt with").option(
2196
+ "--attach-to-location-id <id>",
2197
+ "auto-attach result to this location's atmosphere_motions bucket"
2198
+ ).option(
2199
+ "--attach-name <name>",
2200
+ "display name for the atmosphere_motions entry (paired with --attach-to-location-id)"
2201
+ ).option("--aspect-ratio <ratio>", "override default 16:9 \u2014 one of 1:1 | 3:4 | 16:9 | 9:16").option("--profile <name>").option("--json").option("--watch", "poll the motion job until completion").action(
2202
+ async (opts) => {
2203
+ try {
2204
+ const client = buildClient(opts.profile);
2205
+ const result = await client.locations.generateMotion({
2206
+ name: opts.name,
2207
+ motionPrompt: opts.motionPrompt,
2208
+ sourceImageUrl: opts.sourceImageUrl,
2209
+ provider: opts.provider,
2210
+ // Commander hands us a raw string; the SDK's union is the
2211
+ // canonical 4-value style set. We narrow here so a typo (e.g.
2212
+ // `--style anim`) doesn't silently send a value the route's Zod
2213
+ // would reject — surface a clear CLI error instead.
2214
+ style: opts.style,
2215
+ canonicalDescription: opts.canonicalDescription,
2216
+ attachToLocationId: opts.attachToLocationId,
2217
+ attachName: opts.attachName,
2218
+ // `aspectRatio` is a 4-value union (1:1 / 3:4 / 16:9 / 9:16). We
2219
+ // pass commander's raw string through with a narrowing cast; the
2220
+ // route's `z.enum(CHARACTER_ASPECT_OPTIONS)` is the source of
2221
+ // truth on rejection — keeping the CLI thin avoids drift if we
2222
+ // ever extend the option set.
2223
+ aspectRatio: opts.aspectRatio
2224
+ });
2225
+ if (opts.json && !opts.watch) {
2226
+ emit(result, opts);
2227
+ return;
2228
+ }
2229
+ success(`motion generation started \u2014 job ${result.jobId}`);
2230
+ if (!opts.watch) {
2231
+ dim(`follow: nodaro jobs get ${result.jobId}`);
2232
+ return;
2233
+ }
2234
+ await watchUntilTerminal({
2235
+ fetch: () => client.jobs.get(result.jobId),
2236
+ label: result.jobId,
2237
+ ...opts
2238
+ });
2239
+ } catch (err) {
2240
+ handleError(err);
2241
+ }
2242
+ }
2243
+ );
2244
+ cmd.command("approve-main-image <id>").description("approve a completed generate-location job as the location's main image").requiredOption("--candidate-job-id <jobId>", "the candidate job id from `generate`").option("--profile <name>").option("--json").action(async (id, opts) => {
2245
+ try {
2246
+ const client = buildClient(opts.profile);
2247
+ const result = await client.locations.approveMainImage(id, opts.candidateJobId);
2248
+ if (opts.json) {
2249
+ emit(result, opts);
2250
+ return;
2251
+ }
2252
+ success(`main image approved \u2192 ${result.sourceImageUrl}`);
2253
+ if (result.canonicalDescription) {
2254
+ console.log(`caption: ${result.canonicalDescription}`);
2255
+ } else {
2256
+ dim("(LLM caption sub-failed \u2014 run `locations recaption <id>` to retry)");
2257
+ }
2258
+ } catch (err) {
2259
+ handleError(err);
2260
+ }
2261
+ });
2262
+ cmd.command("recaption <id>").description("re-run the LLM caption against the location's current main image").option("--profile <name>").option("--json").action(async (id, opts) => {
2263
+ try {
2264
+ const client = buildClient(opts.profile);
2265
+ const result = await client.locations.recaption(id);
2266
+ if (opts.json) {
2267
+ emit(result, opts);
2268
+ return;
2269
+ }
2270
+ success(`caption refreshed`);
2271
+ console.log(result.canonicalDescription);
2272
+ } catch (err) {
2273
+ handleError(err);
2274
+ }
2275
+ });
2276
+ return cmd;
2277
+ }
2278
+ function registerLocationsCommands(program2) {
2279
+ program2.addCommand(locationsCommand());
2280
+ }
2281
+ var OBJECT_CATEGORIES = [
2282
+ "furniture",
2283
+ "vehicle",
2284
+ "weapon",
2285
+ "food",
2286
+ "clothing",
2287
+ "electronics",
2288
+ "nature",
2289
+ "tool",
2290
+ "animal",
2291
+ "other"
2292
+ ];
2293
+ var OBJECT_STYLES = ["realistic", "anime", "3d-pixar", "illustration"];
2294
+ var ASPECT_RATIOS = ["1:1", "3:4", "16:9", "9:16", "4:3"];
2295
+ var MOTION_PROVIDERS = [
2296
+ "kling-turbo",
2297
+ "kling",
2298
+ "kling-3.0",
2299
+ "minimax",
2300
+ "hailuo-2.3",
2301
+ "wan-i2v",
2302
+ "seedance",
2303
+ "bytedance-lite"
2304
+ ];
2305
+ var ASSET_TYPE_TO_COLUMN2 = {
2306
+ angles: "angles",
2307
+ materials: "materials",
2308
+ variations: "variations",
2309
+ motion: "motion_clips"
2310
+ };
2311
+ function objectsCommand() {
2312
+ const cmd = new Command("objects").description(
2313
+ "list, inspect, and manage objects; trigger main-image / asset generation"
2314
+ );
2315
+ 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(
2316
+ async (opts) => {
2317
+ try {
2318
+ const client = buildClient(opts.profile);
2319
+ const result = await client.objects.list({
2320
+ archived: opts.archived,
2321
+ projectId: opts.project
2322
+ });
2323
+ if (opts.json) {
2324
+ emit(result.objects, opts);
2325
+ return;
2326
+ }
2327
+ table(
2328
+ result.objects.map((o) => ({
2329
+ id: o.id,
2330
+ name: o.name,
2331
+ category: o.category ?? "",
2332
+ mainImage: o.sourceImageUrl ? "yes" : "no",
2333
+ updatedAt: o.updatedAt
2334
+ })),
2335
+ ["id", "name", "category", "mainImage", "updatedAt"]
2336
+ );
2337
+ } catch (err) {
2338
+ handleError(err);
2339
+ }
2340
+ }
2341
+ );
2342
+ cmd.command("get <id>").description("show one object by id (full asset arrays + pending jobs)").option("--profile <name>").option("--json").action(async (id, opts) => {
2343
+ try {
2344
+ const client = buildClient(opts.profile);
2345
+ const result = await client.objects.get(id);
2346
+ if (opts.json) emit(result, opts);
2347
+ else detail(result);
2348
+ } catch (err) {
2349
+ handleError(err);
2350
+ }
2351
+ });
2352
+ cmd.command("create <name>").description("create a new object row (no main image yet \u2014 call `generate` next)").requiredOption("--node-id <id>", "canvas node id to bind to").option("--description <desc>", "freeform identity notes").addOption(new Option("--category <category>", "object category").choices([...OBJECT_CATEGORIES])).addOption(new Option("--style <style>", "object visual style").choices([...OBJECT_STYLES])).option("--project <projectId>", "drop the row into this project").option("--profile <name>").option("--json").action(
2353
+ async (name, opts) => {
2354
+ try {
2355
+ const client = buildClient(opts.profile);
2356
+ const result = await client.objects.create({
2357
+ nodeId: opts.nodeId,
2358
+ projectId: opts.project,
2359
+ name,
2360
+ description: opts.description,
2361
+ category: opts.category,
2362
+ style: opts.style
2363
+ });
2364
+ if (opts.json) {
2365
+ emit(result, opts);
2366
+ return;
2367
+ }
2368
+ success(`created object ${result.id} (${name})`);
2369
+ } catch (err) {
2370
+ handleError(err);
2371
+ }
2372
+ }
2373
+ );
2374
+ cmd.command("update <id>").description("update identity fields on an existing object").option("--name <name>").option("--description <desc>").addOption(new Option("--category <category>", "object category").choices([...OBJECT_CATEGORIES])).addOption(new Option("--style <style>", "object visual style").choices([...OBJECT_STYLES])).option("--style-lock <bool>", "lock asset gens to the canonical style (true/false)").option("--canonical-description <desc>", "manually set the LLM-style caption (skips recaption)").option("--expected-updated-at <iso>", "optimistic-concurrency token \u2014 fail with 409 on mismatch").option("--profile <name>").option("--json").action(
2375
+ async (id, opts) => {
2376
+ try {
2377
+ const has = [
2378
+ opts.name,
2379
+ opts.description,
2380
+ opts.category,
2381
+ opts.style,
2382
+ opts.styleLock,
2383
+ opts.canonicalDescription
2384
+ ].some((v) => v !== void 0);
2385
+ if (!has) {
2386
+ throw new Error(
2387
+ "nothing to update \u2014 provide at least one of --name / --description / --category / --style / --style-lock / --canonical-description"
2388
+ );
2389
+ }
2390
+ const client = buildClient(opts.profile);
2391
+ const patch = {};
2392
+ if (opts.name !== void 0) patch.name = opts.name;
2393
+ if (opts.description !== void 0) patch.description = opts.description;
2394
+ if (opts.category !== void 0) patch.category = opts.category;
2395
+ if (opts.style !== void 0) patch.style = opts.style;
2396
+ if (opts.styleLock !== void 0) {
2397
+ patch.styleLock = parseBoolFlag(opts.styleLock, "style-lock");
2398
+ }
2399
+ if (opts.canonicalDescription !== void 0) {
2400
+ patch.canonicalDescription = opts.canonicalDescription;
2401
+ }
2402
+ if (opts.expectedUpdatedAt !== void 0) {
2403
+ patch.expectedUpdatedAt = opts.expectedUpdatedAt;
2404
+ }
2405
+ const result = await client.objects.update(id, patch);
2406
+ if (opts.json) {
2407
+ emit(result, opts);
2408
+ return;
2409
+ }
2410
+ success(`updated object ${result.id} (updatedAt ${result.updatedAt})`);
2411
+ } catch (err) {
2412
+ handleError(err);
2413
+ }
2414
+ }
2415
+ );
2416
+ cmd.command("delete <id>").description("soft-delete (archive) an object \u2014 restore with `objects restore <id>`").option("--permanent", "permanently delete (archived rows only)").option("--profile <name>").option("--json").action(async (id, opts) => {
2417
+ try {
2418
+ const client = buildClient(opts.profile);
2419
+ if (opts.permanent) {
2420
+ const result2 = await client.objects.permanentDelete(id);
2421
+ if (opts.json) {
2422
+ emit(result2, opts);
2423
+ return;
2424
+ }
2425
+ success(`permanently deleted object ${id}`);
2426
+ return;
2427
+ }
2428
+ const result = await client.objects.delete(id);
2429
+ if (opts.json) {
2430
+ emit(result, opts);
2431
+ return;
2432
+ }
2433
+ success(`archived object ${id}`);
2434
+ } catch (err) {
2435
+ handleError(err);
2436
+ }
2437
+ });
2438
+ cmd.command("restore <id>").description("un-archive a soft-deleted object (auto-suffixes name on conflict)").option("--profile <name>").option("--json").action(async (id, opts) => {
2439
+ try {
2440
+ const client = buildClient(opts.profile);
2441
+ const result = await client.objects.restore(id);
2442
+ if (opts.json) {
2443
+ emit(result, opts);
2444
+ return;
2445
+ }
2446
+ success(`restored object ${result.id} (${result.name})`);
2447
+ } catch (err) {
2448
+ handleError(err);
2449
+ }
2450
+ });
2451
+ cmd.command("generate").description("trigger main-image generation for an object").requiredOption("--name <name>", "the object's display name (used in the prompt)").option("--description <desc>").option("--user-prompt <prompt>", "additional free-text prompt").addOption(new Option("--category <category>", "object category").choices([...OBJECT_CATEGORIES])).addOption(new Option("--style <style>", "object visual style").choices([...OBJECT_STYLES])).option("--provider <provider>", "image provider (defaults to nano-banana)").option("--count <n>", "1, 2, or 4 candidate main images", "1").option("--attach-to-object-id <id>", "auto-attach result to this object row (count=1 only)").option("--seed-prompt-hint <hint>", "parameter-picker prompt-fragment pass-through").option("--profile <name>").option("--json").option("--watch", "poll all jobs until they complete (parallel)").action(
2452
+ async (opts) => {
2453
+ try {
2454
+ const client = buildClient(opts.profile);
2455
+ const result = await client.objects.generate({
2456
+ name: opts.name,
2457
+ description: opts.description,
2458
+ userPrompt: opts.userPrompt,
2459
+ category: opts.category,
2460
+ style: opts.style,
2461
+ provider: opts.provider,
2462
+ count: parseCount(opts.count),
2463
+ attachToObjectId: opts.attachToObjectId,
2464
+ seedPromptHint: opts.seedPromptHint
2465
+ });
2466
+ const jobIds = result.jobIds ?? (result.jobId ? [result.jobId] : []);
2467
+ if (opts.json && !opts.watch) {
2468
+ emit(result, opts);
2469
+ return;
2470
+ }
2471
+ success(`generation started \u2014 ${jobIds.length} job(s)`);
2472
+ for (const jobId of jobIds) {
2473
+ console.log(` ${jobId}`);
2474
+ }
2475
+ if (!opts.watch) {
2476
+ dim(`follow: nodaro jobs get ${jobIds[0]}`);
2477
+ return;
2478
+ }
2479
+ await Promise.all(
2480
+ jobIds.map(
2481
+ (id) => watchUntilTerminal({
2482
+ fetch: () => client.jobs.get(id),
2483
+ label: id,
2484
+ ...opts
2485
+ })
2486
+ )
2487
+ );
2488
+ } catch (err) {
2489
+ handleError(err);
2490
+ }
2491
+ }
2492
+ );
2493
+ cmd.command("generate-asset").description("trigger a single angles / materials / variations / motion / custom asset generation").addOption(
2494
+ new Option("--asset-type <type>", "asset bucket to generate into").choices([...OBJECT_ASSET_TYPES])
2495
+ ).requiredOption("--variant <name>", "the named variant (e.g. 'front', 'wood', 'weathered')").requiredOption("--attach-to-object-id <id>", "object row to append the result to").addOption(
2496
+ new Option("--attach-to-column <col>", "override the attach column (required for --asset-type custom)").choices([
2497
+ ...OBJECT_ATTACH_COLUMNS
2498
+ ])
2499
+ ).option("--name <name>", "object's display name (avoids an extra GET to fetch it)").option("--description <desc>", "object's description (avoids an extra GET to fetch it)").option("--seed-prompt-hint <hint>", "parameter-picker prompt-fragment pass-through").option("--profile <name>").option("--json").option("--watch", "poll until completion").action(
2500
+ async (opts) => {
2501
+ try {
2502
+ if (!opts.assetType) {
2503
+ throw new Error("--asset-type is required");
2504
+ }
2505
+ const client = buildClient(opts.profile);
2506
+ let name = opts.name;
2507
+ let description = opts.description;
2508
+ if (name === void 0 || description === void 0) {
2509
+ const obj = await client.objects.get(opts.attachToObjectId);
2510
+ name ??= obj.name;
2511
+ description ??= obj.description ?? void 0;
2512
+ }
2513
+ const inferredColumn = ASSET_TYPE_TO_COLUMN2[opts.assetType];
2514
+ const resolvedColumn = opts.attachToColumn ?? inferredColumn;
2515
+ if (!resolvedColumn) {
2516
+ throw new Error(
2517
+ `--attach-to-column is required for --asset-type ${opts.assetType} (no inferred column)`
2518
+ );
2519
+ }
2520
+ const result = await client.objects.generateAsset({
2521
+ assetType: opts.assetType,
2522
+ variant: opts.variant,
2523
+ name,
2524
+ description,
2525
+ attachToObjectId: opts.attachToObjectId,
2526
+ attachToColumn: resolvedColumn,
2527
+ attachName: opts.variant,
2528
+ seedPromptHint: opts.seedPromptHint
2529
+ });
2530
+ if (opts.json && !opts.watch) {
2531
+ emit(result, opts);
2532
+ return;
2533
+ }
2534
+ success(`generation started \u2014 job ${result.jobId}`);
2535
+ if (!opts.watch) {
2536
+ dim(`follow: nodaro jobs get ${result.jobId}`);
2537
+ return;
2538
+ }
2539
+ await watchUntilTerminal({
2540
+ fetch: () => client.jobs.get(result.jobId),
2541
+ label: result.jobId,
2542
+ ...opts
2543
+ });
2544
+ } catch (err) {
2545
+ handleError(err);
2546
+ }
2547
+ }
2548
+ );
2549
+ cmd.command("generate-motion").description(
2550
+ "animate the object's main image into a motion clip (rotation, orbit, hover, drift)"
2551
+ ).requiredOption("--name <name>", "the object's display name (used in the prompt)").requiredOption("--motion-prompt <prompt>", "describe WHAT moves and HOW (rotate, orbit, hover)").requiredOption(
2552
+ "--source-image-url <url>",
2553
+ "URL of the product-shot to animate"
2554
+ ).addOption(
2555
+ new Option("--provider <provider>", "i2v provider").choices([...MOTION_PROVIDERS]).default("kling-turbo")
2556
+ ).addOption(
2557
+ new Option("--style <style>", "object visual style").choices([...OBJECT_STYLES]).default("realistic")
2558
+ ).option("--canonical-description <desc>", "LLM caption to anchor the prompt with").option(
2559
+ "--attach-to-object-id <id>",
2560
+ "auto-attach result to this object's motion_clips bucket"
2561
+ ).option(
2562
+ "--attach-name <name>",
2563
+ "display name for the motion_clips entry (paired with --attach-to-object-id)"
2564
+ ).addOption(
2565
+ new Option("--aspect-ratio <ratio>", "aspect ratio (default 1:1 product-showcase)").choices([...ASPECT_RATIOS]).default("1:1")
2566
+ ).option("--seed-prompt-hint <hint>", "parameter-picker prompt-fragment pass-through").option("--profile <name>").option("--json").option("--watch", "poll the motion job until completion").action(
2567
+ async (opts) => {
2568
+ try {
2569
+ const client = buildClient(opts.profile);
2570
+ const result = await client.objects.generateMotion({
2571
+ name: opts.name,
2572
+ motionPrompt: opts.motionPrompt,
2573
+ sourceImageUrl: opts.sourceImageUrl,
2574
+ provider: opts.provider,
2575
+ style: opts.style,
2576
+ canonicalDescription: opts.canonicalDescription,
2577
+ attachToObjectId: opts.attachToObjectId,
2578
+ attachName: opts.attachName,
2579
+ seedPromptHint: opts.seedPromptHint,
2580
+ aspectRatio: opts.aspectRatio
2581
+ });
2582
+ if (opts.json && !opts.watch) {
2583
+ emit(result, opts);
2584
+ return;
2585
+ }
2586
+ success(`motion generation started \u2014 job ${result.jobId}`);
2587
+ if (!opts.watch) {
2588
+ dim(`follow: nodaro jobs get ${result.jobId}`);
2589
+ return;
2590
+ }
2591
+ await watchUntilTerminal({
2592
+ fetch: () => client.jobs.get(result.jobId),
2593
+ label: result.jobId,
2594
+ ...opts
2595
+ });
2596
+ } catch (err) {
2597
+ handleError(err);
2598
+ }
2599
+ }
2600
+ );
2601
+ cmd.command("approve-main-image <id>").description("approve a completed generate-object job as the object's main image").requiredOption("--candidate-job-id <jobId>", "the candidate job id from `generate`").option(
2602
+ "--expected-updated-at <iso>",
2603
+ "optimistic-concurrency token \u2014 fail with 409 on mismatch"
2604
+ ).option("--profile <name>").option("--json").action(
2605
+ async (id, opts) => {
2606
+ try {
2607
+ const client = buildClient(opts.profile);
2608
+ const result = await client.objects.approveMainImage(
2609
+ id,
2610
+ opts.candidateJobId,
2611
+ opts.expectedUpdatedAt
2612
+ );
2613
+ if (opts.json) {
2614
+ emit(result, opts);
2615
+ return;
2616
+ }
2617
+ success(`main image approved \u2192 ${result.sourceImageUrl}`);
2618
+ if (result.canonicalDescription) {
2619
+ console.log(`caption: ${result.canonicalDescription}`);
2620
+ } else {
2621
+ dim("(LLM caption sub-failed \u2014 run `objects recaption <id>` to retry)");
2622
+ }
2623
+ } catch (err) {
2624
+ handleError(err);
2625
+ }
2626
+ }
2627
+ );
2628
+ cmd.command("recaption <id>").description("re-run the LLM caption against the object's current main image").option("--profile <name>").option("--json").action(async (id, opts) => {
2629
+ try {
2630
+ const client = buildClient(opts.profile);
2631
+ const result = await client.objects.recaption(id);
2632
+ if (opts.json) {
2633
+ emit(result, opts);
2634
+ return;
2635
+ }
2636
+ success(`caption refreshed`);
2637
+ console.log(result.canonicalDescription);
2638
+ } catch (err) {
2639
+ handleError(err);
2640
+ }
2641
+ });
2642
+ return cmd;
2643
+ }
2644
+ function registerObjectsCommands(program2) {
2645
+ program2.addCommand(objectsCommand());
2646
+ }
2647
+
2648
+ // src/index.ts
2649
+ function readVersion() {
2650
+ try {
2651
+ return require_package().version;
2652
+ } catch {
2653
+ return "0.0.0-dev";
2654
+ }
2655
+ }
2656
+ 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");
2657
+ program.addCommand(authCommand());
2658
+ program.addCommand(projectsCommand());
2659
+ program.addCommand(workflowsCommand());
2660
+ program.addCommand(appsCommand());
2661
+ program.addCommand(nodesCommand());
2662
+ program.addCommand(jobsCommand());
2663
+ program.addCommand(executionsCommand());
2664
+ program.addCommand(charactersCommand());
2665
+ program.addCommand(promptCommand());
2666
+ program.addCommand(voiceCommand());
2667
+ program.addCommand(presetsCommand());
2668
+ program.addCommand(communityCommand());
2669
+ program.addCommand(pickerCatalogsCommand());
2670
+ registerLocationsCommands(program);
2671
+ registerObjectsCommands(program);
2672
+ program.parseAsync().catch((err) => {
2673
+ console.error(err instanceof Error ? err.message : err);
2674
+ process.exit(1);
2675
+ });
2676
+ //# sourceMappingURL=index.js.map
2677
+ //# sourceMappingURL=index.js.map