@goodandready/dsh-voice 0.9.57 → 0.9.59

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 CHANGED
@@ -73,7 +73,7 @@ graph LR
73
73
  ---
74
74
 
75
75
  ## ✨ Key Features
76
- - 🎙️ **4 Dictation Post-Processing Modes (#264)**: Verbatim (0 LLM calls, raw STT), Clean text (punctuation & filler removal without fact alteration), Agent task (structured problem/goals/criteria), and Note (key thoughts & actions). Customizable prompt templates with 1-click default restore.
76
+ - 🎙️ **5 Dictation Post-Processing Modes (#264, #346)**: Verbatim (0 LLM calls, raw STT), Clean text (punctuation & filler removal), Agent task (structured problem/goals/criteria), Bug report (structured problem/repro steps/expected), and Note (key thoughts & actions). Customizable prompt templates with 1-click default restore.
77
77
  - ⚡ **Dynamic Context-Aware Lexicon Boosting (#167)**: Gathers technical identifiers, code tokens, and vocabulary from composer drafts, recent chat history, and open code blocks, passing them as hints to Deepgram (`&keywords=...`), Groq, local-whisper, and SenseVoice.
78
78
  - 🎯 **Voice Action Macros (#167)**: User-defined spoken trigger phrases (e.g. "review code", "run tests") expand into structured prompt templates with `{text}` argument replacement.
79
79
 
@@ -101,7 +101,7 @@ graph LR
101
101
 
102
102
  ---
103
103
 
104
- ## 📝 What's New in 0.8.32
104
+ ## 📝 Architecture & Features (0.9.x)
105
105
 
106
106
  10-point feature epic & SenseVoice 1-Click Installer (Issue #129):
107
107
 
@@ -235,7 +235,7 @@ Open **Settings → Plugins → Plugin settings → Voice** in the Web UI:
235
235
  Registers `transcribe_audio(file_path, language?)` in `ctx.tools`, allowing agents to analyze audio files, interview recordings, and voice notes directly from disk. Path containment is strictly enforced against allowed directories (`allowedAudioDirs`, `~/.dsh`, `tmpdir`, `cwd`) with symlink traversal escape prevention and magic-byte audio format validation.
236
236
 
237
237
  ### Internal HTTP & WebSocket Endpoints
238
- * `GET /dsh-voice/ws/stream` — RFC 6455 WebSocket streaming channel for real-time dictation with interim transcription previews (`{ type: 'interim', text }`) and final transcript dispatch (`{ type: 'final', text, action, provider }`). Authenticated via `hasSameOrigin` or `x-dsh-voice-token` (#282, #292).
238
+ * `WebSocket /dsh-voice/ws/stream` — RFC 6455 WebSocket streaming channel (HTTP Upgrade) for real-time dictation with interim transcription previews (`{ type: 'interim', text }`) and final transcript dispatch (`{ type: 'final', text, action, provider }`). Authenticated via `hasSameOrigin` or `x-dsh-voice-token` (#282, #292).
239
239
  * `POST /dsh-voice/transcribe` — `{ dataBase64, mimeType, mode }` → `{ ok, text, provider, tookMs }`
240
240
  * `POST /dsh-voice/polish` — `{ text }` → `{ ok, text }`
241
241
  * `GET /dsh-voice/status` — Returns daemon status, active chains, SenseVoice and `effectiveSensevoiceProvider`. Emits `sessionToken` exclusively to verified same-origin callers (#292).
package/README.ru.md CHANGED
@@ -73,7 +73,7 @@ graph LR
73
73
  ---
74
74
 
75
75
  ## ✨ Ключевые возможности
76
- - 🎙️ **4 режима диктовки (#264)**: «Дословно» (0 вызовов LLM, чистый STT), «Чистый текст» (пунктуация и удаление мусорных слов без искажения фактов), «Задача агенту» (структурированная формулировка проблемы, целей и критериев приёмки), «Заметка» (ключевые мысли и задачи). Настраиваемые шаблоны с кнопкой сброса к стандартам.
76
+ - 🎙️ **5 режимов диктовки (#264, #346)**: «Дословно» (0 вызовов LLM, чистый STT), «Чистый текст» (пунктуация и удаление мусорных слов), «Задача агенту» (структурированная формулировка проблемы, целей и критериев), «Отчёт о баге» (структурированные шаги воспроизведения и ошибки) и «Заметка» (ключевые мысли и задачи). Настраиваемые шаблоны с кнопкой сброса к стандартам.
77
77
  - ⚡ **Контекстный бустинг лексикона (#167)**: сбор терминов и идентификаторов из активного черновика, последних сообщений чата и блоков кода в DOM, с передачей в Deepgram (`&keywords`), Groq (`prompt`), local-whisper и SenseVoice.
78
78
  - 🎯 **Голосовые макросы (#167)**: настраиваемые шаблоны голосовых действий («сделай ревью», «запусти тесты»), автоматически раскрывающиеся в структурированные промпты с подстановкой `{text}`.
79
79
 
@@ -101,7 +101,7 @@ graph LR
101
101
 
102
102
  ---
103
103
 
104
- ## 📝 Что нового в 0.8.32
104
+ ## 📝 Архитектура и возможности (0.9.x)
105
105
 
106
106
  Пакет из 10 улучшений и установка SenseVoice в 1 клик (Issue #129):
107
107
 
package/README.zh.md CHANGED
@@ -73,7 +73,7 @@ graph LR
73
73
  ---
74
74
 
75
75
  ## ✨ 核心亮点
76
- - 🎙️ **4 种听写后处理模式 (#264)**:逐字直录(0 次 LLM 调用)、清爽文本(整理标点符号与语气词)、智能体任务(结构化问题、目标与验收标准)、便签备忘(要点与行动项)。支持自定义提示词模板与一键重置。
76
+ - 🎙️ **5 种听写后处理模式 (#264, #346)**:逐字直录(0 次 LLM 调用)、清爽文本(整理标点符号与语气词)、智能体任务(结构化问题、目标与验收标准)、缺陷报告(问题概要与复现步骤)、便签备忘(要点与行动项)。支持自定义提示词模板与一键重置。
77
77
  - ⚡ **动态会话上下文词汇增强 (#167)**:自动提取输入框草稿、会话消息与代码块中的专业术语,透传给 Deepgram、Groq、local-whisper 与 SenseVoice 识别引擎。
78
78
  - 🎯 **语音动作宏指令 (#167)**:语音短语(如“做代码审查”、“运行测试”)自动展开为带有 `{text}` 参数替换的结构化提示词模板。
79
79
 
package/lib/client.js CHANGED
@@ -53,8 +53,8 @@ const en = {
53
53
  'pauseHint':'Pause duration that triggers phrase cut', 'speaking':'You are speaking…',
54
54
  'silence':'Pause…', 'normalizeTranscript':'Normalize file transcripts', 'undo':'Undo last insert', 'undone':'Insert undone',
55
55
  'nothingToUndo':'Nothing to undo', 'clipping':'Clipping', 'clippingHint':'Too loud (clipping)', 'lowVolume':'Low signal',
56
- 'lowVolumeHint':'Speak louder', 'vadEngine':'VAD engine', 'vadEngineHint':'Neural Silero VAD (WASM/ONNX) or classic amplitude gate',
57
- 'vadSilero':'Silero VAD (neural)', 'vadAmplitude':'Amplitude gate', 'streamingWs':'Streaming WebSocket',
56
+ 'lowVolumeHint':'Speak louder', 'vadEngine':'VAD engine', 'vadEngineHint':'Acoustic heuristic VAD (RMS/ZCR) or classic amplitude gate',
57
+ 'vadSilero':'Heuristic VAD (RMS/ZCR)', 'vadAmplitude':'Amplitude gate', 'streamingWs':'Streaming WebSocket',
58
58
  'streamingWsHint':'Real-time WebSocket audio streaming to local ASR', 'beep':'Beep on start/stop', 'localOnly':'Local whisper only',
59
59
  'localOnlyHint':'Restrict both chains to the local whisper.cpp server: fully offline.', 'sendDelay':'Dictation send delay (ms)',
60
60
  'sendDelayHint':'Wait before appending a dictated phrase, with a cancel window. 0 = off', 'mic':'Microphone',
@@ -214,7 +214,7 @@ const zh = {
214
214
  'langDe':'德语 (de)', 'dictationHint':'语音按停顿自动切句,文字实时追加至输入框。', 'pauseMs':'断句静音停顿时长(毫秒)', 'pauseHint':'数值越小切分越频繁、出字越快,但可能切断未说完的词',
215
215
  'speaking':'正在说话…', 'silence':'停顿…', 'normalizeTranscript':'规范化转写文本', 'undo':'撤销上次插入', 'undone':'插入已撤销', 'nothingToUndo':'没有可撤销的内容',
216
216
  'clipping':'爆音', 'clippingHint':'音量过大(爆音截断)', 'lowVolume':'信号微弱', 'lowVolumeHint':'请提高音量', 'vadEngine':'VAD 引擎',
217
- 'vadEngineHint':'神经网络 Silero VAD (WASM/ONNX) 或传统振幅门限', 'vadSilero':'Silero VAD(神经网络)', 'vadAmplitude':'振幅门限',
217
+ 'vadEngineHint':'声学启发式 VAD (RMS/ZCR) 或传统振幅门限', 'vadSilero':'启发式 VAD (RMS/ZCR)', 'vadAmplitude':'振幅门限',
218
218
  'streamingWs':'流式 WebSocket', 'streamingWsHint':'向本地 ASR 实时通过 WebSocket 流式传输音频', 'beep':'启停提示音', 'localOnly':'仅使用本地 whisper',
219
219
  'localOnlyHint':'将双链限制为仅使用本地 whisper.cpp 服务:纯离线运行。', 'sendDelay':'听写延迟追加 (ms)', 'sendDelayHint':'追加听写文本前的缓冲等待时间,允许撤回。0 为关闭',
220
220
  'mic':'麦克风设备', 'micDefault':'系统默认', 'vocabulary':'自定义词汇表(每行一个词)', 'polish':'模型润色转写文本', 'polishHint':'插入前通过模型修正标点符号并消除语气口头禅',
@@ -2398,7 +2398,7 @@ setTimeout(() => { if (voice.lastUndoNotice === msg) { voice.lastUndoNotice = ''
2398
2398
  })
2399
2399
  }
2400
2400
  }
2401
- const DICTATION_MODES = ['clean', 'task', 'note', 'verbatim']
2401
+ const DICTATION_MODES = ['clean', 'task', 'note', 'bug', 'verbatim']
2402
2402
  function getDictationModeLabel(m, t) {
2403
2403
  const trans = t || moduleT
2404
2404
  if (m === 'verbatim') return trans('modeVerbatim')
@@ -2,6 +2,7 @@
2
2
  // Solves DSH network limitation where client-side persistence is blocked in non-loopback environments (Gitea #149).
3
3
 
4
4
  import { writeJson, readBody, isTrustedCaller, rotateVoiceSessionToken, getVoiceSessionToken } from './http-util.js'
5
+ import { bestEffort } from './best-effort.js'
5
6
 
6
7
  export function registerConfigRoutes(ctx, {
7
8
  NS,
@@ -33,7 +34,9 @@ export function registerConfigRoutes(ctx, {
33
34
  try {
34
35
  const settingsService = getSettingsService?.()
35
36
  rev = settingsService?.describe?.()?.find?.((r) => r.ns === NS)?.revision
36
- } catch { /* ignore revision lookup errors */ }
37
+ } catch (revErr) {
38
+ bestEffort('readRevision', () => { throw revErr }, ctx?.logger)
39
+ }
37
40
  writeJson(res, 200, { ok: true, config: live(), revision: rev })
38
41
  return
39
42
  }
@@ -103,7 +106,9 @@ export function registerConfigRoutes(ctx, {
103
106
  let currentRev
104
107
  try {
105
108
  currentRev = settingsService.describe?.()?.find?.((r) => r.ns === NS)?.revision
106
- } catch { /* ignore revision lookup errors */ }
109
+ } catch (revErr) {
110
+ bestEffort('readRevision', () => { throw revErr }, ctx?.logger)
111
+ }
107
112
 
108
113
  if (typeof expectedRevision === 'number' && typeof currentRev === 'number' && expectedRevision !== currentRev) {
109
114
  writeJson(res, 409, {
@@ -158,7 +163,7 @@ export function registerConfigRoutes(ctx, {
158
163
  try {
159
164
  newRev = settingsService?.describe?.()?.find?.((r) => r.ns === NS)?.revision
160
165
  } catch (revErr) {
161
- bestEffort('readRevision', () => { throw revErr })
166
+ bestEffort('readRevision', () => { throw revErr }, ctx?.logger)
162
167
  }
163
168
  writeJson(res, 200, { ok: true, config: live(), revision: newRev, sessionToken: getVoiceSessionToken() })
164
169
  } catch (err) {
@@ -1,6 +1,6 @@
1
1
  // lib/dictation-modes.js — Dictation post-processing modes (#264, #321)
2
2
 
3
- export const DICTATION_MODES = ['verbatim', 'clean', 'task', 'note']
3
+ export const DICTATION_MODES = ['verbatim', 'clean', 'task', 'note', 'bug']
4
4
  export const ALL_DICTATION_MODES = ['verbatim', 'clean', 'task', 'note', 'bug']
5
5
 
6
6
  export const DEFAULT_DICTATION_PROMPTS = {
@@ -5,6 +5,7 @@ import { resolveSensevoiceProvider } from './sensevoice-installer.js'
5
5
  import { applyVoiceMacros } from './macros.js'
6
6
  import { createSyntheticWav } from './wav.js'
7
7
  import { handleWsUpgrade } from './ws-framer.js'
8
+ import { defaultProviderRegistry } from './providers.js'
8
9
 
9
10
  function writeJson(res, status, obj) {
10
11
  res.writeHead(status, { 'content-type': 'application/json' })
@@ -22,6 +23,7 @@ export function registerHostRoutes(ctx, deps) {
22
23
  extractVoiceActions,
23
24
  applyJargonDictionary,
24
25
  KNOWN_KEYS,
26
+ resolveKey,
25
27
  } = deps
26
28
 
27
29
  const {
@@ -33,6 +35,46 @@ export function registerHostRoutes(ctx, deps) {
33
35
  startSensevoice,
34
36
  } = daemons
35
37
 
38
+ let cachedHealth = null
39
+ let cachedHealthAt = 0
40
+
41
+ async function getProviderHealth(cfg) {
42
+ const now = Date.now()
43
+ if (cachedHealth && (now - cachedHealthAt < 30000)) {
44
+ return cachedHealth
45
+ }
46
+ const activeKeys = new Set()
47
+ for (const entry of (cfg?.dictation?.chain || [])) {
48
+ if (entry?.provider) activeKeys.add(entry.provider)
49
+ }
50
+ for (const entry of (cfg?.message?.chain || [])) {
51
+ if (entry?.provider) activeKeys.add(entry.provider)
52
+ }
53
+ const health = await defaultProviderRegistry.checkHealth({ resolveKey, cfg }, { keys: Array.from(activeKeys) })
54
+ const customList = Array.isArray(cfg?.customProviders) ? cfg.customProviders : []
55
+ for (const spec of customList) {
56
+ const key = String(spec && spec.key || '').trim()
57
+ if (key && activeKeys.has(key) && !health[key]) {
58
+ const configured = Boolean(spec.baseURL && spec.model)
59
+ let hasKey = true
60
+ if (spec.keyEnv) {
61
+ const k = await resolveKey?.(spec.keyEnv)
62
+ hasKey = Boolean(k)
63
+ }
64
+ health[key] = {
65
+ key,
66
+ configured,
67
+ hasKey,
68
+ ok: configured && hasKey,
69
+ reason: !configured ? 'missing baseURL or model' : (!hasKey ? `no ${spec.keyEnv}` : null),
70
+ }
71
+ }
72
+ }
73
+ cachedHealth = health
74
+ cachedHealthAt = now
75
+ return health
76
+ }
77
+
36
78
  ctx.effect(() => ctx.webServer.register({
37
79
  kind: 'exact',
38
80
  path: '/dsh-voice/status',
@@ -44,6 +86,7 @@ export function registerHostRoutes(ctx, deps) {
44
86
  const sensevoiceOk = await sensevoiceAlive()
45
87
  const whisperError = whisperOk ? null : getWhisperError()
46
88
  const sensevoiceError = sensevoiceOk ? null : getSensevoiceError()
89
+ const providerHealth = await getProviderHealth(cfg)
47
90
  writeJson(res, 200, {
48
91
  ok: true,
49
92
  sessionToken: hasSameOrigin(req) ? getVoiceSessionToken() : null,
@@ -103,7 +146,10 @@ export function registerHostRoutes(ctx, deps) {
103
146
  showMessageButton: cfg.showMessageButton !== false,
104
147
  dictationMode: cfg.dictationMode || 'clean',
105
148
  dictationPrompts: cfg.dictationPrompts || {},
149
+ vadEngine: cfg.vadEngine || 'silero',
150
+ streamingWs: cfg.streamingWs !== false,
106
151
  voiceMacros: Array.isArray(cfg.voiceMacros) ? cfg.voiceMacros : [],
152
+ providerHealth,
107
153
  providerStats: statsTracker.get(),
108
154
  recentDiagnostics: typeof statsTracker.getDiagnostics === 'function' ? statsTracker.getDiagnostics() : [],
109
155
  })
@@ -377,12 +423,24 @@ export function registerHostRoutes(ctx, deps) {
377
423
  },
378
424
  }), 'dsh-voice: /transcribe route')
379
425
 
426
+ ctx.effect(() => ctx.webServer.register({
427
+ kind: 'exact',
428
+ path: '/dsh-voice/providers/health',
429
+ handler: async (req, res) => {
430
+ if (req.method !== 'GET') { writeJson(res, 405, { ok: false, error: { code: 'method', message: 'GET only' } }); return }
431
+ if (!isTrustedCaller(req)) { writeJson(res, 403, { ok: false, error: { code: 'forbidden', message: 'forbidden source origin' } }); return }
432
+ const cfg = live()
433
+ const health = await getProviderHealth(cfg)
434
+ writeJson(res, 200, { ok: true, health })
435
+ },
436
+ }), 'dsh-voice: provider health route')
437
+
380
438
  ctx.effect(() => ctx.webServer.register({
381
439
  kind: 'exact',
382
440
  path: '/dsh-voice/vad/status',
383
441
  handler: async (req, res) => {
384
442
  if (!isTrustedCaller(req)) { writeJson(res, 403, { ok: false, error: 'forbidden' }); return }
385
- writeJson(res, 200, { ok: true, sileroAvailable: true, sampleRate: 16000, frameSamples: 512 })
443
+ writeJson(res, 200, { ok: true, engine: 'heuristic-rms-zcr', sileroAvailable: false, modelLoaded: false, sampleRate: 16000, frameSamples: 512 })
386
444
  },
387
445
  }), 'dsh-voice: /dsh-voice/vad/status route')
388
446
 
package/lib/http-util.js CHANGED
@@ -237,7 +237,7 @@ export function hasSameOrigin(req) {
237
237
  // DeepSeek Desktop shell or authenticated DSH session on loopback/same-host
238
238
  const remote = req.socket?.remoteAddress || req.connection?.remoteAddress || ''
239
239
  if (isDesktopShellRequest(req)) return true
240
- if (hasDshAuthCookie(req) && (isLoopback(remote) || host)) return true
240
+ if (hasDshAuthCookie(req) && isLoopback(remote)) return true
241
241
 
242
242
  return false
243
243
  }
package/lib/index.js CHANGED
@@ -61,13 +61,14 @@ export function apply(ctx, baseConfig) {
61
61
  triggerAutostart()
62
62
 
63
63
  const statsTracker = createStatsTracker()
64
- const { transcribe, polishText } = createServerPipeline({ ctx, live, statsTracker })
64
+ const { resolveKey, transcribe, polishText } = createServerPipeline({ ctx, live, statsTracker })
65
65
 
66
66
  registerServerRoutes(ctx, {
67
67
  NS,
68
68
  live,
69
69
  daemons,
70
70
  statsTracker,
71
+ resolveKey,
71
72
  transcribe,
72
73
  polishText,
73
74
  getSettingsService: () => settingsService,
@@ -339,6 +339,14 @@ export class OpenAICompatibleProvider extends SpeechToTextProvider {
339
339
  return { valid: true }
340
340
  }
341
341
 
342
+ async healthcheck({ resolveKey } = {}) {
343
+ if (this.spec?.keyEnv) {
344
+ const key = await resolveKey?.(this.spec.keyEnv)
345
+ if (!key) return { ok: false, reason: `no ${this.spec.keyEnv}` }
346
+ }
347
+ return { ok: true }
348
+ }
349
+
342
350
  async transcribe(deps, req) {
343
351
  const { resolveKey, fetchImpl } = deps
344
352
  const { bytes, mime, lang, signal, models, effectivePrompt } = req
@@ -456,6 +464,39 @@ export class ProviderRegistry {
456
464
  return Array.from(this.providers.keys())
457
465
  }
458
466
 
467
+ /**
468
+ * Check configuration and health for providers (#347).
469
+ * @param {{ resolveKey?: Function, cfg?: object }} deps
470
+ * @param {{ keys?: string[] }} [options]
471
+ * @returns {Promise<Record<string, { key: string, configured: boolean, hasKey: boolean, ok: boolean, reason: string|null }>>}
472
+ */
473
+ async checkHealth(deps = {}, options = {}) {
474
+ const { resolveKey, cfg } = deps
475
+ const keysToCheck = options.keys || this.keys()
476
+ const result = {}
477
+ for (const key of keysToCheck) {
478
+ const provider = this.get(key)
479
+ if (!provider) continue
480
+ const validRes = typeof provider.validateConfig === 'function' ? provider.validateConfig(cfg) : { valid: true }
481
+ let hcRes = { ok: true }
482
+ if (typeof provider.healthcheck === 'function') {
483
+ try {
484
+ hcRes = await provider.healthcheck({ resolveKey, cfg })
485
+ } catch (err) {
486
+ hcRes = { ok: false, reason: String(err?.message || err) }
487
+ }
488
+ }
489
+ result[key] = {
490
+ key,
491
+ configured: Boolean(validRes.valid),
492
+ hasKey: Boolean(hcRes.ok),
493
+ ok: Boolean(validRes.valid && hcRes.ok),
494
+ reason: (!validRes.valid ? validRes.reason : hcRes.reason) || null,
495
+ }
496
+ }
497
+ return result
498
+ }
499
+
459
500
  /**
460
501
  * Build execution runners for runChain(), applying presets and customProviders.
461
502
  */
@@ -14,6 +14,7 @@ export function registerServerRoutes(ctx, deps) {
14
14
  live,
15
15
  daemons,
16
16
  statsTracker,
17
+ resolveKey,
17
18
  transcribe,
18
19
  polishText,
19
20
  getSettingsService,
@@ -27,6 +28,7 @@ export function registerServerRoutes(ctx, deps) {
27
28
  live,
28
29
  daemons,
29
30
  statsTracker,
31
+ resolveKey,
30
32
  transcribe,
31
33
  polishText,
32
34
  sessionCommand,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goodandready/dsh-voice",
3
- "version": "0.9.57",
3
+ "version": "0.9.59",
4
4
  "description": "Voice input for DeepSeek Harness: dictation chunked by pauses and voice messages, each with its own provider fallback chain (Deepgram, Groq, HuggingFace, local whisper.cpp, plus any OpenAI-compatible API of your own).",
5
5
  "license": "MIT",
6
6
  "type": "module",