@nodaro/cli 1.31.0 → 1.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -3
- package/dist/index.js +1123 -57
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { join } from 'path';
|
|
|
9
9
|
import { createServer } from 'http';
|
|
10
10
|
import { randomBytes } from 'crypto';
|
|
11
11
|
import { spawn } from 'child_process';
|
|
12
|
-
import { ContinuationRefusedError, createClient, StaticTokenAuth, UnauthorizedError, NodaroError, LOCATION_ASSET_TYPES, LOCATION_ATTACH_COLUMNS, OBJECT_ASSET_TYPES, OBJECT_ATTACH_COLUMNS } from '@nodaro/sdk';
|
|
12
|
+
import { ContinuationRefusedError, createClient, StaticTokenAuth, UnauthorizedError, NodaroError, CallbackAuth, LOCATION_ASSET_TYPES, LOCATION_ATTACH_COLUMNS, OBJECT_ASSET_TYPES, OBJECT_ATTACH_COLUMNS } from '@nodaro/sdk';
|
|
13
13
|
import select from '@inquirer/select';
|
|
14
14
|
import checkbox from '@inquirer/checkbox';
|
|
15
15
|
import input from '@inquirer/input';
|
|
@@ -18,8 +18,8 @@ import { TRANSCRIBE_PROVIDERS, transcribeLaneSupportsWordTimestamps, DIALOGUE_PR
|
|
|
18
18
|
import { OVERLAY_ANCHORS, OVERLAY_PLATFORM_IDS, DEFAULT_VIDEO_MASK_PROVIDER, VIDEO_MASK_PROVIDERS, VIDEO_MASK_LIMITS, MASK_COMPOSITE_BOUNDS, MASK_COMPOSITE_DEFAULTS, MASK_COMPOSITE_BACKGROUND_FITS, MASK_COMPOSITE_AUDIO_SOURCES } from '@nodaro/shared/media';
|
|
19
19
|
import { ALL_CAPTION_STYLES, DEFAULT_CAPTION_LOOK, CAPTION_LOOK_IDS, CAPTION_MAX_WORDS_PER_LINE_MIN, CAPTION_MAX_WORDS_PER_LINE_MAX, SUPPORTED_FONT_NAMES } from '@nodaro/shared/captions';
|
|
20
20
|
import { VIDEO_OVERLAY_PRESET_IDS, VIDEO_OVERLAY_CORNERS, VIDEO_OVERLAY_OUTPUT_ASPECTS, isVideoOverlayPresetId, isVideoOverlayCorner, isVideoOverlayOutputAspect, VIDEO_OVERLAY_FITS } from '@nodaro/shared/video';
|
|
21
|
+
import { collectionRecordHeadline, parseNodePresetExport } from '@nodaro/shared/nodes';
|
|
21
22
|
import { SOCIAL_PLATFORMS, COMPETITOR_ACCOUNT_KEYS, isMeasurableCard, isSocialPost, COMPETITOR_ABOUT_PLATFORMS, COMPETITOR_SCHEDULES } from '@nodaro/shared/social';
|
|
22
|
-
import { collectionRecordHeadline } from '@nodaro/shared/nodes';
|
|
23
23
|
import { RECAST_SEGMENT_PACKS } from '@nodaro/shared/apps';
|
|
24
24
|
import { SPEAKER_LAYOUT_IDS, EDL_TARGET_ASPECTS, EDIT_PLAN_TIERS, EDIT_PLAN_MODES } from '@nodaro/shared/edl';
|
|
25
25
|
|
|
@@ -37,7 +37,7 @@ var require_package = __commonJS({
|
|
|
37
37
|
"package.json"(exports$1, module) {
|
|
38
38
|
module.exports = {
|
|
39
39
|
name: "@nodaro/cli",
|
|
40
|
-
version: "1.
|
|
40
|
+
version: "1.32.0",
|
|
41
41
|
description: "Command-line interface for Nodaro \u2014 list and run workflows, inspect jobs and executions, manage projects from the terminal.",
|
|
42
42
|
type: "module",
|
|
43
43
|
license: "Apache-2.0",
|
|
@@ -78,11 +78,11 @@ var require_package = __commonJS({
|
|
|
78
78
|
"@inquirer/confirm": "^6.0.12",
|
|
79
79
|
"@inquirer/input": "^5.0.12",
|
|
80
80
|
"@inquirer/select": "^5.1.4",
|
|
81
|
-
"@nodaro/sdk": "^2.
|
|
82
|
-
"@nodaro/shared": "^3.
|
|
81
|
+
"@nodaro/sdk": "^2.29.0",
|
|
82
|
+
"@nodaro/shared": "^3.33.0",
|
|
83
83
|
commander: "^12.1.0",
|
|
84
84
|
picocolors: "^1.1.1",
|
|
85
|
-
"@nodaro/prompts": "^1.
|
|
85
|
+
"@nodaro/prompts": "^1.39.0"
|
|
86
86
|
},
|
|
87
87
|
devDependencies: {
|
|
88
88
|
tsup: "^8.5.0",
|
|
@@ -102,6 +102,7 @@ var require_package = __commonJS({
|
|
|
102
102
|
};
|
|
103
103
|
}
|
|
104
104
|
});
|
|
105
|
+
var DEFAULT_BASE_URL = "https://app.nodaro.ai";
|
|
105
106
|
function configDir() {
|
|
106
107
|
return process.env.NODARO_CONFIG_DIR ?? join(homedir(), ".config", "nodaro");
|
|
107
108
|
}
|
|
@@ -155,6 +156,9 @@ function deleteProfile(name) {
|
|
|
155
156
|
saveConfig(config);
|
|
156
157
|
return true;
|
|
157
158
|
}
|
|
159
|
+
function terminalSafe(text) {
|
|
160
|
+
return text.replace(/[\u0000-\u001f\u007f-\u009f]/g, "\uFFFD");
|
|
161
|
+
}
|
|
158
162
|
function emit(value, opts = {}) {
|
|
159
163
|
if (opts.json) {
|
|
160
164
|
const indent = process.stdout.isTTY ? 2 : void 0;
|
|
@@ -203,7 +207,7 @@ function table(rows2, columns) {
|
|
|
203
207
|
}
|
|
204
208
|
function format(value) {
|
|
205
209
|
if (value === null || value === void 0) return "";
|
|
206
|
-
if (typeof value === "string") return value;
|
|
210
|
+
if (typeof value === "string") return terminalSafe(value);
|
|
207
211
|
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
208
212
|
if (value instanceof Date) return value.toISOString();
|
|
209
213
|
return JSON.stringify(value);
|
|
@@ -319,7 +323,6 @@ function escapeHtml(s) {
|
|
|
319
323
|
}
|
|
320
324
|
|
|
321
325
|
// src/commands/auth.ts
|
|
322
|
-
var DEFAULT_BASE_URL = "https://app.nodaro.ai";
|
|
323
326
|
function authCommand() {
|
|
324
327
|
const cmd = new Command("auth").description("manage credentials for one or more Nodaro instances");
|
|
325
328
|
cmd.command("login").description("save a token for a profile (browser flow by default; --token or --no-browser for paste)").option("--profile <name>", "profile name", "production").option("--token <token>", "API token (skips browser flow and prompt)").option("--base-url <url>", "Nodaro base URL", DEFAULT_BASE_URL).option("--no-browser", "skip the browser flow and prompt for a pasted token instead").action(async (opts) => {
|
|
@@ -406,7 +409,15 @@ function saveWorkspace(profileName, workspaceId) {
|
|
|
406
409
|
}
|
|
407
410
|
|
|
408
411
|
// src/client.ts
|
|
409
|
-
var CLI_VERSION = "1.
|
|
412
|
+
var CLI_VERSION = "1.32.0" ;
|
|
413
|
+
function buildPublicClient(opts = {}) {
|
|
414
|
+
const { profile } = getProfile(opts.profile);
|
|
415
|
+
return createClient({
|
|
416
|
+
baseUrl: opts.baseUrl ?? profile?.baseUrl ?? DEFAULT_BASE_URL,
|
|
417
|
+
auth: new CallbackAuth(() => null),
|
|
418
|
+
clientLabel: `cli/${CLI_VERSION}`
|
|
419
|
+
});
|
|
420
|
+
}
|
|
410
421
|
function buildClient(profileName) {
|
|
411
422
|
const { name, profile } = getProfile(profileName);
|
|
412
423
|
if (!profile) {
|
|
@@ -670,8 +681,6 @@ function sessionsCommand() {
|
|
|
670
681
|
});
|
|
671
682
|
return cmd;
|
|
672
683
|
}
|
|
673
|
-
|
|
674
|
-
// src/util.ts
|
|
675
684
|
function collectVariadic(value, previous) {
|
|
676
685
|
return [...previous ?? [], value];
|
|
677
686
|
}
|
|
@@ -739,6 +748,101 @@ async function reportQueuedJob(result, fetchJob, opts) {
|
|
|
739
748
|
json: opts.json
|
|
740
749
|
});
|
|
741
750
|
}
|
|
751
|
+
var TRAINING_IN_FLIGHT = /* @__PURE__ */ new Set(["queued", "training"]);
|
|
752
|
+
function isTransientPollError(err) {
|
|
753
|
+
if (!(err instanceof NodaroError)) return true;
|
|
754
|
+
if (err.status === 408 || err.status === 429) return true;
|
|
755
|
+
return !(err.status >= 400 && err.status < 500);
|
|
756
|
+
}
|
|
757
|
+
async function watchTraining(opts) {
|
|
758
|
+
const intervalMs = opts.intervalMs ?? 1e4;
|
|
759
|
+
const start = Date.now();
|
|
760
|
+
let lastStatus = "";
|
|
761
|
+
let lastInFlight;
|
|
762
|
+
for (; ; ) {
|
|
763
|
+
let result;
|
|
764
|
+
try {
|
|
765
|
+
result = await opts.fetch();
|
|
766
|
+
} catch (err) {
|
|
767
|
+
if (!isTransientPollError(err)) throw err;
|
|
768
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
769
|
+
info(`[${elapsed(start)}s] poll failed (will retry): ${errMsg}`);
|
|
770
|
+
await sleep(intervalMs);
|
|
771
|
+
continue;
|
|
772
|
+
}
|
|
773
|
+
const status = result.status;
|
|
774
|
+
if (status !== lastStatus) {
|
|
775
|
+
info(`[${elapsed(start)}s] ${opts.label} \u2192 ${status}`);
|
|
776
|
+
lastStatus = status;
|
|
777
|
+
}
|
|
778
|
+
if (TRAINING_IN_FLIGHT.has(status)) {
|
|
779
|
+
lastInFlight = status;
|
|
780
|
+
await sleep(intervalMs);
|
|
781
|
+
continue;
|
|
782
|
+
}
|
|
783
|
+
if (opts.json) {
|
|
784
|
+
emit(result, opts);
|
|
785
|
+
return result;
|
|
786
|
+
}
|
|
787
|
+
if (status === "succeeded") {
|
|
788
|
+
success("training succeeded");
|
|
789
|
+
return result;
|
|
790
|
+
}
|
|
791
|
+
if (status === "failed") {
|
|
792
|
+
if (result.error) info(`reason: ${result.error}`);
|
|
793
|
+
process.exit(2);
|
|
794
|
+
}
|
|
795
|
+
if (status === "cancelled") process.exit(130);
|
|
796
|
+
if (status === "untrained") {
|
|
797
|
+
if (lastInFlight === "training") {
|
|
798
|
+
info("the training was removed before it finished");
|
|
799
|
+
process.exit(130);
|
|
800
|
+
}
|
|
801
|
+
if (lastInFlight === "queued") {
|
|
802
|
+
info("the training could not be started (nothing was charged), or was removed before it started");
|
|
803
|
+
process.exit(2);
|
|
804
|
+
}
|
|
805
|
+
info("no training in flight");
|
|
806
|
+
}
|
|
807
|
+
return result;
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
async function watchJobsUntilTerminal(opts) {
|
|
811
|
+
const intervalMs = opts.intervalMs ?? 2e3;
|
|
812
|
+
const start = Date.now();
|
|
813
|
+
const lastStatus = /* @__PURE__ */ new Map();
|
|
814
|
+
const settled = /* @__PURE__ */ new Map();
|
|
815
|
+
for (; ; ) {
|
|
816
|
+
for (const jobId of opts.jobIds) {
|
|
817
|
+
if (settled.has(jobId)) continue;
|
|
818
|
+
try {
|
|
819
|
+
const { data } = await opts.fetchStatus(jobId);
|
|
820
|
+
if (data.status !== lastStatus.get(jobId)) {
|
|
821
|
+
info(`[${elapsed(start)}s] ${jobId} \u2192 ${data.status}`);
|
|
822
|
+
lastStatus.set(jobId, data.status);
|
|
823
|
+
}
|
|
824
|
+
if (TERMINAL.has(data.status) || data.status === "pending_review") settled.set(jobId, data);
|
|
825
|
+
} catch (err) {
|
|
826
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
827
|
+
info(`[${elapsed(start)}s] ${jobId} poll failed (will retry): ${errMsg}`);
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
if (settled.size === opts.jobIds.length) break;
|
|
831
|
+
await sleep(intervalMs);
|
|
832
|
+
}
|
|
833
|
+
const finals = opts.jobIds.map((jobId) => settled.get(jobId));
|
|
834
|
+
if (opts.json) {
|
|
835
|
+
emit(finals, opts);
|
|
836
|
+
return finals;
|
|
837
|
+
}
|
|
838
|
+
const completed = finals.filter((job) => job.status === "completed").length;
|
|
839
|
+
if (completed === finals.length) {
|
|
840
|
+
success(`all ${finals.length} completed in ${elapsed(start)}s`);
|
|
841
|
+
return finals;
|
|
842
|
+
}
|
|
843
|
+
info(`${completed} of ${finals.length} completed`);
|
|
844
|
+
process.exit(finals.some((job) => job.status === "failed" || job.status === "cancelled") ? 2 : 3);
|
|
845
|
+
}
|
|
742
846
|
function elapsed(startMs) {
|
|
743
847
|
return ((Date.now() - startMs) / 1e3).toFixed(1);
|
|
744
848
|
}
|
|
@@ -1014,8 +1118,59 @@ async function watchExecution(client, executionId, opts) {
|
|
|
1014
1118
|
...opts
|
|
1015
1119
|
});
|
|
1016
1120
|
}
|
|
1121
|
+
var RATING_FILTERS = ["good", "bad", "rated", "unrated"];
|
|
1122
|
+
function list(value) {
|
|
1123
|
+
if (value === void 0) return void 0;
|
|
1124
|
+
const values = value.split(",").map((v) => v.trim()).filter(Boolean);
|
|
1125
|
+
return values.length > 0 ? values : void 0;
|
|
1126
|
+
}
|
|
1127
|
+
function ratingFilter(value) {
|
|
1128
|
+
if (value === void 0) return void 0;
|
|
1129
|
+
if (!RATING_FILTERS.includes(value)) {
|
|
1130
|
+
throw new Error(`--rating takes ${RATING_FILTERS.join(", ")} (got "${value}")`);
|
|
1131
|
+
}
|
|
1132
|
+
return value;
|
|
1133
|
+
}
|
|
1134
|
+
function ratingArg(value) {
|
|
1135
|
+
if (value === "clear") return null;
|
|
1136
|
+
if (value === "good" || value === "bad") return value;
|
|
1137
|
+
throw new Error(`a rating is good, bad or clear (got "${value}")`);
|
|
1138
|
+
}
|
|
1017
1139
|
function jobsCommand() {
|
|
1018
|
-
const cmd = new Command("jobs").description("inspect and cancel
|
|
1140
|
+
const cmd = new Command("jobs").description("list, inspect, rate and cancel jobs");
|
|
1141
|
+
cmd.command("list").description("your jobs, newest first").option("--status <statuses>", "only these statuses, comma-separated (e.g. failed,cancelled)").option("--type <types>", "only these input_data.type values, comma-separated (e.g. generate-image)").option("--origin <origin>", "only jobs this client app sent").option("--favorited", "only jobs you favorited").option("--no-favorited", "only jobs you did not favorite").option("--rating <rating>", "good, bad, rated (any) or unrated").option("--limit <n>", "page size (1-100)").option("--cursor <cursor>", "the previous page's next").option("--profile <name>").option("--json").action(async (opts) => {
|
|
1142
|
+
try {
|
|
1143
|
+
const rating = ratingFilter(opts.rating);
|
|
1144
|
+
const client = buildClient(opts.profile);
|
|
1145
|
+
const page = await client.jobs.list({
|
|
1146
|
+
status: list(opts.status),
|
|
1147
|
+
type: list(opts.type),
|
|
1148
|
+
origin: opts.origin,
|
|
1149
|
+
favorited: opts.favorited,
|
|
1150
|
+
rating,
|
|
1151
|
+
limit: opts.limit ? Number(opts.limit) : void 0,
|
|
1152
|
+
cursor: opts.cursor
|
|
1153
|
+
});
|
|
1154
|
+
if (opts.json) {
|
|
1155
|
+
emit(page, opts);
|
|
1156
|
+
return;
|
|
1157
|
+
}
|
|
1158
|
+
table(
|
|
1159
|
+
page.data.map((job) => ({
|
|
1160
|
+
id: job.id,
|
|
1161
|
+
status: job.status,
|
|
1162
|
+
type: job.input_data?.type ?? job.job_type ?? "",
|
|
1163
|
+
favorited: job.favorited ? "yes" : "",
|
|
1164
|
+
rating: job.rating ?? "",
|
|
1165
|
+
created: job.created_at
|
|
1166
|
+
})),
|
|
1167
|
+
["id", "status", "type", "favorited", "rating", "created"]
|
|
1168
|
+
);
|
|
1169
|
+
if (page.next) dim(`next: --cursor ${page.next}`);
|
|
1170
|
+
} catch (err) {
|
|
1171
|
+
handleError(err);
|
|
1172
|
+
}
|
|
1173
|
+
});
|
|
1019
1174
|
cmd.command("get <id>").description("show one job by id").option("--profile <name>").option("--json").action(async (id, opts) => {
|
|
1020
1175
|
try {
|
|
1021
1176
|
const client = buildClient(opts.profile);
|
|
@@ -1026,6 +1181,17 @@ function jobsCommand() {
|
|
|
1026
1181
|
handleError(err);
|
|
1027
1182
|
}
|
|
1028
1183
|
});
|
|
1184
|
+
cmd.command("rate <id> <rating>").description("rate one of your jobs: good, bad, or clear to remove the rating").option("--profile <name>").option("--json").action(async (id, value, opts) => {
|
|
1185
|
+
try {
|
|
1186
|
+
const rating = ratingArg(value);
|
|
1187
|
+
const client = buildClient(opts.profile);
|
|
1188
|
+
const result = await client.jobs.rate(id, rating);
|
|
1189
|
+
if (opts.json) emit(result, opts);
|
|
1190
|
+
else success(rating ? `rated job ${id} ${rating}` : `cleared the rating of job ${id}`);
|
|
1191
|
+
} catch (err) {
|
|
1192
|
+
handleError(err);
|
|
1193
|
+
}
|
|
1194
|
+
});
|
|
1029
1195
|
cmd.command("cancel <id>").description("cancel a pending or running job").option("--profile <name>").option("--json").action(async (id, opts) => {
|
|
1030
1196
|
try {
|
|
1031
1197
|
const client = buildClient(opts.profile);
|
|
@@ -1038,6 +1204,62 @@ function jobsCommand() {
|
|
|
1038
1204
|
});
|
|
1039
1205
|
return cmd;
|
|
1040
1206
|
}
|
|
1207
|
+
var MEDIA_TYPES = ["image", "video", "audio"];
|
|
1208
|
+
function mediaType(value) {
|
|
1209
|
+
if (value === void 0) return void 0;
|
|
1210
|
+
if (!MEDIA_TYPES.includes(value)) {
|
|
1211
|
+
throw new Error(`--type takes ${MEDIA_TYPES.join(", ")} (got "${value}")`);
|
|
1212
|
+
}
|
|
1213
|
+
return value;
|
|
1214
|
+
}
|
|
1215
|
+
function galleryCommand() {
|
|
1216
|
+
const cmd = new Command("gallery").description("the public gallery, and your favorites");
|
|
1217
|
+
cmd.command("browse").description("the public gallery, newest first \u2014 or one person's work with --user, or your favorites with --favorites").option("--type <type>", "image, video or audio").option("--user <id>", "only this person's work (your own id includes your private items)").option("--favorites", "only your own items that you favorited").option("--limit <n>", "page size (1-50)").option("--cursor <cursor>", "the previous page's nextCursor").option("--profile <name>").option("--json").action(async (opts) => {
|
|
1218
|
+
try {
|
|
1219
|
+
const type = mediaType(opts.type);
|
|
1220
|
+
if (opts.favorites && opts.user) throw new Error("--favorites lists your own favorites: drop --user");
|
|
1221
|
+
const client = buildClient(opts.profile);
|
|
1222
|
+
const userId = opts.favorites ? (await client.me()).id : opts.user;
|
|
1223
|
+
const page = await client.gallery.browse({
|
|
1224
|
+
type,
|
|
1225
|
+
userId,
|
|
1226
|
+
favoritesOnly: opts.favorites,
|
|
1227
|
+
limit: opts.limit ? Number(opts.limit) : void 0,
|
|
1228
|
+
cursor: opts.cursor
|
|
1229
|
+
});
|
|
1230
|
+
if (opts.json) {
|
|
1231
|
+
emit(page, opts);
|
|
1232
|
+
return;
|
|
1233
|
+
}
|
|
1234
|
+
table(
|
|
1235
|
+
page.data.map((item) => ({ id: item.id, type: item.type, url: item.outputUrl, created: item.createdAt })),
|
|
1236
|
+
["id", "type", "url", "created"]
|
|
1237
|
+
);
|
|
1238
|
+
if (page.nextCursor) dim(`next: --cursor ${page.nextCursor}`);
|
|
1239
|
+
} catch (err) {
|
|
1240
|
+
handleError(err);
|
|
1241
|
+
}
|
|
1242
|
+
});
|
|
1243
|
+
cmd.command("favorite <jobId>").description("favorite a job (your own, or a public one) \u2014 or remove it from your favorites when it is one").option("--profile <name>").option("--json").action(async (jobId, opts) => {
|
|
1244
|
+
try {
|
|
1245
|
+
const result = await buildClient(opts.profile).gallery.toggleFavorite(jobId);
|
|
1246
|
+
if (opts.json) emit(result, opts);
|
|
1247
|
+
else success(result.favorited ? `favorited job ${jobId}` : `removed job ${jobId} from your favorites`);
|
|
1248
|
+
} catch (err) {
|
|
1249
|
+
handleError(err);
|
|
1250
|
+
}
|
|
1251
|
+
});
|
|
1252
|
+
cmd.command("favorites").description("your favorited job ids, newest first").option("--profile <name>").option("--json").action(async (opts) => {
|
|
1253
|
+
try {
|
|
1254
|
+
const ids = await buildClient(opts.profile).gallery.favorites();
|
|
1255
|
+
if (opts.json) emit(ids, opts);
|
|
1256
|
+
else for (const id of ids) info(id);
|
|
1257
|
+
} catch (err) {
|
|
1258
|
+
handleError(err);
|
|
1259
|
+
}
|
|
1260
|
+
});
|
|
1261
|
+
return cmd;
|
|
1262
|
+
}
|
|
1041
1263
|
function videoProCommand() {
|
|
1042
1264
|
const cmd = new Command("video-pro").description(
|
|
1043
1265
|
"stop / continue generate-video-pro runs (segmented long-video engine)"
|
|
@@ -1376,6 +1598,27 @@ Tip: \`nodaro apps get <slug>\` shows the input schema for that app.`).action(as
|
|
|
1376
1598
|
});
|
|
1377
1599
|
return cmd;
|
|
1378
1600
|
}
|
|
1601
|
+
var BATCH_NODE_TYPE = "generate-image";
|
|
1602
|
+
function withBatchFlags(type, params, flags) {
|
|
1603
|
+
if (flags.count === void 0 && flags.models === void 0) return params;
|
|
1604
|
+
if (type !== BATCH_NODE_TYPE) {
|
|
1605
|
+
throw new Error(`--count / --models are ${BATCH_NODE_TYPE} options (several images in one call)`);
|
|
1606
|
+
}
|
|
1607
|
+
const out = { ...params };
|
|
1608
|
+
if (flags.count !== void 0) {
|
|
1609
|
+
const count = Number(flags.count);
|
|
1610
|
+
if (!/^\d+$/.test(flags.count.trim()) || count < 1) throw new Error(`--count must be a whole number of images, 1 or more (got "${flags.count}")`);
|
|
1611
|
+
out.count = count;
|
|
1612
|
+
}
|
|
1613
|
+
if (flags.models !== void 0) {
|
|
1614
|
+
out.models = flags.models.split(/[\s,]+/).filter(Boolean);
|
|
1615
|
+
}
|
|
1616
|
+
return out;
|
|
1617
|
+
}
|
|
1618
|
+
function batchOf(result) {
|
|
1619
|
+
const r = result;
|
|
1620
|
+
return r && Array.isArray(r.jobIds) && Array.isArray(r.groups) && typeof r.batchId === "string" ? r : null;
|
|
1621
|
+
}
|
|
1379
1622
|
async function pickNodeInteractively(client) {
|
|
1380
1623
|
if (!isInteractive()) {
|
|
1381
1624
|
warn("missing <type> and stdin is not a TTY \u2014 provide a node type or pipe input");
|
|
@@ -1445,12 +1688,15 @@ function nodesCommand() {
|
|
|
1445
1688
|
handleError(err);
|
|
1446
1689
|
}
|
|
1447
1690
|
});
|
|
1448
|
-
cmd.command("run [type] [extras...]").description("run a single node directly \u2014 no workflow, no DAG. Inputs go through --param k=v (repeat) or --params-file body.json. Omit <type> for an interactive picker.").option("--param <pairs...>", `input value, repeat or space-separate; JSON arrays/objects supported (e.g. --param prompt="a leopard" --param 'targetPickers=["person"]')`, collectVariadic).option("--params-file <path>", "JSON file with the full input body (--param flags override matching keys)").option("--watch", "if the response includes a jobId, poll until the job completes").option("--poll-interval <ms>", "watch poll interval in ms", (v) => parseInt(v, 10), 2e3).option("--profile <name>").option("--json").addHelpText("after", `
|
|
1691
|
+
cmd.command("run [type] [extras...]").description("run a single node directly \u2014 no workflow, no DAG. Inputs go through --param k=v (repeat) or --params-file body.json. Omit <type> for an interactive picker.").option("--param <pairs...>", `input value, repeat or space-separate; JSON arrays/objects supported (e.g. --param prompt="a leopard" --param 'targetPickers=["person"]')`, collectVariadic).option("--params-file <path>", "JSON file with the full input body (--param flags override matching keys)").option("--watch", "if the response includes a jobId, poll until the job completes (every job of a batch)").option("--poll-interval <ms>", "watch poll interval in ms", (v) => parseInt(v, 10), 2e3).option("--count <n>", "generate-image: how many images (1-4), each its own job; with --models, per model").option("--models <ids>", "generate-image: run the same request on 2-4 models at once (comma-separated), instead of provider").option("--profile <name>").option("--json").addHelpText("after", `
|
|
1449
1692
|
Examples:
|
|
1450
1693
|
$ nodaro nodes run generate-image --param prompt="a snow leopard" --watch
|
|
1451
1694
|
$ nodaro nodes run generate-image --param prompt="hi" --param provider=flux --param resolution=2K --watch
|
|
1695
|
+
$ nodaro nodes run generate-image --param prompt="a snow leopard" --count 4 --watch
|
|
1696
|
+
$ nodaro nodes run generate-image --param prompt="a snow leopard" --models gpt-image-2,flux-2-max --count 2 --watch
|
|
1452
1697
|
$ echo '{"prompt":"hi","provider":"flux"}' > body.json
|
|
1453
1698
|
$ nodaro nodes run generate-image --params-file body.json --watch
|
|
1699
|
+
$ nodaro nodes run generate-image --param presetId=generate-image/logo-wordmark --param presetVariables='{"BRAND":"Acme"}' --watch
|
|
1454
1700
|
$ nodaro nodes run text-to-speech --param text="And so it begins." --param previousText="The night before, nobody slept." --param nextText="By noon the harbour was empty." --watch
|
|
1455
1701
|
$ nodaro nodes run video-depth --param videoUrl=https://cdn.example/clip.mp4 --param colormap=turbo --watch
|
|
1456
1702
|
|
|
@@ -1469,13 +1715,31 @@ Tip: \`nodaro nodes get <type>\` shows the full input schema (required fields, p
|
|
|
1469
1715
|
try {
|
|
1470
1716
|
const client = buildClient(opts.profile);
|
|
1471
1717
|
const resolvedType = type ?? await pickNodeInteractively(client);
|
|
1472
|
-
const params = resolveParams(opts.param, opts.paramsFile);
|
|
1718
|
+
const params = withBatchFlags(resolvedType, resolveParams(opts.param, opts.paramsFile), opts);
|
|
1473
1719
|
const result = await client.nodes.run(resolvedType, params);
|
|
1474
1720
|
const jobId = typeof result === "object" && result && "jobId" in result ? result.jobId : null;
|
|
1475
1721
|
if (opts.json && !opts.watch) {
|
|
1476
1722
|
emit(result, opts);
|
|
1477
1723
|
return;
|
|
1478
1724
|
}
|
|
1725
|
+
const batch = batchOf(result);
|
|
1726
|
+
if (batch) {
|
|
1727
|
+
success(`${batch.jobIds.length} jobs queued (batch ${batch.batchId})${batch.deduped ? " \u2014 already created by an earlier request with this key" : ""}`);
|
|
1728
|
+
for (const group of batch.groups) {
|
|
1729
|
+
info(` ${group.model}: ${group.jobIds.join(", ")}${group.credits !== void 0 ? ` (${group.credits} credits)` : ""}`);
|
|
1730
|
+
}
|
|
1731
|
+
if (!opts.watch) {
|
|
1732
|
+
dim(`follow: nodaro jobs get <id> for each id above, or run with --watch`);
|
|
1733
|
+
return;
|
|
1734
|
+
}
|
|
1735
|
+
await watchJobsUntilTerminal({
|
|
1736
|
+
jobIds: batch.jobIds,
|
|
1737
|
+
fetchStatus: (id) => client.jobs.getStatus(id),
|
|
1738
|
+
intervalMs: opts.pollInterval,
|
|
1739
|
+
json: opts.json
|
|
1740
|
+
});
|
|
1741
|
+
return;
|
|
1742
|
+
}
|
|
1479
1743
|
if (!jobId) {
|
|
1480
1744
|
success(`${resolvedType} completed (inline)`);
|
|
1481
1745
|
detail(result);
|
|
@@ -1504,7 +1768,7 @@ function charactersCommand() {
|
|
|
1504
1768
|
const cmd = new Command("characters").description(
|
|
1505
1769
|
"list, inspect, and manage characters; trigger portrait / asset / motion generation"
|
|
1506
1770
|
);
|
|
1507
|
-
cmd.command("list").description("list characters (active by default)").option("--project <projectId>", "filter to one project").option("--archived", "show archived characters instead of active ones").option("--limit <n>", "max characters to return (default 100, max 500)").option("--profile <name>").option("--json").action(
|
|
1771
|
+
cmd.command("list").description("list characters (active by default)").option("--project <projectId>", "filter to one project").option("--archived", "show archived characters instead of active ones").option("--search <words>", "only characters whose name or description contains every word (up to 5, any case)").addOption(new Option("--q <words>", "same as --search").conflicts("search")).option("--limit <n>", "max characters to return (default 100, max 500)").option("--profile <name>").option("--json").action(
|
|
1508
1772
|
async (opts) => {
|
|
1509
1773
|
try {
|
|
1510
1774
|
const client = buildClient(opts.profile);
|
|
@@ -1515,6 +1779,7 @@ function charactersCommand() {
|
|
|
1515
1779
|
const result = await client.characters.list({
|
|
1516
1780
|
projectId: opts.project,
|
|
1517
1781
|
archived: opts.archived,
|
|
1782
|
+
q: opts.search ?? opts.q,
|
|
1518
1783
|
limit: limitNum
|
|
1519
1784
|
});
|
|
1520
1785
|
if (opts.json) {
|
|
@@ -1818,6 +2083,76 @@ function charactersCommand() {
|
|
|
1818
2083
|
handleError(err);
|
|
1819
2084
|
}
|
|
1820
2085
|
});
|
|
2086
|
+
cmd.command("train <id>").description(
|
|
2087
|
+
"train a high-fidelity model of the character on its own images (Nodaro Cloud; paid, about 15 minutes)"
|
|
2088
|
+
).option(
|
|
2089
|
+
"--image <url>",
|
|
2090
|
+
"train on this image only \u2014 repeat for each (at least 4); default: every eligible image",
|
|
2091
|
+
collectVariadic
|
|
2092
|
+
).option("--watch", "poll the training's job until it completes").option("--poll-interval <ms>", "watch poll interval in ms", (v) => parseInt(v, 10), 1e4).option("--profile <name>").option("--json").action(
|
|
2093
|
+
async (id, opts) => {
|
|
2094
|
+
try {
|
|
2095
|
+
const client = buildClient(opts.profile);
|
|
2096
|
+
const result = await client.characters.train(
|
|
2097
|
+
id,
|
|
2098
|
+
opts.image?.length ? { selectedImageUrls: opts.image } : {}
|
|
2099
|
+
);
|
|
2100
|
+
if (opts.json && !opts.watch) {
|
|
2101
|
+
emit(result, opts);
|
|
2102
|
+
return;
|
|
2103
|
+
}
|
|
2104
|
+
success(`training started \u2014 job ${result.jobId} (trigger word ${result.triggerWord})`);
|
|
2105
|
+
if (!opts.watch) {
|
|
2106
|
+
dim(`follow: nodaro characters training ${id} --watch`);
|
|
2107
|
+
return;
|
|
2108
|
+
}
|
|
2109
|
+
await watchUntilTerminal({
|
|
2110
|
+
fetch: () => client.jobs.get(result.jobId),
|
|
2111
|
+
label: result.jobId,
|
|
2112
|
+
intervalMs: opts.pollInterval,
|
|
2113
|
+
json: opts.json
|
|
2114
|
+
});
|
|
2115
|
+
} catch (err) {
|
|
2116
|
+
handleError(err);
|
|
2117
|
+
}
|
|
2118
|
+
}
|
|
2119
|
+
);
|
|
2120
|
+
cmd.command("training <id>").description(
|
|
2121
|
+
"show where the character's training stands: untrained | queued | training | succeeded | failed | cancelled (Nodaro Cloud)"
|
|
2122
|
+
).option("--watch", "poll until the training stops moving (exit 0 succeeded, 2 failed, 130 cancelled)").option("--poll-interval <ms>", "watch poll interval in ms", (v) => parseInt(v, 10), 1e4).option("--profile <name>").option("--json").action(async (id, opts) => {
|
|
2123
|
+
try {
|
|
2124
|
+
const client = buildClient(opts.profile);
|
|
2125
|
+
if (opts.watch) {
|
|
2126
|
+
await watchTraining({
|
|
2127
|
+
fetch: () => client.characters.trainingStatus(id),
|
|
2128
|
+
label: id,
|
|
2129
|
+
intervalMs: opts.pollInterval,
|
|
2130
|
+
json: opts.json
|
|
2131
|
+
});
|
|
2132
|
+
return;
|
|
2133
|
+
}
|
|
2134
|
+
const result = await client.characters.trainingStatus(id);
|
|
2135
|
+
if (opts.json) emit(result, opts);
|
|
2136
|
+
else detail(result);
|
|
2137
|
+
} catch (err) {
|
|
2138
|
+
handleError(err);
|
|
2139
|
+
}
|
|
2140
|
+
});
|
|
2141
|
+
cmd.command("delete-lora <id>").description(
|
|
2142
|
+
"remove the character's trained model: cancels a training in flight (refunded) and deletes the model \u2014 cannot be undone (Nodaro Cloud)"
|
|
2143
|
+
).option("--profile <name>").option("--json").action(async (id, opts) => {
|
|
2144
|
+
try {
|
|
2145
|
+
const client = buildClient(opts.profile);
|
|
2146
|
+
await client.characters.deleteLora(id);
|
|
2147
|
+
if (opts.json) {
|
|
2148
|
+
emit({ ok: true }, opts);
|
|
2149
|
+
return;
|
|
2150
|
+
}
|
|
2151
|
+
success(`removed the trained model of character ${id}`);
|
|
2152
|
+
} catch (err) {
|
|
2153
|
+
handleError(err);
|
|
2154
|
+
}
|
|
2155
|
+
});
|
|
1821
2156
|
return cmd;
|
|
1822
2157
|
}
|
|
1823
2158
|
function commonWizardFields(opts) {
|
|
@@ -3439,9 +3774,57 @@ Example:
|
|
|
3439
3774
|
);
|
|
3440
3775
|
return cmd;
|
|
3441
3776
|
}
|
|
3777
|
+
function collect(value, previous = []) {
|
|
3778
|
+
return [...previous, value];
|
|
3779
|
+
}
|
|
3780
|
+
function readJsonFile(path) {
|
|
3781
|
+
let raw;
|
|
3782
|
+
try {
|
|
3783
|
+
raw = readFileSync(path === "-" ? 0 : path, "utf8");
|
|
3784
|
+
} catch (err) {
|
|
3785
|
+
throw new Error(`cannot read ${path}: ${err.message}`);
|
|
3786
|
+
}
|
|
3787
|
+
try {
|
|
3788
|
+
return JSON.parse(raw);
|
|
3789
|
+
} catch (err) {
|
|
3790
|
+
throw new Error(`${path} is not valid JSON: ${err.message}`);
|
|
3791
|
+
}
|
|
3792
|
+
}
|
|
3793
|
+
function presetData(opts) {
|
|
3794
|
+
if (opts.data !== void 0 && opts.dataFile !== void 0) throw new Error("pass --data or --data-file, not both");
|
|
3795
|
+
let value;
|
|
3796
|
+
if (opts.data !== void 0) {
|
|
3797
|
+
try {
|
|
3798
|
+
value = JSON.parse(opts.data);
|
|
3799
|
+
} catch (err) {
|
|
3800
|
+
throw new Error(`--data is not valid JSON: ${err.message}`);
|
|
3801
|
+
}
|
|
3802
|
+
} else if (opts.dataFile !== void 0) {
|
|
3803
|
+
value = readJsonFile(opts.dataFile);
|
|
3804
|
+
} else {
|
|
3805
|
+
return void 0;
|
|
3806
|
+
}
|
|
3807
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error("the preset data must be a JSON object");
|
|
3808
|
+
return value;
|
|
3809
|
+
}
|
|
3810
|
+
function presetsToImport(value) {
|
|
3811
|
+
if (Array.isArray(value)) return value;
|
|
3812
|
+
return parseNodePresetExport(value).presets;
|
|
3813
|
+
}
|
|
3814
|
+
function intOption(raw, flag) {
|
|
3815
|
+
if (raw === void 0) return void 0;
|
|
3816
|
+
if (!/^-?\d+$/.test(raw.trim())) throw new Error(`${flag} must be a whole number`);
|
|
3817
|
+
return Number(raw);
|
|
3818
|
+
}
|
|
3819
|
+
function groupKind(raw) {
|
|
3820
|
+
if (raw === void 0) return void 0;
|
|
3821
|
+
if (raw !== "folder" && raw !== "section") throw new Error("--kind must be folder or section");
|
|
3822
|
+
return raw;
|
|
3823
|
+
}
|
|
3824
|
+
var plural = (n, word) => `${n} ${word}${n === 1 ? "" : "s"}`;
|
|
3442
3825
|
function presetsCommand() {
|
|
3443
3826
|
const cmd = new Command("presets").description(
|
|
3444
|
-
"
|
|
3827
|
+
"node presets \u2014 your own (create, update, delete, import, favorites, folders) plus the built-in factory catalog"
|
|
3445
3828
|
);
|
|
3446
3829
|
cmd.command("list").description("list your custom presets (or the built-in factory catalog with --factory)").option("--node-type <type>", "filter to one node type, e.g. generate-image").option("--factory", "list the built-in factory catalog instead of your custom presets").option("--profile <name>").option("--json").action(async (opts) => {
|
|
3447
3830
|
try {
|
|
@@ -3460,9 +3843,11 @@ function presetsCommand() {
|
|
|
3460
3843
|
result.data.map((p) => ({
|
|
3461
3844
|
id: p.id,
|
|
3462
3845
|
name: p.name,
|
|
3463
|
-
group: p.group ?? ""
|
|
3846
|
+
group: p.group ?? "",
|
|
3847
|
+
photos: p.minReferences ? p.minReferences : "",
|
|
3848
|
+
preview: p.previewUrl ? "yes" : ""
|
|
3464
3849
|
})),
|
|
3465
|
-
["id", "name", "group"]
|
|
3850
|
+
["id", "name", "group", "photos", "preview"]
|
|
3466
3851
|
);
|
|
3467
3852
|
return;
|
|
3468
3853
|
}
|
|
@@ -3472,25 +3857,97 @@ function presetsCommand() {
|
|
|
3472
3857
|
return;
|
|
3473
3858
|
}
|
|
3474
3859
|
table(
|
|
3475
|
-
presets.map((p) => ({
|
|
3476
|
-
|
|
3860
|
+
presets.map((p) => ({
|
|
3861
|
+
id: p.id,
|
|
3862
|
+
nodeType: p.nodeType,
|
|
3863
|
+
name: p.name,
|
|
3864
|
+
photos: p.minReferences ? p.minReferences : "",
|
|
3865
|
+
updatedAt: p.updatedAt
|
|
3866
|
+
})),
|
|
3867
|
+
["id", "nodeType", "name", "photos", "updatedAt"]
|
|
3868
|
+
);
|
|
3869
|
+
} catch (err) {
|
|
3870
|
+
handleError(err);
|
|
3871
|
+
}
|
|
3872
|
+
});
|
|
3873
|
+
cmd.command("create").description("save a preset: a node type, a name and its node config (data)").requiredOption("--node-type <type>", "the node type it configures, e.g. generate-image").requiredOption("--name <name>", "unique per node type").option("--data <json>", "the node config as a JSON object").option("--data-file <path>", "the node config from a JSON file (- for stdin)").option("--description <text>").option("--group <id>", "one of your preset folders").option("--tag <tag>", "a tag (repeatable)", collect).option("--preview-url <url>", "an example picture: an image already stored on this platform").option("--profile <name>").option("--json").action(
|
|
3874
|
+
async (opts) => {
|
|
3875
|
+
try {
|
|
3876
|
+
const data = presetData(opts);
|
|
3877
|
+
if (!data) throw new Error("pass the preset's node config with --data or --data-file");
|
|
3878
|
+
const preset = await buildClient(opts.profile).presets.create({
|
|
3879
|
+
nodeType: opts.nodeType,
|
|
3880
|
+
name: opts.name,
|
|
3881
|
+
data,
|
|
3882
|
+
...opts.description !== void 0 ? { description: opts.description } : {},
|
|
3883
|
+
...opts.group !== void 0 ? { groupId: opts.group } : {},
|
|
3884
|
+
...opts.tag !== void 0 ? { tags: opts.tag } : {},
|
|
3885
|
+
...opts.previewUrl !== void 0 ? { previewUrl: opts.previewUrl } : {}
|
|
3886
|
+
});
|
|
3887
|
+
if (opts.json) {
|
|
3888
|
+
emit(preset, opts);
|
|
3889
|
+
return;
|
|
3890
|
+
}
|
|
3891
|
+
success(`created preset ${preset.name} (${preset.id})`);
|
|
3892
|
+
} catch (err) {
|
|
3893
|
+
handleError(err);
|
|
3894
|
+
}
|
|
3895
|
+
}
|
|
3896
|
+
);
|
|
3897
|
+
cmd.command("update <id>").description("rename a preset, replace its config, move it, or set / remove its preview").option("--name <name>").option("--description <text>").option("--data <json>", "replace the node config with this JSON object").option("--data-file <path>", "replace the node config from a JSON file (- for stdin)").option("--group <id>", "move it into one of your preset folders").option("--no-group", "move it out of its folder").option("--tag <tag>", "replace the tags (repeatable)", collect).option("--preview-url <url>", "set the example picture: an image already stored on this platform").option("--no-preview-url", "remove the example picture").option("--expected-updated-at <iso>", "refuse if the preset changed since this updatedAt").option("--profile <name>").option("--json").action(
|
|
3898
|
+
async (id, opts) => {
|
|
3899
|
+
try {
|
|
3900
|
+
const data = presetData(opts);
|
|
3901
|
+
const patch = {
|
|
3902
|
+
...opts.name !== void 0 ? { name: opts.name } : {},
|
|
3903
|
+
...opts.description !== void 0 ? { description: opts.description } : {},
|
|
3904
|
+
...data !== void 0 ? { data } : {},
|
|
3905
|
+
...opts.group !== void 0 ? { groupId: opts.group === false ? null : opts.group } : {},
|
|
3906
|
+
...opts.tag !== void 0 ? { tags: opts.tag } : {},
|
|
3907
|
+
...opts.previewUrl !== void 0 ? { previewUrl: opts.previewUrl === false ? null : opts.previewUrl } : {}
|
|
3908
|
+
};
|
|
3909
|
+
if (Object.keys(patch).length === 0) {
|
|
3910
|
+
throw new Error("nothing to update \u2014 pass --name, --description, --data, --group, --tag or --preview-url");
|
|
3911
|
+
}
|
|
3912
|
+
const preset = await buildClient(opts.profile).presets.update(
|
|
3913
|
+
id,
|
|
3914
|
+
patch,
|
|
3915
|
+
opts.expectedUpdatedAt ? { expectedUpdatedAt: opts.expectedUpdatedAt } : {}
|
|
3916
|
+
);
|
|
3917
|
+
if (opts.json) {
|
|
3918
|
+
emit(preset, opts);
|
|
3919
|
+
return;
|
|
3920
|
+
}
|
|
3921
|
+
success(`updated preset ${preset.name} (${preset.id})`);
|
|
3922
|
+
} catch (err) {
|
|
3923
|
+
handleError(err);
|
|
3924
|
+
}
|
|
3925
|
+
}
|
|
3926
|
+
);
|
|
3927
|
+
cmd.command("delete <id>").description("delete one of your presets").option("--expected-updated-at <iso>", "refuse if the preset changed since this updatedAt").option("--profile <name>").option("--json").action(async (id, opts) => {
|
|
3928
|
+
try {
|
|
3929
|
+
const result = await buildClient(opts.profile).presets.delete(
|
|
3930
|
+
id,
|
|
3931
|
+
opts.expectedUpdatedAt ? { expectedUpdatedAt: opts.expectedUpdatedAt } : {}
|
|
3477
3932
|
);
|
|
3933
|
+
if (opts.json) {
|
|
3934
|
+
emit(result, opts);
|
|
3935
|
+
return;
|
|
3936
|
+
}
|
|
3937
|
+
success(`deleted preset ${id}`);
|
|
3478
3938
|
} catch (err) {
|
|
3479
3939
|
handleError(err);
|
|
3480
3940
|
}
|
|
3481
3941
|
});
|
|
3482
|
-
cmd.command("
|
|
3942
|
+
cmd.command("import <file>").description("import presets from a file: what `presets export` writes, or a JSON list of presets (- for stdin)").option("--profile <name>").option("--json").action(async (path, opts) => {
|
|
3483
3943
|
try {
|
|
3484
|
-
const
|
|
3485
|
-
const
|
|
3944
|
+
const presets = presetsToImport(readJsonFile(path));
|
|
3945
|
+
const result = await buildClient(opts.profile).presets.import(presets);
|
|
3486
3946
|
if (opts.json) {
|
|
3487
|
-
emit(
|
|
3947
|
+
emit(result, opts);
|
|
3488
3948
|
return;
|
|
3489
3949
|
}
|
|
3490
|
-
|
|
3491
|
-
groups.map((g) => ({ id: g.id, nodeType: g.nodeType, name: g.name, kind: g.kind })),
|
|
3492
|
-
["id", "nodeType", "name", "kind"]
|
|
3493
|
-
);
|
|
3950
|
+
success(`imported ${plural(result.imported, "preset")}`);
|
|
3494
3951
|
} catch (err) {
|
|
3495
3952
|
handleError(err);
|
|
3496
3953
|
}
|
|
@@ -3513,7 +3970,7 @@ function presetsCommand() {
|
|
|
3513
3970
|
const json = JSON.stringify(envelope, null, 2);
|
|
3514
3971
|
if (opts.output) {
|
|
3515
3972
|
writeFileSync(opts.output, json);
|
|
3516
|
-
success(`exported ${presets.length
|
|
3973
|
+
success(`exported ${plural(presets.length, "preset")} to ${opts.output}`);
|
|
3517
3974
|
} else {
|
|
3518
3975
|
process.stdout.write(`${json}
|
|
3519
3976
|
`);
|
|
@@ -3522,10 +3979,115 @@ function presetsCommand() {
|
|
|
3522
3979
|
handleError(err);
|
|
3523
3980
|
}
|
|
3524
3981
|
});
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3982
|
+
cmd.command("favorites").description("list your favorite preset ids for a node type, newest first").requiredOption("--node-type <type>", "e.g. generate-image").option("--profile <name>").option("--json").action(async (opts) => {
|
|
3983
|
+
try {
|
|
3984
|
+
const ids = await buildClient(opts.profile).presets.favorites(opts.nodeType);
|
|
3985
|
+
if (opts.json) {
|
|
3986
|
+
emit(ids, opts);
|
|
3987
|
+
return;
|
|
3988
|
+
}
|
|
3989
|
+
table(ids.map((presetId) => ({ presetId })), ["presetId"]);
|
|
3990
|
+
} catch (err) {
|
|
3991
|
+
handleError(err);
|
|
3992
|
+
}
|
|
3993
|
+
});
|
|
3994
|
+
cmd.command("favorite <presetId>").description("add a preset (a factory id such as generate-image/character-board, or one of yours) to your favorites").requiredOption("--node-type <type>", "e.g. generate-image").option("--profile <name>").option("--json").action(async (presetId, opts) => {
|
|
3995
|
+
try {
|
|
3996
|
+
const result = await buildClient(opts.profile).presets.addFavorite({ nodeType: opts.nodeType, presetId });
|
|
3997
|
+
if (opts.json) {
|
|
3998
|
+
emit(result, opts);
|
|
3999
|
+
return;
|
|
4000
|
+
}
|
|
4001
|
+
success(`added ${presetId} to your favorites`);
|
|
4002
|
+
} catch (err) {
|
|
4003
|
+
handleError(err);
|
|
4004
|
+
}
|
|
4005
|
+
});
|
|
4006
|
+
cmd.command("unfavorite <presetId>").description("remove a preset from your favorites").requiredOption("--node-type <type>", "e.g. generate-image").option("--profile <name>").option("--json").action(async (presetId, opts) => {
|
|
4007
|
+
try {
|
|
4008
|
+
const result = await buildClient(opts.profile).presets.removeFavorite({ nodeType: opts.nodeType, presetId });
|
|
4009
|
+
if (opts.json) {
|
|
4010
|
+
emit(result, opts);
|
|
4011
|
+
return;
|
|
4012
|
+
}
|
|
4013
|
+
success(`removed ${presetId} from your favorites`);
|
|
4014
|
+
} catch (err) {
|
|
4015
|
+
handleError(err);
|
|
4016
|
+
}
|
|
4017
|
+
});
|
|
4018
|
+
cmd.addCommand(groupsCommand());
|
|
4019
|
+
return cmd;
|
|
4020
|
+
}
|
|
4021
|
+
function groupsCommand() {
|
|
4022
|
+
const cmd = new Command("groups").description("your preset folders and sections: list (default), create, update, delete");
|
|
4023
|
+
cmd.command("list", { isDefault: true }).description("list your preset folders and sections").option("--node-type <type>", "filter to one node type").option("--profile <name>").option("--json").action(async (opts) => {
|
|
4024
|
+
try {
|
|
4025
|
+
const client = buildClient(opts.profile);
|
|
4026
|
+
const groups = await client.presets.listGroups(opts.nodeType);
|
|
4027
|
+
if (opts.json) {
|
|
4028
|
+
emit(groups, opts);
|
|
4029
|
+
return;
|
|
4030
|
+
}
|
|
4031
|
+
table(
|
|
4032
|
+
groups.map((g) => ({ id: g.id, nodeType: g.nodeType, name: g.name, kind: g.kind })),
|
|
4033
|
+
["id", "nodeType", "name", "kind"]
|
|
4034
|
+
);
|
|
4035
|
+
} catch (err) {
|
|
4036
|
+
handleError(err);
|
|
4037
|
+
}
|
|
4038
|
+
});
|
|
4039
|
+
cmd.command("create").description("create a folder (collapsible) or a section (a flat header)").requiredOption("--node-type <type>", "e.g. generate-image").requiredOption("--name <name>").option("--kind <kind>", "folder (default) or section").option("--sort-order <n>", "its position").option("--profile <name>").option("--json").action(async (opts) => {
|
|
4040
|
+
try {
|
|
4041
|
+
const kind = groupKind(opts.kind);
|
|
4042
|
+
const sortOrder = intOption(opts.sortOrder, "--sort-order");
|
|
4043
|
+
const group = await buildClient(opts.profile).presets.createGroup({
|
|
4044
|
+
nodeType: opts.nodeType,
|
|
4045
|
+
name: opts.name,
|
|
4046
|
+
...kind !== void 0 ? { kind } : {},
|
|
4047
|
+
...sortOrder !== void 0 ? { sortOrder } : {}
|
|
4048
|
+
});
|
|
4049
|
+
if (opts.json) {
|
|
4050
|
+
emit(group, opts);
|
|
4051
|
+
return;
|
|
4052
|
+
}
|
|
4053
|
+
success(`created ${group.kind} ${group.name} (${group.id})`);
|
|
4054
|
+
} catch (err) {
|
|
4055
|
+
handleError(err);
|
|
4056
|
+
}
|
|
4057
|
+
});
|
|
4058
|
+
cmd.command("update <id>").description("rename or move a folder or section").option("--name <name>").option("--sort-order <n>", "its position").option("--profile <name>").option("--json").action(async (id, opts) => {
|
|
4059
|
+
try {
|
|
4060
|
+
const sortOrder = intOption(opts.sortOrder, "--sort-order");
|
|
4061
|
+
if (opts.name === void 0 && sortOrder === void 0) throw new Error("nothing to update \u2014 pass --name or --sort-order");
|
|
4062
|
+
const group = await buildClient(opts.profile).presets.updateGroup(id, {
|
|
4063
|
+
...opts.name !== void 0 ? { name: opts.name } : {},
|
|
4064
|
+
...sortOrder !== void 0 ? { sortOrder } : {}
|
|
4065
|
+
});
|
|
4066
|
+
if (opts.json) {
|
|
4067
|
+
emit(group, opts);
|
|
4068
|
+
return;
|
|
4069
|
+
}
|
|
4070
|
+
success(`updated ${group.kind} ${group.name} (${group.id})`);
|
|
4071
|
+
} catch (err) {
|
|
4072
|
+
handleError(err);
|
|
4073
|
+
}
|
|
4074
|
+
});
|
|
4075
|
+
cmd.command("delete <id>").description("delete a folder or section \u2014 its presets move out of it, none are deleted").option("--profile <name>").option("--json").action(async (id, opts) => {
|
|
4076
|
+
try {
|
|
4077
|
+
const result = await buildClient(opts.profile).presets.deleteGroup(id);
|
|
4078
|
+
if (opts.json) {
|
|
4079
|
+
emit(result, opts);
|
|
4080
|
+
return;
|
|
4081
|
+
}
|
|
4082
|
+
success(`deleted preset group ${id}`);
|
|
4083
|
+
} catch (err) {
|
|
4084
|
+
handleError(err);
|
|
4085
|
+
}
|
|
4086
|
+
});
|
|
4087
|
+
return cmd;
|
|
4088
|
+
}
|
|
4089
|
+
function postFromJson(value, index2 = 0) {
|
|
4090
|
+
const candidate = Array.isArray(value) ? value[index2] : value;
|
|
3529
4091
|
if (!isSocialPost(candidate)) {
|
|
3530
4092
|
throw new Error(
|
|
3531
4093
|
Array.isArray(value) ? `item ${index2} of the file is not a Social Search post` : "the file is not a Social Search post (or a list of them)"
|
|
@@ -3874,6 +4436,185 @@ function collectionsCommand() {
|
|
|
3874
4436
|
});
|
|
3875
4437
|
return cmd;
|
|
3876
4438
|
}
|
|
4439
|
+
function colorList(value) {
|
|
4440
|
+
return value.split(/[\s,]+/).filter(Boolean);
|
|
4441
|
+
}
|
|
4442
|
+
function palettesCommand() {
|
|
4443
|
+
const cmd = new Command("palettes").description(
|
|
4444
|
+
'your colour palettes \u2014 use one on generate-image as direction.colorLook "palette:<id>"'
|
|
4445
|
+
);
|
|
4446
|
+
cmd.command("list").description("your palettes, newest first").option("--limit <n>", "page size (1-100)").option("--cursor <cursor>", "the previous page's nextCursor").option("--profile <name>").option("--json").action(async (opts) => {
|
|
4447
|
+
try {
|
|
4448
|
+
const page = await buildClient(opts.profile).palettes.list({
|
|
4449
|
+
limit: opts.limit ? Number(opts.limit) : void 0,
|
|
4450
|
+
cursor: opts.cursor
|
|
4451
|
+
});
|
|
4452
|
+
if (opts.json) {
|
|
4453
|
+
emit(page, opts);
|
|
4454
|
+
return;
|
|
4455
|
+
}
|
|
4456
|
+
table(
|
|
4457
|
+
page.data.map((p) => ({ id: p.id, name: p.name, colors: p.colors.join(" "), updatedAt: p.updatedAt })),
|
|
4458
|
+
["id", "name", "colors", "updatedAt"]
|
|
4459
|
+
);
|
|
4460
|
+
if (page.nextCursor) dim(`next: --cursor ${page.nextCursor}`);
|
|
4461
|
+
} catch (err) {
|
|
4462
|
+
handleError(err);
|
|
4463
|
+
}
|
|
4464
|
+
});
|
|
4465
|
+
cmd.command("get <id>").description("show one palette").option("--profile <name>").option("--json").action(async (id, opts) => {
|
|
4466
|
+
try {
|
|
4467
|
+
const palette = await buildClient(opts.profile).palettes.get(id);
|
|
4468
|
+
if (opts.json) emit(palette, opts);
|
|
4469
|
+
else detail(palette);
|
|
4470
|
+
} catch (err) {
|
|
4471
|
+
handleError(err);
|
|
4472
|
+
}
|
|
4473
|
+
});
|
|
4474
|
+
cmd.command("create").description("create a palette (2-12 #RRGGBB colours)").requiredOption("--name <name>", "1-80 characters").requiredOption("--colors <hex...>", 'colours, comma- or space-separated, e.g. "#0F4C5C,#E3B23C"').option("--description <text>", "your own note (not put into the prompt)").option("--profile <name>").option("--json").action(async (opts) => {
|
|
4475
|
+
try {
|
|
4476
|
+
const palette = await buildClient(opts.profile).palettes.create({
|
|
4477
|
+
name: opts.name,
|
|
4478
|
+
colors: [].concat(opts.colors).flatMap(colorList),
|
|
4479
|
+
...opts.description !== void 0 ? { description: opts.description } : {}
|
|
4480
|
+
});
|
|
4481
|
+
if (opts.json) {
|
|
4482
|
+
emit(palette, opts);
|
|
4483
|
+
return;
|
|
4484
|
+
}
|
|
4485
|
+
success(`created palette ${palette.id} \u2014 use it as direction.colorLook "palette:${palette.id}"`);
|
|
4486
|
+
} catch (err) {
|
|
4487
|
+
handleError(err);
|
|
4488
|
+
}
|
|
4489
|
+
});
|
|
4490
|
+
cmd.command("update <id>").description("change a palette: only what you pass is written").option("--name <name>").option("--colors <hex...>", "replace the colours (2-12, comma- or space-separated)").option("--description <text>").option("--clear-description", "remove the note").option("--profile <name>").option("--json").action(
|
|
4491
|
+
async (id, opts) => {
|
|
4492
|
+
try {
|
|
4493
|
+
const input2 = {
|
|
4494
|
+
...opts.name !== void 0 ? { name: opts.name } : {},
|
|
4495
|
+
...opts.colors !== void 0 ? { colors: [].concat(opts.colors).flatMap(colorList) } : {},
|
|
4496
|
+
...opts.clearDescription ? { description: null } : opts.description !== void 0 ? { description: opts.description } : {}
|
|
4497
|
+
};
|
|
4498
|
+
if (Object.keys(input2).length === 0) {
|
|
4499
|
+
throw new Error("nothing to update \u2014 provide --name, --colors, --description or --clear-description");
|
|
4500
|
+
}
|
|
4501
|
+
const palette = await buildClient(opts.profile).palettes.update(id, input2);
|
|
4502
|
+
if (opts.json) {
|
|
4503
|
+
emit(palette, opts);
|
|
4504
|
+
return;
|
|
4505
|
+
}
|
|
4506
|
+
success(`updated palette ${palette.id}`);
|
|
4507
|
+
} catch (err) {
|
|
4508
|
+
handleError(err);
|
|
4509
|
+
}
|
|
4510
|
+
}
|
|
4511
|
+
);
|
|
4512
|
+
cmd.command("delete <id>").description("delete a palette (a run that still names it answers 404)").option("--profile <name>").option("--json").action(async (id, opts) => {
|
|
4513
|
+
try {
|
|
4514
|
+
await buildClient(opts.profile).palettes.delete(id);
|
|
4515
|
+
if (opts.json) {
|
|
4516
|
+
emit({ success: true, id }, opts);
|
|
4517
|
+
return;
|
|
4518
|
+
}
|
|
4519
|
+
success(`deleted palette ${id}`);
|
|
4520
|
+
} catch (err) {
|
|
4521
|
+
handleError(err);
|
|
4522
|
+
}
|
|
4523
|
+
});
|
|
4524
|
+
return cmd;
|
|
4525
|
+
}
|
|
4526
|
+
function imageOf(value) {
|
|
4527
|
+
const bar = value.indexOf("|");
|
|
4528
|
+
if (bar === -1) return { url: value.trim() };
|
|
4529
|
+
const url = value.slice(0, bar).trim();
|
|
4530
|
+
const caption = value.slice(bar + 1).trim();
|
|
4531
|
+
return caption ? { url, caption } : { url };
|
|
4532
|
+
}
|
|
4533
|
+
function moodboardsCommand() {
|
|
4534
|
+
const cmd = new Command("moodboards").description(
|
|
4535
|
+
'your moodboards \u2014 use one on generate-image as direction.style "moodboard:<id>" (its description joins the prompt, its images go as style references)'
|
|
4536
|
+
);
|
|
4537
|
+
cmd.command("list").description("your moodboards, newest first").option("--limit <n>", "page size (1-100)").option("--cursor <cursor>", "the previous page's nextCursor").option("--profile <name>").option("--json").action(async (opts) => {
|
|
4538
|
+
try {
|
|
4539
|
+
const page = await buildClient(opts.profile).moodboards.list({
|
|
4540
|
+
limit: opts.limit ? Number(opts.limit) : void 0,
|
|
4541
|
+
cursor: opts.cursor
|
|
4542
|
+
});
|
|
4543
|
+
if (opts.json) {
|
|
4544
|
+
emit(page, opts);
|
|
4545
|
+
return;
|
|
4546
|
+
}
|
|
4547
|
+
table(
|
|
4548
|
+
page.data.map((m) => ({ id: m.id, name: m.name, images: m.images.length, updatedAt: m.updatedAt })),
|
|
4549
|
+
["id", "name", "images", "updatedAt"]
|
|
4550
|
+
);
|
|
4551
|
+
if (page.nextCursor) dim(`next: --cursor ${page.nextCursor}`);
|
|
4552
|
+
} catch (err) {
|
|
4553
|
+
handleError(err);
|
|
4554
|
+
}
|
|
4555
|
+
});
|
|
4556
|
+
cmd.command("get <id>").description("show one moodboard with its images").option("--profile <name>").option("--json").action(async (id, opts) => {
|
|
4557
|
+
try {
|
|
4558
|
+
const board = await buildClient(opts.profile).moodboards.get(id);
|
|
4559
|
+
if (opts.json) emit(board, opts);
|
|
4560
|
+
else detail(board);
|
|
4561
|
+
} catch (err) {
|
|
4562
|
+
handleError(err);
|
|
4563
|
+
}
|
|
4564
|
+
});
|
|
4565
|
+
cmd.command("create").description("create a moodboard (1-12 images)").requiredOption("--name <name>", "1-80 characters").option("--image <url[|caption]>", 'image link, repeat per image (1-12); add "|caption" to describe it', collectVariadic).option("--description <text>", "the words a run puts into the prompt (up to 1000 characters)").option("--profile <name>").option("--json").action(async (opts) => {
|
|
4566
|
+
try {
|
|
4567
|
+
if (!opts.image || opts.image.length === 0) throw new Error("a moodboard needs at least one --image");
|
|
4568
|
+
const board = await buildClient(opts.profile).moodboards.create({
|
|
4569
|
+
name: opts.name,
|
|
4570
|
+
...opts.description !== void 0 ? { description: opts.description } : {},
|
|
4571
|
+
images: opts.image.map(imageOf)
|
|
4572
|
+
});
|
|
4573
|
+
if (opts.json) {
|
|
4574
|
+
emit(board, opts);
|
|
4575
|
+
return;
|
|
4576
|
+
}
|
|
4577
|
+
success(`created moodboard ${board.id} \u2014 use it as direction.style "moodboard:${board.id}"`);
|
|
4578
|
+
} catch (err) {
|
|
4579
|
+
handleError(err);
|
|
4580
|
+
}
|
|
4581
|
+
});
|
|
4582
|
+
cmd.command("update <id>").description("change a moodboard: only what you pass is written; --image replaces every image").option("--name <name>").option("--description <text>").option("--clear-description", "remove the description").option("--image <url[|caption]>", "replace the images (repeat per image, 1-12)", collectVariadic).option("--profile <name>").option("--json").action(
|
|
4583
|
+
async (id, opts) => {
|
|
4584
|
+
try {
|
|
4585
|
+
const input2 = {
|
|
4586
|
+
...opts.name !== void 0 ? { name: opts.name } : {},
|
|
4587
|
+
...opts.clearDescription ? { description: null } : opts.description !== void 0 ? { description: opts.description } : {},
|
|
4588
|
+
...opts.image && opts.image.length > 0 ? { images: opts.image.map(imageOf) } : {}
|
|
4589
|
+
};
|
|
4590
|
+
if (Object.keys(input2).length === 0) {
|
|
4591
|
+
throw new Error("nothing to update \u2014 provide --name, --description, --clear-description or --image");
|
|
4592
|
+
}
|
|
4593
|
+
const board = await buildClient(opts.profile).moodboards.update(id, input2);
|
|
4594
|
+
if (opts.json) {
|
|
4595
|
+
emit(board, opts);
|
|
4596
|
+
return;
|
|
4597
|
+
}
|
|
4598
|
+
success(`updated moodboard ${board.id}`);
|
|
4599
|
+
} catch (err) {
|
|
4600
|
+
handleError(err);
|
|
4601
|
+
}
|
|
4602
|
+
}
|
|
4603
|
+
);
|
|
4604
|
+
cmd.command("delete <id>").description("delete a moodboard (the images it links to are untouched)").option("--profile <name>").option("--json").action(async (id, opts) => {
|
|
4605
|
+
try {
|
|
4606
|
+
await buildClient(opts.profile).moodboards.delete(id);
|
|
4607
|
+
if (opts.json) {
|
|
4608
|
+
emit({ success: true, id }, opts);
|
|
4609
|
+
return;
|
|
4610
|
+
}
|
|
4611
|
+
success(`deleted moodboard ${id}`);
|
|
4612
|
+
} catch (err) {
|
|
4613
|
+
handleError(err);
|
|
4614
|
+
}
|
|
4615
|
+
});
|
|
4616
|
+
return cmd;
|
|
4617
|
+
}
|
|
3877
4618
|
function accountsFromFlags(flags) {
|
|
3878
4619
|
const pairs = [
|
|
3879
4620
|
["tiktok", flags.tiktok],
|
|
@@ -3957,8 +4698,8 @@ function outcomeLine(o) {
|
|
|
3957
4698
|
function recordLines(record) {
|
|
3958
4699
|
return record.filter((r) => r.shown).map((r) => `${FAMILY_LABEL[r.family]}: ${r.worked} of ${r.tried} worked for you (on average ${r.avgRatio}x your usual)`);
|
|
3959
4700
|
}
|
|
3960
|
-
function rows(
|
|
3961
|
-
return
|
|
4701
|
+
function rows(list2) {
|
|
4702
|
+
return list2.map((c) => ({
|
|
3962
4703
|
id: c.id,
|
|
3963
4704
|
brand: c.isOwn ? `${c.brand} (yours)` : c.brand,
|
|
3964
4705
|
searches: c.searches,
|
|
@@ -3971,9 +4712,9 @@ function competitorsCommand() {
|
|
|
3971
4712
|
const cmd = new Command("competitors").description("brands you track (competitors or your own), their scans and action cards (Nodaro Cloud)");
|
|
3972
4713
|
cmd.command("list").description("list tracked brands").option("--profile <name>").option("--json").action(async (opts) => {
|
|
3973
4714
|
try {
|
|
3974
|
-
const
|
|
3975
|
-
if (opts.json) return emit(
|
|
3976
|
-
table(rows(
|
|
4715
|
+
const list2 = await buildClient(opts.profile).competitors.list();
|
|
4716
|
+
if (opts.json) return emit(list2, opts);
|
|
4717
|
+
table(rows(list2), ["id", "brand", "searches", "schedule", "lastScan", "note"]);
|
|
3977
4718
|
} catch (err) {
|
|
3978
4719
|
handleError(err);
|
|
3979
4720
|
}
|
|
@@ -4602,7 +5343,7 @@ function catalogCommand() {
|
|
|
4602
5343
|
}
|
|
4603
5344
|
function modelsCommand() {
|
|
4604
5345
|
const cmd = new Command("models").description(
|
|
4605
|
-
"browse the model catalog \u2014 capability sheets, per-variant credit pricing, prompt tips"
|
|
5346
|
+
"browse the model catalog \u2014 makers, capability sheets, per-variant credit pricing, prompt tips"
|
|
4606
5347
|
);
|
|
4607
5348
|
cmd.command("list").description("list available models (grouped by kind and family)").option("--kind <kind>", "image | video | audio").option("--mode <mode>", 'operation filter, e.g. "t2v", "i2v", "t2i", "tts"').option("--family <name>", 'vendor / lab name, e.g. "Google", "Bytedance"').option("--featured", "featured models only").option("--profile <name>").option("--json").addHelpText(
|
|
4608
5349
|
"after",
|
|
@@ -4630,6 +5371,9 @@ Examples:
|
|
|
4630
5371
|
id: m.id,
|
|
4631
5372
|
kind: section.kind,
|
|
4632
5373
|
family: group.family,
|
|
5374
|
+
// The company behind the model (a family can name a lab or a
|
|
5375
|
+
// product line); an older server sends none.
|
|
5376
|
+
maker: m.maker?.name ?? "-",
|
|
4633
5377
|
modes: m.modes.join(","),
|
|
4634
5378
|
credits: (m.pricing ?? []).map((p) => p.credits).join("/") || "-",
|
|
4635
5379
|
featured: m.featured ? "\u2605" : "",
|
|
@@ -4637,7 +5381,7 @@ Examples:
|
|
|
4637
5381
|
}))
|
|
4638
5382
|
)
|
|
4639
5383
|
);
|
|
4640
|
-
table(rows2, ["id", "kind", "family", "modes", "credits", "featured", "doctrine"]);
|
|
5384
|
+
table(rows2, ["id", "kind", "family", "maker", "modes", "credits", "featured", "doctrine"]);
|
|
4641
5385
|
} catch (err) {
|
|
4642
5386
|
handleError(err);
|
|
4643
5387
|
}
|
|
@@ -4860,11 +5604,11 @@ function locationsCommand() {
|
|
|
4860
5604
|
const cmd = new Command("locations").description(
|
|
4861
5605
|
"list, inspect, and manage locations; trigger main-image / asset generation"
|
|
4862
5606
|
);
|
|
4863
|
-
cmd.command("list").description("list locations (active by default)").option("--archived", "show archived locations instead of active ones").option("--profile <name>").option("--json").action(
|
|
5607
|
+
cmd.command("list").description("list locations (active by default)").option("--archived", "show archived locations instead of active ones").option("--search <words>", "only locations whose name or description contains every word (up to 5, any case)").addOption(new Option("--q <words>", "same as --search").conflicts("search")).option("--profile <name>").option("--json").action(
|
|
4864
5608
|
async (opts) => {
|
|
4865
5609
|
try {
|
|
4866
5610
|
const client = buildClient(opts.profile);
|
|
4867
|
-
const result = await client.locations.list({ archived: opts.archived });
|
|
5611
|
+
const result = await client.locations.list({ archived: opts.archived, q: opts.search ?? opts.q });
|
|
4868
5612
|
if (opts.json) {
|
|
4869
5613
|
emit(result.locations, opts);
|
|
4870
5614
|
return;
|
|
@@ -5198,13 +5942,14 @@ function objectsCommand() {
|
|
|
5198
5942
|
const cmd = new Command("objects").description(
|
|
5199
5943
|
"list, inspect, and manage objects; trigger main-image / asset generation"
|
|
5200
5944
|
);
|
|
5201
|
-
cmd.command("list").description("list objects (active by default)").option("--project <id>", "scope to a specific project").option("--archived", "show archived objects instead of active ones").option("--profile <name>").option("--json").action(
|
|
5945
|
+
cmd.command("list").description("list objects (active by default)").option("--project <id>", "scope to a specific project").option("--archived", "show archived objects instead of active ones").option("--search <words>", "only objects whose name or description contains every word (up to 5, any case)").addOption(new Option("--q <words>", "same as --search").conflicts("search")).option("--profile <name>").option("--json").action(
|
|
5202
5946
|
async (opts) => {
|
|
5203
5947
|
try {
|
|
5204
5948
|
const client = buildClient(opts.profile);
|
|
5205
5949
|
const result = await client.objects.list({
|
|
5206
5950
|
archived: opts.archived,
|
|
5207
|
-
projectId: opts.project
|
|
5951
|
+
projectId: opts.project,
|
|
5952
|
+
q: opts.search ?? opts.q
|
|
5208
5953
|
});
|
|
5209
5954
|
if (opts.json) {
|
|
5210
5955
|
emit(result.objects, opts);
|
|
@@ -5975,7 +6720,7 @@ var CONTINUATION_NEXT_STEP = {
|
|
|
5975
6720
|
continuation_superseded: (id) => ` \u2014 continue that one: nodaro edit continue-use-case ${id} --mode from-failed`,
|
|
5976
6721
|
render_final_already_rendered: (id) => ` \u2014 its result is the one to use: nodaro jobs get ${id}`
|
|
5977
6722
|
};
|
|
5978
|
-
function
|
|
6723
|
+
function readJsonFile2(path) {
|
|
5979
6724
|
let raw;
|
|
5980
6725
|
try {
|
|
5981
6726
|
raw = readFileSync(path, "utf8");
|
|
@@ -6038,7 +6783,7 @@ function editCommand() {
|
|
|
6038
6783
|
async (opts) => {
|
|
6039
6784
|
let sources;
|
|
6040
6785
|
if (opts.sourcesFile) {
|
|
6041
|
-
const parsed =
|
|
6786
|
+
const parsed = readJsonFile2(opts.sourcesFile);
|
|
6042
6787
|
if (!Array.isArray(parsed)) {
|
|
6043
6788
|
warn(`--sources-file ${opts.sourcesFile} must contain a JSON array of { id, url } rows`);
|
|
6044
6789
|
process.exit(1);
|
|
@@ -6084,9 +6829,9 @@ function editCommand() {
|
|
|
6084
6829
|
try {
|
|
6085
6830
|
const client = buildClient(opts.profile);
|
|
6086
6831
|
const result = await client.edit.applyEdl({
|
|
6087
|
-
edl:
|
|
6832
|
+
edl: readJsonFile2(opts.edl),
|
|
6088
6833
|
...opts.source && opts.source.length > 0 ? { sources: opts.source } : {},
|
|
6089
|
-
...opts.transcript ? { transcript:
|
|
6834
|
+
...opts.transcript ? { transcript: readJsonFile2(opts.transcript) } : {},
|
|
6090
6835
|
output: opts.output,
|
|
6091
6836
|
quality: opts.quality,
|
|
6092
6837
|
...opts.crossfadeMs !== void 0 ? { crossfadeMs: opts.crossfadeMs } : {},
|
|
@@ -6165,7 +6910,7 @@ function editCommand() {
|
|
|
6165
6910
|
{
|
|
6166
6911
|
jobId,
|
|
6167
6912
|
mode: opts.mode,
|
|
6168
|
-
...opts.edit !== void 0 ? { editedEdl:
|
|
6913
|
+
...opts.edit !== void 0 ? { editedEdl: readJsonFile2(opts.edit) } : {}
|
|
6169
6914
|
},
|
|
6170
6915
|
opts.idempotencyKey ? { idempotencyKey: opts.idempotencyKey } : void 0
|
|
6171
6916
|
);
|
|
@@ -6212,7 +6957,7 @@ function editCommand() {
|
|
|
6212
6957
|
}
|
|
6213
6958
|
let sources;
|
|
6214
6959
|
if (opts.sourcesFile) {
|
|
6215
|
-
const parsed =
|
|
6960
|
+
const parsed = readJsonFile2(opts.sourcesFile);
|
|
6216
6961
|
if (!Array.isArray(parsed)) {
|
|
6217
6962
|
warn(`--sources-file ${opts.sourcesFile} must contain a JSON array of source rows`);
|
|
6218
6963
|
process.exit(1);
|
|
@@ -6230,10 +6975,10 @@ function editCommand() {
|
|
|
6230
6975
|
const input2 = {
|
|
6231
6976
|
mode: opts.mode,
|
|
6232
6977
|
planTier: opts.planTier,
|
|
6233
|
-
transcript:
|
|
6978
|
+
transcript: readJsonFile2(opts.transcript),
|
|
6234
6979
|
sources,
|
|
6235
|
-
...opts.silence ? { silence:
|
|
6236
|
-
...opts.offsets ? { offsets:
|
|
6980
|
+
...opts.silence ? { silence: readJsonFile2(opts.silence) } : {},
|
|
6981
|
+
...opts.offsets ? { offsets: readJsonFile2(opts.offsets) } : {},
|
|
6237
6982
|
...opts.transcriptSource ? { transcriptSourceId: opts.transcriptSource } : {},
|
|
6238
6983
|
...opts.instructions !== void 0 ? { instructions: opts.instructions } : {},
|
|
6239
6984
|
...opts.styleGuide !== void 0 ? { styleGuide: opts.styleGuide } : {},
|
|
@@ -6259,10 +7004,10 @@ function editCommand() {
|
|
|
6259
7004
|
try {
|
|
6260
7005
|
const client = buildClient(opts.profile);
|
|
6261
7006
|
const input2 = {
|
|
6262
|
-
edl:
|
|
6263
|
-
transcript:
|
|
6264
|
-
...opts.speakerMap ? { speakerMap:
|
|
6265
|
-
...opts.speakerNames ? { speakerNames:
|
|
7007
|
+
edl: readJsonFile2(opts.edl),
|
|
7008
|
+
transcript: readJsonFile2(opts.transcript),
|
|
7009
|
+
...opts.speakerMap ? { speakerMap: readJsonFile2(opts.speakerMap) } : {},
|
|
7010
|
+
...opts.speakerNames ? { speakerNames: readJsonFile2(opts.speakerNames) } : {},
|
|
6266
7011
|
...opts.minShotMs !== void 0 ? { minShotMs: opts.minShotMs } : {},
|
|
6267
7012
|
...opts.leadMs !== void 0 ? { leadMs: opts.leadMs } : {},
|
|
6268
7013
|
...opts.maxShotMs !== void 0 ? { maxShotMs: opts.maxShotMs } : {},
|
|
@@ -6283,6 +7028,322 @@ function editCommand() {
|
|
|
6283
7028
|
);
|
|
6284
7029
|
return cmd;
|
|
6285
7030
|
}
|
|
7031
|
+
var GIB = 1024 * 1024 * 1024;
|
|
7032
|
+
function money(m) {
|
|
7033
|
+
try {
|
|
7034
|
+
return new Intl.NumberFormat("en", { style: "currency", currency: m.currency }).format(m.amount);
|
|
7035
|
+
} catch {
|
|
7036
|
+
return `${m.amount} ${m.currency}`;
|
|
7037
|
+
}
|
|
7038
|
+
}
|
|
7039
|
+
function priceCell(plan, slot) {
|
|
7040
|
+
if (plan.prices === null) return "free";
|
|
7041
|
+
if (slot === "monthly") return plan.prices.monthly ? money(plan.prices.monthly) : "unavailable";
|
|
7042
|
+
const yearly = plan.prices.yearly;
|
|
7043
|
+
if (!yearly) return "unavailable";
|
|
7044
|
+
return yearly.perMonth === null ? money(yearly) : `${money(yearly)} (${money({ amount: yearly.perMonth, currency: yearly.currency })} a month)`;
|
|
7045
|
+
}
|
|
7046
|
+
function grant(credits) {
|
|
7047
|
+
return `${credits.amount.toLocaleString("en")} / ${credits.per}`;
|
|
7048
|
+
}
|
|
7049
|
+
function creditsCell(plan) {
|
|
7050
|
+
if (plan.signupCredits !== null) return `${plan.signupCredits.toLocaleString("en")} once`;
|
|
7051
|
+
const monthly = plan.prices?.monthly?.credits ?? null;
|
|
7052
|
+
const yearly = plan.prices?.yearly?.credits ?? null;
|
|
7053
|
+
if (monthly && yearly) {
|
|
7054
|
+
return monthly.amount === yearly.amount && monthly.per === yearly.per ? grant(monthly) : `${grant(monthly)} (yearly: ${grant(yearly)})`;
|
|
7055
|
+
}
|
|
7056
|
+
if (monthly) return grant(monthly);
|
|
7057
|
+
return yearly ? `yearly: ${grant(yearly)}` : "-";
|
|
7058
|
+
}
|
|
7059
|
+
function storageCell(bytes) {
|
|
7060
|
+
const gb = bytes / GIB;
|
|
7061
|
+
return `${Number.isInteger(gb) ? gb : gb.toFixed(1)} GB`;
|
|
7062
|
+
}
|
|
7063
|
+
function billingCommand() {
|
|
7064
|
+
const cmd = new Command("billing").description(
|
|
7065
|
+
"plans and prices, your subscription, and how this deployment bills (buying stays in the app)"
|
|
7066
|
+
);
|
|
7067
|
+
cmd.command("plans").description("the plans and credit packs on sale, with their prices (Nodaro Cloud; no sign-in needed)").option("--profile <name>", "ask this profile's instance (its token is not sent)").option("--base-url <url>", "ask this instance instead (default: the profile's, else https://app.nodaro.ai)").option("--json").addHelpText(
|
|
7068
|
+
"after",
|
|
7069
|
+
`
|
|
7070
|
+
Examples:
|
|
7071
|
+
$ nodaro billing plans
|
|
7072
|
+
$ nodaro billing plans --json`
|
|
7073
|
+
).action(async (opts) => {
|
|
7074
|
+
try {
|
|
7075
|
+
const client = buildPublicClient({ profile: opts.profile, baseUrl: opts.baseUrl });
|
|
7076
|
+
const result = await client.billing.plans();
|
|
7077
|
+
if (opts.json) {
|
|
7078
|
+
emit(result, opts);
|
|
7079
|
+
return;
|
|
7080
|
+
}
|
|
7081
|
+
table(
|
|
7082
|
+
result.data.map((plan) => ({
|
|
7083
|
+
id: plan.id,
|
|
7084
|
+
name: plan.name,
|
|
7085
|
+
monthly: priceCell(plan, "monthly"),
|
|
7086
|
+
yearly: priceCell(plan, "yearly"),
|
|
7087
|
+
credits: creditsCell(plan),
|
|
7088
|
+
parallel: plan.parallelism,
|
|
7089
|
+
storage: storageCell(plan.storageBytes)
|
|
7090
|
+
})),
|
|
7091
|
+
["id", "name", "monthly", "yearly", "credits", "parallel", "storage"]
|
|
7092
|
+
);
|
|
7093
|
+
info("");
|
|
7094
|
+
table(
|
|
7095
|
+
result.topUps.map((pack) => ({
|
|
7096
|
+
id: pack.id,
|
|
7097
|
+
credits: pack.credits.toLocaleString("en"),
|
|
7098
|
+
price: pack.price ? money(pack.price) : "unavailable"
|
|
7099
|
+
})),
|
|
7100
|
+
["id", "credits", "price"]
|
|
7101
|
+
);
|
|
7102
|
+
const { min, max, currency } = result.topUpRange;
|
|
7103
|
+
dim(`Or load any whole amount from ${money({ amount: min, currency })} to ${money({ amount: max, currency })} in the app.`);
|
|
7104
|
+
} catch (err) {
|
|
7105
|
+
handleError(err);
|
|
7106
|
+
}
|
|
7107
|
+
});
|
|
7108
|
+
cmd.command("subscription").description("your subscription, and the plan your account's entitlements follow (Nodaro Cloud)").option("--profile <name>").option("--json").action(async (opts) => {
|
|
7109
|
+
try {
|
|
7110
|
+
const client = buildClient(opts.profile);
|
|
7111
|
+
const result = await client.billing.subscription();
|
|
7112
|
+
if (opts.json) {
|
|
7113
|
+
emit(result, opts);
|
|
7114
|
+
return;
|
|
7115
|
+
}
|
|
7116
|
+
if (!result.data) {
|
|
7117
|
+
info(`No subscription. Plan in force: ${result.effectiveTier}`);
|
|
7118
|
+
return;
|
|
7119
|
+
}
|
|
7120
|
+
detail(result);
|
|
7121
|
+
} catch (err) {
|
|
7122
|
+
handleError(err);
|
|
7123
|
+
}
|
|
7124
|
+
});
|
|
7125
|
+
cmd.command("account").description("your plan and balance as this deployment's billing provider reports them, in its unit").option("--profile <name>").option("--json").action(async (opts) => {
|
|
7126
|
+
try {
|
|
7127
|
+
const client = buildClient(opts.profile);
|
|
7128
|
+
const account = await client.billing.account();
|
|
7129
|
+
if (opts.json) {
|
|
7130
|
+
emit(account, opts);
|
|
7131
|
+
return;
|
|
7132
|
+
}
|
|
7133
|
+
if (account === null) {
|
|
7134
|
+
info("The billing provider could not answer right now; this is not a zero balance.");
|
|
7135
|
+
return;
|
|
7136
|
+
}
|
|
7137
|
+
detail(account);
|
|
7138
|
+
} catch (err) {
|
|
7139
|
+
handleError(err);
|
|
7140
|
+
}
|
|
7141
|
+
});
|
|
7142
|
+
cmd.command("surface").description("how this deployment bills: whether it meters usage, and the unit costs display in (no sign-in needed)").option("--profile <name>", "ask this profile's instance (its token is not sent)").option("--base-url <url>", "ask this instance instead (default: the profile's, else https://app.nodaro.ai)").option("--json").action(async (opts) => {
|
|
7143
|
+
try {
|
|
7144
|
+
const client = buildPublicClient({ profile: opts.profile, baseUrl: opts.baseUrl });
|
|
7145
|
+
const surface = await client.billing.surface();
|
|
7146
|
+
if (opts.json) {
|
|
7147
|
+
emit(surface, opts);
|
|
7148
|
+
return;
|
|
7149
|
+
}
|
|
7150
|
+
detail(surface);
|
|
7151
|
+
} catch (err) {
|
|
7152
|
+
handleError(err);
|
|
7153
|
+
}
|
|
7154
|
+
});
|
|
7155
|
+
return cmd;
|
|
7156
|
+
}
|
|
7157
|
+
var JOB_EVENTS = ["job.completed", "job.failed"];
|
|
7158
|
+
var DELIVERY_STATUSES = ["pending", "delivered", "failed"];
|
|
7159
|
+
function eventList(value) {
|
|
7160
|
+
if (value === void 0) return void 0;
|
|
7161
|
+
const events = value.split(/[\s,]+/).filter(Boolean);
|
|
7162
|
+
const unknown = events.filter((e) => !JOB_EVENTS.includes(e));
|
|
7163
|
+
if (unknown.length > 0) throw new Error(`unknown event ${unknown.join(", ")} \u2014 use ${JOB_EVENTS.join(" or ")}`);
|
|
7164
|
+
return events;
|
|
7165
|
+
}
|
|
7166
|
+
function printSecret(secret, what) {
|
|
7167
|
+
info("");
|
|
7168
|
+
info(`Signing secret (${what} \u2014 shown this once, store it now):`);
|
|
7169
|
+
info(` ${secret}`);
|
|
7170
|
+
info("");
|
|
7171
|
+
}
|
|
7172
|
+
function deliveryRow(d) {
|
|
7173
|
+
return {
|
|
7174
|
+
id: d.id,
|
|
7175
|
+
event: d.event,
|
|
7176
|
+
status: d.status,
|
|
7177
|
+
attempts: d.attempts,
|
|
7178
|
+
response: d.responseStatus ?? "",
|
|
7179
|
+
error: d.error ?? "",
|
|
7180
|
+
createdAt: d.createdAt
|
|
7181
|
+
};
|
|
7182
|
+
}
|
|
7183
|
+
var sleep2 = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
7184
|
+
function webhooksCommand() {
|
|
7185
|
+
const cmd = new Command("webhooks").description(
|
|
7186
|
+
"outbound webhooks: endpoints that receive your job.completed / job.failed, signed \u2014 create, rotate the secret, delivery log, test"
|
|
7187
|
+
);
|
|
7188
|
+
cmd.command("list").description("your webhook endpoints").option("--profile <name>").option("--json").action(async (opts) => {
|
|
7189
|
+
try {
|
|
7190
|
+
const client = buildClient(opts.profile);
|
|
7191
|
+
const result = await client.webhooks.list();
|
|
7192
|
+
if (opts.json) {
|
|
7193
|
+
emit(result.data, opts);
|
|
7194
|
+
return;
|
|
7195
|
+
}
|
|
7196
|
+
table(
|
|
7197
|
+
result.data.map((e) => ({
|
|
7198
|
+
id: e.id,
|
|
7199
|
+
url: e.url,
|
|
7200
|
+
events: e.events.join(","),
|
|
7201
|
+
active: e.isActive ? "yes" : e.disabledReason ? `no (${e.disabledReason})` : "no",
|
|
7202
|
+
app: e.appId ?? ""
|
|
7203
|
+
})),
|
|
7204
|
+
["id", "url", "events", "active", "app"]
|
|
7205
|
+
);
|
|
7206
|
+
} catch (err) {
|
|
7207
|
+
handleError(err);
|
|
7208
|
+
}
|
|
7209
|
+
});
|
|
7210
|
+
cmd.command("get <id>").description("show one endpoint").option("--profile <name>").option("--json").action(async (id, opts) => {
|
|
7211
|
+
try {
|
|
7212
|
+
const client = buildClient(opts.profile);
|
|
7213
|
+
const result = await client.webhooks.get(id);
|
|
7214
|
+
if (opts.json) emit(result.data, opts);
|
|
7215
|
+
else detail(result.data);
|
|
7216
|
+
} catch (err) {
|
|
7217
|
+
handleError(err);
|
|
7218
|
+
}
|
|
7219
|
+
});
|
|
7220
|
+
cmd.command("create").description("register an https endpoint; prints its signing secret once").requiredOption("--url <url>", "https address on a public host").option("--events <events>", `comma-separated: ${JOB_EVENTS.join(",")} (default: both)`).option("--description <text>").option("--profile <name>").option("--json").action(async (opts) => {
|
|
7221
|
+
try {
|
|
7222
|
+
const events = eventList(opts.events);
|
|
7223
|
+
const client = buildClient(opts.profile);
|
|
7224
|
+
const result = await client.webhooks.create({ url: opts.url, events, description: opts.description });
|
|
7225
|
+
if (opts.json) {
|
|
7226
|
+
emit(result, opts);
|
|
7227
|
+
return;
|
|
7228
|
+
}
|
|
7229
|
+
success(`created webhook endpoint ${result.data.id}`);
|
|
7230
|
+
printSecret(result.secret, "new endpoint");
|
|
7231
|
+
} catch (err) {
|
|
7232
|
+
handleError(err);
|
|
7233
|
+
}
|
|
7234
|
+
});
|
|
7235
|
+
cmd.command("update <id>").description("change the address, events or description; switch on or off").option("--url <url>").option("--events <events>", `comma-separated: ${JOB_EVENTS.join(",")}`).option("--description <text>").option("--clear-description").option("--enable", "switch on (clears an automatic switch-off)").option("--disable", "switch off").option("--profile <name>").option("--json").action(
|
|
7236
|
+
async (id, opts) => {
|
|
7237
|
+
try {
|
|
7238
|
+
if (opts.enable && opts.disable) throw new Error("choose one of --enable or --disable");
|
|
7239
|
+
const events = eventList(opts.events);
|
|
7240
|
+
const isActive = opts.enable ? true : opts.disable ? false : void 0;
|
|
7241
|
+
const description = opts.clearDescription ? null : opts.description;
|
|
7242
|
+
if (opts.url === void 0 && events === void 0 && isActive === void 0 && description === void 0) {
|
|
7243
|
+
throw new Error("nothing to update \u2014 provide --url, --events, --description, --clear-description, --enable or --disable");
|
|
7244
|
+
}
|
|
7245
|
+
const client = buildClient(opts.profile);
|
|
7246
|
+
const result = await client.webhooks.update(id, { url: opts.url, events, isActive, description });
|
|
7247
|
+
if (opts.json) {
|
|
7248
|
+
emit(result.data, opts);
|
|
7249
|
+
return;
|
|
7250
|
+
}
|
|
7251
|
+
success(`updated webhook endpoint ${result.data.id}`);
|
|
7252
|
+
} catch (err) {
|
|
7253
|
+
handleError(err);
|
|
7254
|
+
}
|
|
7255
|
+
}
|
|
7256
|
+
);
|
|
7257
|
+
cmd.command("delete <id>").description("delete an endpoint and its delivery log").option("--profile <name>").option("--json").action(async (id, opts) => {
|
|
7258
|
+
try {
|
|
7259
|
+
const client = buildClient(opts.profile);
|
|
7260
|
+
await client.webhooks.delete(id);
|
|
7261
|
+
if (opts.json) {
|
|
7262
|
+
emit({ success: true, id }, opts);
|
|
7263
|
+
return;
|
|
7264
|
+
}
|
|
7265
|
+
success(`deleted webhook endpoint ${id}`);
|
|
7266
|
+
} catch (err) {
|
|
7267
|
+
handleError(err);
|
|
7268
|
+
}
|
|
7269
|
+
});
|
|
7270
|
+
cmd.command("rotate-secret <id>").description("replace the signing secret; the old one keeps signing beside it for a grace period (a day by default); prints the new one once").option("--grace <seconds>", "how long the old secret keeps signing (0 = stop it now; at most 604800)").option("--profile <name>").option("--json").action(async (id, opts) => {
|
|
7271
|
+
try {
|
|
7272
|
+
let input2 = {};
|
|
7273
|
+
if (opts.grace !== void 0) {
|
|
7274
|
+
const seconds = Number(opts.grace);
|
|
7275
|
+
if (!Number.isInteger(seconds) || seconds < 0 || seconds > 604800) {
|
|
7276
|
+
throw new Error(`--grace must be whole seconds from 0 to 604800, not ${opts.grace}`);
|
|
7277
|
+
}
|
|
7278
|
+
input2 = { gracePeriodSeconds: seconds };
|
|
7279
|
+
}
|
|
7280
|
+
const client = buildClient(opts.profile);
|
|
7281
|
+
const result = await client.webhooks.rotateSecret(id, input2);
|
|
7282
|
+
if (opts.json) {
|
|
7283
|
+
emit(result, opts);
|
|
7284
|
+
return;
|
|
7285
|
+
}
|
|
7286
|
+
success(`rotated the signing secret of ${id}`);
|
|
7287
|
+
printSecret(result.secret, "rotated");
|
|
7288
|
+
info(
|
|
7289
|
+
result.previousSecretExpiresAt ? `The old secret keeps signing too until ${result.previousSecretExpiresAt}: update your receiver before then.` : "The old secret no longer signs: update your receiver now."
|
|
7290
|
+
);
|
|
7291
|
+
} catch (err) {
|
|
7292
|
+
handleError(err);
|
|
7293
|
+
}
|
|
7294
|
+
});
|
|
7295
|
+
cmd.command("deliveries <id>").description("the endpoint's delivery log, newest first (kept 30 days)").option("--status <status>", DELIVERY_STATUSES.join("|")).option("--limit <n>", "page size (1-100)").option("--cursor <cursor>", "the previous page's next").option("--profile <name>").option("--json").action(async (id, opts) => {
|
|
7296
|
+
try {
|
|
7297
|
+
if (opts.status && !DELIVERY_STATUSES.includes(opts.status)) {
|
|
7298
|
+
throw new Error(`unknown status ${opts.status} \u2014 use ${DELIVERY_STATUSES.join(", ")}`);
|
|
7299
|
+
}
|
|
7300
|
+
const client = buildClient(opts.profile);
|
|
7301
|
+
const page = await client.webhooks.deliveries(id, {
|
|
7302
|
+
status: opts.status,
|
|
7303
|
+
limit: opts.limit ? Number(opts.limit) : void 0,
|
|
7304
|
+
cursor: opts.cursor
|
|
7305
|
+
});
|
|
7306
|
+
if (opts.json) {
|
|
7307
|
+
emit(page, opts);
|
|
7308
|
+
return;
|
|
7309
|
+
}
|
|
7310
|
+
table(page.data.map(deliveryRow), ["id", "event", "status", "attempts", "response", "error", "createdAt"]);
|
|
7311
|
+
if (page.next) dim(`next: --cursor ${page.next}`);
|
|
7312
|
+
} catch (err) {
|
|
7313
|
+
handleError(err);
|
|
7314
|
+
}
|
|
7315
|
+
});
|
|
7316
|
+
cmd.command("test <id>").description("send a ping to the endpoint (tried once); --wait shows how it answered").option("--wait", "wait for the result (up to 60 s)").option("--poll-interval <ms>", "how often to look (default 1000)").option("--profile <name>").option("--json").action(async (id, opts) => {
|
|
7317
|
+
try {
|
|
7318
|
+
const client = buildClient(opts.profile);
|
|
7319
|
+
const queued = await client.webhooks.test(id);
|
|
7320
|
+
if (!opts.wait) {
|
|
7321
|
+
if (opts.json) emit(queued.data, opts);
|
|
7322
|
+
else success(`queued ping ${queued.data.id} \u2014 follow it with: nodaro webhooks deliveries ${id}`);
|
|
7323
|
+
return;
|
|
7324
|
+
}
|
|
7325
|
+
const interval = Math.max(1, Number(opts.pollInterval ?? 1e3) || 1e3);
|
|
7326
|
+
const deadline = Date.now() + 6e4;
|
|
7327
|
+
let last = queued.data;
|
|
7328
|
+
for (; ; ) {
|
|
7329
|
+
last = (await client.webhooks.getDelivery(id, queued.data.id)).data;
|
|
7330
|
+
if (last.status !== "pending" || Date.now() > deadline) break;
|
|
7331
|
+
await sleep2(interval);
|
|
7332
|
+
}
|
|
7333
|
+
if (opts.json) {
|
|
7334
|
+
emit(last, opts);
|
|
7335
|
+
return;
|
|
7336
|
+
}
|
|
7337
|
+
if (last.status === "delivered") success(`ping delivered: ${last.responseStatus} in ${last.durationMs ?? "?"} ms`);
|
|
7338
|
+
else if (last.status === "failed") {
|
|
7339
|
+
warn(terminalSafe(`ping failed: ${last.error ?? "no answer"}${last.responseBody ? ` \u2014 ${last.responseBody}` : ""}`));
|
|
7340
|
+
} else warn(`ping still pending after 60 s \u2014 check: nodaro webhooks deliveries ${id}`);
|
|
7341
|
+
} catch (err) {
|
|
7342
|
+
handleError(err);
|
|
7343
|
+
}
|
|
7344
|
+
});
|
|
7345
|
+
return cmd;
|
|
7346
|
+
}
|
|
6286
7347
|
|
|
6287
7348
|
// src/index.ts
|
|
6288
7349
|
function readVersion() {
|
|
@@ -6303,6 +7364,7 @@ program.addCommand(workflowsCommand());
|
|
|
6303
7364
|
program.addCommand(appsCommand());
|
|
6304
7365
|
program.addCommand(nodesCommand());
|
|
6305
7366
|
program.addCommand(jobsCommand());
|
|
7367
|
+
program.addCommand(galleryCommand());
|
|
6306
7368
|
program.addCommand(videoProCommand());
|
|
6307
7369
|
program.addCommand(executionsCommand());
|
|
6308
7370
|
program.addCommand(charactersCommand());
|
|
@@ -6313,6 +7375,8 @@ program.addCommand(audioCommand());
|
|
|
6313
7375
|
program.addCommand(presetsCommand());
|
|
6314
7376
|
program.addCommand(savedPostsCommand());
|
|
6315
7377
|
program.addCommand(collectionsCommand());
|
|
7378
|
+
program.addCommand(palettesCommand());
|
|
7379
|
+
program.addCommand(moodboardsCommand());
|
|
6316
7380
|
program.addCommand(competitorsCommand());
|
|
6317
7381
|
program.addCommand(communityCommand());
|
|
6318
7382
|
program.addCommand(pickerCatalogsCommand());
|
|
@@ -6323,6 +7387,8 @@ program.addCommand(recastCommand());
|
|
|
6323
7387
|
program.addCommand(orgCommand());
|
|
6324
7388
|
program.addCommand(workspaceCommand());
|
|
6325
7389
|
program.addCommand(editCommand());
|
|
7390
|
+
program.addCommand(billingCommand());
|
|
7391
|
+
program.addCommand(webhooksCommand());
|
|
6326
7392
|
registerLocationsCommands(program);
|
|
6327
7393
|
registerObjectsCommands(program);
|
|
6328
7394
|
program.parseAsync().catch((err) => {
|