@aicopycoders/exodus 2026.11.1200-beta.2 → 2026.11.1200-beta.21

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.
@@ -4,7 +4,7 @@ import os from "node:os";
4
4
  import path from "node:path";
5
5
  import { formatApiError } from "../lib/format.js";
6
6
  import { missingRouteLine } from "../lib/route-support.js";
7
- import { customerAnswer, customerStageIsWorking } from "./video-customer.js";
7
+ import { customerAnswer, customerRunPage, customerStageIsWorking, onOwnDashboard } from "./video-customer.js";
8
8
  import { asVideoRun, describeFetchFailure, RUN_PATH, startedThenWait, waitFlow } from "./video.js";
9
9
  export const SWIPE_BREAKDOWNS_PATH = "/api/v2/video/breakdowns";
10
10
  export const SWIPE_UPLOAD_URL_PATH = "/api/v2/video/breakdowns/upload-url";
@@ -13,6 +13,10 @@ export const SWIPE_PRODUCTS_PATH = "/api/v2/video/swipe-products";
13
13
  export const SWIPES_PATH = "/api/v2/video/swipes";
14
14
  export const SWIPE_RUNS_PATH = "/api/v2/video/swipe-runs";
15
15
  export const SWIPE_SHEET_PATH = "/api/v2/video/swipe-sheet";
16
+ export const SWIPE_SHEET_PRICE_PATH = "/api/v2/video/swipe-sheet-price";
17
+ export const SWIPE_SHEET_OPTIONS_PATH = "/api/v2/video/swipe-sheet/options";
18
+ export const SHEET_SOURCES_QUERY = "sources=recommended";
19
+ export const SWIPE_WRITE_PEOPLE_PATH = "/api/v2/video/swipe-write-people";
16
20
  export const SWIPE_LIBRARY_PATH = "/api/v2/swipe-library";
17
21
  export const SWIPE_MODES = [
18
22
  { flag: "whole-ad", mode: "whole", label: "Whole ad", helper: "Every part of their ad, rewritten for your brand." },
@@ -22,7 +26,7 @@ export const SWIPE_MODES = [
22
26
  ];
23
27
  export const SWIPE_CLOSENESS = [
24
28
  { step: 1, flag: "mirror", name: "Mirror", line: "Same lines in the same order. Only your brand, product and claims change." },
25
- { step: 2, flag: "close", name: "Close", line: "Same parts in the same order, each line said in new words." },
29
+ { step: 2, flag: "close", name: "Close", line: "Same parts in the same order, with the same kind of line in each, in new words." },
26
30
  { step: 3, flag: "same-beats", name: "Same beats", line: "Same job for each part, in the same order. New words and new examples." },
27
31
  {
28
32
  step: 4,
@@ -138,6 +142,18 @@ export function planSwipeCommand(rest, occurrences) {
138
142
  if (named !== "write")
139
143
  return usage(kindElsewhere(named));
140
144
  }
145
+ const verbNamed = rest.find((word) => VERBS.includes(word));
146
+ const sheetSet = verbNamed === "sheet" && rest.slice(rest.indexOf("sheet") + 1).find((word) => !ON_WORDS.has(word.toLowerCase()) && !OFF_WORDS.has(word.toLowerCase())) === "set";
147
+ const peopleFlag = last("people-max-usd") !== undefined && !sheetSet ? "people-max-usd" : last("people")?.flag === "no-people" ? "no-people" : null;
148
+ if (peopleFlag !== null) {
149
+ const named = verbNamed;
150
+ if (named !== "write") {
151
+ const who = named === undefined ? "video swipe --file, --url and --ad" : `video swipe ${named}`;
152
+ return usage(peopleFlag === "people-max-usd"
153
+ ? `${who} takes no --people-max-usd: it carries the people's most on exodus video swipe write --yes.`
154
+ : `${who} takes no --no-people: it is a flag of exodus video swipe write.`);
155
+ }
156
+ }
141
157
  if (verb === undefined) {
142
158
  const given = ["file", "url", "ad"].filter((name) => value(name) !== undefined);
143
159
  if (given.length !== 1) {
@@ -217,7 +233,14 @@ export function planSwipeCommand(rest, occurrences) {
217
233
  const start = startChoicesOf({ style: value("style"), title: value("title"), music: on("music"), oneShot: on("one-shot") }, CLI_WORDS.start);
218
234
  if ("problem" in start)
219
235
  return usage(start.problem);
220
- return { kind: "start", swipeId: id, ask: start.ask, again: on("again"), opts };
236
+ const most = value("max-usd");
237
+ if (most === null)
238
+ return usage("video swipe start --max-usd needs the most the price showed, such as 4.89.");
239
+ if (most !== undefined && !/^\d+(\.\d{1,2})?$/.test(most.trim())) {
240
+ return usage(`video swipe start --max-usd takes a dollar amount, such as 4.89 (got "${most}").`);
241
+ }
242
+ const ask = most === undefined ? start.ask : { ...start.ask, maxUsd: Number(most.trim()) };
243
+ return { kind: "start", swipeId: id, ask, again: on("again"), opts };
221
244
  }
222
245
  const product = value("product");
223
246
  if (!product)
@@ -228,21 +251,112 @@ export function planSwipeCommand(rest, occurrences) {
228
251
  const kind = value("kind");
229
252
  if (kind === null || (kind !== undefined && !kind.trim()))
230
253
  return usage(`video swipe write --kind needs the key of a kind of ad. ${KIND_CHECKED}`);
231
- return { kind: "write", breakdownId: id, ask: { productId: product.trim(), ...write.ask, ...(kind !== undefined ? { kind: kind.trim() } : {}) }, opts };
254
+ const peopleMost = value("people-max-usd");
255
+ if (peopleMost === null)
256
+ return usage("video swipe write --people-max-usd needs the people's most the write showed, such as 1.52.");
257
+ if (peopleMost !== undefined && !/^\d+(\.\d{1,2})?$/.test(peopleMost.trim())) {
258
+ return usage(`video swipe write --people-max-usd takes a dollar amount, such as 1.52 (got "${peopleMost}").`);
259
+ }
260
+ const noPeople = last("people")?.flag === "no-people";
261
+ if (peopleMost !== undefined && noPeople)
262
+ return usage("video swipe write takes --people-max-usd or --no-people, not both.");
263
+ if (peopleMost !== undefined && !opts.yes)
264
+ return usage("video swipe write --people-max-usd goes with --yes, after the price.");
265
+ const people = { ...(peopleMost !== undefined ? { peopleMaxUsd: Number(peopleMost.trim()) } : {}), ...(noPeople ? { noPeople: true } : {}) };
266
+ return { kind: "write", breakdownId: id, ask: { productId: product.trim(), ...write.ask, ...(kind !== undefined ? { kind: kind.trim() } : {}), ...people }, opts };
232
267
  }
233
268
  export const SHEET_ROW_ID = /^[A-Za-z][A-Za-z0-9-]{0,63}$/;
234
269
  const SHEET_SET_LINE = 'exodus video swipe sheet set <swipeId> <row>=<value> [<row>=<value> ...]';
270
+ const SHEET_PRICE_LINE = "exodus video swipe sheet price <swipeId>";
271
+ const SHEET_PEOPLE_LINE = "exodus video swipe sheet people <swipeId> [--count <n>] [--yes --max-usd <n>] [--wait] [--json]";
272
+ export const SHEET_PEOPLE_MOST = 8;
235
273
  function planSheet(words, occurrences, opts) {
236
274
  const usage = (line) => ({ kind: "usage", line });
237
275
  const typedFlag = (names) => occurrences.find((o) => names.some((name) => o.flag === name || o.flag === `no-${name}`))?.flag;
238
- const paid = typedFlag(FIND_PAID_FLAGS);
276
+ const switchWords = new Set(occurrences.filter((o) => ["json", "yes", "wait"].includes(o.flag) && o.value !== undefined).map((o) => o.value));
277
+ const given = words.filter((word) => !(switchWords.has(word) && (ON_WORDS.has(word.toLowerCase()) || OFF_WORDS.has(word.toLowerCase()))));
278
+ if (given[0] === "people") {
279
+ const other = typedFlag([
280
+ ...FIND_PAID_FLAGS.filter((flag) => flag !== "yes" && flag !== "wait"),
281
+ ...FIND_OTHER_FLAGS.filter((flag) => flag !== "max-usd"),
282
+ "brand",
283
+ "limit",
284
+ ]);
285
+ if (other)
286
+ return usage(`video swipe sheet people takes no --${other}. Its flags: --count, --yes, --max-usd, --wait, --json.`);
287
+ const [, swipeId, ...extra] = given;
288
+ if (!swipeId)
289
+ return usage(`video swipe sheet people needs a swipe id: ${SHEET_PEOPLE_LINE}`);
290
+ if (extra.length > 0)
291
+ return usage(`video swipe sheet people takes one swipe id (got "${extra[0]}"): ${SHEET_PEOPLE_LINE}`);
292
+ const typed = occurrences.filter((o) => o.flag === "count").at(-1);
293
+ let count = null;
294
+ if (typed) {
295
+ const n = typed.value !== undefined && /^\d+$/.test(typed.value.trim()) ? Number(typed.value.trim()) : Number.NaN;
296
+ if (!(n >= 1 && n <= SHEET_PEOPLE_MOST))
297
+ return usage(`video swipe sheet people --count takes 1 to ${SHEET_PEOPLE_MOST} (got "${typed.value ?? ""}").`);
298
+ count = n;
299
+ }
300
+ if (opts.wait && !opts.yes)
301
+ return usage("video swipe sheet people --wait waits for people being made: give it with --yes, after the price.");
302
+ const most = occurrences.filter((o) => o.flag === "max-usd").at(-1);
303
+ let maxUsd = null;
304
+ if (most) {
305
+ const n = most.value !== undefined && /^\d+(\.\d+)?$/.test(most.value.trim()) ? Number(most.value.trim()) : Number.NaN;
306
+ if (!Number.isFinite(n))
307
+ return usage(`video swipe sheet people --max-usd takes the price's most in dollars, such as 0.95 (got "${most.value ?? ""}").`);
308
+ maxUsd = n;
309
+ }
310
+ if (opts.yes && maxUsd === null) {
311
+ return usage("video swipe sheet people --yes needs --max-usd <n>, the most the price said. Run it without --yes first to read the price.");
312
+ }
313
+ if (maxUsd !== null && !opts.yes)
314
+ return usage("video swipe sheet people --max-usd goes with --yes, after the price.");
315
+ return { kind: "sheet-people", swipeId, count, maxUsd, opts };
316
+ }
317
+ const setMost = given[0] === "set" ? occurrences.filter((o) => o.flag === "people-max-usd").at(-1) : undefined;
318
+ let peopleMaxUsd;
319
+ if (setMost) {
320
+ const other = typedFlag([...FIND_PAID_FLAGS.filter((flag) => flag !== "yes"), ...FIND_OTHER_FLAGS, "brand", "limit", "count"]);
321
+ if (other)
322
+ return usage(`video swipe sheet set takes no --${other}. Its flags: --yes with --people-max-usd, and --json.`);
323
+ const most = setMost.value !== undefined && !setMost.value.startsWith("--") && setMost.value.trim() ? setMost.value.trim() : null;
324
+ if (most === null)
325
+ return usage("video swipe sheet set --people-max-usd needs the most the price showed, such as 1.02.");
326
+ if (!/^\d+(\.\d{1,2})?$/.test(most))
327
+ return usage(`video swipe sheet set --people-max-usd takes a dollar amount, such as 1.02 (got "${setMost.value}").`);
328
+ if (!opts.yes)
329
+ return usage("video swipe sheet set --people-max-usd goes with --yes, after the price.");
330
+ peopleMaxUsd = Number(most);
331
+ }
332
+ const peopleOnly = typedFlag(["count"]);
333
+ if (peopleOnly)
334
+ return usage(`Only video swipe sheet people takes --${peopleOnly}.`);
335
+ if (given[0] === "set" && opts.yes && peopleMaxUsd === undefined) {
336
+ return usage("video swipe sheet set takes --yes only with --people-max-usd <n>, the most the price of a choice that buys showed. A set that buys nothing takes neither.");
337
+ }
338
+ const paid = typedFlag(peopleMaxUsd !== undefined ? FIND_PAID_FLAGS.filter((flag) => flag !== "yes") : FIND_PAID_FLAGS);
239
339
  if (paid)
240
- return usage(`video swipe sheet is free and buys nothing, so it takes no --${paid}. Its only flag is --json.`);
340
+ return usage(`video swipe sheet buys nothing, so it takes no --${paid}. Its only flag is --json.`);
241
341
  const other = typedFlag([...FIND_OTHER_FLAGS, "brand", "limit"]);
242
342
  if (other)
243
343
  return usage(`video swipe sheet takes no --${other}. Its only flag is --json.`);
244
- const switchWords = new Set(occurrences.filter((o) => o.flag === "json" && o.value !== undefined).map((o) => o.value));
245
- const given = words.filter((word) => !(switchWords.has(word) && (ON_WORDS.has(word.toLowerCase()) || OFF_WORDS.has(word.toLowerCase()))));
344
+ if (given[0] === "price") {
345
+ const [, swipeId, ...extra] = given;
346
+ if (!swipeId)
347
+ return usage(`video swipe sheet price needs a swipe id: ${SHEET_PRICE_LINE}`);
348
+ if (extra.length > 0)
349
+ return usage(`video swipe sheet price takes one swipe id (got "${extra[0]}"): ${SHEET_PRICE_LINE}`);
350
+ return { kind: "sheet-price", swipeId, opts };
351
+ }
352
+ if (given[0] === "voices") {
353
+ const [, swipeId, ...extra] = given;
354
+ if (!swipeId)
355
+ return usage("video swipe sheet voices needs a swipe id: exodus video swipe sheet voices <swipeId> [--json]");
356
+ if (extra.length > 0)
357
+ return usage(`video swipe sheet voices takes one swipe id (got "${extra[0]}").`);
358
+ return { kind: "sheet-voices", swipeId, opts };
359
+ }
246
360
  if (given[0] !== "set") {
247
361
  const [swipeId, ...extra] = given;
248
362
  if (!swipeId)
@@ -268,7 +382,7 @@ function planSheet(words, occurrences, opts) {
268
382
  const value = pair.slice(at + 1);
269
383
  picks[row] = value === "" ? null : value;
270
384
  }
271
- return { kind: "sheet-set", swipeId, picks, opts };
385
+ return { kind: "sheet-set", swipeId, picks, ...(peopleMaxUsd !== undefined ? { peopleMaxUsd } : {}), opts };
272
386
  }
273
387
  const KIND_CHECKED = "A kind this ad can't be made as is refused, with the kinds it can be made as, before the write is paid.";
274
388
  const templateKindLine = (template, kind) => kind ? `Kind of ad: ${template.kind.label}, the template's pick; the write uses ${kind}, the sheet's kind.` : `Kind of ad: ${template.kind.label}.`;
@@ -376,11 +490,14 @@ function progress(opts) {
376
490
  const POLL_MS = 5000;
377
491
  const MAX_MISSES = 3;
378
492
  const missed = (res) => res.status >= 500 || res.status === 429;
379
- async function poll(read, step, maxPolls, deps) {
493
+ async function poll(read, step, maxPolls, deps, untilMs) {
380
494
  let misses = 0;
381
495
  for (let i = 0; i < maxPolls; i++) {
382
- if (i > 0)
496
+ if (i > 0) {
383
497
  await deps.sleep(POLL_MS);
498
+ if (untilMs !== undefined && deps.now() >= untilMs)
499
+ break;
500
+ }
384
501
  const res = await read().catch(() => null);
385
502
  if (!res || missed(res)) {
386
503
  if (++misses >= MAX_MISSES)
@@ -410,6 +527,10 @@ const VIDEO_TYPES = {
410
527
  ".webm": "video/webm",
411
528
  };
412
529
  const BREAKDOWN_MAX_POLLS = 300;
530
+ export function breakdownPage(dashboardUrl, breakdownId) {
531
+ return `${dashboardUrl.replace(/\/+$/, "")}/video?door=swipe&breakdown=${encodeURIComponent(breakdownId)}`;
532
+ }
533
+ const pageLine = (dashboardUrl, breakdownId) => `Their ad on the dashboard: ${breakdownPage(dashboardUrl, breakdownId)}`;
413
534
  export async function swipeBreakdownFlow(source, opts, deps) {
414
535
  const { json } = opts;
415
536
  let file = null;
@@ -480,9 +601,12 @@ export async function swipeBreakdownFlow(source, opts, deps) {
480
601
  if (!started.breakdownId)
481
602
  return failed("The server did not say which breakdown it started.", json);
482
603
  const { breakdownId, existing } = started;
483
- const head = existing
484
- ? [`This ad already has a breakdown: ${breakdownId}. It cost nothing.`]
485
- : [`Breakdown ${breakdownId} started. It reads the ad on the team's keys, in a few minutes.`];
604
+ const head = [
605
+ existing
606
+ ? `This ad already has a breakdown: ${breakdownId}. It cost nothing.`
607
+ : `Breakdown ${breakdownId} started. It reads the ad on the team's keys, in a few minutes.`,
608
+ pageLine(deps.dashboardUrl, breakdownId),
609
+ ];
486
610
  if (!opts.wait) {
487
611
  return {
488
612
  code: 0,
@@ -541,16 +665,16 @@ async function waitForBreakdown(breakdownId, opts, deps, say) {
541
665
  return { code: 1, lines: [error, hint], json: { error, mayStillFinish: hint } };
542
666
  }
543
667
  const { read } = ended.done;
544
- return { code: read.breakdown.status === "failed" ? 1 : 0, lines: breakdownEndLines(read), json: { breakdown: read.breakdown, template: read.template } };
668
+ return { code: read.breakdown.status === "failed" ? 1 : 0, lines: breakdownEndLines(read, deps.dashboardUrl), json: { breakdown: read.breakdown, template: read.template } };
545
669
  }
546
- function breakdownEndLines({ breakdown, template }) {
670
+ function breakdownEndLines({ breakdown, template }, dashboardUrl) {
547
671
  if (breakdown.status === "failed") {
548
672
  return [
549
673
  `The breakdown failed: ${breakdown.error ?? "no reason was given."}`,
550
674
  "Reading the ad again is paid too: run the same exodus video swipe command with --yes, after the member's yes.",
551
675
  ];
552
676
  }
553
- return ["The breakdown is done.", ...spentLines(breakdown), ...nextAfterBreakdown(breakdown._id, template)];
677
+ return ["The breakdown is done.", pageLine(dashboardUrl, breakdown._id), ...spentLines(breakdown), ...nextAfterBreakdown(breakdown._id, template)];
554
678
  }
555
679
  function spentLines(breakdown) {
556
680
  if (breakdown.reused)
@@ -612,9 +736,9 @@ export async function swipeStatusFlow(breakdownId, opts, deps, full = false) {
612
736
  ...breakdown.steps.map((step) => ` ${step.status.padEnd(width)} ${step.label}`),
613
737
  ];
614
738
  if (breakdown.status === "done" || breakdown.status === "failed")
615
- lines.push(...breakdownEndLines(read));
739
+ lines.push(...breakdownEndLines(read, deps.dashboardUrl));
616
740
  else
617
- lines.push(`Wait for it: exodus video swipe status ${breakdown._id} --wait`);
741
+ lines.push(pageLine(deps.dashboardUrl, breakdown._id), `Wait for it: exodus video swipe status ${breakdown._id} --wait`);
618
742
  if (full)
619
743
  lines.push(...fullLines(isRecord(res.data) ? res.data : {}));
620
744
  return { code: 0, lines };
@@ -653,15 +777,106 @@ export function fullLines(data) {
653
777
  lines.push(` ${member.name || member.characterId} (${member.characterId}), ${EMBODIMENT[member.embodiment] ?? member.embodiment}`);
654
778
  lines.push(` Look: ${member.look}`, ` Voice: ${member.voice}`);
655
779
  }
780
+ lines.push("", ...filmingLines(full.filming, full.version));
656
781
  if (full.warnings.length > 0)
657
782
  lines.push("", "What it was not sure about:", ...full.warnings.map((warning) => ` - ${warning}`));
658
783
  return lines;
659
784
  }
785
+ const atSec = (sec) => `${sec.toFixed(1)} s`;
786
+ const fromTo = (from, to) => from !== undefined && to !== undefined ? seconds(from, to) : from !== undefined ? `from ${atSec(from)}` : to !== undefined ? `to ${atSec(to)}` : "";
787
+ const joinParts = (parts, by = ", ") => parts.filter((p) => typeof p === "string" && p !== "").join(by);
788
+ const oneLine = (text) => text.trim().replace(/\s*\n\s*/g, " / ");
789
+ const productWord = (product) => (product === true ? "the product" : product === false ? "not the product" : "");
790
+ export function filmingLines(filming, version) {
791
+ if (!filming || Object.keys(filming).length === 0) {
792
+ return [
793
+ version === "1.0"
794
+ ? "How it is filmed: this breakdown does not say (it is of version 1.0, made before Exodus read how an ad is filmed)."
795
+ : "How it is filmed: nothing was read.",
796
+ ];
797
+ }
798
+ const f = filming;
799
+ const out = [];
800
+ const line = (label, text) => {
801
+ if (text !== "")
802
+ out.push(` ${label}: ${oneLine(text)}`);
803
+ };
804
+ line("Camera", f.filmedBy ?? "");
805
+ line("Measured", f.measuredStillPct !== undefined
806
+ ? `in ${f.measuredStillPct}% of the moments the measure settled in the talking shots, most of the part of the frame it could read stood still and no larger part slid together (this does not prove the phone was put down: a still layer over most of the frame reads the same)`
807
+ : "");
808
+ line("Camera height", f.cameraHeight ?? "");
809
+ line("Camera tilt", f.cameraTilt ?? "");
810
+ line("Camera movement", f.movement ?? "");
811
+ line("Framing", f.framing ?? "");
812
+ line("Pose", joinParts([f.pose, f.body && `body: ${f.body}`], "; "));
813
+ line("Moves", (f.moves ?? []).map((m) => `${m.move} ${m.to !== undefined ? seconds(m.at, m.to) : `at ${atSec(m.at)}`}`).join("; "));
814
+ line("Holds", (f.held ?? [])
815
+ .map((h) => `${h.thing} (${joinParts([h.hands && `${h.hands} ${h.hands === "one" ? "hand" : "hands"}`, productWord(h.product), h.wholeAd ? "the whole ad" : fromTo(h.from, h.to)])})`)
816
+ .join("; "));
817
+ line("Hands", (f.handActions ?? []).map((a) => `${seconds(a.from, a.to)} ${a.does}${a.things ? `, with ${a.things}` : ""}${a.product === undefined ? "" : ` (${productWord(a.product)})`}`).join("; "));
818
+ const p = f.personLook ?? {};
819
+ line("The person", joinParts([
820
+ p.hair &&
821
+ (p.hair === "bald" || p.hair === "shaved"
822
+ ? `${p.hair} head`
823
+ : p.hair === "covered"
824
+ ? (p.hairColour ? `${p.hairColour} hair, covered` : "hair covered")
825
+ : `${joinParts([p.hair, p.hairColour], " ")} hair`),
826
+ p.hair === undefined && p.hairColour && `${p.hairColour} hair`,
827
+ p.skinTone && `${p.skinTone} skin`,
828
+ p.build && `${p.build} build`,
829
+ p.glasses && (p.glasses === "none" ? "no glasses" : p.glasses),
830
+ p.facialHair && (p.facialHair === "none" ? "no facial hair" : p.facialHair),
831
+ ]));
832
+ const placeList = (f.placeList ?? []).map((place) => joinParts([place.setting, place.line], ": ")).join("; ");
833
+ if (placeList)
834
+ line(`Places${f.places ? ` (${f.places})` : ""}`, placeList);
835
+ else
836
+ line("Places", f.places ?? "");
837
+ line("Main place", f.placeLine ?? "");
838
+ line("In view", (f.props ?? []).join(", "));
839
+ line("Light", joinParts([f.light, f.lightSource && `from ${f.lightSource}`]));
840
+ const c = f.captions;
841
+ line("Captions", c ? joinParts([c.amount, c.style, c.position, c.caps === undefined ? "" : c.caps ? "in capitals" : "not in capitals"], "; ") : "");
842
+ if ((f.inserts ?? []).length > 0) {
843
+ out.push(" Laid over the picture:");
844
+ for (const i of f.inserts ?? []) {
845
+ const when = i.secondsOn !== undefined ? `${atSec(i.at)} for ${atSec(i.secondsOn)}` : atSec(i.at);
846
+ out.push(` ${when} ${joinParts([i.part, i.where, i.widthPct !== undefined && `${i.widthPct}% wide`])}${i.words ? `: ${oneLine(i.words)}` : ""}`);
847
+ }
848
+ }
849
+ const perMinute = f.cutsPerMinute !== undefined ? `${f.cutsPerMinute} a minute` : "";
850
+ line("Cuts", f.cuts ? `${f.cuts}${perMinute ? ` (${perMinute})` : ""}` : perMinute);
851
+ line("B-roll", f.brollShare ?? "");
852
+ line("Words", f.wordsPerSecond !== undefined ? `${f.wordsPerSecond} a second` : "");
853
+ line("First seconds", f.firstSeconds ?? "");
854
+ line("How the hook is built", f.hookBuilt ?? "");
855
+ line("How it ends", f.endCard ?? "");
856
+ return ["How it is filmed:", ...(out.length > 0 ? [BY_EYE, ...out] : [" Nothing was read."])];
857
+ }
858
+ const BY_EYE = " (The video model's reading by eye, not proven: every line but Measured, taken from the frames; Words, counted by code; and Cuts, counted by code with the jump cuts the video model saw.)";
660
859
  const TEMPLATE_MAX_POLLS = 120;
860
+ function offeredOf(template) {
861
+ const list = template.offered;
862
+ if (!Array.isArray(list))
863
+ return [];
864
+ return list.filter((entry) => isRecord(entry) && typeof entry.key === "string" && typeof entry.label === "string" && typeof entry.reason === "string");
865
+ }
866
+ function offeredLine(kind, how) {
867
+ const about = typeof kind.about === "string" && kind.about.trim() !== "" ? ` ${kind.about.trim()}` : "";
868
+ return `Also fits their ad: ${kind.label} (${kind.key}).${about} ${kind.reason} If the member wants it, ${how}.`;
869
+ }
870
+ function sheetOfferedLines(template, sheet) {
871
+ if (sheet.kind !== null || sheet.sources.length !== 1)
872
+ return [];
873
+ return offeredOf(template).map((offered) => ` ${offeredLine(offered, `set "kind": "${offered.key}" in the sheet before its next run`)}`);
874
+ }
661
875
  function templateLines(template) {
662
876
  return [
663
877
  `Kind of ad: ${template.kind.label} (${template.kind.key})`,
664
878
  ` ${template.kind.why}`,
879
+ ...offeredOf(template).map((kind) => offeredLine(kind, `add --kind ${kind.key} to the write`)),
665
880
  `Look: ${template.look.label} (${template.look.slug})`,
666
881
  ` ${template.look.why}`,
667
882
  `Their ad: ${template.lines} lines, about ${Math.round(template.seconds)} s.`,
@@ -669,7 +884,7 @@ function templateLines(template) {
669
884
  }
670
885
  function nextAfterTemplate(breakdownId) {
671
886
  return [
672
- "The swipe writes this kind of ad and no other. If the member wants another kind, say so before writing.",
887
+ "The swipe writes the kind of ad it was matched to, or the one --kind names, and no other. If the member wants another kind, say so before writing.",
673
888
  "Next: pick a product (exodus video swipe products), then write (paid, on the member's key; ask first):",
674
889
  ` exodus video swipe write ${breakdownId} --product <productId> --mode whole-ad --closeness 2 --yes`,
675
890
  ];
@@ -764,6 +979,7 @@ export const FIND_OTHER_FLAGS = [
764
979
  "persona",
765
980
  "retry-refused",
766
981
  "kind",
982
+ "max-usd",
767
983
  ];
768
984
  const TEXT_MAX = 400;
769
985
  export const FIND_KIND_LINE = "The kind of an ad is known only after it is read.";
@@ -923,6 +1139,7 @@ function swipeLines(swipe, after) {
923
1139
  `Kept: ${draft.note.kept}`,
924
1140
  `Changed: ${draft.note.changed}`,
925
1141
  ...(draft.lengthGap ? [`Length: ours is about ${draft.lengthGap.ours} s, theirs about ${draft.lengthGap.theirs} s.`] : []),
1142
+ ...(draft.howClose ? [draft.howClose.sentence] : []),
926
1143
  costLine(swipe),
927
1144
  "",
928
1145
  swipe.workflowRunId && swipe.runHoldsStart === false
@@ -946,12 +1163,13 @@ export async function swipeWriteFlow(breakdownId, ask, opts, deps) {
946
1163
  if (memberScript !== undefined && !memberScript.trim())
947
1164
  return failed(`--script ${ask.scriptFile} is empty.`, json);
948
1165
  if (!opts.yes)
949
- return needsYesResult("write", json, choiceLines(ask));
1166
+ return writeNeedsYes(breakdownId, ask, json, deps);
950
1167
  const res = await deps.post(SWIPES_PATH, {
951
1168
  breakdownId,
952
1169
  productId: ask.productId,
953
1170
  request: requestOf(ask, memberScript),
954
1171
  ...(ask.kind ? { kind: ask.kind } : {}),
1172
+ ...(ask.peopleMaxUsd !== undefined ? { peopleMostUsd: ask.peopleMaxUsd } : {}),
955
1173
  });
956
1174
  if (!res.ok)
957
1175
  return swipeError(res, json);
@@ -961,6 +1179,9 @@ export async function swipeWriteFlow(breakdownId, ask, opts, deps) {
961
1179
  opts.onJob?.(job);
962
1180
  const out = progress(opts);
963
1181
  out.say("Writing the brand's version on the member's key. It takes four to nine minutes.");
1182
+ if (ask.peopleMaxUsd !== undefined) {
1183
+ out.say(`Once the script is stored, the people to pick from are made, or taken from an earlier write of this ad with at most one check of their pictures paid, and the script is read for an animal it puts in the picture, whose picture is drawn when it has one; at most ${usd(ask.peopleMaxUsd)} on the member's keys for all of it.`);
1184
+ }
964
1185
  const ended = await poll(() => deps.get(`${SWIPES_PATH}?job=${encodeURIComponent(job)}`), (polled) => {
965
1186
  if (!polled.ok)
966
1187
  return { done: { refused: polled } };
@@ -987,10 +1208,151 @@ export async function swipeWriteFlow(breakdownId, ask, opts, deps) {
987
1208
  if (dropped)
988
1209
  return failed(dropped, json, { kindDropped: true, swipeId: swipe._id });
989
1210
  const written = swipe.outcome.kind === "written";
1211
+ const people = ask.peopleMaxUsd !== undefined
1212
+ ? written
1213
+ ? await peopleAfterWrite(swipe._id, ask.peopleMaxUsd, out, deps)
1214
+ : NONE_WITH_REFUSAL
1215
+ : written && !ask.noPeople
1216
+ ? await peopleNotAsked(breakdownId, swipe, deps)
1217
+ : null;
990
1218
  if (json) {
991
- return { code: written ? 0 : 1, lines: [JSON.stringify(written ? { ok: true, swipe } : { ok: false, refused: true, swipe })] };
1219
+ const answer = written ? { ok: true, swipe, ...(people ? { people: people.json } : {}) } : { ok: false, refused: true, swipe };
1220
+ return { code: written ? 0 : 1, lines: [JSON.stringify(answer)] };
1221
+ }
1222
+ const lines = swipeLines(swipe, "write");
1223
+ const withPeople = !people ? lines : written ? [...lines.slice(0, -1), ...people.lines, "", ...lines.slice(-1)] : [...lines, ...people.lines];
1224
+ return { code: written ? 0 : 1, lines: [...out.kept, ...withPeople] };
1225
+ }
1226
+ async function writePeopleOf(breakdownId, kind, deps) {
1227
+ try {
1228
+ const res = await deps.get(`${SWIPE_WRITE_PEOPLE_PATH}?${writePeopleQuery(breakdownId, kind)}`);
1229
+ const people = res.ok && isRecord(res.data) && isRecord(res.data.people) ? res.data.people : null;
1230
+ if (!people || people.makesPeople !== true || typeof people.mostUsd !== "number" || !Array.isArray(people.lines))
1231
+ return null;
1232
+ return people;
1233
+ }
1234
+ catch {
1235
+ return null;
992
1236
  }
993
- return { code: written ? 0 : 1, lines: [...out.kept, ...swipeLines(swipe, "write")] };
1237
+ }
1238
+ async function writeNeedsYes(breakdownId, ask, json, deps) {
1239
+ const plain = needsYesResult("write", json, choiceLines(ask));
1240
+ const people = ask.noPeople ? null : await writePeopleOf(breakdownId, ask.kind, deps);
1241
+ if (!people)
1242
+ return plain;
1243
+ const yes = `--yes --people-max-usd ${mostShown(people.mostUsd)}`;
1244
+ if (json)
1245
+ return { code: 0, lines: [JSON.stringify({ ...JSON.parse(plain.lines[0]), people: { ...people, yes } })] };
1246
+ return {
1247
+ code: 0,
1248
+ lines: [
1249
+ ...plain.lines.slice(0, -1).map((line) => (line === NO_PRICE ? WRITE_NO_PRICE_PEOPLE_PRICED : line)),
1250
+ ...people.lines,
1251
+ `Ask the member. On their yes, run the same command with ${yes}: people are made only with that figure, and never cost more. --yes alone, or --no-people, writes without them.`,
1252
+ ],
1253
+ };
1254
+ }
1255
+ const WRITE_NO_PRICE_PEOPLE_PRICED = "The CLI prints no price for the script's own write: its text calls on the member's key have no figure before they run. The people's price is below.";
1256
+ const PEOPLE_MADE_WAIT_POLLS = (5 * 60_000) / POLL_MS;
1257
+ async function peopleNotAsked(breakdownId, swipe, deps) {
1258
+ const kind = swipe.outcome.kind === "written" ? swipe.outcome.draft.conceit : swipe.kind;
1259
+ const priceLine = `exodus video swipe sheet people ${swipe._id}`;
1260
+ let res;
1261
+ try {
1262
+ res = await deps.get(`${SWIPE_WRITE_PEOPLE_PATH}?${writePeopleQuery(breakdownId, kind)}`);
1263
+ }
1264
+ catch {
1265
+ res = { ok: false, status: 0, data: null };
1266
+ }
1267
+ if (!res.ok && (res.status === 0 || res.status >= 500 || res.status === 429)) {
1268
+ return {
1269
+ lines: [
1270
+ `No people to pick from were made with this write: its yes carried no --people-max-usd. Whether this kind of ad makes them could not be read. See their price (free): ${priceLine}`,
1271
+ ],
1272
+ json: { state: "unknown" },
1273
+ };
1274
+ }
1275
+ const people = res.ok && isRecord(res.data) && isRecord(res.data.people) ? res.data.people : null;
1276
+ if (people?.makesPeople !== true)
1277
+ return null;
1278
+ return {
1279
+ lines: [`No people to pick from were made with this write: its yes carried no --people-max-usd. See their price (free): ${priceLine}`],
1280
+ json: { state: "not-asked" },
1281
+ };
1282
+ }
1283
+ const writePeopleQuery = (breakdownId, kind) => `breakdownId=${encodeURIComponent(breakdownId)}${kind ? `&kind=${encodeURIComponent(kind)}` : ""}`;
1284
+ const NONE_WITH_REFUSAL = { lines: ["No people were made, and nothing was paid for them."], json: { state: "none" } };
1285
+ const peopleSheetPath = (swipeId) => `${SWIPE_SHEET_PATH}?id=${encodeURIComponent(swipeId)}&${SHEET_SOURCES_QUERY}`;
1286
+ async function untilPeopleMade(swipeId, deps, waitFor, onWait, polls = PEOPLE_MADE_WAIT_POLLS, untilMs = deps.now() + polls * POLL_MS) {
1287
+ let waited = false;
1288
+ let last;
1289
+ const ended = await poll(() => deps.get(peopleSheetPath(swipeId)), (read) => {
1290
+ const sheet = read.ok ? sheetOf(read.data) : null;
1291
+ if (!sheet)
1292
+ return { done: null };
1293
+ const who = rowOfSheet(sheet.sheet, "who");
1294
+ last = who ?? last;
1295
+ if (who?.optionsStatus?.making === true && waitFor(who)) {
1296
+ if (!waited)
1297
+ onWait(who);
1298
+ waited = true;
1299
+ return null;
1300
+ }
1301
+ return { done: { sheet: sheet.sheet, who, waited } };
1302
+ }, polls, deps, untilMs);
1303
+ return "done" in ended ? ended : { ...ended, ...(last ? { last } : {}) };
1304
+ }
1305
+ function startFilmsLine(who, swipeId) {
1306
+ if (!who || !who.options || who.options.length === 0)
1307
+ return null;
1308
+ const films = startFilmsOf(who);
1309
+ if (films === "picked")
1310
+ return `The start films person ${who.value}, your pick.`;
1311
+ if (films === "recommended")
1312
+ return `A start with no pick films person ${who.value}, the recommended one.`;
1313
+ const lead = films === "new-from-your-words" ? "The start films" : "A start with no pick films";
1314
+ return `${lead} ${castFrom(who)}, not one of these. To film one of them (free): exodus video swipe sheet set ${swipeId} who=<n>`;
1315
+ }
1316
+ function startFilmsOf(who) {
1317
+ if (typeof who.value === "number")
1318
+ return who.from === "you" ? "picked" : "recommended";
1319
+ if (typeof who.value === "string")
1320
+ return who.from === "you" ? "new-from-your-words" : "new-from-type";
1321
+ return "new-from-script";
1322
+ }
1323
+ function startFilmsJson(who) {
1324
+ return who?.options && who.options.length > 0 ? { recommended: who.recommended ?? null, films: startFilmsOf(who) } : null;
1325
+ }
1326
+ function castFrom(who) {
1327
+ if (typeof who.value !== "string")
1328
+ return "a new person cast from the script's own words about its speaker";
1329
+ return who.from === "you" ? "a new person cast from your words on the person row" : "a new person cast from their speaker's type";
1330
+ }
1331
+ async function peopleAfterWrite(swipeId, mostUsd, out, deps) {
1332
+ const look = `See them: exodus video swipe sheet ${swipeId}`;
1333
+ const askLine = `Ask for them (the price first, free): exodus video swipe sheet people ${swipeId}`;
1334
+ const ended = await untilPeopleMade(swipeId, deps, () => true, (who) => out.say(`${who.optionsStatus?.sentence ?? "Making the people."} Waiting for them, up to 5 minutes.`));
1335
+ if ("timedOut" in ended) {
1336
+ const said = ended.last?.optionsStatus?.sentence?.trim();
1337
+ return { lines: [said ? `Still not done after 5 minutes: ${said} ${look}` : `The people are still being made. ${look}`], json: { mostUsd, state: "making" } };
1338
+ }
1339
+ if ("lost" in ended || ended.done === null) {
1340
+ return { lines: [`Where the people stand could not be read. ${look}`], json: { mostUsd, state: "unknown" } };
1341
+ }
1342
+ const status = ended.done.who?.optionsStatus;
1343
+ const people = peopleLines(ended.done.sheet);
1344
+ const json = { mostUsd, status: status ?? null, people: ended.done.who?.options ?? [] };
1345
+ if (!status || status.noneYet) {
1346
+ return { lines: ["No people were made with this write, and nothing was paid for them.", askLine], json: { ...json, state: "none" } };
1347
+ }
1348
+ if (people.length === 0)
1349
+ return { lines: [status.sentence, askLine], json: { ...json, state: "failed" } };
1350
+ const films = startFilmsLine(ended.done.who, swipeId);
1351
+ const pick = typeof ended.done.who?.value === "number" ? [`Pick another (free): exodus video swipe sheet set ${swipeId} who=<n>`] : [];
1352
+ return {
1353
+ lines: [status.sentence, "People to pick from:", ...people, ...(films ? [films] : []), ...pick],
1354
+ json: { ...json, state: status.failed ? "failed" : "made", ...(startFilmsJson(ended.done.who) ?? {}) },
1355
+ };
994
1356
  }
995
1357
  export async function swipeShowFlow(swipeId, opts, deps) {
996
1358
  const res = await deps.get(`${SWIPES_PATH}?id=${encodeURIComponent(swipeId)}`);
@@ -1033,12 +1395,45 @@ export async function swipeListFlow(opts, deps) {
1033
1395
  }),
1034
1396
  };
1035
1397
  }
1036
- const FROM_WORDS = { you: "from you", "their-ad": "from their ad", kind: "from the kind of ad" };
1037
- function sheetOf(data) {
1398
+ const FROM_WORDS = { you: "from you", "their-ad": "from their ad", kind: "from the kind of ad", recommended: "recommended" };
1399
+ export { onOwnDashboard };
1400
+ function sheetOf(data, own = "") {
1038
1401
  if (!isRecord(data) || !isRecord(data.sheet) || !Array.isArray(data.sheet.sections))
1039
1402
  return null;
1040
- return { sheet: data.sheet, dashboardUrl: typeof data.dashboardUrl === "string" ? data.dashboardUrl : "" };
1403
+ return { sheet: data.sheet, dashboardUrl: onOwnDashboard(typeof data.dashboardUrl === "string" ? data.dashboardUrl : "", own) };
1404
+ }
1405
+ function optionLines(row, above, swipeId) {
1406
+ const lines = [];
1407
+ if (row.options === null)
1408
+ return lines;
1409
+ const options = row.options;
1410
+ const addressed = options.some((option) => option.pictureUrl || option.sampleUrl);
1411
+ if (addressed) {
1412
+ for (const option of options) {
1413
+ const address = option.pictureUrl ? `picture: ${option.pictureUrl}` : option.sampleUrl ? `sample: ${option.sampleUrl}` : "";
1414
+ lines.push(` ${option.id}: ${option.label}${address ? ` ${address}` : ""}`);
1415
+ }
1416
+ }
1417
+ else if (options.some((option) => option.line)) {
1418
+ for (const option of options)
1419
+ lines.push(` ${option.id} (${option.label})${option.line ? `: ${option.line}` : ""}`);
1420
+ }
1421
+ else if (options.length > 0 || !row.optionsStatus) {
1422
+ const cost = row.optionsCostUsd ? ` (showing them costs ${usd(row.optionsCostUsd)})` : "";
1423
+ const none = above ? `none until ${above.label.toLowerCase().replace(/^the /, "a ")} is set` : "none";
1424
+ const shown = options.length > 0 ? options.map((option) => `${option.id} (${option.label})`).join(", ") : none;
1425
+ lines.push(` options${cost}: ${shown}`);
1426
+ }
1427
+ if (row.optionsStatus?.sentence)
1428
+ lines.push(` ${row.optionsStatus.sentence}`);
1429
+ const noneMade = row.optionsStatus && !row.optionsStatus.making && options.length === 0 && (row.optionsStatus.asksLeft ?? 0) > 0;
1430
+ if (row.id === "who" && (row.optionsStatus?.noneYet || noneMade))
1431
+ lines.push(` See the price (free): exodus video swipe sheet people ${swipeId}`);
1432
+ if (row.id === "voice" && row.value === null)
1433
+ lines.push(` List the voices: exodus video swipe sheet voices ${swipeId}`);
1434
+ return lines;
1041
1435
  }
1436
+ const SIZE_ROW_CUT_LINE = "The takes are filmed at this size; the app cuts the finished video at 1080x1920.";
1042
1437
  export function sheetLines(sheet, dashboardUrl) {
1043
1438
  const { swipeId } = sheet;
1044
1439
  const page = dashboardUrl ? [`The swipe on the dashboard: ${dashboardUrl}`] : [];
@@ -1054,14 +1449,18 @@ export function sheetLines(sheet, dashboardUrl) {
1054
1449
  for (const section of sheet.sections) {
1055
1450
  lines.push("", section.label);
1056
1451
  for (const row of section.rows) {
1057
- const value = row.value === null ? "not set" : String(row.value);
1452
+ const picked = typeof row.value === "number" ? row.options?.find((option) => option.id === String(row.value)) : undefined;
1453
+ const none = row.none && row.value === row.none.value ? row.none : undefined;
1454
+ const value = row.value === null ? "not set" : picked ? `${row.value} (${picked.label})` : none ? `${row.value} (${none.label})` : String(row.value);
1058
1455
  lines.push(` ${row.id}${row.readOnly ? ", read only" : ""}: ${value}`);
1059
- if (row.from)
1060
- lines.push(` ${FROM_WORDS[row.from]}${row.why ? `: ${row.why}` : ""}`);
1061
- if (row.options) {
1062
- const cost = row.optionsCostUsd ? ` (showing them costs ${usd(row.optionsCostUsd)})` : "";
1063
- lines.push(` options${cost}: ${row.options.map((option) => `${option.id} (${option.label})`).join(", ")}`);
1064
- }
1456
+ const fromWords = row.from && Object.prototype.hasOwnProperty.call(FROM_WORDS, row.from) ? FROM_WORDS[row.from] : null;
1457
+ if (fromWords)
1458
+ lines.push(` ${fromWords}${row.why ? `: ${row.why}` : ""}`);
1459
+ else if (row.why)
1460
+ lines.push(` ${row.why}`);
1461
+ if (row.id === "size" && row.value !== null)
1462
+ lines.push(` ${SIZE_ROW_CUT_LINE}`);
1463
+ lines.push(...optionLines(row, section.rows[section.rows.indexOf(row) - 1], swipeId));
1065
1464
  lines.push(` ${row.usedBy ? `read by: ${row.usedBy}` : "no step reads it yet"}`);
1066
1465
  }
1067
1466
  }
@@ -1076,21 +1475,21 @@ export function sheetLines(sheet, dashboardUrl) {
1076
1475
  return lines;
1077
1476
  }
1078
1477
  export async function swipeSheetReadFlow(swipeId, opts, deps) {
1079
- const res = await deps.get(`${SWIPE_SHEET_PATH}?id=${encodeURIComponent(swipeId)}`);
1478
+ const res = await deps.get(`${SWIPE_SHEET_PATH}?id=${encodeURIComponent(swipeId)}&${SHEET_SOURCES_QUERY}`);
1080
1479
  if (!res.ok)
1081
1480
  return swipeError(res, opts.json);
1082
- const read = sheetOf(res.data);
1481
+ const read = sheetOf(res.data, deps.dashboardUrl);
1083
1482
  if (!read)
1084
1483
  return failed("The server's answer about this sheet could not be read.", opts.json);
1085
1484
  if (opts.json)
1086
1485
  return { code: 0, lines: [JSON.stringify({ ok: true, ...read })] };
1087
1486
  return { code: 0, lines: sheetLines(read.sheet, read.dashboardUrl) };
1088
1487
  }
1089
- export async function swipeSheetSetFlow(swipeId, picks, opts, deps) {
1488
+ export async function swipeSheetSetFlow(swipeId, picks, opts, deps, peopleMaxUsd) {
1090
1489
  const readAgain = `Whether it was saved is not known. Read the sheet again: exodus video swipe sheet ${swipeId}`;
1091
1490
  let res;
1092
1491
  try {
1093
- res = await deps.post(SWIPE_SHEET_PATH, { swipeId, picks });
1492
+ res = await deps.post(`${SWIPE_SHEET_PATH}?${SHEET_SOURCES_QUERY}`, { swipeId, picks, ...(peopleMaxUsd !== undefined ? { peopleMostUsd: peopleMaxUsd } : {}) });
1094
1493
  }
1095
1494
  catch (err) {
1096
1495
  const error = `The server could not be reached: ${describeFetchFailure(err)}.`;
@@ -1103,31 +1502,400 @@ export async function swipeSheetSetFlow(swipeId, picks, opts, deps) {
1103
1502
  const refused = res.status >= 400 && res.status < 500;
1104
1503
  if (opts.json)
1105
1504
  return { code: 1, lines: [JSON.stringify({ ok: false, status: res.status, error, saved: refused ? false : "unknown" })] };
1505
+ if (refused && (/Nothing was (set|saved)\.$/.test(error) || /Nothing was set or paid\./.test(error)))
1506
+ return { code: 1, lines: [error] };
1106
1507
  return { code: 1, lines: [error, refused ? "Nothing was saved." : readAgain] };
1107
1508
  }
1108
- const read = sheetOf(res.data);
1509
+ const read = sheetOf(res.data, deps.dashboardUrl);
1109
1510
  if (!read)
1110
1511
  return failed("The sheet was saved, but the server's answer could not be read: exodus video swipe sheet " + swipeId, opts.json);
1111
1512
  if (opts.json)
1112
1513
  return { code: 0, lines: [JSON.stringify({ ok: true, saved: true, ...read })] };
1113
1514
  const set = Object.keys(picks).filter((row) => picks[row] !== null);
1114
1515
  const cleared = Object.keys(picks).filter((row) => picks[row] === null);
1115
- const said = [...(set.length > 0 ? [`Saved ${set.join(", ")}.`] : []), ...(cleared.length > 0 ? [`Cleared ${cleared.join(", ")}.`] : [])];
1516
+ const rowsNow = read.sheet.sections.flatMap((section) => section.rows);
1517
+ const backToDefault = (id) => {
1518
+ const row = rowsNow.find((candidate) => candidate.id === id);
1519
+ return row?.none && row.value !== null && row.from !== "you" ? row : undefined;
1520
+ };
1521
+ const plainCleared = cleared.filter((id) => !backToDefault(id));
1522
+ const said = [
1523
+ ...(set.length > 0 ? [`Saved ${set.join(", ")}.`] : []),
1524
+ ...(plainCleared.length > 0 ? [`Cleared ${plainCleared.join(", ")}.`] : []),
1525
+ ...cleared.flatMap((id) => {
1526
+ const row = backToDefault(id);
1527
+ return row?.none ? [`Cleared ${id}, so it is back to its default, ${String(row.value)}; for ${row.none.label}, set ${id}=${row.none.value}.`] : [];
1528
+ }),
1529
+ ];
1530
+ if (read.sheet.notice)
1531
+ said.push(read.sheet.notice);
1116
1532
  return { code: 0, lines: [said.join(" "), "", ...sheetLines(read.sheet, read.dashboardUrl)] };
1117
1533
  }
1534
+ function priceOf(data, own = "") {
1535
+ if (!isRecord(data) || !isRecord(data.price) || typeof data.price.priced !== "boolean")
1536
+ return null;
1537
+ const price = data.price;
1538
+ if (price.priced && (!isRecord(price.picked) || !Array.isArray(price.options)))
1539
+ return null;
1540
+ return { price, dashboardUrl: onOwnDashboard(typeof data.dashboardUrl === "string" ? data.dashboardUrl : "", own) };
1541
+ }
1542
+ const lineUsd = (value) => (Math.abs(value * 100 - Math.round(value * 100)) < 1e-6 ? usd(value) : `$${value.toFixed(3)}`);
1543
+ function filmWords(row, scriptTakes) {
1544
+ if (row.takes === "first" && scriptTakes > 1)
1545
+ return `${row.size}, the first take only`;
1546
+ return `${row.size}, ${scriptTakes === 1 ? "its one take" : `all ${scriptTakes} takes`}`;
1547
+ }
1548
+ function priceWords(row) {
1549
+ if ("why" in row)
1550
+ return `no price: ${row.why}`;
1551
+ return `about ${usd(row.costUsd)}, at most ${usd(row.maxUsd)}${row.startRefusal ? `. The start refuses it: ${row.startRefusal}` : ""}`;
1552
+ }
1553
+ function distinctOptions(price) {
1554
+ return price.scriptTakes > 1 ? price.options : price.options.filter((row) => row.takes === "all");
1555
+ }
1556
+ function cheaperOption(price) {
1557
+ return price.options.some((row) => !("why" in row) && !row.startRefusal && row.costUsd < price.picked.costUsd);
1558
+ }
1559
+ function pickedPriceLine(price) {
1560
+ return `about ${usd(price.picked.costUsd)}, at most ${usd(price.picked.maxUsd)} (${filmWords(price.picked, price.scriptTakes)}, as the swipe's sheet stands)`;
1561
+ }
1562
+ function changeLine(price) {
1563
+ if (!price.sizeChoices)
1564
+ return "This server offers the kind's own size and every take for now: 480p and the first take only are not switched on.";
1565
+ const rows = distinctOptions(price);
1566
+ const sizes = [...new Set(rows.map((row) => row.size))];
1567
+ const takes = [...new Set(rows.map((row) => row.takes))];
1568
+ const parts = [`size=<${sizes.join(" or ")}>`, ...(takes.length > 1 ? [`takes=<${takes.join(" or ")}>`] : [])];
1569
+ return `Change it (free): exodus video swipe sheet set ${price.swipeId} ${parts.join(" ")}. The start films what the sheet says then.`;
1570
+ }
1571
+ const AT_MOST = "At most: every take and every picture ordered twice, the most the run orders for one storyboard. A change asked for after the takes are filmed, such as a new voice or the storyboard made again, films them again and is paid on top.";
1572
+ function refusalLines(price) {
1573
+ return [
1574
+ ...price.startRefusals.map((why) => `The start would be refused now: ${why}`),
1575
+ ...(price.heldBy ? [`This swipe already has a video, run ${price.heldBy}: a start makes a second, paid video only with --again.`] : []),
1576
+ ];
1577
+ }
1578
+ export function priceLines(price, dashboardUrl) {
1579
+ const page = dashboardUrl ? [`The swipe on the dashboard: ${dashboardUrl}`] : [];
1580
+ if (!price.priced)
1581
+ return [`No price for the video of swipe ${price.swipeId}: ${price.why}`, ...page];
1582
+ const lines = [
1583
+ `The video of swipe ${price.swipeId}${price.kind ? `, ${price.kind.label} (${price.kind.key})` : ""}, before the yes:`,
1584
+ `Price: ${pickedPriceLine(price)}.`,
1585
+ ...(price.picked.startRefusal ? [`The start refuses it: ${price.picked.startRefusal}`] : []),
1586
+ ...price.picked.lines.map((line) => ` ${line.what}: ${lineUsd(line.usd)}`),
1587
+ "",
1588
+ ...(price.sizeChoices ? ["Each size:", ...distinctOptions(price).map((row) => ` ${filmWords(row, price.scriptTakes)}: ${priceWords(row)}`), ""] : []),
1589
+ ...price.notes,
1590
+ price.leavesOut,
1591
+ AT_MOST,
1592
+ ...refusalLines(price),
1593
+ changeLine(price),
1594
+ ...page,
1595
+ ];
1596
+ return lines.filter((line, i) => !(line === "" && lines[i - 1] === ""));
1597
+ }
1598
+ export async function swipeSheetPriceFlow(swipeId, opts, deps) {
1599
+ const res = await deps.get(`${SWIPE_SHEET_PRICE_PATH}?id=${encodeURIComponent(swipeId)}`);
1600
+ if (!res.ok)
1601
+ return swipeError(res, opts.json);
1602
+ const read = priceOf(res.data, deps.dashboardUrl);
1603
+ if (!read)
1604
+ return failed("The server's answer about this price could not be read.", opts.json);
1605
+ if (opts.json)
1606
+ return { code: 0, lines: [JSON.stringify({ ok: true, ...read })] };
1607
+ return { code: 0, lines: priceLines(read.price, read.dashboardUrl) };
1608
+ }
1609
+ async function startNeedsYes(swipeId, step, json, again, choice, deps) {
1610
+ let price = null;
1611
+ try {
1612
+ const res = await deps.get(`${SWIPE_SHEET_PRICE_PATH}?id=${encodeURIComponent(swipeId)}`);
1613
+ price = res.ok ? (priceOf(res.data)?.price ?? null) : null;
1614
+ }
1615
+ catch {
1616
+ price = null;
1617
+ }
1618
+ if (!price?.priced)
1619
+ return needsYesResult(step, json, choice);
1620
+ const { buys, paidBy } = PAID[step];
1621
+ if (json)
1622
+ return { code: 0, lines: [JSON.stringify({ ok: false, needsYes: true, buys, paidBy, price })] };
1623
+ const before = price.picked.lines.filter((line) => line.beforeStop === true);
1624
+ const when = step === "start-one-shot"
1625
+ ? "paid from the start: the whole video is made with no stop"
1626
+ : before.length > 0
1627
+ ? `paid once the storyboard is approved, but for ${before.map((line) => `${line.what.charAt(0).toLowerCase()}${line.what.slice(1)} (${lineUsd(line.usd)})`).join(" and ")}, made before the run stops there`
1628
+ : "paid once the storyboard is approved: the run stops there first";
1629
+ return {
1630
+ code: 0,
1631
+ lines: [
1632
+ "This step costs money, so nothing was sent.",
1633
+ ...choice,
1634
+ `It buys: ${buys}`,
1635
+ `Who pays: ${paidBy}`,
1636
+ `The whole video's price: ${pickedPriceLine(price)}, ${when}.`,
1637
+ ...(price.picked.startRefusal ? [`The start refuses it: ${price.picked.startRefusal}`] : []),
1638
+ price.leavesOut,
1639
+ AT_MOST,
1640
+ ...price.startRefusals.map((why) => `The start would be refused now: ${why}`),
1641
+ ...(price.heldBy && !again ? [`This swipe already has a video, run ${price.heldBy}: this start is refused, and a second, paid video needs --again.`] : []),
1642
+ ...(cheaperOption(price) ? [`For less, set the sheet first (free): exodus video swipe sheet price ${swipeId} lists each size.`] : []),
1643
+ `Ask the member. On their yes, run the same command with --yes --max-usd ${price.picked.maxUsd.toFixed(2)}: the start is refused if it can now cost more.`,
1644
+ ],
1645
+ };
1646
+ }
1647
+ function optionsAnswerOf(data, own = "") {
1648
+ const read = sheetOf(data, own);
1649
+ if (!read || !isRecord(data) || (data.row !== "who" && data.row !== "voice"))
1650
+ return null;
1651
+ return { ...data, sheet: read.sheet, dashboardUrl: read.dashboardUrl };
1652
+ }
1653
+ const rowOfSheet = (sheet, id) => sheet.sections.flatMap((section) => section.rows).find((row) => row.id === id);
1654
+ function peopleLines(sheet) {
1655
+ const row = rowOfSheet(sheet, "who");
1656
+ return (row?.options ?? []).map((option) => ` ${option.id}: ${option.label}${option.pictureUrl ? ` picture: ${option.pictureUrl}` : ""}`);
1657
+ }
1658
+ const PEOPLE_WAIT_POLLS = (45 * 60_000) / POLL_MS;
1659
+ const mostShown = (mostUsd) => (Math.ceil(Math.round(mostUsd * 100_000) / 1000) / 100).toFixed(2);
1660
+ export async function swipeSheetPeopleFlow(swipeId, count, maxUsd, opts, deps) {
1661
+ const again = `exodus video swipe sheet people ${swipeId}${count !== null ? ` --count ${count}` : ""}`;
1662
+ let res;
1663
+ try {
1664
+ res = await deps.post(`${SWIPE_SHEET_OPTIONS_PATH}?${SHEET_SOURCES_QUERY}`, {
1665
+ swipeId,
1666
+ row: "who",
1667
+ ...(count !== null ? { count } : {}),
1668
+ ...(opts.yes ? { yes: true } : {}),
1669
+ ...(maxUsd !== null ? { mostUsd: maxUsd } : {}),
1670
+ });
1671
+ }
1672
+ catch (err) {
1673
+ const error = `The server could not be reached: ${describeFetchFailure(err)}.`;
1674
+ const look = opts.yes ? `Whether they are being made is not known. Read the sheet before asking again: exodus video swipe sheet ${swipeId}` : "Nothing was made.";
1675
+ return { code: 1, lines: opts.json ? [JSON.stringify({ ok: false, error, started: opts.yes ? "unknown" : false })] : [error, look] };
1676
+ }
1677
+ if (!res.ok) {
1678
+ if (res.status === 404)
1679
+ return swipeError(res, opts.json);
1680
+ const error = swipeErrorLine(res);
1681
+ const refused = res.status >= 400 && res.status < 500;
1682
+ const look = refused ? "Nothing was made." : `Whether they are being made is not known. Read the sheet before asking again: exodus video swipe sheet ${swipeId}`;
1683
+ return { code: 1, lines: opts.json ? [JSON.stringify({ ok: false, status: res.status, error, started: refused ? false : "unknown" })] : [error, look] };
1684
+ }
1685
+ const answer = optionsAnswerOf(res.data, deps.dashboardUrl);
1686
+ if (!answer?.price)
1687
+ return failed(`The server's answer about these people could not be read. Read the sheet: exodus video swipe sheet ${swipeId}`, opts.json);
1688
+ if (!answer.started) {
1689
+ if (opts.json)
1690
+ return { code: 0, lines: [JSON.stringify({ ok: true, started: false, price: answer.price, refusal: answer.refusal ?? null })] };
1691
+ const most = mostShown(answer.price.mostUsd);
1692
+ const next = answer.refusal
1693
+ ? [answer.refusal]
1694
+ : [`Make them (paid, on your keys, at most $${most}): ${again} --yes --max-usd ${most}`];
1695
+ return { code: 0, lines: [...answer.price.lines, "Nothing was made or paid yet.", ...next] };
1696
+ }
1697
+ const ids = answer.ids ?? [];
1698
+ const head = [
1699
+ `Making ${ids.length === 1 ? "1 new person" : `${ids.length} new people`}, numbers ${ids.join(", ")}, at most $${mostShown(answer.price.mostUsd)} on your keys.`,
1700
+ ];
1701
+ if (!opts.wait) {
1702
+ const lines = [...head, `See them as they are made: exodus video swipe sheet ${swipeId}`, `Pick one: exodus video swipe sheet set ${swipeId} who=<n>`];
1703
+ return { code: 0, lines: opts.json ? [JSON.stringify({ ok: true, started: true, ids, price: answer.price, sheet: answer.sheet, dashboardUrl: answer.dashboardUrl })] : lines };
1704
+ }
1705
+ const out = progress(opts);
1706
+ for (const line of head)
1707
+ out.say(line);
1708
+ const ended = await poll(() => deps.get(`${SWIPE_SHEET_PATH}?id=${encodeURIComponent(swipeId)}&${SHEET_SOURCES_QUERY}`), (read) => {
1709
+ if (!read.ok)
1710
+ return { done: { refused: read } };
1711
+ const sheet = sheetOf(read.data, deps.dashboardUrl);
1712
+ if (!sheet)
1713
+ return null;
1714
+ return rowOfSheet(sheet.sheet, "who")?.optionsStatus?.making === true ? null : { done: sheet };
1715
+ }, PEOPLE_WAIT_POLLS, deps);
1716
+ const stillGoing = `They may still be made: exodus video swipe sheet ${swipeId}`;
1717
+ if ("lost" in ended)
1718
+ return failed(`${LOST} ${stillGoing}`, opts.json);
1719
+ if ("timedOut" in ended)
1720
+ return failed(`The people are still being made. ${stillGoing}`, opts.json);
1721
+ if ("refused" in ended.done)
1722
+ return waitRefused(ended.done.refused, stillGoing, opts.json);
1723
+ const { sheet, dashboardUrl } = ended.done;
1724
+ const status = rowOfSheet(sheet, "who")?.optionsStatus;
1725
+ if (opts.json)
1726
+ return { code: 0, lines: [JSON.stringify({ ok: true, started: true, ids, status: status ?? null, sheet, dashboardUrl })] };
1727
+ const people = peopleLines(sheet);
1728
+ return {
1729
+ code: status?.failed ? 1 : 0,
1730
+ lines: [
1731
+ ...out.kept,
1732
+ ...(status?.sentence ? [status.sentence] : []),
1733
+ ...(people.length > 0 ? ["People to pick from:", ...people, `Pick one: exodus video swipe sheet set ${swipeId} who=<n>`] : []),
1734
+ ],
1735
+ };
1736
+ }
1737
+ async function maxUsdUnsupported(swipeId, maxUsd, deps) {
1738
+ const cannot = `so it can't hold this start to ${usd(maxUsd)}, and nothing was started.`;
1739
+ try {
1740
+ const res = await deps.get(`${SWIPE_SHEET_PRICE_PATH}?id=${encodeURIComponent(swipeId)}`);
1741
+ return missingRouteLine(res, "exodus video swipe start --max-usd") ? `This server has no price before the yes, ${cannot}` : null;
1742
+ }
1743
+ catch {
1744
+ return `The server could not be asked whether it holds a start to a price, ${cannot}`;
1745
+ }
1746
+ }
1747
+ function recommendedVoiceLines(row) {
1748
+ const labelOf = (id) => row.options?.find((option) => option.id === id)?.label ?? id;
1749
+ if (row.from === "recommended" && typeof row.value === "number") {
1750
+ return [`Recommended: ${row.value} (${labelOf(String(row.value))}).${row.why ? ` ${row.why}` : ""} A start with no pick films it.`];
1751
+ }
1752
+ if (row.recommended !== undefined && row.from === "you" && row.value !== null) {
1753
+ const picked = String(row.value) === row.recommended ? "You picked it, so a start films it." : `You picked ${row.value}, so a start films your pick.`;
1754
+ return [`Recommended: ${row.recommended} (${labelOf(row.recommended)}). ${picked}`];
1755
+ }
1756
+ return row.value === null && row.why ? [row.why] : [];
1757
+ }
1758
+ export async function swipeSheetVoicesFlow(swipeId, opts, deps) {
1759
+ const res = await deps.post(`${SWIPE_SHEET_OPTIONS_PATH}?${SHEET_SOURCES_QUERY}`, { swipeId, row: "voice" });
1760
+ if (!res.ok)
1761
+ return swipeError(res, opts.json);
1762
+ const answer = optionsAnswerOf(res.data, deps.dashboardUrl);
1763
+ if (!answer)
1764
+ return failed(`The server's answer about the voices could not be read. Read the sheet: exodus video swipe sheet ${swipeId}`, opts.json);
1765
+ const row = rowOfSheet(answer.sheet, "voice");
1766
+ if (opts.json)
1767
+ return { code: 0, lines: [JSON.stringify({ ok: true, voices: row?.options ?? [], status: row?.optionsStatus ?? null, sheet: answer.sheet, dashboardUrl: answer.dashboardUrl })] };
1768
+ const voices = (row?.options ?? []).map((option) => ` ${option.id}: ${option.label}${option.sampleUrl ? ` sample: ${option.sampleUrl}` : ""}`);
1769
+ return {
1770
+ code: 0,
1771
+ lines: [
1772
+ ...(row?.optionsStatus?.sentence ? [row.optionsStatus.sentence] : []),
1773
+ ...voices,
1774
+ ...(row ? recommendedVoiceLines(row) : []),
1775
+ ...(voices.length > 0 ? [`Pick one (free): exodus video swipe sheet set ${swipeId} voice=<n>. The video is then filmed in that voice.`] : []),
1776
+ ],
1777
+ };
1778
+ }
1779
+ async function peopleBeforeStart(swipeId, opts, deps, read) {
1780
+ const first = read !== undefined ? read : await readSheetForStart(swipeId, deps);
1781
+ const who = first ? rowOfSheet(first.sheet, "who") : undefined;
1782
+ if (!who)
1783
+ return null;
1784
+ if (!who.optionsStatus?.making || who.from === "you") {
1785
+ const films = startFilmsLine(who, swipeId);
1786
+ return films ? { lines: [films], stillMaking: false, waited: false, who } : null;
1787
+ }
1788
+ const aged = typeof who.optionsStatus.makingForMs === "number";
1789
+ const leftMs = PEOPLE_MADE_WAIT_MS - (aged ? Math.max(0, who.optionsStatus.makingForMs ?? 0) : 0);
1790
+ if (leftMs <= 0)
1791
+ return { lines: [goesOnLine(who, aged)], stillMaking: true, waited: false, who };
1792
+ const out = progress(opts);
1793
+ out.say(checksOnly(who, aged)
1794
+ ? "The pictures of the people to pick from are being checked for this swipe. The start waits for the check, until 5 minutes after it started, so a start with no pick films the one it recommends."
1795
+ : `People to pick from are being made for this swipe. The start waits for them, ${aged ? "until 5 minutes after they were asked for" : "up to 5 minutes"}, so a start with no pick films the one a check of their faces recommends.`);
1796
+ const ended = await untilPeopleMade(swipeId, deps, (row) => row.from !== "you", () => undefined, Math.ceil(leftMs / POLL_MS), deps.now() + leftMs);
1797
+ if ("timedOut" in ended || "lost" in ended || ended.done === null) {
1798
+ const last = ("timedOut" in ended || "lost" in ended ? ended.last : undefined) ?? who;
1799
+ const why = "timedOut" in ended ? undefined : "Where the people stand could not be read";
1800
+ return { lines: [...out.kept, goesOnLine(last, aged, why)], stillMaking: true, waited: true, who: last };
1801
+ }
1802
+ const sentence = ended.done.who?.optionsStatus?.sentence;
1803
+ const films = startFilmsLine(ended.done.who, swipeId);
1804
+ return { lines: [...out.kept, ...(sentence ? [sentence] : []), ...(films ? [films] : [])], stillMaking: false, waited: true, who: ended.done.who };
1805
+ }
1806
+ const PEOPLE_MADE_WAIT_MS = 5 * 60_000;
1807
+ async function readSheetForStart(swipeId, deps) {
1808
+ try {
1809
+ const res = await deps.get(peopleSheetPath(swipeId));
1810
+ return res.ok ? sheetOf(res.data) : null;
1811
+ }
1812
+ catch {
1813
+ return null;
1814
+ }
1815
+ }
1816
+ export const ANIMAL_WAIT_LINE = "The animal the script puts in the picture is being found and drawn for this swipe. The start waits for it, until 5 minutes after the write asked for it, so the video films the one on the sheet and does not pay to find and draw it again.";
1817
+ export const ANIMAL_GOES_ON_LINE = "The animal is still being found or drawn 5 minutes after the write asked for it, so the start goes on: the video looks for an animal in the script itself and draws one when it finds one.";
1818
+ async function animalBeforeStart(swipeId, first, opts, deps) {
1819
+ const animal = first ? rowOfSheet(first.sheet, "animal") : undefined;
1820
+ if (animal?.optionsStatus?.making !== true)
1821
+ return { sheet: first, lines: [] };
1822
+ const out = progress(opts);
1823
+ const leftMs = PEOPLE_MADE_WAIT_MS - Math.max(0, animal.optionsStatus.makingForMs ?? 0);
1824
+ if (leftMs <= 0) {
1825
+ out.say(ANIMAL_GOES_ON_LINE);
1826
+ return { sheet: first, lines: out.kept };
1827
+ }
1828
+ out.say(ANIMAL_WAIT_LINE);
1829
+ let last = first;
1830
+ const ended = await poll(() => deps.get(peopleSheetPath(swipeId)), (res) => {
1831
+ const sheet = res.ok ? sheetOf(res.data) : null;
1832
+ if (!sheet)
1833
+ return { done: false };
1834
+ last = sheet;
1835
+ return rowOfSheet(sheet.sheet, "animal")?.optionsStatus?.making === true ? null : { done: true };
1836
+ }, Math.ceil(leftMs / POLL_MS), deps, deps.now() + leftMs);
1837
+ if (!("done" in ended) || !ended.done)
1838
+ out.say(ANIMAL_GOES_ON_LINE);
1839
+ return { sheet: last, lines: out.kept };
1840
+ }
1841
+ const checksOnly = (who, aged) => aged && who.optionsStatus?.making === true && typeof who.optionsStatus.count !== "number";
1842
+ function goesOnLine(who, aged, why) {
1843
+ const checking = checksOnly(who, aged);
1844
+ why ??= checking
1845
+ ? "The check of their pictures is still running 5 minutes after it started"
1846
+ : aged
1847
+ ? "The people are still being made 5 minutes after they were asked for"
1848
+ : "The people are still being made after 5 minutes";
1849
+ const films = typeof who.value === "number"
1850
+ ? who.from === "you"
1851
+ ? `it films person ${who.value}, your pick`
1852
+ : `it films person ${who.value}, the recommended one`
1853
+ : `it films ${castFrom(who)}, not one of ${checking ? "these" : "the people being made"}`;
1854
+ return `${why}, so the start goes on with the sheet as it stands now: ${films}. They stay on the sheet for a next video.`;
1855
+ }
1856
+ function withPeopleWait(result, people, json) {
1857
+ if (!json)
1858
+ return { ...result, lines: [...people.lines, ...result.lines] };
1859
+ if (result.lines.length !== 1)
1860
+ return result;
1861
+ const films = startFilmsJson(people.who);
1862
+ try {
1863
+ const answer = JSON.parse(result.lines[0]);
1864
+ return {
1865
+ ...result,
1866
+ lines: [JSON.stringify({ ...answer, ...(people.waited || people.stillMaking ? { peopleWait: { stillMaking: people.stillMaking } } : {}), ...(films ? { startFilms: films } : {}) })],
1867
+ };
1868
+ }
1869
+ catch {
1870
+ return result;
1871
+ }
1872
+ }
1118
1873
  export const SWIPE_ALREADY_STARTED_CODE = "SWIPE_ALREADY_STARTED";
1119
1874
  export function alreadyStartedOf(res) {
1120
1875
  if (res.ok || res.status !== 409 || !isRecord(res.data) || !isRecord(res.data.error))
1121
1876
  return null;
1122
- const { code, runId, url } = res.data.error;
1877
+ const { code, runId } = res.data.error;
1123
1878
  if (code !== SWIPE_ALREADY_STARTED_CODE || typeof runId !== "string" || !runId)
1124
1879
  return null;
1125
- return { runId, url: typeof url === "string" ? url : "" };
1880
+ return { runId };
1126
1881
  }
1127
- export async function swipeStartFlow(swipeId, ask, opts, deps, again = false) {
1882
+ export async function swipeStartFlow(swipeId, ask, opts, deps, again = false, waitPeople = false) {
1128
1883
  const { json } = opts;
1129
1884
  if (!opts.yes) {
1130
- return needsYesResult(ask.oneShot ? "start-one-shot" : "start", json, again ? ["With --again: a second video from this swipe, even if it already has one. It is paid on its own."] : []);
1885
+ return startNeedsYes(swipeId, ask.oneShot ? "start-one-shot" : "start", json, again, again ? ["With --again: a second video from this swipe, even if it already has one. It is paid on its own."] : [], deps);
1886
+ }
1887
+ const animal = waitPeople ? await animalBeforeStart(swipeId, await readSheetForStart(swipeId, deps), opts, deps) : null;
1888
+ const people = waitPeople ? await peopleBeforeStart(swipeId, opts, deps, animal?.sheet ?? null) : null;
1889
+ if (people)
1890
+ return withPeopleWait(await swipeStartFlow(swipeId, ask, opts, deps, again), { ...people, lines: [...(animal?.lines ?? []), ...people.lines] }, json);
1891
+ if (animal && animal.lines.length > 0) {
1892
+ const result = await swipeStartFlow(swipeId, ask, opts, deps, again);
1893
+ return json ? result : { ...result, lines: [...animal.lines, ...result.lines] };
1894
+ }
1895
+ if (ask.maxUsd !== undefined) {
1896
+ const unheld = await maxUsdUnsupported(swipeId, ask.maxUsd, deps);
1897
+ if (unheld)
1898
+ return failed(unheld, json);
1131
1899
  }
1132
1900
  const res = await deps.post(SWIPE_RUNS_PATH, {
1133
1901
  swipeId,
@@ -1136,17 +1904,20 @@ export async function swipeStartFlow(swipeId, ask, opts, deps, again = false) {
1136
1904
  ...(ask.music ? { music: true } : {}),
1137
1905
  ...(ask.oneShot ? {} : { reviewStoryboard: true }),
1138
1906
  ...(again ? { again: true } : {}),
1907
+ ...(ask.maxUsd !== undefined ? { maxUsd: ask.maxUsd } : {}),
1139
1908
  });
1909
+ const pageOf = (runId) => customerRunPage(deps.dashboardUrl, runId);
1140
1910
  const held = alreadyStartedOf(res);
1141
1911
  if (held) {
1142
1912
  const error = `Swipe ${swipeId} already has a video, so nothing was started: run ${held.runId}.`;
1913
+ const heldPage = { runId: held.runId, url: pageOf(held.runId) };
1143
1914
  if (json)
1144
- return { code: 1, lines: [JSON.stringify({ ok: false, status: res.status, error, alreadyStarted: held })] };
1915
+ return { code: 1, lines: [JSON.stringify({ ok: false, status: res.status, error, alreadyStarted: heldPage })] };
1145
1916
  return {
1146
1917
  code: 1,
1147
1918
  lines: [
1148
1919
  error,
1149
- held.url ? `Watch it: ${held.url}` : `Check it: exodus video status ${held.runId}`,
1920
+ `Watch it: ${heldPage.url}`,
1150
1921
  `A second video from this swipe is paid on its own. Only on the member's yes to a second video: exodus video swipe start ${swipeId} --again --yes`,
1151
1922
  ],
1152
1923
  };
@@ -1156,9 +1927,9 @@ export async function swipeStartFlow(swipeId, ask, opts, deps, again = false) {
1156
1927
  const customer = customerAnswer(res.data);
1157
1928
  const data = isRecord(res.data) ? res.data : {};
1158
1929
  const runId = customer?.runId ?? (typeof data.runId === "string" ? data.runId : "");
1159
- const url = customer?.dashboardUrl ?? (typeof data.url === "string" ? data.url : "");
1160
1930
  if (!runId)
1161
1931
  return failed("The server started the ad but did not say which run it is.", json);
1932
+ const url = pageOf(runId);
1162
1933
  const card = isRecord(data.card) ? data.card : null;
1163
1934
  const label = (value) => (isRecord(value) && typeof value.label === "string" ? value.label : null);
1164
1935
  const head = [
@@ -1178,7 +1949,7 @@ export async function swipeStartFlow(swipeId, ask, opts, deps, again = false) {
1178
1949
  "",
1179
1950
  ask.oneShot
1180
1951
  ? "The app approves the storyboard itself if its checks pass. It only stops for you if they find a problem."
1181
- : "It stops at the storyboard for the member's yes. Nothing else is bought before then.",
1952
+ : "It stops at the storyboard for the member's yes. The voices and clips are bought only after that yes.",
1182
1953
  `Check in whenever: exodus video status ${runId}`,
1183
1954
  ],
1184
1955
  };
@@ -2046,6 +2817,7 @@ async function runSheetSource(item, videos, ctx) {
2046
2817
  say(started.existing === true
2047
2818
  ? ` This ad already has a breakdown: ${src.breakdownId}. It cost nothing.`
2048
2819
  : ` Breakdown ${src.breakdownId} started. It reads the ad on the team's keys, in a few minutes.`);
2820
+ say(` ${pageLine(deps.dashboardUrl, src.breakdownId)}`);
2049
2821
  }
2050
2822
  else {
2051
2823
  say(` Breakdown ${src.breakdownId}, from before.`);
@@ -2094,6 +2866,8 @@ async function runSheetSource(item, videos, ctx) {
2094
2866
  src.lastError = null;
2095
2867
  touch(src);
2096
2868
  say(` ${templateKindLine(template, sheet.kind)} Look: ${template.look.label}. The template was made before, so it cost nothing.`);
2869
+ for (const line of sheetOfferedLines(template, sheet))
2870
+ say(line);
2097
2871
  }
2098
2872
  else {
2099
2873
  const at = stamp(deps);
@@ -2118,6 +2892,8 @@ async function runSheetSource(item, videos, ctx) {
2118
2892
  src.lastError = null;
2119
2893
  touch(src);
2120
2894
  say(` ${templateKindLine(view, sheet.kind)} Look: ${view.look.label}.`);
2895
+ for (const line of sheetOfferedLines(view, sheet))
2896
+ say(line);
2121
2897
  }
2122
2898
  }
2123
2899
  }
@@ -2198,7 +2974,7 @@ async function runSheetSource(item, videos, ctx) {
2198
2974
  jobNamed = true;
2199
2975
  touch(write);
2200
2976
  };
2201
- const wrote = answerOf(await swipeWriteFlow(breakdownId, { productId: ctx.productId, ...sheetWrite.ask }, { json: true, yes: true, wait: false, onJob }, deps));
2977
+ const wrote = answerOf(await swipeWriteFlow(breakdownId, { productId: ctx.productId, ...sheetWrite.ask, noPeople: true }, { json: true, yes: true, wait: false, onJob }, deps));
2202
2978
  if (!isRecord(wrote.swipe)) {
2203
2979
  if (!jobNamed && postRefused(wrote))
2204
2980
  write.pending = null;
@@ -2430,6 +3206,8 @@ function runStateWord(data) {
2430
3206
  return "failed";
2431
3207
  if (run.isTerminal)
2432
3208
  return "done";
3209
+ if (run.appCut === "making")
3210
+ return "running";
2433
3211
  if (run.status === "awaiting-approval" || run.status === "awaiting-review") {
2434
3212
  const parked = run.nodes.find((node) => node.nodeId === run.pausedNodeId);
2435
3213
  return run.pauseReason === undefined && parked && ["scene-frames", "storyboard"].includes(parked.kind) ? "storyboard" : "waiting";
@@ -2898,11 +3676,17 @@ export async function runSwipePlan(plan, deps, onProgressLine) {
2898
3676
  case "find":
2899
3677
  return swipeFindFlow(plan.ask, opts, deps);
2900
3678
  case "start":
2901
- return swipeStartFlow(plan.swipeId, plan.ask, opts, deps, plan.again);
3679
+ return swipeStartFlow(plan.swipeId, plan.ask, opts, deps, plan.again, true);
2902
3680
  case "sheet":
2903
3681
  return swipeSheetReadFlow(plan.swipeId, opts, deps);
2904
3682
  case "sheet-set":
2905
- return swipeSheetSetFlow(plan.swipeId, plan.picks, opts, deps);
3683
+ return swipeSheetSetFlow(plan.swipeId, plan.picks, opts, deps, plan.peopleMaxUsd);
3684
+ case "sheet-price":
3685
+ return swipeSheetPriceFlow(plan.swipeId, opts, deps);
3686
+ case "sheet-people":
3687
+ return swipeSheetPeopleFlow(plan.swipeId, plan.count, plan.maxUsd, opts, deps);
3688
+ case "sheet-voices":
3689
+ return swipeSheetVoicesFlow(plan.swipeId, opts, deps);
2906
3690
  case "run":
2907
3691
  return swipeSheetFlow(plan.sheetFile, { ...opts, retryRefused: plan.retryRefused, status: plan.status, persona: plan.persona }, deps);
2908
3692
  }