@youweichen/pi-harness 0.0.0-stage → 1.1.0

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 (456) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +74 -2
  3. package/bin/pi-harness.mjs +1819 -0
  4. package/deploy/com.youweichen.pi-harness.plist +48 -0
  5. package/deploy/nginx-subpath.conf +88 -0
  6. package/deploy/pi-harness-task.xml +71 -0
  7. package/deploy/pi-harness.service +31 -0
  8. package/dist/server/agent-service.js +3131 -0
  9. package/dist/server/app-version.js +19 -0
  10. package/dist/server/attachments.js +526 -0
  11. package/dist/server/auth-file.js +61 -0
  12. package/dist/server/bg-servers.js +154 -0
  13. package/dist/server/client-eviction.js +19 -0
  14. package/dist/server/client-id.js +9 -0
  15. package/dist/server/client-state.js +202 -0
  16. package/dist/server/codemode-image-routes.js +36 -0
  17. package/dist/server/codemode-presentation.js +19 -0
  18. package/dist/server/component-updates.js +135 -0
  19. package/dist/server/context-breakdown.js +56 -0
  20. package/dist/server/control-socket.js +178 -0
  21. package/dist/server/conversation.js +65 -0
  22. package/dist/server/dir-browser.js +77 -0
  23. package/dist/server/editor-snapshot.js +38 -0
  24. package/dist/server/ensure-bash.js +80 -0
  25. package/dist/server/extension-display.js +23 -0
  26. package/dist/server/extensions-catalog.js +64 -0
  27. package/dist/server/extensions-model.js +46 -0
  28. package/dist/server/extensions-routes.js +255 -0
  29. package/dist/server/extensions-worker.js +188 -0
  30. package/dist/server/files-service.js +787 -0
  31. package/dist/server/index.js +1033 -0
  32. package/dist/server/markdown-images.js +42 -0
  33. package/dist/server/model-admin.js +801 -0
  34. package/dist/server/model-config-merge.js +32 -0
  35. package/dist/server/native-mcp-config.js +103 -0
  36. package/dist/server/native-mcp-presentation.js +12 -0
  37. package/dist/server/native-prompt-template.js +12 -0
  38. package/dist/server/native-tools.js +32 -0
  39. package/dist/server/node-agent.js +262 -0
  40. package/dist/server/node-sources.js +142 -0
  41. package/dist/server/node-workbench.js +729 -0
  42. package/dist/server/origin-policy.js +50 -0
  43. package/dist/server/patch-node-pty.js +96 -0
  44. package/dist/server/pi-environment.js +203 -0
  45. package/dist/server/plan/extension.js +74 -0
  46. package/dist/server/plan/progress.js +90 -0
  47. package/dist/server/plan/settings.js +41 -0
  48. package/dist/server/plan/state.js +123 -0
  49. package/dist/server/plugin-facilities.js +304 -0
  50. package/dist/server/plugin-updater.js +245 -0
  51. package/dist/server/plugins.js +712 -0
  52. package/dist/server/private-file.js +28 -0
  53. package/dist/server/process-utils.js +112 -0
  54. package/dist/server/prompt-delivery.js +80 -0
  55. package/dist/server/protocol-version.js +11 -0
  56. package/dist/server/protocol.js +6 -0
  57. package/dist/server/provider-auth.js +99 -0
  58. package/dist/server/query-cache.js +45 -0
  59. package/dist/server/recovery-state.js +37 -0
  60. package/dist/server/scm.js +459 -0
  61. package/dist/server/security-headers.js +24 -0
  62. package/dist/server/serialize.js +254 -0
  63. package/dist/server/session-file-read.js +225 -0
  64. package/dist/server/session-record-worker.js +21 -0
  65. package/dist/server/session-reload.js +13 -0
  66. package/dist/server/session-tree-controller.js +250 -0
  67. package/dist/server/session-tree.js +191 -0
  68. package/dist/server/settings-service.js +53 -0
  69. package/dist/server/skills-service.js +87 -0
  70. package/dist/server/slash-commands.js +286 -0
  71. package/dist/server/sqlite-preview.js +58 -0
  72. package/dist/server/sqlite-query.js +67 -0
  73. package/dist/server/sqlite-worker.js +12 -0
  74. package/dist/server/system-prompt-files.js +158 -0
  75. package/dist/server/system-prompt-routes.js +40 -0
  76. package/dist/server/system-prompt-view.js +49 -0
  77. package/dist/server/task-progress.js +233 -0
  78. package/dist/server/terminals.js +833 -0
  79. package/dist/server/text-sniff.js +269 -0
  80. package/dist/server/thinking-timing.js +91 -0
  81. package/dist/server/token-auth.js +37 -0
  82. package/dist/server/tool-output.js +97 -0
  83. package/dist/server/tool-text-incidents.js +82 -0
  84. package/dist/server/tool-text.js +67 -0
  85. package/dist/server/uploads.js +112 -0
  86. package/dist/server/user-attachments.js +96 -0
  87. package/dist/server/webui-context.js +257 -0
  88. package/dist/server/wiki-links.js +136 -0
  89. package/dist/server/wiki-pdf-worker.js +23 -0
  90. package/dist/server/wiki-pdf.js +36 -0
  91. package/dist/server/wiki-routes.js +184 -0
  92. package/dist/server/wiki-service.js +524 -0
  93. package/electron/main.mjs +607 -0
  94. package/extensions/webui.ts +192 -0
  95. package/package.json +122 -4
  96. package/web/dist/apple-touch-icon.png +0 -0
  97. package/web/dist/assets/NodeWorkbench-BiP2ktQP.js +3 -0
  98. package/web/dist/assets/TerminalPanel-CKaSUsN-.js +2 -0
  99. package/web/dist/assets/abnfDiagram-VCTEODGH-CnwRJDRL.js +1 -0
  100. package/web/dist/assets/arc-CG4Q7-W_.js +1 -0
  101. package/web/dist/assets/architectureDiagram-5GKGNRK7-BrGqX_Rg.js +36 -0
  102. package/web/dist/assets/blockDiagram-I7D4REHJ-C2t0PjZT.js +129 -0
  103. package/web/dist/assets/c4Diagram-7LVT6UL2-CadrcgGL.js +38 -0
  104. package/web/dist/assets/channel-C27Jizb6.js +1 -0
  105. package/web/dist/assets/chunk-2Q5K7J3B-CC3V2ITZ.js +1 -0
  106. package/web/dist/assets/chunk-5VM5RSS4-DqKSbGmE.js +15 -0
  107. package/web/dist/assets/chunk-F27PBJKO-_CDr3JbY.js +1 -0
  108. package/web/dist/assets/chunk-IMKFNOWR-BIR4H4fX.js +231 -0
  109. package/web/dist/assets/chunk-JWPE2WC7-CrsdBGXT.js +1 -0
  110. package/web/dist/assets/chunk-POPQ4Y6H-C6q9kQmf.js +1 -0
  111. package/web/dist/assets/chunk-SVP7TREG-l2XXTr2v.js +88 -0
  112. package/web/dist/assets/chunk-TICWLB2K-29I_mZgB.js +206 -0
  113. package/web/dist/assets/chunk-XXDRQBXY-htV9FBqi.js +1 -0
  114. package/web/dist/assets/classDiagram-ZZMXUADV-DYTBrAEP.js +1 -0
  115. package/web/dist/assets/classDiagram-v2-VYDZK3BY-DYTBrAEP.js +1 -0
  116. package/web/dist/assets/cose-bilkent-JH36ORCC-Cop-ihyx.js +1 -0
  117. package/web/dist/assets/cynefin-OW5HDTMX-IEk8qBRq.js +178 -0
  118. package/web/dist/assets/cynefinDiagram-5FMLGOSQ-Bmzt6Qb5.js +62 -0
  119. package/web/dist/assets/cytoscape.esm-Bch-eiPH.js +331 -0
  120. package/web/dist/assets/dagre-GXQ25YYZ-DiXTJYYU.js +4 -0
  121. package/web/dist/assets/defaultLocale-DX6XiGOO.js +1 -0
  122. package/web/dist/assets/diagram-S7CK7UJ4-BT7CLuNk.js +30 -0
  123. package/web/dist/assets/diagram-UQ7AKVKN-BZZ3nTCO.js +41 -0
  124. package/web/dist/assets/diagram-VSXAHHWV-Dal8LeZh.js +3 -0
  125. package/web/dist/assets/diagram-VX7I27RA-D6V9FfNA.js +24 -0
  126. package/web/dist/assets/diagram-Z3DM3KII-KUAIcFiD.js +24 -0
  127. package/web/dist/assets/ebnfDiagram-PWID7BFC-s0FEPZrV.js +1 -0
  128. package/web/dist/assets/erDiagram-RLTQ6QDP-CiIQPFCD.js +99 -0
  129. package/web/dist/assets/flowDiagram-HODETNUW-CvG4MYWn.js +168 -0
  130. package/web/dist/assets/ganttDiagram-EL5Y4UJY-CUf115ii.js +292 -0
  131. package/web/dist/assets/gitGraphDiagram-WWUBYQGX-o3K1r6fL.js +106 -0
  132. package/web/dist/assets/index-C3vDFSEV.css +10 -0
  133. package/web/dist/assets/index-C5or_GAq.js +276 -0
  134. package/web/dist/assets/infoDiagram-27XIBGKW-BxiBeQ8E.js +2 -0
  135. package/web/dist/assets/init-Gi6I4Gst.js +1 -0
  136. package/web/dist/assets/ishikawaDiagram-5VMMS53U-B1ONuCkH.js +70 -0
  137. package/web/dist/assets/journeyDiagram-3NMN7TZE-DwmuoXcX.js +139 -0
  138. package/web/dist/assets/kanban-definition-UXKFOSKX-pMKHubxH.js +89 -0
  139. package/web/dist/assets/katex-C5jXJg4s.js +257 -0
  140. package/web/dist/assets/layout-CEwfjQR0.js +1 -0
  141. package/web/dist/assets/linear-D22Gdbt1.js +1 -0
  142. package/web/dist/assets/markdown-BhJ_LInD.js +51 -0
  143. package/web/dist/assets/mermaid.core-CO2nrD04.js +312 -0
  144. package/web/dist/assets/mindmap-definition-YA3MSWOX-9MQn9ZAp.js +96 -0
  145. package/web/dist/assets/ordinal-Cboi1Yqb.js +1 -0
  146. package/web/dist/assets/pegDiagram-XKGWAZYB-Dy6fLjM-.js +1 -0
  147. package/web/dist/assets/pieDiagram-E7YTZNPT-EDLez6nA.js +39 -0
  148. package/web/dist/assets/quadrantDiagram-AXDQQJYC-Cgcd9mvy.js +7 -0
  149. package/web/dist/assets/railroadDiagram-O6MQD6OU-B4Td0tjj.js +1 -0
  150. package/web/dist/assets/react-BddUxV-9.js +24 -0
  151. package/web/dist/assets/requirementDiagram-BXWQKSXE-aF2QNZ78.js +84 -0
  152. package/web/dist/assets/sankeyDiagram-P5KCCOFB-DgTYwYMa.js +40 -0
  153. package/web/dist/assets/sequenceDiagram-WJ2MYXX4-EUcddWUc.js +162 -0
  154. package/web/dist/assets/sizeCapture-INFHLROL-CXHOv9Sx.js +1 -0
  155. package/web/dist/assets/stateDiagram-D77RDMKH-B-xlgfaK.js +1 -0
  156. package/web/dist/assets/stateDiagram-v2-MP3YSRHH-kwAwAlWX.js +1 -0
  157. package/web/dist/assets/swimlanes-42K2YHIH-BtFBOCDh.js +1 -0
  158. package/web/dist/assets/swimlanesDiagram-VR7AAH4N-D5j5Cj3S.js +8 -0
  159. package/web/dist/assets/timeline-definition-24CTP7MA-CZlQY6pb.js +120 -0
  160. package/web/dist/assets/vennDiagram-4TSXK5OY-Cn61dJvL.js +34 -0
  161. package/web/dist/assets/wardleyDiagram-VM6X3IG4-fiMNrWpr.js +78 -0
  162. package/web/dist/assets/xterm-6GBZ9nXN.css +32 -0
  163. package/web/dist/assets/xterm-D1D2FVe3.js +38 -0
  164. package/web/dist/assets/xychartDiagram-S5SC5T6Z-CuzM_sof.js +7 -0
  165. package/web/dist/brand-mark.svg +5 -0
  166. package/web/dist/favicon-32.png +0 -0
  167. package/web/dist/favicon.svg +5 -0
  168. package/web/dist/fonts/WIKI-FONTS.md +5 -0
  169. package/web/dist/fonts/ibm-plex-mono/ibm-plex-mono-latin-400-normal.woff2 +0 -0
  170. package/web/dist/fonts/ibm-plex-mono/ibm-plex-mono-latin-500-normal.woff2 +0 -0
  171. package/web/dist/fonts/ibm-plex-mono/ibm-plex-mono-latin-600-normal.woff2 +0 -0
  172. package/web/dist/fonts/ibm-plex-mono/ibm-plex-mono-latin-ext-400-normal.woff2 +0 -0
  173. package/web/dist/fonts/ibm-plex-mono/ibm-plex-mono-latin-ext-500-normal.woff2 +0 -0
  174. package/web/dist/fonts/ibm-plex-mono/ibm-plex-mono-latin-ext-600-normal.woff2 +0 -0
  175. package/web/dist/fonts/ibm-plex-sans/LICENSE +93 -0
  176. package/web/dist/fonts/ibm-plex-sans/ibm-plex-sans-latin-400-normal.woff2 +0 -0
  177. package/web/dist/fonts/ibm-plex-sans/ibm-plex-sans-latin-500-normal.woff2 +0 -0
  178. package/web/dist/fonts/ibm-plex-sans/ibm-plex-sans-latin-600-normal.woff2 +0 -0
  179. package/web/dist/fonts/ibm-plex-sans/ibm-plex-sans-latin-ext-400-normal.woff2 +0 -0
  180. package/web/dist/fonts/ibm-plex-sans/ibm-plex-sans-latin-ext-500-normal.woff2 +0 -0
  181. package/web/dist/fonts/ibm-plex-sans/ibm-plex-sans-latin-ext-600-normal.woff2 +0 -0
  182. package/web/dist/fonts/inter/inter-latin-400-normal.woff2 +0 -0
  183. package/web/dist/fonts/inter/inter-latin-500-normal.woff2 +0 -0
  184. package/web/dist/fonts/inter/inter-latin-600-normal.woff2 +0 -0
  185. package/web/dist/fonts/inter/inter-latin-700-normal.woff2 +0 -0
  186. package/web/dist/fonts/inter/inter-latin-800-normal.woff2 +0 -0
  187. package/web/dist/fonts/inter/inter-latin-ext-400-normal.woff2 +0 -0
  188. package/web/dist/fonts/inter/inter-latin-ext-500-normal.woff2 +0 -0
  189. package/web/dist/fonts/inter/inter-latin-ext-600-normal.woff2 +0 -0
  190. package/web/dist/fonts/inter/inter-latin-ext-700-normal.woff2 +0 -0
  191. package/web/dist/fonts/inter/inter-latin-ext-800-normal.woff2 +0 -0
  192. package/web/dist/fonts/jetbrains-mono/LICENSE +93 -0
  193. package/web/dist/fonts/jetbrains-mono/jetbrains-mono-latin-400-normal.woff2 +0 -0
  194. package/web/dist/fonts/jetbrains-mono/jetbrains-mono-latin-500-normal.woff2 +0 -0
  195. package/web/dist/fonts/jetbrains-mono/jetbrains-mono-latin-600-normal.woff2 +0 -0
  196. package/web/dist/fonts/jetbrains-mono/jetbrains-mono-latin-ext-400-normal.woff2 +0 -0
  197. package/web/dist/fonts/jetbrains-mono/jetbrains-mono-latin-ext-500-normal.woff2 +0 -0
  198. package/web/dist/fonts/jetbrains-mono/jetbrains-mono-latin-ext-600-normal.woff2 +0 -0
  199. package/web/dist/fonts/noto-serif-sc/LICENSE +94 -0
  200. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-0.woff2 +0 -0
  201. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-1.woff2 +0 -0
  202. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-10.woff2 +0 -0
  203. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-100.woff2 +0 -0
  204. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-11.woff2 +0 -0
  205. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-12.woff2 +0 -0
  206. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-13.woff2 +0 -0
  207. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-14.woff2 +0 -0
  208. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-15.woff2 +0 -0
  209. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-16.woff2 +0 -0
  210. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-17.woff2 +0 -0
  211. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-18.woff2 +0 -0
  212. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-19.woff2 +0 -0
  213. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-2.woff2 +0 -0
  214. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-20.woff2 +0 -0
  215. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-21.woff2 +0 -0
  216. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-22.woff2 +0 -0
  217. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-23.woff2 +0 -0
  218. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-24.woff2 +0 -0
  219. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-25.woff2 +0 -0
  220. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-26.woff2 +0 -0
  221. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-27.woff2 +0 -0
  222. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-28.woff2 +0 -0
  223. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-29.woff2 +0 -0
  224. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-3.woff2 +0 -0
  225. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-30.woff2 +0 -0
  226. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-31.woff2 +0 -0
  227. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-32.woff2 +0 -0
  228. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-33.woff2 +0 -0
  229. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-34.woff2 +0 -0
  230. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-35.woff2 +0 -0
  231. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-36.woff2 +0 -0
  232. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-37.woff2 +0 -0
  233. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-38.woff2 +0 -0
  234. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-39.woff2 +0 -0
  235. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-4.woff2 +0 -0
  236. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-40.woff2 +0 -0
  237. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-41.woff2 +0 -0
  238. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-42.woff2 +0 -0
  239. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-43.woff2 +0 -0
  240. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-44.woff2 +0 -0
  241. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-45.woff2 +0 -0
  242. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-46.woff2 +0 -0
  243. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-47.woff2 +0 -0
  244. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-48.woff2 +0 -0
  245. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-49.woff2 +0 -0
  246. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-5.woff2 +0 -0
  247. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-50.woff2 +0 -0
  248. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-51.woff2 +0 -0
  249. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-52.woff2 +0 -0
  250. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-53.woff2 +0 -0
  251. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-54.woff2 +0 -0
  252. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-55.woff2 +0 -0
  253. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-56.woff2 +0 -0
  254. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-57.woff2 +0 -0
  255. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-58.woff2 +0 -0
  256. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-59.woff2 +0 -0
  257. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-6.woff2 +0 -0
  258. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-60.woff2 +0 -0
  259. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-61.woff2 +0 -0
  260. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-62.woff2 +0 -0
  261. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-63.woff2 +0 -0
  262. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-64.woff2 +0 -0
  263. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-65.woff2 +0 -0
  264. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-66.woff2 +0 -0
  265. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-67.woff2 +0 -0
  266. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-68.woff2 +0 -0
  267. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-69.woff2 +0 -0
  268. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-7.woff2 +0 -0
  269. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-70.woff2 +0 -0
  270. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-71.woff2 +0 -0
  271. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-72.woff2 +0 -0
  272. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-73.woff2 +0 -0
  273. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-74.woff2 +0 -0
  274. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-75.woff2 +0 -0
  275. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-76.woff2 +0 -0
  276. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-77.woff2 +0 -0
  277. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-78.woff2 +0 -0
  278. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-79.woff2 +0 -0
  279. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-8.woff2 +0 -0
  280. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-80.woff2 +0 -0
  281. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-81.woff2 +0 -0
  282. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-82.woff2 +0 -0
  283. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-83.woff2 +0 -0
  284. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-84.woff2 +0 -0
  285. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-85.woff2 +0 -0
  286. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-86.woff2 +0 -0
  287. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-87.woff2 +0 -0
  288. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-88.woff2 +0 -0
  289. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-89.woff2 +0 -0
  290. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-9.woff2 +0 -0
  291. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-90.woff2 +0 -0
  292. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-91.woff2 +0 -0
  293. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-92.woff2 +0 -0
  294. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-93.woff2 +0 -0
  295. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-94.woff2 +0 -0
  296. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-95.woff2 +0 -0
  297. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-96.woff2 +0 -0
  298. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-97.woff2 +0 -0
  299. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-98.woff2 +0 -0
  300. package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-99.woff2 +0 -0
  301. package/web/dist/fonts/source-serif-4/LICENSE +93 -0
  302. package/web/dist/fonts/source-serif-4/source-serif-4-500-0.woff2 +0 -0
  303. package/web/dist/fonts/source-serif-4/source-serif-4-500-1.woff2 +0 -0
  304. package/web/dist/fonts/source-serif-4/source-serif-4-500-2.woff2 +0 -0
  305. package/web/dist/fonts/source-serif-4/source-serif-4-500-3.woff2 +0 -0
  306. package/web/dist/fonts/source-serif-4/source-serif-4-500-4.woff2 +0 -0
  307. package/web/dist/fonts/source-serif-4/source-serif-4-500-5.woff2 +0 -0
  308. package/web/dist/icon/1a-mark.svg +1 -0
  309. package/web/dist/icon.ico +0 -0
  310. package/web/dist/index.html +18 -0
  311. package/web/public/apple-touch-icon.png +0 -0
  312. package/web/public/brand-mark.svg +5 -0
  313. package/web/public/favicon-32.png +0 -0
  314. package/web/public/favicon.svg +5 -0
  315. package/web/public/fonts/WIKI-FONTS.md +5 -0
  316. package/web/public/fonts/ibm-plex-mono/ibm-plex-mono-latin-400-normal.woff2 +0 -0
  317. package/web/public/fonts/ibm-plex-mono/ibm-plex-mono-latin-500-normal.woff2 +0 -0
  318. package/web/public/fonts/ibm-plex-mono/ibm-plex-mono-latin-600-normal.woff2 +0 -0
  319. package/web/public/fonts/ibm-plex-mono/ibm-plex-mono-latin-ext-400-normal.woff2 +0 -0
  320. package/web/public/fonts/ibm-plex-mono/ibm-plex-mono-latin-ext-500-normal.woff2 +0 -0
  321. package/web/public/fonts/ibm-plex-mono/ibm-plex-mono-latin-ext-600-normal.woff2 +0 -0
  322. package/web/public/fonts/ibm-plex-sans/LICENSE +93 -0
  323. package/web/public/fonts/ibm-plex-sans/ibm-plex-sans-latin-400-normal.woff2 +0 -0
  324. package/web/public/fonts/ibm-plex-sans/ibm-plex-sans-latin-500-normal.woff2 +0 -0
  325. package/web/public/fonts/ibm-plex-sans/ibm-plex-sans-latin-600-normal.woff2 +0 -0
  326. package/web/public/fonts/ibm-plex-sans/ibm-plex-sans-latin-ext-400-normal.woff2 +0 -0
  327. package/web/public/fonts/ibm-plex-sans/ibm-plex-sans-latin-ext-500-normal.woff2 +0 -0
  328. package/web/public/fonts/ibm-plex-sans/ibm-plex-sans-latin-ext-600-normal.woff2 +0 -0
  329. package/web/public/fonts/inter/inter-latin-400-normal.woff2 +0 -0
  330. package/web/public/fonts/inter/inter-latin-500-normal.woff2 +0 -0
  331. package/web/public/fonts/inter/inter-latin-600-normal.woff2 +0 -0
  332. package/web/public/fonts/inter/inter-latin-700-normal.woff2 +0 -0
  333. package/web/public/fonts/inter/inter-latin-800-normal.woff2 +0 -0
  334. package/web/public/fonts/inter/inter-latin-ext-400-normal.woff2 +0 -0
  335. package/web/public/fonts/inter/inter-latin-ext-500-normal.woff2 +0 -0
  336. package/web/public/fonts/inter/inter-latin-ext-600-normal.woff2 +0 -0
  337. package/web/public/fonts/inter/inter-latin-ext-700-normal.woff2 +0 -0
  338. package/web/public/fonts/inter/inter-latin-ext-800-normal.woff2 +0 -0
  339. package/web/public/fonts/jetbrains-mono/LICENSE +93 -0
  340. package/web/public/fonts/jetbrains-mono/jetbrains-mono-latin-400-normal.woff2 +0 -0
  341. package/web/public/fonts/jetbrains-mono/jetbrains-mono-latin-500-normal.woff2 +0 -0
  342. package/web/public/fonts/jetbrains-mono/jetbrains-mono-latin-600-normal.woff2 +0 -0
  343. package/web/public/fonts/jetbrains-mono/jetbrains-mono-latin-ext-400-normal.woff2 +0 -0
  344. package/web/public/fonts/jetbrains-mono/jetbrains-mono-latin-ext-500-normal.woff2 +0 -0
  345. package/web/public/fonts/jetbrains-mono/jetbrains-mono-latin-ext-600-normal.woff2 +0 -0
  346. package/web/public/fonts/noto-serif-sc/LICENSE +94 -0
  347. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-0.woff2 +0 -0
  348. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-1.woff2 +0 -0
  349. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-10.woff2 +0 -0
  350. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-100.woff2 +0 -0
  351. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-11.woff2 +0 -0
  352. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-12.woff2 +0 -0
  353. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-13.woff2 +0 -0
  354. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-14.woff2 +0 -0
  355. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-15.woff2 +0 -0
  356. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-16.woff2 +0 -0
  357. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-17.woff2 +0 -0
  358. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-18.woff2 +0 -0
  359. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-19.woff2 +0 -0
  360. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-2.woff2 +0 -0
  361. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-20.woff2 +0 -0
  362. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-21.woff2 +0 -0
  363. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-22.woff2 +0 -0
  364. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-23.woff2 +0 -0
  365. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-24.woff2 +0 -0
  366. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-25.woff2 +0 -0
  367. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-26.woff2 +0 -0
  368. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-27.woff2 +0 -0
  369. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-28.woff2 +0 -0
  370. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-29.woff2 +0 -0
  371. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-3.woff2 +0 -0
  372. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-30.woff2 +0 -0
  373. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-31.woff2 +0 -0
  374. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-32.woff2 +0 -0
  375. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-33.woff2 +0 -0
  376. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-34.woff2 +0 -0
  377. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-35.woff2 +0 -0
  378. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-36.woff2 +0 -0
  379. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-37.woff2 +0 -0
  380. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-38.woff2 +0 -0
  381. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-39.woff2 +0 -0
  382. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-4.woff2 +0 -0
  383. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-40.woff2 +0 -0
  384. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-41.woff2 +0 -0
  385. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-42.woff2 +0 -0
  386. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-43.woff2 +0 -0
  387. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-44.woff2 +0 -0
  388. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-45.woff2 +0 -0
  389. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-46.woff2 +0 -0
  390. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-47.woff2 +0 -0
  391. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-48.woff2 +0 -0
  392. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-49.woff2 +0 -0
  393. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-5.woff2 +0 -0
  394. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-50.woff2 +0 -0
  395. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-51.woff2 +0 -0
  396. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-52.woff2 +0 -0
  397. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-53.woff2 +0 -0
  398. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-54.woff2 +0 -0
  399. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-55.woff2 +0 -0
  400. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-56.woff2 +0 -0
  401. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-57.woff2 +0 -0
  402. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-58.woff2 +0 -0
  403. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-59.woff2 +0 -0
  404. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-6.woff2 +0 -0
  405. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-60.woff2 +0 -0
  406. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-61.woff2 +0 -0
  407. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-62.woff2 +0 -0
  408. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-63.woff2 +0 -0
  409. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-64.woff2 +0 -0
  410. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-65.woff2 +0 -0
  411. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-66.woff2 +0 -0
  412. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-67.woff2 +0 -0
  413. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-68.woff2 +0 -0
  414. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-69.woff2 +0 -0
  415. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-7.woff2 +0 -0
  416. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-70.woff2 +0 -0
  417. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-71.woff2 +0 -0
  418. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-72.woff2 +0 -0
  419. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-73.woff2 +0 -0
  420. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-74.woff2 +0 -0
  421. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-75.woff2 +0 -0
  422. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-76.woff2 +0 -0
  423. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-77.woff2 +0 -0
  424. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-78.woff2 +0 -0
  425. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-79.woff2 +0 -0
  426. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-8.woff2 +0 -0
  427. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-80.woff2 +0 -0
  428. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-81.woff2 +0 -0
  429. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-82.woff2 +0 -0
  430. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-83.woff2 +0 -0
  431. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-84.woff2 +0 -0
  432. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-85.woff2 +0 -0
  433. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-86.woff2 +0 -0
  434. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-87.woff2 +0 -0
  435. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-88.woff2 +0 -0
  436. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-89.woff2 +0 -0
  437. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-9.woff2 +0 -0
  438. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-90.woff2 +0 -0
  439. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-91.woff2 +0 -0
  440. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-92.woff2 +0 -0
  441. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-93.woff2 +0 -0
  442. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-94.woff2 +0 -0
  443. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-95.woff2 +0 -0
  444. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-96.woff2 +0 -0
  445. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-97.woff2 +0 -0
  446. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-98.woff2 +0 -0
  447. package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-99.woff2 +0 -0
  448. package/web/public/fonts/source-serif-4/LICENSE +93 -0
  449. package/web/public/fonts/source-serif-4/source-serif-4-500-0.woff2 +0 -0
  450. package/web/public/fonts/source-serif-4/source-serif-4-500-1.woff2 +0 -0
  451. package/web/public/fonts/source-serif-4/source-serif-4-500-2.woff2 +0 -0
  452. package/web/public/fonts/source-serif-4/source-serif-4-500-3.woff2 +0 -0
  453. package/web/public/fonts/source-serif-4/source-serif-4-500-4.woff2 +0 -0
  454. package/web/public/fonts/source-serif-4/source-serif-4-500-5.woff2 +0 -0
  455. package/web/public/icon/1a-mark.svg +1 -0
  456. package/web/public/icon.ico +0 -0
@@ -0,0 +1,255 @@
1
+ import { nativeSkills } from "./skills-service.js";
2
+ import { mkdirSync, readFileSync, writeFileSync, renameSync, statSync, realpathSync, existsSync } from "node:fs";
3
+ import { createHash } from "node:crypto";
4
+ import { killPidTree } from "./process-utils.js";
5
+ import { fork } from "node:child_process";
6
+ import { randomUUID } from "node:crypto";
7
+ import { join } from "node:path";
8
+ import { getAgentDir } from "@earendil-works/pi-coding-agent";
9
+ import { readJson, textField, resourceTypes, sourceInfo, validateSource } from "./extensions-model.js";
10
+ import { browseCatalog, cachedFetch, safeUrl, packageReleaseNotes } from "./extensions-catalog.js";
11
+ const jobs = new Map();
12
+ const tickets = new Map();
13
+ const states = new Map();
14
+ let mutation;
15
+ let readers = 0;
16
+ let canBackgroundRun = () => false;
17
+ const background = new Map();
18
+ function autoCheckEnabled(agentDir) { try {
19
+ return readJson(join(agentDir, "webui-extensions.json")).autoCheck !== false;
20
+ }
21
+ catch {
22
+ return false;
23
+ } }
24
+ const backgroundTimer = setInterval(() => {
25
+ if (mutation || readers || !canBackgroundRun())
26
+ return;
27
+ const entry = [...background].find(([, v]) => v.next <= Date.now());
28
+ if (!entry)
29
+ return;
30
+ const [cwd, target] = entry;
31
+ target.next = Date.now() + 6 * 60 * 60 * 1000;
32
+ if (!autoCheckEnabled(target.agentDir))
33
+ return;
34
+ readers++;
35
+ void runWorker({ cwd, agentDir: target.agentDir, action: "check" }).then(state => states.set(cwd, state)).catch(() => { }).finally(() => { readers--; });
36
+ }, 60000);
37
+ backgroundTimer.unref();
38
+ function runWorker(input, log = () => { }) {
39
+ return new Promise((resolve, reject) => {
40
+ const child = fork(new URL(import.meta.url.endsWith(".ts") ? "./extensions-worker.ts" : "./extensions-worker.js", import.meta.url), ["--extensions-worker"], { detached: process.platform !== "win32", stdio: ["ignore", "pipe", "pipe", "ipc"], execArgv: process.execArgv.filter(a => !a.startsWith("--watch")), env: { ...process.env, ELECTRON_RUN_AS_NODE: "1", GIT_TERMINAL_PROMPT: "0" } });
41
+ let result, failure;
42
+ child.stdout?.on("data", chunk => log(String(chunk)));
43
+ child.stderr?.on("data", chunk => log(String(chunk)));
44
+ child.on("message", (message) => { if (message.progress)
45
+ log(message.progress); if (message.state)
46
+ result = message.state; if (message.error)
47
+ failure = Error(message.error); });
48
+ const stop = () => { if (child.pid)
49
+ killPidTree(child.pid); };
50
+ process.once("exit", stop);
51
+ const timer = setTimeout(() => { failure = Error("Package operation timed out"); stop(); }, input.action === "mutate" ? 20 * 60 * 1000 : 120000);
52
+ child.once("error", error => { clearTimeout(timer); process.removeListener("exit", stop); reject(error); });
53
+ child.once("exit", () => { clearTimeout(timer); process.removeListener("exit", stop); result && !failure ? resolve(result) : reject(failure ?? Error("Package worker stopped")); });
54
+ child.send(input);
55
+ });
56
+ }
57
+ async function previewSource(source) {
58
+ const info = sourceInfo(source);
59
+ let meta = {};
60
+ if (info.kind === "npm")
61
+ meta = await cachedFetch(`https://registry.npmjs.org/${encodeURIComponent(info.name)}/${encodeURIComponent(info.ref ?? "latest")}`);
62
+ if (info.kind === "local") {
63
+ try {
64
+ meta = readJson(join(source, "package.json"));
65
+ }
66
+ catch (e) {
67
+ if (e.code !== "ENOTDIR")
68
+ throw e;
69
+ }
70
+ }
71
+ const resources = {};
72
+ for (const type of resourceTypes)
73
+ if (Array.isArray(meta.pi?.[type]))
74
+ resources[type] = meta.pi[type].filter((v) => typeof v === "string").slice(0, 100);
75
+ return { source, name: textField(meta.name) ?? info.name, version: textField(meta.version), description: textField(meta.description), license: textField(meta.license), author: textField(typeof meta.author === "string" ? meta.author : meta.author?.name), repository: safeUrl(typeof meta.repository === "string" ? meta.repository : meta.repository?.url), resources, canPin: info.kind === "npm" && typeof meta.version === "string" };
76
+ }
77
+ export function installExtensionsRoutes(app, service, originAllowed) {
78
+ canBackgroundRun = () => !service().quiesceInfo().quiesced;
79
+ app.post("/api/extensions", async (req, res) => {
80
+ res.setHeader("Cache-Control", "no-store");
81
+ if (!originAllowed(req) || !req.is("application/json")) {
82
+ res.sendStatus(403);
83
+ return;
84
+ }
85
+ const { clientId, cwd, action } = req.body ?? {};
86
+ const cs = typeof clientId === "string" ? service().get(clientId) : undefined;
87
+ if (!cs || cs.cwd !== cwd || cs.switchingWorkspace || service().quiesceInfo().quiesced) {
88
+ res.status(409).json({ error: "Workspace unavailable" });
89
+ return;
90
+ }
91
+ const agentDir = getAgentDir();
92
+ try {
93
+ if (action === "open-info" && req.body.id === "skills:user") {
94
+ const path = join(agentDir, "skills");
95
+ res.json({ absolute: existsSync(path) ? path : agentDir });
96
+ return;
97
+ }
98
+ if (action === "skills-list" || action === "skills-toggle") {
99
+ if (mutation || readers >= 4)
100
+ throw Error("Package manager busy");
101
+ const change = action === "skills-toggle" ? req.body : undefined;
102
+ if (change && (typeof change.id !== "string" || typeof change.enabled !== "boolean" || typeof change.version !== "string"))
103
+ throw Error("Invalid skill change");
104
+ if (change)
105
+ mutation = randomUUID();
106
+ readers++;
107
+ try {
108
+ const valid = () => cs.cwd === cwd && !cs.switchingWorkspace && !service().quiesceInfo().quiesced;
109
+ const state = await nativeSkills(cwd, agentDir, change, valid);
110
+ if (!valid())
111
+ throw Error("Workspace changed");
112
+ res.json(state);
113
+ }
114
+ finally {
115
+ readers--;
116
+ if (change)
117
+ mutation = undefined;
118
+ }
119
+ return;
120
+ }
121
+ if (action === "preferences") {
122
+ if (typeof req.body.enabled !== "boolean")
123
+ throw Error("Invalid preference");
124
+ const path = join(agentDir, "webui-extensions.json"), previous = readJson(path);
125
+ mkdirSync(agentDir, { recursive: true });
126
+ writeFileSync(`${path}.tmp`, JSON.stringify({ ...previous, autoCheck: req.body.enabled }), { mode: 0o600 });
127
+ renameSync(`${path}.tmp`, path);
128
+ res.json({ autoCheck: req.body.enabled });
129
+ return;
130
+ }
131
+ if (action === "search") {
132
+ res.json(await browseCatalog(String(req.body.query ?? ""), String(req.body.type ?? ""), String(req.body.sort ?? ""), Number(req.body.page) || 1));
133
+ return;
134
+ }
135
+ if (action === "details") {
136
+ res.json(await previewSource(validateSource(req.body.source, cwd)));
137
+ return;
138
+ }
139
+ if (action === "preview") {
140
+ const preview = { ...await previewSource(validateSource(req.body.source, cwd)), ticket: randomUUID() };
141
+ if (tickets.size >= 64)
142
+ tickets.delete(tickets.keys().next().value);
143
+ tickets.set(preview.ticket, { cwd, clientId, until: Date.now() + 1200000, preview });
144
+ res.json(preview);
145
+ return;
146
+ }
147
+ if (action === "job") {
148
+ const job = jobs.get(req.body.id);
149
+ if (!job || job.clientId !== clientId || job.cwd !== cwd)
150
+ throw Error("Operation not found");
151
+ res.json(job);
152
+ return;
153
+ }
154
+ if (action === "start") {
155
+ if (mutation)
156
+ throw Error("Package manager is busy; retry shortly");
157
+ const op = req.body.operation;
158
+ if (!op || !["install", "remove", "toggle", "update", "update-all", "unpin", "move"].includes(op.action) || op.scope && !["user", "project"].includes(op.scope) || op.action === "toggle" && typeof op.enabled !== "boolean")
159
+ throw Error("Invalid operation");
160
+ let source;
161
+ if (op.action === "install") {
162
+ const ticket = tickets.get(op.ticket ?? "");
163
+ if (!ticket || ticket.cwd !== cwd || ticket.clientId !== clientId || ticket.until < Date.now())
164
+ throw Error("Install preview expired; review the source again");
165
+ source = ticket.preview.source;
166
+ if (op.pin && ticket.preview.canPin)
167
+ source = `${sourceInfo(source).unpinned}@${ticket.preview.version}`;
168
+ tickets.delete(op.ticket);
169
+ }
170
+ const id = randomUUID(), job = { id, phase: "running", log: "", cwd, clientId };
171
+ if (jobs.size >= 32)
172
+ jobs.delete(jobs.keys().next().value);
173
+ jobs.set(id, job);
174
+ mutation = id;
175
+ void runWorker({ cwd, agentDir, action: "mutate", operation: op, source, version: req.body.version }, line => { job.log = (job.log + line + "\n").slice(-128000); }).then(() => { states.delete(cwd); job.phase = "done"; }, error => { job.phase = "error"; job.error = error.message; job.log += `\n${error.message}`; }).finally(() => { mutation = undefined; });
176
+ res.json(job);
177
+ return;
178
+ }
179
+ if (action !== "list" && action !== "check" && !["open-info", "file", "save-file", "notes"].includes(action))
180
+ throw Error("Unknown action");
181
+ if (mutation)
182
+ throw Error("Package operation running");
183
+ if (readers >= 4)
184
+ throw Error("Package manager busy");
185
+ readers++;
186
+ try {
187
+ const cached = states.get(cwd);
188
+ const state = await runWorker({ cwd, agentDir, action: action === "check" ? "check" : "list" });
189
+ if (cs.cwd !== cwd || cs.switchingWorkspace)
190
+ throw Error("Workspace changed");
191
+ if (["file", "save-file", "notes"].includes(action)) {
192
+ const item = state.packages.find(p => p.id === req.body.id);
193
+ if (!item)
194
+ throw Error("Package unavailable");
195
+ if (action === "notes") {
196
+ res.json(item.kind === "npm" ? await packageReleaseNotes(sourceInfo(item.source).name) : { title: item.version ?? "", notes: [] });
197
+ return;
198
+ }
199
+ if (item.kind !== "file" || !item.trusted || !item.path || !/\.[cm]?[jt]s$/.test(item.path))
200
+ throw Error("Only trusted standalone extension files can be edited here");
201
+ const path = realpathSync(item.path), info = statSync(path);
202
+ if (!info.isFile() || info.size > 512 * 1024)
203
+ throw Error("Extension file exceeds editor limit (512 KB)");
204
+ const raw = readFileSync(path), version = createHash("sha256").update(raw).digest("hex");
205
+ if (action === "save-file") {
206
+ if (mutation)
207
+ throw Error("Package operation running");
208
+ if (version !== req.body.version)
209
+ throw Error("File changed externally; reopen before saving");
210
+ if (typeof req.body.content !== "string" || Buffer.byteLength(req.body.content) > 512 * 1024)
211
+ throw Error("Invalid extension content");
212
+ const temp = `${path}.${randomUUID()}.tmp`;
213
+ writeFileSync(temp, req.body.content, { mode: info.mode });
214
+ renameSync(temp, path);
215
+ res.json({ saved: true });
216
+ }
217
+ else
218
+ res.json({ content: new TextDecoder("utf-8", { fatal: true }).decode(raw), version });
219
+ return;
220
+ }
221
+ if (action === "open-info") {
222
+ const item = state.packages.find(p => p.id === req.body.id);
223
+ if (!item?.path)
224
+ throw Error("Installed path unavailable");
225
+ res.json({ absolute: item.path });
226
+ return;
227
+ }
228
+ if (action === "check") {
229
+ if (states.size > 32)
230
+ states.delete(states.keys().next().value);
231
+ states.set(cwd, state);
232
+ }
233
+ else if (cached?.version === state.version) {
234
+ state.checkedAt = cached.checkedAt;
235
+ for (const item of state.packages) {
236
+ const old = cached.packages.find(p => p.id === item.id);
237
+ if (old?.version === item.version)
238
+ Object.assign(item, { update: old?.update, latest: old?.latest, checkError: old?.checkError });
239
+ }
240
+ }
241
+ state.autoCheck = autoCheckEnabled(agentDir);
242
+ if (background.size > 32)
243
+ background.delete(background.keys().next().value);
244
+ background.set(cwd, { agentDir, next: Math.max(Date.now() + 60000, (state.checkedAt ?? 0) + 6 * 60 * 60 * 1000) });
245
+ res.json(state);
246
+ }
247
+ finally {
248
+ readers--;
249
+ }
250
+ }
251
+ catch (error) {
252
+ res.status(400).json({ error: error instanceof Error ? error.message : String(error) });
253
+ }
254
+ });
255
+ }
@@ -0,0 +1,188 @@
1
+ import { DefaultPackageManager, SettingsManager, ProjectTrustStore } from "@earendil-works/pi-coding-agent";
2
+ import { writeFileSync, mkdirSync, renameSync } from "node:fs";
3
+ import { join, relative } from "node:path";
4
+ import { createHash } from "node:crypto";
5
+ import { readJson, textField, resourceTypes, sourceOf, sourceInfo, packageDisabled, settingsVersion } from "./extensions-model.js";
6
+ import { extensionDisplay } from "./extension-display.js";
7
+ import { gitOutput, latestNpmVersion } from "./component-updates.js";
8
+ const blankResources = () => ({ extensions: [], skills: [], prompts: [], themes: [] });
9
+ export async function extensionWork(input, progress = () => { }) {
10
+ const { cwd, agentDir } = input;
11
+ const trusted = new ProjectTrustStore(agentDir).get(cwd) === true;
12
+ const settings = SettingsManager.create(cwd, agentDir, { projectTrusted: trusted });
13
+ const errors = settings.drainErrors();
14
+ if (errors.length)
15
+ throw Error(errors.map(e => e.error.message).join("\n"));
16
+ const manager = new DefaultPackageManager({ cwd, agentDir, settingsManager: settings });
17
+ manager.setProgressCallback(event => progress(`${event.type}: ${event.message ?? event.source}`));
18
+ const config = (scope) => scope === "user" ? settings.getGlobalSettings() : settings.getProjectSettings();
19
+ const packages = (scope) => config(scope).packages ?? [];
20
+ const setPackages = (scope, entries) => scope === "user" ? settings.setPackages(entries) : settings.setProjectPackages(entries);
21
+ const flush = async () => { await settings.flush(); const errors = settings.drainErrors(); if (errors.length)
22
+ throw Error(errors.map(e => e.error.message).join("\n")); };
23
+ const scopedManager = (scope, entries) => {
24
+ const isolated = SettingsManager.inMemory({ ...settings.getSettings(), packages: [] }, { projectTrusted: true });
25
+ if (scope === "project")
26
+ isolated.setProjectPackages(entries);
27
+ else
28
+ isolated.setPackages(entries);
29
+ return new DefaultPackageManager({ cwd, agentDir, settingsManager: isolated });
30
+ };
31
+ const checkUpdates = async () => (await Promise.all(["user", "project"].filter(scope => scope === "user" || trusted).map(scope => scopedManager(scope, packages(scope)).checkForAvailableUpdates()))).flat();
32
+ const backupPath = join(agentDir, "webui-extension-filters.json");
33
+ const backup = readJson(backupPath);
34
+ const backupKey = (id) => createHash("sha256").update(`${id.startsWith("user:") ? "global" : cwd}:${id}`).digest("hex");
35
+ const saveBackup = () => { mkdirSync(agentDir, { recursive: true }); writeFileSync(`${backupPath}.tmp`, JSON.stringify(backup), { mode: 0o600 }); renameSync(`${backupPath}.tmp`, backupPath); };
36
+ async function list() {
37
+ const resources = await manager.resolve(async () => "skip");
38
+ const result = [];
39
+ const projectDeclarations = readJson(join(cwd, ".pi/settings.json")).packages ?? [];
40
+ for (const scope of ["user", "project"]) {
41
+ const declarations = scope === "project" && !trusted ? projectDeclarations : packages(scope);
42
+ for (const entry of declarations) {
43
+ const source = sourceOf(entry), info = sourceInfo(source), path = scope === "project" && !trusted ? undefined : manager.getInstalledPath(source, scope);
44
+ let metadata = {};
45
+ if (path)
46
+ try {
47
+ metadata = readJson(join(path, "package.json"));
48
+ }
49
+ catch { }
50
+ const counts = blankResources();
51
+ for (const type of resourceTypes)
52
+ counts[type] = resources[type].filter(r => r.metadata.source === source && r.metadata.scope === scope).map(r => relative(path ?? cwd, r.path));
53
+ result.push({ id: `${scope}:${source}`, source, scope, kind: info.kind, name: textField(metadata.name) ?? info.name, path, version: textField(metadata.version), description: textField(metadata.description), enabled: !packageDisabled(entry), pinned: info.pinned, trusted: scope === "user" || trusted, resources: counts, protected: ["@youweichen/pi-harness", "pi-harness", "@earendil-works/pi-coding-agent"].includes(info.name) });
54
+ }
55
+ }
56
+ for (const resource of resources.extensions) {
57
+ if (resource.metadata.origin !== "top-level" || resource.path.startsWith("builtin:") || resource.metadata.scope === "temporary")
58
+ continue;
59
+ result.push({ id: `file:${resource.metadata.scope}:${resource.path}`, source: resource.path, ...extensionDisplay(resource.path), scope: resource.metadata.scope, kind: "file", path: resource.path, enabled: resource.enabled, pinned: false, trusted: resource.metadata.scope === "user" || trusted, resources: blankResources() });
60
+ }
61
+ return { packages: result, version: settingsVersion(cwd, agentDir), trusted };
62
+ }
63
+ if (input.action === "mutate") {
64
+ if (input.version !== settingsVersion(cwd, agentDir))
65
+ throw Error("Pi settings changed; refresh before applying changes");
66
+ const op = input.operation;
67
+ const state = await list(), target = state.packages.find(p => p.id === op.id);
68
+ if (!["install", "update-all"].includes(op.action) && !target)
69
+ throw Error("Package no longer configured");
70
+ if (target?.kind === "file" && op.action !== "toggle")
71
+ throw Error("Standalone files only support toggling and editing");
72
+ if (target?.protected)
73
+ throw Error("This package must be managed with the application");
74
+ if (target && !target.trusted || op.scope === "project" && !trusted)
75
+ throw Error("Project is not trusted; review it in MCP settings or Pi first");
76
+ if (input.version !== settingsVersion(cwd, agentDir))
77
+ throw Error("Pi settings changed; refresh before applying changes");
78
+ const scope = target?.scope ?? op.scope ?? "user", local = scope === "project";
79
+ const source = target?.source ?? input.source;
80
+ const entries = packages(scope), index = entries.findIndex(p => sourceOf(p) === source);
81
+ if (op.action === "install") {
82
+ if (!input.source)
83
+ throw Error("Install preview expired");
84
+ if (["@youweichen/pi-harness", "pi-harness", "@earendil-works/pi-coding-agent"].includes(sourceInfo(input.source).name))
85
+ throw Error("Manage this package with the application updater");
86
+ await manager.install(input.source, { local });
87
+ if (input.version !== settingsVersion(cwd, agentDir))
88
+ throw Error("Pi settings changed during install; files were installed but configuration was not overwritten");
89
+ manager.addSourceToSettings(input.source, { local });
90
+ }
91
+ else if (op.action === "remove") {
92
+ await manager.remove(source, { local });
93
+ await settings.reload();
94
+ manager.removeSourceFromSettings(source, { local });
95
+ delete backup[backupKey(target.id)];
96
+ saveBackup();
97
+ }
98
+ else if (op.action === "toggle" && target?.kind === "file") {
99
+ const paths = [...(config(scope).extensions ?? [])].filter(p => p !== `-${source}` && p !== `+${source}`);
100
+ paths.push(`${op.enabled ? "+" : "-"}${source}`);
101
+ if (local)
102
+ settings.setProjectExtensionPaths(paths);
103
+ else
104
+ settings.setExtensionPaths(paths);
105
+ }
106
+ else if (op.action === "toggle") {
107
+ const key = backupKey(target.id);
108
+ if (!op.enabled && !packageDisabled(entries[index])) {
109
+ backup[key] = entries[index];
110
+ saveBackup();
111
+ entries[index] = { ...(typeof entries[index] === "object" ? entries[index] : { source }), autoload: true, extensions: [], skills: [], prompts: [], themes: [] };
112
+ }
113
+ if (op.enabled && packageDisabled(entries[index]))
114
+ entries[index] = backup[key] ?? { source };
115
+ setPackages(scope, entries);
116
+ }
117
+ else if (op.action === "unpin") {
118
+ const unpinned = sourceInfo(source).unpinned;
119
+ entries[index] = typeof entries[index] === "string" ? unpinned : { ...entries[index], source: unpinned };
120
+ const saved = backup[backupKey(target.id)];
121
+ if (saved) {
122
+ backup[backupKey(`${scope}:${unpinned}`)] = typeof saved === "string" ? unpinned : { ...saved, source: unpinned };
123
+ saveBackup();
124
+ }
125
+ setPackages(scope, entries);
126
+ }
127
+ else if (op.action === "move") {
128
+ const destination = scope === "user" ? "project" : "user";
129
+ if (!trusted)
130
+ throw Error("Project is not trusted");
131
+ if (packages(destination).some(p => sourceInfo(sourceOf(p)).unpinned === sourceInfo(source).unpinned))
132
+ throw Error("Package already declared in destination scope");
133
+ const movedSource = target.kind === "local" ? target.path ?? source : source;
134
+ await manager.install(movedSource, { local: destination === "project" });
135
+ if (input.version !== settingsVersion(cwd, agentDir))
136
+ throw Error("Pi settings changed during move; destination files installed but configuration retained");
137
+ const old = entries[index], moved = typeof old === "string" ? movedSource : { ...old, source: movedSource };
138
+ setPackages(destination, [...packages(destination), moved]);
139
+ await flush();
140
+ setPackages(scope, entries.filter((_, i) => i !== index));
141
+ const oldBackup = backup[backupKey(target.id)];
142
+ if (oldBackup) {
143
+ backup[backupKey(`${destination}:${movedSource}`)] = typeof oldBackup === "string" ? movedSource : { ...oldBackup, source: movedSource };
144
+ saveBackup();
145
+ }
146
+ }
147
+ else if (op.action === "update" || op.action === "update-all") {
148
+ const updates = await checkUpdates();
149
+ const eligible = state.packages.filter(p => !p.protected && p.trusted && !p.pinned && updates.some(u => u.source === p.source && u.scope === p.scope) && (op.action === "update-all" || p.id === target.id));
150
+ if (!eligible.length)
151
+ throw Error("No updates available");
152
+ for (const [i, p] of eligible.entries()) {
153
+ if (p.kind === "git" && p.path && await gitOutput(p.path, ["status", "--porcelain"]))
154
+ throw Error(`Local changes in ${p.name}; commit or save them before updating`);
155
+ progress(`${i + 1}/${eligible.length} ${p.name}`);
156
+ // A scope-isolated native manager prevents update(source) from also updating another declaration.
157
+ const updater = scopedManager(p.scope, [p.source]);
158
+ updater.setProgressCallback(event => progress(`${event.type}: ${event.message ?? event.source}`));
159
+ await updater.update(p.source);
160
+ }
161
+ }
162
+ else
163
+ throw Error("Unsupported operation");
164
+ await flush();
165
+ }
166
+ const state = await list();
167
+ if (input.action === "check") {
168
+ const updates = await checkUpdates();
169
+ for (const item of state.packages) {
170
+ item.update = !item.protected && updates.some(u => u.scope === item.scope && u.source === item.source);
171
+ if (item.update && item.kind === "npm" && !sourceInfo(item.source).ref)
172
+ try {
173
+ item.latest = await latestNpmVersion(sourceInfo(item.source).name);
174
+ }
175
+ catch (e) {
176
+ item.checkError = String(e);
177
+ }
178
+ if (item.update && item.kind === "git")
179
+ item.latest = "HEAD";
180
+ }
181
+ state.checkedAt = Date.now();
182
+ }
183
+ return state;
184
+ }
185
+ if (process.send && process.argv.includes("--extensions-worker"))
186
+ process.once("message", (input) => {
187
+ void extensionWork(input, message => process.send?.({ progress: message })).then(state => process.send?.({ state }, () => process.disconnect()), error => process.send?.({ error: error instanceof Error ? error.message : String(error) }, () => process.disconnect()));
188
+ });