@unbrained/pm-cli 2026.6.23 → 2026.6.30

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 (716) hide show
  1. package/CHANGELOG.md +120 -0
  2. package/CONTRIBUTING.md +30 -0
  3. package/README.md +16 -3
  4. package/dist/cli/commander-usage.js +3 -3
  5. package/dist/cli/commander-usage.js.map +1 -1
  6. package/dist/cli/commands/aggregate.js +8 -7
  7. package/dist/cli/commands/aggregate.js.map +1 -1
  8. package/dist/cli/commands/close.d.ts +2 -4
  9. package/dist/cli/commands/close.js +5 -17
  10. package/dist/cli/commands/close.js.map +1 -1
  11. package/dist/cli/commands/completion.js +158 -9
  12. package/dist/cli/commands/completion.js.map +1 -1
  13. package/dist/cli/commands/config.d.ts +1 -1
  14. package/dist/cli/commands/config.js +2 -2
  15. package/dist/cli/commands/config.js.map +1 -1
  16. package/dist/cli/commands/context.d.ts +31 -4
  17. package/dist/cli/commands/context.js +33 -10
  18. package/dist/cli/commands/context.js.map +1 -1
  19. package/dist/cli/commands/contracts.js +48 -8
  20. package/dist/cli/commands/contracts.js.map +1 -1
  21. package/dist/cli/commands/create.d.ts +1 -6
  22. package/dist/cli/commands/create.js +10 -155
  23. package/dist/cli/commands/create.js.map +1 -1
  24. package/dist/cli/commands/extension/describe.d.ts +15 -0
  25. package/dist/cli/commands/extension/describe.js +48 -2
  26. package/dist/cli/commands/extension/describe.js.map +1 -1
  27. package/dist/cli/commands/extension/doctor.js +5 -2
  28. package/dist/cli/commands/extension/doctor.js.map +1 -1
  29. package/dist/cli/commands/extension/install-sources.js +37 -7
  30. package/dist/cli/commands/extension/install-sources.js.map +1 -1
  31. package/dist/cli/commands/extension/scaffold.d.ts +31 -8
  32. package/dist/cli/commands/extension/scaffold.js +1956 -182
  33. package/dist/cli/commands/extension/scaffold.js.map +1 -1
  34. package/dist/cli/commands/extension.d.ts +22 -2
  35. package/dist/cli/commands/extension.js +189 -13
  36. package/dist/cli/commands/extension.js.map +1 -1
  37. package/dist/cli/commands/index.d.ts +3 -1
  38. package/dist/cli/commands/index.js +5 -3
  39. package/dist/cli/commands/index.js.map +1 -1
  40. package/dist/cli/commands/item-filter-options.d.ts +63 -0
  41. package/dist/cli/commands/item-filter-options.js +10 -0
  42. package/dist/cli/commands/item-filter-options.js.map +1 -0
  43. package/dist/cli/commands/legacy-none-tokens.d.ts +14 -0
  44. package/dist/cli/commands/legacy-none-tokens.js +31 -2
  45. package/dist/cli/commands/legacy-none-tokens.js.map +1 -1
  46. package/dist/cli/commands/linked-artifacts.d.ts +7 -0
  47. package/dist/cli/commands/linked-artifacts.js +12 -2
  48. package/dist/cli/commands/linked-artifacts.js.map +1 -1
  49. package/dist/cli/commands/list.d.ts +16 -39
  50. package/dist/cli/commands/list.js +127 -118
  51. package/dist/cli/commands/list.js.map +1 -1
  52. package/dist/cli/commands/next.d.ts +98 -0
  53. package/dist/cli/commands/next.js +304 -0
  54. package/dist/cli/commands/next.js.map +1 -0
  55. package/dist/cli/commands/profile.d.ts +208 -0
  56. package/dist/cli/commands/profile.js +418 -0
  57. package/dist/cli/commands/profile.js.map +1 -0
  58. package/dist/cli/commands/repeatable-metadata-parsers.js +12 -13
  59. package/dist/cli/commands/repeatable-metadata-parsers.js.map +1 -1
  60. package/dist/cli/commands/schema.d.ts +7 -0
  61. package/dist/cli/commands/schema.js +9 -3
  62. package/dist/cli/commands/schema.js.map +1 -1
  63. package/dist/cli/commands/search.d.ts +2 -39
  64. package/dist/cli/commands/search.js +104 -106
  65. package/dist/cli/commands/search.js.map +1 -1
  66. package/dist/cli/commands/shared-unset-fields.d.ts +30 -0
  67. package/dist/cli/commands/shared-unset-fields.js +161 -0
  68. package/dist/cli/commands/shared-unset-fields.js.map +1 -0
  69. package/dist/cli/commands/stats.js +15 -3
  70. package/dist/cli/commands/stats.js.map +1 -1
  71. package/dist/cli/commands/test.js +9 -5
  72. package/dist/cli/commands/test.js.map +1 -1
  73. package/dist/cli/commands/update.d.ts +1 -6
  74. package/dist/cli/commands/update.js +12 -157
  75. package/dist/cli/commands/update.js.map +1 -1
  76. package/dist/cli/commands/validate.js +20 -5
  77. package/dist/cli/commands/validate.js.map +1 -1
  78. package/dist/cli/help-content.js +26 -2
  79. package/dist/cli/help-content.js.map +1 -1
  80. package/dist/cli/help-json-payload.js +3 -3
  81. package/dist/cli/help-json-payload.js.map +1 -1
  82. package/dist/cli/main.js +27 -12
  83. package/dist/cli/main.js.map +1 -1
  84. package/dist/cli/register-list-query.js +42 -3
  85. package/dist/cli/register-list-query.js.map +1 -1
  86. package/dist/cli/register-mutation.js +86 -2
  87. package/dist/cli/register-mutation.js.map +1 -1
  88. package/dist/cli/register-setup.js +67 -6
  89. package/dist/cli/register-setup.js.map +1 -1
  90. package/dist/cli/registration-helpers.d.ts +9 -1
  91. package/dist/cli/registration-helpers.js +34 -3
  92. package/dist/cli/registration-helpers.js.map +1 -1
  93. package/dist/cli-bundle/chunks/activity-EJBMXUBH.js +16 -0
  94. package/dist/cli-bundle/chunks/{activity-H2LMOSSW.js → activity-MVSEND6D.js} +9 -11
  95. package/dist/cli-bundle/chunks/{aggregate-R725FC3S.js → aggregate-MOC4TR2G.js} +16 -17
  96. package/dist/cli-bundle/chunks/aggregate-MOC4TR2G.js.map +1 -0
  97. package/dist/cli-bundle/chunks/{aggregate-EGJLZQBI.js → aggregate-XJHLZQ5X.js} +15 -16
  98. package/dist/cli-bundle/chunks/aggregate-XJHLZQ5X.js.map +7 -0
  99. package/dist/cli-bundle/chunks/{append-5J345QGU.js → append-KDHT4GHI.js} +10 -12
  100. package/dist/cli-bundle/chunks/{append-5J345QGU.js.map → append-KDHT4GHI.js.map} +1 -1
  101. package/dist/cli-bundle/chunks/{append-O5HPBMRN.js → append-LEDBAM3K.js} +8 -10
  102. package/dist/cli-bundle/chunks/{append-O5HPBMRN.js.map → append-LEDBAM3K.js.map} +1 -1
  103. package/dist/cli-bundle/chunks/{chunk-IB3GYLQE.js → chunk-3JWQCLR5.js} +3 -3
  104. package/dist/cli-bundle/chunks/{chunk-2A34E3BA.js → chunk-4TXTVZL3.js} +2 -2
  105. package/dist/cli-bundle/chunks/{chunk-G6N5VEOK.js → chunk-4YIMPANT.js} +3 -3
  106. package/dist/cli-bundle/chunks/{chunk-7AUB5HNA.js → chunk-53ARXF2O.js} +9 -11
  107. package/dist/cli-bundle/chunks/{chunk-7AUB5HNA.js.map → chunk-53ARXF2O.js.map} +1 -1
  108. package/dist/cli-bundle/chunks/chunk-5ABGFWR4.js +116 -0
  109. package/dist/cli-bundle/chunks/chunk-5ABGFWR4.js.map +1 -0
  110. package/dist/cli-bundle/chunks/{chunk-2BFPAUAF.js → chunk-5IRVSKPS.js} +2990 -2890
  111. package/dist/cli-bundle/chunks/chunk-5IRVSKPS.js.map +1 -0
  112. package/dist/cli-bundle/chunks/{chunk-JR2LV3M4.js → chunk-5T6WPLRO.js} +233 -190
  113. package/dist/cli-bundle/chunks/chunk-5T6WPLRO.js.map +7 -0
  114. package/dist/cli-bundle/chunks/{chunk-CKGNPJAG.js → chunk-6T5ZIWBS.js} +3011 -2888
  115. package/dist/cli-bundle/chunks/chunk-6T5ZIWBS.js.map +7 -0
  116. package/dist/cli-bundle/chunks/{chunk-QH3PJYON.js → chunk-6YRAMXRS.js} +111 -114
  117. package/dist/cli-bundle/chunks/chunk-6YRAMXRS.js.map +1 -0
  118. package/dist/cli-bundle/chunks/{chunk-7XGQXHFB.js → chunk-73PTKMAE.js} +3 -3
  119. package/dist/cli-bundle/chunks/{chunk-Y4SUQQYH.js → chunk-74PUWBGN.js} +53 -54
  120. package/dist/cli-bundle/chunks/chunk-74PUWBGN.js.map +1 -0
  121. package/dist/cli-bundle/chunks/{chunk-T5472OMV.js → chunk-7L6TXOOC.js} +4 -6
  122. package/dist/cli-bundle/chunks/{chunk-T5472OMV.js.map → chunk-7L6TXOOC.js.map} +1 -1
  123. package/dist/cli-bundle/chunks/chunk-7M2HAZEB.js +17 -0
  124. package/dist/cli-bundle/chunks/chunk-7M2HAZEB.js.map +7 -0
  125. package/dist/cli-bundle/chunks/{chunk-3VY3YQO6.js → chunk-7RIJGN4R.js} +2 -2
  126. package/dist/cli-bundle/chunks/{chunk-G6PYHBBR.js → chunk-7WDETKGP.js} +192 -113
  127. package/dist/cli-bundle/chunks/chunk-7WDETKGP.js.map +7 -0
  128. package/dist/cli-bundle/chunks/{chunk-AONIHR2C.js → chunk-A3UNLXNJ.js} +40 -260
  129. package/dist/cli-bundle/chunks/chunk-A3UNLXNJ.js.map +7 -0
  130. package/dist/cli-bundle/chunks/{chunk-4KD54S3Z.js → chunk-AWN4PPH5.js} +10 -14
  131. package/dist/cli-bundle/chunks/{chunk-4KD54S3Z.js.map → chunk-AWN4PPH5.js.map} +1 -1
  132. package/dist/cli-bundle/chunks/{chunk-FXR67XVQ.js → chunk-BN3CWK6G.js} +2 -2
  133. package/dist/cli-bundle/chunks/{chunk-KFWBJPSG.js → chunk-BOWQWXLI.js} +12 -24
  134. package/dist/cli-bundle/chunks/chunk-BOWQWXLI.js.map +1 -0
  135. package/dist/cli-bundle/chunks/{chunk-4BHT5VDC.js → chunk-C2KCIZKZ.js} +2 -2
  136. package/dist/cli-bundle/chunks/{chunk-O6LLO73I.js → chunk-CHRNYKNI.js} +2 -2
  137. package/dist/cli-bundle/chunks/{chunk-UELRKQQU.js → chunk-CY5IJMUM.js} +1239 -495
  138. package/dist/cli-bundle/chunks/chunk-CY5IJMUM.js.map +1 -0
  139. package/dist/cli-bundle/chunks/chunk-CZVISY5A.js +87 -0
  140. package/dist/cli-bundle/chunks/chunk-CZVISY5A.js.map +7 -0
  141. package/dist/cli-bundle/chunks/{chunk-7K2XXO4I.js → chunk-D5LYZVGB.js} +7 -9
  142. package/dist/cli-bundle/chunks/{chunk-7K2XXO4I.js.map → chunk-D5LYZVGB.js.map} +1 -1
  143. package/dist/cli-bundle/chunks/{chunk-ZQ3ZVXX2.js → chunk-D6USKAMA.js} +2 -2
  144. package/dist/cli-bundle/chunks/{context-BLBD3PUB.js → chunk-DJDXAU74.js} +19 -21
  145. package/dist/cli-bundle/chunks/chunk-DJDXAU74.js.map +7 -0
  146. package/dist/cli-bundle/chunks/{chunk-WZQWHN4R.js → chunk-DLDCPF5X.js} +3 -3
  147. package/dist/cli-bundle/chunks/{chunk-HFFUQR73.js → chunk-DORJSBGJ.js} +35 -9
  148. package/dist/cli-bundle/chunks/chunk-DORJSBGJ.js.map +7 -0
  149. package/dist/cli-bundle/chunks/{chunk-XVF4YARA.js → chunk-DRPF274X.js} +5 -7
  150. package/dist/cli-bundle/chunks/{chunk-XVF4YARA.js.map → chunk-DRPF274X.js.map} +2 -2
  151. package/dist/cli-bundle/chunks/{chunk-QL5RVYOA.js → chunk-DU66JUGT.js} +16 -14
  152. package/dist/cli-bundle/chunks/chunk-DU66JUGT.js.map +7 -0
  153. package/dist/cli-bundle/chunks/{chunk-UVC5LOR7.js → chunk-E2Q2ULMR.js} +4 -4
  154. package/dist/cli-bundle/chunks/{chunk-U2Z5YUSO.js → chunk-EVWYAG46.js} +9 -11
  155. package/dist/cli-bundle/chunks/{chunk-U2Z5YUSO.js.map → chunk-EVWYAG46.js.map} +1 -1
  156. package/dist/cli-bundle/chunks/{chunk-5VOINNKT.js → chunk-F6VH3LFC.js} +2 -2
  157. package/dist/cli-bundle/chunks/{chunk-VFAQ4LMN.js → chunk-F7G53BOA.js} +18 -11
  158. package/dist/cli-bundle/chunks/chunk-F7G53BOA.js.map +7 -0
  159. package/dist/cli-bundle/chunks/{chunk-Q2KNGP7C.js → chunk-FBZ5XAAF.js} +9 -11
  160. package/dist/cli-bundle/chunks/{chunk-Q2KNGP7C.js.map → chunk-FBZ5XAAF.js.map} +1 -1
  161. package/dist/cli-bundle/chunks/{chunk-H4IIJDE4.js → chunk-FDEVKXC4.js} +2 -2
  162. package/dist/cli-bundle/chunks/{chunk-7UGEAPRY.js → chunk-GF7EAR22.js} +10 -14
  163. package/dist/cli-bundle/chunks/{chunk-7UGEAPRY.js.map → chunk-GF7EAR22.js.map} +1 -1
  164. package/dist/cli-bundle/chunks/{context-DHLVPXN3.js → chunk-HIBK6H4S.js} +20 -22
  165. package/dist/cli-bundle/chunks/chunk-HIBK6H4S.js.map +1 -0
  166. package/dist/cli-bundle/chunks/{chunk-34EONI5F.js → chunk-HUYYMTGW.js} +2 -2
  167. package/dist/cli-bundle/chunks/chunk-IBMFIKVS.js +14 -0
  168. package/dist/cli-bundle/chunks/chunk-IBMFIKVS.js.map +1 -0
  169. package/dist/cli-bundle/chunks/{chunk-BB6MDVNQ.js → chunk-IBU2LLWM.js} +8 -12
  170. package/dist/cli-bundle/chunks/{chunk-BB6MDVNQ.js.map → chunk-IBU2LLWM.js.map} +1 -1
  171. package/dist/cli-bundle/chunks/{chunk-55ISXAQH.js → chunk-IDYCAK35.js} +53 -54
  172. package/dist/cli-bundle/chunks/chunk-IDYCAK35.js.map +7 -0
  173. package/dist/cli-bundle/chunks/{chunk-M4T5DXD5.js → chunk-IF4ERU6A.js} +7 -9
  174. package/dist/cli-bundle/chunks/{chunk-M4T5DXD5.js.map → chunk-IF4ERU6A.js.map} +1 -1
  175. package/dist/cli-bundle/chunks/{chunk-CIIK67GW.js → chunk-IHXXUIXS.js} +4 -4
  176. package/dist/cli-bundle/chunks/chunk-IZQOJR2B.js +2459 -0
  177. package/dist/cli-bundle/chunks/chunk-IZQOJR2B.js.map +7 -0
  178. package/dist/cli-bundle/chunks/{chunk-SBQTAVJZ.js → chunk-JIP67N2K.js} +3 -3
  179. package/dist/cli-bundle/chunks/chunk-JJ4SG243.js +119 -0
  180. package/dist/cli-bundle/chunks/chunk-JJ4SG243.js.map +7 -0
  181. package/dist/cli-bundle/chunks/{chunk-TQZH6OD6.js → chunk-JTRKME24.js} +11 -13
  182. package/dist/cli-bundle/chunks/{chunk-TQZH6OD6.js.map → chunk-JTRKME24.js.map} +1 -1
  183. package/dist/cli-bundle/chunks/{chunk-WBRKK5QR.js → chunk-JVQ7UOYC.js} +6 -8
  184. package/dist/cli-bundle/chunks/{chunk-WBRKK5QR.js.map → chunk-JVQ7UOYC.js.map} +1 -1
  185. package/dist/cli-bundle/chunks/{chunk-KQMUV6LX.js → chunk-JZG5ADVE.js} +191 -98
  186. package/dist/cli-bundle/chunks/chunk-JZG5ADVE.js.map +1 -0
  187. package/dist/cli-bundle/chunks/{chunk-46G6RSB6.js → chunk-K46GQ265.js} +17 -15
  188. package/dist/cli-bundle/chunks/chunk-K46GQ265.js.map +1 -0
  189. package/dist/cli-bundle/chunks/{chunk-5UVVASSA.js → chunk-KGQ3W65B.js} +100 -35
  190. package/dist/cli-bundle/chunks/chunk-KGQ3W65B.js.map +1 -0
  191. package/dist/cli-bundle/chunks/{chunk-2T3JG6V4.js → chunk-KRASIL6M.js} +2 -2
  192. package/dist/cli-bundle/chunks/{chunk-SR3EKWZG.js → chunk-KTMMTOIP.js} +127 -127
  193. package/dist/cli-bundle/chunks/chunk-KTMMTOIP.js.map +7 -0
  194. package/dist/cli-bundle/chunks/{chunk-DT5LPYOD.js → chunk-KYDYQMNW.js} +5 -7
  195. package/dist/cli-bundle/chunks/{chunk-DT5LPYOD.js.map → chunk-KYDYQMNW.js.map} +1 -1
  196. package/dist/cli-bundle/chunks/{chunk-IPKJ6B36.js → chunk-LBH7UYKY.js} +106 -34
  197. package/dist/cli-bundle/chunks/chunk-LBH7UYKY.js.map +7 -0
  198. package/dist/cli-bundle/chunks/{chunk-P77P2ILI.js → chunk-MLHX6DN5.js} +2 -2
  199. package/dist/cli-bundle/chunks/{chunk-YUDJD3XO.js → chunk-NIBP3I7A.js} +36 -10
  200. package/dist/cli-bundle/chunks/chunk-NIBP3I7A.js.map +1 -0
  201. package/dist/cli-bundle/chunks/{schema-RBTJ2YXW.js → chunk-NO6Y6FB2.js} +144 -67
  202. package/dist/cli-bundle/chunks/chunk-NO6Y6FB2.js.map +7 -0
  203. package/dist/cli-bundle/chunks/{chunk-2CKH2LMV.js → chunk-OB3RJV5F.js} +2 -2
  204. package/dist/cli-bundle/chunks/chunk-OKQ22KTH.js +379 -0
  205. package/dist/cli-bundle/chunks/chunk-OKQ22KTH.js.map +1 -0
  206. package/dist/cli-bundle/chunks/{chunk-FIGAZ4Y7.js → chunk-OUQ5JEFM.js} +3 -3
  207. package/dist/cli-bundle/chunks/{chunk-NK3UPBVG.js → chunk-QE5UFCCO.js} +2 -2
  208. package/dist/cli-bundle/chunks/{chunk-MJTINN54.js → chunk-RM6MHL6A.js} +110 -113
  209. package/dist/cli-bundle/chunks/chunk-RM6MHL6A.js.map +7 -0
  210. package/dist/cli-bundle/chunks/{chunk-LRKKONT2.js → chunk-RPRW26NG.js} +12 -16
  211. package/dist/cli-bundle/chunks/{chunk-LRKKONT2.js.map → chunk-RPRW26NG.js.map} +1 -1
  212. package/dist/cli-bundle/chunks/{chunk-WM5ZVBPE.js → chunk-SJZTPVFT.js} +4 -4
  213. package/dist/cli-bundle/chunks/{chunk-MJTSZKK5.js → chunk-SNUK7H5J.js} +1363 -605
  214. package/dist/cli-bundle/chunks/chunk-SNUK7H5J.js.map +7 -0
  215. package/dist/cli-bundle/chunks/chunk-T7ZMQI4J.js +2435 -0
  216. package/dist/cli-bundle/chunks/chunk-T7ZMQI4J.js.map +1 -0
  217. package/dist/cli-bundle/chunks/{chunk-W72GHSJE.js → chunk-TQ6E76BE.js} +11 -13
  218. package/dist/cli-bundle/chunks/{chunk-W72GHSJE.js.map → chunk-TQ6E76BE.js.map} +1 -1
  219. package/dist/cli-bundle/chunks/{chunk-ZRK4O56R.js → chunk-UB3V5WUI.js} +225 -189
  220. package/dist/cli-bundle/chunks/chunk-UB3V5WUI.js.map +1 -0
  221. package/dist/cli-bundle/chunks/{chunk-SKN7LC5W.js → chunk-UFKNF23C.js} +11 -23
  222. package/dist/cli-bundle/chunks/chunk-UFKNF23C.js.map +7 -0
  223. package/dist/cli-bundle/chunks/{chunk-VAYA4XFX.js → chunk-V3KLX7U7.js} +3 -3
  224. package/dist/cli-bundle/chunks/{chunk-GAJVRGGA.js → chunk-VD3LKZFX.js} +41 -254
  225. package/dist/cli-bundle/chunks/chunk-VD3LKZFX.js.map +1 -0
  226. package/dist/cli-bundle/chunks/{chunk-AD3A7ZD6.js → chunk-VMY7MZEM.js} +10 -14
  227. package/dist/cli-bundle/chunks/{chunk-AD3A7ZD6.js.map → chunk-VMY7MZEM.js.map} +1 -1
  228. package/dist/cli-bundle/chunks/chunk-VZDBVEZR.js +382 -0
  229. package/dist/cli-bundle/chunks/chunk-VZDBVEZR.js.map +7 -0
  230. package/dist/cli-bundle/chunks/{chunk-CE5P2NQR.js → chunk-WFJZDUM7.js} +19 -12
  231. package/dist/cli-bundle/chunks/chunk-WFJZDUM7.js.map +1 -0
  232. package/dist/cli-bundle/chunks/{schema-MNTAVQCY.js → chunk-WTRUDJ3R.js} +136 -66
  233. package/dist/cli-bundle/chunks/chunk-WTRUDJ3R.js.map +1 -0
  234. package/dist/cli-bundle/chunks/{chunk-T72AZDBA.js → chunk-YEDFE4DC.js} +6 -8
  235. package/dist/cli-bundle/chunks/{chunk-T72AZDBA.js.map → chunk-YEDFE4DC.js.map} +1 -1
  236. package/dist/cli-bundle/chunks/chunk-YJIEJRZB.js +84 -0
  237. package/dist/cli-bundle/chunks/chunk-YJIEJRZB.js.map +1 -0
  238. package/dist/cli-bundle/chunks/{chunk-H2IP4QLJ.js → chunk-Z55WX4IQ.js} +12 -16
  239. package/dist/cli-bundle/chunks/{chunk-H2IP4QLJ.js.map → chunk-Z55WX4IQ.js.map} +1 -1
  240. package/dist/cli-bundle/chunks/{chunk-2RDVQEWV.js → chunk-Z5BM2FKQ.js} +4 -4
  241. package/dist/cli-bundle/chunks/{chunk-66MEDTUD.js → chunk-ZEATCVAC.js} +2 -2
  242. package/dist/cli-bundle/chunks/{chunk-NCVCO3NZ.js → chunk-ZFIEEDTJ.js} +3 -3
  243. package/dist/cli-bundle/chunks/{chunk-7SV63ZHD.js → chunk-ZIE6WXJ2.js} +128 -128
  244. package/dist/cli-bundle/chunks/chunk-ZIE6WXJ2.js.map +1 -0
  245. package/dist/cli-bundle/chunks/{claim-4KHAA2RN.js → claim-6NINZYB3.js} +10 -12
  246. package/dist/cli-bundle/chunks/{claim-4KHAA2RN.js.map → claim-6NINZYB3.js.map} +1 -1
  247. package/dist/cli-bundle/chunks/{claim-CSPJFLNH.js → claim-HMCLSLUE.js} +8 -10
  248. package/dist/cli-bundle/chunks/{claim-CSPJFLNH.js.map → claim-HMCLSLUE.js.map} +1 -1
  249. package/dist/cli-bundle/chunks/close-37KEHLYM.js +14 -0
  250. package/dist/cli-bundle/chunks/{close-W56IOGYG.js → close-OP3LK7Z2.js} +7 -8
  251. package/dist/cli-bundle/chunks/{close-many-BX5DCSVV.js → close-many-BFMP6HHK.js} +15 -17
  252. package/dist/cli-bundle/chunks/{close-many-BX5DCSVV.js.map → close-many-BFMP6HHK.js.map} +1 -1
  253. package/dist/cli-bundle/chunks/{close-many-TQU5F4E4.js → close-many-CXJBOWWY.js} +17 -19
  254. package/dist/cli-bundle/chunks/{close-many-TQU5F4E4.js.map → close-many-CXJBOWWY.js.map} +1 -1
  255. package/dist/cli-bundle/chunks/{comments-VRECH75R.js → comments-ETHABIY6.js} +9 -11
  256. package/dist/cli-bundle/chunks/{comments-VRECH75R.js.map → comments-ETHABIY6.js.map} +1 -1
  257. package/dist/cli-bundle/chunks/{comments-U5KUC4EU.js → comments-MU2WMBUY.js} +11 -13
  258. package/dist/cli-bundle/chunks/{comments-U5KUC4EU.js.map → comments-MU2WMBUY.js.map} +1 -1
  259. package/dist/cli-bundle/chunks/{config-D3OKQO52.js → config-FIXJZEQK.js} +18 -387
  260. package/dist/cli-bundle/chunks/config-FIXJZEQK.js.map +7 -0
  261. package/dist/cli-bundle/chunks/{config-MMJA4LLK.js → config-X3ZVCUUG.js} +18 -380
  262. package/dist/cli-bundle/chunks/config-X3ZVCUUG.js.map +1 -0
  263. package/dist/cli-bundle/chunks/context-7ZEZV3BV.js +42 -0
  264. package/dist/cli-bundle/chunks/context-XDI4DKKT.js +46 -0
  265. package/dist/cli-bundle/chunks/{contracts-XGVMMPC5.js → contracts-KP4QAGVW.js} +72 -15
  266. package/dist/cli-bundle/chunks/contracts-KP4QAGVW.js.map +1 -0
  267. package/dist/cli-bundle/chunks/{contracts-C3SZCXXG.js → contracts-SMOAN5NF.js} +72 -15
  268. package/dist/cli-bundle/chunks/contracts-SMOAN5NF.js.map +7 -0
  269. package/dist/cli-bundle/chunks/{copy-HHL3K4QP.js → copy-CWM6SBY6.js} +7 -11
  270. package/dist/cli-bundle/chunks/{copy-HHL3K4QP.js.map → copy-CWM6SBY6.js.map} +1 -1
  271. package/dist/cli-bundle/chunks/{copy-5D5DX3VK.js → copy-JJ3KOQW2.js} +9 -13
  272. package/dist/cli-bundle/chunks/{copy-5D5DX3VK.js.map → copy-JJ3KOQW2.js.map} +1 -1
  273. package/dist/cli-bundle/chunks/create-DFMNBKBS.js +28 -0
  274. package/dist/cli-bundle/chunks/{create-IXY43O4H.js → create-J5Q2ELZT.js} +12 -14
  275. package/dist/cli-bundle/chunks/{delete-IBUR3M42.js → delete-2GZLQEUQ.js} +7 -9
  276. package/dist/cli-bundle/chunks/{delete-IBUR3M42.js.map → delete-2GZLQEUQ.js.map} +1 -1
  277. package/dist/cli-bundle/chunks/{delete-QQC2FGUH.js → delete-OOQS4KVD.js} +5 -7
  278. package/dist/cli-bundle/chunks/{delete-QQC2FGUH.js.map → delete-OOQS4KVD.js.map} +1 -1
  279. package/dist/cli-bundle/chunks/{deps-KWKRHXIN.js → deps-IF4IGL4R.js} +6 -9
  280. package/dist/cli-bundle/chunks/{deps-KWKRHXIN.js.map → deps-IF4IGL4R.js.map} +1 -1
  281. package/dist/cli-bundle/chunks/{deps-VTPO4BSE.js → deps-ZVGGCRR6.js} +8 -11
  282. package/dist/cli-bundle/chunks/{deps-VTPO4BSE.js.map → deps-ZVGGCRR6.js.map} +1 -1
  283. package/dist/cli-bundle/chunks/{docs-IIO3FEUO.js → docs-2TIFR62T.js} +8 -9
  284. package/dist/cli-bundle/chunks/{docs-IIO3FEUO.js.map → docs-2TIFR62T.js.map} +1 -1
  285. package/dist/cli-bundle/chunks/{docs-7CHFHXLN.js → docs-NFTBCQQC.js} +10 -11
  286. package/dist/cli-bundle/chunks/{docs-7CHFHXLN.js.map → docs-NFTBCQQC.js.map} +1 -1
  287. package/dist/cli-bundle/chunks/{eval-IO7LREOL.js → eval-2F6EH4XN.js} +12 -14
  288. package/dist/cli-bundle/chunks/{eval-IO7LREOL.js.map → eval-2F6EH4XN.js.map} +1 -1
  289. package/dist/cli-bundle/chunks/{eval-CEYYEPSX.js → eval-PFKXQR3B.js} +10 -12
  290. package/dist/cli-bundle/chunks/{eval-CEYYEPSX.js.map → eval-PFKXQR3B.js.map} +1 -1
  291. package/dist/cli-bundle/chunks/{extension-KCPUWSY2.js → extension-3LRYX7SW.js} +11 -7
  292. package/dist/cli-bundle/chunks/{extension-UTTQDUYI.js → extension-GMVOIP4O.js} +11 -7
  293. package/dist/cli-bundle/chunks/{files-Z2HHEFGP.js → files-DF3HO6XK.js} +11 -13
  294. package/dist/cli-bundle/chunks/{files-Z2HHEFGP.js.map → files-DF3HO6XK.js.map} +1 -1
  295. package/dist/cli-bundle/chunks/{files-TPUL6KWB.js → files-T5ODMETM.js} +9 -11
  296. package/dist/cli-bundle/chunks/{files-TPUL6KWB.js.map → files-T5ODMETM.js.map} +1 -1
  297. package/dist/cli-bundle/chunks/{focus-YRNNH7IP.js → focus-DLXKK4AH.js} +10 -14
  298. package/dist/cli-bundle/chunks/{focus-YRNNH7IP.js.map → focus-DLXKK4AH.js.map} +1 -1
  299. package/dist/cli-bundle/chunks/{focus-JVJCGC2D.js → focus-MY5ARIEK.js} +8 -12
  300. package/dist/cli-bundle/chunks/{focus-JVJCGC2D.js.map → focus-MY5ARIEK.js.map} +1 -1
  301. package/dist/cli-bundle/chunks/{gc-O5GUO3SU.js → gc-FULIVYR4.js} +3 -3
  302. package/dist/cli-bundle/chunks/{gc-PYVVEELM.js → gc-MDGRR2SU.js} +3 -3
  303. package/dist/cli-bundle/chunks/{get-X4O3HBEY.js → get-AWK324RS.js} +10 -13
  304. package/dist/cli-bundle/chunks/{get-X4O3HBEY.js.map → get-AWK324RS.js.map} +1 -1
  305. package/dist/cli-bundle/chunks/{get-ENLTEGTX.js → get-VYPIICPC.js} +12 -15
  306. package/dist/cli-bundle/chunks/{get-ENLTEGTX.js.map → get-VYPIICPC.js.map} +1 -1
  307. package/dist/cli-bundle/chunks/{health-5EXTY44Q.js → health-FBCVZGSX.js} +16 -17
  308. package/dist/cli-bundle/chunks/{health-5EXTY44Q.js.map → health-FBCVZGSX.js.map} +1 -1
  309. package/dist/cli-bundle/chunks/{health-BOTB7YSU.js → health-Q66C43GN.js} +18 -19
  310. package/dist/cli-bundle/chunks/{health-BOTB7YSU.js.map → health-Q66C43GN.js.map} +1 -1
  311. package/dist/cli-bundle/chunks/history-5XUSLAJA.js +18 -0
  312. package/dist/cli-bundle/chunks/{history-AJTXLT6S.js → history-X4OSES6K.js} +8 -10
  313. package/dist/cli-bundle/chunks/{history-compact-46MRHW3I.js → history-compact-2GHT32UX.js} +13 -16
  314. package/dist/cli-bundle/chunks/{history-compact-46MRHW3I.js.map → history-compact-2GHT32UX.js.map} +1 -1
  315. package/dist/cli-bundle/chunks/{history-compact-43OOUAWD.js → history-compact-WLCQEKXS.js} +11 -14
  316. package/dist/cli-bundle/chunks/{history-compact-43OOUAWD.js.map → history-compact-WLCQEKXS.js.map} +1 -1
  317. package/dist/cli-bundle/chunks/{history-redact-KUUUVUFM.js → history-redact-45YW65BK.js} +9 -11
  318. package/dist/cli-bundle/chunks/history-redact-BVHWDXPR.js +19 -0
  319. package/dist/cli-bundle/chunks/{history-repair-B5PZBOPU.js → history-repair-FY75IC26.js} +13 -16
  320. package/dist/cli-bundle/chunks/{history-repair-B5PZBOPU.js.map → history-repair-FY75IC26.js.map} +1 -1
  321. package/dist/cli-bundle/chunks/{history-repair-VQTYOSRS.js → history-repair-GABSDSVD.js} +11 -14
  322. package/dist/cli-bundle/chunks/{history-repair-VQTYOSRS.js.map → history-repair-GABSDSVD.js.map} +1 -1
  323. package/dist/cli-bundle/chunks/{init-BNLVFPRG.js → init-KO7CGIRQ.js} +11 -11
  324. package/dist/cli-bundle/chunks/init-TRYJELH4.js +21 -0
  325. package/dist/cli-bundle/chunks/{learnings-MUUU5KMC.js → learnings-3F7YLI45.js} +9 -11
  326. package/dist/cli-bundle/chunks/{learnings-MUUU5KMC.js.map → learnings-3F7YLI45.js.map} +1 -1
  327. package/dist/cli-bundle/chunks/{learnings-XSGX52S7.js → learnings-LHZT5BHW.js} +11 -13
  328. package/dist/cli-bundle/chunks/{learnings-XSGX52S7.js.map → learnings-LHZT5BHW.js.map} +1 -1
  329. package/dist/cli-bundle/chunks/{list-32U7BSKE.js → list-ROT7JF62.js} +10 -10
  330. package/dist/cli-bundle/chunks/{list-ZEEOHLTQ.js → list-Y6AU5BJS.js} +10 -10
  331. package/dist/cli-bundle/chunks/next-66BJB4N2.js +277 -0
  332. package/dist/cli-bundle/chunks/next-66BJB4N2.js.map +7 -0
  333. package/dist/cli-bundle/chunks/next-N5MWJTBY.js +274 -0
  334. package/dist/cli-bundle/chunks/next-N5MWJTBY.js.map +1 -0
  335. package/dist/cli-bundle/chunks/{notes-OHU25L3M.js → notes-EVJZ3VAB.js} +11 -13
  336. package/dist/cli-bundle/chunks/{notes-OHU25L3M.js.map → notes-EVJZ3VAB.js.map} +1 -1
  337. package/dist/cli-bundle/chunks/{notes-NJ45OZGF.js → notes-FW6YFLND.js} +9 -11
  338. package/dist/cli-bundle/chunks/{notes-NJ45OZGF.js.map → notes-FW6YFLND.js.map} +1 -1
  339. package/dist/cli-bundle/chunks/{plan-LWWAEV5Y.js → plan-DQ7G4EDC.js} +15 -18
  340. package/dist/cli-bundle/chunks/{plan-LWWAEV5Y.js.map → plan-DQ7G4EDC.js.map} +1 -1
  341. package/dist/cli-bundle/chunks/{plan-KQA7CAKI.js → plan-ZHKZ7JVF.js} +17 -20
  342. package/dist/cli-bundle/chunks/{plan-KQA7CAKI.js.map → plan-ZHKZ7JVF.js.map} +1 -1
  343. package/dist/cli-bundle/chunks/profile-CHAW6SEA.js +1197 -0
  344. package/dist/cli-bundle/chunks/profile-CHAW6SEA.js.map +1 -0
  345. package/dist/cli-bundle/chunks/profile-UPZGCDOG.js +1235 -0
  346. package/dist/cli-bundle/chunks/profile-UPZGCDOG.js.map +7 -0
  347. package/dist/cli-bundle/chunks/{register-list-query-DDCHPONM.js → register-list-query-KY6Z6WV7.js} +44 -20
  348. package/dist/cli-bundle/chunks/register-list-query-KY6Z6WV7.js.map +7 -0
  349. package/dist/cli-bundle/chunks/{register-list-query-YNPBVIKM.js → register-list-query-Y2VRHPCL.js} +45 -21
  350. package/dist/cli-bundle/chunks/register-list-query-Y2VRHPCL.js.map +1 -0
  351. package/dist/cli-bundle/chunks/{register-mutation-LAVKYY63.js → register-mutation-N6AYSKPM.js} +103 -37
  352. package/dist/cli-bundle/chunks/register-mutation-N6AYSKPM.js.map +7 -0
  353. package/dist/cli-bundle/chunks/{register-mutation-7ALWDDAX.js → register-mutation-PCARIGZS.js} +104 -38
  354. package/dist/cli-bundle/chunks/register-mutation-PCARIGZS.js.map +1 -0
  355. package/dist/cli-bundle/chunks/{register-operations-U5JAW3WE.js → register-operations-L6CYTOIH.js} +30 -32
  356. package/dist/cli-bundle/chunks/{register-operations-U5JAW3WE.js.map → register-operations-L6CYTOIH.js.map} +1 -1
  357. package/dist/cli-bundle/chunks/{register-operations-R4VOQ6EF.js → register-operations-YAT6FUUB.js} +32 -34
  358. package/dist/cli-bundle/chunks/{register-operations-R4VOQ6EF.js.map → register-operations-YAT6FUUB.js.map} +1 -1
  359. package/dist/cli-bundle/chunks/{register-setup-KBXQDCXE.js → register-setup-MPANILQF.js} +67 -24
  360. package/dist/cli-bundle/chunks/register-setup-MPANILQF.js.map +7 -0
  361. package/dist/cli-bundle/chunks/{register-setup-RCRUHMSZ.js → register-setup-N7UGXYJC.js} +68 -25
  362. package/dist/cli-bundle/chunks/register-setup-N7UGXYJC.js.map +1 -0
  363. package/dist/cli-bundle/chunks/{restore-6K53WOWO.js → restore-DKMCLPI5.js} +9 -11
  364. package/dist/cli-bundle/chunks/restore-IRAKSWIW.js +17 -0
  365. package/dist/cli-bundle/chunks/{scheduling-shortcuts-NJ5UVJFB.js → scheduling-shortcuts-3F4QUEDH.js} +14 -16
  366. package/dist/cli-bundle/chunks/{scheduling-shortcuts-NJ5UVJFB.js.map → scheduling-shortcuts-3F4QUEDH.js.map} +1 -1
  367. package/dist/cli-bundle/chunks/{scheduling-shortcuts-OQVJXG3M.js → scheduling-shortcuts-BNZLQK36.js} +12 -14
  368. package/dist/cli-bundle/chunks/{scheduling-shortcuts-OQVJXG3M.js.map → scheduling-shortcuts-BNZLQK36.js.map} +1 -1
  369. package/dist/cli-bundle/chunks/schema-OLT6LVKH.js +75 -0
  370. package/dist/cli-bundle/chunks/schema-XJXKJQF5.js +71 -0
  371. package/dist/cli-bundle/chunks/{search-6HOIVZDU.js → search-CX5UMV4H.js} +10 -12
  372. package/dist/cli-bundle/chunks/{search-ZWYEMASC.js → search-KP6H7COV.js} +10 -12
  373. package/dist/cli-bundle/chunks/{stats-R5OAJVZK.js → stats-7XW4OEMK.js} +20 -12
  374. package/dist/cli-bundle/chunks/stats-7XW4OEMK.js.map +7 -0
  375. package/dist/cli-bundle/chunks/{stats-FS742AMA.js → stats-QZUG6MX5.js} +21 -13
  376. package/dist/cli-bundle/chunks/stats-QZUG6MX5.js.map +1 -0
  377. package/dist/cli-bundle/chunks/{telemetry-7DIGDQUO.js → telemetry-DIFPXCAT.js} +4 -4
  378. package/dist/cli-bundle/chunks/{telemetry-FWEXSJLQ.js → telemetry-WTYFUPRL.js} +4 -4
  379. package/dist/cli-bundle/chunks/{test-NZF7OT2F.js → test-HU2BS7EY.js} +14 -16
  380. package/dist/cli-bundle/chunks/test-HU2BS7EY.js.map +1 -0
  381. package/dist/cli-bundle/chunks/test-QNDXZQCW.js +34 -0
  382. package/dist/cli-bundle/chunks/test-QNDXZQCW.js.map +7 -0
  383. package/dist/cli-bundle/chunks/{test-all-DPN62TX7.js → test-all-PZTBLLQ6.js} +17 -20
  384. package/dist/cli-bundle/chunks/{test-all-DPN62TX7.js.map → test-all-PZTBLLQ6.js.map} +1 -1
  385. package/dist/cli-bundle/chunks/{test-all-KL7TLMJF.js → test-all-XLPI4USF.js} +19 -22
  386. package/dist/cli-bundle/chunks/{test-all-KL7TLMJF.js.map → test-all-XLPI4USF.js.map} +1 -1
  387. package/dist/cli-bundle/chunks/{test-runs-C6CFIVOS.js → test-runs-CA6K32RD.js} +6 -7
  388. package/dist/cli-bundle/chunks/test-runs-CA6K32RD.js.map +1 -0
  389. package/dist/cli-bundle/chunks/{test-runs-IAJDL6CA.js → test-runs-LANLLPVO.js} +5 -6
  390. package/dist/cli-bundle/chunks/test-runs-LANLLPVO.js.map +7 -0
  391. package/dist/cli-bundle/chunks/update-DJKWLBWJ.js +28 -0
  392. package/dist/cli-bundle/chunks/update-DJKWLBWJ.js.map +1 -0
  393. package/dist/cli-bundle/chunks/update-UXDLTEOZ.js +24 -0
  394. package/dist/cli-bundle/chunks/update-UXDLTEOZ.js.map +7 -0
  395. package/dist/cli-bundle/chunks/{update-many-YEH2DQL6.js → update-many-LU3SCNK5.js} +32 -33
  396. package/dist/cli-bundle/chunks/{update-many-YEH2DQL6.js.map → update-many-LU3SCNK5.js.map} +1 -1
  397. package/dist/cli-bundle/chunks/{update-many-MUTIOAP3.js → update-many-VW5DGF3S.js} +34 -35
  398. package/dist/cli-bundle/chunks/{update-many-MUTIOAP3.js.map → update-many-VW5DGF3S.js.map} +1 -1
  399. package/dist/cli-bundle/chunks/{upgrade-HYJ3SWWU.js → upgrade-77FRUAXN.js} +12 -8
  400. package/dist/cli-bundle/chunks/{upgrade-HYJ3SWWU.js.map → upgrade-77FRUAXN.js.map} +1 -1
  401. package/dist/cli-bundle/chunks/{upgrade-UBNLBZNR.js → upgrade-ICXY244R.js} +10 -6
  402. package/dist/cli-bundle/chunks/{upgrade-UBNLBZNR.js.map → upgrade-ICXY244R.js.map} +1 -1
  403. package/dist/cli-bundle/chunks/{validate-6QWQVCX2.js → validate-2G566PKQ.js} +37 -28
  404. package/dist/cli-bundle/chunks/validate-2G566PKQ.js.map +7 -0
  405. package/dist/cli-bundle/chunks/{validate-W5V5ZGQX.js → validate-BDPVXHHH.js} +38 -29
  406. package/dist/cli-bundle/chunks/validate-BDPVXHHH.js.map +1 -0
  407. package/dist/cli-bundle/main.js +56 -38
  408. package/dist/cli-bundle/main.js.map +2 -2
  409. package/dist/core/config/positional-value.d.ts +2 -0
  410. package/dist/core/config/positional-value.js +2 -2
  411. package/dist/core/config/positional-value.js.map +1 -1
  412. package/dist/core/extensions/activation-summary-markdown.d.ts +71 -0
  413. package/dist/core/extensions/activation-summary-markdown.js +140 -0
  414. package/dist/core/extensions/activation-summary-markdown.js.map +1 -0
  415. package/dist/core/extensions/activation-summary.d.ts +2 -0
  416. package/dist/core/extensions/activation-summary.js +3 -2
  417. package/dist/core/extensions/activation-summary.js.map +1 -1
  418. package/dist/core/extensions/capability-usage.d.ts +1 -1
  419. package/dist/core/extensions/capability-usage.js +4 -3
  420. package/dist/core/extensions/capability-usage.js.map +1 -1
  421. package/dist/core/extensions/extension-registries.js +3 -2
  422. package/dist/core/extensions/extension-registries.js.map +1 -1
  423. package/dist/core/extensions/extension-types.d.ts +21 -1
  424. package/dist/core/extensions/extension-types.js +3 -2
  425. package/dist/core/extensions/extension-types.js.map +1 -1
  426. package/dist/core/extensions/loader.d.ts +1 -2
  427. package/dist/core/extensions/loader.js +169 -103
  428. package/dist/core/extensions/loader.js.map +1 -1
  429. package/dist/core/extensions/version-compat.d.ts +107 -0
  430. package/dist/core/extensions/version-compat.js +130 -0
  431. package/dist/core/extensions/version-compat.js.map +1 -0
  432. package/dist/core/fs/fs-utils.js +27 -2
  433. package/dist/core/fs/fs-utils.js.map +1 -1
  434. package/dist/core/item/actionability.d.ts +57 -0
  435. package/dist/core/item/actionability.js +178 -0
  436. package/dist/core/item/actionability.js.map +1 -0
  437. package/dist/core/item/type-registry.js +18 -45
  438. package/dist/core/item/type-registry.js.map +1 -1
  439. package/dist/core/profile/profile-describe.d.ts +64 -0
  440. package/dist/core/profile/profile-describe.js +83 -0
  441. package/dist/core/profile/profile-describe.js.map +1 -0
  442. package/dist/core/profile/profile-lint.d.ts +53 -0
  443. package/dist/core/profile/profile-lint.js +422 -0
  444. package/dist/core/profile/profile-lint.js.map +1 -0
  445. package/dist/core/profile/profile-plan.d.ts +145 -0
  446. package/dist/core/profile/profile-plan.js +0 -0
  447. package/dist/core/profile/profile-plan.js.map +1 -0
  448. package/dist/core/profile/profile-presets.d.ts +218 -0
  449. package/dist/core/profile/profile-presets.js +325 -0
  450. package/dist/core/profile/profile-presets.js.map +1 -0
  451. package/dist/core/schema/fields-file.js +25 -25
  452. package/dist/core/schema/fields-file.js.map +1 -1
  453. package/dist/core/schema/item-types-file.js +3 -3
  454. package/dist/core/schema/item-types-file.js.map +1 -1
  455. package/dist/core/schema/runtime-schema.js +4 -4
  456. package/dist/core/schema/runtime-schema.js.map +1 -1
  457. package/dist/core/schema/status-defs-file.js +3 -3
  458. package/dist/core/schema/status-defs-file.js.map +1 -1
  459. package/dist/core/shared/serialization.js +83 -62
  460. package/dist/core/shared/serialization.js.map +1 -1
  461. package/dist/core/store/item-store.d.ts +1 -0
  462. package/dist/core/store/item-store.js +16 -8
  463. package/dist/core/store/item-store.js.map +1 -1
  464. package/dist/core/store/paths.js +4 -32
  465. package/dist/core/store/paths.js.map +1 -1
  466. package/dist/core/store/settings.js +14 -14
  467. package/dist/core/store/settings.js.map +1 -1
  468. package/dist/core/telemetry/observability.js +50 -54
  469. package/dist/core/telemetry/observability.js.map +1 -1
  470. package/dist/core/telemetry/runtime.js +11 -2
  471. package/dist/core/telemetry/runtime.js.map +1 -1
  472. package/dist/core/test/background-runs.js +3 -2
  473. package/dist/core/test/background-runs.js.map +1 -1
  474. package/dist/core/validate/linked-artifact-reference.d.ts +24 -0
  475. package/dist/core/validate/linked-artifact-reference.js +41 -0
  476. package/dist/core/validate/linked-artifact-reference.js.map +1 -0
  477. package/dist/mcp/server.js +183 -83
  478. package/dist/mcp/server.js.map +1 -1
  479. package/dist/mcp/tool-definitions.js +33 -2
  480. package/dist/mcp/tool-definitions.js.map +1 -1
  481. package/dist/sdk/cli-contracts/commander-types.d.ts +1 -0
  482. package/dist/sdk/cli-contracts/commander-types.js +15 -2
  483. package/dist/sdk/cli-contracts/commander-types.js.map +1 -1
  484. package/dist/sdk/cli-contracts/enum-contracts.d.ts +3 -3
  485. package/dist/sdk/cli-contracts/enum-contracts.js +6 -2
  486. package/dist/sdk/cli-contracts/enum-contracts.js.map +1 -1
  487. package/dist/sdk/cli-contracts/flag-contracts.d.ts +149 -0
  488. package/dist/sdk/cli-contracts/flag-contracts.js +1583 -0
  489. package/dist/sdk/cli-contracts/flag-contracts.js.map +1 -0
  490. package/dist/sdk/cli-contracts/string-lists.d.ts +14 -0
  491. package/dist/sdk/cli-contracts/string-lists.js +20 -0
  492. package/dist/sdk/cli-contracts/string-lists.js.map +1 -0
  493. package/dist/sdk/cli-contracts/tool-option-contracts.d.ts +1 -1
  494. package/dist/sdk/cli-contracts/tool-option-contracts.js +51 -109
  495. package/dist/sdk/cli-contracts/tool-option-contracts.js.map +1 -1
  496. package/dist/sdk/cli-contracts/tool-parameter-tables.d.ts +17 -0
  497. package/dist/sdk/cli-contracts/tool-parameter-tables.js +54 -5
  498. package/dist/sdk/cli-contracts/tool-parameter-tables.js.map +1 -1
  499. package/dist/sdk/cli-contracts/tool-schema.d.ts +74 -0
  500. package/dist/sdk/cli-contracts/tool-schema.js +840 -0
  501. package/dist/sdk/cli-contracts/tool-schema.js.map +1 -0
  502. package/dist/sdk/cli-contracts.d.ts +13 -193
  503. package/dist/sdk/cli-contracts.js +5 -2277
  504. package/dist/sdk/cli-contracts.js.map +1 -1
  505. package/dist/sdk/compose.d.ts +346 -4
  506. package/dist/sdk/compose.js +486 -15
  507. package/dist/sdk/compose.js.map +1 -1
  508. package/dist/sdk/define.d.ts +29 -14
  509. package/dist/sdk/define.js +21 -7
  510. package/dist/sdk/define.js.map +1 -1
  511. package/dist/sdk/index.d.ts +14 -3
  512. package/dist/sdk/index.js +14 -3
  513. package/dist/sdk/index.js.map +1 -1
  514. package/dist/sdk/testing.d.ts +156 -3
  515. package/dist/sdk/testing.js +172 -4
  516. package/dist/sdk/testing.js.map +1 -1
  517. package/docs/AGENT_GUIDE.md +2 -0
  518. package/docs/CLAUDE_CODE_PLUGIN.md +2 -2
  519. package/docs/COMMANDS.md +37 -0
  520. package/docs/EXTENSIONS.md +20 -20
  521. package/docs/RELEASING.md +6 -1
  522. package/docs/SDK.md +387 -20
  523. package/docs/TESTING.md +12 -0
  524. package/docs/examples/policy-restricted-extension/README.md +6 -0
  525. package/docs/examples/policy-restricted-extension/index.ts +40 -0
  526. package/docs/examples/policy-restricted-extension/manifest.json +2 -2
  527. package/docs/examples/starter-extension/README.md +14 -2
  528. package/docs/examples/starter-extension/{index.js → index.ts} +51 -6
  529. package/docs/examples/starter-extension/manifest.json +2 -2
  530. package/package.json +20 -7
  531. package/packages/pm-beads/extensions/beads/index.ts +3 -3
  532. package/packages/pm-beads/extensions/beads/manifest.json +2 -2
  533. package/packages/pm-beads/extensions/beads/runtime-loader.ts +19 -7
  534. package/packages/pm-beads/extensions/beads/runtime.ts +155 -37
  535. package/packages/pm-calendar/extensions/calendar/index.ts +3 -3
  536. package/packages/pm-calendar/extensions/calendar/manifest.json +2 -2
  537. package/packages/pm-calendar/extensions/calendar/runtime.ts +2 -2
  538. package/packages/pm-command-kit/extensions/command-kit/index.ts +1 -1
  539. package/packages/pm-command-kit/extensions/command-kit/manifest.json +2 -2
  540. package/packages/pm-governance-audit/extensions/governance-audit/index.ts +2 -2
  541. package/packages/pm-governance-audit/extensions/governance-audit/manifest.json +2 -2
  542. package/packages/pm-governance-audit/extensions/governance-audit/runtime.ts +1 -1
  543. package/packages/pm-guide-shell/extensions/guide-shell/index.ts +2 -2
  544. package/packages/pm-guide-shell/extensions/guide-shell/manifest.json +2 -2
  545. package/packages/pm-guide-shell/extensions/guide-shell/runtime.ts +1 -1
  546. package/packages/pm-kanban/README.md +97 -0
  547. package/packages/pm-kanban/extensions/kanban/index.ts +191 -0
  548. package/packages/pm-kanban/extensions/kanban/manifest.json +19 -0
  549. package/packages/pm-kanban/package.json +57 -0
  550. package/packages/pm-lifecycle-hooks/extensions/lifecycle-hooks/index.ts +1 -1
  551. package/packages/pm-lifecycle-hooks/extensions/lifecycle-hooks/manifest.json +2 -2
  552. package/packages/pm-linked-test-adapters/extensions/linked-test-adapters/index.ts +2 -2
  553. package/packages/pm-linked-test-adapters/extensions/linked-test-adapters/manifest.json +2 -2
  554. package/packages/pm-linked-test-adapters/extensions/linked-test-adapters/runtime.ts +1 -1
  555. package/packages/pm-search-advanced/extensions/search-advanced/index.ts +2 -2
  556. package/packages/pm-search-advanced/extensions/search-advanced/manifest.json +2 -2
  557. package/packages/pm-search-advanced/extensions/search-advanced/runtime.ts +1 -1
  558. package/packages/pm-templates/extensions/templates/index.ts +2 -2
  559. package/packages/pm-templates/extensions/templates/manifest.json +2 -2
  560. package/packages/pm-templates/extensions/templates/runtime.ts +1 -1
  561. package/packages/pm-todos/extensions/todos/index.ts +3 -3
  562. package/packages/pm-todos/extensions/todos/manifest.json +2 -2
  563. package/packages/pm-todos/extensions/todos/runtime-loader.ts +19 -7
  564. package/packages/pm-todos/extensions/todos/runtime.ts +177 -43
  565. package/plugins/pm-claude/scripts/pm-mcp-server.mjs +2 -2
  566. package/plugins/pm-codex/scripts/pm-mcp-server.mjs +2 -2
  567. package/scripts/bundle-cli.mjs +1 -1
  568. package/dist/cli-bundle/chunks/activity-XUZ2AHCW.js +0 -18
  569. package/dist/cli-bundle/chunks/aggregate-EGJLZQBI.js.map +0 -7
  570. package/dist/cli-bundle/chunks/aggregate-R725FC3S.js.map +0 -1
  571. package/dist/cli-bundle/chunks/chunk-2BFPAUAF.js.map +0 -1
  572. package/dist/cli-bundle/chunks/chunk-46G6RSB6.js.map +0 -1
  573. package/dist/cli-bundle/chunks/chunk-55ISXAQH.js.map +0 -7
  574. package/dist/cli-bundle/chunks/chunk-5UVVASSA.js.map +0 -1
  575. package/dist/cli-bundle/chunks/chunk-7MRQ4HMK.js +0 -78
  576. package/dist/cli-bundle/chunks/chunk-7MRQ4HMK.js.map +0 -7
  577. package/dist/cli-bundle/chunks/chunk-7SV63ZHD.js.map +0 -1
  578. package/dist/cli-bundle/chunks/chunk-AONIHR2C.js.map +0 -7
  579. package/dist/cli-bundle/chunks/chunk-C5AOG6D2.js +0 -691
  580. package/dist/cli-bundle/chunks/chunk-C5AOG6D2.js.map +0 -1
  581. package/dist/cli-bundle/chunks/chunk-CE5P2NQR.js.map +0 -1
  582. package/dist/cli-bundle/chunks/chunk-CKGNPJAG.js.map +0 -7
  583. package/dist/cli-bundle/chunks/chunk-G6PYHBBR.js.map +0 -7
  584. package/dist/cli-bundle/chunks/chunk-GAJVRGGA.js.map +0 -1
  585. package/dist/cli-bundle/chunks/chunk-HFFUQR73.js.map +0 -7
  586. package/dist/cli-bundle/chunks/chunk-IPKJ6B36.js.map +0 -7
  587. package/dist/cli-bundle/chunks/chunk-JR2LV3M4.js.map +0 -7
  588. package/dist/cli-bundle/chunks/chunk-KFWBJPSG.js.map +0 -1
  589. package/dist/cli-bundle/chunks/chunk-KQMUV6LX.js.map +0 -1
  590. package/dist/cli-bundle/chunks/chunk-MJTINN54.js.map +0 -7
  591. package/dist/cli-bundle/chunks/chunk-MJTSZKK5.js.map +0 -7
  592. package/dist/cli-bundle/chunks/chunk-MVKFOLLM.js +0 -694
  593. package/dist/cli-bundle/chunks/chunk-MVKFOLLM.js.map +0 -7
  594. package/dist/cli-bundle/chunks/chunk-QH3PJYON.js.map +0 -1
  595. package/dist/cli-bundle/chunks/chunk-QL5RVYOA.js.map +0 -7
  596. package/dist/cli-bundle/chunks/chunk-S26C36QC.js +0 -83
  597. package/dist/cli-bundle/chunks/chunk-S26C36QC.js.map +0 -1
  598. package/dist/cli-bundle/chunks/chunk-S2RUQSX2.js +0 -75
  599. package/dist/cli-bundle/chunks/chunk-S2RUQSX2.js.map +0 -1
  600. package/dist/cli-bundle/chunks/chunk-SKH7OGE5.js +0 -86
  601. package/dist/cli-bundle/chunks/chunk-SKH7OGE5.js.map +0 -7
  602. package/dist/cli-bundle/chunks/chunk-SKN7LC5W.js.map +0 -7
  603. package/dist/cli-bundle/chunks/chunk-SR3EKWZG.js.map +0 -7
  604. package/dist/cli-bundle/chunks/chunk-UELRKQQU.js.map +0 -1
  605. package/dist/cli-bundle/chunks/chunk-VFAQ4LMN.js.map +0 -7
  606. package/dist/cli-bundle/chunks/chunk-Y4SUQQYH.js.map +0 -1
  607. package/dist/cli-bundle/chunks/chunk-YDEXO24S.js +0 -654
  608. package/dist/cli-bundle/chunks/chunk-YDEXO24S.js.map +0 -1
  609. package/dist/cli-bundle/chunks/chunk-YJ3SUEPD.js +0 -657
  610. package/dist/cli-bundle/chunks/chunk-YJ3SUEPD.js.map +0 -7
  611. package/dist/cli-bundle/chunks/chunk-YUDJD3XO.js.map +0 -1
  612. package/dist/cli-bundle/chunks/chunk-ZRK4O56R.js.map +0 -1
  613. package/dist/cli-bundle/chunks/close-A3EMKBBY.js +0 -15
  614. package/dist/cli-bundle/chunks/config-D3OKQO52.js.map +0 -7
  615. package/dist/cli-bundle/chunks/config-MMJA4LLK.js.map +0 -1
  616. package/dist/cli-bundle/chunks/context-BLBD3PUB.js.map +0 -7
  617. package/dist/cli-bundle/chunks/context-DHLVPXN3.js.map +0 -1
  618. package/dist/cli-bundle/chunks/contracts-C3SZCXXG.js.map +0 -7
  619. package/dist/cli-bundle/chunks/contracts-XGVMMPC5.js.map +0 -1
  620. package/dist/cli-bundle/chunks/create-QVGFYA2X.js +0 -30
  621. package/dist/cli-bundle/chunks/history-AK3E5Z3C.js +0 -20
  622. package/dist/cli-bundle/chunks/history-redact-TWIYQV5J.js +0 -21
  623. package/dist/cli-bundle/chunks/init-RCRKW5PL.js +0 -21
  624. package/dist/cli-bundle/chunks/register-list-query-DDCHPONM.js.map +0 -7
  625. package/dist/cli-bundle/chunks/register-list-query-YNPBVIKM.js.map +0 -1
  626. package/dist/cli-bundle/chunks/register-mutation-7ALWDDAX.js.map +0 -1
  627. package/dist/cli-bundle/chunks/register-mutation-LAVKYY63.js.map +0 -7
  628. package/dist/cli-bundle/chunks/register-setup-KBXQDCXE.js.map +0 -7
  629. package/dist/cli-bundle/chunks/register-setup-RCRUHMSZ.js.map +0 -1
  630. package/dist/cli-bundle/chunks/restore-2ZKT6UDC.js +0 -19
  631. package/dist/cli-bundle/chunks/schema-MNTAVQCY.js.map +0 -1
  632. package/dist/cli-bundle/chunks/schema-RBTJ2YXW.js.map +0 -7
  633. package/dist/cli-bundle/chunks/stats-FS742AMA.js.map +0 -1
  634. package/dist/cli-bundle/chunks/stats-R5OAJVZK.js.map +0 -7
  635. package/dist/cli-bundle/chunks/test-QJXLKV26.js +0 -36
  636. package/dist/cli-bundle/chunks/test-runs-C6CFIVOS.js.map +0 -1
  637. package/dist/cli-bundle/chunks/test-runs-IAJDL6CA.js.map +0 -7
  638. package/dist/cli-bundle/chunks/update-2XCQNOD6.js +0 -28
  639. package/dist/cli-bundle/chunks/update-IWUCXVH2.js +0 -24
  640. package/dist/cli-bundle/chunks/validate-6QWQVCX2.js.map +0 -7
  641. package/dist/cli-bundle/chunks/validate-W5V5ZGQX.js.map +0 -1
  642. package/docs/examples/policy-restricted-extension/index.js +0 -21
  643. package/packages/pm-beads/extensions/beads/index.js +0 -64
  644. package/packages/pm-beads/extensions/beads/runtime-loader.js +0 -86
  645. package/packages/pm-beads/extensions/beads/runtime.js +0 -482
  646. package/packages/pm-calendar/extensions/calendar/index.js +0 -150
  647. package/packages/pm-calendar/extensions/calendar/runtime.js +0 -126
  648. package/packages/pm-command-kit/extensions/command-kit/index.js +0 -181
  649. package/packages/pm-governance-audit/extensions/governance-audit/index.js +0 -177
  650. package/packages/pm-governance-audit/extensions/governance-audit/runtime.js +0 -153
  651. package/packages/pm-guide-shell/extensions/guide-shell/index.js +0 -98
  652. package/packages/pm-guide-shell/extensions/guide-shell/runtime.js +0 -294
  653. package/packages/pm-lifecycle-hooks/extensions/lifecycle-hooks/index.js +0 -18
  654. package/packages/pm-linked-test-adapters/extensions/linked-test-adapters/index.js +0 -124
  655. package/packages/pm-linked-test-adapters/extensions/linked-test-adapters/runtime.js +0 -110
  656. package/packages/pm-search-advanced/extensions/search-advanced/index.js +0 -258
  657. package/packages/pm-search-advanced/extensions/search-advanced/runtime.js +0 -361
  658. package/packages/pm-templates/extensions/templates/index.js +0 -132
  659. package/packages/pm-templates/extensions/templates/runtime.js +0 -35
  660. package/packages/pm-todos/extensions/todos/index.js +0 -81
  661. package/packages/pm-todos/extensions/todos/runtime-loader.js +0 -86
  662. package/packages/pm-todos/extensions/todos/runtime.js +0 -545
  663. /package/dist/cli-bundle/chunks/{activity-XUZ2AHCW.js.map → activity-EJBMXUBH.js.map} +0 -0
  664. /package/dist/cli-bundle/chunks/{activity-H2LMOSSW.js.map → activity-MVSEND6D.js.map} +0 -0
  665. /package/dist/cli-bundle/chunks/{chunk-IB3GYLQE.js.map → chunk-3JWQCLR5.js.map} +0 -0
  666. /package/dist/cli-bundle/chunks/{chunk-2A34E3BA.js.map → chunk-4TXTVZL3.js.map} +0 -0
  667. /package/dist/cli-bundle/chunks/{chunk-G6N5VEOK.js.map → chunk-4YIMPANT.js.map} +0 -0
  668. /package/dist/cli-bundle/chunks/{chunk-7XGQXHFB.js.map → chunk-73PTKMAE.js.map} +0 -0
  669. /package/dist/cli-bundle/chunks/{chunk-3VY3YQO6.js.map → chunk-7RIJGN4R.js.map} +0 -0
  670. /package/dist/cli-bundle/chunks/{chunk-FXR67XVQ.js.map → chunk-BN3CWK6G.js.map} +0 -0
  671. /package/dist/cli-bundle/chunks/{chunk-4BHT5VDC.js.map → chunk-C2KCIZKZ.js.map} +0 -0
  672. /package/dist/cli-bundle/chunks/{chunk-O6LLO73I.js.map → chunk-CHRNYKNI.js.map} +0 -0
  673. /package/dist/cli-bundle/chunks/{chunk-ZQ3ZVXX2.js.map → chunk-D6USKAMA.js.map} +0 -0
  674. /package/dist/cli-bundle/chunks/{chunk-WZQWHN4R.js.map → chunk-DLDCPF5X.js.map} +0 -0
  675. /package/dist/cli-bundle/chunks/{chunk-UVC5LOR7.js.map → chunk-E2Q2ULMR.js.map} +0 -0
  676. /package/dist/cli-bundle/chunks/{chunk-5VOINNKT.js.map → chunk-F6VH3LFC.js.map} +0 -0
  677. /package/dist/cli-bundle/chunks/{chunk-H4IIJDE4.js.map → chunk-FDEVKXC4.js.map} +0 -0
  678. /package/dist/cli-bundle/chunks/{chunk-34EONI5F.js.map → chunk-HUYYMTGW.js.map} +0 -0
  679. /package/dist/cli-bundle/chunks/{chunk-CIIK67GW.js.map → chunk-IHXXUIXS.js.map} +0 -0
  680. /package/dist/cli-bundle/chunks/{chunk-SBQTAVJZ.js.map → chunk-JIP67N2K.js.map} +0 -0
  681. /package/dist/cli-bundle/chunks/{chunk-2T3JG6V4.js.map → chunk-KRASIL6M.js.map} +0 -0
  682. /package/dist/cli-bundle/chunks/{chunk-P77P2ILI.js.map → chunk-MLHX6DN5.js.map} +0 -0
  683. /package/dist/cli-bundle/chunks/{chunk-2CKH2LMV.js.map → chunk-OB3RJV5F.js.map} +0 -0
  684. /package/dist/cli-bundle/chunks/{chunk-FIGAZ4Y7.js.map → chunk-OUQ5JEFM.js.map} +0 -0
  685. /package/dist/cli-bundle/chunks/{chunk-NK3UPBVG.js.map → chunk-QE5UFCCO.js.map} +0 -0
  686. /package/dist/cli-bundle/chunks/{chunk-WM5ZVBPE.js.map → chunk-SJZTPVFT.js.map} +0 -0
  687. /package/dist/cli-bundle/chunks/{chunk-VAYA4XFX.js.map → chunk-V3KLX7U7.js.map} +0 -0
  688. /package/dist/cli-bundle/chunks/{chunk-2RDVQEWV.js.map → chunk-Z5BM2FKQ.js.map} +0 -0
  689. /package/dist/cli-bundle/chunks/{chunk-66MEDTUD.js.map → chunk-ZEATCVAC.js.map} +0 -0
  690. /package/dist/cli-bundle/chunks/{chunk-NCVCO3NZ.js.map → chunk-ZFIEEDTJ.js.map} +0 -0
  691. /package/dist/cli-bundle/chunks/{close-A3EMKBBY.js.map → close-37KEHLYM.js.map} +0 -0
  692. /package/dist/cli-bundle/chunks/{close-W56IOGYG.js.map → close-OP3LK7Z2.js.map} +0 -0
  693. /package/dist/cli-bundle/chunks/{create-QVGFYA2X.js.map → context-7ZEZV3BV.js.map} +0 -0
  694. /package/dist/cli-bundle/chunks/{create-IXY43O4H.js.map → context-XDI4DKKT.js.map} +0 -0
  695. /package/dist/cli-bundle/chunks/{extension-UTTQDUYI.js.map → create-DFMNBKBS.js.map} +0 -0
  696. /package/dist/cli-bundle/chunks/{extension-KCPUWSY2.js.map → create-J5Q2ELZT.js.map} +0 -0
  697. /package/dist/cli-bundle/chunks/{history-AJTXLT6S.js.map → extension-3LRYX7SW.js.map} +0 -0
  698. /package/dist/cli-bundle/chunks/{history-AK3E5Z3C.js.map → extension-GMVOIP4O.js.map} +0 -0
  699. /package/dist/cli-bundle/chunks/{gc-O5GUO3SU.js.map → gc-FULIVYR4.js.map} +0 -0
  700. /package/dist/cli-bundle/chunks/{gc-PYVVEELM.js.map → gc-MDGRR2SU.js.map} +0 -0
  701. /package/dist/cli-bundle/chunks/{history-redact-TWIYQV5J.js.map → history-5XUSLAJA.js.map} +0 -0
  702. /package/dist/cli-bundle/chunks/{history-redact-KUUUVUFM.js.map → history-X4OSES6K.js.map} +0 -0
  703. /package/dist/cli-bundle/chunks/{init-BNLVFPRG.js.map → history-redact-45YW65BK.js.map} +0 -0
  704. /package/dist/cli-bundle/chunks/{init-RCRKW5PL.js.map → history-redact-BVHWDXPR.js.map} +0 -0
  705. /package/dist/cli-bundle/chunks/{list-32U7BSKE.js.map → init-KO7CGIRQ.js.map} +0 -0
  706. /package/dist/cli-bundle/chunks/{list-ZEEOHLTQ.js.map → init-TRYJELH4.js.map} +0 -0
  707. /package/dist/cli-bundle/chunks/{restore-6K53WOWO.js.map → list-ROT7JF62.js.map} +0 -0
  708. /package/dist/cli-bundle/chunks/{restore-2ZKT6UDC.js.map → list-Y6AU5BJS.js.map} +0 -0
  709. /package/dist/cli-bundle/chunks/{search-6HOIVZDU.js.map → restore-DKMCLPI5.js.map} +0 -0
  710. /package/dist/cli-bundle/chunks/{search-ZWYEMASC.js.map → restore-IRAKSWIW.js.map} +0 -0
  711. /package/dist/cli-bundle/chunks/{test-NZF7OT2F.js.map → schema-OLT6LVKH.js.map} +0 -0
  712. /package/dist/cli-bundle/chunks/{test-QJXLKV26.js.map → schema-XJXKJQF5.js.map} +0 -0
  713. /package/dist/cli-bundle/chunks/{update-2XCQNOD6.js.map → search-CX5UMV4H.js.map} +0 -0
  714. /package/dist/cli-bundle/chunks/{update-IWUCXVH2.js.map → search-KP6H7COV.js.map} +0 -0
  715. /package/dist/cli-bundle/chunks/{telemetry-7DIGDQUO.js.map → telemetry-DIFPXCAT.js.map} +0 -0
  716. /package/dist/cli-bundle/chunks/{telemetry-FWEXSJLQ.js.map → telemetry-WTYFUPRL.js.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  nowIso
3
- } from "./chunk-P77P2ILI.js";
3
+ } from "./chunk-MLHX6DN5.js";
4
4
  import {
5
5
  EXIT_CODE,
6
6
  appendLineAtomic,
@@ -11,13 +11,13 @@ import {
11
11
  resolveTelemetryErrorCategory,
12
12
  writeFileAtomic,
13
13
  writeSettings
14
- } from "./chunk-MJTSZKK5.js";
14
+ } from "./chunk-SNUK7H5J.js";
15
15
 
16
16
  // dist/core/telemetry/observability.js
17
17
  !(function() {
18
18
  try {
19
19
  var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
20
- n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "4c03b7be-f7c0-5da3-ad78-cca945ab108c");
20
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "1a034a5f-bb30-5cea-8926-4d11eb3b9c5f");
21
21
  } catch (e2) {
22
22
  }
23
23
  })();
@@ -72,6 +72,45 @@ function normalizeErrorCode(errorCode2) {
72
72
  const normalized = errorCode2?.trim().toLowerCase();
73
73
  return normalized && normalized.length > 0 ? normalized : void 0;
74
74
  }
75
+ var TELEMETRY_ERROR_MESSAGE_CLASSIFIERS = [
76
+ { code: "unknown_command", matches: (message) => message.includes("unknown command") },
77
+ { code: "unknown_option", matches: (message) => message.includes("unknown option") },
78
+ {
79
+ code: "missing_required_option",
80
+ matches: (message) => message.includes("missing required options") || message.includes("missing required option")
81
+ },
82
+ { code: "missing_required_argument", matches: (message) => message.includes("missing required argument") },
83
+ { code: "no_update_fields", matches: (message) => message.includes("no update flags provided") },
84
+ {
85
+ code: "ownership_conflict",
86
+ matches: (message) => message.includes("is assigned to") && message.includes("use --force")
87
+ },
88
+ { code: "lock_conflict", matches: (message) => message.includes("is locked") },
89
+ {
90
+ code: "terminal_state_conflict",
91
+ matches: (message) => message.includes("already terminal") && message.includes("use --force")
92
+ },
93
+ { code: "tracker_not_initialized", matches: (message) => message.includes("tracker is not initialized") },
94
+ { code: "item_not_found", matches: (message) => message.includes(" not found") },
95
+ {
96
+ code: "close_through_update",
97
+ matches: (message) => message.includes('use "pm close <id> <text>" to close an item') || message.includes("invalid --status value") && message.includes('"closed"')
98
+ },
99
+ {
100
+ code: "invalid_argument_value",
101
+ matches: (message) => message.startsWith("invalid ") || message.includes(" must be ") || message.includes(" requires ")
102
+ },
103
+ {
104
+ code: "invalid_command_usage",
105
+ matches: (message) => message.includes("either as positional") && message.includes("not both")
106
+ }
107
+ ];
108
+ var TELEMETRY_EXIT_CODE_FALLBACKS = /* @__PURE__ */ new Map([
109
+ [EXIT_CODE.USAGE, "invalid_command_usage"],
110
+ [EXIT_CODE.NOT_FOUND, "item_not_found"],
111
+ [EXIT_CODE.CONFLICT, "lock_conflict"],
112
+ [EXIT_CODE.DEPENDENCY_FAILED, "dependency_failed"]
113
+ ]);
75
114
  function deriveTelemetryCommandTaxonomy(commandPath) {
76
115
  const normalizedPath = normalizeCommandPath(commandPath);
77
116
  const tokens = normalizedPath.length > 0 ? normalizedPath.split(" ") : ["<unknown>"];
@@ -108,57 +147,14 @@ function inferTelemetryErrorCode(params) {
108
147
  return explicit;
109
148
  }
110
149
  const message = (params.errorMessage ?? "").trim().toLowerCase();
111
- if (message.includes("unknown command")) {
112
- return "unknown_command";
113
- }
114
- if (message.includes("unknown option")) {
115
- return "unknown_option";
116
- }
117
- if (message.includes("missing required options") || message.includes("missing required option")) {
118
- return "missing_required_option";
119
- }
120
- if (message.includes("missing required argument")) {
121
- return "missing_required_argument";
122
- }
123
- if (message.includes("no update flags provided")) {
124
- return "no_update_fields";
125
- }
126
- if (message.includes("is assigned to") && message.includes("use --force")) {
127
- return "ownership_conflict";
128
- }
129
- if (message.includes("is locked")) {
130
- return "lock_conflict";
131
- }
132
- if (message.includes("already terminal") && message.includes("use --force")) {
133
- return "terminal_state_conflict";
134
- }
135
- if (message.includes("tracker is not initialized")) {
136
- return "tracker_not_initialized";
137
- }
138
- if (message.includes(" not found")) {
139
- return "item_not_found";
140
- }
141
- if (message.includes('use "pm close <id> <text>" to close an item') || message.includes("invalid --status value") && message.includes('"closed"')) {
142
- return "close_through_update";
143
- }
144
- if (message.startsWith("invalid ") || message.includes(" must be ") || message.includes(" requires ")) {
145
- return "invalid_argument_value";
146
- }
147
- if (message.includes("either as positional") && message.includes("not both")) {
148
- return "invalid_command_usage";
150
+ for (const classifier of TELEMETRY_ERROR_MESSAGE_CLASSIFIERS) {
151
+ if (classifier.matches(message)) {
152
+ return classifier.code;
153
+ }
149
154
  }
150
155
  const exitCode = Number.isFinite(params.exitCode) ? Math.max(0, Math.trunc(params.exitCode)) : void 0;
151
- if (exitCode === EXIT_CODE.USAGE) {
152
- return "invalid_command_usage";
153
- }
154
- if (exitCode === EXIT_CODE.NOT_FOUND) {
155
- return "item_not_found";
156
- }
157
- if (exitCode === EXIT_CODE.CONFLICT) {
158
- return "lock_conflict";
159
- }
160
- if (exitCode === EXIT_CODE.DEPENDENCY_FAILED) {
161
- return "dependency_failed";
156
+ if (exitCode !== void 0) {
157
+ return TELEMETRY_EXIT_CODE_FALLBACKS.get(exitCode) ?? "command_failed";
162
158
  }
163
159
  return "command_failed";
164
160
  }
@@ -210,7 +206,7 @@ import path from "node:path";
210
206
  !(function() {
211
207
  try {
212
208
  var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
213
- n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "dbba82ab-8052-5828-babf-094b3f066810");
209
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "761a82c5-659b-5d4d-bc1a-0e93f36f8b56");
214
210
  } catch (e2) {
215
211
  }
216
212
  })();
@@ -1543,6 +1539,9 @@ function scheduleTelemetryFlush(globalPmRoot, endpoint, retentionDays) {
1543
1539
  [PM_TELEMETRY_FLUSH_CHILD_ENV]: "1"
1544
1540
  }
1545
1541
  });
1542
+ child.on("error", () => {
1543
+ releaseTelemetryFlushSpawnGate(globalPmRoot);
1544
+ });
1546
1545
  child.unref();
1547
1546
  } catch {
1548
1547
  releaseTelemetryFlushSpawnGate(globalPmRoot);
@@ -1771,4 +1770,4 @@ export {
1771
1770
  finishTelemetryCommand,
1772
1771
  emitTelemetryErrorEvent
1773
1772
  };
1774
- //# sourceMappingURL=chunk-55ISXAQH.js.map
1773
+ //# sourceMappingURL=chunk-IDYCAK35.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../../core/telemetry/observability.ts", "../../../../../../../../core/telemetry/runtime.ts"],
4
+ "sourcesContent": ["/**\n * @module core/telemetry/observability\n *\n * Captures consent-aware telemetry and observability events for Observability.\n */\nimport { EXIT_CODE, type TelemetryErrorCategory } from \"../shared/constants.js\";\n\n/**\n * Restricts telemetry resolution stage values accepted by command, SDK, and storage contracts.\n */\nexport type TelemetryResolutionStage = \"parse\" | \"preflight\" | \"execute\" | \"unknown\";\n\n/**\n * Restricts telemetry command resolution values accepted by command, SDK, and storage contracts.\n */\nexport type TelemetryCommandResolution =\n | \"success\"\n | \"nonexistent_command\"\n | \"invalid_option\"\n | \"missing_required_option\"\n | \"missing_required_argument\"\n | \"invalid_usage\"\n | \"validation_failed\"\n | \"health_findings\"\n | \"validation_findings\"\n | \"conflict\"\n | \"runtime_failed\"\n | \"unknown_failed\";\n\n/**\n * Documents the telemetry command taxonomy payload exchanged by command, SDK, and package integrations.\n */\nexport interface TelemetryCommandTaxonomy {\n command_path: string;\n command_root: string;\n command_leaf: string;\n command_depth: number;\n command_family: \"setup\" | \"query\" | \"mutation\" | \"testing\" | \"extension\" | \"diagnostics\" | \"other\";\n}\n\ninterface InferTelemetryErrorCodeParams {\n ok: boolean;\n errorCode?: string;\n errorMessage?: string;\n exitCode?: number;\n}\n\ninterface TelemetryErrorMessageClassifier {\n code: string;\n matches: (message: string) => boolean;\n}\n\nconst SETUP_ROOT_COMMANDS = new Set([\"init\", \"config\", \"completion\", \"completion-statuses\", \"completion-tags\", \"completion-types\"]);\nconst QUERY_ROOT_COMMANDS = new Set([\n \"list\",\n \"list-all\",\n \"list-open\",\n \"list-in-progress\",\n \"list-blocked\",\n \"list-closed\",\n \"list-canceled\",\n \"list-draft\",\n \"search\",\n \"get\",\n \"context\",\n \"calendar\",\n \"history\",\n \"activity\",\n \"aggregate\",\n \"deps\",\n \"contracts\",\n \"stats\",\n \"dedupe-audit\",\n]);\nconst MUTATION_ROOT_COMMANDS = new Set([\n \"create\",\n \"update\",\n \"update-many\",\n \"close-many\",\n \"append\",\n \"close\",\n \"delete\",\n \"restore\",\n \"claim\",\n \"release\",\n \"comments\",\n \"notes\",\n \"learnings\",\n \"files\",\n \"docs\",\n \"start-task\",\n \"pause-task\",\n \"close-task\",\n]);\nconst TESTING_ROOT_COMMANDS = new Set([\"test\", \"test-all\", \"test-runs\", \"test-verify\", \"trace-test\", \"test-ping\"]);\nconst DIAGNOSTICS_ROOT_COMMANDS = new Set([\"health\", \"validate\", \"normalize\", \"reindex\", \"gc\", \"telemetry\", \"extension-doctor\"]);\n\nfunction normalizeCommandPath(commandPath: string): string {\n return commandPath\n .trim()\n .replaceAll(/\\s+/g, \" \")\n .toLowerCase();\n}\n\nfunction normalizeErrorCode(errorCode: string | undefined): string | undefined {\n const normalized = errorCode?.trim().toLowerCase();\n return normalized && normalized.length > 0 ? normalized : undefined;\n}\n\nconst TELEMETRY_ERROR_MESSAGE_CLASSIFIERS: readonly TelemetryErrorMessageClassifier[] = [\n { code: \"unknown_command\", matches: (message) => message.includes(\"unknown command\") },\n { code: \"unknown_option\", matches: (message) => message.includes(\"unknown option\") },\n {\n code: \"missing_required_option\",\n matches: (message) => message.includes(\"missing required options\") || message.includes(\"missing required option\"),\n },\n { code: \"missing_required_argument\", matches: (message) => message.includes(\"missing required argument\") },\n { code: \"no_update_fields\", matches: (message) => message.includes(\"no update flags provided\") },\n {\n code: \"ownership_conflict\",\n matches: (message) => message.includes(\"is assigned to\") && message.includes(\"use --force\"),\n },\n { code: \"lock_conflict\", matches: (message) => message.includes(\"is locked\") },\n {\n code: \"terminal_state_conflict\",\n matches: (message) => message.includes(\"already terminal\") && message.includes(\"use --force\"),\n },\n { code: \"tracker_not_initialized\", matches: (message) => message.includes(\"tracker is not initialized\") },\n { code: \"item_not_found\", matches: (message) => message.includes(\" not found\") },\n {\n code: \"close_through_update\",\n matches: (message) =>\n message.includes(\"use \\\"pm close <id> <text>\\\" to close an item\") ||\n (message.includes(\"invalid --status value\") && message.includes(\"\\\"closed\\\"\")),\n },\n {\n code: \"invalid_argument_value\",\n matches: (message) => message.startsWith(\"invalid \") || message.includes(\" must be \") || message.includes(\" requires \"),\n },\n {\n code: \"invalid_command_usage\",\n matches: (message) => message.includes(\"either as positional\") && message.includes(\"not both\"),\n },\n];\n\nconst TELEMETRY_EXIT_CODE_FALLBACKS: ReadonlyMap<number, string> = new Map([\n [EXIT_CODE.USAGE, \"invalid_command_usage\"],\n [EXIT_CODE.NOT_FOUND, \"item_not_found\"],\n [EXIT_CODE.CONFLICT, \"lock_conflict\"],\n [EXIT_CODE.DEPENDENCY_FAILED, \"dependency_failed\"],\n]);\n\n/**\n * Implements derive telemetry command taxonomy for the public runtime surface of this module.\n */\nexport function deriveTelemetryCommandTaxonomy(commandPath: string): TelemetryCommandTaxonomy {\n const normalizedPath = normalizeCommandPath(commandPath);\n // tokens always has at least one element (the fallback [\"<unknown>\"]), so the\n // first/last lookups are never undefined.\n const tokens = normalizedPath.length > 0 ? normalizedPath.split(\" \") : [\"<unknown>\"];\n const root = tokens[0] as string;\n const leaf = tokens[tokens.length - 1] as string;\n\n let family: TelemetryCommandTaxonomy[\"command_family\"] = \"other\";\n if (SETUP_ROOT_COMMANDS.has(root)) {\n family = \"setup\";\n } else if (QUERY_ROOT_COMMANDS.has(root)) {\n family = \"query\";\n } else if (MUTATION_ROOT_COMMANDS.has(root)) {\n family = \"mutation\";\n } else if (TESTING_ROOT_COMMANDS.has(root)) {\n family = \"testing\";\n } else if (root === \"extension\") {\n family = \"extension\";\n } else if (DIAGNOSTICS_ROOT_COMMANDS.has(root)) {\n family = \"diagnostics\";\n }\n\n return {\n command_path: normalizedPath.length > 0 ? normalizedPath : \"<unknown>\",\n command_root: root,\n command_leaf: leaf,\n command_depth: tokens.length,\n command_family: family,\n };\n}\n\n/**\n * Implements infer telemetry error code for the public runtime surface of this module.\n */\nexport function inferTelemetryErrorCode(params: InferTelemetryErrorCodeParams): string | undefined {\n if (params.ok) {\n return undefined;\n }\n\n const explicit = normalizeErrorCode(params.errorCode);\n if (explicit) {\n return explicit;\n }\n\n const message = (params.errorMessage ?? \"\").trim().toLowerCase();\n // NOTE: A \"strict create mode requires concrete values for --\" message is always\n // classified as invalid_argument_value by the ordered ` requires ` classifier,\n // so a dedicated branch would be unreachable and is intentionally omitted.\n for (const classifier of TELEMETRY_ERROR_MESSAGE_CLASSIFIERS) {\n if (classifier.matches(message)) {\n return classifier.code;\n }\n }\n\n const exitCode = Number.isFinite(params.exitCode) ? Math.max(0, Math.trunc(params.exitCode as number)) : undefined;\n if (exitCode !== undefined) {\n return TELEMETRY_EXIT_CODE_FALLBACKS.get(exitCode) ?? \"command_failed\";\n }\n return \"command_failed\";\n}\n\n/**\n * Implements derive telemetry command resolution for the public runtime surface of this module.\n */\nexport function deriveTelemetryCommandResolution(params: {\n ok: boolean;\n errorCode?: string;\n errorCategory?: TelemetryErrorCategory;\n}): TelemetryCommandResolution {\n if (params.ok) {\n return \"success\";\n }\n\n const normalizedCode = normalizeErrorCode(params.errorCode);\n if (normalizedCode === \"unknown_command\") {\n return \"nonexistent_command\";\n }\n if (normalizedCode === \"unknown_option\") {\n return \"invalid_option\";\n }\n if (normalizedCode === \"missing_required_option\") {\n return \"missing_required_option\";\n }\n if (normalizedCode === \"missing_required_argument\") {\n return \"missing_required_argument\";\n }\n if (normalizedCode === \"health_findings\") {\n return \"health_findings\";\n }\n if (normalizedCode === \"validation_findings\") {\n return \"validation_findings\";\n }\n\n if (params.errorCategory === \"usage\") {\n return \"invalid_usage\";\n }\n if (params.errorCategory === \"validation\") {\n return \"validation_failed\";\n }\n if (params.errorCategory === \"conflict\") {\n return \"conflict\";\n }\n if (params.errorCategory === \"runtime\") {\n return \"runtime_failed\";\n }\n return \"unknown_failed\";\n}\n", "/**\n * @module core/telemetry/runtime\n *\n * Captures consent-aware telemetry and observability events for Runtime.\n */\nimport crypto from \"node:crypto\";\nimport { spawn } from \"node:child_process\";\nimport { mkdirSync, rmSync, statSync } from \"node:fs\";\nimport { mkdir, readdir, rm, stat } from \"node:fs/promises\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport type { GlobalOptions } from \"../shared/command-types.js\";\nimport { resolvePmPackageRootFromModule } from \"../packages/root.js\";\nimport { appendLineAtomic, readFileIfExists, writeFileAtomic } from \"../fs/fs-utils.js\";\nimport { resolveTelemetryErrorCategory, type TelemetryErrorCategory } from \"../shared/constants.js\";\nimport { nowIso } from \"../shared/time.js\";\nimport { resolveGlobalPmRoot } from \"../store/paths.js\";\nimport { readSettings, writeSettings } from \"../store/settings.js\";\nimport {\n deriveTelemetryCommandResolution,\n deriveTelemetryCommandTaxonomy,\n inferTelemetryErrorCode,\n type TelemetryCommandResolution,\n type TelemetryCommandTaxonomy,\n type TelemetryResolutionStage,\n} from \"./observability.js\";\n\nconst TELEMETRY_QUEUE_RELATIVE_PATH = path.join(\"runtime\", \"telemetry\", \"events.jsonl\");\nconst TELEMETRY_STATE_RELATIVE_PATH = path.join(\"runtime\", \"telemetry\", \"state.json\");\nconst TELEMETRY_OTEL_SPANS_RELATIVE_PATH = path.join(\"runtime\", \"telemetry\", \"otel-spans.jsonl\");\n// Kept small so a worst-case batch against a blackholed collector\n// (TELEMETRY_OTEL_SPANS_FLUSH_BATCH_SIZE * TELEMETRY_HTTP_TIMEOUT_MS plus the\n// preceding event flush) stays well under TELEMETRY_FLUSH_LOCK_STALE_MS (60s).\n// Otherwise a later command could treat the still-held flush lock as stale and\n// start a second concurrent worker.\nconst TELEMETRY_OTEL_SPANS_FLUSH_BATCH_SIZE = 8;\nconst TELEMETRY_OTEL_SPANS_MAX_PENDING = 500;\nexport const TELEMETRY_SCHEMA_VERSION = 1;\nconst TELEMETRY_CLIENT_SCHEMA_VERSION = 1;\nconst TELEMETRY_FLUSH_BATCH_SIZE = 100;\nconst TELEMETRY_MAX_RETRY_DELAY_MS = 3_600_000;\nconst TELEMETRY_RETRY_BASE_DELAY_MS = 30_000;\nconst TELEMETRY_HTTP_TIMEOUT_MS = 5_000;\nconst MILLISECONDS_PER_DAY = 86_400_000;\nconst TELEMETRY_MAX_EVENT_BYTES = 65_536;\nconst TELEMETRY_SANITIZE_MAX_DEPTH = 6;\nconst TELEMETRY_SANITIZE_MAX_ARRAY_ITEMS = 20;\nexport const TELEMETRY_MAX_QUEUE_ENTRY_ATTEMPTS = 15;\nconst TELEMETRY_RESULT_PREVIEW_MAX_BYTES = 8_192;\nconst TELEMETRY_QUEUE_REWRITE_RETRY_DELAYS_MS = [25, 50, 100, 200] as const;\nconst TELEMETRY_QUEUE_TMP_ORPHAN_MAX_AGE_MS = 60 * 60 * 1000;\nconst TELEMETRY_FLUSH_LOCK_STALE_MS = 60_000;\nconst TELEMETRY_FLUSH_SPAWN_LOCK_STALE_MS = 60_000;\nconst OTEL_TRACES_ENDPOINT_ENV = \"OTEL_EXPORTER_OTLP_TRACES_ENDPOINT\";\nconst OTEL_BASE_ENDPOINT_ENV = \"OTEL_EXPORTER_OTLP_ENDPOINT\";\nconst OTEL_SERVICE_NAME_ENV = \"OTEL_SERVICE_NAME\";\nconst PM_TELEMETRY_DISABLED_ENV = \"PM_TELEMETRY_DISABLED\";\nconst PM_NO_TELEMETRY_ENV = \"PM_NO_TELEMETRY\";\nconst PM_TELEMETRY_DISABLED_VALUES = new Set([\"1\", \"true\", \"yes\", \"on\"]);\nconst PM_TELEMETRY_OTEL_DISABLED_ENV = \"PM_TELEMETRY_OTEL_DISABLED\";\nconst PM_TELEMETRY_OTEL_DISABLED_VALUES = new Set([\"1\", \"true\", \"yes\", \"on\"]);\nconst PM_TELEMETRY_INLINE_FLUSH_ENV = \"PM_TELEMETRY_INLINE_FLUSH\";\nconst PM_TELEMETRY_FLUSH_CHILD_ENV = \"PM_TELEMETRY_FLUSH_CHILD\";\nconst PM_TELEMETRY_SOURCE_CONTEXT_ENV = \"PM_TELEMETRY_SOURCE_CONTEXT\";\nconst PM_AUTHOR_ENV = \"PM_AUTHOR\";\nexport const PM_TELEMETRY_SOURCE_CONTEXT_VALUES = [\"user\", \"automation\", \"test\", \"dogfood\", \"audit_smoke\"] as const;\n\nlet _lastFlushPromise: Promise<void> = Promise.resolve();\nlet _queueMutationPromise: Promise<unknown> = Promise.resolve();\n\n/** Wait for the most recent background flush to settle. Test-only helper. */\nexport async function waitForPendingFlush(): Promise<void> {\n await _lastFlushPromise;\n await _queueMutationPromise;\n}\nconst PM_TELEMETRY_SOURCE_CONTEXT_SET = new Set<string>(PM_TELEMETRY_SOURCE_CONTEXT_VALUES);\nconst BOOLEAN_TRUE_VALUES = new Set([\"1\", \"true\", \"yes\", \"on\"]);\nconst PROCESS_SESSION_ID = crypto.randomUUID();\n\nconst SENSITIVE_KEYWORDS = [\n \"token\",\n \"secret\",\n \"password\",\n \"passwd\",\n \"api_key\",\n \"apikey\",\n \"authorization\",\n \"cookie\",\n \"session\",\n \"credentials\",\n \"bearer\",\n] as const;\nconst SENSITIVE_INLINE_KEY_PATTERN =\n \"(?:token|secret|password|passwd|api[_-]?key|apikey|authorization|cookie|session|credentials|bearer)\";\nconst INLINE_SENSITIVE_ASSIGNMENT_PATTERN = new RegExp(\n `\\\\b(${SENSITIVE_INLINE_KEY_PATTERN})\\\\s*([:=])\\\\s*([^\\\\s,;]+)`,\n \"giu\",\n);\nconst INLINE_SENSITIVE_FLAG_PATTERN = new RegExp(\n `(--${SENSITIVE_INLINE_KEY_PATTERN})(=|\\\\s+)([^\\\\s,;]+)`,\n \"giu\",\n);\nconst ABSOLUTE_PATH_TOKEN_PATTERN = /(^|[\\s\"'`(=])\\/(?:[^\\s\"'`),;]+)/g;\nconst BEARER_TOKEN_PATTERN = /bearer\\s+[a-z0-9._=-]+/giu;\nconst PRIVATE_IP_PATTERN =\n /\\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;\n\ninterface TelemetryEvent {\n schema_version: number;\n event_id: string;\n event_type: \"command_start\" | \"command_finish\" | \"command_error\";\n occurred_at: string;\n installation_id: string;\n session_id: string;\n command: string;\n payload: Record<string, unknown>;\n}\n\ninterface QueuedTelemetryEvent {\n client_schema_version?: number;\n event: TelemetryEvent;\n attempts: number;\n last_attempt_at?: string;\n next_attempt_after?: string;\n}\n\ninterface TelemetryRuntimeState {\n last_attempted_flush_at?: string;\n last_successful_flush_at?: string;\n last_failed_flush_at?: string;\n last_failed_flush_error?: string;\n endpoint?: string;\n queue_entries?: number;\n pending_otel_spans?: number;\n last_otel_attempt_at?: string;\n last_otel_success_at?: string;\n last_otel_failure_at?: string;\n last_otel_failure_error?: string;\n}\n\n/**\n * A built OpenTelemetry span request awaiting export. Persisted to a small,\n * bounded queue so the OTLP trace POST happens in the detached, unref'd flush\n * worker instead of inline in the foreground command. This keeps the CLI process\n * from staying alive while a connecting socket to an unreachable traces endpoint\n * drains its 5s timeout (the GH-209 root cause). `payload` is the fully built\n * OTLP resourceSpans body; `endpoint` is the per-span traces endpoint.\n */\ninterface PendingOtelSpan {\n /**\n * Stable id used to reconcile the queue after the network flush: the worker\n * re-reads the file and removes/updates only the spans it processed, by id, so\n * spans appended by a concurrent foreground process during the flush are never\n * overwritten. Mirrors the event-queue's event_id-based reconciliation.\n */\n id: string;\n endpoint: string;\n payload: unknown;\n enqueued_at: string;\n attempts: number;\n next_attempt_after?: string;\n}\n\ntype TelemetryCaptureLevel = \"minimal\" | \"redacted\" | \"max\";\ntype TelemetrySourceContext = (typeof PM_TELEMETRY_SOURCE_CONTEXT_VALUES)[number];\ntype TelemetrySourceContextSource = \"inferred\" | \"env_override\";\n\ninterface ResolvedTelemetrySourceContext {\n source_context: TelemetrySourceContext;\n source_context_source: TelemetrySourceContextSource;\n}\n\n/**\n * Documents the active telemetry command payload exchanged by command, SDK, and package integrations.\n */\nexport interface ActiveTelemetryCommand {\n started_at: string;\n started_at_ms: number;\n command: string;\n command_taxonomy: TelemetryCommandTaxonomy;\n pm_version: string;\n source_context: TelemetrySourceContext;\n source_context_source: TelemetrySourceContextSource;\n installation_id: string;\n pm_root_hash: string;\n cwd_hash: string;\n endpoint: string;\n retention_days: number;\n global_pm_root: string;\n capture_level: TelemetryCaptureLevel;\n otel_traces_endpoint?: string;\n otel_trace_id?: string;\n otel_span_id?: string;\n}\n\n/**\n * Documents the telemetry command context payload exchanged by command, SDK, and package integrations.\n */\nexport interface TelemetryCommandContext {\n command: string;\n pm_version: string;\n args: string[];\n options: Record<string, unknown>;\n global: GlobalOptions;\n pm_root: string;\n}\n\n/**\n * Documents the telemetry command outcome payload exchanged by command, SDK, and package integrations.\n */\nexport interface TelemetryCommandOutcome {\n ok: boolean;\n error?: string;\n result?: unknown;\n exit_code?: number;\n error_code?: string;\n error_category?: TelemetryErrorCategory;\n command_resolution?: TelemetryCommandResolution;\n resolution_stage?: TelemetryResolutionStage;\n}\n\n/**\n * Documents the telemetry error event context payload exchanged by command, SDK, and package integrations.\n */\nexport interface TelemetryErrorEventContext {\n command: string;\n args: string[];\n options: Record<string, unknown>;\n global: GlobalOptions;\n pm_version: string;\n pm_root: string;\n error_code: string;\n error_message: string;\n exit_code: number;\n error_category?: TelemetryErrorCategory;\n command_resolution?: TelemetryCommandResolution;\n resolution_stage?: TelemetryResolutionStage;\n}\n\n\nfunction queuePath(globalPmRoot: string): string {\n return path.join(globalPmRoot, TELEMETRY_QUEUE_RELATIVE_PATH);\n}\n\nfunction otelSpansQueuePath(globalPmRoot: string): string {\n return path.join(globalPmRoot, TELEMETRY_OTEL_SPANS_RELATIVE_PATH);\n}\n\nfunction telemetryRuntimeDirectory(globalPmRoot: string): string {\n return path.dirname(queuePath(globalPmRoot));\n}\n\nfunction runtimeStatePath(globalPmRoot: string): string {\n return path.join(globalPmRoot, TELEMETRY_STATE_RELATIVE_PATH);\n}\n\nfunction flushLockPath(globalPmRoot: string): string {\n return path.join(globalPmRoot, \"runtime\", \"telemetry\", \"flush.lock\");\n}\n\nfunction flushSpawnLockPath(globalPmRoot: string): string {\n return path.join(globalPmRoot, \"runtime\", \"telemetry\", \"flush.spawn.lock\");\n}\n\nfunction telemetryFlushRunnerPath(): string {\n return path.join(resolvePmPackageRootFromModule(import.meta.url, [\"../../..\"]), \"dist\", \"cli\", \"telemetry-flush.js\");\n}\n\nfunction shouldFlushInline(): boolean {\n if (parseBooleanTrueLike(process.env[PM_TELEMETRY_INLINE_FLUSH_ENV])) {\n return true;\n }\n if (parseBooleanTrueLike(process.env[PM_TELEMETRY_FLUSH_CHILD_ENV])) {\n return true;\n }\n const nodeEnv = (process.env.NODE_ENV ?? \"\").trim().toLowerCase();\n return typeof process.env.VITEST === \"string\" || typeof process.env.VITEST_WORKER_ID === \"string\" || nodeEnv === \"test\";\n}\n\nasync function readRuntimeState(globalPmRoot: string): Promise<TelemetryRuntimeState> {\n const raw = await readFileIfExists(runtimeStatePath(globalPmRoot));\n if (!raw || raw.trim().length === 0) {\n return {};\n }\n try {\n const parsed = JSON.parse(raw) as TelemetryRuntimeState;\n if (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) {\n return {};\n }\n return parsed;\n } catch {\n return {};\n }\n}\n\nasync function writeRuntimeState(globalPmRoot: string, patch: TelemetryRuntimeState): Promise<void> {\n try {\n const current = await readRuntimeState(globalPmRoot);\n const next: TelemetryRuntimeState = {\n ...current,\n ...patch,\n };\n const normalized = Object.fromEntries(\n Object.entries(next)\n .filter(([, value]) => value !== undefined)\n .sort((left, right) => left[0].localeCompare(right[0])),\n );\n await writeFileAtomic(runtimeStatePath(globalPmRoot), `${JSON.stringify(normalized, null, 2)}\\n`);\n } catch {\n // Runtime state persistence is best effort and must not block command execution.\n }\n}\n\nfunction isSensitiveKey(key: string): boolean {\n const normalized = key.trim().toLowerCase().replaceAll(\"-\", \"_\").replaceAll(/[^a-z0-9_]+/g, \"_\");\n const tokens = normalized.split(\"_\").filter((token) => token.length > 0);\n return SENSITIVE_KEYWORDS.some(\n (keyword) => normalized === keyword || normalized.endsWith(`_${keyword}`) || tokens.includes(keyword),\n );\n}\n\nfunction redactInlineSensitiveAssignments(input: string): string {\n const withoutAssignments = input.replaceAll(\n INLINE_SENSITIVE_ASSIGNMENT_PATTERN,\n (_match: string, key: string, delimiter: string): string => `${key}${delimiter}[redacted]`,\n );\n return withoutAssignments.replaceAll(\n INLINE_SENSITIVE_FLAG_PATTERN,\n (_match: string, flag: string, delimiter: string): string => `${flag}${delimiter}[redacted]`,\n );\n}\n\nfunction redactAbsolutePathTokens(input: string): string {\n return input.replaceAll(\n ABSOLUTE_PATH_TOKEN_PATTERN,\n (_match: string, prefix: string): string => `${prefix}[redacted_path]`,\n );\n}\n\nfunction isAsciiLetterOrDigitCode(code: number): boolean {\n const isUpper = code >= 65 && code <= 90;\n const isLower = code >= 97 && code <= 122;\n const isDigit = code >= 48 && code <= 57;\n return isUpper || isLower || isDigit;\n}\n\nfunction isEmailLocalCharacter(character: string | undefined): boolean {\n if (!character) {\n return false;\n }\n const code = character.charCodeAt(0);\n if (isAsciiLetterOrDigitCode(code)) {\n return true;\n }\n return character === \".\" || character === \"_\" || character === \"%\" || character === \"+\" || character === \"-\";\n}\n\nfunction isEmailDomainCharacter(character: string | undefined): boolean {\n if (!character) {\n return false;\n }\n const code = character.charCodeAt(0);\n if (isAsciiLetterOrDigitCode(code)) {\n return true;\n }\n return character === \".\" || character === \"-\";\n}\n\nfunction looksLikeEmailToken(token: string): boolean {\n const atIndex = token.indexOf(\"@\");\n if (atIndex <= 0 || atIndex !== token.lastIndexOf(\"@\") || atIndex === token.length - 1) {\n return false;\n }\n const localPart = token.slice(0, atIndex);\n const domainPart = token.slice(atIndex + 1);\n const lastDot = domainPart.lastIndexOf(\".\");\n if (lastDot <= 0 || lastDot === domainPart.length - 1) {\n return false;\n }\n if (domainPart.length - (lastDot + 1) < 2) {\n return false;\n }\n for (const character of localPart) {\n if (!isEmailLocalCharacter(character)) {\n return false;\n }\n }\n for (const character of domainPart) {\n if (!isEmailDomainCharacter(character)) {\n return false;\n }\n }\n return true;\n}\n\nfunction redactEmailTokens(input: string): string {\n let redacted = \"\";\n let cursor = 0;\n while (cursor < input.length) {\n const atIndex = input.indexOf(\"@\", cursor);\n if (atIndex < 0) {\n redacted += input.slice(cursor);\n break;\n }\n let start = atIndex - 1;\n while (start >= cursor && isEmailLocalCharacter(input[start])) {\n start -= 1;\n }\n start += 1;\n let end = atIndex + 1;\n while (end < input.length && isEmailDomainCharacter(input[end])) {\n end += 1;\n }\n const candidate = input.slice(start, end);\n if (looksLikeEmailToken(candidate)) {\n redacted += input.slice(cursor, start);\n redacted += \"[redacted_email]\";\n cursor = end;\n continue;\n }\n redacted += input.slice(cursor, atIndex + 1);\n cursor = atIndex + 1;\n }\n return redacted;\n}\n\nfunction sanitizeCommonSensitiveTokens(input: string): string {\n const withoutEmails = redactEmailTokens(input);\n const withoutBearer = withoutEmails.replaceAll(BEARER_TOKEN_PATTERN, \"bearer [redacted_token]\");\n return withoutBearer.replaceAll(PRIVATE_IP_PATTERN, \"[redacted_ip]\");\n}\n\nfunction sanitizeStringRedacted(input: string): string {\n const withoutCommonSensitiveTokens = sanitizeCommonSensitiveTokens(input);\n const withoutInlineSecrets = redactInlineSensitiveAssignments(withoutCommonSensitiveTokens);\n const withoutAbsolutePaths = redactAbsolutePathTokens(withoutInlineSecrets);\n const trimmed = withoutAbsolutePaths.trim();\n if (trimmed.startsWith(\"/\") && trimmed.length > 1) {\n return \"[redacted_path]\";\n }\n if (withoutAbsolutePaths.length > 512) {\n return `${withoutAbsolutePaths.slice(0, 509)}...`;\n }\n return withoutAbsolutePaths;\n}\n\nfunction sanitizeStringMax(input: string): string {\n const withoutCommonSensitiveTokens = sanitizeCommonSensitiveTokens(input);\n const withoutInlineSecrets = redactInlineSensitiveAssignments(withoutCommonSensitiveTokens);\n const withoutAbsolutePaths = redactAbsolutePathTokens(withoutInlineSecrets);\n const trimmed = withoutAbsolutePaths.trim();\n if (trimmed.startsWith(\"/\") && trimmed.length > 1) {\n return \"[redacted_path]\";\n }\n if (withoutAbsolutePaths.length > 2048) {\n return `${withoutAbsolutePaths.slice(0, 2045)}...`;\n }\n return withoutAbsolutePaths;\n}\n\nfunction sanitizeString(input: string, captureLevel: Exclude<TelemetryCaptureLevel, \"minimal\"> = \"redacted\"): string {\n if (captureLevel === \"max\") {\n return sanitizeStringMax(input);\n }\n return sanitizeStringRedacted(input);\n}\n\nfunction sanitizeValue(\n value: unknown,\n keyHint?: string,\n captureLevel: Exclude<TelemetryCaptureLevel, \"minimal\"> = \"redacted\",\n depth = 0,\n): unknown {\n if (keyHint && isSensitiveKey(keyHint)) {\n return \"[redacted]\";\n }\n if (value === null || value === undefined) {\n return value;\n }\n if (typeof value === \"string\") {\n return sanitizeString(value, captureLevel);\n }\n if (typeof value === \"number\" || typeof value === \"boolean\") {\n return value;\n }\n if (depth >= TELEMETRY_SANITIZE_MAX_DEPTH) {\n return \"[depth_truncated]\";\n }\n if (Array.isArray(value)) {\n return value.slice(0, TELEMETRY_SANITIZE_MAX_ARRAY_ITEMS).map((entry) => sanitizeValue(entry, undefined, captureLevel, depth + 1));\n }\n if (typeof value === \"object\") {\n const record = value as Record<string, unknown>;\n const sanitized: Record<string, unknown> = {};\n for (const [key, nested] of Object.entries(record)) {\n sanitized[key] = sanitizeValue(nested, key, captureLevel, depth + 1);\n }\n return sanitized;\n }\n return String(value);\n}\n\nfunction sanitizeCommandArgs(\n args: string[],\n captureLevel: Exclude<TelemetryCaptureLevel, \"minimal\"> = \"redacted\",\n): string[] {\n const sanitized: string[] = [];\n let nextIsSensitiveValue = false;\n for (const rawArg of args) {\n const arg = sanitizeString(rawArg, captureLevel);\n if (nextIsSensitiveValue) {\n sanitized.push(\"[redacted]\");\n nextIsSensitiveValue = false;\n continue;\n }\n if (arg.startsWith(\"--\")) {\n const withoutPrefix = arg.slice(2);\n const delimiterIndex = withoutPrefix.indexOf(\"=\");\n if (delimiterIndex >= 0) {\n const key = withoutPrefix.slice(0, delimiterIndex);\n const value = withoutPrefix.slice(delimiterIndex + 1);\n if (isSensitiveKey(key)) {\n sanitized.push(`--${key}=[redacted]`);\n } else {\n sanitized.push(`--${key}=${sanitizeString(value, captureLevel)}`);\n }\n continue;\n }\n if (isSensitiveKey(withoutPrefix)) {\n sanitized.push(`--${withoutPrefix}`);\n nextIsSensitiveValue = true;\n continue;\n }\n }\n sanitized.push(arg);\n }\n return sanitized;\n}\n\nfunction normalizeCaptureLevel(value: string | undefined): TelemetryCaptureLevel {\n const normalized = value?.trim().toLowerCase();\n if (normalized === \"minimal\" || normalized === \"redacted\" || normalized === \"max\") {\n return normalized;\n }\n return \"redacted\";\n}\n\nfunction parseBooleanTrueLike(value: string | undefined): boolean {\n return BOOLEAN_TRUE_VALUES.has((value ?? \"\").trim().toLowerCase());\n}\n\nfunction normalizePmVersion(value: string | undefined): string {\n const trimmed = typeof value === \"string\" ? value.trim() : \"\";\n return trimmed.length > 0 ? trimmed : \"0.0.0\";\n}\n\nfunction normalizeTelemetryErrorCode(value: string | undefined): string | undefined {\n const normalized = value?.trim();\n return normalized && normalized.length > 0 ? normalized : undefined;\n}\n\nfunction normalizeTelemetryExitCode(exitCode: number | undefined, ok: boolean): number {\n if (Number.isFinite(exitCode)) {\n return Math.max(0, Math.trunc(exitCode as number));\n }\n return ok ? 0 : 1;\n}\n\nfunction normalizeTelemetryErrorCategory(params: {\n ok: boolean;\n errorCode?: string;\n errorCategory?: TelemetryErrorCategory;\n}): TelemetryErrorCategory | undefined {\n if (params.ok) {\n return undefined;\n }\n if (typeof params.errorCategory === \"string\" && params.errorCategory.trim().length > 0) {\n return params.errorCategory;\n }\n if (typeof params.errorCode === \"string\" && params.errorCode.trim().length > 0) {\n return resolveTelemetryErrorCategory(params.errorCode);\n }\n return \"unknown\";\n}\n\nfunction resolveTelemetrySourceContext(globalOptions: GlobalOptions): ResolvedTelemetrySourceContext {\n const override = (process.env[PM_TELEMETRY_SOURCE_CONTEXT_ENV] ?? \"\").trim().toLowerCase();\n if (PM_TELEMETRY_SOURCE_CONTEXT_SET.has(override)) {\n return {\n source_context: override as TelemetrySourceContext,\n source_context_source: \"env_override\",\n };\n }\n const nodeEnv = (process.env.NODE_ENV ?? \"\").trim().toLowerCase();\n if (typeof process.env.VITEST === \"string\" || typeof process.env.VITEST_WORKER_ID === \"string\" || nodeEnv === \"test\") {\n return {\n source_context: \"test\",\n source_context_source: \"inferred\",\n };\n }\n const nonTty = process.stdin.isTTY !== true || process.stdout.isTTY !== true;\n const ci = parseBooleanTrueLike(process.env.CI);\n const scriptLikeMode = globalOptions.json === true || globalOptions.quiet === true;\n if (nonTty || ci || scriptLikeMode) {\n return {\n source_context: \"automation\",\n source_context_source: \"inferred\",\n };\n }\n return {\n source_context: \"user\",\n source_context_source: \"inferred\",\n };\n}\n\nfunction hashWithInstallationId(installationId: string, value: string): string {\n return crypto.createHash(\"sha256\").update(`${installationId}:${value}`).digest(\"hex\");\n}\n\n/**\n * Builds the agent-identity dimension for a telemetry payload from `PM_AUTHOR`.\n *\n * The raw `PM_AUTHOR` value (e.g. `claude-code-agent`) is never emitted. At\n * non-minimal capture levels a stable `author_context_hash` is attached — the\n * same installation-id-keyed one-way hash used for `pm_root_hash`/`cwd_hash`, so\n * agent-driven invocations can be segmented in Sentry/dashboards while the same\n * author hashes differently across installations. Because the field is a one-way\n * hash, it intentionally bypasses the {@link SENSITIVE_KEYWORDS} redaction path.\n * At minimal capture only a `has_author_context` boolean is surfaced.\n */\nfunction buildAuthorContextPayloadFields(\n captureLevel: TelemetryCaptureLevel,\n installationId: string,\n): Record<string, unknown> {\n const author = (process.env[PM_AUTHOR_ENV] ?? \"\").trim();\n if (captureLevel === \"minimal\") {\n return { has_author_context: author.length > 0 };\n }\n return author.length > 0\n ? { author_context_hash: hashWithInstallationId(installationId, author) }\n : {};\n}\n\nfunction normalizeForHash(value: unknown, depth = 0): unknown {\n if (value === null || value === undefined) {\n return value;\n }\n if (typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\") {\n return value;\n }\n if (depth >= TELEMETRY_SANITIZE_MAX_DEPTH) {\n return \"[depth_truncated]\";\n }\n if (Array.isArray(value)) {\n return value.slice(0, TELEMETRY_SANITIZE_MAX_ARRAY_ITEMS).map((entry) => normalizeForHash(entry, depth + 1));\n }\n if (typeof value === \"object\") {\n const record = value as Record<string, unknown>;\n const normalized: Record<string, unknown> = {};\n const sortedKeys = Object.keys(record).sort((left, right) => left.localeCompare(right));\n for (const key of sortedKeys) {\n normalized[key] = normalizeForHash(record[key], depth + 1);\n }\n return normalized;\n }\n return String(value);\n}\n\nfunction hashTelemetryValue(installationId: string, value: unknown): string {\n return hashWithInstallationId(installationId, JSON.stringify(normalizeForHash(value)));\n}\n\nfunction hashCommandArgs(installationId: string, args: string[]): { hashes: string[]; digest: string } {\n return {\n hashes: args.map((arg) => hashWithInstallationId(installationId, arg)),\n digest: hashWithInstallationId(installationId, args.join(\"\\u0000\")),\n };\n}\n\nfunction hashTelemetryErrorFingerprint(\n installationId: string,\n command: string,\n errorCode: string | undefined,\n errorMessage: string | undefined,\n): string {\n const normalizedMessage = sanitizeString(typeof errorMessage === \"string\" ? errorMessage : \"\", \"redacted\");\n const normalizedCode = typeof errorCode === \"string\" && errorCode.length > 0 ? errorCode : \"unknown_error\";\n const fingerprintSource = `${command}\\u0000${normalizedCode}\\u0000${normalizedMessage}`;\n return hashWithInstallationId(installationId, fingerprintSource);\n}\n\nfunction telemetryDisabledByEnvironment(): boolean {\n return (\n PM_TELEMETRY_DISABLED_VALUES.has((process.env[PM_TELEMETRY_DISABLED_ENV] ?? \"\").trim().toLowerCase()) ||\n PM_TELEMETRY_DISABLED_VALUES.has((process.env[PM_NO_TELEMETRY_ENV] ?? \"\").trim().toLowerCase())\n );\n}\n\nfunction resolveOtelTracesEndpoint(): string | null {\n if (PM_TELEMETRY_OTEL_DISABLED_VALUES.has((process.env[PM_TELEMETRY_OTEL_DISABLED_ENV] ?? \"\").trim().toLowerCase())) {\n return null;\n }\n\n const directEndpoint = (process.env[OTEL_TRACES_ENDPOINT_ENV] ?? \"\").trim();\n if (directEndpoint.length > 0) {\n try {\n return new URL(directEndpoint).toString();\n } catch {\n return null;\n }\n }\n\n const baseEndpoint = (process.env[OTEL_BASE_ENDPOINT_ENV] ?? \"\").trim();\n if (baseEndpoint.length === 0) {\n return null;\n }\n\n try {\n const url = new URL(baseEndpoint);\n const normalizedPath = url.pathname.replace(/\\/+$/, \"\");\n if (!normalizedPath.endsWith(\"/v1/traces\")) {\n url.pathname = `${normalizedPath.length === 0 ? \"\" : normalizedPath}/v1/traces`;\n }\n return url.toString();\n } catch {\n return null;\n }\n}\n\nfunction isoToUnixNano(iso: string): string {\n const parsedMs = Date.parse(iso);\n const epochMs = Number.isNaN(parsedMs) ? Date.now() : parsedMs;\n return `${BigInt(epochMs) * 1_000_000n}`;\n}\n\nfunction otlpStringAttribute(key: string, value: string): { key: string; value: { stringValue: string } } {\n return {\n key,\n value: { stringValue: value },\n };\n}\n\nfunction otlpBoolAttribute(key: string, value: boolean): { key: string; value: { boolValue: boolean } } {\n return {\n key,\n value: { boolValue: value },\n };\n}\n\nfunction otlpIntAttribute(key: string, value: number): { key: string; value: { intValue: string } } {\n return {\n key,\n value: { intValue: String(Math.max(0, Math.trunc(value))) },\n };\n}\n\n/**\n * Build the OTLP trace-export request for a finished command without performing\n * any network I/O. Returns `null` when OTLP export is not configured (no traces\n * endpoint / trace ids). The actual POST is deferred to the detached flush worker\n * via {@link enqueuePendingOtelSpan} so the foreground command never blocks on a\n * connecting socket (GH-209).\n */\nfunction buildOtelSpanRequest(\n activeCommand: ActiveTelemetryCommand,\n outcome: { ok: boolean; error?: string; exit_code?: number; error_code?: string; error_category?: TelemetryErrorCategory },\n finishedAtIso: string,\n durationMs: number,\n): { endpoint: string; payload: unknown } | null {\n if (\n typeof activeCommand.otel_traces_endpoint !== \"string\" ||\n activeCommand.otel_traces_endpoint.trim().length === 0 ||\n typeof activeCommand.otel_trace_id !== \"string\" ||\n activeCommand.otel_trace_id.length === 0 ||\n typeof activeCommand.otel_span_id !== \"string\" ||\n activeCommand.otel_span_id.length === 0\n ) {\n return null;\n }\n\n const serviceNameCandidate = sanitizeString((process.env[OTEL_SERVICE_NAME_ENV] ?? \"\").trim());\n const serviceName = serviceNameCandidate.length > 0 ? serviceNameCandidate : \"pm-cli\";\n const normalizedExitCode = normalizeTelemetryExitCode(outcome.exit_code, outcome.ok);\n const normalizedErrorCode = normalizeTelemetryErrorCode(outcome.error_code);\n const normalizedErrorCategory = normalizeTelemetryErrorCategory({\n ok: outcome.ok,\n errorCode: normalizedErrorCode,\n errorCategory: outcome.error_category,\n });\n const attributes: Array<\n | ReturnType<typeof otlpStringAttribute>\n | ReturnType<typeof otlpBoolAttribute>\n | ReturnType<typeof otlpIntAttribute>\n > = [\n otlpStringAttribute(\"pm.command\", sanitizeString(activeCommand.command)),\n otlpStringAttribute(\"pm.version\", activeCommand.pm_version),\n otlpStringAttribute(\"pm.source_context\", activeCommand.source_context),\n otlpStringAttribute(\"pm.source_context_source\", activeCommand.source_context_source),\n otlpStringAttribute(\"pm.installation_id\", activeCommand.installation_id),\n otlpStringAttribute(\"pm.session_id\", PROCESS_SESSION_ID),\n otlpStringAttribute(\"pm.pm_root_hash\", activeCommand.pm_root_hash),\n otlpStringAttribute(\"pm.cwd_hash\", activeCommand.cwd_hash),\n otlpBoolAttribute(\"pm.ok\", outcome.ok),\n otlpIntAttribute(\"pm.exit_code\", normalizedExitCode),\n otlpIntAttribute(\"pm.duration_ms\", durationMs),\n ];\n if (typeof normalizedErrorCode === \"string\") {\n attributes.push(otlpStringAttribute(\"pm.error_code\", normalizedErrorCode));\n }\n if (typeof normalizedErrorCategory === \"string\") {\n attributes.push(otlpStringAttribute(\"pm.error_category\", normalizedErrorCategory));\n }\n if (typeof outcome.error === \"string\" && outcome.error.trim().length > 0) {\n attributes.push(otlpStringAttribute(\"pm.error\", sanitizeString(outcome.error)));\n }\n\n const payload = {\n resourceSpans: [\n {\n resource: {\n attributes: [otlpStringAttribute(\"service.name\", serviceName)],\n },\n scopeSpans: [\n {\n scope: {\n name: \"pm-cli.telemetry\",\n version: \"1\",\n },\n spans: [\n {\n traceId: activeCommand.otel_trace_id,\n spanId: activeCommand.otel_span_id,\n name: `pm.command.${sanitizeString(activeCommand.command)}`,\n kind: 1,\n startTimeUnixNano: isoToUnixNano(activeCommand.started_at),\n endTimeUnixNano: isoToUnixNano(finishedAtIso),\n attributes,\n status: {\n code: outcome.ok ? 1 : 2,\n message: outcome.ok\n ? \"\"\n : sanitizeString(typeof outcome.error === \"string\" ? outcome.error : \"command_failed\"),\n },\n },\n ],\n },\n ],\n },\n ],\n };\n\n return { endpoint: activeCommand.otel_traces_endpoint, payload };\n}\n\nfunction summarizeResult(\n result: unknown,\n captureLevel: Exclude<TelemetryCaptureLevel, \"minimal\"> = \"redacted\",\n): Record<string, unknown> {\n if (result === null || result === undefined) {\n return { type: \"nullish\" };\n }\n if (typeof result === \"string\") {\n return { type: \"string\", value: sanitizeString(result, captureLevel) };\n }\n if (typeof result === \"number\" || typeof result === \"boolean\") {\n return { type: typeof result, value: result };\n }\n if (Array.isArray(result)) {\n return {\n type: \"array\",\n length: result.length,\n sample: result.slice(0, 5).map((entry) => sanitizeValue(entry, undefined, captureLevel)),\n };\n }\n if (typeof result === \"object\") {\n const record = result as Record<string, unknown>;\n const keys = Object.keys(record).sort((left, right) => left.localeCompare(right));\n const sanitized: Record<string, unknown> = {};\n let previewBytes = 0;\n for (const key of keys.slice(0, 25)) {\n const sanitizedValue = sanitizeValue(record[key], key, captureLevel);\n const entrySize = JSON.stringify(sanitizedValue).length;\n if (previewBytes + entrySize > TELEMETRY_RESULT_PREVIEW_MAX_BYTES) {\n sanitized[key] = \"[preview_truncated]\";\n break;\n }\n previewBytes += entrySize;\n sanitized[key] = sanitizedValue;\n }\n return {\n type: \"object\",\n key_count: keys.length,\n keys_preview: keys.slice(0, 50),\n preview: sanitized,\n };\n }\n return { type: typeof result, value: String(result) };\n}\n\nfunction buildCommandStartPayload(params: {\n captureLevel: TelemetryCaptureLevel;\n context: TelemetryCommandContext;\n pmVersion: string;\n sourceContext: ResolvedTelemetrySourceContext;\n pmRootHash: string;\n cwdHash: string;\n installationId: string;\n}): Record<string, unknown> {\n const { captureLevel, context, pmVersion, sourceContext, pmRootHash, cwdHash, installationId } = params;\n const commandTaxonomy = deriveTelemetryCommandTaxonomy(context.command);\n const hashedArgs = hashCommandArgs(installationId, context.args);\n const commandInvocationDigest = hashWithInstallationId(installationId, `${context.command}\\u0000${context.args.join(\"\\u0000\")}`);\n const commandOptionsDigest = hashTelemetryValue(installationId, context.options);\n const globalOptionsDigest = hashTelemetryValue(installationId, context.global);\n const authorContextFields = buildAuthorContextPayloadFields(captureLevel, installationId);\n if (captureLevel === \"minimal\") {\n return {\n capture_level: captureLevel,\n pm_version: pmVersion,\n source_context: sourceContext.source_context,\n source_context_source: sourceContext.source_context_source,\n command_taxonomy: commandTaxonomy,\n command_args_digest: hashedArgs.digest,\n command_invocation_digest: commandInvocationDigest,\n command_options_digest: commandOptionsDigest,\n global_options_digest: globalOptionsDigest,\n ...authorContextFields,\n };\n }\n return {\n pm_version: pmVersion,\n source_context: sourceContext.source_context,\n source_context_source: sourceContext.source_context_source,\n command_taxonomy: commandTaxonomy,\n ...authorContextFields,\n command_args: sanitizeCommandArgs(context.args, captureLevel),\n command_args_hashes: hashedArgs.hashes,\n command_args_digest: hashedArgs.digest,\n command_invocation_digest: commandInvocationDigest,\n command_options: sanitizeValue(context.options, undefined, captureLevel) as Record<string, unknown>,\n command_options_digest: commandOptionsDigest,\n global_options: sanitizeValue(context.global, undefined, captureLevel) as Record<string, unknown>,\n global_options_digest: globalOptionsDigest,\n pm_root_hash: pmRootHash,\n cwd_hash: cwdHash,\n capture_level: captureLevel,\n runtime: {\n node: process.version,\n platform: process.platform,\n arch: process.arch,\n hostname_hash: hashWithInstallationId(installationId, os.hostname()),\n stdin_tty: process.stdin.isTTY === true,\n stdout_tty: process.stdout.isTTY === true,\n },\n };\n}\n\nfunction buildCommandFinishPayload(params: {\n captureLevel: TelemetryCaptureLevel;\n pmVersion: string;\n sourceContext: ResolvedTelemetrySourceContext;\n outcome: TelemetryCommandOutcome;\n durationMs: number;\n startedAt: string;\n command: string;\n installationId: string;\n commandTaxonomy: TelemetryCommandTaxonomy;\n exitCode: number;\n errorCode?: string;\n errorCategory?: TelemetryErrorCategory;\n commandResolution: TelemetryCommandResolution;\n resolutionStage: TelemetryResolutionStage;\n}): Record<string, unknown> {\n const {\n captureLevel,\n pmVersion,\n sourceContext,\n outcome,\n durationMs,\n startedAt,\n command,\n installationId,\n commandTaxonomy,\n exitCode,\n errorCode,\n errorCategory,\n commandResolution,\n resolutionStage,\n } = params;\n const errorFingerprint =\n outcome.ok === false\n ? hashTelemetryErrorFingerprint(installationId, command, errorCode, outcome.error)\n : undefined;\n const authorContextFields = buildAuthorContextPayloadFields(captureLevel, installationId);\n if (captureLevel === \"minimal\") {\n return {\n capture_level: captureLevel,\n pm_version: pmVersion,\n source_context: sourceContext.source_context,\n source_context_source: sourceContext.source_context_source,\n command_taxonomy: commandTaxonomy,\n command_resolution: commandResolution,\n resolution_stage: resolutionStage,\n ok: outcome.ok,\n exit_code: exitCode,\n error_code: errorCode,\n error_category: errorCategory,\n error: outcome.error ? sanitizeString(outcome.error, \"redacted\") : undefined,\n error_fingerprint: errorFingerprint,\n duration_ms: durationMs,\n ...authorContextFields,\n };\n }\n return {\n capture_level: captureLevel,\n pm_version: pmVersion,\n source_context: sourceContext.source_context,\n source_context_source: sourceContext.source_context_source,\n command_taxonomy: commandTaxonomy,\n command_resolution: commandResolution,\n resolution_stage: resolutionStage,\n ...authorContextFields,\n ok: outcome.ok,\n exit_code: exitCode,\n error_code: errorCode,\n error_category: errorCategory,\n error: outcome.error ? sanitizeString(outcome.error, captureLevel) : undefined,\n error_fingerprint: errorFingerprint,\n duration_ms: durationMs,\n started_at: startedAt,\n result_summary: summarizeResult(outcome.result, captureLevel),\n };\n}\n\nfunction buildCommandErrorPayload(params: {\n captureLevel: TelemetryCaptureLevel;\n pmVersion: string;\n sourceContext: ResolvedTelemetrySourceContext;\n command: string;\n commandTaxonomy: TelemetryCommandTaxonomy;\n commandResolution: TelemetryCommandResolution;\n resolutionStage: TelemetryResolutionStage;\n args: string[];\n options: Record<string, unknown>;\n pmRootHash: string;\n cwdHash: string;\n installationId: string;\n errorCode: string;\n errorMessage: string;\n errorCategory: TelemetryErrorCategory;\n exitCode: number;\n}): Record<string, unknown> {\n const {\n captureLevel,\n pmVersion,\n sourceContext,\n command,\n commandTaxonomy,\n commandResolution,\n resolutionStage,\n args,\n options,\n pmRootHash,\n cwdHash,\n installationId,\n errorCode,\n errorMessage,\n errorCategory,\n exitCode,\n } = params;\n const attemptedArgHashes = hashCommandArgs(installationId, args);\n const attemptedCommandDigest = hashWithInstallationId(installationId, command);\n const attemptedOptionsDigest = hashTelemetryValue(installationId, options);\n const errorFingerprint = hashTelemetryErrorFingerprint(installationId, command, errorCode, errorMessage);\n if (captureLevel === \"minimal\") {\n return {\n capture_level: captureLevel,\n pm_version: pmVersion,\n source_context: sourceContext.source_context,\n source_context_source: sourceContext.source_context_source,\n command_taxonomy: commandTaxonomy,\n command_resolution: commandResolution,\n resolution_stage: resolutionStage,\n attempted_command_digest: attemptedCommandDigest,\n attempted_args_digest: attemptedArgHashes.digest,\n attempted_options_digest: attemptedOptionsDigest,\n error_code: errorCode,\n error_category: errorCategory,\n exit_code: exitCode,\n error: sanitizeString(errorMessage, \"redacted\"),\n error_fingerprint: errorFingerprint,\n };\n }\n\n return {\n capture_level: captureLevel,\n pm_version: pmVersion,\n source_context: sourceContext.source_context,\n source_context_source: sourceContext.source_context_source,\n command_taxonomy: commandTaxonomy,\n command_resolution: commandResolution,\n resolution_stage: resolutionStage,\n attempted_command: sanitizeString(command, captureLevel),\n attempted_command_digest: attemptedCommandDigest,\n attempted_args: sanitizeCommandArgs(args, captureLevel),\n attempted_args_hashes: attemptedArgHashes.hashes,\n attempted_args_digest: attemptedArgHashes.digest,\n attempted_options: sanitizeValue(options, undefined, captureLevel) as Record<string, unknown>,\n attempted_options_digest: attemptedOptionsDigest,\n error_code: errorCode,\n error_category: errorCategory,\n exit_code: exitCode,\n error: sanitizeString(errorMessage, captureLevel),\n error_fingerprint: errorFingerprint,\n pm_root_hash: pmRootHash,\n cwd_hash: cwdHash,\n runtime: {\n node: process.version,\n platform: process.platform,\n arch: process.arch,\n hostname_hash: hashWithInstallationId(installationId, os.hostname()),\n stdin_tty: process.stdin.isTTY === true,\n stdout_tty: process.stdout.isTTY === true,\n },\n };\n}\n\nasync function ensureInstallationId(\n globalPmRoot: string,\n): Promise<{ installationId: string; endpoint: string; retentionDays: number }> {\n const settings = await readSettings(globalPmRoot);\n let changed = false;\n if (settings.telemetry.installation_id.trim().length === 0) {\n settings.telemetry.installation_id = crypto.randomUUID();\n changed = true;\n }\n if (changed) {\n await writeSettings(globalPmRoot, settings, \"telemetry:install_id\");\n }\n return {\n installationId: settings.telemetry.installation_id,\n endpoint: settings.telemetry.endpoint,\n retentionDays: Math.max(1, Math.trunc(settings.telemetry.retention_days)),\n };\n}\n\nasync function enqueueTelemetryEvent(globalPmRoot: string, event: TelemetryEvent): Promise<void> {\n const queued: QueuedTelemetryEvent = {\n client_schema_version: TELEMETRY_CLIENT_SCHEMA_VERSION,\n event,\n attempts: 0,\n };\n let serialized = JSON.stringify(queued);\n if (serialized.length > TELEMETRY_MAX_EVENT_BYTES) {\n const trimmed = { ...event, payload: { ...event.payload, result_summary: { truncated: true, reason: \"payload_size_exceeded\", original_bytes: serialized.length } } };\n const trimmedQueued: QueuedTelemetryEvent = {\n client_schema_version: TELEMETRY_CLIENT_SCHEMA_VERSION,\n event: trimmed,\n attempts: 0,\n };\n serialized = JSON.stringify(trimmedQueued);\n }\n await withQueueMutation(async () => {\n await appendLineAtomic(queuePath(globalPmRoot), serialized);\n });\n}\n\nfunction parseQueueLines(raw: string): QueuedTelemetryEvent[] {\n const entries: QueuedTelemetryEvent[] = [];\n for (const line of raw.split(\"\\n\")) {\n const trimmed = line.trim();\n if (trimmed.length === 0) {\n continue;\n }\n try {\n const parsed = JSON.parse(trimmed) as QueuedTelemetryEvent;\n if (\n parsed &&\n typeof parsed === \"object\" &&\n parsed.event &&\n typeof parsed.event === \"object\" &&\n typeof parsed.attempts === \"number\" &&\n (\n parsed.client_schema_version === undefined ||\n (typeof parsed.client_schema_version === \"number\" && Number.isFinite(parsed.client_schema_version))\n )\n ) {\n entries.push(parsed);\n }\n } catch {\n // Drop malformed lines to preserve queue forward progress.\n }\n }\n return entries;\n}\n\nfunction nextRetryIso(attempts: number): string {\n const delay = Math.min(TELEMETRY_RETRY_BASE_DELAY_MS * 2 ** Math.max(attempts - 1, 0), TELEMETRY_MAX_RETRY_DELAY_MS);\n return new Date(Date.now() + delay).toISOString();\n}\n\nfunction isDueForRetryAt(nextAttemptAfter: string | undefined): boolean {\n if (typeof nextAttemptAfter !== \"string\" || nextAttemptAfter.trim().length === 0) {\n return true;\n }\n const dueAtMs = Date.parse(nextAttemptAfter);\n if (Number.isNaN(dueAtMs)) {\n return true;\n }\n return dueAtMs <= Date.now();\n}\n\nfunction isDueForRetry(entry: QueuedTelemetryEvent): boolean {\n return isDueForRetryAt(entry.next_attempt_after);\n}\n\nfunction retentionCutoffMs(retentionDays: number): number {\n const normalizedDays = Number.isFinite(retentionDays) ? Math.max(1, Math.trunc(retentionDays)) : 1;\n return Date.now() - normalizedDays * MILLISECONDS_PER_DAY;\n}\n\nfunction isExpiredQueueEntry(entry: QueuedTelemetryEvent, cutoffMs: number): boolean {\n const occurredAt = entry.event?.occurred_at;\n if (typeof occurredAt !== \"string\" || occurredAt.trim().length === 0) {\n return false;\n }\n const occurredAtMs = Date.parse(occurredAt);\n if (Number.isNaN(occurredAtMs)) {\n return false;\n }\n return occurredAtMs < cutoffMs;\n}\n\nfunction pruneExpiredQueueEntries(\n entries: QueuedTelemetryEvent[],\n retentionDays: number,\n): { entries: QueuedTelemetryEvent[]; prunedCount: number } {\n const cutoffMs = retentionCutoffMs(retentionDays);\n const retained: QueuedTelemetryEvent[] = [];\n let prunedCount = 0;\n for (const entry of entries) {\n const serializedSize = JSON.stringify(entry).length;\n const oversized = serializedSize > TELEMETRY_MAX_EVENT_BYTES;\n if (oversized || isExpiredQueueEntry(entry, cutoffMs) || entry.attempts >= TELEMETRY_MAX_QUEUE_ENTRY_ATTEMPTS) {\n prunedCount += 1;\n continue;\n }\n retained.push(entry);\n }\n return { entries: retained, prunedCount };\n}\n\nasync function rewriteQueue(globalPmRoot: string, entries: QueuedTelemetryEvent[]): Promise<void> {\n const serialized = entries.map((entry) => JSON.stringify(entry)).join(\"\\n\");\n const contents = serialized.length > 0 ? `${serialized}\\n` : \"\";\n for (let attempt = 0; ; attempt += 1) {\n try {\n await writeFileAtomic(queuePath(globalPmRoot), contents);\n return;\n } catch (error: unknown) {\n const retryDelay = TELEMETRY_QUEUE_REWRITE_RETRY_DELAYS_MS[attempt];\n if (retryDelay === undefined || !isRetryableQueueRewriteError(error)) {\n throw error;\n }\n await sleep(retryDelay);\n }\n }\n}\n\nfunction isRetryableQueueRewriteError(error: unknown): boolean {\n if (typeof error !== \"object\" || error === null || !(\"code\" in error)) {\n return false;\n }\n const code = (error as { code?: unknown }).code;\n return code === \"EACCES\" || code === \"EBUSY\" || code === \"EPERM\";\n}\n\nfunction sleep(milliseconds: number): Promise<void> {\n return new Promise((resolve) => {\n setTimeout(resolve, milliseconds);\n });\n}\n\n/**\n * Append a built OTLP span request to the bounded pending-spans queue. The\n * detached flush worker drains and POSTs these so the foreground command never\n * performs OTLP network I/O (GH-209). Best effort: a write failure never blocks\n * the command, and the span is simply not exported.\n */\nasync function enqueuePendingOtelSpan(globalPmRoot: string, request: { endpoint: string; payload: unknown }): Promise<void> {\n const pending: PendingOtelSpan = {\n id: crypto.randomUUID(),\n endpoint: request.endpoint,\n payload: request.payload,\n enqueued_at: nowIso(),\n attempts: 0,\n };\n const serialized = JSON.stringify(pending);\n // Drop oversized spans rather than poison the queue; they would never flush.\n if (serialized.length > TELEMETRY_MAX_EVENT_BYTES) {\n return;\n }\n await withQueueMutation(async () => {\n await appendLineAtomic(otelSpansQueuePath(globalPmRoot), serialized);\n });\n}\n\n/**\n * Derive a stable id for a legacy id-less pending span from its identity fields.\n * Deterministic so the same on-disk line yields the same id across reads, which\n * is what lets reconciliation remove/update it after a flush.\n */\nfunction backfillPendingOtelSpanId(entry: { endpoint: string; enqueued_at: string; payload: unknown }): string {\n const material = JSON.stringify([entry.endpoint, entry.enqueued_at, entry.payload]);\n return crypto.createHash(\"sha256\").update(material).digest(\"hex\").slice(0, 32);\n}\n\nfunction parsePendingOtelSpanLines(raw: string): PendingOtelSpan[] {\n const entries: PendingOtelSpan[] = [];\n for (const line of raw.split(\"\\n\")) {\n const trimmed = line.trim();\n if (trimmed.length === 0) {\n continue;\n }\n try {\n const parsed = JSON.parse(trimmed) as PendingOtelSpan;\n if (\n parsed &&\n typeof parsed === \"object\" &&\n typeof parsed.endpoint === \"string\" &&\n parsed.endpoint.trim().length > 0 &&\n \"payload\" in parsed &&\n typeof parsed.attempts === \"number\" &&\n Number.isFinite(parsed.attempts)\n ) {\n // Backfill an id for legacy entries written before id tracking existed.\n // It MUST be deterministic from the entry's content so the post-flush\n // re-read derives the same id and reconciliation can address the entry;\n // a random id would differ between reads and strand the span.\n if (typeof parsed.id !== \"string\" || parsed.id.length === 0) {\n parsed.id = backfillPendingOtelSpanId(parsed);\n }\n entries.push(parsed);\n }\n } catch {\n // Drop malformed lines to preserve forward progress.\n }\n }\n return entries;\n}\n\nfunction isExpiredPendingOtelSpan(entry: PendingOtelSpan, cutoffMs: number): boolean {\n if (typeof entry.enqueued_at !== \"string\" || entry.enqueued_at.trim().length === 0) {\n return false;\n }\n const enqueuedAtMs = Date.parse(entry.enqueued_at);\n if (Number.isNaN(enqueuedAtMs)) {\n return false;\n }\n return enqueuedAtMs < cutoffMs;\n}\n\nfunction prunePendingOtelSpans(\n entries: PendingOtelSpan[],\n retentionDays: number,\n): { entries: PendingOtelSpan[]; prunedCount: number } {\n const cutoffMs = retentionCutoffMs(retentionDays);\n const retained: PendingOtelSpan[] = [];\n let prunedCount = 0;\n for (const entry of entries) {\n const oversized = JSON.stringify(entry).length > TELEMETRY_MAX_EVENT_BYTES;\n if (oversized || isExpiredPendingOtelSpan(entry, cutoffMs) || entry.attempts >= TELEMETRY_MAX_QUEUE_ENTRY_ATTEMPTS) {\n prunedCount += 1;\n continue;\n }\n retained.push(entry);\n }\n if (retained.length > TELEMETRY_OTEL_SPANS_MAX_PENDING) {\n const overflow = retained.length - TELEMETRY_OTEL_SPANS_MAX_PENDING;\n prunedCount += overflow;\n // Keep the most recently enqueued spans; oldest beyond the cap are dropped.\n return { entries: retained.slice(overflow), prunedCount };\n }\n return { entries: retained, prunedCount };\n}\n\nasync function rewritePendingOtelSpans(globalPmRoot: string, entries: PendingOtelSpan[]): Promise<void> {\n const serialized = entries.map((entry) => JSON.stringify(entry)).join(\"\\n\");\n const contents = serialized.length > 0 ? `${serialized}\\n` : \"\";\n for (let attempt = 0; ; attempt += 1) {\n try {\n await writeFileAtomic(otelSpansQueuePath(globalPmRoot), contents);\n return;\n } catch (error: unknown) {\n const retryDelay = TELEMETRY_QUEUE_REWRITE_RETRY_DELAYS_MS[attempt];\n if (retryDelay === undefined || !isRetryableQueueRewriteError(error)) {\n throw error;\n }\n await sleep(retryDelay);\n }\n }\n}\n\n/**\n * Drain the pending OTLP span queue and POST due spans to their traces endpoint.\n * Runs only inside the flush worker (detached child) or the inline test path, so\n * the foreground command never makes OTLP network calls. Failures increment\n * per-span attempts with backoff and are retried by a later flush; runtime state\n * records OTLP export diagnostics for `pm health` (GH-205).\n */\n/**\n * Re-read the spans queue under the mutation serializer and rewrite it with the\n * processed spans removed/updated by id, preserving any spans a concurrent\n * foreground process appended during the (network) flush window. `succeededIds`\n * are dropped; `failedUpdates` patch attempts/next_attempt_after by id; all other\n * (incl. newly-appended) entries are retained, then pruned. Returns the count of\n * spans left in the queue. Mirrors removeFlushedEntriesFromCurrentQueue.\n */\nasync function reconcilePendingOtelSpansAfterFlush(\n globalPmRoot: string,\n retentionDays: number,\n succeededIds: ReadonlySet<string>,\n failedUpdates: ReadonlyMap<string, { attempts: number; next_attempt_after: string }>,\n): Promise<number> {\n return withQueueMutation(async () => {\n const raw = await readFileIfExists(otelSpansQueuePath(globalPmRoot));\n const current = raw === null ? [] : parsePendingOtelSpanLines(raw);\n const reconciled: PendingOtelSpan[] = [];\n for (const entry of current) {\n if (succeededIds.has(entry.id)) {\n continue;\n }\n const failure = failedUpdates.get(entry.id);\n reconciled.push(failure ? { ...entry, attempts: failure.attempts, next_attempt_after: failure.next_attempt_after } : entry);\n }\n const { entries: retained } = prunePendingOtelSpans(reconciled, retentionDays);\n await rewritePendingOtelSpans(globalPmRoot, retained);\n return retained.length;\n });\n}\n\nasync function flushPendingOtelSpans(globalPmRoot: string, retentionDays: number): Promise<void> {\n const raw = await readFileIfExists(otelSpansQueuePath(globalPmRoot));\n if (raw === null || raw.trim().length === 0) {\n await writeRuntimeState(globalPmRoot, { pending_otel_spans: 0 });\n return;\n }\n const entries = parsePendingOtelSpanLines(raw);\n const { entries: retained, prunedCount } = prunePendingOtelSpans(entries, retentionDays);\n const due = retained.filter((entry) => isDueForRetryAt(entry.next_attempt_after)).slice(\n 0,\n TELEMETRY_OTEL_SPANS_FLUSH_BATCH_SIZE,\n );\n if (due.length === 0) {\n // Nothing to POST. Still reconcile so pruning persists, but only if pruning\n // actually changed the on-disk set (avoids a redundant rewrite each command).\n const remaining = prunedCount > 0 ? await reconcilePendingOtelSpansAfterFlush(globalPmRoot, retentionDays, new Set(), new Map()) : retained.length;\n await writeRuntimeState(globalPmRoot, { pending_otel_spans: remaining });\n return;\n }\n\n const attemptTime = nowIso();\n const succeededIds = new Set<string>();\n const failedUpdates = new Map<string, { attempts: number; next_attempt_after: string }>();\n let succeededCount = 0;\n let lastError: string | undefined;\n // Export the batch concurrently so a slow/blackholed collector caps the worker\n // at one TELEMETRY_HTTP_TIMEOUT_MS rather than batch-size x timeout — keeping it\n // well within the flush-lock TTL. The Set/Map/counter mutations are synchronous\n // and safe under Node's single-threaded event loop.\n await Promise.all(\n due.map(async (span) => {\n try {\n const response = await fetch(span.endpoint, {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify(span.payload),\n signal: AbortSignal.timeout(TELEMETRY_HTTP_TIMEOUT_MS),\n });\n if (!response.ok) {\n throw new Error(`local_otel_export_http_${response.status}`);\n }\n succeededIds.add(span.id);\n succeededCount += 1;\n } catch (error: unknown) {\n lastError = error instanceof Error ? sanitizeString(error.message, \"redacted\") : \"local_otel_export_failed\";\n const nextAttempts = span.attempts + 1;\n failedUpdates.set(span.id, { attempts: nextAttempts, next_attempt_after: nextRetryIso(nextAttempts) });\n }\n }),\n );\n\n const remaining = await reconcilePendingOtelSpansAfterFlush(globalPmRoot, retentionDays, succeededIds, failedUpdates);\n const statePatch: TelemetryRuntimeState = {\n pending_otel_spans: remaining,\n last_otel_attempt_at: attemptTime,\n };\n if (succeededCount > 0) {\n statePatch.last_otel_success_at = attemptTime;\n }\n if (lastError !== undefined) {\n statePatch.last_otel_failure_at = attemptTime;\n statePatch.last_otel_failure_error = lastError;\n } else if (remaining === 0) {\n // Only clear the failure diagnostic once the queue is fully drained. A\n // clean batch while other (not-yet-due) spans still wait could be hiding\n // earlier failures; keep the last known failure until nothing is pending.\n statePatch.last_otel_failure_at = undefined;\n statePatch.last_otel_failure_error = undefined;\n }\n await writeRuntimeState(globalPmRoot, statePatch);\n}\n\n/**\n * Flush both telemetry artifacts under the same worker invocation: the event\n * ingest queue and the pending OTLP span queue. Used by the detached flush\n * worker and the inline (test) path so OTLP export always happens off the\n * foreground command's critical path.\n */\nasync function flushTelemetryArtifacts(globalPmRoot: string, endpoint: string, retentionDays: number): Promise<void> {\n // Isolate the two artifacts: a failure flushing the event queue (e.g. a corrupt\n // queue file) must not strand the OTLP span flush in the same pass, and vice\n // versa. Both are best effort and retried on the next dispatch.\n try {\n await flushQueue(globalPmRoot, endpoint, retentionDays);\n } catch {\n // Best effort; event-queue flush is retried on the next dispatch.\n }\n try {\n await flushPendingOtelSpans(globalPmRoot, retentionDays);\n } catch {\n // Best effort; span flush is retried on the next dispatch.\n }\n}\n\nasync function cleanupTelemetryQueueTempOrphans(\n globalPmRoot: string,\n maxAgeMs = TELEMETRY_QUEUE_TMP_ORPHAN_MAX_AGE_MS,\n): Promise<void> {\n try {\n const dirPath = telemetryRuntimeDirectory(globalPmRoot);\n const entries = await readdir(dirPath, { withFileTypes: true });\n const cutoffMs = Date.now() - Math.max(0, maxAgeMs);\n await Promise.all(\n entries\n .filter((entry) => entry.isFile() && /^\\.events\\.jsonl\\.\\d+\\.\\d+\\.[a-f0-9]+\\.tmp$/.test(entry.name))\n .map(async (entry) => {\n const candidate = path.join(dirPath, entry.name);\n const candidateStats = await stat(candidate);\n if (candidateStats.mtimeMs < cutoffMs) {\n await rm(candidate, { force: true });\n }\n }),\n );\n } catch {\n // Telemetry cleanup is best-effort and must not affect command execution.\n }\n}\n\nasync function withQueueMutation<T>(operation: () => Promise<T>): Promise<T> {\n const run = _queueMutationPromise.catch(\n /* c8 ignore next */\n () => {},\n ).then(operation);\n _queueMutationPromise = run.catch(\n /* c8 ignore next */\n () => {},\n );\n return run;\n}\n\nasync function readCurrentQueueEntries(globalPmRoot: string): Promise<QueuedTelemetryEvent[]> {\n const raw = await readFileIfExists(queuePath(globalPmRoot));\n if (raw === null || raw.trim().length === 0) {\n return [];\n }\n return parseQueueLines(raw);\n}\n\nasync function removeFlushedEntriesFromCurrentQueue(\n globalPmRoot: string,\n flushedIds: ReadonlySet<string>,\n retentionDays: number,\n): Promise<QueuedTelemetryEvent[]> {\n return withQueueMutation(async () => {\n const currentEntries = await readCurrentQueueEntries(globalPmRoot);\n const { entries: retainedEntries } = pruneExpiredQueueEntries(currentEntries, retentionDays);\n const remaining = retainedEntries.filter((entry) => !flushedIds.has(entry.event.event_id));\n await rewriteQueue(globalPmRoot, remaining);\n return remaining;\n });\n}\n\nasync function markFailedEntriesInCurrentQueue(\n globalPmRoot: string,\n failedIds: ReadonlySet<string>,\n attemptTime: string,\n retentionDays: number,\n): Promise<QueuedTelemetryEvent[]> {\n return withQueueMutation(async () => {\n const currentEntries = await readCurrentQueueEntries(globalPmRoot);\n const { entries: retainedEntries } = pruneExpiredQueueEntries(currentEntries, retentionDays);\n const retried = retainedEntries.map((entry) => {\n if (!failedIds.has(entry.event.event_id)) {\n return entry;\n }\n const attempts = entry.attempts + 1;\n return {\n ...entry,\n attempts,\n last_attempt_at: attemptTime,\n next_attempt_after: nextRetryIso(attempts),\n };\n });\n await rewriteQueue(globalPmRoot, retried);\n return retried;\n });\n}\n\nasync function flushQueue(globalPmRoot: string, endpoint: string, retentionDays: number): Promise<void> {\n await cleanupTelemetryQueueTempOrphans(globalPmRoot);\n const normalizedEndpoint = endpoint.trim();\n if (normalizedEndpoint.length === 0) {\n return;\n }\n const raw = await readFileIfExists(queuePath(globalPmRoot));\n if (raw === null || raw.trim().length === 0) {\n await writeRuntimeState(globalPmRoot, {\n endpoint: normalizedEndpoint,\n queue_entries: 0,\n });\n return;\n }\n const queueEntries = parseQueueLines(raw);\n if (queueEntries.length === 0) {\n await writeRuntimeState(globalPmRoot, {\n endpoint: normalizedEndpoint,\n queue_entries: 0,\n });\n return;\n }\n const { entries: retainedEntries, prunedCount } = pruneExpiredQueueEntries(queueEntries, retentionDays);\n if (retainedEntries.length === 0) {\n await rewriteQueue(globalPmRoot, []);\n await writeRuntimeState(globalPmRoot, {\n endpoint: normalizedEndpoint,\n queue_entries: 0,\n });\n return;\n }\n const dueEntries = retainedEntries.filter((entry) => isDueForRetry(entry)).slice(0, TELEMETRY_FLUSH_BATCH_SIZE);\n if (dueEntries.length === 0) {\n if (prunedCount > 0) {\n await rewriteQueue(globalPmRoot, retainedEntries);\n }\n await writeRuntimeState(globalPmRoot, {\n endpoint: normalizedEndpoint,\n queue_entries: retainedEntries.length,\n });\n return;\n }\n const dueIds = new Set(dueEntries.map((entry) => entry.event.event_id));\n const attemptTime = nowIso();\n const requestHeaders: Record<string, string> = {\n \"content-type\": \"application/json\",\n };\n const ingestKey = process.env.PM_TELEMETRY_INGEST_KEY?.trim();\n if (ingestKey) {\n requestHeaders[\"x-pm-telemetry-key\"] = ingestKey;\n }\n\n try {\n const response = await fetch(normalizedEndpoint, {\n method: \"POST\",\n headers: requestHeaders,\n body: JSON.stringify({\n schema_version: TELEMETRY_SCHEMA_VERSION,\n events: dueEntries.map((entry) => entry.event),\n }),\n signal: AbortSignal.timeout(TELEMETRY_HTTP_TIMEOUT_MS),\n });\n if (!response.ok) {\n throw new Error(`telemetry_flush_http_${response.status}`);\n }\n } catch (error: unknown) {\n const retried = await markFailedEntriesInCurrentQueue(globalPmRoot, dueIds, attemptTime, retentionDays);\n const errorMessage = (() => {\n if (error instanceof Error) {\n return sanitizeString(error.message, \"redacted\");\n }\n return \"telemetry_flush_failed\";\n })();\n await writeRuntimeState(globalPmRoot, {\n endpoint: normalizedEndpoint,\n queue_entries: retried.length,\n last_attempted_flush_at: attemptTime,\n last_failed_flush_at: attemptTime,\n last_failed_flush_error: errorMessage,\n });\n return;\n }\n\n try {\n const remaining = await removeFlushedEntriesFromCurrentQueue(globalPmRoot, dueIds, retentionDays);\n await writeRuntimeState(globalPmRoot, {\n endpoint: normalizedEndpoint,\n queue_entries: remaining.length,\n last_attempted_flush_at: attemptTime,\n last_successful_flush_at: attemptTime,\n last_failed_flush_at: undefined,\n last_failed_flush_error: undefined,\n });\n /* c8 ignore start */\n } catch (error: unknown) {\n const errorMessage = (() => {\n if (error instanceof Error) {\n return sanitizeString(error.message, \"redacted\");\n }\n return \"telemetry_flush_failed\";\n })();\n const currentEntries = await readCurrentQueueEntries(globalPmRoot).catch(() => retainedEntries);\n await writeRuntimeState(globalPmRoot, {\n endpoint: normalizedEndpoint,\n queue_entries: currentEntries.length,\n last_attempted_flush_at: attemptTime,\n last_failed_flush_at: attemptTime,\n last_failed_flush_error: errorMessage,\n });\n }\n /* c8 ignore stop */\n}\n\nasync function acquireTelemetryFlushLock(globalPmRoot: string): Promise<boolean> {\n const lockPath = flushLockPath(globalPmRoot);\n await mkdir(path.dirname(lockPath), { recursive: true });\n try {\n await mkdir(lockPath);\n return true;\n } catch (error: unknown) {\n if (typeof error !== \"object\" || error === null || !(\"code\" in error) || (error as { code?: unknown }).code !== \"EEXIST\") {\n throw error;\n }\n }\n\n try {\n const lockStats = await stat(lockPath);\n if (Date.now() - lockStats.mtimeMs < TELEMETRY_FLUSH_LOCK_STALE_MS) {\n return false;\n }\n await rm(lockPath, { recursive: true, force: true });\n await mkdir(lockPath);\n return true;\n } catch {\n return false;\n }\n}\n\nfunction isFreshDirectoryLock(lockPath: string, staleMs: number): boolean {\n try {\n return Date.now() - statSync(lockPath).mtimeMs < staleMs;\n } catch {\n return false;\n }\n}\n\nfunction removeDirectoryLockBestEffort(lockPath: string): void {\n try {\n rmSync(lockPath, { recursive: true, force: true });\n } catch {\n // Flush scheduling is best effort and must never fail user commands.\n }\n}\n\nfunction errorCode(error: unknown): string | undefined {\n if (typeof error !== \"object\" || error === null || !(\"code\" in error)) {\n return undefined;\n }\n const code = (error as { code?: unknown }).code;\n return typeof code === \"string\" ? code : undefined;\n}\n\nfunction createDirectoryLock(lockPath: string): boolean {\n try {\n mkdirSync(lockPath);\n return true;\n } catch (error: unknown) {\n const code = errorCode(error);\n if (code === \"EEXIST\") {\n return false;\n }\n if (code !== \"ENOENT\") {\n return false;\n }\n }\n\n /* c8 ignore start */\n try {\n mkdirSync(path.dirname(lockPath), { recursive: true });\n mkdirSync(lockPath);\n return true;\n } catch {\n return false;\n }\n /* c8 ignore stop */\n}\n\nfunction acquireTelemetryFlushSpawnGate(globalPmRoot: string): boolean {\n if (isFreshDirectoryLock(flushLockPath(globalPmRoot), TELEMETRY_FLUSH_LOCK_STALE_MS)) {\n return false;\n }\n\n const lockPath = flushSpawnLockPath(globalPmRoot);\n try {\n if (Date.now() - statSync(lockPath).mtimeMs < TELEMETRY_FLUSH_SPAWN_LOCK_STALE_MS) {\n return false;\n }\n removeDirectoryLockBestEffort(lockPath);\n } catch (error: unknown) {\n if (errorCode(error) !== \"ENOENT\") {\n return false;\n }\n }\n\n return createDirectoryLock(lockPath);\n}\n\nfunction releaseTelemetryFlushSpawnGate(globalPmRoot: string): void {\n removeDirectoryLockBestEffort(flushSpawnLockPath(globalPmRoot));\n}\n\nexport const _testOnly = {\n acquireTelemetryFlushSpawnGate,\n acquireTelemetryFlushLock,\n buildAuthorContextPayloadFields,\n buildCommandErrorPayload,\n buildCommandFinishPayload,\n buildCommandStartPayload,\n buildOtelSpanRequest,\n createDirectoryLock,\n enqueuePendingOtelSpan,\n enqueueTelemetryEvent,\n errorCode,\n flushPendingOtelSpans,\n flushQueue,\n flushQueueWithProcessLock,\n flushTelemetryArtifacts,\n hashTelemetryErrorFingerprint,\n hashTelemetryValue,\n isEmailDomainCharacter,\n isEmailLocalCharacter,\n isExpiredPendingOtelSpan,\n isExpiredQueueEntry,\n isFreshDirectoryLock,\n isDueForRetry,\n isDueForRetryAt,\n isRetryableQueueRewriteError,\n looksLikeEmailToken,\n otelSpansQueuePath,\n parseBooleanTrueLike,\n parsePendingOtelSpanLines,\n prunePendingOtelSpans,\n reconcilePendingOtelSpansAfterFlush,\n retentionCutoffMs,\n resolveOtelTracesEndpoint,\n rewritePendingOtelSpans,\n normalizeForHash,\n normalizeCaptureLevel,\n normalizePmVersion,\n normalizeTelemetryErrorCategory,\n normalizeTelemetryErrorCode,\n normalizeTelemetryExitCode,\n parseQueueLines,\n pruneExpiredQueueEntries,\n readRuntimeState,\n readCurrentQueueEntries,\n releaseTelemetryFlushSpawnGate,\n removeFlushedEntriesFromCurrentQueue,\n removeDirectoryLockBestEffort,\n resolveTelemetrySourceContext,\n rewriteQueue,\n sanitizeCommandArgs,\n sanitizeStringMax,\n sanitizeStringRedacted,\n sanitizeValue,\n scheduleTelemetryFlush,\n shouldFlushInline,\n sleep,\n summarizeResult,\n telemetryFlushRunnerPath,\n withQueueMutation,\n flushLockPath,\n flushSpawnLockPath,\n runtimeStatePath,\n writeRuntimeState,\n};\n\nasync function flushQueueWithProcessLock(globalPmRoot: string, endpoint: string, retentionDays: number): Promise<void> {\n const acquired = await acquireTelemetryFlushLock(globalPmRoot);\n releaseTelemetryFlushSpawnGate(globalPmRoot);\n if (!acquired) {\n return;\n }\n try {\n await flushTelemetryArtifacts(globalPmRoot, endpoint, retentionDays);\n } finally {\n try {\n await rm(flushLockPath(globalPmRoot), { recursive: true, force: true });\n } catch {\n // Best effort lock cleanup; stale locks are recovered by TTL checks.\n }\n }\n}\n\nfunction scheduleTelemetryFlush(globalPmRoot: string, endpoint: string, retentionDays: number): void {\n if (shouldFlushInline()) {\n const previousFlush = _lastFlushPromise;\n const nextFlush = flushTelemetryArtifacts(globalPmRoot, endpoint, retentionDays);\n _lastFlushPromise = Promise.allSettled([previousFlush, nextFlush]).then(() => {});\n return;\n }\n\n try {\n const acquiredSpawnGate = acquireTelemetryFlushSpawnGate(globalPmRoot);\n if (!acquiredSpawnGate) {\n return;\n }\n const child = spawn(process.execPath, [telemetryFlushRunnerPath()], {\n detached: true,\n stdio: \"ignore\",\n // Detached workers inherit cwd by default. On Windows that can keep a\n // disposable project directory locked after the foreground command exits.\n cwd: os.tmpdir(),\n env: {\n ...process.env,\n PM_GLOBAL_PATH: globalPmRoot,\n [PM_TELEMETRY_FLUSH_CHILD_ENV]: \"1\",\n },\n });\n // A detached spawn can fail asynchronously — the runtime cannot launch the\n // executable (locked-down Windows runners, missing flush runner, EACCES).\n // Node re-throws an 'error' event with no listener as an uncaught exception,\n // which would crash the foreground CLI and, under the test runner, the\n // vitest worker during teardown (GH-348). Flush is strictly best effort, so\n // swallow the failure and release the spawn gate to permit a later retry.\n child.on(\"error\", () => {\n releaseTelemetryFlushSpawnGate(globalPmRoot);\n });\n child.unref();\n } catch {\n releaseTelemetryFlushSpawnGate(globalPmRoot);\n // Flush scheduling is best effort and must not keep the CLI alive.\n }\n}\n\n/**\n * Implements flush telemetry queue now for the public runtime surface of this module.\n */\nexport async function flushTelemetryQueueNow(globalPmRoot = resolveGlobalPmRoot(process.cwd())): Promise<void> {\n if (telemetryDisabledByEnvironment()) {\n return;\n }\n try {\n const settings = await readSettings(globalPmRoot);\n if (!settings.telemetry.enabled) {\n return;\n }\n const { endpoint, retentionDays } = await ensureInstallationId(globalPmRoot);\n await flushQueueWithProcessLock(globalPmRoot, endpoint, retentionDays);\n } catch {\n // Telemetry workers are best effort and must never fail user commands.\n }\n}\n\n/**\n * Implements start telemetry command for the public runtime surface of this module.\n */\nexport async function startTelemetryCommand(context: TelemetryCommandContext): Promise<ActiveTelemetryCommand | null> {\n if (telemetryDisabledByEnvironment()) {\n return null;\n }\n if (\n context.command === \"telemetry\" &&\n context.args.some((token) => token.trim().toLowerCase() === \"clear\")\n ) {\n return null;\n }\n try {\n const globalPmRoot = resolveGlobalPmRoot(process.cwd());\n const settings = await readSettings(globalPmRoot);\n if (!settings.telemetry.enabled) {\n return null;\n }\n const captureLevel = normalizeCaptureLevel(settings.telemetry.capture_level);\n const { installationId, endpoint, retentionDays } = await ensureInstallationId(globalPmRoot);\n const pmVersion = normalizePmVersion(context.pm_version);\n const sourceContext = resolveTelemetrySourceContext(context.global);\n const pmRootHash = hashWithInstallationId(installationId, context.pm_root);\n const cwdHash = hashWithInstallationId(installationId, process.cwd());\n const otelTracesEndpoint = resolveOtelTracesEndpoint();\n const occurredAt = nowIso();\n const event: TelemetryEvent = {\n schema_version: TELEMETRY_SCHEMA_VERSION,\n event_id: crypto.randomUUID(),\n event_type: \"command_start\",\n occurred_at: occurredAt,\n installation_id: installationId,\n session_id: PROCESS_SESSION_ID,\n command: context.command,\n payload: buildCommandStartPayload({\n captureLevel,\n context,\n pmVersion,\n sourceContext,\n pmRootHash,\n cwdHash,\n installationId,\n }),\n };\n await enqueueTelemetryEvent(globalPmRoot, event);\n scheduleTelemetryFlush(globalPmRoot, endpoint, retentionDays);\n const commandTaxonomy = deriveTelemetryCommandTaxonomy(context.command);\n return {\n started_at: occurredAt,\n started_at_ms: Date.now(),\n command: context.command,\n command_taxonomy: commandTaxonomy,\n pm_version: pmVersion,\n source_context: sourceContext.source_context,\n source_context_source: sourceContext.source_context_source,\n installation_id: installationId,\n pm_root_hash: pmRootHash,\n cwd_hash: cwdHash,\n endpoint,\n retention_days: retentionDays,\n global_pm_root: globalPmRoot,\n capture_level: captureLevel,\n otel_traces_endpoint: otelTracesEndpoint ?? undefined,\n otel_trace_id: otelTracesEndpoint ? crypto.randomBytes(16).toString(\"hex\") : undefined,\n otel_span_id: otelTracesEndpoint ? crypto.randomBytes(8).toString(\"hex\") : undefined,\n };\n } catch {\n // Telemetry must never block command execution.\n return null;\n }\n}\n\n/**\n * Implements finish telemetry command for the public runtime surface of this module.\n */\nexport async function finishTelemetryCommand(\n activeCommand: ActiveTelemetryCommand | null,\n outcome: TelemetryCommandOutcome,\n): Promise<void> {\n if (!activeCommand) {\n return;\n }\n try {\n const finishedAt = nowIso();\n const durationMs = Math.max(0, Date.now() - activeCommand.started_at_ms);\n const normalizedErrorCode = normalizeTelemetryErrorCode(\n inferTelemetryErrorCode({\n ok: outcome.ok,\n errorCode: outcome.error_code,\n errorMessage: outcome.error,\n exitCode: outcome.exit_code,\n }),\n );\n const normalizedErrorCategory = normalizeTelemetryErrorCategory({\n ok: outcome.ok,\n errorCode: normalizedErrorCode,\n errorCategory: outcome.error_category,\n });\n const normalizedExitCode = normalizeTelemetryExitCode(outcome.exit_code, outcome.ok);\n const commandResolution =\n outcome.command_resolution ??\n deriveTelemetryCommandResolution({\n ok: outcome.ok,\n errorCode: normalizedErrorCode,\n errorCategory: normalizedErrorCategory,\n });\n const resolutionStage = outcome.resolution_stage ?? \"execute\";\n const event: TelemetryEvent = {\n schema_version: TELEMETRY_SCHEMA_VERSION,\n event_id: crypto.randomUUID(),\n event_type: \"command_finish\",\n occurred_at: finishedAt,\n installation_id: activeCommand.installation_id,\n session_id: PROCESS_SESSION_ID,\n command: activeCommand.command,\n payload: buildCommandFinishPayload({\n captureLevel: activeCommand.capture_level,\n pmVersion: activeCommand.pm_version,\n sourceContext: {\n source_context: activeCommand.source_context,\n source_context_source: activeCommand.source_context_source,\n },\n outcome,\n durationMs,\n startedAt: activeCommand.started_at,\n command: activeCommand.command,\n installationId: activeCommand.installation_id,\n commandTaxonomy: activeCommand.command_taxonomy,\n exitCode: normalizedExitCode,\n errorCode: normalizedErrorCode,\n errorCategory: normalizedErrorCategory,\n commandResolution,\n resolutionStage,\n }),\n };\n await enqueueTelemetryEvent(activeCommand.global_pm_root, event);\n const otelRequest = buildOtelSpanRequest(\n activeCommand,\n {\n ...outcome,\n exit_code: normalizedExitCode,\n error_code: normalizedErrorCode,\n error_category: normalizedErrorCategory,\n },\n finishedAt,\n durationMs,\n );\n if (otelRequest) {\n // Persist the span for the detached worker; never POST inline so the\n // foreground command exits promptly even if the traces endpoint is\n // unreachable (GH-209).\n await enqueuePendingOtelSpan(activeCommand.global_pm_root, otelRequest);\n }\n scheduleTelemetryFlush(activeCommand.global_pm_root, activeCommand.endpoint, activeCommand.retention_days);\n } catch {\n // Telemetry must never block command execution.\n }\n}\n\n/**\n * Implements emit telemetry error event for the public runtime surface of this module.\n */\nexport async function emitTelemetryErrorEvent(context: TelemetryErrorEventContext): Promise<void> {\n if (telemetryDisabledByEnvironment()) {\n return;\n }\n try {\n const globalPmRoot = resolveGlobalPmRoot(process.cwd());\n const settings = await readSettings(globalPmRoot);\n if (!settings.telemetry.enabled) {\n return;\n }\n const captureLevel = normalizeCaptureLevel(settings.telemetry.capture_level);\n const { installationId, endpoint, retentionDays } = await ensureInstallationId(globalPmRoot);\n const pmVersion = normalizePmVersion(context.pm_version);\n const sourceContext = resolveTelemetrySourceContext(context.global);\n const pmRootHash = hashWithInstallationId(installationId, context.pm_root);\n const cwdHash = hashWithInstallationId(installationId, process.cwd());\n const occurredAt = nowIso();\n const normalizedErrorCode =\n normalizeTelemetryErrorCode(\n inferTelemetryErrorCode({\n ok: false,\n errorCode: context.error_code,\n errorMessage: context.error_message,\n exitCode: context.exit_code,\n }),\n ) as string;\n const normalizedErrorCategory =\n context.error_category ?? resolveTelemetryErrorCategory(normalizedErrorCode);\n const normalizedExitCode = normalizeTelemetryExitCode(context.exit_code, false);\n const normalizedCommand = context.command.trim().length > 0 ? context.command : \"<unknown>\";\n const commandTaxonomy = deriveTelemetryCommandTaxonomy(normalizedCommand);\n const commandResolution =\n context.command_resolution ??\n deriveTelemetryCommandResolution({\n ok: false,\n errorCode: normalizedErrorCode,\n errorCategory: normalizedErrorCategory,\n });\n const resolutionStage = context.resolution_stage ?? \"unknown\";\n\n const event: TelemetryEvent = {\n schema_version: TELEMETRY_SCHEMA_VERSION,\n event_id: crypto.randomUUID(),\n event_type: \"command_error\",\n occurred_at: occurredAt,\n installation_id: installationId,\n session_id: PROCESS_SESSION_ID,\n command: sanitizeString(normalizedCommand, \"redacted\"),\n payload: buildCommandErrorPayload({\n captureLevel,\n pmVersion,\n sourceContext,\n command: normalizedCommand,\n commandTaxonomy,\n commandResolution,\n resolutionStage,\n args: context.args,\n options: context.options,\n pmRootHash,\n cwdHash,\n installationId,\n errorCode: normalizedErrorCode,\n errorCategory: normalizedErrorCategory,\n exitCode: normalizedExitCode,\n errorMessage: context.error_message,\n }),\n };\n await enqueueTelemetryEvent(globalPmRoot, event);\n scheduleTelemetryFlush(globalPmRoot, endpoint, retentionDays);\n } catch {\n // Telemetry must never block command execution.\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AA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AAQ;MACnB,cAAc,QAAQ;MACtB,UAAU,QAAQ;KACnB,CAAC;AAEN,UAAM,0BACJ,QAAQ,kBAAkB,8BAA8B,mBAAmB;AAC7E,UAAM,qBAAqB,2BAA2B,QAAQ,WAAW,KAAK;AAC9E,UAAM,oBAAoB,QAAQ,QAAQ,KAAI,EAAG,SAAS,IAAI,QAAQ,UAAU;AAChF,UAAM,kBAAkB,+BAA+B,iBAAiB;AACxE,UAAM,oBACJ,QAAQ,sBACR,iCAAiC;MAC/B,IAAI;MACJ,WAAW;MACX,eAAe;KAChB;AACH,UAAM,kBAAkB,QAAQ,oBAAoB;AAEpD,UAAM,QAAwB;MAC5B,gBAAgB;MAChB,UAAU,OAAO,WAAU;MAC3B,YAAY;MACZ,aAAa;MACb,iBAAiB;MACjB,YAAY;MACZ,SAAS,eAAe,mBAAmB,UAAU;MACrD,SAAS,yBAAyB;QAChC;QACA;QACA;QACA,SAAS;QACT;QACA;QACA;QACA,MAAM,QAAQ;QACd,SAAS,QAAQ;QACjB;QACA;QACA;QACA,WAAW;QACX,eAAe;QACf,UAAU;QACV,cAAc,QAAQ;OACvB;;AAEH,UAAM,sBAAsB,cAAc,KAAK;AAC/C,2BAAuB,cAAc,UAAU,aAAa;EAC9D,QAAQ;EAER;AACF;",
6
+ "names": ["errorCode", "errorCode", "remaining"]
7
+ }
@@ -1,21 +1,18 @@
1
1
  import {
2
2
  readHistoryEntries
3
- } from "./chunk-BB6MDVNQ.js";
3
+ } from "./chunk-IBU2LLWM.js";
4
4
  import {
5
5
  parseLimit
6
- } from "./chunk-T5472OMV.js";
6
+ } from "./chunk-7L6TXOOC.js";
7
7
  import {
8
8
  enforceHistoryStreamPolicyForItems,
9
9
  listAllFrontMatterLight
10
- } from "./chunk-IPKJ6B36.js";
11
- import {
12
- resolveItemTypeRegistry
13
- } from "./chunk-YJ3SUEPD.js";
10
+ } from "./chunk-LBH7UYKY.js";
14
11
  import {
15
12
  compareTimestampStrings,
16
13
  nowIso,
17
14
  resolveIsoOrRelative
18
- } from "./chunk-P77P2ILI.js";
15
+ } from "./chunk-MLHX6DN5.js";
19
16
  import {
20
17
  EXIT_CODE,
21
18
  PmCliError,
@@ -23,9 +20,10 @@ import {
23
20
  getSettingsPath,
24
21
  pathExists,
25
22
  readSettings,
23
+ resolveItemTypeRegistry,
26
24
  resolvePmRoot,
27
25
  runActiveOnReadHooks
28
- } from "./chunk-MJTSZKK5.js";
26
+ } from "./chunk-SNUK7H5J.js";
29
27
 
30
28
  // dist/cli/commands/activity.js
31
29
  import fs from "node:fs/promises";
@@ -193,4 +191,4 @@ export {
193
191
  _testOnly,
194
192
  runActivity
195
193
  };
196
- //# sourceMappingURL=chunk-M4T5DXD5.js.map
194
+ //# sourceMappingURL=chunk-IF4ERU6A.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../../cli/commands/activity.ts"],
4
4
  "sourcesContent": ["/**\n * @module cli/commands/activity\n *\n * Implements the pm activity command surface and its agent-facing runtime behavior.\n */\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { getActiveExtensionRegistrations, runActiveOnReadHooks } from \"../../core/extensions/index.js\";\nimport { pathExists } from \"../../core/fs/fs-utils.js\";\nimport { enforceHistoryStreamPolicyForItems } from \"../../core/history/history-stream-policy.js\";\nimport { resolveItemTypeRegistry } from \"../../core/item/type-registry.js\";\nimport { EXIT_CODE } from \"../../core/shared/constants.js\";\nimport type { GlobalOptions } from \"../../core/shared/command-types.js\";\nimport { PmCliError } from \"../../core/shared/errors.js\";\nimport { compareTimestampStrings, nowIso, resolveIsoOrRelative } from \"../../core/shared/time.js\";\nimport { listAllFrontMatterLight } from \"../../core/store/item-store.js\";\nimport { getSettingsPath, resolvePmRoot } from \"../../core/store/paths.js\";\nimport { readSettings } from \"../../core/store/settings.js\";\nimport { readHistoryEntries } from \"./history.js\";\nimport { parseLimit } from \"../shared-parsers.js\";\nimport type { HistoryEntry } from \"../../types/index.js\";\n\n/**\n * Documents the activity command options payload exchanged by command, SDK, and package integrations.\n */\nexport interface ActivityCommandOptions {\n id?: string;\n op?: string;\n author?: string;\n from?: string;\n to?: string;\n limit?: string;\n compact?: boolean;\n}\n\n/**\n * Documents the activity entry payload exchanged by command, SDK, and package integrations.\n */\nexport interface ActivityEntry extends HistoryEntry {\n id: string;\n}\n\n/**\n * Documents the compact activity entry payload exchanged by command, SDK, and package integrations.\n */\nexport interface CompactActivityEntry {\n id: string;\n op: string;\n ts: string;\n author: string;\n msg?: string;\n}\n\n/**\n * Documents the activity result payload exchanged by command, SDK, and package integrations.\n */\nexport interface ActivityResult {\n activity: ActivityEntry[];\n compact_activity?: CompactActivityEntry[];\n compact: boolean;\n count: number;\n limit: number | null;\n}\n\nfunction parseNonEmptyFilter(raw: string | undefined, flagLabel: string): string | undefined {\n if (raw === undefined) return undefined;\n const normalized = raw.trim();\n if (normalized.length === 0) {\n throw new PmCliError(`${flagLabel} must not be empty`, EXIT_CODE.USAGE);\n }\n return normalized;\n}\n\nfunction parseRangeBound(raw: string | undefined, nowValue: string, fieldLabel: string): string | undefined {\n if (raw === undefined) return undefined;\n const normalized = raw.trim();\n if (normalized.length === 0) {\n throw new PmCliError(\"Activity time bounds must not be empty\", EXIT_CODE.USAGE);\n }\n return resolveIsoOrRelative(normalized, new Date(nowValue), fieldLabel);\n}\n\nfunction includeByTimeWindow(entry: ActivityEntry, from: string | undefined, to: string | undefined): boolean {\n if (entry.ts.length === 0 && (from || to)) {\n return false;\n }\n if (from && compareTimestampStrings(entry.ts, from) < 0) {\n return false;\n }\n if (to && compareTimestampStrings(entry.ts, to) >= 0) {\n return false;\n }\n return true;\n}\n\nfunction limitEntries<T>(values: T[], limit: number | undefined): T[] {\n if (limit === undefined) return values;\n return values.slice(0, limit);\n}\n\nfunction readActivityString(value: unknown, fallback = \"\"): string {\n return typeof value === \"string\" ? value : fallback;\n}\n\nfunction normalizeActivityEntry(id: string, entry: HistoryEntry): ActivityEntry {\n return {\n ...entry,\n id,\n ts: readActivityString(entry.ts),\n author: readActivityString(entry.author, \"unknown\"),\n op: readActivityString(entry.op, \"unknown\"),\n patch: Array.isArray(entry.patch) ? entry.patch : [],\n before_hash: readActivityString(entry.before_hash),\n after_hash: readActivityString(entry.after_hash),\n };\n}\n\nfunction sortActivity(entries: ActivityEntry[]): ActivityEntry[] {\n return [...entries].sort((a, b) => {\n const byTimestamp = b.ts.localeCompare(a.ts);\n if (byTimestamp !== 0) return byTimestamp;\n const byId = a.id.localeCompare(b.id);\n if (byId !== 0) return byId;\n return a.op.localeCompare(b.op);\n });\n}\n\nasync function listHistoryFiles(historyDir: string): Promise<string[]> {\n try {\n return (await fs.readdir(historyDir))\n .filter((entry) => entry.endsWith(\".jsonl\"))\n .sort((a, b) => a.localeCompare(b));\n } catch (error: unknown) {\n // Activity should degrade gracefully when optional history storage is absent.\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") {\n return [];\n }\n throw error;\n }\n}\n\nexport const _testOnly = {\n parseNonEmptyFilter,\n parseRangeBound,\n includeByTimeWindow,\n limitEntries,\n readActivityString,\n normalizeActivityEntry,\n sortActivity,\n listHistoryFiles,\n};\n\n/**\n * Implements run activity for the public runtime surface of this module.\n */\nexport async function runActivity(options: ActivityCommandOptions, global: GlobalOptions): Promise<ActivityResult> {\n const pmRoot = resolvePmRoot(process.cwd(), global.path);\n if (!(await pathExists(getSettingsPath(pmRoot)))) {\n throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);\n }\n\n const nowValue = nowIso();\n const idFilter = parseNonEmptyFilter(options.id, \"Activity --id\");\n const opFilter = parseNonEmptyFilter(options.op, \"Activity --op\");\n const authorFilter = parseNonEmptyFilter(options.author, \"Activity --author\");\n const fromBound = parseRangeBound(options.from, nowValue, \"--from\");\n const toBound = parseRangeBound(options.to, nowValue, \"--to\");\n if (fromBound && toBound && compareTimestampStrings(fromBound, toBound) >= 0) {\n throw new PmCliError(\"Activity --from must be before --to\", EXIT_CODE.USAGE);\n }\n const limit = parseLimit(options.limit);\n const settings = await readSettings(pmRoot);\n const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());\n const items = await listAllFrontMatterLight(pmRoot, settings.item_format, typeRegistry.type_to_folder, undefined, settings.schema);\n await enforceHistoryStreamPolicyForItems({\n pmRoot,\n settings,\n itemIds: items.map((item) => item.id),\n commandLabel: \"activity\",\n });\n const historyDir = path.join(pmRoot, \"history\");\n await runActiveOnReadHooks({\n path: historyDir,\n scope: \"project\",\n });\n const historyFiles = await listHistoryFiles(historyDir);\n\n const combined: ActivityEntry[] = [];\n for (const file of historyFiles) {\n const id = file.slice(0, -\".jsonl\".length);\n if (idFilter && id !== idFilter) {\n continue;\n }\n const entries = await readHistoryEntries(path.join(historyDir, file), id);\n for (const entry of entries) {\n if (opFilter && entry.op !== opFilter) {\n continue;\n }\n if (authorFilter && entry.author !== authorFilter) {\n continue;\n }\n const candidate = normalizeActivityEntry(id, entry);\n if (!includeByTimeWindow(candidate, fromBound, toBound)) {\n continue;\n }\n combined.push({\n ...candidate,\n });\n }\n }\n\n const activity = limitEntries(sortActivity(combined), limit);\n const compact = options.compact === true;\n const compactActivity = compact\n ? activity.map((entry): CompactActivityEntry => ({\n id: entry.id,\n op: entry.op,\n ts: entry.ts,\n author: entry.author,\n ...(entry.message ? { msg: entry.message } : {}),\n }))\n : undefined;\n return {\n activity: compact ? [] : activity,\n compact_activity: compactActivity,\n compact,\n count: activity.length,\n limit: limit ?? null,\n };\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,OAAO,QAAQ;AACf,OAAO,UAAU;;;;;;;;AA0DjB,SAAS,oBAAoB,KAAyB,WAAiB;AACrE,MAAI,QAAQ;AAAW,WAAO;AAC9B,QAAM,aAAa,IAAI,KAAI;AAC3B,MAAI,WAAW,WAAW,GAAG;AAC3B,UAAM,IAAI,WAAW,GAAG,SAAS,sBAAsB,UAAU,KAAK;EACxE;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;IAChB,OAAO,SAAS;;AAEpB;",
6
6
  "names": ["global"]
7
7
  }
@@ -2,14 +2,14 @@
2
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]="7919579f-9834-5809-8c55-f7618807569e")}catch(e){}}();
3
3
  import {
4
4
  verifyHistoryChain
5
- } from "./chunk-WM5ZVBPE.js";
5
+ } from "./chunk-SJZTPVFT.js";
6
6
  import {
7
7
  hashDocument
8
- } from "./chunk-5UVVASSA.js";
8
+ } from "./chunk-KGQ3W65B.js";
9
9
  import {
10
10
  getHistoryPath,
11
11
  writeFileAtomic
12
- } from "./chunk-UELRKQQU.js";
12
+ } from "./chunk-CY5IJMUM.js";
13
13
 
14
14
  // dist/core/history/drift-scan.js
15
15
  import fs from "fs/promises";
@@ -187,6 +187,6 @@ async function scanHistoryDrift(pmRoot, items, options = {}) {
187
187
  export {
188
188
  scanHistoryDrift
189
189
  };
190
- //# sourceMappingURL=chunk-CIIK67GW.js.map
190
+ //# sourceMappingURL=chunk-IHXXUIXS.js.map
191
191
 
192
192
  //# debugId=7919579f-9834-5809-8c55-f7618807569e