@openchamber/web 1.19.0 → 1.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{CodeMirrorCommentWidgets-DAvopJvy.js → CodeMirrorCommentWidgets-C2BopIs3.js} +1 -1
- package/dist/assets/CommitSection-HJeMUAWb.js +1 -0
- package/dist/assets/DiffView-D5cvbEPb.js +4 -0
- package/dist/assets/FilesView-DPU8aNPL.js +17 -0
- package/dist/assets/GitView-Ct6xWrVH.js +6 -0
- package/dist/assets/{JsonTreeView-h4dHASlq.js → JsonTreeView-osju7J70.js} +1 -1
- package/dist/assets/MarkdownImageGallery-EujHSZ2M.js +1 -0
- package/dist/assets/MarkdownRendererImpl-CPzu4kIr.js +12 -0
- package/dist/assets/OnboardingScreen-w2VG4fWY.js +1 -0
- package/dist/assets/{PatchDiff-jPKTJje5.js → PatchDiff-Dan3mADn.js} +1 -1
- package/dist/assets/PierreDiffViewer-CGoI2v0q.js +157 -0
- package/dist/assets/PlanView-Dgg-WTEc.js +4 -0
- package/dist/assets/SessionSwitcherDropdown-CJTrc8K7.js +1 -0
- package/dist/assets/SettingsView-D9yRuFZw.js +28 -0
- package/dist/assets/SettingsWindow-DXF-MTHG.js +1 -0
- package/dist/assets/ToolOutputDialog-DrCa1JRk.js +15 -0
- package/dist/assets/ToolPartDiffPreview-B_tfvlNF.js +8 -0
- package/dist/assets/{VirtualizedFileDiff-B37yB9jZ.js → VirtualizedFileDiff-CN_BctrR.js} +4 -4
- package/dist/assets/{Virtualizer-X_7XPoTH.js → Virtualizer-CZlLSacm.js} +1 -1
- package/dist/assets/Virtualizer-D_a8gKmg.js +1 -0
- package/dist/assets/{WalkthroughView-Bxun3k66.js → WalkthroughView-D9Q4lr5x.js} +2 -2
- package/dist/assets/{computeVirtualFileMetrics-DYFv_yZS.js → computeVirtualFileMetrics-Gi1d5eU1.js} +1 -1
- package/dist/assets/contextPanelEmbeddedChat-CpzVNWAv.js +1 -0
- package/dist/assets/de-B_LdJwEM.js +9 -0
- package/dist/assets/es-CubfsAYV.js +15 -0
- package/dist/assets/fr-5qJM0nFS.js +13 -0
- package/dist/assets/index-BW82eK5v.css +1 -0
- package/dist/assets/index-Brm3X9rs.js +1 -0
- package/dist/assets/index-rlLjZUM5.js +7 -0
- package/dist/assets/{isDiffPlainText-DwHKxDYc.js → isDiffPlainText-pH9kAJQH.js} +1 -1
- package/dist/assets/{isFilePlainText-Dwq6ILxo.js → isFilePlainText-CVKy_dgB.js} +1 -1
- package/dist/assets/ja-DJYIBUlH.js +15 -0
- package/dist/assets/ko-DcUBkB7y.js +15 -0
- package/dist/assets/main-DLBxKIoX.js +926 -0
- package/dist/assets/main-vUCh0VB0.js +2 -0
- package/dist/assets/markdownCore-DG6GHLF4.js +3 -0
- package/dist/assets/miniChat-BlzGEYgE.js +2 -0
- package/dist/assets/mobile-CkX6H-IT.js +2 -0
- package/dist/assets/{patchFileDiff-BEDPDypx.js → patchFileDiff-BCTsE43U.js} +3 -3
- package/dist/assets/pl-rB6BLcio.js +15 -0
- package/dist/assets/pt-BR-DcwtlO-o.js +15 -0
- package/dist/assets/renderElectronMiniChatApp-CJYe_KOL.js +2 -0
- package/dist/assets/renderMobileApp-hQJTnr8B.js +25 -0
- package/dist/assets/runtimeEndpointReset-BDh7r8BL.js +15 -0
- package/dist/assets/scheduledTasksApi-CAGPh_gZ.js +1 -0
- package/dist/assets/{shikiHighlight-DXYW46vW.js → shikiHighlight-BgTPSITe.js} +1 -1
- package/dist/assets/uk-INZlFD9A.js +15 -0
- package/dist/assets/useAppFontEffects-Cll4gnsh.js +7268 -0
- package/dist/assets/useInlineCommentController-DFFv0hae.js +2 -0
- package/dist/assets/{vendor-base-ui-BYlZTzrw.js → vendor-base-ui-_6j2xOWl.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-CiAYDJXN.js → vendor-codemirror-language-data-DkQX2EBa.js} +2 -2
- package/dist/assets/{vendor-framer-motion-CRSgBxjL.js → vendor-framer-motion-livSKyyV.js} +1 -1
- package/dist/assets/vendor-legendapp-list-gg7YLRW7.js +1 -0
- package/dist/assets/{vendor-motion-dom-DJLgZh4Q.js → vendor-motion-dom-D_o3BTI3.js} +1 -1
- package/dist/assets/vendor-zod-BLfBSgBh.js +39 -0
- package/dist/assets/{web-components-DCLjCO9n.js → web-components-DLnGY4fs.js} +4 -4
- package/dist/assets/zh-CN-Dzda8xa1.js +15 -0
- package/dist/assets/zh-TW-Cwn3rNYZ.js +15 -0
- package/dist/index.html +6 -5
- package/dist/mini-chat.html +5 -4
- package/dist/mobile.html +5 -4
- package/package.json +5 -7
- package/server/index.js +44 -0
- package/server/lib/agent-memory/project-resolution.js +10 -1
- package/server/lib/agent-memory/project-resolution.test.js +9 -0
- package/server/lib/agent-memory/runtime.js +7 -2
- package/server/lib/client-auth/pairing.js +8 -7
- package/server/lib/client-auth/pairing.test.js +5 -1
- package/server/lib/client-auth/remote-clients.js +9 -1
- package/server/lib/client-auth/remote-clients.test.js +17 -0
- package/server/lib/dictation/DOCUMENTATION.md +32 -8
- package/server/lib/dictation/local/sherpa-recognizer.js +35 -78
- package/server/lib/dictation/local/worker-process.js +2 -2
- package/server/lib/dictation/openai-compatible-session.js +3 -2
- package/server/lib/dictation/stream-manager.js +77 -34
- package/server/lib/dictation/stream-manager.test.js +60 -2
- package/server/lib/fs/routes.test.js +76 -0
- package/server/lib/git/routes.js +43 -0
- package/server/lib/git/service.js +85 -5
- package/server/lib/git/service.test.js +93 -0
- package/server/lib/github/pr-status.js +10 -1
- package/server/lib/opencode/DOCUMENTATION.md +6 -2
- package/server/lib/opencode/feature-routes-runtime.js +5 -9
- package/server/lib/opencode/lifecycle.js +202 -26
- package/server/lib/opencode/lifecycle.test.js +179 -1
- package/server/lib/opencode/providers.js +9 -4
- package/server/lib/opencode/providers.test.js +27 -0
- package/server/lib/opencode/restart-session-recovery.test.js +59 -0
- package/server/lib/opencode/session-runtime.js +39 -2
- package/server/lib/opencode/session-runtime.test.js +74 -0
- package/server/lib/opencode/settings-helpers.js +15 -0
- package/server/lib/opencode/settings-helpers.test.js +22 -0
- package/server/lib/opencode/settings-normalization-runtime.js +3 -0
- package/server/lib/opencode/settings-normalization-runtime.test.js +16 -0
- package/server/lib/opencode/settings-runtime.js +32 -10
- package/server/lib/opencode/settings-runtime.test.js +85 -0
- package/server/lib/opencode/skill-routes.js +29 -73
- package/server/lib/opencode/skill-routes.test.js +2 -5
- package/server/lib/project-context/DOCUMENTATION.md +2 -0
- package/server/lib/project-context/runtime.js +7 -2
- package/server/lib/projects/project-config.js +7 -2
- package/server/lib/quota/DOCUMENTATION.md +1 -1
- package/server/lib/quota/providers/claude/index.js +2 -2
- package/server/lib/quota/providers/index.js +1 -7
- package/server/lib/quota/providers/zai.js +26 -6
- package/server/lib/quota/providers/zai.test.js +33 -0
- package/server/lib/relay/DOCUMENTATION.md +1 -1
- package/server/lib/relay/service.js +34 -2
- package/server/lib/relay/service.test.js +69 -0
- package/server/lib/session-goal/runtime.js +2 -1
- package/server/lib/session-goal/runtime.test.js +4 -2
- package/server/lib/session-knowledge/DOCUMENTATION.md +2 -0
- package/server/lib/skills-catalog/DOCUMENTATION.md +18 -45
- package/server/lib/skills-catalog/cache.js +120 -1
- package/server/lib/skills-catalog/cache.test.js +77 -0
- package/server/lib/skills-catalog/curated-sources.js +21 -5
- package/server/lib/skills-catalog/curated-sources.test.js +4 -4
- package/server/lib/skills-catalog/disk-cache.js +52 -0
- package/server/lib/skills-catalog/github-meta.js +139 -0
- package/server/lib/skills-catalog/github-meta.test.js +71 -0
- package/server/lib/skills-catalog/source.js +0 -5
- package/server/lib/small-model/DOCUMENTATION.md +74 -6
- package/server/lib/small-model/call.js +46 -12
- package/server/lib/small-model/call.test.js +79 -0
- package/server/lib/small-model/index.js +51 -8
- package/server/lib/small-model/index.test.js +73 -3
- package/server/lib/small-model/routes.js +1 -1
- package/server/lib/small-model/runtime-providers.js +156 -0
- package/server/lib/small-model/runtime-providers.test.js +112 -0
- package/server/lib/terminal/DOCUMENTATION.md +2 -0
- package/server/lib/terminal/runtime.js +29 -1
- package/server/lib/terminal/runtime.test.js +26 -0
- package/server/lib/ui-auth/ui-auth.js +2 -2
- package/server/lib/ui-auth/ui-auth.test.js +2 -2
- package/dist/assets/CommitSection-D9cV-qR9.js +0 -1
- package/dist/assets/DiagramEditor-B9NCadU7.js +0 -1
- package/dist/assets/DiagramView-LKGBwf4G.js +0 -1
- package/dist/assets/DiffView-BWNq-0ov.js +0 -4
- package/dist/assets/FilesView-DB-Q0Gkz.js +0 -14
- package/dist/assets/GitView-DsWXqWx3.js +0 -6
- package/dist/assets/MarkdownImageGallery-n0ikH-xm.js +0 -1
- package/dist/assets/MarkdownRendererImpl-CT2mjx-s.js +0 -12
- package/dist/assets/OnboardingScreen-CDjgzxEe.js +0 -1
- package/dist/assets/PierreDiffViewer-D_Gt4A_6.js +0 -136
- package/dist/assets/PlanView-UvuxIl9-.js +0 -4
- package/dist/assets/SessionSwitcherDropdown-xKU4LRuQ.js +0 -1
- package/dist/assets/SettingsView-3B9VN6Ys.js +0 -28
- package/dist/assets/SettingsWindow-CqQNDKNd.js +0 -1
- package/dist/assets/ToolOutputDialog-PmjlAxVE.js +0 -15
- package/dist/assets/ToolPartDiffPreview-B34Xw9wq.js +0 -8
- package/dist/assets/contextPanelEmbeddedChat-BO1wRpaN.js +0 -1
- package/dist/assets/de-DbV6CLxv.js +0 -9
- package/dist/assets/es-CVDlyzZ4.js +0 -15
- package/dist/assets/fr-Czc-p0g-.js +0 -13
- package/dist/assets/index-1OhiMDBz.css +0 -1
- package/dist/assets/index-BSvmTvZl.js +0 -1
- package/dist/assets/index-DzriVon2.js +0 -7
- package/dist/assets/ja-dwc9NM_S.js +0 -15
- package/dist/assets/ko-Ds1DZ8FX.js +0 -15
- package/dist/assets/main-BF51IOVF.js +0 -921
- package/dist/assets/main-D7UPARut.js +0 -2
- package/dist/assets/markdownCore-BgeBDwD3.js +0 -2
- package/dist/assets/miniChat-BISXSGOo.js +0 -2
- package/dist/assets/mobile-BnYxVuvw.js +0 -2
- package/dist/assets/pl-CLiTO7i-.js +0 -15
- package/dist/assets/pt-BR-GIimJgpK.js +0 -15
- package/dist/assets/renderElectronMiniChatApp-BaOy72Gi.js +0 -2
- package/dist/assets/renderMobileApp-BiMbzPq9.js +0 -25
- package/dist/assets/runtimeEndpointReset-BMBRhIbf.js +0 -15
- package/dist/assets/scheduledTasksApi-01zzfzqH.js +0 -1
- package/dist/assets/uk-DLfgD1ki.js +0 -15
- package/dist/assets/useAppFontEffects-CbzHzFop.js +0 -7271
- package/dist/assets/useInlineCommentController-CegKdDXi.js +0 -2
- package/dist/assets/vendor-zod-adaMkgkm.js +0 -39
- package/dist/assets/zh-CN-DkeP5awK.js +0 -15
- package/dist/assets/zh-TW-BocaFm3d.js +0 -15
- package/server/lib/quota/providers/command-code.js +0 -90
- package/server/lib/quota/providers/command-code.test.js +0 -72
- package/server/lib/skills-catalog/clawdhub/api.js +0 -126
- package/server/lib/skills-catalog/clawdhub/install.js +0 -238
- package/server/lib/skills-catalog/clawdhub/install.test.js +0 -100
- package/server/lib/skills-catalog/clawdhub/scan.js +0 -61
package/dist/index.html
CHANGED
|
@@ -509,15 +509,16 @@
|
|
|
509
509
|
pointer-events: none;
|
|
510
510
|
}
|
|
511
511
|
</style>
|
|
512
|
-
<script type="module" crossorigin src="/assets/main-
|
|
512
|
+
<script type="module" crossorigin src="/assets/main-vUCh0VB0.js"></script>
|
|
513
513
|
<link rel="modulepreload" crossorigin href="/assets/vendor-vite-runtime-DD1OZmLC.js">
|
|
514
|
-
<link rel="modulepreload" crossorigin href="/assets/vendor-opencode-sdk-BJ73u-bH.js">
|
|
515
514
|
<link rel="modulepreload" crossorigin href="/assets/vendor-scheduler-7OC5HNn7.js">
|
|
516
515
|
<link rel="modulepreload" crossorigin href="/assets/vendor-react-BUCujlKS.js">
|
|
517
516
|
<link rel="modulepreload" crossorigin href="/assets/vendor-zustand-BAGL70zf.js">
|
|
518
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
519
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
520
|
-
<link rel="
|
|
517
|
+
<link rel="modulepreload" crossorigin href="/assets/vendor-zod-BLfBSgBh.js">
|
|
518
|
+
<link rel="modulepreload" crossorigin href="/assets/vendor-opencode-sdk-BJ73u-bH.js">
|
|
519
|
+
<link rel="modulepreload" crossorigin href="/assets/index-rlLjZUM5.js">
|
|
520
|
+
<link rel="modulepreload" crossorigin href="/assets/contextPanelEmbeddedChat-CpzVNWAv.js">
|
|
521
|
+
<link rel="stylesheet" crossorigin href="/assets/index-BW82eK5v.css">
|
|
521
522
|
</head>
|
|
522
523
|
<body class="h-full bg-background text-foreground">
|
|
523
524
|
<div id="root" class="h-full">
|
package/dist/mini-chat.html
CHANGED
|
@@ -74,14 +74,15 @@
|
|
|
74
74
|
}
|
|
75
75
|
</style>
|
|
76
76
|
|
|
77
|
-
<script type="module" crossorigin src="/assets/miniChat-
|
|
77
|
+
<script type="module" crossorigin src="/assets/miniChat-BlzGEYgE.js"></script>
|
|
78
78
|
<link rel="modulepreload" crossorigin href="/assets/vendor-vite-runtime-DD1OZmLC.js">
|
|
79
|
-
<link rel="modulepreload" crossorigin href="/assets/vendor-opencode-sdk-BJ73u-bH.js">
|
|
80
79
|
<link rel="modulepreload" crossorigin href="/assets/vendor-scheduler-7OC5HNn7.js">
|
|
81
80
|
<link rel="modulepreload" crossorigin href="/assets/vendor-react-BUCujlKS.js">
|
|
82
81
|
<link rel="modulepreload" crossorigin href="/assets/vendor-zustand-BAGL70zf.js">
|
|
83
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
84
|
-
<link rel="
|
|
82
|
+
<link rel="modulepreload" crossorigin href="/assets/vendor-zod-BLfBSgBh.js">
|
|
83
|
+
<link rel="modulepreload" crossorigin href="/assets/vendor-opencode-sdk-BJ73u-bH.js">
|
|
84
|
+
<link rel="modulepreload" crossorigin href="/assets/index-rlLjZUM5.js">
|
|
85
|
+
<link rel="stylesheet" crossorigin href="/assets/index-BW82eK5v.css">
|
|
85
86
|
</head>
|
|
86
87
|
<body class="h-full bg-background text-foreground">
|
|
87
88
|
<div id="root" class="h-full">
|
package/dist/mobile.html
CHANGED
|
@@ -63,14 +63,15 @@
|
|
|
63
63
|
})();
|
|
64
64
|
</script>
|
|
65
65
|
|
|
66
|
-
<script type="module" crossorigin src="/assets/mobile-
|
|
66
|
+
<script type="module" crossorigin src="/assets/mobile-CkX6H-IT.js"></script>
|
|
67
67
|
<link rel="modulepreload" crossorigin href="/assets/vendor-vite-runtime-DD1OZmLC.js">
|
|
68
|
-
<link rel="modulepreload" crossorigin href="/assets/vendor-opencode-sdk-BJ73u-bH.js">
|
|
69
68
|
<link rel="modulepreload" crossorigin href="/assets/vendor-scheduler-7OC5HNn7.js">
|
|
70
69
|
<link rel="modulepreload" crossorigin href="/assets/vendor-react-BUCujlKS.js">
|
|
71
70
|
<link rel="modulepreload" crossorigin href="/assets/vendor-zustand-BAGL70zf.js">
|
|
72
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
73
|
-
<link rel="
|
|
71
|
+
<link rel="modulepreload" crossorigin href="/assets/vendor-zod-BLfBSgBh.js">
|
|
72
|
+
<link rel="modulepreload" crossorigin href="/assets/vendor-opencode-sdk-BJ73u-bH.js">
|
|
73
|
+
<link rel="modulepreload" crossorigin href="/assets/index-rlLjZUM5.js">
|
|
74
|
+
<link rel="stylesheet" crossorigin href="/assets/index-BW82eK5v.css">
|
|
74
75
|
</head>
|
|
75
76
|
<body class="h-full bg-background text-foreground">
|
|
76
77
|
<div id="root" class="h-full"></div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openchamber/web",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.21.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./server/index.js",
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
},
|
|
14
14
|
"scripts": {
|
|
15
15
|
"dev": "bun run build:watch",
|
|
16
|
-
"dev:server": "bun server/index.js --port ${OPENCHAMBER_PORT:-3001}",
|
|
17
|
-
"dev:server:watch": "nodemon --watch server --ext js --exec \"bun server/index.js --port ${OPENCHAMBER_PORT:-3001}\"",
|
|
16
|
+
"dev:server": "OPENCHAMBER_RELAY_HOST=${OPENCHAMBER_RELAY_HOST:-off} bun server/index.js --port ${OPENCHAMBER_PORT:-3001}",
|
|
17
|
+
"dev:server:watch": "OPENCHAMBER_RELAY_HOST=${OPENCHAMBER_RELAY_HOST:-off} nodemon --watch server --ext js --exec \"bun server/index.js --port ${OPENCHAMBER_PORT:-3001}\"",
|
|
18
18
|
"build": "vite build",
|
|
19
19
|
"build:watch": "vite build --watch",
|
|
20
20
|
"type-check": "tsc --noEmit",
|
|
@@ -25,9 +25,8 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@clack/prompts": "^1.1.0",
|
|
27
27
|
"@octokit/rest": "^22.0.1",
|
|
28
|
-
"@opencode-ai/sdk": "1.18.
|
|
28
|
+
"@opencode-ai/sdk": "1.18.23",
|
|
29
29
|
"@simplewebauthn/server": "13.3.1",
|
|
30
|
-
"adm-zip": "^0.6.0",
|
|
31
30
|
"bun-pty": "^0.4.5",
|
|
32
31
|
"compression": "^1.8.1",
|
|
33
32
|
"cron-parser": "^4.9.0",
|
|
@@ -63,7 +62,6 @@
|
|
|
63
62
|
"@remixicon/react": "^4.7.0",
|
|
64
63
|
"@simplewebauthn/browser": "13.3.0",
|
|
65
64
|
"@tailwindcss/postcss": "^4.0.0",
|
|
66
|
-
"@types/adm-zip": "^0.5.7",
|
|
67
65
|
"@types/node": "^24.3.1",
|
|
68
66
|
"@types/react": "^19.1.10",
|
|
69
67
|
"@types/react-dom": "^19.1.7",
|
|
@@ -89,8 +87,8 @@
|
|
|
89
87
|
"remark-gfm": "^4.0.1",
|
|
90
88
|
"sonner": "^2.0.7",
|
|
91
89
|
"strip-json-comments": "^5.0.3",
|
|
92
|
-
"tailwind-merge": "^3.3.1",
|
|
93
90
|
"supertest": "^7.2.2",
|
|
91
|
+
"tailwind-merge": "^3.3.1",
|
|
94
92
|
"tailwindcss": "^4.0.0",
|
|
95
93
|
"tsx": "^4.20.6",
|
|
96
94
|
"tw-animate-css": "^1.3.8",
|
package/server/index.js
CHANGED
|
@@ -72,6 +72,7 @@ import { createOpenCodeResolutionRuntime } from './lib/opencode/opencode-resolut
|
|
|
72
72
|
import { resolveOpenCodeUpgradeCapability } from './lib/opencode/upgrade-capability.js';
|
|
73
73
|
import { createBootstrapRuntime } from './lib/opencode/bootstrap-runtime.js';
|
|
74
74
|
import { createSessionRuntime } from './lib/opencode/session-runtime.js';
|
|
75
|
+
import { configureOpenCodeRuntimeProviders, resetOpenCodeRuntimeProviders } from './lib/small-model/runtime-providers.js';
|
|
75
76
|
import { createOpenCodeWatcherRuntime } from './lib/opencode/watcher.js';
|
|
76
77
|
import { createSessionAssistRuntime } from './lib/session-assist/runtime.js';
|
|
77
78
|
import { createSessionGoalRuntime } from './lib/session-goal/runtime.js';
|
|
@@ -530,6 +531,9 @@ let openCodeApiPrefixDetected = true;
|
|
|
530
531
|
let openCodeApiDetectionTimer = null;
|
|
531
532
|
let lastOpenCodeError = null;
|
|
532
533
|
let lastOpenCodeLaunchDiagnostics = null;
|
|
534
|
+
let lastOpenCodeHealthFailure = null;
|
|
535
|
+
let lastManagedOpenCodeProcess = null;
|
|
536
|
+
let lastOpenCodeRestartDiagnostics = null;
|
|
533
537
|
let isOpenCodeReady = false;
|
|
534
538
|
let openCodeNotReadySince = 0;
|
|
535
539
|
let isExternalOpenCode = false;
|
|
@@ -661,6 +665,11 @@ const buildOpenCodeUrl = (...args) => openCodeNetworkRuntime.buildOpenCodeUrl(..
|
|
|
661
665
|
const ensureOpenCodeApiPrefix = (...args) => openCodeNetworkRuntime.ensureOpenCodeApiPrefix(...args);
|
|
662
666
|
const scheduleOpenCodeApiDetection = (...args) => openCodeNetworkRuntime.scheduleOpenCodeApiDetection(...args);
|
|
663
667
|
|
|
668
|
+
// Plugin-registered providers exist only inside the running OpenCode process.
|
|
669
|
+
// Small-model callers resolve them through this connection; without it they
|
|
670
|
+
// stay on the file-based resolution and plugin models remain unreachable.
|
|
671
|
+
configureOpenCodeRuntimeProviders({ buildOpenCodeUrl, getOpenCodeAuthHeaders });
|
|
672
|
+
|
|
664
673
|
const ENV_CONFIGURED_API_PREFIX = normalizeApiPrefix(
|
|
665
674
|
process.env.OPENCODE_API_PREFIX || process.env.OPENCHAMBER_API_PREFIX || ''
|
|
666
675
|
);
|
|
@@ -1089,6 +1098,9 @@ Object.defineProperties(openCodeLifecycleState, {
|
|
|
1089
1098
|
openCodeApiDetectionTimer: { get: () => openCodeApiDetectionTimer, set: (value) => { openCodeApiDetectionTimer = value; } },
|
|
1090
1099
|
lastOpenCodeError: { get: () => lastOpenCodeError, set: (value) => { lastOpenCodeError = value; } },
|
|
1091
1100
|
lastOpenCodeLaunchDiagnostics: { get: () => lastOpenCodeLaunchDiagnostics, set: (value) => { lastOpenCodeLaunchDiagnostics = value; } },
|
|
1101
|
+
lastOpenCodeHealthFailure: { get: () => lastOpenCodeHealthFailure, set: (value) => { lastOpenCodeHealthFailure = value; } },
|
|
1102
|
+
lastManagedOpenCodeProcess: { get: () => lastManagedOpenCodeProcess, set: (value) => { lastManagedOpenCodeProcess = value; } },
|
|
1103
|
+
lastOpenCodeRestartDiagnostics: { get: () => lastOpenCodeRestartDiagnostics, set: (value) => { lastOpenCodeRestartDiagnostics = value; } },
|
|
1092
1104
|
isOpenCodeReady: { get: () => isOpenCodeReady, set: (value) => { isOpenCodeReady = value; } },
|
|
1093
1105
|
openCodeNotReadySince: { get: () => openCodeNotReadySince, set: (value) => { openCodeNotReadySince = value; } },
|
|
1094
1106
|
isExternalOpenCode: { get: () => isExternalOpenCode, set: (value) => { isExternalOpenCode = value; } },
|
|
@@ -1156,11 +1168,31 @@ const openCodeLifecycleRuntime = createOpenCodeLifecycleRuntime({
|
|
|
1156
1168
|
// process (#2638). The runtime is created later by the startup pipeline;
|
|
1157
1169
|
// by the time any restart runs, it is assigned.
|
|
1158
1170
|
onOpenCodeRestarted: () => {
|
|
1171
|
+
// A restart reloads plugins: provider ports, credentials and the provider
|
|
1172
|
+
// list itself can all differ from what was cached.
|
|
1173
|
+
resetOpenCodeRuntimeProviders();
|
|
1159
1174
|
try {
|
|
1160
1175
|
messageStreamRuntime?.rebindUpstream();
|
|
1161
1176
|
} catch (error) {
|
|
1162
1177
|
console.warn('Failed to rebind message stream after OpenCode restart:', error?.message ?? error);
|
|
1163
1178
|
}
|
|
1179
|
+
try {
|
|
1180
|
+
const { sessionIds } = sessionRuntime.interruptBusySessionsAfterRestart();
|
|
1181
|
+
if (sessionIds.length > 0) {
|
|
1182
|
+
const multiple = sessionIds.length > 1;
|
|
1183
|
+
broadcastUiNotification({
|
|
1184
|
+
title: multiple ? 'Chats interrupted' : 'Chat interrupted',
|
|
1185
|
+
body: multiple
|
|
1186
|
+
? 'OpenCode restarted during running responses. Send a message in each chat to continue.'
|
|
1187
|
+
: 'OpenCode restarted during a running response. Send a message to continue.',
|
|
1188
|
+
tag: 'opencode-restart-interrupted',
|
|
1189
|
+
kind: 'opencode-restart-interrupted',
|
|
1190
|
+
sessionId: sessionIds[0],
|
|
1191
|
+
});
|
|
1192
|
+
}
|
|
1193
|
+
} catch (error) {
|
|
1194
|
+
console.warn('Failed to reconcile sessions after OpenCode restart:', error?.message ?? error);
|
|
1195
|
+
}
|
|
1164
1196
|
},
|
|
1165
1197
|
getManagedOpenCodeEnv: async () => {
|
|
1166
1198
|
const settings = await readSettingsFromDiskMigrated().catch(() => null);
|
|
@@ -1259,6 +1291,7 @@ const resolveMemoryProjectId = createMemoryProjectResolver({
|
|
|
1259
1291
|
return sanitizeProjects(settings?.projects || []).map((project) => project.path);
|
|
1260
1292
|
},
|
|
1261
1293
|
resolvePrimaryWorktreeRoot,
|
|
1294
|
+
managedProjectRoots: [path.join(OPENCHAMBER_USER_CONFIG_ROOT, 'chats')],
|
|
1262
1295
|
});
|
|
1263
1296
|
|
|
1264
1297
|
/**
|
|
@@ -1658,6 +1691,9 @@ async function main(options = {}) {
|
|
|
1658
1691
|
isOpenCodeReady,
|
|
1659
1692
|
lastOpenCodeError,
|
|
1660
1693
|
lastOpenCodeLaunchDiagnostics,
|
|
1694
|
+
lastOpenCodeHealthFailure,
|
|
1695
|
+
lastManagedOpenCodeProcess,
|
|
1696
|
+
lastOpenCodeRestartDiagnostics,
|
|
1661
1697
|
opencodeBinaryResolved: resolvedOpencodeBinary || null,
|
|
1662
1698
|
opencodeBinarySource: resolvedOpencodeBinarySource || null,
|
|
1663
1699
|
opencodeLaunchBinary: launchSpec?.binary || null,
|
|
@@ -1779,6 +1815,14 @@ async function main(options = {}) {
|
|
|
1779
1815
|
fs,
|
|
1780
1816
|
process,
|
|
1781
1817
|
}),
|
|
1818
|
+
// Dev/debug instances share the data dir (and thus the relay identity) with
|
|
1819
|
+
// the production instance, so they must not host the relay on their own —
|
|
1820
|
+
// paired devices would land on them. OPENCHAMBER_RELAY_HOST=off disables
|
|
1821
|
+
// passive hosting explicitly (dev scripts set it); the Electron dev shell is
|
|
1822
|
+
// covered via OPENCHAMBER_ELECTRON_DEV. OPENCHAMBER_RELAY_HOST=on overrides
|
|
1823
|
+
// both. Explicit enable/pairing on the instance still hosts regardless.
|
|
1824
|
+
allowPassiveHost: process.env.OPENCHAMBER_RELAY_HOST === 'on'
|
|
1825
|
+
|| (process.env.OPENCHAMBER_RELAY_HOST !== 'off' && process.env.OPENCHAMBER_ELECTRON_DEV !== '1'),
|
|
1782
1826
|
// Relay demand = any paired device or pending pairing session that uses the
|
|
1783
1827
|
// relay transport. Drives the auto on/off lifecycle.
|
|
1784
1828
|
hasRelayDemand: async () => {
|
|
@@ -24,7 +24,8 @@ const normalize = (value) => {
|
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
export const createMemoryProjectResolver = (dependencies) => {
|
|
27
|
-
const { listProjectPaths, resolvePrimaryWorktreeRoot } = dependencies;
|
|
27
|
+
const { listProjectPaths, resolvePrimaryWorktreeRoot, managedProjectRoots = [] } = dependencies;
|
|
28
|
+
const managedRoots = managedProjectRoots.map(normalize).filter(Boolean);
|
|
28
29
|
|
|
29
30
|
return async (directory) => {
|
|
30
31
|
const resolved = normalize(directory);
|
|
@@ -32,6 +33,14 @@ export const createMemoryProjectResolver = (dependencies) => {
|
|
|
32
33
|
return '';
|
|
33
34
|
}
|
|
34
35
|
|
|
36
|
+
const managedRoot = managedRoots.find((root) => {
|
|
37
|
+
const relative = path.relative(root, resolved);
|
|
38
|
+
return relative === '' || (!relative.startsWith('..') && !path.isAbsolute(relative));
|
|
39
|
+
});
|
|
40
|
+
if (managedRoot) {
|
|
41
|
+
return createProjectIdFromPath(managedRoot);
|
|
42
|
+
}
|
|
43
|
+
|
|
35
44
|
let configured = [];
|
|
36
45
|
try {
|
|
37
46
|
configured = ((await listProjectPaths()) || []).map(normalize).filter(Boolean);
|
|
@@ -51,6 +51,15 @@ describe('resolving a session directory to its project', () => {
|
|
|
51
51
|
expect(await resolve('/tmp/loose')).toBe(createProjectIdFromPath('/tmp/loose'));
|
|
52
52
|
});
|
|
53
53
|
|
|
54
|
+
test('managed chat session directories share the Chats root store', async () => {
|
|
55
|
+
const chatsRoot = '/Users/x/.config/openchamber/chats';
|
|
56
|
+
const resolve = createResolver({ managedProjectRoots: [chatsRoot] });
|
|
57
|
+
|
|
58
|
+
expect(await resolve(`${chatsRoot}/2026-08-21/session-a`)).toBe(createProjectIdFromPath(chatsRoot));
|
|
59
|
+
expect(await resolve(`${chatsRoot}/2026-08-21/session-b`)).toBe(createProjectIdFromPath(chatsRoot));
|
|
60
|
+
expect(await resolve('/Users/x/.config/openchamber/chats-other/session-a')).not.toBe(createProjectIdFromPath(chatsRoot));
|
|
61
|
+
});
|
|
62
|
+
|
|
54
63
|
test('no directory resolves to nothing rather than to some default project', async () => {
|
|
55
64
|
const resolve = createResolver();
|
|
56
65
|
|
|
@@ -236,8 +236,13 @@ export const createAgentMemoryRuntime = (deps) => {
|
|
|
236
236
|
const writeJsonAtomic = async (filePath, value) => {
|
|
237
237
|
const temporaryPath = `${filePath}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
238
238
|
await fsPromises.mkdir(path.dirname(filePath), { recursive: true });
|
|
239
|
-
|
|
240
|
-
|
|
239
|
+
try {
|
|
240
|
+
await fsPromises.writeFile(temporaryPath, JSON.stringify(value, null, 2), 'utf8');
|
|
241
|
+
await fsPromises.rename(temporaryPath, filePath);
|
|
242
|
+
} catch (error) {
|
|
243
|
+
await fsPromises.rm(temporaryPath, { force: true }).catch(() => {});
|
|
244
|
+
throw error;
|
|
245
|
+
}
|
|
241
246
|
};
|
|
242
247
|
|
|
243
248
|
const withWriteLock = async (key, mutate) => {
|
|
@@ -262,14 +262,15 @@ export const createClientPairingRuntime = ({
|
|
|
262
262
|
if (!constantTimeEqual(session.secretHash, hashSecret(normalizedSecret), crypto)) throw redeemError();
|
|
263
263
|
|
|
264
264
|
// The operator's typed pairing label is THIS server's name for the device
|
|
265
|
-
// (shown in the device list)
|
|
266
|
-
// label
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|| normalizeOptionalString(deviceName)
|
|
270
|
-
|| 'Remote client';
|
|
265
|
+
// (shown in the device list) and wins outright. The device's self-reported
|
|
266
|
+
// label is only a fallback: on a re-pair with the same dedupeKey,
|
|
267
|
+
// createClient keeps the replaced record's label over it, so a rescan
|
|
268
|
+
// without a typed name does not reset the device to the app default.
|
|
271
269
|
const result = await remoteClientAuthRuntime.createClient({
|
|
272
|
-
label,
|
|
270
|
+
label: normalizeOptionalString(session.label),
|
|
271
|
+
fallbackLabel: normalizeOptionalString(clientLabel)
|
|
272
|
+
|| normalizeOptionalString(deviceName)
|
|
273
|
+
|| 'Remote client',
|
|
273
274
|
clientKind: normalizedKind,
|
|
274
275
|
dedupeKey: normalizeOptionalString(dedupeKey) || `pairing:${session.id}`,
|
|
275
276
|
authMethod: 'pairing',
|
|
@@ -13,7 +13,7 @@ const makeRuntime = async (options = {}) => {
|
|
|
13
13
|
createClient: vi.fn(async (input) => {
|
|
14
14
|
const client = {
|
|
15
15
|
id: `client-${createdClients.length + 1}`,
|
|
16
|
-
label: input.label,
|
|
16
|
+
label: input.label ?? input.fallbackLabel,
|
|
17
17
|
clientKind: input.clientKind,
|
|
18
18
|
authMethod: input.authMethod,
|
|
19
19
|
pairingId: input.pairingId,
|
|
@@ -61,6 +61,10 @@ describe('client auth pairing runtime', () => {
|
|
|
61
61
|
pairingId: created.pairing.id,
|
|
62
62
|
clientKind: 'mobile',
|
|
63
63
|
dedupeKey: 'device-key',
|
|
64
|
+
// No operator-typed pairing label: the app-reported name is only a
|
|
65
|
+
// fallback so a re-pair keeps the existing device record's label.
|
|
66
|
+
label: null,
|
|
67
|
+
fallbackLabel: 'Iryna iPhone',
|
|
64
68
|
}));
|
|
65
69
|
|
|
66
70
|
await expect(runtime.redeemPairingSession({
|
|
@@ -157,6 +157,7 @@ export const createRemoteClientAuthRuntime = ({ fsPromises, path, crypto, storeP
|
|
|
157
157
|
|
|
158
158
|
const createClient = async ({
|
|
159
159
|
label,
|
|
160
|
+
fallbackLabel,
|
|
160
161
|
expiresAt,
|
|
161
162
|
clientKind,
|
|
162
163
|
dedupeKey,
|
|
@@ -172,9 +173,16 @@ export const createRemoteClientAuthRuntime = ({ fsPromises, path, crypto, storeP
|
|
|
172
173
|
const store = await readStore();
|
|
173
174
|
const normalizedDedupeKey = normalizeOptionalString(dedupeKey);
|
|
174
175
|
const token = generateToken();
|
|
176
|
+
// A dedupe-keyed mint REPLACES the previous record for the same device,
|
|
177
|
+
// so an operator-visible name must survive the replacement: an explicit
|
|
178
|
+
// label wins, otherwise the replaced record's label is kept, and only a
|
|
179
|
+
// first-ever mint falls back to the client-reported default.
|
|
180
|
+
const existing = normalizedDedupeKey
|
|
181
|
+
? store.clients.find((entry) => entry.dedupeKey === normalizedDedupeKey)
|
|
182
|
+
: null;
|
|
175
183
|
const client = {
|
|
176
184
|
id: generateId(),
|
|
177
|
-
label: normalizeLabel(label),
|
|
185
|
+
label: normalizeLabel(normalizeOptionalString(label) || existing?.label || fallbackLabel),
|
|
178
186
|
tokenHash: hashToken(token),
|
|
179
187
|
createdAt: nowIso(),
|
|
180
188
|
lastUsedAt: null,
|
|
@@ -83,6 +83,23 @@ describe('remote client auth runtime', () => {
|
|
|
83
83
|
}
|
|
84
84
|
});
|
|
85
85
|
|
|
86
|
+
it('keeps the replaced record label on a dedupe re-mint without an explicit label', async () => {
|
|
87
|
+
const { dir, runtime } = await createRuntime();
|
|
88
|
+
try {
|
|
89
|
+
await runtime.createClient({ label: 'Iryna iPhone', dedupeKey: 'mobile:device-1', fallbackLabel: 'OpenChamber Mobile' });
|
|
90
|
+
const remint = await runtime.createClient({ dedupeKey: 'mobile:device-1', fallbackLabel: 'OpenChamber Mobile' });
|
|
91
|
+
expect(remint.client.label).toBe('Iryna iPhone');
|
|
92
|
+
|
|
93
|
+
const renamed = await runtime.createClient({ label: 'Work phone', dedupeKey: 'mobile:device-1', fallbackLabel: 'OpenChamber Mobile' });
|
|
94
|
+
expect(renamed.client.label).toBe('Work phone');
|
|
95
|
+
|
|
96
|
+
const fresh = await runtime.createClient({ dedupeKey: 'mobile:device-2', fallbackLabel: 'OpenChamber Mobile' });
|
|
97
|
+
expect(fresh.client.label).toBe('OpenChamber Mobile');
|
|
98
|
+
} finally {
|
|
99
|
+
await fs.rm(dir, { recursive: true, force: true });
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
86
103
|
it('keeps the token store private on disk', async () => {
|
|
87
104
|
const { dir, runtime } = await createRuntime();
|
|
88
105
|
try {
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
# Dictation module
|
|
2
2
|
|
|
3
|
-
Server-authoritative
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
Server-authoritative speech-to-text for the chat composer, plus local
|
|
4
|
+
text-to-speech. The client streams 16 kHz mono PCM16 chunks (base64) over a
|
|
5
|
+
WebSocket while the user speaks; the server buffers them and transcribes each
|
|
6
|
+
segment exactly once, when the segment is committed.
|
|
7
|
+
|
|
8
|
+
Transcription is deliberately not incremental. Parakeet is an offline model
|
|
9
|
+
trained on whole utterances, so re-decoding the growing buffer to animate a
|
|
10
|
+
live transcript costs O(n^2) work for a result the final decode replaces. The
|
|
11
|
+
composer shows no text while recording and inserts the full transcript on
|
|
12
|
+
stop.
|
|
7
13
|
|
|
8
14
|
Local TTS (Kokoro via sherpa-onnx OfflineTts) runs in the same worker process
|
|
9
15
|
and is exposed as `POST /api/dictation/tts/speak` (JSON `{text, speakerId?,
|
|
@@ -21,9 +27,9 @@ same status/download/delete routes.
|
|
|
21
27
|
Created from the startup pipeline (`startup-pipeline-runtime.js`) before
|
|
22
28
|
the generic OpenCode proxy so routes are not shadowed.
|
|
23
29
|
- `stream-manager.js` — `DictationStreamManager`, one per WS connection.
|
|
24
|
-
Chunk reordering by `seq` + ack, resampling to the provider rate,
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
Chunk reordering by `seq` + ack, resampling to the provider rate, segment
|
|
31
|
+
splitting, silence suppression by PCM peak, partial-transcript
|
|
32
|
+
concatenation, adaptive finalization timeout.
|
|
27
33
|
- `service.js` — provider resolution and readiness. Providers:
|
|
28
34
|
- `local` (default): sherpa-onnx Parakeet TDT in a forked worker process.
|
|
29
35
|
Models auto-download in the background on first use; while missing, the
|
|
@@ -33,7 +39,7 @@ same status/download/delete routes.
|
|
|
33
39
|
OpenAI-compatible `/v1/audio/transcriptions` endpoint
|
|
34
40
|
(`openai-compatible-session.js`, reuses `../tts/stt.js`).
|
|
35
41
|
- `local/` — worker process + client (IPC, idle shutdown TTL), sherpa
|
|
36
|
-
recognizer engine and
|
|
42
|
+
recognizer engine and segment session (one decode per committed segment),
|
|
37
43
|
model catalog and downloader. The native `sherpa-onnx-node` addon is only
|
|
38
44
|
ever loaded inside the worker process.
|
|
39
45
|
- `audio.js` — PCM16 helpers: format parsing, peak, WAV wrapping, streaming
|
|
@@ -53,9 +59,27 @@ Server → client: `ready`, `ack {ackSeq}`, `partial {text}`,
|
|
|
53
59
|
`{ provider: 'local' | 'openai-compatible', language?, localModel?,
|
|
54
60
|
openaiCompatible?: { baseUrl, model, apiKey } }`.
|
|
55
61
|
|
|
62
|
+
## Segmentation
|
|
63
|
+
|
|
64
|
+
A dictation is one segment unless it runs long. Past `segmentMinSeconds`
|
|
65
|
+
(60 s) the manager commits on the first silent chunk, so cuts land at a pause
|
|
66
|
+
rather than mid-word; `segmentMaxSeconds` (90 s) is a hard cap for speech with
|
|
67
|
+
no pause in it. Client chunks are ~1 s, so "silent chunk" is roughly a second
|
|
68
|
+
of silence.
|
|
69
|
+
|
|
70
|
+
The bounds exist because Parakeet is a full-attention conformer: decode cost
|
|
71
|
+
and peak memory grow quadratically with segment length. Measured on Parakeet
|
|
72
|
+
v3 int8 with 2 threads: 60 s took 2.1 s and +90 MB, 180 s took 9.3 s and
|
|
73
|
+
+490 MB, 300 s took 21.3 s and +1.5 GB. Committed segments decode while the
|
|
74
|
+
user is still speaking, so only the tail is left to transcribe on stop.
|
|
75
|
+
|
|
56
76
|
## Invariants
|
|
57
77
|
|
|
58
78
|
- Never load `sherpa-onnx-node` in the main server process.
|
|
79
|
+
- Transcription happens on commit only; sessions never emit non-final
|
|
80
|
+
transcripts. The `partial` messages a client receives are the concatenation
|
|
81
|
+
of already-committed segments, and exist so a dictation that fails partway
|
|
82
|
+
can be salvaged instead of losing minutes of speech.
|
|
59
83
|
- The stream manager acks only the highest contiguous seq; the client is
|
|
60
84
|
expected to retain unacked segments for retry/replay.
|
|
61
85
|
- Silence-only segments (peak < 300) are cleared, never committed, so
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Sherpa-onnx offline recognizer engine (NeMo transducer / Parakeet) plus a
|
|
3
|
-
*
|
|
4
|
-
* segment
|
|
3
|
+
* segment transcription session that decodes each segment exactly once, when
|
|
4
|
+
* the segment is committed.
|
|
5
|
+
*
|
|
6
|
+
* Parakeet is an offline model: it is trained to see a whole utterance at
|
|
7
|
+
* once. Decoding the accumulated audio repeatedly to animate a live transcript
|
|
8
|
+
* costs O(n^2) work for a result the final decode throws away, so this session
|
|
9
|
+
* only decodes on commit.
|
|
5
10
|
*
|
|
6
11
|
* Runs inside the dictation worker process only — never load the native
|
|
7
12
|
* addon in the main server process.
|
|
@@ -147,31 +152,26 @@ export class SherpaOfflineRecognizerEngine {
|
|
|
147
152
|
}
|
|
148
153
|
|
|
149
154
|
/**
|
|
150
|
-
*
|
|
151
|
-
* Accumulates the current segment's PCM and
|
|
152
|
-
*
|
|
153
|
-
* finalizes the segment and starts a new one.
|
|
155
|
+
* Segment transcription session backed by the offline recognizer.
|
|
156
|
+
* Accumulates the current segment's PCM and decodes it once in `commit()`,
|
|
157
|
+
* which emits the segment's final transcript and starts a new segment.
|
|
154
158
|
*
|
|
155
159
|
* Implements the StreamingTranscriptionSession contract used by
|
|
156
|
-
* DictationStreamManager.
|
|
160
|
+
* DictationStreamManager. It never emits non-final transcripts: the manager's
|
|
161
|
+
* live `partial` messages are the concatenation of already-committed segments.
|
|
157
162
|
*/
|
|
158
|
-
export class
|
|
163
|
+
export class SherpaSegmentTranscriptionSession extends EventEmitter {
|
|
159
164
|
/**
|
|
160
|
-
* @param {{ engine: SherpaOfflineRecognizerEngine
|
|
165
|
+
* @param {{ engine: SherpaOfflineRecognizerEngine }} params
|
|
161
166
|
*/
|
|
162
|
-
constructor({ engine
|
|
167
|
+
constructor({ engine }) {
|
|
163
168
|
super();
|
|
164
169
|
this.engine = engine;
|
|
165
170
|
this.requiredSampleRate = engine.sampleRate;
|
|
166
|
-
this.minDecodeIntervalMs = minDecodeIntervalMs ?? 350;
|
|
167
171
|
this.connected = false;
|
|
168
172
|
this.currentSegmentId = null;
|
|
169
173
|
this.previousSegmentId = null;
|
|
170
|
-
this.lastPartialText = '';
|
|
171
174
|
this.pcm16 = Buffer.alloc(0);
|
|
172
|
-
this.lastDecodeAt = 0;
|
|
173
|
-
this.decoding = false;
|
|
174
|
-
this.pendingDecode = false;
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
async connect() {
|
|
@@ -184,39 +184,38 @@ export class SherpaRealtimeTranscriptionSession extends EventEmitter {
|
|
|
184
184
|
|
|
185
185
|
appendPcm16(chunk) {
|
|
186
186
|
if (!this.connected || !this.currentSegmentId) {
|
|
187
|
-
this.emit('error', new Error('Sherpa
|
|
187
|
+
this.emit('error', new Error('Sherpa transcription session not connected'));
|
|
188
188
|
return;
|
|
189
189
|
}
|
|
190
190
|
this.pcm16 = this.pcm16.length === 0 ? chunk : Buffer.concat([this.pcm16, chunk]);
|
|
191
|
-
this.maybeDecode(false).catch((err) => {
|
|
192
|
-
this.emit('error', err instanceof Error ? err : new Error(String(err)));
|
|
193
|
-
});
|
|
194
191
|
}
|
|
195
192
|
|
|
196
193
|
commit() {
|
|
197
194
|
if (!this.connected || !this.currentSegmentId) {
|
|
198
|
-
this.emit('error', new Error('Sherpa
|
|
195
|
+
this.emit('error', new Error('Sherpa transcription session not connected'));
|
|
199
196
|
return;
|
|
200
197
|
}
|
|
201
198
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
const finalText = this.lastPartialText;
|
|
206
|
-
const segmentId = this.currentSegmentId;
|
|
207
|
-
const previousSegmentId = this.previousSegmentId;
|
|
199
|
+
const segmentId = this.currentSegmentId;
|
|
200
|
+
const previousSegmentId = this.previousSegmentId;
|
|
201
|
+
const pcm16 = this.pcm16;
|
|
208
202
|
|
|
209
|
-
|
|
210
|
-
|
|
203
|
+
// Start the next segment before decoding: decoding blocks the worker for
|
|
204
|
+
// seconds on long segments, and audio for the next one keeps arriving.
|
|
205
|
+
this.previousSegmentId = segmentId;
|
|
206
|
+
this.currentSegmentId = randomUUID();
|
|
207
|
+
this.pcm16 = Buffer.alloc(0);
|
|
211
208
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
209
|
+
this.emit('committed', { segmentId, previousSegmentId });
|
|
210
|
+
|
|
211
|
+
let transcript;
|
|
212
|
+
try {
|
|
213
|
+
transcript = this.engine.decodePcm16(pcm16);
|
|
214
|
+
} catch (err) {
|
|
215
|
+
this.emit('error', err instanceof Error ? err : new Error(String(err)));
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
this.emit('transcript', { segmentId, transcript, isFinal: true });
|
|
220
219
|
}
|
|
221
220
|
|
|
222
221
|
clear() {
|
|
@@ -225,7 +224,6 @@ export class SherpaRealtimeTranscriptionSession extends EventEmitter {
|
|
|
225
224
|
}
|
|
226
225
|
this.pcm16 = Buffer.alloc(0);
|
|
227
226
|
this.currentSegmentId = randomUUID();
|
|
228
|
-
this.lastPartialText = '';
|
|
229
227
|
}
|
|
230
228
|
|
|
231
229
|
close() {
|
|
@@ -233,45 +231,4 @@ export class SherpaRealtimeTranscriptionSession extends EventEmitter {
|
|
|
233
231
|
this.currentSegmentId = null;
|
|
234
232
|
this.pcm16 = Buffer.alloc(0);
|
|
235
233
|
}
|
|
236
|
-
|
|
237
|
-
async maybeDecode(force) {
|
|
238
|
-
if (!this.connected || !this.currentSegmentId) {
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
const now = Date.now();
|
|
243
|
-
if (!force && now - this.lastDecodeAt < this.minDecodeIntervalMs) {
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
if (this.decoding) {
|
|
248
|
-
this.pendingDecode = true;
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
this.decoding = true;
|
|
253
|
-
try {
|
|
254
|
-
const decodeStartedAt = Date.now();
|
|
255
|
-
const text = this.engine.decodePcm16(this.pcm16);
|
|
256
|
-
this.lastDecodeAt = Date.now();
|
|
257
|
-
// Adaptive throttle: on slow hardware (or heavy models) re-decoding the
|
|
258
|
-
// growing segment every 350ms would monopolize the worker. Space partial
|
|
259
|
-
// decodes to ~1.5x the observed decode time.
|
|
260
|
-
this.minDecodeIntervalMs = Math.max(350, (this.lastDecodeAt - decodeStartedAt) * 1.5);
|
|
261
|
-
if (text !== this.lastPartialText) {
|
|
262
|
-
this.lastPartialText = text;
|
|
263
|
-
this.emit('transcript', {
|
|
264
|
-
segmentId: this.currentSegmentId,
|
|
265
|
-
transcript: text,
|
|
266
|
-
isFinal: false,
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
} finally {
|
|
270
|
-
this.decoding = false;
|
|
271
|
-
if (this.pendingDecode) {
|
|
272
|
-
this.pendingDecode = false;
|
|
273
|
-
await this.maybeDecode(true);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
234
|
}
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
import {
|
|
19
19
|
SherpaOfflineRecognizerEngine,
|
|
20
|
-
|
|
20
|
+
SherpaSegmentTranscriptionSession,
|
|
21
21
|
} from './sherpa-recognizer.js';
|
|
22
22
|
import { SherpaTtsEngine } from './sherpa-tts.js';
|
|
23
23
|
import { getLocalSttModelDir, getLocalSttModelSpec } from './model-catalog.js';
|
|
@@ -126,7 +126,7 @@ async function handleRequest(message) {
|
|
|
126
126
|
case 'session.create': {
|
|
127
127
|
cleanupSession(message.sessionId);
|
|
128
128
|
const engine = getEngine(message.modelsDir, message.modelId);
|
|
129
|
-
const session = new
|
|
129
|
+
const session = new SherpaSegmentTranscriptionSession({ engine });
|
|
130
130
|
session.on('committed', (payload) => {
|
|
131
131
|
sendToParent({ type: 'session.committed', sessionId: message.sessionId, payload });
|
|
132
132
|
});
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
* endpoints (faster-whisper, whisper.cpp, OpenAI, ...).
|
|
4
4
|
*
|
|
5
5
|
* The Whisper HTTP API cannot stream, so audio is buffered per segment and
|
|
6
|
-
* transcribed on commit().
|
|
7
|
-
*
|
|
6
|
+
* transcribed on commit(). This matches how the local session behaves: the
|
|
7
|
+
* DictationStreamManager splits long dictations at pauses, and everything
|
|
8
|
+
* shorter is one request on stop.
|
|
8
9
|
*
|
|
9
10
|
* Implements the StreamingTranscriptionSession contract used by
|
|
10
11
|
* DictationStreamManager.
|