@openchambery/web 1.19.22-beta.1 → 2.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -7
- package/bin/cli-opencode.test.js +208 -0
- package/bin/cli.js +62 -9
- package/bin/lib/cli-startup.js +105 -2
- package/bin/lib/cli-startup.test.js +179 -0
- package/dist/assets/{AgentAvatar-CRaBJXKs.js → AgentAvatar-B_JQoreg.js} +1 -1
- package/dist/assets/AssistantView-ClQAfGOT.js +3 -0
- package/dist/assets/{DiagramView-D1LGK_s2.js → DiagramView-BNnda8qO.js} +1 -1
- package/dist/assets/{FadeInOnReveal-B0kJo9Ii.js → FadeInOnReveal-VYQTSAkr.js} +1 -1
- package/dist/assets/{Icon-BgdfPhNs.js → Icon-BiEQEcih.js} +1 -1
- package/dist/assets/MarkdownRenderer-CJHSsWin.js +2 -0
- package/dist/assets/{MarkdownRendererImpl-DfoCJ1Mq.js → MarkdownRendererImpl-DwrHFGUp.js} +3 -3
- package/dist/assets/{MarkstreamRendererImpl-D2dsW5Lg.js → MarkstreamRendererImpl-CSnbQMu3.js} +1 -1
- package/dist/assets/MobileDetailNavigation-BXr6AGLT.js +1 -0
- package/dist/assets/{MobileShareBridge-2Yjn6wXg.js → MobileShareBridge-D7OE9OP_.js} +2 -2
- package/dist/assets/MobileSurface-D2jUkX9l.js +2 -0
- package/dist/assets/{MultiRunWindow-tTbMFowS.js → MultiRunWindow-DF3iIFCd.js} +1 -1
- package/dist/assets/{OnboardingScreen-CD2KtlF3.js → OnboardingScreen-BjHmlwlw.js} +1 -1
- package/dist/assets/OverlayScrollbar-DLtWO_Gp.js +2 -0
- package/dist/assets/SettingsView-BRxELjow.js +25 -0
- package/dist/assets/{SettingsWindow-zIa76s4t.js → SettingsWindow-BI5swspb.js} +1 -1
- package/dist/assets/{TerminalView-CDdzF4yi.js → TerminalView-BU3x8-fr.js} +1 -1
- package/dist/assets/{ToolOutputDialog-DNqA4uBl.js → ToolOutputDialog-BEWhBcRd.js} +2 -2
- package/dist/assets/appThemeRegistry-4MR0F7Jz.js +1 -0
- package/dist/assets/{button-CI7Q-Zw_.js → button-DKuz3L8l.js} +1 -1
- package/dist/assets/collapsible-DXbDynN4.js +3 -0
- package/dist/assets/context-menu-CqolsLCm.js +1 -0
- package/dist/assets/{desktopHosts-B1ixEylr.js → desktopHosts-CoDkOnyS.js} +1 -1
- package/dist/assets/{desktopRelayRestore-4JmFUw8r.js → desktopRelayRestore-DDlVKyOE.js} +1 -1
- package/dist/assets/{diagram-DdLO8HZ9.js → diagram-D7T8HQgj.js} +1 -1
- package/dist/assets/{dialog-B6pnIYmp.js → dialog-DQYl3W_o.js} +1 -1
- package/dist/assets/es-CN3E_zXj.js +15 -0
- package/dist/assets/{fileMentionTouchSelection-DNeiqns-.js → fileMentionTouchSelection-BZ6ovBYH.js} +1 -1
- package/dist/assets/{fileQueries-DQc8EJUf.js → fileQueries-JrpcsOCs.js} +1 -1
- package/dist/assets/fr-9zZvQZD2.js +13 -0
- package/dist/assets/gitApi-CM42qUed.js +10 -0
- package/dist/assets/{imageSource-BlAJJUEI.js → imageSource-CIl0FL10.js} +1 -1
- package/dist/assets/{input-D-__fwRi.js → input-CzQy8UhV.js} +1 -1
- package/dist/assets/insertionBoundaries-CtkZ9720.js +1 -0
- package/dist/assets/ja-Dnjk_82N.js +15 -0
- package/dist/assets/ko-BxCEE99C.js +15 -0
- package/dist/assets/main-BILgBI3B.js +169 -0
- package/dist/assets/main-BeveiW6F.js +2 -0
- package/dist/assets/markdown-worker-bS5OgGO3.js +2 -0
- package/dist/assets/{markdownHeightCache-BhxqJOvf.js → markdownHeightCache-Cj1I5NDw.js} +1 -1
- package/dist/assets/{markdownTheme-DOfGg-A7.js → markdownTheme-CKac3wKC.js} +1 -1
- package/dist/assets/mcpQueries-D5mQymgM.js +1 -0
- package/dist/assets/miniChat-BgrzM3u7.js +2 -0
- package/dist/assets/mobile-DtYoQE8C.js +2 -0
- package/dist/assets/multirun-jy8dEI96.js +4 -0
- package/dist/assets/{persistence-Ce3AnpEr.js → persistence-C9LQpiOS.js} +2 -2
- package/dist/assets/pl-CNNsWnPM.js +15 -0
- package/dist/assets/platform-BQghHRfp.js +6 -0
- package/dist/assets/pt-BR-BZB2DJMp.js +15 -0
- package/dist/assets/renderElectronMiniChatApp-BGrrmeME.js +2 -0
- package/dist/assets/renderMobileApp-u3c4GtFC.js +28 -0
- package/dist/assets/{runtimeConfig-CMkwoQ_X.js → runtimeConfig-BIGBRGQI.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-ChOxt-J7.js → runtimeEndpointReset-D2savkuw.js} +12 -12
- package/dist/assets/{sessionChangeSummary-NnxcqCTI.js → sessionChangeSummary-eIbpSfrO.js} +1 -1
- package/dist/assets/{sessionLookup-BrU3rFHJ.js → sessionLookup-myHe5ltu.js} +1 -1
- package/dist/assets/{sortable-tabs-strip-Fnfhf3K9.js → sortable-tabs-strip-BQtmHx9r.js} +1 -1
- package/dist/assets/src-CLN7Z-zx.css +2 -0
- package/dist/assets/store-DLCiZaA6.js +15 -0
- package/dist/assets/{terminalApi-xjqssKke.js → terminalApi-BxcdiduX.js} +1 -1
- package/dist/assets/{textarea-bHYxZtfH.js → textarea-CakKvqFw.js} +1 -1
- package/dist/assets/{tooltip-0T5jv0cu.js → tooltip-Cx5gTbdY.js} +1 -1
- package/dist/assets/uk-rwQrxeYM.js +15 -0
- package/dist/assets/{url-_z7evzdK.js → url-CDHnjlsm.js} +1 -1
- package/dist/assets/{useAppFontEffects-C02YFyAv.js → useAppFontEffects-CNeo0aZs.js} +59 -45
- package/dist/assets/{useAssistantUIStore-CMutVh9B.js → useAssistantUIStore-asNG6K7n.js} +1 -1
- package/dist/assets/useDesktopWindowControlsLayout-DBJ56qIo.js +1 -0
- package/dist/assets/useEffectiveDirectory-B4LvR8Gt.js +1 -0
- package/dist/assets/{useFontPreferences-B1JYyzpK.js → useFontPreferences-CUnQ4TVm.js} +1 -1
- package/dist/assets/useMobileNavigationStore-ZHJPxlHt.js +414 -0
- package/dist/assets/{useRuntimeAPIs-DSLXJybW.js → useRuntimeAPIs-DwLtO0c_.js} +1 -1
- package/dist/assets/useSessionAutoCleanup-BIVmrnYU.js +2 -0
- package/dist/assets/{useThemeSystem-DMzWVJaW.js → useThemeSystem-BlNUWH47.js} +1 -1
- package/dist/assets/useUIStore-CQYKJnrg.js +1 -0
- package/dist/assets/{useWorkerHighlightedLines-C9z0ML1z.js → useWorkerHighlightedLines-CJZbJDW3.js} +2 -2
- package/dist/assets/{vendor-base-ui-CnHfUmDN.js → vendor-base-ui-CDjyofeD.js} +1 -1
- package/dist/assets/{vendor-cmdk-CeAGfrLo.js → vendor-cmdk-BFH0UpXX.js} +1 -1
- package/dist/assets/{vendor-dnd-kit-accessibility-BY5LhhUB.js → vendor-dnd-kit-accessibility-BrR3AKvM.js} +1 -1
- package/dist/assets/{vendor-dnd-kit-core-CvWxUPdb.js → vendor-dnd-kit-core-CNfdvk6H.js} +1 -1
- package/dist/assets/{vendor-dnd-kit-sortable-hHdP9lLb.js → vendor-dnd-kit-sortable-DQUaTeGj.js} +1 -1
- package/dist/assets/{vendor-framer-motion-DFy_BSVd.js → vendor-framer-motion-4dogsUk3.js} +1 -1
- package/dist/assets/{vendor-legendapp-list-WE32lwNk.js → vendor-legendapp-list-BU7MdPZR.js} +1 -1
- package/dist/assets/{vendor-markstream-react-DX55XLGO.js → vendor-markstream-react-qHC2FykU.js} +3 -3
- package/dist/assets/vendor-opencode-client-BOe2qpQb.js +12 -0
- package/dist/assets/{vendor-pierre-diffs-DX7XTPG3.js → vendor-pierre-diffs-CUfqC003.js} +1 -1
- package/dist/assets/{vendor-react-DLPElpoQ.js → vendor-react-C94A0AHl.js} +1 -1
- package/dist/assets/{vendor-react-drawio-ECtEwvbc.js → vendor-react-drawio-FVlWqKVE.js} +1 -1
- package/dist/assets/{vendor-reactuses-core-BnW6GxJt.js → vendor-reactuses-core-C2A3EjUi.js} +1 -1
- package/dist/assets/{vendor-sonner-DVzioF3d.js → vendor-sonner-DNqHmUQs.js} +1 -1
- package/dist/assets/{vendor-stream-diffs-DWy3xSmp.js → vendor-stream-diffs-CwbKsmlv.js} +2 -2
- package/dist/assets/{vendor-tanstack-react-query-D7pys_c9.js → vendor-tanstack-react-query-D0iFK57C.js} +1 -1
- package/dist/assets/{vendor-tanstack-react-virtual-tlDgH6PG.js → vendor-tanstack-react-virtual-B2kV6cnT.js} +1 -1
- package/dist/assets/{vendor-yaml-DIcAK3EC.js → vendor-yaml-C9KlJAlj.js} +37 -37
- package/dist/assets/{vendor-zustand-B4dlGEM2.js → vendor-zustand-BqLKf6ZY.js} +1 -1
- package/dist/assets/zh-CN-BvmBDnkD.js +15 -0
- package/dist/assets/zh-TW-9wcHTX0y.js +15 -0
- package/dist/index.html +13 -13
- package/dist/mini-chat.html +13 -13
- package/dist/mobile.html +13 -13
- package/package.json +2 -2
- package/server/index.js +392 -20
- package/server/lib/assistants/DOCUMENTATION.md +26 -21
- package/server/lib/assistants/assign.js +2 -1
- package/server/lib/assistants/contact-store.js +37 -19
- package/server/lib/assistants/contracts.js +11 -1
- package/server/lib/assistants/projection-history.test.js +454 -0
- package/server/lib/assistants/routes.js +11 -5
- package/server/lib/assistants/service.js +850 -294
- package/server/lib/assistants/service.test.js +588 -274
- package/server/lib/conversations/DOCUMENTATION.md +5 -5
- package/server/lib/conversations/service.js +87 -57
- package/server/lib/conversations/service.test.js +132 -100
- package/server/lib/conversations/validation.js +11 -1
- package/server/lib/event-stream/directory-ws-bridge.js +13 -2
- package/server/lib/event-stream/global-hub.js +51 -5
- package/server/lib/event-stream/runtime.js +57 -20
- package/server/lib/event-stream/runtime.test.js +112 -0
- package/server/lib/llm/DOCUMENTATION.md +95 -84
- package/server/lib/llm/catalog.js +111 -45
- package/server/lib/llm/catalog.test.js +121 -59
- package/server/lib/llm/completions.js +41 -12
- package/server/lib/llm/completions.test.js +45 -4
- package/server/lib/llm/generate.js +516 -453
- package/server/lib/llm/generate.test.js +705 -484
- package/server/lib/llm/routes.js +8 -4
- package/server/lib/message-queue/DOCUMENTATION.md +5 -5
- package/server/lib/message-queue/opencode-adapter.js +191 -104
- package/server/lib/message-queue/opencode-adapter.test.js +328 -58
- package/server/lib/message-queue/runtime.js +15 -2
- package/server/lib/message-queue/runtime.test.js +6 -6
- package/server/lib/message-queue/worker.js +7 -1
- package/server/lib/notifications/runtime.js +5 -0
- package/server/lib/opencode/DOCUMENTATION.md +103 -16
- package/server/lib/opencode/agent-document.d.ts +28 -0
- package/server/lib/opencode/agent-document.js +280 -0
- package/server/lib/opencode/agent-document.test.js +137 -0
- package/server/lib/opencode/agents.js +96 -0
- package/server/lib/opencode/auth-state-runtime.js +5 -0
- package/server/lib/opencode/bootstrap-runtime.js +2 -0
- package/server/lib/opencode/config-entity-routes.js +111 -102
- package/server/lib/opencode/config-entity-routes.test.js +123 -10
- package/server/lib/opencode/config-hot-reload.integration.test.js +105 -0
- package/server/lib/opencode/ensure-cli.js +238 -0
- package/server/lib/opencode/ensure-cli.test.js +119 -0
- package/server/lib/opencode/env-runtime.js +208 -111
- package/server/lib/opencode/env-runtime.test.js +211 -14
- package/server/lib/opencode/feature-routes-runtime.js +80 -5
- package/server/lib/opencode/feature-routes-runtime.test.js +18 -0
- package/server/lib/opencode/http-server-connections.js +98 -0
- package/server/lib/opencode/http-server-connections.test.js +321 -0
- package/server/lib/opencode/lifecycle.js +539 -95
- package/server/lib/opencode/lifecycle.test.js +698 -6
- package/server/lib/opencode/managed-capabilities-runtime.js +15 -2
- package/server/lib/opencode/managed-capabilities-runtime.test.js +1 -0
- package/server/lib/opencode/network-runtime.js +28 -16
- package/server/lib/opencode/network-runtime.test.js +68 -4
- package/server/lib/opencode/openchamber-routes.js +7 -1
- package/server/lib/opencode/opencode2-pin.js +139 -0
- package/server/lib/opencode/opencode2-pin.test.js +88 -0
- package/server/lib/opencode/opencode2-sidecar.e2e.test.js +326 -0
- package/server/lib/opencode/owned-runtime-upgrade.js +431 -0
- package/server/lib/opencode/owned-runtime-upgrade.test.js +160 -0
- package/server/lib/opencode/plugin-compatibility.js +15 -0
- package/server/lib/opencode/plugin-compatibility.test.js +21 -0
- package/server/lib/opencode/plugin-routes.js +3 -18
- package/server/lib/opencode/plugin-routes.test.js +9 -9
- package/server/lib/opencode/plugins.js +4 -3
- package/server/lib/opencode/plugins.test.js +12 -0
- package/server/lib/opencode/provider-catalog.js +58 -12
- package/server/lib/opencode/provider-catalog.test.js +48 -0
- package/server/lib/opencode/proxy.js +368 -28
- package/server/lib/opencode/proxy.test.js +338 -0
- package/server/lib/opencode/routes.js +303 -76
- package/server/lib/opencode/routes.test.js +315 -50
- package/server/lib/opencode/runtime-contract.js +401 -0
- package/server/lib/opencode/runtime-contract.test.js +214 -0
- package/server/lib/opencode/server-opencode-fetch.js +242 -0
- package/server/lib/opencode/server-opencode-fetch.test.js +130 -0
- package/server/lib/opencode/server-utils-runtime.js +35 -0
- package/server/lib/opencode/shared-service.integration.test.js +66 -0
- package/server/lib/opencode/shared-service.js +147 -0
- package/server/lib/opencode/shared-service.test.js +93 -0
- package/server/lib/opencode/shared.js +3 -3
- package/server/lib/opencode/shutdown-runtime.js +15 -6
- package/server/lib/opencode/shutdown-runtime.test.js +49 -1
- package/server/lib/opencode/skill-routes.js +26 -40
- package/server/lib/opencode/skill-routes.test.js +71 -7
- package/server/lib/opencode/skills.test.js +15 -0
- package/server/lib/opencode/startup-pipeline-runtime.js +4 -0
- package/server/lib/opencode/static-routes-runtime.js +3 -1
- package/server/lib/opencode/static-routes-runtime.test.js +33 -0
- package/server/lib/opencode/v1-migration-gate.js +157 -0
- package/server/lib/opencode/v1-migration-gate.test.js +111 -0
- package/server/lib/opencode/v2-client.js +60 -0
- package/server/lib/opencode/v2-plugin-host-shim/index.mjs +155 -0
- package/server/lib/opencode/v2-plugin-host-shim/package.json +4 -0
- package/server/lib/opencode/watcher.js +2 -1
- package/server/lib/opencode/watcher.test.js +1 -1
- package/server/lib/permission-auto-accept/DOCUMENTATION.md +5 -5
- package/server/lib/permission-auto-accept/runtime.js +14 -7
- package/server/lib/permission-auto-accept/runtime.test.js +27 -12
- package/server/lib/relay/reasoning-projection.e2e.test.ts +22 -7
- package/server/lib/scheduled-tasks/DOCUMENTATION.md +79 -39
- package/server/lib/scheduled-tasks/managed-tool-route.js +31 -1
- package/server/lib/scheduled-tasks/managed-tool-route.test.js +23 -0
- package/server/lib/scheduled-tasks/routes.js +27 -0
- package/server/lib/scheduled-tasks/routes.test.js +94 -0
- package/server/lib/scheduled-tasks/runtime.js +381 -310
- package/server/lib/scheduled-tasks/runtime.test.js +600 -309
- package/server/lib/session-goal/DOCUMENTATION.md +173 -22
- package/server/lib/session-goal/capability.js +57 -0
- package/server/lib/session-goal/capability.test.js +33 -0
- package/server/lib/session-goal/routes.js +240 -2
- package/server/lib/session-goal/routes.test.js +211 -0
- package/server/lib/session-goal/runtime.js +1617 -113
- package/server/lib/session-goal/runtime.test.js +1500 -70
- package/server/lib/session-index/DOCUMENTATION.md +18 -15
- package/server/lib/session-index/event-ingest.js +89 -16
- package/server/lib/session-index/event-ingest.test.js +73 -0
- package/server/lib/session-index/host-authority-snapshot.js +92 -0
- package/server/lib/session-index/routes.host-archive.test.js +201 -0
- package/server/lib/session-index/routes.js +63 -10
- package/server/lib/session-index/routes.test.js +8 -8
- package/server/lib/session-index/service.js +7 -1
- package/server/lib/session-index/sync-runtime.js +171 -41
- package/server/lib/session-index/sync-runtime.test.js +164 -9
- package/server/lib/session-metadata/DOCUMENTATION.md +86 -0
- package/server/lib/session-metadata/routes.js +193 -0
- package/server/lib/session-metadata/routes.test.js +156 -0
- package/server/lib/session-metadata/session-archive.d.ts +73 -0
- package/server/lib/session-metadata/session-archive.js +654 -0
- package/server/lib/session-metadata/session-archive.test.js +359 -0
- package/server/lib/session-metadata/session-metadata-store.d.ts +36 -0
- package/server/lib/session-metadata/session-metadata-store.js +375 -0
- package/server/lib/session-metadata/session-metadata-store.test.js +379 -0
- package/server/lib/session-metadata/session-projection.d.ts +41 -0
- package/server/lib/session-metadata/session-projection.js +255 -0
- package/server/lib/session-metadata/session-projection.test.js +64 -0
- package/server/lib/session-metadata/system-session.js +55 -0
- package/server/lib/session-metadata/system-session.test.js +55 -0
- package/server/lib/session-title/DOCUMENTATION.md +40 -7
- package/server/lib/session-title/native-runtime.test.js +167 -0
- package/server/lib/session-title/runtime.js +67 -42
- package/server/lib/session-title/session-access.js +46 -0
- package/server/lib/session-title/session-access.test.js +91 -0
- package/server/lib/session-turn-pages/DOCUMENTATION.md +12 -11
- package/server/lib/session-turn-pages/reconcile.service.js +1 -1
- package/server/lib/session-turn-pages/reconcile.service.test.js +16 -0
- package/server/lib/session-turn-pages/routes.js +123 -75
- package/server/lib/session-turn-pages/routes.test.js +566 -0
- package/server/lib/session-turn-pages/service.js +6 -2
- package/server/lib/session-turn-pages/service.test.js +34 -0
- package/server/lib/session-turn-pages/session-message-projection.d.ts +13 -0
- package/server/lib/session-turn-pages/session-message-projection.js +281 -0
- package/server/lib/small-model/DOCUMENTATION.md +101 -146
- package/server/lib/small-model/catalog.js +84 -54
- package/server/lib/small-model/catalog.test.js +111 -9
- package/server/lib/small-model/custom-api.js +68 -0
- package/server/lib/small-model/custom-api.test.js +64 -0
- package/server/lib/small-model/index.js +125 -241
- package/server/lib/small-model/resolve.js +35 -120
- package/server/lib/small-model/resolve.test.js +20 -110
- package/server/lib/small-model/routes.js +1 -3
- package/server/lib/small-model/summary-settings.test.js +157 -253
- package/server/opencode-proxy.test.js +63 -12
- package/dist/assets/AssistantView-BUveAgc4.js +0 -3
- package/dist/assets/MarkdownRenderer-BbrbDH6-.js +0 -2
- package/dist/assets/MobileDetailNavigation-B0aqKXd7.js +0 -1
- package/dist/assets/MobileSurface-DW7WfPsy.js +0 -2
- package/dist/assets/OverlayScrollbar-DrA0Vsg5.js +0 -2
- package/dist/assets/SettingsView-PkXIavr7.js +0 -25
- package/dist/assets/appThemeRegistry-D5Yxg4YF.js +0 -1
- package/dist/assets/collapsible-D5Phaykh.js +0 -1
- package/dist/assets/context-menu-CubSDW2g.js +0 -1
- package/dist/assets/es-DA3MqOo0.js +0 -15
- package/dist/assets/fr-Dbz0CdIA.js +0 -13
- package/dist/assets/gitApi-DXyC4MiV.js +0 -7
- package/dist/assets/insertionBoundaries-KlOVrHHt.js +0 -1
- package/dist/assets/ja-DumanVQA.js +0 -15
- package/dist/assets/ko-C0IkiUjQ.js +0 -15
- package/dist/assets/main-BPS5ylib.js +0 -2
- package/dist/assets/main-Cpd9VWYs.js +0 -169
- package/dist/assets/markdown-worker-CptoICmq.js +0 -2
- package/dist/assets/miniChat-B8_KLWiY.js +0 -2
- package/dist/assets/mobile-CtktKrXn.js +0 -2
- package/dist/assets/multirun-CYfP9Cfm.js +0 -4
- package/dist/assets/pl-B9No6MQp.js +0 -15
- package/dist/assets/platform-0w_Q9_ji.js +0 -2
- package/dist/assets/projectMeta-S1hJ7oBp.js +0 -3
- package/dist/assets/pt-BR-DyQ0WTDh.js +0 -15
- package/dist/assets/renderElectronMiniChatApp-iK14LWm8.js +0 -2
- package/dist/assets/renderMobileApp-DORLPWnb.js +0 -28
- package/dist/assets/src-rS3zCcsC.css +0 -2
- package/dist/assets/store-5B_LDnLM.js +0 -15
- package/dist/assets/uk-C_1KkqyP.js +0 -15
- package/dist/assets/useDesktopWindowControlsLayout-Dnr-jX0C.js +0 -1
- package/dist/assets/useEffectiveDirectory-CZLLyarc.js +0 -1
- package/dist/assets/useMobileNavigationStore-CoCiqNgm.js +0 -413
- package/dist/assets/useSessionAutoCleanup-xQyETQkG.js +0 -2
- package/dist/assets/useUIStore-Bxv3f23A.js +0 -1
- package/dist/assets/vendor-opencode-sdk-C07HQypa.js +0 -7
- package/dist/assets/zh-CN-uWILgBdt.js +0 -15
- package/dist/assets/zh-TW-MYfdvhbD.js +0 -15
- package/server/lib/small-model/call.js +0 -427
- package/server/lib/small-model/call.test.js +0 -382
- package/server/lib/small-model/opencode-session.js +0 -339
- package/server/lib/small-model/opencode-session.test.js +0 -177
|
@@ -1,382 +0,0 @@
|
|
|
1
|
-
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
-
|
|
3
|
-
// readConfig reads merged opencode config layers from disk; mock it so each
|
|
4
|
-
// test controls the provider config without touching the filesystem. call.js
|
|
5
|
-
// imports only readConfig from shared.js, so the rest of that module is left
|
|
6
|
-
// untouched for this file.
|
|
7
|
-
vi.mock('../opencode/shared.js', () => ({
|
|
8
|
-
readConfig: vi.fn(),
|
|
9
|
-
}));
|
|
10
|
-
|
|
11
|
-
const { callSmallModel } = await import('./call.js');
|
|
12
|
-
const { readConfig } = await import('../opencode/shared.js');
|
|
13
|
-
|
|
14
|
-
// Minimal catalog fragment used by the catalog-based base URL resolution case.
|
|
15
|
-
// Base URL comes from model.api.url (OpenCode SDK shape), not provider.api.
|
|
16
|
-
const CATALOG = {
|
|
17
|
-
mistral: {
|
|
18
|
-
id: 'mistral',
|
|
19
|
-
name: 'Mistral',
|
|
20
|
-
models: {
|
|
21
|
-
'mistral-small-latest': {
|
|
22
|
-
id: 'mistral-small-latest',
|
|
23
|
-
api: { url: 'https://api.mistral.ai/v1' },
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const ok = (content) => ({
|
|
30
|
-
ok: true,
|
|
31
|
-
status: 200,
|
|
32
|
-
json: async () => ({
|
|
33
|
-
choices: [{ message: { content }, finish_reason: 'stop' }],
|
|
34
|
-
}),
|
|
35
|
-
text: async () => JSON.stringify({
|
|
36
|
-
choices: [{ message: { content }, finish_reason: 'stop' }],
|
|
37
|
-
}),
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
const lastCall = (mock) => {
|
|
41
|
-
const [url, init] = mock.mock.calls.at(-1);
|
|
42
|
-
return { url: String(url), init };
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
// Regression coverage for the small-model dispatch to custom OpenAI-compatible
|
|
46
|
-
// providers — credential and endpoint resolution, precedence, and non-leakage.
|
|
47
|
-
describe('callSmallModel — custom provider config', () => {
|
|
48
|
-
let fetchMock;
|
|
49
|
-
let originalFetch;
|
|
50
|
-
|
|
51
|
-
beforeEach(() => {
|
|
52
|
-
fetchMock = vi.fn();
|
|
53
|
-
originalFetch = globalThis.fetch;
|
|
54
|
-
globalThis.fetch = fetchMock;
|
|
55
|
-
readConfig.mockReset();
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
afterEach(() => {
|
|
59
|
-
globalThis.fetch = originalFetch;
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
describe('config-supplied credentials (no auth.json entry)', () => {
|
|
63
|
-
it('calls a custom summary API without an OpenCode provider login', async () => {
|
|
64
|
-
fetchMock.mockResolvedValue(ok('summary'));
|
|
65
|
-
|
|
66
|
-
const text = await callSmallModel({
|
|
67
|
-
auth: {},
|
|
68
|
-
catalog: {},
|
|
69
|
-
workingDirectory: '/proj',
|
|
70
|
-
providerID: 'custom',
|
|
71
|
-
modelID: 'summary-model',
|
|
72
|
-
prompt: 'Summarize this diff.',
|
|
73
|
-
custom: {
|
|
74
|
-
baseURL: 'https://summary.example.test/v1',
|
|
75
|
-
apiToken: 'summary-token',
|
|
76
|
-
},
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
expect(text).toBe('summary');
|
|
80
|
-
const { url, init } = lastCall(fetchMock);
|
|
81
|
-
expect(url).toBe('https://summary.example.test/v1/chat/completions');
|
|
82
|
-
expect(init.headers.Authorization).toBe('Bearer summary-token');
|
|
83
|
-
expect(JSON.stringify(init.body)).not.toContain('summary-token');
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it('uses apiKey and baseURL from provider config when no auth.json entry exists', async () => {
|
|
87
|
-
readConfig.mockReturnValue({
|
|
88
|
-
provider: {
|
|
89
|
-
custom: {
|
|
90
|
-
options: { apiKey: 'test-key', baseURL: 'https://proxy.example.test/v1' },
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
});
|
|
94
|
-
fetchMock.mockResolvedValue(ok('hello'));
|
|
95
|
-
|
|
96
|
-
const text = await callSmallModel({
|
|
97
|
-
auth: {},
|
|
98
|
-
catalog: {},
|
|
99
|
-
workingDirectory: '/proj',
|
|
100
|
-
providerID: 'custom',
|
|
101
|
-
modelID: 'gpt-4o-mini',
|
|
102
|
-
prompt: 'hi',
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
expect(text).toBe('hello');
|
|
106
|
-
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
107
|
-
|
|
108
|
-
const { url, init } = lastCall(fetchMock);
|
|
109
|
-
// Config baseURL is used, never the hardcoded OpenAI endpoint.
|
|
110
|
-
expect(url).toBe('https://proxy.example.test/v1/chat/completions');
|
|
111
|
-
expect(url).not.toContain('api.openai.com');
|
|
112
|
-
// Config apiKey becomes the bearer credential.
|
|
113
|
-
expect(init.headers.Authorization).toBe('Bearer test-key');
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it('trims a trailing slash from the configured baseURL', async () => {
|
|
117
|
-
readConfig.mockReturnValue({
|
|
118
|
-
provider: {
|
|
119
|
-
custom: { options: { apiKey: 'k', baseURL: 'https://proxy.example.test/v1/' } },
|
|
120
|
-
},
|
|
121
|
-
});
|
|
122
|
-
fetchMock.mockResolvedValue(ok('ok'));
|
|
123
|
-
|
|
124
|
-
await callSmallModel({
|
|
125
|
-
auth: {},
|
|
126
|
-
catalog: {},
|
|
127
|
-
workingDirectory: '/proj',
|
|
128
|
-
providerID: 'custom',
|
|
129
|
-
modelID: 'gpt-4o-mini',
|
|
130
|
-
prompt: 'hi',
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
expect(lastCall(fetchMock).url).toBe('https://proxy.example.test/v1/chat/completions');
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
it('throws "No OpenCode login found for provider" when neither auth.json nor config apiKey exists', async () => {
|
|
137
|
-
readConfig.mockReturnValue({
|
|
138
|
-
provider: { custom: { options: { baseURL: 'https://proxy.example.test/v1' } } },
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
await expect(callSmallModel({
|
|
142
|
-
auth: {},
|
|
143
|
-
catalog: {},
|
|
144
|
-
workingDirectory: '/proj',
|
|
145
|
-
providerID: 'custom',
|
|
146
|
-
modelID: 'gpt-4o-mini',
|
|
147
|
-
prompt: 'hi',
|
|
148
|
-
})).rejects.toThrow('No OpenCode login found for provider "custom"');
|
|
149
|
-
|
|
150
|
-
// The credential gate fires before any network call.
|
|
151
|
-
expect(fetchMock).not.toHaveBeenCalled();
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
it('treats a blank/whitespace apiKey in config as absent', async () => {
|
|
155
|
-
readConfig.mockReturnValue({
|
|
156
|
-
provider: {
|
|
157
|
-
custom: { options: { apiKey: ' ', baseURL: 'https://proxy.example.test/v1' } },
|
|
158
|
-
},
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
await expect(callSmallModel({
|
|
162
|
-
auth: {},
|
|
163
|
-
catalog: {},
|
|
164
|
-
workingDirectory: '/proj',
|
|
165
|
-
providerID: 'custom',
|
|
166
|
-
modelID: 'gpt-4o-mini',
|
|
167
|
-
prompt: 'hi',
|
|
168
|
-
})).rejects.toThrow('No OpenCode login found for provider "custom"');
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
describe('resolution order when auth.json is also present', () => {
|
|
173
|
-
it('uses the auth.json credential with the config baseURL', async () => {
|
|
174
|
-
readConfig.mockReturnValue({
|
|
175
|
-
provider: { custom: { options: { baseURL: 'https://proxy.example.test/v1' } } },
|
|
176
|
-
});
|
|
177
|
-
fetchMock.mockResolvedValue(ok('done'));
|
|
178
|
-
|
|
179
|
-
const text = await callSmallModel({
|
|
180
|
-
auth: { custom: { type: 'api', key: 'authjson-key' } },
|
|
181
|
-
catalog: {},
|
|
182
|
-
workingDirectory: '/proj',
|
|
183
|
-
providerID: 'custom',
|
|
184
|
-
modelID: 'gpt-4o-mini',
|
|
185
|
-
prompt: 'hi',
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
expect(text).toBe('done');
|
|
189
|
-
const { url, init } = lastCall(fetchMock);
|
|
190
|
-
expect(url).toBe('https://proxy.example.test/v1/chat/completions');
|
|
191
|
-
expect(init.headers.Authorization).toBe('Bearer authjson-key');
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
it('prefers the config apiKey over an auth.json credential when both are present (matches OpenCode)', async () => {
|
|
195
|
-
readConfig.mockReturnValue({
|
|
196
|
-
provider: {
|
|
197
|
-
custom: { options: { apiKey: 'config-key', baseURL: 'https://proxy.example.test/v1' } },
|
|
198
|
-
},
|
|
199
|
-
});
|
|
200
|
-
fetchMock.mockResolvedValue(ok('done'));
|
|
201
|
-
|
|
202
|
-
await callSmallModel({
|
|
203
|
-
auth: { custom: { type: 'api', key: 'authjson-key' } },
|
|
204
|
-
catalog: {},
|
|
205
|
-
workingDirectory: '/proj',
|
|
206
|
-
providerID: 'custom',
|
|
207
|
-
modelID: 'gpt-4o-mini',
|
|
208
|
-
prompt: 'hi',
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
// OpenCode's resolveSDK reads options.apiKey first and only falls back to
|
|
212
|
-
// auth.json's key when config has none — so the config key wins and the
|
|
213
|
-
// auth.json credential must never be sent.
|
|
214
|
-
expect(lastCall(fetchMock).init.headers.Authorization).toBe('Bearer config-key');
|
|
215
|
-
expect(JSON.stringify(fetchMock.mock.calls[0][1])).not.toContain('authjson-key');
|
|
216
|
-
});
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
describe('openai provider custom baseURL override', () => {
|
|
220
|
-
it('respects provider.openai.options.baseURL over the hardcoded OpenAI endpoint', async () => {
|
|
221
|
-
readConfig.mockReturnValue({
|
|
222
|
-
provider: { openai: { options: { baseURL: 'https://gateway.example.test/v1' } } },
|
|
223
|
-
});
|
|
224
|
-
fetchMock.mockResolvedValue(ok('ok'));
|
|
225
|
-
|
|
226
|
-
await callSmallModel({
|
|
227
|
-
auth: { openai: { type: 'api', key: 'sk-openai' } },
|
|
228
|
-
catalog: {},
|
|
229
|
-
workingDirectory: '/proj',
|
|
230
|
-
providerID: 'openai',
|
|
231
|
-
modelID: 'gpt-4o-mini',
|
|
232
|
-
prompt: 'hi',
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
const { url, init } = lastCall(fetchMock);
|
|
236
|
-
expect(url).toBe('https://gateway.example.test/v1/chat/completions');
|
|
237
|
-
expect(url).not.toContain('api.openai.com');
|
|
238
|
-
expect(init.headers.Authorization).toBe('Bearer sk-openai');
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
it('falls back to https://api.openai.com/v1 when no openai baseURL override is configured', async () => {
|
|
242
|
-
readConfig.mockReturnValue({});
|
|
243
|
-
fetchMock.mockResolvedValue(ok('ok'));
|
|
244
|
-
|
|
245
|
-
await callSmallModel({
|
|
246
|
-
auth: { openai: { type: 'api', key: 'sk-openai' } },
|
|
247
|
-
catalog: {},
|
|
248
|
-
workingDirectory: '/proj',
|
|
249
|
-
providerID: 'openai',
|
|
250
|
-
modelID: 'gpt-4o-mini',
|
|
251
|
-
prompt: 'hi',
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
expect(lastCall(fetchMock).url).toBe('https://api.openai.com/v1/chat/completions');
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
it('still requires a credential: a baseURL alone does not authenticate openai', async () => {
|
|
258
|
-
readConfig.mockReturnValue({
|
|
259
|
-
provider: { openai: { options: { baseURL: 'https://gateway.example.test/v1' } } },
|
|
260
|
-
});
|
|
261
|
-
|
|
262
|
-
await expect(callSmallModel({
|
|
263
|
-
auth: {},
|
|
264
|
-
catalog: {},
|
|
265
|
-
workingDirectory: '/proj',
|
|
266
|
-
providerID: 'openai',
|
|
267
|
-
modelID: 'gpt-4o-mini',
|
|
268
|
-
prompt: 'hi',
|
|
269
|
-
})).rejects.toThrow('No OpenCode login found for provider "openai"');
|
|
270
|
-
});
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
describe('catalog-based base URL (no config override)', () => {
|
|
274
|
-
it('uses the model api.url from the catalog when no config baseURL is set', async () => {
|
|
275
|
-
readConfig.mockReturnValue({});
|
|
276
|
-
fetchMock.mockResolvedValue(ok('ok'));
|
|
277
|
-
|
|
278
|
-
await callSmallModel({
|
|
279
|
-
auth: { mistral: { type: 'api', key: 'mistral-key' } },
|
|
280
|
-
catalog: CATALOG,
|
|
281
|
-
workingDirectory: '/proj',
|
|
282
|
-
providerID: 'mistral',
|
|
283
|
-
modelID: 'mistral-small-latest',
|
|
284
|
-
prompt: 'hi',
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
const { url, init } = lastCall(fetchMock);
|
|
288
|
-
expect(url).toBe('https://api.mistral.ai/v1/chat/completions');
|
|
289
|
-
expect(init.headers.Authorization).toBe('Bearer mistral-key');
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
it('prefers config baseURL over model api.url', async () => {
|
|
293
|
-
readConfig.mockReturnValue({
|
|
294
|
-
provider: { mistral: { options: { baseURL: 'https://gateway.example.test/v1' } } },
|
|
295
|
-
});
|
|
296
|
-
fetchMock.mockResolvedValue(ok('ok'));
|
|
297
|
-
|
|
298
|
-
await callSmallModel({
|
|
299
|
-
auth: { mistral: { type: 'api', key: 'mistral-key' } },
|
|
300
|
-
catalog: CATALOG,
|
|
301
|
-
workingDirectory: '/proj',
|
|
302
|
-
providerID: 'mistral',
|
|
303
|
-
modelID: 'mistral-small-latest',
|
|
304
|
-
prompt: 'hi',
|
|
305
|
-
});
|
|
306
|
-
|
|
307
|
-
expect(lastCall(fetchMock).url).toBe('https://gateway.example.test/v1/chat/completions');
|
|
308
|
-
});
|
|
309
|
-
|
|
310
|
-
it('throws when a non-openai provider has no model api.url and no config baseURL', async () => {
|
|
311
|
-
readConfig.mockReturnValue({});
|
|
312
|
-
|
|
313
|
-
await expect(callSmallModel({
|
|
314
|
-
auth: { custom: { type: 'api', key: 'k' } },
|
|
315
|
-
catalog: {},
|
|
316
|
-
workingDirectory: '/proj',
|
|
317
|
-
providerID: 'custom',
|
|
318
|
-
modelID: 'gpt-4o-mini',
|
|
319
|
-
prompt: 'hi',
|
|
320
|
-
})).rejects.toThrow('Provider "custom" has no known API base URL');
|
|
321
|
-
});
|
|
322
|
-
});
|
|
323
|
-
|
|
324
|
-
describe('config-supplied key does not leak', () => {
|
|
325
|
-
// The config-supplied key must stay in-memory: never copied into catalog
|
|
326
|
-
// metadata, the response, or the request body.
|
|
327
|
-
it('does not mutate the catalog or echo the key in the request/response', async () => {
|
|
328
|
-
const catalog = { custom: { id: 'custom', models: {} } };
|
|
329
|
-
const catalogBefore = JSON.parse(JSON.stringify(catalog));
|
|
330
|
-
readConfig.mockReturnValue({
|
|
331
|
-
provider: {
|
|
332
|
-
custom: { options: { apiKey: 'test-key', baseURL: 'https://proxy.example.test/v1' } },
|
|
333
|
-
},
|
|
334
|
-
});
|
|
335
|
-
fetchMock.mockResolvedValue(ok('the answer'));
|
|
336
|
-
|
|
337
|
-
const text = await callSmallModel({
|
|
338
|
-
auth: {},
|
|
339
|
-
catalog,
|
|
340
|
-
workingDirectory: '/proj',
|
|
341
|
-
providerID: 'custom',
|
|
342
|
-
modelID: 'gpt-4o-mini',
|
|
343
|
-
prompt: 'hi',
|
|
344
|
-
});
|
|
345
|
-
|
|
346
|
-
// Response text is exactly the model output — no credential echoed back.
|
|
347
|
-
expect(text).toBe('the answer');
|
|
348
|
-
// Catalog object left untouched (key stays in-memory only).
|
|
349
|
-
expect(catalog).toEqual(catalogBefore);
|
|
350
|
-
|
|
351
|
-
const { url, init } = lastCall(fetchMock);
|
|
352
|
-
// The key rides only in the Authorization header.
|
|
353
|
-
expect(url).not.toContain('test-key');
|
|
354
|
-
const body = JSON.parse(init.body);
|
|
355
|
-
expect(JSON.stringify(body)).not.toContain('test-key');
|
|
356
|
-
});
|
|
357
|
-
});
|
|
358
|
-
|
|
359
|
-
describe('merged config layers', () => {
|
|
360
|
-
it('reads the provider config for the supplied working directory', async () => {
|
|
361
|
-
readConfig.mockReturnValue({
|
|
362
|
-
provider: {
|
|
363
|
-
custom: { options: { apiKey: 'test-key', baseURL: 'https://proxy.example.test/v1' } },
|
|
364
|
-
},
|
|
365
|
-
});
|
|
366
|
-
fetchMock.mockResolvedValue(ok('ok'));
|
|
367
|
-
|
|
368
|
-
await callSmallModel({
|
|
369
|
-
auth: {},
|
|
370
|
-
catalog: {},
|
|
371
|
-
workingDirectory: '/path/to/project',
|
|
372
|
-
providerID: 'custom',
|
|
373
|
-
modelID: 'gpt-4o-mini',
|
|
374
|
-
prompt: 'hi',
|
|
375
|
-
});
|
|
376
|
-
|
|
377
|
-
// readConfig merges global + project-scoped layers for this directory;
|
|
378
|
-
// confirm callSmallModel passes the working directory straight through.
|
|
379
|
-
expect(readConfig).toHaveBeenCalledWith('/path/to/project');
|
|
380
|
-
});
|
|
381
|
-
});
|
|
382
|
-
});
|