@aicopycoders/exodus 2026.11.1200-beta.13 → 2026.11.1200-beta.15

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.
@@ -362,10 +362,15 @@ the run started:
362
362
 
363
363
  - **The app makes the cut** of a swiped video, a video from the dashboard's
364
364
  Video page and a beta tester's run, once every clip is made and no scene is
365
- held. On a run started with `--one-shot` that cut is delivered by itself,
365
+ held. While it makes it, `status` on an admin key says "Every piece is
366
+ made. The app makes the cut now; look again in a minute: exodus video
367
+ status <runId>": make no cut of your own, and read `status` again in a
368
+ minute. `exodus video wait <runId>` waits through it. On a run started with `--one-shot` that cut is delivered by itself,
366
369
  with no approve: on an admin key `status` then says "Final cut: approved
367
370
  and delivered.", and on a beta tester's key "Your video is ready: <link>".
368
- Only when the app's check of the finished film against its own sound fails
371
+ In the minute between the cut and the delivery, `status` on an admin key
372
+ says "Final cut: made. This run delivers it by itself; look again in a
373
+ minute.": read it again then, and send no approve. Only when the app's check of the finished film against its own sound fails
369
374
  (One-take UGC checks it) does a One-shot cut wait instead, as a Guided one
370
375
  does, with the check's sentences under it in `status`. The member's last say is before that: the One-shot yes, and the yes to keep
371
376
  the last held take, since that keep starts the cut. Say so at each. Give
@@ -388,14 +393,18 @@ it): ask approve, a new run that films every take again at its full price
388
393
  (for a swiped video, `exodus video swipe start <swipeId> --again`, its price
389
394
  first), or stop here.
390
395
 
391
- On an admin key, `pull` writes the pieces only, never the finished video,
392
- even once the app has made and delivered it: give the member the run page to
393
- watch it. On a beta tester's key, `pull` also writes `video.<ext>` once the
394
- finished video is ready.
396
+ `pull` also writes the finished video as `video.<ext>` once the run has one,
397
+ on an admin key as on a beta tester's. On a delivered run it ends "This run
398
+ is delivered. The finished video is <file>.": give the member that file and
399
+ the run page to watch it. On a run the app cuts, once every piece is made
400
+ and until it is delivered, it ends with no upload line: make no cut of your
401
+ own, unless `status` says the app's cut didn't work and offers you to cut it
402
+ yourself, and the member says yes.
395
403
 
396
404
  - Approve: `exodus video approve <runId>` makes the cut the ad. It is one-way.
397
- - Redo a clip: `retry-clip` as at stop 4, after their yes. Then pull, cut
398
- and upload again.
405
+ - Redo a clip: `retry-clip` as at stop 4, after their yes. On a run the app
406
+ cuts, it cuts again by itself (read `status`); on any other, pull, cut and
407
+ upload again.
399
408
 
400
409
  **On the song format**, tell the member this before they approve: "The song
401
410
  made here is for review. Before this video runs as a paid ad, make the same
@@ -1003,9 +1012,9 @@ every video has started:
1003
1012
  <runId>` and do what it prints. The app makes a swiped video's cut ("End:
1004
1013
  watch and approve"), so make no cut of your own. A one-shot run is
1005
1014
  delivered by itself once that cut is made: give the member its run page.
1006
- While the app makes it, `status` may still say "Parked: every piece is
1007
- made and the run is waiting for a cut." for a short while: read `status`
1008
- again before anything else. A run that stopped at the storyboard goes to
1015
+ While the app makes it, `status` says "Every piece is made. The app makes
1016
+ the cut now; look again in a minute: exodus video status <runId>": read
1017
+ `status` again in a minute. A run that stopped at the storyboard goes to
1009
1018
  stop 3, then the end.
1010
1019
 
1011
1020
  **Never start the same swipe twice.** One swipe is one video. A start of a
@@ -1648,15 +1657,20 @@ under it:
1648
1657
  `retry-frame --note` before `retry-clip`; the clip redo alone resends the
1649
1658
  refused picture. On a video the app cuts itself (one started from the
1650
1659
  dashboard, a swiped video, a beta tester's run: "End: watch and approve"),
1651
- the app makes the cut; when a scene's clip still has a drawing fault after it was made
1660
+ the app makes the cut. While it makes it, the stop block says "Every piece
1661
+ is made. The app makes the cut now; look again in a minute: exodus video
1662
+ status <runId>" and names no pull, upload or `retry-clip`: read `status`
1663
+ again in a minute. When a scene's clip still has a drawing fault after it was made
1652
1664
  again, the stop block says `Held:` and names the scene
1653
1665
  (`stop.heldScenes` in `--json`). No cut is made until each held scene is
1654
1666
  made again with `retry-clip`, or kept as it is with `exodus video keep
1655
1667
  <runId> --scene <n>` or on the video's page (the link it prints). Keeping
1656
1668
  the last one starts the cut.
1657
- A One-take take held for its words, or for a product label that came out
1658
- backwards and could not be fixed, is named under `Held:` with its own
1659
- sentence, every reason it was held for (`stop.heldTakes` in `--json`). It
1669
+ A One-take take held for its words, for a picture that came out turned on
1670
+ its side or upside down, or for a product label that came out backwards and
1671
+ could not be fixed, is named under `Held:` with its own
1672
+ sentence, every reason it was held for (`stop.heldTakes` in `--json`), from
1673
+ the moment the take is made. It
1660
1674
  cannot be made again on its own, so no `retry-clip` is offered. Show the user the sentence
1661
1675
  and ask them to watch the take. With their yes, `exodus video keep <runId>
1662
1676
  --scene <n>` keeps it as it is: it orders nothing, and keeping the last held
@@ -2317,8 +2331,10 @@ length. Do not invent a number.
2317
2331
  `pull` writes a flat folder and a `manifest.json` that indexes it. The manifest
2318
2332
  is the data you decide from; the filenames are its values. Scene numbers are the
2319
2333
  run's own. Every `pull` re-downloads and overwrites every file, so running it
2320
- again is always safe. It never writes the finished video the app made ("End:
2321
- watch and approve").
2334
+ again is always safe. Once the run has a finished video, it writes that too,
2335
+ as `video.<ext>` ("End: watch and approve"), except while the app makes the
2336
+ cut again after a redo: the one on the run then is about to be replaced. When
2337
+ a different `video.<ext>` was already in the folder, it says it replaced it.
2322
2338
 
2323
2339
  ```
2324
2340
  storyboard.json the whole storyboard envelope (see below)
@@ -2333,6 +2349,7 @@ narration.mp3 one continuous narrator take of the whole script
2333
2349
  narration.json that take's settings, master-timeline words, and the
2334
2350
  per-scene ranges it was cut into
2335
2351
  music.<ext> the music bed
2352
+ video.<ext> the finished video, once the run has one
2336
2353
  manifest.json the index below
2337
2354
  ```
2338
2355
 
@@ -2412,6 +2429,8 @@ provenance which saved rulebook this run followed:
2412
2429
  rig is a copy. Names, ids and a version
2413
2430
  only — never the rules themselves
2414
2431
  failed[] files that did not download: {file, url, error}
2432
+ video the finished video's filename; null when it
2433
+ did not download. Absent when the run has none
2415
2434
  ```
2416
2435
 
2417
2436
  ### What each piece is
@@ -630,12 +630,21 @@ function spokenWords(word) {
630
630
  return spokenForms(word).flatMap((t) => SPOKEN_FORMS.get(t) ?? [t]).map((t) => SAME_WORD_SPELLINGS.get(t) ?? t);
631
631
  }
632
632
 
633
+ /**
634
+ * COP-311: a scribe writes two words it heard as one with a slash ("probiotic/an" for "probiotic and"): the
635
+ * aligners read them as the words they are, as scout scribe.ts slashParts. A number ("1/2", "24/7") stays whole.
636
+ */
637
+ function slashParts(word) {
638
+ const parts = String(word ?? "").split("/").filter(Boolean);
639
+ return parts.length > 1 && parts.every((p) => /\p{L}/u.test(p)) ? parts : [word];
640
+ }
641
+
633
642
  /** { tokens, sourceIndex }: tokens[i] came from written word sourceIndex[i]. */
634
- function spokenTokens(words) {
643
+ function spokenTokens(words, partsOf = (word) => [word]) {
635
644
  const tokens = [];
636
645
  const sourceIndex = [];
637
646
  words.forEach((word, i) => {
638
- for (const token of spokenWords(word)) {
647
+ for (const token of partsOf(word).flatMap(spokenWords)) {
639
648
  tokens.push(token);
640
649
  sourceIndex.push(i);
641
650
  }
@@ -726,6 +735,24 @@ const soundKey = (token) =>
726
735
  .replace(/(?<=\w{3})oe$/, "o")
727
736
  .replace(/(?<=[aeiou])z$/, "s");
728
737
 
738
+ /**
739
+ * The script's and the heard words' tokens as the aligner compares them, and
740
+ * its word match: matches(e, h) when script token e is said by heard token h.
741
+ * `slash`: both sides read a word written with a slash as its words (COP-311).
742
+ */
743
+ function scriptTokens(words, written, slash = true) {
744
+ const partsOf = slash ? slashParts : undefined;
745
+ const scripted = spokenTokens(written, partsOf);
746
+ const heardWords = spokenTokens(words.map((w) => w.w), partsOf);
747
+ const nameLike = nameLikeWords(written);
748
+ const names = scripted.tokens.filter((_, t) => nameLike[scripted.sourceIndex[t]]);
749
+ const heard = joinSplitWords(heardWords, scripted.tokens, names);
750
+ const expected = joinSplitWords(scripted, heard.tokens);
751
+ const matches = (e, h) =>
752
+ h < heard.tokens.length && sameWord(expected.tokens[e], heard.tokens[h], nameLike[expected.sourceIndex[e]]);
753
+ return { heardWords, heard, expected, matches };
754
+ }
755
+
729
756
  /**
730
757
  * Where the script's first complete, in-order delivery sits in the heard
731
758
  * words, or null. heardTokenOf/heardWordOf give the heard token and word that
@@ -735,15 +762,13 @@ const soundKey = (token) =>
735
762
  * exact delivery wins. Mirrors scout scribe.ts alignScript.
736
763
  */
737
764
  function alignScript(words, written) {
738
- const scripted = spokenTokens(written);
739
- const heardWords = spokenTokens(words.map((w) => w.w));
740
- const nameLike = nameLikeWords(written);
741
- const names = scripted.tokens.filter((_, t) => nameLike[scripted.sourceIndex[t]]);
742
- const heard = joinSplitWords(heardWords, scripted.tokens, names);
743
- const expected = joinSplitWords(scripted, heard.tokens);
765
+ // COP-311: read with the slash words split, else as written, so a take found before ("salt and/or pepper"
766
+ // said "salt and pepper") is still found. Mirrors scout scribe.ts alignScript.
767
+ return alignTokens(scriptTokens(words, written, true)) ?? alignTokens(scriptTokens(words, written, false));
768
+ }
769
+
770
+ function alignTokens({ heardWords, heard, expected, matches }) {
744
771
  if (expected.tokens.length === 0 || heard.tokens.length === 0) return null;
745
- const matches = (e, h) =>
746
- h < heard.tokens.length && sameWord(expected.tokens[e], heard.tokens[h], nameLike[expected.sourceIndex[e]]);
747
772
  const pair = (allowMisheard) => {
748
773
  const tokenOf = [];
749
774
  let j = 0;
@@ -766,6 +791,90 @@ function alignScript(words, written) {
766
791
  };
767
792
  }
768
793
 
794
+ /** scriptTimes: sounds a speaker makes between words; one never stands in the place of a script word. */
795
+ const FILLER_TOKENS = new Set(["um", "umm", "uhm", "uh", "uhh", "er", "erm", "ah", "hmm", "mm", "mhm"]);
796
+ /** scriptTimes: a take with fewer of its script's tokens heard as written than this share is not the script misheard. */
797
+ const MIN_HEARD_SHARE = 0.5;
798
+
799
+ /**
800
+ * COP-311, Mario's "Fix the text, never the times", for a take where
801
+ * alignScript finds no delivery of the whole script in order: the script's
802
+ * tokens and the heard ones are paired by their longest common run, with the
803
+ * aligner's word match. The script tokens left between two pairs take the
804
+ * time of the heard words left in their place, a filler ("um") never one of
805
+ * them: one heard token each when the counts are the same, else, with one
806
+ * heard token more (a word heard as two), the span of them shared evenly by
807
+ * the script words there. Before the first pair or after the last, only one
808
+ * heard token each: a lead-in ("Okay so") or a sign-off ("Thanks guys") is
809
+ * not told apart from a misheard first or last word, so neither is shown.
810
+ * Every other place times nothing: a script word dropped, or said over words
811
+ * the script does not have, is not shown, and a heard word with no script
812
+ * word in its place times nothing. A take with fewer than MIN_HEARD_SHARE of
813
+ * its script tokens heard as written says something else: only those are
814
+ * timed. A script word with a digit ("$23.08", "30%") is timed only where
815
+ * its number words are heard as written ("dollars" may be heard as "oh"),
816
+ * so a number said otherwise is never shown. `times[e]` is script token e's [start, end] on the heard words'
817
+ * clock, or null.
818
+ */
819
+ function scriptTimes(words, written) {
820
+ const { heard, expected, matches } = scriptTokens(words, written);
821
+ const n = expected.tokens.length;
822
+ const m = heard.tokens.length;
823
+ // run[e * (m + 1) + h]: the longest common run of script tokens e.. and heard tokens h..
824
+ const run = new Int32Array((n + 1) * (m + 1));
825
+ const at = (e, h) => run[e * (m + 1) + h];
826
+ for (let e = n - 1; e >= 0; e--) {
827
+ for (let h = m - 1; h >= 0; h--) {
828
+ run[e * (m + 1) + h] = matches(e, h) ? at(e + 1, h + 1) + 1 : Math.max(at(e + 1, h), at(e, h + 1));
829
+ }
830
+ }
831
+ // Each script token on its earliest heard token that keeps the run longest.
832
+ const pairs = [[-1, -1]];
833
+ for (let e = 0, h = 0; e < n && h < m; ) {
834
+ if (matches(e, h)) pairs.push([e++, h++]);
835
+ else if (at(e, h + 1) >= at(e + 1, h)) h++;
836
+ else e++;
837
+ }
838
+ pairs.push([n, m]);
839
+ const span = (from, to) => [words[heard.sourceIndex[from]].s, words[heard.lastSourceIndex[to]].e];
840
+ const times = new Array(n).fill(null);
841
+ const scriptHeard = pairs.length - 2 >= n * MIN_HEARD_SHARE;
842
+ for (let k = 0; k + 1 < pairs.length; k++) {
843
+ const [e0, h0] = pairs[k];
844
+ const [e1, h1] = pairs[k + 1];
845
+ if (e0 >= 0) times[e0] = span(h0, h0);
846
+ const left = e1 - e0 - 1;
847
+ if (!scriptHeard || left === 0) continue;
848
+ const places = [];
849
+ for (let h = h0 + 1; h < h1; h++) if (!FILLER_TOKENS.has(heard.tokens[h])) places.push(h);
850
+ // At an end, a heard word more is a lead-in or a sign-off as likely as a word heard as two.
851
+ if ((e0 < 0 || e1 === n) && places.length !== left) continue;
852
+ if (places.length === left) {
853
+ for (let i = 0; i < left; i++) times[e0 + 1 + i] = span(places[i], places[i]);
854
+ } else if (places.length === left + 1) {
855
+ const [gapStart, gapEnd] = span(places[0], places.at(-1));
856
+ const owners = [...new Set(expected.sourceIndex.slice(e0 + 1, e1))];
857
+ const share = (gapEnd - gapStart) / owners.length;
858
+ for (let t = e0 + 1; t < e1; t++) {
859
+ const u = owners.indexOf(expected.sourceIndex[t]);
860
+ times[t] = [gapStart + u * share, gapStart + (u + 1) * share];
861
+ }
862
+ }
863
+ }
864
+ // A number token of a script word with a digit not heard as written: that word is not shown.
865
+ const paired = new Set(pairs.slice(1, -1).map(([e]) => e));
866
+ const numberToken = (token) => NUMBER_WORDS.has(token) || /\p{N}/u.test(token);
867
+ const unheardNumbers = new Set();
868
+ for (let e = 0; e < n; e++) {
869
+ if (paired.has(e) || !numberToken(expected.tokens[e])) continue;
870
+ for (let i = expected.sourceIndex[e]; i <= expected.lastSourceIndex[e]; i++) if (/\p{N}/u.test(written[i])) unheardNumbers.add(i);
871
+ }
872
+ for (let e = 0; e < n; e++) {
873
+ for (let i = expected.sourceIndex[e]; i <= expected.lastSourceIndex[e]; i++) if (unheardNumbers.has(i)) times[e] = null;
874
+ }
875
+ return { expected, times };
876
+ }
877
+
769
878
  /**
770
879
  * #2541: the indexes of the heard words that deliver the first and last
771
880
  * scripted word, matching the script in order at its earliest delivery, or null
@@ -4611,14 +4720,14 @@ export function lineCaptionScreens(words, cap = null) {
4611
4720
 
4612
4721
  /**
4613
4722
  * captionsByLine: the cut's words in its own time, each with the script line
4614
- * it belongs to. Where a segment's script is heard in order (alignScript),
4615
- * they are the script's words as written, each timed by the heard words that
4616
- * say it; elsewhere they are the heard words, each on the line its place among
4617
- * the script's words gives it, the way a cue line is found (lineInSegment).
4723
+ * it belongs to. They are the script's words as written, never a heard word
4724
+ * the script does not have (COP-311). Where a segment's script is heard in
4725
+ * order (alignScript), each is timed by the heard words that say it;
4726
+ * elsewhere by the heard words in its place (scriptTimes), and a script word
4727
+ * with nothing heard in its place is left out.
4618
4728
  */
4619
4729
  export function lineWords(timeline, storyboard) {
4620
4730
  const texts = new Map((storyboard?.script ?? []).map((line) => [line?.lineId, line?.text]));
4621
- const counts = lineWordCounts(storyboard);
4622
4731
  const rows = [];
4623
4732
  for (const seg of timeline.spine) {
4624
4733
  const heard = seg.words ?? [];
@@ -4638,19 +4747,48 @@ export function lineWords(timeline, storyboard) {
4638
4747
  });
4639
4748
  continue;
4640
4749
  }
4641
- const ends = [];
4642
- let n = 0;
4643
- for (const id of seg.lineIds) ends.push((n += counts.get(id) ?? 0));
4644
- heard.forEach((w, i) => {
4645
- const text = (w.w ?? "").trim();
4646
- const start = at(w.s);
4647
- const end = at(w.e);
4648
- if (!text || end <= start) return;
4649
- const j = ends.findIndex((last) => Math.min(i, n - 1) < last);
4650
- rows.push({ text, start, end, line: seg.lineIds[j] ?? seg.lineIds.at(-1) ?? `scene ${seg.sceneIndex}` });
4750
+ // COP-311: the script's words still, each on the time of what was heard in its place (scriptTimes).
4751
+ const lineOf = lines.flatMap((ws, j) => ws.map(() => seg.lineIds[j]));
4752
+ const { expected, times } = scriptTimes(heard, lines.flat());
4753
+ lines.flat().forEach((text, i) => {
4754
+ const said = times.filter((time, e) => time && expected.sourceIndex[e] <= i && i <= expected.lastSourceIndex[e]);
4755
+ if (said.length === 0) return;
4756
+ const start = at(said[0][0]);
4757
+ const end = at(said.at(-1)[1]);
4758
+ if (end > start) rows.push({ text, start, end, line: lineOf[i] });
4651
4759
  });
4652
4760
  }
4653
- return rows;
4761
+ return sharedHeardWords(rows);
4762
+ }
4763
+
4764
+ /**
4765
+ * lineWords: script words that start on one heard word but are not timed
4766
+ * alike ("probiotics/and" ending one line and starting the next) take that
4767
+ * word's time (to the earliest of their ends) in turn, so no caption screen
4768
+ * is cleared before its word is said. A word that runs on past it keeps its
4769
+ * own end. Words timed alike on one line stay on one screen
4770
+ * (lineCaptionScreens).
4771
+ */
4772
+ function sharedHeardWords(rows) {
4773
+ const out = [];
4774
+ for (let i = 0; i < rows.length; ) {
4775
+ let j = i + 1;
4776
+ while (j < rows.length && rows[j].start === rows[i].start) j++;
4777
+ const run = rows.slice(i, j);
4778
+ const keys = [...new Set(run.map((r) => `${r.line}|${r.end}`))];
4779
+ if (keys.length === 1) out.push(...run);
4780
+ else {
4781
+ const start = run[0].start;
4782
+ const shared = Math.min(...run.map((r) => r.end));
4783
+ const slot = (shared - start) / keys.length;
4784
+ for (const r of run) {
4785
+ const u = keys.indexOf(`${r.line}|${r.end}`);
4786
+ out.push({ ...r, start: roundMs(start + u * slot), end: r.end > shared ? r.end : roundMs(start + (u + 1) * slot) });
4787
+ }
4788
+ }
4789
+ i = j;
4790
+ }
4791
+ return out;
4654
4792
  }
4655
4793
 
4656
4794
  /**
@@ -3133,6 +3133,8 @@ function runStateWord(data) {
3133
3133
  return "failed";
3134
3134
  if (run.isTerminal)
3135
3135
  return "done";
3136
+ if (run.appCut === "making")
3137
+ return "running";
3136
3138
  if (run.status === "awaiting-approval" || run.status === "awaiting-review") {
3137
3139
  const parked = run.nodes.find((node) => node.nodeId === run.pausedNodeId);
3138
3140
  return run.pauseReason === undefined && parked && ["scene-frames", "storyboard"].includes(parked.kind) ? "storyboard" : "waiting";
@@ -107,6 +107,7 @@ export type ArtifactSubset = {
107
107
  words?: ClipWord[];
108
108
  qc?: ClipQc;
109
109
  final?: boolean;
110
+ autoCut?: boolean;
110
111
  revoiced?: boolean;
111
112
  speechTrimmed?: boolean;
112
113
  tailTrimmed?: boolean;
@@ -225,6 +226,9 @@ export interface VideoRun {
225
226
  };
226
227
  workflowId?: string;
227
228
  cutHeldScenes?: number[];
229
+ appCut?: "making" | "needs-person";
230
+ storyboardAutoApprove?: boolean;
231
+ moduleKey?: string;
228
232
  cutFailure?: {
229
233
  sentence: string;
230
234
  };
@@ -256,6 +260,9 @@ export interface NodeItem {
256
260
  error?: string;
257
261
  attempt?: number;
258
262
  flagged?: boolean;
263
+ acceptedAsIs?: {
264
+ at: number;
265
+ };
259
266
  findings?: ClipFinding[];
260
267
  speech?: SpeechSummary;
261
268
  staleClaim?: boolean;
@@ -290,12 +297,14 @@ export interface FlowResult {
290
297
  lines: string[];
291
298
  usage?: true;
292
299
  }
300
+ export declare function checkDownloadSize(received: number, headers: Pick<Headers, "get">): void;
293
301
  export interface VideoDeps {
294
302
  get: (path: string) => Promise<ApiResponse<unknown>>;
295
303
  post: (path: string, body: unknown) => Promise<ApiResponse<unknown>>;
296
304
  mkdirp: (dir: string) => void;
297
305
  writeFile: (filePath: string, text: string) => void;
298
306
  downloadToFile: (url: string, filePath: string) => Promise<void>;
307
+ piecesOnly?: true;
299
308
  readFile: (filePath: string) => string;
300
309
  readFileBytes: (filePath: string) => Uint8Array;
301
310
  statFile: (filePath: string) => {
@@ -334,6 +343,10 @@ export type RunStop = {
334
343
  heldScenes?: number[];
335
344
  heldTakes?: HeldTake[];
336
345
  cutFailure?: string;
346
+ appMakesCut?: true;
347
+ appCutOnRun?: true;
348
+ appOutdatesCut?: true;
349
+ redoingScenes?: number[];
337
350
  } | {
338
351
  at: "pilot";
339
352
  nodeId?: string;
@@ -388,7 +401,10 @@ export interface HeldTake {
388
401
  sentence: string;
389
402
  }
390
403
  export declare function heldTakesOf(scenes: readonly number[] | undefined, items: readonly NodeItem[] | null | undefined): HeldTake[];
404
+ export declare function flaggedHeldTakesOf(items: readonly NodeItem[] | null | undefined): HeldTake[];
391
405
  export declare function resolveStop(stop: RunStop, cutAttached: boolean | null, items?: NodeItem[] | null): ResolvedStop;
406
+ export declare function appCutOutdates(run: Pick<VideoRun, "appCut" | "moduleKey">): boolean;
407
+ export declare function appIsCutting(stop: ResolvedStop): boolean;
392
408
  export declare function resolveStopAtPark(stop: RunStop, runId: string, deps: Pick<VideoDeps, "get">): Promise<ResolvedStop>;
393
409
  export declare function stageWord(stage: string): string;
394
410
  export declare function stepName(kind: string | undefined): string;
@@ -502,6 +518,7 @@ export interface VideoManifest {
502
518
  file: string | null;
503
519
  reason?: string;
504
520
  };
521
+ video?: string | null;
505
522
  }
506
523
  export interface RunShots {
507
524
  frame?: string;
@@ -520,6 +537,7 @@ export declare function scenePrefix(sceneIndex: number): string;
520
537
  export declare function planPull(run: VideoRun, items: NodeItem[], opts: {
521
538
  pulledAt: string;
522
539
  dashboardUrl: string;
540
+ piecesOnly?: true;
523
541
  }): PullPlan;
524
542
  export declare function markPullFailure(manifest: VideoManifest, failure: PullFailure): void;
525
543
  export declare function missingSetupLabels(progress: ShowRow["setupProgress"]): string[];
@@ -703,6 +703,17 @@ export function asVideoRun(data) {
703
703
  const run = (data ?? {});
704
704
  return { ...run, nodes: Array.isArray(run.nodes) ? run.nodes : [] };
705
705
  }
706
+ export function checkDownloadSize(received, headers) {
707
+ if (received === 0)
708
+ throw new Error("the download was empty");
709
+ const encoding = headers.get("content-encoding");
710
+ if (encoding && encoding !== "identity")
711
+ return;
712
+ const stated = Number(headers.get("content-length") ?? "");
713
+ if (Number.isFinite(stated) && stated > 0 && stated !== received) {
714
+ throw new Error(`the download came to ${received} bytes, not the ${stated} the server sent`);
715
+ }
716
+ }
706
717
  export const defaultDeps = {
707
718
  get: (p) => apiGet(p),
708
719
  post: (p, body) => apiPost(p, body),
@@ -714,7 +725,17 @@ export const defaultDeps = {
714
725
  const res = await fetch(url);
715
726
  if (!res.ok)
716
727
  throw new Error(`HTTP ${res.status}`);
717
- fs.writeFileSync(filePath, Buffer.from(await res.arrayBuffer()));
728
+ const bytes = Buffer.from(await res.arrayBuffer());
729
+ checkDownloadSize(bytes.length, res.headers);
730
+ const part = `${filePath}.part`;
731
+ try {
732
+ fs.writeFileSync(part, bytes);
733
+ fs.renameSync(part, filePath);
734
+ }
735
+ catch (err) {
736
+ fs.rmSync(part, { force: true });
737
+ throw err;
738
+ }
718
739
  },
719
740
  readFile: (filePath) => fs.readFileSync(filePath, "utf-8"),
720
741
  readFileBytes: (filePath) => fs.readFileSync(filePath),
@@ -917,6 +938,8 @@ export function classifyRun(run) {
917
938
  ...(missingScenes.length > 0 && framesNodeId ? { framesNodeId } : {}),
918
939
  ...(run.cutHeldScenes?.length ? { heldScenes: run.cutHeldScenes } : {}),
919
940
  ...(run.cutFailure?.sentence ? { cutFailure: run.cutFailure.sentence } : {}),
941
+ ...(run.appCut === "making" ? { appMakesCut: true } : {}),
942
+ ...(appCutOutdates(run) ? { appOutdatesCut: true } : {}),
920
943
  };
921
944
  }
922
945
  return { at: "paused", nodeId: run.pausedNodeId, reason: run.pauseReason };
@@ -943,13 +966,33 @@ export function heldTakesOf(scenes, items) {
943
966
  if (!scenes?.length || !items)
944
967
  return [];
945
968
  return scenes.flatMap((sceneIndex) => {
946
- const latest = items
947
- .filter((i) => i.itemKind === "clip" && i.sceneIndex === sceneIndex)
948
- .reduce((best, i) => (!best || (i.attempt ?? 0) >= (best.attempt ?? 0) ? i : best), undefined);
949
- const said = (latest?.findings ?? [])
950
- .filter((f) => ONE_TAKE_HOLD_CODES.includes(f.code) && f.detail.trim())
951
- .map((f) => f.detail.trim());
952
- return said.length > 0 ? [{ sceneIndex, sentence: said.join(" ") }] : [];
969
+ const said = holdSentenceOf(latestClipRow(items, sceneIndex));
970
+ return said !== null ? [{ sceneIndex, sentence: said }] : [];
971
+ });
972
+ }
973
+ function latestClipRow(items, sceneIndex) {
974
+ return items
975
+ .filter((i) => i.itemKind === "clip" && i.sceneIndex === sceneIndex)
976
+ .reduce((best, i) => (!best || (i.attempt ?? 0) >= (best.attempt ?? 0) ? i : best), undefined);
977
+ }
978
+ function holdSentenceOf(row) {
979
+ const said = (row?.findings ?? [])
980
+ .filter((f) => ONE_TAKE_HOLD_CODES.includes(f.code) && f.detail.trim())
981
+ .map((f) => f.detail.trim());
982
+ return said.length > 0 ? said.join(" ") : null;
983
+ }
984
+ export function flaggedHeldTakesOf(items) {
985
+ if (!items)
986
+ return [];
987
+ const scenes = [...new Set(items.filter((i) => i.itemKind === "clip" && isPullSceneIndex(i.sceneIndex)).map((i) => i.sceneIndex))];
988
+ return scenes
989
+ .sort((a, b) => a - b)
990
+ .flatMap((sceneIndex) => {
991
+ const latest = latestClipRow(items, sceneIndex);
992
+ if (!latest || latest.status !== "done" || latest.flagged !== true || latest.acceptedAsIs)
993
+ return [];
994
+ const said = holdSentenceOf(latest);
995
+ return said !== null ? [{ sceneIndex, sentence: said }] : [];
953
996
  });
954
997
  }
955
998
  export function resolveStop(stop, cutAttached, items) {
@@ -962,8 +1005,36 @@ export function resolveStop(stop, cutAttached, items) {
962
1005
  }
963
1006
  if (stop.at !== "final-watch")
964
1007
  return stop;
965
- const heldTakes = heldTakesOf(stop.heldScenes, items);
966
- return { ...stop, cutAttached, ...(heldTakes.length > 0 ? { heldTakes } : {}) };
1008
+ const named = heldTakesOf(stop.heldScenes, items);
1009
+ const fromRows = cutAttached === false
1010
+ ? flaggedHeldTakesOf(items).filter((t) => !(stop.heldScenes ?? []).includes(t.sceneIndex))
1011
+ : [];
1012
+ const heldTakes = fromRows.length > 0 ? [...named, ...fromRows].sort((a, b) => a.sceneIndex - b.sceneIndex) : named;
1013
+ const heldScenes = fromRows.length > 0
1014
+ ? [...(stop.heldScenes ?? []), ...fromRows.map((t) => t.sceneIndex)].sort((a, b) => a - b)
1015
+ : stop.heldScenes;
1016
+ return {
1017
+ ...stop,
1018
+ cutAttached,
1019
+ ...(heldScenes?.length ? { heldScenes } : {}),
1020
+ ...(heldTakes.length > 0 ? { heldTakes } : {}),
1021
+ ...(items && hasAppCut(items) ? { appCutOnRun: true } : {}),
1022
+ };
1023
+ }
1024
+ export function appCutOutdates(run) {
1025
+ return run.appCut === "making" && run.moduleKey === "script-video";
1026
+ }
1027
+ function hasAppCut(items) {
1028
+ return items.some((i) => i.itemKind === "final" && i.status === "done" && i.artifact?.type === "video" && i.artifact.autoCut === true);
1029
+ }
1030
+ export function appIsCutting(stop) {
1031
+ return (stop.at === "final-watch" &&
1032
+ stop.appMakesCut === true &&
1033
+ !stop.missingScenes?.length &&
1034
+ !stop.heldScenes?.length &&
1035
+ !stop.cutFailure &&
1036
+ stop.cutAttached !== null &&
1037
+ (!stop.cutAttached || (stop.appCutOnRun === true && stop.appOutdatesCut === true)));
967
1038
  }
968
1039
  export async function resolveStopAtPark(stop, runId, deps) {
969
1040
  if (stop.at !== "final-watch" && stop.at !== "pilot")
@@ -1159,6 +1230,21 @@ export function stopLines(stop, runId, runUrl, videoPage) {
1159
1230
  `Watch it here: ${runUrl}`,
1160
1231
  ];
1161
1232
  }
1233
+ if (appIsCutting(stop)) {
1234
+ if (stop.redoingScenes?.length) {
1235
+ const many = stop.redoingScenes.length > 1;
1236
+ return [
1237
+ `Scene${many ? "s" : ""} ${stop.redoingScenes.join(", ")} ${many ? "are" : "is"} being made again. The app cuts the video again once ${many ? "they are" : "it is"} made; look again in a few minutes: exodus video status ${runId}`,
1238
+ `Watch it here: ${runUrl}`,
1239
+ ];
1240
+ }
1241
+ return [
1242
+ stop.cutAttached
1243
+ ? `Every piece is made. The app makes the cut again now; look again in a minute: exodus video status ${runId}`
1244
+ : `Every piece is made. The app makes the cut now; look again in a minute: exodus video status ${runId}`,
1245
+ `Watch it here: ${runUrl}`,
1246
+ ];
1247
+ }
1162
1248
  if (stop.cutAttached) {
1163
1249
  return [
1164
1250
  "Parked: your cut is uploaded and waiting for your approval.",
@@ -1732,6 +1818,8 @@ export function planPull(run, items, opts) {
1732
1818
  };
1733
1819
  });
1734
1820
  const { cast, downloads: castDownloads } = planCastRefs(run, items, castVoicePins(storyboardArtifact));
1821
+ const finishedUrl = opts.piecesOnly || appCutOutdates(run) ? undefined : finishedVideoUrl(items);
1822
+ const finished = finishedUrl ? { file: `video.${extFor(finishedUrl, "video")}`, url: finishedUrl } : null;
1735
1823
  const downloads = [
1736
1824
  ...(reference ? [reference] : []),
1737
1825
  ...(productSheet ? [productSheet] : []),
@@ -1743,6 +1831,7 @@ export function planPull(run, items, opts) {
1743
1831
  ...[...clipByScene.values()].map((c) => c.download),
1744
1832
  ...(music ? [music] : []),
1745
1833
  ...castDownloads,
1834
+ ...(finished ? [finished] : []),
1746
1835
  ];
1747
1836
  return {
1748
1837
  downloads,
@@ -1788,11 +1877,40 @@ export function planPull(run, items, opts) {
1788
1877
  ...(run.videoChoice?.videoModel === "template-video" && run.heldSong === true
1789
1878
  ? { wholeVoice: true, templateMotion: { enabled: true } } : {}),
1790
1879
  ...(run.shots?.frame || run.shots?.pacing ? { shots: run.shots } : {}),
1880
+ ...(finished ? { video: finished.file } : {}),
1791
1881
  },
1792
1882
  };
1793
1883
  }
1884
+ function finishedVideoUrl(items) {
1885
+ const finals = items.filter((i) => i.itemKind === "final" && i.status === "done" && i.artifact?.type === "video");
1886
+ return finals.length === 1 && finals[0].artifact?.type === "video" ? finals[0].artifact.videoUrl || undefined : undefined;
1887
+ }
1888
+ function appCutsRun(run, items) {
1889
+ return run.appCut !== undefined || hasAppCut(items);
1890
+ }
1891
+ function fingerprintInFolder(dir, file, deps) {
1892
+ if (!file || deps.statFile(path.join(dir, file)) === null)
1893
+ return null;
1894
+ return createHash("sha256").update(deps.readFileBytes(path.join(dir, file))).digest("hex");
1895
+ }
1896
+ function replacedVideoLines(dir, file, before, deps) {
1897
+ if (!file || before === null)
1898
+ return [];
1899
+ const after = fingerprintInFolder(dir, file, deps);
1900
+ return after !== null && after !== before
1901
+ ? [`A different ${file} was already in ${dir}; the pull replaced it with this run's finished video.`]
1902
+ : [];
1903
+ }
1904
+ function runStopped(run) {
1905
+ return run.status === "failed" || run.status === "cancelled" || run.status === "canceled";
1906
+ }
1907
+ function deliveredLine(dir, video) {
1908
+ return video ? `This run is delivered. The finished video is ${path.join(dir, video)}.` : "This run is delivered.";
1909
+ }
1794
1910
  export function markPullFailure(manifest, failure) {
1795
1911
  manifest.failed.push(failure);
1912
+ if (manifest.video === failure.file)
1913
+ manifest.video = null;
1796
1914
  if (manifest.storyboard === failure.file)
1797
1915
  manifest.storyboard = null;
1798
1916
  if (manifest.reference === failure.file)
@@ -3802,6 +3920,10 @@ export async function waitFlow(runId, opts, deps) {
3802
3920
  }
3803
3921
  }
3804
3922
  const resolved = resolveStop(stop, items ? hasAttachedCut(items) : null, items);
3923
+ if (appIsCutting(resolved)) {
3924
+ progress("Working: the app makes the cut…");
3925
+ continue;
3926
+ }
3805
3927
  if (opts.json) {
3806
3928
  return {
3807
3929
  code: stop.at === "failed" ? 1 : 0,
@@ -3844,6 +3966,9 @@ function carryingOn(run) {
3844
3966
  return (run.status === "queued" &&
3845
3967
  run.nodes.some((n) => n.status !== "idle" && n.status !== "out-of-scope"));
3846
3968
  }
3969
+ function cutDeliversItself(run, stop) {
3970
+ return run.storyboardAutoApprove === true && stop.at === "running";
3971
+ }
3847
3972
  export async function statusFlow(runId, json, deps) {
3848
3973
  const runRes = await deps.get(`${RUN_PATH}?runId=${encodeURIComponent(runId)}`);
3849
3974
  if (!runRes.ok)
@@ -3861,7 +3986,9 @@ export async function statusFlow(runId, json, deps) {
3861
3986
  return errorResult(itemsRes, json);
3862
3987
  const items = itemsRes.data.items ?? [];
3863
3988
  const hasFinal = hasAttachedCut(items);
3864
- const stop = resolveStop(classifyRun(run), hasFinal, items);
3989
+ const resolved = resolveStop(classifyRun(run), hasFinal, items);
3990
+ const redoingScenes = resolved.at === "final-watch" ? scenesBeingRedone(run, items) : [];
3991
+ const stop = resolved.at === "final-watch" && redoingScenes.length > 0 ? { ...resolved, redoingScenes } : resolved;
3865
3992
  const failedStoryboard = failedStoryboardNode(run);
3866
3993
  const guidance = stopLines(stop.at === "failed" && errorEchoesReasons(stop.error, failedStoryboard?.planFailure)
3867
3994
  ? { ...stop, error: undefined }
@@ -4019,11 +4146,17 @@ export async function statusFlow(runId, json, deps) {
4019
4146
  lines.push(...(await statusVoiceLines(runId, deps)));
4020
4147
  }
4021
4148
  const cost = runCostLine(run, items);
4022
- lines.push("", ...(cost ? [cost] : []), hasFinal && stop.at === "finished"
4023
- ? "Final cut: approved and delivered."
4024
- : hasFinal
4025
- ? `Final cut: uploaded. Approve it with: exodus video approve ${runId}`
4026
- : "Final cut: not uploaded yet.", ...(run.cutCheck ?? []));
4149
+ lines.push("", ...(cost ? [cost] : []), runStopped(run)
4150
+ ? hasFinal ? "Final cut: on the run, which stopped before it was delivered." : "Final cut: none. This run stopped before one was made."
4151
+ : hasFinal && stop.at === "finished"
4152
+ ? "Final cut: approved and delivered."
4153
+ : hasFinal && cutDeliversItself(run, stop)
4154
+ ? "Final cut: made. This run delivers it by itself; look again in a minute."
4155
+ : hasFinal && appIsCutting(stop)
4156
+ ? "Final cut: the app makes it again now; look again in a minute."
4157
+ : hasFinal
4158
+ ? `Final cut: uploaded. Approve it with: exodus video approve ${runId}`
4159
+ : "Final cut: not uploaded yet.", ...(run.cutCheck ?? []));
4027
4160
  let finalSpeech;
4028
4161
  for (const item of items)
4029
4162
  if (item.itemKind === "final" && item.status === "done")
@@ -5511,6 +5644,7 @@ async function customerPullFlow(run, dir, json, deps) {
5511
5644
  dashboardUrl: deps.dashboardUrl,
5512
5645
  });
5513
5646
  deps.mkdirp(dir);
5647
+ const videoBefore = fingerprintInFolder(dir, manifest.video, deps);
5514
5648
  const failures = (await runPool(downloads.map((download) => () => downloadWithRetry(download, dir, deps)), PULL_CONCURRENCY)).filter((f) => f !== null);
5515
5649
  const landed = (file) => file !== null && !failures.some((f) => f.file === file) ? file : null;
5516
5650
  for (const scene of manifest.scenes) {
@@ -5539,6 +5673,7 @@ async function customerPullFlow(run, dir, json, deps) {
5539
5673
  lines: [
5540
5674
  `Pulled ${downloads.length - failures.length + 1} files into ${dir}`,
5541
5675
  `Every piece is listed in ${manifestPath}.`,
5676
+ ...replacedVideoLines(dir, manifest.video, videoBefore, deps),
5542
5677
  ...(manifest.video ? [] : ["The finished video isn't ready yet, so only the scene pieces came down."]),
5543
5678
  ...(failures.length > 0
5544
5679
  ? [
@@ -5548,11 +5683,13 @@ async function customerPullFlow(run, dir, json, deps) {
5548
5683
  "Run the same command again to retry.",
5549
5684
  ]
5550
5685
  : []),
5551
- "",
5552
- `When your cut is ready: exodus video upload ${runId} --file cut.mp4`,
5686
+ ...(customerDelivered(run) ? ["", deliveredLine(dir, manifest.video)] : []),
5553
5687
  ],
5554
5688
  };
5555
5689
  }
5690
+ function customerDelivered(run) {
5691
+ return run.stage === "ready" && run.awaitingSignOff !== true;
5692
+ }
5556
5693
  export async function pullFlow(runId, dir, json, deps) {
5557
5694
  const runRes = await deps.get(`${RUN_PATH}?runId=${encodeURIComponent(runId)}`);
5558
5695
  if (!runRes.ok)
@@ -5568,6 +5705,7 @@ export async function pullFlow(runId, dir, json, deps) {
5568
5705
  const plan = planPull(run, items, {
5569
5706
  pulledAt: new Date(deps.now()).toISOString(),
5570
5707
  dashboardUrl: deps.dashboardUrl,
5708
+ ...(deps.piecesOnly ? { piecesOnly: true } : {}),
5571
5709
  });
5572
5710
  deps.mkdirp(dir);
5573
5711
  if (plan.downloads.length === 0 && plan.texts.length === 0) {
@@ -5582,6 +5720,7 @@ export async function pullFlow(runId, dir, json, deps) {
5582
5720
  for (const text of plan.texts) {
5583
5721
  deps.writeFile(path.join(dir, text.file), text.body);
5584
5722
  }
5723
+ const videoBefore = fingerprintInFolder(dir, plan.manifest.video, deps);
5585
5724
  const failures = await runPool(plan.downloads.map((download) => () => downloadWithRetry(download, dir, deps)), PULL_CONCURRENCY);
5586
5725
  for (const failure of failures) {
5587
5726
  if (failure)
@@ -5601,6 +5740,7 @@ export async function pullFlow(runId, dir, json, deps) {
5601
5740
  const lines = [
5602
5741
  `Pulled ${wrote} files into ${dir}`,
5603
5742
  `Every piece is indexed in ${path.join(dir, "manifest.json")} — scene numbers there are the run's own.`,
5743
+ ...replacedVideoLines(dir, plan.manifest.video, videoBefore, deps),
5604
5744
  ...musicLines(plan.manifest),
5605
5745
  ];
5606
5746
  if (plan.manifest.dropped.length > 0) {
@@ -5634,7 +5774,15 @@ export async function pullFlow(runId, dir, json, deps) {
5634
5774
  lines.push(` ${failure.file}: ${failure.error}`);
5635
5775
  lines.push("Run the same command again to retry just those.");
5636
5776
  }
5637
- lines.push("", `When your cut is ready: exodus video upload ${runId} --file cut.mp4`);
5777
+ if (runStopped(run)) {
5778
+ lines.push("", "This run stopped before it was delivered, so no cut can be uploaded to it now.");
5779
+ }
5780
+ else if (hasAttachedCut(items) && classifyRun(run).at === "finished") {
5781
+ lines.push("", deliveredLine(dir, plan.manifest.video));
5782
+ }
5783
+ else if (!appCutsRun(run, items)) {
5784
+ lines.push("", `When your cut is ready: exodus video upload ${runId} --file cut.mp4`);
5785
+ }
5638
5786
  return { code: failed.length > 0 ? 1 : 0, lines };
5639
5787
  }
5640
5788
  const BOX_HEADER = 8;
@@ -5,4 +5,5 @@ export const ONE_TAKE_HOLD_CODES = [
5
5
  "one-take-words-unchecked",
6
6
  "one-take-label-held",
7
7
  "one-take-said-wrong",
8
+ "one-take-sideways",
8
9
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aicopycoders/exodus",
3
- "version": "2026.11.1200-beta.13",
3
+ "version": "2026.11.1200-beta.15",
4
4
  "description": "CLI + Claude Code skills for the Copycoders Exodus ad pipeline",
5
5
  "repository": {
6
6
  "type": "git",