@nodaro/cli 1.34.0 → 1.37.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 +9 -0
- package/dist/index.js +567 -50
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
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';
|
|
@@ -17,7 +17,7 @@ import checkbox from '@inquirer/checkbox';
|
|
|
17
17
|
import input from '@inquirer/input';
|
|
18
18
|
import { CHARACTER_STYLES } from '@nodaro/shared/entities';
|
|
19
19
|
import { TRANSCRIBE_PROVIDERS, transcribeLaneSupportsWordTimestamps, DIALOGUE_PROVIDERS, dialogueStabilityAccepted, dialogueProviderOf, getDialogueCapabilities, TRANSCRIBE_LANES, DEFAULT_TRANSCRIBE_PROVIDER } from '@nodaro/shared/models';
|
|
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';
|
|
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, MASK_COMPOSITE_FILLS } from '@nodaro/shared/media';
|
|
21
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';
|
|
22
22
|
import { VIDEO_OVERLAY_PRESET_IDS, VIDEO_OVERLAY_CORNERS, VIDEO_OVERLAY_OUTPUT_ASPECTS, isVideoOverlayPresetId, isVideoOverlayCorner, isVideoOverlayOutputAspect, VIDEO_OVERLAY_FITS } from '@nodaro/shared/video';
|
|
23
23
|
import { SOCIAL_PLATFORMS, COMPETITOR_ACCOUNT_KEYS, isMeasurableCard, isSocialPost, COMPETITOR_ABOUT_PLATFORMS, COMPETITOR_SCHEDULES } from '@nodaro/shared/social';
|
|
@@ -41,7 +41,7 @@ var require_package = __commonJS({
|
|
|
41
41
|
"package.json"(exports$1, module) {
|
|
42
42
|
module.exports = {
|
|
43
43
|
name: "@nodaro/cli",
|
|
44
|
-
version: "1.
|
|
44
|
+
version: "1.37.0",
|
|
45
45
|
description: "Command-line interface for Nodaro \u2014 list and run workflows, inspect jobs and executions, manage projects from the terminal.",
|
|
46
46
|
type: "module",
|
|
47
47
|
license: "Apache-2.0",
|
|
@@ -82,8 +82,8 @@ var require_package = __commonJS({
|
|
|
82
82
|
"@inquirer/confirm": "^6.0.12",
|
|
83
83
|
"@inquirer/input": "^5.0.12",
|
|
84
84
|
"@inquirer/select": "^5.1.4",
|
|
85
|
-
"@nodaro/sdk": "^2.
|
|
86
|
-
"@nodaro/shared": "^3.
|
|
85
|
+
"@nodaro/sdk": "^2.37.0",
|
|
86
|
+
"@nodaro/shared": "^3.38.0",
|
|
87
87
|
commander: "^12.1.0",
|
|
88
88
|
picocolors: "^1.1.1",
|
|
89
89
|
"@nodaro/prompts": "^1.40.0"
|
|
@@ -173,20 +173,20 @@ function detail(value) {
|
|
|
173
173
|
console.log(JSON.stringify(value, null, 2));
|
|
174
174
|
}
|
|
175
175
|
function success(line) {
|
|
176
|
-
console.log(
|
|
176
|
+
console.log(pc5.green("\u2713") + " " + line);
|
|
177
177
|
}
|
|
178
178
|
function info(line) {
|
|
179
179
|
console.log(line);
|
|
180
180
|
}
|
|
181
181
|
function dim(line) {
|
|
182
|
-
console.log(
|
|
182
|
+
console.log(pc5.dim(line));
|
|
183
183
|
}
|
|
184
184
|
function warn(line) {
|
|
185
|
-
console.error(
|
|
185
|
+
console.error(pc5.yellow("\u26A0") + " " + line);
|
|
186
186
|
}
|
|
187
187
|
function table(rows2, columns) {
|
|
188
188
|
if (rows2.length === 0) {
|
|
189
|
-
console.log(
|
|
189
|
+
console.log(pc5.dim("(empty)"));
|
|
190
190
|
return;
|
|
191
191
|
}
|
|
192
192
|
const widths = {};
|
|
@@ -198,7 +198,7 @@ function table(rows2, columns) {
|
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
200
|
for (const col of columns) widths[col] = Math.min(widths[col], 60);
|
|
201
|
-
console.log(columns.map((c) =>
|
|
201
|
+
console.log(columns.map((c) => pc5.bold(c.padEnd(widths[c]))).join(" "));
|
|
202
202
|
console.log(columns.map((c) => "-".repeat(widths[c])).join(" "));
|
|
203
203
|
for (const row of rows2) {
|
|
204
204
|
console.log(
|
|
@@ -362,7 +362,7 @@ function authCommand() {
|
|
|
362
362
|
if (opts.json) {
|
|
363
363
|
emit({ profile: name, baseUrl: profile.baseUrl, tokenMasked: maskToken(profile.token), signedIn: true }, opts);
|
|
364
364
|
} else {
|
|
365
|
-
info(`profile: ${
|
|
365
|
+
info(`profile: ${pc5.cyan(name)}`);
|
|
366
366
|
info(`baseUrl: ${profile.baseUrl}`);
|
|
367
367
|
info(`token: ${maskToken(profile.token)}`);
|
|
368
368
|
}
|
|
@@ -413,7 +413,7 @@ function saveWorkspace(profileName, workspaceId) {
|
|
|
413
413
|
}
|
|
414
414
|
|
|
415
415
|
// src/client.ts
|
|
416
|
-
var CLI_VERSION = "1.
|
|
416
|
+
var CLI_VERSION = "1.37.0" ;
|
|
417
417
|
function buildPublicClient(opts = {}) {
|
|
418
418
|
const { profile } = getProfile(opts.profile);
|
|
419
419
|
return createClient({
|
|
@@ -425,8 +425,8 @@ function buildPublicClient(opts = {}) {
|
|
|
425
425
|
function buildClient(profileName) {
|
|
426
426
|
const { name, profile } = getProfile(profileName);
|
|
427
427
|
if (!profile) {
|
|
428
|
-
console.error(
|
|
429
|
-
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}` : ""}`));
|
|
430
430
|
process.exit(1);
|
|
431
431
|
}
|
|
432
432
|
const { workspaceId } = resolveWorkspace(profile);
|
|
@@ -443,20 +443,20 @@ function buildClient(profileName) {
|
|
|
443
443
|
}
|
|
444
444
|
function handleError(err) {
|
|
445
445
|
if (err instanceof UnauthorizedError) {
|
|
446
|
-
console.error(
|
|
447
|
-
console.error(
|
|
446
|
+
console.error(pc5.red("\u2717 unauthorized \u2014 token missing, expired, or invalid"));
|
|
447
|
+
console.error(pc5.dim(" run: nodaro auth login"));
|
|
448
448
|
process.exit(1);
|
|
449
449
|
}
|
|
450
450
|
if (err instanceof NodaroError) {
|
|
451
|
-
console.error(
|
|
452
|
-
if (err.code) console.error(
|
|
451
|
+
console.error(pc5.red(`\u2717 ${err.message}`));
|
|
452
|
+
if (err.code) console.error(pc5.dim(` code: ${err.code}`));
|
|
453
453
|
process.exit(1);
|
|
454
454
|
}
|
|
455
455
|
if (err instanceof Error) {
|
|
456
|
-
console.error(
|
|
456
|
+
console.error(pc5.red(`\u2717 ${err.message}`));
|
|
457
457
|
process.exit(1);
|
|
458
458
|
}
|
|
459
|
-
console.error(
|
|
459
|
+
console.error(pc5.red("\u2717 unknown error"), err);
|
|
460
460
|
process.exit(1);
|
|
461
461
|
}
|
|
462
462
|
|
|
@@ -1133,7 +1133,8 @@ function workflowsCommand() {
|
|
|
1133
1133
|
success(`Render final of ${renderNodeId} runs ${quote.nodeIds.join(", ")}`);
|
|
1134
1134
|
if (quote.estimatedCredits !== null) {
|
|
1135
1135
|
dim(
|
|
1136
|
-
|
|
1136
|
+
// `~`: an LLM node in the run is charged its actual usage, so the figure is an estimate.
|
|
1137
|
+
`estimated ${quote.estimatedCreditsIsEstimate ? "~" : ""}${quote.estimatedCredits} credits` + (quote.sufficient === false ? ` \u2014 not covered${quote.available !== null ? ` (${quote.available} available)` : ""}` : "")
|
|
1137
1138
|
);
|
|
1138
1139
|
}
|
|
1139
1140
|
return;
|
|
@@ -1835,10 +1836,14 @@ async function pickNodeInteractively(client) {
|
|
|
1835
1836
|
choices: result.data.map((n) => ({
|
|
1836
1837
|
name: `${n.label} \u2014 ${n.type}`,
|
|
1837
1838
|
value: n.type,
|
|
1838
|
-
description: `${n.category} \u2192 ${n.outputType}${n.creditCost ? ` (${n
|
|
1839
|
+
description: `${n.category} \u2192 ${n.outputType}${n.creditCost ? ` (${nodeCreditsLabel(n)})` : ""}`
|
|
1839
1840
|
}))
|
|
1840
1841
|
});
|
|
1841
1842
|
}
|
|
1843
|
+
function nodeCreditsLabel(n) {
|
|
1844
|
+
if (n.creditCost === "unpriced") return "unpriced";
|
|
1845
|
+
return `${n.estimate ? "~" : ""}${n.creditCost} cr`;
|
|
1846
|
+
}
|
|
1842
1847
|
function rejectPositionalParams(extras, example) {
|
|
1843
1848
|
if (!extras || extras.length === 0) return;
|
|
1844
1849
|
const looksLikeObject = extras[0].trim().startsWith("{");
|
|
@@ -1870,7 +1875,7 @@ function nodesCommand() {
|
|
|
1870
1875
|
label: n.label,
|
|
1871
1876
|
category: n.category,
|
|
1872
1877
|
outputType: n.outputType,
|
|
1873
|
-
credits: n.creditCost
|
|
1878
|
+
credits: n.creditCost === void 0 ? "" : n.estimate ? `~${n.creditCost}` : n.creditCost,
|
|
1874
1879
|
providers: n.providers ? n.providers.length : ""
|
|
1875
1880
|
})),
|
|
1876
1881
|
["type", "label", "category", "outputType", "credits", "providers"]
|
|
@@ -2373,7 +2378,7 @@ function promptCommand() {
|
|
|
2373
2378
|
const cmd = new Command("prompt").description(
|
|
2374
2379
|
"AI prompt wizard \u2014 analyze, generate, and enhance prompts for generation nodes"
|
|
2375
2380
|
);
|
|
2376
|
-
cmd.command("wizard").description("interactive: answer guided questions and get an optimized prompt").option("--node-type <type>", "target node type (omit for an interactive picker)").option("--prompt <text>", "your rough idea (optional)").option("--provider <name>").option("--style <name>").option("--aspect-ratio <ratio>").option("--duration <seconds>", "clip duration in seconds", (v) => parseInt(v, 10)).option("--llm-model <id>").option("--reasoning-effort <level>", "reasoning effort: none|low|medium|high|xhigh|max (model-dependent)").option("--advanced", "Gemini and Claude models: run on the provider's own API so --temperature/--max-tokens/the full reasoning range apply.
|
|
2381
|
+
cmd.command("wizard").description("interactive: answer guided questions and get an optimized prompt").option("--node-type <type>", "target node type (omit for an interactive picker)").option("--prompt <text>", "your rough idea (optional)").option("--provider <name>").option("--style <name>").option("--aspect-ratio <ratio>").option("--duration <seconds>", "clip duration in seconds", (v) => parseInt(v, 10)).option("--llm-model <id>").option("--reasoning-effort <level>", "reasoning effort: none|low|medium|high|xhigh|max (model-dependent)").option("--advanced", "Gemini and Claude models: run on the provider's own API so --temperature/--max-tokens/the full reasoning range apply. Charged per token at that lane's rate.").option("--temperature <n>", "Sampling temperature (only with --advanced)", parseFloat).option("--max-tokens <n>", "Output token cap (only with --advanced)", (v) => parseInt(v, 10)).option("--profile <name>").action(async (opts) => {
|
|
2377
2382
|
try {
|
|
2378
2383
|
if (!isInteractive()) {
|
|
2379
2384
|
warn("`prompt wizard` needs an interactive terminal \u2014 use `prompt analyze` + `prompt generate`, or `prompt enhance`, in scripts.");
|
|
@@ -2423,7 +2428,7 @@ function promptCommand() {
|
|
|
2423
2428
|
handleError(err);
|
|
2424
2429
|
}
|
|
2425
2430
|
});
|
|
2426
|
-
cmd.command("analyze").description("return guided questions for a rough prompt idea").requiredOption("--node-type <type>").option("--prompt <text>").option("--provider <name>").option("--style <name>").option("--aspect-ratio <ratio>").option("--duration <seconds>", "clip duration in seconds", (v) => parseInt(v, 10)).option("--llm-model <id>").option("--reasoning-effort <level>", "reasoning effort: none|low|medium|high|xhigh|max (model-dependent)").option("--advanced", "Gemini and Claude models: run on the provider's own API so --temperature/--max-tokens/the full reasoning range apply.
|
|
2431
|
+
cmd.command("analyze").description("return guided questions for a rough prompt idea").requiredOption("--node-type <type>").option("--prompt <text>").option("--provider <name>").option("--style <name>").option("--aspect-ratio <ratio>").option("--duration <seconds>", "clip duration in seconds", (v) => parseInt(v, 10)).option("--llm-model <id>").option("--reasoning-effort <level>", "reasoning effort: none|low|medium|high|xhigh|max (model-dependent)").option("--advanced", "Gemini and Claude models: run on the provider's own API so --temperature/--max-tokens/the full reasoning range apply. Charged per token at that lane's rate.").option("--temperature <n>", "Sampling temperature (only with --advanced)", parseFloat).option("--max-tokens <n>", "Output token cap (only with --advanced)", (v) => parseInt(v, 10)).option("--profile <name>").option("--json").action(async (opts) => {
|
|
2427
2432
|
try {
|
|
2428
2433
|
const client = buildClient(opts.profile);
|
|
2429
2434
|
const { jobId, questions } = await client.promptHelper.analyze({
|
|
@@ -2448,7 +2453,7 @@ function promptCommand() {
|
|
|
2448
2453
|
handleError(err);
|
|
2449
2454
|
}
|
|
2450
2455
|
});
|
|
2451
|
-
cmd.command("generate").description("build an optimized prompt from --selection category=value flags").requiredOption("--node-type <type>").option("--selection <pairs...>", "category=value (repeat); custom answers are wizard-only", collectVariadic).option("--original-prompt <text>").option("--provider <name>").option("--style <name>").option("--aspect-ratio <ratio>").option("--duration <seconds>", "clip duration in seconds", (v) => parseInt(v, 10)).option("--llm-model <id>").option("--reasoning-effort <level>", "reasoning effort: none|low|medium|high|xhigh|max (model-dependent)").option("--advanced", "Gemini and Claude models: run on the provider's own API so --temperature/--max-tokens/the full reasoning range apply.
|
|
2456
|
+
cmd.command("generate").description("build an optimized prompt from --selection category=value flags").requiredOption("--node-type <type>").option("--selection <pairs...>", "category=value (repeat); custom answers are wizard-only", collectVariadic).option("--original-prompt <text>").option("--provider <name>").option("--style <name>").option("--aspect-ratio <ratio>").option("--duration <seconds>", "clip duration in seconds", (v) => parseInt(v, 10)).option("--llm-model <id>").option("--reasoning-effort <level>", "reasoning effort: none|low|medium|high|xhigh|max (model-dependent)").option("--advanced", "Gemini and Claude models: run on the provider's own API so --temperature/--max-tokens/the full reasoning range apply. Charged per token at that lane's rate.").option("--temperature <n>", "Sampling temperature (only with --advanced)", parseFloat).option("--max-tokens <n>", "Output token cap (only with --advanced)", (v) => parseInt(v, 10)).option("--profile <name>").option("--json").action(async (opts) => {
|
|
2452
2457
|
try {
|
|
2453
2458
|
const client = buildClient(opts.profile);
|
|
2454
2459
|
const selections = parseSelectionPairs(opts.selection);
|
|
@@ -2468,7 +2473,7 @@ function promptCommand() {
|
|
|
2468
2473
|
handleError(err);
|
|
2469
2474
|
}
|
|
2470
2475
|
});
|
|
2471
|
-
cmd.command("enhance").description("rewrite a rough idea into one optimized prompt (no questions)").requiredOption("--node-type <type>").option("--prompt <text>").option("--provider <name>").option("--style <name>").option("--aspect-ratio <ratio>").option("--duration <seconds>", "clip duration in seconds", (v) => parseInt(v, 10)).option("--llm-model <id>").option("--reasoning-effort <level>", "reasoning effort: none|low|medium|high|xhigh|max (model-dependent)").option("--advanced", "Gemini and Claude models: run on the provider's own API so --temperature/--max-tokens/the full reasoning range apply.
|
|
2476
|
+
cmd.command("enhance").description("rewrite a rough idea into one optimized prompt (no questions)").requiredOption("--node-type <type>").option("--prompt <text>").option("--provider <name>").option("--style <name>").option("--aspect-ratio <ratio>").option("--duration <seconds>", "clip duration in seconds", (v) => parseInt(v, 10)).option("--llm-model <id>").option("--reasoning-effort <level>", "reasoning effort: none|low|medium|high|xhigh|max (model-dependent)").option("--advanced", "Gemini and Claude models: run on the provider's own API so --temperature/--max-tokens/the full reasoning range apply. Charged per token at that lane's rate.").option("--temperature <n>", "Sampling temperature (only with --advanced)", parseFloat).option("--max-tokens <n>", "Output token cap (only with --advanced)", (v) => parseInt(v, 10)).option("--profile <name>").option("--json").action(async (opts) => {
|
|
2472
2477
|
try {
|
|
2473
2478
|
const client = buildClient(opts.profile);
|
|
2474
2479
|
const result = await client.promptHelper.enhance({
|
|
@@ -3049,6 +3054,16 @@ function parseSafeArea(raw) {
|
|
|
3049
3054
|
const [x, y, w, h] = parts;
|
|
3050
3055
|
return { x, y, w, h };
|
|
3051
3056
|
}
|
|
3057
|
+
function parseVideoMaskZone(raw) {
|
|
3058
|
+
const parts = raw.split(",").map((n) => n.trim());
|
|
3059
|
+
const nums = parts.map((n) => /^(?:\d+\.?\d*|\.\d+)$/.test(n) ? Number(n) : Number.NaN);
|
|
3060
|
+
if (nums.length !== 4 || nums.some((n) => !(n >= VIDEO_MASK_LIMITS.ZONE_MARGIN_PCT_MIN && n <= VIDEO_MASK_LIMITS.ZONE_MARGIN_PCT_MAX))) {
|
|
3061
|
+
warn(`--zone must be "left,right,top,bottom", each a % of the frame from ${VIDEO_MASK_LIMITS.ZONE_MARGIN_PCT_MIN} to ${VIDEO_MASK_LIMITS.ZONE_MARGIN_PCT_MAX}, e.g. 10,10,5,5 (got "${raw}")`);
|
|
3062
|
+
process.exit(1);
|
|
3063
|
+
}
|
|
3064
|
+
const [leftPct, rightPct, topPct, bottomPct] = nums;
|
|
3065
|
+
return { leftPct, rightPct, topPct, bottomPct };
|
|
3066
|
+
}
|
|
3052
3067
|
function mediaCommand() {
|
|
3053
3068
|
const cmd = new Command("media").description(
|
|
3054
3069
|
"media ingestion + compositing \u2014 pull a social video into storage, trim video/audio, burn captions, still-to-video, slideshow, collage images, overlay layers on an image or timed images on a video, save a URL to storage, probe metadata"
|
|
@@ -3652,11 +3667,12 @@ image, passed through unchanged): \`nodaro jobs get <jobId>\`. Use the mask for
|
|
|
3652
3667
|
handleError(err);
|
|
3653
3668
|
}
|
|
3654
3669
|
});
|
|
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", `
|
|
3670
|
+
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("--hold-last-mask", "keep the last mask on frames where the subject is lost (e.g. hidden behind a hand)").option("--min-subject-height <pct>", `ignore subjects smaller than this % of the frame height, ${VIDEO_MASK_LIMITS.MIN_SUBJECT_HEIGHT_PCT_MIN}\u2013${VIDEO_MASK_LIMITS.MIN_SUBJECT_HEIGHT_PCT_MAX} (default 0 = off)`, (v) => Number(v)).option("--max-subject-height <pct>", `ignore subjects larger than this % of the frame height, ${VIDEO_MASK_LIMITS.MAX_SUBJECT_HEIGHT_PCT_MIN}\u2013${VIDEO_MASK_LIMITS.MAX_SUBJECT_HEIGHT_PCT_MAX} (default 0 = off)`, (v) => Number(v)).option("--zone <L,R,T,B>", `keep only subjects whose centre is inside these left,right,top,bottom margins, each ${VIDEO_MASK_LIMITS.ZONE_MARGIN_PCT_MIN}\u2013${VIDEO_MASK_LIMITS.ZONE_MARGIN_PCT_MAX} % of the frame (default off)`).option("--per-shot", "detect the subject again in every shot after a scene cut").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", `
|
|
3656
3671
|
Examples:
|
|
3657
3672
|
$ nodaro media video-mask https://x/dance.mp4 "the dancer" --watch
|
|
3658
3673
|
$ nodaro media video-mask https://x/street.mp4 "person, dog" --threshold 0.3 --watch
|
|
3659
3674
|
$ nodaro media video-mask https://x/long-take.mp4 "the skater" --model sam-3 --watch
|
|
3675
|
+
$ nodaro media video-mask https://x/edit.mp4 "face" --per-shot --zone 10,10,5,5 --watch
|
|
3660
3676
|
|
|
3661
3677
|
Clips up to ${VIDEO_MASK_LIMITS.MAX_BILLED_SEC} s at ${VIDEO_MASK_LIMITS.FPS_BASIS} fps (a faster clip counts proportionally longer); priced by the
|
|
3662
3678
|
clip's length. Feed the mask to \`nodaro media mask-composite\`.`).action(async (videoUrl, prompt, opts) => {
|
|
@@ -3669,27 +3685,67 @@ clip's length. Feed the mask to \`nodaro media mask-composite\`.`).action(async
|
|
|
3669
3685
|
warn(`--threshold must be between ${VIDEO_MASK_LIMITS.THRESHOLD_MIN} and ${VIDEO_MASK_LIMITS.THRESHOLD_MAX}`);
|
|
3670
3686
|
process.exit(1);
|
|
3671
3687
|
}
|
|
3688
|
+
if (opts.minSubjectHeight !== void 0 && !(Number.isFinite(opts.minSubjectHeight) && opts.minSubjectHeight >= VIDEO_MASK_LIMITS.MIN_SUBJECT_HEIGHT_PCT_MIN && opts.minSubjectHeight <= VIDEO_MASK_LIMITS.MIN_SUBJECT_HEIGHT_PCT_MAX)) {
|
|
3689
|
+
warn(`--min-subject-height must be a number from ${VIDEO_MASK_LIMITS.MIN_SUBJECT_HEIGHT_PCT_MIN} to ${VIDEO_MASK_LIMITS.MIN_SUBJECT_HEIGHT_PCT_MAX}`);
|
|
3690
|
+
process.exit(1);
|
|
3691
|
+
}
|
|
3692
|
+
if (opts.maxSubjectHeight !== void 0 && !(Number.isFinite(opts.maxSubjectHeight) && opts.maxSubjectHeight >= VIDEO_MASK_LIMITS.MAX_SUBJECT_HEIGHT_PCT_MIN && opts.maxSubjectHeight <= VIDEO_MASK_LIMITS.MAX_SUBJECT_HEIGHT_PCT_MAX)) {
|
|
3693
|
+
warn(`--max-subject-height must be a number from ${VIDEO_MASK_LIMITS.MAX_SUBJECT_HEIGHT_PCT_MIN} to ${VIDEO_MASK_LIMITS.MAX_SUBJECT_HEIGHT_PCT_MAX}`);
|
|
3694
|
+
process.exit(1);
|
|
3695
|
+
}
|
|
3696
|
+
if ((opts.minSubjectHeight ?? 0) > 0 && (opts.maxSubjectHeight ?? 0) > 0 && opts.minSubjectHeight > opts.maxSubjectHeight) {
|
|
3697
|
+
warn("--min-subject-height is above --max-subject-height: no subject could be kept");
|
|
3698
|
+
process.exit(1);
|
|
3699
|
+
}
|
|
3700
|
+
const zone = opts.zone !== void 0 ? parseVideoMaskZone(opts.zone) : void 0;
|
|
3672
3701
|
const client = buildClient(opts.profile);
|
|
3673
3702
|
const result = await client.media.videoMask({
|
|
3674
3703
|
videoUrl,
|
|
3675
3704
|
prompt,
|
|
3676
3705
|
...opts.threshold !== void 0 ? { threshold: opts.threshold } : {},
|
|
3677
|
-
...opts.model ? { provider: opts.model } : {}
|
|
3706
|
+
...opts.model ? { provider: opts.model } : {},
|
|
3707
|
+
...opts.holdLastMask ? { holdLastMask: true } : {},
|
|
3708
|
+
...opts.minSubjectHeight !== void 0 ? { minSubjectHeightPct: opts.minSubjectHeight } : {},
|
|
3709
|
+
...opts.maxSubjectHeight !== void 0 ? { maxSubjectHeightPct: opts.maxSubjectHeight } : {},
|
|
3710
|
+
...zone ? { zone } : {},
|
|
3711
|
+
...opts.perShot ? { perShot: true } : {}
|
|
3678
3712
|
});
|
|
3679
3713
|
await reportQueuedJob(result, () => client.jobs.get(result.jobId), { ...opts, note: "video mask" });
|
|
3680
3714
|
} catch (err) {
|
|
3681
3715
|
handleError(err);
|
|
3682
3716
|
}
|
|
3683
3717
|
});
|
|
3684
|
-
cmd.command("mask-composite <
|
|
3718
|
+
cmd.command("mask-composite <urls...>").description("put a foreground video over a background video through a mask video (white = foreground) \u2014 local compositor, no AI. Takes <foregroundUrl> <backgroundUrl> <maskUrl>; with --fill pixelate|blur, <backgroundUrl> <maskUrl>").option("--invert", "swap which side of the mask shows the foreground").option("--feather <px>", `edge softening ${MASK_COMPOSITE_BOUNDS.FEATHER_MIN}\u2013${MASK_COMPOSITE_BOUNDS.FEATHER_MAX} px (default ${MASK_COMPOSITE_DEFAULTS.feather})`, (v) => parseInt(v, 10)).option("--grow <px>", `grow (+) or shrink (\u2212) the foreground region, ${MASK_COMPOSITE_BOUNDS.GROW_MIN}\u2013${MASK_COMPOSITE_BOUNDS.GROW_MAX} px (default 0)`, (v) => parseInt(v, 10)).option("--background-fit <fit>", `${MASK_COMPOSITE_BACKGROUND_FITS.join(" | ")} (default ${MASK_COMPOSITE_DEFAULTS.backgroundFit})`).option("--audio <source>", `${MASK_COMPOSITE_AUDIO_SOURCES.join(" | ")} (default ${MASK_COMPOSITE_DEFAULTS.audioSource})`).option("--fill <fill>", `what fills the mask: ${MASK_COMPOSITE_FILLS.join(" | ")} (default ${MASK_COMPOSITE_DEFAULTS.fill}; pixelate / blur use the background itself and take no foreground)`).option("--pixel-size-pct <pct>", `pixelate block size, % of the frame width, ${MASK_COMPOSITE_BOUNDS.PIXEL_SIZE_PCT_MIN}\u2013${MASK_COMPOSITE_BOUNDS.PIXEL_SIZE_PCT_MAX} (default ${MASK_COMPOSITE_DEFAULTS.pixelSizePct})`, (v) => Number(v)).option("--blur-strength-pct <pct>", `blur strength (sigma), % of the frame width, ${MASK_COMPOSITE_BOUNDS.BLUR_STRENGTH_PCT_MIN}\u2013${MASK_COMPOSITE_BOUNDS.BLUR_STRENGTH_PCT_MAX} (default ${MASK_COMPOSITE_DEFAULTS.blurStrengthPct})`, (v) => Number(v)).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", `
|
|
3685
3719
|
Example:
|
|
3686
3720
|
$ nodaro media mask-composite https://x/dance.mp4 https://x/beach.mp4 https://x/dance-mask.mp4 --feather 4 --grow -1 --watch
|
|
3721
|
+
$ nodaro media mask-composite https://x/street.mp4 https://x/faces-mask.mp4 --fill pixelate --pixel-size-pct 2 --watch
|
|
3687
3722
|
|
|
3688
3723
|
The result follows the FOREGROUND's size, frame rate and length; the background
|
|
3689
|
-
is fitted to that frame and loops when shorter; the mask holds its last frame
|
|
3690
|
-
|
|
3724
|
+
is fitted to that frame and loops when shorter; the mask holds its last frame.
|
|
3725
|
+
With --fill pixelate or blur the masked area is the background itself,
|
|
3726
|
+
pixelated or blurred, and the result follows the background.`).action(
|
|
3727
|
+
async (urls, opts) => {
|
|
3691
3728
|
try {
|
|
3692
3729
|
const b = MASK_COMPOSITE_BOUNDS;
|
|
3730
|
+
if (opts.fill && !MASK_COMPOSITE_FILLS.includes(opts.fill)) {
|
|
3731
|
+
warn(`--fill must be one of ${MASK_COMPOSITE_FILLS.join(", ")} (got "${opts.fill}")`);
|
|
3732
|
+
process.exit(1);
|
|
3733
|
+
}
|
|
3734
|
+
const fill = opts.fill ?? MASK_COMPOSITE_DEFAULTS.fill;
|
|
3735
|
+
const withForeground = fill === "video";
|
|
3736
|
+
if (urls.length !== (withForeground ? 3 : 2)) {
|
|
3737
|
+
warn(withForeground ? "give <foregroundUrl> <backgroundUrl> <maskUrl>" : `with --fill ${fill}, give <backgroundUrl> <maskUrl> (no foreground)`);
|
|
3738
|
+
process.exit(1);
|
|
3739
|
+
}
|
|
3740
|
+
const [foregroundUrl, backgroundUrl, maskUrl] = withForeground ? urls : [void 0, ...urls];
|
|
3741
|
+
if (opts.pixelSizePct !== void 0 && !(Number.isFinite(opts.pixelSizePct) && opts.pixelSizePct >= b.PIXEL_SIZE_PCT_MIN && opts.pixelSizePct <= b.PIXEL_SIZE_PCT_MAX)) {
|
|
3742
|
+
warn(`--pixel-size-pct must be a number from ${b.PIXEL_SIZE_PCT_MIN} to ${b.PIXEL_SIZE_PCT_MAX}`);
|
|
3743
|
+
process.exit(1);
|
|
3744
|
+
}
|
|
3745
|
+
if (opts.blurStrengthPct !== void 0 && !(Number.isFinite(opts.blurStrengthPct) && opts.blurStrengthPct >= b.BLUR_STRENGTH_PCT_MIN && opts.blurStrengthPct <= b.BLUR_STRENGTH_PCT_MAX)) {
|
|
3746
|
+
warn(`--blur-strength-pct must be a number from ${b.BLUR_STRENGTH_PCT_MIN} to ${b.BLUR_STRENGTH_PCT_MAX}`);
|
|
3747
|
+
process.exit(1);
|
|
3748
|
+
}
|
|
3693
3749
|
if (opts.feather !== void 0 && !(Number.isInteger(opts.feather) && opts.feather >= b.FEATHER_MIN && opts.feather <= b.FEATHER_MAX)) {
|
|
3694
3750
|
warn(`--feather must be a whole number from ${b.FEATHER_MIN} to ${b.FEATHER_MAX}`);
|
|
3695
3751
|
process.exit(1);
|
|
@@ -3708,14 +3764,17 @@ is fitted to that frame and loops when shorter; the mask holds its last frame.`)
|
|
|
3708
3764
|
}
|
|
3709
3765
|
const client = buildClient(opts.profile);
|
|
3710
3766
|
const result = await client.media.maskComposite({
|
|
3711
|
-
foregroundUrl,
|
|
3767
|
+
...foregroundUrl ? { foregroundUrl } : {},
|
|
3712
3768
|
backgroundUrl,
|
|
3713
3769
|
maskUrl,
|
|
3714
3770
|
...opts.invert ? { invertMask: true } : {},
|
|
3715
3771
|
...opts.feather !== void 0 ? { feather: opts.feather } : {},
|
|
3716
3772
|
...opts.grow !== void 0 ? { grow: opts.grow } : {},
|
|
3717
3773
|
...opts.backgroundFit ? { backgroundFit: opts.backgroundFit } : {},
|
|
3718
|
-
...opts.audio ? { audioSource: opts.audio } : {}
|
|
3774
|
+
...opts.audio ? { audioSource: opts.audio } : {},
|
|
3775
|
+
...opts.fill ? { fill } : {},
|
|
3776
|
+
...opts.pixelSizePct !== void 0 ? { pixelSizePct: opts.pixelSizePct } : {},
|
|
3777
|
+
...opts.blurStrengthPct !== void 0 ? { blurStrengthPct: opts.blurStrengthPct } : {}
|
|
3719
3778
|
});
|
|
3720
3779
|
await reportQueuedJob(result, () => client.jobs.get(result.jobId), { ...opts, note: "mask composite" });
|
|
3721
3780
|
} catch (err) {
|
|
@@ -5615,8 +5674,50 @@ Examples:
|
|
|
5615
5674
|
}
|
|
5616
5675
|
}
|
|
5617
5676
|
);
|
|
5677
|
+
cmd.command("cost <ids...>").description(
|
|
5678
|
+
"credits each identifier is charged \u2014 a model id, a credit id, or a metered LLM price key (<feature>:<model>[:direct]); an estimate prints as ~N"
|
|
5679
|
+
).option("--profile <name>").option("--json").addHelpText(
|
|
5680
|
+
"after",
|
|
5681
|
+
`
|
|
5682
|
+
A metered LLM price key (llmPriceKey from @nodaro/shared/llm-models) is
|
|
5683
|
+
charged for the tokens the call actually uses, so its figure is an estimate of
|
|
5684
|
+
a typical call and prints as ~N. Every model's per-token rate:
|
|
5685
|
+
docs/pricing/llm-models.md.
|
|
5686
|
+
|
|
5687
|
+
Examples:
|
|
5688
|
+
$ nodaro models cost nano-banana-pro seedance-2-fast
|
|
5689
|
+
$ nodaro models cost llm-chat:gemini-3.6-flash llm-chat:claude-opus-5.5:direct
|
|
5690
|
+
$ nodaro models cost llm-chat:claude-fable-5 --json`
|
|
5691
|
+
).action(async (ids, opts) => {
|
|
5692
|
+
try {
|
|
5693
|
+
const client = buildClient(opts.profile);
|
|
5694
|
+
const result = await client.credits.modelCosts(ids);
|
|
5695
|
+
if (opts.json) {
|
|
5696
|
+
emit(result, opts);
|
|
5697
|
+
return;
|
|
5698
|
+
}
|
|
5699
|
+
table(costRows(ids, result), ["id", "credits", "note"]);
|
|
5700
|
+
} catch (err) {
|
|
5701
|
+
handleError(err);
|
|
5702
|
+
}
|
|
5703
|
+
});
|
|
5618
5704
|
return cmd;
|
|
5619
5705
|
}
|
|
5706
|
+
function costRows(ids, result) {
|
|
5707
|
+
const estimates = new Set(result.estimates ?? []);
|
|
5708
|
+
const missing = new Set(result.missing);
|
|
5709
|
+
const errors = new Set(result.errors);
|
|
5710
|
+
return [...new Set(ids)].map((id) => {
|
|
5711
|
+
const credits = result.data[id];
|
|
5712
|
+
if (typeof credits === "number") {
|
|
5713
|
+
const estimate = estimates.has(id);
|
|
5714
|
+
return { id, credits: estimate ? `~${credits}` : String(credits), note: estimate ? "estimate: charged per token used" : "" };
|
|
5715
|
+
}
|
|
5716
|
+
if (errors.has(id)) return { id, credits: "-", note: terminalSafe(result.errorCodes?.[id]?.message ?? "could not be priced") };
|
|
5717
|
+
if (missing.has(id)) return { id, credits: "-", note: "no price on this server" };
|
|
5718
|
+
return { id, credits: "-", note: "not asked (over the batch limit)" };
|
|
5719
|
+
});
|
|
5720
|
+
}
|
|
5620
5721
|
function readJsonObject2(path, flag) {
|
|
5621
5722
|
let raw;
|
|
5622
5723
|
try {
|
|
@@ -5821,6 +5922,271 @@ function recastCommand() {
|
|
|
5821
5922
|
});
|
|
5822
5923
|
return cmd;
|
|
5823
5924
|
}
|
|
5925
|
+
var RESOLUTIONS = ["480p", "720p", "1080p"];
|
|
5926
|
+
var SLOT_KEY_RE = /^[a-z0-9_]{1,32}$/;
|
|
5927
|
+
var URL_SPLIT_RE = /,(?=\s*https?:\/\/)/i;
|
|
5928
|
+
var CHIPS = ["body", "outfit", "hair", "coat", "shape", "finish"];
|
|
5929
|
+
function addRunFlags(cmd) {
|
|
5930
|
+
return cmd.option(
|
|
5931
|
+
"--slot <key=url[,url]>",
|
|
5932
|
+
"a slot's pictures, 1-3 per slot (repeat for each slot; the same key again adds pictures)",
|
|
5933
|
+
collectVariadic
|
|
5934
|
+
).option(
|
|
5935
|
+
"--choice <key.chip=new|original>",
|
|
5936
|
+
"a slot's chip: make it anew from your pictures or keep the clip's, e.g. person.outfit=original (repeatable)",
|
|
5937
|
+
collectVariadic
|
|
5938
|
+
).option("--example <n>", "1-based example whose pictures fill the optional slots you leave empty (default 1)").option("--details <text>", "your own words (at most 1,000 characters); mention a slot as {slot:<key>}").option("--preview", "a 4-second preview run (only when the trend offers one)").addOption(new Option("--resolution <r>", "default 480p").choices([...RESOLUTIONS])).option("--no-draft", "a full run instead of a draft (a draft is 480p only, and the default there)");
|
|
5939
|
+
}
|
|
5940
|
+
function checkSlotKey(flag, spec, key2) {
|
|
5941
|
+
if (!SLOT_KEY_RE.test(key2) || key2 === "__proto__") {
|
|
5942
|
+
throw new Error(`${flag} ${spec}: "${key2}" is not a slot key (lowercase letters, digits and _, up to 32; see \`nodaro trends get <slug>\`)`);
|
|
5943
|
+
}
|
|
5944
|
+
}
|
|
5945
|
+
function parseSlot(spec) {
|
|
5946
|
+
const eq = spec.indexOf("=");
|
|
5947
|
+
const key2 = eq === -1 ? "" : spec.slice(0, eq).trim();
|
|
5948
|
+
const images = eq === -1 ? [] : spec.slice(eq + 1).split(URL_SPLIT_RE).map((u) => u.trim()).filter(Boolean);
|
|
5949
|
+
if (!key2 || images.length === 0) {
|
|
5950
|
+
throw new Error(`--slot ${spec}: expected key=url[,url], e.g. --slot person=https://example.com/me.jpg`);
|
|
5951
|
+
}
|
|
5952
|
+
checkSlotKey("--slot", spec, key2);
|
|
5953
|
+
return { key: key2, images };
|
|
5954
|
+
}
|
|
5955
|
+
function parseChoice(spec) {
|
|
5956
|
+
const eq = spec.indexOf("=");
|
|
5957
|
+
const target = eq === -1 ? "" : spec.slice(0, eq).trim();
|
|
5958
|
+
const value = eq === -1 ? "" : spec.slice(eq + 1).trim();
|
|
5959
|
+
const dot = target.lastIndexOf(".");
|
|
5960
|
+
const key2 = dot === -1 ? "" : target.slice(0, dot);
|
|
5961
|
+
const chip = dot === -1 ? "" : target.slice(dot + 1);
|
|
5962
|
+
if (!key2 || !chip) {
|
|
5963
|
+
throw new Error(`--choice ${spec}: expected key.chip=new|original, e.g. --choice person.outfit=original`);
|
|
5964
|
+
}
|
|
5965
|
+
if (!CHIPS.includes(chip)) {
|
|
5966
|
+
throw new Error(`--choice ${spec}: the chip must be one of ${CHIPS.slice(0, -1).join(", ")} or ${CHIPS.at(-1)}`);
|
|
5967
|
+
}
|
|
5968
|
+
if (value !== "new" && value !== "original") {
|
|
5969
|
+
throw new Error(`--choice ${spec}: the value must be new or original`);
|
|
5970
|
+
}
|
|
5971
|
+
checkSlotKey("--choice", spec, key2);
|
|
5972
|
+
return { key: key2, chip, value };
|
|
5973
|
+
}
|
|
5974
|
+
function parseLimit(raw) {
|
|
5975
|
+
if (raw === void 0) return void 0;
|
|
5976
|
+
const n = Number(raw);
|
|
5977
|
+
if (!/^\d+$/.test(raw.trim()) || !Number.isInteger(n) || n < 1 || n > 60) {
|
|
5978
|
+
throw new Error(`--limit ${raw}: expected a whole number from 1 to 60`);
|
|
5979
|
+
}
|
|
5980
|
+
return n;
|
|
5981
|
+
}
|
|
5982
|
+
function buildRequest(flags) {
|
|
5983
|
+
const slots = /* @__PURE__ */ Object.create(null);
|
|
5984
|
+
for (const spec of flags.slot ?? []) {
|
|
5985
|
+
const { key: key2, images } = parseSlot(spec);
|
|
5986
|
+
const slot = slots[key2] ??= {};
|
|
5987
|
+
slot.images = [...slot.images ?? [], ...images];
|
|
5988
|
+
}
|
|
5989
|
+
for (const spec of flags.choice ?? []) {
|
|
5990
|
+
const { key: key2, chip, value } = parseChoice(spec);
|
|
5991
|
+
(slots[key2] ??= {})[chip] = value;
|
|
5992
|
+
}
|
|
5993
|
+
const request = { slots };
|
|
5994
|
+
if (flags.example !== void 0) {
|
|
5995
|
+
const n = Number(flags.example);
|
|
5996
|
+
if (!Number.isInteger(n) || n < 1) throw new Error(`--example ${flags.example}: expected a whole number from 1`);
|
|
5997
|
+
request.example = n;
|
|
5998
|
+
}
|
|
5999
|
+
if (flags.details !== void 0) request.details = flags.details;
|
|
6000
|
+
if (flags.preview) request.preview = true;
|
|
6001
|
+
if (flags.resolution) request.resolution = flags.resolution;
|
|
6002
|
+
if (flags.draft === false) request.draft = false;
|
|
6003
|
+
return request;
|
|
6004
|
+
}
|
|
6005
|
+
function trendsCommand() {
|
|
6006
|
+
const cmd = new Command("trends").description(
|
|
6007
|
+
"trends \u2014 ready-made Cast Swap recipes: browse, quote, run with your own pictures, favorite (Cloud edition)"
|
|
6008
|
+
);
|
|
6009
|
+
cmd.command("list").description("the published trend catalog, in its curated order").option("--search <text>", "search text").option("--tag <tag>", "only trends with this tag").option("--favorites", "only your favorites").option("--locale <locale>", "language of names and descriptions (default your profile's, then English)").option("--limit <n>", "page size (1-60)").option("--cursor <cursor>", "the previous page's next").option("--profile <name>").option("--json").action(async (opts) => {
|
|
6010
|
+
try {
|
|
6011
|
+
const limit = parseLimit(opts.limit);
|
|
6012
|
+
const client = buildClient(opts.profile);
|
|
6013
|
+
const page = await client.trends.list({
|
|
6014
|
+
q: opts.search,
|
|
6015
|
+
tag: opts.tag,
|
|
6016
|
+
favorites: opts.favorites,
|
|
6017
|
+
locale: opts.locale,
|
|
6018
|
+
limit,
|
|
6019
|
+
cursor: opts.cursor
|
|
6020
|
+
});
|
|
6021
|
+
if (opts.json) {
|
|
6022
|
+
emit(page, opts);
|
|
6023
|
+
return;
|
|
6024
|
+
}
|
|
6025
|
+
table(
|
|
6026
|
+
page.data.map((t) => ({
|
|
6027
|
+
slug: t.slug,
|
|
6028
|
+
name: t.name,
|
|
6029
|
+
needs: Object.entries(t.needs).filter(([, n]) => n > 0).map(([kind, n]) => `${n} ${kind}`).join(", "),
|
|
6030
|
+
seconds: t.durationSec,
|
|
6031
|
+
tags: t.tags.join(", "),
|
|
6032
|
+
favorite: t.isFavorite ? "\u2605" : ""
|
|
6033
|
+
})),
|
|
6034
|
+
["slug", "name", "needs", "seconds", "tags", "favorite"]
|
|
6035
|
+
);
|
|
6036
|
+
if (page.next) dim(`next: --cursor ${page.next}`);
|
|
6037
|
+
} catch (err) {
|
|
6038
|
+
handleError(err);
|
|
6039
|
+
}
|
|
6040
|
+
});
|
|
6041
|
+
cmd.command("get <slug>").description("a trend's page: its slots, examples, preview and resolutions").option("--locale <locale>", "language of names and descriptions").option("--profile <name>").option("--json").action(async (slug, opts) => {
|
|
6042
|
+
try {
|
|
6043
|
+
const trend = await buildClient(opts.profile).trends.get(slug, { locale: opts.locale });
|
|
6044
|
+
if (opts.json) emit(trend, opts);
|
|
6045
|
+
else detail(trend);
|
|
6046
|
+
} catch (err) {
|
|
6047
|
+
handleError(err);
|
|
6048
|
+
}
|
|
6049
|
+
});
|
|
6050
|
+
addRunFlags(
|
|
6051
|
+
cmd.command("estimate <slug>").description("quote a run before starting it (free)")
|
|
6052
|
+
).option("--profile <name>").option("--json").action(async (slug, opts) => {
|
|
6053
|
+
try {
|
|
6054
|
+
const request = buildRequest(opts);
|
|
6055
|
+
const quote = await buildClient(opts.profile).trends.estimate(slug, request);
|
|
6056
|
+
if (opts.json) {
|
|
6057
|
+
emit(quote, opts);
|
|
6058
|
+
return;
|
|
6059
|
+
}
|
|
6060
|
+
info(
|
|
6061
|
+
`about ${quote.expectedCredits} credits` + (quote.holdCredits !== quote.expectedCredits ? ` (up to ${quote.holdCredits} held while it runs)` : "")
|
|
6062
|
+
);
|
|
6063
|
+
for (const [part, credits] of Object.entries(quote.breakdown)) dim(` ${terminalSafe(part)}: ${credits}`);
|
|
6064
|
+
} catch (err) {
|
|
6065
|
+
handleError(err);
|
|
6066
|
+
}
|
|
6067
|
+
});
|
|
6068
|
+
addRunFlags(
|
|
6069
|
+
cmd.command("run <slug>").description("start a run \u2014 SPENDS CREDITS; run `estimate` first. Prints the job to follow")
|
|
6070
|
+
).option("--session <id>", "a generation session of yours (accepted; not yet applied: trend runs are not filed into sessions yet)").option("--idempotency-key <key>", "8-200 characters; a retry with the same key returns the first run's job").option("--profile <name>").option("--json").action(async (slug, opts) => {
|
|
6071
|
+
try {
|
|
6072
|
+
const request = buildRequest(opts);
|
|
6073
|
+
if (opts.session) request.sessionId = opts.session;
|
|
6074
|
+
const result = await buildClient(opts.profile).trends.run(
|
|
6075
|
+
slug,
|
|
6076
|
+
request,
|
|
6077
|
+
opts.idempotencyKey ? { idempotencyKey: opts.idempotencyKey } : {}
|
|
6078
|
+
);
|
|
6079
|
+
if (opts.json) {
|
|
6080
|
+
emit(result, opts);
|
|
6081
|
+
return;
|
|
6082
|
+
}
|
|
6083
|
+
success(`started trend run \u2014 job ${result.jobId}`);
|
|
6084
|
+
dim(`follow it: nodaro jobs get ${result.jobId}`);
|
|
6085
|
+
} catch (err) {
|
|
6086
|
+
handleError(err);
|
|
6087
|
+
}
|
|
6088
|
+
});
|
|
6089
|
+
cmd.command("runs").description("your trend runs, newest first").option("--trend <slug>", "only runs of this trend").option("--limit <n>", "page size (1-60)").option("--cursor <cursor>", "the previous page's next").option("--profile <name>").option("--json").action(async (opts) => {
|
|
6090
|
+
try {
|
|
6091
|
+
const limit = parseLimit(opts.limit);
|
|
6092
|
+
const page = await buildClient(opts.profile).trends.runs({
|
|
6093
|
+
trend: opts.trend,
|
|
6094
|
+
cursor: opts.cursor,
|
|
6095
|
+
limit
|
|
6096
|
+
});
|
|
6097
|
+
if (opts.json) {
|
|
6098
|
+
emit(page, opts);
|
|
6099
|
+
return;
|
|
6100
|
+
}
|
|
6101
|
+
table(
|
|
6102
|
+
page.data.map((r) => ({
|
|
6103
|
+
jobId: r.jobId,
|
|
6104
|
+
trend: r.trend.slug,
|
|
6105
|
+
status: r.status,
|
|
6106
|
+
resolution: r.preview ? `${r.resolution} preview` : r.resolution,
|
|
6107
|
+
draft: r.draft,
|
|
6108
|
+
credits: r.creditsCharged,
|
|
6109
|
+
createdAt: r.createdAt,
|
|
6110
|
+
video: r.videoUrl
|
|
6111
|
+
})),
|
|
6112
|
+
["jobId", "trend", "status", "resolution", "draft", "credits", "createdAt", "video"]
|
|
6113
|
+
);
|
|
6114
|
+
if (page.next) dim(`next: --cursor ${page.next}`);
|
|
6115
|
+
} catch (err) {
|
|
6116
|
+
handleError(err);
|
|
6117
|
+
}
|
|
6118
|
+
});
|
|
6119
|
+
cmd.command("favorite <slug>").description("add a trend to your favorites").option("--profile <name>").option("--json").action(async (slug, opts) => {
|
|
6120
|
+
try {
|
|
6121
|
+
await buildClient(opts.profile).trends.favorite(slug);
|
|
6122
|
+
if (opts.json) {
|
|
6123
|
+
emit({ success: true, slug }, opts);
|
|
6124
|
+
return;
|
|
6125
|
+
}
|
|
6126
|
+
success(`added ${terminalSafe(slug)} to your favorites`);
|
|
6127
|
+
} catch (err) {
|
|
6128
|
+
handleError(err);
|
|
6129
|
+
}
|
|
6130
|
+
});
|
|
6131
|
+
cmd.command("unfavorite <slug>").description("remove a trend from your favorites").option("--profile <name>").option("--json").action(async (slug, opts) => {
|
|
6132
|
+
try {
|
|
6133
|
+
await buildClient(opts.profile).trends.unfavorite(slug);
|
|
6134
|
+
if (opts.json) {
|
|
6135
|
+
emit({ success: true, slug }, opts);
|
|
6136
|
+
return;
|
|
6137
|
+
}
|
|
6138
|
+
success(`removed ${terminalSafe(slug)} from your favorites`);
|
|
6139
|
+
} catch (err) {
|
|
6140
|
+
handleError(err);
|
|
6141
|
+
}
|
|
6142
|
+
});
|
|
6143
|
+
return cmd;
|
|
6144
|
+
}
|
|
6145
|
+
function fullQualityCommand() {
|
|
6146
|
+
const cmd = new Command("full-quality").description(
|
|
6147
|
+
"finish a draft run (Cast Swap or trend) at Full Quality: the same take at 1080p, as a new job \u2014 `estimate` quotes it (free), `run` SPENDS CREDITS"
|
|
6148
|
+
);
|
|
6149
|
+
cmd.command("estimate <jobId>").description("quote finishing the draft at Full Quality (free): the credits, and until when the draft can be finished").option("--profile <name>").option("--json").action(async (jobId, opts) => {
|
|
6150
|
+
try {
|
|
6151
|
+
const quote = await buildClient(opts.profile).castSwap.fullQualityEstimate(jobId);
|
|
6152
|
+
if (opts.json) {
|
|
6153
|
+
emit(quote, opts);
|
|
6154
|
+
return;
|
|
6155
|
+
}
|
|
6156
|
+
info(`about ${quote.totalCredits} credits`);
|
|
6157
|
+
dim(` castSwap: ${quote.breakdown.castSwap}`);
|
|
6158
|
+
dim(` seedanceHd: ${quote.breakdown.seedanceHd}`);
|
|
6159
|
+
if (quote.breakdown.seedanceHd === 0) dim(" an earlier try's 1080p render is reused");
|
|
6160
|
+
dim(`available until ${terminalSafe(quote.availableUntil)}`);
|
|
6161
|
+
} catch (err) {
|
|
6162
|
+
handleError(err);
|
|
6163
|
+
}
|
|
6164
|
+
});
|
|
6165
|
+
cmd.command("run <jobId>").description("start Full Quality \u2014 SPENDS CREDITS; run `estimate` first. Prints the job to follow").option("--session <id>", "a generation session of yours to file the result in").option("--profile <name>").option("--json").action(async (jobId, opts) => {
|
|
6166
|
+
try {
|
|
6167
|
+
const result = await buildClient(opts.profile).castSwap.fullQuality(
|
|
6168
|
+
jobId,
|
|
6169
|
+
opts.session !== void 0 ? { sessionId: opts.session } : {}
|
|
6170
|
+
);
|
|
6171
|
+
if (opts.json) {
|
|
6172
|
+
emit(result, opts);
|
|
6173
|
+
return;
|
|
6174
|
+
}
|
|
6175
|
+
const id = terminalSafe(result.jobId);
|
|
6176
|
+
if (result.existing) info(`this draft's Full Quality already exists \u2014 job ${id} (nothing new was charged)`);
|
|
6177
|
+
else success(`started Full Quality \u2014 job ${id}`);
|
|
6178
|
+
dim(`follow it: nodaro jobs get ${id}`);
|
|
6179
|
+
} catch (err) {
|
|
6180
|
+
handleError(err);
|
|
6181
|
+
}
|
|
6182
|
+
});
|
|
6183
|
+
return cmd;
|
|
6184
|
+
}
|
|
6185
|
+
function castSwapCommand() {
|
|
6186
|
+
const cmd = new Command("cast-swap").description("Cast Swap \u2014 replace who and what is in a short video (Cloud edition)");
|
|
6187
|
+
cmd.addCommand(fullQualityCommand());
|
|
6188
|
+
return cmd;
|
|
6189
|
+
}
|
|
5824
6190
|
var ASSET_TYPE_TO_COLUMN = {
|
|
5825
6191
|
timeOfDay: "time_of_day",
|
|
5826
6192
|
weather: "weather",
|
|
@@ -6776,7 +7142,7 @@ function workspaceCommand() {
|
|
|
6776
7142
|
emit({ profile: name, workspaceId: workspaceId ?? null, source }, opts);
|
|
6777
7143
|
return;
|
|
6778
7144
|
}
|
|
6779
|
-
info(`profile: ${
|
|
7145
|
+
info(`profile: ${pc5.cyan(name)}`);
|
|
6780
7146
|
info(`workspace: ${workspaceId ?? "(personal space)"}`);
|
|
6781
7147
|
if (!profile) {
|
|
6782
7148
|
warn(`no credentials for profile "${name}" \u2014 run: nodaro auth login`);
|
|
@@ -6959,6 +7325,63 @@ function refuseUnknownPlanTier(planTier) {
|
|
|
6959
7325
|
process.exit(1);
|
|
6960
7326
|
}
|
|
6961
7327
|
}
|
|
7328
|
+
|
|
7329
|
+
// src/commands/edit-recordings.ts
|
|
7330
|
+
function withRecordingsOptions(cmd) {
|
|
7331
|
+
return cmd.requiredOption(
|
|
7332
|
+
"--media <url>",
|
|
7333
|
+
"the recording (video or audio URL, up to 3 hours); repeat it for the cameras of one conversation, in order (several need Speaker Map)",
|
|
7334
|
+
collectVariadic
|
|
7335
|
+
).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(
|
|
7336
|
+
"--speaker-camera <speaker=recording>",
|
|
7337
|
+
"with several recordings: put a speaker (1 = the first voice heard) on a --media number, 0 = the wide shot (repeatable)",
|
|
7338
|
+
collectVariadic
|
|
7339
|
+
);
|
|
7340
|
+
}
|
|
7341
|
+
var WHOLE = /^\d+$/;
|
|
7342
|
+
function recordingsInput(opts) {
|
|
7343
|
+
const several = opts.media.length > 1 || opts.masterAudio !== void 0;
|
|
7344
|
+
const cameraFlags = opts.wideCamera !== void 0 || opts.synced === true || (opts.speakerCamera?.length ?? 0) > 0;
|
|
7345
|
+
if (cameraFlags && !several) {
|
|
7346
|
+
warn("--wide-camera, --synced and --speaker-camera apply with several --media or --master-audio only");
|
|
7347
|
+
process.exit(1);
|
|
7348
|
+
}
|
|
7349
|
+
let wide;
|
|
7350
|
+
if (opts.wideCamera !== void 0) {
|
|
7351
|
+
if (!WHOLE.test(opts.wideCamera) || Number(opts.wideCamera) < 1) {
|
|
7352
|
+
warn(`--wide-camera must be a recording number, 1 or more (got "${opts.wideCamera}")`);
|
|
7353
|
+
process.exit(1);
|
|
7354
|
+
}
|
|
7355
|
+
wide = Number(opts.wideCamera);
|
|
7356
|
+
}
|
|
7357
|
+
const speakerCameras = {};
|
|
7358
|
+
for (const pair of opts.speakerCamera ?? []) {
|
|
7359
|
+
const [speaker, recording, ...extra] = pair.split("=");
|
|
7360
|
+
if (extra.length > 0 || !speaker || !recording || !WHOLE.test(speaker) || !WHOLE.test(recording) || Number(speaker) < 1) {
|
|
7361
|
+
warn(`--speaker-camera must be <speaker>=<recording>: a speaker 1 or more, a --media number or 0 for the wide shot (got "${pair}")`);
|
|
7362
|
+
process.exit(1);
|
|
7363
|
+
}
|
|
7364
|
+
const key2 = String(Number(speaker));
|
|
7365
|
+
if (key2 in speakerCameras) {
|
|
7366
|
+
warn(`--speaker-camera names speaker ${key2} twice`);
|
|
7367
|
+
process.exit(1);
|
|
7368
|
+
}
|
|
7369
|
+
speakerCameras[key2] = Number(recording);
|
|
7370
|
+
}
|
|
7371
|
+
const cameras = {
|
|
7372
|
+
...wide !== void 0 ? { wide } : {},
|
|
7373
|
+
...opts.synced ? { synced: true } : {},
|
|
7374
|
+
...Object.keys(speakerCameras).length > 0 ? { speakerCameras } : {}
|
|
7375
|
+
};
|
|
7376
|
+
return {
|
|
7377
|
+
// One --media is the one-recording request it always was.
|
|
7378
|
+
...opts.media.length === 1 ? { mediaUrl: opts.media[0] } : { mediaUrls: [...opts.media] },
|
|
7379
|
+
...opts.masterAudio !== void 0 ? { masterAudioUrl: opts.masterAudio } : {},
|
|
7380
|
+
...Object.keys(cameras).length > 0 ? { cameras } : {}
|
|
7381
|
+
};
|
|
7382
|
+
}
|
|
7383
|
+
|
|
7384
|
+
// src/commands/edit-use-case.ts
|
|
6962
7385
|
var EMPHASIS_HELP = `none, or ${SPEAKER_EMPHASIS_STYLES.filter((s) => s !== "none").join(", ")} joined with "+" (each once)`;
|
|
6963
7386
|
var CONTINUATION_NEXT_STEP = {
|
|
6964
7387
|
already_running: (id) => ` \u2014 follow it: nodaro jobs get ${id}`,
|
|
@@ -6967,7 +7390,13 @@ var CONTINUATION_NEXT_STEP = {
|
|
|
6967
7390
|
};
|
|
6968
7391
|
function registerUseCaseCommands(cmd) {
|
|
6969
7392
|
const framingLayouts = ["auto", ...SPEAKER_LAYOUT_IDS];
|
|
6970
|
-
|
|
7393
|
+
const FRAMING_SOURCES = Object.keys({ auto: true, static: true, tracking: true });
|
|
7394
|
+
withRecordingsOptions(
|
|
7395
|
+
cmd.command("tighten-episode").description("tighten a podcast recording in one step (transcribe, cut silences, render; optional captions, music and framing)")
|
|
7396
|
+
).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(
|
|
7397
|
+
"--framing-source <source>",
|
|
7398
|
+
`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)`
|
|
7399
|
+
).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
7400
|
async (opts, command) => {
|
|
6972
7401
|
if (opts.output !== void 0 && opts.output !== "video" && opts.output !== "audio") {
|
|
6973
7402
|
warn(`--output must be "video" or "audio" (got "${opts.output}")`);
|
|
@@ -6986,13 +7415,23 @@ function registerUseCaseCommands(cmd) {
|
|
|
6986
7415
|
warn(`--layout must be ${framingLayouts.join(", ")} (got "${opts.layout}")`);
|
|
6987
7416
|
process.exit(1);
|
|
6988
7417
|
}
|
|
7418
|
+
if (opts.framingSource !== void 0 && opts.framing === void 0) {
|
|
7419
|
+
warn("--framing-source applies with --framing only (it picks how the framing follows the speakers)");
|
|
7420
|
+
process.exit(1);
|
|
7421
|
+
}
|
|
7422
|
+
if (opts.framingSource !== void 0 && !FRAMING_SOURCES.includes(opts.framingSource)) {
|
|
7423
|
+
warn(`--framing-source must be ${FRAMING_SOURCES.join(", ")} (got "${opts.framingSource}")`);
|
|
7424
|
+
process.exit(1);
|
|
7425
|
+
}
|
|
7426
|
+
const recordings = recordingsInput(opts);
|
|
6989
7427
|
try {
|
|
6990
7428
|
const client = buildClient(opts.profile);
|
|
6991
7429
|
const result = await client.edit.tightenEpisode({
|
|
6992
|
-
|
|
7430
|
+
...recordings,
|
|
6993
7431
|
...opts.music ? { musicUrl: opts.music } : {},
|
|
6994
7432
|
...opts.output ? { output: opts.output } : {},
|
|
6995
7433
|
...opts.framing ? { framing: { aspect: opts.framing, layout: opts.layout ?? "auto" } } : {},
|
|
7434
|
+
...opts.framingSource ? { framingSource: opts.framingSource } : {},
|
|
6996
7435
|
// commander's --no-captions defaults `captions` to true: send it only when turned off.
|
|
6997
7436
|
...opts.captions === false ? { captions: false } : {},
|
|
6998
7437
|
...opts.review ? { reviewBeforeRender: true } : {},
|
|
@@ -7037,7 +7476,9 @@ function registerUseCaseCommands(cmd) {
|
|
|
7037
7476
|
}
|
|
7038
7477
|
}
|
|
7039
7478
|
);
|
|
7040
|
-
|
|
7479
|
+
withRecordingsOptions(
|
|
7480
|
+
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")
|
|
7481
|
+
).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
7482
|
async (opts) => {
|
|
7042
7483
|
const formats = opts.formats?.split(",").map((f) => f.trim()).filter((f) => f.length > 0);
|
|
7043
7484
|
if (formats !== void 0 && (formats.length === 0 || formats.some((f) => !TRAILER_FORMATS.includes(f)))) {
|
|
@@ -7045,11 +7486,12 @@ function registerUseCaseCommands(cmd) {
|
|
|
7045
7486
|
process.exit(1);
|
|
7046
7487
|
}
|
|
7047
7488
|
refuseUnknownPlanTier(opts.planTier);
|
|
7489
|
+
const recordings = recordingsInput(opts);
|
|
7048
7490
|
try {
|
|
7049
7491
|
const client = buildClient(opts.profile);
|
|
7050
7492
|
const result = await client.edit.episodeTrailer(
|
|
7051
7493
|
{
|
|
7052
|
-
|
|
7494
|
+
...recordings,
|
|
7053
7495
|
...opts.introCard ? { introCardUrl: opts.introCard } : {},
|
|
7054
7496
|
...formats ? { formats } : {},
|
|
7055
7497
|
...opts.review ? { reviewBeforeRender: true } : {},
|
|
@@ -7074,14 +7516,19 @@ function registerUseCaseCommands(cmd) {
|
|
|
7074
7516
|
const failed = Array.isArray(out.failedFormats) ? out.failedFormats.filter((f) => typeof f === "string") : [];
|
|
7075
7517
|
if (failed.length > 0) console.log(`Could not render: ${failed.join(", ")}`);
|
|
7076
7518
|
}
|
|
7077
|
-
if (opts.review) console.log(
|
|
7519
|
+
if (opts.review) console.log(pc5.dim(` render every format after your review: nodaro edit continue-use-case ${result.jobId} --mode render-final`));
|
|
7078
7520
|
} catch (err) {
|
|
7079
7521
|
handleError(err);
|
|
7080
7522
|
}
|
|
7081
7523
|
}
|
|
7082
7524
|
);
|
|
7083
7525
|
const isWhole = (v, min, max) => v !== void 0 && /^\d+$/.test(v.trim()) && Number(v) >= min && Number(v) <= max;
|
|
7084
|
-
|
|
7526
|
+
withRecordingsOptions(
|
|
7527
|
+
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)")
|
|
7528
|
+
).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(
|
|
7529
|
+
"--framing-source <source>",
|
|
7530
|
+
`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)`
|
|
7531
|
+
).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(
|
|
7085
7532
|
async (opts) => {
|
|
7086
7533
|
if (opts.count !== void 0 && !isWhole(opts.count, 1, EDIT_PLAN_MAX_CLIP_COUNT)) {
|
|
7087
7534
|
warn(`--count must be 1\u2013${EDIT_PLAN_MAX_CLIP_COUNT} (got "${opts.count}")`);
|
|
@@ -7117,6 +7564,14 @@ function registerUseCaseCommands(cmd) {
|
|
|
7117
7564
|
warn(`--emphasis must be ${EMPHASIS_HELP} (got "${opts.emphasis}")`);
|
|
7118
7565
|
process.exit(1);
|
|
7119
7566
|
}
|
|
7567
|
+
if (opts.framingSource !== void 0 && opts.framing === "none") {
|
|
7568
|
+
warn("--framing-source applies with a framing only (not with --framing none)");
|
|
7569
|
+
process.exit(1);
|
|
7570
|
+
}
|
|
7571
|
+
if (opts.framingSource !== void 0 && !FRAMING_SOURCES.includes(opts.framingSource)) {
|
|
7572
|
+
warn(`--framing-source must be ${FRAMING_SOURCES.join(", ")} (got "${opts.framingSource}")`);
|
|
7573
|
+
process.exit(1);
|
|
7574
|
+
}
|
|
7120
7575
|
if (opts.captionStyle !== void 0 && opts.captions === false) {
|
|
7121
7576
|
warn("--caption-style applies with captions on (drop --no-captions)");
|
|
7122
7577
|
process.exit(1);
|
|
@@ -7126,11 +7581,12 @@ function registerUseCaseCommands(cmd) {
|
|
|
7126
7581
|
process.exit(1);
|
|
7127
7582
|
}
|
|
7128
7583
|
refuseUnknownPlanTier(opts.planTier);
|
|
7584
|
+
const recordings = recordingsInput(opts);
|
|
7129
7585
|
try {
|
|
7130
7586
|
const client = buildClient(opts.profile);
|
|
7131
7587
|
const result = await client.edit.clipPack(
|
|
7132
7588
|
{
|
|
7133
|
-
|
|
7589
|
+
...recordings,
|
|
7134
7590
|
...opts.count !== void 0 ? { count: Number(opts.count) } : {},
|
|
7135
7591
|
...opts.length !== void 0 ? { targetDurationSec: Number(opts.length) } : {},
|
|
7136
7592
|
// none = the recording's shape; an aspect alone leaves the layout to the route (stacked).
|
|
@@ -7142,6 +7598,7 @@ function registerUseCaseCommands(cmd) {
|
|
|
7142
7598
|
...opts.emphasis ? { emphasisStyle: opts.emphasis } : {}
|
|
7143
7599
|
}
|
|
7144
7600
|
} : {},
|
|
7601
|
+
...opts.framingSource ? { framingSource: opts.framingSource } : {},
|
|
7145
7602
|
// commander's --no-captions defaults `captions` to true: send it only when turned off.
|
|
7146
7603
|
...opts.captions === false ? { captions: false } : {},
|
|
7147
7604
|
...opts.captionStyle ? { captionStyle: opts.captionStyle } : {},
|
|
@@ -7170,13 +7627,71 @@ function registerUseCaseCommands(cmd) {
|
|
|
7170
7627
|
const failed = typeof out.failedClips === "number" && out.failedClips > 0 ? out.failedClips : 0;
|
|
7171
7628
|
if (failed > 0) console.log(failed === 1 ? "1 clip could not be rendered." : `${failed} clips could not be rendered.`);
|
|
7172
7629
|
}
|
|
7173
|
-
if (opts.review) console.log(
|
|
7630
|
+
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>]`));
|
|
7631
|
+
} catch (err) {
|
|
7632
|
+
handleError(err);
|
|
7633
|
+
}
|
|
7634
|
+
}
|
|
7635
|
+
);
|
|
7636
|
+
const LAYOUT_FRAMING_SOURCES = Object.keys({ auto: true, static: true, tracking: true });
|
|
7637
|
+
withRecordingsOptions(
|
|
7638
|
+
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)")
|
|
7639
|
+
).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(
|
|
7640
|
+
"--framing-source <source>",
|
|
7641
|
+
`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)`
|
|
7642
|
+
).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(
|
|
7643
|
+
async (opts) => {
|
|
7644
|
+
if (opts.aspect !== void 0 && !EDL_TARGET_ASPECTS.includes(opts.aspect)) {
|
|
7645
|
+
warn(`--aspect must be ${EDL_TARGET_ASPECTS.join(", ")} (got "${opts.aspect}")`);
|
|
7646
|
+
process.exit(1);
|
|
7647
|
+
}
|
|
7648
|
+
if (opts.layout !== void 0 && !framingLayouts.includes(opts.layout)) {
|
|
7649
|
+
warn(`--layout must be ${framingLayouts.join(", ")} (got "${opts.layout}")`);
|
|
7650
|
+
process.exit(1);
|
|
7651
|
+
}
|
|
7652
|
+
if (opts.switch !== void 0 && !SPEAKER_SWITCH_IDS.includes(opts.switch)) {
|
|
7653
|
+
warn(`--switch must be one of ${SPEAKER_SWITCH_IDS.join(", ")} (got "${opts.switch}")`);
|
|
7654
|
+
process.exit(1);
|
|
7655
|
+
}
|
|
7656
|
+
if (opts.emphasis !== void 0 && !isKnownSpeakerEmphasisStyle(opts.emphasis)) {
|
|
7657
|
+
warn(`--emphasis must be ${EMPHASIS_HELP} (got "${opts.emphasis}")`);
|
|
7658
|
+
process.exit(1);
|
|
7659
|
+
}
|
|
7660
|
+
if (opts.framingSource !== void 0 && !LAYOUT_FRAMING_SOURCES.includes(opts.framingSource)) {
|
|
7661
|
+
warn(`--framing-source must be ${LAYOUT_FRAMING_SOURCES.join(", ")} (got "${opts.framingSource}")`);
|
|
7662
|
+
process.exit(1);
|
|
7663
|
+
}
|
|
7664
|
+
const recordings = recordingsInput(opts);
|
|
7665
|
+
try {
|
|
7666
|
+
const client = buildClient(opts.profile);
|
|
7667
|
+
const result = await client.edit.speakerLayout(
|
|
7668
|
+
{
|
|
7669
|
+
...recordings,
|
|
7670
|
+
...opts.aspect ? { targetAspect: opts.aspect } : {},
|
|
7671
|
+
...opts.layout ? { layout: opts.layout } : {},
|
|
7672
|
+
...opts.switch ? { switchType: opts.switch } : {},
|
|
7673
|
+
...opts.emphasis ? { emphasisStyle: opts.emphasis } : {},
|
|
7674
|
+
...opts.framingSource ? { framingSource: opts.framingSource } : {},
|
|
7675
|
+
...opts.review ? { reviewBeforeRender: true } : {}
|
|
7676
|
+
},
|
|
7677
|
+
opts.idempotencyKey ? { idempotencyKey: opts.idempotencyKey } : void 0
|
|
7678
|
+
);
|
|
7679
|
+
const done = await reportQueuedJob(result, () => client.jobs.getStatus(result.jobId), {
|
|
7680
|
+
json: opts.json,
|
|
7681
|
+
watch: opts.watch,
|
|
7682
|
+
pollInterval: opts.pollInterval,
|
|
7683
|
+
note: "speaker-layout"
|
|
7684
|
+
});
|
|
7685
|
+
if (opts.json) return;
|
|
7686
|
+
const url = done?.data.output_data?.videoUrl;
|
|
7687
|
+
if (done?.data.status === "completed" && typeof url === "string") console.log(url);
|
|
7688
|
+
if (opts.review) console.log(pc5.dim(` render the final after your review: nodaro edit continue-use-case ${result.jobId} --mode render-final`));
|
|
7174
7689
|
} catch (err) {
|
|
7175
7690
|
handleError(err);
|
|
7176
7691
|
}
|
|
7177
7692
|
}
|
|
7178
7693
|
);
|
|
7179
|
-
cmd.command("continue-use-case <jobId>").description("continue a Tighten Episode, Chapters, Trailer
|
|
7694
|
+
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(
|
|
7180
7695
|
"--type <type>",
|
|
7181
7696
|
`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
7697
|
).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) => {
|
|
@@ -7214,9 +7729,9 @@ function registerUseCaseCommands(cmd) {
|
|
|
7214
7729
|
if (opts.json) {
|
|
7215
7730
|
emit({ error: { code: err.code, message: err.message }, jobId: err.jobId }, opts);
|
|
7216
7731
|
} else {
|
|
7217
|
-
console.error(
|
|
7218
|
-
console.error(
|
|
7219
|
-
console.error(
|
|
7732
|
+
console.error(pc5.red(`\u2717 ${err.message}`));
|
|
7733
|
+
console.error(pc5.dim(` code: ${err.code}`));
|
|
7734
|
+
console.error(pc5.dim(` job: ${err.jobId}${CONTINUATION_NEXT_STEP[err.code]?.(err.jobId) ?? ""}`));
|
|
7220
7735
|
}
|
|
7221
7736
|
process.exit(1);
|
|
7222
7737
|
}
|
|
@@ -7225,9 +7740,9 @@ function registerUseCaseCommands(cmd) {
|
|
|
7225
7740
|
if (opts.json) {
|
|
7226
7741
|
emit({ error: { code: err.code, message } }, opts);
|
|
7227
7742
|
} else {
|
|
7228
|
-
console.error(
|
|
7229
|
-
console.error(
|
|
7230
|
-
console.error(
|
|
7743
|
+
console.error(pc5.red(`\u2717 ${message}`));
|
|
7744
|
+
console.error(pc5.dim(` code: ${err.code}`));
|
|
7745
|
+
console.error(pc5.dim(` --type: ${USE_CASE_NODE_TYPES.join(" | ")}`));
|
|
7231
7746
|
}
|
|
7232
7747
|
process.exit(1);
|
|
7233
7748
|
}
|
|
@@ -7840,6 +8355,8 @@ program.addCommand(catalogCommand());
|
|
|
7840
8355
|
program.addCommand(modelsCommand());
|
|
7841
8356
|
program.addCommand(shotsCommand());
|
|
7842
8357
|
program.addCommand(recastCommand());
|
|
8358
|
+
program.addCommand(trendsCommand());
|
|
8359
|
+
program.addCommand(castSwapCommand());
|
|
7843
8360
|
program.addCommand(orgCommand());
|
|
7844
8361
|
program.addCommand(workspaceCommand());
|
|
7845
8362
|
program.addCommand(editCommand());
|