@pi-chamber/web 1.0.3 → 1.0.4-rc.1

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 (290) hide show
  1. package/dist/assets/DiagramView-DfZMQkXY.js +1 -0
  2. package/dist/assets/{DiffView-D19Jps0i.js → DiffView-BjWUdbL5.js} +6 -6
  3. package/dist/assets/FileSaveConflictDialog-u5L4k_5k.js +3 -0
  4. package/dist/assets/FilesView-qP1ypN9J.js +6 -0
  5. package/dist/assets/GitHubDetailScaffold-zCKCy5OJ.js +11 -0
  6. package/dist/assets/GitHubLinkPicker-CwxKY3lN.js +1 -0
  7. package/dist/assets/GitHubListPrimitives-Ck3zllel.js +1 -0
  8. package/dist/assets/GitView-y2k2i4gR.js +9 -0
  9. package/dist/assets/IssuesSurface-HWgR87N3.js +7 -0
  10. package/dist/assets/JsonTreeView-DSuC4naV.js +1 -0
  11. package/dist/assets/{MarkdownRendererImpl-DV5Xkj8N.js → MarkdownRendererImpl-CT5ln9em.js} +5 -5
  12. package/dist/assets/PatchDiff-DArTeWeK.js +1 -0
  13. package/dist/assets/PierreDiffViewer-DQKujzLb.js +134 -0
  14. package/dist/assets/PullRequestsSurface-Cfb1wSvC.js +2 -0
  15. package/dist/assets/SessionSwitcherContent-DEGJyZBl.js +1 -0
  16. package/dist/assets/SessionSwitcherDropdown-cC9wVBH7.js +2 -0
  17. package/dist/assets/SessionUnreadDot-CELKNVIM.js +1 -0
  18. package/dist/assets/SettingsView-CZvRRgJe.js +6 -0
  19. package/dist/assets/SettingsWindow-CZM1dmVb.js +1 -0
  20. package/dist/assets/ToolOutputDialog-DClOSbJc.js +8 -0
  21. package/dist/assets/ToolPartDiffPreview-BaFiGUDE.js +1 -0
  22. package/dist/assets/{VirtualizedFileDiff-CJondRlh.js → VirtualizedFileDiff-D6KbvKc6.js} +3 -3
  23. package/dist/assets/Virtualizer-wpC51ZBQ.js +1 -0
  24. package/dist/assets/collapsible-DhV9d4dT.js +1 -0
  25. package/dist/assets/computeVirtualFileMetrics-CeMpF2xC.js +3 -0
  26. package/dist/assets/{contextFileOpenGuard-CsZL8yie.js → contextFileOpenGuard-Ck5u_kAP.js} +1 -1
  27. package/dist/assets/gitStatusPredicates-DEBSqUNE.js +1 -0
  28. package/dist/assets/githubLink-DT7i2NlH.js +10 -0
  29. package/dist/assets/index-6IO1AcJI.js +10 -0
  30. package/dist/assets/index-BAmzAlNx.css +1 -0
  31. package/dist/assets/index-eDf4LKLY.js +1 -0
  32. package/dist/assets/main-BczEScAA.js +2 -0
  33. package/dist/assets/main-CHLNMYeJ.js +136 -0
  34. package/dist/assets/markdownCore-C4Gk5Zht.js +2 -0
  35. package/dist/assets/miniChat-Do3hE87Z.js +2 -0
  36. package/dist/assets/mobile-CTnihwfa.js +2 -0
  37. package/dist/assets/permissionStore-B9Hkrqny.js +1 -0
  38. package/dist/assets/pi-session-focus-preference-LDVCJ_YR.js +10 -0
  39. package/dist/assets/renderDiffWithHighlighter-CDsgOnkH.js +1 -0
  40. package/dist/assets/renderElectronMiniChatApp-DSa3gYqR.js +2 -0
  41. package/dist/assets/renderFileWithHighlighter-TpKRyfCY.js +1 -0
  42. package/dist/assets/renderMobileApp-CPE-3uMl.js +11 -0
  43. package/dist/assets/runtimeEndpointReset-CzJfovWI.js +62 -0
  44. package/dist/assets/{runtimeSurface-BdndJV2m.js → runtimeSurface-DW_Ia4q3.js} +1 -1
  45. package/dist/assets/shell-CjFT_Tl9.js +1 -0
  46. package/dist/assets/sprite-HGQGInUp.js +6510 -0
  47. package/dist/assets/useAppFontEffects-CG3_yteE.js +212 -0
  48. package/dist/assets/{useFilesViewSearch-DJ3psTKU.js → useFilesViewSearch-C_LzYIgD.js} +1 -1
  49. package/dist/assets/useGitHubRemoteSearch-DsxWOzKZ.js +1 -0
  50. package/dist/assets/useSwitcherItems-BmoCnS9W.js +1 -0
  51. package/dist/assets/vendor-base-ui-DIkTOIJS.js +1 -0
  52. package/dist/assets/{vendor-beautiful-mermaid-D3YCkKz7.js → vendor-beautiful-mermaid-DApbjBp2.js} +1 -1
  53. package/dist/assets/vendor-boot-DyL2td56.js +69 -0
  54. package/dist/assets/vendor-codemirror-autocomplete-DsFn4GLp.js +1 -0
  55. package/dist/assets/vendor-codemirror-lang-angular-B_NMmBbS.js +1 -0
  56. package/dist/assets/vendor-codemirror-lang-cpp-GOE7Gjd0.js +1 -0
  57. package/dist/assets/vendor-codemirror-lang-css-Dwf2XpnZ.js +1 -0
  58. package/dist/assets/vendor-codemirror-lang-go-C2KHbcll.js +7 -0
  59. package/dist/assets/vendor-codemirror-lang-html-DcKqyeGk.js +1 -0
  60. package/dist/assets/vendor-codemirror-lang-java-6eGbyB2k.js +1 -0
  61. package/dist/assets/vendor-codemirror-lang-javascript-DpTUrvx8.js +13 -0
  62. package/dist/assets/vendor-codemirror-lang-jinja-xSUJjXhr.js +1 -0
  63. package/dist/assets/vendor-codemirror-lang-json-CLGxdOCz.js +1 -0
  64. package/dist/assets/vendor-codemirror-lang-less-6nXi1rS9.js +1 -0
  65. package/dist/assets/vendor-codemirror-lang-liquid-B9hmb9P8.js +1 -0
  66. package/dist/assets/vendor-codemirror-lang-markdown-DmFP9s6x.js +1 -0
  67. package/dist/assets/vendor-codemirror-lang-php-DC6To8iX.js +1 -0
  68. package/dist/assets/vendor-codemirror-lang-python-yuxIkjit.js +3 -0
  69. package/dist/assets/vendor-codemirror-lang-rust-di1Sjz-0.js +1 -0
  70. package/dist/assets/vendor-codemirror-lang-sass-BWpV9NPV.js +1 -0
  71. package/dist/assets/{vendor-codemirror-lang-sql-HpQWHJjv.js → vendor-codemirror-lang-sql-C_RazIaB.js} +2 -2
  72. package/dist/assets/vendor-codemirror-lang-vue-BYL0r7KR.js +1 -0
  73. package/dist/assets/vendor-codemirror-lang-wast-BiVarhcz.js +1 -0
  74. package/dist/assets/vendor-codemirror-lang-xml-Cn1lY1ts.js +1 -0
  75. package/dist/assets/vendor-codemirror-lang-yaml-BZ6mZw9L.js +1 -0
  76. package/dist/assets/vendor-codemirror-language-data-DglcKYWT.js +2 -0
  77. package/dist/assets/vendor-codemirror-search-DaE6R5gH.js +2 -0
  78. package/dist/assets/{vendor-elkjs-mzfkf0ML.js → vendor-elkjs-D27273Ms.js} +1 -1
  79. package/dist/assets/{vendor-heic2any-BHsbokcA.js → vendor-heic2any-pq-UTQQR.js} +1 -1
  80. package/dist/assets/vendor-lezer-cpp-Dt99h3WT.js +1 -0
  81. package/dist/assets/vendor-lezer-css-DNU_fzPI.js +1 -0
  82. package/dist/assets/vendor-lezer-go-BEFtcNyS.js +1 -0
  83. package/dist/assets/vendor-lezer-html-DDGRhRUz.js +1 -0
  84. package/dist/assets/vendor-lezer-java-DmfZtW09.js +1 -0
  85. package/dist/assets/vendor-lezer-javascript-oje4tdp_.js +1 -0
  86. package/dist/assets/vendor-lezer-json-BRXb_bDX.js +1 -0
  87. package/dist/assets/vendor-lezer-lr-BU2qmu_5.js +1 -0
  88. package/dist/assets/{vendor-lezer-markdown-C6g-d6P3.js → vendor-lezer-markdown-CicYv7V9.js} +4 -4
  89. package/dist/assets/vendor-lezer-php-COORrTpE.js +1 -0
  90. package/dist/assets/vendor-lezer-python-Cuvm9X9Y.js +1 -0
  91. package/dist/assets/vendor-lezer-rust-C_zOfHbX.js +1 -0
  92. package/dist/assets/vendor-lezer-sass-DWP4w7O1.js +1 -0
  93. package/dist/assets/vendor-lezer-xml-Br6nOYeG.js +1 -0
  94. package/dist/assets/vendor-lezer-yaml-CYQmm6Sb.js +1 -0
  95. package/dist/assets/{vendor-lru_map-Cy8fTs3_.js → vendor-lru_map-DOPmc7GU.js} +1 -1
  96. package/dist/assets/{vendor-qrcode-B0KNSajT.js → vendor-qrcode-Dv4uniC1.js} +1 -1
  97. package/dist/assets/vendor-react-DASdDPIk.js +1 -0
  98. package/dist/assets/{vendor-react-drawio-BYDptOsj.js → vendor-react-drawio-Duu5LgQA.js} +1 -1
  99. package/dist/assets/{vendor-replit-codemirror-vim-DaSwPsXt.js → vendor-replit-codemirror-vim-CZy3BUVv.js} +15 -15
  100. package/dist/assets/vendor-zustand-CUi8eEds.js +6 -0
  101. package/dist/assets/{web-components-CCKlju0Z.js → web-components-CH3-XV-n.js} +4 -4
  102. package/dist/index.html +7 -9
  103. package/dist/mini-chat.html +6 -8
  104. package/dist/mobile.html +6 -8
  105. package/package.json +1 -1
  106. package/server/index.js +3 -1
  107. package/server/lib/fs/DOCUMENTATION.md +1 -1
  108. package/server/lib/fs/routes.js +1 -50
  109. package/server/lib/git/DOCUMENTATION.md +18 -11
  110. package/server/lib/git/index.js +8 -3
  111. package/server/lib/git/routes.js +0 -129
  112. package/server/lib/git/service.js +40 -152
  113. package/server/lib/git/service.test.js +42 -18
  114. package/server/lib/github/DOCUMENTATION.md +271 -0
  115. package/server/lib/github/cache.js +164 -0
  116. package/server/lib/github/checks.js +230 -0
  117. package/server/lib/github/client.js +305 -0
  118. package/server/lib/github/context.js +177 -0
  119. package/server/lib/github/contracts.test.js +235 -0
  120. package/server/lib/github/correctness.test.js +356 -0
  121. package/server/lib/github/credential.js +46 -0
  122. package/server/lib/github/errors.js +151 -0
  123. package/server/lib/github/gh-cli.js +336 -0
  124. package/server/lib/github/index.js +27 -0
  125. package/server/lib/github/issues.js +495 -0
  126. package/server/lib/github/pulls.js +699 -0
  127. package/server/lib/github/repo-scope.js +688 -0
  128. package/server/lib/github/routes.js +599 -0
  129. package/server/lib/github/security.test.js +275 -0
  130. package/server/lib/github/templates.js +153 -0
  131. package/server/lib/package-manager-detect-child.js +12 -0
  132. package/server/lib/package-manager.js +366 -92
  133. package/server/lib/package-manager.test.js +109 -0
  134. package/server/lib/pi/routes-extension-events.test.js +268 -4
  135. package/server/lib/pi/routes.js +109 -25
  136. package/server/lib/pi/routes.test.js +118 -0
  137. package/server/lib/pi/session-daemon/DOCUMENTATION.md +5 -3
  138. package/server/lib/pi/session-daemon/extension-bridge-draft.test.js +222 -0
  139. package/server/lib/pi/session-daemon/extension-bridge.js +415 -42
  140. package/server/lib/pi/session-daemon/extension-name.js +87 -0
  141. package/server/lib/pi/session-daemon/extension-name.test.js +143 -0
  142. package/server/lib/pi/session-daemon/extension-theme.js +142 -0
  143. package/server/lib/pi/session-daemon/extension-theme.test.js +117 -0
  144. package/server/lib/pi/session-daemon/extension-tool-render.js +365 -0
  145. package/server/lib/pi/session-daemon/extension-tool-render.test.js +607 -0
  146. package/server/lib/pi/session-daemon/session-daemon-extensions.test.js +322 -2
  147. package/server/lib/pi/session-daemon/session-daemon-list-live.test.js +244 -0
  148. package/server/lib/pi/session-daemon/session-daemon.js +204 -33
  149. package/server/lib/pi/session-daemon/session-daemon.test.js +218 -0
  150. package/server/lib/pi/ui-settings-store.js +1 -1
  151. package/server/lib/static-cache-control.js +18 -0
  152. package/server/lib/static-cache-control.test.js +25 -0
  153. package/server/lib/workspace/host.js +2 -0
  154. package/dist/assets/DiagramView-Bj1ZrdhI.js +0 -1
  155. package/dist/assets/FileSaveConflictDialog-2Z4V_gZU.js +0 -3
  156. package/dist/assets/FilesView-K18gBSws.js +0 -6
  157. package/dist/assets/GitView-Hm1KBPaD.js +0 -8
  158. package/dist/assets/JsonTreeView-fNsiZEIo.js +0 -1
  159. package/dist/assets/PatchDiff-DZaJG6jj.js +0 -1
  160. package/dist/assets/SessionSwitcherContent-RAsmsuYk.js +0 -1
  161. package/dist/assets/SessionSwitcherDropdown-DuLPlIF_.js +0 -2
  162. package/dist/assets/SessionUnreadDot-Dm6k5OCd.js +0 -1
  163. package/dist/assets/SettingsView-Chu4zbWo.js +0 -6
  164. package/dist/assets/SettingsWindow-CJzFmmfu.js +0 -1
  165. package/dist/assets/ToolOutputDialog-uYeXsAGc.js +0 -8
  166. package/dist/assets/ToolPartDiffPreview-DnAHVRs-.js +0 -1
  167. package/dist/assets/Virtualizer-BSHVMKgK.js +0 -1
  168. package/dist/assets/collapsible-BH1vXEAI.js +0 -1
  169. package/dist/assets/computeVirtualFileMetrics-DXkR5jdw.js +0 -3
  170. package/dist/assets/gitStatusPredicates-BW8heN1a.js +0 -134
  171. package/dist/assets/index-5fyXnZFi.css +0 -1
  172. package/dist/assets/index-BrgKwTb0.js +0 -1
  173. package/dist/assets/index-C-sV_9sb.js +0 -8
  174. package/dist/assets/isDiffPlainText-DZFr1Tta.js +0 -1
  175. package/dist/assets/isFilePlainText-KNpEMvb-.js +0 -1
  176. package/dist/assets/main-BPY2ug1A.js +0 -135
  177. package/dist/assets/main-BRIjzIRl.js +0 -2
  178. package/dist/assets/markdownCore-DYizLr1N.js +0 -3
  179. package/dist/assets/miniChat-Dva4MINl.js +0 -2
  180. package/dist/assets/mobile-6jNUNv_x.js +0 -2
  181. package/dist/assets/permissionStore-iKN1K2_x.js +0 -1
  182. package/dist/assets/renderElectronMiniChatApp-BIeBrZmO.js +0 -2
  183. package/dist/assets/renderMobileApp-BDCtZpeS.js +0 -11
  184. package/dist/assets/runtimeEndpointReset-DqdGOWp8.js +0 -53
  185. package/dist/assets/useAppFontEffects-BABx-DxZ.js +0 -6722
  186. package/dist/assets/usePushVisibilityBeacon-BciEu3HS.js +0 -10
  187. package/dist/assets/useSwitcherItems-C7_5TB_n.js +0 -1
  188. package/dist/assets/vendor-aria-hidden-DvXkyWUv.js +0 -1
  189. package/dist/assets/vendor-base-ui-DXSHfszQ.js +0 -1
  190. package/dist/assets/vendor-class-variance-authority-5VPnzWs2.js +0 -1
  191. package/dist/assets/vendor-cmdk-zXx6sGnS.js +0 -1
  192. package/dist/assets/vendor-codemirror-autocomplete-wd6iRebq.js +0 -1
  193. package/dist/assets/vendor-codemirror-commands-CNlncqrr.js +0 -1
  194. package/dist/assets/vendor-codemirror-lang-angular-DU_4KiiW.js +0 -1
  195. package/dist/assets/vendor-codemirror-lang-cpp-CmIT9Z5_.js +0 -1
  196. package/dist/assets/vendor-codemirror-lang-css-djiuoTi8.js +0 -1
  197. package/dist/assets/vendor-codemirror-lang-go-COZSwZYW.js +0 -7
  198. package/dist/assets/vendor-codemirror-lang-html-CKHqhW5R.js +0 -1
  199. package/dist/assets/vendor-codemirror-lang-java-CNMP5hyC.js +0 -1
  200. package/dist/assets/vendor-codemirror-lang-javascript-DuOEwJ3f.js +0 -13
  201. package/dist/assets/vendor-codemirror-lang-jinja-DaKn_b1k.js +0 -1
  202. package/dist/assets/vendor-codemirror-lang-json-CZ07HmNC.js +0 -1
  203. package/dist/assets/vendor-codemirror-lang-less-wJdQiDBf.js +0 -1
  204. package/dist/assets/vendor-codemirror-lang-liquid-0z48Roi8.js +0 -1
  205. package/dist/assets/vendor-codemirror-lang-markdown-DtcZDGqe.js +0 -1
  206. package/dist/assets/vendor-codemirror-lang-php-W8plS-JQ.js +0 -1
  207. package/dist/assets/vendor-codemirror-lang-python-DzzokVau.js +0 -3
  208. package/dist/assets/vendor-codemirror-lang-rust-C4ulBVpf.js +0 -1
  209. package/dist/assets/vendor-codemirror-lang-sass-BkZJYEwS.js +0 -1
  210. package/dist/assets/vendor-codemirror-lang-vue-DiBPljCc.js +0 -1
  211. package/dist/assets/vendor-codemirror-lang-wast-DoABsogh.js +0 -1
  212. package/dist/assets/vendor-codemirror-lang-xml-BhLJhOCH.js +0 -1
  213. package/dist/assets/vendor-codemirror-lang-yaml-D95i1Y5R.js +0 -1
  214. package/dist/assets/vendor-codemirror-language-BByA_dGF.js +0 -3
  215. package/dist/assets/vendor-codemirror-language-data-BB5mQv-R.js +0 -2
  216. package/dist/assets/vendor-codemirror-search-BV44140v.js +0 -2
  217. package/dist/assets/vendor-codemirror-state-CNWM3Q8V.js +0 -5
  218. package/dist/assets/vendor-codemirror-view-Ct4T37Ue.js +0 -4
  219. package/dist/assets/vendor-crelt-C8TCjufn.js +0 -1
  220. package/dist/assets/vendor-detect-node-es-l0sNRNKZ.js +0 -1
  221. package/dist/assets/vendor-dnd-kit-accessibility-DZKKhs9S.js +0 -1
  222. package/dist/assets/vendor-dnd-kit-core-C9qcAm_1.js +0 -5
  223. package/dist/assets/vendor-dnd-kit-sortable-D8ozj8M-.js +0 -1
  224. package/dist/assets/vendor-dnd-kit-utilities-DTY1C6ST.js +0 -1
  225. package/dist/assets/vendor-floating-ui-core-CXmKXOXc.js +0 -1
  226. package/dist/assets/vendor-floating-ui-dom-WyXykhNi.js +0 -1
  227. package/dist/assets/vendor-floating-ui-react-dom-BZOGXAGe.js +0 -1
  228. package/dist/assets/vendor-floating-ui-utils-BzXdqYpP.js +0 -1
  229. package/dist/assets/vendor-framer-motion-CfplGuM0.js +0 -1
  230. package/dist/assets/vendor-get-nonce-C-Z93AgS.js +0 -1
  231. package/dist/assets/vendor-lezer-common-B3-cUCR_.js +0 -1
  232. package/dist/assets/vendor-lezer-cpp-BleAU9o-.js +0 -1
  233. package/dist/assets/vendor-lezer-css-C5xB6jxd.js +0 -1
  234. package/dist/assets/vendor-lezer-go-CXK1UKk8.js +0 -1
  235. package/dist/assets/vendor-lezer-highlight-CDMHUZ74.js +0 -1
  236. package/dist/assets/vendor-lezer-html-C0I1p52t.js +0 -1
  237. package/dist/assets/vendor-lezer-java-D_zzj-NV.js +0 -1
  238. package/dist/assets/vendor-lezer-javascript-D7Tj24ot.js +0 -1
  239. package/dist/assets/vendor-lezer-json-Iaex0UN-.js +0 -1
  240. package/dist/assets/vendor-lezer-lr-bhwg1HMg.js +0 -1
  241. package/dist/assets/vendor-lezer-php-_DHrbsZG.js +0 -1
  242. package/dist/assets/vendor-lezer-python-CvuFxeZl.js +0 -1
  243. package/dist/assets/vendor-lezer-rust-Lqgd5SAo.js +0 -1
  244. package/dist/assets/vendor-lezer-sass-Dnm2lY4t.js +0 -1
  245. package/dist/assets/vendor-lezer-xml-hUDuAyS5.js +0 -1
  246. package/dist/assets/vendor-lezer-yaml-BNIl6S_O.js +0 -1
  247. package/dist/assets/vendor-marijn-find-cluster-break-DXwl3gUT.js +0 -1
  248. package/dist/assets/vendor-motion-dom-DhJ-sYS5.js +0 -1
  249. package/dist/assets/vendor-motion-l0sNRNKZ.js +0 -1
  250. package/dist/assets/vendor-motion-utils-CKEGc_YG.js +0 -1
  251. package/dist/assets/vendor-radix-ui-primitive-Dc_FVRD7.js +0 -1
  252. package/dist/assets/vendor-radix-ui-react-compose-refs-8xy6TJML.js +0 -1
  253. package/dist/assets/vendor-radix-ui-react-context-CFsX-AUC.js +0 -1
  254. package/dist/assets/vendor-radix-ui-react-dialog-D2yhEu2p.js +0 -5
  255. package/dist/assets/vendor-radix-ui-react-dismissable-layer-DrorBNg9.js +0 -1
  256. package/dist/assets/vendor-radix-ui-react-focus-guards-BfdFmL7c.js +0 -1
  257. package/dist/assets/vendor-radix-ui-react-focus-scope-D2BkImwt.js +0 -1
  258. package/dist/assets/vendor-radix-ui-react-id-D2kS9K1j.js +0 -1
  259. package/dist/assets/vendor-radix-ui-react-portal-YgCRIyi7.js +0 -1
  260. package/dist/assets/vendor-radix-ui-react-presence-D432pCMB.js +0 -1
  261. package/dist/assets/vendor-radix-ui-react-primitive-DkH8dMOR.js +0 -1
  262. package/dist/assets/vendor-radix-ui-react-slot-BIDFZX0-.js +0 -1
  263. package/dist/assets/vendor-radix-ui-react-use-callback-ref-BwDcSoGV.js +0 -1
  264. package/dist/assets/vendor-radix-ui-react-use-controllable-state-LiqmKSXO.js +0 -1
  265. package/dist/assets/vendor-radix-ui-react-use-effect-event-D94va83M.js +0 -1
  266. package/dist/assets/vendor-radix-ui-react-use-escape-keydown-DTkqjenV.js +0 -1
  267. package/dist/assets/vendor-radix-ui-react-use-layout-effect-C8Yrsaph.js +0 -1
  268. package/dist/assets/vendor-react-B5Z1Mdn3.js +0 -9
  269. package/dist/assets/vendor-react-remove-scroll-bar-CSAHp1YF.js +0 -38
  270. package/dist/assets/vendor-react-remove-scroll-vR1dy1aP.js +0 -4
  271. package/dist/assets/vendor-react-style-singleton-Ctw6HnYx.js +0 -1
  272. package/dist/assets/vendor-reselect-l0sNRNKZ.js +0 -1
  273. package/dist/assets/vendor-scheduler-7OC5HNn7.js +0 -1
  274. package/dist/assets/vendor-simplewebauthn-browser-VDA66rT_.js +0 -2
  275. package/dist/assets/vendor-sonner-BDtm25td.js +0 -1
  276. package/dist/assets/vendor-style-mod-NZ5MEPvj.js +0 -3
  277. package/dist/assets/vendor-tanstack-react-virtual-2skouoFw.js +0 -1
  278. package/dist/assets/vendor-tanstack-virtual-core-Dubg10g5.js +0 -1
  279. package/dist/assets/vendor-tslib-De9GV7Vy.js +0 -1
  280. package/dist/assets/vendor-use-callback-ref-CVVuCyLj.js +0 -1
  281. package/dist/assets/vendor-use-sidecar-Vv4V8Nd1.js +0 -1
  282. package/dist/assets/vendor-use-sync-external-store-D0AXkdQC.js +0 -1
  283. package/dist/assets/vendor-w3c-keyname-Vcq4gwWv.js +0 -1
  284. package/dist/assets/vendor-zustand-GVb4H8HE.js +0 -6
  285. package/server/lib/git/credentials.js +0 -41
  286. package/server/lib/git/identity-storage.js +0 -122
  287. /package/dist/assets/{vendor-katex-CNckGUMB.js → vendor-katex-DZG0Ov6p.js} +0 -0
  288. /package/dist/assets/{vendor-katex-Cp579UoJ.css → vendor-katex-css-Cp579UoJ.css} +0 -0
  289. /package/dist/assets/{vendor-xterm-xterm-CrXqRur4.js → vendor-xterm-xterm-B-qIQCd3.js} +0 -0
  290. /package/dist/assets/{vendor-xterm-xterm-DDGTF8rc.css → vendor-xterm-xterm-css-DDGTF8rc.css} +0 -0
@@ -915,6 +915,44 @@ describe('Pi runtime route', () => {
915
915
  });
916
916
  });
917
917
 
918
+ it('whitelists live list status and drops a malformed one without failing the row', async () => {
919
+ const row = (id, live) => ({
920
+ session: { id, directory: '/workspace', createdAt: 1, updatedAt: 2 },
921
+ updatedAt: 2,
922
+ ...(live !== undefined ? { live } : {}),
923
+ });
924
+ const runtime = {
925
+ health: async () => ({ state: 'ready', protocolVersion: 1, capabilities: ['sessions.list'] }),
926
+ request: async () => ({
927
+ streamEpoch: 'epoch-1',
928
+ sessions: [
929
+ row('busy', { lifecycle: 'busy', sequence: 7, runStartedAt: 100, serverNow: 200, cwd: '/private', pid: 42 }),
930
+ row('retry', { lifecycle: 'retry', sequence: 8, retry: { attempt: 2, next: 300, message: 'rate limited', raw: { secret: 'x' } }, serverNow: 200 }),
931
+ row('idle', { lifecycle: 'idle', sequence: 9, serverNow: 200 }),
932
+ row('bad-state', { lifecycle: 'compacting', sequence: 1 }),
933
+ row('bad-sequence', { lifecycle: 'busy', sequence: -1 }),
934
+ row('bad-shape', 'busy'),
935
+ row('none'),
936
+ ],
937
+ }),
938
+ };
939
+ const app = express();
940
+ registerPiRuntimeRoutes(app, { getPiSessionDaemonRuntime: () => runtime });
941
+ server = await listen(app);
942
+
943
+ const response = await fetch(`http://127.0.0.1:${server.address().port}/api/pi/sessions?directory=%2Fworkspace`);
944
+ expect(response.status).toBe(200);
945
+ const body = await response.json();
946
+ const byId = new Map(body.sessions.map((item) => [item.session.id, item]));
947
+ expect(body.sessions).toHaveLength(7);
948
+ expect(byId.get('busy').live).toEqual({ lifecycle: 'busy', sequence: 7, runStartedAt: 100, serverNow: 200 });
949
+ expect(byId.get('retry').live).toEqual({ lifecycle: 'retry', sequence: 8, retry: { attempt: 2, next: 300, message: 'rate limited' }, serverNow: 200 });
950
+ expect(byId.get('idle').live).toEqual({ lifecycle: 'idle', sequence: 9, serverNow: 200 });
951
+ for (const id of ['bad-state', 'bad-sequence', 'bad-shape', 'none']) {
952
+ expect(byId.get(id).live).toBeUndefined();
953
+ }
954
+ });
955
+
918
956
  it('renames a session through the daemon without accepting a body session identity', async () => {
919
957
  const runtime = {
920
958
  health: async () => ({ state: 'ready', protocolVersion: 1, capabilities: ['sessions.rename'] }),
@@ -1133,6 +1171,86 @@ describe('Pi runtime route', () => {
1133
1171
  }
1134
1172
  });
1135
1173
 
1174
+ it('creates a session and projects the created detail like a session read', async () => {
1175
+ const calls = [];
1176
+ let created;
1177
+ const runtime = {
1178
+ health: async () => ({ state: 'ready', protocolVersion: 1, capabilities: [] }),
1179
+ request: async (command, payload) => {
1180
+ calls.push({ command, payload });
1181
+ return created;
1182
+ },
1183
+ };
1184
+ const app = express();
1185
+ app.use(express.json());
1186
+ registerPiRuntimeRoutes(app, { getPiSessionDaemonRuntime: () => runtime });
1187
+ server = await listen(app);
1188
+ const url = `http://127.0.0.1:${server.address().port}/api/pi/sessions`;
1189
+ const create = (body) => fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) });
1190
+ const session = { id: 'pi-session-new', directory: '/workspace', createdAt: 1, updatedAt: 1, messageCount: 0, privatePath: '/private' };
1191
+
1192
+ created = { session, messages: [], lastSequence: 3, isStreaming: false, lifecycle: 'idle', streamEpoch: 'epoch-create', serverNow: 10 };
1193
+ const empty = await create({ directory: '/workspace', title: 'New' });
1194
+ expect(empty.status).toBe(201);
1195
+ await expect(empty.json()).resolves.toEqual({
1196
+ session: { id: 'pi-session-new', directory: '/workspace', createdAt: 1, updatedAt: 1, messageCount: 0 },
1197
+ messages: [],
1198
+ lastSequence: 3,
1199
+ isStreaming: false,
1200
+ lifecycle: 'idle',
1201
+ streamEpoch: 'epoch-create',
1202
+ serverNow: 10,
1203
+ });
1204
+ expect(calls).toEqual([{ command: 'sessions.create', payload: { directory: '/workspace', title: 'New', cwd: '/workspace' } }]);
1205
+
1206
+ // Extensions such as Plannotator append entries or messages from
1207
+ // `session_start`, so a brand-new session can carry extension items and
1208
+ // extension UI state.
1209
+ created = {
1210
+ session: { ...session, messageCount: 2 },
1211
+ messages: [
1212
+ { message: { id: 'entry-1', sessionId: 'pi-session-new', directory: '/workspace', role: 'extension', customType: 'plannotator', createdAt: 2, data: { mode: 'plan' } }, parts: [] },
1213
+ { message: { id: 'entry-2', sessionId: 'pi-session-new', directory: '/workspace', role: 'extension', customType: 'plannotator', text: 'Plan mode ready', createdAt: 3, details: { step: 1 } }, parts: [] },
1214
+ ],
1215
+ lastSequence: 4,
1216
+ isStreaming: false,
1217
+ lifecycle: 'idle',
1218
+ streamEpoch: 'epoch-create',
1219
+ extensionStatuses: [{ key: 'plannotator', text: 'planning' }],
1220
+ };
1221
+ const withExtension = await create({ cwd: '/workspace' });
1222
+ expect(withExtension.status).toBe(201);
1223
+ await expect(withExtension.json()).resolves.toMatchObject({
1224
+ session: { id: 'pi-session-new', messageCount: 2 },
1225
+ messages: [
1226
+ { message: { id: 'entry-1', role: 'extension', customType: 'plannotator', data: { mode: 'plan' } }, parts: [] },
1227
+ { message: { id: 'entry-2', role: 'extension', customType: 'plannotator', text: 'Plan mode ready', details: { step: 1 } }, parts: [] },
1228
+ ],
1229
+ lastSequence: 4,
1230
+ lifecycle: 'idle',
1231
+ streamEpoch: 'epoch-create',
1232
+ extensionStatuses: [{ key: 'plannotator', text: 'planning' }],
1233
+ });
1234
+
1235
+ for (const malformed of [
1236
+ { session, messages: [{ message: { id: 'entry-1', sessionId: 'pi-session-new', directory: '/workspace', role: 'system', createdAt: 2 }, parts: [] }], lastSequence: 4 },
1237
+ { session, messages: [{ message: { id: 'entry-1', sessionId: 'pi-session-new', directory: '/workspace', role: 'extension', createdAt: 2 } }], lastSequence: 4 },
1238
+ { session, messages: [], lastSequence: 'x' },
1239
+ { session, lastSequence: 4 },
1240
+ { session: { id: '' }, messages: [], lastSequence: 4 },
1241
+ null,
1242
+ ]) {
1243
+ created = malformed;
1244
+ const response = await create({ cwd: '/workspace' });
1245
+ expect(response.status).toBe(503);
1246
+ await expect(response.json()).resolves.toEqual({ error: { code: 'DAEMON_PROTOCOL_MISMATCH' } });
1247
+ }
1248
+
1249
+ const callsBeforeInvalid = calls.length;
1250
+ expect((await create({})).status).toBe(400);
1251
+ expect(calls).toHaveLength(callsBeforeInvalid);
1252
+ });
1253
+
1136
1254
  it('verifies archive membership against the owning directory', async () => {
1137
1255
  const calls = [];
1138
1256
  const runtime = {
@@ -8,9 +8,11 @@ This module is the Pi-owned session-daemon foundation. A detached local daemon p
8
8
 
9
9
  - `../extension-protocol.js` owns the bounded form descriptor and response validation shared by the private daemon bridge and public route projection, so both sides of the IPC seam accept the same field contract.
10
10
  - `extension-bridge.js` owns extension UI bindings, pending dialog lifecycle, normalized status/widget/panel/app state, snapshot projection, and extension event publication. `session-daemon.js` supplies runtime lookup, publication, redaction, and directory dependencies through its narrow factory interface.
11
+ - `extension-name.js` owns path-free extension display names for `extensions.list` and the `source` of runtime `extension.error` events. A single-file extension is named after its file; an `index` entry point is named after its nearest non-generic directory, or the package root for package extensions. Neither surface ever carries a server path.
12
+ - `extension-tool-render.js` owns daemon-side rendering for Pi extension tools that define `renderCall` or `renderResult`. Built-in tools are excluded so PiChamber retains native tool card rendering. Global Pi TUI theme symbols are installed once without overriding an existing theme. Partial updates render both the collapsed and expanded result slots (the browser draws the expanded slot only when a row is expanded), are throttled at 250ms with a trailing timer and component `invalidate()` trigger, the latest live render of a running tool is kept and included in session detail so a client opening mid-run sees the working state, settled results are rendered only for messages a history page selects (never for the whole branch) and memoized per toolResult message for history replay, and rendered ANSI lines are bounded to 100 columns, ≤200 lines, and ≤2000 characters per line.
11
13
  - `session-daemon.js`
12
14
  - `createPiSessionRuntime({ cwd, agentDir })` creates a persistent Pi runtime using the selected server-side cwd and Pi agent directory. It uses Pi's normal settings, credentials, models, sessions, skills, prompts, context discovery, and native extensions. Every runtime creation binds extensions through `session.bindExtensions()` in rpc-like mode with a daemon-owned UI bridge, so pi extensions load exactly as they do under the Pi CLI's RPC mode. Sessions created outside PiChamber (Pi CLI or any other writer of the cwd-scoped JSONL directory) are the same records: `sessions.list`/`open` hydrate from `getEntries()`, then overlay the live `session.messages` / `state.streamingMessage` turn while `isStreaming` is true, including an unpersisted user prompt that has not flushed to JSONL yet. A later prompt must overlay live turns onto that log rather than replace it. An unmatched `toolCall` projects as `running` only while `isStreaming` is authoritative; the same unmatched call in an idle persisted turn projects as a timestamped interruption error instead of malformed `completed` state. `getSession` also reports `isStreaming` and `lifecycle` so a restarted UI can restore the working/tooling state without waiting for the next token.
13
- - Extension bridging: blocking dialogs (`ctx.ui.select/confirm/input/editor`, plus the PiChamber-specific `ctx.ui.form` which resolves with a values object keyed by field id) publish an `extension.dialog` event and stay pending until answered by the `extensions.respond` private command; every answer, timeout, abort, session close, or daemon stop publishes an authoritative `extension.dialog.dismiss` event before resolving the extension so every connected client removes the modal (timeouts resolve defaults, abort resolves cancellation, form answers travel as a sanitized `values` record and are rejected unless required fields, number bounds, select options, and checkbox values match the pending form); fire-and-forget calls publish `extension.notify`, `extension.status`, `extension.widget`, session-scoped `extension.editor`, and `extension.title`; extension errors publish `extension.error`; appended custom entries and displayed custom messages publish `extension.entry` / `extension.message`. `pichamber.ui` entries with a stable `id` are additionally mirrored into normalized `extension.ui` panel events (latest wins per id, `removed: true` unregisters) and `pichamber.app` entries into sandboxed `extension.app` app surfaces; extension live state is kept in per-session maps and included in both `sessions.open` and `session.snapshot`. The open response must cover every extension event at or below its `lastSequence`, so first attach cannot skip one-time startup statuses before the browser stream connects; reconnect snapshots rebuild the same live panels. TUI-only component replacement, footers, and themes remain intentional no-ops; standard RPC editor replacement and window titles are projected to the focused browser session. Pending dialogs are cancelled when the owning runtime hits idle disposal or daemon stop so no extension thread blocks forever. Unknown dialog responses return `{ resolved: false }` rather than throwing so a stale client retry cannot tear down the shared socket.
15
+ - Extension bridging: blocking dialogs (`ctx.ui.select/confirm/input/editor`, plus the PiChamber-specific `ctx.ui.form` which resolves with a values object keyed by field id) publish an `extension.dialog` event and stay pending until answered by the `extensions.respond` private command; every answer, timeout, abort, session close, or daemon stop publishes an authoritative `extension.dialog.dismiss` event before resolving the extension so every connected client removes the modal (timeouts resolve defaults, abort resolves cancellation, form answers travel as a sanitized `values` record and are rejected unless required fields, number bounds, select options, and checkbox values match the pending form); fire-and-forget calls publish `extension.notify`, `extension.status`, `extension.widget` (supporting both string arrays and component factory functions rendered daemon-side with a 100-column `tuiStub` and 100ms coalesced `requestRender()` throttling, with automatic lifecycle disposal and error capture), session-scoped `extension.working` (`setWorkingMessage` / `setWorkingVisible` with control character sanitization and 200-char cap; `setHiddenThinkingLabel` and `setWorkingIndicator` remain intentional no-ops because PiChamber uses its own turn working header and full thinking presentation), session-scoped `extension.editor` (`mode: 'set' | 'paste'`, default `'set'`), and `extension.title`; extension errors publish `extension.error`; displayed custom messages publish `extension.message`, and appended `pichamber.*` custom entries without a stable `id` publish `extension.entry` and appear as one-off extension-role transcript items; any other `appendEntry` custom entry is private extension state (Pi's TUI never renders it) and is neither published nor projected into history. `pichamber.ui` entries with a stable `id` and `pichamber.app` entries are mirrored into normalized live panel/app state (`extension.ui` / `extension.app` events live; latest wins per id, `removed: true` unregisters) and are excluded from transcript messages to avoid duplicate rendering. `ctx.ui.getEditorText()` uses a lazy server-side mirror: the first call on a session marks it as tracked, emits an `extension.editor.track` event (`{ enabled: true }`), and returns the current mirror text (or `''` initially); the browser composer observes tracking through session snapshots and the event stream, immediately syncing its current draft and then debouncing subsequent draft changes by 250ms via `POST /api/pi/sessions/:id/editor-draft` with monotonically increasing revisions to reject out-of-order deliveries; prompt submission resets the mirror text to empty while preserving tracking; `setEditorText` and `pasteToEditor` update the mirror synchronously; and session close, deletion, reload, or daemon disposal clears both the mirror and the tracking flag and publishes `extension.editor.track` with `{ enabled: false }` so browsers stop syncing until a later call opts the session back in. Untracked sessions never allocate mirror state (a prompt reset only touches an existing mirror), and draft syncs refresh the session's idle-disposal timer without reactivating a disposed runtime. `ctx.ui.theme` implements the complete Pi SDK `Theme` interface (`fg`, `bg`, `bold`, `italic`, `underline`, `inverse`, `strikethrough`, `getFgAnsi`, `getBgAnsi`, `getColorMode`, `getThinkingBorderColor`, `getBashModeBorderColor`), encoding semantic colors as standard truecolor SGR escape markers (`38;2;1;1;<index>m` and `48;2;1;1;<index>m`) using canonical `THEME_COLORS` and `THEME_BG_COLORS` lists that must stay strictly synchronized with `packages/ui/src/lib/pi/ansi.ts`. Extension live state (statuses, widgets, panels, apps, titles, and working indicators) is kept in per-session maps and included in both `sessions.open` and `session.snapshot`; on session runtime creation/open, restart, or branch mutation (`sessions.navigate`, `sessions.fork`, `sessions.clone`), live panels and apps are rebuilt by replaying the active branch's persisted `pichamber.ui`/`pichamber.app` custom entries in order without publishing per-entry events. The open response must cover every extension event at or below its `lastSequence`, so first attach cannot skip one-time startup statuses before the browser stream connects; reconnect snapshots rebuild the same live panels. TUI-only `setHeader`, `setFooter`, and `custom` remain intentional no-ops because PiChamber provides web/GUI message framing and composer docks rather than terminal chrome; standard RPC editor replacement/insertion and window titles are projected to the focused browser session. Pending dialogs are cancelled when the owning runtime hits idle disposal, session deletion, or daemon stop so no extension thread blocks forever. Unknown dialog responses return `{ resolved: false }` rather than throwing so a stale client retry cannot tear down the shared socket.
14
16
  - `createSessionDaemon(options)` starts/stops the authenticated local socket daemon and validates its endpoint and setup inputs. Test seams inject `createRuntime` for resident runtimes and `createServices` (default `createAgentSessionServices`) for transient per-mutation prompt services.
15
17
  - `session-replay.js` owns the byte- and count-bounded contiguous replay suffix (`MAX_REPLAY_EVENTS`, `MAX_REPLAY_BYTES`, `createSessionReplayLog`). It caches one serialized line per event for broadcast/replay reuse and reports contiguity (`canReplay`) without trusting filtered delivery.
16
18
  - `daemon-process.js` is the detached private-process entrypoint. It reads the daemon credential from its owner-only sidecar, starts the socket, writes non-secret identity state only after readiness, persists an accepted ownership claim before acknowledging it over IPC, and removes only its own state on signal shutdown.
@@ -21,7 +23,7 @@ This module is the Pi-owned session-daemon foundation. A detached local daemon p
21
23
  - `../server/server-profile.js` derives one stable daemon profile per server: installed web is `web-p<port>`, development web is `web-dev-p<port>`, installed desktop is `desktop`, and development desktop is `desktop-dev`. `PICHAMBER_SERVER_PROFILE` overrides the derivation with a hashed `custom-<hash>` key so raw input never becomes a path, while preserving whether the launcher is a development build for stale-code replacement. The profile key is stable across restarts; the server instance id is a fresh UUID per launch. Development launchers (`scripts/dev-web-hmr.mjs`, `scripts/dev-web-full.mjs`, `cross-env` in the `dev:server` scripts, `PICHAMBER_ELECTRON_DEV`) explicitly mark themselves so stopping development can never terminate the installed daemon.
22
24
  - `../server/cross-process-lock.js` serializes critical sections across servers sharing one data directory (exclusive create, owner nonce, dead-pid steal, bounded wait). It backs the daemon operation lock pattern and every shared read-modify-write store below.
23
25
  - `session-lease.js` owns exclusive cross-daemon residency of one Pi session, keyed by canonical agent directory, cwd, and session id under `<agentDir>/.pichamber/locks/sessions/`. The lease is acquired before a resident `AgentSessionRuntime` is created and released after idle disposal, deletion, replacement, or daemon shutdown. Opening or deleting a session leased by another live daemon returns `SESSION_IN_USE` (HTTP 409) while the session stays visible in listings; different sessions remain fully concurrent. Lease files from different `PICHAMBER_DATA_DIR` values still coordinate because they live under the shared agent directory.
24
- - `../routes.js` registers authenticated public adapters before the generic proxy. It exposes only whitelisted runtime, project, session, provider-auth/configuration, settings, resource, small-model utility, and SSE event shapes; no browser response contains daemon paths, credentials, PIDs, headers, or socket framing. Session actions are path-selected, so an identity supplied in a request body cannot redirect a mutation. `archive-store.js` persists PiChamber-only opaque session archive metadata atomically beneath the PiChamber data root and never edits Pi JSONL. `settings-store.js` keeps PiChamber new-session defaults separate from Pi settings.json. `/api/pi/small-model/generate` reads that sidecar and runs a bounded in-memory no-tools Pi session, so utility generation creates no visible or persisted session and exposes no model or credential details. `GET /api/pi/settings` copies leftover UI/desktop `defaultModel` / small / walkthrough strings into that sidecar when those sidecar fields are unset, then Sessions settings is the only editor. Sidecar `defaultThinkingByModel` is the per-model thinking map (`provider/model` keys). A stored global `defaultThinking` with a default model is copied onto that map key and dropped; global thinking without a default model remains a clamp-only fallback. `ui-settings-store.js` owns portable PiChamber preferences at data-root `settings.json` and host, device, and secret-bearing values at `runtime-state.json`. `/api/pi/ui-settings` merges both views for existing clients and splits writes through explicit field allowlists. It migrates an unscoped flat file once; after the portable scope marker exists, local fields found in `settings.json` are ignored rather than applied to the host. The route is not available through removed `/api/config/*` aliases. `session-folders-store.js` validates and atomically persists the restored sidebar's folder snapshot at `/api/pi/session-folders`; a missing snapshot is distinct from an empty one. `custom-themes.js` serves validated custom-theme candidates from `/api/pi/themes` with per-file partial-failure isolation. `model-config-store.js` atomically updates Pi's credential-blind `models.json`; literal keys continue through Pi auth and headers are write-only. `providers.config.get` returns `config: null` for a provider that is not in `models.json` (built-in catalog entries) and fails only when that file is present but malformed.
26
+ - `../routes.js` registers authenticated public adapters before the generic proxy. It exposes only whitelisted runtime, project, session, provider-auth/configuration, settings, resource, small-model utility, and SSE event shapes; no browser response contains daemon paths, credentials, PIDs, headers, or socket framing. Session actions are path-selected, so an identity supplied in a request body cannot redirect a mutation. `POST /api/pi/sessions` projects the created detail through the same session-detail projector as `GET /api/pi/sessions/:id`, so extension items appended from `session_start`, the `streamEpoch` stamp, and extension UI snapshot state are returned rather than rejected; only a malformed detail is `DAEMON_PROTOCOL_MISMATCH`. `archive-store.js` persists PiChamber-only opaque session archive metadata atomically beneath the PiChamber data root and never edits Pi JSONL. `settings-store.js` keeps PiChamber new-session defaults separate from Pi settings.json. `/api/pi/small-model/generate` reads that sidecar and runs a bounded in-memory no-tools Pi session, so utility generation creates no visible or persisted session and exposes no model or credential details. `GET /api/pi/settings` copies leftover UI/desktop `defaultModel` / small / walkthrough strings into that sidecar when those sidecar fields are unset, then Sessions settings is the only editor. Sidecar `defaultThinkingByModel` is the per-model thinking map (`provider/model` keys). A stored global `defaultThinking` with a default model is copied onto that map key and dropped; global thinking without a default model remains a clamp-only fallback. `ui-settings-store.js` owns portable PiChamber preferences at data-root `settings.json` and host, device, and secret-bearing values at `runtime-state.json`. `/api/pi/ui-settings` merges both views for existing clients and splits writes through explicit field allowlists. It migrates an unscoped flat file once; after the portable scope marker exists, local fields found in `settings.json` are ignored rather than applied to the host. The route is not available through removed `/api/config/*` aliases. `session-folders-store.js` validates and atomically persists the restored sidebar's folder snapshot at `/api/pi/session-folders`; a missing snapshot is distinct from an empty one. `custom-themes.js` serves validated custom-theme candidates from `/api/pi/themes` with per-file partial-failure isolation. `model-config-store.js` atomically updates Pi's credential-blind `models.json`; literal keys continue through Pi auth and headers are write-only. `providers.config.get` returns `config: null` for a provider that is not in `models.json` (built-in catalog entries) and fails only when that file is present but malformed.
25
27
  - `../event-stream.js` owns the `/api/pi/events` SSE connection lifecycle so `../routes.js` stays a thin adapter. Per connection it installs cleanup before `subscribe` is awaited (a client that leaves during the opening window cannot leak a daemon subscription; a late subscription is closed exactly once), funnels client disconnect, subscription error, and server shutdown through one idempotent cleanup, hands an `AbortSignal` through the supervisor to the private IPC subscriber, never writes a named heartbeat or a late frame to a dead response, and byte-bounds the response socket buffer (`res.writableLength`, default 8 MiB, aligned with the daemon replay budget) with the bound enforced BEFORE each write so no single frame overshoots it. A client that stops reading is disconnected recoverably — the stream ends and the client reconnects from its last accepted sequence for replay or an authoritative snapshot, so no event is silently removed from an otherwise contiguous stream, but frames still buffered when the disconnect fires are not promised as delivered; the reconnect replay is the delivery guarantee — while a healthy client's connection stays independent of the slow one. Every teardown is bounded: a `write()` that returns false starts a drain deadline (default 5s) that ends even a quiet never-draining client, and after `res.end()` a terminate deadline (default 5s) destroys the response, because `end()` alone only queues the FIN behind unflushed data and would otherwise leave a stalled socket open forever and hang server shutdown/close. The response `'error'` guard stays attached for the response's lifetime (idempotent; cleanup can complete while data is still in flight and a late unhandled `'error'` would crash the process). The registry tracks live connections so `registerPiRuntimeRoutes` can expose `closeEventStreams()` for server shutdown, ending active and still-opening streams (and their daemon subscriptions) before the HTTP server closes. The IPC subscriber removes its abort listener and destroys the opening or active daemon socket on cancellation.
26
28
  - `*.test.js` uses temporary cwd, agent, data, and runtime directories; it never loads a developer's Pi home, credentials, or sessions. On Windows the private endpoint is a named pipe, not a `.sock` file, and POSIX mode-bit assertions are skipped.
27
29
 
@@ -36,7 +38,7 @@ This module is the Pi-owned session-daemon foundation. A detached local daemon p
36
38
  - The public health route deliberately whitelists its response fields (state, protocol version, capability names, and the opaque public `streamEpoch`). It never returns a daemon endpoint, credential, PID, cwd, agent directory, or transcript data. Public transcript and event projections preserve daemon-redacted assistant error messages so the UI can distinguish provider/runtime failures instead of reducing every failure to `ASSISTANT_ERROR`.
37
39
  - A client must send an `authenticate` frame carrying the host-private daemon credential before it can issue a request. Credentials are never logged or returned.
38
40
  - Frames are LF-delimited JSON. One frame has a 16 MiB maximum. Complete frames are parsed before the client bounds the remaining incomplete frame. Invalid JSON reports `MALFORMED_DAEMON_RESPONSE`; an oversized response reports `DAEMON_RESPONSE_TOO_LARGE`. A malformed, oversized, unauthenticated, or invalid request closes the connection.
39
- - The private core commands are `runtime.health`, `projects.list/select`, `providers.list/config.get/models.set/models.add/status/login/login.respond/login.status/logout`, `settings.get/set`, `resources.list/update/prompts.create/prompts.update/prompts.delete`, `extensions.list/respond`, and session list/create/open/messages/rename/delete/tree/navigate/fork/clone/prompt/steer/followUp/sendReceipt/abort/model/thinking/compact operations. Resource lists use opaque IDs and never disclose server paths. Only top-level Pi prompt templates and applicable AGENTS.md sources are editable; package/path resources and skills are browse-only. Prompt-template mutations resolve against the caller's explicit effective directory, reject stale and cross-directory opaque IDs, enforce project trust for project prompts, serialize create/update/delete operations, preserve existing files on validation or write failure, atomically reserve new destinations without overwriting concurrent writers, use temporary-file persistence with cleanup, preserve unknown frontmatter fields (for example `argument-hint`) when editing description or content, and for rename validate the destination name and scope, reject collisions, write the destination atomically, remove the source only after success, and roll back the destination when source removal fails. A committed prompt mutation never disposes a session runtime: affected idle sessions use Pi's identity-preserving `session.reload()`, while streaming, compacting, and extension-command sessions finish first and reload at their next safe lifecycle edge. Global prompts refresh every resident runtime; project prompts refresh only runtimes in that directory. Mutation responses merge freshly discovered editable prompts from transient per-mutation services (never retained; Pi 0.84.1 exposes no dispose on AgentSessionServices/ModelRuntime/ResourceLoader/SettingsManager — file reads plus a cleared create-time timeout, no watchers/intervals/listeners, so dropping the reference lets GC reclaim it) with live package/path/extension resources so the Settings page reflects the committed file even while runtime activation is deferred. `providers.refresh` touches only live runtimes; the returned catalog always comes from the active runtime via `providers.list`. Generic non-prompt resource writes share the serialized resource-mutation queue and commit through an atomic replace even while a session is active. The daemon returns `deferred: true` and recreates resident runtimes after they become idle; a new session reads the committed file immediately. If immediate recreation fails after a committed write, the response still reports deferred activation and the daemon keeps the recreation queued for a later safe edge. Project trust changes are persisted in Pi trust.json and use the same deferred runtime recreation; project-local extensions load through Pi's own trust flow once trust is resolved. Provider login submits API keys only across authenticated private IPC or brokers Pi's OAuth/device/manual-code interaction; public projections contain only opaque login IDs, prompts, URLs/device codes, model catalog/configuration, and stable states, never credentials or write-only headers. `providers.models.set` atomically persists Pi's `models.json`; a busy runtime returns `deferred: true` and is rehydrated after all active sessions are idle, while a new session sees the catalog immediately. `providers.models.add` appends one model (`id` required; optional `name`, `reasoning`, `thinkingLevelMap`, `input`, `contextWindow`, and `maxTokens`) atomically without replacing the provider. The model configuration store owns normalization and validation. The daemon rejects duplicate or unavailable live models, seeds a missing file provider only from authoritative live metadata when safely representable, rejects extension registrations with an explicit `models` array, and uses the same deferred recreation as `providers.models.set`. A successful recreation publishes a provider-catalog invalidation so connected settings views load the new authoritative catalog. Provider edits preserve unexposed existing model metadata server-side while public projections remain credential-blind. `providers.list` projects only catalog and authentication-status metadata, including Pi-supported `thinkingLevels` (`null` map entries hidden, `xhigh`/`max` opt-in). Session thinking overrides are clamped to the live model's supported levels. `sessions.list` checks each cwd JSONL header (not the full transcript) so a project with large session logs cannot spend tens of seconds on startup. SDK `SessionManager.list` is not used for that path; `listPiSessionJsonlDirectory` reads a header, a bounded prefix for the first user prompt, and a tail for the latest rename. Concurrent lists of the same directory share one in-flight result. Concurrent `sessions.open` of the same id share one in-flight runtime create; a duplicate that finishes later disposes itself and returns the registered runtime instead of `SESSION_RUNTIME_CONFLICT`. Full-file JSONL validation stays on open of a chosen session. The browser explicitly selects an existing user-chosen project directory before listing it; the daemon's startup cwd is an internal fallback, not a user-visible default project. Unnamed persisted sessions use their first prompt as a readable list title when available. `sessions.open` and `getSession` project the last assistant `provider`/`model`/`thinkingLevel` onto the session record so reopening a chat keeps that cache identity. `sessions.open`, navigate, fork, and clone return a tail page bounded by both projected-message count and serialized bytes. `sessions.messages` reads older pages with an opaque before-cursor. A page that starts inside a tool loop repeats the owning user message as a grouping anchor; browser merging deduplicates that overlap. Persisted tool results are indexed across the active branch before paging, so a paged assistant tool call still receives its matching final result. Session selection validates a persisted JSONL path before Pi opens it; inactive mutations are never directed by a browser-supplied path. `sessions.open` first checks a caller-supplied directory through its bounded header list, so an ordinary project-scoped open neither walks every directory in the agent store nor adopts a same-id session from another directory. Directory-less deep links resolve by Pi's `timestamp_<id>.jsonl` filename before broader SDK-list and header-scan fallbacks. Directory-wide JSONL checks on list/create/startup are header-only; full-file validation stays on open of a chosen transcript. Attachment paths originate in the server-local upload map and cross only private IPC into Pi's tool context. Pi may persist or echo those paths in its authoritative JSONL transcript, so every public projection redacts them recursively: session titles/previews, user and assistant text/thinking, tool arguments, errors, snapshots, and live message events never expose the server-local path. Persisted projection first checks for the attachment marker, then redacts matching tokens with a delimiter scan whose work stays linear for large encoded strings and tool payloads. The daemon maps Pi message lifecycle, deltas, tools, queue changes, model/thinking, compaction, interruption state, and session title updates (`session.updated` on create-with-title, first-prompt auto-title, and rename) to canonical events. Session deletion publishes an explicit `session.deleted` event; archive and directory moves keep the id and never publish it. Pi `model_select`, `thinking_level_changed`, and `session_info_changed` events are authoritative for model, thinking, and session-name changes made by extensions, the TUI, or another client. The bridge observes Pi provider registration and label writes because Pi 0.84.1 emits no corresponding session events: provider mutations publish a catalog invalidation, and label mutations invalidate the bounded session-tree projection. `ctx.reload()` clears old extension UI state, reloads Pi resources, and invalidates provider/resource/command catalogs. `ctx.shutdown()` disposes only the requesting idle session runtime after its command or turn settles; it never stops the shared daemon or unrelated sessions. Compaction events preserve Pi's manual/threshold/overflow reason, active/retrying/terminal phase, retry timing, redacted failure, compact-and-retry intent, and pre/post token estimates. The latest state is included in `getSession` and reconnect snapshots; after daemon restart, the latest persisted Pi `CompactionEntry` restores completed feedback without treating history as live work. Tool events carry redacted input arguments, cumulative partial-output snapshots, final output, error text, renderer metadata (edit diffs, truncation notes), and server start/end timestamps plus a `serverNow` sample so clients with different clocks can normalize elapsed time. Active and recently completed tool parts retain their start timestamps in the daemon's bounded in-memory timing cache, so `getSession` hydration keeps timers consistent across clients and browser reloads until the daemon restarts. Pi loads skills with the ordinary `read` tool. The daemon matches those read paths against the active runtime's authoritative `resourceLoader.getSkills()` catalog and adds path-free `metadata.pichamber.skill.name` for live events, hydrated history, and reconnect snapshots. PiChamber uses that metadata for its compact Skill row and Settings navigation; an arbitrary file named `SKILL.md` remains a normal read. Persisted `toolResult` entries merge into their assistant `toolCall` parts as output/error/end time so hydrated sessions render complete tool cards; tool-result entries never surface as standalone messages. Assistant message projections and start events carry the owning user-message id so the restored turn renderer can group and display replies; all assistant entries in a tool loop and every retry/compaction continuation remain attached to the latest user turn until `agent_settled` closes the run. Assistant message projections also pass through Pi's per-turn `Usage` (input, output, cacheRead, cacheWrite, totalTokens, and the same five numeric cost fields). The daemon sanitizes the raw payload through `projectUsage` before publication: every numeric must be finite and non-negative, the whole object is omitted when any field is missing or wrong type, and unknown keys are never copied. The `assistant.message.end` event carries the same sanitized usage so the last turn updates without waiting for a full `getSession` refetch. The public route whitelist re-applies the same sanitizer on each projection so a stale or malformed payload from a different daemon version cannot surface as `NaN` or `Infinity` in the reducer.- Live `message_start` events use daemon-generated browser message IDs because Pi has not appended the corresponding session entry yet. Pi agent-core emits streaming assistant starts as shallow copies, not as the finalized object it later persists. At `message_end`, `message-entry-aliases.js` therefore rebinds the synthetic ID to the finalized event object, then maps that object by identity to Pi's appended entry in a microtask. `sessions.navigate` and `sessions.fork` resolve the mapping after stripping any part suffix. Alias keys include cwd and session ID, survive idle runtime disposal of persisted sessions, and clear on explicit session deletion, confirmed ephemeral expiration (which publishes `session.deleted`), or daemon shutdown. Hydrated message projections continue to use the Pi entry ID directly.
41
+ - The private core commands are `runtime.health`, `projects.list/select`, `providers.list/config.get/models.set/models.add/status/login/login.respond/login.status/logout`, `settings.get/set`, `resources.list/update/prompts.create/prompts.update/prompts.delete`, `extensions.list/respond`, and session list/create/open/messages/rename/delete/tree/navigate/fork/clone/prompt/steer/followUp/sendReceipt/abort/model/thinking/compact operations. Resource lists use opaque IDs and never disclose server paths. Only top-level Pi prompt templates and applicable AGENTS.md sources are editable; package/path resources and skills are browse-only. Prompt-template mutations resolve against the caller's explicit effective directory, reject stale and cross-directory opaque IDs, enforce project trust for project prompts, serialize create/update/delete operations, preserve existing files on validation or write failure, atomically reserve new destinations without overwriting concurrent writers, use temporary-file persistence with cleanup, preserve unknown frontmatter fields (for example `argument-hint`) when editing description or content, and for rename validate the destination name and scope, reject collisions, write the destination atomically, remove the source only after success, and roll back the destination when source removal fails. A committed prompt mutation never disposes a session runtime: affected idle sessions use Pi's identity-preserving `session.reload()`, while streaming, compacting, and extension-command sessions finish first and reload at their next safe lifecycle edge. Global prompts refresh every resident runtime; project prompts refresh only runtimes in that directory. Mutation responses merge freshly discovered editable prompts from transient per-mutation services (never retained; Pi 0.84.1 exposes no dispose on AgentSessionServices/ModelRuntime/ResourceLoader/SettingsManager — file reads plus a cleared create-time timeout, no watchers/intervals/listeners, so dropping the reference lets GC reclaim it) with live package/path/extension resources so the Settings page reflects the committed file even while runtime activation is deferred. `providers.refresh` touches only live runtimes; the returned catalog always comes from the active runtime via `providers.list`. Generic non-prompt resource writes share the serialized resource-mutation queue and commit through an atomic replace even while a session is active. The daemon returns `deferred: true` and recreates resident runtimes after they become idle; a new session reads the committed file immediately. If immediate recreation fails after a committed write, the response still reports deferred activation and the daemon keeps the recreation queued for a later safe edge. Project trust changes are persisted in Pi trust.json and use the same deferred runtime recreation; project-local extensions load through Pi's own trust flow once trust is resolved. Provider login submits API keys only across authenticated private IPC or brokers Pi's OAuth/device/manual-code interaction; public projections contain only opaque login IDs, prompts, URLs/device codes, model catalog/configuration, and stable states, never credentials or write-only headers. `providers.models.set` atomically persists Pi's `models.json`; a busy runtime returns `deferred: true` and is rehydrated after all active sessions are idle, while a new session sees the catalog immediately. `providers.models.add` appends one model (`id` required; optional `name`, `reasoning`, `thinkingLevelMap`, `input`, `contextWindow`, and `maxTokens`) atomically without replacing the provider. The model configuration store owns normalization and validation. The daemon rejects duplicate or unavailable live models, seeds a missing file provider only from authoritative live metadata when safely representable, rejects extension registrations with an explicit `models` array, and uses the same deferred recreation as `providers.models.set`. A successful recreation publishes a provider-catalog invalidation so connected settings views load the new authoritative catalog. Provider edits preserve unexposed existing model metadata server-side while public projections remain credential-blind. `providers.list` projects only catalog and authentication-status metadata, including Pi-supported `thinkingLevels` (`null` map entries hidden, `xhigh`/`max` opt-in). Session thinking overrides are clamped to the live model's supported levels. `sessions.list` checks each cwd JSONL header (not the full transcript) so a project with large session logs cannot spend tens of seconds on startup. SDK `SessionManager.list` is not used for that path; `listPiSessionJsonlDirectory` reads a header, a bounded prefix for the first user prompt, and a tail for the latest rename. Each listed row whose runtime is resident in this daemon (including unpersisted resident sessions) carries `live: { lifecycle, sequence, retry?, runStartedAt?, serverNow }`, sampled synchronously with the current event `sequence` from the same retry/streaming/run-start state as snapshots; rows without a resident runtime carry no `live`, which clients treat as unknown rather than idle. Concurrent lists of the same directory share one in-flight result. Concurrent `sessions.open` of the same id share one in-flight runtime create; a duplicate that finishes later disposes itself and returns the registered runtime instead of `SESSION_RUNTIME_CONFLICT`. Full-file JSONL validation stays on open of a chosen session. The browser explicitly selects an existing user-chosen project directory before listing it; the daemon's startup cwd is an internal fallback, not a user-visible default project. Unnamed persisted sessions use their first prompt as a readable list title when available. `sessions.open` and `getSession` project the last assistant `provider`/`model`/`thinkingLevel` onto the session record so reopening a chat keeps that cache identity. `sessions.open`, navigate, fork, and clone return a tail page bounded by both projected-message count and serialized bytes. `sessions.messages` reads older pages with an opaque before-cursor. A page that starts inside a tool loop repeats the owning user message as a grouping anchor; browser merging deduplicates that overlap. Persisted tool results are indexed across the active branch before paging, so a paged assistant tool call still receives its matching final result. Session selection validates a persisted JSONL path before Pi opens it; inactive mutations are never directed by a browser-supplied path. `sessions.open` first checks a caller-supplied directory through its bounded header list, so an ordinary project-scoped open neither walks every directory in the agent store nor adopts a same-id session from another directory. Directory-less deep links resolve by Pi's `timestamp_<id>.jsonl` filename before broader SDK-list and header-scan fallbacks. Directory-wide JSONL checks on list/create/startup are header-only; full-file validation stays on open of a chosen transcript. Attachment paths originate in the server-local upload map and cross only private IPC into Pi's tool context. Pi may persist or echo those paths in its authoritative JSONL transcript, so every public projection redacts them recursively: session titles/previews, user and assistant text/thinking, tool arguments, errors, snapshots, and live message events never expose the server-local path. Persisted projection first checks for the attachment marker, then redacts matching tokens with a delimiter scan whose work stays linear for large encoded strings and tool payloads. The daemon maps Pi message lifecycle, deltas, tools, queue changes, model/thinking, compaction, interruption state, and session title updates (`session.updated` on create-with-title, first-prompt auto-title, and rename) to canonical events. Session deletion publishes an explicit `session.deleted` event; archive and directory moves keep the id and never publish it. Pi `model_select`, `thinking_level_changed`, and `session_info_changed` events are authoritative for model, thinking, and session-name changes made by extensions, the TUI, or another client. The bridge observes Pi provider registration and label writes because Pi 0.84.1 emits no corresponding session events: provider mutations publish a catalog invalidation, and label mutations invalidate the bounded session-tree projection. `ctx.reload()` clears old extension UI state, reloads Pi resources, and invalidates provider/resource/command catalogs. `ctx.shutdown()` disposes only the requesting idle session runtime after its command or turn settles; it never stops the shared daemon or unrelated sessions. Compaction events preserve Pi's manual/threshold/overflow reason, active/retrying/terminal phase, retry timing, redacted failure, compact-and-retry intent, and pre/post token estimates. The latest state is included in `getSession` and reconnect snapshots; after daemon restart, the latest persisted Pi `CompactionEntry` restores completed feedback without treating history as live work. Tool events carry redacted input arguments, cumulative partial-output snapshots, final output, error text, renderer metadata (edit diffs, truncation notes), and server start/end timestamps plus a `serverNow` sample so clients with different clocks can normalize elapsed time. Active and recently completed tool parts retain their start timestamps in the daemon's bounded in-memory timing cache, so `getSession` hydration keeps timers consistent across clients and browser reloads until the daemon restarts. Pi loads skills with the ordinary `read` tool. The daemon matches those read paths against the active runtime's authoritative `resourceLoader.getSkills()` catalog and adds path-free `metadata.pichamber.skill.name` for live events, hydrated history, and reconnect snapshots. PiChamber uses that metadata for its compact Skill row and Settings navigation; an arbitrary file named `SKILL.md` remains a normal read. Persisted `toolResult` entries merge into their assistant `toolCall` parts as output/error/end time so hydrated sessions render complete tool cards; tool-result entries never surface as standalone messages. Assistant message projections and start events carry the owning user-message id so the restored turn renderer can group and display replies; all assistant entries in a tool loop and every retry/compaction continuation remain attached to the latest user turn until `agent_settled` closes the run. Assistant message projections also pass through Pi's per-turn `Usage` (input, output, cacheRead, cacheWrite, totalTokens, and the same five numeric cost fields). The daemon sanitizes the raw payload through `projectUsage` before publication: every numeric must be finite and non-negative, the whole object is omitted when any field is missing or wrong type, and unknown keys are never copied. The `assistant.message.end` event carries the same sanitized usage so the last turn updates without waiting for a full `getSession` refetch. The public route whitelist re-applies the same sanitizer on each projection so a stale or malformed payload from a different daemon version cannot surface as `NaN` or `Infinity` in the reducer.- Live `message_start` events use daemon-generated browser message IDs because Pi has not appended the corresponding session entry yet. Pi agent-core emits streaming assistant starts as shallow copies, not as the finalized object it later persists. At `message_end`, `message-entry-aliases.js` therefore rebinds the synthetic ID to the finalized event object, then maps that object by identity to Pi's appended entry in a microtask. `sessions.navigate` and `sessions.fork` resolve the mapping after stripping any part suffix. Alias keys include cwd and session ID, survive idle runtime disposal of persisted sessions, and clear on explicit session deletion, confirmed ephemeral expiration (which publishes `session.deleted`), or daemon shutdown. Hydrated message projections continue to use the Pi entry ID directly.
40
42
  - Each event and reconnect snapshot has a monotonic sequence. Replay is capability-negotiated: the subscriber stamps its cursor with the `streamEpoch` it was established under, a marker-less cursor fails as `DAEMON_PROTOCOL_MISMATCH`, and a cursor from a retired epoch resyncs from a snapshot instead of replaying — even when this daemon's sequence numerically overtook the old cursor, replaying from it would silently skip the head of the new space. Every event, snapshot, and health result carries an opaque random `streamEpoch` regenerated on every daemon process start (never derived from daemon id, profile key, pid, or any private identity); `runtime.health` advertises the `events.streamEpoch` capability, session reads stamp it so clients can reject stale-epoch responses, and a snapshot published because the cursor could not be replayed is additionally stamped `resync: true` as a recovery baseline. A reconnect replays the retained contiguous suffix after its cursor when available, otherwise it receives an authoritative `session.snapshot`; unavailable runtimes are not represented as empty sessions. The suffix lives in `session-replay.js` and is bounded by both count (1,024 events) and encoded wire bytes (8 MiB): eviction removes whole oldest events first and never truncates content, each event is serialized once and the cached line is reused for live broadcast and replay, and live delivery stays full-fidelity even for events too large to retain. The byte budget counts encoded wire bytes, not heap, and snapshots assign sequence numbers without replay insertion so numeric gaps from private snapshots are intentional. A single oversized event clears the retained suffix without being retained, an empty ring never replays, and a cursor beyond the latest sequence resynchronizes from a snapshot; contiguity is judged on the global suffix while delivery stays session-filtered, so a filtered client never replays through a gap. A missed suffix recovers through `session.snapshot` plus `sessions.open` hydrate, which re-reads persisted entries for tool finals and lifecycle.
41
43
  - Prompt, steer, and follow-up requests acknowledge acceptance only after the Pi SDK preflight signal (session.prompt with preflightResult(true)); the daemon owns the still-running turn promise and publishes any asynchronous rejection as `session.error`. A preflight rejection (preflightResult(false)) propagates as the request rejection so dedup never caches it as accepted and the operation id stays reusable. Plain text uses prompt() with expandPromptTemplates:false and source:extension plus images; slash input keeps source:rpc. Pi can emit the live user-message start before that message is branch-readable, so the daemon queues each accepted prompt's path-free file metadata per delivery kind (`prompt`/`steer`/`followUp`) and adds it to the matching user start. SDK `queue_update` shrink is the authoritative owner of the next user start (steering drains before followUp regardless of send order); direct starts emit no shrink and fall back to oldest-by-generation. Requested `steer`/`followUp` always travels as SDK `streamingBehavior` (ignored while idle) so an idle arrival that races another sender still queues. Retention is decided at resolution from authoritative runtime state (`isStreaming` or SDK queue non-empty, never for handled extension commands); only queued resolutions keep metadata until their per-delivery start, all other completions clean a still-pending entry (an extension command that never emits a user start). The browser can render the attachment footer immediately without exposing bytes or server paths, while later hydration remains authoritative. An extension command may resolve without starting an agent turn, so completion of its non-streaming prompt promise publishes the idle lifecycle boundary that Pi does not emit as `agent_settled`. Pi notifies extensions of model switches (`model_select`) but not session subscribers, so that same completion edge also reconciles a changed live model into `session.model` before the idle boundary; thinking already emits `thinking_level_changed` to subscribers and needs no reconciliation. A registered extension invocation is not used for automatic first-prompt naming: an extension-only empty session remains unnamed unless the extension names it, and the first later conversation prompt supplies the derived title. Classification uses the active Pi runtime's registered extension commands, not a browser claim. Manual compact requests likewise acknowledge startup instead of holding the public/private request open for the summarization call; the daemon-owned promise reports its outcome through `session.compaction`. A second compact request while Pi is compacting fails as `SESSION_BUSY`, and optional `/compact` instructions pass to `AgentSession.compact(customInstructions)`. A later prompt on the same session invalidates an older send rejection so it cannot error the new turn. If the rejected send left Pi streaming, the daemon aborts it. Steer/follow-up against an idle session starts a new prompt instead of `SESSION_NOT_RUNNING`. Agent and compaction completion are never held behind the 30-second public/private request budgets. Pi retryable provider failures remain live: an `agent_end` with `willRetry` does not publish terminal `session.error`, and `auto_retry_start` projects Pi's attempt, next-attempt time, and redacted error text through `session.lifecycle: retry`. Retry metadata is retained in reconnect and `getSession` snapshots until the next `agent_start` begins the attempt. `agent_settled` remains the authoritative idle boundary after retry success, exhaustion, or cancellation and clears the run's user/assistant ownership.
42
44
  - Send-intent deduplication (`send-operation-registry.js`) owns the authoritative execution boundary for prompt/steer/followUp: the client labels each intent with a stable `operationId` and the health-verified `streamEpoch`, the daemon claims `kind + sessionId + operationId + streamEpoch` BEFORE Pi activation, and an identical same-epoch retry returns the original acceptance receipt (`{ accepted, messageId, deduplicated: true }`) without invoking Pi again. A concurrent duplicate of a still-pending intent shares the original outcome; the same full key with a different payload (text, model, thinking, message id, or attachments) fails as `OPERATION_PAYLOAD_MISMATCH` (HTTP 409). An intent from another daemon lifetime fails as `STALE_STREAM_EPOCH` (HTTP 409) before Pi or attachment-consumption side effects. The same id on a different kind or session is a different intent and executes independently, never a mismatch. Only acceptances are retained: request-path rejections happen before Pi runs (nothing executed, id reusable) while pending duplicates still share the original rejection, and every claim settles so pending duplicates never hang. Retention is bounded: receipts expire after `sendOperationTtlMs` (default ten minutes) and at most 1,024 accepted receipts are retained (oldest evicted to a bounded expired tombstone); pending claims are bounded separately (256 entries, never expired while active, new distinct pending past the bound fails as `SESSION_BUSY`). An expired or evicted id reports `expired` and a retry with the same id fails as `OPERATION_EXPIRED` (HTTP 410), never an automatic re-execution — callers must use a new operation id. `sessions.sendReceipt` is the exact read-only receipt lookup for an uncertain send: it requires the full `kind + sessionId + operationId + streamEpoch` identity; a missing epoch returns `unknown`, never invokes Pi, and returns `accepted` (retained receipt), `pending`, `expired` (seen but retention gone, outcome unknown, never assume success), or `unknown` (never seen in this retention window, tombstone pressure, post-restart, or rejected before Pi ran). The registry is in-memory per daemon process with bounded tombstones (`expired` degrades to `unknown` under pressure): there is no lifetime receipt guarantee, only within the retention window. A restart loses receipts, but the replacement daemon rejects the retired epoch instead of replaying the old intent. Receipt lookup and replay protection remain separate read-only contracts.
@@ -0,0 +1,222 @@
1
+ import { describe, expect, it } from 'vitest';
2
+
3
+ import { createExtensionBridge } from './extension-bridge.js';
4
+
5
+ // Direct bridge coverage for the getEditorText() draft mirror lifecycle edges
6
+ // that the socket-level daemon tests cannot reach (disposal, untracked reset).
7
+ const createBridge = (options = {}) => {
8
+ const published = [];
9
+ const bridge = createExtensionBridge({
10
+ publish: (event, payload, sessionId, directory) => published.push({ event, payload, sessionId, directory }),
11
+ resolveDirectory: async (directory) => directory,
12
+ redactAttachmentPaths: (value) => value,
13
+ redactAttachmentValues: (value) => value,
14
+ findRuntimeBySessionId: options.findRuntimeBySessionId || (() => undefined),
15
+ getDefaultDirectory: options.getDefaultDirectory || (() => '/repo'),
16
+ getSequence: () => 0,
17
+ protocolError: (code, message) => Object.assign(new Error(message), { code }),
18
+ requestSessionShutdown: () => {},
19
+ });
20
+ const session = options.session || { sessionId: 's1' };
21
+ const bindings = bridge.buildExtensionBindings(session);
22
+ const ui = bindings.uiContext;
23
+ return { bridge, ui, bindings, published, session };
24
+ };
25
+
26
+ const trackEvents = (published) => published.filter((entry) => entry.event === 'extension.editor.track');
27
+
28
+ describe('extension bridge draft mirror', () => {
29
+ it('disables browser sync when session extension state is cleared', () => {
30
+ const { bridge, ui, published } = createBridge();
31
+ ui.getEditorText();
32
+ expect(bridge.updateExtensionDraft('s1', 'typed', 1)).toEqual({ accepted: true });
33
+
34
+ bridge.clearExtensionState('s1');
35
+
36
+ expect(trackEvents(published).map((entry) => entry.payload)).toEqual([{ enabled: true }, { enabled: false }]);
37
+ expect(bridge.getSnapshotState('s1').draftTracked).toBeUndefined();
38
+ expect(bridge.updateExtensionDraft('s1', 'late', 2)).toEqual({ accepted: false });
39
+ expect(ui.getEditorText()).toBe('');
40
+ // A later call opts the session back in.
41
+ expect(trackEvents(published).at(-1).payload).toEqual({ enabled: true });
42
+ });
43
+
44
+ it('does not publish a disable event for sessions that never tracked', () => {
45
+ const { bridge, published } = createBridge();
46
+ bridge.clearExtensionState('s1');
47
+ expect(trackEvents(published)).toEqual([]);
48
+ });
49
+
50
+ it('prompt reset does not allocate draft state for untracked sessions', () => {
51
+ const { bridge, ui, published } = createBridge();
52
+ bridge.resetExtensionDraft('s1');
53
+ expect(ui.getEditorText()).toBe('');
54
+ expect(bridge.getSnapshotState('s1')).toEqual({ draftTracked: true });
55
+ expect(trackEvents(published)).toHaveLength(1);
56
+ });
57
+ });
58
+
59
+ describe('extension bridge session directory scoping', () => {
60
+ it('publishes session-scoped events stamped with the session runtime directory', () => {
61
+ const { ui, published } = createBridge({
62
+ findRuntimeBySessionId: (id) => (id === 's1' ? { cwd: '/dir-b' } : undefined),
63
+ getDefaultDirectory: () => '/default-dir',
64
+ });
65
+
66
+ ui.setStatus('status-key', 'Running');
67
+ expect(published.at(-1)).toEqual({
68
+ event: 'extension.status',
69
+ payload: { key: 'status-key', text: 'Running' },
70
+ sessionId: 's1',
71
+ directory: '/dir-b',
72
+ });
73
+
74
+ ui.notify('Test notification', 'warning');
75
+ expect(published.at(-1)).toEqual({
76
+ event: 'extension.notify',
77
+ payload: { message: 'Test notification', level: 'warning' },
78
+ sessionId: 's1',
79
+ directory: '/dir-b',
80
+ });
81
+
82
+ ui.setWorkingMessage('working...');
83
+ expect(published.at(-1)).toEqual({
84
+ event: 'extension.working',
85
+ payload: { message: 'working...' },
86
+ sessionId: 's1',
87
+ directory: '/dir-b',
88
+ });
89
+
90
+ ui.setWorkingVisible(true);
91
+ expect(published.at(-1)).toEqual({
92
+ event: 'extension.working',
93
+ payload: { message: 'working...', visible: true },
94
+ sessionId: 's1',
95
+ directory: '/dir-b',
96
+ });
97
+ });
98
+ });
99
+
100
+ describe('extension bridge setWidget', () => {
101
+ it('clears string widget on null and omits placement when clearing', () => {
102
+ const { bridge, ui, published } = createBridge();
103
+
104
+ ui.setWidget('w1', ['line 1'], { placement: 'belowEditor' });
105
+ expect(published.at(-1)).toEqual({
106
+ event: 'extension.widget',
107
+ payload: { key: 'w1', lines: ['line 1'], placement: 'belowEditor' },
108
+ sessionId: 's1',
109
+ directory: '/repo',
110
+ });
111
+ expect(bridge.getSnapshotState('s1').widgets).toEqual([
112
+ { key: 'w1', lines: ['line 1'], placement: 'belowEditor' },
113
+ ]);
114
+
115
+ // Clearing via null
116
+ ui.setWidget('w1', null, { placement: 'belowEditor' });
117
+ expect(published.at(-1)).toEqual({
118
+ event: 'extension.widget',
119
+ payload: { key: 'w1' },
120
+ sessionId: 's1',
121
+ directory: '/repo',
122
+ });
123
+ expect(bridge.getSnapshotState('s1').widgets).toBeUndefined();
124
+
125
+ // Re-set and clear via undefined
126
+ ui.setWidget('w1', ['line 2'], { placement: 'belowEditor' });
127
+ ui.setWidget('w1', undefined, { placement: 'belowEditor' });
128
+ expect(published.at(-1)).toEqual({
129
+ event: 'extension.widget',
130
+ payload: { key: 'w1' },
131
+ sessionId: 's1',
132
+ directory: '/repo',
133
+ });
134
+ expect(bridge.getSnapshotState('s1').widgets).toBeUndefined();
135
+ });
136
+ });
137
+
138
+ describe('extension bridge component widget disposal', () => {
139
+ it('returns early in scheduleComponentWidgetsRender after session extension state is cleared', async () => {
140
+ const { bridge, ui, published } = createBridge();
141
+ let capturedTui = null;
142
+ let renderCount = 0;
143
+
144
+ ui.setWidget('comp', (tui) => {
145
+ capturedTui = tui;
146
+ return {
147
+ render: () => {
148
+ renderCount += 1;
149
+ return [`render-${renderCount}`];
150
+ },
151
+ };
152
+ });
153
+
154
+ expect(renderCount).toBe(1);
155
+ const initialPublishCount = published.length;
156
+
157
+ // Clear session extension state
158
+ bridge.clearExtensionState('s1');
159
+
160
+ // Disposed component tries to request render
161
+ capturedTui.requestRender();
162
+
163
+ await new Promise((resolve) => setTimeout(resolve, 150));
164
+ expect(renderCount).toBe(1);
165
+ expect(published.filter((p) => p.event === 'extension.widget' && p.payload.lines)).toHaveLength(1);
166
+ expect(published.length).toBe(initialPublishCount + 1); // +1 from clearExtensionState's clearing widget event
167
+ });
168
+ });
169
+
170
+ describe('extension bridge reload and tree navigation panel rebuilding', () => {
171
+ it('rebuilds panels and apps from branch entries after reloadSession', async () => {
172
+ const entries = [
173
+ { type: 'custom', customType: 'pichamber.ui', data: { id: 'p1', title: 'Panel 1', component: 'test' } },
174
+ { type: 'custom', customType: 'pichamber.app', data: { appId: 'a1', title: 'App 1', html: '<div>App</div>' } },
175
+ ];
176
+ let reloaded = false;
177
+ const session = {
178
+ sessionId: 's1',
179
+ sessionManager: {
180
+ getBranch: () => entries,
181
+ },
182
+ reload: async () => {
183
+ reloaded = true;
184
+ },
185
+ };
186
+ const { bridge, bindings } = createBridge({ session });
187
+
188
+ await bindings.commandContextActions.reload();
189
+ expect(reloaded).toBe(true);
190
+
191
+ const snapshot = bridge.getSnapshotState('s1');
192
+ expect(snapshot.panels).toEqual([
193
+ { id: 'p1', title: 'Panel 1', component: 'test' },
194
+ ]);
195
+ expect(snapshot.apps).toEqual([
196
+ { appId: 'a1', title: 'App 1', html: '<div>App</div>' },
197
+ ]);
198
+ });
199
+
200
+ it('rebuilds panels and apps after successful navigateTree', async () => {
201
+ const entries = [
202
+ { type: 'custom', customType: 'pichamber.ui', data: { id: 'p2', title: 'Panel 2', component: 'test2' } },
203
+ ];
204
+ const session = {
205
+ sessionId: 's1',
206
+ sessionManager: {
207
+ getBranch: () => entries,
208
+ },
209
+ navigateTree: async () => ({ cancelled: false }),
210
+ };
211
+ const { bridge, bindings } = createBridge({ session });
212
+
213
+ const result = await bindings.commandContextActions.navigateTree('entry-target');
214
+ expect(result).toEqual({ cancelled: false });
215
+
216
+ const snapshot = bridge.getSnapshotState('s1');
217
+ expect(snapshot.panels).toEqual([
218
+ { id: 'p2', title: 'Panel 2', component: 'test2' },
219
+ ]);
220
+ });
221
+ });
222
+