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/cli.js
CHANGED
|
@@ -75,19 +75,19 @@ var init_pyjson = __esm({
|
|
|
75
75
|
return `{${keys2.map((key2) => `${JSON.stringify(key2)}: ${pyJson(value[key2], sortKeys)}`).join(", ")}}`;
|
|
76
76
|
};
|
|
77
77
|
reprString = (text13) => {
|
|
78
|
-
const
|
|
78
|
+
const quote16 = text13.includes("'") && !text13.includes('"') ? '"' : "'";
|
|
79
79
|
let out2 = "";
|
|
80
80
|
for (const ch of text13) {
|
|
81
81
|
const code = ch.codePointAt(0);
|
|
82
82
|
if (ch === "\\") out2 += "\\\\";
|
|
83
|
-
else if (ch ===
|
|
83
|
+
else if (ch === quote16) out2 += `\\${quote16}`;
|
|
84
84
|
else if (ch === "\n") out2 += "\\n";
|
|
85
85
|
else if (ch === "\r") out2 += "\\r";
|
|
86
86
|
else if (ch === " ") out2 += "\\t";
|
|
87
87
|
else if (code < 32 || code >= 127 && code <= 159) out2 += `\\x${code.toString(16).padStart(2, "0")}`;
|
|
88
88
|
else out2 += ch;
|
|
89
89
|
}
|
|
90
|
-
return
|
|
90
|
+
return quote16 + out2 + quote16;
|
|
91
91
|
};
|
|
92
92
|
pyRepr = (value) => {
|
|
93
93
|
if (value === null || value === void 0) return "None";
|
|
@@ -107,8 +107,8 @@ var init_pyjson = __esm({
|
|
|
107
107
|
}
|
|
108
108
|
return a === b;
|
|
109
109
|
};
|
|
110
|
-
pyUnquote = (text13) => text13.replace(/(?:%[0-9A-Fa-f]{2})+/g, (
|
|
111
|
-
const bytes = Uint8Array.from(
|
|
110
|
+
pyUnquote = (text13) => text13.replace(/(?:%[0-9A-Fa-f]{2})+/g, (run7) => {
|
|
111
|
+
const bytes = Uint8Array.from(run7.slice(1).split("%"), (hex3) => Number.parseInt(hex3, 16));
|
|
112
112
|
return new TextDecoder().decode(bytes);
|
|
113
113
|
});
|
|
114
114
|
}
|
|
@@ -280,7 +280,7 @@ var VERSION;
|
|
|
280
280
|
var init_version = __esm({
|
|
281
281
|
"src/version.ts"() {
|
|
282
282
|
"use strict";
|
|
283
|
-
VERSION = "4.6.
|
|
283
|
+
VERSION = "4.6.13";
|
|
284
284
|
}
|
|
285
285
|
});
|
|
286
286
|
|
|
@@ -680,8 +680,8 @@ var init_post_bundle = __esm({
|
|
|
680
680
|
const blocker = await resourceBlocker(rt, res, baseDir);
|
|
681
681
|
if (blocker) blockers.push(blocker);
|
|
682
682
|
}
|
|
683
|
-
const
|
|
684
|
-
for (const item2 of
|
|
683
|
+
const missing5 = Array.isArray(bundle.missing) ? bundle.missing : [];
|
|
684
|
+
for (const item2 of missing5) blockers.push(msg(`the bundle still declares a missing item: ${plain(item2)}`, `bundle \u4ECD\u58F0\u660E\u7F3A\u9879: ${plain(item2)}`));
|
|
685
685
|
return { buildable: blockers.length === 0, blockers };
|
|
686
686
|
};
|
|
687
687
|
}
|
|
@@ -1131,11 +1131,11 @@ var init_state = __esm({
|
|
|
1131
1131
|
if (await install.createExclusive(paths.lock, mine)) return await ownsLock(rt, paths);
|
|
1132
1132
|
const stale = await text13(paths.lock);
|
|
1133
1133
|
if (await lockHolder(rt, paths)) return false;
|
|
1134
|
-
const
|
|
1135
|
-
const renamed = await rt.fs.rename(paths.lock,
|
|
1134
|
+
const moved2 = `${paths.lock}.stale-${rt.randomUUID().slice(0, 8)}`;
|
|
1135
|
+
const renamed = await rt.fs.rename(paths.lock, moved2).then(() => true, () => false);
|
|
1136
1136
|
if (renamed) {
|
|
1137
|
-
const taken = await text13(
|
|
1138
|
-
await removeState(rt,
|
|
1137
|
+
const taken = await text13(moved2);
|
|
1138
|
+
await removeState(rt, moved2);
|
|
1139
1139
|
if (taken !== stale) {
|
|
1140
1140
|
if (taken !== null) await install.createExclusive(paths.lock, taken).catch(() => false);
|
|
1141
1141
|
return false;
|
|
@@ -1485,7 +1485,7 @@ var init_auto = __esm({
|
|
|
1485
1485
|
if (!await target2.install.canWrite(dir)) return msg(`${dir} cannot be written by this user`, `\u5F53\u524D\u7528\u6237\u4E0D\u80FD\u5199\u5165 ${dir}`);
|
|
1486
1486
|
return null;
|
|
1487
1487
|
};
|
|
1488
|
-
attemptedLately = (rt,
|
|
1488
|
+
attemptedLately = (rt, attempt3, version) => attempt3 !== null && (since(rt, attempt3.startedAt) < DAY_MS || attempt3.version === version && since(rt, attempt3.startedAt) < RETRY_SAME_VERSION_MS);
|
|
1489
1489
|
startAutoUpdate = async (rt, paths, target2, command2, args2) => {
|
|
1490
1490
|
if (!autoCommand(command2, args2)) return "command";
|
|
1491
1491
|
const check7 = await readState(rt, paths.check);
|
|
@@ -1500,14 +1500,14 @@ var init_auto = __esm({
|
|
|
1500
1500
|
if (await lockHolder(rt, paths)) return "locked";
|
|
1501
1501
|
const processes = rt.processes;
|
|
1502
1502
|
if (!processes) return "blocked";
|
|
1503
|
-
const
|
|
1504
|
-
if (!await writeState(rt, paths.attempt,
|
|
1503
|
+
const attempt3 = { version: latest2, from: VERSION, startedAt: rt.now().toISOString(), status: "started" };
|
|
1504
|
+
if (!await writeState(rt, paths.attempt, attempt3)) return "blocked";
|
|
1505
1505
|
try {
|
|
1506
1506
|
if (((await rt.fs.stat(paths.log))?.size ?? 0) > LOG_KEPT_BYTES) await rt.fs.rm(paths.log);
|
|
1507
1507
|
await processes.spawnDetached([...processes.selfCommand.slice(0, 2), "update", "--background", "--to", latest2], { cwd: rt.homeDir ?? rt.cwd, logFile: paths.log });
|
|
1508
1508
|
return "started";
|
|
1509
1509
|
} catch (error2) {
|
|
1510
|
-
await writeState(rt, paths.attempt, { ...
|
|
1510
|
+
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))}`) });
|
|
1511
1511
|
return "spawn-failed";
|
|
1512
1512
|
}
|
|
1513
1513
|
};
|
|
@@ -1540,30 +1540,30 @@ var init_session = __esm({
|
|
|
1540
1540
|
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}`);
|
|
1541
1541
|
SKILL_COMMAND = REFRESH_COMMAND;
|
|
1542
1542
|
outcomeNews = async (rt, paths, found, news) => {
|
|
1543
|
-
let
|
|
1544
|
-
if (!
|
|
1545
|
-
if (
|
|
1546
|
-
if (since(rt,
|
|
1547
|
-
|
|
1548
|
-
}
|
|
1549
|
-
const { version, from } =
|
|
1550
|
-
if (
|
|
1551
|
-
news.lines.push(autoFailedMessage(version,
|
|
1552
|
-
Object.assign(news.fields, { failed: { version, reason:
|
|
1543
|
+
let attempt3 = found;
|
|
1544
|
+
if (!attempt3 || attempt3.reported || typeof attempt3.version !== "string") return void 0;
|
|
1545
|
+
if (attempt3.status === "started") {
|
|
1546
|
+
if (since(rt, attempt3.startedAt) < STALE_MS || await lockHolder(rt, paths)) return attempt3.version;
|
|
1547
|
+
attempt3 = { ...attempt3, status: "failed", reason: msg("it did not finish", "\u6CA1\u6709\u8FD0\u884C\u5B8C") };
|
|
1548
|
+
}
|
|
1549
|
+
const { version, from } = attempt3;
|
|
1550
|
+
if (attempt3.status === "failed") {
|
|
1551
|
+
news.lines.push(autoFailedMessage(version, attempt3.reason ?? ""));
|
|
1552
|
+
Object.assign(news.fields, { failed: { version, reason: attempt3.reason ?? "" }, command: UPDATE_COMMAND });
|
|
1553
1553
|
} else {
|
|
1554
1554
|
const now = parseVersion(VERSION);
|
|
1555
1555
|
const target2 = parseVersion(version);
|
|
1556
|
-
if (!now || !target2 || compareVersions(now, target2) < 0) return since(rt,
|
|
1556
|
+
if (!now || !target2 || compareVersions(now, target2) < 0) return since(rt, attempt3.startedAt) < DAY_MS ? version : void 0;
|
|
1557
1557
|
Object.assign(news.fields, { updated: { from, to: version } });
|
|
1558
|
-
if (
|
|
1558
|
+
if (attempt3.status === "skill-failed") {
|
|
1559
1559
|
news.lines.push(msg(
|
|
1560
|
-
`${updatedMessage(version)}, but the agents' Skill copies could not be refreshed: ${
|
|
1561
|
-
`${updatedMessage(version)}\uFF0C\u4F46\u5404 Agent \u7684 Skill \u526F\u672C\u6CA1\u6709\u66F4\u65B0\u6210\u529F\uFF1A${
|
|
1560
|
+
`${updatedMessage(version)}, but the agents' Skill copies could not be refreshed: ${attempt3.reason ?? ""}; run ${SKILL_COMMAND}`,
|
|
1561
|
+
`${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}`
|
|
1562
1562
|
));
|
|
1563
|
-
Object.assign(news.fields, { skill: { reason:
|
|
1563
|
+
Object.assign(news.fields, { skill: { reason: attempt3.reason ?? "" }, command: SKILL_COMMAND });
|
|
1564
1564
|
} else news.lines.push(updatedMessage(version));
|
|
1565
1565
|
}
|
|
1566
|
-
await writeState(rt, paths.attempt, { ...
|
|
1566
|
+
await writeState(rt, paths.attempt, { ...attempt3, reported: true });
|
|
1567
1567
|
return void 0;
|
|
1568
1568
|
};
|
|
1569
1569
|
noticeNews = async (rt, paths, check7, news, command2) => {
|
|
@@ -1603,13 +1603,13 @@ var init_session = __esm({
|
|
|
1603
1603
|
const paths = activePaths(rt, command2);
|
|
1604
1604
|
if (!paths) return idle();
|
|
1605
1605
|
const check7 = await readState(rt, paths.check);
|
|
1606
|
-
const
|
|
1606
|
+
const attempt3 = await readState(rt, paths.attempt);
|
|
1607
1607
|
const due = !checkIsFresh(rt, check7);
|
|
1608
|
-
if (!due && offer(VERSION, check7?.latest) === "none" && (!
|
|
1608
|
+
if (!due && offer(VERSION, check7?.latest) === "none" && (!attempt3 || attempt3.reported)) return idle();
|
|
1609
1609
|
const target2 = await installKind(rt);
|
|
1610
1610
|
if (target2.kind !== "global" && target2.kind !== "managed") return idle();
|
|
1611
1611
|
const news = { lines: [], fields: { current: VERSION } };
|
|
1612
|
-
const underway = target2.kind === "global" ? await outcomeNews(rt, paths,
|
|
1612
|
+
const underway = target2.kind === "global" ? await outcomeNews(rt, paths, attempt3, news) : void 0;
|
|
1613
1613
|
if (!news.lines.length && underway !== check7?.latest) await noticeNews(rt, paths, check7, news, target2.kind === "managed" ? target2.command : UPDATE_COMMAND);
|
|
1614
1614
|
for (const line of news.lines) rt.stderr(`${line}
|
|
1615
1615
|
`);
|
|
@@ -2461,7 +2461,7 @@ var init_build = __esm({
|
|
|
2461
2461
|
];
|
|
2462
2462
|
const gaps = await reviewGaps(project, plan4, notes2);
|
|
2463
2463
|
const { warnings } = notes2;
|
|
2464
|
-
const
|
|
2464
|
+
const report4 = {
|
|
2465
2465
|
structureReady: blockers.length === 0,
|
|
2466
2466
|
visualQa: gaps.length ? "pending" : "reviewed-by-agent",
|
|
2467
2467
|
readyToDeliver: blockers.length === 0 && gaps.length === 0,
|
|
@@ -2471,8 +2471,8 @@ var init_build = __esm({
|
|
|
2471
2471
|
warnings,
|
|
2472
2472
|
concept: project.manifest.concept
|
|
2473
2473
|
};
|
|
2474
|
-
await writeJson(project.rt, project.abs("build-report.json"),
|
|
2475
|
-
return
|
|
2474
|
+
await writeJson(project.rt, project.abs("build-report.json"), report4);
|
|
2475
|
+
return report4;
|
|
2476
2476
|
};
|
|
2477
2477
|
doctor = async (project) => {
|
|
2478
2478
|
const { rt, manifest } = project;
|
|
@@ -2536,24 +2536,24 @@ var init_args = __esm({
|
|
|
2536
2536
|
}
|
|
2537
2537
|
};
|
|
2538
2538
|
describeChoices = (choices) => choices.map((c) => `'${c}'`).join(", ");
|
|
2539
|
-
convert = (
|
|
2540
|
-
if (
|
|
2541
|
-
if (!/^[-+]?\d+$/.test(raw.trim())) throw new UsageError(`argument ${
|
|
2539
|
+
convert = (spec10, raw) => {
|
|
2540
|
+
if (spec10.kind === "int") {
|
|
2541
|
+
if (!/^[-+]?\d+$/.test(raw.trim())) throw new UsageError(`argument ${spec10.flag}: invalid int value: '${raw}'`);
|
|
2542
2542
|
return Number.parseInt(raw, 10);
|
|
2543
2543
|
}
|
|
2544
|
-
if (
|
|
2544
|
+
if (spec10.kind === "number") {
|
|
2545
2545
|
const value = Number(raw);
|
|
2546
2546
|
if (raw.trim() === "" || Number.isNaN(value))
|
|
2547
|
-
throw new UsageError(`argument ${
|
|
2547
|
+
throw new UsageError(`argument ${spec10.flag}: invalid float value: '${raw}'`);
|
|
2548
2548
|
return value;
|
|
2549
2549
|
}
|
|
2550
|
-
if (
|
|
2551
|
-
throw new UsageError(`argument ${
|
|
2550
|
+
if (spec10.choices && !spec10.choices.includes(raw))
|
|
2551
|
+
throw new UsageError(`argument ${spec10.flag}: invalid choice: '${raw}' (choose from ${describeChoices(spec10.choices)})`);
|
|
2552
2552
|
return raw;
|
|
2553
2553
|
};
|
|
2554
2554
|
isOptionToken = (token) => token.startsWith("-") && token !== "-" && !/^-\d/.test(token);
|
|
2555
|
-
parseArgs = (argv,
|
|
2556
|
-
const options = new Map((
|
|
2555
|
+
parseArgs = (argv, spec10) => {
|
|
2556
|
+
const options = new Map((spec10.options ?? []).map((o) => [o.flag, o]));
|
|
2557
2557
|
const values = /* @__PURE__ */ new Map();
|
|
2558
2558
|
const positionals = [];
|
|
2559
2559
|
let help = false;
|
|
@@ -2599,7 +2599,7 @@ var init_args = __esm({
|
|
|
2599
2599
|
} else values.set(key2, value);
|
|
2600
2600
|
}
|
|
2601
2601
|
if (help) return new ParsedArgs(values, true);
|
|
2602
|
-
const declared =
|
|
2602
|
+
const declared = spec10.positionals ?? [];
|
|
2603
2603
|
if (positionals.length > declared.length && !declared.at(-1)?.variadic)
|
|
2604
2604
|
throw new UsageError(`unrecognized arguments: ${positionals.slice(declared.length).join(" ")}`);
|
|
2605
2605
|
declared.forEach((positional, index) => {
|
|
@@ -2612,12 +2612,12 @@ var init_args = __esm({
|
|
|
2612
2612
|
);
|
|
2613
2613
|
values.set(keyOf(positional.name), positional.variadic ? raws : raws[0]);
|
|
2614
2614
|
});
|
|
2615
|
-
const
|
|
2615
|
+
const missing5 = [
|
|
2616
2616
|
...declared.filter((p) => p.required !== false && !values.has(keyOf(p.name))).map((p) => p.name),
|
|
2617
|
-
...(
|
|
2617
|
+
...(spec10.options ?? []).filter((o) => o.required && !values.has(keyOf(o.flag))).map((o) => o.flag)
|
|
2618
2618
|
];
|
|
2619
|
-
if (
|
|
2620
|
-
for (const option of
|
|
2619
|
+
if (missing5.length) throw new UsageError(`the following arguments are required: ${missing5.join(", ")}`);
|
|
2620
|
+
for (const option of spec10.options ?? []) {
|
|
2621
2621
|
const key2 = keyOf(option.flag);
|
|
2622
2622
|
if (!values.has(key2) && option.default !== void 0) values.set(key2, option.default);
|
|
2623
2623
|
}
|
|
@@ -2629,26 +2629,26 @@ var init_args = __esm({
|
|
|
2629
2629
|
if (option.kind === "list") return `${option.flag} ${meta} [${meta} ...]`;
|
|
2630
2630
|
return `${option.flag} ${option.choices ? `{${option.choices.join(",")}}` : meta}`;
|
|
2631
2631
|
};
|
|
2632
|
-
formatUsage = (
|
|
2632
|
+
formatUsage = (spec10) => {
|
|
2633
2633
|
const parts = [
|
|
2634
|
-
...(
|
|
2635
|
-
...(
|
|
2634
|
+
...(spec10.options ?? []).map((o) => o.required ? optionUsage(o) : `[${optionUsage(o)}]`),
|
|
2635
|
+
...(spec10.positionals ?? []).map((p) => {
|
|
2636
2636
|
const name = p.choices ? `{${p.choices.join(",")}}` : p.name;
|
|
2637
2637
|
return p.variadic ? p.required === false ? `[${name} ...]` : `${name} [${name} ...]` : name;
|
|
2638
2638
|
})
|
|
2639
2639
|
];
|
|
2640
|
-
return `usage: ${
|
|
2640
|
+
return `usage: ${spec10.prog} [-h] ${parts.join(" ")}`.trimEnd();
|
|
2641
2641
|
};
|
|
2642
|
-
formatHelp = (
|
|
2643
|
-
const lines2 = [formatUsage(
|
|
2644
|
-
if (
|
|
2645
|
-
if (
|
|
2642
|
+
formatHelp = (spec10) => {
|
|
2643
|
+
const lines2 = [formatUsage(spec10), ""];
|
|
2644
|
+
if (spec10.description) lines2.push(spec10.description, "");
|
|
2645
|
+
if (spec10.positionals?.length) {
|
|
2646
2646
|
lines2.push("positional arguments:");
|
|
2647
|
-
for (const p of
|
|
2647
|
+
for (const p of spec10.positionals) lines2.push(` ${p.choices ? `{${p.choices.join(",")}}` : p.name} ${p.help ?? ""}`);
|
|
2648
2648
|
lines2.push("");
|
|
2649
2649
|
}
|
|
2650
2650
|
lines2.push("options:", " -h, --help show this help message and exit");
|
|
2651
|
-
for (const o of
|
|
2651
|
+
for (const o of spec10.options ?? []) {
|
|
2652
2652
|
const extra2 = [
|
|
2653
2653
|
o.required ? "required" : "",
|
|
2654
2654
|
o.default !== void 0 && o.kind !== "flag" ? `default: ${o.default}` : ""
|
|
@@ -2657,19 +2657,19 @@ var init_args = __esm({
|
|
|
2657
2657
|
}
|
|
2658
2658
|
return lines2.join("\n") + "\n";
|
|
2659
2659
|
};
|
|
2660
|
-
withArgs = async (argv,
|
|
2660
|
+
withArgs = async (argv, spec10, rt, body) => {
|
|
2661
2661
|
let args2;
|
|
2662
2662
|
try {
|
|
2663
|
-
args2 = parseArgs(argv,
|
|
2663
|
+
args2 = parseArgs(argv, spec10);
|
|
2664
2664
|
} catch (error2) {
|
|
2665
2665
|
if (!(error2 instanceof UsageError)) throw error2;
|
|
2666
|
-
rt.stderr(`${formatUsage(
|
|
2667
|
-
${
|
|
2666
|
+
rt.stderr(`${formatUsage(spec10)}
|
|
2667
|
+
${spec10.prog}: error: ${error2.message}
|
|
2668
2668
|
`);
|
|
2669
2669
|
return 2;
|
|
2670
2670
|
}
|
|
2671
2671
|
if (args2.help) {
|
|
2672
|
-
rt.stdout(formatHelp(
|
|
2672
|
+
rt.stdout(formatHelp(spec10));
|
|
2673
2673
|
return 0;
|
|
2674
2674
|
}
|
|
2675
2675
|
return body(args2);
|
|
@@ -2923,20 +2923,20 @@ var init_project_fonts = __esm({
|
|
|
2923
2923
|
fontEntry = (role) => ({ ...role, cssFamily: role.family });
|
|
2924
2924
|
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("");
|
|
2925
2925
|
linkInstalledFonts = async (project, only) => {
|
|
2926
|
-
const
|
|
2927
|
-
if (!installedFontLinks(project)) return
|
|
2926
|
+
const report4 = { linked: [] };
|
|
2927
|
+
if (!installedFontLinks(project)) return report4;
|
|
2928
2928
|
for (const page2 of project.manifest.pages.filter((candidate) => !only || only.includes(candidate.id))) {
|
|
2929
2929
|
try {
|
|
2930
2930
|
const before = await project.readPageHtml(page2.id);
|
|
2931
2931
|
const after = withFontLinks(before, installedFontLinks(project, before));
|
|
2932
2932
|
if (after === before) continue;
|
|
2933
2933
|
await project.writePageHtml(page2.id, after);
|
|
2934
|
-
|
|
2934
|
+
report4.linked.push(page2.id);
|
|
2935
2935
|
} catch (error2) {
|
|
2936
|
-
(
|
|
2936
|
+
(report4.failed ??= []).push({ page: page2.id, reason: error2 instanceof Error ? error2.message : String(error2) });
|
|
2937
2937
|
}
|
|
2938
2938
|
}
|
|
2939
|
-
return
|
|
2939
|
+
return report4;
|
|
2940
2940
|
};
|
|
2941
2941
|
CHINESE_LANGUAGE = /(^|[^a-z])zh([^a-z]|$)|chinese|中文/i;
|
|
2942
2942
|
cjkFontWarnings = (project, roleIds) => {
|
|
@@ -3410,9 +3410,9 @@ var init_page_select = __esm({
|
|
|
3410
3410
|
ValueError2 = class extends Error {
|
|
3411
3411
|
name = "ValueError";
|
|
3412
3412
|
};
|
|
3413
|
-
selectPages = (project,
|
|
3414
|
-
if (
|
|
3415
|
-
const wanted = [...new Set(
|
|
3413
|
+
selectPages = (project, spec10) => {
|
|
3414
|
+
if (spec10 === "all") return project.manifest.pages.map((page2) => page2.id);
|
|
3415
|
+
const wanted = [...new Set(spec10.split(",").map((id2) => id2.trim()).filter(Boolean))];
|
|
3416
3416
|
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"));
|
|
3417
3417
|
for (const id2 of wanted) project.page(id2);
|
|
3418
3418
|
return wanted;
|
|
@@ -3440,9 +3440,9 @@ var init_core = __esm({
|
|
|
3440
3440
|
init_template_plugins();
|
|
3441
3441
|
init_page_select();
|
|
3442
3442
|
DIR = { flag: "--dir", required: true };
|
|
3443
|
-
onProject = (
|
|
3444
|
-
spec: { ...
|
|
3445
|
-
run: async (args2, rt) =>
|
|
3443
|
+
onProject = (spec10, run7) => ({
|
|
3444
|
+
spec: { ...spec10, options: [DIR, ...spec10.options ?? []] },
|
|
3445
|
+
run: async (args2, rt) => run7(await Project.load(rt, args2.req("dir")), args2, rt)
|
|
3446
3446
|
});
|
|
3447
3447
|
init = () => ({
|
|
3448
3448
|
spec: {
|
|
@@ -3541,9 +3541,9 @@ var init_core = __esm({
|
|
|
3541
3541
|
build = () => onProject(
|
|
3542
3542
|
{ 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" }] },
|
|
3543
3543
|
async (project, args2, rt) => {
|
|
3544
|
-
const
|
|
3545
|
-
printJson(rt, { ok: true, build:
|
|
3546
|
-
return
|
|
3544
|
+
const report4 = await buildProject(project, args2.flag("concept-off"));
|
|
3545
|
+
printJson(rt, { ok: true, build: report4 }, true);
|
|
3546
|
+
return report4.structureReady ? 0 : 2;
|
|
3547
3547
|
}
|
|
3548
3548
|
);
|
|
3549
3549
|
doctorCommand = () => onProject({ description: msg("project and environment report", "\u5DE5\u7A0B\u4E0E\u73AF\u5883\u62A5\u544A") }, async (project, _args, rt) => {
|
|
@@ -3956,9 +3956,9 @@ var init_workflow = __esm({
|
|
|
3956
3956
|
return fail(rt, failureText(error2));
|
|
3957
3957
|
}
|
|
3958
3958
|
};
|
|
3959
|
-
onProject2 = (
|
|
3960
|
-
spec: { ...
|
|
3961
|
-
run: reporting(async (args2, rt) =>
|
|
3959
|
+
onProject2 = (spec10, run7) => ({
|
|
3960
|
+
spec: { ...spec10, options: [DIR2, ...spec10.options ?? []] },
|
|
3961
|
+
run: reporting(async (args2, rt) => run7(await Project.load(rt, args2.req("dir")), args2, rt))
|
|
3962
3962
|
});
|
|
3963
3963
|
PROFILE_FILE = "template-profile.json";
|
|
3964
3964
|
templateProfile = () => onProject2(
|
|
@@ -4655,8 +4655,8 @@ var init_agents = __esm({
|
|
|
4655
4655
|
label: "Copilot CLI",
|
|
4656
4656
|
homes: (rt, home) => [env(rt, "COPILOT_HOME") ?? rt.path.join(home, ".copilot")],
|
|
4657
4657
|
skillsDir: (rt, home) => {
|
|
4658
|
-
const
|
|
4659
|
-
return
|
|
4658
|
+
const moved2 = env(rt, "COPILOT_HOME");
|
|
4659
|
+
return moved2 ? rt.path.join(moved2, "skills") : sharedSkillsDir(rt, home);
|
|
4660
4660
|
},
|
|
4661
4661
|
env: ["COPILOT_CLI"]
|
|
4662
4662
|
},
|
|
@@ -4668,8 +4668,8 @@ var init_agents = __esm({
|
|
|
4668
4668
|
label: "DeepSeek Harness",
|
|
4669
4669
|
homes: (rt, home) => [env(rt, "DSH_HOME") ?? rt.path.join(home, ".dsh")],
|
|
4670
4670
|
skillsDir: (rt, home) => {
|
|
4671
|
-
const
|
|
4672
|
-
return
|
|
4671
|
+
const moved2 = env(rt, "DSH_AGENTS_HOME");
|
|
4672
|
+
return moved2 ? rt.path.join(moved2, "skills") : sharedSkillsDir(rt, home);
|
|
4673
4673
|
},
|
|
4674
4674
|
env: ["DSH_SHELL"]
|
|
4675
4675
|
},
|
|
@@ -5649,8 +5649,8 @@ var init_perform = __esm({
|
|
|
5649
5649
|
STAGING = ".popost-update-";
|
|
5650
5650
|
ASIDE = ".popost-old-";
|
|
5651
5651
|
QUIET = ["--no-fund", "--no-audit", "--loglevel=error"];
|
|
5652
|
-
updatePlan = async (rt, target2,
|
|
5653
|
-
const wanted =
|
|
5652
|
+
updatePlan = async (rt, target2, spec10) => {
|
|
5653
|
+
const wanted = spec10 === "latest" || parseVersion(spec10) ? spec10 : "latest";
|
|
5654
5654
|
const node2 = target2.install.execPath;
|
|
5655
5655
|
const staging = rt.path.join(rt.path.dirname(target2.root), `${STAGING}${rt.randomUUID().slice(0, 8)}`);
|
|
5656
5656
|
const staged = rt.platform === "win32" ? rt.path.join(staging, "node_modules", PACKAGE_NAME) : rt.path.join(staging, "lib", "node_modules", PACKAGE_NAME);
|
|
@@ -5701,13 +5701,13 @@ var init_perform = __esm({
|
|
|
5701
5701
|
return { reason: errorText(error2) };
|
|
5702
5702
|
}
|
|
5703
5703
|
};
|
|
5704
|
-
stage2 = async (rt, plan4,
|
|
5704
|
+
stage2 = async (rt, plan4, spec10, cwd, background2) => {
|
|
5705
5705
|
const viewed = await runStep(rt, plan4.view, cwd, NPM_QUERY_TIMEOUT_MS);
|
|
5706
5706
|
if ("reason" in viewed) return viewed;
|
|
5707
5707
|
if (viewed.code !== 0) return { reason: npmFailure(rt, viewed.code, viewed.stderr) };
|
|
5708
5708
|
const release = readRelease(viewed.stdout);
|
|
5709
|
-
if (!release ||
|
|
5710
|
-
return { reason: msg(`the registry has no entry for popost${
|
|
5709
|
+
if (!release || spec10 !== "latest" && release.version !== spec10)
|
|
5710
|
+
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`) };
|
|
5711
5711
|
const { version } = release;
|
|
5712
5712
|
if (compareVersions(parseVersion(version), parseVersion(VERSION)) <= 0) return { version };
|
|
5713
5713
|
if (background2 && release.deprecated)
|
|
@@ -5756,28 +5756,28 @@ var init_perform = __esm({
|
|
|
5756
5756
|
refreshSkill = async (rt, argv, cwd) => {
|
|
5757
5757
|
try {
|
|
5758
5758
|
const result = await rt.programs.run(argv, { cwd, timeoutMs: NPM_INSTALL_TIMEOUT_MS });
|
|
5759
|
-
let
|
|
5759
|
+
let report4;
|
|
5760
5760
|
try {
|
|
5761
5761
|
const { next: _next, skipped: skipped2, ...rest } = JSON.parse(new TextDecoder().decode(result.stdout));
|
|
5762
|
-
|
|
5762
|
+
report4 = { ...rest, ...Array.isArray(skipped2) ? { skipped: skipped2.map((entry2) => entry2?.agent) } : {} };
|
|
5763
5763
|
} catch {
|
|
5764
|
-
|
|
5764
|
+
report4 = void 0;
|
|
5765
5765
|
}
|
|
5766
|
-
if (result.code === 0 &&
|
|
5767
|
-
return { ok: false, ...
|
|
5766
|
+
if (result.code === 0 && report4?.ok === true) return { ok: true, report: report4 };
|
|
5767
|
+
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`) };
|
|
5768
5768
|
} catch (error2) {
|
|
5769
5769
|
return { ok: false, reason: errorText(error2) };
|
|
5770
5770
|
}
|
|
5771
5771
|
};
|
|
5772
|
-
runUpdate = async (rt, target2,
|
|
5773
|
-
const plan4 = await updatePlan(rt, target2,
|
|
5772
|
+
runUpdate = async (rt, target2, spec10, options) => {
|
|
5773
|
+
const plan4 = await updatePlan(rt, target2, spec10);
|
|
5774
5774
|
const cwd = rt.homeDir ?? rt.cwd;
|
|
5775
5775
|
let version = VERSION;
|
|
5776
5776
|
let checked2;
|
|
5777
5777
|
if (!options.skipNpm) {
|
|
5778
5778
|
await clearLeftovers(rt, rt.path.dirname(target2.root));
|
|
5779
5779
|
try {
|
|
5780
|
-
const staged = await stage2(rt, plan4,
|
|
5780
|
+
const staged = await stage2(rt, plan4, spec10, cwd, options.background === true);
|
|
5781
5781
|
if ("reason" in staged) return { status: "failed", reason: staged.reason, ...staged.deprecated ? { deprecated: true } : {} };
|
|
5782
5782
|
if (staged.version !== VERSION && compareVersions(parseVersion(staged.version), parseVersion(VERSION)) > 0) {
|
|
5783
5783
|
const held = await options.holdSwap?.();
|
|
@@ -5799,8 +5799,8 @@ var init_perform = __esm({
|
|
|
5799
5799
|
if (!skill.ok) return { status: "skill-failed", version, reason: skill.reason ?? "", ...skill.report ? { install: skill.report } : {}, ...how };
|
|
5800
5800
|
return { status: "ok", version, install: skill.report ?? {}, ...how };
|
|
5801
5801
|
};
|
|
5802
|
-
performUpdate = async (rt, target2,
|
|
5803
|
-
const outcome = await runUpdate(rt, target2,
|
|
5802
|
+
performUpdate = async (rt, target2, spec10, options = {}) => {
|
|
5803
|
+
const outcome = await runUpdate(rt, target2, spec10, options);
|
|
5804
5804
|
return outcome.status === "ok" ? outcome : { ...outcome, reason: safeText(rt, outcome.reason) };
|
|
5805
5805
|
};
|
|
5806
5806
|
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");
|
|
@@ -6248,8 +6248,8 @@ var init_decimal = __esm({
|
|
|
6248
6248
|
const negative = this.int < 0n;
|
|
6249
6249
|
const digits = (negative ? -this.int : this.int).toString().padStart(this.scale + 1, "0");
|
|
6250
6250
|
const head = digits.slice(0, digits.length - this.scale);
|
|
6251
|
-
const
|
|
6252
|
-
return `${negative ? "-" : ""}${head}${
|
|
6251
|
+
const tail4 = this.scale ? `.${digits.slice(digits.length - this.scale)}` : "";
|
|
6252
|
+
return `${negative ? "-" : ""}${head}${tail4}`;
|
|
6253
6253
|
}
|
|
6254
6254
|
};
|
|
6255
6255
|
decimalOf = (value) => typeof value === "string" || typeof value === "number" ? Decimal.parse(String(value)) : null;
|
|
@@ -7621,7 +7621,7 @@ var init_context = __esm({
|
|
|
7621
7621
|
return inside6 !== null && await isFile(rt, inside6) ? inside6 : null;
|
|
7622
7622
|
};
|
|
7623
7623
|
jobIdOf = (entry2) => entry2.purpose === "composition" ? "composition" : entry2.id;
|
|
7624
|
-
wantedPages = (
|
|
7624
|
+
wantedPages = (spec10) => typeof spec10.pages === "number" ? Array.from({ length: spec10.pages }, (_, index) => `p${index + 1}`) : spec10.pages ?? [];
|
|
7625
7625
|
pagePlan = (ctx) => {
|
|
7626
7626
|
const existing = ctx.project ? ctx.project.manifest.pages.map((page2) => page2.id) : ["p1"];
|
|
7627
7627
|
const add2 = wantedPages(ctx.spec).filter((id2) => !existing.includes(id2));
|
|
@@ -7690,31 +7690,31 @@ var init_check2 = __esm({
|
|
|
7690
7690
|
throw error2;
|
|
7691
7691
|
}
|
|
7692
7692
|
};
|
|
7693
|
-
checkProject = (ctx, opened,
|
|
7694
|
-
const { spec:
|
|
7695
|
-
if (opened.problem)
|
|
7696
|
-
if (!ctx.project && !opened.problem &&
|
|
7697
|
-
if (ctx.project &&
|
|
7698
|
-
|
|
7693
|
+
checkProject = (ctx, opened, report4) => {
|
|
7694
|
+
const { spec: spec10 } = ctx;
|
|
7695
|
+
if (opened.problem) report4("dir", opened.problem);
|
|
7696
|
+
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"));
|
|
7697
|
+
if (ctx.project && spec10.mode !== void 0 && spec10.mode !== ctx.project.manifest.mode)
|
|
7698
|
+
report4(
|
|
7699
7699
|
"mode",
|
|
7700
7700
|
msg(
|
|
7701
7701
|
`the project already exists as "${ctx.project.manifest.mode}" and its mode cannot change: remove "mode" or set it to "${ctx.project.manifest.mode}"`,
|
|
7702
7702
|
`\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}"`
|
|
7703
7703
|
)
|
|
7704
7704
|
);
|
|
7705
|
-
if (!ctx.project && Array.isArray(
|
|
7706
|
-
if (
|
|
7705
|
+
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"'));
|
|
7706
|
+
if (spec10.quote === true && !spec10.images.length) report4("quote", msg("there are no images to quote", "\u6CA1\u6709\u53EF\u62A5\u4EF7\u7684\u56FE\u7247"));
|
|
7707
7707
|
};
|
|
7708
|
-
checkReference = async (ctx, entry2,
|
|
7708
|
+
checkReference = async (ctx, entry2, report4) => {
|
|
7709
7709
|
const where3 = `references[${entry2.index}]`;
|
|
7710
7710
|
const read2 = await readNextToSpec(ctx, entry2.file);
|
|
7711
|
-
if ("problem" in read2)
|
|
7711
|
+
if ("problem" in read2) report4(`${where3}.file`, read2.problem);
|
|
7712
7712
|
else {
|
|
7713
7713
|
const problem4 = pictureProblem(read2.bytes, entry2.file);
|
|
7714
|
-
if (problem4)
|
|
7714
|
+
if (problem4) report4(`${where3}.file`, problem4);
|
|
7715
7715
|
}
|
|
7716
7716
|
const { final } = pagePlan(ctx);
|
|
7717
|
-
if (entry2.page !== void 0 && !final.includes(entry2.page))
|
|
7717
|
+
if (entry2.page !== void 0 && !final.includes(entry2.page)) report4(
|
|
7718
7718
|
`${where3}.page`,
|
|
7719
7719
|
msg(
|
|
7720
7720
|
`"${entry2.page}" is not a page of this project (pages: ${final.join(", ")})`,
|
|
@@ -7722,12 +7722,12 @@ var init_check2 = __esm({
|
|
|
7722
7722
|
)
|
|
7723
7723
|
);
|
|
7724
7724
|
};
|
|
7725
|
-
checkFonts = async (ctx,
|
|
7725
|
+
checkFonts = async (ctx, report4) => {
|
|
7726
7726
|
if (!ctx.spec.fonts.length) return;
|
|
7727
7727
|
try {
|
|
7728
7728
|
const known2 = (await loadLibrary(ctx.rt)).palette.roles.map((role) => role.id);
|
|
7729
7729
|
const unknown = ctx.spec.fonts.filter((role) => !known2.includes(role));
|
|
7730
|
-
if (unknown.length)
|
|
7730
|
+
if (unknown.length) report4(
|
|
7731
7731
|
"fonts",
|
|
7732
7732
|
msg(
|
|
7733
7733
|
`unknown font roles: ${unknown.join(", ")} (popost font list shows the available ones)`,
|
|
@@ -7735,7 +7735,7 @@ var init_check2 = __esm({
|
|
|
7735
7735
|
)
|
|
7736
7736
|
);
|
|
7737
7737
|
} catch (error2) {
|
|
7738
|
-
|
|
7738
|
+
report4("fonts", errorText(error2));
|
|
7739
7739
|
}
|
|
7740
7740
|
};
|
|
7741
7741
|
readPlan = async (ctx, file) => {
|
|
@@ -7748,16 +7748,16 @@ var init_check2 = __esm({
|
|
|
7748
7748
|
return { problem: msg(`${file} is not valid JSON (${detail2})`, `${file} \u4E0D\u662F\u5408\u6CD5\u7684 JSON\uFF08${detail2}\uFF09`) };
|
|
7749
7749
|
}
|
|
7750
7750
|
};
|
|
7751
|
-
checkPlan = async (ctx,
|
|
7751
|
+
checkPlan = async (ctx, report4) => {
|
|
7752
7752
|
if (ctx.spec.plan === void 0) return;
|
|
7753
7753
|
const read2 = await readPlan(ctx, ctx.spec.plan);
|
|
7754
|
-
if ("problem" in read2) return
|
|
7754
|
+
if ("problem" in read2) return report4("plan", read2.problem);
|
|
7755
7755
|
const { final } = pagePlan(ctx);
|
|
7756
7756
|
const orderHint = msg(
|
|
7757
7757
|
` (the project will have: ${final.join(", ")}; set "pages" to match the plan)`,
|
|
7758
7758
|
`\uFF08\u9879\u76EE\u5C06\u6709\u7684\u9875\uFF1A${final.join(", ")}\uFF1B\u8BF7\u628A "pages" \u8BBE\u6210\u4E0E plan \u4E00\u81F4\uFF09`
|
|
7759
7759
|
);
|
|
7760
|
-
for (const message2 of validate(read2.plan, final, orderHint))
|
|
7760
|
+
for (const message2 of validate(read2.plan, final, orderHint)) report4("plan", message2);
|
|
7761
7761
|
};
|
|
7762
7762
|
registeredRoles = (ctx) => /* @__PURE__ */ new Set([...ctx.project ? registeredReferences(ctx.project).map((ref) => ref.role) : [], ...ctx.spec.references.map((ref) => ref.role)]);
|
|
7763
7763
|
noReference = (token) => {
|
|
@@ -7768,28 +7768,28 @@ var init_check2 = __esm({
|
|
|
7768
7768
|
`"${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`
|
|
7769
7769
|
);
|
|
7770
7770
|
};
|
|
7771
|
-
checkRefToken = async (ctx, token, where3,
|
|
7771
|
+
checkRefToken = async (ctx, token, where3, report4) => {
|
|
7772
7772
|
if (token === REF_ALL || REF_ROLES.includes(token)) {
|
|
7773
7773
|
const roles = registeredRoles(ctx);
|
|
7774
7774
|
const have = token === REF_ALL ? roles.size > 0 : roles.has(token);
|
|
7775
|
-
if (!have)
|
|
7775
|
+
if (!have) report4(where3, noReference(token));
|
|
7776
7776
|
return;
|
|
7777
7777
|
}
|
|
7778
7778
|
const found = await locateRef(ctx, token);
|
|
7779
|
-
if (found === null) return
|
|
7779
|
+
if (found === null) return report4(where3, msg(`picture not found: ${token}`, `\u627E\u4E0D\u5230\u56FE\u7247\uFF1A${token}`));
|
|
7780
7780
|
const problem4 = pictureProblem(await ctx.rt.fs.readFile(found), token);
|
|
7781
|
-
if (problem4)
|
|
7781
|
+
if (problem4) report4(where3, problem4);
|
|
7782
7782
|
};
|
|
7783
7783
|
twinKey = (prompt, entry2) => JSON.stringify([normalizePrompt(prompt), entry2.aspect ?? null, entry2.ref]);
|
|
7784
|
-
checkImage = async (ctx, entry2, seen,
|
|
7784
|
+
checkImage = async (ctx, entry2, seen, report4) => {
|
|
7785
7785
|
const where3 = `images[${entry2.index}]`;
|
|
7786
7786
|
const read2 = await readNextToSpec(ctx, entry2.promptFile);
|
|
7787
|
-
if ("problem" in read2)
|
|
7787
|
+
if ("problem" in read2) report4(`${where3}.promptFile`, read2.problem);
|
|
7788
7788
|
else {
|
|
7789
7789
|
const key2 = twinKey(new TextDecoder().decode(read2.bytes), entry2);
|
|
7790
7790
|
const twin = seen.get(key2);
|
|
7791
7791
|
if (twin)
|
|
7792
|
-
|
|
7792
|
+
report4(
|
|
7793
7793
|
where3,
|
|
7794
7794
|
msg(
|
|
7795
7795
|
`"${entry2.id}" asks for the same picture as "${twin}" (same prompt, aspect and references): keep one, or change the prompt of the other`,
|
|
@@ -7798,9 +7798,9 @@ var init_check2 = __esm({
|
|
|
7798
7798
|
);
|
|
7799
7799
|
seen.set(key2, entry2.id);
|
|
7800
7800
|
}
|
|
7801
|
-
for (const token of entry2.ref) await checkRefToken(ctx, token, `${where3}.ref`,
|
|
7801
|
+
for (const token of entry2.ref) await checkRefToken(ctx, token, `${where3}.ref`, report4);
|
|
7802
7802
|
const mode = ctx.project?.manifest.mode ?? ctx.spec.mode ?? "original";
|
|
7803
|
-
if (entry2.purpose === "composition" && mode === "strict")
|
|
7803
|
+
if (entry2.purpose === "composition" && mode === "strict") report4(
|
|
7804
7804
|
`${where3}.purpose`,
|
|
7805
7805
|
msg(
|
|
7806
7806
|
"a strict (reproduction) project has no composition job: it uses the supplied references",
|
|
@@ -7810,13 +7810,13 @@ var init_check2 = __esm({
|
|
|
7810
7810
|
};
|
|
7811
7811
|
checkSpec = async (ctx, opened) => {
|
|
7812
7812
|
const problems2 = [];
|
|
7813
|
-
const
|
|
7814
|
-
checkProject(ctx, opened,
|
|
7815
|
-
for (const entry2 of ctx.spec.references) await checkReference(ctx, entry2,
|
|
7816
|
-
await checkFonts(ctx,
|
|
7817
|
-
await checkPlan(ctx,
|
|
7813
|
+
const report4 = (where3, message2) => void problems2.push(`${where3}: ${message2}`);
|
|
7814
|
+
checkProject(ctx, opened, report4);
|
|
7815
|
+
for (const entry2 of ctx.spec.references) await checkReference(ctx, entry2, report4);
|
|
7816
|
+
await checkFonts(ctx, report4);
|
|
7817
|
+
await checkPlan(ctx, report4);
|
|
7818
7818
|
const seen = /* @__PURE__ */ new Map();
|
|
7819
|
-
for (const entry2 of ctx.spec.images) await checkImage(ctx, entry2, seen,
|
|
7819
|
+
for (const entry2 of ctx.spec.images) await checkImage(ctx, entry2, seen, report4);
|
|
7820
7820
|
return problems2;
|
|
7821
7821
|
};
|
|
7822
7822
|
}
|
|
@@ -7937,9 +7937,9 @@ var init_cli_args = __esm({
|
|
|
7937
7937
|
"use strict";
|
|
7938
7938
|
init_args();
|
|
7939
7939
|
init_i18n();
|
|
7940
|
-
joinSpacedValues = (argv,
|
|
7941
|
-
const known2 = new Set((
|
|
7942
|
-
const single = new Set((
|
|
7940
|
+
joinSpacedValues = (argv, spec10) => {
|
|
7941
|
+
const known2 = new Set((spec10.options ?? []).map((o) => o.flag));
|
|
7942
|
+
const single = new Set((spec10.options ?? []).filter((o) => o.kind === void 0 || o.kind === "string" || o.kind === "append").map((o) => o.flag));
|
|
7943
7943
|
const out2 = [];
|
|
7944
7944
|
for (let i = 0; i < argv.length; i++) {
|
|
7945
7945
|
const token = argv[i];
|
|
@@ -7961,20 +7961,20 @@ var init_cli_args = __esm({
|
|
|
7961
7961
|
if (key2 !== void 0 && !IDEMPOTENCY.test(key2))
|
|
7962
7962
|
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 . _ -"));
|
|
7963
7963
|
};
|
|
7964
|
-
withProviderArgs = async (argv,
|
|
7964
|
+
withProviderArgs = async (argv, spec10, rt, body) => {
|
|
7965
7965
|
let args2;
|
|
7966
7966
|
try {
|
|
7967
|
-
args2 = parseArgs(joinSpacedValues(argv,
|
|
7967
|
+
args2 = parseArgs(joinSpacedValues(argv, spec10), spec10);
|
|
7968
7968
|
if (!args2.help) checkCustomTypes(args2);
|
|
7969
7969
|
} catch (error2) {
|
|
7970
7970
|
if (!(error2 instanceof UsageError)) throw error2;
|
|
7971
|
-
rt.stderr(`usage: ${
|
|
7972
|
-
${
|
|
7971
|
+
rt.stderr(`usage: ${spec10.prog} [-h] ...
|
|
7972
|
+
${spec10.prog}: error: ${error2.message}
|
|
7973
7973
|
`);
|
|
7974
7974
|
return 2;
|
|
7975
7975
|
}
|
|
7976
7976
|
if (args2.help) {
|
|
7977
|
-
rt.stdout(formatHelp(
|
|
7977
|
+
rt.stdout(formatHelp(spec10));
|
|
7978
7978
|
return 0;
|
|
7979
7979
|
}
|
|
7980
7980
|
return body(args2);
|
|
@@ -8190,32 +8190,32 @@ var init_cli_quote = __esm({
|
|
|
8190
8190
|
return refs;
|
|
8191
8191
|
};
|
|
8192
8192
|
serverQuote = async (prov, model, aspect, count5, refs, allowFree, recheck = false) => {
|
|
8193
|
-
let
|
|
8193
|
+
let quote16;
|
|
8194
8194
|
try {
|
|
8195
|
-
|
|
8195
|
+
quote16 = await prov.quote({ model, aspect, count: count5, refs, recheck });
|
|
8196
8196
|
} catch (error2) {
|
|
8197
8197
|
if (error2 instanceof CapabilityError) throw new CliReject(2, error2.message);
|
|
8198
8198
|
if (error2 instanceof ImageProviderError)
|
|
8199
8199
|
throw new CliReject(exitCodeOf(error2), msg(`${error2.message} (nothing was submitted or charged)`, `${error2.message}\uFF08\u672A\u63D0\u4EA4\u3001\u672A\u6263\u8D39\uFF09`));
|
|
8200
8200
|
throw error2;
|
|
8201
8201
|
}
|
|
8202
|
-
const unit = parseCredits(
|
|
8203
|
-
const total2 = parseCredits(
|
|
8204
|
-
if (
|
|
8202
|
+
const unit = parseCredits(quote16.creditsPerImage, allowFree);
|
|
8203
|
+
const total2 = parseCredits(quote16.totalCredits, allowFree);
|
|
8204
|
+
if (quote16.sufficient === false)
|
|
8205
8205
|
throw new CliReject(
|
|
8206
8206
|
1,
|
|
8207
8207
|
msg(
|
|
8208
|
-
`Not enough credits: this needs ${total2} credits (${unit} per image) and the balance is ${
|
|
8209
|
-
`\u79EF\u5206\u4E0D\u8DB3\uFF1A\u672C\u6B21\u9700\u8981 ${total2} \u79EF\u5206\uFF08\u6BCF\u5F20 ${unit}\uFF09\uFF0C\u5F53\u524D\u4F59\u989D ${
|
|
8208
|
+
`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`,
|
|
8209
|
+
`\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`
|
|
8210
8210
|
),
|
|
8211
|
-
{ billing: { model:
|
|
8211
|
+
{ billing: { model: quote16.model, count: count5, creditsPerImage: String(unit), totalCredits: String(total2), balance: quote16.balance, sufficient: false, charged: false } }
|
|
8212
8212
|
);
|
|
8213
|
-
return { quote:
|
|
8213
|
+
return { quote: quote16, unit, total: total2 };
|
|
8214
8214
|
};
|
|
8215
8215
|
isFree = (ctx, pcfg, row) => Boolean(row?.free || pcfg.free || ctx.cfg.freeExplicit);
|
|
8216
8216
|
priceOnPlatform = async (ctx, prov, pcfg, a, count5, refs) => {
|
|
8217
|
-
const { quote:
|
|
8218
|
-
return { model:
|
|
8217
|
+
const { quote: quote16, unit, total: total2 } = await serverQuote(prov, a.model, a.aspectRatio, count5, refs, isFree(ctx, pcfg));
|
|
8218
|
+
return { model: quote16.model, label: quote16.label, unit, total: total2, billingUnit: "credits", priceSource: "popost.ai /images/quote", extraBilling: { balance: quote16.balance, sufficient: quote16.sufficient } };
|
|
8219
8219
|
};
|
|
8220
8220
|
priceByoK = async (ctx, name, pcfg, a, count5) => {
|
|
8221
8221
|
const prov = makeProvider(ctx, name);
|
|
@@ -8421,14 +8421,14 @@ var init_cli_generate = __esm({
|
|
|
8421
8421
|
const snapUnit = record2.pricingSnapshot.unitCredits === null ? null : decimalOf(record2.pricingSnapshot.unitCredits);
|
|
8422
8422
|
const count5 = Number(record2.count);
|
|
8423
8423
|
if (prov instanceof PopostProvider) {
|
|
8424
|
-
const { quote:
|
|
8424
|
+
const { quote: quote16, unit: unit2, total: total2 } = await serverQuote(prov, record2.model, record2.aspect, count5, refs, isFree(ctx, pcfg), true);
|
|
8425
8425
|
const quotedTotal = record2.totalCredits ? decimalOf(record2.totalCredits) : null;
|
|
8426
|
-
if (
|
|
8426
|
+
if (quote16.model !== record2.model)
|
|
8427
8427
|
throw new CliReject(
|
|
8428
8428
|
1,
|
|
8429
8429
|
msg(
|
|
8430
|
-
`the platform priced model ${
|
|
8431
|
-
`\u5E73\u53F0\u62A5\u4EF7\u6A21\u578B ${
|
|
8430
|
+
`the platform priced model ${quote16.model}, but the quote is bound to ${record2.model}; stop and quote again`,
|
|
8431
|
+
`\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`
|
|
8432
8432
|
)
|
|
8433
8433
|
);
|
|
8434
8434
|
if (!sameDecimal(unit2, snapUnit) || !sameDecimal(total2, quotedTotal)) {
|
|
@@ -8441,7 +8441,7 @@ var init_cli_generate = __esm({
|
|
|
8441
8441
|
)
|
|
8442
8442
|
);
|
|
8443
8443
|
}
|
|
8444
|
-
return { options: { idempotencyKey: idempotencyKey(a, record2), maxCredits: record2.totalCredits }, unit: unit2, total: total2, extraBilling: { balanceBefore:
|
|
8444
|
+
return { options: { idempotencyKey: idempotencyKey(a, record2), maxCredits: record2.totalCredits }, unit: unit2, total: total2, extraBilling: { balanceBefore: quote16.balance } };
|
|
8445
8445
|
}
|
|
8446
8446
|
const row = (await prov.models()).find((r) => r.value === record2.model);
|
|
8447
8447
|
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`));
|
|
@@ -8853,10 +8853,10 @@ commands: ${NAMES.join(", ")}
|
|
|
8853
8853
|
if (name === void 0) return usageError(rt, "the following arguments are required: cmd");
|
|
8854
8854
|
const command2 = NAMES.find((n) => n === name);
|
|
8855
8855
|
if (!command2) return usageError(rt, `argument cmd: invalid choice: '${name}' (choose from ${NAMES.map((n) => `'${n}'`).join(", ")})`);
|
|
8856
|
-
const
|
|
8856
|
+
const spec10 = { prog: `${PROG} ${command2}`, ...specs()[command2] };
|
|
8857
8857
|
return withProviderArgs(
|
|
8858
8858
|
rest,
|
|
8859
|
-
|
|
8859
|
+
spec10,
|
|
8860
8860
|
rt,
|
|
8861
8861
|
async (a) => print(rt, await executeCli(rt, { provider: globals.string("provider"), config: globals.string("config"), globals: globalsOf(a), command: commandOf(command2, a) }))
|
|
8862
8862
|
);
|
|
@@ -8875,7 +8875,7 @@ var init_retry = __esm({
|
|
|
8875
8875
|
init_i18n();
|
|
8876
8876
|
ledgerPathOf2 = (project) => resolvePath(project.rt, project.rt.path.join(project.root, "production", "ledger.jsonl"));
|
|
8877
8877
|
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");
|
|
8878
|
-
refusedUncharged = (
|
|
8878
|
+
refusedUncharged = (attempt3) => (attempt3.state === "ambiguous" || attempt3.state === "refunded") && attempt3.charged === false;
|
|
8879
8879
|
submissionKey = async (project, job, call2) => {
|
|
8880
8880
|
const prior = await heldBy(project, job);
|
|
8881
8881
|
if (!prior) {
|
|
@@ -8912,8 +8912,8 @@ var init_retry = __esm({
|
|
|
8912
8912
|
if (job.runAttempted && !job.attemptedQuoteId && job.quoteId) job.attemptedQuoteId = job.quoteId;
|
|
8913
8913
|
};
|
|
8914
8914
|
recordRun = async (project, job, path4, quoteId2, wasAttempted) => {
|
|
8915
|
-
const
|
|
8916
|
-
if (quoteId2 &&
|
|
8915
|
+
const attempt3 = quoteId2 ? await attempt(project.rt, ledgerPathOf2(project), quoteId2) : null;
|
|
8916
|
+
if (quoteId2 && attempt3 && !refusedUncharged(attempt3)) job.attemptedQuoteId = quoteId2;
|
|
8917
8917
|
else if (wasAttempted) job.runAttempted = true;
|
|
8918
8918
|
else delete job.runAttempted;
|
|
8919
8919
|
await saveJob(project.rt, path4, job);
|
|
@@ -9192,9 +9192,9 @@ var init_batch_quote = __esm({
|
|
|
9192
9192
|
const price = billing2?.sufficient === false ? { credits: billing2.totalCredits ?? null, insufficient: true } : {};
|
|
9193
9193
|
return { row: { id: id2, ok: false, code, error: result.error, ...price }, balance: balanceOf(billing2) };
|
|
9194
9194
|
}
|
|
9195
|
-
const
|
|
9195
|
+
const quote16 = result.quote;
|
|
9196
9196
|
const billing = result.billing;
|
|
9197
|
-
const row = { id: id2, ok: true, quoteId:
|
|
9197
|
+
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 };
|
|
9198
9198
|
return { row, balance: balanceOf(billing) };
|
|
9199
9199
|
};
|
|
9200
9200
|
quoteOne = async (project, entry2, call2) => {
|
|
@@ -9389,8 +9389,8 @@ var init_prepare = __esm({
|
|
|
9389
9389
|
);
|
|
9390
9390
|
}
|
|
9391
9391
|
if (jobState(job) === "prepared") return true;
|
|
9392
|
-
const
|
|
9393
|
-
throw refusal2(project, id2, job,
|
|
9392
|
+
const attempt3 = job.quoteId ? await attempt(project.rt, ledgerPathOf2(project), job.quoteId) : null;
|
|
9393
|
+
throw refusal2(project, id2, job, attempt3 !== null && refusedUncharged(attempt3));
|
|
9394
9394
|
};
|
|
9395
9395
|
recordedGrid = (project) => {
|
|
9396
9396
|
const { grid } = project.manifest.concept;
|
|
@@ -9513,10 +9513,10 @@ var init_steps = __esm({
|
|
|
9513
9513
|
)
|
|
9514
9514
|
);
|
|
9515
9515
|
}
|
|
9516
|
-
const { rt, spec:
|
|
9517
|
-
if (
|
|
9518
|
-
const mode =
|
|
9519
|
-
const project = await Project.create(rt, ctx.dir,
|
|
9516
|
+
const { rt, spec: spec10 } = ctx;
|
|
9517
|
+
if (spec10.brief === void 0) throw new StepFailure(msg("brief is required to create the project", "\u521B\u5EFA\u9879\u76EE\u9700\u8981 brief"));
|
|
9518
|
+
const mode = spec10.mode ?? "original";
|
|
9519
|
+
const project = await Project.create(rt, ctx.dir, spec10.brief, mode, spec10.width, spec10.height);
|
|
9520
9520
|
await project.appendDesignNote(initDesignNote());
|
|
9521
9521
|
ctx.project = project;
|
|
9522
9522
|
const first = project.manifest.pages[0];
|
|
@@ -9585,18 +9585,18 @@ var init_steps = __esm({
|
|
|
9585
9585
|
};
|
|
9586
9586
|
fontsStep = async (ctx) => {
|
|
9587
9587
|
const project = projectOf(ctx);
|
|
9588
|
-
const
|
|
9589
|
-
for (const role of ctx.spec.fonts) if (!await isInstalled(project, role))
|
|
9590
|
-
if (!
|
|
9588
|
+
const missing5 = [];
|
|
9589
|
+
for (const role of ctx.spec.fonts) if (!await isInstalled(project, role)) missing5.push(role);
|
|
9590
|
+
if (!missing5.length)
|
|
9591
9591
|
return skipped(
|
|
9592
9592
|
msg(`font roles already installed: ${ctx.spec.fonts.join(", ")}`, `\u5B57\u4F53\u89D2\u8272\u5DF2\u5B89\u88C5\uFF1A${ctx.spec.fonts.join(", ")}`) + linksNote(project)
|
|
9593
9593
|
);
|
|
9594
|
-
const { result, fontLinks } = await installFonts(ctx.rt, project,
|
|
9594
|
+
const { result, fontLinks } = await installFonts(ctx.rt, project, missing5.join(","), true);
|
|
9595
9595
|
const { installed } = result;
|
|
9596
|
-
const kept3 = ctx.spec.fonts.length -
|
|
9596
|
+
const kept3 = ctx.spec.fonts.length - missing5.length;
|
|
9597
9597
|
const detail2 = msg(
|
|
9598
|
-
`installed ${
|
|
9599
|
-
`\u5DF2\u5B89\u88C5 ${
|
|
9598
|
+
`installed ${missing5.join(", ")}${kept3 ? `; ${kept3} already installed` : ""}`,
|
|
9599
|
+
`\u5DF2\u5B89\u88C5 ${missing5.join(", ")}${kept3 ? `\uFF1B${kept3} \u4E2A\u6B64\u524D\u5DF2\u5B89\u88C5` : ""}`
|
|
9600
9600
|
) + linksNote(project);
|
|
9601
9601
|
return done(detail2, [], cjkFontWarnings(project, installed.map((role) => role.id)), fontLinks);
|
|
9602
9602
|
};
|
|
@@ -9773,104 +9773,104 @@ var init_spec = __esm({
|
|
|
9773
9773
|
isObj = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9774
9774
|
at2 = (base, key2) => base ? `${base}.${key2}` : key2;
|
|
9775
9775
|
quoted2 = (values) => values.map((value) => `"${value}"`).join(", ");
|
|
9776
|
-
noExtraKeys = (obj3, allowed, base,
|
|
9777
|
-
for (const key2 of Object.keys(obj3)) if (!allowed.includes(key2))
|
|
9776
|
+
noExtraKeys = (obj3, allowed, base, report4) => {
|
|
9777
|
+
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`));
|
|
9778
9778
|
};
|
|
9779
|
-
readString = (obj3, key2, base,
|
|
9779
|
+
readString = (obj3, key2, base, report4, required2 = false) => {
|
|
9780
9780
|
const value = obj3[key2];
|
|
9781
9781
|
if (value === void 0) {
|
|
9782
|
-
if (required2)
|
|
9782
|
+
if (required2) report4(at2(base, key2), msg("required", "\u5FC5\u586B"));
|
|
9783
9783
|
return void 0;
|
|
9784
9784
|
}
|
|
9785
9785
|
if (typeof value !== "string" || !value.trim()) {
|
|
9786
|
-
|
|
9786
|
+
report4(at2(base, key2), msg("must be a non-empty string", "\u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32"));
|
|
9787
9787
|
return void 0;
|
|
9788
9788
|
}
|
|
9789
9789
|
return value;
|
|
9790
9790
|
};
|
|
9791
|
-
readEnum = (obj3, key2, allowed, base,
|
|
9792
|
-
const value = readString(obj3, key2, base,
|
|
9791
|
+
readEnum = (obj3, key2, allowed, base, report4) => {
|
|
9792
|
+
const value = readString(obj3, key2, base, report4);
|
|
9793
9793
|
if (value === void 0) return void 0;
|
|
9794
9794
|
if (allowed.includes(value)) return value;
|
|
9795
|
-
|
|
9795
|
+
report4(at2(base, key2), msg(`"${value}" is not one of ${quoted2(allowed)}`, `"${value}" \u4E0D\u5728\u53EF\u9009\u503C ${quoted2(allowed)} \u4E4B\u4E2D`));
|
|
9796
9796
|
return void 0;
|
|
9797
9797
|
};
|
|
9798
9798
|
MODE_ALIASES = { replicate: "strict", reproduce: "strict", create: "original" };
|
|
9799
|
-
readMode = (obj3,
|
|
9799
|
+
readMode = (obj3, report4) => {
|
|
9800
9800
|
const alias = typeof obj3.mode === "string" ? MODE_ALIASES[obj3.mode.trim().toLowerCase()] : void 0;
|
|
9801
|
-
return alias ?? readEnum(obj3, "mode", MODES, "",
|
|
9801
|
+
return alias ?? readEnum(obj3, "mode", MODES, "", report4);
|
|
9802
9802
|
};
|
|
9803
|
-
readInt = (obj3, key2, base,
|
|
9803
|
+
readInt = (obj3, key2, base, report4, min, max) => {
|
|
9804
9804
|
const value = obj3[key2];
|
|
9805
9805
|
if (value === void 0) return void 0;
|
|
9806
9806
|
if (typeof value === "number" && Number.isInteger(value) && value >= min && value <= max) return value;
|
|
9807
|
-
|
|
9807
|
+
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`));
|
|
9808
9808
|
return void 0;
|
|
9809
9809
|
};
|
|
9810
|
-
readBool = (obj3, key2,
|
|
9810
|
+
readBool = (obj3, key2, report4) => {
|
|
9811
9811
|
const value = obj3[key2];
|
|
9812
|
-
if (value !== void 0 && typeof value !== "boolean")
|
|
9812
|
+
if (value !== void 0 && typeof value !== "boolean") report4(key2, msg("must be true or false", "\u5FC5\u987B\u662F true \u6216 false"));
|
|
9813
9813
|
return typeof value === "boolean" ? value : void 0;
|
|
9814
9814
|
};
|
|
9815
|
-
readPages = (value,
|
|
9815
|
+
readPages = (value, report4) => {
|
|
9816
9816
|
if (value === void 0) return void 0;
|
|
9817
9817
|
if (typeof value === "number") {
|
|
9818
9818
|
if (Number.isInteger(value) && value >= 1 && value <= MAX_PAGES) return value;
|
|
9819
|
-
|
|
9819
|
+
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`));
|
|
9820
9820
|
return void 0;
|
|
9821
9821
|
}
|
|
9822
9822
|
if (!Array.isArray(value) || !value.length) {
|
|
9823
|
-
|
|
9823
|
+
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'));
|
|
9824
9824
|
return void 0;
|
|
9825
9825
|
}
|
|
9826
9826
|
const ids3 = value.filter((id2) => typeof id2 === "string" && SAFE_PAGE_ID.test(id2));
|
|
9827
|
-
if (ids3.length !== value.length)
|
|
9827
|
+
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"));
|
|
9828
9828
|
const twice = ids3.find((id2, index) => ids3.indexOf(id2) !== index);
|
|
9829
|
-
if (twice)
|
|
9830
|
-
if (value.length > MAX_PAGES)
|
|
9829
|
+
if (twice) report4("pages", msg(`page id "${twice}" is listed twice`, `\u9875 id "${twice}" \u91CD\u590D\u51FA\u73B0`));
|
|
9830
|
+
if (value.length > MAX_PAGES) report4("pages", msg(`at most ${MAX_PAGES} pages`, `\u6700\u591A ${MAX_PAGES} \u9875`));
|
|
9831
9831
|
return ids3.length === value.length && !twice ? ids3 : void 0;
|
|
9832
9832
|
};
|
|
9833
|
-
readSettings = (value,
|
|
9833
|
+
readSettings = (value, report4) => {
|
|
9834
9834
|
if (value === void 0) return void 0;
|
|
9835
9835
|
if (!isObj(value)) {
|
|
9836
|
-
|
|
9836
|
+
report4("settings", msg("must be an object", "\u5FC5\u987B\u662F\u5BF9\u8C61"));
|
|
9837
9837
|
return void 0;
|
|
9838
9838
|
}
|
|
9839
|
-
noExtraKeys(value, SETTINGS_KEYS, "settings",
|
|
9839
|
+
noExtraKeys(value, SETTINGS_KEYS, "settings", report4);
|
|
9840
9840
|
return {
|
|
9841
|
-
platform: readEnum(value, "platform", PLATFORMS2, "settings",
|
|
9842
|
-
language: readString(value, "language", "settings",
|
|
9843
|
-
channel: readEnum(value, "channel", CHANNELS, "settings",
|
|
9844
|
-
model: readString(value, "model", "settings",
|
|
9841
|
+
platform: readEnum(value, "platform", PLATFORMS2, "settings", report4),
|
|
9842
|
+
language: readString(value, "language", "settings", report4),
|
|
9843
|
+
channel: readEnum(value, "channel", CHANNELS, "settings", report4),
|
|
9844
|
+
model: readString(value, "model", "settings", report4)
|
|
9845
9845
|
};
|
|
9846
9846
|
};
|
|
9847
|
-
readFonts = (value,
|
|
9847
|
+
readFonts = (value, report4) => {
|
|
9848
9848
|
if (value === void 0) return [];
|
|
9849
9849
|
if (!Array.isArray(value) || !value.every((role) => typeof role === "string" && role.trim())) {
|
|
9850
|
-
|
|
9850
|
+
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"));
|
|
9851
9851
|
return [];
|
|
9852
9852
|
}
|
|
9853
9853
|
const roles = value.map((role) => role.trim());
|
|
9854
9854
|
const twice = roles.find((role, index) => roles.indexOf(role) !== index);
|
|
9855
|
-
if (twice)
|
|
9855
|
+
if (twice) report4("fonts", msg(`"${twice}" is listed twice`, `"${twice}" \u91CD\u590D\u51FA\u73B0`));
|
|
9856
9856
|
return [...new Set(roles)];
|
|
9857
9857
|
};
|
|
9858
|
-
readReference = (value, base,
|
|
9858
|
+
readReference = (value, base, report4) => {
|
|
9859
9859
|
if (!isObj(value)) {
|
|
9860
|
-
|
|
9860
|
+
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"}'));
|
|
9861
9861
|
return null;
|
|
9862
9862
|
}
|
|
9863
|
-
noExtraKeys(value, REFERENCE_KEYS, base,
|
|
9864
|
-
const file = readString(value, "file", base,
|
|
9865
|
-
const role = readEnum(value, "role", REF_ROLES, base,
|
|
9866
|
-
const page2 = readString(value, "page", base,
|
|
9863
|
+
noExtraKeys(value, REFERENCE_KEYS, base, report4);
|
|
9864
|
+
const file = readString(value, "file", base, report4, true);
|
|
9865
|
+
const role = readEnum(value, "role", REF_ROLES, base, report4) ?? "layout";
|
|
9866
|
+
const page2 = readString(value, "page", base, report4);
|
|
9867
9867
|
return file === void 0 ? null : { file, role, ...page2 === void 0 ? {} : { page: page2 } };
|
|
9868
9868
|
};
|
|
9869
|
-
readRefs = (value, base,
|
|
9869
|
+
readRefs = (value, base, report4) => {
|
|
9870
9870
|
if (value === void 0) return [];
|
|
9871
9871
|
const list7 = Array.isArray(value) ? value : [value];
|
|
9872
9872
|
if (!list7.length || !list7.every((ref) => typeof ref === "string" && ref.trim())) {
|
|
9873
|
-
|
|
9873
|
+
report4(
|
|
9874
9874
|
at2(base, "ref"),
|
|
9875
9875
|
msg(
|
|
9876
9876
|
"must be a role (layout, identity, style, content, all), a picture path, or a list of them",
|
|
@@ -9881,9 +9881,9 @@ var init_spec = __esm({
|
|
|
9881
9881
|
}
|
|
9882
9882
|
return list7;
|
|
9883
9883
|
};
|
|
9884
|
-
readImage = (value, base,
|
|
9884
|
+
readImage = (value, base, report4) => {
|
|
9885
9885
|
if (!isObj(value)) {
|
|
9886
|
-
|
|
9886
|
+
report4(
|
|
9887
9887
|
base,
|
|
9888
9888
|
msg(
|
|
9889
9889
|
'must be an object like {"id": "hero", "promptFile": "prompts/hero.md", "aspect": "9:16"}',
|
|
@@ -9892,66 +9892,66 @@ var init_spec = __esm({
|
|
|
9892
9892
|
);
|
|
9893
9893
|
return null;
|
|
9894
9894
|
}
|
|
9895
|
-
noExtraKeys(value, IMAGE_KEYS, base,
|
|
9896
|
-
const purpose = readEnum(value, "purpose", PURPOSES, base,
|
|
9897
|
-
const named = readString(value, "id", base,
|
|
9898
|
-
if (named !== void 0 && !JOB_ID.test(named))
|
|
9895
|
+
noExtraKeys(value, IMAGE_KEYS, base, report4);
|
|
9896
|
+
const purpose = readEnum(value, "purpose", PURPOSES, base, report4) ?? "material";
|
|
9897
|
+
const named = readString(value, "id", base, report4, purpose === "material");
|
|
9898
|
+
if (named !== void 0 && !JOB_ID.test(named)) report4(
|
|
9899
9899
|
at2(base, "id"),
|
|
9900
9900
|
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`)
|
|
9901
9901
|
);
|
|
9902
|
-
if (purpose === "material" && named === "composition")
|
|
9903
|
-
if (purpose === "composition" && named !== void 0 && named !== "composition")
|
|
9902
|
+
if (purpose === "material" && named === "composition") report4(at2(base, "id"), msg('"composition" is reserved for the composition job', '"composition" \u4FDD\u7559\u7ED9 composition \u4EFB\u52A1'));
|
|
9903
|
+
if (purpose === "composition" && named !== void 0 && named !== "composition") report4(
|
|
9904
9904
|
at2(base, "id"),
|
|
9905
9905
|
msg('the composition job is always called "composition": leave id out', 'composition \u4EFB\u52A1\u56FA\u5B9A\u53EB "composition"\uFF1A\u4E0D\u8981\u5199 id')
|
|
9906
9906
|
);
|
|
9907
|
-
const promptFile = readString(value, "promptFile", base,
|
|
9908
|
-
const aspect = readString(value, "aspect", base,
|
|
9909
|
-
if (aspect !== void 0 && !ASPECT4.test(aspect))
|
|
9910
|
-
const ref = readRefs(value.ref, base,
|
|
9907
|
+
const promptFile = readString(value, "promptFile", base, report4, true);
|
|
9908
|
+
const aspect = readString(value, "aspect", base, report4);
|
|
9909
|
+
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`));
|
|
9910
|
+
const ref = readRefs(value.ref, base, report4);
|
|
9911
9911
|
if (promptFile === void 0 || purpose === "material" && named === void 0) return null;
|
|
9912
9912
|
return { id: purpose === "composition" ? "composition" : named, promptFile, ...aspect === void 0 ? {} : { aspect }, purpose, ref };
|
|
9913
9913
|
};
|
|
9914
|
-
readList = (value, key2,
|
|
9914
|
+
readList = (value, key2, report4, read2) => {
|
|
9915
9915
|
if (value === void 0) return [];
|
|
9916
9916
|
if (!Array.isArray(value)) {
|
|
9917
|
-
|
|
9917
|
+
report4(key2, msg("must be a list", "\u5FC5\u987B\u662F\u5217\u8868"));
|
|
9918
9918
|
return [];
|
|
9919
9919
|
}
|
|
9920
9920
|
const entries3 = value.map((item2, index) => {
|
|
9921
|
-
const entry2 = read2(item2, `${key2}[${index}]`,
|
|
9921
|
+
const entry2 = read2(item2, `${key2}[${index}]`, report4);
|
|
9922
9922
|
return entry2 === null ? null : { ...entry2, index };
|
|
9923
9923
|
});
|
|
9924
9924
|
return entries3.filter((entry2) => entry2 !== null);
|
|
9925
9925
|
};
|
|
9926
|
-
reportRepeatedJobs = (images,
|
|
9926
|
+
reportRepeatedJobs = (images, report4) => {
|
|
9927
9927
|
const ids3 = images.map((image2) => image2.id);
|
|
9928
9928
|
const twice = ids3.find((id2, index) => ids3.indexOf(id2) !== index);
|
|
9929
|
-
if (twice)
|
|
9929
|
+
if (twice) report4("images", msg(`job id "${twice}" is used twice`, `\u4EFB\u52A1 id "${twice}" \u7528\u4E86\u4E24\u6B21`));
|
|
9930
9930
|
};
|
|
9931
9931
|
parseSpec = (raw) => {
|
|
9932
9932
|
const problems2 = [];
|
|
9933
|
-
const
|
|
9933
|
+
const report4 = (where3, message2) => void problems2.push(`${where3}: ${message2}`);
|
|
9934
9934
|
if (!isObj(raw)) {
|
|
9935
|
-
|
|
9935
|
+
report4("spec", msg("must be a JSON object (see popost setup --help)", "\u5FC5\u987B\u662F JSON \u5BF9\u8C61\uFF08\u89C1 popost setup --help\uFF09"));
|
|
9936
9936
|
return { spec: { references: [], fonts: [], images: [] }, problems: problems2, unusable: true };
|
|
9937
9937
|
}
|
|
9938
|
-
noExtraKeys(raw, SPEC_KEYS, "",
|
|
9939
|
-
const images = readList(raw.images, "images",
|
|
9940
|
-
reportRepeatedJobs(images,
|
|
9941
|
-
const
|
|
9942
|
-
brief: readString(raw, "brief", "",
|
|
9943
|
-
mode: readMode(raw,
|
|
9944
|
-
width: readInt(raw, "width", "",
|
|
9945
|
-
height: readInt(raw, "height", "",
|
|
9946
|
-
pages: readPages(raw.pages,
|
|
9947
|
-
settings: readSettings(raw.settings,
|
|
9948
|
-
references: readList(raw.references, "references",
|
|
9949
|
-
fonts: readFonts(raw.fonts,
|
|
9950
|
-
plan: readString(raw, "plan", "",
|
|
9938
|
+
noExtraKeys(raw, SPEC_KEYS, "", report4);
|
|
9939
|
+
const images = readList(raw.images, "images", report4, readImage);
|
|
9940
|
+
reportRepeatedJobs(images, report4);
|
|
9941
|
+
const spec10 = {
|
|
9942
|
+
brief: readString(raw, "brief", "", report4),
|
|
9943
|
+
mode: readMode(raw, report4),
|
|
9944
|
+
width: readInt(raw, "width", "", report4, 1, MAX_CANVAS),
|
|
9945
|
+
height: readInt(raw, "height", "", report4, 1, MAX_CANVAS),
|
|
9946
|
+
pages: readPages(raw.pages, report4),
|
|
9947
|
+
settings: readSettings(raw.settings, report4),
|
|
9948
|
+
references: readList(raw.references, "references", report4, readReference),
|
|
9949
|
+
fonts: readFonts(raw.fonts, report4),
|
|
9950
|
+
plan: readString(raw, "plan", "", report4),
|
|
9951
9951
|
images,
|
|
9952
|
-
quote: readBool(raw, "quote",
|
|
9952
|
+
quote: readBool(raw, "quote", report4)
|
|
9953
9953
|
};
|
|
9954
|
-
return { spec:
|
|
9954
|
+
return { spec: spec10, problems: problems2 };
|
|
9955
9955
|
};
|
|
9956
9956
|
}
|
|
9957
9957
|
});
|
|
@@ -10066,7 +10066,7 @@ var init_run2 = __esm({
|
|
|
10066
10066
|
runSetup = async (rt, call2) => {
|
|
10067
10067
|
const loaded = await loadSpec(rt, call2.specPath);
|
|
10068
10068
|
if ("error" in loaded) return refused2(loaded.error);
|
|
10069
|
-
const { spec:
|
|
10069
|
+
const { spec: spec10, problems: shape, unusable } = parseSpec(loaded.raw);
|
|
10070
10070
|
if (unusable)
|
|
10071
10071
|
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`), {
|
|
10072
10072
|
problems: shape
|
|
@@ -10074,7 +10074,7 @@ var init_run2 = __esm({
|
|
|
10074
10074
|
const opened = await openProject(rt, call2.dir);
|
|
10075
10075
|
const ctx = {
|
|
10076
10076
|
rt,
|
|
10077
|
-
spec:
|
|
10077
|
+
spec: spec10,
|
|
10078
10078
|
dir: call2.dir,
|
|
10079
10079
|
specDir: rt.path.dirname(rt.path.resolve(rt.cwd, call2.specPath)),
|
|
10080
10080
|
config: call2.config,
|
|
@@ -10779,11 +10779,11 @@ var init_push = __esm({
|
|
|
10779
10779
|
}
|
|
10780
10780
|
};
|
|
10781
10781
|
rateAware = async (rt, call2) => {
|
|
10782
|
-
for (let
|
|
10782
|
+
for (let attempt3 = 0; ; attempt3++) {
|
|
10783
10783
|
try {
|
|
10784
10784
|
return await call2();
|
|
10785
10785
|
} catch (error2) {
|
|
10786
|
-
if (!(error2 instanceof PopostApiError) || error2.code !== "RATE_LIMITED" ||
|
|
10786
|
+
if (!(error2 instanceof PopostApiError) || error2.code !== "RATE_LIMITED" || attempt3 >= RATE_RETRIES) throw error2;
|
|
10787
10787
|
const asked2 = Number(error2.details.retryAfterSeconds);
|
|
10788
10788
|
const seconds8 = Number.isFinite(asked2) && asked2 > 0 ? Math.min(asked2, MAX_WAIT_SEC) : 5;
|
|
10789
10789
|
await sleep(rt, Math.ceil(seconds8 * 1e3));
|
|
@@ -10918,14 +10918,14 @@ var init_push = __esm({
|
|
|
10918
10918
|
const uploads = { ids: /* @__PURE__ */ new Map(), reused: /* @__PURE__ */ new Set(), uploaded: 0 };
|
|
10919
10919
|
let reply = null;
|
|
10920
10920
|
let fresh = /* @__PURE__ */ new Set();
|
|
10921
|
-
for (let
|
|
10921
|
+
for (let attempt3 = 0; reply === null; attempt3++) {
|
|
10922
10922
|
try {
|
|
10923
10923
|
await ensureUploads(rt, client2, pictures, cache2, fresh, uploads);
|
|
10924
10924
|
const body = syncBody(project, exported.html, pictures, uploads.ids, options);
|
|
10925
10925
|
reply = parseReply(await rateAware(rt, () => client2.request("POST", "/projects/sync", { body, timeoutSec: SYNC_TIMEOUT_SEC })), client2.baseUrl);
|
|
10926
10926
|
} catch (error2) {
|
|
10927
10927
|
const stale = staleAssetIndexes(error2).flatMap((i) => pictures[i] ? [pictures[i].sha] : []);
|
|
10928
|
-
if (
|
|
10928
|
+
if (attempt3 === 0 && stale.length) {
|
|
10929
10929
|
for (const sha2 of stale) uploads.ids.delete(sha2);
|
|
10930
10930
|
fresh = new Set(stale);
|
|
10931
10931
|
continue;
|
|
@@ -11634,26 +11634,26 @@ var init_png = __esm({
|
|
|
11634
11634
|
};
|
|
11635
11635
|
renderPages = async (project, pids, outPaths = {}, force2 = false) => {
|
|
11636
11636
|
const { rt } = project;
|
|
11637
|
-
const
|
|
11637
|
+
const report4 = { paths: {}, rendered: [], unchanged: [] };
|
|
11638
11638
|
const pending3 = [];
|
|
11639
11639
|
for (const pid of pids) {
|
|
11640
11640
|
project.page(pid);
|
|
11641
11641
|
const out2 = outPaths[pid] ?? rt.path.join(project.exportsDir, `${pid}.png`);
|
|
11642
11642
|
const cached2 = force2 ? null : await cachedPng(project, pid, out2);
|
|
11643
11643
|
if (cached2) {
|
|
11644
|
-
|
|
11645
|
-
|
|
11644
|
+
report4.paths[pid] = cached2;
|
|
11645
|
+
report4.unchanged.push(pid);
|
|
11646
11646
|
} else pending3.push({ pid, out: out2 });
|
|
11647
11647
|
}
|
|
11648
|
-
if (!pending3.length) return
|
|
11648
|
+
if (!pending3.length) return report4;
|
|
11649
11649
|
await withBrowser(rt, async (browser) => {
|
|
11650
11650
|
for (const { pid, out: out2 } of pending3) {
|
|
11651
11651
|
await renderOne(project, browser, pid, out2);
|
|
11652
|
-
|
|
11653
|
-
|
|
11652
|
+
report4.paths[pid] = out2;
|
|
11653
|
+
report4.rendered.push(pid);
|
|
11654
11654
|
}
|
|
11655
11655
|
});
|
|
11656
|
-
return
|
|
11656
|
+
return report4;
|
|
11657
11657
|
};
|
|
11658
11658
|
renderPagesPng = async (project, pids, outPaths = {}, force2 = false) => (await renderPages(project, pids, outPaths, force2)).paths;
|
|
11659
11659
|
renderPagePng = async (project, pid, out2, force2 = false) => {
|
|
@@ -11742,9 +11742,9 @@ var init_subcommand = __esm({
|
|
|
11742
11742
|
"src/editor/subcommand.ts"() {
|
|
11743
11743
|
"use strict";
|
|
11744
11744
|
runSubcommand3 = async (rt, argv) => {
|
|
11745
|
-
const { run:
|
|
11745
|
+
const { run: run7 } = await Promise.resolve().then(() => (init_main2(), main_exports));
|
|
11746
11746
|
const out2 = [];
|
|
11747
|
-
const code = await
|
|
11747
|
+
const code = await run7(argv, { ...rt, stdout: (text13) => void out2.push(text13), stderr: () => void 0 });
|
|
11748
11748
|
try {
|
|
11749
11749
|
const parsed = JSON.parse(out2.join("").trim());
|
|
11750
11750
|
return { code, json: parsed && typeof parsed === "object" ? parsed : null };
|
|
@@ -11809,9 +11809,9 @@ var init_routes_get = __esm({
|
|
|
11809
11809
|
const html2 = editorHtml(await ctx.load(), source2, ctx.req.rawQuery, ctx.state.cloud.mode());
|
|
11810
11810
|
return noStoreResponse(html2, "text/html; charset=utf-8");
|
|
11811
11811
|
};
|
|
11812
|
-
staticFile = async (ctx, root, urlPath,
|
|
11812
|
+
staticFile = async (ctx, root, urlPath, missing5) => {
|
|
11813
11813
|
const file = await readProjectFile(ctx.rt, root, urlPath);
|
|
11814
|
-
return file ? fileResponse(file.data, mimeType(file.path)) : notFound(ctx,
|
|
11814
|
+
return file ? fileResponse(file.data, mimeType(file.path)) : notFound(ctx, missing5);
|
|
11815
11815
|
};
|
|
11816
11816
|
EXACT = {
|
|
11817
11817
|
"/api/export-options": exportOptions,
|
|
@@ -12197,10 +12197,10 @@ var init_server = __esm({
|
|
|
12197
12197
|
return state2;
|
|
12198
12198
|
};
|
|
12199
12199
|
createLock = () => {
|
|
12200
|
-
let
|
|
12200
|
+
let tail4 = Promise.resolve();
|
|
12201
12201
|
return (fn) => {
|
|
12202
|
-
const result =
|
|
12203
|
-
|
|
12202
|
+
const result = tail4.then(fn, fn);
|
|
12203
|
+
tail4 = result.catch(() => void 0);
|
|
12204
12204
|
return result;
|
|
12205
12205
|
};
|
|
12206
12206
|
};
|
|
@@ -12384,8 +12384,8 @@ var init_render = __esm({
|
|
|
12384
12384
|
};
|
|
12385
12385
|
};
|
|
12386
12386
|
syncDelivered = async (rt, project) => !commandSyncs(rt) ? void 0 : deliverToCloud(new CloudService(rt, () => project.root), project.manifest.language?.toLowerCase().startsWith("zh") ? "zh" : "en");
|
|
12387
|
-
rendering = (
|
|
12388
|
-
spec: { ...
|
|
12387
|
+
rendering = (spec10, prepare4 = false) => ({
|
|
12388
|
+
spec: { ...spec10, options: [DIR3, ...spec10.options ?? []] },
|
|
12389
12389
|
run: async (args2, rt) => {
|
|
12390
12390
|
const project = await Project.load(rt, args2.req("dir"));
|
|
12391
12391
|
let before = {};
|
|
@@ -12595,8 +12595,8 @@ var init_sheet_layout = __esm({
|
|
|
12595
12595
|
return taken;
|
|
12596
12596
|
};
|
|
12597
12597
|
const head = take(chars, room * 0.6);
|
|
12598
|
-
const
|
|
12599
|
-
return `${head.join("")}\u2026${
|
|
12598
|
+
const tail4 = take([...chars].reverse(), room * 0.4).reverse();
|
|
12599
|
+
return `${head.join("")}\u2026${tail4.join("")}`;
|
|
12600
12600
|
};
|
|
12601
12601
|
layoutSheet = (bands) => {
|
|
12602
12602
|
const groups2 = bands.filter((band) => band.length > 0);
|
|
@@ -12683,10 +12683,10 @@ var init_sheet2 = __esm({
|
|
|
12683
12683
|
}
|
|
12684
12684
|
return args2.has("labels") ? msg("--labels only goes with --files", "--labels \u53EA\u80FD\u914D\u5408 --files \u4F7F\u7528") : null;
|
|
12685
12685
|
};
|
|
12686
|
-
selectedPages = (project,
|
|
12686
|
+
selectedPages = (project, spec10) => {
|
|
12687
12687
|
const all = project.manifest.pages.map((page2) => page2.id);
|
|
12688
|
-
if (
|
|
12689
|
-
const wanted =
|
|
12688
|
+
if (spec10 === "all") return all;
|
|
12689
|
+
const wanted = spec10.split(",").map((id2) => id2.trim()).filter(Boolean);
|
|
12690
12690
|
const unknown = wanted.filter((id2) => !all.includes(id2));
|
|
12691
12691
|
if (unknown.length)
|
|
12692
12692
|
throw new ValueError(
|
|
@@ -12963,11 +12963,11 @@ var init_batch_run = __esm({
|
|
|
12963
12963
|
`${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`
|
|
12964
12964
|
);
|
|
12965
12965
|
standing = async (project, quoteId2) => {
|
|
12966
|
-
const
|
|
12967
|
-
if (
|
|
12968
|
-
if (
|
|
12969
|
-
if (
|
|
12970
|
-
if (
|
|
12966
|
+
const attempt3 = await attempt(project.rt, ledgerPathOf2(project), quoteId2).catch(() => null);
|
|
12967
|
+
if (attempt3?.state === "consumed") return { outcome: "failed", charged: true };
|
|
12968
|
+
if (attempt3?.state === "failed") return { outcome: "failed", charged: true };
|
|
12969
|
+
if (attempt3?.state === "submitted") return { outcome: "pending", charged: true };
|
|
12970
|
+
if (attempt3 && attempt3.charged !== false) return { outcome: "ambiguous", charged: "unknown" };
|
|
12971
12971
|
return { outcome: "failed", charged: false };
|
|
12972
12972
|
};
|
|
12973
12973
|
failedRow = async (project, entry2, quoteId2, code, error2) => ({
|
|
@@ -14115,8 +14115,8 @@ var init_inspiration_plan = __esm({
|
|
|
14115
14115
|
const b = bundle;
|
|
14116
14116
|
if (b.parseStatus !== "ready" && !options.allowIncomplete) {
|
|
14117
14117
|
const errorsOf = b.errors ?? [];
|
|
14118
|
-
const
|
|
14119
|
-
const detail2 = [...errorsOf, ...
|
|
14118
|
+
const missing5 = (b.missing ?? []).map((m) => msg(`missing ${m}`, `\u7F3A ${m}`));
|
|
14119
|
+
const detail2 = [...errorsOf, ...missing5].join(msg("; ", "\uFF1B")) || msg("no reason given", "\u672A\u8BF4\u660E");
|
|
14120
14120
|
throw new InputError(
|
|
14121
14121
|
msg(
|
|
14122
14122
|
`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`,
|
|
@@ -15749,7 +15749,7 @@ var init_browser = __esm({
|
|
|
15749
15749
|
for (const root of roots2) {
|
|
15750
15750
|
if (!existsSync(root)) continue;
|
|
15751
15751
|
for (const dir of readdirSync(root).filter((d) => /^chromium/.test(d)).sort().reverse())
|
|
15752
|
-
for (const
|
|
15752
|
+
for (const tail4 of tails) out2.push(path.join(root, dir, ...tail4));
|
|
15753
15753
|
}
|
|
15754
15754
|
return out2;
|
|
15755
15755
|
};
|
|
@@ -16091,8 +16091,8 @@ var init_chunks = __esm({
|
|
|
16091
16091
|
const last = out2[out2.length - 1];
|
|
16092
16092
|
return last && last[1] - last[0] < shortest ? [...out2.slice(0, -1), [last[0], end]] : [...out2, [bounds2[i], end]];
|
|
16093
16093
|
}, []);
|
|
16094
|
-
const
|
|
16095
|
-
const ranges =
|
|
16094
|
+
const tail4 = joined[joined.length - 1], before = joined[joined.length - 2];
|
|
16095
|
+
const ranges = tail4 && before && tail4[1] - tail4[0] < shortest ? [...joined.slice(0, -2), [before[0], tail4[1]]] : joined;
|
|
16096
16096
|
const longest = Math.max(shortest, Math.round(r.canvas.fps * MAX_CHUNK_SECONDS));
|
|
16097
16097
|
return ranges.flatMap(([from, to]) => {
|
|
16098
16098
|
const count5 = Math.ceil((to - from) / longest);
|
|
@@ -16350,9 +16350,9 @@ var init_motion = __esm({
|
|
|
16350
16350
|
return { blur: BLUR_START * (1 - e), opacity: e };
|
|
16351
16351
|
}
|
|
16352
16352
|
};
|
|
16353
|
-
motionState = (
|
|
16354
|
-
const eased =
|
|
16355
|
-
const partial = phase === "enter" ? entrance(
|
|
16353
|
+
motionState = (spec10, phase, t) => {
|
|
16354
|
+
const eased = spec10.preset === "type" ? clamp01(t) : ease(spec10.ease, t);
|
|
16355
|
+
const partial = phase === "enter" ? entrance(spec10, spec10.direction, eased) : entrance(spec10, OPPOSITE[spec10.direction], 1 - eased);
|
|
16356
16356
|
return { ...IDENTITY_ELEMENT, ...partial };
|
|
16357
16357
|
};
|
|
16358
16358
|
}
|
|
@@ -17371,38 +17371,38 @@ var init_check_footage = __esm({
|
|
|
17371
17371
|
const f = ctx.footage[id2];
|
|
17372
17372
|
return f && !("error" in f) ? f : void 0;
|
|
17373
17373
|
};
|
|
17374
|
-
runsOutAt = (ctx,
|
|
17374
|
+
runsOutAt = (ctx, spec10, f, span2) => {
|
|
17375
17375
|
const last = f.frames - 1;
|
|
17376
|
-
const raw = (n2) => (
|
|
17376
|
+
const raw = (n2) => (spec10.in ?? 0) + Math.round((n2 - span2.start) * f.fps * (spec10.speed ?? 1) / ctx.fps);
|
|
17377
17377
|
if (span2.end <= span2.start || raw(span2.end - 1) <= last) return void 0;
|
|
17378
17378
|
let n = span2.start;
|
|
17379
17379
|
while (raw(n) <= last) n++;
|
|
17380
17380
|
return n;
|
|
17381
17381
|
};
|
|
17382
17382
|
sourceText = (file, f) => '"' + (file ?? "?") + '" has ' + f.frames + " frames (" + (f.frames / f.fps).toFixed(2) + " s at " + Number(f.fps.toFixed(3)) + " fps)";
|
|
17383
|
-
soundProblems = (
|
|
17384
|
-
if (
|
|
17383
|
+
soundProblems = (spec10, f, id2, at7) => {
|
|
17384
|
+
if (spec10.audio === void 0 || spec10.audio === false) return [];
|
|
17385
17385
|
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.')];
|
|
17386
17386
|
return [];
|
|
17387
17387
|
};
|
|
17388
17388
|
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.")] : [];
|
|
17389
17389
|
SLOWED = 0.9;
|
|
17390
|
-
slowProblems = (
|
|
17390
|
+
slowProblems = (spec10, at7, what) => typeof spec10.speed === "number" && spec10.speed < SLOWED ? [warning(
|
|
17391
17391
|
at7 + ".speed",
|
|
17392
|
-
what + " plays at " +
|
|
17392
|
+
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.",
|
|
17393
17393
|
'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.'
|
|
17394
17394
|
)] : [];
|
|
17395
|
-
checkPlay = (ctx,
|
|
17395
|
+
checkPlay = (ctx, spec10, id2, at7, what, span2) => {
|
|
17396
17396
|
const m = ctx.materials.get(id2);
|
|
17397
17397
|
if (!m) return [];
|
|
17398
17398
|
if (m.kind !== "video")
|
|
17399
|
-
return FOOTAGE_KEYS.filter((k) =>
|
|
17399
|
+
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.'));
|
|
17400
17400
|
const f = factsOf(ctx, id2);
|
|
17401
|
-
if (!f) return slowProblems(
|
|
17402
|
-
const sound2 = [...slowProblems(
|
|
17403
|
-
if ((
|
|
17404
|
-
return [error(at7 + ".in", what + " starts at source frame " +
|
|
17405
|
-
const out2 = span2 ? runsOutAt(ctx,
|
|
17401
|
+
if (!f) return slowProblems(spec10, at7, what);
|
|
17402
|
+
const sound2 = [...slowProblems(spec10, at7, what), ...soundProblems(spec10, f, id2, at7)];
|
|
17403
|
+
if ((spec10.in ?? 0) > f.frames - 1)
|
|
17404
|
+
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];
|
|
17405
|
+
const out2 = span2 ? runsOutAt(ctx, spec10, f, span2) : void 0;
|
|
17406
17406
|
if (out2 === void 0 || !span2) return sound2;
|
|
17407
17407
|
return [
|
|
17408
17408
|
warning(
|
|
@@ -18043,6 +18043,8 @@ var init_contract = __esm({
|
|
|
18043
18043
|
audio: findingSchema.optional(),
|
|
18044
18044
|
visual: findingSchema.optional(),
|
|
18045
18045
|
events: z.array(findingSchema.extend({ id: text4 })).optional(),
|
|
18046
|
+
/** Independent visual and audible continuity verdicts at actual output-frame boundaries. */
|
|
18047
|
+
joins: z.array(findingSchema.extend({ at: z.number().int().positive() })).optional(),
|
|
18046
18048
|
/** Include every speech command, external sound, native clip sound and audio bed, or [] for silence. */
|
|
18047
18049
|
audioUses: z.array(audioUseSchema).optional()
|
|
18048
18050
|
});
|
|
@@ -18636,10 +18638,10 @@ var init_footage2 = __esm({
|
|
|
18636
18638
|
const { fs, path: path4 } = rt;
|
|
18637
18639
|
await fs.mkdir(job.dir);
|
|
18638
18640
|
const have = new Set(await fs.readdir(job.dir));
|
|
18639
|
-
const
|
|
18640
|
-
if (
|
|
18641
|
-
const lo =
|
|
18642
|
-
const hi =
|
|
18641
|
+
const missing5 = job.frames.filter((f) => !have.has(frameName(f)));
|
|
18642
|
+
if (missing5.length === 0) return { extracted: 0, reused: job.frames.length };
|
|
18643
|
+
const lo = missing5[0] ?? 0;
|
|
18644
|
+
const hi = missing5[missing5.length - 1] ?? 0;
|
|
18643
18645
|
const tmp = path4.join(job.dir, ".extract-" + rt.randomUUID());
|
|
18644
18646
|
await fs.mkdir(tmp);
|
|
18645
18647
|
try {
|
|
@@ -18666,11 +18668,11 @@ var init_footage2 = __esm({
|
|
|
18666
18668
|
path4.join(tmp, "%0" + FRAME_DIGITS + "d.png")
|
|
18667
18669
|
]);
|
|
18668
18670
|
const written2 = new Set(await fs.readdir(tmp));
|
|
18669
|
-
const absent2 =
|
|
18671
|
+
const absent2 = missing5.filter((f) => !written2.has(frameName(f - lo)));
|
|
18670
18672
|
if (absent2.length > 0)
|
|
18671
18673
|
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.");
|
|
18672
|
-
for (const f of
|
|
18673
|
-
return { extracted:
|
|
18674
|
+
for (const f of missing5) await fs.rename(path4.join(tmp, frameName(f - lo)), path4.join(job.dir, frameName(f)));
|
|
18675
|
+
return { extracted: missing5.length, reused: job.frames.length - missing5.length };
|
|
18674
18676
|
} finally {
|
|
18675
18677
|
await fs.rm(tmp);
|
|
18676
18678
|
}
|
|
@@ -19469,10 +19471,10 @@ var init_gradual = __esm({
|
|
|
19469
19471
|
};
|
|
19470
19472
|
keepsMoving = (sg, s, e, dab) => {
|
|
19471
19473
|
const still = Math.max(0.8, 0.02 * dab);
|
|
19472
|
-
let
|
|
19474
|
+
let run7 = 0, longest = 0;
|
|
19473
19475
|
for (let m = s + 1; m < e; m++) {
|
|
19474
|
-
|
|
19475
|
-
longest = Math.max(longest,
|
|
19476
|
+
run7 = dist(sg, m, m - 1) < still && !viaOf(sg, m) ? run7 + 1 : 0;
|
|
19477
|
+
longest = Math.max(longest, run7);
|
|
19476
19478
|
}
|
|
19477
19479
|
return longest <= Math.max(3, 0.25 * (e - s));
|
|
19478
19480
|
};
|
|
@@ -20264,12 +20266,12 @@ var init_switch = __esm({
|
|
|
20264
20266
|
};
|
|
20265
20267
|
GLITCH_VERTICAL = 0.12;
|
|
20266
20268
|
NOISE = 2e-3;
|
|
20267
|
-
joltKind = (
|
|
20268
|
-
const sx =
|
|
20269
|
-
if (sy > GLITCH_VERTICAL * sx + NOISE *
|
|
20269
|
+
joltKind = (moved2) => {
|
|
20270
|
+
const sx = moved2.reduce((s, x2) => s + Math.abs(x2.dx), 0), sy = moved2.reduce((s, x2) => s + Math.abs(x2.dy), 0);
|
|
20271
|
+
if (sy > GLITCH_VERTICAL * sx + NOISE * moved2.length) return "shake";
|
|
20270
20272
|
let flips = 0, keeps = 0;
|
|
20271
|
-
for (let i = 1; i <
|
|
20272
|
-
const p =
|
|
20273
|
+
for (let i = 1; i < moved2.length; i++) {
|
|
20274
|
+
const p = moved2[i - 1], q = moved2[i];
|
|
20273
20275
|
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;
|
|
20274
20276
|
if (Math.sign(p.dx) !== Math.sign(q.dx)) flips++;
|
|
20275
20277
|
else keeps++;
|
|
@@ -20289,12 +20291,12 @@ var init_switch = __esm({
|
|
|
20289
20291
|
FULL = 0.97;
|
|
20290
20292
|
PURE_SHIFT = 0.01;
|
|
20291
20293
|
SCALED = 0.03;
|
|
20292
|
-
whipDirection = (
|
|
20293
|
-
const sx =
|
|
20294
|
-
const ax =
|
|
20294
|
+
whipDirection = (moved2, side) => {
|
|
20295
|
+
const sx = moved2.reduce((s, x2) => s + x2.dx, 0), sy = moved2.reduce((s, x2) => s + x2.dy, 0);
|
|
20296
|
+
const ax = moved2.reduce((s, x2) => s + Math.abs(x2.dx), 0), ay = moved2.reduce((s, x2) => s + Math.abs(x2.dy), 0);
|
|
20295
20297
|
const horizontal = ax >= ay;
|
|
20296
20298
|
const net = horizontal ? sx : sy, path4 = horizontal ? ax : ay;
|
|
20297
|
-
if (
|
|
20299
|
+
if (moved2.length < 2 || Math.abs(net) < 0.9 * path4 || path4 < 0.04) return void 0;
|
|
20298
20300
|
const way = side < 0 ? Math.sign(net) : -Math.sign(net);
|
|
20299
20301
|
return horizontal ? way > 0 ? "right" : "left" : way > 0 ? "down" : "up";
|
|
20300
20302
|
};
|
|
@@ -20302,7 +20304,7 @@ var init_switch = __esm({
|
|
|
20302
20304
|
const reads = fx.map((f) => f.read);
|
|
20303
20305
|
const count5 = (k) => reads.filter((r) => r.kind === k).length;
|
|
20304
20306
|
const veils = reads.flatMap((r) => r.kind === "veiled" ? [r] : []);
|
|
20305
|
-
const
|
|
20307
|
+
const moved2 = reads.flatMap((r) => r.kind === "moved" ? [r] : []);
|
|
20306
20308
|
const turned = reads.flatMap((r) => r.kind === "turned" ? [r] : []);
|
|
20307
20309
|
if (veils.length * 2 >= reads.length) {
|
|
20308
20310
|
const white = veils.filter((v) => v.via === "white").length * 2 >= veils.length;
|
|
@@ -20310,11 +20312,11 @@ var init_switch = __esm({
|
|
|
20310
20312
|
return { kind: "fade", via: white ? "white" : "black" };
|
|
20311
20313
|
}
|
|
20312
20314
|
if (turned.some((r) => r.deg >= 20)) return { kind: "spin" };
|
|
20313
|
-
if (count5("blurred") >= Math.max(
|
|
20314
|
-
if (
|
|
20315
|
-
const way =
|
|
20315
|
+
if (count5("blurred") >= Math.max(moved2.length, turned.length, 1)) return { kind: "blur" };
|
|
20316
|
+
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" };
|
|
20317
|
+
const way = moved2.every((r) => Math.abs(r.scale - 1) < SCALED) ? whipDirection(moved2, side) : void 0;
|
|
20316
20318
|
if (way) return { kind: "whip", direction: way };
|
|
20317
|
-
if (
|
|
20319
|
+
if (moved2.length) return { kind: joltKind(fx.flatMap((f) => f.read.kind === "moved" ? [{ ...f.read, frame: f.frame, side: f.side }] : [])) };
|
|
20318
20320
|
return { kind: turned.length ? "spin" : "blur" };
|
|
20319
20321
|
};
|
|
20320
20322
|
oneSidedKind = (r) => {
|
|
@@ -21041,8 +21043,8 @@ var init_camera2 = __esm({
|
|
|
21041
21043
|
measureCamera = (c) => {
|
|
21042
21044
|
if (c.gray.length < 3) return UNKNOWN;
|
|
21043
21045
|
const st = steps(c);
|
|
21044
|
-
const
|
|
21045
|
-
if (
|
|
21046
|
+
const moved2 = mayMove(st) ? withMove(c) : void 0;
|
|
21047
|
+
if (moved2) return moved2;
|
|
21046
21048
|
const good = st.filter((s) => s.ok);
|
|
21047
21049
|
if (good.length < Math.max(1, 0.5 * st.length)) return UNKNOWN;
|
|
21048
21050
|
let S = 1, tx = 0, ty = 0, time = 0;
|
|
@@ -21856,7 +21858,7 @@ var init_reveal = __esm({
|
|
|
21856
21858
|
const all = pointsOf(mask2, w);
|
|
21857
21859
|
if (all.nNew < 4 || all.nNew === all.n) return void 0;
|
|
21858
21860
|
const front = frontOf(all, origin);
|
|
21859
|
-
const
|
|
21861
|
+
const run7 = Math.hypot(front[0] - origin[0], front[1] - origin[1]);
|
|
21860
21862
|
const straight = straightFit(all);
|
|
21861
21863
|
const edges = edgePixels(mask2, w, h);
|
|
21862
21864
|
const circle = circleFit(all, edges, w, h);
|
|
@@ -21871,7 +21873,7 @@ var init_reveal = __esm({
|
|
|
21871
21873
|
const base = { front, edge, box: [x0, y0, x1 - x0 + 1, y1 - y0 + 1] };
|
|
21872
21874
|
if (straight.fit >= CLEAN_FIT && straight.fit >= (circle?.fit ?? 0) - 0.03) return { ...base, shape: { shape: "straight", fit: straight.fit, angle: straight.angle } };
|
|
21873
21875
|
if (circle && circle.fit >= CLEAN_FIT) return { ...base, shape: { shape: "circle", fit: circle.fit, centre: circle.centre, grows: circle.grows } };
|
|
21874
|
-
const head =
|
|
21876
|
+
const head = run7 > 1 ? headOf(mask2, w, h, front, [(front[0] - origin[0]) / run7, (front[1] - origin[1]) / run7]) : void 0;
|
|
21875
21877
|
const rest = head ? pointsOf(mask2, w, head.pixels) : all;
|
|
21876
21878
|
const wedge = rest.nNew >= 4 && rest.nNew < rest.n ? wedgeFit(rest, head ? head.neck : front) : { fit: 0, angle: 0, spread: 0 };
|
|
21877
21879
|
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) };
|
|
@@ -22467,14 +22469,14 @@ var init_submit_retry = __esm({
|
|
|
22467
22469
|
};
|
|
22468
22470
|
sendIdempotent = async (rt, send2, o = {}) => {
|
|
22469
22471
|
const tries = o.tries ?? SUBMIT_TRIES, pause2 = o.pauseMs ?? SUBMIT_PAUSE_MS;
|
|
22470
|
-
for (let
|
|
22472
|
+
for (let attempt3 = 1; ; attempt3 += 1) {
|
|
22471
22473
|
try {
|
|
22472
22474
|
return await send2();
|
|
22473
22475
|
} catch (error2) {
|
|
22474
|
-
const unknown = error2 instanceof AmbiguousSubmitError ||
|
|
22476
|
+
const unknown = error2 instanceof AmbiguousSubmitError || attempt3 > 1 && o.stillWorking?.(error2) === true;
|
|
22475
22477
|
if (!unknown) throw error2;
|
|
22476
|
-
if (
|
|
22477
|
-
await sleep(rt, pause2 * 2 ** (
|
|
22478
|
+
if (attempt3 >= tries) throw lastWord(error2, tries);
|
|
22479
|
+
await sleep(rt, pause2 * 2 ** (attempt3 - 1));
|
|
22478
22480
|
}
|
|
22479
22481
|
}
|
|
22480
22482
|
};
|
|
@@ -22670,12 +22672,12 @@ var init_paid_download = __esm({
|
|
|
22670
22672
|
};
|
|
22671
22673
|
downloadPaid = async (rt, url, o) => {
|
|
22672
22674
|
const href = checkUrl(url, "the link of " + o.what);
|
|
22673
|
-
for (let
|
|
22675
|
+
for (let attempt3 = 1; ; attempt3 += 1) {
|
|
22674
22676
|
const got = await once2(rt, href, o);
|
|
22675
22677
|
if (got instanceof Uint8Array) return got;
|
|
22676
|
-
if (!got.retry ||
|
|
22677
|
-
throw new ToolError(capital(o.what) + " could not be downloaded (" + got.reason + (
|
|
22678
|
-
await sleep(rt, DOWNLOAD_PAUSES_MS[Math.min(
|
|
22678
|
+
if (!got.retry || attempt3 >= DOWNLOAD_TRIES)
|
|
22679
|
+
throw new ToolError(capital(o.what) + " could not be downloaded (" + got.reason + (attempt3 > 1 ? "; tried " + attempt3 + " times" : "") + "). " + o.again);
|
|
22680
|
+
await sleep(rt, DOWNLOAD_PAUSES_MS[Math.min(attempt3, DOWNLOAD_PAUSES_MS.length) - 1] ?? 0);
|
|
22679
22681
|
}
|
|
22680
22682
|
};
|
|
22681
22683
|
}
|
|
@@ -23049,7 +23051,7 @@ var init_dialogue = __esm({
|
|
|
23049
23051
|
return s.lines.map((l) => {
|
|
23050
23052
|
const text13 = typeof l.text === "string" ? l.text : "";
|
|
23051
23053
|
const length2 = Math.max(ESTIMATE.least, spokenChars(text13).length / (wideText(text13) ? ORDINARY_PACE.wide : ORDINARY_PACE.latin));
|
|
23052
|
-
const line = { speaker: l.speaker, text: text13, at: r2(t), to: r2(t + length2) };
|
|
23054
|
+
const line = { speaker: l.speaker, text: text13, at: r2(t), to: r2(t + length2), ...l.offscreen ? { offscreen: true } : {} };
|
|
23053
23055
|
t += length2 + ESTIMATE.gap;
|
|
23054
23056
|
return line;
|
|
23055
23057
|
});
|
|
@@ -23060,7 +23062,7 @@ var init_dialogue = __esm({
|
|
|
23060
23062
|
const shot = times ? firstShot(s, times) : void 0;
|
|
23061
23063
|
const zero = times && shot !== void 0 ? times.shots[shot] ?? 0 : 0;
|
|
23062
23064
|
return s.lines.map((l) => {
|
|
23063
|
-
const said = { speaker: l.speaker, text: l.text };
|
|
23065
|
+
const said = { speaker: l.speaker, text: l.text, ...l.offscreen ? { offscreen: true } : {} };
|
|
23064
23066
|
if (l.beat !== void 0) {
|
|
23065
23067
|
const b = times && shot !== void 0 && Number.isInteger(l.beat) ? times.beats[l.beat] : void 0;
|
|
23066
23068
|
return b && times ? { ...said, at: r2((b.start - zero) / times.fps), to: r2((b.end - zero) / times.fps), beat: l.beat } : void 0;
|
|
@@ -23090,7 +23092,8 @@ var init_dialogue = __esm({
|
|
|
23090
23092
|
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>}.`));
|
|
23091
23093
|
return;
|
|
23092
23094
|
}
|
|
23093
|
-
if (
|
|
23095
|
+
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."));
|
|
23096
|
+
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).'));
|
|
23094
23097
|
if (typeof s.language === "string" && TAG.test(s.language.trim()) && spokenChars(l.text).length && wideLanguage(s.language) !== wideText(l.text))
|
|
23095
23098
|
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.'));
|
|
23096
23099
|
const timed = l.at !== void 0 || l.to !== void 0;
|
|
@@ -23098,7 +23101,8 @@ var init_dialogue = __esm({
|
|
|
23098
23101
|
else if (l.beat !== void 0) {
|
|
23099
23102
|
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>."));
|
|
23100
23103
|
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."));
|
|
23101
|
-
else if (
|
|
23104
|
+
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."));
|
|
23105
|
+
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").`));
|
|
23102
23106
|
} 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".'));
|
|
23103
23107
|
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.'));
|
|
23104
23108
|
});
|
|
@@ -23145,6 +23149,14 @@ var init_dialogue = __esm({
|
|
|
23145
23149
|
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");
|
|
23146
23150
|
dialoguePrompt = (d) => {
|
|
23147
23151
|
const speakers = [...new Set(d.lines.map((l) => l.speaker))];
|
|
23152
|
+
if (d.lines.some((line) => line.offscreen)) {
|
|
23153
|
+
const zh = pl("", "zh");
|
|
23154
|
+
const timeline3 = d.lines.map((line) => {
|
|
23155
|
+
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)";
|
|
23156
|
+
return stamp2(line.at) + "-" + stamp2(line.to) + (zh ? " \u79D2 " : " s ") + line.speaker + role + (zh ? " \u8BF4 " : " says ") + JSON.stringify(line.text);
|
|
23157
|
+
}).join(zh ? "\uFF1B" : "; ");
|
|
23158
|
+
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.";
|
|
23159
|
+
}
|
|
23148
23160
|
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";
|
|
23149
23161
|
const lines2 = d.lines.map((l) => stamp2(l.at) + "-" + stamp2(l.to) + " s " + l.speaker + " says " + JSON.stringify(l.text)).join("; ");
|
|
23150
23162
|
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.";
|
|
@@ -23384,6 +23396,15 @@ var init_check4 = __esm({
|
|
|
23384
23396
|
};
|
|
23385
23397
|
inspect("review.audio", r.audio, AUDIBLE);
|
|
23386
23398
|
inspect("review.visual", r.visual, VISUAL);
|
|
23399
|
+
const joinsSeen = /* @__PURE__ */ new Set();
|
|
23400
|
+
for (const join3 of r.joins ?? []) {
|
|
23401
|
+
const at7 = "review.joins." + join3.at;
|
|
23402
|
+
if (joinsSeen.has(join3.at)) fail2(at7, "A cut was reviewed more than once.");
|
|
23403
|
+
joinsSeen.add(join3.at);
|
|
23404
|
+
inspect(at7, join3, ["video"]);
|
|
23405
|
+
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))
|
|
23406
|
+
pending3(at7 + ".evidence", "Continuity needs an audible video window across this cut, bound to the actual artifact.");
|
|
23407
|
+
}
|
|
23387
23408
|
if (r.audioUses === void 0) pending3("review.audioUses", "Inventory every output audio route, including imported sound and native clip audio.");
|
|
23388
23409
|
else {
|
|
23389
23410
|
const audio = checkReplicationAudio(c, r.audioUses, { complete: true });
|
|
@@ -23423,7 +23444,7 @@ var init_voice_spans = __esm({
|
|
|
23423
23444
|
init_check_common();
|
|
23424
23445
|
voiceSpanProblems = (project, resolved2) => {
|
|
23425
23446
|
const problems2 = [];
|
|
23426
|
-
for (const track of project.tracks) {
|
|
23447
|
+
for (const track of project.tracks ?? []) {
|
|
23427
23448
|
if (track.type !== "audio" || track.role !== "voice") continue;
|
|
23428
23449
|
const route2 = resolved2.audio.find((a) => a.id === track.id);
|
|
23429
23450
|
const at7 = "tracks." + track.id + ".lines";
|
|
@@ -23624,26 +23645,26 @@ var init_resolve = __esm({
|
|
|
23624
23645
|
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 } }).');
|
|
23625
23646
|
return f;
|
|
23626
23647
|
};
|
|
23627
|
-
playOf2 = (
|
|
23628
|
-
resolveTransition = (
|
|
23629
|
-
if (!
|
|
23630
|
-
const kind =
|
|
23648
|
+
playOf2 = (spec10, id2, start) => ({ material: id2, start, in: spec10.in ?? 0, speed: spec10.speed ?? 1 });
|
|
23649
|
+
resolveTransition = (spec10, boundary, fps) => {
|
|
23650
|
+
if (!spec10 || spec10.transition === "cut") return void 0;
|
|
23651
|
+
const kind = spec10.transition;
|
|
23631
23652
|
const d = TRANSITION_DEFAULTS[kind];
|
|
23632
|
-
const frames =
|
|
23633
|
-
const side =
|
|
23653
|
+
const frames = spec10.frames ?? transitionFrames(kind, fps);
|
|
23654
|
+
const side = spec10.side ?? "both";
|
|
23634
23655
|
const a = side === "both" ? boundary - Math.floor(frames / 2) : side === "after" ? boundary : boundary - frames;
|
|
23635
23656
|
return {
|
|
23636
23657
|
kind,
|
|
23637
23658
|
a,
|
|
23638
23659
|
frames,
|
|
23639
23660
|
boundary,
|
|
23640
|
-
direction:
|
|
23641
|
-
mode:
|
|
23642
|
-
via:
|
|
23661
|
+
direction: spec10.direction ?? d.direction,
|
|
23662
|
+
mode: spec10.mode ?? d.mode,
|
|
23663
|
+
via: spec10.via ?? d.via,
|
|
23643
23664
|
// A one-sided effect settles ('after') or builds up ('before') by default.
|
|
23644
|
-
ease:
|
|
23665
|
+
ease: spec10.ease ?? (side === "after" ? "out" : side === "before" ? "in" : d.ease),
|
|
23645
23666
|
side,
|
|
23646
|
-
strength:
|
|
23667
|
+
strength: spec10.strength ?? 1
|
|
23647
23668
|
};
|
|
23648
23669
|
};
|
|
23649
23670
|
resolveBase = (ctx, s, start) => {
|
|
@@ -23692,8 +23713,8 @@ var init_resolve = __esm({
|
|
|
23692
23713
|
};
|
|
23693
23714
|
clipSounds = (ctx, segments2, items, tracks) => {
|
|
23694
23715
|
const fromBases = segments2.flatMap((s, k) => {
|
|
23695
|
-
const
|
|
23696
|
-
return s.base.kind === "video" &&
|
|
23716
|
+
const spec10 = ctx.project.segments[k]?.base;
|
|
23717
|
+
return s.base.kind === "video" && spec10 && "material" in spec10 ? [{ id: s.id, spec: spec10, play: s.base.play, end: s.end }] : [];
|
|
23697
23718
|
});
|
|
23698
23719
|
const ownSound2 = tracks.some((t) => !t.bed && !t.role);
|
|
23699
23720
|
const beds = tracks.filter((t) => t.bed).map((t) => ({ start: t.sound.start, end: t.sound.end ?? ctx.tl.total }));
|
|
@@ -24119,11 +24140,27 @@ var init_profile3 = __esm({
|
|
|
24119
24140
|
});
|
|
24120
24141
|
|
|
24121
24142
|
// src/video/generate/provenance.ts
|
|
24122
|
-
var materialSignature, materialSignatures;
|
|
24143
|
+
var materialReceiptFile, readMaterialReceipt, materialSignature, materialSignatures;
|
|
24123
24144
|
var init_provenance = __esm({
|
|
24124
24145
|
"src/video/generate/provenance.ts"() {
|
|
24125
24146
|
"use strict";
|
|
24126
24147
|
init_util();
|
|
24148
|
+
materialReceiptFile = (clip11) => clip11 + ".material.json";
|
|
24149
|
+
readMaterialReceipt = async (rt, full) => {
|
|
24150
|
+
const receipt = await readJson(rt, materialReceiptFile(full)).catch(() => void 0);
|
|
24151
|
+
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;
|
|
24152
|
+
const hash5 = await sha256File(rt, full).catch(() => void 0);
|
|
24153
|
+
if (!hash5 || hash5 !== receipt.sha256) return void 0;
|
|
24154
|
+
return {
|
|
24155
|
+
version: 1,
|
|
24156
|
+
pipeline: receipt.pipeline,
|
|
24157
|
+
provider: receipt.provider,
|
|
24158
|
+
sha256: hash5,
|
|
24159
|
+
requestHash: receipt.requestHash,
|
|
24160
|
+
...typeof receipt.continues === "string" ? { continues: receipt.continues } : {},
|
|
24161
|
+
...Number.isInteger(receipt.continueAt) && (receipt.continueAt ?? -1) >= 0 ? { continueAt: receipt.continueAt } : {}
|
|
24162
|
+
};
|
|
24163
|
+
};
|
|
24127
24164
|
materialSignature = (value) => sha256(JSON.stringify(value));
|
|
24128
24165
|
materialSignatures = (value, legacyRequests = []) => [.../* @__PURE__ */ new Set([materialSignature(value), ...legacyRequests.map((request) => materialSignature({ ...value, request }))])];
|
|
24129
24166
|
}
|
|
@@ -25213,7 +25250,7 @@ var init_generate = __esm({
|
|
|
25213
25250
|
if (r.code !== 0) throw new Error(why || "The generator exited with " + r.code + ".");
|
|
25214
25251
|
const count5 = (v) => typeof v === "number" ? v : void 0;
|
|
25215
25252
|
const [credits2, chargedCredits] = [count5(said.credits), count5(said.chargedCredits)];
|
|
25216
|
-
return { ...credits2 !== void 0 ? { credits: credits2 } : {}, ...chargedCredits !== void 0 ? { chargedCredits } : {}, ...typeof said.key === "string" ? { key: said.key } : {} };
|
|
25253
|
+
return { ...credits2 !== void 0 ? { credits: credits2 } : {}, ...chargedCredits !== void 0 ? { chargedCredits } : {}, ...typeof said.key === "string" ? { key: said.key } : {}, ...typeof said.task === "string" ? { task: said.task } : {} };
|
|
25217
25254
|
})
|
|
25218
25255
|
};
|
|
25219
25256
|
};
|
|
@@ -25235,6 +25272,8 @@ var init_generate = __esm({
|
|
|
25235
25272
|
};
|
|
25236
25273
|
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.';
|
|
25237
25274
|
frameProblems = (r, at7, found, clips) => {
|
|
25275
|
+
if (r.continueAt !== void 0 && (!r.continues || !Number.isInteger(r.continueAt) || r.continueAt < 0))
|
|
25276
|
+
return [error(at7 + ".continueAt", '"continueAt" needs "continues" and a nonnegative source frame index.', "Select the actual cut-out frame of the preceding clip.")];
|
|
25238
25277
|
if (!usesFrames2(r)) return [];
|
|
25239
25278
|
const out2 = [];
|
|
25240
25279
|
const key2 = r.continues !== void 0 ? "continues" : r.firstFrame !== void 0 ? "firstFrame" : "lastFrame";
|
|
@@ -25330,6 +25369,10 @@ var init_generate = __esm({
|
|
|
25330
25369
|
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.'));
|
|
25331
25370
|
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"]));
|
|
25332
25371
|
out2.push(...frameProblems(r, at7, found, clips));
|
|
25372
|
+
if (usesFrames2(r) && policy.frames === false) {
|
|
25373
|
+
const field = r.continues !== void 0 ? "continues" : r.firstFrame !== void 0 ? "firstFrame" : "lastFrame";
|
|
25374
|
+
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."));
|
|
25375
|
+
}
|
|
25333
25376
|
out2.push(...modeProblems(r, at7, policy.clipMusic ?? [], kindOf3(String(r.file)) !== "image"));
|
|
25334
25377
|
for (const k of LISTS) {
|
|
25335
25378
|
for (const [j, p] of listed3(r, k).entries()) {
|
|
@@ -25404,13 +25447,13 @@ var init_generate = __esm({
|
|
|
25404
25447
|
return out2;
|
|
25405
25448
|
};
|
|
25406
25449
|
lastFrameFile = (clip11) => clip11.slice(0, clip11.length - extOf(clip11).length) + ".last.png";
|
|
25407
|
-
lastFrameOf = async (rt, dir, clip11) => {
|
|
25408
|
-
const from = rt.path.resolve(dir, clip11)
|
|
25409
|
-
const
|
|
25410
|
-
|
|
25411
|
-
|
|
25412
|
-
|
|
25413
|
-
|
|
25450
|
+
lastFrameOf = async (rt, dir, clip11, frame2) => {
|
|
25451
|
+
const from = rt.path.resolve(dir, clip11);
|
|
25452
|
+
const to = rt.path.resolve(dir, frame2 === void 0 ? lastFrameFile(clip11) : lastFrameFile(clip11).replace(".last.png", ".frame-" + frame2 + ".png"));
|
|
25453
|
+
const p = await probe2(rt, from);
|
|
25454
|
+
const index = frame2 ?? Math.max(0, p.frames - 1);
|
|
25455
|
+
if (index >= p.frames) throw new Error("continueAt " + index + " lies outside " + clip11 + " (" + p.frames + " frames). Nothing was sent.");
|
|
25456
|
+
await extractFrame(rt, from, index, to);
|
|
25414
25457
|
return to;
|
|
25415
25458
|
};
|
|
25416
25459
|
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.";
|
|
@@ -25421,7 +25464,7 @@ var init_generate = __esm({
|
|
|
25421
25464
|
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") })) };
|
|
25422
25465
|
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") })) };
|
|
25423
25466
|
const before = Array.isArray(o.requests) && o.times ? await saidBefore(rt, o.dir, o.requests) : void 0;
|
|
25424
|
-
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) });
|
|
25467
|
+
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) });
|
|
25425
25468
|
if (problems2.length) return { materials: [], credits: 0, chargedCredits: 0, problems: problems2 };
|
|
25426
25469
|
const said = [];
|
|
25427
25470
|
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)]);
|
|
@@ -25572,10 +25615,10 @@ var init_generate = __esm({
|
|
|
25572
25615
|
const r = gets && picture3 && source2 ? anchored(asked3, picture3, source2, o.picture?.person, shown3 !== void 0) : asked3;
|
|
25573
25616
|
const at7 = (p) => rt.path.resolve(o.dir, p);
|
|
25574
25617
|
const references = Object.fromEntries(LISTS.flatMap((k) => r[k]?.length ? [[k, (r[k] ?? []).map(at7)]] : []));
|
|
25575
|
-
const start = priceOnly ? void 0 : asked3.continues ? await lastFrameOf(rt, o.dir, asked3.continues) : asked3.firstFrame ? at7(asked3.firstFrame) : void 0;
|
|
25618
|
+
const start = priceOnly ? void 0 : asked3.continues ? await lastFrameOf(rt, o.dir, asked3.continues, asked3.continueAt) : asked3.firstFrame ? at7(asked3.firstFrame) : void 0;
|
|
25576
25619
|
const frames = { ...start ? { firstFrame: start } : {}, ...start && asked3.lastFrame ? { lastFrame: at7(asked3.lastFrame) } : {} };
|
|
25577
|
-
const
|
|
25578
|
-
const request = { prompt: r.prompt + (sent ? speechPrompt(sent) : "") +
|
|
25620
|
+
const tail4 = mode ? sound2.tailOf(original, mode) : separateMusic && kind === "video" ? noMusic() : "";
|
|
25621
|
+
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 } : {} };
|
|
25579
25622
|
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" } : {} };
|
|
25580
25623
|
const made = await o.generator.make(kind, request, partial, agreement);
|
|
25581
25624
|
const charged = made.chargedCredits ?? made.credits;
|
|
@@ -25584,7 +25627,21 @@ var init_generate = __esm({
|
|
|
25584
25627
|
if (!await exists4(partial)) throw new Error("The generator finished without writing the file.");
|
|
25585
25628
|
if (sent) await finalizeSpeech(rt, partial, sent, o.dir, target2);
|
|
25586
25629
|
const stripped = mode === "silent" && await probe2(rt, partial).then((p) => p.hasAudio, () => false) ? await stripSound(rt, partial) : false;
|
|
25630
|
+
const receipt = o.provider ? materialReceiptFile(asked3.file) : void 0;
|
|
25631
|
+
const provenance = o.provider ? {
|
|
25632
|
+
version: 1,
|
|
25633
|
+
pipeline: "popost video materials",
|
|
25634
|
+
provider: o.provider,
|
|
25635
|
+
sha256: await sha256File(rt, partial),
|
|
25636
|
+
requestHash: requestHash2(rt, original),
|
|
25637
|
+
...asked3.continues ? { continues: asked3.continues, ...asked3.continueAt !== void 0 ? { continueAt: asked3.continueAt } : {} } : {}
|
|
25638
|
+
} : void 0;
|
|
25587
25639
|
await rt.fs.rename(partial, target2);
|
|
25640
|
+
if (receipt && provenance) {
|
|
25641
|
+
await writeJson(rt, rt.path.resolve(o.dir, receipt), provenance);
|
|
25642
|
+
entry2 = { ...entry2, receipt };
|
|
25643
|
+
}
|
|
25644
|
+
if (made.task) entry2 = { ...entry2, task: made.task };
|
|
25588
25645
|
if (mode) await writeModeReceipt(rt, target2, { sound: mode, ...basis ? { clipMusic: basis } : {}, ...stripped ? { stripped: true } : {} });
|
|
25589
25646
|
if (asked3.speech) for (const ext of [".speech.wav", ".speech.json"]) await rt.fs.rename(partial + ext, target2 + ext);
|
|
25590
25647
|
if (cast || asked3.speech) await rt.fs.writeFile(target2 + ".generation.json", signature2);
|
|
@@ -25604,6 +25661,7 @@ var init_generate = __esm({
|
|
|
25604
25661
|
continue;
|
|
25605
25662
|
}
|
|
25606
25663
|
}
|
|
25664
|
+
if (!entry2.made && o.provider && await readMaterialReceipt(rt, target2)) entry2 = { ...entry2, receipt: materialReceiptFile(asked3.file) };
|
|
25607
25665
|
if (mode && original.sound !== void 0 && !await readModeReceipt(rt, target2)) await writeModeReceipt(rt, target2, { sound: mode, ...basis ? { clipMusic: basis } : {} });
|
|
25608
25666
|
if (kind === "video") {
|
|
25609
25667
|
const p = await probe2(rt, target2).catch(() => void 0);
|
|
@@ -25774,8 +25832,8 @@ var init_shared = __esm({
|
|
|
25774
25832
|
name = "VideoCommandError";
|
|
25775
25833
|
};
|
|
25776
25834
|
expected = (error2) => error2 instanceof VideoCommandError || error2 instanceof VideoUnavailableError || error2 instanceof BrowserUnavailableError || error2 instanceof FfmpegError || isExpectedFailure(error2);
|
|
25777
|
-
command = (description5,
|
|
25778
|
-
spec: { description: description5, ...
|
|
25835
|
+
command = (description5, spec10, body, projectOf4, titleOf) => ({
|
|
25836
|
+
spec: { description: description5, ...spec10 },
|
|
25779
25837
|
run: async (args2, rt) => {
|
|
25780
25838
|
const project = projectOf4?.(args2);
|
|
25781
25839
|
try {
|
|
@@ -26392,14 +26450,14 @@ var init_check5 = __esm({
|
|
|
26392
26450
|
measuredLabel = (b) => [b.kind, b.mode, b.direction, b.via ? "via " + b.via : ""].filter(Boolean).join(" ");
|
|
26393
26451
|
coverageProblems2 = ({ r, m, at: at7 }) => {
|
|
26394
26452
|
const fps = m.source.fps, s22 = (f) => (f / fps).toFixed(2);
|
|
26395
|
-
const
|
|
26453
|
+
const missing5 = 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.'));
|
|
26396
26454
|
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."));
|
|
26397
26455
|
const times = r.elements.shots.flatMap((s) => {
|
|
26398
26456
|
const ms = m.shots[s.shot - 1];
|
|
26399
26457
|
if (!ms || Math.abs(s.time[0] - ms.start / fps) <= TIME_SLACK && Math.abs(s.time[1] - ms.end / fps) <= TIME_SLACK) return [];
|
|
26400
26458
|
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".')];
|
|
26401
26459
|
});
|
|
26402
|
-
return [...
|
|
26460
|
+
return [...missing5, ...extra2, ...times];
|
|
26403
26461
|
};
|
|
26404
26462
|
transitionProblems2 = ({ r, m, at: at7 }) => r.elements.shots.flatMap((s) => {
|
|
26405
26463
|
const here = at7(s.shot) + ".transitionIn", t = s.transitionIn;
|
|
@@ -26952,7 +27010,7 @@ var init_speech2 = __esm({
|
|
|
26952
27010
|
LATIN_RUN = /[A-Za-z0-9]+/g;
|
|
26953
27011
|
syllablesOf = (text13) => {
|
|
26954
27012
|
const cjk = (text13.match(CJK_ALL) ?? []).length;
|
|
26955
|
-
const latin = (text13.match(LATIN_RUN) ?? []).reduce((n,
|
|
27013
|
+
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);
|
|
26956
27014
|
return Math.max(1, cjk + latin);
|
|
26957
27015
|
};
|
|
26958
27016
|
median4 = (xs) => [...xs].sort((a, b) => a - b)[Math.floor(xs.length / 2)] ?? 0;
|
|
@@ -27010,11 +27068,11 @@ var init_speech2 = __esm({
|
|
|
27010
27068
|
const pauses = pausesOf(t.words, o.pace ?? paceFramesOf(t.words));
|
|
27011
27069
|
const runs4 = [];
|
|
27012
27070
|
t.words.forEach((w, k) => {
|
|
27013
|
-
const
|
|
27071
|
+
const run7 = runs4[runs4.length - 1];
|
|
27014
27072
|
const prev = t.words[k - 1];
|
|
27015
|
-
if (
|
|
27016
|
-
|
|
27017
|
-
|
|
27073
|
+
if (run7 && prev && (pauses[k] ?? 0) < pauseFrames && !CLAUSE_END.test(prev.text)) {
|
|
27074
|
+
run7.words.push(w);
|
|
27075
|
+
run7.pauses.push(pauses[k] ?? 0);
|
|
27018
27076
|
} else runs4.push({ words: [w], pauses: [pauses[k] ?? 0] });
|
|
27019
27077
|
});
|
|
27020
27078
|
const cutUp = runs4.flatMap((r) => atBoundaries(r, o.boundaries ?? [], edge)).flatMap((r) => atLargestPause(r, max, edge));
|
|
@@ -28698,11 +28756,11 @@ var init_browser_step = __esm({
|
|
|
28698
28756
|
BrowserStepTimeoutError = class extends Error {
|
|
28699
28757
|
name = "BrowserStepTimeoutError";
|
|
28700
28758
|
};
|
|
28701
|
-
browserStep = async (stage3,
|
|
28759
|
+
browserStep = async (stage3, run7, ms = 3e4) => {
|
|
28702
28760
|
let timer;
|
|
28703
28761
|
try {
|
|
28704
28762
|
return await Promise.race([
|
|
28705
|
-
|
|
28763
|
+
run7(),
|
|
28706
28764
|
new Promise((_resolve, reject) => {
|
|
28707
28765
|
timer = setTimeout(() => reject(new BrowserStepTimeoutError("Chrome did not finish " + stage3 + " within " + ms / 1e3 + " seconds. Check the browser and project assets, then retry.")), ms);
|
|
28708
28766
|
})
|
|
@@ -29332,12 +29390,12 @@ var init_cues = __esm({
|
|
|
29332
29390
|
const used = /* @__PURE__ */ new Set();
|
|
29333
29391
|
for (const line of sample.lines) {
|
|
29334
29392
|
if (line.confidence < MIN_CONFIDENCE2 || !norm(line.text)) continue;
|
|
29335
|
-
const
|
|
29336
|
-
if (
|
|
29337
|
-
|
|
29338
|
-
|
|
29339
|
-
|
|
29340
|
-
used.add(
|
|
29393
|
+
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));
|
|
29394
|
+
if (run7) {
|
|
29395
|
+
run7.lines.push(line);
|
|
29396
|
+
run7.frames.push(sample.frame);
|
|
29397
|
+
run7.last = index;
|
|
29398
|
+
used.add(run7);
|
|
29341
29399
|
} else {
|
|
29342
29400
|
const fresh = { lines: [line], frames: [sample.frame], last: index };
|
|
29343
29401
|
open.push(fresh);
|
|
@@ -29354,20 +29412,20 @@ var init_cues = __esm({
|
|
|
29354
29412
|
});
|
|
29355
29413
|
return [...done2, ...open];
|
|
29356
29414
|
};
|
|
29357
|
-
toCue = (
|
|
29358
|
-
const first =
|
|
29359
|
-
const exact =
|
|
29360
|
-
const placed2 = exact.length ? exact :
|
|
29415
|
+
toCue = (run7, step2, total2) => {
|
|
29416
|
+
const first = run7.frames[0] ?? 0, last = run7.frames[run7.frames.length - 1] ?? 0;
|
|
29417
|
+
const exact = run7.lines.filter((l) => !l.partial);
|
|
29418
|
+
const placed2 = exact.length ? exact : run7.lines;
|
|
29361
29419
|
const box2 = union2(placed2.map((l) => l.box));
|
|
29362
29420
|
const heights = placed2.map((l) => l.box[3]).sort((a, b) => a - b);
|
|
29363
29421
|
return {
|
|
29364
|
-
text: bestText(
|
|
29422
|
+
text: bestText(run7.lines),
|
|
29365
29423
|
start: Math.max(0, first - Math.floor(step2 / 2)),
|
|
29366
29424
|
end: Math.min(total2, last + Math.ceil(step2 / 2)),
|
|
29367
29425
|
box: box2,
|
|
29368
29426
|
size: Math.round((heights[Math.floor(heights.length / 2)] ?? 0) * 1e4) / 1e4,
|
|
29369
|
-
samples:
|
|
29370
|
-
confidence: Math.round(
|
|
29427
|
+
samples: run7.lines.length,
|
|
29428
|
+
confidence: Math.round(run7.lines.reduce((s, l) => s + l.confidence, 0) / run7.lines.length * 1e3) / 1e3
|
|
29371
29429
|
};
|
|
29372
29430
|
};
|
|
29373
29431
|
presence2 = (cue, all, frames) => {
|
|
@@ -29686,21 +29744,21 @@ var init_beats = __esm({
|
|
|
29686
29744
|
uncoveredRuns = (words, shown3, tolerance) => {
|
|
29687
29745
|
const covered4 = (w) => shown3.some((b) => mid2(w) >= b.start - tolerance && mid2(w) < b.end + tolerance);
|
|
29688
29746
|
const runs4 = [];
|
|
29689
|
-
let
|
|
29747
|
+
let run7 = [];
|
|
29690
29748
|
for (const w of words) {
|
|
29691
|
-
const prev =
|
|
29749
|
+
const prev = run7[run7.length - 1];
|
|
29692
29750
|
if (covered4(w) || prev && shown3.some((b) => b.start < mid2(w) && b.end > mid2(prev))) {
|
|
29693
|
-
if (
|
|
29694
|
-
|
|
29751
|
+
if (run7.length) runs4.push(run7);
|
|
29752
|
+
run7 = [];
|
|
29695
29753
|
}
|
|
29696
|
-
if (!covered4(w))
|
|
29754
|
+
if (!covered4(w)) run7.push(w);
|
|
29697
29755
|
}
|
|
29698
|
-
if (
|
|
29756
|
+
if (run7.length) runs4.push(run7);
|
|
29699
29757
|
return runs4;
|
|
29700
29758
|
};
|
|
29701
|
-
isStray = (
|
|
29702
|
-
const first =
|
|
29703
|
-
if (!first || !last ||
|
|
29759
|
+
isStray = (run7, shown3, fps) => {
|
|
29760
|
+
const first = run7[0], last = run7[run7.length - 1];
|
|
29761
|
+
if (!first || !last || run7.reduce((n, w) => n + syllablesOf(w.text), 0) > STRAY_SYLLABLES) return false;
|
|
29704
29762
|
const near3 = STRAY_SECONDS * fps;
|
|
29705
29763
|
return shown3.some((b) => Math.abs(first.start - b.end) <= near3 || Math.abs(b.start - last.end) <= near3);
|
|
29706
29764
|
};
|
|
@@ -29734,9 +29792,9 @@ var init_beats = __esm({
|
|
|
29734
29792
|
if (!o.transcript || !words.length) return { ...text13 ? { text: text13 } : {}, beats: shown3.map((b) => withKind(b, kinds)), captions };
|
|
29735
29793
|
const t = o.transcript;
|
|
29736
29794
|
const pace2 = paceFramesOf(words);
|
|
29737
|
-
const runs4 = uncoveredRuns(words, shown3, coverTolerance(o.text)).filter((
|
|
29795
|
+
const runs4 = uncoveredRuns(words, shown3, coverTolerance(o.text)).filter((run7) => !isStray(run7, shown3, t.fps));
|
|
29738
29796
|
const cuts = [...o.boundaries ?? [], ...(kinds ?? []).map((k) => k.start)].sort((a, b) => a - b);
|
|
29739
|
-
const spoken = runs4.flatMap((
|
|
29797
|
+
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 }));
|
|
29740
29798
|
return { ...text13 ? { text: text13 } : {}, beats: ordered([...shown3, ...spoken]).map((b) => withKind(b, kinds)), captions };
|
|
29741
29799
|
};
|
|
29742
29800
|
uncoveredSpeech = (beats2, transcript2, o = {}) => {
|
|
@@ -29745,12 +29803,12 @@ var init_beats = __esm({
|
|
|
29745
29803
|
const out2 = words.filter((w) => !beats2.some((b) => mid2(w) >= b.start - tol && mid2(w) < b.end + tol));
|
|
29746
29804
|
const shown3 = beats2.filter((b) => b.shown);
|
|
29747
29805
|
const runs4 = out2.reduce((acc, w) => {
|
|
29748
|
-
const
|
|
29749
|
-
if (
|
|
29806
|
+
const run7 = acc[acc.length - 1], prev = run7?.[run7.length - 1];
|
|
29807
|
+
if (run7 && prev && words.indexOf(prev) + 1 === words.indexOf(w)) run7.push(w);
|
|
29750
29808
|
else acc.push([w]);
|
|
29751
29809
|
return acc;
|
|
29752
29810
|
}, []);
|
|
29753
|
-
const left = o.strays ? runs4.filter((
|
|
29811
|
+
const left = o.strays ? runs4.filter((run7) => !isStray(run7, shown3, transcript2?.fps ?? 1)).flat() : out2;
|
|
29754
29812
|
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 };
|
|
29755
29813
|
};
|
|
29756
29814
|
coverTolerance = (text13) => Math.ceil((text13?.step ?? 0) / 2);
|
|
@@ -30666,9 +30724,9 @@ var init_describe = __esm({
|
|
|
30666
30724
|
if (m.boundaries.length) L.push("- Changes between shots: " + histogram3(m.boundaries.map((b) => b.kind)));
|
|
30667
30725
|
const moving = m.shots.filter((s) => s.camera.kind === "move").length;
|
|
30668
30726
|
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");
|
|
30669
|
-
const
|
|
30670
|
-
if (p.amount !== void 0 &&
|
|
30671
|
-
L.push("- Motion amount: " + p.amount + " over the video, by shot from " +
|
|
30727
|
+
const moved2 = p.amounts.flatMap((a, k) => a === void 0 ? [] : [{ a, k }]).sort((x2, y) => x2.a - y.a);
|
|
30728
|
+
if (p.amount !== void 0 && moved2.length)
|
|
30729
|
+
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");
|
|
30672
30730
|
const movement = movementCardLine(p.activity, p.written);
|
|
30673
30731
|
if (movement) L.push(movement);
|
|
30674
30732
|
if (inset) L.push("- " + insetText(inset, m.shots.length));
|
|
@@ -31301,8 +31359,8 @@ var init_retarget = __esm({
|
|
|
31301
31359
|
const into = k > 0 ? m.boundaries[k - 1] : void 0;
|
|
31302
31360
|
const keptBoth = "keep" in fill4 && k > 0 && "keep" in plan4.shots[k - 1];
|
|
31303
31361
|
if (into && !keptBoth) {
|
|
31304
|
-
const
|
|
31305
|
-
if (
|
|
31362
|
+
const spec10 = transitionSpec(into, toFrames2, Math.min(lengths[k - 1] ?? 1, lengths[k] ?? 1));
|
|
31363
|
+
if (spec10) segment2.in = spec10;
|
|
31306
31364
|
}
|
|
31307
31365
|
return segment2;
|
|
31308
31366
|
});
|
|
@@ -31527,9 +31585,9 @@ var init_structure = __esm({
|
|
|
31527
31585
|
const out2 = [];
|
|
31528
31586
|
starts.forEach((S, k) => {
|
|
31529
31587
|
const e = t.shots[k]?.effect;
|
|
31530
|
-
const
|
|
31588
|
+
const moved2 = !e || k === 0 ? S : e.by === "this" ? S - Math.floor(e.frames / 2) : S + Math.ceil(e.frames / 2);
|
|
31531
31589
|
const lo = k === 0 ? 0 : (out2[k - 1] ?? 0) + 1, hi = (starts[k + 1] ?? total2) - 1;
|
|
31532
|
-
out2.push(k === 0 ? 0 : Math.max(lo, Math.min(hi,
|
|
31590
|
+
out2.push(k === 0 ? 0 : Math.max(lo, Math.min(hi, moved2)));
|
|
31533
31591
|
});
|
|
31534
31592
|
return out2;
|
|
31535
31593
|
};
|
|
@@ -31540,12 +31598,12 @@ var init_structure = __esm({
|
|
|
31540
31598
|
};
|
|
31541
31599
|
STILL3 = { kind: "static", zoomPerS: 0, panPerS: [0, 0], confidence: 1 };
|
|
31542
31600
|
cameraOf = (s) => s.camera ? { kind: "move", zoomPerS: s.camera.zoom ?? 0, panPerS: s.camera.pan ?? [0, 0], confidence: 1 } : STILL3;
|
|
31543
|
-
boundaryAt = (S,
|
|
31544
|
-
if (!
|
|
31601
|
+
boundaryAt = (S, spec10, frames) => {
|
|
31602
|
+
if (!spec10 || spec10.transition === "cut" || frames < 2) return { frame: S, kind: "cut", start: S - 1, end: S, confidence: 1 };
|
|
31545
31603
|
const a = S - Math.floor(frames / 2);
|
|
31546
|
-
return { frame: S, kind:
|
|
31604
|
+
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 };
|
|
31547
31605
|
};
|
|
31548
|
-
transitionFrames3 = (
|
|
31606
|
+
transitionFrames3 = (spec10, room) => !spec10 || spec10.transition === "cut" ? 0 : Math.min(Math.max(2, spec10.frames ?? 0), room);
|
|
31549
31607
|
measureOf = (t, starts, total2, boundaries) => ({
|
|
31550
31608
|
version: 1,
|
|
31551
31609
|
source: { width: t.canvas.width, height: t.canvas.height, fps: t.canvas.fps, frames: total2, duration: total2 / t.canvas.fps, hasAudio: false },
|
|
@@ -31832,9 +31890,9 @@ var init_main = __esm({
|
|
|
31832
31890
|
return best ? { box: best.box, kind: best.kind } : void 0;
|
|
31833
31891
|
};
|
|
31834
31892
|
motionOf = (layers) => {
|
|
31835
|
-
const
|
|
31893
|
+
const main24 = mainPicture(layers);
|
|
31836
31894
|
const said = layers.flatMap((l) => {
|
|
31837
|
-
const isMain =
|
|
31895
|
+
const isMain = main24 !== void 0 && l.box === main24.box && l.kind === main24.kind;
|
|
31838
31896
|
const words = [l.moves, l.enters].filter((t) => typeof t === "string" && t.trim() !== "");
|
|
31839
31897
|
const own3 = l.kind === "pointer" ? l.moves ? [l.moves] : [] : isMain ? words.filter((t) => MOTION_WORDS.test(t)) : [];
|
|
31840
31898
|
return own3.map((t) => l.id + ": " + t.trim());
|
|
@@ -31843,10 +31901,10 @@ var init_main = __esm({
|
|
|
31843
31901
|
};
|
|
31844
31902
|
extrasOf = (e) => {
|
|
31845
31903
|
const layers = [...e.design, ...e.content];
|
|
31846
|
-
const
|
|
31904
|
+
const main24 = mainPicture(layers), motion3 = motionOf(layers);
|
|
31847
31905
|
const highlight = e.captions?.highlight, reveal = e.captions?.reveal;
|
|
31848
31906
|
return {
|
|
31849
|
-
...
|
|
31907
|
+
...main24 ? { main: main24 } : {},
|
|
31850
31908
|
...motion3 ? { motion: motion3 } : {},
|
|
31851
31909
|
...highlight && !isNone(highlight) ? { highlight } : {},
|
|
31852
31910
|
...reveal && reveal.trim() ? { reveal } : {}
|
|
@@ -32495,13 +32553,13 @@ var init_cloud2 = __esm({
|
|
|
32495
32553
|
sent = await ensureUploads2(rt, client2, job.refs, sent, job.file);
|
|
32496
32554
|
const body = specOf(s, job.request, job.seconds, job.refs, sent, job.silent);
|
|
32497
32555
|
sent = await ensureQuote(rt, client2, body, sent, job.file);
|
|
32498
|
-
const
|
|
32499
|
-
if (job.request.priceOnly) throw new ConfirmNeeded(
|
|
32500
|
-
agreeToPrice(s,
|
|
32556
|
+
const quote16 = sent.quote;
|
|
32557
|
+
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.");
|
|
32558
|
+
agreeToPrice(s, quote16.price, job.unplanned);
|
|
32501
32559
|
try {
|
|
32502
|
-
const task = await createTask2(rt, client2, { ...body, prompt: job.request.prompt, quoteId:
|
|
32560
|
+
const task = await createTask2(rt, client2, { ...body, prompt: job.request.prompt, quoteId: quote16.quoteId, idempotencyKey: keyOf4(sent) });
|
|
32503
32561
|
await save2(rt, job.file, { ...sent, taskId: task.id });
|
|
32504
|
-
await job.onPaid(typeof task.credits === "number" ? task.credits :
|
|
32562
|
+
await job.onPaid(typeof task.credits === "number" ? task.credits : quote16.price.credits);
|
|
32505
32563
|
return task;
|
|
32506
32564
|
} catch (error2) {
|
|
32507
32565
|
if (round6 > 1 || !(error2 instanceof PopostApiError) || error2.code !== "QUOTE_EXPIRED") throw error2;
|
|
@@ -32639,7 +32697,7 @@ var init_cloud2 = __esm({
|
|
|
32639
32697
|
throw ended(done2);
|
|
32640
32698
|
}
|
|
32641
32699
|
await fetchClip(rt, client2, done2, out2);
|
|
32642
|
-
return { ...typeof done2.credits === "number" ? { credits: done2.credits } : {}, chargedCredits: charged, key: key2 };
|
|
32700
|
+
return { ...typeof done2.credits === "number" ? { credits: done2.credits } : {}, chargedCredits: charged, key: key2, task: done2.id };
|
|
32643
32701
|
};
|
|
32644
32702
|
priceClip = async (rt, client2, s, request) => {
|
|
32645
32703
|
const seconds8 = request.seconds ?? DEFAULT_SECONDS;
|
|
@@ -32866,8 +32924,8 @@ var init_cloud_image = __esm({
|
|
|
32866
32924
|
const provider = new PopostProvider(rt, { config: s.imageModel ? withModel(config3, s.imageModel) : config3 });
|
|
32867
32925
|
const aspect = request.aspect ?? "1:1";
|
|
32868
32926
|
const refs = await Promise.all((request.images ?? []).map(async (value) => ({ kind: "local", value, sha256: await sha256File(rt, value) })));
|
|
32869
|
-
const
|
|
32870
|
-
return { credits:
|
|
32927
|
+
const quote16 = await provider.quote({ model: s.imageModel ?? null, aspect, count: 1, refs });
|
|
32928
|
+
return { credits: quote16.totalCredits, model: quote16.model, aspectRatio: aspect, balance: quote16.balance };
|
|
32871
32929
|
};
|
|
32872
32930
|
makePicture = async (rt, s, config3, request, out2) => {
|
|
32873
32931
|
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);
|
|
@@ -32882,13 +32940,13 @@ var init_cloud_image = __esm({
|
|
|
32882
32940
|
const sent = await readRecord3(rt, file, key2);
|
|
32883
32941
|
const before = sent.taskId ? await pickUp2(rt, s, provider, sent, file, out2, wanted) : void 0;
|
|
32884
32942
|
if (before) return before;
|
|
32885
|
-
const
|
|
32886
|
-
agreeToPrice(s, { credits:
|
|
32887
|
-
const made = await provider.submit(request.prompt, { aspect, refs, model:
|
|
32943
|
+
const quote16 = await provider.quote({ model: s.imageModel ?? null, aspect, count: 1, refs });
|
|
32944
|
+
agreeToPrice(s, { credits: quote16.totalCredits, model: quote16.model, aspectRatio: aspect, balance: quote16.balance });
|
|
32945
|
+
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) => {
|
|
32888
32946
|
if (error2 instanceof AmbiguousSubmitError) throw new GenerateError("The picture was asked for, but whether it was made is unknown. " + RETRY_HINT);
|
|
32889
32947
|
throw error2;
|
|
32890
32948
|
});
|
|
32891
|
-
const credits2 = typeof made.costCredits === "number" ? made.costCredits :
|
|
32949
|
+
const credits2 = typeof made.costCredits === "number" ? made.costCredits : quote16.totalCredits;
|
|
32892
32950
|
if (made.status === "running" || made.status === "failed") {
|
|
32893
32951
|
const task = typeof made.serverTaskId === "string" ? made.serverTaskId : void 0;
|
|
32894
32952
|
const ended2 = made.status === "failed" ? { told: String(made.taskId) } : {};
|
|
@@ -33081,10 +33139,20 @@ var init_product = __esm({
|
|
|
33081
33139
|
init_generate2();
|
|
33082
33140
|
init_shared();
|
|
33083
33141
|
PROJECT = { name: "project", help: "the video project directory" };
|
|
33084
|
-
builtInGenerator = (rt) =>
|
|
33142
|
+
builtInGenerator = (rt) => {
|
|
33143
|
+
const [program = "", script = "", ...rest] = toolCommand(rt, "POPOST_GEN_CMD") ?? [];
|
|
33144
|
+
const name = rt.path.basename(program).toLowerCase();
|
|
33145
|
+
const nodeCli = /^node(?:\.exe)?$/.test(name) && /(?:^|[/\\])popost[/\\]dist[/\\]cli\.js$/.test(script);
|
|
33146
|
+
if (!nodeCli && !/^popost(?:\.(?:exe|cmd))?$/.test(name)) return false;
|
|
33147
|
+
const args2 = nodeCli ? rest : [script, ...rest];
|
|
33148
|
+
return args2.some((word2, i) => word2 === "video" && args2[i + 1] === "generate");
|
|
33149
|
+
};
|
|
33085
33150
|
referenceLimits = async (rt) => {
|
|
33086
33151
|
if (!toolCommand(rt, "POPOST_GEN_CMD")) return { unread: "no generator is configured" };
|
|
33087
|
-
if (!builtInGenerator(rt))
|
|
33152
|
+
if (!builtInGenerator(rt)) {
|
|
33153
|
+
const frames = rt.env.POPOST_GEN_FRAMES?.trim();
|
|
33154
|
+
return frames === "true" || frames === "false" ? { limits: { frames: frames === "true" } } : { unread: "the generator is a tool of your own" };
|
|
33155
|
+
}
|
|
33088
33156
|
try {
|
|
33089
33157
|
const data = await listModels((await platform2(rt)).client);
|
|
33090
33158
|
const wanted = rt.env.POPOST_VIDEO_MODEL?.trim() || (typeof data.default === "string" ? data.default : void 0);
|
|
@@ -33266,10 +33334,10 @@ var init_product = __esm({
|
|
|
33266
33334
|
const dir = userPath(rt, args2.req("project"));
|
|
33267
33335
|
const { sheet: sheet4, problems: problems2 } = await readProductSheet(rt, dir);
|
|
33268
33336
|
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.");
|
|
33269
|
-
const [
|
|
33270
|
-
if (!!
|
|
33337
|
+
const [quote16, unattended] = [args2.string("quote")?.trim(), args2.string("unattended")?.trim()];
|
|
33338
|
+
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.`);
|
|
33271
33339
|
if (!inferredFacts(sheet4).length) throw new VideoCommandError("Every fact of the sheet is the user's own: there is nothing to confirm.");
|
|
33272
|
-
const confirmation = { by:
|
|
33340
|
+
const confirmation = { by: quote16 ? "user" : "unattended", quote: quote16 ?? unattended ?? "", facts: inferredHash(sheet4), at: rt.now().toISOString() };
|
|
33273
33341
|
await writeJson(rt, rt.path.join(dir, PRODUCT_FILE), { ...sheet4, confirmation });
|
|
33274
33342
|
printJson(rt, { ok: true, confirmation: confirmationOf({ ...sheet4, confirmation }), facts: inferredFacts(sheet4).length });
|
|
33275
33343
|
},
|
|
@@ -34064,8 +34132,8 @@ var init_collect = __esm({
|
|
|
34064
34132
|
gather = async (rt, dir, o) => {
|
|
34065
34133
|
const { policy, model } = o.requests.length ? await promptPolicy(rt) : { policy: "user" };
|
|
34066
34134
|
const seen = /* @__PURE__ */ new Map();
|
|
34067
|
-
const
|
|
34068
|
-
const problems2 = (
|
|
34135
|
+
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;
|
|
34136
|
+
const problems2 = (report4?.problems ?? []).filter((p) => !(p.level === "error" && /^It was not made: it costs/.test(p.message)));
|
|
34069
34137
|
const sheet4 = (await readProductSheet(rt, dir)).sheet;
|
|
34070
34138
|
const cast = await readCast(rt, dir).catch(() => void 0);
|
|
34071
34139
|
const productPictures = new Map((sheet4?.products ?? []).flatMap((p) => p.pictures.map((x2) => [x2.file, p.id])));
|
|
@@ -34088,8 +34156,8 @@ var init_collect = __esm({
|
|
|
34088
34156
|
});
|
|
34089
34157
|
for (const [k, role] of [["firstFrame", "first frame"], ["lastFrame", "last frame"]]) if (r[k]) pictures.push({ file: r[k], role, name: role });
|
|
34090
34158
|
const notes2 = [
|
|
34091
|
-
...r.continues ? ["starts from the last frame of " + r.continues + ", taken once that clip is made"] : [],
|
|
34092
|
-
...
|
|
34159
|
+
...r.continues ? ["starts from " + (r.continueAt === void 0 ? "the last frame" : "source frame " + r.continueAt) + " of " + r.continues + ", taken once that clip is made"] : [],
|
|
34160
|
+
...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"] : []
|
|
34093
34161
|
];
|
|
34094
34162
|
clips.push({
|
|
34095
34163
|
key: key2,
|
|
@@ -34132,7 +34200,7 @@ var init_collect = __esm({
|
|
|
34132
34200
|
kept: kept3,
|
|
34133
34201
|
voices,
|
|
34134
34202
|
...balance !== void 0 ? { balance } : {},
|
|
34135
|
-
notes:
|
|
34203
|
+
notes: report4?.notes ?? []
|
|
34136
34204
|
};
|
|
34137
34205
|
};
|
|
34138
34206
|
}
|
|
@@ -34181,8 +34249,8 @@ var init_sheet4 = __esm({
|
|
|
34181
34249
|
}
|
|
34182
34250
|
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>");
|
|
34183
34251
|
for (const i of rows3) {
|
|
34184
|
-
const
|
|
34185
|
-
out2.push('<div class="card"><div class="head">' + escapeHtml(i.file) + '</div><div class="spec">' + escapeHtml(
|
|
34252
|
+
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 ");
|
|
34253
|
+
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>");
|
|
34186
34254
|
}
|
|
34187
34255
|
return '<!doctype html><html><head><meta charset="utf-8"><style>' + CSS3 + "</style></head><body>" + out2.join("") + "</body></html>";
|
|
34188
34256
|
};
|
|
@@ -34313,8 +34381,8 @@ var init_summary = __esm({
|
|
|
34313
34381
|
}
|
|
34314
34382
|
if (s.items.length) out2.push("## " + msg("Clips and pictures to generate", "\u5F85\u751F\u6210\u7684\u89C6\u9891\u7247\u6BB5\u548C\u56FE\u7247"), "");
|
|
34315
34383
|
s.items.forEach((i, n) => {
|
|
34316
|
-
const
|
|
34317
|
-
out2.push("### " + (n + 1) + ". " + i.file + " (" + state(i.confirmed) + ")", "",
|
|
34384
|
+
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 ");
|
|
34385
|
+
out2.push("### " + (n + 1) + ". " + i.file + " (" + state(i.confirmed) + ")", "", spec10, "");
|
|
34318
34386
|
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("; "));
|
|
34319
34387
|
if (i.sounds.length) out2.push(msg("Sounds sent with it: ", "\u968F\u8BF7\u6C42\u53D1\u9001\u7684\u58F0\u97F3\uFF1A") + i.sounds.join(", "));
|
|
34320
34388
|
if (i.clips.length) out2.push(msg("Clips sent with it: ", "\u968F\u8BF7\u6C42\u53D1\u9001\u7684\u89C6\u9891\uFF1A") + i.clips.join(", "));
|
|
@@ -34414,15 +34482,15 @@ var init_takes = __esm({
|
|
|
34414
34482
|
}, "");
|
|
34415
34483
|
takesOf = (lines2) => {
|
|
34416
34484
|
const takes = [];
|
|
34417
|
-
let
|
|
34485
|
+
let run7 = [];
|
|
34418
34486
|
const close = () => {
|
|
34419
|
-
if (
|
|
34420
|
-
|
|
34487
|
+
if (run7.length) takes.push({ lines: run7, text: takeText(run7.map((k) => lines2[k] ?? "")) });
|
|
34488
|
+
run7 = [];
|
|
34421
34489
|
};
|
|
34422
34490
|
lines2.forEach((line, i) => {
|
|
34423
34491
|
if (!line.trim()) return close();
|
|
34424
|
-
if (
|
|
34425
|
-
|
|
34492
|
+
if (run7.length && takeText([...run7, i].map((k) => lines2[k] ?? "")).length > TAKE_MAX) close();
|
|
34493
|
+
run7.push(i);
|
|
34426
34494
|
});
|
|
34427
34495
|
close();
|
|
34428
34496
|
return takes;
|
|
@@ -34750,15 +34818,15 @@ var init_speech_check = __esm({
|
|
|
34750
34818
|
comparedWords = (text13) => {
|
|
34751
34819
|
const out2 = [];
|
|
34752
34820
|
for (const piece of text13.normalize("NFKC").toLowerCase().split(/[^\p{L}\p{N}']+/u)) {
|
|
34753
|
-
let
|
|
34821
|
+
let run7 = "";
|
|
34754
34822
|
for (const ch of piece) {
|
|
34755
34823
|
if (CJK3.test(ch)) {
|
|
34756
|
-
if (
|
|
34757
|
-
|
|
34824
|
+
if (run7) out2.push(run7);
|
|
34825
|
+
run7 = "";
|
|
34758
34826
|
out2.push(ch);
|
|
34759
|
-
} else
|
|
34827
|
+
} else run7 += ch;
|
|
34760
34828
|
}
|
|
34761
|
-
if (
|
|
34829
|
+
if (run7.replace(/'/g, "")) out2.push(run7.replace(/^'+|'+$/g, ""));
|
|
34762
34830
|
}
|
|
34763
34831
|
return out2;
|
|
34764
34832
|
};
|
|
@@ -34780,9 +34848,9 @@ var init_speech_check = __esm({
|
|
|
34780
34848
|
const a = comparedWords(script), b = comparedWords(heard);
|
|
34781
34849
|
const pairs = commonPairs(a, b);
|
|
34782
34850
|
const saidA = new Set(pairs.map(([i]) => i)), saidB = new Set(pairs.map(([, j]) => j));
|
|
34783
|
-
const
|
|
34851
|
+
const missing5 = a.filter((_w, i) => !saidA.has(i)), extra2 = b.filter((_w, j) => !saidB.has(j));
|
|
34784
34852
|
const n = a.length, matched = pairs.length;
|
|
34785
|
-
return { script: n, heard: b.length, matched, share: n ? Math.round(matched / n * 100) / 100 : 1, missing:
|
|
34853
|
+
return { script: n, heard: b.length, matched, share: n ? Math.round(matched / n * 100) / 100 : 1, missing: missing5.slice(0, 12), extra: extra2.slice(0, 12) };
|
|
34786
34854
|
};
|
|
34787
34855
|
lineTimes = (lines2, words) => {
|
|
34788
34856
|
const perLine = lines2.map((l) => comparedWords(l));
|
|
@@ -35012,7 +35080,7 @@ var init_character = __esm({
|
|
|
35012
35080
|
});
|
|
35013
35081
|
|
|
35014
35082
|
// src/video/commands/materials.ts
|
|
35015
|
-
var errorsIn, PICTURE_EXT2, givenAnchor, characterOf, budgeted, payingPending, LOOK_AGAIN_MS, waitLimitMs,
|
|
35083
|
+
var errorsIn, PICTURE_EXT2, givenAnchor, characterOf, budgeted, payingPending, LOOK_AGAIN_MS, waitLimitMs, pendingNext3, beingMade2, allRuns, PRICE_NEXT, specOf2, toAgree, materials;
|
|
35016
35084
|
var init_materials = __esm({
|
|
35017
35085
|
"src/video/commands/materials.ts"() {
|
|
35018
35086
|
"use strict";
|
|
@@ -35080,7 +35148,7 @@ var init_materials = __esm({
|
|
|
35080
35148
|
});
|
|
35081
35149
|
LOOK_AGAIN_MS = 15e3;
|
|
35082
35150
|
waitLimitMs = (rt) => (Number(rt.env.POPOST_GEN_WAIT_MIN) > 0 ? Number(rt.env.POPOST_GEN_WAIT_MIN) : 30) * 6e4;
|
|
35083
|
-
|
|
35151
|
+
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.";
|
|
35084
35152
|
beingMade2 = (pending3) => {
|
|
35085
35153
|
const count5 = (kind, word2) => {
|
|
35086
35154
|
const n = pending3.filter((m) => m.kind === kind).length;
|
|
@@ -35095,7 +35163,7 @@ var init_materials = __esm({
|
|
|
35095
35163
|
const deadline2 = rt.now().getTime() + waitLimitMs(rt);
|
|
35096
35164
|
while (!noWait && r.materials.some((m) => m.pending || m.queued) && rt.now().getTime() < deadline2) {
|
|
35097
35165
|
const queued = r.materials.filter((m) => m.queued).length;
|
|
35098
|
-
rt.stderr(beingMade2(r.materials.filter((m) => m.pending)) + " being made
|
|
35166
|
+
rt.stderr(beingMade2(r.materials.filter((m) => m.pending)) + " being made by the selected generator" + (queued ? ", " + queued + " queued after them" : "") + "\n");
|
|
35099
35167
|
await sleep(rt, LOOK_AGAIN_MS);
|
|
35100
35168
|
r = await once5();
|
|
35101
35169
|
for (const m of r.materials) if (m.made) made.add(m.file);
|
|
@@ -35136,7 +35204,7 @@ var init_materials = __esm({
|
|
|
35136
35204
|
...CREDIT_OPTIONS,
|
|
35137
35205
|
{ 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" },
|
|
35138
35206
|
{ 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" },
|
|
35139
|
-
{ flag: "--no-wait", kind: "flag", help: 'send every clip and picture that can be sent and return at once
|
|
35207
|
+
{ 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' }
|
|
35140
35208
|
]
|
|
35141
35209
|
},
|
|
35142
35210
|
async (args2, rt) => {
|
|
@@ -35148,12 +35216,23 @@ var init_materials = __esm({
|
|
|
35148
35216
|
const modes = pkg ? modeContextOf(pkg.template) : void 0;
|
|
35149
35217
|
const sheet4 = await readProductSheet(rt, dir);
|
|
35150
35218
|
const showsProduct = Array.isArray(requests) && requests.some((r5) => Array.isArray(r5?.products) && r5.products.length > 0);
|
|
35151
|
-
const
|
|
35219
|
+
const internal = builtInGenerator(rt);
|
|
35220
|
+
const route2 = internal ? "popost.ai" : commandGenerator(rt) ? "external" : void 0;
|
|
35221
|
+
const frameRequests = Array.isArray(requests) && requests.some((r5) => r5?.firstFrame !== void 0 || r5?.lastFrame !== void 0 || r5?.continues !== void 0);
|
|
35222
|
+
const limits = sheet4.sheet && showsProduct || frameRequests ? await referenceLimits(rt) : {};
|
|
35223
|
+
const frameSupport = limits.limits?.frames;
|
|
35224
|
+
const frameAdvice = route2 === "external" && frameRequests && frameSupport === void 0 ? [{
|
|
35225
|
+
level: "warning",
|
|
35226
|
+
at: "POPOST_GEN_FRAMES",
|
|
35227
|
+
message: "Exact frame support has not been verified for this external generator.",
|
|
35228
|
+
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."
|
|
35229
|
+
}] : [];
|
|
35230
|
+
const generation = route2 ? { pipeline: "popost video materials", provider: route2 } : void 0;
|
|
35152
35231
|
if (args2.flag("check")) {
|
|
35153
|
-
const wrong = await checkRequests(rt, requests, dir, { selectedIdentity: !!(args2.string("character") || args2.string("anchor-image")), ...times ? { times } : {}, clipMusic: await clipMusicExceptions(rt, dir) });
|
|
35232
|
+
const wrong = await checkRequests(rt, requests, dir, { selectedIdentity: !!(args2.string("character") || args2.string("anchor-image")), frames: frameSupport, ...times ? { times } : {}, clipMusic: await clipMusicExceptions(rt, dir) });
|
|
35154
35233
|
const product = Array.isArray(requests) ? await productRequestProblems(rt, requests, dir, { loaded: sheet4, castPictures: await castPictureCount(rt, dir), hint: true, ...limits }) : [];
|
|
35155
35234
|
const stops = wrong.length + errorsIn(product);
|
|
35156
|
-
printJson(rt, { ok: stops === 0, requests: Array.isArray(requests) ? requests.length : 0, problems: [...wrong, ...product, ...groupingAdvice(requests)] });
|
|
35235
|
+
printJson(rt, { ok: stops === 0, requests: Array.isArray(requests) ? requests.length : 0, generation, problems: [...wrong, ...product, ...frameAdvice, ...groupingAdvice(requests)] });
|
|
35157
35236
|
return stops ? 2 : 0;
|
|
35158
35237
|
}
|
|
35159
35238
|
const [image2, character, off2] = [args2.string("anchor-image"), args2.string("character"), args2.flag("no-anchor")];
|
|
@@ -35163,7 +35242,7 @@ var init_materials = __esm({
|
|
|
35163
35242
|
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.');
|
|
35164
35243
|
const picture3 = image2 !== void 0 ? await givenAnchor(rt, dir, image2) : character !== void 0 ? await characterOf(rt, dir, character) : void 0;
|
|
35165
35244
|
const wallet = max !== void 0 ? new Wallet(max) : void 0;
|
|
35166
|
-
const pricedOnly = wallet === void 0 &&
|
|
35245
|
+
const pricedOnly = wallet === void 0 && internal && !rt.env.POPOST_GEN_MAX_CREDITS && !/\s--yes\b/.test(rt.env.POPOST_GEN_CMD ?? "");
|
|
35167
35246
|
if (!pricedOnly && Array.isArray(requests) && !errorsIn(sheet4.problems)) {
|
|
35168
35247
|
const current = await currentInputs(rt, dir, { requests, ...picture3 ? { anchor: picture3.file } : {} });
|
|
35169
35248
|
const needed = [...current.toMake, ...picture3 && current.toMake.length ? ["anchor"] : []];
|
|
@@ -35192,6 +35271,8 @@ var init_materials = __esm({
|
|
|
35192
35271
|
plan: wallet !== void 0,
|
|
35193
35272
|
submitOnly: true,
|
|
35194
35273
|
product: { ...limits, paying: !pricedOnly },
|
|
35274
|
+
frames: frameSupport,
|
|
35275
|
+
provider: route2,
|
|
35195
35276
|
policy,
|
|
35196
35277
|
// The template's beats give spoken lines their times; a video with a music track of its own gets clips without music.
|
|
35197
35278
|
...times ? { times } : {},
|
|
@@ -35214,17 +35295,18 @@ var init_materials = __esm({
|
|
|
35214
35295
|
...r.materials.some((m) => m.pending || m.queued) ? {
|
|
35215
35296
|
pending: r.materials.filter((m) => m.pending).map((m) => ({ file: m.file, ...m.task ? { task: m.task } : {} })),
|
|
35216
35297
|
...r.materials.some((m) => m.queued) ? { queued: r.materials.filter((m) => m.queued).map((m) => ({ file: m.file, after: m.waitsFor })) } : {},
|
|
35217
|
-
...agree ? {} : { next:
|
|
35298
|
+
...agree ? {} : { next: pendingNext3(internal) }
|
|
35218
35299
|
} : {},
|
|
35219
35300
|
credits: r.credits,
|
|
35220
35301
|
chargedCredits: r.chargedCredits,
|
|
35221
35302
|
...r.anchor ? { anchor: r.anchor } : {},
|
|
35222
35303
|
...r.toConfirm ? { toConfirm: r.toConfirm } : {},
|
|
35223
35304
|
...agree ?? {},
|
|
35305
|
+
generation,
|
|
35224
35306
|
materials: r.materials,
|
|
35225
35307
|
...r.notes?.length ? { notes: r.notes } : {},
|
|
35226
35308
|
...r.clipMusic?.length ? { clipMusic: r.clipMusic } : {},
|
|
35227
|
-
problems: [...r.problems, ...groupingAdvice(requests)]
|
|
35309
|
+
problems: [...r.problems, ...frameAdvice, ...groupingAdvice(requests)]
|
|
35228
35310
|
});
|
|
35229
35311
|
return agree ? CONFIRM_EXIT : errorsIn(r.problems) ? 2 : 0;
|
|
35230
35312
|
},
|
|
@@ -35402,9 +35484,9 @@ var init_inputs = __esm({
|
|
|
35402
35484
|
const data = await rt.fs.readText(rt.path.join(dir, SUMMARY_JSON)).then((t) => JSON.parse(t), () => void 0);
|
|
35403
35485
|
const summary4 = data ? withDisplay(data, display) : void 0;
|
|
35404
35486
|
if (summary4) await writeSummary(rt, dir, summary4);
|
|
35405
|
-
const
|
|
35406
|
-
await writeInputs(rt, dir, { ...record2, display, shown: { ...record2.shown, ...
|
|
35407
|
-
printJson(rt, { ok: true, stored: Object.keys(map), summary: rt.path.join(dir, SUMMARY_MD), displayMissing:
|
|
35487
|
+
const missing5 = summary4?.displayMissing ?? [];
|
|
35488
|
+
await writeInputs(rt, dir, { ...record2, display, shown: { ...record2.shown, ...missing5.length ? { missing: missing5 } : { missing: [] } } });
|
|
35489
|
+
printJson(rt, { ok: true, stored: Object.keys(map), summary: rt.path.join(dir, SUMMARY_MD), displayMissing: missing5, next: missing5.length ? "Still owed: " + missing5.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." });
|
|
35408
35490
|
},
|
|
35409
35491
|
(args2) => args2.string("project")
|
|
35410
35492
|
);
|
|
@@ -35419,8 +35501,8 @@ var init_inputs = __esm({
|
|
|
35419
35501
|
},
|
|
35420
35502
|
async (args2, rt) => {
|
|
35421
35503
|
const dir = userPath(rt, args2.req("project"));
|
|
35422
|
-
const [
|
|
35423
|
-
if (!!
|
|
35504
|
+
const [quote16, unattended] = [args2.string("quote")?.trim(), args2.string("unattended")?.trim()];
|
|
35505
|
+
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.`);
|
|
35424
35506
|
const record2 = await readInputs(rt, dir);
|
|
35425
35507
|
const shown3 = record2.shown;
|
|
35426
35508
|
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.");
|
|
@@ -35428,12 +35510,12 @@ var init_inputs = __esm({
|
|
|
35428
35510
|
const current = await currentInputs(rt, dir, { requests, ...shown3.anchor ? { anchor: shown3.anchor } : {} });
|
|
35429
35511
|
const changed2 = Object.keys({ ...shown3.items, ...current.items }).filter((k) => shown3.items[k] !== current.items[k]);
|
|
35430
35512
|
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.");
|
|
35431
|
-
if (
|
|
35432
|
-
const by =
|
|
35513
|
+
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.");
|
|
35514
|
+
const by = quote16 ? "user" : "unattended";
|
|
35433
35515
|
const at7 = rt.now().toISOString();
|
|
35434
|
-
await writeInputs(rt, dir, { ...record2, confirmed: { by, quote:
|
|
35516
|
+
await writeInputs(rt, dir, { ...record2, confirmed: { by, quote: quote16 ?? unattended ?? "", at: at7, items: shown3.items } });
|
|
35435
35517
|
const sheet4 = (await readProductSheet(rt, dir)).sheet;
|
|
35436
|
-
if (sheet4 && inferredFacts(sheet4).length && confirmationOf(sheet4) !== "confirmed") await writeJson(rt, rt.path.join(dir, PRODUCT_FILE), { ...sheet4, confirmation: { by, quote:
|
|
35518
|
+
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 } });
|
|
35437
35519
|
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." });
|
|
35438
35520
|
},
|
|
35439
35521
|
(args2) => args2.string("project")
|
|
@@ -35960,9 +36042,9 @@ var init_core2 = __esm({
|
|
|
35960
36042
|
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)));
|
|
35961
36043
|
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]));
|
|
35962
36044
|
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]));
|
|
35963
|
-
const
|
|
36045
|
+
const moved2 = deltaE(next, at7);
|
|
35964
36046
|
at7 = next;
|
|
35965
|
-
if (
|
|
36047
|
+
if (moved2 < 1.5) break;
|
|
35966
36048
|
}
|
|
35967
36049
|
return rgb ? { lab: at7, rgb } : void 0;
|
|
35968
36050
|
};
|
|
@@ -35987,10 +36069,10 @@ var init_core2 = __esm({
|
|
|
35987
36069
|
const far2 = near3.slice(0, Math.max(5, Math.round(near3.length / 4))).map((n) => n.x);
|
|
35988
36070
|
const next = labMedian(far2.map((x2) => x2.lab));
|
|
35989
36071
|
if (seen.filter((x2) => deltaE(x2.lab, next) <= 14).length < seen.length / 6) break;
|
|
35990
|
-
const
|
|
36072
|
+
const moved2 = deltaE(next, at7);
|
|
35991
36073
|
at7 = next;
|
|
35992
36074
|
rgb = rgbMedian(far2.map((x2) => x2.rgb));
|
|
35993
|
-
if (
|
|
36075
|
+
if (moved2 < 1.5) break;
|
|
35994
36076
|
}
|
|
35995
36077
|
return { lab: at7, rgb };
|
|
35996
36078
|
};
|
|
@@ -36010,14 +36092,14 @@ var init_core2 = __esm({
|
|
|
36010
36092
|
};
|
|
36011
36093
|
const scan2 = (outer, inner, at7, into) => {
|
|
36012
36094
|
for (let o = outer[0]; o < outer[1]; o++) {
|
|
36013
|
-
let
|
|
36095
|
+
let run7 = 0;
|
|
36014
36096
|
for (let i = inner[0]; i <= inner[1]; i++) {
|
|
36015
36097
|
if (i < inner[1] && at7(o, i)) {
|
|
36016
|
-
|
|
36098
|
+
run7++;
|
|
36017
36099
|
continue;
|
|
36018
36100
|
}
|
|
36019
|
-
if (
|
|
36020
|
-
|
|
36101
|
+
if (run7 > 0 && run7 <= max) into.push(run7);
|
|
36102
|
+
run7 = 0;
|
|
36021
36103
|
}
|
|
36022
36104
|
}
|
|
36023
36105
|
};
|
|
@@ -36206,13 +36288,13 @@ var init_letters = __esm({
|
|
|
36206
36288
|
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);
|
|
36207
36289
|
let covered4 = 0, total2 = 0;
|
|
36208
36290
|
for (const y of rows3) {
|
|
36209
|
-
let
|
|
36291
|
+
let run7 = 0;
|
|
36210
36292
|
for (let x2 = x0; x2 <= x1; x2++) {
|
|
36211
36293
|
const near3 = x2 < x1 && edge2At(f, y * f.w + x2, lab) <= NEAR * NEAR;
|
|
36212
|
-
if (near3)
|
|
36294
|
+
if (near3) run7++;
|
|
36213
36295
|
else {
|
|
36214
|
-
if (
|
|
36215
|
-
|
|
36296
|
+
if (run7 >= wide) covered4 += run7;
|
|
36297
|
+
run7 = 0;
|
|
36216
36298
|
}
|
|
36217
36299
|
}
|
|
36218
36300
|
total2 += x1 - x0;
|
|
@@ -36650,7 +36732,7 @@ var init_shadow = __esm({
|
|
|
36650
36732
|
MIN_LINES = 2;
|
|
36651
36733
|
lightness = (f, x2, y) => f.lab[3 * (y * f.w + x2)] ?? 0;
|
|
36652
36734
|
scan = (ls, bg, into) => {
|
|
36653
|
-
const
|
|
36735
|
+
const tail4 = (from, step2) => {
|
|
36654
36736
|
let n = 0;
|
|
36655
36737
|
for (let t = from + step2; t >= 0 && t < ls.length; t += step2) {
|
|
36656
36738
|
const v = ls[t] ?? 0, prev = ls[t - step2] ?? 0;
|
|
@@ -36662,8 +36744,8 @@ var init_shadow = __esm({
|
|
|
36662
36744
|
for (let t = 1; t + 1 < ls.length; t++) {
|
|
36663
36745
|
const v = ls[t] ?? 0;
|
|
36664
36746
|
if (v > bg - CORE || v > (ls[t - 1] ?? 0) || v > (ls[t + 1] ?? 0)) continue;
|
|
36665
|
-
into.before.push(
|
|
36666
|
-
into.after.push(
|
|
36747
|
+
into.before.push(tail4(t, -1));
|
|
36748
|
+
into.after.push(tail4(t, 1));
|
|
36667
36749
|
}
|
|
36668
36750
|
};
|
|
36669
36751
|
lightLines = (around3) => around3.flatMap((px2, k) => px2.length && labMedian(px2)[0] >= LIGHT ? [k] : []);
|
|
@@ -37150,9 +37232,9 @@ var init_readback_kept = __esm({
|
|
|
37150
37232
|
const who = readerOf(rt);
|
|
37151
37233
|
const [hashes2, kept3] = await Promise.all([Promise.all(frames.map(async (f) => sha256(await rt.fs.readFile(f.file)))), keptLines(rt, file, who)]);
|
|
37152
37234
|
const old = hashes2.map((h) => Array.isArray(kept3[h]) ? kept3[h] : void 0);
|
|
37153
|
-
const
|
|
37154
|
-
onKept?.(frames.length -
|
|
37155
|
-
const read2 = new Map((
|
|
37235
|
+
const missing5 = frames.filter((_f, i) => old[i] === void 0);
|
|
37236
|
+
onKept?.(frames.length - missing5.length, frames.length);
|
|
37237
|
+
const read2 = new Map((missing5.length ? await reader.read(missing5) : []).map((s) => [s.frame, s.lines]));
|
|
37156
37238
|
const found = frames.flatMap((f, i) => {
|
|
37157
37239
|
const lines2 = old[i] ?? read2.get(f.frame);
|
|
37158
37240
|
return lines2 ? [{ hash: hashes2[i], sample: { frame: f.frame, lines: lines2 } }] : [];
|
|
@@ -37491,12 +37573,12 @@ var init_sheets = __esm({
|
|
|
37491
37573
|
const fps = p.fps > 0 ? p.fps : 30;
|
|
37492
37574
|
const secondsOf4 = o.secondsOf ?? ((f) => f / fps);
|
|
37493
37575
|
const last = Math.max(0, sourceFrames(p) - 1);
|
|
37494
|
-
const drawings = specs2.map((
|
|
37495
|
-
const frames2 =
|
|
37576
|
+
const drawings = specs2.map((spec10) => {
|
|
37577
|
+
const frames2 = spec10.frames.filter((f) => f >= 0 && f <= last);
|
|
37496
37578
|
const grid = gridOf(Math.max(1, frames2.length), size.width);
|
|
37497
37579
|
const width = GAP2 + grid.columns * (size.width + GAP2), height = GAP2 + grid.rows * (size.height + BAND + GAP2);
|
|
37498
|
-
const result = { file: rt.path.join(o.outDir,
|
|
37499
|
-
return { spec: { ...
|
|
37580
|
+
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 };
|
|
37581
|
+
return { spec: { ...spec10, frames: frames2 }, grid, left: frames2.length, result };
|
|
37500
37582
|
});
|
|
37501
37583
|
const wanted = /* @__PURE__ */ new Map();
|
|
37502
37584
|
for (const d of drawings) d.spec.frames.forEach((f, slot) => {
|
|
@@ -38376,7 +38458,7 @@ var init_check6 = __esm({
|
|
|
38376
38458
|
fileProblems2 = async (rt, pkg, fill4, dir, lengths) => {
|
|
38377
38459
|
const exists4 = async (p) => await rt.fs.stat(p) !== null;
|
|
38378
38460
|
const out2 = [];
|
|
38379
|
-
const
|
|
38461
|
+
const missing5 = (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).");
|
|
38380
38462
|
for (const [k, raw] of fill4.shots.entries()) {
|
|
38381
38463
|
const s = raw;
|
|
38382
38464
|
if (k >= pkg.template.shots.length || kindsOf2(s).length !== 1) continue;
|
|
@@ -38385,7 +38467,7 @@ var init_check6 = __esm({
|
|
|
38385
38467
|
if (typeof file !== "string" || !file.trim() || isOutside(file)) continue;
|
|
38386
38468
|
const full = rt.path.resolve(dir, file);
|
|
38387
38469
|
if (!await exists4(full)) {
|
|
38388
|
-
out2.push(
|
|
38470
|
+
out2.push(missing5("shots[" + k + "]." + key2, file));
|
|
38389
38471
|
continue;
|
|
38390
38472
|
}
|
|
38391
38473
|
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."));
|
|
@@ -38395,8 +38477,8 @@ var init_check6 = __esm({
|
|
|
38395
38477
|
}
|
|
38396
38478
|
out2.push(...await itemFileProblems(rt, pkg, s, k, dir, lengths));
|
|
38397
38479
|
}
|
|
38398
|
-
if (typeof fill4.sound === "string" && !await exists4(rt.path.resolve(dir, fill4.sound))) out2.push(
|
|
38399
|
-
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(
|
|
38480
|
+
if (typeof fill4.sound === "string" && !await exists4(rt.path.resolve(dir, fill4.sound))) out2.push(missing5("sound", fill4.sound));
|
|
38481
|
+
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(missing5("beds[" + i + "].footage", bed.footage));
|
|
38400
38482
|
out2.push(...await stillProblems(rt, pkg, fill4, dir, lengths));
|
|
38401
38483
|
for (const p of await slotPictures(rt, fill4, dir)) out2.push(...await slotPictureProblems(rt, p, dir));
|
|
38402
38484
|
return out2;
|
|
@@ -38950,9 +39032,9 @@ var init_build2 = __esm({
|
|
|
38950
39032
|
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." });
|
|
38951
39033
|
const segment2 = { id: id2, frames, base: { material: "pic-" + id2, ...camera3 && Object.keys(camera3).length ? { camera: camera3 } : {} } };
|
|
38952
39034
|
if (into) {
|
|
38953
|
-
const
|
|
38954
|
-
if (
|
|
38955
|
-
segment2.in =
|
|
39035
|
+
const spec10 = transitionSpec2(into, toFrames2);
|
|
39036
|
+
if (spec10) {
|
|
39037
|
+
segment2.in = spec10;
|
|
38956
39038
|
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) + ")." });
|
|
38957
39039
|
}
|
|
38958
39040
|
}
|
|
@@ -39722,11 +39804,11 @@ var init_shot_transition = __esm({
|
|
|
39722
39804
|
};
|
|
39723
39805
|
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];
|
|
39724
39806
|
};
|
|
39725
|
-
transitionOf3 = (ref, other, into,
|
|
39807
|
+
transitionOf3 = (ref, other, into, locate4) => {
|
|
39726
39808
|
if (!into || into.kind === "cut") return void 0;
|
|
39727
39809
|
const fa = fpsOf(ref), dtA = ref.rhythm.step / fa, dtB = other.rhythm.step / fpsOf(other);
|
|
39728
39810
|
const reference2 = spanOf2(into, fa);
|
|
39729
|
-
const where3 =
|
|
39811
|
+
const where3 = locate4(reference2);
|
|
39730
39812
|
if (!ref.rhythm.change.length || !other.rhythm.change.length) return void 0;
|
|
39731
39813
|
const wa = { from: reference2.from - CONTEXT_SAMPLES * dtA, to: reference2.to + CONTEXT_SAMPLES * dtA };
|
|
39732
39814
|
const n = Math.max(MIN_POINTS, Math.round((wa.to - wa.from) / dtA));
|
|
@@ -40194,19 +40276,19 @@ var init_generate3 = __esm({
|
|
|
40194
40276
|
const kind = r.pick(kinds);
|
|
40195
40277
|
if (kind === "cut") return void 0;
|
|
40196
40278
|
const frames = r.int(Math.round(fps * 0.2), Math.round(fps * 0.6));
|
|
40197
|
-
const
|
|
40198
|
-
if (kind === "wipe")
|
|
40279
|
+
const spec10 = { transition: kind, frames };
|
|
40280
|
+
if (kind === "wipe") spec10.direction = r.pick(WIPE_DIRECTIONS);
|
|
40199
40281
|
if (kind === "slide") {
|
|
40200
|
-
|
|
40201
|
-
|
|
40282
|
+
spec10.direction = r.pick(DIRECTIONS2);
|
|
40283
|
+
spec10.mode = r.pick(["push", "cover", "reveal"]);
|
|
40202
40284
|
}
|
|
40203
|
-
if (kind === "whip")
|
|
40204
|
-
if (kind === "fade")
|
|
40285
|
+
if (kind === "whip") spec10.direction = r.pick(DIRECTIONS2);
|
|
40286
|
+
if (kind === "fade") spec10.via = r.pick(["black", "white"]);
|
|
40205
40287
|
if (sides && SIDED.includes(kind) && r.chance(0.5)) {
|
|
40206
|
-
|
|
40207
|
-
|
|
40288
|
+
spec10.side = r.pick(["after", "before"]);
|
|
40289
|
+
spec10.strength = r.pick([0.6, 1, 1.5]);
|
|
40208
40290
|
}
|
|
40209
|
-
return
|
|
40291
|
+
return spec10;
|
|
40210
40292
|
};
|
|
40211
40293
|
cameraMove = (r, frames, fps) => {
|
|
40212
40294
|
const from = r.int(Math.round(fps * 0.5), Math.round(frames * 0.3));
|
|
@@ -40217,14 +40299,14 @@ var init_generate3 = __esm({
|
|
|
40217
40299
|
};
|
|
40218
40300
|
motion2 = (r, presets, fps, maxFrames) => {
|
|
40219
40301
|
const preset = r.pick(presets);
|
|
40220
|
-
const
|
|
40221
|
-
if (preset === "none") return
|
|
40222
|
-
|
|
40223
|
-
if (preset !== "type")
|
|
40224
|
-
if (preset === "pop")
|
|
40225
|
-
if (preset === "slide" || preset === "wipe")
|
|
40226
|
-
if (preset === "slide")
|
|
40227
|
-
return
|
|
40302
|
+
const spec10 = { preset };
|
|
40303
|
+
if (preset === "none") return spec10;
|
|
40304
|
+
spec10.frames = Math.max(3, Math.min(maxFrames, r.int(Math.round(fps * 0.2), Math.round(fps * 0.5))));
|
|
40305
|
+
if (preset !== "type") spec10.ease = r.pick(EASES3);
|
|
40306
|
+
if (preset === "pop") spec10.overshoot = r.pick([0.08, 0.12, 0.2]);
|
|
40307
|
+
if (preset === "slide" || preset === "wipe") spec10.direction = r.pick(DIRECTIONS2);
|
|
40308
|
+
if (preset === "slide") spec10.distance = r.pick([0.2, 0.3, 0.45]);
|
|
40309
|
+
return spec10;
|
|
40228
40310
|
};
|
|
40229
40311
|
boxes = (r, n) => {
|
|
40230
40312
|
const rows3 = [0.1, 0.4, 0.7];
|
|
@@ -40261,9 +40343,9 @@ var init_generate3 = __esm({
|
|
|
40261
40343
|
const k = segments2.findIndex((s3) => "assets/" + s3.id + ".png" === p.file);
|
|
40262
40344
|
const s = segments2[k], next = segments2[k + 1];
|
|
40263
40345
|
if (!s || !ALIASING.has(p.recipe.source)) return p;
|
|
40264
|
-
const
|
|
40346
|
+
const moved2 = "material" in s.base && s.base.camera !== void 0;
|
|
40265
40347
|
const transformed = [s.in, next?.in].some((t) => t !== void 0 && TRANSFORMING.has(t.transition));
|
|
40266
|
-
return
|
|
40348
|
+
return moved2 || transformed ? { ...p, recipe: { ...p.recipe, source: STEADY2[p.recipe.seed % STEADY2.length] } } : p;
|
|
40267
40349
|
});
|
|
40268
40350
|
synthCase = (options) => {
|
|
40269
40351
|
const o = { width: 1080, height: 1920, fps: 30, transitions: ALL_TRANSITIONS, motions: ALL_MOTIONS, pictureShare: 0.6, maxItems: 2, cameraShare: 0.4, ...options };
|
|
@@ -41491,7 +41573,7 @@ var init_director = __esm({
|
|
|
41491
41573
|
}
|
|
41492
41574
|
};
|
|
41493
41575
|
const shot = async () => {
|
|
41494
|
-
const
|
|
41576
|
+
const spec10 = {
|
|
41495
41577
|
camera: camera3,
|
|
41496
41578
|
sample: sampleNext || frames % SAMPLE_EVERY === 0,
|
|
41497
41579
|
...highlight ? { highlight: { ...highlight, line } } : {},
|
|
@@ -41499,7 +41581,7 @@ var init_director = __esm({
|
|
|
41499
41581
|
...ring2 ? { ring: { ...ring2, line: Math.max(1.5, line * 0.75) } } : {}
|
|
41500
41582
|
};
|
|
41501
41583
|
sampleNext = false;
|
|
41502
|
-
const draw2 = () => page2.evaluate((f) => window.__popostStage ? { sample: window.__popostStage.render(f) } : null,
|
|
41584
|
+
const draw2 = () => page2.evaluate((f) => window.__popostStage ? { sample: window.__popostStage.render(f) } : null, spec10);
|
|
41503
41585
|
let drawn = await draw2();
|
|
41504
41586
|
if (!drawn) {
|
|
41505
41587
|
await newDocument();
|
|
@@ -41520,7 +41602,7 @@ var init_director = __esm({
|
|
|
41520
41602
|
frames++;
|
|
41521
41603
|
return Buffer.from(shotOf4.data, "base64");
|
|
41522
41604
|
};
|
|
41523
|
-
const
|
|
41605
|
+
const locate4 = async (index, selector) => {
|
|
41524
41606
|
const handle3 = await page2.locator(selector).first().elementHandle({ timeout: 3e3 }).catch(() => null);
|
|
41525
41607
|
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.');
|
|
41526
41608
|
return handle3;
|
|
@@ -41537,7 +41619,7 @@ var init_director = __esm({
|
|
|
41537
41619
|
return z10.x > 0 && z10.y > 0 && a.x < view.width && a.y < view.height;
|
|
41538
41620
|
};
|
|
41539
41621
|
const middleOf2 = async (index, selector, scroll) => {
|
|
41540
|
-
const handle3 = await
|
|
41622
|
+
const handle3 = await locate4(index, selector);
|
|
41541
41623
|
let b = await boxOf(index, handle3, selector);
|
|
41542
41624
|
let p = { x: b.x + b.width / 2, y: b.y + b.height / 2 };
|
|
41543
41625
|
if (scroll && !inWindow(p)) {
|
|
@@ -41585,7 +41667,7 @@ var init_director = __esm({
|
|
|
41585
41667
|
const named = Array.isArray(z10.to) ? "the box " + JSON.stringify(z10.to) : '"' + z10.to + '"';
|
|
41586
41668
|
const box2 = Array.isArray(z10.to) ? { x: z10.to[0], y: z10.to[1], width: z10.to[2], height: z10.to[3] } : await (async () => {
|
|
41587
41669
|
const sel = z10.to;
|
|
41588
|
-
const b = await boxOf(index, await
|
|
41670
|
+
const b = await boxOf(index, await locate4(index, sel), sel);
|
|
41589
41671
|
return { ...b, x: b.x + now.scrollX, y: b.y + now.scrollY };
|
|
41590
41672
|
})();
|
|
41591
41673
|
plan4 = zoomPlan(box2, now, view, fill4, o.band);
|
|
@@ -41606,7 +41688,7 @@ var init_director = __esm({
|
|
|
41606
41688
|
}
|
|
41607
41689
|
async function* mark(index, h, frame2) {
|
|
41608
41690
|
const id2 = nextId++;
|
|
41609
|
-
await keep3(await
|
|
41691
|
+
await keep3(await locate4(index, h.to), id2);
|
|
41610
41692
|
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 };
|
|
41611
41693
|
const count5 = h.frames ?? DEFAULTS.highlightFrames;
|
|
41612
41694
|
for (let i = 1; i <= count5; i++) {
|
|
@@ -41630,7 +41712,7 @@ var init_director = __esm({
|
|
|
41630
41712
|
highlight = void 0;
|
|
41631
41713
|
}
|
|
41632
41714
|
async function* type(index, t, frame2) {
|
|
41633
|
-
const handle3 = await
|
|
41715
|
+
const handle3 = await locate4(index, t.into);
|
|
41634
41716
|
try {
|
|
41635
41717
|
await handle3.fill("", { timeout: 3e3 });
|
|
41636
41718
|
await handle3.focus();
|
|
@@ -41650,7 +41732,7 @@ var init_director = __esm({
|
|
|
41650
41732
|
}
|
|
41651
41733
|
async function* hover(index, selector, frame2) {
|
|
41652
41734
|
if (!pointer) {
|
|
41653
|
-
await (await
|
|
41735
|
+
await (await locate4(index, selector)).hover({ timeout: 5e3 });
|
|
41654
41736
|
yield await frame2();
|
|
41655
41737
|
return;
|
|
41656
41738
|
}
|
|
@@ -41663,7 +41745,7 @@ var init_director = __esm({
|
|
|
41663
41745
|
}
|
|
41664
41746
|
async function* click(index, selector, frame2) {
|
|
41665
41747
|
if (!pointer) {
|
|
41666
|
-
const handle3 = await
|
|
41748
|
+
const handle3 = await locate4(index, selector);
|
|
41667
41749
|
await settleAfter(() => handle3.click({ timeout: 5e3 }));
|
|
41668
41750
|
yield await frame2();
|
|
41669
41751
|
return;
|
|
@@ -43297,7 +43379,7 @@ var init_render3 = __esm({
|
|
|
43297
43379
|
lastSent = now;
|
|
43298
43380
|
send2(next);
|
|
43299
43381
|
};
|
|
43300
|
-
const
|
|
43382
|
+
const run7 = async (settings2, snapshot) => {
|
|
43301
43383
|
const started = rt.now().getTime();
|
|
43302
43384
|
set2({ state: "running", frame: 0, total: 0, started });
|
|
43303
43385
|
try {
|
|
@@ -43329,7 +43411,7 @@ var init_render3 = __esm({
|
|
|
43329
43411
|
return {
|
|
43330
43412
|
start: (settings2, snapshot) => {
|
|
43331
43413
|
if (running) return false;
|
|
43332
|
-
running =
|
|
43414
|
+
running = run7(settings2, snapshot).finally(() => {
|
|
43333
43415
|
running = void 0;
|
|
43334
43416
|
});
|
|
43335
43417
|
return true;
|
|
@@ -44087,7 +44169,7 @@ var init_lifecycle = __esm({
|
|
|
44087
44169
|
init_native();
|
|
44088
44170
|
pause = (rt, ms) => rt.sleep?.(ms) ?? new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
44089
44171
|
waitForExit = async (rt, app) => {
|
|
44090
|
-
for (let
|
|
44172
|
+
for (let attempt3 = 0; attempt3 < 25; attempt3++) {
|
|
44091
44173
|
if (!(await applicationPids(rt, app)).length) return true;
|
|
44092
44174
|
await pause(rt, 200);
|
|
44093
44175
|
}
|
|
@@ -44109,7 +44191,7 @@ var init_lifecycle = __esm({
|
|
|
44109
44191
|
else await runNative(rt, ["taskkill", "/PID", String(pid)]);
|
|
44110
44192
|
}
|
|
44111
44193
|
if (restarted && !await waitForExit(rt, app)) return { ok: false, restarted, quitPending: true };
|
|
44112
|
-
for (let
|
|
44194
|
+
for (let attempt3 = 0; attempt3 < 4; attempt3++) {
|
|
44113
44195
|
if (rt.platform === "darwin") await runNative(rt, ["open", "-a", app.appPath]);
|
|
44114
44196
|
else if (rt.processes) await rt.processes.spawnDetached([app.executable], { cwd: app.appPath, logFile: rt.path.join(dir, ".studio", "native-editor.log") });
|
|
44115
44197
|
else return { ok: false, restarted, message: "This host cannot launch the desktop editor." };
|
|
@@ -45063,10 +45145,10 @@ var init_copied = __esm({
|
|
|
45063
45145
|
for (let i = 0; i < tokens3.length; ) {
|
|
45064
45146
|
let j = i;
|
|
45065
45147
|
while (j < tokens3.length && all.includes(keyOf7(tokens3.slice(i, j + 1)))) j++;
|
|
45066
|
-
const
|
|
45067
|
-
const key2 = keyOf7(
|
|
45068
|
-
const line =
|
|
45069
|
-
if (line) out2.push({ shown: normal.slice(
|
|
45148
|
+
const run7 = tokens3.slice(i, j);
|
|
45149
|
+
const key2 = keyOf7(run7);
|
|
45150
|
+
const line = run7.reduce((n, x2) => n + x2.weight, 0) >= PHRASE && !told.includes(key2) ? lines2.find((l) => l.key.includes(key2))?.line : void 0;
|
|
45151
|
+
if (line) out2.push({ shown: normal.slice(run7[0]?.at ?? 0, run7[run7.length - 1]?.end ?? 0), line });
|
|
45070
45152
|
i = line ? j : i + 1;
|
|
45071
45153
|
}
|
|
45072
45154
|
return out2;
|
|
@@ -45152,11 +45234,11 @@ var init_findings2 = __esm({
|
|
|
45152
45234
|
};
|
|
45153
45235
|
unseenProblem = (shot, mine, longer, theirs, picture3) => {
|
|
45154
45236
|
const shown3 = theirs.filter((t) => t.visible).map((t) => t.index);
|
|
45155
|
-
const
|
|
45156
|
-
if (!
|
|
45237
|
+
const missing5 = outermost(mine.filter((t) => !t.visible && shown3.includes(t.index))).slice(0, 3);
|
|
45238
|
+
if (!missing5.length) return void 0;
|
|
45157
45239
|
return warning(
|
|
45158
45240
|
at4(shot.k),
|
|
45159
|
-
"In " + where2(shot) + ", a shot of " + s2(shot.seconds) + ", " + quoted4(
|
|
45241
|
+
"In " + where2(shot) + ", a shot of " + s2(shot.seconds) + ", " + quoted4(missing5.map((t) => t.text)) + (missing5.length > 1 ? " are" : " is") + " never visible (" + picture3 + '), though segment "' + longer.id + '" (' + s2(longer.seconds) + ") shows " + (missing5.length > 1 ? "them" : "it") + " with the same scene file: the entrance starts after this shorter shot has ended.",
|
|
45160
45242
|
'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."
|
|
45161
45243
|
);
|
|
45162
45244
|
};
|
|
@@ -46811,13 +46893,13 @@ var init_see = __esm({
|
|
|
46811
46893
|
}
|
|
46812
46894
|
const usage2 = { input: 0, output: 0 };
|
|
46813
46895
|
let why = "";
|
|
46814
|
-
for (let
|
|
46896
|
+
for (let attempt3 = 1; attempt3 <= 2; attempt3++) {
|
|
46815
46897
|
const reply = await o.model.ask([{ role: "user", content }]);
|
|
46816
46898
|
usage2.input += reply.usage?.input ?? 0;
|
|
46817
46899
|
usage2.output += reply.usage?.output ?? 0;
|
|
46818
46900
|
const value = extractJson(reply.text).value;
|
|
46819
46901
|
const list7 = Array.isArray(value?.shots) ? value.shots.filter((x2) => typeof x2 === "string" && x2.trim() !== "") : [];
|
|
46820
|
-
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:
|
|
46902
|
+
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 };
|
|
46821
46903
|
why = "the model gave " + list7.length + " sentences for " + shots2.length + " shots";
|
|
46822
46904
|
}
|
|
46823
46905
|
return { usage: usage2, requests: 2, why };
|
|
@@ -48015,14 +48097,14 @@ var init_hosted3 = __esm({
|
|
|
48015
48097
|
}
|
|
48016
48098
|
};
|
|
48017
48099
|
quoteOrder = async (rt, seconds8) => {
|
|
48018
|
-
const
|
|
48100
|
+
const quote16 = await quoteMusicTrack(rt, seconds8).catch((e) => {
|
|
48019
48101
|
const max = e instanceof PopostApiError && e.code === "INVALID_REQUEST" && typeof e.details.maxSeconds === "number" ? e.details.maxSeconds : void 0;
|
|
48020
48102
|
if (max !== void 0) throw new MusicTooLong(seconds8, max);
|
|
48021
48103
|
if (e instanceof PopostApiError && e.code === "UPSTREAM_ERROR" && (e.status === 503 || e.status === void 0)) throw new MusicUnavailable();
|
|
48022
48104
|
throw e;
|
|
48023
48105
|
});
|
|
48024
|
-
if (
|
|
48025
|
-
return
|
|
48106
|
+
if (quote16.maxTrackSeconds !== null && seconds8 > quote16.maxTrackSeconds) throw new MusicTooLong(seconds8, quote16.maxTrackSeconds);
|
|
48107
|
+
return quote16;
|
|
48026
48108
|
};
|
|
48027
48109
|
UNAVAILABLE = "popost.ai could not make the music (its generator is not available now); nothing was charged. Run the same command again later.";
|
|
48028
48110
|
HINT = "Run the same command again: the same description and length reuse the same music job.";
|
|
@@ -48052,19 +48134,19 @@ var init_hosted3 = __esm({
|
|
|
48052
48134
|
};
|
|
48053
48135
|
inPlace = async (rt, out2, r) => r.audioSha256 !== void 0 && await rt.fs.readFile(out2).then((bytes) => sha256(bytes) === r.audioSha256, () => false);
|
|
48054
48136
|
orderLength = async (rt, seconds8) => {
|
|
48055
|
-
const
|
|
48056
|
-
const longer = Math.min(seconds8 + MARGIN_SECONDS,
|
|
48057
|
-
if (!(longer > seconds8)) return { seconds: seconds8, quote:
|
|
48137
|
+
const quote16 = await quoteOrder(rt, seconds8);
|
|
48138
|
+
const longer = Math.min(seconds8 + MARGIN_SECONDS, quote16.maxTrackSeconds === null ? Infinity : Math.floor(quote16.maxTrackSeconds));
|
|
48139
|
+
if (!(longer > seconds8)) return { seconds: seconds8, quote: quote16 };
|
|
48058
48140
|
const more = await quoteOrder(rt, longer).catch((e) => {
|
|
48059
48141
|
if (e instanceof MusicTooLong) return void 0;
|
|
48060
48142
|
throw e;
|
|
48061
48143
|
});
|
|
48062
|
-
return more && more.credits ===
|
|
48144
|
+
return more && more.credits === quote16.credits ? { seconds: longer, quote: more } : { seconds: seconds8, quote: quote16 };
|
|
48063
48145
|
};
|
|
48064
48146
|
musicPrice = async (rt, o) => {
|
|
48065
48147
|
if ((await receiptOf2(rt, o)).id) return [];
|
|
48066
|
-
const { quote:
|
|
48067
|
-
return [{ kind: "music", what: (o.vocals ? "music with vocals: " : "instrumental music: ") + clip10(o.prompt) + (
|
|
48148
|
+
const { quote: quote16 } = await orderLength(rt, o.seconds);
|
|
48149
|
+
return [{ kind: "music", what: (o.vocals ? "music with vocals: " : "instrumental music: ") + clip10(o.prompt) + (quote16.model ? " (" + quote16.model + ")" : ""), credits: quote16.credits, seconds: o.seconds }];
|
|
48068
48150
|
};
|
|
48069
48151
|
download3 = async (rt, url, out2) => {
|
|
48070
48152
|
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 });
|
|
@@ -48127,8 +48209,8 @@ var init_hosted3 = __esm({
|
|
|
48127
48209
|
lengthOf = async (rt, o, known2) => {
|
|
48128
48210
|
const had = known2 ?? await audioSeconds(rt, o.out).catch(() => void 0);
|
|
48129
48211
|
if (had === void 0) return { seconds: null };
|
|
48130
|
-
const seconds8 = round22(had),
|
|
48131
|
-
return { seconds: seconds8, ...
|
|
48212
|
+
const seconds8 = round22(had), missing5 = round22((o.fit ?? o.seconds) - had);
|
|
48213
|
+
return { seconds: seconds8, ...missing5 > SHORT_TOLERANCE ? { short: { seconds: seconds8, missing: missing5 } } : {} };
|
|
48132
48214
|
};
|
|
48133
48215
|
written = async (rt, o, receipt, job) => {
|
|
48134
48216
|
if (job.state !== "ready" || !job.audioUrl) throw new ToolError("The popost.ai music is " + (job.state || "not ready") + "; run the same command again.");
|
|
@@ -48214,7 +48296,7 @@ var init_media = __esm({
|
|
|
48214
48296
|
const account = connected(rt);
|
|
48215
48297
|
const tools2 = { ...named, transcribe: named.transcribe ?? (account ? HOSTED : null), speak: named.speak ?? (account ? HOSTED : null), music: musicEnabled(rt) ? HOSTED : null };
|
|
48216
48298
|
const offers = account ? { hosted: HOSTED_NOTE } : { connect: CONNECT };
|
|
48217
|
-
const
|
|
48299
|
+
const missing5 = [
|
|
48218
48300
|
...rt.programs ? [] : ["this host cannot run local programs, so no video command works here"],
|
|
48219
48301
|
...rt.programs && version === null ? ['ffmpeg was not found: install it or set POPOST_FFMPEG (asked for "' + ffmpegPath(rt) + '")'] : [],
|
|
48220
48302
|
...browser === true ? [] : [browser]
|
|
@@ -48223,8 +48305,8 @@ var init_media = __esm({
|
|
|
48223
48305
|
const cpus = budget2 ? { budget: budget2.cpus, from: budget2.source } : null;
|
|
48224
48306
|
const reading = named.readText !== null || named.transcribe !== null;
|
|
48225
48307
|
const cache2 = await projectCache(rt);
|
|
48226
|
-
printJson(rt, { ok:
|
|
48227
|
-
return
|
|
48308
|
+
printJson(rt, { ok: missing5.length === 0, ffmpeg: version, browser: browser === true, cpus, tools: tools2, ...cache2 ? { cache: cache2 } : {}, ...offers, ...reading ? { note: FIRST_RUN } : {}, ...missing5.length ? { missing: missing5 } : {} });
|
|
48309
|
+
return missing5.length ? 2 : 0;
|
|
48228
48310
|
}
|
|
48229
48311
|
);
|
|
48230
48312
|
soundOnly = async (rt, file, e) => {
|
|
@@ -48573,8 +48655,8 @@ var init_music = __esm({
|
|
|
48573
48655
|
lengthLine = (made, file, of) => {
|
|
48574
48656
|
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";
|
|
48575
48657
|
if (!made.short) return void 0;
|
|
48576
|
-
const { seconds: seconds8, missing:
|
|
48577
|
-
return "The music is " + seconds8.toFixed(2) + " s long, " +
|
|
48658
|
+
const { seconds: seconds8, missing: missing5 } = made.short;
|
|
48659
|
+
return "The music is " + seconds8.toFixed(2) + " s long, " + missing5.toFixed(2) + " s shorter than the " + of.toFixed(2) + " s it is for: the last " + missing5.toFixed(2) + " s of the video would have no music. Order a longer track (this command with --seconds " + musicSeconds(of + missing5 + 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 " + missing5.toFixed(2) + " s).\n";
|
|
48578
48660
|
};
|
|
48579
48661
|
overLimit = (e, items, max) => {
|
|
48580
48662
|
if (!(e instanceof PopostApiError && e.code === "CREDIT_LIMIT_EXCEEDED")) throw e;
|
|
@@ -49527,8 +49609,8 @@ var init_project_windows = __esm({
|
|
|
49527
49609
|
return first.map((k) => {
|
|
49528
49610
|
if (k === void 0 || k === 0) return void 0;
|
|
49529
49611
|
const t = resolveTransition(project.segments[k]?.in, tl.starts[k], fps);
|
|
49530
|
-
const
|
|
49531
|
-
return t ? { from: t.a / fps, to: (t.a + t.frames) / fps, declared: { kind: t.kind, residual: 0, ...
|
|
49612
|
+
const spec10 = project.segments[k]?.in;
|
|
49613
|
+
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 };
|
|
49532
49614
|
});
|
|
49533
49615
|
};
|
|
49534
49616
|
}
|
|
@@ -49543,16 +49625,16 @@ var init_compare_scope = __esm({
|
|
|
49543
49625
|
init_fingerprint2();
|
|
49544
49626
|
comparisonScope = (reference2, facts) => {
|
|
49545
49627
|
const unchanged2 = { measure: reference2 };
|
|
49546
|
-
const
|
|
49547
|
-
if (!Array.isArray(
|
|
49628
|
+
const omitted2 = facts?.omittedShots;
|
|
49629
|
+
if (!Array.isArray(omitted2) || !omitted2.length || !facts?.template.fingerprint || referenceFingerprint(reference2) !== facts.template.fingerprint) return unchanged2;
|
|
49548
49630
|
const fps = reference2.source.fps;
|
|
49549
49631
|
let end = reference2.source.frames;
|
|
49550
|
-
for (const s of [...
|
|
49632
|
+
for (const s of [...omitted2].reverse()) {
|
|
49551
49633
|
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;
|
|
49552
49634
|
end = Math.round(s.seconds[0] * fps);
|
|
49553
49635
|
if (!reference2.shots.some((shot) => Math.abs(shot.start - end) <= 1)) return unchanged2;
|
|
49554
49636
|
}
|
|
49555
|
-
return end > 0 && end < reference2.source.frames ? { measure: endAt({ measure: reference2 }, end).measure, omitted } : unchanged2;
|
|
49637
|
+
return end > 0 && end < reference2.source.frames ? { measure: endAt({ measure: reference2 }, end).measure, omitted: omitted2 } : unchanged2;
|
|
49556
49638
|
};
|
|
49557
49639
|
}
|
|
49558
49640
|
});
|
|
@@ -50312,6 +50394,122 @@ var init_motion_bundle = __esm({
|
|
|
50312
50394
|
}
|
|
50313
50395
|
});
|
|
50314
50396
|
|
|
50397
|
+
// src/video/replication/review.ts
|
|
50398
|
+
var joinFrames, matchingReviewClock, timelineJoins, spreadFrames3, spanFrames2, same4, frameEvidence, short2, rebind, buildReview, withVerdicts;
|
|
50399
|
+
var init_review3 = __esm({
|
|
50400
|
+
"src/video/replication/review.ts"() {
|
|
50401
|
+
"use strict";
|
|
50402
|
+
init_revision();
|
|
50403
|
+
joinFrames = (segments2, fps) => {
|
|
50404
|
+
const offset = Math.max(1, Math.round(fps / 4));
|
|
50405
|
+
return segments2.slice(1).map((next, index) => {
|
|
50406
|
+
const before = segments2[index];
|
|
50407
|
+
const start = next.transition?.a ?? next.start;
|
|
50408
|
+
const end = start + (next.transition?.frames ?? 0);
|
|
50409
|
+
return {
|
|
50410
|
+
at: next.start,
|
|
50411
|
+
frames: [.../* @__PURE__ */ new Set([
|
|
50412
|
+
Math.max(before.start, start - offset),
|
|
50413
|
+
Math.max(before.start, start - 1),
|
|
50414
|
+
...end > start ? [Math.floor((start + end - 1) / 2)] : [],
|
|
50415
|
+
Math.min(next.end - 1, end),
|
|
50416
|
+
Math.min(next.end - 1, end + offset - 1)
|
|
50417
|
+
])].sort((a, b) => a - b)
|
|
50418
|
+
};
|
|
50419
|
+
});
|
|
50420
|
+
};
|
|
50421
|
+
matchingReviewClock = (clock4, video) => clock4.frames === video.frames && Math.abs(clock4.frames / clock4.fps - video.frames / video.fps) * clock4.fps < 0.25;
|
|
50422
|
+
timelineJoins = (r, extra2 = []) => {
|
|
50423
|
+
const joins = new Map(joinFrames(r.segments, r.canvas.fps).map((join3) => [join3.at, join3]));
|
|
50424
|
+
const boundaries = [...extra2, ...r.items.filter((item2) => item2.type === "image" || item2.type === "video").flatMap((item2) => [item2.start, item2.end])];
|
|
50425
|
+
const offset = Math.max(1, Math.round(r.canvas.fps / 4));
|
|
50426
|
+
for (const at7 of boundaries) {
|
|
50427
|
+
if (at7 <= 0 || at7 >= r.frames || joins.has(at7)) continue;
|
|
50428
|
+
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)])] });
|
|
50429
|
+
}
|
|
50430
|
+
return [...joins.values()].sort((a, b) => a.at - b.at);
|
|
50431
|
+
};
|
|
50432
|
+
spreadFrames3 = (total2, n) => [...new Set(Array.from({ length: Math.min(n, total2) }, (_, k) => Math.floor((2 * k + 1) * total2 / (2 * Math.min(n, total2)))))];
|
|
50433
|
+
spanFrames2 = (span2, total2) => {
|
|
50434
|
+
const last = Math.max(0, Math.min(span2[1], total2) - 1), first = Math.min(span2[0], last);
|
|
50435
|
+
const picked2 = [.../* @__PURE__ */ new Set([first, Math.floor((first + last) / 2), last])];
|
|
50436
|
+
if (picked2.length < 2 && total2 > 1) picked2.push(first > 0 ? first - 1 : first + 1);
|
|
50437
|
+
return picked2.sort((a, b) => a - b);
|
|
50438
|
+
};
|
|
50439
|
+
same4 = (a, b) => !!a && !!b && a.toLowerCase() === b.toLowerCase();
|
|
50440
|
+
frameEvidence = (v, frame2, what) => ({ kind: "observed", detail: "Frame " + frame2 + " of the final video: " + what, file: v.file, sha256: v.fingerprint, media: "video", frame: frame2 });
|
|
50441
|
+
short2 = (s) => s.length > 90 ? s.slice(0, 89) + "\u2026" : s;
|
|
50442
|
+
rebind = (old, bound, v, oldVideo, changed2) => {
|
|
50443
|
+
const ofVideo = (e) => same4(e.sha256, oldVideo) || same4(e.sha256, v.fingerprint) || e.file === v.file;
|
|
50444
|
+
const kept3 = (old?.evidence ?? []).filter((e) => !changed2 || !ofVideo(e));
|
|
50445
|
+
const key2 = (e) => [e.file, e.sha256, e.frame, JSON.stringify(e.at)].join("|");
|
|
50446
|
+
const seen = new Set(kept3.map(key2));
|
|
50447
|
+
return { status: changed2 ? "pending" : old?.status ?? "pending", evidence: [...kept3, ...bound.filter((e) => !seen.has(key2(e)))] };
|
|
50448
|
+
};
|
|
50449
|
+
buildReview = (o) => {
|
|
50450
|
+
const { contract: c, old, video: v } = o;
|
|
50451
|
+
const revision = sourceRevision(c);
|
|
50452
|
+
const changed2 = !!old && (!same4(old.artifactFingerprint, v.fingerprint) || !same4(old.sourceRevision, revision));
|
|
50453
|
+
const seconds8 = Math.round(v.frames / v.fps * 1e3) / 1e3;
|
|
50454
|
+
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);
|
|
50455
|
+
const visualFrames = o.visual.map((frame2) => frameEvidence(v, frame2, "its medium, finish and layout against the reference."));
|
|
50456
|
+
const continuity = (o.joins ?? []).flatMap((join3) => join3.frames.map((frame2) => frameEvidence(v, frame2, "the continuity of the cut or transition at frame " + join3.at + ".")));
|
|
50457
|
+
const visual = rebind(old?.visual, [...visualFrames, ...continuity], v, old?.artifactFingerprint, changed2);
|
|
50458
|
+
const joins = (o.joins ?? []).map((join3) => ({
|
|
50459
|
+
at: join3.at,
|
|
50460
|
+
...rebind(old?.joins?.find((item2) => item2.at === join3.at), [
|
|
50461
|
+
...join3.frames.map((frame2) => frameEvidence(v, frame2, "pose, action phase, framing, camera direction and product state across join " + join3.at + ".")),
|
|
50462
|
+
{
|
|
50463
|
+
kind: "observed",
|
|
50464
|
+
detail: "Watch and listen at normal speed across join " + join3.at + ": action, speech, speaker timbre and ambience.",
|
|
50465
|
+
file: v.file,
|
|
50466
|
+
sha256: v.fingerprint,
|
|
50467
|
+
media: "video",
|
|
50468
|
+
at: [Math.max(0, join3.at / v.fps - 1.25), Math.min(v.frames / v.fps, join3.at / v.fps + 1.25)]
|
|
50469
|
+
}
|
|
50470
|
+
], v, old?.artifactFingerprint, changed2)
|
|
50471
|
+
}));
|
|
50472
|
+
const missing5 = [];
|
|
50473
|
+
const events = c.events.map((e) => {
|
|
50474
|
+
const planned = o.plan?.events.find((p) => p.id === e.id);
|
|
50475
|
+
const frames = o.events[e.id] ?? (planned ? spanFrames2(planned.span, v.frames) : void 0);
|
|
50476
|
+
if (!frames) missing5.push(e.id);
|
|
50477
|
+
const names = ["lead-in", "middle", "resolved state"];
|
|
50478
|
+
const bound = (frames ?? []).map((f, k, all) => frameEvidence(v, f, (all.length === 3 ? names[k] : "a state") + ' of "' + short2(e.description) + '" (' + e.id + ")."));
|
|
50479
|
+
return { id: e.id, ...rebind(old?.events?.find((x2) => x2.id === e.id), bound, v, old?.artifactFingerprint, changed2), frames: frames ?? [] };
|
|
50480
|
+
});
|
|
50481
|
+
const review4 = {
|
|
50482
|
+
sourceFingerprint: c.source.fingerprint,
|
|
50483
|
+
sourceRevision: revision,
|
|
50484
|
+
production: "rendered",
|
|
50485
|
+
artifactFingerprint: v.fingerprint,
|
|
50486
|
+
target: { fps: v.fps, frames: v.frames },
|
|
50487
|
+
audio,
|
|
50488
|
+
visual,
|
|
50489
|
+
...o.joins !== void 0 ? { joins } : {},
|
|
50490
|
+
events: events.map(({ frames: _frames, ...finding }) => finding),
|
|
50491
|
+
...old?.audioUses ? { audioUses: old.audioUses } : o.audioUses ? { audioUses: o.audioUses } : {}
|
|
50492
|
+
};
|
|
50493
|
+
return { review: review4, changed: changed2, missing: missing5, 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 }))] };
|
|
50494
|
+
};
|
|
50495
|
+
withVerdicts = (r, passed, failed4) => {
|
|
50496
|
+
const names = /* @__PURE__ */ new Set(["audio", "visual", ...(r.events ?? []).map((e) => e.id), ...(r.joins ?? []).map((join3) => "join-" + join3.at)]);
|
|
50497
|
+
const unknown = [...passed, ...failed4].filter((n) => !names.has(n));
|
|
50498
|
+
const status2 = (name, s) => passed.includes(name) ? "passed" : failed4.includes(name) ? "failed" : s;
|
|
50499
|
+
return {
|
|
50500
|
+
unknown,
|
|
50501
|
+
review: {
|
|
50502
|
+
...r,
|
|
50503
|
+
...r.audio ? { audio: { ...r.audio, status: status2("audio", r.audio.status) } } : {},
|
|
50504
|
+
...r.visual ? { visual: { ...r.visual, status: status2("visual", r.visual.status) } } : {},
|
|
50505
|
+
...r.joins ? { joins: r.joins.map((join3) => ({ ...join3, status: status2("join-" + join3.at, join3.status) })) } : {},
|
|
50506
|
+
...r.events ? { events: r.events.map((e) => ({ ...e, status: status2(e.id, e.status) })) } : {}
|
|
50507
|
+
}
|
|
50508
|
+
};
|
|
50509
|
+
};
|
|
50510
|
+
}
|
|
50511
|
+
});
|
|
50512
|
+
|
|
50315
50513
|
// src/video/replication/source-clock.ts
|
|
50316
50514
|
var sourceClockOf, inspectSourceClock;
|
|
50317
50515
|
var init_source_clock = __esm({
|
|
@@ -50604,7 +50802,7 @@ var init_books = __esm({
|
|
|
50604
50802
|
...list7.filter((x2) => x2.file !== e.file || x2.sha256 === e.sha256 && (x2.frame !== e.frame || JSON.stringify(x2.at) !== JSON.stringify(e.at))),
|
|
50605
50803
|
e
|
|
50606
50804
|
];
|
|
50607
|
-
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)";
|
|
50805
|
+
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)";
|
|
50608
50806
|
object5 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
50609
50807
|
list6 = (v) => Array.isArray(v) ? v : [];
|
|
50610
50808
|
eventIn = (events, id2, file) => {
|
|
@@ -50615,6 +50813,12 @@ var init_books = __esm({
|
|
|
50615
50813
|
};
|
|
50616
50814
|
placeOf3 = (data, where3) => {
|
|
50617
50815
|
const [file, rest] = where3.startsWith("plan:") ? [PLAN_FILE2, where3.slice(5)] : where3.startsWith("review:") ? [REVIEW_FILE, where3.slice(7)] : [REPLICATION_FILE, where3];
|
|
50816
|
+
if (file === REVIEW_FILE && rest.startsWith("join-")) {
|
|
50817
|
+
const joins = Array.isArray(data.joins) ? data.joins.filter(object5) : [];
|
|
50818
|
+
const holder = joins.find((join3) => "join-" + join3.at === rest);
|
|
50819
|
+
if (!holder) throw new BooksError("This cut has no bound review. Run replication review and inspect its join preview first.");
|
|
50820
|
+
return { holder, key: "evidence" };
|
|
50821
|
+
}
|
|
50618
50822
|
if (rest.startsWith("event:")) {
|
|
50619
50823
|
if (file === REVIEW_FILE) {
|
|
50620
50824
|
const events = Array.isArray(data.events) ? data.events : data.events = [];
|
|
@@ -50705,75 +50909,6 @@ var init_books = __esm({
|
|
|
50705
50909
|
}
|
|
50706
50910
|
});
|
|
50707
50911
|
|
|
50708
|
-
// src/video/replication/review.ts
|
|
50709
|
-
var spreadFrames3, spanFrames2, same4, frameEvidence, short2, rebind, buildReview, withVerdicts;
|
|
50710
|
-
var init_review3 = __esm({
|
|
50711
|
-
"src/video/replication/review.ts"() {
|
|
50712
|
-
"use strict";
|
|
50713
|
-
init_revision();
|
|
50714
|
-
spreadFrames3 = (total2, n) => [...new Set(Array.from({ length: Math.min(n, total2) }, (_, k) => Math.floor((2 * k + 1) * total2 / (2 * Math.min(n, total2)))))];
|
|
50715
|
-
spanFrames2 = (span2, total2) => {
|
|
50716
|
-
const last = Math.max(0, Math.min(span2[1], total2) - 1), first = Math.min(span2[0], last);
|
|
50717
|
-
const picked2 = [.../* @__PURE__ */ new Set([first, Math.floor((first + last) / 2), last])];
|
|
50718
|
-
if (picked2.length < 2 && total2 > 1) picked2.push(first > 0 ? first - 1 : first + 1);
|
|
50719
|
-
return picked2.sort((a, b) => a - b);
|
|
50720
|
-
};
|
|
50721
|
-
same4 = (a, b) => !!a && !!b && a.toLowerCase() === b.toLowerCase();
|
|
50722
|
-
frameEvidence = (v, frame2, what) => ({ kind: "observed", detail: "Frame " + frame2 + " of the final video: " + what, file: v.file, sha256: v.fingerprint, media: "video", frame: frame2 });
|
|
50723
|
-
short2 = (s) => s.length > 90 ? s.slice(0, 89) + "\u2026" : s;
|
|
50724
|
-
rebind = (old, bound, v, oldVideo, changed2) => {
|
|
50725
|
-
const ofVideo = (e) => same4(e.sha256, oldVideo) || same4(e.sha256, v.fingerprint) || e.file === v.file;
|
|
50726
|
-
const kept3 = (old?.evidence ?? []).filter((e) => !changed2 || !ofVideo(e));
|
|
50727
|
-
const key2 = (e) => [e.file, e.sha256, e.frame, JSON.stringify(e.at)].join("|");
|
|
50728
|
-
const seen = new Set(kept3.map(key2));
|
|
50729
|
-
return { status: changed2 ? "pending" : old?.status ?? "pending", evidence: [...kept3, ...bound.filter((e) => !seen.has(key2(e)))] };
|
|
50730
|
-
};
|
|
50731
|
-
buildReview = (o) => {
|
|
50732
|
-
const { contract: c, old, video: v } = o;
|
|
50733
|
-
const revision = sourceRevision(c);
|
|
50734
|
-
const changed2 = !!old && (!same4(old.artifactFingerprint, v.fingerprint) || !same4(old.sourceRevision, revision));
|
|
50735
|
-
const seconds8 = Math.round(v.frames / v.fps * 1e3) / 1e3;
|
|
50736
|
-
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);
|
|
50737
|
-
const visual = rebind(old?.visual, o.visual.map((f) => frameEvidence(v, f, "its medium, finish and layout against the reference.")), v, old?.artifactFingerprint, changed2);
|
|
50738
|
-
const missing4 = [];
|
|
50739
|
-
const events = c.events.map((e) => {
|
|
50740
|
-
const planned = o.plan?.events.find((p) => p.id === e.id);
|
|
50741
|
-
const frames = o.events[e.id] ?? (planned ? spanFrames2(planned.span, v.frames) : void 0);
|
|
50742
|
-
if (!frames) missing4.push(e.id);
|
|
50743
|
-
const names = ["lead-in", "middle", "resolved state"];
|
|
50744
|
-
const bound = (frames ?? []).map((f, k, all) => frameEvidence(v, f, (all.length === 3 ? names[k] : "a state") + ' of "' + short2(e.description) + '" (' + e.id + ")."));
|
|
50745
|
-
return { id: e.id, ...rebind(old?.events?.find((x2) => x2.id === e.id), bound, v, old?.artifactFingerprint, changed2), frames: frames ?? [] };
|
|
50746
|
-
});
|
|
50747
|
-
const review4 = {
|
|
50748
|
-
sourceFingerprint: c.source.fingerprint,
|
|
50749
|
-
sourceRevision: revision,
|
|
50750
|
-
production: "rendered",
|
|
50751
|
-
artifactFingerprint: v.fingerprint,
|
|
50752
|
-
target: { fps: v.fps, frames: v.frames },
|
|
50753
|
-
audio,
|
|
50754
|
-
visual,
|
|
50755
|
-
events: events.map(({ frames: _frames, ...finding }) => finding),
|
|
50756
|
-
...old?.audioUses ? { audioUses: old.audioUses } : o.audioUses ? { audioUses: o.audioUses } : {}
|
|
50757
|
-
};
|
|
50758
|
-
return { review: review4, changed: changed2, missing: missing4, frames: [{ name: "audio", frames: [] }, { name: "visual", frames: o.visual }, ...events.map((e) => ({ name: e.id, frames: e.frames }))] };
|
|
50759
|
-
};
|
|
50760
|
-
withVerdicts = (r, passed, failed4) => {
|
|
50761
|
-
const names = /* @__PURE__ */ new Set(["audio", "visual", ...(r.events ?? []).map((e) => e.id)]);
|
|
50762
|
-
const unknown = [...passed, ...failed4].filter((n) => !names.has(n));
|
|
50763
|
-
const status2 = (name, s) => passed.includes(name) ? "passed" : failed4.includes(name) ? "failed" : s;
|
|
50764
|
-
return {
|
|
50765
|
-
unknown,
|
|
50766
|
-
review: {
|
|
50767
|
-
...r,
|
|
50768
|
-
...r.audio ? { audio: { ...r.audio, status: status2("audio", r.audio.status) } } : {},
|
|
50769
|
-
...r.visual ? { visual: { ...r.visual, status: status2("visual", r.visual.status) } } : {},
|
|
50770
|
-
...r.events ? { events: r.events.map((e) => ({ ...e, status: status2(e.id, e.status) })) } : {}
|
|
50771
|
-
}
|
|
50772
|
-
};
|
|
50773
|
-
};
|
|
50774
|
-
}
|
|
50775
|
-
});
|
|
50776
|
-
|
|
50777
50912
|
// src/video/commands/replication-books.ts
|
|
50778
50913
|
var DIR7, secondsOf3, books, leftIn, bindEvents, evidence2, framesOf3, eventFrames, readJson7, oldReview, lookFrames, planOf3, audioUsesOf, namesOf2, review3, bookCommands;
|
|
50779
50914
|
var init_replication_books = __esm({
|
|
@@ -50869,12 +51004,16 @@ var init_replication_books = __esm({
|
|
|
50869
51004
|
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.");
|
|
50870
51005
|
return parsed.review;
|
|
50871
51006
|
};
|
|
50872
|
-
lookFrames = async (rt, dir, video) => {
|
|
50873
|
-
|
|
50874
|
-
const
|
|
50875
|
-
|
|
50876
|
-
|
|
50877
|
-
|
|
51007
|
+
lookFrames = async (rt, dir, video, extra2) => {
|
|
51008
|
+
if (!await rt.fs.stat(rt.path.join(dir, "video.json"))) return { overview: spreadFrames3(video.frames, 6), joins: void 0 };
|
|
51009
|
+
const built = await buildPage(rt, dir);
|
|
51010
|
+
const clock4 = built.resolved;
|
|
51011
|
+
if (!clock4 || !matchingReviewClock({ frames: clock4.frames, fps: clock4.canvas.fps }, video))
|
|
51012
|
+
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.");
|
|
51013
|
+
if (extra2.some((frame2) => frame2 <= 0 || frame2 >= video.frames)) throw new VideoCommandError("--join must lie strictly inside the final artifact.");
|
|
51014
|
+
const mids = clock4.segments.map((s) => Math.floor((s.start + s.end - 1) / 2));
|
|
51015
|
+
const overview = mids.length <= 8 ? mids : spreadFrames3(mids.length, 8).map((k) => mids[k]);
|
|
51016
|
+
return { overview, joins: timelineJoins(clock4, extra2) };
|
|
50878
51017
|
};
|
|
50879
51018
|
planOf3 = async (rt, dir) => {
|
|
50880
51019
|
const parsed = planSchema.safeParse(await readJson7(rt, rt.path.join(dir, PLAN_FILE2)));
|
|
@@ -50888,6 +51027,7 @@ var init_replication_books = __esm({
|
|
|
50888
51027
|
{ flag: "--artifact", required: true, help: "the final rendered MP4" },
|
|
50889
51028
|
{ flag: "--frames", help: "frames of the video for the look (default: the middle of each shot, at most 8)" },
|
|
50890
51029
|
{ 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" },
|
|
51030
|
+
{ flag: "--join", kind: "append", help: "an internal generated-shot cut at an output frame; joins and visual-layer boundaries are included automatically" },
|
|
50891
51031
|
{ flag: "--passed", help: "the findings you looked at (listened to) that hold: audio, visual and event ids, separated by commas" },
|
|
50892
51032
|
{ flag: "--failed", help: "the findings that do not hold, the same way" },
|
|
50893
51033
|
{ flag: "--sheets", help: "where the sheets of the frames go (default <dir>/review/replication)" }
|
|
@@ -50902,34 +51042,76 @@ var init_replication_books = __esm({
|
|
|
50902
51042
|
const video = { file: bound.evidence.file ?? "", fingerprint: bound.evidence.sha256 ?? "", fps: p.fps, frames: p.frames };
|
|
50903
51043
|
const old = await oldReview(rt, dir);
|
|
50904
51044
|
const typed = args2.string("frames");
|
|
51045
|
+
const { overview, joins } = await lookFrames(rt, dir, video, [...(old?.artifactFingerprint === video.fingerprint ? old.joins ?? [] : []).map((join3) => join3.at), ...args2.list("join").flatMap((value) => framesOf3(value, "--join"))]);
|
|
50905
51046
|
const built = buildReview({
|
|
50906
51047
|
contract: read2.contract,
|
|
50907
51048
|
...old ? { old } : {},
|
|
50908
51049
|
...await planOf3(rt, dir).then((plan4) => plan4 ? { plan: plan4 } : {}),
|
|
50909
51050
|
video,
|
|
50910
|
-
visual: typed ? framesOf3(typed, "--frames") :
|
|
51051
|
+
visual: typed ? framesOf3(typed, "--frames") : overview,
|
|
51052
|
+
...joins ? { joins } : {},
|
|
50911
51053
|
events: eventFrames(args2.list("event")),
|
|
50912
51054
|
...await audioUsesOf(rt, dir).then((u) => u ? { audioUses: u } : {})
|
|
50913
51055
|
});
|
|
50914
51056
|
const passed = namesOf2(args2.string("passed")), failed4 = namesOf2(args2.string("failed"));
|
|
50915
51057
|
const judged = passed.length + failed4.length > 0;
|
|
50916
|
-
if (judged && (typed || args2.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.");
|
|
51058
|
+
if (judged && (typed || args2.list("event").length || args2.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.");
|
|
50917
51059
|
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.");
|
|
51060
|
+
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)))) {
|
|
51061
|
+
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.");
|
|
51062
|
+
}
|
|
51063
|
+
for (const name of [...passed, ...failed4].filter((name2) => name2.startsWith("join-"))) {
|
|
51064
|
+
if (!old?.joins?.some((join3) => "join-" + join3.at === name))
|
|
51065
|
+
throw new VideoCommandError("This cut is new to the review. Generate and watch its join preview before recording a verdict.");
|
|
51066
|
+
}
|
|
50918
51067
|
const verdicts = withVerdicts(built.review, passed, failed4);
|
|
50919
51068
|
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.");
|
|
50920
|
-
await rt.fs.writeFile(rt.path.join(dir, REVIEW_FILE), JSON.stringify(verdicts.review, null, 2) + "\n");
|
|
50921
51069
|
const sheetsDir = userPath(rt, args2.string("sheets") ?? rt.path.join(dir, "review", "replication"));
|
|
50922
51070
|
const sheetOf = (name) => (name === "visual" ? "visual" : "event-" + name.replace(/[^a-z0-9_-]/gi, "_")) + ".jpg";
|
|
50923
|
-
|
|
50924
|
-
|
|
51071
|
+
const joinSheets = (joins ?? []).map(({ at: at7, frames }) => ({ at: at7, frames, file: "join-" + at7 + ".jpg" }));
|
|
51072
|
+
if (!judged) {
|
|
51073
|
+
const sheets = built.frames.filter((f) => f.frames.length).map(({ name, frames }) => ({ file: sheetOf(name), frames }));
|
|
51074
|
+
await writeSheets2(rt, file, [...sheets, ...joinSheets], { width: 320, outDir: sheetsDir, probe: p });
|
|
51075
|
+
for (const join3 of joinSheets) {
|
|
51076
|
+
const start = Math.max(0, join3.at / video.fps - 1.25);
|
|
51077
|
+
const end = Math.min(video.frames / video.fps, join3.at / video.fps + 1.25);
|
|
51078
|
+
await runFfmpegOk(rt, [
|
|
51079
|
+
"-y",
|
|
51080
|
+
"-ss",
|
|
51081
|
+
String(start),
|
|
51082
|
+
"-i",
|
|
51083
|
+
file,
|
|
51084
|
+
"-t",
|
|
51085
|
+
String(end - start),
|
|
51086
|
+
"-map",
|
|
51087
|
+
"0:v:0",
|
|
51088
|
+
"-map",
|
|
51089
|
+
"0:a?",
|
|
51090
|
+
"-c:v",
|
|
51091
|
+
"libx264",
|
|
51092
|
+
"-preset",
|
|
51093
|
+
"veryfast",
|
|
51094
|
+
"-crf",
|
|
51095
|
+
"20",
|
|
51096
|
+
"-c:a",
|
|
51097
|
+
"aac",
|
|
51098
|
+
"-movflags",
|
|
51099
|
+
"+faststart",
|
|
51100
|
+
rt.path.join(sheetsDir, "join-" + join3.at + ".mp4")
|
|
51101
|
+
]);
|
|
51102
|
+
}
|
|
51103
|
+
}
|
|
51104
|
+
await rt.fs.writeFile(rt.path.join(dir, REVIEW_FILE), JSON.stringify(verdicts.review, null, 2) + "\n");
|
|
51105
|
+
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";
|
|
50925
51106
|
printJson(rt, {
|
|
50926
51107
|
ok: built.missing.length === 0,
|
|
50927
51108
|
review: rt.path.join(dir, REVIEW_FILE),
|
|
50928
51109
|
artifact: video,
|
|
50929
51110
|
changed: built.changed,
|
|
51111
|
+
...!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") })) } : {},
|
|
50930
51112
|
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)) } : {} })),
|
|
50931
51113
|
...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." } : {},
|
|
50932
|
-
next: judged ? "popost video replication check " + dir + " --reference <the reference> --artifact " + args2.req("artifact") : "Open each sheet and listen
|
|
51114
|
+
next: judged ? "popost video replication check " + dir + " --reference <the reference> --artifact " + args2.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>."
|
|
50933
51115
|
});
|
|
50934
51116
|
return built.missing.length ? 2 : 0;
|
|
50935
51117
|
});
|
|
@@ -50945,6 +51127,7 @@ var init_replication = __esm({
|
|
|
50945
51127
|
init_util();
|
|
50946
51128
|
init_ffmpeg();
|
|
50947
51129
|
init_compile();
|
|
51130
|
+
init_provenance();
|
|
50948
51131
|
init_contract();
|
|
50949
51132
|
init_check4();
|
|
50950
51133
|
init_io2();
|
|
@@ -50952,6 +51135,7 @@ var init_replication = __esm({
|
|
|
50952
51135
|
init_pairs();
|
|
50953
51136
|
init_motion_bundle();
|
|
50954
51137
|
init_audio_provenance();
|
|
51138
|
+
init_review3();
|
|
50955
51139
|
init_revision();
|
|
50956
51140
|
init_retiming();
|
|
50957
51141
|
init_speech_observed();
|
|
@@ -51064,7 +51248,15 @@ var init_replication = __esm({
|
|
|
51064
51248
|
source: event2.span,
|
|
51065
51249
|
target: event2.span.map((frame2) => clock4.map ? clock4.map(frame2) : Math.round((frame2 - (c.scope?.span[0] ?? 0)) / c.source.fps * r.canvas.fps))
|
|
51066
51250
|
})) : void 0;
|
|
51067
|
-
const
|
|
51251
|
+
const footageUsed = /* @__PURE__ */ new Set([
|
|
51252
|
+
...r.segments.flatMap((s) => s.base.kind === "video" ? [s.base.play.material] : []),
|
|
51253
|
+
...r.items.flatMap((i) => i.play ? [i.play.material] : [])
|
|
51254
|
+
]);
|
|
51255
|
+
const materialSources = await Promise.all([...footageUsed].flatMap((material3) => {
|
|
51256
|
+
const file = r.footage?.[material3]?.src;
|
|
51257
|
+
return file ? [readMaterialReceipt(rt, rt.path.resolve(dir, file)).then((receipt) => receipt ? { material: material3, file, receipt: materialReceiptFile(file), ...receipt } : { material: material3, file, provider: "unknown" })] : [];
|
|
51258
|
+
}));
|
|
51259
|
+
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 ?? [] };
|
|
51068
51260
|
if (args2.string("out")) await writeJson2(rt, userPath(rt, args2.req("out")), data);
|
|
51069
51261
|
return report2(rt, [...built.problems, ...source2.problems, ...clock4.problems], { timeline: data });
|
|
51070
51262
|
});
|
|
@@ -51103,7 +51295,7 @@ var init_replication = __esm({
|
|
|
51103
51295
|
boundFindings = (c, review4, actual) => {
|
|
51104
51296
|
const fingerprint = actual.fingerprint;
|
|
51105
51297
|
const problems2 = [];
|
|
51106
|
-
for (const [name, finding] of [["audio", review4.audio], ["visual", review4.visual], ...(review4.events ?? []).map((e) => [e.id, e])]) {
|
|
51298
|
+
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])]) {
|
|
51107
51299
|
if (finding?.status !== "passed") continue;
|
|
51108
51300
|
for (const e of finding.evidence.filter((e2) => e2.sha256 === fingerprint)) {
|
|
51109
51301
|
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))
|
|
@@ -51165,6 +51357,15 @@ var init_replication = __esm({
|
|
|
51165
51357
|
const parsed = parseReplicationReview(input);
|
|
51166
51358
|
problems2.push(...parsed.problems, ...await evidenceProblems(rt, dir, parsed.review));
|
|
51167
51359
|
if (parsed.review) problems2.push(...boundFindings(c, parsed.review, actual));
|
|
51360
|
+
if (built.resolved) {
|
|
51361
|
+
const clock4 = built.resolved;
|
|
51362
|
+
if (!matchingReviewClock({ frames: clock4.frames, fps: clock4.canvas.fps }, actual))
|
|
51363
|
+
problems2.push(error("replication.review.joins", "The project and final artifact clocks cannot be mapped safely.", "Render and review the current project."));
|
|
51364
|
+
for (const join3 of timelineJoins(clock4)) {
|
|
51365
|
+
if (!parsed.review?.joins?.some((item2) => item2.at === join3.at))
|
|
51366
|
+
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 + "."));
|
|
51367
|
+
}
|
|
51368
|
+
}
|
|
51168
51369
|
const assessment = assessReplication(c, input, actual);
|
|
51169
51370
|
problems2.push(...assessment.problems);
|
|
51170
51371
|
const failed4 = problems2.some((p) => p.level === "error"), accepted = !failed4 && assessment.requirementsMet === true;
|
|
@@ -51307,12 +51508,592 @@ var init_video = __esm({
|
|
|
51307
51508
|
}
|
|
51308
51509
|
});
|
|
51309
51510
|
|
|
51511
|
+
// src/feedback/clean.ts
|
|
51512
|
+
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;
|
|
51513
|
+
var init_clean2 = __esm({
|
|
51514
|
+
"src/feedback/clean.ts"() {
|
|
51515
|
+
"use strict";
|
|
51516
|
+
REDACTED = "[redacted]";
|
|
51517
|
+
BINARY_MIN_CHARS = 1024;
|
|
51518
|
+
SECRET_WORDS = /* @__PURE__ */ new Set(["apikey", "secret", "secrets", "token", "password", "passwd", "pwd", "credential", "credentials"]);
|
|
51519
|
+
KEY_QUALIFIERS = /* @__PURE__ */ new Set(["api", "access", "secret", "private", "client", "auth", "signing", "encryption", "master", "service", "account"]);
|
|
51520
|
+
VARIABLE4 = /^[A-Z][A-Z0-9_]*$/;
|
|
51521
|
+
UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
51522
|
+
wordsOf = (name) => name.replace(/([a-z0-9])([A-Z])/g, "$1 $2").split(/[^A-Za-z0-9]+/).filter(Boolean).map((word2) => word2.toLowerCase());
|
|
51523
|
+
isSecretName = (name) => wordsOf(name).some((word2, i, words) => SECRET_WORDS.has(word2) || (word2 === "key" || word2 === "keys") && i > 0 && KEY_QUALIFIERS.has(words[i - 1]));
|
|
51524
|
+
isSecretValue = (value) => value.length >= 8 && !/\s/.test(value) && !UUID.test(value) && value !== REDACTED && !value.startsWith("$") && !value.includes("process.env") && !value.startsWith("[omitted");
|
|
51525
|
+
TOKEN_PATTERNS = [
|
|
51526
|
+
/-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z0-9 ]*PRIVATE KEY-----/g,
|
|
51527
|
+
/\bpopost_[A-Za-z0-9_-]{43}(?![A-Za-z0-9_-])/g,
|
|
51528
|
+
/\bpat_device_[A-Za-z0-9_-]{43}(?![A-Za-z0-9_-])/g,
|
|
51529
|
+
/\bsk-[A-Za-z0-9_-]{20,}/g,
|
|
51530
|
+
/\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g,
|
|
51531
|
+
/\bgh[pousr]_[A-Za-z0-9]{30,}\b/g,
|
|
51532
|
+
/\bgithub_pat_[A-Za-z0-9_]{40,}\b/g,
|
|
51533
|
+
/\bxox[abposr]-[A-Za-z0-9-]{10,}/g,
|
|
51534
|
+
/\beyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g
|
|
51535
|
+
];
|
|
51536
|
+
BEARER = /\b(Bearer)\s+[A-Za-z0-9._~+/=-]{12,}/gi;
|
|
51537
|
+
URL_PARAM = /([?&](?:X-Amz-Signature|X-Amz-Credential|X-Amz-Security-Token|Signature|sig|token|access_token|api_key|apikey|key)=)[^&\s"'<>#]+/gi;
|
|
51538
|
+
ASSIGNMENT = /(["']?)\b([A-Za-z_][A-Za-z0-9_.-]*)\1(\s*[:=]\s*)(["']?)([^\s"'`,;&<>]+)\4/g;
|
|
51539
|
+
INLINE_DATA_URL = /data:([\w.+/-]+)?(?:;[\w=.+-]+)*;base64,[A-Za-z0-9+/=]{1024,}/g;
|
|
51540
|
+
DATA_URL = /^data:([\w.+/-]+)?[;,]/;
|
|
51541
|
+
BASE64_ONLY = /^[A-Za-z0-9+/=_\-\r\n]+$/;
|
|
51542
|
+
kb = (chars) => Math.max(1, Math.round(chars * 3 / 4 / 1024));
|
|
51543
|
+
omitted = (mime, chars) => `[omitted: ${mime || "binary"} ${kb(chars)} KB]`;
|
|
51544
|
+
sniffBase64 = (data) => {
|
|
51545
|
+
if (data.startsWith("iVBOR")) return "image/png";
|
|
51546
|
+
if (data.startsWith("/9j/")) return "image/jpeg";
|
|
51547
|
+
if (data.startsWith("R0lGOD")) return "image/gif";
|
|
51548
|
+
if (data.startsWith("UklGR")) return "image/webp";
|
|
51549
|
+
return void 0;
|
|
51550
|
+
};
|
|
51551
|
+
escapeRegExp3 = (text13) => text13.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
51552
|
+
environmentSecrets = (env2) => [...new Set(Object.entries(env2).filter(([name, value]) => isSecretName(name) && typeof value === "string" && isSecretValue(value)).map(([, value]) => value))].sort(
|
|
51553
|
+
(a, b) => b.length - a.length
|
|
51554
|
+
);
|
|
51555
|
+
createCleaner = (options = {}) => {
|
|
51556
|
+
const stats = { redactions: 0, omittedImages: 0 };
|
|
51557
|
+
const home = options.homeDir && options.homeDir.length > 1 ? new RegExp(`${escapeRegExp3(options.homeDir.replace(/[\\/]+$/, ""))}(?=[\\\\/"'\\s]|$)`, "g") : null;
|
|
51558
|
+
const secrets = (options.secrets ?? []).filter((value) => value.length >= 8);
|
|
51559
|
+
const redact = (value) => {
|
|
51560
|
+
let out2 = value;
|
|
51561
|
+
for (const secret of secrets)
|
|
51562
|
+
if (out2.includes(secret)) {
|
|
51563
|
+
stats.redactions += out2.split(secret).length - 1;
|
|
51564
|
+
out2 = out2.split(secret).join(REDACTED);
|
|
51565
|
+
}
|
|
51566
|
+
for (const pattern of TOKEN_PATTERNS)
|
|
51567
|
+
out2 = out2.replace(pattern, () => {
|
|
51568
|
+
stats.redactions += 1;
|
|
51569
|
+
return REDACTED;
|
|
51570
|
+
});
|
|
51571
|
+
out2 = out2.replace(BEARER, (_all, word2) => {
|
|
51572
|
+
stats.redactions += 1;
|
|
51573
|
+
return `${word2} ${REDACTED}`;
|
|
51574
|
+
});
|
|
51575
|
+
out2 = out2.replace(URL_PARAM, (_all, name) => {
|
|
51576
|
+
stats.redactions += 1;
|
|
51577
|
+
return name + REDACTED;
|
|
51578
|
+
});
|
|
51579
|
+
return out2.replace(ASSIGNMENT, (all, quote16, name, sep, valueQuote, secret, at7, whole2) => {
|
|
51580
|
+
const call2 = !valueQuote && (/[(){}]/.test(secret) || whole2[at7 + all.length] === "(");
|
|
51581
|
+
if (call2 || !isSecretName(name) || !isSecretValue(secret) || !valueQuote && !VARIABLE4.test(name)) return all;
|
|
51582
|
+
stats.redactions += 1;
|
|
51583
|
+
return `${quote16}${name}${quote16}${sep}${valueQuote}${REDACTED}${valueQuote}`;
|
|
51584
|
+
});
|
|
51585
|
+
};
|
|
51586
|
+
const binary = (value, mime) => {
|
|
51587
|
+
if (value.length <= BINARY_MIN_CHARS) return void 0;
|
|
51588
|
+
const url = DATA_URL.exec(value);
|
|
51589
|
+
if (url) return omitted(url[1], value.length - value.indexOf(",") - 1);
|
|
51590
|
+
if (!BASE64_ONLY.test(value)) return void 0;
|
|
51591
|
+
return omitted(mime ?? sniffBase64(value), value.length);
|
|
51592
|
+
};
|
|
51593
|
+
const text13 = (value, mime) => {
|
|
51594
|
+
const whole2 = binary(value, mime);
|
|
51595
|
+
if (whole2 !== void 0) {
|
|
51596
|
+
stats.omittedImages += 1;
|
|
51597
|
+
return whole2;
|
|
51598
|
+
}
|
|
51599
|
+
const inline = value.replace(INLINE_DATA_URL, (all, type) => {
|
|
51600
|
+
stats.omittedImages += 1;
|
|
51601
|
+
return omitted(type, all.length - all.indexOf(",") - 1);
|
|
51602
|
+
});
|
|
51603
|
+
const clean2 = redact(inline);
|
|
51604
|
+
return home ? clean2.replace(home, "~") : clean2;
|
|
51605
|
+
};
|
|
51606
|
+
const json4 = (value) => {
|
|
51607
|
+
if (typeof value === "string") return text13(value);
|
|
51608
|
+
if (Array.isArray(value)) return value.map(json4);
|
|
51609
|
+
if (value === null || typeof value !== "object") return value;
|
|
51610
|
+
const record2 = value;
|
|
51611
|
+
const mime = [record2.media_type, record2.mediaType, record2.mime_type, record2.mimeType].find((m) => typeof m === "string");
|
|
51612
|
+
return Object.fromEntries(
|
|
51613
|
+
Object.entries(record2).map(([key2, item2]) => {
|
|
51614
|
+
if (typeof item2 === "string" && isSecretName(key2) && isSecretValue(item2)) {
|
|
51615
|
+
stats.redactions += 1;
|
|
51616
|
+
return [key2, REDACTED];
|
|
51617
|
+
}
|
|
51618
|
+
return [key2, typeof item2 === "string" ? text13(item2, mime) : json4(item2)];
|
|
51619
|
+
})
|
|
51620
|
+
);
|
|
51621
|
+
};
|
|
51622
|
+
return { stats, text: (value) => text13(value), json: json4 };
|
|
51623
|
+
};
|
|
51624
|
+
cleanJsonl = (cleaner, raw) => {
|
|
51625
|
+
const out2 = [];
|
|
51626
|
+
let lines2 = 0;
|
|
51627
|
+
for (const line of raw.split("\n")) {
|
|
51628
|
+
if (line.trim() === "") {
|
|
51629
|
+
out2.push(line);
|
|
51630
|
+
continue;
|
|
51631
|
+
}
|
|
51632
|
+
lines2 += 1;
|
|
51633
|
+
let parsed;
|
|
51634
|
+
try {
|
|
51635
|
+
parsed = JSON.parse(line);
|
|
51636
|
+
} catch {
|
|
51637
|
+
out2.push(cleaner.text(line));
|
|
51638
|
+
continue;
|
|
51639
|
+
}
|
|
51640
|
+
out2.push(JSON.stringify(cleaner.json(parsed)));
|
|
51641
|
+
}
|
|
51642
|
+
return { text: out2.join("\n"), lines: lines2 };
|
|
51643
|
+
};
|
|
51644
|
+
}
|
|
51645
|
+
});
|
|
51646
|
+
|
|
51647
|
+
// src/feedback/project-files.ts
|
|
51648
|
+
var MAX_DEPTH2, MAX_LISTED, DOCUMENT_MAX_BYTES, DOCUMENTS_MAX_BYTES, TEXT_EXTENSIONS, SKIPPED_DIRS, PRIVATE_NAME, extensionOf2, listFiles, isDocument, collectProjectFiles;
|
|
51649
|
+
var init_project_files = __esm({
|
|
51650
|
+
"src/feedback/project-files.ts"() {
|
|
51651
|
+
"use strict";
|
|
51652
|
+
init_pyjson();
|
|
51653
|
+
MAX_DEPTH2 = 6;
|
|
51654
|
+
MAX_LISTED = 2e3;
|
|
51655
|
+
DOCUMENT_MAX_BYTES = 512 * 1024;
|
|
51656
|
+
DOCUMENTS_MAX_BYTES = 5 * 1024 * 1024;
|
|
51657
|
+
TEXT_EXTENSIONS = /* @__PURE__ */ new Set([".json", ".md", ".txt", ".html", ".css", ".log", ".yaml", ".yml"]);
|
|
51658
|
+
SKIPPED_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git", ".hg", ".svn", "dist", ".cache", "cache", ".next", ".turbo", "__pycache__", ".venv", "venv", "secrets", ".secrets"]);
|
|
51659
|
+
PRIVATE_NAME = /^\.env|^\.npmrc$|^\.netrc$|(^|[._-])(credentials?|secrets?)([._-]|$)/i;
|
|
51660
|
+
extensionOf2 = (name) => {
|
|
51661
|
+
const dot3 = name.lastIndexOf(".");
|
|
51662
|
+
return dot3 > 0 ? name.slice(dot3).toLowerCase() : "";
|
|
51663
|
+
};
|
|
51664
|
+
listFiles = async (rt, root) => {
|
|
51665
|
+
const found = [];
|
|
51666
|
+
let level = [""];
|
|
51667
|
+
for (let depth = 0; depth <= MAX_DEPTH2 && level.length && found.length <= MAX_LISTED; depth++) {
|
|
51668
|
+
const next = [];
|
|
51669
|
+
for (const rel2 of level) {
|
|
51670
|
+
const names = await rt.fs.readdir(rel2 ? rt.path.join(root, ...rel2.split("/")) : root).catch(() => []);
|
|
51671
|
+
for (const name of [...names].sort(compareCodePoints)) {
|
|
51672
|
+
const path4 = rel2 ? `${rel2}/${name}` : name;
|
|
51673
|
+
const stat2 = await rt.fs.stat(rt.path.join(root, ...path4.split("/")));
|
|
51674
|
+
if (stat2?.isDirectory && !SKIPPED_DIRS.has(name.toLowerCase())) next.push(path4);
|
|
51675
|
+
else if (stat2?.isFile) found.push({ path: path4, bytes: stat2.size });
|
|
51676
|
+
if (found.length > MAX_LISTED) return found;
|
|
51677
|
+
}
|
|
51678
|
+
}
|
|
51679
|
+
level = next;
|
|
51680
|
+
}
|
|
51681
|
+
return found;
|
|
51682
|
+
};
|
|
51683
|
+
isDocument = (file) => {
|
|
51684
|
+
const name = file.path.split("/").pop() ?? "";
|
|
51685
|
+
return TEXT_EXTENSIONS.has(extensionOf2(name)) && file.bytes <= DOCUMENT_MAX_BYTES && !PRIVATE_NAME.test(name);
|
|
51686
|
+
};
|
|
51687
|
+
collectProjectFiles = async (rt, root, cleaner) => {
|
|
51688
|
+
const listed3 = await listFiles(rt, root);
|
|
51689
|
+
const files = listed3.slice(0, MAX_LISTED);
|
|
51690
|
+
const documents = {};
|
|
51691
|
+
let total2 = 0;
|
|
51692
|
+
for (const file of files.filter(isDocument)) {
|
|
51693
|
+
if (total2 + file.bytes > DOCUMENTS_MAX_BYTES) continue;
|
|
51694
|
+
const text13 = await rt.fs.readText(rt.path.join(root, ...file.path.split("/"))).catch(() => void 0);
|
|
51695
|
+
if (text13 === void 0) continue;
|
|
51696
|
+
documents[file.path] = cleaner.text(text13);
|
|
51697
|
+
total2 += file.bytes;
|
|
51698
|
+
}
|
|
51699
|
+
return { files, documents, listTruncated: listed3.length > MAX_LISTED };
|
|
51700
|
+
};
|
|
51701
|
+
}
|
|
51702
|
+
});
|
|
51703
|
+
|
|
51704
|
+
// src/feedback/transcript.ts
|
|
51705
|
+
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;
|
|
51706
|
+
var init_transcript = __esm({
|
|
51707
|
+
"src/feedback/transcript.ts"() {
|
|
51708
|
+
"use strict";
|
|
51709
|
+
init_agents();
|
|
51710
|
+
init_i18n();
|
|
51711
|
+
init_clean2();
|
|
51712
|
+
TRANSCRIPT_MAX_BYTES = 40 * 1024 * 1024;
|
|
51713
|
+
TRANSCRIPT_READ_MAX_BYTES = 256 * 1024 * 1024;
|
|
51714
|
+
SESSION_ID = /^[A-Za-z0-9_-]{1,200}$/;
|
|
51715
|
+
CODEX_DAYS_SEARCHED = 400;
|
|
51716
|
+
FeedbackError = class extends Error {
|
|
51717
|
+
constructor(code, message2) {
|
|
51718
|
+
super(message2);
|
|
51719
|
+
this.code = code;
|
|
51720
|
+
}
|
|
51721
|
+
code;
|
|
51722
|
+
name = "FeedbackError";
|
|
51723
|
+
};
|
|
51724
|
+
envValue2 = (rt, name) => {
|
|
51725
|
+
const value = rt.env[name]?.trim();
|
|
51726
|
+
return value ? value : void 0;
|
|
51727
|
+
};
|
|
51728
|
+
detectAgent = (rt, session) => {
|
|
51729
|
+
const given2 = session?.trim();
|
|
51730
|
+
if (given2 !== void 0 && !SESSION_ID.test(given2))
|
|
51731
|
+
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"));
|
|
51732
|
+
const claude = envValue2(rt, "CLAUDE_CODE_SESSION_ID");
|
|
51733
|
+
const codex = envValue2(rt, "CODEX_THREAD_ID");
|
|
51734
|
+
const known2 = (id2, sid) => ({ id: id2, label: agentLabel(id2), ...given2 ?? sid ? { sessionId: given2 ?? sid } : {} });
|
|
51735
|
+
if (claude || envValue2(rt, "CLAUDECODE")) return known2("claude-code", claude);
|
|
51736
|
+
if (codex) return known2("codex", codex);
|
|
51737
|
+
const other = AGENTS.find((agent) => agent.env?.some((name) => envValue2(rt, name)));
|
|
51738
|
+
return other ? known2(other.id) : { id: "unknown", label: "unknown", ...given2 ? { sessionId: given2 } : {} };
|
|
51739
|
+
};
|
|
51740
|
+
isFileAt = async (rt, path4) => (await rt.fs.stat(path4))?.isFile ?? false;
|
|
51741
|
+
listDir = async (rt, dir) => rt.fs.readdir(dir).catch(() => []);
|
|
51742
|
+
moved = (rt, name, home, dir) => {
|
|
51743
|
+
const value = envValue2(rt, name);
|
|
51744
|
+
return value ? rt.path.resolve(rt.cwd, value) : rt.path.join(home, dir);
|
|
51745
|
+
};
|
|
51746
|
+
findClaudeCode = async (rt, home, sid) => {
|
|
51747
|
+
const projects = rt.path.join(moved(rt, "CLAUDE_CONFIG_DIR", home, ".claude"), "projects");
|
|
51748
|
+
for (const folder of await listDir(rt, projects)) {
|
|
51749
|
+
const file = rt.path.join(projects, folder, `${sid}.jsonl`);
|
|
51750
|
+
if (await isFileAt(rt, file)) return file;
|
|
51751
|
+
}
|
|
51752
|
+
return void 0;
|
|
51753
|
+
};
|
|
51754
|
+
newestFirst = async (rt, dir, pattern) => (await listDir(rt, dir)).filter((name) => pattern.test(name)).sort().reverse();
|
|
51755
|
+
codexRollout = async (rt, dir, sid) => {
|
|
51756
|
+
const name = (await listDir(rt, dir)).find((entry2) => entry2.startsWith("rollout-") && entry2.endsWith(`-${sid}.jsonl`));
|
|
51757
|
+
return name ? rt.path.join(dir, name) : void 0;
|
|
51758
|
+
};
|
|
51759
|
+
findCodex = async (rt, home, sid) => {
|
|
51760
|
+
const base = moved(rt, "CODEX_HOME", home, ".codex");
|
|
51761
|
+
const sessions = rt.path.join(base, "sessions");
|
|
51762
|
+
let days = 0;
|
|
51763
|
+
for (const year of await newestFirst(rt, sessions, /^\d{4}$/))
|
|
51764
|
+
for (const month of await newestFirst(rt, rt.path.join(sessions, year), /^\d{2}$/))
|
|
51765
|
+
for (const day of await newestFirst(rt, rt.path.join(sessions, year, month), /^\d{2}$/)) {
|
|
51766
|
+
if (++days > CODEX_DAYS_SEARCHED) return codexRollout(rt, rt.path.join(base, "archived_sessions"), sid);
|
|
51767
|
+
const found = await codexRollout(rt, rt.path.join(sessions, year, month, day), sid);
|
|
51768
|
+
if (found) return found;
|
|
51769
|
+
}
|
|
51770
|
+
return codexRollout(rt, rt.path.join(base, "archived_sessions"), sid);
|
|
51771
|
+
};
|
|
51772
|
+
locate3 = async (rt, agent) => {
|
|
51773
|
+
if (agent.id !== "claude-code" && agent.id !== "codex")
|
|
51774
|
+
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`) };
|
|
51775
|
+
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`) };
|
|
51776
|
+
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") };
|
|
51777
|
+
const claude = agent.id === "claude-code";
|
|
51778
|
+
const path4 = claude ? await findClaudeCode(rt, rt.homeDir, agent.sessionId) : await findCodex(rt, rt.homeDir, agent.sessionId);
|
|
51779
|
+
if (path4) return { path: path4, format: claude ? "claude-code-jsonl" : "codex-jsonl" };
|
|
51780
|
+
const where3 = claude ? "~/.claude/projects/*/" : "~/.codex/sessions/YYYY/MM/DD/, ~/.codex/archived_sessions/";
|
|
51781
|
+
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`) };
|
|
51782
|
+
};
|
|
51783
|
+
tail3 = (data, max) => {
|
|
51784
|
+
if (data.length <= max) return { data, cut: false };
|
|
51785
|
+
const start = data.length - max;
|
|
51786
|
+
const newline = data.indexOf(10, start);
|
|
51787
|
+
return { data: data.subarray(newline < 0 ? start : newline + 1), cut: true };
|
|
51788
|
+
};
|
|
51789
|
+
missing3 = (reason2) => ({ status: "missing", reason: reason2, lines: 0, bytes: 0, truncated: false });
|
|
51790
|
+
readTranscript = async (rt, agent, cleaner, options) => {
|
|
51791
|
+
if (options.skip) return { status: "skipped", lines: 0, bytes: 0, truncated: false };
|
|
51792
|
+
let found;
|
|
51793
|
+
if (options.file !== void 0) {
|
|
51794
|
+
const path4 = rt.path.resolve(rt.cwd, options.file);
|
|
51795
|
+
if (!await isFileAt(rt, path4)) throw new FeedbackError("TRANSCRIPT_NOT_FOUND", msg(`--transcript: ${options.file} is not a file`, `--transcript\uFF1A${options.file} \u4E0D\u662F\u6587\u4EF6`));
|
|
51796
|
+
found = { path: path4, format: path4.endsWith(".jsonl") ? "jsonl" : "text" };
|
|
51797
|
+
} else found = await locate3(rt, agent);
|
|
51798
|
+
if (!found.path) return missing3(found.reason ?? "");
|
|
51799
|
+
const raw = tail3(await rt.fs.readFile(found.path), TRANSCRIPT_READ_MAX_BYTES);
|
|
51800
|
+
const decoded = new TextDecoder("utf-8", { fatal: false }).decode(raw.data);
|
|
51801
|
+
const cleaned = found.format === "text" ? { text: cleaner.text(decoded), lines: decoded.split("\n").length } : cleanJsonl(cleaner, decoded);
|
|
51802
|
+
const bytes = new TextEncoder().encode(cleaned.text);
|
|
51803
|
+
const kept3 = tail3(bytes, TRANSCRIPT_MAX_BYTES);
|
|
51804
|
+
const text13 = kept3.cut ? new TextDecoder().decode(kept3.data) : cleaned.text;
|
|
51805
|
+
const lines2 = kept3.cut ? text13.split("\n").filter((line) => line.trim() !== "").length : cleaned.lines;
|
|
51806
|
+
return { status: "found", path: found.path, format: found.format ?? "jsonl", text: text13, lines: lines2, bytes: kept3.data.length, truncated: raw.cut || kept3.cut };
|
|
51807
|
+
};
|
|
51808
|
+
}
|
|
51809
|
+
});
|
|
51810
|
+
|
|
51811
|
+
// src/feedback/bundle.ts
|
|
51812
|
+
import { gzipSync } from "fflate";
|
|
51813
|
+
var FORMAT5, MESSAGE_MAX_CHARS, MAX_BUNDLE_BYTES, tildify, projectDirOf, cleanMessage, documentOf, buildFeedback;
|
|
51814
|
+
var init_bundle = __esm({
|
|
51815
|
+
"src/feedback/bundle.ts"() {
|
|
51816
|
+
"use strict";
|
|
51817
|
+
init_util();
|
|
51818
|
+
init_i18n();
|
|
51819
|
+
init_task();
|
|
51820
|
+
init_version();
|
|
51821
|
+
init_clean2();
|
|
51822
|
+
init_project_files();
|
|
51823
|
+
init_transcript();
|
|
51824
|
+
FORMAT5 = "popost-feedback/1";
|
|
51825
|
+
MESSAGE_MAX_CHARS = 4e3;
|
|
51826
|
+
MAX_BUNDLE_BYTES = 25 * 1024 * 1024;
|
|
51827
|
+
tildify = (rt, path4) => {
|
|
51828
|
+
const home = rt.homeDir?.replace(/[\\/]+$/, "");
|
|
51829
|
+
return home && home.length > 1 && (path4 === home || path4.startsWith(home + rt.path.sep)) ? "~" + path4.slice(home.length) : path4;
|
|
51830
|
+
};
|
|
51831
|
+
projectDirOf = async (rt, dir) => {
|
|
51832
|
+
if (dir === void 0) return enclosingProject(rt, ".");
|
|
51833
|
+
const root = rt.path.resolve(rt.cwd, dir);
|
|
51834
|
+
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`));
|
|
51835
|
+
return root;
|
|
51836
|
+
};
|
|
51837
|
+
cleanMessage = (raw, clean2) => {
|
|
51838
|
+
const message2 = raw.trim();
|
|
51839
|
+
if (!message2)
|
|
51840
|
+
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"));
|
|
51841
|
+
if ([...message2].length > MESSAGE_MAX_CHARS)
|
|
51842
|
+
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`));
|
|
51843
|
+
return clean2(message2);
|
|
51844
|
+
};
|
|
51845
|
+
documentOf = (rt, built, createdAt) => ({
|
|
51846
|
+
format: FORMAT5,
|
|
51847
|
+
createdAt,
|
|
51848
|
+
message: built.message,
|
|
51849
|
+
client: { version: VERSION, platform: rt.platform ?? "unknown", ...rt.arch ? { arch: rt.arch } : {}, ...rt.nodeVersion ? { node: rt.nodeVersion } : {}, lang: currentLang() },
|
|
51850
|
+
agent: { id: built.agent.id, ...built.agent.sessionId ? { sessionId: built.agent.sessionId } : {}, ...built.transcript.path ? { transcriptPath: tildify(rt, built.transcript.path) } : {} },
|
|
51851
|
+
task: {
|
|
51852
|
+
...built.projectDir ? { dir: tildify(rt, built.projectDir) } : {},
|
|
51853
|
+
...built.task?.id ? { id: built.task.id } : {},
|
|
51854
|
+
...built.task?.title ? { title: built.task.title } : {},
|
|
51855
|
+
...built.task ? { kind: built.task.kind } : {}
|
|
51856
|
+
},
|
|
51857
|
+
project: { files: built.project?.files ?? [], documents: built.project?.documents ?? {} },
|
|
51858
|
+
transcript: {
|
|
51859
|
+
status: built.transcript.status,
|
|
51860
|
+
...built.transcript.format ? { format: built.transcript.format } : {},
|
|
51861
|
+
...built.transcript.text !== void 0 ? { text: built.transcript.text } : {},
|
|
51862
|
+
lines: built.transcript.lines,
|
|
51863
|
+
bytes: built.transcript.bytes,
|
|
51864
|
+
truncated: built.transcript.truncated,
|
|
51865
|
+
omittedImages: built.transcript.omittedImages
|
|
51866
|
+
},
|
|
51867
|
+
redactions: built.stats.redactions
|
|
51868
|
+
});
|
|
51869
|
+
buildFeedback = async (rt, options) => {
|
|
51870
|
+
const cleaner = createCleaner({ homeDir: rt.homeDir, secrets: environmentSecrets(rt.env) });
|
|
51871
|
+
const message2 = cleanMessage(options.message, cleaner.text);
|
|
51872
|
+
const agent = detectAgent(rt, options.session);
|
|
51873
|
+
const before = cleaner.stats.omittedImages;
|
|
51874
|
+
const transcript2 = await readTranscript(rt, agent, cleaner, { file: options.transcript, skip: options.noTranscript });
|
|
51875
|
+
const transcriptImages = cleaner.stats.omittedImages - before;
|
|
51876
|
+
const projectDir = await projectDirOf(rt, options.dir);
|
|
51877
|
+
const task = projectDir ? await projectTask(rt, { dir: projectDir, kind: "found" }, false).catch(() => void 0) : void 0;
|
|
51878
|
+
const project = projectDir ? await collectProjectFiles(rt, projectDir, cleaner) : void 0;
|
|
51879
|
+
const parts = { message: message2, agent, transcript: { ...transcript2, omittedImages: transcriptImages }, projectDir, task, project, stats: { ...cleaner.stats } };
|
|
51880
|
+
const json4 = JSON.stringify(documentOf(rt, parts, rt.now().toISOString()));
|
|
51881
|
+
const gzip = gzipSync(new TextEncoder().encode(json4), { level: 6, mtime: 0 });
|
|
51882
|
+
return { ...parts, gzip, sha256: sha256(gzip) };
|
|
51883
|
+
};
|
|
51884
|
+
}
|
|
51885
|
+
});
|
|
51886
|
+
|
|
51887
|
+
// src/feedback/upload.ts
|
|
51888
|
+
var RATE_RETRIES2, MAX_WAIT_SEC2, UPLOAD_ATTEMPTS, AGENT_ID, rateAware2, reservation, badAnswer, ticketOf, uploadMissing, attempt2, sendFeedback;
|
|
51889
|
+
var init_upload = __esm({
|
|
51890
|
+
"src/feedback/upload.ts"() {
|
|
51891
|
+
"use strict";
|
|
51892
|
+
init_i18n();
|
|
51893
|
+
init_base();
|
|
51894
|
+
init_errors3();
|
|
51895
|
+
init_time();
|
|
51896
|
+
init_task();
|
|
51897
|
+
init_version();
|
|
51898
|
+
RATE_RETRIES2 = 3;
|
|
51899
|
+
MAX_WAIT_SEC2 = 60;
|
|
51900
|
+
UPLOAD_ATTEMPTS = 2;
|
|
51901
|
+
AGENT_ID = /^[a-z0-9-]{1,40}$/;
|
|
51902
|
+
rateAware2 = async (rt, call2) => {
|
|
51903
|
+
for (let attempt3 = 0; ; attempt3++) {
|
|
51904
|
+
try {
|
|
51905
|
+
return await call2();
|
|
51906
|
+
} catch (error2) {
|
|
51907
|
+
if (!(error2 instanceof PopostApiError) || error2.code !== "RATE_LIMITED" || attempt3 >= RATE_RETRIES2) throw error2;
|
|
51908
|
+
const asked2 = Number(error2.details.retryAfterSeconds);
|
|
51909
|
+
await sleep(rt, Math.ceil((Number.isFinite(asked2) && asked2 > 0 ? Math.min(asked2, MAX_WAIT_SEC2) : 5) * 1e3));
|
|
51910
|
+
}
|
|
51911
|
+
}
|
|
51912
|
+
};
|
|
51913
|
+
reservation = (rt, built, operationKey) => {
|
|
51914
|
+
const title = cleanTitle(built.task?.title);
|
|
51915
|
+
const task = {
|
|
51916
|
+
...built.task?.id && TASK_ID.test(built.task.id) ? { id: built.task.id } : {},
|
|
51917
|
+
...title ? { title } : {},
|
|
51918
|
+
...built.task ? { kind: built.task.kind } : {}
|
|
51919
|
+
};
|
|
51920
|
+
return {
|
|
51921
|
+
operationKey,
|
|
51922
|
+
message: built.message,
|
|
51923
|
+
sizeBytes: built.gzip.length,
|
|
51924
|
+
sha256: built.sha256,
|
|
51925
|
+
...AGENT_ID.test(built.agent.id) ? { agent: { id: built.agent.id, ...built.agent.sessionId ? { sessionId: built.agent.sessionId } : {} } } : {},
|
|
51926
|
+
...Object.keys(task).length ? { task } : {},
|
|
51927
|
+
client: { version: VERSION, os: (rt.platform ?? "unknown").slice(0, 80) },
|
|
51928
|
+
contents: {
|
|
51929
|
+
transcript: built.transcript.status,
|
|
51930
|
+
transcriptBytes: built.transcript.bytes,
|
|
51931
|
+
transcriptLines: built.transcript.lines,
|
|
51932
|
+
projectFiles: Object.keys(built.project?.documents ?? {}).length,
|
|
51933
|
+
redactions: built.stats.redactions,
|
|
51934
|
+
omittedImages: built.stats.omittedImages,
|
|
51935
|
+
truncated: built.transcript.truncated
|
|
51936
|
+
}
|
|
51937
|
+
};
|
|
51938
|
+
};
|
|
51939
|
+
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" });
|
|
51940
|
+
ticketOf = (data) => {
|
|
51941
|
+
if (!isRecord(data) || typeof data.id !== "string" || !/^[A-Za-z0-9-]{1,64}$/.test(data.id) || data.uploadUrl !== null && typeof data.uploadUrl !== "string")
|
|
51942
|
+
throw badAnswer("POST /feedback");
|
|
51943
|
+
const reference2 = typeof data.reference === "string" && data.reference ? data.reference : data.id.slice(0, 8);
|
|
51944
|
+
return { id: data.id, reference: reference2, uploadUrl: data.uploadUrl, state: String(data.state ?? "") };
|
|
51945
|
+
};
|
|
51946
|
+
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"));
|
|
51947
|
+
attempt2 = async (rt, client2, built, body) => {
|
|
51948
|
+
const ticket2 = ticketOf(await rateAware2(rt, () => client2.request("POST", "/feedback", { body })));
|
|
51949
|
+
if (ticket2.state === "received" && !ticket2.uploadUrl) return { id: ticket2.id, reference: ticket2.reference, receivedAt: rt.now().toISOString() };
|
|
51950
|
+
if (ticket2.uploadUrl)
|
|
51951
|
+
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"));
|
|
51952
|
+
const done2 = await rateAware2(rt, () => client2.request("POST", `/feedback/${encodeURIComponent(ticket2.id)}/complete`, { body: {} }));
|
|
51953
|
+
if (!isRecord(done2) || done2.id !== ticket2.id) throw badAnswer(`POST /feedback/${ticket2.id}/complete`);
|
|
51954
|
+
return {
|
|
51955
|
+
id: ticket2.id,
|
|
51956
|
+
reference: typeof done2.reference === "string" && done2.reference ? done2.reference : ticket2.reference,
|
|
51957
|
+
receivedAt: typeof done2.receivedAt === "string" ? done2.receivedAt : rt.now().toISOString()
|
|
51958
|
+
};
|
|
51959
|
+
};
|
|
51960
|
+
sendFeedback = async (rt, client2, built) => {
|
|
51961
|
+
const body = reservation(rt, built, rt.randomUUID());
|
|
51962
|
+
for (let tries = 1; ; tries++) {
|
|
51963
|
+
try {
|
|
51964
|
+
return await attempt2(rt, client2, built, body);
|
|
51965
|
+
} catch (error2) {
|
|
51966
|
+
if (tries >= UPLOAD_ATTEMPTS || !uploadMissing(error2)) throw error2;
|
|
51967
|
+
}
|
|
51968
|
+
}
|
|
51969
|
+
};
|
|
51970
|
+
}
|
|
51971
|
+
});
|
|
51972
|
+
|
|
51973
|
+
// src/commands/feedback.ts
|
|
51974
|
+
var feedback_exports = {};
|
|
51975
|
+
__export(feedback_exports, {
|
|
51976
|
+
main: () => main22
|
|
51977
|
+
});
|
|
51978
|
+
var spec9, quote15, wouldSend, tooLarge, report3, run5, main22;
|
|
51979
|
+
var init_feedback = __esm({
|
|
51980
|
+
"src/commands/feedback.ts"() {
|
|
51981
|
+
"use strict";
|
|
51982
|
+
init_args();
|
|
51983
|
+
init_util();
|
|
51984
|
+
init_bundle();
|
|
51985
|
+
init_transcript();
|
|
51986
|
+
init_upload();
|
|
51987
|
+
init_i18n();
|
|
51988
|
+
init_api();
|
|
51989
|
+
init_errors3();
|
|
51990
|
+
spec9 = () => ({
|
|
51991
|
+
prog: "popost feedback",
|
|
51992
|
+
description: msg(
|
|
51993
|
+
"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.",
|
|
51994
|
+
"\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"
|
|
51995
|
+
),
|
|
51996
|
+
options: [
|
|
51997
|
+
{ 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") },
|
|
51998
|
+
{ 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") },
|
|
51999
|
+
{ 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") },
|
|
52000
|
+
{ flag: "--no-transcript", kind: "flag", help: msg("send no session transcript", "\u4E0D\u53D1\u9001\u4F1A\u8BDD\u8BB0\u5F55") },
|
|
52001
|
+
{ 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") },
|
|
52002
|
+
{ 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") },
|
|
52003
|
+
{ 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") }
|
|
52004
|
+
]
|
|
52005
|
+
});
|
|
52006
|
+
quote15 = (word2) => /^[A-Za-z0-9_./:=,@+-]+$/.test(word2) ? word2 : `'${word2.replace(/'/g, `'\\''`)}'`;
|
|
52007
|
+
wouldSend = (rt, built) => {
|
|
52008
|
+
const { transcript: transcript2, project } = built;
|
|
52009
|
+
const sent = project ? project.files.filter((file) => file.path in project.documents) : [];
|
|
52010
|
+
return {
|
|
52011
|
+
message: built.message,
|
|
52012
|
+
agent: { id: built.agent.id, label: built.agent.label, ...built.agent.sessionId ? { sessionId: built.agent.sessionId } : {} },
|
|
52013
|
+
transcript: {
|
|
52014
|
+
status: transcript2.status,
|
|
52015
|
+
...transcript2.path ? { path: tildify(rt, transcript2.path) } : {},
|
|
52016
|
+
...transcript2.format ? { format: transcript2.format } : {},
|
|
52017
|
+
lines: transcript2.lines,
|
|
52018
|
+
bytes: transcript2.bytes,
|
|
52019
|
+
truncated: transcript2.truncated,
|
|
52020
|
+
omittedImages: transcript2.omittedImages,
|
|
52021
|
+
...transcript2.reason ? { reason: transcript2.reason } : {}
|
|
52022
|
+
},
|
|
52023
|
+
project: project ? {
|
|
52024
|
+
dir: tildify(rt, built.projectDir ?? ""),
|
|
52025
|
+
task: built.task ? { ...built.task.id ? { id: built.task.id } : {}, ...built.task.title ? { title: built.task.title } : {}, kind: built.task.kind } : null,
|
|
52026
|
+
sent,
|
|
52027
|
+
listedOnly: project.files.length - sent.length,
|
|
52028
|
+
...project.listTruncated ? { listTruncated: true } : {}
|
|
52029
|
+
} : null,
|
|
52030
|
+
redactions: built.stats.redactions,
|
|
52031
|
+
omittedImages: built.stats.omittedImages,
|
|
52032
|
+
bytes: built.gzip.length
|
|
52033
|
+
};
|
|
52034
|
+
};
|
|
52035
|
+
tooLarge = (built) => msg(
|
|
52036
|
+
`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.`,
|
|
52037
|
+
`\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`
|
|
52038
|
+
);
|
|
52039
|
+
report3 = async (rt, argv, options) => {
|
|
52040
|
+
if (options.transcript !== void 0 && options.noTranscript)
|
|
52041
|
+
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" });
|
|
52042
|
+
const built = await buildFeedback(rt, options);
|
|
52043
|
+
const out2 = options.out ? rt.path.resolve(rt.cwd, options.out) : void 0;
|
|
52044
|
+
if (out2) await rt.fs.writeFile(out2, built.gzip);
|
|
52045
|
+
const written2 = out2 ? { out: tildify(rt, out2) } : {};
|
|
52046
|
+
if (built.gzip.length > MAX_BUNDLE_BYTES) return fail(rt, tooLarge(built), 2, { code: "TOO_LARGE", bytes: built.gzip.length, ...written2 });
|
|
52047
|
+
if (!options.confirm) {
|
|
52048
|
+
const next = ["popost", "feedback", ...argv, "--confirm"].map(quote15).join(" ");
|
|
52049
|
+
const note = msg(
|
|
52050
|
+
"Nothing was sent. Show the user what would be sent; run next only after they agree.",
|
|
52051
|
+
"\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"
|
|
52052
|
+
);
|
|
52053
|
+
printJson(rt, { ok: true, dryRun: true, wouldSend: wouldSend(rt, built), ...written2, next, note }, true);
|
|
52054
|
+
return 0;
|
|
52055
|
+
}
|
|
52056
|
+
const sent = await sendFeedback(rt, new PopostClient({ ...rt, project: void 0 }), built);
|
|
52057
|
+
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`);
|
|
52058
|
+
printJson(rt, { ok: true, id: sent.id, reference: sent.reference, bytes: built.gzip.length, receivedAt: sent.receivedAt, ...written2, note: thanks });
|
|
52059
|
+
return 0;
|
|
52060
|
+
};
|
|
52061
|
+
run5 = async (rt, argv, options) => {
|
|
52062
|
+
try {
|
|
52063
|
+
return await report3(rt, argv, options);
|
|
52064
|
+
} catch (error2) {
|
|
52065
|
+
if (error2 instanceof FeedbackError) return fail(rt, error2.message, 2, { code: error2.code });
|
|
52066
|
+
if (error2 instanceof PopostApiError) {
|
|
52067
|
+
const code = error2.code || "API_ERROR";
|
|
52068
|
+
return fail(rt, error2.message, LOCAL_ERROR_CODES.includes(code) ? 2 : 1, { code });
|
|
52069
|
+
}
|
|
52070
|
+
if (error2 instanceof UsageError) return fail(rt, error2.message, 2, { code: "AUTH" });
|
|
52071
|
+
throw error2;
|
|
52072
|
+
}
|
|
52073
|
+
};
|
|
52074
|
+
main22 = (argv, rt) => withArgs(
|
|
52075
|
+
argv,
|
|
52076
|
+
spec9(),
|
|
52077
|
+
rt,
|
|
52078
|
+
(args2) => run5(rt, argv, {
|
|
52079
|
+
message: args2.req("message"),
|
|
52080
|
+
dir: args2.string("dir"),
|
|
52081
|
+
transcript: args2.string("transcript"),
|
|
52082
|
+
noTranscript: args2.flag("no-transcript"),
|
|
52083
|
+
session: args2.string("session"),
|
|
52084
|
+
out: args2.string("out"),
|
|
52085
|
+
confirm: args2.flag("confirm")
|
|
52086
|
+
})
|
|
52087
|
+
);
|
|
52088
|
+
}
|
|
52089
|
+
});
|
|
52090
|
+
|
|
51310
52091
|
// src/commands/post-bundle.ts
|
|
51311
52092
|
var post_bundle_exports2 = {};
|
|
51312
52093
|
__export(post_bundle_exports2, {
|
|
51313
|
-
main: () =>
|
|
52094
|
+
main: () => main23
|
|
51314
52095
|
});
|
|
51315
|
-
var FILE, ticket, validate2, importBundle, serviceConfig2, table2, failure3,
|
|
52096
|
+
var FILE, ticket, validate2, importBundle, serviceConfig2, table2, failure3, main23;
|
|
51316
52097
|
var init_post_bundle2 = __esm({
|
|
51317
52098
|
"src/commands/post-bundle.ts"() {
|
|
51318
52099
|
"use strict";
|
|
@@ -51377,7 +52158,7 @@ var init_post_bundle2 = __esm({
|
|
|
51377
52158
|
printJson(rt, { ok: false, error: { code, msg: error2.message } }, true);
|
|
51378
52159
|
return 2;
|
|
51379
52160
|
};
|
|
51380
|
-
|
|
52161
|
+
main23 = async (argv, rt) => {
|
|
51381
52162
|
try {
|
|
51382
52163
|
return await runSubcommand("popost", table2(), argv, rt);
|
|
51383
52164
|
} catch (error2) {
|
|
@@ -51392,9 +52173,9 @@ var init_post_bundle2 = __esm({
|
|
|
51392
52173
|
// src/main.ts
|
|
51393
52174
|
var main_exports = {};
|
|
51394
52175
|
__export(main_exports, {
|
|
51395
|
-
run: () =>
|
|
52176
|
+
run: () => run6
|
|
51396
52177
|
});
|
|
51397
|
-
var GROUPS2, register, usage,
|
|
52178
|
+
var GROUPS2, register, usage, run6, runCommand;
|
|
51398
52179
|
var init_main2 = __esm({
|
|
51399
52180
|
"src/main.ts"() {
|
|
51400
52181
|
"use strict";
|
|
@@ -51434,6 +52215,7 @@ var init_main2 = __esm({
|
|
|
51434
52215
|
register(["cloud"], async () => (await Promise.resolve().then(() => (init_cloud(), cloud_exports))).main, false);
|
|
51435
52216
|
register(["deck"], async () => (await Promise.resolve().then(() => (init_deck(), deck_exports))).main, false);
|
|
51436
52217
|
register(["video"], async () => (await Promise.resolve().then(() => (init_video(), video_exports))).main, false);
|
|
52218
|
+
register(["feedback"], async () => (await Promise.resolve().then(() => (init_feedback(), feedback_exports))).main, false);
|
|
51437
52219
|
register(["ticket", "validate", "import"], async () => (await Promise.resolve().then(() => (init_post_bundle2(), post_bundle_exports2))).main, true);
|
|
51438
52220
|
usage = () => msg(
|
|
51439
52221
|
[
|
|
@@ -51450,6 +52232,7 @@ var init_main2 = __esm({
|
|
|
51450
52232
|
"sources: ticket, validate, import, attach-bundle, link, inspiration, template",
|
|
51451
52233
|
"account: account (credit balance and plan), usage (what a project has cost, from popost.ai), pricing (current link tariff); no charge",
|
|
51452
52234
|
"video: video (videos as editable projects; popost video --help lists its commands)",
|
|
52235
|
+
"support: feedback (report a problem to the popost team, only when the user asks; dry run unless --confirm)",
|
|
51453
52236
|
""
|
|
51454
52237
|
].join("\n"),
|
|
51455
52238
|
[
|
|
@@ -51466,10 +52249,11 @@ var init_main2 = __esm({
|
|
|
51466
52249
|
"\u7D20\u6750\u6765\u6E90: ticket\u3001validate\u3001import\u3001attach-bundle\u3001link\u3001inspiration\u3001template",
|
|
51467
52250
|
"\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",
|
|
51468
52251
|
"\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",
|
|
52252
|
+
"\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",
|
|
51469
52253
|
""
|
|
51470
52254
|
].join("\n")
|
|
51471
52255
|
);
|
|
51472
|
-
|
|
52256
|
+
run6 = (argv, rt) => withLang(resolveLang(rt.env), () => runCommand(argv, rt));
|
|
51473
52257
|
runCommand = async (argv, rt) => {
|
|
51474
52258
|
const [name, ...rest] = argv;
|
|
51475
52259
|
if (!name || name === "-h" || name === "--help" || name === "help") {
|
|
@@ -51490,10 +52274,10 @@ ${usage()}`);
|
|
|
51490
52274
|
const updates = await openUpdateSession(rt, name, rest);
|
|
51491
52275
|
const own3 = updates.rt;
|
|
51492
52276
|
try {
|
|
51493
|
-
const
|
|
52277
|
+
const main24 = await group.load();
|
|
51494
52278
|
const { dirArg: dirArg2, inProject: inProject3 } = await Promise.resolve().then(() => (init_task(), task_exports));
|
|
51495
52279
|
const dir = dirArg2(rest);
|
|
51496
|
-
return await
|
|
52280
|
+
return await main24(group.keepName ? argv : rest, dir ? inProject3(own3, dir, "found") : own3);
|
|
51497
52281
|
} catch (error2) {
|
|
51498
52282
|
printJson(own3, { ok: false, error: errorText(error2) });
|
|
51499
52283
|
return 1;
|
|
@@ -51638,7 +52422,7 @@ var openSystemBrowser = async (url, host) => {
|
|
|
51638
52422
|
};
|
|
51639
52423
|
|
|
51640
52424
|
// src/node-runtime.ts
|
|
51641
|
-
var
|
|
52425
|
+
var missing4 = (error2) => error2?.code === "ENOENT";
|
|
51642
52426
|
var nodeFileSystem = {
|
|
51643
52427
|
realpath: (p) => fsp.realpath(p),
|
|
51644
52428
|
readFile: async (p) => new Uint8Array(await fsp.readFile(p)),
|
|
@@ -51666,7 +52450,7 @@ var nodeFileSystem = {
|
|
|
51666
52450
|
const s = await fsp.stat(p);
|
|
51667
52451
|
return { isFile: s.isFile(), isDirectory: s.isDirectory(), size: s.size, mtimeMs: s.mtimeMs };
|
|
51668
52452
|
} catch (error2) {
|
|
51669
|
-
if (
|
|
52453
|
+
if (missing4(error2)) return null;
|
|
51670
52454
|
throw error2;
|
|
51671
52455
|
}
|
|
51672
52456
|
},
|
|
@@ -51873,7 +52657,7 @@ var readOptional = (file) => {
|
|
|
51873
52657
|
try {
|
|
51874
52658
|
return readFileSync(file, "utf8");
|
|
51875
52659
|
} catch (error2) {
|
|
51876
|
-
if (
|
|
52660
|
+
if (missing4(error2)) return null;
|
|
51877
52661
|
throw error2;
|
|
51878
52662
|
}
|
|
51879
52663
|
};
|
|
@@ -51985,6 +52769,8 @@ var createNodeRuntime = (profile2) => {
|
|
|
51985
52769
|
openExternal: (url) => openSystemBrowser(url, systemBrowserHost),
|
|
51986
52770
|
homeDir: homeDir2,
|
|
51987
52771
|
platform: platform3(),
|
|
52772
|
+
arch: process.arch,
|
|
52773
|
+
nodeVersion: process.version,
|
|
51988
52774
|
stdin: readStdin,
|
|
51989
52775
|
readSecret: () => readTerminalSecret(process.stdin, (text13) => void process.stderr.write(text13)),
|
|
51990
52776
|
skillRoot: packageRoot(),
|
|
@@ -52039,7 +52825,7 @@ if (hasProfile && !(profile && PROFILE_NAME.test(profile))) {
|
|
|
52039
52825
|
`);
|
|
52040
52826
|
process.exit(2);
|
|
52041
52827
|
}
|
|
52042
|
-
|
|
52828
|
+
run6(args, createNodeRuntime(profile)).then(
|
|
52043
52829
|
(code) => {
|
|
52044
52830
|
process.exitCode = code;
|
|
52045
52831
|
},
|