@aicopycoders/exodus 2026.11.1100-beta.7 → 2026.11.1100-beta.8

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.
@@ -700,17 +700,18 @@ step 3 comes once every video has started:
700
700
  to "End: watch and approve" (pull, cut, upload, the run page). A run that
701
701
  stopped at the storyboard goes to stop 3, then the end.
702
702
 
703
- **Never start the same swipe twice.** Each start is a second, paid video.
704
- Before any second start of a swipe, run `exodus video swipe show <swipeId>`:
705
- when it prints "It started run <runId>", the run started, so follow it with
706
- `exodus video status <runId>`. Before writing again after a write whose wait
707
- was cut off, run `exodus video swipe list`. It lists the newest first, and
708
- the writes run one at a time, so a row for that ad above the last swipe id
709
- you noted (any row for it, when you noted none), with no run and not marked
710
- refused, is that write. Show it with `exodus video swipe show <swipeId>` and
711
- start it instead of writing again. A row marked refused is that write's
712
- refusal: report it as a refused write. When no such row is there yet, the write may
713
- still finish: check again later.
703
+ **Never start the same swipe twice.** One swipe is one video. A start of a
704
+ swipe that already has a video is refused, starts nothing, and names the run:
705
+ follow that run with `exodus video status <runId>`. `--again` makes a second,
706
+ paid video from the same swipe: use it only when the member asks for a second
707
+ video. Before writing again after a write whose wait was cut off, run
708
+ `exodus video swipe list`. It lists the newest first, each with when it was
709
+ written and its product, and the writes run one at a time, so a row for that
710
+ ad and product above the last swipe id you noted (any row for it, when you
711
+ noted none), with no run and not marked refused, is that write. Show it with
712
+ `exodus video swipe show <swipeId>` and start it instead of writing again. A
713
+ row marked refused is that write's refusal: report it as a refused write. When
714
+ no such row is there yet, the write may still finish: check again later.
714
715
 
715
716
  At the end, report each video on one line: its ad and persona, its run id
716
717
  and its `Watch it:` link, or why it stopped.
@@ -927,7 +928,8 @@ after their yes.
927
928
  `--title "<name>"` names the ad, for admins only: a beta tester leaves it
928
929
  off, or the CLI refuses it with one sentence naming it. With `--one-shot`
929
930
  it buys the whole video with no stop: ask before passing it. `--wait` waits until the run needs the
930
- member.
931
+ member. A swipe that already has a video is refused, with its run; a
932
+ second video from it needs `--again` and the member's yes to a second video.
931
933
  6. **Then** stop 3 (the storyboard) and the end, as above.
932
934
 
933
935
  ### Every swipe command
@@ -942,10 +944,12 @@ exodus video swipe products the brand's products a
942
944
  exodus video swipe write <breakdownId> --product <id> [--mode <mode>] [--closeness <step>] [--look <slug>] [--script <file>] [--yes]
943
945
  the brand's version (member's key); waits for it
944
946
  exodus video swipe show <swipeId> one swipe again
945
- exodus video swipe list the brand's newest swipes; a refused one shows what it cost
947
+ exodus video swipe list the brand's newest swipes, each with when it was written and its product;
948
+ a refused one shows what it cost
946
949
  exodus video swipe find [--brand "<name>"] [--limit <n>] video ads in the swipe library to offer as options (free); no kind, no results
947
- exodus video swipe start <swipeId> [--style <look>] [--title "<name>"] [--music] [--one-shot] [--yes] [--wait]
948
- start the run on the kind the swipe wrote
950
+ exodus video swipe start <swipeId> [--style <look>] [--title "<name>"] [--music] [--one-shot] [--again] [--yes] [--wait]
951
+ start the run on the kind the swipe wrote; --again for a
952
+ second, paid video of a swipe that already has one
949
953
  exodus video swipe run --sheet <file> [--status] [--persona <name>] [--yes] [--retry-refused] [--wait] every video of a sheet saved as a JSON file
950
954
  ```
951
955
 
@@ -1,4 +1,5 @@
1
1
  import type { FlagOccurrence } from "../lib/args.js";
2
+ import type { ApiResponse } from "../lib/client.js";
2
3
  import { type FlowResult, type VideoDeps } from "./video.js";
3
4
  export declare const SWIPE_BREAKDOWNS_PATH = "/api/v2/video/breakdowns";
4
5
  export declare const SWIPE_UPLOAD_URL_PATH = "/api/v2/video/breakdowns/upload-url";
@@ -106,6 +107,7 @@ export interface SwipeView {
106
107
  checksFound?: string[];
107
108
  workflowRunId: string | null;
108
109
  costUsd: number | null;
110
+ runHoldsStart?: boolean;
109
111
  }
110
112
  export interface SwipeListRow {
111
113
  _id: string;
@@ -120,11 +122,16 @@ export interface SwipeListRow {
120
122
  sourceKind: string;
121
123
  sourceUrl?: string;
122
124
  fileName?: string;
125
+ sourceAdId?: string;
123
126
  } | null;
124
127
  outcome?: {
125
128
  kind: "written" | "refused";
126
129
  };
127
130
  costUsd?: number | null;
131
+ product?: {
132
+ id: string;
133
+ name: string;
134
+ } | null;
128
135
  }
129
136
  type ServerMode = "whole" | "hook" | "their-format" | "new-look";
130
137
  export declare const SWIPE_MODES: ReadonlyArray<{
@@ -215,6 +222,7 @@ export type SwipePlan = {
215
222
  kind: "start";
216
223
  swipeId: string;
217
224
  ask: StartAsk;
225
+ again: boolean;
218
226
  opts: SwipeOpts;
219
227
  } | {
220
228
  kind: "run";
@@ -264,7 +272,7 @@ export declare function fullLines(data: Record<string, unknown>): string[];
264
272
  export declare function swipeTemplateFlow(breakdownId: string, opts: SwipeRunOptions, deps: VideoDeps): Promise<FlowResult>;
265
273
  export declare function swipeProductsFlow(opts: SwipeOpts, deps: VideoDeps): Promise<FlowResult>;
266
274
  export declare const FIND_READ = 200;
267
- export declare const FIND_PAID_FLAGS: readonly ["yes", "wait", "file", "url", "ad"];
275
+ export declare const FIND_PAID_FLAGS: readonly ["yes", "wait", "file", "url", "ad", "again"];
268
276
  export declare const FIND_OTHER_FLAGS: readonly ["one-shot", "music", "mode", "closeness", "product", "look", "script", "style", "title", "sheet", "full", "status", "persona", "retry-refused"];
269
277
  export declare const FIND_KIND_LINE = "The kind of an ad is known only after it is read.";
270
278
  export declare const FIND_EMPTY_LIBRARY = "The swipe library has no ads yet for this brand.";
@@ -306,7 +314,12 @@ export declare function swipeFindFlow(ask: FindAsk, opts: SwipeOpts, deps: Video
306
314
  export declare function swipeWriteFlow(breakdownId: string, ask: WriteAsk, opts: SwipeRunOptions, deps: VideoDeps): Promise<FlowResult>;
307
315
  export declare function swipeShowFlow(swipeId: string, opts: SwipeOpts, deps: VideoDeps): Promise<FlowResult>;
308
316
  export declare function swipeListFlow(opts: SwipeOpts, deps: VideoDeps): Promise<FlowResult>;
309
- export declare function swipeStartFlow(swipeId: string, ask: StartAsk, opts: SwipeRunOptions, deps: VideoDeps): Promise<FlowResult>;
317
+ export declare const SWIPE_ALREADY_STARTED_CODE = "SWIPE_ALREADY_STARTED";
318
+ export declare function alreadyStartedOf(res: ApiResponse<unknown>): {
319
+ runId: string;
320
+ url: string;
321
+ } | null;
322
+ export declare function swipeStartFlow(swipeId: string, ask: StartAsk, opts: SwipeRunOptions, deps: VideoDeps, again?: boolean): Promise<FlowResult>;
310
323
  export declare const SHEET_FIELDS: readonly ["sources", "product", "personas", "mechanism", "guidance", "mode", "closeness", "look", "script", "characters", "finish", "oneShot", "style", "title", "music"];
311
324
  export declare const SHEET_VIDEO_WARNING = 6;
312
325
  export interface SheetSource {
@@ -374,6 +387,7 @@ export interface WritePending {
374
387
  export interface StartPending {
375
388
  at: string;
376
389
  swipeId: string;
390
+ serverAt?: number;
377
391
  }
378
392
  export interface SheetRunState {
379
393
  runId: string | null;
@@ -425,6 +439,7 @@ export interface SheetFiles {
425
439
  host: string;
426
440
  isAlive(pid: number): boolean;
427
441
  realPath(file: string): string;
442
+ listDir(dir: string): string[];
428
443
  onStop(cleanup: () => void): () => void;
429
444
  }
430
445
  export type SheetDeps = VideoDeps & {
@@ -432,6 +447,7 @@ export type SheetDeps = VideoDeps & {
432
447
  };
433
448
  export declare const nodeSheetFiles: SheetFiles;
434
449
  export declare const sheetLockPath: (sheetFile: string) => string;
450
+ export declare const sheetTakeoverPath: (sheetFile: string) => string;
435
451
  export type SheetVideoState = "not started" | "breakdown" | "template" | "written" | "refused" | "running" | "storyboard" | "waiting" | "done" | "failed" | "unread";
436
452
  export interface SheetFlowOptions extends SwipeRunOptions {
437
453
  retryRefused: boolean;
@@ -96,10 +96,11 @@ const SHEET_FLAGS = [
96
96
  ["url", 'list the ad in the sheet\'s "sources".'],
97
97
  ["ad", 'list the ad in the sheet\'s "sources".'],
98
98
  ["full", "--full is for exodus video swipe status."],
99
+ ["again", "a sheet never starts a swipe twice. For a second video of one swipe, use exodus video swipe start <swipeId> --again."],
99
100
  ];
100
101
  const OFF_WORDS = new Set(["false", "no", "off", "0"]);
101
102
  const ON_WORDS = new Set(["true", "yes", "on", "1"]);
102
- const SWITCHES = ["json", "yes", "wait", "full", "music", "one-shot", "retry-refused", "status"];
103
+ const SWITCHES = ["json", "yes", "wait", "full", "music", "one-shot", "retry-refused", "status", "again"];
103
104
  export function planSwipeCommand(rest, occurrences) {
104
105
  const last = (name) => occurrences.filter((o) => o.flag === name || o.flag === `no-${name}`).at(-1);
105
106
  const switchState = (name) => {
@@ -207,7 +208,7 @@ export function planSwipeCommand(rest, occurrences) {
207
208
  const start = startChoicesOf({ style: value("style"), title: value("title"), music: on("music"), oneShot: on("one-shot") }, CLI_WORDS.start);
208
209
  if ("problem" in start)
209
210
  return usage(start.problem);
210
- return { kind: "start", swipeId: id, ask: start.ask, opts };
211
+ return { kind: "start", swipeId: id, ask: start.ask, again: on("again"), opts };
211
212
  }
212
213
  const product = value("product");
213
214
  if (!product)
@@ -680,7 +681,7 @@ export const FIND_READ = 200;
680
681
  const FIND_MAX = FIND_READ;
681
682
  const FIND_DEFAULT_LIMIT = 30;
682
683
  const FIRST_LINE_MAX = 60;
683
- export const FIND_PAID_FLAGS = ["yes", "wait", "file", "url", "ad"];
684
+ export const FIND_PAID_FLAGS = ["yes", "wait", "file", "url", "ad", "again"];
684
685
  export const FIND_OTHER_FLAGS = [
685
686
  "one-shot",
686
687
  "music",
@@ -845,9 +846,11 @@ function swipeLines(swipe, after) {
845
846
  ...(draft.lengthGap ? [`Length: ours is about ${draft.lengthGap.ours} s, theirs about ${draft.lengthGap.theirs} s.`] : []),
846
847
  costLine(swipe),
847
848
  "",
848
- swipe.workflowRunId
849
- ? `It started run ${swipe.workflowRunId}: exodus video status ${swipe.workflowRunId}. Another start is a second, paid video.`
850
- : `Start the video (paid; ask first): exodus video swipe start ${swipe._id} --yes`,
849
+ swipe.workflowRunId && swipe.runHoldsStart === false
850
+ ? `It started run ${swipe.workflowRunId}, which failed or was cancelled: exodus video status ${swipe.workflowRunId}. Starting the swipe again is paid (ask first): exodus video swipe start ${swipe._id} --yes`
851
+ : swipe.workflowRunId
852
+ ? `It started run ${swipe.workflowRunId}: exodus video status ${swipe.workflowRunId}. A second video from this swipe is paid on its own and needs --again (ask first): exodus video swipe start ${swipe._id} --again --yes`
853
+ : `Start the video (paid; ask first): exodus video swipe start ${swipe._id} --yes`,
851
854
  ];
852
855
  }
853
856
  export async function swipeWriteFlow(breakdownId, ask, opts, deps) {
@@ -913,6 +916,7 @@ export async function swipeShowFlow(swipeId, opts, deps) {
913
916
  return { code: 0, lines: [JSON.stringify({ ok: true, swipe })] };
914
917
  return { code: 0, lines: swipeLines(swipe, "show") };
915
918
  }
919
+ const writtenAt = (ms) => `${new Date(ms).toISOString().slice(0, 16).replace("T", " ")} UTC`;
916
920
  export async function swipeListFlow(opts, deps) {
917
921
  const res = await deps.get(SWIPES_PATH);
918
922
  if (!res.ok)
@@ -930,8 +934,10 @@ export async function swipeListFlow(opts, deps) {
930
934
  const ad = row.source?.sourceUrl ?? row.source?.fileName ?? "an ad";
931
935
  return [
932
936
  row._id,
937
+ ...(typeof row.createdAt === "number" ? [`written ${writtenAt(row.createdAt)}`] : []),
933
938
  `${mode.label}${step ? `, ${step.step} ${step.name}` : ""}`,
934
939
  ad,
940
+ ...(row.product !== undefined ? [row.product ? `for ${row.product.name}` : "for a product since deleted"] : []),
935
941
  ...(row.workflowRunId ? [`run ${row.workflowRunId}`] : []),
936
942
  ...(row.outcome?.kind === "refused"
937
943
  ? [`refused, ${typeof row.costUsd === "number" ? `cost ${usd(row.costUsd)}` : "cost unknown"}, nothing started`]
@@ -940,17 +946,42 @@ export async function swipeListFlow(opts, deps) {
940
946
  }),
941
947
  };
942
948
  }
943
- export async function swipeStartFlow(swipeId, ask, opts, deps) {
949
+ export const SWIPE_ALREADY_STARTED_CODE = "SWIPE_ALREADY_STARTED";
950
+ export function alreadyStartedOf(res) {
951
+ if (res.ok || res.status !== 409 || !isRecord(res.data) || !isRecord(res.data.error))
952
+ return null;
953
+ const { code, runId, url } = res.data.error;
954
+ if (code !== SWIPE_ALREADY_STARTED_CODE || typeof runId !== "string" || !runId)
955
+ return null;
956
+ return { runId, url: typeof url === "string" ? url : "" };
957
+ }
958
+ export async function swipeStartFlow(swipeId, ask, opts, deps, again = false) {
944
959
  const { json } = opts;
945
- if (!opts.yes)
946
- return needsYesResult(ask.oneShot ? "start-one-shot" : "start", json);
960
+ if (!opts.yes) {
961
+ 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."] : []);
962
+ }
947
963
  const res = await deps.post(SWIPE_RUNS_PATH, {
948
964
  swipeId,
949
965
  ...(ask.style ? { style: ask.style } : {}),
950
966
  ...(ask.title ? { title: ask.title } : {}),
951
967
  ...(ask.music ? { music: true } : {}),
952
968
  ...(ask.oneShot ? {} : { reviewStoryboard: true }),
969
+ ...(again ? { again: true } : {}),
953
970
  });
971
+ const held = alreadyStartedOf(res);
972
+ if (held) {
973
+ const error = `Swipe ${swipeId} already has a video, so nothing was started: run ${held.runId}.`;
974
+ if (json)
975
+ return { code: 1, lines: [JSON.stringify({ ok: false, status: res.status, error, alreadyStarted: held })] };
976
+ return {
977
+ code: 1,
978
+ lines: [
979
+ error,
980
+ held.url ? `Watch it: ${held.url}` : `Check it: exodus video status ${held.runId}`,
981
+ `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`,
982
+ ],
983
+ };
984
+ }
954
985
  if (!res.ok)
955
986
  return swipeError(res, json);
956
987
  const customer = customerAnswer(res.data);
@@ -1379,6 +1410,14 @@ export const nodeSheetFiles = {
1379
1410
  realPath(file) {
1380
1411
  return fs.realpathSync(file);
1381
1412
  },
1413
+ listDir(dir) {
1414
+ try {
1415
+ return fs.readdirSync(dir);
1416
+ }
1417
+ catch {
1418
+ return [];
1419
+ }
1420
+ },
1382
1421
  onStop(cleanup) {
1383
1422
  const handlers = ["SIGINT", "SIGTERM"].map((signal) => {
1384
1423
  const handler = () => {
@@ -1397,6 +1436,7 @@ export const nodeSheetFiles = {
1397
1436
  const sheetFilesOf = (deps) => deps.sheetFiles ?? nodeSheetFiles;
1398
1437
  export const sheetLockPath = (sheetFile) => `${sheetStatePath(sheetFile)}.lock`;
1399
1438
  const LOCK_SETTLE_MS = 250;
1439
+ export const sheetTakeoverPath = (sheetFile) => `${sheetLockPath(sheetFile)}.takeover`;
1400
1440
  async function takeSheetLock(sheetFile, deps) {
1401
1441
  const files = sheetFilesOf(deps);
1402
1442
  const lockFile = sheetLockPath(sheetFile);
@@ -1438,12 +1478,32 @@ async function takeSheetLock(sheetFile, deps) {
1438
1478
  const stale = holder.pid !== null && holder.host === files.host && !files.isAlive(holder.pid);
1439
1479
  if (!stale)
1440
1480
  return { problem: busy(holder.words) };
1441
- const still = holderOf();
1442
- const same = holder.token !== null ? still.token === holder.token : still.token === null && still.pid === holder.pid && still.at === holder.at;
1443
- if (!same)
1444
- return { problem: busy(still.words) };
1445
- files.remove(lockFile);
1446
- made = tryCreate();
1481
+ const takeoverFile = sheetTakeoverPath(sheetFile);
1482
+ let takeover;
1483
+ try {
1484
+ takeover = files.createNew(takeoverFile, text);
1485
+ }
1486
+ catch (err) {
1487
+ takeover = err instanceof Error ? err : new Error(String(err));
1488
+ }
1489
+ if (takeover !== true) {
1490
+ return {
1491
+ problem: takeover === false
1492
+ ? `Another run of this sheet is taking over the lock ${lockFile} left by a run that is no longer going, so this one sent nothing. If no run of this sheet is going, deleting ${takeoverFile} and ${lockFile} is safe; then run the command again.`
1493
+ : `The lock ${lockFile} could not be taken over (${takeover.message}). Nothing was sent.`,
1494
+ };
1495
+ }
1496
+ try {
1497
+ const still = holderOf();
1498
+ const same = holder.token !== null ? still.token === holder.token : still.token === null && still.pid === holder.pid && still.at === holder.at;
1499
+ if (!same)
1500
+ return { problem: busy(still.words) };
1501
+ files.remove(lockFile);
1502
+ made = tryCreate();
1503
+ }
1504
+ finally {
1505
+ files.remove(takeoverFile);
1506
+ }
1447
1507
  note = `A lock left by a run that is no longer going (${holder.words}) was taken.`;
1448
1508
  }
1449
1509
  if (made === false)
@@ -1520,8 +1580,10 @@ function stateFromJson(raw) {
1520
1580
  return `${whereRun} has a field of the wrong kind`;
1521
1581
  }
1522
1582
  const rp = run.pending;
1523
- if (rp !== null && !(isRecord(rp) && at(rp.at) && typeof rp.swipeId === "string"))
1583
+ if (rp !== null &&
1584
+ !(isRecord(rp) && at(rp.at) && typeof rp.swipeId === "string" && (rp.serverAt === undefined || (typeof rp.serverAt === "number" && Number.isFinite(rp.serverAt))))) {
1524
1585
  return `${whereRun} has a "pending" this CLI did not write`;
1586
+ }
1525
1587
  runs[index] = { ...run };
1526
1588
  }
1527
1589
  writes[persona] = { ...write, runs };
@@ -1537,8 +1599,9 @@ function readSheetState(sheetFile, deps) {
1537
1599
  text = deps.readFile(file);
1538
1600
  }
1539
1601
  catch (err) {
1540
- if (err.code === "ENOENT")
1541
- return { state: { version: 3, sheet: path.basename(sheetFile), sources: dict() } };
1602
+ if (err.code === "ENOENT") {
1603
+ return { state: { version: 3, sheet: path.basename(sheetFile), sources: dict() }, missing: true };
1604
+ }
1542
1605
  return {
1543
1606
  problem: `The state file ${file} is there but can't be opened (${err instanceof Error ? err.message : String(err)}). It keeps what this sheet already bought, so nothing was sent. Fix its permissions, then run the command again.`,
1544
1607
  };
@@ -1551,7 +1614,7 @@ function readSheetState(sheetFile, deps) {
1551
1614
  checked = "it is not valid JSON";
1552
1615
  }
1553
1616
  if (typeof checked !== "string")
1554
- return { state: checked };
1617
+ return { state: checked, missing: false };
1555
1618
  return {
1556
1619
  problem: `The state file ${file} can't be read: ${checked}. Fix it, or move it away; without it the next run buys every step again, even the ones already bought.`,
1557
1620
  };
@@ -2014,12 +2077,19 @@ async function readSwipe(swipeId, deps) {
2014
2077
  const res = await deps.get(`${SWIPES_PATH}?id=${encodeURIComponent(swipeId)}`);
2015
2078
  if (!res.ok)
2016
2079
  return { problem: swipeErrorLine(res) };
2017
- return isRecord(res.data) && isRecord(res.data.swipe) ? { swipe: res.data.swipe } : { problem: "Its answer could not be read." };
2080
+ if (!isRecord(res.data) || !isRecord(res.data.swipe))
2081
+ return { problem: "Its answer could not be read." };
2082
+ const now = res.data.now;
2083
+ return { swipe: res.data.swipe, serverNow: typeof now === "number" && Number.isFinite(now) ? now : null };
2084
+ }
2085
+ function startAge(pending, serverNow, deps) {
2086
+ const local = deps.now() - Date.parse(pending.at);
2087
+ return pending.serverAt !== undefined && serverNow !== null ? Math.min(local, serverNow - pending.serverAt) : local;
2018
2088
  }
2019
2089
  async function settlePendingStart(video, run, outcome, ctx) {
2020
2090
  const pending = run.pending;
2021
- const ago = minutesAgo(ctx.deps.now() - Date.parse(pending.at));
2022
2091
  const read = await readSwipe(pending.swipeId, ctx.deps);
2092
+ const ago = minutesAgo(startAge(pending, "problem" in read ? null : read.serverNow, ctx.deps));
2023
2093
  if ("problem" in read) {
2024
2094
  stopRun(video, run, outcome, `A start was sent ${ago} ago and its answer was not seen, and swipe ${pending.swipeId} could not be read to check it: ${read.problem} Nothing was sent again.`, ctx);
2025
2095
  return "stopped";
@@ -2036,7 +2106,7 @@ async function settlePendingStart(video, run, outcome, ctx) {
2036
2106
  await sayIfFailedAtStart(video, runId, pending.swipeId, ctx);
2037
2107
  return "taken";
2038
2108
  }
2039
- if (ctx.deps.now() - Date.parse(pending.at) < START_PENDING_MS) {
2109
+ if (startAge(pending, read.serverNow, ctx.deps) < START_PENDING_MS) {
2040
2110
  stopRun(video, run, outcome, `A start was sent ${ago} ago and its answer was not seen. It may still be starting, so nothing was sent again. Run the sheet again in a few minutes.`, ctx);
2041
2111
  return "stopped";
2042
2112
  }
@@ -2062,10 +2132,22 @@ async function startVideo(video, run, swipeId, outcome, ctx) {
2062
2132
  await sayIfFailedAtStart(video, existing, swipeId, ctx);
2063
2133
  return;
2064
2134
  }
2065
- run.pending = { at: stamp(ctx.deps), swipeId };
2135
+ run.pending = { at: stamp(ctx.deps), swipeId, ...(read.serverNow !== null ? { serverAt: read.serverNow } : {}) };
2066
2136
  run.updatedAt = stamp(ctx.deps);
2067
2137
  ctx.save();
2068
2138
  const started = answerOf(await swipeStartFlow(swipeId, ctx.sheet.start, { json: true, yes: true, wait: false }, ctx.deps));
2139
+ const held = isRecord(started.alreadyStarted) && typeof started.alreadyStarted.runId === "string" ? started.alreadyStarted : null;
2140
+ if (held) {
2141
+ const heldRunId = held.runId;
2142
+ const holder = heldIds(ctx.state).runs.get(heldRunId);
2143
+ if (holder && holder !== run) {
2144
+ stopRun(video, run, outcome, `Swipe ${swipeId} already has run ${heldRunId}, which is another video's in this sheet. One swipe is one video, so nothing was sent again.`, ctx);
2145
+ return;
2146
+ }
2147
+ takeRun(video, run, outcome, heldRunId, typeof held.url === "string" && held.url ? held.url : null, ctx);
2148
+ ctx.say(` Video ${video.n}: swipe ${swipeId} already has run ${heldRunId}; it is this video's run. Nothing more was started. Check it: exodus video status ${heldRunId}`);
2149
+ return;
2150
+ }
2069
2151
  if (started.ok !== true || typeof started.runId !== "string") {
2070
2152
  if (postRefused(started))
2071
2153
  run.pending = null;
@@ -2314,7 +2396,7 @@ export async function swipeSheetFlow(given, opts, deps) {
2314
2396
  return failed(stateRead.problem, json);
2315
2397
  if (opts.status)
2316
2398
  return sheetStatusFlow(sheet, sheetFile, videos, personas, stateRead.state, opts, deps);
2317
- return sheetPaidFlow(sheet, sheetFile, videos, personas, stateRead.state, null, opts, deps);
2399
+ return sheetPaidFlow(sheet, sheetFile, videos, personas, stateRead.state, null, opts, deps, stateRead.missing);
2318
2400
  }
2319
2401
  const lock = await takeSheetLock(sheetFile, deps);
2320
2402
  if ("problem" in lock)
@@ -2353,8 +2435,70 @@ async function startChecks(sheet, deps) {
2353
2435
  }
2354
2436
  return null;
2355
2437
  }
2438
+ async function lostProgressLines(sheet, sheetFile, state, missing, planned, deps) {
2439
+ const stateName = path.basename(sheetStatePath(sheetFile));
2440
+ const lines = [];
2441
+ if (missing) {
2442
+ const dir = path.dirname(sheetFile);
2443
+ const leftBehind = sheetFilesOf(deps)
2444
+ .listDir(dir)
2445
+ .filter((name) => name.endsWith(".state.json") && name !== stateName)
2446
+ .map((name) => ({ name, sheetName: name.slice(0, -".state.json".length) }))
2447
+ .filter(({ sheetName }) => sheetName && deps.statFile(path.join(dir, sheetName)) === null);
2448
+ for (const { name, sheetName } of leftBehind) {
2449
+ lines.push(`A saved progress file, ${name}, is beside this sheet for a sheet named ${sheetName} that is no longer there. If this sheet was renamed from ${sheetName}, rename ${name} to ${stateName} before the yes; without it the yes buys every step below again.`);
2450
+ }
2451
+ const res = await deps.get(SWIPES_PATH);
2452
+ const rows = res.ok && isRecord(res.data) && Array.isArray(res.data.swipes) ? res.data.swipes : [];
2453
+ const ours = rows.filter((row) => {
2454
+ if (row.outcome?.kind === "refused")
2455
+ return false;
2456
+ return planned.some(({ item, steps }) => {
2457
+ const breakdownId = steps.find((step) => step.step === "breakdown")?.have;
2458
+ if (breakdownId && row.breakdownId === breakdownId)
2459
+ return true;
2460
+ if (item.source.kind === "url")
2461
+ return row.source?.sourceUrl === item.source.url;
2462
+ if (item.source.kind === "file")
2463
+ return row.source?.fileName === path.basename(item.source.file);
2464
+ return row.source?.sourceAdId === item.source.swipeAdId;
2465
+ });
2466
+ });
2467
+ if (ours.length > 0) {
2468
+ const named = ours.map((row) => (row.workflowRunId ? `${row._id} (video run ${row.workflowRunId})` : `${row._id} (no video yet)`)).join(", ");
2469
+ lines.push(`No saved progress was found beside this sheet (${stateName}), but this brand already has swipes of these ads: ${named}. The yes writes and starts them again, which is paid. If this sheet was run before from another folder or under another name, put its saved progress here as ${stateName} first.`);
2470
+ }
2471
+ return lines;
2472
+ }
2473
+ const inSheet = new Set(sheet.personas.length > 0 ? sheet.personas.map((persona) => persona.name) : [""]);
2474
+ for (const item of sheet.sources) {
2475
+ const src = state.sources[item.key];
2476
+ if (!src)
2477
+ continue;
2478
+ for (const [key, write] of Object.entries(src.writes)) {
2479
+ if (inSheet.has(key))
2480
+ continue;
2481
+ const runs = Object.values(write.runs);
2482
+ const runIds = runs.map((run) => run.runId).filter((id) => id !== null);
2483
+ const unseen = runs.map((run) => run.pending?.swipeId).filter((id) => id !== undefined);
2484
+ if (!write.swipeId && !write.pending && runIds.length === 0 && unseen.length === 0)
2485
+ continue;
2486
+ const who = key ? `persona "${key}"` : "the write with no persona";
2487
+ const had = [
2488
+ ...(write.swipeId ? [`swipe ${write.swipeId}`] : []),
2489
+ ...runIds.map((id) => `video run ${id}`),
2490
+ ];
2491
+ lines.push([
2492
+ `The saved progress for ${item.key} has ${who}, which is no longer in the sheet${had.length > 0 ? ` (${had.join(", ")})` : ""}. If it was renamed, the yes writes and starts it again under its new name, which is paid.`,
2493
+ ...unseen.map((id) => `It also has a start for it whose answer was never seen: check exodus video swipe show ${id} before the yes.`),
2494
+ ...(write.pending ? ["It also has a write for it whose end was never seen: check exodus video swipe list before the yes."] : []),
2495
+ ].join(" "));
2496
+ }
2497
+ }
2498
+ return lines;
2499
+ }
2356
2500
  const shellWord = (word) => (/^[\w./@%+=:,-]+$/.test(word) ? word : `'${word.replace(/'/g, "'\\''")}'`);
2357
- async function sheetPaidFlow(sheet, sheetFile, videos, personas, state, lockNote, opts, deps) {
2501
+ async function sheetPaidFlow(sheet, sheetFile, videos, personas, state, lockNote, opts, deps, stateMissing = false) {
2358
2502
  const { json } = opts;
2359
2503
  const stateFile = sheetStatePath(sheetFile);
2360
2504
  for (const [index, item] of sheet.sources.entries()) {
@@ -2389,6 +2533,7 @@ async function sheetPaidFlow(sheet, sheetFile, videos, personas, state, lockNote
2389
2533
  }
2390
2534
  const needsYes = planned.some(({ steps }) => steps.some((step) => step.buy));
2391
2535
  const warning = videos.length > SHEET_VIDEO_WARNING ? [`That is ${videos.length} videos, more than ${SHEET_VIDEO_WARNING}. Check the count with the member before the yes.`] : [];
2536
+ const progressLost = await lostProgressLines(sheet, sheetFile, state, stateMissing, planned, deps);
2392
2537
  if (json) {
2393
2538
  return {
2394
2539
  code: 0,
@@ -2402,6 +2547,7 @@ async function sheetPaidFlow(sheet, sheetFile, videos, personas, state, lockNote
2402
2547
  count,
2403
2548
  videos: videosJson,
2404
2549
  ...(warning.length > 0 ? { warning: warning[0] } : {}),
2550
+ ...(progressLost.length > 0 ? { progressLost } : {}),
2405
2551
  notUsed,
2406
2552
  moved: sheet.moved,
2407
2553
  sources: planned.map(({ item, steps }) => ({ source: item.given, steps })),
@@ -2415,6 +2561,7 @@ async function sheetPaidFlow(sheet, sheetFile, videos, personas, state, lockNote
2415
2561
  lines: [
2416
2562
  ...head,
2417
2563
  ...warning,
2564
+ ...progressLost,
2418
2565
  "",
2419
2566
  ...planned.flatMap(({ item, steps }, i) => [`Ad ${i + 1}: ${item.key}`, ...plannedLines(steps)]),
2420
2567
  "",
@@ -2556,7 +2703,7 @@ export async function runSwipePlan(plan, deps, onProgressLine) {
2556
2703
  case "find":
2557
2704
  return swipeFindFlow(plan.ask, opts, deps);
2558
2705
  case "start":
2559
- return swipeStartFlow(plan.swipeId, plan.ask, opts, deps);
2706
+ return swipeStartFlow(plan.swipeId, plan.ask, opts, deps, plan.again);
2560
2707
  case "run":
2561
2708
  return swipeSheetFlow(plan.sheetFile, { ...opts, retryRefused: plan.retryRefused, status: plan.status, persona: plan.persona }, deps);
2562
2709
  }
@@ -205,7 +205,7 @@ Usage:
205
205
  exodus video swipe show <swipeId> [--json]
206
206
  exodus video swipe list [--json]
207
207
  exodus video swipe find [--brand "<name>"] [--limit <n>] [--json]
208
- exodus video swipe start <swipeId> [--style <look>] [--title "<name>"] [--music] [--one-shot] [--yes] [--wait] [--json]
208
+ exodus video swipe start <swipeId> [--style <look>] [--title "<name>"] [--music] [--one-shot] [--again] [--yes] [--wait] [--json]
209
209
  exodus video swipe run --sheet <file> [--status] [--persona <name>] [--yes] [--retry-refused] [--wait] [--json]
210
210
 
211
211
  Options:
@@ -487,6 +487,9 @@ what it buys and who pays. The CLI prints no price for any of them.
487
487
  --script <file> Your own script (swipe write --mode their-format)
488
488
  --style <look> A look other than the swipe's own (swipe start)
489
489
  --title "<name>" The ad's name (swipe start). Admin-only
490
+ --again A second, paid video from a swipe that already has one
491
+ (swipe start). Without it the server refuses to start a
492
+ swipe whose video is there, and names that run
490
493
  --sheet <file> The whole swipe in one JSON file (swipe run): the ads
491
494
  (sources, each a url, an ad id or a file), the product,
492
495
  the personas, mode, closeness, look or script, the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aicopycoders/exodus",
3
- "version": "2026.11.1100-beta.7",
3
+ "version": "2026.11.1100-beta.8",
4
4
  "description": "CLI + Claude Code skills for the Copycoders Exodus ad pipeline",
5
5
  "repository": {
6
6
  "type": "git",