@yuriai/web 0.2.40-beta.3 → 0.2.40-beta.5
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-kQhfwlay.js → AgentAvatar-B7KbxN8Y.js} +1 -1
- package/dist/assets/AssistantConversationSurface-BnK_KTBO.js +3 -0
- package/dist/assets/{AssistantUnreadBadge-B2SY-_-u.js → AssistantUnreadBadge-vu4ZhTft.js} +1 -1
- package/dist/assets/{AssistantView-C_hiAuTd.js → AssistantView-CEfEWUIr.js} +1 -1
- package/dist/assets/DiagramView-Dlzr08J_.js +1 -0
- package/dist/assets/{FadeInOnReveal-CMeIdEKz.js → FadeInOnReveal-DMRmNsau.js} +1 -1
- package/dist/assets/{GuiPluginPage-WXqykPAg.js → GuiPluginPage-DVug4z_p.js} +1 -1
- package/dist/assets/GuiPluginSurface-L43o6Xv8.js +1 -0
- package/dist/assets/{GuiPluginWindow-BLzchKn7.js → GuiPluginWindow-tHXkS18H.js} +1 -1
- package/dist/assets/{Icon-DygEqfgq.js → Icon-DizeYahT.js} +1 -1
- package/dist/assets/{ImageLoadingPlaceholder-kbBRpDSD.js → ImageLoadingPlaceholder-BZC5m_km.js} +1 -1
- package/dist/assets/LoadingImage-Csw4L-Dr.js +1 -0
- package/dist/assets/MarkdownRenderer-D_0iKhQN.js +2 -0
- package/dist/assets/MarkdownRendererImpl-BZ0XgjS0.js +10 -0
- package/dist/assets/MarkstreamRendererImpl-DBd6Glg9.js +3 -0
- package/dist/assets/MobileDetailNavigation-xgwvsQuR.js +1 -0
- package/dist/assets/{MobileResizableSheet-Dt2U0JHY.js → MobileResizableSheet-CQQ7O-2X.js} +1 -1
- package/dist/assets/MobileShareBridge-IO45gM2G.js +3 -0
- package/dist/assets/MobileSurface-DmYgZONB.js +2 -0
- package/dist/assets/{MultiRunWindow-BuRo90Ma.js → MultiRunWindow-fJ3XfntS.js} +1 -1
- package/dist/assets/OnboardingScreen-MJS5T5rL.js +1 -0
- package/dist/assets/{OverlayScrollbar-B0X61qR-.js → OverlayScrollbar-jtMYTn1y.js} +1 -1
- package/dist/assets/SettingsView-ZWFLpPSI.js +29 -0
- package/dist/assets/{SettingsWindow-kCbf8IoB.js → SettingsWindow-DGRmrIWz.js} +1 -1
- package/dist/assets/SetupTourDialog-BYbAubwA.js +1 -0
- package/dist/assets/TerminalView-CoJ6_9P1.js +8 -0
- package/dist/assets/ToolOutputDialog-5xBwOJ6a.js +16 -0
- package/dist/assets/VoiceSettings-CN33koSc.js +2 -0
- package/dist/assets/{YuriLogo-B58GIl2v.js → YuriLogo-CvyJy_R9.js} +1 -1
- package/dist/assets/YuriWordmark-DnFAS-Ko.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-DO1rEVQf.js → capgoAdapter-CCLtBZL1.js} +1 -1
- package/dist/assets/{checkbox-BW80bcK5.js → checkbox-rOV6DjeG.js} +1 -1
- package/dist/assets/client-uz8O6TPX.js +7 -0
- package/dist/assets/{collapsible-BOL5Wx2J.js → collapsible-CKswuqAw.js} +1 -1
- package/dist/assets/{context-menu-CiFnjP1q.js → context-menu-B4njwT_M.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-DRn8iIs1.js → diagram-BppQ_USn.js} +1 -1
- package/dist/assets/{dialog-DQp289fr.js → dialog-Bg8MJnOV.js} +1 -1
- package/dist/assets/{es-D0Q_CV0t.js → es-Ba3NUCtE.js} +3 -3
- package/dist/assets/{fileMentionTouchSelection-582p0uCX.js → fileMentionTouchSelection-D-AdTJVr.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-vYBmQIuU.js → gitApi-DVx_V1x6.js} +11 -7
- package/dist/assets/gitApiHttp-DvTBxvX8.js +3 -0
- package/dist/assets/historyImportQueries-D_9RlrLp.js +1 -0
- package/dist/assets/host-DrGjjO6K.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-B281XcMR.js → input-DRjuZMeA.js} +1 -1
- package/dist/assets/input-store-CjUOfpyA.js +1 -0
- package/dist/assets/insertionBoundaries-DZtQt2Ah.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-BMFY9mtb.js +2 -0
- package/dist/assets/main-D2s9J_jN.js +169 -0
- package/dist/assets/{markdownHeightCache-BgYJswDy.js → markdownHeightCache-BL99DlhC.js} +1 -1
- package/dist/assets/{markdownTheme-CHNl6tUv.js → markdownTheme-DFDWa8Gh.js} +1 -1
- package/dist/assets/mcpQueries-HzYMEVWd.js +1 -0
- package/dist/assets/miniChat-BbJ0GKpk.js +2 -0
- package/dist/assets/mobile-_zUth69Z.js +2 -0
- package/dist/assets/mobileBackNavigation--ZdrI-Yj.js +1 -0
- package/dist/assets/mobileConnections-C3eGEOPy.js +2 -0
- package/dist/assets/multirun-CDYNyLBH.js +3 -0
- package/dist/assets/{native-config-BOaqa45X.js → native-config-DOawZfln.js} +1 -1
- package/dist/assets/navigation-Ibk_Pw-q.js +2 -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-D1Ytss9U.js +1 -0
- package/dist/assets/prompt-attachment-upload-BNhDXymd.js +1 -0
- package/dist/assets/{pt-BR-fZW8CCVQ.js → pt-BR-C930XU1k.js} +3 -3
- package/dist/assets/pwa-CXupOTsD.js +2 -0
- package/dist/assets/queue-abort-optimistic-CQXpIlq6.js +1 -0
- package/dist/assets/{react-DPhQUTaH.js → react-CgRToPwO.js} +1 -1
- package/dist/assets/{readiness-BpVAjFhF.js → readiness-BfuZm6Yw.js} +2 -2
- package/dist/assets/relay-preview-frame-src-BPyz3nXA.js +1 -0
- package/dist/assets/remote-input-store-BOdCWpQY.js +1 -0
- package/dist/assets/remoteProjectQueries-CkxdZNw4.js +1 -0
- package/dist/assets/renderElectronMiniChatApp-pJ59iC34.js +2 -0
- package/dist/assets/renderMobileApp-BQFC-gOA.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-tHm7o_0I.js +2 -0
- package/dist/assets/{runtimeEndpointReset-BOdd_mJM.css → runtimeEndpointReset-BUGfn7y0.css} +1 -1
- package/dist/assets/runtimeEndpointReset-BhHWFNvo.js +150 -0
- package/dist/assets/safeStorage-DTOhKN0V.js +1 -0
- package/dist/assets/scheduledTaskNavigation-BIDtQ4wN.js +1 -0
- package/dist/assets/{select-CyPxbnW8.js → select-B1On-Y4Z.js} +1 -1
- package/dist/assets/sessionLookup-RcyTTDOy.js +1 -0
- package/dist/assets/sortable-tabs-strip-nD1Me06z.js +1 -0
- package/dist/assets/{speechSettingsQueries-CTsBn-Ib.js → speechSettingsQueries-BYhNpzDJ.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-madXrfqA.js +1 -0
- package/dist/assets/{textarea-CjJsstUF.js → textarea-Qt06OhhX.js} +1 -1
- package/dist/assets/{tooltip-Di_DSZ8p.js → tooltip-D382RCy1.js} +1 -1
- package/dist/assets/tour-CQMBn8gJ.js +1 -0
- package/dist/assets/{types-wnqkJWYs.js → types-CHszLAS3.js} +1 -1
- package/dist/assets/{uk-C4OKsNRv.js → uk-OXQSdzuT.js} +3 -3
- package/dist/assets/{useAppFontEffects-BRMf55oN.js → useAppFontEffects-CqXrCJVt.js} +63 -58
- package/dist/assets/useAppFontEffects-K31q-1OV.css +1 -0
- package/dist/assets/useAssistantUIStore-jOKVcBK8.js +1 -0
- package/dist/assets/useDesktopWindowControlsLayout-KH4UP7Gj.js +1 -0
- package/dist/assets/{useDictation-Sk20Gi0T.js → useDictation-Bs7TWO9r.js} +1 -1
- package/dist/assets/useEffectiveDirectory-CCKRdyK9.js +1 -0
- package/dist/assets/useFontPreferences-CPrl1_3z.js +1 -0
- package/dist/assets/{useMobileHtmlPreviewStore-C03uVLfX.js → useMobileHtmlPreviewStore-EOAzZiAy.js} +1 -1
- package/dist/assets/useMobileNavigationStore-BNtVrnSw.js +13 -0
- package/dist/assets/usePluginsStore-bMuGciUE.js +1 -0
- package/dist/assets/useProjectRuntimeAPIs-BFCXBu2J.js +1 -0
- package/dist/assets/{useStreamingTextThrottle-CjMALEr7.js → useStreamingTextThrottle-C8xAqcgP.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-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-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 +35 -5
- package/server/lib/assistants/builtin-skills.js +1 -1
- package/server/lib/assistants/builtin-skills.test.js +2 -0
- 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 +25 -1
- package/server/lib/gui-customization/projects-client.mjs +59 -0
- package/server/lib/gui-customization/projects.js +43 -0
- package/server/lib/gui-customization/projects.test.js +103 -0
- package/server/lib/gui-customization/remote-connections-client.mjs +2 -8
- package/server/lib/gui-customization/session-skill-command.mjs +8 -0
- package/server/lib/gui-customization/session-skill.js +15 -10
- package/server/lib/gui-customization/session-skill.test.js +21 -2
- package/server/lib/gui-customization/skill/SKILL.md +3 -1
- package/server/lib/gui-customization/skill/references/projects.md +63 -0
- package/server/lib/gui-customization/skill/references/remote-connections.md +11 -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/DOCUMENTATION.md +12 -0
- package/server/lib/notifications/emitter-runtime.js +5 -0
- package/server/lib/notifications/runtime.js +20 -2
- package/server/lib/notifications/runtime.test.js +21 -0
- package/server/lib/notifications/session-unread-runtime.js +51 -13
- package/server/lib/notifications/session-unread.test.js +113 -1
- package/server/lib/opencode/DOCUMENTATION.md +28 -0
- package/server/lib/opencode/core-routes.js +16 -3
- package/server/lib/opencode/core-routes.test.js +28 -0
- package/server/lib/opencode/feature-routes-runtime.js +12 -1
- package/server/lib/opencode/feature-routes-runtime.test.js +4 -0
- 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/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 +12 -3
- package/server/lib/relay/tunnel-host.js +1 -0
- package/server/lib/remote-hosts/DOCUMENTATION.md +269 -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 +644 -0
- package/server/lib/remote-hosts/json-lifecycle.test.js +55 -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 +432 -0
- package/server/lib/remote-hosts/routes.test.js +1176 -0
- package/server/lib/remote-hosts/settings-production.test.js +145 -0
- package/server/lib/remote-hosts/store.js +110 -0
- package/server/lib/remote-hosts/store.test.js +33 -0
- package/server/lib/remote-hosts/transport.js +113 -0
- package/server/lib/scheduled-tasks/session-skill.js +2 -1
- package/server/lib/scheduled-tasks/session-skill.test.js +34 -1
- package/server/lib/session-folders/routes.js +1 -0
- package/server/lib/session-index/DOCUMENTATION.md +4 -1
- package/server/lib/session-index/event-ingest.js +8 -0
- package/server/lib/session-index/event-ingest.test.js +16 -0
- package/server/lib/session-index/service.js +1 -0
- package/server/lib/session-index/service.test.js +3 -1
- package/server/lib/session-metadata/DOCUMENTATION.md +18 -1
- package/server/lib/session-title/DOCUMENTATION.md +3 -0
- package/server/lib/session-title/runtime.js +1 -0
- package/server/lib/session-title/runtime.test.js +2 -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-CW3U6Lhp.js +0 -3
- package/dist/assets/DiagramView-CzhdZEw4.js +0 -1
- package/dist/assets/GuiPluginSurface-BG3hENTt.js +0 -1
- package/dist/assets/LoadingImage-DmucvXdY.js +0 -1
- package/dist/assets/MarkdownRenderer-BkOMcK8x.js +0 -2
- package/dist/assets/MarkdownRendererImpl-B5vJtPoa.js +0 -10
- package/dist/assets/MarkstreamRendererImpl-1J-Gu2M2.js +0 -3
- package/dist/assets/MobileDetailNavigation-48o8aG28.js +0 -1
- package/dist/assets/MobileShareBridge-DnYT3Dbz.js +0 -3
- package/dist/assets/MobileTabPageHeader-D6kqRFm0.js +0 -2
- package/dist/assets/OnboardingScreen-Bn0RgrJU.js +0 -1
- package/dist/assets/SettingsView-Bla2lVqS.js +0 -29
- package/dist/assets/SetupTourDialog-GDRS3gDa.js +0 -1
- package/dist/assets/TerminalView-B1u3s7IN.js +0 -8
- package/dist/assets/ToolOutputDialog-CYUPmbtq.js +0 -10
- package/dist/assets/VoiceSettings-Dy6-nkQo.js +0 -2
- package/dist/assets/YuriWordmark--S-QEpRp.js +0 -1
- package/dist/assets/appThemeRegistry--G1XaYmo.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-CB4gv9rr.js +0 -1
- package/dist/assets/main-B1KrAdkh.js +0 -2
- package/dist/assets/main-Caf-6KmT.js +0 -169
- package/dist/assets/mcpQueries-CQyOFjX2.js +0 -1
- package/dist/assets/miniChat-zEoOVjOQ.js +0 -2
- package/dist/assets/mobile-Dt8wAkc4.js +0 -2
- package/dist/assets/mobileBackNavigation-BbKMa0Jb.js +0 -1
- package/dist/assets/mobileConnections-CXYj4P9M.js +0 -2
- package/dist/assets/multirun-9v2r_beX.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-ZouOo-T_.js +0 -1
- package/dist/assets/pwa-syKJBLoe.js +0 -2
- package/dist/assets/queue-abort-optimistic-BYH5yLM2.js +0 -1
- package/dist/assets/renderElectronMiniChatApp-DprABvit.js +0 -2
- package/dist/assets/renderMobileApp-DQmX6iak.js +0 -29
- package/dist/assets/runtime-file-resource-CL7EVzOG.js +0 -2
- package/dist/assets/runtimeConfig-7Umh9QWi.js +0 -2
- package/dist/assets/runtimeEndpointReset-BYtLmSuX.js +0 -149
- package/dist/assets/scheduledTaskNavigation-FMDNRUnX.js +0 -1
- package/dist/assets/sessionLookup-D_fPlqqT.js +0 -1
- package/dist/assets/sortable-tabs-strip-BclS0Hnd.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-Bq9DFNYn.js +0 -1
- package/dist/assets/useEffectiveDirectory-5RwQ_nuK.js +0 -1
- package/dist/assets/useFontPreferences-DxzruDDQ.js +0 -1
- package/dist/assets/useMobileNavigationStore-ePbEoQwb.js +0 -17
- package/dist/assets/usePluginsStore-HJJZ65gd.js +0 -1
- package/dist/assets/useUIStore-vvNwcOk3.js +0 -1
- package/dist/assets/useWorkerHighlightedLines-6x1R4afJ.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
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
});
|
|
@@ -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,432 @@
|
|
|
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
|
+
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)
|
|
28
|
+
|| /^\/api\/yuri\/(session|session-index|session-unread|session-folders|session-order|message-queue|content-search|events)(\/|$)/.test(pathname);
|
|
29
|
+
};
|
|
30
|
+
const report = (res, error) => {
|
|
31
|
+
if (res.headersSent) return res.destroy();
|
|
32
|
+
const code = error?.code || 'remote_unavailable';
|
|
33
|
+
// Transport failures may contain URL credentials or content. Never serialize
|
|
34
|
+
// arbitrary upstream Error.message or log the request/response body.
|
|
35
|
+
const allowed = new Set(['remote_incompatible', 'remote_authorization_required', 'host_unavailable',
|
|
36
|
+
'project_not_found', 'validation_error', 'stale_host', 'subscription_not_found', 'content_capacity', 'remote_request_failed',
|
|
37
|
+
'remote_ssh_authentication_failed', 'remote_ssh_unavailable', 'remote_relay_unavailable', 'remote_service_starting']);
|
|
38
|
+
const publicCode = allowed.has(code) ? code : 'remote_unavailable';
|
|
39
|
+
return res.status(error?.status || 503).json({ code: publicCode, error: publicCode,
|
|
40
|
+
retryable: ![401, 403, 404, 409].includes(error?.status),
|
|
41
|
+
...(publicCode === 'remote_incompatible' ? { minimumVersion: { remoteProjectsProtocol: 1, opencode: RUNTIME_CONTRACT_MIN_VERIFIED } } : {}) });
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export function registerRemoteHostRoutes(app, { gateway, getAuth, server, isRequestOriginAllowed,
|
|
45
|
+
remoteClientAuthRuntime, readSettings, persistSettings, validateDirectoryPath,
|
|
46
|
+
globalEventHub, broadcaster, supportedRemote = false, version = 'unknown', getOpenCodeCompatibility = () => null }) {
|
|
47
|
+
const store = gateway.store;
|
|
48
|
+
const registry = createProjectRegistry({ persistSettings, validateDirectoryPath });
|
|
49
|
+
const jsonParser = express.json({ limit: '1mb' });
|
|
50
|
+
const parseMutation = (req, res, next) => jsonParser(req, res, (error) => {
|
|
51
|
+
if (error) return res.status(400).json({ code: 'validation_error', error: 'Invalid project mutation payload' });
|
|
52
|
+
next();
|
|
53
|
+
});
|
|
54
|
+
const resources = new Map();
|
|
55
|
+
const tracked = new Set();
|
|
56
|
+
const authorizedResources = new Map();
|
|
57
|
+
const expirations = new Map();
|
|
58
|
+
const expiryTimers = new Map();
|
|
59
|
+
const closeOwner = (owner) => {
|
|
60
|
+
for (const [resource, id] of authorizedResources) if (id === owner) authorizedResources.delete(resource);
|
|
61
|
+
for (const close of [...(resources.get(owner) || [])]) close();
|
|
62
|
+
gateway.releaseOwner(owner);
|
|
63
|
+
};
|
|
64
|
+
const armExpiry = (owner, force = false) => {
|
|
65
|
+
if (expiryTimers.has(owner) || (!force && !store.projects().length) || !expirations.get(owner)) return;
|
|
66
|
+
const delay = Math.max(0, expirations.get(owner) - Date.now());
|
|
67
|
+
const timer = setTimeout(() => {
|
|
68
|
+
expiryTimers.delete(owner);
|
|
69
|
+
if (expirations.get(owner) <= Date.now()) closeOwner(owner);
|
|
70
|
+
else armExpiry(owner, force);
|
|
71
|
+
}, Math.min(delay, 2147483647));
|
|
72
|
+
timer.unref?.(); expiryTimers.set(owner, timer);
|
|
73
|
+
};
|
|
74
|
+
const authorize = async (req, res, { aggregate = true } = {}) => {
|
|
75
|
+
const clientRequest = Object.create(req);
|
|
76
|
+
clientRequest.headers = { ...req.headers };
|
|
77
|
+
delete clientRequest.headers.cookie;
|
|
78
|
+
const auth = await getAuth()?.resolveAuthContext(clientRequest, res);
|
|
79
|
+
// A password-less browser cookie is not a pairing grant. Native local
|
|
80
|
+
// clients use a real server-issued desktop-local credential as well.
|
|
81
|
+
if (auth?.type !== 'client' || !auth.clientId) throw remoteFailure('remote_authorization_required', 401);
|
|
82
|
+
const client = auth.client || (await remoteClientAuthRuntime?.listClients?.())?.find((entry) => entry.id === auth.clientId);
|
|
83
|
+
if (!client) throw remoteFailure('remote_authorization_required', 401);
|
|
84
|
+
if (client.revokedAt || (client.expiresAt && Date.parse(client.expiresAt) <= Date.now())) throw remoteFailure('remote_authorization_required', 401);
|
|
85
|
+
if (aggregate && client.clientKind !== 'desktop-local'
|
|
86
|
+
&& !(client.authMethod === 'pairing' && client.pairingId && ['desktop', 'mobile'].includes(client.clientKind))) {
|
|
87
|
+
throw remoteFailure('remote_authorization_required', 403);
|
|
88
|
+
}
|
|
89
|
+
if (client.expiresAt) expirations.set(auth.clientId, Date.parse(client.expiresAt));
|
|
90
|
+
return auth.clientId;
|
|
91
|
+
};
|
|
92
|
+
const retainResource = (owner, close) => {
|
|
93
|
+
let entries = resources.get(owner);
|
|
94
|
+
if (!entries) { entries = new Set(); resources.set(owner, entries); }
|
|
95
|
+
entries.add(close);
|
|
96
|
+
armExpiry(owner);
|
|
97
|
+
return () => {
|
|
98
|
+
entries.delete(close);
|
|
99
|
+
if (!entries.size) {
|
|
100
|
+
resources.delete(owner); clearTimeout(expiryTimers.get(owner)); expiryTimers.delete(owner);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
const track = (req, res, owner) => {
|
|
105
|
+
if (tracked.has(res)) return;
|
|
106
|
+
tracked.add(res);
|
|
107
|
+
authorizedResources.set(res, owner);
|
|
108
|
+
const release = gateway.observe(res, owner);
|
|
109
|
+
const remove = retainResource(owner, () => res.destroy());
|
|
110
|
+
res.once('close', () => { tracked.delete(res); authorizedResources.delete(res); release(); remove(); });
|
|
111
|
+
};
|
|
112
|
+
const revoke = remoteClientAuthRuntime?.subscribeRevocation?.((id) => {
|
|
113
|
+
closeOwner(id);
|
|
114
|
+
}) || (() => {});
|
|
115
|
+
// This is the already-existing client -> Hub stream, not a new socket per host.
|
|
116
|
+
app.use((req, res, next) => {
|
|
117
|
+
if (!/^\/api\/(global\/event|event)(?:\?|$)/.test(req.originalUrl || req.url)) return next();
|
|
118
|
+
const writeHead = res.writeHead;
|
|
119
|
+
res.writeHead = function (...args) {
|
|
120
|
+
const result = writeHead.apply(this, args);
|
|
121
|
+
if (this.statusCode === 200) void authorize(req, res).then((owner) => {
|
|
122
|
+
if (!res.destroyed && !res.writableEnded) track(req, res, owner);
|
|
123
|
+
}).catch(() => {});
|
|
124
|
+
return result;
|
|
125
|
+
};
|
|
126
|
+
next();
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
// Local-only directory authority. Returning only local projects prevents
|
|
130
|
+
// A -> B from silently aggregating B -> C and prevents cycles.
|
|
131
|
+
app.get('/api/projects', async (_req, res) => {
|
|
132
|
+
try { res.json({ projects: (await readSettings()).projects?.filter((p) => !p.hostId) || [] }); }
|
|
133
|
+
catch (error) { report(res, error); }
|
|
134
|
+
});
|
|
135
|
+
app.post('/api/projects', async (req, res) => {
|
|
136
|
+
try {
|
|
137
|
+
await authorize(req, res, { aggregate: false });
|
|
138
|
+
const result = await registry.register({ ...req.body, activate: false });
|
|
139
|
+
app.emit('yuri:projects-changed');
|
|
140
|
+
res.json({ project: result.project, created: result.created });
|
|
141
|
+
} catch (error) { report(res, error); }
|
|
142
|
+
});
|
|
143
|
+
app.patch('/api/projects/:id', async (req, res) => {
|
|
144
|
+
try {
|
|
145
|
+
await authorize(req, res, { aggregate: false });
|
|
146
|
+
let project;
|
|
147
|
+
const settings = await persistSettings((current) => ({ projects: (current.projects || []).map((entry) => {
|
|
148
|
+
if (entry.id !== req.params.id || entry.hostId) return entry;
|
|
149
|
+
project = { ...entry, ...projectMetadata(req.body) }; return project;
|
|
150
|
+
}) }));
|
|
151
|
+
project = settings.projects?.find((p) => p.id === req.params.id);
|
|
152
|
+
if (!project) throw remoteFailure('project_not_found', 404);
|
|
153
|
+
app.emit('yuri:projects-changed');
|
|
154
|
+
res.json({ project });
|
|
155
|
+
} catch (error) { report(res, error); }
|
|
156
|
+
});
|
|
157
|
+
app.get('/api/hosts/capabilities', async (req, res) => {
|
|
158
|
+
try {
|
|
159
|
+
await authorize(req, res, { aggregate: false });
|
|
160
|
+
res.json({ remoteProjects: supportedRemote, protocol: 1, instanceId: store.hubId, version,
|
|
161
|
+
opencode: getOpenCodeCompatibility() });
|
|
162
|
+
} catch (error) { report(res, error); }
|
|
163
|
+
});
|
|
164
|
+
app.get('/api/hosts/status-stream', async (req, res) => {
|
|
165
|
+
try {
|
|
166
|
+
const owner = await authorize(req, res, { aggregate: false });
|
|
167
|
+
res.status(200).set({ 'Content-Type': 'text/event-stream', 'Cache-Control': 'no-store', 'X-Accel-Buffering': 'no' });
|
|
168
|
+
res.flushHeaders();
|
|
169
|
+
const send = (event) => {
|
|
170
|
+
let payload = projectRemoteStatusEvent(event.payload || event);
|
|
171
|
+
if (!payload) return;
|
|
172
|
+
if (payload.type === 'yuri:notification') payload = { type: payload.type, properties: {
|
|
173
|
+
sessionID: payload.properties?.sessionID, sessionId: payload.properties?.sessionId,
|
|
174
|
+
title: payload.properties?.title, kind: payload.properties?.kind, tag: payload.properties?.tag,
|
|
175
|
+
directory: payload.properties?.directory, event: payload.properties?.event,
|
|
176
|
+
instanceId: payload.properties?.instanceId || store.hubId } };
|
|
177
|
+
const frame = `data: ${JSON.stringify({ directory: event.directory || payload.properties?.directory || 'global', payload })}\n\n`;
|
|
178
|
+
if (res.writableLength > 256 * 1024) return res.destroy();
|
|
179
|
+
res.write(frame);
|
|
180
|
+
};
|
|
181
|
+
const unsubscribeNative = globalEventHub.subscribeEvent(send);
|
|
182
|
+
const unsubscribeYuri = broadcaster.subscribe((payload, options) => send({ payload, directory: options?.directory }));
|
|
183
|
+
const projectsChanged = () => send({ type: 'yuri:projects-changed', properties: {} });
|
|
184
|
+
app.on('yuri:projects-changed', projectsChanged);
|
|
185
|
+
const heartbeat = setInterval(() => res.write(': heartbeat\n\n'), 1000);
|
|
186
|
+
const remove = retainResource(owner, () => res.destroy());
|
|
187
|
+
armExpiry(owner, true);
|
|
188
|
+
res.once('close', () => { clearInterval(heartbeat); unsubscribeNative(); unsubscribeYuri(); remove(); app.off('yuri:projects-changed', projectsChanged); });
|
|
189
|
+
res.write(': ready\n\n');
|
|
190
|
+
} catch (error) { report(res, error); }
|
|
191
|
+
});
|
|
192
|
+
app.get('/api/hosts', (_req, res, next) => {
|
|
193
|
+
if (gateway.supported) return next();
|
|
194
|
+
res.json({ supported: false, hubId: store.hubId, hosts: [], projects: [], reason: 'pc_hub_required' });
|
|
195
|
+
});
|
|
196
|
+
app.use('/api/hosts', async (req, res, next) => {
|
|
197
|
+
try {
|
|
198
|
+
req.remoteHostOwner = await authorize(req, res);
|
|
199
|
+
const operation = new AbortController();
|
|
200
|
+
req.remoteHostSignal = operation.signal;
|
|
201
|
+
const remove = retainResource(req.remoteHostOwner, () => {
|
|
202
|
+
operation.abort();
|
|
203
|
+
if (!res.headersSent) res.status(401).json({ code: 'remote_authorization_required', error: 'remote_authorization_required' });
|
|
204
|
+
else res.destroy();
|
|
205
|
+
});
|
|
206
|
+
const release = gateway.observe(res, req.remoteHostOwner, { status: false });
|
|
207
|
+
const hostMatch = /^\/api\/hosts\/([^/]+)(?:\/|$)/.exec(req.originalUrl);
|
|
208
|
+
const priority = /\/api\/session(?:\/|\?)/.test(req.originalUrl)
|
|
209
|
+
|| (req.method !== 'GET' && req.method !== 'HEAD');
|
|
210
|
+
const releaseHost = hostMatch ? gateway.retainHost(decodeURIComponent(hostMatch[1]), res, priority) : () => {};
|
|
211
|
+
res.once('close', () => { operation.abort(); release(); releaseHost(); remove(); });
|
|
212
|
+
res.setHeader('Cache-Control', 'private, no-store');
|
|
213
|
+
next();
|
|
214
|
+
} catch (error) { report(res, error); }
|
|
215
|
+
});
|
|
216
|
+
app.get('/api/hosts', async (_req, res) => {
|
|
217
|
+
try { res.json(await gateway.list()); } catch (error) { report(res, error); }
|
|
218
|
+
});
|
|
219
|
+
app.get('/api/hosts/projects', (_req, res) => res.json({ projects: store.projects() }));
|
|
220
|
+
app.get('/api/hosts/:hostId/summaries', (req, res) => {
|
|
221
|
+
try { res.json(gateway.summaries(req.params.hostId)); } catch (error) { report(res, error); }
|
|
222
|
+
});
|
|
223
|
+
app.post('/api/hosts/:hostId/connect', async (req, res) => {
|
|
224
|
+
try { res.json({ host: await gateway.connect(req.params.hostId) }); } catch (error) { report(res, error); }
|
|
225
|
+
});
|
|
226
|
+
app.post('/api/hosts/:hostId/projects', parseMutation, async (req, res) => {
|
|
227
|
+
try {
|
|
228
|
+
const remote = await gateway.json(req.params.hostId, '/api/projects', { method: 'POST',
|
|
229
|
+
signal: req.remoteHostSignal,
|
|
230
|
+
headers: { 'content-type': 'application/json' }, body: JSON.stringify({ path: req.body?.path, label: req.body?.label }) });
|
|
231
|
+
if (req.remoteHostSignal.aborted) throw remoteFailure('remote_authorization_required', 401);
|
|
232
|
+
if (!remote.project?.id || !remote.project?.path || remote.project.hostId) throw remoteFailure('remote_invalid_project');
|
|
233
|
+
const existed = store.projects(req.params.hostId).some((p) => p.path === remote.project.path);
|
|
234
|
+
const project = store.saveProject(req.params.hostId, remote.project);
|
|
235
|
+
for (const owner of resources.keys()) armExpiry(owner);
|
|
236
|
+
gateway.projectReferencesChanged(req.params.hostId);
|
|
237
|
+
if (!existed) broadcaster({ type: 'yuri:project-order-changed', properties: { occurredAt: Date.now() } });
|
|
238
|
+
res.json({ project, created: !existed });
|
|
239
|
+
} catch (error) { report(res, error); }
|
|
240
|
+
});
|
|
241
|
+
app.patch('/api/hosts/:hostId/projects/:projectId', parseMutation, async (req, res) => {
|
|
242
|
+
try {
|
|
243
|
+
const project = store.projects(req.params.hostId).find((p) => p.id === req.params.projectId);
|
|
244
|
+
if (!project) throw remoteFailure('project_not_found', 404);
|
|
245
|
+
const remote = await gateway.json(req.params.hostId, `/api/projects/${encodeURIComponent(project.remoteProjectId)}`,
|
|
246
|
+
{ method: 'PATCH', signal: req.remoteHostSignal, headers: { 'content-type': 'application/json' }, body: JSON.stringify(projectMetadata(req.body)) });
|
|
247
|
+
if (req.remoteHostSignal.aborted) throw remoteFailure('remote_authorization_required', 401);
|
|
248
|
+
const refreshed = store.refreshProject(project, remote.project);
|
|
249
|
+
if (!refreshed) throw remoteFailure('project_not_found', 404);
|
|
250
|
+
res.json({ project: refreshed });
|
|
251
|
+
} catch (error) { report(res, error); }
|
|
252
|
+
});
|
|
253
|
+
app.delete('/api/hosts/:hostId/projects/:projectId', (req, res) => {
|
|
254
|
+
const removed = store.removeProject(req.params.hostId, req.params.projectId);
|
|
255
|
+
if (removed) broadcaster({ type: 'yuri:project-order-changed', properties: { occurredAt: Date.now() } });
|
|
256
|
+
gateway.projectReferencesChanged(req.params.hostId); res.status(204).end();
|
|
257
|
+
});
|
|
258
|
+
app.post('/api/hosts/:hostId/subscriptions', parseMutation, async (req, res) => {
|
|
259
|
+
let lease;
|
|
260
|
+
try {
|
|
261
|
+
lease = await gateway.subscribe(req.params.hostId, req.body, req.remoteHostOwner);
|
|
262
|
+
await authorize(req, res);
|
|
263
|
+
if (res.destroyed || req.aborted) throw remoteFailure('remote_authorization_required', 401);
|
|
264
|
+
res.json(lease);
|
|
265
|
+
}
|
|
266
|
+
catch (error) {
|
|
267
|
+
if (lease) { try { gateway.release(req.params.hostId, lease.id, req.remoteHostOwner); } catch { /* Revocation may already have removed it. */ } }
|
|
268
|
+
report(res, error);
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
app.delete('/api/hosts/:hostId/subscriptions/:id', (req, res) => {
|
|
272
|
+
try { gateway.release(req.params.hostId, req.params.id, req.remoteHostOwner); res.status(204).end(); }
|
|
273
|
+
catch (error) { report(res, error); }
|
|
274
|
+
});
|
|
275
|
+
app.post('/api/hosts/:hostId/api/preview/targets', parseMutation, (req, res, next) => {
|
|
276
|
+
try {
|
|
277
|
+
if (req.body?.kind === 'file') {
|
|
278
|
+
const directory = gateway.assertProjectDirectory(req.params.hostId, req.body.directory);
|
|
279
|
+
req.body = { ...req.body, directory };
|
|
280
|
+
}
|
|
281
|
+
next();
|
|
282
|
+
} catch (error) { report(res, error); }
|
|
283
|
+
});
|
|
284
|
+
app.delete('/api/hosts/:hostId/api/preview/targets/:id', parseMutation, (_req, _res, next) => next());
|
|
285
|
+
app.use('/api/hosts/:hostId', async (req, res) => {
|
|
286
|
+
const controller = new AbortController();
|
|
287
|
+
const abort = () => controller.abort();
|
|
288
|
+
res.once('close', abort);
|
|
289
|
+
const remove = retainResource(req.remoteHostOwner, () => { controller.abort(); res.destroy(); });
|
|
290
|
+
try {
|
|
291
|
+
const route = req.url;
|
|
292
|
+
if (!safeRoute(route, req.method)) return res.status(403).json({ code: 'remote_scope_forbidden', error: 'remote_scope_forbidden' });
|
|
293
|
+
const url = new URL(route, 'http://remote.invalid');
|
|
294
|
+
if (url.pathname.startsWith('/api/preview/proxy/') && url.pathname.includes('/_file/')) {
|
|
295
|
+
if (!parseFilePreviewPath(url.pathname) || !['GET', 'HEAD'].includes(req.method)) {
|
|
296
|
+
return res.status(403).json({ code: 'remote_scope_forbidden', error: 'remote_scope_forbidden' });
|
|
297
|
+
}
|
|
298
|
+
url.pathname = replaceFilePreviewUrlAuthToken(url.pathname, '-');
|
|
299
|
+
}
|
|
300
|
+
for (const key of ['yuri_url_token', 'oc_client_token']) url.searchParams.delete(key);
|
|
301
|
+
const headers = {};
|
|
302
|
+
const hostPrefix = `/api/hosts/${encodeURIComponent(req.params.hostId)}`;
|
|
303
|
+
const preview = url.pathname.startsWith('/api/preview/');
|
|
304
|
+
const previewAuth = preview ? await getAuth().issueClientUrlToken(req) : null;
|
|
305
|
+
if (preview) headers['x-yuri-preview-hub-prefix'] = hostPrefix;
|
|
306
|
+
for (const name of ['accept', 'content-type', 'x-opencode-directory', 'x-opencode-directory-encoding',
|
|
307
|
+
'last-event-id', 'range', 'if-none-match', 'x-yuri-gui-revision',
|
|
308
|
+
'x-yuri-content-length', 'x-yuri-sha256', 'x-yuri-mime', 'x-yuri-filename']) if (typeof req.headers[name] === 'string') headers[name] = req.headers[name];
|
|
309
|
+
const init = { method: req.method, headers, signal: controller.signal };
|
|
310
|
+
if (!['GET', 'HEAD'].includes(req.method)) {
|
|
311
|
+
if (req.body !== undefined) init.body = JSON.stringify(req.body);
|
|
312
|
+
else { init.body = Readable.toWeb(req); init.duplex = 'half'; }
|
|
313
|
+
}
|
|
314
|
+
const streaming = preview || init.duplex === 'half'
|
|
315
|
+
|| /^\/api\/fs\/(raw|serve)(\/|$)/.test(url.pathname)
|
|
316
|
+
|| /^\/api\/terminal\/[^/]+\/stream$/.test(url.pathname)
|
|
317
|
+
|| url.pathname === '/api/yuri/events';
|
|
318
|
+
const response = await gateway.request(req.params.hostId, `${url.pathname}${url.search}`, init, {
|
|
319
|
+
streaming, longRunning: streaming || !['GET', 'HEAD'].includes(req.method),
|
|
320
|
+
});
|
|
321
|
+
res.status(response.status);
|
|
322
|
+
const location = response.headers.get('location');
|
|
323
|
+
if (location) {
|
|
324
|
+
const target = new URL(location, `http://remote.invalid${url.pathname}`);
|
|
325
|
+
if (target.origin !== 'http://remote.invalid') throw remoteFailure('remote_redirect_forbidden', 502);
|
|
326
|
+
const scoped = target.pathname.startsWith(`${hostPrefix}/`) ? target.pathname : `${hostPrefix}${target.pathname}`;
|
|
327
|
+
res.setHeader('Location', `${scoped}${target.search}${target.hash}`.replaceAll(REMOTE_PREVIEW_TOKEN_MARKER, previewAuth?.token || ''));
|
|
328
|
+
}
|
|
329
|
+
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']) {
|
|
330
|
+
const value = response.headers.get(name); if (value) res.setHeader(name, value);
|
|
331
|
+
}
|
|
332
|
+
if (/^\/api\/(config|provider|plugin|mcp|agent)(\/|$)/.test(url.pathname)
|
|
333
|
+
&& (response.headers.get('content-type') || '').includes('application/json')) {
|
|
334
|
+
return res.json(projectRemoteConfiguration(await response.json()));
|
|
335
|
+
}
|
|
336
|
+
const textualPreview = preview && /text\/|javascript|ecmascript|application\/json/.test(response.headers.get('content-type') || '');
|
|
337
|
+
const body = textualPreview && response.body ? replacePreviewToken(response.body, previewAuth?.token || '') : response.body;
|
|
338
|
+
if (body) for await (const chunk of body) {
|
|
339
|
+
if (controller.signal.aborted) break;
|
|
340
|
+
if (!res.write(chunk)) await once(res, 'drain', { signal: controller.signal });
|
|
341
|
+
}
|
|
342
|
+
res.end();
|
|
343
|
+
} catch (error) { if (!controller.signal.aborted) report(res, error); }
|
|
344
|
+
finally { remove(); res.off('close', abort); }
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
const wss = new WebSocketServer({ noServer: true, maxPayload: 1024 * 1024 });
|
|
348
|
+
const onUpgrade = async (req, socket, head) => {
|
|
349
|
+
const url = new URL(req.url, 'http://hub.invalid');
|
|
350
|
+
const match = /^\/api\/hosts\/([^/]+)(\/api\/.*)$/.exec(url.pathname);
|
|
351
|
+
if (!match) {
|
|
352
|
+
if (url.pathname === '/api/global/event/ws') {
|
|
353
|
+
try {
|
|
354
|
+
const owner = await authorize(req, null);
|
|
355
|
+
authorizedResources.set(socket, owner);
|
|
356
|
+
const release = gateway.observe(socket, owner);
|
|
357
|
+
const remove = retainResource(owner, () => socket.destroy());
|
|
358
|
+
socket.once('close', () => { authorizedResources.delete(socket); release(); remove(); });
|
|
359
|
+
} catch { /* Existing message stream handler owns its authentication. */ }
|
|
360
|
+
}
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
let upstream;
|
|
364
|
+
let downstream;
|
|
365
|
+
const pendingFrames = [];
|
|
366
|
+
let pendingBytes = 0;
|
|
367
|
+
let admissionFailed = false;
|
|
368
|
+
let removeResource = () => {};
|
|
369
|
+
try {
|
|
370
|
+
if (!websocketPath(match[2]) || !await isRequestOriginAllowed(req)) throw remoteFailure('remote_authorization_required', 403);
|
|
371
|
+
if (match[2].startsWith('/api/preview/proxy/') && match[2].includes('/_file/')) throw remoteFailure('remote_authorization_required', 403);
|
|
372
|
+
const owner = await authorize(req, null);
|
|
373
|
+
removeResource = retainResource(owner, () => { socket.destroy(); upstream?.close(); });
|
|
374
|
+
const release = gateway.observe(socket, owner);
|
|
375
|
+
const releaseHost = gateway.retainHost(decodeURIComponent(match[1]), socket);
|
|
376
|
+
socket.once('close', () => { admissionFailed = true; pendingFrames.length = 0; upstream?.close(); removeResource(); release(); releaseHost(); });
|
|
377
|
+
url.searchParams.delete('yuri_url_token');
|
|
378
|
+
const protocols = typeof req.headers['sec-websocket-protocol'] === 'string'
|
|
379
|
+
? req.headers['sec-websocket-protocol'].split(',').map((value) => value.trim()).filter(Boolean) : [];
|
|
380
|
+
upstream = await gateway.openWebSocket(decodeURIComponent(match[1]), `${match[2]}${url.search}`, protocols, {
|
|
381
|
+
onMessage: ({ data }) => {
|
|
382
|
+
if (admissionFailed) return;
|
|
383
|
+
if (downstream?.readyState === 1) { downstream.send(data); return; }
|
|
384
|
+
pendingBytes += Buffer.byteLength(data);
|
|
385
|
+
if (pendingBytes > 1024 * 1024 || pendingFrames.length >= 256) {
|
|
386
|
+
admissionFailed = true; pendingFrames.length = 0; upstream?.close();
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
pendingFrames.push(data);
|
|
390
|
+
},
|
|
391
|
+
});
|
|
392
|
+
if (socket.destroyed || admissionFailed) throw remoteFailure('remote_authorization_required', 401);
|
|
393
|
+
await new Promise((resolve, reject) => {
|
|
394
|
+
if (upstream.readyState === 1) return resolve();
|
|
395
|
+
if (upstream.readyState !== 0) return reject(remoteFailure('remote_unavailable'));
|
|
396
|
+
const timer = setTimeout(() => { upstream.close(); reject(remoteFailure('remote_unavailable')); }, 15000);
|
|
397
|
+
upstream.onopen = () => { clearTimeout(timer); resolve(); };
|
|
398
|
+
upstream.onerror = upstream.onclose = () => { clearTimeout(timer); reject(remoteFailure('remote_unavailable')); };
|
|
399
|
+
});
|
|
400
|
+
await authorize(req, null);
|
|
401
|
+
if (socket.destroyed || admissionFailed || upstream.readyState !== 1) throw remoteFailure('remote_authorization_required', 401);
|
|
402
|
+
wss.handleUpgrade(req, socket, head, (client) => {
|
|
403
|
+
downstream = client;
|
|
404
|
+
upstream.onclose = () => client.close();
|
|
405
|
+
upstream.onerror = () => client.close(1011);
|
|
406
|
+
client.on('message', (data, binary) => {
|
|
407
|
+
if (upstream.readyState === 1) upstream.send(binary ? data : data.toString());
|
|
408
|
+
});
|
|
409
|
+
client.once('close', () => { upstream.close(); removeResource(); });
|
|
410
|
+
for (const data of pendingFrames) client.send(data);
|
|
411
|
+
pendingFrames.length = 0; pendingBytes = 0;
|
|
412
|
+
});
|
|
413
|
+
} catch {
|
|
414
|
+
admissionFailed = true; pendingFrames.length = 0;
|
|
415
|
+
upstream?.close(); removeResource();
|
|
416
|
+
if (!socket.destroyed) socket.end('HTTP/1.1 403 Forbidden\r\nConnection: close\r\n\r\n');
|
|
417
|
+
}
|
|
418
|
+
};
|
|
419
|
+
server.on('upgrade', onUpgrade);
|
|
420
|
+
return {
|
|
421
|
+
canReceiveHostEvents(resource) {
|
|
422
|
+
const owner = authorizedResources.get(resource) || authorizedResources.get(resource?._socket);
|
|
423
|
+
return Boolean(owner && (!expirations.has(owner) || expirations.get(owner) > Date.now()));
|
|
424
|
+
},
|
|
425
|
+
stop() {
|
|
426
|
+
revoke(); server.off('upgrade', onUpgrade);
|
|
427
|
+
for (const timer of expiryTimers.values()) clearTimeout(timer);
|
|
428
|
+
authorizedResources.clear();
|
|
429
|
+
for (const entries of resources.values()) for (const close of [...entries]) close();
|
|
430
|
+
wss.close(); gateway.stop();
|
|
431
|
+
} };
|
|
432
|
+
}
|