@nodaro/cli 1.32.0 → 1.35.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 +6 -0
- package/dist/index.js +752 -147
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -2,26 +2,30 @@
|
|
|
2
2
|
import { Command, Option } from 'commander';
|
|
3
3
|
import { createInterface } from 'readline/promises';
|
|
4
4
|
import { stdout, stdin } from 'process';
|
|
5
|
-
import
|
|
5
|
+
import pc5 from 'picocolors';
|
|
6
6
|
import { writeFileSync, readFileSync, existsSync, mkdirSync, chmodSync } from 'fs';
|
|
7
7
|
import { hostname, platform, homedir } from 'os';
|
|
8
8
|
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
|
-
import { collectionRecordHeadline, parseNodePresetExport } from '@nodaro/shared/nodes';
|
|
22
23
|
import { SOCIAL_PLATFORMS, COMPETITOR_ACCOUNT_KEYS, isMeasurableCard, isSocialPost, COMPETITOR_ABOUT_PLATFORMS, COMPETITOR_SCHEDULES } from '@nodaro/shared/social';
|
|
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.35.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.33.0",
|
|
86
|
+
"@nodaro/shared": "^3.37.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",
|
|
@@ -169,20 +173,20 @@ function detail(value) {
|
|
|
169
173
|
console.log(JSON.stringify(value, null, 2));
|
|
170
174
|
}
|
|
171
175
|
function success(line) {
|
|
172
|
-
console.log(
|
|
176
|
+
console.log(pc5.green("\u2713") + " " + line);
|
|
173
177
|
}
|
|
174
178
|
function info(line) {
|
|
175
179
|
console.log(line);
|
|
176
180
|
}
|
|
177
181
|
function dim(line) {
|
|
178
|
-
console.log(
|
|
182
|
+
console.log(pc5.dim(line));
|
|
179
183
|
}
|
|
180
184
|
function warn(line) {
|
|
181
|
-
console.error(
|
|
185
|
+
console.error(pc5.yellow("\u26A0") + " " + line);
|
|
182
186
|
}
|
|
183
187
|
function table(rows2, columns) {
|
|
184
188
|
if (rows2.length === 0) {
|
|
185
|
-
console.log(
|
|
189
|
+
console.log(pc5.dim("(empty)"));
|
|
186
190
|
return;
|
|
187
191
|
}
|
|
188
192
|
const widths = {};
|
|
@@ -194,7 +198,7 @@ function table(rows2, columns) {
|
|
|
194
198
|
}
|
|
195
199
|
}
|
|
196
200
|
for (const col of columns) widths[col] = Math.min(widths[col], 60);
|
|
197
|
-
console.log(columns.map((c) =>
|
|
201
|
+
console.log(columns.map((c) => pc5.bold(c.padEnd(widths[c]))).join(" "));
|
|
198
202
|
console.log(columns.map((c) => "-".repeat(widths[c])).join(" "));
|
|
199
203
|
for (const row of rows2) {
|
|
200
204
|
console.log(
|
|
@@ -358,7 +362,7 @@ function authCommand() {
|
|
|
358
362
|
if (opts.json) {
|
|
359
363
|
emit({ profile: name, baseUrl: profile.baseUrl, tokenMasked: maskToken(profile.token), signedIn: true }, opts);
|
|
360
364
|
} else {
|
|
361
|
-
info(`profile: ${
|
|
365
|
+
info(`profile: ${pc5.cyan(name)}`);
|
|
362
366
|
info(`baseUrl: ${profile.baseUrl}`);
|
|
363
367
|
info(`token: ${maskToken(profile.token)}`);
|
|
364
368
|
}
|
|
@@ -409,7 +413,7 @@ function saveWorkspace(profileName, workspaceId) {
|
|
|
409
413
|
}
|
|
410
414
|
|
|
411
415
|
// src/client.ts
|
|
412
|
-
var CLI_VERSION = "1.
|
|
416
|
+
var CLI_VERSION = "1.35.0" ;
|
|
413
417
|
function buildPublicClient(opts = {}) {
|
|
414
418
|
const { profile } = getProfile(opts.profile);
|
|
415
419
|
return createClient({
|
|
@@ -421,8 +425,8 @@ function buildPublicClient(opts = {}) {
|
|
|
421
425
|
function buildClient(profileName) {
|
|
422
426
|
const { name, profile } = getProfile(profileName);
|
|
423
427
|
if (!profile) {
|
|
424
|
-
console.error(
|
|
425
|
-
console.error(
|
|
428
|
+
console.error(pc5.red(`\u2717 no credentials for profile "${name}"`));
|
|
429
|
+
console.error(pc5.dim(` run: nodaro auth login${profileName ? ` --profile ${profileName}` : ""}`));
|
|
426
430
|
process.exit(1);
|
|
427
431
|
}
|
|
428
432
|
const { workspaceId } = resolveWorkspace(profile);
|
|
@@ -439,20 +443,20 @@ function buildClient(profileName) {
|
|
|
439
443
|
}
|
|
440
444
|
function handleError(err) {
|
|
441
445
|
if (err instanceof UnauthorizedError) {
|
|
442
|
-
console.error(
|
|
443
|
-
console.error(
|
|
446
|
+
console.error(pc5.red("\u2717 unauthorized \u2014 token missing, expired, or invalid"));
|
|
447
|
+
console.error(pc5.dim(" run: nodaro auth login"));
|
|
444
448
|
process.exit(1);
|
|
445
449
|
}
|
|
446
450
|
if (err instanceof NodaroError) {
|
|
447
|
-
console.error(
|
|
448
|
-
if (err.code) console.error(
|
|
451
|
+
console.error(pc5.red(`\u2717 ${err.message}`));
|
|
452
|
+
if (err.code) console.error(pc5.dim(` code: ${err.code}`));
|
|
449
453
|
process.exit(1);
|
|
450
454
|
}
|
|
451
455
|
if (err instanceof Error) {
|
|
452
|
-
console.error(
|
|
456
|
+
console.error(pc5.red(`\u2717 ${err.message}`));
|
|
453
457
|
process.exit(1);
|
|
454
458
|
}
|
|
455
|
-
console.error(
|
|
459
|
+
console.error(pc5.red("\u2717 unknown error"), err);
|
|
456
460
|
process.exit(1);
|
|
457
461
|
}
|
|
458
462
|
|
|
@@ -626,14 +630,15 @@ function sessionsCommand() {
|
|
|
626
630
|
handleError(err);
|
|
627
631
|
}
|
|
628
632
|
});
|
|
629
|
-
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) => {
|
|
630
634
|
try {
|
|
631
635
|
const title = opts.untitled ? null : opts.title;
|
|
632
636
|
const archived = opts.archive ? true : opts.unarchive ? false : void 0;
|
|
633
|
-
|
|
634
|
-
|
|
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");
|
|
635
640
|
}
|
|
636
|
-
const result = await buildClient(opts.profile).sessions.update(id, { title, archived });
|
|
641
|
+
const result = await buildClient(opts.profile).sessions.update(id, { title, archived, coverJobId });
|
|
637
642
|
if (opts.json) {
|
|
638
643
|
emit(result.data, opts);
|
|
639
644
|
return;
|
|
@@ -849,6 +854,25 @@ function elapsed(startMs) {
|
|
|
849
854
|
function sleep(ms) {
|
|
850
855
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
851
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
|
+
}
|
|
852
876
|
|
|
853
877
|
// src/commands/workflows.ts
|
|
854
878
|
function readJsonObject(path, flag) {
|
|
@@ -869,6 +893,52 @@ function readJsonObject(path, flag) {
|
|
|
869
893
|
}
|
|
870
894
|
return parsed;
|
|
871
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
|
+
}
|
|
872
942
|
function workflowsCommand() {
|
|
873
943
|
const cmd = new Command("workflows").description("list, run, and manage workflows");
|
|
874
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) => {
|
|
@@ -986,16 +1056,94 @@ function workflowsCommand() {
|
|
|
986
1056
|
handleError(err);
|
|
987
1057
|
}
|
|
988
1058
|
});
|
|
989
|
-
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) => {
|
|
990
1123
|
try {
|
|
991
1124
|
const client = buildClient(opts.profile);
|
|
992
|
-
const
|
|
993
|
-
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);
|
|
994
1142
|
if (opts.json && !opts.watch) {
|
|
995
1143
|
emit(result, opts);
|
|
996
1144
|
return;
|
|
997
1145
|
}
|
|
998
|
-
success(`execution ${result.executionId} (${result.status})`);
|
|
1146
|
+
success(`execution ${result.executionId} (${result.status}) \u2014 Render final of ${renderNodeId}`);
|
|
999
1147
|
if (!opts.watch) {
|
|
1000
1148
|
dim(`follow: nodaro executions get ${result.executionId} --watch`);
|
|
1001
1149
|
return;
|
|
@@ -1476,24 +1624,31 @@ function rejectPositionalInputs(extras, slug) {
|
|
|
1476
1624
|
}
|
|
1477
1625
|
process.exit(1);
|
|
1478
1626
|
}
|
|
1479
|
-
function
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
const
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
try {
|
|
1491
|
-
value = JSON.parse(raw);
|
|
1492
|
-
} 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}`);
|
|
1493
1638
|
}
|
|
1494
|
-
|
|
1639
|
+
return lines;
|
|
1495
1640
|
}
|
|
1496
|
-
|
|
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 [];
|
|
1497
1652
|
}
|
|
1498
1653
|
function appsCommand() {
|
|
1499
1654
|
const cmd = new Command("apps").description("browse and run published apps (workflows wrapped in a curated UI)");
|
|
@@ -1596,6 +1751,52 @@ Tip: \`nodaro apps get <slug>\` shows the input schema for that app.`).action(as
|
|
|
1596
1751
|
handleError(err);
|
|
1597
1752
|
}
|
|
1598
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
|
+
});
|
|
1599
1800
|
return cmd;
|
|
1600
1801
|
}
|
|
1601
1802
|
var BATCH_NODE_TYPE = "generate-image";
|
|
@@ -3428,6 +3629,29 @@ names).`).action(
|
|
|
3428
3629
|
}
|
|
3429
3630
|
}
|
|
3430
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
|
+
});
|
|
3431
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", `
|
|
3432
3656
|
Examples:
|
|
3433
3657
|
$ nodaro media video-mask https://x/dance.mp4 "the dancer" --watch
|
|
@@ -3826,15 +4050,15 @@ function presetsCommand() {
|
|
|
3826
4050
|
const cmd = new Command("presets").description(
|
|
3827
4051
|
"node presets \u2014 your own (create, update, delete, import, favorites, folders) plus the built-in factory catalog"
|
|
3828
4052
|
);
|
|
3829
|
-
cmd.command("list").description("list your custom presets (or the built-in factory catalog with --factory)").option("--node-type <type>", "filter to one node type, e.g. generate-image").option("--factory", "list the built-in factory catalog instead of your custom presets").option("--profile <name>").option("--json").action(async (opts) => {
|
|
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) => {
|
|
3830
4054
|
try {
|
|
3831
|
-
const client = buildClient(opts.profile);
|
|
3832
4055
|
if (opts.factory) {
|
|
3833
4056
|
if (!opts.nodeType) {
|
|
3834
4057
|
handleError(new Error("--node-type is required with --factory (e.g. --node-type generate-image)"));
|
|
3835
4058
|
return;
|
|
3836
4059
|
}
|
|
3837
|
-
const
|
|
4060
|
+
const client2 = buildPublicClient({ profile: opts.profile, baseUrl: opts.baseUrl });
|
|
4061
|
+
const result = await client2.presets.listFactory(opts.nodeType);
|
|
3838
4062
|
if (opts.json) {
|
|
3839
4063
|
emit(result, opts);
|
|
3840
4064
|
return;
|
|
@@ -3851,6 +4075,10 @@ function presetsCommand() {
|
|
|
3851
4075
|
);
|
|
3852
4076
|
return;
|
|
3853
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);
|
|
3854
4082
|
const presets = await client.presets.list(opts.nodeType);
|
|
3855
4083
|
if (opts.json) {
|
|
3856
4084
|
emit(presets, opts);
|
|
@@ -6548,7 +6776,7 @@ function workspaceCommand() {
|
|
|
6548
6776
|
emit({ profile: name, workspaceId: workspaceId ?? null, source }, opts);
|
|
6549
6777
|
return;
|
|
6550
6778
|
}
|
|
6551
|
-
info(`profile: ${
|
|
6779
|
+
info(`profile: ${pc5.cyan(name)}`);
|
|
6552
6780
|
info(`workspace: ${workspaceId ?? "(personal space)"}`);
|
|
6553
6781
|
if (!profile) {
|
|
6554
6782
|
warn(`no credentials for profile "${name}" \u2014 run: nodaro auth login`);
|
|
@@ -6712,14 +6940,6 @@ var SOURCE_LABELS = {
|
|
|
6712
6940
|
profile: "the profile's saved workspace",
|
|
6713
6941
|
none: "nothing \u2014 the personal space"
|
|
6714
6942
|
};
|
|
6715
|
-
function isEditPlanMode(v) {
|
|
6716
|
-
return EDIT_PLAN_MODES.includes(v);
|
|
6717
|
-
}
|
|
6718
|
-
var CONTINUATION_NEXT_STEP = {
|
|
6719
|
-
already_running: (id) => ` \u2014 follow it: nodaro jobs get ${id}`,
|
|
6720
|
-
continuation_superseded: (id) => ` \u2014 continue that one: nodaro edit continue-use-case ${id} --mode from-failed`,
|
|
6721
|
-
render_final_already_rendered: (id) => ` \u2014 its result is the one to use: nodaro jobs get ${id}`
|
|
6722
|
-
};
|
|
6723
6943
|
function readJsonFile2(path) {
|
|
6724
6944
|
let raw;
|
|
6725
6945
|
try {
|
|
@@ -6733,6 +6953,442 @@ function readJsonFile2(path) {
|
|
|
6733
6953
|
throw new Error(`${path} is not valid JSON: ${err.message}`);
|
|
6734
6954
|
}
|
|
6735
6955
|
}
|
|
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);
|
|
6960
|
+
}
|
|
6961
|
+
}
|
|
6962
|
+
|
|
6963
|
+
// src/commands/edit-recordings.ts
|
|
6964
|
+
function withRecordingsOptions(cmd) {
|
|
6965
|
+
return cmd.requiredOption(
|
|
6966
|
+
"--media <url>",
|
|
6967
|
+
"the recording (video or audio URL, up to 3 hours); repeat it for the cameras of one conversation, in order (several need Speaker Map)",
|
|
6968
|
+
collectVariadic
|
|
6969
|
+
).option("--master-audio <url>", "the mixer or recorder track: the episode's sound and the clock the recordings are lined up to (needs Speaker Map)").option("--wide-camera <n>", "with several recordings: which --media (1-based) is the wide shot").option("--synced", "with several recordings: they already share one clock, skip lining them up").option(
|
|
6970
|
+
"--speaker-camera <speaker=recording>",
|
|
6971
|
+
"with several recordings: put a speaker (1 = the first voice heard) on a --media number, 0 = the wide shot (repeatable)",
|
|
6972
|
+
collectVariadic
|
|
6973
|
+
);
|
|
6974
|
+
}
|
|
6975
|
+
var WHOLE = /^\d+$/;
|
|
6976
|
+
function recordingsInput(opts) {
|
|
6977
|
+
const several = opts.media.length > 1 || opts.masterAudio !== void 0;
|
|
6978
|
+
const cameraFlags = opts.wideCamera !== void 0 || opts.synced === true || (opts.speakerCamera?.length ?? 0) > 0;
|
|
6979
|
+
if (cameraFlags && !several) {
|
|
6980
|
+
warn("--wide-camera, --synced and --speaker-camera apply with several --media or --master-audio only");
|
|
6981
|
+
process.exit(1);
|
|
6982
|
+
}
|
|
6983
|
+
let wide;
|
|
6984
|
+
if (opts.wideCamera !== void 0) {
|
|
6985
|
+
if (!WHOLE.test(opts.wideCamera) || Number(opts.wideCamera) < 1) {
|
|
6986
|
+
warn(`--wide-camera must be a recording number, 1 or more (got "${opts.wideCamera}")`);
|
|
6987
|
+
process.exit(1);
|
|
6988
|
+
}
|
|
6989
|
+
wide = Number(opts.wideCamera);
|
|
6990
|
+
}
|
|
6991
|
+
const speakerCameras = {};
|
|
6992
|
+
for (const pair of opts.speakerCamera ?? []) {
|
|
6993
|
+
const [speaker, recording, ...extra] = pair.split("=");
|
|
6994
|
+
if (extra.length > 0 || !speaker || !recording || !WHOLE.test(speaker) || !WHOLE.test(recording) || Number(speaker) < 1) {
|
|
6995
|
+
warn(`--speaker-camera must be <speaker>=<recording>: a speaker 1 or more, a --media number or 0 for the wide shot (got "${pair}")`);
|
|
6996
|
+
process.exit(1);
|
|
6997
|
+
}
|
|
6998
|
+
const key2 = String(Number(speaker));
|
|
6999
|
+
if (key2 in speakerCameras) {
|
|
7000
|
+
warn(`--speaker-camera names speaker ${key2} twice`);
|
|
7001
|
+
process.exit(1);
|
|
7002
|
+
}
|
|
7003
|
+
speakerCameras[key2] = Number(recording);
|
|
7004
|
+
}
|
|
7005
|
+
const cameras = {
|
|
7006
|
+
...wide !== void 0 ? { wide } : {},
|
|
7007
|
+
...opts.synced ? { synced: true } : {},
|
|
7008
|
+
...Object.keys(speakerCameras).length > 0 ? { speakerCameras } : {}
|
|
7009
|
+
};
|
|
7010
|
+
return {
|
|
7011
|
+
// One --media is the one-recording request it always was.
|
|
7012
|
+
...opts.media.length === 1 ? { mediaUrl: opts.media[0] } : { mediaUrls: [...opts.media] },
|
|
7013
|
+
...opts.masterAudio !== void 0 ? { masterAudioUrl: opts.masterAudio } : {},
|
|
7014
|
+
...Object.keys(cameras).length > 0 ? { cameras } : {}
|
|
7015
|
+
};
|
|
7016
|
+
}
|
|
7017
|
+
|
|
7018
|
+
// src/commands/edit-use-case.ts
|
|
7019
|
+
var EMPHASIS_HELP = `none, or ${SPEAKER_EMPHASIS_STYLES.filter((s) => s !== "none").join(", ")} joined with "+" (each once)`;
|
|
7020
|
+
var CONTINUATION_NEXT_STEP = {
|
|
7021
|
+
already_running: (id) => ` \u2014 follow it: nodaro jobs get ${id}`,
|
|
7022
|
+
continuation_superseded: (id) => ` \u2014 continue that one: nodaro edit continue-use-case ${id} --mode from-failed`,
|
|
7023
|
+
render_final_already_rendered: (id) => ` \u2014 its result is the one to use: nodaro jobs get ${id}`
|
|
7024
|
+
};
|
|
7025
|
+
function registerUseCaseCommands(cmd) {
|
|
7026
|
+
const framingLayouts = ["auto", ...SPEAKER_LAYOUT_IDS];
|
|
7027
|
+
const FRAMING_SOURCES = Object.keys({ auto: true, static: true, tracking: true });
|
|
7028
|
+
withRecordingsOptions(
|
|
7029
|
+
cmd.command("tighten-episode").description("tighten a podcast recording in one step (transcribe, cut silences, render; optional captions, music and framing)")
|
|
7030
|
+
).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(
|
|
7031
|
+
"--framing-source <source>",
|
|
7032
|
+
`with --framing, how it follows the speakers: ${FRAMING_SOURCES.join(" | ")} (default static: the even split; tracking follows faces with Speaker Frames, charged per started block of 1,000 sampled frames; auto follows faces while Speaker Frames is available to you)`
|
|
7033
|
+
).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(
|
|
7034
|
+
async (opts, command) => {
|
|
7035
|
+
if (opts.output !== void 0 && opts.output !== "video" && opts.output !== "audio") {
|
|
7036
|
+
warn(`--output must be "video" or "audio" (got "${opts.output}")`);
|
|
7037
|
+
process.exit(1);
|
|
7038
|
+
}
|
|
7039
|
+
refuseUnknownPlanTier(opts.planTier);
|
|
7040
|
+
if (opts.framing !== void 0 && !EDL_TARGET_ASPECTS.includes(opts.framing)) {
|
|
7041
|
+
warn(`--framing must be ${EDL_TARGET_ASPECTS.join(", ")} (got "${opts.framing}")`);
|
|
7042
|
+
process.exit(1);
|
|
7043
|
+
}
|
|
7044
|
+
if (opts.layout !== void 0 && opts.framing === void 0) {
|
|
7045
|
+
warn("--layout applies with --framing only (it picks the framed layout)");
|
|
7046
|
+
process.exit(1);
|
|
7047
|
+
}
|
|
7048
|
+
if (opts.layout !== void 0 && !framingLayouts.includes(opts.layout)) {
|
|
7049
|
+
warn(`--layout must be ${framingLayouts.join(", ")} (got "${opts.layout}")`);
|
|
7050
|
+
process.exit(1);
|
|
7051
|
+
}
|
|
7052
|
+
if (opts.framingSource !== void 0 && opts.framing === void 0) {
|
|
7053
|
+
warn("--framing-source applies with --framing only (it picks how the framing follows the speakers)");
|
|
7054
|
+
process.exit(1);
|
|
7055
|
+
}
|
|
7056
|
+
if (opts.framingSource !== void 0 && !FRAMING_SOURCES.includes(opts.framingSource)) {
|
|
7057
|
+
warn(`--framing-source must be ${FRAMING_SOURCES.join(", ")} (got "${opts.framingSource}")`);
|
|
7058
|
+
process.exit(1);
|
|
7059
|
+
}
|
|
7060
|
+
const recordings = recordingsInput(opts);
|
|
7061
|
+
try {
|
|
7062
|
+
const client = buildClient(opts.profile);
|
|
7063
|
+
const result = await client.edit.tightenEpisode({
|
|
7064
|
+
...recordings,
|
|
7065
|
+
...opts.music ? { musicUrl: opts.music } : {},
|
|
7066
|
+
...opts.output ? { output: opts.output } : {},
|
|
7067
|
+
...opts.framing ? { framing: { aspect: opts.framing, layout: opts.layout ?? "auto" } } : {},
|
|
7068
|
+
...opts.framingSource ? { framingSource: opts.framingSource } : {},
|
|
7069
|
+
// commander's --no-captions defaults `captions` to true: send it only when turned off.
|
|
7070
|
+
...opts.captions === false ? { captions: false } : {},
|
|
7071
|
+
...opts.review ? { reviewBeforeRender: true } : {},
|
|
7072
|
+
...opts.planTier ? { planTier: opts.planTier } : {},
|
|
7073
|
+
...opts.instructions ? { instructions: opts.instructions } : {}
|
|
7074
|
+
});
|
|
7075
|
+
await reportQueuedJob(result, () => client.jobs.getStatus(result.jobId), {
|
|
7076
|
+
json: opts.json,
|
|
7077
|
+
watch: opts.watch,
|
|
7078
|
+
pollInterval: opts.pollInterval,
|
|
7079
|
+
note: command.name()
|
|
7080
|
+
});
|
|
7081
|
+
} catch (err) {
|
|
7082
|
+
handleError(err);
|
|
7083
|
+
}
|
|
7084
|
+
}
|
|
7085
|
+
);
|
|
7086
|
+
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(
|
|
7087
|
+
async (opts, command) => {
|
|
7088
|
+
refuseUnknownPlanTier(opts.planTier);
|
|
7089
|
+
try {
|
|
7090
|
+
const client = buildClient(opts.profile);
|
|
7091
|
+
const result = await client.edit.episodeChapters(
|
|
7092
|
+
{
|
|
7093
|
+
mediaUrl: opts.media,
|
|
7094
|
+
...opts.planTier ? { planTier: opts.planTier } : {},
|
|
7095
|
+
...opts.instructions ? { instructions: opts.instructions } : {},
|
|
7096
|
+
...opts.styleGuide ? { styleGuide: opts.styleGuide } : {}
|
|
7097
|
+
},
|
|
7098
|
+
opts.idempotencyKey ? { idempotencyKey: opts.idempotencyKey } : void 0
|
|
7099
|
+
);
|
|
7100
|
+
const done = await reportQueuedJob(result, () => client.jobs.getStatus(result.jobId), {
|
|
7101
|
+
json: opts.json,
|
|
7102
|
+
watch: opts.watch,
|
|
7103
|
+
pollInterval: opts.pollInterval,
|
|
7104
|
+
note: command.name()
|
|
7105
|
+
});
|
|
7106
|
+
const text = done?.data.output_data?.text;
|
|
7107
|
+
if (!opts.json && done?.data.status === "completed" && typeof text === "string" && text.length > 0) console.log(text);
|
|
7108
|
+
} catch (err) {
|
|
7109
|
+
handleError(err);
|
|
7110
|
+
}
|
|
7111
|
+
}
|
|
7112
|
+
);
|
|
7113
|
+
withRecordingsOptions(
|
|
7114
|
+
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")
|
|
7115
|
+
).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(
|
|
7116
|
+
async (opts) => {
|
|
7117
|
+
const formats = opts.formats?.split(",").map((f) => f.trim()).filter((f) => f.length > 0);
|
|
7118
|
+
if (formats !== void 0 && (formats.length === 0 || formats.some((f) => !TRAILER_FORMATS.includes(f)))) {
|
|
7119
|
+
warn(`--formats must be one or more of ${TRAILER_FORMATS.join(", ")}, comma-separated (got "${opts.formats}")`);
|
|
7120
|
+
process.exit(1);
|
|
7121
|
+
}
|
|
7122
|
+
refuseUnknownPlanTier(opts.planTier);
|
|
7123
|
+
const recordings = recordingsInput(opts);
|
|
7124
|
+
try {
|
|
7125
|
+
const client = buildClient(opts.profile);
|
|
7126
|
+
const result = await client.edit.episodeTrailer(
|
|
7127
|
+
{
|
|
7128
|
+
...recordings,
|
|
7129
|
+
...opts.introCard ? { introCardUrl: opts.introCard } : {},
|
|
7130
|
+
...formats ? { formats } : {},
|
|
7131
|
+
...opts.review ? { reviewBeforeRender: true } : {},
|
|
7132
|
+
...opts.planTier ? { planTier: opts.planTier } : {},
|
|
7133
|
+
...opts.instructions ? { instructions: opts.instructions } : {},
|
|
7134
|
+
...opts.styleGuide ? { styleGuide: opts.styleGuide } : {}
|
|
7135
|
+
},
|
|
7136
|
+
opts.idempotencyKey ? { idempotencyKey: opts.idempotencyKey } : void 0
|
|
7137
|
+
);
|
|
7138
|
+
const done = await reportQueuedJob(result, () => client.jobs.getStatus(result.jobId), {
|
|
7139
|
+
json: opts.json,
|
|
7140
|
+
watch: opts.watch,
|
|
7141
|
+
pollInterval: opts.pollInterval,
|
|
7142
|
+
note: "episode-trailer"
|
|
7143
|
+
});
|
|
7144
|
+
if (opts.json) return;
|
|
7145
|
+
const out = done?.data.output_data;
|
|
7146
|
+
if (done?.data.status === "completed" && Array.isArray(out?.formats)) {
|
|
7147
|
+
for (const f of out.formats) {
|
|
7148
|
+
if (typeof f?.format === "string" && typeof f.url === "string") console.log(`${f.format} ${f.url}`);
|
|
7149
|
+
}
|
|
7150
|
+
const failed = Array.isArray(out.failedFormats) ? out.failedFormats.filter((f) => typeof f === "string") : [];
|
|
7151
|
+
if (failed.length > 0) console.log(`Could not render: ${failed.join(", ")}`);
|
|
7152
|
+
}
|
|
7153
|
+
if (opts.review) console.log(pc5.dim(` render every format after your review: nodaro edit continue-use-case ${result.jobId} --mode render-final`));
|
|
7154
|
+
} catch (err) {
|
|
7155
|
+
handleError(err);
|
|
7156
|
+
}
|
|
7157
|
+
}
|
|
7158
|
+
);
|
|
7159
|
+
const isWhole = (v, min, max) => v !== void 0 && /^\d+$/.test(v.trim()) && Number(v) >= min && Number(v) <= max;
|
|
7160
|
+
withRecordingsOptions(
|
|
7161
|
+
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; several cameras cut to the speaker in every clip)")
|
|
7162
|
+
).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(
|
|
7163
|
+
"--framing-source <source>",
|
|
7164
|
+
`how the framing follows the speakers (not with --framing none): ${FRAMING_SOURCES.join(" | ")} (default static: the even split; tracking follows faces with one Speaker Frames run over the whole pack, charged per started block of 1,000 sampled frames; auto follows faces while Speaker Frames is available to you)`
|
|
7165
|
+
).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(
|
|
7166
|
+
async (opts) => {
|
|
7167
|
+
if (opts.count !== void 0 && !isWhole(opts.count, 1, EDIT_PLAN_MAX_CLIP_COUNT)) {
|
|
7168
|
+
warn(`--count must be 1\u2013${EDIT_PLAN_MAX_CLIP_COUNT} (got "${opts.count}")`);
|
|
7169
|
+
process.exit(1);
|
|
7170
|
+
}
|
|
7171
|
+
if (opts.length !== void 0 && !isWhole(opts.length, CLIP_PACK_MIN_TARGET_SEC, CLIP_PACK_MAX_TARGET_SEC)) {
|
|
7172
|
+
warn(`--length must be ${CLIP_PACK_MIN_TARGET_SEC}\u2013${CLIP_PACK_MAX_TARGET_SEC} seconds (got "${opts.length}")`);
|
|
7173
|
+
process.exit(1);
|
|
7174
|
+
}
|
|
7175
|
+
if (opts.framing !== void 0 && opts.framing !== "none" && !EDL_TARGET_ASPECTS.includes(opts.framing)) {
|
|
7176
|
+
warn(`--framing must be ${EDL_TARGET_ASPECTS.join(", ")} or none (got "${opts.framing}")`);
|
|
7177
|
+
process.exit(1);
|
|
7178
|
+
}
|
|
7179
|
+
if (opts.layout !== void 0 && (opts.framing === void 0 || opts.framing === "none")) {
|
|
7180
|
+
warn("--layout applies with --framing <aspect> only (it picks the framed layout)");
|
|
7181
|
+
process.exit(1);
|
|
7182
|
+
}
|
|
7183
|
+
if (opts.layout !== void 0 && !framingLayouts.includes(opts.layout)) {
|
|
7184
|
+
warn(`--layout must be ${framingLayouts.join(", ")} (got "${opts.layout}")`);
|
|
7185
|
+
process.exit(1);
|
|
7186
|
+
}
|
|
7187
|
+
for (const [flag, value] of [["--switch", opts.switch], ["--emphasis", opts.emphasis]]) {
|
|
7188
|
+
if (value !== void 0 && (opts.framing === void 0 || opts.framing === "none")) {
|
|
7189
|
+
warn(`${flag} applies with --framing <aspect> only (it is part of the framing)`);
|
|
7190
|
+
process.exit(1);
|
|
7191
|
+
}
|
|
7192
|
+
}
|
|
7193
|
+
if (opts.switch !== void 0 && !SPEAKER_SWITCH_IDS.includes(opts.switch)) {
|
|
7194
|
+
warn(`--switch must be one of ${SPEAKER_SWITCH_IDS.join(", ")} (got "${opts.switch}")`);
|
|
7195
|
+
process.exit(1);
|
|
7196
|
+
}
|
|
7197
|
+
if (opts.emphasis !== void 0 && !isKnownSpeakerEmphasisStyle(opts.emphasis)) {
|
|
7198
|
+
warn(`--emphasis must be ${EMPHASIS_HELP} (got "${opts.emphasis}")`);
|
|
7199
|
+
process.exit(1);
|
|
7200
|
+
}
|
|
7201
|
+
if (opts.framingSource !== void 0 && opts.framing === "none") {
|
|
7202
|
+
warn("--framing-source applies with a framing only (not with --framing none)");
|
|
7203
|
+
process.exit(1);
|
|
7204
|
+
}
|
|
7205
|
+
if (opts.framingSource !== void 0 && !FRAMING_SOURCES.includes(opts.framingSource)) {
|
|
7206
|
+
warn(`--framing-source must be ${FRAMING_SOURCES.join(", ")} (got "${opts.framingSource}")`);
|
|
7207
|
+
process.exit(1);
|
|
7208
|
+
}
|
|
7209
|
+
if (opts.captionStyle !== void 0 && opts.captions === false) {
|
|
7210
|
+
warn("--caption-style applies with captions on (drop --no-captions)");
|
|
7211
|
+
process.exit(1);
|
|
7212
|
+
}
|
|
7213
|
+
if (opts.captionStyle !== void 0 && !ALL_CAPTION_STYLES.includes(opts.captionStyle)) {
|
|
7214
|
+
warn(`--caption-style must be ${ALL_CAPTION_STYLES.join(", ")} (got "${opts.captionStyle}")`);
|
|
7215
|
+
process.exit(1);
|
|
7216
|
+
}
|
|
7217
|
+
refuseUnknownPlanTier(opts.planTier);
|
|
7218
|
+
const recordings = recordingsInput(opts);
|
|
7219
|
+
try {
|
|
7220
|
+
const client = buildClient(opts.profile);
|
|
7221
|
+
const result = await client.edit.clipPack(
|
|
7222
|
+
{
|
|
7223
|
+
...recordings,
|
|
7224
|
+
...opts.count !== void 0 ? { count: Number(opts.count) } : {},
|
|
7225
|
+
...opts.length !== void 0 ? { targetDurationSec: Number(opts.length) } : {},
|
|
7226
|
+
// none = the recording's shape; an aspect alone leaves the layout to the route (stacked).
|
|
7227
|
+
...opts.framing === "none" ? { framing: null } : opts.framing ? {
|
|
7228
|
+
framing: {
|
|
7229
|
+
aspect: opts.framing,
|
|
7230
|
+
...opts.layout ? { layout: opts.layout } : {},
|
|
7231
|
+
...opts.switch ? { switchType: opts.switch } : {},
|
|
7232
|
+
...opts.emphasis ? { emphasisStyle: opts.emphasis } : {}
|
|
7233
|
+
}
|
|
7234
|
+
} : {},
|
|
7235
|
+
...opts.framingSource ? { framingSource: opts.framingSource } : {},
|
|
7236
|
+
// commander's --no-captions defaults `captions` to true: send it only when turned off.
|
|
7237
|
+
...opts.captions === false ? { captions: false } : {},
|
|
7238
|
+
...opts.captionStyle ? { captionStyle: opts.captionStyle } : {},
|
|
7239
|
+
...opts.review ? { reviewBeforeRender: true } : {},
|
|
7240
|
+
...opts.planTier ? { planTier: opts.planTier } : {},
|
|
7241
|
+
...opts.instructions ? { instructions: opts.instructions } : {},
|
|
7242
|
+
...opts.styleGuide ? { styleGuide: opts.styleGuide } : {}
|
|
7243
|
+
},
|
|
7244
|
+
opts.idempotencyKey ? { idempotencyKey: opts.idempotencyKey } : void 0
|
|
7245
|
+
);
|
|
7246
|
+
const done = await reportQueuedJob(result, () => client.jobs.getStatus(result.jobId), {
|
|
7247
|
+
json: opts.json,
|
|
7248
|
+
watch: opts.watch,
|
|
7249
|
+
pollInterval: opts.pollInterval,
|
|
7250
|
+
note: "clip-pack"
|
|
7251
|
+
});
|
|
7252
|
+
if (opts.json) return;
|
|
7253
|
+
const out = done?.data.output_data;
|
|
7254
|
+
if (done?.data.status === "completed" && Array.isArray(out?.clips)) {
|
|
7255
|
+
;
|
|
7256
|
+
out.clips.forEach((c, i) => {
|
|
7257
|
+
if (typeof c?.url !== "string") return;
|
|
7258
|
+
const note = [typeof c.title === "string" ? c.title : "", c.captionsFailed === true ? "(no captions)" : ""].filter(Boolean).join(" ");
|
|
7259
|
+
console.log(`${i + 1} ${c.url}${note ? ` ${note}` : ""}`);
|
|
7260
|
+
});
|
|
7261
|
+
const failed = typeof out.failedClips === "number" && out.failedClips > 0 ? out.failedClips : 0;
|
|
7262
|
+
if (failed > 0) console.log(failed === 1 ? "1 clip could not be rendered." : `${failed} clips could not be rendered.`);
|
|
7263
|
+
}
|
|
7264
|
+
if (opts.review) console.log(pc5.dim(` render the kept clips after your review: nodaro edit continue-use-case ${result.jobId} --mode render-final [--edit <file>]`));
|
|
7265
|
+
} catch (err) {
|
|
7266
|
+
handleError(err);
|
|
7267
|
+
}
|
|
7268
|
+
}
|
|
7269
|
+
);
|
|
7270
|
+
const LAYOUT_FRAMING_SOURCES = Object.keys({ auto: true, static: true, tracking: true });
|
|
7271
|
+
withRecordingsOptions(
|
|
7272
|
+
cmd.command("speaker-layout").description("frame a whole recording by speaker in one step \u2014 the same length, nothing cut (several recordings: each speaker on their own camera)")
|
|
7273
|
+
).option("--aspect <aspect>", `the video's shape (default 9:16): ${EDL_TARGET_ASPECTS.join(" | ")}`).option("--layout <layout>", `how the speakers are laid out (default stacked): ${framingLayouts.join(" | ")}`).option("--switch <id>", "the switch at each speaker change (default cut): cut | pan | zoom | xfade:<transition>, e.g. xfade:fade").option("--emphasis <style>", `how the speaker talking is emphasised (default scale): ${EMPHASIS_HELP}`).option(
|
|
7274
|
+
"--framing-source <source>",
|
|
7275
|
+
`how the speakers are followed: ${LAYOUT_FRAMING_SOURCES.join(" | ")} (default auto: follows faces with Speaker Frames while it is available to you, else the even split; static: the even split; tracking: follows faces, charged per started block of 1,000 sampled frames)`
|
|
7276
|
+
).option("--review", "stop at a preview to review (render the final with `nodaro edit continue-use-case <jobId> --mode render-final`)").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 framed video's URL").option("--poll-interval <ms>", "poll interval with --watch", (v) => parseInt(v, 10)).option("--profile <name>").option("--json").action(
|
|
7277
|
+
async (opts) => {
|
|
7278
|
+
if (opts.aspect !== void 0 && !EDL_TARGET_ASPECTS.includes(opts.aspect)) {
|
|
7279
|
+
warn(`--aspect must be ${EDL_TARGET_ASPECTS.join(", ")} (got "${opts.aspect}")`);
|
|
7280
|
+
process.exit(1);
|
|
7281
|
+
}
|
|
7282
|
+
if (opts.layout !== void 0 && !framingLayouts.includes(opts.layout)) {
|
|
7283
|
+
warn(`--layout must be ${framingLayouts.join(", ")} (got "${opts.layout}")`);
|
|
7284
|
+
process.exit(1);
|
|
7285
|
+
}
|
|
7286
|
+
if (opts.switch !== void 0 && !SPEAKER_SWITCH_IDS.includes(opts.switch)) {
|
|
7287
|
+
warn(`--switch must be one of ${SPEAKER_SWITCH_IDS.join(", ")} (got "${opts.switch}")`);
|
|
7288
|
+
process.exit(1);
|
|
7289
|
+
}
|
|
7290
|
+
if (opts.emphasis !== void 0 && !isKnownSpeakerEmphasisStyle(opts.emphasis)) {
|
|
7291
|
+
warn(`--emphasis must be ${EMPHASIS_HELP} (got "${opts.emphasis}")`);
|
|
7292
|
+
process.exit(1);
|
|
7293
|
+
}
|
|
7294
|
+
if (opts.framingSource !== void 0 && !LAYOUT_FRAMING_SOURCES.includes(opts.framingSource)) {
|
|
7295
|
+
warn(`--framing-source must be ${LAYOUT_FRAMING_SOURCES.join(", ")} (got "${opts.framingSource}")`);
|
|
7296
|
+
process.exit(1);
|
|
7297
|
+
}
|
|
7298
|
+
const recordings = recordingsInput(opts);
|
|
7299
|
+
try {
|
|
7300
|
+
const client = buildClient(opts.profile);
|
|
7301
|
+
const result = await client.edit.speakerLayout(
|
|
7302
|
+
{
|
|
7303
|
+
...recordings,
|
|
7304
|
+
...opts.aspect ? { targetAspect: opts.aspect } : {},
|
|
7305
|
+
...opts.layout ? { layout: opts.layout } : {},
|
|
7306
|
+
...opts.switch ? { switchType: opts.switch } : {},
|
|
7307
|
+
...opts.emphasis ? { emphasisStyle: opts.emphasis } : {},
|
|
7308
|
+
...opts.framingSource ? { framingSource: opts.framingSource } : {},
|
|
7309
|
+
...opts.review ? { reviewBeforeRender: true } : {}
|
|
7310
|
+
},
|
|
7311
|
+
opts.idempotencyKey ? { idempotencyKey: opts.idempotencyKey } : void 0
|
|
7312
|
+
);
|
|
7313
|
+
const done = await reportQueuedJob(result, () => client.jobs.getStatus(result.jobId), {
|
|
7314
|
+
json: opts.json,
|
|
7315
|
+
watch: opts.watch,
|
|
7316
|
+
pollInterval: opts.pollInterval,
|
|
7317
|
+
note: "speaker-layout"
|
|
7318
|
+
});
|
|
7319
|
+
if (opts.json) return;
|
|
7320
|
+
const url = done?.data.output_data?.videoUrl;
|
|
7321
|
+
if (done?.data.status === "completed" && typeof url === "string") console.log(url);
|
|
7322
|
+
if (opts.review) console.log(pc5.dim(` render the final after your review: nodaro edit continue-use-case ${result.jobId} --mode render-final`));
|
|
7323
|
+
} catch (err) {
|
|
7324
|
+
handleError(err);
|
|
7325
|
+
}
|
|
7326
|
+
}
|
|
7327
|
+
);
|
|
7328
|
+
cmd.command("continue-use-case <jobId>").description("continue a Tighten Episode, Chapters, Trailer, Clip Pack or Speaker Layout 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); a Speaker Layout run has no plan to edit").option(
|
|
7329
|
+
"--type <type>",
|
|
7330
|
+
`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`
|
|
7331
|
+
).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) => {
|
|
7332
|
+
if (opts.mode !== "from-failed" && opts.mode !== "render-final") {
|
|
7333
|
+
warn(`--mode must be "from-failed" or "render-final" (got "${opts.mode}")`);
|
|
7334
|
+
process.exit(1);
|
|
7335
|
+
}
|
|
7336
|
+
if (opts.type !== void 0 && !USE_CASE_NODE_TYPES.includes(opts.type)) {
|
|
7337
|
+
warn(`--type must be ${USE_CASE_NODE_TYPES.join(", ")} (got "${opts.type}")`);
|
|
7338
|
+
process.exit(1);
|
|
7339
|
+
}
|
|
7340
|
+
if (opts.edit !== void 0 && opts.mode !== "render-final") {
|
|
7341
|
+
warn("--edit applies to --mode render-final only");
|
|
7342
|
+
process.exit(1);
|
|
7343
|
+
}
|
|
7344
|
+
try {
|
|
7345
|
+
const client = buildClient(opts.profile);
|
|
7346
|
+
const result = await client.edit.continueUseCase(
|
|
7347
|
+
{
|
|
7348
|
+
jobId,
|
|
7349
|
+
mode: opts.mode,
|
|
7350
|
+
...opts.edit !== void 0 ? { editedEdl: readJsonFile2(opts.edit) } : {},
|
|
7351
|
+
...opts.type !== void 0 ? { nodeType: opts.type } : {}
|
|
7352
|
+
},
|
|
7353
|
+
opts.idempotencyKey ? { idempotencyKey: opts.idempotencyKey } : void 0
|
|
7354
|
+
);
|
|
7355
|
+
await reportQueuedJob(result, () => client.jobs.getStatus(result.jobId), {
|
|
7356
|
+
json: opts.json,
|
|
7357
|
+
watch: opts.watch,
|
|
7358
|
+
pollInterval: opts.pollInterval,
|
|
7359
|
+
note: `continue-use-case (${opts.mode})`
|
|
7360
|
+
});
|
|
7361
|
+
} catch (err) {
|
|
7362
|
+
if (err instanceof ContinuationRefusedError) {
|
|
7363
|
+
if (opts.json) {
|
|
7364
|
+
emit({ error: { code: err.code, message: err.message }, jobId: err.jobId }, opts);
|
|
7365
|
+
} else {
|
|
7366
|
+
console.error(pc5.red(`\u2717 ${err.message}`));
|
|
7367
|
+
console.error(pc5.dim(` code: ${err.code}`));
|
|
7368
|
+
console.error(pc5.dim(` job: ${err.jobId}${CONTINUATION_NEXT_STEP[err.code]?.(err.jobId) ?? ""}`));
|
|
7369
|
+
}
|
|
7370
|
+
process.exit(1);
|
|
7371
|
+
}
|
|
7372
|
+
if (err instanceof NodaroError && err.code === "use_case_type_unknown") {
|
|
7373
|
+
const message = "pass --type <node type> (this key can't read the job's type)";
|
|
7374
|
+
if (opts.json) {
|
|
7375
|
+
emit({ error: { code: err.code, message } }, opts);
|
|
7376
|
+
} else {
|
|
7377
|
+
console.error(pc5.red(`\u2717 ${message}`));
|
|
7378
|
+
console.error(pc5.dim(` code: ${err.code}`));
|
|
7379
|
+
console.error(pc5.dim(` --type: ${USE_CASE_NODE_TYPES.join(" | ")}`));
|
|
7380
|
+
}
|
|
7381
|
+
process.exit(1);
|
|
7382
|
+
}
|
|
7383
|
+
handleError(err);
|
|
7384
|
+
}
|
|
7385
|
+
});
|
|
7386
|
+
}
|
|
7387
|
+
|
|
7388
|
+
// src/commands/edit.ts
|
|
7389
|
+
function isEditPlanMode(v) {
|
|
7390
|
+
return EDIT_PLAN_MODES.includes(v);
|
|
7391
|
+
}
|
|
6736
7392
|
function parseSourceSpec(spec, index2) {
|
|
6737
7393
|
const named = /^([^=\s]{1,200})=(https?:\/\/.+)$/.exec(spec);
|
|
6738
7394
|
const id = named ? named[1] : `source-${index2 + 1}`;
|
|
@@ -6813,6 +7469,39 @@ function editCommand() {
|
|
|
6813
7469
|
}
|
|
6814
7470
|
}
|
|
6815
7471
|
);
|
|
7472
|
+
cmd.command("speaker-map").description("work out which camera each speaker is on, from the cameras' own microphones (keyless)").option(
|
|
7473
|
+
"--source <[id=]url>",
|
|
7474
|
+
"a camera (or the master / wide) as url or id=url (repeatable, 2-6); ids are minted as source-N when omitted",
|
|
7475
|
+
collectVariadic
|
|
7476
|
+
).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(
|
|
7477
|
+
async (opts) => {
|
|
7478
|
+
const sources = opts.sourcesFile ? readJsonFile2(opts.sourcesFile) : (opts.source ?? []).map(parseAudioSyncSource);
|
|
7479
|
+
if (!Array.isArray(sources) || sources.length < 2 || sources.length > 6) {
|
|
7480
|
+
warn("speaker-map takes 2-6 recordings \u2014 pass --source <url> (repeatable) or --sources-file <file> (a JSON array of { id, url } rows)");
|
|
7481
|
+
process.exit(1);
|
|
7482
|
+
}
|
|
7483
|
+
try {
|
|
7484
|
+
const client = buildClient(opts.profile);
|
|
7485
|
+
const input2 = {
|
|
7486
|
+
sources,
|
|
7487
|
+
transcript: readJsonFile2(opts.transcript),
|
|
7488
|
+
...opts.offsets ? { offsets: readJsonFile2(opts.offsets) } : {},
|
|
7489
|
+
...opts.master !== void 0 ? { masterSourceId: opts.master } : {},
|
|
7490
|
+
...opts.wide !== void 0 ? { wideSourceId: opts.wide } : {},
|
|
7491
|
+
...opts.marginDb !== void 0 ? { marginDb: opts.marginDb } : {}
|
|
7492
|
+
};
|
|
7493
|
+
const result = await client.edit.speakerMap(input2);
|
|
7494
|
+
await reportQueuedJob(result, () => client.jobs.getStatus(result.jobId), {
|
|
7495
|
+
json: opts.json,
|
|
7496
|
+
watch: opts.watch,
|
|
7497
|
+
pollInterval: opts.pollInterval,
|
|
7498
|
+
note: `speaker-map (${sources.length} sources)`
|
|
7499
|
+
});
|
|
7500
|
+
} catch (err) {
|
|
7501
|
+
handleError(err);
|
|
7502
|
+
}
|
|
7503
|
+
}
|
|
7504
|
+
);
|
|
6816
7505
|
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(
|
|
6817
7506
|
"--clip-key <key>",
|
|
6818
7507
|
'the plan clip this render cuts, "<first inMs>-<last outMs>" of a clips-mode plan clip; stamped back on the result as clipKey'
|
|
@@ -6848,92 +7537,7 @@ function editCommand() {
|
|
|
6848
7537
|
}
|
|
6849
7538
|
}
|
|
6850
7539
|
);
|
|
6851
|
-
|
|
6852
|
-
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(
|
|
6853
|
-
async (opts) => {
|
|
6854
|
-
if (opts.output !== void 0 && opts.output !== "video" && opts.output !== "audio") {
|
|
6855
|
-
warn(`--output must be "video" or "audio" (got "${opts.output}")`);
|
|
6856
|
-
process.exit(1);
|
|
6857
|
-
}
|
|
6858
|
-
if (opts.planTier !== void 0 && !EDIT_PLAN_TIERS.includes(opts.planTier)) {
|
|
6859
|
-
warn(`--plan-tier must be ${EDIT_PLAN_TIERS.join(", ")} (got "${opts.planTier}")`);
|
|
6860
|
-
process.exit(1);
|
|
6861
|
-
}
|
|
6862
|
-
if (opts.framing !== void 0 && !EDL_TARGET_ASPECTS.includes(opts.framing)) {
|
|
6863
|
-
warn(`--framing must be ${EDL_TARGET_ASPECTS.join(", ")} (got "${opts.framing}")`);
|
|
6864
|
-
process.exit(1);
|
|
6865
|
-
}
|
|
6866
|
-
if (opts.layout !== void 0 && opts.framing === void 0) {
|
|
6867
|
-
warn("--layout applies with --framing only (it picks the framed layout)");
|
|
6868
|
-
process.exit(1);
|
|
6869
|
-
}
|
|
6870
|
-
if (opts.layout !== void 0 && !framingLayouts.includes(opts.layout)) {
|
|
6871
|
-
warn(`--layout must be ${framingLayouts.join(", ")} (got "${opts.layout}")`);
|
|
6872
|
-
process.exit(1);
|
|
6873
|
-
}
|
|
6874
|
-
try {
|
|
6875
|
-
const client = buildClient(opts.profile);
|
|
6876
|
-
const result = await client.edit.tightenEpisode({
|
|
6877
|
-
mediaUrl: opts.media,
|
|
6878
|
-
...opts.music ? { musicUrl: opts.music } : {},
|
|
6879
|
-
...opts.output ? { output: opts.output } : {},
|
|
6880
|
-
...opts.framing ? { framing: { aspect: opts.framing, layout: opts.layout ?? "auto" } } : {},
|
|
6881
|
-
// commander's --no-captions defaults `captions` to true: send it only when turned off.
|
|
6882
|
-
...opts.captions === false ? { captions: false } : {},
|
|
6883
|
-
...opts.review ? { reviewBeforeRender: true } : {},
|
|
6884
|
-
...opts.planTier ? { planTier: opts.planTier } : {},
|
|
6885
|
-
...opts.instructions ? { instructions: opts.instructions } : {}
|
|
6886
|
-
});
|
|
6887
|
-
await reportQueuedJob(result, () => client.jobs.getStatus(result.jobId), {
|
|
6888
|
-
json: opts.json,
|
|
6889
|
-
watch: opts.watch,
|
|
6890
|
-
pollInterval: opts.pollInterval,
|
|
6891
|
-
note: "tighten-episode"
|
|
6892
|
-
});
|
|
6893
|
-
} catch (err) {
|
|
6894
|
-
handleError(err);
|
|
6895
|
-
}
|
|
6896
|
-
}
|
|
6897
|
-
);
|
|
6898
|
-
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("--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) => {
|
|
6899
|
-
if (opts.mode !== "from-failed" && opts.mode !== "render-final") {
|
|
6900
|
-
warn(`--mode must be "from-failed" or "render-final" (got "${opts.mode}")`);
|
|
6901
|
-
process.exit(1);
|
|
6902
|
-
}
|
|
6903
|
-
if (opts.edit !== void 0 && opts.mode !== "render-final") {
|
|
6904
|
-
warn("--edit applies to --mode render-final only");
|
|
6905
|
-
process.exit(1);
|
|
6906
|
-
}
|
|
6907
|
-
try {
|
|
6908
|
-
const client = buildClient(opts.profile);
|
|
6909
|
-
const result = await client.edit.continueUseCase(
|
|
6910
|
-
{
|
|
6911
|
-
jobId,
|
|
6912
|
-
mode: opts.mode,
|
|
6913
|
-
...opts.edit !== void 0 ? { editedEdl: readJsonFile2(opts.edit) } : {}
|
|
6914
|
-
},
|
|
6915
|
-
opts.idempotencyKey ? { idempotencyKey: opts.idempotencyKey } : void 0
|
|
6916
|
-
);
|
|
6917
|
-
await reportQueuedJob(result, () => client.jobs.getStatus(result.jobId), {
|
|
6918
|
-
json: opts.json,
|
|
6919
|
-
watch: opts.watch,
|
|
6920
|
-
pollInterval: opts.pollInterval,
|
|
6921
|
-
note: `continue-use-case (${opts.mode})`
|
|
6922
|
-
});
|
|
6923
|
-
} catch (err) {
|
|
6924
|
-
if (err instanceof ContinuationRefusedError) {
|
|
6925
|
-
if (opts.json) {
|
|
6926
|
-
emit({ error: { code: err.code, message: err.message }, jobId: err.jobId }, opts);
|
|
6927
|
-
} else {
|
|
6928
|
-
console.error(pc3.red(`\u2717 ${err.message}`));
|
|
6929
|
-
console.error(pc3.dim(` code: ${err.code}`));
|
|
6930
|
-
console.error(pc3.dim(` job: ${err.jobId}${CONTINUATION_NEXT_STEP[err.code]?.(err.jobId) ?? ""}`));
|
|
6931
|
-
}
|
|
6932
|
-
process.exit(1);
|
|
6933
|
-
}
|
|
6934
|
-
handleError(err);
|
|
6935
|
-
}
|
|
6936
|
-
});
|
|
7540
|
+
registerUseCaseCommands(cmd);
|
|
6937
7541
|
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(
|
|
6938
7542
|
"--source <url>",
|
|
6939
7543
|
"a media source as [id=]url[@audio|@video] (repeatable); id defaults to source-N, kind to video",
|
|
@@ -6999,7 +7603,7 @@ function editCommand() {
|
|
|
6999
7603
|
}
|
|
7000
7604
|
}
|
|
7001
7605
|
);
|
|
7002
|
-
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(
|
|
7606
|
+
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(
|
|
7003
7607
|
async (opts) => {
|
|
7004
7608
|
try {
|
|
7005
7609
|
const client = buildClient(opts.profile);
|
|
@@ -7007,6 +7611,7 @@ function editCommand() {
|
|
|
7007
7611
|
edl: readJsonFile2(opts.edl),
|
|
7008
7612
|
transcript: readJsonFile2(opts.transcript),
|
|
7009
7613
|
...opts.speakerMap ? { speakerMap: readJsonFile2(opts.speakerMap) } : {},
|
|
7614
|
+
...opts.speakerMapResult ? { speakerMapResult: readJsonFile2(opts.speakerMapResult) } : {},
|
|
7010
7615
|
...opts.speakerNames ? { speakerNames: readJsonFile2(opts.speakerNames) } : {},
|
|
7011
7616
|
...opts.minShotMs !== void 0 ? { minShotMs: opts.minShotMs } : {},
|
|
7012
7617
|
...opts.leadMs !== void 0 ? { leadMs: opts.leadMs } : {},
|