@yuriai/web 0.2.40-beta.4 → 0.2.40-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AgentAvatar-BmT_6apW.js → AgentAvatar-XDXiFZvA.js} +1 -1
- package/dist/assets/AssistantConversationSurface-B59k-lXE.css +1 -0
- package/dist/assets/AssistantConversationSurface-CQnJaKTn.js +3 -0
- package/dist/assets/AssistantSessionCard-DXY8-wyP.js +2 -0
- package/dist/assets/{AssistantUnreadBadge-C34eOGCL.js → AssistantUnreadBadge-B-G015yE.js} +1 -1
- package/dist/assets/{AssistantView-0nXkM9VG.js → AssistantView-CasyQbii.js} +1 -1
- package/dist/assets/DiagramView-DhWnsM9v.js +1 -0
- package/dist/assets/{FadeInOnReveal-CCVdl9Vt.js → FadeInOnReveal-Ca9EVP3a.js} +1 -1
- package/dist/assets/{GuiPluginPage-BMt5AMqg.js → GuiPluginPage-DKOsUpVL.js} +1 -1
- package/dist/assets/GuiPluginSurface-BfXMBqdD.js +1 -0
- package/dist/assets/{GuiPluginWindow-BVvzrnp1.js → GuiPluginWindow-Dmg2Qui6.js} +1 -1
- package/dist/assets/{Icon-B5nBc6dO.js → Icon-ChyA050P.js} +1 -1
- package/dist/assets/{ImageLoadingPlaceholder-Bv5mmf2U.js → ImageLoadingPlaceholder-C8QUF5aV.js} +1 -1
- package/dist/assets/LoadingImage-BxRq1dMQ.js +1 -0
- package/dist/assets/MarkdownRenderer-CvWLikEO.js +2 -0
- package/dist/assets/MarkdownRendererImpl-CcNsQOEn.js +10 -0
- package/dist/assets/MarkstreamRendererImpl-D9W5XXPo.js +3 -0
- package/dist/assets/MobileDetailNavigation-CnwIZn5g.js +1 -0
- package/dist/assets/{MobileResizableSheet-D5PcZMuI.js → MobileResizableSheet-Bpp079l7.js} +1 -1
- package/dist/assets/MobileShareBridge-C-GpJfF6.js +3 -0
- package/dist/assets/MobileSurface-CrNI8cYQ.js +2 -0
- package/dist/assets/{MultiRunWindow-rMqP99ID.js → MultiRunWindow-DvywQkz9.js} +1 -1
- package/dist/assets/OnboardingScreen-BvueSxVk.js +1 -0
- package/dist/assets/{OverlayScrollbar-Byx2H3pc.js → OverlayScrollbar-CPaH_j8g.js} +1 -1
- package/dist/assets/RemoteAssistantSessionCard-CFWE00xD.js +1 -0
- package/dist/assets/SettingsView-Df6GCFPI.js +29 -0
- package/dist/assets/{SettingsWindow-U-RDDOS7.js → SettingsWindow-BpaRjeR-.js} +1 -1
- package/dist/assets/SetupTourDialog-DD_4qiTz.js +1 -0
- package/dist/assets/TerminalView-CRTtNAfA.js +8 -0
- package/dist/assets/ToolOutputDialog-omGmWntf.js +16 -0
- package/dist/assets/VoiceSettings-Du-Yd5MF.js +2 -0
- package/dist/assets/{YuriLogo-B58GIl2v.js → YuriLogo-CvyJy_R9.js} +1 -1
- package/dist/assets/YuriWordmark-B7lmpLRB.js +1 -0
- package/dist/assets/{assistant-attachment-cache-Cmzt4xXE.js → assistant-attachment-cache-D-LmCflm.js} +1 -1
- package/dist/assets/bootstrap-eLlfzqAI.js +1 -0
- package/dist/assets/{capgoAdapter-B5NImlKh.js → capgoAdapter-CqMX4zC-.js} +1 -1
- package/dist/assets/{checkbox-Bdj4n5cI.js → checkbox-KNAgqjPZ.js} +1 -1
- package/dist/assets/client-1Fk5IbQR.js +7 -0
- package/dist/assets/{collapsible-D1JZOgJZ.js → collapsible-CdiLY07j.js} +1 -1
- package/dist/assets/{context-menu-DDX0ZFhc.js → context-menu-CO_VRWeV.js} +1 -1
- package/dist/assets/{desktopHosts-DovfbQPm.js → desktopHosts-135cuRCE.js} +1 -1
- package/dist/assets/{desktopRelayRestore-D4pbpNKN.js → desktopRelayRestore-1aUztDPU.js} +1 -1
- package/dist/assets/{device-DNG0cNwQ.js → device-QL8KNSLM.js} +1 -1
- package/dist/assets/{diagram-C72TQWfh.js → diagram-9b-Aaful.js} +1 -1
- package/dist/assets/{dialog-CIKJalI5.js → dialog-8YYmYPFP.js} +1 -1
- package/dist/assets/{es-D0Q_CV0t.js → es-Ba3NUCtE.js} +3 -3
- package/dist/assets/{fileMentionTouchSelection-tnd9RDDh.js → fileMentionTouchSelection-CLQBqWR8.js} +1 -1
- package/dist/assets/fileReferenceActions-cYqdsXFz.js +1 -0
- package/dist/assets/{fr-DrO5SAKl.js → fr-CRhp3hyT.js} +3 -3
- package/dist/assets/{gitApi-BI8OG_ts.js → gitApi-uhoLUa-e.js} +11 -7
- package/dist/assets/gitApiHttp-B0FJaIhU.js +3 -0
- package/dist/assets/{gui-DN2sVP96.js → gui-BMN3-WPc.js} +1 -1
- package/dist/assets/historyImportQueries-D_9RlrLp.js +1 -0
- package/dist/assets/host-D9EDWNmx.js +1 -0
- package/dist/assets/{i18n-UaLestuf.js → i18n-RH7UieOS.js} +1 -1
- package/dist/assets/image-loading-DBqnxgDH.js +1 -0
- package/dist/assets/{input-gVHSS0EB.js → input-DK8VTvJw.js} +1 -1
- package/dist/assets/input-store-CsY-uaSj.js +1 -0
- package/dist/assets/insertionBoundaries-rYqUxuB-.js +1 -0
- package/dist/assets/{ja-BNeP9_GU.js → ja-D-UPjDY2.js} +3 -3
- package/dist/assets/{ko-DRRFD_7l.js → ko-x-z9J5z7.js} +3 -3
- package/dist/assets/main-BMx-2MjO.js +169 -0
- package/dist/assets/main-DzqojuZ1.js +2 -0
- package/dist/assets/{markdownHeightCache-B-FoaQ1U.js → markdownHeightCache-DAvnT6xF.js} +1 -1
- package/dist/assets/{markdownTheme-CHNl6tUv.js → markdownTheme-DFDWa8Gh.js} +1 -1
- package/dist/assets/mcpQueries-CpH8vPf1.js +1 -0
- package/dist/assets/miniChat-BTE_XpRk.js +2 -0
- package/dist/assets/mobile-BBZOulQ1.js +2 -0
- package/dist/assets/mobileBackNavigation-Cq08UPxZ.js +1 -0
- package/dist/assets/mobileConnections-ZehAozpe.js +2 -0
- package/dist/assets/multirun-Cll2Meol.js +3 -0
- package/dist/assets/{native-DsqzO52u.js → native-CDqNKjmz.js} +1 -1
- package/dist/assets/{native-config-DqDXViVx.js → native-config-DtUZFauV.js} +1 -1
- package/dist/assets/navigation-J3d8PQcs.js +2 -0
- package/dist/assets/openRemoteProjectSession-oJZpCDPT.js +1 -0
- package/dist/assets/{pl-BnW5wJrl.js → pl-Cqo1FJwM.js} +3 -3
- package/dist/assets/platform-wF65ZFgV.js +1 -0
- package/dist/assets/project-preview-2H-TmJkd.js +1 -0
- package/dist/assets/projectActions-50e_f9dI.js +1 -0
- package/dist/assets/projectMeta-BBpfOmij.js +1 -0
- package/dist/assets/prompt-attachment-upload-9fjmgafL.js +1 -0
- package/dist/assets/{pt-BR-fZW8CCVQ.js → pt-BR-C930XU1k.js} +3 -3
- package/dist/assets/pwa-C8B1Mf_t.js +2 -0
- package/dist/assets/queue-abort-optimistic-B1Uskf6F.js +1 -0
- package/dist/assets/{react-DeB-Vc_L.js → react-45rBMaUm.js} +1 -1
- package/dist/assets/{readiness-CIlvQ-aQ.js → readiness-CrjBrUa_.js} +2 -2
- package/dist/assets/reference-history-DqfMBWzF.js +1 -0
- package/dist/assets/relay-preview-frame-src-BPyz3nXA.js +1 -0
- package/dist/assets/remote-input-store-84i8uDyM.js +1 -0
- package/dist/assets/remoteProjectQueries-B6lrEDMq.js +1 -0
- package/dist/assets/remoteSessionReference-YiGvdabX.js +1 -0
- package/dist/assets/renderElectronMiniChatApp-BuHQB0V8.js +2 -0
- package/dist/assets/renderMobileApp-D_VswCi0.js +29 -0
- package/dist/assets/{runtime-file-download-DMY1k1af.js → runtime-file-download-D11Nnedg.js} +1 -1
- package/dist/assets/runtime-file-resource-CuLP3xp7.js +6 -0
- package/dist/assets/runtimeConfig-CMbNyYbK.js +2 -0
- package/dist/assets/{runtimeEndpointReset-BOdd_mJM.css → runtimeEndpointReset-BUGfn7y0.css} +1 -1
- package/dist/assets/runtimeEndpointReset-zo-HZQgX.js +151 -0
- package/dist/assets/safeStorage-DTOhKN0V.js +1 -0
- package/dist/assets/scheduledTaskNavigation-y5g8D2ee.js +1 -0
- package/dist/assets/{select-BwCKwnTH.js → select-VWoGVTBZ.js} +1 -1
- package/dist/assets/sessionLookup-JAf5UU7-.js +1 -0
- package/dist/assets/sortable-tabs-strip-Dbt3TTAs.js +1 -0
- package/dist/assets/{speechSettingsQueries-C5mPRWIv.js → speechSettingsQueries-Bidfcv0W.js} +1 -1
- package/dist/assets/src-BZCFf9_1.css +2 -0
- package/dist/assets/{store-CzVMz42v.js → store-DunGyOfe.js} +4 -4
- package/dist/assets/terminalApi-Cq0vjFe1.js +1 -0
- package/dist/assets/{textarea-CaTDyZrS.js → textarea-vyMsAV5p.js} +1 -1
- package/dist/assets/{tooltip-BvZzoiqg.js → tooltip-DWqHWi4N.js} +1 -1
- package/dist/assets/tour-CQMBn8gJ.js +1 -0
- package/dist/assets/{types-Bm8kDgSv.js → types-DeOkRCgE.js} +1 -1
- package/dist/assets/{uk-C4OKsNRv.js → uk-OXQSdzuT.js} +3 -3
- package/dist/assets/useAppFontEffects-K31q-1OV.css +1 -0
- package/dist/assets/{useAppFontEffects-C9IaiJgF.js → useAppFontEffects-z382Lhm_.js} +63 -58
- package/dist/assets/useAssistantUIStore-jOKVcBK8.js +1 -0
- package/dist/assets/useDesktopWindowControlsLayout-BEs7i5qj.js +1 -0
- package/dist/assets/{useDictation-Sk20Gi0T.js → useDictation-e68rFA6y.js} +1 -1
- package/dist/assets/useEffectiveDirectory-CcM3S1OQ.js +1 -0
- package/dist/assets/useFontPreferences-CO-L-Gd7.js +1 -0
- package/dist/assets/{useMobileHtmlPreviewStore-C03uVLfX.js → useMobileHtmlPreviewStore-EOAzZiAy.js} +1 -1
- package/dist/assets/useMobileNavigationStore-BA0IaUi_.js +13 -0
- package/dist/assets/usePluginsStore-BG5MW5LR.js +1 -0
- package/dist/assets/useProjectRuntimeAPIs-Be4gXG7P.js +1 -0
- package/dist/assets/{useStreamingTextThrottle-CeKHHK13.js → useStreamingTextThrottle-DylP9HFC.js} +1 -1
- package/dist/assets/{useThemeSystem-CNzUUkFn.js → useThemeSystem-C57Z9mV2.js} +1 -1
- package/dist/assets/useUIStore-Cfmg-aDQ.js +1 -0
- package/dist/assets/uuid-D-SDZijH.js +1 -0
- package/dist/assets/{vendor-base-ui-CzHs0bHY.js → vendor-base-ui-z2M4boRm.js} +1 -1
- package/dist/assets/{vendor-cmdk-C_tivUtr.js → vendor-cmdk-BgHvMv5l.js} +1 -1
- package/dist/assets/{vendor-dnd-kit-accessibility-BOtnpZt5.js → vendor-dnd-kit-accessibility-gVi9ga0x.js} +1 -1
- package/dist/assets/{vendor-dnd-kit-core-DK4OoOTr.js → vendor-dnd-kit-core-Dd5yS2-T.js} +1 -1
- package/dist/assets/{vendor-dnd-kit-sortable-Cv69eQm1.js → vendor-dnd-kit-sortable-CV-SGi8y.js} +1 -1
- package/dist/assets/{vendor-framer-motion-DDMKlXiP.js → vendor-framer-motion-CF9BQLta.js} +1 -1
- package/dist/assets/{vendor-markstream-react-6zxyQLCD.js → vendor-markstream-react-TwEpkgfP.js} +3 -3
- package/dist/assets/vendor-motion-Dv27UnOI.js +1 -0
- package/dist/assets/{vendor-opencode-client-cQ47ywrT.js → vendor-opencode-client-BM2r1f0o.js} +3 -3
- package/dist/assets/{vendor-opencode-plugin-BmdTE4Te.js → vendor-opencode-plugin-ZhpPgHCL.js} +1 -1
- package/dist/assets/{vendor-pierre-diffs-BFiZ3IhI.js → vendor-pierre-diffs-tqo4Z3TC.js} +1 -1
- package/dist/assets/{vendor-react-DlzBev0S.js → vendor-react-P8wFrkcT.js} +1 -1
- package/dist/assets/{vendor-react-drawio-Dyg1-39Q.js → vendor-react-drawio-CQW1YP2l.js} +1 -1
- package/dist/assets/vendor-reactuses-core-Dyjw5sZR.js +1 -0
- package/dist/assets/{vendor-solid-js-D98iXT7C.js → vendor-solid-js-BBVUd3Hw.js} +1 -1
- package/dist/assets/{vendor-sonner-BEHGipm5.js → vendor-sonner-B5HgJenP.js} +1 -1
- package/dist/assets/{vendor-stream-diffs-wcQxoPZk.js → vendor-stream-diffs-DCMtZcS3.js} +2 -2
- package/dist/assets/vendor-tanstack-query-core-BSjXNgF_.js +1 -0
- package/dist/assets/vendor-tanstack-react-query-B-KblYBV.js +1 -0
- package/dist/assets/{vendor-tanstack-react-virtual-DSFNK3qc.js → vendor-tanstack-react-virtual-BkuqzrEV.js} +1 -1
- package/dist/assets/{vendor-zustand-vDaAPGfl.js → vendor-zustand-Cwko4FG1.js} +1 -1
- package/dist/assets/{zh-CN-ieAs59w6.js → zh-CN-B5X8yCZV.js} +3 -3
- package/dist/assets/{zh-TW-WWTW1fkP.js → zh-TW-CF6zr1fk.js} +3 -3
- package/dist/index.html +32 -27
- package/dist/mini-chat.html +32 -27
- package/dist/mobile.html +2 -2
- package/package.json +3 -2
- package/server/index.d.ts +19 -0
- package/server/index.js +36 -5
- package/server/lib/assistants/DOCUMENTATION.md +87 -0
- package/server/lib/assistants/assign.js +10 -7
- package/server/lib/assistants/builtin-skills.js +1 -0
- package/server/lib/assistants/builtin-skills.test.js +1 -1
- package/server/lib/assistants/cards.js +6 -1
- package/server/lib/assistants/contact-store.js +22 -5
- package/server/lib/assistants/contact-tools.js +46 -26
- package/server/lib/assistants/execution-target.js +136 -0
- package/server/lib/assistants/opencode-tools.js +22 -9
- package/server/lib/assistants/remote-execution.test.js +378 -0
- package/server/lib/assistants/remote-watch-reconciler.js +43 -0
- package/server/lib/assistants/remote-watch-reconciler.test.js +88 -0
- package/server/lib/assistants/routes.js +1 -0
- package/server/lib/assistants/service.js +302 -99
- package/server/lib/assistants/yuri-project.http.test.js +2 -2
- package/server/lib/client-auth/remote-clients.js +11 -0
- package/server/lib/content-search/DOCUMENTATION.md +5 -0
- package/server/lib/content-search/routes.js +4 -0
- package/server/lib/content-search/routes.test.js +10 -0
- package/server/lib/event-stream/DOCUMENTATION.md +5 -0
- package/server/lib/event-stream/runtime.js +3 -0
- package/server/lib/event-stream/upstream-reader.js +1 -1
- package/server/lib/gui-customization/DOCUMENTATION.md +8 -2
- package/server/lib/gui-customization/projects-client.mjs +10 -8
- package/server/lib/gui-customization/projects-remote.js +101 -0
- package/server/lib/gui-customization/projects-remote.test.js +125 -0
- package/server/lib/gui-customization/projects.js +30 -6
- package/server/lib/gui-customization/projects.test.js +66 -1
- package/server/lib/gui-customization/session-skill.js +2 -2
- package/server/lib/gui-customization/session-skill.test.js +4 -0
- package/server/lib/gui-customization/skill/SKILL.md +3 -1
- package/server/lib/gui-customization/skill/references/projects.md +30 -3
- package/server/lib/gui-customization/skill/references/remote-connections.md +13 -0
- package/server/lib/message-queue/DOCUMENTATION.md +4 -0
- package/server/lib/message-queue/service.js +2 -1
- package/server/lib/message-queue/service.test.js +11 -0
- package/server/lib/notifications/emitter-runtime.js +5 -0
- package/server/lib/opencode/DOCUMENTATION.md +34 -0
- package/server/lib/opencode/core-routes.js +14 -2
- package/server/lib/opencode/core-routes.test.js +28 -0
- package/server/lib/opencode/feature-routes-runtime.js +8 -1
- package/server/lib/opencode/proxy.js +1 -0
- package/server/lib/opencode/routes.js +18 -4
- package/server/lib/opencode/routes.test.js +22 -0
- package/server/lib/opencode/settings-helpers.js +26 -0
- package/server/lib/opencode/settings-helpers.test.js +20 -0
- package/server/lib/opencode/settings-runtime.js +5 -3
- package/server/lib/opencode/settings-runtime.test.js +35 -0
- package/server/lib/opencode/v2-client.js +9 -4
- package/server/lib/preview/DOCUMENTATION.md +73 -0
- package/server/lib/preview/file-preview-path.js +37 -0
- package/server/lib/preview/file-target.js +38 -0
- package/server/lib/preview/file-target.test.js +111 -0
- package/server/lib/preview/proxy-runtime.js +110 -17
- package/server/lib/projects/DOCUMENTATION.md +6 -0
- package/server/lib/relay/tunnel-host.js +1 -0
- package/server/lib/remote-hosts/DOCUMENTATION.md +321 -0
- package/server/lib/remote-hosts/configuration.js +15 -0
- package/server/lib/remote-hosts/deadline.js +22 -0
- package/server/lib/remote-hosts/deadline.test.js +64 -0
- package/server/lib/remote-hosts/fixtures/settings-server.mjs +26 -0
- package/server/lib/remote-hosts/gateway.js +744 -0
- package/server/lib/remote-hosts/json-lifecycle.test.js +90 -0
- package/server/lib/remote-hosts/preview-scope.js +23 -0
- package/server/lib/remote-hosts/relay-client.ts +3 -0
- package/server/lib/remote-hosts/routes.js +429 -0
- package/server/lib/remote-hosts/routes.test.js +1427 -0
- package/server/lib/remote-hosts/settings-production.test.js +145 -0
- package/server/lib/remote-hosts/store.js +124 -0
- package/server/lib/remote-hosts/store.test.js +52 -0
- package/server/lib/remote-hosts/task-client.js +25 -0
- package/server/lib/remote-hosts/task-client.test.js +60 -0
- package/server/lib/remote-hosts/transport.js +118 -0
- package/server/lib/request-cors.js +1 -1
- package/server/lib/request-cors.test.js +1 -0
- package/server/lib/scheduled-tasks/session-skill.test.js +33 -2
- package/server/lib/session-folders/routes.js +1 -0
- package/server/lib/transcript-cache/DOCUMENTATION.md +4 -0
- package/server/lib/transcript-cache/routes.js +3 -0
- package/server/lib/transcript-cache/service.js +15 -0
- package/server/lib/transcript-cache/service.test.js +13 -0
- package/server/lib/ui-auth/DOCUMENTATION.md +18 -0
- package/server/lib/ui-auth/ui-auth.js +30 -2
- package/server/lib/ui-auth/ui-auth.test.js +46 -1
- package/dist/assets/AssistantConversationSurface-B-D-mLgs.js +0 -3
- package/dist/assets/AssistantConversationSurface-n9w_Av0k.css +0 -1
- package/dist/assets/DiagramView-BU6jWxKJ.js +0 -1
- package/dist/assets/GuiPluginSurface-kxAcgmf1.js +0 -1
- package/dist/assets/LoadingImage-BzBw_1lI.js +0 -1
- package/dist/assets/MarkdownRenderer-CoMohPOZ.js +0 -2
- package/dist/assets/MarkdownRendererImpl-DoZW1UKH.js +0 -10
- package/dist/assets/MarkstreamRendererImpl-B3zd5x2O.js +0 -3
- package/dist/assets/MobileDetailNavigation-bEZ_NA03.js +0 -1
- package/dist/assets/MobileShareBridge-Cjukxazk.js +0 -3
- package/dist/assets/MobileTabPageHeader-Da1maXx-.js +0 -2
- package/dist/assets/OnboardingScreen-CZhqHzAj.js +0 -1
- package/dist/assets/SettingsView-7Bea2DvF.js +0 -29
- package/dist/assets/SetupTourDialog-CKec5tUy.js +0 -1
- package/dist/assets/TerminalView-CS1oSAuY.js +0 -8
- package/dist/assets/ToolOutputDialog-BWhrFvvI.js +0 -10
- package/dist/assets/VoiceSettings-7aFmJq9Z.js +0 -2
- package/dist/assets/YuriWordmark--S-QEpRp.js +0 -1
- package/dist/assets/appThemeRegistry-LyWTE-mT.js +0 -1
- package/dist/assets/bootstrap-BhC95qVC.js +0 -1
- package/dist/assets/fileQueries-D9l0crnM.js +0 -1
- package/dist/assets/fileReferenceActions-BmquJskG.js +0 -1
- package/dist/assets/gitApiHttp-D4d-rgcR.js +0 -9
- package/dist/assets/historyImportQueries-DkB2_92i.js +0 -1
- package/dist/assets/host-kMLXU0hK.js +0 -1
- package/dist/assets/image-loading-BrDob6MW.js +0 -1
- package/dist/assets/insertionBoundaries-B-yZI6iY.js +0 -1
- package/dist/assets/main-BfAN93rT.js +0 -169
- package/dist/assets/main-DYWwmI_W.js +0 -2
- package/dist/assets/mcpQueries-CehWHIB1.js +0 -1
- package/dist/assets/miniChat-BlkcLQBr.js +0 -2
- package/dist/assets/mobile-I3Xe5NtO.js +0 -2
- package/dist/assets/mobileBackNavigation-BFUH-c-G.js +0 -1
- package/dist/assets/mobileConnections-BFvtbJXX.js +0 -2
- package/dist/assets/multirun-DdEjp77z.js +0 -3
- package/dist/assets/pathNormalization-ewtPqJWn.js +0 -1
- package/dist/assets/platform-DMsFWy1a.js +0 -1
- package/dist/assets/projectActions-C-9Z8R7y.js +0 -1
- package/dist/assets/projectMeta-BKgum5WN.js +0 -1
- package/dist/assets/pwa-BvKUY4Hk.js +0 -2
- package/dist/assets/queue-abort-optimistic-BcbiNk8t.js +0 -1
- package/dist/assets/renderElectronMiniChatApp-DIjWdFHu.js +0 -2
- package/dist/assets/renderMobileApp-CE0QyOH0.js +0 -29
- package/dist/assets/runtime-file-resource-CL7EVzOG.js +0 -2
- package/dist/assets/runtimeConfig-uhjQn4kK.js +0 -2
- package/dist/assets/runtimeEndpointReset-DezNESKT.js +0 -149
- package/dist/assets/scheduledTaskNavigation-FMDNRUnX.js +0 -1
- package/dist/assets/sessionLookup-DzKZsy-W.js +0 -1
- package/dist/assets/sortable-tabs-strip-m5JQrTx4.js +0 -1
- package/dist/assets/src-HgtAe3Q4.css +0 -2
- package/dist/assets/terminalApi-DK4KmfFn.js +0 -1
- package/dist/assets/touch-gestures-CErgaXZ7.js +0 -1
- package/dist/assets/tour-DDI0Zg7l.js +0 -1
- package/dist/assets/useAppFontEffects-RpgNbjA4.css +0 -1
- package/dist/assets/useAssistantUIStore-nNYL140o.js +0 -1
- package/dist/assets/useDesktopWindowControlsLayout-C3M12PjJ.js +0 -1
- package/dist/assets/useEffectiveDirectory-Do4UqfZR.js +0 -1
- package/dist/assets/useFontPreferences-DxzruDDQ.js +0 -1
- package/dist/assets/useMobileNavigationStore-InwdmuDX.js +0 -17
- package/dist/assets/usePluginsStore-BH4-CNcj.js +0 -1
- package/dist/assets/useUIStore-vvNwcOk3.js +0 -1
- package/dist/assets/useWorkerHighlightedLines-0XahwAbS.js +0 -7
- package/dist/assets/vendor-motion-C9oiAdx-.js +0 -1
- package/dist/assets/vendor-reactuses-core-CuTmqEMK.js +0 -1
- package/dist/assets/vendor-tanstack-query-core-Y_YoRHtC.js +0 -1
- package/dist/assets/vendor-tanstack-react-query-B-Wpqq5J.js +0 -1
- /package/dist/assets/{sessionLookup-8C8nv-EP.css → reference-history-8C8nv-EP.css} +0 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { afterEach, expect, it, vi } from 'vitest';
|
|
2
|
+
import fs from 'node:fs/promises';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { createRemoteHostGateway } from './gateway.js';
|
|
6
|
+
import { createRemoteHostStore } from './store.js';
|
|
7
|
+
|
|
8
|
+
let gateway; let root;
|
|
9
|
+
afterEach(async () => { gateway?.stop(); gateway = null; vi.useRealTimers(); if (root) await fs.rm(root, { recursive: true, force: true }); root = null; });
|
|
10
|
+
const setup = async fetch => {
|
|
11
|
+
root = await fs.mkdtemp(path.join(os.tmpdir(), 'opencode/json-lifecycle-'));
|
|
12
|
+
const host = { id: 'host', source: 'direct', clientToken: 'fixture-a', apiUrl: 'http://fixture.invalid' };
|
|
13
|
+
gateway = createRemoteHostGateway({ store: createRemoteHostStore(path.join(root, 'remote.sqlite')),
|
|
14
|
+
indexDbPath: path.join(root, 'index.sqlite'), adapter: { listHosts: async () => [{ ...host }] },
|
|
15
|
+
transportFactory: async () => ({ capabilities: { remoteProjects: true, protocol: 1, instanceId: 'fixture' }, fetch, close() {} }) });
|
|
16
|
+
const resource = {}; gateway.observe(resource, 'owner', { status: false }); gateway.retainHost('host', resource);
|
|
17
|
+
await Promise.resolve(); await Promise.resolve(); vi.useFakeTimers();
|
|
18
|
+
return host;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
it('fifty fully consumed JSON responses retain zero deadline timers with the shared connection alive', async () => {
|
|
22
|
+
await setup(async () => Response.json({ value: 42 }));
|
|
23
|
+
for (let index = 0; index < 50; index++) expect(await gateway.json('host', '/api/value')).toEqual({ value: 42 });
|
|
24
|
+
expect(vi.getTimerCount()).toBe(0);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it.each([['malformed', () => new Response('{'), 'SyntaxError'],
|
|
28
|
+
['non-2xx', () => new Response('{}', { status: 503 }), 'Error']])('%s consumption preserves failure and releases its deadline', async (_name, response, name) => {
|
|
29
|
+
await setup(async () => response());
|
|
30
|
+
await expect(gateway.json('host', '/api/value')).rejects.toMatchObject({ name });
|
|
31
|
+
expect(vi.getTimerCount()).toBe(0);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('headers alone do not release the JSON body deadline', async () => {
|
|
35
|
+
let body; let started;
|
|
36
|
+
const bodyStarted = new Promise(resolve => { started = resolve; });
|
|
37
|
+
await setup(async (_route, init) => ({ ok: true, json: () => {
|
|
38
|
+
started(); return new Promise((resolve, reject) => { body = resolve;
|
|
39
|
+
init.signal.addEventListener('abort', () => reject(init.signal.reason), { once: true }); });
|
|
40
|
+
} }));
|
|
41
|
+
const reading = gateway.json('host', '/api/value');
|
|
42
|
+
const assertion = expect(reading).rejects.toMatchObject({ name: 'TimeoutError' });
|
|
43
|
+
await bodyStarted; expect(vi.getTimerCount()).toBe(1);
|
|
44
|
+
await vi.advanceTimersByTimeAsync(15000); await assertion;
|
|
45
|
+
expect(vi.getTimerCount()).toBe(0); body({ value: 'too late' });
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('credential ABA after body headers still rejects a late parsed value and clears the local owner', async () => {
|
|
49
|
+
let finish; let started;
|
|
50
|
+
const bodyStarted = new Promise(resolve => { started = resolve; });
|
|
51
|
+
const host = await setup(async () => ({ ok: true, json: () => { started(); return new Promise(resolve => { finish = resolve; }); } }));
|
|
52
|
+
const reading = gateway.json('host', '/api/value'); const assertion = expect(reading).rejects.toMatchObject({ code: 'stale_host' });
|
|
53
|
+
await bodyStarted; host.clientToken = 'fixture-b'; await gateway.list(); host.clientToken = 'fixture-a'; await gateway.list();
|
|
54
|
+
finish({ value: 'stale' }); await assertion; expect(vi.getTimerCount()).toBe(0);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it.each(['abort', 'retarget'])('remote registration never persists a late project after %s', async (mode) => {
|
|
58
|
+
let finish; let started;
|
|
59
|
+
const bodyStarted = new Promise(resolve => { started = resolve; });
|
|
60
|
+
const host = await setup(async () => ({ ok: true, json: () => { started(); return new Promise(resolve => { finish = resolve; }); } }));
|
|
61
|
+
const controller = new AbortController();
|
|
62
|
+
const pending = gateway.registerProject('host', { path: '/repo' }, { instanceId: 'fixture', signal: controller.signal });
|
|
63
|
+
const assertion = expect(pending).rejects.toThrow();
|
|
64
|
+
await bodyStarted;
|
|
65
|
+
if (mode === 'abort') controller.abort();
|
|
66
|
+
else { host.clientToken = 'replacement'; await gateway.list(); }
|
|
67
|
+
finish({ project: { id: 'remote', path: '/repo' } });
|
|
68
|
+
await assertion;
|
|
69
|
+
expect(gateway.store.projects()).toEqual([]);
|
|
70
|
+
expect(vi.getTimerCount()).toBe(0);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it.each([{}, { project: { id: 'remote', path: '/repo', hostId: 'nested-host' } }, { project: { id: 'remote', path: {} } }])('rejects malformed remote registration responses without saving a reference: %j', async (response) => {
|
|
74
|
+
await setup(async () => Response.json(response));
|
|
75
|
+
await expect(gateway.registerProject('host', { path: '/repo' }, { instanceId: 'fixture' })).rejects.toMatchObject({ code: 'remote_invalid_project' });
|
|
76
|
+
expect(gateway.store.projects()).toEqual([]);
|
|
77
|
+
expect(vi.getTimerCount()).toBe(0);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('uses only the remote canonical path when deduplicating registrations from different aliases', async () => {
|
|
81
|
+
const fetch = vi.fn(async () => Response.json({ project: { id: 'remote', path: '/remote-canonical', label: 'Preserved' } }));
|
|
82
|
+
await setup(fetch);
|
|
83
|
+
const first = await gateway.registerProject('host', { path: '/remote-alias' }, { instanceId: 'fixture' });
|
|
84
|
+
const second = await gateway.registerProject('host', { path: '/another-remote-alias' }, { instanceId: 'fixture' });
|
|
85
|
+
expect(first).toMatchObject({ created: true, project: { path: '/remote-canonical' } });
|
|
86
|
+
expect(second).toEqual({ project: first.project, created: false });
|
|
87
|
+
expect(gateway.store.projects()).toEqual([first.project]);
|
|
88
|
+
expect(fetch.mock.calls.map(([, init]) => JSON.parse(init.body).path)).toEqual(['/remote-alias', '/another-remote-alias']);
|
|
89
|
+
expect(vi.getTimerCount()).toBe(0);
|
|
90
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const REMOTE_PREVIEW_TOKEN_MARKER = '__YURI_HUB_URL_AUTH__';
|
|
2
|
+
export const remotePreviewPrefix = (req) => {
|
|
3
|
+
const prefix = req.headers?.['x-yuri-preview-hub-prefix'];
|
|
4
|
+
return typeof prefix === 'string' && /^\/api\/hosts\/[A-Za-z0-9._~%-]{1,256}$/.test(prefix) ? prefix : '';
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
// Retain only a possible partial marker, not the response body.
|
|
8
|
+
export async function* replacePreviewToken(body, token) {
|
|
9
|
+
const decoder = new TextDecoder();
|
|
10
|
+
let tail = '';
|
|
11
|
+
for await (const chunk of body) {
|
|
12
|
+
const text = (tail + decoder.decode(chunk, { stream: true })).replaceAll(REMOTE_PREVIEW_TOKEN_MARKER, token);
|
|
13
|
+
let suffix = 0;
|
|
14
|
+
for (let length = 1; length < REMOTE_PREVIEW_TOKEN_MARKER.length; length++) {
|
|
15
|
+
if (text.endsWith(REMOTE_PREVIEW_TOKEN_MARKER.slice(0, length))) suffix = length;
|
|
16
|
+
}
|
|
17
|
+
tail = suffix ? text.slice(-suffix) : '';
|
|
18
|
+
const output = suffix ? text.slice(0, -suffix) : text;
|
|
19
|
+
if (output) yield Buffer.from(output);
|
|
20
|
+
}
|
|
21
|
+
const output = (tail + decoder.decode()).replaceAll(REMOTE_PREVIEW_TOKEN_MARKER, token);
|
|
22
|
+
if (output) yield Buffer.from(output);
|
|
23
|
+
}
|
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
import { WebSocketServer } from 'ws';
|
|
2
|
+
import express from 'express';
|
|
3
|
+
import { once } from 'node:events';
|
|
4
|
+
import { Readable } from 'node:stream';
|
|
5
|
+
import { createProjectRegistry } from '../projects/registry.js';
|
|
6
|
+
import { projectRemoteStatusEvent, remoteFailure } from './gateway.js';
|
|
7
|
+
import { projectMetadata } from './store.js';
|
|
8
|
+
import { REMOTE_PREVIEW_TOKEN_MARKER, replacePreviewToken } from './preview-scope.js';
|
|
9
|
+
import { projectRemoteConfiguration } from './configuration.js';
|
|
10
|
+
import { RUNTIME_CONTRACT_MIN_VERIFIED } from '../opencode/runtime-contract.js';
|
|
11
|
+
import { parseFilePreviewPath, replaceFilePreviewUrlAuthToken } from '../preview/file-preview-path.js';
|
|
12
|
+
|
|
13
|
+
const websocketPath = (path) => path === '/api/terminal/ws' || path.startsWith('/api/preview/proxy/');
|
|
14
|
+
const safeRoute = (route, method) => {
|
|
15
|
+
if (!route.startsWith('/api/') || /[\\\r\n]/.test(route)) return false;
|
|
16
|
+
const pathname = new URL(route, 'http://remote.invalid').pathname;
|
|
17
|
+
if (pathname === '/api/magic-prompts'
|
|
18
|
+
|| /^\/api\/github\/(?:auth\/status|issues\/(?:list|get|comments)|pulls\/(?:list|context))$/.test(pathname)) {
|
|
19
|
+
return method === 'GET' || method === 'HEAD';
|
|
20
|
+
}
|
|
21
|
+
if (pathname.startsWith('/api/yuri/content-search') && method !== 'GET') return false;
|
|
22
|
+
if (/^\/api\/config\/(?:settings|global|.*\/file)(\/|$)/.test(pathname)
|
|
23
|
+
|| (/^\/api\/experimental(?:\/|$)/.test(pathname) && !/^\/api\/experimental\/worktree(?:\/|$)/.test(pathname))) return false;
|
|
24
|
+
if (/^\/api\/(hosts|client-auth|system|gui-network|remote-desktop|assistants|scheduled-tasks)(\/|$)/.test(pathname)
|
|
25
|
+
|| /^\/api\/yuri\/(transcript-cache|config-sync|relay|realtime-proxy)(\/|$)/.test(pathname)) return false;
|
|
26
|
+
if (method !== 'GET' && method !== 'HEAD' && /^\/api\/(config|provider|plugin|mcp|global|agent|command|skill|settings|opencode|push)(\/|$)/.test(pathname)) return false;
|
|
27
|
+
if (/^\/api\/yuri\/sessions\/[^/]+\/(archive|metadata)$/.test(pathname)) return method === 'PUT';
|
|
28
|
+
return /^\/api\/(info|fs|git|terminal|preview|session|sessions|session-folders|session-order|permission|permission-auto-accept|question|question-auto-delegate|form|command|agent|provider|config|plugin|skill|mcp|find|file|vcs|path|project|projects|experimental|location|session-activity)(\/|$)/.test(pathname)
|
|
29
|
+
|| /^\/api\/yuri\/(session|session-index|session-unread|session-folders|session-order|message-queue|content-search|events)(\/|$)/.test(pathname);
|
|
30
|
+
};
|
|
31
|
+
const report = (res, error) => {
|
|
32
|
+
if (res.headersSent) return res.destroy();
|
|
33
|
+
const code = error?.code || 'remote_unavailable';
|
|
34
|
+
// Transport failures may contain URL credentials or content. Never serialize
|
|
35
|
+
// arbitrary upstream Error.message or log the request/response body.
|
|
36
|
+
const allowed = new Set(['remote_incompatible', 'remote_instance_mismatch', 'remote_authorization_required', 'host_unavailable',
|
|
37
|
+
'project_not_found', 'validation_error', 'stale_host', 'subscription_not_found', 'content_capacity', 'remote_request_failed',
|
|
38
|
+
'remote_ssh_authentication_failed', 'remote_ssh_unavailable', 'remote_relay_unavailable', 'remote_service_starting']);
|
|
39
|
+
const publicCode = allowed.has(code) ? code : 'remote_unavailable';
|
|
40
|
+
return res.status(error?.status || 503).json({ code: publicCode, error: publicCode,
|
|
41
|
+
retryable: ![401, 403, 404, 409].includes(error?.status),
|
|
42
|
+
...(publicCode === 'remote_incompatible' ? { minimumVersion: { remoteProjectsProtocol: 1, opencode: RUNTIME_CONTRACT_MIN_VERIFIED } } : {}) });
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export function registerRemoteHostRoutes(app, { gateway, getAuth, server, isRequestOriginAllowed,
|
|
46
|
+
remoteClientAuthRuntime, readSettings, persistSettings, validateDirectoryPath,
|
|
47
|
+
globalEventHub, broadcaster, supportedRemote = false, version = 'unknown', getOpenCodeCompatibility = () => null }) {
|
|
48
|
+
const store = gateway.store;
|
|
49
|
+
const registry = createProjectRegistry({ persistSettings, validateDirectoryPath });
|
|
50
|
+
const jsonParser = express.json({ limit: '1mb' });
|
|
51
|
+
const parseMutation = (req, res, next) => jsonParser(req, res, (error) => {
|
|
52
|
+
if (error) return res.status(400).json({ code: 'validation_error', error: 'Invalid project mutation payload' });
|
|
53
|
+
next();
|
|
54
|
+
});
|
|
55
|
+
const resources = new Map();
|
|
56
|
+
const tracked = new Set();
|
|
57
|
+
const authorizedResources = new Map();
|
|
58
|
+
const expirations = new Map();
|
|
59
|
+
const expiryTimers = new Map();
|
|
60
|
+
const closeOwner = (owner) => {
|
|
61
|
+
for (const [resource, id] of authorizedResources) if (id === owner) authorizedResources.delete(resource);
|
|
62
|
+
for (const close of [...(resources.get(owner) || [])]) close();
|
|
63
|
+
gateway.releaseOwner(owner);
|
|
64
|
+
};
|
|
65
|
+
const armExpiry = (owner, force = false) => {
|
|
66
|
+
if (expiryTimers.has(owner) || (!force && !store.projects().length) || !expirations.get(owner)) return;
|
|
67
|
+
const delay = Math.max(0, expirations.get(owner) - Date.now());
|
|
68
|
+
const timer = setTimeout(() => {
|
|
69
|
+
expiryTimers.delete(owner);
|
|
70
|
+
if (expirations.get(owner) <= Date.now()) closeOwner(owner);
|
|
71
|
+
else armExpiry(owner, force);
|
|
72
|
+
}, Math.min(delay, 2147483647));
|
|
73
|
+
timer.unref?.(); expiryTimers.set(owner, timer);
|
|
74
|
+
};
|
|
75
|
+
const unsubscribeProjectChanges = broadcaster.subscribe((payload) => {
|
|
76
|
+
if (payload.type === 'yuri:project-order-changed') for (const owner of resources.keys()) armExpiry(owner);
|
|
77
|
+
});
|
|
78
|
+
const authorize = async (req, res, { aggregate = true } = {}) => {
|
|
79
|
+
const clientRequest = Object.create(req);
|
|
80
|
+
clientRequest.headers = { ...req.headers };
|
|
81
|
+
delete clientRequest.headers.cookie;
|
|
82
|
+
const auth = await getAuth()?.resolveAuthContext(clientRequest, res);
|
|
83
|
+
// A password-less browser cookie is not a pairing grant. Native local
|
|
84
|
+
// clients use a real server-issued desktop-local credential as well.
|
|
85
|
+
if (auth?.type !== 'client' || !auth.clientId) throw remoteFailure('remote_authorization_required', 401);
|
|
86
|
+
const client = auth.client || (await remoteClientAuthRuntime?.listClients?.())?.find((entry) => entry.id === auth.clientId);
|
|
87
|
+
if (!client) throw remoteFailure('remote_authorization_required', 401);
|
|
88
|
+
if (client.revokedAt || (client.expiresAt && Date.parse(client.expiresAt) <= Date.now())) throw remoteFailure('remote_authorization_required', 401);
|
|
89
|
+
if (aggregate && client.clientKind !== 'desktop-local'
|
|
90
|
+
&& !(client.authMethod === 'pairing' && client.pairingId && ['desktop', 'mobile'].includes(client.clientKind))) {
|
|
91
|
+
throw remoteFailure('remote_authorization_required', 403);
|
|
92
|
+
}
|
|
93
|
+
if (client.expiresAt) expirations.set(auth.clientId, Date.parse(client.expiresAt));
|
|
94
|
+
return auth.clientId;
|
|
95
|
+
};
|
|
96
|
+
const retainResource = (owner, close) => {
|
|
97
|
+
let entries = resources.get(owner);
|
|
98
|
+
if (!entries) { entries = new Set(); resources.set(owner, entries); }
|
|
99
|
+
entries.add(close);
|
|
100
|
+
armExpiry(owner);
|
|
101
|
+
return () => {
|
|
102
|
+
entries.delete(close);
|
|
103
|
+
if (!entries.size) {
|
|
104
|
+
resources.delete(owner); clearTimeout(expiryTimers.get(owner)); expiryTimers.delete(owner);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
const track = (req, res, owner) => {
|
|
109
|
+
if (tracked.has(res)) return;
|
|
110
|
+
tracked.add(res);
|
|
111
|
+
authorizedResources.set(res, owner);
|
|
112
|
+
const release = gateway.observe(res, owner);
|
|
113
|
+
const remove = retainResource(owner, () => res.destroy());
|
|
114
|
+
res.once('close', () => { tracked.delete(res); authorizedResources.delete(res); release(); remove(); });
|
|
115
|
+
};
|
|
116
|
+
const revoke = remoteClientAuthRuntime?.subscribeRevocation?.((id) => {
|
|
117
|
+
closeOwner(id);
|
|
118
|
+
}) || (() => {});
|
|
119
|
+
// This is the already-existing client -> Hub stream, not a new socket per host.
|
|
120
|
+
app.use((req, res, next) => {
|
|
121
|
+
if (!/^\/api\/(global\/event|event)(?:\?|$)/.test(req.originalUrl || req.url)) return next();
|
|
122
|
+
const writeHead = res.writeHead;
|
|
123
|
+
res.writeHead = function (...args) {
|
|
124
|
+
const result = writeHead.apply(this, args);
|
|
125
|
+
if (this.statusCode === 200) void authorize(req, res).then((owner) => {
|
|
126
|
+
if (!res.destroyed && !res.writableEnded) track(req, res, owner);
|
|
127
|
+
}).catch(() => {});
|
|
128
|
+
return result;
|
|
129
|
+
};
|
|
130
|
+
next();
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
// Local-only directory authority. Returning only local projects prevents
|
|
134
|
+
// A -> B from silently aggregating B -> C and prevents cycles.
|
|
135
|
+
app.get('/api/projects', async (_req, res) => {
|
|
136
|
+
try { res.json({ projects: (await readSettings()).projects?.filter((p) => !p.hostId) || [] }); }
|
|
137
|
+
catch (error) { report(res, error); }
|
|
138
|
+
});
|
|
139
|
+
app.post('/api/projects', async (req, res) => {
|
|
140
|
+
try {
|
|
141
|
+
await authorize(req, res, { aggregate: false });
|
|
142
|
+
const result = await registry.register({ ...req.body, activate: false });
|
|
143
|
+
app.emit('yuri:projects-changed');
|
|
144
|
+
res.json({ project: result.project, created: result.created });
|
|
145
|
+
} catch (error) { report(res, error); }
|
|
146
|
+
});
|
|
147
|
+
app.patch('/api/projects/:id', async (req, res) => {
|
|
148
|
+
try {
|
|
149
|
+
await authorize(req, res, { aggregate: false });
|
|
150
|
+
let project;
|
|
151
|
+
const settings = await persistSettings((current) => ({ projects: (current.projects || []).map((entry) => {
|
|
152
|
+
if (entry.id !== req.params.id || entry.hostId) return entry;
|
|
153
|
+
project = { ...entry, ...projectMetadata(req.body) }; return project;
|
|
154
|
+
}) }));
|
|
155
|
+
project = settings.projects?.find((p) => p.id === req.params.id);
|
|
156
|
+
if (!project) throw remoteFailure('project_not_found', 404);
|
|
157
|
+
app.emit('yuri:projects-changed');
|
|
158
|
+
res.json({ project });
|
|
159
|
+
} catch (error) { report(res, error); }
|
|
160
|
+
});
|
|
161
|
+
app.get('/api/hosts/capabilities', async (req, res) => {
|
|
162
|
+
try {
|
|
163
|
+
await authorize(req, res, { aggregate: false });
|
|
164
|
+
res.json({ remoteProjects: supportedRemote, protocol: 1, instanceId: store.hubId, version,
|
|
165
|
+
opencode: getOpenCodeCompatibility() });
|
|
166
|
+
} catch (error) { report(res, error); }
|
|
167
|
+
});
|
|
168
|
+
app.get('/api/hosts/status-stream', async (req, res) => {
|
|
169
|
+
try {
|
|
170
|
+
const owner = await authorize(req, res, { aggregate: false });
|
|
171
|
+
res.status(200).set({ 'Content-Type': 'text/event-stream', 'Cache-Control': 'no-store', 'X-Accel-Buffering': 'no' });
|
|
172
|
+
res.flushHeaders();
|
|
173
|
+
const send = (event) => {
|
|
174
|
+
let payload = projectRemoteStatusEvent(event.payload || event);
|
|
175
|
+
if (!payload) return;
|
|
176
|
+
if (payload.type === 'yuri:notification') payload = { type: payload.type, properties: {
|
|
177
|
+
sessionID: payload.properties?.sessionID, sessionId: payload.properties?.sessionId,
|
|
178
|
+
title: payload.properties?.title, kind: payload.properties?.kind, tag: payload.properties?.tag,
|
|
179
|
+
directory: payload.properties?.directory, event: payload.properties?.event,
|
|
180
|
+
instanceId: payload.properties?.instanceId || store.hubId } };
|
|
181
|
+
const frame = `data: ${JSON.stringify({ directory: event.directory || payload.properties?.directory || 'global', payload })}\n\n`;
|
|
182
|
+
if (res.writableLength > 256 * 1024) return res.destroy();
|
|
183
|
+
res.write(frame);
|
|
184
|
+
};
|
|
185
|
+
const unsubscribeNative = globalEventHub.subscribeEvent(send);
|
|
186
|
+
const unsubscribeYuri = broadcaster.subscribe((payload, options) => send({ payload, directory: options?.directory }));
|
|
187
|
+
const projectsChanged = () => send({ type: 'yuri:projects-changed', properties: {} });
|
|
188
|
+
app.on('yuri:projects-changed', projectsChanged);
|
|
189
|
+
const heartbeat = setInterval(() => res.write(': heartbeat\n\n'), 1000);
|
|
190
|
+
const remove = retainResource(owner, () => res.destroy());
|
|
191
|
+
armExpiry(owner, true);
|
|
192
|
+
res.once('close', () => { clearInterval(heartbeat); unsubscribeNative(); unsubscribeYuri(); remove(); app.off('yuri:projects-changed', projectsChanged); });
|
|
193
|
+
res.write(': ready\n\n');
|
|
194
|
+
} catch (error) { report(res, error); }
|
|
195
|
+
});
|
|
196
|
+
app.get('/api/hosts', (_req, res, next) => {
|
|
197
|
+
if (gateway.supported) return next();
|
|
198
|
+
res.json({ supported: false, hubId: store.hubId, hosts: [], projects: [], reason: 'pc_hub_required' });
|
|
199
|
+
});
|
|
200
|
+
app.use('/api/hosts', async (req, res, next) => {
|
|
201
|
+
try {
|
|
202
|
+
req.remoteHostOwner = await authorize(req, res);
|
|
203
|
+
const operation = new AbortController();
|
|
204
|
+
req.remoteHostSignal = operation.signal;
|
|
205
|
+
const remove = retainResource(req.remoteHostOwner, () => {
|
|
206
|
+
operation.abort();
|
|
207
|
+
if (!res.headersSent) res.status(401).json({ code: 'remote_authorization_required', error: 'remote_authorization_required' });
|
|
208
|
+
else res.destroy();
|
|
209
|
+
});
|
|
210
|
+
const release = gateway.observe(res, req.remoteHostOwner, { status: false });
|
|
211
|
+
const hostMatch = /^\/api\/hosts\/([^/]+)(?:\/|$)/.exec(req.originalUrl);
|
|
212
|
+
const priority = /\/api\/session(?:\/|\?)/.test(req.originalUrl)
|
|
213
|
+
|| (req.method !== 'GET' && req.method !== 'HEAD');
|
|
214
|
+
const releaseHost = hostMatch ? gateway.retainHost(decodeURIComponent(hostMatch[1]), res, priority) : () => {};
|
|
215
|
+
res.once('close', () => { operation.abort(); release(); releaseHost(); remove(); });
|
|
216
|
+
res.setHeader('Cache-Control', 'private, no-store');
|
|
217
|
+
next();
|
|
218
|
+
} catch (error) { report(res, error); }
|
|
219
|
+
});
|
|
220
|
+
app.get('/api/hosts', async (_req, res) => {
|
|
221
|
+
try { res.json(await gateway.list()); } catch (error) { report(res, error); }
|
|
222
|
+
});
|
|
223
|
+
app.get('/api/hosts/projects', (_req, res) => res.json({ projects: store.projects() }));
|
|
224
|
+
app.get('/api/hosts/:hostId/summaries', (req, res) => {
|
|
225
|
+
try { res.json(gateway.summaries(req.params.hostId)); } catch (error) { report(res, error); }
|
|
226
|
+
});
|
|
227
|
+
app.post('/api/hosts/:hostId/connect', async (req, res) => {
|
|
228
|
+
try { res.json({ host: await gateway.connect(req.params.hostId) }); } catch (error) { report(res, error); }
|
|
229
|
+
});
|
|
230
|
+
app.post('/api/hosts/:hostId/projects', parseMutation, async (req, res) => {
|
|
231
|
+
try {
|
|
232
|
+
res.json(await gateway.registerProject(req.params.hostId, req.body, {
|
|
233
|
+
signal: req.remoteHostSignal, instanceId: req.get('x-yuri-target-instance') || undefined,
|
|
234
|
+
}));
|
|
235
|
+
} catch (error) { report(res, error); }
|
|
236
|
+
});
|
|
237
|
+
app.patch('/api/hosts/:hostId/projects/:projectId', parseMutation, async (req, res) => {
|
|
238
|
+
try {
|
|
239
|
+
const project = store.projects(req.params.hostId).find((p) => p.id === req.params.projectId);
|
|
240
|
+
if (!project) throw remoteFailure('project_not_found', 404);
|
|
241
|
+
const remote = await gateway.json(req.params.hostId, `/api/projects/${encodeURIComponent(project.remoteProjectId)}`,
|
|
242
|
+
{ method: 'PATCH', signal: req.remoteHostSignal, headers: { 'content-type': 'application/json' }, body: JSON.stringify(projectMetadata(req.body)) });
|
|
243
|
+
if (req.remoteHostSignal.aborted) throw remoteFailure('remote_authorization_required', 401);
|
|
244
|
+
const refreshed = store.refreshProject(project, remote.project);
|
|
245
|
+
if (!refreshed) throw remoteFailure('project_not_found', 404);
|
|
246
|
+
res.json({ project: refreshed });
|
|
247
|
+
} catch (error) { report(res, error); }
|
|
248
|
+
});
|
|
249
|
+
app.delete('/api/hosts/:hostId/projects/:projectId', (req, res) => {
|
|
250
|
+
const removed = store.removeProject(req.params.hostId, req.params.projectId);
|
|
251
|
+
if (removed) broadcaster({ type: 'yuri:project-order-changed', properties: { occurredAt: Date.now() } });
|
|
252
|
+
gateway.projectReferencesChanged(req.params.hostId); res.status(204).end();
|
|
253
|
+
});
|
|
254
|
+
app.post('/api/hosts/:hostId/subscriptions', parseMutation, async (req, res) => {
|
|
255
|
+
let lease;
|
|
256
|
+
try {
|
|
257
|
+
lease = await gateway.subscribe(req.params.hostId, req.body, req.remoteHostOwner);
|
|
258
|
+
await authorize(req, res);
|
|
259
|
+
if (res.destroyed || req.aborted) throw remoteFailure('remote_authorization_required', 401);
|
|
260
|
+
res.json(lease);
|
|
261
|
+
}
|
|
262
|
+
catch (error) {
|
|
263
|
+
if (lease) { try { gateway.release(req.params.hostId, lease.id, req.remoteHostOwner); } catch { /* Revocation may already have removed it. */ } }
|
|
264
|
+
report(res, error);
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
app.delete('/api/hosts/:hostId/subscriptions/:id', (req, res) => {
|
|
268
|
+
try { gateway.release(req.params.hostId, req.params.id, req.remoteHostOwner); res.status(204).end(); }
|
|
269
|
+
catch (error) { report(res, error); }
|
|
270
|
+
});
|
|
271
|
+
app.post('/api/hosts/:hostId/api/preview/targets', parseMutation, (req, res, next) => {
|
|
272
|
+
try {
|
|
273
|
+
if (req.body?.kind === 'file') {
|
|
274
|
+
const directory = gateway.assertProjectDirectory(req.params.hostId, req.body.directory);
|
|
275
|
+
req.body = { ...req.body, directory };
|
|
276
|
+
}
|
|
277
|
+
next();
|
|
278
|
+
} catch (error) { report(res, error); }
|
|
279
|
+
});
|
|
280
|
+
app.delete('/api/hosts/:hostId/api/preview/targets/:id', parseMutation, (_req, _res, next) => next());
|
|
281
|
+
app.use('/api/hosts/:hostId', async (req, res) => {
|
|
282
|
+
const controller = new AbortController();
|
|
283
|
+
const abort = () => controller.abort();
|
|
284
|
+
res.once('close', abort);
|
|
285
|
+
const remove = retainResource(req.remoteHostOwner, () => { controller.abort(); res.destroy(); });
|
|
286
|
+
try {
|
|
287
|
+
const route = req.url;
|
|
288
|
+
if (!safeRoute(route, req.method)) return res.status(403).json({ code: 'remote_scope_forbidden', error: 'remote_scope_forbidden' });
|
|
289
|
+
const url = new URL(route, 'http://remote.invalid');
|
|
290
|
+
if (url.pathname.startsWith('/api/preview/proxy/') && url.pathname.includes('/_file/')) {
|
|
291
|
+
if (!parseFilePreviewPath(url.pathname) || !['GET', 'HEAD'].includes(req.method)) {
|
|
292
|
+
return res.status(403).json({ code: 'remote_scope_forbidden', error: 'remote_scope_forbidden' });
|
|
293
|
+
}
|
|
294
|
+
url.pathname = replaceFilePreviewUrlAuthToken(url.pathname, '-');
|
|
295
|
+
}
|
|
296
|
+
for (const key of ['yuri_url_token', 'oc_client_token']) url.searchParams.delete(key);
|
|
297
|
+
const headers = {};
|
|
298
|
+
const hostPrefix = `/api/hosts/${encodeURIComponent(req.params.hostId)}`;
|
|
299
|
+
const preview = url.pathname.startsWith('/api/preview/');
|
|
300
|
+
const previewAuth = preview ? await getAuth().issueClientUrlToken(req) : null;
|
|
301
|
+
if (preview) headers['x-yuri-preview-hub-prefix'] = hostPrefix;
|
|
302
|
+
for (const name of ['accept', 'content-type', 'x-opencode-directory', 'x-opencode-directory-encoding',
|
|
303
|
+
'last-event-id', 'range', 'if-none-match', 'x-yuri-gui-revision',
|
|
304
|
+
'x-yuri-content-length', 'x-yuri-sha256', 'x-yuri-mime', 'x-yuri-filename']) if (typeof req.headers[name] === 'string') headers[name] = req.headers[name];
|
|
305
|
+
const init = { method: req.method, headers, signal: controller.signal };
|
|
306
|
+
if (!['GET', 'HEAD'].includes(req.method)) {
|
|
307
|
+
if (req.body !== undefined) init.body = JSON.stringify(req.body);
|
|
308
|
+
else { init.body = Readable.toWeb(req); init.duplex = 'half'; }
|
|
309
|
+
}
|
|
310
|
+
const streaming = preview || init.duplex === 'half'
|
|
311
|
+
|| /^\/api\/fs\/(raw|serve)(\/|$)/.test(url.pathname)
|
|
312
|
+
|| /^\/api\/terminal\/[^/]+\/stream$/.test(url.pathname)
|
|
313
|
+
|| url.pathname === '/api/yuri/events';
|
|
314
|
+
const response = await gateway.request(req.params.hostId, `${url.pathname}${url.search}`, init, {
|
|
315
|
+
streaming, longRunning: streaming || !['GET', 'HEAD'].includes(req.method),
|
|
316
|
+
...(req.headers['x-yuri-target-instance'] !== undefined ? { instanceId: req.headers['x-yuri-target-instance'] } : {}),
|
|
317
|
+
});
|
|
318
|
+
res.status(response.status);
|
|
319
|
+
const location = response.headers.get('location');
|
|
320
|
+
if (location) {
|
|
321
|
+
const target = new URL(location, `http://remote.invalid${url.pathname}`);
|
|
322
|
+
if (target.origin !== 'http://remote.invalid') throw remoteFailure('remote_redirect_forbidden', 502);
|
|
323
|
+
const scoped = target.pathname.startsWith(`${hostPrefix}/`) ? target.pathname : `${hostPrefix}${target.pathname}`;
|
|
324
|
+
res.setHeader('Location', `${scoped}${target.search}${target.hash}`.replaceAll(REMOTE_PREVIEW_TOKEN_MARKER, previewAuth?.token || ''));
|
|
325
|
+
}
|
|
326
|
+
for (const name of ['content-type', 'content-range', 'content-disposition', 'content-security-policy', 'referrer-policy', 'accept-ranges', 'etag', 'last-modified', 'x-inertia', 'x-yuri-gui-revision', 'x-yuri-gui-code', 'x-yuri-file-exists']) {
|
|
327
|
+
const value = response.headers.get(name); if (value) res.setHeader(name, value);
|
|
328
|
+
}
|
|
329
|
+
if (/^\/api\/(config|provider|plugin|mcp|agent)(\/|$)/.test(url.pathname)
|
|
330
|
+
&& (response.headers.get('content-type') || '').includes('application/json')) {
|
|
331
|
+
return res.json(projectRemoteConfiguration(await response.json()));
|
|
332
|
+
}
|
|
333
|
+
const textualPreview = preview && /text\/|javascript|ecmascript|application\/json/.test(response.headers.get('content-type') || '');
|
|
334
|
+
const body = textualPreview && response.body ? replacePreviewToken(response.body, previewAuth?.token || '') : response.body;
|
|
335
|
+
if (body) for await (const chunk of body) {
|
|
336
|
+
if (controller.signal.aborted) break;
|
|
337
|
+
if (!res.write(chunk)) await once(res, 'drain', { signal: controller.signal });
|
|
338
|
+
}
|
|
339
|
+
res.end();
|
|
340
|
+
} catch (error) { if (!controller.signal.aborted) report(res, error); }
|
|
341
|
+
finally { remove(); res.off('close', abort); }
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
const wss = new WebSocketServer({ noServer: true, maxPayload: 1024 * 1024 });
|
|
345
|
+
const onUpgrade = async (req, socket, head) => {
|
|
346
|
+
const url = new URL(req.url, 'http://hub.invalid');
|
|
347
|
+
const match = /^\/api\/hosts\/([^/]+)(\/api\/.*)$/.exec(url.pathname);
|
|
348
|
+
if (!match) {
|
|
349
|
+
if (url.pathname === '/api/global/event/ws') {
|
|
350
|
+
try {
|
|
351
|
+
const owner = await authorize(req, null);
|
|
352
|
+
authorizedResources.set(socket, owner);
|
|
353
|
+
const release = gateway.observe(socket, owner);
|
|
354
|
+
const remove = retainResource(owner, () => socket.destroy());
|
|
355
|
+
socket.once('close', () => { authorizedResources.delete(socket); release(); remove(); });
|
|
356
|
+
} catch { /* Existing message stream handler owns its authentication. */ }
|
|
357
|
+
}
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
let upstream;
|
|
361
|
+
let downstream;
|
|
362
|
+
const pendingFrames = [];
|
|
363
|
+
let pendingBytes = 0;
|
|
364
|
+
let admissionFailed = false;
|
|
365
|
+
let removeResource = () => {};
|
|
366
|
+
try {
|
|
367
|
+
if (!websocketPath(match[2]) || !await isRequestOriginAllowed(req)) throw remoteFailure('remote_authorization_required', 403);
|
|
368
|
+
if (match[2].startsWith('/api/preview/proxy/') && match[2].includes('/_file/')) throw remoteFailure('remote_authorization_required', 403);
|
|
369
|
+
const owner = await authorize(req, null);
|
|
370
|
+
removeResource = retainResource(owner, () => { socket.destroy(); upstream?.close(); });
|
|
371
|
+
const release = gateway.observe(socket, owner);
|
|
372
|
+
const releaseHost = gateway.retainHost(decodeURIComponent(match[1]), socket);
|
|
373
|
+
socket.once('close', () => { admissionFailed = true; pendingFrames.length = 0; upstream?.close(); removeResource(); release(); releaseHost(); });
|
|
374
|
+
url.searchParams.delete('yuri_url_token');
|
|
375
|
+
const protocols = typeof req.headers['sec-websocket-protocol'] === 'string'
|
|
376
|
+
? req.headers['sec-websocket-protocol'].split(',').map((value) => value.trim()).filter(Boolean) : [];
|
|
377
|
+
upstream = await gateway.openWebSocket(decodeURIComponent(match[1]), `${match[2]}${url.search}`, protocols, {
|
|
378
|
+
onMessage: ({ data }) => {
|
|
379
|
+
if (admissionFailed) return;
|
|
380
|
+
if (downstream?.readyState === 1) { downstream.send(data); return; }
|
|
381
|
+
pendingBytes += Buffer.byteLength(data);
|
|
382
|
+
if (pendingBytes > 1024 * 1024 || pendingFrames.length >= 256) {
|
|
383
|
+
admissionFailed = true; pendingFrames.length = 0; upstream?.close();
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
pendingFrames.push(data);
|
|
387
|
+
},
|
|
388
|
+
});
|
|
389
|
+
if (socket.destroyed || admissionFailed) throw remoteFailure('remote_authorization_required', 401);
|
|
390
|
+
await new Promise((resolve, reject) => {
|
|
391
|
+
if (upstream.readyState === 1) return resolve();
|
|
392
|
+
if (upstream.readyState !== 0) return reject(remoteFailure('remote_unavailable'));
|
|
393
|
+
const timer = setTimeout(() => { upstream.close(); reject(remoteFailure('remote_unavailable')); }, 15000);
|
|
394
|
+
upstream.onopen = () => { clearTimeout(timer); resolve(); };
|
|
395
|
+
upstream.onerror = upstream.onclose = () => { clearTimeout(timer); reject(remoteFailure('remote_unavailable')); };
|
|
396
|
+
});
|
|
397
|
+
await authorize(req, null);
|
|
398
|
+
if (socket.destroyed || admissionFailed || upstream.readyState !== 1) throw remoteFailure('remote_authorization_required', 401);
|
|
399
|
+
wss.handleUpgrade(req, socket, head, (client) => {
|
|
400
|
+
downstream = client;
|
|
401
|
+
upstream.onclose = () => client.close();
|
|
402
|
+
upstream.onerror = () => client.close(1011);
|
|
403
|
+
client.on('message', (data, binary) => {
|
|
404
|
+
if (upstream.readyState === 1) upstream.send(binary ? data : data.toString());
|
|
405
|
+
});
|
|
406
|
+
client.once('close', () => { upstream.close(); removeResource(); });
|
|
407
|
+
for (const data of pendingFrames) client.send(data);
|
|
408
|
+
pendingFrames.length = 0; pendingBytes = 0;
|
|
409
|
+
});
|
|
410
|
+
} catch {
|
|
411
|
+
admissionFailed = true; pendingFrames.length = 0;
|
|
412
|
+
upstream?.close(); removeResource();
|
|
413
|
+
if (!socket.destroyed) socket.end('HTTP/1.1 403 Forbidden\r\nConnection: close\r\n\r\n');
|
|
414
|
+
}
|
|
415
|
+
};
|
|
416
|
+
server.on('upgrade', onUpgrade);
|
|
417
|
+
return {
|
|
418
|
+
canReceiveHostEvents(resource) {
|
|
419
|
+
const owner = authorizedResources.get(resource) || authorizedResources.get(resource?._socket);
|
|
420
|
+
return Boolean(owner && (!expirations.has(owner) || expirations.get(owner) > Date.now()));
|
|
421
|
+
},
|
|
422
|
+
stop() {
|
|
423
|
+
revoke(); unsubscribeProjectChanges(); server.off('upgrade', onUpgrade);
|
|
424
|
+
for (const timer of expiryTimers.values()) clearTimeout(timer);
|
|
425
|
+
authorizedResources.clear();
|
|
426
|
+
for (const entries of resources.values()) for (const close of [...entries]) close();
|
|
427
|
+
wss.close(); gateway.stop();
|
|
428
|
+
} };
|
|
429
|
+
}
|