@powerhousedao/shared 6.2.3-dev.10 → 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 -93
  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 -475
  122. package/dist/clis/constants.mjs +84 -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 +3806 -1952
  137. package/dist/clis/index.d.mts.map +1 -1
  138. package/dist/clis/index.mjs +1535 -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 +103 -101
  204. package/dist/document-drive/index.d.ts.map +1 -1
  205. package/dist/document-drive/index.js +41 -32
  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 -5144
  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 +22 -2
  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-DDpRvBK_.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-DP3QgHTq.d.ts +0 -836
  358. package/dist/index-DP3QgHTq.d.ts.map +0 -1
  359. package/dist/types-BIoOWpOT.d.ts +0 -3172
  360. package/dist/types-BIoOWpOT.d.ts.map +0 -1
  361. package/dist/types-C1in4fl3.d.ts.map +0 -1
  362. package/dist/types-DDpRvBK_.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,9 +206,14 @@ 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",
@@ -190,11 +232,11 @@ const packageJsonExports = {
190
232
  };
191
233
  const packageScripts = {
192
234
  "test:watch": "vitest",
193
- lint: "oxlint --type-aware --type-check",
194
- "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",
195
237
  format: "oxfmt",
196
238
  "format:check": "oxfmt --check",
197
- tsc: "tsc",
239
+ tsc: "ph-cli generate connect-routes && tsc",
198
240
  "tsc:watch": "tsc --watch",
199
241
  generate: "ph-cli generate",
200
242
  connect: "ph-cli connect",
@@ -202,6 +244,7 @@ const packageScripts = {
202
244
  reactor: "ph-cli reactor",
203
245
  service: "ph-cli service",
204
246
  vetra: "ph-cli vetra",
247
+ mcp: "ph-cli mcp",
205
248
  "service-startup": "bash ./node_modules/@powerhousedao/ph-cli/dist/scripts/service-startup.sh",
206
249
  "service-unstartup": "bash ./node_modules/@powerhousedao/ph-cli/dist/scripts/service-unstartup.sh"
207
250
  };
@@ -250,15 +293,14 @@ const externalDevDependencies = {
250
293
  "@types/react": "^19.2.3",
251
294
  "@types/react-dom": "^19.2.3",
252
295
  "@vitejs/plugin-react": "^6.0.1",
253
- "@vitest/coverage-v8": "4.1.1",
254
- oxfmt: "0.55.0",
255
- oxlint: "1.70.0",
256
- "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",
257
300
  tailwindcss: "^4.1.16",
258
- typescript: "^5.9.3",
301
+ typescript: "~7.0.2",
259
302
  vite: "^8.0.10",
260
- "vite-tsconfig-paths": "6.1.1",
261
- vitest: "4.1.1"
303
+ vitest: "5.0.3"
262
304
  };
263
305
  const defaultManifest = {
264
306
  name: "",
@@ -317,6 +359,28 @@ const buildArgs = {
317
359
  defaultValue: () => "dist",
318
360
  defaultValueIsSerializable: true
319
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
+ }),
320
384
  ...debugArgs
321
385
  };
322
386
  const packageManagerArgs = {
@@ -365,10 +429,9 @@ const localPackage = option({
365
429
  env: "PH_LOCAL_PACKAGE"
366
430
  });
367
431
  const disableLocalPackages = flag({
368
- type: boolean,
432
+ type: optional(boolean),
369
433
  long: "ignore-local",
370
- description: "Do not load local packages from this project",
371
- defaultValue: () => false
434
+ description: "Do not load local packages from this project"
372
435
  });
373
436
  const httpsKeyFile = option({
374
437
  type: optional(string),
@@ -422,7 +485,7 @@ const vetraSwitchboardArgs = {
422
485
  const defaultDrivesUrl = option({
423
486
  type: optional(string),
424
487
  long: "default-drives-url",
425
- description: "The default drives url to use in connect",
488
+ description: "Comma-separated drive URLs to use as Connect's default drives.",
426
489
  defaultValue: () => ""
427
490
  });
428
491
  const logLevel = option({
@@ -559,7 +622,7 @@ const connectRuntimeOverrideArgs = {
559
622
  json: option({
560
623
  type: optional(string),
561
624
  long: "json",
562
- 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."
563
626
  }),
564
627
  renownUrl: option({
565
628
  type: optional(string),
@@ -588,6 +651,11 @@ const connectRuntimeOverrideArgs = {
588
651
  long: "external-packages",
589
652
  description: "Override connect.packages.externalEnabled."
590
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
+ }),
591
659
  remoteDrivesEnabled: option({
592
660
  type: optional(cliBoolean),
593
661
  long: "remote-drives-enabled",
@@ -631,7 +699,7 @@ const connectRuntimeOverrideArgs = {
631
699
  homeBackground: option({
632
700
  type: optional(string),
633
701
  long: "home-background",
634
- 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."
635
703
  }),
636
704
  sentryDsn: option({
637
705
  type: optional(string),
@@ -679,7 +747,7 @@ const connectBuildArgs = {
679
747
  favicon: option({
680
748
  type: optional(string),
681
749
  long: "favicon",
682
- 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."
683
751
  }),
684
752
  ...commonArgs
685
753
  };
@@ -809,6 +877,44 @@ const generateArgs = {
809
877
  long: "subgraph",
810
878
  description: "Subgraph name."
811
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
+ }),
812
918
  importScriptName: option({
813
919
  type: optional(string),
814
920
  long: "import-script",
@@ -874,6 +980,52 @@ const generateArgs = {
874
980
  ...debugArgs
875
981
  };
876
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
877
1029
  //#region clis/args/inspect.ts
878
1030
  const inspectArgs = {
879
1031
  packageName: positional({
@@ -911,6 +1063,43 @@ const installArgs = {
911
1063
  ...debugArgs
912
1064
  };
913
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
914
1103
  //#region clis/args/list.ts
915
1104
  const listArgs = { ...debugArgs };
916
1105
  //#endregion
@@ -949,20 +1138,36 @@ const loginArgs = {
949
1138
  ...debugArgs
950
1139
  };
951
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
952
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.";
953
1160
  const migrateArgs = {
954
1161
  versionPositional: positional({
955
1162
  type: optional(string),
956
1163
  displayName: "version",
957
- description: "The version to migrate to. Accepts a valid semver version or `staging`, `dev`, `latest`."
1164
+ description: versionDescription
958
1165
  }),
959
1166
  version: option({
960
1167
  long: "version",
961
1168
  short: "v",
962
- type: string,
963
- description: "The version to migrate to. Accepts a valid semver version or `staging`, `dev`, `latest`.",
964
- defaultValue: () => "latest",
965
- defaultValueIsSerializable: true
1169
+ type: optional(string),
1170
+ description: versionDescription
966
1171
  }),
967
1172
  force: flag({
968
1173
  type: optional(boolean),
@@ -973,6 +1178,44 @@ const migrateArgs = {
973
1178
  ...debugArgs
974
1179
  };
975
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
976
1219
  //#region clis/args/publish.ts
977
1220
  const publishArgs = {
978
1221
  registry: option({
@@ -980,6 +1223,14 @@ const publishArgs = {
980
1223
  long: "registry",
981
1224
  description: "Registry URL to publish to (overrides config and environment)"
982
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
+ }),
983
1234
  ...debugArgs,
984
1235
  forwardedArgs: rest({
985
1236
  displayName: "npm-args",
@@ -1005,6 +1256,30 @@ const registryLoginArgs = {
1005
1256
  ...debugArgs
1006
1257
  };
1007
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
1008
1283
  //#region clis/args/switchboard.ts
1009
1284
  const switchboardArgs = {
1010
1285
  ...vetraSwitchboardArgs,
@@ -1019,7 +1294,7 @@ const switchboardArgs = {
1019
1294
  basePath: option({
1020
1295
  type: optional(string),
1021
1296
  long: "base-path",
1022
- description: "base path for the API endpoints (sets the BASE_PATH environment variable)"
1297
+ description: "base path for the API endpoints (overrides BASE_PATH)"
1023
1298
  }),
1024
1299
  keypairPath: option({
1025
1300
  type: optional(string),
@@ -1098,6 +1373,13 @@ const uninstallArgs = {
1098
1373
  //#endregion
1099
1374
  //#region clis/project-env.ts
1100
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
+ }
1101
1383
  /**
1102
1384
  * Load the project's `.env.local` and `.env` into `process.env`.
1103
1385
  *
@@ -1111,8 +1393,10 @@ let loadedFor;
1111
1393
  * call it more than once per process.
1112
1394
  */
1113
1395
  function loadProjectEnv(cwd = process.cwd()) {
1396
+ if (isDotenvDisabled()) return;
1114
1397
  if (loadedFor === cwd) return;
1115
1398
  loadedFor = cwd;
1399
+ namesBeforeLoad ??= new Set(Object.keys(process.env));
1116
1400
  dotenv.config({ path: join(cwd, ".env.local") });
1117
1401
  dotenv.config({ path: join(cwd, ".env") });
1118
1402
  }
@@ -1185,6 +1469,13 @@ const vetraArgs = {
1185
1469
  defaultValue: () => false,
1186
1470
  defaultValueIsSerializable: true
1187
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
+ }),
1188
1479
  disableConnect: flag({
1189
1480
  type: boolean,
1190
1481
  long: "disable-connect",
@@ -1217,6 +1508,8 @@ const vetraArgs = {
1217
1508
  //#endregion
1218
1509
  //#region clis/command-names.ts
1219
1510
  const phCliCommandNames = [
1511
+ "run",
1512
+ "host",
1220
1513
  "generate",
1221
1514
  "vetra",
1222
1515
  "connect",
@@ -1228,7 +1521,10 @@ const phCliCommandNames = [
1228
1521
  "registry-login",
1229
1522
  "inspect",
1230
1523
  "is",
1524
+ "keyframes",
1525
+ "mcp",
1231
1526
  "migrate",
1527
+ "model",
1232
1528
  "switchboard",
1233
1529
  "reactor",
1234
1530
  "login",
@@ -1251,7 +1547,19 @@ function helpCommand(config) {
1251
1547
  aliases
1252
1548
  });
1253
1549
  }
1254
- 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
+ }),
1255
1563
  generate: helpCommand({
1256
1564
  name: "generate",
1257
1565
  args: generateArgs,
@@ -1308,12 +1616,30 @@ const phCliHelpCommands = {
1308
1616
  description: "Inspect a package",
1309
1617
  handler: () => {}
1310
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
+ }),
1311
1631
  migrate: helpCommand({
1312
1632
  name: "migrate",
1313
1633
  args: migrateArgs,
1314
1634
  description: "Run migrations",
1315
1635
  handler: () => {}
1316
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
+ }),
1317
1643
  switchboard: helpCommand({
1318
1644
  name: "switchboard",
1319
1645
  aliases: ["reactor"],
@@ -1348,6 +1674,7 @@ const phCliHelpCommands = {
1348
1674
  handler: () => {}
1349
1675
  })
1350
1676
  };
1677
+ const phCliHelpCommands = isUniformRunnersEnabled() ? allPhCliHelpCommands : (({ run: _run, host: _host, ...rest }) => rest)(allPhCliHelpCommands);
1351
1678
  //#endregion
1352
1679
  //#region clis/args/init.ts
1353
1680
  const initArgs = {
@@ -1363,6 +1690,12 @@ const initArgs = {
1363
1690
  description: "The name of your project. A new directory will be created in your current directory with this name."
1364
1691
  }),
1365
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
+ }),
1366
1699
  tag: option({
1367
1700
  type: optional(oneOf([
1368
1701
  "latest",
@@ -1403,10 +1736,15 @@ const initArgs = {
1403
1736
  short: "r",
1404
1737
  description: "Remote drive identifier."
1405
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
+ }),
1406
1744
  clone: option({
1407
1745
  type: optional(string),
1408
1746
  long: "clone",
1409
- 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)."
1410
1748
  }),
1411
1749
  ...debugArgs
1412
1750
  };
@@ -1442,9 +1780,44 @@ const unpublishArgs = {
1442
1780
  })
1443
1781
  };
1444
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
1445
1816
  //#region ../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js
1446
1817
  var require_picocolors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1447
- let p = process || {}, argv = p.argv || [], env = p.env || {};
1818
+ let p = process || {};
1819
+ let argv = p.argv || [];
1820
+ let env = p.env || {};
1448
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);
1449
1822
  let formatter = (open, close, replace = open) => (input) => {
1450
1823
  let string = "" + input, index = string.indexOf(close, open.length);
@@ -1532,7 +1905,7 @@ var require_js_tokens = /* @__PURE__ */ __commonJSMin(((exports) => {
1532
1905
  };
1533
1906
  }));
1534
1907
  //#endregion
1535
- //#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
1536
1909
  var require_identifier = /* @__PURE__ */ __commonJSMin(((exports) => {
1537
1910
  Object.defineProperty(exports, "__esModule", { value: true });
1538
1911
  exports.isIdentifierChar = isIdentifierChar;
@@ -2540,7 +2913,7 @@ var require_identifier = /* @__PURE__ */ __commonJSMin(((exports) => {
2540
2913
  }
2541
2914
  }));
2542
2915
  //#endregion
2543
- //#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
2544
2917
  var require_keyword = /* @__PURE__ */ __commonJSMin(((exports) => {
2545
2918
  Object.defineProperty(exports, "__esModule", { value: true });
2546
2919
  exports.isKeyword = isKeyword;
@@ -2619,7 +2992,7 @@ var require_keyword = /* @__PURE__ */ __commonJSMin(((exports) => {
2619
2992
  }
2620
2993
  }));
2621
2994
  //#endregion
2622
- //#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
2623
2996
  var require_lib$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
2624
2997
  Object.defineProperty(exports, "__esModule", { value: true });
2625
2998
  Object.defineProperty(exports, "isIdentifierChar", {
@@ -2706,7 +3079,7 @@ var import_lib = (/* @__PURE__ */ __commonJSMin(((exports) => {
2706
3079
  function getDefs(enabled) {
2707
3080
  return enabled ? defsOn : defsOff;
2708
3081
  }
2709
- const sometimesKeywords = new Set([
3082
+ const sometimesKeywords = /* @__PURE__ */ new Set([
2710
3083
  "as",
2711
3084
  "async",
2712
3085
  "from",
@@ -2773,9 +3146,10 @@ var import_lib = (/* @__PURE__ */ __commonJSMin(((exports) => {
2773
3146
  else if (i === lineDiff) markerLines[lineNumber] = [0, endColumn];
2774
3147
  else markerLines[lineNumber] = [0, source[lineNumber - i].length];
2775
3148
  }
2776
- else if (startColumn === endColumn) if (startColumn) markerLines[startLine] = [startColumn, 0];
2777
- else markerLines[startLine] = true;
2778
- 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];
2779
3153
  return {
2780
3154
  start,
2781
3155
  end,
@@ -4235,49 +4609,47 @@ var require_validate_npm_package_license = /* @__PURE__ */ __commonJSMin(((expor
4235
4609
  };
4236
4610
  }));
4237
4611
  //#endregion
4238
- //#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
4239
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
+ });
4240
4629
  Object.defineProperty(exports, "__esModule", { value: !0 });
4241
4630
  exports.LRUCache = void 0;
4242
- 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) => {
4243
- typeof R.emitWarning == "function" ? R.emitWarning(c, t, e, i) : console.error(`[${e}] ${t}: ${c}`);
4244
- }, C = globalThis.AbortController, L = globalThis.AbortSignal;
4245
- if (typeof C > "u") {
4246
- L = class {
4247
- onabort;
4248
- _onabort = [];
4249
- reason;
4250
- aborted = !1;
4251
- addEventListener(i, s) {
4252
- this._onabort.push(s);
4253
- }
4254
- }, C = class {
4255
- constructor() {
4256
- t();
4257
- }
4258
- signal = new L();
4259
- abort(i) {
4260
- if (!this.signal.aborted) {
4261
- this.signal.reason = i, this.signal.aborted = !0;
4262
- for (let s of this.signal._onabort) s(i);
4263
- this.signal.onabort?.(i);
4264
- }
4265
- }
4266
- };
4267
- let c = R.env?.LRU_CACHE_IGNORE_AC_WARNING !== "1", t = () => {
4268
- 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));
4269
- };
4270
- }
4271
- 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 {
4272
4643
  constructor(t) {
4273
4644
  super(t), this.fill(0);
4274
4645
  }
4275
- }, W = class c {
4646
+ };
4647
+ var x = class c {
4276
4648
  heap;
4277
4649
  length;
4278
4650
  static #o = !1;
4279
4651
  static create(t) {
4280
- let e = M(t);
4652
+ let e = H(t);
4281
4653
  if (!e) return [];
4282
4654
  c.#o = !0;
4283
4655
  let i = new c(t, e);
@@ -4297,14 +4669,14 @@ var require_index_min = /* @__PURE__ */ __commonJSMin(((exports) => {
4297
4669
  exports.LRUCache = class c {
4298
4670
  #o;
4299
4671
  #c;
4300
- #w;
4301
- #C;
4302
- #S;
4303
- #L;
4304
- #U;
4305
4672
  #m;
4673
+ #W;
4674
+ #S;
4675
+ #M;
4676
+ #j;
4677
+ #w;
4306
4678
  get perf() {
4307
- return this.#m;
4679
+ return this.#w;
4308
4680
  }
4309
4681
  ttl;
4310
4682
  ttlResolution;
@@ -4321,48 +4693,49 @@ var require_index_min = /* @__PURE__ */ __commonJSMin(((exports) => {
4321
4693
  allowStaleOnFetchAbort;
4322
4694
  allowStaleOnFetchRejection;
4323
4695
  ignoreFetchAbort;
4696
+ backgroundFetchSize;
4324
4697
  #n;
4325
- #_;
4698
+ #b;
4326
4699
  #s;
4327
4700
  #i;
4328
4701
  #t;
4329
- #a;
4330
- #u;
4331
4702
  #l;
4703
+ #u;
4704
+ #a;
4332
4705
  #h;
4333
- #b;
4706
+ #_;
4334
4707
  #r;
4335
4708
  #y;
4336
- #A;
4709
+ #F;
4337
4710
  #d;
4338
4711
  #g;
4339
4712
  #T;
4340
- #v;
4713
+ #U;
4341
4714
  #f;
4342
- #I;
4715
+ #D;
4343
4716
  static unsafeExposeInternals(t) {
4344
4717
  return {
4345
- starts: t.#A,
4718
+ starts: t.#F,
4346
4719
  ttls: t.#d,
4347
4720
  autopurgeTimers: t.#g,
4348
4721
  sizes: t.#y,
4349
4722
  keyMap: t.#s,
4350
4723
  keyList: t.#i,
4351
4724
  valList: t.#t,
4352
- next: t.#a,
4725
+ next: t.#l,
4353
4726
  prev: t.#u,
4354
4727
  get head() {
4355
- return t.#l;
4728
+ return t.#a;
4356
4729
  },
4357
4730
  get tail() {
4358
4731
  return t.#h;
4359
4732
  },
4360
- free: t.#b,
4733
+ free: t.#_,
4361
4734
  isBackgroundFetch: (e) => t.#e(e),
4362
- backgroundFetch: (e, i, s, n) => t.#x(e, i, s, n),
4363
- moveToTail: (e) => t.#D(e),
4364
- indexes: (e) => t.#F(e),
4365
- 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),
4366
4739
  isStale: (e) => t.#p(e)
4367
4740
  };
4368
4741
  }
@@ -4373,188 +4746,190 @@ var require_index_min = /* @__PURE__ */ __commonJSMin(((exports) => {
4373
4746
  return this.#c;
4374
4747
  }
4375
4748
  get calculatedSize() {
4376
- return this.#_;
4749
+ return this.#b;
4377
4750
  }
4378
4751
  get size() {
4379
4752
  return this.#n;
4380
4753
  }
4381
4754
  get fetchMethod() {
4382
- return this.#L;
4755
+ return this.#M;
4383
4756
  }
4384
4757
  get memoMethod() {
4385
- return this.#U;
4758
+ return this.#j;
4386
4759
  }
4387
4760
  get dispose() {
4388
- return this.#w;
4761
+ return this.#m;
4389
4762
  }
4390
4763
  get onInsert() {
4391
- return this.#C;
4764
+ return this.#W;
4392
4765
  }
4393
4766
  get disposeAfter() {
4394
4767
  return this.#S;
4395
4768
  }
4396
4769
  constructor(t) {
4397
- 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;
4398
- if (v !== void 0 && typeof v?.now != "function") throw new TypeError("perf option must have a now() method if specified");
4399
- if (this.#m = v ?? G, e !== 0 && !y(e)) throw new TypeError("max option must be a nonnegative integer");
4400
- let O = e ? M(e) : Array;
4401
- if (!O) throw new Error("invalid max value: " + e);
4402
- 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) {
4403
4776
  if (!this.#c && !this.maxEntrySize) throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");
4404
4777
  if (typeof this.sizeCalculation != "function") throw new TypeError("sizeCalculation set to non-function");
4405
4778
  }
4406
4779
  if (S !== void 0 && typeof S != "function") throw new TypeError("memoMethod must be a function if defined");
4407
- if (this.#U = S, l !== void 0 && typeof l != "function") throw new TypeError("fetchMethod must be a function if specified");
4408
- 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) {
4409
- if (this.#c !== 0 && !y(this.#c)) throw new TypeError("maxSize must be a positive integer if specified");
4410
- if (!y(this.maxEntrySize)) throw new TypeError("maxEntrySize must be a positive integer if specified");
4411
- 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();
4412
4785
  }
4413
- 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) {
4414
- if (!y(this.ttl)) throw new TypeError("ttl must be a positive integer if specified");
4415
- 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();
4416
4789
  }
4417
4790
  if (this.#o === 0 && this.ttl === 0 && this.#c === 0) throw new TypeError("At least one of max, maxSize, or ttl is required");
4418
4791
  if (!this.ttlAutopurge && !this.#o && !this.#c) {
4419
- let E = "LRU_CACHE_UNBOUNDED";
4420
- 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));
4421
4794
  }
4422
4795
  }
4423
4796
  getRemainingTTL(t) {
4424
- return this.#s.has(t) ? Infinity : 0;
4425
- }
4426
- #j() {
4427
- let t = new z(this.#o), e = new z(this.#o);
4428
- this.#d = t, this.#A = e;
4429
- let i = this.ttlAutopurge ? new Array(this.#o) : void 0;
4430
- this.#g = i, this.#N = (h, r, a = this.#m.now()) => {
4431
- 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);
4432
4805
  }, this.#R = (h) => {
4433
- 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]);
4434
4807
  };
4435
- let s = this.ttlAutopurge ? (h, r) => {
4436
- if (i?.[h] && (clearTimeout(i[h]), i[h] = void 0), r && r !== 0 && i) {
4437
- let a = setTimeout(() => {
4438
- this.#p(h) && this.#E(this.#i[h], "expire");
4439
- }, r + 1);
4440
- 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;
4441
4814
  }
4442
4815
  } : () => {};
4443
- this.#z = (h, r) => {
4444
- if (t[r]) {
4445
- let a = t[r], w = e[r];
4446
- if (!a || !w) return;
4447
- h.ttl = a, h.start = w, h.now = n || o();
4448
- 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);
4449
4822
  }
4450
4823
  };
4451
- let n = 0, o = () => {
4452
- let h = this.#m.now();
4824
+ let n = 0, r = () => {
4825
+ let h = this.#w.now();
4453
4826
  if (this.ttlResolution > 0) {
4454
4827
  n = h;
4455
- let r = setTimeout(() => n = 0, this.ttlResolution);
4456
- r.unref && r.unref();
4828
+ let a = setTimeout(() => n = 0, this.ttlResolution);
4829
+ a.unref && a.unref();
4457
4830
  }
4458
4831
  return h;
4459
4832
  };
4460
4833
  this.getRemainingTTL = (h) => {
4461
- let r = this.#s.get(h);
4462
- if (r === void 0) return 0;
4463
- let a = t[r], w = e[r];
4464
- if (!a || !w) return Infinity;
4465
- 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);
4466
4839
  }, this.#p = (h) => {
4467
- let r = e[h], a = t[h];
4468
- return !!a && !!r && (n || o()) - r > a;
4840
+ let a = e[h], o = t[h];
4841
+ return !!o && !!a && (n || r()) - a > o;
4469
4842
  };
4470
4843
  }
4471
4844
  #R = () => {};
4472
- #z = () => {};
4473
- #N = () => {};
4845
+ #E = () => {};
4846
+ #H = () => {};
4474
4847
  #p = () => !1;
4475
- #B() {
4476
- let t = new z(this.#o);
4477
- this.#_ = 0, this.#y = t, this.#W = (e) => {
4478
- this.#_ -= t[e], t[e] = 0;
4479
- }, this.#P = (e, i, s, n) => {
4480
- if (this.#e(i)) return 0;
4481
- if (!y(s)) if (n) {
4482
- if (typeof n != "function") throw new TypeError("sizeCalculation must be a function");
4483
- if (s = n(i, e), !y(s)) throw new TypeError("sizeCalculation return invalid (expect positive integer)");
4484
- } 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
+ }
4485
4860
  return s;
4486
- }, this.#M = (e, i, s) => {
4861
+ }, this.#I = (e, i, s) => {
4487
4862
  if (t[e] = i, this.#c) {
4488
4863
  let n = this.#c - t[e];
4489
- for (; this.#_ > n;) this.#G(!0);
4864
+ for (; this.#b > n;) this.#P(!0);
4490
4865
  }
4491
- this.#_ += t[e], s && (s.entrySize = i, s.totalCalculatedSize = this.#_);
4866
+ this.#b += t[e], s && (s.entrySize = i, s.totalCalculatedSize = this.#b);
4492
4867
  };
4493
4868
  }
4494
- #W = (t) => {};
4495
- #M = (t, e, i) => {};
4496
- #P = (t, e, i, s) => {
4869
+ #C = (t) => {};
4870
+ #I = (t, e, i) => {};
4871
+ #N = (t, e, i, s) => {
4497
4872
  if (i || s) throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");
4498
4873
  return 0;
4499
4874
  };
4500
- *#F({ allowStale: t = this.allowStale } = {}) {
4501
- 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];
4502
4877
  }
4503
- *#O({ allowStale: t = this.allowStale } = {}) {
4504
- 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];
4505
4880
  }
4506
- #H(t) {
4881
+ #V(t) {
4507
4882
  return t !== void 0 && this.#s.get(this.#i[t]) === t;
4508
4883
  }
4509
4884
  *entries() {
4510
- 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]]);
4511
4886
  }
4512
4887
  *rentries() {
4513
- 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]]);
4514
4889
  }
4515
4890
  *keys() {
4516
- for (let t of this.#F()) {
4891
+ for (let t of this.#A()) {
4517
4892
  let e = this.#i[t];
4518
4893
  e !== void 0 && !this.#e(this.#t[t]) && (yield e);
4519
4894
  }
4520
4895
  }
4521
4896
  *rkeys() {
4522
- for (let t of this.#O()) {
4897
+ for (let t of this.#z()) {
4523
4898
  let e = this.#i[t];
4524
4899
  e !== void 0 && !this.#e(this.#t[t]) && (yield e);
4525
4900
  }
4526
4901
  }
4527
4902
  *values() {
4528
- 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]);
4529
4904
  }
4530
4905
  *rvalues() {
4531
- 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]);
4532
4907
  }
4533
4908
  [Symbol.iterator]() {
4534
4909
  return this.entries();
4535
4910
  }
4536
4911
  [Symbol.toStringTag] = "LRUCache";
4537
4912
  find(t, e = {}) {
4538
- for (let i of this.#F()) {
4913
+ for (let i of this.#A()) {
4539
4914
  let s = this.#t[i], n = this.#e(s) ? s.__staleWhileFetching : s;
4540
- 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);
4541
4916
  }
4542
4917
  }
4543
4918
  forEach(t, e = this) {
4544
- for (let i of this.#F()) {
4919
+ for (let i of this.#A()) {
4545
4920
  let s = this.#t[i], n = this.#e(s) ? s.__staleWhileFetching : s;
4546
4921
  n !== void 0 && t.call(e, n, this.#i[i], this);
4547
4922
  }
4548
4923
  }
4549
4924
  rforEach(t, e = this) {
4550
- for (let i of this.#O()) {
4925
+ for (let i of this.#z()) {
4551
4926
  let s = this.#t[i], n = this.#e(s) ? s.__staleWhileFetching : s;
4552
4927
  n !== void 0 && t.call(e, n, this.#i[i], this);
4553
4928
  }
4554
4929
  }
4555
4930
  purgeStale() {
4556
4931
  let t = !1;
4557
- 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);
4558
4933
  return t;
4559
4934
  }
4560
4935
  info(t) {
@@ -4563,24 +4938,24 @@ var require_index_min = /* @__PURE__ */ __commonJSMin(((exports) => {
4563
4938
  let i = this.#t[e], s = this.#e(i) ? i.__staleWhileFetching : i;
4564
4939
  if (s === void 0) return;
4565
4940
  let n = { value: s };
4566
- if (this.#d && this.#A) {
4567
- let o = this.#d[e], h = this.#A[e];
4568
- 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();
4569
4944
  }
4570
4945
  return this.#y && (n.size = this.#y[e]), n;
4571
4946
  }
4572
4947
  dump() {
4573
4948
  let t = [];
4574
- for (let e of this.#F({ allowStale: !0 })) {
4949
+ for (let e of this.#A({ allowStale: !0 })) {
4575
4950
  let i = this.#i[e], s = this.#t[e], n = this.#e(s) ? s.__staleWhileFetching : s;
4576
4951
  if (n === void 0 || i === void 0) continue;
4577
- let o = { value: n };
4578
- if (this.#d && this.#A) {
4579
- o.ttl = this.#d[e];
4580
- let h = this.#m.now() - this.#A[e];
4581
- 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);
4582
4957
  }
4583
- this.#y && (o.size = this.#y[e]), t.unshift([i, o]);
4958
+ this.#y && (r.size = this.#y[e]), t.unshift([i, r]);
4584
4959
  }
4585
4960
  return t;
4586
4961
  }
@@ -4589,53 +4964,60 @@ var require_index_min = /* @__PURE__ */ __commonJSMin(((exports) => {
4589
4964
  for (let [e, i] of t) {
4590
4965
  if (i.start) {
4591
4966
  let s = Date.now() - i.start;
4592
- i.start = this.#m.now() - s;
4967
+ i.start = this.#w.now() - s;
4593
4968
  }
4594
- this.set(e, i.value, i);
4969
+ this.#O(e, i.value, i);
4595
4970
  }
4596
4971
  }
4597
4972
  set(t, e, i = {}) {
4598
- if (e === void 0) return this.delete(t), this;
4599
- 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);
4600
- if (this.maxEntrySize && w > this.maxEntrySize) return r && (r.set = "miss", r.maxEntrySizeExceeded = !0), this.#E(t, "set"), this;
4601
- let f = this.#n === 0 ? void 0 : this.#s.get(t);
4602
- 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");
4603
4987
  else {
4604
- this.#D(f);
4605
- let d = this.#t[f];
4606
- if (e !== d) {
4607
- if (this.#v && this.#e(d)) {
4608
- d.__abortController.abort(/* @__PURE__ */ new Error("replaced"));
4609
- let { __staleWhileFetching: g } = d;
4610
- g !== void 0 && !o && (this.#T && this.#w?.(g, t, "set"), this.#f && this.#r?.push([
4611
- 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,
4612
4996
  t,
4613
4997
  "set"
4614
4998
  ]));
4615
- } else o || (this.#T && this.#w?.(d, t, "set"), this.#f && this.#r?.push([
4616
- d,
4999
+ } else this.#T && this.#m?.(p, t, "set"), this.#f && this.#r?.push([
5000
+ p,
4617
5001
  t,
4618
5002
  "set"
4619
- ]));
4620
- if (this.#W(f), this.#M(f, w, r), this.#t[f] = e, r) {
4621
- r.set = "replace";
4622
- let g = d && this.#e(d) ? d.__staleWhileFetching : d;
4623
- 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);
4624
5007
  }
4625
- } else r && (r.set = "update");
4626
- this.#I && this.onInsert?.(e, t, e === d ? "update" : "replace");
5008
+ } else d || (o && (o.set = "update"), this.#D && this.onInsert?.(e, t, "update"));
4627
5009
  }
4628
- 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) {
4629
- let d = this.#r, g;
4630
- 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);
4631
5013
  }
4632
5014
  return this;
4633
5015
  }
4634
5016
  pop() {
4635
5017
  try {
4636
5018
  for (; this.#n;) {
4637
- let t = this.#t[this.#l];
4638
- if (this.#G(!0), this.#e(t)) {
5019
+ let t = this.#t[this.#a];
5020
+ if (this.#P(!0), this.#e(t)) {
4639
5021
  if (t.__staleWhileFetching) return t.__staleWhileFetching;
4640
5022
  } else if (t !== void 0) return t;
4641
5023
  }
@@ -4646,163 +5028,214 @@ var require_index_min = /* @__PURE__ */ __commonJSMin(((exports) => {
4646
5028
  }
4647
5029
  }
4648
5030
  }
4649
- #G(t) {
4650
- let e = this.#l, i = this.#i[e], s = this.#t[e];
4651
- 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([
4652
- 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,
4653
5037
  i,
4654
5038
  "evict"
4655
- ])), 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;
4656
5040
  }
4657
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 = {}) {
4658
5048
  let { updateAgeOnHas: i = this.updateAgeOnHas, status: s } = e, n = this.#s.get(t);
4659
5049
  if (n !== void 0) {
4660
- let o = this.#t[n];
4661
- if (this.#e(o) && o.__staleWhileFetching === void 0) return !1;
4662
- if (this.#p(n)) s && (s.has = "stale", this.#z(s, n));
4663
- 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;
4664
5054
  } else s && (s.has = "miss");
4665
5055
  return !1;
4666
5056
  }
4667
5057
  peek(t, e = {}) {
4668
- let { allowStale: i = this.allowStale } = e, s = this.#s.get(t);
4669
- if (s === void 0 || !i && this.#p(s)) return;
4670
- let n = this.#t[s];
4671
- 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;
4672
5071
  }
4673
- #x(t, e, i, s) {
5072
+ #G(t, e, i, s) {
4674
5073
  let n = e === void 0 ? void 0 : this.#t[e];
4675
5074
  if (this.#e(n)) return n;
4676
- let o = new C(), { signal: h } = i;
4677
- h?.addEventListener("abort", () => o.abort(h.reason), { signal: o.signal });
4678
- let r = {
4679
- 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,
4680
5079
  options: i,
4681
5080
  context: s
4682
- }, a = (p, _ = !1) => {
4683
- let { aborted: l } = o.signal, S = i.ignoreFetchAbort && p !== void 0, b = i.ignoreFetchAbort || !!(i.allowStaleOnFetchAbort && p !== void 0);
4684
- 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);
4685
- let m = g, u = this.#t[e];
4686
- 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;
4687
- }, w = (p) => (i.status && (i.status.fetchRejected = !0, i.status.fetchError = p), f(p, !1)), f = (p, _) => {
4688
- let { aborted: l } = o.signal, S = l && i.allowStaleOnFetchAbort, b = S || i.allowStaleOnFetchRejection, m = b || i.noDeleteOnFetchRejection, u = g;
4689
- 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;
4690
- if (u.__returned === u) throw p;
4691
- }, d = (p, _) => {
4692
- let l = this.#L?.(t, n, r);
4693
- l && l instanceof Promise && l.then((S) => p(S === void 0 ? void 0 : S), _), o.signal.addEventListener("abort", () => {
4694
- (!i.ignoreFetchAbort || i.allowStaleOnFetchAbort) && (p(void 0), i.allowStaleOnFetchAbort && (p = (S) => a(S, !0)));
4695
- });
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);
4696
5095
  };
4697
5096
  i.status && (i.status.fetchDispatched = !0);
4698
- let g = new Promise(d).then(a, w), A = Object.assign(g, {
4699
- __abortController: o,
5097
+ let u = new Promise(y).then(o, d), p = Object.assign(u, {
5098
+ __abortController: r,
4700
5099
  __staleWhileFetching: n,
4701
5100
  __returned: void 0
4702
5101
  });
4703
- return e === void 0 ? (this.set(t, A, {
4704
- ...r.options,
5102
+ return e === void 0 ? (this.#O(t, p, {
5103
+ ...a.options,
4705
5104
  status: void 0
4706
- }), e = this.#s.get(t)) : this.#t[e] = A, A;
5105
+ }), e = this.#s.get(t)) : this.#t[e] = p, p;
4707
5106
  }
4708
5107
  #e(t) {
4709
- if (!this.#v) return !1;
5108
+ if (!this.#U) return !1;
4710
5109
  let e = t;
4711
- 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;
4712
5111
  }
4713
- async fetch(t, e = {}) {
4714
- 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;
4715
- 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, {
4716
5121
  allowStale: i,
4717
5122
  updateAgeOnGet: s,
4718
5123
  noDeleteOnStaleGet: n,
4719
5124
  status: l
4720
5125
  });
4721
- let b = {
5126
+ let F = {
4722
5127
  allowStale: i,
4723
5128
  updateAgeOnGet: s,
4724
5129
  noDeleteOnStaleGet: n,
4725
- ttl: o,
5130
+ ttl: r,
4726
5131
  noDisposeOnSet: h,
4727
- size: r,
4728
- sizeCalculation: a,
4729
- noUpdateTTL: w,
4730
- noDeleteOnFetchRejection: f,
4731
- allowStaleOnFetchRejection: d,
4732
- allowStaleOnFetchAbort: A,
4733
- ignoreFetchAbort: g,
5132
+ size: a,
5133
+ sizeCalculation: o,
5134
+ noUpdateTTL: d,
5135
+ noDeleteOnFetchRejection: _,
5136
+ allowStaleOnFetchRejection: y,
5137
+ allowStaleOnFetchAbort: p,
5138
+ ignoreFetchAbort: u,
4734
5139
  status: l,
4735
5140
  signal: S
4736
- }, m = this.#s.get(t);
4737
- if (m === void 0) {
5141
+ }, w = this.#s.get(t);
5142
+ if (w === void 0) {
4738
5143
  l && (l.fetch = "miss");
4739
- let u = this.#x(t, m, b, p);
4740
- return u.__returned = u;
5144
+ let m = this.#G(t, w, F, f);
5145
+ return m.__returned = m;
4741
5146
  } else {
4742
- let u = this.#t[m];
4743
- if (this.#e(u)) {
4744
- let E = i && u.__staleWhileFetching !== void 0;
4745
- 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;
4746
5151
  }
4747
- let T = this.#p(m);
4748
- if (!_ && !T) return l && (l.fetch = "hit"), this.#D(m), s && this.#R(m), l && this.#z(l, m), u;
4749
- let F = this.#x(t, m, b, p), O = F.__staleWhileFetching !== void 0 && i;
4750
- 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;
4751
5156
  }
4752
5157
  }
4753
- async forceFetch(t, e = {}) {
4754
- 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);
4755
5166
  if (i === void 0) throw new Error("fetch() returned undefined");
4756
5167
  return i;
4757
5168
  }
4758
5169
  memo(t, e = {}) {
4759
- 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;
4760
5177
  if (!i) throw new Error("no memoMethod provided to constructor");
4761
- let { context: s, forceRefresh: n, ...o } = e, h = this.get(t, o);
4762
- if (!n && h !== void 0) return h;
4763
- let r = i(t, h, {
4764
- 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,
4765
5184
  context: s
4766
5185
  });
4767
- return this.set(t, r, o), r;
5186
+ return n && (n.value = d), this.#O(t, d, h), d;
4768
5187
  }
4769
5188
  get(t, e = {}) {
4770
- let { allowStale: i = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: n = this.noDeleteOnStaleGet, status: o } = e, h = this.#s.get(t);
4771
- if (h !== void 0) {
4772
- let r = this.#t[h], a = this.#e(r);
4773
- 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));
4774
- } 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);
4775
5202
  }
4776
- #k(t, e) {
4777
- this.#u[e] = t, this.#a[t] = e;
5203
+ #B(t, e) {
5204
+ this.#u[e] = t, this.#l[t] = e;
4778
5205
  }
4779
- #D(t) {
4780
- 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);
4781
5208
  }
4782
5209
  delete(t) {
4783
- return this.#E(t, "delete");
4784
- }
4785
- #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
+ });
4786
5219
  let i = !1;
4787
5220
  if (this.#n !== 0) {
4788
5221
  let s = this.#s.get(t);
4789
- 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);
4790
5223
  else {
4791
- this.#W(s);
5224
+ this.#C(s);
4792
5225
  let n = this.#t[s];
4793
- 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([
4794
5227
  n,
4795
5228
  t,
4796
5229
  e
4797
5230
  ])), this.#s.delete(t), this.#i[s] = void 0, this.#t[s] = void 0, s === this.#h) this.#h = this.#u[s];
4798
- else if (s === this.#l) this.#l = this.#a[s];
5231
+ else if (s === this.#a) this.#a = this.#l[s];
4799
5232
  else {
4800
- let o = this.#u[s];
4801
- this.#a[o] = this.#a[s];
4802
- let h = this.#a[s];
5233
+ let r = this.#u[s];
5234
+ this.#l[r] = this.#l[s];
5235
+ let h = this.#l[s];
4803
5236
  this.#u[h] = this.#u[s];
4804
5237
  }
4805
- this.#n--, this.#b.push(s);
5238
+ this.#n--, this.#_.push(s);
4806
5239
  }
4807
5240
  }
4808
5241
  if (this.#f && this.#r?.length) {
@@ -4812,27 +5245,27 @@ var require_index_min = /* @__PURE__ */ __commonJSMin(((exports) => {
4812
5245
  return i;
4813
5246
  }
4814
5247
  clear() {
4815
- return this.#V("delete");
5248
+ return this.#$("delete");
4816
5249
  }
4817
- #V(t) {
4818
- for (let e of this.#O({ allowStale: !0 })) {
5250
+ #$(t) {
5251
+ for (let e of this.#z({ allowStale: !0 })) {
4819
5252
  let i = this.#t[e];
4820
5253
  if (this.#e(i)) i.__abortController.abort(/* @__PURE__ */ new Error("deleted"));
4821
5254
  else {
4822
5255
  let s = this.#i[e];
4823
- 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([
4824
5257
  i,
4825
5258
  s,
4826
5259
  t
4827
5260
  ]);
4828
5261
  }
4829
5262
  }
4830
- if (this.#s.clear(), this.#t.fill(void 0), this.#i.fill(void 0), this.#d && this.#A) {
4831
- 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);
4832
5265
  for (let e of this.#g ?? []) e !== void 0 && clearTimeout(e);
4833
5266
  this.#g?.fill(void 0);
4834
5267
  }
4835
- 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) {
4836
5269
  let e = this.#r, i;
4837
5270
  for (; i = e?.shift();) this.#S?.(...i);
4838
5271
  }
@@ -5028,8 +5461,10 @@ var require_parse_url = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5028
5461
  if (Object.prototype.hasOwnProperty.call(protocols, proto)) return arg;
5029
5462
  if (arg.substr(firstColon, 3) === "://") return arg;
5030
5463
  const firstAt = arg.indexOf("@");
5031
- if (firstAt > -1) if (firstAt > firstColon) return `git+ssh://${arg}`;
5032
- else return arg;
5464
+ if (firstAt > -1) {
5465
+ if (firstAt > firstColon) return `git+ssh://${arg}`;
5466
+ else return arg;
5467
+ }
5033
5468
  return `${arg.slice(0, firstColon + 1)}//${arg.slice(firstColon + 1)}`;
5034
5469
  };
5035
5470
  const correctUrl = (giturl) => {
@@ -5066,7 +5501,8 @@ var require_from_url = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5066
5501
  };
5067
5502
  module.exports = (giturl, opts, { gitHosts, protocols }) => {
5068
5503
  if (!giturl) return;
5069
- const parsed = parseUrl(isGitHubShorthand(giturl) ? `github:${giturl}` : giturl, protocols);
5504
+ const correctedUrl = isGitHubShorthand(giturl) ? `github:${giturl}` : giturl;
5505
+ const parsed = parseUrl(correctedUrl, protocols);
5070
5506
  if (!parsed) return;
5071
5507
  const gitHostShortcut = gitHosts.byShortcut[parsed.protocol];
5072
5508
  const gitHostDomain = gitHosts.byDomain[parsed.hostname.startsWith("www.") ? parsed.hostname.slice(4) : parsed.hostname];
@@ -5529,17 +5965,22 @@ var require_fixer = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5529
5965
  var hosted = hostedGitInfo.fromUrl(data.repository.url);
5530
5966
  if (hosted && hosted.bugs()) data.bugs = { url: hosted.bugs() };
5531
5967
  } else if (data.bugs) {
5532
- if (typeof data.bugs === "string") if (isEmail(data.bugs)) data.bugs = { email: data.bugs };
5533
- else if (URL$1.canParse(data.bugs)) data.bugs = { url: data.bugs };
5534
- else this.warn("nonEmailUrlBugsString");
5535
- 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 {
5536
5973
  bugsTypos(data.bugs, this.warn);
5537
5974
  var oldBugs = data.bugs;
5538
5975
  data.bugs = {};
5539
- if (oldBugs.url) if (URL$1.canParse(oldBugs.url)) data.bugs.url = oldBugs.url;
5540
- else this.warn("nonUrlBugsUrlField");
5541
- if (oldBugs.email) if (typeof oldBugs.email === "string" && isEmail(oldBugs.email)) data.bugs.email = oldBugs.email;
5542
- 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
+ }
5543
5984
  }
5544
5985
  if (!data.bugs.email && !data.bugs.url) {
5545
5986
  delete data.bugs;
@@ -5771,10 +6212,19 @@ const _readPackage = (file, normalize) => {
5771
6212
  return json;
5772
6213
  };
5773
6214
  async function readPackage({ cwd, normalize = true } = {}) {
5774
- return _readPackage(await fsPromises.readFile(getPackagePath(cwd), "utf8"), normalize);
6215
+ const packageFile = await fsPromises.readFile(getPackagePath(cwd), "utf8");
6216
+ return _readPackage(packageFile, normalize);
5775
6217
  }
5776
6218
  //#endregion
5777
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
+ };
5778
6228
  function spawnAsync(command, args, options = {}) {
5779
6229
  return new Promise((resolve, reject) => {
5780
6230
  const child = spawn(command, args, {
@@ -5788,26 +6238,36 @@ function spawnAsync(command, args, options = {}) {
5788
6238
  });
5789
6239
  let stdout = "";
5790
6240
  let stderr = "";
6241
+ child.stdout?.setEncoding("utf8");
6242
+ child.stderr?.setEncoding("utf8");
5791
6243
  child.stdout?.on("data", (d) => {
5792
- stdout += d.toString();
6244
+ stdout += d;
5793
6245
  });
5794
6246
  child.stderr?.on("data", (d) => {
5795
- stderr += d.toString();
6247
+ stderr += d;
5796
6248
  });
5797
6249
  child.on("error", reject);
5798
6250
  child.on("close", (code) => {
5799
6251
  if (code === 0) resolve(stdout.trim());
5800
- 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()));
5801
6253
  });
5802
6254
  });
5803
6255
  }
5804
6256
  //#endregion
5805
6257
  //#region clis/file-system/dependencies.ts
5806
6258
  async function fetchNpmVersionFromRegistryForTag(packageName, tag) {
5807
- const cleanedVersion = clean(await fetchPackageVersionFromNpmRegistry(`${packageName}@${tag}`));
6259
+ const version = await fetchPackageVersionFromNpmRegistry(`${packageName}@${tag}`);
6260
+ const cleanedVersion = clean(version);
5808
6261
  if (!cleanedVersion) throw new Error(`Failed to fetch version for package "${packageName}" at tag "${tag}".`);
5809
6262
  return cleanedVersion;
5810
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
+ }
5811
6271
  async function fetchPackageVersionFromNpmRegistry(packageSpecifier, registryUrl) {
5812
6272
  const failedFetchErrorMessage = `Failed to fetch version from npm registry for ${packageSpecifier}.`;
5813
6273
  try {
@@ -5885,6 +6345,96 @@ async function getPackageVersionFromPackageJson(packageJsonPath) {
5885
6345
  return (await readPackage({ cwd: packageJsonPath })).version;
5886
6346
  }
5887
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
5888
6438
  //#region clis/file-system/directory-exists.ts
5889
6439
  async function directoryExists(path) {
5890
6440
  if (!path) return false;
@@ -6054,7 +6604,7 @@ PH CLI package manager: ${packageManager}
6054
6604
  //#endregion
6055
6605
  //#region clis/file-system/write-file-ensuring-dir.ts
6056
6606
  async function writeFileEnsuringDir(filePath, contents) {
6057
- await mkdir(dirname(filePath), { recursive: true });
6607
+ await mkdir(dirname(resolve(filePath)), { recursive: true });
6058
6608
  await writeFile(filePath, contents, { encoding: "utf-8" });
6059
6609
  }
6060
6610
  //#endregion
@@ -6276,18 +6826,35 @@ function getTelemetryStatus() {
6276
6826
  //#region constants.ts
6277
6827
  const PACKAGES_DEPENDENCIES = [
6278
6828
  "@powerhousedao/builder-tools",
6829
+ "@powerhousedao/clint",
6279
6830
  "@powerhousedao/codegen",
6280
6831
  "@powerhousedao/common",
6281
6832
  "@powerhousedao/config",
6833
+ "@powerhousedao/connect-core",
6282
6834
  "@powerhousedao/design-system",
6835
+ "@powerhousedao/desktop",
6836
+ "@powerhousedao/host-core",
6283
6837
  "document-drive",
6284
6838
  "document-model",
6839
+ "@powerhousedao/opentelemetry-instrumentation-reactor",
6840
+ "@powerhousedao/pieces-framework",
6841
+ "@powerhousedao/portle",
6285
6842
  "@powerhousedao/reactor",
6286
6843
  "@powerhousedao/reactor-api",
6844
+ "@powerhousedao/reactor-attachments",
6287
6845
  "@powerhousedao/reactor-browser",
6846
+ "@powerhousedao/reactor-drive",
6847
+ "@powerhousedao/reactor-group",
6848
+ "@powerhousedao/reactor-hypercore",
6288
6849
  "@powerhousedao/reactor-mcp",
6850
+ "@powerhousedao/reactor-privacy",
6851
+ "@powerhousedao/reactor-router",
6852
+ "@powerhousedao/reactor-workflow",
6853
+ "@powerhousedao/registry",
6289
6854
  "@powerhousedao/switchboard-gui",
6290
6855
  "@powerhousedao/vetra",
6856
+ "@powerhousedao/vetra-studio",
6857
+ "@powerhousedao/workflow",
6291
6858
  "@powerhousedao/analytics-engine-core",
6292
6859
  "@powerhousedao/analytics-engine-knex",
6293
6860
  "@powerhousedao/analytics-engine-pg",
@@ -6295,14 +6862,13 @@ const PACKAGES_DEPENDENCIES = [
6295
6862
  "@powerhousedao/analytics-engine-graphql",
6296
6863
  "@powerhousedao/shared",
6297
6864
  "@powerhousedao/powerhouse-vetra-packages",
6298
- "@powerhousedao/analytics-engine-core",
6299
- "@powerhousedao/analytics-engine-graphql",
6300
- "@powerhousedao/analytics-engine-knex",
6301
- "@powerhousedao/analytics-engine-pg",
6302
- "@powerhousedao/analytics-engine-browser",
6303
6865
  "@renown/sdk"
6304
6866
  ];
6305
- const CLIS_DEPENDENCIES = ["ph-cmd", "@powerhousedao/ph-cli"];
6867
+ const CLIS_DEPENDENCIES = [
6868
+ "ph-cmd",
6869
+ "@powerhousedao/ph-cli",
6870
+ "@powerhousedao/ph-run"
6871
+ ];
6306
6872
  const APPS_DEPENDENCIES = ["@powerhousedao/connect", "@powerhousedao/switchboard"];
6307
6873
  const ALL_POWERHOUSE_DEPENDENCIES = [
6308
6874
  ...PACKAGES_DEPENDENCIES,
@@ -6365,7 +6931,35 @@ async function runUseLocal(monorepoPath, skipInstall) {
6365
6931
  runCmd(`pnpm install`);
6366
6932
  }
6367
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
+ }
6368
6960
  function buildPnpmLink(packageName, monorepoPath) {
6961
+ const dir = workspacePackages(monorepoPath).get(packageName);
6962
+ if (dir) return `link:${dir}`;
6369
6963
  const isCli = CLIS_DEPENDENCIES.includes(packageName);
6370
6964
  const isApp = APPS_DEPENDENCIES.includes(packageName);
6371
6965
  const packageDir = isCli ? "clis" : isApp ? "apps" : "packages";
@@ -6373,6 +6967,458 @@ function buildPnpmLink(packageName, monorepoPath) {
6373
6967
  return `link:${path.join(monorepoPath, packageDir, packageNameWithoutNamespace).replace("analytics-engine-", "analytics-engine/")}`;
6374
6968
  }
6375
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
6376
7422
  //#region connect/schema-fragments.ts
6377
7423
  const powerhousePackageSchema = {
6378
7424
  type: "object",
@@ -6403,512 +7449,100 @@ const powerhousePackageSchema = {
6403
7449
  }
6404
7450
  }
6405
7451
  };
6406
- 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 = {
6407
7473
  type: "object",
6408
7474
  additionalProperties: false,
6409
- description: "Visibility and add/delete affordances for a drive section in the sidebar.",
6410
7475
  properties: {
6411
- enabled: {
6412
- type: "boolean",
6413
- description: "When false, the section is hidden in the sidebar.",
6414
- default: true
6415
- },
6416
- allowAdd: {
6417
- type: "boolean",
6418
- description: "When false, the section's 'add drive' affordance is hidden.",
6419
- default: true
7476
+ interval: {
7477
+ type: "integer",
7478
+ minimum: 1,
7479
+ description: "Write a keyframe every N revisions."
6420
7480
  },
6421
- allowDelete: {
6422
- type: "boolean",
6423
- description: "When false, drives in this section cannot be deleted from the UI.",
6424
- default: true
7481
+ keep: {
7482
+ type: ["integer", "null"],
7483
+ minimum: 1,
7484
+ description: "Keyframes kept per document stream, newest first; null keeps them all."
6425
7485
  }
6426
7486
  }
6427
7487
  };
6428
- const pwaUrlPatternSchema = {
6429
- description: "URL match. A string is matched verbatim by Workbox; { source, flags } is rebuilt into a RegExp at build time.",
6430
- 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: [{
6431
7496
  type: "object",
6432
7497
  additionalProperties: false,
6433
- 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.",
6434
7504
  properties: {
6435
- source: {
6436
- type: "string",
6437
- description: "RegExp source."
7505
+ formatVersion: definitionSourceFormatVersionSchema,
7506
+ mode: {
7507
+ const: "code-first",
7508
+ description: "This package declares its models in TypeScript."
6438
7509
  },
6439
- flags: {
6440
- type: "string",
6441
- description: "RegExp flags (e.g. 'i')."
6442
- }
6443
- }
6444
- }]
6445
- };
6446
- const pwaIconSchema = {
6447
- type: "object",
6448
- additionalProperties: false,
6449
- required: ["src"],
6450
- properties: {
6451
- src: { type: "string" },
6452
- sizes: { type: "string" },
6453
- type: { type: "string" },
6454
- purpose: { type: "string" }
6455
- }
6456
- };
6457
- const phConnectRuntimeConfigSchema = {
6458
- type: "object",
6459
- additionalProperties: false,
6460
- description: "Connect-specific UI customisations. All fields optional; omit the section entirely for default behaviour.",
6461
- properties: {
6462
- branding: {
6463
- type: "object",
6464
- additionalProperties: false,
6465
- description: "App identity and visual branding.",
6466
- properties: {
6467
- appName: {
6468
- type: "string",
6469
- description: "Browser tab title and any in-app brand text. Defaults to 'Powerhouse Connect'."
6470
- },
6471
- homeBackground: {
6472
- type: ["string", "null"],
6473
- description: "Hero image on the empty home screen. URL or path to override; null or omitted uses the bundled default image."
6474
- }
6475
- }
6476
- },
6477
- app: {
6478
- type: "object",
6479
- additionalProperties: false,
6480
- description: "Top-level Connect application behaviour.",
6481
- properties: {
6482
- logLevel: {
6483
- type: "string",
6484
- enum: [
6485
- "debug",
6486
- "info",
6487
- "warn",
6488
- "error"
6489
- ],
6490
- description: "Log level applied by Connect's logger at boot. Affects browser-side output only.",
6491
- default: "info"
6492
- },
6493
- basePath: {
6494
- type: "string",
6495
- 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.",
6496
- default: "/"
6497
- },
6498
- offline: {
6499
- type: "boolean",
6500
- 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.",
6501
- default: true
6502
- },
6503
- studioMode: {
6504
- type: "boolean",
6505
- 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.",
6506
- default: false
6507
- }
6508
- }
6509
- },
6510
- ai: {
6511
- type: "object",
6512
- additionalProperties: false,
6513
- description: "AI assistant (chat) behaviour.",
6514
- properties: { assistantEnabled: {
6515
- type: "boolean",
6516
- 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.",
6517
- default: false
6518
- } }
6519
- },
6520
- packages: {
6521
- type: "object",
6522
- additionalProperties: false,
6523
- description: "Runtime behaviour for the Connect package manager (separate from top-level `packages[]`, which lists which packages to load).",
6524
- properties: {
6525
- externalEnabled: {
6526
- type: "boolean",
6527
- 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.",
6528
- default: true
6529
- },
6530
- liveReload: {
6531
- type: "boolean",
6532
- 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).",
6533
- default: false
6534
- }
6535
- }
6536
- },
6537
- drives: {
6538
- type: "object",
6539
- additionalProperties: false,
6540
- description: "Default-drive and add-drive UI behaviour.",
6541
- properties: {
6542
- allowAddDrive: {
6543
- type: "boolean",
6544
- description: "When false, the SPA hides the 'add drive' affordance entirely (top-level). Per-section overrides live in `sections.{remote,local}.allowAdd`.",
6545
- default: true
6546
- },
6547
- defaultDrives: {
6548
- type: "array",
6549
- 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).",
6550
- default: [],
6551
- items: { oneOf: [{
6552
- type: "object",
6553
- additionalProperties: false,
6554
- required: ["url"],
6555
- properties: {
6556
- url: { type: "string" },
6557
- name: { type: ["string", "null"] },
6558
- icon: { type: ["string", "null"] }
6559
- }
6560
- }, {
6561
- type: "object",
6562
- additionalProperties: false,
6563
- required: ["local", "id"],
6564
- properties: {
6565
- local: {
6566
- const: true,
6567
- description: "Discriminator: this entry is a local drive created on first boot."
6568
- },
6569
- id: {
6570
- type: "string",
6571
- description: "Stable drive id. The drive is created with this id on first boot and is not re-created on later boots."
6572
- },
6573
- name: { type: ["string", "null"] },
6574
- icon: { type: ["string", "null"] },
6575
- app: {
6576
- type: "string",
6577
- description: "Drive app (preferred editor) to open on the drive."
6578
- }
6579
- }
6580
- }] }
6581
- },
6582
- preserveStrategy: {
6583
- type: "string",
6584
- enum: ["preserve-all", "preserve-by-url-and-detach"],
6585
- 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."
6586
- },
6587
- sections: {
6588
- type: "object",
6589
- additionalProperties: false,
6590
- description: "Per-section visibility and affordance toggles. `remote` covers what was historically split into 'public' + 'cloud'; `local` is browser-local drives.",
6591
- properties: {
6592
- remote: driveSectionSchema,
6593
- local: driveSectionSchema
6594
- }
6595
- }
6596
- }
6597
- },
6598
- renown: {
6599
- type: "object",
6600
- additionalProperties: false,
6601
- description: "Renown identity / authentication coordinates.",
6602
- properties: {
6603
- url: {
6604
- type: "string",
6605
- description: "Renown auth service URL.",
6606
- default: "https://www.renown.id"
6607
- },
6608
- networkId: {
6609
- type: "string",
6610
- description: "CAIP-2 network namespace (e.g. 'eip155').",
6611
- default: "eip155"
6612
- },
6613
- chainId: {
6614
- type: "number",
6615
- description: "CAIP-2 chain reference within the network namespace.",
6616
- default: 1
6617
- },
6618
- namespace: {
6619
- type: "string",
6620
- description: "Renown localStorage namespace; share it across Connects to share login."
6621
- },
6622
- switchboardUrl: {
6623
- type: "string",
6624
- 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`."
6625
- },
6626
- adapters: {
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: {
6627
7514
  type: "object",
6628
7515
  additionalProperties: false,
6629
- description: "Per-adapter wallet config for in-page auth. Presence of an adapter key enables it; omit or leave empty for redirect-only behaviour.",
7516
+ required: ["specifier"],
6630
7517
  properties: {
6631
- rainbow: {
6632
- type: "object",
6633
- additionalProperties: false,
6634
- description: "wagmi + RainbowKit external-wallet adapter config.",
6635
- properties: {
6636
- walletConnectProjectId: {
6637
- type: "string",
6638
- description: "WalletConnect project id; required for this adapter to function."
6639
- },
6640
- infuraProjectId: {
6641
- type: "string",
6642
- description: "Optional Infura project id used to build RPC transports."
6643
- }
6644
- }
6645
- },
6646
- privy: {
6647
- type: "object",
6648
- additionalProperties: false,
6649
- description: "Privy embedded/social adapter config.",
6650
- properties: {
6651
- appId: {
6652
- type: "string",
6653
- description: "Privy application id; required for this adapter to function."
6654
- },
6655
- clientId: {
6656
- type: "string",
6657
- description: "Optional Privy client id."
6658
- },
6659
- methods: {
6660
- type: "array",
6661
- description: "Login methods this adapter offers; default per adapter when omitted.",
6662
- items: { type: "string" }
6663
- }
6664
- }
6665
- }
6666
- }
6667
- }
6668
- }
6669
- },
6670
- sentry: {
6671
- type: "object",
6672
- additionalProperties: false,
6673
- 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.",
6674
- properties: {
6675
- dsn: {
6676
- type: ["string", "null"],
6677
- description: "Sentry DSN URL. `null` disables Sentry entirely; the SPA never loads the Sentry SDK chunk.",
6678
- default: null
6679
- },
6680
- env: {
6681
- type: "string",
6682
- description: "Sentry environment label, surfaced as the `environment` tag on every event.",
6683
- default: "dev"
6684
- },
6685
- tracing: {
6686
- type: "boolean",
6687
- description: "Enable Sentry performance tracing.",
6688
- default: false
6689
- }
6690
- }
6691
- },
6692
- instance: {
6693
- type: "object",
6694
- additionalProperties: false,
6695
- required: ["namespace", "reactorWorker"],
6696
- description: "Per-instance identity. Lets one origin host multiple isolated Connect instances, each with its own storage + SharedWorker namespace.",
6697
- properties: {
6698
- namespace: {
6699
- type: ["string", "null"],
6700
- 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.",
6701
- default: null
6702
- },
6703
- reactorWorker: {
6704
- type: "boolean",
6705
- 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.",
6706
- default: false
6707
- }
6708
- }
6709
- },
6710
- reactor: {
6711
- type: "object",
6712
- additionalProperties: false,
6713
- description: "Settings for the reactor Connect runs in the browser, on the main thread or in the shared worker alike.",
6714
- properties: { featureFlags: {
6715
- type: "object",
6716
- additionalProperties: false,
6717
- 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.",
6718
- properties: {
6719
- documentDecisions: {
6720
- type: "boolean",
6721
- description: "Decide writes from the document stream rather than the document meta cache, so a backdated deletion denies the operations that sort after it.",
6722
- default: false
6723
- },
6724
- authEnforcement: {
6725
- type: "boolean",
6726
- description: "Enforce the auth scope's policy at admission, replay, and read. Requires documentDecisions.",
6727
- default: false
6728
- },
6729
- authGroups: {
6730
- type: "boolean",
6731
- description: "Let `{ group }` principals match against the rosters of the group documents a policy names. Requires authEnforcement.",
6732
- default: false
6733
- },
6734
- authConditions: {
6735
- type: "boolean",
6736
- description: "Evaluate `where` and `match` conditions on grants. Requires authGroups. Do not enable on a fleet `preflight:auth` reports as crossing a reducer version.",
6737
- default: false
6738
- }
6739
- }
6740
- } }
6741
- },
6742
- pwa: {
6743
- type: "object",
6744
- additionalProperties: false,
6745
- 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.",
6746
- properties: {
6747
- manifest: {
6748
- type: "object",
6749
- additionalProperties: false,
6750
- description: "Web-app-manifest field overrides.",
6751
- properties: {
6752
- name: { type: "string" },
6753
- short_name: { type: "string" },
6754
- description: { type: "string" },
6755
- theme_color: { type: "string" },
6756
- background_color: { type: "string" },
6757
- display: {
7518
+ specifier: {
6758
7519
  type: "string",
6759
- enum: [
6760
- "fullscreen",
6761
- "standalone",
6762
- "minimal-ui",
6763
- "browser"
6764
- ]
7520
+ pattern: `^\\./.*${DEFINITION_SOURCE_EXTENSION.source}`,
7521
+ description: "POSIX package-relative module path beginning with './'. It may not leave the package root."
6765
7522
  },
6766
- start_url: { type: "string" },
6767
- scope: { type: "string" },
6768
- icons: {
7523
+ exportPath: {
6769
7524
  type: "array",
6770
- description: "Icons appended to the built-in set and de-duplicated by (src, sizes, purpose).",
6771
- items: pwaIconSchema
6772
- },
6773
- file_handlers: {
6774
- type: "array",
6775
- 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.",
6776
- items: {
6777
- type: "object",
6778
- additionalProperties: false,
6779
- required: ["accept"],
6780
- properties: {
6781
- accept: {
6782
- type: "object",
6783
- description: "MIME type → file extensions. Each extension must start with '.'; browsers ignore entries without it.",
6784
- additionalProperties: {
6785
- type: "array",
6786
- items: {
6787
- type: "string",
6788
- pattern: "^\\."
6789
- }
6790
- }
6791
- },
6792
- icons: {
6793
- type: "array",
6794
- description: "OS-level file-type icons.",
6795
- items: pwaIconSchema
6796
- },
6797
- launch_type: {
6798
- type: "string",
6799
- enum: ["single-client", "multiple-clients"]
6800
- }
6801
- }
6802
- }
6803
- },
6804
- launch_handler: {
6805
- type: "object",
6806
- additionalProperties: false,
6807
- required: ["client_mode"],
6808
- description: "How the OS launches the app for handled files/links. Connect defaults to focus-existing.",
6809
- properties: { client_mode: {
6810
- type: "string",
6811
- enum: [
6812
- "auto",
6813
- "focus-existing",
6814
- "navigate-existing",
6815
- "navigate-new"
6816
- ]
6817
- } }
6818
- }
6819
- }
6820
- },
6821
- globPatterns: {
6822
- type: "array",
6823
- items: { type: "string" },
6824
- description: "Extra Workbox precache globs, unioned with the built-ins."
6825
- },
6826
- globIgnores: {
6827
- type: "array",
6828
- items: { type: "string" },
6829
- description: "Extra precache ignore globs, unioned with the built-ins."
6830
- },
6831
- maximumFileSizeToCacheInBytes: {
6832
- type: "number",
6833
- description: "Raise the precache file-size ceiling. The max across all contributors wins, so no contributor can shrink another's limit."
6834
- },
6835
- runtimeCaching: {
6836
- type: "array",
6837
- 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.",
6838
- items: {
6839
- type: "object",
6840
- additionalProperties: false,
6841
- required: ["urlPattern", "handler"],
6842
- properties: {
6843
- urlPattern: pwaUrlPatternSchema,
6844
- handler: {
6845
- type: "string",
6846
- enum: [
6847
- "CacheFirst",
6848
- "CacheOnly",
6849
- "NetworkFirst",
6850
- "NetworkOnly",
6851
- "StaleWhileRevalidate"
6852
- ]
6853
- },
6854
- method: {
6855
- type: "string",
6856
- enum: [
6857
- "GET",
6858
- "POST",
6859
- "PUT",
6860
- "DELETE",
6861
- "HEAD",
6862
- "PATCH"
6863
- ]
6864
- },
6865
- options: {
6866
- type: "object",
6867
- additionalProperties: false,
6868
- properties: {
6869
- cacheName: { type: "string" },
6870
- networkTimeoutSeconds: {
6871
- type: "number",
6872
- description: "Seconds a NetworkFirst rule waits for the network before falling back to the cache."
6873
- },
6874
- expiration: {
6875
- type: "object",
6876
- additionalProperties: false,
6877
- properties: {
6878
- maxEntries: { type: "number" },
6879
- maxAgeSeconds: { type: "number" }
6880
- }
6881
- },
6882
- cacheableResponse: {
6883
- type: "object",
6884
- additionalProperties: false,
6885
- properties: {
6886
- statuses: {
6887
- type: "array",
6888
- items: { type: "number" }
6889
- },
6890
- headers: {
6891
- type: "object",
6892
- additionalProperties: { type: "string" }
6893
- }
6894
- }
6895
- }
6896
- }
6897
- }
7525
+ items: { type: "string" },
7526
+ description: "Exact property keys into the imported namespace, outermost first. Omit it to select the namespace root."
6898
7527
  }
6899
7528
  }
6900
- },
6901
- navigateFallbackDenylist: {
6902
- type: "array",
6903
- description: "Extra SPA navigate-fallback denylist patterns, unioned with the built-ins.",
6904
- items: pwaUrlPatternSchema
6905
7529
  }
6906
7530
  }
6907
7531
  }
6908
- }
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
+ }]
6909
7545
  };
6910
- //#endregion
6911
- //#region clis/source-config-schema.ts
6912
7546
  const SOURCE_CONFIG_SCHEMA_ID = "https://powerhouse.inc/schemas/powerhouse.source.json";
6913
7547
  const sourceConfigSchema = {
6914
7548
  $schema: "http://json-schema.org/draft-07/schema#",
@@ -7010,6 +7644,22 @@ const sourceConfigSchema = {
7010
7644
  description: "Required when `type: postgres`."
7011
7645
  }
7012
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
+ }
7013
7663
  }
7014
7664
  }
7015
7665
  },
@@ -7108,9 +7758,36 @@ const sourceConfigSchema = {
7108
7758
  connectPort: {
7109
7759
  type: "integer",
7110
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
+ } }
7111
7770
  }
7112
7771
  }
7113
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
+ },
7114
7791
  packageRegistryUrl: {
7115
7792
  type: "string",
7116
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."
@@ -7118,7 +7795,8 @@ const sourceConfigSchema = {
7118
7795
  connect: {
7119
7796
  ...phConnectRuntimeConfigSchema,
7120
7797
  description: "Connect-specific UI customisations. Copied verbatim into the runtime config at build time."
7121
- }
7798
+ },
7799
+ definitionSources: definitionSourcesSchema
7122
7800
  }
7123
7801
  };
7124
7802
  //#endregion
@@ -7152,6 +7830,6 @@ function assertNodeVersion(nodeVersion = process.versions.node) {
7152
7830
  if (lt(nodeVersion, "24.0.0")) throw new NodeVersionError(nodeVersion, MINIMUM_NODE_VERSION);
7153
7831
  }
7154
7832
  //#endregion
7155
- 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 };
7156
7834
 
7157
7835
  //# sourceMappingURL=index.mjs.map