@double_geste/agent-standup 1.46.0 → 1.47.1
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 +1 -1
- package/bin/agent-standup.js +62 -3
- package/kokoro-worker.js +13 -6
- package/kokoro.js +97 -27
- package/package.json +3 -1
- package/public/index.html +245 -65
- package/public/locales/README.md +1 -1
- package/public/locales/da.json +6 -1
- package/public/locales/de.json +6 -1
- package/public/locales/en.json +5 -0
- package/public/locales/es.json +6 -1
- package/public/locales/ja.json +6 -1
- package/public/locales/ko.json +6 -1
- package/public/locales/pt-BR.json +6 -1
- package/public/locales/zh-CN.json +6 -1
- package/public/locales/zh-TW.json +6 -1
- package/server.js +4 -4
- package/supertonic-worker.js +82 -0
- package/zh-g2p.js +175 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Agent Standup (command line)
|
|
2
2
|
|
|
3
|
-
Your Claude Code, Codex and Mistral Vibe sessions as a live team call, without any editor. Free, MIT, and by default it never calls Claude: it reads the session files Claude Code, Codex, Mistral Vibe and Cowork already write, and calls Claude only to translate a call held in French, Spanish or Brazilian Portuguese, or for the optional jokes.
|
|
3
|
+
Your Claude Code, Codex and Mistral Vibe sessions as a live team call, without any editor. Free, MIT, and by default it never calls Claude: it reads the session files Claude Code, Codex, Mistral Vibe and Cowork already write, and calls Claude only to translate a call held in another language (French, Spanish or Brazilian Portuguese, or German, Danish, Japanese, Korean or Chinese once you say yes), or for the optional jokes.
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
6
|
npx @double_geste/agent-standup # then open http://localhost:4747 (add --open to open it for you)
|
package/bin/agent-standup.js
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
// agent-standup status [--here] [--json] [--titles] counts of working / needs you / your turn
|
|
5
5
|
// agent-standup statusline same, one short line; reads Claude Code's statusLine JSON on stdin
|
|
6
6
|
// agent-standup report [--day D] [--here] [--json] [--titles] what each session did that day: time worked, time it waited for you, calls, files (the plugin's whiteboard and timesheet skills read it)
|
|
7
|
-
//
|
|
7
|
+
// agent-standup credits [--session ID] [--here] [--json] a line for a pull request: who was on the call (the lead and its sub-agents, named as the call names them) and what they did (the plugin's credits skill)
|
|
8
|
+
// Everything reads the local session files Claude Code already writes. Nothing is sent anywhere unless the call is in French, Spanish or Brazilian Portuguese (or German, Danish, Japanese, Korean or Chinese, once you say yes) or you turn on the jokes (they use your own Claude login or ANTHROPIC_API_KEY).
|
|
8
9
|
const path = require('path'), { spawn } = require('child_process');
|
|
9
10
|
const pkg = require('../package.json');
|
|
10
11
|
const argv = process.argv.slice(2), flags = {}, rest = [];
|
|
@@ -12,7 +13,7 @@ for (let i = 0; i < argv.length; i++) {
|
|
|
12
13
|
const a = argv[i], val = () => argv[++i];
|
|
13
14
|
if (a === '--port') flags.port = val(); else if (a === '--projects') flags.projects = val(); else if (a === '--codex') flags.codex = val(); else if (a === '--vibe') flags.vibe = val(); else if (a === '--cowork') flags.cowork = val(); else if (a === '--characters') flags.characters = val(); else if (a === '--config-dir') flags.config = val();
|
|
14
15
|
else if (a === '--reply') flags.reply = /^(0|1|on|off|yes|no|true|false)$/i.test(argv[i + 1] || '') ? val() : 'on'; // alone or followed by on / off
|
|
15
|
-
else if (a === '--from') flags.from = val(); else if (a === '--open') flags.open = true; else if (a === '--here') flags.here = true; else if (a === '--json') flags.json = true; else if (a === '--titles') flags.titles = true; else if (a === '--config') flags.config = val(); else if (a === '--day') flags.day = val();
|
|
16
|
+
else if (a === '--from') flags.from = val(); else if (a === '--open') flags.open = true; else if (a === '--here') flags.here = true; else if (a === '--json') flags.json = true; else if (a === '--titles') flags.titles = true; else if (a === '--config') flags.config = val(); else if (a === '--day') flags.day = val(); else if (a === '--session') flags.session = val();
|
|
16
17
|
else if (a === '-h' || a === '--help') flags.help = true; else if (a === '-v' || a === '--version') flags.version = true; else rest.push(a);
|
|
17
18
|
}
|
|
18
19
|
const cmd = rest[0] || 'serve';
|
|
@@ -23,6 +24,7 @@ Usage
|
|
|
23
24
|
agent-standup status [--here] [--json] what is going on right now (--here: only the current folder)
|
|
24
25
|
agent-standup statusline one short line for a status bar (reads Claude Code's JSON on stdin)
|
|
25
26
|
agent-standup report [--day D] [--json] what each session did that day: time worked, waits for you, calls, files
|
|
27
|
+
agent-standup credits [--session ID] [--json] a credits line for a pull request: the lead and sub-agents of a session, its time and calls
|
|
26
28
|
|
|
27
29
|
Options
|
|
28
30
|
--port N port of the local server (default 4747)
|
|
@@ -43,6 +45,8 @@ Options
|
|
|
43
45
|
--json status, report: machine-readable output
|
|
44
46
|
--day D report: the day to tell, YYYY-MM-DD, today (the default) or yesterday, in local time
|
|
45
47
|
--titles include session titles, questions, commands and errors
|
|
48
|
+
--session ID credits: the session to credit (default: the Claude Code session it runs in, $CLAUDE_CODE_SESSION_ID;
|
|
49
|
+
with --here and no id, the current folder's latest session)
|
|
46
50
|
`;
|
|
47
51
|
if (flags.help || cmd === 'help') { process.stdout.write(HELP); process.exit(0); }
|
|
48
52
|
if (flags.version || cmd === 'version') { console.log(pkg.version); process.exit(0); }
|
|
@@ -117,7 +121,62 @@ async function report(day, dir, titles) {
|
|
|
117
121
|
return { day: ymd(from), sessions: rows.length, workMin: rows.reduce((n, r) => n + r.workMin, 0), waitMin: rows.reduce((n, r) => n + r.waitMin, 0), rows };
|
|
118
122
|
}
|
|
119
123
|
|
|
120
|
-
|
|
124
|
+
// The cast of one session, named as the call names it: the lead (the editor's setting, this project's, the global one, or Margot), then each sub-agent in the order it was born, a fork after
|
|
125
|
+
// the lead (Margot 2), a name of its own when the person turned those on, a tool's own name (Codex's nicknames) unless they gave a list, otherwise a name drawn from its id.
|
|
126
|
+
// A copy of public/index.html (NAMES, hash, cleanLead, uniqueName, subName, twinOf): keep the two in step; test/cli-credits.test.js checks the list against the page's.
|
|
127
|
+
const NAMES = ['Ada','Linus','Grace','Alan','Margaret','Dennis','Barbara','Ken','Radia','Tim','Hedy','Guido','Frances','Bjarne','Katherine','Brian','Sophie','Niklaus','Annie','Donald','Joan','Edsger','Lynn','Vint','Mae','Rob','Zoe','Ivan','Nina','Otto','Lena','Hugo','Ines','Théo','Maya','Jules','Alma','Remy','Cleo','Noah','Iris','Leo','Mira','Axel','Nora','Eli','Lou','Gaby'];
|
|
128
|
+
const fnv = (s) => { let h = 2166136261; for (const c of s) h = Math.imul(h ^ c.charCodeAt(0), 16777619); return h >>> 0; };
|
|
129
|
+
const cleanName = (v) => Array.from(String(v == null ? '' : v).replace(/'/g, '’').replace(/[\u0000-\u001f\u007f-\u009f<>&"`\\]/g, '').replace(/\s+/g, ' ').trim()).slice(0, 24).join('').trim();
|
|
130
|
+
function castOf(agents, prefs, key) {
|
|
131
|
+
prefs = prefs && typeof prefs === 'object' ? prefs : {};
|
|
132
|
+
const lead = cleanName(process.env.AGENT_STANDUP_LEAD_NAME) || (key && cleanName(prefs['leadName:' + key])) || cleanName(prefs.leadName) || 'Margot', low = (n) => String(n).toLocaleLowerCase();
|
|
133
|
+
const isLead = (n) => { const l = low(lead), s = low(n || ''); return !!n && (s === l || (s.startsWith(l + ' ') && /^\d+$/.test(s.slice(l.length + 1)))); };
|
|
134
|
+
const list = []; { const seen = new Set(); for (const v of (typeof prefs.subNames === 'string' ? prefs.subNames : '').split(/[,;\n]+/)) { const n = cleanName(v), k = low(n); if (n && !seen.has(k) && list.length < 200) { seen.add(k); list.push(n); } } }
|
|
135
|
+
const book = {}, names = {};
|
|
136
|
+
const unique = (id, h) => {
|
|
137
|
+
const taken = new Set(Object.values(book).map(low)); taken.add(low(lead));
|
|
138
|
+
const own = list.filter((n) => !isLead(n)), pool = own.length ? own : NAMES, at = own.length ? 0 : h;
|
|
139
|
+
for (let k = 0; k < pool.length; k++) { const n = pool[(at + k) % pool.length]; if (!taken.has(low(n))) return (book[id] = n); }
|
|
140
|
+
for (let r = 2; ; r++) for (let k = 0; k < pool.length; k++) { const b = pool[(at + k) % pool.length]; if (isLead(b)) continue; const n = b + ' ' + r; if (!taken.has(low(n))) return (book[id] = n); }
|
|
141
|
+
};
|
|
142
|
+
const ownFree = (a) => { const taken = new Set(Object.keys(book).filter((k) => k !== a.id).map((k) => low(book[k]))); let n = a.own; for (let r = 2; taken.has(low(n)); r++) n = a.own + ' ' + r; return n; };
|
|
143
|
+
let twins = 0;
|
|
144
|
+
const subs = (agents || []).filter((a) => a && a.id && a.id !== 'main' && a.id !== 'user').map((a, j) => ({ a, j })).sort((x, y) => (x.a.born || Infinity) - (y.a.born || Infinity) || x.j - y.j).map((x) => x.a);
|
|
145
|
+
for (const a of subs) {
|
|
146
|
+
const twinN = /^fork$/i.test(a.type || '') && !('given' in a) && !(a.own && prefs.ownNames) ? 2 + twins++ : 0, given = twinN ? lead + ' ' + twinN : 'given' in a ? a.given : a.name;
|
|
147
|
+
names[a.id] = a.own && prefs.ownNames && !isLead(a.own) ? (book[a.id] = ownFree(a)) : ((twinN || (!isLead(given) && !list.length)) && given) || unique(a.id, fnv(a.id));
|
|
148
|
+
}
|
|
149
|
+
return { lead, names };
|
|
150
|
+
}
|
|
151
|
+
const SITE = 'https://agent-standup.com';
|
|
152
|
+
function credits(id, dir) {
|
|
153
|
+
const want = (r) => (id ? r.id === id : !dir || fold(r.proj) === fold(projKey(dir)));
|
|
154
|
+
let r = server.sessionRows().filter(want).sort((a, b) => b.mtime - a.mtime)[0];
|
|
155
|
+
if (!r && server.sessionsSince) r = server.sessionsSince(0).filter(want).sort((a, b) => b.mtime - a.mtime)[0]; // an older session than the recent list holds
|
|
156
|
+
if (!r) return null;
|
|
157
|
+
const tl = server.timeline(r.proj, r.id), ev = tl.events.slice().sort((x, y) => x.ts - y.ts), busy = new Set(), files = new Set(); let work = 0, commands = 0, edits = 0;
|
|
158
|
+
ev.forEach((e, i) => {
|
|
159
|
+
if (e.agent && e.agent !== 'main' && e.agent !== 'user') busy.add(e.agent);
|
|
160
|
+
if (e.kind === 'tools') for (const t of e.tools) { const k = t.d && t.d.kind; if (k === 'cmd') commands++; if (k === 'edit' || k === 'write') { edits++; if (typeof t.d.file === 'string' && t.d.file) files.add(t.d.file); } }
|
|
161
|
+
if (i && e.kind !== 'user') { const gap = e.ts - ev[i - 1].ts; if (gap <= GAP_WORK) work += gap; } // as report counts it: the gaps within a turn, up to 10 minutes each
|
|
162
|
+
});
|
|
163
|
+
const cast = castOf(tl.agents, server.readPrefs ? server.readPrefs() : null, server.leadKey ? server.leadKey(r.proj, r.id) : ''), subs = (tl.agents || []).filter((a) => a && busy.has(a.id)).map((a) => cast.names[a.id]).filter(Boolean);
|
|
164
|
+
const shown = subs.length > 5 ? [...subs.slice(0, 4), `${subs.length - 4} others`] : subs, who = [cast.lead, ...shown].reduce((s, n, i, all) => (i ? s + (i === all.length - 1 ? ' and ' : ', ') : '') + n, '');
|
|
165
|
+
const workMin = Math.round(work / 60e3), plural = (n, w) => `${n} ${w}${n === 1 ? '' : 's'}`;
|
|
166
|
+
const facts = [workMin ? `${dur(workMin)} of work` : '', commands ? plural(commands, 'command') : '', edits ? plural(edits, 'edit') + (files.size ? ` in ${plural(files.size, 'file')}` : '') : ''].filter(Boolean);
|
|
167
|
+
const md = (s) => s.replace(/[\\`*_[\]~|#<>]/g, '\\$&'); // names are the person's own words: plain text in the line
|
|
168
|
+
return { session: r.id, project: projLabel(String(r.project || r.proj)), lead: cast.lead, subAgents: subs, workMin, commands, edits, filesChanged: files.size,
|
|
169
|
+
markdown: `<sub><a href="${SITE}"><img src="${SITE}/brand/team-strip.svg" height="16" align="absmiddle" alt="The Agent Standup cast"></a> Built on an <a href="${SITE}">Agent Standup</a> call by ${md(who)}${facts.map((f) => ' · ' + f).join('')}</sub>`,
|
|
170
|
+
text: `Built on an Agent Standup call by ${who}${facts.map((f) => ' · ' + f).join('')} · ${SITE}` };
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (cmd === 'credits') {
|
|
174
|
+
const id = flags.session || (flags.here ? '' : process.env.CLAUDE_CODE_SESSION_ID || '');
|
|
175
|
+
if (!id && !flags.here) { console.error('No session to credit: run it from inside a Claude Code session, or pass --session <id> or --here (the current folder\'s latest session).'); process.exit(2); }
|
|
176
|
+
let c; try { c = credits(id, flags.here ? process.cwd() : ''); } catch (e) { console.error('Could not read that session: ' + (e && e.message)); process.exit(1); }
|
|
177
|
+
if (!c) { console.error(id ? `No session ${id} in the session files.` : 'No session in this folder.'); process.exit(1); }
|
|
178
|
+
process.stdout.write((flags.json ? JSON.stringify(c, null, 2) : c.markdown) + '\n', () => process.exit(0));
|
|
179
|
+
} else if (cmd === 'status') {
|
|
121
180
|
const s = snapshot(flags.here ? process.cwd() : '');
|
|
122
181
|
if (flags.json) console.log(JSON.stringify({ needsYou: s.needsYou, working: s.working, yourTurn: s.yourTurn, idle: s.idle, sessions: s.rows.map((r) => ({ project: r.proj, id: r.id, state: r.state, tool: r.tool, ageMs: Math.round(r.ageMs), subAgentsActive: r.subActive, subAgents: r.subTotal, ...(r.since ? { since: r.since } : {}), ...(r.ran ? { ran: r.ran } : {}), ...(r.limit ? { limit: r.limit } : {}), ...(r.auth ? { auth: 1 } : {}), ...(flags.titles ? { title: r.title, ...(r.ask ? { ask: r.ask } : {}), ...(r.menu && r.menu.about ? { about: r.menu.about } : {}), ...(r.gave ? { gave: r.gave } : {}) } : {}) })) }, null, 2)); // since: when it started to wait, ran: how long it worked before · with --titles only, what the sessions say (it can hold a path, a command or a secret): ask, the question or command that waits for you, about, what that command is for, gave, the error it stopped on
|
|
123
182
|
else console.log(line(s, false));
|
package/kokoro-worker.js
CHANGED
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
// writes a 16-bit WAV to `out` and answers { id, ok, seconds } or { id, ok: false, error }. Started by kokoro.js.
|
|
4
4
|
const fs = require('fs'), path = require('path'), readline = require('readline'), { createRequire } = require('module'), { pathToFileURL } = require('url');
|
|
5
5
|
const MODEL = 'onnx-community/Kokoro-82M-v1.0-ONNX';
|
|
6
|
+
// Chinese is another model of the same family, Kokoro-82M-v1.1-zh, in full precision: on an M1 Pro the 8-bit file was twice as slow, and the half-precision one returned silence (NaN) for most voices.
|
|
7
|
+
// kokoro.js puts its files, checked, where transformers.js keeps what it downloads, so loading it here reads them from disk. Its phonemes come from zh-g2p.js, its voices from <dir>/zh-voices.
|
|
8
|
+
const ZH_MODEL = 'onnx-community/Kokoro-82M-v1.1-zh-ONNX', ZH_DTYPE = 'fp32';
|
|
6
9
|
const send = (o) => fs.writeSync(1, JSON.stringify(o) + '\n');
|
|
7
10
|
const finite = (samples) => { for (let i = 0; i < samples.length; i++) if (samples[i] !== samples[i]) return false; return true; }; // a quantised model can return NaN for a whole line, which would be written as silence
|
|
8
11
|
function wav(samples, rate) { // Float32 in [-1, 1] → 16-bit mono WAV
|
|
@@ -15,7 +18,7 @@ const FILE = { q8: 'model_quantized', q4: 'model_q4', fp32: 'model', fp16: 'mode
|
|
|
15
18
|
// The model takes 510 phonemes per call (about 480 letters of plain English, 300 when the line is full of numbers) and kokoro-js cuts the rest without a word:
|
|
16
19
|
// a line that does not fit is made in parts and joined. LONG is what the tokenizer throws instead of cutting (see main).
|
|
17
20
|
const LONG = new Error('too long for one call'), QUIET = 0.003;
|
|
18
|
-
const CUTS = [[/[.!?…]+["'”’»)\]]*\s+(?![\sa-zà-ÿ])|\s*\n\s*/g, 0.45], [/[,;:—–]\s
|
|
21
|
+
const CUTS = [[/[.!?…]+["'”’»)\]]*\s+(?![\sa-zà-ÿ])|\s*\n\s*|[。!?]+[”’」』)]*\s*/g, 0.45], [/[,;:—–]\s+|[,、;:]\s*/g, 0.2], [/\s+/g, 0.05]]; // where a line may be cut, best first, each with the pause it gets in seconds at speed 1: the end of a sentence, a comma, a space (Chinese marks need no space after them)
|
|
19
22
|
function halve(s) { // two parts at the cut nearest the middle, so no part is a stray word; a text with no space at all is cut in the middle
|
|
20
23
|
for (const [re, gap] of CUTS) { let at = 0; for (const m of s.matchAll(re)) { const i = m.index + m[0].length; if (i < s.length && Math.abs(i - s.length / 2) < Math.abs(at - s.length / 2)) at = i; } if (at) return [s.slice(0, at), s.slice(at), gap]; }
|
|
21
24
|
const at = Math.ceil(s.length / 2); return [s.slice(0, at), s.slice(at), 0];
|
|
@@ -59,13 +62,17 @@ async function main() {
|
|
|
59
62
|
for (const ext of ['.onnx', '.onnx_data']) { try { fs.unlinkSync(path.join(onnx, name + ext)); dropped++; } catch {} }
|
|
60
63
|
if (!dropped) throw e; console.error('kokoro: the ' + dtype + ' model could not be loaded (' + String((e && e.message) || e).slice(0, 80) + '); fetching it again'); tts = await load();
|
|
61
64
|
}
|
|
62
|
-
const tok =
|
|
63
|
-
|
|
64
|
-
const packs = new Map(), pack = (n) => { if (!packs.has(n)) { const b = fs.readFileSync(path.join(dir, 'node_modules', 'kokoro-js', 'voices', n + '.bin')); packs.set(n, new Float32Array(b.buffer.slice(b.byteOffset, b.byteOffset + b.length))); } return packs.get(n); }; // a voice: 510 styles of 256 numbers, one per length of line. All 54 come with kokoro-js
|
|
65
|
+
const strict = (m) => { const tok = m.tokenizer; if (tok) m.tokenizer = (t, o) => { const r = tok(t, { ...o, truncation: false }); if (r.input_ids.dims.at(-1) > (tok.model_max_length || 512)) throw LONG; return r; }; return m; };
|
|
66
|
+
strict(tts); // kokoro-js calls the tokenizer with truncation on, which drops every phoneme past the model's limit and says nothing: count them all here and refuse instead
|
|
67
|
+
const packs = new Map(), pack = (n) => { if (!packs.has(n)) { const b = fs.readFileSync(/^z[fm]_/.test(n) ? path.join(dir, 'zh-voices', n + '.bin') : path.join(dir, 'node_modules', 'kokoro-js', 'voices', n + '.bin')); packs.set(n, new Float32Array(b.buffer.slice(b.byteOffset, b.byteOffset + b.length))); } return packs.get(n); }; // a voice: 510 styles of 256 numbers, one per length of line. All 54 of v1.0 come with kokoro-js; the Chinese ones are fetched by kokoro.js
|
|
68
|
+
let zh = null; // the Chinese model and its phonemizer, loaded on the first Chinese line: whoever never hears one never loads them
|
|
69
|
+
const zhLoad = async () => zh || (zh = { tts: strict(await KokoroTTS.from_pretrained(ZH_MODEL, { dtype: ZH_DTYPE, device: 'cpu' })), g2p: require(path.join(__dirname, 'zh-g2p.js')).make(req('pinyin-pro'), req('jieba-wasm'), req('opencc-js').Converter({ from: 'tw', to: 'cn' })) });
|
|
65
70
|
const foreign = async (text, o) => { // what kokoro-js' generate_from_ids does, with a style that can be a mix of several voices (o.mix: [[voice, share], …])
|
|
66
|
-
const
|
|
71
|
+
const z = o.lang === 'zh' ? await zhLoad() : null, m = z ? z.tts : tts; // Chinese: its own model; an English word inside the line is said from its English phonemes
|
|
72
|
+
const ph = z ? await z.g2p(text, (w) => phonemes(dir, w, 'en-us')) : await phonemes(dir, text, o.lang);
|
|
73
|
+
const { input_ids } = m.tokenizer(ph, { truncation: true }), at = 256 * Math.min(Math.max(input_ids.dims.at(-1) - 2, 0), 509), style = new Float32Array(256);
|
|
67
74
|
for (const [name, share] of o.mix) { const v = pack(name); for (let i = 0; i < 256; i++) style[i] += share * v[at + i]; }
|
|
68
|
-
const { waveform } = await
|
|
75
|
+
const { waveform } = await m.model({ input_ids, style: new tf.Tensor('float32', style, [1, 256]), speed: new tf.Tensor('float32', [o.speed], [1]) });
|
|
69
76
|
return { audio: waveform.data, sampling_rate: 24000 };
|
|
70
77
|
};
|
|
71
78
|
const say = (text, o) => (o.lang ? foreign(text, o) : tts.generate(text, { voice: o.voice, speed: o.speed }));
|
package/kokoro.js
CHANGED
|
@@ -1,12 +1,36 @@
|
|
|
1
1
|
// Natural voices with Kokoro-82M (kokoro-js on ONNX Runtime), installed on demand outside the extension.
|
|
2
2
|
// Nothing here runs until the person clicks Install in ⚙ → Sound: the packages (about 430 MB) go to one user folder, the model (about 155 MB) is fetched on first use.
|
|
3
3
|
// French, Spanish and Brazilian Portuguese are the same model: kokoro-js only reads English, so the install adds a full eSpeak NG (WebAssembly, 18 MB, GPL: fetched by npm like the rest, never shipped with the app) for the phonemes. See kokoro-worker.js.
|
|
4
|
-
|
|
4
|
+
// German, Danish, Japanese and Korean, which Kokoro has no voice for, are another model, Supertonic 3, on the onnxruntime-node that kokoro-js brings: about 400 MB more, fetched from Hugging Face only when
|
|
5
|
+
// the person adds the voices of one of these languages (install({ st: true })), at a fixed revision, each file checked against its size and SHA-256 before it is kept. See supertonic-worker.js.
|
|
6
|
+
// Chinese (Simplified and Traditional, both Mandarin) is Kokoro's own Chinese model, Kokoro-82M-v1.1-zh, in the same worker as Kokoro: install({ zh: true }) adds three npm packages for its phonemes
|
|
7
|
+
// (pinyin-pro, jieba-wasm, opencc-js; see zh-g2p.js) and fetches the model in full precision and eight of its voices the same checked way, about 365 MB in all.
|
|
8
|
+
const fs = require('fs'), os = require('os'), path = require('path'), http = require('http'), https = require('https'), crypto = require('crypto'), { spawn } = require('child_process');
|
|
5
9
|
|
|
6
10
|
const WIN = process.platform === 'win32';
|
|
7
11
|
const DIR = process.env.AGENT_STANDUP_KOKORO_DIR || (WIN ? path.join(process.env.LOCALAPPDATA || path.join(os.homedir(), 'AppData', 'Local'), 'agent-standup', 'kokoro') : path.join(os.homedir(), '.cache', 'agent-standup', 'kokoro'));
|
|
8
12
|
const PKG = 'kokoro-js@1.2.1', G2P = 'espeak-ng@1.0.2', G2P_MB = 18, DTYPE = 'q4', SIZE_MB = 750, MAX_RESTARTS = 3;
|
|
9
13
|
const WORKER = process.env.AGENT_STANDUP_KOKORO_WORKER || path.join(__dirname, 'kokoro-worker.js'), LOG = path.join(DIR, 'install.log');
|
|
14
|
+
const ST_WORKER = process.env.AGENT_STANDUP_ST_WORKER || path.join(__dirname, 'supertonic-worker.js'), ST_DIR = path.join(DIR, 'supertonic-3');
|
|
15
|
+
const ST_URL = process.env.AGENT_STANDUP_ST_URL || 'https://huggingface.co/Supertone/supertonic-3/resolve/3cadd1ee6394adea1bd021217a0e650ede09a323/'; // the revision of 18 May 2026; the upstream repository is archived
|
|
16
|
+
const ST_FILES = [['onnx/duration_predictor.onnx', 3700147, 'c3eb91414d5ff8a7a239b7fe9e34e7e2bf8a8140d8375ffb14718b1c639325db'], ['onnx/text_encoder.onnx', 36416150, 'c7befd5ea8c3119769e8a6c1486c4edc6a3bc8365c67621c881bbb774b9902ff'],
|
|
17
|
+
['onnx/vector_estimator.onnx', 256534781, '883ac868ea0275ef0e991524dc64f16b3c0376efd7c320af6b53f5b780d7c61c'], ['onnx/vocoder.onnx', 101424195, '085de76dd8e8d5836d6ca66826601f615939218f90e519f70ee8a36ed2a4c4ba'],
|
|
18
|
+
['onnx/tts.json', 8253, '42078d3aef1cd43ab43021f3c54f47d2d75ceb4e75f627f118890128b06a0d09'], ['onnx/unicode_indexer.json', 277676, '9bf7346e43883a81f8645c81224f786d43c5b57f3641f6e7671a7d6c493cb24f'], ['LICENSE', 15007, '0d944a9110fed9a9602d60e0423a272903e7bd21ab060490774efc77c2275e9f'],
|
|
19
|
+
['voice_styles/F1.json', 292046, 'bbdec6ee00231c2c742ad05483df5334cab3b52fda3ba38e6a07059c4563dbc2'], ['voice_styles/F2.json', 292423, '7c722c6a72707b1a77f035d67f0d1351ba187738e06f7683e8c72b1df3477fc6'], ['voice_styles/F3.json', 290794, '12f6ef2573baa2defa1128069cb59f203e3ab67c92af77b42df8a0e3a2f7c6ab'],
|
|
20
|
+
['voice_styles/F4.json', 291808, 'c2fa764c1225a76dfc3e2c73e8aa4f70d9ee48793860eb34c295fff01c2e032b'], ['voice_styles/M1.json', 291748, 'e35604687f5d23694b8e91593a93eec0e4eca6c0b02bb8ed69139ab2ea6b0a5b'], ['voice_styles/M2.json', 292055, 'b76cbf62bac707c710cf0ae5aba5e31eea1a6339a9734bfae33ab98499534a50'],
|
|
21
|
+
['voice_styles/M3.json', 290198, 'ea1ac35ccb91b0d7ecad533a2fbd0eec10c91513d8951e3b25fbba99954e159b'], ['voice_styles/M4.json', 291522, 'ca8eefad4fcd989c9379032ff3e50738adc547eeb5e221b82593a6d7b3bac303']];
|
|
22
|
+
if (process.env.AGENT_STANDUP_ST_FILES) ST_FILES.splice(0, ST_FILES.length, ...JSON.parse(process.env.AGENT_STANDUP_ST_FILES)); // the tests: small files of their own, served by a local server
|
|
23
|
+
const ST_MB = () => Math.round(ST_FILES.reduce((n, f) => n + f[1], 0) / 1e6);
|
|
24
|
+
const ZH_REPO = 'onnx-community/Kokoro-82M-v1.1-zh-ONNX', ZH_PKGS = ['pinyin-pro@3.29.5', 'jieba-wasm@2.4.0', 'opencc-js@1.4.2'], ZH_PKG_MB = 23;
|
|
25
|
+
const ZH_URL = process.env.AGENT_STANDUP_ZH_URL || 'https://huggingface.co/onnx-community/Kokoro-82M-v1.1-zh-ONNX/resolve/6cc0f0d2ebe369a68b0df87c2b65c1af8c0ac3e3/'; // the revision of 5 July 2025
|
|
26
|
+
// The cast: in the order agents get them, a woman and a man in turn as in English, each character keeping its English name. Among the 40 of the 100 Chinese voices tried, a speech recogniser understood
|
|
27
|
+
// all about as well (2026-11-14), so they are chosen to sound apart: their pitches spread from 102 to 289 Hz.
|
|
28
|
+
const ZH_CAST = [['zf_001', 'Heart', '0a89ec12bb93fb9c74077924daf02568baad64e1f869389f5aaee01a386035f8'], ['zm_010', 'Fenrir', '73b088f7e0dc47adca4d6a642ee68843df90ff56ec2800c29d96609989d6de0a'], ['zf_038', 'Emma', '569bb54ebf05c00c89eaf56218992474a8a0494d8f94a14e933ae6a5ea9f7e31'], ['zm_029', 'Michael', 'ff78cb9f64d43fe6179c9479257775bea94dc31eade9362b0c630749025d8ecd'], ['zf_019', 'Bella', 'ab5906846335ac1227c47fd04be8b7b10a47c3ee77729296cc4c0f3f8fe79073'], ['zm_016', 'George', '4dc408a11f1e8925ff8bca40c885e7596d08be63c2c61571234b96170f8e6d1b'], ['zf_036', 'Sarah', 'b72873066ef9d57d4ea0605d32a82b2655010af51edbaecd6f926250d84efa4e'], ['zm_030', 'Puck', '32f8fe4d5f626dfb67adb73499690fd4f5952763746efbcadcf2daad4a3560a6']]; // [voice, name, SHA-256]; median pitch 249, 136, 289, 102, 168, 155, 202, 122 Hz
|
|
29
|
+
const ZH_FILES = [['onnx/model.onnx', 339369442, '94b973941b1852754f979be5d5e20be666d5c81d9bb886b88ae1dc85c9b895ca'], ['config.json', 44, 'df34b4f930b23447cd4dc410fabfb42eb3f24e803e6c3f97d618fb359380a36f'],
|
|
30
|
+
['tokenizer.json', 4944, '5715a60b09d5e4b9074435d68c6ccd5675b9d48b220e109fdea3cda681e23d15'], ['tokenizer_config.json', 113, 'be1cb066d6ef6b074b3f15e6a6dd21ac88ff3cdaedf325f0aaed686c70f75d20'], ...ZH_CAST.map(([v, , sha]) => ['voices/' + v + '.bin', 522240, sha])];
|
|
31
|
+
if (process.env.AGENT_STANDUP_ZH_FILES) ZH_FILES.splice(0, ZH_FILES.length, ...JSON.parse(process.env.AGENT_STANDUP_ZH_FILES));
|
|
32
|
+
const zhPath = (f) => (f.startsWith('voices/') ? path.join(DIR, 'zh-voices', path.basename(f)) : path.join(DIR, 'models', ...ZH_REPO.split('/'), f)); // the model where transformers.js keeps what it downloads: the worker then loads it from disk
|
|
33
|
+
const ZH_MB = () => Math.round(ZH_FILES.reduce((n, f) => n + f[1], 0) / 1e6) + ZH_PKG_MB;
|
|
10
34
|
|
|
11
35
|
// In the order agents get them (the lead takes the first), so successive agents sound distinct.
|
|
12
36
|
const EN = [['af_heart', 'Heart', 'en_US'], ['am_fenrir', 'Fenrir', 'en_US'], ['bf_emma', 'Emma', 'en_GB'], ['am_michael', 'Michael', 'en_US'], ['af_bella', 'Bella', 'en_US'], ['bm_george', 'George', 'en_GB'], ['af_sarah', 'Sarah', 'en_US'], ['am_puck', 'Puck', 'en_US']].map(([name, label, locale]) => ({ name, label, locale }));
|
|
@@ -21,13 +45,20 @@ const FR = [['ff_siwis', 'Siwis', null, 1], ['fr_fenrir', 'Fenrir', 'am_fenrir',
|
|
|
21
45
|
const cast = (pre, locale, lang, f, m, m2) => [[f, 'Dora', [[f, 1]]], [m, 'Alex', [[m, 1]]], [pre + '_emma', 'Emma', [[f, 0.5], ['bf_emma', 0.5]]], [pre + '_michael', 'Michael', [[m2, 0.5], ['am_michael', 0.5]]], [pre + '_bella', 'Bella', [[f, 0.5], ['af_bella', 0.5]]], [pre + '_george', 'George', [[m2, 0.5], ['bm_george', 0.5]]], [pre + '_sarah', 'Sarah', [[f, 0.5], ['af_sarah', 0.5]]], [pre + '_puck', 'Puck', [[m, 0.5], ['am_puck', 0.5]]]]
|
|
22
46
|
.map(([name, label, mix]) => ({ name, label, locale, lang, mix }));
|
|
23
47
|
const ES = cast('es', 'es_ES', 'es', 'ef_dora', 'em_alex', 'em_santa'), PT = cast('pt', 'pt_BR', 'pt-br', 'pf_dora', 'pm_alex', 'pm_santa');
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
const
|
|
48
|
+
// German, Danish, Japanese and Korean: Supertonic 3's voices are the same in every language it speaks. Eight of its ten, a woman and a man in turn as in English, each character keeping its English name.
|
|
49
|
+
const ST_CAST = [['F1', 'Heart'], ['M1', 'Fenrir'], ['F2', 'Emma'], ['M2', 'Michael'], ['F3', 'Bella'], ['M3', 'George'], ['F4', 'Sarah'], ['M4', 'Puck']];
|
|
50
|
+
const stCast = (lang, locale) => ST_CAST.map(([st, label]) => ({ name: lang + '_' + label.toLowerCase(), label, locale, st, stLang: lang }));
|
|
51
|
+
const ZH = ZH_CAST.map(([v, label]) => ({ name: 'zh_' + label.toLowerCase(), label, locale: 'zh_CN', lang: 'zh', mix: [[v, 1]], zh: true }));
|
|
52
|
+
const VOICES = [...EN, ...FR, ...ES, ...PT, ...stCast('de', 'de_DE'), ...stCast('da', 'da_DK'), ...stCast('ja', 'ja_JP'), ...stCast('ko', 'ko_KR'), ...ZH], find = (n) => VOICES.find((v) => v.name === n);
|
|
53
|
+
const voices = () => VOICES.filter((v) => (v.zh ? zhInstalled() : v.st ? installed() && stInstalled() : !v.lang || g2p())).map(({ name, label, locale }) => ({ name, label, locale })), hasVoice = (n) => !!find(n); // the ones that are not English are listed once their phonemizer or their model is there
|
|
54
|
+
const localeOf = (n) => (find(n) || EN[0]).locale, natural = (n) => !!((find(n) || {}).st || (find(n) || {}).zh); // natural: a Supertonic or Chinese voice, which never hands its line to a system voice
|
|
27
55
|
const speedFor = (wpm) => Math.max(0.5, Math.min(2, Math.round((wpm / 178) * 20) / 20)); // 178 words a minute is about Kokoro's natural pace
|
|
28
56
|
const exists = (f) => { try { fs.statSync(f); return true; } catch { return false; } };
|
|
29
57
|
const installed = () => exists(path.join(DIR, 'node_modules', 'kokoro-js', 'package.json'));
|
|
30
58
|
const g2p = () => installed() && exists(path.join(DIR, 'node_modules', 'espeak-ng', 'package.json')); // an install made before the other languages were added has kokoro-js alone: the same button adds the phonemizer
|
|
59
|
+
const size = (f) => { try { return fs.statSync(f).size; } catch { return -1; } }, whole = (files, at) => files.every(([f, n]) => size(at(f)) === n); // a file is renamed into place only once checked
|
|
60
|
+
const stInstalled = () => whole(ST_FILES, (f) => path.join(ST_DIR, f));
|
|
61
|
+
const zhPkgs = () => ZH_PKGS.every((p) => exists(path.join(DIR, 'node_modules', p.slice(0, p.lastIndexOf('@')), 'package.json'))), zhInstalled = () => g2p() && zhPkgs() && whole(ZH_FILES, zhPath);
|
|
31
62
|
|
|
32
63
|
function findNpm() {
|
|
33
64
|
const home = os.homedir(), names = WIN ? ['npm.cmd', 'npm.bat', 'npm'] : ['npm'], cands = [];
|
|
@@ -38,13 +69,17 @@ function findNpm() {
|
|
|
38
69
|
return cands.find((c) => c && exists(c)) || null;
|
|
39
70
|
}
|
|
40
71
|
|
|
41
|
-
// ---- install: `npm install --prefix DIR kokoro-js@x espeak-ng@y`, output in DIR/install.log, one job at a time
|
|
72
|
+
// ---- install: `npm install --prefix DIR kokoro-js@x espeak-ng@y`, output in DIR/install.log, one job at a time; with { st: true }, the Supertonic files as well, fetched beside it;
|
|
73
|
+
// with { zh: true }, the three packages of the Chinese phonemes in the same npm run, and the Chinese model and voices fetched beside it
|
|
42
74
|
let job = null, lastError = '';
|
|
43
|
-
function install() {
|
|
44
|
-
|
|
75
|
+
function install(o = {}) {
|
|
76
|
+
const sets = [o.st && !stInstalled() && 'st', o.zh && !whole(ZH_FILES, zhPath) && 'zh'].filter(Boolean);
|
|
77
|
+
if (sets.length && !dl && (installed() || job || findNpm())) fetchSets(sets); // useless without the npm part (onnxruntime-node, kokoro-js), which is started below when it is missing
|
|
78
|
+
const zh = o.zh && !zhPkgs(), pkgs = g2p() && !zh ? [] : [PKG, G2P, ...(zh ? ZH_PKGS : [])]; // Kokoro's own packages always named with the others: npm removes from the folder whatever its package.json does not list
|
|
79
|
+
if (job || !pkgs.length) return status();
|
|
45
80
|
const npm = findNpm(); if (!npm) { lastError = 'npm not found'; return status(); }
|
|
46
81
|
fs.mkdirSync(DIR, { recursive: true }); lastError = '';
|
|
47
|
-
const out = fs.openSync(LOG, 'w'), args = ['install', '--prefix', DIR, '--no-audit', '--no-fund',
|
|
82
|
+
const out = fs.openSync(LOG, 'w'), args = ['install', '--prefix', DIR, '--no-audit', '--no-fund', ...pkgs];
|
|
48
83
|
const env = { ...process.env }, pk = Object.keys(env).find((k) => k.toUpperCase() === 'PATH') || 'PATH'; env[pk] = path.dirname(npm) + path.delimiter + (env[pk] || ''); // npm starts with `#!/usr/bin/env node`: an editor or app opened from the Dock has a PATH without node's folder (exit 127, issue #11), and node sits next to npm
|
|
49
84
|
job = WIN && /\.(cmd|bat)$/i.test(npm) ? spawn('"' + npm + '"', args.map((a) => (a === DIR ? '"' + a + '"' : a)), { shell: true, env, stdio: ['ignore', out, out], windowsHide: true }) : spawn(npm, args, { env, stdio: ['ignore', out, out], windowsHide: true });
|
|
50
85
|
const done = (why) => { job = null; try { fs.closeSync(out); } catch {} if (why) lastError = why; else warm(); };
|
|
@@ -53,48 +88,83 @@ function install() {
|
|
|
53
88
|
return status();
|
|
54
89
|
}
|
|
55
90
|
|
|
56
|
-
// ----
|
|
57
|
-
let
|
|
58
|
-
function
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
91
|
+
// ---- the Supertonic and Chinese files, one after the other: each goes to <name>.part, is checked (size and SHA-256), then renamed. A file already there whole is kept, so a download cut short goes on where it stopped.
|
|
92
|
+
let dl = null, dlError = '';
|
|
93
|
+
function get(url, file, [, size, sha], hops = 0) {
|
|
94
|
+
return new Promise((resolve, reject) => {
|
|
95
|
+
let abort = null; // set once the answer is coming in: from then on every failure goes through fail(), so the half file is gone before the answer
|
|
96
|
+
const req = (url.startsWith('http:') ? http : https).get(url, { headers: /* http: only the tests' local server */ { 'user-agent': 'agent-standup' } }, (res) => {
|
|
97
|
+
if ([301, 302, 303, 307, 308].includes(res.statusCode) && res.headers.location && hops < 6) { res.resume(); return get(new URL(res.headers.location, url).href, file, [, size, sha], hops + 1).then(resolve, reject); } // Hugging Face hands the large files to its CDN
|
|
98
|
+
if (res.statusCode !== 200) { res.resume(); return reject(new Error('HTTP ' + res.statusCode)); }
|
|
99
|
+
const h = crypto.createHash('sha256'), part = file + '.part', out = fs.createWriteStream(part); let n = 0;
|
|
100
|
+
let failed = false; const fail = abort = (e) => { if (failed) return; failed = true; /* the first cause is the one told: a cut connection also makes the half file say "write after destroyed" */ res.destroy(); const gone = () => fs.rm(part, { force: true }, () => reject(e)); if (out.closed) gone(); else { out.once('close', gone); out.destroy(); } }; // the half file is gone before the answer: a second try starts a new one of the same name
|
|
101
|
+
res.on('data', (d) => { h.update(d); n += d.length; if (dl) dl.done += d.length; }); res.on('error', (e) => fail(e && e.message === 'aborted' ? new Error('connection cut') : e)); out.on('error', fail); // 'aborted' is what node says of a connection reset mid-body
|
|
102
|
+
res.on('close', () => { if (!res.complete) fail(new Error('connection cut')); });
|
|
103
|
+
out.on('finish', () => { if (n !== size || h.digest('hex') !== sha) return fail(new Error('a file arrived damaged')); try { fs.renameSync(part, file); resolve(); } catch (e) { fail(e); } });
|
|
104
|
+
res.pipe(out);
|
|
105
|
+
});
|
|
106
|
+
req.on('error', (e) => (abort ? abort(e) : reject(e))); req.setTimeout(60e3, () => req.destroy(new Error('no answer from Hugging Face')));
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
const CUT = /connection cut|no answer|ECONNRESET|ECONNABORTED|EPIPE|ETIMEDOUT|EAI_AGAIN|socket hang up|HTTP 5\d\d/; // a cut connection, a stalled one or a server error: worth another try; a missing file (HTTP 404, and other 4xx), an address that does not resolve or a refused connection (ENOTFOUND, ECONNREFUSED) or a damaged file is not
|
|
110
|
+
async function getRetrying(url, to, f) { // up to three tries a file, a short pause between them, the progress taken back to where the file began
|
|
111
|
+
for (let at = 1, from = dl ? dl.done : 0; ; at++) { try { return await get(url, to, f); } catch (e) { if (at >= 3 || !CUT.test(String((e && (e.code || e.message)) || e))) throw e; if (dl) dl.done = from; await new Promise((r) => setTimeout(r, 1000 * at)); } }
|
|
112
|
+
}
|
|
113
|
+
const SETS = { st: { files: ST_FILES, url: () => ST_URL, at: (f) => path.join(ST_DIR, f) }, zh: { files: ZH_FILES, url: () => ZH_URL, at: zhPath } };
|
|
114
|
+
function fetchSets(names) {
|
|
115
|
+
dlError = ''; const todo = []; for (const n of names) { const S = SETS[n]; for (const f of S.files) if (size(S.at(f[0])) !== f[1]) todo.push([S.url() + f[0], S.at(f[0]), f]); }
|
|
116
|
+
dl = { done: 0, total: todo.reduce((n, t) => n + t[2][1], 0) };
|
|
117
|
+
(async () => { for (const [url, to, f] of todo) { fs.mkdirSync(path.dirname(to), { recursive: true }); await getRetrying(url, to, f); } })()
|
|
118
|
+
.then(() => { dl = null; }, (e) => { dl = null; dlError = 'download: ' + String((e && e.message) || e).slice(0, 120); });
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// ---- workers: one child process per model (Kokoro; Supertonic for German, Danish, Japanese and Korean), each started on first use and restarted after a crash up to MAX_RESTARTS times.
|
|
122
|
+
// One line at a time across both. The Supertonic one only starts when a line in one of its languages comes, so whoever never hears them never loads its 400 MB.
|
|
123
|
+
const W = { k: { script: () => WORKER, env: { AGENT_STANDUP_KOKORO_DTYPE: DTYPE }, name: 'kokoro', w: null, restarts: 0, err: (e) => { lastError = e; } }, s: { script: () => ST_WORKER, env: { AGENT_STANDUP_ST_DIR: ST_DIR }, name: 'supertonic', w: null, restarts: 0, err: (e) => { dlError = e; } } };
|
|
124
|
+
let seq = 0; const queue = []; let busy = false;
|
|
125
|
+
function startWorker(kind = 'k') {
|
|
126
|
+
const K = W[kind]; if (K.w) return K.w;
|
|
127
|
+
if (K.restarts >= MAX_RESTARTS) throw new Error(K.name + ' worker gave up');
|
|
128
|
+
const p = spawn(process.execPath, [K.script()], { env: { ...process.env, ELECTRON_RUN_AS_NODE: '1', AGENT_STANDUP_KOKORO_DIR: DIR, ...K.env }, stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true });
|
|
129
|
+
const w = (K.w = { p, ready: false, pending: new Map(), err: '' }); let buf = '';
|
|
63
130
|
p.stdout.on('data', (d) => {
|
|
64
131
|
buf += d; let i;
|
|
65
132
|
while ((i = buf.indexOf('\n')) >= 0) {
|
|
66
133
|
const line = buf.slice(0, i); buf = buf.slice(i + 1); let m; try { m = JSON.parse(line); } catch { continue; } // library chatter is ignored
|
|
67
|
-
if (m.ready) { w.ready = true;
|
|
134
|
+
if (m.ready) { w.ready = true; K.err(''); continue; }
|
|
68
135
|
const r = w.pending.get(m.id); if (!r) continue; w.pending.delete(m.id); m.ok ? r.resolve(m) : r.reject(new Error(m.error || 'tts failed'));
|
|
69
136
|
}
|
|
70
137
|
});
|
|
71
138
|
p.stderr.on('data', (d) => { w.err = (w.err + d).slice(-600); }); p.stdin.on('error', () => {});
|
|
72
|
-
const gone = (why) => { if (
|
|
73
|
-
p.on('error', (e) => gone('
|
|
139
|
+
const gone = (why) => { if (K.w !== w) return; K.w = null; K.restarts++; K.err(why); const jobs = [...w.pending.values()]; w.pending.clear(); busy = false; for (const r of jobs) r.reject(new Error(why)); };
|
|
140
|
+
p.on('error', (e) => gone(K.name + ' worker: ' + e.message)); p.on('close', (code) => gone(K.name + ' worker exited (' + code + ') ' + (w.err.trim().split('\n').pop() || '')));
|
|
74
141
|
return w;
|
|
75
142
|
}
|
|
76
|
-
function warm() { if (installed() && !
|
|
143
|
+
function warm() { if (installed() && !W.k.w && W.k.restarts < MAX_RESTARTS) try { startWorker('k'); } catch {} }
|
|
77
144
|
function pump() {
|
|
78
145
|
if (busy || !queue.length) return;
|
|
79
|
-
const j = queue.shift(); let w; try { w = startWorker(); } catch (e) { j.reject(e); return pump(); }
|
|
80
|
-
const id = ++seq, late = setTimeout(() => { if (w.pending.has(id)) {
|
|
81
|
-
const next = (fn, ok) => (
|
|
146
|
+
const j = queue.shift(), v = find(j.voice), kind = v.st ? 's' : 'k', K = W[kind]; let w; try { w = startWorker(kind); } catch (e) { j.reject(e); return pump(); }
|
|
147
|
+
const id = ++seq, late = setTimeout(() => { if (w.pending.has(id)) { K.err(K.name + ' worker: no answer'); try { w.p.kill(); } catch {} } }, w.ready ? Math.max(60e3, j.text.length * 80) : 180e3); // a worker that hangs is stopped (and started again on the next line): every line after it waited for ever. Supertonic takes about 40 ms a letter in Japanese
|
|
148
|
+
const next = (fn, ok) => (r) => { clearTimeout(late); busy = false; if (ok) K.restarts = 0; fn(r); pump(); }; busy = true; // ok: a line spoken, the count of crashes starts again (three over days of an open editor turned the voices off)
|
|
82
149
|
w.pending.set(id, { resolve: next(j.resolve, true), reject: next(j.reject) });
|
|
83
|
-
|
|
84
|
-
w.p.stdin.write(JSON.stringify({ id, text: j.text, voice: j.voice, speed: j.speed, out: j.out, lang: v.lang, mix: v.mix }) + '\n');
|
|
150
|
+
w.p.stdin.write(JSON.stringify(v.st ? { id, text: j.text, voice: v.st, lang: v.stLang, speed: j.speed, out: j.out } : { id, text: j.text, voice: j.voice, speed: j.speed, out: j.out, lang: v.lang, mix: v.mix }) + '\n');
|
|
85
151
|
}
|
|
86
152
|
function synth(text, voice, speed, out) {
|
|
87
153
|
if (!installed()) return Promise.reject(new Error('kokoro not installed'));
|
|
88
154
|
if (!hasVoice(voice)) return Promise.reject(new Error('unknown voice'));
|
|
155
|
+
if (find(voice).st && !stInstalled()) return Promise.reject(new Error('supertonic not installed'));
|
|
156
|
+
if (find(voice).zh && !zhInstalled()) return Promise.reject(new Error('chinese voices not installed'));
|
|
89
157
|
return new Promise((resolve, reject) => { queue.push({ text: String(text).slice(0, 2500), voice, speed, out, resolve, reject }); pump(); });
|
|
90
158
|
}
|
|
91
159
|
function status() {
|
|
92
160
|
let log = ''; try { log = fs.readFileSync(LOG, 'utf8').slice(-400); } catch {}
|
|
93
|
-
|
|
161
|
+
const k = W.k.w, sw = W.s.w;
|
|
162
|
+
return { dir: DIR, sizeMb: SIZE_MB, installed: installed(), g2p: g2p(), g2pMb: G2P_MB, installing: !!job || !!dl, ready: !!(k && k.ready), gaveUp: W.k.restarts >= MAX_RESTARTS, error: lastError || null, npm: !!findNpm(), log,
|
|
163
|
+
st: stInstalled(), stMb: ST_MB(), stReady: !!(sw && sw.ready), stGaveUp: W.s.restarts >= MAX_RESTARTS, zh: zhInstalled(), zhMb: ZH_MB(), dlPct: dl ? Math.floor((100 * dl.done) / Math.max(1, dl.total)) : null, dlError: dlError || null }; // st: the Supertonic files are there (German, Danish, Japanese, Korean); zh: the Chinese packages and files
|
|
94
164
|
}
|
|
95
165
|
function shutdown() {
|
|
96
166
|
for (const j of queue.splice(0)) j.reject(new Error('kokoro shut down'));
|
|
97
|
-
if (
|
|
167
|
+
for (const K of Object.values(W)) if (K.w) { const w = K.w; K.w = null; try { w.p.kill(); } catch {} for (const r of w.pending.values()) r.reject(new Error('kokoro shut down')); w.pending.clear(); }
|
|
98
168
|
busy = false; if (job) { try { job.kill(); } catch {} job = null; }
|
|
99
169
|
}
|
|
100
|
-
module.exports = { DIR, voices, hasVoice, localeOf, speedFor, status, install, warm, synth, shutdown };
|
|
170
|
+
module.exports = { DIR, voices, hasVoice, localeOf, natural, speedFor, status, install, warm, synth, shutdown };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@double_geste/agent-standup",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.47.1",
|
|
4
4
|
"description": "Your Claude Code, Codex and Mistral Vibe agents as a live video call, from the terminal: a local page in your browser, plus one-line status for status bars. Free, open source, zero token cost.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"agent-standup": "bin/agent-standup.js"
|
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
"reply.js",
|
|
16
16
|
"kokoro.js",
|
|
17
17
|
"kokoro-worker.js",
|
|
18
|
+
"supertonic-worker.js",
|
|
19
|
+
"zh-g2p.js",
|
|
18
20
|
"demo.js",
|
|
19
21
|
"public",
|
|
20
22
|
"examples",
|