@gentbajko/slopify 2.0.2 → 2.0.3
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/dist/adapters/alignment/protocol.js +11 -1
- package/dist/adapters/alignment/runner.js +4 -1
- package/dist/adapters/alignment/worker.js +28 -5
- package/dist/adapters/explain.js +93 -0
- package/dist/adapters/ffmpeg.js +3 -3
- package/dist/adapters/host-cli/index.js +9 -2
- package/dist/adapters/host-cli/transport.js +4 -4
- package/dist/adapters/image/bytes.js +2 -2
- package/dist/adapters/image/codex-output.js +12 -12
- package/dist/adapters/image/codex.js +24 -8
- package/dist/adapters/image/fal.js +12 -6
- package/dist/adapters/image/google.js +18 -8
- package/dist/adapters/image/models.js +8 -2
- package/dist/adapters/image/openai.js +15 -6
- package/dist/adapters/image/replicate.js +16 -7
- package/dist/adapters/llm/claude-code-models.js +1 -1
- package/dist/adapters/llm/claude-code.js +16 -7
- package/dist/adapters/llm/cli-login-error.js +2 -1
- package/dist/adapters/llm/codex-models.js +1 -1
- package/dist/adapters/llm/codex.js +5 -6
- package/dist/adapters/llm/document-workspace.js +2 -2
- package/dist/adapters/llm/gemini-models.js +1 -1
- package/dist/adapters/llm/gemini-workspace.js +1 -1
- package/dist/adapters/llm/gemini.js +15 -11
- package/dist/adapters/llm/openrouter.js +21 -9
- package/dist/adapters/llm/run-cli.js +14 -11
- package/dist/adapters/tts/cartesia.js +10 -3
- package/dist/adapters/tts/elevenlabs.js +18 -6
- package/dist/adapters/tts/inworld-async.js +47 -16
- package/dist/adapters/tts/inworld.js +25 -15
- package/dist/adapters/tts/openai.js +18 -6
- package/dist/catalog/registry.js +13 -10
- package/dist/catalog/store.js +1 -1
- package/dist/catalog/validate.js +13 -4
- package/dist/edge/cli.js +33 -7
- package/dist/edge/docker-launch.js +6 -6
- package/dist/edge/docker-projects/engine.js +34 -13
- package/dist/edge/docker-projects/install.js +8 -8
- package/dist/edge/docker-projects/state.js +6 -6
- package/dist/edge/docker-projects/tree.js +6 -6
- package/dist/edge/docker.js +13 -13
- package/dist/edge/http/actions.js +27 -25
- package/dist/edge/http/app.js +3 -3
- package/dist/edge/http/audio-preview.js +1 -1
- package/dist/edge/http/checkpoints.js +5 -1
- package/dist/edge/http/diagnostics.js +3 -1
- package/dist/edge/http/draft-files.js +2 -2
- package/dist/edge/http/draft-problem.js +11 -1
- package/dist/edge/http/files.js +4 -4
- package/dist/edge/http/folder-location.js +3 -3
- package/dist/edge/http/fonts.js +22 -10
- package/dist/edge/http/host-cli.js +34 -12
- package/dist/edge/http/multipart.js +7 -5
- package/dist/edge/http/open-folder.js +2 -2
- package/dist/edge/http/planning.js +4 -4
- package/dist/edge/http/problem.js +2 -2
- package/dist/edge/http/project-templates.js +7 -3
- package/dist/edge/http/projects.js +8 -8
- package/dist/edge/http/prompts.js +9 -4
- package/dist/edge/http/providers.js +15 -7
- package/dist/edge/http/revision-files.js +3 -3
- package/dist/edge/http/revisions.js +30 -4
- package/dist/edge/http/schedules.js +9 -9
- package/dist/edge/http/settings.js +15 -9
- package/dist/edge/http/staging.js +5 -5
- package/dist/edge/http/storage.js +4 -4
- package/dist/edge/http/subtitles.js +1 -1
- package/dist/edge/http/tutorial.js +2 -2
- package/dist/edge/http/update.js +3 -3
- package/dist/host-cli/install.js +28 -6
- package/dist/host-cli/paths.js +6 -6
- package/dist/host-cli/server.js +1 -1
- package/dist/host-cli/service.js +11 -11
- package/dist/host-cli/status.js +7 -3
- package/dist/kernel/config/index.js +6 -4
- package/dist/kernel/db/migrate.js +2 -1
- package/dist/kernel/db/migrations/0013-schedule-topic-queue.sql +4 -0
- package/dist/kernel/lock.js +4 -3
- package/dist/kernel/ports/subtitles.js +15 -1
- package/dist/kernel/runner/attempt.js +26 -2
- package/dist/main.js +2 -2
- package/dist/slices/admission/rules.js +32 -20
- package/dist/slices/article/continuation.js +4 -2
- package/dist/slices/article/plain.js +2 -2
- package/dist/slices/article/provided-entries.js +3 -3
- package/dist/slices/article/run.js +2 -2
- package/dist/slices/article/segments.js +5 -3
- package/dist/slices/control/providers.js +20 -7
- package/dist/slices/fonts/catalog.js +1 -1
- package/dist/slices/fonts/upload.js +1 -1
- package/dist/slices/images/run.js +5 -5
- package/dist/slices/library/lint.js +13 -7
- package/dist/slices/library/slots.js +2 -2
- package/dist/slices/narration/concat.js +1 -1
- package/dist/slices/narration/pronunciation-chunks.js +3 -3
- package/dist/slices/narration/pronunciation.js +2 -2
- package/dist/slices/narration/run.js +7 -7
- package/dist/slices/narration/steering.js +3 -3
- package/dist/slices/play-drafts/convert.js +5 -4
- package/dist/slices/play-drafts/readiness.js +12 -6
- package/dist/slices/play-drafts/review-inputs.js +7 -4
- package/dist/slices/play-drafts/review.js +3 -3
- package/dist/slices/play-drafts/service.js +3 -1
- package/dist/slices/play-drafts/uploads.js +1 -1
- package/dist/slices/rebuild/admission-repo.js +2 -2
- package/dist/slices/rebuild/recipe-legacy.js +1 -1
- package/dist/slices/rebuild/recipe-narration-text.js +1 -1
- package/dist/slices/rebuild/recipe-visual.js +1 -1
- package/dist/slices/rebuild/recovery.js +2 -2
- package/dist/slices/rebuild/repo.js +3 -3
- package/dist/slices/rebuild/runtime-admission.js +4 -4
- package/dist/slices/rebuild/runtime-article.js +5 -5
- package/dist/slices/rebuild/runtime-checkpoints.js +4 -4
- package/dist/slices/rebuild/runtime-export-inputs.js +6 -6
- package/dist/slices/rebuild/runtime-export.js +4 -4
- package/dist/slices/rebuild/runtime-local.js +6 -6
- package/dist/slices/rebuild/runtime-narration-text.js +46 -7
- package/dist/slices/rebuild/runtime-piece-label.js +62 -0
- package/dist/slices/rebuild/runtime-provider.js +6 -4
- package/dist/slices/rebuild/runtime-publication.js +3 -3
- package/dist/slices/rebuild/runtime-run.js +11 -1
- package/dist/slices/rebuild/runtime-subtitles.js +78 -15
- package/dist/slices/rebuild/transition-repo.js +6 -6
- package/dist/slices/reruns/index.js +1 -1
- package/dist/slices/research/run.js +9 -7
- package/dist/slices/research/synthesis.js +4 -2
- package/dist/slices/revisions/mutation-assets.js +26 -8
- package/dist/slices/revisions/mutation-cues.js +1 -1
- package/dist/slices/revisions/rules.js +18 -9
- package/dist/slices/revisions/schema.js +1 -1
- package/dist/slices/schedules/repo.js +55 -11
- package/dist/slices/schedules/scheduler.js +25 -8
- package/dist/slices/schedules/schema.js +19 -4
- package/dist/slices/schedules/service.js +2 -0
- package/dist/slices/settings/cli-paths.js +7 -4
- package/dist/slices/settings/models.js +4 -4
- package/dist/slices/settings/playback.js +2 -2
- package/dist/slices/storage/assets.js +5 -5
- package/dist/slices/storage/layout.js +1 -1
- package/dist/slices/subtitles/captions.js +1 -1
- package/dist/slices/subtitles/prepare.js +5 -5
- package/dist/slices/subtitles/transcript.js +1 -1
- package/dist/slices/thumbnail/run.js +8 -8
- package/dist/slices/video/audio-inputs.js +2 -2
- package/dist/slices/video/ffmpeg.js +6 -4
- package/dist/slices/video/plan.js +1 -1
- package/dist/slices/video/run.js +2 -2
- package/dist/updater/plan.js +1 -1
- package/dist/updater/service.js +4 -3
- package/dist/updater/worker.js +6 -4
- package/dist/web/assets/{index-CZNiHm8P.css → index-Bwtmu9ei.css} +1 -1
- package/dist/web/assets/index-DjhMJqMN.js +141 -0
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/web/assets/index-DPgGLX5m.js +0 -137
|
@@ -9,7 +9,7 @@ export function joinedNarration(parts) {
|
|
|
9
9
|
export function narrationTextParts(view, plan, segment) {
|
|
10
10
|
const concat = plan.recipes.find((row) => row.key === (segment === "body" ? "audio:body:concat" : `audio:${segment}`));
|
|
11
11
|
if (concat === undefined)
|
|
12
|
-
throw new Error(`
|
|
12
|
+
throw new Error(`Slopify hit an internal error (the ${segment} narration is missing from the project plan). Retry stage; if it happens again, use Download diagnostics in Settings and report it.`);
|
|
13
13
|
return concat.dependsOn.map((key) => {
|
|
14
14
|
const recipe = plan.recipes.find((row) => row.key === key);
|
|
15
15
|
const selected = view.pieces.find((row) => row.key === key &&
|
|
@@ -18,7 +18,7 @@ export function narrationTextParts(view, plan, segment) {
|
|
|
18
18
|
row.piece.state === "done" &&
|
|
19
19
|
row.fingerprint === recipe?.fingerprint);
|
|
20
20
|
if (selected === undefined || recipe === undefined)
|
|
21
|
-
throw new Error("
|
|
21
|
+
throw new Error("Some narration chunks aren't finished, so the full narration text isn't available. Let the Narration stage finish (Resume, or Retry stage on it), or regenerate the missing chunk in Edit project → Narration.");
|
|
22
22
|
const input = recipe.input;
|
|
23
23
|
if (input.kind === "provided" &&
|
|
24
24
|
Array.isArray(input.semantic) &&
|
|
@@ -29,13 +29,13 @@ export function narrationTextParts(view, plan, segment) {
|
|
|
29
29
|
requestText: null,
|
|
30
30
|
};
|
|
31
31
|
if (input.kind !== "tts")
|
|
32
|
-
throw new Error("
|
|
32
|
+
throw new Error("Slopify hit an internal error (a narration chunk's text was never worked out). Retry stage; if it happens again, use Download diagnostics in Settings and report it.");
|
|
33
33
|
const payload = z
|
|
34
34
|
.object({ text: z.string().optional(), spokenText: z.string().optional() })
|
|
35
35
|
.parse(JSON.parse(selected.piece.payload ?? "{}"));
|
|
36
36
|
if (input.spokenText !== undefined &&
|
|
37
37
|
(payload.spokenText !== input.spokenText || payload.text !== input.text))
|
|
38
|
-
throw new Error("
|
|
38
|
+
throw new Error("A narration chunk's audio no longer matches its prepared text. Regenerate that chunk in Edit project → Narration, then Retry stage.");
|
|
39
39
|
return {
|
|
40
40
|
logicalKey: input.logicalKey,
|
|
41
41
|
spokenText: input.spokenText === undefined ? (payload.text ?? input.text) : (payload.spokenText ?? ""),
|
|
@@ -45,7 +45,7 @@ export function narrationTextParts(view, plan, segment) {
|
|
|
45
45
|
}
|
|
46
46
|
export async function publishNarrationText(deps, context, piece) {
|
|
47
47
|
if (piece.input.kind !== "local")
|
|
48
|
-
throw new Error("
|
|
48
|
+
throw new Error("Slopify hit an internal error (the narration text file step was set up wrongly). Retry stage; if it happens again, use Download diagnostics in Settings and report it.");
|
|
49
49
|
const { segment } = z
|
|
50
50
|
.object({ segment: z.enum(["body", "intro", "outro"]) })
|
|
51
51
|
.parse(piece.input.values);
|
|
@@ -54,10 +54,10 @@ export async function publishNarrationText(deps, context, piece) {
|
|
|
54
54
|
.prepare("SELECT recipe_context FROM revision_work WHERE id=?")
|
|
55
55
|
.get(context.work.workId);
|
|
56
56
|
if (view === undefined)
|
|
57
|
-
throw new Error("
|
|
57
|
+
throw new Error("Slopify hit an internal error (the project version being narrated is missing). Retry stage; if it happens again, use Download diagnostics in Settings and report it.");
|
|
58
58
|
const plan = executionPlan(deps, view, savedCatalogue(row?.recipe_context));
|
|
59
59
|
if (!plan.recipes.some((recipe) => recipe.key === piece.key && recipe.fingerprint === piece.fingerprint))
|
|
60
|
-
throw new Error("
|
|
60
|
+
throw new Error("Slopify hit an internal error (the narration text no longer matches the project's saved inputs). Retry stage; if it happens again, use Download diagnostics in Settings and report it.");
|
|
61
61
|
const parts = narrationTextParts(view, plan, segment);
|
|
62
62
|
const outputs = preparedTexts(deps, context, piece, [
|
|
63
63
|
["narration_txt", `${segment}-narration.txt`, joinedNarration(parts)],
|
|
@@ -73,3 +73,42 @@ export async function publishNarrationText(deps, context, piece) {
|
|
|
73
73
|
}));
|
|
74
74
|
await publishResult(deps, context, piece, outputs, { segment });
|
|
75
75
|
}
|
|
76
|
+
// The narration's chunks in the order they are spoken, each with its clean text. A chunk is
|
|
77
|
+
// sent as one or more parts; the Narration editor numbers these chunks, so anything that
|
|
78
|
+
// names "chunk N" to a person counts from this list.
|
|
79
|
+
export function narrationChunks(parts) {
|
|
80
|
+
const chunks = [];
|
|
81
|
+
for (const part of parts) {
|
|
82
|
+
const last = chunks.at(-1);
|
|
83
|
+
if (last?.key === part.logicalKey)
|
|
84
|
+
chunks[chunks.length - 1] = {
|
|
85
|
+
key: last.key,
|
|
86
|
+
spokenText: `${last.spokenText}${part.spokenText}`,
|
|
87
|
+
};
|
|
88
|
+
else
|
|
89
|
+
chunks.push({ key: part.logicalKey, spokenText: part.spokenText });
|
|
90
|
+
}
|
|
91
|
+
return chunks;
|
|
92
|
+
}
|
|
93
|
+
// The current chunk keys of each narration segment, in spoken order, for the Narration
|
|
94
|
+
// editor. Undefined when the revision has no admitted work to read a plan from, or its
|
|
95
|
+
// narration is not complete yet; the editor then keeps its own listing.
|
|
96
|
+
export function narrationChunkOrder(deps, projectId, revisionId) {
|
|
97
|
+
const row = deps.db
|
|
98
|
+
.prepare("SELECT recipe_context FROM revision_work WHERE project_id=? AND revision_id=? AND recipe_context IS NOT NULL LIMIT 1")
|
|
99
|
+
.get(projectId, revisionId);
|
|
100
|
+
const view = executionView(deps, projectId, revisionId);
|
|
101
|
+
if (row === undefined || view === undefined)
|
|
102
|
+
return undefined;
|
|
103
|
+
const plan = executionPlan(deps, view, savedCatalogue(row.recipe_context));
|
|
104
|
+
const order = {};
|
|
105
|
+
for (const segment of ["intro", "body", "outro"]) {
|
|
106
|
+
try {
|
|
107
|
+
order[segment] = narrationChunks(narrationTextParts(view, plan, segment)).map((chunk) => chunk.key);
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
// A segment that is off, or not narrated yet, has no chunks to order.
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return order;
|
|
114
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { executionPlan, executionView, savedCatalogue } from "./runtime-plan.js";
|
|
2
|
+
// What a failed step is called on screen, so its error says which image, chunk or topic to
|
|
3
|
+
// fix. Worked out only after a failure: numbering a narration chunk means building the plan.
|
|
4
|
+
// Undefined for steps that name their own place (captions, export) or have no single one.
|
|
5
|
+
export function pieceLabel(deps, context, piece) {
|
|
6
|
+
const { key } = piece;
|
|
7
|
+
if (key === "thumbnail:image" || key.startsWith("thumbnail:"))
|
|
8
|
+
return "Thumbnail";
|
|
9
|
+
if (key === "article:body")
|
|
10
|
+
return "Article";
|
|
11
|
+
if (key === "entry:intro:text")
|
|
12
|
+
return "Intro text";
|
|
13
|
+
if (key === "entry:outro:text")
|
|
14
|
+
return "Outro text";
|
|
15
|
+
if (key === "research:planner")
|
|
16
|
+
return "Research plan";
|
|
17
|
+
if (key === "research:notes")
|
|
18
|
+
return "Research notes";
|
|
19
|
+
const topic = /^research:chapter:(\d+)$/.exec(key);
|
|
20
|
+
if (topic !== null)
|
|
21
|
+
return `Research topic ${topic[1] ?? ""}`;
|
|
22
|
+
const view = () => executionView(deps, context.work.projectId, context.work.revisionId);
|
|
23
|
+
if (key.startsWith("image:")) {
|
|
24
|
+
const at = view()?.revision.content.imageOrder.indexOf(key.slice("image:".length)) ?? -1;
|
|
25
|
+
return at === -1 ? "An image" : `Image ${String(at + 1)}`;
|
|
26
|
+
}
|
|
27
|
+
const narration = /^(?:narration:prepare:(?:intro|body|outro):)?audio:(intro|body|outro)(?::(.+))?$/.exec(key);
|
|
28
|
+
if (narration === null)
|
|
29
|
+
return undefined;
|
|
30
|
+
const segment = narration[1] ?? "body";
|
|
31
|
+
const prefix = segment === "body" ? "Narration" : `${segment === "intro" ? "Intro" : "Outro"} narration`;
|
|
32
|
+
if (narration[2] === undefined || narration[2] === "concat" || narration[2] === "future")
|
|
33
|
+
return prefix;
|
|
34
|
+
return narrationChunk(deps, context, segment, key, prefix) ?? prefix;
|
|
35
|
+
}
|
|
36
|
+
function narrationChunk(deps, context, segment, key, prefix) {
|
|
37
|
+
const row = deps.db
|
|
38
|
+
.prepare("SELECT recipe_context FROM revision_work WHERE id=?")
|
|
39
|
+
.get(context.work.workId);
|
|
40
|
+
const view = executionView(deps, context.work.projectId, context.work.revisionId);
|
|
41
|
+
if (row?.recipe_context === null || row === undefined || view === undefined)
|
|
42
|
+
return undefined;
|
|
43
|
+
const plan = executionPlan(deps, view, savedCatalogue(row.recipe_context));
|
|
44
|
+
const concat = plan.recipes.find((recipe) => recipe.key === (segment === "body" ? "audio:body:concat" : `audio:${segment}`));
|
|
45
|
+
if (concat === undefined)
|
|
46
|
+
return undefined;
|
|
47
|
+
// Parts are `<chunk>:<n>`; the chunk is everything before the last colon.
|
|
48
|
+
const chunkOf = (part) => part.slice(0, part.lastIndexOf(":"));
|
|
49
|
+
const chunks = [...new Set(concat.dependsOn.map(chunkOf))];
|
|
50
|
+
const preparing = key.startsWith("narration:prepare:");
|
|
51
|
+
const chunk = preparing ? key.slice(key.indexOf("audio:")) : chunkOf(key);
|
|
52
|
+
const at = chunks.indexOf(chunk);
|
|
53
|
+
if (at === -1)
|
|
54
|
+
return undefined;
|
|
55
|
+
const label = `${prefix} chunk ${String(at + 1)} of ${String(chunks.length)}`;
|
|
56
|
+
if (preparing)
|
|
57
|
+
return `${label} (preparing its text)`;
|
|
58
|
+
const parts = concat.dependsOn.filter((part) => chunkOf(part) === chunk);
|
|
59
|
+
return parts.length > 1
|
|
60
|
+
? `${label}, part ${String(parts.indexOf(key) + 1)} of ${String(parts.length)}`
|
|
61
|
+
: label;
|
|
62
|
+
}
|
|
@@ -117,13 +117,15 @@ export async function executeProviderRecipe(deps, context, providers, piece) {
|
|
|
117
117
|
});
|
|
118
118
|
return "done";
|
|
119
119
|
}
|
|
120
|
-
throw new Error("
|
|
120
|
+
throw new Error("Slopify hit an internal error (this step has no provider request to run). Use Retry stage; if it happens again, use Download diagnostics in Settings and report it.");
|
|
121
121
|
}
|
|
122
122
|
function checkAnswer(piece, answer) {
|
|
123
123
|
if (answer.text.trim() === "")
|
|
124
|
-
return "The
|
|
124
|
+
return "The AI model sent back an empty answer. Use Retry stage; if it keeps happening, choose another model in the Providers section of Edit project.";
|
|
125
125
|
if (piece.key === "research:planner")
|
|
126
|
-
return chaptersFrom(answer.text).length === 0
|
|
126
|
+
return chaptersFrom(answer.text).length === 0
|
|
127
|
+
? "The AI model's research plan listed no chapters, so research could not go on. Use Retry stage; if it keeps happening, choose another model in the Providers section of Edit project."
|
|
128
|
+
: undefined;
|
|
127
129
|
if (piece.key === "research:notes" || piece.key.startsWith("research:chapter:"))
|
|
128
130
|
return sourcedAnswer(piece.key, answer.text);
|
|
129
131
|
return undefined;
|
|
@@ -175,7 +177,7 @@ async function publishText(deps, context, piece, answer) {
|
|
|
175
177
|
: [];
|
|
176
178
|
const title = titles[Number(piece.key.split(":").at(-1)) - 1];
|
|
177
179
|
if (typeof title !== "string")
|
|
178
|
-
throw new Error("
|
|
180
|
+
throw new Error("Slopify hit an internal error (a research chapter has no title in the research plan). Use Retry stage; if it happens again, use Download diagnostics in Settings and report it.");
|
|
179
181
|
const asset = writeAsset(deps, context.work.projectId, `research-${piece.key.split(":").at(-1)}.md`, Buffer.from(answer.text));
|
|
180
182
|
await publishResult(deps, context, piece, [], { title, notes: answer.text }, asset);
|
|
181
183
|
return;
|
|
@@ -29,7 +29,7 @@ export function preparedResult(deps, context, piece, role, asset, durationMs = n
|
|
|
29
29
|
export function preparedText(deps, context, piece, role, filename, text) {
|
|
30
30
|
const output = preparedTexts(deps, context, piece, [[role, filename, text]])[0];
|
|
31
31
|
if (output === undefined)
|
|
32
|
-
throw new Error("
|
|
32
|
+
throw new Error("Slopify hit an internal error (a text file could not be prepared). Retry stage; if it happens again, use Download diagnostics in Settings and report it.");
|
|
33
33
|
return output;
|
|
34
34
|
}
|
|
35
35
|
export function preparedTexts(deps, context, piece, texts) {
|
|
@@ -168,10 +168,10 @@ export function retainPartialArticle(deps, context, piece, text) {
|
|
|
168
168
|
if (authority === undefined)
|
|
169
169
|
return;
|
|
170
170
|
if (authority.key !== piece.key || authority.fingerprint !== piece.fingerprint)
|
|
171
|
-
throw new Error("
|
|
171
|
+
throw new Error("Slopify hit an internal error (a partly written article doesn't match its saved step). Retry stage; if it happens again, use Download diagnostics in Settings and report it.");
|
|
172
172
|
const revision = revisionById(deps.db, context.work.projectId, context.work.revisionId);
|
|
173
173
|
if (revision === undefined)
|
|
174
|
-
throw new Error("
|
|
174
|
+
throw new Error("Slopify hit an internal error (the project version for a partly written article is missing). Retry stage; if it happens again, use Download diagnostics in Settings and report it.");
|
|
175
175
|
insertAsset(deps.db, result.asset);
|
|
176
176
|
insertManifestOutput(deps.db, revision, {
|
|
177
177
|
slot: `article:partial:${piece.id}`,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { executeExportRecipe } from "./runtime-export.js";
|
|
2
2
|
import { executeLocalRecipe } from "./runtime-local.js";
|
|
3
|
+
import { pieceLabel } from "./runtime-piece-label.js";
|
|
3
4
|
import { executeProviderRecipe } from "./runtime-provider.js";
|
|
4
5
|
import { executeSubtitleRecipe } from "./runtime-subtitles.js";
|
|
5
6
|
import { workPieces } from "./work-records.js";
|
|
@@ -25,7 +26,16 @@ export async function runRevisionInvocation(deps, context, providers) {
|
|
|
25
26
|
deps.db
|
|
26
27
|
.prepare("UPDATE revision_work_pieces SET state=? WHERE id=? AND work_id=? AND state!='done'")
|
|
27
28
|
.run(context.signal.aborted ? "pending" : "failed", piece.id, context.work.workId);
|
|
28
|
-
|
|
29
|
+
if (context.signal.aborted || !(error instanceof Error))
|
|
30
|
+
throw error;
|
|
31
|
+
let label;
|
|
32
|
+
try {
|
|
33
|
+
label = pieceLabel(deps, context, piece);
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
// The error itself matters more than its label.
|
|
37
|
+
}
|
|
38
|
+
throw label === undefined ? error : new Error(`${label}: ${error.message}`, { cause: error });
|
|
29
39
|
}
|
|
30
40
|
}
|
|
31
41
|
deps.db
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { subtitleModelDir } from "../../kernel/paths.js";
|
|
4
|
+
import { SubtitleMismatch } from "../../kernel/ports/subtitles.js";
|
|
4
5
|
import { resolveFont } from "../fonts/index.js";
|
|
5
6
|
import { validateCues } from "../revisions/rules.js";
|
|
6
7
|
import { discardPreparedAssets, writeAsset } from "../storage/assets.js";
|
|
7
8
|
import { outputPath } from "../storage/layout.js";
|
|
8
9
|
import { captionCues, serializeAss, serializeSrt, serializeVtt } from "../subtitles/captions.js";
|
|
9
10
|
import { exportSnapshot, retainedOutput, revisionAudio, revisionTranscript, } from "./runtime-export-inputs.js";
|
|
11
|
+
import { narrationChunks, narrationTextParts, } from "./runtime-narration-text.js";
|
|
10
12
|
import { preparedResult, preparedText, publishResult } from "./runtime-publication.js";
|
|
11
13
|
const wordsSchema = z.object({
|
|
12
14
|
key: z.string(),
|
|
@@ -39,14 +41,15 @@ export async function executeSubtitleRecipe(deps, context, piece) {
|
|
|
39
41
|
return cues(deps, context, piece, snapshot);
|
|
40
42
|
if (piece.key === "subtitles:files")
|
|
41
43
|
return files(deps, context, piece, snapshot);
|
|
42
|
-
throw new Error("
|
|
44
|
+
throw new Error("Slopify hit an internal error (unknown kind of caption step). Retry stage; if it happens again, use Download diagnostics in Settings and report it.");
|
|
43
45
|
}
|
|
44
46
|
async function timing(deps, context, piece, snapshot) {
|
|
45
47
|
const audio = await revisionAudio(deps, context, snapshot.view);
|
|
46
48
|
if (audio.length === 0)
|
|
47
|
-
throw new Error("
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
throw new Error("Captions need narration audio, but this project has none. Turn captions off in Edit project → Subtitles, or turn narration on, then Retry stage.");
|
|
50
|
+
const alignSubtitles = deps.alignSubtitles;
|
|
51
|
+
if (alignSubtitles === undefined)
|
|
52
|
+
throw new Error("Slopify hit an internal error (the caption timing tool is missing from this build). Retry stage; if it happens again, use Download diagnostics in Settings and report it.");
|
|
50
53
|
if (!context.maySubmit(piece.id))
|
|
51
54
|
return "held";
|
|
52
55
|
const words = [];
|
|
@@ -55,10 +58,11 @@ async function timing(deps, context, piece, snapshot) {
|
|
|
55
58
|
const total = audio.reduce((sum, segment) => sum + segment.seconds, 0);
|
|
56
59
|
for (const segment of audio) {
|
|
57
60
|
context.signal.throwIfAborted();
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
61
|
+
const { path, kind } = segment;
|
|
62
|
+
if (path !== null && kind !== "gap") {
|
|
63
|
+
const aligned = await located(snapshot, kind, () => alignSubtitles({
|
|
64
|
+
audioPath: path,
|
|
65
|
+
text: revisionTranscript(deps, snapshot, kind),
|
|
62
66
|
cacheDir: subtitleModelDir(deps.paths.dataDir),
|
|
63
67
|
ffmpeg: deps.ffmpeg,
|
|
64
68
|
signal: context.signal,
|
|
@@ -70,10 +74,10 @@ async function timing(deps, context, piece, snapshot) {
|
|
|
70
74
|
current: Math.round((100 * (offset + segment.seconds * (maximum > 0 ? current / maximum : 0))) / total),
|
|
71
75
|
total: 100,
|
|
72
76
|
}),
|
|
73
|
-
});
|
|
77
|
+
}));
|
|
74
78
|
for (const word of aligned) {
|
|
75
79
|
if (word.end > segment.seconds + 0.1)
|
|
76
|
-
throw new Error("
|
|
80
|
+
throw new Error("Caption timing came out longer than the narration audio. Retry stage; if it happens again, use Download diagnostics in Settings and report it.");
|
|
77
81
|
words.push({
|
|
78
82
|
...word,
|
|
79
83
|
start: word.start + offset,
|
|
@@ -84,7 +88,7 @@ async function timing(deps, context, piece, snapshot) {
|
|
|
84
88
|
offset += segment.seconds;
|
|
85
89
|
}
|
|
86
90
|
if (captionCues(words).length === 0)
|
|
87
|
-
throw new Error("
|
|
91
|
+
throw new Error("None of the narration could be matched to the article text, so captions can't be timed. Captions only work for English narration; if you uploaded your own audio, make sure it reads the article text, then Retry stage.");
|
|
88
92
|
context.signal.throwIfAborted();
|
|
89
93
|
const output = preparedText(deps, context, piece, "subtitle_words", "subtitles.json", JSON.stringify({ key: piece.logicalFingerprint ?? piece.fingerprint, words, omissions }));
|
|
90
94
|
await publishResult(deps, context, piece, [output], { words, omissions }, output.asset);
|
|
@@ -96,7 +100,7 @@ async function cues(deps, context, piece, snapshot) {
|
|
|
96
100
|
let value;
|
|
97
101
|
if (manual !== undefined) {
|
|
98
102
|
if (plan.work.find((one) => one.key === piece.key)?.disposition === "review")
|
|
99
|
-
throw new Error("
|
|
103
|
+
throw new Error("Your edited captions were written for an older version of the narration. Review them in Edit project → Captions and save, then Retry stage.");
|
|
100
104
|
const audio = await revisionAudio(deps, context, view);
|
|
101
105
|
const errors = validateCues(manual.cues, audio.reduce((sum, segment) => sum + segment.seconds, 0));
|
|
102
106
|
if (errors.length > 0)
|
|
@@ -109,7 +113,7 @@ async function cues(deps, context, piece, snapshot) {
|
|
|
109
113
|
one.state === "ready" &&
|
|
110
114
|
one.workKey === "subtitles:timing");
|
|
111
115
|
if (output === undefined)
|
|
112
|
-
throw new Error("
|
|
116
|
+
throw new Error("Caption timing is missing. Use Re-run section on Video, then Retry stage.");
|
|
113
117
|
const timed = wordsSchema.parse(JSON.parse(readFileSync(outputPath(deps.paths, context.work.projectId, output.output.path), "utf8")));
|
|
114
118
|
value = { cues: [...captionCues(timed.words)], omissions: timed.omissions };
|
|
115
119
|
}
|
|
@@ -123,10 +127,10 @@ async function files(deps, context, piece, snapshot) {
|
|
|
123
127
|
const { view } = snapshot;
|
|
124
128
|
const config = view.revision.config.subtitles;
|
|
125
129
|
if (config === undefined || config.mode === "off")
|
|
126
|
-
throw new Error("
|
|
130
|
+
throw new Error("Slopify hit an internal error (captions are off for this version of the project). Retry stage; if it happens again, use Download diagnostics in Settings and report it.");
|
|
127
131
|
const row = view.pieces.find((one) => one.key === "subtitles:cues" && one.selected && one.available && one.piece.state === "done");
|
|
128
132
|
if (row?.piece.payload === null || row?.piece.payload === undefined)
|
|
129
|
-
throw new Error("The
|
|
133
|
+
throw new Error("The captions haven't been prepared yet. Use Re-run section on Video, then Retry stage.");
|
|
130
134
|
const value = cuesSchema.parse(JSON.parse(row.piece.payload));
|
|
131
135
|
const previous = view.outputs.find((one) => one.output.role === "subtitle_font" && one.selected && one.available);
|
|
132
136
|
const previousFiles = view.pieces.find((one) => one.key === "subtitles:files" &&
|
|
@@ -200,3 +204,62 @@ async function files(deps, context, piece, snapshot) {
|
|
|
200
204
|
discardPreparedAssets(deps, prepared.map((one) => one.asset));
|
|
201
205
|
}
|
|
202
206
|
}
|
|
207
|
+
// A mismatch names the place to fix: the time in the narration, the chunk that holds it (as
|
|
208
|
+
// the Narration editor numbers them) and what was expected against what was heard. The
|
|
209
|
+
// usual cause is a TTS request that skipped or reworded a sentence.
|
|
210
|
+
async function located(snapshot, segment, align) {
|
|
211
|
+
try {
|
|
212
|
+
return await align();
|
|
213
|
+
}
|
|
214
|
+
catch (error) {
|
|
215
|
+
if (!(error instanceof SubtitleMismatch))
|
|
216
|
+
throw error;
|
|
217
|
+
throw new Error(mismatchMessage(snapshot, segment, error), { cause: error });
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
export function mismatchMessage(snapshot, segment, mismatch) {
|
|
221
|
+
let chunks = [];
|
|
222
|
+
try {
|
|
223
|
+
chunks = narrationChunks(narrationTextParts(snapshot.view, snapshot.plan, segment));
|
|
224
|
+
}
|
|
225
|
+
catch {
|
|
226
|
+
// Without a readable plan the message still gives the time and the words.
|
|
227
|
+
}
|
|
228
|
+
return describeMismatch(chunks, segment, mismatch);
|
|
229
|
+
}
|
|
230
|
+
export function describeMismatch(chunks, segment, mismatch) {
|
|
231
|
+
const probe = comparable(mismatch.expected).split(" ").slice(0, 6).join(" ");
|
|
232
|
+
const at = probe === ""
|
|
233
|
+
? chunks.length - 1
|
|
234
|
+
: chunks.findIndex((chunk) => comparable(chunk.spokenText).includes(probe));
|
|
235
|
+
const chunk = at === -1 ? undefined : chunks[at];
|
|
236
|
+
const where = chunk === undefined
|
|
237
|
+
? `${clock(mismatch.at)} into the ${segment} narration`
|
|
238
|
+
: `${clock(mismatch.at)} into the ${segment} narration, in narration chunk ${String(at + 1)} of ${String(chunks.length)} (it starts "${opening(chunk.spokenText)}")`;
|
|
239
|
+
const expected = mismatch.expected === "" ? "the end of the text" : `"${mismatch.expected}…"`;
|
|
240
|
+
const heard = mismatch.heard === "" ? "no more speech" : `"${mismatch.heard.toLowerCase()}…"`;
|
|
241
|
+
const fix = chunk === undefined
|
|
242
|
+
? "Check that part of the narration, regenerate it in Edit project → Narration, then Resume."
|
|
243
|
+
: `In Edit project → Narration, regenerate narration chunk ${String(at + 1)}, then Resume.`;
|
|
244
|
+
return `Subtitles stopped matching the audio at ${where}. The text expected ${expected} but the audio has ${heard} The recording there probably skips or changes words. ${fix}`;
|
|
245
|
+
}
|
|
246
|
+
function comparable(text) {
|
|
247
|
+
return text
|
|
248
|
+
.toUpperCase()
|
|
249
|
+
.replace(/&/g, " AND ")
|
|
250
|
+
.replace(/[^A-Z0-9' ]+/g, " ")
|
|
251
|
+
.replace(/\s+/g, " ")
|
|
252
|
+
.trim();
|
|
253
|
+
}
|
|
254
|
+
function opening(text) {
|
|
255
|
+
return text.trim().split(/\s+/).slice(0, 6).join(" ");
|
|
256
|
+
}
|
|
257
|
+
function clock(seconds) {
|
|
258
|
+
const whole = Math.floor(seconds);
|
|
259
|
+
const hours = Math.floor(whole / 3600);
|
|
260
|
+
const minutes = Math.floor((whole % 3600) / 60);
|
|
261
|
+
const rest = String(whole % 60).padStart(2, "0");
|
|
262
|
+
return hours > 0
|
|
263
|
+
? `${String(hours)}:${String(minutes).padStart(2, "0")}:${rest}`
|
|
264
|
+
: `${String(minutes)}:${rest}`;
|
|
265
|
+
}
|
|
@@ -15,14 +15,14 @@ export function transitionRevisionWork(deps, input) {
|
|
|
15
15
|
transact(db, () => {
|
|
16
16
|
const current = currentRevisionId(db, input.projectId);
|
|
17
17
|
if (current !== input.baseRevisionId && current !== input.revisionId)
|
|
18
|
-
throw new Error("
|
|
18
|
+
throw new Error("The project was changed while this was being saved. Try again.");
|
|
19
19
|
const base = revisionById(db, input.projectId, input.baseRevisionId);
|
|
20
20
|
const next = revisionById(db, input.projectId, input.revisionId);
|
|
21
21
|
if (base === undefined || next === undefined)
|
|
22
|
-
throw new Error("
|
|
22
|
+
throw new Error("Slopify hit an internal error (a project version to switch between is missing). Try again; if it happens again, use Download diagnostics in Settings and report it.");
|
|
23
23
|
if (JSON.stringify(Object.entries(input.fingerprints).sort()) !==
|
|
24
24
|
JSON.stringify(Object.entries(next.fingerprints).sort()))
|
|
25
|
-
throw new Error("
|
|
25
|
+
throw new Error("Slopify hit an internal error (the planned steps don't match the saved project version). Try again; if it happens again, use Download diagnostics in Settings and report it.");
|
|
26
26
|
const reserved = db
|
|
27
27
|
.prepare(`SELECT r.* FROM revision_work_reservations r JOIN revision_work w ON w.id=r.work_id WHERE r.project_id=? AND r.revision_id=? AND w.state IN ('pending','running','done')`)
|
|
28
28
|
.all(input.projectId, input.baseRevisionId)
|
|
@@ -57,13 +57,13 @@ export function transitionRevisionWork(deps, input) {
|
|
|
57
57
|
continue;
|
|
58
58
|
const exact = input.recipes?.find((row) => row.key === key);
|
|
59
59
|
if (exact !== undefined && exact.fingerprint !== fp)
|
|
60
|
-
throw new Error("
|
|
60
|
+
throw new Error("Slopify hit an internal error (a planned step doesn't match the saved project version). Try again; if it happens again, use Download diagnostics in Settings and report it.");
|
|
61
61
|
const kind = exact?.stage ?? stageForKey(key);
|
|
62
62
|
const stage = db
|
|
63
63
|
.prepare("SELECT id FROM stages WHERE project_id=? AND kind=?")
|
|
64
64
|
.get(input.projectId, kind);
|
|
65
65
|
if (stage === undefined)
|
|
66
|
-
throw new Error("
|
|
66
|
+
throw new Error("Slopify hit an internal error (a planned step has no matching stage). Try again; if it happens again, use Download diagnostics in Settings and report it.");
|
|
67
67
|
const workId = deps.ids.next();
|
|
68
68
|
const pieceId = deps.ids.next();
|
|
69
69
|
db.prepare(`INSERT INTO revision_work(id,project_id,revision_id,stage_id,kind,fingerprint,state,dispatch_state,created_at) VALUES (?,?,?,?,?,?,'pending','held',?)`).run(workId, input.projectId, input.revisionId, z.string().parse(stage.id), kind, fp, deps.clock.now().toISOString());
|
|
@@ -104,5 +104,5 @@ function stageForKey(key) {
|
|
|
104
104
|
return "thumbnail";
|
|
105
105
|
if (prefix === "export" || prefix === "subtitles" || prefix === "video")
|
|
106
106
|
return "video";
|
|
107
|
-
throw new Error("
|
|
107
|
+
throw new Error("Slopify hit an internal error (unknown kind of step). Try again; if it happens again, use Download diagnostics in Settings and report it.");
|
|
108
108
|
}
|
|
@@ -204,7 +204,7 @@ function clearStage(deps, stage, outputs) {
|
|
|
204
204
|
// runs the returned cleanup only after commit. Finished narration is left intact.
|
|
205
205
|
export function clearUnfinishedAudio(deps, projectId) {
|
|
206
206
|
if (currentRevisionId(deps.db, projectId) !== undefined)
|
|
207
|
-
throw new Error("
|
|
207
|
+
throw new Error("Slopify hit an internal error (narration was changed the old way on a project that uses versions). Try again; if it happens again, use Download diagnostics in Settings and report it.");
|
|
208
208
|
const stage = stagesOf(deps.db, projectId).find((one) => one.kind === "audio");
|
|
209
209
|
if (stage === undefined ||
|
|
210
210
|
stage.state === "done" ||
|
|
@@ -10,7 +10,7 @@ import { chaptersFrom, plannerMessages, subAgentMessages } from "./planner.js";
|
|
|
10
10
|
import { sourcedAnswer, synthesisMessages } from "./synthesis.js";
|
|
11
11
|
// A model that cannot ground on the web fails the stage immediately, with no fallback to
|
|
12
12
|
// what the model already knows.
|
|
13
|
-
export const webResearchUnsupported = "web research
|
|
13
|
+
export const webResearchUnsupported = "The chosen AI model can't search the web, which research needs. Choose a model with web search in Edit project → Providers, or turn research off, then Retry stage.";
|
|
14
14
|
// What a chapter piece carries between runs: its title, and its notes once a sub-agent
|
|
15
15
|
// has answered. That is the whole of the resume.
|
|
16
16
|
const chapterPayload = z.object({ title: z.string(), notes: z.string().optional() });
|
|
@@ -18,14 +18,14 @@ export async function runResearch(deps, context, providers) {
|
|
|
18
18
|
const { projectId } = context.stage;
|
|
19
19
|
const project = projectById(deps.db, projectId);
|
|
20
20
|
if (project === undefined) {
|
|
21
|
-
throw new Error(
|
|
21
|
+
throw new Error("This project no longer exists; it may have been deleted while it was running.");
|
|
22
22
|
}
|
|
23
23
|
const choice = project.config.llm;
|
|
24
24
|
const articlePrompt = project.config.rendered.article;
|
|
25
25
|
if (choice === undefined || articlePrompt === undefined) {
|
|
26
26
|
// Admission refuses a run whose research is Generate without both, so
|
|
27
27
|
// reaching here is a bug in admission rather than something the user did.
|
|
28
|
-
throw new Error("
|
|
28
|
+
throw new Error("No AI model or article prompt is set for research. Choose a model in Edit project → Providers and check Edit project → Prompts, then Retry stage.");
|
|
29
29
|
}
|
|
30
30
|
const brief = { articlePrompt, values: project.config.values };
|
|
31
31
|
try {
|
|
@@ -62,7 +62,7 @@ async function research(deps, context, providers, choice, brief) {
|
|
|
62
62
|
messages: synthesisMessages(brief, findings),
|
|
63
63
|
documents: researchDocuments(findings),
|
|
64
64
|
previewLabel: "Writing research notes",
|
|
65
|
-
check: (given) => sourcedAnswer("the
|
|
65
|
+
check: (given) => sourcedAnswer("the research summary", given.text),
|
|
66
66
|
});
|
|
67
67
|
if (!answer.ok)
|
|
68
68
|
return "held";
|
|
@@ -110,7 +110,9 @@ async function plan(deps, context, providers, choice, brief, add) {
|
|
|
110
110
|
messages: plannerMessages(brief),
|
|
111
111
|
previewLabel: "Planning research",
|
|
112
112
|
// An empty answer, or one with no chapter in it, is a failed attempt.
|
|
113
|
-
check: (given) => chaptersFrom(given.text).length === 0
|
|
113
|
+
check: (given) => chaptersFrom(given.text).length === 0
|
|
114
|
+
? "The AI model didn't return any research topics. Retry stage; if it keeps happening, choose a different model in Edit project → Providers."
|
|
115
|
+
: undefined,
|
|
114
116
|
});
|
|
115
117
|
if (!answer.ok)
|
|
116
118
|
return answer;
|
|
@@ -156,7 +158,7 @@ async function researchChapters(deps, context, providers, choice, brief, chapter
|
|
|
156
158
|
// Grounding is asked for explicitly, so a model without it says so
|
|
157
159
|
// instead of answering from what it already knows.
|
|
158
160
|
webSearch: true,
|
|
159
|
-
check: (given) => sourcedAnswer(`the
|
|
161
|
+
check: (given) => sourcedAnswer(`the research topic "${kept.title}"`, given.text),
|
|
160
162
|
});
|
|
161
163
|
if (!answer.ok) {
|
|
162
164
|
setPiece(deps.db, piece.id, "pending", piece.payload);
|
|
@@ -215,7 +217,7 @@ function section(label, messages) {
|
|
|
215
217
|
}
|
|
216
218
|
function payloadOf(piece) {
|
|
217
219
|
if (piece.payload === null) {
|
|
218
|
-
throw new Error(
|
|
220
|
+
throw new Error("Slopify hit an internal error (a saved research topic is empty). Retry stage; if it happens again, use Download diagnostics in Settings and report it.");
|
|
219
221
|
}
|
|
220
222
|
return chapterPayload.parse(JSON.parse(piece.payload));
|
|
221
223
|
}
|
|
@@ -41,7 +41,9 @@ export function endsWithSources(text) {
|
|
|
41
41
|
// but cannot be used is a failed attempt, so the wrapper retries it.
|
|
42
42
|
export function sourcedAnswer(who, text) {
|
|
43
43
|
if (text.trim() === "") {
|
|
44
|
-
return
|
|
44
|
+
return `The AI model returned an empty answer for ${who}. Retry stage; if it keeps happening, choose a different model in Edit project → Providers.`;
|
|
45
45
|
}
|
|
46
|
-
return endsWithSources(text)
|
|
46
|
+
return endsWithSources(text)
|
|
47
|
+
? undefined
|
|
48
|
+
: `The AI model's answer for ${who} had no sources. Research needs web sources: Retry stage, or choose a model with web search in Edit project → Providers.`;
|
|
47
49
|
}
|
|
@@ -34,11 +34,14 @@ export function validateUploads(deps, edit) {
|
|
|
34
34
|
(to.kind === "image" && edit.config.sources.images === "off"))
|
|
35
35
|
fields.push({
|
|
36
36
|
field,
|
|
37
|
-
message: "
|
|
37
|
+
message: "This section is off or not set to use your own file. Change the section's setting first, then add the file.",
|
|
38
38
|
});
|
|
39
39
|
const destination = JSON.stringify(to);
|
|
40
40
|
if (staged.has(upload.stagedFileId) || destinations.has(destination))
|
|
41
|
-
fields.push({
|
|
41
|
+
fields.push({
|
|
42
|
+
field,
|
|
43
|
+
message: "The same file or place is used twice. Remove the duplicate.",
|
|
44
|
+
});
|
|
42
45
|
staged.add(upload.stagedFileId);
|
|
43
46
|
destinations.add(destination);
|
|
44
47
|
const file = stagedFileById(deps.db, upload.stagedFileId);
|
|
@@ -47,11 +50,20 @@ export function validateUploads(deps, edit) {
|
|
|
47
50
|
file.state !== "staged" ||
|
|
48
51
|
file.stageKind !== kind ||
|
|
49
52
|
!statSync(stagingPath(deps.paths, file.path), { throwIfNoEntry: false })?.isFile())
|
|
50
|
-
fields.push({
|
|
53
|
+
fields.push({
|
|
54
|
+
field,
|
|
55
|
+
message: "This upload is missing or has not finished. Upload the file again.",
|
|
56
|
+
});
|
|
51
57
|
if (to.kind === "image" && edit.content.imageDefinitions[to.imageKey] === undefined)
|
|
52
|
-
fields.push({
|
|
58
|
+
fields.push({
|
|
59
|
+
field,
|
|
60
|
+
message: "This image is no longer in the project. Reload the page and choose again.",
|
|
61
|
+
});
|
|
53
62
|
if (to.kind === "narration" && !to.key.startsWith("audio:"))
|
|
54
|
-
fields.push({
|
|
63
|
+
fields.push({
|
|
64
|
+
field,
|
|
65
|
+
message: "Choose which part of the narration this audio file replaces.",
|
|
66
|
+
});
|
|
55
67
|
}
|
|
56
68
|
return fields;
|
|
57
69
|
}
|
|
@@ -81,7 +93,10 @@ export function validateAssetReferences(deps, projectId, content, prepared) {
|
|
|
81
93
|
deps.db
|
|
82
94
|
.prepare("SELECT 1 FROM project_assets WHERE project_id=? AND id=?")
|
|
83
95
|
.get(projectId, id) === undefined)
|
|
84
|
-
fields.push({
|
|
96
|
+
fields.push({
|
|
97
|
+
field,
|
|
98
|
+
message: "This file does not belong to this project. Reload the page and choose again.",
|
|
99
|
+
});
|
|
85
100
|
if (!prepared.some((row) => row.id === id) &&
|
|
86
101
|
deps.db
|
|
87
102
|
.prepare("SELECT 1 FROM revision_outputs WHERE project_id=? AND asset_id=? AND json_extract(descriptor,'$.stageKind')=? AND json_extract(descriptor,'$.role') IN (SELECT value FROM json_each(?))")
|
|
@@ -95,7 +110,10 @@ export function validateAssetReferences(deps, projectId, content, prepared) {
|
|
|
95
110
|
deps.db
|
|
96
111
|
.prepare("SELECT 1 FROM project_revisions r, json_each(r.content, '$.narrationOverrides') o WHERE r.project_id=? AND json_extract(o.value,'$.kind')='asset' AND json_extract(o.value,'$.assetId')=? LIMIT 1")
|
|
97
112
|
.get(projectId, id) !== undefined))
|
|
98
|
-
fields.push({
|
|
113
|
+
fields.push({
|
|
114
|
+
field,
|
|
115
|
+
message: "This file cannot be used in this section. Choose a file of the right kind.",
|
|
116
|
+
});
|
|
99
117
|
}
|
|
100
118
|
return fields;
|
|
101
119
|
}
|
|
@@ -144,5 +162,5 @@ export function validateReplacementAvailability(deps, base, edit) {
|
|
|
144
162
|
previous.has(id) ||
|
|
145
163
|
statSync(outputPath(deps.paths, base.revision.projectId, assetPath(deps, base.revision.projectId, id)), { throwIfNoEntry: false })?.isFile()
|
|
146
164
|
? []
|
|
147
|
-
: [{ field: "content", message: "The replacement
|
|
165
|
+
: [{ field: "content", message: "The replacement file is missing. Upload it again." }]);
|
|
148
166
|
}
|
|
@@ -34,7 +34,7 @@ export function validateProposedCues(base, edit, plan, prepared, durations) {
|
|
|
34
34
|
const fail = () => [
|
|
35
35
|
{
|
|
36
36
|
field: "content.subtitleCues",
|
|
37
|
-
message: "
|
|
37
|
+
message: "The narration changed or is not finished, so these captions no longer line up. Reload the page and edit the captions again once narration is complete.",
|
|
38
38
|
},
|
|
39
39
|
];
|
|
40
40
|
const candidates = [
|