@pi-chamber/web 1.0.7 → 1.0.8-rc.2
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/AgentsSurface-CcWBqAWV.js +1 -0
- package/dist/assets/ChoicesArtifact-Kk-qvrSB.js +1 -0
- package/dist/assets/DiagramView-DZUBo1uP.js +1 -0
- package/dist/assets/{DiffView-BxW6BuOC.js → DiffView-CiZy4jFA.js} +6 -6
- package/dist/assets/FileSaveConflictDialog-DZ9NDwOO.js +3 -0
- package/dist/assets/FilesView-DqiZ9kw9.js +6 -0
- package/dist/assets/GitHubDetailScaffold-DM2DH7o8.js +11 -0
- package/dist/assets/GitHubLinkPicker-ChB8NZ1h.js +1 -0
- package/dist/assets/GitHubListPrimitives-CibDiJGq.js +1 -0
- package/dist/assets/{GitView-DD33ngnM.js → GitView--EaZQrBr.js} +5 -5
- package/dist/assets/{IssuesSurface-BAY_eyX5.js → IssuesSurface-CySTpaD1.js} +3 -3
- package/dist/assets/{JsonTreeView-DpXbUrAl.js → JsonTreeView-_yMHKKQZ.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-Cn63lAmn.js → MarkdownRendererImpl-D_-2fQw0.js} +3 -3
- package/dist/assets/PatchDiff-bHObDlhD.js +1 -0
- package/dist/assets/PierreDiffViewer-UY7Cse-s.js +147 -0
- package/dist/assets/PullRequestsSurface-iXy6chwc.js +2 -0
- package/dist/assets/{SessionSwitcherContent-CscYekC1.js → SessionSwitcherContent-DJGCa_wN.js} +1 -1
- package/dist/assets/SessionSwitcherDropdown-CDOX-5Y2.js +2 -0
- package/dist/assets/SessionUnreadDot-Dwc3MdvA.js +1 -0
- package/dist/assets/SettingsView-DA-U9lsj.js +11 -0
- package/dist/assets/{SettingsWindow-gxjULdm1.js → SettingsWindow-CUg49Mfh.js} +1 -1
- package/dist/assets/{StickyHorizontalScrollbar-DNsbTLS7.js → StickyHorizontalScrollbar-CMbTn5WQ.js} +1 -1
- package/dist/assets/SubagentsArtifact-DUZX9tDe.js +1 -0
- package/dist/assets/ToolOutputDialog-BuZZaRw4.js +8 -0
- package/dist/assets/ToolPartDiffPreview-CKncG6i2.js +1 -0
- package/dist/assets/{VirtualizedFileDiff-BrbPymTL.js → VirtualizedFileDiff-BGZiLPe_.js} +4 -4
- package/dist/assets/{Virtualizer-okhy9Aq3.js → Virtualizer-PxblpQn6.js} +1 -1
- package/dist/assets/VisualFrame-DBZkHFnG.js +22 -0
- package/dist/assets/VisualsArtifact-Bq0vMO-i.js +1 -0
- package/dist/assets/{collapsible-D6qdoq7-.js → collapsible-Bro9KrfM.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-G4csGiKs.js → computeVirtualFileMetrics-DJQqK49u.js} +2 -2
- package/dist/assets/contextFileOpenGuard-ByWK3Sru.js +1 -0
- package/dist/assets/{fileTreeStatus-Bskhj4qT.js → fileTreeStatus-CyJ3TOYD.js} +2 -2
- package/dist/assets/gitStatusPredicates-BsXrwngT.js +1 -0
- package/dist/assets/githubLink-g2bmC0qi.js +10 -0
- package/dist/assets/index-B_L9GVYw.css +1 -0
- package/dist/assets/{index-ComwtfT4.js → index-C9rUUQ_Y.js} +1 -1
- package/dist/assets/index-CKKWVoND.js +11 -0
- package/dist/assets/{main-DoiadX0a.js → main-DT-4_fhe.js} +2 -2
- package/dist/assets/main-DsLMU9CT.js +137 -0
- package/dist/assets/{markdownCore-DczkEluO.js → markdownCore-QmM_aOnZ.js} +2 -2
- package/dist/assets/{miniChat-Ck6MEZ9Q.js → miniChat-BqGslD2z.js} +2 -2
- package/dist/assets/{mobile-BucKVm1P.js → mobile-C5JOcDIC.js} +2 -2
- package/dist/assets/{nativeFileSave-Cp9i5QGd.js → nativeFileSave-DSMsJqXM.js} +1 -1
- package/dist/assets/pi-session-focus-preference-Cc_S4zi1.js +9 -0
- package/dist/assets/{renderDiffWithHighlighter-PL82AR81.js → renderDiffWithHighlighter-BXhnIAHg.js} +1 -1
- package/dist/assets/renderElectronMiniChatApp-CiSkecEE.js +2 -0
- package/dist/assets/{renderFileWithHighlighter-CYgfbA4F.js → renderFileWithHighlighter-CK29YZtC.js} +1 -1
- package/dist/assets/renderMobileApp-C4JuoxsZ.js +11 -0
- package/dist/assets/runtimeEndpointReset-Dwj-jCDS.js +66 -0
- package/dist/assets/runtimeSurface-0K7vuUpd.js +1 -0
- package/dist/assets/selection-CnYkEsu_.js +1 -0
- package/dist/assets/useAppFontEffects-CV5UyTRw.js +226 -0
- package/dist/assets/useGitHubRemoteSearch-CgP-zEBj.js +1 -0
- package/dist/assets/useSwitcherItems-C8G5F0hs.js +1 -0
- package/dist/assets/{vendor-aparajita-capacitor-secure-storage-DVZvgYu4.js → vendor-aparajita-capacitor-secure-storage-DUoR8t1G.js} +1 -1
- package/dist/assets/{vendor-base-ui-BCqPBzDj.js → vendor-base-ui-DE6jnTiC.js} +1 -1
- package/dist/assets/{vendor-boot-3SaHYVb1.js → vendor-boot-D-KEJjsM.js} +29 -29
- package/dist/assets/{vendor-capacitor-app-NbQ-WiPS.js → vendor-capacitor-app-CO5jS31X.js} +1 -1
- package/dist/assets/{vendor-capacitor-keyboard-CgrHt8iN.js → vendor-capacitor-keyboard-335osRpd.js} +1 -1
- package/dist/assets/{vendor-capacitor-status-bar-CWt0OF5t.js → vendor-capacitor-status-bar-lB9y4H9d.js} +1 -1
- package/dist/assets/{vendor-codemirror-autocomplete-WThuuUAz.js → vendor-codemirror-autocomplete-BKvJ8PfM.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-angular-BbLGCxF6.js → vendor-codemirror-lang-angular-wjCUD0bM.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-cpp-Cceks-9O.js → vendor-codemirror-lang-cpp-LJzlG8sJ.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-css-D1wpUg3Z.js → vendor-codemirror-lang-css-DoEEdEpW.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-go-Cv0zXHHM.js → vendor-codemirror-lang-go-DexsLPb8.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-html-DbL8oT9H.js → vendor-codemirror-lang-html-h25V-Hp5.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-java-CNugenuC.js → vendor-codemirror-lang-java-D8xoT8cv.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-javascript-Bx_FIyZF.js → vendor-codemirror-lang-javascript-DF3GDYje.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-jinja-DDGjB3Zq.js → vendor-codemirror-lang-jinja-BboTHFdn.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-json-DIvqf9Pb.js → vendor-codemirror-lang-json-DCqvG1nE.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-less-D8r9dGG1.js → vendor-codemirror-lang-less-B8ZrSKJM.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-liquid-B24mguYi.js → vendor-codemirror-lang-liquid-DF9S5m5F.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-markdown-v3yG2sbf.js → vendor-codemirror-lang-markdown-6BNbCEPe.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-php-BcZGalqy.js → vendor-codemirror-lang-php-CQwAz1Hd.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-python-b-JqEwQy.js → vendor-codemirror-lang-python-DQym-8Tx.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-rust-B1uZxDW-.js → vendor-codemirror-lang-rust-DknzOTkO.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sass-DqPrngKp.js → vendor-codemirror-lang-sass-dB0Rm5HI.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sql-UyCnpt-k.js → vendor-codemirror-lang-sql-CCQUnnD-.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-vue-xDwYkovV.js → vendor-codemirror-lang-vue-h1M5bF00.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-wast-CF3169p_.js → vendor-codemirror-lang-wast-DWgtlGfu.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-xml-FCtVhuOb.js → vendor-codemirror-lang-xml-DncwoCUY.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-yaml-g0sPmAnv.js → vendor-codemirror-lang-yaml-C7QkS5ER.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-B03xgzP2.js → vendor-codemirror-language-data-BUZIlm3G.js} +2 -2
- package/dist/assets/{vendor-codemirror-search-Dw3Wpu15.js → vendor-codemirror-search-BlDCaCMK.js} +1 -1
- package/dist/assets/{vendor-lezer-cpp-Cu3E-KUI.js → vendor-lezer-cpp-B4JK1BC1.js} +1 -1
- package/dist/assets/{vendor-lezer-css-Cb8vp67u.js → vendor-lezer-css-DRxDmhcy.js} +1 -1
- package/dist/assets/{vendor-lezer-go-BTsIaOm7.js → vendor-lezer-go-DsUgfmxi.js} +1 -1
- package/dist/assets/{vendor-lezer-html-UQMsUwj-.js → vendor-lezer-html-qr9pUPmM.js} +1 -1
- package/dist/assets/{vendor-lezer-java-BIWrFrAx.js → vendor-lezer-java-6UyNiQiB.js} +1 -1
- package/dist/assets/{vendor-lezer-javascript-BH2Etgoy.js → vendor-lezer-javascript-CUdJ0VGA.js} +1 -1
- package/dist/assets/{vendor-lezer-json-CE-QUCwM.js → vendor-lezer-json-BKYAA8Hu.js} +1 -1
- package/dist/assets/{vendor-lezer-lr-HY6Yc0Vr.js → vendor-lezer-lr-DluApmOX.js} +1 -1
- package/dist/assets/{vendor-lezer-markdown-xFL3Evwf.js → vendor-lezer-markdown-B-uzYzYT.js} +1 -1
- package/dist/assets/{vendor-lezer-php-Cr_mQGrG.js → vendor-lezer-php-DI6PNjlz.js} +1 -1
- package/dist/assets/{vendor-lezer-python-BNRFWCb0.js → vendor-lezer-python-Bj232yb5.js} +1 -1
- package/dist/assets/{vendor-lezer-rust-BvfOK5cU.js → vendor-lezer-rust-DlPG_Yau.js} +1 -1
- package/dist/assets/{vendor-lezer-sass-qoxiLisk.js → vendor-lezer-sass-CBsyWB2A.js} +1 -1
- package/dist/assets/{vendor-lezer-xml--x8SSpqU.js → vendor-lezer-xml-C1FmgtmE.js} +1 -1
- package/dist/assets/{vendor-lezer-yaml-BDo1JaEr.js → vendor-lezer-yaml-DpHmjriG.js} +1 -1
- package/dist/assets/{vendor-replit-codemirror-vim-D1Fe7FiY.js → vendor-replit-codemirror-vim-Cvk64got.js} +1 -1
- package/dist/assets/{web-components-CGDpzixf.js → web-components-BpncHjnV.js} +4 -4
- package/dist/index.html +4 -4
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +2 -1
- package/plugins/featured.json +12 -0
- package/plugins/registry.json +7 -0
- package/plugins/subagents/LICENSE +25 -0
- package/plugins/subagents/agents/planner.md +36 -0
- package/plugins/subagents/agents/reviewer.md +34 -0
- package/plugins/subagents/agents/scout.md +49 -0
- package/plugins/subagents/agents/worker.md +23 -0
- package/plugins/subagents/extension.js +631 -0
- package/plugins/subagents/extension.test.js +295 -0
- package/plugins/subagents/package.json +41 -0
- package/plugins/visuals/choices.js +168 -0
- package/plugins/visuals/extension.js +90 -0
- package/plugins/visuals/files.js +74 -0
- package/plugins/visuals/package.json +32 -0
- package/server/index.js +103 -24
- package/server/lib/git/DOCUMENTATION.md +4 -0
- package/server/lib/git/service.js +70 -5
- package/server/lib/git/service.test.js +179 -0
- package/server/lib/github/DOCUMENTATION.md +6 -2
- package/server/lib/github/gh-cli.js +35 -9
- package/server/lib/github/gh-cli.test.js +122 -0
- package/server/lib/marketplace/DOCUMENTATION.md +95 -0
- package/server/lib/marketplace/featured.js +176 -0
- package/server/lib/marketplace/featured.test.js +207 -0
- package/server/lib/marketplace/npm-registry.js +255 -0
- package/server/lib/marketplace/npm-registry.test.js +227 -0
- package/server/lib/marketplace/routes.js +64 -0
- package/server/lib/marketplace/routes.test.js +119 -0
- package/server/lib/marketplace/service.js +225 -0
- package/server/lib/marketplace/service.test.js +174 -0
- package/server/lib/notifications/DOCUMENTATION.md +10 -4
- package/server/lib/notifications/pi-notification-watcher.js +95 -33
- package/server/lib/notifications/pi-notification-watcher.test.js +89 -0
- package/server/lib/open-url/DOCUMENTATION.md +2 -1
- package/server/lib/pi/extension-protocol.js +54 -0
- package/server/lib/pi/fixtures/pichamber-gui-demo.ts +12 -13
- package/server/lib/pi/merged-event-stream.js +316 -0
- package/server/lib/pi/merged-event-stream.test.js +95 -0
- package/server/lib/pi/routes-daemon-pool.test.js +348 -0
- package/server/lib/pi/routes-extension-events.test.js +115 -0
- package/server/lib/pi/routes-merged-events.test.js +327 -0
- package/server/lib/pi/routes-sandbox.test.js +1684 -0
- package/server/lib/pi/routes.js +790 -87
- package/server/lib/pi/routes.test.js +381 -1
- package/server/lib/pi/sandbox/DOCUMENTATION.md +68 -0
- package/server/lib/pi/sandbox/launcher.js +122 -0
- package/server/lib/pi/sandbox/launcher.test.js +91 -0
- package/server/lib/pi/sandbox/nono-launcher.js +455 -0
- package/server/lib/pi/sandbox/nono-launcher.test.js +371 -0
- package/server/lib/pi/sandbox/nono-profile-macos.json +20 -0
- package/server/lib/pi/sandbox/nono-profile-wsl2.json +21 -0
- package/server/lib/pi/sandbox/nono-profile.json +22 -0
- package/server/lib/pi/sandbox/project-sandbox-manager.js +1461 -0
- package/server/lib/pi/sandbox/project-sandbox-setting.js +166 -0
- package/server/lib/pi/sandbox/project-sandbox.js +207 -0
- package/server/lib/pi/sandbox/sandbox-routes.js +110 -0
- package/server/lib/pi/sandbox/sandboxed-folders.js +100 -0
- package/server/lib/pi/sandbox/sandboxed-folders.test.js +65 -0
- package/server/lib/pi/sandbox/trust-ask.js +135 -0
- package/server/lib/pi/sandbox/trust-ask.test.js +54 -0
- package/server/lib/pi/sandbox/worktree-ids.js +96 -0
- package/server/lib/pi/sandbox/worktree-ids.test.js +73 -0
- package/server/lib/pi/session-daemon/DOCUMENTATION.md +47 -10
- package/server/lib/pi/session-daemon/daemon-pool.js +157 -0
- package/server/lib/pi/session-daemon/daemon-process.js +10 -1
- package/server/lib/pi/session-daemon/extension-bridge.js +89 -29
- package/server/lib/pi/session-daemon/extension-config.js +902 -0
- package/server/lib/pi/session-daemon/extension-config.test.js +798 -0
- package/server/lib/pi/session-daemon/extension-controls.js +177 -0
- package/server/lib/pi/session-daemon/extension-controls.test.js +181 -0
- package/server/lib/pi/session-daemon/extension-name.js +6 -0
- package/server/lib/pi/session-daemon/extension-name.test.js +5 -0
- package/server/lib/pi/session-daemon/extension-palette.js +146 -0
- package/server/lib/pi/session-daemon/extension-palette.test.js +107 -0
- package/server/lib/pi/session-daemon/extension-replacements.js +138 -0
- package/server/lib/pi/session-daemon/extension-replacements.test.js +116 -0
- package/server/lib/pi/session-daemon/extension-ui-mode.js +30 -0
- package/server/lib/pi/session-daemon/extension-ui-mode.test.js +34 -0
- package/server/lib/pi/session-daemon/pichamber-ui.js +44 -0
- package/server/lib/pi/session-daemon/plugin-host.js +245 -0
- package/server/lib/pi/session-daemon/plugin-host.test.js +192 -0
- package/server/lib/pi/session-daemon/session-daemon-controls.e2e.test.js +205 -0
- package/server/lib/pi/session-daemon/session-daemon-drafts.e2e.test.js +409 -0
- package/server/lib/pi/session-daemon/session-daemon-extension-config.e2e.test.js +196 -0
- package/server/lib/pi/session-daemon/session-daemon-extensions.test.js +137 -6
- package/server/lib/pi/session-daemon/session-daemon-plugins.e2e.test.js +272 -0
- package/server/lib/pi/session-daemon/session-daemon-providers.e2e.test.js +153 -0
- package/server/lib/pi/session-daemon/session-daemon-read-persisted.test.js +167 -0
- package/server/lib/pi/session-daemon/session-daemon.js +927 -108
- package/server/lib/pi/session-daemon/session-daemon.test.js +391 -4
- package/server/lib/pi/session-daemon/session-engine-router.js +7 -0
- package/server/lib/pi/session-daemon/session-engine-router.test.js +20 -0
- package/server/lib/pi/session-daemon/session-idle-residency.test.js +98 -1
- package/server/lib/pi/session-daemon/session-jsonl.js +49 -10
- package/server/lib/pi/session-daemon/session-jsonl.test.js +11 -0
- package/server/lib/pi/session-daemon/session-lease.js +93 -15
- package/server/lib/pi/session-daemon/session-lease.test.js +107 -1
- package/server/lib/pi/session-daemon/supervisor-launcher-stop.test.js +295 -0
- package/server/lib/pi/session-daemon/supervisor-sandbox-nono.e2e.test.js +301 -0
- package/server/lib/pi/session-daemon/supervisor-sandbox.test.js +444 -0
- package/server/lib/pi/session-daemon/supervisor.js +408 -38
- package/server/lib/pi/session-daemon/supervisor.test.js +28 -0
- package/server/lib/pi/settings-store.js +14 -0
- package/server/lib/pi/settings-store.test.js +11 -0
- package/server/lib/pi/ui-settings-store.js +88 -2
- package/server/lib/pi/ui-settings-store.test.js +118 -0
- package/server/lib/plugins/DOCUMENTATION.md +198 -0
- package/server/lib/plugins/daemon-sync.js +88 -0
- package/server/lib/plugins/daemon-sync.supervisor.test.js +83 -0
- package/server/lib/plugins/daemon-sync.test.js +108 -0
- package/server/lib/plugins/impact.js +139 -0
- package/server/lib/plugins/impact.test.js +83 -0
- package/server/lib/plugins/manifest.js +220 -0
- package/server/lib/plugins/manifest.test.js +127 -0
- package/server/lib/plugins/registry.js +59 -0
- package/server/lib/plugins/routes.js +92 -0
- package/server/lib/plugins/routes.test.js +247 -0
- package/server/lib/plugins/service.js +183 -0
- package/server/lib/plugins/store.js +261 -0
- package/server/lib/plugins/store.test.js +188 -0
- package/server/lib/plugins/visuals-extension.test.js +237 -0
- package/server/lib/server/cross-process-lock.js +28 -3
- package/server/lib/server-browser/DOCUMENTATION.md +32 -7
- package/server/lib/server-browser/browser-tab.js +4 -1
- package/server/lib/server-browser/downloads.js +261 -34
- package/server/lib/server-browser/downloads.test.js +171 -0
- package/server/lib/server-browser/runtime.integration.test.js +47 -0
- package/server/lib/server-browser/runtime.js +16 -0
- package/server/lib/server-browser/server-browser.js +25 -6
- package/server/lib/tunnels/executable-search.js +5 -1
- package/server/lib/tunnels/executable-search.test.js +26 -0
- package/dist/assets/DiagramView-BB-aZobi.js +0 -1
- package/dist/assets/FileSaveConflictDialog-Bzz8FNMq.js +0 -3
- package/dist/assets/FilesView-DECxN8Z0.js +0 -6
- package/dist/assets/GitHubDetailScaffold-CWsWycRd.js +0 -11
- package/dist/assets/GitHubLinkPicker-BVYdg_e8.js +0 -1
- package/dist/assets/GitHubListPrimitives-Dlv3tC4d.js +0 -1
- package/dist/assets/PatchDiff-BklyOEHs.js +0 -1
- package/dist/assets/PierreDiffViewer-wc6cB6qw.js +0 -147
- package/dist/assets/PullRequestsSurface-BZvJkT1I.js +0 -2
- package/dist/assets/SessionSwitcherDropdown-DShvvGwC.js +0 -2
- package/dist/assets/SessionUnreadDot-CbqRq6h_.js +0 -1
- package/dist/assets/SettingsView-DcF-At5E.js +0 -6
- package/dist/assets/ToolOutputDialog-DdMIfrnK.js +0 -8
- package/dist/assets/ToolPartDiffPreview-C6Sm4eVf.js +0 -1
- package/dist/assets/contextFileOpenGuard-UU86YHgI.js +0 -1
- package/dist/assets/gitStatusPredicates-DQEO4Psc.js +0 -1
- package/dist/assets/githubLink-ByPAyFjh.js +0 -10
- package/dist/assets/index-BaLCg7tL.css +0 -1
- package/dist/assets/index-I2QYqABE.js +0 -11
- package/dist/assets/main-DyFfbllq.js +0 -137
- package/dist/assets/pi-session-focus-preference-Dx0UXPoO.js +0 -9
- package/dist/assets/renderElectronMiniChatApp-Cb7s7dWl.js +0 -2
- package/dist/assets/renderMobileApp-Bp74b_Lo.js +0 -11
- package/dist/assets/runtimeEndpointReset-7nWYnKd4.js +0 -62
- package/dist/assets/runtimeSurface-CFwnvks_.js +0 -1
- package/dist/assets/useAppFontEffects-ZTyNwFk6.js +0 -213
- package/dist/assets/useGitHubRemoteSearch-BF3ohpsh.js +0 -1
- package/dist/assets/useSwitcherItems-BJzwyDGX.js +0 -1
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it } from 'vitest';
|
|
2
|
+
import express from 'express';
|
|
3
|
+
|
|
4
|
+
import { registerPiRuntimeRoutes } from './routes.js';
|
|
5
|
+
import { createPiDaemonPool } from './session-daemon/daemon-pool.js';
|
|
6
|
+
|
|
7
|
+
const listen = (app) => new Promise((resolve, reject) => {
|
|
8
|
+
const server = app.listen(0, '127.0.0.1', () => resolve(server));
|
|
9
|
+
server.once('error', reject);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const close = (server) => new Promise((resolve) => {
|
|
13
|
+
if (!server) return resolve();
|
|
14
|
+
server.closeAllConnections?.();
|
|
15
|
+
server.close(() => resolve());
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const tick = () => new Promise((resolve) => setTimeout(resolve, 5));
|
|
19
|
+
|
|
20
|
+
// A fake daemon whose event stream the test drives: every subscription is
|
|
21
|
+
// recorded with its options, and `emit` writes a daemon frame to every open
|
|
22
|
+
// subscription.
|
|
23
|
+
const fakeDaemon = (epoch) => {
|
|
24
|
+
const subscriptions = [];
|
|
25
|
+
return {
|
|
26
|
+
epoch,
|
|
27
|
+
subscriptions,
|
|
28
|
+
get open() {
|
|
29
|
+
return subscriptions.filter((s) => !s.closed);
|
|
30
|
+
},
|
|
31
|
+
request: async () => ({}),
|
|
32
|
+
subscribe: async (options) => {
|
|
33
|
+
const record = { options, closed: false };
|
|
34
|
+
subscriptions.push(record);
|
|
35
|
+
return () => { record.closed = true; };
|
|
36
|
+
},
|
|
37
|
+
emit(event, sequence, payload) {
|
|
38
|
+
for (const s of this.open) {
|
|
39
|
+
s.options.onEvent({ protocolVersion: 1, kind: 'event', event, sequence, streamEpoch: epoch, payload });
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
fail() {
|
|
43
|
+
for (const s of this.open) s.options.onError(new Error('socket closed'));
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const title = (sessionId, directory, value) => ({ sessionId, directory, title: value });
|
|
49
|
+
|
|
50
|
+
// Reads SSE `data:` frames from a response as parsed JSON, ignoring heartbeats.
|
|
51
|
+
const sseReader = (response) => {
|
|
52
|
+
const reader = response.body.getReader();
|
|
53
|
+
const decoder = new TextDecoder();
|
|
54
|
+
let buffer = '';
|
|
55
|
+
const frames = [];
|
|
56
|
+
// One read stays pending across timeouts: a read abandoned after a
|
|
57
|
+
// timeout would still take the next chunk and drop it.
|
|
58
|
+
let pending = null;
|
|
59
|
+
return {
|
|
60
|
+
frames,
|
|
61
|
+
async until(predicate, limit = 50) {
|
|
62
|
+
for (let i = 0; i < limit && !predicate(frames); i += 1) {
|
|
63
|
+
pending ??= reader.read();
|
|
64
|
+
const next = await Promise.race([pending, new Promise((r) => setTimeout(() => r({ timeout: true }), 200))]);
|
|
65
|
+
if (next.timeout) continue;
|
|
66
|
+
pending = null;
|
|
67
|
+
if (next.done) break;
|
|
68
|
+
buffer += decoder.decode(next.value);
|
|
69
|
+
let end = buffer.indexOf('\n\n');
|
|
70
|
+
while (end >= 0) {
|
|
71
|
+
const block = buffer.slice(0, end);
|
|
72
|
+
buffer = buffer.slice(end + 2);
|
|
73
|
+
const data = block.split('\n').find((line) => line.startsWith('data: '));
|
|
74
|
+
if (data && !block.startsWith('event: heartbeat')) frames.push(JSON.parse(data.slice(6)));
|
|
75
|
+
end = buffer.indexOf('\n\n');
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return frames;
|
|
79
|
+
},
|
|
80
|
+
cancel: () => reader.cancel(),
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
describe('merged Pi event stream over a daemon pool', () => {
|
|
85
|
+
let server;
|
|
86
|
+
const readers = [];
|
|
87
|
+
afterEach(async () => {
|
|
88
|
+
for (const reader of readers.splice(0)) await reader.cancel().catch(() => undefined);
|
|
89
|
+
await close(server);
|
|
90
|
+
server = undefined;
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
const start = async (pool) => {
|
|
94
|
+
const app = express();
|
|
95
|
+
registerPiRuntimeRoutes(app, { daemonPool: pool, archiveStore: { read: async () => ({}), set: async () => undefined } });
|
|
96
|
+
server = await listen(app);
|
|
97
|
+
return async (query = '') => {
|
|
98
|
+
const response = await fetch(`http://127.0.0.1:${server.address().port}/api/pi/events?capabilities=events.streamEpoch${query}`);
|
|
99
|
+
if (response.status !== 200) return { status: response.status, body: await response.json() };
|
|
100
|
+
const reader = sseReader(response);
|
|
101
|
+
readers.push(reader);
|
|
102
|
+
await reader.until(() => false, 1);
|
|
103
|
+
return reader;
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
it('keeps main-only frames and subscribe options unchanged', async () => {
|
|
108
|
+
const main = fakeDaemon('epoch-main');
|
|
109
|
+
const pool = createPiDaemonPool({ getMainRuntime: () => main });
|
|
110
|
+
const open = await start(pool);
|
|
111
|
+
|
|
112
|
+
const stream = await open('&sessionId=s-1&directory=/work/other&fromSequence=7&streamEpoch=epoch-main');
|
|
113
|
+
main.emit('session.updated', 8, title('s-1', '/work/other', 'Main'));
|
|
114
|
+
await stream.until((frames) => frames.length >= 1);
|
|
115
|
+
|
|
116
|
+
expect(stream.frames).toEqual([{
|
|
117
|
+
protocolVersion: 1, kind: 'event', name: 'session.updated', sequence: 8,
|
|
118
|
+
sessionId: 's-1', directory: '/work/other', streamEpoch: 'epoch-main', payload: { title: 'Main' },
|
|
119
|
+
}]);
|
|
120
|
+
const { onEvent, onError, signal, ...options } = main.subscriptions[0].options;
|
|
121
|
+
expect(options).toEqual({ sessionId: 's-1', directory: '/work/other', fromSequence: 7, streamEpoch: 'epoch-main' });
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it('merges every daemon\'s frames, tagging project daemon frames with an opaque stream and cursor', async () => {
|
|
125
|
+
const main = fakeDaemon('epoch-main');
|
|
126
|
+
const sandbox = fakeDaemon('epoch-box');
|
|
127
|
+
const pool = createPiDaemonPool({ getMainRuntime: () => main });
|
|
128
|
+
pool.register('/work/a', { runtime: sandbox, directories: ['/work/a'] });
|
|
129
|
+
const open = await start(pool);
|
|
130
|
+
|
|
131
|
+
const stream = await open();
|
|
132
|
+
main.emit('session.updated', 3, title('s-main', '/work/other', 'Main'));
|
|
133
|
+
sandbox.emit('session.updated', 11, title('s-box', '/work/a', 'Box'));
|
|
134
|
+
await stream.until((frames) => frames.length >= 2);
|
|
135
|
+
|
|
136
|
+
const [fromMain, fromBox] = stream.frames;
|
|
137
|
+
expect(fromMain).toEqual({
|
|
138
|
+
protocolVersion: 1, kind: 'event', name: 'session.updated', sequence: 3,
|
|
139
|
+
sessionId: 's-main', directory: '/work/other', streamEpoch: 'epoch-main', payload: { title: 'Main' },
|
|
140
|
+
});
|
|
141
|
+
expect(fromBox).toMatchObject({ name: 'session.updated', sequence: 11, sessionId: 's-box', streamEpoch: 'epoch-box', payload: { title: 'Box' } });
|
|
142
|
+
expect(typeof fromBox.stream).toBe('string');
|
|
143
|
+
expect(typeof fromBox.cursor).toBe('string');
|
|
144
|
+
// Opaque: the pool key (a server path) never appears on the wire.
|
|
145
|
+
expect(fromBox.stream).not.toContain('/work');
|
|
146
|
+
expect(Buffer.from(fromBox.cursor, 'base64url').toString()).not.toContain('/work');
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it('resumes every project daemon from the cursor and main from its own sequence', async () => {
|
|
150
|
+
const main = fakeDaemon('epoch-main');
|
|
151
|
+
const sandbox = fakeDaemon('epoch-box');
|
|
152
|
+
const other = fakeDaemon('epoch-other');
|
|
153
|
+
const pool = createPiDaemonPool({ getMainRuntime: () => main });
|
|
154
|
+
pool.register('/work/a', { runtime: sandbox, directories: ['/work/a'] });
|
|
155
|
+
pool.register('/work/b', { runtime: other, directories: ['/work/b'] });
|
|
156
|
+
const open = await start(pool);
|
|
157
|
+
|
|
158
|
+
const first = await open();
|
|
159
|
+
sandbox.emit('session.updated', 11, title('s-box', '/work/a', 'Box'));
|
|
160
|
+
other.emit('session.updated', 4, title('s-other', '/work/b', 'Other'));
|
|
161
|
+
await first.until((frames) => frames.length >= 2);
|
|
162
|
+
const cursor = first.frames[1].cursor;
|
|
163
|
+
|
|
164
|
+
await open(`&fromSequence=30&streamEpoch=epoch-main&cursor=${encodeURIComponent(cursor)}`);
|
|
165
|
+
const pick = ({ fromSequence, streamEpoch }) => ({ fromSequence, streamEpoch });
|
|
166
|
+
expect(pick(main.subscriptions[1].options)).toEqual({ fromSequence: 30, streamEpoch: 'epoch-main' });
|
|
167
|
+
expect(pick(sandbox.subscriptions[1].options)).toEqual({ fromSequence: 11, streamEpoch: 'epoch-box' });
|
|
168
|
+
expect(pick(other.subscriptions[1].options)).toEqual({ fromSequence: 4, streamEpoch: 'epoch-other' });
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
it('rejects a malformed cursor and a cursor without the epoch capability', async () => {
|
|
172
|
+
const main = fakeDaemon('epoch-main');
|
|
173
|
+
const pool = createPiDaemonPool({ getMainRuntime: () => main });
|
|
174
|
+
const open = await start(pool);
|
|
175
|
+
|
|
176
|
+
expect(await open('&cursor=not-a-cursor')).toEqual({ status: 400, body: { error: { code: 'INVALID_ARGUMENT' } } });
|
|
177
|
+
const response = await fetch(`http://127.0.0.1:${server.address().port}/api/pi/events?cursor=e30`);
|
|
178
|
+
expect(response.status).toBe(400);
|
|
179
|
+
expect(main.subscriptions).toEqual([]);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
it('a restarted project daemon resyncs only its own sessions', async () => {
|
|
183
|
+
const main = fakeDaemon('epoch-main');
|
|
184
|
+
const sandbox = fakeDaemon('epoch-box');
|
|
185
|
+
const pool = createPiDaemonPool({ getMainRuntime: () => main });
|
|
186
|
+
pool.register('/work/a', { runtime: sandbox, directories: ['/work/a'] });
|
|
187
|
+
const open = await start(pool);
|
|
188
|
+
|
|
189
|
+
const stream = await open();
|
|
190
|
+
main.emit('session.updated', 3, title('s-main', '/work/other', 'Main'));
|
|
191
|
+
sandbox.emit('session.updated', 11, title('s-box', '/work/a', 'Box'));
|
|
192
|
+
await stream.until((frames) => frames.length >= 2);
|
|
193
|
+
|
|
194
|
+
const restarted = fakeDaemon('epoch-box-2');
|
|
195
|
+
pool.register('/work/a', { runtime: restarted, directories: ['/work/a'] });
|
|
196
|
+
await stream.until((frames) => frames.length >= 3);
|
|
197
|
+
await tick();
|
|
198
|
+
|
|
199
|
+
expect(stream.frames[2]).toEqual({
|
|
200
|
+
protocolVersion: 1, kind: 'event', name: 'session.moved', sequence: 0,
|
|
201
|
+
sessionId: 's-box', directory: '/work/a', payload: {},
|
|
202
|
+
});
|
|
203
|
+
expect(sandbox.open).toEqual([]);
|
|
204
|
+
// The new process is asked to resume from the old lifetime's cursor, which
|
|
205
|
+
// it answers with a resync snapshot.
|
|
206
|
+
const { fromSequence, streamEpoch } = restarted.subscriptions[0].options;
|
|
207
|
+
expect({ fromSequence, streamEpoch }).toEqual({ fromSequence: 11, streamEpoch: 'epoch-box' });
|
|
208
|
+
// Main was never resubscribed and keeps streaming.
|
|
209
|
+
expect(main.subscriptions).toHaveLength(1);
|
|
210
|
+
main.emit('session.updated', 4, title('s-main', '/work/other', 'Still'));
|
|
211
|
+
restarted.emit('session.updated', 1, title('s-box', '/work/a', 'Again'));
|
|
212
|
+
await stream.until((frames) => frames.length >= 5);
|
|
213
|
+
expect(stream.frames.slice(3).map((f) => [f.sessionId, f.streamEpoch])).toEqual([
|
|
214
|
+
['s-main', 'epoch-main'], ['s-box', 'epoch-box-2'],
|
|
215
|
+
]);
|
|
216
|
+
expect(stream.frames.filter((f) => f.name === 'session.moved')).toHaveLength(1);
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
it('a project daemon stopping or failing does not drop the others', async () => {
|
|
220
|
+
const main = fakeDaemon('epoch-main');
|
|
221
|
+
const sandbox = fakeDaemon('epoch-box');
|
|
222
|
+
const other = fakeDaemon('epoch-other');
|
|
223
|
+
const pool = createPiDaemonPool({ getMainRuntime: () => main });
|
|
224
|
+
pool.register('/work/a', { runtime: sandbox, directories: ['/work/a'] });
|
|
225
|
+
pool.register('/work/b', { runtime: other, directories: ['/work/b'] });
|
|
226
|
+
const open = await start(pool);
|
|
227
|
+
|
|
228
|
+
const stream = await open();
|
|
229
|
+
sandbox.emit('session.updated', 11, title('s-box', '/work/a', 'Box'));
|
|
230
|
+
other.emit('session.updated', 4, title('s-other', '/work/b', 'Other'));
|
|
231
|
+
await stream.until((frames) => frames.length >= 2);
|
|
232
|
+
|
|
233
|
+
pool.unregister('/work/a');
|
|
234
|
+
other.fail();
|
|
235
|
+
await stream.until((frames) => frames.length >= 4);
|
|
236
|
+
expect(stream.frames.slice(2).map((f) => [f.name, f.sessionId])).toEqual([
|
|
237
|
+
['session.moved', 's-box'], ['session.moved', 's-other'],
|
|
238
|
+
]);
|
|
239
|
+
expect(sandbox.open).toEqual([]);
|
|
240
|
+
|
|
241
|
+
main.emit('session.updated', 5, title('s-main', '/work/other', 'Main'));
|
|
242
|
+
await stream.until((frames) => frames.length >= 5);
|
|
243
|
+
expect(stream.frames[4]).toMatchObject({ sessionId: 's-main', streamEpoch: 'epoch-main' });
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
it('retries a failed project daemon subscription from its last position and drops a stopped daemon from the cursor', async () => {
|
|
247
|
+
const main = fakeDaemon('epoch-main');
|
|
248
|
+
const sandbox = fakeDaemon('epoch-box');
|
|
249
|
+
const other = fakeDaemon('epoch-other');
|
|
250
|
+
const pool = createPiDaemonPool({ getMainRuntime: () => main });
|
|
251
|
+
pool.register('/work/a', { runtime: sandbox, directories: ['/work/a'] });
|
|
252
|
+
pool.register('/work/b', { runtime: other, directories: ['/work/b'] });
|
|
253
|
+
const app = express();
|
|
254
|
+
registerPiRuntimeRoutes(app, { daemonPool: pool, eventStreamRetryBaseMs: 1, archiveStore: { read: async () => ({}), set: async () => undefined } });
|
|
255
|
+
server = await listen(app);
|
|
256
|
+
const response = await fetch(`http://127.0.0.1:${server.address().port}/api/pi/events?capabilities=events.streamEpoch`);
|
|
257
|
+
const stream = sseReader(response);
|
|
258
|
+
readers.push(stream);
|
|
259
|
+
await stream.until(() => false, 1);
|
|
260
|
+
|
|
261
|
+
sandbox.emit('session.updated', 11, title('s-box', '/work/a', 'Box'));
|
|
262
|
+
other.emit('session.updated', 4, title('s-other', '/work/b', 'Other'));
|
|
263
|
+
await stream.until((frames) => frames.length >= 2);
|
|
264
|
+
sandbox.fail();
|
|
265
|
+
for (let i = 0; i < 20 && sandbox.open.length === 0; i += 1) await tick();
|
|
266
|
+
const { fromSequence, streamEpoch } = sandbox.subscriptions.at(-1).options;
|
|
267
|
+
expect({ fromSequence, streamEpoch }).toEqual({ fromSequence: 11, streamEpoch: 'epoch-box' });
|
|
268
|
+
|
|
269
|
+
pool.unregister('/work/a');
|
|
270
|
+
other.emit('session.updated', 5, title('s-other', '/work/b', 'Again'));
|
|
271
|
+
await stream.until((frames) => frames.some((f) => f.payload?.title === 'Again'));
|
|
272
|
+
const last = stream.frames.at(-1);
|
|
273
|
+
const decoded = JSON.parse(Buffer.from(last.cursor, 'base64url').toString());
|
|
274
|
+
expect(Object.values(decoded.d)).toEqual([['epoch-other', 5]]);
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
it('subscribes to a daemon that appears mid-stream without a cursor', async () => {
|
|
278
|
+
const main = fakeDaemon('epoch-main');
|
|
279
|
+
const pool = createPiDaemonPool({ getMainRuntime: () => main });
|
|
280
|
+
const open = await start(pool);
|
|
281
|
+
const stream = await open('&fromSequence=2&streamEpoch=epoch-main');
|
|
282
|
+
|
|
283
|
+
const sandbox = fakeDaemon('epoch-box');
|
|
284
|
+
pool.register('/work/a', { runtime: sandbox, directories: ['/work/a'] });
|
|
285
|
+
await tick();
|
|
286
|
+
expect(sandbox.subscriptions).toHaveLength(1);
|
|
287
|
+
expect(sandbox.subscriptions[0].options.fromSequence).toBeUndefined();
|
|
288
|
+
expect(sandbox.subscriptions[0].options.streamEpoch).toBeUndefined();
|
|
289
|
+
sandbox.emit('session.snapshot', 1, { sessionId: 's-box', directory: '/work/a', lifecycle: 'idle', queue: {} });
|
|
290
|
+
await stream.until((frames) => frames.length >= 1);
|
|
291
|
+
expect(stream.frames[0]).toMatchObject({ name: 'session.snapshot', sessionId: 's-box', streamEpoch: 'epoch-box' });
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
it('announces a session whose frames move to another daemon', async () => {
|
|
295
|
+
const main = fakeDaemon('epoch-main');
|
|
296
|
+
const sandbox = fakeDaemon('epoch-box');
|
|
297
|
+
const pool = createPiDaemonPool({ getMainRuntime: () => main });
|
|
298
|
+
pool.register('/work/a', { runtime: sandbox, directories: ['/work/a'] });
|
|
299
|
+
const open = await start(pool);
|
|
300
|
+
const stream = await open();
|
|
301
|
+
|
|
302
|
+
main.emit('session.updated', 3, title('s-1', '/work/a', 'Before'));
|
|
303
|
+
sandbox.emit('session.updated', 1, title('s-1', '/work/a', 'After'));
|
|
304
|
+
await stream.until((frames) => frames.length >= 3);
|
|
305
|
+
expect(stream.frames.map((f) => [f.name, f.streamEpoch])).toEqual([
|
|
306
|
+
['session.updated', 'epoch-main'], ['session.moved', undefined], ['session.updated', 'epoch-box'],
|
|
307
|
+
]);
|
|
308
|
+
|
|
309
|
+
pool.announceMove('s-2', '/work/a');
|
|
310
|
+
await stream.until((frames) => frames.length >= 4);
|
|
311
|
+
expect(stream.frames[3]).toMatchObject({ name: 'session.moved', sessionId: 's-2', directory: '/work/a' });
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
it('still ends the connection when the main daemon subscription fails', async () => {
|
|
315
|
+
const main = fakeDaemon('epoch-main');
|
|
316
|
+
const sandbox = fakeDaemon('epoch-box');
|
|
317
|
+
const pool = createPiDaemonPool({ getMainRuntime: () => main });
|
|
318
|
+
pool.register('/work/a', { runtime: sandbox, directories: ['/work/a'] });
|
|
319
|
+
const open = await start(pool);
|
|
320
|
+
await open();
|
|
321
|
+
|
|
322
|
+
main.fail();
|
|
323
|
+
await tick();
|
|
324
|
+
expect(main.open).toEqual([]);
|
|
325
|
+
expect(sandbox.open).toEqual([]);
|
|
326
|
+
});
|
|
327
|
+
});
|