@powerhousedao/shared 6.2.3-dev.1 → 6.2.3-dev.100

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 (365) hide show
  1. package/dist/action-id-DON1WCeY.d.ts +19 -0
  2. package/dist/action-id-DON1WCeY.d.ts.map +1 -0
  3. package/dist/analytics/index.d.ts +4 -4
  4. package/dist/analytics/index.d.ts.map +1 -1
  5. package/dist/analytics/index.js +25 -24
  6. package/dist/analytics/index.js.map +1 -1
  7. package/dist/clis/args/access-token.d.mts +15 -2
  8. package/dist/clis/args/access-token.d.mts.map +1 -0
  9. package/dist/clis/args/access-token.mjs +21 -1
  10. package/dist/clis/args/access-token.mjs.map +1 -0
  11. package/dist/clis/args/{common-CcYbXrBx.mjs → common-DG_SF8fN.mjs} +66 -12
  12. package/dist/clis/args/common-DG_SF8fN.mjs.map +1 -0
  13. package/dist/clis/args/common-DmerPWXo.d.mts +190 -0
  14. package/dist/clis/args/common-DmerPWXo.d.mts.map +1 -0
  15. package/dist/clis/args/common.d.mts +3 -2
  16. package/dist/clis/args/common.mjs +1 -1
  17. package/dist/clis/args/connect.d.mts +449 -2
  18. package/dist/clis/args/connect.d.mts.map +1 -0
  19. package/dist/clis/args/connect.mjs +202 -1
  20. package/dist/clis/args/connect.mjs.map +1 -0
  21. package/dist/clis/args/{generate-CA916Fvj.mjs → generate-DoDfK_Wi.mjs} +40 -2
  22. package/dist/clis/args/generate-DoDfK_Wi.mjs.map +1 -0
  23. package/dist/clis/args/generate.d.mts +102 -2
  24. package/dist/clis/args/generate.d.mts.map +1 -0
  25. package/dist/clis/args/generate.mjs +1 -1
  26. package/dist/clis/args/help-BsMOLPsF.d.mts +251 -0
  27. package/dist/clis/args/help-BsMOLPsF.d.mts.map +1 -0
  28. package/dist/clis/args/{help-Bqbgbalu.mjs → help-DJCRTkC9.mjs} +75 -16
  29. package/dist/clis/args/help-DJCRTkC9.mjs.map +1 -0
  30. package/dist/clis/args/help.d.mts +3 -2
  31. package/dist/clis/args/help.mjs +16 -1
  32. package/dist/clis/args/host.d.mts +23 -0
  33. package/dist/clis/args/host.d.mts.map +1 -0
  34. package/dist/clis/args/host.mjs +35 -0
  35. package/dist/clis/args/host.mjs.map +1 -0
  36. package/dist/clis/args/index.d.mts +24 -19
  37. package/dist/clis/args/index.mjs +23 -19
  38. package/dist/clis/args/init.d.mts +54 -2
  39. package/dist/clis/args/init.d.mts.map +1 -0
  40. package/dist/clis/args/init.mjs +77 -1
  41. package/dist/clis/args/init.mjs.map +1 -0
  42. package/dist/clis/args/inspect.d.mts +12 -2
  43. package/dist/clis/args/inspect.d.mts.map +1 -0
  44. package/dist/clis/args/inspect.mjs +14 -1
  45. package/dist/clis/args/inspect.mjs.map +1 -0
  46. package/dist/clis/args/install.d.mts +36 -2
  47. package/dist/clis/args/install.d.mts.map +1 -0
  48. package/dist/clis/args/install.mjs +31 -1
  49. package/dist/clis/args/install.mjs.map +1 -0
  50. package/dist/clis/args/keyframes.d.mts +25 -0
  51. package/dist/clis/args/keyframes.d.mts.map +1 -0
  52. package/dist/clis/args/keyframes.mjs +42 -0
  53. package/dist/clis/args/keyframes.mjs.map +1 -0
  54. package/dist/clis/args/list.d.mts +9 -2
  55. package/dist/clis/args/list.d.mts.map +1 -0
  56. package/dist/clis/args/list.mjs +6 -1
  57. package/dist/clis/args/list.mjs.map +1 -0
  58. package/dist/clis/args/login.d.mts +24 -2
  59. package/dist/clis/args/login.d.mts.map +1 -0
  60. package/dist/clis/args/login.mjs +39 -1
  61. package/dist/clis/args/login.mjs.map +1 -0
  62. package/dist/clis/args/mcp.d.mts +15 -0
  63. package/dist/clis/args/mcp.d.mts.map +1 -0
  64. package/dist/clis/args/mcp.mjs +22 -0
  65. package/dist/clis/args/mcp.mjs.map +1 -0
  66. package/dist/clis/args/migrate.d.mts +18 -2
  67. package/dist/clis/args/migrate.d.mts.map +1 -0
  68. package/dist/clis/args/migrate.mjs +27 -1
  69. package/dist/clis/args/migrate.mjs.map +1 -0
  70. package/dist/clis/args/model.d.mts +39 -0
  71. package/dist/clis/args/model.d.mts.map +1 -0
  72. package/dist/clis/args/model.mjs +51 -0
  73. package/dist/clis/args/model.mjs.map +1 -0
  74. package/dist/clis/args/publish.d.mts +19 -2
  75. package/dist/clis/args/publish.d.mts.map +1 -0
  76. package/dist/clis/args/publish.mjs +26 -1
  77. package/dist/clis/args/publish.mjs.map +1 -0
  78. package/dist/clis/args/registry.d.mts +16 -2
  79. package/dist/clis/args/registry.d.mts.map +1 -0
  80. package/dist/clis/args/registry.mjs +22 -1
  81. package/dist/clis/args/registry.mjs.map +1 -0
  82. package/dist/clis/args/run.d.mts +18 -0
  83. package/dist/clis/args/run.d.mts.map +1 -0
  84. package/dist/clis/args/run.mjs +28 -0
  85. package/dist/clis/args/run.mjs.map +1 -0
  86. package/dist/clis/args/service-CLCvH3kf.d.mts +27 -0
  87. package/dist/clis/args/service-CLCvH3kf.d.mts.map +1 -0
  88. package/dist/clis/args/service.d.mts +3 -2
  89. package/dist/clis/args/service.mjs +10 -1
  90. package/dist/clis/args/service.mjs.map +1 -0
  91. package/dist/clis/args/switchboard.d.mts +69 -2
  92. package/dist/clis/args/switchboard.d.mts.map +1 -0
  93. package/dist/clis/args/switchboard.mjs +84 -1
  94. package/dist/clis/args/switchboard.mjs.map +1 -0
  95. package/dist/clis/args/uninstall.d.mts +27 -2
  96. package/dist/clis/args/uninstall.d.mts.map +1 -0
  97. package/dist/clis/args/uninstall.mjs +15 -1
  98. package/dist/clis/args/uninstall.mjs.map +1 -0
  99. package/dist/clis/args/unpublish.d.mts +21 -2
  100. package/dist/clis/args/unpublish.d.mts.map +1 -0
  101. package/dist/clis/args/unpublish.mjs +29 -1
  102. package/dist/clis/args/unpublish.mjs.map +1 -0
  103. package/dist/clis/args/{vetra-b4KUu1Ax.mjs → vetra-BqjDopAP.mjs} +18 -2
  104. package/dist/clis/args/vetra-BqjDopAP.mjs.map +1 -0
  105. package/dist/clis/args/vetra.d.mts +113 -2
  106. package/dist/clis/args/vetra.d.mts.map +1 -0
  107. package/dist/clis/args/vetra.mjs +1 -1
  108. package/dist/clis/build-config-BM1RL4u_.mjs +309 -0
  109. package/dist/clis/build-config-BM1RL4u_.mjs.map +1 -0
  110. package/dist/clis/build-config.d.mts +71 -10616
  111. package/dist/clis/build-config.d.mts.map +1 -1
  112. package/dist/clis/build-config.mjs +2 -88
  113. package/dist/clis/build-pieces.d.mts +167 -0
  114. package/dist/clis/build-pieces.d.mts.map +1 -0
  115. package/dist/clis/build-pieces.mjs +594 -0
  116. package/dist/clis/build-pieces.mjs.map +1 -0
  117. package/dist/clis/command-names.d.mts +6 -2
  118. package/dist/clis/command-names.d.mts.map +1 -1
  119. package/dist/clis/command-names.mjs +10 -1
  120. package/dist/clis/command-names.mjs.map +1 -1
  121. package/dist/clis/constants.d.mts +3 -462
  122. package/dist/clis/constants.mjs +92 -21
  123. package/dist/clis/constants.mjs.map +1 -1
  124. package/dist/clis/definition-sources.d.mts +57 -0
  125. package/dist/clis/definition-sources.d.mts.map +1 -0
  126. package/dist/clis/definition-sources.mjs +98 -0
  127. package/dist/clis/definition-sources.mjs.map +1 -0
  128. package/dist/clis/definition-types-CiUH8dqg.d.mts +18 -0
  129. package/dist/clis/definition-types-CiUH8dqg.d.mts.map +1 -0
  130. package/dist/clis/feature-flags.d.mts +17 -0
  131. package/dist/clis/feature-flags.d.mts.map +1 -0
  132. package/dist/clis/feature-flags.mjs +21 -0
  133. package/dist/clis/feature-flags.mjs.map +1 -0
  134. package/dist/clis/index-DnZYG-8g.d.mts +11154 -0
  135. package/dist/clis/index-DnZYG-8g.d.mts.map +1 -0
  136. package/dist/clis/index.d.mts +3819 -1952
  137. package/dist/clis/index.d.mts.map +1 -1
  138. package/dist/clis/index.mjs +1543 -857
  139. package/dist/clis/index.mjs.map +1 -1
  140. package/dist/clis/package-style.d.mts +32 -0
  141. package/dist/clis/package-style.d.mts.map +1 -0
  142. package/dist/clis/package-style.mjs +102 -0
  143. package/dist/clis/package-style.mjs.map +1 -0
  144. package/dist/clis/ph-dir.d.mts +26 -0
  145. package/dist/clis/ph-dir.d.mts.map +1 -0
  146. package/dist/clis/ph-dir.mjs +37 -0
  147. package/dist/clis/ph-dir.mjs.map +1 -0
  148. package/dist/clis/project-env.d.mts +10 -4
  149. package/dist/clis/project-env.d.mts.map +1 -1
  150. package/dist/clis/project-env.mjs +16 -1
  151. package/dist/clis/project-env.mjs.map +1 -1
  152. package/dist/clis/project-ports.d.mts +5 -5
  153. package/dist/clis/project-ports.d.mts.map +1 -1
  154. package/dist/clis/project-ports.mjs +1 -1
  155. package/dist/clis/project-ports.mjs.map +1 -1
  156. package/dist/clis/real-paths.d.mts +14 -0
  157. package/dist/clis/real-paths.d.mts.map +1 -0
  158. package/dist/clis/real-paths.mjs +36 -0
  159. package/dist/clis/real-paths.mjs.map +1 -0
  160. package/dist/clis/rolldown-runtime-B4iAMlE-.mjs +35 -0
  161. package/dist/clis/services/telemetry.d.mts +7 -7
  162. package/dist/clis/services/telemetry.d.mts.map +1 -1
  163. package/dist/clis/services/telemetry.mjs.map +1 -1
  164. package/dist/clis/types-Qy1GBoTY.d.mts +2506 -0
  165. package/dist/clis/types-Qy1GBoTY.d.mts.map +1 -0
  166. package/dist/clis/utils.d.mts +4 -4
  167. package/dist/clis/utils.d.mts.map +1 -1
  168. package/dist/clis/utils.mjs.map +1 -1
  169. package/dist/{config-loader-B845Hidf.js → config-loader-B7SqNz8z.js} +50 -12
  170. package/dist/config-loader-B7SqNz8z.js.map +1 -0
  171. package/dist/connect/app-shell.d.ts +48 -0
  172. package/dist/connect/app-shell.d.ts.map +1 -0
  173. package/dist/connect/app-shell.js +90 -0
  174. package/dist/connect/app-shell.js.map +1 -0
  175. package/dist/connect/config-loader.d.ts +21 -8
  176. package/dist/connect/config-loader.d.ts.map +1 -1
  177. package/dist/connect/config-loader.js +2 -2
  178. package/dist/connect/connect-config-schema.d.ts +3 -0
  179. package/dist/connect/connect-config-schema.js +486 -0
  180. package/dist/connect/connect-config-schema.js.map +1 -0
  181. package/dist/connect/image-ref.d.ts +32 -0
  182. package/dist/connect/image-ref.d.ts.map +1 -0
  183. package/dist/connect/image-ref.js +80 -0
  184. package/dist/connect/image-ref.js.map +1 -0
  185. package/dist/connect/index.d.ts +226 -643
  186. package/dist/connect/index.d.ts.map +1 -1
  187. package/dist/connect/index.js +443 -507
  188. package/dist/connect/index.js.map +1 -1
  189. package/dist/connect/json-adapter.d.ts +3 -4
  190. package/dist/connect/json-adapter.d.ts.map +1 -1
  191. package/dist/connect/json-adapter.js.map +1 -1
  192. package/dist/connect/origin-placeholder.d.ts +52 -0
  193. package/dist/connect/origin-placeholder.d.ts.map +1 -0
  194. package/dist/connect/origin-placeholder.js +101 -0
  195. package/dist/connect/origin-placeholder.js.map +1 -0
  196. package/dist/connect-config-schema-cBfkNo1b.d.ts +1872 -0
  197. package/dist/connect-config-schema-cBfkNo1b.d.ts.map +1 -0
  198. package/dist/constants-5UFY_rXh.d.ts +9 -0
  199. package/dist/constants-5UFY_rXh.d.ts.map +1 -0
  200. package/dist/constants.d.ts +3 -2
  201. package/dist/constants.js +22 -6
  202. package/dist/constants.js.map +1 -1
  203. package/dist/document-drive/index.d.ts +137 -95
  204. package/dist/document-drive/index.d.ts.map +1 -1
  205. package/dist/document-drive/index.js +133 -64
  206. package/dist/document-drive/index.js.map +1 -1
  207. package/dist/document-model/action-id.d.ts +3 -0
  208. package/dist/document-model/action-id.js +59 -0
  209. package/dist/document-model/action-id.js.map +1 -0
  210. package/dist/document-model/dispatch.d.ts +25 -0
  211. package/dist/document-model/dispatch.d.ts.map +1 -0
  212. package/dist/document-model/dispatch.js +0 -0
  213. package/dist/document-model/errors.d.ts +3 -0
  214. package/dist/document-model/errors.js +214 -0
  215. package/dist/document-model/errors.js.map +1 -0
  216. package/dist/document-model/index.d.ts +6 -4
  217. package/dist/document-model/index.js +7 -5143
  218. package/dist/document-model/mock.d.ts +2 -3
  219. package/dist/document-model/mock.d.ts.map +1 -1
  220. package/dist/document-model/mock.js +2 -1
  221. package/dist/document-model/mock.js.map +1 -1
  222. package/dist/document-model/utils.d.ts +4 -2
  223. package/dist/document-model/utils.js +3 -2
  224. package/dist/document-model/version.d.ts +3 -0
  225. package/dist/document-model/version.js +8 -0
  226. package/dist/document-model/version.js.map +1 -0
  227. package/dist/document-model-TCCW8aMC.js +5795 -0
  228. package/dist/document-model-TCCW8aMC.js.map +1 -0
  229. package/dist/host-tokens/index.d.ts +3 -0
  230. package/dist/host-tokens/index.js +2 -0
  231. package/dist/host-tokens-DOeyxqLi.js +322 -0
  232. package/dist/host-tokens-DOeyxqLi.js.map +1 -0
  233. package/dist/index-C_lizUqn.d.ts +36 -0
  234. package/dist/index-C_lizUqn.d.ts.map +1 -0
  235. package/dist/index-D58WVj_E.d.ts +246 -0
  236. package/dist/index-D58WVj_E.d.ts.map +1 -0
  237. package/dist/index.d.ts +7 -6
  238. package/dist/index.js.map +1 -1
  239. package/dist/processors/index.d.ts +3 -2
  240. package/dist/processors/index.js +180 -67
  241. package/dist/processors/index.js.map +1 -1
  242. package/dist/processors/testing.d.ts +22 -0
  243. package/dist/processors/testing.d.ts.map +1 -0
  244. package/dist/processors/testing.js +77 -0
  245. package/dist/processors/testing.js.map +1 -0
  246. package/dist/purge-CbAV5DVh.js +631 -0
  247. package/dist/purge-CbAV5DVh.js.map +1 -0
  248. package/dist/registry/index.d.ts +15 -15
  249. package/dist/registry/index.d.ts.map +1 -1
  250. package/dist/registry/index.js +64 -12
  251. package/dist/registry/index.js.map +1 -1
  252. package/dist/registry/manifest-slim.d.ts +4 -3
  253. package/dist/registry/manifest-slim.d.ts.map +1 -1
  254. package/dist/registry/manifest-slim.js +21 -0
  255. package/dist/registry/manifest-slim.js.map +1 -1
  256. package/dist/registry/updates.d.ts +3 -3
  257. package/dist/registry/updates.d.ts.map +1 -1
  258. package/dist/registry/updates.js.map +1 -1
  259. package/dist/registry/urls.d.ts +2 -2
  260. package/dist/registry/urls.d.ts.map +1 -1
  261. package/dist/registry/urls.js.map +1 -1
  262. package/dist/rolldown-runtime-D7D4PA-g.js +13 -0
  263. package/dist/{types-C1in4fl3.d.ts → types-Bsp8VL2y.d.ts} +2 -2
  264. package/dist/types-Bsp8VL2y.d.ts.map +1 -0
  265. package/dist/{types-YqLqb0Zb.d.ts → types-BuEzD0jp.d.ts} +39 -43
  266. package/dist/types-BuEzD0jp.d.ts.map +1 -0
  267. package/dist/types-cIIv_Rsg.d.ts +5710 -0
  268. package/dist/types-cIIv_Rsg.d.ts.map +1 -0
  269. package/dist/{utils-aaTmfxFW.js → utils-DiV32YIj.js} +53 -3
  270. package/dist/utils-DiV32YIj.js.map +1 -0
  271. package/dist/utils-MrLmLEVr.js +78 -0
  272. package/dist/utils-MrLmLEVr.js.map +1 -0
  273. package/dist/version-BxLITo9P.d.ts +6 -0
  274. package/dist/version-BxLITo9P.d.ts.map +1 -0
  275. package/package.json +42 -7
  276. package/dist/clis/args/access-token--9H57y8J.d.mts +0 -18
  277. package/dist/clis/args/access-token--9H57y8J.d.mts.map +0 -1
  278. package/dist/clis/args/access-token-To5LaIfL.mjs +0 -22
  279. package/dist/clis/args/access-token-To5LaIfL.mjs.map +0 -1
  280. package/dist/clis/args/common-CcYbXrBx.mjs.map +0 -1
  281. package/dist/clis/args/common-Dsf1vpHV.d.mts +0 -183
  282. package/dist/clis/args/common-Dsf1vpHV.d.mts.map +0 -1
  283. package/dist/clis/args/connect-BVVvCmL9.mjs +0 -198
  284. package/dist/clis/args/connect-BVVvCmL9.mjs.map +0 -1
  285. package/dist/clis/args/connect-DetTnI8g.d.mts +0 -443
  286. package/dist/clis/args/connect-DetTnI8g.d.mts.map +0 -1
  287. package/dist/clis/args/generate-CA916Fvj.mjs.map +0 -1
  288. package/dist/clis/args/generate-DnV-bfXt.d.mts +0 -87
  289. package/dist/clis/args/generate-DnV-bfXt.d.mts.map +0 -1
  290. package/dist/clis/args/help-Bqbgbalu.mjs.map +0 -1
  291. package/dist/clis/args/help-CjAsudUn.d.mts +0 -193
  292. package/dist/clis/args/help-CjAsudUn.d.mts.map +0 -1
  293. package/dist/clis/args/init-CUXyfquF.d.mts +0 -55
  294. package/dist/clis/args/init-CUXyfquF.d.mts.map +0 -1
  295. package/dist/clis/args/init-rz9Ei7nq.mjs +0 -67
  296. package/dist/clis/args/init-rz9Ei7nq.mjs.map +0 -1
  297. package/dist/clis/args/inspect-DtZeoA5c.d.mts +0 -15
  298. package/dist/clis/args/inspect-DtZeoA5c.d.mts.map +0 -1
  299. package/dist/clis/args/inspect-tckH8mSw.mjs +0 -15
  300. package/dist/clis/args/inspect-tckH8mSw.mjs.map +0 -1
  301. package/dist/clis/args/install-CkP8zcHb.d.mts +0 -40
  302. package/dist/clis/args/install-CkP8zcHb.d.mts.map +0 -1
  303. package/dist/clis/args/install-Sz2DlCHh.mjs +0 -32
  304. package/dist/clis/args/install-Sz2DlCHh.mjs.map +0 -1
  305. package/dist/clis/args/list-BGf8s_gj.d.mts +0 -12
  306. package/dist/clis/args/list-BGf8s_gj.d.mts.map +0 -1
  307. package/dist/clis/args/list-DM2d6f1m.mjs +0 -7
  308. package/dist/clis/args/list-DM2d6f1m.mjs.map +0 -1
  309. package/dist/clis/args/login-DNsHwvqk.d.mts +0 -27
  310. package/dist/clis/args/login-DNsHwvqk.d.mts.map +0 -1
  311. package/dist/clis/args/login-DiKT5Jfu.mjs +0 -40
  312. package/dist/clis/args/login-DiKT5Jfu.mjs.map +0 -1
  313. package/dist/clis/args/magic-string.es-h_0HDQBQ.mjs +0 -1013
  314. package/dist/clis/args/magic-string.es-h_0HDQBQ.mjs.map +0 -1
  315. package/dist/clis/args/migrate-CG_gWc4k.mjs +0 -29
  316. package/dist/clis/args/migrate-CG_gWc4k.mjs.map +0 -1
  317. package/dist/clis/args/migrate-sixkWhxm.d.mts +0 -21
  318. package/dist/clis/args/migrate-sixkWhxm.d.mts.map +0 -1
  319. package/dist/clis/args/publish-DDZYsUfV.mjs +0 -19
  320. package/dist/clis/args/publish-DDZYsUfV.mjs.map +0 -1
  321. package/dist/clis/args/publish-Dqe5DUst.d.mts +0 -18
  322. package/dist/clis/args/publish-Dqe5DUst.d.mts.map +0 -1
  323. package/dist/clis/args/registry-C_OVFQmI.mjs +0 -23
  324. package/dist/clis/args/registry-C_OVFQmI.mjs.map +0 -1
  325. package/dist/clis/args/registry-C_RfTsKB.d.mts +0 -19
  326. package/dist/clis/args/registry-C_RfTsKB.d.mts.map +0 -1
  327. package/dist/clis/args/service-CHOOr0Gg.mjs +0 -11
  328. package/dist/clis/args/service-CHOOr0Gg.mjs.map +0 -1
  329. package/dist/clis/args/service-DhIkf8-O.d.mts +0 -22
  330. package/dist/clis/args/service-DhIkf8-O.d.mts.map +0 -1
  331. package/dist/clis/args/switchboard-BlPaq2at.d.mts +0 -72
  332. package/dist/clis/args/switchboard-BlPaq2at.d.mts.map +0 -1
  333. package/dist/clis/args/switchboard-Dsp7nosi.mjs +0 -85
  334. package/dist/clis/args/switchboard-Dsp7nosi.mjs.map +0 -1
  335. package/dist/clis/args/uninstall-BpA3YYbw.d.mts +0 -31
  336. package/dist/clis/args/uninstall-BpA3YYbw.d.mts.map +0 -1
  337. package/dist/clis/args/uninstall-CTwTX0u_.mjs +0 -16
  338. package/dist/clis/args/uninstall-CTwTX0u_.mjs.map +0 -1
  339. package/dist/clis/args/unpublish-BPMkGEg5.mjs +0 -30
  340. package/dist/clis/args/unpublish-BPMkGEg5.mjs.map +0 -1
  341. package/dist/clis/args/unpublish-CvwaIimG.d.mts +0 -24
  342. package/dist/clis/args/unpublish-CvwaIimG.d.mts.map +0 -1
  343. package/dist/clis/args/vetra-DLQ6lhLl.d.mts +0 -113
  344. package/dist/clis/args/vetra-DLQ6lhLl.d.mts.map +0 -1
  345. package/dist/clis/args/vetra-b4KUu1Ax.mjs.map +0 -1
  346. package/dist/clis/args/vetra-ports.test.d.mts +0 -1
  347. package/dist/clis/args/vetra-ports.test.mjs +0 -13249
  348. package/dist/clis/args/vetra-ports.test.mjs.map +0 -1
  349. package/dist/clis/build-config.mjs.map +0 -1
  350. package/dist/clis/constants.d.mts.map +0 -1
  351. package/dist/config-loader-B845Hidf.js.map +0 -1
  352. package/dist/constants-BP_gjn8g.d.ts +0 -8
  353. package/dist/constants-BP_gjn8g.d.ts.map +0 -1
  354. package/dist/document-model/index.js.map +0 -1
  355. package/dist/index-C_iVZe7f.d.ts +0 -7
  356. package/dist/index-C_iVZe7f.d.ts.map +0 -1
  357. package/dist/index-DyYIJtVy.d.ts +0 -836
  358. package/dist/index-DyYIJtVy.d.ts.map +0 -1
  359. package/dist/types-C1in4fl3.d.ts.map +0 -1
  360. package/dist/types-CpnWmiFY.d.ts +0 -3167
  361. package/dist/types-CpnWmiFY.d.ts.map +0 -1
  362. package/dist/types-YqLqb0Zb.d.ts.map +0 -1
  363. package/dist/utils-DP122OSS.d.ts +0 -18
  364. package/dist/utils-DP122OSS.d.ts.map +0 -1
  365. package/dist/utils-aaTmfxFW.js.map +0 -1
@@ -1,48 +1,27 @@
1
- import { createRequire } from "node:module";
1
+ import { i as __toESM, r as __require, t as __commonJSMin } from "./rolldown-runtime-B4iAMlE-.mjs";
2
2
  import { array, boolean, command, flag, multioption, number, oneOf, option, optional, positional, rest, restPositionals, string } from "cmd-ts";
3
3
  import { AGENTS as AGENTS$1 } from "package-manager-detector/constants";
4
4
  import { homedir } from "node:os";
5
5
  import path, { join } from "node:path";
6
- import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
6
+ import { accessSync, constants, existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
7
7
  import dotenv from "dotenv";
8
8
  import chalk from "chalk";
9
9
  import fsPromises, { mkdir, stat, writeFile } from "node:fs/promises";
10
10
  import { fileURLToPath } from "node:url";
11
11
  import { promisify } from "node:util";
12
12
  import { execFile } from "node:child_process";
13
- import { clean, valid } from "semver";
13
+ import { clean, compare, satisfies, valid } from "semver";
14
14
  import spawn from "cross-spawn";
15
+ import coerce from "semver/functions/coerce.js";
16
+ import gte from "semver/functions/gte.js";
15
17
  import { isTruthy } from "remeda";
16
18
  import npa from "npm-package-arg";
17
19
  import { packageDirectory } from "package-directory";
18
20
  import { execSync } from "child_process";
19
- import { dirname } from "path";
21
+ import { dirname, resolve } from "path";
20
22
  import { writePackage } from "write-package";
23
+ import { toJSONSchema, z } from "zod";
21
24
  import lt from "semver/functions/lt.js";
22
- //#region \0rolldown/runtime.js
23
- var __create = Object.create;
24
- var __defProp = Object.defineProperty;
25
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
26
- var __getOwnPropNames = Object.getOwnPropertyNames;
27
- var __getProtoOf = Object.getPrototypeOf;
28
- var __hasOwnProp = Object.prototype.hasOwnProperty;
29
- var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
30
- var __copyProps = (to, from, except, desc) => {
31
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
32
- key = keys[i];
33
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
34
- get: ((k) => from[k]).bind(null, key),
35
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
36
- });
37
- }
38
- return to;
39
- };
40
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
41
- value: mod,
42
- enumerable: true
43
- }) : target, mod));
44
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
45
- //#endregion
46
25
  //#region clis/constants.ts
47
26
  const SERVICE_ACTIONS = [
48
27
  "start",
@@ -51,7 +30,7 @@ const SERVICE_ACTIONS = [
51
30
  "setup",
52
31
  "restart"
53
32
  ];
54
- const SECONDS_IN_DAY = 1440 * 60;
33
+ const SECONDS_IN_DAY = 86400;
55
34
  const DEFAULT_EXPIRY_DAYS = 7;
56
35
  const DEFAULT_EXPIRY_SECONDS = 7 * SECONDS_IN_DAY;
57
36
  const DRIVES_PRESERVE_STRATEGIES = ["preserve-all", "preserve-by-url-and-detach"];
@@ -74,6 +53,18 @@ const PROJECT_PORT_BAND_SIZE = 1e3;
74
53
  const PROJECT_PORT_BAND_SWITCHBOARD = 7e3;
75
54
  const PROJECT_PORT_BAND_STUDIO = 6e3;
76
55
  const PROJECT_PORT_BAND_VETRA_CONNECT = 2e3;
56
+ /**
57
+ * Icon for the drives switchboard creates by default, inlined as a data URI.
58
+ *
59
+ * A remote URL is the wrong shape for this: the value is baked into the drive
60
+ * document and rendered by every Connect that opens it, so the icon only
61
+ * appears when that client can reach that host. A desktop or air-gapped install
62
+ * cannot, and the ipfs.io gateway this previously pointed at now answers 403
63
+ * regardless.
64
+ *
65
+ * The mark is drawn dark-on-light so it stays legible against either theme.
66
+ */
67
+ const DEFAULT_DRIVE_ICON = "data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2016%2016'%3E%3Crect%20width='16'%20height='16'%20rx='3'%20fill='%23F3F5F7'/%3E%3Cpath%20fill='%23343839'%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M10.0059%200L3.41636%205.45646C2.44979%206.25682%202.3795%207.71452%203.26456%208.60418L5.54425%2010.8957C6.21311%2011.568%206.35783%2012.6012%205.89944%2013.4314L4.48126%2016H2.13333C0.955126%2016%200%2015.0449%200%2013.8667V2.13333C0%200.955126%200.955126%200%202.13333%200H10.0059ZM11.2436%200L10.0128%202.24221C9.55899%203.06891%209.70183%204.09549%2010.3641%204.7669L12.7825%207.21868C13.6656%208.11402%2013.5866%209.57512%2012.612%2010.37L5.70922%2016H13.8667C15.0449%2016%2016%2015.0449%2016%2013.8667V2.13333C16%200.955126%2015.0449%200%2013.8667%200H11.2436Z'/%3E%3C/svg%3E";
77
68
  const DEFAULT_VETRA_DRIVE_ID = "vetra";
78
69
  const MINIMUM_NODE_VERSION = "24.0.0";
79
70
  const PH_BIN = "ph-cli-legacy";
@@ -82,11 +73,18 @@ const PH_GLOBAL_DIR_NAME = ".ph";
82
73
  const PH_GLOBAL_PROJECT_NAME = ".ph";
83
74
  const HOME_DIR = homedir();
84
75
  const POWERHOUSE_GLOBAL_DIR = join(HOME_DIR, ".ph");
85
- const VERSIONED_PEER_DEPENDENCIES = ["document-model", "@powerhousedao/reactor-browser"];
76
+ const VERSIONED_PEER_DEPENDENCIES = [
77
+ "document-model",
78
+ "@powerhousedao/reactor-browser",
79
+ "@powerhousedao/connect-core"
80
+ ];
86
81
  const REACTOR_API_PACKAGE = "@powerhousedao/reactor-api";
87
82
  const ANALYTICS_ENGINE_CORE_PACKAGE = "@powerhousedao/analytics-engine-core";
88
83
  const GRAPHQL_PACKAGE = "graphql";
89
84
  const GRAPHQL_TAG_PACKAGE = "graphql-tag";
85
+ const PIECES_FRAMEWORK_PACKAGE = "@powerhousedao/pieces-framework";
86
+ const KYSELY_PACKAGE = "kysely";
87
+ const RELATIONAL_DB_PROCESSOR_CLASS = "RelationalDbProcessor";
90
88
  const PEER_EXTERNAL_DEPENDENCIES = {
91
89
  [GRAPHQL_PACKAGE]: {
92
90
  peer: "^16",
@@ -106,14 +104,43 @@ const PEER_EXTERNAL_DEPENDENCIES = {
106
104
  },
107
105
  zod: {
108
106
  peer: "^4",
109
- dev: "4.3.6"
107
+ dev: "4.6.5"
108
+ },
109
+ "@tanstack/react-router": {
110
+ peer: "^1.170.41",
111
+ dev: "1.170.41"
110
112
  }
111
113
  };
112
- const FEATURE_DEPENDENCIES = { analyticsProcessor: {
113
- peerVersioned: [ANALYTICS_ENGINE_CORE_PACKAGE],
114
- peerExternal: {}
115
- } };
116
- const VERSIONED_DEPENDENCIES = [...VERSIONED_PEER_DEPENDENCIES, ...FEATURE_DEPENDENCIES.analyticsProcessor.peerVersioned];
114
+ const FEATURE_DEPENDENCIES = {
115
+ analyticsProcessor: {
116
+ peerVersioned: [ANALYTICS_ENGINE_CORE_PACKAGE],
117
+ peerExternal: {},
118
+ devVersioned: []
119
+ },
120
+ relationalDbProcessor: {
121
+ peerVersioned: [],
122
+ peerExternal: { [KYSELY_PACKAGE]: {
123
+ peer: "^0.28",
124
+ dev: "0.28.16"
125
+ } },
126
+ devVersioned: []
127
+ },
128
+ subgraph: {
129
+ peerVersioned: [REACTOR_API_PACKAGE],
130
+ peerExternal: {},
131
+ devVersioned: []
132
+ },
133
+ piece: {
134
+ peerVersioned: [],
135
+ peerExternal: {},
136
+ devVersioned: [PIECES_FRAMEWORK_PACKAGE]
137
+ }
138
+ };
139
+ const VERSIONED_DEPENDENCIES = [
140
+ ...VERSIONED_PEER_DEPENDENCIES,
141
+ ...FEATURE_DEPENDENCIES.analyticsProcessor.peerVersioned,
142
+ ...FEATURE_DEPENDENCIES.subgraph.peerVersioned
143
+ ];
117
144
  const BOILERPLATE_ALLOWED_BUILDS = [
118
145
  "@apollo/protobufjs",
119
146
  "@datadog/pprof",
@@ -130,12 +157,22 @@ const BOILERPLATE_DEPENDENCY_OVERRIDES = {
130
157
  vite: "8.0.14",
131
158
  rolldown: "1.0.2"
132
159
  };
160
+ const BOILERPLATE_TRANSITIVE_OVERRIDES = {
161
+ "@solana/kit": "5.5.1",
162
+ "@solana-program/system": "0.10.0",
163
+ "@solana-program/token": "0.9.0"
164
+ };
133
165
  const VERSIONED_DEV_DEPENDENCIES = [
134
166
  "@powerhousedao/ph-cli",
135
167
  "@powerhousedao/reactor",
136
168
  "@powerhousedao/shared",
137
169
  "@powerhousedao/connect",
138
- "@powerhousedao/design-system"
170
+ "@powerhousedao/design-system",
171
+ "@powerhousedao/host-core",
172
+ "@powerhousedao/clint",
173
+ "@powerhousedao/desktop",
174
+ "@powerhousedao/vetra-studio",
175
+ "@powerhousedao/switchboard"
139
176
  ];
140
177
  const packageJsonExports = {
141
178
  ".": {
@@ -169,24 +206,37 @@ const packageJsonExports = {
169
206
  },
170
207
  "./subgraphs": {
171
208
  types: "./dist/types/subgraphs/index.d.ts",
172
- browser: "./dist/browser/subgraphs/index.js",
173
209
  node: "./dist/node/subgraphs/index.mjs"
174
210
  },
211
+ "./scalars": {
212
+ types: "./dist/types/scalars/index.d.ts",
213
+ browser: "./dist/browser/scalars/index.js",
214
+ node: "./dist/node/scalars/index.mjs"
215
+ },
216
+ "./connect-routes": { browser: "./dist/browser/connect-routes.js" },
175
217
  "./processors": {
176
218
  types: "./dist/types/processors/index.d.ts",
177
219
  browser: "./dist/browser/processors/index.js",
178
220
  node: "./dist/node/processors/index.mjs"
179
221
  },
222
+ "./pieces": {
223
+ types: "./dist/types/pieces/index.d.ts",
224
+ node: "./dist/node/pieces/index.mjs"
225
+ },
226
+ "./pieces/*": {
227
+ types: "./dist/types/pieces/*/index.d.ts",
228
+ node: "./dist/node/pieces/*/index.mjs"
229
+ },
180
230
  "./manifest": "./dist/powerhouse.manifest.json",
181
231
  "./style.css": "./dist/style.css"
182
232
  };
183
233
  const packageScripts = {
184
234
  "test:watch": "vitest",
185
- lint: "oxlint --type-aware --type-check",
186
- "lint:fix": "oxlint --type-aware --type-check --fix",
235
+ lint: "ph-cli generate connect-routes && oxlint --type-aware --type-check",
236
+ "lint:fix": "ph-cli generate connect-routes && oxlint --type-aware --type-check --fix",
187
237
  format: "oxfmt",
188
238
  "format:check": "oxfmt --check",
189
- tsc: "tsc",
239
+ tsc: "ph-cli generate connect-routes && tsc",
190
240
  "tsc:watch": "tsc --watch",
191
241
  generate: "ph-cli generate",
192
242
  connect: "ph-cli connect",
@@ -194,6 +244,7 @@ const packageScripts = {
194
244
  reactor: "ph-cli reactor",
195
245
  service: "ph-cli service",
196
246
  vetra: "ph-cli vetra",
247
+ mcp: "ph-cli mcp",
197
248
  "service-startup": "bash ./node_modules/@powerhousedao/ph-cli/dist/scripts/service-startup.sh",
198
249
  "service-unstartup": "bash ./node_modules/@powerhousedao/ph-cli/dist/scripts/service-unstartup.sh"
199
250
  };
@@ -242,15 +293,14 @@ const externalDevDependencies = {
242
293
  "@types/react": "^19.2.3",
243
294
  "@types/react-dom": "^19.2.3",
244
295
  "@vitejs/plugin-react": "^6.0.1",
245
- "@vitest/coverage-v8": "4.1.1",
246
- oxfmt: "0.55.0",
247
- oxlint: "1.70.0",
248
- "oxlint-tsgolint": "0.23.0",
296
+ "@vitest/coverage-v8": "5.0.3",
297
+ oxfmt: "0.68.0",
298
+ oxlint: "1.83.0",
299
+ "oxlint-tsgolint": "7.0.2001",
249
300
  tailwindcss: "^4.1.16",
250
- typescript: "^5.9.3",
301
+ typescript: "~7.0.2",
251
302
  vite: "^8.0.10",
252
- "vite-tsconfig-paths": "6.1.1",
253
- vitest: "4.1.1"
303
+ vitest: "5.0.3"
254
304
  };
255
305
  const defaultManifest = {
256
306
  name: "",
@@ -309,6 +359,28 @@ const buildArgs = {
309
359
  defaultValue: () => "dist",
310
360
  defaultValueIsSerializable: true
311
361
  }),
362
+ noSharedDeps: flag({
363
+ type: boolean,
364
+ long: "no-shared-deps",
365
+ description: "Bundle the shared dependency set instead of externalizing it (default: externalize)",
366
+ defaultValue: () => false,
367
+ defaultValueIsSerializable: true
368
+ }),
369
+ ignoreTypeErrors: flag({
370
+ type: boolean,
371
+ long: "ignore-type-errors",
372
+ description: "Unsafe: build even when tsc reports type errors, without asking. The package can load and still fail at runtime",
373
+ defaultValue: () => false,
374
+ defaultValueIsSerializable: true
375
+ }),
376
+ /** @experimental Builds for a release: the release check, then a release approval. */
377
+ release: flag({
378
+ type: boolean,
379
+ long: "release",
380
+ description: "Experimental: check every document model as for a release and stop the build, previous output intact, when the check finds them invalid or cannot run; then write the release approval ph publish verifies",
381
+ defaultValue: () => false,
382
+ defaultValueIsSerializable: true
383
+ }),
312
384
  ...debugArgs
313
385
  };
314
386
  const packageManagerArgs = {
@@ -357,10 +429,9 @@ const localPackage = option({
357
429
  env: "PH_LOCAL_PACKAGE"
358
430
  });
359
431
  const disableLocalPackages = flag({
360
- type: boolean,
432
+ type: optional(boolean),
361
433
  long: "ignore-local",
362
- description: "Do not load local packages from this project",
363
- defaultValue: () => false
434
+ description: "Do not load local packages from this project"
364
435
  });
365
436
  const httpsKeyFile = option({
366
437
  type: optional(string),
@@ -414,7 +485,7 @@ const vetraSwitchboardArgs = {
414
485
  const defaultDrivesUrl = option({
415
486
  type: optional(string),
416
487
  long: "default-drives-url",
417
- description: "The default drives url to use in connect",
488
+ description: "Comma-separated drive URLs to use as Connect's default drives.",
418
489
  defaultValue: () => ""
419
490
  });
420
491
  const logLevel = option({
@@ -551,7 +622,7 @@ const connectRuntimeOverrideArgs = {
551
622
  json: option({
552
623
  type: optional(string),
553
624
  long: "json",
554
- description: "Inline JSON override for the runtime connect.* block, e.g. '{\"renown\":{\"url\":\"...\"}}'. Validated against the runtime schema; deep-merged on top of env seeds and source powerhouse.config.json. Individual --flag values beat --json on collision."
625
+ description: "Inline JSON override for the runtime connect.* block, without the \"connect\" wrapper, e.g. '{\"app\":{\"workflowsEnabled\":true},\"renown\":{\"url\":\"...\"}}'. A top-level packageRegistryUrl is also accepted. Validated against the runtime schema (unknown keys fail); deep-merged on top of source powerhouse.config.json. Individual --flag values beat --json on collision."
555
626
  }),
556
627
  renownUrl: option({
557
628
  type: optional(string),
@@ -580,6 +651,11 @@ const connectRuntimeOverrideArgs = {
580
651
  long: "external-packages",
581
652
  description: "Override connect.packages.externalEnabled."
582
653
  }),
654
+ workflows: option({
655
+ type: optional(cliBoolean),
656
+ long: "workflows",
657
+ description: "Override connect.app.workflowsEnabled (load the @powerhousedao/workflow package: workflow + connection documents, their editors and Workflow Studio)."
658
+ }),
583
659
  remoteDrivesEnabled: option({
584
660
  type: optional(cliBoolean),
585
661
  long: "remote-drives-enabled",
@@ -623,7 +699,7 @@ const connectRuntimeOverrideArgs = {
623
699
  homeBackground: option({
624
700
  type: optional(string),
625
701
  long: "home-background",
626
- description: "Override connect.branding.homeBackground. URL or path to an image; pass an empty string (\"\") to reset to the bundled default."
702
+ description: "Override connect.home.background (the generic plugin's home screen). URL or path to an image, pinned bottom-right; pass an empty string (\"\") to reset to the bundled gradient."
627
703
  }),
628
704
  sentryDsn: option({
629
705
  type: optional(string),
@@ -671,7 +747,7 @@ const connectBuildArgs = {
671
747
  favicon: option({
672
748
  type: optional(string),
673
749
  long: "favicon",
674
- description: "Path to a favicon file (e.g. .ico) to bundle in place of the default Connect icon. Emitted as icon.ico; resolved relative to the build cwd."
750
+ description: "Path to a favicon file (e.g. .ico) to bundle in place of the default Connect icon. Emitted as icon.ico, or icon.svg/icon.png for those types; resolved relative to the build cwd."
675
751
  }),
676
752
  ...commonArgs
677
753
  };
@@ -801,6 +877,44 @@ const generateArgs = {
801
877
  long: "subgraph",
802
878
  description: "Subgraph name."
803
879
  }),
880
+ pieceName: option({
881
+ type: optional(string),
882
+ long: "piece",
883
+ description: "Piece name."
884
+ }),
885
+ pieceId: option({
886
+ type: optional(string),
887
+ long: "piece-id",
888
+ description: "Piece id, the pieceName a workflow step holds, e.g. @acme/piece-crm. Defaults to one derived from the package name."
889
+ }),
890
+ pieceAuth: option({
891
+ type: oneOf([
892
+ "none",
893
+ "secret",
894
+ "custom"
895
+ ]),
896
+ long: "piece-auth",
897
+ description: "The kind of connection the generated piece asks for. Default is custom.",
898
+ defaultValue: () => "custom",
899
+ defaultValueIsSerializable: true
900
+ }),
901
+ pieceActionName: option({
902
+ type: optional(string),
903
+ long: "piece-action",
904
+ description: "Name of an action to generate inside a piece."
905
+ }),
906
+ pieceTriggerName: option({
907
+ type: optional(string),
908
+ long: "piece-trigger",
909
+ description: "Name of a trigger to generate inside a piece."
910
+ }),
911
+ pieceTriggerStrategy: option({
912
+ type: oneOf(["polling", "webhook"]),
913
+ long: "piece-trigger-strategy",
914
+ description: "How a generated trigger fires. Default is polling.",
915
+ defaultValue: () => "polling",
916
+ defaultValueIsSerializable: true
917
+ }),
804
918
  importScriptName: option({
805
919
  type: optional(string),
806
920
  long: "import-script",
@@ -866,6 +980,52 @@ const generateArgs = {
866
980
  ...debugArgs
867
981
  };
868
982
  //#endregion
983
+ //#region clis/feature-flags.ts
984
+ /**
985
+ * Feature toggles shared by the CLIs (ph-cli and ph-cmd's dispatch/help).
986
+ * Hand-rolled env predicates by the CLI convention — deliberately no
987
+ * OpenFeature dependency here; that stack belongs to the runtime apps.
988
+ */
989
+ /**
990
+ * Gates the uniform-runners surface: the `ph run` command (registration,
991
+ * help listing, and ph-cmd forwarding), host-name sugar, and the `ph init`
992
+ * hosts/ scaffold. Off by default; set to `1` or `true` to enable. Rollout
993
+ * plan: docs/plans/2026-10-13-uniform-runners.md.
994
+ */
995
+ const UNIFORM_RUNNERS_FLAG = "FEATURE_UNIFORM_RUNNERS_ENABLED";
996
+ function isUniformRunnersEnabled(env = process.env) {
997
+ const value = env[UNIFORM_RUNNERS_FLAG]?.trim().toLowerCase();
998
+ return value === "1" || value === "true";
999
+ }
1000
+ //#endregion
1001
+ //#region clis/args/host.ts
1002
+ const hostCheckArgs = {
1003
+ host: positional({
1004
+ type: string,
1005
+ displayName: "host",
1006
+ description: "the host to check (a directory under hosts/)"
1007
+ }),
1008
+ envFile: option({
1009
+ type: optional(string),
1010
+ long: "env",
1011
+ description: "check against this env file alone instead of the project .env and the process env"
1012
+ }),
1013
+ verb: option({
1014
+ type: optional(string),
1015
+ long: "verb",
1016
+ description: "the verb to check at (default: run)"
1017
+ })
1018
+ };
1019
+ positional({
1020
+ type: string,
1021
+ displayName: "host",
1022
+ description: "the host to export (a directory under hosts/)"
1023
+ }), option({
1024
+ type: optional(string),
1025
+ long: "out",
1026
+ description: "write the JSON to this file instead of stdout"
1027
+ });
1028
+ //#endregion
869
1029
  //#region clis/args/inspect.ts
870
1030
  const inspectArgs = {
871
1031
  packageName: positional({
@@ -903,6 +1063,43 @@ const installArgs = {
903
1063
  ...debugArgs
904
1064
  };
905
1065
  //#endregion
1066
+ //#region clis/args/keyframes.ts
1067
+ const KEYFRAMES_ACTIONS = [
1068
+ "preview",
1069
+ "clean",
1070
+ "status",
1071
+ "cancel",
1072
+ "reclaim"
1073
+ ];
1074
+ const keyframesArgs = {
1075
+ action: positional({
1076
+ type: oneOf(KEYFRAMES_ACTIONS),
1077
+ displayName: "action",
1078
+ description: "preview: report what a clean-up would remove, without writing. clean: apply the configured keep and remove the keyframes of deleted documents (needs --yes). status: show the latest run and reclaim. cancel: stop a running clean-up. reclaim: rewrite the Keyframe table to give the space back to the disk."
1079
+ }),
1080
+ url: option({
1081
+ type: optional(string),
1082
+ long: "url",
1083
+ description: "The switchboard's GraphQL endpoint, e.g. http://localhost:4001/graphql. Defaults to reactor.port in powerhouse.config.json."
1084
+ }),
1085
+ token: option({
1086
+ type: optional(string),
1087
+ long: "token",
1088
+ description: "Admin bearer token. Defaults to PH_ACCESS_TOKEN, then a token from your `ph login` identity. Its address must be in the host's auth admins."
1089
+ }),
1090
+ yes: flag({
1091
+ type: optional(boolean),
1092
+ long: "yes",
1093
+ description: "Confirms a clean or a reclaim; both refuse to run without it."
1094
+ }),
1095
+ json: flag({
1096
+ type: optional(boolean),
1097
+ long: "json",
1098
+ description: "Print the result as JSON."
1099
+ }),
1100
+ ...debugArgs
1101
+ };
1102
+ //#endregion
906
1103
  //#region clis/args/list.ts
907
1104
  const listArgs = { ...debugArgs };
908
1105
  //#endregion
@@ -941,20 +1138,36 @@ const loginArgs = {
941
1138
  ...debugArgs
942
1139
  };
943
1140
  //#endregion
1141
+ //#region clis/args/mcp.ts
1142
+ const mcpArgs = {
1143
+ projectDir: option({
1144
+ type: optional(string),
1145
+ long: "project-dir",
1146
+ description: "Powerhouse project to serve. Defaults to the nearest directory above the working directory that holds powerhouse.config.json."
1147
+ }),
1148
+ startTimeout: option({
1149
+ type: number,
1150
+ long: "start-timeout",
1151
+ description: "Seconds to wait for Vetra to answer /ready after starting it on the first tool call",
1152
+ defaultValue: () => 120,
1153
+ defaultValueIsSerializable: true
1154
+ }),
1155
+ ...debugArgs
1156
+ };
1157
+ //#endregion
944
1158
  //#region clis/args/migrate.ts
1159
+ const versionDescription = "The version to migrate to. Accepts a valid semver version or `staging`, `dev`, `latest`. Defaults to the release channel of the project's installed Powerhouse packages.";
945
1160
  const migrateArgs = {
946
1161
  versionPositional: positional({
947
1162
  type: optional(string),
948
1163
  displayName: "version",
949
- description: "The version to migrate to. Accepts a valid semver version or `staging`, `dev`, `latest`."
1164
+ description: versionDescription
950
1165
  }),
951
1166
  version: option({
952
1167
  long: "version",
953
1168
  short: "v",
954
- type: string,
955
- description: "The version to migrate to. Accepts a valid semver version or `staging`, `dev`, `latest`.",
956
- defaultValue: () => "latest",
957
- defaultValueIsSerializable: true
1169
+ type: optional(string),
1170
+ description: versionDescription
958
1171
  }),
959
1172
  force: flag({
960
1173
  type: optional(boolean),
@@ -965,6 +1178,44 @@ const migrateArgs = {
965
1178
  ...debugArgs
966
1179
  };
967
1180
  //#endregion
1181
+ //#region clis/args/model.ts
1182
+ const json = flag({
1183
+ type: boolean,
1184
+ long: "json",
1185
+ description: "Print exactly one JSON report on stdout and nothing else",
1186
+ defaultValue: () => false,
1187
+ defaultValueIsSerializable: true
1188
+ });
1189
+ /**
1190
+ * @experimental Arguments of `ph model check`. Experimental while code-first
1191
+ * projects are introduced.
1192
+ */
1193
+ const modelCheckArgs = {
1194
+ /** @experimental Runs the release profile instead of the edit profile. */
1195
+ release: flag({
1196
+ type: boolean,
1197
+ long: "release",
1198
+ description: "Experimental: check as ph build --release does, with the release checks and host validation over every model. Writes nothing",
1199
+ defaultValue: () => false,
1200
+ defaultValueIsSerializable: true
1201
+ }),
1202
+ /** @experimental Verifies the release approval without loading the project. */
1203
+ prepack: flag({
1204
+ type: boolean,
1205
+ long: "prepack",
1206
+ description: "Experimental: without loading the package, exit 0 when the release approval ph build --release wrote matches it, 1 when it does not, and 2 when it cannot be checked. For a \"prepack\" script, so npm publish stops too",
1207
+ defaultValue: () => false,
1208
+ defaultValueIsSerializable: true
1209
+ }),
1210
+ json,
1211
+ ...debugArgs
1212
+ };
1213
+ positional({
1214
+ type: optional(string),
1215
+ displayName: "documentType@version",
1216
+ description: "Inspect one model version, such as acme/invoice@1 (default: every model)"
1217
+ }), { ...debugArgs };
1218
+ //#endregion
968
1219
  //#region clis/args/publish.ts
969
1220
  const publishArgs = {
970
1221
  registry: option({
@@ -972,6 +1223,14 @@ const publishArgs = {
972
1223
  long: "registry",
973
1224
  description: "Registry URL to publish to (overrides config and environment)"
974
1225
  }),
1226
+ /** @experimental Refuses to publish a package without a current release approval. */
1227
+ requireApproval: flag({
1228
+ type: boolean,
1229
+ long: "require-approval",
1230
+ description: "Experimental: publish only when the release approval that ph build --release wrote matches this package; otherwise exit 1 before contacting the registry. Forwards only --tag, --access, --otp, --dry-run, --provenance, --json and --loglevel to npm, refuses npm configuration in the environment that selects another package (npm_config_workspace, npm_config_workspaces, npm_config_include_workspace_root), and publishes with --ignore-scripts so lifecycle scripts cannot change the files it checked",
1231
+ defaultValue: () => false,
1232
+ defaultValueIsSerializable: true
1233
+ }),
975
1234
  ...debugArgs,
976
1235
  forwardedArgs: rest({
977
1236
  displayName: "npm-args",
@@ -997,6 +1256,30 @@ const registryLoginArgs = {
997
1256
  ...debugArgs
998
1257
  };
999
1258
  //#endregion
1259
+ //#region clis/args/run.ts
1260
+ const runArgs = {
1261
+ host: positional({
1262
+ type: string,
1263
+ displayName: "host",
1264
+ description: "the host to run (a directory under hosts/)"
1265
+ }),
1266
+ verb: positional({
1267
+ type: optional(string),
1268
+ displayName: "verb",
1269
+ description: "optional verb the runner forwards (dev, build, serve, …)"
1270
+ }),
1271
+ debug: flag({
1272
+ type: optional(boolean),
1273
+ long: "debug",
1274
+ description: "verbose runner diagnostics"
1275
+ }),
1276
+ explain: option({
1277
+ type: optional(string),
1278
+ long: "explain",
1279
+ description: "explain a resolved aspect instead of running (drives, outputs)"
1280
+ })
1281
+ };
1282
+ //#endregion
1000
1283
  //#region clis/args/switchboard.ts
1001
1284
  const switchboardArgs = {
1002
1285
  ...vetraSwitchboardArgs,
@@ -1011,7 +1294,7 @@ const switchboardArgs = {
1011
1294
  basePath: option({
1012
1295
  type: optional(string),
1013
1296
  long: "base-path",
1014
- description: "base path for the API endpoints (sets the BASE_PATH environment variable)"
1297
+ description: "base path for the API endpoints (overrides BASE_PATH)"
1015
1298
  }),
1016
1299
  keypairPath: option({
1017
1300
  type: optional(string),
@@ -1090,6 +1373,13 @@ const uninstallArgs = {
1090
1373
  //#endregion
1091
1374
  //#region clis/project-env.ts
1092
1375
  let loadedFor;
1376
+ let namesBeforeLoad;
1377
+ /** `PH_NO_DOTENV=1` (or `true`): no `.env` file is read, so a launcher's
1378
+ * explicit environment is the whole environment. */
1379
+ function isDotenvDisabled(env = process.env) {
1380
+ const value = env.PH_NO_DOTENV?.trim().toLowerCase();
1381
+ return value === "1" || value === "true";
1382
+ }
1093
1383
  /**
1094
1384
  * Load the project's `.env.local` and `.env` into `process.env`.
1095
1385
  *
@@ -1103,8 +1393,10 @@ let loadedFor;
1103
1393
  * call it more than once per process.
1104
1394
  */
1105
1395
  function loadProjectEnv(cwd = process.cwd()) {
1396
+ if (isDotenvDisabled()) return;
1106
1397
  if (loadedFor === cwd) return;
1107
1398
  loadedFor = cwd;
1399
+ namesBeforeLoad ??= new Set(Object.keys(process.env));
1108
1400
  dotenv.config({ path: join(cwd, ".env.local") });
1109
1401
  dotenv.config({ path: join(cwd, ".env") });
1110
1402
  }
@@ -1177,6 +1469,13 @@ const vetraArgs = {
1177
1469
  defaultValue: () => false,
1178
1470
  defaultValueIsSerializable: true
1179
1471
  }),
1472
+ restart: flag({
1473
+ type: boolean,
1474
+ long: "restart",
1475
+ description: "Stop this project's running Vetra first (the pid in .ph/vetra-runtime.json), then start",
1476
+ defaultValue: () => false,
1477
+ defaultValueIsSerializable: true
1478
+ }),
1180
1479
  disableConnect: flag({
1181
1480
  type: boolean,
1182
1481
  long: "disable-connect",
@@ -1209,6 +1508,8 @@ const vetraArgs = {
1209
1508
  //#endregion
1210
1509
  //#region clis/command-names.ts
1211
1510
  const phCliCommandNames = [
1511
+ "run",
1512
+ "host",
1212
1513
  "generate",
1213
1514
  "vetra",
1214
1515
  "connect",
@@ -1220,7 +1521,10 @@ const phCliCommandNames = [
1220
1521
  "registry-login",
1221
1522
  "inspect",
1222
1523
  "is",
1524
+ "keyframes",
1525
+ "mcp",
1223
1526
  "migrate",
1527
+ "model",
1224
1528
  "switchboard",
1225
1529
  "reactor",
1226
1530
  "login",
@@ -1243,7 +1547,19 @@ function helpCommand(config) {
1243
1547
  aliases
1244
1548
  });
1245
1549
  }
1246
- const phCliHelpCommands = {
1550
+ const allPhCliHelpCommands = {
1551
+ run: helpCommand({
1552
+ name: "run",
1553
+ args: runArgs,
1554
+ description: "Run a host from hosts/ with its runner",
1555
+ handler: () => {}
1556
+ }),
1557
+ host: helpCommand({
1558
+ name: "host",
1559
+ args: hostCheckArgs,
1560
+ description: "Check or export a host from hosts/: `ph host check|export <host>`",
1561
+ handler: () => {}
1562
+ }),
1247
1563
  generate: helpCommand({
1248
1564
  name: "generate",
1249
1565
  args: generateArgs,
@@ -1300,12 +1616,30 @@ const phCliHelpCommands = {
1300
1616
  description: "Inspect a package",
1301
1617
  handler: () => {}
1302
1618
  }),
1619
+ mcp: helpCommand({
1620
+ name: "mcp",
1621
+ args: mcpArgs,
1622
+ description: "Serve the project's reactor-mcp tools over stdio, starting Vetra on the first tool call",
1623
+ handler: () => {}
1624
+ }),
1625
+ keyframes: helpCommand({
1626
+ name: "keyframes",
1627
+ args: keyframesArgs,
1628
+ description: "Report on and clean up the keyframes of a running switchboard",
1629
+ handler: () => {}
1630
+ }),
1303
1631
  migrate: helpCommand({
1304
1632
  name: "migrate",
1305
1633
  args: migrateArgs,
1306
1634
  description: "Run migrations",
1307
1635
  handler: () => {}
1308
1636
  }),
1637
+ model: helpCommand({
1638
+ name: "model",
1639
+ args: modelCheckArgs,
1640
+ description: "Check or inspect this package's document models (experimental): `ph model check|inspect`",
1641
+ handler: () => {}
1642
+ }),
1309
1643
  switchboard: helpCommand({
1310
1644
  name: "switchboard",
1311
1645
  aliases: ["reactor"],
@@ -1340,6 +1674,7 @@ const phCliHelpCommands = {
1340
1674
  handler: () => {}
1341
1675
  })
1342
1676
  };
1677
+ const phCliHelpCommands = isUniformRunnersEnabled() ? allPhCliHelpCommands : (({ run: _run, host: _host, ...rest }) => rest)(allPhCliHelpCommands);
1343
1678
  //#endregion
1344
1679
  //#region clis/args/init.ts
1345
1680
  const initArgs = {
@@ -1355,6 +1690,12 @@ const initArgs = {
1355
1690
  description: "The name of your project. A new directory will be created in your current directory with this name."
1356
1691
  }),
1357
1692
  ...packageManagerArgs,
1693
+ packageManager: option({
1694
+ type: optional(oneOf(AGENTS)),
1695
+ long: "package-manager",
1696
+ short: "p",
1697
+ description: "Package manager that installs the project: `npm`, `pnpm`, `yarn` or `bun`. Defaults to the one that launched ph (npx, pnpm dlx, bunx), else the one that installed ph (unless npm), else bun, then pnpm 10.14 or later if installed, else npm."
1698
+ }),
1358
1699
  tag: option({
1359
1700
  type: optional(oneOf([
1360
1701
  "latest",
@@ -1395,10 +1736,15 @@ const initArgs = {
1395
1736
  short: "r",
1396
1737
  description: "Remote drive identifier."
1397
1738
  }),
1739
+ uniformRunners: flag({
1740
+ type: optional(boolean),
1741
+ long: "uniform-runners",
1742
+ description: "Scaffold the hosts/ folder (uniform-runners architecture). Also enabled project-wide by FEATURE_UNIFORM_RUNNERS_ENABLED."
1743
+ }),
1398
1744
  clone: option({
1399
1745
  type: optional(string),
1400
1746
  long: "clone",
1401
- description: "Path to an existing scaffolded project to clone instead of resolving deps from scratch. Install runs offline from the cloned project's pnpm-lock.yaml (requires --pnpm; --version/--tag are ignored)."
1747
+ description: "Path to an existing scaffolded project to clone instead of resolving deps from scratch. Install runs offline from the cloned project's lockfile: pnpm-lock.yaml with pnpm, package-lock.json with npm (other package managers are refused; --version/--tag are ignored)."
1402
1748
  }),
1403
1749
  ...debugArgs
1404
1750
  };
@@ -1434,9 +1780,44 @@ const unpublishArgs = {
1434
1780
  })
1435
1781
  };
1436
1782
  //#endregion
1783
+ //#region clis/ph-dir.ts
1784
+ /**
1785
+ * The project's `.ph` tree — stores, identity, run records, registry cache.
1786
+ *
1787
+ * Classically `<cwd>/.ph` (every classic command resolves it exactly so). A
1788
+ * desktop shell relocates the WHOLE tree under the user's profile by setting
1789
+ * `PH_USER_DATA_DIR`: the tree is then `${userData}/.ph`, the same names
1790
+ * under a different root, and nothing of the user's lands in the install
1791
+ * dir. One resolver replaces the former `.ph/...` literals; it adds no path
1792
+ * names and no layout of its own.
1793
+ */
1794
+ function resolvePhDir(base = process.cwd(), env = process.env) {
1795
+ return path.join(env.PH_USER_DATA_DIR ?? base, ".ph");
1796
+ }
1797
+ /**
1798
+ * The two PGlite store dirs the switchboard defaults to, for the server and
1799
+ * for `ph switchboard --reset` (which must touch the same paths). Without a
1800
+ * user-data root these are the classic literals, verbatim — byte-identical
1801
+ * to every classic boot log and reset prompt. Under PH_USER_DATA_DIR they
1802
+ * are the same names inside `${userData}/.ph`.
1803
+ */
1804
+ function defaultStoreDirs(env = process.env, phDir) {
1805
+ const root = phDir ?? (env.PH_USER_DATA_DIR ? resolvePhDir(void 0, env) : void 0);
1806
+ if (root === void 0) return {
1807
+ reactor: "./.ph/reactor-storage",
1808
+ readModel: ".ph/read-storage"
1809
+ };
1810
+ return {
1811
+ reactor: path.join(root, "reactor-storage"),
1812
+ readModel: path.join(root, "read-storage")
1813
+ };
1814
+ }
1815
+ //#endregion
1437
1816
  //#region ../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js
1438
1817
  var require_picocolors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1439
- let p = process || {}, argv = p.argv || [], env = p.env || {};
1818
+ let p = process || {};
1819
+ let argv = p.argv || [];
1820
+ let env = p.env || {};
1440
1821
  let isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
1441
1822
  let formatter = (open, close, replace = open) => (input) => {
1442
1823
  let string = "" + input, index = string.indexOf(close, open.length);
@@ -1524,7 +1905,7 @@ var require_js_tokens = /* @__PURE__ */ __commonJSMin(((exports) => {
1524
1905
  };
1525
1906
  }));
1526
1907
  //#endregion
1527
- //#region ../../node_modules/.pnpm/@babel+helper-validator-identifier@7.28.5/node_modules/@babel/helper-validator-identifier/lib/identifier.js
1908
+ //#region ../../node_modules/.pnpm/@babel+helper-validator-identifier@7.29.7/node_modules/@babel/helper-validator-identifier/lib/identifier.js
1528
1909
  var require_identifier = /* @__PURE__ */ __commonJSMin(((exports) => {
1529
1910
  Object.defineProperty(exports, "__esModule", { value: true });
1530
1911
  exports.isIdentifierChar = isIdentifierChar;
@@ -2532,7 +2913,7 @@ var require_identifier = /* @__PURE__ */ __commonJSMin(((exports) => {
2532
2913
  }
2533
2914
  }));
2534
2915
  //#endregion
2535
- //#region ../../node_modules/.pnpm/@babel+helper-validator-identifier@7.28.5/node_modules/@babel/helper-validator-identifier/lib/keyword.js
2916
+ //#region ../../node_modules/.pnpm/@babel+helper-validator-identifier@7.29.7/node_modules/@babel/helper-validator-identifier/lib/keyword.js
2536
2917
  var require_keyword = /* @__PURE__ */ __commonJSMin(((exports) => {
2537
2918
  Object.defineProperty(exports, "__esModule", { value: true });
2538
2919
  exports.isKeyword = isKeyword;
@@ -2611,7 +2992,7 @@ var require_keyword = /* @__PURE__ */ __commonJSMin(((exports) => {
2611
2992
  }
2612
2993
  }));
2613
2994
  //#endregion
2614
- //#region ../../node_modules/.pnpm/@babel+helper-validator-identifier@7.28.5/node_modules/@babel/helper-validator-identifier/lib/index.js
2995
+ //#region ../../node_modules/.pnpm/@babel+helper-validator-identifier@7.29.7/node_modules/@babel/helper-validator-identifier/lib/index.js
2615
2996
  var require_lib$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
2616
2997
  Object.defineProperty(exports, "__esModule", { value: true });
2617
2998
  Object.defineProperty(exports, "isIdentifierChar", {
@@ -2698,7 +3079,7 @@ var import_lib = (/* @__PURE__ */ __commonJSMin(((exports) => {
2698
3079
  function getDefs(enabled) {
2699
3080
  return enabled ? defsOn : defsOff;
2700
3081
  }
2701
- const sometimesKeywords = new Set([
3082
+ const sometimesKeywords = /* @__PURE__ */ new Set([
2702
3083
  "as",
2703
3084
  "async",
2704
3085
  "from",
@@ -2765,9 +3146,10 @@ var import_lib = (/* @__PURE__ */ __commonJSMin(((exports) => {
2765
3146
  else if (i === lineDiff) markerLines[lineNumber] = [0, endColumn];
2766
3147
  else markerLines[lineNumber] = [0, source[lineNumber - i].length];
2767
3148
  }
2768
- else if (startColumn === endColumn) if (startColumn) markerLines[startLine] = [startColumn, 0];
2769
- else markerLines[startLine] = true;
2770
- else markerLines[startLine] = [startColumn, endColumn - startColumn];
3149
+ else if (startColumn === endColumn) {
3150
+ if (startColumn) markerLines[startLine] = [startColumn, 0];
3151
+ else markerLines[startLine] = true;
3152
+ } else markerLines[startLine] = [startColumn, endColumn - startColumn];
2771
3153
  return {
2772
3154
  start,
2773
3155
  end,
@@ -4227,49 +4609,47 @@ var require_validate_npm_package_license = /* @__PURE__ */ __commonJSMin(((expor
4227
4609
  };
4228
4610
  }));
4229
4611
  //#endregion
4230
- //#region ../../node_modules/.pnpm/lru-cache@11.2.7/node_modules/lru-cache/dist/commonjs/index.min.js
4612
+ //#region ../../node_modules/.pnpm/lru-cache@11.5.0/node_modules/lru-cache/dist/commonjs/node/index.min.js
4231
4613
  var require_index_min = /* @__PURE__ */ __commonJSMin(((exports) => {
4614
+ var j = (c, t) => () => (t || c((t = { exports: {} }).exports, t), t.exports);
4615
+ var I = j((O) => {
4616
+ "use strict";
4617
+ Object.defineProperty(O, "__esModule", { value: !0 });
4618
+ O.tracing = O.metrics = void 0;
4619
+ var U = __require("node:diagnostics_channel");
4620
+ O.metrics = (0, U.channel)("lru-cache:metrics");
4621
+ O.tracing = (0, U.tracingChannel)("lru-cache");
4622
+ });
4623
+ var P = j((D) => {
4624
+ "use strict";
4625
+ Object.defineProperty(D, "__esModule", { value: !0 });
4626
+ D.defaultPerf = void 0;
4627
+ D.defaultPerf = typeof performance == "object" && performance && typeof performance.now == "function" ? performance : Date;
4628
+ });
4232
4629
  Object.defineProperty(exports, "__esModule", { value: !0 });
4233
4630
  exports.LRUCache = void 0;
4234
- var G = typeof performance == "object" && performance && typeof performance.now == "function" ? performance : Date, U = /* @__PURE__ */ new Set(), R = typeof process == "object" && process ? process : {}, I = (c, t, e, i) => {
4235
- typeof R.emitWarning == "function" ? R.emitWarning(c, t, e, i) : console.error(`[${e}] ${t}: ${c}`);
4236
- }, C = globalThis.AbortController, L = globalThis.AbortSignal;
4237
- if (typeof C > "u") {
4238
- L = class {
4239
- onabort;
4240
- _onabort = [];
4241
- reason;
4242
- aborted = !1;
4243
- addEventListener(i, s) {
4244
- this._onabort.push(s);
4245
- }
4246
- }, C = class {
4247
- constructor() {
4248
- t();
4249
- }
4250
- signal = new L();
4251
- abort(i) {
4252
- if (!this.signal.aborted) {
4253
- this.signal.reason = i, this.signal.aborted = !0;
4254
- for (let s of this.signal._onabort) s(i);
4255
- this.signal.onabort?.(i);
4256
- }
4257
- }
4258
- };
4259
- let c = R.env?.LRU_CACHE_IGNORE_AC_WARNING !== "1", t = () => {
4260
- c && (c = !1, I("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.", "NO_ABORT_CONTROLLER", "ENOTSUP", t));
4261
- };
4262
- }
4263
- var x = (c) => !U.has(c), y = (c) => c && c === Math.floor(c) && c > 0 && isFinite(c), M = (c) => y(c) ? c <= Math.pow(2, 8) ? Uint8Array : c <= Math.pow(2, 16) ? Uint16Array : c <= Math.pow(2, 32) ? Uint32Array : c <= Number.MAX_SAFE_INTEGER ? z : null : null, z = class extends Array {
4631
+ var g = I();
4632
+ var N = P();
4633
+ var C = () => g.metrics.hasSubscribers || g.tracing.hasSubscribers;
4634
+ var k = /* @__PURE__ */ new Set();
4635
+ var G = typeof process == "object" && process ? process : {};
4636
+ var V = (c, t, e, i) => {
4637
+ typeof G.emitWarning == "function" ? G.emitWarning(c, t, e, i) : console.error(`[${e}] ${t}: ${c}`);
4638
+ };
4639
+ var q = (c) => !k.has(c);
4640
+ var T = (c) => !!c && c === Math.floor(c) && c > 0 && isFinite(c);
4641
+ var H = (c) => T(c) ? c <= Math.pow(2, 8) ? Uint8Array : c <= Math.pow(2, 16) ? Uint16Array : c <= Math.pow(2, 32) ? Uint32Array : c <= Number.MAX_SAFE_INTEGER ? W : null : null;
4642
+ var W = class extends Array {
4264
4643
  constructor(t) {
4265
4644
  super(t), this.fill(0);
4266
4645
  }
4267
- }, W = class c {
4646
+ };
4647
+ var x = class c {
4268
4648
  heap;
4269
4649
  length;
4270
4650
  static #o = !1;
4271
4651
  static create(t) {
4272
- let e = M(t);
4652
+ let e = H(t);
4273
4653
  if (!e) return [];
4274
4654
  c.#o = !0;
4275
4655
  let i = new c(t, e);
@@ -4289,14 +4669,14 @@ var require_index_min = /* @__PURE__ */ __commonJSMin(((exports) => {
4289
4669
  exports.LRUCache = class c {
4290
4670
  #o;
4291
4671
  #c;
4292
- #w;
4293
- #C;
4294
- #S;
4295
- #L;
4296
- #U;
4297
4672
  #m;
4673
+ #W;
4674
+ #S;
4675
+ #M;
4676
+ #j;
4677
+ #w;
4298
4678
  get perf() {
4299
- return this.#m;
4679
+ return this.#w;
4300
4680
  }
4301
4681
  ttl;
4302
4682
  ttlResolution;
@@ -4313,48 +4693,49 @@ var require_index_min = /* @__PURE__ */ __commonJSMin(((exports) => {
4313
4693
  allowStaleOnFetchAbort;
4314
4694
  allowStaleOnFetchRejection;
4315
4695
  ignoreFetchAbort;
4696
+ backgroundFetchSize;
4316
4697
  #n;
4317
- #_;
4698
+ #b;
4318
4699
  #s;
4319
4700
  #i;
4320
4701
  #t;
4321
- #a;
4322
- #u;
4323
4702
  #l;
4703
+ #u;
4704
+ #a;
4324
4705
  #h;
4325
- #b;
4706
+ #_;
4326
4707
  #r;
4327
4708
  #y;
4328
- #A;
4709
+ #F;
4329
4710
  #d;
4330
4711
  #g;
4331
4712
  #T;
4332
- #v;
4713
+ #U;
4333
4714
  #f;
4334
- #I;
4715
+ #D;
4335
4716
  static unsafeExposeInternals(t) {
4336
4717
  return {
4337
- starts: t.#A,
4718
+ starts: t.#F,
4338
4719
  ttls: t.#d,
4339
4720
  autopurgeTimers: t.#g,
4340
4721
  sizes: t.#y,
4341
4722
  keyMap: t.#s,
4342
4723
  keyList: t.#i,
4343
4724
  valList: t.#t,
4344
- next: t.#a,
4725
+ next: t.#l,
4345
4726
  prev: t.#u,
4346
4727
  get head() {
4347
- return t.#l;
4728
+ return t.#a;
4348
4729
  },
4349
4730
  get tail() {
4350
4731
  return t.#h;
4351
4732
  },
4352
- free: t.#b,
4733
+ free: t.#_,
4353
4734
  isBackgroundFetch: (e) => t.#e(e),
4354
- backgroundFetch: (e, i, s, n) => t.#x(e, i, s, n),
4355
- moveToTail: (e) => t.#D(e),
4356
- indexes: (e) => t.#F(e),
4357
- rindexes: (e) => t.#O(e),
4735
+ backgroundFetch: (e, i, s, n) => t.#G(e, i, s, n),
4736
+ moveToTail: (e) => t.#L(e),
4737
+ indexes: (e) => t.#A(e),
4738
+ rindexes: (e) => t.#z(e),
4358
4739
  isStale: (e) => t.#p(e)
4359
4740
  };
4360
4741
  }
@@ -4365,188 +4746,190 @@ var require_index_min = /* @__PURE__ */ __commonJSMin(((exports) => {
4365
4746
  return this.#c;
4366
4747
  }
4367
4748
  get calculatedSize() {
4368
- return this.#_;
4749
+ return this.#b;
4369
4750
  }
4370
4751
  get size() {
4371
4752
  return this.#n;
4372
4753
  }
4373
4754
  get fetchMethod() {
4374
- return this.#L;
4755
+ return this.#M;
4375
4756
  }
4376
4757
  get memoMethod() {
4377
- return this.#U;
4758
+ return this.#j;
4378
4759
  }
4379
4760
  get dispose() {
4380
- return this.#w;
4761
+ return this.#m;
4381
4762
  }
4382
4763
  get onInsert() {
4383
- return this.#C;
4764
+ return this.#W;
4384
4765
  }
4385
4766
  get disposeAfter() {
4386
4767
  return this.#S;
4387
4768
  }
4388
4769
  constructor(t) {
4389
- let { max: e = 0, ttl: i, ttlResolution: s = 1, ttlAutopurge: n, updateAgeOnGet: o, updateAgeOnHas: h, allowStale: r, dispose: a, onInsert: w, disposeAfter: f, noDisposeOnSet: d, noUpdateTTL: g, maxSize: A = 0, maxEntrySize: p = 0, sizeCalculation: _, fetchMethod: l, memoMethod: S, noDeleteOnFetchRejection: b, noDeleteOnStaleGet: m, allowStaleOnFetchRejection: u, allowStaleOnFetchAbort: T, ignoreFetchAbort: F, perf: v } = t;
4390
- if (v !== void 0 && typeof v?.now != "function") throw new TypeError("perf option must have a now() method if specified");
4391
- if (this.#m = v ?? G, e !== 0 && !y(e)) throw new TypeError("max option must be a nonnegative integer");
4392
- let O = e ? M(e) : Array;
4393
- if (!O) throw new Error("invalid max value: " + e);
4394
- if (this.#o = e, this.#c = A, this.maxEntrySize = p || this.#c, this.sizeCalculation = _, this.sizeCalculation) {
4770
+ let { max: e = 0, ttl: i, ttlResolution: s = 1, ttlAutopurge: n, updateAgeOnGet: r, updateAgeOnHas: h, allowStale: a, dispose: o, onInsert: d, disposeAfter: _, noDisposeOnSet: y, noUpdateTTL: u, maxSize: p = 0, maxEntrySize: f = 0, sizeCalculation: b, fetchMethod: l, memoMethod: S, noDeleteOnFetchRejection: F, noDeleteOnStaleGet: w, allowStaleOnFetchRejection: m, allowStaleOnFetchAbort: A, ignoreFetchAbort: z, backgroundFetchSize: M = 1, perf: v } = t;
4771
+ if (this.backgroundFetchSize = M, v !== void 0 && typeof v?.now != "function") throw new TypeError("perf option must have a now() method if specified");
4772
+ if (this.#w = v ?? N.defaultPerf, e !== 0 && !T(e)) throw new TypeError("max option must be a nonnegative integer");
4773
+ let E = e ? H(e) : Array;
4774
+ if (!E) throw new Error("invalid max value: " + e);
4775
+ if (this.#o = e, this.#c = p, this.maxEntrySize = f || this.#c, this.sizeCalculation = b, this.sizeCalculation) {
4395
4776
  if (!this.#c && !this.maxEntrySize) throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");
4396
4777
  if (typeof this.sizeCalculation != "function") throw new TypeError("sizeCalculation set to non-function");
4397
4778
  }
4398
4779
  if (S !== void 0 && typeof S != "function") throw new TypeError("memoMethod must be a function if defined");
4399
- if (this.#U = S, l !== void 0 && typeof l != "function") throw new TypeError("fetchMethod must be a function if specified");
4400
- if (this.#L = l, this.#v = !!l, this.#s = /* @__PURE__ */ new Map(), this.#i = new Array(e).fill(void 0), this.#t = new Array(e).fill(void 0), this.#a = new O(e), this.#u = new O(e), this.#l = 0, this.#h = 0, this.#b = W.create(e), this.#n = 0, this.#_ = 0, typeof a == "function" && (this.#w = a), typeof w == "function" && (this.#C = w), typeof f == "function" ? (this.#S = f, this.#r = []) : (this.#S = void 0, this.#r = void 0), this.#T = !!this.#w, this.#I = !!this.#C, this.#f = !!this.#S, this.noDisposeOnSet = !!d, this.noUpdateTTL = !!g, this.noDeleteOnFetchRejection = !!b, this.allowStaleOnFetchRejection = !!u, this.allowStaleOnFetchAbort = !!T, this.ignoreFetchAbort = !!F, this.maxEntrySize !== 0) {
4401
- if (this.#c !== 0 && !y(this.#c)) throw new TypeError("maxSize must be a positive integer if specified");
4402
- if (!y(this.maxEntrySize)) throw new TypeError("maxEntrySize must be a positive integer if specified");
4403
- this.#B();
4780
+ if (this.#j = S, l !== void 0 && typeof l != "function") throw new TypeError("fetchMethod must be a function if specified");
4781
+ if (this.#M = l, this.#U = !!l, this.#s = /* @__PURE__ */ new Map(), this.#i = Array.from({ length: e }).fill(void 0), this.#t = Array.from({ length: e }).fill(void 0), this.#l = new E(e), this.#u = new E(e), this.#a = 0, this.#h = 0, this.#_ = x.create(e), this.#n = 0, this.#b = 0, typeof o == "function" && (this.#m = o), typeof d == "function" && (this.#W = d), typeof _ == "function" ? (this.#S = _, this.#r = []) : (this.#S = void 0, this.#r = void 0), this.#T = !!this.#m, this.#D = !!this.#W, this.#f = !!this.#S, this.noDisposeOnSet = !!y, this.noUpdateTTL = !!u, this.noDeleteOnFetchRejection = !!F, this.allowStaleOnFetchRejection = !!m, this.allowStaleOnFetchAbort = !!A, this.ignoreFetchAbort = !!z, this.maxEntrySize !== 0) {
4782
+ if (this.#c !== 0 && !T(this.#c)) throw new TypeError("maxSize must be a positive integer if specified");
4783
+ if (!T(this.maxEntrySize)) throw new TypeError("maxEntrySize must be a positive integer if specified");
4784
+ this.#X();
4404
4785
  }
4405
- if (this.allowStale = !!r, this.noDeleteOnStaleGet = !!m, this.updateAgeOnGet = !!o, this.updateAgeOnHas = !!h, this.ttlResolution = y(s) || s === 0 ? s : 1, this.ttlAutopurge = !!n, this.ttl = i || 0, this.ttl) {
4406
- if (!y(this.ttl)) throw new TypeError("ttl must be a positive integer if specified");
4407
- this.#j();
4786
+ if (this.allowStale = !!a, this.noDeleteOnStaleGet = !!w, this.updateAgeOnGet = !!r, this.updateAgeOnHas = !!h, this.ttlResolution = T(s) || s === 0 ? s : 1, this.ttlAutopurge = !!n, this.ttl = i || 0, this.ttl) {
4787
+ if (!T(this.ttl)) throw new TypeError("ttl must be a positive integer if specified");
4788
+ this.#k();
4408
4789
  }
4409
4790
  if (this.#o === 0 && this.ttl === 0 && this.#c === 0) throw new TypeError("At least one of max, maxSize, or ttl is required");
4410
4791
  if (!this.ttlAutopurge && !this.#o && !this.#c) {
4411
- let E = "LRU_CACHE_UNBOUNDED";
4412
- x(E) && (U.add(E), I("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.", "UnboundedCacheWarning", E, c));
4792
+ let R = "LRU_CACHE_UNBOUNDED";
4793
+ q(R) && (k.add(R), V("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.", "UnboundedCacheWarning", R, c));
4413
4794
  }
4414
4795
  }
4415
4796
  getRemainingTTL(t) {
4416
- return this.#s.has(t) ? Infinity : 0;
4417
- }
4418
- #j() {
4419
- let t = new z(this.#o), e = new z(this.#o);
4420
- this.#d = t, this.#A = e;
4421
- let i = this.ttlAutopurge ? new Array(this.#o) : void 0;
4422
- this.#g = i, this.#N = (h, r, a = this.#m.now()) => {
4423
- e[h] = r !== 0 ? a : 0, t[h] = r, s(h, r);
4797
+ return this.#s.has(t) ? 1 / 0 : 0;
4798
+ }
4799
+ #k() {
4800
+ let t = new W(this.#o), e = new W(this.#o);
4801
+ this.#d = t, this.#F = e;
4802
+ let i = this.ttlAutopurge ? Array.from({ length: this.#o }) : void 0;
4803
+ this.#g = i, this.#H = (h, a, o = this.#w.now()) => {
4804
+ e[h] = a !== 0 ? o : 0, t[h] = a, s(h, a);
4424
4805
  }, this.#R = (h) => {
4425
- e[h] = t[h] !== 0 ? this.#m.now() : 0, s(h, t[h]);
4806
+ e[h] = t[h] !== 0 ? this.#w.now() : 0, s(h, t[h]);
4426
4807
  };
4427
- let s = this.ttlAutopurge ? (h, r) => {
4428
- if (i?.[h] && (clearTimeout(i[h]), i[h] = void 0), r && r !== 0 && i) {
4429
- let a = setTimeout(() => {
4430
- this.#p(h) && this.#E(this.#i[h], "expire");
4431
- }, r + 1);
4432
- a.unref && a.unref(), i[h] = a;
4808
+ let s = this.ttlAutopurge ? (h, a) => {
4809
+ if (i?.[h] && (clearTimeout(i[h]), i[h] = void 0), a && a !== 0 && i) {
4810
+ let o = setTimeout(() => {
4811
+ this.#p(h) && this.#v(this.#i[h], "expire");
4812
+ }, a + 1);
4813
+ o.unref && o.unref(), i[h] = o;
4433
4814
  }
4434
4815
  } : () => {};
4435
- this.#z = (h, r) => {
4436
- if (t[r]) {
4437
- let a = t[r], w = e[r];
4438
- if (!a || !w) return;
4439
- h.ttl = a, h.start = w, h.now = n || o();
4440
- h.remainingTTL = a - (h.now - w);
4816
+ this.#E = (h, a) => {
4817
+ if (t[a]) {
4818
+ let o = t[a], d = e[a];
4819
+ if (!o || !d) return;
4820
+ h.ttl = o, h.start = d, h.now = n || r();
4821
+ h.remainingTTL = o - (h.now - d);
4441
4822
  }
4442
4823
  };
4443
- let n = 0, o = () => {
4444
- let h = this.#m.now();
4824
+ let n = 0, r = () => {
4825
+ let h = this.#w.now();
4445
4826
  if (this.ttlResolution > 0) {
4446
4827
  n = h;
4447
- let r = setTimeout(() => n = 0, this.ttlResolution);
4448
- r.unref && r.unref();
4828
+ let a = setTimeout(() => n = 0, this.ttlResolution);
4829
+ a.unref && a.unref();
4449
4830
  }
4450
4831
  return h;
4451
4832
  };
4452
4833
  this.getRemainingTTL = (h) => {
4453
- let r = this.#s.get(h);
4454
- if (r === void 0) return 0;
4455
- let a = t[r], w = e[r];
4456
- if (!a || !w) return Infinity;
4457
- return a - ((n || o()) - w);
4834
+ let a = this.#s.get(h);
4835
+ if (a === void 0) return 0;
4836
+ let o = t[a], d = e[a];
4837
+ if (!o || !d) return 1 / 0;
4838
+ return o - ((n || r()) - d);
4458
4839
  }, this.#p = (h) => {
4459
- let r = e[h], a = t[h];
4460
- return !!a && !!r && (n || o()) - r > a;
4840
+ let a = e[h], o = t[h];
4841
+ return !!o && !!a && (n || r()) - a > o;
4461
4842
  };
4462
4843
  }
4463
4844
  #R = () => {};
4464
- #z = () => {};
4465
- #N = () => {};
4845
+ #E = () => {};
4846
+ #H = () => {};
4466
4847
  #p = () => !1;
4467
- #B() {
4468
- let t = new z(this.#o);
4469
- this.#_ = 0, this.#y = t, this.#W = (e) => {
4470
- this.#_ -= t[e], t[e] = 0;
4471
- }, this.#P = (e, i, s, n) => {
4472
- if (this.#e(i)) return 0;
4473
- if (!y(s)) if (n) {
4474
- if (typeof n != "function") throw new TypeError("sizeCalculation must be a function");
4475
- if (s = n(i, e), !y(s)) throw new TypeError("sizeCalculation return invalid (expect positive integer)");
4476
- } else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
4848
+ #X() {
4849
+ let t = new W(this.#o);
4850
+ this.#b = 0, this.#y = t, this.#C = (e) => {
4851
+ this.#b -= t[e], t[e] = 0;
4852
+ }, this.#N = (e, i, s, n) => {
4853
+ if (!T(s)) {
4854
+ if (this.#e(i)) return this.backgroundFetchSize;
4855
+ if (n) {
4856
+ if (typeof n != "function") throw new TypeError("sizeCalculation must be a function");
4857
+ if (s = n(i, e), !T(s)) throw new TypeError("sizeCalculation return invalid (expect positive integer)");
4858
+ } else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
4859
+ }
4477
4860
  return s;
4478
- }, this.#M = (e, i, s) => {
4861
+ }, this.#I = (e, i, s) => {
4479
4862
  if (t[e] = i, this.#c) {
4480
4863
  let n = this.#c - t[e];
4481
- for (; this.#_ > n;) this.#G(!0);
4864
+ for (; this.#b > n;) this.#P(!0);
4482
4865
  }
4483
- this.#_ += t[e], s && (s.entrySize = i, s.totalCalculatedSize = this.#_);
4866
+ this.#b += t[e], s && (s.entrySize = i, s.totalCalculatedSize = this.#b);
4484
4867
  };
4485
4868
  }
4486
- #W = (t) => {};
4487
- #M = (t, e, i) => {};
4488
- #P = (t, e, i, s) => {
4869
+ #C = (t) => {};
4870
+ #I = (t, e, i) => {};
4871
+ #N = (t, e, i, s) => {
4489
4872
  if (i || s) throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");
4490
4873
  return 0;
4491
4874
  };
4492
- *#F({ allowStale: t = this.allowStale } = {}) {
4493
- if (this.#n) for (let e = this.#h; !(!this.#H(e) || ((t || !this.#p(e)) && (yield e), e === this.#l));) e = this.#u[e];
4875
+ *#A({ allowStale: t = this.allowStale } = {}) {
4876
+ if (this.#n) for (let e = this.#h; this.#V(e) && ((t || !this.#p(e)) && (yield e), e !== this.#a);) e = this.#u[e];
4494
4877
  }
4495
- *#O({ allowStale: t = this.allowStale } = {}) {
4496
- if (this.#n) for (let e = this.#l; !(!this.#H(e) || ((t || !this.#p(e)) && (yield e), e === this.#h));) e = this.#a[e];
4878
+ *#z({ allowStale: t = this.allowStale } = {}) {
4879
+ if (this.#n) for (let e = this.#a; this.#V(e) && ((t || !this.#p(e)) && (yield e), e !== this.#h);) e = this.#l[e];
4497
4880
  }
4498
- #H(t) {
4881
+ #V(t) {
4499
4882
  return t !== void 0 && this.#s.get(this.#i[t]) === t;
4500
4883
  }
4501
4884
  *entries() {
4502
- for (let t of this.#F()) this.#t[t] !== void 0 && this.#i[t] !== void 0 && !this.#e(this.#t[t]) && (yield [this.#i[t], this.#t[t]]);
4885
+ for (let t of this.#A()) this.#t[t] !== void 0 && this.#i[t] !== void 0 && !this.#e(this.#t[t]) && (yield [this.#i[t], this.#t[t]]);
4503
4886
  }
4504
4887
  *rentries() {
4505
- for (let t of this.#O()) this.#t[t] !== void 0 && this.#i[t] !== void 0 && !this.#e(this.#t[t]) && (yield [this.#i[t], this.#t[t]]);
4888
+ for (let t of this.#z()) this.#t[t] !== void 0 && this.#i[t] !== void 0 && !this.#e(this.#t[t]) && (yield [this.#i[t], this.#t[t]]);
4506
4889
  }
4507
4890
  *keys() {
4508
- for (let t of this.#F()) {
4891
+ for (let t of this.#A()) {
4509
4892
  let e = this.#i[t];
4510
4893
  e !== void 0 && !this.#e(this.#t[t]) && (yield e);
4511
4894
  }
4512
4895
  }
4513
4896
  *rkeys() {
4514
- for (let t of this.#O()) {
4897
+ for (let t of this.#z()) {
4515
4898
  let e = this.#i[t];
4516
4899
  e !== void 0 && !this.#e(this.#t[t]) && (yield e);
4517
4900
  }
4518
4901
  }
4519
4902
  *values() {
4520
- for (let t of this.#F()) this.#t[t] !== void 0 && !this.#e(this.#t[t]) && (yield this.#t[t]);
4903
+ for (let t of this.#A()) this.#t[t] !== void 0 && !this.#e(this.#t[t]) && (yield this.#t[t]);
4521
4904
  }
4522
4905
  *rvalues() {
4523
- for (let t of this.#O()) this.#t[t] !== void 0 && !this.#e(this.#t[t]) && (yield this.#t[t]);
4906
+ for (let t of this.#z()) this.#t[t] !== void 0 && !this.#e(this.#t[t]) && (yield this.#t[t]);
4524
4907
  }
4525
4908
  [Symbol.iterator]() {
4526
4909
  return this.entries();
4527
4910
  }
4528
4911
  [Symbol.toStringTag] = "LRUCache";
4529
4912
  find(t, e = {}) {
4530
- for (let i of this.#F()) {
4913
+ for (let i of this.#A()) {
4531
4914
  let s = this.#t[i], n = this.#e(s) ? s.__staleWhileFetching : s;
4532
- if (n !== void 0 && t(n, this.#i[i], this)) return this.get(this.#i[i], e);
4915
+ if (n !== void 0 && t(n, this.#i[i], this)) return this.#x(this.#i[i], e);
4533
4916
  }
4534
4917
  }
4535
4918
  forEach(t, e = this) {
4536
- for (let i of this.#F()) {
4919
+ for (let i of this.#A()) {
4537
4920
  let s = this.#t[i], n = this.#e(s) ? s.__staleWhileFetching : s;
4538
4921
  n !== void 0 && t.call(e, n, this.#i[i], this);
4539
4922
  }
4540
4923
  }
4541
4924
  rforEach(t, e = this) {
4542
- for (let i of this.#O()) {
4925
+ for (let i of this.#z()) {
4543
4926
  let s = this.#t[i], n = this.#e(s) ? s.__staleWhileFetching : s;
4544
4927
  n !== void 0 && t.call(e, n, this.#i[i], this);
4545
4928
  }
4546
4929
  }
4547
4930
  purgeStale() {
4548
4931
  let t = !1;
4549
- for (let e of this.#O({ allowStale: !0 })) this.#p(e) && (this.#E(this.#i[e], "expire"), t = !0);
4932
+ for (let e of this.#z({ allowStale: !0 })) this.#p(e) && (this.#v(this.#i[e], "expire"), t = !0);
4550
4933
  return t;
4551
4934
  }
4552
4935
  info(t) {
@@ -4555,24 +4938,24 @@ var require_index_min = /* @__PURE__ */ __commonJSMin(((exports) => {
4555
4938
  let i = this.#t[e], s = this.#e(i) ? i.__staleWhileFetching : i;
4556
4939
  if (s === void 0) return;
4557
4940
  let n = { value: s };
4558
- if (this.#d && this.#A) {
4559
- let o = this.#d[e], h = this.#A[e];
4560
- if (o && h) n.ttl = o - (this.#m.now() - h), n.start = Date.now();
4941
+ if (this.#d && this.#F) {
4942
+ let r = this.#d[e], h = this.#F[e];
4943
+ if (r && h) n.ttl = r - (this.#w.now() - h), n.start = Date.now();
4561
4944
  }
4562
4945
  return this.#y && (n.size = this.#y[e]), n;
4563
4946
  }
4564
4947
  dump() {
4565
4948
  let t = [];
4566
- for (let e of this.#F({ allowStale: !0 })) {
4949
+ for (let e of this.#A({ allowStale: !0 })) {
4567
4950
  let i = this.#i[e], s = this.#t[e], n = this.#e(s) ? s.__staleWhileFetching : s;
4568
4951
  if (n === void 0 || i === void 0) continue;
4569
- let o = { value: n };
4570
- if (this.#d && this.#A) {
4571
- o.ttl = this.#d[e];
4572
- let h = this.#m.now() - this.#A[e];
4573
- o.start = Math.floor(Date.now() - h);
4952
+ let r = { value: n };
4953
+ if (this.#d && this.#F) {
4954
+ r.ttl = this.#d[e];
4955
+ let h = this.#w.now() - this.#F[e];
4956
+ r.start = Math.floor(Date.now() - h);
4574
4957
  }
4575
- this.#y && (o.size = this.#y[e]), t.unshift([i, o]);
4958
+ this.#y && (r.size = this.#y[e]), t.unshift([i, r]);
4576
4959
  }
4577
4960
  return t;
4578
4961
  }
@@ -4581,53 +4964,60 @@ var require_index_min = /* @__PURE__ */ __commonJSMin(((exports) => {
4581
4964
  for (let [e, i] of t) {
4582
4965
  if (i.start) {
4583
4966
  let s = Date.now() - i.start;
4584
- i.start = this.#m.now() - s;
4967
+ i.start = this.#w.now() - s;
4585
4968
  }
4586
- this.set(e, i.value, i);
4969
+ this.#O(e, i.value, i);
4587
4970
  }
4588
4971
  }
4589
4972
  set(t, e, i = {}) {
4590
- if (e === void 0) return this.delete(t), this;
4591
- let { ttl: s = this.ttl, start: n, noDisposeOnSet: o = this.noDisposeOnSet, sizeCalculation: h = this.sizeCalculation, status: r } = i, { noUpdateTTL: a = this.noUpdateTTL } = i, w = this.#P(t, e, i.size || 0, h);
4592
- if (this.maxEntrySize && w > this.maxEntrySize) return r && (r.set = "miss", r.maxEntrySizeExceeded = !0), this.#E(t, "set"), this;
4593
- let f = this.#n === 0 ? void 0 : this.#s.get(t);
4594
- if (f === void 0) f = this.#n === 0 ? this.#h : this.#b.length !== 0 ? this.#b.pop() : this.#n === this.#o ? this.#G(!1) : this.#n, this.#i[f] = t, this.#t[f] = e, this.#s.set(t, f), this.#a[this.#h] = f, this.#u[f] = this.#h, this.#h = f, this.#n++, this.#M(f, w, r), r && (r.set = "add"), a = !1, this.#I && this.#C?.(e, t, "add");
4973
+ let { status: s = g.metrics.hasSubscribers ? {} : void 0 } = i;
4974
+ i.status = s, s && (s.op = "set", s.key = t, e !== void 0 && (s.value = e), s.cache = this);
4975
+ let n = this.#O(t, e, i);
4976
+ return s && g.metrics.hasSubscribers && g.metrics.publish(s), n;
4977
+ }
4978
+ #O(t, e, i, s) {
4979
+ let { ttl: n = this.ttl, start: r, noDisposeOnSet: h = this.noDisposeOnSet, sizeCalculation: a = this.sizeCalculation, status: o } = i, d = this.#e(e);
4980
+ if (e === void 0) return o && (o.set = "deleted"), this.delete(t), this;
4981
+ let { noUpdateTTL: _ = this.noUpdateTTL } = i;
4982
+ o && !d && (o.value = e);
4983
+ let y = this.#N(t, e, i.size || 0, a, o);
4984
+ if (this.maxEntrySize && y > this.maxEntrySize) return this.#v(t, "set"), o && (o.set = "miss", o.maxEntrySizeExceeded = !0), this;
4985
+ let u = this.#n === 0 ? void 0 : this.#s.get(t);
4986
+ if (u === void 0) u = this.#n === 0 ? this.#h : this.#_.length !== 0 ? this.#_.pop() : this.#n === this.#o ? this.#P(!1) : this.#n, this.#i[u] = t, this.#t[u] = e, this.#s.set(t, u), this.#l[this.#h] = u, this.#u[u] = this.#h, this.#h = u, this.#n++, this.#I(u, y, o), o && (o.set = "add"), _ = !1, this.#D && !d && this.#W?.(e, t, "add");
4595
4987
  else {
4596
- this.#D(f);
4597
- let d = this.#t[f];
4598
- if (e !== d) {
4599
- if (this.#v && this.#e(d)) {
4600
- d.__abortController.abort(/* @__PURE__ */ new Error("replaced"));
4601
- let { __staleWhileFetching: g } = d;
4602
- g !== void 0 && !o && (this.#T && this.#w?.(g, t, "set"), this.#f && this.#r?.push([
4603
- g,
4988
+ this.#L(u);
4989
+ let p = this.#t[u];
4990
+ if (e !== p) {
4991
+ if (!h) if (this.#e(p)) {
4992
+ p !== s && p.__abortController.abort(/* @__PURE__ */ new Error("replaced"));
4993
+ let { __staleWhileFetching: f } = p;
4994
+ f !== void 0 && f !== e && (this.#T && this.#m?.(f, t, "set"), this.#f && this.#r?.push([
4995
+ f,
4604
4996
  t,
4605
4997
  "set"
4606
4998
  ]));
4607
- } else o || (this.#T && this.#w?.(d, t, "set"), this.#f && this.#r?.push([
4608
- d,
4999
+ } else this.#T && this.#m?.(p, t, "set"), this.#f && this.#r?.push([
5000
+ p,
4609
5001
  t,
4610
5002
  "set"
4611
- ]));
4612
- if (this.#W(f), this.#M(f, w, r), this.#t[f] = e, r) {
4613
- r.set = "replace";
4614
- let g = d && this.#e(d) ? d.__staleWhileFetching : d;
4615
- g !== void 0 && (r.oldValue = g);
5003
+ ]);
5004
+ if (this.#C(u), this.#I(u, y, o), this.#t[u] = e, !d) {
5005
+ let f = p && this.#e(p) ? p.__staleWhileFetching : p, b = f === void 0 ? "add" : e !== f ? "replace" : "update";
5006
+ o && (o.set = b, f !== void 0 && (o.oldValue = f)), this.#D && this.onInsert?.(e, t, b);
4616
5007
  }
4617
- } else r && (r.set = "update");
4618
- this.#I && this.onInsert?.(e, t, e === d ? "update" : "replace");
5008
+ } else d || (o && (o.set = "update"), this.#D && this.onInsert?.(e, t, "update"));
4619
5009
  }
4620
- if (s !== 0 && !this.#d && this.#j(), this.#d && (a || this.#N(f, s, n), r && this.#z(r, f)), !o && this.#f && this.#r) {
4621
- let d = this.#r, g;
4622
- for (; g = d?.shift();) this.#S?.(...g);
5010
+ if (n !== 0 && !this.#d && this.#k(), this.#d && (_ || this.#H(u, n, r), o && this.#E(o, u)), !h && this.#f && this.#r) {
5011
+ let p = this.#r, f;
5012
+ for (; f = p?.shift();) this.#S?.(...f);
4623
5013
  }
4624
5014
  return this;
4625
5015
  }
4626
5016
  pop() {
4627
5017
  try {
4628
5018
  for (; this.#n;) {
4629
- let t = this.#t[this.#l];
4630
- if (this.#G(!0), this.#e(t)) {
5019
+ let t = this.#t[this.#a];
5020
+ if (this.#P(!0), this.#e(t)) {
4631
5021
  if (t.__staleWhileFetching) return t.__staleWhileFetching;
4632
5022
  } else if (t !== void 0) return t;
4633
5023
  }
@@ -4638,163 +5028,214 @@ var require_index_min = /* @__PURE__ */ __commonJSMin(((exports) => {
4638
5028
  }
4639
5029
  }
4640
5030
  }
4641
- #G(t) {
4642
- let e = this.#l, i = this.#i[e], s = this.#t[e];
4643
- return this.#v && this.#e(s) ? s.__abortController.abort(/* @__PURE__ */ new Error("evicted")) : (this.#T || this.#f) && (this.#T && this.#w?.(s, i, "evict"), this.#f && this.#r?.push([
4644
- s,
5031
+ #P(t) {
5032
+ let e = this.#a, i = this.#i[e], s = this.#t[e], n = this.#e(s);
5033
+ n && s.__abortController.abort(/* @__PURE__ */ new Error("evicted"));
5034
+ let r = n ? s.__staleWhileFetching : s;
5035
+ return (this.#T || this.#f) && r !== void 0 && (this.#T && this.#m?.(r, i, "evict"), this.#f && this.#r?.push([
5036
+ r,
4645
5037
  i,
4646
5038
  "evict"
4647
- ])), this.#W(e), this.#g?.[e] && (clearTimeout(this.#g[e]), this.#g[e] = void 0), t && (this.#i[e] = void 0, this.#t[e] = void 0, this.#b.push(e)), this.#n === 1 ? (this.#l = this.#h = 0, this.#b.length = 0) : this.#l = this.#a[e], this.#s.delete(i), this.#n--, e;
5039
+ ])), this.#C(e), this.#g?.[e] && (clearTimeout(this.#g[e]), this.#g[e] = void 0), t && (this.#i[e] = void 0, this.#t[e] = void 0, this.#_.push(e)), this.#n === 1 ? (this.#a = this.#h = 0, this.#_.length = 0) : this.#a = this.#l[e], this.#s.delete(i), this.#n--, e;
4648
5040
  }
4649
5041
  has(t, e = {}) {
5042
+ let { status: i = g.metrics.hasSubscribers ? {} : void 0 } = e;
5043
+ e.status = i, i && (i.op = "has", i.key = t, i.cache = this);
5044
+ let s = this.#Y(t, e);
5045
+ return g.metrics.hasSubscribers && g.metrics.publish(i), s;
5046
+ }
5047
+ #Y(t, e = {}) {
4650
5048
  let { updateAgeOnHas: i = this.updateAgeOnHas, status: s } = e, n = this.#s.get(t);
4651
5049
  if (n !== void 0) {
4652
- let o = this.#t[n];
4653
- if (this.#e(o) && o.__staleWhileFetching === void 0) return !1;
4654
- if (this.#p(n)) s && (s.has = "stale", this.#z(s, n));
4655
- else return i && this.#R(n), s && (s.has = "hit", this.#z(s, n)), !0;
5050
+ let r = this.#t[n];
5051
+ if (this.#e(r) && r.__staleWhileFetching === void 0) return !1;
5052
+ if (this.#p(n)) s && (s.has = "stale", this.#E(s, n));
5053
+ else return i && this.#R(n), s && (s.has = "hit", this.#E(s, n)), !0;
4656
5054
  } else s && (s.has = "miss");
4657
5055
  return !1;
4658
5056
  }
4659
5057
  peek(t, e = {}) {
4660
- let { allowStale: i = this.allowStale } = e, s = this.#s.get(t);
4661
- if (s === void 0 || !i && this.#p(s)) return;
4662
- let n = this.#t[s];
4663
- return this.#e(n) ? n.__staleWhileFetching : n;
5058
+ let { status: i = C() ? {} : void 0 } = e;
5059
+ i && (i.op = "peek", i.key = t, i.cache = this), e.status = i;
5060
+ let s = this.#J(t, e);
5061
+ return g.metrics.hasSubscribers && g.metrics.publish(i), s;
5062
+ }
5063
+ #J(t, e) {
5064
+ let { status: i, allowStale: s = this.allowStale } = e, n = this.#s.get(t);
5065
+ if (n === void 0 || !s && this.#p(n)) {
5066
+ i && (i.peek = n === void 0 ? "miss" : "stale");
5067
+ return;
5068
+ }
5069
+ let r = this.#t[n], h = this.#e(r) ? r.__staleWhileFetching : r;
5070
+ return i && (h !== void 0 ? (i.peek = "hit", i.value = h) : i.peek = "miss"), h;
4664
5071
  }
4665
- #x(t, e, i, s) {
5072
+ #G(t, e, i, s) {
4666
5073
  let n = e === void 0 ? void 0 : this.#t[e];
4667
5074
  if (this.#e(n)) return n;
4668
- let o = new C(), { signal: h } = i;
4669
- h?.addEventListener("abort", () => o.abort(h.reason), { signal: o.signal });
4670
- let r = {
4671
- signal: o.signal,
5075
+ let r = new AbortController(), { signal: h } = i;
5076
+ h?.addEventListener("abort", () => r.abort(h.reason), { signal: r.signal });
5077
+ let a = {
5078
+ signal: r.signal,
4672
5079
  options: i,
4673
5080
  context: s
4674
- }, a = (p, _ = !1) => {
4675
- let { aborted: l } = o.signal, S = i.ignoreFetchAbort && p !== void 0, b = i.ignoreFetchAbort || !!(i.allowStaleOnFetchAbort && p !== void 0);
4676
- if (i.status && (l && !_ ? (i.status.fetchAborted = !0, i.status.fetchError = o.signal.reason, S && (i.status.fetchAbortIgnored = !0)) : i.status.fetchResolved = !0), l && !S && !_) return f(o.signal.reason, b);
4677
- let m = g, u = this.#t[e];
4678
- return (u === g || S && _ && u === void 0) && (p === void 0 ? m.__staleWhileFetching !== void 0 ? this.#t[e] = m.__staleWhileFetching : this.#E(t, "fetch") : (i.status && (i.status.fetchUpdated = !0), this.set(t, p, r.options))), p;
4679
- }, w = (p) => (i.status && (i.status.fetchRejected = !0, i.status.fetchError = p), f(p, !1)), f = (p, _) => {
4680
- let { aborted: l } = o.signal, S = l && i.allowStaleOnFetchAbort, b = S || i.allowStaleOnFetchRejection, m = b || i.noDeleteOnFetchRejection, u = g;
4681
- if (this.#t[e] === g && (!m || !_ && u.__staleWhileFetching === void 0 ? this.#E(t, "fetch") : S || (this.#t[e] = u.__staleWhileFetching)), b) return i.status && u.__staleWhileFetching !== void 0 && (i.status.returnedStale = !0), u.__staleWhileFetching;
4682
- if (u.__returned === u) throw p;
4683
- }, d = (p, _) => {
4684
- let l = this.#L?.(t, n, r);
4685
- l && l instanceof Promise && l.then((S) => p(S === void 0 ? void 0 : S), _), o.signal.addEventListener("abort", () => {
4686
- (!i.ignoreFetchAbort || i.allowStaleOnFetchAbort) && (p(void 0), i.allowStaleOnFetchAbort && (p = (S) => a(S, !0)));
4687
- });
5081
+ }, o = (f, b = !1) => {
5082
+ let { aborted: l } = r.signal, S = i.ignoreFetchAbort && f !== void 0, F = i.ignoreFetchAbort || !!(i.allowStaleOnFetchAbort && f !== void 0);
5083
+ if (i.status && (l && !b ? (i.status.fetchAborted = !0, i.status.fetchError = r.signal.reason, S && (i.status.fetchAbortIgnored = !0)) : i.status.fetchResolved = !0), l && !S && !b) return _(r.signal.reason, F);
5084
+ let w = u, m = this.#t[e];
5085
+ return (m === u || m === void 0 && S && b) && (f === void 0 ? w.__staleWhileFetching !== void 0 ? this.#t[e] = w.__staleWhileFetching : this.#v(t, "fetch") : (i.status && (i.status.fetchUpdated = !0), this.#O(t, f, a.options, w))), f;
5086
+ }, d = (f) => (i.status && (i.status.fetchRejected = !0, i.status.fetchError = f), _(f, !1)), _ = (f, b) => {
5087
+ let { aborted: l } = r.signal, S = l && i.allowStaleOnFetchAbort, F = S || i.allowStaleOnFetchRejection, w = F || i.noDeleteOnFetchRejection, m = u;
5088
+ if (this.#t[e] === u && (!w || !b && m.__staleWhileFetching === void 0 ? this.#v(t, "fetch") : S || (this.#t[e] = m.__staleWhileFetching)), F) return i.status && m.__staleWhileFetching !== void 0 && (i.status.returnedStale = !0), m.__staleWhileFetching;
5089
+ if (m.__returned === m) throw f;
5090
+ }, y = (f, b) => {
5091
+ let l = this.#M?.(t, n, a);
5092
+ r.signal.addEventListener("abort", () => {
5093
+ (!i.ignoreFetchAbort || i.allowStaleOnFetchAbort) && (f(void 0), i.allowStaleOnFetchAbort && (f = (S) => o(S, !0)));
5094
+ }), l && l instanceof Promise ? l.then((S) => f(S === void 0 ? void 0 : S), b) : l !== void 0 && f(l);
4688
5095
  };
4689
5096
  i.status && (i.status.fetchDispatched = !0);
4690
- let g = new Promise(d).then(a, w), A = Object.assign(g, {
4691
- __abortController: o,
5097
+ let u = new Promise(y).then(o, d), p = Object.assign(u, {
5098
+ __abortController: r,
4692
5099
  __staleWhileFetching: n,
4693
5100
  __returned: void 0
4694
5101
  });
4695
- return e === void 0 ? (this.set(t, A, {
4696
- ...r.options,
5102
+ return e === void 0 ? (this.#O(t, p, {
5103
+ ...a.options,
4697
5104
  status: void 0
4698
- }), e = this.#s.get(t)) : this.#t[e] = A, A;
5105
+ }), e = this.#s.get(t)) : this.#t[e] = p, p;
4699
5106
  }
4700
5107
  #e(t) {
4701
- if (!this.#v) return !1;
5108
+ if (!this.#U) return !1;
4702
5109
  let e = t;
4703
- return !!e && e instanceof Promise && e.hasOwnProperty("__staleWhileFetching") && e.__abortController instanceof C;
5110
+ return !!e && e instanceof Promise && e.hasOwnProperty("__staleWhileFetching") && e.__abortController instanceof AbortController;
4704
5111
  }
4705
- async fetch(t, e = {}) {
4706
- let { allowStale: i = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: n = this.noDeleteOnStaleGet, ttl: o = this.ttl, noDisposeOnSet: h = this.noDisposeOnSet, size: r = 0, sizeCalculation: a = this.sizeCalculation, noUpdateTTL: w = this.noUpdateTTL, noDeleteOnFetchRejection: f = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection: d = this.allowStaleOnFetchRejection, ignoreFetchAbort: g = this.ignoreFetchAbort, allowStaleOnFetchAbort: A = this.allowStaleOnFetchAbort, context: p, forceRefresh: _ = !1, status: l, signal: S } = e;
4707
- if (!this.#v) return l && (l.fetch = "get"), this.get(t, {
5112
+ fetch(t, e = {}) {
5113
+ let i = g.tracing.hasSubscribers, { status: s = C() ? {} : void 0 } = e;
5114
+ e.status = s, s && e.context && (s.context = e.context);
5115
+ let n = this.#q(t, e);
5116
+ return s && i && (s.trace = !0, g.tracing.tracePromise(() => n, s).catch(() => {})), n;
5117
+ }
5118
+ async #q(t, e = {}) {
5119
+ let { allowStale: i = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: n = this.noDeleteOnStaleGet, ttl: r = this.ttl, noDisposeOnSet: h = this.noDisposeOnSet, size: a = 0, sizeCalculation: o = this.sizeCalculation, noUpdateTTL: d = this.noUpdateTTL, noDeleteOnFetchRejection: _ = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection: y = this.allowStaleOnFetchRejection, ignoreFetchAbort: u = this.ignoreFetchAbort, allowStaleOnFetchAbort: p = this.allowStaleOnFetchAbort, context: f, forceRefresh: b = !1, status: l, signal: S } = e;
5120
+ if (l && (l.op = "fetch", l.key = t, b && (l.forceRefresh = !0), l.cache = this), !this.#U) return l && (l.fetch = "get"), this.#x(t, {
4708
5121
  allowStale: i,
4709
5122
  updateAgeOnGet: s,
4710
5123
  noDeleteOnStaleGet: n,
4711
5124
  status: l
4712
5125
  });
4713
- let b = {
5126
+ let F = {
4714
5127
  allowStale: i,
4715
5128
  updateAgeOnGet: s,
4716
5129
  noDeleteOnStaleGet: n,
4717
- ttl: o,
5130
+ ttl: r,
4718
5131
  noDisposeOnSet: h,
4719
- size: r,
4720
- sizeCalculation: a,
4721
- noUpdateTTL: w,
4722
- noDeleteOnFetchRejection: f,
4723
- allowStaleOnFetchRejection: d,
4724
- allowStaleOnFetchAbort: A,
4725
- ignoreFetchAbort: g,
5132
+ size: a,
5133
+ sizeCalculation: o,
5134
+ noUpdateTTL: d,
5135
+ noDeleteOnFetchRejection: _,
5136
+ allowStaleOnFetchRejection: y,
5137
+ allowStaleOnFetchAbort: p,
5138
+ ignoreFetchAbort: u,
4726
5139
  status: l,
4727
5140
  signal: S
4728
- }, m = this.#s.get(t);
4729
- if (m === void 0) {
5141
+ }, w = this.#s.get(t);
5142
+ if (w === void 0) {
4730
5143
  l && (l.fetch = "miss");
4731
- let u = this.#x(t, m, b, p);
4732
- return u.__returned = u;
5144
+ let m = this.#G(t, w, F, f);
5145
+ return m.__returned = m;
4733
5146
  } else {
4734
- let u = this.#t[m];
4735
- if (this.#e(u)) {
4736
- let E = i && u.__staleWhileFetching !== void 0;
4737
- return l && (l.fetch = "inflight", E && (l.returnedStale = !0)), E ? u.__staleWhileFetching : u.__returned = u;
5147
+ let m = this.#t[w];
5148
+ if (this.#e(m)) {
5149
+ let E = i && m.__staleWhileFetching !== void 0;
5150
+ return l && (l.fetch = "inflight", E && (l.returnedStale = !0)), E ? m.__staleWhileFetching : m.__returned = m;
4738
5151
  }
4739
- let T = this.#p(m);
4740
- if (!_ && !T) return l && (l.fetch = "hit"), this.#D(m), s && this.#R(m), l && this.#z(l, m), u;
4741
- let F = this.#x(t, m, b, p), O = F.__staleWhileFetching !== void 0 && i;
4742
- return l && (l.fetch = T ? "stale" : "refresh", O && T && (l.returnedStale = !0)), O ? F.__staleWhileFetching : F.__returned = F;
5152
+ let A = this.#p(w);
5153
+ if (!b && !A) return l && (l.fetch = "hit"), this.#L(w), s && this.#R(w), l && this.#E(l, w), m;
5154
+ let z = this.#G(t, w, F, f), v = z.__staleWhileFetching !== void 0 && i;
5155
+ return l && (l.fetch = A ? "stale" : "refresh", v && A && (l.returnedStale = !0)), v ? z.__staleWhileFetching : z.__returned = z;
4743
5156
  }
4744
5157
  }
4745
- async forceFetch(t, e = {}) {
4746
- let i = await this.fetch(t, e);
5158
+ forceFetch(t, e = {}) {
5159
+ let i = g.tracing.hasSubscribers, { status: s = C() ? {} : void 0 } = e;
5160
+ e.status = s, s && e.context && (s.context = e.context);
5161
+ let n = this.#K(t, e);
5162
+ return s && i && (s.trace = !0, g.tracing.tracePromise(() => n, s).catch(() => {})), n;
5163
+ }
5164
+ async #K(t, e = {}) {
5165
+ let i = await this.#q(t, e);
4747
5166
  if (i === void 0) throw new Error("fetch() returned undefined");
4748
5167
  return i;
4749
5168
  }
4750
5169
  memo(t, e = {}) {
4751
- let i = this.#U;
5170
+ let { status: i = g.metrics.hasSubscribers ? {} : void 0 } = e;
5171
+ e.status = i, i && (i.op = "memo", i.key = t, e.context && (i.context = e.context), i.cache = this);
5172
+ let s = this.#Q(t, e);
5173
+ return i && (i.value = s), g.metrics.hasSubscribers && g.metrics.publish(i), s;
5174
+ }
5175
+ #Q(t, e = {}) {
5176
+ let i = this.#j;
4752
5177
  if (!i) throw new Error("no memoMethod provided to constructor");
4753
- let { context: s, forceRefresh: n, ...o } = e, h = this.get(t, o);
4754
- if (!n && h !== void 0) return h;
4755
- let r = i(t, h, {
4756
- options: o,
5178
+ let { context: s, status: n, forceRefresh: r, ...h } = e;
5179
+ n && r && (n.forceRefresh = !0);
5180
+ let a = this.#x(t, h), o = r || a === void 0;
5181
+ if (n && (n.memo = o ? "miss" : "hit", o || (n.value = a)), !o) return a;
5182
+ let d = i(t, a, {
5183
+ options: h,
4757
5184
  context: s
4758
5185
  });
4759
- return this.set(t, r, o), r;
5186
+ return n && (n.value = d), this.#O(t, d, h), d;
4760
5187
  }
4761
5188
  get(t, e = {}) {
4762
- let { allowStale: i = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: n = this.noDeleteOnStaleGet, status: o } = e, h = this.#s.get(t);
4763
- if (h !== void 0) {
4764
- let r = this.#t[h], a = this.#e(r);
4765
- return o && this.#z(o, h), this.#p(h) ? (o && (o.get = "stale"), a ? (o && i && r.__staleWhileFetching !== void 0 && (o.returnedStale = !0), i ? r.__staleWhileFetching : void 0) : (n || this.#E(t, "expire"), o && i && (o.returnedStale = !0), i ? r : void 0)) : (o && (o.get = "hit"), a ? r.__staleWhileFetching : (this.#D(h), s && this.#R(h), r));
4766
- } else o && (o.get = "miss");
5189
+ let { status: i = g.metrics.hasSubscribers ? {} : void 0 } = e;
5190
+ e.status = i, i && (i.op = "get", i.key = t, i.cache = this);
5191
+ let s = this.#x(t, e);
5192
+ return i && (s !== void 0 && (i.value = s), g.metrics.hasSubscribers && g.metrics.publish(i)), s;
5193
+ }
5194
+ #x(t, e = {}) {
5195
+ let { allowStale: i = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: n = this.noDeleteOnStaleGet, status: r } = e, h = this.#s.get(t);
5196
+ if (h === void 0) {
5197
+ r && (r.get = "miss");
5198
+ return;
5199
+ }
5200
+ let a = this.#t[h], o = this.#e(a);
5201
+ return r && this.#E(r, h), this.#p(h) ? o ? (r && (r.get = "stale-fetching"), i && a.__staleWhileFetching !== void 0 ? (r && (r.returnedStale = !0), a.__staleWhileFetching) : void 0) : (n || this.#v(t, "expire"), r && (r.get = "stale"), i ? (r && (r.returnedStale = !0), a) : void 0) : (r && (r.get = o ? "fetching" : "hit"), this.#L(h), s && this.#R(h), o ? a.__staleWhileFetching : a);
4767
5202
  }
4768
- #k(t, e) {
4769
- this.#u[e] = t, this.#a[t] = e;
5203
+ #B(t, e) {
5204
+ this.#u[e] = t, this.#l[t] = e;
4770
5205
  }
4771
- #D(t) {
4772
- t !== this.#h && (t === this.#l ? this.#l = this.#a[t] : this.#k(this.#u[t], this.#a[t]), this.#k(this.#h, t), this.#h = t);
5206
+ #L(t) {
5207
+ t !== this.#h && (t === this.#a ? this.#a = this.#l[t] : this.#B(this.#u[t], this.#l[t]), this.#B(this.#h, t), this.#h = t);
4773
5208
  }
4774
5209
  delete(t) {
4775
- return this.#E(t, "delete");
4776
- }
4777
- #E(t, e) {
5210
+ return this.#v(t, "delete");
5211
+ }
5212
+ #v(t, e) {
5213
+ g.metrics.hasSubscribers && g.metrics.publish({
5214
+ op: "delete",
5215
+ delete: e,
5216
+ key: t,
5217
+ cache: this
5218
+ });
4778
5219
  let i = !1;
4779
5220
  if (this.#n !== 0) {
4780
5221
  let s = this.#s.get(t);
4781
- if (s !== void 0) if (this.#g?.[s] && (clearTimeout(this.#g?.[s]), this.#g[s] = void 0), i = !0, this.#n === 1) this.#V(e);
5222
+ if (s !== void 0) if (this.#g?.[s] && (clearTimeout(this.#g?.[s]), this.#g[s] = void 0), i = !0, this.#n === 1) this.#$(e);
4782
5223
  else {
4783
- this.#W(s);
5224
+ this.#C(s);
4784
5225
  let n = this.#t[s];
4785
- if (this.#e(n) ? n.__abortController.abort(/* @__PURE__ */ new Error("deleted")) : (this.#T || this.#f) && (this.#T && this.#w?.(n, t, e), this.#f && this.#r?.push([
5226
+ if (this.#e(n) ? n.__abortController.abort(/* @__PURE__ */ new Error("deleted")) : (this.#T || this.#f) && (this.#T && this.#m?.(n, t, e), this.#f && this.#r?.push([
4786
5227
  n,
4787
5228
  t,
4788
5229
  e
4789
5230
  ])), this.#s.delete(t), this.#i[s] = void 0, this.#t[s] = void 0, s === this.#h) this.#h = this.#u[s];
4790
- else if (s === this.#l) this.#l = this.#a[s];
5231
+ else if (s === this.#a) this.#a = this.#l[s];
4791
5232
  else {
4792
- let o = this.#u[s];
4793
- this.#a[o] = this.#a[s];
4794
- let h = this.#a[s];
5233
+ let r = this.#u[s];
5234
+ this.#l[r] = this.#l[s];
5235
+ let h = this.#l[s];
4795
5236
  this.#u[h] = this.#u[s];
4796
5237
  }
4797
- this.#n--, this.#b.push(s);
5238
+ this.#n--, this.#_.push(s);
4798
5239
  }
4799
5240
  }
4800
5241
  if (this.#f && this.#r?.length) {
@@ -4804,27 +5245,27 @@ var require_index_min = /* @__PURE__ */ __commonJSMin(((exports) => {
4804
5245
  return i;
4805
5246
  }
4806
5247
  clear() {
4807
- return this.#V("delete");
5248
+ return this.#$("delete");
4808
5249
  }
4809
- #V(t) {
4810
- for (let e of this.#O({ allowStale: !0 })) {
5250
+ #$(t) {
5251
+ for (let e of this.#z({ allowStale: !0 })) {
4811
5252
  let i = this.#t[e];
4812
5253
  if (this.#e(i)) i.__abortController.abort(/* @__PURE__ */ new Error("deleted"));
4813
5254
  else {
4814
5255
  let s = this.#i[e];
4815
- this.#T && this.#w?.(i, s, t), this.#f && this.#r?.push([
5256
+ this.#T && this.#m?.(i, s, t), this.#f && this.#r?.push([
4816
5257
  i,
4817
5258
  s,
4818
5259
  t
4819
5260
  ]);
4820
5261
  }
4821
5262
  }
4822
- if (this.#s.clear(), this.#t.fill(void 0), this.#i.fill(void 0), this.#d && this.#A) {
4823
- this.#d.fill(0), this.#A.fill(0);
5263
+ if (this.#s.clear(), this.#t.fill(void 0), this.#i.fill(void 0), this.#d && this.#F) {
5264
+ this.#d.fill(0), this.#F.fill(0);
4824
5265
  for (let e of this.#g ?? []) e !== void 0 && clearTimeout(e);
4825
5266
  this.#g?.fill(void 0);
4826
5267
  }
4827
- if (this.#y && this.#y.fill(0), this.#l = 0, this.#h = 0, this.#b.length = 0, this.#_ = 0, this.#n = 0, this.#f && this.#r) {
5268
+ if (this.#y && this.#y.fill(0), this.#a = 0, this.#h = 0, this.#_.length = 0, this.#b = 0, this.#n = 0, this.#f && this.#r) {
4828
5269
  let e = this.#r, i;
4829
5270
  for (; i = e?.shift();) this.#S?.(...i);
4830
5271
  }
@@ -5020,8 +5461,10 @@ var require_parse_url = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5020
5461
  if (Object.prototype.hasOwnProperty.call(protocols, proto)) return arg;
5021
5462
  if (arg.substr(firstColon, 3) === "://") return arg;
5022
5463
  const firstAt = arg.indexOf("@");
5023
- if (firstAt > -1) if (firstAt > firstColon) return `git+ssh://${arg}`;
5024
- else return arg;
5464
+ if (firstAt > -1) {
5465
+ if (firstAt > firstColon) return `git+ssh://${arg}`;
5466
+ else return arg;
5467
+ }
5025
5468
  return `${arg.slice(0, firstColon + 1)}//${arg.slice(firstColon + 1)}`;
5026
5469
  };
5027
5470
  const correctUrl = (giturl) => {
@@ -5058,7 +5501,8 @@ var require_from_url = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5058
5501
  };
5059
5502
  module.exports = (giturl, opts, { gitHosts, protocols }) => {
5060
5503
  if (!giturl) return;
5061
- const parsed = parseUrl(isGitHubShorthand(giturl) ? `github:${giturl}` : giturl, protocols);
5504
+ const correctedUrl = isGitHubShorthand(giturl) ? `github:${giturl}` : giturl;
5505
+ const parsed = parseUrl(correctedUrl, protocols);
5062
5506
  if (!parsed) return;
5063
5507
  const gitHostShortcut = gitHosts.byShortcut[parsed.protocol];
5064
5508
  const gitHostDomain = gitHosts.byDomain[parsed.hostname.startsWith("www.") ? parsed.hostname.slice(4) : parsed.hostname];
@@ -5521,17 +5965,22 @@ var require_fixer = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5521
5965
  var hosted = hostedGitInfo.fromUrl(data.repository.url);
5522
5966
  if (hosted && hosted.bugs()) data.bugs = { url: hosted.bugs() };
5523
5967
  } else if (data.bugs) {
5524
- if (typeof data.bugs === "string") if (isEmail(data.bugs)) data.bugs = { email: data.bugs };
5525
- else if (URL$1.canParse(data.bugs)) data.bugs = { url: data.bugs };
5526
- else this.warn("nonEmailUrlBugsString");
5527
- else {
5968
+ if (typeof data.bugs === "string") {
5969
+ if (isEmail(data.bugs)) data.bugs = { email: data.bugs };
5970
+ else if (URL$1.canParse(data.bugs)) data.bugs = { url: data.bugs };
5971
+ else this.warn("nonEmailUrlBugsString");
5972
+ } else {
5528
5973
  bugsTypos(data.bugs, this.warn);
5529
5974
  var oldBugs = data.bugs;
5530
5975
  data.bugs = {};
5531
- if (oldBugs.url) if (URL$1.canParse(oldBugs.url)) data.bugs.url = oldBugs.url;
5532
- else this.warn("nonUrlBugsUrlField");
5533
- if (oldBugs.email) if (typeof oldBugs.email === "string" && isEmail(oldBugs.email)) data.bugs.email = oldBugs.email;
5534
- else this.warn("nonEmailBugsEmailField");
5976
+ if (oldBugs.url) {
5977
+ if (URL$1.canParse(oldBugs.url)) data.bugs.url = oldBugs.url;
5978
+ else this.warn("nonUrlBugsUrlField");
5979
+ }
5980
+ if (oldBugs.email) {
5981
+ if (typeof oldBugs.email === "string" && isEmail(oldBugs.email)) data.bugs.email = oldBugs.email;
5982
+ else this.warn("nonEmailBugsEmailField");
5983
+ }
5535
5984
  }
5536
5985
  if (!data.bugs.email && !data.bugs.url) {
5537
5986
  delete data.bugs;
@@ -5763,10 +6212,19 @@ const _readPackage = (file, normalize) => {
5763
6212
  return json;
5764
6213
  };
5765
6214
  async function readPackage({ cwd, normalize = true } = {}) {
5766
- return _readPackage(await fsPromises.readFile(getPackagePath(cwd), "utf8"), normalize);
6215
+ const packageFile = await fsPromises.readFile(getPackagePath(cwd), "utf8");
6216
+ return _readPackage(packageFile, normalize);
5767
6217
  }
5768
6218
  //#endregion
5769
6219
  //#region clis/file-system/spawn-async.ts
6220
+ var SpawnError = class extends Error {
6221
+ stdout;
6222
+ constructor(message, stdout) {
6223
+ super(message);
6224
+ this.stdout = stdout;
6225
+ this.name = "SpawnError";
6226
+ }
6227
+ };
5770
6228
  function spawnAsync(command, args, options = {}) {
5771
6229
  return new Promise((resolve, reject) => {
5772
6230
  const child = spawn(command, args, {
@@ -5780,26 +6238,36 @@ function spawnAsync(command, args, options = {}) {
5780
6238
  });
5781
6239
  let stdout = "";
5782
6240
  let stderr = "";
6241
+ child.stdout?.setEncoding("utf8");
6242
+ child.stderr?.setEncoding("utf8");
5783
6243
  child.stdout?.on("data", (d) => {
5784
- stdout += d.toString();
6244
+ stdout += d;
5785
6245
  });
5786
6246
  child.stderr?.on("data", (d) => {
5787
- stderr += d.toString();
6247
+ stderr += d;
5788
6248
  });
5789
6249
  child.on("error", reject);
5790
6250
  child.on("close", (code) => {
5791
6251
  if (code === 0) resolve(stdout.trim());
5792
- else reject(new Error(stderr.trim() || `${command} exited with code ${code}`));
6252
+ else reject(new SpawnError(stderr.trim() || stdout.trim() || `${command} exited with code ${code}`, stdout.trim()));
5793
6253
  });
5794
6254
  });
5795
6255
  }
5796
6256
  //#endregion
5797
6257
  //#region clis/file-system/dependencies.ts
5798
6258
  async function fetchNpmVersionFromRegistryForTag(packageName, tag) {
5799
- const cleanedVersion = clean(await fetchPackageVersionFromNpmRegistry(`${packageName}@${tag}`));
6259
+ const version = await fetchPackageVersionFromNpmRegistry(`${packageName}@${tag}`);
6260
+ const cleanedVersion = clean(version);
5800
6261
  if (!cleanedVersion) throw new Error(`Failed to fetch version for package "${packageName}" at tag "${tag}".`);
5801
6262
  return cleanedVersion;
5802
6263
  }
6264
+ /** Whether `version` is in the semver `range`; false when it is not a range. */
6265
+ function versionSatisfies(version, range) {
6266
+ return satisfies(version, range);
6267
+ }
6268
+ function lowestVersion(versions) {
6269
+ return [...versions].sort(compare)[0];
6270
+ }
5803
6271
  async function fetchPackageVersionFromNpmRegistry(packageSpecifier, registryUrl) {
5804
6272
  const failedFetchErrorMessage = `Failed to fetch version from npm registry for ${packageSpecifier}.`;
5805
6273
  try {
@@ -5877,6 +6345,96 @@ async function getPackageVersionFromPackageJson(packageJsonPath) {
5877
6345
  return (await readPackage({ cwd: packageJsonPath })).version;
5878
6346
  }
5879
6347
  //#endregion
6348
+ //#region clis/file-system/package-manager.ts
6349
+ const SUPPORTED = [
6350
+ "npm",
6351
+ "pnpm",
6352
+ "yarn",
6353
+ "bun"
6354
+ ];
6355
+ /** Checked on PATH in this order when no user agent names a manager. */
6356
+ const PATH_PREFERENCE = ["bun", "pnpm"];
6357
+ /**
6358
+ * Oldest version detection will pick. `ph init` passes `--allow-build=<pkg>`
6359
+ * to `pnpm dlx` (injectPnpmAllowBuilds), which pnpm accepts from 10.14.0;
6360
+ * older versions fail with ERR_PNPM_SPEC_NOT_SUPPORTED_BY_ANY_RESOLVER.
6361
+ * An explicit --pnpm still uses whatever pnpm is installed.
6362
+ */
6363
+ const MIN_VERSION = { pnpm: "10.14.0" };
6364
+ /**
6365
+ * Picks a package manager when the user passed no --npm/--pnpm/--yarn/--bun
6366
+ * flag. In order:
6367
+ * 1. the manager that launched us (`npm_config_user_agent`, set by
6368
+ * npx / pnpm dlx / yarn dlx / bunx and by package scripts)
6369
+ * 2. the manager that installed the CLI globally (`installedWith`), unless
6370
+ * that is npm
6371
+ * 3. bun, then pnpm, if found on PATH
6372
+ * 4. npm
6373
+ * A manager older than its MIN_VERSION is skipped. A version-manager shim
6374
+ * (corepack, asdf, mise) on PATH counts as installed if `--version` works.
6375
+ */
6376
+ function detectPackageManager(options = {}) {
6377
+ const env = options.env ?? process.env;
6378
+ const platform = options.platform ?? process.platform;
6379
+ const allowed = options.allowed ?? SUPPORTED;
6380
+ const [uaName, uaVersion] = env.npm_config_user_agent?.split(" ")[0]?.split("/") ?? [];
6381
+ const fromUserAgent = uaName;
6382
+ if (fromUserAgent && allowed.includes(fromUserAgent) && isRecentEnough(fromUserAgent, uaVersion)) return {
6383
+ pm: fromUserAgent,
6384
+ source: "user-agent"
6385
+ };
6386
+ const fromInstall = options.installedWith && options.installedWith !== "npm" ? options.installedWith : void 0;
6387
+ const candidates = [...fromInstall ? [[fromInstall, "install"]] : [], ...PATH_PREFERENCE.map((pm) => [pm, "path"])];
6388
+ for (const [pm, source] of candidates) {
6389
+ if (!allowed.includes(pm)) continue;
6390
+ const file = findOnPath(pm, env, platform);
6391
+ if (!file) continue;
6392
+ if (MIN_VERSION[pm] && !isRecentEnough(pm, readVersion(file, env))) continue;
6393
+ return {
6394
+ pm,
6395
+ source
6396
+ };
6397
+ }
6398
+ return {
6399
+ pm: "npm",
6400
+ source: "fallback"
6401
+ };
6402
+ }
6403
+ function isRecentEnough(pm, version) {
6404
+ const min = MIN_VERSION[pm];
6405
+ if (!min) return true;
6406
+ const parsed = version ? coerce(version) : null;
6407
+ return parsed !== null && gte(parsed, min);
6408
+ }
6409
+ function readVersion(file, env) {
6410
+ const result = spawn.sync(file, ["--version"], {
6411
+ encoding: "utf8",
6412
+ env,
6413
+ timeout: 1e4
6414
+ });
6415
+ return result.status === 0 ? result.stdout.trim() : void 0;
6416
+ }
6417
+ function findOnPath(bin, env, platform) {
6418
+ const isWindows = platform === "win32";
6419
+ const pathValue = isWindows ? Object.entries(env).find(([k]) => k.toUpperCase() === "PATH")?.[1] : env.PATH;
6420
+ if (!pathValue) return void 0;
6421
+ const extensions = isWindows ? (env.PATHEXT ?? ".COM;.EXE;.BAT;.CMD").split(";").filter(Boolean) : [""];
6422
+ const dirs = pathValue.split(isWindows ? ";" : ":").filter(Boolean);
6423
+ for (const dir of dirs) for (const ext of extensions) {
6424
+ const file = path.join(dir, bin + ext);
6425
+ if (isExecutableFile(file, isWindows)) return file;
6426
+ }
6427
+ }
6428
+ function isExecutableFile(file, isWindows) {
6429
+ try {
6430
+ if (!statSync(file).isFile()) return false;
6431
+ if (!isWindows) accessSync(file, constants.X_OK);
6432
+ return true;
6433
+ } catch {
6434
+ return false;
6435
+ }
6436
+ }
6437
+ //#endregion
5880
6438
  //#region clis/file-system/directory-exists.ts
5881
6439
  async function directoryExists(path) {
5882
6440
  if (!path) return false;
@@ -6046,7 +6604,7 @@ PH CLI package manager: ${packageManager}
6046
6604
  //#endregion
6047
6605
  //#region clis/file-system/write-file-ensuring-dir.ts
6048
6606
  async function writeFileEnsuringDir(filePath, contents) {
6049
- await mkdir(dirname(filePath), { recursive: true });
6607
+ await mkdir(dirname(resolve(filePath)), { recursive: true });
6050
6608
  await writeFile(filePath, contents, { encoding: "utf-8" });
6051
6609
  }
6052
6610
  //#endregion
@@ -6268,18 +6826,35 @@ function getTelemetryStatus() {
6268
6826
  //#region constants.ts
6269
6827
  const PACKAGES_DEPENDENCIES = [
6270
6828
  "@powerhousedao/builder-tools",
6829
+ "@powerhousedao/clint",
6271
6830
  "@powerhousedao/codegen",
6272
6831
  "@powerhousedao/common",
6273
6832
  "@powerhousedao/config",
6833
+ "@powerhousedao/connect-core",
6274
6834
  "@powerhousedao/design-system",
6835
+ "@powerhousedao/desktop",
6836
+ "@powerhousedao/host-core",
6275
6837
  "document-drive",
6276
6838
  "document-model",
6839
+ "@powerhousedao/opentelemetry-instrumentation-reactor",
6840
+ "@powerhousedao/pieces-framework",
6841
+ "@powerhousedao/portle",
6277
6842
  "@powerhousedao/reactor",
6278
6843
  "@powerhousedao/reactor-api",
6844
+ "@powerhousedao/reactor-attachments",
6279
6845
  "@powerhousedao/reactor-browser",
6846
+ "@powerhousedao/reactor-drive",
6847
+ "@powerhousedao/reactor-group",
6848
+ "@powerhousedao/reactor-hypercore",
6280
6849
  "@powerhousedao/reactor-mcp",
6850
+ "@powerhousedao/reactor-privacy",
6851
+ "@powerhousedao/reactor-router",
6852
+ "@powerhousedao/reactor-workflow",
6853
+ "@powerhousedao/registry",
6281
6854
  "@powerhousedao/switchboard-gui",
6282
6855
  "@powerhousedao/vetra",
6856
+ "@powerhousedao/vetra-studio",
6857
+ "@powerhousedao/workflow",
6283
6858
  "@powerhousedao/analytics-engine-core",
6284
6859
  "@powerhousedao/analytics-engine-knex",
6285
6860
  "@powerhousedao/analytics-engine-pg",
@@ -6287,14 +6862,13 @@ const PACKAGES_DEPENDENCIES = [
6287
6862
  "@powerhousedao/analytics-engine-graphql",
6288
6863
  "@powerhousedao/shared",
6289
6864
  "@powerhousedao/powerhouse-vetra-packages",
6290
- "@powerhousedao/analytics-engine-core",
6291
- "@powerhousedao/analytics-engine-graphql",
6292
- "@powerhousedao/analytics-engine-knex",
6293
- "@powerhousedao/analytics-engine-pg",
6294
- "@powerhousedao/analytics-engine-browser",
6295
6865
  "@renown/sdk"
6296
6866
  ];
6297
- const CLIS_DEPENDENCIES = ["ph-cmd", "@powerhousedao/ph-cli"];
6867
+ const CLIS_DEPENDENCIES = [
6868
+ "ph-cmd",
6869
+ "@powerhousedao/ph-cli",
6870
+ "@powerhousedao/ph-run"
6871
+ ];
6298
6872
  const APPS_DEPENDENCIES = ["@powerhousedao/connect", "@powerhousedao/switchboard"];
6299
6873
  const ALL_POWERHOUSE_DEPENDENCIES = [
6300
6874
  ...PACKAGES_DEPENDENCIES,
@@ -6357,7 +6931,35 @@ async function runUseLocal(monorepoPath, skipInstall) {
6357
6931
  runCmd(`pnpm install`);
6358
6932
  }
6359
6933
  }
6934
+ const WORKSPACE_DIRS = [
6935
+ "packages",
6936
+ "packages/analytics-engine",
6937
+ "clis",
6938
+ "apps"
6939
+ ];
6940
+ const workspaces = /* @__PURE__ */ new Map();
6941
+ function workspacePackages(monorepoPath) {
6942
+ let dirs = workspaces.get(monorepoPath);
6943
+ if (dirs) return dirs;
6944
+ dirs = /* @__PURE__ */ new Map();
6945
+ for (const parent of WORKSPACE_DIRS) {
6946
+ const root = path.join(monorepoPath, parent);
6947
+ if (!existsSync(root)) continue;
6948
+ for (const entry of readdirSync(root, { withFileTypes: true })) {
6949
+ const manifest = path.join(root, entry.name, "package.json");
6950
+ if (!entry.isDirectory() || !existsSync(manifest)) continue;
6951
+ try {
6952
+ const { name } = JSON.parse(readFileSync(manifest, "utf8"));
6953
+ if (name) dirs.set(name, path.join(root, entry.name));
6954
+ } catch {}
6955
+ }
6956
+ }
6957
+ workspaces.set(monorepoPath, dirs);
6958
+ return dirs;
6959
+ }
6360
6960
  function buildPnpmLink(packageName, monorepoPath) {
6961
+ const dir = workspacePackages(monorepoPath).get(packageName);
6962
+ if (dir) return `link:${dir}`;
6361
6963
  const isCli = CLIS_DEPENDENCIES.includes(packageName);
6362
6964
  const isApp = APPS_DEPENDENCIES.includes(packageName);
6363
6965
  const packageDir = isCli ? "clis" : isApp ? "apps" : "packages";
@@ -6365,6 +6967,458 @@ function buildPnpmLink(packageName, monorepoPath) {
6365
6967
  return `link:${path.join(monorepoPath, packageDir, packageNameWithoutNamespace).replace("analytics-engine-", "analytics-engine/")}`;
6366
6968
  }
6367
6969
  //#endregion
6970
+ //#region connect/connect-config-schema.ts
6971
+ const IMAGE_REF = "Image reference: a project-relative file path, a URL, or a data URI.";
6972
+ const IMAGE_REF_OR_DEFAULT = "Image reference: a project-relative file path (resolved by the Connect build), a URL, or a data URI. null keeps the default.";
6973
+ /** An image reference: a project-relative file path (the Connect build turns
6974
+ * it into a data URI or an emitted file), a URL, or a data URI. */
6975
+ const connectImageRefSchema = z.string().describe(IMAGE_REF);
6976
+ /** An image reference where `null` (or omitting it) keeps the default. */
6977
+ const optionalImageRef = (description = IMAGE_REF_OR_DEFAULT) => connectImageRefSchema.nullable().optional().describe(description);
6978
+ /** An image per colour scheme: one reference for both, or `{ light, dark }`
6979
+ * (`dark` falls back to `light`). */
6980
+ const connectSchemedImageSchema = z.union([connectImageRefSchema, z.strictObject({
6981
+ light: connectImageRefSchema,
6982
+ dark: connectImageRefSchema.nullable().optional()
6983
+ })]).describe("One image for both colour schemes, or { light, dark } (dark falls back to light).");
6984
+ /** A CSS colour per colour scheme (`dark` falls back to `light`). */
6985
+ const connectSchemedColorSchema = z.union([z.string(), z.strictObject({
6986
+ light: z.string(),
6987
+ dark: z.string().nullable().optional()
6988
+ })]);
6989
+ /** A CSS length: a number is px, a string is passed through as written. */
6990
+ const connectLengthSchema = z.union([z.number(), z.string()]);
6991
+ const optionalLength = () => connectLengthSchema.nullable().optional().describe("A CSS length: a number is px; a string is used as written (\"40%\", \"min(55%, 880px)\", \"calc(50% - 120px)\").");
6992
+ /** Distances to the four edges; each is optional. */
6993
+ const connectEdgesSchema = z.strictObject({
6994
+ top: optionalLength(),
6995
+ right: optionalLength(),
6996
+ bottom: optionalLength(),
6997
+ left: optionalLength()
6998
+ });
6999
+ /** One image of a decorated pane, absolutely positioned inside it. */
7000
+ const connectBackgroundLayerSchema = z.strictObject({
7001
+ src: connectSchemedImageSchema,
7002
+ position: connectEdgesSchema.nullable().optional().describe("Distances to the pane's edges; at most one per axis. Omitted: centred both ways."),
7003
+ width: optionalLength(),
7004
+ height: optionalLength(),
7005
+ minWidth: optionalLength(),
7006
+ minHeight: optionalLength(),
7007
+ maxWidth: optionalLength(),
7008
+ maxHeight: optionalLength(),
7009
+ opacity: z.number().min(0).max(1).nullable().optional().describe("0 to 1 (default 1)."),
7010
+ fade: connectEdgesSchema.nullable().optional().describe("Feather depth per edge, fading the layer into the page colour.")
7011
+ }).describe("An image laid over the page, absolutely positioned: the edges set in `position` pin it, an axis with neither edge set is centred.");
7012
+ /** A decorated pane: the page colour and the images laid over it. */
7013
+ const connectBackgroundLayersSchema = z.strictObject({
7014
+ color: connectSchemedColorSchema.nullable().optional().describe("The page colour, or { light, dark }. Omitted or null: the theme's page background."),
7015
+ layers: z.array(connectBackgroundLayerSchema).describe("Painted in order; the first is at the back.")
7016
+ });
7017
+ /** A pane's background: layers over a page colour, or one image as
7018
+ * shorthand for a single layer pinned bottom-right. */
7019
+ const connectBackgroundSchema = z.union([connectImageRefSchema, connectBackgroundLayersSchema]).describe("Layered images over a page colour, or a single image pinned to the bottom-right corner. null keeps the default.");
7020
+ /** The loading image and the motion applied to it. */
7021
+ const connectLoaderSchema = z.strictObject({
7022
+ src: connectImageRefSchema,
7023
+ animation: z.enum([
7024
+ "pulse",
7025
+ "spin",
7026
+ "none"
7027
+ ]).nullable().optional().describe("Motion applied to the image (default pulse)."),
7028
+ size: z.number().min(16).max(512).nullable().optional().describe("Rendered width in CSS pixels (default 96); the height follows the image.")
7029
+ });
7030
+ /** `connect.branding`: Connect's identity and look. */
7031
+ const connectBrandingSchema = z.strictObject({
7032
+ appName: z.string().nullable().optional().describe("Browser tab title, installed-app name and in-app brand text. null or omitted: 'Powerhouse Connect'."),
7033
+ icon: optionalImageRef("App icon master (1024x1024 PNG recommended, or an SVG). The favicons and installed-app icons are found next to it as <name>_16x16.png, _32x32, _64x64, _192x192 and _512x512; the 64 px one is the in-app logo. null or omitted: Connect's icon."),
7034
+ favicon: z.string().nullable().optional().describe("The browser tab icon: a file (.ico, .svg or .png) relative to the project, served and built as icon.ico, or as icon.svg or icon.png for those types. A build input; the built runtime config leaves it out. `ph connect build --favicon` wins over it."),
7035
+ loader: z.union([connectImageRefSchema, connectLoaderSchema]).nullable().optional().describe("The loading image (first paint, app start, drive and editor loading). A path gets a gentle pulse; { src, animation, size } says otherwise, with animation \"none\" for an image that animates itself (animated SVG, GIF or WebP). null or omitted: Connect's animated logo.")
7036
+ }).describe("App identity and visual branding. Every field is optional; null means the default.");
7037
+ /** `connect.home`: the home screen (the generic chrome's landing page). */
7038
+ const connectHomeSchema = z.strictObject({ background: connectBackgroundSchema.nullable().optional().describe("The home screen's background: { color, layers } with each image positioned and sized, or one image pinned bottom-right. null or omitted: the bundled gradient.") }).describe("The home screen (the generic chrome's landing page).");
7039
+ const connectAppSchema = z.strictObject({
7040
+ logLevel: z.enum([
7041
+ "debug",
7042
+ "info",
7043
+ "warn",
7044
+ "error"
7045
+ ]).optional().meta({
7046
+ description: "Log level applied by Connect's logger at boot. Affects browser-side output only.",
7047
+ default: "info"
7048
+ }),
7049
+ basePath: z.string().optional().meta({
7050
+ description: "Base path Connect is mounted under (e.g. '/connect' for subpath deploys). Normalised at runtime to start and end with '/'. Defaults to the build-time BASE_URL.",
7051
+ default: "/"
7052
+ }),
7053
+ offline: z.boolean().optional().meta({
7054
+ description: "When true (default), the build emits a precaching service worker so Connect's app shell works offline, and the SPA registers it at boot. Set false to opt this deployment out: no service worker is built, the SPA skips registration, and any previously-installed worker is unregistered.",
7055
+ default: true
7056
+ }),
7057
+ studioMode: z.boolean().optional().meta({
7058
+ description: "Studio mode. Enables builder-only capabilities: Connect loads the vetra package and exposes DocumentModel (and vetra spec types) as creatable documents. Forced on by `ph vetra` / `ph connect studio`; false by default.",
7059
+ default: false
7060
+ }),
7061
+ cookieBanner: z.boolean().optional().meta({
7062
+ description: "Show the analytics cookie consent banner on a first visit, when a plugin that needs consent (Sentry, OpenPanel) is active. When false, no banner is shown and analytics consent stays rejected. `ph vetra` turns it off for its local Studio; true by default.",
7063
+ default: true
7064
+ }),
7065
+ workflowsEnabled: z.boolean().optional().describe("Powerhouse workflows in Connect. When true the tab loads the @powerhousedao/workflow package (workflow + connection documents, their editors and Workflow Studio) and the reactor worker registers its document models. Falls back to the top-level `workflows.enabled`; set it to override that for Connect. Independent of studioMode. False when neither is set.")
7066
+ }).describe("Top-level Connect application behaviour.");
7067
+ const connectAiSchema = z.strictObject({ assistantEnabled: z.boolean().optional().meta({
7068
+ description: "When true, Connect mounts the in-browser AI assistant (bottom-right chat FAB that talks to a user-configured OpenAI-compatible endpoint and acts on the reactor). Disabled by default.",
7069
+ default: false
7070
+ }) }).describe("AI assistant (chat) behaviour.");
7071
+ const connectPackagesSchema = z.strictObject({
7072
+ externalEnabled: z.boolean().optional().meta({
7073
+ description: "When false, Connect refuses to load any package that wasn't bundled at build time. Affirmative replacement for the legacy PH_CONNECT_EXTERNAL_PACKAGES_DISABLED env var.",
7074
+ default: true
7075
+ }),
7076
+ liveReload: z.boolean().optional().meta({
7077
+ description: "When true, Connect subscribes to the static-mode `/__packages` SSE channel so live publishes flow into the running tab without a page reload. Only works under hosting that serves this channel (e.g. ph-clint static mode).",
7078
+ default: false
7079
+ })
7080
+ }).describe("Runtime behaviour for the Connect package manager (separate from top-level `packages[]`, which lists which packages to load).");
7081
+ const EXPLORER_ICONS_DESCRIPTION = "The drive explorer's icons (the generic plugin's); each null keeps the built-in icon.";
7082
+ /** The drive explorer's icons: the generic chrome's, owned by the generic
7083
+ * plugin. Each `null` keeps the built-in icon. */
7084
+ const connectExplorerIconsSchema = z.strictObject({
7085
+ localDrive: optionalImageRef("Local drives without an icon of their own."),
7086
+ remoteDrive: optionalImageRef("Remote drives without an icon of their own."),
7087
+ folder: optionalImageRef("Folders."),
7088
+ document: optionalImageRef("Documents whose type has no icon in `documents`."),
7089
+ documents: z.record(z.string(), connectImageRefSchema).nullable().optional().describe("Per document type, e.g. \"acme/invoice\".")
7090
+ }).describe(EXPLORER_ICONS_DESCRIPTION);
7091
+ const connectDefaultDriveRemoteSchema = z.strictObject({
7092
+ url: z.string(),
7093
+ name: z.string().nullable().optional(),
7094
+ icon: z.string().nullable().optional()
7095
+ });
7096
+ const connectDefaultDriveLocalSchema = z.strictObject({
7097
+ local: z.literal(true).describe("Discriminator: this entry is a local drive created on first boot."),
7098
+ id: z.string().describe("Stable drive id. The drive is created with this id on first boot and is not re-created on later boots."),
7099
+ name: z.string().nullable().optional(),
7100
+ icon: z.string().nullable().optional(),
7101
+ app: z.string().optional().describe("Drive app (preferred editor) to open on the drive.")
7102
+ });
7103
+ const connectDefaultDriveSchema = z.union([connectDefaultDriveRemoteSchema, connectDefaultDriveLocalSchema]);
7104
+ /** `connect.drives.sections.{remote,local}`: three affirmative toggles. */
7105
+ const connectDriveSectionSchema = z.strictObject({
7106
+ enabled: z.boolean().optional().meta({
7107
+ description: "When false, the section is hidden in the sidebar.",
7108
+ default: true
7109
+ }),
7110
+ allowAdd: z.boolean().optional().meta({
7111
+ description: "When false, the section's 'add drive' affordance is hidden.",
7112
+ default: true
7113
+ }),
7114
+ allowDelete: z.boolean().optional().meta({
7115
+ description: "When false, drives in this section cannot be deleted from the UI.",
7116
+ default: true
7117
+ })
7118
+ }).describe("Visibility and add/delete affordances for a drive section in the sidebar.");
7119
+ const connectDriveSectionsSchema = z.strictObject({
7120
+ remote: connectDriveSectionSchema.optional(),
7121
+ local: connectDriveSectionSchema.optional()
7122
+ }).describe("Per-section visibility and affordance toggles. `remote` covers what was historically split into 'public' + 'cloud'; `local` is browser-local drives.");
7123
+ /** Mirrors DRIVES_PRESERVE_STRATEGIES (../clis/constants.ts, which imports
7124
+ * node: modules, so it is not imported here); a test pins the two. */
7125
+ const connectDrivePreserveStrategySchema = z.enum(["preserve-all", "preserve-by-url-and-detach"]);
7126
+ const connectDrivesSchema = z.strictObject({
7127
+ allowAddDrive: z.boolean().optional().meta({
7128
+ description: "When false, the SPA hides the 'add drive' affordance entirely (top-level). Per-section overrides live in `sections.{remote,local}.allowAdd`.",
7129
+ default: true
7130
+ }),
7131
+ defaultDrives: z.array(connectDefaultDriveSchema).optional().meta({
7132
+ description: "Drives the SPA auto-connects to on first load. Each entry is either a remote drive (a URL, with optional name/icon overrides) or a local drive (created locally on first boot, with a stable id and optional name/icon/app).",
7133
+ default: []
7134
+ }),
7135
+ preserveStrategy: connectDrivePreserveStrategySchema.optional().describe("Strategy applied when defaultDrives change between deploys. 'preserve-all' keeps user-added drives untouched; 'preserve-by-url-and-detach' detaches removed default drives. No schema default — opt-in only."),
7136
+ sections: connectDriveSectionsSchema.optional(),
7137
+ icons: connectExplorerIconsSchema.nullable().optional().describe(EXPLORER_ICONS_DESCRIPTION)
7138
+ }).describe("Default-drive and add-drive UI behaviour.");
7139
+ const connectRenownRainbowAdapterSchema = z.strictObject({
7140
+ walletConnectProjectId: z.string().optional().describe("WalletConnect project id; required for this adapter to function."),
7141
+ infuraProjectId: z.string().optional().describe("Optional Infura project id used to build RPC transports.")
7142
+ }).describe("wagmi + RainbowKit external-wallet adapter config.");
7143
+ const connectRenownPrivyAdapterSchema = z.strictObject({
7144
+ appId: z.string().optional().describe("Privy application id; required for this adapter to function."),
7145
+ clientId: z.string().optional().describe("Optional Privy client id."),
7146
+ methods: z.array(z.string()).optional().describe("Login methods this adapter offers; default per adapter when omitted.")
7147
+ }).describe("Privy embedded/social adapter config.");
7148
+ const connectRenownAdaptersSchema = z.strictObject({
7149
+ rainbow: connectRenownRainbowAdapterSchema.optional(),
7150
+ privy: connectRenownPrivyAdapterSchema.optional()
7151
+ }).describe("Per-adapter wallet config for in-page auth. Presence of an adapter key enables it; omit or leave empty for redirect-only behaviour.");
7152
+ const connectRenownSchema = z.strictObject({
7153
+ url: z.string().optional().meta({
7154
+ description: "Renown auth service URL.",
7155
+ default: "https://www.renown.id"
7156
+ }),
7157
+ networkId: z.string().optional().meta({
7158
+ description: "CAIP-2 network namespace (e.g. 'eip155').",
7159
+ default: "eip155"
7160
+ }),
7161
+ chainId: z.number().optional().meta({
7162
+ description: "CAIP-2 chain reference within the network namespace.",
7163
+ default: 1
7164
+ }),
7165
+ namespace: z.string().optional().describe("Renown localStorage namespace; share it across Connects to share login."),
7166
+ switchboardUrl: z.string().optional().describe("Switchboard GraphQL URL. When set, Connect enables in-page (no-redirect) Renown sign-in; otherwise it falls back to the redirect flow via `url`."),
7167
+ adapters: connectRenownAdaptersSchema.optional()
7168
+ }).describe("Renown identity / authentication coordinates.");
7169
+ const connectSentrySchema = z.strictObject({
7170
+ dsn: z.string().nullable().optional().meta({
7171
+ description: "Sentry DSN URL. `null` disables Sentry entirely; the SPA never loads the Sentry SDK chunk.",
7172
+ default: null
7173
+ }),
7174
+ env: z.string().optional().meta({
7175
+ description: "Sentry environment label, surfaced as the `environment` tag on every event.",
7176
+ default: "dev"
7177
+ }),
7178
+ tracing: z.boolean().optional().meta({
7179
+ description: "Enable Sentry performance tracing.",
7180
+ default: false
7181
+ })
7182
+ }).describe("Sentry error-tracking coordinates. Set `dsn` to enable Sentry; leave `dsn` null to disable. The Sentry release tag stays build-time (stamped via Vite's `define` from WORKSPACE_VERSION) so it always matches the sourcemaps uploaded by CI.");
7183
+ const connectOpenPanelSchema = z.strictObject({
7184
+ clientId: z.string().optional().meta({
7185
+ description: "OpenPanel client id. Empty string disables OpenPanel entirely.",
7186
+ default: ""
7187
+ }),
7188
+ apiUrl: z.string().optional().describe("OpenPanel API URL for self-hosted instances (e.g. 'https://openpanel.example/api'). Omit to use OpenPanel's hosted API."),
7189
+ trackUiEvents: z.boolean().optional().meta({
7190
+ description: "Track UI events.",
7191
+ default: true
7192
+ }),
7193
+ trackOperations: z.boolean().optional().meta({
7194
+ description: "Track document operations.",
7195
+ default: true
7196
+ })
7197
+ }).describe("OpenPanel product analytics. Set `clientId` to enable; an empty `clientId` disables it. Events are only sent after the user accepts analytics cookies. Takes precedence over the build-time PH_CONNECT_OPENPANEL_* env vars.");
7198
+ /** Which reactor client Connect runs (see PHReactorClientMode). */
7199
+ const connectReactorClientModeSchema = z.enum([
7200
+ "in-process",
7201
+ "worker",
7202
+ "remote",
7203
+ "router"
7204
+ ]);
7205
+ const connectInstanceSchema = z.strictObject({
7206
+ namespace: z.string().nullable().meta({
7207
+ description: "Explicit storage/SharedWorker namespace for this instance. `null` derives it from the base path (and, later, the configured endpoint), so root deployments stay byte-identical.",
7208
+ default: null
7209
+ }),
7210
+ reactorWorker: z.boolean().meta({
7211
+ description: "Host the reactor in a shared worker instead of on the main thread. Off by default; the main-thread reactor stays the proven path until cutover is verified. Packaged deployments load the worker from the prebuilt bundle `ph connect build` emits under __reactor_worker__/ (the dev server builds it lazily at the same path); when that bundle is absent the feature reports itself unavailable instead of starting a worker that cannot load.",
7212
+ default: false
7213
+ }),
7214
+ multiReactor: z.boolean().optional().meta({
7215
+ description: "Opt-in multi-reactor routing. When on, Connect routes through the in-browser reactor plus remote backends instead of the single in-browser reactor. Off by default; the single-reactor path is unchanged.",
7216
+ default: false
7217
+ })
7218
+ }).describe("Per-instance identity. Lets one origin host multiple isolated Connect instances, each with its own storage + SharedWorker namespace.");
7219
+ const connectReactorFeatureFlagsSchema = z.strictObject({
7220
+ documentDecisions: z.boolean().optional().meta({
7221
+ description: "Decide writes from the document stream rather than the document meta cache, so a backdated deletion denies the operations that sort after it.",
7222
+ default: false
7223
+ }),
7224
+ authEnforcement: z.boolean().optional().meta({
7225
+ description: "Enforce the auth scope's policy at admission, replay, and read. Requires documentDecisions.",
7226
+ default: false
7227
+ }),
7228
+ authGroups: z.boolean().optional().meta({
7229
+ description: "Let `{ group }` principals match against the rosters of the group documents a policy names. Requires authEnforcement.",
7230
+ default: false
7231
+ }),
7232
+ authConditions: z.boolean().optional().meta({
7233
+ description: "Evaluate `where` and `match` conditions on grants. Requires authGroups. Do not enable on a fleet `preflight:auth` reports as crossing a reducer version.",
7234
+ default: false
7235
+ }),
7236
+ undoV3: z.boolean().optional().meta({ description: "Support base-reducer 3 (id-targeted undo), which new documents then take. A peer without it is held from base-reducer 3 documents until it upgrades. Unset leaves the reactor's default." })
7237
+ }).describe("Reactor feature flags. The four enforcement flags each imply their predecessors, and the reactor refuses to boot on a set that names a later one without an earlier one. They are consensus settings: a Connect syncing with a fleet must carry the same enforcement flags the fleet does, or the two reach different replay outcomes for the same history and diverge. undoV3 has no prerequisites; peers negotiate it.");
7238
+ const connectReactorSchema = z.strictObject({
7239
+ featureFlags: connectReactorFeatureFlagsSchema.optional(),
7240
+ createSignaturePolicy: z.enum(["legacy", "v2-required"]).optional().meta({
7241
+ description: "What new documents are created as. `v2-required` documents accept only v2 action signatures and take content-addressed ids; set `legacy` while any peer Connect syncs with predates them. Existing documents keep their policy.",
7242
+ default: "v2-required"
7243
+ }),
7244
+ unsupportedStoredDocuments: z.enum(["refuse", "read-only"]).optional().meta({
7245
+ description: "What the reactor does when this browser's store holds documents at protocol versions this build does not run. `refuse` fails the boot and names the versions; `read-only` boots and keeps those documents read-only.",
7246
+ default: "refuse"
7247
+ })
7248
+ }).describe("Settings for the reactor Connect runs in the browser, on the main thread or in the shared worker alike.");
7249
+ /** A runtime-caching / denylist URL match. A string is handed to Workbox
7250
+ * verbatim; `{ source, flags }` is rebuilt into a RegExp at build time. */
7251
+ const connectPwaUrlPatternSchema = z.union([z.string(), z.strictObject({
7252
+ source: z.string().describe("RegExp source."),
7253
+ flags: z.string().optional().describe("RegExp flags (e.g. 'i').")
7254
+ }).refine((p) => {
7255
+ try {
7256
+ new RegExp(p.source, p.flags);
7257
+ return true;
7258
+ } catch {
7259
+ return false;
7260
+ }
7261
+ }, { message: "source/flags do not compile to a valid RegExp" })]).describe("URL match. A string is matched verbatim by Workbox; { source, flags } is rebuilt into a RegExp at build time.");
7262
+ const connectPwaCacheStrategySchema = z.enum([
7263
+ "CacheFirst",
7264
+ "CacheOnly",
7265
+ "NetworkFirst",
7266
+ "NetworkOnly",
7267
+ "StaleWhileRevalidate"
7268
+ ]);
7269
+ /** Serialisable subset of a Workbox `RuntimeCaching` rule. */
7270
+ const connectPwaRuntimeCachingSchema = z.strictObject({
7271
+ urlPattern: connectPwaUrlPatternSchema,
7272
+ handler: connectPwaCacheStrategySchema,
7273
+ method: z.enum([
7274
+ "GET",
7275
+ "POST",
7276
+ "PUT",
7277
+ "DELETE",
7278
+ "HEAD",
7279
+ "PATCH"
7280
+ ]).optional(),
7281
+ options: z.strictObject({
7282
+ cacheName: z.string().optional(),
7283
+ networkTimeoutSeconds: z.number().optional().describe("Seconds a NetworkFirst rule waits for the network before falling back to the cache."),
7284
+ expiration: z.strictObject({
7285
+ maxEntries: z.number().optional(),
7286
+ maxAgeSeconds: z.number().optional()
7287
+ }).optional(),
7288
+ cacheableResponse: z.strictObject({
7289
+ statuses: z.array(z.number()).optional(),
7290
+ headers: z.record(z.string(), z.string()).optional()
7291
+ }).optional()
7292
+ }).optional()
7293
+ });
7294
+ const connectPwaIconSchema = z.strictObject({
7295
+ src: z.string(),
7296
+ sizes: z.string().optional(),
7297
+ type: z.string().optional(),
7298
+ purpose: z.string().optional()
7299
+ });
7300
+ /** A File Handling API entry. No `action`: every handler opens at Connect's
7301
+ * app root, because consuming launched files needs Connect's own code. */
7302
+ const connectPwaFileHandlerSchema = z.strictObject({
7303
+ accept: z.record(z.string(), z.array(z.string().regex(/^\./, "file extensions must start with '.'"))).describe("MIME type → file extensions. Each extension must start with '.'; browsers ignore entries without it."),
7304
+ icons: z.array(connectPwaIconSchema).optional().describe("OS-level file-type icons."),
7305
+ launch_type: z.enum(["single-client", "multiple-clients"]).optional()
7306
+ });
7307
+ /** Web-app-manifest fields a package or project may override. */
7308
+ const connectPwaManifestSchema = z.strictObject({
7309
+ name: z.string().optional(),
7310
+ short_name: z.string().optional(),
7311
+ description: z.string().optional(),
7312
+ theme_color: z.string().optional(),
7313
+ background_color: z.string().optional(),
7314
+ display: z.enum([
7315
+ "fullscreen",
7316
+ "standalone",
7317
+ "minimal-ui",
7318
+ "browser"
7319
+ ]).optional(),
7320
+ start_url: z.string().optional(),
7321
+ scope: z.string().optional(),
7322
+ icons: z.array(connectPwaIconSchema).optional().describe("Icons appended to the built-in set and de-duplicated by (src, sizes, purpose)."),
7323
+ file_handlers: z.array(connectPwaFileHandlerSchema).optional().describe("File associations appended after Connect's built-in .phd/.phdm handler and de-duplicated on the whole entry. Entries only declare accepted types; there is no action field, because opening the files requires Connect's own runtime handling, so every handler opens at the app root."),
7324
+ launch_handler: z.strictObject({ client_mode: z.enum([
7325
+ "auto",
7326
+ "focus-existing",
7327
+ "navigate-existing",
7328
+ "navigate-new"
7329
+ ]) }).optional().describe("How the OS launches the app for handled files/links. Connect defaults to focus-existing.")
7330
+ }).describe("Web-app-manifest field overrides.");
7331
+ const pwaShape = {
7332
+ globPatterns: z.array(z.string()).optional().describe("Extra Workbox precache globs, unioned with the built-ins."),
7333
+ globIgnores: z.array(z.string()).optional().describe("Extra precache ignore globs, unioned with the built-ins."),
7334
+ maximumFileSizeToCacheInBytes: z.number().optional().describe("Raise the precache file-size ceiling. The max across all contributors wins, so no contributor can shrink another's limit."),
7335
+ runtimeCaching: z.array(connectPwaRuntimeCachingSchema).optional().describe("Runtime-caching rules appended after the built-in rules. Workbox is first-match-wins, so these cannot override a built-in rule matching the same URL."),
7336
+ navigateFallbackDenylist: z.array(connectPwaUrlPatternSchema).optional().describe("Extra SPA navigate-fallback denylist patterns, unioned with the built-ins.")
7337
+ };
7338
+ const PWA_DESCRIPTION = "Progressive-web-app / service-worker overrides, layered on Connect's built-in PWA defaults at build time. Scalar fields deep-merge (this layer wins); the array members (icons, file_handlers, globs, runtimeCaching and denylist patterns) are additive; maximumFileSizeToCacheInBytes takes the max across contributors. (categories is not set here — it is derived from the manifest's category field.) Only applied when connect.app.offline is true.";
7339
+ /** `connect.pwa` as authored. */
7340
+ const connectPwaSchema = z.strictObject({
7341
+ manifest: connectPwaManifestSchema.optional(),
7342
+ ...pwaShape
7343
+ }).describe(PWA_DESCRIPTION);
7344
+ /**
7345
+ * The `connect` block as authored: powerhouse.config.json's `connect`, the
7346
+ * connect host's `config`, and `ph connect config` writes. Every field is
7347
+ * optional; omit the section entirely for default behaviour.
7348
+ */
7349
+ const connectConfigSchema = z.strictObject({
7350
+ branding: connectBrandingSchema.optional(),
7351
+ home: connectHomeSchema.optional(),
7352
+ app: connectAppSchema.optional(),
7353
+ ai: connectAiSchema.optional(),
7354
+ packages: connectPackagesSchema.optional(),
7355
+ drives: connectDrivesSchema.optional(),
7356
+ renown: connectRenownSchema.optional(),
7357
+ sentry: connectSentrySchema.optional(),
7358
+ openPanel: connectOpenPanelSchema.optional(),
7359
+ instance: connectInstanceSchema.optional(),
7360
+ reactor: connectReactorSchema.optional(),
7361
+ pwa: connectPwaSchema.optional()
7362
+ }).describe("Connect-specific UI customisations. All fields optional; omit the section entirely for default behaviour.");
7363
+ /** `schema` carrying `source`'s description and meta (zod keeps them per
7364
+ * instance, so `.extend()` and a rebuilt field drop them). */
7365
+ function withMetaOf(schema, source) {
7366
+ const meta = source.meta();
7367
+ return meta ? schema.meta(meta) : schema;
7368
+ }
7369
+ /** One entry of the host.js composition, projected into the served config as
7370
+ * data (module specifier + validated config). */
7371
+ const connectCompositionEntrySchema = z.strictObject({
7372
+ module: z.string(),
7373
+ config: z.record(z.string(), z.unknown()).optional()
7374
+ });
7375
+ /** A switchboard Connect routes to, from one of the host's remote backends. */
7376
+ const connectRemoteBackendSchema = z.strictObject({
7377
+ name: z.string().min(1).describe("The backend's key in the host config."),
7378
+ url: z.string().describe("A drive address on the switchboard: <switchboard>/d/<slug>."),
7379
+ requestTimeoutMs: z.number().int().positive().optional().describe("Give up on one request after this long. Default 30000."),
7380
+ breaker: z.union([z.literal(false), z.strictObject({
7381
+ failures: z.number().int().min(1).optional(),
7382
+ openMs: z.number().int().nonnegative().optional()
7383
+ })]).optional().describe("After `failures` failed requests in a row, send nothing for `openMs`. false: never stop trying."),
7384
+ realtime: z.boolean().optional().describe("Live updates over a socket. Default true.")
7385
+ });
7386
+ /** The router settings a host sets for Connect. */
7387
+ const connectRouterSettingsSchema = z.strictObject({
7388
+ newDrives: z.string().min(1).optional().describe("The remoteBackends[].name new drives are created on, with no copy in this browser. Absent: the browser reactor, else the only switchboard."),
7389
+ probeTimeoutMs: z.number().int().nonnegative().optional(),
7390
+ provisionalRouteMs: z.number().int().nonnegative().optional()
7391
+ });
7392
+ /** `sync: false` keeps no copy in this browser; unset means true. */
7393
+ const connectCollectionSchema = z.strictObject({
7394
+ backend: z.string().min(1),
7395
+ sync: z.boolean().optional()
7396
+ });
7397
+ /** `collections` holds placed drives that are not default drives, keyed by declared slug. */
7398
+ const connectRuntimeInstanceSchema = connectInstanceSchema.extend({
7399
+ reactorClient: connectReactorClientModeSchema.optional(),
7400
+ storage: z.enum(["idb", "memory"]).optional().meta({ description: "Where the browser reactor keeps its stores. `memory`: nothing outlives the page (or its shared worker). Absent: idb." }),
7401
+ remoteBackends: z.array(connectRemoteBackendSchema).optional(),
7402
+ collections: z.record(z.string(), connectCollectionSchema).optional(),
7403
+ router: connectRouterSettingsSchema.optional()
7404
+ });
7405
+ /** A remote default drive plus the backend serving it. */
7406
+ const connectRuntimeDefaultDriveRemoteSchema = connectDefaultDriveRemoteSchema.extend({
7407
+ backend: z.string().min(1).optional(),
7408
+ sync: z.boolean().optional()
7409
+ });
7410
+ const connectRuntimeDefaultDriveSchema = z.union([connectRuntimeDefaultDriveRemoteSchema, connectDefaultDriveLocalSchema]);
7411
+ const connectRuntimeDrivesSchema = withMetaOf(connectDrivesSchema.extend({ defaultDrives: withMetaOf(z.array(connectRuntimeDefaultDriveSchema).optional(), connectDrivesSchema.shape.defaultDrives) }), connectDrivesSchema);
7412
+ /** The manifest plus `categories`, derived from contributors' `category`. */
7413
+ const connectRuntimePwaManifestSchema = connectPwaManifestSchema.extend({ categories: z.array(z.string()).optional() });
7414
+ const connectRuntimePwaSchema = connectPwaSchema.extend({ manifest: connectRuntimePwaManifestSchema.optional() });
7415
+ connectConfigSchema.extend({
7416
+ composition: z.array(connectCompositionEntrySchema).optional(),
7417
+ drives: connectRuntimeDrivesSchema.optional(),
7418
+ instance: connectRuntimeInstanceSchema.optional(),
7419
+ pwa: connectRuntimePwaSchema.optional()
7420
+ });
7421
+ //#endregion
6368
7422
  //#region connect/schema-fragments.ts
6369
7423
  const powerhousePackageSchema = {
6370
7424
  type: "object",
@@ -6395,512 +7449,100 @@ const powerhousePackageSchema = {
6395
7449
  }
6396
7450
  }
6397
7451
  };
6398
- const driveSectionSchema = {
7452
+ /** Emits a zod schema as a draft-07 fragment: input shape, no `$schema`. */
7453
+ function emitJsonSchemaFragment(schema) {
7454
+ const { $schema: _, ...fragment } = toJSONSchema(schema, {
7455
+ target: "draft-7",
7456
+ io: "input",
7457
+ unrepresentable: "throw"
7458
+ });
7459
+ return fragment;
7460
+ }
7461
+ /** The authored `connect` block, as validated by Ajv. */
7462
+ const phConnectRuntimeConfigSchema = /* @__PURE__ */ emitJsonSchemaFragment(connectConfigSchema);
7463
+ //#endregion
7464
+ //#region clis/definition-sources.ts
7465
+ /**
7466
+ * @experimental The extensions a definition source may have. Hosts evaluate
7467
+ * every source as an ES module.
7468
+ */
7469
+ const DEFINITION_SOURCE_EXTENSION = /\.(?:[jt]sx?|m[jt]s)$/;
7470
+ //#endregion
7471
+ //#region clis/source-config-schema.ts
7472
+ const keyframeRuleSchema = {
6399
7473
  type: "object",
6400
7474
  additionalProperties: false,
6401
- description: "Visibility and add/delete affordances for a drive section in the sidebar.",
6402
7475
  properties: {
6403
- enabled: {
6404
- type: "boolean",
6405
- description: "When false, the section is hidden in the sidebar.",
6406
- default: true
7476
+ interval: {
7477
+ type: "integer",
7478
+ minimum: 1,
7479
+ description: "Write a keyframe every N revisions."
6407
7480
  },
6408
- allowAdd: {
6409
- type: "boolean",
6410
- description: "When false, the section's 'add drive' affordance is hidden.",
6411
- default: true
6412
- },
6413
- allowDelete: {
6414
- type: "boolean",
6415
- description: "When false, drives in this section cannot be deleted from the UI.",
6416
- default: true
7481
+ keep: {
7482
+ type: ["integer", "null"],
7483
+ minimum: 1,
7484
+ description: "Keyframes kept per document stream, newest first; null keeps them all."
6417
7485
  }
6418
7486
  }
6419
7487
  };
6420
- const pwaUrlPatternSchema = {
6421
- description: "URL match. A string is matched verbatim by Workbox; { source, flags } is rebuilt into a RegExp at build time.",
6422
- oneOf: [{ type: "string" }, {
7488
+ const definitionSourceFormatVersionSchema = {
7489
+ const: 1,
7490
+ description: "Definition-source format version. Only 1 is supported."
7491
+ };
7492
+ const definitionSourcesSchema = {
7493
+ type: "object",
7494
+ description: "Experimental. How this package authors its document models. Without it, `ph generate` uses the default authoring mode.",
7495
+ oneOf: [{
6423
7496
  type: "object",
6424
7497
  additionalProperties: false,
6425
- required: ["source"],
7498
+ required: [
7499
+ "formatVersion",
7500
+ "mode",
7501
+ "entries"
7502
+ ],
7503
+ description: "Code-first: the listed TypeScript modules declare the package's document models.",
6426
7504
  properties: {
6427
- source: {
6428
- type: "string",
6429
- description: "RegExp source."
7505
+ formatVersion: definitionSourceFormatVersionSchema,
7506
+ mode: {
7507
+ const: "code-first",
7508
+ description: "This package declares its models in TypeScript."
6430
7509
  },
6431
- flags: {
6432
- type: "string",
6433
- description: "RegExp flags (e.g. 'i')."
6434
- }
6435
- }
6436
- }]
6437
- };
6438
- const pwaIconSchema = {
6439
- type: "object",
6440
- additionalProperties: false,
6441
- required: ["src"],
6442
- properties: {
6443
- src: { type: "string" },
6444
- sizes: { type: "string" },
6445
- type: { type: "string" },
6446
- purpose: { type: "string" }
6447
- }
6448
- };
6449
- const phConnectRuntimeConfigSchema = {
6450
- type: "object",
6451
- additionalProperties: false,
6452
- description: "Connect-specific UI customisations. All fields optional; omit the section entirely for default behaviour.",
6453
- properties: {
6454
- branding: {
6455
- type: "object",
6456
- additionalProperties: false,
6457
- description: "App identity and visual branding.",
6458
- properties: {
6459
- appName: {
6460
- type: "string",
6461
- description: "Browser tab title and any in-app brand text. Defaults to 'Powerhouse Connect'."
6462
- },
6463
- homeBackground: {
6464
- type: ["string", "null"],
6465
- description: "Hero image on the empty home screen. URL or path to override; null or omitted uses the bundled default image."
6466
- }
6467
- }
6468
- },
6469
- app: {
6470
- type: "object",
6471
- additionalProperties: false,
6472
- description: "Top-level Connect application behaviour.",
6473
- properties: {
6474
- logLevel: {
6475
- type: "string",
6476
- enum: [
6477
- "debug",
6478
- "info",
6479
- "warn",
6480
- "error"
6481
- ],
6482
- description: "Log level applied by Connect's logger at boot. Affects browser-side output only.",
6483
- default: "info"
6484
- },
6485
- basePath: {
6486
- type: "string",
6487
- description: "Base path Connect is mounted under (e.g. '/connect' for subpath deploys). Normalised at runtime to start and end with '/'. Defaults to the build-time BASE_URL.",
6488
- default: "/"
6489
- },
6490
- offline: {
6491
- type: "boolean",
6492
- description: "When true (default), the build emits a precaching service worker so Connect's app shell works offline, and the SPA registers it at boot. Set false to opt this deployment out: no service worker is built, the SPA skips registration, and any previously-installed worker is unregistered.",
6493
- default: true
6494
- },
6495
- studioMode: {
6496
- type: "boolean",
6497
- description: "Studio mode. Enables builder-only capabilities: Connect loads the vetra package and exposes DocumentModel (and vetra spec types) as creatable documents. Forced on by `ph vetra` / `ph connect studio`; false by default.",
6498
- default: false
6499
- }
6500
- }
6501
- },
6502
- ai: {
6503
- type: "object",
6504
- additionalProperties: false,
6505
- description: "AI assistant (chat) behaviour.",
6506
- properties: { assistantEnabled: {
6507
- type: "boolean",
6508
- description: "When true, Connect mounts the in-browser AI assistant (bottom-right chat FAB that talks to a user-configured OpenAI-compatible endpoint and acts on the reactor). Disabled by default.",
6509
- default: false
6510
- } }
6511
- },
6512
- packages: {
6513
- type: "object",
6514
- additionalProperties: false,
6515
- description: "Runtime behaviour for the Connect package manager (separate from top-level `packages[]`, which lists which packages to load).",
6516
- properties: {
6517
- externalEnabled: {
6518
- type: "boolean",
6519
- description: "When false, Connect refuses to load any package that wasn't bundled at build time. Affirmative replacement for the legacy PH_CONNECT_EXTERNAL_PACKAGES_DISABLED env var.",
6520
- default: true
6521
- },
6522
- liveReload: {
6523
- type: "boolean",
6524
- description: "When true, Connect subscribes to the static-mode `/__packages` SSE channel so live publishes flow into the running tab without a page reload. Only works under hosting that serves this channel (e.g. ph-clint static mode).",
6525
- default: false
6526
- }
6527
- }
6528
- },
6529
- drives: {
6530
- type: "object",
6531
- additionalProperties: false,
6532
- description: "Default-drive and add-drive UI behaviour.",
6533
- properties: {
6534
- allowAddDrive: {
6535
- type: "boolean",
6536
- description: "When false, the SPA hides the 'add drive' affordance entirely (top-level). Per-section overrides live in `sections.{remote,local}.allowAdd`.",
6537
- default: true
6538
- },
6539
- defaultDrives: {
6540
- type: "array",
6541
- description: "Drives the SPA auto-connects to on first load. Each entry is either a remote drive (a URL, with optional name/icon overrides) or a local drive (created locally on first boot, with a stable id and optional name/icon/app).",
6542
- default: [],
6543
- items: { oneOf: [{
6544
- type: "object",
6545
- additionalProperties: false,
6546
- required: ["url"],
6547
- properties: {
6548
- url: { type: "string" },
6549
- name: { type: ["string", "null"] },
6550
- icon: { type: ["string", "null"] }
6551
- }
6552
- }, {
6553
- type: "object",
6554
- additionalProperties: false,
6555
- required: ["local", "id"],
6556
- properties: {
6557
- local: {
6558
- const: true,
6559
- description: "Discriminator: this entry is a local drive created on first boot."
6560
- },
6561
- id: {
6562
- type: "string",
6563
- description: "Stable drive id. The drive is created with this id on first boot and is not re-created on later boots."
6564
- },
6565
- name: { type: ["string", "null"] },
6566
- icon: { type: ["string", "null"] },
6567
- app: {
6568
- type: "string",
6569
- description: "Drive app (preferred editor) to open on the drive."
6570
- }
6571
- }
6572
- }] }
6573
- },
6574
- preserveStrategy: {
6575
- type: "string",
6576
- enum: ["preserve-all", "preserve-by-url-and-detach"],
6577
- description: "Strategy applied when defaultDrives change between deploys. 'preserve-all' keeps user-added drives untouched; 'preserve-by-url-and-detach' detaches removed default drives. No schema default — opt-in only."
6578
- },
6579
- sections: {
7510
+ entries: {
7511
+ type: "array",
7512
+ description: "The modules that declare code-first definitions. `ph generate` adds the entry of each model it scaffolds.",
7513
+ items: {
6580
7514
  type: "object",
6581
7515
  additionalProperties: false,
6582
- description: "Per-section visibility and affordance toggles. `remote` covers what was historically split into 'public' + 'cloud'; `local` is browser-local drives.",
7516
+ required: ["specifier"],
6583
7517
  properties: {
6584
- remote: driveSectionSchema,
6585
- local: driveSectionSchema
6586
- }
6587
- }
6588
- }
6589
- },
6590
- renown: {
6591
- type: "object",
6592
- additionalProperties: false,
6593
- description: "Renown identity / authentication coordinates.",
6594
- properties: {
6595
- url: {
6596
- type: "string",
6597
- description: "Renown auth service URL.",
6598
- default: "https://www.renown.id"
6599
- },
6600
- networkId: {
6601
- type: "string",
6602
- description: "CAIP-2 network namespace (e.g. 'eip155').",
6603
- default: "eip155"
6604
- },
6605
- chainId: {
6606
- type: "number",
6607
- description: "CAIP-2 chain reference within the network namespace.",
6608
- default: 1
6609
- },
6610
- namespace: {
6611
- type: "string",
6612
- description: "Renown localStorage namespace; share it across Connects to share login."
6613
- },
6614
- switchboardUrl: {
6615
- type: "string",
6616
- description: "Switchboard GraphQL URL. When set, Connect enables in-page (no-redirect) Renown sign-in; otherwise it falls back to the redirect flow via `url`."
6617
- },
6618
- adapters: {
6619
- type: "object",
6620
- additionalProperties: false,
6621
- description: "Per-adapter wallet config for in-page auth. Presence of an adapter key enables it; omit or leave empty for redirect-only behaviour.",
6622
- properties: {
6623
- rainbow: {
6624
- type: "object",
6625
- additionalProperties: false,
6626
- description: "wagmi + RainbowKit external-wallet adapter config.",
6627
- properties: {
6628
- walletConnectProjectId: {
6629
- type: "string",
6630
- description: "WalletConnect project id; required for this adapter to function."
6631
- },
6632
- infuraProjectId: {
6633
- type: "string",
6634
- description: "Optional Infura project id used to build RPC transports."
6635
- }
6636
- }
6637
- },
6638
- privy: {
6639
- type: "object",
6640
- additionalProperties: false,
6641
- description: "Privy embedded/social adapter config.",
6642
- properties: {
6643
- appId: {
6644
- type: "string",
6645
- description: "Privy application id; required for this adapter to function."
6646
- },
6647
- clientId: {
6648
- type: "string",
6649
- description: "Optional Privy client id."
6650
- },
6651
- methods: {
6652
- type: "array",
6653
- description: "Login methods this adapter offers; default per adapter when omitted.",
6654
- items: { type: "string" }
6655
- }
6656
- }
6657
- }
6658
- }
6659
- }
6660
- }
6661
- },
6662
- sentry: {
6663
- type: "object",
6664
- additionalProperties: false,
6665
- description: "Sentry error-tracking coordinates. Set `dsn` to enable Sentry; leave `dsn` null to disable. The Sentry release tag stays build-time (stamped via Vite's `define` from WORKSPACE_VERSION) so it always matches the sourcemaps uploaded by CI.",
6666
- properties: {
6667
- dsn: {
6668
- type: ["string", "null"],
6669
- description: "Sentry DSN URL. `null` disables Sentry entirely; the SPA never loads the Sentry SDK chunk.",
6670
- default: null
6671
- },
6672
- env: {
6673
- type: "string",
6674
- description: "Sentry environment label, surfaced as the `environment` tag on every event.",
6675
- default: "dev"
6676
- },
6677
- tracing: {
6678
- type: "boolean",
6679
- description: "Enable Sentry performance tracing.",
6680
- default: false
6681
- }
6682
- }
6683
- },
6684
- instance: {
6685
- type: "object",
6686
- additionalProperties: false,
6687
- required: ["namespace", "reactorWorker"],
6688
- description: "Per-instance identity. Lets one origin host multiple isolated Connect instances, each with its own storage + SharedWorker namespace.",
6689
- properties: {
6690
- namespace: {
6691
- type: ["string", "null"],
6692
- description: "Explicit storage/SharedWorker namespace for this instance. `null` derives it from the base path (and, later, the configured endpoint), so root deployments stay byte-identical.",
6693
- default: null
6694
- },
6695
- reactorWorker: {
6696
- type: "boolean",
6697
- description: "Host the reactor in a shared worker instead of on the main thread. Off by default; the main-thread reactor stays the proven path until cutover is verified.",
6698
- default: false
6699
- }
6700
- }
6701
- },
6702
- reactor: {
6703
- type: "object",
6704
- additionalProperties: false,
6705
- description: "Settings for the reactor Connect runs in the browser, on the main thread or in the shared worker alike.",
6706
- properties: { featureFlags: {
6707
- type: "object",
6708
- additionalProperties: false,
6709
- description: "Enforcement flags. Each implies its predecessors, and the reactor refuses to boot on a set that names a later flag without an earlier one. These are consensus settings: a Connect syncing with a fleet must carry the same flags the fleet does, or the two reach different replay outcomes for the same history and diverge.",
6710
- properties: {
6711
- documentDecisions: {
6712
- type: "boolean",
6713
- description: "Decide writes from the document stream rather than the document meta cache, so a backdated deletion denies the operations that sort after it.",
6714
- default: false
6715
- },
6716
- authEnforcement: {
6717
- type: "boolean",
6718
- description: "Enforce the auth scope's policy at admission, replay, and read. Requires documentDecisions.",
6719
- default: false
6720
- },
6721
- authGroups: {
6722
- type: "boolean",
6723
- description: "Let `{ group }` principals match against the rosters of the group documents a policy names. Requires authEnforcement.",
6724
- default: false
6725
- },
6726
- authConditions: {
6727
- type: "boolean",
6728
- description: "Evaluate `where` and `match` conditions on grants. Requires authGroups. Do not enable on a fleet `preflight:auth` reports as crossing a reducer version.",
6729
- default: false
6730
- }
6731
- }
6732
- } }
6733
- },
6734
- pwa: {
6735
- type: "object",
6736
- additionalProperties: false,
6737
- description: "Progressive-web-app / service-worker overrides, layered on Connect's built-in PWA defaults at build time. Scalar fields deep-merge (this layer wins); the array members (icons, file_handlers, globs, runtimeCaching and denylist patterns) are additive; maximumFileSizeToCacheInBytes takes the max across contributors. (categories is not set here — it is derived from the manifest's category field.) Only applied when connect.app.offline is true.",
6738
- properties: {
6739
- manifest: {
6740
- type: "object",
6741
- additionalProperties: false,
6742
- description: "Web-app-manifest field overrides.",
6743
- properties: {
6744
- name: { type: "string" },
6745
- short_name: { type: "string" },
6746
- description: { type: "string" },
6747
- theme_color: { type: "string" },
6748
- background_color: { type: "string" },
6749
- display: {
7518
+ specifier: {
6750
7519
  type: "string",
6751
- enum: [
6752
- "fullscreen",
6753
- "standalone",
6754
- "minimal-ui",
6755
- "browser"
6756
- ]
7520
+ pattern: `^\\./.*${DEFINITION_SOURCE_EXTENSION.source}`,
7521
+ description: "POSIX package-relative module path beginning with './'. It may not leave the package root."
6757
7522
  },
6758
- start_url: { type: "string" },
6759
- scope: { type: "string" },
6760
- icons: {
7523
+ exportPath: {
6761
7524
  type: "array",
6762
- description: "Icons appended to the built-in set and de-duplicated by (src, sizes, purpose).",
6763
- items: pwaIconSchema
6764
- },
6765
- file_handlers: {
6766
- type: "array",
6767
- description: "File associations appended after Connect's built-in .phd/.phdm handler and de-duplicated on the whole entry. Entries only declare accepted types; there is no action field, because opening the files requires Connect's own runtime handling, so every handler opens at the app root.",
6768
- items: {
6769
- type: "object",
6770
- additionalProperties: false,
6771
- required: ["accept"],
6772
- properties: {
6773
- accept: {
6774
- type: "object",
6775
- description: "MIME type → file extensions. Each extension must start with '.'; browsers ignore entries without it.",
6776
- additionalProperties: {
6777
- type: "array",
6778
- items: {
6779
- type: "string",
6780
- pattern: "^\\."
6781
- }
6782
- }
6783
- },
6784
- icons: {
6785
- type: "array",
6786
- description: "OS-level file-type icons.",
6787
- items: pwaIconSchema
6788
- },
6789
- launch_type: {
6790
- type: "string",
6791
- enum: ["single-client", "multiple-clients"]
6792
- }
6793
- }
6794
- }
6795
- },
6796
- launch_handler: {
6797
- type: "object",
6798
- additionalProperties: false,
6799
- required: ["client_mode"],
6800
- description: "How the OS launches the app for handled files/links. Connect defaults to focus-existing.",
6801
- properties: { client_mode: {
6802
- type: "string",
6803
- enum: [
6804
- "auto",
6805
- "focus-existing",
6806
- "navigate-existing",
6807
- "navigate-new"
6808
- ]
6809
- } }
6810
- }
6811
- }
6812
- },
6813
- globPatterns: {
6814
- type: "array",
6815
- items: { type: "string" },
6816
- description: "Extra Workbox precache globs, unioned with the built-ins."
6817
- },
6818
- globIgnores: {
6819
- type: "array",
6820
- items: { type: "string" },
6821
- description: "Extra precache ignore globs, unioned with the built-ins."
6822
- },
6823
- maximumFileSizeToCacheInBytes: {
6824
- type: "number",
6825
- description: "Raise the precache file-size ceiling. The max across all contributors wins, so no contributor can shrink another's limit."
6826
- },
6827
- runtimeCaching: {
6828
- type: "array",
6829
- description: "Runtime-caching rules appended after the built-in rules. Workbox is first-match-wins, so these cannot override a built-in rule matching the same URL.",
6830
- items: {
6831
- type: "object",
6832
- additionalProperties: false,
6833
- required: ["urlPattern", "handler"],
6834
- properties: {
6835
- urlPattern: pwaUrlPatternSchema,
6836
- handler: {
6837
- type: "string",
6838
- enum: [
6839
- "CacheFirst",
6840
- "CacheOnly",
6841
- "NetworkFirst",
6842
- "NetworkOnly",
6843
- "StaleWhileRevalidate"
6844
- ]
6845
- },
6846
- method: {
6847
- type: "string",
6848
- enum: [
6849
- "GET",
6850
- "POST",
6851
- "PUT",
6852
- "DELETE",
6853
- "HEAD",
6854
- "PATCH"
6855
- ]
6856
- },
6857
- options: {
6858
- type: "object",
6859
- additionalProperties: false,
6860
- properties: {
6861
- cacheName: { type: "string" },
6862
- networkTimeoutSeconds: {
6863
- type: "number",
6864
- description: "Seconds a NetworkFirst rule waits for the network before falling back to the cache."
6865
- },
6866
- expiration: {
6867
- type: "object",
6868
- additionalProperties: false,
6869
- properties: {
6870
- maxEntries: { type: "number" },
6871
- maxAgeSeconds: { type: "number" }
6872
- }
6873
- },
6874
- cacheableResponse: {
6875
- type: "object",
6876
- additionalProperties: false,
6877
- properties: {
6878
- statuses: {
6879
- type: "array",
6880
- items: { type: "number" }
6881
- },
6882
- headers: {
6883
- type: "object",
6884
- additionalProperties: { type: "string" }
6885
- }
6886
- }
6887
- }
6888
- }
6889
- }
7525
+ items: { type: "string" },
7526
+ description: "Exact property keys into the imported namespace, outermost first. Omit it to select the namespace root."
6890
7527
  }
6891
7528
  }
6892
- },
6893
- navigateFallbackDenylist: {
6894
- type: "array",
6895
- description: "Extra SPA navigate-fallback denylist patterns, unioned with the built-ins.",
6896
- items: pwaUrlPatternSchema
6897
7529
  }
6898
7530
  }
6899
7531
  }
6900
- }
7532
+ }, {
7533
+ type: "object",
7534
+ additionalProperties: false,
7535
+ required: ["formatVersion", "mode"],
7536
+ description: "Schema-first: this package authors its models as SDL plus model.json.",
7537
+ properties: {
7538
+ formatVersion: definitionSourceFormatVersionSchema,
7539
+ mode: {
7540
+ const: "schema-first",
7541
+ description: "This package declares no code-first module. `entries` is forbidden here."
7542
+ }
7543
+ }
7544
+ }]
6901
7545
  };
6902
- //#endregion
6903
- //#region clis/source-config-schema.ts
6904
7546
  const SOURCE_CONFIG_SCHEMA_ID = "https://powerhouse.inc/schemas/powerhouse.source.json";
6905
7547
  const sourceConfigSchema = {
6906
7548
  $schema: "http://json-schema.org/draft-07/schema#",
@@ -7002,6 +7644,22 @@ const sourceConfigSchema = {
7002
7644
  description: "Required when `type: postgres`."
7003
7645
  }
7004
7646
  }
7647
+ },
7648
+ keyframes: {
7649
+ type: "object",
7650
+ additionalProperties: false,
7651
+ description: "How many keyframes a document stream keeps and how often one is written. Without this block: a keyframe every 10 revisions, all kept. `PH_KEYFRAMES` overrides it.",
7652
+ properties: {
7653
+ default: {
7654
+ ...keyframeRuleSchema,
7655
+ description: "The rule for every type `types` does not name."
7656
+ },
7657
+ types: {
7658
+ type: "object",
7659
+ description: "Rules by exact document type, over `default`.",
7660
+ additionalProperties: keyframeRuleSchema
7661
+ }
7662
+ }
7005
7663
  }
7006
7664
  }
7007
7665
  },
@@ -7100,9 +7758,36 @@ const sourceConfigSchema = {
7100
7758
  connectPort: {
7101
7759
  type: "integer",
7102
7760
  description: "Port `ph vetra`'s Connect dev server listens on. Assigned per project by `ph init`. Overridden by PH_VETRA_CONNECT_PORT or --connect-port."
7761
+ },
7762
+ previewDrive: {
7763
+ type: "object",
7764
+ additionalProperties: false,
7765
+ description: "The Vetra Preview drive `ph vetra` creates in watch mode.",
7766
+ properties: { app: {
7767
+ type: "string",
7768
+ description: "Id of the drive app the preview drive opens in, e.g. a drive editor's `config.id`. `ph vetra` sets it on the drive each time it starts; leaving it out keeps the drive's current app."
7769
+ } }
7103
7770
  }
7104
7771
  }
7105
7772
  },
7773
+ assistant: {
7774
+ type: "object",
7775
+ additionalProperties: false,
7776
+ description: "The project's agent host (hosts/assistant): a headless Mastra agent API on the project switchboard.",
7777
+ properties: { port: {
7778
+ type: "integer",
7779
+ description: "Port the assistant host's chat-completions API listens on. Read by hosts/assistant/host.js (default 4910)."
7780
+ } }
7781
+ },
7782
+ workflows: {
7783
+ type: "object",
7784
+ additionalProperties: false,
7785
+ description: "Powerhouse workflows on this reactor.",
7786
+ properties: { enabled: {
7787
+ type: "boolean",
7788
+ description: "Register the workflow document models and run workflows, on the reactor and in Connect. PH_WORKFLOWS_ENABLED overrides it for the reactor, and connect.app.workflowsEnabled for Connect."
7789
+ } }
7790
+ },
7106
7791
  packageRegistryUrl: {
7107
7792
  type: "string",
7108
7793
  description: "Project-wide package registry endpoint. Used by `ph install` / `ph publish` / `ph registry-login` and Switchboard, and copied verbatim into the runtime config so the Connect SPA's Package Manager UI reads the same registry."
@@ -7110,7 +7795,8 @@ const sourceConfigSchema = {
7110
7795
  connect: {
7111
7796
  ...phConnectRuntimeConfigSchema,
7112
7797
  description: "Connect-specific UI customisations. Copied verbatim into the runtime config at build time."
7113
- }
7798
+ },
7799
+ definitionSources: definitionSourcesSchema
7114
7800
  }
7115
7801
  };
7116
7802
  //#endregion
@@ -7144,6 +7830,6 @@ function assertNodeVersion(nodeVersion = process.versions.node) {
7144
7830
  if (lt(nodeVersion, "24.0.0")) throw new NodeVersionError(nodeVersion, MINIMUM_NODE_VERSION);
7145
7831
  }
7146
7832
  //#endregion
7147
- export { AGENTS, ANALYTICS_ENGINE_CORE_PACKAGE, BOILERPLATE_ALLOWED_BUILDS, BOILERPLATE_DEPENDENCY_OVERRIDES, DEFAULT_CONFIG, DEFAULT_CONNECT_OUTDIR, DEFAULT_CONNECT_PREVIEW_PORT, DEFAULT_CONNECT_STUDIO_PORT, DEFAULT_EXPIRY_DAYS, DEFAULT_EXPIRY_SECONDS, DEFAULT_REGISTRY_LOGIN_EXPIRY, DEFAULT_REGISTRY_URL, DEFAULT_RENOWN_URL, DEFAULT_SWITCHBOARD_PORT, DEFAULT_TIMEOUT, DEFAULT_VETRA_CONNECT_PORT, DEFAULT_VETRA_DRIVE_ID, DRIVES_PRESERVE_STRATEGIES, FEATURE_DEPENDENCIES, GRAPHQL_PACKAGE, GRAPHQL_TAG_PACKAGE, HOME_DIR, LEGACY_LINT_FORMAT_DEPENDENCIES, LEGACY_LINT_FORMAT_FILES, LOG_LEVELS, MINIMUM_NODE_VERSION, NodeVersionError, PEER_EXTERNAL_DEPENDENCIES, PH_BIN, PH_GLOBAL_DIR_NAME, PH_GLOBAL_PROJECT_NAME, POWERHOUSE_CONFIG_FILE, POWERHOUSE_GLOBAL_DIR, PROJECT_PORT_BAND_SIZE, PROJECT_PORT_BAND_STUDIO, PROJECT_PORT_BAND_SWITCHBOARD, PROJECT_PORT_BAND_VETRA_CONNECT, REACTOR_API_PACKAGE, SECONDS_IN_DAY, SERVICE_ACTIONS, SOURCE_CONFIG_SCHEMA_ID, VERSIONED_DEPENDENCIES, VERSIONED_DEV_DEPENDENCIES, VERSIONED_PEER_DEPENDENCIES, accessTokenArgs, assertNodeVersion, buildArgs, commonArgs, commonServerArgs, connectArgs, connectBasePath, connectBuildArgs, connectConfigArgs, connectPreviewArgs, connectStudioArgs, debugArgs, defaultDrivesUrl, defaultManifest, directoryExists, directoryExistsSync, disableLocalPackages, drivesPreserveStrategy, externalDependencies, externalDevDependencies, fetchNpmVersionFromRegistryForTag, fetchPackageVersionFromNpmRegistry, fileExists, fileExistsSync, force, generateArgs, getConfig, getGlobalPowerhouseProjectDirPath, getLocalPowerhouseProjectDirPath, getPackageManagerAtPowerhouseProjectDirPath, getPackageManagerCommand, getPackageNameFromPackageJson, getPackageVersionFromPackageJson, getPhCliVersionInfo, getPhCmdVersionInfo, getPowerhouseProjectInfo, getPowerhouseProjectInstallCommand, getPowerhouseProjectUninstallCommand, getTagFromVersion, getTelemetryStatus, handleMutuallyExclusiveOptions, https, httpsCertFile, httpsKeyFile, initArgs, initCliTelemetry, injectPnpmAllowBuilds, inspectArgs, installArgs, isDirectory, isFile, isPowerhouseProject, listArgs, localPackage, logLevel, logVersionUpdate, loginArgs, makeDependenciesWithVersions, makeVersionedDependencies, makeVersionedDependenciesMap, migrateArgs, packageJsonExports, packageManagerArgs, packageScripts, packages, parsePackageManager, parsePackageVersion, parseTag, phCliCommandNames, phCliHelpCommands, publishArgs, registryLoginArgs, renownNamespace, renownSwitchboardUrl, resolveConnectPortDefault, resolveSwitchboardPortDefault, resolveTelemetryConsent, runCmd, runUseLocal, serviceArgs, setTelemetryConsent, sourceConfigSchema, spawnAsync, switchboardArgs, uninstallArgs, unpublishArgs, vetraArgs, vetraSwitchboardArgs, writeFileEnsuringDir };
7833
+ export { AGENTS, ANALYTICS_ENGINE_CORE_PACKAGE, BOILERPLATE_ALLOWED_BUILDS, BOILERPLATE_DEPENDENCY_OVERRIDES, BOILERPLATE_TRANSITIVE_OVERRIDES, DEFAULT_CONFIG, DEFAULT_CONNECT_OUTDIR, DEFAULT_CONNECT_PREVIEW_PORT, DEFAULT_CONNECT_STUDIO_PORT, DEFAULT_DRIVE_ICON, DEFAULT_EXPIRY_DAYS, DEFAULT_EXPIRY_SECONDS, DEFAULT_REGISTRY_LOGIN_EXPIRY, DEFAULT_REGISTRY_URL, DEFAULT_RENOWN_URL, DEFAULT_SWITCHBOARD_PORT, DEFAULT_TIMEOUT, DEFAULT_VETRA_CONNECT_PORT, DEFAULT_VETRA_DRIVE_ID, DRIVES_PRESERVE_STRATEGIES, FEATURE_DEPENDENCIES, GRAPHQL_PACKAGE, GRAPHQL_TAG_PACKAGE, HOME_DIR, KEYFRAMES_ACTIONS, KYSELY_PACKAGE, LEGACY_LINT_FORMAT_DEPENDENCIES, LEGACY_LINT_FORMAT_FILES, LOG_LEVELS, MINIMUM_NODE_VERSION, NodeVersionError, PEER_EXTERNAL_DEPENDENCIES, PH_BIN, PH_GLOBAL_DIR_NAME, PH_GLOBAL_PROJECT_NAME, PIECES_FRAMEWORK_PACKAGE, POWERHOUSE_CONFIG_FILE, POWERHOUSE_GLOBAL_DIR, PROJECT_PORT_BAND_SIZE, PROJECT_PORT_BAND_STUDIO, PROJECT_PORT_BAND_SWITCHBOARD, PROJECT_PORT_BAND_VETRA_CONNECT, REACTOR_API_PACKAGE, RELATIONAL_DB_PROCESSOR_CLASS, SECONDS_IN_DAY, SERVICE_ACTIONS, SOURCE_CONFIG_SCHEMA_ID, SpawnError, VERSIONED_DEPENDENCIES, VERSIONED_DEV_DEPENDENCIES, VERSIONED_PEER_DEPENDENCIES, accessTokenArgs, assertNodeVersion, buildArgs, buildPnpmLink, commonArgs, commonServerArgs, connectArgs, connectBasePath, connectBuildArgs, connectConfigArgs, connectPreviewArgs, connectStudioArgs, debugArgs, defaultDrivesUrl, defaultManifest, defaultStoreDirs, detectPackageManager, directoryExists, directoryExistsSync, disableLocalPackages, drivesPreserveStrategy, externalDependencies, externalDevDependencies, fetchNpmVersionFromRegistryForTag, fetchPackageVersionFromNpmRegistry, fileExists, fileExistsSync, force, generateArgs, getConfig, getGlobalPowerhouseProjectDirPath, getLocalPowerhouseProjectDirPath, getPackageManagerAtPowerhouseProjectDirPath, getPackageManagerCommand, getPackageNameFromPackageJson, getPackageVersionFromPackageJson, getPhCliVersionInfo, getPhCmdVersionInfo, getPowerhouseProjectInfo, getPowerhouseProjectInstallCommand, getPowerhouseProjectUninstallCommand, getTagFromVersion, getTelemetryStatus, handleMutuallyExclusiveOptions, https, httpsCertFile, httpsKeyFile, initArgs, initCliTelemetry, injectPnpmAllowBuilds, inspectArgs, installArgs, isDirectory, isFile, isPowerhouseProject, keyframesArgs, listArgs, localPackage, logLevel, logVersionUpdate, loginArgs, lowestVersion, makeDependenciesWithVersions, makeVersionedDependencies, makeVersionedDependenciesMap, migrateArgs, packageJsonExports, packageManagerArgs, packageScripts, packages, parsePackageManager, parsePackageVersion, parseTag, phCliCommandNames, phCliHelpCommands, publishArgs, registryLoginArgs, renownNamespace, renownSwitchboardUrl, resolveConnectPortDefault, resolvePhDir, resolveSwitchboardPortDefault, resolveTelemetryConsent, runCmd, runUseLocal, serviceArgs, setTelemetryConsent, sourceConfigSchema, spawnAsync, switchboardArgs, uninstallArgs, unpublishArgs, versionSatisfies, vetraArgs, vetraSwitchboardArgs, writeFileEnsuringDir };
7148
7834
 
7149
7835
  //# sourceMappingURL=index.mjs.map