@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.
Files changed (265) hide show
  1. package/dist/assets/AgentsSurface-CcWBqAWV.js +1 -0
  2. package/dist/assets/ChoicesArtifact-Kk-qvrSB.js +1 -0
  3. package/dist/assets/DiagramView-DZUBo1uP.js +1 -0
  4. package/dist/assets/{DiffView-BxW6BuOC.js → DiffView-CiZy4jFA.js} +6 -6
  5. package/dist/assets/FileSaveConflictDialog-DZ9NDwOO.js +3 -0
  6. package/dist/assets/FilesView-DqiZ9kw9.js +6 -0
  7. package/dist/assets/GitHubDetailScaffold-DM2DH7o8.js +11 -0
  8. package/dist/assets/GitHubLinkPicker-ChB8NZ1h.js +1 -0
  9. package/dist/assets/GitHubListPrimitives-CibDiJGq.js +1 -0
  10. package/dist/assets/{GitView-DD33ngnM.js → GitView--EaZQrBr.js} +5 -5
  11. package/dist/assets/{IssuesSurface-BAY_eyX5.js → IssuesSurface-CySTpaD1.js} +3 -3
  12. package/dist/assets/{JsonTreeView-DpXbUrAl.js → JsonTreeView-_yMHKKQZ.js} +1 -1
  13. package/dist/assets/{MarkdownRendererImpl-Cn63lAmn.js → MarkdownRendererImpl-D_-2fQw0.js} +3 -3
  14. package/dist/assets/PatchDiff-bHObDlhD.js +1 -0
  15. package/dist/assets/PierreDiffViewer-UY7Cse-s.js +147 -0
  16. package/dist/assets/PullRequestsSurface-iXy6chwc.js +2 -0
  17. package/dist/assets/{SessionSwitcherContent-CscYekC1.js → SessionSwitcherContent-DJGCa_wN.js} +1 -1
  18. package/dist/assets/SessionSwitcherDropdown-CDOX-5Y2.js +2 -0
  19. package/dist/assets/SessionUnreadDot-Dwc3MdvA.js +1 -0
  20. package/dist/assets/SettingsView-DA-U9lsj.js +11 -0
  21. package/dist/assets/{SettingsWindow-gxjULdm1.js → SettingsWindow-CUg49Mfh.js} +1 -1
  22. package/dist/assets/{StickyHorizontalScrollbar-DNsbTLS7.js → StickyHorizontalScrollbar-CMbTn5WQ.js} +1 -1
  23. package/dist/assets/SubagentsArtifact-DUZX9tDe.js +1 -0
  24. package/dist/assets/ToolOutputDialog-BuZZaRw4.js +8 -0
  25. package/dist/assets/ToolPartDiffPreview-CKncG6i2.js +1 -0
  26. package/dist/assets/{VirtualizedFileDiff-BrbPymTL.js → VirtualizedFileDiff-BGZiLPe_.js} +4 -4
  27. package/dist/assets/{Virtualizer-okhy9Aq3.js → Virtualizer-PxblpQn6.js} +1 -1
  28. package/dist/assets/VisualFrame-DBZkHFnG.js +22 -0
  29. package/dist/assets/VisualsArtifact-Bq0vMO-i.js +1 -0
  30. package/dist/assets/{collapsible-D6qdoq7-.js → collapsible-Bro9KrfM.js} +1 -1
  31. package/dist/assets/{computeVirtualFileMetrics-G4csGiKs.js → computeVirtualFileMetrics-DJQqK49u.js} +2 -2
  32. package/dist/assets/contextFileOpenGuard-ByWK3Sru.js +1 -0
  33. package/dist/assets/{fileTreeStatus-Bskhj4qT.js → fileTreeStatus-CyJ3TOYD.js} +2 -2
  34. package/dist/assets/gitStatusPredicates-BsXrwngT.js +1 -0
  35. package/dist/assets/githubLink-g2bmC0qi.js +10 -0
  36. package/dist/assets/index-B_L9GVYw.css +1 -0
  37. package/dist/assets/{index-ComwtfT4.js → index-C9rUUQ_Y.js} +1 -1
  38. package/dist/assets/index-CKKWVoND.js +11 -0
  39. package/dist/assets/{main-DoiadX0a.js → main-DT-4_fhe.js} +2 -2
  40. package/dist/assets/main-DsLMU9CT.js +137 -0
  41. package/dist/assets/{markdownCore-DczkEluO.js → markdownCore-QmM_aOnZ.js} +2 -2
  42. package/dist/assets/{miniChat-Ck6MEZ9Q.js → miniChat-BqGslD2z.js} +2 -2
  43. package/dist/assets/{mobile-BucKVm1P.js → mobile-C5JOcDIC.js} +2 -2
  44. package/dist/assets/{nativeFileSave-Cp9i5QGd.js → nativeFileSave-DSMsJqXM.js} +1 -1
  45. package/dist/assets/pi-session-focus-preference-Cc_S4zi1.js +9 -0
  46. package/dist/assets/{renderDiffWithHighlighter-PL82AR81.js → renderDiffWithHighlighter-BXhnIAHg.js} +1 -1
  47. package/dist/assets/renderElectronMiniChatApp-CiSkecEE.js +2 -0
  48. package/dist/assets/{renderFileWithHighlighter-CYgfbA4F.js → renderFileWithHighlighter-CK29YZtC.js} +1 -1
  49. package/dist/assets/renderMobileApp-C4JuoxsZ.js +11 -0
  50. package/dist/assets/runtimeEndpointReset-Dwj-jCDS.js +66 -0
  51. package/dist/assets/runtimeSurface-0K7vuUpd.js +1 -0
  52. package/dist/assets/selection-CnYkEsu_.js +1 -0
  53. package/dist/assets/useAppFontEffects-CV5UyTRw.js +226 -0
  54. package/dist/assets/useGitHubRemoteSearch-CgP-zEBj.js +1 -0
  55. package/dist/assets/useSwitcherItems-C8G5F0hs.js +1 -0
  56. package/dist/assets/{vendor-aparajita-capacitor-secure-storage-DVZvgYu4.js → vendor-aparajita-capacitor-secure-storage-DUoR8t1G.js} +1 -1
  57. package/dist/assets/{vendor-base-ui-BCqPBzDj.js → vendor-base-ui-DE6jnTiC.js} +1 -1
  58. package/dist/assets/{vendor-boot-3SaHYVb1.js → vendor-boot-D-KEJjsM.js} +29 -29
  59. package/dist/assets/{vendor-capacitor-app-NbQ-WiPS.js → vendor-capacitor-app-CO5jS31X.js} +1 -1
  60. package/dist/assets/{vendor-capacitor-keyboard-CgrHt8iN.js → vendor-capacitor-keyboard-335osRpd.js} +1 -1
  61. package/dist/assets/{vendor-capacitor-status-bar-CWt0OF5t.js → vendor-capacitor-status-bar-lB9y4H9d.js} +1 -1
  62. package/dist/assets/{vendor-codemirror-autocomplete-WThuuUAz.js → vendor-codemirror-autocomplete-BKvJ8PfM.js} +1 -1
  63. package/dist/assets/{vendor-codemirror-lang-angular-BbLGCxF6.js → vendor-codemirror-lang-angular-wjCUD0bM.js} +1 -1
  64. package/dist/assets/{vendor-codemirror-lang-cpp-Cceks-9O.js → vendor-codemirror-lang-cpp-LJzlG8sJ.js} +1 -1
  65. package/dist/assets/{vendor-codemirror-lang-css-D1wpUg3Z.js → vendor-codemirror-lang-css-DoEEdEpW.js} +1 -1
  66. package/dist/assets/{vendor-codemirror-lang-go-Cv0zXHHM.js → vendor-codemirror-lang-go-DexsLPb8.js} +1 -1
  67. package/dist/assets/{vendor-codemirror-lang-html-DbL8oT9H.js → vendor-codemirror-lang-html-h25V-Hp5.js} +1 -1
  68. package/dist/assets/{vendor-codemirror-lang-java-CNugenuC.js → vendor-codemirror-lang-java-D8xoT8cv.js} +1 -1
  69. package/dist/assets/{vendor-codemirror-lang-javascript-Bx_FIyZF.js → vendor-codemirror-lang-javascript-DF3GDYje.js} +1 -1
  70. package/dist/assets/{vendor-codemirror-lang-jinja-DDGjB3Zq.js → vendor-codemirror-lang-jinja-BboTHFdn.js} +1 -1
  71. package/dist/assets/{vendor-codemirror-lang-json-DIvqf9Pb.js → vendor-codemirror-lang-json-DCqvG1nE.js} +1 -1
  72. package/dist/assets/{vendor-codemirror-lang-less-D8r9dGG1.js → vendor-codemirror-lang-less-B8ZrSKJM.js} +1 -1
  73. package/dist/assets/{vendor-codemirror-lang-liquid-B24mguYi.js → vendor-codemirror-lang-liquid-DF9S5m5F.js} +1 -1
  74. package/dist/assets/{vendor-codemirror-lang-markdown-v3yG2sbf.js → vendor-codemirror-lang-markdown-6BNbCEPe.js} +1 -1
  75. package/dist/assets/{vendor-codemirror-lang-php-BcZGalqy.js → vendor-codemirror-lang-php-CQwAz1Hd.js} +1 -1
  76. package/dist/assets/{vendor-codemirror-lang-python-b-JqEwQy.js → vendor-codemirror-lang-python-DQym-8Tx.js} +1 -1
  77. package/dist/assets/{vendor-codemirror-lang-rust-B1uZxDW-.js → vendor-codemirror-lang-rust-DknzOTkO.js} +1 -1
  78. package/dist/assets/{vendor-codemirror-lang-sass-DqPrngKp.js → vendor-codemirror-lang-sass-dB0Rm5HI.js} +1 -1
  79. package/dist/assets/{vendor-codemirror-lang-sql-UyCnpt-k.js → vendor-codemirror-lang-sql-CCQUnnD-.js} +1 -1
  80. package/dist/assets/{vendor-codemirror-lang-vue-xDwYkovV.js → vendor-codemirror-lang-vue-h1M5bF00.js} +1 -1
  81. package/dist/assets/{vendor-codemirror-lang-wast-CF3169p_.js → vendor-codemirror-lang-wast-DWgtlGfu.js} +1 -1
  82. package/dist/assets/{vendor-codemirror-lang-xml-FCtVhuOb.js → vendor-codemirror-lang-xml-DncwoCUY.js} +1 -1
  83. package/dist/assets/{vendor-codemirror-lang-yaml-g0sPmAnv.js → vendor-codemirror-lang-yaml-C7QkS5ER.js} +1 -1
  84. package/dist/assets/{vendor-codemirror-language-data-B03xgzP2.js → vendor-codemirror-language-data-BUZIlm3G.js} +2 -2
  85. package/dist/assets/{vendor-codemirror-search-Dw3Wpu15.js → vendor-codemirror-search-BlDCaCMK.js} +1 -1
  86. package/dist/assets/{vendor-lezer-cpp-Cu3E-KUI.js → vendor-lezer-cpp-B4JK1BC1.js} +1 -1
  87. package/dist/assets/{vendor-lezer-css-Cb8vp67u.js → vendor-lezer-css-DRxDmhcy.js} +1 -1
  88. package/dist/assets/{vendor-lezer-go-BTsIaOm7.js → vendor-lezer-go-DsUgfmxi.js} +1 -1
  89. package/dist/assets/{vendor-lezer-html-UQMsUwj-.js → vendor-lezer-html-qr9pUPmM.js} +1 -1
  90. package/dist/assets/{vendor-lezer-java-BIWrFrAx.js → vendor-lezer-java-6UyNiQiB.js} +1 -1
  91. package/dist/assets/{vendor-lezer-javascript-BH2Etgoy.js → vendor-lezer-javascript-CUdJ0VGA.js} +1 -1
  92. package/dist/assets/{vendor-lezer-json-CE-QUCwM.js → vendor-lezer-json-BKYAA8Hu.js} +1 -1
  93. package/dist/assets/{vendor-lezer-lr-HY6Yc0Vr.js → vendor-lezer-lr-DluApmOX.js} +1 -1
  94. package/dist/assets/{vendor-lezer-markdown-xFL3Evwf.js → vendor-lezer-markdown-B-uzYzYT.js} +1 -1
  95. package/dist/assets/{vendor-lezer-php-Cr_mQGrG.js → vendor-lezer-php-DI6PNjlz.js} +1 -1
  96. package/dist/assets/{vendor-lezer-python-BNRFWCb0.js → vendor-lezer-python-Bj232yb5.js} +1 -1
  97. package/dist/assets/{vendor-lezer-rust-BvfOK5cU.js → vendor-lezer-rust-DlPG_Yau.js} +1 -1
  98. package/dist/assets/{vendor-lezer-sass-qoxiLisk.js → vendor-lezer-sass-CBsyWB2A.js} +1 -1
  99. package/dist/assets/{vendor-lezer-xml--x8SSpqU.js → vendor-lezer-xml-C1FmgtmE.js} +1 -1
  100. package/dist/assets/{vendor-lezer-yaml-BDo1JaEr.js → vendor-lezer-yaml-DpHmjriG.js} +1 -1
  101. package/dist/assets/{vendor-replit-codemirror-vim-D1Fe7FiY.js → vendor-replit-codemirror-vim-Cvk64got.js} +1 -1
  102. package/dist/assets/{web-components-CGDpzixf.js → web-components-BpncHjnV.js} +4 -4
  103. package/dist/index.html +4 -4
  104. package/dist/mini-chat.html +3 -3
  105. package/dist/mobile.html +3 -3
  106. package/package.json +2 -1
  107. package/plugins/featured.json +12 -0
  108. package/plugins/registry.json +7 -0
  109. package/plugins/subagents/LICENSE +25 -0
  110. package/plugins/subagents/agents/planner.md +36 -0
  111. package/plugins/subagents/agents/reviewer.md +34 -0
  112. package/plugins/subagents/agents/scout.md +49 -0
  113. package/plugins/subagents/agents/worker.md +23 -0
  114. package/plugins/subagents/extension.js +631 -0
  115. package/plugins/subagents/extension.test.js +295 -0
  116. package/plugins/subagents/package.json +41 -0
  117. package/plugins/visuals/choices.js +168 -0
  118. package/plugins/visuals/extension.js +90 -0
  119. package/plugins/visuals/files.js +74 -0
  120. package/plugins/visuals/package.json +32 -0
  121. package/server/index.js +103 -24
  122. package/server/lib/git/DOCUMENTATION.md +4 -0
  123. package/server/lib/git/service.js +70 -5
  124. package/server/lib/git/service.test.js +179 -0
  125. package/server/lib/github/DOCUMENTATION.md +6 -2
  126. package/server/lib/github/gh-cli.js +35 -9
  127. package/server/lib/github/gh-cli.test.js +122 -0
  128. package/server/lib/marketplace/DOCUMENTATION.md +95 -0
  129. package/server/lib/marketplace/featured.js +176 -0
  130. package/server/lib/marketplace/featured.test.js +207 -0
  131. package/server/lib/marketplace/npm-registry.js +255 -0
  132. package/server/lib/marketplace/npm-registry.test.js +227 -0
  133. package/server/lib/marketplace/routes.js +64 -0
  134. package/server/lib/marketplace/routes.test.js +119 -0
  135. package/server/lib/marketplace/service.js +225 -0
  136. package/server/lib/marketplace/service.test.js +174 -0
  137. package/server/lib/notifications/DOCUMENTATION.md +10 -4
  138. package/server/lib/notifications/pi-notification-watcher.js +95 -33
  139. package/server/lib/notifications/pi-notification-watcher.test.js +89 -0
  140. package/server/lib/open-url/DOCUMENTATION.md +2 -1
  141. package/server/lib/pi/extension-protocol.js +54 -0
  142. package/server/lib/pi/fixtures/pichamber-gui-demo.ts +12 -13
  143. package/server/lib/pi/merged-event-stream.js +316 -0
  144. package/server/lib/pi/merged-event-stream.test.js +95 -0
  145. package/server/lib/pi/routes-daemon-pool.test.js +348 -0
  146. package/server/lib/pi/routes-extension-events.test.js +115 -0
  147. package/server/lib/pi/routes-merged-events.test.js +327 -0
  148. package/server/lib/pi/routes-sandbox.test.js +1684 -0
  149. package/server/lib/pi/routes.js +790 -87
  150. package/server/lib/pi/routes.test.js +381 -1
  151. package/server/lib/pi/sandbox/DOCUMENTATION.md +68 -0
  152. package/server/lib/pi/sandbox/launcher.js +122 -0
  153. package/server/lib/pi/sandbox/launcher.test.js +91 -0
  154. package/server/lib/pi/sandbox/nono-launcher.js +455 -0
  155. package/server/lib/pi/sandbox/nono-launcher.test.js +371 -0
  156. package/server/lib/pi/sandbox/nono-profile-macos.json +20 -0
  157. package/server/lib/pi/sandbox/nono-profile-wsl2.json +21 -0
  158. package/server/lib/pi/sandbox/nono-profile.json +22 -0
  159. package/server/lib/pi/sandbox/project-sandbox-manager.js +1461 -0
  160. package/server/lib/pi/sandbox/project-sandbox-setting.js +166 -0
  161. package/server/lib/pi/sandbox/project-sandbox.js +207 -0
  162. package/server/lib/pi/sandbox/sandbox-routes.js +110 -0
  163. package/server/lib/pi/sandbox/sandboxed-folders.js +100 -0
  164. package/server/lib/pi/sandbox/sandboxed-folders.test.js +65 -0
  165. package/server/lib/pi/sandbox/trust-ask.js +135 -0
  166. package/server/lib/pi/sandbox/trust-ask.test.js +54 -0
  167. package/server/lib/pi/sandbox/worktree-ids.js +96 -0
  168. package/server/lib/pi/sandbox/worktree-ids.test.js +73 -0
  169. package/server/lib/pi/session-daemon/DOCUMENTATION.md +47 -10
  170. package/server/lib/pi/session-daemon/daemon-pool.js +157 -0
  171. package/server/lib/pi/session-daemon/daemon-process.js +10 -1
  172. package/server/lib/pi/session-daemon/extension-bridge.js +89 -29
  173. package/server/lib/pi/session-daemon/extension-config.js +902 -0
  174. package/server/lib/pi/session-daemon/extension-config.test.js +798 -0
  175. package/server/lib/pi/session-daemon/extension-controls.js +177 -0
  176. package/server/lib/pi/session-daemon/extension-controls.test.js +181 -0
  177. package/server/lib/pi/session-daemon/extension-name.js +6 -0
  178. package/server/lib/pi/session-daemon/extension-name.test.js +5 -0
  179. package/server/lib/pi/session-daemon/extension-palette.js +146 -0
  180. package/server/lib/pi/session-daemon/extension-palette.test.js +107 -0
  181. package/server/lib/pi/session-daemon/extension-replacements.js +138 -0
  182. package/server/lib/pi/session-daemon/extension-replacements.test.js +116 -0
  183. package/server/lib/pi/session-daemon/extension-ui-mode.js +30 -0
  184. package/server/lib/pi/session-daemon/extension-ui-mode.test.js +34 -0
  185. package/server/lib/pi/session-daemon/pichamber-ui.js +44 -0
  186. package/server/lib/pi/session-daemon/plugin-host.js +245 -0
  187. package/server/lib/pi/session-daemon/plugin-host.test.js +192 -0
  188. package/server/lib/pi/session-daemon/session-daemon-controls.e2e.test.js +205 -0
  189. package/server/lib/pi/session-daemon/session-daemon-drafts.e2e.test.js +409 -0
  190. package/server/lib/pi/session-daemon/session-daemon-extension-config.e2e.test.js +196 -0
  191. package/server/lib/pi/session-daemon/session-daemon-extensions.test.js +137 -6
  192. package/server/lib/pi/session-daemon/session-daemon-plugins.e2e.test.js +272 -0
  193. package/server/lib/pi/session-daemon/session-daemon-providers.e2e.test.js +153 -0
  194. package/server/lib/pi/session-daemon/session-daemon-read-persisted.test.js +167 -0
  195. package/server/lib/pi/session-daemon/session-daemon.js +927 -108
  196. package/server/lib/pi/session-daemon/session-daemon.test.js +391 -4
  197. package/server/lib/pi/session-daemon/session-engine-router.js +7 -0
  198. package/server/lib/pi/session-daemon/session-engine-router.test.js +20 -0
  199. package/server/lib/pi/session-daemon/session-idle-residency.test.js +98 -1
  200. package/server/lib/pi/session-daemon/session-jsonl.js +49 -10
  201. package/server/lib/pi/session-daemon/session-jsonl.test.js +11 -0
  202. package/server/lib/pi/session-daemon/session-lease.js +93 -15
  203. package/server/lib/pi/session-daemon/session-lease.test.js +107 -1
  204. package/server/lib/pi/session-daemon/supervisor-launcher-stop.test.js +295 -0
  205. package/server/lib/pi/session-daemon/supervisor-sandbox-nono.e2e.test.js +301 -0
  206. package/server/lib/pi/session-daemon/supervisor-sandbox.test.js +444 -0
  207. package/server/lib/pi/session-daemon/supervisor.js +408 -38
  208. package/server/lib/pi/session-daemon/supervisor.test.js +28 -0
  209. package/server/lib/pi/settings-store.js +14 -0
  210. package/server/lib/pi/settings-store.test.js +11 -0
  211. package/server/lib/pi/ui-settings-store.js +88 -2
  212. package/server/lib/pi/ui-settings-store.test.js +118 -0
  213. package/server/lib/plugins/DOCUMENTATION.md +198 -0
  214. package/server/lib/plugins/daemon-sync.js +88 -0
  215. package/server/lib/plugins/daemon-sync.supervisor.test.js +83 -0
  216. package/server/lib/plugins/daemon-sync.test.js +108 -0
  217. package/server/lib/plugins/impact.js +139 -0
  218. package/server/lib/plugins/impact.test.js +83 -0
  219. package/server/lib/plugins/manifest.js +220 -0
  220. package/server/lib/plugins/manifest.test.js +127 -0
  221. package/server/lib/plugins/registry.js +59 -0
  222. package/server/lib/plugins/routes.js +92 -0
  223. package/server/lib/plugins/routes.test.js +247 -0
  224. package/server/lib/plugins/service.js +183 -0
  225. package/server/lib/plugins/store.js +261 -0
  226. package/server/lib/plugins/store.test.js +188 -0
  227. package/server/lib/plugins/visuals-extension.test.js +237 -0
  228. package/server/lib/server/cross-process-lock.js +28 -3
  229. package/server/lib/server-browser/DOCUMENTATION.md +32 -7
  230. package/server/lib/server-browser/browser-tab.js +4 -1
  231. package/server/lib/server-browser/downloads.js +261 -34
  232. package/server/lib/server-browser/downloads.test.js +171 -0
  233. package/server/lib/server-browser/runtime.integration.test.js +47 -0
  234. package/server/lib/server-browser/runtime.js +16 -0
  235. package/server/lib/server-browser/server-browser.js +25 -6
  236. package/server/lib/tunnels/executable-search.js +5 -1
  237. package/server/lib/tunnels/executable-search.test.js +26 -0
  238. package/dist/assets/DiagramView-BB-aZobi.js +0 -1
  239. package/dist/assets/FileSaveConflictDialog-Bzz8FNMq.js +0 -3
  240. package/dist/assets/FilesView-DECxN8Z0.js +0 -6
  241. package/dist/assets/GitHubDetailScaffold-CWsWycRd.js +0 -11
  242. package/dist/assets/GitHubLinkPicker-BVYdg_e8.js +0 -1
  243. package/dist/assets/GitHubListPrimitives-Dlv3tC4d.js +0 -1
  244. package/dist/assets/PatchDiff-BklyOEHs.js +0 -1
  245. package/dist/assets/PierreDiffViewer-wc6cB6qw.js +0 -147
  246. package/dist/assets/PullRequestsSurface-BZvJkT1I.js +0 -2
  247. package/dist/assets/SessionSwitcherDropdown-DShvvGwC.js +0 -2
  248. package/dist/assets/SessionUnreadDot-CbqRq6h_.js +0 -1
  249. package/dist/assets/SettingsView-DcF-At5E.js +0 -6
  250. package/dist/assets/ToolOutputDialog-DdMIfrnK.js +0 -8
  251. package/dist/assets/ToolPartDiffPreview-C6Sm4eVf.js +0 -1
  252. package/dist/assets/contextFileOpenGuard-UU86YHgI.js +0 -1
  253. package/dist/assets/gitStatusPredicates-DQEO4Psc.js +0 -1
  254. package/dist/assets/githubLink-ByPAyFjh.js +0 -10
  255. package/dist/assets/index-BaLCg7tL.css +0 -1
  256. package/dist/assets/index-I2QYqABE.js +0 -11
  257. package/dist/assets/main-DyFfbllq.js +0 -137
  258. package/dist/assets/pi-session-focus-preference-Dx0UXPoO.js +0 -9
  259. package/dist/assets/renderElectronMiniChatApp-Cb7s7dWl.js +0 -2
  260. package/dist/assets/renderMobileApp-Bp74b_Lo.js +0 -11
  261. package/dist/assets/runtimeEndpointReset-7nWYnKd4.js +0 -62
  262. package/dist/assets/runtimeSurface-CFwnvks_.js +0 -1
  263. package/dist/assets/useAppFontEffects-ZTyNwFk6.js +0 -213
  264. package/dist/assets/useGitHubRemoteSearch-BF3ohpsh.js +0 -1
  265. package/dist/assets/useSwitcherItems-BJzwyDGX.js +0 -1
@@ -0,0 +1,902 @@
1
+ // Owns what `pi config`, `pi list`, `pi install npm:<name>`, `pi update`, and
2
+ // `pi remove` do for Pi extensions: listing what is configured (path-free),
3
+ // turning resources on or off per scope, and installing, updating, or
4
+ // removing a configured package. `session-daemon.js` routes the
5
+ // private commands here and supplies the lock, queue, trust, and runtime
6
+ // recreation.
7
+ //
8
+ // Pi keeps the toggle logic private to its terminal screen
9
+ // (`modes/interactive/components/config-selector.js`), so the write functions
10
+ // below reimplement it method by method over a settings-manager-like object.
11
+ // Recheck them against that file on every SDK upgrade.
12
+
13
+ import { createHash } from 'node:crypto';
14
+ import { closeSync, fstatSync, openSync, readSync, realpathSync } from 'node:fs';
15
+ import { homedir } from 'node:os';
16
+ import { basename, dirname, isAbsolute, join, relative, resolve, win32 } from 'node:path';
17
+ import { fileURLToPath } from 'node:url';
18
+ import {
19
+ CONFIG_DIR_NAME,
20
+ DefaultPackageManager,
21
+ SettingsManager,
22
+ } from '@earendil-works/pi-coding-agent';
23
+
24
+ import { LOADED_BUILTIN_EXTENSIONS } from './builtin-extensions.js';
25
+
26
+ // Pi's `BUILTIN_PATH_PREFIX` (core/source-info.js) is not exported.
27
+ // extension-config.test.js pins this against what Pi resolves.
28
+ export const BUILTIN_PATH_PREFIX = 'builtin:';
29
+
30
+ // Resource types Pi's filters know. Only extensions are listed for now; the
31
+ // writes already handle every type so skills, prompts, and themes are additive.
32
+ const RESOURCE_TYPES = ['extensions', 'skills', 'prompts', 'themes'];
33
+ const LISTED_RESOURCE_TYPES = ['extensions'];
34
+ const OVERRIDE_STATES = new Set(['inherit', 'load', 'unload']);
35
+ const GROUP_ORDER = { package: 0, auto: 1, settings: 2, builtin: 3 };
36
+ const MAX_ERROR_MESSAGE_LENGTH = 300;
37
+ const MAX_NAME_LENGTH = 256;
38
+ const ID_PATTERN = /^[A-Za-z0-9_-]{43}$/;
39
+ // npm's rules for a new package name (validate-npm-package-name): lowercase,
40
+ // optional scope, URL-safe characters, no leading `.` or `_`.
41
+ const NPM_PACKAGE_NAME_PATTERN = /^(?:@[a-z0-9~-][a-z0-9._~-]*\/)?[a-z0-9~-][a-z0-9._~-]*$/;
42
+ const MAX_NPM_NAME_LENGTH = 214;
43
+ const MAX_VERSION_LENGTH = 64;
44
+ const VERSION_PATTERN = /^[0-9A-Za-z.+-]+$/;
45
+ // The exact versions semver's `valid()` takes, which is what Pi calls pinned
46
+ // (`isExactNpmVersion` in core/package-manager.js).
47
+ const EXACT_VERSION_PATTERN = /^=?v?\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;
48
+ const MAX_PACKAGE_JSON_BYTES = 256 * 1024;
49
+
50
+ const isValidNpmPackageName = (name) => typeof name === 'string'
51
+ && name.length > 0 && name.length <= MAX_NPM_NAME_LENGTH && NPM_PACKAGE_NAME_PATTERN.test(name);
52
+
53
+ class ExtensionConfigError extends Error {
54
+ constructor(code, message) {
55
+ super(message);
56
+ this.code = code;
57
+ }
58
+ }
59
+
60
+ const invalid = (message = 'The extension configuration request is invalid.') => new ExtensionConfigError('INVALID_ARGUMENT', message);
61
+
62
+ // ---------------------------------------------------------------------------
63
+ // Path helpers Pi uses but does not export (utils/paths.js, source-info.js).
64
+
65
+ const isSyntheticPath = (path) => path.startsWith(BUILTIN_PATH_PREFIX) || path.startsWith('<');
66
+
67
+ const canonicalizePath = (path) => {
68
+ try {
69
+ return realpathSync(path);
70
+ } catch {
71
+ return path;
72
+ }
73
+ };
74
+
75
+ const getPathComparisonKey = (path) => (process.platform === 'win32' ? win32.resolve(path).toLowerCase() : resolve(path));
76
+
77
+ const getResourcePathKey = (path) => (isSyntheticPath(path) ? path : getPathComparisonKey(canonicalizePath(path)));
78
+
79
+ const isLocalPath = (value) => {
80
+ const trimmed = value.trim();
81
+ return !['npm:', 'git:', 'github:', 'http:', 'https:', 'ssh:', 'builtin:'].some((prefix) => trimmed.startsWith(prefix));
82
+ };
83
+
84
+ const normalizePath = (input) => {
85
+ const normalized = input.trim();
86
+ if (normalized === '~') return homedir();
87
+ if (normalized.startsWith('~/') || (process.platform === 'win32' && normalized.startsWith('~\\'))) {
88
+ return join(homedir(), normalized.slice(2));
89
+ }
90
+ if (/^file:\/\//.test(normalized)) return fileURLToPath(normalized);
91
+ return normalized;
92
+ };
93
+
94
+ const resolvePath = (input, baseDir) => {
95
+ const normalized = normalizePath(input);
96
+ return isAbsolute(normalized) ? resolve(normalized) : resolve(normalizePath(baseDir), normalized);
97
+ };
98
+
99
+ // ---------------------------------------------------------------------------
100
+ // Toggle logic, reimplemented from Pi's ResourceList (config-selector.js).
101
+ //
102
+ // `ctx` is `{ settingsManager, cwd, agentDir, inheritedEnabledByKey }`.
103
+ // `item` is `{ path, enabled, metadata, resourceType }`, the shape Pi's
104
+ // resolve() returns with the resource type added.
105
+
106
+ const stripPrefix = (entry) => (entry.startsWith('!') || entry.startsWith('+') || entry.startsWith('-') ? entry.slice(1) : entry);
107
+
108
+ const getPatternEntryTarget = stripPrefix;
109
+
110
+ const getItemScope = (item) => (item.metadata.scope === 'project' ? 'project' : 'user');
111
+
112
+ export const getResourceItemKey = (item) => `${item.resourceType}:${getResourcePathKey(item.path)}`;
113
+
114
+ const getTopLevelBaseDir = (ctx, scope) => (scope === 'project' ? join(ctx.cwd, CONFIG_DIR_NAME) : ctx.agentDir);
115
+
116
+ const getResourcePattern = (ctx, item) => {
117
+ if (item.metadata.source === 'builtin') return item.path;
118
+ const baseDir = item.metadata.baseDir ?? getTopLevelBaseDir(ctx, item.metadata.scope);
119
+ return relative(baseDir, item.path);
120
+ };
121
+
122
+ const getPackageResourcePattern = (item) => {
123
+ const baseDir = item.metadata.baseDir ?? dirname(item.path);
124
+ return relative(baseDir, item.path);
125
+ };
126
+
127
+ const getResourcePatternForScope = (ctx, item, scope) => {
128
+ const sourceScope = getItemScope(item);
129
+ if (scope !== sourceScope || item.metadata.source === 'builtin') return item.path;
130
+ const baseDir = item.metadata.baseDir ?? getTopLevelBaseDir(ctx, sourceScope);
131
+ return relative(baseDir, item.path);
132
+ };
133
+
134
+ const getTopLevelOverridePatterns = (ctx, item, scope) => {
135
+ const baseDir = getTopLevelBaseDir(ctx, scope);
136
+ const patterns = new Set([
137
+ getResourcePatternForScope(ctx, item, scope),
138
+ item.path,
139
+ relative(baseDir, item.path),
140
+ ]);
141
+ if (item.metadata.baseDir) patterns.add(relative(item.metadata.baseDir, item.path));
142
+ return patterns;
143
+ };
144
+
145
+ const packageSourceStringMatches = (ctx, leftSource, leftScope, rightSource, rightScope) => {
146
+ if (leftSource === rightSource) return true;
147
+ if (!isLocalPath(leftSource) || !isLocalPath(rightSource)) return false;
148
+ const left = resolvePath(leftSource, getTopLevelBaseDir(ctx, leftScope));
149
+ const right = resolvePath(rightSource, getTopLevelBaseDir(ctx, rightScope));
150
+ return left === right;
151
+ };
152
+
153
+ const findMatchingPackageSource = (ctx, item, targetScope) => {
154
+ const settings = targetScope === 'project'
155
+ ? ctx.settingsManager.getProjectSettings()
156
+ : ctx.settingsManager.getGlobalSettings();
157
+ return (settings.packages ?? []).find((pkg) => packageSourceStringMatches(
158
+ ctx,
159
+ item.metadata.source,
160
+ getItemScope(item),
161
+ typeof pkg === 'string' ? pkg : pkg.source,
162
+ targetScope,
163
+ ));
164
+ };
165
+
166
+ export const createPackageOverrideSource = (ctx, item) => {
167
+ const source = item.metadata.source;
168
+ if (!isLocalPath(source)) return { source, autoload: false };
169
+ const sourcePath = resolvePath(source, getTopLevelBaseDir(ctx, getItemScope(item)));
170
+ return { source: relative(getTopLevelBaseDir(ctx, 'project'), sourcePath) || '.', autoload: false };
171
+ };
172
+
173
+ const isInheritedGlobalItem = (ctx, item) => (
174
+ getItemScope(item) === 'user' || ctx.inheritedEnabledByKey.has(getResourceItemKey(item))
175
+ );
176
+
177
+ export const getInheritedEnabled = (ctx, item) => (
178
+ ctx.inheritedEnabledByKey.get(getResourceItemKey(item))
179
+ ?? (getItemScope(item) === 'user' ? item.enabled : true)
180
+ );
181
+
182
+ export const getOverrideStateFromEntries = (entries, patterns, emptyArrayIsUnload) => {
183
+ if (entries.length === 0 && emptyArrayIsUnload) return 'unload';
184
+ let state = 'inherit';
185
+ for (const entry of entries) {
186
+ if (!patterns.has(getPatternEntryTarget(entry))) continue;
187
+ state = entry.startsWith('!') || entry.startsWith('-') ? 'unload' : 'load';
188
+ }
189
+ return state;
190
+ };
191
+
192
+ // The project's own override for an item (Pi reads this only in project mode).
193
+ export const getProjectOverrideState = (ctx, item) => {
194
+ if (item.metadata.origin === 'top-level') {
195
+ return getOverrideStateFromEntries(
196
+ ctx.settingsManager.getProjectSettings()[item.resourceType] ?? [],
197
+ getTopLevelOverridePatterns(ctx, item, 'project'),
198
+ false,
199
+ );
200
+ }
201
+ const pkg = findMatchingPackageSource(ctx, item, 'project');
202
+ if (typeof pkg !== 'object' || pkg === null) return 'inherit';
203
+ const entries = pkg[item.resourceType];
204
+ if (entries === undefined) return 'inherit';
205
+ return getOverrideStateFromEntries(entries, new Set([getPackageResourcePattern(item)]), pkg.autoload !== false);
206
+ };
207
+
208
+ const setTopLevelPaths = (settingsManager, scope, key, paths) => {
209
+ if (scope === 'project') {
210
+ if (key === 'extensions') settingsManager.setProjectExtensionPaths(paths);
211
+ else if (key === 'skills') settingsManager.setProjectSkillPaths(paths);
212
+ else if (key === 'prompts') settingsManager.setProjectPromptTemplatePaths(paths);
213
+ else settingsManager.setProjectThemePaths(paths);
214
+ return;
215
+ }
216
+ if (key === 'extensions') settingsManager.setExtensionPaths(paths);
217
+ else if (key === 'skills') settingsManager.setSkillPaths(paths);
218
+ else if (key === 'prompts') settingsManager.setPromptTemplatePaths(paths);
219
+ else settingsManager.setThemePaths(paths);
220
+ };
221
+
222
+ // Global mode, top-level resource: replace any `!`/`+`/`-` entry for the
223
+ // pattern with `+pattern` or `-pattern` in the item's own scope.
224
+ export const toggleTopLevelResource = (ctx, item, enabled) => {
225
+ const scope = item.metadata.scope;
226
+ const settings = scope === 'project' ? ctx.settingsManager.getProjectSettings() : ctx.settingsManager.getGlobalSettings();
227
+ const current = settings[item.resourceType] ?? [];
228
+ const pattern = getResourcePattern(ctx, item);
229
+ const updated = current.filter((entry) => stripPrefix(entry) !== pattern);
230
+ updated.push(`${enabled ? '+' : '-'}${pattern}`);
231
+ setTopLevelPaths(ctx.settingsManager, scope === 'project' ? 'project' : 'user', item.resourceType, updated);
232
+ };
233
+
234
+ // Global mode, package resource: object form with a per-type filter, back to
235
+ // the plain string when no filter is left.
236
+ export const togglePackageResource = (ctx, item, enabled) => {
237
+ const scope = item.metadata.scope;
238
+ const settings = scope === 'project' ? ctx.settingsManager.getProjectSettings() : ctx.settingsManager.getGlobalSettings();
239
+ const packages = [...(settings.packages ?? [])];
240
+ const pkgIndex = packages.findIndex((pkg) => (typeof pkg === 'string' ? pkg : pkg.source) === item.metadata.source);
241
+ if (pkgIndex === -1) return false;
242
+ let pkg = packages[pkgIndex];
243
+ if (typeof pkg === 'string') {
244
+ pkg = { source: pkg };
245
+ packages[pkgIndex] = pkg;
246
+ }
247
+ const current = pkg[item.resourceType] ?? [];
248
+ const pattern = getPackageResourcePattern(item);
249
+ const updated = current.filter((entry) => stripPrefix(entry) !== pattern);
250
+ updated.push(`${enabled ? '+' : '-'}${pattern}`);
251
+ pkg[item.resourceType] = updated.length > 0 ? updated : undefined;
252
+ if (!RESOURCE_TYPES.some((key) => pkg[key] !== undefined)) packages[pkgIndex] = pkg.source;
253
+ if (scope === 'project') ctx.settingsManager.setProjectPackages(packages);
254
+ else ctx.settingsManager.setPackages(packages);
255
+ return true;
256
+ };
257
+
258
+ const setProjectTopLevelOverride = (ctx, item, state) => {
259
+ const current = ctx.settingsManager.getProjectSettings()[item.resourceType] ?? [];
260
+ const inherited = isInheritedGlobalItem(ctx, item);
261
+ const pattern = inherited ? item.path : getResourcePatternForScope(ctx, item, 'project');
262
+ const patterns = getTopLevelOverridePatterns(ctx, item, 'project');
263
+ const updated = current.filter((entry) => {
264
+ const target = getPatternEntryTarget(entry);
265
+ if ((entry.startsWith('!') || entry.startsWith('+') || entry.startsWith('-')) && patterns.has(target)) return false;
266
+ return !(state === 'inherit' && inherited && target === pattern);
267
+ });
268
+ if (state !== 'inherit') {
269
+ // Project entries name inherited files to override them. Built-in paths need no entry.
270
+ if (inherited && item.metadata.source !== 'builtin' && !updated.includes(pattern)) updated.push(pattern);
271
+ updated.push(`${state === 'load' ? '+' : '-'}${pattern}`);
272
+ }
273
+ setTopLevelPaths(ctx.settingsManager, 'project', item.resourceType, updated);
274
+ return true;
275
+ };
276
+
277
+ const setProjectPackageOverride = (ctx, item, state) => {
278
+ const packages = [...(ctx.settingsManager.getProjectSettings().packages ?? [])];
279
+ let pkgIndex = packages.findIndex((pkg) => packageSourceStringMatches(
280
+ ctx,
281
+ item.metadata.source,
282
+ getItemScope(item),
283
+ typeof pkg === 'string' ? pkg : pkg.source,
284
+ 'project',
285
+ ));
286
+ if (pkgIndex === -1) {
287
+ if (state === 'inherit') return false;
288
+ packages.push(createPackageOverrideSource(ctx, item));
289
+ pkgIndex = packages.length - 1;
290
+ }
291
+ let pkg = packages[pkgIndex];
292
+ if (pkg === undefined) return false;
293
+ if (typeof pkg === 'string') {
294
+ pkg = { source: pkg };
295
+ packages[pkgIndex] = pkg;
296
+ }
297
+ const pattern = getPackageResourcePattern(item);
298
+ const updated = (pkg[item.resourceType] ?? []).filter((entry) => getPatternEntryTarget(entry) !== pattern);
299
+ if (state !== 'inherit') updated.push(`${state === 'load' ? '+' : '-'}${pattern}`);
300
+ pkg[item.resourceType] = updated.length > 0 ? updated : undefined;
301
+ if (!RESOURCE_TYPES.some((key) => pkg[key] !== undefined)) {
302
+ if (pkg.autoload === false) packages.splice(pkgIndex, 1);
303
+ else packages[pkgIndex] = pkg.source;
304
+ }
305
+ ctx.settingsManager.setProjectPackages(packages);
306
+ return true;
307
+ };
308
+
309
+ export const setProjectResourceOverride = (ctx, item, state) => (
310
+ item.metadata.origin === 'top-level'
311
+ ? setProjectTopLevelOverride(ctx, item, state)
312
+ : setProjectPackageOverride(ctx, item, state)
313
+ );
314
+
315
+ // Global mode write. Like `pi config`, only user-scope items toggle here.
316
+ export const setGlobalResourceEnabled = (ctx, item, enabled) => {
317
+ if (getItemScope(item) !== 'user') return false;
318
+ if (item.metadata.origin === 'top-level') {
319
+ toggleTopLevelResource(ctx, item, enabled);
320
+ return true;
321
+ }
322
+ return togglePackageResource(ctx, item, enabled);
323
+ };
324
+
325
+ // ---------------------------------------------------------------------------
326
+ // Path-free display forms.
327
+
328
+ const hashId = (...parts) => createHash('sha256').update(parts.join('\0')).digest('base64url');
329
+
330
+ const sanitizeName = (value) => {
331
+ const cleaned = String(value).replace(/\\/g, '/').slice(0, MAX_NAME_LENGTH);
332
+ return cleaned.length > 0 ? cleaned : 'unknown';
333
+ };
334
+
335
+ // `pi config`'s display name: the built-in name, `parent/file` for an
336
+ // extension whose parent folder is not `extensions`, else the file name.
337
+ const resourceDisplayName = (item) => {
338
+ if (item.metadata.source === 'builtin') return sanitizeName(item.path.slice(BUILTIN_PATH_PREFIX.length));
339
+ const fileName = basename(item.path);
340
+ const parentFolder = basename(dirname(item.path));
341
+ if (item.resourceType === 'extensions' && parentFolder !== 'extensions' && parentFolder.length > 0) {
342
+ return sanitizeName(`${parentFolder}/${fileName}`);
343
+ }
344
+ if (item.resourceType === 'skills' && fileName === 'SKILL.md' && parentFolder.length > 0) return sanitizeName(parentFolder);
345
+ return sanitizeName(fileName);
346
+ };
347
+
348
+ // Removes URL userinfo (`user:token@`) from any `scheme://` authority.
349
+ export const stripUrlCredentials = (value) => value.replace(
350
+ /([A-Za-z][A-Za-z0-9+.-]*:\/\/)([^/?#\s]*@)/g,
351
+ (_match, scheme) => scheme,
352
+ );
353
+
354
+ const packageKind = (source) => {
355
+ const trimmed = source.trim();
356
+ if (trimmed.startsWith('npm:')) return 'npm';
357
+ if (isLocalPath(trimmed)) return 'local';
358
+ return 'git';
359
+ };
360
+
361
+ // npm and git: as written in settings, credentials stripped. Local: the
362
+ // folder name only.
363
+ export const displayPackageSource = (source, baseDir) => {
364
+ const kind = packageKind(source);
365
+ if (kind !== 'local') return stripUrlCredentials(source.trim()).slice(0, MAX_NAME_LENGTH);
366
+ const resolved = baseDir ? resolvePath(source, baseDir) : source.trim().replace(/[\\/]+$/, '');
367
+ return sanitizeName(basename(resolved) || 'local');
368
+ };
369
+
370
+ const NPM_SPEC_PATTERN = /^(@?[^@]+(?:\/[^@]+)?)(?:@(.+))?$/;
371
+ const parseNpmName = (spec) => spec.match(NPM_SPEC_PATTERN)?.[1] ?? spec;
372
+
373
+ // Pi never updates an npm source written with an exact version.
374
+ const isPinnedSource = (source) => {
375
+ if (packageKind(source) !== 'npm') return false;
376
+ const version = source.trim().slice('npm:'.length).trim().match(NPM_SPEC_PATTERN)?.[2];
377
+ return typeof version === 'string' && EXACT_VERSION_PATTERN.test(version.trim());
378
+ };
379
+
380
+ // name, version, and the PiChamber plugin marker from an installed package's
381
+ // own package.json. Any read or parse error leaves them out; the path is
382
+ // never returned.
383
+ const readInstalledPackageInfo = (installedPath) => {
384
+ if (typeof installedPath !== 'string' || installedPath.length === 0) return {};
385
+ let fd;
386
+ try {
387
+ fd = openSync(join(installedPath, 'package.json'), 'r');
388
+ const { size } = fstatSync(fd);
389
+ if (size > MAX_PACKAGE_JSON_BYTES) return {};
390
+ const buffer = Buffer.alloc(size);
391
+ const read = readSync(fd, buffer, 0, size, 0);
392
+ const manifest = JSON.parse(buffer.subarray(0, read).toString('utf8'));
393
+ if (!manifest || typeof manifest !== 'object' || Array.isArray(manifest)) return {};
394
+ const { name, version, pichamber } = manifest;
395
+ return {
396
+ ...(isValidNpmPackageName(name) ? { name } : {}),
397
+ ...(typeof version === 'string' && version.length <= MAX_VERSION_LENGTH && VERSION_PATTERN.test(version) ? { version } : {}),
398
+ ...(pichamber && typeof pichamber === 'object' && !Array.isArray(pichamber) && Number.isFinite(pichamber.apiVersion)
399
+ ? { pichamber: true }
400
+ : {}),
401
+ };
402
+ } catch {
403
+ return {};
404
+ } finally {
405
+ if (fd !== undefined) {
406
+ try { closeSync(fd); } catch { /* already closed */ }
407
+ }
408
+ }
409
+ };
410
+
411
+ // Pi's package identity (npm by name, local by resolved path); git sources
412
+ // keep their written form minus credentials.
413
+ const packageIdentity = (source, baseDir) => {
414
+ const kind = packageKind(source);
415
+ if (kind === 'npm') return `npm:${parseNpmName(source.trim().slice('npm:'.length).trim())}`;
416
+ if (kind === 'git') return `git:${stripUrlCredentials(source.trim())}`;
417
+ return `local:${getPathComparisonKey(resolvePath(source, baseDir))}`;
418
+ };
419
+
420
+ const packageId = (scope, identity) => hashId('package', scope, identity);
421
+
422
+ const resourceId = (resourceType, scope, item) => hashId(
423
+ resourceType,
424
+ scope,
425
+ item.metadata.source === 'builtin' ? item.path : getResourcePathKey(item.path),
426
+ );
427
+
428
+ // Error text from npm, git, or the SDK: server paths and credentials removed,
429
+ // length capped.
430
+ export const sanitizeErrorMessage = (message, knownPaths = []) => {
431
+ let text = typeof message === 'string' ? message : String(message ?? '');
432
+ for (const path of [...knownPaths].filter((value) => typeof value === 'string' && value.length > 1).sort((a, b) => b.length - a.length)) {
433
+ text = text.split(path).join('<path>');
434
+ }
435
+ text = stripUrlCredentials(text)
436
+ .replace(/(^|[\s'"`(=:])(?:[A-Za-z]:)?~?[\\/](?!\/)[^\s'"`)]*/g, '$1<path>')
437
+ .replace(/\s+/g, ' ')
438
+ .trim();
439
+ if (text.length > MAX_ERROR_MESSAGE_LENGTH) text = `${text.slice(0, MAX_ERROR_MESSAGE_LENGTH - 3)}...`;
440
+ return text.length > 0 ? text : 'The operation failed.';
441
+ };
442
+
443
+ const groupOf = (metadata) => {
444
+ if (metadata.origin === 'package') return 'package';
445
+ if (metadata.source === 'builtin') return 'builtin';
446
+ if (metadata.source === 'auto') return 'auto';
447
+ return 'settings';
448
+ };
449
+
450
+ // ---------------------------------------------------------------------------
451
+ // Service.
452
+
453
+ const defaultCreateSettingsManager = ({ cwd, agentDir, projectTrusted }) => SettingsManager.create(cwd, agentDir, { projectTrusted });
454
+ const defaultCreatePackageManager = (options) => new DefaultPackageManager(options);
455
+
456
+ export function createExtensionConfig({
457
+ agentDir,
458
+ createSettingsManager = defaultCreateSettingsManager,
459
+ createPackageManager = defaultCreatePackageManager,
460
+ builtinExtensions = LOADED_BUILTIN_EXTENSIONS.map((entry) => entry.name),
461
+ } = {}) {
462
+ if (typeof agentDir !== 'string' || agentDir.length === 0) throw new TypeError('agentDir is required.');
463
+
464
+ const baseDirFor = (scope, cwd) => (scope === 'project' ? join(cwd, CONFIG_DIR_NAME) : agentDir);
465
+
466
+ // Never installs: a missing package is skipped and shows `installed: false`.
467
+ const resolveView = async (cwd, projectTrusted) => {
468
+ const settingsManager = createSettingsManager({ cwd, agentDir, projectTrusted });
469
+ const packageManager = createPackageManager({ cwd, agentDir, settingsManager, builtinExtensions: [...builtinExtensions] });
470
+ const resolved = await packageManager.resolve(async () => 'skip');
471
+ return { settingsManager, packageManager, resolved };
472
+ };
473
+
474
+ const itemsOf = (resolved) => LISTED_RESOURCE_TYPES.flatMap((resourceType) => (
475
+ (Array.isArray(resolved?.[resourceType]) ? resolved[resourceType] : [])
476
+ .filter((entry) => entry && typeof entry.path === 'string' && entry.metadata)
477
+ .map((entry) => ({ path: entry.path, enabled: entry.enabled !== false, metadata: entry.metadata, resourceType }))
478
+ ));
479
+
480
+ /**
481
+ * Builds both views like `pi config` does. `target` is
482
+ * `{ cwd, directory?, trusted }`; `cwd` is where the global view resolves.
483
+ */
484
+ const snapshot = async ({ cwd, directory, trusted }) => {
485
+ const globalCwd = directory ?? cwd;
486
+ const global = await resolveView(globalCwd, false);
487
+ const project = directory && trusted ? await resolveView(directory, true) : null;
488
+ const globalItems = itemsOf(global.resolved);
489
+ const inheritedEnabledByKey = new Map(globalItems.map((item) => [getResourceItemKey(item), item.enabled]));
490
+ const ctxFor = (view, viewCwd) => ({ settingsManager: view.settingsManager, cwd: viewCwd, agentDir, inheritedEnabledByKey });
491
+ const globalCtx = ctxFor(global, globalCwd);
492
+ const projectCtx = project ? ctxFor(project, directory) : null;
493
+
494
+ // The same file or built-in keeps one id in both views: an item the
495
+ // global view lists is declared there (user scope).
496
+ const globalById = new Map();
497
+ for (const item of globalItems) globalById.set(resourceId(item.resourceType, 'user', item), item);
498
+ const projectById = new Map();
499
+ if (project) {
500
+ for (const item of itemsOf(project.resolved)) {
501
+ const declared = inheritedEnabledByKey.has(getResourceItemKey(item)) ? 'user' : getItemScope(item);
502
+ projectById.set(resourceId(item.resourceType, declared, item), item);
503
+ }
504
+ }
505
+ return { global, project, globalCtx, projectCtx, globalById, projectById, globalCwd };
506
+ };
507
+
508
+ // Turns the daemon's replacement facts (which carry file paths) into the
509
+ // path-free `replaced` list. Item ids come from this response's own
510
+ // `extensions` array; a winner that is not listed gets only its display name.
511
+ const projectReplaced = (replacements, snap, extensions) => {
512
+ const itemEntries = [...snap.globalById, ...(snap.projectById ?? [])];
513
+ const nameById = new Map(extensions.map((entry) => [entry.id, entry.name]));
514
+ const idByPathKey = new Map();
515
+ const idByBuiltinPath = new Map();
516
+ for (const [id, item] of itemEntries) {
517
+ if (!nameById.has(id)) continue;
518
+ if (item.metadata.source === 'builtin') idByBuiltinPath.set(item.path, id);
519
+ else if (!idByPathKey.has(getResourcePathKey(item.path))) idByPathKey.set(getResourcePathKey(item.path), id);
520
+ }
521
+ const winner = (by) => {
522
+ if (!by || typeof by.name !== 'string') return undefined;
523
+ const id = typeof by.path === 'string' ? idByPathKey.get(getResourcePathKey(by.path)) : undefined;
524
+ return id ? { id, name: nameById.get(id) } : { name: sanitizeName(by.name) };
525
+ };
526
+ const detail = (entry) => ({
527
+ ...(entry.registers ? { registers: { kind: entry.registers.kind, name: sanitizeName(entry.registers.name) } } : {}),
528
+ ...(winner(entry.by) ? { by: winner(entry.by) } : {}),
529
+ });
530
+ const replaced = [];
531
+ for (const plugin of replacements.plugins ?? []) {
532
+ replaced.push({ kind: 'plugin', id: plugin.id, ...detail(plugin) });
533
+ }
534
+ for (const builtin of replacements.builtins ?? []) {
535
+ const id = idByBuiltinPath.get(builtin.path);
536
+ if (id) replaced.push({ kind: 'builtin', id, ...detail(builtin) });
537
+ }
538
+ return replaced;
539
+ };
540
+
541
+ const buildResponse = (snap, { directory, trusted }, replacements) => {
542
+ const { global, project, projectCtx, globalById, projectById, globalCwd } = snap;
543
+ const listing = project ?? global;
544
+ const configured = listing.packageManager.listConfiguredPackages();
545
+ const packages = [];
546
+ const packageIdBySourceScope = new Map();
547
+ const entries = (Array.isArray(configured) ? configured : [])
548
+ .filter((pkg) => pkg && typeof pkg.source === 'string' && (pkg.scope === 'user' || pkg.scope === 'project'))
549
+ .map((pkg) => {
550
+ const baseDir = baseDirFor(pkg.scope, project ? directory : globalCwd);
551
+ return { pkg, baseDir, identity: packageIdentity(pkg.source, baseDir) };
552
+ });
553
+ // A project entry with `autoload: false` for a package the user already
554
+ // has is where Pi keeps that project's overrides (see
555
+ // `createPackageOverrideSource`). It is not a second package: its
556
+ // extensions stay listed under the user's package.
557
+ const userIdentities = new Set(entries.filter((entry) => entry.pkg.scope === 'user').map((entry) => entry.identity));
558
+ const projectPackageSettings = listing.settingsManager.getProjectSettings?.().packages ?? [];
559
+ const isOverrideRecord = ({ pkg, identity }) => pkg.scope === 'project' && userIdentities.has(identity)
560
+ && projectPackageSettings.some((entry) => entry && typeof entry === 'object' && entry.source === pkg.source && entry.autoload === false);
561
+ for (const entry of entries) {
562
+ const { pkg, baseDir, identity } = entry;
563
+ const id = packageId(pkg.scope, identity);
564
+ if (isOverrideRecord(entry)) continue;
565
+ packageIdBySourceScope.set(`${pkg.scope}\0${pkg.source}`, id);
566
+ packages.push({
567
+ id,
568
+ source: displayPackageSource(pkg.source, baseDir),
569
+ scope: pkg.scope,
570
+ kind: packageKind(pkg.source),
571
+ installed: typeof pkg.installedPath === 'string' && pkg.installedPath.length > 0,
572
+ filtered: pkg.filtered === true,
573
+ ...(isPinnedSource(pkg.source) ? { pinned: true } : {}),
574
+ ...readInstalledPackageInfo(pkg.installedPath),
575
+ });
576
+ }
577
+ packages.sort((a, b) => (a.scope === b.scope ? a.source.localeCompare(b.source) : a.scope === 'user' ? -1 : 1));
578
+ const packageRank = new Map(packages.map((pkg, index) => [pkg.id, index]));
579
+
580
+ const extensions = [];
581
+ const ids = new Set([...globalById.keys(), ...projectById.keys()]);
582
+ for (const id of ids) {
583
+ const globalItem = globalById.get(id);
584
+ const projectItem = projectById.get(id);
585
+ const item = globalItem ?? projectItem;
586
+ const group = groupOf(item.metadata);
587
+ const scope = globalItem ? 'user' : getItemScope(item);
588
+ const pkgId = group === 'package'
589
+ ? packageIdBySourceScope.get(`${item.metadata.scope === 'project' ? 'project' : 'user'}\0${item.metadata.source}`)
590
+ : undefined;
591
+ extensions.push({
592
+ id,
593
+ name: resourceDisplayName(item),
594
+ group,
595
+ ...(pkgId ? { packageId: pkgId } : {}),
596
+ scope,
597
+ ...(globalItem ? { global: globalItem.enabled } : {}),
598
+ ...(projectItem && projectCtx ? {
599
+ project: {
600
+ state: getProjectOverrideState(projectCtx, projectItem),
601
+ inherited: getInheritedEnabled(projectCtx, projectItem),
602
+ enabled: projectItem.enabled,
603
+ },
604
+ } : {}),
605
+ });
606
+ }
607
+ extensions.sort((a, b) => {
608
+ if (a.group !== b.group) return GROUP_ORDER[a.group] - GROUP_ORDER[b.group];
609
+ if (a.group === 'package' && a.packageId !== b.packageId) {
610
+ return (packageRank.get(a.packageId) ?? Infinity) - (packageRank.get(b.packageId) ?? Infinity);
611
+ }
612
+ if (a.scope !== b.scope) return a.scope === 'user' ? -1 : 1;
613
+ return a.name.localeCompare(b.name);
614
+ });
615
+
616
+ const failures = new Map();
617
+ for (const view of [global, project]) {
618
+ for (const failure of view?.resolved?.installFailures ?? []) {
619
+ if (!failure || typeof failure.source !== 'string') continue;
620
+ const scope = failure.scope === 'project' ? 'project' : 'user';
621
+ const baseDir = baseDirFor(scope, project ? directory : globalCwd);
622
+ const source = displayPackageSource(failure.source, baseDir);
623
+ failures.set(`${scope}\0${source}`, {
624
+ source,
625
+ message: sanitizeErrorMessage(failure.message, [agentDir, directory, globalCwd, homedir()]),
626
+ });
627
+ }
628
+ }
629
+
630
+ return {
631
+ ...(directory ? { directory } : {}),
632
+ project: { available: Boolean(directory), trusted: Boolean(directory && trusted) },
633
+ packages,
634
+ extensions,
635
+ installFailures: [...failures.values()],
636
+ // Present only when a live runtime answered; absent means unknown.
637
+ ...(replacements ? { replaced: projectReplaced(replacements, snap, extensions) } : {}),
638
+ };
639
+ };
640
+
641
+ /**
642
+ * `replacements` is optional: `{ plugins: [{ id, registers?, by?: { path, name } }],
643
+ * builtins: [{ path, registers?, by? }] }` from `extension-replacements.js`.
644
+ * Without it the answer has no `replaced` field.
645
+ */
646
+ const list = async (target, replacements) => buildResponse(await snapshot(target), target, replacements);
647
+
648
+ const assertWritable = (settingsManager) => {
649
+ if (settingsManager.drainErrors().length > 0) {
650
+ throw new ExtensionConfigError('PI_SETTINGS_INVALID', 'Pi settings could not be read.');
651
+ }
652
+ };
653
+
654
+ const commit = async (settingsManager) => {
655
+ await settingsManager.flush();
656
+ if (settingsManager.drainErrors().length > 0) {
657
+ throw new ExtensionConfigError('PI_SETTINGS_INVALID', 'Pi settings could not be written.');
658
+ }
659
+ };
660
+
661
+ /**
662
+ * Validates a set request. Returns the parsed request; throws
663
+ * `INVALID_ARGUMENT` for a malformed one.
664
+ */
665
+ const parseSetRequest = (payload) => {
666
+ if (!payload || typeof payload !== 'object' || Array.isArray(payload)) throw invalid();
667
+ if (typeof payload.id !== 'string' || !ID_PATTERN.test(payload.id)) throw invalid();
668
+ if (payload.scope === 'global') {
669
+ if (typeof payload.enabled !== 'boolean' || payload.state !== undefined) throw invalid();
670
+ return { id: payload.id, scope: 'global', enabled: payload.enabled };
671
+ }
672
+ if (payload.scope === 'project') {
673
+ // Either the override itself, or just on/off: `set` then picks the
674
+ // override against the settings it reads under the lock.
675
+ if (payload.state === undefined && typeof payload.enabled === 'boolean') {
676
+ return { id: payload.id, scope: 'project', enabled: payload.enabled };
677
+ }
678
+ if (!OVERRIDE_STATES.has(payload.state) || payload.enabled !== undefined) throw invalid();
679
+ return { id: payload.id, scope: 'project', state: payload.state };
680
+ }
681
+ throw invalid();
682
+ };
683
+
684
+ /**
685
+ * Writes one toggle. The caller holds the shared Pi config lock and the
686
+ * resource mutation queue, resolved `target.directory`, and read
687
+ * `target.trusted` inside the lock.
688
+ */
689
+ const set = async (target, payload) => {
690
+ const request = parseSetRequest(payload);
691
+ if (request.scope === 'project') {
692
+ if (!target.directory) throw invalid('Project scope requires a directory.');
693
+ if (!target.trusted) throw new ExtensionConfigError('PROJECT_UNTRUSTED', 'The project is not trusted.');
694
+ }
695
+ const snap = await snapshot(target);
696
+ if (request.scope === 'global') {
697
+ const item = snap.globalById.get(request.id);
698
+ if (!item) {
699
+ if (snap.projectById.has(request.id)) throw invalid('Only user resources can be changed in global scope.');
700
+ throw new ExtensionConfigError('RESOURCE_NOT_FOUND', 'The requested extension was not found.');
701
+ }
702
+ // Writes go through a fresh manager so nothing the listing cached is
703
+ // written back.
704
+ const settingsManager = createSettingsManager({ cwd: snap.globalCwd, agentDir, projectTrusted: Boolean(target.directory && target.trusted) });
705
+ assertWritable(settingsManager);
706
+ const ctx = { ...snap.globalCtx, settingsManager };
707
+ if (!setGlobalResourceEnabled(ctx, item, request.enabled)) {
708
+ throw new ExtensionConfigError('PACKAGE_NOT_CONFIGURED', 'The package is no longer configured.');
709
+ }
710
+ await commit(settingsManager);
711
+ return;
712
+ }
713
+ const item = snap.projectById.get(request.id);
714
+ if (!item) throw new ExtensionConfigError('RESOURCE_NOT_FOUND', 'The requested extension was not found.');
715
+ const settingsManager = createSettingsManager({ cwd: target.directory, agentDir, projectTrusted: true });
716
+ assertWritable(settingsManager);
717
+ const ctx = { ...snap.projectCtx, settingsManager };
718
+ // On/off keeps no project entry when the project would get that value
719
+ // anyway. The client cannot decide this: its copy of the global value may
720
+ // be older than a change made in a terminal or another tab.
721
+ const state = request.state
722
+ ?? (request.enabled === getInheritedEnabled(snap.projectCtx, item) ? 'inherit' : request.enabled ? 'load' : 'unload');
723
+ // Pi reports no change for "inherit" on a package with no project entry.
724
+ if (setProjectResourceOverride(ctx, item, state)) await commit(settingsManager);
725
+ };
726
+
727
+ const managersFor = (target) => {
728
+ const projectTrusted = Boolean(target.directory && target.trusted);
729
+ const globalCwd = target.directory ?? target.cwd;
730
+ const settingsManager = createSettingsManager({ cwd: globalCwd, agentDir, projectTrusted });
731
+ const packageManager = createPackageManager({ cwd: globalCwd, agentDir, settingsManager, builtinExtensions: [...builtinExtensions] });
732
+ return { projectTrusted, globalCwd, settingsManager, packageManager };
733
+ };
734
+
735
+ const configuredEntries = (packageManager) => {
736
+ const configured = packageManager.listConfiguredPackages();
737
+ return (Array.isArray(configured) ? configured : [])
738
+ .filter((pkg) => pkg && typeof pkg.source === 'string' && (pkg.scope === 'user' || pkg.scope === 'project'));
739
+ };
740
+
741
+ // The configured package a list id names. A project package needs a
742
+ // trusted directory.
743
+ const findConfiguredPackage = (target, id) => {
744
+ const managers = managersFor(target);
745
+ const match = configuredEntries(managers.packageManager).find((pkg) => (
746
+ packageId(pkg.scope, packageIdentity(pkg.source, baseDirFor(pkg.scope, managers.globalCwd))) === id
747
+ ));
748
+ if (!match) throw new ExtensionConfigError('RESOURCE_NOT_FOUND', 'The requested package was not found.');
749
+ if (match.scope === 'project' && !managers.projectTrusted) {
750
+ throw new ExtensionConfigError('PROJECT_UNTRUSTED', 'The project is not trusted.');
751
+ }
752
+ return { ...managers, match };
753
+ };
754
+
755
+ const errorText = (error, globalCwd) => sanitizeErrorMessage(
756
+ error instanceof Error ? error.message : error,
757
+ [agentDir, globalCwd, homedir()],
758
+ );
759
+
760
+ const runDirectly = (operation) => operation();
761
+
762
+ const parseInstallRequest = (payload) => {
763
+ if (!payload || typeof payload !== 'object' || Array.isArray(payload)) throw invalid();
764
+ // A bare npm name only: no version, and no git, URL, or local source.
765
+ if (!isValidNpmPackageName(payload.name)) throw invalid('Only an npm package name can be installed.');
766
+ if (payload.scope !== 'user' && payload.scope !== 'project') throw invalid();
767
+ return { name: payload.name, scope: payload.scope };
768
+ };
769
+
770
+ const assertInstallTarget = (target, scope) => {
771
+ if (scope !== 'project') return;
772
+ if (!target.directory) throw invalid('Project scope requires a directory.');
773
+ if (!target.trusted) throw new ExtensionConfigError('PROJECT_UNTRUSTED', 'The project is not trusted.');
774
+ };
775
+
776
+ const assertNotConfigured = (packageManager, scope, identity) => {
777
+ if (configuredEntries(packageManager).some((pkg) => pkg.scope === scope && packageKind(pkg.source) === 'npm'
778
+ && packageIdentity(pkg.source) === identity)) {
779
+ throw new ExtensionConfigError('PACKAGE_ALREADY_INSTALLED', 'The package is already installed in that scope.');
780
+ }
781
+ };
782
+
783
+ /**
784
+ * `pi install npm:<name>` in two steps so the npm download holds no lock:
785
+ * `serializeInstall` runs Pi's `install` (one npm run at a time), then
786
+ * `withWriteLock(write)` runs `write(freshTarget)` under the resource
787
+ * mutation queue and the shared Pi config lock to add the source to
788
+ * settings. Both hooks default to running directly. `resolveTarget`
789
+ * reads the target again when the queued npm step starts, so trust
790
+ * revoked while it waited stops it. Returns `{ installedId }`, the new
791
+ * package's list id.
792
+ */
793
+ const installPackage = async (target, payload, {
794
+ serializeInstall = runDirectly,
795
+ withWriteLock = (write) => write(target),
796
+ resolveTarget = async () => target,
797
+ } = {}) => {
798
+ const request = parseInstallRequest(payload);
799
+ const source = `npm:${request.name}`;
800
+ const identity = packageIdentity(source);
801
+ const local = request.scope === 'project';
802
+ assertInstallTarget(target, request.scope);
803
+ {
804
+ const { packageManager } = managersFor(target);
805
+ assertNotConfigured(packageManager, request.scope, identity);
806
+ }
807
+ await serializeInstall(async () => {
808
+ // Trust can change while this waits in the queue: check again first.
809
+ const current = await resolveTarget();
810
+ assertInstallTarget(current, request.scope);
811
+ const { packageManager, globalCwd } = managersFor(current);
812
+ try {
813
+ await packageManager.install(source, { local });
814
+ } catch (error) {
815
+ throw new ExtensionConfigError('PACKAGE_INSTALL_FAILED', errorText(error, globalCwd));
816
+ }
817
+ });
818
+ await withWriteLock(async (fresh) => {
819
+ // Trust and settings can change while npm runs: check again.
820
+ assertInstallTarget(fresh, request.scope);
821
+ const { settingsManager, packageManager } = managersFor(fresh);
822
+ assertNotConfigured(packageManager, request.scope, identity);
823
+ assertWritable(settingsManager);
824
+ // The package files are installed by now and stay if this write fails;
825
+ // Pi's own `installAndPersist` leaves them the same way. Report the
826
+ // failed write, never success.
827
+ try {
828
+ packageManager.addSourceToSettings(source, { local });
829
+ } catch {
830
+ throw new ExtensionConfigError('PI_SETTINGS_INVALID', 'Pi settings could not be written.');
831
+ }
832
+ await commit(settingsManager);
833
+ });
834
+ return { installedId: packageId(request.scope, identity) };
835
+ };
836
+
837
+ /**
838
+ * `pi update <source>` for one configured npm or git package, run through
839
+ * `serializeInstall` with no lock held. Pi updates every entry with the
840
+ * same identity in the settings it can read. `resolveTarget` reads the
841
+ * target again when the queued step starts, so the package is looked up
842
+ * with the trust and settings of that moment. The caller recreates
843
+ * runtimes afterwards.
844
+ */
845
+ const updatePackage = async (target, payload, { serializeInstall = runDirectly, resolveTarget = async () => target } = {}) => {
846
+ if (!payload || typeof payload !== 'object' || Array.isArray(payload)
847
+ || typeof payload.id !== 'string' || !ID_PATTERN.test(payload.id)) {
848
+ throw invalid();
849
+ }
850
+ const assertUpdatable = (source) => {
851
+ if (packageKind(source) === 'local') throw invalid('A local package has nothing to update.');
852
+ if (isPinnedSource(source)) throw new ExtensionConfigError('PACKAGE_PINNED', 'The package is pinned to a version.');
853
+ };
854
+ assertUpdatable(findConfiguredPackage(target, payload.id).match.source);
855
+ await serializeInstall(async () => {
856
+ // Trust and settings can change while this waits in the queue: look
857
+ // the package up again, which leaves out an untrusted project's.
858
+ const current = await resolveTarget();
859
+ const { match } = findConfiguredPackage(current, payload.id);
860
+ assertUpdatable(match.source);
861
+ const { packageManager, globalCwd } = managersFor(current);
862
+ try {
863
+ await packageManager.update(match.source);
864
+ } catch (error) {
865
+ throw new ExtensionConfigError('PACKAGE_UPDATE_FAILED', errorText(error, globalCwd));
866
+ }
867
+ });
868
+ };
869
+
870
+ /**
871
+ * Removes one configured package through Pi's `removeAndPersist`. Same
872
+ * locking contract as `set`. PiChamber deletes no path itself.
873
+ */
874
+ const removePackage = async (target, payload) => {
875
+ if (!payload || typeof payload !== 'object' || Array.isArray(payload)
876
+ || typeof payload.id !== 'string' || !ID_PATTERN.test(payload.id)) {
877
+ throw invalid();
878
+ }
879
+ const { projectTrusted, globalCwd, settingsManager, packageManager, match } = findConfiguredPackage(target, payload.id);
880
+ assertWritable(settingsManager);
881
+ // Pi matches the source as if it were typed after `pi remove`: a relative
882
+ // local path is read against the working directory. Settings keep it
883
+ // relative to their own folder, so a local package goes in as the
884
+ // absolute path it names there.
885
+ const source = packageKind(match.source) === 'local'
886
+ ? resolvePath(match.source, baseDirFor(match.scope, globalCwd))
887
+ : match.source;
888
+ let removed;
889
+ try {
890
+ removed = await packageManager.removeAndPersist(source, { local: match.scope === 'project' });
891
+ } catch (error) {
892
+ throw new ExtensionConfigError('PACKAGE_REMOVE_FAILED', errorText(error, globalCwd));
893
+ }
894
+ // The package files may already be gone here. A settings write that
895
+ // fails now leaves an entry for a missing package: report it, never
896
+ // success.
897
+ await commit(settingsManager);
898
+ if (!removed) throw new ExtensionConfigError('PACKAGE_NOT_CONFIGURED', 'Pi settings had no entry for the package.');
899
+ };
900
+
901
+ return { list, set, installPackage, updatePackage, removePackage };
902
+ }