@gentbajko/slopify 0.5.1 → 0.7.0
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 +36 -1
- package/SUBTITLES.md +21 -0
- package/dist/adapter-registry.js +18 -3
- package/dist/adapters/alignment/audio.js +45 -0
- package/dist/adapters/alignment/cache.js +91 -0
- package/dist/adapters/alignment/ctc.js +128 -0
- package/dist/adapters/alignment/index.js +34 -0
- package/dist/adapters/alignment/lock.js +58 -0
- package/dist/adapters/alignment/numbers.js +91 -0
- package/dist/adapters/alignment/protocol.js +23 -0
- package/dist/adapters/alignment/quality.js +17 -0
- package/dist/adapters/alignment/runner.js +76 -0
- package/dist/adapters/alignment/text.js +61 -0
- package/dist/adapters/alignment/vocabulary.js +69 -0
- package/dist/adapters/alignment/worker.js +163 -0
- package/dist/adapters/image/google.js +12 -15
- package/dist/adapters/image/models.js +72 -0
- package/dist/adapters/image/openai.js +3 -5
- package/dist/adapters/llm/catalogue-files.js +23 -0
- package/dist/adapters/llm/claude-code.js +9 -7
- package/dist/adapters/llm/codex-models.js +46 -0
- package/dist/adapters/llm/codex.js +7 -12
- package/dist/adapters/llm/gemini-models.js +85 -0
- package/dist/adapters/llm/gemini-workspace.js +70 -0
- package/dist/adapters/llm/gemini.js +138 -0
- package/dist/adapters/llm/openrouter.js +11 -2
- package/dist/adapters/llm/run-cli.js +6 -9
- package/dist/adapters/tts/cartesia.js +9 -1
- package/dist/adapters/tts/elevenlabs.js +33 -2
- package/dist/adapters/tts/inworld-async.js +150 -0
- package/dist/adapters/tts/inworld-text.js +32 -0
- package/dist/adapters/tts/inworld.js +170 -0
- package/dist/adapters/tts/openai.js +31 -4
- package/dist/assets/fonts/Barlow-Regular.ttf +0 -0
- package/dist/assets/fonts/OFL.txt +93 -0
- package/dist/assets/fonts/SOURCE.txt +7 -0
- package/dist/edge/cli.js +5 -0
- package/dist/edge/events/hub.js +9 -2
- package/dist/edge/events/preview-cache.js +40 -0
- package/dist/edge/http/actions.js +2 -0
- package/dist/edge/http/app.js +30 -1
- package/dist/edge/http/audio-preview.js +46 -0
- package/dist/edge/http/fonts.js +147 -0
- package/dist/edge/http/projects.js +23 -1
- package/dist/edge/http/providers.js +29 -0
- package/dist/edge/http/subtitles.js +92 -0
- package/dist/edge/http/update.js +57 -0
- package/dist/edge/update-worker.js +44 -0
- package/dist/kernel/audio-preview.js +188 -0
- package/dist/kernel/cli-command.js +45 -0
- package/dist/kernel/ports/subtitles.js +1 -0
- package/dist/kernel/runner/providers.js +75 -24
- package/dist/main.js +106 -25
- package/dist/model-catalog.js +37 -0
- package/dist/slices/admission/repo.js +2 -0
- package/dist/slices/admission/rules.js +6 -0
- package/dist/slices/control/index.js +1 -0
- package/dist/slices/control/providers.js +2 -0
- package/dist/slices/fonts/catalog.js +95 -0
- package/dist/slices/fonts/discovery.js +81 -0
- package/dist/slices/fonts/files.js +37 -0
- package/dist/slices/fonts/index.js +5 -0
- package/dist/slices/fonts/model.js +4 -0
- package/dist/slices/fonts/preview.js +14 -0
- package/dist/slices/fonts/sfnt.js +262 -0
- package/dist/slices/fonts/upload.js +40 -0
- package/dist/slices/narration/live.js +21 -0
- package/dist/slices/narration/run.js +9 -9
- package/dist/slices/research/run.js +3 -0
- package/dist/slices/settings/cli-paths.js +98 -0
- package/dist/slices/settings/cli-status.js +21 -12
- package/dist/slices/settings/model.js +11 -0
- package/dist/slices/settings/models.js +89 -0
- package/dist/slices/settings/readiness.js +13 -9
- package/dist/slices/storage/downloads.js +2 -0
- package/dist/slices/storage/layout.js +10 -0
- package/dist/slices/storage/model.js +5 -0
- package/dist/slices/storage/repo.js +1 -0
- package/dist/slices/subtitles/captions.js +91 -0
- package/dist/slices/subtitles/layout.js +19 -0
- package/dist/slices/subtitles/model.js +27 -0
- package/dist/slices/subtitles/prepare.js +167 -0
- package/dist/slices/subtitles/transcript.js +34 -0
- package/dist/slices/video/audio-export.js +3 -0
- package/dist/slices/video/ffmpeg.js +14 -7
- package/dist/slices/video/plan.js +4 -4
- package/dist/slices/video/run.js +5 -2
- package/dist/slices/video/write-export.js +85 -20
- package/dist/updater/candidate.js +28 -0
- package/dist/updater/forward.js +35 -0
- package/dist/updater/install-flow.js +26 -0
- package/dist/updater/install.js +50 -0
- package/dist/updater/model.js +24 -0
- package/dist/updater/plan.js +135 -0
- package/dist/updater/readiness.js +15 -0
- package/dist/updater/registry.js +19 -0
- package/dist/updater/service.js +128 -0
- package/dist/updater/worker.js +136 -0
- package/dist/web/assets/index-6QIQ-TzO.css +1 -0
- package/dist/web/assets/index-CNgWL-ct.js +130 -0
- package/dist/web/index.html +2 -2
- package/package.json +4 -2
- package/dist/web/assets/index-C1fsrIP5.css +0 -1
- package/dist/web/assets/index-DwJ_XTl3.js +0 -81
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Inworld's streaming endpoint accepts 4,000 characters. Split inside the
|
|
2
|
+
// adapter so whole-text narration and long intros/outros all remain usable.
|
|
3
|
+
// UTF-16 length is conservative for Unicode; never cut a surrogate pair.
|
|
4
|
+
export function inworldTextParts(text) {
|
|
5
|
+
const parts = [];
|
|
6
|
+
let current = "";
|
|
7
|
+
for (const sentence of new Intl.Segmenter("en", { granularity: "sentence" }).segment(text)) {
|
|
8
|
+
if (current.length + sentence.segment.length <= 4000) {
|
|
9
|
+
current += sentence.segment;
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
if (current.trim())
|
|
13
|
+
parts.push(current.trim());
|
|
14
|
+
let remaining = sentence.segment;
|
|
15
|
+
while (remaining.length > 4000) {
|
|
16
|
+
const window = remaining.slice(0, 4000);
|
|
17
|
+
const boundary = Math.max(window.lastIndexOf(" "), window.lastIndexOf("\n"), window.lastIndexOf("\t"));
|
|
18
|
+
let cut = boundary > 0 ? boundary : 4000;
|
|
19
|
+
const last = remaining.charCodeAt(cut - 1);
|
|
20
|
+
if (last >= 0xd800 && last <= 0xdbff)
|
|
21
|
+
cut--;
|
|
22
|
+
const piece = remaining.slice(0, cut).trim();
|
|
23
|
+
if (piece)
|
|
24
|
+
parts.push(piece);
|
|
25
|
+
remaining = remaining.slice(cut).trimStart();
|
|
26
|
+
}
|
|
27
|
+
current = remaining;
|
|
28
|
+
}
|
|
29
|
+
if (current.trim())
|
|
30
|
+
parts.push(current.trim());
|
|
31
|
+
return parts;
|
|
32
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { redact } from "../../kernel/log.js";
|
|
3
|
+
import { providerError } from "../../kernel/ports/model.js";
|
|
4
|
+
import { retryAfter } from "../retry-after.js";
|
|
5
|
+
import { inworldAsync } from "./inworld-async.js";
|
|
6
|
+
import { inworldTextParts } from "./inworld-text.js";
|
|
7
|
+
export const inworldModels = [
|
|
8
|
+
{ id: "inworld-tts-2", name: "Realtime TTS-2" },
|
|
9
|
+
{ id: "inworld-tts-2-flash", name: "Realtime TTS-2 Flash" },
|
|
10
|
+
];
|
|
11
|
+
const envelope = z.object({
|
|
12
|
+
result: z.object({ audioContent: z.string().optional() }).optional(),
|
|
13
|
+
error: z.object({ code: z.number().optional(), message: z.string().optional() }).optional(),
|
|
14
|
+
});
|
|
15
|
+
export function inworldTts(deps) {
|
|
16
|
+
return {
|
|
17
|
+
id: "inworld",
|
|
18
|
+
capabilities: { streams: true },
|
|
19
|
+
models: async () => inworldModels,
|
|
20
|
+
synthesize: async (request) => {
|
|
21
|
+
const key = deps
|
|
22
|
+
.key()
|
|
23
|
+
?.trim()
|
|
24
|
+
.replace(/^Basic\s+/i, "");
|
|
25
|
+
if (!key)
|
|
26
|
+
throw providerError({ kind: "missing_key", message: "No Inworld API key is stored." });
|
|
27
|
+
const cancel = new AbortController();
|
|
28
|
+
const signal = AbortSignal.any([request.signal, cancel.signal]);
|
|
29
|
+
const iterator = synthesizeParts(deps, { ...request, signal }, key);
|
|
30
|
+
return {
|
|
31
|
+
container: "mp3",
|
|
32
|
+
audio: new ReadableStream({
|
|
33
|
+
async pull(controller) {
|
|
34
|
+
try {
|
|
35
|
+
const next = await iterator.next();
|
|
36
|
+
if (next.done)
|
|
37
|
+
controller.close();
|
|
38
|
+
else
|
|
39
|
+
controller.enqueue(next.value);
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
controller.error(error);
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
async cancel() {
|
|
46
|
+
cancel.abort();
|
|
47
|
+
await iterator.return();
|
|
48
|
+
},
|
|
49
|
+
}, { highWaterMark: 0 }),
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
async function* synthesizeParts(deps, request, key) {
|
|
55
|
+
if ((request.model ?? "inworld-tts-2") === "inworld-tts-2" && request.text.length > 4000) {
|
|
56
|
+
yield* inworldAsync(deps, request, key);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const parts = inworldTextParts(request.text);
|
|
60
|
+
if (parts.length === 0)
|
|
61
|
+
throw providerError({ kind: "unsupported", message: "Inworld needs text to narrate." });
|
|
62
|
+
for (const text of parts) {
|
|
63
|
+
request.signal.throwIfAborted();
|
|
64
|
+
const response = await deps.fetch("https://api.inworld.ai/tts/v1/voice:stream", {
|
|
65
|
+
method: "POST",
|
|
66
|
+
redirect: "error",
|
|
67
|
+
signal: request.signal,
|
|
68
|
+
headers: { Authorization: `Basic ${key}`, "Content-Type": "application/json" },
|
|
69
|
+
body: JSON.stringify({
|
|
70
|
+
text,
|
|
71
|
+
voiceId: request.voiceId,
|
|
72
|
+
modelId: request.model ?? "inworld-tts-2",
|
|
73
|
+
audioConfig: { audioEncoding: "MP3", sampleRateHertz: 48_000, bitRate: 128_000 },
|
|
74
|
+
}),
|
|
75
|
+
});
|
|
76
|
+
if (!response.ok) {
|
|
77
|
+
const detail = clean(await response.text().catch(() => ""), key);
|
|
78
|
+
const retryAfterMs = retryAfter(response.headers.get("retry-after"));
|
|
79
|
+
throw providerError({
|
|
80
|
+
kind: response.status === 401 || response.status === 403
|
|
81
|
+
? "auth"
|
|
82
|
+
: response.status === 429
|
|
83
|
+
? "rate_limit"
|
|
84
|
+
: response.status === 400 || response.status === 404
|
|
85
|
+
? "unsupported"
|
|
86
|
+
: "other",
|
|
87
|
+
message: clean(`Inworld answered ${response.status} for voice ${request.voiceId}: ${detail || response.statusText}`, key),
|
|
88
|
+
...(retryAfterMs === undefined ? {} : { retryAfterMs }),
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
if (response.body === null)
|
|
92
|
+
throw invalid("answered with no audio");
|
|
93
|
+
let heard = false;
|
|
94
|
+
for await (const line of lines(response.body)) {
|
|
95
|
+
request.signal.throwIfAborted();
|
|
96
|
+
let raw;
|
|
97
|
+
try {
|
|
98
|
+
raw = JSON.parse(line);
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
throw invalid("sent an unreadable audio chunk");
|
|
102
|
+
}
|
|
103
|
+
const parsed = envelope.safeParse(raw);
|
|
104
|
+
if (!parsed.success || (!parsed.data.result && !parsed.data.error))
|
|
105
|
+
throw invalid("sent an unreadable audio chunk");
|
|
106
|
+
if (parsed.data.error) {
|
|
107
|
+
const { code, message } = parsed.data.error;
|
|
108
|
+
throw providerError({
|
|
109
|
+
kind: code === 16 || code === 7
|
|
110
|
+
? "auth"
|
|
111
|
+
: code === 8
|
|
112
|
+
? "rate_limit"
|
|
113
|
+
: code === 3 || code === 5
|
|
114
|
+
? "unsupported"
|
|
115
|
+
: "other",
|
|
116
|
+
message: `Inworld stream failed: ${clean(message ?? "audio generation stopped", key)}`,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
const encoded = parsed.data.result?.audioContent;
|
|
120
|
+
if (!encoded)
|
|
121
|
+
continue;
|
|
122
|
+
if (!/^[A-Za-z0-9+/]*={0,2}$/.test(encoded) || encoded.length % 4 === 1)
|
|
123
|
+
throw invalid("sent invalid encoded audio");
|
|
124
|
+
const audio = Buffer.from(encoded, "base64");
|
|
125
|
+
if (audio.length === 0)
|
|
126
|
+
continue;
|
|
127
|
+
heard = true;
|
|
128
|
+
yield audio;
|
|
129
|
+
}
|
|
130
|
+
if (!heard)
|
|
131
|
+
throw invalid("answered with no audio");
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
async function* lines(body) {
|
|
135
|
+
const reader = body.getReader();
|
|
136
|
+
const decoder = new TextDecoder();
|
|
137
|
+
let pending = "";
|
|
138
|
+
try {
|
|
139
|
+
for (;;) {
|
|
140
|
+
const { done, value } = await reader.read();
|
|
141
|
+
pending += done ? decoder.decode() : decoder.decode(value, { stream: true });
|
|
142
|
+
let end = pending.indexOf("\n");
|
|
143
|
+
while (end !== -1) {
|
|
144
|
+
if (end > 8 * 1024 * 1024)
|
|
145
|
+
throw invalid("sent an oversized audio chunk");
|
|
146
|
+
const line = pending.slice(0, end).trim();
|
|
147
|
+
pending = pending.slice(end + 1);
|
|
148
|
+
if (line)
|
|
149
|
+
yield line;
|
|
150
|
+
end = pending.indexOf("\n");
|
|
151
|
+
}
|
|
152
|
+
if (pending.length > 8 * 1024 * 1024)
|
|
153
|
+
throw invalid("sent an oversized audio chunk");
|
|
154
|
+
if (done)
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
if (pending.trim())
|
|
158
|
+
yield pending.trim();
|
|
159
|
+
}
|
|
160
|
+
finally {
|
|
161
|
+
await reader.cancel().catch(() => { });
|
|
162
|
+
reader.releaseLock();
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
function clean(message, key) {
|
|
166
|
+
return redact(message.replaceAll(key, "[redacted]"));
|
|
167
|
+
}
|
|
168
|
+
function invalid(detail) {
|
|
169
|
+
return providerError({ kind: "other", message: `Inworld ${detail}.` });
|
|
170
|
+
}
|
|
@@ -5,9 +5,18 @@ import { retryAfter } from "../retry-after.js";
|
|
|
5
5
|
// The HTTP gateway adapter for OpenAI's speech endpoint. `fetch` and nothing else; the response
|
|
6
6
|
// body is already the stream the port asks for.
|
|
7
7
|
export const openAiAudioBase = "https://api.openai.com/v1";
|
|
8
|
-
//
|
|
9
|
-
// three per character.
|
|
8
|
+
// Older callers can omit a model; saved project choices always supply one.
|
|
10
9
|
export const openAiTtsModel = "gpt-4o-mini-tts";
|
|
10
|
+
export const openAiTtsModels = [
|
|
11
|
+
{ id: "gpt-4o-mini-tts", name: "GPT-4o mini TTS" },
|
|
12
|
+
{ id: "gpt-4o-mini-tts-2025-12-15", name: "GPT-4o mini TTS (2025-12-15)" },
|
|
13
|
+
{ id: "tts-1", name: "TTS-1" },
|
|
14
|
+
{ id: "tts-1-hd", name: "TTS-1 HD" },
|
|
15
|
+
];
|
|
16
|
+
const modelList = z.object({ data: z.array(z.object({ id: z.string().min(1) })) });
|
|
17
|
+
// /models has no capability metadata. Only the speech endpoint's documented model families
|
|
18
|
+
// and dated snapshots belong here; realtime and transcription models use different APIs.
|
|
19
|
+
const speechModel = /^(?:tts-1(?:-hd)?(?:-\d{4})?|gpt-4o-mini-tts(?:-\d{4}-\d{2}-\d{2})?)$/;
|
|
11
20
|
const errorBody = z.object({
|
|
12
21
|
error: z.object({ message: z.string(), code: z.string().nullish() }),
|
|
13
22
|
});
|
|
@@ -19,6 +28,24 @@ export function openAiTts(deps) {
|
|
|
19
28
|
return {
|
|
20
29
|
id: "openai-tts",
|
|
21
30
|
capabilities: { streams: true },
|
|
31
|
+
models: async () => {
|
|
32
|
+
const response = await deps.fetch(`${openAiAudioBase}/models`, {
|
|
33
|
+
headers: { Authorization: `Bearer ${keyOf(deps)}` },
|
|
34
|
+
signal: AbortSignal.timeout(10_000),
|
|
35
|
+
});
|
|
36
|
+
if (!response.ok)
|
|
37
|
+
throw await failure(response);
|
|
38
|
+
const parsed = modelList.safeParse(safeJson(await response.text()));
|
|
39
|
+
if (!parsed.success) {
|
|
40
|
+
throw providerError({
|
|
41
|
+
kind: "other",
|
|
42
|
+
message: "OpenAI's model list was not in the shape this app can read",
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return parsed.data.data
|
|
46
|
+
.filter((model) => speechModel.test(model.id))
|
|
47
|
+
.map((model) => ({ id: model.id, name: model.id }));
|
|
48
|
+
},
|
|
22
49
|
synthesize: async (req) => {
|
|
23
50
|
const response = await deps.fetch(`${openAiAudioBase}/audio/speech`, {
|
|
24
51
|
method: "POST",
|
|
@@ -31,7 +58,7 @@ export function openAiTts(deps) {
|
|
|
31
58
|
// 400 and that is what the stage shows, so a user who chose Whole text learns the limit
|
|
32
59
|
// from the provider that set it.
|
|
33
60
|
body: JSON.stringify({
|
|
34
|
-
model: openAiTtsModel,
|
|
61
|
+
model: req.model ?? openAiTtsModel,
|
|
35
62
|
input: req.text,
|
|
36
63
|
voice: voiceOf(req.voiceId),
|
|
37
64
|
response_format: "mp3",
|
|
@@ -80,7 +107,7 @@ async function failure(response, voiceId) {
|
|
|
80
107
|
kind: kindOf(response.status),
|
|
81
108
|
// The voice ID is named, so a rejected voice reads differently from
|
|
82
109
|
// a rejected key.
|
|
83
|
-
message: `OpenAI answered ${response.status} for voice ${voiceId}: ${message}`,
|
|
110
|
+
message: `OpenAI answered ${response.status}${voiceId === undefined ? "" : ` for voice ${voiceId}`}: ${message}`,
|
|
84
111
|
...(retryAfterMs === undefined ? {} : { retryAfterMs }),
|
|
85
112
|
});
|
|
86
113
|
}
|
|
Binary file
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Copyright 2017 The Barlow Project Authors (https://github.com/jpt/barlow)
|
|
2
|
+
|
|
3
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
+
This license is copied below, and is also available with a FAQ at:
|
|
5
|
+
http://scripts.sil.org/OFL
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
-----------------------------------------------------------
|
|
9
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
10
|
+
-----------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
PREAMBLE
|
|
13
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
14
|
+
development of collaborative font projects, to support the font creation
|
|
15
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
16
|
+
open framework in which fonts may be shared and improved in partnership
|
|
17
|
+
with others.
|
|
18
|
+
|
|
19
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
20
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
21
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
22
|
+
redistributed and/or sold with any software provided that any reserved
|
|
23
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
24
|
+
however, cannot be released under any other type of license. The
|
|
25
|
+
requirement for fonts to remain under this license does not apply
|
|
26
|
+
to any document created using the fonts or their derivatives.
|
|
27
|
+
|
|
28
|
+
DEFINITIONS
|
|
29
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
30
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
31
|
+
include source files, build scripts and documentation.
|
|
32
|
+
|
|
33
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
34
|
+
copyright statement(s).
|
|
35
|
+
|
|
36
|
+
"Original Version" refers to the collection of Font Software components as
|
|
37
|
+
distributed by the Copyright Holder(s).
|
|
38
|
+
|
|
39
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
40
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
41
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
42
|
+
new environment.
|
|
43
|
+
|
|
44
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
45
|
+
writer or other person who contributed to the Font Software.
|
|
46
|
+
|
|
47
|
+
PERMISSION & CONDITIONS
|
|
48
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
49
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
50
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
51
|
+
Software, subject to the following conditions:
|
|
52
|
+
|
|
53
|
+
1) Neither the Font Software nor any of its individual components,
|
|
54
|
+
in Original or Modified Versions, may be sold by itself.
|
|
55
|
+
|
|
56
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
57
|
+
redistributed and/or sold with any software, provided that each copy
|
|
58
|
+
contains the above copyright notice and this license. These can be
|
|
59
|
+
included either as stand-alone text files, human-readable headers or
|
|
60
|
+
in the appropriate machine-readable metadata fields within text or
|
|
61
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
62
|
+
|
|
63
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
64
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
65
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
66
|
+
presented to the users.
|
|
67
|
+
|
|
68
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
69
|
+
Software shall not be used to promote, endorse or advertise any
|
|
70
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
71
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
72
|
+
permission.
|
|
73
|
+
|
|
74
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
75
|
+
must be distributed entirely under this license, and must not be
|
|
76
|
+
distributed under any other license. The requirement for fonts to
|
|
77
|
+
remain under this license does not apply to any document created
|
|
78
|
+
using the Font Software.
|
|
79
|
+
|
|
80
|
+
TERMINATION
|
|
81
|
+
This license becomes null and void if any of the above conditions are
|
|
82
|
+
not met.
|
|
83
|
+
|
|
84
|
+
DISCLAIMER
|
|
85
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
86
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
87
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
88
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
89
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
90
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
91
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
92
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
93
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Barlow-Regular.ttf
|
|
2
|
+
Source: https://raw.githubusercontent.com/google/fonts/6cdf01867df0813c2390f90dff7dc66c87f14cf7/ofl/barlow/Barlow-Regular.ttf
|
|
3
|
+
SHA-256: 95aa02c7c43096e0dd44d787ba6216864a67157e402adab59b35572e0c1577ea
|
|
4
|
+
|
|
5
|
+
OFL.txt
|
|
6
|
+
Source: https://raw.githubusercontent.com/google/fonts/6cdf01867df0813c2390f90dff7dc66c87f14cf7/ofl/barlow/OFL.txt
|
|
7
|
+
SHA-256: 186d750eb496a4c17a76385f82be6aea2ac1cf2de074a811d63786cf374ea73f
|
package/dist/edge/cli.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { parseArgs } from "node:util";
|
|
3
3
|
import { configFrom } from "../kernel/config/index.js";
|
|
4
|
+
import { readVersion } from "../kernel/version.js";
|
|
4
5
|
import { boot } from "../main.js";
|
|
6
|
+
import { forwardManagedUpdate } from "../updater/forward.js";
|
|
5
7
|
import { openBrowser } from "./open-browser.js";
|
|
6
8
|
const { values } = parseArgs({
|
|
7
9
|
options: {
|
|
@@ -13,6 +15,9 @@ const { values } = parseArgs({
|
|
|
13
15
|
});
|
|
14
16
|
try {
|
|
15
17
|
const config = configFrom(values, process.env);
|
|
18
|
+
const forwarded = await forwardManagedUpdate(config.dataDir, readVersion(), process.argv.slice(2));
|
|
19
|
+
if (forwarded !== undefined)
|
|
20
|
+
process.exit(forwarded);
|
|
16
21
|
const { paths, url, stop } = await boot(config);
|
|
17
22
|
console.log(`Slopify is running at ${url}`);
|
|
18
23
|
console.log(`Slopify data directory: ${paths.dataDir}`);
|
package/dist/edge/events/hub.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { createPreviewCache } from "./preview-cache.js";
|
|
1
2
|
export function createHub(deps) {
|
|
3
|
+
const previews = createPreviewCache();
|
|
2
4
|
const projects = new Map();
|
|
3
5
|
const globals = new Set();
|
|
4
6
|
// The tally a page needs before anything else happens. The runner emits it when it
|
|
@@ -43,11 +45,15 @@ export function createHub(deps) {
|
|
|
43
45
|
subscribe: (projectId, stream, signal) => {
|
|
44
46
|
const set = projects.get(projectId) ?? new Set();
|
|
45
47
|
projects.set(projectId, set);
|
|
46
|
-
|
|
48
|
+
const subscriber = join(set, stream, signal, () => {
|
|
47
49
|
if (set.size === 0) {
|
|
48
50
|
projects.delete(projectId);
|
|
49
51
|
}
|
|
50
|
-
})
|
|
52
|
+
});
|
|
53
|
+
if (set.has(subscriber))
|
|
54
|
+
for (const event of previews.snapshot(projectId))
|
|
55
|
+
send(subscriber, event);
|
|
56
|
+
return subscriber.done;
|
|
51
57
|
},
|
|
52
58
|
subscribeGlobal: (stream, signal) => {
|
|
53
59
|
const subscriber = join(globals, stream, signal, () => { });
|
|
@@ -57,6 +63,7 @@ export function createHub(deps) {
|
|
|
57
63
|
return subscriber.done;
|
|
58
64
|
},
|
|
59
65
|
emit: (projectId, event) => {
|
|
66
|
+
previews.observe(event);
|
|
60
67
|
for (const subscriber of projects.get(projectId) ?? []) {
|
|
61
68
|
send(subscriber, event);
|
|
62
69
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Preview memory is bounded independently from durable outputs. A subscriber joining
|
|
2
|
+
// mid-call receives only visible response text, never prompts or provider reasoning.
|
|
3
|
+
export function createPreviewCache() {
|
|
4
|
+
const projects = new Map();
|
|
5
|
+
return {
|
|
6
|
+
observe: (event) => {
|
|
7
|
+
if (event.type === "stage.state") {
|
|
8
|
+
const calls = projects.get(event.projectId);
|
|
9
|
+
if (calls) {
|
|
10
|
+
for (const [id, call] of calls)
|
|
11
|
+
if (call.stage === event.stage)
|
|
12
|
+
calls.delete(id);
|
|
13
|
+
if (calls.size === 0)
|
|
14
|
+
projects.delete(event.projectId);
|
|
15
|
+
}
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (event.type !== "llm.preview")
|
|
19
|
+
return;
|
|
20
|
+
const calls = projects.get(event.projectId) ?? new Map();
|
|
21
|
+
const prior = calls.get(event.callId);
|
|
22
|
+
const text = (event.reset ? event.text : `${prior?.text ?? ""}${event.text}`).slice(-64 * 1024);
|
|
23
|
+
calls.delete(event.callId);
|
|
24
|
+
calls.set(event.callId, { ...event, text, reset: true });
|
|
25
|
+
while (calls.size > 8) {
|
|
26
|
+
const id = calls.keys().next().value;
|
|
27
|
+
if (id !== undefined)
|
|
28
|
+
calls.delete(id);
|
|
29
|
+
}
|
|
30
|
+
projects.delete(event.projectId);
|
|
31
|
+
projects.set(event.projectId, calls);
|
|
32
|
+
while (projects.size > 16) {
|
|
33
|
+
const id = projects.keys().next().value;
|
|
34
|
+
if (id !== undefined)
|
|
35
|
+
projects.delete(id);
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
snapshot: (projectId) => [...(projects.get(projectId)?.values() ?? [])],
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -9,6 +9,7 @@ import { changeProviders, pauseProject, resumeProject } from "../../slices/contr
|
|
|
9
9
|
import { withProjectControl } from "../../slices/control/lock.js";
|
|
10
10
|
import { providerChangesSchema } from "../../slices/control/providers.js";
|
|
11
11
|
import { deleteImage, editArticle, regenerateImage, rerunStage, retryStage, } from "../../slices/reruns/index.js";
|
|
12
|
+
import { allowsCustomModel } from "../../slices/settings/models.js";
|
|
12
13
|
import { providerStatuses } from "../../slices/settings/readiness.js";
|
|
13
14
|
import { outputsOf } from "../../slices/storage/repo.js";
|
|
14
15
|
import { onInvalid, problem, titleOf } from "./problem.js";
|
|
@@ -79,6 +80,7 @@ export function actionRoutes(deps) {
|
|
|
79
80
|
runner: deps.runner,
|
|
80
81
|
emit: (projectId, event) => deps.hub.emit(projectId, event),
|
|
81
82
|
providers: () => providerStatuses({ db: deps.db, probe: deps.probe }),
|
|
83
|
+
allowsCustomModels: allowsCustomModel,
|
|
82
84
|
modelsFor: deps.modelsFor ?? (() => Promise.reject(new Error("Model catalog unavailable"))),
|
|
83
85
|
};
|
|
84
86
|
const view = (projectId) => {
|
package/dist/edge/http/app.js
CHANGED
|
@@ -3,15 +3,19 @@ import { serveStatic } from "@hono/node-server/serve-static";
|
|
|
3
3
|
import { Hono } from "hono";
|
|
4
4
|
import { streamSSE } from "hono/streaming";
|
|
5
5
|
import { actionRoutes } from "./actions.js";
|
|
6
|
+
import { audioPreviewRoutes } from "./audio-preview.js";
|
|
6
7
|
import { entryRoutes } from "./entries.js";
|
|
7
8
|
import { fileRoutes } from "./files.js";
|
|
9
|
+
import { fontsRoutes } from "./fonts.js";
|
|
8
10
|
import { problem, problemFromError, titleOf } from "./problem.js";
|
|
9
11
|
import { projectRoutes } from "./projects.js";
|
|
10
12
|
import { promptRoutes } from "./prompts.js";
|
|
11
13
|
import { providerRoutes } from "./providers.js";
|
|
12
14
|
import { settingsRoutes } from "./settings.js";
|
|
13
15
|
import { stagingRoutes } from "./staging.js";
|
|
16
|
+
import { subtitleRoutes } from "./subtitles.js";
|
|
14
17
|
import { telemetryRoutes } from "./telemetry.js";
|
|
18
|
+
import { updateRoutes } from "./update.js";
|
|
15
19
|
import { usageRoutes } from "./usage.js";
|
|
16
20
|
const notBuilt = "The Slopify UI is not built yet. The API is running: try /api/health.\n" +
|
|
17
21
|
"Build the SPA with `npm run build` at the repository root.\n";
|
|
@@ -24,9 +28,13 @@ function apiRoutes(deps, startedAt) {
|
|
|
24
28
|
}))
|
|
25
29
|
.route("/staging", stagingRoutes(deps))
|
|
26
30
|
.route("/projects", projectRoutes(deps))
|
|
31
|
+
.route("/projects", audioPreviewRoutes(deps))
|
|
32
|
+
.route("/update", updateRoutes(deps))
|
|
27
33
|
// The re-run and cancel actions sit on the same prefix as the project itself; they
|
|
28
34
|
// are their own router because they are their own concern.
|
|
29
35
|
.route("/projects", actionRoutes(deps))
|
|
36
|
+
.route("/projects", subtitleRoutes(deps))
|
|
37
|
+
.route("/fonts", fontsRoutes(deps))
|
|
30
38
|
.route("/prompts", promptRoutes(deps))
|
|
31
39
|
.route("/entries", entryRoutes(deps))
|
|
32
40
|
.route("/telemetry", telemetryRoutes(deps))
|
|
@@ -38,8 +46,29 @@ export function createApp(deps) {
|
|
|
38
46
|
const startedAt = deps.clock.now().getTime();
|
|
39
47
|
const app = new Hono()
|
|
40
48
|
.use("*", async (c, next) => {
|
|
41
|
-
|
|
49
|
+
// A provisional candidate must not trigger the stale-tab Reload dialog.
|
|
50
|
+
if (!deps.updater?.locked())
|
|
51
|
+
c.header("X-Slopify-Version", deps.version);
|
|
42
52
|
await next();
|
|
53
|
+
})
|
|
54
|
+
.use("/api/*", async (c, next) => {
|
|
55
|
+
if (deps.updater === undefined ||
|
|
56
|
+
["GET", "HEAD", "OPTIONS"].includes(c.req.method) ||
|
|
57
|
+
["/api/update", "/api/update/", "/api/update/activate", "/api/update/activate/"].includes(c.req.path))
|
|
58
|
+
return next();
|
|
59
|
+
const release = deps.updater.beginMutation();
|
|
60
|
+
if (release === undefined)
|
|
61
|
+
return problem(c, {
|
|
62
|
+
status: 409,
|
|
63
|
+
title: titleOf(409),
|
|
64
|
+
detail: "Slopify is updating. Wait for it to restart before making changes.",
|
|
65
|
+
});
|
|
66
|
+
try {
|
|
67
|
+
await next();
|
|
68
|
+
}
|
|
69
|
+
finally {
|
|
70
|
+
release();
|
|
71
|
+
}
|
|
43
72
|
})
|
|
44
73
|
.onError((error, c) => problemFromError(c, error, deps))
|
|
45
74
|
.notFound(missing)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { zValidator } from "@hono/zod-validator";
|
|
2
|
+
import { Hono } from "hono";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { projectTitle } from "../../slices/storage/repo.js";
|
|
5
|
+
import { onInvalid, problem, titleOf } from "./problem.js";
|
|
6
|
+
const projectParam = z.object({
|
|
7
|
+
projectId: z
|
|
8
|
+
.string()
|
|
9
|
+
.min(1)
|
|
10
|
+
.max(64)
|
|
11
|
+
.regex(/^[0-9A-Za-z_-]+$/),
|
|
12
|
+
});
|
|
13
|
+
const previewParam = projectParam.extend({ previewId: z.uuid() });
|
|
14
|
+
export function audioPreviewRoutes(deps) {
|
|
15
|
+
return new Hono()
|
|
16
|
+
.get("/:projectId/audio-preview", zValidator("param", projectParam, onInvalid), (c) => {
|
|
17
|
+
const { projectId } = c.req.valid("param");
|
|
18
|
+
if (projectTitle(deps.db, projectId) === undefined)
|
|
19
|
+
return missing(c);
|
|
20
|
+
c.header("Cache-Control", "no-store");
|
|
21
|
+
return c.json({ previews: deps.audioPreviews?.list(projectId) ?? [] });
|
|
22
|
+
})
|
|
23
|
+
.get("/:projectId/audio-preview/:previewId", zValidator("param", previewParam, onInvalid), (c) => {
|
|
24
|
+
const { projectId, previewId } = c.req.valid("param");
|
|
25
|
+
if (projectTitle(deps.db, projectId) === undefined)
|
|
26
|
+
return missing(c);
|
|
27
|
+
const stream = deps.audioPreviews?.stream(projectId, previewId, c.req.raw.signal);
|
|
28
|
+
if (stream === undefined)
|
|
29
|
+
return missing(c);
|
|
30
|
+
// A growing MP3 has no final length or seek range. A native audio element
|
|
31
|
+
// can consume it progressively; late listeners receive the retained prefix.
|
|
32
|
+
return c.body(stream, 200, {
|
|
33
|
+
"Content-Type": "audio/mpeg",
|
|
34
|
+
"Cache-Control": "no-store",
|
|
35
|
+
"Accept-Ranges": "none",
|
|
36
|
+
"X-Content-Type-Options": "nosniff",
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function missing(c) {
|
|
41
|
+
return problem(c, {
|
|
42
|
+
status: 404,
|
|
43
|
+
title: titleOf(404),
|
|
44
|
+
detail: "This live audio preview is no longer available. Finished narration is available in the audio outputs.",
|
|
45
|
+
});
|
|
46
|
+
}
|