@aicopycoders/exodus 2026.11.700-beta.1 → 2026.11.1000-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +357 -0
- package/assets/skills/exodus-video/SKILL.md +309 -1
- package/assets/skills/exodus-video/scripts/first-cut-text.d.mts +4 -1
- package/assets/skills/exodus-video/scripts/first-cut-text.mjs +20 -2
- package/assets/skills/exodus-video/scripts/first-cut.d.mts +80 -4
- package/assets/skills/exodus-video/scripts/first-cut.mjs +1248 -132
- package/assets/skills/swipe/SKILL.md +11 -2
- package/dist/commands/video-customer.d.ts +1 -1
- package/dist/commands/video-customer.js +7 -0
- package/dist/commands/video.d.ts +160 -2
- package/dist/commands/video.js +1633 -43
- package/dist/commands/workflow.d.ts +3 -3
- package/dist/commands/workflow.js +20 -2
- package/dist/lib/templateBrief.d.ts +7 -0
- package/dist/lib/templateBrief.js +9 -0
- package/package.json +1 -1
package/dist/commands/video.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
1
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { apiGet, apiPost, getDashboardUrl } from "../lib/client.js";
|
|
@@ -6,7 +6,8 @@ import { displayRunStatus, formatApiError } from "../lib/format.js";
|
|
|
6
6
|
import { isWorkerStoppedPark } from "../lib/runStatus.js";
|
|
7
7
|
import { missingRouteLine } from "../lib/route-support.js";
|
|
8
8
|
import { probeDurationSec } from "../lib/preflight.js";
|
|
9
|
-
import {
|
|
9
|
+
import { composeTemplateBrief } from "../lib/templateBrief.js";
|
|
10
|
+
import { ASSET_UPLOAD_POLICY, pauseAheadLine, parseVoicesFlag, } from "./workflow.js";
|
|
10
11
|
import { HELPER_LEDGER_BASE, SET_OPTION_LEDGER_BASE } from "../lib/helperLedgerBase.js";
|
|
11
12
|
import { customerAnswer, customerRunPage, customerStageIsWorking, customerStageLines, customerStatusLines, customerStoryboardLines, customerVoicesLines, } from "./video-customer.js";
|
|
12
13
|
const VOICE_MODES = ["native", "voice-first"];
|
|
@@ -62,6 +63,16 @@ The whole loop, in order:
|
|
|
62
63
|
also settle the voices here, at the launch, instead of at step 5 — the
|
|
63
64
|
launch flags all live in: exodus workflow --help
|
|
64
65
|
|
|
66
|
+
A format with a picks stop stops first, before anything is planned:
|
|
67
|
+
exodus video picks <runId>
|
|
68
|
+
The faces, voices and rooms it drew for each person and place, a link
|
|
69
|
+
each.
|
|
70
|
+
exodus video pick <runId> --face <who>=<n> --voice <who>=<n> --room <place>=<n>
|
|
71
|
+
Nothing is planned until every slot has a pick. A pick that leaves one
|
|
72
|
+
open is saved and starts nothing.
|
|
73
|
+
exodus video picks <runId> --redo face:<who> --note "<what to change>"
|
|
74
|
+
Four new paid pictures for one face or room.
|
|
75
|
+
|
|
65
76
|
4. exodus video storyboard <runId>
|
|
66
77
|
The scene cards: what each scene says and the picture it will look like.
|
|
67
78
|
|
|
@@ -84,6 +95,12 @@ The whole loop, in order:
|
|
|
84
95
|
request, even on a One-shot run. Review its exact requests and prices here,
|
|
85
96
|
then approve those same requests with --request-quote <reviewSha256>.
|
|
86
97
|
|
|
98
|
+
A format with a pilot clip makes one clip after this approval and stops
|
|
99
|
+
again before the others. status prints the pilot's scene, whether its
|
|
100
|
+
clip was made, and every check that failed or could not run. Redo it
|
|
101
|
+
with retry-clip; approve again to make the other clips.
|
|
102
|
+
A One-shot run makes every clip without stopping.
|
|
103
|
+
|
|
87
104
|
7. exodus video status <runId>
|
|
88
105
|
Where the run is and how each scene's clip turned out. If the storyboard
|
|
89
106
|
failed, it also says which parts of it were accepted and why the next one
|
|
@@ -121,7 +138,8 @@ The whole loop, in order:
|
|
|
121
138
|
hear on the recording keeps it from being approved.
|
|
122
139
|
|
|
123
140
|
exodus video retry-clip <runId> --scene <n>
|
|
124
|
-
Redo ONE finished clip while the run waits for the cut
|
|
141
|
+
Redo ONE finished clip while the run waits for the cut, or redo the
|
|
142
|
+
pilot clip while the run waits after it. Everything
|
|
125
143
|
else stays. A --note steers the motion, never the words. Add
|
|
126
144
|
--voice-first when the words came out wrong: the line is recorded in
|
|
127
145
|
the character's own voice first, then the clip is made to match it.
|
|
@@ -149,6 +167,8 @@ Usage:
|
|
|
149
167
|
exodus video song <runId> [--json]
|
|
150
168
|
exodus video song approve <runId> --master <masterSha256> [--json]
|
|
151
169
|
exodus video song import <runId> --file <audio> --lyric <text|@file> --rights "<statement>" [--from <s> --to <s>] [--json]
|
|
170
|
+
exodus video picks <runId> [--redo face:<who>|room:<place>] [--note "..."] [--json]
|
|
171
|
+
exodus video pick <runId> [--face <who>=<n>] [--voice <who>=<n|name|id>] [--room <place>=<n>] [--style <key>] [--move <who>=<x>,<y>] [--note "..."] [--json]
|
|
152
172
|
exodus video storyboard <runId> [--json]
|
|
153
173
|
exodus video approve <runId> [--approve-stale-cut] [--json]
|
|
154
174
|
exodus video retry-frame <runId> [--node <nodeId>] --scene <n> [--note "..."] [--json]
|
|
@@ -163,6 +183,9 @@ Usage:
|
|
|
163
183
|
exodus video pull <runId> --out <dir> [--json]
|
|
164
184
|
exodus video upload <runId> --file <cut.mp4> [--duration <sec>] [--json]
|
|
165
185
|
exodus video start --script <file> --conceit <kind> --style <look> [--direction "<note>"] [--frame pov] [--pacing <jump-cuts|long-take|montage>] [--voice-path <path>] [--video-model <id>] [--voice <native|voice-first>] [--source-record <file.json>] [--adaptation-plan <file|original>] [--music] [--broll] [--one-shot] [--director] [--wait] [--json]
|
|
186
|
+
Template starts also accept: [--requested-seconds <seconds>] [--pictures-per-scene <1|3>] [--product <brandProductId>] [--elements <json|@file>] [--voices <json|@file>] [--resume-script <saved-stop-response.json>]
|
|
187
|
+
With --describe: [--product-context <text>] [--audience <text>] [--offer <text>] [--mechanism <text>]
|
|
188
|
+
exodus video start --input-options [--conceit <template>] [--voice <native|voice-first>] [--voice-path <path>] [--video-model <id>] [--json]
|
|
166
189
|
exodus video director <runId> <on|off|follow> [--json]
|
|
167
190
|
|
|
168
191
|
Options:
|
|
@@ -170,8 +193,9 @@ Options:
|
|
|
170
193
|
--file <cut.mp4> Your finished cut (upload). MP4, MOV or WebM, up to 200MB
|
|
171
194
|
--duration <sec> How long your cut is, in seconds. Only needed when the
|
|
172
195
|
length can't be read off the file itself
|
|
173
|
-
--note "<text>" How to steer one redo (retry-frame, retry-clip
|
|
174
|
-
what a B-roll shot should show (broll add,
|
|
196
|
+
--note "<text>" How to steer one redo (retry-frame, retry-clip, picks
|
|
197
|
+
--redo), what a B-roll shot should show (broll add,
|
|
198
|
+
broll move), or a note saved with your picks (pick)
|
|
175
199
|
--line <id> The script line a B-roll shot goes on (broll add,
|
|
176
200
|
broll move). exodus video broll <runId> lists the ids
|
|
177
201
|
--node <nodeId> Which scene-frames node holds the still (retry-frame;
|
|
@@ -199,6 +223,18 @@ Options:
|
|
|
199
223
|
--clear <who> Take a character's voice off again (voices). Repeatable
|
|
200
224
|
--from <file.json> A file of characters and voices, by name or ID (voices).
|
|
201
225
|
--set and --clear win over the same name in the file
|
|
226
|
+
--face <who>=<n> The face to keep for a person (pick). <who> is the name
|
|
227
|
+
the script uses, <n> the option picks printed. Repeat
|
|
228
|
+
it once per person
|
|
229
|
+
--voice <who>=<v> The voice for a person (pick): an option number, a
|
|
230
|
+
catalog voice's name or an ElevenLabs voice ID.
|
|
231
|
+
Repeatable
|
|
232
|
+
--room <place>=<n> The room to keep for a place (pick). Repeatable
|
|
233
|
+
--style <key> The director style (pick), when the run offers one
|
|
234
|
+
--move <who>=<x>,<y> Where a person stands on the blocking map, in metres
|
|
235
|
+
(pick). Refused until a format has a blocking map
|
|
236
|
+
--redo <slot> Four new paid pictures for face:<who> or room:<place>
|
|
237
|
+
(picks). The second redo of the same slot needs --note
|
|
202
238
|
--catalog List the voices you can pick by name (voices). No run
|
|
203
239
|
needed. With a run, also the best few for each
|
|
204
240
|
character who speaks
|
|
@@ -213,6 +249,45 @@ Options:
|
|
|
213
249
|
the server can't tell who says a line, it asks and
|
|
214
250
|
starts nothing. If a description is too thin to write
|
|
215
251
|
from, it says what is missing and starts nothing
|
|
252
|
+
--describe Template: explicitly write from the brief in --script.
|
|
253
|
+
Review the returned script before preparing a storyboard.
|
|
254
|
+
Cannot be combined with --adapt or --resume-script
|
|
255
|
+
--adapt <intent> Template: adapt the exact pasted text in --script to the
|
|
256
|
+
selected structure. State what may change; no new claims,
|
|
257
|
+
identities or consent are inferred. Review original and
|
|
258
|
+
changed text before continuing. Not --adaptation-plan
|
|
259
|
+
--keep-original With --adapt, intentionally review the exact original
|
|
260
|
+
instead of generating changes. Guards and billable checks
|
|
261
|
+
still require a quote; no adaptation is claimed
|
|
262
|
+
--input-mode <automatic|manual|hybrid>
|
|
263
|
+
Template INPUT assistance only, never --one-shot.
|
|
264
|
+
Explicit selections survive every mode. In Hybrid, blank
|
|
265
|
+
supported fields resolve automatically; locks still apply
|
|
266
|
+
--structure <key> A supported structure published for the selected template.
|
|
267
|
+
Unknown or incompatible structures are refused
|
|
268
|
+
--reference <key> A template's reference-ad inspiration, not a production
|
|
269
|
+
element, actor identity, soundtrack or voice permission
|
|
270
|
+
--subject <product|service|non-product>
|
|
271
|
+
Explicit subject, never guessed from the absence of
|
|
272
|
+
--product. Service/non-product cannot select a saved product
|
|
273
|
+
--template-brief <json|@file>
|
|
274
|
+
Template creative pins: { "cards": { "<layer>": "<card>" },
|
|
275
|
+
"settings": { "<name>": "<value>" } }. Discover supported
|
|
276
|
+
controls first; the server validates capabilities and locks
|
|
277
|
+
--song-controls <json|@file>
|
|
278
|
+
--mechanism-plan <json|@file>
|
|
279
|
+
Supported template song/story controls. JSON objects only;
|
|
280
|
+
server schema, capabilities and locks remain authoritative
|
|
281
|
+
Song controls require published songControls:true support;
|
|
282
|
+
{} or all-blank text controls explicitly clear saved Song pins
|
|
283
|
+
--quote-preparation Request only the current script or storyboard phase quote.
|
|
284
|
+
No writer/audio/image/video work. Save --json and review
|
|
285
|
+
estimatedUsd (approximate), maximumUsd (phase bound), scope
|
|
286
|
+
and expiry; this is not a whole-video price
|
|
287
|
+
--authorize-preparation <saved-quote.json>
|
|
288
|
+
Explicitly accept that quote's maximumUsd for its exact
|
|
289
|
+
phase/input. Never upgrades input Automatic to paid consent.
|
|
290
|
+
Keep the same file for recovery; no silent new quote/retry
|
|
216
291
|
--source-record <file.json>
|
|
217
292
|
A real ad's source record (start, with --conceit), for
|
|
218
293
|
a kind of ad that copies an ad shot for shot. Without
|
|
@@ -223,9 +298,49 @@ Options:
|
|
|
223
298
|
for a template that keeps its source's roles and beats,
|
|
224
299
|
or "original" for a brief with no source ad. Any other
|
|
225
300
|
kind refuses it
|
|
226
|
-
--stop-at-script Print the script the run would start on, and start
|
|
227
|
-
|
|
228
|
-
|
|
301
|
+
--stop-at-script Print the script the run would start on, and start no
|
|
302
|
+
storyboard/video run (start, with --conceit). Preparation
|
|
303
|
+
may still be paid. For templates, use
|
|
304
|
+
--json to save the approval, source and choices; edit only
|
|
305
|
+
a separate script file, then continue with --resume-script
|
|
306
|
+
--resume-script <saved-stop-response.json>
|
|
307
|
+
Continue a template's saved --stop-at-script --json
|
|
308
|
+
response with --script <edited.txt>, --conceit and
|
|
309
|
+
--style. Keep the server-issued approval, approved source,
|
|
310
|
+
brief, product, selected video model, signed references and voice map.
|
|
311
|
+
V2 also retains input intent/subject/structure/reference,
|
|
312
|
+
direction, sound/story choices and declared source/adaptation
|
|
313
|
+
records; material edits need a new quoted script review.
|
|
314
|
+
Explicit length, picture, --voice, --voice-path and
|
|
315
|
+
--video-model flags override their matching saved choices.
|
|
316
|
+
Changed or cleared --elements and --voices require
|
|
317
|
+
explicit --stop-at-script --json with
|
|
318
|
+
--resume-script to check the edited script and issue a new
|
|
319
|
+
approval; then resume that returned response to start.
|
|
320
|
+
Keep your original description and edited script files.
|
|
321
|
+
A different product still needs fresh writing and approval
|
|
322
|
+
without --resume-script.
|
|
323
|
+
Not for --show
|
|
324
|
+
--input-options List your templates: Golden Six first, then more templates.
|
|
325
|
+
Add --conceit <template> for structures, capabilities,
|
|
326
|
+
identity locks, references and account voices.
|
|
327
|
+
GET only: writes, quotes and starts nothing. Optional
|
|
328
|
+
--voice, --voice-path and --video-model require --conceit.
|
|
329
|
+
Reports unsupported, unavailable and empty separately;
|
|
330
|
+
use the returned IDs with --elements and --voices
|
|
331
|
+
--elements <json|@file>
|
|
332
|
+
Template saved references: [{"handle":"host","elementId":"<id>"}].
|
|
333
|
+
Only authorized saved character/location IDs are supported;
|
|
334
|
+
this does not upload images. [] means no saved references
|
|
335
|
+
--voices <json|@file>
|
|
336
|
+
Template voices keyed by canonical SCRIPT speaker name:
|
|
337
|
+
{"HOST":"<voiceId>","NARRATOR":{"voiceId":"<id>","label":"Name"},"GUEST":null}.
|
|
338
|
+
A string pins, an object pins with an optional label,
|
|
339
|
+
null clears that speaker. {} means no selected voices.
|
|
340
|
+
Repeated --elements or --voices: last value wins.
|
|
341
|
+
Empty selections are omitted; the server checks IDs,
|
|
342
|
+
template support and approval again before starting.
|
|
343
|
+
--voice and --voice-path keep their existing meanings
|
|
229
344
|
--rewrite-to-fit If the script doesn't fit the kind of ad (more speakers
|
|
230
345
|
than it takes, or a rule it has), write a new script for
|
|
231
346
|
it from yours, print it, and start on it (start, with
|
|
@@ -236,6 +351,26 @@ Options:
|
|
|
236
351
|
--conceit <kind> Kind of ad (start)
|
|
237
352
|
--style <look> Look (start)
|
|
238
353
|
The server lists the kinds and looks it offers. An unknown word prints them.
|
|
354
|
+
--product-context <text>
|
|
355
|
+
Product facts for a template's --describe brief.
|
|
356
|
+
This is text, not the saved-product ID used by --product.
|
|
357
|
+
--audience <text> Audience for a template's --describe brief
|
|
358
|
+
--offer <text> Approved offer for a template's --describe brief
|
|
359
|
+
--mechanism <text> Supported mechanism for a template's --describe brief.
|
|
360
|
+
Brief fields combine with --script file text, not with
|
|
361
|
+
--adapt, --keep-original, --resume-script or non-template starts.
|
|
362
|
+
--requested-seconds <seconds>
|
|
363
|
+
Requested template length: a positive finite number,
|
|
364
|
+
including fractional seconds. Sent as requested, not
|
|
365
|
+
clamped to a preset. The server may refuse an unsupported
|
|
366
|
+
length before starting. Not an upload's --duration
|
|
367
|
+
--pictures-per-scene <1|3>
|
|
368
|
+
Template scene-picture candidates: 1 (default) or 3
|
|
369
|
+
--product <brandProductId>
|
|
370
|
+
Existing product from this brand for a template start.
|
|
371
|
+
Uses its authorized product photos as references, never
|
|
372
|
+
a URL, image-ad reference, actor identity or style pick.
|
|
373
|
+
These three options do not work with --show
|
|
239
374
|
--direction "<note>" Note for the whole ad (start)
|
|
240
375
|
--frame pov Camera-as-character POV: the camera is a person in the
|
|
241
376
|
scene (start, with --conceit). Leave it off for a
|
|
@@ -296,6 +431,9 @@ Examples:
|
|
|
296
431
|
exodus video retry-clip run_123 --scene 3 --note "keep the handshake in frame"
|
|
297
432
|
exodus video retry-clip run_123 --scene 3 --voice-first
|
|
298
433
|
exodus video revoice run_123 --all
|
|
434
|
+
exodus video picks run_123
|
|
435
|
+
exodus video pick run_123 --face STRATEGIST=2 --voice STRATEGIST=3 --room OFFICE=4
|
|
436
|
+
exodus video picks run_123 --redo face:STRATEGIST --note "older, greyer"
|
|
299
437
|
exodus video voices run_123
|
|
300
438
|
exodus video voices --catalog
|
|
301
439
|
exodus video voices run_123 --catalog
|
|
@@ -335,6 +473,7 @@ const REVOICE_NOT_ON_THIS_SERVER = "This Exodus server does not have the voice r
|
|
|
335
473
|
"was spent. It arrives with the next server update.";
|
|
336
474
|
export const FINAL_PATH = "/api/v2/video/final";
|
|
337
475
|
export const VOICES_PATH = "/api/v2/video/voices";
|
|
476
|
+
export const PICKS_PATH = "/api/v2/video/picks";
|
|
338
477
|
export const ASSET_UPLOAD_URL_PATH = "/api/v2/workflows/asset-upload-url";
|
|
339
478
|
export const ASSETS_PATH = "/api/v2/workflows/assets";
|
|
340
479
|
function withoutJudgeFields({ judgeDetail: _d, judgeSeverity: _s, ...rest }) {
|
|
@@ -454,6 +593,60 @@ function errorResult(res, json) {
|
|
|
454
593
|
: [videoApiError(res)],
|
|
455
594
|
};
|
|
456
595
|
}
|
|
596
|
+
const SPEECH_CODE = /^speech-/;
|
|
597
|
+
const SKIPPED_CODE = /-check-skipped$/;
|
|
598
|
+
export function pilotCheck(sceneIndex, row, hasLine) {
|
|
599
|
+
if (!row)
|
|
600
|
+
return { sceneIndex, clip: "failed", error: "No clip was made for this scene", failed: [], skipped: [] };
|
|
601
|
+
if (row.status === "failed") {
|
|
602
|
+
return { sceneIndex, clip: "failed", ...(row.error ? { error: row.error } : {}), failed: [], skipped: [] };
|
|
603
|
+
}
|
|
604
|
+
if (row.status !== "done")
|
|
605
|
+
return { sceneIndex, clip: "making", failed: [], skipped: [] };
|
|
606
|
+
const findings = row.findings ?? [];
|
|
607
|
+
const speech = findings.filter((f) => SPEECH_CODE.test(f.code));
|
|
608
|
+
const wrong = speech.filter((f) => f.severity === "fail");
|
|
609
|
+
const speechSkipped = speech.find((f) => f.code === "speech-check-skipped");
|
|
610
|
+
const words = wrong.length
|
|
611
|
+
? `no match: ${wrong[0].detail}${wrong.length > 1 ? ` (and ${wrong.length - 1} more)` : ""}`
|
|
612
|
+
: speechSkipped
|
|
613
|
+
? `not checked: ${speechSkipped.detail}`
|
|
614
|
+
: hasLine === false
|
|
615
|
+
? "no line to check"
|
|
616
|
+
: "no problem found";
|
|
617
|
+
const others = findings.filter((f) => !SPEECH_CODE.test(f.code));
|
|
618
|
+
const failed = others.filter((f) => f.severity === "fail").map((f) => f.detail);
|
|
619
|
+
const skipped = others.filter((f) => f.severity !== "fail" && SKIPPED_CODE.test(f.code)).map((f) => f.detail);
|
|
620
|
+
return { sceneIndex, clip: "made", words, failed, skipped };
|
|
621
|
+
}
|
|
622
|
+
function pilotScenesWithoutLine(run, scenes) {
|
|
623
|
+
const artifact = run.nodes
|
|
624
|
+
.flatMap((n) => n.outputs ?? [])
|
|
625
|
+
.find((a) => a.type === "storyboard");
|
|
626
|
+
let board = artifact?.storyboard;
|
|
627
|
+
if (board === undefined && typeof artifact?.storyboardJson === "string") {
|
|
628
|
+
try {
|
|
629
|
+
board = JSON.parse(artifact.storyboardJson);
|
|
630
|
+
}
|
|
631
|
+
catch {
|
|
632
|
+
return [];
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
const boardScenes = board?.scenes;
|
|
636
|
+
if (!Array.isArray(boardScenes))
|
|
637
|
+
return [];
|
|
638
|
+
return scenes.filter((n) => {
|
|
639
|
+
const scene = boardScenes.find((b) => b.sceneIndex === n);
|
|
640
|
+
return scene !== undefined && !(scene.dialogue ?? []).some((d) => (d.line ?? "").trim().length > 0);
|
|
641
|
+
});
|
|
642
|
+
}
|
|
643
|
+
function pilotScenesOf(run) {
|
|
644
|
+
if (run.pilot?.sceneIndexes?.length)
|
|
645
|
+
return [...run.pilot.sceneIndexes].sort((a, b) => a - b);
|
|
646
|
+
const parked = run.nodes.find((n) => n.nodeId === run.pausedNodeId);
|
|
647
|
+
const scenes = (parked?.outputs ?? []).flatMap((o) => o.type === "video" && typeof o.sceneIndex === "number" ? [o.sceneIndex] : []);
|
|
648
|
+
return [...new Set(scenes)].sort((a, b) => a - b);
|
|
649
|
+
}
|
|
457
650
|
const GATE_NODE_KINDS = new Set(["scene-frames", "storyboard"]);
|
|
458
651
|
function isAwaitingApproval(status) {
|
|
459
652
|
return status === "awaiting-approval" || status === "awaiting-review";
|
|
@@ -495,9 +688,22 @@ export function classifyRun(run) {
|
|
|
495
688
|
...(why ? { error: why } : {}),
|
|
496
689
|
};
|
|
497
690
|
}
|
|
691
|
+
if (run.pauseReason === "pilot") {
|
|
692
|
+
const sceneIndexes = pilotScenesOf(run);
|
|
693
|
+
const silentScenes = pilotScenesWithoutLine(run, sceneIndexes);
|
|
694
|
+
return {
|
|
695
|
+
at: "pilot",
|
|
696
|
+
...(run.pausedNodeId ? { nodeId: run.pausedNodeId } : {}),
|
|
697
|
+
sceneIndexes,
|
|
698
|
+
...(silentScenes.length ? { silentScenes } : {}),
|
|
699
|
+
};
|
|
700
|
+
}
|
|
498
701
|
if (run.requestQuotePending === true)
|
|
499
702
|
return { at: "request-quote" };
|
|
500
703
|
const pausedNode = run.nodes.find((n) => n.nodeId === run.pausedNodeId);
|
|
704
|
+
if (pausedNode?.kind === "picks" && !parkedByBuilderCheckpoint(run)) {
|
|
705
|
+
return { at: "picks", nodeId: pausedNode.nodeId };
|
|
706
|
+
}
|
|
501
707
|
if (pausedNode && parkedAtStoryboardGate(run, pausedNode)) {
|
|
502
708
|
const held = heldReason(run);
|
|
503
709
|
return {
|
|
@@ -552,18 +758,26 @@ export function scenesBeingRedone(run, items) {
|
|
|
552
758
|
}
|
|
553
759
|
return [...scenes].sort((a, b) => a - b);
|
|
554
760
|
}
|
|
555
|
-
export function resolveStop(stop, cutAttached) {
|
|
761
|
+
export function resolveStop(stop, cutAttached, items) {
|
|
762
|
+
if (stop.at === "pilot") {
|
|
763
|
+
if (!items)
|
|
764
|
+
return stop;
|
|
765
|
+
const clipOf = (sceneIndex) => items.find((i) => i.itemKind === "clip" && i.sceneIndex === sceneIndex && (!stop.nodeId || i.nodeId === stop.nodeId));
|
|
766
|
+
const hasLine = (n) => (stop.silentScenes?.includes(n) ? false : undefined);
|
|
767
|
+
return { ...stop, checks: stop.sceneIndexes.map((n) => pilotCheck(n, clipOf(n), hasLine(n))) };
|
|
768
|
+
}
|
|
556
769
|
if (stop.at !== "final-watch")
|
|
557
770
|
return stop;
|
|
558
771
|
return { ...stop, cutAttached };
|
|
559
772
|
}
|
|
560
773
|
export async function resolveStopAtPark(stop, runId, deps) {
|
|
561
|
-
if (stop.at !== "final-watch")
|
|
774
|
+
if (stop.at !== "final-watch" && stop.at !== "pilot")
|
|
562
775
|
return stop;
|
|
563
776
|
const res = await deps.get(`${ITEMS_PATH}?runId=${encodeURIComponent(runId)}`);
|
|
564
777
|
if (!res.ok)
|
|
565
778
|
return resolveStop(stop, null);
|
|
566
|
-
|
|
779
|
+
const items = res.data.items ?? [];
|
|
780
|
+
return resolveStop(stop, hasAttachedCut(items), items);
|
|
567
781
|
}
|
|
568
782
|
const STAGE_WORDS = {
|
|
569
783
|
brief: "reading the script",
|
|
@@ -622,7 +836,50 @@ function missingSceneLines(missing, framesNodeId, runId, runUrl) {
|
|
|
622
836
|
lines.push("The ad can't be approved until every scene has a clip.", `Watch it here: ${runUrl}`);
|
|
623
837
|
return lines;
|
|
624
838
|
}
|
|
839
|
+
function pilotLines(stop, runId, runUrl) {
|
|
840
|
+
const scenes = stop.sceneIndexes;
|
|
841
|
+
const checks = stop.checks ?? [];
|
|
842
|
+
const failedScenes = checks.filter((c) => c.clip === "failed").map((c) => c.sceneIndex);
|
|
843
|
+
const allMade = checks.length > 0 && checks.every((c) => c.clip === "made");
|
|
844
|
+
const which = scenes.length ? ` (${scenesPhrase(scenes)})` : "";
|
|
845
|
+
const headline = failedScenes.length
|
|
846
|
+
? `Run ${runId}'s pilot clip failed (${scenesPhrase(failedScenes)}) and is waiting for you.`
|
|
847
|
+
: allMade
|
|
848
|
+
? `Run ${runId} made its pilot clip${scenes.length > 1 ? "s" : ""}${which} and is waiting for you.`
|
|
849
|
+
: `Run ${runId} stopped at its pilot clip${which} and is waiting for you.`;
|
|
850
|
+
const lines = [headline, `Watch it here: ${runUrl}`];
|
|
851
|
+
const one = checks.length === 1;
|
|
852
|
+
const label = (name, sceneIndex) => one ? `${name}:`.padEnd(22) : `${name}, scene ${sceneIndex}: `;
|
|
853
|
+
for (const c of checks) {
|
|
854
|
+
if (c.clip === "failed") {
|
|
855
|
+
lines.push(`${label("Clip failed", c.sceneIndex)}${c.error ?? "no clip was made"}`);
|
|
856
|
+
continue;
|
|
857
|
+
}
|
|
858
|
+
if (c.clip === "making") {
|
|
859
|
+
lines.push(`${label("Clip", c.sceneIndex)}still being made, not checked yet`);
|
|
860
|
+
continue;
|
|
861
|
+
}
|
|
862
|
+
lines.push(`${label("Word check", c.sceneIndex)}${c.words}`);
|
|
863
|
+
for (const detail of c.failed)
|
|
864
|
+
lines.push(`${label("Check failed", c.sceneIndex)}${detail}`);
|
|
865
|
+
for (const detail of c.skipped)
|
|
866
|
+
lines.push(`${label("Check skipped", c.sceneIndex)}${detail}`);
|
|
867
|
+
}
|
|
868
|
+
const redoScene = failedScenes[0] ?? scenes[0];
|
|
869
|
+
lines.push(`Redo it: exodus video retry-clip ${runId} --scene ${redoScene ?? "<n>"} --note "<what is wrong>"`, `Make the other clips: exodus video approve ${runId}`);
|
|
870
|
+
return lines;
|
|
871
|
+
}
|
|
625
872
|
export function stopLines(stop, runId, runUrl) {
|
|
873
|
+
if (stop.at === "picks") {
|
|
874
|
+
return [
|
|
875
|
+
"Parked: the run is waiting for your picks. Nothing is planned or filmed until every slot has one.",
|
|
876
|
+
`See them: exodus video picks ${runId}`,
|
|
877
|
+
`Pick: exodus video pick ${runId} --face <who>=<n> --voice <who>=<n> --room <place>=<n>`,
|
|
878
|
+
`Watch it here: ${runUrl}`,
|
|
879
|
+
];
|
|
880
|
+
}
|
|
881
|
+
if (stop.at === "pilot")
|
|
882
|
+
return pilotLines(stop, runId, runUrl);
|
|
626
883
|
if (stop.at === "request-quote")
|
|
627
884
|
return [
|
|
628
885
|
"Parked: final provider requests are prepared; the unapproved paid operations have not been sent.",
|
|
@@ -810,6 +1067,7 @@ function clipFromArtifact(sceneIndex, artifact) {
|
|
|
810
1067
|
voicePitchHz: artifact.voicePitchHz ?? null,
|
|
811
1068
|
voicePitchMethod: artifact.voicePitchMethod ?? null,
|
|
812
1069
|
replannedIdea: artifact.replannedIdea ?? null,
|
|
1070
|
+
...(artifact.voiceLock !== undefined ? { voiceLock: artifact.voiceLock } : {}),
|
|
813
1071
|
};
|
|
814
1072
|
}
|
|
815
1073
|
function keyframeDownload(sceneIndex, imageUrl) {
|
|
@@ -987,6 +1245,10 @@ function withReplannedPrompts(raw, replanned) {
|
|
|
987
1245
|
}
|
|
988
1246
|
export function planPull(run, items, opts) {
|
|
989
1247
|
const texts = [];
|
|
1248
|
+
const clipAudio = run.videoChoice?.videoModel === "template-video"
|
|
1249
|
+
? run.songAsVoice || run.videoChoice.voiceMode === "voice-first" ? "discard"
|
|
1250
|
+
: run.videoChoice.voiceMode === "native" ? "keep" : undefined
|
|
1251
|
+
: undefined;
|
|
990
1252
|
const storyboardArtifact = run.nodes
|
|
991
1253
|
.flatMap((n) => n.outputs ?? [])
|
|
992
1254
|
.find((a) => a.type === "storyboard");
|
|
@@ -1200,6 +1462,7 @@ export function planPull(run, items, opts) {
|
|
|
1200
1462
|
voiceFirstBlockedBy: clip ? clip.voiceFirstBlockedBy : null,
|
|
1201
1463
|
voicePitchHz: clip ? clip.voicePitchHz : null,
|
|
1202
1464
|
voicePitchMethod: clip ? clip.voicePitchMethod : null,
|
|
1465
|
+
...(clip?.voiceLock !== undefined ? { voiceLock: clip.voiceLock } : {}),
|
|
1203
1466
|
clipStatus: item?.status ?? "missing",
|
|
1204
1467
|
error: item?.error ?? null,
|
|
1205
1468
|
flagged: item?.flagged === true,
|
|
@@ -1259,6 +1522,7 @@ export function planPull(run, items, opts) {
|
|
|
1259
1522
|
},
|
|
1260
1523
|
}
|
|
1261
1524
|
: {}),
|
|
1525
|
+
...(clipAudio ? { clipAudio } : {}),
|
|
1262
1526
|
...(run.shots?.frame || run.shots?.pacing ? { shots: run.shots } : {}),
|
|
1263
1527
|
},
|
|
1264
1528
|
};
|
|
@@ -1301,6 +1565,7 @@ export function markPullFailure(manifest, failure) {
|
|
|
1301
1565
|
scene.voiceFirstBlockedBy = null;
|
|
1302
1566
|
scene.voicePitchHz = null;
|
|
1303
1567
|
scene.voicePitchMethod = null;
|
|
1568
|
+
delete scene.voiceLock;
|
|
1304
1569
|
}
|
|
1305
1570
|
if (scene.voice === failure.file)
|
|
1306
1571
|
scene.voice = null;
|
|
@@ -1487,6 +1752,24 @@ function planValueFlag(occurrences, name) {
|
|
|
1487
1752
|
}
|
|
1488
1753
|
return { ok: true, value };
|
|
1489
1754
|
}
|
|
1755
|
+
function planTemplateValue(occurrences, name, exactText = false) {
|
|
1756
|
+
let value;
|
|
1757
|
+
for (const occurrence of occurrences) {
|
|
1758
|
+
if (occurrence.flag !== name)
|
|
1759
|
+
continue;
|
|
1760
|
+
const given = occurrence.value?.trim();
|
|
1761
|
+
if (!given || given.startsWith("--")) {
|
|
1762
|
+
return { ok: false, line: `video start --${name} needs a value.` };
|
|
1763
|
+
}
|
|
1764
|
+
const choice = exactText ? occurrence.value : given;
|
|
1765
|
+
if (value !== undefined && value !== choice) {
|
|
1766
|
+
return { ok: false, line: `video start --${name} has conflicting values. Pass one choice.` };
|
|
1767
|
+
}
|
|
1768
|
+
value = choice;
|
|
1769
|
+
}
|
|
1770
|
+
return { ok: true, value };
|
|
1771
|
+
}
|
|
1772
|
+
const TEMPLATE_WRITER_BRIEF_USAGE = "--product-context, --audience, --offer and --mechanism require a template start with --describe; not --adapt, --keep-original or --resume-script.";
|
|
1490
1773
|
export function planVideoStart(flags, occurrences) {
|
|
1491
1774
|
const showId = nonBlank(flagString(flags, "show"));
|
|
1492
1775
|
const scriptFile = nonBlank(flagString(flags, "script"));
|
|
@@ -1525,6 +1808,121 @@ export function planVideoStart(flags, occurrences) {
|
|
|
1525
1808
|
const planFlag = planValueFlag(occurrences, "adaptation-plan");
|
|
1526
1809
|
if (!planFlag.ok)
|
|
1527
1810
|
return { kind: "usage", line: planFlag.line };
|
|
1811
|
+
const resumeFlag = planTemplateValue(occurrences, "resume-script");
|
|
1812
|
+
if (!resumeFlag.ok)
|
|
1813
|
+
return { kind: "usage", line: resumeFlag.line };
|
|
1814
|
+
if (showId && resumeFlag.value !== undefined) {
|
|
1815
|
+
return { kind: "usage", line: "--resume-script is a template input, not a --show choice." };
|
|
1816
|
+
}
|
|
1817
|
+
const secondsFlag = planTemplateValue(occurrences, "requested-seconds");
|
|
1818
|
+
if (!secondsFlag.ok)
|
|
1819
|
+
return { kind: "usage", line: secondsFlag.line };
|
|
1820
|
+
const picturesFlag = planTemplateValue(occurrences, "pictures-per-scene");
|
|
1821
|
+
if (!picturesFlag.ok)
|
|
1822
|
+
return { kind: "usage", line: picturesFlag.line };
|
|
1823
|
+
const productFlag = planTemplateValue(occurrences, "product");
|
|
1824
|
+
if (!productFlag.ok)
|
|
1825
|
+
return { kind: "usage", line: productFlag.line };
|
|
1826
|
+
const elementsFlag = planValueFlag(occurrences, "elements");
|
|
1827
|
+
if (!elementsFlag.ok)
|
|
1828
|
+
return { kind: "usage", line: elementsFlag.line };
|
|
1829
|
+
const voicesFlag = planValueFlag(occurrences, "voices");
|
|
1830
|
+
if (!voicesFlag.ok)
|
|
1831
|
+
return { kind: "usage", line: voicesFlag.line };
|
|
1832
|
+
const inputModeFlag = planTemplateValue(occurrences, "input-mode");
|
|
1833
|
+
if (!inputModeFlag.ok)
|
|
1834
|
+
return { kind: "usage", line: inputModeFlag.line };
|
|
1835
|
+
if (inputModeFlag.value !== undefined
|
|
1836
|
+
&& inputModeFlag.value !== "automatic" && inputModeFlag.value !== "manual" && inputModeFlag.value !== "hybrid") {
|
|
1837
|
+
return { kind: "usage", line: "video start --input-mode must be automatic, manual or hybrid." };
|
|
1838
|
+
}
|
|
1839
|
+
const structureFlag = planTemplateValue(occurrences, "structure");
|
|
1840
|
+
if (!structureFlag.ok)
|
|
1841
|
+
return { kind: "usage", line: structureFlag.line };
|
|
1842
|
+
const referenceFlag = planTemplateValue(occurrences, "reference");
|
|
1843
|
+
if (!referenceFlag.ok)
|
|
1844
|
+
return { kind: "usage", line: referenceFlag.line };
|
|
1845
|
+
const subjectFlag = planTemplateValue(occurrences, "subject");
|
|
1846
|
+
if (!subjectFlag.ok)
|
|
1847
|
+
return { kind: "usage", line: subjectFlag.line };
|
|
1848
|
+
if (subjectFlag.value !== undefined
|
|
1849
|
+
&& subjectFlag.value !== "product" && subjectFlag.value !== "service" && subjectFlag.value !== "non-product") {
|
|
1850
|
+
return { kind: "usage", line: "video start --subject must be product, service or non-product." };
|
|
1851
|
+
}
|
|
1852
|
+
const adaptFlag = planTemplateValue(occurrences, "adapt", true);
|
|
1853
|
+
if (!adaptFlag.ok)
|
|
1854
|
+
return { kind: "usage", line: adaptFlag.line };
|
|
1855
|
+
const briefFlag = planTemplateValue(occurrences, "template-brief");
|
|
1856
|
+
if (!briefFlag.ok)
|
|
1857
|
+
return { kind: "usage", line: briefFlag.line };
|
|
1858
|
+
const songFlag = planTemplateValue(occurrences, "song-controls");
|
|
1859
|
+
if (!songFlag.ok)
|
|
1860
|
+
return { kind: "usage", line: songFlag.line };
|
|
1861
|
+
const mechanismFlag = planTemplateValue(occurrences, "mechanism-plan");
|
|
1862
|
+
if (!mechanismFlag.ok)
|
|
1863
|
+
return { kind: "usage", line: mechanismFlag.line };
|
|
1864
|
+
const authorizationFlag = planTemplateValue(occurrences, "authorize-preparation");
|
|
1865
|
+
if (!authorizationFlag.ok)
|
|
1866
|
+
return { kind: "usage", line: authorizationFlag.line };
|
|
1867
|
+
const quoteFlags = occurrences.filter(({ flag }) => flag === "quote-preparation");
|
|
1868
|
+
if (quoteFlags.some(({ value }) => value !== undefined && !value.startsWith("--"))) {
|
|
1869
|
+
return { kind: "usage", line: "--quote-preparation takes no value. It requests a phase quote, not paid preparation." };
|
|
1870
|
+
}
|
|
1871
|
+
const quotePreparation = quoteFlags.length > 0;
|
|
1872
|
+
if (quotePreparation && authorizationFlag.value !== undefined) {
|
|
1873
|
+
return { kind: "usage", line: "Pass --quote-preparation to review the quote, or --authorize-preparation <saved-quote.json> to accept that exact quote, not both." };
|
|
1874
|
+
}
|
|
1875
|
+
const describeFlags = occurrences.filter(({ flag }) => flag === "describe");
|
|
1876
|
+
if (describeFlags.some(({ value }) => value !== undefined && !value.startsWith("--"))) {
|
|
1877
|
+
return { kind: "usage", line: "--describe takes no value. It writes from the brief in --script." };
|
|
1878
|
+
}
|
|
1879
|
+
const describe = describeFlags.length > 0;
|
|
1880
|
+
const keepFlags = occurrences.filter(({ flag }) => flag === "keep-original");
|
|
1881
|
+
if (keepFlags.some(({ value }) => value !== undefined && !value.startsWith("--"))) {
|
|
1882
|
+
return { kind: "usage", line: "--keep-original takes no value. It requests guarded review of the exact original, not new adaptation." };
|
|
1883
|
+
}
|
|
1884
|
+
const keepOriginal = keepFlags.length > 0;
|
|
1885
|
+
const writerBrief = {};
|
|
1886
|
+
for (const [flag, field] of [
|
|
1887
|
+
["product-context", "product"], ["audience", "audience"], ["offer", "offer"], ["mechanism", "mechanism"],
|
|
1888
|
+
]) {
|
|
1889
|
+
const choice = planTemplateValue(occurrences, flag);
|
|
1890
|
+
if (!choice.ok)
|
|
1891
|
+
return { kind: "usage", line: choice.line };
|
|
1892
|
+
if (choice.value !== undefined)
|
|
1893
|
+
writerBrief[field] = choice.value;
|
|
1894
|
+
}
|
|
1895
|
+
if (Object.keys(writerBrief).length
|
|
1896
|
+
&& (!describe || showId || keepOriginal || adaptFlag.value !== undefined || resumeFlag.value !== undefined)) {
|
|
1897
|
+
return { kind: "usage", line: TEMPLATE_WRITER_BRIEF_USAGE };
|
|
1898
|
+
}
|
|
1899
|
+
if (describe && keepOriginal) {
|
|
1900
|
+
return { kind: "usage", line: "Pass --describe to write from a brief or --keep-original to review unchanged copy, not both." };
|
|
1901
|
+
}
|
|
1902
|
+
if (describe && adaptFlag.value !== undefined) {
|
|
1903
|
+
return { kind: "usage", line: "Pass --describe to write from a brief or --adapt <intent> to adapt pasted text, not both." };
|
|
1904
|
+
}
|
|
1905
|
+
if (resumeFlag.value !== undefined && (describe || adaptFlag.value !== undefined)) {
|
|
1906
|
+
return { kind: "usage", line: "--resume-script retains the original source and adaptation intent; do not combine it with --describe or --adapt." };
|
|
1907
|
+
}
|
|
1908
|
+
if (showId && (inputModeFlag.value !== undefined || structureFlag.value !== undefined
|
|
1909
|
+
|| referenceFlag.value !== undefined || subjectFlag.value !== undefined
|
|
1910
|
+
|| adaptFlag.value !== undefined || briefFlag.value !== undefined || songFlag.value !== undefined
|
|
1911
|
+
|| mechanismFlag.value !== undefined || quotePreparation || authorizationFlag.value !== undefined || keepOriginal || describe)) {
|
|
1912
|
+
return { kind: "usage", line: "V2 input and preparation flags are template inputs, not --show choices." };
|
|
1913
|
+
}
|
|
1914
|
+
const requestedSeconds = secondsFlag.value === undefined ? undefined : Number(secondsFlag.value);
|
|
1915
|
+
if (requestedSeconds !== undefined && (!Number.isFinite(requestedSeconds) || requestedSeconds <= 0)) {
|
|
1916
|
+
return { kind: "usage", line: "video start --requested-seconds must be a positive finite number of seconds." };
|
|
1917
|
+
}
|
|
1918
|
+
if (picturesFlag.value !== undefined && picturesFlag.value !== "1" && picturesFlag.value !== "3") {
|
|
1919
|
+
return { kind: "usage", line: "video start --pictures-per-scene must be 1 or 3." };
|
|
1920
|
+
}
|
|
1921
|
+
const hasTemplateInputs = requestedSeconds !== undefined || picturesFlag.value !== undefined
|
|
1922
|
+
|| productFlag.value !== undefined || elementsFlag.value !== undefined || voicesFlag.value !== undefined;
|
|
1923
|
+
if (showId && hasTemplateInputs) {
|
|
1924
|
+
return { kind: "usage", line: "--requested-seconds, --pictures-per-scene, --product, --elements and --voices are template inputs, not --show choices." };
|
|
1925
|
+
}
|
|
1528
1926
|
const videoModel = videoModelFlag.value;
|
|
1529
1927
|
const voiceMode = voiceFlag.value;
|
|
1530
1928
|
const reviewStoryboardFlag = occurrences.some((o) => o.flag === "review-storyboard");
|
|
@@ -1697,6 +2095,46 @@ export function planVideoStart(flags, occurrences) {
|
|
|
1697
2095
|
opts.sourceRecordFile = recordFlag.value;
|
|
1698
2096
|
if (planFlag.value)
|
|
1699
2097
|
opts.adaptationPlanFile = planFlag.value;
|
|
2098
|
+
if (resumeFlag.value)
|
|
2099
|
+
opts.resumeScriptFile = resumeFlag.value;
|
|
2100
|
+
if (requestedSeconds !== undefined)
|
|
2101
|
+
opts.requestedSeconds = requestedSeconds;
|
|
2102
|
+
if (picturesFlag.value !== undefined)
|
|
2103
|
+
opts.picturesPerScene = picturesFlag.value === "3" ? 3 : 1;
|
|
2104
|
+
if (productFlag.value !== undefined)
|
|
2105
|
+
opts.productId = productFlag.value;
|
|
2106
|
+
if (elementsFlag.value !== undefined)
|
|
2107
|
+
opts.elementsInput = elementsFlag.value;
|
|
2108
|
+
if (voicesFlag.value !== undefined)
|
|
2109
|
+
opts.voicesInput = voicesFlag.value;
|
|
2110
|
+
if (inputModeFlag.value === "automatic" || inputModeFlag.value === "manual" || inputModeFlag.value === "hybrid") {
|
|
2111
|
+
opts.inputMode = inputModeFlag.value;
|
|
2112
|
+
}
|
|
2113
|
+
if (structureFlag.value !== undefined)
|
|
2114
|
+
opts.structure = structureFlag.value;
|
|
2115
|
+
if (referenceFlag.value !== undefined)
|
|
2116
|
+
opts.reference = referenceFlag.value;
|
|
2117
|
+
if (subjectFlag.value === "product" || subjectFlag.value === "service" || subjectFlag.value === "non-product") {
|
|
2118
|
+
opts.subject = subjectFlag.value;
|
|
2119
|
+
}
|
|
2120
|
+
if (adaptFlag.value !== undefined)
|
|
2121
|
+
opts.adaptationIntent = adaptFlag.value;
|
|
2122
|
+
if (briefFlag.value !== undefined)
|
|
2123
|
+
opts.templateBriefInput = briefFlag.value;
|
|
2124
|
+
if (songFlag.value !== undefined)
|
|
2125
|
+
opts.songControlsInput = songFlag.value;
|
|
2126
|
+
if (mechanismFlag.value !== undefined)
|
|
2127
|
+
opts.mechanismPlanInput = mechanismFlag.value;
|
|
2128
|
+
if (quotePreparation)
|
|
2129
|
+
opts.quotePreparation = true;
|
|
2130
|
+
if (authorizationFlag.value !== undefined)
|
|
2131
|
+
opts.authorizePreparationFile = authorizationFlag.value;
|
|
2132
|
+
if (describe)
|
|
2133
|
+
opts.describe = true;
|
|
2134
|
+
if (keepOriginal)
|
|
2135
|
+
opts.keepOriginal = true;
|
|
2136
|
+
if (Object.keys(writerBrief).length)
|
|
2137
|
+
opts.writerBrief = writerBrief;
|
|
1700
2138
|
if (frameFlag.value || pacingFlag.value) {
|
|
1701
2139
|
opts.shots = {
|
|
1702
2140
|
...(frameFlag.value ? { frame: frameFlag.value } : {}),
|
|
@@ -1708,15 +2146,24 @@ export function planVideoStart(flags, occurrences) {
|
|
|
1708
2146
|
function isRecord(value) {
|
|
1709
2147
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1710
2148
|
}
|
|
1711
|
-
function scriptRunOptionsOf(data) {
|
|
1712
|
-
|
|
2149
|
+
function scriptRunOptionsOf(data, door = "script") {
|
|
2150
|
+
const rows = isRecord(data) ? data[door === "template" ? "templates" : "conceits"] : undefined;
|
|
2151
|
+
if (!isRecord(data) || !Array.isArray(rows) || !Array.isArray(data.styles)) {
|
|
1713
2152
|
return null;
|
|
1714
2153
|
}
|
|
1715
2154
|
const conceits = [];
|
|
1716
|
-
for (const row of
|
|
2155
|
+
for (const row of rows) {
|
|
1717
2156
|
if (!isRecord(row) || typeof row.key !== "string" || typeof row.label !== "string")
|
|
1718
2157
|
return null;
|
|
1719
|
-
|
|
2158
|
+
if (door === "template" && row.style !== undefined) {
|
|
2159
|
+
if (!isRecord(row.style) || typeof row.style.slug !== "string" || row.style.slug.trim() === ""
|
|
2160
|
+
|| typeof row.style.label !== "string")
|
|
2161
|
+
return null;
|
|
2162
|
+
conceits.push({ key: row.key, label: row.label, style: { slug: row.style.slug, label: row.style.label } });
|
|
2163
|
+
}
|
|
2164
|
+
else {
|
|
2165
|
+
conceits.push({ key: row.key, label: row.label });
|
|
2166
|
+
}
|
|
1720
2167
|
}
|
|
1721
2168
|
const styles = [];
|
|
1722
2169
|
for (const row of data.styles) {
|
|
@@ -1726,6 +2173,181 @@ function scriptRunOptionsOf(data) {
|
|
|
1726
2173
|
}
|
|
1727
2174
|
return { conceits, styles };
|
|
1728
2175
|
}
|
|
2176
|
+
const GOLDEN_TEMPLATE_KEYS = [
|
|
2177
|
+
"ugc-template", "authority-yapper-template", "microdrama-template",
|
|
2178
|
+
"skeleton-timeline-template", "pixar-song-template", "personification-template",
|
|
2179
|
+
];
|
|
2180
|
+
function templateListingResult(menu, data, json) {
|
|
2181
|
+
const rows = isRecord(data) && Array.isArray(data.templates) ? data.templates : [];
|
|
2182
|
+
const templates = menu.conceits.map(({ key, label }) => {
|
|
2183
|
+
const row = rows.find((entry) => isRecord(entry) && entry.key === key);
|
|
2184
|
+
const experience = isRecord(row) && isRecord(row.templateExperience) ? row.templateExperience : undefined;
|
|
2185
|
+
return {
|
|
2186
|
+
key, label,
|
|
2187
|
+
description: isRecord(row) && typeof row.description === "string" ? row.description.replace(/\s+/g, " ").trim() : "",
|
|
2188
|
+
structureCount: Array.isArray(experience?.structures) ? experience.structures.length : 0,
|
|
2189
|
+
};
|
|
2190
|
+
});
|
|
2191
|
+
const golden = GOLDEN_TEMPLATE_KEYS.flatMap((key) => templates.filter((row) => row.key === key));
|
|
2192
|
+
const extras = templates.filter(({ key }) => !GOLDEN_TEMPLATE_KEYS.some((goldenKey) => goldenKey === key));
|
|
2193
|
+
if (json)
|
|
2194
|
+
return { code: 0, lines: [JSON.stringify({ templates: [
|
|
2195
|
+
...golden.map((row) => ({ ...row, group: "golden-six" })),
|
|
2196
|
+
...extras.map((row) => ({ ...row, group: "more" })),
|
|
2197
|
+
] })] };
|
|
2198
|
+
return { code: 0, lines: templates.length === 0 ? ["No templates are available."] : [
|
|
2199
|
+
{ label: "Golden Six", templates: golden },
|
|
2200
|
+
{ label: `${extras.length} more ${extras.length === 1 ? "template" : "templates"}`, templates: extras },
|
|
2201
|
+
].flatMap((group) => group.templates.length ? [
|
|
2202
|
+
group.label,
|
|
2203
|
+
...group.templates.map((row) => ` ${row.key} — ${row.label} — ${row.description} — ${row.structureCount} ${row.structureCount === 1 ? "structure" : "structures"}`),
|
|
2204
|
+
] : []) };
|
|
2205
|
+
}
|
|
2206
|
+
async function templateInputOptionsFlow(occurrences, json, deps) {
|
|
2207
|
+
const allowed = {
|
|
2208
|
+
conceit: true, "input-options": true, voice: true, "voice-path": true, "video-model": true, json: true,
|
|
2209
|
+
};
|
|
2210
|
+
const unsupported = occurrences.find(({ flag }) => !Object.hasOwn(allowed, flag));
|
|
2211
|
+
if (unsupported) {
|
|
2212
|
+
return { code: 1, usage: true, lines: [`--input-options is read-only; --${unsupported.flag} is not a discovery option.`] };
|
|
2213
|
+
}
|
|
2214
|
+
if (occurrences.some(({ flag, value }) => flag === "input-options" && value !== undefined && !value.startsWith("--"))) {
|
|
2215
|
+
return { code: 1, usage: true, lines: ["--input-options takes no value. Choose the template with --conceit <template>."] };
|
|
2216
|
+
}
|
|
2217
|
+
const template = planTemplateValue(occurrences, "conceit");
|
|
2218
|
+
if (!template.ok)
|
|
2219
|
+
return { code: 1, usage: true, lines: [template.line] };
|
|
2220
|
+
if (!template.value && occurrences.some(({ flag }) => flag === "voice" || flag === "voice-path" || flag === "video-model")) {
|
|
2221
|
+
return { code: 1, usage: true, lines: ["Choose --conceit <template> to inspect voice and video route options."] };
|
|
2222
|
+
}
|
|
2223
|
+
const query = new URLSearchParams({ door: "template" });
|
|
2224
|
+
if (template.value)
|
|
2225
|
+
query.set("template", template.value);
|
|
2226
|
+
for (const [flag, field] of [["voice", "voiceMode"], ["voice-path", "voicePath"], ["video-model", "videoModel"]]) {
|
|
2227
|
+
const choice = planValueFlag(occurrences, flag);
|
|
2228
|
+
if (!choice.ok)
|
|
2229
|
+
return { code: 1, usage: true, lines: [choice.line] };
|
|
2230
|
+
if (choice.value !== undefined) {
|
|
2231
|
+
if (flag === "voice" && !isVoiceMode(choice.value)) {
|
|
2232
|
+
return { code: 1, usage: true, lines: [`video start --voice must be native or voice-first (got "${choice.value}").`] };
|
|
2233
|
+
}
|
|
2234
|
+
query.set(field, choice.value);
|
|
2235
|
+
}
|
|
2236
|
+
}
|
|
2237
|
+
const response = await deps.get(`${SCRIPT_RUNS_PATH}?${query}`).catch(() => null);
|
|
2238
|
+
if (!response)
|
|
2239
|
+
return adminOnlyResult("Template input options could not be read. Nothing has started.", json);
|
|
2240
|
+
if (!response.ok)
|
|
2241
|
+
return errorResult(response, json);
|
|
2242
|
+
const menu = scriptRunOptionsOf(response.data, "template");
|
|
2243
|
+
if (!menu)
|
|
2244
|
+
return adminOnlyResult("This server did not publish a readable template catalog. Nothing has started.", json);
|
|
2245
|
+
if (!template.value)
|
|
2246
|
+
return templateListingResult(menu, response.data, json);
|
|
2247
|
+
const options = isRecord(response.data) ? response.data.inputOptions : undefined;
|
|
2248
|
+
if (!menu?.conceits.some(({ key }) => key === template.value)
|
|
2249
|
+
|| !isRecord(options) || !isRecord(options.selectors)
|
|
2250
|
+
|| typeof options.selectors.elements !== "boolean" || typeof options.selectors.voices !== "boolean"
|
|
2251
|
+
|| !Array.isArray(options.elements) || !Array.isArray(options.voices)
|
|
2252
|
+
|| typeof options.voicesUnavailable !== "boolean") {
|
|
2253
|
+
return adminOnlyResult("This server did not publish readable input options for that template. Nothing has started.", json);
|
|
2254
|
+
}
|
|
2255
|
+
const rows = isRecord(response.data) && Array.isArray(response.data.templates) ? response.data.templates : [];
|
|
2256
|
+
const selected = rows.find((row) => isRecord(row) && row.key === template.value);
|
|
2257
|
+
const experience = isRecord(selected) && isRecord(selected.templateExperience) ? selected.templateExperience : undefined;
|
|
2258
|
+
const capabilities = isRecord(selected) && isRecord(selected.templateCapabilities) ? selected.templateCapabilities : undefined;
|
|
2259
|
+
const metadata = {
|
|
2260
|
+
...(experience ? { templateExperience: experience } : {}),
|
|
2261
|
+
...(capabilities ? { templateCapabilities: capabilities } : {}),
|
|
2262
|
+
};
|
|
2263
|
+
const experienceLines = [];
|
|
2264
|
+
if (experience) {
|
|
2265
|
+
if (isRecord(experience.identity)) {
|
|
2266
|
+
experienceLines.push(`Identity: ${String(experience.identity.summary ?? "")}`, ...stringsOf(experience.identity.locks).flatMap((lock) => {
|
|
2267
|
+
const lines = [];
|
|
2268
|
+
let remaining = lock.replace(/\s+/g, " ").trim();
|
|
2269
|
+
while (remaining.length > 90) {
|
|
2270
|
+
const space = remaining.lastIndexOf(" ", 90);
|
|
2271
|
+
const end = space > 0 ? space : 90;
|
|
2272
|
+
lines.push(`${lines.length ? " " : " Locked: "}${remaining.slice(0, end)}`);
|
|
2273
|
+
remaining = remaining.slice(end).trimStart();
|
|
2274
|
+
}
|
|
2275
|
+
lines.push(`${lines.length ? " " : " Locked: "}${remaining}`);
|
|
2276
|
+
return lines;
|
|
2277
|
+
}), ...stringsOf(experience.identity.flexible).map((choice) => ` Supported variation: ${choice}`));
|
|
2278
|
+
}
|
|
2279
|
+
if (Array.isArray(experience.structures)) {
|
|
2280
|
+
experienceLines.push("Story structures (select with --structure):");
|
|
2281
|
+
let structureNumber = 0;
|
|
2282
|
+
for (const structure of experience.structures) {
|
|
2283
|
+
if (!isRecord(structure) || typeof structure.key !== "string" || typeof structure.label !== "string")
|
|
2284
|
+
continue;
|
|
2285
|
+
experienceLines.push(` ${++structureNumber}. ${structure.label} (${structure.key})${structure.key === experience.defaultStructureKey ? " (template-default)" : ""}`, ...(typeof structure.description === "string" ? [` ${structure.description}`] : []), ...(Array.isArray(structure.beats) ? [` Beats: ${structure.beats
|
|
2286
|
+
.filter((beat) => isRecord(beat) && typeof beat.label === "string")
|
|
2287
|
+
.map((beat, index) => `${index + 1}. ${beat.label}`).join(" → ")}`] : []), ...(typeof structure.exampleScript === "string" ? [
|
|
2288
|
+
" Example:",
|
|
2289
|
+
...structure.exampleScript.split(/\r?\n/).map((line) => ` ${line}`),
|
|
2290
|
+
] : []));
|
|
2291
|
+
}
|
|
2292
|
+
}
|
|
2293
|
+
if (Array.isArray(experience.references)) {
|
|
2294
|
+
experienceLines.push("Reference examples — production rights are not granted:");
|
|
2295
|
+
for (const reference of experience.references) {
|
|
2296
|
+
if (!isRecord(reference) || typeof reference.key !== "string" || typeof reference.label !== "string")
|
|
2297
|
+
continue;
|
|
2298
|
+
const playable = reference.availability === "playable" && reference.previewRights !== "restricted"
|
|
2299
|
+
&& isRecord(reference.media) && reference.media.kind === "video" && typeof reference.media.url === "string"
|
|
2300
|
+
&& reference.media.url.trim().length > 0;
|
|
2301
|
+
const unavailable = reference.previewRights === "restricted" ? "preview restricted"
|
|
2302
|
+
: reference.availability === "playable" ? "no video preview"
|
|
2303
|
+
: String(reference.availability ?? "unavailable");
|
|
2304
|
+
experienceLines.push(` ${reference.label} (${reference.key}): ${playable ? "playable" : `not playable — ${unavailable}`}`, ...(typeof reference.unavailableReason === "string" ? [` ${reference.unavailableReason}`] : []), ...(isRecord(reference.source) && typeof reference.source.label === "string" ? [` Source: ${reference.source.label}`] : []), ...(isRecord(reference.source) && typeof reference.source.url === "string" ? [` URL: ${reference.source.url}`] : []));
|
|
2305
|
+
}
|
|
2306
|
+
}
|
|
2307
|
+
}
|
|
2308
|
+
const references = [];
|
|
2309
|
+
for (const row of options.elements) {
|
|
2310
|
+
if (!isRecord(row) || typeof row.elementId !== "string" || typeof row.handle !== "string"
|
|
2311
|
+
|| (row.kind !== "character" && row.kind !== "location")
|
|
2312
|
+
|| typeof row.name !== "string" || typeof row.look !== "string" || typeof row.imageUrl !== "string") {
|
|
2313
|
+
return adminOnlyResult("This server returned unreadable saved references. Nothing has started.", json);
|
|
2314
|
+
}
|
|
2315
|
+
references.push(` ${row.name} (${row.kind}) — handle: ${row.handle}; elementId: ${row.elementId}`, ` Look: ${row.look}`, ` Image: ${row.imageUrl}`);
|
|
2316
|
+
}
|
|
2317
|
+
const voices = [];
|
|
2318
|
+
for (const row of options.voices) {
|
|
2319
|
+
if (!isRecord(row) || typeof row.voiceId !== "string" || typeof row.name !== "string"
|
|
2320
|
+
|| (row.description !== undefined && typeof row.description !== "string")
|
|
2321
|
+
|| (row.previewUrl !== undefined && typeof row.previewUrl !== "string")) {
|
|
2322
|
+
return adminOnlyResult("This server returned unreadable account voices. Nothing has started.", json);
|
|
2323
|
+
}
|
|
2324
|
+
voices.push(` ${row.name} — voiceId: ${row.voiceId}`, ...(row.description ? [` ${row.description}`] : []), ...(row.previewUrl ? [` Preview: ${row.previewUrl}`] : []));
|
|
2325
|
+
}
|
|
2326
|
+
if (json)
|
|
2327
|
+
return { code: 0, lines: [JSON.stringify({ ...options, ...metadata })] };
|
|
2328
|
+
return {
|
|
2329
|
+
code: 0,
|
|
2330
|
+
lines: [
|
|
2331
|
+
`Template input options: ${template.value}`,
|
|
2332
|
+
...experienceLines,
|
|
2333
|
+
...(capabilities ? [
|
|
2334
|
+
"Server-supported creative controls (template-default values are not intelligent automatic choices):",
|
|
2335
|
+
JSON.stringify(capabilities, null, 2),
|
|
2336
|
+
"Use --template-brief for supported pins. Server locks, dependencies and paid approval still apply.",
|
|
2337
|
+
] : ["V2 creative capabilities are not published by this server; no local catalog or fallback choices are supplied."]),
|
|
2338
|
+
...(!options.selectors.elements
|
|
2339
|
+
? ["Saved references are not supported for this template and selected route."]
|
|
2340
|
+
: references.length === 0 ? ["No supported saved references are available."]
|
|
2341
|
+
: ["Saved references:", ...references]),
|
|
2342
|
+
...(!options.selectors.voices
|
|
2343
|
+
? ["Account voices are not supported for this template and selected route."]
|
|
2344
|
+
: options.voicesUnavailable
|
|
2345
|
+
? ["Account voices are unavailable right now; this is not an empty catalog. No fallback voices are offered."]
|
|
2346
|
+
: voices.length === 0 ? ["No account voices are available."]
|
|
2347
|
+
: ["Account voices:", ...voices]),
|
|
2348
|
+
],
|
|
2349
|
+
};
|
|
2350
|
+
}
|
|
1729
2351
|
function isResolvedCard(value) {
|
|
1730
2352
|
if (!isRecord(value))
|
|
1731
2353
|
return false;
|
|
@@ -1877,16 +2499,57 @@ function scriptStartRefused(res, json) {
|
|
|
1877
2499
|
],
|
|
1878
2500
|
};
|
|
1879
2501
|
}
|
|
1880
|
-
function stoppedAtScriptResult(data, json) {
|
|
2502
|
+
function stoppedAtScriptResult(data, json, templateStart, voices, selections, templateIntent, context, intentResolution) {
|
|
1881
2503
|
const script = typeof data.script === "string" ? data.script : "";
|
|
1882
2504
|
const tidied = data.tidied === undefined ? null : scriptTidiedOf(data.tidied);
|
|
1883
2505
|
const written = writtenOf(data.written);
|
|
1884
2506
|
const rewritten = writtenOf(data.rewritten);
|
|
2507
|
+
if (templateIntent) {
|
|
2508
|
+
const retained = scriptResumeOf(data);
|
|
2509
|
+
if (!retained?.templateIntent
|
|
2510
|
+
|| !sameJsonValue(retained.templateIntent, templateIntent)
|
|
2511
|
+
|| !sameTemplateBrief(retained.templateBrief, context?.templateBrief)
|
|
2512
|
+
|| retained.productId !== context?.productId || retained.videoModel !== context?.videoModel
|
|
2513
|
+
|| (data.direction !== undefined && retained.direction !== context?.direction)
|
|
2514
|
+
|| (data.music !== undefined && retained.music !== context?.music)
|
|
2515
|
+
|| (data.shots !== undefined && !sameJsonValue(retained.shots, context?.shots))
|
|
2516
|
+
|| (data.songControls !== undefined && !sameJsonValue(retained.songControls, context?.songControls))
|
|
2517
|
+
|| (data.mechanismPlan !== undefined && !sameJsonValue(retained.mechanismPlan, context?.mechanismPlan))) {
|
|
2518
|
+
return adminOnlyResult("The server did not return a signed script review with the exact original input, mode, structure and adaptation intent. Do not resume this response; request a fresh review.", json);
|
|
2519
|
+
}
|
|
2520
|
+
}
|
|
2521
|
+
const { voiceMode: serverVoiceMode, voicePath: serverVoicePath, elements: serverElements, voices: serverVoices, ...templateData } = data;
|
|
2522
|
+
if (templateStart && ((voices.voiceMode !== undefined && serverVoiceMode !== undefined && voices.voiceMode !== serverVoiceMode)
|
|
2523
|
+
|| (voices.voicePath !== undefined && serverVoicePath !== undefined && voices.voicePath !== serverVoicePath))) {
|
|
2524
|
+
return adminOnlyResult("The server returned different voice choices from those selected. Nothing has started. Check the choices and write the script again before resuming.", json);
|
|
2525
|
+
}
|
|
2526
|
+
if (templateStart) {
|
|
2527
|
+
const elements = serverElements === undefined ? [] : scriptElementsOf(serverElements);
|
|
2528
|
+
const voiceMap = serverVoices === undefined ? {} : scriptVoicesOf(serverVoices);
|
|
2529
|
+
if (elements === null || voiceMap === null
|
|
2530
|
+
|| !sameScriptSelections(selections, { elements, voices: voiceMap })) {
|
|
2531
|
+
return adminOnlyResult("The server did not retain the selected references and voices in its script approval response. Nothing has started. Write and approve the script again before resuming.", json);
|
|
2532
|
+
}
|
|
2533
|
+
}
|
|
1885
2534
|
if (json) {
|
|
1886
2535
|
return {
|
|
1887
2536
|
code: 0,
|
|
1888
2537
|
lines: [
|
|
1889
2538
|
JSON.stringify({
|
|
2539
|
+
...(templateStart ? {
|
|
2540
|
+
...templateData,
|
|
2541
|
+
...selections,
|
|
2542
|
+
...(voices.voiceMode !== undefined ? { voiceMode: voices.voiceMode } : {}),
|
|
2543
|
+
...(voices.voicePath !== undefined ? { voicePath: voices.voicePath } : {}),
|
|
2544
|
+
...(templateIntent && context?.direction !== undefined ? { direction: context.direction } : {}),
|
|
2545
|
+
...(templateIntent && context?.music !== undefined ? { music: context.music } : {}),
|
|
2546
|
+
...(templateIntent && context?.shots !== undefined ? { shots: context.shots } : {}),
|
|
2547
|
+
...(templateIntent && context?.songControls !== undefined ? { songControls: context.songControls } : {}),
|
|
2548
|
+
...(templateIntent && context?.mechanismPlan !== undefined ? { mechanismPlan: context.mechanismPlan } : {}),
|
|
2549
|
+
...(templateIntent && context?.sourceRecord !== undefined ? { sourceRecord: context.sourceRecord } : {}),
|
|
2550
|
+
...(templateIntent && context?.adaptationPlan !== undefined ? { adaptationPlan: context.adaptationPlan } : {}),
|
|
2551
|
+
...(intentResolution !== undefined ? { intentResolution } : {}),
|
|
2552
|
+
} : {}),
|
|
1890
2553
|
stoppedAtScript: true,
|
|
1891
2554
|
script,
|
|
1892
2555
|
...(tidied ? { tidied } : {}),
|
|
@@ -1900,15 +2563,47 @@ function stoppedAtScriptResult(data, json) {
|
|
|
1900
2563
|
code: 0,
|
|
1901
2564
|
lines: [
|
|
1902
2565
|
...scriptTidiedHead(tidied),
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
:
|
|
1906
|
-
|
|
1907
|
-
|
|
2566
|
+
...(templateIntent ? [
|
|
2567
|
+
`Input assistance: ${templateIntent.mode === "auto" ? "automatic" : templateIntent.mode}`,
|
|
2568
|
+
...(templateIntent.structureKey ? [`Structure: ${templateIntent.structureKey}`] : []),
|
|
2569
|
+
...(templateIntent.referenceKey ? [`Reference inspiration: ${templateIntent.referenceKey} (not production rights)`] : []),
|
|
2570
|
+
"",
|
|
2571
|
+
] : []),
|
|
2572
|
+
...(templateIntent ? intentResolution ? [
|
|
2573
|
+
"Effective creative brief (server-resolved; raw pins remain separate):",
|
|
2574
|
+
JSON.stringify(intentResolution.effectiveBrief, null, 2),
|
|
2575
|
+
"Choice provenance (template-default / resolved / pinned):",
|
|
2576
|
+
JSON.stringify(intentResolution.provenance, null, 2),
|
|
2577
|
+
"",
|
|
2578
|
+
] : ["This server did not publish resolved-choice provenance for this draft.", ""] : []),
|
|
2579
|
+
...(templateIntent?.input.kind === "adapt" ? [
|
|
2580
|
+
"Original pasted text (retained exactly in --json):",
|
|
2581
|
+
templateIntent.input.originalText,
|
|
2582
|
+
"",
|
|
2583
|
+
"Adaptation intent:",
|
|
2584
|
+
templateIntent.input.adaptationIntent,
|
|
2585
|
+
"",
|
|
2586
|
+
templateIntent.input.originalText === script
|
|
2587
|
+
? "No text changed. The original was kept; no adaptation is claimed."
|
|
2588
|
+
: "Changed text — compare the original above with the complete resulting script below:",
|
|
2589
|
+
"",
|
|
2590
|
+
] : []),
|
|
2591
|
+
templateIntent
|
|
2592
|
+
? "Script preparation finished; no storyboard or video run has started. Review this exact resulting script before continuing:"
|
|
2593
|
+
: rewritten !== null
|
|
2594
|
+
? "Your script didn't fit this kind of ad, so we wrote a new one from it. Nothing has started."
|
|
2595
|
+
: written !== null
|
|
2596
|
+
? "Your file described the ad, so we wrote this script from it. Nothing has started."
|
|
2597
|
+
: "This is the script the run would start on. Nothing has started.",
|
|
1908
2598
|
"",
|
|
1909
2599
|
...script.split("\n").map((line) => (line ? ` ${line}` : "")),
|
|
1910
2600
|
"",
|
|
1911
|
-
|
|
2601
|
+
...(templateStart ? [
|
|
2602
|
+
"Use --stop-at-script --json to save the server-issued approval, original source and template choices as a JSON file.",
|
|
2603
|
+
"Edit only a separate script file, then repeat --conceit and --style with --resume-script <saved-stop-response.json> --script <edited.txt>, without --stop-at-script.",
|
|
2604
|
+
] : [
|
|
2605
|
+
"To start it, save it to a file and run the same command with --script <that file> and without --stop-at-script.",
|
|
2606
|
+
]),
|
|
1912
2607
|
],
|
|
1913
2608
|
};
|
|
1914
2609
|
}
|
|
@@ -1946,6 +2641,391 @@ function waitJsonWith(waited, facts) {
|
|
|
1946
2641
|
lines: [JSON.stringify({ ...parsed, ...facts })],
|
|
1947
2642
|
};
|
|
1948
2643
|
}
|
|
2644
|
+
function scriptElementsOf(value) {
|
|
2645
|
+
if (!Array.isArray(value))
|
|
2646
|
+
return null;
|
|
2647
|
+
const elements = [];
|
|
2648
|
+
for (const row of value) {
|
|
2649
|
+
if (!isRecord(row) || Object.keys(row).some((key) => key !== "handle" && key !== "elementId")
|
|
2650
|
+
|| typeof row.handle !== "string" || row.handle.trim() === ""
|
|
2651
|
+
|| typeof row.elementId !== "string" || row.elementId.trim() === "")
|
|
2652
|
+
return null;
|
|
2653
|
+
elements.push({ handle: row.handle, elementId: row.elementId });
|
|
2654
|
+
}
|
|
2655
|
+
return elements;
|
|
2656
|
+
}
|
|
2657
|
+
function scriptVoicesOf(value) {
|
|
2658
|
+
if (!isRecord(value))
|
|
2659
|
+
return null;
|
|
2660
|
+
const entries = [];
|
|
2661
|
+
for (const [who, choice] of Object.entries(value)) {
|
|
2662
|
+
if (choice === null) {
|
|
2663
|
+
entries.push([who, null]);
|
|
2664
|
+
continue;
|
|
2665
|
+
}
|
|
2666
|
+
const voiceId = typeof choice === "string" ? choice : isRecord(choice) ? choice.voiceId : undefined;
|
|
2667
|
+
if (typeof voiceId !== "string" || voiceId.trim() === "" || /\s/.test(voiceId.trim()))
|
|
2668
|
+
return null;
|
|
2669
|
+
entries.push([who, typeof choice === "string" ? choice : {
|
|
2670
|
+
voiceId,
|
|
2671
|
+
...(isRecord(choice) && typeof choice.label === "string" ? { label: choice.label } : {}),
|
|
2672
|
+
}]);
|
|
2673
|
+
}
|
|
2674
|
+
return Object.fromEntries(entries);
|
|
2675
|
+
}
|
|
2676
|
+
function sameScriptSelections(left, right) {
|
|
2677
|
+
const facts = [left, right].map((selection) => ({
|
|
2678
|
+
elements: [...(selection.elements ?? [])].sort((a, b) => a.handle.localeCompare(b.handle)),
|
|
2679
|
+
voices: Object.entries(selection.voices ?? {})
|
|
2680
|
+
.map(([who, choice]) => {
|
|
2681
|
+
const voiceId = typeof choice === "string" ? choice : choice?.voiceId;
|
|
2682
|
+
const label = typeof choice === "object" && choice !== null ? choice.label?.trim() : undefined;
|
|
2683
|
+
return {
|
|
2684
|
+
who: who.trim(),
|
|
2685
|
+
choice: voiceId === undefined ? null : {
|
|
2686
|
+
voiceId: voiceId.trim(), ...(label ? { label } : {}),
|
|
2687
|
+
},
|
|
2688
|
+
};
|
|
2689
|
+
})
|
|
2690
|
+
.sort((a, b) => a.who.localeCompare(b.who)),
|
|
2691
|
+
}));
|
|
2692
|
+
return JSON.stringify(facts[0]) === JSON.stringify(facts[1]);
|
|
2693
|
+
}
|
|
2694
|
+
function scriptTemplateBriefOf(value) {
|
|
2695
|
+
if (!isRecord(value) || Object.keys(value).some((key) => key !== "cards" && key !== "settings"))
|
|
2696
|
+
return null;
|
|
2697
|
+
if (value.cards !== undefined
|
|
2698
|
+
&& (!isRecord(value.cards) || !Object.values(value.cards).every((card) => typeof card === "string")))
|
|
2699
|
+
return null;
|
|
2700
|
+
if (value.settings !== undefined
|
|
2701
|
+
&& (!isRecord(value.settings) || !Object.values(value.settings).every((setting) => typeof setting === "string" || typeof setting === "boolean"
|
|
2702
|
+
|| (typeof setting === "number" && Number.isFinite(setting)))))
|
|
2703
|
+
return null;
|
|
2704
|
+
return value;
|
|
2705
|
+
}
|
|
2706
|
+
function withoutBlankTemplatePins(pins) {
|
|
2707
|
+
if (pins === undefined)
|
|
2708
|
+
return undefined;
|
|
2709
|
+
let result = pins;
|
|
2710
|
+
for (const [key, value] of Object.entries(pins)) {
|
|
2711
|
+
if (typeof value !== "string" || value.trim() !== "")
|
|
2712
|
+
continue;
|
|
2713
|
+
if (result === pins)
|
|
2714
|
+
result = { ...pins };
|
|
2715
|
+
delete result[key];
|
|
2716
|
+
}
|
|
2717
|
+
return Object.keys(result).length ? result : undefined;
|
|
2718
|
+
}
|
|
2719
|
+
function templateIntentOf(value) {
|
|
2720
|
+
if (!isRecord(value) || Object.keys(value).some((key) => !["mode", "structureKey", "referenceKey", "input"].includes(key))
|
|
2721
|
+
|| (value.mode !== "auto" && value.mode !== "manual" && value.mode !== "hybrid"))
|
|
2722
|
+
return null;
|
|
2723
|
+
for (const field of ["structureKey", "referenceKey"]) {
|
|
2724
|
+
if (value[field] !== undefined && (typeof value[field] !== "string" || value[field].trim() === ""))
|
|
2725
|
+
return null;
|
|
2726
|
+
}
|
|
2727
|
+
const input = value.input;
|
|
2728
|
+
if (!isRecord(input) || Object.keys(input).some((key) => !["kind", "subject", "originalText", "adaptationIntent"].includes(key))
|
|
2729
|
+
|| (input.kind !== "brief" && input.kind !== "adapt")
|
|
2730
|
+
|| typeof input.originalText !== "string" || input.originalText.trim() === "")
|
|
2731
|
+
return null;
|
|
2732
|
+
if (input.subject !== undefined && input.subject !== "product" && input.subject !== "service" && input.subject !== "non-product")
|
|
2733
|
+
return null;
|
|
2734
|
+
if (input.kind === "adapt"
|
|
2735
|
+
? typeof input.adaptationIntent !== "string" || input.adaptationIntent.trim() === ""
|
|
2736
|
+
: input.adaptationIntent !== undefined)
|
|
2737
|
+
return null;
|
|
2738
|
+
return {
|
|
2739
|
+
mode: value.mode,
|
|
2740
|
+
...(value.structureKey !== undefined ? { structureKey: value.structureKey } : {}),
|
|
2741
|
+
...(value.referenceKey !== undefined ? { referenceKey: value.referenceKey } : {}),
|
|
2742
|
+
input: {
|
|
2743
|
+
kind: input.kind, originalText: input.originalText,
|
|
2744
|
+
...(input.subject !== undefined ? { subject: input.subject } : {}),
|
|
2745
|
+
...(input.kind === "adapt" ? { adaptationIntent: input.adaptationIntent } : {}),
|
|
2746
|
+
},
|
|
2747
|
+
};
|
|
2748
|
+
}
|
|
2749
|
+
function sameTemplateBrief(left, right) {
|
|
2750
|
+
for (const field of ["cards", "settings"]) {
|
|
2751
|
+
const a = left?.[field] ?? {};
|
|
2752
|
+
const b = right?.[field] ?? {};
|
|
2753
|
+
if (Object.keys(a).length !== Object.keys(b).length
|
|
2754
|
+
|| Object.entries(a).some(([key, value]) => !Object.hasOwn(b, key) || b[key] !== value))
|
|
2755
|
+
return false;
|
|
2756
|
+
}
|
|
2757
|
+
return true;
|
|
2758
|
+
}
|
|
2759
|
+
function sameJsonValue(left, right) {
|
|
2760
|
+
if (left === right)
|
|
2761
|
+
return true;
|
|
2762
|
+
if (Array.isArray(left) && Array.isArray(right)) {
|
|
2763
|
+
return left.length === right.length && left.every((value, index) => sameJsonValue(value, right[index]));
|
|
2764
|
+
}
|
|
2765
|
+
if (!isRecord(left) || !isRecord(right))
|
|
2766
|
+
return false;
|
|
2767
|
+
return Object.keys(left).length === Object.keys(right).length
|
|
2768
|
+
&& Object.entries(left).every(([key, value]) => Object.hasOwn(right, key) && sameJsonValue(value, right[key]));
|
|
2769
|
+
}
|
|
2770
|
+
function preparationQuoteOf(value) {
|
|
2771
|
+
if (!isRecord(value) || typeof value.quoteId !== "string" || !value.quoteId.trim()
|
|
2772
|
+
|| (value.phase !== "script" && value.phase !== "storyboard")
|
|
2773
|
+
|| typeof value.contextHash !== "string" || !value.contextHash.trim()
|
|
2774
|
+
|| typeof value.expiresAt !== "number" || !Number.isFinite(new Date(value.expiresAt).getTime())
|
|
2775
|
+
|| (value.estimatedUsd !== null && (typeof value.estimatedUsd !== "number" || !Number.isFinite(value.estimatedUsd) || value.estimatedUsd < 0))
|
|
2776
|
+
|| typeof value.maximumUsd !== "number" || !Number.isFinite(value.maximumUsd) || value.maximumUsd <= 0
|
|
2777
|
+
|| typeof value.scope !== "string" || !value.scope.trim())
|
|
2778
|
+
return null;
|
|
2779
|
+
return {
|
|
2780
|
+
quoteId: value.quoteId, phase: value.phase, contextHash: value.contextHash, expiresAt: value.expiresAt,
|
|
2781
|
+
estimatedUsd: value.estimatedUsd, maximumUsd: value.maximumUsd, scope: value.scope,
|
|
2782
|
+
};
|
|
2783
|
+
}
|
|
2784
|
+
function preparationInputOf(body, phase) {
|
|
2785
|
+
const input = {};
|
|
2786
|
+
for (const field of [
|
|
2787
|
+
"script", "conceit", "style", "templateBrief", "productId", "elements", "voiceMode", "voicePath",
|
|
2788
|
+
"videoModel", "scriptApproval", "approvedSource", "adaptationPlan", "direction", "templateIntent",
|
|
2789
|
+
"music", "shots", "songControls", "mechanismPlan",
|
|
2790
|
+
]) {
|
|
2791
|
+
if (body[field] !== undefined)
|
|
2792
|
+
input[field] = body[field];
|
|
2793
|
+
}
|
|
2794
|
+
if (body.voices !== undefined) {
|
|
2795
|
+
input.voices = Object.entries(body.voices).map(([who, choice]) => {
|
|
2796
|
+
const voiceId = typeof choice === "string" ? choice.trim() : choice?.voiceId.trim();
|
|
2797
|
+
const label = typeof choice === "object" && choice !== null ? choice.label?.trim() : undefined;
|
|
2798
|
+
return {
|
|
2799
|
+
who: who.trim(),
|
|
2800
|
+
choice: voiceId === undefined ? { kind: "clear" } : {
|
|
2801
|
+
kind: "pin", voiceId, ...(label ? { label } : {}),
|
|
2802
|
+
},
|
|
2803
|
+
};
|
|
2804
|
+
});
|
|
2805
|
+
}
|
|
2806
|
+
if (phase === "script") {
|
|
2807
|
+
input.operation = body.rewriteToFit === true ? "rewrite" : body.describe === true ? "write" : "reapprove";
|
|
2808
|
+
if (body.describe !== undefined)
|
|
2809
|
+
input.describe = body.describe;
|
|
2810
|
+
}
|
|
2811
|
+
else {
|
|
2812
|
+
for (const field of ["reviewStoryboard", "director", "broll", "sourceRecord"]) {
|
|
2813
|
+
if (body[field] !== undefined)
|
|
2814
|
+
input[field] = body[field];
|
|
2815
|
+
}
|
|
2816
|
+
input.launchedVia = "cli";
|
|
2817
|
+
}
|
|
2818
|
+
return input;
|
|
2819
|
+
}
|
|
2820
|
+
async function templateResolutionFlow(template, templateIntent, templateBrief, route, deps) {
|
|
2821
|
+
const query = new URLSearchParams({ door: "template", template, templateIntent: JSON.stringify(templateIntent) });
|
|
2822
|
+
if (templateBrief !== undefined)
|
|
2823
|
+
query.set("templateBrief", JSON.stringify(templateBrief));
|
|
2824
|
+
for (const field of ["voiceMode", "voicePath", "videoModel"]) {
|
|
2825
|
+
const value = route[field];
|
|
2826
|
+
if (value !== undefined)
|
|
2827
|
+
query.set(field, value);
|
|
2828
|
+
}
|
|
2829
|
+
const response = await deps.get(`${SCRIPT_RUNS_PATH}?${query}`).catch(() => null);
|
|
2830
|
+
const refused = (line) => ({ kind: "result", result: adminOnlyResult(line, route.json) });
|
|
2831
|
+
if (!response)
|
|
2832
|
+
return refused("Current template input options could not be read. No paid preparation was requested.");
|
|
2833
|
+
if (!response.ok)
|
|
2834
|
+
return { kind: "result", result: errorResult(response, route.json) };
|
|
2835
|
+
const options = isRecord(response.data) ? response.data.inputOptions : undefined;
|
|
2836
|
+
if (!isRecord(options))
|
|
2837
|
+
return refused("The server did not return selected template input options. No paid preparation was requested.");
|
|
2838
|
+
if (route.songControls !== undefined) {
|
|
2839
|
+
const rows = isRecord(response.data) && Array.isArray(response.data.templates) ? response.data.templates : [];
|
|
2840
|
+
const selected = rows.find((row) => isRecord(row) && row.key === template);
|
|
2841
|
+
const capabilities = isRecord(selected) && isRecord(selected.templateCapabilities) ? selected.templateCapabilities : undefined;
|
|
2842
|
+
if (capabilities?.songControls !== true) {
|
|
2843
|
+
return refused("The server does not advertise Song controls for this template. Your pins were not discarded. Remove them explicitly with --song-controls '{}' or select a supported template and request fresh review. No paid preparation was requested.");
|
|
2844
|
+
}
|
|
2845
|
+
}
|
|
2846
|
+
if (options.intentResolution === undefined)
|
|
2847
|
+
return { kind: "resolution" };
|
|
2848
|
+
const raw = options.intentResolution;
|
|
2849
|
+
const intent = isRecord(raw) ? templateIntentOf(raw.intent) : null;
|
|
2850
|
+
if (!isRecord(raw) || !intent || !sameJsonValue(intent, templateIntent) || typeof raw.ok !== "boolean"
|
|
2851
|
+
|| !isRecord(raw.effectiveBrief) || !isRecord(raw.provenance) || !Array.isArray(raw.holds)) {
|
|
2852
|
+
return refused("The server returned unreadable or stale template input resolution. No paid preparation was requested.");
|
|
2853
|
+
}
|
|
2854
|
+
const holds = [];
|
|
2855
|
+
for (const hold of raw.holds) {
|
|
2856
|
+
if (!isRecord(hold) || typeof hold.code !== "string" || typeof hold.field !== "string" || typeof hold.message !== "string") {
|
|
2857
|
+
return refused("The server returned unreadable template input holds. No paid preparation was requested.");
|
|
2858
|
+
}
|
|
2859
|
+
holds.push({ code: hold.code, field: hold.field, message: hold.message });
|
|
2860
|
+
}
|
|
2861
|
+
const value = {
|
|
2862
|
+
ok: raw.ok, intent, effectiveBrief: raw.effectiveBrief, provenance: raw.provenance, holds,
|
|
2863
|
+
...(raw.structure !== undefined ? { structure: raw.structure } : {}),
|
|
2864
|
+
...(raw.reference !== undefined ? { reference: raw.reference } : {}),
|
|
2865
|
+
...(raw.capabilities !== undefined ? { capabilities: raw.capabilities } : {}),
|
|
2866
|
+
};
|
|
2867
|
+
if (!raw.ok || holds.length > 0) {
|
|
2868
|
+
const error = holds.length ? holds.map(({ field, message }) => `${field}: ${message}`).join("\n") : "The current template input is held.";
|
|
2869
|
+
return {
|
|
2870
|
+
kind: "result",
|
|
2871
|
+
result: { code: 1, lines: route.json ? [JSON.stringify({ ok: false, error, intentResolution: value })] : [error, "No paid preparation was requested."] },
|
|
2872
|
+
};
|
|
2873
|
+
}
|
|
2874
|
+
return { kind: "resolution", value };
|
|
2875
|
+
}
|
|
2876
|
+
async function preparationFlow(phase, input, opts, deps, intentResolution, reviewedControls) {
|
|
2877
|
+
const result = (line) => ({ kind: "result", result: adminOnlyResult(line, opts.json) });
|
|
2878
|
+
let saved;
|
|
2879
|
+
if (opts.authorizePreparationFile !== undefined) {
|
|
2880
|
+
try {
|
|
2881
|
+
const value = JSON.parse(deps.readFile(opts.authorizePreparationFile));
|
|
2882
|
+
const quote = isRecord(value) ? preparationQuoteOf(value.preparationQuote) : null;
|
|
2883
|
+
if (!isRecord(value) || !quote || typeof value.requestId !== "string" || !value.requestId.trim()
|
|
2884
|
+
|| !isRecord(value.input))
|
|
2885
|
+
throw new Error("expected an unchanged --quote-preparation --json response");
|
|
2886
|
+
saved = { preparationQuote: quote, requestId: value.requestId, input: value.input };
|
|
2887
|
+
}
|
|
2888
|
+
catch (error) {
|
|
2889
|
+
return result(`Can't read --authorize-preparation: ${error instanceof Error ? error.message : String(error)}. No paid preparation was requested.`);
|
|
2890
|
+
}
|
|
2891
|
+
if (saved.preparationQuote.phase !== phase) {
|
|
2892
|
+
return result("The saved preparation quote belongs to a different phase or input. Review a new quote for this exact draft; an old quote cannot authorize changed text or context. No paid preparation was requested.");
|
|
2893
|
+
}
|
|
2894
|
+
}
|
|
2895
|
+
else if (!opts.quotePreparation) {
|
|
2896
|
+
return result("Template preparation requires a reviewed phase quote. Repeat this command with --quote-preparation --json, save and review the response, then explicitly accept it with --authorize-preparation <saved-quote.json>. Input mode never approves spending. No paid preparation was requested.");
|
|
2897
|
+
}
|
|
2898
|
+
const requestId = saved?.requestId ?? randomUUID();
|
|
2899
|
+
const response = await deps.post("/api/v2/video/template-preparation", { phase, requestId, input }).catch(() => null);
|
|
2900
|
+
if (!response)
|
|
2901
|
+
return result("The preparation quote could not be read. Keep the same saved quote for recovery; no paid preparation was requested.");
|
|
2902
|
+
if (!response.ok && response.status === 404)
|
|
2903
|
+
return result("The preparation quote endpoint is unavailable for this key or server. No paid preparation was requested.");
|
|
2904
|
+
if (!response.ok)
|
|
2905
|
+
return { kind: "result", result: errorResult(response, opts.json) };
|
|
2906
|
+
const quote = preparationQuoteOf(response.data);
|
|
2907
|
+
if (!quote || quote.phase !== phase)
|
|
2908
|
+
return result("This server did not return a usable quote for the requested phase. No paid preparation was requested.");
|
|
2909
|
+
const canonicalInput = isRecord(response.data) && isRecord(response.data.canonicalInput) ? response.data.canonicalInput : null;
|
|
2910
|
+
if (!canonicalInput || canonicalInput.script !== input.script
|
|
2911
|
+
|| !sameJsonValue(canonicalInput.templateIntent, input.templateIntent)
|
|
2912
|
+
|| !sameJsonValue(canonicalInput.approvedSource, input.approvedSource)
|
|
2913
|
+
|| canonicalInput.operation !== input.operation || canonicalInput.describe !== input.describe
|
|
2914
|
+
|| (canonicalInput.songControls !== undefined && !isRecord(canonicalInput.songControls))
|
|
2915
|
+
|| (canonicalInput.mechanismPlan !== undefined && !isRecord(canonicalInput.mechanismPlan))) {
|
|
2916
|
+
return result("The server did not return canonical preparation input for the same exact source and operation. No paid preparation was requested.");
|
|
2917
|
+
}
|
|
2918
|
+
if (reviewedControls && (!sameJsonValue(canonicalInput.songControls, reviewedControls.songControls)
|
|
2919
|
+
|| !sameJsonValue(canonicalInput.mechanismPlan, reviewedControls.mechanismPlan))) {
|
|
2920
|
+
return result("The script or template context changed after review. Resume with --stop-at-script --json to review the current controls before starting. No paid preparation was requested.");
|
|
2921
|
+
}
|
|
2922
|
+
if (saved) {
|
|
2923
|
+
if (!sameJsonValue(quote, saved.preparationQuote)) {
|
|
2924
|
+
return result("The server returned different preparation authority. The saved approval was not replayed and the new quote was not accepted. Review current authority explicitly; no paid preparation was requested.");
|
|
2925
|
+
}
|
|
2926
|
+
if (!sameJsonValue(canonicalInput, saved.input)) {
|
|
2927
|
+
return result("The saved preparation quote belongs to a different phase or input. Review a new quote for this exact draft; an old quote cannot authorize changed text or context. No paid preparation was requested.");
|
|
2928
|
+
}
|
|
2929
|
+
return { kind: "authorized", authorization: { quoteId: quote.quoteId, maximumUsd: saved.preparationQuote.maximumUsd }, canonicalInput };
|
|
2930
|
+
}
|
|
2931
|
+
const envelope = { preparationQuote: quote, requestId, input: canonicalInput, ...(intentResolution ? { intentResolution } : {}) };
|
|
2932
|
+
return {
|
|
2933
|
+
kind: "result",
|
|
2934
|
+
result: {
|
|
2935
|
+
code: 0,
|
|
2936
|
+
lines: opts.json ? [JSON.stringify(envelope)] : [
|
|
2937
|
+
`${phase === "script" ? "Script" : "Storyboard"} preparation quote (no paid preparation requested)`,
|
|
2938
|
+
quote.estimatedUsd === null
|
|
2939
|
+
? "Actual cost unknown; only the maximum allowance is available."
|
|
2940
|
+
: `Approximate estimate: $${quote.estimatedUsd}`,
|
|
2941
|
+
`Maximum for this phase: $${quote.maximumUsd}`,
|
|
2942
|
+
`Scope: ${quote.scope}`,
|
|
2943
|
+
`Expires: ${new Date(quote.expiresAt).toISOString()}`,
|
|
2944
|
+
...(intentResolution ? [
|
|
2945
|
+
"Effective creative brief and provenance (server):",
|
|
2946
|
+
JSON.stringify({ effectiveBrief: intentResolution.effectiveBrief, provenance: intentResolution.provenance }, null, 2),
|
|
2947
|
+
] : ["This server did not publish resolved-choice provenance for this draft."]),
|
|
2948
|
+
"This is not a whole-video price or approval.",
|
|
2949
|
+
"Save this command's --quote-preparation --json response. After reviewing it, repeat the exact draft with --authorize-preparation <saved-quote.json> instead of --quote-preparation.",
|
|
2950
|
+
],
|
|
2951
|
+
},
|
|
2952
|
+
};
|
|
2953
|
+
}
|
|
2954
|
+
function scriptJsonObjectInput(input, deps) {
|
|
2955
|
+
const raw = input.trim();
|
|
2956
|
+
const value = JSON.parse(raw.startsWith("@") ? deps.readFile(raw.slice(1)) : raw);
|
|
2957
|
+
if (!isRecord(value))
|
|
2958
|
+
throw new Error("expected a JSON object");
|
|
2959
|
+
return value;
|
|
2960
|
+
}
|
|
2961
|
+
function scriptResumeOf(value) {
|
|
2962
|
+
if (!isRecord(value) || value.stoppedAtScript !== true
|
|
2963
|
+
|| typeof value.script !== "string" || value.script.trim() === "")
|
|
2964
|
+
return null;
|
|
2965
|
+
if (typeof value.scriptApproval !== "string" || value.scriptApproval.trim() === "")
|
|
2966
|
+
return null;
|
|
2967
|
+
const source = value.approvedSource;
|
|
2968
|
+
if (!isRecord(source) || Object.keys(source).some((key) => key !== "mode" && key !== "text")
|
|
2969
|
+
|| (source.mode !== "verbatim" && source.mode !== "description")
|
|
2970
|
+
|| typeof source.text !== "string" || source.text.trim() === "")
|
|
2971
|
+
return null;
|
|
2972
|
+
const brief = value.templateBrief === undefined ? undefined : scriptTemplateBriefOf(value.templateBrief);
|
|
2973
|
+
if (brief === null)
|
|
2974
|
+
return null;
|
|
2975
|
+
const templateIntent = value.templateIntent === undefined ? undefined : templateIntentOf(value.templateIntent);
|
|
2976
|
+
if (templateIntent === null)
|
|
2977
|
+
return null;
|
|
2978
|
+
if (templateIntent && value.direction !== undefined && typeof value.direction !== "string")
|
|
2979
|
+
return null;
|
|
2980
|
+
if (templateIntent) {
|
|
2981
|
+
if (value.music !== undefined && typeof value.music !== "boolean")
|
|
2982
|
+
return null;
|
|
2983
|
+
if (value.shots !== undefined && (!isRecord(value.shots)
|
|
2984
|
+
|| Object.keys(value.shots).some((key) => key !== "frame" && key !== "pacing")
|
|
2985
|
+
|| !Object.values(value.shots).every((field) => typeof field === "string")))
|
|
2986
|
+
return null;
|
|
2987
|
+
if (value.songControls !== undefined && !isRecord(value.songControls))
|
|
2988
|
+
return null;
|
|
2989
|
+
if (value.mechanismPlan !== undefined && !isRecord(value.mechanismPlan))
|
|
2990
|
+
return null;
|
|
2991
|
+
}
|
|
2992
|
+
if (value.productId !== undefined
|
|
2993
|
+
&& (typeof value.productId !== "string" || value.productId.trim() === ""))
|
|
2994
|
+
return null;
|
|
2995
|
+
if (value.voiceMode !== undefined
|
|
2996
|
+
&& (typeof value.voiceMode !== "string" || !isVoiceMode(value.voiceMode)))
|
|
2997
|
+
return null;
|
|
2998
|
+
if (value.voicePath !== undefined
|
|
2999
|
+
&& (typeof value.voicePath !== "string" || value.voicePath.trim() === ""))
|
|
3000
|
+
return null;
|
|
3001
|
+
if (value.videoModel !== undefined
|
|
3002
|
+
&& (typeof value.videoModel !== "string" || value.videoModel.trim() === ""))
|
|
3003
|
+
return null;
|
|
3004
|
+
const elements = value.elements === undefined ? undefined : scriptElementsOf(value.elements);
|
|
3005
|
+
const voices = value.voices === undefined ? undefined : scriptVoicesOf(value.voices);
|
|
3006
|
+
if (elements === null || voices === null)
|
|
3007
|
+
return null;
|
|
3008
|
+
return {
|
|
3009
|
+
reviewedScript: value.script,
|
|
3010
|
+
...(templateIntent !== undefined ? { templateIntent } : {}),
|
|
3011
|
+
...(templateIntent && typeof value.direction === "string" ? { direction: value.direction } : {}),
|
|
3012
|
+
...(templateIntent && value.music !== undefined ? { music: value.music } : {}),
|
|
3013
|
+
...(templateIntent && value.shots !== undefined ? { shots: value.shots } : {}),
|
|
3014
|
+
...(templateIntent && value.songControls !== undefined ? { songControls: value.songControls } : {}),
|
|
3015
|
+
...(templateIntent && value.mechanismPlan !== undefined ? { mechanismPlan: value.mechanismPlan } : {}),
|
|
3016
|
+
...(templateIntent && value.sourceRecord !== undefined ? { sourceRecord: value.sourceRecord } : {}),
|
|
3017
|
+
...(templateIntent && value.adaptationPlan !== undefined ? { adaptationPlan: value.adaptationPlan } : {}),
|
|
3018
|
+
scriptApproval: value.scriptApproval,
|
|
3019
|
+
approvedSource: { mode: source.mode, text: source.text },
|
|
3020
|
+
...(brief !== undefined ? { templateBrief: brief } : {}),
|
|
3021
|
+
...(value.productId !== undefined ? { productId: value.productId } : {}),
|
|
3022
|
+
...(value.voiceMode !== undefined ? { voiceMode: value.voiceMode } : {}),
|
|
3023
|
+
...(value.voicePath !== undefined ? { voicePath: value.voicePath } : {}),
|
|
3024
|
+
...(value.videoModel !== undefined ? { videoModel: value.videoModel } : {}),
|
|
3025
|
+
...(elements !== undefined ? { elements } : {}),
|
|
3026
|
+
...(voices !== undefined ? { voices } : {}),
|
|
3027
|
+
};
|
|
3028
|
+
}
|
|
1949
3029
|
export async function startScriptFlow(opts, deps) {
|
|
1950
3030
|
let script;
|
|
1951
3031
|
try {
|
|
@@ -1962,7 +3042,127 @@ export async function startScriptFlow(opts, deps) {
|
|
|
1962
3042
|
if (script.trim().length === 0) {
|
|
1963
3043
|
return { code: 1, lines: [`The script file "${opts.scriptFile}" is empty.`] };
|
|
1964
3044
|
}
|
|
1965
|
-
|
|
3045
|
+
if (opts.writerBrief)
|
|
3046
|
+
script = composeTemplateBrief({ ...opts.writerBrief, about: script });
|
|
3047
|
+
let resume;
|
|
3048
|
+
if (opts.resumeScriptFile) {
|
|
3049
|
+
let saved;
|
|
3050
|
+
try {
|
|
3051
|
+
saved = JSON.parse(deps.readFile(opts.resumeScriptFile));
|
|
3052
|
+
}
|
|
3053
|
+
catch (error) {
|
|
3054
|
+
return { code: 1, lines: [`Can't read the saved script response "${opts.resumeScriptFile}" as JSON: ${String(error)}`] };
|
|
3055
|
+
}
|
|
3056
|
+
const parsed = scriptResumeOf(saved);
|
|
3057
|
+
if (!parsed) {
|
|
3058
|
+
return {
|
|
3059
|
+
code: 1,
|
|
3060
|
+
lines: ["--resume-script needs a saved stoppedAtScript:true response with a nonempty script and server-issued scriptApproval, approvedSource { mode: \"verbatim\" | \"description\", text }, and valid templateBrief/productId/voiceMode/voicePath/videoModel/elements/voices if supplied. Write and explicitly approve a fresh script with --stop-at-script --json before resuming."],
|
|
3061
|
+
};
|
|
3062
|
+
}
|
|
3063
|
+
resume = parsed;
|
|
3064
|
+
}
|
|
3065
|
+
if (resume && opts.productId !== undefined && opts.productId !== resume.productId) {
|
|
3066
|
+
return {
|
|
3067
|
+
code: 1,
|
|
3068
|
+
lines: ["The selected product differs from the saved script's approved product. Write and explicitly approve a fresh script for that product with --stop-at-script --json, without --resume-script. Nothing has started."],
|
|
3069
|
+
};
|
|
3070
|
+
}
|
|
3071
|
+
const hasIntentInputs = opts.inputMode !== undefined || opts.structure !== undefined || opts.reference !== undefined
|
|
3072
|
+
|| opts.subject !== undefined || opts.adaptationIntent !== undefined || opts.describe === true || opts.keepOriginal === true
|
|
3073
|
+
|| opts.templateBriefInput !== undefined || opts.songControlsInput !== undefined || opts.mechanismPlanInput !== undefined;
|
|
3074
|
+
const hasPreparationConsent = opts.quotePreparation === true || opts.authorizePreparationFile !== undefined;
|
|
3075
|
+
if (resume && resume.templateIntent === undefined && hasIntentInputs) {
|
|
3076
|
+
return adminOnlyResult("This saved review has no V2 original-input context. Start a fresh --describe or --adapt review using the original source file, without --resume-script. Nothing has started.", opts.json);
|
|
3077
|
+
}
|
|
3078
|
+
const templateIntent = resume?.templateIntent || hasIntentInputs
|
|
3079
|
+
? {
|
|
3080
|
+
mode: opts.inputMode === "automatic" ? "auto" : opts.inputMode ?? resume?.templateIntent?.mode ?? "auto",
|
|
3081
|
+
...(opts.structure !== undefined || resume?.templateIntent?.structureKey !== undefined
|
|
3082
|
+
? { structureKey: opts.structure ?? resume?.templateIntent?.structureKey } : {}),
|
|
3083
|
+
...(opts.reference !== undefined || resume?.templateIntent?.referenceKey !== undefined
|
|
3084
|
+
? { referenceKey: opts.reference ?? resume?.templateIntent?.referenceKey } : {}),
|
|
3085
|
+
input: {
|
|
3086
|
+
...(resume?.templateIntent?.input ?? {
|
|
3087
|
+
kind: opts.adaptationIntent !== undefined ? "adapt" : "brief",
|
|
3088
|
+
originalText: script,
|
|
3089
|
+
...(opts.adaptationIntent !== undefined ? { adaptationIntent: opts.adaptationIntent } : {}),
|
|
3090
|
+
}),
|
|
3091
|
+
...(opts.subject !== undefined ? { subject: opts.subject } : {}),
|
|
3092
|
+
},
|
|
3093
|
+
}
|
|
3094
|
+
: undefined;
|
|
3095
|
+
let stopAtScript = opts.stopAtScript === true || opts.keepOriginal === true
|
|
3096
|
+
|| (templateIntent !== undefined && (resume === undefined || opts.rewriteToFit === true));
|
|
3097
|
+
if (templateIntent && opts.rewriteToFit && resume === undefined) {
|
|
3098
|
+
return adminOnlyResult("A V2 rewrite needs a previously reviewed --resume-script response. For an initial adaptation, use --adapt <intent>; write and review before rewriting. Nothing has started.", opts.json);
|
|
3099
|
+
}
|
|
3100
|
+
if (opts.keepOriginal && script !== templateIntent?.input.originalText) {
|
|
3101
|
+
return adminOnlyResult("--keep-original requires --script to contain the exact original text, not an edited result. Nothing has started.", opts.json);
|
|
3102
|
+
}
|
|
3103
|
+
if (templateIntent && opts.reviewStoryboard !== true) {
|
|
3104
|
+
return adminOnlyResult("V2 template inputs require storyboard review; do not combine them with --one-shot. Nothing has started.", opts.json);
|
|
3105
|
+
}
|
|
3106
|
+
if (templateIntent && resume === undefined && !opts.describe && opts.adaptationIntent === undefined) {
|
|
3107
|
+
return adminOnlyResult("Choose an explicit initial V2 script path: --describe to write from a brief, --adapt <intent> to adapt copy, or --adapt <intent> --keep-original for guarded unchanged review. Input mode alone never rewrites text. No paid preparation was requested.", opts.json);
|
|
3108
|
+
}
|
|
3109
|
+
const music = opts.music ?? (templateIntent ? resume?.music : undefined);
|
|
3110
|
+
const shots = templateIntent && (resume?.shots || opts.shots)
|
|
3111
|
+
? { ...resume?.shots, ...opts.shots }
|
|
3112
|
+
: opts.shots;
|
|
3113
|
+
let songControls = templateIntent ? resume?.songControls : undefined;
|
|
3114
|
+
let mechanismPlan = templateIntent ? resume?.mechanismPlan : undefined;
|
|
3115
|
+
try {
|
|
3116
|
+
if (opts.songControlsInput !== undefined)
|
|
3117
|
+
songControls = withoutBlankTemplatePins(scriptJsonObjectInput(opts.songControlsInput, deps));
|
|
3118
|
+
if (opts.mechanismPlanInput !== undefined)
|
|
3119
|
+
mechanismPlan = scriptJsonObjectInput(opts.mechanismPlanInput, deps);
|
|
3120
|
+
}
|
|
3121
|
+
catch (error) {
|
|
3122
|
+
return adminOnlyResult(`Can't read template sound/story controls: ${error instanceof Error ? error.message : String(error)}`, opts.json);
|
|
3123
|
+
}
|
|
3124
|
+
let suppliedBrief;
|
|
3125
|
+
if (opts.templateBriefInput !== undefined) {
|
|
3126
|
+
try {
|
|
3127
|
+
const raw = opts.templateBriefInput.trim();
|
|
3128
|
+
const parsed = scriptTemplateBriefOf(JSON.parse(raw.startsWith("@") ? deps.readFile(raw.slice(1)) : raw));
|
|
3129
|
+
if (parsed === null)
|
|
3130
|
+
throw new Error("expected { cards?: { layer: card }, settings?: { name: primitive } }");
|
|
3131
|
+
suppliedBrief = parsed;
|
|
3132
|
+
}
|
|
3133
|
+
catch (error) {
|
|
3134
|
+
return adminOnlyResult(`Can't read --template-brief: ${error instanceof Error ? error.message : String(error)}`, opts.json);
|
|
3135
|
+
}
|
|
3136
|
+
}
|
|
3137
|
+
let elements = resume?.elements;
|
|
3138
|
+
let selectedVoices = resume?.voices;
|
|
3139
|
+
try {
|
|
3140
|
+
if (opts.elementsInput !== undefined) {
|
|
3141
|
+
let text = opts.elementsInput.trim();
|
|
3142
|
+
if (text.startsWith("@"))
|
|
3143
|
+
text = deps.readFile(text.slice(1));
|
|
3144
|
+
const parsed = scriptElementsOf(JSON.parse(text));
|
|
3145
|
+
if (parsed === null)
|
|
3146
|
+
throw new Error("--elements must be an array of { handle, elementId } with nonempty strings.");
|
|
3147
|
+
elements = parsed;
|
|
3148
|
+
}
|
|
3149
|
+
if (opts.voicesInput !== undefined) {
|
|
3150
|
+
const parsed = scriptVoicesOf(parseVoicesFlag([{ flag: "voices", value: opts.voicesInput }], deps.readFile));
|
|
3151
|
+
if (parsed === null)
|
|
3152
|
+
throw new Error("--voices must map script speaker names to a nonempty voice ID without spaces, { voiceId, label? }, or null.");
|
|
3153
|
+
selectedVoices = parsed;
|
|
3154
|
+
}
|
|
3155
|
+
}
|
|
3156
|
+
catch (error) {
|
|
3157
|
+
return { code: 1, lines: [`Can't read template selections: ${error instanceof Error ? error.message : String(error)}`] };
|
|
3158
|
+
}
|
|
3159
|
+
if (resume && !opts.stopAtScript && !sameScriptSelections(resume, { elements, voices: selectedVoices })) {
|
|
3160
|
+
return {
|
|
3161
|
+
code: 1,
|
|
3162
|
+
lines: ["The selected references or voices differ from the saved script's approved selections. Keep your original description and edited script files. Use --stop-at-script --json with --resume-script to explicitly check and approve the edited script with these selections, then resume the returned approval response to start. Nothing has started."],
|
|
3163
|
+
};
|
|
3164
|
+
}
|
|
3165
|
+
let sourceRecord = templateIntent ? resume?.sourceRecord : undefined;
|
|
1966
3166
|
if (opts.sourceRecordFile) {
|
|
1967
3167
|
try {
|
|
1968
3168
|
sourceRecord = JSON.parse(deps.readFile(opts.sourceRecordFile));
|
|
@@ -1976,7 +3176,7 @@ export async function startScriptFlow(opts, deps) {
|
|
|
1976
3176
|
};
|
|
1977
3177
|
}
|
|
1978
3178
|
}
|
|
1979
|
-
let adaptationPlan;
|
|
3179
|
+
let adaptationPlan = templateIntent ? resume?.adaptationPlan : undefined;
|
|
1980
3180
|
if (opts.adaptationPlanFile) {
|
|
1981
3181
|
try {
|
|
1982
3182
|
adaptationPlan = opts.adaptationPlanFile === "original"
|
|
@@ -1987,39 +3187,173 @@ export async function startScriptFlow(opts, deps) {
|
|
|
1987
3187
|
return { code: 1, lines: [`Can't read semantic adaptation JSON: ${String(error)}`] };
|
|
1988
3188
|
}
|
|
1989
3189
|
}
|
|
1990
|
-
|
|
3190
|
+
let templateStart = resume !== undefined || opts.requestedSeconds !== undefined
|
|
3191
|
+
|| opts.picturesPerScene !== undefined || opts.productId !== undefined
|
|
3192
|
+
|| opts.elementsInput !== undefined || opts.voicesInput !== undefined || templateIntent !== undefined || hasPreparationConsent;
|
|
3193
|
+
const templateMenuPath = `${SCRIPT_RUNS_PATH}?door=template`;
|
|
3194
|
+
let templateDefaultStyle;
|
|
3195
|
+
const listed = await deps.get(templateStart ? templateMenuPath : SCRIPT_RUNS_PATH).catch(() => null);
|
|
3196
|
+
if (templateStart && !listed?.ok) {
|
|
3197
|
+
return listed
|
|
3198
|
+
? errorResult(listed, opts.json)
|
|
3199
|
+
: adminOnlyResult("Template preflight could not be read. Nothing has started.", opts.json);
|
|
3200
|
+
}
|
|
1991
3201
|
if (listed?.ok) {
|
|
1992
|
-
|
|
3202
|
+
let options = scriptRunOptionsOf(listed.data, templateStart ? "template" : "script");
|
|
1993
3203
|
if (!options) {
|
|
1994
|
-
return adminOnlyResult(
|
|
3204
|
+
return adminOnlyResult(templateStart
|
|
3205
|
+
? "This server did not publish a readable template menu. Nothing has started."
|
|
3206
|
+
: "The server's list of kinds and looks could not be read.", opts.json);
|
|
3207
|
+
}
|
|
3208
|
+
if (!templateStart && !options.conceits.some((row) => row.key === opts.conceit)) {
|
|
3209
|
+
const templates = await deps.get(templateMenuPath).catch(() => null);
|
|
3210
|
+
const offered = templates?.ok ? scriptRunOptionsOf(templates.data, "template") : null;
|
|
3211
|
+
if (offered?.conceits.some((row) => row.key === opts.conceit)) {
|
|
3212
|
+
options = offered;
|
|
3213
|
+
templateStart = true;
|
|
3214
|
+
}
|
|
1995
3215
|
}
|
|
1996
3216
|
const problem = scriptRunPickProblem(options, opts.conceit, opts.style);
|
|
3217
|
+
if (opts.writerBrief && !options.conceits.some((row) => row.key === opts.conceit)) {
|
|
3218
|
+
const line = `${TEMPLATE_WRITER_BRIEF_USAGE} ${problem}`;
|
|
3219
|
+
return opts.json ? adminOnlyResult(line, true) : { code: 1, usage: true, lines: [line] };
|
|
3220
|
+
}
|
|
1997
3221
|
if (problem) {
|
|
1998
3222
|
return opts.json ? adminOnlyResult(problem, true) : { code: 1, lines: [problem], usage: true };
|
|
1999
3223
|
}
|
|
3224
|
+
if (templateStart) {
|
|
3225
|
+
templateDefaultStyle = options.conceits.find((row) => row.key === opts.conceit)?.style?.slug;
|
|
3226
|
+
}
|
|
3227
|
+
}
|
|
3228
|
+
if (templateStart) {
|
|
3229
|
+
if (opts.reviewStoryboard !== true) {
|
|
3230
|
+
return adminOnlyResult("Template preparation requires storyboard review; do not combine it with --one-shot. Nothing has started.", opts.json);
|
|
3231
|
+
}
|
|
3232
|
+
if (opts.rewriteToFit && resume === undefined) {
|
|
3233
|
+
return adminOnlyResult("A template rewrite needs a previously reviewed --resume-script response. Review the initial script before quoting a rewrite. Nothing has started.", opts.json);
|
|
3234
|
+
}
|
|
3235
|
+
stopAtScript ||= resume === undefined || opts.rewriteToFit === true;
|
|
3236
|
+
}
|
|
3237
|
+
let baseBrief = suppliedBrief === undefined ? resume?.templateBrief : {
|
|
3238
|
+
...resume?.templateBrief,
|
|
3239
|
+
...(suppliedBrief.cards !== undefined ? { cards: { ...resume?.templateBrief?.cards, ...suppliedBrief.cards } } : {}),
|
|
3240
|
+
...(suppliedBrief.settings !== undefined ? { settings: { ...resume?.templateBrief?.settings, ...suppliedBrief.settings } } : {}),
|
|
3241
|
+
};
|
|
3242
|
+
if (templateIntent && baseBrief) {
|
|
3243
|
+
const cards = withoutBlankTemplatePins(baseBrief.cards);
|
|
3244
|
+
const settings = withoutBlankTemplatePins(baseBrief.settings);
|
|
3245
|
+
if (cards !== baseBrief.cards || settings !== baseBrief.settings) {
|
|
3246
|
+
baseBrief = { ...(cards !== undefined ? { cards } : {}), ...(settings !== undefined ? { settings } : {}) };
|
|
3247
|
+
}
|
|
2000
3248
|
}
|
|
2001
|
-
const
|
|
3249
|
+
const hasBriefOverrides = opts.requestedSeconds !== undefined || opts.picturesPerScene !== undefined;
|
|
3250
|
+
let templateBrief = hasBriefOverrides
|
|
3251
|
+
? {
|
|
3252
|
+
...baseBrief,
|
|
3253
|
+
settings: {
|
|
3254
|
+
...baseBrief?.settings,
|
|
3255
|
+
...(opts.requestedSeconds !== undefined ? { planningSeconds: opts.requestedSeconds } : {}),
|
|
3256
|
+
...(opts.picturesPerScene !== undefined ? { sceneFrameCandidates: opts.picturesPerScene } : {}),
|
|
3257
|
+
},
|
|
3258
|
+
}
|
|
3259
|
+
: baseBrief;
|
|
3260
|
+
if (templateIntent && (opts.style !== templateDefaultStyle || templateBrief?.cards?.style !== undefined)) {
|
|
3261
|
+
templateBrief = { ...templateBrief, cards: { ...templateBrief?.cards, style: opts.style } };
|
|
3262
|
+
}
|
|
3263
|
+
else if (templateDefaultStyle !== undefined
|
|
3264
|
+
&& (opts.style !== templateDefaultStyle || templateBrief?.cards?.style !== undefined)) {
|
|
3265
|
+
const cards = { ...templateBrief?.cards };
|
|
3266
|
+
delete cards.style;
|
|
3267
|
+
if (opts.style !== templateDefaultStyle)
|
|
3268
|
+
cards.style = opts.style;
|
|
3269
|
+
templateBrief = {
|
|
3270
|
+
...(Object.keys(cards).length > 0 ? { cards } : {}),
|
|
3271
|
+
...(templateBrief?.settings !== undefined ? { settings: templateBrief.settings } : {}),
|
|
3272
|
+
};
|
|
3273
|
+
if (Object.keys(templateBrief).length === 0)
|
|
3274
|
+
templateBrief = undefined;
|
|
3275
|
+
}
|
|
3276
|
+
const productId = opts.productId ?? resume?.productId;
|
|
3277
|
+
const videoModel = opts.videoModel ?? resume?.videoModel;
|
|
3278
|
+
const voices = {
|
|
3279
|
+
voiceMode: opts.voiceMode ?? resume?.voiceMode,
|
|
3280
|
+
voicePath: opts.voicePath ?? resume?.voicePath,
|
|
3281
|
+
};
|
|
3282
|
+
const direction = opts.direction ?? (templateIntent ? resume?.direction : undefined);
|
|
3283
|
+
if (resume?.templateIntent && !stopAtScript && (script !== resume.reviewedScript
|
|
3284
|
+
|| !sameJsonValue(templateIntent, resume.templateIntent)
|
|
3285
|
+
|| !sameTemplateBrief(templateBrief, resume.templateBrief)
|
|
3286
|
+
|| videoModel !== resume.videoModel || voices.voiceMode !== resume.voiceMode || voices.voicePath !== resume.voicePath
|
|
3287
|
+
|| direction !== resume.direction
|
|
3288
|
+
|| music !== resume.music || !sameJsonValue(shots, resume.shots)
|
|
3289
|
+
|| (!(opts.quotePreparation || opts.authorizePreparationFile)
|
|
3290
|
+
&& (!sameJsonValue(songControls, resume.songControls) || !sameJsonValue(mechanismPlan, resume.mechanismPlan)))
|
|
3291
|
+
|| !sameJsonValue(sourceRecord, resume.sourceRecord)
|
|
3292
|
+
|| !sameJsonValue(adaptationPlan, resume.adaptationPlan))) {
|
|
3293
|
+
return adminOnlyResult("The script or template context changed after review. Keep the original source and edited script. Resume with --stop-at-script --json, review the exact returned text and context, then resume that new response without --stop-at-script. Nothing has started.", opts.json);
|
|
3294
|
+
}
|
|
3295
|
+
const selections = {
|
|
3296
|
+
...(elements?.length ? { elements } : {}),
|
|
3297
|
+
...(selectedVoices && Object.keys(selectedVoices).length ? { voices: selectedVoices } : {}),
|
|
3298
|
+
};
|
|
3299
|
+
const body = {
|
|
2002
3300
|
script,
|
|
2003
3301
|
conceit: opts.conceit,
|
|
2004
3302
|
style: opts.style,
|
|
2005
|
-
...(
|
|
2006
|
-
...(
|
|
2007
|
-
...(
|
|
2008
|
-
...(
|
|
2009
|
-
...(
|
|
3303
|
+
...(direction ? { direction } : {}),
|
|
3304
|
+
...(voices.voicePath !== undefined ? { voicePath: voices.voicePath } : {}),
|
|
3305
|
+
...(videoModel !== undefined ? { videoModel } : {}),
|
|
3306
|
+
...(voices.voiceMode !== undefined ? { voiceMode: voices.voiceMode } : {}),
|
|
3307
|
+
...(templateIntent ? (music !== undefined ? { music } : {}) : music === true ? { music: true } : {}),
|
|
2010
3308
|
...(opts.reviewStoryboard ? { reviewStoryboard: true } : {}),
|
|
2011
3309
|
...(opts.director ? { director: true } : {}),
|
|
2012
3310
|
...(opts.broll ? { broll: true } : {}),
|
|
2013
|
-
...(
|
|
2014
|
-
...(
|
|
3311
|
+
...(shots ? { shots } : {}),
|
|
3312
|
+
...(templateIntent && songControls !== undefined ? { songControls } : {}),
|
|
3313
|
+
...(templateIntent && mechanismPlan !== undefined ? { mechanismPlan } : {}),
|
|
3314
|
+
...(stopAtScript ? { stopAtScript: true } : {}),
|
|
2015
3315
|
...(opts.rewriteToFit ? { rewriteToFit: true } : {}),
|
|
2016
3316
|
...(sourceRecord !== undefined ? { sourceRecord } : {}),
|
|
2017
3317
|
...(adaptationPlan !== undefined ? { adaptationPlan } : {}),
|
|
2018
|
-
|
|
3318
|
+
...(resume ? { approvedSource: resume.approvedSource, scriptApproval: resume.scriptApproval } : {}),
|
|
3319
|
+
...(templateIntent !== undefined ? { templateIntent } : {}),
|
|
3320
|
+
...(templateIntent !== undefined && resume === undefined && !opts.keepOriginal
|
|
3321
|
+
&& (opts.describe || opts.adaptationIntent !== undefined) ? { describe: true } : {}),
|
|
3322
|
+
...(templateStart && templateBrief !== undefined ? { templateBrief } : {}),
|
|
3323
|
+
...(templateStart && productId !== undefined ? { productId } : {}),
|
|
3324
|
+
...selections,
|
|
3325
|
+
};
|
|
3326
|
+
let intentResolution;
|
|
3327
|
+
if (templateIntent) {
|
|
3328
|
+
const resolution = await templateResolutionFlow(opts.conceit, templateIntent, templateBrief, { ...voices, videoModel, json: opts.json, songControls }, deps);
|
|
3329
|
+
if (resolution.kind === "result")
|
|
3330
|
+
return resolution.result;
|
|
3331
|
+
intentResolution = resolution.value;
|
|
3332
|
+
}
|
|
3333
|
+
if (templateStart) {
|
|
3334
|
+
const preparation = await preparationFlow(stopAtScript ? "script" : "storyboard", preparationInputOf(body, stopAtScript ? "script" : "storyboard"), opts, deps, intentResolution, resume?.templateIntent && !stopAtScript ? resume : undefined);
|
|
3335
|
+
if (preparation.kind === "result")
|
|
3336
|
+
return preparation.result;
|
|
3337
|
+
body.preparationAuthorization = preparation.authorization;
|
|
3338
|
+
songControls = isRecord(preparation.canonicalInput.songControls) ? preparation.canonicalInput.songControls : undefined;
|
|
3339
|
+
mechanismPlan = isRecord(preparation.canonicalInput.mechanismPlan) ? preparation.canonicalInput.mechanismPlan : undefined;
|
|
3340
|
+
if (songControls === undefined)
|
|
3341
|
+
delete body.songControls;
|
|
3342
|
+
else
|
|
3343
|
+
body.songControls = songControls;
|
|
3344
|
+
if (mechanismPlan === undefined)
|
|
3345
|
+
delete body.mechanismPlan;
|
|
3346
|
+
else
|
|
3347
|
+
body.mechanismPlan = mechanismPlan;
|
|
3348
|
+
}
|
|
3349
|
+
const res = await deps.post(SCRIPT_RUNS_PATH, body);
|
|
2019
3350
|
if (!res.ok)
|
|
2020
3351
|
return scriptNeedsCallerResult(res, opts.json) ?? scriptStartRefused(res, opts.json);
|
|
2021
3352
|
if (isRecord(res.data) && res.data.stoppedAtScript === true) {
|
|
2022
|
-
return stoppedAtScriptResult(res.data, opts.json);
|
|
3353
|
+
return stoppedAtScriptResult(res.data, opts.json, templateStart || scriptResumeOf(res.data) !== null, voices, selections, templateIntent, { templateBrief, productId, videoModel, direction, music, shots, songControls, mechanismPlan, sourceRecord, adaptationPlan }, intentResolution);
|
|
3354
|
+
}
|
|
3355
|
+
if (templateStart && stopAtScript) {
|
|
3356
|
+
return adminOnlyResult("The server did not return the requested script-review stop. Do not retry automatically; inspect the response/server run before continuing.", opts.json);
|
|
2023
3357
|
}
|
|
2024
3358
|
const customerStart = customerAnswer(res.data);
|
|
2025
3359
|
if (customerStart)
|
|
@@ -2154,6 +3488,10 @@ export async function waitFlow(runId, opts, deps) {
|
|
|
2154
3488
|
continue;
|
|
2155
3489
|
}
|
|
2156
3490
|
let items = null;
|
|
3491
|
+
if (stop.at === "pilot") {
|
|
3492
|
+
const itemsRes = await deps.get(`${ITEMS_PATH}?runId=${encodeURIComponent(runId)}`);
|
|
3493
|
+
items = itemsRes.ok ? (itemsRes.data.items ?? []) : null;
|
|
3494
|
+
}
|
|
2157
3495
|
if (stop.at === "final-watch") {
|
|
2158
3496
|
const itemsRes = await deps.get(`${ITEMS_PATH}?runId=${encodeURIComponent(runId)}`);
|
|
2159
3497
|
items = itemsRes.ok ? (itemsRes.data.items ?? []) : null;
|
|
@@ -2166,7 +3504,7 @@ export async function waitFlow(runId, opts, deps) {
|
|
|
2166
3504
|
continue;
|
|
2167
3505
|
}
|
|
2168
3506
|
}
|
|
2169
|
-
const resolved = resolveStop(stop, items ? hasAttachedCut(items) : null);
|
|
3507
|
+
const resolved = resolveStop(stop, items ? hasAttachedCut(items) : null, items);
|
|
2170
3508
|
if (opts.json) {
|
|
2171
3509
|
return {
|
|
2172
3510
|
code: stop.at === "failed" ? 1 : 0,
|
|
@@ -2223,7 +3561,7 @@ export async function statusFlow(runId, json, deps) {
|
|
|
2223
3561
|
return errorResult(itemsRes, json);
|
|
2224
3562
|
const items = itemsRes.data.items ?? [];
|
|
2225
3563
|
const hasFinal = hasAttachedCut(items);
|
|
2226
|
-
const stop = resolveStop(classifyRun(run), hasFinal);
|
|
3564
|
+
const stop = resolveStop(classifyRun(run), hasFinal, items);
|
|
2227
3565
|
const failedStoryboard = failedStoryboardNode(run);
|
|
2228
3566
|
const guidance = stopLines(stop.at === "failed" && errorEchoesReasons(stop.error, failedStoryboard?.planFailure)
|
|
2229
3567
|
? { ...stop, error: undefined }
|
|
@@ -2701,6 +4039,203 @@ export async function approveFlow(runId, opts, deps) {
|
|
|
2701
4039
|
],
|
|
2702
4040
|
};
|
|
2703
4041
|
}
|
|
4042
|
+
function shellWord(word) {
|
|
4043
|
+
return /^[\w.:-]+$/.test(word) ? word : `'${word.replace(/'/g, "'\\''")}'`;
|
|
4044
|
+
}
|
|
4045
|
+
function placeName(place) {
|
|
4046
|
+
return place.word ?? place.place;
|
|
4047
|
+
}
|
|
4048
|
+
function pickCommand(runId, view) {
|
|
4049
|
+
const parts = view.open.map((slot) => {
|
|
4050
|
+
const [kind, ...rest] = slot.split(":");
|
|
4051
|
+
const name = shellWord(rest.join(":"));
|
|
4052
|
+
if (kind === "style")
|
|
4053
|
+
return "--style <key>";
|
|
4054
|
+
return `--${kind} ${name}=<n>`;
|
|
4055
|
+
});
|
|
4056
|
+
return `exodus video pick ${runId} ${parts.join(" ")}`.trimEnd();
|
|
4057
|
+
}
|
|
4058
|
+
export function picksLines(view, runId, runUrl) {
|
|
4059
|
+
const options = view.options;
|
|
4060
|
+
if (!options) {
|
|
4061
|
+
return [
|
|
4062
|
+
`Run ${runId} has no picks to choose from yet. It draws them before its storyboard.`,
|
|
4063
|
+
`Check back with: exodus video status ${runId}`,
|
|
4064
|
+
];
|
|
4065
|
+
}
|
|
4066
|
+
if (view.pickedAt !== null) {
|
|
4067
|
+
const chosen = [
|
|
4068
|
+
...(view.choice?.faces ?? []).map((f) => `${f.who} face ${f.n}`),
|
|
4069
|
+
...(view.choice?.voices ?? []).map((v) => `${v.who} voice ${v.label ?? v.voiceId}`),
|
|
4070
|
+
...(view.choice?.rooms ?? []).map((r) => {
|
|
4071
|
+
const place = options.places.find((p) => p.place === r.place);
|
|
4072
|
+
return `${(place ? placeName(place) : r.place).toUpperCase()} room ${r.n}`;
|
|
4073
|
+
}),
|
|
4074
|
+
...(view.choice?.style ? [`style ${view.choice.style}`] : []),
|
|
4075
|
+
];
|
|
4076
|
+
return [
|
|
4077
|
+
`Run ${runId} has its picks${chosen.length ? `: ${chosen.join(", ")}` : ""}.`,
|
|
4078
|
+
`Follow it: exodus video status ${runId}`,
|
|
4079
|
+
];
|
|
4080
|
+
}
|
|
4081
|
+
if (view.redoing) {
|
|
4082
|
+
return [
|
|
4083
|
+
`Run ${runId} is drawing new options for ${view.redoing}.`,
|
|
4084
|
+
`Check back with: exodus video picks ${runId}`,
|
|
4085
|
+
];
|
|
4086
|
+
}
|
|
4087
|
+
if (!view.parked) {
|
|
4088
|
+
return [`Run ${runId} isn't waiting for picks right now.`, `See where it is: exodus video status ${runId}`];
|
|
4089
|
+
}
|
|
4090
|
+
const chosenFace = (who) => view.choice?.faces.find((f) => f.who === who)?.n;
|
|
4091
|
+
const chosenVoice = (who) => view.choice?.voices.find((v) => v.who === who);
|
|
4092
|
+
const chosenRoom = (place) => view.choice?.rooms.find((r) => r.place === place)?.n;
|
|
4093
|
+
const mark = (yes) => (yes ? " (picked)" : "");
|
|
4094
|
+
const lines = [`Run ${runId} is waiting for your picks.`, `See the pictures and hear the voices: ${runUrl}`, ""];
|
|
4095
|
+
for (const person of options.people) {
|
|
4096
|
+
lines.push(`${person.who} (speaks ${person.lines} ${person.lines === 1 ? "line" : "lines"})`);
|
|
4097
|
+
const modelWidth = Math.max(0, ...person.faces.map((f) => f.model.length));
|
|
4098
|
+
for (const face of person.faces) {
|
|
4099
|
+
lines.push(` face ${face.n} ${face.model.padEnd(modelWidth)} ${face.imageUrl ?? "(no link yet)"}${mark(chosenFace(person.who) === face.n)}`);
|
|
4100
|
+
}
|
|
4101
|
+
if (person.voices.length === 0) {
|
|
4102
|
+
lines.push(" voice: this run's video model casts the voice itself from the script, so there is none to pick.");
|
|
4103
|
+
}
|
|
4104
|
+
const nameWidth = Math.max(0, ...person.voices.map((v) => v.name.length));
|
|
4105
|
+
const voice = chosenVoice(person.who);
|
|
4106
|
+
for (const option of person.voices) {
|
|
4107
|
+
lines.push(` voice ${option.n} ${option.name.padEnd(nameWidth)} ${option.sampleUrl ?? "(no sample link)"}${mark(voice?.voiceId === option.voiceId)}`);
|
|
4108
|
+
}
|
|
4109
|
+
if (voice && !person.voices.some((o) => o.voiceId === voice.voiceId)) {
|
|
4110
|
+
lines.push(` voice: ${voice.label ?? voice.voiceId} (picked)`);
|
|
4111
|
+
}
|
|
4112
|
+
}
|
|
4113
|
+
for (const place of options.places) {
|
|
4114
|
+
const from = place.from === "terrain" ? " (the script names no place, so this is the format's own)" : "";
|
|
4115
|
+
lines.push(`${placeName(place).toUpperCase()}${from}`);
|
|
4116
|
+
lines.push(` ${place.rooms.map((room) => `room ${room.n} ${room.imageUrl ?? "(no link yet)"}${mark(chosenRoom(place.place) === room.n)}`).join(" ")}`);
|
|
4117
|
+
}
|
|
4118
|
+
if (options.styles?.length) {
|
|
4119
|
+
lines.push("STYLE");
|
|
4120
|
+
const width = Math.max(...options.styles.map((key) => key.length));
|
|
4121
|
+
for (const key of options.styles) {
|
|
4122
|
+
const card = view.styleCards?.[key];
|
|
4123
|
+
const about = card ? `${card.title}. ${card.slots.camera}` : "";
|
|
4124
|
+
lines.push(` ${key.padEnd(width)} ${about}${mark(view.choice?.style === key)}`.trimEnd());
|
|
4125
|
+
}
|
|
4126
|
+
}
|
|
4127
|
+
if (view.mapNote)
|
|
4128
|
+
lines.push("MAP", ` ${view.mapNote}`);
|
|
4129
|
+
lines.push("");
|
|
4130
|
+
if (view.choice)
|
|
4131
|
+
lines.push(`Still open: ${view.open.join(", ")}`);
|
|
4132
|
+
lines.push(`Pick with: ${pickCommand(runId, view)}`);
|
|
4133
|
+
lines.push(`New options for one face or room: exodus video picks ${runId} --redo face:<who> --note "<what to change>"`);
|
|
4134
|
+
return lines;
|
|
4135
|
+
}
|
|
4136
|
+
export async function picksFlow(runId, json, deps) {
|
|
4137
|
+
const res = await deps.get(`${PICKS_PATH}?runId=${encodeURIComponent(runId)}`);
|
|
4138
|
+
if (!res.ok)
|
|
4139
|
+
return errorResult(res, json);
|
|
4140
|
+
const view = res.data;
|
|
4141
|
+
if (json)
|
|
4142
|
+
return { code: 0, lines: [JSON.stringify(view, null, 2)] };
|
|
4143
|
+
return { code: 0, lines: picksLines(view, runId, reviewUrl(deps.dashboardUrl, { _id: runId })) };
|
|
4144
|
+
}
|
|
4145
|
+
export function parsePickFlags(occurrences) {
|
|
4146
|
+
const request = { faces: [], voices: [], rooms: [], moves: [] };
|
|
4147
|
+
for (const { flag, value } of occurrences) {
|
|
4148
|
+
if (!["face", "voice", "room", "move", "style", "note"].includes(flag))
|
|
4149
|
+
continue;
|
|
4150
|
+
if (value === undefined || !value.trim())
|
|
4151
|
+
return { ok: false, line: `--${flag} needs a value.` };
|
|
4152
|
+
if (flag === "style") {
|
|
4153
|
+
request.style = value.trim();
|
|
4154
|
+
continue;
|
|
4155
|
+
}
|
|
4156
|
+
if (flag === "note") {
|
|
4157
|
+
request.note = value.trim();
|
|
4158
|
+
continue;
|
|
4159
|
+
}
|
|
4160
|
+
const eq = value.lastIndexOf("=");
|
|
4161
|
+
const name = eq > 0 ? value.slice(0, eq).trim() : "";
|
|
4162
|
+
const picked = eq > 0 ? value.slice(eq + 1).trim() : "";
|
|
4163
|
+
if (!name || !picked) {
|
|
4164
|
+
const shape = flag === "move" ? "<who>=<x>,<y>" : flag === "voice" ? "<who>=<n|voice name|voice id>" : flag === "room" ? "<place>=<n>" : "<who>=<n>";
|
|
4165
|
+
return { ok: false, line: `--${flag} must look like ${shape} (got "${value}").` };
|
|
4166
|
+
}
|
|
4167
|
+
if (flag === "voice") {
|
|
4168
|
+
request.voices.push({ who: name, voice: picked });
|
|
4169
|
+
continue;
|
|
4170
|
+
}
|
|
4171
|
+
if (flag === "move") {
|
|
4172
|
+
const [x, y, ...extra] = picked.split(",").map((part) => Number(part.trim()));
|
|
4173
|
+
if (extra.length > 0 || !Number.isFinite(x) || !Number.isFinite(y)) {
|
|
4174
|
+
return { ok: false, line: `--move ${name} needs metres as <x>,<y>, for example --move ${shellWord(name)}=1.25,2 (got "${picked}").` };
|
|
4175
|
+
}
|
|
4176
|
+
request.moves.push({ who: name, x, y });
|
|
4177
|
+
continue;
|
|
4178
|
+
}
|
|
4179
|
+
const n = Number(picked);
|
|
4180
|
+
if (!Number.isInteger(n) || n < 1) {
|
|
4181
|
+
return { ok: false, line: `--${flag} ${name}=${picked}: the option is a whole number from 1, as exodus video picks prints it.` };
|
|
4182
|
+
}
|
|
4183
|
+
if (flag === "face")
|
|
4184
|
+
request.faces.push({ who: name, n });
|
|
4185
|
+
else
|
|
4186
|
+
request.rooms.push({ place: name, n });
|
|
4187
|
+
}
|
|
4188
|
+
const any = request.faces.length + request.voices.length + request.rooms.length + request.moves.length > 0 || request.style !== undefined;
|
|
4189
|
+
if (!any) {
|
|
4190
|
+
return { ok: false, line: "video pick needs at least one --face <who>=<n>, --voice <who>=<n>, --room <place>=<n> or --style <key>." };
|
|
4191
|
+
}
|
|
4192
|
+
return { ok: true, request };
|
|
4193
|
+
}
|
|
4194
|
+
export async function pickFlow(runId, request, json, deps) {
|
|
4195
|
+
const res = await deps.post(PICKS_PATH, {
|
|
4196
|
+
runId,
|
|
4197
|
+
...(request.faces.length ? { faces: request.faces } : {}),
|
|
4198
|
+
...(request.voices.length ? { voices: request.voices } : {}),
|
|
4199
|
+
...(request.rooms.length ? { rooms: request.rooms } : {}),
|
|
4200
|
+
...(request.moves.length ? { moves: request.moves } : {}),
|
|
4201
|
+
...(request.style !== undefined ? { style: request.style } : {}),
|
|
4202
|
+
...(request.note !== undefined ? { note: request.note } : {}),
|
|
4203
|
+
});
|
|
4204
|
+
if (!res.ok)
|
|
4205
|
+
return errorResult(res, json);
|
|
4206
|
+
const receipt = res.data;
|
|
4207
|
+
if (json)
|
|
4208
|
+
return { code: 0, lines: [JSON.stringify({ ok: true, runId, ...receipt })] };
|
|
4209
|
+
if (receipt.done) {
|
|
4210
|
+
return {
|
|
4211
|
+
code: 0,
|
|
4212
|
+
lines: [`Picked. Run ${runId} goes on and plans its storyboard on your picks.`, `Follow it: exodus video status ${runId}`],
|
|
4213
|
+
};
|
|
4214
|
+
}
|
|
4215
|
+
return {
|
|
4216
|
+
code: 0,
|
|
4217
|
+
lines: [
|
|
4218
|
+
`Saved. Still open: ${receipt.open.join(", ")}.`,
|
|
4219
|
+
"Nothing starts until every slot has a pick.",
|
|
4220
|
+
`See the options: exodus video picks ${runId}`,
|
|
4221
|
+
],
|
|
4222
|
+
};
|
|
4223
|
+
}
|
|
4224
|
+
export async function redoPicksFlow(runId, slot, note, json, deps) {
|
|
4225
|
+
const res = await deps.post(PICKS_PATH, { runId, redo: slot, ...(note !== undefined ? { note } : {}) });
|
|
4226
|
+
if (!res.ok)
|
|
4227
|
+
return errorResult(res, json);
|
|
4228
|
+
const data = res.data;
|
|
4229
|
+
if (json)
|
|
4230
|
+
return { code: 0, lines: [JSON.stringify({ ok: true, runId, ...data })] };
|
|
4231
|
+
return {
|
|
4232
|
+
code: 0,
|
|
4233
|
+
lines: [
|
|
4234
|
+
`Drawing four new options for ${data.slot}. The other picks stay.`,
|
|
4235
|
+
`See them when they are ready: exodus video picks ${runId}`,
|
|
4236
|
+
],
|
|
4237
|
+
};
|
|
4238
|
+
}
|
|
2704
4239
|
export async function flagFlow(runId, note, json, deps) {
|
|
2705
4240
|
const res = await deps.post(FLAG_PATH, { runId, note });
|
|
2706
4241
|
if (!res.ok)
|
|
@@ -2925,6 +4460,7 @@ export function planClipRedo(run, items, target) {
|
|
|
2925
4460
|
(row.status === "done" &&
|
|
2926
4461
|
(row.flagged === true ||
|
|
2927
4462
|
stop.at === "final-watch" ||
|
|
4463
|
+
(stop.at === "pilot" && stop.sceneIndexes.includes(target.sceneIndex)) ||
|
|
2928
4464
|
(stop.at === "running" && stop.autoRedoScenes !== undefined)));
|
|
2929
4465
|
if (!redoable) {
|
|
2930
4466
|
if (row.status === "done") {
|
|
@@ -4067,17 +5603,24 @@ export async function reviewFlow(runId, opts, deps) {
|
|
|
4067
5603
|
}
|
|
4068
5604
|
async function readSongListen(runId, deps) {
|
|
4069
5605
|
const res = await deps.get(`${SONG_PATH}?runId=${encodeURIComponent(runId)}`);
|
|
4070
|
-
|
|
5606
|
+
const data = res.ok ? res.data : null;
|
|
5607
|
+
return { res, song: data?.song ?? null, hold: data?.hold ?? null };
|
|
4071
5608
|
}
|
|
4072
5609
|
const SONG_NOT_ON_THIS_SERVER = "This Exodus server does not hold Song masters for approval yet.";
|
|
4073
5610
|
export async function songListenFlow(runId, json, deps) {
|
|
4074
|
-
const { res, song } = await readSongListen(runId, deps);
|
|
5611
|
+
const { res, song, hold } = await readSongListen(runId, deps);
|
|
4075
5612
|
if (missingRouteLine(res, "exodus video song"))
|
|
4076
5613
|
return { code: 1, lines: [SONG_NOT_ON_THIS_SERVER] };
|
|
4077
5614
|
if (!res.ok)
|
|
4078
5615
|
return errorResult(res, json);
|
|
4079
5616
|
if (json)
|
|
4080
|
-
return { code: 0, lines: [JSON.stringify({ runId, song })] };
|
|
5617
|
+
return { code: 0, lines: [JSON.stringify({ runId, song, ...(hold ? { hold } : {}) })] };
|
|
5618
|
+
if (hold)
|
|
5619
|
+
return { code: 0, lines: [
|
|
5620
|
+
`SONG HELD — ad run ${runId}`,
|
|
5621
|
+
` ${hold.reason}`,
|
|
5622
|
+
` No master is ready to approve. Try again on step ${hold.nodeId} to resume the retained song, not a new run.`,
|
|
5623
|
+
] };
|
|
4081
5624
|
if (!song)
|
|
4082
5625
|
return { code: 0, lines: ["This run holds no Song master yet, so there is nothing to listen to."] };
|
|
4083
5626
|
const heard = song.coverage.status === "full" ? "every lyric line heard" : `lyric ${song.coverage.status}${song.coverage.unheardLines.length ? `; no word heard on line ${song.coverage.unheardLines.map((n) => n + 1).join(", ")}` : ""}`;
|
|
@@ -4098,11 +5641,13 @@ export async function songListenFlow(runId, json, deps) {
|
|
|
4098
5641
|
};
|
|
4099
5642
|
}
|
|
4100
5643
|
export async function songApproveFlow(runId, masterSha256, json, deps) {
|
|
4101
|
-
const { res, song } = await readSongListen(runId, deps);
|
|
5644
|
+
const { res, song, hold } = await readSongListen(runId, deps);
|
|
4102
5645
|
if (missingRouteLine(res, "exodus video song approve"))
|
|
4103
5646
|
return { code: 1, lines: [SONG_NOT_ON_THIS_SERVER] };
|
|
4104
5647
|
if (!res.ok)
|
|
4105
5648
|
return errorResult(res, json);
|
|
5649
|
+
if (hold)
|
|
5650
|
+
return { code: 1, lines: [`No Song master is ready to approve: ${hold.reason}`] };
|
|
4106
5651
|
if (!song)
|
|
4107
5652
|
return { code: 1, lines: ["This run holds no Song master yet, so there is nothing to approve."] };
|
|
4108
5653
|
if (song.identity.masterSha256 !== masterSha256) {
|
|
@@ -4191,6 +5736,25 @@ const VALUE_FLAGS = new Set([
|
|
|
4191
5736
|
"pacing",
|
|
4192
5737
|
"source-record",
|
|
4193
5738
|
"adaptation-plan",
|
|
5739
|
+
"resume-script",
|
|
5740
|
+
"requested-seconds",
|
|
5741
|
+
"pictures-per-scene",
|
|
5742
|
+
"product",
|
|
5743
|
+
"product-context",
|
|
5744
|
+
"audience",
|
|
5745
|
+
"offer",
|
|
5746
|
+
"mechanism",
|
|
5747
|
+
"elements",
|
|
5748
|
+
"voices",
|
|
5749
|
+
"input-mode",
|
|
5750
|
+
"structure",
|
|
5751
|
+
"reference",
|
|
5752
|
+
"subject",
|
|
5753
|
+
"adapt",
|
|
5754
|
+
"template-brief",
|
|
5755
|
+
"song-controls",
|
|
5756
|
+
"mechanism-plan",
|
|
5757
|
+
"authorize-preparation",
|
|
4194
5758
|
"note",
|
|
4195
5759
|
"out",
|
|
4196
5760
|
"file",
|
|
@@ -4206,6 +5770,10 @@ const VALUE_FLAGS = new Set([
|
|
|
4206
5770
|
"lyric",
|
|
4207
5771
|
"rights",
|
|
4208
5772
|
"request-quote",
|
|
5773
|
+
"face",
|
|
5774
|
+
"room",
|
|
5775
|
+
"move",
|
|
5776
|
+
"redo",
|
|
4209
5777
|
]);
|
|
4210
5778
|
export function parsePositional(args = process.argv.slice(3)) {
|
|
4211
5779
|
const out = [];
|
|
@@ -4249,6 +5817,12 @@ export async function run(flags, occurrences) {
|
|
|
4249
5817
|
if (sub === "shows")
|
|
4250
5818
|
return printResult(await showsFlow(json, defaultDeps));
|
|
4251
5819
|
if (sub === "start") {
|
|
5820
|
+
if (occurrences.some(({ flag }) => flag === "input-options")) {
|
|
5821
|
+
const options = await templateInputOptionsFlow(occurrences, json, defaultDeps);
|
|
5822
|
+
if (options.usage)
|
|
5823
|
+
usage(options.lines[0] ?? "");
|
|
5824
|
+
return printResult(options);
|
|
5825
|
+
}
|
|
4252
5826
|
const plan = planVideoStart(flags, occurrences);
|
|
4253
5827
|
if (plan.kind === "usage")
|
|
4254
5828
|
usage(plan.line);
|
|
@@ -4285,6 +5859,8 @@ export async function run(flags, occurrences) {
|
|
|
4285
5859
|
"review",
|
|
4286
5860
|
"song",
|
|
4287
5861
|
"quote",
|
|
5862
|
+
"picks",
|
|
5863
|
+
"pick",
|
|
4288
5864
|
];
|
|
4289
5865
|
if (sub === "voices" && flags["catalog"] !== undefined && flags["catalog"] !== false) {
|
|
4290
5866
|
return printResult(await voiceCatalogFlow(runId, json, defaultDeps));
|
|
@@ -4331,6 +5907,20 @@ export async function run(flags, occurrences) {
|
|
|
4331
5907
|
}
|
|
4332
5908
|
if (sub === "storyboard")
|
|
4333
5909
|
return printResult(await storyboardFlow(runId, json, defaultDeps));
|
|
5910
|
+
if (sub === "picks") {
|
|
5911
|
+
const redo = flagString(flags, "redo");
|
|
5912
|
+
if (flags["redo"] !== undefined && !redo?.trim())
|
|
5913
|
+
usage("video picks --redo needs face:<who> or room:<place>.");
|
|
5914
|
+
if (redo)
|
|
5915
|
+
return printResult(await redoPicksFlow(runId, redo.trim(), flagString(flags, "note"), json, defaultDeps));
|
|
5916
|
+
return printResult(await picksFlow(runId, json, defaultDeps));
|
|
5917
|
+
}
|
|
5918
|
+
if (sub === "pick") {
|
|
5919
|
+
const plan = parsePickFlags(occurrences);
|
|
5920
|
+
if (!plan.ok)
|
|
5921
|
+
usage(plan.line);
|
|
5922
|
+
return printResult(await pickFlow(runId, plan.request, json, defaultDeps));
|
|
5923
|
+
}
|
|
4334
5924
|
if (sub === "director") {
|
|
4335
5925
|
const choice = parseDirectorSwitch(rest[1]);
|
|
4336
5926
|
if (!choice)
|