popost 4.6.12 → 4.6.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/SKILL.md +5 -3
- package/dist/cli.js +1461 -675
- package/dist/index.js +1456 -672
- package/dist/types/commands/feedback.d.ts +2 -0
- package/dist/types/feedback/bundle.d.ts +33 -0
- package/dist/types/feedback/clean.d.ts +44 -0
- package/dist/types/feedback/project-files.d.ts +19 -0
- package/dist/types/feedback/transcript.d.ts +38 -0
- package/dist/types/feedback/upload.d.ts +13 -0
- package/dist/types/runtime.d.ts +3 -0
- package/dist/types/version.d.ts +1 -1
- package/dist/types/video/commands/product.d.ts +2 -6
- package/dist/types/video/generate/cloud.d.ts +1 -0
- package/dist/types/video/generate/dialogue.d.ts +2 -0
- package/dist/types/video/generate/index.d.ts +8 -0
- package/dist/types/video/generate/provenance.d.ts +13 -0
- package/dist/types/video/replication/books.d.ts +1 -1
- package/dist/types/video/replication/contract.d.ts +56 -0
- package/dist/types/video/replication/review.d.ts +17 -0
- package/dist/types/video/replication/voice-spans.d.ts +1 -1
- package/package.json +1 -1
- package/references/video-continuity.md +40 -0
- package/references/video-replication.md +3 -1
- package/references/video-step-0-machine.md +7 -0
- package/references/video-step-3-content.md +8 -0
- package/references/video-tools.md +26 -1
- package/references/video.md +2 -0
package/dist/index.js
CHANGED
|
@@ -39,19 +39,19 @@ var init_pyjson = __esm({
|
|
|
39
39
|
return `{${keys2.map((key2) => `${JSON.stringify(key2)}: ${pyJson(value[key2], sortKeys)}`).join(", ")}}`;
|
|
40
40
|
};
|
|
41
41
|
reprString = (text13) => {
|
|
42
|
-
const
|
|
42
|
+
const quote16 = text13.includes("'") && !text13.includes('"') ? '"' : "'";
|
|
43
43
|
let out2 = "";
|
|
44
44
|
for (const ch of text13) {
|
|
45
45
|
const code = ch.codePointAt(0);
|
|
46
46
|
if (ch === "\\") out2 += "\\\\";
|
|
47
|
-
else if (ch ===
|
|
47
|
+
else if (ch === quote16) out2 += `\\${quote16}`;
|
|
48
48
|
else if (ch === "\n") out2 += "\\n";
|
|
49
49
|
else if (ch === "\r") out2 += "\\r";
|
|
50
50
|
else if (ch === " ") out2 += "\\t";
|
|
51
51
|
else if (code < 32 || code >= 127 && code <= 159) out2 += `\\x${code.toString(16).padStart(2, "0")}`;
|
|
52
52
|
else out2 += ch;
|
|
53
53
|
}
|
|
54
|
-
return
|
|
54
|
+
return quote16 + out2 + quote16;
|
|
55
55
|
};
|
|
56
56
|
pyRepr = (value) => {
|
|
57
57
|
if (value === null || value === void 0) return "None";
|
|
@@ -71,8 +71,8 @@ var init_pyjson = __esm({
|
|
|
71
71
|
}
|
|
72
72
|
return a === b;
|
|
73
73
|
};
|
|
74
|
-
pyUnquote = (text13) => text13.replace(/(?:%[0-9A-Fa-f]{2})+/g, (
|
|
75
|
-
const bytes = Uint8Array.from(
|
|
74
|
+
pyUnquote = (text13) => text13.replace(/(?:%[0-9A-Fa-f]{2})+/g, (run7) => {
|
|
75
|
+
const bytes = Uint8Array.from(run7.slice(1).split("%"), (hex3) => Number.parseInt(hex3, 16));
|
|
76
76
|
return new TextDecoder().decode(bytes);
|
|
77
77
|
});
|
|
78
78
|
}
|
|
@@ -265,7 +265,7 @@ var VERSION;
|
|
|
265
265
|
var init_version = __esm({
|
|
266
266
|
"src/version.ts"() {
|
|
267
267
|
"use strict";
|
|
268
|
-
VERSION = "4.6.
|
|
268
|
+
VERSION = "4.6.13";
|
|
269
269
|
}
|
|
270
270
|
});
|
|
271
271
|
|
|
@@ -665,8 +665,8 @@ var init_post_bundle = __esm({
|
|
|
665
665
|
const blocker = await resourceBlocker(rt, res, baseDir);
|
|
666
666
|
if (blocker) blockers.push(blocker);
|
|
667
667
|
}
|
|
668
|
-
const
|
|
669
|
-
for (const item2 of
|
|
668
|
+
const missing4 = Array.isArray(bundle.missing) ? bundle.missing : [];
|
|
669
|
+
for (const item2 of missing4) blockers.push(msg(`the bundle still declares a missing item: ${plain(item2)}`, `bundle \u4ECD\u58F0\u660E\u7F3A\u9879: ${plain(item2)}`));
|
|
670
670
|
return { buildable: blockers.length === 0, blockers };
|
|
671
671
|
};
|
|
672
672
|
}
|
|
@@ -1109,11 +1109,11 @@ var init_state = __esm({
|
|
|
1109
1109
|
if (await install.createExclusive(paths.lock, mine)) return await ownsLock(rt, paths);
|
|
1110
1110
|
const stale = await text13(paths.lock);
|
|
1111
1111
|
if (await lockHolder(rt, paths)) return false;
|
|
1112
|
-
const
|
|
1113
|
-
const renamed = await rt.fs.rename(paths.lock,
|
|
1112
|
+
const moved2 = `${paths.lock}.stale-${rt.randomUUID().slice(0, 8)}`;
|
|
1113
|
+
const renamed = await rt.fs.rename(paths.lock, moved2).then(() => true, () => false);
|
|
1114
1114
|
if (renamed) {
|
|
1115
|
-
const taken = await text13(
|
|
1116
|
-
await removeState(rt,
|
|
1115
|
+
const taken = await text13(moved2);
|
|
1116
|
+
await removeState(rt, moved2);
|
|
1117
1117
|
if (taken !== stale) {
|
|
1118
1118
|
if (taken !== null) await install.createExclusive(paths.lock, taken).catch(() => false);
|
|
1119
1119
|
return false;
|
|
@@ -1463,7 +1463,7 @@ var init_auto = __esm({
|
|
|
1463
1463
|
if (!await target2.install.canWrite(dir)) return msg(`${dir} cannot be written by this user`, `\u5F53\u524D\u7528\u6237\u4E0D\u80FD\u5199\u5165 ${dir}`);
|
|
1464
1464
|
return null;
|
|
1465
1465
|
};
|
|
1466
|
-
attemptedLately = (rt,
|
|
1466
|
+
attemptedLately = (rt, attempt3, version) => attempt3 !== null && (since(rt, attempt3.startedAt) < DAY_MS || attempt3.version === version && since(rt, attempt3.startedAt) < RETRY_SAME_VERSION_MS);
|
|
1467
1467
|
startAutoUpdate = async (rt, paths, target2, command2, args) => {
|
|
1468
1468
|
if (!autoCommand(command2, args)) return "command";
|
|
1469
1469
|
const check7 = await readState(rt, paths.check);
|
|
@@ -1478,14 +1478,14 @@ var init_auto = __esm({
|
|
|
1478
1478
|
if (await lockHolder(rt, paths)) return "locked";
|
|
1479
1479
|
const processes = rt.processes;
|
|
1480
1480
|
if (!processes) return "blocked";
|
|
1481
|
-
const
|
|
1482
|
-
if (!await writeState(rt, paths.attempt,
|
|
1481
|
+
const attempt3 = { version: latest2, from: VERSION, startedAt: rt.now().toISOString(), status: "started" };
|
|
1482
|
+
if (!await writeState(rt, paths.attempt, attempt3)) return "blocked";
|
|
1483
1483
|
try {
|
|
1484
1484
|
if (((await rt.fs.stat(paths.log))?.size ?? 0) > LOG_KEPT_BYTES) await rt.fs.rm(paths.log);
|
|
1485
1485
|
await processes.spawnDetached([...processes.selfCommand.slice(0, 2), "update", "--background", "--to", latest2], { cwd: rt.homeDir ?? rt.cwd, logFile: paths.log });
|
|
1486
1486
|
return "started";
|
|
1487
1487
|
} catch (error2) {
|
|
1488
|
-
await writeState(rt, paths.attempt, { ...
|
|
1488
|
+
await writeState(rt, paths.attempt, { ...attempt3, status: "failed", finishedAt: rt.now().toISOString(), reason: msg(`the update could not be started: ${safeDetail(rt, String(error2))}`, `\u65E0\u6CD5\u542F\u52A8\u66F4\u65B0\uFF1A${safeDetail(rt, String(error2))}`) });
|
|
1489
1489
|
return "spawn-failed";
|
|
1490
1490
|
}
|
|
1491
1491
|
};
|
|
@@ -1518,30 +1518,30 @@ var init_session = __esm({
|
|
|
1518
1518
|
autoFailedMessage = (version, reason2) => msg(`an automatic update to ${version} failed: ${reason2}; run ${UPDATE_COMMAND}`, `\u81EA\u52A8\u66F4\u65B0\u5230 ${version} \u5931\u8D25\uFF1A${reason2}\uFF1B\u8BF7\u8FD0\u884C ${UPDATE_COMMAND}`);
|
|
1519
1519
|
SKILL_COMMAND = REFRESH_COMMAND;
|
|
1520
1520
|
outcomeNews = async (rt, paths, found, news) => {
|
|
1521
|
-
let
|
|
1522
|
-
if (!
|
|
1523
|
-
if (
|
|
1524
|
-
if (since(rt,
|
|
1525
|
-
|
|
1526
|
-
}
|
|
1527
|
-
const { version, from } =
|
|
1528
|
-
if (
|
|
1529
|
-
news.lines.push(autoFailedMessage(version,
|
|
1530
|
-
Object.assign(news.fields, { failed: { version, reason:
|
|
1521
|
+
let attempt3 = found;
|
|
1522
|
+
if (!attempt3 || attempt3.reported || typeof attempt3.version !== "string") return void 0;
|
|
1523
|
+
if (attempt3.status === "started") {
|
|
1524
|
+
if (since(rt, attempt3.startedAt) < STALE_MS || await lockHolder(rt, paths)) return attempt3.version;
|
|
1525
|
+
attempt3 = { ...attempt3, status: "failed", reason: msg("it did not finish", "\u6CA1\u6709\u8FD0\u884C\u5B8C") };
|
|
1526
|
+
}
|
|
1527
|
+
const { version, from } = attempt3;
|
|
1528
|
+
if (attempt3.status === "failed") {
|
|
1529
|
+
news.lines.push(autoFailedMessage(version, attempt3.reason ?? ""));
|
|
1530
|
+
Object.assign(news.fields, { failed: { version, reason: attempt3.reason ?? "" }, command: UPDATE_COMMAND });
|
|
1531
1531
|
} else {
|
|
1532
1532
|
const now = parseVersion(VERSION);
|
|
1533
1533
|
const target2 = parseVersion(version);
|
|
1534
|
-
if (!now || !target2 || compareVersions(now, target2) < 0) return since(rt,
|
|
1534
|
+
if (!now || !target2 || compareVersions(now, target2) < 0) return since(rt, attempt3.startedAt) < DAY_MS ? version : void 0;
|
|
1535
1535
|
Object.assign(news.fields, { updated: { from, to: version } });
|
|
1536
|
-
if (
|
|
1536
|
+
if (attempt3.status === "skill-failed") {
|
|
1537
1537
|
news.lines.push(msg(
|
|
1538
|
-
`${updatedMessage(version)}, but the agents' Skill copies could not be refreshed: ${
|
|
1539
|
-
`${updatedMessage(version)}\uFF0C\u4F46\u5404 Agent \u7684 Skill \u526F\u672C\u6CA1\u6709\u66F4\u65B0\u6210\u529F\uFF1A${
|
|
1538
|
+
`${updatedMessage(version)}, but the agents' Skill copies could not be refreshed: ${attempt3.reason ?? ""}; run ${SKILL_COMMAND}`,
|
|
1539
|
+
`${updatedMessage(version)}\uFF0C\u4F46\u5404 Agent \u7684 Skill \u526F\u672C\u6CA1\u6709\u66F4\u65B0\u6210\u529F\uFF1A${attempt3.reason ?? ""}\uFF1B\u8BF7\u8FD0\u884C ${SKILL_COMMAND}`
|
|
1540
1540
|
));
|
|
1541
|
-
Object.assign(news.fields, { skill: { reason:
|
|
1541
|
+
Object.assign(news.fields, { skill: { reason: attempt3.reason ?? "" }, command: SKILL_COMMAND });
|
|
1542
1542
|
} else news.lines.push(updatedMessage(version));
|
|
1543
1543
|
}
|
|
1544
|
-
await writeState(rt, paths.attempt, { ...
|
|
1544
|
+
await writeState(rt, paths.attempt, { ...attempt3, reported: true });
|
|
1545
1545
|
return void 0;
|
|
1546
1546
|
};
|
|
1547
1547
|
noticeNews = async (rt, paths, check7, news, command2) => {
|
|
@@ -1581,13 +1581,13 @@ var init_session = __esm({
|
|
|
1581
1581
|
const paths = activePaths(rt, command2);
|
|
1582
1582
|
if (!paths) return idle();
|
|
1583
1583
|
const check7 = await readState(rt, paths.check);
|
|
1584
|
-
const
|
|
1584
|
+
const attempt3 = await readState(rt, paths.attempt);
|
|
1585
1585
|
const due = !checkIsFresh(rt, check7);
|
|
1586
|
-
if (!due && offer(VERSION, check7?.latest) === "none" && (!
|
|
1586
|
+
if (!due && offer(VERSION, check7?.latest) === "none" && (!attempt3 || attempt3.reported)) return idle();
|
|
1587
1587
|
const target2 = await installKind(rt);
|
|
1588
1588
|
if (target2.kind !== "global" && target2.kind !== "managed") return idle();
|
|
1589
1589
|
const news = { lines: [], fields: { current: VERSION } };
|
|
1590
|
-
const underway = target2.kind === "global" ? await outcomeNews(rt, paths,
|
|
1590
|
+
const underway = target2.kind === "global" ? await outcomeNews(rt, paths, attempt3, news) : void 0;
|
|
1591
1591
|
if (!news.lines.length && underway !== check7?.latest) await noticeNews(rt, paths, check7, news, target2.kind === "managed" ? target2.command : UPDATE_COMMAND);
|
|
1592
1592
|
for (const line of news.lines) rt.stderr(`${line}
|
|
1593
1593
|
`);
|
|
@@ -2439,7 +2439,7 @@ var init_build = __esm({
|
|
|
2439
2439
|
];
|
|
2440
2440
|
const gaps = await reviewGaps(project, plan4, notes2);
|
|
2441
2441
|
const { warnings } = notes2;
|
|
2442
|
-
const
|
|
2442
|
+
const report4 = {
|
|
2443
2443
|
structureReady: blockers.length === 0,
|
|
2444
2444
|
visualQa: gaps.length ? "pending" : "reviewed-by-agent",
|
|
2445
2445
|
readyToDeliver: blockers.length === 0 && gaps.length === 0,
|
|
@@ -2449,8 +2449,8 @@ var init_build = __esm({
|
|
|
2449
2449
|
warnings,
|
|
2450
2450
|
concept: project.manifest.concept
|
|
2451
2451
|
};
|
|
2452
|
-
await writeJson(project.rt, project.abs("build-report.json"),
|
|
2453
|
-
return
|
|
2452
|
+
await writeJson(project.rt, project.abs("build-report.json"), report4);
|
|
2453
|
+
return report4;
|
|
2454
2454
|
};
|
|
2455
2455
|
doctor = async (project) => {
|
|
2456
2456
|
const { rt, manifest } = project;
|
|
@@ -2514,24 +2514,24 @@ var init_args = __esm({
|
|
|
2514
2514
|
}
|
|
2515
2515
|
};
|
|
2516
2516
|
describeChoices = (choices) => choices.map((c) => `'${c}'`).join(", ");
|
|
2517
|
-
convert = (
|
|
2518
|
-
if (
|
|
2519
|
-
if (!/^[-+]?\d+$/.test(raw.trim())) throw new UsageError(`argument ${
|
|
2517
|
+
convert = (spec10, raw) => {
|
|
2518
|
+
if (spec10.kind === "int") {
|
|
2519
|
+
if (!/^[-+]?\d+$/.test(raw.trim())) throw new UsageError(`argument ${spec10.flag}: invalid int value: '${raw}'`);
|
|
2520
2520
|
return Number.parseInt(raw, 10);
|
|
2521
2521
|
}
|
|
2522
|
-
if (
|
|
2522
|
+
if (spec10.kind === "number") {
|
|
2523
2523
|
const value = Number(raw);
|
|
2524
2524
|
if (raw.trim() === "" || Number.isNaN(value))
|
|
2525
|
-
throw new UsageError(`argument ${
|
|
2525
|
+
throw new UsageError(`argument ${spec10.flag}: invalid float value: '${raw}'`);
|
|
2526
2526
|
return value;
|
|
2527
2527
|
}
|
|
2528
|
-
if (
|
|
2529
|
-
throw new UsageError(`argument ${
|
|
2528
|
+
if (spec10.choices && !spec10.choices.includes(raw))
|
|
2529
|
+
throw new UsageError(`argument ${spec10.flag}: invalid choice: '${raw}' (choose from ${describeChoices(spec10.choices)})`);
|
|
2530
2530
|
return raw;
|
|
2531
2531
|
};
|
|
2532
2532
|
isOptionToken = (token) => token.startsWith("-") && token !== "-" && !/^-\d/.test(token);
|
|
2533
|
-
parseArgs = (argv,
|
|
2534
|
-
const options = new Map((
|
|
2533
|
+
parseArgs = (argv, spec10) => {
|
|
2534
|
+
const options = new Map((spec10.options ?? []).map((o) => [o.flag, o]));
|
|
2535
2535
|
const values = /* @__PURE__ */ new Map();
|
|
2536
2536
|
const positionals = [];
|
|
2537
2537
|
let help = false;
|
|
@@ -2577,7 +2577,7 @@ var init_args = __esm({
|
|
|
2577
2577
|
} else values.set(key2, value);
|
|
2578
2578
|
}
|
|
2579
2579
|
if (help) return new ParsedArgs(values, true);
|
|
2580
|
-
const declared =
|
|
2580
|
+
const declared = spec10.positionals ?? [];
|
|
2581
2581
|
if (positionals.length > declared.length && !declared.at(-1)?.variadic)
|
|
2582
2582
|
throw new UsageError(`unrecognized arguments: ${positionals.slice(declared.length).join(" ")}`);
|
|
2583
2583
|
declared.forEach((positional, index) => {
|
|
@@ -2590,12 +2590,12 @@ var init_args = __esm({
|
|
|
2590
2590
|
);
|
|
2591
2591
|
values.set(keyOf(positional.name), positional.variadic ? raws : raws[0]);
|
|
2592
2592
|
});
|
|
2593
|
-
const
|
|
2593
|
+
const missing4 = [
|
|
2594
2594
|
...declared.filter((p) => p.required !== false && !values.has(keyOf(p.name))).map((p) => p.name),
|
|
2595
|
-
...(
|
|
2595
|
+
...(spec10.options ?? []).filter((o) => o.required && !values.has(keyOf(o.flag))).map((o) => o.flag)
|
|
2596
2596
|
];
|
|
2597
|
-
if (
|
|
2598
|
-
for (const option of
|
|
2597
|
+
if (missing4.length) throw new UsageError(`the following arguments are required: ${missing4.join(", ")}`);
|
|
2598
|
+
for (const option of spec10.options ?? []) {
|
|
2599
2599
|
const key2 = keyOf(option.flag);
|
|
2600
2600
|
if (!values.has(key2) && option.default !== void 0) values.set(key2, option.default);
|
|
2601
2601
|
}
|
|
@@ -2607,26 +2607,26 @@ var init_args = __esm({
|
|
|
2607
2607
|
if (option.kind === "list") return `${option.flag} ${meta} [${meta} ...]`;
|
|
2608
2608
|
return `${option.flag} ${option.choices ? `{${option.choices.join(",")}}` : meta}`;
|
|
2609
2609
|
};
|
|
2610
|
-
formatUsage = (
|
|
2610
|
+
formatUsage = (spec10) => {
|
|
2611
2611
|
const parts = [
|
|
2612
|
-
...(
|
|
2613
|
-
...(
|
|
2612
|
+
...(spec10.options ?? []).map((o) => o.required ? optionUsage(o) : `[${optionUsage(o)}]`),
|
|
2613
|
+
...(spec10.positionals ?? []).map((p) => {
|
|
2614
2614
|
const name = p.choices ? `{${p.choices.join(",")}}` : p.name;
|
|
2615
2615
|
return p.variadic ? p.required === false ? `[${name} ...]` : `${name} [${name} ...]` : name;
|
|
2616
2616
|
})
|
|
2617
2617
|
];
|
|
2618
|
-
return `usage: ${
|
|
2618
|
+
return `usage: ${spec10.prog} [-h] ${parts.join(" ")}`.trimEnd();
|
|
2619
2619
|
};
|
|
2620
|
-
formatHelp = (
|
|
2621
|
-
const lines2 = [formatUsage(
|
|
2622
|
-
if (
|
|
2623
|
-
if (
|
|
2620
|
+
formatHelp = (spec10) => {
|
|
2621
|
+
const lines2 = [formatUsage(spec10), ""];
|
|
2622
|
+
if (spec10.description) lines2.push(spec10.description, "");
|
|
2623
|
+
if (spec10.positionals?.length) {
|
|
2624
2624
|
lines2.push("positional arguments:");
|
|
2625
|
-
for (const p of
|
|
2625
|
+
for (const p of spec10.positionals) lines2.push(` ${p.choices ? `{${p.choices.join(",")}}` : p.name} ${p.help ?? ""}`);
|
|
2626
2626
|
lines2.push("");
|
|
2627
2627
|
}
|
|
2628
2628
|
lines2.push("options:", " -h, --help show this help message and exit");
|
|
2629
|
-
for (const o of
|
|
2629
|
+
for (const o of spec10.options ?? []) {
|
|
2630
2630
|
const extra2 = [
|
|
2631
2631
|
o.required ? "required" : "",
|
|
2632
2632
|
o.default !== void 0 && o.kind !== "flag" ? `default: ${o.default}` : ""
|
|
@@ -2635,19 +2635,19 @@ var init_args = __esm({
|
|
|
2635
2635
|
}
|
|
2636
2636
|
return lines2.join("\n") + "\n";
|
|
2637
2637
|
};
|
|
2638
|
-
withArgs = async (argv,
|
|
2638
|
+
withArgs = async (argv, spec10, rt, body) => {
|
|
2639
2639
|
let args;
|
|
2640
2640
|
try {
|
|
2641
|
-
args = parseArgs(argv,
|
|
2641
|
+
args = parseArgs(argv, spec10);
|
|
2642
2642
|
} catch (error2) {
|
|
2643
2643
|
if (!(error2 instanceof UsageError)) throw error2;
|
|
2644
|
-
rt.stderr(`${formatUsage(
|
|
2645
|
-
${
|
|
2644
|
+
rt.stderr(`${formatUsage(spec10)}
|
|
2645
|
+
${spec10.prog}: error: ${error2.message}
|
|
2646
2646
|
`);
|
|
2647
2647
|
return 2;
|
|
2648
2648
|
}
|
|
2649
2649
|
if (args.help) {
|
|
2650
|
-
rt.stdout(formatHelp(
|
|
2650
|
+
rt.stdout(formatHelp(spec10));
|
|
2651
2651
|
return 0;
|
|
2652
2652
|
}
|
|
2653
2653
|
return body(args);
|
|
@@ -2901,20 +2901,20 @@ var init_project_fonts = __esm({
|
|
|
2901
2901
|
fontEntry = (role) => ({ ...role, cssFamily: role.family });
|
|
2902
2902
|
installedFontLinks = (project, html2) => project.manifest.fonts.filter((font) => typeof font.cssPath === "string").filter((font) => html2 === void 0 || !font.cssFamily || !embedsFamily(html2, String(font.cssFamily))).map((font) => fontLinkTag(String(font.cssPath))).join("");
|
|
2903
2903
|
linkInstalledFonts = async (project, only) => {
|
|
2904
|
-
const
|
|
2905
|
-
if (!installedFontLinks(project)) return
|
|
2904
|
+
const report4 = { linked: [] };
|
|
2905
|
+
if (!installedFontLinks(project)) return report4;
|
|
2906
2906
|
for (const page2 of project.manifest.pages.filter((candidate) => !only || only.includes(candidate.id))) {
|
|
2907
2907
|
try {
|
|
2908
2908
|
const before = await project.readPageHtml(page2.id);
|
|
2909
2909
|
const after = withFontLinks(before, installedFontLinks(project, before));
|
|
2910
2910
|
if (after === before) continue;
|
|
2911
2911
|
await project.writePageHtml(page2.id, after);
|
|
2912
|
-
|
|
2912
|
+
report4.linked.push(page2.id);
|
|
2913
2913
|
} catch (error2) {
|
|
2914
|
-
(
|
|
2914
|
+
(report4.failed ??= []).push({ page: page2.id, reason: error2 instanceof Error ? error2.message : String(error2) });
|
|
2915
2915
|
}
|
|
2916
2916
|
}
|
|
2917
|
-
return
|
|
2917
|
+
return report4;
|
|
2918
2918
|
};
|
|
2919
2919
|
CHINESE_LANGUAGE = /(^|[^a-z])zh([^a-z]|$)|chinese|中文/i;
|
|
2920
2920
|
cjkFontWarnings = (project, roleIds) => {
|
|
@@ -3388,9 +3388,9 @@ var init_page_select = __esm({
|
|
|
3388
3388
|
ValueError2 = class extends Error {
|
|
3389
3389
|
name = "ValueError";
|
|
3390
3390
|
};
|
|
3391
|
-
selectPages = (project,
|
|
3392
|
-
if (
|
|
3393
|
-
const wanted = [...new Set(
|
|
3391
|
+
selectPages = (project, spec10) => {
|
|
3392
|
+
if (spec10 === "all") return project.manifest.pages.map((page2) => page2.id);
|
|
3393
|
+
const wanted = [...new Set(spec10.split(",").map((id2) => id2.trim()).filter(Boolean))];
|
|
3394
3394
|
if (!wanted.length) throw new ValueError2(msg("--page needs a page id, a comma-separated list such as p1,p3, or all", "--page \u9700\u8981\u4E00\u4E2A\u9875 id\u3001\u9017\u53F7\u5206\u9694\u7684\u5217\u8868\uFF08\u5982 p1,p3\uFF09\u6216 all"));
|
|
3395
3395
|
for (const id2 of wanted) project.page(id2);
|
|
3396
3396
|
return wanted;
|
|
@@ -3418,9 +3418,9 @@ var init_core = __esm({
|
|
|
3418
3418
|
init_template_plugins();
|
|
3419
3419
|
init_page_select();
|
|
3420
3420
|
DIR = { flag: "--dir", required: true };
|
|
3421
|
-
onProject = (
|
|
3422
|
-
spec: { ...
|
|
3423
|
-
run: async (args, rt) =>
|
|
3421
|
+
onProject = (spec10, run7) => ({
|
|
3422
|
+
spec: { ...spec10, options: [DIR, ...spec10.options ?? []] },
|
|
3423
|
+
run: async (args, rt) => run7(await Project.load(rt, args.req("dir")), args, rt)
|
|
3424
3424
|
});
|
|
3425
3425
|
init = () => ({
|
|
3426
3426
|
spec: {
|
|
@@ -3519,9 +3519,9 @@ var init_core = __esm({
|
|
|
3519
3519
|
build = () => onProject(
|
|
3520
3520
|
{ description: msg("structural readiness checks; writes build-report.json", "\u7ED3\u6784\u5C31\u7EEA\u68C0\u67E5\uFF1B\u5199\u51FA build-report.json"), options: [{ flag: "--concept-off", kind: "flag" }] },
|
|
3521
3521
|
async (project, args, rt) => {
|
|
3522
|
-
const
|
|
3523
|
-
printJson(rt, { ok: true, build:
|
|
3524
|
-
return
|
|
3522
|
+
const report4 = await buildProject(project, args.flag("concept-off"));
|
|
3523
|
+
printJson(rt, { ok: true, build: report4 }, true);
|
|
3524
|
+
return report4.structureReady ? 0 : 2;
|
|
3525
3525
|
}
|
|
3526
3526
|
);
|
|
3527
3527
|
doctorCommand = () => onProject({ description: msg("project and environment report", "\u5DE5\u7A0B\u4E0E\u73AF\u5883\u62A5\u544A") }, async (project, _args, rt) => {
|
|
@@ -3934,9 +3934,9 @@ var init_workflow = __esm({
|
|
|
3934
3934
|
return fail(rt, failureText(error2));
|
|
3935
3935
|
}
|
|
3936
3936
|
};
|
|
3937
|
-
onProject2 = (
|
|
3938
|
-
spec: { ...
|
|
3939
|
-
run: reporting(async (args, rt) =>
|
|
3937
|
+
onProject2 = (spec10, run7) => ({
|
|
3938
|
+
spec: { ...spec10, options: [DIR2, ...spec10.options ?? []] },
|
|
3939
|
+
run: reporting(async (args, rt) => run7(await Project.load(rt, args.req("dir")), args, rt))
|
|
3940
3940
|
});
|
|
3941
3941
|
PROFILE_FILE = "template-profile.json";
|
|
3942
3942
|
templateProfile = () => onProject2(
|
|
@@ -4633,8 +4633,8 @@ var init_agents = __esm({
|
|
|
4633
4633
|
label: "Copilot CLI",
|
|
4634
4634
|
homes: (rt, home) => [env(rt, "COPILOT_HOME") ?? rt.path.join(home, ".copilot")],
|
|
4635
4635
|
skillsDir: (rt, home) => {
|
|
4636
|
-
const
|
|
4637
|
-
return
|
|
4636
|
+
const moved2 = env(rt, "COPILOT_HOME");
|
|
4637
|
+
return moved2 ? rt.path.join(moved2, "skills") : sharedSkillsDir(rt, home);
|
|
4638
4638
|
},
|
|
4639
4639
|
env: ["COPILOT_CLI"]
|
|
4640
4640
|
},
|
|
@@ -4646,8 +4646,8 @@ var init_agents = __esm({
|
|
|
4646
4646
|
label: "DeepSeek Harness",
|
|
4647
4647
|
homes: (rt, home) => [env(rt, "DSH_HOME") ?? rt.path.join(home, ".dsh")],
|
|
4648
4648
|
skillsDir: (rt, home) => {
|
|
4649
|
-
const
|
|
4650
|
-
return
|
|
4649
|
+
const moved2 = env(rt, "DSH_AGENTS_HOME");
|
|
4650
|
+
return moved2 ? rt.path.join(moved2, "skills") : sharedSkillsDir(rt, home);
|
|
4651
4651
|
},
|
|
4652
4652
|
env: ["DSH_SHELL"]
|
|
4653
4653
|
},
|
|
@@ -5633,8 +5633,8 @@ var init_perform = __esm({
|
|
|
5633
5633
|
STAGING = ".popost-update-";
|
|
5634
5634
|
ASIDE = ".popost-old-";
|
|
5635
5635
|
QUIET = ["--no-fund", "--no-audit", "--loglevel=error"];
|
|
5636
|
-
updatePlan = async (rt, target2,
|
|
5637
|
-
const wanted =
|
|
5636
|
+
updatePlan = async (rt, target2, spec10) => {
|
|
5637
|
+
const wanted = spec10 === "latest" || parseVersion(spec10) ? spec10 : "latest";
|
|
5638
5638
|
const node2 = target2.install.execPath;
|
|
5639
5639
|
const staging = rt.path.join(rt.path.dirname(target2.root), `${STAGING}${rt.randomUUID().slice(0, 8)}`);
|
|
5640
5640
|
const staged = rt.platform === "win32" ? rt.path.join(staging, "node_modules", PACKAGE_NAME) : rt.path.join(staging, "lib", "node_modules", PACKAGE_NAME);
|
|
@@ -5685,13 +5685,13 @@ var init_perform = __esm({
|
|
|
5685
5685
|
return { reason: errorText(error2) };
|
|
5686
5686
|
}
|
|
5687
5687
|
};
|
|
5688
|
-
stage2 = async (rt, plan4,
|
|
5688
|
+
stage2 = async (rt, plan4, spec10, cwd, background2) => {
|
|
5689
5689
|
const viewed = await runStep(rt, plan4.view, cwd, NPM_QUERY_TIMEOUT_MS);
|
|
5690
5690
|
if ("reason" in viewed) return viewed;
|
|
5691
5691
|
if (viewed.code !== 0) return { reason: npmFailure(rt, viewed.code, viewed.stderr) };
|
|
5692
5692
|
const release = readRelease(viewed.stdout);
|
|
5693
|
-
if (!release ||
|
|
5694
|
-
return { reason: msg(`the registry has no entry for popost${
|
|
5693
|
+
if (!release || spec10 !== "latest" && release.version !== spec10)
|
|
5694
|
+
return { reason: msg(`the registry has no entry for popost${spec10 === "latest" ? "" : ` ${spec10}`} that can be read`, `registry \u4E0A\u6CA1\u6709\u53EF\u8BFB\u53D6\u7684 popost${spec10 === "latest" ? "" : ` ${spec10}`} \u6761\u76EE`) };
|
|
5695
5695
|
const { version } = release;
|
|
5696
5696
|
if (compareVersions(parseVersion(version), parseVersion(VERSION)) <= 0) return { version };
|
|
5697
5697
|
if (background2 && release.deprecated)
|
|
@@ -5740,28 +5740,28 @@ var init_perform = __esm({
|
|
|
5740
5740
|
refreshSkill = async (rt, argv, cwd) => {
|
|
5741
5741
|
try {
|
|
5742
5742
|
const result = await rt.programs.run(argv, { cwd, timeoutMs: NPM_INSTALL_TIMEOUT_MS });
|
|
5743
|
-
let
|
|
5743
|
+
let report4;
|
|
5744
5744
|
try {
|
|
5745
5745
|
const { next: _next, skipped: skipped2, ...rest } = JSON.parse(new TextDecoder().decode(result.stdout));
|
|
5746
|
-
|
|
5746
|
+
report4 = { ...rest, ...Array.isArray(skipped2) ? { skipped: skipped2.map((entry2) => entry2?.agent) } : {} };
|
|
5747
5747
|
} catch {
|
|
5748
|
-
|
|
5748
|
+
report4 = void 0;
|
|
5749
5749
|
}
|
|
5750
|
-
if (result.code === 0 &&
|
|
5751
|
-
return { ok: false, ...
|
|
5750
|
+
if (result.code === 0 && report4?.ok === true) return { ok: true, report: report4 };
|
|
5751
|
+
return { ok: false, ...report4 ? { report: report4 } : {}, reason: typeof report4?.error === "string" ? report4.error : safeDetail(rt, result.stderr) || msg(`popost install ended with code ${result.code}`, `popost install \u4EE5\u9000\u51FA\u7801 ${result.code} \u7ED3\u675F`) };
|
|
5752
5752
|
} catch (error2) {
|
|
5753
5753
|
return { ok: false, reason: errorText(error2) };
|
|
5754
5754
|
}
|
|
5755
5755
|
};
|
|
5756
|
-
runUpdate = async (rt, target2,
|
|
5757
|
-
const plan4 = await updatePlan(rt, target2,
|
|
5756
|
+
runUpdate = async (rt, target2, spec10, options) => {
|
|
5757
|
+
const plan4 = await updatePlan(rt, target2, spec10);
|
|
5758
5758
|
const cwd = rt.homeDir ?? rt.cwd;
|
|
5759
5759
|
let version = VERSION;
|
|
5760
5760
|
let checked2;
|
|
5761
5761
|
if (!options.skipNpm) {
|
|
5762
5762
|
await clearLeftovers(rt, rt.path.dirname(target2.root));
|
|
5763
5763
|
try {
|
|
5764
|
-
const staged = await stage2(rt, plan4,
|
|
5764
|
+
const staged = await stage2(rt, plan4, spec10, cwd, options.background === true);
|
|
5765
5765
|
if ("reason" in staged) return { status: "failed", reason: staged.reason, ...staged.deprecated ? { deprecated: true } : {} };
|
|
5766
5766
|
if (staged.version !== VERSION && compareVersions(parseVersion(staged.version), parseVersion(VERSION)) > 0) {
|
|
5767
5767
|
const held = await options.holdSwap?.();
|
|
@@ -5783,8 +5783,8 @@ var init_perform = __esm({
|
|
|
5783
5783
|
if (!skill.ok) return { status: "skill-failed", version, reason: skill.reason ?? "", ...skill.report ? { install: skill.report } : {}, ...how };
|
|
5784
5784
|
return { status: "ok", version, install: skill.report ?? {}, ...how };
|
|
5785
5785
|
};
|
|
5786
|
-
performUpdate = async (rt, target2,
|
|
5787
|
-
const outcome = await runUpdate(rt, target2,
|
|
5786
|
+
performUpdate = async (rt, target2, spec10, options = {}) => {
|
|
5787
|
+
const outcome = await runUpdate(rt, target2, spec10, options);
|
|
5788
5788
|
return outcome.status === "ok" ? outcome : { ...outcome, reason: safeText(rt, outcome.reason) };
|
|
5789
5789
|
};
|
|
5790
5790
|
restartHint = () => msg("Restart the agent or start a new chat if it does not see the new Skill.", "\u5982\u679C Agent \u6CA1\u6709\u8BFB\u5230\u65B0\u7684 Skill\uFF0C\u8BF7\u91CD\u542F Agent \u6216\u5F00\u4E00\u4E2A\u65B0\u5BF9\u8BDD\u3002");
|
|
@@ -6232,8 +6232,8 @@ var init_decimal = __esm({
|
|
|
6232
6232
|
const negative = this.int < 0n;
|
|
6233
6233
|
const digits = (negative ? -this.int : this.int).toString().padStart(this.scale + 1, "0");
|
|
6234
6234
|
const head = digits.slice(0, digits.length - this.scale);
|
|
6235
|
-
const
|
|
6236
|
-
return `${negative ? "-" : ""}${head}${
|
|
6235
|
+
const tail4 = this.scale ? `.${digits.slice(digits.length - this.scale)}` : "";
|
|
6236
|
+
return `${negative ? "-" : ""}${head}${tail4}`;
|
|
6237
6237
|
}
|
|
6238
6238
|
};
|
|
6239
6239
|
decimalOf = (value) => typeof value === "string" || typeof value === "number" ? Decimal.parse(String(value)) : null;
|
|
@@ -7605,7 +7605,7 @@ var init_context = __esm({
|
|
|
7605
7605
|
return inside6 !== null && await isFile(rt, inside6) ? inside6 : null;
|
|
7606
7606
|
};
|
|
7607
7607
|
jobIdOf = (entry2) => entry2.purpose === "composition" ? "composition" : entry2.id;
|
|
7608
|
-
wantedPages = (
|
|
7608
|
+
wantedPages = (spec10) => typeof spec10.pages === "number" ? Array.from({ length: spec10.pages }, (_, index) => `p${index + 1}`) : spec10.pages ?? [];
|
|
7609
7609
|
pagePlan = (ctx) => {
|
|
7610
7610
|
const existing = ctx.project ? ctx.project.manifest.pages.map((page2) => page2.id) : ["p1"];
|
|
7611
7611
|
const add2 = wantedPages(ctx.spec).filter((id2) => !existing.includes(id2));
|
|
@@ -7674,31 +7674,31 @@ var init_check2 = __esm({
|
|
|
7674
7674
|
throw error2;
|
|
7675
7675
|
}
|
|
7676
7676
|
};
|
|
7677
|
-
checkProject = (ctx, opened,
|
|
7678
|
-
const { spec:
|
|
7679
|
-
if (opened.problem)
|
|
7680
|
-
if (!ctx.project && !opened.problem &&
|
|
7681
|
-
if (ctx.project &&
|
|
7682
|
-
|
|
7677
|
+
checkProject = (ctx, opened, report4) => {
|
|
7678
|
+
const { spec: spec10 } = ctx;
|
|
7679
|
+
if (opened.problem) report4("dir", opened.problem);
|
|
7680
|
+
if (!ctx.project && !opened.problem && spec10.brief === void 0) report4("brief", msg("required: the project does not exist yet", "\u5FC5\u586B\uFF1A\u9879\u76EE\u8FD8\u4E0D\u5B58\u5728"));
|
|
7681
|
+
if (ctx.project && spec10.mode !== void 0 && spec10.mode !== ctx.project.manifest.mode)
|
|
7682
|
+
report4(
|
|
7683
7683
|
"mode",
|
|
7684
7684
|
msg(
|
|
7685
7685
|
`the project already exists as "${ctx.project.manifest.mode}" and its mode cannot change: remove "mode" or set it to "${ctx.project.manifest.mode}"`,
|
|
7686
7686
|
`\u9879\u76EE\u5DF2\u5B58\u5728\uFF0Cmode \u4E3A "${ctx.project.manifest.mode}"\uFF0C\u4E0D\u80FD\u66F4\u6539\uFF1A\u5220\u6389 "mode" \u6216\u8BBE\u4E3A "${ctx.project.manifest.mode}"`
|
|
7687
7687
|
)
|
|
7688
7688
|
);
|
|
7689
|
-
if (!ctx.project && Array.isArray(
|
|
7690
|
-
if (
|
|
7689
|
+
if (!ctx.project && Array.isArray(spec10.pages) && spec10.pages[0] !== "p1") report4("pages", msg('a new project starts with page p1: begin the list with "p1"', '\u65B0\u9879\u76EE\u4ECE p1 \u9875\u5F00\u59CB\uFF1A\u5217\u8868\u7B2C\u4E00\u9879\u8981\u662F "p1"'));
|
|
7690
|
+
if (spec10.quote === true && !spec10.images.length) report4("quote", msg("there are no images to quote", "\u6CA1\u6709\u53EF\u62A5\u4EF7\u7684\u56FE\u7247"));
|
|
7691
7691
|
};
|
|
7692
|
-
checkReference = async (ctx, entry2,
|
|
7692
|
+
checkReference = async (ctx, entry2, report4) => {
|
|
7693
7693
|
const where3 = `references[${entry2.index}]`;
|
|
7694
7694
|
const read2 = await readNextToSpec(ctx, entry2.file);
|
|
7695
|
-
if ("problem" in read2)
|
|
7695
|
+
if ("problem" in read2) report4(`${where3}.file`, read2.problem);
|
|
7696
7696
|
else {
|
|
7697
7697
|
const problem4 = pictureProblem(read2.bytes, entry2.file);
|
|
7698
|
-
if (problem4)
|
|
7698
|
+
if (problem4) report4(`${where3}.file`, problem4);
|
|
7699
7699
|
}
|
|
7700
7700
|
const { final } = pagePlan(ctx);
|
|
7701
|
-
if (entry2.page !== void 0 && !final.includes(entry2.page))
|
|
7701
|
+
if (entry2.page !== void 0 && !final.includes(entry2.page)) report4(
|
|
7702
7702
|
`${where3}.page`,
|
|
7703
7703
|
msg(
|
|
7704
7704
|
`"${entry2.page}" is not a page of this project (pages: ${final.join(", ")})`,
|
|
@@ -7706,12 +7706,12 @@ var init_check2 = __esm({
|
|
|
7706
7706
|
)
|
|
7707
7707
|
);
|
|
7708
7708
|
};
|
|
7709
|
-
checkFonts = async (ctx,
|
|
7709
|
+
checkFonts = async (ctx, report4) => {
|
|
7710
7710
|
if (!ctx.spec.fonts.length) return;
|
|
7711
7711
|
try {
|
|
7712
7712
|
const known2 = (await loadLibrary(ctx.rt)).palette.roles.map((role) => role.id);
|
|
7713
7713
|
const unknown = ctx.spec.fonts.filter((role) => !known2.includes(role));
|
|
7714
|
-
if (unknown.length)
|
|
7714
|
+
if (unknown.length) report4(
|
|
7715
7715
|
"fonts",
|
|
7716
7716
|
msg(
|
|
7717
7717
|
`unknown font roles: ${unknown.join(", ")} (popost font list shows the available ones)`,
|
|
@@ -7719,7 +7719,7 @@ var init_check2 = __esm({
|
|
|
7719
7719
|
)
|
|
7720
7720
|
);
|
|
7721
7721
|
} catch (error2) {
|
|
7722
|
-
|
|
7722
|
+
report4("fonts", errorText(error2));
|
|
7723
7723
|
}
|
|
7724
7724
|
};
|
|
7725
7725
|
readPlan = async (ctx, file) => {
|
|
@@ -7732,16 +7732,16 @@ var init_check2 = __esm({
|
|
|
7732
7732
|
return { problem: msg(`${file} is not valid JSON (${detail2})`, `${file} \u4E0D\u662F\u5408\u6CD5\u7684 JSON\uFF08${detail2}\uFF09`) };
|
|
7733
7733
|
}
|
|
7734
7734
|
};
|
|
7735
|
-
checkPlan = async (ctx,
|
|
7735
|
+
checkPlan = async (ctx, report4) => {
|
|
7736
7736
|
if (ctx.spec.plan === void 0) return;
|
|
7737
7737
|
const read2 = await readPlan(ctx, ctx.spec.plan);
|
|
7738
|
-
if ("problem" in read2) return
|
|
7738
|
+
if ("problem" in read2) return report4("plan", read2.problem);
|
|
7739
7739
|
const { final } = pagePlan(ctx);
|
|
7740
7740
|
const orderHint = msg(
|
|
7741
7741
|
` (the project will have: ${final.join(", ")}; set "pages" to match the plan)`,
|
|
7742
7742
|
`\uFF08\u9879\u76EE\u5C06\u6709\u7684\u9875\uFF1A${final.join(", ")}\uFF1B\u8BF7\u628A "pages" \u8BBE\u6210\u4E0E plan \u4E00\u81F4\uFF09`
|
|
7743
7743
|
);
|
|
7744
|
-
for (const message2 of validate(read2.plan, final, orderHint))
|
|
7744
|
+
for (const message2 of validate(read2.plan, final, orderHint)) report4("plan", message2);
|
|
7745
7745
|
};
|
|
7746
7746
|
registeredRoles = (ctx) => /* @__PURE__ */ new Set([...ctx.project ? registeredReferences(ctx.project).map((ref) => ref.role) : [], ...ctx.spec.references.map((ref) => ref.role)]);
|
|
7747
7747
|
noReference = (token) => {
|
|
@@ -7752,28 +7752,28 @@ var init_check2 = __esm({
|
|
|
7752
7752
|
`"${token}"\uFF1A\u8FD8\u6CA1\u6709\u767B\u8BB0 ${kind}\u53C2\u8003\u56FE\uFF1B\u5728 "references" \u4E0B\u6DFB\u52A0\u4E00\u5F20\uFF08role "${role}"\uFF09\uFF0C\u6216\u76F4\u63A5\u7ED9\u56FE\u7247\u8DEF\u5F84`
|
|
7753
7753
|
);
|
|
7754
7754
|
};
|
|
7755
|
-
checkRefToken = async (ctx, token, where3,
|
|
7755
|
+
checkRefToken = async (ctx, token, where3, report4) => {
|
|
7756
7756
|
if (token === REF_ALL || REF_ROLES.includes(token)) {
|
|
7757
7757
|
const roles = registeredRoles(ctx);
|
|
7758
7758
|
const have = token === REF_ALL ? roles.size > 0 : roles.has(token);
|
|
7759
|
-
if (!have)
|
|
7759
|
+
if (!have) report4(where3, noReference(token));
|
|
7760
7760
|
return;
|
|
7761
7761
|
}
|
|
7762
7762
|
const found = await locateRef(ctx, token);
|
|
7763
|
-
if (found === null) return
|
|
7763
|
+
if (found === null) return report4(where3, msg(`picture not found: ${token}`, `\u627E\u4E0D\u5230\u56FE\u7247\uFF1A${token}`));
|
|
7764
7764
|
const problem4 = pictureProblem(await ctx.rt.fs.readFile(found), token);
|
|
7765
|
-
if (problem4)
|
|
7765
|
+
if (problem4) report4(where3, problem4);
|
|
7766
7766
|
};
|
|
7767
7767
|
twinKey = (prompt, entry2) => JSON.stringify([normalizePrompt(prompt), entry2.aspect ?? null, entry2.ref]);
|
|
7768
|
-
checkImage = async (ctx, entry2, seen,
|
|
7768
|
+
checkImage = async (ctx, entry2, seen, report4) => {
|
|
7769
7769
|
const where3 = `images[${entry2.index}]`;
|
|
7770
7770
|
const read2 = await readNextToSpec(ctx, entry2.promptFile);
|
|
7771
|
-
if ("problem" in read2)
|
|
7771
|
+
if ("problem" in read2) report4(`${where3}.promptFile`, read2.problem);
|
|
7772
7772
|
else {
|
|
7773
7773
|
const key2 = twinKey(new TextDecoder().decode(read2.bytes), entry2);
|
|
7774
7774
|
const twin = seen.get(key2);
|
|
7775
7775
|
if (twin)
|
|
7776
|
-
|
|
7776
|
+
report4(
|
|
7777
7777
|
where3,
|
|
7778
7778
|
msg(
|
|
7779
7779
|
`"${entry2.id}" asks for the same picture as "${twin}" (same prompt, aspect and references): keep one, or change the prompt of the other`,
|
|
@@ -7782,9 +7782,9 @@ var init_check2 = __esm({
|
|
|
7782
7782
|
);
|
|
7783
7783
|
seen.set(key2, entry2.id);
|
|
7784
7784
|
}
|
|
7785
|
-
for (const token of entry2.ref) await checkRefToken(ctx, token, `${where3}.ref`,
|
|
7785
|
+
for (const token of entry2.ref) await checkRefToken(ctx, token, `${where3}.ref`, report4);
|
|
7786
7786
|
const mode = ctx.project?.manifest.mode ?? ctx.spec.mode ?? "original";
|
|
7787
|
-
if (entry2.purpose === "composition" && mode === "strict")
|
|
7787
|
+
if (entry2.purpose === "composition" && mode === "strict") report4(
|
|
7788
7788
|
`${where3}.purpose`,
|
|
7789
7789
|
msg(
|
|
7790
7790
|
"a strict (reproduction) project has no composition job: it uses the supplied references",
|
|
@@ -7794,13 +7794,13 @@ var init_check2 = __esm({
|
|
|
7794
7794
|
};
|
|
7795
7795
|
checkSpec = async (ctx, opened) => {
|
|
7796
7796
|
const problems2 = [];
|
|
7797
|
-
const
|
|
7798
|
-
checkProject(ctx, opened,
|
|
7799
|
-
for (const entry2 of ctx.spec.references) await checkReference(ctx, entry2,
|
|
7800
|
-
await checkFonts(ctx,
|
|
7801
|
-
await checkPlan(ctx,
|
|
7797
|
+
const report4 = (where3, message2) => void problems2.push(`${where3}: ${message2}`);
|
|
7798
|
+
checkProject(ctx, opened, report4);
|
|
7799
|
+
for (const entry2 of ctx.spec.references) await checkReference(ctx, entry2, report4);
|
|
7800
|
+
await checkFonts(ctx, report4);
|
|
7801
|
+
await checkPlan(ctx, report4);
|
|
7802
7802
|
const seen = /* @__PURE__ */ new Map();
|
|
7803
|
-
for (const entry2 of ctx.spec.images) await checkImage(ctx, entry2, seen,
|
|
7803
|
+
for (const entry2 of ctx.spec.images) await checkImage(ctx, entry2, seen, report4);
|
|
7804
7804
|
return problems2;
|
|
7805
7805
|
};
|
|
7806
7806
|
}
|
|
@@ -7921,9 +7921,9 @@ var init_cli_args = __esm({
|
|
|
7921
7921
|
"use strict";
|
|
7922
7922
|
init_args();
|
|
7923
7923
|
init_i18n();
|
|
7924
|
-
joinSpacedValues = (argv,
|
|
7925
|
-
const known2 = new Set((
|
|
7926
|
-
const single = new Set((
|
|
7924
|
+
joinSpacedValues = (argv, spec10) => {
|
|
7925
|
+
const known2 = new Set((spec10.options ?? []).map((o) => o.flag));
|
|
7926
|
+
const single = new Set((spec10.options ?? []).filter((o) => o.kind === void 0 || o.kind === "string" || o.kind === "append").map((o) => o.flag));
|
|
7927
7927
|
const out2 = [];
|
|
7928
7928
|
for (let i = 0; i < argv.length; i++) {
|
|
7929
7929
|
const token = argv[i];
|
|
@@ -7945,20 +7945,20 @@ var init_cli_args = __esm({
|
|
|
7945
7945
|
if (key2 !== void 0 && !IDEMPOTENCY.test(key2))
|
|
7946
7946
|
throw new UsageError(msg("argument --idempotency-key: must be 8\u2013128 letters, digits or . _ -", "argument --idempotency-key: \u987B\u4E3A 8\u2013128 \u4F4D\u5B57\u6BCD\u3001\u6570\u5B57\u6216 . _ -"));
|
|
7947
7947
|
};
|
|
7948
|
-
withProviderArgs = async (argv,
|
|
7948
|
+
withProviderArgs = async (argv, spec10, rt, body) => {
|
|
7949
7949
|
let args;
|
|
7950
7950
|
try {
|
|
7951
|
-
args = parseArgs(joinSpacedValues(argv,
|
|
7951
|
+
args = parseArgs(joinSpacedValues(argv, spec10), spec10);
|
|
7952
7952
|
if (!args.help) checkCustomTypes(args);
|
|
7953
7953
|
} catch (error2) {
|
|
7954
7954
|
if (!(error2 instanceof UsageError)) throw error2;
|
|
7955
|
-
rt.stderr(`usage: ${
|
|
7956
|
-
${
|
|
7955
|
+
rt.stderr(`usage: ${spec10.prog} [-h] ...
|
|
7956
|
+
${spec10.prog}: error: ${error2.message}
|
|
7957
7957
|
`);
|
|
7958
7958
|
return 2;
|
|
7959
7959
|
}
|
|
7960
7960
|
if (args.help) {
|
|
7961
|
-
rt.stdout(formatHelp(
|
|
7961
|
+
rt.stdout(formatHelp(spec10));
|
|
7962
7962
|
return 0;
|
|
7963
7963
|
}
|
|
7964
7964
|
return body(args);
|
|
@@ -8174,32 +8174,32 @@ var init_cli_quote = __esm({
|
|
|
8174
8174
|
return refs;
|
|
8175
8175
|
};
|
|
8176
8176
|
serverQuote = async (prov, model, aspect, count5, refs, allowFree, recheck = false) => {
|
|
8177
|
-
let
|
|
8177
|
+
let quote16;
|
|
8178
8178
|
try {
|
|
8179
|
-
|
|
8179
|
+
quote16 = await prov.quote({ model, aspect, count: count5, refs, recheck });
|
|
8180
8180
|
} catch (error2) {
|
|
8181
8181
|
if (error2 instanceof CapabilityError) throw new CliReject(2, error2.message);
|
|
8182
8182
|
if (error2 instanceof ImageProviderError)
|
|
8183
8183
|
throw new CliReject(exitCodeOf(error2), msg(`${error2.message} (nothing was submitted or charged)`, `${error2.message}\uFF08\u672A\u63D0\u4EA4\u3001\u672A\u6263\u8D39\uFF09`));
|
|
8184
8184
|
throw error2;
|
|
8185
8185
|
}
|
|
8186
|
-
const unit = parseCredits(
|
|
8187
|
-
const total2 = parseCredits(
|
|
8188
|
-
if (
|
|
8186
|
+
const unit = parseCredits(quote16.creditsPerImage, allowFree);
|
|
8187
|
+
const total2 = parseCredits(quote16.totalCredits, allowFree);
|
|
8188
|
+
if (quote16.sufficient === false)
|
|
8189
8189
|
throw new CliReject(
|
|
8190
8190
|
1,
|
|
8191
8191
|
msg(
|
|
8192
|
-
`Not enough credits: this needs ${total2} credits (${unit} per image) and the balance is ${
|
|
8193
|
-
`\u79EF\u5206\u4E0D\u8DB3\uFF1A\u672C\u6B21\u9700\u8981 ${total2} \u79EF\u5206\uFF08\u6BCF\u5F20 ${unit}\uFF09\uFF0C\u5F53\u524D\u4F59\u989D ${
|
|
8192
|
+
`Not enough credits: this needs ${total2} credits (${unit} per image) and the balance is ${quote16.balance ?? "unknown"}. Nothing was submitted or charged. It is paid with popost credits: popost account shows the balance and where to buy more; or choose local references, your own API key or the agent's image tool`,
|
|
8193
|
+
`\u79EF\u5206\u4E0D\u8DB3\uFF1A\u672C\u6B21\u9700\u8981 ${total2} \u79EF\u5206\uFF08\u6BCF\u5F20 ${unit}\uFF09\uFF0C\u5F53\u524D\u4F59\u989D ${quote16.balance ?? "\u672A\u77E5"}\uFF1B\u8FD9\u4E00\u6B65\u9700\u8981 popost \u79EF\u5206\uFF1A\u53EF\u7528 popost account \u67E5\u770B\u8D2D\u4E70\u9009\u9879\uFF0C\u6216\u9009\u62E9\u672C\u5730\u53C2\u8003\u3001\u81EA\u5E26 Key / Agent \u751F\u56FE\uFF08\u672A\u63D0\u4EA4\u3001\u672A\u6263\u8D39\uFF1Bpopost account \u53EF\u67E5\u4F59\u989D\u548C\u8D2D\u4E70\u9875\u9762\uFF09`
|
|
8194
8194
|
),
|
|
8195
|
-
{ billing: { model:
|
|
8195
|
+
{ billing: { model: quote16.model, count: count5, creditsPerImage: String(unit), totalCredits: String(total2), balance: quote16.balance, sufficient: false, charged: false } }
|
|
8196
8196
|
);
|
|
8197
|
-
return { quote:
|
|
8197
|
+
return { quote: quote16, unit, total: total2 };
|
|
8198
8198
|
};
|
|
8199
8199
|
isFree = (ctx, pcfg, row) => Boolean(row?.free || pcfg.free || ctx.cfg.freeExplicit);
|
|
8200
8200
|
priceOnPlatform = async (ctx, prov, pcfg, a, count5, refs) => {
|
|
8201
|
-
const { quote:
|
|
8202
|
-
return { model:
|
|
8201
|
+
const { quote: quote16, unit, total: total2 } = await serverQuote(prov, a.model, a.aspectRatio, count5, refs, isFree(ctx, pcfg));
|
|
8202
|
+
return { model: quote16.model, label: quote16.label, unit, total: total2, billingUnit: "credits", priceSource: "popost.ai /images/quote", extraBilling: { balance: quote16.balance, sufficient: quote16.sufficient } };
|
|
8203
8203
|
};
|
|
8204
8204
|
priceByoK = async (ctx, name, pcfg, a, count5) => {
|
|
8205
8205
|
const prov = makeProvider(ctx, name);
|
|
@@ -8405,14 +8405,14 @@ var init_cli_generate = __esm({
|
|
|
8405
8405
|
const snapUnit = record2.pricingSnapshot.unitCredits === null ? null : decimalOf(record2.pricingSnapshot.unitCredits);
|
|
8406
8406
|
const count5 = Number(record2.count);
|
|
8407
8407
|
if (prov instanceof PopostProvider) {
|
|
8408
|
-
const { quote:
|
|
8408
|
+
const { quote: quote16, unit: unit2, total: total2 } = await serverQuote(prov, record2.model, record2.aspect, count5, refs, isFree(ctx, pcfg), true);
|
|
8409
8409
|
const quotedTotal = record2.totalCredits ? decimalOf(record2.totalCredits) : null;
|
|
8410
|
-
if (
|
|
8410
|
+
if (quote16.model !== record2.model)
|
|
8411
8411
|
throw new CliReject(
|
|
8412
8412
|
1,
|
|
8413
8413
|
msg(
|
|
8414
|
-
`the platform priced model ${
|
|
8415
|
-
`\u5E73\u53F0\u62A5\u4EF7\u6A21\u578B ${
|
|
8414
|
+
`the platform priced model ${quote16.model}, but the quote is bound to ${record2.model}; stop and quote again`,
|
|
8415
|
+
`\u5E73\u53F0\u62A5\u4EF7\u6A21\u578B ${quote16.model} \u4E0E quote \u7ED1\u5B9A\u6A21\u578B ${record2.model} \u4E0D\u4E00\u81F4\uFF0C\u505C\u6B62\u5E76\u91CD\u65B0 quote`
|
|
8416
8416
|
)
|
|
8417
8417
|
);
|
|
8418
8418
|
if (!sameDecimal(unit2, snapUnit) || !sameDecimal(total2, quotedTotal)) {
|
|
@@ -8425,7 +8425,7 @@ var init_cli_generate = __esm({
|
|
|
8425
8425
|
)
|
|
8426
8426
|
);
|
|
8427
8427
|
}
|
|
8428
|
-
return { options: { idempotencyKey: idempotencyKey(a, record2), maxCredits: record2.totalCredits }, unit: unit2, total: total2, extraBilling: { balanceBefore:
|
|
8428
|
+
return { options: { idempotencyKey: idempotencyKey(a, record2), maxCredits: record2.totalCredits }, unit: unit2, total: total2, extraBilling: { balanceBefore: quote16.balance } };
|
|
8429
8429
|
}
|
|
8430
8430
|
const row = (await prov.models()).find((r) => r.value === record2.model);
|
|
8431
8431
|
if (!row) throw new CliReject(1, msg(`the latest model list has no price for ${record2.model}; refused`, `latest \u6E05\u5355\u4E2D\u6A21\u578B ${record2.model} \u4EF7\u683C\u672A\u77E5\uFF0C\u62D2\u7EDD\u63D0\u4EA4`));
|
|
@@ -8837,10 +8837,10 @@ commands: ${NAMES.join(", ")}
|
|
|
8837
8837
|
if (name === void 0) return usageError(rt, "the following arguments are required: cmd");
|
|
8838
8838
|
const command2 = NAMES.find((n) => n === name);
|
|
8839
8839
|
if (!command2) return usageError(rt, `argument cmd: invalid choice: '${name}' (choose from ${NAMES.map((n) => `'${n}'`).join(", ")})`);
|
|
8840
|
-
const
|
|
8840
|
+
const spec10 = { prog: `${PROG} ${command2}`, ...specs()[command2] };
|
|
8841
8841
|
return withProviderArgs(
|
|
8842
8842
|
rest,
|
|
8843
|
-
|
|
8843
|
+
spec10,
|
|
8844
8844
|
rt,
|
|
8845
8845
|
async (a) => print(rt, await executeCli(rt, { provider: globals.string("provider"), config: globals.string("config"), globals: globalsOf(a), command: commandOf(command2, a) }))
|
|
8846
8846
|
);
|
|
@@ -8859,7 +8859,7 @@ var init_retry = __esm({
|
|
|
8859
8859
|
init_i18n();
|
|
8860
8860
|
ledgerPathOf2 = (project) => resolvePath(project.rt, project.rt.path.join(project.root, "production", "ledger.jsonl"));
|
|
8861
8861
|
refused = () => msg("submission already attempted; query its quote/ledger before any retry", "\u5DF2\u7ECF\u63D0\u4EA4\u8FC7\uFF1B\u91CD\u8BD5\u524D\u8BF7\u5148\u67E5\u8BE2\u5B83\u7684\u62A5\u4EF7/\u8D26\u672C\u8BB0\u5F55");
|
|
8862
|
-
refusedUncharged = (
|
|
8862
|
+
refusedUncharged = (attempt3) => (attempt3.state === "ambiguous" || attempt3.state === "refunded") && attempt3.charged === false;
|
|
8863
8863
|
submissionKey = async (project, job, call2) => {
|
|
8864
8864
|
const prior = await heldBy(project, job);
|
|
8865
8865
|
if (!prior) {
|
|
@@ -8896,8 +8896,8 @@ var init_retry = __esm({
|
|
|
8896
8896
|
if (job.runAttempted && !job.attemptedQuoteId && job.quoteId) job.attemptedQuoteId = job.quoteId;
|
|
8897
8897
|
};
|
|
8898
8898
|
recordRun = async (project, job, path2, quoteId2, wasAttempted) => {
|
|
8899
|
-
const
|
|
8900
|
-
if (quoteId2 &&
|
|
8899
|
+
const attempt3 = quoteId2 ? await attempt(project.rt, ledgerPathOf2(project), quoteId2) : null;
|
|
8900
|
+
if (quoteId2 && attempt3 && !refusedUncharged(attempt3)) job.attemptedQuoteId = quoteId2;
|
|
8901
8901
|
else if (wasAttempted) job.runAttempted = true;
|
|
8902
8902
|
else delete job.runAttempted;
|
|
8903
8903
|
await saveJob(project.rt, path2, job);
|
|
@@ -9176,9 +9176,9 @@ var init_batch_quote = __esm({
|
|
|
9176
9176
|
const price = billing2?.sufficient === false ? { credits: billing2.totalCredits ?? null, insufficient: true } : {};
|
|
9177
9177
|
return { row: { id: id2, ok: false, code, error: result.error, ...price }, balance: balanceOf(billing2) };
|
|
9178
9178
|
}
|
|
9179
|
-
const
|
|
9179
|
+
const quote16 = result.quote;
|
|
9180
9180
|
const billing = result.billing;
|
|
9181
|
-
const row = { id: id2, ok: true, quoteId:
|
|
9181
|
+
const row = { id: id2, ok: true, quoteId: quote16.quoteId, model: quote16.model, aspect: quote16.aspect, credits: billing.totalCredits ?? null, expiresAt: quote16.expiresAt, quoteFile: result.quoteFile, billingUnit: billing.unit ?? null, provider: quote16.provider };
|
|
9182
9182
|
return { row, balance: balanceOf(billing) };
|
|
9183
9183
|
};
|
|
9184
9184
|
quoteOne = async (project, entry2, call2) => {
|
|
@@ -9373,8 +9373,8 @@ var init_prepare = __esm({
|
|
|
9373
9373
|
);
|
|
9374
9374
|
}
|
|
9375
9375
|
if (jobState(job) === "prepared") return true;
|
|
9376
|
-
const
|
|
9377
|
-
throw refusal2(project, id2, job,
|
|
9376
|
+
const attempt3 = job.quoteId ? await attempt(project.rt, ledgerPathOf2(project), job.quoteId) : null;
|
|
9377
|
+
throw refusal2(project, id2, job, attempt3 !== null && refusedUncharged(attempt3));
|
|
9378
9378
|
};
|
|
9379
9379
|
recordedGrid = (project) => {
|
|
9380
9380
|
const { grid } = project.manifest.concept;
|
|
@@ -9497,10 +9497,10 @@ var init_steps = __esm({
|
|
|
9497
9497
|
)
|
|
9498
9498
|
);
|
|
9499
9499
|
}
|
|
9500
|
-
const { rt, spec:
|
|
9501
|
-
if (
|
|
9502
|
-
const mode =
|
|
9503
|
-
const project = await Project.create(rt, ctx.dir,
|
|
9500
|
+
const { rt, spec: spec10 } = ctx;
|
|
9501
|
+
if (spec10.brief === void 0) throw new StepFailure(msg("brief is required to create the project", "\u521B\u5EFA\u9879\u76EE\u9700\u8981 brief"));
|
|
9502
|
+
const mode = spec10.mode ?? "original";
|
|
9503
|
+
const project = await Project.create(rt, ctx.dir, spec10.brief, mode, spec10.width, spec10.height);
|
|
9504
9504
|
await project.appendDesignNote(initDesignNote());
|
|
9505
9505
|
ctx.project = project;
|
|
9506
9506
|
const first = project.manifest.pages[0];
|
|
@@ -9569,18 +9569,18 @@ var init_steps = __esm({
|
|
|
9569
9569
|
};
|
|
9570
9570
|
fontsStep = async (ctx) => {
|
|
9571
9571
|
const project = projectOf(ctx);
|
|
9572
|
-
const
|
|
9573
|
-
for (const role of ctx.spec.fonts) if (!await isInstalled(project, role))
|
|
9574
|
-
if (!
|
|
9572
|
+
const missing4 = [];
|
|
9573
|
+
for (const role of ctx.spec.fonts) if (!await isInstalled(project, role)) missing4.push(role);
|
|
9574
|
+
if (!missing4.length)
|
|
9575
9575
|
return skipped(
|
|
9576
9576
|
msg(`font roles already installed: ${ctx.spec.fonts.join(", ")}`, `\u5B57\u4F53\u89D2\u8272\u5DF2\u5B89\u88C5\uFF1A${ctx.spec.fonts.join(", ")}`) + linksNote(project)
|
|
9577
9577
|
);
|
|
9578
|
-
const { result, fontLinks } = await installFonts(ctx.rt, project,
|
|
9578
|
+
const { result, fontLinks } = await installFonts(ctx.rt, project, missing4.join(","), true);
|
|
9579
9579
|
const { installed } = result;
|
|
9580
|
-
const kept3 = ctx.spec.fonts.length -
|
|
9580
|
+
const kept3 = ctx.spec.fonts.length - missing4.length;
|
|
9581
9581
|
const detail2 = msg(
|
|
9582
|
-
`installed ${
|
|
9583
|
-
`\u5DF2\u5B89\u88C5 ${
|
|
9582
|
+
`installed ${missing4.join(", ")}${kept3 ? `; ${kept3} already installed` : ""}`,
|
|
9583
|
+
`\u5DF2\u5B89\u88C5 ${missing4.join(", ")}${kept3 ? `\uFF1B${kept3} \u4E2A\u6B64\u524D\u5DF2\u5B89\u88C5` : ""}`
|
|
9584
9584
|
) + linksNote(project);
|
|
9585
9585
|
return done(detail2, [], cjkFontWarnings(project, installed.map((role) => role.id)), fontLinks);
|
|
9586
9586
|
};
|
|
@@ -9757,104 +9757,104 @@ var init_spec = __esm({
|
|
|
9757
9757
|
isObj = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9758
9758
|
at2 = (base, key2) => base ? `${base}.${key2}` : key2;
|
|
9759
9759
|
quoted2 = (values) => values.map((value) => `"${value}"`).join(", ");
|
|
9760
|
-
noExtraKeys = (obj3, allowed, base,
|
|
9761
|
-
for (const key2 of Object.keys(obj3)) if (!allowed.includes(key2))
|
|
9760
|
+
noExtraKeys = (obj3, allowed, base, report4) => {
|
|
9761
|
+
for (const key2 of Object.keys(obj3)) if (!allowed.includes(key2)) report4(at2(base, key2), msg(`unknown key (allowed: ${allowed.join(", ")})`, `\u672A\u77E5\u5B57\u6BB5\uFF08\u5141\u8BB8\uFF1A${allowed.join(", ")}\uFF09`));
|
|
9762
9762
|
};
|
|
9763
|
-
readString = (obj3, key2, base,
|
|
9763
|
+
readString = (obj3, key2, base, report4, required2 = false) => {
|
|
9764
9764
|
const value = obj3[key2];
|
|
9765
9765
|
if (value === void 0) {
|
|
9766
|
-
if (required2)
|
|
9766
|
+
if (required2) report4(at2(base, key2), msg("required", "\u5FC5\u586B"));
|
|
9767
9767
|
return void 0;
|
|
9768
9768
|
}
|
|
9769
9769
|
if (typeof value !== "string" || !value.trim()) {
|
|
9770
|
-
|
|
9770
|
+
report4(at2(base, key2), msg("must be a non-empty string", "\u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32"));
|
|
9771
9771
|
return void 0;
|
|
9772
9772
|
}
|
|
9773
9773
|
return value;
|
|
9774
9774
|
};
|
|
9775
|
-
readEnum = (obj3, key2, allowed, base,
|
|
9776
|
-
const value = readString(obj3, key2, base,
|
|
9775
|
+
readEnum = (obj3, key2, allowed, base, report4) => {
|
|
9776
|
+
const value = readString(obj3, key2, base, report4);
|
|
9777
9777
|
if (value === void 0) return void 0;
|
|
9778
9778
|
if (allowed.includes(value)) return value;
|
|
9779
|
-
|
|
9779
|
+
report4(at2(base, key2), msg(`"${value}" is not one of ${quoted2(allowed)}`, `"${value}" \u4E0D\u5728\u53EF\u9009\u503C ${quoted2(allowed)} \u4E4B\u4E2D`));
|
|
9780
9780
|
return void 0;
|
|
9781
9781
|
};
|
|
9782
9782
|
MODE_ALIASES = { replicate: "strict", reproduce: "strict", create: "original" };
|
|
9783
|
-
readMode = (obj3,
|
|
9783
|
+
readMode = (obj3, report4) => {
|
|
9784
9784
|
const alias = typeof obj3.mode === "string" ? MODE_ALIASES[obj3.mode.trim().toLowerCase()] : void 0;
|
|
9785
|
-
return alias ?? readEnum(obj3, "mode", MODES, "",
|
|
9785
|
+
return alias ?? readEnum(obj3, "mode", MODES, "", report4);
|
|
9786
9786
|
};
|
|
9787
|
-
readInt = (obj3, key2, base,
|
|
9787
|
+
readInt = (obj3, key2, base, report4, min, max) => {
|
|
9788
9788
|
const value = obj3[key2];
|
|
9789
9789
|
if (value === void 0) return void 0;
|
|
9790
9790
|
if (typeof value === "number" && Number.isInteger(value) && value >= min && value <= max) return value;
|
|
9791
|
-
|
|
9791
|
+
report4(at2(base, key2), msg(`must be a whole number from ${min} to ${max}`, `\u5FC5\u987B\u662F ${min} \u5230 ${max} \u4E4B\u95F4\u7684\u6574\u6570`));
|
|
9792
9792
|
return void 0;
|
|
9793
9793
|
};
|
|
9794
|
-
readBool = (obj3, key2,
|
|
9794
|
+
readBool = (obj3, key2, report4) => {
|
|
9795
9795
|
const value = obj3[key2];
|
|
9796
|
-
if (value !== void 0 && typeof value !== "boolean")
|
|
9796
|
+
if (value !== void 0 && typeof value !== "boolean") report4(key2, msg("must be true or false", "\u5FC5\u987B\u662F true \u6216 false"));
|
|
9797
9797
|
return typeof value === "boolean" ? value : void 0;
|
|
9798
9798
|
};
|
|
9799
|
-
readPages = (value,
|
|
9799
|
+
readPages = (value, report4) => {
|
|
9800
9800
|
if (value === void 0) return void 0;
|
|
9801
9801
|
if (typeof value === "number") {
|
|
9802
9802
|
if (Number.isInteger(value) && value >= 1 && value <= MAX_PAGES) return value;
|
|
9803
|
-
|
|
9803
|
+
report4("pages", msg(`a page count must be a whole number from 1 to ${MAX_PAGES}`, `\u9875\u6570\u5FC5\u987B\u662F 1 \u5230 ${MAX_PAGES} \u4E4B\u95F4\u7684\u6574\u6570`));
|
|
9804
9804
|
return void 0;
|
|
9805
9805
|
}
|
|
9806
9806
|
if (!Array.isArray(value) || !value.length) {
|
|
9807
|
-
|
|
9807
|
+
report4("pages", msg('must be a page count (3) or a list of page ids (["p1","p2","p3"])', '\u5FC5\u987B\u662F\u9875\u6570\uFF083\uFF09\u6216\u9875 id \u5217\u8868\uFF08["p1","p2","p3"]\uFF09'));
|
|
9808
9808
|
return void 0;
|
|
9809
9809
|
}
|
|
9810
9810
|
const ids3 = value.filter((id2) => typeof id2 === "string" && SAFE_PAGE_ID.test(id2));
|
|
9811
|
-
if (ids3.length !== value.length)
|
|
9811
|
+
if (ids3.length !== value.length) report4("pages", msg("page ids are letters, digits, _ and - (at most 64)", "\u9875 id \u53EA\u80FD\u7528\u5B57\u6BCD\u3001\u6570\u5B57\u3001_ \u548C -\uFF08\u6700\u591A 64 \u4E2A\u5B57\u7B26\uFF09"));
|
|
9812
9812
|
const twice = ids3.find((id2, index) => ids3.indexOf(id2) !== index);
|
|
9813
|
-
if (twice)
|
|
9814
|
-
if (value.length > MAX_PAGES)
|
|
9813
|
+
if (twice) report4("pages", msg(`page id "${twice}" is listed twice`, `\u9875 id "${twice}" \u91CD\u590D\u51FA\u73B0`));
|
|
9814
|
+
if (value.length > MAX_PAGES) report4("pages", msg(`at most ${MAX_PAGES} pages`, `\u6700\u591A ${MAX_PAGES} \u9875`));
|
|
9815
9815
|
return ids3.length === value.length && !twice ? ids3 : void 0;
|
|
9816
9816
|
};
|
|
9817
|
-
readSettings = (value,
|
|
9817
|
+
readSettings = (value, report4) => {
|
|
9818
9818
|
if (value === void 0) return void 0;
|
|
9819
9819
|
if (!isObj(value)) {
|
|
9820
|
-
|
|
9820
|
+
report4("settings", msg("must be an object", "\u5FC5\u987B\u662F\u5BF9\u8C61"));
|
|
9821
9821
|
return void 0;
|
|
9822
9822
|
}
|
|
9823
|
-
noExtraKeys(value, SETTINGS_KEYS, "settings",
|
|
9823
|
+
noExtraKeys(value, SETTINGS_KEYS, "settings", report4);
|
|
9824
9824
|
return {
|
|
9825
|
-
platform: readEnum(value, "platform", PLATFORMS2, "settings",
|
|
9826
|
-
language: readString(value, "language", "settings",
|
|
9827
|
-
channel: readEnum(value, "channel", CHANNELS, "settings",
|
|
9828
|
-
model: readString(value, "model", "settings",
|
|
9825
|
+
platform: readEnum(value, "platform", PLATFORMS2, "settings", report4),
|
|
9826
|
+
language: readString(value, "language", "settings", report4),
|
|
9827
|
+
channel: readEnum(value, "channel", CHANNELS, "settings", report4),
|
|
9828
|
+
model: readString(value, "model", "settings", report4)
|
|
9829
9829
|
};
|
|
9830
9830
|
};
|
|
9831
|
-
readFonts = (value,
|
|
9831
|
+
readFonts = (value, report4) => {
|
|
9832
9832
|
if (value === void 0) return [];
|
|
9833
9833
|
if (!Array.isArray(value) || !value.every((role) => typeof role === "string" && role.trim())) {
|
|
9834
|
-
|
|
9834
|
+
report4("fonts", msg("must be a list of font role ids (popost font list)", "\u5FC5\u987B\u662F\u5B57\u4F53\u89D2\u8272 id \u5217\u8868\uFF08\u89C1 popost font list\uFF09"));
|
|
9835
9835
|
return [];
|
|
9836
9836
|
}
|
|
9837
9837
|
const roles = value.map((role) => role.trim());
|
|
9838
9838
|
const twice = roles.find((role, index) => roles.indexOf(role) !== index);
|
|
9839
|
-
if (twice)
|
|
9839
|
+
if (twice) report4("fonts", msg(`"${twice}" is listed twice`, `"${twice}" \u91CD\u590D\u51FA\u73B0`));
|
|
9840
9840
|
return [...new Set(roles)];
|
|
9841
9841
|
};
|
|
9842
|
-
readReference = (value, base,
|
|
9842
|
+
readReference = (value, base, report4) => {
|
|
9843
9843
|
if (!isObj(value)) {
|
|
9844
|
-
|
|
9844
|
+
report4(base, msg('must be an object like {"file": "inputs/a.jpg", "role": "layout"}', '\u5FC5\u987B\u662F\u5BF9\u8C61\uFF0C\u4F8B\u5982 {"file": "inputs/a.jpg", "role": "layout"}'));
|
|
9845
9845
|
return null;
|
|
9846
9846
|
}
|
|
9847
|
-
noExtraKeys(value, REFERENCE_KEYS, base,
|
|
9848
|
-
const file = readString(value, "file", base,
|
|
9849
|
-
const role = readEnum(value, "role", REF_ROLES, base,
|
|
9850
|
-
const page2 = readString(value, "page", base,
|
|
9847
|
+
noExtraKeys(value, REFERENCE_KEYS, base, report4);
|
|
9848
|
+
const file = readString(value, "file", base, report4, true);
|
|
9849
|
+
const role = readEnum(value, "role", REF_ROLES, base, report4) ?? "layout";
|
|
9850
|
+
const page2 = readString(value, "page", base, report4);
|
|
9851
9851
|
return file === void 0 ? null : { file, role, ...page2 === void 0 ? {} : { page: page2 } };
|
|
9852
9852
|
};
|
|
9853
|
-
readRefs = (value, base,
|
|
9853
|
+
readRefs = (value, base, report4) => {
|
|
9854
9854
|
if (value === void 0) return [];
|
|
9855
9855
|
const list7 = Array.isArray(value) ? value : [value];
|
|
9856
9856
|
if (!list7.length || !list7.every((ref) => typeof ref === "string" && ref.trim())) {
|
|
9857
|
-
|
|
9857
|
+
report4(
|
|
9858
9858
|
at2(base, "ref"),
|
|
9859
9859
|
msg(
|
|
9860
9860
|
"must be a role (layout, identity, style, content, all), a picture path, or a list of them",
|
|
@@ -9865,9 +9865,9 @@ var init_spec = __esm({
|
|
|
9865
9865
|
}
|
|
9866
9866
|
return list7;
|
|
9867
9867
|
};
|
|
9868
|
-
readImage = (value, base,
|
|
9868
|
+
readImage = (value, base, report4) => {
|
|
9869
9869
|
if (!isObj(value)) {
|
|
9870
|
-
|
|
9870
|
+
report4(
|
|
9871
9871
|
base,
|
|
9872
9872
|
msg(
|
|
9873
9873
|
'must be an object like {"id": "hero", "promptFile": "prompts/hero.md", "aspect": "9:16"}',
|
|
@@ -9876,66 +9876,66 @@ var init_spec = __esm({
|
|
|
9876
9876
|
);
|
|
9877
9877
|
return null;
|
|
9878
9878
|
}
|
|
9879
|
-
noExtraKeys(value, IMAGE_KEYS, base,
|
|
9880
|
-
const purpose = readEnum(value, "purpose", PURPOSES, base,
|
|
9881
|
-
const named = readString(value, "id", base,
|
|
9882
|
-
if (named !== void 0 && !JOB_ID.test(named))
|
|
9879
|
+
noExtraKeys(value, IMAGE_KEYS, base, report4);
|
|
9880
|
+
const purpose = readEnum(value, "purpose", PURPOSES, base, report4) ?? "material";
|
|
9881
|
+
const named = readString(value, "id", base, report4, purpose === "material");
|
|
9882
|
+
if (named !== void 0 && !JOB_ID.test(named)) report4(
|
|
9883
9883
|
at2(base, "id"),
|
|
9884
9884
|
msg(`"${named}" is not a valid id (letters, digits, _ and -, at most 64)`, `"${named}" \u4E0D\u662F\u6709\u6548\u7684 id\uFF08\u5B57\u6BCD\u3001\u6570\u5B57\u3001_ \u548C -\uFF0C\u6700\u591A 64 \u4E2A\u5B57\u7B26\uFF09`)
|
|
9885
9885
|
);
|
|
9886
|
-
if (purpose === "material" && named === "composition")
|
|
9887
|
-
if (purpose === "composition" && named !== void 0 && named !== "composition")
|
|
9886
|
+
if (purpose === "material" && named === "composition") report4(at2(base, "id"), msg('"composition" is reserved for the composition job', '"composition" \u4FDD\u7559\u7ED9 composition \u4EFB\u52A1'));
|
|
9887
|
+
if (purpose === "composition" && named !== void 0 && named !== "composition") report4(
|
|
9888
9888
|
at2(base, "id"),
|
|
9889
9889
|
msg('the composition job is always called "composition": leave id out', 'composition \u4EFB\u52A1\u56FA\u5B9A\u53EB "composition"\uFF1A\u4E0D\u8981\u5199 id')
|
|
9890
9890
|
);
|
|
9891
|
-
const promptFile = readString(value, "promptFile", base,
|
|
9892
|
-
const aspect = readString(value, "aspect", base,
|
|
9893
|
-
if (aspect !== void 0 && !ASPECT4.test(aspect))
|
|
9894
|
-
const ref = readRefs(value.ref, base,
|
|
9891
|
+
const promptFile = readString(value, "promptFile", base, report4, true);
|
|
9892
|
+
const aspect = readString(value, "aspect", base, report4);
|
|
9893
|
+
if (aspect !== void 0 && !ASPECT4.test(aspect)) report4(at2(base, "aspect"), msg(`"${aspect}" must be W:H, for example 1:1, 3:4 or 9:16`, `"${aspect}" \u5FC5\u987B\u662F \u5BBD:\u9AD8 \u7684\u5F62\u5F0F\uFF0C\u4F8B\u5982 1:1\u30013:4 \u6216 9:16`));
|
|
9894
|
+
const ref = readRefs(value.ref, base, report4);
|
|
9895
9895
|
if (promptFile === void 0 || purpose === "material" && named === void 0) return null;
|
|
9896
9896
|
return { id: purpose === "composition" ? "composition" : named, promptFile, ...aspect === void 0 ? {} : { aspect }, purpose, ref };
|
|
9897
9897
|
};
|
|
9898
|
-
readList = (value, key2,
|
|
9898
|
+
readList = (value, key2, report4, read2) => {
|
|
9899
9899
|
if (value === void 0) return [];
|
|
9900
9900
|
if (!Array.isArray(value)) {
|
|
9901
|
-
|
|
9901
|
+
report4(key2, msg("must be a list", "\u5FC5\u987B\u662F\u5217\u8868"));
|
|
9902
9902
|
return [];
|
|
9903
9903
|
}
|
|
9904
9904
|
const entries3 = value.map((item2, index) => {
|
|
9905
|
-
const entry2 = read2(item2, `${key2}[${index}]`,
|
|
9905
|
+
const entry2 = read2(item2, `${key2}[${index}]`, report4);
|
|
9906
9906
|
return entry2 === null ? null : { ...entry2, index };
|
|
9907
9907
|
});
|
|
9908
9908
|
return entries3.filter((entry2) => entry2 !== null);
|
|
9909
9909
|
};
|
|
9910
|
-
reportRepeatedJobs = (images,
|
|
9910
|
+
reportRepeatedJobs = (images, report4) => {
|
|
9911
9911
|
const ids3 = images.map((image2) => image2.id);
|
|
9912
9912
|
const twice = ids3.find((id2, index) => ids3.indexOf(id2) !== index);
|
|
9913
|
-
if (twice)
|
|
9913
|
+
if (twice) report4("images", msg(`job id "${twice}" is used twice`, `\u4EFB\u52A1 id "${twice}" \u7528\u4E86\u4E24\u6B21`));
|
|
9914
9914
|
};
|
|
9915
9915
|
parseSpec = (raw) => {
|
|
9916
9916
|
const problems2 = [];
|
|
9917
|
-
const
|
|
9917
|
+
const report4 = (where3, message2) => void problems2.push(`${where3}: ${message2}`);
|
|
9918
9918
|
if (!isObj(raw)) {
|
|
9919
|
-
|
|
9919
|
+
report4("spec", msg("must be a JSON object (see popost setup --help)", "\u5FC5\u987B\u662F JSON \u5BF9\u8C61\uFF08\u89C1 popost setup --help\uFF09"));
|
|
9920
9920
|
return { spec: { references: [], fonts: [], images: [] }, problems: problems2, unusable: true };
|
|
9921
9921
|
}
|
|
9922
|
-
noExtraKeys(raw, SPEC_KEYS, "",
|
|
9923
|
-
const images = readList(raw.images, "images",
|
|
9924
|
-
reportRepeatedJobs(images,
|
|
9925
|
-
const
|
|
9926
|
-
brief: readString(raw, "brief", "",
|
|
9927
|
-
mode: readMode(raw,
|
|
9928
|
-
width: readInt(raw, "width", "",
|
|
9929
|
-
height: readInt(raw, "height", "",
|
|
9930
|
-
pages: readPages(raw.pages,
|
|
9931
|
-
settings: readSettings(raw.settings,
|
|
9932
|
-
references: readList(raw.references, "references",
|
|
9933
|
-
fonts: readFonts(raw.fonts,
|
|
9934
|
-
plan: readString(raw, "plan", "",
|
|
9922
|
+
noExtraKeys(raw, SPEC_KEYS, "", report4);
|
|
9923
|
+
const images = readList(raw.images, "images", report4, readImage);
|
|
9924
|
+
reportRepeatedJobs(images, report4);
|
|
9925
|
+
const spec10 = {
|
|
9926
|
+
brief: readString(raw, "brief", "", report4),
|
|
9927
|
+
mode: readMode(raw, report4),
|
|
9928
|
+
width: readInt(raw, "width", "", report4, 1, MAX_CANVAS),
|
|
9929
|
+
height: readInt(raw, "height", "", report4, 1, MAX_CANVAS),
|
|
9930
|
+
pages: readPages(raw.pages, report4),
|
|
9931
|
+
settings: readSettings(raw.settings, report4),
|
|
9932
|
+
references: readList(raw.references, "references", report4, readReference),
|
|
9933
|
+
fonts: readFonts(raw.fonts, report4),
|
|
9934
|
+
plan: readString(raw, "plan", "", report4),
|
|
9935
9935
|
images,
|
|
9936
|
-
quote: readBool(raw, "quote",
|
|
9936
|
+
quote: readBool(raw, "quote", report4)
|
|
9937
9937
|
};
|
|
9938
|
-
return { spec:
|
|
9938
|
+
return { spec: spec10, problems: problems2 };
|
|
9939
9939
|
};
|
|
9940
9940
|
}
|
|
9941
9941
|
});
|
|
@@ -10050,7 +10050,7 @@ var init_run2 = __esm({
|
|
|
10050
10050
|
runSetup = async (rt, call2) => {
|
|
10051
10051
|
const loaded = await loadSpec(rt, call2.specPath);
|
|
10052
10052
|
if ("error" in loaded) return refused2(loaded.error);
|
|
10053
|
-
const { spec:
|
|
10053
|
+
const { spec: spec10, problems: shape, unusable } = parseSpec(loaded.raw);
|
|
10054
10054
|
if (unusable)
|
|
10055
10055
|
return refused2(msg(`the spec has ${shape.length} problem; nothing was changed`, `spec \u6709 ${shape.length} \u4E2A\u95EE\u9898\uFF1B\u672A\u505A\u4EFB\u4F55\u6539\u52A8`), {
|
|
10056
10056
|
problems: shape
|
|
@@ -10058,7 +10058,7 @@ var init_run2 = __esm({
|
|
|
10058
10058
|
const opened = await openProject(rt, call2.dir);
|
|
10059
10059
|
const ctx = {
|
|
10060
10060
|
rt,
|
|
10061
|
-
spec:
|
|
10061
|
+
spec: spec10,
|
|
10062
10062
|
dir: call2.dir,
|
|
10063
10063
|
specDir: rt.path.dirname(rt.path.resolve(rt.cwd, call2.specPath)),
|
|
10064
10064
|
config: call2.config,
|
|
@@ -10763,11 +10763,11 @@ var init_push = __esm({
|
|
|
10763
10763
|
}
|
|
10764
10764
|
};
|
|
10765
10765
|
rateAware = async (rt, call2) => {
|
|
10766
|
-
for (let
|
|
10766
|
+
for (let attempt3 = 0; ; attempt3++) {
|
|
10767
10767
|
try {
|
|
10768
10768
|
return await call2();
|
|
10769
10769
|
} catch (error2) {
|
|
10770
|
-
if (!(error2 instanceof PopostApiError) || error2.code !== "RATE_LIMITED" ||
|
|
10770
|
+
if (!(error2 instanceof PopostApiError) || error2.code !== "RATE_LIMITED" || attempt3 >= RATE_RETRIES) throw error2;
|
|
10771
10771
|
const asked2 = Number(error2.details.retryAfterSeconds);
|
|
10772
10772
|
const seconds8 = Number.isFinite(asked2) && asked2 > 0 ? Math.min(asked2, MAX_WAIT_SEC) : 5;
|
|
10773
10773
|
await sleep(rt, Math.ceil(seconds8 * 1e3));
|
|
@@ -10902,14 +10902,14 @@ var init_push = __esm({
|
|
|
10902
10902
|
const uploads = { ids: /* @__PURE__ */ new Map(), reused: /* @__PURE__ */ new Set(), uploaded: 0 };
|
|
10903
10903
|
let reply = null;
|
|
10904
10904
|
let fresh = /* @__PURE__ */ new Set();
|
|
10905
|
-
for (let
|
|
10905
|
+
for (let attempt3 = 0; reply === null; attempt3++) {
|
|
10906
10906
|
try {
|
|
10907
10907
|
await ensureUploads(rt, client2, pictures, cache2, fresh, uploads);
|
|
10908
10908
|
const body = syncBody(project, exported.html, pictures, uploads.ids, options);
|
|
10909
10909
|
reply = parseReply(await rateAware(rt, () => client2.request("POST", "/projects/sync", { body, timeoutSec: SYNC_TIMEOUT_SEC })), client2.baseUrl);
|
|
10910
10910
|
} catch (error2) {
|
|
10911
10911
|
const stale = staleAssetIndexes(error2).flatMap((i) => pictures[i] ? [pictures[i].sha] : []);
|
|
10912
|
-
if (
|
|
10912
|
+
if (attempt3 === 0 && stale.length) {
|
|
10913
10913
|
for (const sha2 of stale) uploads.ids.delete(sha2);
|
|
10914
10914
|
fresh = new Set(stale);
|
|
10915
10915
|
continue;
|
|
@@ -11618,26 +11618,26 @@ var init_png = __esm({
|
|
|
11618
11618
|
};
|
|
11619
11619
|
renderPages = async (project, pids, outPaths = {}, force2 = false) => {
|
|
11620
11620
|
const { rt } = project;
|
|
11621
|
-
const
|
|
11621
|
+
const report4 = { paths: {}, rendered: [], unchanged: [] };
|
|
11622
11622
|
const pending3 = [];
|
|
11623
11623
|
for (const pid of pids) {
|
|
11624
11624
|
project.page(pid);
|
|
11625
11625
|
const out2 = outPaths[pid] ?? rt.path.join(project.exportsDir, `${pid}.png`);
|
|
11626
11626
|
const cached2 = force2 ? null : await cachedPng(project, pid, out2);
|
|
11627
11627
|
if (cached2) {
|
|
11628
|
-
|
|
11629
|
-
|
|
11628
|
+
report4.paths[pid] = cached2;
|
|
11629
|
+
report4.unchanged.push(pid);
|
|
11630
11630
|
} else pending3.push({ pid, out: out2 });
|
|
11631
11631
|
}
|
|
11632
|
-
if (!pending3.length) return
|
|
11632
|
+
if (!pending3.length) return report4;
|
|
11633
11633
|
await withBrowser(rt, async (browser) => {
|
|
11634
11634
|
for (const { pid, out: out2 } of pending3) {
|
|
11635
11635
|
await renderOne(project, browser, pid, out2);
|
|
11636
|
-
|
|
11637
|
-
|
|
11636
|
+
report4.paths[pid] = out2;
|
|
11637
|
+
report4.rendered.push(pid);
|
|
11638
11638
|
}
|
|
11639
11639
|
});
|
|
11640
|
-
return
|
|
11640
|
+
return report4;
|
|
11641
11641
|
};
|
|
11642
11642
|
renderPagesPng = async (project, pids, outPaths = {}, force2 = false) => (await renderPages(project, pids, outPaths, force2)).paths;
|
|
11643
11643
|
renderPagePng = async (project, pid, out2, force2 = false) => {
|
|
@@ -11726,9 +11726,9 @@ var init_subcommand = __esm({
|
|
|
11726
11726
|
"src/editor/subcommand.ts"() {
|
|
11727
11727
|
"use strict";
|
|
11728
11728
|
runSubcommand3 = async (rt, argv) => {
|
|
11729
|
-
const { run:
|
|
11729
|
+
const { run: run7 } = await Promise.resolve().then(() => (init_main2(), main_exports));
|
|
11730
11730
|
const out2 = [];
|
|
11731
|
-
const code = await
|
|
11731
|
+
const code = await run7(argv, { ...rt, stdout: (text13) => void out2.push(text13), stderr: () => void 0 });
|
|
11732
11732
|
try {
|
|
11733
11733
|
const parsed = JSON.parse(out2.join("").trim());
|
|
11734
11734
|
return { code, json: parsed && typeof parsed === "object" ? parsed : null };
|
|
@@ -11793,9 +11793,9 @@ var init_routes_get = __esm({
|
|
|
11793
11793
|
const html2 = editorHtml(await ctx.load(), source2, ctx.req.rawQuery, ctx.state.cloud.mode());
|
|
11794
11794
|
return noStoreResponse(html2, "text/html; charset=utf-8");
|
|
11795
11795
|
};
|
|
11796
|
-
staticFile = async (ctx, root, urlPath,
|
|
11796
|
+
staticFile = async (ctx, root, urlPath, missing4) => {
|
|
11797
11797
|
const file = await readProjectFile(ctx.rt, root, urlPath);
|
|
11798
|
-
return file ? fileResponse(file.data, mimeType(file.path)) : notFound(ctx,
|
|
11798
|
+
return file ? fileResponse(file.data, mimeType(file.path)) : notFound(ctx, missing4);
|
|
11799
11799
|
};
|
|
11800
11800
|
EXACT = {
|
|
11801
11801
|
"/api/export-options": exportOptions,
|
|
@@ -12181,10 +12181,10 @@ var init_server = __esm({
|
|
|
12181
12181
|
return state2;
|
|
12182
12182
|
};
|
|
12183
12183
|
createLock = () => {
|
|
12184
|
-
let
|
|
12184
|
+
let tail4 = Promise.resolve();
|
|
12185
12185
|
return (fn) => {
|
|
12186
|
-
const result =
|
|
12187
|
-
|
|
12186
|
+
const result = tail4.then(fn, fn);
|
|
12187
|
+
tail4 = result.catch(() => void 0);
|
|
12188
12188
|
return result;
|
|
12189
12189
|
};
|
|
12190
12190
|
};
|
|
@@ -12368,8 +12368,8 @@ var init_render = __esm({
|
|
|
12368
12368
|
};
|
|
12369
12369
|
};
|
|
12370
12370
|
syncDelivered = async (rt, project) => !commandSyncs(rt) ? void 0 : deliverToCloud(new CloudService(rt, () => project.root), project.manifest.language?.toLowerCase().startsWith("zh") ? "zh" : "en");
|
|
12371
|
-
rendering = (
|
|
12372
|
-
spec: { ...
|
|
12371
|
+
rendering = (spec10, prepare4 = false) => ({
|
|
12372
|
+
spec: { ...spec10, options: [DIR3, ...spec10.options ?? []] },
|
|
12373
12373
|
run: async (args, rt) => {
|
|
12374
12374
|
const project = await Project.load(rt, args.req("dir"));
|
|
12375
12375
|
let before = {};
|
|
@@ -12579,8 +12579,8 @@ var init_sheet_layout = __esm({
|
|
|
12579
12579
|
return taken;
|
|
12580
12580
|
};
|
|
12581
12581
|
const head = take(chars, room * 0.6);
|
|
12582
|
-
const
|
|
12583
|
-
return `${head.join("")}\u2026${
|
|
12582
|
+
const tail4 = take([...chars].reverse(), room * 0.4).reverse();
|
|
12583
|
+
return `${head.join("")}\u2026${tail4.join("")}`;
|
|
12584
12584
|
};
|
|
12585
12585
|
layoutSheet = (bands) => {
|
|
12586
12586
|
const groups2 = bands.filter((band) => band.length > 0);
|
|
@@ -12667,10 +12667,10 @@ var init_sheet2 = __esm({
|
|
|
12667
12667
|
}
|
|
12668
12668
|
return args.has("labels") ? msg("--labels only goes with --files", "--labels \u53EA\u80FD\u914D\u5408 --files \u4F7F\u7528") : null;
|
|
12669
12669
|
};
|
|
12670
|
-
selectedPages = (project,
|
|
12670
|
+
selectedPages = (project, spec10) => {
|
|
12671
12671
|
const all = project.manifest.pages.map((page2) => page2.id);
|
|
12672
|
-
if (
|
|
12673
|
-
const wanted =
|
|
12672
|
+
if (spec10 === "all") return all;
|
|
12673
|
+
const wanted = spec10.split(",").map((id2) => id2.trim()).filter(Boolean);
|
|
12674
12674
|
const unknown = wanted.filter((id2) => !all.includes(id2));
|
|
12675
12675
|
if (unknown.length)
|
|
12676
12676
|
throw new ValueError(
|
|
@@ -12947,11 +12947,11 @@ var init_batch_run = __esm({
|
|
|
12947
12947
|
`${ids3.join(", ")} \u7684\u7ED3\u679C\u4E0D\u660E\uFF1A\u5148\u67E5\u770B\u8D26\u53F7\uFF0C\u786E\u6709\u9700\u8981\u518D\u8FD0\u884C image quote --dir ${dir} --id ${ids3.join(",")} \u548C image run --quote-id <\u65B0\u62A5\u4EF7> --confirm\uFF1B\u6CBF\u7528\u539F\u6765\u7684\u5E42\u7B49\u952E\uFF0C\u5E73\u53F0\u53EA\u6263\u4E00\u6B21\u8D39`
|
|
12948
12948
|
);
|
|
12949
12949
|
standing = async (project, quoteId2) => {
|
|
12950
|
-
const
|
|
12951
|
-
if (
|
|
12952
|
-
if (
|
|
12953
|
-
if (
|
|
12954
|
-
if (
|
|
12950
|
+
const attempt3 = await attempt(project.rt, ledgerPathOf2(project), quoteId2).catch(() => null);
|
|
12951
|
+
if (attempt3?.state === "consumed") return { outcome: "failed", charged: true };
|
|
12952
|
+
if (attempt3?.state === "failed") return { outcome: "failed", charged: true };
|
|
12953
|
+
if (attempt3?.state === "submitted") return { outcome: "pending", charged: true };
|
|
12954
|
+
if (attempt3 && attempt3.charged !== false) return { outcome: "ambiguous", charged: "unknown" };
|
|
12955
12955
|
return { outcome: "failed", charged: false };
|
|
12956
12956
|
};
|
|
12957
12957
|
failedRow = async (project, entry2, quoteId2, code, error2) => ({
|
|
@@ -14099,8 +14099,8 @@ var init_inspiration_plan = __esm({
|
|
|
14099
14099
|
const b = bundle;
|
|
14100
14100
|
if (b.parseStatus !== "ready" && !options.allowIncomplete) {
|
|
14101
14101
|
const errorsOf = b.errors ?? [];
|
|
14102
|
-
const
|
|
14103
|
-
const detail2 = [...errorsOf, ...
|
|
14102
|
+
const missing4 = (b.missing ?? []).map((m) => msg(`missing ${m}`, `\u7F3A ${m}`));
|
|
14103
|
+
const detail2 = [...errorsOf, ...missing4].join(msg("; ", "\uFF1B")) || msg("no reason given", "\u672A\u8BF4\u660E");
|
|
14104
14104
|
throw new InputError(
|
|
14105
14105
|
msg(
|
|
14106
14106
|
`PostBundle parseStatus=${String(b.parseStatus)}: the content is incomplete (${detail2}). Complete it from local screenshots or text and mark it ready first, or, to save only what is there, add --allow-incomplete`,
|
|
@@ -15733,7 +15733,7 @@ var init_browser = __esm({
|
|
|
15733
15733
|
for (const root of roots2) {
|
|
15734
15734
|
if (!existsSync(root)) continue;
|
|
15735
15735
|
for (const dir of readdirSync(root).filter((d) => /^chromium/.test(d)).sort().reverse())
|
|
15736
|
-
for (const
|
|
15736
|
+
for (const tail4 of tails) out2.push(path.join(root, dir, ...tail4));
|
|
15737
15737
|
}
|
|
15738
15738
|
return out2;
|
|
15739
15739
|
};
|
|
@@ -16075,8 +16075,8 @@ var init_chunks = __esm({
|
|
|
16075
16075
|
const last = out2[out2.length - 1];
|
|
16076
16076
|
return last && last[1] - last[0] < shortest ? [...out2.slice(0, -1), [last[0], end]] : [...out2, [bounds2[i], end]];
|
|
16077
16077
|
}, []);
|
|
16078
|
-
const
|
|
16079
|
-
const ranges =
|
|
16078
|
+
const tail4 = joined[joined.length - 1], before = joined[joined.length - 2];
|
|
16079
|
+
const ranges = tail4 && before && tail4[1] - tail4[0] < shortest ? [...joined.slice(0, -2), [before[0], tail4[1]]] : joined;
|
|
16080
16080
|
const longest = Math.max(shortest, Math.round(r.canvas.fps * MAX_CHUNK_SECONDS));
|
|
16081
16081
|
return ranges.flatMap(([from, to]) => {
|
|
16082
16082
|
const count5 = Math.ceil((to - from) / longest);
|
|
@@ -16282,9 +16282,9 @@ var init_motion = __esm({
|
|
|
16282
16282
|
return { blur: BLUR_START * (1 - e), opacity: e };
|
|
16283
16283
|
}
|
|
16284
16284
|
};
|
|
16285
|
-
motionState = (
|
|
16286
|
-
const eased =
|
|
16287
|
-
const partial = phase === "enter" ? entrance(
|
|
16285
|
+
motionState = (spec10, phase, t) => {
|
|
16286
|
+
const eased = spec10.preset === "type" ? clamp01(t) : ease(spec10.ease, t);
|
|
16287
|
+
const partial = phase === "enter" ? entrance(spec10, spec10.direction, eased) : entrance(spec10, OPPOSITE[spec10.direction], 1 - eased);
|
|
16288
16288
|
return { ...IDENTITY_ELEMENT, ...partial };
|
|
16289
16289
|
};
|
|
16290
16290
|
}
|
|
@@ -17303,38 +17303,38 @@ var init_check_footage = __esm({
|
|
|
17303
17303
|
const f = ctx.footage[id2];
|
|
17304
17304
|
return f && !("error" in f) ? f : void 0;
|
|
17305
17305
|
};
|
|
17306
|
-
runsOutAt = (ctx,
|
|
17306
|
+
runsOutAt = (ctx, spec10, f, span2) => {
|
|
17307
17307
|
const last = f.frames - 1;
|
|
17308
|
-
const raw = (n2) => (
|
|
17308
|
+
const raw = (n2) => (spec10.in ?? 0) + Math.round((n2 - span2.start) * f.fps * (spec10.speed ?? 1) / ctx.fps);
|
|
17309
17309
|
if (span2.end <= span2.start || raw(span2.end - 1) <= last) return void 0;
|
|
17310
17310
|
let n = span2.start;
|
|
17311
17311
|
while (raw(n) <= last) n++;
|
|
17312
17312
|
return n;
|
|
17313
17313
|
};
|
|
17314
17314
|
sourceText = (file, f) => '"' + (file ?? "?") + '" has ' + f.frames + " frames (" + (f.frames / f.fps).toFixed(2) + " s at " + Number(f.fps.toFixed(3)) + " fps)";
|
|
17315
|
-
soundProblems = (
|
|
17316
|
-
if (
|
|
17315
|
+
soundProblems = (spec10, f, id2, at7) => {
|
|
17316
|
+
if (spec10.audio === void 0 || spec10.audio === false) return [];
|
|
17317
17317
|
if (!f.hasAudio) return [warning(at7 + ".audio", 'Material "' + id2 + '" has no sound track, so "audio" has no effect.', 'Remove "audio", or use a file with sound.')];
|
|
17318
17318
|
return [];
|
|
17319
17319
|
};
|
|
17320
17320
|
silentBedProblems = (ctx, id2, at7, track) => factsOf(ctx, id2)?.hasAudio === false ? [warning(at7, 'The bed "' + track + '" plays the sound of "' + id2 + '", which has no sound track (a clip made without sound), so it adds nothing to the mix.', "Remove the bed, or use a clip with sound.")] : [];
|
|
17321
17321
|
SLOWED = 0.9;
|
|
17322
|
-
slowProblems = (
|
|
17322
|
+
slowProblems = (spec10, at7, what) => typeof spec10.speed === "number" && spec10.speed < SLOWED ? [warning(
|
|
17323
17323
|
at7 + ".speed",
|
|
17324
|
-
what + " plays at " +
|
|
17324
|
+
what + " plays at " + spec10.speed + " of its speed: everything in it moves slower than it was made, and a clip slowed down to fill a shot looks slowed down.",
|
|
17325
17325
|
'Set "speed" to 1 or more and give the shot enough footage (a longer clip, a second clip, an earlier "in"); keep a lower speed only when the reference shot itself is in slow motion.'
|
|
17326
17326
|
)] : [];
|
|
17327
|
-
checkPlay = (ctx,
|
|
17327
|
+
checkPlay = (ctx, spec10, id2, at7, what, span2) => {
|
|
17328
17328
|
const m = ctx.materials.get(id2);
|
|
17329
17329
|
if (!m) return [];
|
|
17330
17330
|
if (m.kind !== "video")
|
|
17331
|
-
return FOOTAGE_KEYS.filter((k) =>
|
|
17331
|
+
return FOOTAGE_KEYS.filter((k) => spec10[k] !== void 0).map((k) => error(at7 + "." + k, '"' + k + '" applies to a video material, but "' + id2 + '" is ' + (m.kind === "image" ? "an image" : "a " + m.kind) + " material.", 'Remove "' + k + '", or use a video material.'));
|
|
17332
17332
|
const f = factsOf(ctx, id2);
|
|
17333
|
-
if (!f) return slowProblems(
|
|
17334
|
-
const sound2 = [...slowProblems(
|
|
17335
|
-
if ((
|
|
17336
|
-
return [error(at7 + ".in", what + " starts at source frame " +
|
|
17337
|
-
const out2 = span2 ? runsOutAt(ctx,
|
|
17333
|
+
if (!f) return slowProblems(spec10, at7, what);
|
|
17334
|
+
const sound2 = [...slowProblems(spec10, at7, what), ...soundProblems(spec10, f, id2, at7)];
|
|
17335
|
+
if ((spec10.in ?? 0) > f.frames - 1)
|
|
17336
|
+
return [error(at7 + ".in", what + " starts at source frame " + spec10.in + ", but " + sourceText(m.file, f) + ".", 'Set "in" to at most ' + (f.frames - 1) + " (frames are counted from 0 at the source's own rate)."), ...sound2];
|
|
17337
|
+
const out2 = span2 ? runsOutAt(ctx, spec10, f, span2) : void 0;
|
|
17338
17338
|
if (out2 === void 0 || !span2) return sound2;
|
|
17339
17339
|
return [
|
|
17340
17340
|
warning(
|
|
@@ -17975,6 +17975,8 @@ var init_contract = __esm({
|
|
|
17975
17975
|
audio: findingSchema.optional(),
|
|
17976
17976
|
visual: findingSchema.optional(),
|
|
17977
17977
|
events: z.array(findingSchema.extend({ id: text4 })).optional(),
|
|
17978
|
+
/** Independent visual and audible continuity verdicts at actual output-frame boundaries. */
|
|
17979
|
+
joins: z.array(findingSchema.extend({ at: z.number().int().positive() })).optional(),
|
|
17978
17980
|
/** Include every speech command, external sound, native clip sound and audio bed, or [] for silence. */
|
|
17979
17981
|
audioUses: z.array(audioUseSchema).optional()
|
|
17980
17982
|
});
|
|
@@ -18568,10 +18570,10 @@ var init_footage2 = __esm({
|
|
|
18568
18570
|
const { fs, path: path2 } = rt;
|
|
18569
18571
|
await fs.mkdir(job.dir);
|
|
18570
18572
|
const have = new Set(await fs.readdir(job.dir));
|
|
18571
|
-
const
|
|
18572
|
-
if (
|
|
18573
|
-
const lo =
|
|
18574
|
-
const hi =
|
|
18573
|
+
const missing4 = job.frames.filter((f) => !have.has(frameName(f)));
|
|
18574
|
+
if (missing4.length === 0) return { extracted: 0, reused: job.frames.length };
|
|
18575
|
+
const lo = missing4[0] ?? 0;
|
|
18576
|
+
const hi = missing4[missing4.length - 1] ?? 0;
|
|
18575
18577
|
const tmp = path2.join(job.dir, ".extract-" + rt.randomUUID());
|
|
18576
18578
|
await fs.mkdir(tmp);
|
|
18577
18579
|
try {
|
|
@@ -18598,11 +18600,11 @@ var init_footage2 = __esm({
|
|
|
18598
18600
|
path2.join(tmp, "%0" + FRAME_DIGITS + "d.png")
|
|
18599
18601
|
]);
|
|
18600
18602
|
const written2 = new Set(await fs.readdir(tmp));
|
|
18601
|
-
const absent2 =
|
|
18603
|
+
const absent2 = missing4.filter((f) => !written2.has(frameName(f - lo)));
|
|
18602
18604
|
if (absent2.length > 0)
|
|
18603
18605
|
throw new Error("Extracting frames " + lo + ".." + hi + " of " + job.file + " gave " + written2.size + " pictures; frame " + absent2[0] + " is missing. The file may be damaged or shorter than its header says; re-encode it with ffmpeg.");
|
|
18604
|
-
for (const f of
|
|
18605
|
-
return { extracted:
|
|
18606
|
+
for (const f of missing4) await fs.rename(path2.join(tmp, frameName(f - lo)), path2.join(job.dir, frameName(f)));
|
|
18607
|
+
return { extracted: missing4.length, reused: job.frames.length - missing4.length };
|
|
18606
18608
|
} finally {
|
|
18607
18609
|
await fs.rm(tmp);
|
|
18608
18610
|
}
|
|
@@ -19401,10 +19403,10 @@ var init_gradual = __esm({
|
|
|
19401
19403
|
};
|
|
19402
19404
|
keepsMoving = (sg, s, e, dab) => {
|
|
19403
19405
|
const still = Math.max(0.8, 0.02 * dab);
|
|
19404
|
-
let
|
|
19406
|
+
let run7 = 0, longest = 0;
|
|
19405
19407
|
for (let m = s + 1; m < e; m++) {
|
|
19406
|
-
|
|
19407
|
-
longest = Math.max(longest,
|
|
19408
|
+
run7 = dist(sg, m, m - 1) < still && !viaOf(sg, m) ? run7 + 1 : 0;
|
|
19409
|
+
longest = Math.max(longest, run7);
|
|
19408
19410
|
}
|
|
19409
19411
|
return longest <= Math.max(3, 0.25 * (e - s));
|
|
19410
19412
|
};
|
|
@@ -20196,12 +20198,12 @@ var init_switch = __esm({
|
|
|
20196
20198
|
};
|
|
20197
20199
|
GLITCH_VERTICAL = 0.12;
|
|
20198
20200
|
NOISE = 2e-3;
|
|
20199
|
-
joltKind = (
|
|
20200
|
-
const sx =
|
|
20201
|
-
if (sy > GLITCH_VERTICAL * sx + NOISE *
|
|
20201
|
+
joltKind = (moved2) => {
|
|
20202
|
+
const sx = moved2.reduce((s, x2) => s + Math.abs(x2.dx), 0), sy = moved2.reduce((s, x2) => s + Math.abs(x2.dy), 0);
|
|
20203
|
+
if (sy > GLITCH_VERTICAL * sx + NOISE * moved2.length) return "shake";
|
|
20202
20204
|
let flips = 0, keeps = 0;
|
|
20203
|
-
for (let i = 1; i <
|
|
20204
|
-
const p =
|
|
20205
|
+
for (let i = 1; i < moved2.length; i++) {
|
|
20206
|
+
const p = moved2[i - 1], q = moved2[i];
|
|
20205
20207
|
if (p.side !== q.side || p.frame === void 0 || q.frame !== p.frame + 1 || Math.abs(p.dx) < 4e-3 || Math.abs(q.dx) < 4e-3) continue;
|
|
20206
20208
|
if (Math.sign(p.dx) !== Math.sign(q.dx)) flips++;
|
|
20207
20209
|
else keeps++;
|
|
@@ -20221,12 +20223,12 @@ var init_switch = __esm({
|
|
|
20221
20223
|
FULL = 0.97;
|
|
20222
20224
|
PURE_SHIFT = 0.01;
|
|
20223
20225
|
SCALED = 0.03;
|
|
20224
|
-
whipDirection = (
|
|
20225
|
-
const sx =
|
|
20226
|
-
const ax =
|
|
20226
|
+
whipDirection = (moved2, side) => {
|
|
20227
|
+
const sx = moved2.reduce((s, x2) => s + x2.dx, 0), sy = moved2.reduce((s, x2) => s + x2.dy, 0);
|
|
20228
|
+
const ax = moved2.reduce((s, x2) => s + Math.abs(x2.dx), 0), ay = moved2.reduce((s, x2) => s + Math.abs(x2.dy), 0);
|
|
20227
20229
|
const horizontal = ax >= ay;
|
|
20228
20230
|
const net = horizontal ? sx : sy, path2 = horizontal ? ax : ay;
|
|
20229
|
-
if (
|
|
20231
|
+
if (moved2.length < 2 || Math.abs(net) < 0.9 * path2 || path2 < 0.04) return void 0;
|
|
20230
20232
|
const way = side < 0 ? Math.sign(net) : -Math.sign(net);
|
|
20231
20233
|
return horizontal ? way > 0 ? "right" : "left" : way > 0 ? "down" : "up";
|
|
20232
20234
|
};
|
|
@@ -20234,7 +20236,7 @@ var init_switch = __esm({
|
|
|
20234
20236
|
const reads = fx.map((f) => f.read);
|
|
20235
20237
|
const count5 = (k) => reads.filter((r) => r.kind === k).length;
|
|
20236
20238
|
const veils = reads.flatMap((r) => r.kind === "veiled" ? [r] : []);
|
|
20237
|
-
const
|
|
20239
|
+
const moved2 = reads.flatMap((r) => r.kind === "moved" ? [r] : []);
|
|
20238
20240
|
const turned = reads.flatMap((r) => r.kind === "turned" ? [r] : []);
|
|
20239
20241
|
if (veils.length * 2 >= reads.length) {
|
|
20240
20242
|
const white = veils.filter((v) => v.via === "white").length * 2 >= veils.length;
|
|
@@ -20242,11 +20244,11 @@ var init_switch = __esm({
|
|
|
20242
20244
|
return { kind: "fade", via: white ? "white" : "black" };
|
|
20243
20245
|
}
|
|
20244
20246
|
if (turned.some((r) => r.deg >= 20)) return { kind: "spin" };
|
|
20245
|
-
if (count5("blurred") >= Math.max(
|
|
20246
|
-
if (
|
|
20247
|
-
const way =
|
|
20247
|
+
if (count5("blurred") >= Math.max(moved2.length, turned.length, 1)) return { kind: "blur" };
|
|
20248
|
+
if (moved2.length && moved2.every((r) => Math.abs(r.dx) < PURE_SHIFT && Math.abs(r.dy) < PURE_SHIFT) && moved2.some((r) => Math.abs(r.scale - 1) >= SCALED)) return { kind: "zoom" };
|
|
20249
|
+
const way = moved2.every((r) => Math.abs(r.scale - 1) < SCALED) ? whipDirection(moved2, side) : void 0;
|
|
20248
20250
|
if (way) return { kind: "whip", direction: way };
|
|
20249
|
-
if (
|
|
20251
|
+
if (moved2.length) return { kind: joltKind(fx.flatMap((f) => f.read.kind === "moved" ? [{ ...f.read, frame: f.frame, side: f.side }] : [])) };
|
|
20250
20252
|
return { kind: turned.length ? "spin" : "blur" };
|
|
20251
20253
|
};
|
|
20252
20254
|
oneSidedKind = (r) => {
|
|
@@ -20973,8 +20975,8 @@ var init_camera2 = __esm({
|
|
|
20973
20975
|
measureCamera = (c) => {
|
|
20974
20976
|
if (c.gray.length < 3) return UNKNOWN;
|
|
20975
20977
|
const st = steps(c);
|
|
20976
|
-
const
|
|
20977
|
-
if (
|
|
20978
|
+
const moved2 = mayMove(st) ? withMove(c) : void 0;
|
|
20979
|
+
if (moved2) return moved2;
|
|
20978
20980
|
const good = st.filter((s) => s.ok);
|
|
20979
20981
|
if (good.length < Math.max(1, 0.5 * st.length)) return UNKNOWN;
|
|
20980
20982
|
let S = 1, tx = 0, ty = 0, time = 0;
|
|
@@ -21788,7 +21790,7 @@ var init_reveal = __esm({
|
|
|
21788
21790
|
const all = pointsOf(mask2, w);
|
|
21789
21791
|
if (all.nNew < 4 || all.nNew === all.n) return void 0;
|
|
21790
21792
|
const front = frontOf(all, origin);
|
|
21791
|
-
const
|
|
21793
|
+
const run7 = Math.hypot(front[0] - origin[0], front[1] - origin[1]);
|
|
21792
21794
|
const straight = straightFit(all);
|
|
21793
21795
|
const edges = edgePixels(mask2, w, h);
|
|
21794
21796
|
const circle = circleFit(all, edges, w, h);
|
|
@@ -21803,7 +21805,7 @@ var init_reveal = __esm({
|
|
|
21803
21805
|
const base = { front, edge, box: [x0, y0, x1 - x0 + 1, y1 - y0 + 1] };
|
|
21804
21806
|
if (straight.fit >= CLEAN_FIT && straight.fit >= (circle?.fit ?? 0) - 0.03) return { ...base, shape: { shape: "straight", fit: straight.fit, angle: straight.angle } };
|
|
21805
21807
|
if (circle && circle.fit >= CLEAN_FIT) return { ...base, shape: { shape: "circle", fit: circle.fit, centre: circle.centre, grows: circle.grows } };
|
|
21806
|
-
const head =
|
|
21808
|
+
const head = run7 > 1 ? headOf(mask2, w, h, front, [(front[0] - origin[0]) / run7, (front[1] - origin[1]) / run7]) : void 0;
|
|
21807
21809
|
const rest = head ? pointsOf(mask2, w, head.pixels) : all;
|
|
21808
21810
|
const wedge = rest.nNew >= 4 && rest.nNew < rest.n ? wedgeFit(rest, head ? head.neck : front) : { fit: 0, angle: 0, spread: 0 };
|
|
21809
21811
|
const shape = wedge.fit >= WEDGE_FIT && wedge.spread <= WIDEST ? { shape: "wedge", fit: wedge.fit, angle: wedge.angle, spread: wedge.spread } : { shape: "irregular", fit: Math.max(straight.fit, circle?.fit ?? 0, wedge.fit) };
|
|
@@ -22399,14 +22401,14 @@ var init_submit_retry = __esm({
|
|
|
22399
22401
|
};
|
|
22400
22402
|
sendIdempotent = async (rt, send2, o = {}) => {
|
|
22401
22403
|
const tries = o.tries ?? SUBMIT_TRIES, pause2 = o.pauseMs ?? SUBMIT_PAUSE_MS;
|
|
22402
|
-
for (let
|
|
22404
|
+
for (let attempt3 = 1; ; attempt3 += 1) {
|
|
22403
22405
|
try {
|
|
22404
22406
|
return await send2();
|
|
22405
22407
|
} catch (error2) {
|
|
22406
|
-
const unknown = error2 instanceof AmbiguousSubmitError ||
|
|
22408
|
+
const unknown = error2 instanceof AmbiguousSubmitError || attempt3 > 1 && o.stillWorking?.(error2) === true;
|
|
22407
22409
|
if (!unknown) throw error2;
|
|
22408
|
-
if (
|
|
22409
|
-
await sleep(rt, pause2 * 2 ** (
|
|
22410
|
+
if (attempt3 >= tries) throw lastWord(error2, tries);
|
|
22411
|
+
await sleep(rt, pause2 * 2 ** (attempt3 - 1));
|
|
22410
22412
|
}
|
|
22411
22413
|
}
|
|
22412
22414
|
};
|
|
@@ -22602,12 +22604,12 @@ var init_paid_download = __esm({
|
|
|
22602
22604
|
};
|
|
22603
22605
|
downloadPaid = async (rt, url, o) => {
|
|
22604
22606
|
const href = checkUrl(url, "the link of " + o.what);
|
|
22605
|
-
for (let
|
|
22607
|
+
for (let attempt3 = 1; ; attempt3 += 1) {
|
|
22606
22608
|
const got = await once2(rt, href, o);
|
|
22607
22609
|
if (got instanceof Uint8Array) return got;
|
|
22608
|
-
if (!got.retry ||
|
|
22609
|
-
throw new ToolError(capital(o.what) + " could not be downloaded (" + got.reason + (
|
|
22610
|
-
await sleep(rt, DOWNLOAD_PAUSES_MS[Math.min(
|
|
22610
|
+
if (!got.retry || attempt3 >= DOWNLOAD_TRIES)
|
|
22611
|
+
throw new ToolError(capital(o.what) + " could not be downloaded (" + got.reason + (attempt3 > 1 ? "; tried " + attempt3 + " times" : "") + "). " + o.again);
|
|
22612
|
+
await sleep(rt, DOWNLOAD_PAUSES_MS[Math.min(attempt3, DOWNLOAD_PAUSES_MS.length) - 1] ?? 0);
|
|
22611
22613
|
}
|
|
22612
22614
|
};
|
|
22613
22615
|
}
|
|
@@ -22981,7 +22983,7 @@ var init_dialogue = __esm({
|
|
|
22981
22983
|
return s.lines.map((l) => {
|
|
22982
22984
|
const text13 = typeof l.text === "string" ? l.text : "";
|
|
22983
22985
|
const length2 = Math.max(ESTIMATE.least, spokenChars(text13).length / (wideText(text13) ? ORDINARY_PACE.wide : ORDINARY_PACE.latin));
|
|
22984
|
-
const line = { speaker: l.speaker, text: text13, at: r2(t), to: r2(t + length2) };
|
|
22986
|
+
const line = { speaker: l.speaker, text: text13, at: r2(t), to: r2(t + length2), ...l.offscreen ? { offscreen: true } : {} };
|
|
22985
22987
|
t += length2 + ESTIMATE.gap;
|
|
22986
22988
|
return line;
|
|
22987
22989
|
});
|
|
@@ -22992,7 +22994,7 @@ var init_dialogue = __esm({
|
|
|
22992
22994
|
const shot = times ? firstShot(s, times) : void 0;
|
|
22993
22995
|
const zero = times && shot !== void 0 ? times.shots[shot] ?? 0 : 0;
|
|
22994
22996
|
return s.lines.map((l) => {
|
|
22995
|
-
const said = { speaker: l.speaker, text: l.text };
|
|
22997
|
+
const said = { speaker: l.speaker, text: l.text, ...l.offscreen ? { offscreen: true } : {} };
|
|
22996
22998
|
if (l.beat !== void 0) {
|
|
22997
22999
|
const b = times && shot !== void 0 && Number.isInteger(l.beat) ? times.beats[l.beat] : void 0;
|
|
22998
23000
|
return b && times ? { ...said, at: r2((b.start - zero) / times.fps), to: r2((b.end - zero) / times.fps), beat: l.beat } : void 0;
|
|
@@ -23022,7 +23024,8 @@ var init_dialogue = __esm({
|
|
|
23022
23024
|
out2.push(error(where3, "A line says who speaks and the exact words.", `Write {"speaker": "<a role of this clip's cast>", "text": "The exact words", "beat": <the beat it re-makes>}.`));
|
|
23023
23025
|
return;
|
|
23024
23026
|
}
|
|
23025
|
-
if (
|
|
23027
|
+
if (l.offscreen !== void 0 && typeof l.offscreen !== "boolean") out2.push(error(where3 + ".offscreen", "Offscreen is a boolean.", "Set it to true only for dialogue heard from outside the frame."));
|
|
23028
|
+
if (l.offscreen !== true && !o.cast.includes(l.speaker)) out2.push(error(where3 + ".speaker", "The speaker " + quote2(l.speaker) + ` is not in this clip's "cast" (` + (o.cast.join(", ") || "empty") + ").", 'Name a role of the cast, or add the role to "cast" (cast.json has the roles).'));
|
|
23026
23029
|
if (typeof s.language === "string" && TAG.test(s.language.trim()) && spokenChars(l.text).length && wideLanguage(s.language) !== wideText(l.text))
|
|
23027
23030
|
out2.push(error(where3 + ".text", "The line " + quote2(l.text) + " is not written in the script of its language (" + languageName(s.language) + ").", "Write the line in " + languageName(s.language) + ', or correct "language" to the language the line is in.'));
|
|
23028
23031
|
const timed = l.at !== void 0 || l.to !== void 0;
|
|
@@ -23030,7 +23033,8 @@ var init_dialogue = __esm({
|
|
|
23030
23033
|
else if (l.beat !== void 0) {
|
|
23031
23034
|
if (!times) out2.push(error(where3 + ".beat", "The time of beat " + JSON.stringify(l.beat) + " is the template's, and no template was given.", "Run the command with --template <the template directory>."));
|
|
23032
23035
|
else if (!Number.isInteger(l.beat) || !times.beats[l.beat]) out2.push(error(where3 + ".beat", "The template has no beat " + JSON.stringify(l.beat) + " (its beats are 0 to " + (times.beats.length - 1) + ").", "Write the number of the beat this line re-makes, as timeline.md and TEMPLATE.md number them."));
|
|
23033
|
-
else if (
|
|
23036
|
+
else if (l.offscreen === true && times.beats[l.beat]?.speech === "on-camera") out2.push(error(where3 + ".beat", "This reference beat has a visible speaker.", "Use a visible cast role for this beat and move the offscreen line to its own original beat."));
|
|
23037
|
+
else if (times.kinds && !l.offscreen && times.beats[l.beat]?.speech !== "on-camera") out2.push(error(where3 + ".beat", "Beat " + l.beat + " is not said on camera in the reference: no person of a clip says it.", `Name only beats TEMPLATE.md marks "on camera"; narration is the voice-over's (the fill's "voice").`));
|
|
23034
23038
|
} else if (hasBeats) out2.push(error(where3, "A line of a video made from a template names the beat it re-makes; its time is the program's, not written by hand.", 'Write "beat": <the number of its beat> and remove "at" and "to".'));
|
|
23035
23039
|
else if (!free && !(typeof l.at === "number" && typeof l.to === "number" && l.at >= 0 && l.to > l.at)) out2.push(error(where3, `Without a template's beats the lines of a clip either all say when they are spoken ("at" and "to" in seconds, "to" after "at") or none does: the program then gives them slots by an ordinary speaking rate.`, 'Write "at": 0.5, "to": 2.8 on every line, or remove "at" and "to" from all of them.'));
|
|
23036
23040
|
});
|
|
@@ -23077,6 +23081,14 @@ var init_dialogue = __esm({
|
|
|
23077
23081
|
noMusic = () => pl(NO_MUSIC, " \u672C\u7247\u6BB5\u6CA1\u6709\u80CC\u666F\u97F3\u4E50\uFF0C\u4E5F\u6CA1\u6709\u914D\u4E50\uFF1A\u53EA\u6709\u573A\u666F\u7684\u73AF\u5883\u58F0\u3001\u97F3\u6548\u548C\u5BF9\u767D\u3002\u89C6\u9891\u7684\u97F3\u4E50\u662F\u5355\u72EC\u7684\u4E00\u6761\u97F3\u8F68\u3002");
|
|
23078
23082
|
dialoguePrompt = (d) => {
|
|
23079
23083
|
const speakers = [...new Set(d.lines.map((l) => l.speaker))];
|
|
23084
|
+
if (d.lines.some((line) => line.offscreen)) {
|
|
23085
|
+
const zh = pl("", "zh");
|
|
23086
|
+
const timeline3 = d.lines.map((line) => {
|
|
23087
|
+
const role = line.offscreen ? zh ? "\uFF08\u753B\u5916\uFF0C\u4E0D\u51FA\u955C\uFF09" : " (off camera, heard only)" : zh ? "\uFF08\u51FA\u955C\uFF0C\u5BF9\u53E3\u578B\uFF09" : " (visible, lip-synced)";
|
|
23088
|
+
return stamp2(line.at) + "-" + stamp2(line.to) + (zh ? " \u79D2 " : " s ") + line.speaker + role + (zh ? " \u8BF4 " : " says ") + JSON.stringify(line.text);
|
|
23089
|
+
}).join(zh ? "\uFF1B" : "; ");
|
|
23090
|
+
return zh ? " \u7528" + languageName(d.language) + "\u6309\u65F6\u95F4\u539F\u751F\u5F55\u5236\u4EE5\u4E0B\u5BF9\u767D\uFF1A" + timeline3 + "\u3002\u753B\u5916\u8BF4\u8BDD\u4EBA\u7684\u58F0\u97F3\u6765\u81EA\u955C\u5934\u540E\u65B9\uFF0C\u753B\u9762\u4E0D\u51FA\u73B0\u753B\u5916\u8BF4\u8BDD\u4EBA\u3002\u51FA\u955C\u4EBA\u7269\u53EA\u5728\u81EA\u5DF1\u7684\u53F0\u8BCD\u65F6\u5BF9\u53E3\u578B\uFF0C\u542C\u5BF9\u65B9\u65F6\u81EA\u7136\u53CD\u5E94\u3002\u6CA1\u6709\u989D\u5916\u5BF9\u767D\u3001\u65C1\u767D\u3001\u5B57\u5E55\u6216\u5C4F\u5E55\u6587\u5B57\u3002" : " Record this native dialogue in " + languageName(d.language) + ": " + timeline3 + ". Off-camera speakers are heard from behind the camera and are never shown in those lines. Visible speakers lip-sync only to their own lines and react naturally while listening. No extra dialogue, narrator, captions or on-screen text.";
|
|
23091
|
+
}
|
|
23080
23092
|
if (pl("", "zh")) return " \u5BF9\u767D\uFF1A\u7528" + languageName(d.language) + "\u539F\u751F\u8BF4\u51FA\uFF0C\u4E0E\u753B\u9762\u540C\u65F6\u5F55\u5236\u5E76\u5BF9\u597D\u53E3\u578B\uFF0C" + (speakers.length === 1 ? speakers[0] + "\u7684\u5634" : "\u6BCF\u4E2A\u8BF4\u8BDD\u4EBA\u7684\u5634") + "\u4E0E" + (speakers.length === 1 ? "\u53F0\u8BCD" : "\u5404\u81EA\u7684\u53F0\u8BCD") + "\u5B8C\u5168\u540C\u6B65\u3002\u53F0\u8BCD\u7684\u65F6\u95F4\u7EBF\uFF0C\u4ECE\u7247\u6BB5\u5F00\u59CB\u7B97\u8D77\uFF0C\u5355\u4F4D\u4E3A\u79D2\uFF1A" + d.lines.map((l) => stamp2(l.at) + "-" + stamp2(l.to) + " \u79D2 " + l.speaker + " \u8BF4 " + JSON.stringify(l.text)).join("\uFF1B") + "\u3002\u8FD9\u4E9B\u65F6\u95F4\u4E4B\u5916\u6CA1\u6709\u4EBA\u8BF4\u8BDD\uFF0C\u4E24\u53E5\u53F0\u8BCD\u4E4B\u95F4\u5634\u4FDD\u6301\u95ED\u5408\u3002\u6CA1\u6709\u5176\u4ED6\u5BF9\u767D\uFF0C\u6CA1\u6709\u65C1\u767D\uFF0C\u6CA1\u6709\u5B57\u5E55\u6216\u5C4F\u5E55\u6587\u5B57\uFF0C\u6CA1\u6709\u914D\u97F3\uFF0C\u4E5F\u6CA1\u6709\u7FFB\u8BD1\u540E\u7684\u8BED\u97F3\u3002\u751F\u6210\u7684\u8BED\u97F3\u5C31\u662F\u6700\u7EC8\u97F3\u9891\uFF0C\u4E4B\u540E\u4E0D\u4F1A\u88AB\u66FF\u6362\u3002";
|
|
23081
23093
|
const lines2 = d.lines.map((l) => stamp2(l.at) + "-" + stamp2(l.to) + " s " + l.speaker + " says " + JSON.stringify(l.text)).join("; ");
|
|
23082
23094
|
return " Dialogue: native speech in " + languageName(d.language) + ", recorded with the picture and lip-synced, the mouth of " + (speakers.length === 1 ? speakers[0] : "each speaker") + " moving exactly with " + (speakers.length === 1 ? "the" : "their own") + " words. Timeline of the lines, in seconds from the start of the clip: " + lines2 + ". Nobody speaks outside these times, and mouths rest closed between the lines. No other dialogue, no narrator, no captions or on-screen text, no dubbing and no translated speech. The generated speech is the final audio and is not replaced afterwards.";
|
|
@@ -23316,6 +23328,15 @@ var init_check4 = __esm({
|
|
|
23316
23328
|
};
|
|
23317
23329
|
inspect("review.audio", r.audio, AUDIBLE);
|
|
23318
23330
|
inspect("review.visual", r.visual, VISUAL);
|
|
23331
|
+
const joinsSeen = /* @__PURE__ */ new Set();
|
|
23332
|
+
for (const join3 of r.joins ?? []) {
|
|
23333
|
+
const at7 = "review.joins." + join3.at;
|
|
23334
|
+
if (joinsSeen.has(join3.at)) fail2(at7, "A cut was reviewed more than once.");
|
|
23335
|
+
joinsSeen.add(join3.at);
|
|
23336
|
+
inspect(at7, join3, ["video"]);
|
|
23337
|
+
if (join3.status === "passed" && !join3.evidence.some((e) => e.sha256 === r.artifactFingerprint && e.media === "video" && e.at && r.target && e.at[0] < join3.at / r.target.fps && e.at[1] > join3.at / r.target.fps))
|
|
23338
|
+
pending3(at7 + ".evidence", "Continuity needs an audible video window across this cut, bound to the actual artifact.");
|
|
23339
|
+
}
|
|
23319
23340
|
if (r.audioUses === void 0) pending3("review.audioUses", "Inventory every output audio route, including imported sound and native clip audio.");
|
|
23320
23341
|
else {
|
|
23321
23342
|
const audio = checkReplicationAudio(c, r.audioUses, { complete: true });
|
|
@@ -23355,7 +23376,7 @@ var init_voice_spans = __esm({
|
|
|
23355
23376
|
init_check_common();
|
|
23356
23377
|
voiceSpanProblems = (project, resolved) => {
|
|
23357
23378
|
const problems2 = [];
|
|
23358
|
-
for (const track of project.tracks) {
|
|
23379
|
+
for (const track of project.tracks ?? []) {
|
|
23359
23380
|
if (track.type !== "audio" || track.role !== "voice") continue;
|
|
23360
23381
|
const route2 = resolved.audio.find((a) => a.id === track.id);
|
|
23361
23382
|
const at7 = "tracks." + track.id + ".lines";
|
|
@@ -23556,26 +23577,26 @@ var init_resolve = __esm({
|
|
|
23556
23577
|
throw new Error('resolve: video material "' + id2 + '" needs the frame rate and frame count of its file' + (f ? " (" + f.error + ")" : "") + '. buildPage reads them with probe(); a direct caller passes them: resolve(project, { "' + id2 + '": { width, height, fps, frames, hasAudio } }).');
|
|
23557
23578
|
return f;
|
|
23558
23579
|
};
|
|
23559
|
-
playOf2 = (
|
|
23560
|
-
resolveTransition = (
|
|
23561
|
-
if (!
|
|
23562
|
-
const kind =
|
|
23580
|
+
playOf2 = (spec10, id2, start) => ({ material: id2, start, in: spec10.in ?? 0, speed: spec10.speed ?? 1 });
|
|
23581
|
+
resolveTransition = (spec10, boundary, fps) => {
|
|
23582
|
+
if (!spec10 || spec10.transition === "cut") return void 0;
|
|
23583
|
+
const kind = spec10.transition;
|
|
23563
23584
|
const d = TRANSITION_DEFAULTS[kind];
|
|
23564
|
-
const frames =
|
|
23565
|
-
const side =
|
|
23585
|
+
const frames = spec10.frames ?? transitionFrames(kind, fps);
|
|
23586
|
+
const side = spec10.side ?? "both";
|
|
23566
23587
|
const a = side === "both" ? boundary - Math.floor(frames / 2) : side === "after" ? boundary : boundary - frames;
|
|
23567
23588
|
return {
|
|
23568
23589
|
kind,
|
|
23569
23590
|
a,
|
|
23570
23591
|
frames,
|
|
23571
23592
|
boundary,
|
|
23572
|
-
direction:
|
|
23573
|
-
mode:
|
|
23574
|
-
via:
|
|
23593
|
+
direction: spec10.direction ?? d.direction,
|
|
23594
|
+
mode: spec10.mode ?? d.mode,
|
|
23595
|
+
via: spec10.via ?? d.via,
|
|
23575
23596
|
// A one-sided effect settles ('after') or builds up ('before') by default.
|
|
23576
|
-
ease:
|
|
23597
|
+
ease: spec10.ease ?? (side === "after" ? "out" : side === "before" ? "in" : d.ease),
|
|
23577
23598
|
side,
|
|
23578
|
-
strength:
|
|
23599
|
+
strength: spec10.strength ?? 1
|
|
23579
23600
|
};
|
|
23580
23601
|
};
|
|
23581
23602
|
resolveBase = (ctx, s, start) => {
|
|
@@ -23624,8 +23645,8 @@ var init_resolve = __esm({
|
|
|
23624
23645
|
};
|
|
23625
23646
|
clipSounds = (ctx, segments2, items, tracks) => {
|
|
23626
23647
|
const fromBases = segments2.flatMap((s, k) => {
|
|
23627
|
-
const
|
|
23628
|
-
return s.base.kind === "video" &&
|
|
23648
|
+
const spec10 = ctx.project.segments[k]?.base;
|
|
23649
|
+
return s.base.kind === "video" && spec10 && "material" in spec10 ? [{ id: s.id, spec: spec10, play: s.base.play, end: s.end }] : [];
|
|
23629
23650
|
});
|
|
23630
23651
|
const ownSound2 = tracks.some((t) => !t.bed && !t.role);
|
|
23631
23652
|
const beds = tracks.filter((t) => t.bed).map((t) => ({ start: t.sound.start, end: t.sound.end ?? ctx.tl.total }));
|
|
@@ -24051,11 +24072,27 @@ var init_profile3 = __esm({
|
|
|
24051
24072
|
});
|
|
24052
24073
|
|
|
24053
24074
|
// src/video/generate/provenance.ts
|
|
24054
|
-
var materialSignature, materialSignatures;
|
|
24075
|
+
var materialReceiptFile, readMaterialReceipt, materialSignature, materialSignatures;
|
|
24055
24076
|
var init_provenance = __esm({
|
|
24056
24077
|
"src/video/generate/provenance.ts"() {
|
|
24057
24078
|
"use strict";
|
|
24058
24079
|
init_util();
|
|
24080
|
+
materialReceiptFile = (clip11) => clip11 + ".material.json";
|
|
24081
|
+
readMaterialReceipt = async (rt, full) => {
|
|
24082
|
+
const receipt = await readJson(rt, materialReceiptFile(full)).catch(() => void 0);
|
|
24083
|
+
if (receipt?.version !== 1 || receipt.pipeline !== "popost video materials" || !["popost.ai", "external"].includes(receipt.provider) || typeof receipt.requestHash !== "string" || !/^[0-9a-f]{64}$/.test(receipt.requestHash)) return void 0;
|
|
24084
|
+
const hash5 = await sha256File(rt, full).catch(() => void 0);
|
|
24085
|
+
if (!hash5 || hash5 !== receipt.sha256) return void 0;
|
|
24086
|
+
return {
|
|
24087
|
+
version: 1,
|
|
24088
|
+
pipeline: receipt.pipeline,
|
|
24089
|
+
provider: receipt.provider,
|
|
24090
|
+
sha256: hash5,
|
|
24091
|
+
requestHash: receipt.requestHash,
|
|
24092
|
+
...typeof receipt.continues === "string" ? { continues: receipt.continues } : {},
|
|
24093
|
+
...Number.isInteger(receipt.continueAt) && (receipt.continueAt ?? -1) >= 0 ? { continueAt: receipt.continueAt } : {}
|
|
24094
|
+
};
|
|
24095
|
+
};
|
|
24059
24096
|
materialSignature = (value) => sha256(JSON.stringify(value));
|
|
24060
24097
|
materialSignatures = (value, legacyRequests = []) => [.../* @__PURE__ */ new Set([materialSignature(value), ...legacyRequests.map((request) => materialSignature({ ...value, request }))])];
|
|
24061
24098
|
}
|
|
@@ -25145,7 +25182,7 @@ var init_generate = __esm({
|
|
|
25145
25182
|
if (r.code !== 0) throw new Error(why || "The generator exited with " + r.code + ".");
|
|
25146
25183
|
const count5 = (v) => typeof v === "number" ? v : void 0;
|
|
25147
25184
|
const [credits2, chargedCredits] = [count5(said.credits), count5(said.chargedCredits)];
|
|
25148
|
-
return { ...credits2 !== void 0 ? { credits: credits2 } : {}, ...chargedCredits !== void 0 ? { chargedCredits } : {}, ...typeof said.key === "string" ? { key: said.key } : {} };
|
|
25185
|
+
return { ...credits2 !== void 0 ? { credits: credits2 } : {}, ...chargedCredits !== void 0 ? { chargedCredits } : {}, ...typeof said.key === "string" ? { key: said.key } : {}, ...typeof said.task === "string" ? { task: said.task } : {} };
|
|
25149
25186
|
})
|
|
25150
25187
|
};
|
|
25151
25188
|
};
|
|
@@ -25167,6 +25204,8 @@ var init_generate = __esm({
|
|
|
25167
25204
|
};
|
|
25168
25205
|
FRAME_FIX = 'Use frames for a shot that goes on from another clip or needs an exact first picture, and reference pictures ("images") for who or what is in the clip.';
|
|
25169
25206
|
frameProblems = (r, at7, found, clips) => {
|
|
25207
|
+
if (r.continueAt !== void 0 && (!r.continues || !Number.isInteger(r.continueAt) || r.continueAt < 0))
|
|
25208
|
+
return [error(at7 + ".continueAt", '"continueAt" needs "continues" and a nonnegative source frame index.', "Select the actual cut-out frame of the preceding clip.")];
|
|
25170
25209
|
if (!usesFrames2(r)) return [];
|
|
25171
25210
|
const out2 = [];
|
|
25172
25211
|
const key2 = r.continues !== void 0 ? "continues" : r.firstFrame !== void 0 ? "firstFrame" : "lastFrame";
|
|
@@ -25262,6 +25301,10 @@ var init_generate = __esm({
|
|
|
25262
25301
|
if (r.anchor !== void 0 && typeof r.anchor !== "boolean") out2.push(error(at7 + ".anchor", '"anchor" is false for a clip that shares nothing with the others; it is ' + JSON.stringify(r.anchor) + ".", 'Write "anchor": false, or remove it.'));
|
|
25263
25302
|
if (r.aspect !== void 0 && !(typeof r.aspect === "string" && ASPECT5.test(r.aspect))) out2.push(error(at7 + ".aspect", '"aspect" is a ratio such as "16:9", "9:16" or "1:1", or "adaptive"; it is ' + JSON.stringify(r.aspect) + ".", 'Write "aspect": "16:9".', ["16:9", "9:16", "1:1", "adaptive"]));
|
|
25264
25303
|
out2.push(...frameProblems(r, at7, found, clips));
|
|
25304
|
+
if (usesFrames2(r) && policy.frames === false) {
|
|
25305
|
+
const field = r.continues !== void 0 ? "continues" : r.firstFrame !== void 0 ? "firstFrame" : "lastFrame";
|
|
25306
|
+
out2.push(error(at7 + "." + field, "The selected generator takes no first frame or last frame as an exact constraint.", "Keep the action in one request, or cut at a real shot boundary and use identity, product and location references."));
|
|
25307
|
+
}
|
|
25265
25308
|
out2.push(...modeProblems(r, at7, policy.clipMusic ?? [], kindOf3(String(r.file)) !== "image"));
|
|
25266
25309
|
for (const k of LISTS) {
|
|
25267
25310
|
for (const [j, p] of listed3(r, k).entries()) {
|
|
@@ -25336,13 +25379,13 @@ var init_generate = __esm({
|
|
|
25336
25379
|
return out2;
|
|
25337
25380
|
};
|
|
25338
25381
|
lastFrameFile = (clip11) => clip11.slice(0, clip11.length - extOf(clip11).length) + ".last.png";
|
|
25339
|
-
lastFrameOf = async (rt, dir, clip11) => {
|
|
25340
|
-
const from = rt.path.resolve(dir, clip11)
|
|
25341
|
-
const
|
|
25342
|
-
|
|
25343
|
-
|
|
25344
|
-
|
|
25345
|
-
|
|
25382
|
+
lastFrameOf = async (rt, dir, clip11, frame2) => {
|
|
25383
|
+
const from = rt.path.resolve(dir, clip11);
|
|
25384
|
+
const to = rt.path.resolve(dir, frame2 === void 0 ? lastFrameFile(clip11) : lastFrameFile(clip11).replace(".last.png", ".frame-" + frame2 + ".png"));
|
|
25385
|
+
const p = await probe2(rt, from);
|
|
25386
|
+
const index = frame2 ?? Math.max(0, p.frames - 1);
|
|
25387
|
+
if (index >= p.frames) throw new Error("continueAt " + index + " lies outside " + clip11 + " (" + p.frames + " frames). Nothing was sent.");
|
|
25388
|
+
await extractFrame(rt, from, index, to);
|
|
25346
25389
|
return to;
|
|
25347
25390
|
};
|
|
25348
25391
|
afterFailure = (message2) => message2.includes("[CONTENT_REJECTED]") ? "Its content was refused, and the same request would be refused again (it cost nothing). Change the prompt or the reference pictures of this request (for example, leave out the names of brands, characters and well-known works, and pictures of them), then run the command again." : "Read the message; a request that was refused cost nothing. Run the command again to make only what is missing.";
|
|
@@ -25353,7 +25396,7 @@ var init_generate = __esm({
|
|
|
25353
25396
|
if (replication.forbidNewSpeech) o = { ...o, requests: o.requests.map((r) => ({ ...r, prompt: r.prompt + pl(" Do not add dialogue, voice-over, spoken narration or lip-synced speech. Preserve the requested music, effects and ambience; absence of narration does not mean silence.", " \u4E0D\u8981\u6DFB\u52A0\u5BF9\u767D\u3001\u753B\u5916\u97F3\u3001\u65C1\u767D\u6216\u5BF9\u53E3\u578B\u7684\u8BED\u97F3\u3002\u4FDD\u7559\u6240\u8981\u6C42\u7684\u97F3\u4E50\u3001\u97F3\u6548\u548C\u73AF\u5883\u58F0\uFF1B\u6CA1\u6709\u65C1\u767D\u4E0D\u7B49\u4E8E\u6CA1\u6709\u58F0\u97F3\u3002") })) };
|
|
25354
25397
|
else if (replication.forbidNewNarration) o = { ...o, requests: o.requests.map((r) => ({ ...r, prompt: r.prompt + pl(" Do not add a voice-over or narrator. Preserve only the planned source-role dialogue, music/vocals, effects and ambience.", " \u4E0D\u8981\u6DFB\u52A0\u753B\u5916\u97F3\u6216\u65C1\u767D\u3002\u53EA\u4FDD\u7559\u8BA1\u5212\u4E2D\u7684\u539F\u89D2\u8272\u5BF9\u767D\u3001\u97F3\u4E50/\u4EBA\u58F0\u3001\u97F3\u6548\u548C\u73AF\u5883\u58F0\u3002") })) };
|
|
25355
25398
|
const before = Array.isArray(o.requests) && o.times ? await saidBefore(rt, o.dir, o.requests) : void 0;
|
|
25356
|
-
const problems2 = await checkRequests(rt, o.requests, o.dir, { selectedIdentity: !!o.picture, ...o.times ? { times: o.times } : {}, ...before ? { covered: before } : {}, clipMusic: await clipMusicExceptions(rt, o.dir) });
|
|
25399
|
+
const problems2 = await checkRequests(rt, o.requests, o.dir, { selectedIdentity: !!o.picture, frames: o.frames, ...o.times ? { times: o.times } : {}, ...before ? { covered: before } : {}, clipMusic: await clipMusicExceptions(rt, o.dir) });
|
|
25357
25400
|
if (problems2.length) return { materials: [], credits: 0, chargedCredits: 0, problems: problems2 };
|
|
25358
25401
|
const said = [];
|
|
25359
25402
|
const clipFiles = /* @__PURE__ */ new Set([...o.requests.filter((r) => kindOf3(r.file) === "video").map((r) => r.file), ...((await readClipRecord(rt, o.dir).catch(() => void 0))?.plan ?? []).map((c) => c.file)]);
|
|
@@ -25504,10 +25547,10 @@ var init_generate = __esm({
|
|
|
25504
25547
|
const r = gets && picture3 && source2 ? anchored(asked3, picture3, source2, o.picture?.person, shown3 !== void 0) : asked3;
|
|
25505
25548
|
const at7 = (p) => rt.path.resolve(o.dir, p);
|
|
25506
25549
|
const references = Object.fromEntries(LISTS.flatMap((k) => r[k]?.length ? [[k, (r[k] ?? []).map(at7)]] : []));
|
|
25507
|
-
const start = priceOnly ? void 0 : asked3.continues ? await lastFrameOf(rt, o.dir, asked3.continues) : asked3.firstFrame ? at7(asked3.firstFrame) : void 0;
|
|
25550
|
+
const start = priceOnly ? void 0 : asked3.continues ? await lastFrameOf(rt, o.dir, asked3.continues, asked3.continueAt) : asked3.firstFrame ? at7(asked3.firstFrame) : void 0;
|
|
25508
25551
|
const frames = { ...start ? { firstFrame: start } : {}, ...start && asked3.lastFrame ? { lastFrame: at7(asked3.lastFrame) } : {} };
|
|
25509
|
-
const
|
|
25510
|
-
const request = { prompt: r.prompt + (sent ? speechPrompt(sent) : "") +
|
|
25552
|
+
const tail4 = mode ? sound2.tailOf(original, mode) : separateMusic && kind === "video" ? noMusic() : "";
|
|
25553
|
+
const request = { prompt: r.prompt + (sent ? speechPrompt(sent) : "") + tail4, ...mode === "silent" ? { audio: false } : {}, ...r.seconds ? { seconds: r.seconds } : {}, ...r.aspect ? { aspect: r.aspect } : {}, ...references, ...frames, ...priceOnly ? { priceOnly: true } : {} };
|
|
25511
25554
|
const agreement = { POPOST_GEN_PROJECT: o.dir, POPOST_GEN_INPUT: inputKey(original.file), ...kind === "video" ? { POPOST_GEN_FILE: original.file, POPOST_GEN_REQUEST: requestHash2(rt, original), POPOST_GEN_WHAT: original.prompt } : {}, ...o.submitOnly ? { POPOST_GEN_NO_WAIT: "1" } : {} };
|
|
25512
25555
|
const made = await o.generator.make(kind, request, partial, agreement);
|
|
25513
25556
|
const charged = made.chargedCredits ?? made.credits;
|
|
@@ -25516,7 +25559,21 @@ var init_generate = __esm({
|
|
|
25516
25559
|
if (!await exists4(partial)) throw new Error("The generator finished without writing the file.");
|
|
25517
25560
|
if (sent) await finalizeSpeech(rt, partial, sent, o.dir, target2);
|
|
25518
25561
|
const stripped = mode === "silent" && await probe2(rt, partial).then((p) => p.hasAudio, () => false) ? await stripSound(rt, partial) : false;
|
|
25562
|
+
const receipt = o.provider ? materialReceiptFile(asked3.file) : void 0;
|
|
25563
|
+
const provenance = o.provider ? {
|
|
25564
|
+
version: 1,
|
|
25565
|
+
pipeline: "popost video materials",
|
|
25566
|
+
provider: o.provider,
|
|
25567
|
+
sha256: await sha256File(rt, partial),
|
|
25568
|
+
requestHash: requestHash2(rt, original),
|
|
25569
|
+
...asked3.continues ? { continues: asked3.continues, ...asked3.continueAt !== void 0 ? { continueAt: asked3.continueAt } : {} } : {}
|
|
25570
|
+
} : void 0;
|
|
25519
25571
|
await rt.fs.rename(partial, target2);
|
|
25572
|
+
if (receipt && provenance) {
|
|
25573
|
+
await writeJson(rt, rt.path.resolve(o.dir, receipt), provenance);
|
|
25574
|
+
entry2 = { ...entry2, receipt };
|
|
25575
|
+
}
|
|
25576
|
+
if (made.task) entry2 = { ...entry2, task: made.task };
|
|
25520
25577
|
if (mode) await writeModeReceipt(rt, target2, { sound: mode, ...basis ? { clipMusic: basis } : {}, ...stripped ? { stripped: true } : {} });
|
|
25521
25578
|
if (asked3.speech) for (const ext of [".speech.wav", ".speech.json"]) await rt.fs.rename(partial + ext, target2 + ext);
|
|
25522
25579
|
if (cast || asked3.speech) await rt.fs.writeFile(target2 + ".generation.json", signature2);
|
|
@@ -25536,6 +25593,7 @@ var init_generate = __esm({
|
|
|
25536
25593
|
continue;
|
|
25537
25594
|
}
|
|
25538
25595
|
}
|
|
25596
|
+
if (!entry2.made && o.provider && await readMaterialReceipt(rt, target2)) entry2 = { ...entry2, receipt: materialReceiptFile(asked3.file) };
|
|
25539
25597
|
if (mode && original.sound !== void 0 && !await readModeReceipt(rt, target2)) await writeModeReceipt(rt, target2, { sound: mode, ...basis ? { clipMusic: basis } : {} });
|
|
25540
25598
|
if (kind === "video") {
|
|
25541
25599
|
const p = await probe2(rt, target2).catch(() => void 0);
|
|
@@ -25706,8 +25764,8 @@ var init_shared = __esm({
|
|
|
25706
25764
|
name = "VideoCommandError";
|
|
25707
25765
|
};
|
|
25708
25766
|
expected = (error2) => error2 instanceof VideoCommandError || error2 instanceof VideoUnavailableError || error2 instanceof BrowserUnavailableError || error2 instanceof FfmpegError || isExpectedFailure(error2);
|
|
25709
|
-
command = (description5,
|
|
25710
|
-
spec: { description: description5, ...
|
|
25767
|
+
command = (description5, spec10, body, projectOf4, titleOf) => ({
|
|
25768
|
+
spec: { description: description5, ...spec10 },
|
|
25711
25769
|
run: async (args, rt) => {
|
|
25712
25770
|
const project = projectOf4?.(args);
|
|
25713
25771
|
try {
|
|
@@ -26324,14 +26382,14 @@ var init_check5 = __esm({
|
|
|
26324
26382
|
measuredLabel = (b) => [b.kind, b.mode, b.direction, b.via ? "via " + b.via : ""].filter(Boolean).join(" ");
|
|
26325
26383
|
coverageProblems2 = ({ r, m, at: at7 }) => {
|
|
26326
26384
|
const fps = m.source.fps, s22 = (f) => (f / fps).toFixed(2);
|
|
26327
|
-
const
|
|
26385
|
+
const missing4 = m.shots.filter((s) => !r.present.includes(s.index + 1)).map((s) => error("shots", "Shot " + (s.index + 1) + " (" + s22(s.start) + "-" + s22(s.end) + " s) has no entry.", "Open " + shotSheetFile(s.index + 1) + ' and add {"shot": ' + (s.index + 1) + ', "time": [' + s22(s.start) + ", " + s22(s.end) + '], "layout": "...", "layers": [...]} for it.'));
|
|
26328
26386
|
const extra2 = r.present.filter((n) => n > m.shots.length).map((n) => error(at7(n) + ".shot", "There is no shot " + n + ": the measurement has " + m.shots.length + ".", "Remove the entry, or give it the number of the shot it describes."));
|
|
26329
26387
|
const times = r.elements.shots.flatMap((s) => {
|
|
26330
26388
|
const ms = m.shots[s.shot - 1];
|
|
26331
26389
|
if (!ms || Math.abs(s.time[0] - ms.start / fps) <= TIME_SLACK && Math.abs(s.time[1] - ms.end / fps) <= TIME_SLACK) return [];
|
|
26332
26390
|
return [warning(at7(s.shot) + ".time", "Shot " + s.shot + " is " + s22(ms.start) + "-" + s22(ms.end) + " s in the measurement; its entry says " + s.time[0] + "-" + s.time[1] + " s.", "Copy the measured time, [" + s22(ms.start) + ", " + s22(ms.end) + ']: entries go by the measured shots. Where the frames show a change the measurement missed, say so in "rebuild".')];
|
|
26333
26391
|
});
|
|
26334
|
-
return [...
|
|
26392
|
+
return [...missing4, ...extra2, ...times];
|
|
26335
26393
|
};
|
|
26336
26394
|
transitionProblems2 = ({ r, m, at: at7 }) => r.elements.shots.flatMap((s) => {
|
|
26337
26395
|
const here = at7(s.shot) + ".transitionIn", t = s.transitionIn;
|
|
@@ -26884,7 +26942,7 @@ var init_speech2 = __esm({
|
|
|
26884
26942
|
LATIN_RUN = /[A-Za-z0-9]+/g;
|
|
26885
26943
|
syllablesOf = (text13) => {
|
|
26886
26944
|
const cjk = (text13.match(CJK_ALL) ?? []).length;
|
|
26887
|
-
const latin = (text13.match(LATIN_RUN) ?? []).reduce((n,
|
|
26945
|
+
const latin = (text13.match(LATIN_RUN) ?? []).reduce((n, run7) => n + (/^[A-Z0-9]{1,5}$/.test(run7) ? run7.length : Math.ceil(run7.length / 2.5)), 0);
|
|
26888
26946
|
return Math.max(1, cjk + latin);
|
|
26889
26947
|
};
|
|
26890
26948
|
median4 = (xs) => [...xs].sort((a, b) => a - b)[Math.floor(xs.length / 2)] ?? 0;
|
|
@@ -26942,11 +27000,11 @@ var init_speech2 = __esm({
|
|
|
26942
27000
|
const pauses = pausesOf(t.words, o.pace ?? paceFramesOf(t.words));
|
|
26943
27001
|
const runs4 = [];
|
|
26944
27002
|
t.words.forEach((w, k) => {
|
|
26945
|
-
const
|
|
27003
|
+
const run7 = runs4[runs4.length - 1];
|
|
26946
27004
|
const prev = t.words[k - 1];
|
|
26947
|
-
if (
|
|
26948
|
-
|
|
26949
|
-
|
|
27005
|
+
if (run7 && prev && (pauses[k] ?? 0) < pauseFrames && !CLAUSE_END.test(prev.text)) {
|
|
27006
|
+
run7.words.push(w);
|
|
27007
|
+
run7.pauses.push(pauses[k] ?? 0);
|
|
26950
27008
|
} else runs4.push({ words: [w], pauses: [pauses[k] ?? 0] });
|
|
26951
27009
|
});
|
|
26952
27010
|
const cutUp = runs4.flatMap((r) => atBoundaries(r, o.boundaries ?? [], edge)).flatMap((r) => atLargestPause(r, max, edge));
|
|
@@ -28630,11 +28688,11 @@ var init_browser_step = __esm({
|
|
|
28630
28688
|
BrowserStepTimeoutError = class extends Error {
|
|
28631
28689
|
name = "BrowserStepTimeoutError";
|
|
28632
28690
|
};
|
|
28633
|
-
browserStep = async (stage3,
|
|
28691
|
+
browserStep = async (stage3, run7, ms = 3e4) => {
|
|
28634
28692
|
let timer;
|
|
28635
28693
|
try {
|
|
28636
28694
|
return await Promise.race([
|
|
28637
|
-
|
|
28695
|
+
run7(),
|
|
28638
28696
|
new Promise((_resolve, reject) => {
|
|
28639
28697
|
timer = setTimeout(() => reject(new BrowserStepTimeoutError("Chrome did not finish " + stage3 + " within " + ms / 1e3 + " seconds. Check the browser and project assets, then retry.")), ms);
|
|
28640
28698
|
})
|
|
@@ -29264,12 +29322,12 @@ var init_cues = __esm({
|
|
|
29264
29322
|
const used = /* @__PURE__ */ new Set();
|
|
29265
29323
|
for (const line of sample.lines) {
|
|
29266
29324
|
if (line.confidence < MIN_CONFIDENCE2 || !norm(line.text)) continue;
|
|
29267
|
-
const
|
|
29268
|
-
if (
|
|
29269
|
-
|
|
29270
|
-
|
|
29271
|
-
|
|
29272
|
-
used.add(
|
|
29325
|
+
const run7 = open.find((r) => !used.has(r) && samePlace(r.lines[r.lines.length - 1]?.box ?? line.box, line.box) && sameText(r.lines[r.lines.length - 1]?.text ?? "", line.text));
|
|
29326
|
+
if (run7) {
|
|
29327
|
+
run7.lines.push(line);
|
|
29328
|
+
run7.frames.push(sample.frame);
|
|
29329
|
+
run7.last = index;
|
|
29330
|
+
used.add(run7);
|
|
29273
29331
|
} else {
|
|
29274
29332
|
const fresh = { lines: [line], frames: [sample.frame], last: index };
|
|
29275
29333
|
open.push(fresh);
|
|
@@ -29286,20 +29344,20 @@ var init_cues = __esm({
|
|
|
29286
29344
|
});
|
|
29287
29345
|
return [...done2, ...open];
|
|
29288
29346
|
};
|
|
29289
|
-
toCue = (
|
|
29290
|
-
const first =
|
|
29291
|
-
const exact =
|
|
29292
|
-
const placed2 = exact.length ? exact :
|
|
29347
|
+
toCue = (run7, step2, total2) => {
|
|
29348
|
+
const first = run7.frames[0] ?? 0, last = run7.frames[run7.frames.length - 1] ?? 0;
|
|
29349
|
+
const exact = run7.lines.filter((l) => !l.partial);
|
|
29350
|
+
const placed2 = exact.length ? exact : run7.lines;
|
|
29293
29351
|
const box2 = union2(placed2.map((l) => l.box));
|
|
29294
29352
|
const heights = placed2.map((l) => l.box[3]).sort((a, b) => a - b);
|
|
29295
29353
|
return {
|
|
29296
|
-
text: bestText(
|
|
29354
|
+
text: bestText(run7.lines),
|
|
29297
29355
|
start: Math.max(0, first - Math.floor(step2 / 2)),
|
|
29298
29356
|
end: Math.min(total2, last + Math.ceil(step2 / 2)),
|
|
29299
29357
|
box: box2,
|
|
29300
29358
|
size: Math.round((heights[Math.floor(heights.length / 2)] ?? 0) * 1e4) / 1e4,
|
|
29301
|
-
samples:
|
|
29302
|
-
confidence: Math.round(
|
|
29359
|
+
samples: run7.lines.length,
|
|
29360
|
+
confidence: Math.round(run7.lines.reduce((s, l) => s + l.confidence, 0) / run7.lines.length * 1e3) / 1e3
|
|
29303
29361
|
};
|
|
29304
29362
|
};
|
|
29305
29363
|
presence2 = (cue, all, frames) => {
|
|
@@ -29618,21 +29676,21 @@ var init_beats = __esm({
|
|
|
29618
29676
|
uncoveredRuns = (words, shown3, tolerance) => {
|
|
29619
29677
|
const covered4 = (w) => shown3.some((b) => mid2(w) >= b.start - tolerance && mid2(w) < b.end + tolerance);
|
|
29620
29678
|
const runs4 = [];
|
|
29621
|
-
let
|
|
29679
|
+
let run7 = [];
|
|
29622
29680
|
for (const w of words) {
|
|
29623
|
-
const prev =
|
|
29681
|
+
const prev = run7[run7.length - 1];
|
|
29624
29682
|
if (covered4(w) || prev && shown3.some((b) => b.start < mid2(w) && b.end > mid2(prev))) {
|
|
29625
|
-
if (
|
|
29626
|
-
|
|
29683
|
+
if (run7.length) runs4.push(run7);
|
|
29684
|
+
run7 = [];
|
|
29627
29685
|
}
|
|
29628
|
-
if (!covered4(w))
|
|
29686
|
+
if (!covered4(w)) run7.push(w);
|
|
29629
29687
|
}
|
|
29630
|
-
if (
|
|
29688
|
+
if (run7.length) runs4.push(run7);
|
|
29631
29689
|
return runs4;
|
|
29632
29690
|
};
|
|
29633
|
-
isStray = (
|
|
29634
|
-
const first =
|
|
29635
|
-
if (!first || !last ||
|
|
29691
|
+
isStray = (run7, shown3, fps) => {
|
|
29692
|
+
const first = run7[0], last = run7[run7.length - 1];
|
|
29693
|
+
if (!first || !last || run7.reduce((n, w) => n + syllablesOf(w.text), 0) > STRAY_SYLLABLES) return false;
|
|
29636
29694
|
const near3 = STRAY_SECONDS * fps;
|
|
29637
29695
|
return shown3.some((b) => Math.abs(first.start - b.end) <= near3 || Math.abs(b.start - last.end) <= near3);
|
|
29638
29696
|
};
|
|
@@ -29666,9 +29724,9 @@ var init_beats = __esm({
|
|
|
29666
29724
|
if (!o.transcript || !words.length) return { ...text13 ? { text: text13 } : {}, beats: shown3.map((b) => withKind(b, kinds)), captions };
|
|
29667
29725
|
const t = o.transcript;
|
|
29668
29726
|
const pace2 = paceFramesOf(words);
|
|
29669
|
-
const runs4 = uncoveredRuns(words, shown3, coverTolerance(o.text)).filter((
|
|
29727
|
+
const runs4 = uncoveredRuns(words, shown3, coverTolerance(o.text)).filter((run7) => !isStray(run7, shown3, t.fps));
|
|
29670
29728
|
const cuts = [...o.boundaries ?? [], ...(kinds ?? []).map((k) => k.start)].sort((a, b) => a - b);
|
|
29671
|
-
const spoken = runs4.flatMap((
|
|
29729
|
+
const spoken = runs4.flatMap((run7) => phrasesOf({ ...t, words: run7 }, { pace: pace2, minFrames: Math.round(MIN_PHRASE_SECONDS * t.fps), ...cuts.length ? { boundaries: cuts } : {} })).map((p) => ({ start: p.start, end: Math.min(p.end, o.total), text: p.text, shown: false, said: true, confidence: p.confidence }));
|
|
29672
29730
|
return { ...text13 ? { text: text13 } : {}, beats: ordered([...shown3, ...spoken]).map((b) => withKind(b, kinds)), captions };
|
|
29673
29731
|
};
|
|
29674
29732
|
uncoveredSpeech = (beats2, transcript2, o = {}) => {
|
|
@@ -29677,12 +29735,12 @@ var init_beats = __esm({
|
|
|
29677
29735
|
const out2 = words.filter((w) => !beats2.some((b) => mid2(w) >= b.start - tol && mid2(w) < b.end + tol));
|
|
29678
29736
|
const shown3 = beats2.filter((b) => b.shown);
|
|
29679
29737
|
const runs4 = out2.reduce((acc, w) => {
|
|
29680
|
-
const
|
|
29681
|
-
if (
|
|
29738
|
+
const run7 = acc[acc.length - 1], prev = run7?.[run7.length - 1];
|
|
29739
|
+
if (run7 && prev && words.indexOf(prev) + 1 === words.indexOf(w)) run7.push(w);
|
|
29682
29740
|
else acc.push([w]);
|
|
29683
29741
|
return acc;
|
|
29684
29742
|
}, []);
|
|
29685
|
-
const left = o.strays ? runs4.filter((
|
|
29743
|
+
const left = o.strays ? runs4.filter((run7) => !isStray(run7, shown3, transcript2?.fps ?? 1)).flat() : out2;
|
|
29686
29744
|
return { seconds: Math.round(left.reduce((n, w) => n + w.end - w.start, 0) / Math.max(1, transcript2?.fps ?? 1) * 10) / 10, words: left.length };
|
|
29687
29745
|
};
|
|
29688
29746
|
coverTolerance = (text13) => Math.ceil((text13?.step ?? 0) / 2);
|
|
@@ -30598,9 +30656,9 @@ var init_describe = __esm({
|
|
|
30598
30656
|
if (m.boundaries.length) L.push("- Changes between shots: " + histogram3(m.boundaries.map((b) => b.kind)));
|
|
30599
30657
|
const moving = m.shots.filter((s) => s.camera.kind === "move").length;
|
|
30600
30658
|
L.push("- Camera moves in " + moving + " of " + m.shots.length + " shots; " + m.shots.reduce((n, s) => n + s.events.length, 0) + " motion events in all");
|
|
30601
|
-
const
|
|
30602
|
-
if (p.amount !== void 0 &&
|
|
30603
|
-
L.push("- Motion amount: " + p.amount + " over the video, by shot from " +
|
|
30659
|
+
const moved2 = p.amounts.flatMap((a, k) => a === void 0 ? [] : [{ a, k }]).sort((x2, y) => x2.a - y.a);
|
|
30660
|
+
if (p.amount !== void 0 && moved2.length)
|
|
30661
|
+
L.push("- Motion amount: " + p.amount + " over the video, by shot from " + moved2[0]?.a + " (#" + two7((moved2[0]?.k ?? 0) + 1) + ") to " + moved2[moved2.length - 1]?.a + " (#" + two7((moved2[moved2.length - 1]?.k ?? 0) + 1) + "): the mean change of the picture between frames 1/15 s apart, in levels of 255 (0 is a still picture); shots/NN.md has each shot's");
|
|
30604
30662
|
const movement = movementCardLine(p.activity, p.written);
|
|
30605
30663
|
if (movement) L.push(movement);
|
|
30606
30664
|
if (inset) L.push("- " + insetText(inset, m.shots.length));
|
|
@@ -31233,8 +31291,8 @@ var init_retarget = __esm({
|
|
|
31233
31291
|
const into = k > 0 ? m.boundaries[k - 1] : void 0;
|
|
31234
31292
|
const keptBoth = "keep" in fill4 && k > 0 && "keep" in plan4.shots[k - 1];
|
|
31235
31293
|
if (into && !keptBoth) {
|
|
31236
|
-
const
|
|
31237
|
-
if (
|
|
31294
|
+
const spec10 = transitionSpec(into, toFrames2, Math.min(lengths[k - 1] ?? 1, lengths[k] ?? 1));
|
|
31295
|
+
if (spec10) segment2.in = spec10;
|
|
31238
31296
|
}
|
|
31239
31297
|
return segment2;
|
|
31240
31298
|
});
|
|
@@ -31459,9 +31517,9 @@ var init_structure = __esm({
|
|
|
31459
31517
|
const out2 = [];
|
|
31460
31518
|
starts.forEach((S, k) => {
|
|
31461
31519
|
const e = t.shots[k]?.effect;
|
|
31462
|
-
const
|
|
31520
|
+
const moved2 = !e || k === 0 ? S : e.by === "this" ? S - Math.floor(e.frames / 2) : S + Math.ceil(e.frames / 2);
|
|
31463
31521
|
const lo = k === 0 ? 0 : (out2[k - 1] ?? 0) + 1, hi = (starts[k + 1] ?? total2) - 1;
|
|
31464
|
-
out2.push(k === 0 ? 0 : Math.max(lo, Math.min(hi,
|
|
31522
|
+
out2.push(k === 0 ? 0 : Math.max(lo, Math.min(hi, moved2)));
|
|
31465
31523
|
});
|
|
31466
31524
|
return out2;
|
|
31467
31525
|
};
|
|
@@ -31472,12 +31530,12 @@ var init_structure = __esm({
|
|
|
31472
31530
|
};
|
|
31473
31531
|
STILL3 = { kind: "static", zoomPerS: 0, panPerS: [0, 0], confidence: 1 };
|
|
31474
31532
|
cameraOf = (s) => s.camera ? { kind: "move", zoomPerS: s.camera.zoom ?? 0, panPerS: s.camera.pan ?? [0, 0], confidence: 1 } : STILL3;
|
|
31475
|
-
boundaryAt = (S,
|
|
31476
|
-
if (!
|
|
31533
|
+
boundaryAt = (S, spec10, frames) => {
|
|
31534
|
+
if (!spec10 || spec10.transition === "cut" || frames < 2) return { frame: S, kind: "cut", start: S - 1, end: S, confidence: 1 };
|
|
31477
31535
|
const a = S - Math.floor(frames / 2);
|
|
31478
|
-
return { frame: S, kind:
|
|
31536
|
+
return { frame: S, kind: spec10.transition, start: a - 1, end: a + frames, ...spec10.direction ? { direction: spec10.direction } : {}, ...spec10.mode ? { mode: spec10.mode } : {}, ...spec10.via ? { via: spec10.via } : {}, confidence: 1 };
|
|
31479
31537
|
};
|
|
31480
|
-
transitionFrames3 = (
|
|
31538
|
+
transitionFrames3 = (spec10, room) => !spec10 || spec10.transition === "cut" ? 0 : Math.min(Math.max(2, spec10.frames ?? 0), room);
|
|
31481
31539
|
measureOf = (t, starts, total2, boundaries) => ({
|
|
31482
31540
|
version: 1,
|
|
31483
31541
|
source: { width: t.canvas.width, height: t.canvas.height, fps: t.canvas.fps, frames: total2, duration: total2 / t.canvas.fps, hasAudio: false },
|
|
@@ -31764,9 +31822,9 @@ var init_main = __esm({
|
|
|
31764
31822
|
return best ? { box: best.box, kind: best.kind } : void 0;
|
|
31765
31823
|
};
|
|
31766
31824
|
motionOf = (layers) => {
|
|
31767
|
-
const
|
|
31825
|
+
const main24 = mainPicture(layers);
|
|
31768
31826
|
const said = layers.flatMap((l) => {
|
|
31769
|
-
const isMain =
|
|
31827
|
+
const isMain = main24 !== void 0 && l.box === main24.box && l.kind === main24.kind;
|
|
31770
31828
|
const words = [l.moves, l.enters].filter((t) => typeof t === "string" && t.trim() !== "");
|
|
31771
31829
|
const own3 = l.kind === "pointer" ? l.moves ? [l.moves] : [] : isMain ? words.filter((t) => MOTION_WORDS.test(t)) : [];
|
|
31772
31830
|
return own3.map((t) => l.id + ": " + t.trim());
|
|
@@ -31775,10 +31833,10 @@ var init_main = __esm({
|
|
|
31775
31833
|
};
|
|
31776
31834
|
extrasOf = (e) => {
|
|
31777
31835
|
const layers = [...e.design, ...e.content];
|
|
31778
|
-
const
|
|
31836
|
+
const main24 = mainPicture(layers), motion3 = motionOf(layers);
|
|
31779
31837
|
const highlight = e.captions?.highlight, reveal = e.captions?.reveal;
|
|
31780
31838
|
return {
|
|
31781
|
-
...
|
|
31839
|
+
...main24 ? { main: main24 } : {},
|
|
31782
31840
|
...motion3 ? { motion: motion3 } : {},
|
|
31783
31841
|
...highlight && !isNone(highlight) ? { highlight } : {},
|
|
31784
31842
|
...reveal && reveal.trim() ? { reveal } : {}
|
|
@@ -32427,13 +32485,13 @@ var init_cloud2 = __esm({
|
|
|
32427
32485
|
sent = await ensureUploads2(rt, client2, job.refs, sent, job.file);
|
|
32428
32486
|
const body = specOf(s, job.request, job.seconds, job.refs, sent, job.silent);
|
|
32429
32487
|
sent = await ensureQuote(rt, client2, body, sent, job.file);
|
|
32430
|
-
const
|
|
32431
|
-
if (job.request.priceOnly) throw new ConfirmNeeded(
|
|
32432
|
-
agreeToPrice(s,
|
|
32488
|
+
const quote16 = sent.quote;
|
|
32489
|
+
if (job.request.priceOnly) throw new ConfirmNeeded(quote16.price, "This costs " + quote16.price.credits + " credits. Only its price was asked for: nothing was made or charged.");
|
|
32490
|
+
agreeToPrice(s, quote16.price, job.unplanned);
|
|
32433
32491
|
try {
|
|
32434
|
-
const task = await createTask2(rt, client2, { ...body, prompt: job.request.prompt, quoteId:
|
|
32492
|
+
const task = await createTask2(rt, client2, { ...body, prompt: job.request.prompt, quoteId: quote16.quoteId, idempotencyKey: keyOf4(sent) });
|
|
32435
32493
|
await save2(rt, job.file, { ...sent, taskId: task.id });
|
|
32436
|
-
await job.onPaid(typeof task.credits === "number" ? task.credits :
|
|
32494
|
+
await job.onPaid(typeof task.credits === "number" ? task.credits : quote16.price.credits);
|
|
32437
32495
|
return task;
|
|
32438
32496
|
} catch (error2) {
|
|
32439
32497
|
if (round5 > 1 || !(error2 instanceof PopostApiError) || error2.code !== "QUOTE_EXPIRED") throw error2;
|
|
@@ -32571,7 +32629,7 @@ var init_cloud2 = __esm({
|
|
|
32571
32629
|
throw ended(done2);
|
|
32572
32630
|
}
|
|
32573
32631
|
await fetchClip(rt, client2, done2, out2);
|
|
32574
|
-
return { ...typeof done2.credits === "number" ? { credits: done2.credits } : {}, chargedCredits: charged, key: key2 };
|
|
32632
|
+
return { ...typeof done2.credits === "number" ? { credits: done2.credits } : {}, chargedCredits: charged, key: key2, task: done2.id };
|
|
32575
32633
|
};
|
|
32576
32634
|
priceClip = async (rt, client2, s, request) => {
|
|
32577
32635
|
const seconds8 = request.seconds ?? DEFAULT_SECONDS;
|
|
@@ -32798,8 +32856,8 @@ var init_cloud_image = __esm({
|
|
|
32798
32856
|
const provider = new PopostProvider(rt, { config: s.imageModel ? withModel(config3, s.imageModel) : config3 });
|
|
32799
32857
|
const aspect = request.aspect ?? "1:1";
|
|
32800
32858
|
const refs = await Promise.all((request.images ?? []).map(async (value) => ({ kind: "local", value, sha256: await sha256File(rt, value) })));
|
|
32801
|
-
const
|
|
32802
|
-
return { credits:
|
|
32859
|
+
const quote16 = await provider.quote({ model: s.imageModel ?? null, aspect, count: 1, refs });
|
|
32860
|
+
return { credits: quote16.totalCredits, model: quote16.model, aspectRatio: aspect, balance: quote16.balance };
|
|
32803
32861
|
};
|
|
32804
32862
|
makePicture = async (rt, s, config3, request, out2) => {
|
|
32805
32863
|
if (request.firstFrame !== void 0 || request.lastFrame !== void 0) throw new GenerateError('Only a clip starts from a frame; a picture takes reference pictures ("images"). Nothing was sent.', 2);
|
|
@@ -32814,13 +32872,13 @@ var init_cloud_image = __esm({
|
|
|
32814
32872
|
const sent = await readRecord3(rt, file, key2);
|
|
32815
32873
|
const before = sent.taskId ? await pickUp2(rt, s, provider, sent, file, out2, wanted) : void 0;
|
|
32816
32874
|
if (before) return before;
|
|
32817
|
-
const
|
|
32818
|
-
agreeToPrice(s, { credits:
|
|
32819
|
-
const made = await provider.submit(request.prompt, { aspect, refs, model:
|
|
32875
|
+
const quote16 = await provider.quote({ model: s.imageModel ?? null, aspect, count: 1, refs });
|
|
32876
|
+
agreeToPrice(s, { credits: quote16.totalCredits, model: quote16.model, aspectRatio: aspect, balance: quote16.balance });
|
|
32877
|
+
const made = await provider.submit(request.prompt, { aspect, refs, model: quote16.model, count: 1, options: { idempotencyKey: key2, maxCredits: String(quote16.totalCredits), ...s.noWait ? { noWait: true } : {} } }).catch((error2) => {
|
|
32820
32878
|
if (error2 instanceof AmbiguousSubmitError) throw new GenerateError("The picture was asked for, but whether it was made is unknown. " + RETRY_HINT);
|
|
32821
32879
|
throw error2;
|
|
32822
32880
|
});
|
|
32823
|
-
const credits2 = typeof made.costCredits === "number" ? made.costCredits :
|
|
32881
|
+
const credits2 = typeof made.costCredits === "number" ? made.costCredits : quote16.totalCredits;
|
|
32824
32882
|
if (made.status === "running" || made.status === "failed") {
|
|
32825
32883
|
const task = typeof made.serverTaskId === "string" ? made.serverTaskId : void 0;
|
|
32826
32884
|
const ended2 = made.status === "failed" ? { told: String(made.taskId) } : {};
|
|
@@ -33013,10 +33071,20 @@ var init_product = __esm({
|
|
|
33013
33071
|
init_generate2();
|
|
33014
33072
|
init_shared();
|
|
33015
33073
|
PROJECT = { name: "project", help: "the video project directory" };
|
|
33016
|
-
builtInGenerator = (rt) =>
|
|
33074
|
+
builtInGenerator = (rt) => {
|
|
33075
|
+
const [program = "", script = "", ...rest] = toolCommand(rt, "POPOST_GEN_CMD") ?? [];
|
|
33076
|
+
const name = rt.path.basename(program).toLowerCase();
|
|
33077
|
+
const nodeCli = /^node(?:\.exe)?$/.test(name) && /(?:^|[/\\])popost[/\\]dist[/\\]cli\.js$/.test(script);
|
|
33078
|
+
if (!nodeCli && !/^popost(?:\.(?:exe|cmd))?$/.test(name)) return false;
|
|
33079
|
+
const args = nodeCli ? rest : [script, ...rest];
|
|
33080
|
+
return args.some((word2, i) => word2 === "video" && args[i + 1] === "generate");
|
|
33081
|
+
};
|
|
33017
33082
|
referenceLimits = async (rt) => {
|
|
33018
33083
|
if (!toolCommand(rt, "POPOST_GEN_CMD")) return { unread: "no generator is configured" };
|
|
33019
|
-
if (!builtInGenerator(rt))
|
|
33084
|
+
if (!builtInGenerator(rt)) {
|
|
33085
|
+
const frames = rt.env.POPOST_GEN_FRAMES?.trim();
|
|
33086
|
+
return frames === "true" || frames === "false" ? { limits: { frames: frames === "true" } } : { unread: "the generator is a tool of your own" };
|
|
33087
|
+
}
|
|
33020
33088
|
try {
|
|
33021
33089
|
const data = await listModels((await platform2(rt)).client);
|
|
33022
33090
|
const wanted = rt.env.POPOST_VIDEO_MODEL?.trim() || (typeof data.default === "string" ? data.default : void 0);
|
|
@@ -33198,10 +33266,10 @@ var init_product = __esm({
|
|
|
33198
33266
|
const dir = userPath(rt, args.req("project"));
|
|
33199
33267
|
const { sheet: sheet4, problems: problems2 } = await readProductSheet(rt, dir);
|
|
33200
33268
|
if (!sheet4) throw new VideoCommandError(problems2.length ? "The product sheet has errors; fix them first (popost video product check <project>)." : "The project has no product sheet.");
|
|
33201
|
-
const [
|
|
33202
|
-
if (!!
|
|
33269
|
+
const [quote16, unattended] = [args.string("quote")?.trim(), args.string("unattended")?.trim()];
|
|
33270
|
+
if (!!quote16 === !!unattended) throw new VideoCommandError(`Give --quote "<the user's answer>", or --unattended "<who authorised running without questions>": one of them, with the actual words.`);
|
|
33203
33271
|
if (!inferredFacts(sheet4).length) throw new VideoCommandError("Every fact of the sheet is the user's own: there is nothing to confirm.");
|
|
33204
|
-
const confirmation = { by:
|
|
33272
|
+
const confirmation = { by: quote16 ? "user" : "unattended", quote: quote16 ?? unattended ?? "", facts: inferredHash(sheet4), at: rt.now().toISOString() };
|
|
33205
33273
|
await writeJson(rt, rt.path.join(dir, PRODUCT_FILE), { ...sheet4, confirmation });
|
|
33206
33274
|
printJson(rt, { ok: true, confirmation: confirmationOf({ ...sheet4, confirmation }), facts: inferredFacts(sheet4).length });
|
|
33207
33275
|
},
|
|
@@ -33996,8 +34064,8 @@ var init_collect = __esm({
|
|
|
33996
34064
|
gather = async (rt, dir, o) => {
|
|
33997
34065
|
const { policy, model } = o.requests.length ? await promptPolicy(rt) : { policy: "user" };
|
|
33998
34066
|
const seen = /* @__PURE__ */ new Map();
|
|
33999
|
-
const
|
|
34000
|
-
const problems2 = (
|
|
34067
|
+
const report4 = o.requests.length ? await makeMaterials(rt, { requests: o.requests, dir, generator: recorder(rt, seen), plan: false, submitOnly: true, product: { paying: false }, policy, ...o.lang ? { lang: o.lang } : {}, ...o.times ? { times: o.times } : {}, ...o.music !== void 0 ? { music: o.music } : {}, ...o.anchor !== void 0 ? { anchor: o.anchor } : {}, ...o.picture ? { picture: o.picture } : {} }) : void 0;
|
|
34068
|
+
const problems2 = (report4?.problems ?? []).filter((p) => !(p.level === "error" && /^It was not made: it costs/.test(p.message)));
|
|
34001
34069
|
const sheet4 = (await readProductSheet(rt, dir)).sheet;
|
|
34002
34070
|
const cast = await readCast(rt, dir).catch(() => void 0);
|
|
34003
34071
|
const productPictures = new Map((sheet4?.products ?? []).flatMap((p) => p.pictures.map((x2) => [x2.file, p.id])));
|
|
@@ -34020,8 +34088,8 @@ var init_collect = __esm({
|
|
|
34020
34088
|
});
|
|
34021
34089
|
for (const [k, role] of [["firstFrame", "first frame"], ["lastFrame", "last frame"]]) if (r[k]) pictures.push({ file: r[k], role, name: role });
|
|
34022
34090
|
const notes2 = [
|
|
34023
|
-
...r.continues ? ["starts from the last frame of " + r.continues + ", taken once that clip is made"] : [],
|
|
34024
|
-
...
|
|
34091
|
+
...r.continues ? ["starts from " + (r.continueAt === void 0 ? "the last frame" : "source frame " + r.continueAt) + " of " + r.continues + ", taken once that clip is made"] : [],
|
|
34092
|
+
...report4?.materials.find((m) => m.file === r.file)?.waiting ? ["a frame of the first clip of the list is added as its last reference picture once that clip is made, with a sentence that points at it"] : []
|
|
34025
34093
|
];
|
|
34026
34094
|
clips.push({
|
|
34027
34095
|
key: key2,
|
|
@@ -34064,7 +34132,7 @@ var init_collect = __esm({
|
|
|
34064
34132
|
kept: kept3,
|
|
34065
34133
|
voices,
|
|
34066
34134
|
...balance !== void 0 ? { balance } : {},
|
|
34067
|
-
notes:
|
|
34135
|
+
notes: report4?.notes ?? []
|
|
34068
34136
|
};
|
|
34069
34137
|
};
|
|
34070
34138
|
}
|
|
@@ -34113,8 +34181,8 @@ var init_sheet4 = __esm({
|
|
|
34113
34181
|
}
|
|
34114
34182
|
if (rows3.length) out2.push("<h2>" + escapeHtml(msg("Clips and pictures to generate", "\u5F85\u751F\u6210\u7684\u89C6\u9891\u7247\u6BB5\u548C\u56FE\u7247")) + "</h2>");
|
|
34115
34183
|
for (const i of rows3) {
|
|
34116
|
-
const
|
|
34117
|
-
out2.push('<div class="card"><div class="head">' + escapeHtml(i.file) + '</div><div class="spec">' + escapeHtml(
|
|
34184
|
+
const spec10 = [i.kind === "video" && i.seconds !== void 0 ? i.seconds + msg(" s", " \u79D2") : "", i.aspect ?? "", i.resolution ?? "", i.model ?? "", i.credits === null ? msg("price unknown", "\u4EF7\u683C\u672A\u77E5") : i.credits + msg(" credits", " \u79EF\u5206")].filter(Boolean).join(" \xB7 ");
|
|
34185
|
+
out2.push('<div class="card"><div class="head">' + escapeHtml(i.file) + '</div><div class="spec">' + escapeHtml(spec10) + '</div><div class="what">' + escapeHtml(short(i.prompt.display ?? i.what, 300)) + '</div><div class="row">' + (i.pictures.length ? i.pictures.map((p) => tile(p.role === "product" ? "product" : p.role === "cast" ? "cast" : "", p.file, p.name, p.role === "product" || p.role === "cast" ? "" : p.role)).join("") : '<span class="none">' + escapeHtml(msg("no picture is sent with it: made from the prompt alone", "\u4E0D\u968F\u8BF7\u6C42\u53D1\u9001\u56FE\u7247\uFF1A\u4EC5\u51ED\u63D0\u793A\u8BCD\u751F\u6210")) + "</span>") + "</div>" + i.notes.map((n) => '<div class="note">' + escapeHtml(n) + "</div>").join("") + "</div>");
|
|
34118
34186
|
}
|
|
34119
34187
|
return '<!doctype html><html><head><meta charset="utf-8"><style>' + CSS3 + "</style></head><body>" + out2.join("") + "</body></html>";
|
|
34120
34188
|
};
|
|
@@ -34245,8 +34313,8 @@ var init_summary = __esm({
|
|
|
34245
34313
|
}
|
|
34246
34314
|
if (s.items.length) out2.push("## " + msg("Clips and pictures to generate", "\u5F85\u751F\u6210\u7684\u89C6\u9891\u7247\u6BB5\u548C\u56FE\u7247"), "");
|
|
34247
34315
|
s.items.forEach((i, n) => {
|
|
34248
|
-
const
|
|
34249
|
-
out2.push("### " + (n + 1) + ". " + i.file + " (" + state(i.confirmed) + ")", "",
|
|
34316
|
+
const spec10 = [i.model ? msg("model ", "\u6A21\u578B ") + i.model : "", i.resolution ?? "", i.seconds !== void 0 && i.kind === "video" ? i.seconds + msg(" s", " \u79D2") : "", i.aspect ?? "", credits(i.credits, i.priceNote)].filter(Boolean).join(" \xB7 ");
|
|
34317
|
+
out2.push("### " + (n + 1) + ". " + i.file + " (" + state(i.confirmed) + ")", "", spec10, "");
|
|
34250
34318
|
if (i.pictures.length) out2.push(msg("Pictures sent with it: ", "\u968F\u8BF7\u6C42\u53D1\u9001\u7684\u56FE\u7247\uFF1A") + i.pictures.map((p) => p.name + " = " + p.file + " (" + p.role + ")").join("; "));
|
|
34251
34319
|
if (i.sounds.length) out2.push(msg("Sounds sent with it: ", "\u968F\u8BF7\u6C42\u53D1\u9001\u7684\u58F0\u97F3\uFF1A") + i.sounds.join(", "));
|
|
34252
34320
|
if (i.clips.length) out2.push(msg("Clips sent with it: ", "\u968F\u8BF7\u6C42\u53D1\u9001\u7684\u89C6\u9891\uFF1A") + i.clips.join(", "));
|
|
@@ -34346,15 +34414,15 @@ var init_takes = __esm({
|
|
|
34346
34414
|
}, "");
|
|
34347
34415
|
takesOf = (lines2) => {
|
|
34348
34416
|
const takes = [];
|
|
34349
|
-
let
|
|
34417
|
+
let run7 = [];
|
|
34350
34418
|
const close = () => {
|
|
34351
|
-
if (
|
|
34352
|
-
|
|
34419
|
+
if (run7.length) takes.push({ lines: run7, text: takeText(run7.map((k) => lines2[k] ?? "")) });
|
|
34420
|
+
run7 = [];
|
|
34353
34421
|
};
|
|
34354
34422
|
lines2.forEach((line, i) => {
|
|
34355
34423
|
if (!line.trim()) return close();
|
|
34356
|
-
if (
|
|
34357
|
-
|
|
34424
|
+
if (run7.length && takeText([...run7, i].map((k) => lines2[k] ?? "")).length > TAKE_MAX) close();
|
|
34425
|
+
run7.push(i);
|
|
34358
34426
|
});
|
|
34359
34427
|
close();
|
|
34360
34428
|
return takes;
|
|
@@ -34682,15 +34750,15 @@ var init_speech_check = __esm({
|
|
|
34682
34750
|
comparedWords = (text13) => {
|
|
34683
34751
|
const out2 = [];
|
|
34684
34752
|
for (const piece of text13.normalize("NFKC").toLowerCase().split(/[^\p{L}\p{N}']+/u)) {
|
|
34685
|
-
let
|
|
34753
|
+
let run7 = "";
|
|
34686
34754
|
for (const ch of piece) {
|
|
34687
34755
|
if (CJK3.test(ch)) {
|
|
34688
|
-
if (
|
|
34689
|
-
|
|
34756
|
+
if (run7) out2.push(run7);
|
|
34757
|
+
run7 = "";
|
|
34690
34758
|
out2.push(ch);
|
|
34691
|
-
} else
|
|
34759
|
+
} else run7 += ch;
|
|
34692
34760
|
}
|
|
34693
|
-
if (
|
|
34761
|
+
if (run7.replace(/'/g, "")) out2.push(run7.replace(/^'+|'+$/g, ""));
|
|
34694
34762
|
}
|
|
34695
34763
|
return out2;
|
|
34696
34764
|
};
|
|
@@ -34712,9 +34780,9 @@ var init_speech_check = __esm({
|
|
|
34712
34780
|
const a = comparedWords(script), b = comparedWords(heard);
|
|
34713
34781
|
const pairs = commonPairs(a, b);
|
|
34714
34782
|
const saidA = new Set(pairs.map(([i]) => i)), saidB = new Set(pairs.map(([, j]) => j));
|
|
34715
|
-
const
|
|
34783
|
+
const missing4 = a.filter((_w, i) => !saidA.has(i)), extra2 = b.filter((_w, j) => !saidB.has(j));
|
|
34716
34784
|
const n = a.length, matched = pairs.length;
|
|
34717
|
-
return { script: n, heard: b.length, matched, share: n ? Math.round(matched / n * 100) / 100 : 1, missing:
|
|
34785
|
+
return { script: n, heard: b.length, matched, share: n ? Math.round(matched / n * 100) / 100 : 1, missing: missing4.slice(0, 12), extra: extra2.slice(0, 12) };
|
|
34718
34786
|
};
|
|
34719
34787
|
lineTimes = (lines2, words) => {
|
|
34720
34788
|
const perLine = lines2.map((l) => comparedWords(l));
|
|
@@ -34944,7 +35012,7 @@ var init_character = __esm({
|
|
|
34944
35012
|
});
|
|
34945
35013
|
|
|
34946
35014
|
// src/video/commands/materials.ts
|
|
34947
|
-
var errorsIn, PICTURE_EXT2, givenAnchor, characterOf, budgeted, payingPending, LOOK_AGAIN_MS, waitLimitMs,
|
|
35015
|
+
var errorsIn, PICTURE_EXT2, givenAnchor, characterOf, budgeted, payingPending, LOOK_AGAIN_MS, waitLimitMs, pendingNext3, beingMade2, allRuns, PRICE_NEXT, specOf2, toAgree, materials;
|
|
34948
35016
|
var init_materials = __esm({
|
|
34949
35017
|
"src/video/commands/materials.ts"() {
|
|
34950
35018
|
"use strict";
|
|
@@ -35012,7 +35080,7 @@ var init_materials = __esm({
|
|
|
35012
35080
|
});
|
|
35013
35081
|
LOOK_AGAIN_MS = 15e3;
|
|
35014
35082
|
waitLimitMs = (rt) => (Number(rt.env.POPOST_GEN_WAIT_MIN) > 0 ? Number(rt.env.POPOST_GEN_WAIT_MIN) : 30) * 6e4;
|
|
35015
|
-
|
|
35083
|
+
pendingNext3 = (internal) => 'The files in "pending" are being made ' + (internal ? "on popost.ai, all at once (a picture takes about a minute, a clip a few minutes) and are paid for. " : "by the selected generator and have already been submitted. ") + "Go on with the steps that do not need them (scenes, captions, the voice-over, the music, the timeline with the clips' places), then run this same command again to pick them up before they are placed or rendered: nothing is paid twice. Clips queued after another are sent once that one is there.";
|
|
35016
35084
|
beingMade2 = (pending3) => {
|
|
35017
35085
|
const count5 = (kind, word2) => {
|
|
35018
35086
|
const n = pending3.filter((m) => m.kind === kind).length;
|
|
@@ -35027,7 +35095,7 @@ var init_materials = __esm({
|
|
|
35027
35095
|
const deadline2 = rt.now().getTime() + waitLimitMs(rt);
|
|
35028
35096
|
while (!noWait && r.materials.some((m) => m.pending || m.queued) && rt.now().getTime() < deadline2) {
|
|
35029
35097
|
const queued = r.materials.filter((m) => m.queued).length;
|
|
35030
|
-
rt.stderr(beingMade2(r.materials.filter((m) => m.pending)) + " being made
|
|
35098
|
+
rt.stderr(beingMade2(r.materials.filter((m) => m.pending)) + " being made by the selected generator" + (queued ? ", " + queued + " queued after them" : "") + "\n");
|
|
35031
35099
|
await sleep(rt, LOOK_AGAIN_MS);
|
|
35032
35100
|
r = await once5();
|
|
35033
35101
|
for (const m of r.materials) if (m.made) made.add(m.file);
|
|
@@ -35068,7 +35136,7 @@ var init_materials = __esm({
|
|
|
35068
35136
|
...CREDIT_OPTIONS,
|
|
35069
35137
|
{ flag: "--approve-unplanned", kind: "append", metavar: "KEY", help: "apply user authorization to this exact clip outside the recorded plan (key from confirm.clip); reuse existing scope/account/budget and repair coverage when valid, otherwise obtain authorization first; repeat only for covered keys" },
|
|
35070
35138
|
{ flag: "--unattended", metavar: "TEXT", help: "nobody can be asked (a batch the user commissioned to run without questions): who authorised going on without showing the inputs, in their words. Recorded as such; the delivery notes say so" },
|
|
35071
|
-
{ flag: "--no-wait", kind: "flag", help: 'send every clip and picture that can be sent and return at once
|
|
35139
|
+
{ flag: "--no-wait", kind: "flag", help: 'send every clip and picture that can be sent and return at once when the selected generator supports it; "pending" lists them. Run the same command again to pick them up (and to send the clips queued after them); nothing is paid twice. Without it the command sends them all and waits until they are there' }
|
|
35072
35140
|
]
|
|
35073
35141
|
},
|
|
35074
35142
|
async (args, rt) => {
|
|
@@ -35080,12 +35148,23 @@ var init_materials = __esm({
|
|
|
35080
35148
|
const modes = pkg ? modeContextOf(pkg.template) : void 0;
|
|
35081
35149
|
const sheet4 = await readProductSheet(rt, dir);
|
|
35082
35150
|
const showsProduct = Array.isArray(requests) && requests.some((r5) => Array.isArray(r5?.products) && r5.products.length > 0);
|
|
35083
|
-
const
|
|
35151
|
+
const internal = builtInGenerator(rt);
|
|
35152
|
+
const route2 = internal ? "popost.ai" : commandGenerator(rt) ? "external" : void 0;
|
|
35153
|
+
const frameRequests = Array.isArray(requests) && requests.some((r5) => r5?.firstFrame !== void 0 || r5?.lastFrame !== void 0 || r5?.continues !== void 0);
|
|
35154
|
+
const limits = sheet4.sheet && showsProduct || frameRequests ? await referenceLimits(rt) : {};
|
|
35155
|
+
const frameSupport = limits.limits?.frames;
|
|
35156
|
+
const frameAdvice = route2 === "external" && frameRequests && frameSupport === void 0 ? [{
|
|
35157
|
+
level: "warning",
|
|
35158
|
+
at: "POPOST_GEN_FRAMES",
|
|
35159
|
+
message: "Exact frame support has not been verified for this external generator.",
|
|
35160
|
+
fix: "Confirm that the adapter sends first and last frames as exact frame constraints, then set POPOST_GEN_FRAMES=true. If it sends them as ordinary references, use POPOST_GEN_FRAMES=false and cut at an intentional change of shot."
|
|
35161
|
+
}] : [];
|
|
35162
|
+
const generation = route2 ? { pipeline: "popost video materials", provider: route2 } : void 0;
|
|
35084
35163
|
if (args.flag("check")) {
|
|
35085
|
-
const wrong = await checkRequests(rt, requests, dir, { selectedIdentity: !!(args.string("character") || args.string("anchor-image")), ...times ? { times } : {}, clipMusic: await clipMusicExceptions(rt, dir) });
|
|
35164
|
+
const wrong = await checkRequests(rt, requests, dir, { selectedIdentity: !!(args.string("character") || args.string("anchor-image")), frames: frameSupport, ...times ? { times } : {}, clipMusic: await clipMusicExceptions(rt, dir) });
|
|
35086
35165
|
const product = Array.isArray(requests) ? await productRequestProblems(rt, requests, dir, { loaded: sheet4, castPictures: await castPictureCount(rt, dir), hint: true, ...limits }) : [];
|
|
35087
35166
|
const stops = wrong.length + errorsIn(product);
|
|
35088
|
-
printJson(rt, { ok: stops === 0, requests: Array.isArray(requests) ? requests.length : 0, problems: [...wrong, ...product, ...groupingAdvice(requests)] });
|
|
35167
|
+
printJson(rt, { ok: stops === 0, requests: Array.isArray(requests) ? requests.length : 0, generation, problems: [...wrong, ...product, ...frameAdvice, ...groupingAdvice(requests)] });
|
|
35089
35168
|
return stops ? 2 : 0;
|
|
35090
35169
|
}
|
|
35091
35170
|
const [image2, character, off2] = [args.string("anchor-image"), args.string("character"), args.flag("no-anchor")];
|
|
@@ -35095,7 +35174,7 @@ var init_materials = __esm({
|
|
|
35095
35174
|
if (!generator) throw new VideoCommandError('No generator is configured: set POPOST_GEN_CMD to a tool of yours (skills/popost/tools/video/ has examples), or to "popost video generate" (popost.ai, paid in credits), or use --check.');
|
|
35096
35175
|
const picture3 = image2 !== void 0 ? await givenAnchor(rt, dir, image2) : character !== void 0 ? await characterOf(rt, dir, character) : void 0;
|
|
35097
35176
|
const wallet = max !== void 0 ? new Wallet(max) : void 0;
|
|
35098
|
-
const pricedOnly = wallet === void 0 &&
|
|
35177
|
+
const pricedOnly = wallet === void 0 && internal && !rt.env.POPOST_GEN_MAX_CREDITS && !/\s--yes\b/.test(rt.env.POPOST_GEN_CMD ?? "");
|
|
35099
35178
|
if (!pricedOnly && Array.isArray(requests) && !errorsIn(sheet4.problems)) {
|
|
35100
35179
|
const current = await currentInputs(rt, dir, { requests, ...picture3 ? { anchor: picture3.file } : {} });
|
|
35101
35180
|
const needed = [...current.toMake, ...picture3 && current.toMake.length ? ["anchor"] : []];
|
|
@@ -35124,6 +35203,8 @@ var init_materials = __esm({
|
|
|
35124
35203
|
plan: wallet !== void 0,
|
|
35125
35204
|
submitOnly: true,
|
|
35126
35205
|
product: { ...limits, paying: !pricedOnly },
|
|
35206
|
+
frames: frameSupport,
|
|
35207
|
+
provider: route2,
|
|
35127
35208
|
policy,
|
|
35128
35209
|
// The template's beats give spoken lines their times; a video with a music track of its own gets clips without music.
|
|
35129
35210
|
...times ? { times } : {},
|
|
@@ -35146,17 +35227,18 @@ var init_materials = __esm({
|
|
|
35146
35227
|
...r.materials.some((m) => m.pending || m.queued) ? {
|
|
35147
35228
|
pending: r.materials.filter((m) => m.pending).map((m) => ({ file: m.file, ...m.task ? { task: m.task } : {} })),
|
|
35148
35229
|
...r.materials.some((m) => m.queued) ? { queued: r.materials.filter((m) => m.queued).map((m) => ({ file: m.file, after: m.waitsFor })) } : {},
|
|
35149
|
-
...agree ? {} : { next:
|
|
35230
|
+
...agree ? {} : { next: pendingNext3(internal) }
|
|
35150
35231
|
} : {},
|
|
35151
35232
|
credits: r.credits,
|
|
35152
35233
|
chargedCredits: r.chargedCredits,
|
|
35153
35234
|
...r.anchor ? { anchor: r.anchor } : {},
|
|
35154
35235
|
...r.toConfirm ? { toConfirm: r.toConfirm } : {},
|
|
35155
35236
|
...agree ?? {},
|
|
35237
|
+
generation,
|
|
35156
35238
|
materials: r.materials,
|
|
35157
35239
|
...r.notes?.length ? { notes: r.notes } : {},
|
|
35158
35240
|
...r.clipMusic?.length ? { clipMusic: r.clipMusic } : {},
|
|
35159
|
-
problems: [...r.problems, ...groupingAdvice(requests)]
|
|
35241
|
+
problems: [...r.problems, ...frameAdvice, ...groupingAdvice(requests)]
|
|
35160
35242
|
});
|
|
35161
35243
|
return agree ? CONFIRM_EXIT : errorsIn(r.problems) ? 2 : 0;
|
|
35162
35244
|
},
|
|
@@ -35334,9 +35416,9 @@ var init_inputs = __esm({
|
|
|
35334
35416
|
const data = await rt.fs.readText(rt.path.join(dir, SUMMARY_JSON)).then((t) => JSON.parse(t), () => void 0);
|
|
35335
35417
|
const summary4 = data ? withDisplay(data, display) : void 0;
|
|
35336
35418
|
if (summary4) await writeSummary(rt, dir, summary4);
|
|
35337
|
-
const
|
|
35338
|
-
await writeInputs(rt, dir, { ...record2, display, shown: { ...record2.shown, ...
|
|
35339
|
-
printJson(rt, { ok: true, stored: Object.keys(map), summary: rt.path.join(dir, SUMMARY_MD), displayMissing:
|
|
35419
|
+
const missing4 = summary4?.displayMissing ?? [];
|
|
35420
|
+
await writeInputs(rt, dir, { ...record2, display, shown: { ...record2.shown, ...missing4.length ? { missing: missing4 } : { missing: [] } } });
|
|
35421
|
+
printJson(rt, { ok: true, stored: Object.keys(map), summary: rt.path.join(dir, SUMMARY_MD), displayMissing: missing4, next: missing4.length ? "Still owed: " + missing4.join(", ") + "." : "The summary now shows the user's-language version first and the sent text underneath. Run popost video inputs show again to redraw the sheet's captions, then show the user." });
|
|
35340
35422
|
},
|
|
35341
35423
|
(args) => args.string("project")
|
|
35342
35424
|
);
|
|
@@ -35351,8 +35433,8 @@ var init_inputs = __esm({
|
|
|
35351
35433
|
},
|
|
35352
35434
|
async (args, rt) => {
|
|
35353
35435
|
const dir = userPath(rt, args.req("project"));
|
|
35354
|
-
const [
|
|
35355
|
-
if (!!
|
|
35436
|
+
const [quote16, unattended] = [args.string("quote")?.trim(), args.string("unattended")?.trim()];
|
|
35437
|
+
if (!!quote16 === !!unattended) throw new VideoCommandError(`Give --quote "<the user's answer>", or --unattended "<who authorised running without questions>": one of them, with the actual words.`);
|
|
35356
35438
|
const record2 = await readInputs(rt, dir);
|
|
35357
35439
|
const shown3 = record2.shown;
|
|
35358
35440
|
if (!shown3) throw new VideoCommandError("Nothing was shown yet: run popost video inputs show <project> --requests <list>, show the user the sheet and the summary, then record their answer.");
|
|
@@ -35360,12 +35442,12 @@ var init_inputs = __esm({
|
|
|
35360
35442
|
const current = await currentInputs(rt, dir, { requests, ...shown3.anchor ? { anchor: shown3.anchor } : {} });
|
|
35361
35443
|
const changed2 = Object.keys({ ...shown3.items, ...current.items }).filter((k) => shown3.items[k] !== current.items[k]);
|
|
35362
35444
|
if (changed2.length) throw new VideoCommandError("The inputs changed since they were shown (" + changed2.join(", ") + "): the user's answer is about what they saw. Run popost video inputs show again, show the user what changed, then record their answer.");
|
|
35363
|
-
if (
|
|
35364
|
-
const by =
|
|
35445
|
+
if (quote16 && shown3.missing?.length) throw new VideoCommandError("The user was not shown " + shown3.missing.join(", ") + " in their own language: write it with popost video inputs translate, run inputs show again and show them, then record their answer.");
|
|
35446
|
+
const by = quote16 ? "user" : "unattended";
|
|
35365
35447
|
const at7 = rt.now().toISOString();
|
|
35366
|
-
await writeInputs(rt, dir, { ...record2, confirmed: { by, quote:
|
|
35448
|
+
await writeInputs(rt, dir, { ...record2, confirmed: { by, quote: quote16 ?? unattended ?? "", at: at7, items: shown3.items } });
|
|
35367
35449
|
const sheet4 = (await readProductSheet(rt, dir)).sheet;
|
|
35368
|
-
if (sheet4 && inferredFacts(sheet4).length && confirmationOf(sheet4) !== "confirmed") await writeJson(rt, rt.path.join(dir, PRODUCT_FILE), { ...sheet4, confirmation: { by, quote:
|
|
35450
|
+
if (sheet4 && inferredFacts(sheet4).length && confirmationOf(sheet4) !== "confirmed") await writeJson(rt, rt.path.join(dir, PRODUCT_FILE), { ...sheet4, confirmation: { by, quote: quote16 ?? unattended ?? "", facts: inferredHash(sheet4), at: at7 } });
|
|
35369
35451
|
printJson(rt, { ok: true, confirmed: Object.keys(shown3.items), by, record: rt.path.join(dir, INPUTS_FILE), ...by === "unattended" ? { note: "The user did not see these inputs (unattended: " + unattended + "). Say so in the delivery notes." } : {}, next: "Run the paid commands within the agreed budget (--confirm --max-credits <left>). A request, picture or voice line changed later is asked about again, alone." });
|
|
35370
35452
|
},
|
|
35371
35453
|
(args) => args.string("project")
|
|
@@ -35892,9 +35974,9 @@ var init_core2 = __esm({
|
|
|
35892
35974
|
const far2 = px2.map((i) => ({ i, t: side * ((f.lab[3 * i] ?? 0) - away[0]) })).sort((a, b) => b.t - a.t || a.i - b.i).slice(0, Math.max(6, Math.round(FAR2 * px2.length)));
|
|
35893
35975
|
const next = labMedian(far2.map((x2) => [f.lab[3 * x2.i] ?? 0, f.lab[3 * x2.i + 1] ?? 0, f.lab[3 * x2.i + 2] ?? 0]));
|
|
35894
35976
|
rgb = rgbMedian(far2.map((x2) => [f.rgb[3 * x2.i] ?? 0, f.rgb[3 * x2.i + 1] ?? 0, f.rgb[3 * x2.i + 2] ?? 0]));
|
|
35895
|
-
const
|
|
35977
|
+
const moved2 = deltaE(next, at7);
|
|
35896
35978
|
at7 = next;
|
|
35897
|
-
if (
|
|
35979
|
+
if (moved2 < 1.5) break;
|
|
35898
35980
|
}
|
|
35899
35981
|
return rgb ? { lab: at7, rgb } : void 0;
|
|
35900
35982
|
};
|
|
@@ -35919,10 +36001,10 @@ var init_core2 = __esm({
|
|
|
35919
36001
|
const far2 = near3.slice(0, Math.max(5, Math.round(near3.length / 4))).map((n) => n.x);
|
|
35920
36002
|
const next = labMedian(far2.map((x2) => x2.lab));
|
|
35921
36003
|
if (seen.filter((x2) => deltaE(x2.lab, next) <= 14).length < seen.length / 6) break;
|
|
35922
|
-
const
|
|
36004
|
+
const moved2 = deltaE(next, at7);
|
|
35923
36005
|
at7 = next;
|
|
35924
36006
|
rgb = rgbMedian(far2.map((x2) => x2.rgb));
|
|
35925
|
-
if (
|
|
36007
|
+
if (moved2 < 1.5) break;
|
|
35926
36008
|
}
|
|
35927
36009
|
return { lab: at7, rgb };
|
|
35928
36010
|
};
|
|
@@ -35942,14 +36024,14 @@ var init_core2 = __esm({
|
|
|
35942
36024
|
};
|
|
35943
36025
|
const scan2 = (outer, inner, at7, into) => {
|
|
35944
36026
|
for (let o = outer[0]; o < outer[1]; o++) {
|
|
35945
|
-
let
|
|
36027
|
+
let run7 = 0;
|
|
35946
36028
|
for (let i = inner[0]; i <= inner[1]; i++) {
|
|
35947
36029
|
if (i < inner[1] && at7(o, i)) {
|
|
35948
|
-
|
|
36030
|
+
run7++;
|
|
35949
36031
|
continue;
|
|
35950
36032
|
}
|
|
35951
|
-
if (
|
|
35952
|
-
|
|
36033
|
+
if (run7 > 0 && run7 <= max) into.push(run7);
|
|
36034
|
+
run7 = 0;
|
|
35953
36035
|
}
|
|
35954
36036
|
}
|
|
35955
36037
|
};
|
|
@@ -36138,13 +36220,13 @@ var init_letters = __esm({
|
|
|
36138
36220
|
const rows3 = [...Array.from({ length: Math.round(0.35 * h) }, (_v, j) => Math.round(box2.y0 - 0.25 * h) + j), ...Array.from({ length: Math.round(0.35 * h) }, (_v, j) => Math.round(box2.y1 - 0.1 * h) + j)].filter((y) => y >= 0 && y < f.h);
|
|
36139
36221
|
let covered4 = 0, total2 = 0;
|
|
36140
36222
|
for (const y of rows3) {
|
|
36141
|
-
let
|
|
36223
|
+
let run7 = 0;
|
|
36142
36224
|
for (let x2 = x0; x2 <= x1; x2++) {
|
|
36143
36225
|
const near3 = x2 < x1 && edge2At(f, y * f.w + x2, lab) <= NEAR * NEAR;
|
|
36144
|
-
if (near3)
|
|
36226
|
+
if (near3) run7++;
|
|
36145
36227
|
else {
|
|
36146
|
-
if (
|
|
36147
|
-
|
|
36228
|
+
if (run7 >= wide) covered4 += run7;
|
|
36229
|
+
run7 = 0;
|
|
36148
36230
|
}
|
|
36149
36231
|
}
|
|
36150
36232
|
total2 += x1 - x0;
|
|
@@ -36582,7 +36664,7 @@ var init_shadow = __esm({
|
|
|
36582
36664
|
MIN_LINES = 2;
|
|
36583
36665
|
lightness = (f, x2, y) => f.lab[3 * (y * f.w + x2)] ?? 0;
|
|
36584
36666
|
scan = (ls, bg, into) => {
|
|
36585
|
-
const
|
|
36667
|
+
const tail4 = (from, step2) => {
|
|
36586
36668
|
let n = 0;
|
|
36587
36669
|
for (let t = from + step2; t >= 0 && t < ls.length; t += step2) {
|
|
36588
36670
|
const v = ls[t] ?? 0, prev = ls[t - step2] ?? 0;
|
|
@@ -36594,8 +36676,8 @@ var init_shadow = __esm({
|
|
|
36594
36676
|
for (let t = 1; t + 1 < ls.length; t++) {
|
|
36595
36677
|
const v = ls[t] ?? 0;
|
|
36596
36678
|
if (v > bg - CORE || v > (ls[t - 1] ?? 0) || v > (ls[t + 1] ?? 0)) continue;
|
|
36597
|
-
into.before.push(
|
|
36598
|
-
into.after.push(
|
|
36679
|
+
into.before.push(tail4(t, -1));
|
|
36680
|
+
into.after.push(tail4(t, 1));
|
|
36599
36681
|
}
|
|
36600
36682
|
};
|
|
36601
36683
|
lightLines = (around3) => around3.flatMap((px2, k) => px2.length && labMedian(px2)[0] >= LIGHT ? [k] : []);
|
|
@@ -37082,9 +37164,9 @@ var init_readback_kept = __esm({
|
|
|
37082
37164
|
const who = readerOf(rt);
|
|
37083
37165
|
const [hashes2, kept3] = await Promise.all([Promise.all(frames.map(async (f) => sha256(await rt.fs.readFile(f.file)))), keptLines(rt, file, who)]);
|
|
37084
37166
|
const old = hashes2.map((h) => Array.isArray(kept3[h]) ? kept3[h] : void 0);
|
|
37085
|
-
const
|
|
37086
|
-
onKept?.(frames.length -
|
|
37087
|
-
const read2 = new Map((
|
|
37167
|
+
const missing4 = frames.filter((_f, i) => old[i] === void 0);
|
|
37168
|
+
onKept?.(frames.length - missing4.length, frames.length);
|
|
37169
|
+
const read2 = new Map((missing4.length ? await reader.read(missing4) : []).map((s) => [s.frame, s.lines]));
|
|
37088
37170
|
const found = frames.flatMap((f, i) => {
|
|
37089
37171
|
const lines2 = old[i] ?? read2.get(f.frame);
|
|
37090
37172
|
return lines2 ? [{ hash: hashes2[i], sample: { frame: f.frame, lines: lines2 } }] : [];
|
|
@@ -37423,12 +37505,12 @@ var init_sheets = __esm({
|
|
|
37423
37505
|
const fps = p.fps > 0 ? p.fps : 30;
|
|
37424
37506
|
const secondsOf4 = o.secondsOf ?? ((f) => f / fps);
|
|
37425
37507
|
const last = Math.max(0, sourceFrames(p) - 1);
|
|
37426
|
-
const drawings = specs2.map((
|
|
37427
|
-
const frames2 =
|
|
37508
|
+
const drawings = specs2.map((spec10) => {
|
|
37509
|
+
const frames2 = spec10.frames.filter((f) => f >= 0 && f <= last);
|
|
37428
37510
|
const grid = gridOf(Math.max(1, frames2.length), size.width);
|
|
37429
37511
|
const width = GAP2 + grid.columns * (size.width + GAP2), height = GAP2 + grid.rows * (size.height + BAND + GAP2);
|
|
37430
|
-
const result = { file: rt.path.join(o.outDir,
|
|
37431
|
-
return { spec: { ...
|
|
37512
|
+
const result = { file: rt.path.join(o.outDir, spec10.file), frames: frames2, seconds: frames2.map((f) => Math.round(secondsOf4(f) * 1e3) / 1e3), ...grid, width, height };
|
|
37513
|
+
return { spec: { ...spec10, frames: frames2 }, grid, left: frames2.length, result };
|
|
37432
37514
|
});
|
|
37433
37515
|
const wanted = /* @__PURE__ */ new Map();
|
|
37434
37516
|
for (const d of drawings) d.spec.frames.forEach((f, slot) => {
|
|
@@ -38308,7 +38390,7 @@ var init_check6 = __esm({
|
|
|
38308
38390
|
fileProblems2 = async (rt, pkg, fill4, dir, lengths) => {
|
|
38309
38391
|
const exists4 = async (p) => await rt.fs.stat(p) !== null;
|
|
38310
38392
|
const out2 = [];
|
|
38311
|
-
const
|
|
38393
|
+
const missing4 = (at7, file) => error(at7, quote13(file) + " does not exist in " + dir + ".", "Put the file there, or correct the path (it is relative to the project directory).");
|
|
38312
38394
|
for (const [k, raw] of fill4.shots.entries()) {
|
|
38313
38395
|
const s = raw;
|
|
38314
38396
|
if (k >= pkg.template.shots.length || kindsOf2(s).length !== 1) continue;
|
|
@@ -38317,7 +38399,7 @@ var init_check6 = __esm({
|
|
|
38317
38399
|
if (typeof file !== "string" || !file.trim() || isOutside(file)) continue;
|
|
38318
38400
|
const full = rt.path.resolve(dir, file);
|
|
38319
38401
|
if (!await exists4(full)) {
|
|
38320
|
-
out2.push(
|
|
38402
|
+
out2.push(missing4("shots[" + k + "]." + key2, file));
|
|
38321
38403
|
continue;
|
|
38322
38404
|
}
|
|
38323
38405
|
if (key2 === "picture" && !PICTURES3.includes(rt.path.extname(file).toLowerCase())) out2.push(error("shots[" + k + "].picture", quote13(file) + " is not a picture file (" + PICTURES3.join(", ") + ").", "Convert it to WebP or PNG."));
|
|
@@ -38327,8 +38409,8 @@ var init_check6 = __esm({
|
|
|
38327
38409
|
}
|
|
38328
38410
|
out2.push(...await itemFileProblems(rt, pkg, s, k, dir, lengths));
|
|
38329
38411
|
}
|
|
38330
|
-
if (typeof fill4.sound === "string" && !await exists4(rt.path.resolve(dir, fill4.sound))) out2.push(
|
|
38331
|
-
for (const [i, bed] of (Array.isArray(fill4.beds) ? fill4.beds : []).entries()) if (typeof bed?.footage === "string" && !isOutside(bed.footage) && !await exists4(rt.path.resolve(dir, bed.footage))) out2.push(
|
|
38412
|
+
if (typeof fill4.sound === "string" && !await exists4(rt.path.resolve(dir, fill4.sound))) out2.push(missing4("sound", fill4.sound));
|
|
38413
|
+
for (const [i, bed] of (Array.isArray(fill4.beds) ? fill4.beds : []).entries()) if (typeof bed?.footage === "string" && !isOutside(bed.footage) && !await exists4(rt.path.resolve(dir, bed.footage))) out2.push(missing4("beds[" + i + "].footage", bed.footage));
|
|
38332
38414
|
out2.push(...await stillProblems(rt, pkg, fill4, dir, lengths));
|
|
38333
38415
|
for (const p of await slotPictures(rt, fill4, dir)) out2.push(...await slotPictureProblems(rt, p, dir));
|
|
38334
38416
|
return out2;
|
|
@@ -38882,9 +38964,9 @@ var init_build2 = __esm({
|
|
|
38882
38964
|
if (moving && camera3?.pan) notes2.push({ at: "segments[" + k + "].base.camera", kind: "approximate", message: "A pan needs a picture wider than one frame; one frame of the reference is used and scaled up." });
|
|
38883
38965
|
const segment2 = { id: id2, frames, base: { material: "pic-" + id2, ...camera3 && Object.keys(camera3).length ? { camera: camera3 } : {} } };
|
|
38884
38966
|
if (into) {
|
|
38885
|
-
const
|
|
38886
|
-
if (
|
|
38887
|
-
segment2.in =
|
|
38967
|
+
const spec10 = transitionSpec2(into, toFrames2);
|
|
38968
|
+
if (spec10) {
|
|
38969
|
+
segment2.in = spec10;
|
|
38888
38970
|
if (into.confidence < minConfidence) notes2.push({ at: "segments[" + k + "].in", kind: "inferred", message: "The kind of this transition was measured with low confidence (" + into.confidence.toFixed(2) + ")." });
|
|
38889
38971
|
}
|
|
38890
38972
|
}
|
|
@@ -39654,11 +39736,11 @@ var init_shot_transition = __esm({
|
|
|
39654
39736
|
};
|
|
39655
39737
|
return other.boundaries.filter((b) => b.kind !== "cut" && spanOf2(b, fb).from <= w.to && spanOf2(b, fb).to >= w.from).sort((x2, y) => Math.abs(centre2(x2) - mid3) - Math.abs(centre2(y) - mid3))[0];
|
|
39656
39738
|
};
|
|
39657
|
-
transitionOf3 = (ref, other, into,
|
|
39739
|
+
transitionOf3 = (ref, other, into, locate4) => {
|
|
39658
39740
|
if (!into || into.kind === "cut") return void 0;
|
|
39659
39741
|
const fa = fpsOf(ref), dtA = ref.rhythm.step / fa, dtB = other.rhythm.step / fpsOf(other);
|
|
39660
39742
|
const reference2 = spanOf2(into, fa);
|
|
39661
|
-
const where3 =
|
|
39743
|
+
const where3 = locate4(reference2);
|
|
39662
39744
|
if (!ref.rhythm.change.length || !other.rhythm.change.length) return void 0;
|
|
39663
39745
|
const wa = { from: reference2.from - CONTEXT_SAMPLES * dtA, to: reference2.to + CONTEXT_SAMPLES * dtA };
|
|
39664
39746
|
const n = Math.max(MIN_POINTS, Math.round((wa.to - wa.from) / dtA));
|
|
@@ -40126,19 +40208,19 @@ var init_generate3 = __esm({
|
|
|
40126
40208
|
const kind = r.pick(kinds);
|
|
40127
40209
|
if (kind === "cut") return void 0;
|
|
40128
40210
|
const frames = r.int(Math.round(fps * 0.2), Math.round(fps * 0.6));
|
|
40129
|
-
const
|
|
40130
|
-
if (kind === "wipe")
|
|
40211
|
+
const spec10 = { transition: kind, frames };
|
|
40212
|
+
if (kind === "wipe") spec10.direction = r.pick(WIPE_DIRECTIONS);
|
|
40131
40213
|
if (kind === "slide") {
|
|
40132
|
-
|
|
40133
|
-
|
|
40214
|
+
spec10.direction = r.pick(DIRECTIONS2);
|
|
40215
|
+
spec10.mode = r.pick(["push", "cover", "reveal"]);
|
|
40134
40216
|
}
|
|
40135
|
-
if (kind === "whip")
|
|
40136
|
-
if (kind === "fade")
|
|
40217
|
+
if (kind === "whip") spec10.direction = r.pick(DIRECTIONS2);
|
|
40218
|
+
if (kind === "fade") spec10.via = r.pick(["black", "white"]);
|
|
40137
40219
|
if (sides && SIDED.includes(kind) && r.chance(0.5)) {
|
|
40138
|
-
|
|
40139
|
-
|
|
40220
|
+
spec10.side = r.pick(["after", "before"]);
|
|
40221
|
+
spec10.strength = r.pick([0.6, 1, 1.5]);
|
|
40140
40222
|
}
|
|
40141
|
-
return
|
|
40223
|
+
return spec10;
|
|
40142
40224
|
};
|
|
40143
40225
|
cameraMove = (r, frames, fps) => {
|
|
40144
40226
|
const from = r.int(Math.round(fps * 0.5), Math.round(frames * 0.3));
|
|
@@ -40149,14 +40231,14 @@ var init_generate3 = __esm({
|
|
|
40149
40231
|
};
|
|
40150
40232
|
motion2 = (r, presets, fps, maxFrames) => {
|
|
40151
40233
|
const preset = r.pick(presets);
|
|
40152
|
-
const
|
|
40153
|
-
if (preset === "none") return
|
|
40154
|
-
|
|
40155
|
-
if (preset !== "type")
|
|
40156
|
-
if (preset === "pop")
|
|
40157
|
-
if (preset === "slide" || preset === "wipe")
|
|
40158
|
-
if (preset === "slide")
|
|
40159
|
-
return
|
|
40234
|
+
const spec10 = { preset };
|
|
40235
|
+
if (preset === "none") return spec10;
|
|
40236
|
+
spec10.frames = Math.max(3, Math.min(maxFrames, r.int(Math.round(fps * 0.2), Math.round(fps * 0.5))));
|
|
40237
|
+
if (preset !== "type") spec10.ease = r.pick(EASES3);
|
|
40238
|
+
if (preset === "pop") spec10.overshoot = r.pick([0.08, 0.12, 0.2]);
|
|
40239
|
+
if (preset === "slide" || preset === "wipe") spec10.direction = r.pick(DIRECTIONS2);
|
|
40240
|
+
if (preset === "slide") spec10.distance = r.pick([0.2, 0.3, 0.45]);
|
|
40241
|
+
return spec10;
|
|
40160
40242
|
};
|
|
40161
40243
|
boxes = (r, n) => {
|
|
40162
40244
|
const rows3 = [0.1, 0.4, 0.7];
|
|
@@ -40193,9 +40275,9 @@ var init_generate3 = __esm({
|
|
|
40193
40275
|
const k = segments2.findIndex((s3) => "assets/" + s3.id + ".png" === p.file);
|
|
40194
40276
|
const s = segments2[k], next = segments2[k + 1];
|
|
40195
40277
|
if (!s || !ALIASING.has(p.recipe.source)) return p;
|
|
40196
|
-
const
|
|
40278
|
+
const moved2 = "material" in s.base && s.base.camera !== void 0;
|
|
40197
40279
|
const transformed = [s.in, next?.in].some((t) => t !== void 0 && TRANSFORMING.has(t.transition));
|
|
40198
|
-
return
|
|
40280
|
+
return moved2 || transformed ? { ...p, recipe: { ...p.recipe, source: STEADY2[p.recipe.seed % STEADY2.length] } } : p;
|
|
40199
40281
|
});
|
|
40200
40282
|
synthCase = (options) => {
|
|
40201
40283
|
const o = { width: 1080, height: 1920, fps: 30, transitions: ALL_TRANSITIONS, motions: ALL_MOTIONS, pictureShare: 0.6, maxItems: 2, cameraShare: 0.4, ...options };
|
|
@@ -41423,7 +41505,7 @@ var init_director = __esm({
|
|
|
41423
41505
|
}
|
|
41424
41506
|
};
|
|
41425
41507
|
const shot = async () => {
|
|
41426
|
-
const
|
|
41508
|
+
const spec10 = {
|
|
41427
41509
|
camera: camera3,
|
|
41428
41510
|
sample: sampleNext || frames % SAMPLE_EVERY === 0,
|
|
41429
41511
|
...highlight ? { highlight: { ...highlight, line } } : {},
|
|
@@ -41431,7 +41513,7 @@ var init_director = __esm({
|
|
|
41431
41513
|
...ring2 ? { ring: { ...ring2, line: Math.max(1.5, line * 0.75) } } : {}
|
|
41432
41514
|
};
|
|
41433
41515
|
sampleNext = false;
|
|
41434
|
-
const draw2 = () => page2.evaluate((f) => window.__popostStage ? { sample: window.__popostStage.render(f) } : null,
|
|
41516
|
+
const draw2 = () => page2.evaluate((f) => window.__popostStage ? { sample: window.__popostStage.render(f) } : null, spec10);
|
|
41435
41517
|
let drawn = await draw2();
|
|
41436
41518
|
if (!drawn) {
|
|
41437
41519
|
await newDocument();
|
|
@@ -41452,7 +41534,7 @@ var init_director = __esm({
|
|
|
41452
41534
|
frames++;
|
|
41453
41535
|
return Buffer.from(shotOf4.data, "base64");
|
|
41454
41536
|
};
|
|
41455
|
-
const
|
|
41537
|
+
const locate4 = async (index, selector) => {
|
|
41456
41538
|
const handle3 = await page2.locator(selector).first().elementHandle({ timeout: 3e3 }).catch(() => null);
|
|
41457
41539
|
if (!handle3) throw new CaptureError(at7(index) + "nothing on " + page2.url() + ' matches "' + selector + '". Take a selector from popost video capture <url> --outline (sections, targets), or write a CSS selector of your own.');
|
|
41458
41540
|
return handle3;
|
|
@@ -41469,7 +41551,7 @@ var init_director = __esm({
|
|
|
41469
41551
|
return z10.x > 0 && z10.y > 0 && a.x < view.width && a.y < view.height;
|
|
41470
41552
|
};
|
|
41471
41553
|
const middleOf2 = async (index, selector, scroll) => {
|
|
41472
|
-
const handle3 = await
|
|
41554
|
+
const handle3 = await locate4(index, selector);
|
|
41473
41555
|
let b = await boxOf(index, handle3, selector);
|
|
41474
41556
|
let p = { x: b.x + b.width / 2, y: b.y + b.height / 2 };
|
|
41475
41557
|
if (scroll && !inWindow(p)) {
|
|
@@ -41517,7 +41599,7 @@ var init_director = __esm({
|
|
|
41517
41599
|
const named = Array.isArray(z10.to) ? "the box " + JSON.stringify(z10.to) : '"' + z10.to + '"';
|
|
41518
41600
|
const box2 = Array.isArray(z10.to) ? { x: z10.to[0], y: z10.to[1], width: z10.to[2], height: z10.to[3] } : await (async () => {
|
|
41519
41601
|
const sel = z10.to;
|
|
41520
|
-
const b = await boxOf(index, await
|
|
41602
|
+
const b = await boxOf(index, await locate4(index, sel), sel);
|
|
41521
41603
|
return { ...b, x: b.x + now.scrollX, y: b.y + now.scrollY };
|
|
41522
41604
|
})();
|
|
41523
41605
|
plan4 = zoomPlan(box2, now, view, fill4, o.band);
|
|
@@ -41538,7 +41620,7 @@ var init_director = __esm({
|
|
|
41538
41620
|
}
|
|
41539
41621
|
async function* mark(index, h, frame2) {
|
|
41540
41622
|
const id2 = nextId++;
|
|
41541
|
-
await keep3(await
|
|
41623
|
+
await keep3(await locate4(index, h.to), id2);
|
|
41542
41624
|
const base = { id: id2, selector: h.to, style: h.style ?? "box", color: h.color ?? DEFAULTS.color, pad: h.pad ?? DEFAULTS.pad, progress: 0, opacity: 1 };
|
|
41543
41625
|
const count5 = h.frames ?? DEFAULTS.highlightFrames;
|
|
41544
41626
|
for (let i = 1; i <= count5; i++) {
|
|
@@ -41562,7 +41644,7 @@ var init_director = __esm({
|
|
|
41562
41644
|
highlight = void 0;
|
|
41563
41645
|
}
|
|
41564
41646
|
async function* type(index, t, frame2) {
|
|
41565
|
-
const handle3 = await
|
|
41647
|
+
const handle3 = await locate4(index, t.into);
|
|
41566
41648
|
try {
|
|
41567
41649
|
await handle3.fill("", { timeout: 3e3 });
|
|
41568
41650
|
await handle3.focus();
|
|
@@ -41582,7 +41664,7 @@ var init_director = __esm({
|
|
|
41582
41664
|
}
|
|
41583
41665
|
async function* hover(index, selector, frame2) {
|
|
41584
41666
|
if (!pointer) {
|
|
41585
|
-
await (await
|
|
41667
|
+
await (await locate4(index, selector)).hover({ timeout: 5e3 });
|
|
41586
41668
|
yield await frame2();
|
|
41587
41669
|
return;
|
|
41588
41670
|
}
|
|
@@ -41595,7 +41677,7 @@ var init_director = __esm({
|
|
|
41595
41677
|
}
|
|
41596
41678
|
async function* click(index, selector, frame2) {
|
|
41597
41679
|
if (!pointer) {
|
|
41598
|
-
const handle3 = await
|
|
41680
|
+
const handle3 = await locate4(index, selector);
|
|
41599
41681
|
await settleAfter(() => handle3.click({ timeout: 5e3 }));
|
|
41600
41682
|
yield await frame2();
|
|
41601
41683
|
return;
|
|
@@ -43229,7 +43311,7 @@ var init_render3 = __esm({
|
|
|
43229
43311
|
lastSent = now;
|
|
43230
43312
|
send2(next);
|
|
43231
43313
|
};
|
|
43232
|
-
const
|
|
43314
|
+
const run7 = async (settings2, snapshot) => {
|
|
43233
43315
|
const started = rt.now().getTime();
|
|
43234
43316
|
set2({ state: "running", frame: 0, total: 0, started });
|
|
43235
43317
|
try {
|
|
@@ -43261,7 +43343,7 @@ var init_render3 = __esm({
|
|
|
43261
43343
|
return {
|
|
43262
43344
|
start: (settings2, snapshot) => {
|
|
43263
43345
|
if (running) return false;
|
|
43264
|
-
running =
|
|
43346
|
+
running = run7(settings2, snapshot).finally(() => {
|
|
43265
43347
|
running = void 0;
|
|
43266
43348
|
});
|
|
43267
43349
|
return true;
|
|
@@ -44019,7 +44101,7 @@ var init_lifecycle = __esm({
|
|
|
44019
44101
|
init_native();
|
|
44020
44102
|
pause = (rt, ms) => rt.sleep?.(ms) ?? new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
44021
44103
|
waitForExit = async (rt, app) => {
|
|
44022
|
-
for (let
|
|
44104
|
+
for (let attempt3 = 0; attempt3 < 25; attempt3++) {
|
|
44023
44105
|
if (!(await applicationPids(rt, app)).length) return true;
|
|
44024
44106
|
await pause(rt, 200);
|
|
44025
44107
|
}
|
|
@@ -44041,7 +44123,7 @@ var init_lifecycle = __esm({
|
|
|
44041
44123
|
else await runNative(rt, ["taskkill", "/PID", String(pid)]);
|
|
44042
44124
|
}
|
|
44043
44125
|
if (restarted && !await waitForExit(rt, app)) return { ok: false, restarted, quitPending: true };
|
|
44044
|
-
for (let
|
|
44126
|
+
for (let attempt3 = 0; attempt3 < 4; attempt3++) {
|
|
44045
44127
|
if (rt.platform === "darwin") await runNative(rt, ["open", "-a", app.appPath]);
|
|
44046
44128
|
else if (rt.processes) await rt.processes.spawnDetached([app.executable], { cwd: app.appPath, logFile: rt.path.join(dir, ".studio", "native-editor.log") });
|
|
44047
44129
|
else return { ok: false, restarted, message: "This host cannot launch the desktop editor." };
|
|
@@ -44995,10 +45077,10 @@ var init_copied = __esm({
|
|
|
44995
45077
|
for (let i = 0; i < tokens3.length; ) {
|
|
44996
45078
|
let j = i;
|
|
44997
45079
|
while (j < tokens3.length && all.includes(keyOf7(tokens3.slice(i, j + 1)))) j++;
|
|
44998
|
-
const
|
|
44999
|
-
const key2 = keyOf7(
|
|
45000
|
-
const line =
|
|
45001
|
-
if (line) out2.push({ shown: normal.slice(
|
|
45080
|
+
const run7 = tokens3.slice(i, j);
|
|
45081
|
+
const key2 = keyOf7(run7);
|
|
45082
|
+
const line = run7.reduce((n, x2) => n + x2.weight, 0) >= PHRASE && !told.includes(key2) ? lines2.find((l) => l.key.includes(key2))?.line : void 0;
|
|
45083
|
+
if (line) out2.push({ shown: normal.slice(run7[0]?.at ?? 0, run7[run7.length - 1]?.end ?? 0), line });
|
|
45002
45084
|
i = line ? j : i + 1;
|
|
45003
45085
|
}
|
|
45004
45086
|
return out2;
|
|
@@ -45084,11 +45166,11 @@ var init_findings2 = __esm({
|
|
|
45084
45166
|
};
|
|
45085
45167
|
unseenProblem = (shot, mine, longer, theirs, picture3) => {
|
|
45086
45168
|
const shown3 = theirs.filter((t) => t.visible).map((t) => t.index);
|
|
45087
|
-
const
|
|
45088
|
-
if (!
|
|
45169
|
+
const missing4 = outermost(mine.filter((t) => !t.visible && shown3.includes(t.index))).slice(0, 3);
|
|
45170
|
+
if (!missing4.length) return void 0;
|
|
45089
45171
|
return warning(
|
|
45090
45172
|
at4(shot.k),
|
|
45091
|
-
"In " + where2(shot) + ", a shot of " + s2(shot.seconds) + ", " + quoted4(
|
|
45173
|
+
"In " + where2(shot) + ", a shot of " + s2(shot.seconds) + ", " + quoted4(missing4.map((t) => t.text)) + (missing4.length > 1 ? " are" : " is") + " never visible (" + picture3 + '), though segment "' + longer.id + '" (' + s2(longer.seconds) + ") shows " + (missing4.length > 1 ? "them" : "it") + " with the same scene file: the entrance starts after this shorter shot has ended.",
|
|
45092
45174
|
'Time the entrances for the shortest shot that shows "' + shot.src + '": every text visible by ' + s2(readBy(shot.seconds)) + ", then held. Or give this segment a scene file of its own."
|
|
45093
45175
|
);
|
|
45094
45176
|
};
|
|
@@ -46743,13 +46825,13 @@ var init_see = __esm({
|
|
|
46743
46825
|
}
|
|
46744
46826
|
const usage2 = { input: 0, output: 0 };
|
|
46745
46827
|
let why = "";
|
|
46746
|
-
for (let
|
|
46828
|
+
for (let attempt3 = 1; attempt3 <= 2; attempt3++) {
|
|
46747
46829
|
const reply = await o.model.ask([{ role: "user", content }]);
|
|
46748
46830
|
usage2.input += reply.usage?.input ?? 0;
|
|
46749
46831
|
usage2.output += reply.usage?.output ?? 0;
|
|
46750
46832
|
const value = extractJson(reply.text).value;
|
|
46751
46833
|
const list7 = Array.isArray(value?.shots) ? value.shots.filter((x2) => typeof x2 === "string" && x2.trim() !== "") : [];
|
|
46752
|
-
if (list7.length === shots2.length) return { notes: list7.map((x2) => x2.trim().replace(/\s+/g, " ").replace(/^shot\s*\d+\s*[:.-]\s*/i, "")), usage: usage2, requests:
|
|
46834
|
+
if (list7.length === shots2.length) return { notes: list7.map((x2) => x2.trim().replace(/\s+/g, " ").replace(/^shot\s*\d+\s*[:.-]\s*/i, "")), usage: usage2, requests: attempt3 };
|
|
46753
46835
|
why = "the model gave " + list7.length + " sentences for " + shots2.length + " shots";
|
|
46754
46836
|
}
|
|
46755
46837
|
return { usage: usage2, requests: 2, why };
|
|
@@ -47947,14 +48029,14 @@ var init_hosted3 = __esm({
|
|
|
47947
48029
|
}
|
|
47948
48030
|
};
|
|
47949
48031
|
quoteOrder = async (rt, seconds8) => {
|
|
47950
|
-
const
|
|
48032
|
+
const quote16 = await quoteMusicTrack(rt, seconds8).catch((e) => {
|
|
47951
48033
|
const max = e instanceof PopostApiError && e.code === "INVALID_REQUEST" && typeof e.details.maxSeconds === "number" ? e.details.maxSeconds : void 0;
|
|
47952
48034
|
if (max !== void 0) throw new MusicTooLong(seconds8, max);
|
|
47953
48035
|
if (e instanceof PopostApiError && e.code === "UPSTREAM_ERROR" && (e.status === 503 || e.status === void 0)) throw new MusicUnavailable();
|
|
47954
48036
|
throw e;
|
|
47955
48037
|
});
|
|
47956
|
-
if (
|
|
47957
|
-
return
|
|
48038
|
+
if (quote16.maxTrackSeconds !== null && seconds8 > quote16.maxTrackSeconds) throw new MusicTooLong(seconds8, quote16.maxTrackSeconds);
|
|
48039
|
+
return quote16;
|
|
47958
48040
|
};
|
|
47959
48041
|
UNAVAILABLE = "popost.ai could not make the music (its generator is not available now); nothing was charged. Run the same command again later.";
|
|
47960
48042
|
HINT = "Run the same command again: the same description and length reuse the same music job.";
|
|
@@ -47984,19 +48066,19 @@ var init_hosted3 = __esm({
|
|
|
47984
48066
|
};
|
|
47985
48067
|
inPlace = async (rt, out2, r) => r.audioSha256 !== void 0 && await rt.fs.readFile(out2).then((bytes) => sha256(bytes) === r.audioSha256, () => false);
|
|
47986
48068
|
orderLength = async (rt, seconds8) => {
|
|
47987
|
-
const
|
|
47988
|
-
const longer = Math.min(seconds8 + MARGIN_SECONDS,
|
|
47989
|
-
if (!(longer > seconds8)) return { seconds: seconds8, quote:
|
|
48069
|
+
const quote16 = await quoteOrder(rt, seconds8);
|
|
48070
|
+
const longer = Math.min(seconds8 + MARGIN_SECONDS, quote16.maxTrackSeconds === null ? Infinity : Math.floor(quote16.maxTrackSeconds));
|
|
48071
|
+
if (!(longer > seconds8)) return { seconds: seconds8, quote: quote16 };
|
|
47990
48072
|
const more = await quoteOrder(rt, longer).catch((e) => {
|
|
47991
48073
|
if (e instanceof MusicTooLong) return void 0;
|
|
47992
48074
|
throw e;
|
|
47993
48075
|
});
|
|
47994
|
-
return more && more.credits ===
|
|
48076
|
+
return more && more.credits === quote16.credits ? { seconds: longer, quote: more } : { seconds: seconds8, quote: quote16 };
|
|
47995
48077
|
};
|
|
47996
48078
|
musicPrice = async (rt, o) => {
|
|
47997
48079
|
if ((await receiptOf2(rt, o)).id) return [];
|
|
47998
|
-
const { quote:
|
|
47999
|
-
return [{ kind: "music", what: (o.vocals ? "music with vocals: " : "instrumental music: ") + clip10(o.prompt) + (
|
|
48080
|
+
const { quote: quote16 } = await orderLength(rt, o.seconds);
|
|
48081
|
+
return [{ kind: "music", what: (o.vocals ? "music with vocals: " : "instrumental music: ") + clip10(o.prompt) + (quote16.model ? " (" + quote16.model + ")" : ""), credits: quote16.credits, seconds: o.seconds }];
|
|
48000
48082
|
};
|
|
48001
48083
|
download3 = async (rt, url, out2) => {
|
|
48002
48084
|
const bytes = await downloadPaid(rt, url, { what: "the music", again: "Run the same command again: the track is paid for and is downloaded again without a new charge.", maxBytes: MAX_BYTES4 });
|
|
@@ -48059,8 +48141,8 @@ var init_hosted3 = __esm({
|
|
|
48059
48141
|
lengthOf = async (rt, o, known2) => {
|
|
48060
48142
|
const had = known2 ?? await audioSeconds(rt, o.out).catch(() => void 0);
|
|
48061
48143
|
if (had === void 0) return { seconds: null };
|
|
48062
|
-
const seconds8 = round22(had),
|
|
48063
|
-
return { seconds: seconds8, ...
|
|
48144
|
+
const seconds8 = round22(had), missing4 = round22((o.fit ?? o.seconds) - had);
|
|
48145
|
+
return { seconds: seconds8, ...missing4 > SHORT_TOLERANCE ? { short: { seconds: seconds8, missing: missing4 } } : {} };
|
|
48064
48146
|
};
|
|
48065
48147
|
written = async (rt, o, receipt, job) => {
|
|
48066
48148
|
if (job.state !== "ready" || !job.audioUrl) throw new ToolError("The popost.ai music is " + (job.state || "not ready") + "; run the same command again.");
|
|
@@ -48146,7 +48228,7 @@ var init_media = __esm({
|
|
|
48146
48228
|
const account = connected(rt);
|
|
48147
48229
|
const tools2 = { ...named, transcribe: named.transcribe ?? (account ? HOSTED : null), speak: named.speak ?? (account ? HOSTED : null), music: musicEnabled(rt) ? HOSTED : null };
|
|
48148
48230
|
const offers = account ? { hosted: HOSTED_NOTE } : { connect: CONNECT };
|
|
48149
|
-
const
|
|
48231
|
+
const missing4 = [
|
|
48150
48232
|
...rt.programs ? [] : ["this host cannot run local programs, so no video command works here"],
|
|
48151
48233
|
...rt.programs && version === null ? ['ffmpeg was not found: install it or set POPOST_FFMPEG (asked for "' + ffmpegPath(rt) + '")'] : [],
|
|
48152
48234
|
...browser === true ? [] : [browser]
|
|
@@ -48155,8 +48237,8 @@ var init_media = __esm({
|
|
|
48155
48237
|
const cpus = budget ? { budget: budget.cpus, from: budget.source } : null;
|
|
48156
48238
|
const reading = named.readText !== null || named.transcribe !== null;
|
|
48157
48239
|
const cache2 = await projectCache(rt);
|
|
48158
|
-
printJson(rt, { ok:
|
|
48159
|
-
return
|
|
48240
|
+
printJson(rt, { ok: missing4.length === 0, ffmpeg: version, browser: browser === true, cpus, tools: tools2, ...cache2 ? { cache: cache2 } : {}, ...offers, ...reading ? { note: FIRST_RUN } : {}, ...missing4.length ? { missing: missing4 } : {} });
|
|
48241
|
+
return missing4.length ? 2 : 0;
|
|
48160
48242
|
}
|
|
48161
48243
|
);
|
|
48162
48244
|
soundOnly = async (rt, file, e) => {
|
|
@@ -48505,8 +48587,8 @@ var init_music = __esm({
|
|
|
48505
48587
|
lengthLine = (made, file, of) => {
|
|
48506
48588
|
if (made.seconds === null) return "The length of " + file + " could not be read here (ffmpeg): check it against the video's " + of.toFixed(2) + " s before the music is placed.\n";
|
|
48507
48589
|
if (!made.short) return void 0;
|
|
48508
|
-
const { seconds: seconds8, missing:
|
|
48509
|
-
return "The music is " + seconds8.toFixed(2) + " s long, " +
|
|
48590
|
+
const { seconds: seconds8, missing: missing4 } = made.short;
|
|
48591
|
+
return "The music is " + seconds8.toFixed(2) + " s long, " + missing4.toFixed(2) + " s shorter than the " + of.toFixed(2) + " s it is for: the last " + missing4.toFixed(2) + " s of the video would have no music. Order a longer track (this command with --seconds " + musicSeconds(of + missing4 + MARGIN_SECONDS) + " is a new order, priced and agreed anew; the music is faded out at the end of the video), or end the video with the music (shorten its last scene by " + missing4.toFixed(2) + " s).\n";
|
|
48510
48592
|
};
|
|
48511
48593
|
overLimit = (e, items, max) => {
|
|
48512
48594
|
if (!(e instanceof PopostApiError && e.code === "CREDIT_LIMIT_EXCEEDED")) throw e;
|
|
@@ -49459,8 +49541,8 @@ var init_project_windows = __esm({
|
|
|
49459
49541
|
return first.map((k) => {
|
|
49460
49542
|
if (k === void 0 || k === 0) return void 0;
|
|
49461
49543
|
const t = resolveTransition(project.segments[k]?.in, tl.starts[k], fps);
|
|
49462
|
-
const
|
|
49463
|
-
return t ? { from: t.a / fps, to: (t.a + t.frames) / fps, declared: { kind: t.kind, residual: 0, ...
|
|
49544
|
+
const spec10 = project.segments[k]?.in;
|
|
49545
|
+
return t ? { from: t.a / fps, to: (t.a + t.frames) / fps, declared: { kind: t.kind, residual: 0, ...spec10?.direction ? { direction: spec10.direction } : {}, ...spec10?.mode ? { mode: spec10.mode } : {}, ...spec10?.via ? { via: spec10.via } : {} } } : { from: tl.starts[k] / fps, to: tl.starts[k] / fps };
|
|
49464
49546
|
});
|
|
49465
49547
|
};
|
|
49466
49548
|
}
|
|
@@ -49475,16 +49557,16 @@ var init_compare_scope = __esm({
|
|
|
49475
49557
|
init_fingerprint2();
|
|
49476
49558
|
comparisonScope = (reference2, facts) => {
|
|
49477
49559
|
const unchanged2 = { measure: reference2 };
|
|
49478
|
-
const
|
|
49479
|
-
if (!Array.isArray(
|
|
49560
|
+
const omitted2 = facts?.omittedShots;
|
|
49561
|
+
if (!Array.isArray(omitted2) || !omitted2.length || !facts?.template.fingerprint || referenceFingerprint(reference2) !== facts.template.fingerprint) return unchanged2;
|
|
49480
49562
|
const fps = reference2.source.fps;
|
|
49481
49563
|
let end = reference2.source.frames;
|
|
49482
|
-
for (const s of [...
|
|
49564
|
+
for (const s of [...omitted2].reverse()) {
|
|
49483
49565
|
if (!s || typeof s.reason !== "string" || !s.reason.trim() || !Array.isArray(s.seconds) || s.seconds.length !== 2 || !s.seconds.every(Number.isFinite) || Math.abs(s.seconds[1] * fps - end) > 0.51 || s.seconds[0] < 0 || s.seconds[0] >= s.seconds[1]) return unchanged2;
|
|
49484
49566
|
end = Math.round(s.seconds[0] * fps);
|
|
49485
49567
|
if (!reference2.shots.some((shot) => Math.abs(shot.start - end) <= 1)) return unchanged2;
|
|
49486
49568
|
}
|
|
49487
|
-
return end > 0 && end < reference2.source.frames ? { measure: endAt({ measure: reference2 }, end).measure, omitted } : unchanged2;
|
|
49569
|
+
return end > 0 && end < reference2.source.frames ? { measure: endAt({ measure: reference2 }, end).measure, omitted: omitted2 } : unchanged2;
|
|
49488
49570
|
};
|
|
49489
49571
|
}
|
|
49490
49572
|
});
|
|
@@ -50244,6 +50326,122 @@ var init_motion_bundle = __esm({
|
|
|
50244
50326
|
}
|
|
50245
50327
|
});
|
|
50246
50328
|
|
|
50329
|
+
// src/video/replication/review.ts
|
|
50330
|
+
var joinFrames, matchingReviewClock, timelineJoins, spreadFrames3, spanFrames2, same4, frameEvidence, short2, rebind, buildReview, withVerdicts;
|
|
50331
|
+
var init_review3 = __esm({
|
|
50332
|
+
"src/video/replication/review.ts"() {
|
|
50333
|
+
"use strict";
|
|
50334
|
+
init_revision();
|
|
50335
|
+
joinFrames = (segments2, fps) => {
|
|
50336
|
+
const offset = Math.max(1, Math.round(fps / 4));
|
|
50337
|
+
return segments2.slice(1).map((next, index) => {
|
|
50338
|
+
const before = segments2[index];
|
|
50339
|
+
const start = next.transition?.a ?? next.start;
|
|
50340
|
+
const end = start + (next.transition?.frames ?? 0);
|
|
50341
|
+
return {
|
|
50342
|
+
at: next.start,
|
|
50343
|
+
frames: [.../* @__PURE__ */ new Set([
|
|
50344
|
+
Math.max(before.start, start - offset),
|
|
50345
|
+
Math.max(before.start, start - 1),
|
|
50346
|
+
...end > start ? [Math.floor((start + end - 1) / 2)] : [],
|
|
50347
|
+
Math.min(next.end - 1, end),
|
|
50348
|
+
Math.min(next.end - 1, end + offset - 1)
|
|
50349
|
+
])].sort((a, b) => a - b)
|
|
50350
|
+
};
|
|
50351
|
+
});
|
|
50352
|
+
};
|
|
50353
|
+
matchingReviewClock = (clock4, video) => clock4.frames === video.frames && Math.abs(clock4.frames / clock4.fps - video.frames / video.fps) * clock4.fps < 0.25;
|
|
50354
|
+
timelineJoins = (r, extra2 = []) => {
|
|
50355
|
+
const joins = new Map(joinFrames(r.segments, r.canvas.fps).map((join3) => [join3.at, join3]));
|
|
50356
|
+
const boundaries = [...extra2, ...r.items.filter((item2) => item2.type === "image" || item2.type === "video").flatMap((item2) => [item2.start, item2.end])];
|
|
50357
|
+
const offset = Math.max(1, Math.round(r.canvas.fps / 4));
|
|
50358
|
+
for (const at7 of boundaries) {
|
|
50359
|
+
if (at7 <= 0 || at7 >= r.frames || joins.has(at7)) continue;
|
|
50360
|
+
joins.set(at7, { at: at7, frames: [.../* @__PURE__ */ new Set([Math.max(0, at7 - offset), at7 - 1, at7, Math.min(r.frames - 1, at7 + offset - 1)])] });
|
|
50361
|
+
}
|
|
50362
|
+
return [...joins.values()].sort((a, b) => a.at - b.at);
|
|
50363
|
+
};
|
|
50364
|
+
spreadFrames3 = (total2, n) => [...new Set(Array.from({ length: Math.min(n, total2) }, (_, k) => Math.floor((2 * k + 1) * total2 / (2 * Math.min(n, total2)))))];
|
|
50365
|
+
spanFrames2 = (span2, total2) => {
|
|
50366
|
+
const last = Math.max(0, Math.min(span2[1], total2) - 1), first = Math.min(span2[0], last);
|
|
50367
|
+
const picked2 = [.../* @__PURE__ */ new Set([first, Math.floor((first + last) / 2), last])];
|
|
50368
|
+
if (picked2.length < 2 && total2 > 1) picked2.push(first > 0 ? first - 1 : first + 1);
|
|
50369
|
+
return picked2.sort((a, b) => a - b);
|
|
50370
|
+
};
|
|
50371
|
+
same4 = (a, b) => !!a && !!b && a.toLowerCase() === b.toLowerCase();
|
|
50372
|
+
frameEvidence = (v, frame2, what) => ({ kind: "observed", detail: "Frame " + frame2 + " of the final video: " + what, file: v.file, sha256: v.fingerprint, media: "video", frame: frame2 });
|
|
50373
|
+
short2 = (s) => s.length > 90 ? s.slice(0, 89) + "\u2026" : s;
|
|
50374
|
+
rebind = (old, bound, v, oldVideo, changed2) => {
|
|
50375
|
+
const ofVideo = (e) => same4(e.sha256, oldVideo) || same4(e.sha256, v.fingerprint) || e.file === v.file;
|
|
50376
|
+
const kept3 = (old?.evidence ?? []).filter((e) => !changed2 || !ofVideo(e));
|
|
50377
|
+
const key2 = (e) => [e.file, e.sha256, e.frame, JSON.stringify(e.at)].join("|");
|
|
50378
|
+
const seen = new Set(kept3.map(key2));
|
|
50379
|
+
return { status: changed2 ? "pending" : old?.status ?? "pending", evidence: [...kept3, ...bound.filter((e) => !seen.has(key2(e)))] };
|
|
50380
|
+
};
|
|
50381
|
+
buildReview = (o) => {
|
|
50382
|
+
const { contract: c, old, video: v } = o;
|
|
50383
|
+
const revision = sourceRevision(c);
|
|
50384
|
+
const changed2 = !!old && (!same4(old.artifactFingerprint, v.fingerprint) || !same4(old.sourceRevision, revision));
|
|
50385
|
+
const seconds8 = Math.round(v.frames / v.fps * 1e3) / 1e3;
|
|
50386
|
+
const audio = rebind(old?.audio, [{ kind: "observed", detail: "The sound of the final video, all " + seconds8 + " s: its voices, music and effects against the reference.", file: v.file, sha256: v.fingerprint, media: "video", at: [0, seconds8] }], v, old?.artifactFingerprint, changed2);
|
|
50387
|
+
const visualFrames = o.visual.map((frame2) => frameEvidence(v, frame2, "its medium, finish and layout against the reference."));
|
|
50388
|
+
const continuity = (o.joins ?? []).flatMap((join3) => join3.frames.map((frame2) => frameEvidence(v, frame2, "the continuity of the cut or transition at frame " + join3.at + ".")));
|
|
50389
|
+
const visual = rebind(old?.visual, [...visualFrames, ...continuity], v, old?.artifactFingerprint, changed2);
|
|
50390
|
+
const joins = (o.joins ?? []).map((join3) => ({
|
|
50391
|
+
at: join3.at,
|
|
50392
|
+
...rebind(old?.joins?.find((item2) => item2.at === join3.at), [
|
|
50393
|
+
...join3.frames.map((frame2) => frameEvidence(v, frame2, "pose, action phase, framing, camera direction and product state across join " + join3.at + ".")),
|
|
50394
|
+
{
|
|
50395
|
+
kind: "observed",
|
|
50396
|
+
detail: "Watch and listen at normal speed across join " + join3.at + ": action, speech, speaker timbre and ambience.",
|
|
50397
|
+
file: v.file,
|
|
50398
|
+
sha256: v.fingerprint,
|
|
50399
|
+
media: "video",
|
|
50400
|
+
at: [Math.max(0, join3.at / v.fps - 1.25), Math.min(v.frames / v.fps, join3.at / v.fps + 1.25)]
|
|
50401
|
+
}
|
|
50402
|
+
], v, old?.artifactFingerprint, changed2)
|
|
50403
|
+
}));
|
|
50404
|
+
const missing4 = [];
|
|
50405
|
+
const events = c.events.map((e) => {
|
|
50406
|
+
const planned = o.plan?.events.find((p) => p.id === e.id);
|
|
50407
|
+
const frames = o.events[e.id] ?? (planned ? spanFrames2(planned.span, v.frames) : void 0);
|
|
50408
|
+
if (!frames) missing4.push(e.id);
|
|
50409
|
+
const names = ["lead-in", "middle", "resolved state"];
|
|
50410
|
+
const bound = (frames ?? []).map((f, k, all) => frameEvidence(v, f, (all.length === 3 ? names[k] : "a state") + ' of "' + short2(e.description) + '" (' + e.id + ")."));
|
|
50411
|
+
return { id: e.id, ...rebind(old?.events?.find((x2) => x2.id === e.id), bound, v, old?.artifactFingerprint, changed2), frames: frames ?? [] };
|
|
50412
|
+
});
|
|
50413
|
+
const review4 = {
|
|
50414
|
+
sourceFingerprint: c.source.fingerprint,
|
|
50415
|
+
sourceRevision: revision,
|
|
50416
|
+
production: "rendered",
|
|
50417
|
+
artifactFingerprint: v.fingerprint,
|
|
50418
|
+
target: { fps: v.fps, frames: v.frames },
|
|
50419
|
+
audio,
|
|
50420
|
+
visual,
|
|
50421
|
+
...o.joins !== void 0 ? { joins } : {},
|
|
50422
|
+
events: events.map(({ frames: _frames, ...finding }) => finding),
|
|
50423
|
+
...old?.audioUses ? { audioUses: old.audioUses } : o.audioUses ? { audioUses: o.audioUses } : {}
|
|
50424
|
+
};
|
|
50425
|
+
return { review: review4, changed: changed2, missing: missing4, frames: [{ name: "audio", frames: [] }, { name: "visual", frames: o.visual }, ...joins.map((join3) => ({ name: "join-" + join3.at, frames: [] })), ...events.map((e) => ({ name: e.id, frames: e.frames }))] };
|
|
50426
|
+
};
|
|
50427
|
+
withVerdicts = (r, passed, failed4) => {
|
|
50428
|
+
const names = /* @__PURE__ */ new Set(["audio", "visual", ...(r.events ?? []).map((e) => e.id), ...(r.joins ?? []).map((join3) => "join-" + join3.at)]);
|
|
50429
|
+
const unknown = [...passed, ...failed4].filter((n) => !names.has(n));
|
|
50430
|
+
const status2 = (name, s) => passed.includes(name) ? "passed" : failed4.includes(name) ? "failed" : s;
|
|
50431
|
+
return {
|
|
50432
|
+
unknown,
|
|
50433
|
+
review: {
|
|
50434
|
+
...r,
|
|
50435
|
+
...r.audio ? { audio: { ...r.audio, status: status2("audio", r.audio.status) } } : {},
|
|
50436
|
+
...r.visual ? { visual: { ...r.visual, status: status2("visual", r.visual.status) } } : {},
|
|
50437
|
+
...r.joins ? { joins: r.joins.map((join3) => ({ ...join3, status: status2("join-" + join3.at, join3.status) })) } : {},
|
|
50438
|
+
...r.events ? { events: r.events.map((e) => ({ ...e, status: status2(e.id, e.status) })) } : {}
|
|
50439
|
+
}
|
|
50440
|
+
};
|
|
50441
|
+
};
|
|
50442
|
+
}
|
|
50443
|
+
});
|
|
50444
|
+
|
|
50247
50445
|
// src/video/replication/source-clock.ts
|
|
50248
50446
|
var sourceClockOf, inspectSourceClock;
|
|
50249
50447
|
var init_source_clock = __esm({
|
|
@@ -50536,7 +50734,7 @@ var init_books = __esm({
|
|
|
50536
50734
|
...list7.filter((x2) => x2.file !== e.file || x2.sha256 === e.sha256 && (x2.frame !== e.frame || JSON.stringify(x2.at) !== JSON.stringify(e.at))),
|
|
50537
50735
|
e
|
|
50538
50736
|
];
|
|
50539
|
-
PLACES = "audio, visual, inventory, music, scope, event:<id> (replication.json); plan:visual, plan:event:<id> (replication.plan.json); review:audio, review:visual, review:event:<id> (replication.review.json)";
|
|
50737
|
+
PLACES = "audio, visual, inventory, music, scope, event:<id> (replication.json); plan:visual, plan:event:<id> (replication.plan.json); review:audio, review:visual, review:join-<frame>, review:event:<id> (replication.review.json)";
|
|
50540
50738
|
object5 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
50541
50739
|
list6 = (v) => Array.isArray(v) ? v : [];
|
|
50542
50740
|
eventIn = (events, id2, file) => {
|
|
@@ -50547,6 +50745,12 @@ var init_books = __esm({
|
|
|
50547
50745
|
};
|
|
50548
50746
|
placeOf3 = (data, where3) => {
|
|
50549
50747
|
const [file, rest] = where3.startsWith("plan:") ? [PLAN_FILE2, where3.slice(5)] : where3.startsWith("review:") ? [REVIEW_FILE, where3.slice(7)] : [REPLICATION_FILE, where3];
|
|
50748
|
+
if (file === REVIEW_FILE && rest.startsWith("join-")) {
|
|
50749
|
+
const joins = Array.isArray(data.joins) ? data.joins.filter(object5) : [];
|
|
50750
|
+
const holder = joins.find((join3) => "join-" + join3.at === rest);
|
|
50751
|
+
if (!holder) throw new BooksError("This cut has no bound review. Run replication review and inspect its join preview first.");
|
|
50752
|
+
return { holder, key: "evidence" };
|
|
50753
|
+
}
|
|
50550
50754
|
if (rest.startsWith("event:")) {
|
|
50551
50755
|
if (file === REVIEW_FILE) {
|
|
50552
50756
|
const events = Array.isArray(data.events) ? data.events : data.events = [];
|
|
@@ -50637,75 +50841,6 @@ var init_books = __esm({
|
|
|
50637
50841
|
}
|
|
50638
50842
|
});
|
|
50639
50843
|
|
|
50640
|
-
// src/video/replication/review.ts
|
|
50641
|
-
var spreadFrames3, spanFrames2, same4, frameEvidence, short2, rebind, buildReview, withVerdicts;
|
|
50642
|
-
var init_review3 = __esm({
|
|
50643
|
-
"src/video/replication/review.ts"() {
|
|
50644
|
-
"use strict";
|
|
50645
|
-
init_revision();
|
|
50646
|
-
spreadFrames3 = (total2, n) => [...new Set(Array.from({ length: Math.min(n, total2) }, (_, k) => Math.floor((2 * k + 1) * total2 / (2 * Math.min(n, total2)))))];
|
|
50647
|
-
spanFrames2 = (span2, total2) => {
|
|
50648
|
-
const last = Math.max(0, Math.min(span2[1], total2) - 1), first = Math.min(span2[0], last);
|
|
50649
|
-
const picked2 = [.../* @__PURE__ */ new Set([first, Math.floor((first + last) / 2), last])];
|
|
50650
|
-
if (picked2.length < 2 && total2 > 1) picked2.push(first > 0 ? first - 1 : first + 1);
|
|
50651
|
-
return picked2.sort((a, b) => a - b);
|
|
50652
|
-
};
|
|
50653
|
-
same4 = (a, b) => !!a && !!b && a.toLowerCase() === b.toLowerCase();
|
|
50654
|
-
frameEvidence = (v, frame2, what) => ({ kind: "observed", detail: "Frame " + frame2 + " of the final video: " + what, file: v.file, sha256: v.fingerprint, media: "video", frame: frame2 });
|
|
50655
|
-
short2 = (s) => s.length > 90 ? s.slice(0, 89) + "\u2026" : s;
|
|
50656
|
-
rebind = (old, bound, v, oldVideo, changed2) => {
|
|
50657
|
-
const ofVideo = (e) => same4(e.sha256, oldVideo) || same4(e.sha256, v.fingerprint) || e.file === v.file;
|
|
50658
|
-
const kept3 = (old?.evidence ?? []).filter((e) => !changed2 || !ofVideo(e));
|
|
50659
|
-
const key2 = (e) => [e.file, e.sha256, e.frame, JSON.stringify(e.at)].join("|");
|
|
50660
|
-
const seen = new Set(kept3.map(key2));
|
|
50661
|
-
return { status: changed2 ? "pending" : old?.status ?? "pending", evidence: [...kept3, ...bound.filter((e) => !seen.has(key2(e)))] };
|
|
50662
|
-
};
|
|
50663
|
-
buildReview = (o) => {
|
|
50664
|
-
const { contract: c, old, video: v } = o;
|
|
50665
|
-
const revision = sourceRevision(c);
|
|
50666
|
-
const changed2 = !!old && (!same4(old.artifactFingerprint, v.fingerprint) || !same4(old.sourceRevision, revision));
|
|
50667
|
-
const seconds8 = Math.round(v.frames / v.fps * 1e3) / 1e3;
|
|
50668
|
-
const audio = rebind(old?.audio, [{ kind: "observed", detail: "The sound of the final video, all " + seconds8 + " s: its voices, music and effects against the reference.", file: v.file, sha256: v.fingerprint, media: "video", at: [0, seconds8] }], v, old?.artifactFingerprint, changed2);
|
|
50669
|
-
const visual = rebind(old?.visual, o.visual.map((f) => frameEvidence(v, f, "its medium, finish and layout against the reference.")), v, old?.artifactFingerprint, changed2);
|
|
50670
|
-
const missing3 = [];
|
|
50671
|
-
const events = c.events.map((e) => {
|
|
50672
|
-
const planned = o.plan?.events.find((p) => p.id === e.id);
|
|
50673
|
-
const frames = o.events[e.id] ?? (planned ? spanFrames2(planned.span, v.frames) : void 0);
|
|
50674
|
-
if (!frames) missing3.push(e.id);
|
|
50675
|
-
const names = ["lead-in", "middle", "resolved state"];
|
|
50676
|
-
const bound = (frames ?? []).map((f, k, all) => frameEvidence(v, f, (all.length === 3 ? names[k] : "a state") + ' of "' + short2(e.description) + '" (' + e.id + ")."));
|
|
50677
|
-
return { id: e.id, ...rebind(old?.events?.find((x2) => x2.id === e.id), bound, v, old?.artifactFingerprint, changed2), frames: frames ?? [] };
|
|
50678
|
-
});
|
|
50679
|
-
const review4 = {
|
|
50680
|
-
sourceFingerprint: c.source.fingerprint,
|
|
50681
|
-
sourceRevision: revision,
|
|
50682
|
-
production: "rendered",
|
|
50683
|
-
artifactFingerprint: v.fingerprint,
|
|
50684
|
-
target: { fps: v.fps, frames: v.frames },
|
|
50685
|
-
audio,
|
|
50686
|
-
visual,
|
|
50687
|
-
events: events.map(({ frames: _frames, ...finding }) => finding),
|
|
50688
|
-
...old?.audioUses ? { audioUses: old.audioUses } : o.audioUses ? { audioUses: o.audioUses } : {}
|
|
50689
|
-
};
|
|
50690
|
-
return { review: review4, changed: changed2, missing: missing3, frames: [{ name: "audio", frames: [] }, { name: "visual", frames: o.visual }, ...events.map((e) => ({ name: e.id, frames: e.frames }))] };
|
|
50691
|
-
};
|
|
50692
|
-
withVerdicts = (r, passed, failed4) => {
|
|
50693
|
-
const names = /* @__PURE__ */ new Set(["audio", "visual", ...(r.events ?? []).map((e) => e.id)]);
|
|
50694
|
-
const unknown = [...passed, ...failed4].filter((n) => !names.has(n));
|
|
50695
|
-
const status2 = (name, s) => passed.includes(name) ? "passed" : failed4.includes(name) ? "failed" : s;
|
|
50696
|
-
return {
|
|
50697
|
-
unknown,
|
|
50698
|
-
review: {
|
|
50699
|
-
...r,
|
|
50700
|
-
...r.audio ? { audio: { ...r.audio, status: status2("audio", r.audio.status) } } : {},
|
|
50701
|
-
...r.visual ? { visual: { ...r.visual, status: status2("visual", r.visual.status) } } : {},
|
|
50702
|
-
...r.events ? { events: r.events.map((e) => ({ ...e, status: status2(e.id, e.status) })) } : {}
|
|
50703
|
-
}
|
|
50704
|
-
};
|
|
50705
|
-
};
|
|
50706
|
-
}
|
|
50707
|
-
});
|
|
50708
|
-
|
|
50709
50844
|
// src/video/commands/replication-books.ts
|
|
50710
50845
|
var DIR7, secondsOf3, books, leftIn, bindEvents, evidence2, framesOf3, eventFrames, readJson7, oldReview, lookFrames, planOf3, audioUsesOf, namesOf2, review3, bookCommands;
|
|
50711
50846
|
var init_replication_books = __esm({
|
|
@@ -50801,12 +50936,16 @@ var init_replication_books = __esm({
|
|
|
50801
50936
|
if (!parsed.review) throw new VideoCommandError(REVIEW_FILE + " in " + dir + " is not a review (" + (parsed.problems[0]?.at ?? "") + ": " + (parsed.problems[0]?.message ?? "unreadable") + "). Correct it, or delete it to start the review again.");
|
|
50802
50937
|
return parsed.review;
|
|
50803
50938
|
};
|
|
50804
|
-
lookFrames = async (rt, dir, video) => {
|
|
50805
|
-
|
|
50806
|
-
const
|
|
50807
|
-
|
|
50808
|
-
|
|
50809
|
-
|
|
50939
|
+
lookFrames = async (rt, dir, video, extra2) => {
|
|
50940
|
+
if (!await rt.fs.stat(rt.path.join(dir, "video.json"))) return { overview: spreadFrames3(video.frames, 6), joins: void 0 };
|
|
50941
|
+
const built = await buildPage(rt, dir);
|
|
50942
|
+
const clock4 = built.resolved;
|
|
50943
|
+
if (!clock4 || !matchingReviewClock({ frames: clock4.frames, fps: clock4.canvas.fps }, video))
|
|
50944
|
+
throw new VideoCommandError("The project and artifact clocks cannot be mapped safely. Render the current project before reviewing its cuts; no continuity checks were skipped.");
|
|
50945
|
+
if (extra2.some((frame2) => frame2 <= 0 || frame2 >= video.frames)) throw new VideoCommandError("--join must lie strictly inside the final artifact.");
|
|
50946
|
+
const mids = clock4.segments.map((s) => Math.floor((s.start + s.end - 1) / 2));
|
|
50947
|
+
const overview = mids.length <= 8 ? mids : spreadFrames3(mids.length, 8).map((k) => mids[k]);
|
|
50948
|
+
return { overview, joins: timelineJoins(clock4, extra2) };
|
|
50810
50949
|
};
|
|
50811
50950
|
planOf3 = async (rt, dir) => {
|
|
50812
50951
|
const parsed = planSchema.safeParse(await readJson7(rt, rt.path.join(dir, PLAN_FILE2)));
|
|
@@ -50820,6 +50959,7 @@ var init_replication_books = __esm({
|
|
|
50820
50959
|
{ flag: "--artifact", required: true, help: "the final rendered MP4" },
|
|
50821
50960
|
{ flag: "--frames", help: "frames of the video for the look (default: the middle of each shot, at most 8)" },
|
|
50822
50961
|
{ flag: "--event", kind: "append", metavar: "ID=F,F", help: "frames for one event, when the plan has no span for it or others are wanted, for example --event hook=12,30,48" },
|
|
50962
|
+
{ flag: "--join", kind: "append", help: "an internal generated-shot cut at an output frame; joins and visual-layer boundaries are included automatically" },
|
|
50823
50963
|
{ flag: "--passed", help: "the findings you looked at (listened to) that hold: audio, visual and event ids, separated by commas" },
|
|
50824
50964
|
{ flag: "--failed", help: "the findings that do not hold, the same way" },
|
|
50825
50965
|
{ flag: "--sheets", help: "where the sheets of the frames go (default <dir>/review/replication)" }
|
|
@@ -50834,34 +50974,76 @@ var init_replication_books = __esm({
|
|
|
50834
50974
|
const video = { file: bound.evidence.file ?? "", fingerprint: bound.evidence.sha256 ?? "", fps: p.fps, frames: p.frames };
|
|
50835
50975
|
const old = await oldReview(rt, dir);
|
|
50836
50976
|
const typed = args.string("frames");
|
|
50977
|
+
const { overview, joins } = await lookFrames(rt, dir, video, [...(old?.artifactFingerprint === video.fingerprint ? old.joins ?? [] : []).map((join3) => join3.at), ...args.list("join").flatMap((value) => framesOf3(value, "--join"))]);
|
|
50837
50978
|
const built = buildReview({
|
|
50838
50979
|
contract: read2.contract,
|
|
50839
50980
|
...old ? { old } : {},
|
|
50840
50981
|
...await planOf3(rt, dir).then((plan4) => plan4 ? { plan: plan4 } : {}),
|
|
50841
50982
|
video,
|
|
50842
|
-
visual: typed ? framesOf3(typed, "--frames") :
|
|
50983
|
+
visual: typed ? framesOf3(typed, "--frames") : overview,
|
|
50984
|
+
...joins ? { joins } : {},
|
|
50843
50985
|
events: eventFrames(args.list("event")),
|
|
50844
50986
|
...await audioUsesOf(rt, dir).then((u) => u ? { audioUses: u } : {})
|
|
50845
50987
|
});
|
|
50846
50988
|
const passed = namesOf2(args.string("passed")), failed4 = namesOf2(args.string("failed"));
|
|
50847
50989
|
const judged = passed.length + failed4.length > 0;
|
|
50848
|
-
if (judged && (typed || args.list("event").length)) throw new VideoCommandError("Give the verdicts in a call of their own, without --frames or --event: a frame bound in the same call has not been looked at yet. Nothing was written.");
|
|
50990
|
+
if (judged && (typed || args.list("event").length || args.list("join").length)) throw new VideoCommandError("Give the verdicts in a call of their own, without --frames or --event: a frame bound in the same call has not been looked at yet. Nothing was written.");
|
|
50849
50991
|
if (judged && (!old || built.changed)) throw new VideoCommandError("This video (or the source reading) is new to the review: run replication review without --passed and --failed, open its sheets and listen to it, then give the verdicts in another call. Nothing was written.");
|
|
50992
|
+
if (passed.includes("visual") && joins?.some(({ at: at7, frames }) => frames.some((frame2) => !old?.joins?.find((join3) => join3.at === at7)?.evidence.some((e) => e.sha256 === video.fingerprint && e.frame === frame2)))) {
|
|
50993
|
+
throw new VideoCommandError("The visual review is missing join samples for this timeline. Run replication review without verdicts, then inspect the joins and record the verdict.");
|
|
50994
|
+
}
|
|
50995
|
+
for (const name of [...passed, ...failed4].filter((name2) => name2.startsWith("join-"))) {
|
|
50996
|
+
if (!old?.joins?.some((join3) => "join-" + join3.at === name))
|
|
50997
|
+
throw new VideoCommandError("This cut is new to the review. Generate and watch its join preview before recording a verdict.");
|
|
50998
|
+
}
|
|
50850
50999
|
const verdicts = withVerdicts(built.review, passed, failed4);
|
|
50851
51000
|
if (verdicts.unknown.length) throw new VideoCommandError("The review has no finding " + verdicts.unknown.join(", ") + "; its findings are audio, visual and the events " + read2.contract.events.map((e) => e.id).join(", ") + ". Nothing was written.");
|
|
50852
|
-
await rt.fs.writeFile(rt.path.join(dir, REVIEW_FILE), JSON.stringify(verdicts.review, null, 2) + "\n");
|
|
50853
51001
|
const sheetsDir = userPath(rt, args.string("sheets") ?? rt.path.join(dir, "review", "replication"));
|
|
50854
51002
|
const sheetOf = (name) => (name === "visual" ? "visual" : "event-" + name.replace(/[^a-z0-9_-]/gi, "_")) + ".jpg";
|
|
50855
|
-
|
|
50856
|
-
|
|
51003
|
+
const joinSheets = (joins ?? []).map(({ at: at7, frames }) => ({ at: at7, frames, file: "join-" + at7 + ".jpg" }));
|
|
51004
|
+
if (!judged) {
|
|
51005
|
+
const sheets = built.frames.filter((f) => f.frames.length).map(({ name, frames }) => ({ file: sheetOf(name), frames }));
|
|
51006
|
+
await writeSheets2(rt, file, [...sheets, ...joinSheets], { width: 320, outDir: sheetsDir, probe: p });
|
|
51007
|
+
for (const join3 of joinSheets) {
|
|
51008
|
+
const start = Math.max(0, join3.at / video.fps - 1.25);
|
|
51009
|
+
const end = Math.min(video.frames / video.fps, join3.at / video.fps + 1.25);
|
|
51010
|
+
await runFfmpegOk(rt, [
|
|
51011
|
+
"-y",
|
|
51012
|
+
"-ss",
|
|
51013
|
+
String(start),
|
|
51014
|
+
"-i",
|
|
51015
|
+
file,
|
|
51016
|
+
"-t",
|
|
51017
|
+
String(end - start),
|
|
51018
|
+
"-map",
|
|
51019
|
+
"0:v:0",
|
|
51020
|
+
"-map",
|
|
51021
|
+
"0:a?",
|
|
51022
|
+
"-c:v",
|
|
51023
|
+
"libx264",
|
|
51024
|
+
"-preset",
|
|
51025
|
+
"veryfast",
|
|
51026
|
+
"-crf",
|
|
51027
|
+
"20",
|
|
51028
|
+
"-c:a",
|
|
51029
|
+
"aac",
|
|
51030
|
+
"-movflags",
|
|
51031
|
+
"+faststart",
|
|
51032
|
+
rt.path.join(sheetsDir, "join-" + join3.at + ".mp4")
|
|
51033
|
+
]);
|
|
51034
|
+
}
|
|
51035
|
+
}
|
|
51036
|
+
await rt.fs.writeFile(rt.path.join(dir, REVIEW_FILE), JSON.stringify(verdicts.review, null, 2) + "\n");
|
|
51037
|
+
const statusOf2 = (name) => (name === "audio" ? verdicts.review.audio?.status : name === "visual" ? verdicts.review.visual?.status : name.startsWith("join-") ? verdicts.review.joins?.find((join3) => "join-" + join3.at === name)?.status : verdicts.review.events?.find((e) => e.id === name)?.status) ?? "pending";
|
|
50857
51038
|
printJson(rt, {
|
|
50858
51039
|
ok: built.missing.length === 0,
|
|
50859
51040
|
review: rt.path.join(dir, REVIEW_FILE),
|
|
50860
51041
|
artifact: video,
|
|
50861
51042
|
changed: built.changed,
|
|
51043
|
+
...!judged && joinSheets.length ? { joins: joinSheets.map(({ at: at7, frames, file: file2 }) => ({ at: at7, frames, sheet: rt.path.join(sheetsDir, file2), preview: rt.path.join(sheetsDir, "join-" + at7 + ".mp4") })) } : {},
|
|
50862
51044
|
findings: built.frames.map((f) => ({ name: f.name, status: statusOf2(f.name), frames: f.frames, ...!judged && f.frames.length ? { sheet: rt.path.join(sheetsDir, sheetOf(f.name)) } : {} })),
|
|
50863
51045
|
...built.missing.length ? { missing: built.missing, fix: "The plan has no target span for these events: map them in " + PLAN_FILE2 + ", or give their frames with --event <id>=F,F,F." } : {},
|
|
50864
|
-
next: judged ? "popost video replication check " + dir + " --reference <the reference> --artifact " + args.req("artifact") : "Open each sheet and listen
|
|
51046
|
+
next: judged ? "popost video replication check " + dir + " --reference <the reference> --artifact " + args.req("artifact") : "Open each sheet, watch the join windows and listen through the whole video. Then run replication review again on the same video with --passed and --failed (names: audio, visual, join-<frame>, event ids); add what you saw elsewhere with popost video replication evidence " + dir + " --file \u2026 --add review:<name>."
|
|
50865
51047
|
});
|
|
50866
51048
|
return built.missing.length ? 2 : 0;
|
|
50867
51049
|
});
|
|
@@ -50877,6 +51059,7 @@ var init_replication = __esm({
|
|
|
50877
51059
|
init_util();
|
|
50878
51060
|
init_ffmpeg();
|
|
50879
51061
|
init_compile();
|
|
51062
|
+
init_provenance();
|
|
50880
51063
|
init_contract();
|
|
50881
51064
|
init_check4();
|
|
50882
51065
|
init_io2();
|
|
@@ -50884,6 +51067,7 @@ var init_replication = __esm({
|
|
|
50884
51067
|
init_pairs();
|
|
50885
51068
|
init_motion_bundle();
|
|
50886
51069
|
init_audio_provenance();
|
|
51070
|
+
init_review3();
|
|
50887
51071
|
init_revision();
|
|
50888
51072
|
init_retiming();
|
|
50889
51073
|
init_speech_observed();
|
|
@@ -50996,7 +51180,15 @@ var init_replication = __esm({
|
|
|
50996
51180
|
source: event2.span,
|
|
50997
51181
|
target: event2.span.map((frame2) => clock4.map ? clock4.map(frame2) : Math.round((frame2 - (c.scope?.span[0] ?? 0)) / c.source.fps * r.canvas.fps))
|
|
50998
51182
|
})) : void 0;
|
|
50999
|
-
const
|
|
51183
|
+
const footageUsed = /* @__PURE__ */ new Set([
|
|
51184
|
+
...r.segments.flatMap((s) => s.base.kind === "video" ? [s.base.play.material] : []),
|
|
51185
|
+
...r.items.flatMap((i) => i.play ? [i.play.material] : [])
|
|
51186
|
+
]);
|
|
51187
|
+
const materialSources = await Promise.all([...footageUsed].flatMap((material3) => {
|
|
51188
|
+
const file = r.footage?.[material3]?.src;
|
|
51189
|
+
return file ? [readMaterialReceipt(rt, rt.path.resolve(dir, file)).then((receipt) => receipt ? { material: material3, file, receipt: materialReceiptFile(file), ...receipt } : { material: material3, file, provider: "unknown" })] : [];
|
|
51190
|
+
}));
|
|
51191
|
+
const data = { ...events ? { events } : {}, canvas: r.canvas, frames: r.frames, segments: r.segments, items: r.items, audio: r.audio, speech: r.speech, footage: r.footage, materialSources, words: r.words ?? [] };
|
|
51000
51192
|
if (args.string("out")) await writeJson2(rt, userPath(rt, args.req("out")), data);
|
|
51001
51193
|
return report2(rt, [...built.problems, ...source2.problems, ...clock4.problems], { timeline: data });
|
|
51002
51194
|
});
|
|
@@ -51035,7 +51227,7 @@ var init_replication = __esm({
|
|
|
51035
51227
|
boundFindings = (c, review4, actual) => {
|
|
51036
51228
|
const fingerprint = actual.fingerprint;
|
|
51037
51229
|
const problems2 = [];
|
|
51038
|
-
for (const [name, finding] of [["audio", review4.audio], ["visual", review4.visual], ...(review4.events ?? []).map((e) => [e.id, e])]) {
|
|
51230
|
+
for (const [name, finding] of [["audio", review4.audio], ["visual", review4.visual], ...(review4.events ?? []).map((e) => [e.id, e]), ...(review4.joins ?? []).map((join3) => ["join-" + join3.at, join3])]) {
|
|
51039
51231
|
if (finding?.status !== "passed") continue;
|
|
51040
51232
|
for (const e of finding.evidence.filter((e2) => e2.sha256 === fingerprint)) {
|
|
51041
51233
|
if (e.frame !== void 0 && (e.frame < 0 || e.frame >= actual.frames) || e.at && (e.at[0] < 0 || e.at[1] > actual.frames / actual.fps))
|
|
@@ -51097,6 +51289,15 @@ var init_replication = __esm({
|
|
|
51097
51289
|
const parsed = parseReplicationReview(input);
|
|
51098
51290
|
problems2.push(...parsed.problems, ...await evidenceProblems(rt, dir, parsed.review));
|
|
51099
51291
|
if (parsed.review) problems2.push(...boundFindings(c, parsed.review, actual));
|
|
51292
|
+
if (built.resolved) {
|
|
51293
|
+
const clock4 = built.resolved;
|
|
51294
|
+
if (!matchingReviewClock({ frames: clock4.frames, fps: clock4.canvas.fps }, actual))
|
|
51295
|
+
problems2.push(error("replication.review.joins", "The project and final artifact clocks cannot be mapped safely.", "Render and review the current project."));
|
|
51296
|
+
for (const join3 of timelineJoins(clock4)) {
|
|
51297
|
+
if (!parsed.review?.joins?.some((item2) => item2.at === join3.at))
|
|
51298
|
+
problems2.push(error("replication.review.joins." + join3.at, "This timeline or visual-layer cut has no independent continuity review.", "Run replication review on the actual final artifact, watch its join preview and record join-" + join3.at + "."));
|
|
51299
|
+
}
|
|
51300
|
+
}
|
|
51100
51301
|
const assessment = assessReplication(c, input, actual);
|
|
51101
51302
|
problems2.push(...assessment.problems);
|
|
51102
51303
|
const failed4 = problems2.some((p) => p.level === "error"), accepted = !failed4 && assessment.requirementsMet === true;
|
|
@@ -51239,12 +51440,592 @@ var init_video = __esm({
|
|
|
51239
51440
|
}
|
|
51240
51441
|
});
|
|
51241
51442
|
|
|
51443
|
+
// src/feedback/clean.ts
|
|
51444
|
+
var REDACTED, BINARY_MIN_CHARS, SECRET_WORDS, KEY_QUALIFIERS, VARIABLE4, UUID, wordsOf, isSecretName, isSecretValue, TOKEN_PATTERNS, BEARER, URL_PARAM, ASSIGNMENT, INLINE_DATA_URL, DATA_URL, BASE64_ONLY, kb, omitted, sniffBase64, escapeRegExp3, environmentSecrets, createCleaner, cleanJsonl;
|
|
51445
|
+
var init_clean2 = __esm({
|
|
51446
|
+
"src/feedback/clean.ts"() {
|
|
51447
|
+
"use strict";
|
|
51448
|
+
REDACTED = "[redacted]";
|
|
51449
|
+
BINARY_MIN_CHARS = 1024;
|
|
51450
|
+
SECRET_WORDS = /* @__PURE__ */ new Set(["apikey", "secret", "secrets", "token", "password", "passwd", "pwd", "credential", "credentials"]);
|
|
51451
|
+
KEY_QUALIFIERS = /* @__PURE__ */ new Set(["api", "access", "secret", "private", "client", "auth", "signing", "encryption", "master", "service", "account"]);
|
|
51452
|
+
VARIABLE4 = /^[A-Z][A-Z0-9_]*$/;
|
|
51453
|
+
UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
51454
|
+
wordsOf = (name) => name.replace(/([a-z0-9])([A-Z])/g, "$1 $2").split(/[^A-Za-z0-9]+/).filter(Boolean).map((word2) => word2.toLowerCase());
|
|
51455
|
+
isSecretName = (name) => wordsOf(name).some((word2, i, words) => SECRET_WORDS.has(word2) || (word2 === "key" || word2 === "keys") && i > 0 && KEY_QUALIFIERS.has(words[i - 1]));
|
|
51456
|
+
isSecretValue = (value) => value.length >= 8 && !/\s/.test(value) && !UUID.test(value) && value !== REDACTED && !value.startsWith("$") && !value.includes("process.env") && !value.startsWith("[omitted");
|
|
51457
|
+
TOKEN_PATTERNS = [
|
|
51458
|
+
/-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z0-9 ]*PRIVATE KEY-----/g,
|
|
51459
|
+
/\bpopost_[A-Za-z0-9_-]{43}(?![A-Za-z0-9_-])/g,
|
|
51460
|
+
/\bpat_device_[A-Za-z0-9_-]{43}(?![A-Za-z0-9_-])/g,
|
|
51461
|
+
/\bsk-[A-Za-z0-9_-]{20,}/g,
|
|
51462
|
+
/\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g,
|
|
51463
|
+
/\bgh[pousr]_[A-Za-z0-9]{30,}\b/g,
|
|
51464
|
+
/\bgithub_pat_[A-Za-z0-9_]{40,}\b/g,
|
|
51465
|
+
/\bxox[abposr]-[A-Za-z0-9-]{10,}/g,
|
|
51466
|
+
/\beyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g
|
|
51467
|
+
];
|
|
51468
|
+
BEARER = /\b(Bearer)\s+[A-Za-z0-9._~+/=-]{12,}/gi;
|
|
51469
|
+
URL_PARAM = /([?&](?:X-Amz-Signature|X-Amz-Credential|X-Amz-Security-Token|Signature|sig|token|access_token|api_key|apikey|key)=)[^&\s"'<>#]+/gi;
|
|
51470
|
+
ASSIGNMENT = /(["']?)\b([A-Za-z_][A-Za-z0-9_.-]*)\1(\s*[:=]\s*)(["']?)([^\s"'`,;&<>]+)\4/g;
|
|
51471
|
+
INLINE_DATA_URL = /data:([\w.+/-]+)?(?:;[\w=.+-]+)*;base64,[A-Za-z0-9+/=]{1024,}/g;
|
|
51472
|
+
DATA_URL = /^data:([\w.+/-]+)?[;,]/;
|
|
51473
|
+
BASE64_ONLY = /^[A-Za-z0-9+/=_\-\r\n]+$/;
|
|
51474
|
+
kb = (chars) => Math.max(1, Math.round(chars * 3 / 4 / 1024));
|
|
51475
|
+
omitted = (mime, chars) => `[omitted: ${mime || "binary"} ${kb(chars)} KB]`;
|
|
51476
|
+
sniffBase64 = (data) => {
|
|
51477
|
+
if (data.startsWith("iVBOR")) return "image/png";
|
|
51478
|
+
if (data.startsWith("/9j/")) return "image/jpeg";
|
|
51479
|
+
if (data.startsWith("R0lGOD")) return "image/gif";
|
|
51480
|
+
if (data.startsWith("UklGR")) return "image/webp";
|
|
51481
|
+
return void 0;
|
|
51482
|
+
};
|
|
51483
|
+
escapeRegExp3 = (text13) => text13.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
51484
|
+
environmentSecrets = (env2) => [...new Set(Object.entries(env2).filter(([name, value]) => isSecretName(name) && typeof value === "string" && isSecretValue(value)).map(([, value]) => value))].sort(
|
|
51485
|
+
(a, b) => b.length - a.length
|
|
51486
|
+
);
|
|
51487
|
+
createCleaner = (options = {}) => {
|
|
51488
|
+
const stats = { redactions: 0, omittedImages: 0 };
|
|
51489
|
+
const home = options.homeDir && options.homeDir.length > 1 ? new RegExp(`${escapeRegExp3(options.homeDir.replace(/[\\/]+$/, ""))}(?=[\\\\/"'\\s]|$)`, "g") : null;
|
|
51490
|
+
const secrets = (options.secrets ?? []).filter((value) => value.length >= 8);
|
|
51491
|
+
const redact = (value) => {
|
|
51492
|
+
let out2 = value;
|
|
51493
|
+
for (const secret of secrets)
|
|
51494
|
+
if (out2.includes(secret)) {
|
|
51495
|
+
stats.redactions += out2.split(secret).length - 1;
|
|
51496
|
+
out2 = out2.split(secret).join(REDACTED);
|
|
51497
|
+
}
|
|
51498
|
+
for (const pattern of TOKEN_PATTERNS)
|
|
51499
|
+
out2 = out2.replace(pattern, () => {
|
|
51500
|
+
stats.redactions += 1;
|
|
51501
|
+
return REDACTED;
|
|
51502
|
+
});
|
|
51503
|
+
out2 = out2.replace(BEARER, (_all, word2) => {
|
|
51504
|
+
stats.redactions += 1;
|
|
51505
|
+
return `${word2} ${REDACTED}`;
|
|
51506
|
+
});
|
|
51507
|
+
out2 = out2.replace(URL_PARAM, (_all, name) => {
|
|
51508
|
+
stats.redactions += 1;
|
|
51509
|
+
return name + REDACTED;
|
|
51510
|
+
});
|
|
51511
|
+
return out2.replace(ASSIGNMENT, (all, quote16, name, sep, valueQuote, secret, at7, whole2) => {
|
|
51512
|
+
const call2 = !valueQuote && (/[(){}]/.test(secret) || whole2[at7 + all.length] === "(");
|
|
51513
|
+
if (call2 || !isSecretName(name) || !isSecretValue(secret) || !valueQuote && !VARIABLE4.test(name)) return all;
|
|
51514
|
+
stats.redactions += 1;
|
|
51515
|
+
return `${quote16}${name}${quote16}${sep}${valueQuote}${REDACTED}${valueQuote}`;
|
|
51516
|
+
});
|
|
51517
|
+
};
|
|
51518
|
+
const binary = (value, mime) => {
|
|
51519
|
+
if (value.length <= BINARY_MIN_CHARS) return void 0;
|
|
51520
|
+
const url = DATA_URL.exec(value);
|
|
51521
|
+
if (url) return omitted(url[1], value.length - value.indexOf(",") - 1);
|
|
51522
|
+
if (!BASE64_ONLY.test(value)) return void 0;
|
|
51523
|
+
return omitted(mime ?? sniffBase64(value), value.length);
|
|
51524
|
+
};
|
|
51525
|
+
const text13 = (value, mime) => {
|
|
51526
|
+
const whole2 = binary(value, mime);
|
|
51527
|
+
if (whole2 !== void 0) {
|
|
51528
|
+
stats.omittedImages += 1;
|
|
51529
|
+
return whole2;
|
|
51530
|
+
}
|
|
51531
|
+
const inline = value.replace(INLINE_DATA_URL, (all, type) => {
|
|
51532
|
+
stats.omittedImages += 1;
|
|
51533
|
+
return omitted(type, all.length - all.indexOf(",") - 1);
|
|
51534
|
+
});
|
|
51535
|
+
const clean2 = redact(inline);
|
|
51536
|
+
return home ? clean2.replace(home, "~") : clean2;
|
|
51537
|
+
};
|
|
51538
|
+
const json4 = (value) => {
|
|
51539
|
+
if (typeof value === "string") return text13(value);
|
|
51540
|
+
if (Array.isArray(value)) return value.map(json4);
|
|
51541
|
+
if (value === null || typeof value !== "object") return value;
|
|
51542
|
+
const record2 = value;
|
|
51543
|
+
const mime = [record2.media_type, record2.mediaType, record2.mime_type, record2.mimeType].find((m) => typeof m === "string");
|
|
51544
|
+
return Object.fromEntries(
|
|
51545
|
+
Object.entries(record2).map(([key2, item2]) => {
|
|
51546
|
+
if (typeof item2 === "string" && isSecretName(key2) && isSecretValue(item2)) {
|
|
51547
|
+
stats.redactions += 1;
|
|
51548
|
+
return [key2, REDACTED];
|
|
51549
|
+
}
|
|
51550
|
+
return [key2, typeof item2 === "string" ? text13(item2, mime) : json4(item2)];
|
|
51551
|
+
})
|
|
51552
|
+
);
|
|
51553
|
+
};
|
|
51554
|
+
return { stats, text: (value) => text13(value), json: json4 };
|
|
51555
|
+
};
|
|
51556
|
+
cleanJsonl = (cleaner, raw) => {
|
|
51557
|
+
const out2 = [];
|
|
51558
|
+
let lines2 = 0;
|
|
51559
|
+
for (const line of raw.split("\n")) {
|
|
51560
|
+
if (line.trim() === "") {
|
|
51561
|
+
out2.push(line);
|
|
51562
|
+
continue;
|
|
51563
|
+
}
|
|
51564
|
+
lines2 += 1;
|
|
51565
|
+
let parsed;
|
|
51566
|
+
try {
|
|
51567
|
+
parsed = JSON.parse(line);
|
|
51568
|
+
} catch {
|
|
51569
|
+
out2.push(cleaner.text(line));
|
|
51570
|
+
continue;
|
|
51571
|
+
}
|
|
51572
|
+
out2.push(JSON.stringify(cleaner.json(parsed)));
|
|
51573
|
+
}
|
|
51574
|
+
return { text: out2.join("\n"), lines: lines2 };
|
|
51575
|
+
};
|
|
51576
|
+
}
|
|
51577
|
+
});
|
|
51578
|
+
|
|
51579
|
+
// src/feedback/project-files.ts
|
|
51580
|
+
var MAX_DEPTH2, MAX_LISTED, DOCUMENT_MAX_BYTES, DOCUMENTS_MAX_BYTES, TEXT_EXTENSIONS, SKIPPED_DIRS, PRIVATE_NAME, extensionOf2, listFiles, isDocument, collectProjectFiles;
|
|
51581
|
+
var init_project_files = __esm({
|
|
51582
|
+
"src/feedback/project-files.ts"() {
|
|
51583
|
+
"use strict";
|
|
51584
|
+
init_pyjson();
|
|
51585
|
+
MAX_DEPTH2 = 6;
|
|
51586
|
+
MAX_LISTED = 2e3;
|
|
51587
|
+
DOCUMENT_MAX_BYTES = 512 * 1024;
|
|
51588
|
+
DOCUMENTS_MAX_BYTES = 5 * 1024 * 1024;
|
|
51589
|
+
TEXT_EXTENSIONS = /* @__PURE__ */ new Set([".json", ".md", ".txt", ".html", ".css", ".log", ".yaml", ".yml"]);
|
|
51590
|
+
SKIPPED_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git", ".hg", ".svn", "dist", ".cache", "cache", ".next", ".turbo", "__pycache__", ".venv", "venv", "secrets", ".secrets"]);
|
|
51591
|
+
PRIVATE_NAME = /^\.env|^\.npmrc$|^\.netrc$|(^|[._-])(credentials?|secrets?)([._-]|$)/i;
|
|
51592
|
+
extensionOf2 = (name) => {
|
|
51593
|
+
const dot3 = name.lastIndexOf(".");
|
|
51594
|
+
return dot3 > 0 ? name.slice(dot3).toLowerCase() : "";
|
|
51595
|
+
};
|
|
51596
|
+
listFiles = async (rt, root) => {
|
|
51597
|
+
const found = [];
|
|
51598
|
+
let level = [""];
|
|
51599
|
+
for (let depth = 0; depth <= MAX_DEPTH2 && level.length && found.length <= MAX_LISTED; depth++) {
|
|
51600
|
+
const next = [];
|
|
51601
|
+
for (const rel2 of level) {
|
|
51602
|
+
const names = await rt.fs.readdir(rel2 ? rt.path.join(root, ...rel2.split("/")) : root).catch(() => []);
|
|
51603
|
+
for (const name of [...names].sort(compareCodePoints)) {
|
|
51604
|
+
const path2 = rel2 ? `${rel2}/${name}` : name;
|
|
51605
|
+
const stat = await rt.fs.stat(rt.path.join(root, ...path2.split("/")));
|
|
51606
|
+
if (stat?.isDirectory && !SKIPPED_DIRS.has(name.toLowerCase())) next.push(path2);
|
|
51607
|
+
else if (stat?.isFile) found.push({ path: path2, bytes: stat.size });
|
|
51608
|
+
if (found.length > MAX_LISTED) return found;
|
|
51609
|
+
}
|
|
51610
|
+
}
|
|
51611
|
+
level = next;
|
|
51612
|
+
}
|
|
51613
|
+
return found;
|
|
51614
|
+
};
|
|
51615
|
+
isDocument = (file) => {
|
|
51616
|
+
const name = file.path.split("/").pop() ?? "";
|
|
51617
|
+
return TEXT_EXTENSIONS.has(extensionOf2(name)) && file.bytes <= DOCUMENT_MAX_BYTES && !PRIVATE_NAME.test(name);
|
|
51618
|
+
};
|
|
51619
|
+
collectProjectFiles = async (rt, root, cleaner) => {
|
|
51620
|
+
const listed3 = await listFiles(rt, root);
|
|
51621
|
+
const files = listed3.slice(0, MAX_LISTED);
|
|
51622
|
+
const documents = {};
|
|
51623
|
+
let total2 = 0;
|
|
51624
|
+
for (const file of files.filter(isDocument)) {
|
|
51625
|
+
if (total2 + file.bytes > DOCUMENTS_MAX_BYTES) continue;
|
|
51626
|
+
const text13 = await rt.fs.readText(rt.path.join(root, ...file.path.split("/"))).catch(() => void 0);
|
|
51627
|
+
if (text13 === void 0) continue;
|
|
51628
|
+
documents[file.path] = cleaner.text(text13);
|
|
51629
|
+
total2 += file.bytes;
|
|
51630
|
+
}
|
|
51631
|
+
return { files, documents, listTruncated: listed3.length > MAX_LISTED };
|
|
51632
|
+
};
|
|
51633
|
+
}
|
|
51634
|
+
});
|
|
51635
|
+
|
|
51636
|
+
// src/feedback/transcript.ts
|
|
51637
|
+
var TRANSCRIPT_MAX_BYTES, TRANSCRIPT_READ_MAX_BYTES, SESSION_ID, CODEX_DAYS_SEARCHED, FeedbackError, envValue2, detectAgent, isFileAt, listDir, moved, findClaudeCode, newestFirst, codexRollout, findCodex, locate3, tail3, missing3, readTranscript;
|
|
51638
|
+
var init_transcript = __esm({
|
|
51639
|
+
"src/feedback/transcript.ts"() {
|
|
51640
|
+
"use strict";
|
|
51641
|
+
init_agents();
|
|
51642
|
+
init_i18n();
|
|
51643
|
+
init_clean2();
|
|
51644
|
+
TRANSCRIPT_MAX_BYTES = 40 * 1024 * 1024;
|
|
51645
|
+
TRANSCRIPT_READ_MAX_BYTES = 256 * 1024 * 1024;
|
|
51646
|
+
SESSION_ID = /^[A-Za-z0-9_-]{1,200}$/;
|
|
51647
|
+
CODEX_DAYS_SEARCHED = 400;
|
|
51648
|
+
FeedbackError = class extends Error {
|
|
51649
|
+
constructor(code, message2) {
|
|
51650
|
+
super(message2);
|
|
51651
|
+
this.code = code;
|
|
51652
|
+
}
|
|
51653
|
+
code;
|
|
51654
|
+
name = "FeedbackError";
|
|
51655
|
+
};
|
|
51656
|
+
envValue2 = (rt, name) => {
|
|
51657
|
+
const value = rt.env[name]?.trim();
|
|
51658
|
+
return value ? value : void 0;
|
|
51659
|
+
};
|
|
51660
|
+
detectAgent = (rt, session) => {
|
|
51661
|
+
const given2 = session?.trim();
|
|
51662
|
+
if (given2 !== void 0 && !SESSION_ID.test(given2))
|
|
51663
|
+
throw new FeedbackError("BAD_SESSION", msg("--session is a session id: letters, digits, - and _ only, at most 200", "--session \u662F\u4F1A\u8BDD id\uFF1A\u53EA\u542B\u5B57\u6BCD\u3001\u6570\u5B57\u3001- \u548C _\uFF0C\u6700\u591A 200 \u4E2A\u5B57\u7B26"));
|
|
51664
|
+
const claude = envValue2(rt, "CLAUDE_CODE_SESSION_ID");
|
|
51665
|
+
const codex = envValue2(rt, "CODEX_THREAD_ID");
|
|
51666
|
+
const known2 = (id2, sid) => ({ id: id2, label: agentLabel(id2), ...given2 ?? sid ? { sessionId: given2 ?? sid } : {} });
|
|
51667
|
+
if (claude || envValue2(rt, "CLAUDECODE")) return known2("claude-code", claude);
|
|
51668
|
+
if (codex) return known2("codex", codex);
|
|
51669
|
+
const other = AGENTS.find((agent) => agent.env?.some((name) => envValue2(rt, name)));
|
|
51670
|
+
return other ? known2(other.id) : { id: "unknown", label: "unknown", ...given2 ? { sessionId: given2 } : {} };
|
|
51671
|
+
};
|
|
51672
|
+
isFileAt = async (rt, path2) => (await rt.fs.stat(path2))?.isFile ?? false;
|
|
51673
|
+
listDir = async (rt, dir) => rt.fs.readdir(dir).catch(() => []);
|
|
51674
|
+
moved = (rt, name, home, dir) => {
|
|
51675
|
+
const value = envValue2(rt, name);
|
|
51676
|
+
return value ? rt.path.resolve(rt.cwd, value) : rt.path.join(home, dir);
|
|
51677
|
+
};
|
|
51678
|
+
findClaudeCode = async (rt, home, sid) => {
|
|
51679
|
+
const projects = rt.path.join(moved(rt, "CLAUDE_CONFIG_DIR", home, ".claude"), "projects");
|
|
51680
|
+
for (const folder of await listDir(rt, projects)) {
|
|
51681
|
+
const file = rt.path.join(projects, folder, `${sid}.jsonl`);
|
|
51682
|
+
if (await isFileAt(rt, file)) return file;
|
|
51683
|
+
}
|
|
51684
|
+
return void 0;
|
|
51685
|
+
};
|
|
51686
|
+
newestFirst = async (rt, dir, pattern) => (await listDir(rt, dir)).filter((name) => pattern.test(name)).sort().reverse();
|
|
51687
|
+
codexRollout = async (rt, dir, sid) => {
|
|
51688
|
+
const name = (await listDir(rt, dir)).find((entry2) => entry2.startsWith("rollout-") && entry2.endsWith(`-${sid}.jsonl`));
|
|
51689
|
+
return name ? rt.path.join(dir, name) : void 0;
|
|
51690
|
+
};
|
|
51691
|
+
findCodex = async (rt, home, sid) => {
|
|
51692
|
+
const base = moved(rt, "CODEX_HOME", home, ".codex");
|
|
51693
|
+
const sessions = rt.path.join(base, "sessions");
|
|
51694
|
+
let days = 0;
|
|
51695
|
+
for (const year of await newestFirst(rt, sessions, /^\d{4}$/))
|
|
51696
|
+
for (const month of await newestFirst(rt, rt.path.join(sessions, year), /^\d{2}$/))
|
|
51697
|
+
for (const day of await newestFirst(rt, rt.path.join(sessions, year, month), /^\d{2}$/)) {
|
|
51698
|
+
if (++days > CODEX_DAYS_SEARCHED) return codexRollout(rt, rt.path.join(base, "archived_sessions"), sid);
|
|
51699
|
+
const found = await codexRollout(rt, rt.path.join(sessions, year, month, day), sid);
|
|
51700
|
+
if (found) return found;
|
|
51701
|
+
}
|
|
51702
|
+
return codexRollout(rt, rt.path.join(base, "archived_sessions"), sid);
|
|
51703
|
+
};
|
|
51704
|
+
locate3 = async (rt, agent) => {
|
|
51705
|
+
if (agent.id !== "claude-code" && agent.id !== "codex")
|
|
51706
|
+
return { reason: msg(`popost does not know where ${agent.label === "unknown" ? "this agent" : agent.label} keeps its transcript; name the file with --transcript FILE`, `popost \u4E0D\u77E5\u9053 ${agent.label === "unknown" ? "\u8FD9\u4E2A Agent" : agent.label} \u628A\u4F1A\u8BDD\u8BB0\u5F55\u5B58\u5728\u54EA\u91CC\uFF1B\u8BF7\u7528 --transcript FILE \u6307\u5B9A\u6587\u4EF6`) };
|
|
51707
|
+
if (!agent.sessionId) return { reason: msg(`${agent.label} did not say which session this is; pass --session ID or --transcript FILE`, `${agent.label} \u6CA1\u6709\u7ED9\u51FA\u5F53\u524D\u4F1A\u8BDD id\uFF1B\u8BF7\u4F20 --session ID \u6216 --transcript FILE`) };
|
|
51708
|
+
if (!rt.homeDir) return { reason: msg("this host has no home folder to look in; pass --transcript FILE", "\u5F53\u524D\u73AF\u5883\u6CA1\u6709\u53EF\u67E5\u627E\u7684\u7528\u6237\u4E3B\u76EE\u5F55\uFF1B\u8BF7\u4F20 --transcript FILE") };
|
|
51709
|
+
const claude = agent.id === "claude-code";
|
|
51710
|
+
const path2 = claude ? await findClaudeCode(rt, rt.homeDir, agent.sessionId) : await findCodex(rt, rt.homeDir, agent.sessionId);
|
|
51711
|
+
if (path2) return { path: path2, format: claude ? "claude-code-jsonl" : "codex-jsonl" };
|
|
51712
|
+
const where3 = claude ? "~/.claude/projects/*/" : "~/.codex/sessions/YYYY/MM/DD/, ~/.codex/archived_sessions/";
|
|
51713
|
+
return { reason: msg(`no transcript of session ${agent.sessionId} was found in ${where3}; pass --transcript FILE`, `\u5728 ${where3} \u4E0B\u6CA1\u6709\u627E\u5230\u4F1A\u8BDD ${agent.sessionId} \u7684\u8BB0\u5F55\uFF1B\u8BF7\u4F20 --transcript FILE`) };
|
|
51714
|
+
};
|
|
51715
|
+
tail3 = (data, max) => {
|
|
51716
|
+
if (data.length <= max) return { data, cut: false };
|
|
51717
|
+
const start = data.length - max;
|
|
51718
|
+
const newline = data.indexOf(10, start);
|
|
51719
|
+
return { data: data.subarray(newline < 0 ? start : newline + 1), cut: true };
|
|
51720
|
+
};
|
|
51721
|
+
missing3 = (reason2) => ({ status: "missing", reason: reason2, lines: 0, bytes: 0, truncated: false });
|
|
51722
|
+
readTranscript = async (rt, agent, cleaner, options) => {
|
|
51723
|
+
if (options.skip) return { status: "skipped", lines: 0, bytes: 0, truncated: false };
|
|
51724
|
+
let found;
|
|
51725
|
+
if (options.file !== void 0) {
|
|
51726
|
+
const path2 = rt.path.resolve(rt.cwd, options.file);
|
|
51727
|
+
if (!await isFileAt(rt, path2)) throw new FeedbackError("TRANSCRIPT_NOT_FOUND", msg(`--transcript: ${options.file} is not a file`, `--transcript\uFF1A${options.file} \u4E0D\u662F\u6587\u4EF6`));
|
|
51728
|
+
found = { path: path2, format: path2.endsWith(".jsonl") ? "jsonl" : "text" };
|
|
51729
|
+
} else found = await locate3(rt, agent);
|
|
51730
|
+
if (!found.path) return missing3(found.reason ?? "");
|
|
51731
|
+
const raw = tail3(await rt.fs.readFile(found.path), TRANSCRIPT_READ_MAX_BYTES);
|
|
51732
|
+
const decoded = new TextDecoder("utf-8", { fatal: false }).decode(raw.data);
|
|
51733
|
+
const cleaned = found.format === "text" ? { text: cleaner.text(decoded), lines: decoded.split("\n").length } : cleanJsonl(cleaner, decoded);
|
|
51734
|
+
const bytes = new TextEncoder().encode(cleaned.text);
|
|
51735
|
+
const kept3 = tail3(bytes, TRANSCRIPT_MAX_BYTES);
|
|
51736
|
+
const text13 = kept3.cut ? new TextDecoder().decode(kept3.data) : cleaned.text;
|
|
51737
|
+
const lines2 = kept3.cut ? text13.split("\n").filter((line) => line.trim() !== "").length : cleaned.lines;
|
|
51738
|
+
return { status: "found", path: found.path, format: found.format ?? "jsonl", text: text13, lines: lines2, bytes: kept3.data.length, truncated: raw.cut || kept3.cut };
|
|
51739
|
+
};
|
|
51740
|
+
}
|
|
51741
|
+
});
|
|
51742
|
+
|
|
51743
|
+
// src/feedback/bundle.ts
|
|
51744
|
+
import { gzipSync } from "fflate";
|
|
51745
|
+
var FORMAT5, MESSAGE_MAX_CHARS, MAX_BUNDLE_BYTES, tildify, projectDirOf, cleanMessage, documentOf, buildFeedback;
|
|
51746
|
+
var init_bundle = __esm({
|
|
51747
|
+
"src/feedback/bundle.ts"() {
|
|
51748
|
+
"use strict";
|
|
51749
|
+
init_util();
|
|
51750
|
+
init_i18n();
|
|
51751
|
+
init_task();
|
|
51752
|
+
init_version();
|
|
51753
|
+
init_clean2();
|
|
51754
|
+
init_project_files();
|
|
51755
|
+
init_transcript();
|
|
51756
|
+
FORMAT5 = "popost-feedback/1";
|
|
51757
|
+
MESSAGE_MAX_CHARS = 4e3;
|
|
51758
|
+
MAX_BUNDLE_BYTES = 25 * 1024 * 1024;
|
|
51759
|
+
tildify = (rt, path2) => {
|
|
51760
|
+
const home = rt.homeDir?.replace(/[\\/]+$/, "");
|
|
51761
|
+
return home && home.length > 1 && (path2 === home || path2.startsWith(home + rt.path.sep)) ? "~" + path2.slice(home.length) : path2;
|
|
51762
|
+
};
|
|
51763
|
+
projectDirOf = async (rt, dir) => {
|
|
51764
|
+
if (dir === void 0) return enclosingProject(rt, ".");
|
|
51765
|
+
const root = rt.path.resolve(rt.cwd, dir);
|
|
51766
|
+
if (!(await rt.fs.stat(root))?.isDirectory) throw new FeedbackError("NOT_A_DIRECTORY", msg(`--dir: ${dir} is not a folder`, `--dir\uFF1A${dir} \u4E0D\u662F\u6587\u4EF6\u5939`));
|
|
51767
|
+
return root;
|
|
51768
|
+
};
|
|
51769
|
+
cleanMessage = (raw, clean2) => {
|
|
51770
|
+
const message2 = raw.trim();
|
|
51771
|
+
if (!message2)
|
|
51772
|
+
throw new FeedbackError("EMPTY_MESSAGE", msg("--message is empty: say in the user's words what went wrong", "--message \u4E3A\u7A7A\uFF1A\u8BF7\u7528\u7528\u6237\u81EA\u5DF1\u7684\u8BDD\u5199\u660E\u51FA\u4E86\u4EC0\u4E48\u95EE\u9898"));
|
|
51773
|
+
if ([...message2].length > MESSAGE_MAX_CHARS)
|
|
51774
|
+
throw new FeedbackError("MESSAGE_TOO_LONG", msg(`--message is longer than ${MESSAGE_MAX_CHARS} characters; shorten it`, `--message \u8D85\u8FC7 ${MESSAGE_MAX_CHARS} \u4E2A\u5B57\u7B26\uFF0C\u8BF7\u7F29\u77ED`));
|
|
51775
|
+
return clean2(message2);
|
|
51776
|
+
};
|
|
51777
|
+
documentOf = (rt, built, createdAt) => ({
|
|
51778
|
+
format: FORMAT5,
|
|
51779
|
+
createdAt,
|
|
51780
|
+
message: built.message,
|
|
51781
|
+
client: { version: VERSION, platform: rt.platform ?? "unknown", ...rt.arch ? { arch: rt.arch } : {}, ...rt.nodeVersion ? { node: rt.nodeVersion } : {}, lang: currentLang() },
|
|
51782
|
+
agent: { id: built.agent.id, ...built.agent.sessionId ? { sessionId: built.agent.sessionId } : {}, ...built.transcript.path ? { transcriptPath: tildify(rt, built.transcript.path) } : {} },
|
|
51783
|
+
task: {
|
|
51784
|
+
...built.projectDir ? { dir: tildify(rt, built.projectDir) } : {},
|
|
51785
|
+
...built.task?.id ? { id: built.task.id } : {},
|
|
51786
|
+
...built.task?.title ? { title: built.task.title } : {},
|
|
51787
|
+
...built.task ? { kind: built.task.kind } : {}
|
|
51788
|
+
},
|
|
51789
|
+
project: { files: built.project?.files ?? [], documents: built.project?.documents ?? {} },
|
|
51790
|
+
transcript: {
|
|
51791
|
+
status: built.transcript.status,
|
|
51792
|
+
...built.transcript.format ? { format: built.transcript.format } : {},
|
|
51793
|
+
...built.transcript.text !== void 0 ? { text: built.transcript.text } : {},
|
|
51794
|
+
lines: built.transcript.lines,
|
|
51795
|
+
bytes: built.transcript.bytes,
|
|
51796
|
+
truncated: built.transcript.truncated,
|
|
51797
|
+
omittedImages: built.transcript.omittedImages
|
|
51798
|
+
},
|
|
51799
|
+
redactions: built.stats.redactions
|
|
51800
|
+
});
|
|
51801
|
+
buildFeedback = async (rt, options) => {
|
|
51802
|
+
const cleaner = createCleaner({ homeDir: rt.homeDir, secrets: environmentSecrets(rt.env) });
|
|
51803
|
+
const message2 = cleanMessage(options.message, cleaner.text);
|
|
51804
|
+
const agent = detectAgent(rt, options.session);
|
|
51805
|
+
const before = cleaner.stats.omittedImages;
|
|
51806
|
+
const transcript2 = await readTranscript(rt, agent, cleaner, { file: options.transcript, skip: options.noTranscript });
|
|
51807
|
+
const transcriptImages = cleaner.stats.omittedImages - before;
|
|
51808
|
+
const projectDir = await projectDirOf(rt, options.dir);
|
|
51809
|
+
const task = projectDir ? await projectTask(rt, { dir: projectDir, kind: "found" }, false).catch(() => void 0) : void 0;
|
|
51810
|
+
const project = projectDir ? await collectProjectFiles(rt, projectDir, cleaner) : void 0;
|
|
51811
|
+
const parts = { message: message2, agent, transcript: { ...transcript2, omittedImages: transcriptImages }, projectDir, task, project, stats: { ...cleaner.stats } };
|
|
51812
|
+
const json4 = JSON.stringify(documentOf(rt, parts, rt.now().toISOString()));
|
|
51813
|
+
const gzip = gzipSync(new TextEncoder().encode(json4), { level: 6, mtime: 0 });
|
|
51814
|
+
return { ...parts, gzip, sha256: sha256(gzip) };
|
|
51815
|
+
};
|
|
51816
|
+
}
|
|
51817
|
+
});
|
|
51818
|
+
|
|
51819
|
+
// src/feedback/upload.ts
|
|
51820
|
+
var RATE_RETRIES2, MAX_WAIT_SEC2, UPLOAD_ATTEMPTS, AGENT_ID, rateAware2, reservation, badAnswer, ticketOf, uploadMissing, attempt2, sendFeedback;
|
|
51821
|
+
var init_upload = __esm({
|
|
51822
|
+
"src/feedback/upload.ts"() {
|
|
51823
|
+
"use strict";
|
|
51824
|
+
init_i18n();
|
|
51825
|
+
init_base();
|
|
51826
|
+
init_errors3();
|
|
51827
|
+
init_time();
|
|
51828
|
+
init_task();
|
|
51829
|
+
init_version();
|
|
51830
|
+
RATE_RETRIES2 = 3;
|
|
51831
|
+
MAX_WAIT_SEC2 = 60;
|
|
51832
|
+
UPLOAD_ATTEMPTS = 2;
|
|
51833
|
+
AGENT_ID = /^[a-z0-9-]{1,40}$/;
|
|
51834
|
+
rateAware2 = async (rt, call2) => {
|
|
51835
|
+
for (let attempt3 = 0; ; attempt3++) {
|
|
51836
|
+
try {
|
|
51837
|
+
return await call2();
|
|
51838
|
+
} catch (error2) {
|
|
51839
|
+
if (!(error2 instanceof PopostApiError) || error2.code !== "RATE_LIMITED" || attempt3 >= RATE_RETRIES2) throw error2;
|
|
51840
|
+
const asked2 = Number(error2.details.retryAfterSeconds);
|
|
51841
|
+
await sleep(rt, Math.ceil((Number.isFinite(asked2) && asked2 > 0 ? Math.min(asked2, MAX_WAIT_SEC2) : 5) * 1e3));
|
|
51842
|
+
}
|
|
51843
|
+
}
|
|
51844
|
+
};
|
|
51845
|
+
reservation = (rt, built, operationKey) => {
|
|
51846
|
+
const title = cleanTitle(built.task?.title);
|
|
51847
|
+
const task = {
|
|
51848
|
+
...built.task?.id && TASK_ID.test(built.task.id) ? { id: built.task.id } : {},
|
|
51849
|
+
...title ? { title } : {},
|
|
51850
|
+
...built.task ? { kind: built.task.kind } : {}
|
|
51851
|
+
};
|
|
51852
|
+
return {
|
|
51853
|
+
operationKey,
|
|
51854
|
+
message: built.message,
|
|
51855
|
+
sizeBytes: built.gzip.length,
|
|
51856
|
+
sha256: built.sha256,
|
|
51857
|
+
...AGENT_ID.test(built.agent.id) ? { agent: { id: built.agent.id, ...built.agent.sessionId ? { sessionId: built.agent.sessionId } : {} } } : {},
|
|
51858
|
+
...Object.keys(task).length ? { task } : {},
|
|
51859
|
+
client: { version: VERSION, os: (rt.platform ?? "unknown").slice(0, 80) },
|
|
51860
|
+
contents: {
|
|
51861
|
+
transcript: built.transcript.status,
|
|
51862
|
+
transcriptBytes: built.transcript.bytes,
|
|
51863
|
+
transcriptLines: built.transcript.lines,
|
|
51864
|
+
projectFiles: Object.keys(built.project?.documents ?? {}).length,
|
|
51865
|
+
redactions: built.stats.redactions,
|
|
51866
|
+
omittedImages: built.stats.omittedImages,
|
|
51867
|
+
truncated: built.transcript.truncated
|
|
51868
|
+
}
|
|
51869
|
+
};
|
|
51870
|
+
};
|
|
51871
|
+
badAnswer = (what) => new PopostApiError(msg(`popost.ai answered ${what} in an unexpected format`, `popost.ai \u5BF9 ${what} \u7684\u8FD4\u56DE\u683C\u5F0F\u4E0D\u7B26`), { code: "BAD_RESPONSE" });
|
|
51872
|
+
ticketOf = (data) => {
|
|
51873
|
+
if (!isRecord(data) || typeof data.id !== "string" || !/^[A-Za-z0-9-]{1,64}$/.test(data.id) || data.uploadUrl !== null && typeof data.uploadUrl !== "string")
|
|
51874
|
+
throw badAnswer("POST /feedback");
|
|
51875
|
+
const reference2 = typeof data.reference === "string" && data.reference ? data.reference : data.id.slice(0, 8);
|
|
51876
|
+
return { id: data.id, reference: reference2, uploadUrl: data.uploadUrl, state: String(data.state ?? "") };
|
|
51877
|
+
};
|
|
51878
|
+
uploadMissing = (error2) => error2 instanceof PopostApiError && (error2.code === "UPLOAD_FAILED" || error2.code === "INVALID_REQUEST" && Array.isArray(error2.details.issues) && error2.details.issues.some((issue4) => isRecord(issue4) && issue4.path === "upload"));
|
|
51879
|
+
attempt2 = async (rt, client2, built, body) => {
|
|
51880
|
+
const ticket2 = ticketOf(await rateAware2(rt, () => client2.request("POST", "/feedback", { body })));
|
|
51881
|
+
if (ticket2.state === "received" && !ticket2.uploadUrl) return { id: ticket2.id, reference: ticket2.reference, receivedAt: rt.now().toISOString() };
|
|
51882
|
+
if (ticket2.uploadUrl)
|
|
51883
|
+
await client2.putSigned(ticket2.uploadUrl, built.gzip, "application/gzip", "feedback.json.gz", msg("run the same popost feedback command again", "\u8BF7\u518D\u6B21\u8FD0\u884C\u540C\u4E00\u6761 popost feedback \u547D\u4EE4"));
|
|
51884
|
+
const done2 = await rateAware2(rt, () => client2.request("POST", `/feedback/${encodeURIComponent(ticket2.id)}/complete`, { body: {} }));
|
|
51885
|
+
if (!isRecord(done2) || done2.id !== ticket2.id) throw badAnswer(`POST /feedback/${ticket2.id}/complete`);
|
|
51886
|
+
return {
|
|
51887
|
+
id: ticket2.id,
|
|
51888
|
+
reference: typeof done2.reference === "string" && done2.reference ? done2.reference : ticket2.reference,
|
|
51889
|
+
receivedAt: typeof done2.receivedAt === "string" ? done2.receivedAt : rt.now().toISOString()
|
|
51890
|
+
};
|
|
51891
|
+
};
|
|
51892
|
+
sendFeedback = async (rt, client2, built) => {
|
|
51893
|
+
const body = reservation(rt, built, rt.randomUUID());
|
|
51894
|
+
for (let tries = 1; ; tries++) {
|
|
51895
|
+
try {
|
|
51896
|
+
return await attempt2(rt, client2, built, body);
|
|
51897
|
+
} catch (error2) {
|
|
51898
|
+
if (tries >= UPLOAD_ATTEMPTS || !uploadMissing(error2)) throw error2;
|
|
51899
|
+
}
|
|
51900
|
+
}
|
|
51901
|
+
};
|
|
51902
|
+
}
|
|
51903
|
+
});
|
|
51904
|
+
|
|
51905
|
+
// src/commands/feedback.ts
|
|
51906
|
+
var feedback_exports = {};
|
|
51907
|
+
__export(feedback_exports, {
|
|
51908
|
+
main: () => main22
|
|
51909
|
+
});
|
|
51910
|
+
var spec9, quote15, wouldSend, tooLarge, report3, run5, main22;
|
|
51911
|
+
var init_feedback = __esm({
|
|
51912
|
+
"src/commands/feedback.ts"() {
|
|
51913
|
+
"use strict";
|
|
51914
|
+
init_args();
|
|
51915
|
+
init_util();
|
|
51916
|
+
init_bundle();
|
|
51917
|
+
init_transcript();
|
|
51918
|
+
init_upload();
|
|
51919
|
+
init_i18n();
|
|
51920
|
+
init_api();
|
|
51921
|
+
init_errors3();
|
|
51922
|
+
spec9 = () => ({
|
|
51923
|
+
prog: "popost feedback",
|
|
51924
|
+
description: msg(
|
|
51925
|
+
"Report a problem to the popost team, only when the user asks for it (free). Without --confirm nothing is sent: it prints what would go, which is the message, this Agent session's transcript with secrets and pictures removed, and the project's file list with its small text files. Show that to the user and add --confirm only after they agree.",
|
|
51926
|
+
"\u5411 popost \u56E2\u961F\u53CD\u9988\u95EE\u9898\uFF0C\u4EC5\u5728\u7528\u6237\u8981\u6C42\u65F6\u4F7F\u7528\uFF08\u514D\u8D39\uFF09\u3002\u4E0D\u52A0 --confirm \u65F6\u4E0D\u53D1\u9001\u4EFB\u4F55\u5185\u5BB9\uFF1A\u53EA\u5217\u51FA\u5C06\u8981\u53D1\u9001\u7684\u5185\u5BB9\uFF0C\u5373\u95EE\u9898\u63CF\u8FF0\u3001\u53BB\u6389\u5BC6\u94A5\u548C\u56FE\u7247\u540E\u7684\u5F53\u524D Agent \u4F1A\u8BDD\u8BB0\u5F55\u3001\u5DE5\u7A0B\u7684\u6587\u4EF6\u5217\u8868\u53CA\u5176\u4E2D\u7684\u5C0F\u6587\u672C\u6587\u4EF6\u3002\u628A\u8FD9\u4E9B\u7ED9\u7528\u6237\u770B\uFF0C\u7528\u6237\u540C\u610F\u540E\u518D\u52A0 --confirm\u3002"
|
|
51927
|
+
),
|
|
51928
|
+
options: [
|
|
51929
|
+
{ flag: "--message", required: true, metavar: "TEXT", help: msg("what went wrong, in the user's own words (at most 4000 characters)", "\u51FA\u4E86\u4EC0\u4E48\u95EE\u9898\uFF0C\u7528\u7528\u6237\u81EA\u5DF1\u7684\u8BDD\uFF08\u6700\u591A 4000 \u4E2A\u5B57\u7B26\uFF09") },
|
|
51930
|
+
{ flag: "--dir", help: msg("the project (default: the project around the current folder, if any)", "\u5DE5\u7A0B\u76EE\u5F55\uFF08\u9ED8\u8BA4\uFF1A\u5F53\u524D\u76EE\u5F55\u6240\u5728\u7684\u5DE5\u7A0B\uFF0C\u5982\u679C\u6709\uFF09") },
|
|
51931
|
+
{ flag: "--transcript", metavar: "FILE", help: msg("the Agent session's transcript file, when popost cannot find it by itself", "Agent \u4F1A\u8BDD\u8BB0\u5F55\u6587\u4EF6\uFF0Cpopost \u81EA\u5DF1\u627E\u4E0D\u5230\u65F6\u6307\u5B9A") },
|
|
51932
|
+
{ flag: "--no-transcript", kind: "flag", help: msg("send no session transcript", "\u4E0D\u53D1\u9001\u4F1A\u8BDD\u8BB0\u5F55") },
|
|
51933
|
+
{ flag: "--session", metavar: "ID", help: msg("the Agent session id, when the Agent does not set it", "Agent \u4F1A\u8BDD id\uFF0CAgent \u6CA1\u6709\u63D0\u4F9B\u65F6\u6307\u5B9A") },
|
|
51934
|
+
{ flag: "--out", metavar: "FILE", help: msg("also write the report (gzip JSON) to this file", "\u540C\u65F6\u628A\u62A5\u544A\uFF08gzip \u538B\u7F29\u7684 JSON\uFF09\u5199\u5230\u8FD9\u4E2A\u6587\u4EF6") },
|
|
51935
|
+
{ flag: "--confirm", kind: "flag", help: msg("send it; only after the user has seen the dry run and agreed", "\u53D1\u9001\uFF1B\u4EC5\u5728\u7528\u6237\u770B\u8FC7\u8BD5\u8FD0\u884C\u7ED3\u679C\u5E76\u540C\u610F\u4E4B\u540E") }
|
|
51936
|
+
]
|
|
51937
|
+
});
|
|
51938
|
+
quote15 = (word2) => /^[A-Za-z0-9_./:=,@+-]+$/.test(word2) ? word2 : `'${word2.replace(/'/g, `'\\''`)}'`;
|
|
51939
|
+
wouldSend = (rt, built) => {
|
|
51940
|
+
const { transcript: transcript2, project } = built;
|
|
51941
|
+
const sent = project ? project.files.filter((file) => file.path in project.documents) : [];
|
|
51942
|
+
return {
|
|
51943
|
+
message: built.message,
|
|
51944
|
+
agent: { id: built.agent.id, label: built.agent.label, ...built.agent.sessionId ? { sessionId: built.agent.sessionId } : {} },
|
|
51945
|
+
transcript: {
|
|
51946
|
+
status: transcript2.status,
|
|
51947
|
+
...transcript2.path ? { path: tildify(rt, transcript2.path) } : {},
|
|
51948
|
+
...transcript2.format ? { format: transcript2.format } : {},
|
|
51949
|
+
lines: transcript2.lines,
|
|
51950
|
+
bytes: transcript2.bytes,
|
|
51951
|
+
truncated: transcript2.truncated,
|
|
51952
|
+
omittedImages: transcript2.omittedImages,
|
|
51953
|
+
...transcript2.reason ? { reason: transcript2.reason } : {}
|
|
51954
|
+
},
|
|
51955
|
+
project: project ? {
|
|
51956
|
+
dir: tildify(rt, built.projectDir ?? ""),
|
|
51957
|
+
task: built.task ? { ...built.task.id ? { id: built.task.id } : {}, ...built.task.title ? { title: built.task.title } : {}, kind: built.task.kind } : null,
|
|
51958
|
+
sent,
|
|
51959
|
+
listedOnly: project.files.length - sent.length,
|
|
51960
|
+
...project.listTruncated ? { listTruncated: true } : {}
|
|
51961
|
+
} : null,
|
|
51962
|
+
redactions: built.stats.redactions,
|
|
51963
|
+
omittedImages: built.stats.omittedImages,
|
|
51964
|
+
bytes: built.gzip.length
|
|
51965
|
+
};
|
|
51966
|
+
};
|
|
51967
|
+
tooLarge = (built) => msg(
|
|
51968
|
+
`The report is ${(built.gzip.length / 1048576).toFixed(1)} MB compressed, more than the ${MAX_BUNDLE_BYTES / 1048576} MB popost.ai takes; nothing was sent. Run it again with --no-transcript, or with --dir pointing at a folder without the big files.`,
|
|
51969
|
+
`\u62A5\u544A\u538B\u7F29\u540E ${(built.gzip.length / 1048576).toFixed(1)} MB\uFF0C\u8D85\u8FC7 popost.ai \u63A5\u53D7\u7684 ${MAX_BUNDLE_BYTES / 1048576} MB\uFF0C\u672A\u53D1\u9001\u3002\u8BF7\u52A0 --no-transcript \u91CD\u8BD5\uFF0C\u6216\u8BA9 --dir \u6307\u5411\u4E0D\u542B\u5927\u6587\u4EF6\u7684\u76EE\u5F55\u3002`
|
|
51970
|
+
);
|
|
51971
|
+
report3 = async (rt, argv, options) => {
|
|
51972
|
+
if (options.transcript !== void 0 && options.noTranscript)
|
|
51973
|
+
return fail(rt, msg("--transcript and --no-transcript cannot be used together", "--transcript \u548C --no-transcript \u4E0D\u80FD\u540C\u65F6\u4F7F\u7528"), 2, { code: "BAD_ARGUMENT" });
|
|
51974
|
+
const built = await buildFeedback(rt, options);
|
|
51975
|
+
const out2 = options.out ? rt.path.resolve(rt.cwd, options.out) : void 0;
|
|
51976
|
+
if (out2) await rt.fs.writeFile(out2, built.gzip);
|
|
51977
|
+
const written2 = out2 ? { out: tildify(rt, out2) } : {};
|
|
51978
|
+
if (built.gzip.length > MAX_BUNDLE_BYTES) return fail(rt, tooLarge(built), 2, { code: "TOO_LARGE", bytes: built.gzip.length, ...written2 });
|
|
51979
|
+
if (!options.confirm) {
|
|
51980
|
+
const next = ["popost", "feedback", ...argv, "--confirm"].map(quote15).join(" ");
|
|
51981
|
+
const note = msg(
|
|
51982
|
+
"Nothing was sent. Show the user what would be sent; run next only after they agree.",
|
|
51983
|
+
"\u672A\u53D1\u9001\u4EFB\u4F55\u5185\u5BB9\u3002\u5148\u628A\u5C06\u8981\u53D1\u9001\u7684\u5185\u5BB9\u7ED9\u7528\u6237\u770B\uFF1B\u7528\u6237\u540C\u610F\u540E\u518D\u8FD0\u884C next\u3002"
|
|
51984
|
+
);
|
|
51985
|
+
printJson(rt, { ok: true, dryRun: true, wouldSend: wouldSend(rt, built), ...written2, next, note }, true);
|
|
51986
|
+
return 0;
|
|
51987
|
+
}
|
|
51988
|
+
const sent = await sendFeedback(rt, new PopostClient({ ...rt, project: void 0 }), built);
|
|
51989
|
+
const thanks = msg(`Sent. Give the user the reference ${sent.reference} for any follow-up.`, `\u5DF2\u53D1\u9001\u3002\u8BF7\u628A\u7F16\u53F7 ${sent.reference} \u544A\u8BC9\u7528\u6237\uFF0C\u65B9\u4FBF\u540E\u7EED\u6C9F\u901A\u3002`);
|
|
51990
|
+
printJson(rt, { ok: true, id: sent.id, reference: sent.reference, bytes: built.gzip.length, receivedAt: sent.receivedAt, ...written2, note: thanks });
|
|
51991
|
+
return 0;
|
|
51992
|
+
};
|
|
51993
|
+
run5 = async (rt, argv, options) => {
|
|
51994
|
+
try {
|
|
51995
|
+
return await report3(rt, argv, options);
|
|
51996
|
+
} catch (error2) {
|
|
51997
|
+
if (error2 instanceof FeedbackError) return fail(rt, error2.message, 2, { code: error2.code });
|
|
51998
|
+
if (error2 instanceof PopostApiError) {
|
|
51999
|
+
const code = error2.code || "API_ERROR";
|
|
52000
|
+
return fail(rt, error2.message, LOCAL_ERROR_CODES.includes(code) ? 2 : 1, { code });
|
|
52001
|
+
}
|
|
52002
|
+
if (error2 instanceof UsageError) return fail(rt, error2.message, 2, { code: "AUTH" });
|
|
52003
|
+
throw error2;
|
|
52004
|
+
}
|
|
52005
|
+
};
|
|
52006
|
+
main22 = (argv, rt) => withArgs(
|
|
52007
|
+
argv,
|
|
52008
|
+
spec9(),
|
|
52009
|
+
rt,
|
|
52010
|
+
(args) => run5(rt, argv, {
|
|
52011
|
+
message: args.req("message"),
|
|
52012
|
+
dir: args.string("dir"),
|
|
52013
|
+
transcript: args.string("transcript"),
|
|
52014
|
+
noTranscript: args.flag("no-transcript"),
|
|
52015
|
+
session: args.string("session"),
|
|
52016
|
+
out: args.string("out"),
|
|
52017
|
+
confirm: args.flag("confirm")
|
|
52018
|
+
})
|
|
52019
|
+
);
|
|
52020
|
+
}
|
|
52021
|
+
});
|
|
52022
|
+
|
|
51242
52023
|
// src/commands/post-bundle.ts
|
|
51243
52024
|
var post_bundle_exports2 = {};
|
|
51244
52025
|
__export(post_bundle_exports2, {
|
|
51245
|
-
main: () =>
|
|
52026
|
+
main: () => main23
|
|
51246
52027
|
});
|
|
51247
|
-
var FILE, ticket, validate2, importBundle, serviceConfig2, table2, failure3,
|
|
52028
|
+
var FILE, ticket, validate2, importBundle, serviceConfig2, table2, failure3, main23;
|
|
51248
52029
|
var init_post_bundle2 = __esm({
|
|
51249
52030
|
"src/commands/post-bundle.ts"() {
|
|
51250
52031
|
"use strict";
|
|
@@ -51309,7 +52090,7 @@ var init_post_bundle2 = __esm({
|
|
|
51309
52090
|
printJson(rt, { ok: false, error: { code, msg: error2.message } }, true);
|
|
51310
52091
|
return 2;
|
|
51311
52092
|
};
|
|
51312
|
-
|
|
52093
|
+
main23 = async (argv, rt) => {
|
|
51313
52094
|
try {
|
|
51314
52095
|
return await runSubcommand("popost", table2(), argv, rt);
|
|
51315
52096
|
} catch (error2) {
|
|
@@ -51324,9 +52105,9 @@ var init_post_bundle2 = __esm({
|
|
|
51324
52105
|
// src/main.ts
|
|
51325
52106
|
var main_exports = {};
|
|
51326
52107
|
__export(main_exports, {
|
|
51327
|
-
run: () =>
|
|
52108
|
+
run: () => run6
|
|
51328
52109
|
});
|
|
51329
|
-
var GROUPS2, register, usage,
|
|
52110
|
+
var GROUPS2, register, usage, run6, runCommand;
|
|
51330
52111
|
var init_main2 = __esm({
|
|
51331
52112
|
"src/main.ts"() {
|
|
51332
52113
|
"use strict";
|
|
@@ -51366,6 +52147,7 @@ var init_main2 = __esm({
|
|
|
51366
52147
|
register(["cloud"], async () => (await Promise.resolve().then(() => (init_cloud(), cloud_exports))).main, false);
|
|
51367
52148
|
register(["deck"], async () => (await Promise.resolve().then(() => (init_deck(), deck_exports))).main, false);
|
|
51368
52149
|
register(["video"], async () => (await Promise.resolve().then(() => (init_video(), video_exports))).main, false);
|
|
52150
|
+
register(["feedback"], async () => (await Promise.resolve().then(() => (init_feedback(), feedback_exports))).main, false);
|
|
51369
52151
|
register(["ticket", "validate", "import"], async () => (await Promise.resolve().then(() => (init_post_bundle2(), post_bundle_exports2))).main, true);
|
|
51370
52152
|
usage = () => msg(
|
|
51371
52153
|
[
|
|
@@ -51382,6 +52164,7 @@ var init_main2 = __esm({
|
|
|
51382
52164
|
"sources: ticket, validate, import, attach-bundle, link, inspiration, template",
|
|
51383
52165
|
"account: account (credit balance and plan), usage (what a project has cost, from popost.ai), pricing (current link tariff); no charge",
|
|
51384
52166
|
"video: video (videos as editable projects; popost video --help lists its commands)",
|
|
52167
|
+
"support: feedback (report a problem to the popost team, only when the user asks; dry run unless --confirm)",
|
|
51385
52168
|
""
|
|
51386
52169
|
].join("\n"),
|
|
51387
52170
|
[
|
|
@@ -51398,10 +52181,11 @@ var init_main2 = __esm({
|
|
|
51398
52181
|
"\u7D20\u6750\u6765\u6E90: ticket\u3001validate\u3001import\u3001attach-bundle\u3001link\u3001inspiration\u3001template",
|
|
51399
52182
|
"\u8D26\u6237: account\uFF08\u79EF\u5206\u4F59\u989D\u548C\u5957\u9910\uFF09\u3001usage\uFF08\u4E00\u4E2A\u5DE5\u7A0B\u5DF2\u82B1\u7684\u79EF\u5206\uFF0C\u6765\u81EA popost.ai\uFF09\u3001pricing\uFF08\u5F53\u524D\u94FE\u63A5\u89E3\u6790\u4EF7\u683C\uFF09\uFF1B\u90FD\u4E0D\u6263\u8D39",
|
|
51400
52183
|
"\u89C6\u9891: video\uFF08\u628A\u89C6\u9891\u505A\u6210\u53EF\u7F16\u8F91\u7684\u5DE5\u7A0B\uFF1Bpopost video --help \u5217\u51FA\u5B83\u7684\u547D\u4EE4\uFF09",
|
|
52184
|
+
"\u53CD\u9988: feedback\uFF08\u5411 popost \u56E2\u961F\u53CD\u9988\u95EE\u9898\uFF0C\u4EC5\u5728\u7528\u6237\u8981\u6C42\u65F6\u4F7F\u7528\uFF1B\u4E0D\u52A0 --confirm \u53EA\u8BD5\u8FD0\u884C\uFF09",
|
|
51401
52185
|
""
|
|
51402
52186
|
].join("\n")
|
|
51403
52187
|
);
|
|
51404
|
-
|
|
52188
|
+
run6 = (argv, rt) => withLang(resolveLang(rt.env), () => runCommand(argv, rt));
|
|
51405
52189
|
runCommand = async (argv, rt) => {
|
|
51406
52190
|
const [name, ...rest] = argv;
|
|
51407
52191
|
if (!name || name === "-h" || name === "--help" || name === "help") {
|
|
@@ -51422,10 +52206,10 @@ ${usage()}`);
|
|
|
51422
52206
|
const updates = await openUpdateSession(rt, name, rest);
|
|
51423
52207
|
const own3 = updates.rt;
|
|
51424
52208
|
try {
|
|
51425
|
-
const
|
|
52209
|
+
const main24 = await group.load();
|
|
51426
52210
|
const { dirArg: dirArg2, inProject: inProject3 } = await Promise.resolve().then(() => (init_task(), task_exports));
|
|
51427
52211
|
const dir = dirArg2(rest);
|
|
51428
|
-
return await
|
|
52212
|
+
return await main24(group.keepName ? argv : rest, dir ? inProject3(own3, dir, "found") : own3);
|
|
51429
52213
|
} catch (error2) {
|
|
51430
52214
|
printJson(own3, { ok: false, error: errorText(error2) });
|
|
51431
52215
|
return 1;
|
|
@@ -51450,6 +52234,6 @@ export {
|
|
|
51450
52234
|
findChromium,
|
|
51451
52235
|
importDeck,
|
|
51452
52236
|
launchChromium,
|
|
51453
|
-
|
|
52237
|
+
run6 as run,
|
|
51454
52238
|
searchTemplateIndex
|
|
51455
52239
|
};
|