@unbrained/pm-cli 2026.6.5 → 2026.6.7

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 (596) hide show
  1. package/CHANGELOG.md +77 -0
  2. package/CONTRIBUTING.md +1 -0
  3. package/README.md +17 -5
  4. package/dist/cli/commander-usage.js +74 -4
  5. package/dist/cli/commander-usage.js.map +1 -1
  6. package/dist/cli/commands/aggregate.d.ts +8 -0
  7. package/dist/cli/commands/aggregate.js +84 -7
  8. package/dist/cli/commands/aggregate.js.map +1 -1
  9. package/dist/cli/commands/calendar.js +10 -3
  10. package/dist/cli/commands/calendar.js.map +1 -1
  11. package/dist/cli/commands/close-many.js +13 -10
  12. package/dist/cli/commands/close-many.js.map +1 -1
  13. package/dist/cli/commands/close.d.ts +1 -1
  14. package/dist/cli/commands/close.js +20 -10
  15. package/dist/cli/commands/close.js.map +1 -1
  16. package/dist/cli/commands/completion.js +87 -18
  17. package/dist/cli/commands/completion.js.map +1 -1
  18. package/dist/cli/commands/config.d.ts +5 -4
  19. package/dist/cli/commands/config.js +50 -2
  20. package/dist/cli/commands/config.js.map +1 -1
  21. package/dist/cli/commands/contracts.js +6 -3
  22. package/dist/cli/commands/contracts.js.map +1 -1
  23. package/dist/cli/commands/copy.d.ts +14 -0
  24. package/dist/cli/commands/copy.js +153 -0
  25. package/dist/cli/commands/copy.js.map +1 -0
  26. package/dist/cli/commands/extension/doctor.js +62 -2
  27. package/dist/cli/commands/extension/doctor.js.map +1 -1
  28. package/dist/cli/commands/extension/install-sources.d.ts +8 -0
  29. package/dist/cli/commands/extension/install-sources.js +82 -2
  30. package/dist/cli/commands/extension/install-sources.js.map +1 -1
  31. package/dist/cli/commands/extension.d.ts +29 -0
  32. package/dist/cli/commands/extension.js +61 -2
  33. package/dist/cli/commands/extension.js.map +1 -1
  34. package/dist/cli/commands/gc.d.ts +8 -1
  35. package/dist/cli/commands/gc.js +26 -3
  36. package/dist/cli/commands/gc.js.map +1 -1
  37. package/dist/cli/commands/get.d.ts +9 -0
  38. package/dist/cli/commands/get.js +23 -2
  39. package/dist/cli/commands/get.js.map +1 -1
  40. package/dist/cli/commands/health.js +15 -2
  41. package/dist/cli/commands/health.js.map +1 -1
  42. package/dist/cli/commands/history-compact.d.ts +39 -0
  43. package/dist/cli/commands/history-compact.js +262 -0
  44. package/dist/cli/commands/history-compact.js.map +1 -0
  45. package/dist/cli/commands/history.d.ts +4 -1
  46. package/dist/cli/commands/history.js +12 -24
  47. package/dist/cli/commands/history.js.map +1 -1
  48. package/dist/cli/commands/index.d.ts +3 -0
  49. package/dist/cli/commands/index.js +5 -2
  50. package/dist/cli/commands/index.js.map +1 -1
  51. package/dist/cli/commands/list.d.ts +2 -0
  52. package/dist/cli/commands/list.js +87 -9
  53. package/dist/cli/commands/list.js.map +1 -1
  54. package/dist/cli/commands/reindex.js +8 -4
  55. package/dist/cli/commands/reindex.js.map +1 -1
  56. package/dist/cli/commands/search.d.ts +1 -0
  57. package/dist/cli/commands/search.js +232 -35
  58. package/dist/cli/commands/search.js.map +1 -1
  59. package/dist/cli/commands/stats.d.ts +8 -1
  60. package/dist/cli/commands/stats.js +18 -17
  61. package/dist/cli/commands/stats.js.map +1 -1
  62. package/dist/cli/commands/telemetry.d.ts +8 -0
  63. package/dist/cli/commands/telemetry.js +253 -0
  64. package/dist/cli/commands/telemetry.js.map +1 -0
  65. package/dist/cli/error-guidance.js +26 -2
  66. package/dist/cli/error-guidance.js.map +1 -1
  67. package/dist/cli/extension-command-help.d.ts +1 -0
  68. package/dist/cli/extension-command-help.js +3 -2
  69. package/dist/cli/extension-command-help.js.map +1 -1
  70. package/dist/cli/help-content.js +19 -2
  71. package/dist/cli/help-content.js.map +1 -1
  72. package/dist/cli/main.d.ts +3 -0
  73. package/dist/cli/main.js +13 -21
  74. package/dist/cli/main.js.map +1 -1
  75. package/dist/cli/register-list-query.js +24 -6
  76. package/dist/cli/register-list-query.js.map +1 -1
  77. package/dist/cli/register-mutation.js +52 -17
  78. package/dist/cli/register-mutation.js.map +1 -1
  79. package/dist/cli/register-operations.js +55 -8
  80. package/dist/cli/register-operations.js.map +1 -1
  81. package/dist/cli/register-setup.js +5 -5
  82. package/dist/cli/register-setup.js.map +1 -1
  83. package/dist/cli/registration-helpers.js +21 -3
  84. package/dist/cli/registration-helpers.js.map +1 -1
  85. package/dist/cli-bundle/chunks/activity-5UROHJ3D.js +16 -0
  86. package/dist/cli-bundle/chunks/{activity-3RWRRNOW.js → activity-YVB3QRTE.js} +11 -11
  87. package/dist/cli-bundle/chunks/{aggregate-OOAGKWRG.js → aggregate-LH66F75F.js} +87 -17
  88. package/dist/cli-bundle/chunks/aggregate-LH66F75F.js.map +7 -0
  89. package/dist/cli-bundle/chunks/{aggregate-J35K7WZB.js → aggregate-OHSWFQJM.js} +88 -18
  90. package/dist/cli-bundle/chunks/aggregate-OHSWFQJM.js.map +1 -0
  91. package/dist/cli-bundle/chunks/{append-PNN6UIBZ.js → append-2PPYFAG5.js} +8 -8
  92. package/dist/cli-bundle/chunks/{append-5JE3YGXU.js → append-AUGT5W6J.js} +8 -8
  93. package/dist/cli-bundle/chunks/{chunk-26KTVXJW.js → chunk-2IF7WLB7.js} +2 -2
  94. package/dist/cli-bundle/chunks/{chunk-KA24HME7.js → chunk-2IXCHCLM.js} +5 -6
  95. package/dist/cli-bundle/chunks/chunk-2IXCHCLM.js.map +7 -0
  96. package/dist/cli-bundle/chunks/{chunk-XX5LRINW.js → chunk-2OJHLWBZ.js} +2 -2
  97. package/dist/cli-bundle/chunks/{chunk-ASQM3IF5.js → chunk-3A2CMEM7.js} +5 -4
  98. package/dist/cli-bundle/chunks/{chunk-S3CV7JGJ.js → chunk-3EOBJOF4.js} +5 -4
  99. package/dist/cli-bundle/chunks/{chunk-N5YF3VFN.js → chunk-42LOFGJS.js} +91 -16
  100. package/dist/cli-bundle/chunks/chunk-42LOFGJS.js.map +7 -0
  101. package/dist/cli-bundle/chunks/{chunk-WIKR7KFL.js → chunk-4CHEG6UK.js} +108 -21
  102. package/dist/cli-bundle/chunks/chunk-4CHEG6UK.js.map +7 -0
  103. package/dist/cli-bundle/chunks/{chunk-4QCR4QW3.js → chunk-4GHZR3BA.js} +56 -28
  104. package/dist/cli-bundle/chunks/chunk-4GHZR3BA.js.map +1 -0
  105. package/dist/cli-bundle/chunks/{chunk-B3N4TKNL.js → chunk-5AXMRKN5.js} +8 -8
  106. package/dist/cli-bundle/chunks/{chunk-JQI2HE55.js → chunk-6J4K6JLA.js} +3 -3
  107. package/dist/cli-bundle/chunks/{chunk-V3JQ4IPL.js → chunk-6RZXO5M2.js} +102 -22
  108. package/dist/cli-bundle/chunks/chunk-6RZXO5M2.js.map +1 -0
  109. package/dist/cli-bundle/chunks/{chunk-BNL6S7QH.js → chunk-AVJD6VTA.js} +3 -3
  110. package/dist/cli-bundle/chunks/{chunk-NQP3ECKF.js → chunk-B2KZGPM2.js} +39 -8
  111. package/dist/cli-bundle/chunks/chunk-B2KZGPM2.js.map +1 -0
  112. package/dist/cli-bundle/chunks/{chunk-RQAWLSUU.js → chunk-B5RF3IP7.js} +3 -3
  113. package/dist/cli-bundle/chunks/{chunk-UFCG3SWR.js → chunk-C5W2UH56.js} +3 -3
  114. package/dist/cli-bundle/chunks/{chunk-3OH4DAEB.js → chunk-CKLBZHS7.js} +6 -6
  115. package/dist/cli-bundle/chunks/{chunk-GNHVV4SY.js → chunk-CLD3XNCH.js} +124 -20
  116. package/dist/cli-bundle/chunks/chunk-CLD3XNCH.js.map +1 -0
  117. package/dist/cli-bundle/chunks/{chunk-RANZIID5.js → chunk-FHHBD7PN.js} +38 -7
  118. package/dist/cli-bundle/chunks/chunk-FHHBD7PN.js.map +7 -0
  119. package/dist/cli-bundle/chunks/{chunk-GFWHHMVV.js → chunk-FY6Z3FYY.js} +3 -3
  120. package/dist/cli-bundle/chunks/{chunk-CCUFLH4J.js → chunk-GNIUOLZ2.js} +7 -7
  121. package/dist/cli-bundle/chunks/{chunk-ZRVSMOMR.js → chunk-GPXQBR3H.js} +12 -12
  122. package/dist/cli-bundle/chunks/{chunk-SZQCER6S.js → chunk-GUZBNB3G.js} +27 -5
  123. package/dist/cli-bundle/chunks/chunk-GUZBNB3G.js.map +1 -0
  124. package/dist/cli-bundle/chunks/{chunk-GPGAYASV.js → chunk-H7EO3QA3.js} +5 -5
  125. package/dist/cli-bundle/chunks/{chunk-MISYRLEP.js → chunk-HLC3KTLP.js} +2 -2
  126. package/dist/cli-bundle/chunks/{chunk-KK6YPGH3.js → chunk-HMMMWBK2.js} +2 -2
  127. package/dist/cli-bundle/chunks/{chunk-4PJQSECJ.js → chunk-HRMHZ4RV.js} +26 -4
  128. package/dist/cli-bundle/chunks/chunk-HRMHZ4RV.js.map +7 -0
  129. package/dist/cli-bundle/chunks/{chunk-CJDQB2ED.js → chunk-HV5SSZXF.js} +2 -2
  130. package/dist/cli-bundle/chunks/{chunk-ATBVS6WW.js → chunk-IMCJBN2Q.js} +23 -14
  131. package/dist/cli-bundle/chunks/chunk-IMCJBN2Q.js.map +7 -0
  132. package/dist/cli-bundle/chunks/{chunk-FVXM3GKS.js → chunk-KNGVP5WJ.js} +3 -3
  133. package/dist/cli-bundle/chunks/{chunk-OIQIXTNB.js → chunk-KR6R465K.js} +304 -215
  134. package/dist/cli-bundle/chunks/chunk-KR6R465K.js.map +7 -0
  135. package/dist/cli-bundle/chunks/{chunk-UOVLWB47.js → chunk-LI65XLJR.js} +8 -8
  136. package/dist/cli-bundle/chunks/{chunk-AXXKLVTW.js → chunk-LIN2BPJ7.js} +2 -2
  137. package/dist/cli-bundle/chunks/chunk-LMTOY5HE.js +112 -0
  138. package/dist/cli-bundle/chunks/chunk-LMTOY5HE.js.map +1 -0
  139. package/dist/cli-bundle/chunks/{chunk-Y2AKE2HS.js → chunk-LQHBENVW.js} +3 -3
  140. package/dist/cli-bundle/chunks/{chunk-D5X7N6FI.js → chunk-LXO6V66E.js} +14 -14
  141. package/dist/cli-bundle/chunks/{chunk-TK633IVD.js → chunk-M2PW7EZU.js} +26 -7
  142. package/dist/cli-bundle/chunks/chunk-M2PW7EZU.js.map +7 -0
  143. package/dist/cli-bundle/chunks/{chunk-DFIZGAI5.js → chunk-MOYM2C3J.js} +9 -9
  144. package/dist/cli-bundle/chunks/{chunk-ZQ4F6EC4.js → chunk-MWRS7Z4P.js} +127 -23
  145. package/dist/cli-bundle/chunks/chunk-MWRS7Z4P.js.map +7 -0
  146. package/dist/cli-bundle/chunks/{chunk-5PAOPUZX.js → chunk-NHR2QXXZ.js} +24 -15
  147. package/dist/cli-bundle/chunks/chunk-NHR2QXXZ.js.map +1 -0
  148. package/dist/cli-bundle/chunks/{chunk-OUF3ARDX.js → chunk-NQL32HQ5.js} +12 -12
  149. package/dist/cli-bundle/chunks/{chunk-TBQVUNVH.js → chunk-O7HSSFCC.js} +65 -16
  150. package/dist/cli-bundle/chunks/chunk-O7HSSFCC.js.map +7 -0
  151. package/dist/cli-bundle/chunks/{chunk-GCAVRLGE.js → chunk-OKSKJKHX.js} +9 -9
  152. package/dist/cli-bundle/chunks/chunk-QQL5QSTZ.js +1572 -0
  153. package/dist/cli-bundle/chunks/chunk-QQL5QSTZ.js.map +1 -0
  154. package/dist/cli-bundle/chunks/{chunk-A6PEXMYN.js → chunk-R3V3YCMH.js} +9 -9
  155. package/dist/cli-bundle/chunks/{chunk-T2ORWB6D.js → chunk-RVPTZKBC.js} +9 -9
  156. package/dist/cli-bundle/chunks/{chunk-K47WAYQV.js → chunk-SFFVGNHC.js} +3 -3
  157. package/dist/cli-bundle/chunks/{chunk-DFUSXJDE.js → chunk-SQPKRA54.js} +14 -14
  158. package/dist/cli-bundle/chunks/chunk-THDEID2Z.js +115 -0
  159. package/dist/cli-bundle/chunks/chunk-THDEID2Z.js.map +7 -0
  160. package/dist/cli-bundle/chunks/{chunk-G5BACLYH.js → chunk-TINUJMWN.js} +92 -17
  161. package/dist/cli-bundle/chunks/chunk-TINUJMWN.js.map +1 -0
  162. package/dist/cli-bundle/chunks/{chunk-JB4RGL4V.js → chunk-TNPBPNII.js} +7 -7
  163. package/dist/cli-bundle/chunks/{chunk-XG7RJYHV.js → chunk-TP4DDY27.js} +6 -6
  164. package/dist/cli-bundle/chunks/{chunk-ORTLYVA4.js → chunk-TYJJOTUA.js} +6 -6
  165. package/dist/cli-bundle/chunks/{chunk-HZOS2UG5.js → chunk-UAQOQ7IE.js} +2 -2
  166. package/dist/cli-bundle/chunks/{chunk-D3WUNETC.js → chunk-UEWA73ZZ.js} +5 -5
  167. package/dist/cli-bundle/chunks/{chunk-O5IBJE6S.js → chunk-UIIQC5YO.js} +2 -2
  168. package/dist/cli-bundle/chunks/{chunk-SRVKTWPR.js → chunk-UJUT6AHZ.js} +314 -39
  169. package/dist/cli-bundle/chunks/chunk-UJUT6AHZ.js.map +7 -0
  170. package/dist/cli-bundle/chunks/{chunk-SSFMJCPF.js → chunk-UT6WFXW2.js} +6 -7
  171. package/dist/cli-bundle/chunks/chunk-UT6WFXW2.js.map +1 -0
  172. package/dist/cli-bundle/chunks/{chunk-KBG47ZOY.js → chunk-UYQ7HXH4.js} +10 -6
  173. package/dist/cli-bundle/chunks/chunk-UYQ7HXH4.js.map +1 -0
  174. package/dist/cli-bundle/chunks/{chunk-LDJK7SHN.js → chunk-V6EYFTRL.js} +7 -7
  175. package/dist/cli-bundle/chunks/{chunk-5IRA6IYD.js → chunk-WAA7UI6M.js} +58 -30
  176. package/dist/cli-bundle/chunks/chunk-WAA7UI6M.js.map +7 -0
  177. package/dist/cli-bundle/chunks/{chunk-HPH6X4ZZ.js → chunk-WCQZBDDH.js} +10 -6
  178. package/dist/cli-bundle/chunks/{chunk-HPH6X4ZZ.js.map → chunk-WCQZBDDH.js.map} +2 -2
  179. package/dist/cli-bundle/chunks/chunk-WR5567FH.js +1582 -0
  180. package/dist/cli-bundle/chunks/chunk-WR5567FH.js.map +7 -0
  181. package/dist/cli-bundle/chunks/{chunk-TQ3ZK6VD.js → chunk-WYEXLDDY.js} +3 -3
  182. package/dist/cli-bundle/chunks/{chunk-4LTBNUYT.js → chunk-X4IZKYHP.js} +307 -32
  183. package/dist/cli-bundle/chunks/chunk-X4IZKYHP.js.map +1 -0
  184. package/dist/cli-bundle/chunks/{chunk-KCMIYKTA.js → chunk-X7UHMKPE.js} +3 -3
  185. package/dist/cli-bundle/chunks/{chunk-7K24QB23.js → chunk-XS3O2TFJ.js} +27 -8
  186. package/dist/cli-bundle/chunks/chunk-XS3O2TFJ.js.map +1 -0
  187. package/dist/cli-bundle/chunks/{chunk-EHXPIKKP.js → chunk-XYNT7UFP.js} +303 -207
  188. package/dist/cli-bundle/chunks/chunk-XYNT7UFP.js.map +1 -0
  189. package/dist/cli-bundle/chunks/{chunk-CWT53EYT.js → chunk-YBZW2QQ7.js} +6 -6
  190. package/dist/cli-bundle/chunks/{chunk-VGO2T3TY.js → chunk-YO3THIJF.js} +7 -7
  191. package/dist/cli-bundle/chunks/{chunk-5KB4X7YY.js → chunk-YPH4ESA2.js} +66 -17
  192. package/dist/cli-bundle/chunks/chunk-YPH4ESA2.js.map +1 -0
  193. package/dist/cli-bundle/chunks/{claim-ZFA7HKU4.js → claim-BJ4QMPJC.js} +10 -10
  194. package/dist/cli-bundle/chunks/{claim-AZLP7YFO.js → claim-KW743OSW.js} +10 -10
  195. package/dist/cli-bundle/chunks/close-P4ZBKODL.js +13 -0
  196. package/dist/cli-bundle/chunks/{close-65DFYAVS.js → close-SYHSRZDC.js} +8 -8
  197. package/dist/cli-bundle/chunks/{close-many-UKZSQGM7.js → close-many-DBLEYFOY.js} +29 -26
  198. package/dist/cli-bundle/chunks/close-many-DBLEYFOY.js.map +7 -0
  199. package/dist/cli-bundle/chunks/{close-many-AKPZNSGI.js → close-many-LAC5VR4G.js} +30 -27
  200. package/dist/cli-bundle/chunks/close-many-LAC5VR4G.js.map +1 -0
  201. package/dist/cli-bundle/chunks/{comments-AGBNSJJH.js → comments-JEO6HHVM.js} +10 -10
  202. package/dist/cli-bundle/chunks/{comments-CJWXQI7X.js → comments-YT2PQ5DD.js} +10 -10
  203. package/dist/cli-bundle/chunks/{config-DDPYIA6J.js → config-RZRVS3ZV.js} +127 -11
  204. package/dist/cli-bundle/chunks/config-RZRVS3ZV.js.map +1 -0
  205. package/dist/cli-bundle/chunks/{config-5ON3ADRH.js → config-YJSAAADD.js} +128 -12
  206. package/dist/cli-bundle/chunks/config-YJSAAADD.js.map +7 -0
  207. package/dist/cli-bundle/chunks/{context-E6U3DWVM.js → context-LGYEEKAW.js} +14 -14
  208. package/dist/cli-bundle/chunks/{context-E6U3DWVM.js.map → context-LGYEEKAW.js.map} +2 -2
  209. package/dist/cli-bundle/chunks/{context-ZOJEN5VT.js → context-ZUH5IOOI.js} +15 -15
  210. package/dist/cli-bundle/chunks/context-ZUH5IOOI.js.map +1 -0
  211. package/dist/cli-bundle/chunks/{contracts-CXSFM45B.js → contracts-YXJ6NXKH.js} +11 -5
  212. package/dist/cli-bundle/chunks/contracts-YXJ6NXKH.js.map +7 -0
  213. package/dist/cli-bundle/chunks/{contracts-LCSX5R53.js → contracts-ZIBXROPE.js} +12 -6
  214. package/dist/cli-bundle/chunks/contracts-ZIBXROPE.js.map +1 -0
  215. package/dist/cli-bundle/chunks/copy-BZALX5MQ.js +182 -0
  216. package/dist/cli-bundle/chunks/copy-BZALX5MQ.js.map +1 -0
  217. package/dist/cli-bundle/chunks/copy-YPWEIAPD.js +185 -0
  218. package/dist/cli-bundle/chunks/copy-YPWEIAPD.js.map +7 -0
  219. package/dist/cli-bundle/chunks/create-4DS2QWQC.js +27 -0
  220. package/dist/cli-bundle/chunks/{create-WYFKN2U4.js → create-CF7EVRX7.js} +13 -13
  221. package/dist/cli-bundle/chunks/{delete-ZXWC56WO.js → delete-KR4VBWVE.js} +7 -7
  222. package/dist/cli-bundle/chunks/{delete-RONNH4F4.js → delete-XLZRTRKR.js} +7 -7
  223. package/dist/cli-bundle/chunks/{deps-WII3O4HB.js → deps-2YTXD3VM.js} +7 -7
  224. package/dist/cli-bundle/chunks/{deps-EHXIFOZR.js → deps-GZMFMTGS.js} +7 -7
  225. package/dist/cli-bundle/chunks/{docs-PDREIMLS.js → docs-SLROFEQ4.js} +9 -9
  226. package/dist/cli-bundle/chunks/{docs-JMVCFNHH.js → docs-ZHISRR2D.js} +9 -9
  227. package/dist/cli-bundle/chunks/{extension-G6UXSM5S.js → extension-3C7OOI4F.js} +8 -6
  228. package/dist/cli-bundle/chunks/{extension-B4ROVWJD.js → extension-XYCUXICD.js} +8 -6
  229. package/dist/cli-bundle/chunks/{files-2PN7UM2D.js → files-FUWF2FYJ.js} +9 -9
  230. package/dist/cli-bundle/chunks/{files-MXYS5W4M.js → files-J4I5IU4O.js} +9 -9
  231. package/dist/cli-bundle/chunks/gc-34NXSNSN.js +362 -0
  232. package/dist/cli-bundle/chunks/gc-34NXSNSN.js.map +1 -0
  233. package/dist/cli-bundle/chunks/gc-SPIIZX3A.js +372 -0
  234. package/dist/cli-bundle/chunks/gc-SPIIZX3A.js.map +7 -0
  235. package/dist/cli-bundle/chunks/{get-WXMLRG7M.js → get-SZKNRHMA.js} +34 -12
  236. package/dist/cli-bundle/chunks/get-SZKNRHMA.js.map +1 -0
  237. package/dist/cli-bundle/chunks/{get-CINFEUIY.js → get-VITKYP6S.js} +33 -11
  238. package/dist/cli-bundle/chunks/get-VITKYP6S.js.map +7 -0
  239. package/dist/cli-bundle/chunks/{health-IT5DBPRJ.js → health-4SNTA2TF.js} +27 -13
  240. package/dist/cli-bundle/chunks/health-4SNTA2TF.js.map +7 -0
  241. package/dist/cli-bundle/chunks/{health-5VPOJQ53.js → health-7G3EPM57.js} +28 -14
  242. package/dist/cli-bundle/chunks/health-7G3EPM57.js.map +1 -0
  243. package/dist/cli-bundle/chunks/{history-FLZIP7PM.js → history-SDAWYZR3.js} +10 -10
  244. package/dist/cli-bundle/chunks/history-YDUEILKP.js +20 -0
  245. package/dist/cli-bundle/chunks/history-compact-DMW536VH.js +287 -0
  246. package/dist/cli-bundle/chunks/history-compact-DMW536VH.js.map +1 -0
  247. package/dist/cli-bundle/chunks/history-compact-POTZGG7K.js +290 -0
  248. package/dist/cli-bundle/chunks/history-compact-POTZGG7K.js.map +7 -0
  249. package/dist/cli-bundle/chunks/{history-redact-SSZBAD76.js → history-redact-EPJ7GENL.js} +11 -11
  250. package/dist/cli-bundle/chunks/history-redact-KASLLPE7.js +19 -0
  251. package/dist/cli-bundle/chunks/{history-repair-X7CO5JJZ.js → history-repair-IJ7LLBET.js} +11 -11
  252. package/dist/cli-bundle/chunks/{history-repair-KC5ZOJRZ.js → history-repair-YNESJRT6.js} +11 -11
  253. package/dist/cli-bundle/chunks/init-IGSS4GNH.js +17 -0
  254. package/dist/cli-bundle/chunks/{init-6MRFVOLH.js → init-YHVBTEET.js} +9 -8
  255. package/dist/cli-bundle/chunks/{learnings-DCX55BNX.js → learnings-4YBMIVCZ.js} +10 -10
  256. package/dist/cli-bundle/chunks/{learnings-A3CLB5CO.js → learnings-T4PF24YN.js} +10 -10
  257. package/dist/cli-bundle/chunks/{list-DBRECOG4.js → list-3KEVBOYW.js} +10 -10
  258. package/dist/cli-bundle/chunks/list-E44O2K64.js +20 -0
  259. package/dist/cli-bundle/chunks/{notes-42LIC3UE.js → notes-FLUCNJSH.js} +10 -10
  260. package/dist/cli-bundle/chunks/{notes-P5O3VMQ3.js → notes-GJKALVZM.js} +10 -10
  261. package/dist/cli-bundle/chunks/{plan-HDQXEUKD.js → plan-T5MMZLI3.js} +13 -13
  262. package/dist/cli-bundle/chunks/{plan-IGTE3WOJ.js → plan-YYMIL3HV.js} +13 -13
  263. package/dist/cli-bundle/chunks/{register-list-query-EMNSIUO4.js → register-list-query-I65EZ3HB.js} +33 -27
  264. package/dist/cli-bundle/chunks/register-list-query-I65EZ3HB.js.map +1 -0
  265. package/dist/cli-bundle/chunks/{register-list-query-AG3XKXWL.js → register-list-query-OECMHO4G.js} +32 -26
  266. package/dist/cli-bundle/chunks/register-list-query-OECMHO4G.js.map +7 -0
  267. package/dist/cli-bundle/chunks/{register-mutation-M3YS6XDO.js → register-mutation-2FLXORLR.js} +65 -47
  268. package/dist/cli-bundle/chunks/register-mutation-2FLXORLR.js.map +1 -0
  269. package/dist/cli-bundle/chunks/{register-mutation-RSMT6DPK.js → register-mutation-5GPDEKHR.js} +64 -46
  270. package/dist/cli-bundle/chunks/register-mutation-5GPDEKHR.js.map +7 -0
  271. package/dist/cli-bundle/chunks/{register-operations-KYUOOOOD.js → register-operations-BNGAUMGK.js} +71 -35
  272. package/dist/cli-bundle/chunks/register-operations-BNGAUMGK.js.map +1 -0
  273. package/dist/cli-bundle/chunks/{register-operations-Q54JQZUN.js → register-operations-GQKT35H5.js} +70 -34
  274. package/dist/cli-bundle/chunks/register-operations-GQKT35H5.js.map +7 -0
  275. package/dist/cli-bundle/chunks/{register-setup-DI6P7X75.js → register-setup-DNDCGZ4O.js} +18 -18
  276. package/dist/cli-bundle/chunks/{register-setup-DI6P7X75.js.map → register-setup-DNDCGZ4O.js.map} +1 -1
  277. package/dist/cli-bundle/chunks/{register-setup-YJKIQRKA.js → register-setup-EJY44FPH.js} +17 -17
  278. package/dist/cli-bundle/chunks/{register-setup-YJKIQRKA.js.map → register-setup-EJY44FPH.js.map} +2 -2
  279. package/dist/cli-bundle/chunks/{restore-2XVTBLKQ.js → restore-DDJGVZIN.js} +11 -11
  280. package/dist/cli-bundle/chunks/restore-SJSASGZP.js +17 -0
  281. package/dist/cli-bundle/chunks/{schema-V6BX65Q2.js → schema-B7NQ6XVP.js} +8 -8
  282. package/dist/cli-bundle/chunks/{schema-LVXZWFGY.js → schema-HEGYH6CE.js} +8 -8
  283. package/dist/cli-bundle/chunks/{search-C7NPB7G7.js → search-DVVQ4UO2.js} +421 -42
  284. package/dist/cli-bundle/chunks/search-DVVQ4UO2.js.map +1 -0
  285. package/dist/cli-bundle/chunks/{search-5A3BMFA7.js → search-JNEZJV7H.js} +427 -41
  286. package/dist/cli-bundle/chunks/search-JNEZJV7H.js.map +7 -0
  287. package/dist/cli-bundle/chunks/stats-7JDIJRDH.js +202 -0
  288. package/dist/cli-bundle/chunks/stats-7JDIJRDH.js.map +1 -0
  289. package/dist/cli-bundle/chunks/stats-SYTJRR4Z.js +212 -0
  290. package/dist/cli-bundle/chunks/stats-SYTJRR4Z.js.map +7 -0
  291. package/dist/cli-bundle/chunks/telemetry-4HHWD5Y7.js +251 -0
  292. package/dist/cli-bundle/chunks/telemetry-4HHWD5Y7.js.map +7 -0
  293. package/dist/cli-bundle/chunks/telemetry-EGWP7ZUX.js +248 -0
  294. package/dist/cli-bundle/chunks/telemetry-EGWP7ZUX.js.map +1 -0
  295. package/dist/cli-bundle/chunks/{test-OFYONO3C.js → test-IIELLSZX.js} +14 -13
  296. package/dist/cli-bundle/chunks/test-ML5RLWXE.js +32 -0
  297. package/dist/cli-bundle/chunks/{test-all-EEMKNTGU.js → test-all-7DNCMML7.js} +14 -13
  298. package/dist/cli-bundle/chunks/{test-all-EEMKNTGU.js.map → test-all-7DNCMML7.js.map} +1 -1
  299. package/dist/cli-bundle/chunks/{test-all-OJE6CIO7.js → test-all-IHTUJRRC.js} +16 -15
  300. package/dist/cli-bundle/chunks/{test-all-OJE6CIO7.js.map → test-all-IHTUJRRC.js.map} +1 -1
  301. package/dist/cli-bundle/chunks/{test-runs-IPOPFOAF.js → test-runs-5FEMBV3A.js} +5 -5
  302. package/dist/cli-bundle/chunks/{test-runs-L2M7WKH7.js → test-runs-RNKZ37PS.js} +5 -5
  303. package/dist/cli-bundle/chunks/update-6C67X4KS.js +21 -0
  304. package/dist/cli-bundle/chunks/update-VF26YPT3.js +25 -0
  305. package/dist/cli-bundle/chunks/{update-many-322CCH2L.js → update-many-BSZZZYXY.js} +22 -22
  306. package/dist/cli-bundle/chunks/{update-many-DYWGW57M.js → update-many-BWKJJEBF.js} +22 -22
  307. package/dist/cli-bundle/chunks/{upgrade-3W3RVSNM.js → upgrade-RSE5PC44.js} +7 -6
  308. package/dist/cli-bundle/chunks/{upgrade-3W3RVSNM.js.map → upgrade-RSE5PC44.js.map} +1 -1
  309. package/dist/cli-bundle/chunks/{upgrade-2U727SAM.js → upgrade-YWI5DJFA.js} +5 -4
  310. package/dist/cli-bundle/chunks/{upgrade-2U727SAM.js.map → upgrade-YWI5DJFA.js.map} +1 -1
  311. package/dist/cli-bundle/chunks/{validate-ZFVWPEEN.js → validate-NK3WKB7C.js} +18 -17
  312. package/dist/cli-bundle/chunks/{validate-ZFVWPEEN.js.map → validate-NK3WKB7C.js.map} +1 -1
  313. package/dist/cli-bundle/chunks/{validate-GZ24NYHO.js → validate-UCEOB7S6.js} +20 -19
  314. package/dist/cli-bundle/chunks/{validate-GZ24NYHO.js.map → validate-UCEOB7S6.js.map} +1 -1
  315. package/dist/cli-bundle/main.js +198 -1523
  316. package/dist/cli-bundle/main.js.map +4 -4
  317. package/dist/core/config/nested-settings.d.ts +8 -6
  318. package/dist/core/config/nested-settings.js +71 -5
  319. package/dist/core/config/nested-settings.js.map +1 -1
  320. package/dist/core/config/positional-value.js +4 -2
  321. package/dist/core/config/positional-value.js.map +1 -1
  322. package/dist/core/extensions/extension-types.d.ts +36 -0
  323. package/dist/core/extensions/extension-types.js +2 -2
  324. package/dist/core/extensions/extension-types.js.map +1 -1
  325. package/dist/core/extensions/loader.js +46 -5
  326. package/dist/core/extensions/loader.js.map +1 -1
  327. package/dist/core/history/drift-scan.d.ts +3 -4
  328. package/dist/core/history/drift-scan.js +71 -18
  329. package/dist/core/history/drift-scan.js.map +1 -1
  330. package/dist/core/history/history-diff.d.ts +47 -0
  331. package/dist/core/history/history-diff.js +152 -0
  332. package/dist/core/history/history-diff.js.map +1 -0
  333. package/dist/core/history/history-storage-stats.d.ts +31 -0
  334. package/dist/core/history/history-storage-stats.js +101 -0
  335. package/dist/core/history/history-storage-stats.js.map +1 -0
  336. package/dist/core/item/id.js +4 -5
  337. package/dist/core/item/id.js.map +1 -1
  338. package/dist/core/item/item-format.js +7 -3
  339. package/dist/core/item/item-format.js.map +1 -1
  340. package/dist/core/item/toon-decode.d.ts +7 -0
  341. package/dist/core/item/toon-decode.js +11 -2
  342. package/dist/core/item/toon-decode.js.map +1 -1
  343. package/dist/core/item/type-registry.js +25 -7
  344. package/dist/core/item/type-registry.js.map +1 -1
  345. package/dist/core/lock/lock-gc.d.ts +46 -0
  346. package/dist/core/lock/lock-gc.js +194 -0
  347. package/dist/core/lock/lock-gc.js.map +1 -0
  348. package/dist/core/search/cache.js +5 -3
  349. package/dist/core/search/cache.js.map +1 -1
  350. package/dist/core/search/corpus.d.ts +6 -0
  351. package/dist/core/search/corpus.js +22 -9
  352. package/dist/core/search/corpus.js.map +1 -1
  353. package/dist/core/search/embedding-batches.js +10 -7
  354. package/dist/core/search/embedding-batches.js.map +1 -1
  355. package/dist/core/search/relevance.d.ts +29 -0
  356. package/dist/core/search/relevance.js +226 -0
  357. package/dist/core/search/relevance.js.map +1 -0
  358. package/dist/core/search/vector-stores.d.ts +3 -0
  359. package/dist/core/search/vector-stores.js +23 -10
  360. package/dist/core/search/vector-stores.js.map +1 -1
  361. package/dist/core/shared/constants.js +15 -2
  362. package/dist/core/shared/constants.js.map +1 -1
  363. package/dist/core/shared/errors.d.ts +6 -0
  364. package/dist/core/shared/errors.js +2 -2
  365. package/dist/core/shared/errors.js.map +1 -1
  366. package/dist/core/shared/primitives.d.ts +8 -0
  367. package/dist/core/shared/primitives.js +29 -2
  368. package/dist/core/shared/primitives.js.map +1 -1
  369. package/dist/core/shared/serial-queue.d.ts +12 -0
  370. package/dist/core/shared/serial-queue.js +43 -0
  371. package/dist/core/shared/serial-queue.js.map +1 -0
  372. package/dist/core/shared/time.js +42 -6
  373. package/dist/core/shared/time.js.map +1 -1
  374. package/dist/core/store/paths.js +25 -7
  375. package/dist/core/store/paths.js.map +1 -1
  376. package/dist/core/store/settings-validator.d.ts +11 -0
  377. package/dist/core/store/settings-validator.js +14 -2
  378. package/dist/core/store/settings-validator.js.map +1 -1
  379. package/dist/core/store/settings.d.ts +19 -1
  380. package/dist/core/store/settings.js +199 -17
  381. package/dist/core/store/settings.js.map +1 -1
  382. package/dist/core/telemetry/observability.js +3 -3
  383. package/dist/core/telemetry/observability.js.map +1 -1
  384. package/dist/core/telemetry/runtime.js +99 -6
  385. package/dist/core/telemetry/runtime.js.map +1 -1
  386. package/dist/mcp/server.d.ts +1 -0
  387. package/dist/mcp/server.js +187 -42
  388. package/dist/mcp/server.js.map +1 -1
  389. package/dist/sdk/cli-contracts/commander-types.d.ts +1 -0
  390. package/dist/sdk/cli-contracts/commander-types.js +13 -2
  391. package/dist/sdk/cli-contracts/commander-types.js.map +1 -1
  392. package/dist/sdk/cli-contracts/enum-contracts.d.ts +2 -2
  393. package/dist/sdk/cli-contracts/enum-contracts.js +8 -2
  394. package/dist/sdk/cli-contracts/enum-contracts.js.map +1 -1
  395. package/dist/sdk/cli-contracts/tool-option-contracts.js +7 -2
  396. package/dist/sdk/cli-contracts/tool-option-contracts.js.map +1 -1
  397. package/dist/sdk/cli-contracts/tool-parameter-tables.js +39 -7
  398. package/dist/sdk/cli-contracts/tool-parameter-tables.js.map +1 -1
  399. package/dist/sdk/cli-contracts.d.ts +26 -1
  400. package/dist/sdk/cli-contracts.js +75 -11
  401. package/dist/sdk/cli-contracts.js.map +1 -1
  402. package/dist/sdk/index.d.ts +2 -2
  403. package/dist/sdk/index.js +3 -3
  404. package/dist/sdk/index.js.map +1 -1
  405. package/dist/sdk/testing.d.ts +51 -1
  406. package/dist/sdk/testing.js +93 -2
  407. package/dist/sdk/testing.js.map +1 -1
  408. package/dist/types.d.ts +14 -0
  409. package/dist/types.js +2 -2
  410. package/dist/types.js.map +1 -1
  411. package/docs/AGENT_GUIDE.md +1 -1
  412. package/docs/ARCHITECTURE.md +11 -1
  413. package/docs/CLAUDE_CODE_PLUGIN.md +4 -4
  414. package/docs/CODEX_PLUGIN.md +1 -1
  415. package/docs/COMMANDS.md +42 -4
  416. package/docs/CONFIGURATION.md +31 -2
  417. package/docs/EXTENSIONS.md +28 -8
  418. package/docs/EXTENSION_AUTHOR_CONTRACTS.md +73 -0
  419. package/docs/ONBOARDING.md +165 -0
  420. package/docs/QUICKSTART.md +2 -2
  421. package/docs/README.md +12 -4
  422. package/docs/RELEASING.md +36 -1
  423. package/docs/SDK.md +66 -0
  424. package/docs/TESTING.md +33 -1
  425. package/package.json +6 -2
  426. package/packages/pm-governance-audit/README.md +14 -0
  427. package/packages/pm-governance-audit/extensions/governance-audit/index.js +39 -1
  428. package/packages/pm-governance-audit/extensions/governance-audit/index.ts +40 -2
  429. package/packages/pm-governance-audit/extensions/governance-audit/manifest.json +1 -1
  430. package/packages/pm-governance-audit/package.json +4 -2
  431. package/packages/pm-lifecycle-hooks/README.md +21 -0
  432. package/packages/pm-search-advanced/README.md +38 -0
  433. package/packages/pm-search-advanced/extensions/search-advanced/index.js +17 -0
  434. package/packages/pm-search-advanced/extensions/search-advanced/index.ts +17 -0
  435. package/packages/pm-search-advanced/extensions/search-advanced/runtime.js +216 -1
  436. package/packages/pm-search-advanced/extensions/search-advanced/runtime.ts +271 -2
  437. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  438. package/plugins/pm-claude/README.md +11 -8
  439. package/plugins/pm-claude/agents/pm-coordinator.md +1 -1
  440. package/plugins/pm-claude/commands/pm-init.md +1 -1
  441. package/plugins/pm-codex/README.md +1 -1
  442. package/dist/cli-bundle/chunks/activity-P5BUMWP3.js +0 -16
  443. package/dist/cli-bundle/chunks/aggregate-J35K7WZB.js.map +0 -1
  444. package/dist/cli-bundle/chunks/aggregate-OOAGKWRG.js.map +0 -7
  445. package/dist/cli-bundle/chunks/chunk-4LTBNUYT.js.map +0 -1
  446. package/dist/cli-bundle/chunks/chunk-4PJQSECJ.js.map +0 -7
  447. package/dist/cli-bundle/chunks/chunk-4QCR4QW3.js.map +0 -1
  448. package/dist/cli-bundle/chunks/chunk-5IRA6IYD.js.map +0 -7
  449. package/dist/cli-bundle/chunks/chunk-5KB4X7YY.js.map +0 -1
  450. package/dist/cli-bundle/chunks/chunk-5PAOPUZX.js.map +0 -1
  451. package/dist/cli-bundle/chunks/chunk-7K24QB23.js.map +0 -1
  452. package/dist/cli-bundle/chunks/chunk-ATBVS6WW.js.map +0 -7
  453. package/dist/cli-bundle/chunks/chunk-EHXPIKKP.js.map +0 -1
  454. package/dist/cli-bundle/chunks/chunk-G5BACLYH.js.map +0 -1
  455. package/dist/cli-bundle/chunks/chunk-GNHVV4SY.js.map +0 -1
  456. package/dist/cli-bundle/chunks/chunk-KA24HME7.js.map +0 -7
  457. package/dist/cli-bundle/chunks/chunk-KBG47ZOY.js.map +0 -1
  458. package/dist/cli-bundle/chunks/chunk-N5YF3VFN.js.map +0 -7
  459. package/dist/cli-bundle/chunks/chunk-NQP3ECKF.js.map +0 -1
  460. package/dist/cli-bundle/chunks/chunk-OIQIXTNB.js.map +0 -7
  461. package/dist/cli-bundle/chunks/chunk-RANZIID5.js.map +0 -7
  462. package/dist/cli-bundle/chunks/chunk-SRVKTWPR.js.map +0 -7
  463. package/dist/cli-bundle/chunks/chunk-SSFMJCPF.js.map +0 -1
  464. package/dist/cli-bundle/chunks/chunk-SZQCER6S.js.map +0 -1
  465. package/dist/cli-bundle/chunks/chunk-TBQVUNVH.js.map +0 -7
  466. package/dist/cli-bundle/chunks/chunk-TK633IVD.js.map +0 -7
  467. package/dist/cli-bundle/chunks/chunk-V3JQ4IPL.js.map +0 -1
  468. package/dist/cli-bundle/chunks/chunk-WIKR7KFL.js.map +0 -7
  469. package/dist/cli-bundle/chunks/chunk-ZQ4F6EC4.js.map +0 -7
  470. package/dist/cli-bundle/chunks/close-RMHQ3KWH.js +0 -13
  471. package/dist/cli-bundle/chunks/close-many-AKPZNSGI.js.map +0 -1
  472. package/dist/cli-bundle/chunks/close-many-UKZSQGM7.js.map +0 -7
  473. package/dist/cli-bundle/chunks/config-5ON3ADRH.js.map +0 -7
  474. package/dist/cli-bundle/chunks/config-DDPYIA6J.js.map +0 -1
  475. package/dist/cli-bundle/chunks/context-ZOJEN5VT.js.map +0 -1
  476. package/dist/cli-bundle/chunks/contracts-CXSFM45B.js.map +0 -7
  477. package/dist/cli-bundle/chunks/contracts-LCSX5R53.js.map +0 -1
  478. package/dist/cli-bundle/chunks/create-ATONSAZW.js +0 -27
  479. package/dist/cli-bundle/chunks/gc-GT552UJH.js +0 -178
  480. package/dist/cli-bundle/chunks/gc-GT552UJH.js.map +0 -1
  481. package/dist/cli-bundle/chunks/gc-QNBRJG6H.js +0 -181
  482. package/dist/cli-bundle/chunks/gc-QNBRJG6H.js.map +0 -7
  483. package/dist/cli-bundle/chunks/get-CINFEUIY.js.map +0 -7
  484. package/dist/cli-bundle/chunks/get-WXMLRG7M.js.map +0 -1
  485. package/dist/cli-bundle/chunks/health-5VPOJQ53.js.map +0 -1
  486. package/dist/cli-bundle/chunks/health-IT5DBPRJ.js.map +0 -7
  487. package/dist/cli-bundle/chunks/history-6FC4H6HI.js +0 -20
  488. package/dist/cli-bundle/chunks/history-redact-XKYEZDBL.js +0 -19
  489. package/dist/cli-bundle/chunks/init-KHX3FEEM.js +0 -16
  490. package/dist/cli-bundle/chunks/list-53LZ2AEO.js +0 -20
  491. package/dist/cli-bundle/chunks/register-list-query-AG3XKXWL.js.map +0 -7
  492. package/dist/cli-bundle/chunks/register-list-query-EMNSIUO4.js.map +0 -1
  493. package/dist/cli-bundle/chunks/register-mutation-M3YS6XDO.js.map +0 -1
  494. package/dist/cli-bundle/chunks/register-mutation-RSMT6DPK.js.map +0 -7
  495. package/dist/cli-bundle/chunks/register-operations-KYUOOOOD.js.map +0 -1
  496. package/dist/cli-bundle/chunks/register-operations-Q54JQZUN.js.map +0 -7
  497. package/dist/cli-bundle/chunks/restore-JL5QIH7H.js +0 -17
  498. package/dist/cli-bundle/chunks/search-5A3BMFA7.js.map +0 -7
  499. package/dist/cli-bundle/chunks/search-C7NPB7G7.js.map +0 -1
  500. package/dist/cli-bundle/chunks/stats-FNLYVXTB.js +0 -120
  501. package/dist/cli-bundle/chunks/stats-FNLYVXTB.js.map +0 -1
  502. package/dist/cli-bundle/chunks/stats-Y2CBTZSL.js +0 -123
  503. package/dist/cli-bundle/chunks/stats-Y2CBTZSL.js.map +0 -7
  504. package/dist/cli-bundle/chunks/test-RJ4ZF35X.js +0 -31
  505. package/dist/cli-bundle/chunks/update-6YEHPVXH.js +0 -25
  506. package/dist/cli-bundle/chunks/update-PYLVHMRD.js +0 -21
  507. /package/dist/cli-bundle/chunks/{activity-P5BUMWP3.js.map → activity-5UROHJ3D.js.map} +0 -0
  508. /package/dist/cli-bundle/chunks/{activity-3RWRRNOW.js.map → activity-YVB3QRTE.js.map} +0 -0
  509. /package/dist/cli-bundle/chunks/{append-PNN6UIBZ.js.map → append-2PPYFAG5.js.map} +0 -0
  510. /package/dist/cli-bundle/chunks/{append-5JE3YGXU.js.map → append-AUGT5W6J.js.map} +0 -0
  511. /package/dist/cli-bundle/chunks/{chunk-26KTVXJW.js.map → chunk-2IF7WLB7.js.map} +0 -0
  512. /package/dist/cli-bundle/chunks/{chunk-XX5LRINW.js.map → chunk-2OJHLWBZ.js.map} +0 -0
  513. /package/dist/cli-bundle/chunks/{chunk-ASQM3IF5.js.map → chunk-3A2CMEM7.js.map} +0 -0
  514. /package/dist/cli-bundle/chunks/{chunk-S3CV7JGJ.js.map → chunk-3EOBJOF4.js.map} +0 -0
  515. /package/dist/cli-bundle/chunks/{chunk-B3N4TKNL.js.map → chunk-5AXMRKN5.js.map} +0 -0
  516. /package/dist/cli-bundle/chunks/{chunk-JQI2HE55.js.map → chunk-6J4K6JLA.js.map} +0 -0
  517. /package/dist/cli-bundle/chunks/{chunk-BNL6S7QH.js.map → chunk-AVJD6VTA.js.map} +0 -0
  518. /package/dist/cli-bundle/chunks/{chunk-RQAWLSUU.js.map → chunk-B5RF3IP7.js.map} +0 -0
  519. /package/dist/cli-bundle/chunks/{chunk-UFCG3SWR.js.map → chunk-C5W2UH56.js.map} +0 -0
  520. /package/dist/cli-bundle/chunks/{chunk-3OH4DAEB.js.map → chunk-CKLBZHS7.js.map} +0 -0
  521. /package/dist/cli-bundle/chunks/{chunk-GFWHHMVV.js.map → chunk-FY6Z3FYY.js.map} +0 -0
  522. /package/dist/cli-bundle/chunks/{chunk-CCUFLH4J.js.map → chunk-GNIUOLZ2.js.map} +0 -0
  523. /package/dist/cli-bundle/chunks/{chunk-ZRVSMOMR.js.map → chunk-GPXQBR3H.js.map} +0 -0
  524. /package/dist/cli-bundle/chunks/{chunk-GPGAYASV.js.map → chunk-H7EO3QA3.js.map} +0 -0
  525. /package/dist/cli-bundle/chunks/{chunk-MISYRLEP.js.map → chunk-HLC3KTLP.js.map} +0 -0
  526. /package/dist/cli-bundle/chunks/{chunk-KK6YPGH3.js.map → chunk-HMMMWBK2.js.map} +0 -0
  527. /package/dist/cli-bundle/chunks/{chunk-CJDQB2ED.js.map → chunk-HV5SSZXF.js.map} +0 -0
  528. /package/dist/cli-bundle/chunks/{chunk-FVXM3GKS.js.map → chunk-KNGVP5WJ.js.map} +0 -0
  529. /package/dist/cli-bundle/chunks/{chunk-UOVLWB47.js.map → chunk-LI65XLJR.js.map} +0 -0
  530. /package/dist/cli-bundle/chunks/{chunk-AXXKLVTW.js.map → chunk-LIN2BPJ7.js.map} +0 -0
  531. /package/dist/cli-bundle/chunks/{chunk-Y2AKE2HS.js.map → chunk-LQHBENVW.js.map} +0 -0
  532. /package/dist/cli-bundle/chunks/{chunk-D5X7N6FI.js.map → chunk-LXO6V66E.js.map} +0 -0
  533. /package/dist/cli-bundle/chunks/{chunk-DFIZGAI5.js.map → chunk-MOYM2C3J.js.map} +0 -0
  534. /package/dist/cli-bundle/chunks/{chunk-OUF3ARDX.js.map → chunk-NQL32HQ5.js.map} +0 -0
  535. /package/dist/cli-bundle/chunks/{chunk-GCAVRLGE.js.map → chunk-OKSKJKHX.js.map} +0 -0
  536. /package/dist/cli-bundle/chunks/{chunk-A6PEXMYN.js.map → chunk-R3V3YCMH.js.map} +0 -0
  537. /package/dist/cli-bundle/chunks/{chunk-T2ORWB6D.js.map → chunk-RVPTZKBC.js.map} +0 -0
  538. /package/dist/cli-bundle/chunks/{chunk-K47WAYQV.js.map → chunk-SFFVGNHC.js.map} +0 -0
  539. /package/dist/cli-bundle/chunks/{chunk-DFUSXJDE.js.map → chunk-SQPKRA54.js.map} +0 -0
  540. /package/dist/cli-bundle/chunks/{chunk-JB4RGL4V.js.map → chunk-TNPBPNII.js.map} +0 -0
  541. /package/dist/cli-bundle/chunks/{chunk-XG7RJYHV.js.map → chunk-TP4DDY27.js.map} +0 -0
  542. /package/dist/cli-bundle/chunks/{chunk-ORTLYVA4.js.map → chunk-TYJJOTUA.js.map} +0 -0
  543. /package/dist/cli-bundle/chunks/{chunk-HZOS2UG5.js.map → chunk-UAQOQ7IE.js.map} +0 -0
  544. /package/dist/cli-bundle/chunks/{chunk-D3WUNETC.js.map → chunk-UEWA73ZZ.js.map} +0 -0
  545. /package/dist/cli-bundle/chunks/{chunk-O5IBJE6S.js.map → chunk-UIIQC5YO.js.map} +0 -0
  546. /package/dist/cli-bundle/chunks/{chunk-LDJK7SHN.js.map → chunk-V6EYFTRL.js.map} +0 -0
  547. /package/dist/cli-bundle/chunks/{chunk-TQ3ZK6VD.js.map → chunk-WYEXLDDY.js.map} +0 -0
  548. /package/dist/cli-bundle/chunks/{chunk-KCMIYKTA.js.map → chunk-X7UHMKPE.js.map} +0 -0
  549. /package/dist/cli-bundle/chunks/{chunk-CWT53EYT.js.map → chunk-YBZW2QQ7.js.map} +0 -0
  550. /package/dist/cli-bundle/chunks/{chunk-VGO2T3TY.js.map → chunk-YO3THIJF.js.map} +0 -0
  551. /package/dist/cli-bundle/chunks/{claim-ZFA7HKU4.js.map → claim-BJ4QMPJC.js.map} +0 -0
  552. /package/dist/cli-bundle/chunks/{claim-AZLP7YFO.js.map → claim-KW743OSW.js.map} +0 -0
  553. /package/dist/cli-bundle/chunks/{close-RMHQ3KWH.js.map → close-P4ZBKODL.js.map} +0 -0
  554. /package/dist/cli-bundle/chunks/{close-65DFYAVS.js.map → close-SYHSRZDC.js.map} +0 -0
  555. /package/dist/cli-bundle/chunks/{comments-AGBNSJJH.js.map → comments-JEO6HHVM.js.map} +0 -0
  556. /package/dist/cli-bundle/chunks/{comments-CJWXQI7X.js.map → comments-YT2PQ5DD.js.map} +0 -0
  557. /package/dist/cli-bundle/chunks/{create-ATONSAZW.js.map → create-4DS2QWQC.js.map} +0 -0
  558. /package/dist/cli-bundle/chunks/{create-WYFKN2U4.js.map → create-CF7EVRX7.js.map} +0 -0
  559. /package/dist/cli-bundle/chunks/{delete-ZXWC56WO.js.map → delete-KR4VBWVE.js.map} +0 -0
  560. /package/dist/cli-bundle/chunks/{delete-RONNH4F4.js.map → delete-XLZRTRKR.js.map} +0 -0
  561. /package/dist/cli-bundle/chunks/{deps-WII3O4HB.js.map → deps-2YTXD3VM.js.map} +0 -0
  562. /package/dist/cli-bundle/chunks/{deps-EHXIFOZR.js.map → deps-GZMFMTGS.js.map} +0 -0
  563. /package/dist/cli-bundle/chunks/{docs-PDREIMLS.js.map → docs-SLROFEQ4.js.map} +0 -0
  564. /package/dist/cli-bundle/chunks/{docs-JMVCFNHH.js.map → docs-ZHISRR2D.js.map} +0 -0
  565. /package/dist/cli-bundle/chunks/{extension-G6UXSM5S.js.map → extension-3C7OOI4F.js.map} +0 -0
  566. /package/dist/cli-bundle/chunks/{extension-B4ROVWJD.js.map → extension-XYCUXICD.js.map} +0 -0
  567. /package/dist/cli-bundle/chunks/{files-2PN7UM2D.js.map → files-FUWF2FYJ.js.map} +0 -0
  568. /package/dist/cli-bundle/chunks/{files-MXYS5W4M.js.map → files-J4I5IU4O.js.map} +0 -0
  569. /package/dist/cli-bundle/chunks/{history-FLZIP7PM.js.map → history-SDAWYZR3.js.map} +0 -0
  570. /package/dist/cli-bundle/chunks/{history-6FC4H6HI.js.map → history-YDUEILKP.js.map} +0 -0
  571. /package/dist/cli-bundle/chunks/{history-redact-SSZBAD76.js.map → history-redact-EPJ7GENL.js.map} +0 -0
  572. /package/dist/cli-bundle/chunks/{history-redact-XKYEZDBL.js.map → history-redact-KASLLPE7.js.map} +0 -0
  573. /package/dist/cli-bundle/chunks/{history-repair-X7CO5JJZ.js.map → history-repair-IJ7LLBET.js.map} +0 -0
  574. /package/dist/cli-bundle/chunks/{history-repair-KC5ZOJRZ.js.map → history-repair-YNESJRT6.js.map} +0 -0
  575. /package/dist/cli-bundle/chunks/{init-KHX3FEEM.js.map → init-IGSS4GNH.js.map} +0 -0
  576. /package/dist/cli-bundle/chunks/{init-6MRFVOLH.js.map → init-YHVBTEET.js.map} +0 -0
  577. /package/dist/cli-bundle/chunks/{learnings-DCX55BNX.js.map → learnings-4YBMIVCZ.js.map} +0 -0
  578. /package/dist/cli-bundle/chunks/{learnings-A3CLB5CO.js.map → learnings-T4PF24YN.js.map} +0 -0
  579. /package/dist/cli-bundle/chunks/{list-DBRECOG4.js.map → list-3KEVBOYW.js.map} +0 -0
  580. /package/dist/cli-bundle/chunks/{list-53LZ2AEO.js.map → list-E44O2K64.js.map} +0 -0
  581. /package/dist/cli-bundle/chunks/{notes-42LIC3UE.js.map → notes-FLUCNJSH.js.map} +0 -0
  582. /package/dist/cli-bundle/chunks/{notes-P5O3VMQ3.js.map → notes-GJKALVZM.js.map} +0 -0
  583. /package/dist/cli-bundle/chunks/{plan-HDQXEUKD.js.map → plan-T5MMZLI3.js.map} +0 -0
  584. /package/dist/cli-bundle/chunks/{plan-IGTE3WOJ.js.map → plan-YYMIL3HV.js.map} +0 -0
  585. /package/dist/cli-bundle/chunks/{restore-2XVTBLKQ.js.map → restore-DDJGVZIN.js.map} +0 -0
  586. /package/dist/cli-bundle/chunks/{restore-JL5QIH7H.js.map → restore-SJSASGZP.js.map} +0 -0
  587. /package/dist/cli-bundle/chunks/{schema-V6BX65Q2.js.map → schema-B7NQ6XVP.js.map} +0 -0
  588. /package/dist/cli-bundle/chunks/{schema-LVXZWFGY.js.map → schema-HEGYH6CE.js.map} +0 -0
  589. /package/dist/cli-bundle/chunks/{test-OFYONO3C.js.map → test-IIELLSZX.js.map} +0 -0
  590. /package/dist/cli-bundle/chunks/{test-RJ4ZF35X.js.map → test-ML5RLWXE.js.map} +0 -0
  591. /package/dist/cli-bundle/chunks/{test-runs-IPOPFOAF.js.map → test-runs-5FEMBV3A.js.map} +0 -0
  592. /package/dist/cli-bundle/chunks/{test-runs-L2M7WKH7.js.map → test-runs-RNKZ37PS.js.map} +0 -0
  593. /package/dist/cli-bundle/chunks/{update-PYLVHMRD.js.map → update-6C67X4KS.js.map} +0 -0
  594. /package/dist/cli-bundle/chunks/{update-6YEHPVXH.js.map → update-VF26YPT3.js.map} +0 -0
  595. /package/dist/cli-bundle/chunks/{update-many-322CCH2L.js.map → update-many-BSZZZYXY.js.map} +0 -0
  596. /package/dist/cli-bundle/chunks/{update-many-DYWGW57M.js.map → update-many-BWKJJEBF.js.map} +0 -0
@@ -0,0 +1,1572 @@
1
+
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="87b64271-e0df-5c0d-991b-f7d1a6401710")}catch(e){}}();
3
+ import {
4
+ nowIso
5
+ } from "./chunk-B2KZGPM2.js";
6
+ import {
7
+ EXIT_CODE,
8
+ appendLineAtomic,
9
+ readFileIfExists,
10
+ readSettings,
11
+ resolveGlobalPmRoot,
12
+ resolvePmPackageRootFromModule,
13
+ resolveTelemetryErrorCategory,
14
+ writeFileAtomic,
15
+ writeSettings
16
+ } from "./chunk-X4IZKYHP.js";
17
+
18
+ // dist/core/telemetry/observability.js
19
+ var SETUP_ROOT_COMMANDS = /* @__PURE__ */ new Set(["init", "config", "completion", "completion-statuses", "completion-tags", "completion-types"]);
20
+ var QUERY_ROOT_COMMANDS = /* @__PURE__ */ new Set([
21
+ "list",
22
+ "list-all",
23
+ "list-open",
24
+ "list-in-progress",
25
+ "list-blocked",
26
+ "list-closed",
27
+ "list-canceled",
28
+ "list-draft",
29
+ "search",
30
+ "get",
31
+ "context",
32
+ "calendar",
33
+ "history",
34
+ "activity",
35
+ "aggregate",
36
+ "deps",
37
+ "contracts",
38
+ "stats",
39
+ "dedupe-audit"
40
+ ]);
41
+ var MUTATION_ROOT_COMMANDS = /* @__PURE__ */ new Set([
42
+ "create",
43
+ "update",
44
+ "update-many",
45
+ "close-many",
46
+ "append",
47
+ "close",
48
+ "delete",
49
+ "restore",
50
+ "claim",
51
+ "release",
52
+ "comments",
53
+ "notes",
54
+ "learnings",
55
+ "files",
56
+ "docs",
57
+ "start-task",
58
+ "pause-task",
59
+ "close-task"
60
+ ]);
61
+ var TESTING_ROOT_COMMANDS = /* @__PURE__ */ new Set(["test", "test-all", "test-runs", "test-verify", "trace-test", "test-ping"]);
62
+ var DIAGNOSTICS_ROOT_COMMANDS = /* @__PURE__ */ new Set(["health", "validate", "normalize", "reindex", "gc", "telemetry", "extension-doctor"]);
63
+ function normalizeCommandPath(commandPath) {
64
+ return commandPath.trim().replaceAll(/\s+/g, " ").toLowerCase();
65
+ }
66
+ function normalizeErrorCode(errorCode2) {
67
+ const normalized = errorCode2?.trim().toLowerCase();
68
+ return normalized && normalized.length > 0 ? normalized : void 0;
69
+ }
70
+ function deriveTelemetryCommandTaxonomy(commandPath) {
71
+ const normalizedPath = normalizeCommandPath(commandPath);
72
+ const tokens = normalizedPath.length > 0 ? normalizedPath.split(" ") : ["<unknown>"];
73
+ const root = tokens[0] ?? "<unknown>";
74
+ const leaf = tokens[tokens.length - 1] ?? root;
75
+ let family = "other";
76
+ if (SETUP_ROOT_COMMANDS.has(root)) {
77
+ family = "setup";
78
+ } else if (QUERY_ROOT_COMMANDS.has(root)) {
79
+ family = "query";
80
+ } else if (MUTATION_ROOT_COMMANDS.has(root)) {
81
+ family = "mutation";
82
+ } else if (TESTING_ROOT_COMMANDS.has(root)) {
83
+ family = "testing";
84
+ } else if (root === "extension") {
85
+ family = "extension";
86
+ } else if (DIAGNOSTICS_ROOT_COMMANDS.has(root)) {
87
+ family = "diagnostics";
88
+ }
89
+ return {
90
+ command_path: normalizedPath.length > 0 ? normalizedPath : "<unknown>",
91
+ command_root: root,
92
+ command_leaf: leaf,
93
+ command_depth: tokens.length,
94
+ command_family: family
95
+ };
96
+ }
97
+ function inferTelemetryErrorCode(params) {
98
+ if (params.ok) {
99
+ return void 0;
100
+ }
101
+ const explicit = normalizeErrorCode(params.errorCode);
102
+ if (explicit) {
103
+ return explicit;
104
+ }
105
+ const message = (params.errorMessage ?? "").trim().toLowerCase();
106
+ if (message.includes("unknown command")) {
107
+ return "unknown_command";
108
+ }
109
+ if (message.includes("unknown option")) {
110
+ return "unknown_option";
111
+ }
112
+ if (message.includes("missing required options") || message.includes("missing required option")) {
113
+ return "missing_required_option";
114
+ }
115
+ if (message.includes("missing required argument")) {
116
+ return "missing_required_argument";
117
+ }
118
+ if (message.includes("no update flags provided")) {
119
+ return "no_update_fields";
120
+ }
121
+ if (message.includes("is assigned to") && message.includes("use --force")) {
122
+ return "ownership_conflict";
123
+ }
124
+ if (message.includes("is locked")) {
125
+ return "lock_conflict";
126
+ }
127
+ if (message.includes("already terminal") && message.includes("use --force")) {
128
+ return "terminal_state_conflict";
129
+ }
130
+ if (message.includes("tracker is not initialized")) {
131
+ return "tracker_not_initialized";
132
+ }
133
+ if (message.includes(" not found")) {
134
+ return "item_not_found";
135
+ }
136
+ if (message.includes('use "pm close <id> <text>" to close an item') || message.includes("invalid --status value") && message.includes('"closed"')) {
137
+ return "close_through_update";
138
+ }
139
+ if (message.startsWith("invalid ") || message.includes(" must be ") || message.includes(" requires ")) {
140
+ return "invalid_argument_value";
141
+ }
142
+ if (message.includes("strict create mode requires concrete values for --")) {
143
+ return "missing_required_option";
144
+ }
145
+ if (message.includes("either as positional") && message.includes("not both")) {
146
+ return "invalid_command_usage";
147
+ }
148
+ const exitCode = Number.isFinite(params.exitCode) ? Math.max(0, Math.trunc(params.exitCode ?? 0)) : void 0;
149
+ if (exitCode === EXIT_CODE.USAGE) {
150
+ return "invalid_command_usage";
151
+ }
152
+ if (exitCode === EXIT_CODE.NOT_FOUND) {
153
+ return "item_not_found";
154
+ }
155
+ if (exitCode === EXIT_CODE.CONFLICT) {
156
+ return "lock_conflict";
157
+ }
158
+ if (exitCode === EXIT_CODE.DEPENDENCY_FAILED) {
159
+ return "dependency_failed";
160
+ }
161
+ return "command_failed";
162
+ }
163
+ function deriveTelemetryCommandResolution(params) {
164
+ if (params.ok) {
165
+ return "success";
166
+ }
167
+ const normalizedCode = normalizeErrorCode(params.errorCode);
168
+ if (normalizedCode === "unknown_command") {
169
+ return "nonexistent_command";
170
+ }
171
+ if (normalizedCode === "unknown_option") {
172
+ return "invalid_option";
173
+ }
174
+ if (normalizedCode === "missing_required_option") {
175
+ return "missing_required_option";
176
+ }
177
+ if (normalizedCode === "missing_required_argument") {
178
+ return "missing_required_argument";
179
+ }
180
+ if (normalizedCode === "health_findings") {
181
+ return "health_findings";
182
+ }
183
+ if (normalizedCode === "validation_findings") {
184
+ return "validation_findings";
185
+ }
186
+ if (params.errorCategory === "usage") {
187
+ return "invalid_usage";
188
+ }
189
+ if (params.errorCategory === "validation") {
190
+ return "validation_failed";
191
+ }
192
+ if (params.errorCategory === "conflict") {
193
+ return "conflict";
194
+ }
195
+ if (params.errorCategory === "runtime") {
196
+ return "runtime_failed";
197
+ }
198
+ return "unknown_failed";
199
+ }
200
+
201
+ // dist/core/telemetry/runtime.js
202
+ import crypto from "node:crypto";
203
+ import { spawn } from "node:child_process";
204
+ import { mkdirSync, rmSync, statSync } from "node:fs";
205
+ import { mkdir, readdir, rm, stat } from "node:fs/promises";
206
+ import os from "node:os";
207
+ import path from "node:path";
208
+ var TELEMETRY_QUEUE_RELATIVE_PATH = path.join("runtime", "telemetry", "events.jsonl");
209
+ var TELEMETRY_STATE_RELATIVE_PATH = path.join("runtime", "telemetry", "state.json");
210
+ var TELEMETRY_SCHEMA_VERSION = 1;
211
+ var TELEMETRY_CLIENT_SCHEMA_VERSION = 1;
212
+ var TELEMETRY_FLUSH_BATCH_SIZE = 100;
213
+ var TELEMETRY_MAX_RETRY_DELAY_MS = 36e5;
214
+ var TELEMETRY_RETRY_BASE_DELAY_MS = 3e4;
215
+ var TELEMETRY_HTTP_TIMEOUT_MS = 5e3;
216
+ var MILLISECONDS_PER_DAY = 864e5;
217
+ var TELEMETRY_MAX_EVENT_BYTES = 65536;
218
+ var TELEMETRY_SANITIZE_MAX_DEPTH = 6;
219
+ var TELEMETRY_SANITIZE_MAX_ARRAY_ITEMS = 20;
220
+ var TELEMETRY_MAX_QUEUE_ENTRY_ATTEMPTS = 15;
221
+ var TELEMETRY_RESULT_PREVIEW_MAX_BYTES = 8192;
222
+ var TELEMETRY_QUEUE_REWRITE_RETRY_DELAYS_MS = [25, 50, 100, 200];
223
+ var TELEMETRY_QUEUE_TMP_ORPHAN_MAX_AGE_MS = 60 * 60 * 1e3;
224
+ var TELEMETRY_FLUSH_LOCK_STALE_MS = 6e4;
225
+ var TELEMETRY_FLUSH_SPAWN_LOCK_STALE_MS = 6e4;
226
+ var OTEL_TRACES_ENDPOINT_ENV = "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT";
227
+ var OTEL_BASE_ENDPOINT_ENV = "OTEL_EXPORTER_OTLP_ENDPOINT";
228
+ var OTEL_SERVICE_NAME_ENV = "OTEL_SERVICE_NAME";
229
+ var PM_TELEMETRY_DISABLED_ENV = "PM_TELEMETRY_DISABLED";
230
+ var PM_NO_TELEMETRY_ENV = "PM_NO_TELEMETRY";
231
+ var PM_TELEMETRY_DISABLED_VALUES = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]);
232
+ var PM_TELEMETRY_OTEL_DISABLED_ENV = "PM_TELEMETRY_OTEL_DISABLED";
233
+ var PM_TELEMETRY_OTEL_DISABLED_VALUES = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]);
234
+ var PM_TELEMETRY_INLINE_FLUSH_ENV = "PM_TELEMETRY_INLINE_FLUSH";
235
+ var PM_TELEMETRY_FLUSH_CHILD_ENV = "PM_TELEMETRY_FLUSH_CHILD";
236
+ var PM_TELEMETRY_SOURCE_CONTEXT_ENV = "PM_TELEMETRY_SOURCE_CONTEXT";
237
+ var PM_TELEMETRY_SOURCE_CONTEXT_VALUES = ["user", "automation", "test", "dogfood", "audit_smoke"];
238
+ var _lastFlushPromise = Promise.resolve();
239
+ var _queueMutationPromise = Promise.resolve();
240
+ var PM_TELEMETRY_SOURCE_CONTEXT_SET = new Set(PM_TELEMETRY_SOURCE_CONTEXT_VALUES);
241
+ var BOOLEAN_TRUE_VALUES = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]);
242
+ var PROCESS_SESSION_ID = crypto.randomUUID();
243
+ var SENSITIVE_KEYWORDS = [
244
+ "token",
245
+ "secret",
246
+ "password",
247
+ "passwd",
248
+ "api_key",
249
+ "apikey",
250
+ "authorization",
251
+ "cookie",
252
+ "session",
253
+ "credentials",
254
+ "bearer"
255
+ ];
256
+ var SENSITIVE_INLINE_KEY_PATTERN = "(?:token|secret|password|passwd|api[_-]?key|apikey|authorization|cookie|session|credentials|bearer)";
257
+ var INLINE_SENSITIVE_ASSIGNMENT_PATTERN = new RegExp(`\\b(${SENSITIVE_INLINE_KEY_PATTERN})\\s*([:=])\\s*([^\\s,;]+)`, "giu");
258
+ var INLINE_SENSITIVE_FLAG_PATTERN = new RegExp(`(--${SENSITIVE_INLINE_KEY_PATTERN})(=|\\s+)([^\\s,;]+)`, "giu");
259
+ var ABSOLUTE_PATH_TOKEN_PATTERN = /(^|[\s"'`(=])\/(?:[^\s"'`),;]+)/g;
260
+ var BEARER_TOKEN_PATTERN = /bearer\s+[a-z0-9._=-]+/giu;
261
+ var PRIVATE_IP_PATTERN = /\b(?:10\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|172\.(?:1[6-9]|2\d|3[01])\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|192\.168\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d))\b/g;
262
+ function queuePath(globalPmRoot) {
263
+ return path.join(globalPmRoot, TELEMETRY_QUEUE_RELATIVE_PATH);
264
+ }
265
+ function telemetryRuntimeDirectory(globalPmRoot) {
266
+ return path.dirname(queuePath(globalPmRoot));
267
+ }
268
+ function runtimeStatePath(globalPmRoot) {
269
+ return path.join(globalPmRoot, TELEMETRY_STATE_RELATIVE_PATH);
270
+ }
271
+ function flushLockPath(globalPmRoot) {
272
+ return path.join(globalPmRoot, "runtime", "telemetry", "flush.lock");
273
+ }
274
+ function flushSpawnLockPath(globalPmRoot) {
275
+ return path.join(globalPmRoot, "runtime", "telemetry", "flush.spawn.lock");
276
+ }
277
+ function telemetryFlushRunnerPath() {
278
+ return path.join(resolvePmPackageRootFromModule(import.meta.url, ["../../.."]), "dist", "cli", "telemetry-flush.js");
279
+ }
280
+ function shouldFlushInline() {
281
+ if (parseBooleanTrueLike(process.env[PM_TELEMETRY_INLINE_FLUSH_ENV])) {
282
+ return true;
283
+ }
284
+ if (parseBooleanTrueLike(process.env[PM_TELEMETRY_FLUSH_CHILD_ENV])) {
285
+ return true;
286
+ }
287
+ const nodeEnv = (process.env.NODE_ENV ?? "").trim().toLowerCase();
288
+ return typeof process.env.VITEST === "string" || typeof process.env.VITEST_WORKER_ID === "string" || nodeEnv === "test";
289
+ }
290
+ async function readRuntimeState(globalPmRoot) {
291
+ const raw = await readFileIfExists(runtimeStatePath(globalPmRoot));
292
+ if (!raw || raw.trim().length === 0) {
293
+ return {};
294
+ }
295
+ try {
296
+ const parsed = JSON.parse(raw);
297
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
298
+ return {};
299
+ }
300
+ return parsed;
301
+ } catch {
302
+ return {};
303
+ }
304
+ }
305
+ async function writeRuntimeState(globalPmRoot, patch) {
306
+ try {
307
+ const current = await readRuntimeState(globalPmRoot);
308
+ const next = {
309
+ ...current,
310
+ ...patch
311
+ };
312
+ const normalized = Object.fromEntries(Object.entries(next).filter(([, value]) => value !== void 0).sort((left, right) => left[0].localeCompare(right[0])));
313
+ await writeFileAtomic(runtimeStatePath(globalPmRoot), `${JSON.stringify(normalized, null, 2)}
314
+ `);
315
+ } catch {
316
+ }
317
+ }
318
+ function isSensitiveKey(key) {
319
+ const normalized = key.trim().toLowerCase().replaceAll("-", "_").replaceAll(/[^a-z0-9_]+/g, "_");
320
+ const tokens = normalized.split("_").filter((token) => token.length > 0);
321
+ return SENSITIVE_KEYWORDS.some((keyword) => normalized === keyword || normalized.endsWith(`_${keyword}`) || tokens.includes(keyword));
322
+ }
323
+ function redactInlineSensitiveAssignments(input) {
324
+ const withoutAssignments = input.replaceAll(INLINE_SENSITIVE_ASSIGNMENT_PATTERN, (_match, key, delimiter) => `${key}${delimiter}[redacted]`);
325
+ return withoutAssignments.replaceAll(INLINE_SENSITIVE_FLAG_PATTERN, (_match, flag, delimiter) => `${flag}${delimiter}[redacted]`);
326
+ }
327
+ function redactAbsolutePathTokens(input) {
328
+ return input.replaceAll(ABSOLUTE_PATH_TOKEN_PATTERN, (_match, prefix) => `${prefix}[redacted_path]`);
329
+ }
330
+ function isAsciiLetterOrDigitCode(code) {
331
+ const isUpper = code >= 65 && code <= 90;
332
+ const isLower = code >= 97 && code <= 122;
333
+ const isDigit = code >= 48 && code <= 57;
334
+ return isUpper || isLower || isDigit;
335
+ }
336
+ function isEmailLocalCharacter(character) {
337
+ if (!character) {
338
+ return false;
339
+ }
340
+ const code = character.charCodeAt(0);
341
+ if (isAsciiLetterOrDigitCode(code)) {
342
+ return true;
343
+ }
344
+ return character === "." || character === "_" || character === "%" || character === "+" || character === "-";
345
+ }
346
+ function isEmailDomainCharacter(character) {
347
+ if (!character) {
348
+ return false;
349
+ }
350
+ const code = character.charCodeAt(0);
351
+ if (isAsciiLetterOrDigitCode(code)) {
352
+ return true;
353
+ }
354
+ return character === "." || character === "-";
355
+ }
356
+ function looksLikeEmailToken(token) {
357
+ const atIndex = token.indexOf("@");
358
+ if (atIndex <= 0 || atIndex !== token.lastIndexOf("@") || atIndex === token.length - 1) {
359
+ return false;
360
+ }
361
+ const localPart = token.slice(0, atIndex);
362
+ const domainPart = token.slice(atIndex + 1);
363
+ const lastDot = domainPart.lastIndexOf(".");
364
+ if (lastDot <= 0 || lastDot === domainPart.length - 1) {
365
+ return false;
366
+ }
367
+ if (domainPart.length - (lastDot + 1) < 2) {
368
+ return false;
369
+ }
370
+ for (const character of localPart) {
371
+ if (!isEmailLocalCharacter(character)) {
372
+ return false;
373
+ }
374
+ }
375
+ for (const character of domainPart) {
376
+ if (!isEmailDomainCharacter(character)) {
377
+ return false;
378
+ }
379
+ }
380
+ return true;
381
+ }
382
+ function redactEmailTokens(input) {
383
+ let redacted = "";
384
+ let cursor = 0;
385
+ while (cursor < input.length) {
386
+ const atIndex = input.indexOf("@", cursor);
387
+ if (atIndex < 0) {
388
+ redacted += input.slice(cursor);
389
+ break;
390
+ }
391
+ let start = atIndex - 1;
392
+ while (start >= cursor && isEmailLocalCharacter(input[start])) {
393
+ start -= 1;
394
+ }
395
+ start += 1;
396
+ let end = atIndex + 1;
397
+ while (end < input.length && isEmailDomainCharacter(input[end])) {
398
+ end += 1;
399
+ }
400
+ const candidate = input.slice(start, end);
401
+ if (looksLikeEmailToken(candidate)) {
402
+ redacted += input.slice(cursor, start);
403
+ redacted += "[redacted_email]";
404
+ cursor = end;
405
+ continue;
406
+ }
407
+ redacted += input.slice(cursor, atIndex + 1);
408
+ cursor = atIndex + 1;
409
+ }
410
+ return redacted;
411
+ }
412
+ function sanitizeCommonSensitiveTokens(input) {
413
+ const withoutEmails = redactEmailTokens(input);
414
+ const withoutBearer = withoutEmails.replaceAll(BEARER_TOKEN_PATTERN, "bearer [redacted_token]");
415
+ return withoutBearer.replaceAll(PRIVATE_IP_PATTERN, "[redacted_ip]");
416
+ }
417
+ function sanitizeStringRedacted(input) {
418
+ const withoutCommonSensitiveTokens = sanitizeCommonSensitiveTokens(input);
419
+ const withoutInlineSecrets = redactInlineSensitiveAssignments(withoutCommonSensitiveTokens);
420
+ const withoutAbsolutePaths = redactAbsolutePathTokens(withoutInlineSecrets);
421
+ const trimmed = withoutAbsolutePaths.trim();
422
+ if (trimmed.startsWith("/") && trimmed.length > 1) {
423
+ return "[redacted_path]";
424
+ }
425
+ if (withoutAbsolutePaths.length > 512) {
426
+ return `${withoutAbsolutePaths.slice(0, 509)}...`;
427
+ }
428
+ return withoutAbsolutePaths;
429
+ }
430
+ function sanitizeStringMax(input) {
431
+ const withoutCommonSensitiveTokens = sanitizeCommonSensitiveTokens(input);
432
+ const withoutInlineSecrets = redactInlineSensitiveAssignments(withoutCommonSensitiveTokens);
433
+ const withoutAbsolutePaths = redactAbsolutePathTokens(withoutInlineSecrets);
434
+ const trimmed = withoutAbsolutePaths.trim();
435
+ if (trimmed.startsWith("/") && trimmed.length > 1) {
436
+ return "[redacted_path]";
437
+ }
438
+ if (withoutAbsolutePaths.length > 2048) {
439
+ return `${withoutAbsolutePaths.slice(0, 2045)}...`;
440
+ }
441
+ return withoutAbsolutePaths;
442
+ }
443
+ function sanitizeString(input, captureLevel = "redacted") {
444
+ if (captureLevel === "max") {
445
+ return sanitizeStringMax(input);
446
+ }
447
+ return sanitizeStringRedacted(input);
448
+ }
449
+ function sanitizeValue(value, keyHint, captureLevel = "redacted", depth = 0) {
450
+ if (keyHint && isSensitiveKey(keyHint)) {
451
+ return "[redacted]";
452
+ }
453
+ if (value === null || value === void 0) {
454
+ return value;
455
+ }
456
+ if (typeof value === "string") {
457
+ return sanitizeString(value, captureLevel);
458
+ }
459
+ if (typeof value === "number" || typeof value === "boolean") {
460
+ return value;
461
+ }
462
+ if (depth >= TELEMETRY_SANITIZE_MAX_DEPTH) {
463
+ return "[depth_truncated]";
464
+ }
465
+ if (Array.isArray(value)) {
466
+ return value.slice(0, TELEMETRY_SANITIZE_MAX_ARRAY_ITEMS).map((entry) => sanitizeValue(entry, void 0, captureLevel, depth + 1));
467
+ }
468
+ if (typeof value === "object") {
469
+ const record = value;
470
+ const sanitized = {};
471
+ for (const [key, nested] of Object.entries(record)) {
472
+ sanitized[key] = sanitizeValue(nested, key, captureLevel, depth + 1);
473
+ }
474
+ return sanitized;
475
+ }
476
+ return String(value);
477
+ }
478
+ function sanitizeCommandArgs(args, captureLevel = "redacted") {
479
+ const sanitized = [];
480
+ let nextIsSensitiveValue = false;
481
+ for (const rawArg of args) {
482
+ const arg = sanitizeString(rawArg, captureLevel);
483
+ if (nextIsSensitiveValue) {
484
+ sanitized.push("[redacted]");
485
+ nextIsSensitiveValue = false;
486
+ continue;
487
+ }
488
+ if (arg.startsWith("--")) {
489
+ const withoutPrefix = arg.slice(2);
490
+ const delimiterIndex = withoutPrefix.indexOf("=");
491
+ if (delimiterIndex >= 0) {
492
+ const key = withoutPrefix.slice(0, delimiterIndex);
493
+ const value = withoutPrefix.slice(delimiterIndex + 1);
494
+ if (isSensitiveKey(key)) {
495
+ sanitized.push(`--${key}=[redacted]`);
496
+ } else {
497
+ sanitized.push(`--${key}=${sanitizeString(value, captureLevel)}`);
498
+ }
499
+ continue;
500
+ }
501
+ if (isSensitiveKey(withoutPrefix)) {
502
+ sanitized.push(`--${withoutPrefix}`);
503
+ nextIsSensitiveValue = true;
504
+ continue;
505
+ }
506
+ }
507
+ sanitized.push(arg);
508
+ }
509
+ return sanitized;
510
+ }
511
+ function normalizeCaptureLevel(value) {
512
+ const normalized = value?.trim().toLowerCase();
513
+ if (normalized === "minimal" || normalized === "redacted" || normalized === "max") {
514
+ return normalized;
515
+ }
516
+ return "redacted";
517
+ }
518
+ function parseBooleanTrueLike(value) {
519
+ return BOOLEAN_TRUE_VALUES.has((value ?? "").trim().toLowerCase());
520
+ }
521
+ function normalizePmVersion(value) {
522
+ const trimmed = value?.trim() ?? "";
523
+ return trimmed.length > 0 ? trimmed : "0.0.0";
524
+ }
525
+ function normalizeTelemetryErrorCode(value) {
526
+ const normalized = value?.trim();
527
+ return normalized && normalized.length > 0 ? normalized : void 0;
528
+ }
529
+ function normalizeTelemetryExitCode(exitCode, ok) {
530
+ if (Number.isFinite(exitCode)) {
531
+ return Math.max(0, Math.trunc(exitCode ?? 0));
532
+ }
533
+ return ok ? 0 : 1;
534
+ }
535
+ function normalizeTelemetryErrorCategory(params) {
536
+ if (params.ok) {
537
+ return void 0;
538
+ }
539
+ if (typeof params.errorCategory === "string" && params.errorCategory.trim().length > 0) {
540
+ return params.errorCategory;
541
+ }
542
+ if (typeof params.errorCode === "string" && params.errorCode.trim().length > 0) {
543
+ return resolveTelemetryErrorCategory(params.errorCode);
544
+ }
545
+ return "unknown";
546
+ }
547
+ function resolveTelemetrySourceContext(globalOptions) {
548
+ const override = (process.env[PM_TELEMETRY_SOURCE_CONTEXT_ENV] ?? "").trim().toLowerCase();
549
+ if (PM_TELEMETRY_SOURCE_CONTEXT_SET.has(override)) {
550
+ return {
551
+ source_context: override,
552
+ source_context_source: "env_override"
553
+ };
554
+ }
555
+ const nodeEnv = (process.env.NODE_ENV ?? "").trim().toLowerCase();
556
+ if (typeof process.env.VITEST === "string" || typeof process.env.VITEST_WORKER_ID === "string" || nodeEnv === "test") {
557
+ return {
558
+ source_context: "test",
559
+ source_context_source: "inferred"
560
+ };
561
+ }
562
+ const nonTty = process.stdin.isTTY !== true || process.stdout.isTTY !== true;
563
+ const ci = parseBooleanTrueLike(process.env.CI);
564
+ const scriptLikeMode = globalOptions.json === true || globalOptions.quiet === true;
565
+ if (nonTty || ci || scriptLikeMode) {
566
+ return {
567
+ source_context: "automation",
568
+ source_context_source: "inferred"
569
+ };
570
+ }
571
+ return {
572
+ source_context: "user",
573
+ source_context_source: "inferred"
574
+ };
575
+ }
576
+ function hashWithInstallationId(installationId, value) {
577
+ return crypto.createHash("sha256").update(`${installationId}:${value}`).digest("hex");
578
+ }
579
+ function normalizeForHash(value, depth = 0) {
580
+ if (value === null || value === void 0) {
581
+ return value;
582
+ }
583
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
584
+ return value;
585
+ }
586
+ if (depth >= TELEMETRY_SANITIZE_MAX_DEPTH) {
587
+ return "[depth_truncated]";
588
+ }
589
+ if (Array.isArray(value)) {
590
+ return value.slice(0, TELEMETRY_SANITIZE_MAX_ARRAY_ITEMS).map((entry) => normalizeForHash(entry, depth + 1));
591
+ }
592
+ if (typeof value === "object") {
593
+ const record = value;
594
+ const normalized = {};
595
+ const sortedKeys = Object.keys(record).sort((left, right) => left.localeCompare(right));
596
+ for (const key of sortedKeys) {
597
+ normalized[key] = normalizeForHash(record[key], depth + 1);
598
+ }
599
+ return normalized;
600
+ }
601
+ return String(value);
602
+ }
603
+ function hashTelemetryValue(installationId, value) {
604
+ return hashWithInstallationId(installationId, JSON.stringify(normalizeForHash(value)));
605
+ }
606
+ function hashCommandArgs(installationId, args) {
607
+ return {
608
+ hashes: args.map((arg) => hashWithInstallationId(installationId, arg)),
609
+ digest: hashWithInstallationId(installationId, args.join("\0"))
610
+ };
611
+ }
612
+ function hashTelemetryErrorFingerprint(installationId, command, errorCode2, errorMessage) {
613
+ const normalizedMessage = sanitizeString(errorMessage ?? "", "redacted");
614
+ const fingerprintSource = `${command}\0${errorCode2 ?? "unknown_error"}\0${normalizedMessage}`;
615
+ return hashWithInstallationId(installationId, fingerprintSource);
616
+ }
617
+ function telemetryDisabledByEnvironment() {
618
+ return PM_TELEMETRY_DISABLED_VALUES.has((process.env[PM_TELEMETRY_DISABLED_ENV] ?? "").trim().toLowerCase()) || PM_TELEMETRY_DISABLED_VALUES.has((process.env[PM_NO_TELEMETRY_ENV] ?? "").trim().toLowerCase());
619
+ }
620
+ function resolveOtelTracesEndpoint() {
621
+ if (PM_TELEMETRY_OTEL_DISABLED_VALUES.has((process.env[PM_TELEMETRY_OTEL_DISABLED_ENV] ?? "").trim().toLowerCase())) {
622
+ return null;
623
+ }
624
+ const directEndpoint = (process.env[OTEL_TRACES_ENDPOINT_ENV] ?? "").trim();
625
+ if (directEndpoint.length > 0) {
626
+ try {
627
+ return new URL(directEndpoint).toString();
628
+ } catch {
629
+ return null;
630
+ }
631
+ }
632
+ const baseEndpoint = (process.env[OTEL_BASE_ENDPOINT_ENV] ?? "").trim();
633
+ if (baseEndpoint.length === 0) {
634
+ return null;
635
+ }
636
+ try {
637
+ const url = new URL(baseEndpoint);
638
+ const normalizedPath = url.pathname.replace(/\/+$/, "");
639
+ if (!normalizedPath.endsWith("/v1/traces")) {
640
+ url.pathname = `${normalizedPath.length === 0 ? "" : normalizedPath}/v1/traces`;
641
+ }
642
+ return url.toString();
643
+ } catch {
644
+ return null;
645
+ }
646
+ }
647
+ function isoToUnixNano(iso) {
648
+ const parsedMs = Date.parse(iso);
649
+ const epochMs = Number.isNaN(parsedMs) ? Date.now() : parsedMs;
650
+ return `${BigInt(epochMs) * 1000000n}`;
651
+ }
652
+ function otlpStringAttribute(key, value) {
653
+ return {
654
+ key,
655
+ value: { stringValue: value }
656
+ };
657
+ }
658
+ function otlpBoolAttribute(key, value) {
659
+ return {
660
+ key,
661
+ value: { boolValue: value }
662
+ };
663
+ }
664
+ function otlpIntAttribute(key, value) {
665
+ return {
666
+ key,
667
+ value: { intValue: String(Math.max(0, Math.trunc(value))) }
668
+ };
669
+ }
670
+ async function exportLocalOtelSpan(activeCommand, outcome, finishedAtIso, durationMs) {
671
+ if (typeof activeCommand.otel_traces_endpoint !== "string" || activeCommand.otel_traces_endpoint.trim().length === 0 || typeof activeCommand.otel_trace_id !== "string" || activeCommand.otel_trace_id.length === 0 || typeof activeCommand.otel_span_id !== "string" || activeCommand.otel_span_id.length === 0) {
672
+ return;
673
+ }
674
+ const serviceNameCandidate = sanitizeString((process.env[OTEL_SERVICE_NAME_ENV] ?? "").trim());
675
+ const serviceName = serviceNameCandidate.length > 0 ? serviceNameCandidate : "pm-cli";
676
+ const normalizedExitCode = normalizeTelemetryExitCode(outcome.exit_code, outcome.ok);
677
+ const normalizedErrorCode = normalizeTelemetryErrorCode(outcome.error_code);
678
+ const normalizedErrorCategory = normalizeTelemetryErrorCategory({
679
+ ok: outcome.ok,
680
+ errorCode: normalizedErrorCode,
681
+ errorCategory: outcome.error_category
682
+ });
683
+ const attributes = [
684
+ otlpStringAttribute("pm.command", sanitizeString(activeCommand.command)),
685
+ otlpStringAttribute("pm.version", activeCommand.pm_version),
686
+ otlpStringAttribute("pm.source_context", activeCommand.source_context),
687
+ otlpStringAttribute("pm.source_context_source", activeCommand.source_context_source),
688
+ otlpStringAttribute("pm.installation_id", activeCommand.installation_id),
689
+ otlpStringAttribute("pm.session_id", PROCESS_SESSION_ID),
690
+ otlpStringAttribute("pm.pm_root_hash", activeCommand.pm_root_hash),
691
+ otlpStringAttribute("pm.cwd_hash", activeCommand.cwd_hash),
692
+ otlpBoolAttribute("pm.ok", outcome.ok),
693
+ otlpIntAttribute("pm.exit_code", normalizedExitCode),
694
+ otlpIntAttribute("pm.duration_ms", durationMs)
695
+ ];
696
+ if (typeof normalizedErrorCode === "string") {
697
+ attributes.push(otlpStringAttribute("pm.error_code", normalizedErrorCode));
698
+ }
699
+ if (typeof normalizedErrorCategory === "string") {
700
+ attributes.push(otlpStringAttribute("pm.error_category", normalizedErrorCategory));
701
+ }
702
+ if (typeof outcome.error === "string" && outcome.error.trim().length > 0) {
703
+ attributes.push(otlpStringAttribute("pm.error", sanitizeString(outcome.error)));
704
+ }
705
+ const payload = {
706
+ resourceSpans: [
707
+ {
708
+ resource: {
709
+ attributes: [otlpStringAttribute("service.name", serviceName)]
710
+ },
711
+ scopeSpans: [
712
+ {
713
+ scope: {
714
+ name: "pm-cli.telemetry",
715
+ version: "1"
716
+ },
717
+ spans: [
718
+ {
719
+ traceId: activeCommand.otel_trace_id,
720
+ spanId: activeCommand.otel_span_id,
721
+ name: `pm.command.${sanitizeString(activeCommand.command)}`,
722
+ kind: 1,
723
+ startTimeUnixNano: isoToUnixNano(activeCommand.started_at),
724
+ endTimeUnixNano: isoToUnixNano(finishedAtIso),
725
+ attributes,
726
+ status: {
727
+ code: outcome.ok ? 1 : 2,
728
+ message: outcome.ok ? "" : sanitizeString(outcome.error ?? "command_failed")
729
+ }
730
+ }
731
+ ]
732
+ }
733
+ ]
734
+ }
735
+ ]
736
+ };
737
+ const response = await fetch(activeCommand.otel_traces_endpoint, {
738
+ method: "POST",
739
+ headers: {
740
+ "content-type": "application/json"
741
+ },
742
+ body: JSON.stringify(payload),
743
+ signal: AbortSignal.timeout(TELEMETRY_HTTP_TIMEOUT_MS)
744
+ });
745
+ if (!response.ok) {
746
+ throw new Error(`local_otel_export_http_${response.status}`);
747
+ }
748
+ }
749
+ function summarizeResult(result, captureLevel = "redacted") {
750
+ if (result === null || result === void 0) {
751
+ return { type: "nullish" };
752
+ }
753
+ if (typeof result === "string") {
754
+ return { type: "string", value: sanitizeString(result, captureLevel) };
755
+ }
756
+ if (typeof result === "number" || typeof result === "boolean") {
757
+ return { type: typeof result, value: result };
758
+ }
759
+ if (Array.isArray(result)) {
760
+ return {
761
+ type: "array",
762
+ length: result.length,
763
+ sample: result.slice(0, 5).map((entry) => sanitizeValue(entry, void 0, captureLevel))
764
+ };
765
+ }
766
+ if (typeof result === "object") {
767
+ const record = result;
768
+ const keys = Object.keys(record).sort((left, right) => left.localeCompare(right));
769
+ const sanitized = {};
770
+ let previewBytes = 0;
771
+ for (const key of keys.slice(0, 25)) {
772
+ const sanitizedValue = sanitizeValue(record[key], key, captureLevel);
773
+ const entrySize = JSON.stringify(sanitizedValue)?.length ?? 0;
774
+ if (previewBytes + entrySize > TELEMETRY_RESULT_PREVIEW_MAX_BYTES) {
775
+ sanitized[key] = "[preview_truncated]";
776
+ break;
777
+ }
778
+ previewBytes += entrySize;
779
+ sanitized[key] = sanitizedValue;
780
+ }
781
+ return {
782
+ type: "object",
783
+ key_count: keys.length,
784
+ keys_preview: keys.slice(0, 50),
785
+ preview: sanitized
786
+ };
787
+ }
788
+ return { type: typeof result, value: String(result) };
789
+ }
790
+ function buildCommandStartPayload(params) {
791
+ const { captureLevel, context, pmVersion, sourceContext, pmRootHash, cwdHash, installationId } = params;
792
+ const commandTaxonomy = deriveTelemetryCommandTaxonomy(context.command);
793
+ const hashedArgs = hashCommandArgs(installationId, context.args);
794
+ const commandInvocationDigest = hashWithInstallationId(installationId, `${context.command}\0${context.args.join("\0")}`);
795
+ const commandOptionsDigest = hashTelemetryValue(installationId, context.options);
796
+ const globalOptionsDigest = hashTelemetryValue(installationId, context.global);
797
+ if (captureLevel === "minimal") {
798
+ return {
799
+ capture_level: captureLevel,
800
+ pm_version: pmVersion,
801
+ source_context: sourceContext.source_context,
802
+ source_context_source: sourceContext.source_context_source,
803
+ command_taxonomy: commandTaxonomy,
804
+ command_args_digest: hashedArgs.digest,
805
+ command_invocation_digest: commandInvocationDigest,
806
+ command_options_digest: commandOptionsDigest,
807
+ global_options_digest: globalOptionsDigest
808
+ };
809
+ }
810
+ return {
811
+ pm_version: pmVersion,
812
+ source_context: sourceContext.source_context,
813
+ source_context_source: sourceContext.source_context_source,
814
+ command_taxonomy: commandTaxonomy,
815
+ command_args: sanitizeCommandArgs(context.args, captureLevel),
816
+ command_args_hashes: hashedArgs.hashes,
817
+ command_args_digest: hashedArgs.digest,
818
+ command_invocation_digest: commandInvocationDigest,
819
+ command_options: sanitizeValue(context.options, void 0, captureLevel),
820
+ command_options_digest: commandOptionsDigest,
821
+ global_options: sanitizeValue(context.global, void 0, captureLevel),
822
+ global_options_digest: globalOptionsDigest,
823
+ pm_root_hash: pmRootHash,
824
+ cwd_hash: cwdHash,
825
+ capture_level: captureLevel,
826
+ runtime: {
827
+ node: process.version,
828
+ platform: process.platform,
829
+ arch: process.arch,
830
+ hostname_hash: hashWithInstallationId(installationId, os.hostname()),
831
+ stdin_tty: process.stdin.isTTY === true,
832
+ stdout_tty: process.stdout.isTTY === true
833
+ }
834
+ };
835
+ }
836
+ function buildCommandFinishPayload(params) {
837
+ const { captureLevel, pmVersion, sourceContext, outcome, durationMs, startedAt, command, installationId, commandTaxonomy, exitCode, errorCode: errorCode2, errorCategory, commandResolution, resolutionStage } = params;
838
+ const errorFingerprint = outcome.ok === false ? hashTelemetryErrorFingerprint(installationId, command, errorCode2, outcome.error) : void 0;
839
+ if (captureLevel === "minimal") {
840
+ return {
841
+ capture_level: captureLevel,
842
+ pm_version: pmVersion,
843
+ source_context: sourceContext.source_context,
844
+ source_context_source: sourceContext.source_context_source,
845
+ command_taxonomy: commandTaxonomy,
846
+ command_resolution: commandResolution,
847
+ resolution_stage: resolutionStage,
848
+ ok: outcome.ok,
849
+ exit_code: exitCode,
850
+ error_code: errorCode2,
851
+ error_category: errorCategory,
852
+ error: outcome.error ? sanitizeString(outcome.error, "redacted") : void 0,
853
+ error_fingerprint: errorFingerprint,
854
+ duration_ms: durationMs
855
+ };
856
+ }
857
+ return {
858
+ capture_level: captureLevel,
859
+ pm_version: pmVersion,
860
+ source_context: sourceContext.source_context,
861
+ source_context_source: sourceContext.source_context_source,
862
+ command_taxonomy: commandTaxonomy,
863
+ command_resolution: commandResolution,
864
+ resolution_stage: resolutionStage,
865
+ ok: outcome.ok,
866
+ exit_code: exitCode,
867
+ error_code: errorCode2,
868
+ error_category: errorCategory,
869
+ error: outcome.error ? sanitizeString(outcome.error, captureLevel) : void 0,
870
+ error_fingerprint: errorFingerprint,
871
+ duration_ms: durationMs,
872
+ started_at: startedAt,
873
+ result_summary: summarizeResult(outcome.result, captureLevel)
874
+ };
875
+ }
876
+ function buildCommandErrorPayload(params) {
877
+ const { captureLevel, pmVersion, sourceContext, command, commandTaxonomy, commandResolution, resolutionStage, args, options, pmRootHash, cwdHash, installationId, errorCode: errorCode2, errorMessage, errorCategory, exitCode } = params;
878
+ const attemptedArgHashes = hashCommandArgs(installationId, args);
879
+ const attemptedCommandDigest = hashWithInstallationId(installationId, command);
880
+ const attemptedOptionsDigest = hashTelemetryValue(installationId, options);
881
+ const errorFingerprint = hashTelemetryErrorFingerprint(installationId, command, errorCode2, errorMessage);
882
+ if (captureLevel === "minimal") {
883
+ return {
884
+ capture_level: captureLevel,
885
+ pm_version: pmVersion,
886
+ source_context: sourceContext.source_context,
887
+ source_context_source: sourceContext.source_context_source,
888
+ command_taxonomy: commandTaxonomy,
889
+ command_resolution: commandResolution,
890
+ resolution_stage: resolutionStage,
891
+ attempted_command_digest: attemptedCommandDigest,
892
+ attempted_args_digest: attemptedArgHashes.digest,
893
+ attempted_options_digest: attemptedOptionsDigest,
894
+ error_code: errorCode2,
895
+ error_category: errorCategory,
896
+ exit_code: exitCode,
897
+ error: sanitizeString(errorMessage, "redacted"),
898
+ error_fingerprint: errorFingerprint
899
+ };
900
+ }
901
+ return {
902
+ capture_level: captureLevel,
903
+ pm_version: pmVersion,
904
+ source_context: sourceContext.source_context,
905
+ source_context_source: sourceContext.source_context_source,
906
+ command_taxonomy: commandTaxonomy,
907
+ command_resolution: commandResolution,
908
+ resolution_stage: resolutionStage,
909
+ attempted_command: sanitizeString(command, captureLevel),
910
+ attempted_command_digest: attemptedCommandDigest,
911
+ attempted_args: sanitizeCommandArgs(args, captureLevel),
912
+ attempted_args_hashes: attemptedArgHashes.hashes,
913
+ attempted_args_digest: attemptedArgHashes.digest,
914
+ attempted_options: sanitizeValue(options, void 0, captureLevel),
915
+ attempted_options_digest: attemptedOptionsDigest,
916
+ error_code: errorCode2,
917
+ error_category: errorCategory,
918
+ exit_code: exitCode,
919
+ error: sanitizeString(errorMessage, captureLevel),
920
+ error_fingerprint: errorFingerprint,
921
+ pm_root_hash: pmRootHash,
922
+ cwd_hash: cwdHash,
923
+ runtime: {
924
+ node: process.version,
925
+ platform: process.platform,
926
+ arch: process.arch,
927
+ hostname_hash: hashWithInstallationId(installationId, os.hostname()),
928
+ stdin_tty: process.stdin.isTTY === true,
929
+ stdout_tty: process.stdout.isTTY === true
930
+ }
931
+ };
932
+ }
933
+ async function ensureInstallationId(globalPmRoot) {
934
+ const settings = await readSettings(globalPmRoot);
935
+ let changed = false;
936
+ if (settings.telemetry.installation_id.trim().length === 0) {
937
+ settings.telemetry.installation_id = crypto.randomUUID();
938
+ changed = true;
939
+ }
940
+ if (changed) {
941
+ await writeSettings(globalPmRoot, settings, "telemetry:install_id");
942
+ }
943
+ return {
944
+ installationId: settings.telemetry.installation_id,
945
+ endpoint: settings.telemetry.endpoint,
946
+ retentionDays: Math.max(1, Math.trunc(settings.telemetry.retention_days))
947
+ };
948
+ }
949
+ async function enqueueTelemetryEvent(globalPmRoot, event) {
950
+ const queued = {
951
+ client_schema_version: TELEMETRY_CLIENT_SCHEMA_VERSION,
952
+ event,
953
+ attempts: 0
954
+ };
955
+ let serialized = JSON.stringify(queued);
956
+ if (serialized.length > TELEMETRY_MAX_EVENT_BYTES) {
957
+ const trimmed = { ...event, payload: { ...event.payload, result_summary: { truncated: true, reason: "payload_size_exceeded", original_bytes: serialized.length } } };
958
+ const trimmedQueued = {
959
+ client_schema_version: TELEMETRY_CLIENT_SCHEMA_VERSION,
960
+ event: trimmed,
961
+ attempts: 0
962
+ };
963
+ serialized = JSON.stringify(trimmedQueued);
964
+ }
965
+ await withQueueMutation(async () => {
966
+ await appendLineAtomic(queuePath(globalPmRoot), serialized);
967
+ });
968
+ }
969
+ function parseQueueLines(raw) {
970
+ const entries = [];
971
+ for (const line of raw.split("\n")) {
972
+ const trimmed = line.trim();
973
+ if (trimmed.length === 0) {
974
+ continue;
975
+ }
976
+ try {
977
+ const parsed = JSON.parse(trimmed);
978
+ if (parsed && typeof parsed === "object" && parsed.event && typeof parsed.event === "object" && typeof parsed.attempts === "number" && (parsed.client_schema_version === void 0 || typeof parsed.client_schema_version === "number" && Number.isFinite(parsed.client_schema_version))) {
979
+ entries.push(parsed);
980
+ }
981
+ } catch {
982
+ }
983
+ }
984
+ return entries;
985
+ }
986
+ function nextRetryIso(attempts) {
987
+ const delay = Math.min(TELEMETRY_RETRY_BASE_DELAY_MS * 2 ** Math.max(attempts - 1, 0), TELEMETRY_MAX_RETRY_DELAY_MS);
988
+ return new Date(Date.now() + delay).toISOString();
989
+ }
990
+ function isDueForRetry(entry) {
991
+ if (typeof entry.next_attempt_after !== "string" || entry.next_attempt_after.trim().length === 0) {
992
+ return true;
993
+ }
994
+ const dueAtMs = Date.parse(entry.next_attempt_after);
995
+ if (Number.isNaN(dueAtMs)) {
996
+ return true;
997
+ }
998
+ return dueAtMs <= Date.now();
999
+ }
1000
+ function retentionCutoffMs(retentionDays) {
1001
+ const normalizedDays = Number.isFinite(retentionDays) ? Math.max(1, Math.trunc(retentionDays)) : 1;
1002
+ return Date.now() - normalizedDays * MILLISECONDS_PER_DAY;
1003
+ }
1004
+ function isExpiredQueueEntry(entry, cutoffMs) {
1005
+ const occurredAt = entry.event?.occurred_at;
1006
+ if (typeof occurredAt !== "string" || occurredAt.trim().length === 0) {
1007
+ return false;
1008
+ }
1009
+ const occurredAtMs = Date.parse(occurredAt);
1010
+ if (Number.isNaN(occurredAtMs)) {
1011
+ return false;
1012
+ }
1013
+ return occurredAtMs < cutoffMs;
1014
+ }
1015
+ function pruneExpiredQueueEntries(entries, retentionDays) {
1016
+ const cutoffMs = retentionCutoffMs(retentionDays);
1017
+ const retained = [];
1018
+ let prunedCount = 0;
1019
+ for (const entry of entries) {
1020
+ const serializedSize = JSON.stringify(entry).length;
1021
+ const oversized = serializedSize > TELEMETRY_MAX_EVENT_BYTES;
1022
+ if (oversized || isExpiredQueueEntry(entry, cutoffMs) || entry.attempts >= TELEMETRY_MAX_QUEUE_ENTRY_ATTEMPTS) {
1023
+ prunedCount += 1;
1024
+ continue;
1025
+ }
1026
+ retained.push(entry);
1027
+ }
1028
+ return { entries: retained, prunedCount };
1029
+ }
1030
+ async function rewriteQueue(globalPmRoot, entries) {
1031
+ const serialized = entries.map((entry) => JSON.stringify(entry)).join("\n");
1032
+ const contents = serialized.length > 0 ? `${serialized}
1033
+ ` : "";
1034
+ for (let attempt = 0; ; attempt += 1) {
1035
+ try {
1036
+ await writeFileAtomic(queuePath(globalPmRoot), contents);
1037
+ return;
1038
+ } catch (error) {
1039
+ const retryDelay = TELEMETRY_QUEUE_REWRITE_RETRY_DELAYS_MS[attempt];
1040
+ if (retryDelay === void 0 || !isRetryableQueueRewriteError(error)) {
1041
+ throw error;
1042
+ }
1043
+ await sleep(retryDelay);
1044
+ }
1045
+ }
1046
+ }
1047
+ function isRetryableQueueRewriteError(error) {
1048
+ if (typeof error !== "object" || error === null || !("code" in error)) {
1049
+ return false;
1050
+ }
1051
+ const code = error.code;
1052
+ return code === "EACCES" || code === "EBUSY" || code === "EPERM";
1053
+ }
1054
+ function sleep(milliseconds) {
1055
+ return new Promise((resolve) => {
1056
+ setTimeout(resolve, milliseconds);
1057
+ });
1058
+ }
1059
+ async function cleanupTelemetryQueueTempOrphans(globalPmRoot, maxAgeMs = TELEMETRY_QUEUE_TMP_ORPHAN_MAX_AGE_MS) {
1060
+ try {
1061
+ const dirPath = telemetryRuntimeDirectory(globalPmRoot);
1062
+ const entries = await readdir(dirPath, { withFileTypes: true });
1063
+ const cutoffMs = Date.now() - Math.max(0, maxAgeMs);
1064
+ await Promise.all(entries.filter((entry) => entry.isFile() && /^\.events\.jsonl\.\d+\.\d+\.[a-f0-9]+\.tmp$/.test(entry.name)).map(async (entry) => {
1065
+ const candidate = path.join(dirPath, entry.name);
1066
+ const candidateStats = await stat(candidate);
1067
+ if (candidateStats.mtimeMs < cutoffMs) {
1068
+ await rm(candidate, { force: true });
1069
+ }
1070
+ }));
1071
+ } catch {
1072
+ }
1073
+ }
1074
+ async function withQueueMutation(operation) {
1075
+ const run = _queueMutationPromise.catch(() => {
1076
+ }).then(operation);
1077
+ _queueMutationPromise = run.catch(() => {
1078
+ });
1079
+ return run;
1080
+ }
1081
+ async function readCurrentQueueEntries(globalPmRoot) {
1082
+ const raw = await readFileIfExists(queuePath(globalPmRoot));
1083
+ if (raw === null || raw.trim().length === 0) {
1084
+ return [];
1085
+ }
1086
+ return parseQueueLines(raw);
1087
+ }
1088
+ async function removeFlushedEntriesFromCurrentQueue(globalPmRoot, flushedIds, retentionDays) {
1089
+ return withQueueMutation(async () => {
1090
+ const currentEntries = await readCurrentQueueEntries(globalPmRoot);
1091
+ const { entries: retainedEntries } = pruneExpiredQueueEntries(currentEntries, retentionDays);
1092
+ const remaining = retainedEntries.filter((entry) => !flushedIds.has(entry.event.event_id));
1093
+ await rewriteQueue(globalPmRoot, remaining);
1094
+ return remaining;
1095
+ });
1096
+ }
1097
+ async function markFailedEntriesInCurrentQueue(globalPmRoot, failedIds, attemptTime, retentionDays) {
1098
+ return withQueueMutation(async () => {
1099
+ const currentEntries = await readCurrentQueueEntries(globalPmRoot);
1100
+ const { entries: retainedEntries } = pruneExpiredQueueEntries(currentEntries, retentionDays);
1101
+ const retried = retainedEntries.map((entry) => {
1102
+ if (!failedIds.has(entry.event.event_id)) {
1103
+ return entry;
1104
+ }
1105
+ const attempts = entry.attempts + 1;
1106
+ return {
1107
+ ...entry,
1108
+ attempts,
1109
+ last_attempt_at: attemptTime,
1110
+ next_attempt_after: nextRetryIso(attempts)
1111
+ };
1112
+ });
1113
+ await rewriteQueue(globalPmRoot, retried);
1114
+ return retried;
1115
+ });
1116
+ }
1117
+ async function flushQueue(globalPmRoot, endpoint, retentionDays) {
1118
+ await cleanupTelemetryQueueTempOrphans(globalPmRoot);
1119
+ const normalizedEndpoint = endpoint.trim();
1120
+ if (normalizedEndpoint.length === 0) {
1121
+ return;
1122
+ }
1123
+ const raw = await readFileIfExists(queuePath(globalPmRoot));
1124
+ if (raw === null || raw.trim().length === 0) {
1125
+ await writeRuntimeState(globalPmRoot, {
1126
+ endpoint: normalizedEndpoint,
1127
+ queue_entries: 0
1128
+ });
1129
+ return;
1130
+ }
1131
+ const queueEntries = parseQueueLines(raw);
1132
+ if (queueEntries.length === 0) {
1133
+ await writeRuntimeState(globalPmRoot, {
1134
+ endpoint: normalizedEndpoint,
1135
+ queue_entries: 0
1136
+ });
1137
+ return;
1138
+ }
1139
+ const { entries: retainedEntries, prunedCount } = pruneExpiredQueueEntries(queueEntries, retentionDays);
1140
+ if (retainedEntries.length === 0) {
1141
+ if (prunedCount > 0) {
1142
+ await rewriteQueue(globalPmRoot, []);
1143
+ }
1144
+ await writeRuntimeState(globalPmRoot, {
1145
+ endpoint: normalizedEndpoint,
1146
+ queue_entries: 0
1147
+ });
1148
+ return;
1149
+ }
1150
+ const dueEntries = retainedEntries.filter((entry) => isDueForRetry(entry)).slice(0, TELEMETRY_FLUSH_BATCH_SIZE);
1151
+ if (dueEntries.length === 0) {
1152
+ if (prunedCount > 0) {
1153
+ await rewriteQueue(globalPmRoot, retainedEntries);
1154
+ }
1155
+ await writeRuntimeState(globalPmRoot, {
1156
+ endpoint: normalizedEndpoint,
1157
+ queue_entries: retainedEntries.length
1158
+ });
1159
+ return;
1160
+ }
1161
+ const dueIds = new Set(dueEntries.map((entry) => entry.event.event_id));
1162
+ const attemptTime = nowIso();
1163
+ const requestHeaders = {
1164
+ "content-type": "application/json"
1165
+ };
1166
+ const ingestKey = process.env.PM_TELEMETRY_INGEST_KEY?.trim();
1167
+ if (ingestKey) {
1168
+ requestHeaders["x-pm-telemetry-key"] = ingestKey;
1169
+ }
1170
+ try {
1171
+ const response = await fetch(normalizedEndpoint, {
1172
+ method: "POST",
1173
+ headers: requestHeaders,
1174
+ body: JSON.stringify({
1175
+ schema_version: TELEMETRY_SCHEMA_VERSION,
1176
+ events: dueEntries.map((entry) => entry.event)
1177
+ }),
1178
+ signal: AbortSignal.timeout(TELEMETRY_HTTP_TIMEOUT_MS)
1179
+ });
1180
+ if (!response.ok) {
1181
+ throw new Error(`telemetry_flush_http_${response.status}`);
1182
+ }
1183
+ } catch (error) {
1184
+ const retried = await markFailedEntriesInCurrentQueue(globalPmRoot, dueIds, attemptTime, retentionDays);
1185
+ const errorMessage = (() => {
1186
+ if (error instanceof Error) {
1187
+ return sanitizeString(error.message, "redacted");
1188
+ }
1189
+ return "telemetry_flush_failed";
1190
+ })();
1191
+ await writeRuntimeState(globalPmRoot, {
1192
+ endpoint: normalizedEndpoint,
1193
+ queue_entries: retried.length,
1194
+ last_attempted_flush_at: attemptTime,
1195
+ last_failed_flush_at: attemptTime,
1196
+ last_failed_flush_error: errorMessage
1197
+ });
1198
+ return;
1199
+ }
1200
+ try {
1201
+ const remaining = await removeFlushedEntriesFromCurrentQueue(globalPmRoot, dueIds, retentionDays);
1202
+ await writeRuntimeState(globalPmRoot, {
1203
+ endpoint: normalizedEndpoint,
1204
+ queue_entries: remaining.length,
1205
+ last_attempted_flush_at: attemptTime,
1206
+ last_successful_flush_at: attemptTime,
1207
+ last_failed_flush_at: void 0,
1208
+ last_failed_flush_error: void 0
1209
+ });
1210
+ } catch (error) {
1211
+ const errorMessage = (() => {
1212
+ if (error instanceof Error) {
1213
+ return sanitizeString(error.message, "redacted");
1214
+ }
1215
+ return "telemetry_flush_failed";
1216
+ })();
1217
+ const currentEntries = await readCurrentQueueEntries(globalPmRoot).catch(() => retainedEntries);
1218
+ await writeRuntimeState(globalPmRoot, {
1219
+ endpoint: normalizedEndpoint,
1220
+ queue_entries: currentEntries.length,
1221
+ last_attempted_flush_at: attemptTime,
1222
+ last_failed_flush_at: attemptTime,
1223
+ last_failed_flush_error: errorMessage
1224
+ });
1225
+ }
1226
+ }
1227
+ async function acquireTelemetryFlushLock(globalPmRoot) {
1228
+ const lockPath = flushLockPath(globalPmRoot);
1229
+ await mkdir(path.dirname(lockPath), { recursive: true });
1230
+ try {
1231
+ await mkdir(lockPath);
1232
+ return true;
1233
+ } catch (error) {
1234
+ if (typeof error !== "object" || error === null || !("code" in error) || error.code !== "EEXIST") {
1235
+ throw error;
1236
+ }
1237
+ }
1238
+ try {
1239
+ const lockStats = await stat(lockPath);
1240
+ if (Date.now() - lockStats.mtimeMs < TELEMETRY_FLUSH_LOCK_STALE_MS) {
1241
+ return false;
1242
+ }
1243
+ await rm(lockPath, { recursive: true, force: true });
1244
+ await mkdir(lockPath);
1245
+ return true;
1246
+ } catch {
1247
+ return false;
1248
+ }
1249
+ }
1250
+ function isFreshDirectoryLock(lockPath, staleMs) {
1251
+ try {
1252
+ return Date.now() - statSync(lockPath).mtimeMs < staleMs;
1253
+ } catch {
1254
+ return false;
1255
+ }
1256
+ }
1257
+ function removeDirectoryLockBestEffort(lockPath) {
1258
+ try {
1259
+ rmSync(lockPath, { recursive: true, force: true });
1260
+ } catch {
1261
+ }
1262
+ }
1263
+ function errorCode(error) {
1264
+ if (typeof error !== "object" || error === null || !("code" in error)) {
1265
+ return void 0;
1266
+ }
1267
+ const code = error.code;
1268
+ return typeof code === "string" ? code : void 0;
1269
+ }
1270
+ function createDirectoryLock(lockPath) {
1271
+ try {
1272
+ mkdirSync(lockPath);
1273
+ return true;
1274
+ } catch (error) {
1275
+ const code = errorCode(error);
1276
+ if (code === "EEXIST") {
1277
+ return false;
1278
+ }
1279
+ if (code !== "ENOENT") {
1280
+ return false;
1281
+ }
1282
+ }
1283
+ try {
1284
+ mkdirSync(path.dirname(lockPath), { recursive: true });
1285
+ mkdirSync(lockPath);
1286
+ return true;
1287
+ } catch {
1288
+ return false;
1289
+ }
1290
+ }
1291
+ function acquireTelemetryFlushSpawnGate(globalPmRoot) {
1292
+ if (isFreshDirectoryLock(flushLockPath(globalPmRoot), TELEMETRY_FLUSH_LOCK_STALE_MS)) {
1293
+ return false;
1294
+ }
1295
+ const lockPath = flushSpawnLockPath(globalPmRoot);
1296
+ try {
1297
+ if (Date.now() - statSync(lockPath).mtimeMs < TELEMETRY_FLUSH_SPAWN_LOCK_STALE_MS) {
1298
+ return false;
1299
+ }
1300
+ removeDirectoryLockBestEffort(lockPath);
1301
+ } catch (error) {
1302
+ if (errorCode(error) !== "ENOENT") {
1303
+ return false;
1304
+ }
1305
+ }
1306
+ return createDirectoryLock(lockPath);
1307
+ }
1308
+ function releaseTelemetryFlushSpawnGate(globalPmRoot) {
1309
+ removeDirectoryLockBestEffort(flushSpawnLockPath(globalPmRoot));
1310
+ }
1311
+ async function flushQueueWithProcessLock(globalPmRoot, endpoint, retentionDays) {
1312
+ const acquired = await acquireTelemetryFlushLock(globalPmRoot);
1313
+ releaseTelemetryFlushSpawnGate(globalPmRoot);
1314
+ if (!acquired) {
1315
+ return;
1316
+ }
1317
+ try {
1318
+ await flushQueue(globalPmRoot, endpoint, retentionDays);
1319
+ } finally {
1320
+ await rm(flushLockPath(globalPmRoot), { recursive: true, force: true }).catch(() => {
1321
+ });
1322
+ }
1323
+ }
1324
+ function scheduleTelemetryFlush(globalPmRoot, endpoint, retentionDays) {
1325
+ if (shouldFlushInline()) {
1326
+ const previousFlush = _lastFlushPromise;
1327
+ const nextFlush = flushQueue(globalPmRoot, endpoint, retentionDays).catch(() => {
1328
+ });
1329
+ _lastFlushPromise = Promise.allSettled([previousFlush, nextFlush]).then(() => {
1330
+ });
1331
+ return;
1332
+ }
1333
+ try {
1334
+ const acquiredSpawnGate = acquireTelemetryFlushSpawnGate(globalPmRoot);
1335
+ if (!acquiredSpawnGate) {
1336
+ return;
1337
+ }
1338
+ const child = spawn(process.execPath, [telemetryFlushRunnerPath()], {
1339
+ detached: true,
1340
+ stdio: "ignore",
1341
+ env: {
1342
+ ...process.env,
1343
+ PM_GLOBAL_PATH: globalPmRoot,
1344
+ [PM_TELEMETRY_FLUSH_CHILD_ENV]: "1"
1345
+ }
1346
+ });
1347
+ child.unref();
1348
+ } catch {
1349
+ releaseTelemetryFlushSpawnGate(globalPmRoot);
1350
+ }
1351
+ }
1352
+ async function flushTelemetryQueueNow(globalPmRoot = resolveGlobalPmRoot(process.cwd())) {
1353
+ if (telemetryDisabledByEnvironment()) {
1354
+ return;
1355
+ }
1356
+ try {
1357
+ const settings = await readSettings(globalPmRoot);
1358
+ if (!settings.telemetry.enabled) {
1359
+ return;
1360
+ }
1361
+ const { endpoint, retentionDays } = await ensureInstallationId(globalPmRoot);
1362
+ await flushQueueWithProcessLock(globalPmRoot, endpoint, retentionDays);
1363
+ } catch {
1364
+ }
1365
+ }
1366
+ async function startTelemetryCommand(context) {
1367
+ if (telemetryDisabledByEnvironment()) {
1368
+ return null;
1369
+ }
1370
+ if (context.command === "telemetry" && context.args.some((token) => token.trim().toLowerCase() === "clear")) {
1371
+ return null;
1372
+ }
1373
+ try {
1374
+ const globalPmRoot = resolveGlobalPmRoot(process.cwd());
1375
+ const settings = await readSettings(globalPmRoot);
1376
+ if (!settings.telemetry.enabled) {
1377
+ return null;
1378
+ }
1379
+ const captureLevel = normalizeCaptureLevel(settings.telemetry.capture_level);
1380
+ const { installationId, endpoint, retentionDays } = await ensureInstallationId(globalPmRoot);
1381
+ const pmVersion = normalizePmVersion(context.pm_version);
1382
+ const sourceContext = resolveTelemetrySourceContext(context.global);
1383
+ const pmRootHash = hashWithInstallationId(installationId, context.pm_root);
1384
+ const cwdHash = hashWithInstallationId(installationId, process.cwd());
1385
+ const otelTracesEndpoint = resolveOtelTracesEndpoint();
1386
+ const occurredAt = nowIso();
1387
+ const event = {
1388
+ schema_version: TELEMETRY_SCHEMA_VERSION,
1389
+ event_id: crypto.randomUUID(),
1390
+ event_type: "command_start",
1391
+ occurred_at: occurredAt,
1392
+ installation_id: installationId,
1393
+ session_id: PROCESS_SESSION_ID,
1394
+ command: context.command,
1395
+ payload: buildCommandStartPayload({
1396
+ captureLevel,
1397
+ context,
1398
+ pmVersion,
1399
+ sourceContext,
1400
+ pmRootHash,
1401
+ cwdHash,
1402
+ installationId
1403
+ })
1404
+ };
1405
+ await enqueueTelemetryEvent(globalPmRoot, event);
1406
+ scheduleTelemetryFlush(globalPmRoot, endpoint, retentionDays);
1407
+ const commandTaxonomy = deriveTelemetryCommandTaxonomy(context.command);
1408
+ return {
1409
+ started_at: occurredAt,
1410
+ started_at_ms: Date.now(),
1411
+ command: context.command,
1412
+ command_taxonomy: commandTaxonomy,
1413
+ pm_version: pmVersion,
1414
+ source_context: sourceContext.source_context,
1415
+ source_context_source: sourceContext.source_context_source,
1416
+ installation_id: installationId,
1417
+ pm_root_hash: pmRootHash,
1418
+ cwd_hash: cwdHash,
1419
+ endpoint,
1420
+ retention_days: retentionDays,
1421
+ global_pm_root: globalPmRoot,
1422
+ capture_level: captureLevel,
1423
+ otel_traces_endpoint: otelTracesEndpoint ?? void 0,
1424
+ otel_trace_id: otelTracesEndpoint ? crypto.randomBytes(16).toString("hex") : void 0,
1425
+ otel_span_id: otelTracesEndpoint ? crypto.randomBytes(8).toString("hex") : void 0
1426
+ };
1427
+ } catch {
1428
+ return null;
1429
+ }
1430
+ }
1431
+ async function finishTelemetryCommand(activeCommand, outcome) {
1432
+ if (!activeCommand) {
1433
+ return;
1434
+ }
1435
+ try {
1436
+ const finishedAt = nowIso();
1437
+ const durationMs = Math.max(0, Date.now() - activeCommand.started_at_ms);
1438
+ const normalizedErrorCode = normalizeTelemetryErrorCode(inferTelemetryErrorCode({
1439
+ ok: outcome.ok,
1440
+ errorCode: outcome.error_code,
1441
+ errorMessage: outcome.error,
1442
+ exitCode: outcome.exit_code
1443
+ }));
1444
+ const normalizedErrorCategory = normalizeTelemetryErrorCategory({
1445
+ ok: outcome.ok,
1446
+ errorCode: normalizedErrorCode,
1447
+ errorCategory: outcome.error_category
1448
+ });
1449
+ const normalizedExitCode = normalizeTelemetryExitCode(outcome.exit_code, outcome.ok);
1450
+ const commandResolution = outcome.command_resolution ?? deriveTelemetryCommandResolution({
1451
+ ok: outcome.ok,
1452
+ errorCode: normalizedErrorCode,
1453
+ errorCategory: normalizedErrorCategory
1454
+ });
1455
+ const resolutionStage = outcome.resolution_stage ?? "execute";
1456
+ const event = {
1457
+ schema_version: TELEMETRY_SCHEMA_VERSION,
1458
+ event_id: crypto.randomUUID(),
1459
+ event_type: "command_finish",
1460
+ occurred_at: finishedAt,
1461
+ installation_id: activeCommand.installation_id,
1462
+ session_id: PROCESS_SESSION_ID,
1463
+ command: activeCommand.command,
1464
+ payload: buildCommandFinishPayload({
1465
+ captureLevel: activeCommand.capture_level,
1466
+ pmVersion: activeCommand.pm_version,
1467
+ sourceContext: {
1468
+ source_context: activeCommand.source_context,
1469
+ source_context_source: activeCommand.source_context_source
1470
+ },
1471
+ outcome,
1472
+ durationMs,
1473
+ startedAt: activeCommand.started_at,
1474
+ command: activeCommand.command,
1475
+ installationId: activeCommand.installation_id,
1476
+ commandTaxonomy: activeCommand.command_taxonomy,
1477
+ exitCode: normalizedExitCode,
1478
+ errorCode: normalizedErrorCode,
1479
+ errorCategory: normalizedErrorCategory,
1480
+ commandResolution,
1481
+ resolutionStage
1482
+ })
1483
+ };
1484
+ await enqueueTelemetryEvent(activeCommand.global_pm_root, event);
1485
+ scheduleTelemetryFlush(activeCommand.global_pm_root, activeCommand.endpoint, activeCommand.retention_days);
1486
+ void exportLocalOtelSpan(activeCommand, {
1487
+ ...outcome,
1488
+ exit_code: normalizedExitCode,
1489
+ error_code: normalizedErrorCode,
1490
+ error_category: normalizedErrorCategory
1491
+ }, finishedAt, durationMs).catch(() => {
1492
+ });
1493
+ } catch {
1494
+ }
1495
+ }
1496
+ async function emitTelemetryErrorEvent(context) {
1497
+ if (telemetryDisabledByEnvironment()) {
1498
+ return;
1499
+ }
1500
+ try {
1501
+ const globalPmRoot = resolveGlobalPmRoot(process.cwd());
1502
+ const settings = await readSettings(globalPmRoot);
1503
+ if (!settings.telemetry.enabled) {
1504
+ return;
1505
+ }
1506
+ const captureLevel = normalizeCaptureLevel(settings.telemetry.capture_level);
1507
+ const { installationId, endpoint, retentionDays } = await ensureInstallationId(globalPmRoot);
1508
+ const pmVersion = normalizePmVersion(context.pm_version);
1509
+ const sourceContext = resolveTelemetrySourceContext(context.global);
1510
+ const pmRootHash = hashWithInstallationId(installationId, context.pm_root);
1511
+ const cwdHash = hashWithInstallationId(installationId, process.cwd());
1512
+ const occurredAt = nowIso();
1513
+ const normalizedErrorCode = normalizeTelemetryErrorCode(inferTelemetryErrorCode({
1514
+ ok: false,
1515
+ errorCode: context.error_code,
1516
+ errorMessage: context.error_message,
1517
+ exitCode: context.exit_code
1518
+ })) ?? "unknown_error";
1519
+ const normalizedErrorCategory = context.error_category ?? resolveTelemetryErrorCategory(normalizedErrorCode);
1520
+ const normalizedExitCode = normalizeTelemetryExitCode(context.exit_code, false);
1521
+ const normalizedCommand = context.command.trim().length > 0 ? context.command : "<unknown>";
1522
+ const commandTaxonomy = deriveTelemetryCommandTaxonomy(normalizedCommand);
1523
+ const commandResolution = context.command_resolution ?? deriveTelemetryCommandResolution({
1524
+ ok: false,
1525
+ errorCode: normalizedErrorCode,
1526
+ errorCategory: normalizedErrorCategory
1527
+ });
1528
+ const resolutionStage = context.resolution_stage ?? "unknown";
1529
+ const event = {
1530
+ schema_version: TELEMETRY_SCHEMA_VERSION,
1531
+ event_id: crypto.randomUUID(),
1532
+ event_type: "command_error",
1533
+ occurred_at: occurredAt,
1534
+ installation_id: installationId,
1535
+ session_id: PROCESS_SESSION_ID,
1536
+ command: sanitizeString(normalizedCommand, "redacted"),
1537
+ payload: buildCommandErrorPayload({
1538
+ captureLevel,
1539
+ pmVersion,
1540
+ sourceContext,
1541
+ command: normalizedCommand,
1542
+ commandTaxonomy,
1543
+ commandResolution,
1544
+ resolutionStage,
1545
+ args: context.args,
1546
+ options: context.options,
1547
+ pmRootHash,
1548
+ cwdHash,
1549
+ installationId,
1550
+ errorCode: normalizedErrorCode,
1551
+ errorCategory: normalizedErrorCategory,
1552
+ exitCode: normalizedExitCode,
1553
+ errorMessage: context.error_message
1554
+ })
1555
+ };
1556
+ await enqueueTelemetryEvent(globalPmRoot, event);
1557
+ scheduleTelemetryFlush(globalPmRoot, endpoint, retentionDays);
1558
+ } catch {
1559
+ }
1560
+ }
1561
+
1562
+ export {
1563
+ deriveTelemetryCommandTaxonomy,
1564
+ deriveTelemetryCommandResolution,
1565
+ flushTelemetryQueueNow,
1566
+ startTelemetryCommand,
1567
+ finishTelemetryCommand,
1568
+ emitTelemetryErrorEvent
1569
+ };
1570
+ //# sourceMappingURL=chunk-QQL5QSTZ.js.map
1571
+
1572
+ //# debugId=87b64271-e0df-5c0d-991b-f7d1a6401710