@nodaro/cli 1.31.0 → 1.34.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 +18 -3
- package/dist/index.js +1759 -237
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -9,19 +9,23 @@ 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 {
|
|
12
|
+
import { createClient, StaticTokenAuth, CallbackAuth } from '@nodaro/sdk/client';
|
|
13
|
+
import { ContinuationPreviewPendingError, UnauthorizedError, NodaroError, AppRunVersionChangedError, AlreadyRunningError, ContinuationRefusedError } from '@nodaro/sdk/errors';
|
|
14
|
+
import { collectionRecordHeadline, PREVIEW_RENDER_NODE_TYPES, isPreviewRefusalCode, parseNodePresetExport } from '@nodaro/shared/nodes';
|
|
13
15
|
import select from '@inquirer/select';
|
|
14
16
|
import checkbox from '@inquirer/checkbox';
|
|
15
17
|
import input from '@inquirer/input';
|
|
16
18
|
import { CHARACTER_STYLES } from '@nodaro/shared/entities';
|
|
17
19
|
import { TRANSCRIBE_PROVIDERS, transcribeLaneSupportsWordTimestamps, DIALOGUE_PROVIDERS, dialogueStabilityAccepted, dialogueProviderOf, getDialogueCapabilities, TRANSCRIBE_LANES, DEFAULT_TRANSCRIBE_PROVIDER } from '@nodaro/shared/models';
|
|
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';
|
|
20
|
+
import { OVERLAY_ANCHORS, OVERLAY_PLATFORM_IDS, GENERATE_MASK_LIMITS, 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
21
|
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
22
|
import { VIDEO_OVERLAY_PRESET_IDS, VIDEO_OVERLAY_CORNERS, VIDEO_OVERLAY_OUTPUT_ASPECTS, isVideoOverlayPresetId, isVideoOverlayCorner, isVideoOverlayOutputAspect, VIDEO_OVERLAY_FITS } from '@nodaro/shared/video';
|
|
21
23
|
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
24
|
import { RECAST_SEGMENT_PACKS } from '@nodaro/shared/apps';
|
|
24
|
-
import {
|
|
25
|
+
import { LOCATION_ASSET_TYPES, LOCATION_ATTACH_COLUMNS } from '@nodaro/sdk/locations';
|
|
26
|
+
import { OBJECT_ASSET_TYPES, OBJECT_ATTACH_COLUMNS } from '@nodaro/sdk/objects';
|
|
27
|
+
import { SPEAKER_EMPHASIS_STYLES, EDIT_PLAN_MODES, SPEAKER_LAYOUT_IDS, EDL_TARGET_ASPECTS, EDIT_PLAN_TIERS, EDIT_PLAN_MAX_CLIP_COUNT, SPEAKER_SWITCH_IDS, isKnownSpeakerEmphasisStyle } from '@nodaro/shared/edl';
|
|
28
|
+
import { TRAILER_FORMATS, CLIP_PACK_MIN_TARGET_SEC, CLIP_PACK_MAX_TARGET_SEC, USE_CASE_NODE_TYPES } from '@nodaro/sdk/edit';
|
|
25
29
|
|
|
26
30
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
27
31
|
var __commonJS = (cb, mod) => function __require() {
|
|
@@ -37,7 +41,7 @@ var require_package = __commonJS({
|
|
|
37
41
|
"package.json"(exports$1, module) {
|
|
38
42
|
module.exports = {
|
|
39
43
|
name: "@nodaro/cli",
|
|
40
|
-
version: "1.
|
|
44
|
+
version: "1.34.0",
|
|
41
45
|
description: "Command-line interface for Nodaro \u2014 list and run workflows, inspect jobs and executions, manage projects from the terminal.",
|
|
42
46
|
type: "module",
|
|
43
47
|
license: "Apache-2.0",
|
|
@@ -78,11 +82,11 @@ var require_package = __commonJS({
|
|
|
78
82
|
"@inquirer/confirm": "^6.0.12",
|
|
79
83
|
"@inquirer/input": "^5.0.12",
|
|
80
84
|
"@inquirer/select": "^5.1.4",
|
|
81
|
-
"@nodaro/sdk": "^2.
|
|
82
|
-
"@nodaro/shared": "^3.
|
|
85
|
+
"@nodaro/sdk": "^2.31.0",
|
|
86
|
+
"@nodaro/shared": "^3.35.0",
|
|
83
87
|
commander: "^12.1.0",
|
|
84
88
|
picocolors: "^1.1.1",
|
|
85
|
-
"@nodaro/prompts": "^1.
|
|
89
|
+
"@nodaro/prompts": "^1.40.0"
|
|
86
90
|
},
|
|
87
91
|
devDependencies: {
|
|
88
92
|
tsup: "^8.5.0",
|
|
@@ -102,6 +106,7 @@ var require_package = __commonJS({
|
|
|
102
106
|
};
|
|
103
107
|
}
|
|
104
108
|
});
|
|
109
|
+
var DEFAULT_BASE_URL = "https://app.nodaro.ai";
|
|
105
110
|
function configDir() {
|
|
106
111
|
return process.env.NODARO_CONFIG_DIR ?? join(homedir(), ".config", "nodaro");
|
|
107
112
|
}
|
|
@@ -155,6 +160,9 @@ function deleteProfile(name) {
|
|
|
155
160
|
saveConfig(config);
|
|
156
161
|
return true;
|
|
157
162
|
}
|
|
163
|
+
function terminalSafe(text) {
|
|
164
|
+
return text.replace(/[\u0000-\u001f\u007f-\u009f]/g, "\uFFFD");
|
|
165
|
+
}
|
|
158
166
|
function emit(value, opts = {}) {
|
|
159
167
|
if (opts.json) {
|
|
160
168
|
const indent = process.stdout.isTTY ? 2 : void 0;
|
|
@@ -203,7 +211,7 @@ function table(rows2, columns) {
|
|
|
203
211
|
}
|
|
204
212
|
function format(value) {
|
|
205
213
|
if (value === null || value === void 0) return "";
|
|
206
|
-
if (typeof value === "string") return value;
|
|
214
|
+
if (typeof value === "string") return terminalSafe(value);
|
|
207
215
|
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
208
216
|
if (value instanceof Date) return value.toISOString();
|
|
209
217
|
return JSON.stringify(value);
|
|
@@ -319,7 +327,6 @@ function escapeHtml(s) {
|
|
|
319
327
|
}
|
|
320
328
|
|
|
321
329
|
// src/commands/auth.ts
|
|
322
|
-
var DEFAULT_BASE_URL = "https://app.nodaro.ai";
|
|
323
330
|
function authCommand() {
|
|
324
331
|
const cmd = new Command("auth").description("manage credentials for one or more Nodaro instances");
|
|
325
332
|
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 +413,15 @@ function saveWorkspace(profileName, workspaceId) {
|
|
|
406
413
|
}
|
|
407
414
|
|
|
408
415
|
// src/client.ts
|
|
409
|
-
var CLI_VERSION = "1.
|
|
416
|
+
var CLI_VERSION = "1.34.0" ;
|
|
417
|
+
function buildPublicClient(opts = {}) {
|
|
418
|
+
const { profile } = getProfile(opts.profile);
|
|
419
|
+
return createClient({
|
|
420
|
+
baseUrl: opts.baseUrl ?? profile?.baseUrl ?? DEFAULT_BASE_URL,
|
|
421
|
+
auth: new CallbackAuth(() => null),
|
|
422
|
+
clientLabel: `cli/${CLI_VERSION}`
|
|
423
|
+
});
|
|
424
|
+
}
|
|
410
425
|
function buildClient(profileName) {
|
|
411
426
|
const { name, profile } = getProfile(profileName);
|
|
412
427
|
if (!profile) {
|
|
@@ -615,14 +630,15 @@ function sessionsCommand() {
|
|
|
615
630
|
handleError(err);
|
|
616
631
|
}
|
|
617
632
|
});
|
|
618
|
-
cmd.command("update <id>").description("rename or archive a session").option("--title <title>", "new title").option("--untitled", "clear the title").option("--archive", "archive it").option("--unarchive", "bring it back").option("--profile <name>").option("--json").action(async (id, opts) => {
|
|
633
|
+
cmd.command("update <id>").description("rename or archive a session, or pick its cover").option("--title <title>", "new title").option("--untitled", "clear the title").option("--archive", "archive it").option("--unarchive", "bring it back").option("--cover <jobId>", "one of the session's items to lead its previews").option("--auto-cover", "go back to the automatic cover").option("--profile <name>").option("--json").action(async (id, opts) => {
|
|
619
634
|
try {
|
|
620
635
|
const title = opts.untitled ? null : opts.title;
|
|
621
636
|
const archived = opts.archive ? true : opts.unarchive ? false : void 0;
|
|
622
|
-
|
|
623
|
-
|
|
637
|
+
const coverJobId = opts.autoCover ? null : opts.cover;
|
|
638
|
+
if (title === void 0 && archived === void 0 && coverJobId === void 0) {
|
|
639
|
+
throw new Error("nothing to update \u2014 provide --title, --untitled, --archive, --unarchive, --cover or --auto-cover");
|
|
624
640
|
}
|
|
625
|
-
const result = await buildClient(opts.profile).sessions.update(id, { title, archived });
|
|
641
|
+
const result = await buildClient(opts.profile).sessions.update(id, { title, archived, coverJobId });
|
|
626
642
|
if (opts.json) {
|
|
627
643
|
emit(result.data, opts);
|
|
628
644
|
return;
|
|
@@ -670,8 +686,6 @@ function sessionsCommand() {
|
|
|
670
686
|
});
|
|
671
687
|
return cmd;
|
|
672
688
|
}
|
|
673
|
-
|
|
674
|
-
// src/util.ts
|
|
675
689
|
function collectVariadic(value, previous) {
|
|
676
690
|
return [...previous ?? [], value];
|
|
677
691
|
}
|
|
@@ -739,12 +753,126 @@ async function reportQueuedJob(result, fetchJob, opts) {
|
|
|
739
753
|
json: opts.json
|
|
740
754
|
});
|
|
741
755
|
}
|
|
756
|
+
var TRAINING_IN_FLIGHT = /* @__PURE__ */ new Set(["queued", "training"]);
|
|
757
|
+
function isTransientPollError(err) {
|
|
758
|
+
if (!(err instanceof NodaroError)) return true;
|
|
759
|
+
if (err.status === 408 || err.status === 429) return true;
|
|
760
|
+
return !(err.status >= 400 && err.status < 500);
|
|
761
|
+
}
|
|
762
|
+
async function watchTraining(opts) {
|
|
763
|
+
const intervalMs = opts.intervalMs ?? 1e4;
|
|
764
|
+
const start = Date.now();
|
|
765
|
+
let lastStatus = "";
|
|
766
|
+
let lastInFlight;
|
|
767
|
+
for (; ; ) {
|
|
768
|
+
let result;
|
|
769
|
+
try {
|
|
770
|
+
result = await opts.fetch();
|
|
771
|
+
} catch (err) {
|
|
772
|
+
if (!isTransientPollError(err)) throw err;
|
|
773
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
774
|
+
info(`[${elapsed(start)}s] poll failed (will retry): ${errMsg}`);
|
|
775
|
+
await sleep(intervalMs);
|
|
776
|
+
continue;
|
|
777
|
+
}
|
|
778
|
+
const status = result.status;
|
|
779
|
+
if (status !== lastStatus) {
|
|
780
|
+
info(`[${elapsed(start)}s] ${opts.label} \u2192 ${status}`);
|
|
781
|
+
lastStatus = status;
|
|
782
|
+
}
|
|
783
|
+
if (TRAINING_IN_FLIGHT.has(status)) {
|
|
784
|
+
lastInFlight = status;
|
|
785
|
+
await sleep(intervalMs);
|
|
786
|
+
continue;
|
|
787
|
+
}
|
|
788
|
+
if (opts.json) {
|
|
789
|
+
emit(result, opts);
|
|
790
|
+
return result;
|
|
791
|
+
}
|
|
792
|
+
if (status === "succeeded") {
|
|
793
|
+
success("training succeeded");
|
|
794
|
+
return result;
|
|
795
|
+
}
|
|
796
|
+
if (status === "failed") {
|
|
797
|
+
if (result.error) info(`reason: ${result.error}`);
|
|
798
|
+
process.exit(2);
|
|
799
|
+
}
|
|
800
|
+
if (status === "cancelled") process.exit(130);
|
|
801
|
+
if (status === "untrained") {
|
|
802
|
+
if (lastInFlight === "training") {
|
|
803
|
+
info("the training was removed before it finished");
|
|
804
|
+
process.exit(130);
|
|
805
|
+
}
|
|
806
|
+
if (lastInFlight === "queued") {
|
|
807
|
+
info("the training could not be started (nothing was charged), or was removed before it started");
|
|
808
|
+
process.exit(2);
|
|
809
|
+
}
|
|
810
|
+
info("no training in flight");
|
|
811
|
+
}
|
|
812
|
+
return result;
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
async function watchJobsUntilTerminal(opts) {
|
|
816
|
+
const intervalMs = opts.intervalMs ?? 2e3;
|
|
817
|
+
const start = Date.now();
|
|
818
|
+
const lastStatus = /* @__PURE__ */ new Map();
|
|
819
|
+
const settled = /* @__PURE__ */ new Map();
|
|
820
|
+
for (; ; ) {
|
|
821
|
+
for (const jobId of opts.jobIds) {
|
|
822
|
+
if (settled.has(jobId)) continue;
|
|
823
|
+
try {
|
|
824
|
+
const { data } = await opts.fetchStatus(jobId);
|
|
825
|
+
if (data.status !== lastStatus.get(jobId)) {
|
|
826
|
+
info(`[${elapsed(start)}s] ${jobId} \u2192 ${data.status}`);
|
|
827
|
+
lastStatus.set(jobId, data.status);
|
|
828
|
+
}
|
|
829
|
+
if (TERMINAL.has(data.status) || data.status === "pending_review") settled.set(jobId, data);
|
|
830
|
+
} catch (err) {
|
|
831
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
832
|
+
info(`[${elapsed(start)}s] ${jobId} poll failed (will retry): ${errMsg}`);
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
if (settled.size === opts.jobIds.length) break;
|
|
836
|
+
await sleep(intervalMs);
|
|
837
|
+
}
|
|
838
|
+
const finals = opts.jobIds.map((jobId) => settled.get(jobId));
|
|
839
|
+
if (opts.json) {
|
|
840
|
+
emit(finals, opts);
|
|
841
|
+
return finals;
|
|
842
|
+
}
|
|
843
|
+
const completed = finals.filter((job) => job.status === "completed").length;
|
|
844
|
+
if (completed === finals.length) {
|
|
845
|
+
success(`all ${finals.length} completed in ${elapsed(start)}s`);
|
|
846
|
+
return finals;
|
|
847
|
+
}
|
|
848
|
+
info(`${completed} of ${finals.length} completed`);
|
|
849
|
+
process.exit(finals.some((job) => job.status === "failed" || job.status === "cancelled") ? 2 : 3);
|
|
850
|
+
}
|
|
742
851
|
function elapsed(startMs) {
|
|
743
852
|
return ((Date.now() - startMs) / 1e3).toFixed(1);
|
|
744
853
|
}
|
|
745
854
|
function sleep(ms) {
|
|
746
855
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
747
856
|
}
|
|
857
|
+
function parseOverridePairs(pairs) {
|
|
858
|
+
if (!pairs?.length) return void 0;
|
|
859
|
+
const out = {};
|
|
860
|
+
for (const pair of pairs) {
|
|
861
|
+
const eq = pair.indexOf("=");
|
|
862
|
+
const dot = pair.indexOf(".");
|
|
863
|
+
if (eq === -1 || dot === -1 || dot > eq) throw new Error(`--override expects nodeId.field=value, got "${pair}"`);
|
|
864
|
+
const nodeId = pair.slice(0, dot);
|
|
865
|
+
const field = pair.slice(dot + 1, eq);
|
|
866
|
+
const raw = pair.slice(eq + 1);
|
|
867
|
+
let value = raw;
|
|
868
|
+
try {
|
|
869
|
+
value = JSON.parse(raw);
|
|
870
|
+
} catch {
|
|
871
|
+
}
|
|
872
|
+
out[nodeId] = { ...out[nodeId] ?? {}, [field]: value };
|
|
873
|
+
}
|
|
874
|
+
return out;
|
|
875
|
+
}
|
|
748
876
|
|
|
749
877
|
// src/commands/workflows.ts
|
|
750
878
|
function readJsonObject(path, flag) {
|
|
@@ -765,6 +893,52 @@ function readJsonObject(path, flag) {
|
|
|
765
893
|
}
|
|
766
894
|
return parsed;
|
|
767
895
|
}
|
|
896
|
+
function shellQuote(word) {
|
|
897
|
+
if (!word.startsWith("=") && /^[A-Za-z0-9_.:/=@%+-]+$/.test(word)) return word;
|
|
898
|
+
return `'${word.replace(/'/g, `'\\''`)}'`;
|
|
899
|
+
}
|
|
900
|
+
function readNextBody(value) {
|
|
901
|
+
const raw = value === "-" ? readFileSync(0, "utf8") : value.trim().startsWith("{") ? value : null;
|
|
902
|
+
let parsed;
|
|
903
|
+
if (raw === null) {
|
|
904
|
+
parsed = readJsonObject(value, "--next");
|
|
905
|
+
} else {
|
|
906
|
+
try {
|
|
907
|
+
parsed = JSON.parse(raw);
|
|
908
|
+
} catch (err) {
|
|
909
|
+
throw new Error(`--next is not valid JSON: ${err.message}`);
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
const next = parsed;
|
|
913
|
+
const shape = "--next takes the `next` of a continuation_preview_pending answer: { continueFromExecutionId, nodeIds, inputOverrides }";
|
|
914
|
+
if (typeof next !== "object" || next === null || Array.isArray(next)) throw new Error(shape);
|
|
915
|
+
if (typeof next.continueFromExecutionId !== "string" || next.continueFromExecutionId.length === 0) throw new Error(shape);
|
|
916
|
+
if (!Array.isArray(next.nodeIds) || next.nodeIds.length === 0 || !next.nodeIds.every((id) => typeof id === "string")) {
|
|
917
|
+
throw new Error(shape);
|
|
918
|
+
}
|
|
919
|
+
if (next.inputOverrides !== void 0 && (typeof next.inputOverrides !== "object" || next.inputOverrides === null || Array.isArray(next.inputOverrides))) {
|
|
920
|
+
throw new Error(shape);
|
|
921
|
+
}
|
|
922
|
+
for (const key2 of ["continueMode", "renderFinal"]) {
|
|
923
|
+
if (next[key2] !== void 0 && next[key2] !== null) {
|
|
924
|
+
throw new Error(`--next is the run a held continuation names, which never carries ${key2}: use --from-failed or workflows render-final for that run`);
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
return next;
|
|
928
|
+
}
|
|
929
|
+
function previewPendingCommand(workflowId, err) {
|
|
930
|
+
if (err.renderNodeIds.length === 1 && err.reviewNodeIds.length === 0) {
|
|
931
|
+
return `nodaro workflows render-final ${shellQuote(workflowId)} --from ${shellQuote(err.executionId)} --render ${shellQuote(err.renderNodeIds[0])}`;
|
|
932
|
+
}
|
|
933
|
+
if (!err.next) return null;
|
|
934
|
+
return `nodaro workflows run ${shellQuote(workflowId)} --next ${shellQuote(JSON.stringify(err.next))}`;
|
|
935
|
+
}
|
|
936
|
+
function soleRenderOf(nodes) {
|
|
937
|
+
const renders = (nodes ?? []).filter((n) => PREVIEW_RENDER_NODE_TYPES.has(n.type ?? ""));
|
|
938
|
+
if (renders.length === 1) return renders[0].id;
|
|
939
|
+
if (renders.length === 0) throw new Error("this workflow has no render node to finalize");
|
|
940
|
+
throw new Error(`this workflow has ${renders.length} renders \u2014 name one with --render: ${renders.map((n) => n.id).join(", ")}`);
|
|
941
|
+
}
|
|
768
942
|
function workflowsCommand() {
|
|
769
943
|
const cmd = new Command("workflows").description("list, run, and manage workflows");
|
|
770
944
|
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) => {
|
|
@@ -882,16 +1056,94 @@ function workflowsCommand() {
|
|
|
882
1056
|
handleError(err);
|
|
883
1057
|
}
|
|
884
1058
|
});
|
|
885
|
-
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)").
|
|
1059
|
+
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)").option(
|
|
1060
|
+
"--continue-from <executionId>",
|
|
1061
|
+
"continue an earlier execution of this workflow: nodes not run hand on its outputs (needs --node, unless --from-failed)"
|
|
1062
|
+
).option(
|
|
1063
|
+
"--from-failed",
|
|
1064
|
+
"with --continue-from: resume that FAILED run from where it stopped \u2014 runs only what it did not complete (of --node; default: the nodes its chain was first started on, every node for a full run, plus what it left failed), and each --node no run of its chain ever ran (charged; never a source, trigger or skipped node)"
|
|
1065
|
+
).option(
|
|
1066
|
+
"--override <pairs...>",
|
|
1067
|
+
"per-node override for this run only, nodeId.field=value (repeat); values that parse as JSON are sent as JSON, e.g. --override cut.quality=final",
|
|
1068
|
+
collectVariadic
|
|
1069
|
+
).option(
|
|
1070
|
+
"--next <json|file|->",
|
|
1071
|
+
"send the `next` a continuation_preview_pending answer names, exactly as given (inline JSON, a file, or - for stdin); not combinable with --node, --continue-from, --from-failed or --override"
|
|
1072
|
+
).option(
|
|
1073
|
+
"--idempotency-key <key>",
|
|
1074
|
+
"sent as Idempotency-Key (8+ characters): a retry with the same key answers the run already started"
|
|
1075
|
+
).action(
|
|
1076
|
+
async (id, opts) => {
|
|
1077
|
+
try {
|
|
1078
|
+
if (opts.fromFailed && !opts.continueFrom) {
|
|
1079
|
+
throw new Error("--from-failed needs --continue-from <executionId> (the run that failed)");
|
|
1080
|
+
}
|
|
1081
|
+
if (opts.next !== void 0 && (opts.node || opts.continueFrom || opts.fromFailed || opts.override)) {
|
|
1082
|
+
throw new Error("--next is the whole run: do not combine it with --node, --continue-from, --from-failed or --override");
|
|
1083
|
+
}
|
|
1084
|
+
if (opts.idempotencyKey !== void 0 && opts.idempotencyKey.trim().length < 8) {
|
|
1085
|
+
throw new Error("--idempotency-key must be at least 8 characters (the server ignores a shorter one)");
|
|
1086
|
+
}
|
|
1087
|
+
const params = opts.next !== void 0 ? readNextBody(opts.next) : {
|
|
1088
|
+
...opts.node ? { nodeIds: opts.node } : {},
|
|
1089
|
+
...opts.override ? { inputOverrides: parseOverridePairs(opts.override) } : {},
|
|
1090
|
+
...opts.continueFrom ? { continueFromExecutionId: opts.continueFrom } : {},
|
|
1091
|
+
...opts.fromFailed ? { continueMode: "from-failed" } : {}
|
|
1092
|
+
};
|
|
1093
|
+
const client = buildClient(opts.profile);
|
|
1094
|
+
const result = opts.idempotencyKey ? await client.workflows.run(id, params, { idempotencyKey: opts.idempotencyKey }) : await client.workflows.run(id, params);
|
|
1095
|
+
if (opts.json && !opts.watch) {
|
|
1096
|
+
emit(result, opts);
|
|
1097
|
+
return;
|
|
1098
|
+
}
|
|
1099
|
+
success(`execution ${result.executionId} (${result.status})${result.deduped ? " \u2014 already started by an earlier request with this key" : ""}`);
|
|
1100
|
+
if (result.continuedFrom && result.continuedFrom !== opts.continueFrom) {
|
|
1101
|
+
dim(`continued from ${result.continuedFrom}, a later continuation of ${opts.continueFrom} \u2014 only what it left runs`);
|
|
1102
|
+
}
|
|
1103
|
+
if (!opts.watch) {
|
|
1104
|
+
dim(`follow: nodaro executions get ${result.executionId} --watch`);
|
|
1105
|
+
return;
|
|
1106
|
+
}
|
|
1107
|
+
await watchExecution(client, result.executionId, opts);
|
|
1108
|
+
} catch (err) {
|
|
1109
|
+
if (err instanceof ContinuationPreviewPendingError) {
|
|
1110
|
+
const next = previewPendingCommand(id, err);
|
|
1111
|
+
if (next) {
|
|
1112
|
+
warn("once the preview is reviewed, finish it first, then continue again:");
|
|
1113
|
+
warn(` ${next}`);
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
handleError(err);
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
);
|
|
1120
|
+
cmd.command("render-final <workflowId>").description(
|
|
1121
|
+
"render the final of a run that stopped at a Preview render: the render at Final and every node after it, continuing that run (the server works out which nodes run)"
|
|
1122
|
+
).requiredOption("--from <executionId>", "the run that stopped at the preview (your own completed run of this workflow)").option("--render <nodeId>", "the render node to finalize (default: the workflow's only render)").option("--estimate", "quote it only: the nodes it runs and its estimated credits; nothing is created or charged").option("--watch", "poll execution status until completion").option("--profile <name>").option("--json").action(async (workflowId, opts) => {
|
|
886
1123
|
try {
|
|
887
1124
|
const client = buildClient(opts.profile);
|
|
888
|
-
const
|
|
889
|
-
const
|
|
1125
|
+
const renderNodeId = opts.render ?? soleRenderOf((await client.workflows.get(workflowId)).data.nodes);
|
|
1126
|
+
const params = { renderNodeId, continueFromExecutionId: opts.from };
|
|
1127
|
+
if (opts.estimate) {
|
|
1128
|
+
const { data: quote } = await client.workflows.estimateRenderFinal(workflowId, params);
|
|
1129
|
+
if (opts.json) {
|
|
1130
|
+
emit(quote, opts);
|
|
1131
|
+
return;
|
|
1132
|
+
}
|
|
1133
|
+
success(`Render final of ${renderNodeId} runs ${quote.nodeIds.join(", ")}`);
|
|
1134
|
+
if (quote.estimatedCredits !== null) {
|
|
1135
|
+
dim(
|
|
1136
|
+
`estimated ${quote.estimatedCredits} credits` + (quote.sufficient === false ? ` \u2014 not covered${quote.available !== null ? ` (${quote.available} available)` : ""}` : "")
|
|
1137
|
+
);
|
|
1138
|
+
}
|
|
1139
|
+
return;
|
|
1140
|
+
}
|
|
1141
|
+
const result = await client.workflows.renderFinal(workflowId, params);
|
|
890
1142
|
if (opts.json && !opts.watch) {
|
|
891
1143
|
emit(result, opts);
|
|
892
1144
|
return;
|
|
893
1145
|
}
|
|
894
|
-
success(`execution ${result.executionId} (${result.status})`);
|
|
1146
|
+
success(`execution ${result.executionId} (${result.status}) \u2014 Render final of ${renderNodeId}`);
|
|
895
1147
|
if (!opts.watch) {
|
|
896
1148
|
dim(`follow: nodaro executions get ${result.executionId} --watch`);
|
|
897
1149
|
return;
|
|
@@ -1014,8 +1266,59 @@ async function watchExecution(client, executionId, opts) {
|
|
|
1014
1266
|
...opts
|
|
1015
1267
|
});
|
|
1016
1268
|
}
|
|
1269
|
+
var RATING_FILTERS = ["good", "bad", "rated", "unrated"];
|
|
1270
|
+
function list(value) {
|
|
1271
|
+
if (value === void 0) return void 0;
|
|
1272
|
+
const values = value.split(",").map((v) => v.trim()).filter(Boolean);
|
|
1273
|
+
return values.length > 0 ? values : void 0;
|
|
1274
|
+
}
|
|
1275
|
+
function ratingFilter(value) {
|
|
1276
|
+
if (value === void 0) return void 0;
|
|
1277
|
+
if (!RATING_FILTERS.includes(value)) {
|
|
1278
|
+
throw new Error(`--rating takes ${RATING_FILTERS.join(", ")} (got "${value}")`);
|
|
1279
|
+
}
|
|
1280
|
+
return value;
|
|
1281
|
+
}
|
|
1282
|
+
function ratingArg(value) {
|
|
1283
|
+
if (value === "clear") return null;
|
|
1284
|
+
if (value === "good" || value === "bad") return value;
|
|
1285
|
+
throw new Error(`a rating is good, bad or clear (got "${value}")`);
|
|
1286
|
+
}
|
|
1017
1287
|
function jobsCommand() {
|
|
1018
|
-
const cmd = new Command("jobs").description("inspect and cancel
|
|
1288
|
+
const cmd = new Command("jobs").description("list, inspect, rate and cancel jobs");
|
|
1289
|
+
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) => {
|
|
1290
|
+
try {
|
|
1291
|
+
const rating = ratingFilter(opts.rating);
|
|
1292
|
+
const client = buildClient(opts.profile);
|
|
1293
|
+
const page = await client.jobs.list({
|
|
1294
|
+
status: list(opts.status),
|
|
1295
|
+
type: list(opts.type),
|
|
1296
|
+
origin: opts.origin,
|
|
1297
|
+
favorited: opts.favorited,
|
|
1298
|
+
rating,
|
|
1299
|
+
limit: opts.limit ? Number(opts.limit) : void 0,
|
|
1300
|
+
cursor: opts.cursor
|
|
1301
|
+
});
|
|
1302
|
+
if (opts.json) {
|
|
1303
|
+
emit(page, opts);
|
|
1304
|
+
return;
|
|
1305
|
+
}
|
|
1306
|
+
table(
|
|
1307
|
+
page.data.map((job) => ({
|
|
1308
|
+
id: job.id,
|
|
1309
|
+
status: job.status,
|
|
1310
|
+
type: job.input_data?.type ?? job.job_type ?? "",
|
|
1311
|
+
favorited: job.favorited ? "yes" : "",
|
|
1312
|
+
rating: job.rating ?? "",
|
|
1313
|
+
created: job.created_at
|
|
1314
|
+
})),
|
|
1315
|
+
["id", "status", "type", "favorited", "rating", "created"]
|
|
1316
|
+
);
|
|
1317
|
+
if (page.next) dim(`next: --cursor ${page.next}`);
|
|
1318
|
+
} catch (err) {
|
|
1319
|
+
handleError(err);
|
|
1320
|
+
}
|
|
1321
|
+
});
|
|
1019
1322
|
cmd.command("get <id>").description("show one job by id").option("--profile <name>").option("--json").action(async (id, opts) => {
|
|
1020
1323
|
try {
|
|
1021
1324
|
const client = buildClient(opts.profile);
|
|
@@ -1026,6 +1329,17 @@ function jobsCommand() {
|
|
|
1026
1329
|
handleError(err);
|
|
1027
1330
|
}
|
|
1028
1331
|
});
|
|
1332
|
+
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) => {
|
|
1333
|
+
try {
|
|
1334
|
+
const rating = ratingArg(value);
|
|
1335
|
+
const client = buildClient(opts.profile);
|
|
1336
|
+
const result = await client.jobs.rate(id, rating);
|
|
1337
|
+
if (opts.json) emit(result, opts);
|
|
1338
|
+
else success(rating ? `rated job ${id} ${rating}` : `cleared the rating of job ${id}`);
|
|
1339
|
+
} catch (err) {
|
|
1340
|
+
handleError(err);
|
|
1341
|
+
}
|
|
1342
|
+
});
|
|
1029
1343
|
cmd.command("cancel <id>").description("cancel a pending or running job").option("--profile <name>").option("--json").action(async (id, opts) => {
|
|
1030
1344
|
try {
|
|
1031
1345
|
const client = buildClient(opts.profile);
|
|
@@ -1038,6 +1352,62 @@ function jobsCommand() {
|
|
|
1038
1352
|
});
|
|
1039
1353
|
return cmd;
|
|
1040
1354
|
}
|
|
1355
|
+
var MEDIA_TYPES = ["image", "video", "audio"];
|
|
1356
|
+
function mediaType(value) {
|
|
1357
|
+
if (value === void 0) return void 0;
|
|
1358
|
+
if (!MEDIA_TYPES.includes(value)) {
|
|
1359
|
+
throw new Error(`--type takes ${MEDIA_TYPES.join(", ")} (got "${value}")`);
|
|
1360
|
+
}
|
|
1361
|
+
return value;
|
|
1362
|
+
}
|
|
1363
|
+
function galleryCommand() {
|
|
1364
|
+
const cmd = new Command("gallery").description("the public gallery, and your favorites");
|
|
1365
|
+
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) => {
|
|
1366
|
+
try {
|
|
1367
|
+
const type = mediaType(opts.type);
|
|
1368
|
+
if (opts.favorites && opts.user) throw new Error("--favorites lists your own favorites: drop --user");
|
|
1369
|
+
const client = buildClient(opts.profile);
|
|
1370
|
+
const userId = opts.favorites ? (await client.me()).id : opts.user;
|
|
1371
|
+
const page = await client.gallery.browse({
|
|
1372
|
+
type,
|
|
1373
|
+
userId,
|
|
1374
|
+
favoritesOnly: opts.favorites,
|
|
1375
|
+
limit: opts.limit ? Number(opts.limit) : void 0,
|
|
1376
|
+
cursor: opts.cursor
|
|
1377
|
+
});
|
|
1378
|
+
if (opts.json) {
|
|
1379
|
+
emit(page, opts);
|
|
1380
|
+
return;
|
|
1381
|
+
}
|
|
1382
|
+
table(
|
|
1383
|
+
page.data.map((item) => ({ id: item.id, type: item.type, url: item.outputUrl, created: item.createdAt })),
|
|
1384
|
+
["id", "type", "url", "created"]
|
|
1385
|
+
);
|
|
1386
|
+
if (page.nextCursor) dim(`next: --cursor ${page.nextCursor}`);
|
|
1387
|
+
} catch (err) {
|
|
1388
|
+
handleError(err);
|
|
1389
|
+
}
|
|
1390
|
+
});
|
|
1391
|
+
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) => {
|
|
1392
|
+
try {
|
|
1393
|
+
const result = await buildClient(opts.profile).gallery.toggleFavorite(jobId);
|
|
1394
|
+
if (opts.json) emit(result, opts);
|
|
1395
|
+
else success(result.favorited ? `favorited job ${jobId}` : `removed job ${jobId} from your favorites`);
|
|
1396
|
+
} catch (err) {
|
|
1397
|
+
handleError(err);
|
|
1398
|
+
}
|
|
1399
|
+
});
|
|
1400
|
+
cmd.command("favorites").description("your favorited job ids, newest first").option("--profile <name>").option("--json").action(async (opts) => {
|
|
1401
|
+
try {
|
|
1402
|
+
const ids = await buildClient(opts.profile).gallery.favorites();
|
|
1403
|
+
if (opts.json) emit(ids, opts);
|
|
1404
|
+
else for (const id of ids) info(id);
|
|
1405
|
+
} catch (err) {
|
|
1406
|
+
handleError(err);
|
|
1407
|
+
}
|
|
1408
|
+
});
|
|
1409
|
+
return cmd;
|
|
1410
|
+
}
|
|
1041
1411
|
function videoProCommand() {
|
|
1042
1412
|
const cmd = new Command("video-pro").description(
|
|
1043
1413
|
"stop / continue generate-video-pro runs (segmented long-video engine)"
|
|
@@ -1254,24 +1624,31 @@ function rejectPositionalInputs(extras, slug) {
|
|
|
1254
1624
|
}
|
|
1255
1625
|
process.exit(1);
|
|
1256
1626
|
}
|
|
1257
|
-
function
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
const
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
try {
|
|
1269
|
-
value = JSON.parse(raw);
|
|
1270
|
-
} catch {
|
|
1627
|
+
function parseAppVersion(value) {
|
|
1628
|
+
const n = Number(value);
|
|
1629
|
+
if (!Number.isInteger(n) || n < 1) throw new Error(`--app-version must be a whole number of 1 or more, got ${JSON.stringify(value)}`);
|
|
1630
|
+
return n;
|
|
1631
|
+
}
|
|
1632
|
+
function retryRefusalAdvice(slug, runId, err) {
|
|
1633
|
+
const startOver = ` start it over (every step runs, and is charged, again): nodaro apps run ${shellQuote(slug)} --input \u2026`;
|
|
1634
|
+
if (err instanceof AppRunVersionChangedError) {
|
|
1635
|
+
const lines = ["the app changed since this run, so it is not continued:", startOver];
|
|
1636
|
+
if (err.runVersion !== void 0) {
|
|
1637
|
+
lines.push(` or continue on the run's own version ${err.runVersion}: nodaro apps run-retry ${shellQuote(slug)} ${shellQuote(runId)} --app-version ${err.runVersion}`);
|
|
1271
1638
|
}
|
|
1272
|
-
|
|
1639
|
+
return lines;
|
|
1273
1640
|
}
|
|
1274
|
-
|
|
1641
|
+
if (err instanceof NodaroError && (err.code === "app_run_version_unavailable" || err.code === "continuation_not_failed")) {
|
|
1642
|
+
return [startOver];
|
|
1643
|
+
}
|
|
1644
|
+
if (err instanceof NodaroError && err.code === "already_running") {
|
|
1645
|
+
const live = err instanceof AlreadyRunningError ? `nodaro executions get ${shellQuote(err.executionId)} --watch` : `nodaro apps run-get ${shellQuote(slug)} ${shellQuote(runId)}`;
|
|
1646
|
+
return [` follow it: ${live}`];
|
|
1647
|
+
}
|
|
1648
|
+
if (err instanceof NodaroError && isPreviewRefusalCode(err.code)) {
|
|
1649
|
+
return [" retry it from the app page instead, where a person can review the Preview it stops at"];
|
|
1650
|
+
}
|
|
1651
|
+
return [];
|
|
1275
1652
|
}
|
|
1276
1653
|
function appsCommand() {
|
|
1277
1654
|
const cmd = new Command("apps").description("browse and run published apps (workflows wrapped in a curated UI)");
|
|
@@ -1374,8 +1751,75 @@ Tip: \`nodaro apps get <slug>\` shows the input schema for that app.`).action(as
|
|
|
1374
1751
|
handleError(err);
|
|
1375
1752
|
}
|
|
1376
1753
|
});
|
|
1754
|
+
cmd.command("run-retry <slug> <runId>").description("retry a failed app run from where it stopped: only the steps it did not complete run, and only those are charged").option("--dry-run", "show the steps the Retry would run and what it would charge; start nothing").option("--app-version <n>", "the app version you expect it to run (default: the app's latest); the run's own version continues it after the app changed", parseAppVersion).option("--watch", "follow the Retry's execution until completion").option("--profile <name>").option("--json").addHelpText("after", `
|
|
1755
|
+
The Retry runs the version the run ran, with the inputs the run applied (it takes none).
|
|
1756
|
+
To run with other inputs or on the app's current version, start over with \`nodaro apps run\`.
|
|
1757
|
+
|
|
1758
|
+
Examples:
|
|
1759
|
+
$ nodaro apps run-retry hair-styler-dd3erw 3f0c\u2026 --dry-run
|
|
1760
|
+
$ nodaro apps run-retry hair-styler-dd3erw 3f0c\u2026 --watch`).action(async (slug, runId, opts) => {
|
|
1761
|
+
try {
|
|
1762
|
+
const client = buildClient(opts.profile);
|
|
1763
|
+
if (opts.dryRun) {
|
|
1764
|
+
const { data: plan } = await client.apps.resume(slug, runId, { dryRun: true, version: opts.appVersion });
|
|
1765
|
+
if (opts.json) {
|
|
1766
|
+
emit(plan, opts);
|
|
1767
|
+
return;
|
|
1768
|
+
}
|
|
1769
|
+
table(
|
|
1770
|
+
plan.steps.map((s) => ({ node: s.nodeId, type: s.type, label: s.label ?? "" })),
|
|
1771
|
+
["node", "type", "label"]
|
|
1772
|
+
);
|
|
1773
|
+
const price = plan.estimatedCredits === null ? "not billed in credits on this edition" : `about ${plan.estimatedCredits} credits`;
|
|
1774
|
+
const reused = plan.reusedClips > 0 ? `, ${plan.reusedClips} finished clip(s) handed back at no cost` : "";
|
|
1775
|
+
success(`Retry of run ${plan.runId} (app version ${plan.appVersion ?? "?"}): ${plan.steps.length} step(s), ${price}${reused}`);
|
|
1776
|
+
if (plan.sufficient === false) {
|
|
1777
|
+
warn(
|
|
1778
|
+
plan.appCreditsAllowance !== void 0 ? "you have no app credits left to run apps: the Retry would be refused" : `your balance cannot cover it${plan.available !== null ? ` (${plan.available} available)` : ""}: the Retry would be refused`
|
|
1779
|
+
);
|
|
1780
|
+
}
|
|
1781
|
+
dim(`start it: nodaro apps run-retry ${shellQuote(slug)} ${shellQuote(runId)}${opts.appVersion !== void 0 ? ` --app-version ${opts.appVersion}` : ""}`);
|
|
1782
|
+
return;
|
|
1783
|
+
}
|
|
1784
|
+
const result = await client.apps.resume(slug, runId, { version: opts.appVersion });
|
|
1785
|
+
if (opts.json && !opts.watch) {
|
|
1786
|
+
emit(result, opts);
|
|
1787
|
+
return;
|
|
1788
|
+
}
|
|
1789
|
+
success(`execution ${result.executionId} (${result.status})${result.deduped ? " \u2014 this Retry was already started" : ""}`);
|
|
1790
|
+
if (!opts.watch) {
|
|
1791
|
+
dim(`follow: nodaro executions get ${result.executionId} --watch`);
|
|
1792
|
+
return;
|
|
1793
|
+
}
|
|
1794
|
+
await watchExecution(client, result.executionId, opts);
|
|
1795
|
+
} catch (err) {
|
|
1796
|
+
for (const line of retryRefusalAdvice(slug, runId, err)) warn(line);
|
|
1797
|
+
handleError(err);
|
|
1798
|
+
}
|
|
1799
|
+
});
|
|
1377
1800
|
return cmd;
|
|
1378
1801
|
}
|
|
1802
|
+
var BATCH_NODE_TYPE = "generate-image";
|
|
1803
|
+
function withBatchFlags(type, params, flags) {
|
|
1804
|
+
if (flags.count === void 0 && flags.models === void 0) return params;
|
|
1805
|
+
if (type !== BATCH_NODE_TYPE) {
|
|
1806
|
+
throw new Error(`--count / --models are ${BATCH_NODE_TYPE} options (several images in one call)`);
|
|
1807
|
+
}
|
|
1808
|
+
const out = { ...params };
|
|
1809
|
+
if (flags.count !== void 0) {
|
|
1810
|
+
const count = Number(flags.count);
|
|
1811
|
+
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}")`);
|
|
1812
|
+
out.count = count;
|
|
1813
|
+
}
|
|
1814
|
+
if (flags.models !== void 0) {
|
|
1815
|
+
out.models = flags.models.split(/[\s,]+/).filter(Boolean);
|
|
1816
|
+
}
|
|
1817
|
+
return out;
|
|
1818
|
+
}
|
|
1819
|
+
function batchOf(result) {
|
|
1820
|
+
const r = result;
|
|
1821
|
+
return r && Array.isArray(r.jobIds) && Array.isArray(r.groups) && typeof r.batchId === "string" ? r : null;
|
|
1822
|
+
}
|
|
1379
1823
|
async function pickNodeInteractively(client) {
|
|
1380
1824
|
if (!isInteractive()) {
|
|
1381
1825
|
warn("missing <type> and stdin is not a TTY \u2014 provide a node type or pipe input");
|
|
@@ -1445,12 +1889,15 @@ function nodesCommand() {
|
|
|
1445
1889
|
handleError(err);
|
|
1446
1890
|
}
|
|
1447
1891
|
});
|
|
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", `
|
|
1892
|
+
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
1893
|
Examples:
|
|
1450
1894
|
$ nodaro nodes run generate-image --param prompt="a snow leopard" --watch
|
|
1451
1895
|
$ nodaro nodes run generate-image --param prompt="hi" --param provider=flux --param resolution=2K --watch
|
|
1896
|
+
$ nodaro nodes run generate-image --param prompt="a snow leopard" --count 4 --watch
|
|
1897
|
+
$ nodaro nodes run generate-image --param prompt="a snow leopard" --models gpt-image-2,flux-2-max --count 2 --watch
|
|
1452
1898
|
$ echo '{"prompt":"hi","provider":"flux"}' > body.json
|
|
1453
1899
|
$ nodaro nodes run generate-image --params-file body.json --watch
|
|
1900
|
+
$ nodaro nodes run generate-image --param presetId=generate-image/logo-wordmark --param presetVariables='{"BRAND":"Acme"}' --watch
|
|
1454
1901
|
$ 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
1902
|
$ nodaro nodes run video-depth --param videoUrl=https://cdn.example/clip.mp4 --param colormap=turbo --watch
|
|
1456
1903
|
|
|
@@ -1469,13 +1916,31 @@ Tip: \`nodaro nodes get <type>\` shows the full input schema (required fields, p
|
|
|
1469
1916
|
try {
|
|
1470
1917
|
const client = buildClient(opts.profile);
|
|
1471
1918
|
const resolvedType = type ?? await pickNodeInteractively(client);
|
|
1472
|
-
const params = resolveParams(opts.param, opts.paramsFile);
|
|
1919
|
+
const params = withBatchFlags(resolvedType, resolveParams(opts.param, opts.paramsFile), opts);
|
|
1473
1920
|
const result = await client.nodes.run(resolvedType, params);
|
|
1474
1921
|
const jobId = typeof result === "object" && result && "jobId" in result ? result.jobId : null;
|
|
1475
1922
|
if (opts.json && !opts.watch) {
|
|
1476
1923
|
emit(result, opts);
|
|
1477
1924
|
return;
|
|
1478
1925
|
}
|
|
1926
|
+
const batch = batchOf(result);
|
|
1927
|
+
if (batch) {
|
|
1928
|
+
success(`${batch.jobIds.length} jobs queued (batch ${batch.batchId})${batch.deduped ? " \u2014 already created by an earlier request with this key" : ""}`);
|
|
1929
|
+
for (const group of batch.groups) {
|
|
1930
|
+
info(` ${group.model}: ${group.jobIds.join(", ")}${group.credits !== void 0 ? ` (${group.credits} credits)` : ""}`);
|
|
1931
|
+
}
|
|
1932
|
+
if (!opts.watch) {
|
|
1933
|
+
dim(`follow: nodaro jobs get <id> for each id above, or run with --watch`);
|
|
1934
|
+
return;
|
|
1935
|
+
}
|
|
1936
|
+
await watchJobsUntilTerminal({
|
|
1937
|
+
jobIds: batch.jobIds,
|
|
1938
|
+
fetchStatus: (id) => client.jobs.getStatus(id),
|
|
1939
|
+
intervalMs: opts.pollInterval,
|
|
1940
|
+
json: opts.json
|
|
1941
|
+
});
|
|
1942
|
+
return;
|
|
1943
|
+
}
|
|
1479
1944
|
if (!jobId) {
|
|
1480
1945
|
success(`${resolvedType} completed (inline)`);
|
|
1481
1946
|
detail(result);
|
|
@@ -1504,7 +1969,7 @@ function charactersCommand() {
|
|
|
1504
1969
|
const cmd = new Command("characters").description(
|
|
1505
1970
|
"list, inspect, and manage characters; trigger portrait / asset / motion generation"
|
|
1506
1971
|
);
|
|
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(
|
|
1972
|
+
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
1973
|
async (opts) => {
|
|
1509
1974
|
try {
|
|
1510
1975
|
const client = buildClient(opts.profile);
|
|
@@ -1515,6 +1980,7 @@ function charactersCommand() {
|
|
|
1515
1980
|
const result = await client.characters.list({
|
|
1516
1981
|
projectId: opts.project,
|
|
1517
1982
|
archived: opts.archived,
|
|
1983
|
+
q: opts.search ?? opts.q,
|
|
1518
1984
|
limit: limitNum
|
|
1519
1985
|
});
|
|
1520
1986
|
if (opts.json) {
|
|
@@ -1818,18 +2284,88 @@ function charactersCommand() {
|
|
|
1818
2284
|
handleError(err);
|
|
1819
2285
|
}
|
|
1820
2286
|
});
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
2287
|
+
cmd.command("train <id>").description(
|
|
2288
|
+
"train a high-fidelity model of the character on its own images (Nodaro Cloud; paid, about 15 minutes)"
|
|
2289
|
+
).option(
|
|
2290
|
+
"--image <url>",
|
|
2291
|
+
"train on this image only \u2014 repeat for each (at least 4); default: every eligible image",
|
|
2292
|
+
collectVariadic
|
|
2293
|
+
).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(
|
|
2294
|
+
async (id, opts) => {
|
|
2295
|
+
try {
|
|
2296
|
+
const client = buildClient(opts.profile);
|
|
2297
|
+
const result = await client.characters.train(
|
|
2298
|
+
id,
|
|
2299
|
+
opts.image?.length ? { selectedImageUrls: opts.image } : {}
|
|
2300
|
+
);
|
|
2301
|
+
if (opts.json && !opts.watch) {
|
|
2302
|
+
emit(result, opts);
|
|
2303
|
+
return;
|
|
2304
|
+
}
|
|
2305
|
+
success(`training started \u2014 job ${result.jobId} (trigger word ${result.triggerWord})`);
|
|
2306
|
+
if (!opts.watch) {
|
|
2307
|
+
dim(`follow: nodaro characters training ${id} --watch`);
|
|
2308
|
+
return;
|
|
2309
|
+
}
|
|
2310
|
+
await watchUntilTerminal({
|
|
2311
|
+
fetch: () => client.jobs.get(result.jobId),
|
|
2312
|
+
label: result.jobId,
|
|
2313
|
+
intervalMs: opts.pollInterval,
|
|
2314
|
+
json: opts.json
|
|
2315
|
+
});
|
|
2316
|
+
} catch (err) {
|
|
2317
|
+
handleError(err);
|
|
2318
|
+
}
|
|
2319
|
+
}
|
|
2320
|
+
);
|
|
2321
|
+
cmd.command("training <id>").description(
|
|
2322
|
+
"show where the character's training stands: untrained | queued | training | succeeded | failed | cancelled (Nodaro Cloud)"
|
|
2323
|
+
).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) => {
|
|
2324
|
+
try {
|
|
2325
|
+
const client = buildClient(opts.profile);
|
|
2326
|
+
if (opts.watch) {
|
|
2327
|
+
await watchTraining({
|
|
2328
|
+
fetch: () => client.characters.trainingStatus(id),
|
|
2329
|
+
label: id,
|
|
2330
|
+
intervalMs: opts.pollInterval,
|
|
2331
|
+
json: opts.json
|
|
2332
|
+
});
|
|
2333
|
+
return;
|
|
2334
|
+
}
|
|
2335
|
+
const result = await client.characters.trainingStatus(id);
|
|
2336
|
+
if (opts.json) emit(result, opts);
|
|
2337
|
+
else detail(result);
|
|
2338
|
+
} catch (err) {
|
|
2339
|
+
handleError(err);
|
|
2340
|
+
}
|
|
2341
|
+
});
|
|
2342
|
+
cmd.command("delete-lora <id>").description(
|
|
2343
|
+
"remove the character's trained model: cancels a training in flight (refunded) and deletes the model \u2014 cannot be undone (Nodaro Cloud)"
|
|
2344
|
+
).option("--profile <name>").option("--json").action(async (id, opts) => {
|
|
2345
|
+
try {
|
|
2346
|
+
const client = buildClient(opts.profile);
|
|
2347
|
+
await client.characters.deleteLora(id);
|
|
2348
|
+
if (opts.json) {
|
|
2349
|
+
emit({ ok: true }, opts);
|
|
2350
|
+
return;
|
|
2351
|
+
}
|
|
2352
|
+
success(`removed the trained model of character ${id}`);
|
|
2353
|
+
} catch (err) {
|
|
2354
|
+
handleError(err);
|
|
2355
|
+
}
|
|
2356
|
+
});
|
|
2357
|
+
return cmd;
|
|
2358
|
+
}
|
|
2359
|
+
function commonWizardFields(opts) {
|
|
2360
|
+
return {
|
|
2361
|
+
provider: opts.provider,
|
|
2362
|
+
style: opts.style,
|
|
2363
|
+
aspectRatio: opts.aspectRatio,
|
|
2364
|
+
duration: opts.duration,
|
|
2365
|
+
llmModel: opts.llmModel,
|
|
2366
|
+
reasoningEffort: opts.reasoningEffort,
|
|
2367
|
+
advancedMode: opts.advanced,
|
|
2368
|
+
temperature: opts.temperature,
|
|
1833
2369
|
maxTokens: opts.maxTokens
|
|
1834
2370
|
};
|
|
1835
2371
|
}
|
|
@@ -3093,6 +3629,29 @@ names).`).action(
|
|
|
3093
3629
|
}
|
|
3094
3630
|
}
|
|
3095
3631
|
);
|
|
3632
|
+
cmd.command("generate-mask <imageUrl> <prompt>").description("select a subject described in text in an image (Grounded SAM) and get a black-and-white mask image back (white = the subject)").option("--threshold <n>", `segmentation confidence ${GENERATE_MASK_LIMITS.THRESHOLD_MIN}\u2013${GENERATE_MASK_LIMITS.THRESHOLD_MAX} (default ${GENERATE_MASK_LIMITS.THRESHOLD_DEFAULT}; lower selects more)`, parseFloat).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", `
|
|
3633
|
+
Examples:
|
|
3634
|
+
$ nodaro media generate-mask https://x/portrait.png "the person" --watch
|
|
3635
|
+
$ nodaro media generate-mask https://x/landscape.jpg "sky and clouds" --threshold 0.2 --watch --json
|
|
3636
|
+
|
|
3637
|
+
The finished job's output carries \`maskUrl\` (the mask) and \`imageUrl\` (the source
|
|
3638
|
+
image, passed through unchanged): \`nodaro jobs get <jobId>\`. Use the mask for inpainting.`).action(async (imageUrl, prompt, opts) => {
|
|
3639
|
+
try {
|
|
3640
|
+
if (opts.threshold !== void 0 && !(opts.threshold >= GENERATE_MASK_LIMITS.THRESHOLD_MIN && opts.threshold <= GENERATE_MASK_LIMITS.THRESHOLD_MAX)) {
|
|
3641
|
+
warn(`--threshold must be between ${GENERATE_MASK_LIMITS.THRESHOLD_MIN} and ${GENERATE_MASK_LIMITS.THRESHOLD_MAX}`);
|
|
3642
|
+
process.exit(1);
|
|
3643
|
+
}
|
|
3644
|
+
const client = buildClient(opts.profile);
|
|
3645
|
+
const result = await client.nodes.run("generate-mask", {
|
|
3646
|
+
imageUrl,
|
|
3647
|
+
prompt,
|
|
3648
|
+
...opts.threshold !== void 0 ? { threshold: opts.threshold } : {}
|
|
3649
|
+
});
|
|
3650
|
+
await reportQueuedJob(result, () => client.jobs.get(result.jobId), { ...opts, note: "mask" });
|
|
3651
|
+
} catch (err) {
|
|
3652
|
+
handleError(err);
|
|
3653
|
+
}
|
|
3654
|
+
});
|
|
3096
3655
|
cmd.command("video-mask <videoUrl> <prompt>").description("track a subject described in text through a video (SAM 3.1, or --model sam-3 at half the price) and get a black-and-white mask video back (white = the subject)").option("--model <model>", `${VIDEO_MASK_PROVIDERS.join(" | ")} (default ${DEFAULT_VIDEO_MASK_PROVIDER})`).option("--threshold <n>", `detection confidence ${VIDEO_MASK_LIMITS.THRESHOLD_MIN}\u2013${VIDEO_MASK_LIMITS.THRESHOLD_MAX} (default ${VIDEO_MASK_LIMITS.THRESHOLD_DEFAULT}; lower finds more)`, parseFloat).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", `
|
|
3097
3656
|
Examples:
|
|
3098
3657
|
$ nodaro media video-mask https://x/dance.mp4 "the dancer" --watch
|
|
@@ -3439,19 +3998,67 @@ Example:
|
|
|
3439
3998
|
);
|
|
3440
3999
|
return cmd;
|
|
3441
4000
|
}
|
|
4001
|
+
function collect(value, previous = []) {
|
|
4002
|
+
return [...previous, value];
|
|
4003
|
+
}
|
|
4004
|
+
function readJsonFile(path) {
|
|
4005
|
+
let raw;
|
|
4006
|
+
try {
|
|
4007
|
+
raw = readFileSync(path === "-" ? 0 : path, "utf8");
|
|
4008
|
+
} catch (err) {
|
|
4009
|
+
throw new Error(`cannot read ${path}: ${err.message}`);
|
|
4010
|
+
}
|
|
4011
|
+
try {
|
|
4012
|
+
return JSON.parse(raw);
|
|
4013
|
+
} catch (err) {
|
|
4014
|
+
throw new Error(`${path} is not valid JSON: ${err.message}`);
|
|
4015
|
+
}
|
|
4016
|
+
}
|
|
4017
|
+
function presetData(opts) {
|
|
4018
|
+
if (opts.data !== void 0 && opts.dataFile !== void 0) throw new Error("pass --data or --data-file, not both");
|
|
4019
|
+
let value;
|
|
4020
|
+
if (opts.data !== void 0) {
|
|
4021
|
+
try {
|
|
4022
|
+
value = JSON.parse(opts.data);
|
|
4023
|
+
} catch (err) {
|
|
4024
|
+
throw new Error(`--data is not valid JSON: ${err.message}`);
|
|
4025
|
+
}
|
|
4026
|
+
} else if (opts.dataFile !== void 0) {
|
|
4027
|
+
value = readJsonFile(opts.dataFile);
|
|
4028
|
+
} else {
|
|
4029
|
+
return void 0;
|
|
4030
|
+
}
|
|
4031
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error("the preset data must be a JSON object");
|
|
4032
|
+
return value;
|
|
4033
|
+
}
|
|
4034
|
+
function presetsToImport(value) {
|
|
4035
|
+
if (Array.isArray(value)) return value;
|
|
4036
|
+
return parseNodePresetExport(value).presets;
|
|
4037
|
+
}
|
|
4038
|
+
function intOption(raw, flag) {
|
|
4039
|
+
if (raw === void 0) return void 0;
|
|
4040
|
+
if (!/^-?\d+$/.test(raw.trim())) throw new Error(`${flag} must be a whole number`);
|
|
4041
|
+
return Number(raw);
|
|
4042
|
+
}
|
|
4043
|
+
function groupKind(raw) {
|
|
4044
|
+
if (raw === void 0) return void 0;
|
|
4045
|
+
if (raw !== "folder" && raw !== "section") throw new Error("--kind must be folder or section");
|
|
4046
|
+
return raw;
|
|
4047
|
+
}
|
|
4048
|
+
var plural = (n, word) => `${n} ${word}${n === 1 ? "" : "s"}`;
|
|
3442
4049
|
function presetsCommand() {
|
|
3443
4050
|
const cmd = new Command("presets").description(
|
|
3444
|
-
"
|
|
4051
|
+
"node presets \u2014 your own (create, update, delete, import, favorites, folders) plus the built-in factory catalog"
|
|
3445
4052
|
);
|
|
3446
|
-
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) => {
|
|
4053
|
+
cmd.command("list").description("list your custom presets (or the built-in factory catalog with --factory, which needs no sign-in)").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 (no sign-in needed)").option("--base-url <url>", "with --factory: ask this instance instead (default: the profile's, else https://app.nodaro.ai)").option("--profile <name>").option("--json").action(async (opts) => {
|
|
3447
4054
|
try {
|
|
3448
|
-
const client = buildClient(opts.profile);
|
|
3449
4055
|
if (opts.factory) {
|
|
3450
4056
|
if (!opts.nodeType) {
|
|
3451
4057
|
handleError(new Error("--node-type is required with --factory (e.g. --node-type generate-image)"));
|
|
3452
4058
|
return;
|
|
3453
4059
|
}
|
|
3454
|
-
const
|
|
4060
|
+
const client2 = buildPublicClient({ profile: opts.profile, baseUrl: opts.baseUrl });
|
|
4061
|
+
const result = await client2.presets.listFactory(opts.nodeType);
|
|
3455
4062
|
if (opts.json) {
|
|
3456
4063
|
emit(result, opts);
|
|
3457
4064
|
return;
|
|
@@ -3460,37 +4067,115 @@ function presetsCommand() {
|
|
|
3460
4067
|
result.data.map((p) => ({
|
|
3461
4068
|
id: p.id,
|
|
3462
4069
|
name: p.name,
|
|
3463
|
-
group: p.group ?? ""
|
|
4070
|
+
group: p.group ?? "",
|
|
4071
|
+
photos: p.minReferences ? p.minReferences : "",
|
|
4072
|
+
preview: p.previewUrl ? "yes" : ""
|
|
3464
4073
|
})),
|
|
3465
|
-
["id", "name", "group"]
|
|
4074
|
+
["id", "name", "group", "photos", "preview"]
|
|
3466
4075
|
);
|
|
3467
4076
|
return;
|
|
3468
4077
|
}
|
|
4078
|
+
if (opts.baseUrl !== void 0) {
|
|
4079
|
+
throw new Error("--base-url only applies with --factory; your own presets come from the profile's instance");
|
|
4080
|
+
}
|
|
4081
|
+
const client = buildClient(opts.profile);
|
|
3469
4082
|
const presets = await client.presets.list(opts.nodeType);
|
|
3470
4083
|
if (opts.json) {
|
|
3471
4084
|
emit(presets, opts);
|
|
3472
4085
|
return;
|
|
3473
4086
|
}
|
|
3474
4087
|
table(
|
|
3475
|
-
presets.map((p) => ({
|
|
3476
|
-
|
|
4088
|
+
presets.map((p) => ({
|
|
4089
|
+
id: p.id,
|
|
4090
|
+
nodeType: p.nodeType,
|
|
4091
|
+
name: p.name,
|
|
4092
|
+
photos: p.minReferences ? p.minReferences : "",
|
|
4093
|
+
updatedAt: p.updatedAt
|
|
4094
|
+
})),
|
|
4095
|
+
["id", "nodeType", "name", "photos", "updatedAt"]
|
|
4096
|
+
);
|
|
4097
|
+
} catch (err) {
|
|
4098
|
+
handleError(err);
|
|
4099
|
+
}
|
|
4100
|
+
});
|
|
4101
|
+
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(
|
|
4102
|
+
async (opts) => {
|
|
4103
|
+
try {
|
|
4104
|
+
const data = presetData(opts);
|
|
4105
|
+
if (!data) throw new Error("pass the preset's node config with --data or --data-file");
|
|
4106
|
+
const preset = await buildClient(opts.profile).presets.create({
|
|
4107
|
+
nodeType: opts.nodeType,
|
|
4108
|
+
name: opts.name,
|
|
4109
|
+
data,
|
|
4110
|
+
...opts.description !== void 0 ? { description: opts.description } : {},
|
|
4111
|
+
...opts.group !== void 0 ? { groupId: opts.group } : {},
|
|
4112
|
+
...opts.tag !== void 0 ? { tags: opts.tag } : {},
|
|
4113
|
+
...opts.previewUrl !== void 0 ? { previewUrl: opts.previewUrl } : {}
|
|
4114
|
+
});
|
|
4115
|
+
if (opts.json) {
|
|
4116
|
+
emit(preset, opts);
|
|
4117
|
+
return;
|
|
4118
|
+
}
|
|
4119
|
+
success(`created preset ${preset.name} (${preset.id})`);
|
|
4120
|
+
} catch (err) {
|
|
4121
|
+
handleError(err);
|
|
4122
|
+
}
|
|
4123
|
+
}
|
|
4124
|
+
);
|
|
4125
|
+
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(
|
|
4126
|
+
async (id, opts) => {
|
|
4127
|
+
try {
|
|
4128
|
+
const data = presetData(opts);
|
|
4129
|
+
const patch = {
|
|
4130
|
+
...opts.name !== void 0 ? { name: opts.name } : {},
|
|
4131
|
+
...opts.description !== void 0 ? { description: opts.description } : {},
|
|
4132
|
+
...data !== void 0 ? { data } : {},
|
|
4133
|
+
...opts.group !== void 0 ? { groupId: opts.group === false ? null : opts.group } : {},
|
|
4134
|
+
...opts.tag !== void 0 ? { tags: opts.tag } : {},
|
|
4135
|
+
...opts.previewUrl !== void 0 ? { previewUrl: opts.previewUrl === false ? null : opts.previewUrl } : {}
|
|
4136
|
+
};
|
|
4137
|
+
if (Object.keys(patch).length === 0) {
|
|
4138
|
+
throw new Error("nothing to update \u2014 pass --name, --description, --data, --group, --tag or --preview-url");
|
|
4139
|
+
}
|
|
4140
|
+
const preset = await buildClient(opts.profile).presets.update(
|
|
4141
|
+
id,
|
|
4142
|
+
patch,
|
|
4143
|
+
opts.expectedUpdatedAt ? { expectedUpdatedAt: opts.expectedUpdatedAt } : {}
|
|
4144
|
+
);
|
|
4145
|
+
if (opts.json) {
|
|
4146
|
+
emit(preset, opts);
|
|
4147
|
+
return;
|
|
4148
|
+
}
|
|
4149
|
+
success(`updated preset ${preset.name} (${preset.id})`);
|
|
4150
|
+
} catch (err) {
|
|
4151
|
+
handleError(err);
|
|
4152
|
+
}
|
|
4153
|
+
}
|
|
4154
|
+
);
|
|
4155
|
+
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) => {
|
|
4156
|
+
try {
|
|
4157
|
+
const result = await buildClient(opts.profile).presets.delete(
|
|
4158
|
+
id,
|
|
4159
|
+
opts.expectedUpdatedAt ? { expectedUpdatedAt: opts.expectedUpdatedAt } : {}
|
|
3477
4160
|
);
|
|
4161
|
+
if (opts.json) {
|
|
4162
|
+
emit(result, opts);
|
|
4163
|
+
return;
|
|
4164
|
+
}
|
|
4165
|
+
success(`deleted preset ${id}`);
|
|
3478
4166
|
} catch (err) {
|
|
3479
4167
|
handleError(err);
|
|
3480
4168
|
}
|
|
3481
4169
|
});
|
|
3482
|
-
cmd.command("
|
|
4170
|
+
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
4171
|
try {
|
|
3484
|
-
const
|
|
3485
|
-
const
|
|
4172
|
+
const presets = presetsToImport(readJsonFile(path));
|
|
4173
|
+
const result = await buildClient(opts.profile).presets.import(presets);
|
|
3486
4174
|
if (opts.json) {
|
|
3487
|
-
emit(
|
|
4175
|
+
emit(result, opts);
|
|
3488
4176
|
return;
|
|
3489
4177
|
}
|
|
3490
|
-
|
|
3491
|
-
groups.map((g) => ({ id: g.id, nodeType: g.nodeType, name: g.name, kind: g.kind })),
|
|
3492
|
-
["id", "nodeType", "name", "kind"]
|
|
3493
|
-
);
|
|
4178
|
+
success(`imported ${plural(result.imported, "preset")}`);
|
|
3494
4179
|
} catch (err) {
|
|
3495
4180
|
handleError(err);
|
|
3496
4181
|
}
|
|
@@ -3513,7 +4198,7 @@ function presetsCommand() {
|
|
|
3513
4198
|
const json = JSON.stringify(envelope, null, 2);
|
|
3514
4199
|
if (opts.output) {
|
|
3515
4200
|
writeFileSync(opts.output, json);
|
|
3516
|
-
success(`exported ${presets.length
|
|
4201
|
+
success(`exported ${plural(presets.length, "preset")} to ${opts.output}`);
|
|
3517
4202
|
} else {
|
|
3518
4203
|
process.stdout.write(`${json}
|
|
3519
4204
|
`);
|
|
@@ -3522,6 +4207,111 @@ function presetsCommand() {
|
|
|
3522
4207
|
handleError(err);
|
|
3523
4208
|
}
|
|
3524
4209
|
});
|
|
4210
|
+
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) => {
|
|
4211
|
+
try {
|
|
4212
|
+
const ids = await buildClient(opts.profile).presets.favorites(opts.nodeType);
|
|
4213
|
+
if (opts.json) {
|
|
4214
|
+
emit(ids, opts);
|
|
4215
|
+
return;
|
|
4216
|
+
}
|
|
4217
|
+
table(ids.map((presetId) => ({ presetId })), ["presetId"]);
|
|
4218
|
+
} catch (err) {
|
|
4219
|
+
handleError(err);
|
|
4220
|
+
}
|
|
4221
|
+
});
|
|
4222
|
+
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) => {
|
|
4223
|
+
try {
|
|
4224
|
+
const result = await buildClient(opts.profile).presets.addFavorite({ nodeType: opts.nodeType, presetId });
|
|
4225
|
+
if (opts.json) {
|
|
4226
|
+
emit(result, opts);
|
|
4227
|
+
return;
|
|
4228
|
+
}
|
|
4229
|
+
success(`added ${presetId} to your favorites`);
|
|
4230
|
+
} catch (err) {
|
|
4231
|
+
handleError(err);
|
|
4232
|
+
}
|
|
4233
|
+
});
|
|
4234
|
+
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) => {
|
|
4235
|
+
try {
|
|
4236
|
+
const result = await buildClient(opts.profile).presets.removeFavorite({ nodeType: opts.nodeType, presetId });
|
|
4237
|
+
if (opts.json) {
|
|
4238
|
+
emit(result, opts);
|
|
4239
|
+
return;
|
|
4240
|
+
}
|
|
4241
|
+
success(`removed ${presetId} from your favorites`);
|
|
4242
|
+
} catch (err) {
|
|
4243
|
+
handleError(err);
|
|
4244
|
+
}
|
|
4245
|
+
});
|
|
4246
|
+
cmd.addCommand(groupsCommand());
|
|
4247
|
+
return cmd;
|
|
4248
|
+
}
|
|
4249
|
+
function groupsCommand() {
|
|
4250
|
+
const cmd = new Command("groups").description("your preset folders and sections: list (default), create, update, delete");
|
|
4251
|
+
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) => {
|
|
4252
|
+
try {
|
|
4253
|
+
const client = buildClient(opts.profile);
|
|
4254
|
+
const groups = await client.presets.listGroups(opts.nodeType);
|
|
4255
|
+
if (opts.json) {
|
|
4256
|
+
emit(groups, opts);
|
|
4257
|
+
return;
|
|
4258
|
+
}
|
|
4259
|
+
table(
|
|
4260
|
+
groups.map((g) => ({ id: g.id, nodeType: g.nodeType, name: g.name, kind: g.kind })),
|
|
4261
|
+
["id", "nodeType", "name", "kind"]
|
|
4262
|
+
);
|
|
4263
|
+
} catch (err) {
|
|
4264
|
+
handleError(err);
|
|
4265
|
+
}
|
|
4266
|
+
});
|
|
4267
|
+
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) => {
|
|
4268
|
+
try {
|
|
4269
|
+
const kind = groupKind(opts.kind);
|
|
4270
|
+
const sortOrder = intOption(opts.sortOrder, "--sort-order");
|
|
4271
|
+
const group = await buildClient(opts.profile).presets.createGroup({
|
|
4272
|
+
nodeType: opts.nodeType,
|
|
4273
|
+
name: opts.name,
|
|
4274
|
+
...kind !== void 0 ? { kind } : {},
|
|
4275
|
+
...sortOrder !== void 0 ? { sortOrder } : {}
|
|
4276
|
+
});
|
|
4277
|
+
if (opts.json) {
|
|
4278
|
+
emit(group, opts);
|
|
4279
|
+
return;
|
|
4280
|
+
}
|
|
4281
|
+
success(`created ${group.kind} ${group.name} (${group.id})`);
|
|
4282
|
+
} catch (err) {
|
|
4283
|
+
handleError(err);
|
|
4284
|
+
}
|
|
4285
|
+
});
|
|
4286
|
+
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) => {
|
|
4287
|
+
try {
|
|
4288
|
+
const sortOrder = intOption(opts.sortOrder, "--sort-order");
|
|
4289
|
+
if (opts.name === void 0 && sortOrder === void 0) throw new Error("nothing to update \u2014 pass --name or --sort-order");
|
|
4290
|
+
const group = await buildClient(opts.profile).presets.updateGroup(id, {
|
|
4291
|
+
...opts.name !== void 0 ? { name: opts.name } : {},
|
|
4292
|
+
...sortOrder !== void 0 ? { sortOrder } : {}
|
|
4293
|
+
});
|
|
4294
|
+
if (opts.json) {
|
|
4295
|
+
emit(group, opts);
|
|
4296
|
+
return;
|
|
4297
|
+
}
|
|
4298
|
+
success(`updated ${group.kind} ${group.name} (${group.id})`);
|
|
4299
|
+
} catch (err) {
|
|
4300
|
+
handleError(err);
|
|
4301
|
+
}
|
|
4302
|
+
});
|
|
4303
|
+
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) => {
|
|
4304
|
+
try {
|
|
4305
|
+
const result = await buildClient(opts.profile).presets.deleteGroup(id);
|
|
4306
|
+
if (opts.json) {
|
|
4307
|
+
emit(result, opts);
|
|
4308
|
+
return;
|
|
4309
|
+
}
|
|
4310
|
+
success(`deleted preset group ${id}`);
|
|
4311
|
+
} catch (err) {
|
|
4312
|
+
handleError(err);
|
|
4313
|
+
}
|
|
4314
|
+
});
|
|
3525
4315
|
return cmd;
|
|
3526
4316
|
}
|
|
3527
4317
|
function postFromJson(value, index2 = 0) {
|
|
@@ -3874,38 +4664,217 @@ function collectionsCommand() {
|
|
|
3874
4664
|
});
|
|
3875
4665
|
return cmd;
|
|
3876
4666
|
}
|
|
3877
|
-
function
|
|
3878
|
-
|
|
3879
|
-
["tiktok", flags.tiktok],
|
|
3880
|
-
["instagram", flags.instagram],
|
|
3881
|
-
["youtube", flags.youtube],
|
|
3882
|
-
["x", flags.x],
|
|
3883
|
-
["linkedin", flags.linkedin],
|
|
3884
|
-
["meta_ads", flags.metaAds]
|
|
3885
|
-
];
|
|
3886
|
-
return Object.fromEntries(pairs.filter(([, v]) => v !== void 0 && v.trim() !== ""));
|
|
3887
|
-
}
|
|
3888
|
-
function parseClear(raw) {
|
|
3889
|
-
if (raw === void 0) return [];
|
|
3890
|
-
const wanted = raw.split(",").map((p) => p.trim().replace(/-/g, "_")).filter(Boolean);
|
|
3891
|
-
const bad = wanted.filter((p) => !COMPETITOR_ACCOUNT_KEYS.includes(p));
|
|
3892
|
-
if (bad.length > 0) throw new Error(`--clear takes ${COMPETITOR_ACCOUNT_KEYS.join(", ")} (got ${bad.join(", ")})`);
|
|
3893
|
-
return wanted;
|
|
4667
|
+
function colorList(value) {
|
|
4668
|
+
return value.split(/[\s,]+/).filter(Boolean);
|
|
3894
4669
|
}
|
|
3895
|
-
function
|
|
3896
|
-
const
|
|
3897
|
-
|
|
3898
|
-
const merged = { ...current, ...set };
|
|
3899
|
-
return Object.fromEntries(
|
|
3900
|
-
Object.entries(merged).filter(([key2, value]) => !clear.includes(key2) && typeof value === "string" && value.trim() !== "")
|
|
4670
|
+
function palettesCommand() {
|
|
4671
|
+
const cmd = new Command("palettes").description(
|
|
4672
|
+
'your colour palettes \u2014 use one on generate-image as direction.colorLook "palette:<id>"'
|
|
3901
4673
|
);
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
4674
|
+
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) => {
|
|
4675
|
+
try {
|
|
4676
|
+
const page = await buildClient(opts.profile).palettes.list({
|
|
4677
|
+
limit: opts.limit ? Number(opts.limit) : void 0,
|
|
4678
|
+
cursor: opts.cursor
|
|
4679
|
+
});
|
|
4680
|
+
if (opts.json) {
|
|
4681
|
+
emit(page, opts);
|
|
4682
|
+
return;
|
|
4683
|
+
}
|
|
4684
|
+
table(
|
|
4685
|
+
page.data.map((p) => ({ id: p.id, name: p.name, colors: p.colors.join(" "), updatedAt: p.updatedAt })),
|
|
4686
|
+
["id", "name", "colors", "updatedAt"]
|
|
4687
|
+
);
|
|
4688
|
+
if (page.nextCursor) dim(`next: --cursor ${page.nextCursor}`);
|
|
4689
|
+
} catch (err) {
|
|
4690
|
+
handleError(err);
|
|
4691
|
+
}
|
|
4692
|
+
});
|
|
4693
|
+
cmd.command("get <id>").description("show one palette").option("--profile <name>").option("--json").action(async (id, opts) => {
|
|
4694
|
+
try {
|
|
4695
|
+
const palette = await buildClient(opts.profile).palettes.get(id);
|
|
4696
|
+
if (opts.json) emit(palette, opts);
|
|
4697
|
+
else detail(palette);
|
|
4698
|
+
} catch (err) {
|
|
4699
|
+
handleError(err);
|
|
4700
|
+
}
|
|
4701
|
+
});
|
|
4702
|
+
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) => {
|
|
4703
|
+
try {
|
|
4704
|
+
const palette = await buildClient(opts.profile).palettes.create({
|
|
4705
|
+
name: opts.name,
|
|
4706
|
+
colors: [].concat(opts.colors).flatMap(colorList),
|
|
4707
|
+
...opts.description !== void 0 ? { description: opts.description } : {}
|
|
4708
|
+
});
|
|
4709
|
+
if (opts.json) {
|
|
4710
|
+
emit(palette, opts);
|
|
4711
|
+
return;
|
|
4712
|
+
}
|
|
4713
|
+
success(`created palette ${palette.id} \u2014 use it as direction.colorLook "palette:${palette.id}"`);
|
|
4714
|
+
} catch (err) {
|
|
4715
|
+
handleError(err);
|
|
4716
|
+
}
|
|
4717
|
+
});
|
|
4718
|
+
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(
|
|
4719
|
+
async (id, opts) => {
|
|
4720
|
+
try {
|
|
4721
|
+
const input2 = {
|
|
4722
|
+
...opts.name !== void 0 ? { name: opts.name } : {},
|
|
4723
|
+
...opts.colors !== void 0 ? { colors: [].concat(opts.colors).flatMap(colorList) } : {},
|
|
4724
|
+
...opts.clearDescription ? { description: null } : opts.description !== void 0 ? { description: opts.description } : {}
|
|
4725
|
+
};
|
|
4726
|
+
if (Object.keys(input2).length === 0) {
|
|
4727
|
+
throw new Error("nothing to update \u2014 provide --name, --colors, --description or --clear-description");
|
|
4728
|
+
}
|
|
4729
|
+
const palette = await buildClient(opts.profile).palettes.update(id, input2);
|
|
4730
|
+
if (opts.json) {
|
|
4731
|
+
emit(palette, opts);
|
|
4732
|
+
return;
|
|
4733
|
+
}
|
|
4734
|
+
success(`updated palette ${palette.id}`);
|
|
4735
|
+
} catch (err) {
|
|
4736
|
+
handleError(err);
|
|
4737
|
+
}
|
|
4738
|
+
}
|
|
4739
|
+
);
|
|
4740
|
+
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) => {
|
|
4741
|
+
try {
|
|
4742
|
+
await buildClient(opts.profile).palettes.delete(id);
|
|
4743
|
+
if (opts.json) {
|
|
4744
|
+
emit({ success: true, id }, opts);
|
|
4745
|
+
return;
|
|
4746
|
+
}
|
|
4747
|
+
success(`deleted palette ${id}`);
|
|
4748
|
+
} catch (err) {
|
|
4749
|
+
handleError(err);
|
|
4750
|
+
}
|
|
4751
|
+
});
|
|
4752
|
+
return cmd;
|
|
4753
|
+
}
|
|
4754
|
+
function imageOf(value) {
|
|
4755
|
+
const bar = value.indexOf("|");
|
|
4756
|
+
if (bar === -1) return { url: value.trim() };
|
|
4757
|
+
const url = value.slice(0, bar).trim();
|
|
4758
|
+
const caption = value.slice(bar + 1).trim();
|
|
4759
|
+
return caption ? { url, caption } : { url };
|
|
4760
|
+
}
|
|
4761
|
+
function moodboardsCommand() {
|
|
4762
|
+
const cmd = new Command("moodboards").description(
|
|
4763
|
+
'your moodboards \u2014 use one on generate-image as direction.style "moodboard:<id>" (its description joins the prompt, its images go as style references)'
|
|
4764
|
+
);
|
|
4765
|
+
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) => {
|
|
4766
|
+
try {
|
|
4767
|
+
const page = await buildClient(opts.profile).moodboards.list({
|
|
4768
|
+
limit: opts.limit ? Number(opts.limit) : void 0,
|
|
4769
|
+
cursor: opts.cursor
|
|
4770
|
+
});
|
|
4771
|
+
if (opts.json) {
|
|
4772
|
+
emit(page, opts);
|
|
4773
|
+
return;
|
|
4774
|
+
}
|
|
4775
|
+
table(
|
|
4776
|
+
page.data.map((m) => ({ id: m.id, name: m.name, images: m.images.length, updatedAt: m.updatedAt })),
|
|
4777
|
+
["id", "name", "images", "updatedAt"]
|
|
4778
|
+
);
|
|
4779
|
+
if (page.nextCursor) dim(`next: --cursor ${page.nextCursor}`);
|
|
4780
|
+
} catch (err) {
|
|
4781
|
+
handleError(err);
|
|
4782
|
+
}
|
|
4783
|
+
});
|
|
4784
|
+
cmd.command("get <id>").description("show one moodboard with its images").option("--profile <name>").option("--json").action(async (id, opts) => {
|
|
4785
|
+
try {
|
|
4786
|
+
const board = await buildClient(opts.profile).moodboards.get(id);
|
|
4787
|
+
if (opts.json) emit(board, opts);
|
|
4788
|
+
else detail(board);
|
|
4789
|
+
} catch (err) {
|
|
4790
|
+
handleError(err);
|
|
4791
|
+
}
|
|
4792
|
+
});
|
|
4793
|
+
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) => {
|
|
4794
|
+
try {
|
|
4795
|
+
if (!opts.image || opts.image.length === 0) throw new Error("a moodboard needs at least one --image");
|
|
4796
|
+
const board = await buildClient(opts.profile).moodboards.create({
|
|
4797
|
+
name: opts.name,
|
|
4798
|
+
...opts.description !== void 0 ? { description: opts.description } : {},
|
|
4799
|
+
images: opts.image.map(imageOf)
|
|
4800
|
+
});
|
|
4801
|
+
if (opts.json) {
|
|
4802
|
+
emit(board, opts);
|
|
4803
|
+
return;
|
|
4804
|
+
}
|
|
4805
|
+
success(`created moodboard ${board.id} \u2014 use it as direction.style "moodboard:${board.id}"`);
|
|
4806
|
+
} catch (err) {
|
|
4807
|
+
handleError(err);
|
|
4808
|
+
}
|
|
4809
|
+
});
|
|
4810
|
+
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(
|
|
4811
|
+
async (id, opts) => {
|
|
4812
|
+
try {
|
|
4813
|
+
const input2 = {
|
|
4814
|
+
...opts.name !== void 0 ? { name: opts.name } : {},
|
|
4815
|
+
...opts.clearDescription ? { description: null } : opts.description !== void 0 ? { description: opts.description } : {},
|
|
4816
|
+
...opts.image && opts.image.length > 0 ? { images: opts.image.map(imageOf) } : {}
|
|
4817
|
+
};
|
|
4818
|
+
if (Object.keys(input2).length === 0) {
|
|
4819
|
+
throw new Error("nothing to update \u2014 provide --name, --description, --clear-description or --image");
|
|
4820
|
+
}
|
|
4821
|
+
const board = await buildClient(opts.profile).moodboards.update(id, input2);
|
|
4822
|
+
if (opts.json) {
|
|
4823
|
+
emit(board, opts);
|
|
4824
|
+
return;
|
|
4825
|
+
}
|
|
4826
|
+
success(`updated moodboard ${board.id}`);
|
|
4827
|
+
} catch (err) {
|
|
4828
|
+
handleError(err);
|
|
4829
|
+
}
|
|
4830
|
+
}
|
|
4831
|
+
);
|
|
4832
|
+
cmd.command("delete <id>").description("delete a moodboard (the images it links to are untouched)").option("--profile <name>").option("--json").action(async (id, opts) => {
|
|
4833
|
+
try {
|
|
4834
|
+
await buildClient(opts.profile).moodboards.delete(id);
|
|
4835
|
+
if (opts.json) {
|
|
4836
|
+
emit({ success: true, id }, opts);
|
|
4837
|
+
return;
|
|
4838
|
+
}
|
|
4839
|
+
success(`deleted moodboard ${id}`);
|
|
4840
|
+
} catch (err) {
|
|
4841
|
+
handleError(err);
|
|
4842
|
+
}
|
|
4843
|
+
});
|
|
4844
|
+
return cmd;
|
|
4845
|
+
}
|
|
4846
|
+
function accountsFromFlags(flags) {
|
|
4847
|
+
const pairs = [
|
|
4848
|
+
["tiktok", flags.tiktok],
|
|
4849
|
+
["instagram", flags.instagram],
|
|
4850
|
+
["youtube", flags.youtube],
|
|
4851
|
+
["x", flags.x],
|
|
4852
|
+
["linkedin", flags.linkedin],
|
|
4853
|
+
["meta_ads", flags.metaAds]
|
|
4854
|
+
];
|
|
4855
|
+
return Object.fromEntries(pairs.filter(([, v]) => v !== void 0 && v.trim() !== ""));
|
|
4856
|
+
}
|
|
4857
|
+
function parseClear(raw) {
|
|
4858
|
+
if (raw === void 0) return [];
|
|
4859
|
+
const wanted = raw.split(",").map((p) => p.trim().replace(/-/g, "_")).filter(Boolean);
|
|
4860
|
+
const bad = wanted.filter((p) => !COMPETITOR_ACCOUNT_KEYS.includes(p));
|
|
4861
|
+
if (bad.length > 0) throw new Error(`--clear takes ${COMPETITOR_ACCOUNT_KEYS.join(", ")} (got ${bad.join(", ")})`);
|
|
4862
|
+
return wanted;
|
|
4863
|
+
}
|
|
4864
|
+
function mergeAccounts(current, set, clear) {
|
|
4865
|
+
const both = clear.filter((key2) => set[key2] !== void 0);
|
|
4866
|
+
if (both.length > 0) throw new Error(`cannot both set and clear ${both.join(", ")}`);
|
|
4867
|
+
const merged = { ...current, ...set };
|
|
4868
|
+
return Object.fromEntries(
|
|
4869
|
+
Object.entries(merged).filter(([key2, value]) => !clear.includes(key2) && typeof value === "string" && value.trim() !== "")
|
|
4870
|
+
);
|
|
4871
|
+
}
|
|
4872
|
+
function parseAbout(raw) {
|
|
4873
|
+
if (raw === void 0) return void 0;
|
|
4874
|
+
const wanted = raw.split(",").map((p) => p.trim()).filter(Boolean);
|
|
4875
|
+
const bad = wanted.filter((p) => !COMPETITOR_ABOUT_PLATFORMS.includes(p));
|
|
4876
|
+
if (bad.length > 0) throw new Error(`--about takes ${COMPETITOR_ABOUT_PLATFORMS.join(", ")} (got ${bad.join(", ")})`);
|
|
4877
|
+
return wanted;
|
|
3909
4878
|
}
|
|
3910
4879
|
function parseSchedule(raw) {
|
|
3911
4880
|
if (raw === void 0) return void 0;
|
|
@@ -3957,8 +4926,8 @@ function outcomeLine(o) {
|
|
|
3957
4926
|
function recordLines(record) {
|
|
3958
4927
|
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
4928
|
}
|
|
3960
|
-
function rows(
|
|
3961
|
-
return
|
|
4929
|
+
function rows(list2) {
|
|
4930
|
+
return list2.map((c) => ({
|
|
3962
4931
|
id: c.id,
|
|
3963
4932
|
brand: c.isOwn ? `${c.brand} (yours)` : c.brand,
|
|
3964
4933
|
searches: c.searches,
|
|
@@ -3971,9 +4940,9 @@ function competitorsCommand() {
|
|
|
3971
4940
|
const cmd = new Command("competitors").description("brands you track (competitors or your own), their scans and action cards (Nodaro Cloud)");
|
|
3972
4941
|
cmd.command("list").description("list tracked brands").option("--profile <name>").option("--json").action(async (opts) => {
|
|
3973
4942
|
try {
|
|
3974
|
-
const
|
|
3975
|
-
if (opts.json) return emit(
|
|
3976
|
-
table(rows(
|
|
4943
|
+
const list2 = await buildClient(opts.profile).competitors.list();
|
|
4944
|
+
if (opts.json) return emit(list2, opts);
|
|
4945
|
+
table(rows(list2), ["id", "brand", "searches", "schedule", "lastScan", "note"]);
|
|
3977
4946
|
} catch (err) {
|
|
3978
4947
|
handleError(err);
|
|
3979
4948
|
}
|
|
@@ -4602,7 +5571,7 @@ function catalogCommand() {
|
|
|
4602
5571
|
}
|
|
4603
5572
|
function modelsCommand() {
|
|
4604
5573
|
const cmd = new Command("models").description(
|
|
4605
|
-
"browse the model catalog \u2014 capability sheets, per-variant credit pricing, prompt tips"
|
|
5574
|
+
"browse the model catalog \u2014 makers, capability sheets, per-variant credit pricing, prompt tips"
|
|
4606
5575
|
);
|
|
4607
5576
|
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
5577
|
"after",
|
|
@@ -4630,6 +5599,9 @@ Examples:
|
|
|
4630
5599
|
id: m.id,
|
|
4631
5600
|
kind: section.kind,
|
|
4632
5601
|
family: group.family,
|
|
5602
|
+
// The company behind the model (a family can name a lab or a
|
|
5603
|
+
// product line); an older server sends none.
|
|
5604
|
+
maker: m.maker?.name ?? "-",
|
|
4633
5605
|
modes: m.modes.join(","),
|
|
4634
5606
|
credits: (m.pricing ?? []).map((p) => p.credits).join("/") || "-",
|
|
4635
5607
|
featured: m.featured ? "\u2605" : "",
|
|
@@ -4637,7 +5609,7 @@ Examples:
|
|
|
4637
5609
|
}))
|
|
4638
5610
|
)
|
|
4639
5611
|
);
|
|
4640
|
-
table(rows2, ["id", "kind", "family", "modes", "credits", "featured", "doctrine"]);
|
|
5612
|
+
table(rows2, ["id", "kind", "family", "maker", "modes", "credits", "featured", "doctrine"]);
|
|
4641
5613
|
} catch (err) {
|
|
4642
5614
|
handleError(err);
|
|
4643
5615
|
}
|
|
@@ -4860,11 +5832,11 @@ function locationsCommand() {
|
|
|
4860
5832
|
const cmd = new Command("locations").description(
|
|
4861
5833
|
"list, inspect, and manage locations; trigger main-image / asset generation"
|
|
4862
5834
|
);
|
|
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(
|
|
5835
|
+
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
5836
|
async (opts) => {
|
|
4865
5837
|
try {
|
|
4866
5838
|
const client = buildClient(opts.profile);
|
|
4867
|
-
const result = await client.locations.list({ archived: opts.archived });
|
|
5839
|
+
const result = await client.locations.list({ archived: opts.archived, q: opts.search ?? opts.q });
|
|
4868
5840
|
if (opts.json) {
|
|
4869
5841
|
emit(result.locations, opts);
|
|
4870
5842
|
return;
|
|
@@ -5198,13 +6170,14 @@ function objectsCommand() {
|
|
|
5198
6170
|
const cmd = new Command("objects").description(
|
|
5199
6171
|
"list, inspect, and manage objects; trigger main-image / asset generation"
|
|
5200
6172
|
);
|
|
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(
|
|
6173
|
+
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
6174
|
async (opts) => {
|
|
5203
6175
|
try {
|
|
5204
6176
|
const client = buildClient(opts.profile);
|
|
5205
6177
|
const result = await client.objects.list({
|
|
5206
6178
|
archived: opts.archived,
|
|
5207
|
-
projectId: opts.project
|
|
6179
|
+
projectId: opts.project,
|
|
6180
|
+
q: opts.search ?? opts.q
|
|
5208
6181
|
});
|
|
5209
6182
|
if (opts.json) {
|
|
5210
6183
|
emit(result.objects, opts);
|
|
@@ -5967,15 +6940,7 @@ var SOURCE_LABELS = {
|
|
|
5967
6940
|
profile: "the profile's saved workspace",
|
|
5968
6941
|
none: "nothing \u2014 the personal space"
|
|
5969
6942
|
};
|
|
5970
|
-
function
|
|
5971
|
-
return EDIT_PLAN_MODES.includes(v);
|
|
5972
|
-
}
|
|
5973
|
-
var CONTINUATION_NEXT_STEP = {
|
|
5974
|
-
already_running: (id) => ` \u2014 follow it: nodaro jobs get ${id}`,
|
|
5975
|
-
continuation_superseded: (id) => ` \u2014 continue that one: nodaro edit continue-use-case ${id} --mode from-failed`,
|
|
5976
|
-
render_final_already_rendered: (id) => ` \u2014 its result is the one to use: nodaro jobs get ${id}`
|
|
5977
|
-
};
|
|
5978
|
-
function readJsonFile(path) {
|
|
6943
|
+
function readJsonFile2(path) {
|
|
5979
6944
|
let raw;
|
|
5980
6945
|
try {
|
|
5981
6946
|
raw = readFileSync(path, "utf8");
|
|
@@ -5988,173 +6953,241 @@ function readJsonFile(path) {
|
|
|
5988
6953
|
throw new Error(`${path} is not valid JSON: ${err.message}`);
|
|
5989
6954
|
}
|
|
5990
6955
|
}
|
|
5991
|
-
function
|
|
5992
|
-
|
|
5993
|
-
|
|
5994
|
-
|
|
5995
|
-
const at = rest.lastIndexOf("@");
|
|
5996
|
-
if (at > 0) {
|
|
5997
|
-
const suffix = rest.slice(at + 1);
|
|
5998
|
-
if (suffix === "audio" || suffix === "video") {
|
|
5999
|
-
return { id, url: rest.slice(0, at), kind: suffix };
|
|
6000
|
-
}
|
|
6956
|
+
function refuseUnknownPlanTier(planTier) {
|
|
6957
|
+
if (planTier !== void 0 && !EDIT_PLAN_TIERS.includes(planTier)) {
|
|
6958
|
+
warn(`--plan-tier must be ${EDIT_PLAN_TIERS.join(", ")} (got "${planTier}")`);
|
|
6959
|
+
process.exit(1);
|
|
6001
6960
|
}
|
|
6002
|
-
return { id, url: rest, kind: "video" };
|
|
6003
|
-
}
|
|
6004
|
-
function parseAudioSyncSource(spec, index2) {
|
|
6005
|
-
const named = /^([^=\s]{1,200})=(https?:\/\/.+)$/.exec(spec);
|
|
6006
|
-
return named ? { id: named[1], url: named[2] } : { id: `source-${index2 + 1}`, url: spec };
|
|
6007
6961
|
}
|
|
6008
|
-
|
|
6009
|
-
|
|
6010
|
-
|
|
6011
|
-
)
|
|
6012
|
-
|
|
6013
|
-
|
|
6962
|
+
var EMPHASIS_HELP = `none, or ${SPEAKER_EMPHASIS_STYLES.filter((s) => s !== "none").join(", ")} joined with "+" (each once)`;
|
|
6963
|
+
var CONTINUATION_NEXT_STEP = {
|
|
6964
|
+
already_running: (id) => ` \u2014 follow it: nodaro jobs get ${id}`,
|
|
6965
|
+
continuation_superseded: (id) => ` \u2014 continue that one: nodaro edit continue-use-case ${id} --mode from-failed`,
|
|
6966
|
+
render_final_already_rendered: (id) => ` \u2014 its result is the one to use: nodaro jobs get ${id}`
|
|
6967
|
+
};
|
|
6968
|
+
function registerUseCaseCommands(cmd) {
|
|
6969
|
+
const framingLayouts = ["auto", ...SPEAKER_LAYOUT_IDS];
|
|
6970
|
+
cmd.command("tighten-episode").description("tighten a podcast recording in one step (transcribe, cut silences, render; optional captions, music and framing)").requiredOption("--media <url>", "the recording (video or audio URL, up to 3 hours)").option("--music <url>", "optional music bed, ducked under the voice").option("--output <kind>", "video | audio (an audio recording always makes an audio episode)").option("--framing <aspect>", `frame a video episode on its speakers: ${EDL_TARGET_ASPECTS.join(" | ")}`).option("--layout <layout>", `layout with --framing (default auto): ${framingLayouts.join(" | ")}`).option("--no-captions", "no captions on a video episode").option("--review", "stop at a preview to review (render the final with `nodaro edit continue-use-case <jobId> --mode render-final`)").option("--plan-tier <tier>", EDIT_PLAN_TIERS.join(" | ")).option("--instructions <text>", "editing instructions for the planner").option("--watch", "poll the job until it finishes").option("--poll-interval <ms>", "poll interval with --watch", (v) => parseInt(v, 10)).option("--profile <name>").option("--json").action(
|
|
6971
|
+
async (opts, command) => {
|
|
6972
|
+
if (opts.output !== void 0 && opts.output !== "video" && opts.output !== "audio") {
|
|
6973
|
+
warn(`--output must be "video" or "audio" (got "${opts.output}")`);
|
|
6974
|
+
process.exit(1);
|
|
6975
|
+
}
|
|
6976
|
+
refuseUnknownPlanTier(opts.planTier);
|
|
6977
|
+
if (opts.framing !== void 0 && !EDL_TARGET_ASPECTS.includes(opts.framing)) {
|
|
6978
|
+
warn(`--framing must be ${EDL_TARGET_ASPECTS.join(", ")} (got "${opts.framing}")`);
|
|
6979
|
+
process.exit(1);
|
|
6980
|
+
}
|
|
6981
|
+
if (opts.layout !== void 0 && opts.framing === void 0) {
|
|
6982
|
+
warn("--layout applies with --framing only (it picks the framed layout)");
|
|
6983
|
+
process.exit(1);
|
|
6984
|
+
}
|
|
6985
|
+
if (opts.layout !== void 0 && !framingLayouts.includes(opts.layout)) {
|
|
6986
|
+
warn(`--layout must be ${framingLayouts.join(", ")} (got "${opts.layout}")`);
|
|
6987
|
+
process.exit(1);
|
|
6988
|
+
}
|
|
6014
6989
|
try {
|
|
6015
6990
|
const client = buildClient(opts.profile);
|
|
6016
|
-
const result = await client.edit.
|
|
6017
|
-
|
|
6018
|
-
...opts.
|
|
6019
|
-
...opts.
|
|
6020
|
-
...opts.
|
|
6991
|
+
const result = await client.edit.tightenEpisode({
|
|
6992
|
+
mediaUrl: opts.media,
|
|
6993
|
+
...opts.music ? { musicUrl: opts.music } : {},
|
|
6994
|
+
...opts.output ? { output: opts.output } : {},
|
|
6995
|
+
...opts.framing ? { framing: { aspect: opts.framing, layout: opts.layout ?? "auto" } } : {},
|
|
6996
|
+
// commander's --no-captions defaults `captions` to true: send it only when turned off.
|
|
6997
|
+
...opts.captions === false ? { captions: false } : {},
|
|
6998
|
+
...opts.review ? { reviewBeforeRender: true } : {},
|
|
6999
|
+
...opts.planTier ? { planTier: opts.planTier } : {},
|
|
7000
|
+
...opts.instructions ? { instructions: opts.instructions } : {}
|
|
6021
7001
|
});
|
|
6022
7002
|
await reportQueuedJob(result, () => client.jobs.getStatus(result.jobId), {
|
|
6023
7003
|
json: opts.json,
|
|
6024
7004
|
watch: opts.watch,
|
|
6025
7005
|
pollInterval: opts.pollInterval,
|
|
6026
|
-
note:
|
|
7006
|
+
note: command.name()
|
|
6027
7007
|
});
|
|
6028
7008
|
} catch (err) {
|
|
6029
7009
|
handleError(err);
|
|
6030
7010
|
}
|
|
6031
7011
|
}
|
|
6032
7012
|
);
|
|
6033
|
-
cmd.command("
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
|
|
6037
|
-
|
|
6038
|
-
|
|
6039
|
-
|
|
6040
|
-
|
|
6041
|
-
|
|
6042
|
-
|
|
6043
|
-
|
|
6044
|
-
|
|
6045
|
-
|
|
6046
|
-
|
|
6047
|
-
|
|
6048
|
-
|
|
7013
|
+
cmd.command("episode-chapters").description("list a podcast recording's chapters in one step (transcribe, then plan the chapters); with --watch, prints the show notes").requiredOption("--media <url>", "the recording (video or audio URL, up to 3 hours)").option("--plan-tier <tier>", EDIT_PLAN_TIERS.join(" | ")).option("--instructions <text>", 'instructions for the chapters ("5 to 8 chapters")').option("--style-guide <text>", "a style guide for the chapter titles").option("--idempotency-key <key>", "sent as Idempotency-Key: a retry with the same key answers the run already started").option("--watch", "poll the job until it finishes, then print the chapter list").option("--poll-interval <ms>", "poll interval with --watch", (v) => parseInt(v, 10)).option("--profile <name>").option("--json").action(
|
|
7014
|
+
async (opts, command) => {
|
|
7015
|
+
refuseUnknownPlanTier(opts.planTier);
|
|
7016
|
+
try {
|
|
7017
|
+
const client = buildClient(opts.profile);
|
|
7018
|
+
const result = await client.edit.episodeChapters(
|
|
7019
|
+
{
|
|
7020
|
+
mediaUrl: opts.media,
|
|
7021
|
+
...opts.planTier ? { planTier: opts.planTier } : {},
|
|
7022
|
+
...opts.instructions ? { instructions: opts.instructions } : {},
|
|
7023
|
+
...opts.styleGuide ? { styleGuide: opts.styleGuide } : {}
|
|
7024
|
+
},
|
|
7025
|
+
opts.idempotencyKey ? { idempotencyKey: opts.idempotencyKey } : void 0
|
|
7026
|
+
);
|
|
7027
|
+
const done = await reportQueuedJob(result, () => client.jobs.getStatus(result.jobId), {
|
|
7028
|
+
json: opts.json,
|
|
7029
|
+
watch: opts.watch,
|
|
7030
|
+
pollInterval: opts.pollInterval,
|
|
7031
|
+
note: command.name()
|
|
7032
|
+
});
|
|
7033
|
+
const text = done?.data.output_data?.text;
|
|
7034
|
+
if (!opts.json && done?.data.status === "completed" && typeof text === "string" && text.length > 0) console.log(text);
|
|
7035
|
+
} catch (err) {
|
|
7036
|
+
handleError(err);
|
|
6049
7037
|
}
|
|
6050
|
-
|
|
6051
|
-
|
|
7038
|
+
}
|
|
7039
|
+
);
|
|
7040
|
+
cmd.command("episode-trailer").description("cut a 20\u201340 second trailer of a recording and deliver it in each chosen social format, in one step").requiredOption("--media <url>", "the recording (a video URL, up to 3 hours)").option("--intro-card <url>", "an optional short video (15 s at most) played before the trailer").option("--formats <list>", `comma-separated, at least one: ${TRAILER_FORMATS.join(",")} (default 9:16,1:1,4:5)`).option("--review", "stop at a preview to review (render every format with `nodaro edit continue-use-case <jobId> --mode render-final`)").option("--plan-tier <tier>", EDIT_PLAN_TIERS.join(" | ")).option("--instructions <text>", "instructions for the trailer").option("--style-guide <text>", "a style guide for the plan").option("--idempotency-key <key>", "sent as Idempotency-Key: a retry with the same key answers the run already started").option("--watch", "poll the job until it finishes, then print each format's URL").option("--poll-interval <ms>", "poll interval with --watch", (v) => parseInt(v, 10)).option("--profile <name>").option("--json").action(
|
|
7041
|
+
async (opts) => {
|
|
7042
|
+
const formats = opts.formats?.split(",").map((f) => f.trim()).filter((f) => f.length > 0);
|
|
7043
|
+
if (formats !== void 0 && (formats.length === 0 || formats.some((f) => !TRAILER_FORMATS.includes(f)))) {
|
|
7044
|
+
warn(`--formats must be one or more of ${TRAILER_FORMATS.join(", ")}, comma-separated (got "${opts.formats}")`);
|
|
6052
7045
|
process.exit(1);
|
|
6053
7046
|
}
|
|
7047
|
+
refuseUnknownPlanTier(opts.planTier);
|
|
6054
7048
|
try {
|
|
6055
7049
|
const client = buildClient(opts.profile);
|
|
6056
|
-
const result = await client.edit.
|
|
6057
|
-
|
|
6058
|
-
|
|
6059
|
-
|
|
6060
|
-
|
|
7050
|
+
const result = await client.edit.episodeTrailer(
|
|
7051
|
+
{
|
|
7052
|
+
mediaUrl: opts.media,
|
|
7053
|
+
...opts.introCard ? { introCardUrl: opts.introCard } : {},
|
|
7054
|
+
...formats ? { formats } : {},
|
|
7055
|
+
...opts.review ? { reviewBeforeRender: true } : {},
|
|
7056
|
+
...opts.planTier ? { planTier: opts.planTier } : {},
|
|
7057
|
+
...opts.instructions ? { instructions: opts.instructions } : {},
|
|
7058
|
+
...opts.styleGuide ? { styleGuide: opts.styleGuide } : {}
|
|
7059
|
+
},
|
|
7060
|
+
opts.idempotencyKey ? { idempotencyKey: opts.idempotencyKey } : void 0
|
|
7061
|
+
);
|
|
7062
|
+
const done = await reportQueuedJob(result, () => client.jobs.getStatus(result.jobId), {
|
|
6061
7063
|
json: opts.json,
|
|
6062
7064
|
watch: opts.watch,
|
|
6063
7065
|
pollInterval: opts.pollInterval,
|
|
6064
|
-
note:
|
|
7066
|
+
note: "episode-trailer"
|
|
6065
7067
|
});
|
|
7068
|
+
if (opts.json) return;
|
|
7069
|
+
const out = done?.data.output_data;
|
|
7070
|
+
if (done?.data.status === "completed" && Array.isArray(out?.formats)) {
|
|
7071
|
+
for (const f of out.formats) {
|
|
7072
|
+
if (typeof f?.format === "string" && typeof f.url === "string") console.log(`${f.format} ${f.url}`);
|
|
7073
|
+
}
|
|
7074
|
+
const failed = Array.isArray(out.failedFormats) ? out.failedFormats.filter((f) => typeof f === "string") : [];
|
|
7075
|
+
if (failed.length > 0) console.log(`Could not render: ${failed.join(", ")}`);
|
|
7076
|
+
}
|
|
7077
|
+
if (opts.review) console.log(pc3.dim(` render every format after your review: nodaro edit continue-use-case ${result.jobId} --mode render-final`));
|
|
6066
7078
|
} catch (err) {
|
|
6067
7079
|
handleError(err);
|
|
6068
7080
|
}
|
|
6069
7081
|
}
|
|
6070
7082
|
);
|
|
6071
|
-
|
|
6072
|
-
|
|
6073
|
-
'the plan clip this render cuts, "<first inMs>-<last outMs>" of a clips-mode plan clip; stamped back on the result as clipKey'
|
|
6074
|
-
).option("--watch", "poll the job until it finishes").option("--poll-interval <ms>", "poll interval with --watch", (v) => parseInt(v, 10)).option("--profile <name>").option("--json").action(
|
|
7083
|
+
const isWhole = (v, min, max) => v !== void 0 && /^\d+$/.test(v.trim()) && Number(v) >= min && Number(v) <= max;
|
|
7084
|
+
cmd.command("clip-pack").description("cut a recording into a pack of short clips in one step (find the best moments, render each \u2014 framed and captioned by default)").requiredOption("--media <url>", "the recording (video or audio URL, up to 3 hours; an audio recording makes audio clips)").option("--count <n>", `how many clips, 1\u2013${EDIT_PLAN_MAX_CLIP_COUNT} (default 8; the plan may find fewer)`).option("--length <sec>", `each clip's target length in seconds, ${CLIP_PACK_MIN_TARGET_SEC}\u2013${CLIP_PACK_MAX_TARGET_SEC} (default 60)`).option("--framing <aspect>", `frame each clip on its speakers: ${EDL_TARGET_ASPECTS.join(" | ")}, or none for the recording's shape (default 9:16)`).option("--layout <layout>", `layout with --framing <aspect> (default stacked): ${framingLayouts.join(" | ")}`).option("--switch <id>", `the switch at each speaker change, with --framing <aspect> (default pan): cut | pan | zoom | xfade:<transition>, e.g. xfade:fade`).option("--emphasis <style>", `how the speaker talking is emphasised, with --framing <aspect> (default scale): ${EMPHASIS_HELP}`).option("--no-captions", "no captions on the clips").option("--caption-style <style>", `the captions' look (default karaoke): ${ALL_CAPTION_STYLES.join(" | ")}`).option("--review", "stop at previews to review (render the kept clips with `nodaro edit continue-use-case <jobId> --mode render-final`)").option("--plan-tier <tier>", EDIT_PLAN_TIERS.join(" | ")).option("--instructions <text>", "instructions for picking the clips").option("--style-guide <text>", "a style guide for the plan").option("--idempotency-key <key>", "sent as Idempotency-Key: a retry with the same key answers the run already started").option("--watch", "poll the job until it finishes, then print each clip's URL").option("--poll-interval <ms>", "poll interval with --watch", (v) => parseInt(v, 10)).option("--profile <name>").option("--json").action(
|
|
6075
7085
|
async (opts) => {
|
|
6076
|
-
if (opts.
|
|
6077
|
-
warn(`--
|
|
7086
|
+
if (opts.count !== void 0 && !isWhole(opts.count, 1, EDIT_PLAN_MAX_CLIP_COUNT)) {
|
|
7087
|
+
warn(`--count must be 1\u2013${EDIT_PLAN_MAX_CLIP_COUNT} (got "${opts.count}")`);
|
|
6078
7088
|
process.exit(1);
|
|
6079
7089
|
}
|
|
6080
|
-
if (opts.
|
|
6081
|
-
warn(`--
|
|
7090
|
+
if (opts.length !== void 0 && !isWhole(opts.length, CLIP_PACK_MIN_TARGET_SEC, CLIP_PACK_MAX_TARGET_SEC)) {
|
|
7091
|
+
warn(`--length must be ${CLIP_PACK_MIN_TARGET_SEC}\u2013${CLIP_PACK_MAX_TARGET_SEC} seconds (got "${opts.length}")`);
|
|
6082
7092
|
process.exit(1);
|
|
6083
7093
|
}
|
|
6084
|
-
|
|
6085
|
-
|
|
6086
|
-
|
|
6087
|
-
edl: readJsonFile(opts.edl),
|
|
6088
|
-
...opts.source && opts.source.length > 0 ? { sources: opts.source } : {},
|
|
6089
|
-
...opts.transcript ? { transcript: readJsonFile(opts.transcript) } : {},
|
|
6090
|
-
output: opts.output,
|
|
6091
|
-
quality: opts.quality,
|
|
6092
|
-
...opts.crossfadeMs !== void 0 ? { crossfadeMs: opts.crossfadeMs } : {},
|
|
6093
|
-
...opts.clipKey !== void 0 ? { clipKey: opts.clipKey } : {}
|
|
6094
|
-
});
|
|
6095
|
-
await reportQueuedJob(result, () => client.jobs.getStatus(result.jobId), {
|
|
6096
|
-
json: opts.json,
|
|
6097
|
-
watch: opts.watch,
|
|
6098
|
-
pollInterval: opts.pollInterval,
|
|
6099
|
-
note: `apply-edl (${opts.output})`
|
|
6100
|
-
});
|
|
6101
|
-
} catch (err) {
|
|
6102
|
-
handleError(err);
|
|
7094
|
+
if (opts.framing !== void 0 && opts.framing !== "none" && !EDL_TARGET_ASPECTS.includes(opts.framing)) {
|
|
7095
|
+
warn(`--framing must be ${EDL_TARGET_ASPECTS.join(", ")} or none (got "${opts.framing}")`);
|
|
7096
|
+
process.exit(1);
|
|
6103
7097
|
}
|
|
6104
|
-
|
|
6105
|
-
|
|
6106
|
-
const framingLayouts = ["auto", ...SPEAKER_LAYOUT_IDS];
|
|
6107
|
-
cmd.command("tighten-episode").description("tighten a podcast recording in one step (transcribe, cut silences, render; optional captions, music and framing)").requiredOption("--media <url>", "the recording (video or audio URL, up to 3 hours)").option("--music <url>", "optional music bed, ducked under the voice").option("--output <kind>", "video | audio (an audio recording always makes an audio episode)").option("--framing <aspect>", `frame a video episode on its speakers: ${EDL_TARGET_ASPECTS.join(" | ")}`).option("--layout <layout>", `layout with --framing (default auto): ${framingLayouts.join(" | ")}`).option("--no-captions", "no captions on a video episode").option("--review", "stop at a preview to review (render the final with `nodaro edit continue-use-case <jobId> --mode render-final`)").option("--plan-tier <tier>", EDIT_PLAN_TIERS.join(" | ")).option("--instructions <text>", "editing instructions for the planner").option("--watch", "poll the job until it finishes").option("--poll-interval <ms>", "poll interval with --watch", (v) => parseInt(v, 10)).option("--profile <name>").option("--json").action(
|
|
6108
|
-
async (opts) => {
|
|
6109
|
-
if (opts.output !== void 0 && opts.output !== "video" && opts.output !== "audio") {
|
|
6110
|
-
warn(`--output must be "video" or "audio" (got "${opts.output}")`);
|
|
7098
|
+
if (opts.layout !== void 0 && (opts.framing === void 0 || opts.framing === "none")) {
|
|
7099
|
+
warn("--layout applies with --framing <aspect> only (it picks the framed layout)");
|
|
6111
7100
|
process.exit(1);
|
|
6112
7101
|
}
|
|
6113
|
-
if (opts.
|
|
6114
|
-
warn(`--
|
|
7102
|
+
if (opts.layout !== void 0 && !framingLayouts.includes(opts.layout)) {
|
|
7103
|
+
warn(`--layout must be ${framingLayouts.join(", ")} (got "${opts.layout}")`);
|
|
6115
7104
|
process.exit(1);
|
|
6116
7105
|
}
|
|
6117
|
-
|
|
6118
|
-
|
|
7106
|
+
for (const [flag, value] of [["--switch", opts.switch], ["--emphasis", opts.emphasis]]) {
|
|
7107
|
+
if (value !== void 0 && (opts.framing === void 0 || opts.framing === "none")) {
|
|
7108
|
+
warn(`${flag} applies with --framing <aspect> only (it is part of the framing)`);
|
|
7109
|
+
process.exit(1);
|
|
7110
|
+
}
|
|
7111
|
+
}
|
|
7112
|
+
if (opts.switch !== void 0 && !SPEAKER_SWITCH_IDS.includes(opts.switch)) {
|
|
7113
|
+
warn(`--switch must be one of ${SPEAKER_SWITCH_IDS.join(", ")} (got "${opts.switch}")`);
|
|
6119
7114
|
process.exit(1);
|
|
6120
7115
|
}
|
|
6121
|
-
if (opts.
|
|
6122
|
-
warn(
|
|
7116
|
+
if (opts.emphasis !== void 0 && !isKnownSpeakerEmphasisStyle(opts.emphasis)) {
|
|
7117
|
+
warn(`--emphasis must be ${EMPHASIS_HELP} (got "${opts.emphasis}")`);
|
|
6123
7118
|
process.exit(1);
|
|
6124
7119
|
}
|
|
6125
|
-
if (opts.
|
|
6126
|
-
warn(
|
|
7120
|
+
if (opts.captionStyle !== void 0 && opts.captions === false) {
|
|
7121
|
+
warn("--caption-style applies with captions on (drop --no-captions)");
|
|
7122
|
+
process.exit(1);
|
|
7123
|
+
}
|
|
7124
|
+
if (opts.captionStyle !== void 0 && !ALL_CAPTION_STYLES.includes(opts.captionStyle)) {
|
|
7125
|
+
warn(`--caption-style must be ${ALL_CAPTION_STYLES.join(", ")} (got "${opts.captionStyle}")`);
|
|
6127
7126
|
process.exit(1);
|
|
6128
7127
|
}
|
|
7128
|
+
refuseUnknownPlanTier(opts.planTier);
|
|
6129
7129
|
try {
|
|
6130
7130
|
const client = buildClient(opts.profile);
|
|
6131
|
-
const result = await client.edit.
|
|
6132
|
-
|
|
6133
|
-
|
|
6134
|
-
|
|
6135
|
-
|
|
6136
|
-
|
|
6137
|
-
|
|
6138
|
-
|
|
6139
|
-
|
|
6140
|
-
|
|
6141
|
-
|
|
6142
|
-
|
|
7131
|
+
const result = await client.edit.clipPack(
|
|
7132
|
+
{
|
|
7133
|
+
mediaUrl: opts.media,
|
|
7134
|
+
...opts.count !== void 0 ? { count: Number(opts.count) } : {},
|
|
7135
|
+
...opts.length !== void 0 ? { targetDurationSec: Number(opts.length) } : {},
|
|
7136
|
+
// none = the recording's shape; an aspect alone leaves the layout to the route (stacked).
|
|
7137
|
+
...opts.framing === "none" ? { framing: null } : opts.framing ? {
|
|
7138
|
+
framing: {
|
|
7139
|
+
aspect: opts.framing,
|
|
7140
|
+
...opts.layout ? { layout: opts.layout } : {},
|
|
7141
|
+
...opts.switch ? { switchType: opts.switch } : {},
|
|
7142
|
+
...opts.emphasis ? { emphasisStyle: opts.emphasis } : {}
|
|
7143
|
+
}
|
|
7144
|
+
} : {},
|
|
7145
|
+
// commander's --no-captions defaults `captions` to true: send it only when turned off.
|
|
7146
|
+
...opts.captions === false ? { captions: false } : {},
|
|
7147
|
+
...opts.captionStyle ? { captionStyle: opts.captionStyle } : {},
|
|
7148
|
+
...opts.review ? { reviewBeforeRender: true } : {},
|
|
7149
|
+
...opts.planTier ? { planTier: opts.planTier } : {},
|
|
7150
|
+
...opts.instructions ? { instructions: opts.instructions } : {},
|
|
7151
|
+
...opts.styleGuide ? { styleGuide: opts.styleGuide } : {}
|
|
7152
|
+
},
|
|
7153
|
+
opts.idempotencyKey ? { idempotencyKey: opts.idempotencyKey } : void 0
|
|
7154
|
+
);
|
|
7155
|
+
const done = await reportQueuedJob(result, () => client.jobs.getStatus(result.jobId), {
|
|
6143
7156
|
json: opts.json,
|
|
6144
7157
|
watch: opts.watch,
|
|
6145
7158
|
pollInterval: opts.pollInterval,
|
|
6146
|
-
note: "
|
|
7159
|
+
note: "clip-pack"
|
|
6147
7160
|
});
|
|
7161
|
+
if (opts.json) return;
|
|
7162
|
+
const out = done?.data.output_data;
|
|
7163
|
+
if (done?.data.status === "completed" && Array.isArray(out?.clips)) {
|
|
7164
|
+
;
|
|
7165
|
+
out.clips.forEach((c, i) => {
|
|
7166
|
+
if (typeof c?.url !== "string") return;
|
|
7167
|
+
const note = [typeof c.title === "string" ? c.title : "", c.captionsFailed === true ? "(no captions)" : ""].filter(Boolean).join(" ");
|
|
7168
|
+
console.log(`${i + 1} ${c.url}${note ? ` ${note}` : ""}`);
|
|
7169
|
+
});
|
|
7170
|
+
const failed = typeof out.failedClips === "number" && out.failedClips > 0 ? out.failedClips : 0;
|
|
7171
|
+
if (failed > 0) console.log(failed === 1 ? "1 clip could not be rendered." : `${failed} clips could not be rendered.`);
|
|
7172
|
+
}
|
|
7173
|
+
if (opts.review) console.log(pc3.dim(` render the kept clips after your review: nodaro edit continue-use-case ${result.jobId} --mode render-final [--edit <file>]`));
|
|
6148
7174
|
} catch (err) {
|
|
6149
7175
|
handleError(err);
|
|
6150
7176
|
}
|
|
6151
7177
|
}
|
|
6152
7178
|
);
|
|
6153
|
-
cmd.command("continue-use-case <jobId>").description("continue a Tighten Episode run as a new job: from where it failed, or its Render final after a review").requiredOption("--mode <mode>", "from-failed | render-final").option("--edit <file>", "render-final only: a JSON file holding the reviewer's edit of the plan (an EDL)").option(
|
|
7179
|
+
cmd.command("continue-use-case <jobId>").description("continue a Tighten Episode, Chapters, Trailer or Clip Pack run as a new job: from where it failed, or its Render final after a review").requiredOption("--mode <mode>", "from-failed | render-final").option("--edit <file>", "render-final only: a JSON file holding the reviewer's edit of the plan (an EDL)").option(
|
|
7180
|
+
"--type <type>",
|
|
7181
|
+
`the run's node type (${USE_CASE_NODE_TYPES.join(" | ")}); without it the job is read for its type, which needs the jobs:read scope`
|
|
7182
|
+
).option("--idempotency-key <key>", "sent as Idempotency-Key: a retry with the same key answers the run already started").option("--watch", "poll the job until it finishes").option("--poll-interval <ms>", "poll interval with --watch", (v) => parseInt(v, 10)).option("--profile <name>").option("--json").action(async (jobId, opts) => {
|
|
6154
7183
|
if (opts.mode !== "from-failed" && opts.mode !== "render-final") {
|
|
6155
7184
|
warn(`--mode must be "from-failed" or "render-final" (got "${opts.mode}")`);
|
|
6156
7185
|
process.exit(1);
|
|
6157
7186
|
}
|
|
7187
|
+
if (opts.type !== void 0 && !USE_CASE_NODE_TYPES.includes(opts.type)) {
|
|
7188
|
+
warn(`--type must be ${USE_CASE_NODE_TYPES.join(", ")} (got "${opts.type}")`);
|
|
7189
|
+
process.exit(1);
|
|
7190
|
+
}
|
|
6158
7191
|
if (opts.edit !== void 0 && opts.mode !== "render-final") {
|
|
6159
7192
|
warn("--edit applies to --mode render-final only");
|
|
6160
7193
|
process.exit(1);
|
|
@@ -6165,7 +7198,8 @@ function editCommand() {
|
|
|
6165
7198
|
{
|
|
6166
7199
|
jobId,
|
|
6167
7200
|
mode: opts.mode,
|
|
6168
|
-
...opts.edit !== void 0 ? { editedEdl:
|
|
7201
|
+
...opts.edit !== void 0 ? { editedEdl: readJsonFile2(opts.edit) } : {},
|
|
7202
|
+
...opts.type !== void 0 ? { nodeType: opts.type } : {}
|
|
6169
7203
|
},
|
|
6170
7204
|
opts.idempotencyKey ? { idempotencyKey: opts.idempotencyKey } : void 0
|
|
6171
7205
|
);
|
|
@@ -6186,9 +7220,175 @@ function editCommand() {
|
|
|
6186
7220
|
}
|
|
6187
7221
|
process.exit(1);
|
|
6188
7222
|
}
|
|
7223
|
+
if (err instanceof NodaroError && err.code === "use_case_type_unknown") {
|
|
7224
|
+
const message = "pass --type <node type> (this key can't read the job's type)";
|
|
7225
|
+
if (opts.json) {
|
|
7226
|
+
emit({ error: { code: err.code, message } }, opts);
|
|
7227
|
+
} else {
|
|
7228
|
+
console.error(pc3.red(`\u2717 ${message}`));
|
|
7229
|
+
console.error(pc3.dim(` code: ${err.code}`));
|
|
7230
|
+
console.error(pc3.dim(` --type: ${USE_CASE_NODE_TYPES.join(" | ")}`));
|
|
7231
|
+
}
|
|
7232
|
+
process.exit(1);
|
|
7233
|
+
}
|
|
6189
7234
|
handleError(err);
|
|
6190
7235
|
}
|
|
6191
7236
|
});
|
|
7237
|
+
}
|
|
7238
|
+
|
|
7239
|
+
// src/commands/edit.ts
|
|
7240
|
+
function isEditPlanMode(v) {
|
|
7241
|
+
return EDIT_PLAN_MODES.includes(v);
|
|
7242
|
+
}
|
|
7243
|
+
function parseSourceSpec(spec, index2) {
|
|
7244
|
+
const named = /^([^=\s]{1,200})=(https?:\/\/.+)$/.exec(spec);
|
|
7245
|
+
const id = named ? named[1] : `source-${index2 + 1}`;
|
|
7246
|
+
const rest = named ? named[2] : spec;
|
|
7247
|
+
const at = rest.lastIndexOf("@");
|
|
7248
|
+
if (at > 0) {
|
|
7249
|
+
const suffix = rest.slice(at + 1);
|
|
7250
|
+
if (suffix === "audio" || suffix === "video") {
|
|
7251
|
+
return { id, url: rest.slice(0, at), kind: suffix };
|
|
7252
|
+
}
|
|
7253
|
+
}
|
|
7254
|
+
return { id, url: rest, kind: "video" };
|
|
7255
|
+
}
|
|
7256
|
+
function parseAudioSyncSource(spec, index2) {
|
|
7257
|
+
const named = /^([^=\s]{1,200})=(https?:\/\/.+)$/.exec(spec);
|
|
7258
|
+
return named ? { id: named[1], url: named[2] } : { id: `source-${index2 + 1}`, url: spec };
|
|
7259
|
+
}
|
|
7260
|
+
function editCommand() {
|
|
7261
|
+
const cmd = new Command("edit").description(
|
|
7262
|
+
"editorial primitives for podcast / long-form video \u2014 detect silence, sync recordings, apply an EDL, plan a cut"
|
|
7263
|
+
);
|
|
7264
|
+
cmd.command("silence-detect <audioUrl>").description("detect silence ranges in an audio or video source (ffmpeg, keyless)").option("--threshold-db <dbfs>", "dBFS threshold, \u2264 0 (write a negative as --threshold-db=-35)", (v) => Number(v)).option("--min-silence-ms <ms>", "minimum silence length to report", (v) => parseInt(v, 10)).option("--pad-ms <ms>", "padding kept around speech", (v) => parseInt(v, 10)).option("--watch", "poll the job until it finishes").option("--poll-interval <ms>", "poll interval with --watch", (v) => parseInt(v, 10)).option("--profile <name>").option("--json").action(
|
|
7265
|
+
async (audioUrl, opts) => {
|
|
7266
|
+
try {
|
|
7267
|
+
const client = buildClient(opts.profile);
|
|
7268
|
+
const result = await client.edit.silenceDetect({
|
|
7269
|
+
audioUrl,
|
|
7270
|
+
...opts.thresholdDb !== void 0 ? { thresholdDb: opts.thresholdDb } : {},
|
|
7271
|
+
...opts.minSilenceMs !== void 0 ? { minSilenceMs: opts.minSilenceMs } : {},
|
|
7272
|
+
...opts.padMs !== void 0 ? { padMs: opts.padMs } : {}
|
|
7273
|
+
});
|
|
7274
|
+
await reportQueuedJob(result, () => client.jobs.getStatus(result.jobId), {
|
|
7275
|
+
json: opts.json,
|
|
7276
|
+
watch: opts.watch,
|
|
7277
|
+
pollInterval: opts.pollInterval,
|
|
7278
|
+
note: "silence-detect"
|
|
7279
|
+
});
|
|
7280
|
+
} catch (err) {
|
|
7281
|
+
handleError(err);
|
|
7282
|
+
}
|
|
7283
|
+
}
|
|
7284
|
+
);
|
|
7285
|
+
cmd.command("audio-sync").description("measure how far apart 2-6 recordings' clocks are, from their sound (keyless)").option(
|
|
7286
|
+
"--source <[id=]url>",
|
|
7287
|
+
"a recording (audio or video) as url or id=url (repeatable, 2-6); ids are minted as source-N when omitted",
|
|
7288
|
+
collectVariadic
|
|
7289
|
+
).option("--sources-file <file>", "JSON array of { id, url } rows (overrides --source)").option("--reference <id>", "the source every offset is measured against (default: the first)").option("--watch", "poll the job until it finishes").option("--poll-interval <ms>", "poll interval with --watch", (v) => parseInt(v, 10)).option("--profile <name>").option("--json").action(
|
|
7290
|
+
async (opts) => {
|
|
7291
|
+
let sources;
|
|
7292
|
+
if (opts.sourcesFile) {
|
|
7293
|
+
const parsed = readJsonFile2(opts.sourcesFile);
|
|
7294
|
+
if (!Array.isArray(parsed)) {
|
|
7295
|
+
warn(`--sources-file ${opts.sourcesFile} must contain a JSON array of { id, url } rows`);
|
|
7296
|
+
process.exit(1);
|
|
7297
|
+
}
|
|
7298
|
+
sources = parsed;
|
|
7299
|
+
} else {
|
|
7300
|
+
sources = (opts.source ?? []).map(parseAudioSyncSource);
|
|
7301
|
+
}
|
|
7302
|
+
if (sources.length < 2 || sources.length > 6) {
|
|
7303
|
+
warn(`audio-sync takes 2-6 recordings \u2014 pass --source <url> (repeatable) or --sources-file <file> (got ${sources.length})`);
|
|
7304
|
+
process.exit(1);
|
|
7305
|
+
}
|
|
7306
|
+
try {
|
|
7307
|
+
const client = buildClient(opts.profile);
|
|
7308
|
+
const result = await client.edit.audioSync({
|
|
7309
|
+
sources,
|
|
7310
|
+
...opts.reference !== void 0 ? { reference: opts.reference } : {}
|
|
7311
|
+
});
|
|
7312
|
+
await reportQueuedJob(result, () => client.jobs.getStatus(result.jobId), {
|
|
7313
|
+
json: opts.json,
|
|
7314
|
+
watch: opts.watch,
|
|
7315
|
+
pollInterval: opts.pollInterval,
|
|
7316
|
+
note: `audio-sync (${sources.length} sources)`
|
|
7317
|
+
});
|
|
7318
|
+
} catch (err) {
|
|
7319
|
+
handleError(err);
|
|
7320
|
+
}
|
|
7321
|
+
}
|
|
7322
|
+
);
|
|
7323
|
+
cmd.command("speaker-map").description("work out which camera each speaker is on, from the cameras' own microphones (keyless)").option(
|
|
7324
|
+
"--source <[id=]url>",
|
|
7325
|
+
"a camera (or the master / wide) as url or id=url (repeatable, 2-6); ids are minted as source-N when omitted",
|
|
7326
|
+
collectVariadic
|
|
7327
|
+
).option("--sources-file <file>", "JSON array of { id, url } rows (overrides --source)").requiredOption("--transcript <file>", "path to the transcript JSON WITH speaker labels (transcribe with speaker detection)").option("--offsets <file>", "an audio-sync result JSON (the job's output_data.json); omit when the recordings share a clock").option("--master <id>", "the master audio's id: hears everyone, so it is no one's camera").option("--wide <id>", "the wide shot's id: no one's camera; a speaker with no clear camera is shown on it").option("--margin-db <db>", "how much louder the loudest camera must be than the next (default 3)", (v) => Number(v)).option("--watch", "poll the job until it finishes").option("--poll-interval <ms>", "poll interval with --watch", (v) => parseInt(v, 10)).option("--profile <name>").option("--json").action(
|
|
7328
|
+
async (opts) => {
|
|
7329
|
+
const sources = opts.sourcesFile ? readJsonFile2(opts.sourcesFile) : (opts.source ?? []).map(parseAudioSyncSource);
|
|
7330
|
+
if (!Array.isArray(sources) || sources.length < 2 || sources.length > 6) {
|
|
7331
|
+
warn("speaker-map takes 2-6 recordings \u2014 pass --source <url> (repeatable) or --sources-file <file> (a JSON array of { id, url } rows)");
|
|
7332
|
+
process.exit(1);
|
|
7333
|
+
}
|
|
7334
|
+
try {
|
|
7335
|
+
const client = buildClient(opts.profile);
|
|
7336
|
+
const input2 = {
|
|
7337
|
+
sources,
|
|
7338
|
+
transcript: readJsonFile2(opts.transcript),
|
|
7339
|
+
...opts.offsets ? { offsets: readJsonFile2(opts.offsets) } : {},
|
|
7340
|
+
...opts.master !== void 0 ? { masterSourceId: opts.master } : {},
|
|
7341
|
+
...opts.wide !== void 0 ? { wideSourceId: opts.wide } : {},
|
|
7342
|
+
...opts.marginDb !== void 0 ? { marginDb: opts.marginDb } : {}
|
|
7343
|
+
};
|
|
7344
|
+
const result = await client.edit.speakerMap(input2);
|
|
7345
|
+
await reportQueuedJob(result, () => client.jobs.getStatus(result.jobId), {
|
|
7346
|
+
json: opts.json,
|
|
7347
|
+
watch: opts.watch,
|
|
7348
|
+
pollInterval: opts.pollInterval,
|
|
7349
|
+
note: `speaker-map (${sources.length} sources)`
|
|
7350
|
+
});
|
|
7351
|
+
} catch (err) {
|
|
7352
|
+
handleError(err);
|
|
7353
|
+
}
|
|
7354
|
+
}
|
|
7355
|
+
);
|
|
7356
|
+
cmd.command("apply-edl").description("render an edit decision list into a video or audio cut").requiredOption("--edl <file>", "path to a JSON file holding the EDL").option("--transcript <file>", "optional transcript JSON to remap through the cut").option("--source <url>", "positional media-URL override for edl.sources[i] (repeatable)", collectVariadic).option("--output <kind>", "video | audio", "video").option("--quality <q>", "proxy | final", "final").option("--crossfade-ms <ms>", "default crossfade on boundaries with no transition", (v) => parseInt(v, 10)).option(
|
|
7357
|
+
"--clip-key <key>",
|
|
7358
|
+
'the plan clip this render cuts, "<first inMs>-<last outMs>" of a clips-mode plan clip; stamped back on the result as clipKey'
|
|
7359
|
+
).option("--watch", "poll the job until it finishes").option("--poll-interval <ms>", "poll interval with --watch", (v) => parseInt(v, 10)).option("--profile <name>").option("--json").action(
|
|
7360
|
+
async (opts) => {
|
|
7361
|
+
if (opts.output !== "video" && opts.output !== "audio") {
|
|
7362
|
+
warn(`--output must be "video" or "audio" (got "${opts.output}")`);
|
|
7363
|
+
process.exit(1);
|
|
7364
|
+
}
|
|
7365
|
+
if (opts.quality !== "proxy" && opts.quality !== "final") {
|
|
7366
|
+
warn(`--quality must be "proxy" or "final" (got "${opts.quality}")`);
|
|
7367
|
+
process.exit(1);
|
|
7368
|
+
}
|
|
7369
|
+
try {
|
|
7370
|
+
const client = buildClient(opts.profile);
|
|
7371
|
+
const result = await client.edit.applyEdl({
|
|
7372
|
+
edl: readJsonFile2(opts.edl),
|
|
7373
|
+
...opts.source && opts.source.length > 0 ? { sources: opts.source } : {},
|
|
7374
|
+
...opts.transcript ? { transcript: readJsonFile2(opts.transcript) } : {},
|
|
7375
|
+
output: opts.output,
|
|
7376
|
+
quality: opts.quality,
|
|
7377
|
+
...opts.crossfadeMs !== void 0 ? { crossfadeMs: opts.crossfadeMs } : {},
|
|
7378
|
+
...opts.clipKey !== void 0 ? { clipKey: opts.clipKey } : {}
|
|
7379
|
+
});
|
|
7380
|
+
await reportQueuedJob(result, () => client.jobs.getStatus(result.jobId), {
|
|
7381
|
+
json: opts.json,
|
|
7382
|
+
watch: opts.watch,
|
|
7383
|
+
pollInterval: opts.pollInterval,
|
|
7384
|
+
note: `apply-edl (${opts.output})`
|
|
7385
|
+
});
|
|
7386
|
+
} catch (err) {
|
|
7387
|
+
handleError(err);
|
|
7388
|
+
}
|
|
7389
|
+
}
|
|
7390
|
+
);
|
|
7391
|
+
registerUseCaseCommands(cmd);
|
|
6192
7392
|
cmd.command("plan").description("plan a transcript-driven cut / clips / chapters / trailer (Cloud edition)").requiredOption("--mode <mode>", EDIT_PLAN_MODES.join(" | ")).requiredOption("--plan-tier <tier>", "economy | standard | premium").requiredOption("--transcript <file>", "path to a timed transcript JSON file").option("--silence <file>", "optional silence JSON \u2014 the silence-detect job's output_data.json ({ version, ranges, durationMs })").option(
|
|
6193
7393
|
"--source <url>",
|
|
6194
7394
|
"a media source as [id=]url[@audio|@video] (repeatable); id defaults to source-N, kind to video",
|
|
@@ -6212,7 +7412,7 @@ function editCommand() {
|
|
|
6212
7412
|
}
|
|
6213
7413
|
let sources;
|
|
6214
7414
|
if (opts.sourcesFile) {
|
|
6215
|
-
const parsed =
|
|
7415
|
+
const parsed = readJsonFile2(opts.sourcesFile);
|
|
6216
7416
|
if (!Array.isArray(parsed)) {
|
|
6217
7417
|
warn(`--sources-file ${opts.sourcesFile} must contain a JSON array of source rows`);
|
|
6218
7418
|
process.exit(1);
|
|
@@ -6230,10 +7430,10 @@ function editCommand() {
|
|
|
6230
7430
|
const input2 = {
|
|
6231
7431
|
mode: opts.mode,
|
|
6232
7432
|
planTier: opts.planTier,
|
|
6233
|
-
transcript:
|
|
7433
|
+
transcript: readJsonFile2(opts.transcript),
|
|
6234
7434
|
sources,
|
|
6235
|
-
...opts.silence ? { silence:
|
|
6236
|
-
...opts.offsets ? { offsets:
|
|
7435
|
+
...opts.silence ? { silence: readJsonFile2(opts.silence) } : {},
|
|
7436
|
+
...opts.offsets ? { offsets: readJsonFile2(opts.offsets) } : {},
|
|
6237
7437
|
...opts.transcriptSource ? { transcriptSourceId: opts.transcriptSource } : {},
|
|
6238
7438
|
...opts.instructions !== void 0 ? { instructions: opts.instructions } : {},
|
|
6239
7439
|
...opts.styleGuide !== void 0 ? { styleGuide: opts.styleGuide } : {},
|
|
@@ -6254,15 +7454,16 @@ function editCommand() {
|
|
|
6254
7454
|
}
|
|
6255
7455
|
}
|
|
6256
7456
|
);
|
|
6257
|
-
cmd.command("switch-cameras").description("choose which camera shows each cut of an edit by who is speaking (Cloud edition; flat price)").requiredOption("--edl <file>", "path to ONE EDL JSON (an `edit plan` result)").requiredOption("--transcript <file>", "path to the transcript JSON WITH speaker labels (transcribe with speaker detection)").option("--speaker-map <file>", "JSON object: speaker label \u2192 EDL source id of their camera").option("--speaker-names <file>", "JSON object: speaker label \u2192 display name").option("--min-shot-ms <ms>", "shortest shot (default 2500)", (v) => parseInt(v, 10)).option("--lead-ms <ms>", "cut this long before the new speaker (default 200)", (v) => parseInt(v, 10)).option("--max-shot-ms <ms>", "with a wide source: break to it after this long (default 20000)", (v) => parseInt(v, 10)).option("--wide-every <n>", "with a wide source: every N-th cut to the wide (default 0 = off)", (v) => parseInt(v, 10)).option("--layout-hints", "suggest side-by-side / stacked layouts for crosstalk (Apply EDL renders cut-only edits)").option("--watch", "poll the job until it finishes").option("--poll-interval <ms>", "poll interval with --watch", (v) => parseInt(v, 10)).option("--profile <name>").option("--json").action(
|
|
7457
|
+
cmd.command("switch-cameras").description("choose which camera shows each cut of an edit by who is speaking (Cloud edition; flat price)").requiredOption("--edl <file>", "path to ONE EDL JSON (an `edit plan` result)").requiredOption("--transcript <file>", "path to the transcript JSON WITH speaker labels (transcribe with speaker detection)").option("--speaker-map <file>", "JSON object: speaker label \u2192 EDL source id of their camera").option("--speaker-map-result <file>", "a speaker-map result JSON (the job's output_data.json); a label in --speaker-map wins over it").option("--speaker-names <file>", "JSON object: speaker label \u2192 display name").option("--min-shot-ms <ms>", "shortest shot (default 2500)", (v) => parseInt(v, 10)).option("--lead-ms <ms>", "cut this long before the new speaker (default 200)", (v) => parseInt(v, 10)).option("--max-shot-ms <ms>", "with a wide source: break to it after this long (default 20000)", (v) => parseInt(v, 10)).option("--wide-every <n>", "with a wide source: every N-th cut to the wide (default 0 = off)", (v) => parseInt(v, 10)).option("--layout-hints", "suggest side-by-side / stacked layouts for crosstalk (Apply EDL renders cut-only edits)").option("--watch", "poll the job until it finishes").option("--poll-interval <ms>", "poll interval with --watch", (v) => parseInt(v, 10)).option("--profile <name>").option("--json").action(
|
|
6258
7458
|
async (opts) => {
|
|
6259
7459
|
try {
|
|
6260
7460
|
const client = buildClient(opts.profile);
|
|
6261
7461
|
const input2 = {
|
|
6262
|
-
edl:
|
|
6263
|
-
transcript:
|
|
6264
|
-
...opts.speakerMap ? { speakerMap:
|
|
6265
|
-
...opts.
|
|
7462
|
+
edl: readJsonFile2(opts.edl),
|
|
7463
|
+
transcript: readJsonFile2(opts.transcript),
|
|
7464
|
+
...opts.speakerMap ? { speakerMap: readJsonFile2(opts.speakerMap) } : {},
|
|
7465
|
+
...opts.speakerMapResult ? { speakerMapResult: readJsonFile2(opts.speakerMapResult) } : {},
|
|
7466
|
+
...opts.speakerNames ? { speakerNames: readJsonFile2(opts.speakerNames) } : {},
|
|
6266
7467
|
...opts.minShotMs !== void 0 ? { minShotMs: opts.minShotMs } : {},
|
|
6267
7468
|
...opts.leadMs !== void 0 ? { leadMs: opts.leadMs } : {},
|
|
6268
7469
|
...opts.maxShotMs !== void 0 ? { maxShotMs: opts.maxShotMs } : {},
|
|
@@ -6283,6 +7484,322 @@ function editCommand() {
|
|
|
6283
7484
|
);
|
|
6284
7485
|
return cmd;
|
|
6285
7486
|
}
|
|
7487
|
+
var GIB = 1024 * 1024 * 1024;
|
|
7488
|
+
function money(m) {
|
|
7489
|
+
try {
|
|
7490
|
+
return new Intl.NumberFormat("en", { style: "currency", currency: m.currency }).format(m.amount);
|
|
7491
|
+
} catch {
|
|
7492
|
+
return `${m.amount} ${m.currency}`;
|
|
7493
|
+
}
|
|
7494
|
+
}
|
|
7495
|
+
function priceCell(plan, slot) {
|
|
7496
|
+
if (plan.prices === null) return "free";
|
|
7497
|
+
if (slot === "monthly") return plan.prices.monthly ? money(plan.prices.monthly) : "unavailable";
|
|
7498
|
+
const yearly = plan.prices.yearly;
|
|
7499
|
+
if (!yearly) return "unavailable";
|
|
7500
|
+
return yearly.perMonth === null ? money(yearly) : `${money(yearly)} (${money({ amount: yearly.perMonth, currency: yearly.currency })} a month)`;
|
|
7501
|
+
}
|
|
7502
|
+
function grant(credits) {
|
|
7503
|
+
return `${credits.amount.toLocaleString("en")} / ${credits.per}`;
|
|
7504
|
+
}
|
|
7505
|
+
function creditsCell(plan) {
|
|
7506
|
+
if (plan.signupCredits !== null) return `${plan.signupCredits.toLocaleString("en")} once`;
|
|
7507
|
+
const monthly = plan.prices?.monthly?.credits ?? null;
|
|
7508
|
+
const yearly = plan.prices?.yearly?.credits ?? null;
|
|
7509
|
+
if (monthly && yearly) {
|
|
7510
|
+
return monthly.amount === yearly.amount && monthly.per === yearly.per ? grant(monthly) : `${grant(monthly)} (yearly: ${grant(yearly)})`;
|
|
7511
|
+
}
|
|
7512
|
+
if (monthly) return grant(monthly);
|
|
7513
|
+
return yearly ? `yearly: ${grant(yearly)}` : "-";
|
|
7514
|
+
}
|
|
7515
|
+
function storageCell(bytes) {
|
|
7516
|
+
const gb = bytes / GIB;
|
|
7517
|
+
return `${Number.isInteger(gb) ? gb : gb.toFixed(1)} GB`;
|
|
7518
|
+
}
|
|
7519
|
+
function billingCommand() {
|
|
7520
|
+
const cmd = new Command("billing").description(
|
|
7521
|
+
"plans and prices, your subscription, and how this deployment bills (buying stays in the app)"
|
|
7522
|
+
);
|
|
7523
|
+
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(
|
|
7524
|
+
"after",
|
|
7525
|
+
`
|
|
7526
|
+
Examples:
|
|
7527
|
+
$ nodaro billing plans
|
|
7528
|
+
$ nodaro billing plans --json`
|
|
7529
|
+
).action(async (opts) => {
|
|
7530
|
+
try {
|
|
7531
|
+
const client = buildPublicClient({ profile: opts.profile, baseUrl: opts.baseUrl });
|
|
7532
|
+
const result = await client.billing.plans();
|
|
7533
|
+
if (opts.json) {
|
|
7534
|
+
emit(result, opts);
|
|
7535
|
+
return;
|
|
7536
|
+
}
|
|
7537
|
+
table(
|
|
7538
|
+
result.data.map((plan) => ({
|
|
7539
|
+
id: plan.id,
|
|
7540
|
+
name: plan.name,
|
|
7541
|
+
monthly: priceCell(plan, "monthly"),
|
|
7542
|
+
yearly: priceCell(plan, "yearly"),
|
|
7543
|
+
credits: creditsCell(plan),
|
|
7544
|
+
parallel: plan.parallelism,
|
|
7545
|
+
storage: storageCell(plan.storageBytes)
|
|
7546
|
+
})),
|
|
7547
|
+
["id", "name", "monthly", "yearly", "credits", "parallel", "storage"]
|
|
7548
|
+
);
|
|
7549
|
+
info("");
|
|
7550
|
+
table(
|
|
7551
|
+
result.topUps.map((pack) => ({
|
|
7552
|
+
id: pack.id,
|
|
7553
|
+
credits: pack.credits.toLocaleString("en"),
|
|
7554
|
+
price: pack.price ? money(pack.price) : "unavailable"
|
|
7555
|
+
})),
|
|
7556
|
+
["id", "credits", "price"]
|
|
7557
|
+
);
|
|
7558
|
+
const { min, max, currency } = result.topUpRange;
|
|
7559
|
+
dim(`Or load any whole amount from ${money({ amount: min, currency })} to ${money({ amount: max, currency })} in the app.`);
|
|
7560
|
+
} catch (err) {
|
|
7561
|
+
handleError(err);
|
|
7562
|
+
}
|
|
7563
|
+
});
|
|
7564
|
+
cmd.command("subscription").description("your subscription, and the plan your account's entitlements follow (Nodaro Cloud)").option("--profile <name>").option("--json").action(async (opts) => {
|
|
7565
|
+
try {
|
|
7566
|
+
const client = buildClient(opts.profile);
|
|
7567
|
+
const result = await client.billing.subscription();
|
|
7568
|
+
if (opts.json) {
|
|
7569
|
+
emit(result, opts);
|
|
7570
|
+
return;
|
|
7571
|
+
}
|
|
7572
|
+
if (!result.data) {
|
|
7573
|
+
info(`No subscription. Plan in force: ${result.effectiveTier}`);
|
|
7574
|
+
return;
|
|
7575
|
+
}
|
|
7576
|
+
detail(result);
|
|
7577
|
+
} catch (err) {
|
|
7578
|
+
handleError(err);
|
|
7579
|
+
}
|
|
7580
|
+
});
|
|
7581
|
+
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) => {
|
|
7582
|
+
try {
|
|
7583
|
+
const client = buildClient(opts.profile);
|
|
7584
|
+
const account = await client.billing.account();
|
|
7585
|
+
if (opts.json) {
|
|
7586
|
+
emit(account, opts);
|
|
7587
|
+
return;
|
|
7588
|
+
}
|
|
7589
|
+
if (account === null) {
|
|
7590
|
+
info("The billing provider could not answer right now; this is not a zero balance.");
|
|
7591
|
+
return;
|
|
7592
|
+
}
|
|
7593
|
+
detail(account);
|
|
7594
|
+
} catch (err) {
|
|
7595
|
+
handleError(err);
|
|
7596
|
+
}
|
|
7597
|
+
});
|
|
7598
|
+
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) => {
|
|
7599
|
+
try {
|
|
7600
|
+
const client = buildPublicClient({ profile: opts.profile, baseUrl: opts.baseUrl });
|
|
7601
|
+
const surface = await client.billing.surface();
|
|
7602
|
+
if (opts.json) {
|
|
7603
|
+
emit(surface, opts);
|
|
7604
|
+
return;
|
|
7605
|
+
}
|
|
7606
|
+
detail(surface);
|
|
7607
|
+
} catch (err) {
|
|
7608
|
+
handleError(err);
|
|
7609
|
+
}
|
|
7610
|
+
});
|
|
7611
|
+
return cmd;
|
|
7612
|
+
}
|
|
7613
|
+
var JOB_EVENTS = ["job.completed", "job.failed"];
|
|
7614
|
+
var DELIVERY_STATUSES = ["pending", "delivered", "failed"];
|
|
7615
|
+
function eventList(value) {
|
|
7616
|
+
if (value === void 0) return void 0;
|
|
7617
|
+
const events = value.split(/[\s,]+/).filter(Boolean);
|
|
7618
|
+
const unknown = events.filter((e) => !JOB_EVENTS.includes(e));
|
|
7619
|
+
if (unknown.length > 0) throw new Error(`unknown event ${unknown.join(", ")} \u2014 use ${JOB_EVENTS.join(" or ")}`);
|
|
7620
|
+
return events;
|
|
7621
|
+
}
|
|
7622
|
+
function printSecret(secret, what) {
|
|
7623
|
+
info("");
|
|
7624
|
+
info(`Signing secret (${what} \u2014 shown this once, store it now):`);
|
|
7625
|
+
info(` ${secret}`);
|
|
7626
|
+
info("");
|
|
7627
|
+
}
|
|
7628
|
+
function deliveryRow(d) {
|
|
7629
|
+
return {
|
|
7630
|
+
id: d.id,
|
|
7631
|
+
event: d.event,
|
|
7632
|
+
status: d.status,
|
|
7633
|
+
attempts: d.attempts,
|
|
7634
|
+
response: d.responseStatus ?? "",
|
|
7635
|
+
error: d.error ?? "",
|
|
7636
|
+
createdAt: d.createdAt
|
|
7637
|
+
};
|
|
7638
|
+
}
|
|
7639
|
+
var sleep2 = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
7640
|
+
function webhooksCommand() {
|
|
7641
|
+
const cmd = new Command("webhooks").description(
|
|
7642
|
+
"outbound webhooks: endpoints that receive your job.completed / job.failed, signed \u2014 create, rotate the secret, delivery log, test"
|
|
7643
|
+
);
|
|
7644
|
+
cmd.command("list").description("your webhook endpoints").option("--profile <name>").option("--json").action(async (opts) => {
|
|
7645
|
+
try {
|
|
7646
|
+
const client = buildClient(opts.profile);
|
|
7647
|
+
const result = await client.webhooks.list();
|
|
7648
|
+
if (opts.json) {
|
|
7649
|
+
emit(result.data, opts);
|
|
7650
|
+
return;
|
|
7651
|
+
}
|
|
7652
|
+
table(
|
|
7653
|
+
result.data.map((e) => ({
|
|
7654
|
+
id: e.id,
|
|
7655
|
+
url: e.url,
|
|
7656
|
+
events: e.events.join(","),
|
|
7657
|
+
active: e.isActive ? "yes" : e.disabledReason ? `no (${e.disabledReason})` : "no",
|
|
7658
|
+
app: e.appId ?? ""
|
|
7659
|
+
})),
|
|
7660
|
+
["id", "url", "events", "active", "app"]
|
|
7661
|
+
);
|
|
7662
|
+
} catch (err) {
|
|
7663
|
+
handleError(err);
|
|
7664
|
+
}
|
|
7665
|
+
});
|
|
7666
|
+
cmd.command("get <id>").description("show one endpoint").option("--profile <name>").option("--json").action(async (id, opts) => {
|
|
7667
|
+
try {
|
|
7668
|
+
const client = buildClient(opts.profile);
|
|
7669
|
+
const result = await client.webhooks.get(id);
|
|
7670
|
+
if (opts.json) emit(result.data, opts);
|
|
7671
|
+
else detail(result.data);
|
|
7672
|
+
} catch (err) {
|
|
7673
|
+
handleError(err);
|
|
7674
|
+
}
|
|
7675
|
+
});
|
|
7676
|
+
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) => {
|
|
7677
|
+
try {
|
|
7678
|
+
const events = eventList(opts.events);
|
|
7679
|
+
const client = buildClient(opts.profile);
|
|
7680
|
+
const result = await client.webhooks.create({ url: opts.url, events, description: opts.description });
|
|
7681
|
+
if (opts.json) {
|
|
7682
|
+
emit(result, opts);
|
|
7683
|
+
return;
|
|
7684
|
+
}
|
|
7685
|
+
success(`created webhook endpoint ${result.data.id}`);
|
|
7686
|
+
printSecret(result.secret, "new endpoint");
|
|
7687
|
+
} catch (err) {
|
|
7688
|
+
handleError(err);
|
|
7689
|
+
}
|
|
7690
|
+
});
|
|
7691
|
+
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(
|
|
7692
|
+
async (id, opts) => {
|
|
7693
|
+
try {
|
|
7694
|
+
if (opts.enable && opts.disable) throw new Error("choose one of --enable or --disable");
|
|
7695
|
+
const events = eventList(opts.events);
|
|
7696
|
+
const isActive = opts.enable ? true : opts.disable ? false : void 0;
|
|
7697
|
+
const description = opts.clearDescription ? null : opts.description;
|
|
7698
|
+
if (opts.url === void 0 && events === void 0 && isActive === void 0 && description === void 0) {
|
|
7699
|
+
throw new Error("nothing to update \u2014 provide --url, --events, --description, --clear-description, --enable or --disable");
|
|
7700
|
+
}
|
|
7701
|
+
const client = buildClient(opts.profile);
|
|
7702
|
+
const result = await client.webhooks.update(id, { url: opts.url, events, isActive, description });
|
|
7703
|
+
if (opts.json) {
|
|
7704
|
+
emit(result.data, opts);
|
|
7705
|
+
return;
|
|
7706
|
+
}
|
|
7707
|
+
success(`updated webhook endpoint ${result.data.id}`);
|
|
7708
|
+
} catch (err) {
|
|
7709
|
+
handleError(err);
|
|
7710
|
+
}
|
|
7711
|
+
}
|
|
7712
|
+
);
|
|
7713
|
+
cmd.command("delete <id>").description("delete an endpoint and its delivery log").option("--profile <name>").option("--json").action(async (id, opts) => {
|
|
7714
|
+
try {
|
|
7715
|
+
const client = buildClient(opts.profile);
|
|
7716
|
+
await client.webhooks.delete(id);
|
|
7717
|
+
if (opts.json) {
|
|
7718
|
+
emit({ success: true, id }, opts);
|
|
7719
|
+
return;
|
|
7720
|
+
}
|
|
7721
|
+
success(`deleted webhook endpoint ${id}`);
|
|
7722
|
+
} catch (err) {
|
|
7723
|
+
handleError(err);
|
|
7724
|
+
}
|
|
7725
|
+
});
|
|
7726
|
+
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) => {
|
|
7727
|
+
try {
|
|
7728
|
+
let input2 = {};
|
|
7729
|
+
if (opts.grace !== void 0) {
|
|
7730
|
+
const seconds = Number(opts.grace);
|
|
7731
|
+
if (!Number.isInteger(seconds) || seconds < 0 || seconds > 604800) {
|
|
7732
|
+
throw new Error(`--grace must be whole seconds from 0 to 604800, not ${opts.grace}`);
|
|
7733
|
+
}
|
|
7734
|
+
input2 = { gracePeriodSeconds: seconds };
|
|
7735
|
+
}
|
|
7736
|
+
const client = buildClient(opts.profile);
|
|
7737
|
+
const result = await client.webhooks.rotateSecret(id, input2);
|
|
7738
|
+
if (opts.json) {
|
|
7739
|
+
emit(result, opts);
|
|
7740
|
+
return;
|
|
7741
|
+
}
|
|
7742
|
+
success(`rotated the signing secret of ${id}`);
|
|
7743
|
+
printSecret(result.secret, "rotated");
|
|
7744
|
+
info(
|
|
7745
|
+
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."
|
|
7746
|
+
);
|
|
7747
|
+
} catch (err) {
|
|
7748
|
+
handleError(err);
|
|
7749
|
+
}
|
|
7750
|
+
});
|
|
7751
|
+
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) => {
|
|
7752
|
+
try {
|
|
7753
|
+
if (opts.status && !DELIVERY_STATUSES.includes(opts.status)) {
|
|
7754
|
+
throw new Error(`unknown status ${opts.status} \u2014 use ${DELIVERY_STATUSES.join(", ")}`);
|
|
7755
|
+
}
|
|
7756
|
+
const client = buildClient(opts.profile);
|
|
7757
|
+
const page = await client.webhooks.deliveries(id, {
|
|
7758
|
+
status: opts.status,
|
|
7759
|
+
limit: opts.limit ? Number(opts.limit) : void 0,
|
|
7760
|
+
cursor: opts.cursor
|
|
7761
|
+
});
|
|
7762
|
+
if (opts.json) {
|
|
7763
|
+
emit(page, opts);
|
|
7764
|
+
return;
|
|
7765
|
+
}
|
|
7766
|
+
table(page.data.map(deliveryRow), ["id", "event", "status", "attempts", "response", "error", "createdAt"]);
|
|
7767
|
+
if (page.next) dim(`next: --cursor ${page.next}`);
|
|
7768
|
+
} catch (err) {
|
|
7769
|
+
handleError(err);
|
|
7770
|
+
}
|
|
7771
|
+
});
|
|
7772
|
+
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) => {
|
|
7773
|
+
try {
|
|
7774
|
+
const client = buildClient(opts.profile);
|
|
7775
|
+
const queued = await client.webhooks.test(id);
|
|
7776
|
+
if (!opts.wait) {
|
|
7777
|
+
if (opts.json) emit(queued.data, opts);
|
|
7778
|
+
else success(`queued ping ${queued.data.id} \u2014 follow it with: nodaro webhooks deliveries ${id}`);
|
|
7779
|
+
return;
|
|
7780
|
+
}
|
|
7781
|
+
const interval = Math.max(1, Number(opts.pollInterval ?? 1e3) || 1e3);
|
|
7782
|
+
const deadline = Date.now() + 6e4;
|
|
7783
|
+
let last = queued.data;
|
|
7784
|
+
for (; ; ) {
|
|
7785
|
+
last = (await client.webhooks.getDelivery(id, queued.data.id)).data;
|
|
7786
|
+
if (last.status !== "pending" || Date.now() > deadline) break;
|
|
7787
|
+
await sleep2(interval);
|
|
7788
|
+
}
|
|
7789
|
+
if (opts.json) {
|
|
7790
|
+
emit(last, opts);
|
|
7791
|
+
return;
|
|
7792
|
+
}
|
|
7793
|
+
if (last.status === "delivered") success(`ping delivered: ${last.responseStatus} in ${last.durationMs ?? "?"} ms`);
|
|
7794
|
+
else if (last.status === "failed") {
|
|
7795
|
+
warn(terminalSafe(`ping failed: ${last.error ?? "no answer"}${last.responseBody ? ` \u2014 ${last.responseBody}` : ""}`));
|
|
7796
|
+
} else warn(`ping still pending after 60 s \u2014 check: nodaro webhooks deliveries ${id}`);
|
|
7797
|
+
} catch (err) {
|
|
7798
|
+
handleError(err);
|
|
7799
|
+
}
|
|
7800
|
+
});
|
|
7801
|
+
return cmd;
|
|
7802
|
+
}
|
|
6286
7803
|
|
|
6287
7804
|
// src/index.ts
|
|
6288
7805
|
function readVersion() {
|
|
@@ -6303,6 +7820,7 @@ program.addCommand(workflowsCommand());
|
|
|
6303
7820
|
program.addCommand(appsCommand());
|
|
6304
7821
|
program.addCommand(nodesCommand());
|
|
6305
7822
|
program.addCommand(jobsCommand());
|
|
7823
|
+
program.addCommand(galleryCommand());
|
|
6306
7824
|
program.addCommand(videoProCommand());
|
|
6307
7825
|
program.addCommand(executionsCommand());
|
|
6308
7826
|
program.addCommand(charactersCommand());
|
|
@@ -6313,6 +7831,8 @@ program.addCommand(audioCommand());
|
|
|
6313
7831
|
program.addCommand(presetsCommand());
|
|
6314
7832
|
program.addCommand(savedPostsCommand());
|
|
6315
7833
|
program.addCommand(collectionsCommand());
|
|
7834
|
+
program.addCommand(palettesCommand());
|
|
7835
|
+
program.addCommand(moodboardsCommand());
|
|
6316
7836
|
program.addCommand(competitorsCommand());
|
|
6317
7837
|
program.addCommand(communityCommand());
|
|
6318
7838
|
program.addCommand(pickerCatalogsCommand());
|
|
@@ -6323,6 +7843,8 @@ program.addCommand(recastCommand());
|
|
|
6323
7843
|
program.addCommand(orgCommand());
|
|
6324
7844
|
program.addCommand(workspaceCommand());
|
|
6325
7845
|
program.addCommand(editCommand());
|
|
7846
|
+
program.addCommand(billingCommand());
|
|
7847
|
+
program.addCommand(webhooksCommand());
|
|
6326
7848
|
registerLocationsCommands(program);
|
|
6327
7849
|
registerObjectsCommands(program);
|
|
6328
7850
|
program.parseAsync().catch((err) => {
|