@openchamber/web 2.0.4 → 2.1.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-C_zL-eri.js → CodeMirrorCommentWidgets-qlshRzAf.js} +1 -1
- package/dist/assets/{DiffView-BeN2_YYF.js → DiffView-BI_YgdKl.js} +3 -3
- package/dist/assets/FilesView-B_NJFLBH.js +17 -0
- package/dist/assets/{GitView-DLDazOo1.js → GitView-BWKg6TNS.js} +4 -4
- package/dist/assets/{GuestAttachDialog-C0xe_Lyy.js → GuestAttachDialog-DO4x4vIR.js} +1 -1
- package/dist/assets/{GuestSurfacePane-BdaurnDr.js → GuestSurfacePane-4PY11vEP.js} +1 -1
- package/dist/assets/JsonTreeView-u4yx65zn.js +1 -0
- package/dist/assets/{LinearIssuesView-BryoAHow.js → LinearIssuesView-C4gGBhU8.js} +1 -1
- package/dist/assets/{MarkdownImageGallery-DfuEoaGq.js → MarkdownImageGallery-fqVRCTdC.js} +1 -1
- package/dist/assets/MarkdownRendererImpl-Cfb5fTnq.js +39 -0
- package/dist/assets/OnboardingScreen-CiTV2_OT.js +1 -0
- package/dist/assets/PatchDiff-BrjhzXDM.js +1 -0
- package/dist/assets/{PierreDiffViewer-BC950e3F.js → PierreDiffViewer-CVx2e1cx.js} +5 -5
- package/dist/assets/{PlanView-B7Xgihqk.js → PlanView-DP9DOnI-.js} +4 -4
- package/dist/assets/{PluginPane-2C71F8uF.js → PluginPane-rZvoMQSi.js} +3 -3
- package/dist/assets/SettingsView-Dp9jubRs.js +30 -0
- package/dist/assets/SettingsWindow-Dst0yiV7.js +1 -0
- package/dist/assets/{SubmoduleDiffSummary-BSA9gnIO.js → SubmoduleDiffSummary-CixkM4fI.js} +1 -1
- package/dist/assets/{ToolOutputDialog-DprkVKcj.js → ToolOutputDialog-f0cS2DIf.js} +6 -6
- package/dist/assets/ToolPartDiffPreview-CFFIAFFY.js +8 -0
- package/dist/assets/{VirtualizedFileDiff-Kp8hKJdT.js → VirtualizedFileDiff-B-U_aQwV.js} +4 -4
- package/dist/assets/{WalkthroughView-DGnTzqIU.js → WalkthroughView-C1uB3Pl3.js} +2 -2
- package/dist/assets/{appThemeRegistry-BdEHBA4s.js → appThemeRegistry-DU-UKEHq.js} +1 -1
- package/dist/assets/{commitAndPush-LwtVa2Oc.js → commitAndPush-CtWGqrtW.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-6V1xNpO9.js → computeVirtualFileMetrics-BmhViPMt.js} +1 -1
- package/dist/assets/de-D4hpTCNY.js +10 -0
- package/dist/assets/es-Bw9m3H62.js +16 -0
- package/dist/assets/fileTreeStatus-CvPnAWSi.js +1 -0
- package/dist/assets/fr-Bhll42P0.js +14 -0
- package/dist/assets/index-Btd2mmYT.js +42 -0
- package/dist/assets/index-C-7hQnEc.css +1 -0
- package/dist/assets/{index-CmNPYddV.js → index-DwtCnbiK.js} +1 -1
- package/dist/assets/{isDiffPlainText-1bXcWCrw.js → isDiffPlainText-CPDhzF1K.js} +1 -1
- package/dist/assets/{isFilePlainText-CBAppvy1.js → isFilePlainText-n8k0lMTZ.js} +1 -1
- package/dist/assets/ja-CsHoT43d.js +16 -0
- package/dist/assets/ko-BBNdtFa4.js +16 -0
- package/dist/assets/{main-CzjTMTfW.js → main-D6rlXjug.js} +2 -2
- package/dist/assets/main-kYkr_urz.js +1000 -0
- package/dist/assets/markdownCore-CHm8ycaW.js +7 -0
- package/dist/assets/{miniChat-CP68IL8Q.js → miniChat-2JY8K3Qw.js} +2 -2
- package/dist/assets/mobile-CviaXnnU.js +2 -0
- package/dist/assets/nl-DszyktfH.js +16 -0
- package/dist/assets/openSessionFromRoute-BIlcJIf3.js +1 -0
- package/dist/assets/{web-components-ngpHPEDU.js → parseDiffFromFile-DeZzEah8.js} +5 -5
- package/dist/assets/{patchFileDiff-pqRSHLHI.js → patchFileDiff-BnEHIdM2.js} +2 -2
- package/dist/assets/pl-Bk9_mUXc.js +16 -0
- package/dist/assets/pt-BR-BIXmm3Gw.js +16 -0
- package/dist/assets/{renderElectronMiniChatApp-DKIilR7N.js → renderElectronMiniChatApp-DvUphkjj.js} +2 -2
- package/dist/assets/renderMobileApp-Cdc49X8Y.js +25 -0
- package/dist/assets/runtimeEndpointReset-Cu6RUve4.js +56 -0
- package/dist/assets/shikiHighlight-CcVzlYit.js +1 -0
- package/dist/assets/space-apply-CgJ5JYPK.js +1 -0
- package/dist/assets/space-close-C1tL-_0t.js +1 -0
- package/dist/assets/{textMateThemeFromAppTheme-BSUFChBY.js → textMateThemeFromAppTheme-CAOCeVjl.js} +1 -1
- package/dist/assets/tr-C_13w7CX.js +7 -0
- package/dist/assets/uk-BZTsG-q_.js +16 -0
- package/dist/assets/{useAppFontEffects-Dsl_sLrj.js → useAppFontEffects-CeMgbeVa.js} +185 -177
- package/dist/assets/{useInlineCommentController-d5vntsQ_.js → useInlineCommentController-U97JJifS.js} +2 -2
- package/dist/assets/useRootScrollLock-DMBY2aTT.js +2 -0
- package/dist/assets/{vendor-base-ui-DnNniUWp.js → vendor-base-ui-DWgyZK2k.js} +1 -1
- package/dist/assets/vendor-codemirror-autocomplete-DetzHhtC.js +1 -0
- package/dist/assets/{vendor-codemirror-commands-B7H_j0iU.js → vendor-codemirror-commands-ConqfjLn.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-angular-DEPs2M5t.js → vendor-codemirror-lang-angular-Dbpx8qe-.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-cpp-DhkseaMo.js → vendor-codemirror-lang-cpp-TRtQWrpl.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-css-O0cZX78y.js → vendor-codemirror-lang-css-DY4CGDG2.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-go-fMdQYcON.js → vendor-codemirror-lang-go-CLKXh6B8.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-html-CfgK872x.js → vendor-codemirror-lang-html-CQnNjmg9.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-java-CQj4S3zl.js → vendor-codemirror-lang-java-CokZKqls.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-javascript-Cc2ZYbgX.js → vendor-codemirror-lang-javascript-Kgp6fZRE.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-jinja-BmZZv8g-.js → vendor-codemirror-lang-jinja-DZchyrN1.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-json-CMBS2tG9.js → vendor-codemirror-lang-json-CkdBRvqj.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-less-C6Eo8hVS.js → vendor-codemirror-lang-less-_k-GKz0A.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-liquid-DSTR47-H.js → vendor-codemirror-lang-liquid-DuHUMKoh.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-markdown-BPGOH9ye.js → vendor-codemirror-lang-markdown-CdG1RXm1.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-php-DD9udfPH.js → vendor-codemirror-lang-php-Ca15KQSA.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-python-HahnQaAS.js → vendor-codemirror-lang-python-B4MRHRva.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-rust-nLTovbjv.js → vendor-codemirror-lang-rust-8fLJdxQA.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sass-pL2Yc72v.js → vendor-codemirror-lang-sass-CASr_yQ1.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sql-BVBnan19.js → vendor-codemirror-lang-sql-Dc4ER-re.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-vue-BqGzJVm1.js → vendor-codemirror-lang-vue-fu2BqdK2.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-wast-B0_m5DqU.js → vendor-codemirror-lang-wast-BkCOgSpV.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-xml-Dj3voadT.js → vendor-codemirror-lang-xml-7e-kPepH.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-yaml-yu-9Z5u7.js → vendor-codemirror-lang-yaml-Cq3p_9DI.js} +1 -1
- package/dist/assets/vendor-codemirror-language-CZcLdzDM.js +3 -0
- package/dist/assets/{vendor-codemirror-language-data-B1EetJur.js → vendor-codemirror-language-data-B8HKnqZy.js} +2 -2
- package/dist/assets/vendor-codemirror-search-BZNojiZO.js +2 -0
- package/dist/assets/{vendor-codemirror-state-C9awkmn-.js → vendor-codemirror-state--21VQleR.js} +1 -1
- package/dist/assets/vendor-codemirror-view-8PpN-8l4.js +4 -0
- package/dist/assets/vendor-opencode-client-Byb4ZSqI.js +12 -0
- package/dist/assets/vendor-remend-DcBOpbSu.js +24 -0
- package/dist/assets/{vendor-replit-codemirror-vim-B2DJlAhT.js → vendor-replit-codemirror-vim-EX7OnecQ.js} +1 -1
- package/dist/assets/zh-CN-C62wm2Tg.js +16 -0
- package/dist/assets/zh-TW-BgGTiQA6.js +16 -0
- package/dist/index.html +4 -4
- package/dist/mini-chat.html +4 -4
- package/dist/mobile.html +4 -4
- package/package.json +4 -4
- package/server/index.js +58 -1
- package/server/lib/browser-control/DOCUMENTATION.md +8 -1
- package/server/lib/dev-tunnel/DOCUMENTATION.md +6 -0
- package/server/lib/dev-tunnel/runtime.js +94 -38
- package/server/lib/dev-tunnel/tunnel.test.js +16 -2
- package/server/lib/dictation/DOCUMENTATION.md +23 -10
- package/server/lib/dictation/audio.js +28 -0
- package/server/lib/dictation/local/sherpa-recognizer.js +33 -7
- package/server/lib/dictation/local/sherpa-recognizer.test.js +94 -0
- package/server/lib/dictation/local/worker-client.js +28 -10
- package/server/lib/dictation/local/worker-process.js +25 -1
- package/server/lib/dictation/stream-manager.js +160 -53
- package/server/lib/dictation/stream-manager.test.js +108 -7
- package/server/lib/enterprise-mode.d.ts +2 -0
- package/server/lib/enterprise-mode.js +84 -9
- package/server/lib/enterprise-mode.test.js +115 -0
- package/server/lib/fs/DOCUMENTATION.md +3 -2
- package/server/lib/fs/routes.js +28 -1
- package/server/lib/fs/routes.test.js +31 -5
- package/server/lib/git/DOCUMENTATION.md +1 -1
- package/server/lib/git/service.js +61 -2
- package/server/lib/git/service.test.js +141 -0
- package/server/lib/github/DOCUMENTATION.md +18 -0
- package/server/lib/github/checks-summary.js +76 -0
- package/server/lib/github/pr-summaries.js +282 -0
- package/server/lib/github/pr-summaries.test.js +209 -0
- package/server/lib/github/routes.js +42 -77
- package/server/lib/github/routes.test.js +77 -0
- package/server/lib/inherited-env.js +51 -0
- package/server/lib/inherited-env.test.js +59 -0
- package/server/lib/message-search/DOCUMENTATION.md +83 -0
- package/server/lib/message-search/indexer.js +336 -0
- package/server/lib/message-search/indexer.test.js +341 -0
- package/server/lib/message-search/routes.js +92 -0
- package/server/lib/message-search/runtime.js +234 -0
- package/server/lib/message-search/runtime.test.js +108 -0
- package/server/lib/message-search/sqlite.js +74 -0
- package/server/lib/message-search/store.js +289 -0
- package/server/lib/openchamber-control/DOCUMENTATION.md +6 -1
- package/server/lib/openchamber-control/actions.js +1 -1
- package/server/lib/openchamber-control/service.js +21 -2
- package/server/lib/openchamber-control/service.test.js +50 -0
- package/server/lib/openchamber-sessions/routes.js +15 -0
- package/server/lib/openchamber-sessions/routes.test.js +31 -0
- package/server/lib/opencode/DOCUMENTATION.md +43 -38
- package/server/lib/opencode/auth.d.ts +24 -0
- package/server/lib/opencode/auth.js +130 -66
- package/server/lib/opencode/auth.test.js +114 -70
- package/server/lib/opencode/compatibility.js +4 -3
- package/server/lib/opencode/compatibility.test.js +10 -10
- package/server/lib/opencode/feature-routes-runtime.js +3 -0
- package/server/lib/opencode/lifecycle.js +21 -12
- package/server/lib/opencode/lifecycle.test.js +38 -5
- package/server/lib/opencode/provider-source-route.test.js +55 -2
- package/server/lib/opencode/routes.js +17 -4
- package/server/lib/opencode/settings-helpers.js +6 -0
- package/server/lib/opencode/settings-helpers.test.js +1 -1
- package/server/lib/opencode/settings-registry.json +16 -0
- package/server/lib/opencode/settings-runtime.js +9 -0
- package/server/lib/opencode/shutdown-runtime.js +2 -0
- package/server/lib/opencode/v1-migration-topup.js +13 -3
- package/server/lib/opencode/v2-install.test.js +13 -13
- package/server/lib/quota/DOCUMENTATION.md +11 -5
- package/server/lib/quota/providers/claude/auth.js +19 -6
- package/server/lib/quota/providers/claude/auth.test.js +22 -9
- package/server/lib/quota/providers/claude/index.js +3 -3
- package/server/lib/quota/providers/claude/index.test.js +3 -2
- package/server/lib/quota/providers/cline-pass.js +4 -4
- package/server/lib/quota/providers/codex.js +3 -4
- package/server/lib/quota/providers/codex.test.js +1 -1
- package/server/lib/quota/providers/copilot.js +4 -5
- package/server/lib/quota/providers/copilot.test.js +1 -1
- package/server/lib/quota/providers/deepseek.js +3 -4
- package/server/lib/quota/providers/deepseek.test.js +1 -1
- package/server/lib/quota/providers/google/auth.js +1 -3
- package/server/lib/quota/providers/google/index.js +3 -2
- package/server/lib/quota/providers/hyper.js +4 -4
- package/server/lib/quota/providers/index.js +9 -2
- package/server/lib/quota/providers/index.test.js +5 -3
- package/server/lib/quota/providers/kimi.js +16 -11
- package/server/lib/quota/providers/kimi.test.js +81 -38
- package/server/lib/quota/providers/minimax-shared.js +3 -4
- package/server/lib/quota/providers/nanogpt.js +3 -4
- package/server/lib/quota/providers/neuralwatt.js +3 -4
- package/server/lib/quota/providers/neuralwatt.test.js +1 -1
- package/server/lib/quota/providers/openai.js +2 -8
- package/server/lib/quota/providers/opencode-go.js +5 -5
- package/server/lib/quota/providers/opencode-go.test.js +1 -1
- package/server/lib/quota/providers/openrouter.js +30 -6
- package/server/lib/quota/providers/openrouter.test.js +122 -1
- package/server/lib/quota/providers/wafer.js +3 -4
- package/server/lib/quota/providers/xai.js +12 -12
- package/server/lib/quota/providers/zai.js +3 -4
- package/server/lib/quota/providers/zai.test.js +1 -1
- package/server/lib/quota/providers/zhipuai-coding-plan.js +5 -6
- package/server/lib/quota/providers/zhipuai-coding-plan.test.js +1 -1
- package/server/lib/quota/routes.js +1 -1
- package/server/lib/routing/DOCUMENTATION.md +4 -0
- package/server/lib/routing/runtime.js +45 -4
- package/server/lib/routing/runtime.test.js +35 -6
- package/server/lib/scheduled-tasks/DOCUMENTATION.md +27 -0
- package/server/lib/scheduled-tasks/chats-scope.js +50 -0
- package/server/lib/scheduled-tasks/runtime.js +57 -23
- package/server/lib/scheduled-tasks/runtime.test.js +103 -1
- package/server/lib/scheduled-tasks/service.js +37 -29
- package/server/lib/scheduled-tasks/service.test.js +39 -0
- package/server/lib/spaces/DOCUMENTATION.md +54 -9
- package/server/lib/spaces/host.js +24 -3
- package/server/lib/spaces/journey.js +111 -11
- package/server/lib/spaces/journey.test.js +189 -8
- package/server/lib/spaces/places/docker-disk.js +151 -0
- package/server/lib/spaces/places/docker-disk.test.js +167 -0
- package/server/lib/spaces/places/docker-tools.js +11 -1
- package/server/lib/spaces/places/docker.js +4 -2
- package/server/lib/spaces/places/fake-docker.js +36 -2
- package/server/lib/spaces/routes.js +21 -4
- package/server/lib/spaces/routes.test.js +6 -2
- package/server/lib/spaces/space-archive.js +275 -0
- package/server/lib/spaces/space-archive.test.js +194 -0
- package/server/lib/spaces/space-opencode.js +139 -6
- package/server/lib/spaces/space-opencode.test.js +82 -1
- package/server/lib/spaces/space-records.js +3 -0
- package/server/lib/spaces/space-setup.js +10 -5
- package/server/lib/spaces/space-setup.test.js +8 -2
- package/server/lib/terminal/DOCUMENTATION.md +1 -0
- package/server/lib/terminal/runtime.js +6 -1
- package/server/lib/terminal/runtime.test.js +19 -0
- package/server/lib/tts/routes.js +2 -2
- package/server/lib/tts/service.js +8 -8
- package/dist/assets/FilesView-CN34wm_N.js +0 -17
- package/dist/assets/JsonTreeView-B1Xq-k2t.js +0 -1
- package/dist/assets/MarkdownRendererImpl-B_ZcWOvX.js +0 -12
- package/dist/assets/OnboardingScreen-C22bGmnP.js +0 -1
- package/dist/assets/PatchDiff-0xd6UeFB.js +0 -1
- package/dist/assets/SettingsView-m_zoFiaT.js +0 -30
- package/dist/assets/SettingsWindow-CofS020b.js +0 -1
- package/dist/assets/ToolPartDiffPreview-Dq0go_fX.js +0 -8
- package/dist/assets/de-DlgBHUAI.js +0 -10
- package/dist/assets/es-BC8G41U8.js +0 -16
- package/dist/assets/fr-I0z3vVjy.js +0 -14
- package/dist/assets/index-CgR5rJq_.js +0 -41
- package/dist/assets/index-adyy_sEk.css +0 -1
- package/dist/assets/ja-BIElEsY8.js +0 -16
- package/dist/assets/ko-DRnnHetA.js +0 -16
- package/dist/assets/main-DVX34beR.js +0 -886
- package/dist/assets/markdownCore-Cxbkn5NR.js +0 -7
- package/dist/assets/mobile-BrlBrNfZ.js +0 -2
- package/dist/assets/nl-DzUV-kwp.js +0 -16
- package/dist/assets/pl-Bb-cb7k7.js +0 -16
- package/dist/assets/pt-BR-CyIWrTcE.js +0 -16
- package/dist/assets/renderMobileApp-B0z6-x58.js +0 -25
- package/dist/assets/runtimeEndpointReset-uu1DBwLL.js +0 -52
- package/dist/assets/scheduledTasksApi-BuzWT445.js +0 -1
- package/dist/assets/shikiHighlight-BWGrY5YU.js +0 -1
- package/dist/assets/tr-DXEDSoYO.js +0 -7
- package/dist/assets/uk-C8hN--q_.js +0 -16
- package/dist/assets/useRootScrollLock-2rd5Y6gR.js +0 -2
- package/dist/assets/vendor-codemirror-autocomplete-DzPz9Wgq.js +0 -1
- package/dist/assets/vendor-codemirror-language-BgPj_McA.js +0 -3
- package/dist/assets/vendor-codemirror-search-BmS-GmcX.js +0 -2
- package/dist/assets/vendor-codemirror-view-CiLROUVV.js +0 -4
- package/dist/assets/vendor-opencode-client-DSZl7jSi.js +0 -12
- package/dist/assets/vendor-remend-BWYYytN3.js +0 -22
- package/dist/assets/zh-CN-CtzXdjMZ.js +0 -16
- package/dist/assets/zh-TW-Ds0CADSz.js +0 -16
- package/server/lib/opencode/credential-db.js +0 -144
- package/server/lib/opencode/credential-db.test.js +0 -104
|
@@ -102,7 +102,7 @@ const createRuntime = (overrides = {}, stateOverrides = {}, envOverrides = {}) =
|
|
|
102
102
|
waitForReady: vi.fn(async () => true),
|
|
103
103
|
normalizeApiPrefix: vi.fn(() => ''),
|
|
104
104
|
applyOpencodeBinaryFromSettings: vi.fn(async () => null),
|
|
105
|
-
checkOpenCodeBinary: async () => '2.0.
|
|
105
|
+
checkOpenCodeBinary: async () => '2.0.19',
|
|
106
106
|
ensureOpencodeCliEnv: vi.fn(),
|
|
107
107
|
ensureLocalOpenCodeServerPassword: vi.fn(async () => 'password'),
|
|
108
108
|
resolveManagedOpenCodeLaunchSpec: vi.fn((binary) => ({ binary, args: [], wrapperType: null })),
|
|
@@ -154,6 +154,9 @@ describe('OpenCode lifecycle', () => {
|
|
|
154
154
|
for (const [, , options] of spawnMock.mock.calls) {
|
|
155
155
|
expect(options.env).not.toHaveProperty('OPENCODE_BINARY');
|
|
156
156
|
}
|
|
157
|
+
// Credential reads take variable keys from the environment the current process got.
|
|
158
|
+
expect(runtime.getManagedOpenCodeProcessEnv()).toBe(spawnMock.mock.calls[1][2].env);
|
|
159
|
+
expect(runtime.getManagedOpenCodeProcessEnv()).toMatchObject({ SHELL_ONLY: 'yes' });
|
|
157
160
|
} finally {
|
|
158
161
|
await runtime.testState.openCodeProcess.close();
|
|
159
162
|
}
|
|
@@ -162,7 +165,7 @@ describe('OpenCode lifecycle', () => {
|
|
|
162
165
|
it('records an authoritative ready terminal event for external startup', async () => {
|
|
163
166
|
globalThis.fetch = vi.fn(async () => ({
|
|
164
167
|
ok: true,
|
|
165
|
-
json: async () => ({ version: '2.0.
|
|
168
|
+
json: async () => ({ version: '2.0.20', pid: 1, urls: [], paths: { tmp: '/tmp' } }),
|
|
166
169
|
}));
|
|
167
170
|
const runtime = createRuntime({
|
|
168
171
|
env: {
|
|
@@ -194,7 +197,7 @@ describe('OpenCode lifecycle', () => {
|
|
|
194
197
|
it('recovers an external OPENCODE_HOST connection using its configured endpoint', async () => {
|
|
195
198
|
const fetchMock = vi.fn(async () => ({
|
|
196
199
|
ok: true,
|
|
197
|
-
json: async () => ({ version: '2.0.
|
|
200
|
+
json: async () => ({ version: '2.0.20', pid: 1, urls: [], paths: { tmp: '/tmp' } }),
|
|
198
201
|
}));
|
|
199
202
|
globalThis.fetch = fetchMock;
|
|
200
203
|
const runtime = createRuntime({}, {
|
|
@@ -209,6 +212,7 @@ describe('OpenCode lifecycle', () => {
|
|
|
209
212
|
|
|
210
213
|
await runtime.restartOpenCode();
|
|
211
214
|
|
|
215
|
+
expect(runtime.getManagedOpenCodeProcessEnv()).toBeNull();
|
|
212
216
|
expect(fetchMock).toHaveBeenCalledWith(
|
|
213
217
|
'http://seamus:4095/api/info',
|
|
214
218
|
expect.objectContaining({ method: 'GET' }),
|
|
@@ -271,7 +275,7 @@ describe('OpenCode lifecycle', () => {
|
|
|
271
275
|
it('warms only the last-used directory after a successful bootstrap', async () => {
|
|
272
276
|
const fetchMock = vi.fn(async () => ({
|
|
273
277
|
ok: true,
|
|
274
|
-
json: async () => ({ version: '2.0.
|
|
278
|
+
json: async () => ({ version: '2.0.20', pid: 1, urls: [], paths: { tmp: '/tmp' } }),
|
|
275
279
|
}));
|
|
276
280
|
globalThis.fetch = fetchMock;
|
|
277
281
|
const runtime = createRuntime({
|
|
@@ -694,6 +698,35 @@ describe('OpenCode lifecycle', () => {
|
|
|
694
698
|
expect(server.signalCode).toBe('SIGTERM');
|
|
695
699
|
});
|
|
696
700
|
|
|
701
|
+
it('removes AppImage launcher entries from the managed OpenCode launch env', async () => {
|
|
702
|
+
delete process.env.OPENCODE_BINARY;
|
|
703
|
+
const previous = { APPDIR: process.env.APPDIR, LD_LIBRARY_PATH: process.env.LD_LIBRARY_PATH };
|
|
704
|
+
process.env.APPDIR = '/tmp/.mount_OpenChAbC123';
|
|
705
|
+
process.env.LD_LIBRARY_PATH = '/tmp/.mount_OpenChAbC123/usr/lib:/opt/x:';
|
|
706
|
+
const child = createMockChild();
|
|
707
|
+
spawnMock.mockImplementationOnce(() => {
|
|
708
|
+
queueMicrotask(() => {
|
|
709
|
+
child.stdout.emit('data', 'opencode server listening on http://127.0.0.1:45678\n');
|
|
710
|
+
});
|
|
711
|
+
return child;
|
|
712
|
+
});
|
|
713
|
+
|
|
714
|
+
try {
|
|
715
|
+
const runtime = createRuntime();
|
|
716
|
+
const server = await runtime.startOpenCode();
|
|
717
|
+
const [, , options] = spawnMock.mock.calls[0];
|
|
718
|
+
|
|
719
|
+
expect(options.env.LD_LIBRARY_PATH).toBe('/opt/x');
|
|
720
|
+
|
|
721
|
+
await server.close();
|
|
722
|
+
} finally {
|
|
723
|
+
for (const [key, value] of Object.entries(previous)) {
|
|
724
|
+
if (value === undefined) delete process.env[key];
|
|
725
|
+
else process.env[key] = value;
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
});
|
|
729
|
+
|
|
697
730
|
it('strips AppImage ARGV0 from managed OpenCode launch env', async () => {
|
|
698
731
|
delete process.env.OPENCODE_BINARY;
|
|
699
732
|
const previousArgv0 = process.env.ARGV0;
|
|
@@ -1021,7 +1054,7 @@ it('shares the managed CLI preflight with desktop while startup is pending', asy
|
|
|
1021
1054
|
await checking;
|
|
1022
1055
|
const desktopVerdict = runtime.getManagedOpenCodePreflight();
|
|
1023
1056
|
expect(runtime.testState.isOpenCodeReady).toBe(false);
|
|
1024
|
-
finish('2.0.
|
|
1057
|
+
finish('2.0.20');
|
|
1025
1058
|
expect(await desktopVerdict).toBe(true);
|
|
1026
1059
|
expect(checks).toBe(1);
|
|
1027
1060
|
const server = await starting;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { describe, expect, it, vi } from 'vitest';
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
2
|
import express from 'express';
|
|
3
3
|
import request from 'supertest';
|
|
4
4
|
import { registerOpenCodeRoutes } from './routes.js';
|
|
5
|
+
import { configureOpenCodeCredentials } from './auth.js';
|
|
5
6
|
|
|
6
7
|
const createApp = (getProviderSources) => {
|
|
7
8
|
const app = express();
|
|
@@ -21,6 +22,14 @@ describe('provider writes in enterprise mode', () => {
|
|
|
21
22
|
agent.post('/api/integration/github-copilot/connect/command').send({ methodID: 'cli' }),
|
|
22
23
|
agent.post('/api/experimental/integration/wellknown').send({ url: 'https://example.test' }),
|
|
23
24
|
agent.put('/api/provider').send({ providerID: 'company-ai', config: {}, scope: 'user' }),
|
|
25
|
+
// OpenCode routes these to the key handler too.
|
|
26
|
+
agent.post('/API/integration/openai/connect/key').send({ key: 'sk-test' }),
|
|
27
|
+
agent.post('/api//integration/openai/connect/key').send({ key: 'sk-test' }),
|
|
28
|
+
agent.post('/api/integration/openai/%63onnect/key').send({ key: 'sk-test' }),
|
|
29
|
+
agent.post('/api/integration\\openai\\connect\\key').send({ key: 'sk-test' }),
|
|
30
|
+
agent.post('/api/experimental/integration/wellknown;x').send({ url: 'https://example.test' }),
|
|
31
|
+
agent.post('/api/credential').send({ integrationID: 'openai', value: { type: 'key', key: 'sk-test' } }),
|
|
32
|
+
agent.post('/API//credential').send({ integrationID: 'openai', value: { type: 'key', key: 'sk-test' } }),
|
|
24
33
|
];
|
|
25
34
|
|
|
26
35
|
it('refuses connecting a provider, adding a key, or creating a custom provider', async () => {
|
|
@@ -31,8 +40,17 @@ describe('provider writes in enterprise mode', () => {
|
|
|
31
40
|
expect(response.status).toBe(403);
|
|
32
41
|
expect(response.body.code).toBe('enterprise_mode');
|
|
33
42
|
}
|
|
34
|
-
// Removing an account only narrows access and still reaches OpenCode.
|
|
43
|
+
// Removing or switching an account only narrows access and still reaches OpenCode.
|
|
35
44
|
expect((await agent.delete('/api/credential/cred_1')).status).toBe(404);
|
|
45
|
+
expect((await agent.post('/api/credential/cred_1/activate')).status).toBe(404);
|
|
46
|
+
// Signing in to a remote MCP server reaches a tool server, not a model provider.
|
|
47
|
+
const mcpSignIn = [
|
|
48
|
+
agent.post('/api/integration/mcp_0123456789abcdef/connect/oauth').send({ methodID: 'mcp_0123456789abcdef' }),
|
|
49
|
+
agent.post('/api/integration/mcp_0123456789abcdef/connect/oauth/att_1/complete').send({ code: 'x' }),
|
|
50
|
+
];
|
|
51
|
+
for (const response of await Promise.all(mcpSignIn)) {
|
|
52
|
+
expect(response.status).toBe(404);
|
|
53
|
+
}
|
|
36
54
|
} finally {
|
|
37
55
|
delete process.env.OPENCHAMBER_ENTERPRISE_MODE;
|
|
38
56
|
}
|
|
@@ -45,7 +63,42 @@ describe('provider writes in enterprise mode', () => {
|
|
|
45
63
|
});
|
|
46
64
|
});
|
|
47
65
|
|
|
66
|
+
describe('the stored credential list', () => {
|
|
67
|
+
const reads = (agent) => [
|
|
68
|
+
agent.get('/api/credential'),
|
|
69
|
+
agent.get('/API//credential/'),
|
|
70
|
+
agent.get('/api/%63redential'),
|
|
71
|
+
agent.head('/api/credential'),
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
it('never reaches a client, with or without enterprise mode', async () => {
|
|
75
|
+
const agent = request(createApp(vi.fn()));
|
|
76
|
+
for (const response of await Promise.all(reads(agent))) {
|
|
77
|
+
expect(response.status).toBe(403);
|
|
78
|
+
}
|
|
79
|
+
expect((await agent.get('/api/credential')).body.code).toBe('credential_list_refused');
|
|
80
|
+
|
|
81
|
+
process.env.OPENCHAMBER_ENTERPRISE_MODE = '1';
|
|
82
|
+
try {
|
|
83
|
+
for (const response of await Promise.all(reads(agent))) {
|
|
84
|
+
expect(response.status).toBe(403);
|
|
85
|
+
}
|
|
86
|
+
} finally {
|
|
87
|
+
delete process.env.OPENCHAMBER_ENTERPRISE_MODE;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('does not refuse renaming an account', async () => {
|
|
92
|
+
// No proxy in this app: falling through reads as Express's 404.
|
|
93
|
+
expect((await request(createApp(vi.fn())).patch('/api/credential/cred_1').send({ label: 'work' })).status).toBe(404);
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
48
97
|
describe('GET /api/provider/:providerId/source', () => {
|
|
98
|
+
// The auth source reads OpenCode's stored credentials; this one has none.
|
|
99
|
+
beforeEach(() => configureOpenCodeCredentials({ list: async () => [] }));
|
|
100
|
+
afterEach(() => configureOpenCodeCredentials(null));
|
|
101
|
+
|
|
49
102
|
it('returns the stored config entry next to the layer sources', async () => {
|
|
50
103
|
const stored = {
|
|
51
104
|
name: 'Stored',
|
|
@@ -11,7 +11,13 @@ import { OPENCODE_CONFIG_DIR } from './shared.js';
|
|
|
11
11
|
import { settingsSurfaceOf } from './settings-files.js';
|
|
12
12
|
import { parseWebSearchSelection } from './config-v2.js';
|
|
13
13
|
import { getWebSearchSource, setWarmingEnabled, setWebSearchSelection } from './websearch-config.js';
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
CREDENTIAL_LIST_ERROR,
|
|
16
|
+
ENTERPRISE_MODE_ERROR,
|
|
17
|
+
isCredentialListRequest,
|
|
18
|
+
isEnterpriseMode,
|
|
19
|
+
isProviderConnectRequest,
|
|
20
|
+
} from '../enterprise-mode.js';
|
|
15
21
|
|
|
16
22
|
export const registerOpenCodeRoutes = (app, dependencies) => {
|
|
17
23
|
const {
|
|
@@ -280,10 +286,9 @@ export const registerOpenCodeRoutes = (app, dependencies) => {
|
|
|
280
286
|
|
|
281
287
|
const sources = getProviderSources(providerId, directory);
|
|
282
288
|
const { getProviderAuth } = await getAuthLibrary();
|
|
283
|
-
const auth = getProviderAuth(providerId);
|
|
284
289
|
sources.sources.auth.exists = providerId === 'claude-code'
|
|
285
290
|
? getClaudeCliAuthStatus().connected
|
|
286
|
-
: Boolean(
|
|
291
|
+
: Boolean(await getProviderAuth(providerId));
|
|
287
292
|
|
|
288
293
|
return res.json({
|
|
289
294
|
providerId,
|
|
@@ -308,6 +313,14 @@ export const registerOpenCodeRoutes = (app, dependencies) => {
|
|
|
308
313
|
isProviderConnectRequest(req.method, req.path) ? refuseInEnterpriseMode(req, res, next) : next()
|
|
309
314
|
));
|
|
310
315
|
|
|
316
|
+
// Every stored key, secrets included (OpenCode 2.0.20): this server reads it
|
|
317
|
+
// for itself through `auth.js`, and no client gets it through the proxy.
|
|
318
|
+
app.use((req, res, next) => (
|
|
319
|
+
isCredentialListRequest(req.method, req.path)
|
|
320
|
+
? res.status(403).json({ error: CREDENTIAL_LIST_ERROR, code: 'credential_list_refused' })
|
|
321
|
+
: next()
|
|
322
|
+
));
|
|
323
|
+
|
|
311
324
|
app.put('/api/provider', refuseInEnterpriseMode, async (req, res) => {
|
|
312
325
|
try {
|
|
313
326
|
const providerID = typeof req.body?.providerID === 'string'
|
|
@@ -349,7 +362,7 @@ export const registerOpenCodeRoutes = (app, dependencies) => {
|
|
|
349
362
|
// OpenCode 2 keeps credentials in its own store, out of this server's
|
|
350
363
|
// sight, so the form states whether one exists or follows this write.
|
|
351
364
|
const { getProviderAuth } = await getAuthLibrary();
|
|
352
|
-
const hasStoredAuth = req.body?.hasCredential === true || Boolean(getProviderAuth(providerID));
|
|
365
|
+
const hasStoredAuth = req.body?.hasCredential === true || Boolean(await getProviderAuth(providerID));
|
|
353
366
|
const upsertResult = upsertProviderConfig(providerID, config, directory, scope, { hasStoredAuth });
|
|
354
367
|
|
|
355
368
|
return res.json({
|
|
@@ -289,6 +289,12 @@ export const createSettingsHelpers = (dependencies) => {
|
|
|
289
289
|
if (isPermissionMode(candidate.permissionDefaultMode)) {
|
|
290
290
|
result.permissionDefaultMode = candidate.permissionDefaultMode;
|
|
291
291
|
}
|
|
292
|
+
if (typeof candidate.messageSearchEnabled === 'boolean') {
|
|
293
|
+
result.messageSearchEnabled = candidate.messageSearchEnabled;
|
|
294
|
+
}
|
|
295
|
+
if (typeof candidate.messageSearchReasoningEnabled === 'boolean') {
|
|
296
|
+
result.messageSearchReasoningEnabled = candidate.messageSearchReasoningEnabled;
|
|
297
|
+
}
|
|
292
298
|
if (typeof candidate.desktopUiPassword === 'string') {
|
|
293
299
|
result.desktopUiPassword = candidate.desktopUiPassword.trim();
|
|
294
300
|
}
|
|
@@ -770,7 +770,7 @@ describe('settings registry gate', () => {
|
|
|
770
770
|
securityScopedBookmarks: ['bookmark'], pinnedDirectories: ['/home/testuser/project'],
|
|
771
771
|
desktopLanAccessEnabled: true, desktopKeepAwakeEnabled: true, desktopMinimizeToTrayEnabled: true, desktopMacMenuBarEnabled: true,
|
|
772
772
|
desktopUiPassword: 'secret', githubClientId: 'client', githubScopes: 'repo', skillCatalogs: [{ id: 'c', label: 'C', source: 'https://x' }],
|
|
773
|
-
defaultGitIdentityId: 'global', permissionAutoAccept: { sessions: { s: true }, revision: 1 }, permissionDefaultMode: 'safety',
|
|
773
|
+
defaultGitIdentityId: 'global', permissionAutoAccept: { sessions: { s: true }, revision: 1 }, permissionDefaultMode: 'safety', messageSearchEnabled: true, messageSearchReasoningEnabled: true,
|
|
774
774
|
agentControlToolEnabled: true, agentWebToolEnabled: true, browserProvider: 'builtin', agentMemoryToolEnabled: true, agentNotifyToolEnabled: true, agentToolsCodeMode: true, isolatedSpacesEnabled: true, isolatedSpacesIdleStop: { enabled: true, hours: 4 }, openCodeUpdateToastDismissedVersion: '1.0.0',
|
|
775
775
|
autoDeleteEnabled: true, autoDeleteAfterDays: 30, sessionRetentionOnlyArchived: false, sessionRetentionAction: 'archive', terminalShell: 'zsh', terminalLoginShells: ['zsh'],
|
|
776
776
|
openInAppId: 'vscode', dictationEnabled: true, sttProvider: 'local', sttServerUrl: 'http://localhost:8001/v1', sttModel: 'm', sttLocalModel: 'm', sttLanguage: 'en',
|
|
@@ -122,6 +122,22 @@
|
|
|
122
122
|
"mobile"
|
|
123
123
|
]
|
|
124
124
|
},
|
|
125
|
+
"messageSearchEnabled": {
|
|
126
|
+
"scope": "instance",
|
|
127
|
+
"surfaces": [
|
|
128
|
+
"web",
|
|
129
|
+
"desktop",
|
|
130
|
+
"mobile"
|
|
131
|
+
]
|
|
132
|
+
},
|
|
133
|
+
"messageSearchReasoningEnabled": {
|
|
134
|
+
"scope": "instance",
|
|
135
|
+
"surfaces": [
|
|
136
|
+
"web",
|
|
137
|
+
"desktop",
|
|
138
|
+
"mobile"
|
|
139
|
+
]
|
|
140
|
+
},
|
|
125
141
|
"agentControlToolEnabled": {
|
|
126
142
|
"scope": "instance"
|
|
127
143
|
},
|
|
@@ -68,6 +68,8 @@ export const createSettingsRuntime = (deps) => {
|
|
|
68
68
|
syncManagedRemoteTunnelConfigWithPresets,
|
|
69
69
|
upsertManagedRemoteTunnelToken,
|
|
70
70
|
onManagedPluginSettingsChanged = async () => {},
|
|
71
|
+
onMessageSearchEnabledChanged = () => {},
|
|
72
|
+
onMessageSearchReasoningChanged = () => {},
|
|
71
73
|
} = deps;
|
|
72
74
|
|
|
73
75
|
let persistSettingsLock = Promise.resolve();
|
|
@@ -1130,6 +1132,13 @@ export const createSettingsRuntime = (deps) => {
|
|
|
1130
1132
|
console.warn('Failed to refresh the managed OpenCode config:', error?.message ?? error);
|
|
1131
1133
|
});
|
|
1132
1134
|
}
|
|
1135
|
+
// The search index starts or stops in the background; the save does not wait for it.
|
|
1136
|
+
if (changedKeys.includes('messageSearchEnabled')) {
|
|
1137
|
+
onMessageSearchEnabledChanged(next.messageSearchEnabled === true);
|
|
1138
|
+
}
|
|
1139
|
+
if (changedKeys.includes('messageSearchReasoningEnabled')) {
|
|
1140
|
+
onMessageSearchReasoningChanged(next.messageSearchReasoningEnabled === true);
|
|
1141
|
+
}
|
|
1133
1142
|
return formatSettingsResponse(next);
|
|
1134
1143
|
});
|
|
1135
1144
|
|
|
@@ -13,6 +13,7 @@ export const createGracefulShutdownRuntime = (dependencies) => {
|
|
|
13
13
|
sessionGoalRuntime,
|
|
14
14
|
contextObligatoryRuntime,
|
|
15
15
|
messageQueueRuntime,
|
|
16
|
+
messageSearchRuntime,
|
|
16
17
|
scheduledTasksRuntime,
|
|
17
18
|
getHealthCheckInterval,
|
|
18
19
|
clearHealthCheckInterval,
|
|
@@ -87,6 +88,7 @@ export const createGracefulShutdownRuntime = (dependencies) => {
|
|
|
87
88
|
() => sessionGoalRuntime?.stop?.(),
|
|
88
89
|
() => contextObligatoryRuntime?.stop?.(),
|
|
89
90
|
() => messageQueueRuntime?.stop?.(),
|
|
91
|
+
() => messageSearchRuntime?.stop?.(),
|
|
90
92
|
() => scheduledTasksRuntime?.stop?.(),
|
|
91
93
|
stopAllGuestServices,
|
|
92
94
|
];
|
|
@@ -42,12 +42,22 @@
|
|
|
42
42
|
*/
|
|
43
43
|
|
|
44
44
|
import fs from 'node:fs';
|
|
45
|
+
import os from 'node:os';
|
|
45
46
|
import path from 'node:path';
|
|
46
47
|
import { createRequire } from 'node:module';
|
|
47
48
|
import { z } from 'zod';
|
|
48
49
|
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
const OPENCODE_DATA_DIR = path.join(os.homedir(), '.local', 'share', 'opencode');
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Where OpenCode keeps its database: `OPENCODE_DB` when set (absolute or
|
|
54
|
+
* relative to the data dir), else `opencode.db` in the data dir.
|
|
55
|
+
*/
|
|
56
|
+
const resolveOpenCodeDbPath = (env = process.env) => {
|
|
57
|
+
const configured = (env.OPENCODE_DB ?? '').trim();
|
|
58
|
+
if (configured && configured !== ':memory:') return path.resolve(OPENCODE_DATA_DIR, configured);
|
|
59
|
+
return path.join(OPENCODE_DATA_DIR, 'opencode.db');
|
|
60
|
+
};
|
|
51
61
|
|
|
52
62
|
/** OpenCode's key for the migration state row in `kv`. */
|
|
53
63
|
const MIGRATION_STATE_KEY = 'migration.v1-v2';
|
|
@@ -231,7 +241,7 @@ const countRevisitedSessions = (db, cursor) =>
|
|
|
231
241
|
*/
|
|
232
242
|
export const topUpV1Migration = (options = {}) => {
|
|
233
243
|
const {
|
|
234
|
-
dbPath =
|
|
244
|
+
dbPath = resolveOpenCodeDbPath(),
|
|
235
245
|
fileSystem = fs,
|
|
236
246
|
logger = console,
|
|
237
247
|
now = Date.now,
|
|
@@ -11,7 +11,7 @@ let homeDirectory;
|
|
|
11
11
|
let binary;
|
|
12
12
|
const quote = (value) => "'" + value.replaceAll("'", "'\\''") + "'";
|
|
13
13
|
const cli = (version) => '#!/bin/sh\nprintf "%s\\n" "opencode v' + version + '"\n';
|
|
14
|
-
const run = (script, version = '2.0.
|
|
14
|
+
const run = (script, version = '2.0.20') => installOpenCodeV2({
|
|
15
15
|
homeDirectory,
|
|
16
16
|
fetchImpl: async (url) => url.includes('registry.npmjs.org')
|
|
17
17
|
? Response.json({ version })
|
|
@@ -31,13 +31,13 @@ describe('OpenCode v2 installation', () => {
|
|
|
31
31
|
const script = `#!/bin/bash
|
|
32
32
|
set -eu
|
|
33
33
|
test "$1" = "--version"
|
|
34
|
-
test "$2" = "2.0.
|
|
34
|
+
test "$2" = "2.0.20"
|
|
35
35
|
test "$3" = "--no-modify-path"
|
|
36
|
-
printf %s ${quote(cli('2.0.
|
|
36
|
+
printf %s ${quote(cli('2.0.20'))} > ${quote(binary)}
|
|
37
37
|
chmod 755 ${quote(binary)}
|
|
38
38
|
`;
|
|
39
39
|
expect(await run(script)).toBe(binary);
|
|
40
|
-
expect(await readOpenCodeCliVersion({ binary, args: [] })).toBe('2.0.
|
|
40
|
+
expect(await readOpenCodeCliVersion({ binary, args: [] })).toBe('2.0.20');
|
|
41
41
|
await expect(fs.stat(path.join(path.dirname(binary), '.openchamber-install'))).rejects.toMatchObject({ code: 'ENOENT' });
|
|
42
42
|
});
|
|
43
43
|
|
|
@@ -63,7 +63,7 @@ chmod 755 ${quote(binary)}
|
|
|
63
63
|
});
|
|
64
64
|
|
|
65
65
|
describe('on Windows', () => {
|
|
66
|
-
const tarballOf = (name) => `https://registry.npmjs.org/@opencode/${name}/-/${name}-2.0.
|
|
66
|
+
const tarballOf = (name) => `https://registry.npmjs.org/@opencode/${name}/-/${name}-2.0.20.tgz`;
|
|
67
67
|
let exe;
|
|
68
68
|
const integrityOf = (bytes) => `sha512-${createHash('sha512').update(bytes).digest('base64')}`;
|
|
69
69
|
// The platform package keeps its binary at package/bin/opencode.exe. Here it is a
|
|
@@ -85,8 +85,8 @@ chmod 755 ${quote(binary)}
|
|
|
85
85
|
tarCommand: 'tar',
|
|
86
86
|
fetchImpl: async (url) => {
|
|
87
87
|
const name = PACKAGE_BY_ARCH[arch];
|
|
88
|
-
if (url.endsWith('/@opencode%2Fcli/latest')) return Response.json({ version: '2.0.
|
|
89
|
-
if (url.endsWith(`/@opencode%2F${name}/2.0.
|
|
88
|
+
if (url.endsWith('/@opencode%2Fcli/latest')) return Response.json({ version: '2.0.20' });
|
|
89
|
+
if (url.endsWith(`/@opencode%2F${name}/2.0.20`)) return Response.json({ dist: { tarball: tarballOf(name), integrity } });
|
|
90
90
|
if (url === tarballOf(name)) return new Response(archive);
|
|
91
91
|
return new Response(null, { status: 404 });
|
|
92
92
|
},
|
|
@@ -98,27 +98,27 @@ chmod 755 ${quote(binary)}
|
|
|
98
98
|
});
|
|
99
99
|
|
|
100
100
|
it('installs the verified platform package without the bash installer', async () => {
|
|
101
|
-
expect(await runWindows(await pack('2.0.
|
|
102
|
-
expect(await readOpenCodeCliVersion({ binary: exe, args: [] })).toBe('2.0.
|
|
101
|
+
expect(await runWindows(await pack('2.0.20'))).toBe(exe);
|
|
102
|
+
expect(await readOpenCodeCliVersion({ binary: exe, args: [] })).toBe('2.0.20');
|
|
103
103
|
expect(await readOpenCodeCliVersion({ binary, args: [] })).toBe('1.18.30');
|
|
104
104
|
await expect(fs.stat(path.join(path.dirname(exe), '.openchamber-install'))).rejects.toMatchObject({ code: 'ENOENT' });
|
|
105
105
|
});
|
|
106
106
|
|
|
107
107
|
it('installs the native arm64 package on Windows ARM64', async () => {
|
|
108
|
-
const archive = await pack('2.0.
|
|
108
|
+
const archive = await pack('2.0.20');
|
|
109
109
|
expect(await runWindows(archive, integrityOf(archive), 'arm64')).toBe(exe);
|
|
110
|
-
expect(await readOpenCodeCliVersion({ binary: exe, args: [] })).toBe('2.0.
|
|
110
|
+
expect(await readOpenCodeCliVersion({ binary: exe, args: [] })).toBe('2.0.20');
|
|
111
111
|
});
|
|
112
112
|
|
|
113
113
|
it('rejects a package that does not match its published integrity before touching the binary', async () => {
|
|
114
|
-
const archive = await pack('2.0.
|
|
114
|
+
const archive = await pack('2.0.20');
|
|
115
115
|
await expect(runWindows(archive, integrityOf(Buffer.from('other')))).rejects.toThrow('integrity');
|
|
116
116
|
expect(await readOpenCodeCliVersion({ binary: exe, args: [] })).toBe('1.18.30');
|
|
117
117
|
await expect(fs.stat(path.join(path.dirname(exe), '.openchamber-install'))).rejects.toMatchObject({ code: 'ENOENT' });
|
|
118
118
|
});
|
|
119
119
|
|
|
120
120
|
it('restores the previous binary when the package holds another release', async () => {
|
|
121
|
-
await expect(runWindows(await pack('2.0.
|
|
121
|
+
await expect(runWindows(await pack('2.0.19'))).rejects.toThrow();
|
|
122
122
|
expect(await readOpenCodeCliVersion({ binary: exe, args: [] })).toBe('1.18.30');
|
|
123
123
|
});
|
|
124
124
|
});
|
|
@@ -20,9 +20,13 @@ extension applies the same policy in its own process at activation.
|
|
|
20
20
|
|
|
21
21
|
These provider IDs are currently dispatchable via `fetchQuotaForProvider(providerId)` in `packages/web/server/lib/quota/providers/index.js`.
|
|
22
22
|
|
|
23
|
-
Where this table says "OpenCode `auth.json`", the credential is
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
Where this table says "OpenCode `auth.json`", the credential is the one the
|
|
24
|
+
running OpenCode uses (stored, or from an environment variable when
|
|
25
|
+
OpenChamber launched OpenCode), read through `../opencode/auth.js` (`GET
|
|
26
|
+
/api/credential`, see the opencode module docs); the name is the legacy shape
|
|
27
|
+
the entries keep. The provider list reads it once and hands it to every
|
|
28
|
+
`isConfigured(auth)`; each `fetchQuota` reads it again. When OpenCode cannot be
|
|
29
|
+
asked, `/api/quota/providers` answers 500 instead of an empty list.
|
|
26
30
|
|
|
27
31
|
| Provider ID | Display name | Module | Auth aliases/keys |
|
|
28
32
|
| --- | --- | --- | --- |
|
|
@@ -37,7 +41,7 @@ database first and the legacy file second (see the opencode module docs).
|
|
|
37
41
|
| `hyper` | Charm Hyper | `providers/hyper.js` | `hyper` (API key under `key` or `token`) |
|
|
38
42
|
| `github-copilot` | GitHub Copilot | `providers/copilot.js` | `github-copilot`, `copilot` |
|
|
39
43
|
| `github-copilot-addon` | GitHub Copilot Add-on | `providers/copilot.js` | `github-copilot`, `copilot` |
|
|
40
|
-
| `kimi-for-coding` | Kimi for Coding | `providers/kimi.js` | `kimi-for-coding`, `kimi` |
|
|
44
|
+
| `kimi-for-coding` | Kimi for Coding | `providers/kimi.js` | `kimi-code-plan-cn`, `kimi-for-coding`, `kimi`, `kimi-code-plan-global` (first match wins) |
|
|
41
45
|
| `nano-gpt` | NanoGPT | `providers/nanogpt.js` | `nano-gpt`, `nanogpt`, `nano_gpt` |
|
|
42
46
|
| `openrouter` | OpenRouter | `providers/openrouter.js` | `openrouter` |
|
|
43
47
|
| `zai-coding-plan` | z.ai | `providers/zai.js` | `zai-coding-plan`, `zai`, `z.ai` |
|
|
@@ -122,6 +126,8 @@ Web and VS Code accept finite numeric balances and non-empty numeric strings. Mi
|
|
|
122
126
|
- The weekly `usage` block returns `used` (consumed) with no `remaining` field.
|
|
123
127
|
- Each `limits[].detail` rate-limit block returns `remaining` (available) with no `used` field.
|
|
124
128
|
|
|
129
|
+
Credentials resolve in alias order, first match wins. OpenCode's China plan id `kimi-code-plan-cn` (kimi.com) comes before the pre-split `kimi-for-coding` and `kimi` ids, because a leftover pre-split key can hold a dead credential that would otherwise shadow the live China plan key and return 401. The global plan id `kimi-code-plan-global` (kimi.ai, API base `api.kimi.ai`) stays last: it is not verified that a global key works at the `api.kimi.com` usage address, so it must not outrank a working pre-split key.
|
|
130
|
+
|
|
125
131
|
The provider computes `usedPercent` from whichever of `used`/`remaining` is present (`used` takes precedence when both exist) rather than assuming one field name. Both `packages/web/server/lib/quota/providers/kimi.js` and `packages/vscode/src/quotaProviders.ts` (`fetchKimiQuota`) must stay in sync — the VS Code extension duplicates this parsing logic rather than importing it.
|
|
126
132
|
|
|
127
133
|
## Ollama Cloud settings-page shapes
|
|
@@ -149,7 +155,7 @@ snapshot carries `entitlement`, `remaining`, `unlimited`, and
|
|
|
149
155
|
|
|
150
156
|
## OpenRouter key semantics
|
|
151
157
|
|
|
152
|
-
OpenRouter quota reads `GET https://openrouter.ai/api/v1/key
|
|
158
|
+
OpenRouter quota reads `GET <base>/key`, where `<base>` is the provider's configured `baseURL` (`settings.baseURL`, legacy `options.baseURL`, or legacy `api`, folded by `toProviderEntity`; the v2 `providers.openrouter` entry wins, and the v1 `provider.openrouter` entry is read when the v2 one sets no address) read from the merged opencode config layers; with nothing configured or a config read failure, `<base>` falls back to `https://openrouter.ai/api/v1`. A gateway user's key is only valid against that gateway, so the usage lookup must ride the same base as chat. The default endpoint `GET https://openrouter.ai/api/v1/key` is documented as callable with any valid API key. `GET /api/v1/credits` is documented as "Management key required" and is not used. Calling `/credits` with a normal inference key has been observed to return HTTP 200 with `{total_credits:0, total_usage:0}` rather than an error; this behavior is not documented and is why the old implementation silently rendered "$0.00 left · $0.00 spent". A `/credits` fallback for unlimited keys would render the same zeros, so unlimited keys report `usage_monthly` instead.
|
|
153
159
|
|
|
154
160
|
The documented `limit`, `limit_remaining`, and `limit_reset` fields are present and null on unlimited keys; null means unlimited, never missing data. For a limited key, window usage is `limit - limit_remaining`, not `usage`: `usage` is all-time and measures a different axis from the current reset window. Pairing `usage` with the current limit produces a wrong number. `limit_remaining` is server-computed and already honors `include_byok_in_limit`, so `byok_*` fields are ignored.
|
|
155
161
|
|
|
@@ -18,7 +18,7 @@ import { execFileSync } from 'child_process';
|
|
|
18
18
|
import os from 'os';
|
|
19
19
|
import path from 'path';
|
|
20
20
|
|
|
21
|
-
import {
|
|
21
|
+
import { readOpenCodeCredentials } from '../../../opencode/auth.js';
|
|
22
22
|
import { asObject, asNonEmptyString, normalizeTimestamp, getAuthEntry, normalizeAuthEntry, readJsonFile } from '../../utils/index.js';
|
|
23
23
|
|
|
24
24
|
const KEYCHAIN_SERVICE = 'Claude Code-credentials';
|
|
@@ -79,8 +79,8 @@ const readKeychainCredential = () => {
|
|
|
79
79
|
const readCredentialsFile = () =>
|
|
80
80
|
parseClaudeCodeBlob(readJsonFile(path.join(claudeConfigDirectory(), '.credentials.json')), 'credentials-file');
|
|
81
81
|
|
|
82
|
-
const readOpenCodeCredential = () => {
|
|
83
|
-
const entry = normalizeAuthEntry(getAuthEntry(
|
|
82
|
+
const readOpenCodeCredential = (auth) => {
|
|
83
|
+
const entry = normalizeAuthEntry(getAuthEntry(auth, OPENCODE_AUTH_ALIASES));
|
|
84
84
|
const accessToken = asNonEmptyString(entry?.access) ?? asNonEmptyString(entry?.token);
|
|
85
85
|
if (!accessToken) return null;
|
|
86
86
|
return {
|
|
@@ -99,15 +99,28 @@ const readEnvCredential = () => {
|
|
|
99
99
|
};
|
|
100
100
|
|
|
101
101
|
/**
|
|
102
|
-
* First credential a source can produce, in priority order
|
|
102
|
+
* First credential a source can produce, in priority order, given the
|
|
103
|
+
* credentials OpenCode stores (`auth`).
|
|
103
104
|
*
|
|
104
105
|
* The Keychain wins over the credentials file because on macOS the file is a
|
|
105
106
|
* leftover that Claude Code no longer updates.
|
|
106
107
|
*
|
|
107
108
|
* @returns {ClaudeCredential|null}
|
|
108
109
|
*/
|
|
109
|
-
export const
|
|
110
|
+
export const findClaudeCredential = (auth) =>
|
|
110
111
|
readKeychainCredential()
|
|
111
112
|
?? readCredentialsFile()
|
|
112
|
-
?? readOpenCodeCredential()
|
|
113
|
+
?? readOpenCodeCredential(auth)
|
|
114
|
+
?? readEnvCredential();
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Same order as `findClaudeCredential`; OpenCode is asked only when the
|
|
118
|
+
* local Claude Code sources have nothing.
|
|
119
|
+
*
|
|
120
|
+
* @returns {Promise<ClaudeCredential|null>}
|
|
121
|
+
*/
|
|
122
|
+
export const loadClaudeCredential = async () =>
|
|
123
|
+
readKeychainCredential()
|
|
124
|
+
?? readCredentialsFile()
|
|
125
|
+
?? readOpenCodeCredential(await readOpenCodeCredentials())
|
|
113
126
|
?? readEnvCredential();
|
|
@@ -17,9 +17,9 @@ vi.mock('fs', () => {
|
|
|
17
17
|
return { ...fs, default: fs };
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
-
vi.mock('../../../opencode/auth.js', () => ({
|
|
20
|
+
vi.mock('../../../opencode/auth.js', () => ({ readOpenCodeCredentials: async () => openCodeAuth() }));
|
|
21
21
|
|
|
22
|
-
import { loadClaudeCredential } from './auth.js';
|
|
22
|
+
import { findClaudeCredential, loadClaudeCredential } from './auth.js';
|
|
23
23
|
|
|
24
24
|
const claudeCodeBlob = (accessToken) => JSON.stringify({
|
|
25
25
|
mcpOAuth: { 'linear|abc': { accessToken: 'unrelated-mcp-token' } },
|
|
@@ -55,12 +55,14 @@ afterEach(() => {
|
|
|
55
55
|
delete process.env.CLAUDE_CODE_OAUTH_TOKEN;
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
+
const findLocal = () => findClaudeCredential(openCodeAuth());
|
|
59
|
+
|
|
58
60
|
describe('Claude credential discovery', () => {
|
|
59
61
|
it('prefers the macOS Keychain over a stale credentials file', () => {
|
|
60
62
|
execFileSync.mockReturnValue(claudeCodeBlob('keychain-token'));
|
|
61
63
|
files.set(`${process.env.HOME}/.claude/.credentials.json`, claudeCodeBlob('file-token'));
|
|
62
64
|
|
|
63
|
-
const credential = withPlatform('darwin',
|
|
65
|
+
const credential = withPlatform('darwin', findLocal);
|
|
64
66
|
|
|
65
67
|
expect(credential.accessToken).toBe('keychain-token');
|
|
66
68
|
expect(credential.refreshToken).toBe('keychain-token-refresh');
|
|
@@ -71,7 +73,7 @@ describe('Claude credential discovery', () => {
|
|
|
71
73
|
it('reads the credentials file on Linux, where there is no Keychain', () => {
|
|
72
74
|
files.set(`${process.env.HOME}/.claude/.credentials.json`, claudeCodeBlob('file-token'));
|
|
73
75
|
|
|
74
|
-
const credential = withPlatform('linux',
|
|
76
|
+
const credential = withPlatform('linux', findLocal);
|
|
75
77
|
|
|
76
78
|
expect(execFileSync).not.toHaveBeenCalled();
|
|
77
79
|
expect(credential.accessToken).toBe('file-token');
|
|
@@ -82,13 +84,13 @@ describe('Claude credential discovery', () => {
|
|
|
82
84
|
process.env.CLAUDE_CONFIG_DIR = '/tmp/claude-home';
|
|
83
85
|
files.set('/tmp/claude-home/.credentials.json', claudeCodeBlob('custom-dir-token'));
|
|
84
86
|
|
|
85
|
-
expect(withPlatform('linux',
|
|
87
|
+
expect(withPlatform('linux', findLocal).accessToken).toBe('custom-dir-token');
|
|
86
88
|
});
|
|
87
89
|
|
|
88
90
|
it('falls back to the OpenCode auth entry when Claude Code is not signed in', () => {
|
|
89
91
|
openCodeAuth.mockReturnValue({ anthropic: { access: 'opencode-token', refresh: 'opencode-refresh', expires: 1786735755912 } });
|
|
90
92
|
|
|
91
|
-
const credential = withPlatform('linux',
|
|
93
|
+
const credential = withPlatform('linux', findLocal);
|
|
92
94
|
|
|
93
95
|
expect(credential.accessToken).toBe('opencode-token');
|
|
94
96
|
expect(credential.source).toBe('opencode-auth');
|
|
@@ -98,7 +100,7 @@ describe('Claude credential discovery', () => {
|
|
|
98
100
|
it('falls back to CLAUDE_CODE_OAUTH_TOKEN last, without a refresh token', () => {
|
|
99
101
|
process.env.CLAUDE_CODE_OAUTH_TOKEN = 'env-token';
|
|
100
102
|
|
|
101
|
-
const credential = withPlatform('linux',
|
|
103
|
+
const credential = withPlatform('linux', findLocal);
|
|
102
104
|
|
|
103
105
|
expect(credential.accessToken).toBe('env-token');
|
|
104
106
|
expect(credential.refreshToken).toBeNull();
|
|
@@ -108,10 +110,21 @@ describe('Claude credential discovery', () => {
|
|
|
108
110
|
it('ignores a Keychain blob that only holds unrelated MCP tokens', () => {
|
|
109
111
|
execFileSync.mockReturnValue(JSON.stringify({ mcpOAuth: { 'linear|abc': { accessToken: 'unrelated' } } }));
|
|
110
112
|
|
|
111
|
-
expect(withPlatform('darwin',
|
|
113
|
+
expect(withPlatform('darwin', findLocal)).toBeNull();
|
|
112
114
|
});
|
|
113
115
|
|
|
114
116
|
it('returns null when every source is empty', () => {
|
|
115
|
-
expect(withPlatform('darwin',
|
|
117
|
+
expect(withPlatform('darwin', findLocal)).toBeNull();
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it('asks OpenCode only when the local Claude Code sources are empty', async () => {
|
|
121
|
+
openCodeAuth.mockClear();
|
|
122
|
+
openCodeAuth.mockReturnValue({ anthropic: { access: 'opencode-token', refresh: 'opencode-refresh', expires: 1 } });
|
|
123
|
+
files.set(`${process.env.HOME}/.claude/.credentials.json`, claudeCodeBlob('file-token'));
|
|
124
|
+
expect((await withPlatform('linux', loadClaudeCredential)).source).toBe('credentials-file');
|
|
125
|
+
expect(openCodeAuth).not.toHaveBeenCalled();
|
|
126
|
+
|
|
127
|
+
files.clear();
|
|
128
|
+
expect((await withPlatform('linux', loadClaudeCredential)).source).toBe('opencode-auth');
|
|
116
129
|
});
|
|
117
130
|
});
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
import { createHash } from 'crypto';
|
|
12
12
|
|
|
13
13
|
import { buildResult } from '../../utils/index.js';
|
|
14
|
-
import { loadClaudeCredential } from './auth.js';
|
|
14
|
+
import { findClaudeCredential, loadClaudeCredential } from './auth.js';
|
|
15
15
|
import { toClaudeUsage } from './transforms.js';
|
|
16
16
|
|
|
17
17
|
export const providerId = 'claude';
|
|
@@ -65,10 +65,10 @@ const cachedResultFor = (fingerprint, planLabel) => {
|
|
|
65
65
|
const failure = (error, { configured = true } = {}) =>
|
|
66
66
|
buildResult({ providerId, providerName, ok: false, configured, error });
|
|
67
67
|
|
|
68
|
-
export const isConfigured = () => Boolean(
|
|
68
|
+
export const isConfigured = (auth) => Boolean(findClaudeCredential(auth));
|
|
69
69
|
|
|
70
70
|
const fetchQuotaUncoalesced = async () => {
|
|
71
|
-
const credential = loadClaudeCredential();
|
|
71
|
+
const credential = await loadClaudeCredential();
|
|
72
72
|
if (!credential) {
|
|
73
73
|
return failure('Not configured', { configured: false });
|
|
74
74
|
}
|