@double_geste/agent-standup 1.45.0 → 1.47.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.
@@ -26,4 +26,4 @@ Command titles and setting descriptions use VS Code's own mechanism: `package.nl
26
26
  They work the same way, with their own files: `website/locales/<code>.json` (agent-standup.com, one page per language, written by `npm run website`) and `landing/locales/<code>.json` (the landing page, which fetches the file of the chosen language). English and French are in the pages themselves (`data-en` / `data-fr` in `website/src/home.html` and `landing/template.html`). `node scripts/site-locales.js extract` regenerates the two `en.json`, and `npm run i18n` checks these files too. Keep the HTML tags of a text exactly as in the English.
27
27
 
28
28
  ## What is *not* translated
29
- The words agents say come from your session (their own language), unless the call is held in French, Spanish or Brazilian Portuguese: these three are in the code (`CALL_LANG` in `public/index.html`), each with its own little banter lines (answers to orders, goodbyes) next to the English and French ones, its voices and its translation. Another language needs all of these, not only a catalogue. The built-in demo exists in English and French only.
29
+ The words agents say come from your session (their own language), unless the call is held in French, Spanish, Brazilian Portuguese, German, Danish, Japanese, Korean or Chinese: these eight are in the code (Chinese twice, Simplified `zh` and Traditional `zt`) (`CALL_LANG` in `public/index.html`), each with its own little banter lines (answers to orders, goodbyes) next to the English and French ones, its voices and its translation. Another language needs all of these, not only a catalogue. The built-in demo exists in English and French only.
@@ -194,6 +194,8 @@
194
194
  "Web search": "Websøgning",
195
195
  "working": "arbejder",
196
196
  "Writing ": "Skriver ",
197
+ "Drawing on ": "Tegner på ",
198
+ "Filling ": "Udfylder ",
197
199
  "You": "Dig",
198
200
  "You can also switch between Call, Tree and Sessions at the top of the window.": "Du kan også skifte mellem Opkald, Træ og Sessioner øverst i vinduet.",
199
201
  "Your agents are done 🎉": "Dine agenter er færdige 🎉",
@@ -460,5 +462,8 @@
460
462
  "Agents you named yourself take these names too (switch below).": "Agenter, du selv har navngivet, får også disse navne (kontakten nedenfor).",
461
463
  "Zen: alerts only, no voices (M key)": "Zen: kun advarsler, ingen stemmer (M-tasten)",
462
464
  "Sound: all, zen (alerts only), off": "Lyd: alt, zen (kun advarsler), fra",
463
- "Zen mode: alerts, no voices": "Zen-tilstand: advarsler, ingen stemmer"
465
+ "Zen mode: alerts, no voices": "Zen-tilstand: advarsler, ingen stemmer",
466
+ "Hold the call in this language? Your Claude Code translates what the agents say.": "Holde opkaldet på dette sprog? Din Claude Code oversætter, hvad agenterne siger.",
467
+ "Yes": "Ja",
468
+ "Voices ready in English. This language has natural voices too: one more download.": "Stemmerne er klar på engelsk. Dette sprog har også naturlige stemmer: én download mere."
464
469
  }
@@ -168,6 +168,8 @@
168
168
  "Web search": "Websuche",
169
169
  "working": "arbeitet",
170
170
  "Writing ": "Schreibe ",
171
+ "Drawing on ": "Zeichnet auf ",
172
+ "Filling ": "Füllt ",
171
173
  "You": "Du",
172
174
  "Your agents are done 🎉": "Deine Agenten sind fertig 🎉",
173
175
  "Your Claude Code agents as a live team call": "Deine Claude Code-Agenten live im Team-Videoanruf",
@@ -461,5 +463,8 @@
461
463
  "Agents you named yourself take these names too (switch below).": "Agenten, die du selbst benannt hast, bekommen ebenfalls diese Namen (Schalter unten).",
462
464
  "Zen: alerts only, no voices (M key)": "Zen: nur Hinweistöne, keine Stimmen (Taste M)",
463
465
  "Sound: all, zen (alerts only), off": "Ton: alles, Zen (nur Hinweistöne), aus",
464
- "Zen mode: alerts, no voices": "Zen-Modus: Hinweistöne, keine Stimmen"
466
+ "Zen mode: alerts, no voices": "Zen-Modus: Hinweistöne, keine Stimmen",
467
+ "Hold the call in this language? Your Claude Code translates what the agents say.": "Den Call in dieser Sprache führen? Dein Claude Code übersetzt, was die Agenten sagen.",
468
+ "Yes": "Ja",
469
+ "Voices ready in English. This language has natural voices too: one more download.": "Stimmen auf Englisch bereit. Diese Sprache hat auch natürliche Stimmen: ein Download mehr."
465
470
  }
@@ -109,6 +109,7 @@
109
109
  "Download the new app from GitHub.": "Download the new app from GitHub.",
110
110
  "Downloading the real voices… you can carry on.": "Downloading the real voices… you can carry on.",
111
111
  "Downloading, you can carry on: the agents babble meanwhile.": "Downloading, you can carry on: the agents babble meanwhile.",
112
+ "Drawing on ": "Drawing on ",
112
113
  "Drawn by": "Drawn by",
113
114
  "Drawn characters": "Drawn characters",
114
115
  "duration": "duration",
@@ -134,6 +135,7 @@
134
135
  "Files created in this session": "Files created in this session",
135
136
  "Files made for you, when a turn ends": "Files made for you, when a turn ends",
136
137
  "Files touched": "Files touched",
138
+ "Filling ": "Filling ",
137
139
  "Final report": "Final report",
138
140
  "Find a session": "Find a session",
139
141
  "Find a session…": "Find a session…",
@@ -166,6 +168,7 @@
166
168
  "Hide until the next question": "Hide until the next question",
167
169
  "high": "high",
168
170
  "Highlights": "Highlights",
171
+ "Hold the call in this language? Your Claude Code translates what the agents say.": "Hold the call in this language? Your Claude Code translates what the agents say.",
169
172
  "Human": "Human",
170
173
  "I already bought it": "I already bought it",
171
174
  "idle": "idle",
@@ -416,6 +419,7 @@
416
419
  "Using skill ": "Using skill ",
417
420
  "Voice style": "Voice style",
418
421
  "Voice volume": "Voice volume",
422
+ "Voices ready in English. This language has natural voices too: one more download.": "Voices ready in English. This language has natural voices too: one more download.",
419
423
  "Voices ready in English. This language is still read by the system voices.": "Voices ready in English. This language is still read by the system voices.",
420
424
  "Voices ready.": "Voices ready.",
421
425
  "VS Code was started from inside a Claude Code session: restart VS Code normally (Dock, Spotlight) to enable translation.": "VS Code was started from inside a Claude Code session: restart VS Code normally (Dock, Spotlight) to enable translation.",
@@ -438,6 +442,7 @@
438
442
  "working": "working",
439
443
  "working for": "working for",
440
444
  "Writing ": "Writing ",
445
+ "Yes": "Yes",
441
446
  "Yes, tell me": "Yes, tell me",
442
447
  "You": "You",
443
448
  "You are sharing your screen": "You are sharing your screen",
@@ -168,6 +168,8 @@
168
168
  "Web search": "Búsqueda web",
169
169
  "working": "trabajando",
170
170
  "Writing ": "Escribiendo ",
171
+ "Drawing on ": "Dibujando en ",
172
+ "Filling ": "Rellenando ",
171
173
  "You": "Tú",
172
174
  "Your agents are done 🎉": "Tus agentes han terminado 🎉",
173
175
  "Your Claude Code agents as a live team call": "Tus agentes de Claude Code, en videollamada de equipo en directo",
@@ -461,5 +463,8 @@
461
463
  "Agents you named yourself take these names too (switch below).": "Los agentes que nombraste tú también reciben estos nombres (interruptor de abajo).",
462
464
  "Zen: alerts only, no voices (M key)": "Zen: solo las alertas, sin voces (tecla M)",
463
465
  "Sound: all, zen (alerts only), off": "Sonido: todo, zen (solo alertas), silencio",
464
- "Zen mode: alerts, no voices": "Modo zen: alertas, sin voces"
466
+ "Zen mode: alerts, no voices": "Modo zen: alertas, sin voces",
467
+ "Hold the call in this language? Your Claude Code translates what the agents say.": "¿Hacer la llamada en este idioma? Tu Claude Code traduce lo que dicen los agentes.",
468
+ "Yes": "Sí",
469
+ "Voices ready in English. This language has natural voices too: one more download.": "Voces listas en inglés. Este idioma también tiene voces naturales: una descarga más."
465
470
  }
@@ -168,6 +168,8 @@
168
168
  "Web search": "Web検索",
169
169
  "working": "作業中",
170
170
  "Writing ": "書き込み中: ",
171
+ "Drawing on ": "描画中: ",
172
+ "Filling ": "記入中: ",
171
173
  "You": "あなた",
172
174
  "Your agents are done 🎉": "エージェントが完了しました 🎉",
173
175
  "Your Claude Code agents as a live team call": "Claude Code のエージェントを、ライブのチーム通話で",
@@ -461,5 +463,8 @@
461
463
  "Agents you named yourself take these names too (switch below).": "自分で名前を付けたエージェントにもこれらの名前が付きます(下のスイッチ)。",
462
464
  "Zen: alerts only, no voices (M key)": "Zen:通知音のみ、声なし(Mキー)",
463
465
  "Sound: all, zen (alerts only), off": "サウンド:すべて、Zen(通知音のみ)、オフ",
464
- "Zen mode: alerts, no voices": "Zenモード:通知音のみ、声なし"
466
+ "Zen mode: alerts, no voices": "Zenモード:通知音のみ、声なし",
467
+ "Hold the call in this language? Your Claude Code translates what the agents say.": "通話をこの言語で行いますか?エージェントの発言はあなたの Claude Code が翻訳します。",
468
+ "Yes": "はい",
469
+ "Voices ready in English. This language has natural voices too: one more download.": "英語の音声は準備完了です。この言語にも自然な音声があります(追加のダウンロードが必要です)。"
465
470
  }
@@ -168,6 +168,8 @@
168
168
  "Web search": "웹 검색",
169
169
  "working": "작업 중",
170
170
  "Writing ": "작성 중: ",
171
+ "Drawing on ": "그리는 중: ",
172
+ "Filling ": "채우는 중: ",
171
173
  "You": "나",
172
174
  "Your agents are done 🎉": "에이전트 작업이 끝났습니다 🎉",
173
175
  "Your Claude Code agents as a live team call": "Claude Code 에이전트를 실시간 팀 통화로",
@@ -461,5 +463,8 @@
461
463
  "Agents you named yourself take these names too (switch below).": "직접 이름을 붙인 에이전트도 이 이름을 받습니다(아래 스위치).",
462
464
  "Zen: alerts only, no voices (M key)": "젠: 알림음만, 목소리 없음 (M 키)",
463
465
  "Sound: all, zen (alerts only), off": "소리: 전체, 젠 (알림음만), 끔",
464
- "Zen mode: alerts, no voices": "젠 모드: 알림음만, 목소리 없음"
466
+ "Zen mode: alerts, no voices": "젠 모드: 알림음만, 목소리 없음",
467
+ "Hold the call in this language? Your Claude Code translates what the agents say.": "이 언어로 통화할까요? 에이전트가 하는 말은 내 Claude Code가 번역합니다.",
468
+ "Yes": "예",
469
+ "Voices ready in English. This language has natural voices too: one more download.": "영어 음성이 준비되었습니다. 이 언어에도 자연스러운 음성이 있습니다. 한 번 더 내려받으면 됩니다."
465
470
  }
@@ -175,6 +175,8 @@
175
175
  "Web search": "Pesquisa na web",
176
176
  "working": "trabalhando",
177
177
  "Writing ": "Escrevendo ",
178
+ "Drawing on ": "Desenhando em ",
179
+ "Filling ": "Preenchendo ",
178
180
  "You": "Você",
179
181
  "Your agents are done 🎉": "Seus agentes terminaram 🎉",
180
182
  "Your Claude Code agents as a live team call": "Seus agentes do Claude Code em uma chamada de equipe ao vivo",
@@ -461,5 +463,8 @@
461
463
  "Agents you named yourself take these names too (switch below).": "Os agentes que você mesmo nomeou também recebem esses nomes (chave abaixo).",
462
464
  "Zen: alerts only, no voices (M key)": "Zen: só os alertas, sem vozes (tecla M)",
463
465
  "Sound: all, zen (alerts only), off": "Som: tudo, zen (só alertas), desligado",
464
- "Zen mode: alerts, no voices": "Modo zen: alertas, sem vozes"
466
+ "Zen mode: alerts, no voices": "Modo zen: alertas, sem vozes",
467
+ "Hold the call in this language? Your Claude Code translates what the agents say.": "Fazer a chamada neste idioma? O seu Claude Code traduz o que os agentes dizem.",
468
+ "Yes": "Sim",
469
+ "Voices ready in English. This language has natural voices too: one more download.": "Vozes prontas em inglês. Este idioma também tem vozes naturais: mais um download."
465
470
  }
@@ -168,6 +168,8 @@
168
168
  "Web search": "网页搜索",
169
169
  "working": "工作中",
170
170
  "Writing ": "正在写入 ",
171
+ "Drawing on ": "正在绘制 ",
172
+ "Filling ": "正在填写 ",
171
173
  "You": "你",
172
174
  "Your agents are done 🎉": "你的代理都完成啦 🎉",
173
175
  "Your Claude Code agents as a live team call": "把你的 Claude Code 代理变成实时团队通话",
@@ -461,5 +463,8 @@
461
463
  "Agents you named yourself take these names too (switch below).": "你自己命名的代理也会使用这些名字(见下方开关)。",
462
464
  "Zen: alerts only, no voices (M key)": "禅模式:只有提示音,没有语音(M 键)",
463
465
  "Sound: all, zen (alerts only), off": "声音:全部、禅模式(仅提示音)、关闭",
464
- "Zen mode: alerts, no voices": "禅模式:提示音,无语音"
466
+ "Zen mode: alerts, no voices": "禅模式:提示音,无语音",
467
+ "Hold the call in this language? Your Claude Code translates what the agents say.": "用此语言进行通话吗?智能体说的话由你的 Claude Code 翻译。",
468
+ "Yes": "是",
469
+ "Voices ready in English. This language has natural voices too: one more download.": "英语语音已就绪。此语言也有自然语音:再下载一次即可。"
465
470
  }
@@ -175,6 +175,8 @@
175
175
  "Web search": "網頁搜尋",
176
176
  "working": "工作中",
177
177
  "Writing ": "撰寫 ",
178
+ "Drawing on ": "繪製 ",
179
+ "Filling ": "填寫 ",
178
180
  "You": "你",
179
181
  "Your agents are done 🎉": "你的代理都完成了 🎉",
180
182
  "Your Claude Code agents as a live team call": "把你的 Claude Code 代理變成即時團隊通話",
@@ -461,5 +463,8 @@
461
463
  "Agents you named yourself take these names too (switch below).": "你自己命名的代理也會使用這些名字(見下方開關)。",
462
464
  "Zen: alerts only, no voices (M key)": "禪模式:只有提示音,沒有語音(M 鍵)",
463
465
  "Sound: all, zen (alerts only), off": "聲音:全部、禪模式(僅提示音)、關閉",
464
- "Zen mode: alerts, no voices": "禪模式:提示音,無語音"
466
+ "Zen mode: alerts, no voices": "禪模式:提示音,無語音",
467
+ "Hold the call in this language? Your Claude Code translates what the agents say.": "用此語言進行通話嗎?代理說的話由你的 Claude Code 翻譯。",
468
+ "Yes": "是",
469
+ "Voices ready in English. This language has natural voices too: one more download.": "英文語音已就緒。此語言也有自然語音:再下載一次即可。"
465
470
  }
package/server.js CHANGED
@@ -8,6 +8,7 @@ const os = require('os');
8
8
  const crypto = require('crypto');
9
9
  const codex = require('./codex.js'); // Codex sessions, read as the same call (see codex.js)
10
10
  const vibe = require('./vibe.js'); // Mistral Vibe sessions, the same way (see vibe.js)
11
+ const boards = require('./boards.js'); // Claude Whiteboards and Sheets, drawn again from the session's writes for the shared screen (see boards.js)
11
12
  const reply = require('./reply.js'); // the human's line, typed into the session's tmux pane (see reply.js); off unless AGENT_STANDUP_REPLY=on
12
13
  const SOURCES = [codex, vibe], sourceOf = (proj) => SOURCES.find((m) => m.PROJ === proj) || null, guard = (fn, or) => { try { return fn(); } catch (e) { logError('reader', e); return or; } }; // guard: a session of another tool that cannot be read costs that session, never the list // the tools other than Claude Code: each lists its sessions under one made-up project
13
14
  const kokoro = require('./kokoro.js'); // natural voices, installed on demand (see kokoro.js)
@@ -39,10 +40,11 @@ function claudeHomes() { // [CLAUDE_HOME, the other folders that hold sessions
39
40
  const home = os.homedir(), real = (d) => { try { return fs.statSync(d).isDirectory() ? fs.realpathSync(d) : ''; } catch { return ''; } };
40
41
  let names = []; try { names = fs.readdirSync(home).filter((n) => /^\.claude[-_.][^\\/]+$/.test(n) && !/([-_.~ ](bak|bkp|backup|old|orig|copy|save|saved|prev|archive|snapshot)[\dT_.-]*| \(copy( \d+)?\)| \d+|[-_.]\d{6,}[\dT_.-]*|~)$/i.test(n) && ['.claude.json', '.config.json', '.claude-custom-oauth.json'].some((j) => isFile(path.join(home, n, j)))).sort(); } catch {}
41
42
  const extra = EXTRA_HOMES.split(path.delimiter).map((d) => d.trim()).filter(Boolean).map((d) => path.resolve(d.replace(/^~(?=$|[\\/])/, home)));
42
- const list = [CLAUDE_HOME], seen = new Set([real(path.join(CLAUDE_HOME, 'projects')) || path.join(CLAUDE_HOME, 'projects')]);
43
- for (const d of [path.join(home, '.claude'), ...names.map((n) => path.join(home, n)), ...extra]) { const r = real(path.join(d, 'projects')); if (r && !seen.has(r)) { seen.add(r); list.push(d); } }
44
- homesMemo = { at: now, list }; return list;
43
+ const list = [CLAUDE_HOME], seen = new Set([real(path.join(CLAUDE_HOME, 'projects')) || path.join(CLAUDE_HOME, 'projects')]), twins = [], seenS = new Set([real(path.join(CLAUDE_HOME, 'sessions')) || path.join(CLAUDE_HOME, 'sessions')]);
44
+ for (const d of [path.join(home, '.claude'), ...names.map((n) => path.join(home, n)), ...extra]) { const r = real(path.join(d, 'projects')), s = real(path.join(d, 'sessions')); if (r && !seen.has(r)) { seen.add(r); list.push(d); if (s) seenS.add(s); } else if (r && s && !seenS.has(s)) { seenS.add(s); twins.push(d); } } // a twin: its projects folder is a link to one already read (claude --resume works from both logins), its sessions folder its own
45
+ homesMemo = { at: now, list, twins }; return list;
45
46
  }
47
+ function twinHomes() { claudeHomes(); return homesMemo.twins || []; } // the twins of the last look: their sessions folders are read for status, their projects never twice
46
48
  const projRoots = () => { const h = claudeHomes(); return h.length < 2 ? [ROOT] : h.map((d) => path.join(d, 'projects')); }; // one folder, as most people have: exactly the one read before
47
49
  const PUBLIC = path.join(__dirname, 'public');
48
50
  // Cowork, a tab of the Claude desktop app, keeps each of its sessions in the app's own folder, in the format of Claude Code: <folder>/<account>/<organisation>/<session>/.claude/projects/<project>/<id>.jsonl.
@@ -213,6 +215,7 @@ const toolLabel = (b, ts) => {
213
215
  const outs = i.files.map((f) => (typeof f === 'string' ? f : f && f.file_path)).filter((f) => typeof f === 'string' && path.isAbsolute(f) && f.length <= 400).slice(0, 16);
214
216
  out.d = { kind: 'text', what: 'mcp', v: 'cowork · present_files', text: clip(outs.map((f) => path.basename(f)).join('\n'), 400), ...(outs.length ? { outs } : {}) }; break;
215
217
  }
218
+ { const lv = boards.liveCall(b.name, i); if (lv && lv.op === 'write') { out.d = { kind: 'artifact', file: '', title: '', note: '', live: lv.kind, key: clip(lv.key, 200) }; break; } } // a write to a Claude Whiteboard (its store) or a Claude Sheet (its cells): the call shows the board or the Sheet as that write left it (see liveNote)
216
219
  if (mcp && /(^|_)Claude_Docs$/.test(mcp[1] || '') && mcp[2] === 'batch' && i.container && i.container.create && typeof i.container.create.name === 'string') { out.d = { kind: 'artifact', file: '', title: clip(i.container.create.name, 120), note: '', doc: 1 }; break; } // a doc of the Claude Docs connector being born (its later edits are calls like any other)
217
220
  out.d = mcp ? { kind: 'text', what: 'mcp', v: (mcp[1] || '') + ' · ' + (mcp.slice(2).join('__') || ''), text: clip(JSON.stringify(i), 400) } : { kind: 'text', text: clip(JSON.stringify(i), 300) };
218
221
  }
@@ -230,12 +233,19 @@ const artifactOf = (u) => (u && typeof u === 'object' && typeof u.url === 'strin
230
233
  // What a call that put an artifact in front of the person answered, for the line of files: a publish (above); a doc the Claude Docs connector created, whose answer names the doc and its address;
231
234
  // an artifact opened on the person's screen, only when this session did not publish or create it already (the same artifact under its other address would show twice, and an open would take the place of the publish that has the preview).
232
235
  const DOC_ID = /"created":\{[^{}]*"minted":"([\w-]{6,80})"/, DOC_URL = /"frame":\{[^{}]*"url":"(https:\/\/claude\.ai\/(?:code\/)?artifact\/[\w-]{6,80})"/;
233
- function artOf(st, how, u, text) {
236
+ function artOf(st, how, u, text, tid) {
234
237
  const seen = (st.artIds = st.artIds || new Set()), note = (id, url) => { if (id) seen.add('id ' + id); seen.add('url ' + url); }; // known by its id and by its address: a publish may answer without an id
238
+ if (how === 'peek') { const m = SHEET_FRAME.exec(text); if (m && ART_URL.test(m[2])) (st.sheetUrl = st.sheetUrl || new Map()).set(m[1], m[2]); return null; } // a read of a Sheet names its address: a Sheet made in another session can be shown too
239
+ if (how === 'live') { const d = st.lives && st.lives.get(tid); if (!d) return null; const url = d.live === 'board' ? d.key : (st.sheetUrl && st.sheetUrl.get(d.key)) || ''; if (!ART_URL.test(url) || (st.plainArt && st.plainArt.has(url)) || (d.live === 'sheet' && !/"data":\{"revision":\d+/.test(text))) return null; return { url, title: (st.artT && st.artT.get(url)) || '', typed: 1, live: d.live }; } // a write that went through: a new version of that board or Sheet
235
240
  if (how === 'doc') { const id = DOC_ID.exec(text), m = DOC_URL.exec(text); if (!id || !m || !ART_URL.test(m[1])) return null; note(id[1], m[1]); return { url: m[1], title: '', typed: 1 }; }
236
241
  const a = artifactOf(u), id = a && typeof u.artifact_id === 'string' ? u.artifact_id : ''; if (!a) return null;
237
242
  if (how === 'open') { if ((id && seen.has('id ' + id)) || seen.has('url ' + a.url)) return null; note(id, a.url); return { ...a, typed: 1 }; } // opened, not made here: the window gives its title and its link
238
- note(id, a.url); return a;
243
+ note(id, a.url); (st.artT = st.artT || new Map()).set(a.url, a.title); if (!a.typed) (st.plainArt = st.plainArt || new Set()).add(a.url); /* a page this session published from its own file: its database writes are its own, not a board's */ const sp = SHEET_MADE.exec(text); if (sp) (st.sheetUrl = st.sheetUrl || new Map()).set(sp[1], a.url); return a; // its title, for the writes that fill it; a Sheet: the Claude Docs project that holds its cells
244
+ }
245
+ const SHEET_MADE = /Claude Docs document \(project "([\w-]{6,80})"\)/, SHEET_FRAME = /"frame":\{"slug":"([\w-]{6,80})","url":"(https:\/\/claude\.ai\/(?:code\/)?artifact\/[\w-]{6,80})"/;
246
+ function liveNote(st, b, tool) { // a write to a board or a Sheet is looked up when its answer comes (artOf, 'live'); a read of a Sheet tells its address ('peek')
247
+ const d = tool.d; if (d && d.live) { (st.lives = st.lives || new Map()).set(b.id, d); const url = d.live === 'board' ? d.key : (st.sheetUrl && st.sheetUrl.get(d.key)) || ''; d.title = (st.artT && st.artT.get(url)) || ''; return; }
248
+ if (/^mcp__.+Claude_Docs__read$/.test(b.name || '')) (st.pubs = st.pubs || new Map()).set(b.id, 'peek');
239
249
  }
240
250
  const resultText = (c) => (typeof c === 'string' ? c : Array.isArray(c) ? c.map((x) => x.text || '').join('\n') : '');
241
251
  // The colours and cursor moves of a terminal (ANSI escape codes) are taken out of what a tool printed: the page shows text. clipOut: clip for an output, taking them out of the part it keeps.
@@ -478,9 +488,9 @@ function listSessions() {
478
488
  if (Date.now() - sessionsMemo.at < 2000) return sessionsMemo.rows;
479
489
  const out = listSessions0(); sessionsMemo = { at: Date.now(), rows: out }; return out;
480
490
  }
481
- function listSessions0() {
491
+ function listSessions0(since) { // since: every session written since then, however many (the day report), instead of the most recent ones
482
492
  const rows = [];
483
- for (const m of SOURCES) for (const r of guard(() => m.sessions(30), [])) rows.push({ proj: m.PROJ, id: r.id, mtime: r.mtime, size: r.size, agents: guard(() => (m.subCount ? m.subCount(r.id) : m.subFiles ? m.subFiles(r.id).length : 0), 0), cx: r, src: m });
493
+ for (const m of SOURCES) for (const r of guard(() => m.sessions(since != null ? 2000 : 30), [])) rows.push({ proj: m.PROJ, id: r.id, mtime: r.mtime, size: r.size, agents: guard(() => (m.subCount ? m.subCount(r.id) : m.subFiles ? m.subFiles(r.id).length : 0), 0), cx: r, src: m });
484
494
  for (const proj of projects()) {
485
495
  for (const { id, file } of transcripts(proj)) {
486
496
  let st; try { st = fs.statSync(file); } catch { continue; } // a link to a transcript that is gone
@@ -488,7 +498,7 @@ function listSessions0() {
488
498
  }
489
499
  }
490
500
  rows.sort((a, b) => b.mtime - a.mtime);
491
- const own = (r) => !r.cx && r.proj !== COWORK, top = rows.filter(own).slice(0, 60).concat(rows.filter((r) => r.cx), rows.filter((r) => r.proj === COWORK).slice(0, 30)).sort((a, b) => b.mtime - a.mtime); // the 60 most recent Claude Code sessions as always, and up to 30 of each other tool beside them, Cowork included: none pushes another out
501
+ const own = (r) => !r.cx && r.proj !== COWORK, top = since != null ? rows.filter((r) => r.mtime >= since) : rows.filter(own).slice(0, 60).concat(rows.filter((r) => r.cx), rows.filter((r) => r.proj === COWORK).slice(0, 30)).sort((a, b) => b.mtime - a.mtime); // the 60 most recent Claude Code sessions as always, and up to 30 of each other tool beside them, Cowork included: none pushes another out
492
502
  for (const r of top) {
493
503
  if (r.cx) { const c = r.cx, m = r.src; delete r.cx; delete r.src; r.title = guard(() => m.title(c), '') || r.id; r.project = guard(() => m.projectLabel(c.cwd), '') || m.SOURCE; r.source = m.SOURCE; continue; }
494
504
  // titles come from the cached tail read (custom title, then AI title, then first prompt): no whole-file reads
@@ -578,7 +588,7 @@ const PR_URL = /^https:\/\/github\.com\/[\w.-]+\/[\w.-]+\/pull\/\d+$/; // noth
578
588
  const askOf = (b) => { const q = b.name === 'AskUserQuestion' && b.input && Array.isArray(b.input.questions) && b.input.questions[0] && b.input.questions[0].question; return typeof q === 'string' ? clip(q.trim(), 200) : ''; }; // the question a session stopped on, for its card
579
589
  const callOf = (b) => { const i = b.input || {}, v = b.name === 'Bash' ? i.command : /^(Edit|Write|MultiEdit|NotebookEdit)$/.test(b.name) ? path.basename(String(i.file_path || i.notebook_path || '')) : b.name === 'WebFetch' ? i.url : ''; return typeof v === 'string' && v.trim() ? b.name + '(' + clip(v.replace(/\s+/g, ' ').trim(), 160) + ')' : ''; }; // what a call waiting for your go-ahead would do, written the way Claude Code shows it: Bash(npm test)
580
590
  const PLAN_FILE = /[\\/]\.claude[\\/]plans[\\/][^\\/]+\.md$/, PLAN_DIR = process.env.CLAUDE_CONFIG_DIR ? path.join(process.env.CLAUDE_CONFIG_DIR, 'plans') + path.sep : '';
581
- const planFile = (f) => PLAN_FILE.test(f) || (!!PLAN_DIR && f.startsWith(PLAN_DIR) && f.endsWith('.md')) || (f.endsWith('.md') && claudeHomes().slice(1).some((h) => f.startsWith(path.join(h, 'plans') + path.sep))); // also where a CLAUDE_CONFIG_DIR set elsewhere keeps them, and the other folders read (claudeHomes)
591
+ const planFile = (f) => PLAN_FILE.test(f) || (!!PLAN_DIR && f.startsWith(PLAN_DIR) && f.endsWith('.md')) || (f.endsWith('.md') && claudeHomes().slice(1).concat(twinHomes()).some((h) => f.startsWith(path.join(h, 'plans') + path.sep))); // also where a CLAUDE_CONFIG_DIR set elsewhere keeps them, and the other folders read (claudeHomes, and their twins)
582
592
  const planDoc = (f) => { try { const st = fs.statSync(f); if (!st.isFile() || st.size > 262144) return ''; return clip(fs.readFileSync(f, 'utf8').trim(), 4000); } catch { return ''; } }; // the whole plan, for the shared screen
583
593
  const planText = (f) => { try { const st = fs.statSync(f); if (!st.isFile() || st.size > 262144) return ''; return clip(fs.readFileSync(f, 'utf8').trim(), 1200); } catch { return ''; } };
584
594
  const menuOf = (b) => { // what a menu waiting for you shows, from the call it waits on, word for word: the questions and their options in their order (the terminal numbers them the same way), the command, the file, the plan
@@ -593,7 +603,7 @@ const menuOf = (b) => { // what a menu waiting for you shows, from the call it
593
603
  // Claude Code also keeps <config>/sessions/<pid>.json for each open session: its status (busy, idle, or waiting while a menu waits for your answer: a permission, a question) and since when.
594
604
  // It is the only sign of a Bash approval: in the transcript, a command waiting for your go-ahead looks just like one that runs. A file whose process has ended is left out.
595
605
  const CC_SESSIONS = process.env.AGENT_STANDUP_CC_SESSIONS || path.join(process.env.CLAUDE_CONFIG_DIR || path.join(os.homedir(), '.claude'), 'sessions'), CC_SESSIONS_SET = !!process.env.AGENT_STANDUP_CC_SESSIONS;
596
- const statusDirs = () => { const h = CC_SESSIONS_SET ? [] : claudeHomes(); return h.length < 2 ? [CC_SESSIONS] : h.map((d) => path.join(d, 'sessions')); }; // each folder read keeps the status of its own sessions
606
+ const statusDirs = () => { const h = CC_SESSIONS_SET ? [] : claudeHomes().concat(twinHomes()); return h.length < 2 ? [CC_SESSIONS] : h.map((d) => path.join(d, 'sessions')); }; // each folder read keeps the status of its own sessions
597
607
  const alive = (pid) => { try { process.kill(pid, 0); return true; } catch (e) { return e.code === 'EPERM'; } };
598
608
  function liveStatus() { // session id → { status, since, pid, ep (where it runs: claude-vscode, cli, claude-desktop, sdk-cli…), and for missingTranscripts: raw (the status as written), cwd, kind, startedAt, version, updatedAt (when the file was last written: a /clear moves it, and the id, but not statusUpdatedAt) }
599
609
  const out = new Map(), later = (a, b) => Math.max(a.updatedAt, a.since) > Math.max(b.updatedAt, b.since);
@@ -1049,7 +1059,7 @@ function parseRecord(st, r) {
1049
1059
  const one = blocks(r).filter((b) => b.type === 'tool_result').length === 1; // what Claude Code noted about the call (toolUseResult) is that call's when the record answers one call
1050
1060
  if (one && st.plans && r.toolUseResult && typeof r.toolUseResult.plan === 'string' && r.toolUseResult.plan.trim()) for (const b of blocks(r)) if (b.type === 'tool_result' && st.plans.has(b.tool_use_id)) st.plans.get(b.tool_use_id).d.text = clip(r.toolUseResult.plan.trim(), 4000); // the answer names the plan exactly: the plan file holds only the latest one
1051
1061
  for (const b of blocks(r)) if (b.type === 'tool_result' && st.toolName[b.tool_use_id] && !NO_RESULT.has(st.toolName[b.tool_use_id])) {
1052
- const n = st.toolName[b.tool_use_id], text = resultText(b.content), img = resultImages(b.content).length, files = n === 'Bash' && !b.is_error ? docPaths(text, false).map((f) => absPath(f, r.cwd)) : [], art = !b.is_error && st.pubs && st.pubs.has(b.tool_use_id) ? artOf(st, st.pubs.get(b.tool_use_id), r.toolUseResult, text) : null;
1062
+ const n = st.toolName[b.tool_use_id], text = resultText(b.content), img = resultImages(b.content).length, files = n === 'Bash' && !b.is_error ? docPaths(text, false).map((f) => absPath(f, r.cwd)) : [], art = !b.is_error && st.pubs && st.pubs.has(b.tool_use_id) ? artOf(st, st.pubs.get(b.tool_use_id), r.toolUseResult, text, b.tool_use_id) : null;
1053
1063
  items.push({ id: b.tool_use_id, err: !!b.is_error, out: clipOut(text.replace(/<system-reminder>[\s\S]*?<\/system-reminder>/g, '').trimEnd(), RESULT_MAX[n] || (/^mcp__/.test(n) ? 900 : 600)), ...(img ? { img } : {}), ...(files.length ? { files } : {}), ...(art ? { art } : {}), ...(BROWSER_MCP.test(n) && !b.is_error ? browserSeen(text, n) : {}), ...resultMore(n, text, one ? r.toolUseResult : null) }); // img: how many pictures came back; the page fetches them from /api/media · files: the documents a command says it made
1054
1064
  }
1055
1065
  if (items.length) push({ ts, agent, kind: 'results', items });
@@ -1074,7 +1084,7 @@ function parseRecord(st, r) {
1074
1084
  else if (b.type === 'tool_use') {
1075
1085
  st.toolName[b.id] = b.name; if (b.name === 'TaskCreate') st.tasks = 1; (st.out = st.out || new Set()).add(b.id); if (b.input && b.input.run_in_background) (st.bg = st.bg || {})[b.id] = true; // out: the calls that have no answer yet
1076
1086
  if (b.name === 'Agent' || b.name === 'Task') push({ ts, agent, kind: 'agentcall', toolId: b.id, bg: !!(b.input && b.input.run_in_background), text: (b.input && b.input.prompt) || '', title: (b.input && b.input.description) || '', ...(b.input && typeof b.input.name === 'string' && b.input.name.trim() ? { nm: b.input.name.trim() } : {}) });
1077
- else { const tool = toolLabel(b, ts); if (tool.d && tool.d.outs) tool.d.outs = tool.d.outs.map((f) => absPath(f, r.cwd)); if (/^(Write|Edit|MultiEdit)$/.test(b.name) && b.input && planFile(String(b.input.file_path || ''))) { st.planF = String(b.input.file_path); st.planW = b.name === 'Write' && typeof b.input.content === 'string' ? { mid: m.id, text: clip(b.input.content.trim(), 4000) } : null; } if (tool.d && tool.d.kind === 'plan') { (st.plans = st.plans || new Map()).set(b.id, tool); if (st.planW && st.planW.mid && st.planW.mid === m.id) tool.d.text = st.planW.text; else if (!tool.d.text && st.planF) tool.d.text = (st.planW && st.planW.text) || planDoc(st.planF); } /* a plan written in the same message as its call: the call carries the one before, or none */ /* Claude Code 2.1.30x sends ExitPlanMode with no plan: the plan is the file the session just wrote in ~/.claude/plans */ if (tool.d && tool.d.kind === 'artifact') (st.pubs = st.pubs || new Map()).set(b.id, tool.d.open ? 'open' : tool.d.doc ? 'doc' : 'pub'); push({ ts, agent, kind: 'tool', tool, ...th() }); st.act = st.raw.length - 1; }
1087
+ else { const tool = toolLabel(b, ts); if (tool.d && tool.d.outs) tool.d.outs = tool.d.outs.map((f) => absPath(f, r.cwd)); if (/^(Write|Edit|MultiEdit)$/.test(b.name) && b.input && planFile(String(b.input.file_path || ''))) { st.planF = String(b.input.file_path); st.planW = b.name === 'Write' && typeof b.input.content === 'string' ? { mid: m.id, text: clip(b.input.content.trim(), 4000) } : null; } if (tool.d && tool.d.kind === 'plan') { (st.plans = st.plans || new Map()).set(b.id, tool); if (st.planW && st.planW.mid && st.planW.mid === m.id) tool.d.text = st.planW.text; else if (!tool.d.text && st.planF) tool.d.text = (st.planW && st.planW.text) || planDoc(st.planF); } /* a plan written in the same message as its call: the call carries the one before, or none */ /* Claude Code 2.1.30x sends ExitPlanMode with no plan: the plan is the file the session just wrote in ~/.claude/plans */ liveNote(st, b, tool); if (tool.d && tool.d.kind === 'artifact') (st.pubs = st.pubs || new Map()).set(b.id, tool.d.open ? 'open' : tool.d.doc ? 'doc' : tool.d.live ? 'live' : 'pub'); push({ ts, agent, kind: 'tool', tool, ...th() }); st.act = st.raw.length - 1; }
1078
1088
  }
1079
1089
  }
1080
1090
  if (agent === 'main' && (m.stop_reason === 'end_turn' || ((r.isApiErrorMessage || (m.model === '<synthetic>' && m.stop_reason === 'stop_sequence')) && !(st.out && st.out.size)))) { // also a turn that ends on a message Claude Code writes itself, in the place of the model's: the API is down, the limit is reached, the request was refused, or there was nothing to answer. Nothing follows it, unless a call of the lead is still out: the connection dropped while its agents worked, and it goes on when they answer. (A message of the model that a safety check cuts is not the end either: Claude Code tells the model, which goes on.) The lead's turn is over: Claude Code writes one record per content block, each with the message's stop reason, so the mark goes on the line this record carries (a thinking block carries none)
@@ -1260,7 +1270,7 @@ const translate = (texts, lang) => translateFast(texts, lang);
1260
1270
 
1261
1271
  // Warm `claude` workers: after a slow first call each translation takes ~2-3 s (a cold `claude -p` costs ~6 s).
1262
1272
  // The languages a call can be held in besides English (the page asks for one with `lang`; French when it says nothing, as it always was).
1263
- const TR_LANG = { fr: 'French', es: 'Spanish', pt: 'Brazilian Portuguese' }, trLang = (l) => (Object.hasOwn(TR_LANG, l) ? l : 'fr');
1273
+ const TR_LANG = { fr: 'French', es: 'Spanish', pt: 'Brazilian Portuguese', de: 'German', da: 'Danish', ja: 'Japanese', ko: 'Korean', zh: 'Simplified Chinese', zt: 'Traditional Chinese' }, trLang = (l) => (Object.hasOwn(TR_LANG, l) ? l : 'fr');
1264
1274
  const trInstr = (lang) => `Translate each string of this JSON array into natural spoken ${TR_LANG[lang]}, as a teammate would say it in a meeting. Keep code identifiers, file paths, library names and numbers unchanged.`;
1265
1275
  const trSys = (lang) => `You are a translation engine. Translate the user message into natural spoken ${TR_LANG[lang]}, as a colleague would say it in a meeting. Keep code identifiers, file paths, library names and numbers unchanged. Reply with ONLY the translation, nothing else.`;
1266
1276
  class TrWorker {
@@ -1355,7 +1365,7 @@ function tts(text, voice, rate, engine, fb) {
1355
1365
  if (ttsJobs.has(key)) return ttsJobs.get(key);
1356
1366
  fs.mkdirSync(ttsDir, { recursive: true });
1357
1367
  const tmp = file + '.part.wav';
1358
- const job = (kk ? kokoro.synth(text, voice, kokoro.speedFor(rate), tmp).catch((e) => { const vs = listVoices(), v = vs.voices.find((x) => x.name === fb) || vs.voices.find((x) => x.locale.startsWith(kokoro.localeOf(voice).slice(0, 3))); if (!v) throw e; return synthesize(v.name, rate, text, tmp); }) : synthesize(voice, rate, text, tmp)) // a line Kokoro cannot make goes to a system voice instead of being dropped: the one the page names (fb, its best system voice for this character), or else the first one of the same language
1368
+ const job = (kk ? kokoro.synth(text, voice, kokoro.speedFor(rate), tmp).catch((e) => { if (kokoro.natural(voice)) throw e; const vs = listVoices(), v = vs.voices.find((x) => x.name === fb) || vs.voices.find((x) => x.locale.startsWith(kokoro.localeOf(voice).slice(0, 3))); if (!v) throw e; return synthesize(v.name, rate, text, tmp); }) : synthesize(voice, rate, text, tmp)) // a line Kokoro cannot make goes to a system voice instead of being dropped: the one the page names (fb, its best system voice for this character), or else the first one of the same language. Not for German, Danish, Japanese and Korean (natural): those are natural voices or none, and the page babbles the line
1359
1369
  .then(() => { fs.renameSync(tmp, file); return file; }).finally(() => ttsJobs.delete(key));
1360
1370
  ttsJobs.set(key, job); return job;
1361
1371
  }
@@ -1532,7 +1542,7 @@ function start(port = PORT) {
1532
1542
  if (url.searchParams.get('engine') === 'kokoro') { const st = kokoro.status(); if (st.installed && !st.gaveUp) kokoro.warm(); return json({ available: st.installed && !st.gaveUp, ready: st.ready, voices: kokoro.voices(), platform: process.platform, engine: 'kokoro' }); }
1533
1543
  return loadVoices().then((v) => json(v));
1534
1544
  }
1535
- if (url.pathname === '/api/kokoro/install' && req.method === 'POST') return json(kokoro.install()); if (url.pathname === '/api/usage' && req.method === 'POST') return json(usageWeek());
1545
+ if (url.pathname === '/api/kokoro/install' && req.method === 'POST') return json(kokoro.install({ st: url.searchParams.get('st') === '1', zh: url.searchParams.get('zh') === '1' })); /* st=1: the voices of German, Danish, Japanese and Korean as well; zh=1: the Chinese ones */ if (url.pathname === '/api/usage' && req.method === 'POST') return json(usageWeek());
1536
1546
  if (url.pathname === '/api/update') return updateInfo().then(json, () => json({ on: false, current: VERSION })); /* a newer version, at most one request to npm a day (updateInfo) */
1537
1547
  if (url.pathname === '/api/kokoro') return json(kokoro.status());
1538
1548
  if (url.pathname === '/api/tts') {
@@ -1585,7 +1595,7 @@ function start(port = PORT) {
1585
1595
  if (url.pathname === '/api/artifact') { // the page a publish of this session sent, for the frame of the shared screen · check=1: is there one, and does it name libraries (asked before the frame is drawn) · whole=1: the whole document
1586
1596
  const q = (k) => url.searchParams.get(k) || '', SAFE = /^[\w.\-]+$/, bad = [q('proj'), q('id'), q('agent'), q('tool')].some((v) => !SAFE.test(v) || v === '..' || v.length > 200) || q('tool').length < 6;
1587
1597
  if (bad) { res.writeHead(400); return res.end('bad request'); }
1588
- const file = sourceOf(q('proj')) ? null : mediaFile(q('proj'), q('id'), q('agent')), plan = file && fs.existsSync(file) && fs.existsSync(mediaFile(q('proj'), q('id'), 'main')) ? artifactPlan(q('proj'), q('id'), q('agent'), q('tool')) : null, page = plan && artifactBuild(file, q('tool'), plan, q('whole') === '1');
1598
+ const file = sourceOf(q('proj')) ? null : mediaFile(q('proj'), q('id'), q('agent')), plan = file && fs.existsSync(file) && fs.existsSync(mediaFile(q('proj'), q('id'), 'main')) ? artifactPlan(q('proj'), q('id'), q('agent'), q('tool')) : null, page = plan ? artifactBuild(file, q('tool'), plan, q('whole') === '1') : file && fs.existsSync(file) ? guard(() => boards.livePage(file, q('tool')), null) : null; // no page sent: a write to a board or a Sheet, drawn again from the session's writes
1589
1599
  if (q('check')) return json(page ? { ok: true, net: page.net, ...(page.pages > 1 ? { pages: page.pages, label: page.label } : {}) } : { ok: false }, page ? 200 : 404); // pages: a document of several pages, which can be shown whole (whole=1)
1590
1600
  if (!page) { res.writeHead(404); return res.end('not found'); }
1591
1601
  const body = Buffer.from((/^\s*<!doctype/i.test(page.html) ? '' : '<!doctype html><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">') + page.html, 'utf8'); // an artifact is published as the inside of a page: claude.ai adds the rest, and so does this
@@ -1632,7 +1642,7 @@ function start(port = PORT) {
1632
1642
  } catch (e) { logError(req.method + ' ' + url.pathname, e); if (res.headersSent) return res.destroy(); json({ error: String(e.message || e) }, 500); }
1633
1643
  }).listen(port, '127.0.0.1', function () { console.log(`Agent Standup → http://localhost:${this.address().port}`); });
1634
1644
  }
1635
- module.exports = { answerIn, missingTranscripts, noteEditor, forgetEditor, _winArg: winArg, start, currentSession, shutdown, findClaude, bundledClaude, boardRows, transcriptFile: (proj, id) => path.join(projDir(proj, id), id + '.jsonl'), sessionRows: listSessions, charactersDir, listCharacters, packsDir, installPack, logError, updateInfo, _reveal: reveal, _scrub: { tidy, homeRe }, _artifact: { page: artifactPage, csp: artifactCsp } };
1645
+ module.exports = { answerIn, missingTranscripts, noteEditor, forgetEditor, _winArg: winArg, start, currentSession, shutdown, findClaude, bundledClaude, boardRows, timeline: (proj, id) => timelineEntry(proj, id).tl, transcriptFile: (proj, id) => path.join(projDir(proj, id), id + '.jsonl'), sessionRows: listSessions, sessionsSince: (t) => listSessions0(+t || 0), codexPending: () => guard(() => !!(codex.zPending && codex.zPending()), false), charactersDir, listCharacters, packsDir, installPack, logError, updateInfo, _reveal: reveal, _scrub: { tidy, homeRe }, _artifact: { page: artifactPage, csp: artifactCsp }, readPrefs, leadKey: (proj, id) => guard(() => (leadProject(proj, id) || {}).key || '', '') };
1636
1646
  if (require.main === module && process.env.AGENT_STANDUP_CHILD === '1' && typeof process.send === 'function') { // started by the VS Code extension in a process of its own (see extension.js): reading a large session no longer stops the editor's extensions. Asked for by name: pm2 and others give any app a channel too
1637
1647
  const srv = start(+process.env.PORT || 0), tell = (m) => { try { process.send(m); } catch {} };
1638
1648
  srv.on('listening', () => tell({ port: srv.address().port })).on('error', (e) => { tell({ error: e.code || String(e) }); process.exit(1); });
@@ -0,0 +1,82 @@
1
+ #!/usr/bin/env node
2
+ // Supertonic worker: the natural voices of German, Danish, Japanese and Korean, which Kokoro does not speak. Supertonic 3 (Supertone; model under the OpenRAIL-M licence, downloaded on demand by kokoro.js,
3
+ // never shipped with the app) runs on the onnxruntime-node that the Kokoro install already holds. Loads the four parts of the model once, then reads one JSON request per stdin line
4
+ // ({ id, text, voice, lang, speed, out }: voice is a style file, F1 to M5), writes a 16-bit WAV to `out` and answers { id, ok, seconds } or { id, ok: false, error }. Started by kokoro.js.
5
+ // The inference follows Supertone's MIT-licensed Node example (github.com/supertone-inc/supertonic, nodejs/helper.js), with three changes: a line is cut at the ends of its sentences in every script
6
+ // (。!? too: the example only cuts at ". "), a character the model does not know is left out instead of sent as -1, and the noise the model starts from is drawn from the line itself,
7
+ // so the same line sounds the same each time it is made (the example draws it at random, and a slip then comes and goes).
8
+ const fs = require('fs'), path = require('path'), readline = require('readline'), { createRequire } = require('module');
9
+ const send = (o) => fs.writeSync(1, JSON.stringify(o) + '\n');
10
+ const STEPS = 8; // 5 steps slipped words in French (October 2026 audit); 8 did not
11
+ const LANGS = new Set(['en', 'ko', 'ja', 'ar', 'bg', 'cs', 'da', 'de', 'el', 'es', 'et', 'fi', 'fr', 'hi', 'hr', 'hu', 'id', 'it', 'lt', 'lv', 'nl', 'pl', 'pt', 'ro', 'ru', 'sk', 'sl', 'sv', 'tr', 'uk', 'vi']);
12
+ const finite = (s) => { for (let i = 0; i < s.length; i++) if (s[i] !== s[i]) return false; return true; };
13
+ function wav(samples, rate) { // Float32 in [-1, 1] → 16-bit mono WAV
14
+ const n = samples.length, buf = Buffer.alloc(44 + n * 2);
15
+ buf.write('RIFF', 0); buf.writeUInt32LE(36 + n * 2, 4); buf.write('WAVEfmt ', 8); buf.writeUInt32LE(16, 16); buf.writeUInt16LE(1, 20); buf.writeUInt16LE(1, 22); buf.writeUInt32LE(rate, 24); buf.writeUInt32LE(rate * 2, 28); buf.writeUInt16LE(2, 32); buf.writeUInt16LE(16, 34); buf.write('data', 36); buf.writeUInt32LE(n * 2, 40);
16
+ for (let i = 0; i < n; i++) { const s = Math.max(-1, Math.min(1, samples[i])); buf.writeInt16LE(Math.round(s < 0 ? s * 32768 : s * 32767), 44 + i * 2); }
17
+ return buf;
18
+ }
19
+ // ---- text, as the model was trained to read it (the example's normaliser)
20
+ const EMOJI = /[\u{1F600}-\u{1F64F}\u{1F300}-\u{1F5FF}\u{1F680}-\u{1F6FF}\u{1F700}-\u{1F77F}\u{1F780}-\u{1F7FF}\u{1F800}-\u{1F8FF}\u{1F900}-\u{1F9FF}\u{1FA00}-\u{1FA6F}\u{1FA70}-\u{1FAFF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}\u{1F1E6}-\u{1F1FF}]+/gu;
21
+ const SWAP = [['–', '-'], ['‑', '-'], ['—', '-'], ['_', ' '], ['“', '"'], ['”', '"'], ['‘', "'"], ['’', "'"], ['´', "'"], ['`', "'"], ['[', ' '], [']', ' '], ['|', ' '], ['/', ' '], ['#', ' '], ['→', ' '], ['←', ' '], ['@', ' at '], ['e.g.,', 'for example, '], ['i.e.,', 'that is, ']];
22
+ function normalise(text) {
23
+ text = text.normalize('NFKD').replace(EMOJI, ''); for (const [a, b] of SWAP) text = text.split(a).join(b);
24
+ text = text.replace(/[♥☆♡©\\]/g, '').replace(/ ([,.!?;:'])/g, '$1').replace(/"{2,}/g, '"').replace(/'{2,}/g, "'").replace(/\s+/g, ' ').trim();
25
+ return /[.!?;:,'")\]}…。」』】〉》›»]$/.test(text) ? text : text + '.';
26
+ }
27
+ // ---- a long line is made in parts and joined. The model takes about 300 characters at a time (120 in Japanese and Korean, the example's limits), cut where a pause is natural, best first:
28
+ // the end of a sentence, a comma, a space; a text with none of these is cut in the middle. Each cut gets its pause, in seconds at speed 1.
29
+ const CUTS = [[/[.!?…。!?]+["'”’»)\]」』]*\s*/g, 0.45], [/[,;:、,;:]\s*/g, 0.2], [/\s+/g, 0.05]];
30
+ function halve(s) {
31
+ 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]; }
32
+ const at = Math.ceil(s.length / 2); return [s.slice(0, at), s.slice(at), 0];
33
+ }
34
+ function pieces(text, max) { if (text.length <= max) return [text]; const [a, b, gap] = halve(text); return [...pieces(a.trim(), max), gap, ...pieces(b.trim(), max)].filter((x) => x !== ''); }
35
+ // ---- the noise: a generator seeded by the line, the voice and the language
36
+ function seeded(str) {
37
+ let h = 2166136261; for (let i = 0; i < str.length; i++) { h ^= str.charCodeAt(i); h = Math.imul(h, 16777619); }
38
+ return () => { h = (h + 0x6d2b79f5) | 0; let t = Math.imul(h ^ (h >>> 15), 1 | h); t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t; return ((t ^ (t >>> 14)) >>> 0) / 4294967296; };
39
+ }
40
+ async function main() {
41
+ const dir = process.env.AGENT_STANDUP_KOKORO_DIR, model = process.env.AGENT_STANDUP_ST_DIR || path.join(dir, 'supertonic-3');
42
+ const ort = createRequire(path.join(dir, 'node_modules', 'x.js'))('onnxruntime-node'); // resolved from the install folder, not from the extension
43
+ const onnx = (n) => path.join(model, 'onnx', n), cfg = JSON.parse(fs.readFileSync(onnx('tts.json'), 'utf8')), index = JSON.parse(fs.readFileSync(onnx('unicode_indexer.json'), 'utf8'));
44
+ // without ONNX Runtime's memory arena and patterns, the worker holds about 470 MB instead of 760, at the same speed (measured on an M1 Pro, November 2026)
45
+ const [dp, enc, est, voc] = await Promise.all(['duration_predictor', 'text_encoder', 'vector_estimator', 'vocoder'].map((n) => ort.InferenceSession.create(onnx(n + '.onnx'), { enableCpuMemArena: false, enableMemPattern: false })));
46
+ const rate = cfg.ae.sample_rate, chunk = cfg.ae.base_chunk_size * cfg.ttl.chunk_compress_factor, dim = cfg.ttl.latent_dim * cfg.ttl.chunk_compress_factor;
47
+ const styles = new Map(), style = (v) => { // a voice: two tensors, read once from voice_styles/<v>.json
48
+ if (!/^[FM][1-5]$/.test(v)) throw new Error('unknown voice ' + v);
49
+ if (!styles.has(v)) { const j = JSON.parse(fs.readFileSync(path.join(model, 'voice_styles', v + '.json'), 'utf8')), t = (o) => new ort.Tensor('float32', Float32Array.from(o.data.flat(Infinity)), o.dims); styles.set(v, { ttl: t(j.style_ttl), dp: t(j.style_dp) }); }
50
+ return styles.get(v);
51
+ };
52
+ const f32 = (data, dims) => new ort.Tensor('float32', data, dims);
53
+ async function infer(text, lang, st, speed, seed) { // one piece → Float32Array at `rate`
54
+ const ids = []; for (const ch of `<${lang}>${normalise(text)}</${lang}>`) { const id = index[ch.charCodeAt(0)]; if (id >= 0) ids.push(BigInt(id)); }
55
+ const n = ids.length, textIds = new ort.Tensor('int64', BigInt64Array.from(ids), [1, n]), textMask = f32(new Float32Array(n).fill(1), [1, 1, n]);
56
+ const dur = (await dp.run({ text_ids: textIds, style_dp: st.dp, text_mask: textMask })).duration.data[0] / speed;
57
+ const emb = (await enc.run({ text_ids: textIds, style_ttl: st.ttl, text_mask: textMask })).text_emb;
58
+ const len = Math.floor(dur * rate), T = Math.max(1, Math.ceil(len / chunk)), rnd = seeded(seed), lat = new Float32Array(dim * T);
59
+ for (let i = 0; i < lat.length; i++) { const u = Math.max(1e-10, rnd()), v = rnd(); lat[i] = Math.sqrt(-2 * Math.log(u)) * Math.cos(2 * Math.PI * v); }
60
+ let x = f32(lat, [1, dim, T]); const latMask = f32(new Float32Array(T).fill(1), [1, 1, T]), total = f32(Float32Array.of(STEPS), [1]);
61
+ for (let s = 0; s < STEPS; s++) x = f32((await est.run({ noisy_latent: x, text_emb: emb, style_ttl: st.ttl, text_mask: textMask, latent_mask: latMask, total_step: total, current_step: f32(Float32Array.of(s), [1]) })).denoised_latent.data, [1, dim, T]);
62
+ const out = (await voc.run({ latent: x })).wav_tts.data; return out.subarray(0, Math.min(len, out.length));
63
+ }
64
+ async function make(text, lang, voice, speed) { // the whole line, its pieces joined by their pauses; a piece the model returns as NaN is made once more from other noise
65
+ if (!LANGS.has(lang)) throw new Error('unknown language ' + lang);
66
+ const st = style(voice), parts = pieces(String(text).replace(/\s+/g, ' ').trim(), lang === 'ja' || lang === 'ko' ? 120 : 300), audio = [];
67
+ for (const p of parts) {
68
+ if (typeof p === 'number') { audio.push(new Float32Array(Math.round((p / speed) * rate))); continue; }
69
+ let a = await infer(p, lang, st, speed, voice + '|' + lang + '|' + p); if (!finite(a)) { a = await infer(p, lang, st, speed, 'again|' + voice + '|' + p); if (!finite(a)) throw new Error('the model returned NaN'); }
70
+ audio.push(a);
71
+ }
72
+ const all = new Float32Array(audio.reduce((n, a) => n + a.length, 0)); let at = 0; for (const a of audio) { all.set(a, at); at += a.length; } return all;
73
+ }
74
+ send({ ready: true });
75
+ for await (const line of readline.createInterface({ input: process.stdin })) {
76
+ let m; try { m = JSON.parse(line); } catch { continue; }
77
+ try { const a = await make(m.text, m.lang, m.voice, (+m.speed || 1) * 1.05); fs.writeFileSync(m.out, wav(a, rate)); send({ id: m.id, ok: true, seconds: a.length / rate }); } // 1.05: the example's pace, the model's own at speed 1
78
+ catch (e) { send({ id: m.id, ok: false, error: String((e && e.message) || e).slice(0, 200) }); }
79
+ }
80
+ }
81
+ if (require.main === module) main().catch((e) => { console.error(String((e && e.stack) || e)); process.exit(1); });
82
+ module.exports = { normalise, pieces, seeded };