openclacky 1.5.25 → 1.5.26

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.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +61 -0
  3. data/lib/clacky/agent/chunk_index.rb +2 -1
  4. data/lib/clacky/agent/message_compressor_helper.rb +20 -2
  5. data/lib/clacky/agent/session_serializer.rb +28 -1
  6. data/lib/clacky/agent/skill_manager.rb +2 -8
  7. data/lib/clacky/agent/time_machine.rb +108 -127
  8. data/lib/clacky/agent/tool_executor.rb +2 -11
  9. data/lib/clacky/agent.rb +15 -19
  10. data/lib/clacky/agent_config.rb +14 -4
  11. data/lib/clacky/billing/media_usage.rb +69 -0
  12. data/lib/clacky/billing/platform_billing.rb +5 -0
  13. data/lib/clacky/brand_config.rb +16 -215
  14. data/lib/clacky/default_extensions/ext-studio/agents/ext-developer/system_prompt.md +2 -80
  15. data/lib/clacky/default_extensions/ext-studio/panels/studio/view.js +1 -1
  16. data/lib/clacky/default_extensions/ext-studio/skills/ext-develop/SKILL.md +10 -96
  17. data/lib/clacky/default_extensions/git/panels/git/view.js +208 -69
  18. data/lib/clacky/default_extensions/knowledge/README.md +1 -1
  19. data/lib/clacky/default_extensions/knowledge/README.zh.md +1 -1
  20. data/lib/clacky/default_extensions/knowledge/lib/importer.rb +1 -1
  21. data/lib/clacky/default_extensions/knowledge/panels/kb/view.js +3 -3
  22. data/lib/clacky/default_extensions/meeting/api/handler.rb +23 -2
  23. data/lib/clacky/default_extensions/meeting/panels/meeting/view.js +194 -36
  24. data/lib/clacky/default_extensions/preview/icon.svg +3 -2
  25. data/lib/clacky/default_extensions/secretary/panels/work/view.js +108 -33
  26. data/lib/clacky/default_extensions/side-chat/README.md +40 -0
  27. data/lib/clacky/default_extensions/side-chat/README.zh.md +40 -0
  28. data/lib/clacky/default_extensions/side-chat/api/handler.rb +90 -0
  29. data/lib/clacky/default_extensions/side-chat/api/runtime.rb +411 -0
  30. data/lib/clacky/default_extensions/side-chat/ext.yml +16 -0
  31. data/lib/clacky/default_extensions/side-chat/icon.svg +14 -0
  32. data/lib/clacky/default_extensions/side-chat/panels/side-chat/view.js +779 -0
  33. data/lib/clacky/default_extensions/terminal/README.md +36 -0
  34. data/lib/clacky/default_extensions/terminal/README.zh.md +36 -0
  35. data/lib/clacky/default_extensions/terminal/api/handler.rb +121 -0
  36. data/lib/clacky/default_extensions/terminal/api/runtime.rb +397 -0
  37. data/lib/clacky/default_extensions/terminal/ext.yml +16 -0
  38. data/lib/clacky/default_extensions/terminal/icon.svg +13 -0
  39. data/lib/clacky/default_extensions/terminal/panels/terminal/view.js +351 -0
  40. data/lib/clacky/default_extensions/terminal/vendor/LICENSE +21 -0
  41. data/lib/clacky/default_extensions/terminal/vendor/addon-fit.js +2 -0
  42. data/lib/clacky/default_extensions/terminal/vendor/xterm.css +218 -0
  43. data/lib/clacky/default_extensions/terminal/vendor/xterm.js +2 -0
  44. data/lib/clacky/default_skills/media-gen/SKILL.md +30 -9
  45. data/lib/clacky/extension/api_extension.rb +12 -0
  46. data/lib/clacky/locales/en.rb +14 -11
  47. data/lib/clacky/locales/i18n.rb +25 -0
  48. data/lib/clacky/locales/zh.rb +14 -11
  49. data/lib/clacky/media/base.rb +11 -1
  50. data/lib/clacky/media/openai_compat.rb +271 -3
  51. data/lib/clacky/message_format/open_ai.rb +17 -0
  52. data/lib/clacky/prompts/base.md +3 -0
  53. data/lib/clacky/providers.rb +33 -20
  54. data/lib/clacky/reasoning_levels.rb +75 -0
  55. data/lib/clacky/server/channel/channel_ui_controller.rb +12 -5
  56. data/lib/clacky/server/git_panel.rb +40 -18
  57. data/lib/clacky/server/http_server.rb +62 -71
  58. data/lib/clacky/server/session_registry.rb +3 -0
  59. data/lib/clacky/ui2/markdown_renderer.rb +153 -0
  60. data/lib/clacky/ui2/strings_cjk_patch.rb +134 -124
  61. data/lib/clacky/utils/file_link_normalizer.rb +30 -3
  62. data/lib/clacky/utils/frontmatter.rb +63 -0
  63. data/lib/clacky/utils/model_pricing.rb +67 -9
  64. data/lib/clacky/version.rb +1 -1
  65. data/lib/clacky/web/app.css +722 -274
  66. data/lib/clacky/web/app.js +2 -0
  67. data/lib/clacky/web/components/chat-composer.js +504 -0
  68. data/lib/clacky/web/components/chat-navigator.js +1 -1
  69. data/lib/clacky/web/components/model-picker.js +319 -20
  70. data/lib/clacky/web/components/quote-select.js +97 -39
  71. data/lib/clacky/web/core/aside.js +137 -27
  72. data/lib/clacky/web/core/ext.js +658 -81
  73. data/lib/clacky/web/features/brand/store.js +0 -4
  74. data/lib/clacky/web/features/brand/view.js +2 -99
  75. data/lib/clacky/web/features/extensions/store.js +3 -1
  76. data/lib/clacky/web/features/extensions/view.js +14 -15
  77. data/lib/clacky/web/features/new-session/store.js +4 -0
  78. data/lib/clacky/web/features/new-session/view.js +27 -4
  79. data/lib/clacky/web/features/skills/store.js +7 -5
  80. data/lib/clacky/web/features/skills/view.js +65 -16
  81. data/lib/clacky/web/features/version/view.js +1 -1
  82. data/lib/clacky/web/features/workspace/store.js +7 -3
  83. data/lib/clacky/web/features/workspace/view.js +46 -5
  84. data/lib/clacky/web/i18n.js +104 -58
  85. data/lib/clacky/web/index.html +21 -22
  86. data/lib/clacky/web/lib/box-diagram.js +239 -0
  87. data/lib/clacky/web/sessions.js +117 -151
  88. data/lib/clacky/web/settings.js +23 -16
  89. data/lib/clacky/web/ws-dispatcher.js +4 -1
  90. data/lib/clacky.rb +2 -0
  91. metadata +24 -1
@@ -4,6 +4,9 @@
4
4
 
5
5
  (function () {
6
6
  const ANNOTATE_INTERVAL_MS = 120000;
7
+ // error_type the meeting API returns when the active model provider has no
8
+ // speech-to-text model — a settings gap the user can close in one click.
9
+ const STT_NOT_CONFIGURED = "stt_not_configured";
7
10
  // Wake phrases must be "greeting + name", never a bare product word.
8
11
  // Bare "clacky" / "小克" are too easily tripped by casual mentions of the
9
12
  // brand or STT hallucinations pulled from the meeting vocabulary.
@@ -70,6 +73,8 @@
70
73
  "captions.empty": "Waiting for speech…",
71
74
  "annotations.empty": "Decisions and to-dos are picked out every 2 minutes",
72
75
  "stt.failed": "⚠ Transcription failed: {{msg}}",
76
+ "stt.notConfigured": "No speech-to-text model yet, so this recording can't be transcribed.",
77
+ "stt.goSettings": "Open settings",
73
78
  "alert.noSession": "No active session",
74
79
  "alert.startFailed": "Failed to start meeting: {{msg}}",
75
80
  "end.displayMessage": "🛑 Meeting ended — generating meeting minutes…",
@@ -117,6 +122,8 @@
117
122
  "captions.empty": "正在等待发言…",
118
123
  "annotations.empty": "每 2 分钟自动提取决策和待办",
119
124
  "stt.failed": "⚠ 识别失败:{{msg}}",
125
+ "stt.notConfigured": "还没有配置语音识别模型,无法转写录音。",
126
+ "stt.goSettings": "去设置",
120
127
  "alert.noSession": "没有进行中的会话",
121
128
  "alert.startFailed": "开启会议失败:{{msg}}",
122
129
  "end.displayMessage": "🛑 会议结束 — 正在生成会议纪要…",
@@ -162,12 +169,20 @@
162
169
 
163
170
  // VAD (voice activity detection) — slice on natural speech pauses instead
164
171
  // of a fixed timer, so a sentence is never cut mid-word.
165
- const VAD_SILENCE_THRESHOLD = 0.02; // RMS below this counts as silence
166
- const VAD_SILENCE_HOLD_MS = 700; // pause this long => end of utterance
172
+ //
173
+ // The cutoff is relative to a running estimate of the room's noise floor: a
174
+ // fixed RMS value bakes in one microphone gain, and laptop mics differ by
175
+ // 20 dB or more. VAD_MIN_RMS is only the floor for a digitally silent room.
176
+ const VAD_TICK_MS = 50; // analyser poll interval
177
+ const VAD_MIN_RMS = 0.004; // never treat anything quieter as speech
178
+ const VAD_NOISE_FACTOR = 3.0; // speech must clear the floor by 3x
179
+ const VAD_SILENCE_HOLD_MS = 600; // pause this long => end of utterance
167
180
  const VAD_MIN_SPEECH_MS = 500; // ignore utterances shorter than this
168
- const VAD_MAX_SEGMENT_MS = 12000; // force-cut a very long monologue
169
- const VAD_MIN_ACTIVE_RATIO = 0.25; // fraction of samples above threshold
170
- // required to accept a segment
181
+ const VAD_MIN_SPEECH_TICKS = 8; // ≈400ms of real speech energy required
182
+ // Only a backstop: normal sentences end on the 600ms silence hold long
183
+ // before this. Cutting mid-sentence loses words and reads badly, and
184
+ // DeepSeek takes up to 120s (8MiB) per chunk, so keep the ceiling high.
185
+ const VAD_MAX_SEGMENT_MS = 30000; // force-cut a very long monologue
171
186
 
172
187
  let state = {
173
188
  active: false,
@@ -179,7 +194,7 @@
179
194
  annotations: [],
180
195
  sttError: null,
181
196
  audioCtx: null,
182
- vadRaf: null,
197
+ vadTimer: null,
183
198
  stream: null,
184
199
  vocabulary: "",
185
200
  conversationUntil: 0,
@@ -206,7 +221,11 @@
206
221
  body: JSON.stringify(body),
207
222
  });
208
223
  const data = await res.json();
209
- if (!res.ok) throw new Error(data.error || `Request failed (${res.status})`);
224
+ if (!res.ok) {
225
+ const err = new Error(data.error || `Request failed (${res.status})`);
226
+ err.code = data.error_type || null;
227
+ throw err;
228
+ }
210
229
  return data;
211
230
  }
212
231
 
@@ -258,7 +277,14 @@
258
277
  setStartBtnBusy(btn, true, t(state.resumable ? "btn.resuming" : "btn.starting"));
259
278
 
260
279
  try {
261
- const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
280
+ const stream = await navigator.mediaDevices.getUserMedia({
281
+ audio: {
282
+ echoCancellation: true,
283
+ noiseSuppression: true,
284
+ autoGainControl: true,
285
+ channelCount: 1,
286
+ },
287
+ });
262
288
  // Resuming an in-progress meeting (after a page refresh): keep the
263
289
  // existing meeting_id so new captions append to the same transcript.
264
290
  if (!(state.resumable && state.meetingId)) {
@@ -292,6 +318,13 @@
292
318
  const AudioCtx = window.AudioContext || window.webkitAudioContext;
293
319
  const audioCtx = new AudioCtx();
294
320
  state.audioCtx = audioCtx;
321
+ // We only get here after two awaits (mic permission + /start), so the
322
+ // context can come up suspended even though the click was a gesture. A
323
+ // suspended context still feeds the MediaRecorder but leaves the analyser
324
+ // reporting pure silence, which reads as "user never spoke".
325
+ if (audioCtx.state === "suspended") {
326
+ audioCtx.resume().catch((e) => console.warn("[meeting] audioCtx.resume failed:", e));
327
+ }
295
328
  const source = audioCtx.createMediaStreamSource(stream);
296
329
  const analyser = audioCtx.createAnalyser();
297
330
  analyser.fftSize = 1024;
@@ -301,27 +334,27 @@
301
334
  let recorder = null;
302
335
  let chunks = [];
303
336
  let hadSpeech = false;
337
+ let speechTicks = 0;
338
+ let noiseFloor = 0.002;
304
339
  let segmentStart = 0;
305
340
  let silenceStart = 0;
306
- let activeSamples = 0;
307
- let totalSamples = 0;
308
341
 
309
342
  function newRecorder() {
310
343
  const r = new MediaRecorder(stream, mime ? { mimeType: mime } : {});
311
344
  chunks = [];
312
345
  hadSpeech = false;
346
+ speechTicks = 0;
313
347
  segmentStart = performance.now();
314
348
  silenceStart = 0;
315
- activeSamples = 0;
316
- totalSamples = 0;
317
349
  r.ondataavailable = (e) => { if (e.data && e.data.size > 0) chunks.push(e.data); };
318
350
  r.onstop = () => {
319
351
  const captured = chunks;
320
- const speech = hadSpeech;
352
+ const spoke = speechTicks >= VAD_MIN_SPEECH_TICKS;
321
353
  const dur = performance.now() - segmentStart;
322
- const ratio = totalSamples > 0 ? activeSamples / totalSamples : 0;
323
354
  if (state.active) newRecorder();
324
- if (speech && dur >= VAD_MIN_SPEECH_MS && ratio >= VAD_MIN_ACTIVE_RATIO && captured.length) {
355
+ // Once the meeting is torn down the transcript is already cleared, so
356
+ // a tail segment must not be shipped to STT.
357
+ if (state.active && spoke && dur >= VAD_MIN_SPEECH_MS && captured.length) {
325
358
  sendAudioChunk(new Blob(captured, mime ? { type: mime } : {}));
326
359
  }
327
360
  };
@@ -342,9 +375,14 @@
342
375
  const now = performance.now();
343
376
  const level = rms();
344
377
 
345
- totalSamples++;
346
- if (level >= VAD_SILENCE_THRESHOLD) {
347
- activeSamples++;
378
+ // Fast down, slow up: a quiet gap drops the floor immediately while
379
+ // speech lifts it only slightly, so it settles on the background level
380
+ // instead of chasing the speaker.
381
+ noiseFloor += (level - noiseFloor) * (level < noiseFloor ? 0.25 : 0.002);
382
+ const threshold = Math.max(VAD_MIN_RMS, noiseFloor * VAD_NOISE_FACTOR);
383
+
384
+ if (level >= threshold) {
385
+ speechTicks++;
348
386
  hadSpeech = true;
349
387
  silenceStart = 0;
350
388
  } else if (hadSpeech) {
@@ -357,12 +395,14 @@
357
395
  if (now - segmentStart >= VAD_MAX_SEGMENT_MS && recorder.state === "recording") {
358
396
  recorder.stop();
359
397
  }
360
-
361
- state.vadRaf = requestAnimationFrame(tick);
362
398
  }
363
399
 
364
400
  newRecorder();
365
- state.vadRaf = requestAnimationFrame(tick);
401
+ // setInterval, not requestAnimationFrame: rAF stops firing while the tab
402
+ // is hidden or the window is fully covered — exactly when a meeting runs —
403
+ // which would leave the recorder on one endless segment.
404
+ if (state.vadTimer) clearInterval(state.vadTimer);
405
+ state.vadTimer = setInterval(tick, VAD_TICK_MS);
366
406
  }
367
407
 
368
408
  // Releases the microphone and forgets everything about the live meeting.
@@ -370,7 +410,7 @@
370
410
  // (generate notes) or /cancel (throw the transcript away) gets called.
371
411
  async function teardownRecording() {
372
412
  state.active = false;
373
- if (state.vadRaf) cancelAnimationFrame(state.vadRaf);
413
+ if (state.vadTimer) clearInterval(state.vadTimer);
374
414
  if (state.mediaRecorder && state.mediaRecorder.state !== "inactive") {
375
415
  state.mediaRecorder.stop();
376
416
  }
@@ -388,7 +428,7 @@
388
428
  state.annotations = [];
389
429
  state.sttError = null;
390
430
  state.audioCtx = null;
391
- state.vadRaf = null;
431
+ state.vadTimer = null;
392
432
  state.stream = null;
393
433
  state.conversationUntil = 0;
394
434
  state.expectingSpeech = false;
@@ -440,26 +480,89 @@
440
480
  }
441
481
 
442
482
  const MIN_AUDIO_BYTES = 2000; // drop near-empty blobs before hitting STT
483
+ const WAV_SAMPLE_RATE = 16000;
484
+
485
+ // DeepSeek ASR decodes only 16 kHz PCM WAV / Ogg Opus, and browsers record
486
+ // webm/opus (Chrome) or mp4/aac (Safari) — neither is accepted. Decoding
487
+ // through Web Audio covers both, so one path serves every browser.
488
+ let transcodeCtx = null;
489
+
490
+ async function toWav16k(blob) {
491
+ try {
492
+ if (!transcodeCtx) transcodeCtx = new (window.AudioContext || window.webkitAudioContext)();
493
+ const decoded = await transcodeCtx.decodeAudioData(await blob.arrayBuffer());
494
+ const frames = Math.ceil(decoded.duration * WAV_SAMPLE_RATE);
495
+ if (!frames) return null;
496
+
497
+ const offline = new OfflineAudioContext(1, frames, WAV_SAMPLE_RATE);
498
+ const source = offline.createBufferSource();
499
+ source.buffer = decoded;
500
+ source.connect(offline.destination);
501
+ source.start();
502
+ const pcm = (await offline.startRendering()).getChannelData(0);
503
+
504
+ const buffer = new ArrayBuffer(44 + pcm.length * 2);
505
+ const view = new DataView(buffer);
506
+ const writeTag = (offset, tag) => {
507
+ for (let i = 0; i < tag.length; i++) view.setUint8(offset + i, tag.charCodeAt(i));
508
+ };
509
+ writeTag(0, "RIFF");
510
+ view.setUint32(4, 36 + pcm.length * 2, true);
511
+ writeTag(8, "WAVE");
512
+ writeTag(12, "fmt ");
513
+ view.setUint32(16, 16, true);
514
+ view.setUint16(20, 1, true); // PCM
515
+ view.setUint16(22, 1, true); // mono
516
+ view.setUint32(24, WAV_SAMPLE_RATE, true);
517
+ view.setUint32(28, WAV_SAMPLE_RATE * 2, true);
518
+ view.setUint16(32, 2, true);
519
+ view.setUint16(34, 16, true);
520
+ writeTag(36, "data");
521
+ view.setUint32(40, pcm.length * 2, true);
522
+ for (let i = 0, offset = 44; i < pcm.length; i++, offset += 2) {
523
+ const s = Math.max(-1, Math.min(1, pcm[i]));
524
+ view.setInt16(offset, s < 0 ? s * 0x8000 : s * 0x7fff, true);
525
+ }
526
+ return new Blob([buffer], { type: "audio/wav" });
527
+ } catch (err) {
528
+ // Keep the original container: the gateway falls back to Gemini for it.
529
+ console.warn("[meeting] wav transcode failed, sending original:", err);
530
+ return null;
531
+ }
532
+ }
443
533
 
444
534
  async function sendAudioChunk(blob) {
535
+ // teardownRecording() stops the recorder, which still fires a last onstop.
536
+ if (!state.active) return;
445
537
  if (state.micMuted) return;
446
538
  if (!blob || blob.size < MIN_AUDIO_BYTES) return; // too little audio to be speech
447
- const buf = await blob.arrayBuffer();
539
+
540
+ const wav = await toWav16k(blob);
541
+ if (!state.active || state.micMuted) return;
542
+ const payload = wav || blob;
543
+ const mimeType = wav ? "audio/wav" : blob.type;
544
+
545
+ const buf = await payload.arrayBuffer();
448
546
  const bytes = new Uint8Array(buf);
449
547
  let binary = "";
450
548
  for (let i = 0; i < bytes.length; i++) binary += String.fromCharCode(bytes[i]);
451
549
  const base64 = btoa(binary);
452
550
 
551
+ // A cancel or restart while STT is running must not leak into the new round.
552
+ const meetingId = state.meetingId;
553
+ const stale = () => state.meetingId !== meetingId;
554
+
453
555
  state.transcribing++;
454
556
  updateStatus();
455
557
  try {
456
558
  const result = await postJson("/transcribe", {
457
559
  session_id: state.sessionId,
458
- meeting_id: state.meetingId,
560
+ meeting_id: meetingId,
459
561
  audio_base64: base64,
460
- mime_type: blob.type,
562
+ mime_type: mimeType,
461
563
  vocabulary: state.vocabulary,
462
564
  });
565
+ if (stale()) return;
463
566
 
464
567
  if (result.text && result.text.trim()) {
465
568
  const entry = { ts: Date.now(), text: result.text.trim() };
@@ -472,12 +575,15 @@
472
575
  updateSttError();
473
576
  }
474
577
  } catch (e) {
578
+ if (stale()) return;
475
579
  console.error("STT failed:", e.message);
476
- state.sttError = e.message;
580
+ state.sttError = { code: e.code || null, message: e.message };
477
581
  updateSttError();
478
582
  } finally {
479
- state.transcribing = Math.max(0, state.transcribing - 1);
480
- updateStatus();
583
+ if (!stale()) {
584
+ state.transcribing = Math.max(0, state.transcribing - 1);
585
+ updateStatus();
586
+ }
481
587
  }
482
588
  }
483
589
 
@@ -596,16 +702,65 @@
596
702
  }
597
703
  }
598
704
 
705
+ // Lands on the exact row that fixes it (Settings → Models → Speech-to-Text)
706
+ // instead of the top of the settings page; the row keeps a short outline so
707
+ // the eye finds it after the tab renders.
708
+ function openSttSettings() {
709
+ location.hash = "#settings";
710
+ let tries = 0;
711
+ let tabClicked = false;
712
+ const attempt = () => {
713
+ tries += 1;
714
+ const tab = document.querySelector('#settings-tabs .settings-tab[data-tab="models"]');
715
+ if (tab && !tabClicked) {
716
+ tab.click();
717
+ tabClicked = true;
718
+ }
719
+ const row = document.querySelector('#media-rows .media-row[data-kind="stt"]');
720
+ if (row) {
721
+ row.scrollIntoView({ block: "center", behavior: "smooth" });
722
+ row.classList.add("is-flash");
723
+ setTimeout(() => row.classList.remove("is-flash"), 1800);
724
+ return;
725
+ }
726
+ if (tries < 40) setTimeout(attempt, 100);
727
+ };
728
+ attempt();
729
+ }
730
+
599
731
  function updateSttError() {
600
732
  const el = document.getElementById("meeting-stt-error");
601
733
  if (!el) return;
602
- if (state.sttError) {
603
- el.textContent = t("stt.failed", { msg: state.sttError });
604
- el.style.display = "block";
605
- } else {
734
+ const err = state.sttError;
735
+ if (!err) {
606
736
  el.textContent = "";
737
+ el.dataset.sig = "";
607
738
  el.style.display = "none";
739
+ el.classList.remove("is-actionable");
740
+ return;
741
+ }
742
+ // Failing every segment (~10s) must not rebuild the block under the
743
+ // pointer: the same message stays put.
744
+ const sig = err.code === STT_NOT_CONFIGURED ? err.code : "msg:" + err.message;
745
+ if (el.dataset.sig === sig && el.style.display !== "none") return;
746
+ el.dataset.sig = sig;
747
+ el.innerHTML = "";
748
+ el.style.display = "";
749
+ el.classList.toggle("is-actionable", err.code === STT_NOT_CONFIGURED);
750
+
751
+ if (err.code === STT_NOT_CONFIGURED) {
752
+ const text = document.createElement("span");
753
+ text.textContent = t("stt.notConfigured");
754
+ const action = document.createElement("button");
755
+ action.type = "button";
756
+ action.className = "meeting-stt-error-action";
757
+ action.textContent = t("stt.goSettings");
758
+ action.addEventListener("click", openSttSettings);
759
+ el.append(text, action);
760
+ return;
608
761
  }
762
+
763
+ el.textContent = t("stt.failed", { msg: err.message });
609
764
  }
610
765
 
611
766
  function updateCaptions() {
@@ -1033,7 +1188,7 @@
1033
1188
  dispose() {
1034
1189
  _sessionsById.delete(ctx.sessionId);
1035
1190
  state.active = false;
1036
- if (state.vadRaf) cancelAnimationFrame(state.vadRaf);
1191
+ if (state.vadTimer) clearInterval(state.vadTimer);
1037
1192
  try { if (state.mediaRecorder && state.mediaRecorder.state !== "inactive") state.mediaRecorder.stop(); } catch (_) {}
1038
1193
  if (state.stream) state.stream.getTracks().forEach((t) => t.stop());
1039
1194
  if (state.audioCtx) { try { state.audioCtx.close(); } catch (_) {} }
@@ -1049,7 +1204,7 @@
1049
1204
  render(container, ctx, runtime) { runtime.attach(container); },
1050
1205
  }, {
1051
1206
  tab: { id: "meeting", label: () => t("tab.label") },
1052
- order: 200,
1207
+ order: 60,
1053
1208
  });
1054
1209
 
1055
1210
  // Inject minimal styles
@@ -1103,6 +1258,9 @@
1103
1258
  .meeting-bar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
1104
1259
  .meeting-tip-compact { padding: 7px 10px; font-size: 12px; }
1105
1260
  .meeting-stt-error { background: var(--color-error-bg); color: var(--color-error); border: 1px solid var(--color-error-border); border-radius: var(--radius-md); padding: 8px 10px; margin-top: 10px; font-size: 12px; line-height: 1.4; }
1261
+ .meeting-stt-error.is-actionable { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
1262
+ .meeting-stt-error-action { flex: none; margin-left: auto; background: transparent; border: 1px solid var(--color-error-border); border-radius: 6px; color: var(--color-error); font-family: inherit; font-size: 12px; line-height: 1.4; padding: 2px 8px; cursor: pointer; }
1263
+ .meeting-stt-error-action:hover { background: color-mix(in srgb, var(--color-error) 10%, transparent); }
1106
1264
  .meeting-section { margin-top: 20px; }
1107
1265
  .meeting-section-title { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; font-size: 13px; font-weight: 600; color: var(--color-text-primary); }
1108
1266
  .meeting-count { font-size: 12px; font-weight: 400; color: var(--color-text-muted); }
@@ -1125,7 +1283,7 @@
1125
1283
  .meeting-wave i:nth-child(3) { animation-delay: .3s; }
1126
1284
  .meeting-wave i:nth-child(4) { animation-delay: .45s; }
1127
1285
  @keyframes meeting-wave { 0%, 100% { height: 4px; } 50% { height: 12px; } }
1128
- /* Narrow panels (aside can shrink to 256px): drop the discard label and
1286
+ /* Narrow panels (aside can shrink to 296px): drop the discard label and
1129
1287
  give the controls their own row instead of squeezing the status. */
1130
1288
  @container (max-width: 360px) {
1131
1289
  .meeting-bar { flex-wrap: wrap; row-gap: 8px; }
@@ -7,7 +7,8 @@
7
7
  </defs>
8
8
  <rect width="36" height="36" fill="url(#preview-bg)"/>
9
9
  <g transform="translate(8 8) scale(0.8333)" stroke="#fff" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
10
- <path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"/>
11
- <circle cx="12" cy="12" r="3"/>
10
+ <circle cx="12" cy="12" r="10"/>
11
+ <path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"/>
12
+ <path d="M2 12h20"/>
12
13
  </g>
13
14
  </svg>
@@ -33,7 +33,7 @@
33
33
  "confirm": "Reply",
34
34
  "review": "Discuss",
35
35
  "discuss": "Discuss with secretary",
36
- "history": "Open execution history",
36
+ "history": "Execution history",
37
37
  "technical": "Execution details",
38
38
  "plans": "Recurring plans",
39
39
  "nextRun": "Next run: ",
@@ -41,6 +41,14 @@
41
41
  "daily": "Daily at {time}",
42
42
  "weekdays": "Weekdays at {time}",
43
43
  "planDraft": "I would like to change the plan “{title}”: ",
44
+ "badge_needs_input": "Needs reply",
45
+ "badge_failed": "Needs attention",
46
+ "badge_running": "In progress",
47
+ "badge_queued": "Queued",
48
+ "badge_waiting_event": "Waiting",
49
+ "badge_completed": "Completed",
50
+ "badge_paused": "Paused",
51
+ "badge_cancelled": "Cancelled",
44
52
  "title": "Work"
45
53
  },
46
54
  "zh": {
@@ -75,7 +83,7 @@
75
83
  "confirm": "去回复",
76
84
  "review": "去讨论",
77
85
  "discuss": "与秘书讨论",
78
- "history": "查看执行记录",
86
+ "history": "执行记录",
79
87
  "technical": "执行详情",
80
88
  "plans": "定时安排",
81
89
  "nextRun": "下次执行:",
@@ -83,6 +91,14 @@
83
91
  "daily": "每天 {time}",
84
92
  "weekdays": "工作日 {time}",
85
93
  "planDraft": "我想调整「{title}」这个定时安排:",
94
+ "badge_needs_input": "待协助",
95
+ "badge_failed": "需处理",
96
+ "badge_running": "处理中",
97
+ "badge_queued": "排队中",
98
+ "badge_waiting_event": "等待中",
99
+ "badge_completed": "已完成",
100
+ "badge_paused": "已暂停",
101
+ "badge_cancelled": "已取消",
86
102
  "title": "工作事项"
87
103
  }
88
104
  };
@@ -92,6 +108,35 @@
92
108
  return text.replace(/\{(\w+)\}/g, (_, name) => vars[name] ?? "");
93
109
  };
94
110
  const attention = card => ['needs_input', 'failed'].includes(card.status);
111
+ // tone picks the colour tokens in styles(); loud marks the states that ask the user to act.
112
+ const ring = extra => ['circle', Object.assign({ cx: 7, cy: 7, r: 6, fill: 'none', stroke: 'currentColor', 'stroke-width': 1.5 }, extra)];
113
+ const line = (d, width, extra) => ['path', Object.assign({ d, fill: 'none', stroke: 'currentColor', 'stroke-width': width || 1.5, 'stroke-linecap': 'round' }, extra)];
114
+ const STATUS_BADGE = {
115
+ needs_input: { tone: 'warn', loud: true, icon: [ring(), line('M7 3.8v3.9'), ['circle', { cx: 7, cy: 10, r: 0.9, fill: 'currentColor' }]] },
116
+ failed: { tone: 'err', loud: true, icon: [ring(), line('M4.8 4.8l4.4 4.4M9.2 4.8l-4.4 4.4')] },
117
+ running: { tone: 'live', icon: [ring({ 'stroke-opacity': 0.3 }), line('M7 1a6 6 0 0 1 6 6', 1.5, { class: 'secretary-work-spin' })] },
118
+ queued: { tone: 'mute', icon: [ring({ 'stroke-dasharray': '2.5 2' })] },
119
+ waiting_event: { tone: 'info', icon: [ring(), line('M7 4v3.2l2 1.2', 1.4)] },
120
+ completed: { tone: 'ok', icon: [['circle', { cx: 7, cy: 7, r: 6.5, fill: 'currentColor' }], line('M4.4 7.2l1.9 1.9 3.4-3.6', 1.5, { stroke: 'var(--color-bg-secondary)', 'stroke-linejoin': 'round' })] },
121
+ paused: { tone: 'mute', icon: [ring(), line('M5.4 4.8v4.4M8.6 4.8v4.4')] },
122
+ cancelled: { tone: 'mute', icon: [ring(), line('M4.5 7h5')] }
123
+ };
124
+ const CHEVRON = [line('M2.5 3.8L5 6.3l2.5-2.5', 1.4, { 'stroke-linejoin': 'round' })];
125
+ const svg = (size, viewBox, shapes, cls) => {
126
+ const NS = 'http://www.w3.org/2000/svg';
127
+ const node = document.createElementNS(NS, 'svg');
128
+ node.setAttribute('viewBox', viewBox);
129
+ node.setAttribute('width', size);
130
+ node.setAttribute('height', size);
131
+ node.setAttribute('aria-hidden', 'true');
132
+ if (cls) node.setAttribute('class', cls);
133
+ shapes.forEach(([tag, attrs]) => {
134
+ const child = document.createElementNS(NS, tag);
135
+ Object.keys(attrs).forEach(key => child.setAttribute(key, attrs[key]));
136
+ node.append(child);
137
+ });
138
+ return node;
139
+ };
95
140
  const el = (tag, text, cls) => {
96
141
  const node = document.createElement(tag);
97
142
  if (text) node.textContent = text;
@@ -161,15 +206,21 @@
161
206
  const concise = String(card.display_summary || '').trim();
162
207
  if (concise && concise.length <= 100) return concise;
163
208
  const text = String(card.progress || '').trim();
164
- if (['needs_input', 'waiting_event'].includes(card.status) && text.length <= 100 &&
165
- !/[\n\r`#]|https?:\/\//.test(text) && text) return text;
166
- return t(card.status);
209
+ if (text && text.length <= 100 && !/[\n\r`#]|https?:\/\//.test(text)) return text;
210
+ return '';
167
211
  }
168
212
  function dateText(value) {
169
213
  if (!value) return '';
170
214
  const date = new Date(value);
171
215
  return Number.isNaN(date.getTime()) ? '' : date.toLocaleString(locale());
172
216
  }
217
+ function shortDate(value) {
218
+ if (!value) return '';
219
+ const date = new Date(value);
220
+ if (Number.isNaN(date.getTime())) return '';
221
+ const pad = number => String(number).padStart(2, '0');
222
+ return pad(date.getMonth() + 1) + '-' + pad(date.getDate()) + ' ' + pad(date.getHours()) + ':' + pad(date.getMinutes());
223
+ }
173
224
  function cadence(plan) {
174
225
  const fields = String(plan.cron || '').trim().split(/\s+/);
175
226
  if (fields.length === 5 && /^\d+$/.test(fields[0]) && /^\d+$/.test(fields[1]) &&
@@ -188,27 +239,44 @@
188
239
  .secretary-work-muted { color:var(--color-text-secondary); font-size:12px; }
189
240
  .secretary-work-group { margin-bottom:24px; }
190
241
  .secretary-work-heading { margin:0 0 8px; font-size:12px; font-weight:600; color:var(--color-text-secondary); }
191
- .secretary-work-card { padding:10px 0; border-bottom:1px solid var(--color-border-primary); }
192
- .secretary-work-card:last-child { border-bottom:0; }
242
+ .secretary-work-card { padding:12px 14px; margin-bottom:8px; background:var(--color-bg-card); border:1px solid var(--color-border-primary); border-radius:10px; transition:border-color var(--transition-fast, 120ms ease); }
243
+ .secretary-work-card:hover { border-color:var(--color-border-strong); }
193
244
  .secretary-work summary { cursor:pointer; }
194
245
  .secretary-work summary:focus-visible, .secretary-work button:focus-visible { outline:2px solid var(--color-text-secondary); outline-offset:3px; }
195
246
  .secretary-work-main > summary { list-style:none; position:relative; padding-right:18px; }
196
247
  .secretary-work-main > summary::-webkit-details-marker { display:none; }
197
248
  .secretary-work-main > summary::after { content:'›'; position:absolute; right:0; top:0; color:var(--color-text-tertiary); }
198
249
  .secretary-work-main[open] > summary::after { transform:rotate(90deg); }
199
- .secretary-work-title { display:block; font-weight:500; overflow-wrap:anywhere; }
200
- .secretary-work-brief { display:block; margin-top:3px; color:var(--color-text-secondary); overflow-wrap:anywhere; }
250
+ .secretary-work-head { display:flex; align-items:flex-start; gap:8px; }
251
+ .secretary-work-icon { flex:none; margin-top:3px; color:var(--tone); }
252
+ .secretary-work-title { display:block; flex:1; min-width:0; font-weight:500; overflow-wrap:anywhere; }
253
+ .secretary-work-label { flex:none; font-size:11px; line-height:18px; color:var(--tone-fg); white-space:nowrap; }
254
+ .secretary-work-label.is-loud { padding:0 7px; border-radius:var(--radius-pill, 999px); background:var(--tone-bg); border:1px solid var(--tone-bd); }
255
+ .tone-warn { --tone:var(--color-warning); --tone-fg:var(--color-warning-text); --tone-bg:var(--color-warning-bg); --tone-bd:var(--color-warning-border); }
256
+ .tone-err { --tone:var(--color-error); --tone-fg:var(--color-error); --tone-bg:var(--color-error-bg); --tone-bd:var(--color-error-border); }
257
+ .tone-ok { --tone:var(--color-success); --tone-fg:var(--color-success); }
258
+ .tone-live { --tone:var(--live); --tone-fg:var(--live); }
259
+ .tone-info { --tone:var(--color-info); --tone-fg:var(--color-info); }
260
+ .tone-mute { --tone:var(--color-text-tertiary); --tone-fg:var(--color-text-tertiary); }
261
+ .is-cancelled .secretary-work-title { color:var(--color-text-tertiary); text-decoration:line-through; text-decoration-color:var(--color-border-strong); }
262
+ .is-cancelled .secretary-work-brief { color:var(--color-text-tertiary); }
263
+ .secretary-work-spin { animation:secretary-work-spin 1.2s linear infinite; transform-origin:50% 50%; }
264
+ @keyframes secretary-work-spin { to { transform:rotate(360deg); } }
265
+ .secretary-work-brief { display:block; margin:3px 0 0 22px; font-size:12px; color:var(--color-text-secondary); overflow-wrap:anywhere; }
266
+ .secretary-work-check { display:block; margin:3px 0 0 22px; }
201
267
  .secretary-work-content { white-space:pre-wrap; overflow-wrap:anywhere; margin:10px 0; }
202
- .secretary-work-meta { display:flex; flex-wrap:wrap; gap:2px 10px; margin-top:3px; }
203
- .secretary-work-actions { margin-top:10px; display:flex; align-items:center; gap:14px; }
204
- .secretary-work-actions a { font-size:12px; color:var(--color-text-secondary); text-decoration:none; }
205
- .secretary-work-actions a:hover { text-decoration:underline; }
206
- .secretary-work-details { margin-top:10px; color:var(--color-text-secondary); font-size:12px; }
207
- .secretary-work-details > summary { list-style:none; }
268
+ .secretary-work-footer { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:6px 12px; margin:10px 0 0; color:var(--color-text-tertiary); }
269
+ .secretary-work-actions { display:flex; align-items:center; gap:10px; margin-left:auto; white-space:nowrap; }
270
+ .secretary-work-footer a { color:var(--color-text-secondary); text-decoration:none; }
271
+ .secretary-work-footer a:hover { text-decoration:underline; }
272
+ .secretary-work-details { margin:8px 0 0 22px; color:var(--color-text-secondary); font-size:12px; }
273
+ .secretary-work-details > summary { list-style:none; display:inline-flex; align-items:center; gap:4px; color:var(--color-text-tertiary); border-radius:var(--radius-xs, 4px); }
208
274
  .secretary-work-details > summary::-webkit-details-marker { display:none; }
209
- .secretary-work-details > summary::after { content:" +"; }
210
- .secretary-work-details[open] > summary::after { content:" −"; }
211
- .secretary-work button { cursor:pointer; border:1px solid var(--color-border-primary); border-radius:var(--radius-sm, 6px); background:var(--color-bg-secondary); color:inherit; padding:4px 10px; font:inherit; }
275
+ .secretary-work-details > summary:hover { color:var(--color-text-secondary); }
276
+ .secretary-work-chevron { transition:transform var(--transition-fast, 120ms ease); }
277
+ .secretary-work-details[open] .secretary-work-chevron { transform:rotate(180deg); }
278
+ .secretary-work button { cursor:pointer; border:1px solid var(--color-border-primary); border-radius:var(--radius-sm, 6px); background:transparent; color:var(--color-text-primary); padding:3px 10px; font:inherit; }
279
+ .secretary-work button:hover { background:var(--color-bg-hover); border-color:var(--color-border-strong); }
212
280
  .secretary-work-nested { margin-top:10px; font-size:12px; }
213
281
  .secretary-work-status { display:flex; flex-wrap:wrap; gap:8px; align-items:center; padding:6px 0; }
214
282
  .secretary-work-status-title { color:var(--color-text-secondary); }
@@ -235,32 +303,39 @@
235
303
  return node;
236
304
  }
237
305
  function workRow(card) {
238
- const row = el('article', null, 'secretary-work-card');
239
- row.append(el('strong', card.title, 'secretary-work-title'));
240
- const meta = el('div', null, 'secretary-work-meta secretary-work-muted');
241
- meta.append(el('span', brief(card)));
242
- const created = dateText(card.created_at);
306
+ const row = el('article', null, 'secretary-work-card is-' + card.status);
307
+ const badge = STATUS_BADGE[card.status] || STATUS_BADGE.queued;
308
+ const head = el('div', null, 'secretary-work-head tone-' + badge.tone);
309
+ head.append(svg(14, '0 0 14 14', badge.icon, 'secretary-work-icon'), el('strong', card.title, 'secretary-work-title'),
310
+ el('span', t('badge_' + card.status), 'secretary-work-label' + (badge.loud ? ' is-loud' : '')));
311
+ row.append(head);
312
+ const summary = brief(card);
313
+ if (summary) row.append(el('div', summary, 'secretary-work-brief'));
314
+ const check = dateText(card.waiting?.check_at);
315
+ if (card.status === 'waiting_event' && check) row.append(el('small', t('check') + check, 'secretary-work-muted secretary-work-check'));
316
+ const footer = el('div', null, 'secretary-work-footer secretary-work-muted');
317
+ const created = shortDate(card.created_at);
243
318
  if (created) {
244
- const time = el('time', t('created') + created);
319
+ const time = el('time', created);
245
320
  time.dateTime = card.created_at;
246
- meta.append(time);
321
+ time.title = t('created') + dateText(card.created_at);
322
+ footer.append(time);
247
323
  }
248
- row.append(meta);
249
- const check = dateText(card.waiting?.check_at);
250
- if (card.status === 'waiting_event' && check) row.append(el('small', t('check') + check, 'secretary-work-muted'));
251
- const actions = el('div', null, 'secretary-work-actions');
252
- actions.append(button(t('discuss'), () => discuss(card, ctx.sessionId)));
253
324
  const link = el('a', t('history'));
254
325
  link.href = '#session/' + encodeURIComponent(card.session_id);
255
- actions.append(link);
256
- row.append(actions);
326
+ const actions = el('div', null, 'secretary-work-actions');
327
+ actions.append(link, button(t('discuss'), () => discuss(card, ctx.sessionId)));
328
+ footer.append(actions);
257
329
  if (card.instruction || card.constraints || card.updates?.length) {
258
- const details = disclosure('work:' + card.id, el('summary', t('requirements')), 'secretary-work-details');
330
+ const toggle = el('summary', t('requirements'));
331
+ toggle.append(svg(10, '0 0 10 10', CHEVRON, 'secretary-work-chevron'));
332
+ const details = disclosure('work:' + card.id, toggle, 'secretary-work-details');
259
333
  if (card.instruction) details.append(el('div', card.instruction, 'secretary-work-content'));
260
334
  if (card.constraints) details.append(el('div', t('constraints') + card.constraints, 'secretary-work-content'));
261
335
  (card.updates || []).forEach(update => details.append(el('div', update.text, 'secretary-work-content')));
262
336
  row.append(details);
263
337
  }
338
+ row.append(footer);
264
339
  return row;
265
340
  }
266
341
  function render() {