@yuriai/web 0.2.28 → 0.2.29-beta.11
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 +3 -1
- package/dist/assets/AgentAvatar-CR6dX_XT.js +1 -0
- package/dist/assets/AssistantContactStatus-B0bsfDtC.js +3 -0
- package/dist/assets/{AssistantUnreadBadge-DqThZdCe.js → AssistantUnreadBadge-D2z3wH6e.js} +1 -1
- package/dist/assets/{AssistantView-DPUDCXoY.js → AssistantView-1I_CxjRT.js} +1 -1
- package/dist/assets/{DiagramView-CHVLoYrV.js → DiagramView-CDnuxs05.js} +1 -1
- package/dist/assets/{FadeInOnReveal-Cj3JXYvE.js → FadeInOnReveal-CuOJu25b.js} +1 -1
- package/dist/assets/{GuiPluginSurface-CBZYeKHb.js → GuiPluginSurface-Fz1jDjmD.js} +1 -1
- package/dist/assets/{GuiPluginWindow-_Z5wycnH.js → GuiPluginWindow-CIVNyw4s.js} +1 -1
- package/dist/assets/Icon-BQczEnxm.js +1 -0
- package/dist/assets/{ImageLoadingPlaceholder-DjLaKB4o.js → ImageLoadingPlaceholder-KksxJaKp.js} +1 -1
- package/dist/assets/LoadingImage-Ch5MyA20.js +1 -0
- package/dist/assets/MarkdownRenderer-2h3s-QAX.js +2 -0
- package/dist/assets/{MarkdownRendererImpl-_plqOlsV.js → MarkdownRendererImpl-D-6DekL9.js} +3 -3
- package/dist/assets/MarkstreamRendererImpl-HnrHSasB.js +3 -0
- package/dist/assets/{MobileDetailNavigation-SeT764Ps.js → MobileDetailNavigation-D-Jwj-Fz.js} +1 -1
- package/dist/assets/{MobileResizableSheet-BY1-oo_E.js → MobileResizableSheet-Bk3z4g6T.js} +1 -1
- package/dist/assets/{MobileShareBridge-Dw8gLtJD.js → MobileShareBridge-BjNcovRh.js} +2 -2
- package/dist/assets/MobileTabPageHeader-o3h0Die1.js +2 -0
- package/dist/assets/MultiRunWindow-BHY_fvEe.js +1 -0
- package/dist/assets/{OnboardingScreen-CGqabMbp.js → OnboardingScreen-CgQGvlEs.js} +1 -1
- package/dist/assets/{OverlayScrollbar-AGSWQKg-.js → OverlayScrollbar-C9Ac564a.js} +1 -1
- package/dist/assets/SettingsView-BlOWs55G.js +29 -0
- package/dist/assets/SettingsWindow-EosRcZmc.js +1 -0
- package/dist/assets/SetupTourDialog-CUzqT2sw.css +1 -0
- package/dist/assets/SetupTourDialog-_DdUf4Np.js +1 -0
- package/dist/assets/{TerminalView-OHqpkHzz.js → TerminalView-BrTVmvyd.js} +3 -3
- package/dist/assets/ToolOutputDialog-DVVOJVDJ.js +10 -0
- package/dist/assets/VoiceSettings-C0HSdVvS.css +1 -0
- package/dist/assets/VoiceSettings-UNCCasqF.js +2 -0
- package/dist/assets/YuriLogo-CpccdHvS.js +1 -0
- package/dist/assets/YuriWordmark-hZ6K7Smk.js +1 -0
- package/dist/assets/{appThemeRegistry-9j-rCSlE.js → appThemeRegistry-B8qob2l9.js} +1 -1
- package/dist/assets/appearance--vFosLNi.js +1 -0
- package/dist/assets/{assistant-attachment-cache-B_qRvy-k.js → assistant-attachment-cache-oatc8F4t.js} +1 -1
- package/dist/assets/{button-Bjh2BSXh.js → button-Cjciq1yh.js} +1 -1
- package/dist/assets/{capgoAdapter-DERfot6h.js → capgoAdapter-YgVOiKZO.js} +1 -1
- package/dist/assets/collapsible-BzCn4-sd.js +1 -0
- package/dist/assets/context-menu-BIjCIXOg.js +1 -0
- package/dist/assets/desktopRelayRestore-C7pjf6fE.js +1 -0
- package/dist/assets/{device-BcRP6Tjd.js → device-DN1GigI_.js} +1 -1
- package/dist/assets/{diagram-CXVm2vzI.js → diagram--zTR0vWJ.js} +1 -1
- package/dist/assets/dialog-rVkj8VgE.js +1 -0
- package/dist/assets/dropdown-menu.styles-BDla58Rm.js +1 -0
- package/dist/assets/es-B8dNq0Lv.js +15 -0
- package/dist/assets/{fileMentionTouchSelection-B9NbPN9D.js → fileMentionTouchSelection-CmdNi_d0.js} +2 -2
- package/dist/assets/{fileQueries-BeXkd3o6.js → fileQueries-C2Rs6TPz.js} +1 -1
- package/dist/assets/{fileReferenceActions-CrIAce3K.js → fileReferenceActions-CvDFcgBH.js} +1 -1
- package/dist/assets/{fr-CIGqV46N.js → fr-DbzWoYOD.js} +4 -4
- package/dist/assets/{gitApi-CY3D5CF0.js → gitApi-CEtJm-Si.js} +3 -3
- package/dist/assets/{gitApiHttp-B7vYwgBh.js → gitApiHttp-Ddik7PM_.js} +4 -4
- package/dist/assets/host-D776RHTx.js +1 -0
- package/dist/assets/image-loading-DKQOYtti.js +1 -0
- package/dist/assets/input-GVRUiwuQ.js +1 -0
- package/dist/assets/insertionBoundaries-DQcca8Jd.js +1 -0
- package/dist/assets/{ja-DAhnTq6V.js → ja-BGk5BIrz.js} +4 -4
- package/dist/assets/{ko-FbMgNKcI.js → ko-Broo5A8H.js} +4 -4
- package/dist/assets/magpie-BuRvkGVQ.svg +1 -0
- package/dist/assets/main-BY3PGnZf.js +169 -0
- package/dist/assets/main-CMMAJcu3.js +2 -0
- package/dist/assets/{markdownHeightCache-DVWGXtAX.js → markdownHeightCache-C7UOJdkN.js} +1 -1
- package/dist/assets/{markdownTheme-hpURsgju.js → markdownTheme-CHNl6tUv.js} +1 -1
- package/dist/assets/{mcpQueries-CdOYmUdO.js → mcpQueries-Cb3fyXbV.js} +1 -1
- package/dist/assets/miniChat-Dez8HIZj.js +2 -0
- package/dist/assets/mobile-CE0hClMx.js +2 -0
- package/dist/assets/{mobileBackNavigation-CgZndzFA.js → mobileBackNavigation-HtKkSk0m.js} +1 -1
- package/dist/assets/multirun-CIbNS1L_.js +3 -0
- package/dist/assets/native-DsqzO52u.js +1 -0
- package/dist/assets/{native-config-BpsFKLGl.js → native-config-D-sxhX53.js} +1 -1
- package/dist/assets/persistence-D-rnhgr4.js +3 -0
- package/dist/assets/{pl-DzX0cbiQ.js → pl-not4wEra.js} +4 -4
- package/dist/assets/projectMeta-DMn_yra8.js +1 -0
- package/dist/assets/pt-BR-3OzFQDGv.js +15 -0
- package/dist/assets/pwa-CnptYkbA.js +2 -0
- package/dist/assets/{queryRuntime-CTcigFdj.js → queryRuntime-2dx7jbt9.js} +1 -1
- package/dist/assets/{queue-abort-optimistic-DCLBpirg.js → queue-abort-optimistic-CShE2znR.js} +1 -1
- package/dist/assets/{react-DRe85o5s.js → react-Bwr5-XPi.js} +1 -1
- package/dist/assets/readiness-gqLkYnM4.js +1 -0
- package/dist/assets/renderElectronMiniChatApp-CY9Z1Vhr.js +2 -0
- package/dist/assets/renderMobileApp-BCwgH2Gn.js +28 -0
- package/dist/assets/{runtime-file-download-Cf1WxfeW.js → runtime-file-download-D6bwc3Kj.js} +1 -1
- package/dist/assets/{runtime-file-resource-UJjHUF2C.js → runtime-file-resource-BP4P52ry.js} +1 -1
- package/dist/assets/{runtimeConfig-BBgkLVr_.js → runtimeConfig-BjAB7T92.js} +1 -1
- package/dist/assets/runtimeEndpointReset-b_8lxjHW.js +149 -0
- package/dist/assets/scheduledTaskNavigation-Bp5rGr3m.js +1 -0
- package/dist/assets/select-DeP9bukP.js +1 -0
- package/dist/assets/sessionLookup-CvwAHpsq.js +1 -0
- package/dist/assets/sortable-tabs-strip-BloEQRck.js +1 -0
- package/dist/assets/speechSettingsQueries-B-JHilmU.js +3 -0
- package/dist/assets/src-EZMbcCtg.css +2 -0
- package/dist/assets/{store-DVfZQktm.js → store-CKIMMlXR.js} +5 -4
- package/dist/assets/{terminalApi-rl9mZAlB.js → terminalApi-ChZhb60_.js} +1 -1
- package/dist/assets/{textarea-C6VQ7dHH.js → textarea-B4mWtnN5.js} +1 -1
- package/dist/assets/theme-validation-BGYdrOu7.js +1 -0
- package/dist/assets/themes-BgDJcxRc.js +1 -0
- package/dist/assets/tooltip-BuZ86ipm.js +1 -0
- package/dist/assets/{touch-gestures-K2_ZOkKW.js → touch-gestures-CErgaXZ7.js} +1 -1
- package/dist/assets/tour-Db44qwfs.js +1 -0
- package/dist/assets/types-B5Nt6TGt.js +2 -0
- package/dist/assets/uk-DyZ2SwUJ.js +15 -0
- package/dist/assets/{useAppFontEffects-CEgDiZHu.js → useAppFontEffects-CN6GxBsA.js} +43 -43
- package/dist/assets/{useAssistantUIStore-CfaQV3ID.js → useAssistantUIStore-BI_dAUjx.js} +1 -1
- package/dist/assets/useDesktopWindowControlsLayout-DtGw4mOb.js +1 -0
- package/dist/assets/{dropdown-menu.styles-M78xpvb2.js → useDictation-CwX05CAo.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-BOYMJ6k7.js → useEffectiveDirectory-BcjGq1gO.js} +1 -1
- package/dist/assets/{useFontPreferences-DeqW9nRx.js → useFontPreferences-EsJ4FlIp.js} +1 -1
- package/dist/assets/useMobileNavigationStore-CIldW1SJ.js +17 -0
- package/dist/assets/usePluginsStore-CBQx059k.js +1 -0
- package/dist/assets/{useThemeSystem-CGF5jnIh.js → useThemeSystem-CNzUUkFn.js} +1 -1
- package/dist/assets/useUIStore-CoWJ3ROq.js +1 -0
- package/dist/assets/{useWorkerHighlightedLines-EcJThS4x.js → useWorkerHighlightedLines-jLLdysNE.js} +1 -1
- package/dist/assets/vendor-base-ui-CzHs0bHY.js +1 -0
- package/dist/assets/{vendor-cmdk-C3oBVL9X.js → vendor-cmdk-C_tivUtr.js} +1 -1
- package/dist/assets/vendor-codemirror-autocomplete-C0FrlFqZ.js +12 -0
- package/dist/assets/vendor-codemirror-commands-5saeUOVY.js +1 -0
- package/dist/assets/vendor-codemirror-lang-angular-Cm7vBE3E.js +23 -0
- package/dist/assets/vendor-codemirror-lang-cpp-BjixvwC2.js +1 -0
- package/dist/assets/vendor-codemirror-lang-go-DFb2d_8t.js +11 -0
- package/dist/assets/vendor-codemirror-lang-java-CHitPigf.js +1 -0
- package/dist/assets/vendor-codemirror-lang-jinja-B8yrwpok.js +1 -0
- package/dist/assets/{vendor-codemirror-lang-json-mLulNbwB.js → vendor-codemirror-lang-json-DowyFczU.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-less-CNvptX3P.js → vendor-codemirror-lang-less-B1_0-sTl.js} +1 -1
- package/dist/assets/vendor-codemirror-lang-liquid-FIsA7YFN.js +1 -0
- package/dist/assets/vendor-codemirror-lang-markdown-npWBZIoE.js +6 -0
- package/dist/assets/vendor-codemirror-lang-php-wyEc0fdz.js +1 -0
- package/dist/assets/vendor-codemirror-lang-python-OPRdU26g.js +9 -0
- package/dist/assets/{vendor-codemirror-lang-rust-CtafR0gt.js → vendor-codemirror-lang-rust-DgovszuH.js} +1 -1
- package/dist/assets/vendor-codemirror-lang-sass-BdU-i07o.js +1 -0
- package/dist/assets/{vendor-codemirror-lang-sql-C6q09UUZ.js → vendor-codemirror-lang-sql-DUutq98l.js} +2 -2
- package/dist/assets/{vendor-codemirror-lang-vue-DIB78UsR.js → vendor-codemirror-lang-vue-CuRNbe8H.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-wast-C_JVdOCF.js → vendor-codemirror-lang-wast-CGFAOCoB.js} +1 -1
- package/dist/assets/vendor-codemirror-lang-xml-CMKBqGXF.js +1 -0
- package/dist/assets/{vendor-codemirror-lang-yaml-BO0hIfQM.js → vendor-codemirror-lang-yaml-CH9a1QiY.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-Ctd4WxgW.js → vendor-codemirror-language-data-B3pLWvv-.js} +2 -2
- package/dist/assets/vendor-codemirror-search-hZY-L2l8.js +2 -0
- package/dist/assets/{vendor-dnd-kit-accessibility-DxpFzZhi.js → vendor-dnd-kit-accessibility-BOtnpZt5.js} +1 -1
- package/dist/assets/{vendor-dnd-kit-core-B3g3zWQd.js → vendor-dnd-kit-core-DK4OoOTr.js} +1 -1
- package/dist/assets/{vendor-dnd-kit-sortable-BKewx0Py.js → vendor-dnd-kit-sortable-Cv69eQm1.js} +1 -1
- package/dist/assets/{vendor-framer-motion-C1twy-GF.js → vendor-framer-motion-DDMKlXiP.js} +1 -1
- package/dist/assets/vendor-lodash-es-BS45jPoZ.js +1 -0
- package/dist/assets/{vendor-markstream-react-BlbOg72y.js → vendor-markstream-react-DfLaSG3W.js} +3 -3
- package/dist/assets/vendor-motion-C9oiAdx-.js +1 -0
- package/dist/assets/{vendor-pierre-diffs-Bj9Nqn6w.js → vendor-pierre-diffs-BFiZ3IhI.js} +2 -2
- package/dist/assets/{vendor-react-D5d-V1vN.js → vendor-react-DlzBev0S.js} +1 -1
- package/dist/assets/{vendor-react-drawio-C-iPmmED.js → vendor-react-drawio-Dyg1-39Q.js} +1 -1
- package/dist/assets/vendor-reactuses-core-DWo5Wn6R.js +1 -0
- package/dist/assets/{vendor-replit-codemirror-vim-DCdAdxvE.js → vendor-replit-codemirror-vim-BmQmU1lR.js} +6 -6
- package/dist/assets/{vendor-sonner-r2EJnfoo.js → vendor-sonner-BEHGipm5.js} +1 -1
- package/dist/assets/{vendor-stream-diffs-BnLmeqg2.js → vendor-stream-diffs-wcQxoPZk.js} +2 -2
- package/dist/assets/vendor-tanstack-query-core-Y_YoRHtC.js +1 -0
- package/dist/assets/vendor-tanstack-react-query-B-Wpqq5J.js +1 -0
- package/dist/assets/{vendor-tanstack-react-virtual-BeZn51tF.js → vendor-tanstack-react-virtual-DSFNK3qc.js} +1 -1
- package/dist/assets/{vendor-zustand-B43HCgwC.js → vendor-zustand-vDaAPGfl.js} +1 -1
- package/dist/assets/zh-CN-aNIWxYun.js +15 -0
- package/dist/assets/zh-TW-B1IdCz5g.js +15 -0
- package/dist/index.html +20 -20
- package/dist/mini-chat.html +20 -20
- package/dist/mobile.html +20 -20
- package/package.json +5 -3
- package/server/lib/assistants/DOCUMENTATION.md +1 -1
- package/server/lib/assistants/contact-tools.js +1 -1
- package/server/lib/assistants/harness.js +3 -3
- package/server/lib/client-auth/pairing.js +4 -1
- package/server/lib/client-auth/pairing.test.js +41 -0
- package/server/lib/client-auth/remote-clients.js +6 -2
- package/server/lib/client-auth/remote-clients.test.js +42 -0
- package/server/lib/config-sync/DOCUMENTATION.md +1 -0
- package/server/lib/config-sync/config-sync.test.js +22 -0
- package/server/lib/config-sync/constants.js +0 -3
- package/server/lib/gui-customization/DOCUMENTATION.md +56 -0
- package/server/lib/gui-customization/session-skill.js +58 -0
- package/server/lib/gui-customization/session-skill.test.js +53 -0
- package/server/lib/gui-customization/skill/SKILL.md +38 -0
- package/server/lib/gui-customization/skill/references/appearance.md +79 -0
- package/server/lib/gui-customization/skill/references/file-previews.md +113 -0
- package/server/lib/gui-customization/skill/references/global-pages.md +81 -0
- package/server/lib/gui-customization/skill/references/gui-api.md +37 -0
- package/server/lib/gui-customization/skill/references/preview-exports.md +74 -0
- package/server/lib/gui-customization/skill/references/ui-surfaces.md +228 -0
- package/server/lib/gui-customization/skill/references/workflow.md +80 -0
- package/server/lib/llm/DOCUMENTATION.md +14 -1
- package/server/lib/llm/bridge-plugin.bundle.js +13 -1136
- package/server/lib/llm/bridge-plugin.js +4 -4
- package/server/lib/llm/bridge-plugin.test.js +31 -4
- package/server/lib/opencode/DOCUMENTATION.md +82 -1
- package/server/lib/opencode/config-entity-routes.js +2 -4
- package/server/lib/opencode/config-entity-routes.test.js +16 -13
- package/server/lib/opencode/core-routes.js +5 -2
- package/server/lib/opencode/core-routes.test.js +14 -4
- package/server/lib/opencode/custom-provider-models.d.ts +2 -0
- package/server/lib/opencode/custom-provider-models.js +71 -0
- package/server/lib/opencode/custom-provider-models.test.js +90 -0
- package/server/lib/opencode/custom-provider.d.ts +2 -0
- package/server/lib/opencode/custom-provider.js +107 -0
- package/server/lib/opencode/custom-provider.test.js +211 -0
- package/server/lib/opencode/feature-routes-runtime.js +5 -0
- package/server/lib/opencode/npm-registry.js +9 -2
- package/server/lib/opencode/npm-registry.test.js +22 -1
- package/server/lib/opencode/plugin-routes.js +1 -0
- package/server/lib/opencode/provider-catalog.js +14 -0
- package/server/lib/opencode/provider-catalog.test.js +15 -0
- package/server/lib/opencode/provider-configuration.test.js +64 -0
- package/server/lib/opencode/provider-model-config.d.ts +1 -0
- package/server/lib/opencode/provider-model-config.js +39 -0
- package/server/lib/opencode/provider-model-config.test.js +69 -0
- package/server/lib/opencode/provider-sources.d.ts +10 -0
- package/server/lib/opencode/provider-sources.js +52 -0
- package/server/lib/opencode/provider-sources.test.js +73 -0
- package/server/lib/opencode/providers.d.ts +5 -0
- package/server/lib/opencode/providers.js +28 -0
- package/server/lib/opencode/routes.js +50 -1
- package/server/lib/opencode/settings-helpers.js +0 -3
- package/server/lib/opencode/settings-helpers.test.js +8 -0
- package/server/lib/opencode/static-routes-runtime.js +5 -3
- package/server/lib/opencode/static-routes-runtime.test.js +23 -10
- package/server/lib/remote-desktop/DOCUMENTATION.md +10 -2
- package/server/lib/remote-desktop/runtime.js +3 -2
- package/server/lib/remote-desktop/runtime.test.js +20 -0
- package/server/lib/scheduled-tasks/session-skill.js +3 -0
- package/server/lib/scheduled-tasks/session-skill.test.js +4 -2
- package/server/lib/ui-auth/DOCUMENTATION.md +2 -0
- package/shared/custom-provider-protocol.d.ts +4 -0
- package/shared/custom-provider-protocol.js +32 -0
- package/dist/assets/AgentAvatar-BybF1ayP.js +0 -1
- package/dist/assets/AssistantContactStatus-BwpxTn0d.js +0 -3
- package/dist/assets/Icon-CeRMtJa8.js +0 -1
- package/dist/assets/LoadingImage-DG3otL5V.js +0 -1
- package/dist/assets/MarkdownRenderer-C8rv6z7p.js +0 -2
- package/dist/assets/MarkstreamRendererImpl-bs8HZ4Ra.js +0 -3
- package/dist/assets/MobileTabPageHeader-EsrOCLyg.js +0 -2
- package/dist/assets/MultiRunWindow-C-Qw_g7N.js +0 -1
- package/dist/assets/SettingsView-BLfFnnnX.js +0 -29
- package/dist/assets/SettingsView-BRIvklfP.css +0 -1
- package/dist/assets/SettingsWindow-lyYO8Byy.js +0 -1
- package/dist/assets/ToolOutputDialog-DU4Pb1s0.js +0 -10
- package/dist/assets/YuriLogo-Bb6yHagP.js +0 -1
- package/dist/assets/collapsible-BEAHoxNi.js +0 -1
- package/dist/assets/context-menu-BxLcot-3.js +0 -1
- package/dist/assets/desktopRelayRestore-D1UX7HW2.js +0 -1
- package/dist/assets/dialog-nshKUSE5.js +0 -1
- package/dist/assets/es-N9ZkQwG9.js +0 -15
- package/dist/assets/host-CnVx34Dh.js +0 -1
- package/dist/assets/image-loading-D6kOgU4w.js +0 -1
- package/dist/assets/input-3Re4pmHm.js +0 -1
- package/dist/assets/insertionBoundaries-DK7XYF8d.js +0 -1
- package/dist/assets/main-B_THXYMs.js +0 -2
- package/dist/assets/main-CpcudEZb.js +0 -169
- package/dist/assets/miniChat-DxZiTnAZ.js +0 -2
- package/dist/assets/mobile-BJuATiaC.js +0 -2
- package/dist/assets/multirun-BlaYsQi2.js +0 -3
- package/dist/assets/native-BYMhr-xH.js +0 -1
- package/dist/assets/persistence-CWuLIq1J.js +0 -3
- package/dist/assets/projectMeta-CnXHTolN.js +0 -1
- package/dist/assets/pt-BR-C5yvwyDK.js +0 -15
- package/dist/assets/readiness-U16Qor79.js +0 -1
- package/dist/assets/renderElectronMiniChatApp-n-nhgy1V.js +0 -2
- package/dist/assets/renderMobileApp-DBj_7RlD.js +0 -28
- package/dist/assets/runtimeEndpointReset-BvSQVFfx.js +0 -149
- package/dist/assets/scheduledTaskNavigation-EomDNVu2.js +0 -1
- package/dist/assets/sessionLookup-C_CCp7MJ.js +0 -1
- package/dist/assets/sortable-tabs-strip-p16Pn6Zz.js +0 -1
- package/dist/assets/speechSettingsQueries-CBSEAKyj.js +0 -4
- package/dist/assets/src-u-YDfCVw.css +0 -2
- package/dist/assets/tooltip-Dnc6GA-X.js +0 -1
- package/dist/assets/types-DnZw0gLD.js +0 -2
- package/dist/assets/uk-zbDcUpBy.js +0 -15
- package/dist/assets/useDesktopWindowControlsLayout-B2o4IFmd.js +0 -1
- package/dist/assets/useMobileNavigationStore-DlvrZQ49.js +0 -17
- package/dist/assets/useUIStore-C6CE42oh.js +0 -1
- package/dist/assets/vendor-base-ui-BQjbsJ43.js +0 -1
- package/dist/assets/vendor-codemirror-autocomplete-7c2L_4dM.js +0 -12
- package/dist/assets/vendor-codemirror-commands-B8KrBQ9B.js +0 -1
- package/dist/assets/vendor-codemirror-lang-angular-DXOgWEVj.js +0 -23
- package/dist/assets/vendor-codemirror-lang-cpp-Dh8C3xqP.js +0 -1
- package/dist/assets/vendor-codemirror-lang-go-BXAJ1_dh.js +0 -11
- package/dist/assets/vendor-codemirror-lang-java-DAyCHRhk.js +0 -1
- package/dist/assets/vendor-codemirror-lang-jinja-0TICrMfO.js +0 -1
- package/dist/assets/vendor-codemirror-lang-liquid-8g5seytq.js +0 -1
- package/dist/assets/vendor-codemirror-lang-markdown-CV1IO6Qs.js +0 -6
- package/dist/assets/vendor-codemirror-lang-php-xP7rf28_.js +0 -1
- package/dist/assets/vendor-codemirror-lang-python-YM2WVLHF.js +0 -9
- package/dist/assets/vendor-codemirror-lang-sass-B4iav_Ps.js +0 -1
- package/dist/assets/vendor-codemirror-lang-xml-DIuzY_d4.js +0 -1
- package/dist/assets/vendor-codemirror-search-DiPwvA-6.js +0 -2
- package/dist/assets/vendor-lodash-es-DfLbG5Af.js +0 -1
- package/dist/assets/vendor-motion-BmLx2V78.js +0 -1
- package/dist/assets/vendor-reactuses-core-BcebBLwF.js +0 -1
- package/dist/assets/vendor-tanstack-query-core-BWz0ose6.js +0 -1
- package/dist/assets/vendor-tanstack-react-query-C4SG3JZB.js +0 -1
- package/dist/assets/zh-CN-BHRJ7CF3.js +0 -15
- package/dist/assets/zh-TW-BFI_YFd-.js +0 -15
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { ConfigProvider } from '@opencode/schema/config/provider';
|
|
2
|
+
import { Schema } from 'effect';
|
|
3
|
+
import { currentClient } from './auth.js';
|
|
4
|
+
import { getConfigForPath, isPlainObject, readConfigLayers, writeConfig } from './config-files.js';
|
|
5
|
+
import { customProviderProtocols } from '../../../shared/custom-provider-protocol.js';
|
|
6
|
+
|
|
7
|
+
const packages = new Set(customProviderProtocols.map((protocol) => protocol.package));
|
|
8
|
+
const pending = new Set();
|
|
9
|
+
const failure = (code, status = 400) => Object.assign(new Error(code), { code, status });
|
|
10
|
+
|
|
11
|
+
function validate(input) {
|
|
12
|
+
if (!isPlainObject(input) || (input.providerId !== undefined && (typeof input.providerId !== 'string'
|
|
13
|
+
|| !/^custom-[a-z0-9-]{1,80}$/.test(input.providerId)))) throw failure('INVALID_PROVIDER');
|
|
14
|
+
let config;
|
|
15
|
+
try {
|
|
16
|
+
config = Schema.decodeUnknownSync(ConfigProvider.Info, { onExcessProperty: 'error' })(input.config);
|
|
17
|
+
} catch {
|
|
18
|
+
throw failure('INVALID_PROVIDER');
|
|
19
|
+
}
|
|
20
|
+
if (!config.name?.trim() || !packages.has(config.package)
|
|
21
|
+
|| !isPlainObject(config.settings) || Object.keys(config.settings).some((key) => key !== 'baseURL')
|
|
22
|
+
|| !isPlainObject(config.models) || !Object.keys(config.models).length
|
|
23
|
+
|| (input.apiKey !== undefined && typeof input.apiKey !== 'string')) throw failure('INVALID_PROVIDER');
|
|
24
|
+
try {
|
|
25
|
+
const url = new URL(config.settings.baseURL);
|
|
26
|
+
if (!['http:', 'https:'].includes(url.protocol) || url.username || url.password || url.search || url.hash) throw new Error();
|
|
27
|
+
} catch {
|
|
28
|
+
throw failure('INVALID_BASE_URL');
|
|
29
|
+
}
|
|
30
|
+
for (const [id, model] of Object.entries(config.models)) {
|
|
31
|
+
if (!id.trim() || /[\s#]/.test(id) || ['__proto__', 'constructor', 'prototype'].includes(id)
|
|
32
|
+
|| Object.keys(model).some((key) => !['name', 'capabilities', 'limit'].includes(key))
|
|
33
|
+
|| Object.values(model.limit ?? {}).some((value) => !Number.isSafeInteger(value) || value <= 0)
|
|
34
|
+
|| (model.limit?.context && model.limit?.output && model.limit.output > model.limit.context)) throw failure('INVALID_MODELS');
|
|
35
|
+
}
|
|
36
|
+
if (Object.keys(input.config).some((key) => !['name', 'package', 'settings', 'models'].includes(key))) throw failure('INVALID_PROVIDER');
|
|
37
|
+
return { providerId: input.providerId, config: input.config, apiKey: input.apiKey?.trim() };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function targetForCreation(providerId, directory) {
|
|
41
|
+
const layers = readConfigLayers(directory);
|
|
42
|
+
if (layers.documents.some(({ config }) => Object.hasOwn(config.providers ?? {}, providerId)
|
|
43
|
+
|| Object.hasOwn(config.provider ?? {}, providerId))) throw failure('PROVIDER_EXISTS', 409);
|
|
44
|
+
const path = layers.paths.customPath || layers.paths.userPath;
|
|
45
|
+
const config = getConfigForPath(layers, path);
|
|
46
|
+
if (config.providers !== undefined && !isPlainObject(config.providers)) throw failure('INVALID_PROVIDER_CONFIG');
|
|
47
|
+
return { path, config };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async function allocateProviderId(name, directory, client) {
|
|
51
|
+
const location = directory ? { directory } : undefined;
|
|
52
|
+
const [providers, integrations] = await Promise.all([
|
|
53
|
+
client.provider.list({ location }, { signal: AbortSignal.timeout(8000) }),
|
|
54
|
+
client.integration.list({ location }, { signal: AbortSignal.timeout(8000) }),
|
|
55
|
+
]);
|
|
56
|
+
if (!Array.isArray(providers.data) || !Array.isArray(integrations.data)) throw failure('PROVIDER_SAVE_FAILED', 502);
|
|
57
|
+
const layers = readConfigLayers(directory);
|
|
58
|
+
const used = new Set(['__proto__', 'constructor', 'prototype', ...pending,
|
|
59
|
+
...providers.data.map((entry) => entry.id), ...integrations.data.map((entry) => entry.id),
|
|
60
|
+
...layers.documents.flatMap(({ config }) => [...Object.keys(config.providers ?? {}), ...Object.keys(config.provider ?? {})]),
|
|
61
|
+
]);
|
|
62
|
+
const base = name.normalize('NFKC').trim().toLowerCase().replace(/[^\p{L}\p{N}]+/gu, '-').slice(0, 80).replace(/^-+|-+$/g, '') || 'custom-provider';
|
|
63
|
+
let id = base;
|
|
64
|
+
for (let suffix = 2; used.has(id); suffix++) id = `${base}-${suffix}`;
|
|
65
|
+
pending.add(id);
|
|
66
|
+
return id;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Keys only enter OpenCode's credential store; JSONC edits share the atomic config writer. */
|
|
70
|
+
export async function createCustomProvider(input, directory, client = currentClient()) {
|
|
71
|
+
const validated = validate(input);
|
|
72
|
+
const { config, apiKey } = validated;
|
|
73
|
+
const providerId = validated.providerId ?? await allocateProviderId(config.name, directory, client);
|
|
74
|
+
if (validated.providerId) {
|
|
75
|
+
if (pending.has(providerId)) throw failure('PROVIDER_EXISTS', 409);
|
|
76
|
+
pending.add(providerId);
|
|
77
|
+
}
|
|
78
|
+
let credentialID;
|
|
79
|
+
try {
|
|
80
|
+
targetForCreation(providerId, directory);
|
|
81
|
+
if (apiKey) {
|
|
82
|
+
try {
|
|
83
|
+
const credential = await client.credential.create({ integrationID: providerId, label: config.name,
|
|
84
|
+
value: { type: 'key', key: apiKey }, activate: true }, { signal: AbortSignal.timeout(15000) });
|
|
85
|
+
credentialID = credential.id;
|
|
86
|
+
} catch {
|
|
87
|
+
throw failure('PROVIDER_CREDENTIAL_FAILED', 502);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const target = targetForCreation(providerId, directory);
|
|
91
|
+
writeConfig({ ...target.config, $schema: target.config.$schema ?? 'https://opencode.ai/config.json',
|
|
92
|
+
providers: { ...target.config.providers, [providerId]: config } }, target.path);
|
|
93
|
+
return { providerId };
|
|
94
|
+
} catch (error) {
|
|
95
|
+
if (credentialID) {
|
|
96
|
+
try {
|
|
97
|
+
await client.credential.remove({ credentialID }, { signal: AbortSignal.timeout(15000) });
|
|
98
|
+
} catch {
|
|
99
|
+
throw failure('PROVIDER_CLEANUP_FAILED', 500);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (typeof error.status === 'number') throw error;
|
|
103
|
+
throw failure('PROVIDER_SAVE_FAILED', 500);
|
|
104
|
+
} finally {
|
|
105
|
+
pending.delete(providerId);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { Schema } from 'effect';
|
|
5
|
+
import { ConfigProvider } from '@opencode/schema/config/provider';
|
|
6
|
+
import { beforeEach, afterEach, describe, expect, it, vi } from 'vitest';
|
|
7
|
+
import { createCustomProvider } from './custom-provider.js';
|
|
8
|
+
import { readConfigFile } from './config-files.js';
|
|
9
|
+
import { configureOpenCodeCredentials } from './auth.js';
|
|
10
|
+
import { registerOpenCodeRoutes } from './routes.js';
|
|
11
|
+
import { registerCommonRequestMiddleware } from './core-routes.js';
|
|
12
|
+
import express from 'express';
|
|
13
|
+
import request from 'supertest';
|
|
14
|
+
|
|
15
|
+
let root;
|
|
16
|
+
let file;
|
|
17
|
+
let client;
|
|
18
|
+
const input = (pkg = '@opencode/ai/providers/openai-compatible') => ({
|
|
19
|
+
providerId: 'custom-fixture', apiKey: 'fixture-key',
|
|
20
|
+
config: { name: 'Gateway', package: pkg, settings: { baseURL: 'https://api.example.com/v1' },
|
|
21
|
+
models: { 'upstream/coder': { name: 'Coder', capabilities: { tools: true, input: ['text', 'image'], output: ['text'] }, limit: { context: 32768, output: 8192 } } } },
|
|
22
|
+
});
|
|
23
|
+
beforeEach(() => {
|
|
24
|
+
root = fs.mkdtempSync(path.join(os.tmpdir(), 'yuri-custom-provider-'));
|
|
25
|
+
vi.stubEnv('OPENCODE_CONFIG_DIR', root);
|
|
26
|
+
vi.stubEnv('OPENCODE_CONFIG', '');
|
|
27
|
+
file = path.join(root, 'opencode.jsonc');
|
|
28
|
+
client = { credential: { create: vi.fn().mockResolvedValue({ id: 'fixture-credential' }), remove: vi.fn().mockResolvedValue(undefined) } };
|
|
29
|
+
client.provider = { list: vi.fn().mockResolvedValue({ data: [] }) };
|
|
30
|
+
client.integration = { list: vi.fn().mockResolvedValue({ data: [] }) };
|
|
31
|
+
});
|
|
32
|
+
afterEach(() => { configureOpenCodeCredentials(null); vi.restoreAllMocks(); vi.unstubAllEnvs(); fs.rmSync(root, { recursive: true, force: true }); });
|
|
33
|
+
|
|
34
|
+
describe('custom provider native V2 persistence', () => {
|
|
35
|
+
it.each([
|
|
36
|
+
[' My Gateway ', 'my-gateway'],
|
|
37
|
+
['My__Gateway / Test', 'my-gateway-test'],
|
|
38
|
+
['我的 网关', '我的-网关'],
|
|
39
|
+
['!!!', 'custom-provider'],
|
|
40
|
+
['constructor', 'constructor-2'],
|
|
41
|
+
])('derives a lowercase hyphenated ID from %s', async (name, expectedId) => {
|
|
42
|
+
const draft = input(); delete draft.providerId; draft.config.name = name;
|
|
43
|
+
expect(await createCustomProvider(draft, root, client)).toEqual({ providerId: expectedId });
|
|
44
|
+
expect(readConfigFile(file).providers[expectedId]).toEqual(draft.config);
|
|
45
|
+
expect(client.credential.create).toHaveBeenCalledWith(expect.objectContaining({ integrationID: expectedId }), expect.anything());
|
|
46
|
+
expect(client.provider.list).toHaveBeenCalledWith({ location: { directory: root } }, expect.anything());
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('suffixes duplicate names without replacing saved, runtime or built-in integrations', async () => {
|
|
50
|
+
fs.writeFileSync(file, '{"providers":{"gateway-3":{"name":"Keep"}}}');
|
|
51
|
+
client.provider.list.mockResolvedValue({ data: [{ id: 'gateway' }] });
|
|
52
|
+
client.integration.list.mockResolvedValue({ data: [{ id: 'gateway-2' }] });
|
|
53
|
+
const draft = input(); delete draft.providerId;
|
|
54
|
+
expect(await createCustomProvider(draft, undefined, client)).toEqual({ providerId: 'gateway-4' });
|
|
55
|
+
expect(readConfigFile(file).providers['gateway-3']).toEqual({ name: 'Keep' });
|
|
56
|
+
expect(readConfigFile(file).providers['gateway-4']).toEqual(draft.config);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('reserves distinct name-based IDs for simultaneous creates', async () => {
|
|
60
|
+
const draft = input(); delete draft.providerId;
|
|
61
|
+
const results = await Promise.all([createCustomProvider(draft, undefined, client), createCustomProvider(draft, undefined, client)]);
|
|
62
|
+
expect(results.map((entry) => entry.providerId)).toEqual(['gateway', 'gateway-2']);
|
|
63
|
+
expect(Object.keys(readConfigFile(file).providers)).toEqual(['gateway', 'gateway-2']);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('does not create credentials or config when the ID inventory cannot be read', async () => {
|
|
67
|
+
const draft = input(); delete draft.providerId;
|
|
68
|
+
client.provider.list.mockRejectedValue(new Error('offline'));
|
|
69
|
+
await expect(createCustomProvider(draft, undefined, client)).rejects.toThrow();
|
|
70
|
+
expect(client.credential.create).not.toHaveBeenCalled();
|
|
71
|
+
expect(fs.existsSync(file)).toBe(false);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('parses draft discovery JSON through the common middleware without persisting credentials or config', async () => {
|
|
75
|
+
const fetch = vi.spyOn(globalThis, 'fetch').mockResolvedValue(new Response(JSON.stringify({ data: [{ id: 'coder', name: 'Coder' }] })));
|
|
76
|
+
const app = express(); registerCommonRequestMiddleware(app, { express });
|
|
77
|
+
registerOpenCodeRoutes(app, {});
|
|
78
|
+
const response = await request(app).post('/api/config/providers/custom/models').send({
|
|
79
|
+
package: '@opencode/ai/providers/openai-compatible', baseURL: 'https://api.example.com/v1', apiKey: 'fixture-key',
|
|
80
|
+
}).expect(200);
|
|
81
|
+
expect(response.body).toEqual({ models: [{ id: 'coder', name: 'Coder' }] });
|
|
82
|
+
expect(fetch.mock.calls[0][0].toString()).toBe('https://api.example.com/v1/models');
|
|
83
|
+
expect(fetch.mock.calls[0][1].headers.Authorization).toBe('Bearer fixture-key');
|
|
84
|
+
expect(JSON.stringify(response.body)).not.toContain('fixture-key');
|
|
85
|
+
expect(client.credential.create).not.toHaveBeenCalled(); expect(fs.existsSync(file)).toBe(false);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('exposes only the created provider ID through the authenticated host route and uses the captured directory', async () => {
|
|
89
|
+
configureOpenCodeCredentials(() => client);
|
|
90
|
+
const app = express(); registerCommonRequestMiddleware(app, { express });
|
|
91
|
+
const validateDirectoryPath = vi.fn().mockResolvedValue({ ok: true, directory: root });
|
|
92
|
+
registerOpenCodeRoutes(app, { validateDirectoryPath });
|
|
93
|
+
const response = await request(app).post('/api/config/providers/custom').send({ ...input(), directory: root }).expect(200);
|
|
94
|
+
expect(response.body).toEqual({ providerId: 'custom-fixture' });
|
|
95
|
+
expect(validateDirectoryPath).toHaveBeenCalledWith(root);
|
|
96
|
+
expect(JSON.stringify(response.body)).not.toContain('fixture-key');
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('does not write for an invalid requested directory', async () => {
|
|
100
|
+
configureOpenCodeCredentials(() => client);
|
|
101
|
+
const app = express(); registerCommonRequestMiddleware(app, { express });
|
|
102
|
+
registerOpenCodeRoutes(app, { validateDirectoryPath: async () => ({ ok: false }) });
|
|
103
|
+
await request(app).post('/api/config/providers/custom').send({ ...input(), directory: 'missing' }).expect(400);
|
|
104
|
+
expect(client.credential.create).not.toHaveBeenCalled(); expect(fs.existsSync(file)).toBe(false);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it.each([
|
|
108
|
+
'@opencode/ai/providers/openai-compatible', '@opencode/ai/providers/openai-compatible/responses',
|
|
109
|
+
'@opencode/ai/providers/anthropic-compatible', '@opencode/ai/providers/google',
|
|
110
|
+
])('round-trips %s through the official schema, preserving comments and unrelated config', async (pkg) => {
|
|
111
|
+
const original = '{ // keep this comment\n"model":"existing/coder","providers":{"existing":{"name":"Existing"}},}';
|
|
112
|
+
fs.writeFileSync(file, original);
|
|
113
|
+
expect(await createCustomProvider(input(pkg), undefined, client)).toEqual({ providerId: 'custom-fixture' });
|
|
114
|
+
const saved = readConfigFile(file);
|
|
115
|
+
expect(saved).toEqual({ $schema: 'https://opencode.ai/config.json', model: 'existing/coder',
|
|
116
|
+
providers: { existing: { name: 'Existing' }, 'custom-fixture': input(pkg).config } });
|
|
117
|
+
expect(() => Schema.decodeUnknownSync(ConfigProvider.Info)(saved.providers['custom-fixture'])).not.toThrow();
|
|
118
|
+
expect(fs.readFileSync(file, 'utf8')).toContain('// keep this comment');
|
|
119
|
+
expect(fs.readFileSync(file, 'utf8')).not.toContain('fixture-key');
|
|
120
|
+
expect(fs.readFileSync(`${file}.yuri.backup`, 'utf8')).toBe(original);
|
|
121
|
+
expect(client.credential.create).toHaveBeenCalledWith(expect.objectContaining({ integrationID: 'custom-fixture', value: { type: 'key', key: 'fixture-key' } }), expect.anything());
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it('supports keyless services and writes only the target document, not merged project settings', async () => {
|
|
125
|
+
fs.writeFileSync(path.join(root, 'opencode.json'), '{"model":"global/coder"}');
|
|
126
|
+
const project = path.join(root, 'project'); fs.mkdirSync(project);
|
|
127
|
+
fs.writeFileSync(path.join(project, 'opencode.json'), '{"instructions":["project.md"]}');
|
|
128
|
+
const request = input(); delete request.apiKey;
|
|
129
|
+
await createCustomProvider(request, project, client);
|
|
130
|
+
const saved = readConfigFile(path.join(root, 'opencode.json'));
|
|
131
|
+
expect(saved.model).toBe('global/coder'); expect(saved.instructions).toBeUndefined();
|
|
132
|
+
expect(saved.providers['custom-fixture']).toEqual(request.config);
|
|
133
|
+
expect(client.credential.create).not.toHaveBeenCalled();
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it('honors the explicit config path', async () => {
|
|
137
|
+
const custom = path.join(root, 'explicit.jsonc'); vi.stubEnv('OPENCODE_CONFIG', custom);
|
|
138
|
+
await createCustomProvider(input(), undefined, client);
|
|
139
|
+
expect(readConfigFile(custom).providers['custom-fixture']).toEqual(input().config);
|
|
140
|
+
expect(fs.existsSync(file)).toBe(false);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it('rejects duplicate providers before touching credentials or files', async () => {
|
|
144
|
+
fs.writeFileSync(file, '{"providers":{"custom-fixture":{"name":"Keep"}}}');
|
|
145
|
+
await expect(createCustomProvider(input(), undefined, client)).rejects.toMatchObject({ code: 'PROVIDER_EXISTS' });
|
|
146
|
+
expect(client.credential.create).not.toHaveBeenCalled();
|
|
147
|
+
expect(readConfigFile(file)).toEqual({ providers: { 'custom-fixture': { name: 'Keep' } } });
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it.each(['Gateway Two', 'Gateway One'])('keeps multiple providers independent even with the same endpoint and second name %s', async (secondName) => {
|
|
151
|
+
const first = input(); first.providerId = 'custom-first'; first.config.name = 'Gateway One';
|
|
152
|
+
const second = input(); second.providerId = 'custom-second'; second.config.name = secondName;
|
|
153
|
+
client.credential.create.mockImplementation(async ({ integrationID }) => ({ id: `credential-${integrationID}` }));
|
|
154
|
+
await Promise.all([
|
|
155
|
+
createCustomProvider(first, undefined, client),
|
|
156
|
+
createCustomProvider(second, undefined, client),
|
|
157
|
+
]);
|
|
158
|
+
const saved = readConfigFile(file);
|
|
159
|
+
expect(saved.providers).toEqual({ 'custom-first': first.config, 'custom-second': second.config });
|
|
160
|
+
expect(client.credential.create.mock.calls.map(([credential]) => ({ integrationID: credential.integrationID, label: credential.label })))
|
|
161
|
+
.toEqual([{ integrationID: 'custom-first', label: 'Gateway One' }, { integrationID: 'custom-second', label: secondName }]);
|
|
162
|
+
expect(client.credential.remove).not.toHaveBeenCalled();
|
|
163
|
+
expect(fs.readFileSync(file, 'utf8')).not.toContain('fixture-key');
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it.each([
|
|
167
|
+
(request) => { request.config.npm = '@ai-sdk/openai'; },
|
|
168
|
+
(request) => { request.config.settings.apiKey = 'do-not-write'; },
|
|
169
|
+
(request) => { request.config.settings.baseURL = 'https://user:password@example.com/v1'; },
|
|
170
|
+
(request) => { request.config.settings.baseURL = 'file:///example'; },
|
|
171
|
+
(request) => { request.config.models['upstream/coder'].limit.output = 999999; },
|
|
172
|
+
(request) => { request.config.models['upstream/coder'].limit.context = -1; },
|
|
173
|
+
(request) => { request.config.models = {}; },
|
|
174
|
+
(request) => { request.config.models['upstream/coder'].options = {}; },
|
|
175
|
+
(request) => { request.providerId = '__proto__'; },
|
|
176
|
+
(request) => { request.config.package = 'file:///untrusted.js'; },
|
|
177
|
+
])('rejects malformed/legacy/untrusted input without side effects (%#)', async (change) => {
|
|
178
|
+
const request = input(); change(request);
|
|
179
|
+
await expect(createCustomProvider(request, undefined, client)).rejects.toMatchObject({ status: 400 });
|
|
180
|
+
expect(client.credential.create).not.toHaveBeenCalled(); expect(fs.existsSync(file)).toBe(false);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it('does not replace malformed existing JSONC or persist a credential', async () => {
|
|
184
|
+
fs.writeFileSync(file, '{ broken');
|
|
185
|
+
await expect(createCustomProvider(input(), undefined, client)).rejects.toMatchObject({ code: 'PROVIDER_SAVE_FAILED' });
|
|
186
|
+
expect(fs.readFileSync(file, 'utf8')).toBe('{ broken'); expect(client.credential.create).not.toHaveBeenCalled();
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
it('keeps the original file on failed atomic replacement and rolls back only the new credential', async () => {
|
|
190
|
+
fs.writeFileSync(file, '{ // keep\n"model":"existing/coder"}');
|
|
191
|
+
const original = fs.readFileSync(file, 'utf8');
|
|
192
|
+
vi.spyOn(fs, 'renameSync').mockImplementation(() => { throw new Error('fixture IO error'); });
|
|
193
|
+
await expect(createCustomProvider(input(), undefined, client)).rejects.toMatchObject({ code: 'PROVIDER_SAVE_FAILED' });
|
|
194
|
+
expect(fs.readFileSync(file, 'utf8')).toBe(original);
|
|
195
|
+
expect(client.credential.remove).toHaveBeenCalledWith({ credentialID: 'fixture-credential' }, expect.anything());
|
|
196
|
+
expect(fs.readdirSync(root).some((name) => name.endsWith('.tmp'))).toBe(false);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it('sanitizes credential failures and never writes config after a failed credential save', async () => {
|
|
200
|
+
client.credential.create.mockRejectedValue(new Error('fixture-key in upstream body'));
|
|
201
|
+
const error = await createCustomProvider(input(), undefined, client).catch((error) => error);
|
|
202
|
+
expect(error.message).toBe('PROVIDER_CREDENTIAL_FAILED'); expect(fs.existsSync(file)).toBe(false);
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
it('reports a failed rollback explicitly', async () => {
|
|
206
|
+
vi.spyOn(fs, 'renameSync').mockImplementation(() => { throw new Error('fixture IO error'); });
|
|
207
|
+
client.credential.remove.mockRejectedValue(new Error('fixture cleanup error'));
|
|
208
|
+
await expect(createCustomProvider(input(), undefined, client)).rejects.toMatchObject({ code: 'PROVIDER_CLEANUP_FAILED' });
|
|
209
|
+
expect(fs.existsSync(file)).toBe(false);
|
|
210
|
+
});
|
|
211
|
+
});
|
|
@@ -16,6 +16,7 @@ import { registerProjectIconRoutes } from './project-icon-routes.js';
|
|
|
16
16
|
import { registerScheduledTaskRoutes } from '../scheduled-tasks/routes.js';
|
|
17
17
|
import { registerScheduledTaskToolRoute } from '../scheduled-tasks/managed-tool-route.js';
|
|
18
18
|
import { registerScheduledTaskSessionSkill } from '../scheduled-tasks/session-skill.js';
|
|
19
|
+
import { registerCustomizationSessionSkill } from '../gui-customization/session-skill.js';
|
|
19
20
|
import { registerConversationRoutes } from '../conversations/routes.js';
|
|
20
21
|
import { registerSessionTurnPageRoutes } from '../session-turn-pages/routes.js';
|
|
21
22
|
import { registerAssistantRoutes } from '../assistants/routes.js';
|
|
@@ -247,6 +248,10 @@ export const createFeatureRoutesRuntime = (dependencies) => {
|
|
|
247
248
|
readSettingsFromDiskMigrated, sanitizeProjects, validateDirectoryPath,
|
|
248
249
|
scheduledTaskRouter,
|
|
249
250
|
});
|
|
251
|
+
registerCustomizationSessionSkill(app, {
|
|
252
|
+
express, yuriDataDir, getIsSharedOpenCodeService, getIsExternalOpenCode, waitForOpenCodeReady,
|
|
253
|
+
createClient: () => makeOpenCodeV2Client({ baseUrl: buildOpenCodeUrl('/', ''), authHeaders: getOpenCodeAuthHeaders(), getRuntimeContract }),
|
|
254
|
+
});
|
|
250
255
|
app.use(scheduledTaskRouter);
|
|
251
256
|
|
|
252
257
|
registerScheduledTaskToolRoute(app, {
|
|
@@ -17,6 +17,8 @@ const NPM_REGISTRY_BASE = 'https://registry.npmjs.org';
|
|
|
17
17
|
* @property {string[]} versions
|
|
18
18
|
* @property {Record<string, string>} distTags
|
|
19
19
|
* @property {string} [icon] sanitized top-level package.json `icon` of the latest release
|
|
20
|
+
* @property {string} [description] developer-provided latest package description
|
|
21
|
+
* @property {string} [readme] developer-provided README, bounded to 128 KiB characters
|
|
20
22
|
*
|
|
21
23
|
* @typedef {Object} NpmLookupError
|
|
22
24
|
* @property {false} ok
|
|
@@ -104,7 +106,7 @@ function lookupViaNpmCli(name, cwd) {
|
|
|
104
106
|
return new Promise((resolve) => {
|
|
105
107
|
execFile(
|
|
106
108
|
process.platform === 'win32' ? 'npm.cmd' : 'npm',
|
|
107
|
-
['view', name, 'dist-tags', 'versions', 'icon', '--json'],
|
|
109
|
+
['view', name, 'dist-tags', 'versions', 'icon', 'description', 'readme', '--json'],
|
|
108
110
|
{
|
|
109
111
|
cwd: cwd || undefined,
|
|
110
112
|
timeout: NPM_CLI_TIMEOUT_MS,
|
|
@@ -129,7 +131,10 @@ function lookupViaNpmCli(name, cwd) {
|
|
|
129
131
|
? data.versions.filter((version) => typeof version === 'string')
|
|
130
132
|
: typeof data?.versions === 'string' ? [data.versions] : [];
|
|
131
133
|
const icon = sanitizePluginIcon(data?.icon);
|
|
132
|
-
resolve({ ok: true, latest: distTags.latest ?? null, versions, distTags, ...(icon ? { icon } : {})
|
|
134
|
+
resolve({ ok: true, latest: distTags.latest ?? null, versions, distTags, ...(icon ? { icon } : {}),
|
|
135
|
+
...(typeof data.description === 'string' ? { description: data.description.slice(0, 4096) } : {}),
|
|
136
|
+
...(typeof data.readme === 'string' ? { readme: data.readme.slice(0, 131072) } : {}),
|
|
137
|
+
});
|
|
133
138
|
} catch {
|
|
134
139
|
resolve(null);
|
|
135
140
|
}
|
|
@@ -182,6 +187,8 @@ async function lookupNpmPackageOverHttp(name) {
|
|
|
182
187
|
versions: parseVersions(data?.versions),
|
|
183
188
|
distTags,
|
|
184
189
|
...(icon ? { icon } : {}),
|
|
190
|
+
...(typeof data?.versions?.[latest]?.description === 'string' ? { description: data.versions[latest].description.slice(0, 4096) } : {}),
|
|
191
|
+
...(typeof data.readme === 'string' ? { readme: data.readme.slice(0, 131072) } : {}),
|
|
185
192
|
};
|
|
186
193
|
}
|
|
187
194
|
|
|
@@ -92,6 +92,27 @@ describe('npm registry client', () => {
|
|
|
92
92
|
expect(result).toEqual({ ok: true, latest: null, versions: [], distTags: {} });
|
|
93
93
|
});
|
|
94
94
|
|
|
95
|
+
test('exposes bounded developer description and README from HTTP and npm CLI without substituting content', async () => {
|
|
96
|
+
const description = 'Developer description';
|
|
97
|
+
const readme = '# Developer README\n\nInstallation and usage.';
|
|
98
|
+
fetchMock.mockImplementation(() => jsonResponse({
|
|
99
|
+
'dist-tags': { latest: '1.2.0' }, versions: { '1.2.0': { description } }, readme,
|
|
100
|
+
}));
|
|
101
|
+
expect(await npm.lookupNpmPackage('tour-plugin')).toMatchObject({ description, readme });
|
|
102
|
+
npm.npmCli.lookup = originalCliLookup;
|
|
103
|
+
execFileMock.mockImplementation((_command, _args, _options, callback) => callback(null, JSON.stringify({
|
|
104
|
+
'dist-tags': { latest: '1.2.0' }, versions: ['1.2.0'], description, readme,
|
|
105
|
+
}), ''));
|
|
106
|
+
expect(await npm.lookupNpmPackage('tour-plugin')).toMatchObject({ description, readme });
|
|
107
|
+
npm.npmCli.lookup = async () => null;
|
|
108
|
+
fetchMock.mockImplementation(() => jsonResponse({
|
|
109
|
+
'dist-tags': { latest: '1.2.0' }, versions: { '1.2.0': { description: 'x'.repeat(5000) } }, readme: 'y'.repeat(150000),
|
|
110
|
+
}));
|
|
111
|
+
const bounded = await npm.lookupNpmPackage('large-plugin');
|
|
112
|
+
expect(bounded.description).toHaveLength(4096);
|
|
113
|
+
expect(bounded.readme).toHaveLength(131072);
|
|
114
|
+
});
|
|
115
|
+
|
|
95
116
|
test('404 returns package not found', async () => {
|
|
96
117
|
fetchMock.mockImplementation(() => jsonResponse({}, 404));
|
|
97
118
|
|
|
@@ -228,7 +249,7 @@ describe('npm registry client', () => {
|
|
|
228
249
|
const result = await npm.getNpmInfo('@scope/pkg', { cwd: '/proj' });
|
|
229
250
|
|
|
230
251
|
expect(result.icon).toBe('https://cdn.example/a.png');
|
|
231
|
-
expect(execFileMock).toHaveBeenCalledWith(expect.any(String), ['view', '@scope/pkg', 'dist-tags', 'versions', 'icon', '--json'],
|
|
252
|
+
expect(execFileMock).toHaveBeenCalledWith(expect.any(String), ['view', '@scope/pkg', 'dist-tags', 'versions', 'icon', 'description', 'readme', '--json'],
|
|
232
253
|
expect.objectContaining({ cwd: '/proj' }), expect.any(Function));
|
|
233
254
|
expect(fetchMock).not.toHaveBeenCalled();
|
|
234
255
|
});
|
|
@@ -214,6 +214,7 @@ export const registerPluginRoutes = (app, dependencies) => {
|
|
|
214
214
|
versions: info.versions,
|
|
215
215
|
hasUpdate: currentVersion !== null && isExactSemver(currentVersion) && currentVersion !== info.latest,
|
|
216
216
|
...(info.icon ? { icon: info.icon } : {}),
|
|
217
|
+
...(req.query.details === 'true' ? { description: info.description ?? '', readme: info.readme ?? '' } : {}),
|
|
217
218
|
});
|
|
218
219
|
}
|
|
219
220
|
|
|
@@ -72,6 +72,9 @@ const projectCapabilities = (source) => {
|
|
|
72
72
|
const capabilities = createDictionary();
|
|
73
73
|
const flags = projectBooleanFields(source, ['temperature', 'reasoning', 'attachment', 'toolcall']);
|
|
74
74
|
if (flags) Object.assign(capabilities, flags);
|
|
75
|
+
if (isRecord(source.reasoning) && typeof source.reasoning.supported === 'boolean') {
|
|
76
|
+
capabilities.reasoning = source.reasoning.supported;
|
|
77
|
+
}
|
|
75
78
|
// v2 names tool support `tools`. Keep an explicit catalog `toolcall` flag when both exist.
|
|
76
79
|
if (!Object.hasOwn(capabilities, 'toolcall') && typeof source.tools === 'boolean') {
|
|
77
80
|
capabilities.toolcall = source.tools;
|
|
@@ -138,6 +141,17 @@ function projectModel(source) {
|
|
|
138
141
|
const capabilities = projectCapabilities(source.capabilities);
|
|
139
142
|
if (capabilities) model.capabilities = capabilities;
|
|
140
143
|
}
|
|
144
|
+
if (model.capabilities?.reasoning === undefined) {
|
|
145
|
+
const variants = Array.isArray(source.variants) ? source.variants : isRecord(source.variants) ? Object.values(source.variants) : [];
|
|
146
|
+
const supportsReasoning = variants.some((variant) => {
|
|
147
|
+
if (!isRecord(variant?.settings)) return false;
|
|
148
|
+
const settings = variant.settings;
|
|
149
|
+
return (typeof settings.reasoningEffort === 'string' && ['minimal', 'low', 'medium', 'high', 'xhigh', 'max'].includes(settings.reasoningEffort))
|
|
150
|
+
|| settings.thinking?.type === 'enabled' || settings.thinking?.type === 'adaptive'
|
|
151
|
+
|| (typeof settings.thinkingConfig?.thinkingBudget === 'number' && settings.thinkingConfig.thinkingBudget > 0);
|
|
152
|
+
});
|
|
153
|
+
if (supportsReasoning) model.capabilities = { ...model.capabilities, reasoning: true };
|
|
154
|
+
}
|
|
141
155
|
if (Object.hasOwn(source, 'cost')) {
|
|
142
156
|
const cost = projectCost(source.cost);
|
|
143
157
|
if (cost) model.cost = cost;
|
|
@@ -182,6 +182,20 @@ describe('projectProviderCatalog', () => {
|
|
|
182
182
|
});
|
|
183
183
|
});
|
|
184
184
|
|
|
185
|
+
it('projects V2 image input and explicit reasoning controls instead of obsolete attachment flags', () => {
|
|
186
|
+
const catalog = safeCatalog();
|
|
187
|
+
catalog.providers[0].models = {
|
|
188
|
+
vision: { id: 'vision', name: 'Vision', capabilities: { tools: true, input: ['text', 'image'], output: ['text'], reasoning: { supported: true } } },
|
|
189
|
+
reasoner: { id: 'reasoner', name: 'Reasoner', capabilities: { tools: true, input: ['text'], output: ['text'] }, variants: [{ id: 'high', settings: { reasoningEffort: 'high', apiKey: 'never-project' } }] },
|
|
190
|
+
text: { id: 'text', name: 'Text', capabilities: { input: ['text', 'pdf'], output: ['text'], attachment: true, reasoning: { supported: false } }, variants: [{ id: 'large', settings: { maxTokens: 8000 } }] },
|
|
191
|
+
};
|
|
192
|
+
const result = projectProviderCatalog(catalog);
|
|
193
|
+
expect(result.value.providers[0].models.vision.capabilities).toMatchObject({ input: { image: true }, reasoning: true });
|
|
194
|
+
expect(result.value.providers[0].models.reasoner.capabilities).toMatchObject({ reasoning: true });
|
|
195
|
+
expect(result.value.providers[0].models.text.capabilities).toMatchObject({ reasoning: false });
|
|
196
|
+
expect(JSON.stringify(result)).not.toContain('never-project');
|
|
197
|
+
});
|
|
198
|
+
|
|
185
199
|
it('bounds provider, model, and variant dictionaries while retaining their valid prefixes', () => {
|
|
186
200
|
const model = (id) => ({ id, name: id });
|
|
187
201
|
const providers = Array.from({ length: 201 }, (_, index) => ({
|
|
@@ -243,6 +257,7 @@ describe('projectProviderCatalog', () => {
|
|
|
243
257
|
name: 'GPT 5',
|
|
244
258
|
capabilities: {
|
|
245
259
|
toolcall: true,
|
|
260
|
+
reasoning: true,
|
|
246
261
|
input: { text: true, image: true },
|
|
247
262
|
output: { text: true },
|
|
248
263
|
},
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
5
|
+
import express from 'express';
|
|
6
|
+
import request from 'supertest';
|
|
7
|
+
import { removeProviderConfiguration } from './providers.js';
|
|
8
|
+
import { readConfigFile } from './config-files.js';
|
|
9
|
+
import { registerOpenCodeRoutes } from './routes.js';
|
|
10
|
+
|
|
11
|
+
let root;
|
|
12
|
+
let project;
|
|
13
|
+
let files;
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
root = fs.mkdtempSync(path.join(os.tmpdir(), 'yuri-provider-delete-'));
|
|
16
|
+
project = path.join(root, 'project'); fs.mkdirSync(project);
|
|
17
|
+
const global = path.join(root, 'config'); fs.mkdirSync(global);
|
|
18
|
+
files = [path.join(global, 'opencode.json'), path.join(global, 'opencode.jsonc'), path.join(root, 'explicit.jsonc'), path.join(project, 'opencode.jsonc')];
|
|
19
|
+
vi.stubEnv('OPENCODE_CONFIG_DIR', global); vi.stubEnv('OPENCODE_CONFIG', files[2]);
|
|
20
|
+
files.forEach((file, index) => fs.writeFileSync(file, `{ // keep unrelated comment\n"${index % 2 ? 'providers' : 'provider'}":{"target":{"name":"Target"},"keep":{}},"model":"keep/model"}`));
|
|
21
|
+
});
|
|
22
|
+
afterEach(() => { vi.restoreAllMocks(); vi.unstubAllEnvs(); fs.rmSync(root, { recursive: true, force: true }); });
|
|
23
|
+
|
|
24
|
+
describe('provider configuration deletion', () => {
|
|
25
|
+
it('removes every physical occurrence in both spellings, preserves unrelated values/comments, and supports retry', () => {
|
|
26
|
+
expect(removeProviderConfiguration('target', project)).toBe(true);
|
|
27
|
+
files.forEach((file, index) => {
|
|
28
|
+
expect(readConfigFile(file)).toEqual({ [index % 2 ? 'providers' : 'provider']: { keep: {} }, model: 'keep/model' });
|
|
29
|
+
expect(fs.readFileSync(file, 'utf8')).toContain('// keep unrelated comment');
|
|
30
|
+
expect(fs.readFileSync(`${file}.yuri.backup`, 'utf8')).toContain('Target');
|
|
31
|
+
});
|
|
32
|
+
expect(removeProviderConfiguration('target', project)).toBe(false);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('leaves a failed document intact and completes partial deletion on retry', () => {
|
|
36
|
+
const rename = fs.renameSync.bind(fs);
|
|
37
|
+
const failedPath = fs.realpathSync(files[1]);
|
|
38
|
+
const failure = vi.spyOn(fs, 'renameSync').mockImplementation((from, to) => {
|
|
39
|
+
if (to === failedPath) throw new Error('write failed');
|
|
40
|
+
return rename(from, to);
|
|
41
|
+
});
|
|
42
|
+
expect(() => removeProviderConfiguration('target', project)).toThrow('write failed');
|
|
43
|
+
expect(readConfigFile(files[0]).provider.target).toBeUndefined();
|
|
44
|
+
expect(readConfigFile(files[1]).providers.target).toBeDefined();
|
|
45
|
+
failure.mockRestore();
|
|
46
|
+
expect(removeProviderConfiguration('target', project)).toBe(true);
|
|
47
|
+
expect(files.every((file) => !JSON.stringify(readConfigFile(file)).includes('Target'))).toBe(true);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('fails before any write when one input file is malformed', () => {
|
|
51
|
+
fs.writeFileSync(files[3], '{broken');
|
|
52
|
+
expect(() => removeProviderConfiguration('target', project)).toThrow();
|
|
53
|
+
expect(readConfigFile(files[0]).provider.target).toBeDefined();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('exposes config-only deletion without service reload or credential side effects', async () => {
|
|
57
|
+
const app = express(); const reload = vi.fn();
|
|
58
|
+
registerOpenCodeRoutes(app, { resolveProjectDirectory: async () => ({ directory: project }), refreshOpenCodeAfterConfigChange: reload });
|
|
59
|
+
const response = await request(app).delete('/api/provider/target/auth').query({ scope: 'config', directory: project }).expect(200);
|
|
60
|
+
expect(response.body).toEqual({ success: true, removed: true, requiresReload: false });
|
|
61
|
+
expect(reload).not.toHaveBeenCalled();
|
|
62
|
+
expect(removeProviderConfiguration('target', project)).toBe(false);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function updateProviderModel(input: unknown, directory?: string): { providerId: string; modelId: string };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ConfigProvider } from '@opencode/schema/config/provider';
|
|
2
|
+
import { Schema } from 'effect';
|
|
3
|
+
import { getJsonEntrySource, getJsonWriteTarget, isPlainObject, readConfigLayers, writeConfig } from './config-files.js';
|
|
4
|
+
|
|
5
|
+
const invalid = () => Object.assign(new Error('INVALID_MODEL'), { status: 400 });
|
|
6
|
+
const validId = (value) => typeof value === 'string' && value.length > 0 && value.length <= 512
|
|
7
|
+
&& !/[\s#]/.test(value) && !['__proto__', 'constructor', 'prototype'].includes(value);
|
|
8
|
+
|
|
9
|
+
/** Only model presentation/capabilities are editable; credentials and routing remain host-owned. */
|
|
10
|
+
export function updateProviderModel(input, directory) {
|
|
11
|
+
if (!isPlainObject(input) || !validId(input.providerId) || !validId(input.modelId)
|
|
12
|
+
|| typeof input.name !== 'string' || input.name.length > 1024
|
|
13
|
+
|| typeof input.tools !== 'boolean' || typeof input.vision !== 'boolean'
|
|
14
|
+
|| !Array.isArray(input.inputModalities) || input.inputModalities.some((value) => !['text', 'image', 'audio', 'video', 'pdf'].includes(value))
|
|
15
|
+
|| [input.context, input.output].some((value) => value !== null && (!Number.isSafeInteger(value) || value <= 0))
|
|
16
|
+
|| (input.context && input.output && input.output > input.context)) throw invalid();
|
|
17
|
+
const layers = readConfigLayers(directory);
|
|
18
|
+
const source = getJsonEntrySource(layers, 'providers', input.providerId);
|
|
19
|
+
const target = source.exists ? source : getJsonWriteTarget(layers);
|
|
20
|
+
const provider = target.config.providers?.[input.providerId] ?? {};
|
|
21
|
+
const existing = provider.models?.[input.modelId] ?? {};
|
|
22
|
+
if (!isPlainObject(provider) || !isPlainObject(existing)
|
|
23
|
+
|| (provider.models !== undefined && !isPlainObject(provider.models))) throw invalid();
|
|
24
|
+
const limit = { ...existing.limit };
|
|
25
|
+
for (const key of ['context', 'output']) {
|
|
26
|
+
if (input[key] === null) delete limit[key];
|
|
27
|
+
else limit[key] = input[key];
|
|
28
|
+
}
|
|
29
|
+
const inheritedInput = layers.mergedConfig.providers?.[input.providerId]?.models?.[input.modelId]?.capabilities?.input;
|
|
30
|
+
const modalities = (Array.isArray(inheritedInput) ? inheritedInput : input.inputModalities).filter((value) => value !== 'image');
|
|
31
|
+
const model = { ...existing, name: input.name.trim() || input.modelId, limit,
|
|
32
|
+
capabilities: { ...existing.capabilities, tools: input.tools,
|
|
33
|
+
input: input.vision ? [...modalities, 'image'] : modalities } };
|
|
34
|
+
try { Schema.decodeUnknownSync(ConfigProvider.Info)({ models: { [input.modelId]: model } }); }
|
|
35
|
+
catch { throw invalid(); }
|
|
36
|
+
writeConfig({ ...target.config, providers: { ...target.config.providers,
|
|
37
|
+
[input.providerId]: { ...provider, models: { ...provider.models, [input.modelId]: model } } } }, target.path);
|
|
38
|
+
return { providerId: input.providerId, modelId: input.modelId };
|
|
39
|
+
}
|