sovkora 0.0.0-stage → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +9 -0
- package/README.md +67 -2
- package/dist/commands/agent.command.js +267 -0
- package/dist/commands/chat.command.js +214 -0
- package/dist/commands/chat.handlers.js +150 -0
- package/dist/commands/chat.types.js +44 -0
- package/dist/commands/cinema.command.js +643 -0
- package/dist/commands/config.command.js +228 -0
- package/dist/commands/db.command.js +114 -0
- package/dist/commands/demo.command.js +55 -0
- package/dist/commands/dev.command.js +462 -0
- package/dist/commands/docs.command.js +135 -0
- package/dist/commands/doctor.command.js +119 -0
- package/dist/commands/forgot.command.js +57 -0
- package/dist/commands/generate.command.js +376 -0
- package/dist/commands/graph.command.js +54 -0
- package/dist/commands/init.command.js +380 -0
- package/dist/commands/init.steps.js +115 -0
- package/dist/commands/install.command.js +459 -0
- package/dist/commands/login.command.js +110 -0
- package/dist/commands/logs.command.js +215 -0
- package/dist/commands/logs.steps.js +130 -0
- package/dist/commands/mcp.command.js +104 -0
- package/dist/commands/models.command.js +164 -0
- package/dist/commands/onboard.command.js +236 -0
- package/dist/commands/pack.command.js +255 -0
- package/dist/commands/profile.command.js +51 -0
- package/dist/commands/recover.command.js +489 -0
- package/dist/commands/register.command.js +94 -0
- package/dist/commands/release.command.js +99 -0
- package/dist/commands/reset.command.js +79 -0
- package/dist/commands/runs.command.js +201 -0
- package/dist/commands/settings.command.js +85 -0
- package/dist/commands/start.command.js +590 -0
- package/dist/commands/status.command.js +167 -0
- package/dist/commands/stop.command.js +313 -0
- package/dist/commands/studio.command.js +266 -0
- package/dist/commands/test.command.js +134 -0
- package/dist/commands/verify.command.js +52 -0
- package/dist/commands/video.command.js +73 -0
- package/dist/commands/workspace-guard.js +72 -0
- package/dist/index.js +207 -0
- package/dist/renderers.js +250 -0
- package/dist/services/api-client.js +150 -0
- package/dist/services/auth.api.js +87 -0
- package/dist/services/chat.api.js +117 -0
- package/dist/services/cinema-estimate.json +42 -0
- package/dist/services/cinema.childsafe.js +52 -0
- package/dist/services/cinema.director.js +285 -0
- package/dist/services/cinema.production.js +417 -0
- package/dist/services/cinema.staging.js +323 -0
- package/dist/services/cinema.story.js +758 -0
- package/dist/services/cinema.treatment.js +393 -0
- package/dist/services/composer.run.js +94 -0
- package/dist/services/demo/demo.documents.js +108 -0
- package/dist/services/demo/demo.guard.js +49 -0
- package/dist/services/demo/demo.persona.js +114 -0
- package/dist/services/demo/demo.seed.js +281 -0
- package/dist/services/diagnostics.js +327 -0
- package/dist/services/image-model-recipes.json +93 -0
- package/dist/services/image-models.js +152 -0
- package/dist/services/local-store.js +145 -0
- package/dist/services/mcp.api.js +38 -0
- package/dist/services/model-catalog.js +70 -0
- package/dist/services/notify.js +55 -0
- package/dist/services/pack.api.js +23 -0
- package/dist/services/pack.bundle.js +241 -0
- package/dist/services/pack.sources.js +101 -0
- package/dist/services/release-manifest.js +266 -0
- package/dist/services/runs.view.js +80 -0
- package/dist/services/runs.wait.js +38 -0
- package/dist/services/semver.js +55 -0
- package/dist/services/settings.api.js +108 -0
- package/dist/services/string-utils.js +70 -0
- package/dist/services/studio.api.js +120 -0
- package/dist/services/templates.js +893 -0
- package/dist/services/tool-installer.js +353 -0
- package/dist/services/tool-path.js +72 -0
- package/dist/services/version-manager.js +253 -0
- package/dist/services/workspace-bootstrap.js +68 -0
- package/dist/threads.js +202 -0
- package/dist/types/api.types.js +6 -0
- package/dist/types/local.types.js +6 -0
- package/dist/ui/box.js +46 -0
- package/dist/ui/logger.js +28 -0
- package/dist/ui/platform.js +32 -0
- package/dist/ui/prompts.js +130 -0
- package/dist/ui/table.js +33 -0
- package/dist/utils/config.js +150 -0
- package/dist/utils/development-status.js +22 -0
- package/dist/utils/endpoints.js +41 -0
- package/dist/utils/health.js +94 -0
- package/dist/utils/pid.js +83 -0
- package/dist/utils/platform.js +358 -0
- package/dist/utils/process.js +139 -0
- package/dist/utils/state-dir.js +105 -0
- package/package.json +95 -4
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file cinema.production.ts
|
|
4
|
+
* @description A cinematic short as a production file (ADR-080): the script's shot list, checked once at the edge,
|
|
5
|
+
* and every pure decision the director makes from it — the keyframe and motion prompts, the seeds, the edit decision
|
|
6
|
+
* list of the cut, what runs next, and the estimate shown before anything runs.
|
|
7
|
+
*
|
|
8
|
+
* Nothing here talks to the platform: the director (cinema.director.ts) does, through ordinary Studio runs.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.KEYFRAME_NEGATIVE = exports.KIT_FINISH = exports.NO_CHILDREN = exports.keyframeSize = exports.isCharacterId = exports.CHARACTER_ID = exports.ScriptError = exports.RunState = exports.AMBIENCES = exports.TITLE_STYLES = exports.TRANSITIONS = exports.GRADES = exports.ASPECTS = exports.FORMATS = void 0;
|
|
12
|
+
exports.extractJson = extractJson;
|
|
13
|
+
exports.repairJson = repairJson;
|
|
14
|
+
exports.parseScript = parseScript;
|
|
15
|
+
exports.newProduction = newProduction;
|
|
16
|
+
exports.seedFor = seedFor;
|
|
17
|
+
exports.direction = direction;
|
|
18
|
+
exports.characterPrompt = characterPrompt;
|
|
19
|
+
exports.keyframePrompt = keyframePrompt;
|
|
20
|
+
exports.motionPrompt = motionPrompt;
|
|
21
|
+
exports.editDecisionList = editDecisionList;
|
|
22
|
+
exports.filmSeconds = filmSeconds;
|
|
23
|
+
exports.nextStep = nextStep;
|
|
24
|
+
exports.markReshoot = markReshoot;
|
|
25
|
+
exports.estimate = estimate;
|
|
26
|
+
/** The formats the script Studio knows (cinematic-script's `format` input). */
|
|
27
|
+
exports.FORMATS = ["superhero-vfx", "social-reel", "news-explainer", "trailer", "custom"];
|
|
28
|
+
exports.ASPECTS = ["9:16", "16:9"];
|
|
29
|
+
/** The cut's grades and transitions (orazaka-worker-media app/cut.py): a script naming another is corrected here. */
|
|
30
|
+
exports.GRADES = ["none", "teal-orange", "neon-night", "warm-film", "clean-news", "nordic"];
|
|
31
|
+
exports.TRANSITIONS = ["cut", "fade", "dissolve", "black", "flash", "whip", "slide", "radial", "iris"];
|
|
32
|
+
exports.TITLE_STYLES = ["hero", "kicker", "lower-third", "end"];
|
|
33
|
+
/** The cut's synthesized ambience beds (orazaka-worker-media app/cut.py AMBIENCES). */
|
|
34
|
+
exports.AMBIENCES = ["none", "rain", "storm", "wind", "city", "room", "nature"];
|
|
35
|
+
/** The state of one Studio run of the production, as the platform reported it. */
|
|
36
|
+
exports.RunState = {
|
|
37
|
+
Pending: "PENDING",
|
|
38
|
+
Running: "RUNNING",
|
|
39
|
+
Succeeded: "SUCCEEDED",
|
|
40
|
+
Failed: "FAILED",
|
|
41
|
+
};
|
|
42
|
+
class ScriptError extends Error {
|
|
43
|
+
}
|
|
44
|
+
exports.ScriptError = ScriptError;
|
|
45
|
+
/**
|
|
46
|
+
* A character's id names files on the operator's disk (`<dir>/sheets/<id>.png`), and it is written by a model (the
|
|
47
|
+
* script) or by a treatment the writer model drafted: a slug only, so no id can be a path (`../`, `/`, `\\`).
|
|
48
|
+
*/
|
|
49
|
+
exports.CHARACTER_ID = /^[A-Za-z0-9][A-Za-z0-9_-]{0,39}$/;
|
|
50
|
+
const isCharacterId = (id) => exports.CHARACTER_ID.test(id);
|
|
51
|
+
exports.isCharacterId = isCharacterId;
|
|
52
|
+
/** A value as one line of text: a string as it is, an object or list the model wrote instead as its values joined. */
|
|
53
|
+
const flatten = (value) => {
|
|
54
|
+
if (value === null || value === undefined)
|
|
55
|
+
return "";
|
|
56
|
+
if (typeof value === "object")
|
|
57
|
+
return Object.values(value).map(flatten).join(", ");
|
|
58
|
+
return String(value);
|
|
59
|
+
};
|
|
60
|
+
/** Markdown emphasis a model adds (`**bold**`, `*italic*`) is not a word of the prompt nor of a title. */
|
|
61
|
+
const text = (value, max = 1200) => flatten(value).replace(/\*+/g, "").replace(/\s+/g, " ").trim().slice(0, max);
|
|
62
|
+
const clamp = (value, low, high) => Math.min(high, Math.max(low, value));
|
|
63
|
+
const oneOf = (value, allowed, fallback) => allowed.includes(String(value)) ? String(value) : fallback;
|
|
64
|
+
/** The JSON object inside an LLM's answer: the whole text, or the first `{` to the last `}` (a fenced block). */
|
|
65
|
+
function extractJson(raw) {
|
|
66
|
+
const start = raw.indexOf("{");
|
|
67
|
+
const end = raw.lastIndexOf("}");
|
|
68
|
+
if (start < 0 || end <= start)
|
|
69
|
+
throw new ScriptError("the script holds no JSON object");
|
|
70
|
+
const body = raw.slice(start, end + 1);
|
|
71
|
+
try {
|
|
72
|
+
return JSON.parse(body);
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
// A language model's usual slip: a missing comma between two members, or a trailing one. Repaired once,
|
|
76
|
+
// then parsed; anything else is refused with the parser's own message.
|
|
77
|
+
try {
|
|
78
|
+
return JSON.parse(repairJson(body));
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
throw new ScriptError(`the script is not valid JSON (${error instanceof Error ? error.message : "parse error"})`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/** Inserts the commas a model forgot between members on separate lines, and drops trailing ones (pure). */
|
|
86
|
+
function repairJson(body) {
|
|
87
|
+
// Raw line breaks inside a string literal are not JSON: they become spaces (a walk that knows when it is in a string).
|
|
88
|
+
let inString = false;
|
|
89
|
+
let escaped = false;
|
|
90
|
+
let flat = "";
|
|
91
|
+
for (const char of body) {
|
|
92
|
+
if (inString && (char === "\n" || char === "\r" || char === "\t")) {
|
|
93
|
+
flat += " ";
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if (char === '"' && !escaped)
|
|
97
|
+
inString = !inString;
|
|
98
|
+
escaped = char === "\\" && !escaped;
|
|
99
|
+
flat += char;
|
|
100
|
+
}
|
|
101
|
+
// A bare value with units (`35mm`, `68 BPM`) is a string the model forgot to quote — looked for outside the strings only.
|
|
102
|
+
const quoted = flat
|
|
103
|
+
.split(/("(?:[^"\\]|\\.)*")/)
|
|
104
|
+
.map((part, i) => i % 2 === 1 ? part : part.replace(/:\s*(-?\d[^",\n{}[\]A-Za-z%]*[A-Za-z%][^",\n{}[\]]*)(?=[,\n}\]])/g, ': "$1"'))
|
|
105
|
+
.join("");
|
|
106
|
+
return quoted
|
|
107
|
+
.replace(/("|\}|\]|\d|true|false|null)([ \t]*(?:\n[ \t]*)+)(?=["{[])/g, "$1,$2")
|
|
108
|
+
.replace(/,(\s*[}\]])/g, "$1");
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* The script's answer, checked once: parse, don't validate. What the cut cannot make (an unknown grade or transition) is
|
|
112
|
+
* corrected to the nearest safe value; what the film cannot be made without (no shots, a shot without a keyframe) is
|
|
113
|
+
* refused. The shot count is bounded by what was asked.
|
|
114
|
+
*/
|
|
115
|
+
function parseScript(raw, brief) {
|
|
116
|
+
const data = extractJson(raw);
|
|
117
|
+
const shotsRaw = Array.isArray(data.shots) ? data.shots : [];
|
|
118
|
+
if (shotsRaw.length < 2)
|
|
119
|
+
throw new ScriptError("the script has fewer than two shots");
|
|
120
|
+
const characters = (Array.isArray(data.characters) ? data.characters : [])
|
|
121
|
+
.map((c) => ({ id: text(c?.id, 40), description: text(c?.description, 600) }))
|
|
122
|
+
.filter((c) => (0, exports.isCharacterId)(c.id) && c.description)
|
|
123
|
+
.slice(0, 6);
|
|
124
|
+
const known = new Set(characters.map((c) => c.id));
|
|
125
|
+
const shots = shotsRaw
|
|
126
|
+
.slice(0, Math.max(brief.shots, 2))
|
|
127
|
+
.map((s, i) => {
|
|
128
|
+
const keyframe = text(s?.keyframe);
|
|
129
|
+
if (!keyframe)
|
|
130
|
+
throw new ScriptError(`shot ${i + 1} has no keyframe prompt`);
|
|
131
|
+
const seconds = clamp(Number(s?.seconds) || 5, 2, 5);
|
|
132
|
+
const speed = Number(s?.speed) === 0.5 ? 0.5 : 1;
|
|
133
|
+
const ramp = s?.rampAt === null || s?.rampAt === undefined ? null : Number(s.rampAt);
|
|
134
|
+
return {
|
|
135
|
+
id: i + 1,
|
|
136
|
+
seconds,
|
|
137
|
+
characters: (Array.isArray(s?.characters) ? s.characters : [])
|
|
138
|
+
.map((c) => text(c, 40))
|
|
139
|
+
.filter((c) => known.has(c)),
|
|
140
|
+
camera: text(s?.camera, 300),
|
|
141
|
+
lens: text(s?.lens, 60),
|
|
142
|
+
lighting: text(s?.lighting, 300),
|
|
143
|
+
atmosphere: text(s?.atmosphere, 200),
|
|
144
|
+
action: text(s?.action, 500),
|
|
145
|
+
vfx: text(s?.vfx, 400),
|
|
146
|
+
keyframe,
|
|
147
|
+
motion: text(s?.motion, 800) || text(s?.action, 500),
|
|
148
|
+
transition: i === 0 ? "cut" : oneOf(s?.transition, exports.TRANSITIONS, "cut"),
|
|
149
|
+
speed,
|
|
150
|
+
// A ramp needs room on both sides of it and is never combined with a whole-shot slow motion.
|
|
151
|
+
rampAt: speed === 1 && ramp !== null && Number.isFinite(ramp) && ramp > 0.6 && ramp < seconds - 0.6 ? ramp : null,
|
|
152
|
+
caption: text(s?.caption, 140),
|
|
153
|
+
continuous: s?.continuous === true && i > 0,
|
|
154
|
+
};
|
|
155
|
+
});
|
|
156
|
+
const titles = (Array.isArray(data.titles) ? data.titles : [])
|
|
157
|
+
.map((t) => ({
|
|
158
|
+
text: text(t?.text, 120),
|
|
159
|
+
start: Math.max(0, Number(t?.start) || 0),
|
|
160
|
+
end: Math.max(0, Number(t?.end) || 0),
|
|
161
|
+
style: oneOf(t?.style, exports.TITLE_STYLES, "hero"),
|
|
162
|
+
}))
|
|
163
|
+
.filter((t) => t.text && t.end > t.start + 0.2)
|
|
164
|
+
.slice(0, 8);
|
|
165
|
+
return {
|
|
166
|
+
title: text(data.title, 120) || "Untitled",
|
|
167
|
+
logline: text(data.logline, 300),
|
|
168
|
+
grade: oneOf(data.grade, exports.GRADES, "teal-orange"),
|
|
169
|
+
style: text(data.style, 800),
|
|
170
|
+
characters,
|
|
171
|
+
music: text(data.music, 480) || "cinematic orchestral score, building tension, no vocals",
|
|
172
|
+
ambience: oneOf(data.ambience, exports.AMBIENCES, "none"),
|
|
173
|
+
voiceover: text(data.voiceover, 1800),
|
|
174
|
+
titles,
|
|
175
|
+
shots,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
/** A new, empty production for a brief. */
|
|
179
|
+
function newProduction(brief) {
|
|
180
|
+
return { version: 1, brief, characters: {}, shots: [], history: [] };
|
|
181
|
+
}
|
|
182
|
+
/** The deterministic seed of one keyframe or shot: the production's seed, the shot, the attempt (a reshoot is a new seed). */
|
|
183
|
+
function seedFor(production, shotId, attempt, salt = 0) {
|
|
184
|
+
return (production.brief.seed + shotId * 7919 + attempt * 104729 + salt * 31) % 2147483647;
|
|
185
|
+
}
|
|
186
|
+
/** The image size of a keyframe for an aspect (image-generation's `size` enum). */
|
|
187
|
+
const keyframeSize = (aspect) => (aspect === "9:16" ? "768x1360" : "1360x768");
|
|
188
|
+
exports.keyframeSize = keyframeSize;
|
|
189
|
+
const NO_TEXT = "No text, no letters, no logos, no watermark, no brand names.";
|
|
190
|
+
/** The hard rule of every film (ADR-080 v2.8): in every keyframe, character and shot prompt; checked on the takes (cinema.childsafe.ts). */
|
|
191
|
+
exports.NO_CHILDREN = "No children, no child-like figures, no dolls or toys.";
|
|
192
|
+
/** The Krizaka cinematic kit's finish, said in every picture: what makes a frame read as a film, not a render. */
|
|
193
|
+
exports.KIT_FINISH = "Shot on a cinema camera, anamorphic film look, natural skin texture, motivated lighting, filmic contrast, subtle film grain, " +
|
|
194
|
+
"high dynamic range, sharp focus on the subject, photorealistic, highly detailed";
|
|
195
|
+
function lensLine(shot) {
|
|
196
|
+
if (!shot.lens)
|
|
197
|
+
return "";
|
|
198
|
+
const lens = /mm/i.test(shot.lens) ? shot.lens : `${shot.lens}mm`;
|
|
199
|
+
return `${lens} lens`;
|
|
200
|
+
}
|
|
201
|
+
function cameraLine(shot, forMotion) {
|
|
202
|
+
if (!shot.camera)
|
|
203
|
+
return "";
|
|
204
|
+
return forMotion ? `the view: ${shot.camera.replace(/\bcamera\b/gi, "view")}` : `camera: ${shot.camera}`;
|
|
205
|
+
}
|
|
206
|
+
/** A shot's direction in one sentence: the lens, the camera, the light and the air (only what the script gave). */
|
|
207
|
+
function direction(shot, forMotion = false) {
|
|
208
|
+
return [
|
|
209
|
+
lensLine(shot),
|
|
210
|
+
// In a motion prompt the word "camera" summoned a camera into the frame (gate, 2026-10-17): the view moves instead.
|
|
211
|
+
cameraLine(shot, forMotion),
|
|
212
|
+
shot.lighting ? `lighting: ${shot.lighting}` : "",
|
|
213
|
+
shot.atmosphere ? `atmosphere: ${shot.atmosphere}` : "",
|
|
214
|
+
]
|
|
215
|
+
.filter(Boolean)
|
|
216
|
+
.join(", ");
|
|
217
|
+
}
|
|
218
|
+
/** The still of a character, first: the reference a person looks at before any shot is paid. */
|
|
219
|
+
function characterPrompt(script, character) {
|
|
220
|
+
return text(`Character reference portrait, waist up, three-quarter view, neutral studio background: ${character.description}. ` +
|
|
221
|
+
`Style: ${script.style} Original character design. ${NO_TEXT} ${exports.NO_CHILDREN}`, 1900);
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* The keyframe prompt of a shot: the shot's own first frame, then every character in it described in full, then the
|
|
225
|
+
* visual bible — the same words in every picture are what keep a face and a look from shot to shot.
|
|
226
|
+
*/
|
|
227
|
+
function keyframePrompt(script, shot, aspect) {
|
|
228
|
+
if (script.keyframeKeep) {
|
|
229
|
+
// A treatment's keyframe is directed already: its words, the cast as described, the look, its keep line.
|
|
230
|
+
const described = shot.characters
|
|
231
|
+
.map((id) => script.characters.find((c) => c.id === id)?.description)
|
|
232
|
+
.filter(Boolean)
|
|
233
|
+
.join("; ");
|
|
234
|
+
return text(`${shot.keyframe} ${described ? "Characters: " + described + ". " : ""}${script.style} ${script.keyframeKeep} ${exports.NO_CHILDREN}`, 1900);
|
|
235
|
+
}
|
|
236
|
+
const cast = shot.characters
|
|
237
|
+
.map((id) => script.characters.find((c) => c.id === id))
|
|
238
|
+
.filter((c) => Boolean(c))
|
|
239
|
+
.map((c) => `${c.id}: ${c.description}`)
|
|
240
|
+
.join(". ");
|
|
241
|
+
return text(`${shot.keyframe}. ${cast ? "" + cast + ". " : ""}${shot.vfx ? "Effects: " + shot.vfx + ". " : ""}` +
|
|
242
|
+
`Style: ${script.style} Cinematic film still, ${aspect === "9:16" ? "vertical 9:16" : "widescreen 16:9"} composition, ` +
|
|
243
|
+
`${direction(shot)}. ${exports.KIT_FINISH}. ${NO_TEXT} ${exports.NO_CHILDREN}`, 1900);
|
|
244
|
+
}
|
|
245
|
+
exports.KEYFRAME_NEGATIVE = "text, letters, caption, watermark, logo, signature, deformed hands, extra fingers, extra limbs, fused fingers, " +
|
|
246
|
+
"distorted face, plastic skin, oversaturated, cartoon, 3d render, cgi look, blurry, low quality, jpeg artifacts, " +
|
|
247
|
+
"child, children, child-like figure, doll, toy";
|
|
248
|
+
/** The motion prompt of a shot: what moves, the effects, the camera, the look. */
|
|
249
|
+
function motionPrompt(script, shot) {
|
|
250
|
+
// A treatment's motion is written in film language already (subject, action, camera, lens, light, pace): kept as is.
|
|
251
|
+
if (script.keep)
|
|
252
|
+
return text(`${shot.motion} ${script.keep} ${exports.NO_CHILDREN}`, 1900);
|
|
253
|
+
return text(`${shot.motion.replace(/\bcamera\b/gi, "view")}. ${shot.vfx ? "Visual effects: " + shot.vfx + ". " : ""}${direction(shot, true)}. ` +
|
|
254
|
+
`${script.style} Cinematic, smooth natural motion, stable faces and hands, the same characters throughout, ${NO_TEXT} ${exports.NO_CHILDREN}`, 1900);
|
|
255
|
+
}
|
|
256
|
+
/** Seconds of a 5-second clip a shot uses: Wan's first frames hold the keyframe still, so the head is trimmed. */
|
|
257
|
+
const HEAD_TRIM = 0.15;
|
|
258
|
+
const CLIP_SECONDS = 5.0;
|
|
259
|
+
const TRANSITION_SECONDS = 0.35;
|
|
260
|
+
/** The edit decision list of the cut (cinematic-cut's `edit`), from the script and the order of the shots. */
|
|
261
|
+
function editDecisionList(production, script) {
|
|
262
|
+
const shots = script.shots.map((shot, i) => {
|
|
263
|
+
const out = Math.min(CLIP_SECONDS, HEAD_TRIM + shot.seconds);
|
|
264
|
+
return {
|
|
265
|
+
clip: i,
|
|
266
|
+
in: HEAD_TRIM,
|
|
267
|
+
out: Number(out.toFixed(2)),
|
|
268
|
+
speed: shot.speed,
|
|
269
|
+
...(shot.rampAt !== null ? { rampAt: Number((HEAD_TRIM + shot.rampAt).toFixed(2)), rampSpeed: 0.4 } : {}),
|
|
270
|
+
zoom: shot.speed < 1 || shot.rampAt !== null ? 1.0 : 1.04,
|
|
271
|
+
transition: shot.transition,
|
|
272
|
+
...(shot.transition !== "cut" ? { transitionSeconds: TRANSITION_SECONDS } : {}),
|
|
273
|
+
caption: shot.caption,
|
|
274
|
+
};
|
|
275
|
+
});
|
|
276
|
+
const length = filmSeconds(script);
|
|
277
|
+
const titles = script.titles
|
|
278
|
+
.filter((t) => t.start < length - 0.5)
|
|
279
|
+
.map((t) => ({ ...t, end: Math.min(t.end, length) }));
|
|
280
|
+
// Hollywood finishing (ADR-080): every shot upscaled by SeedVR2 before the cut, the ambience bed and the hits under it.
|
|
281
|
+
return {
|
|
282
|
+
aspect: production.brief.aspect,
|
|
283
|
+
fps: 30,
|
|
284
|
+
grade: script.grade,
|
|
285
|
+
shots,
|
|
286
|
+
titles,
|
|
287
|
+
label: "AI-generated",
|
|
288
|
+
upscale: "seedvr2",
|
|
289
|
+
ambience: script.ambience,
|
|
290
|
+
sfx: true,
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
/** How long the finished film is: each shot's screen time (slow motion and ramps included) minus the overlaps. */
|
|
294
|
+
function filmSeconds(script) {
|
|
295
|
+
let total = 0;
|
|
296
|
+
script.shots.forEach((shot, i) => {
|
|
297
|
+
const screen = shot.rampAt !== null ? shot.rampAt + (shot.seconds - shot.rampAt) / 0.4 : shot.seconds / shot.speed;
|
|
298
|
+
let overlap = TRANSITION_SECONDS;
|
|
299
|
+
if (i === 0)
|
|
300
|
+
overlap = 0;
|
|
301
|
+
else if (shot.transition === "cut")
|
|
302
|
+
overlap = 1 / 30;
|
|
303
|
+
total += screen - overlap;
|
|
304
|
+
});
|
|
305
|
+
return Number(total.toFixed(2));
|
|
306
|
+
}
|
|
307
|
+
const done = (run) => run?.status === exports.RunState.Succeeded;
|
|
308
|
+
function nextStep(production) {
|
|
309
|
+
const script = production.script?.parsed;
|
|
310
|
+
if (!script || !done(production.script))
|
|
311
|
+
return { kind: "script" };
|
|
312
|
+
for (const character of script.characters) {
|
|
313
|
+
if (!done(production.characters[character.id]))
|
|
314
|
+
return { kind: "character", id: character.id };
|
|
315
|
+
}
|
|
316
|
+
for (const shot of script.shots) {
|
|
317
|
+
const state = production.shots.find((s) => s.id === shot.id);
|
|
318
|
+
if (!done(state?.keyframe) && !shot.continuous && !shot.chainFrom && !shot.reuse)
|
|
319
|
+
return { kind: "keyframe", shot: shot.id };
|
|
320
|
+
}
|
|
321
|
+
for (const shot of script.shots) {
|
|
322
|
+
const state = production.shots.find((s) => s.id === shot.id);
|
|
323
|
+
if (!done(state?.video) || state?.review === "reshoot")
|
|
324
|
+
return { kind: "video", shot: shot.id };
|
|
325
|
+
}
|
|
326
|
+
if (!done(production.cut))
|
|
327
|
+
return { kind: "cut" };
|
|
328
|
+
if (script.voiceover && !done(production.voice))
|
|
329
|
+
return { kind: "voice" };
|
|
330
|
+
if (!done(production.sound))
|
|
331
|
+
return { kind: "sound" };
|
|
332
|
+
return { kind: "done" };
|
|
333
|
+
}
|
|
334
|
+
/** Marks shots to be made again (a person's review): their video, and the cut and sound that used them, are redone. */
|
|
335
|
+
function markReshoot(production, ids, newKeyframe = false) {
|
|
336
|
+
const marked = new Set();
|
|
337
|
+
for (const id of ids) {
|
|
338
|
+
const state = production.shots.find((s) => s.id === id);
|
|
339
|
+
if (!state)
|
|
340
|
+
throw new ScriptError(`shot ${id} is not in this production`);
|
|
341
|
+
if (marked.has(id))
|
|
342
|
+
continue;
|
|
343
|
+
marked.add(id);
|
|
344
|
+
state.review = "reshoot";
|
|
345
|
+
state.attempt += 1;
|
|
346
|
+
if (newKeyframe)
|
|
347
|
+
state.keyframe = undefined;
|
|
348
|
+
}
|
|
349
|
+
// A chained shot starts from the last frame of the shot before it: when that shot is made again, its old start is
|
|
350
|
+
// gone, so the chain after it is made again too (and only the chain: a shot from its own keyframe keeps its take).
|
|
351
|
+
const shots = production.script?.parsed?.shots ?? [];
|
|
352
|
+
shots.forEach((shot, i) => {
|
|
353
|
+
let from = undefined;
|
|
354
|
+
if (shot.chainFrom)
|
|
355
|
+
from = shot.chainFrom.shot;
|
|
356
|
+
else if (shot.continuous && i > 0)
|
|
357
|
+
from = shots[i - 1].id;
|
|
358
|
+
if (from === undefined || marked.has(shot.id) || !marked.has(from))
|
|
359
|
+
return;
|
|
360
|
+
const state = production.shots.find((s) => s.id === shot.id);
|
|
361
|
+
if (!state)
|
|
362
|
+
return;
|
|
363
|
+
marked.add(shot.id);
|
|
364
|
+
state.review = "reshoot";
|
|
365
|
+
state.attempt += 1;
|
|
366
|
+
});
|
|
367
|
+
production.cut = undefined;
|
|
368
|
+
production.sound = undefined;
|
|
369
|
+
return production;
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* The estimate shown before a production runs: per step, how many runs, the Studio's own estimated credits (from the
|
|
373
|
+
* catalogue), and the measured time and GPU cost of one run. Steps already done are not counted again.
|
|
374
|
+
*/
|
|
375
|
+
function estimate(production, shotCount, credits, measures) {
|
|
376
|
+
const script = production.script?.parsed;
|
|
377
|
+
const characterCount = script ? script.characters.length : 2;
|
|
378
|
+
const shots = script ? script.shots : [];
|
|
379
|
+
const pending = (key) => script
|
|
380
|
+
? shots.filter((s) => {
|
|
381
|
+
if (key === "keyframe" && (s.continuous || s.chainFrom || s.reuse))
|
|
382
|
+
return false; // it starts from another take
|
|
383
|
+
if (key === "video" && s.reuse)
|
|
384
|
+
return false; // a kept take
|
|
385
|
+
const state = production.shots.find((x) => x.id === s.id);
|
|
386
|
+
return !done(state?.[key]) || (key === "video" && state?.review === "reshoot");
|
|
387
|
+
}).length
|
|
388
|
+
: shotCount;
|
|
389
|
+
const rows = [
|
|
390
|
+
["script", done(production.script) ? 0 : 1],
|
|
391
|
+
["character", script ? script.characters.filter((c) => !done(production.characters[c.id])).length : characterCount],
|
|
392
|
+
["keyframe", pending("keyframe")],
|
|
393
|
+
["video", pending("video")],
|
|
394
|
+
["cut", done(production.cut) ? 0 : 1],
|
|
395
|
+
["voice", (script && !script.voiceover) || done(production.voice) ? 0 : 1],
|
|
396
|
+
["sound", done(production.sound) ? 0 : 1],
|
|
397
|
+
];
|
|
398
|
+
const lines = rows.map(([step, count]) => {
|
|
399
|
+
const measure = measures[step];
|
|
400
|
+
const studio = measure?.studioKey ?? step;
|
|
401
|
+
return {
|
|
402
|
+
step,
|
|
403
|
+
count,
|
|
404
|
+
credits: count * (credits[studio] ?? 0),
|
|
405
|
+
seconds: count * (measure?.seconds ?? 0),
|
|
406
|
+
gpuUsd: Number((count * (measure?.gpuUsd ?? 0)).toFixed(2)),
|
|
407
|
+
};
|
|
408
|
+
});
|
|
409
|
+
const sum = (key) => lines.reduce((total, line) => total + line[key], 0);
|
|
410
|
+
return {
|
|
411
|
+
lines,
|
|
412
|
+
credits: sum("credits"),
|
|
413
|
+
seconds: Math.round(sum("seconds")),
|
|
414
|
+
gpuUsd: Number(sum("gpuUsd").toFixed(2)),
|
|
415
|
+
filmSeconds: script ? filmSeconds(script) : production.brief.durationSeconds,
|
|
416
|
+
};
|
|
417
|
+
}
|