@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,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pi-chamber/plugin-visuals",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"description": "Lets the agent draw HTML pages in the chat.",
|
|
7
|
+
"keywords": ["pi-package", "pichamber-plugin", "html", "visual", "visuals", "chart", "charts", "diagram", "mockup", "render", "preview", "ui", "design", "choices"],
|
|
8
|
+
"pi": {
|
|
9
|
+
"extensions": ["./extension.js"]
|
|
10
|
+
},
|
|
11
|
+
"pichamber": {
|
|
12
|
+
"apiVersion": 1,
|
|
13
|
+
"id": "visuals",
|
|
14
|
+
"name": "Visuals",
|
|
15
|
+
"description": "Lets the agent show charts, diagrams, tables and mockups as HTML pages in the chat.",
|
|
16
|
+
"icon": "artboard",
|
|
17
|
+
"defaultEnabled": false,
|
|
18
|
+
"state": {
|
|
19
|
+
"allowNetwork": {
|
|
20
|
+
"type": "boolean",
|
|
21
|
+
"scope": "global",
|
|
22
|
+
"default": false,
|
|
23
|
+
"label": "Let pages load from the network",
|
|
24
|
+
"description": "Off: pages can only use what they contain."
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"contributes": {
|
|
28
|
+
"settings": ["allowNetwork"],
|
|
29
|
+
"ui": "visuals"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
package/server/index.js
CHANGED
|
@@ -17,12 +17,23 @@ import { createTailscaleService } from './lib/tailscale/service.js';
|
|
|
17
17
|
import { createServerIdResolver } from './lib/relay/server-id.js';
|
|
18
18
|
import { registerTailscaleRoutes } from './lib/tailscale/routes.js';
|
|
19
19
|
import { registerPiRuntimeRoutes } from './lib/pi/routes.js';
|
|
20
|
+
import { createPiDaemonPool } from './lib/pi/session-daemon/daemon-pool.js';
|
|
21
|
+
import { createPluginService } from './lib/plugins/service.js';
|
|
22
|
+
import { createPluginDaemonSync } from './lib/plugins/daemon-sync.js';
|
|
23
|
+
import { registerPluginRoutes } from './lib/plugins/routes.js';
|
|
24
|
+
import { createFeaturedSource, DEFAULT_FEATURED_URL } from './lib/marketplace/featured.js';
|
|
25
|
+
import { createNpmRegistry } from './lib/marketplace/npm-registry.js';
|
|
26
|
+
import { registerMarketplaceRoutes } from './lib/marketplace/routes.js';
|
|
27
|
+
import { createMarketplaceService } from './lib/marketplace/service.js';
|
|
20
28
|
import { createDockerInitialLocalSettings, createPiUiSettingsStore } from './lib/pi/ui-settings-store.js';
|
|
21
29
|
import { detectLinuxDistribution } from './lib/server/linux-distribution.js';
|
|
22
30
|
import { createPiNotificationWatcher } from './lib/notifications/pi-notification-watcher.js';
|
|
23
31
|
import { registerWorkspaceIntegrations } from './lib/workspace/host.js';
|
|
24
32
|
import { createPiSessionDaemonSupervisor } from './lib/pi/session-daemon/supervisor.js';
|
|
25
33
|
import { createOpenUrlIntake } from './lib/open-url/intake.js';
|
|
34
|
+
import { createNonoLauncher } from './lib/pi/sandbox/nono-launcher.js';
|
|
35
|
+
import { createProjectSandboxManager } from './lib/pi/sandbox/project-sandbox-manager.js';
|
|
36
|
+
import { createTrustAskStore } from './lib/pi/sandbox/trust-ask.js';
|
|
26
37
|
import {
|
|
27
38
|
getUnauthenticatedLanErrorMessage,
|
|
28
39
|
isNetworkExposedBindHost,
|
|
@@ -131,6 +142,11 @@ export async function startWebUiServer(options = {}) {
|
|
|
131
142
|
const apiOnly = options.apiOnly === true || isEnvFlagEnabled(process.env.PICHAMBER_API_ONLY);
|
|
132
143
|
const app = express();
|
|
133
144
|
const server = http.createServer(app);
|
|
145
|
+
// The port the server is listening on, or null before it binds.
|
|
146
|
+
const boundPort = () => {
|
|
147
|
+
const address = server.address();
|
|
148
|
+
return typeof address === 'object' && address ? address.port : null;
|
|
149
|
+
};
|
|
134
150
|
const serverStartedAt = new Date().toISOString();
|
|
135
151
|
const dataPath = (name) => path.join(PICHAMBER_DATA_DIR, name);
|
|
136
152
|
const remoteClientAuthRuntime = createRemoteClientAuthRuntime({ fsPromises: fs.promises, path, crypto: await import('node:crypto'), storePath: dataPath('remote-clients.json') });
|
|
@@ -157,10 +173,7 @@ export async function startWebUiServer(options = {}) {
|
|
|
157
173
|
});
|
|
158
174
|
const tunnelService = createTunnelService({
|
|
159
175
|
dataDir: PICHAMBER_DATA_DIR,
|
|
160
|
-
getPort:
|
|
161
|
-
const address = server.address();
|
|
162
|
-
return typeof address === 'object' && address ? address.port : null;
|
|
163
|
-
},
|
|
176
|
+
getPort: boundPort,
|
|
164
177
|
tunnelAuthController,
|
|
165
178
|
getServerLabel: () => os.hostname() || 'PiChamber',
|
|
166
179
|
});
|
|
@@ -182,10 +195,7 @@ export async function startWebUiServer(options = {}) {
|
|
|
182
195
|
const tailscaleService = createTailscaleService({
|
|
183
196
|
dataDir: PICHAMBER_DATA_DIR,
|
|
184
197
|
getServerId: serverIdResolver.getServerId,
|
|
185
|
-
getPort:
|
|
186
|
-
const address = server.address();
|
|
187
|
-
return typeof address === 'object' && address ? address.port : null;
|
|
188
|
-
},
|
|
198
|
+
getPort: boundPort,
|
|
189
199
|
isUiAuthEnabled: hasUiPasswordConfigured,
|
|
190
200
|
isUnsafeUnauthenticatedLanAllowed: () => isUnsafeUnauthenticatedLanAllowed(process.env),
|
|
191
201
|
});
|
|
@@ -195,10 +205,7 @@ export async function startWebUiServer(options = {}) {
|
|
|
195
205
|
console.warn(`[tailscale] Failed to load persisted config: ${error?.message || error}`);
|
|
196
206
|
}
|
|
197
207
|
const pairingTransports = createPairingTransportResolvers({
|
|
198
|
-
getPort:
|
|
199
|
-
const address = server.address();
|
|
200
|
-
return typeof address === 'object' && address ? address.port : null;
|
|
201
|
-
},
|
|
208
|
+
getPort: boundPort,
|
|
202
209
|
bindHost: host,
|
|
203
210
|
getTailscaleCandidate: () => tailscaleService.getPairingCandidate(),
|
|
204
211
|
});
|
|
@@ -236,10 +243,7 @@ export async function startWebUiServer(options = {}) {
|
|
|
236
243
|
serverStartedAt,
|
|
237
244
|
gracefulShutdown,
|
|
238
245
|
getHealthSnapshot: () => ({ pi: { state: 'ready' }, apiOnly }),
|
|
239
|
-
getServerPort:
|
|
240
|
-
const address = server.address();
|
|
241
|
-
return typeof address === 'object' && address ? address.port : null;
|
|
242
|
-
},
|
|
246
|
+
getServerPort: boundPort,
|
|
243
247
|
getTunnelUrl: () => null,
|
|
244
248
|
getServerId: serverIdResolver.getServerId,
|
|
245
249
|
tunnelAuthController,
|
|
@@ -261,9 +265,74 @@ export async function startWebUiServer(options = {}) {
|
|
|
261
265
|
getServerId: serverIdResolver.getServerId,
|
|
262
266
|
getServerLabel: () => os.hostname() || 'PiChamber',
|
|
263
267
|
});
|
|
264
|
-
|
|
265
|
-
|
|
268
|
+
// Plugins: the server owns manifests and state and pushes the enabled set
|
|
269
|
+
// to every daemon (lib/plugins/DOCUMENTATION.md). A health probe runs the
|
|
270
|
+
// supervisor's onDaemonReady hook, which pushes. A sandboxed project's
|
|
271
|
+
// daemon gets a config trimmed to its own folders.
|
|
272
|
+
const pluginService = createPluginService();
|
|
273
|
+
const pluginDaemonSync = createPluginDaemonSync({
|
|
274
|
+
buildConfig: (scope) => pluginService.daemonConfig(scope),
|
|
275
|
+
refresh: () => piSessionDaemonRuntime?.health(),
|
|
276
|
+
});
|
|
277
|
+
// The main daemon is today's supervisor; project daemons register here.
|
|
278
|
+
const piDaemonPool = createPiDaemonPool({ getMainRuntime: () => piSessionDaemonRuntime });
|
|
279
|
+
// Sandboxed projects get their own daemon, started through nono on first
|
|
280
|
+
// use. With no sandboxed project this registers nothing and probes nothing.
|
|
281
|
+
let piRuntimeRoutes = null;
|
|
282
|
+
// Folders whose Pi trust stays "ask" after their sandbox was turned off;
|
|
283
|
+
// the daemons read the same file (sandbox/trust-ask.js).
|
|
284
|
+
const piTrustAsk = createTrustAskStore({ dataDir: PICHAMBER_DATA_DIR });
|
|
285
|
+
const piSandboxManager = createProjectSandboxManager({
|
|
286
|
+
daemonPool: piDaemonPool,
|
|
287
|
+
trustAsk: piTrustAsk,
|
|
266
288
|
uiSettingsStore,
|
|
289
|
+
launcher: createNonoLauncher({
|
|
290
|
+
stageDir: path.join(PICHAMBER_DATA_DIR, 'pi', 'sandbox'),
|
|
291
|
+
customProfileFile: path.join(PICHAMBER_DATA_DIR, 'pi', 'sandbox', 'nono-profile.custom.json'),
|
|
292
|
+
}),
|
|
293
|
+
dataDir: PICHAMBER_DATA_DIR,
|
|
294
|
+
agentDir: async () => {
|
|
295
|
+
const configured = typeof process.env.PICHAMBER_PI_AGENT_DIR === 'string' ? process.env.PICHAMBER_PI_AGENT_DIR.trim() : '';
|
|
296
|
+
if (configured) return configured;
|
|
297
|
+
return (await import('@earendil-works/pi-coding-agent')).getAgentDir();
|
|
298
|
+
},
|
|
299
|
+
getServerPort: boundPort,
|
|
300
|
+
hasConnectedDevices: () => piRuntimeRoutes?.hasLiveEventStreams() ?? false,
|
|
301
|
+
// The same port and version as the main daemon, so sandbox profile keys
|
|
302
|
+
// extend the main daemon's.
|
|
303
|
+
supervisorOptions: ({ roots } = {}) => ({
|
|
304
|
+
port: boundPort() ?? port,
|
|
305
|
+
version: PICHAMBER_VERSION,
|
|
306
|
+
onDaemonReady: pluginDaemonSync.onDaemonReadyFor({ roots }),
|
|
307
|
+
}),
|
|
308
|
+
});
|
|
309
|
+
piRuntimeRoutes = registerPiRuntimeRoutes(app, {
|
|
310
|
+
daemonPool: piDaemonPool,
|
|
311
|
+
sandboxManager: piSandboxManager,
|
|
312
|
+
trustAsk: piTrustAsk,
|
|
313
|
+
uiSettingsStore,
|
|
314
|
+
onSessionDeleted: async (sessionId) => {
|
|
315
|
+
if (await pluginService.forgetSession(sessionId)) pluginDaemonSync.changed();
|
|
316
|
+
},
|
|
317
|
+
});
|
|
318
|
+
registerPluginRoutes(app, { service: pluginService, onChange: pluginDaemonSync.changed });
|
|
319
|
+
// Marketplace: npm search and the featured list (lib/marketplace/DOCUMENTATION.md).
|
|
320
|
+
// PICHAMBER_NPM_REGISTRY_URL / PICHAMBER_NPM_DOWNLOADS_URL point it at a
|
|
321
|
+
// mirror or a test fixture; PICHAMBER_FEATURED_URL=off stops refreshing the
|
|
322
|
+
// featured list from the repository.
|
|
323
|
+
const featuredUrlSetting = process.env.PICHAMBER_FEATURED_URL;
|
|
324
|
+
registerMarketplaceRoutes(app, {
|
|
325
|
+
service: createMarketplaceService({
|
|
326
|
+
registry: createNpmRegistry({
|
|
327
|
+
...(process.env.PICHAMBER_NPM_REGISTRY_URL ? { registryUrl: process.env.PICHAMBER_NPM_REGISTRY_URL } : {}),
|
|
328
|
+
...(process.env.PICHAMBER_NPM_DOWNLOADS_URL ? { downloadsUrl: process.env.PICHAMBER_NPM_DOWNLOADS_URL } : {}),
|
|
329
|
+
}),
|
|
330
|
+
featuredSource: createFeaturedSource({
|
|
331
|
+
cachePath: dataPath(path.join('pi', 'featured.json')),
|
|
332
|
+
remoteUrl: featuredUrlSetting === 'off' ? null : featuredUrlSetting || DEFAULT_FEATURED_URL,
|
|
333
|
+
}),
|
|
334
|
+
bundledPackageNames: () => pluginService.bundledPackageNames(),
|
|
335
|
+
}),
|
|
267
336
|
});
|
|
268
337
|
// Cloudflare Tunnel external access (managed-remote and managed-local modes).
|
|
269
338
|
const requireTunnelAuth = (req, res, next) => uiAuthController.requireAuth(req, res, next);
|
|
@@ -303,11 +372,12 @@ export async function startWebUiServer(options = {}) {
|
|
|
303
372
|
void tailscaleService.reconcile().catch((error) => {
|
|
304
373
|
console.warn(`[tailscale] Failed to apply mapping on startup: ${error?.message || error}`);
|
|
305
374
|
});
|
|
306
|
-
const resolvedPort =
|
|
375
|
+
const resolvedPort = boundPort();
|
|
307
376
|
piSessionDaemonRuntime = createPiSessionDaemonSupervisor({
|
|
308
377
|
dataDir: PICHAMBER_DATA_DIR,
|
|
309
378
|
port: typeof resolvedPort === 'number' ? resolvedPort : port,
|
|
310
379
|
version: PICHAMBER_VERSION,
|
|
380
|
+
onDaemonReady: pluginDaemonSync.onDaemonReady,
|
|
311
381
|
});
|
|
312
382
|
if (typeof resolvedPort === 'number') {
|
|
313
383
|
process.send?.({
|
|
@@ -323,7 +393,7 @@ export async function startWebUiServer(options = {}) {
|
|
|
323
393
|
// supplies its native notification callback.
|
|
324
394
|
if (typeof options.onDesktopNotification === 'function') {
|
|
325
395
|
notificationWatcher = createPiNotificationWatcher({
|
|
326
|
-
|
|
396
|
+
daemonPool: piDaemonPool,
|
|
327
397
|
uiSettingsStore,
|
|
328
398
|
notify: options.onDesktopNotification,
|
|
329
399
|
});
|
|
@@ -340,7 +410,18 @@ export async function startWebUiServer(options = {}) {
|
|
|
340
410
|
} catch (error) {
|
|
341
411
|
console.warn(`[open-url] Intake unavailable: ${error?.code ?? 'UNKNOWN'}`);
|
|
342
412
|
}
|
|
413
|
+
// Register sandboxed projects before any request can route; a failure
|
|
414
|
+
// leaves those projects unregistered, so log it loudly.
|
|
415
|
+
try {
|
|
416
|
+
await piSandboxManager.reconcile();
|
|
417
|
+
} catch (error) {
|
|
418
|
+
console.warn(`[pi-sandbox] Could not load project sandbox settings: ${error?.code ?? error?.message ?? 'UNKNOWN'}`);
|
|
419
|
+
}
|
|
343
420
|
void piSessionDaemonRuntime.start()
|
|
421
|
+
.then(() => {
|
|
422
|
+
// Configure plugins on the started daemon; later requests re-check.
|
|
423
|
+
if (!stopped) void piSessionDaemonRuntime.health();
|
|
424
|
+
})
|
|
344
425
|
.catch((error) => {
|
|
345
426
|
console.warn(`[PiSessionDaemon] unavailable: ${error?.code ?? 'DAEMON_UNAVAILABLE'}`);
|
|
346
427
|
})
|
|
@@ -350,10 +431,7 @@ export async function startWebUiServer(options = {}) {
|
|
|
350
431
|
const controller = {
|
|
351
432
|
expressApp: app,
|
|
352
433
|
httpServer: server,
|
|
353
|
-
getPort:
|
|
354
|
-
const address = server.address();
|
|
355
|
-
return typeof address === 'object' && address ? address.port : null;
|
|
356
|
-
},
|
|
434
|
+
getPort: boundPort,
|
|
357
435
|
getTunnelUrl: () => null,
|
|
358
436
|
getDaemonProfileKey: () => piSessionDaemonRuntime?.paths?.profileKey ?? null,
|
|
359
437
|
getTailscaleStatus: () => tailscaleService.getStatus(),
|
|
@@ -370,6 +448,7 @@ export async function startWebUiServer(options = {}) {
|
|
|
370
448
|
await Promise.allSettled([
|
|
371
449
|
notificationWatcher?.stop(),
|
|
372
450
|
openUrlIntake.stop(),
|
|
451
|
+
piSandboxManager.stop(),
|
|
373
452
|
workspaceRuntime.shutdown(),
|
|
374
453
|
piSessionDaemonRuntime ? piSessionDaemonRuntime.stop() : Promise.resolve(),
|
|
375
454
|
tailscaleService.shutdown(),
|
|
@@ -24,6 +24,10 @@ This module provides Git repository operations for the web server runtime, inclu
|
|
|
24
24
|
any git config previously written into repositories are left untouched on
|
|
25
25
|
disk.
|
|
26
26
|
|
|
27
|
+
## Sandbox
|
|
28
|
+
|
|
29
|
+
Only Pi session daemons (the agent) run in the sandbox. PiChamber's own Git panel, terminal, browser and GitHub features, and worktree hooks and start commands, run outside it with the user's access, so git config, hooks or filters an agent writes into the repo can run when the user or the Git panel runs git. This is a known, accepted trade-off. Git runs the same for every folder, sandboxed project or not. One exception is the worktree folder id: for a project the sandbox manager has remembered an id for (`../pi/sandbox/worktree-ids.js`), new worktrees are filed under that id, not the one in `.git/pichamber`, which the sandboxed agent can rewrite; an unreadable record fails the worktree operation. A project nothing is remembered for is kept out of folders remembered for other projects: when its id (a second clone of the same repository has the same one) is remembered for another root, its worktrees are filed under an id of its own (`ownWorktreeId`), so they never land in a folder a sandbox is granted.
|
|
30
|
+
|
|
27
31
|
## Public API
|
|
28
32
|
|
|
29
33
|
The following functions are exported and used by the web server:
|
|
@@ -2,10 +2,12 @@ import simpleGit from 'simple-git';
|
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import os from 'os';
|
|
5
|
+
import crypto from 'crypto';
|
|
5
6
|
import { execFile } from 'child_process';
|
|
6
7
|
import { promisify } from 'util';
|
|
7
8
|
import { createRequire } from 'module';
|
|
8
9
|
import { resolvePiChamberDataPath } from '../pichamber-data-dir.js';
|
|
10
|
+
import { createWorktreeIdStore, ownWorktreeId } from '../pi/sandbox/worktree-ids.js';
|
|
9
11
|
|
|
10
12
|
const fsp = fs.promises;
|
|
11
13
|
const require = createRequire(import.meta.url);
|
|
@@ -1506,12 +1508,75 @@ export async function continueIntegrate(stateInput = {}) {
|
|
|
1506
1508
|
return { kind: 'success', moved: state.remainingCommits.length };
|
|
1507
1509
|
}
|
|
1508
1510
|
|
|
1511
|
+
const PICHAMBER_ID_FILE_MAX_BYTES = 256;
|
|
1512
|
+
|
|
1513
|
+
// Sandboxed code can write `.git`, so the id file is never followed through a
|
|
1514
|
+
// symlink: it is read only as a small regular file, and replaced by renaming a
|
|
1515
|
+
// new file over it (rename swaps a symlink itself, it does not follow it).
|
|
1516
|
+
const readPiChamberIdFile = async (idFile) => {
|
|
1517
|
+
const info = await fsp.lstat(idFile).catch(() => null);
|
|
1518
|
+
if (!info?.isFile() || info.size > PICHAMBER_ID_FILE_MAX_BYTES) return '';
|
|
1519
|
+
const handle = await fsp.open(idFile, fs.constants.O_RDONLY | (fs.constants.O_NOFOLLOW ?? 0)).catch(() => null);
|
|
1520
|
+
if (!handle) return '';
|
|
1521
|
+
try {
|
|
1522
|
+
const buffer = Buffer.alloc(PICHAMBER_ID_FILE_MAX_BYTES + 1);
|
|
1523
|
+
const { bytesRead } = await handle.read(buffer, 0, buffer.length, 0);
|
|
1524
|
+
return bytesRead > PICHAMBER_ID_FILE_MAX_BYTES ? '' : buffer.toString('utf8', 0, bytesRead).trim();
|
|
1525
|
+
} catch {
|
|
1526
|
+
return '';
|
|
1527
|
+
} finally {
|
|
1528
|
+
await handle.close().catch(() => undefined);
|
|
1529
|
+
}
|
|
1530
|
+
};
|
|
1531
|
+
|
|
1532
|
+
const writePiChamberIdFile = async (idFile, projectId) => {
|
|
1533
|
+
const info = await fsp.lstat(idFile).catch((error) => (error?.code === 'ENOENT' ? null : undefined));
|
|
1534
|
+
// A symlink is replaced itself by the rename below; anything else that is
|
|
1535
|
+
// not a regular file (a directory, a device) is left alone.
|
|
1536
|
+
if (info === undefined || (info && !info.isFile() && !info.isSymbolicLink())) return;
|
|
1537
|
+
const temp = `${idFile}.${process.pid}.${crypto.randomBytes(8).toString('hex')}.tmp`;
|
|
1538
|
+
try {
|
|
1539
|
+
await fsp.writeFile(temp, projectId, { encoding: 'utf8', flag: 'wx', mode: 0o644 });
|
|
1540
|
+
await fsp.rename(temp, idFile);
|
|
1541
|
+
} catch {
|
|
1542
|
+
await fsp.rm(temp, { force: true }).catch(() => undefined);
|
|
1543
|
+
}
|
|
1544
|
+
};
|
|
1545
|
+
|
|
1546
|
+
// The id a sandboxed project was first seen with. Its sandbox owns and is
|
|
1547
|
+
// granted `worktree/<that id>` only, and the sandboxed agent can rewrite the
|
|
1548
|
+
// id file, so a remembered id stands whatever the file says: a worktree
|
|
1549
|
+
// created under another id would be outside the sandbox, or inside another
|
|
1550
|
+
// project's. An unreadable record throws rather than trust the file.
|
|
1551
|
+
const rememberedPiChamberProjectIds = async (primaryWorktree) => {
|
|
1552
|
+
const ids = await createWorktreeIdStore({ file: resolvePiChamberDataPath(['pi', 'sandbox', 'worktree-ids.json']) }).read();
|
|
1553
|
+
const root = path.resolve(primaryWorktree);
|
|
1554
|
+
const real = await fsp.realpath(root).catch(() => root);
|
|
1555
|
+
return {
|
|
1556
|
+
own: ids.get(root) ?? ids.get(real) ?? null,
|
|
1557
|
+
// Ids remembered for other projects: their sandboxes are granted those
|
|
1558
|
+
// folders, so this project's worktrees must not be filed there.
|
|
1559
|
+
others: new Set([...ids].filter(([other]) => other !== root && other !== real).map(([, id]) => id)),
|
|
1560
|
+
};
|
|
1561
|
+
};
|
|
1562
|
+
|
|
1563
|
+
// The worktree folder id of a project nothing is remembered for. A clone of
|
|
1564
|
+
// a repository whose folder a sandboxed project holds gets its own instead.
|
|
1565
|
+
const unsharedPiChamberProjectId = (primaryWorktree, id, others) => (
|
|
1566
|
+
others.has(id) ? ownWorktreeId(primaryWorktree) : id
|
|
1567
|
+
);
|
|
1568
|
+
|
|
1509
1569
|
const ensurePiChamberProjectId = async (primaryWorktree) => {
|
|
1570
|
+
const { own: remembered, others } = await rememberedPiChamberProjectIds(primaryWorktree);
|
|
1571
|
+
if (remembered) return remembered;
|
|
1510
1572
|
const gitDir = path.join(primaryWorktree, '.git');
|
|
1511
1573
|
const idFile = path.join(gitDir, 'pichamber');
|
|
1512
|
-
const existing = await
|
|
1513
|
-
|
|
1514
|
-
|
|
1574
|
+
const existing = await readPiChamberIdFile(idFile);
|
|
1575
|
+
// The id names a folder under the data directory, and an agent working in
|
|
1576
|
+
// the repository can write this file: only a commit hash is taken from it.
|
|
1577
|
+
// Anything else is replaced by the id derived below.
|
|
1578
|
+
if (/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/.test(existing)) {
|
|
1579
|
+
return unsharedPiChamberProjectId(primaryWorktree, existing, others);
|
|
1515
1580
|
}
|
|
1516
1581
|
|
|
1517
1582
|
const rootsResult = await runGitCommandOrThrow(
|
|
@@ -1532,9 +1597,9 @@ const ensurePiChamberProjectId = async (primaryWorktree) => {
|
|
|
1532
1597
|
}
|
|
1533
1598
|
|
|
1534
1599
|
await fsp.mkdir(gitDir, { recursive: true }).catch(() => undefined);
|
|
1535
|
-
await
|
|
1600
|
+
await writePiChamberIdFile(idFile, projectId);
|
|
1536
1601
|
|
|
1537
|
-
return projectId;
|
|
1602
|
+
return unsharedPiChamberProjectId(primaryWorktree, projectId, others);
|
|
1538
1603
|
};
|
|
1539
1604
|
|
|
1540
1605
|
const resolveWorktreeProjectContext = async (directory) => {
|
|
@@ -622,6 +622,185 @@ describe('worktree root resolution', () => {
|
|
|
622
622
|
// ---------------------------------------------------------------------------
|
|
623
623
|
|
|
624
624
|
describe('createWorktree', () => {
|
|
625
|
+
it('takes only a commit hash from the repository id file, so worktrees stay under the data folder', async () => {
|
|
626
|
+
if (!canRunGit()) return;
|
|
627
|
+
|
|
628
|
+
const previousPiChamberDataDir = process.env.PICHAMBER_DATA_DIR;
|
|
629
|
+
const dataHome = createTempDir();
|
|
630
|
+
process.env.PICHAMBER_DATA_DIR = dataHome;
|
|
631
|
+
try {
|
|
632
|
+
const repo = createTempDir();
|
|
633
|
+
runGit(repo, ['init', '-b', 'main']);
|
|
634
|
+
runGit(repo, ['config', 'user.email', 'test@example.com']);
|
|
635
|
+
runGit(repo, ['config', 'user.name', 'Test User']);
|
|
636
|
+
fs.writeFileSync(path.join(repo, 'README.md'), '# Test\n');
|
|
637
|
+
runGit(repo, ['add', 'README.md']);
|
|
638
|
+
runGit(repo, ['commit', '-m', 'Initial commit']);
|
|
639
|
+
const rootCommit = runGit(repo, ['rev-list', '--max-parents=0', 'HEAD']).trim();
|
|
640
|
+
// Something working in the repository pointed the id out of the data folder.
|
|
641
|
+
const idFile = path.join(repo, '.git', 'pichamber');
|
|
642
|
+
fs.writeFileSync(idFile, '../../escape');
|
|
643
|
+
|
|
644
|
+
const created = await createWorktree(repo, {
|
|
645
|
+
mode: 'new',
|
|
646
|
+
branchName: 'feature/id-check',
|
|
647
|
+
worktreeName: 'id-check',
|
|
648
|
+
returnAfterDirectoryCreated: true,
|
|
649
|
+
});
|
|
650
|
+
|
|
651
|
+
const worktreeRoot = path.join(fs.realpathSync(dataHome), 'worktree', rootCommit);
|
|
652
|
+
expect(fs.realpathSync(created.path).startsWith(`${worktreeRoot}${path.sep}`)).toBe(true);
|
|
653
|
+
expect(fs.existsSync(path.join(dataHome, 'escape'))).toBe(false);
|
|
654
|
+
expect(fs.readFileSync(idFile, 'utf8')).toBe(rootCommit);
|
|
655
|
+
await expect.poll(
|
|
656
|
+
async () => (await getWorktreeBootstrapStatus(created.path)).phase,
|
|
657
|
+
{ timeout: 5_000 },
|
|
658
|
+
).toBe('setup-ready');
|
|
659
|
+
} finally {
|
|
660
|
+
if (previousPiChamberDataDir === undefined) {
|
|
661
|
+
delete process.env.PICHAMBER_DATA_DIR;
|
|
662
|
+
} else {
|
|
663
|
+
process.env.PICHAMBER_DATA_DIR = previousPiChamberDataDir;
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
});
|
|
667
|
+
|
|
668
|
+
it('keeps a project\'s worktrees out of a folder remembered for another (sandboxed) project', async () => {
|
|
669
|
+
if (!canRunGit()) return;
|
|
670
|
+
|
|
671
|
+
const previousPiChamberDataDir = process.env.PICHAMBER_DATA_DIR;
|
|
672
|
+
const dataHome = createTempDir();
|
|
673
|
+
process.env.PICHAMBER_DATA_DIR = dataHome;
|
|
674
|
+
try {
|
|
675
|
+
const repo = createTempDir();
|
|
676
|
+
runGit(repo, ['init', '-b', 'main']);
|
|
677
|
+
runGit(repo, ['config', 'user.email', 'test@example.com']);
|
|
678
|
+
runGit(repo, ['config', 'user.name', 'Test User']);
|
|
679
|
+
fs.writeFileSync(path.join(repo, 'README.md'), '# Test\n');
|
|
680
|
+
runGit(repo, ['add', 'README.md']);
|
|
681
|
+
runGit(repo, ['commit', '-m', 'Initial commit']);
|
|
682
|
+
// Another clone of this repository is sandboxed and holds the folder
|
|
683
|
+
// named by the repository's root commit.
|
|
684
|
+
const shared = runGit(repo, ['rev-list', '--max-parents=0', 'HEAD']).trim();
|
|
685
|
+
const record = path.join(dataHome, 'pi', 'sandbox', 'worktree-ids.json');
|
|
686
|
+
fs.mkdirSync(path.dirname(record), { recursive: true });
|
|
687
|
+
fs.writeFileSync(record, JSON.stringify({ version: 1, projects: { '/code/other-clone': shared } }));
|
|
688
|
+
|
|
689
|
+
const created = await createWorktree(repo, {
|
|
690
|
+
mode: 'new',
|
|
691
|
+
branchName: 'feature/own-folder',
|
|
692
|
+
worktreeName: 'own-folder',
|
|
693
|
+
returnAfterDirectoryCreated: true,
|
|
694
|
+
});
|
|
695
|
+
expect(fs.existsSync(path.join(dataHome, 'worktree', shared))).toBe(false);
|
|
696
|
+
expect(fs.realpathSync(created.path).startsWith(`${path.join(fs.realpathSync(dataHome), 'worktree')}${path.sep}`)).toBe(true);
|
|
697
|
+
await expect.poll(
|
|
698
|
+
async () => (await getWorktreeBootstrapStatus(created.path)).phase,
|
|
699
|
+
{ timeout: 5_000 },
|
|
700
|
+
).toBe('setup-ready');
|
|
701
|
+
} finally {
|
|
702
|
+
if (previousPiChamberDataDir === undefined) {
|
|
703
|
+
delete process.env.PICHAMBER_DATA_DIR;
|
|
704
|
+
} else {
|
|
705
|
+
process.env.PICHAMBER_DATA_DIR = previousPiChamberDataDir;
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
});
|
|
709
|
+
|
|
710
|
+
it('files worktrees under the id remembered for a sandboxed project, whatever its id file says', async () => {
|
|
711
|
+
if (!canRunGit()) return;
|
|
712
|
+
|
|
713
|
+
const previousPiChamberDataDir = process.env.PICHAMBER_DATA_DIR;
|
|
714
|
+
const dataHome = createTempDir();
|
|
715
|
+
process.env.PICHAMBER_DATA_DIR = dataHome;
|
|
716
|
+
try {
|
|
717
|
+
const repo = createTempDir();
|
|
718
|
+
runGit(repo, ['init', '-b', 'main']);
|
|
719
|
+
runGit(repo, ['config', 'user.email', 'test@example.com']);
|
|
720
|
+
runGit(repo, ['config', 'user.name', 'Test User']);
|
|
721
|
+
fs.writeFileSync(path.join(repo, 'README.md'), '# Test\n');
|
|
722
|
+
runGit(repo, ['add', 'README.md']);
|
|
723
|
+
runGit(repo, ['commit', '-m', 'Initial commit']);
|
|
724
|
+
const remembered = 'c'.repeat(40);
|
|
725
|
+
const record = path.join(dataHome, 'pi', 'sandbox', 'worktree-ids.json');
|
|
726
|
+
fs.mkdirSync(path.dirname(record), { recursive: true });
|
|
727
|
+
fs.writeFileSync(record, JSON.stringify({ version: 1, projects: { [path.resolve(repo)]: remembered } }));
|
|
728
|
+
// The sandboxed agent named another project's worktree folder.
|
|
729
|
+
const idFile = path.join(repo, '.git', 'pichamber');
|
|
730
|
+
fs.writeFileSync(idFile, 'd'.repeat(40));
|
|
731
|
+
|
|
732
|
+
const created = await createWorktree(repo, {
|
|
733
|
+
mode: 'new',
|
|
734
|
+
branchName: 'feature/remembered',
|
|
735
|
+
worktreeName: 'remembered',
|
|
736
|
+
returnAfterDirectoryCreated: true,
|
|
737
|
+
});
|
|
738
|
+
const worktreeRoot = path.join(fs.realpathSync(dataHome), 'worktree', remembered);
|
|
739
|
+
expect(fs.realpathSync(created.path).startsWith(`${worktreeRoot}${path.sep}`)).toBe(true);
|
|
740
|
+
expect(fs.existsSync(path.join(dataHome, 'worktree', 'd'.repeat(40)))).toBe(false);
|
|
741
|
+
await expect.poll(
|
|
742
|
+
async () => (await getWorktreeBootstrapStatus(created.path)).phase,
|
|
743
|
+
{ timeout: 5_000 },
|
|
744
|
+
).toBe('setup-ready');
|
|
745
|
+
|
|
746
|
+
// A record that cannot be read is not answered from the file.
|
|
747
|
+
fs.writeFileSync(record, '{');
|
|
748
|
+
await expect(createWorktree(repo, {
|
|
749
|
+
mode: 'new',
|
|
750
|
+
branchName: 'feature/unreadable',
|
|
751
|
+
worktreeName: 'unreadable',
|
|
752
|
+
returnAfterDirectoryCreated: true,
|
|
753
|
+
})).rejects.toThrow();
|
|
754
|
+
expect(fs.existsSync(path.join(dataHome, 'worktree', 'd'.repeat(40)))).toBe(false);
|
|
755
|
+
} finally {
|
|
756
|
+
if (previousPiChamberDataDir === undefined) {
|
|
757
|
+
delete process.env.PICHAMBER_DATA_DIR;
|
|
758
|
+
} else {
|
|
759
|
+
process.env.PICHAMBER_DATA_DIR = previousPiChamberDataDir;
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
});
|
|
763
|
+
|
|
764
|
+
it('does not follow a symlink planted at the repository id file', async () => {
|
|
765
|
+
if (!canRunGit()) return;
|
|
766
|
+
|
|
767
|
+
const previousPiChamberDataDir = process.env.PICHAMBER_DATA_DIR;
|
|
768
|
+
const dataHome = createTempDir();
|
|
769
|
+
process.env.PICHAMBER_DATA_DIR = dataHome;
|
|
770
|
+
try {
|
|
771
|
+
const repo = createTempDir();
|
|
772
|
+
runGit(repo, ['init', '-b', 'main']);
|
|
773
|
+
runGit(repo, ['config', 'user.email', 'test@example.com']);
|
|
774
|
+
runGit(repo, ['config', 'user.name', 'Test User']);
|
|
775
|
+
fs.writeFileSync(path.join(repo, 'README.md'), '# Test\n');
|
|
776
|
+
runGit(repo, ['add', 'README.md']);
|
|
777
|
+
runGit(repo, ['commit', '-m', 'Initial commit']);
|
|
778
|
+
const rootCommit = runGit(repo, ['rev-list', '--max-parents=0', 'HEAD']).trim();
|
|
779
|
+
const victim = path.join(createTempDir(), 'victim.txt');
|
|
780
|
+
fs.writeFileSync(victim, 'untouched');
|
|
781
|
+
const idFile = path.join(repo, '.git', 'pichamber');
|
|
782
|
+
fs.symlinkSync(victim, idFile);
|
|
783
|
+
|
|
784
|
+
await createWorktree(repo, {
|
|
785
|
+
mode: 'new',
|
|
786
|
+
branchName: 'feature/link-check',
|
|
787
|
+
worktreeName: 'link-check',
|
|
788
|
+
returnAfterDirectoryCreated: true,
|
|
789
|
+
});
|
|
790
|
+
|
|
791
|
+
expect(fs.readFileSync(victim, 'utf8')).toBe('untouched');
|
|
792
|
+
expect(fs.lstatSync(idFile).isSymbolicLink()).toBe(false);
|
|
793
|
+
expect(fs.readFileSync(idFile, 'utf8')).toBe(rootCommit);
|
|
794
|
+
expect(fs.readdirSync(path.join(repo, '.git')).filter((name) => name.endsWith('.tmp'))).toEqual([]);
|
|
795
|
+
} finally {
|
|
796
|
+
if (previousPiChamberDataDir === undefined) {
|
|
797
|
+
delete process.env.PICHAMBER_DATA_DIR;
|
|
798
|
+
} else {
|
|
799
|
+
process.env.PICHAMBER_DATA_DIR = previousPiChamberDataDir;
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
});
|
|
803
|
+
|
|
625
804
|
it('returns ready/setup-ready when no bootstrap state is recorded', async () => {
|
|
626
805
|
const directory = path.join(createTempDir(), 'missing-worktree');
|
|
627
806
|
|
|
@@ -7,6 +7,8 @@ server runtime. Every GitHub call runs here; the shared UI talks to
|
|
|
7
7
|
`/api/github/*` through `RuntimeAPIs.github`, so web, desktop, hosted
|
|
8
8
|
mobile, and Capacitor share one code path. Tokens never reach a client.
|
|
9
9
|
|
|
10
|
+
Sandboxing: Only Pi session daemons (the agent) run in the sandbox. PiChamber's own Git panel, terminal, browser and GitHub features, and worktree hooks and start commands, run outside it with the user's access, so git config, hooks or filters an agent writes into the repo can run when the user or the Git panel runs git. This is a known, accepted trade-off. The GitHub module's git calls run unsandboxed for every folder.
|
|
11
|
+
|
|
10
12
|
## Entrypoints and structure
|
|
11
13
|
|
|
12
14
|
- `packages/web/server/lib/github/`: module directory.
|
|
@@ -73,8 +75,10 @@ no per-route auth is added here.
|
|
|
73
75
|
- Minimum gh version: `2.4.0` (`MIN_GH_VERSION` in `gh-cli.js`), floored by
|
|
74
76
|
the flags used (`gh auth token --hostname`, plain `gh auth status`).
|
|
75
77
|
`gh auth status --json hosts` is attempted first and plain-text parsing
|
|
76
|
-
is the fallback
|
|
77
|
-
|
|
78
|
+
is the fallback for gh versions that reject `--json` (2.46 does). Current
|
|
79
|
+
gh lists every account signed in to a host; status reports one entry per
|
|
80
|
+
host, the active account, and counts it signed in only when its `state`
|
|
81
|
+
is `success`.
|
|
78
82
|
- Token: `gh auth token --hostname <host>` via `execFile` (arg array, no
|
|
79
83
|
shell), 5 s timeout, memory only, ~30 s cache per host.
|
|
80
84
|
- Pinning: `withPinnedCredential(host, task)` reads the token once per
|
|
@@ -92,24 +92,50 @@ export const parsePlainAuthStatus = (text) => {
|
|
|
92
92
|
};
|
|
93
93
|
|
|
94
94
|
const parseJsonAuthStatus = (text) => {
|
|
95
|
-
//
|
|
96
|
-
// `{ "hosts": { "github.com": { "
|
|
97
|
-
//
|
|
95
|
+
// `gh auth status --json hosts` shapes seen in the wild:
|
|
96
|
+
// `{ "hosts": { "github.com": [ { "login": "...", "state": "success", ... } ] } }`
|
|
97
|
+
// (current gh), a flat `{ "hosts": { "github.com": { ... } } }`, and
|
|
98
|
+
// `{ "hosts": [ { "hostname": "...", "user": "..." } ] }`.
|
|
98
99
|
const parsed = JSON.parse(String(text || ''));
|
|
99
100
|
const raw = parsed?.hosts;
|
|
100
|
-
const entries =
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
const entries = [];
|
|
102
|
+
const push = (hostname, info) => {
|
|
103
|
+
// A host maps to every account signed in there. The module follows gh's
|
|
104
|
+
// active account, so keep that one (or the first, if none is marked).
|
|
105
|
+
const accounts = (Array.isArray(info) ? info : [info])
|
|
106
|
+
.filter((account) => account && typeof account === 'object');
|
|
107
|
+
const account = accounts.find((candidate) => candidate.active === true) || accounts[0];
|
|
108
|
+
if (account) entries.push({ hostname, ...account });
|
|
109
|
+
};
|
|
110
|
+
if (Array.isArray(raw)) {
|
|
111
|
+
for (const info of raw) push(info?.hostname || info?.host, info);
|
|
112
|
+
} else if (raw && typeof raw === 'object') {
|
|
113
|
+
for (const [hostname, info] of Object.entries(raw)) push(hostname, info);
|
|
114
|
+
}
|
|
103
115
|
const hosts = [];
|
|
104
116
|
for (const entry of entries) {
|
|
105
117
|
const host = String(entry.hostname || entry.host || '').trim().toLowerCase();
|
|
106
118
|
if (!host) continue;
|
|
107
|
-
const login =
|
|
119
|
+
const login = [entry.login, entry.user].find((value) => typeof value === 'string' && value) || null;
|
|
120
|
+
// `scopes` is a comma-separated string on current gh; older shapes used an array.
|
|
121
|
+
const rawScopes = entry.tokenScopes ?? entry.scopes;
|
|
122
|
+
const scopes = Array.isArray(rawScopes)
|
|
123
|
+
? rawScopes.filter((scope) => typeof scope === 'string')
|
|
124
|
+
: (typeof rawScopes === 'string'
|
|
125
|
+
? rawScopes.split(',').map((scope) => scope.trim()).filter(Boolean)
|
|
126
|
+
: []);
|
|
127
|
+
// `state` is the verdict. A record for a rejected token still carries
|
|
128
|
+
// `active: true` (and can carry a login), so neither proves the token
|
|
129
|
+
// works: `gh` exits successfully in JSON mode and the error is only in
|
|
130
|
+
// `state`. Shapes without `state` fall back to the legacy predicate.
|
|
131
|
+
const authenticated = typeof entry.state === 'string'
|
|
132
|
+
? entry.state === 'success'
|
|
133
|
+
: Boolean(login || entry.active === true);
|
|
108
134
|
hosts.push({
|
|
109
135
|
host,
|
|
110
|
-
authenticated
|
|
136
|
+
authenticated,
|
|
111
137
|
login,
|
|
112
|
-
scopes
|
|
138
|
+
scopes,
|
|
113
139
|
});
|
|
114
140
|
}
|
|
115
141
|
return hosts;
|