@vercel/cli-support 65.3.1 → 65.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (257) hide show
  1. package/README.md +1 -1
  2. package/dist/chunks/add-7NS6HIWC.js +8 -0
  3. package/dist/chunks/add-NMYFDVXW.js +8 -0
  4. package/dist/chunks/add-PMJ5BECU.js +8 -0
  5. package/dist/chunks/build-BCY6HQJG.js +7 -0
  6. package/dist/chunks/{chunk-SKYDLHEZ.js → chunk-2K3ISCQ6.js} +1 -1
  7. package/dist/chunks/{chunk-BL3HBRF6.js → chunk-2TUVL6WE.js} +1 -1
  8. package/dist/chunks/{chunk-22FDWPWY.js → chunk-363SJ4TN.js} +1 -1
  9. package/dist/chunks/chunk-462YCCJZ.js +7 -0
  10. package/dist/chunks/{chunk-KNLGWGUE.js → chunk-4N6LMERQ.js} +6 -6
  11. package/dist/chunks/chunk-527GBU3K.js +7 -0
  12. package/dist/chunks/chunk-5IWFRZQT.js +10 -0
  13. package/dist/chunks/chunk-5KUUMQ3M.js +7 -0
  14. package/dist/chunks/{chunk-IVSC7ZFJ.js → chunk-5V53NA6C.js} +1 -1
  15. package/dist/chunks/chunk-6I6QJHCY.js +7 -0
  16. package/dist/chunks/chunk-6TXEVQA4.js +7 -0
  17. package/dist/chunks/{chunk-2PKEEQ5W.js → chunk-6YXIWZ3X.js} +1 -1
  18. package/dist/chunks/{chunk-7HV7O6DM.js → chunk-7E3WREH5.js} +1 -1
  19. package/dist/chunks/{chunk-Y6AGOERS.js → chunk-7L5QUDUR.js} +1 -1
  20. package/dist/chunks/{chunk-X4762EE4.js → chunk-7QAGSRCU.js} +1 -1
  21. package/dist/chunks/{chunk-NTZ5WWYV.js → chunk-7R6TRRG5.js} +1 -1
  22. package/dist/chunks/{chunk-WCWP4GBR.js → chunk-AYUUSAB7.js} +1 -1
  23. package/dist/chunks/chunk-BVGGTBYE.js +7 -0
  24. package/dist/chunks/{chunk-YN3C5BL5.js → chunk-C7FQMC6D.js} +1 -1
  25. package/dist/chunks/{chunk-2U7DJZSQ.js → chunk-CBVKB3DT.js} +1 -1
  26. package/dist/chunks/{chunk-FDNYYENK.js → chunk-CC6FLKIP.js} +1 -1
  27. package/dist/chunks/chunk-CR3NBTHV.js +7 -0
  28. package/dist/chunks/{chunk-BBKEP7RO.js → chunk-CWM2F235.js} +1 -1
  29. package/dist/chunks/{chunk-IUXSJWL3.js → chunk-DKJL2KV7.js} +1 -1
  30. package/dist/chunks/{chunk-2ACMWVTB.js → chunk-DQ2SVW4R.js} +1 -1
  31. package/dist/chunks/{chunk-SLI2O5X7.js → chunk-EAXMWCOL.js} +2 -2
  32. package/dist/chunks/{chunk-LRYGNQ6C.js → chunk-ECEDD646.js} +1 -1
  33. package/dist/chunks/{chunk-IGDG5CWT.js → chunk-EEUJLJEJ.js} +1 -1
  34. package/dist/chunks/{chunk-VQSLPYAF.js → chunk-EGNR2DEI.js} +1 -1
  35. package/dist/chunks/chunk-EISD3RG7.js +11 -0
  36. package/dist/chunks/{chunk-GVTXA6HG.js → chunk-EKZTFGDX.js} +1 -1
  37. package/dist/chunks/{chunk-CEMPU323.js → chunk-EU2GBIPC.js} +1 -1
  38. package/dist/chunks/{chunk-3ADDGPEN.js → chunk-F6EBOT64.js} +1 -1
  39. package/dist/chunks/chunk-FHU2O7ZJ.js +8 -0
  40. package/dist/chunks/{chunk-KH6565YH.js → chunk-FLHO75XC.js} +1 -1
  41. package/dist/chunks/chunk-FSPPKNKN.js +7 -0
  42. package/dist/chunks/{chunk-43GBAKL2.js → chunk-GCZVIDNG.js} +1 -1
  43. package/dist/chunks/{chunk-G4T7VBGN.js → chunk-HSFKISDH.js} +1 -1
  44. package/dist/chunks/{chunk-OQCMRU3J.js → chunk-HTXDC7E2.js} +2 -2
  45. package/dist/chunks/{chunk-76SVVWPH.js → chunk-IOZ3I765.js} +1 -1
  46. package/dist/chunks/{chunk-UKQMYTWW.js → chunk-JLE7K4SY.js} +1 -1
  47. package/dist/chunks/{chunk-3JGBBS6V.js → chunk-JP33AIDQ.js} +1 -1
  48. package/dist/chunks/{chunk-ULHNMQ7C.js → chunk-JRPNHWA3.js} +1 -1
  49. package/dist/chunks/{chunk-D2BZMGHP.js → chunk-JUSR7V2L.js} +1 -1
  50. package/dist/chunks/{chunk-XB4SKARZ.js → chunk-JWCEHQQF.js} +1 -1
  51. package/dist/chunks/chunk-K5U47EVH.js +7 -0
  52. package/dist/chunks/{chunk-VOCZ34ON.js → chunk-KCKYPLIH.js} +1 -1
  53. package/dist/chunks/{chunk-2WYYGGEO.js → chunk-KGBIRIFF.js} +1 -1
  54. package/dist/chunks/{chunk-RRREFECI.js → chunk-KJA2GKPT.js} +1 -1
  55. package/dist/chunks/{chunk-S5IWVPYT.js → chunk-KPQLUGFI.js} +1 -1
  56. package/dist/chunks/{chunk-S4SJ7GIZ.js → chunk-KQCFC2JL.js} +1 -1
  57. package/dist/chunks/{chunk-XXXRTHTP.js → chunk-KQCROPL3.js} +1 -1
  58. package/dist/chunks/{chunk-3KKFLKQG.js → chunk-KY335KWI.js} +1 -1
  59. package/dist/chunks/{chunk-OWOWPOIE.js → chunk-L3JYCXVB.js} +1 -1
  60. package/dist/chunks/chunk-LFOWP74R.js +7 -0
  61. package/dist/chunks/{chunk-PFNYWWLI.js → chunk-LOBA3E72.js} +1 -1
  62. package/dist/chunks/{chunk-XZV4BFM5.js → chunk-LQVSU5HR.js} +1 -1
  63. package/dist/chunks/{chunk-2H3SB5RP.js → chunk-LW4N3CW6.js} +1 -1
  64. package/dist/chunks/{chunk-6ISAISGD.js → chunk-M2NXKZKX.js} +1 -1
  65. package/dist/chunks/{chunk-F2SWJEYV.js → chunk-MBEKRUTQ.js} +1 -1
  66. package/dist/chunks/{chunk-UJSW56GS.js → chunk-N2FLYCCO.js} +1 -1
  67. package/dist/chunks/{chunk-ZH6KHD55.js → chunk-N6JBQMOF.js} +2 -2
  68. package/dist/chunks/{chunk-OCQPXOTX.js → chunk-NAX6IARA.js} +1 -1
  69. package/dist/chunks/{chunk-4UGHFESV.js → chunk-NGKO2OOU.js} +1 -1
  70. package/dist/chunks/chunk-NW7WWUCQ.js +9 -0
  71. package/dist/chunks/chunk-O4WNSKQR.js +15 -0
  72. package/dist/chunks/{chunk-7Z3WUAO5.js → chunk-O72YDZKD.js} +1 -1
  73. package/dist/chunks/{chunk-LKLH6DZP.js → chunk-OHEOYFBU.js} +1 -1
  74. package/dist/chunks/{chunk-LJBUJ23M.js → chunk-OZCQTXI4.js} +1 -1
  75. package/dist/chunks/{chunk-LCHECISY.js → chunk-Q4KTAQB3.js} +1 -1
  76. package/dist/chunks/{chunk-TZFDVQ72.js → chunk-QIVX6SCR.js} +1 -1
  77. package/dist/chunks/{chunk-7Y46LB43.js → chunk-QVHXFHBV.js} +1 -1
  78. package/dist/chunks/chunk-QVXS234E.js +7 -0
  79. package/dist/chunks/{chunk-SXOSF4O6.js → chunk-QVZAAMGQ.js} +1 -1
  80. package/dist/chunks/chunk-R2BUF6Z7.js +7 -0
  81. package/dist/chunks/{chunk-OGPENBY2.js → chunk-R2XHJDAP.js} +1 -1
  82. package/dist/chunks/{chunk-E6CO6TUM.js → chunk-RMZTB2IU.js} +1 -1
  83. package/dist/chunks/{chunk-LT3UK4K6.js → chunk-SLGUYM42.js} +1 -1
  84. package/dist/chunks/{chunk-7BGKE3JW.js → chunk-SYFG2RM6.js} +1 -1
  85. package/dist/chunks/chunk-T6243EDS.js +7 -0
  86. package/dist/chunks/chunk-TAISZMA2.js +7 -0
  87. package/dist/chunks/{chunk-TO5PJDEN.js → chunk-TEYREL44.js} +1 -1
  88. package/dist/chunks/{chunk-6KVHNQW4.js → chunk-TIPQQ4TG.js} +1 -1
  89. package/dist/chunks/{chunk-DUT4U5YY.js → chunk-U2OBPULW.js} +1 -1
  90. package/dist/chunks/{chunk-OQPXJCMK.js → chunk-UGNIIDHR.js} +1 -1
  91. package/dist/chunks/{chunk-NQWGRKF4.js → chunk-UHBMX3OK.js} +1 -1
  92. package/dist/chunks/{chunk-QMCHGGDX.js → chunk-VNIKIQVE.js} +1 -1
  93. package/dist/chunks/{chunk-DGYHWXD2.js → chunk-WDXW6A4H.js} +2 -2
  94. package/dist/chunks/{chunk-L4NSF346.js → chunk-WEH6XC4Y.js} +1 -1
  95. package/dist/chunks/{chunk-TKBORMUF.js → chunk-WKZ6JSGZ.js} +1 -1
  96. package/dist/chunks/{chunk-WGXKX24Q.js → chunk-WVHCBDTB.js} +1 -1
  97. package/dist/chunks/{chunk-COM5YCHF.js → chunk-XC46OAAT.js} +1 -1
  98. package/dist/chunks/{chunk-WBF36MYT.js → chunk-XVDRGWXM.js} +1 -1
  99. package/dist/chunks/{chunk-IKQTP764.js → chunk-Y5ZMKL7E.js} +1 -1
  100. package/dist/chunks/{chunk-NEFDNROD.js → chunk-YEZJNXQX.js} +1 -1
  101. package/dist/chunks/{chunk-VMMMBWD3.js → chunk-YHULP2KK.js} +1 -1
  102. package/dist/chunks/{chunk-OMCGXRSA.js → chunk-YMZ6WBKB.js} +2 -2
  103. package/dist/chunks/{chunk-URPEIX6M.js → chunk-ZN6CQWVP.js} +1 -1
  104. package/dist/chunks/{chunk-YK7XLFU2.js → chunk-ZQBSAMFL.js} +1 -1
  105. package/dist/chunks/clear-FKVWDCVA.js +8 -0
  106. package/dist/chunks/{compile-vercel-config-3IYM2CHC.js → compile-vercel-config-GWAJE44R.js} +1 -1
  107. package/dist/chunks/config-5WVLG5SE.js +8 -0
  108. package/dist/chunks/{config-ZFIC7N4D.js → config-RMOHN5YT.js} +1 -1
  109. package/dist/chunks/config-validator.mjs +1 -1
  110. package/dist/chunks/{constants-ICJL2EO5.js → constants-JAB7MRSK.js} +1 -1
  111. package/dist/chunks/delete-5WMB4WFR.js +9 -0
  112. package/dist/chunks/delete-EM4JZPFA.js +10 -0
  113. package/dist/chunks/{detect-services-MOXTX5XG.js → detect-services-BSJGB4RM.js} +1 -1
  114. package/dist/chunks/disable-QOM7UHQC.js +7 -0
  115. package/dist/chunks/discard-L5ZH7P5B.js +14 -0
  116. package/dist/chunks/edit-F3VJGCG2.js +9 -0
  117. package/dist/chunks/edit-TM7YCWBU.js +8 -0
  118. package/dist/chunks/enable-72C3QX34.js +7 -0
  119. package/dist/chunks/{export-MHSH7QCX.js → export-EPLYZF2Q.js} +1 -1
  120. package/dist/chunks/{future-FFOGTKMF.js → future-V77DRMQG.js} +1 -1
  121. package/dist/chunks/generate-cert-for-deploy-Y3YHBMPU.js +7 -0
  122. package/dist/chunks/{image-7METSS6F.js → image-CVXEXU5R.js} +1 -1
  123. package/dist/chunks/{import-builders-GM2SERWV.js → import-builders-PGRKJOOE.js} +1 -1
  124. package/dist/chunks/inspect-BTRNXRJT.js +9 -0
  125. package/dist/chunks/{inspect-IAWVHJXQ.js → inspect-CZ7WXYE5.js} +1 -1
  126. package/dist/chunks/inspect-FGDVWAQP.js +13 -0
  127. package/dist/chunks/{inspect-A7WJQQZO.js → inspect-HFDGZNWC.js} +1 -1
  128. package/dist/chunks/{inspect-DI434TAM.js → inspect-T2AIREYK.js} +1 -1
  129. package/dist/chunks/list-CKRRHAOE.js +12 -0
  130. package/dist/chunks/{list-WWU734RK.js → list-FLREMGJR.js} +1 -1
  131. package/dist/chunks/{list-INRPH25K.js → list-ON4YTQRN.js} +1 -1
  132. package/dist/chunks/login-55LJ5ZA6.js +9 -0
  133. package/dist/chunks/{login-R5NQRPQC.js → login-DQRZSD4Z.js} +1 -1
  134. package/dist/chunks/logs-2HQXWOHM.js +7 -0
  135. package/dist/chunks/{ls-S5E2NQMI.js → ls-2HUJHVLA.js} +1 -1
  136. package/dist/chunks/{ls-V2ZSIVO3.js → ls-3DVM5HLK.js} +1 -1
  137. package/dist/chunks/ls-4B3QYHCI.js +8 -0
  138. package/dist/chunks/{ls-MCQ2NS65.js → ls-A7K4XDQB.js} +1 -1
  139. package/dist/chunks/{ls-LIGIBVAT.js → ls-FK5XEJEU.js} +1 -1
  140. package/dist/chunks/{ls-VXH4QYF5.js → ls-QGUKJJY5.js} +1 -1
  141. package/dist/chunks/ls-VTKHPDWS.js +11 -0
  142. package/dist/chunks/mutate-7ADZBCZM.js +9 -0
  143. package/dist/chunks/{notifications-KFZ333V5.js → notifications-XZJXE2K4.js} +1 -1
  144. package/dist/chunks/open-EE5IZQD7.js +7 -0
  145. package/dist/chunks/{openapi-JGYEFJJV.js → openapi-QBX62ZXC.js} +1 -1
  146. package/dist/chunks/{permissions-ZSHKMXBZ.js → permissions-VYJ4LL5R.js} +1 -1
  147. package/dist/chunks/{plugin-offer-Z6FCPQFD.js → plugin-offer-TEGYA3TA.js} +1 -1
  148. package/dist/chunks/{prompt-missing-credentials-KOA7C4QC.js → prompt-missing-credentials-VP6OVCFM.js} +1 -1
  149. package/dist/chunks/publish-2HEK5UMJ.js +15 -0
  150. package/dist/chunks/pull-WRTTSY7J.js +7 -0
  151. package/dist/chunks/purchase-domain-if-available-6S3NLTUI.js +7 -0
  152. package/dist/chunks/push-L3QRGGLC.js +7 -0
  153. package/dist/chunks/{query-JGPO7TNY.js → query-FXXLX6UB.js} +3 -3
  154. package/dist/chunks/{reauthenticate-OZRQFR66.js → reauthenticate-IXQDC4UZ.js} +1 -1
  155. package/dist/chunks/reorder-B4OXSYCI.js +10 -0
  156. package/dist/chunks/reply-F637K6XH.js +9 -0
  157. package/dist/chunks/resolve-E3F6NYQZ.js +12 -0
  158. package/dist/chunks/{resolve-agent-team-KX77HEAF.js → resolve-agent-team-EIPCH766.js} +1 -1
  159. package/dist/chunks/restore-Q25KRZPH.js +16 -0
  160. package/dist/chunks/rm-FWD2NUGX.js +8 -0
  161. package/dist/chunks/rm-JMQ4QKCC.js +8 -0
  162. package/dist/chunks/rm-PPG7P3GN.js +8 -0
  163. package/dist/chunks/rm-SH3DYKNS.js +8 -0
  164. package/dist/chunks/rm-UEBLKFVC.js +8 -0
  165. package/dist/chunks/{routes-P6LKQCWH.js → routes-PKTWMDWQ.js} +1 -1
  166. package/dist/chunks/rule-inspect-LKQA5I4V.js +8 -0
  167. package/dist/chunks/{schema-YOEAK4VX.js → schema-FBV42W7N.js} +1 -1
  168. package/dist/chunks/{schema-BEUO7G52.js → schema-ZWE5MNMG.js} +1 -1
  169. package/dist/chunks/{select-org-OMLGQEKK.js → select-org-WMB752Z6.js} +1 -1
  170. package/dist/chunks/set-UTYIPOLC.js +7 -0
  171. package/dist/chunks/setup-and-link-ZLY5XQW5.js +7 -0
  172. package/dist/chunks/{skills-4J2NC2QI.js → skills-RKIGVVNM.js} +2 -2
  173. package/dist/chunks/{tags-ZXZQEXOV.js → tags-UCLZ5UMX.js} +1 -1
  174. package/dist/chunks/{types-SK6J2HFE.js → types-YM7TMHXW.js} +1 -1
  175. package/dist/chunks/{update-25CKNOY5.js → update-BGDQ5TXO.js} +1 -1
  176. package/dist/commands/build/index.js +1 -1
  177. package/dist/commands/deploy/index.js +4 -4
  178. package/dist/commands/dev/index.js +4 -4
  179. package/dist/commands/env/index.js +1 -1
  180. package/dist/commands/link/index.js +1 -1
  181. package/dist/commands/list/index.js +1 -1
  182. package/dist/commands/project/index.js +8 -8
  183. package/dist/commands-account.js +8 -8
  184. package/dist/commands-ai.js +12 -12
  185. package/dist/commands-blob.js +8 -8
  186. package/dist/commands-core.js +11 -11
  187. package/dist/commands-deployments.js +1 -1
  188. package/dist/commands-flags.js +6 -6
  189. package/dist/commands-integrations.js +16 -16
  190. package/dist/commands-observability.js +5 -5
  191. package/dist/commands-routing.js +18 -18
  192. package/dist/help.js +1 -1
  193. package/dist/index.js +5 -3
  194. package/dist/internal-build.js +1 -1
  195. package/dist/package.json +60 -61
  196. package/dist/root-help-commands.mjs +1 -1
  197. package/dist/vc.js +148 -137
  198. package/dist/version.mjs +1 -1
  199. package/package.json +54 -54
  200. package/dist/chunks/add-5YZQTIQM.js +0 -8
  201. package/dist/chunks/add-A524QQ2H.js +0 -8
  202. package/dist/chunks/add-V4JMUHKO.js +0 -8
  203. package/dist/chunks/build-K2PVDJZ4.js +0 -7
  204. package/dist/chunks/chunk-3AYYFYZG.js +0 -7
  205. package/dist/chunks/chunk-5IASAERQ.js +0 -7
  206. package/dist/chunks/chunk-76KGQU2G.js +0 -7
  207. package/dist/chunks/chunk-ABZEMNDR.js +0 -7
  208. package/dist/chunks/chunk-APZULWJC.js +0 -8
  209. package/dist/chunks/chunk-AWMQGOS2.js +0 -7
  210. package/dist/chunks/chunk-B4UE4LVE.js +0 -7
  211. package/dist/chunks/chunk-B4YYOSPY.js +0 -7
  212. package/dist/chunks/chunk-E2SADN6I.js +0 -7
  213. package/dist/chunks/chunk-IA3MXJRC.js +0 -8
  214. package/dist/chunks/chunk-IEPW2YRH.js +0 -7
  215. package/dist/chunks/chunk-LUBUI5GF.js +0 -7
  216. package/dist/chunks/chunk-OKEBIUKZ.js +0 -7
  217. package/dist/chunks/chunk-QZX7VG2V.js +0 -9
  218. package/dist/chunks/chunk-RUXO73ON.js +0 -7
  219. package/dist/chunks/chunk-TPNOSQZ3.js +0 -15
  220. package/dist/chunks/chunk-UNEGQPD3.js +0 -7
  221. package/dist/chunks/chunk-V7BEC3E4.js +0 -10
  222. package/dist/chunks/chunk-YHQ7PPXP.js +0 -7
  223. package/dist/chunks/clear-ZS4KQ7OT.js +0 -8
  224. package/dist/chunks/config-N2SBVW4T.js +0 -8
  225. package/dist/chunks/delete-2ZE2NVHI.js +0 -10
  226. package/dist/chunks/delete-AL57HZDQ.js +0 -9
  227. package/dist/chunks/disable-MKI3BKNH.js +0 -7
  228. package/dist/chunks/discard-SI4H7ST3.js +0 -14
  229. package/dist/chunks/edit-DNWH6SPE.js +0 -8
  230. package/dist/chunks/edit-WYNWDFUJ.js +0 -9
  231. package/dist/chunks/enable-J6MMYPYF.js +0 -7
  232. package/dist/chunks/generate-cert-for-deploy-YZKNGAEQ.js +0 -7
  233. package/dist/chunks/inspect-H2Q7XOWN.js +0 -13
  234. package/dist/chunks/inspect-H5JC2XKI.js +0 -9
  235. package/dist/chunks/list-ELEUTZWJ.js +0 -12
  236. package/dist/chunks/login-ZF2TLCQB.js +0 -9
  237. package/dist/chunks/logs-UD7FEXZ7.js +0 -7
  238. package/dist/chunks/ls-5ZEAKKPQ.js +0 -8
  239. package/dist/chunks/ls-IXRLAJ4L.js +0 -11
  240. package/dist/chunks/mutate-OQWOKLIW.js +0 -9
  241. package/dist/chunks/open-HH6K7ZRC.js +0 -7
  242. package/dist/chunks/publish-FPNQ2US4.js +0 -15
  243. package/dist/chunks/pull-7OGOIKB3.js +0 -7
  244. package/dist/chunks/purchase-domain-if-available-F4LKHVBD.js +0 -7
  245. package/dist/chunks/push-NY3SIK2C.js +0 -7
  246. package/dist/chunks/reorder-4J2STFUS.js +0 -10
  247. package/dist/chunks/reply-EO4NTTPW.js +0 -9
  248. package/dist/chunks/resolve-RPHHRPNM.js +0 -12
  249. package/dist/chunks/restore-TEA6TSVK.js +0 -16
  250. package/dist/chunks/rm-BPILSPUI.js +0 -8
  251. package/dist/chunks/rm-F6XVUDBM.js +0 -8
  252. package/dist/chunks/rm-JCPXV2FN.js +0 -8
  253. package/dist/chunks/rm-LPQRGX7N.js +0 -8
  254. package/dist/chunks/rm-WHUGT6TE.js +0 -8
  255. package/dist/chunks/rule-inspect-BOETGPFO.js +0 -8
  256. package/dist/chunks/set-5XY27S7R.js +0 -7
  257. package/dist/chunks/setup-and-link-A7M3QT52.js +0 -7
@@ -4,7 +4,7 @@ import { dirname as __dirname_ } from 'node:path';
4
4
  const require = __createRequire(import.meta.url);
5
5
  const __filename = __fileURLToPath(import.meta.url);
6
6
  const __dirname = __dirname_(__filename);
7
- import{handleTracingApiError,invalidArguments,resolveConfigScope,resolveScope,tracingErrorMessage,tracingErrorReason}from"./chunks/chunk-XZV4BFM5.js";import{main}from"./chunks/chunk-UKQMYTWW.js";import{remoteText}from"./chunks/chunk-GYVJIIYL.js";import{InvalidEventsResponseError,RecordTooLargeError,decodeContinuation,encodeContinuation,fetchEventPages,sortIntervals,warningLine}from"./chunks/chunk-XXXRTHTP.js";import{recordLine,summaryLine,writeJsonError}from"./chunks/chunk-7Z3WUAO5.js";import"./chunks/chunk-RRREFECI.js";import{readStdinText}from"./chunks/chunk-PSOVLGHP.js";import"./chunks/chunk-XOETL6DB.js";import{runCurl}from"./chunks/chunk-LT3UK4K6.js";import{applyDeprecatedGitBranchFlag}from"./chunks/chunk-CEMPU323.js";import"./chunks/chunk-F2SWJEYV.js";import{decodeListCursor,sliceList}from"./chunks/chunk-VQSLPYAF.js";import{parseRepoUrl}from"./chunks/chunk-IQKGQ2Y2.js";import"./chunks/chunk-EAUDC24V.js";import"./chunks/chunk-RRDNKB2X.js";import"./chunks/chunk-MVGTMPMI.js";import"./chunks/chunk-SACGQMVQ.js";import{ellipsis}from"./chunks/chunk-F4KY2TOK.js";import{validateIntegerRangeWithDefault}from"./chunks/chunk-RW3X523R.js";import"./chunks/chunk-ID663OJ7.js";import{printUnknownCommand}from"./chunks/chunk-V7BEC3E4.js";import"./chunks/chunk-2EYYB6YN.js";import{external_exports}from"./chunks/chunk-2NABMKFV.js";import{formatTable}from"./chunks/chunk-LSQREJXO.js";import{stamp_default}from"./chunks/chunk-A2RZZQEP.js";import"./chunks/chunk-Q7D7RGXM.js";import"./chunks/chunk-OWOWPOIE.js";import"./chunks/chunk-YN3C5BL5.js";import"./chunks/chunk-6Y2ZL5XJ.js";import"./chunks/chunk-X4762EE4.js";import"./chunks/chunk-25565AGS.js";import"./chunks/chunk-3JGBBS6V.js";import"./chunks/chunk-L4NSF346.js";import{getRenamedOption}from"./chunks/chunk-IEPW2YRH.js";import"./chunks/chunk-7YKFF6CE.js";import"./chunks/chunk-6OVX3PWM.js";import"./chunks/chunk-OQCMRU3J.js";import{require_open}from"./chunks/chunk-PVASGBEF.js";import"./chunks/chunk-BL3HBRF6.js";import"./chunks/chunk-R6BEOVTU.js";import"./chunks/chunk-HCRD3JFL.js";import"./chunks/chunk-7EJQLVWX.js";import{canPrompt,canPromptOnTerminal}from"./chunks/chunk-IQ7FPAI4.js";import{parseListLimit,printNextPageCommand,printNextPageHint}from"./chunks/chunk-QMCHGGDX.js";import{getSubcommand as getSubcommand2}from"./chunks/chunk-ETV3C2CV.js";import{CI_LOG_LEVELS,ciCommand,createSubcommand4 as createSubcommand,deleteSubcommand,drainsCommand,enableSubcommand,getCommandAliases,grepSubcommand,healthCommand,inspectSubcommand4 as inspectSubcommand,inspectSubcommand7 as inspectSubcommand2,listSubcommand12 as listSubcommand2,listSubcommand6 as listSubcommand,logsSubcommand,pauseSubcommand,rerunSubcommand,resumeSubcommand,updateSubcommand3 as updateSubcommand}from"./chunks/chunk-TPNOSQZ3.js";import{createSubcommand as createSubcommand2,getSubcommand,searchSubcommand,tracesCommand}from"./chunks/chunk-LUBUI5GF.js";import{tracesConfigCommand}from"./chunks/chunk-GVTXA6HG.js";import"./chunks/chunk-5IASAERQ.js";import"./chunks/chunk-WGXKX24Q.js";import"./chunks/chunk-E2SADN6I.js";import"./chunks/chunk-ABZEMNDR.js";import"./chunks/chunk-3AYYFYZG.js";import"./chunks/chunk-76KGQU2G.js";import"./chunks/chunk-UNEGQPD3.js";import"./chunks/chunk-YHQ7PPXP.js";import"./chunks/chunk-NQWGRKF4.js";import"./chunks/chunk-IGDG5CWT.js";import"./chunks/chunk-QZX7VG2V.js";import"./chunks/chunk-3ADDGPEN.js";import"./chunks/chunk-B4YYOSPY.js";import"./chunks/chunk-PFNYWWLI.js";import"./chunks/chunk-NTZ5WWYV.js";import"./chunks/chunk-JALVF3C2.js";import"./chunks/chunk-LJBUJ23M.js";import"./chunks/chunk-OKEBIUKZ.js";import{help}from"./chunks/chunk-KH6565YH.js";import{table}from"./chunks/chunk-773GOZIR.js";import{printError}from"./chunks/chunk-G4T7VBGN.js";import"./chunks/chunk-67GZ5REA.js";import{require_strip_ansi}from"./chunks/chunk-BS32OUOC.js";import"./chunks/chunk-3G3FQYMW.js";import{TelemetryClient}from"./chunks/chunk-2PKEEQ5W.js";import"./chunks/chunk-PUKYAALC.js";import{getContextName,getScope,scopeFlagPassed}from"./chunks/chunk-B4UE4LVE.js";import{require_ms}from"./chunks/chunk-MXTC4ZAQ.js";import"./chunks/chunk-NWGBDBZI.js";import"./chunks/chunk-FGFLTLEA.js";import{AGENT_REASON,AGENT_STATUS,buildCommandWithYes,getErrorRecovery,getExitCodeForReason,getGlobalFlagsFromArgv,outputAgentError,shouldEmitNonInteractiveCommandError,withGlobalFlags,writeAgentError}from"./chunks/chunk-DGYHWXD2.js";import"./chunks/chunk-IUXSJWL3.js";import{execFileAsync,getGitExecutable,getLinkedProject,getProjectByNameOrId,require_pluralize,selectGitRemote,sleep,ua_default}from"./chunks/chunk-KNLGWGUE.js";import{ALIGNED_LABEL_WIDTH,formatAlignedLabel,printAlignedLabel}from"./chunks/chunk-ADLBLGT3.js";import"./chunks/chunk-BBKEP7RO.js";import"./chunks/chunk-4NTBYNFR.js";import{isArgumentError,parseArguments,takeCommand}from"./chunks/chunk-VOCZ34ON.js";import{getTeamByIdOrSlug,quoteArg}from"./chunks/chunk-F53OKXYI.js";import{GLOBAL_CLI_FLAG_NAMES,getFlagsSpecification,validateJsonOutput,warnDeprecatedSubcommand}from"./chunks/chunk-AWMQGOS2.js";import{fetch,toNodeReadable}from"./chunks/chunk-FUX6LKNP.js";import"./chunks/chunk-OPORM35X.js";import"./chunks/chunk-4SAVH3H7.js";import{ProjectNotFound,isAPIError}from"./chunks/chunk-6VH56CX2.js";import{cmd,getCommandName,getCommandNamePlain}from"./chunks/chunk-JESNVRVR.js";import{output_manager_default,recordCliError}from"./chunks/chunk-XP3FT56R.js";import"./chunks/chunk-BLUPZPAS.js";import"./chunks/chunk-RM3ZDRYE.js";import"./chunks/chunk-OO572JUC.js";import"./chunks/chunk-D3AHZ5LI.js";import"./chunks/chunk-2GHZGOWT.js";import"./chunks/chunk-YHPPP3SF.js";import{require_source}from"./chunks/chunk-NB2WLB3J.js";import"./chunks/chunk-ISWW3DKF.js";import"./chunks/chunk-BRQUZ5NC.js";import{__commonJS,__require,__toESM}from"./chunks/chunk-BZENIQ7N.js";var require_split2=__commonJS({"../../node_modules/.pnpm/split2@4.2.0/node_modules/split2/index.js"(exports,module){"use strict";var{Transform:Transform2}=__require("stream"),{StringDecoder}=__require("string_decoder"),kLast=Symbol("last"),kDecoder=Symbol("decoder");function transform(chunk,enc,cb){let list2;if(this.overflow){if(list2=this[kDecoder].write(chunk).split(this.matcher),list2.length===1)return cb();list2.shift(),this.overflow=!1}else this[kLast]+=this[kDecoder].write(chunk),list2=this[kLast].split(this.matcher);this[kLast]=list2.pop();for(let i=0;i<list2.length;i++)try{push(this,this.mapper(list2[i]))}catch(error){return cb(error)}if(this.overflow=this[kLast].length>this.maxLength,this.overflow&&!this.skipOverflow){cb(new Error("maximum buffer reached"));return}cb()}function flush(cb){if(this[kLast]+=this[kDecoder].end(),this[kLast])try{push(this,this.mapper(this[kLast]))}catch(error){return cb(error)}cb()}function push(self,val){val!==void 0&&self.push(val)}function noop(incoming){return incoming}function split2(matcher,mapper,options){switch(matcher=matcher||/\r?\n/,mapper=mapper||noop,options=options||{},arguments.length){case 1:typeof matcher=="function"?(mapper=matcher,matcher=/\r?\n/):typeof matcher=="object"&&!(matcher instanceof RegExp)&&!matcher[Symbol.split]&&(options=matcher,matcher=/\r?\n/);break;case 2:typeof matcher=="function"?(options=mapper,mapper=matcher,matcher=/\r?\n/):typeof mapper=="object"&&(options=mapper,mapper=noop)}options=Object.assign({},options),options.autoDestroy=!0,options.transform=transform,options.flush=flush,options.readableObjectMode=!0;let stream=new Transform2(options);return stream[kLast]="",stream[kDecoder]=new StringDecoder("utf8"),stream.matcher=matcher,stream.mapper=mapper,stream.maxLength=options.maxLength,stream.skipOverflow=options.skipOverflow||!1,stream.overflow=!1,stream._destroy=function(err,cb){this._writableState.errorEmitted=!1,cb(err)},stream}module.exports=split2}});var CiTelemetryClient=class extends TelemetryClient{trackCliSubcommandEnable(actual){this.trackCliSubcommand({subcommand:"enable",value:actual})}trackCliSubcommandInspect(actual){this.trackCliSubcommand({subcommand:"inspect",value:actual})}trackCliSubcommandLogs(actual){this.trackCliSubcommand({subcommand:"logs",value:actual})}trackCliSubcommandGrep(actual){this.trackCliSubcommand({subcommand:"grep",value:actual})}trackCliSubcommandRerun(actual){this.trackCliSubcommand({subcommand:"rerun",value:actual})}trackCliSubcommandList(actual){this.trackCliSubcommand({subcommand:"list",value:actual})}};var import_strip_ansi=__toESM(require_strip_ansi(),1);function ciDisplayText(value){return Array.from((0,import_strip_ansi.default)(value),char=>{let code=char.codePointAt(0);return code>=127&&code<=159?`\\u${code.toString(16).padStart(4,"0")}`:code<32?JSON.stringify(char).slice(1,-1):char}).join("")}function quoteCiCommandArg(value){return/^[a-zA-Z0-9_./:@%+,=-]+$/.test(value)?value:`'${value.replace(/'/g,"'\\''")}'`}function buildCiCommand(argv,args){return getCommandNamePlain([...args,...getGlobalFlagsFromArgv(argv)].map(quoteCiCommandArg).join(" "))}var import_split2=__toESM(require_split2(),1);import{Transform}from"node:stream";import{pipeline}from"node:stream/promises";async function*readNdjson(client,url,options={}){let response=await client.fetch(url,{json:!1,accountId:options.accountId,signal:options.signal}),source=toNodeReadable(response.body),maxFrameBytes=8*1024*1024,frameBytes=0,bounded=new Transform({transform(chunk,_encoding,callback){let start=0;for(;start<chunk.length;){let newline=chunk.indexOf(10,start),end=newline===-1?chunk.length:newline;if(frameBytes+=end-start,frameBytes>maxFrameBytes){callback(new Error("Vercel CI response frame exceeds 8 MiB."));return}if(newline===-1)break;frameBytes=0,start=newline+1}callback(null,chunk)}}),lines=(0,import_split2.default)(),completion=pipeline(source,bounded,lines,{signal:options.signal}).then(()=>{},error=>error);try{let snapshot=response.headers.get("content-type")?.split(";")[0]==="application/json",json="",bytes=0;for await(let line of lines)if(snapshot){if(bytes+=Buffer.byteLength(line)+1,bytes>8*1024*1024)throw new Error("Vercel CI JSON snapshot exceeds 8 MiB.");json+=`${line}
7
+ import{handleTracingApiError,invalidArguments,resolveConfigScope,resolveScope,tracingErrorMessage,tracingErrorReason}from"./chunks/chunk-LQVSU5HR.js";import{main}from"./chunks/chunk-JLE7K4SY.js";import{remoteText}from"./chunks/chunk-GYVJIIYL.js";import{InvalidEventsResponseError,RecordTooLargeError,decodeContinuation,encodeContinuation,fetchEventPages,sortIntervals,warningLine}from"./chunks/chunk-KQCROPL3.js";import{recordLine,summaryLine,writeJsonError}from"./chunks/chunk-O72YDZKD.js";import"./chunks/chunk-KJA2GKPT.js";import{readStdinText}from"./chunks/chunk-PSOVLGHP.js";import"./chunks/chunk-XOETL6DB.js";import{runCurl}from"./chunks/chunk-SLGUYM42.js";import{applyDeprecatedGitBranchFlag}from"./chunks/chunk-EU2GBIPC.js";import"./chunks/chunk-MBEKRUTQ.js";import{decodeListCursor,sliceList}from"./chunks/chunk-EGNR2DEI.js";import{parseRepoUrl}from"./chunks/chunk-IQKGQ2Y2.js";import"./chunks/chunk-EAUDC24V.js";import"./chunks/chunk-RRDNKB2X.js";import"./chunks/chunk-MVGTMPMI.js";import"./chunks/chunk-SACGQMVQ.js";import{ellipsis}from"./chunks/chunk-F4KY2TOK.js";import{validateIntegerRangeWithDefault}from"./chunks/chunk-RW3X523R.js";import"./chunks/chunk-ID663OJ7.js";import{printUnknownCommand}from"./chunks/chunk-5IWFRZQT.js";import"./chunks/chunk-2EYYB6YN.js";import{external_exports}from"./chunks/chunk-2NABMKFV.js";import{formatTable}from"./chunks/chunk-LSQREJXO.js";import{stamp_default}from"./chunks/chunk-A2RZZQEP.js";import"./chunks/chunk-Q7D7RGXM.js";import"./chunks/chunk-L3JYCXVB.js";import"./chunks/chunk-C7FQMC6D.js";import"./chunks/chunk-6Y2ZL5XJ.js";import"./chunks/chunk-7QAGSRCU.js";import"./chunks/chunk-25565AGS.js";import"./chunks/chunk-JP33AIDQ.js";import"./chunks/chunk-WEH6XC4Y.js";import"./chunks/chunk-7YKFF6CE.js";import"./chunks/chunk-6OVX3PWM.js";import"./chunks/chunk-HTXDC7E2.js";import{require_open}from"./chunks/chunk-PVASGBEF.js";import"./chunks/chunk-2TUVL6WE.js";import"./chunks/chunk-R6BEOVTU.js";import"./chunks/chunk-HCRD3JFL.js";import"./chunks/chunk-7EJQLVWX.js";import{canPrompt,canPromptOnTerminal}from"./chunks/chunk-IQ7FPAI4.js";import{parseListLimit,printNextPageCommand,printNextPageHint}from"./chunks/chunk-VNIKIQVE.js";import{getRenamedOption}from"./chunks/chunk-T6243EDS.js";import{getSubcommand as getSubcommand2}from"./chunks/chunk-ETV3C2CV.js";import"./chunks/chunk-FGFLTLEA.js";import{CI_LOG_LEVELS,ciCommand,createSubcommand4 as createSubcommand,deleteSubcommand,drainsCommand,enableSubcommand,getCommandAliases,grepSubcommand,healthCommand,inspectSubcommand4 as inspectSubcommand,inspectSubcommand7 as inspectSubcommand2,listSubcommand12 as listSubcommand2,listSubcommand6 as listSubcommand,logsSubcommand,pauseSubcommand,rerunSubcommand,resumeSubcommand,updateSubcommand3 as updateSubcommand}from"./chunks/chunk-O4WNSKQR.js";import{createSubcommand as createSubcommand2,getSubcommand,searchSubcommand,tracesCommand}from"./chunks/chunk-6I6QJHCY.js";import{tracesConfigCommand}from"./chunks/chunk-EKZTFGDX.js";import"./chunks/chunk-462YCCJZ.js";import"./chunks/chunk-WVHCBDTB.js";import"./chunks/chunk-TAISZMA2.js";import"./chunks/chunk-527GBU3K.js";import"./chunks/chunk-CR3NBTHV.js";import"./chunks/chunk-BVGGTBYE.js";import"./chunks/chunk-6TXEVQA4.js";import"./chunks/chunk-5KUUMQ3M.js";import"./chunks/chunk-UHBMX3OK.js";import"./chunks/chunk-EEUJLJEJ.js";import"./chunks/chunk-NW7WWUCQ.js";import"./chunks/chunk-F6EBOT64.js";import"./chunks/chunk-LFOWP74R.js";import"./chunks/chunk-LOBA3E72.js";import"./chunks/chunk-7R6TRRG5.js";import"./chunks/chunk-JALVF3C2.js";import"./chunks/chunk-OZCQTXI4.js";import"./chunks/chunk-FSPPKNKN.js";import{help}from"./chunks/chunk-FLHO75XC.js";import{table}from"./chunks/chunk-773GOZIR.js";import{printError}from"./chunks/chunk-HSFKISDH.js";import"./chunks/chunk-67GZ5REA.js";import{require_strip_ansi}from"./chunks/chunk-BS32OUOC.js";import"./chunks/chunk-3G3FQYMW.js";import{TelemetryClient}from"./chunks/chunk-6YXIWZ3X.js";import"./chunks/chunk-PUKYAALC.js";import{getContextName,getScope,scopeFlagPassed}from"./chunks/chunk-K5U47EVH.js";import{require_ms}from"./chunks/chunk-MXTC4ZAQ.js";import"./chunks/chunk-NWGBDBZI.js";import{AGENT_REASON,AGENT_STATUS,buildCommandWithYes,getErrorRecovery,getExitCodeForReason,getGlobalFlagsFromArgv,outputAgentError,shouldEmitNonInteractiveCommandError,withGlobalFlags,writeAgentError}from"./chunks/chunk-WDXW6A4H.js";import"./chunks/chunk-DKJL2KV7.js";import{execFileAsync,getGitExecutable,getLinkedProject,getProjectByNameOrId,require_pluralize,selectGitRemote,sleep,ua_default}from"./chunks/chunk-4N6LMERQ.js";import{ALIGNED_LABEL_WIDTH,formatAlignedLabel,printAlignedLabel}from"./chunks/chunk-ADLBLGT3.js";import"./chunks/chunk-CWM2F235.js";import"./chunks/chunk-4NTBYNFR.js";import{isArgumentError,parseArguments,takeCommand}from"./chunks/chunk-KCKYPLIH.js";import{getTeamByIdOrSlug,quoteArg}from"./chunks/chunk-F53OKXYI.js";import{GLOBAL_CLI_FLAG_NAMES,getFlagsSpecification,validateJsonOutput,warnDeprecatedSubcommand}from"./chunks/chunk-QVXS234E.js";import{fetch,toNodeReadable}from"./chunks/chunk-FUX6LKNP.js";import"./chunks/chunk-OPORM35X.js";import"./chunks/chunk-4SAVH3H7.js";import{ProjectNotFound,isAPIError}from"./chunks/chunk-6VH56CX2.js";import{cmd,getCommandName,getCommandNamePlain}from"./chunks/chunk-JESNVRVR.js";import{output_manager_default,recordCliError}from"./chunks/chunk-XP3FT56R.js";import"./chunks/chunk-BLUPZPAS.js";import"./chunks/chunk-RM3ZDRYE.js";import"./chunks/chunk-OO572JUC.js";import"./chunks/chunk-D3AHZ5LI.js";import"./chunks/chunk-2GHZGOWT.js";import"./chunks/chunk-YHPPP3SF.js";import{require_source}from"./chunks/chunk-NB2WLB3J.js";import"./chunks/chunk-ISWW3DKF.js";import"./chunks/chunk-BRQUZ5NC.js";import{__commonJS,__require,__toESM}from"./chunks/chunk-BZENIQ7N.js";var require_split2=__commonJS({"../../node_modules/.pnpm/split2@4.2.0/node_modules/split2/index.js"(exports,module){"use strict";var{Transform:Transform2}=__require("stream"),{StringDecoder}=__require("string_decoder"),kLast=Symbol("last"),kDecoder=Symbol("decoder");function transform(chunk,enc,cb){let list2;if(this.overflow){if(list2=this[kDecoder].write(chunk).split(this.matcher),list2.length===1)return cb();list2.shift(),this.overflow=!1}else this[kLast]+=this[kDecoder].write(chunk),list2=this[kLast].split(this.matcher);this[kLast]=list2.pop();for(let i=0;i<list2.length;i++)try{push(this,this.mapper(list2[i]))}catch(error){return cb(error)}if(this.overflow=this[kLast].length>this.maxLength,this.overflow&&!this.skipOverflow){cb(new Error("maximum buffer reached"));return}cb()}function flush(cb){if(this[kLast]+=this[kDecoder].end(),this[kLast])try{push(this,this.mapper(this[kLast]))}catch(error){return cb(error)}cb()}function push(self,val){val!==void 0&&self.push(val)}function noop(incoming){return incoming}function split2(matcher,mapper,options){switch(matcher=matcher||/\r?\n/,mapper=mapper||noop,options=options||{},arguments.length){case 1:typeof matcher=="function"?(mapper=matcher,matcher=/\r?\n/):typeof matcher=="object"&&!(matcher instanceof RegExp)&&!matcher[Symbol.split]&&(options=matcher,matcher=/\r?\n/);break;case 2:typeof matcher=="function"?(options=mapper,mapper=matcher,matcher=/\r?\n/):typeof mapper=="object"&&(options=mapper,mapper=noop)}options=Object.assign({},options),options.autoDestroy=!0,options.transform=transform,options.flush=flush,options.readableObjectMode=!0;let stream=new Transform2(options);return stream[kLast]="",stream[kDecoder]=new StringDecoder("utf8"),stream.matcher=matcher,stream.mapper=mapper,stream.maxLength=options.maxLength,stream.skipOverflow=options.skipOverflow||!1,stream.overflow=!1,stream._destroy=function(err,cb){this._writableState.errorEmitted=!1,cb(err)},stream}module.exports=split2}});var CiTelemetryClient=class extends TelemetryClient{trackCliSubcommandEnable(actual){this.trackCliSubcommand({subcommand:"enable",value:actual})}trackCliSubcommandInspect(actual){this.trackCliSubcommand({subcommand:"inspect",value:actual})}trackCliSubcommandLogs(actual){this.trackCliSubcommand({subcommand:"logs",value:actual})}trackCliSubcommandGrep(actual){this.trackCliSubcommand({subcommand:"grep",value:actual})}trackCliSubcommandRerun(actual){this.trackCliSubcommand({subcommand:"rerun",value:actual})}trackCliSubcommandList(actual){this.trackCliSubcommand({subcommand:"list",value:actual})}};var import_strip_ansi=__toESM(require_strip_ansi(),1);function ciDisplayText(value){return Array.from((0,import_strip_ansi.default)(value),char=>{let code=char.codePointAt(0);return code>=127&&code<=159?`\\u${code.toString(16).padStart(4,"0")}`:code<32?JSON.stringify(char).slice(1,-1):char}).join("")}function quoteCiCommandArg(value){return/^[a-zA-Z0-9_./:@%+,=-]+$/.test(value)?value:`'${value.replace(/'/g,"'\\''")}'`}function buildCiCommand(argv,args){return getCommandNamePlain([...args,...getGlobalFlagsFromArgv(argv)].map(quoteCiCommandArg).join(" "))}var import_split2=__toESM(require_split2(),1);import{Transform}from"node:stream";import{pipeline}from"node:stream/promises";async function*readNdjson(client,url,options={}){let response=await client.fetch(url,{json:!1,accountId:options.accountId,signal:options.signal}),source=toNodeReadable(response.body),maxFrameBytes=8*1024*1024,frameBytes=0,bounded=new Transform({transform(chunk,_encoding,callback){let start=0;for(;start<chunk.length;){let newline=chunk.indexOf(10,start),end=newline===-1?chunk.length:newline;if(frameBytes+=end-start,frameBytes>maxFrameBytes){callback(new Error("Vercel CI response frame exceeds 8 MiB."));return}if(newline===-1)break;frameBytes=0,start=newline+1}callback(null,chunk)}}),lines=(0,import_split2.default)(),completion=pipeline(source,bounded,lines,{signal:options.signal}).then(()=>{},error=>error);try{let snapshot=response.headers.get("content-type")?.split(";")[0]==="application/json",json="",bytes=0;for await(let line of lines)if(snapshot){if(bytes+=Buffer.byteLength(line)+1,bytes>8*1024*1024)throw new Error("Vercel CI JSON snapshot exceeds 8 MiB.");json+=`${line}
8
8
  `}else line.trim()&&(yield JSON.parse(line));let error=await completion;if(error)throw error;snapshot&&(yield JSON.parse(json))}finally{source.destroy(),bounded.destroy(),lines.destroy(),await completion}}async function resolveCiTeam(_client){return{ok:!0}}function listCiInvocations(client,params,accountId){let query=new URLSearchParams({provider:params.provider,repository:params.repository});params.branch&&query.set("branchName",params.branch),params.commitSha&&query.set("snapshot",params.commitSha);for(let status of params.statuses??[])query.append("status",status);for(let conclusion2 of params.conclusions??[])query.append("conclusion",conclusion2);return params.limit&&query.set("limit",String(params.limit)),params.cursor&&query.set("cursor",params.cursor),client.fetch(`/v2/vercel-ci/invocations?${query}`,{accountId})}function getCiInvocationTree(client,invocationId,options={}){let query=new URLSearchParams;options.attempt&&query.set("attempt",String(options.attempt));let suffix=query.size?`?${query}`:"";return client.fetch(`/v1/vercel-ci/invocations/${encodeURIComponent(invocationId)}/tree${suffix}`,{accountId:options.accountId})}function streamCiInvocationTree(client,invocationId,options){let query=new URLSearchParams({attempt:String(options.attempt),follow:"1"});return readNdjson(client,`/v1/vercel-ci/invocations/${encodeURIComponent(invocationId)}/tree?${query}`,{accountId:options.accountId,signal:options.signal})}async function getLatestCiAttempt(client,invocationId,accountId){let{attempts}=await client.fetch(`/v1/vercel-ci/invocations/${encodeURIComponent(invocationId)}/attempts`,{accountId});return Math.max(1,...attempts.map(attempt=>attempt.attempt))}function searchCiLogs(client,runs,filters,accountId){let query=new URLSearchParams;for(let run of runs)query.append("invocation",`${run.invocationId}:${run.attempt}`);query.set("search",filters.search);for(let level of filters.levels??[])query.append("level",level);return client.fetch(`/v1/vercel-ci/log-search?${query}`,{accountId})}function getCiTaskLogs(client,invocationId,attempt,filters,accountId){let query=new URLSearchParams;for(let task of filters.tasks??[])query.append("task",task);for(let conclusion2 of filters.conclusions??[])query.append("conclusion",conclusion2);for(let level of filters.levels??[])query.append("level",level);filters.search&&query.set("search",filters.search),filters.limit&&query.set("limit",String(filters.limit));let suffix=query.size?`?${query}`:"";return client.fetch(`/v1/vercel-ci/invocations/${encodeURIComponent(invocationId)}/attempts/${attempt}/task-logs${suffix}`,{accountId})}function streamCiTaskRunLogs(client,locator,options){let query=new URLSearchParams({follow:"1"});options.since!==void 0&&query.set("since",String(options.since));for(let level of options.levels??[])query.append("level",level);return readNdjson(client,`${ciTaskRunLogsPath(locator)}?${query}`,{accountId:options.accountId,signal:options.signal})}async function getCiTaskRunLogs(client,locator,options={}){let query=new URLSearchParams;for(let level of options.levels??[])query.append("level",level);let suffix=query.size?`?${query}`:"",snapshot;for await(let value of readNdjson(client,`${ciTaskRunLogsPath(locator)}${suffix}`,{accountId:options.accountId})){if(snapshot||typeof value!="object"||value===null||!("lines"in value)||!Array.isArray(value.lines))throw new Error("Invalid Vercel CI log snapshot.");snapshot=value}if(!snapshot)throw new Error("Missing Vercel CI log snapshot.");return snapshot}function ciTaskRunLogsPath(locator){return`/v1/vercel-ci/${["invocations",locator.invocationId,"attempts",locator.attempt,"job-definitions",locator.jobDefinitionId,"runs",locator.jobRunAttempt,"task-definitions",locator.taskDefinitionId,"runs",locator.taskRunAttempt,"logs"].map(segment=>encodeURIComponent(String(segment))).join("/")}`}async function getCiSetupLogs(client,invocationId,attempt,options={}){let base=`/v1/vercel-ci/invocations/${encodeURIComponent(invocationId)}/attempts/${attempt}`,{invocation}=await client.fetch(base,{accountId:options.accountId});if(invocation.setupConclusion?.result!=="failed")return{failed:!1,lines:[]};let query=new URLSearchParams;for(let level of options.levels??[])query.append("level",level);let suffix=query.size?`?${query}`:"",{lines}=await client.fetch(`${base}/logs${suffix}`,{accountId:options.accountId});return{failed:!0,lines}}function repositorySettingsPath(repo){return`/v1/vercel-ci/repository-settings?${new URLSearchParams({provider:repo.provider,organizationId:repo.organizationId,repository:repo.repository})}`}function getCiRepositorySettings(client,repo,accountId){return client.fetch(repositorySettingsPath(repo),{accountId})}function updateCiRepositorySettings(client,repo,settings,accountId){return client.fetch(repositorySettingsPath(repo),{method:"PATCH",body:settings,accountId})}var CiEnableTelemetryClient=class extends TelemetryClient{trackCliOptionRemote(remote){remote!==void 0&&this.trackCliOption({option:"remote",value:this.redactedValue})}trackCliFlagJson(json){json&&this.trackCliFlag("json")}};var SUPPORTED_PROVIDERS=["github"];async function getCiGitRemoteNames(cwd){let git=await getGitExecutable(cwd),names=await readGit(git,cwd,["remote"]);return names?names.split(`
9
9
  `):[]}async function getCiGitContext(cwd,remoteName="origin"){let git=await getGitExecutable(cwd),[remote,branch,commitSha]=await Promise.all([readGit(git,cwd,["remote","get-url",remoteName]),readGit(git,cwd,["rev-parse","--abbrev-ref","HEAD"]),readGit(git,cwd,["rev-parse","HEAD"])]);if(!remote)return null;let repo=parseRepoUrl(remote),provider=SUPPORTED_PROVIDERS.find(p=>p===repo?.provider);return!repo||!provider?(output_manager_default.debug("Unsupported Git remote for Vercel CI."),null):{provider,repository:`${repo.org}/${repo.repo}`,...branch&&branch!=="HEAD"?{branch}:{},...commitSha?{commitSha}:{}}}var COMMIT_SHA_PATTERN=/^[0-9a-f]{4,40}$/i;async function resolveCommitSha(cwd,value){let sha=value.trim().toLowerCase();if(!COMMIT_SHA_PATTERN.test(sha))return null;if(sha.length===40)return sha;let git=await getGitExecutable(cwd);return await readGit(git,cwd,["rev-parse","--verify","--quiet",`${sha}^{commit}`])??null}async function readGit(git,cwd,args){try{let{stdout}=await execFileAsync(git,args,{cwd});return stdout.trim()||void 0}catch(error){output_manager_default.debug(`git ${args.join(" ")} failed: ${error}`);return}}function failCi(client,failure){return shouldEmitNonInteractiveCommandError(client)?writeAgentError(client,{status:AGENT_STATUS.ERROR,...failure}):output_manager_default.fatal(failure.message),getExitCodeForReason(failure.reason)}function invalidCiArguments(client,message){return failCi(client,{reason:AGENT_REASON.INVALID_ARGUMENTS,message})}function handleCiApiError(client,action,err){if(isAPIError(err)){let detail=err.serverMessage?` ${err.serverMessage}`:"";switch(err.status){case 403:return failCi(client,{reason:AGENT_REASON.PERMISSION_DENIED,message:`Can't ${action}. You don't have access to Vercel CI runs for this team.`});case 404:return failCi(client,{reason:AGENT_REASON.CI_RUN_NOT_FOUND,message:"Couldn't find that Vercel CI run for this team."});case 429:return failCi(client,{reason:AGENT_REASON.RATE_LIMITED,message:`Failed to ${action}. Too many requests. Wait a moment, then try again.`});default:return failCi(client,{reason:AGENT_REASON.API_ERROR,message:`Failed to ${action}.${detail}`})}}throw err}async function resolveCiContext(client,remoteOptions){let remoteName="origin";if(remoteOptions){let remoteNames=await getCiGitRemoteNames(client.cwd);if(remoteOptions.remote!==void 0){if(!remoteNames.includes(remoteOptions.remote))return invalidCiArguments(client,"Can't enable Vercel CI. --remote must name an existing Git remote. Run `git remote` to list remotes, then pass --remote <NAME>.");remoteName=remoteOptions.remote}else{if(remoteNames.length>1&&(remoteOptions.nonInteractive||!canPromptOnTerminal(client)))return invalidCiArguments(client,"Can't enable Vercel CI. Found multiple Git remotes. Pass --remote <NAME> to select one; run `git remote` to list remotes.");remoteNames.length>0&&(remoteName=await selectGitRemote(client,remoteNames))}}let git=await getCiGitContext(client.cwd,remoteName);if(!git)return failCi(client,{reason:AGENT_REASON.GIT_REPOSITORY_REQUIRED,message:remoteOptions?"Couldn't find a supported Git repository for the selected remote. Vercel CI currently supports GitHub repositories. Run `git remote -v` to check remotes, then pass --remote <NAME>.":"Couldn't find a supported Git repository here. Vercel CI currently supports GitHub repositories with an origin remote."});let team=await resolveCiTeam(client);return team.ok?{git,remoteName,accountId:team.accountId}:team.exitCode}async function enable(client,argv){let telemetry=new CiEnableTelemetryClient({opts:{store:client.telemetryEventStore}}),parsedArgs;try{parsedArgs=parseArguments(argv,getFlagsSpecification(enableSubcommand.options))}catch(error){return printError(error,client),2}let{args,flags}=parsedArgs;if(telemetry.trackCliOptionFormat(flags["--format"]),telemetry.trackCliFlagJson(flags["--json"]),telemetry.trackCliOptionRemote(flags["--remote"]),args.length>0)return invalidCiArguments(client,`\`${getCommandNamePlain("ci enable")}\` doesn't take arguments. Run it inside the repository to enable.`);let formatResult=validateJsonOutput(flags);if(!formatResult.valid)return invalidCiArguments(client,formatResult.error);let asJson=formatResult.jsonOutput||client.nonInteractive,context=await resolveCiContext(client,{remote:flags["--remote"],nonInteractive:asJson});if(typeof context=="number")return context;let{git,accountId}=context,[organizationId,repository]=git.repository.split("/"),repo={provider:git.provider,organizationId,repository},repoName=ciDisplayText(git.repository);asJson||output_manager_default.spinner("Enabling Vercel CI\u2026");let settings,outcome;try{let current=await getCiRepositorySettings(client,repo,accountId);current.ciEnabled?(settings=current,outcome="unchanged"):(settings=await updateCiRepositorySettings(client,repo,{ciEnabled:!0},accountId),outcome="enabled")}catch(err){return output_manager_default.stopSpinner(),handleEnableError(client,repoName,err)}output_manager_default.stopSpinner();let listCommand=buildCiCommand(client.argv,["ci","list"]),next=context.remoteName==="origin"?[{command:listCommand,when:"List Vercel CI runs after you push a commit"}]:[],message=outcome==="enabled"?`Enabled Vercel CI for ${repoName}.`:`Vercel CI is already enabled for ${repoName}.`;if(asJson){let payload={repository:settings,outcome,next},agentPayload=client.nonInteractive?{status:AGENT_STATUS.OK,...payload,message}:payload;return client.stdout.write(`${JSON.stringify(agentPayload,null,2)}
10
10
  `),0}return outcome==="enabled"?(printAlignedLabel("Enabled","Vercel CI",{gutter:"\u2713"}),printAlignedLabel("Repository",repoName)):output_manager_default.print(` ${message}
@@ -103,7 +103,7 @@ ${formatRunsTable(invocations)}
103
103
  ${STATUS_PAGE_URL}
104
104
  `),usage?2:1),parsedArgs;try{parsedArgs=parseArguments(argv,getFlagsSpecification(healthCommand.options))}catch(err){return fail2({reason:AGENT_REASON.INVALID_ARGUMENTS,message:err instanceof Error?err.message:String(err)},!0)}jsonOutput=parsedArgs.flags["--json"]===!0,telemetry.trackCliFlagJson(parsedArgs.flags["--json"]),parsedArgs.args[0]==="status-page"&&warnDeprecatedSubcommand(client,"status-page","health");let extra=parsedArgs.args.slice(1);if(extra.length>0)return fail2({reason:AGENT_REASON.UNKNOWN_COMMAND,message:`Unknown command ${toSafeLine(extra[0])} for vercel health.`},!0);jsonOutput||output_manager_default.spinner("Getting the Vercel status\u2026");let report;try{report=await getStatusReport()}catch(err){return fail2(describeFailure(err))}return output_manager_default.stopSpinner(),client.stdout.write(jsonOutput?`${JSON.stringify(report,null,2)}
105
105
  `:`
106
- ${formatStatusReport(report,Date.now())}`),0}var TracesTelemetryClient=class extends TelemetryClient{trackCliArgumentId(id2,kind="requestId"){id2&&this.trackCliArgument({arg:kind,value:this.redactedValue})}trackCliFlagJson(json){json&&this.trackCliFlag("json")}trackCliOptionProject(project){project&&this.trackCliOption({option:"project",value:this.redactedValue})}trackCliFlagOpen(open2){open2&&this.trackCliFlag("open")}trackCliSubcommandConfig(actual){this.trackCliSubcommand({subcommand:"config",value:actual})}trackCliSubcommandSearch(actual){this.trackCliSubcommand({subcommand:"search",value:actual})}trackCliOptionEnvironment(value){this.trackRedactedOption("environment",value)}trackCliOptionService(value){this.trackRedactedOption("service",value)}trackCliOptionName(value){this.trackRedactedOption("name",value)}trackCliOptionKind(value){this.trackRedactedOption("kind",value)}trackCliOptionStatus(value){this.trackRedactedOption("status",value)}trackCliOptionDeployment(value){this.trackRedactedOption("deployment",value)}trackCliOptionDeploymentId(value){this.trackRedactedOption("deployment-id",value)}trackCliOptionRequestId(value){this.trackRedactedOption("request-id",value)}trackCliOptionTraceId(value){this.trackRedactedOption("trace-id",value)}trackCliOptionSpanId(value){this.trackRedactedOption("span-id",value)}trackCliFlagRoot(root){root&&this.trackCliFlag("root")}trackCliOptionSince(value){this.trackRedactedOption("since",value)}trackCliOptionUntil(value){this.trackRedactedOption("until",value)}trackCliOptionLimit(value){value!==void 0&&this.trackCliOption({option:"limit",value:this.redactedValue})}trackCliOptionQuery(value){this.trackRedactedOption("query",value)}trackCliOptionColumns(value){this.trackRedactedOption("columns",value)}trackCliOptionNext(value){this.trackRedactedOption("next",value)}trackRedactedOption(option,value){value!==void 0&&this.trackCliOption({option,value:this.redactedValue})}trackCliOptionView(view){view&&this.trackCliOption({option:"view",value:view})}};var import_chalk8=__toESM(require_source(),1),import_open=__toESM(require_open(),1);var SPAN_STATUS_UNSET="Unset",SPAN_STATUS_OK="Ok",SPAN_STATUS_ERROR="Error",ATTR_HINT_KEYS=["http.url","http.target","db.statement","http.status_code"];function tupleToUs(tuple){if(!tuple||tuple.length!==2)return null;let[seconds,nanoseconds]=tuple;return typeof seconds!="number"||typeof nanoseconds!="number"?null:seconds*1e6+nanoseconds/1e3}function getDurationUs(span){let us=tupleToUs(span.duration);return us===null?null:us<0?0:us}function getStartTimeUs(span){return tupleToUs(span.startTime)}function readAttrString(attributes,key){let value=attributes?.[key];if(typeof value=="string")return value;if(typeof value=="number")return String(value)}function resolveRootSpan(trace){if(trace.spans.length!==0){if(trace.rootSpanId){let match=trace.spans.find(span=>span.spanId===trace.rootSpanId);if(match)return match}return trace.spans[0]}}function compareByStart(a,b){let startA=getStartTimeUs(a),startB=getStartTimeUs(b);return startA===null&&startB===null?0:startA===null?1:startB===null?-1:startA-startB}function analyze(trace){let root=resolveRootSpan(trace),rootDurationUs=root?getDurationUs(root):null,rootStartUs=root?getStartTimeUs(root):null,spansById=new Map;for(let span of trace.spans)spansById.set(span.spanId,span);let childrenByParent=new Map;for(let span of trace.spans){if(!span.parentSpanId||!spansById.has(span.parentSpanId))continue;let list2=childrenByParent.get(span.parentSpanId);list2?list2.push(span):childrenByParent.set(span.parentSpanId,[span])}for(let list2 of childrenByParent.values())list2.sort(compareByStart);let spanInfo=new Map;for(let span of trace.spans){let durationUs=getDurationUs(span),children=childrenByParent.get(span.spanId)??[],childTotalUs=0;for(let child of children){let cd=getDurationUs(child);cd!==null&&(childTotalUs+=cd)}let selfTimeUs=durationUs===null?null:Math.max(0,durationUs-childTotalUs),startOffsetUs=null;if(rootStartUs!==null){let startUs=getStartTimeUs(span);startUs!==null&&(startOffsetUs=Math.max(0,startUs-rootStartUs))}spanInfo.set(span.spanId,{span,durationUs,selfTimeUs,startOffsetUs})}let visited=new Set,treeOrder=[],truncatedAtDepth=!1;root&&(truncatedAtDepth=walkTree(root,0,childrenByParent,visited,treeOrder)||truncatedAtDepth);let orphanOrder=[],orphanRoots=trace.spans.filter(span=>!visited.has(span.spanId)&&(!span.parentSpanId||!spansById.has(span.parentSpanId))).sort(compareByStart);for(let orphan of orphanRoots)truncatedAtDepth=walkTree(orphan,0,childrenByParent,visited,orphanOrder)||truncatedAtDepth;for(let span of trace.spans)visited.has(span.spanId)||(orphanOrder.push({span,depth:0}),visited.add(span.spanId));let errorSpans=trace.spans.filter(span=>span.status?.code===SPAN_STATUS_ERROR),byName=new Map;for(let span of trace.spans){let name=span.name||"<unnamed>",durationUs=getDurationUs(span)??0,entry=byName.get(name);entry?(entry.count+=1,entry.totalUs+=durationUs):byName.set(name,{count:1,totalUs:durationUs})}let repeatedOps=[];for(let[name,{count,totalUs}]of byName)count>=2&&repeatedOps.push({name,count,totalUs,perCallUs:totalUs/count});return repeatedOps.sort((a,b)=>b.totalUs-a.totalUs),{trace,root,rootDurationUs,rootStartUs,spanInfo,treeOrder,orphanOrder,errorSpans,repeatedOps,truncatedAtDepth}}function walkTree(span,depth,childrenByParent,visited,out){if(visited.has(span.spanId))return!1;if(visited.add(span.spanId),depth>=256)return out.push({span,depth}),!0;out.push({span,depth});let truncated=!1,children=childrenByParent.get(span.spanId)??[];for(let child of children)truncated=walkTree(child,depth+1,childrenByParent,visited,out)||truncated;return truncated}var OBSERVABILITY_API_URL="https://vercel.com/api/observability-api/",QUERY_REASON_HEADER="x-vercel-observability-query-reason",QUERY_REASON="cli/traces-get",QueryEngineResponseError=class extends Error{constructor(message){super(message),this.name="QueryEngineResponseError"}};async function fetchTrace({client,teamId,projectId,requestId,traceId}){let traceUrl=new URL(traceId!==void 0?`v1/traces/${encodeURIComponent(traceId)}`:`v1/traces/requests/${encodeURIComponent(requestId)}`,OBSERVABILITY_API_URL);traceUrl.searchParams.set("teamId",teamId),traceUrl.searchParams.set("projectId",projectId);let response=await client.fetch(traceUrl.href,{headers:{[QUERY_REASON_HEADER]:QUERY_REASON}});return{trace:mapTrace(response),partial:isRecord(response.meta)&&response.meta.partial===!0}}function mapTrace(response){if(!isRecord(response)||typeof response.traceId!="string"||!Array.isArray(response.spans))throw new QueryEngineResponseError("Observability API returned an invalid resolved trace.");return{traceId:response.traceId,...typeof response.rootSpanId=="string"?{rootSpanId:response.rootSpanId}:{},spans:response.spans.map(mapSpan)}}function mapSpan(value){if(!isRecord(value)||typeof value.spanId!="string")throw new QueryEngineResponseError("Observability API returned an invalid trace span.");if(typeof value.name!="string"||typeof value.durationMs!="number")throw new QueryEngineResponseError("Observability API returned an invalid trace span.");let timestamp2=parseTimestamp(value.timestamp),attributes=isRecord(value.attributes)?value.attributes:void 0,status=isRecord(value.status)?value.status:void 0,statusCode=mapStatusCode(status?.code),statusMessage=typeof status?.message=="string"?status.message:void 0;return{spanId:value.spanId,...typeof value.parentSpanId=="string"&&value.parentSpanId?{parentSpanId:value.parentSpanId}:{},name:value.name,duration:durationTuple(value.durationMs),startTime:timestampTuple(timestamp2),...attributes?{attributes}:{},status:{code:statusCode,...statusMessage?{message:statusMessage}:{}}}}function mapStatusCode(code){switch(code){case"ERROR":return SPAN_STATUS_ERROR;case"OK":return SPAN_STATUS_OK;default:return SPAN_STATUS_UNSET}}function parseTimestamp(value){if(typeof value!="string")throw new QueryEngineResponseError("Observability API returned an invalid trace timestamp.");let timestamp2=Date.parse(value);if(!Number.isFinite(timestamp2))throw new QueryEngineResponseError("Observability API returned an invalid trace timestamp.");return timestamp2}function durationTuple(durationMs){let nanoseconds=Math.round(durationMs*1e6);if(!Number.isSafeInteger(nanoseconds)||nanoseconds<0)throw new QueryEngineResponseError("Observability API returned an invalid span duration.");return[Math.floor(nanoseconds/1e9),nanoseconds%1e9]}function timestampTuple(timestampMs){let seconds=Math.floor(timestampMs/1e3);return[seconds,(timestampMs-seconds*1e3)*1e6]}function isRecord(value){return typeof value=="object"&&value!==null&&!Array.isArray(value)}var UNKNOWN="<unknown>",UNNAMED="<unnamed>",ATTR_VALUE_MAX_LEN=80,TRACE_ID_MAX_LEN=13;function renderMarkdown(trace,options){let analysis=analyze(trace),sections=[];return sections.push(renderHeader(analysis,options)),analysis.errorSpans.length>0&&sections.push(renderErrors(analysis)),analysis.repeatedOps.length>0&&sections.push(renderRepeatedOps(analysis)),sections.push(renderTree(analysis)),`${sections.join(`
106
+ ${formatStatusReport(report,Date.now())}`),0}var TracesTelemetryClient=class extends TelemetryClient{trackCliArgumentId(id2,kind="requestId"){id2&&this.trackCliArgument({arg:kind,value:this.redactedValue})}trackCliFlagJson(json){json&&this.trackCliFlag("json")}trackCliOptionProject(project){project&&this.trackCliOption({option:"project",value:this.redactedValue})}trackCliFlagOpen(open2){open2&&this.trackCliFlag("open")}trackCliSubcommandConfig(actual){this.trackCliSubcommand({subcommand:"config",value:actual})}trackCliSubcommandSearch(actual){this.trackCliSubcommand({subcommand:"search",value:actual})}trackCliOptionEnvironment(value){this.trackRedactedOption("environment",value)}trackCliOptionService(value){this.trackRedactedOption("service",value)}trackCliOptionName(value){this.trackRedactedOption("name",value)}trackCliOptionKind(value){this.trackRedactedOption("kind",value)}trackCliOptionStatus(value){this.trackRedactedOption("status",value)}trackCliOptionDeployment(value){this.trackRedactedOption("deployment",value)}trackCliOptionDeploymentId(value){this.trackRedactedOption("deployment-id",value)}trackCliOptionRequestId(value){this.trackRedactedOption("request-id",value)}trackCliOptionTrace(value){this.trackRedactedOption("trace",value)}trackCliOptionTraceId(value){this.trackRedactedOption("trace-id",value)}trackCliOptionSpan(value){this.trackRedactedOption("span",value)}trackCliOptionSpanId(value){this.trackRedactedOption("span-id",value)}trackCliFlagRoot(root){root&&this.trackCliFlag("root")}trackCliOptionSince(value){this.trackRedactedOption("since",value)}trackCliOptionUntil(value){this.trackRedactedOption("until",value)}trackCliOptionLimit(value){value!==void 0&&this.trackCliOption({option:"limit",value:this.redactedValue})}trackCliOptionQuery(value){this.trackRedactedOption("query",value)}trackCliOptionColumns(value){this.trackRedactedOption("columns",value)}trackCliOptionNext(value){this.trackRedactedOption("next",value)}trackRedactedOption(option,value){value!==void 0&&this.trackCliOption({option,value:this.redactedValue})}trackCliOptionView(view){view&&this.trackCliOption({option:"view",value:view})}};var import_chalk8=__toESM(require_source(),1),import_open=__toESM(require_open(),1);var SPAN_STATUS_UNSET="Unset",SPAN_STATUS_OK="Ok",SPAN_STATUS_ERROR="Error",ATTR_HINT_KEYS=["http.url","http.target","db.statement","http.status_code"];function tupleToUs(tuple){if(!tuple||tuple.length!==2)return null;let[seconds,nanoseconds]=tuple;return typeof seconds!="number"||typeof nanoseconds!="number"?null:seconds*1e6+nanoseconds/1e3}function getDurationUs(span){let us=tupleToUs(span.duration);return us===null?null:us<0?0:us}function getStartTimeUs(span){return tupleToUs(span.startTime)}function readAttrString(attributes,key){let value=attributes?.[key];if(typeof value=="string")return value;if(typeof value=="number")return String(value)}function resolveRootSpan(trace){if(trace.spans.length!==0){if(trace.rootSpanId){let match=trace.spans.find(span=>span.spanId===trace.rootSpanId);if(match)return match}return trace.spans[0]}}function compareByStart(a,b){let startA=getStartTimeUs(a),startB=getStartTimeUs(b);return startA===null&&startB===null?0:startA===null?1:startB===null?-1:startA-startB}function analyze(trace){let root=resolveRootSpan(trace),rootDurationUs=root?getDurationUs(root):null,rootStartUs=root?getStartTimeUs(root):null,spansById=new Map;for(let span of trace.spans)spansById.set(span.spanId,span);let childrenByParent=new Map;for(let span of trace.spans){if(!span.parentSpanId||!spansById.has(span.parentSpanId))continue;let list2=childrenByParent.get(span.parentSpanId);list2?list2.push(span):childrenByParent.set(span.parentSpanId,[span])}for(let list2 of childrenByParent.values())list2.sort(compareByStart);let spanInfo=new Map;for(let span of trace.spans){let durationUs=getDurationUs(span),children=childrenByParent.get(span.spanId)??[],childTotalUs=0;for(let child of children){let cd=getDurationUs(child);cd!==null&&(childTotalUs+=cd)}let selfTimeUs=durationUs===null?null:Math.max(0,durationUs-childTotalUs),startOffsetUs=null;if(rootStartUs!==null){let startUs=getStartTimeUs(span);startUs!==null&&(startOffsetUs=Math.max(0,startUs-rootStartUs))}spanInfo.set(span.spanId,{span,durationUs,selfTimeUs,startOffsetUs})}let visited=new Set,treeOrder=[],truncatedAtDepth=!1;root&&(truncatedAtDepth=walkTree(root,0,childrenByParent,visited,treeOrder)||truncatedAtDepth);let orphanOrder=[],orphanRoots=trace.spans.filter(span=>!visited.has(span.spanId)&&(!span.parentSpanId||!spansById.has(span.parentSpanId))).sort(compareByStart);for(let orphan of orphanRoots)truncatedAtDepth=walkTree(orphan,0,childrenByParent,visited,orphanOrder)||truncatedAtDepth;for(let span of trace.spans)visited.has(span.spanId)||(orphanOrder.push({span,depth:0}),visited.add(span.spanId));let errorSpans=trace.spans.filter(span=>span.status?.code===SPAN_STATUS_ERROR),byName=new Map;for(let span of trace.spans){let name=span.name||"<unnamed>",durationUs=getDurationUs(span)??0,entry=byName.get(name);entry?(entry.count+=1,entry.totalUs+=durationUs):byName.set(name,{count:1,totalUs:durationUs})}let repeatedOps=[];for(let[name,{count,totalUs}]of byName)count>=2&&repeatedOps.push({name,count,totalUs,perCallUs:totalUs/count});return repeatedOps.sort((a,b)=>b.totalUs-a.totalUs),{trace,root,rootDurationUs,rootStartUs,spanInfo,treeOrder,orphanOrder,errorSpans,repeatedOps,truncatedAtDepth}}function walkTree(span,depth,childrenByParent,visited,out){if(visited.has(span.spanId))return!1;if(visited.add(span.spanId),depth>=256)return out.push({span,depth}),!0;out.push({span,depth});let truncated=!1,children=childrenByParent.get(span.spanId)??[];for(let child of children)truncated=walkTree(child,depth+1,childrenByParent,visited,out)||truncated;return truncated}var OBSERVABILITY_API_URL="https://vercel.com/api/observability-api/",QUERY_REASON_HEADER="x-vercel-observability-query-reason",QUERY_REASON="cli/traces-get",QueryEngineResponseError=class extends Error{constructor(message){super(message),this.name="QueryEngineResponseError"}};async function fetchTrace({client,teamId,projectId,requestId,traceId}){let traceUrl=new URL(traceId!==void 0?`v1/traces/${encodeURIComponent(traceId)}`:`v1/traces/requests/${encodeURIComponent(requestId)}`,OBSERVABILITY_API_URL);traceUrl.searchParams.set("teamId",teamId),traceUrl.searchParams.set("projectId",projectId);let response=await client.fetch(traceUrl.href,{headers:{[QUERY_REASON_HEADER]:QUERY_REASON}});return{trace:mapTrace(response),partial:isRecord(response.meta)&&response.meta.partial===!0}}function mapTrace(response){if(!isRecord(response)||typeof response.traceId!="string"||!Array.isArray(response.spans))throw new QueryEngineResponseError("Observability API returned an invalid resolved trace.");return{traceId:response.traceId,...typeof response.rootSpanId=="string"?{rootSpanId:response.rootSpanId}:{},spans:response.spans.map(mapSpan)}}function mapSpan(value){if(!isRecord(value)||typeof value.spanId!="string")throw new QueryEngineResponseError("Observability API returned an invalid trace span.");if(typeof value.name!="string"||typeof value.durationMs!="number")throw new QueryEngineResponseError("Observability API returned an invalid trace span.");let timestamp2=parseTimestamp(value.timestamp),attributes=isRecord(value.attributes)?value.attributes:void 0,status=isRecord(value.status)?value.status:void 0,statusCode=mapStatusCode(status?.code),statusMessage=typeof status?.message=="string"?status.message:void 0;return{spanId:value.spanId,...typeof value.parentSpanId=="string"&&value.parentSpanId?{parentSpanId:value.parentSpanId}:{},name:value.name,duration:durationTuple(value.durationMs),startTime:timestampTuple(timestamp2),...attributes?{attributes}:{},status:{code:statusCode,...statusMessage?{message:statusMessage}:{}}}}function mapStatusCode(code){switch(code){case"ERROR":return SPAN_STATUS_ERROR;case"OK":return SPAN_STATUS_OK;default:return SPAN_STATUS_UNSET}}function parseTimestamp(value){if(typeof value!="string")throw new QueryEngineResponseError("Observability API returned an invalid trace timestamp.");let timestamp2=Date.parse(value);if(!Number.isFinite(timestamp2))throw new QueryEngineResponseError("Observability API returned an invalid trace timestamp.");return timestamp2}function durationTuple(durationMs){let nanoseconds=Math.round(durationMs*1e6);if(!Number.isSafeInteger(nanoseconds)||nanoseconds<0)throw new QueryEngineResponseError("Observability API returned an invalid span duration.");return[Math.floor(nanoseconds/1e9),nanoseconds%1e9]}function timestampTuple(timestampMs){let seconds=Math.floor(timestampMs/1e3);return[seconds,(timestampMs-seconds*1e3)*1e6]}function isRecord(value){return typeof value=="object"&&value!==null&&!Array.isArray(value)}var UNKNOWN="<unknown>",UNNAMED="<unnamed>",ATTR_VALUE_MAX_LEN=80,TRACE_ID_MAX_LEN=13;function renderMarkdown(trace,options){let analysis=analyze(trace),sections=[];return sections.push(renderHeader(analysis,options)),analysis.errorSpans.length>0&&sections.push(renderErrors(analysis)),analysis.repeatedOps.length>0&&sections.push(renderRepeatedOps(analysis)),sections.push(renderTree(analysis)),`${sections.join(`
107
107
 
108
108
  `)}
109
109
  `}function renderHeader(analysis,options){let{trace,root,rootDurationUs,errorSpans}=analysis,attributes=root?.attributes,method=readAttrString(attributes,"http.method"),target=readAttrString(attributes,"http.target"),status=readAttrString(attributes,"http.status_code"),endpoint=formatEndpoint(method,target,status),duration=formatDurationUs(rootDurationUs),spans=formatSpansLine(trace.spans.length,errorSpans.length);return[`# Trace ${ellipsis(trace.traceId,TRACE_ID_MAX_LEN)}`,"",`- **Trace id:** ${trace.traceId}`,...options.requestId!==void 0?[`- **Request id:** ${options.requestId}`]:[],`- **Endpoint:** ${endpoint}`,`- **Duration:** ${duration}`,`- **Spans:** ${spans}`].join(`
@@ -113,10 +113,10 @@ ${formatStatusReport(report,Date.now())}`),0}var TracesTelemetryClient=class ext
113
113
  `);for(let node of analysis.treeOrder)lines.push(formatTreeRow(node,analysis));if(analysis.orphanOrder.length>0){lines.push("","### Orphan spans","");for(let node of analysis.orphanOrder)lines.push(formatTreeRow(node,analysis))}return analysis.truncatedAtDepth&&lines.push("",`_Tree truncated at depth ${256}._`),lines.join(`
114
114
  `)}function formatTreeRow(node,analysis){let{span,depth}=node,info=analysis.spanInfo.get(span.spanId),indent=" ".repeat(depth),parts=[],durationUs=info?.durationUs??null;if(parts.push(`\`${formatDurationUs(durationUs)}\``),analysis.rootDurationUs!==null&&analysis.rootDurationUs>0&&parts.push(formatPct(durationUs,analysis.rootDurationUs)),analysis.rootStartUs!==null){let offset=info?.startOffsetUs??null;parts.push(formatOffset(offset))}if(parts.push(`\`${span.name||UNNAMED}\``),span.status?.code===SPAN_STATUS_ERROR){let message=span.status.message;parts.push(message?`[error: ${message}]`:"[error]")}let[hint]=collectAttrHints(span.attributes);return hint&&parts.push(`\u2014 \`${hint.key}\`: ${hint.value}`),`${indent}- ${parts.join(" ")}`}function formatEndpoint(method,target,status){let left=method&&target?`${method} ${target}`:method??target,path=left?`\`${left}\``:UNKNOWN;return status?`${path} \u2192 ${status}`:path}function formatSpansLine(count,errors){return errors===0?String(count):`${count} (${errors} ${errors===1?"error":"errors"})`}function formatDurationUs(us){return us===null?UNKNOWN:us<1e3?`${Math.round(us)}\u03BCs`:us<1e6?`${(us/1e3).toFixed(1)}ms`:`${(us/1e6).toFixed(1)}s`}function formatOffset(us){return us===null?`+${UNKNOWN}`:`+${formatDurationUs(us)}`}function formatPct(us,rootUs){if(us===null||rootUs<=0)return UNKNOWN;let pct=us/rootUs*100;return pct>0&&pct<1?"<1%":`${Math.round(pct)}%`}function collectAttrHints(attributes){if(!attributes)return[];let out=[];for(let key of ATTR_HINT_KEYS){let value=readAttrString(attributes,key);value!==void 0&&out.push({key,value:ellipsis(value,ATTR_VALUE_MAX_LEN)})}return out}var VIEW_OPTIONS=["timeline","tree","waterfall"];function isView(value){return VIEW_OPTIONS.includes(value)}function buildDashboardUrl({teamSlug,projectName,traceId,view}){let base=`https://vercel.com/${encodeURIComponent(teamSlug)}/${encodeURIComponent(projectName)}/logs/traces/${encodeURIComponent(traceId)}`;return view&&view!=="timeline"?`${base}?view=${encodeURIComponent(view)}`:base}async function resolveDashboardScope({client,scopeFlag,projectName,linkedProject}){let teamSlug;if(scopeFlag)scopeFlag.startsWith("team_")?teamSlug=(await getTeamByIdOrSlug(client,scopeFlag)).slug:teamSlug=scopeFlag;else if(linkedProject.status==="linked")teamSlug=linkedProject.org.slug;else return{error:"Unable to resolve team slug for the dashboard URL.",reason:AGENT_REASON.NOT_LINKED};return{teamSlug,projectName}}async function get(client,telemetry){let parsedArgs,flagsSpecification=getFlagsSpecification(getSubcommand.options);try{parsedArgs=parseArguments(client.argv.slice(2),flagsSpecification)}catch(err){return printError(err),2}let positional=parsedArgs.args.slice(1),identifiers=[getSubcommand.name,...getSubcommand.aliases].includes(positional[0])?positional.slice(1):positional,id2=identifiers[0],isTraceId=id2!==void 0&&/^[a-fA-F0-9]{32}$/.test(id2),json=parsedArgs.flags["--json"],scopeFlag=parsedArgs.flags["--scope"]?.trim()||void 0,projectFlag=parsedArgs.flags["--project"],openFlag=parsedArgs.flags["--open"],viewFlag=parsedArgs.flags["--view"];if(telemetry.trackCliArgumentId(id2,isTraceId?"traceId":"requestId"),telemetry.trackCliFlagJson(json),telemetry.trackCliOptionProject(projectFlag),telemetry.trackCliFlagOpen(openFlag),telemetry.trackCliOptionView(viewFlag),json&&openFlag){let msg="`--json` and `--open` cannot be used together.";return client.nonInteractive&&outputAgentError(client,{status:AGENT_STATUS.ERROR,reason:AGENT_REASON.INVALID_ARGUMENTS,message:msg}),output_manager_default.error(msg),2}if(viewFlag&&!openFlag){let msg="`--view` can only be used with `--open`.";return client.nonInteractive&&outputAgentError(client,{status:AGENT_STATUS.ERROR,reason:AGENT_REASON.INVALID_ARGUMENTS,message:msg}),output_manager_default.error(msg),2}let view;if(viewFlag!==void 0){if(!isView(viewFlag)){let msg=`\`--view\` must be one of: ${VIEW_OPTIONS.join(", ")}. Received: ${viewFlag}`;return client.nonInteractive&&outputAgentError(client,{status:AGENT_STATUS.ERROR,reason:AGENT_REASON.INVALID_ARGUMENTS,message:msg}),output_manager_default.error(msg),2}view=viewFlag}if(!id2)return output_manager_default.print(help(getSubcommand,{parent:tracesCommand,columns:client.stderr.columns})),2;if(identifiers.length>1){let msg="Provide one trace ID or request ID.";return client.nonInteractive&&writeAgentError(client,{status:AGENT_STATUS.ERROR,reason:AGENT_REASON.INVALID_ARGUMENTS,message:msg}),output_manager_default.fatal(msg),2}let target=isTraceId?{traceId:id2.toLowerCase()}:{requestId:id2},teamId,projectId,linkedProject;if(linkedProject=await getLinkedProject(client),linkedProject.status==="error")if(scopeFlag&&projectFlag)linkedProject={status:"not_linked",org:null,project:null};else return linkedProject.exitCode;let scope;try{scope=await resolveScope({client,flags:{scope:scopeFlag,project:projectFlag},linkedProject})}catch(err){return printError(err),1}if("message"in scope)return client.nonInteractive&&outputAgentError(client,{status:AGENT_STATUS.ERROR,reason:scope.reason,message:scope.message}),output_manager_default.error(scope.message),1;teamId=scope.teamId,projectId=scope.projectId,output_manager_default.spinner("Fetching trace\u2026");let trace,partial;try{({trace,partial}=await fetchTrace({client,teamId,projectId,...target}))}catch(err){return output_manager_default.stopSpinner(),printError(err),1}output_manager_default.stopSpinner();let rootRequestId=resolveRootSpan(trace)?.attributes?.["vercel.request_id"],requestId=target.requestId??(typeof rootRequestId=="string"&&rootRequestId.trim()!==""?rootRequestId:void 0);if(partial&&output_manager_default.warn("Trace is incomplete because it exceeded the span limit."),openFlag){if(!linkedProject){let msg="Unable to resolve project link for the dashboard URL.";return client.nonInteractive&&outputAgentError(client,{status:AGENT_STATUS.ERROR,reason:AGENT_REASON.NOT_LINKED,message:msg}),output_manager_default.error(msg),1}let resolved=await resolveDashboardScope({client,scopeFlag,projectName:scope.projectName,linkedProject});if("error"in resolved)return client.nonInteractive&&outputAgentError(client,{status:AGENT_STATUS.ERROR,reason:resolved.reason,message:resolved.error}),output_manager_default.error(resolved.error),1;let url=buildDashboardUrl({teamSlug:resolved.teamSlug,projectName:resolved.projectName,traceId:trace.traceId,view});return output_manager_default.log(`Opening ${url} in your browser...`),await(0,import_open.default)(url),0}if(json)return client.stdout.write(`${JSON.stringify(trace,null,2)}
115
115
  `),0;client.stdout.write(renderMarkdown(trace,{requestId}));try{let resolved=await resolveDashboardScope({client,scopeFlag,projectName:scope.projectName,linkedProject});if("error"in resolved)output_manager_default.warn(resolved.error);else{let url=buildDashboardUrl({...resolved,traceId:trace.traceId,view});output_manager_default.log(`View trace: ${url}`)}}catch(err){output_manager_default.print(`${import_chalk8.default.yellow("!")} Failed to resolve the dashboard URL. Use --open to retry.
116
- `),output_manager_default.debug(String(err))}return output_manager_default.log("Run with --json for full trace data."),0}var import_chalk9=__toESM(require_source(),1);var import_ms6=__toESM(require_ms(),1);var DEFAULT_LIMIT=100,MAX_LIMIT2=1e3,SPAN_EVENT="vercel.span",SPAN_SELECT=["span","resource"],QUERY_REASON2="cli/traces-search",SPAN_KINDS=["UNSPECIFIED","INTERNAL","SERVER","CLIENT","PRODUCER","CONSUMER"],MAX_RANGE_MS=30*24*60*60*1e3,isoDateTimeSchema=external_exports.iso.datetime({offset:!0}),timeInputSchema=external_exports.union([isoDateTimeSchema,external_exports.iso.date()]),TIME_FORMAT_HINT="Use a duration with units such as 100ms or 30m, an ISO timestamp, or YYYY-MM-DD at midnight UTC.",CONTINUATION_CONFLICTS=["--project","--environment","--service","--name","--kind","--status","--deployment","--deployment-id","--request-id","--trace-id","--span-id","--root","--since","--until","--query"];async function resolveSpanSearchScope(client,project){if(project!==void 0){let scope2=await resolveConfigScope(client,{project});return"exitCode"in scope2?scope2:{ownerId:scope2.teamId,projectIds:[scope2.projectId]}}let scope;try{scope=await getScope(client,{resolveLocalScope:!0})}catch(error){return{exitCode:handleTracingApiError(client,error)}}return scope.isCrossTeamRepo&&!scope.localOrgId&&!scope.explicitScopeProvided&&(!scope.app||scope.user)?{exitCode:invalidArguments(client,"This repository has projects across multiple teams. Pass `--scope <team>` or run from a linked project directory.")}:scope.team?{ownerId:scope.team.id}:{exitCode:invalidArguments(client,"A team scope is required. Pass `--scope <team>` or run `vercel switch <team>`.")}}function parseTime(input,now){let value=input.trim();if(!value)return null;try{let duration=(0,import_ms6.default)(value);if(duration!==void 0&&(duration<=0||!/[a-z]/i.test(value))||duration===void 0&&!timeInputSchema.safeParse(value).success)return null;let date=new Date(duration===void 0?value:now-duration);return Number.isFinite(date.getTime())?date:null}catch{return null}}function buildFilter(flags,spanKind){let clauses=["NOT (service.name:vercel.* AND span.kind:1)"],query=flags["--query"];typeof query=="string"&&clauses.push(`(${query.trim()})`),spanKind!==void 0&&clauses.push(`span.kind:${spanKind}`),flags["--root"]&&clauses.push("span.isRoot:1");let filters=[["--environment","environment"],["--service","service.name"],["--name","span.name"],["--status","span.status.code"],["--deployment","deployment.id"],["--deployment-id","deployment.id"],["--request-id","request.id"],["--trace-id","trace.id"],["--span-id","span.id"]];for(let[flag,dimension]of filters){let rawValue=flags[flag];if(typeof rawValue!="string")continue;let value=flag==="--status"?{error:"Error",ok:"Ok",unset:"Unset"}[rawValue]:rawValue.trim();clauses.push(`${dimension}:${JSON.stringify(value)}`)}return clauses.join(" AND ")}function trackSpanQueryOptions(flags,telemetry){telemetry.trackCliFlagJson(flags["--json"]),telemetry.trackCliOptionProject(flags["--project"]),telemetry.trackCliOptionEnvironment(flags["--environment"]),telemetry.trackCliOptionService(flags["--service"]),telemetry.trackCliOptionName(flags["--name"]),telemetry.trackCliOptionKind(flags["--kind"]),telemetry.trackCliOptionStatus(flags["--status"]),telemetry.trackCliOptionDeployment(flags["--deployment"]),telemetry.trackCliOptionDeploymentId(flags["--deployment-id"]),telemetry.trackCliOptionRequestId(flags["--request-id"]),telemetry.trackCliOptionTraceId(flags["--trace-id"]),telemetry.trackCliOptionSpanId(flags["--span-id"]),telemetry.trackCliFlagRoot(flags["--root"]),telemetry.trackCliOptionSince(flags["--since"]),telemetry.trackCliOptionUntil(flags["--until"]),telemetry.trackCliOptionLimit(flags["--limit"]),telemetry.trackCliOptionQuery(flags["--query"]),telemetry.trackCliOptionNext(flags["--next"])}async function resolveSpanQuery(client,flags,telemetry){let project=flags["--project"],environment=flags["--environment"]?.trim().toLowerCase(),status=flags["--status"]?.trim().toLowerCase(),query=flags["--query"];if(trackSpanQueryOptions(flags,telemetry),environment!==void 0&&!["production","preview"].includes(environment))return{exitCode:invalidArguments(client,"`--environment` must be one of: production, preview.")};if(status!==void 0&&!["error","ok","unset"].includes(status))return{exitCode:invalidArguments(client,"`--status` must be one of: error, ok, unset.")};for(let flag of["--service","--name","--deployment","--deployment-id","--request-id","--trace-id","--span-id"])if(flags[flag]!==void 0&&flags[flag]?.trim()==="")return{exitCode:invalidArguments(client,`\`${flag}\` must not be empty.`)};if(query!==void 0&&query.trim()==="")return{exitCode:invalidArguments(client,"`--query` must not be empty.")};let spanKind;if(flags["--kind"]!==void 0){let value=flags["--kind"].trim().toUpperCase();if(spanKind=/^[0-5]$/.test(value)?Number(value):SPAN_KINDS.indexOf(value.replace(/^SPAN_KIND_/,"")),spanKind===-1)return{exitCode:invalidArguments(client,"`--kind` must be one of: UNSPECIFIED (0), INTERNAL (1), SERVER (2), CLIENT (3), PRODUCER (4), CONSUMER (5).")}}let limit=parseSpanLimit(client,flags["--limit"]);if(typeof limit!="number")return limit;let now=Date.now(),start=parseTime(flags["--since"]??"1h",now),end=flags["--until"]!==void 0?parseTime(flags["--until"],now):new Date(now);if(!start)return{exitCode:invalidArguments(client,`Invalid time format for \`--since\`. ${TIME_FORMAT_HINT}`)};if(!end)return{exitCode:invalidArguments(client,`Invalid time format for \`--until\`. ${TIME_FORMAT_HINT}`)};if(start.getTime()>=end.getTime())return{exitCode:invalidArguments(client,"`--since` must be earlier than `--until`.")};if(end.getTime()-start.getTime()>MAX_RANGE_MS)return{exitCode:invalidArguments(client,"The requested time range must not exceed 30 days.")};if(now-start.getTime()>MAX_RANGE_MS)return{exitCode:invalidArguments(client,"`--since` must be within the last 30 days.")};let scope=await resolveSpanSearchScope(client,project);return"exitCode"in scope?scope:{scope,timeRange:{start:start.toISOString(),end:end.toISOString()},filter:buildFilter({...flags,"--environment":environment,"--status":status},spanKind),limit}}function parseSpanLimit(client,value){let limitResult=validateIntegerRangeWithDefault(value,{flag:"--limit",min:1,max:MAX_LIMIT2,defaultValue:DEFAULT_LIMIT});return limitResult.valid?limitResult.value:{exitCode:invalidArguments(client,limitResult.message)}}function isCanonicalTimestamp(value){let date=new Date(value);return Number.isFinite(date.getTime())&&date.toISOString()===value}function resolveSpanContinuation(client,flags,telemetry){trackSpanQueryOptions(flags,telemetry);let token=flags["--next"]?.trim();if(!token)return{exitCode:invalidArguments(client,"`--next` must not be empty.")};let continuation=decodeContinuation(token),projectIds=continuation?.projectIds??[];if(!continuation||continuation.event!==SPAN_EVENT||continuation.order!=="desc"||projectIds.length>1||!isCanonicalTimestamp(continuation.timeRange.start)||!isCanonicalTimestamp(continuation.timeRange.end)||continuation.timeRange.start>=continuation.timeRange.end)return{exitCode:invalidArguments(client,`\`--next\` is not a valid cursor. Use the pagination.next value from the summary of a previous ${getCommandName("traces search --json")} run.`)};for(let flag of CONTINUATION_CONFLICTS)if(flags[flag]!==void 0)return{exitCode:invalidArguments(client,`\`${flag}\` can't be combined with \`--next\`. The cursor keeps the original filters and time window.`)};if(scopeFlagPassed(client.argv)&&client.config.currentTeam!==continuation.ownerId)return{exitCode:invalidArguments(client,"The `--next` cursor belongs to a different team than `--scope`. Remove `--scope` to use the team in the cursor.")};let limit=parseSpanLimit(client,flags["--limit"]);return typeof limit!="number"?limit:{scope:{ownerId:continuation.ownerId,...projectIds.length===1?{projectIds:[projectIds[0]]}:{}},timeRange:continuation.timeRange,filter:continuation.filter??"",limit,startCursor:continuation.cursor}}function spanEventsRequest(query){return{event:SPAN_EVENT,ownerId:query.scope.ownerId,...query.scope.projectIds?{projectIds:query.scope.projectIds}:{},timeRange:query.timeRange,...query.filter?{filter:query.filter}:{},select:SPAN_SELECT,queryReason:QUERY_REASON2,bailOn429:!0}}function spanContinuationToken(query,cursor){return encodeContinuation({event:SPAN_EVENT,ownerId:query.scope.ownerId,...query.scope.projectIds?{projectIds:query.scope.projectIds}:{},timeRange:query.timeRange,...query.filter?{filter:query.filter}:{},order:"desc",cursor})}function addSpanQueryIssueDetails(err){if(isAPIError(err)){let issues=external_exports.array(external_exports.object({path:external_exports.string(),message:external_exports.string()})).safeParse(err.issues);if(issues.success&&issues.data.length>0){let details=issues.data.map(issue=>`${issue.path}: ${issue.message}`).join(", ");err.serverMessage=`${err.serverMessage}: ${details}`,(err.status===400||err.status===422)&&issues.data.some(issue=>issue.path==="filter")&&(err.serverMessage+=". Filter error positions refer to the generated filter, including CLI-added clauses."),err.message=`${err.serverMessage} (${err.status})`}}}var INVALID_RESPONSE_MESSAGE="The Observability API returned an invalid span search response.",spanSchema=external_exports.object({span:external_exports.object({startTime:isoDateTimeSchema,traceId:external_exports.string(),id:external_exports.string(),parentSpanId:external_exports.string().nullable(),isRoot:external_exports.number(),traceState:external_exports.string(),name:external_exports.string(),kind:external_exports.string(),status:external_exports.object({code:external_exports.string(),message:external_exports.string()}),duration:external_exports.number(),attributes:external_exports.record(external_exports.string(),external_exports.unknown()),events:external_exports.array(external_exports.object({name:external_exports.string(),timestamp:isoDateTimeSchema,attributes:external_exports.record(external_exports.string(),external_exports.unknown())})).optional(),links:external_exports.array(external_exports.object({traceId:external_exports.string(),spanId:external_exports.string(),traceState:external_exports.string(),attributes:external_exports.record(external_exports.string(),external_exports.unknown())})).optional()}).passthrough(),resource:external_exports.object({attributes:external_exports.record(external_exports.string(),external_exports.unknown())})}),spansSchema=external_exports.array(spanSchema);function formatDuration2(durationMs){if(durationMs===0)return"0ms";if(durationMs<1e-6)return"<1ns";let units=[[1e-6,"ns"],[.001,"\u03BCs"],[1,"ms"],[1e3,"s"],[6e4,"m"],[36e5,"h"],[864e5,"d"]],index=units.length-1;for(;durationMs<units[index][0];)index--;let value=Number((durationMs/units[index][0]).toFixed(1));return index<units.length-1&&value>=Math.round(units[index+1][0]/units[index][0])&&(index++,value=Number((durationMs/units[index][0]).toFixed(1))),`${value}${units[index][1]}`}function cell(value){return value||"-"}function stringAttribute(attributes,key){let value=attributes[key];return typeof value=="string"?value:null}var spanColumns={"span.startTime":{header:"TIME",format:event=>new Date(event.span.startTime).toISOString()},"span.duration":{header:"DURATION",format:event=>formatDuration2(event.span.duration)},"span.name":{header:"SPAN NAME",format:event=>ellipsis(cell(event.span.name),60)},"span.status.code":{header:"STATUS",format:event=>event.span.status.code.toUpperCase()==="ERROR"?import_chalk9.default.red("ERROR"):cell(event.span.status.code.toUpperCase())},"service.name":{header:"SERVICE NAME",format:event=>{let serviceName=stringAttribute(event.resource.attributes,"service.name");return serviceName?.startsWith("vercel.")?`\u25B2 ${serviceName}`:cell(serviceName)}},environment:{header:"ENVIRONMENT",format:event=>cell(stringAttribute(event.resource.attributes,"deployment.environment.name"))},"request.id":{header:"REQUEST ID",format:event=>stringAttribute(event.span.attributes,"vercel.request_id")?.split("::").at(-1)||"-"},"trace.id":{header:"TRACE ID",format:event=>cell(event.span.traceId)},"span.id":{header:"SPAN ID",format:event=>cell(event.span.id)},"parent.id":{header:"PARENT ID",format:event=>cell(event.span.parentSpanId)},"span.kind":{header:"SPAN KIND",format:event=>SPAN_KINDS.find((kind,index)=>event.span.kind===String(index)||event.span.kind.toUpperCase()===kind)??cell(event.span.kind)}};function printSpans(client,spans,columns){if(spans.length===0){client.stdout.write(`No spans found for this period.
116
+ `),output_manager_default.debug(String(err))}return output_manager_default.log("Run with --json for full trace data."),0}var import_chalk9=__toESM(require_source(),1);var import_ms6=__toESM(require_ms(),1);var DEFAULT_LIMIT=100,MAX_LIMIT2=1e3,SPAN_EVENT="vercel.span",SPAN_SELECT=["span","resource"],QUERY_REASON2="cli/traces-search",SPAN_KINDS=["UNSPECIFIED","INTERNAL","SERVER","CLIENT","PRODUCER","CONSUMER"],MAX_RANGE_MS=30*24*60*60*1e3,isoDateTimeSchema=external_exports.iso.datetime({offset:!0}),timeInputSchema=external_exports.union([isoDateTimeSchema,external_exports.iso.date()]),TIME_FORMAT_HINT="Use a duration with units such as 100ms or 30m, an ISO timestamp, or YYYY-MM-DD at midnight UTC.",CONTINUATION_CONFLICTS=["--project","--environment","--service","--name","--kind","--status","--deployment","--deployment-id","--request-id","--trace","--trace-id","--span","--span-id","--root","--since","--until","--query"];async function resolveSpanSearchScope(client,project){if(project!==void 0){let scope2=await resolveConfigScope(client,{project});return"exitCode"in scope2?scope2:{ownerId:scope2.teamId,projectIds:[scope2.projectId]}}let scope;try{scope=await getScope(client,{resolveLocalScope:!0})}catch(error){return{exitCode:handleTracingApiError(client,error)}}return scope.isCrossTeamRepo&&!scope.localOrgId&&!scope.explicitScopeProvided&&(!scope.app||scope.user)?{exitCode:invalidArguments(client,"This repository has projects across multiple teams. Pass `--scope <team>` or run from a linked project directory.")}:scope.team?{ownerId:scope.team.id}:{exitCode:invalidArguments(client,"A team scope is required. Pass `--scope <team>` or run `vercel switch <team>`.")}}function parseTime(input,now){let value=input.trim();if(!value)return null;try{let duration=(0,import_ms6.default)(value);if(duration!==void 0&&(duration<=0||!/[a-z]/i.test(value))||duration===void 0&&!timeInputSchema.safeParse(value).success)return null;let date=new Date(duration===void 0?value:now-duration);return Number.isFinite(date.getTime())?date:null}catch{return null}}function buildFilter(flags,spanKind){let clauses=["NOT (service.name:vercel.* AND span.kind:1)"],query=flags["--query"];typeof query=="string"&&clauses.push(`(${query.trim()})`),spanKind!==void 0&&clauses.push(`span.kind:${spanKind}`),flags["--root"]&&clauses.push("span.isRoot:1");let filters=[["--environment","environment"],["--service","service.name"],["--name","span.name"],["--status","span.status.code"],["--deployment","deployment.id"],["--deployment-id","deployment.id"],["--request-id","request.id"],["--trace","trace.id"],["--trace-id","trace.id"],["--span","span.id"],["--span-id","span.id"]];for(let[flag,dimension]of filters){let rawValue=flags[flag];if(typeof rawValue!="string")continue;let value=flag==="--status"?{error:"Error",ok:"Ok",unset:"Unset"}[rawValue]:rawValue.trim();clauses.push(`${dimension}:${JSON.stringify(value)}`)}return clauses.join(" AND ")}function trackSpanQueryOptions(flags,telemetry){telemetry.trackCliFlagJson(flags["--json"]),telemetry.trackCliOptionProject(flags["--project"]),telemetry.trackCliOptionEnvironment(flags["--environment"]),telemetry.trackCliOptionService(flags["--service"]),telemetry.trackCliOptionName(flags["--name"]),telemetry.trackCliOptionKind(flags["--kind"]),telemetry.trackCliOptionStatus(flags["--status"]),telemetry.trackCliOptionDeployment(flags["--deployment"]),telemetry.trackCliOptionDeploymentId(flags["--deployment-id"]),telemetry.trackCliOptionRequestId(flags["--request-id"]),telemetry.trackCliOptionTrace(flags["--trace"]),telemetry.trackCliOptionTraceId(flags["--trace-id"]),telemetry.trackCliOptionSpan(flags["--span"]),telemetry.trackCliOptionSpanId(flags["--span-id"]),telemetry.trackCliFlagRoot(flags["--root"]),telemetry.trackCliOptionSince(flags["--since"]),telemetry.trackCliOptionUntil(flags["--until"]),telemetry.trackCliOptionLimit(flags["--limit"]),telemetry.trackCliOptionQuery(flags["--query"]),telemetry.trackCliOptionNext(flags["--next"])}async function resolveSpanQuery(client,flags,telemetry){let project=flags["--project"],environment=flags["--environment"]?.trim().toLowerCase(),status=flags["--status"]?.trim().toLowerCase(),query=flags["--query"];if(trackSpanQueryOptions(flags,telemetry),environment!==void 0&&!["production","preview"].includes(environment))return{exitCode:invalidArguments(client,"`--environment` must be one of: production, preview.")};if(status!==void 0&&!["error","ok","unset"].includes(status))return{exitCode:invalidArguments(client,"`--status` must be one of: error, ok, unset.")};for(let flag of["--service","--name","--deployment","--deployment-id","--request-id","--trace","--trace-id","--span","--span-id"])if(flags[flag]!==void 0&&flags[flag]?.trim()==="")return{exitCode:invalidArguments(client,`\`${flag}\` must not be empty.`)};if(query!==void 0&&query.trim()==="")return{exitCode:invalidArguments(client,"`--query` must not be empty.")};let spanKind;if(flags["--kind"]!==void 0){let value=flags["--kind"].trim().toUpperCase();if(spanKind=/^[0-5]$/.test(value)?Number(value):SPAN_KINDS.indexOf(value.replace(/^SPAN_KIND_/,"")),spanKind===-1)return{exitCode:invalidArguments(client,"`--kind` must be one of: UNSPECIFIED (0), INTERNAL (1), SERVER (2), CLIENT (3), PRODUCER (4), CONSUMER (5).")}}let limit=parseSpanLimit(client,flags["--limit"]);if(typeof limit!="number")return limit;let now=Date.now(),start=parseTime(flags["--since"]??"1h",now),end=flags["--until"]!==void 0?parseTime(flags["--until"],now):new Date(now);if(!start)return{exitCode:invalidArguments(client,`Invalid time format for \`--since\`. ${TIME_FORMAT_HINT}`)};if(!end)return{exitCode:invalidArguments(client,`Invalid time format for \`--until\`. ${TIME_FORMAT_HINT}`)};if(start.getTime()>=end.getTime())return{exitCode:invalidArguments(client,"`--since` must be earlier than `--until`.")};if(end.getTime()-start.getTime()>MAX_RANGE_MS)return{exitCode:invalidArguments(client,"The requested time range must not exceed 30 days.")};if(now-start.getTime()>MAX_RANGE_MS)return{exitCode:invalidArguments(client,"`--since` must be within the last 30 days.")};let scope=await resolveSpanSearchScope(client,project);return"exitCode"in scope?scope:{scope,timeRange:{start:start.toISOString(),end:end.toISOString()},filter:buildFilter({...flags,"--environment":environment,"--status":status},spanKind),limit}}function parseSpanLimit(client,value){let limitResult=validateIntegerRangeWithDefault(value,{flag:"--limit",min:1,max:MAX_LIMIT2,defaultValue:DEFAULT_LIMIT});return limitResult.valid?limitResult.value:{exitCode:invalidArguments(client,limitResult.message)}}function isCanonicalTimestamp(value){let date=new Date(value);return Number.isFinite(date.getTime())&&date.toISOString()===value}function resolveSpanContinuation(client,flags,telemetry){trackSpanQueryOptions(flags,telemetry);let token=flags["--next"]?.trim();if(!token)return{exitCode:invalidArguments(client,"`--next` must not be empty.")};let continuation=decodeContinuation(token),projectIds=continuation?.projectIds??[];if(!continuation||continuation.event!==SPAN_EVENT||continuation.order!=="desc"||projectIds.length>1||!isCanonicalTimestamp(continuation.timeRange.start)||!isCanonicalTimestamp(continuation.timeRange.end)||continuation.timeRange.start>=continuation.timeRange.end)return{exitCode:invalidArguments(client,`\`--next\` is not a valid cursor. Use the pagination.next value from the summary of a previous ${getCommandName("traces search --json")} run.`)};for(let flag of CONTINUATION_CONFLICTS)if(flags[flag]!==void 0)return{exitCode:invalidArguments(client,`\`${flag}\` can't be combined with \`--next\`. The cursor keeps the original filters and time window.`)};if(scopeFlagPassed(client.argv)&&client.config.currentTeam!==continuation.ownerId)return{exitCode:invalidArguments(client,"The `--next` cursor belongs to a different team than `--scope`. Remove `--scope` to use the team in the cursor.")};let limit=parseSpanLimit(client,flags["--limit"]);return typeof limit!="number"?limit:{scope:{ownerId:continuation.ownerId,...projectIds.length===1?{projectIds:[projectIds[0]]}:{}},timeRange:continuation.timeRange,filter:continuation.filter??"",limit,startCursor:continuation.cursor}}function spanEventsRequest(query){return{event:SPAN_EVENT,ownerId:query.scope.ownerId,...query.scope.projectIds?{projectIds:query.scope.projectIds}:{},timeRange:query.timeRange,...query.filter?{filter:query.filter}:{},select:SPAN_SELECT,queryReason:QUERY_REASON2,bailOn429:!0}}function spanContinuationToken(query,cursor){return encodeContinuation({event:SPAN_EVENT,ownerId:query.scope.ownerId,...query.scope.projectIds?{projectIds:query.scope.projectIds}:{},timeRange:query.timeRange,...query.filter?{filter:query.filter}:{},order:"desc",cursor})}function addSpanQueryIssueDetails(err){if(isAPIError(err)){let issues=external_exports.array(external_exports.object({path:external_exports.string(),message:external_exports.string()})).safeParse(err.issues);if(issues.success&&issues.data.length>0){let details=issues.data.map(issue=>`${issue.path}: ${issue.message}`).join(", ");err.serverMessage=`${err.serverMessage}: ${details}`,(err.status===400||err.status===422)&&issues.data.some(issue=>issue.path==="filter")&&(err.serverMessage+=". Filter error positions refer to the generated filter, including CLI-added clauses."),err.message=`${err.serverMessage} (${err.status})`}}}var INVALID_RESPONSE_MESSAGE="The Observability API returned an invalid span search response.",spanSchema=external_exports.object({span:external_exports.object({startTime:isoDateTimeSchema,traceId:external_exports.string(),id:external_exports.string(),parentSpanId:external_exports.string().nullable(),isRoot:external_exports.number(),traceState:external_exports.string(),name:external_exports.string(),kind:external_exports.string(),status:external_exports.object({code:external_exports.string(),message:external_exports.string()}),duration:external_exports.number(),attributes:external_exports.record(external_exports.string(),external_exports.unknown()),events:external_exports.array(external_exports.object({name:external_exports.string(),timestamp:isoDateTimeSchema,attributes:external_exports.record(external_exports.string(),external_exports.unknown())})).optional(),links:external_exports.array(external_exports.object({traceId:external_exports.string(),spanId:external_exports.string(),traceState:external_exports.string(),attributes:external_exports.record(external_exports.string(),external_exports.unknown())})).optional()}).passthrough(),resource:external_exports.object({attributes:external_exports.record(external_exports.string(),external_exports.unknown())})}),spansSchema=external_exports.array(spanSchema);function formatDuration2(durationMs){if(durationMs===0)return"0ms";if(durationMs<1e-6)return"<1ns";let units=[[1e-6,"ns"],[.001,"\u03BCs"],[1,"ms"],[1e3,"s"],[6e4,"m"],[36e5,"h"],[864e5,"d"]],index=units.length-1;for(;durationMs<units[index][0];)index--;let value=Number((durationMs/units[index][0]).toFixed(1));return index<units.length-1&&value>=Math.round(units[index+1][0]/units[index][0])&&(index++,value=Number((durationMs/units[index][0]).toFixed(1))),`${value}${units[index][1]}`}function cell(value){return value||"-"}function stringAttribute(attributes,key){let value=attributes[key];return typeof value=="string"?value:null}var spanColumns={"span.startTime":{header:"TIME",format:event=>new Date(event.span.startTime).toISOString()},"span.duration":{header:"DURATION",format:event=>formatDuration2(event.span.duration)},"span.name":{header:"SPAN NAME",format:event=>ellipsis(cell(event.span.name),60)},"span.status.code":{header:"STATUS",format:event=>event.span.status.code.toUpperCase()==="ERROR"?import_chalk9.default.red("ERROR"):cell(event.span.status.code.toUpperCase())},"service.name":{header:"SERVICE NAME",format:event=>{let serviceName=stringAttribute(event.resource.attributes,"service.name");return serviceName?.startsWith("vercel.")?`\u25B2 ${serviceName}`:cell(serviceName)}},environment:{header:"ENVIRONMENT",format:event=>cell(stringAttribute(event.resource.attributes,"deployment.environment.name"))},"request.id":{header:"REQUEST ID",format:event=>stringAttribute(event.span.attributes,"vercel.request_id")?.split("::").at(-1)||"-"},"trace.id":{header:"TRACE ID",format:event=>cell(event.span.traceId)},"span.id":{header:"SPAN ID",format:event=>cell(event.span.id)},"parent.id":{header:"PARENT ID",format:event=>cell(event.span.parentSpanId)},"span.kind":{header:"SPAN KIND",format:event=>SPAN_KINDS.find((kind,index)=>event.span.kind===String(index)||event.span.kind.toUpperCase()===kind)??cell(event.span.kind)}};function printSpans(client,spans,columns){if(spans.length===0){client.stdout.write(`No spans found for this period.
117
117
  `);return}client.stdout.write(`${table([columns.map(column=>column.header),...spans.map(span=>columns.map(column=>column.format(span)))])}
118
- `)}async function search(client,telemetry){let parsedArgs;try{parsedArgs=parseArguments(client.argv.slice(2),{...getFlagsSpecification(searchSubcommand.options),"-j":"--json"})}catch(err){return invalidArguments(client,err instanceof Error?err.message:String(err))}let{flags}=parsedArgs,json=!!(flags["--json"]||client.nonInteractive),columnsOption=flags["--columns"];if(telemetry.trackCliOptionColumns(columnsOption),parsedArgs.args.slice(2).length>0)return trackSpanQueryOptions(flags,telemetry),invalidArguments(client,`Unexpected argument: ${parsedArgs.args.slice(2)[0]}.`);let deployment=getRenamedOption(flags,"--deployment","--deployment-id",{json});if("error"in deployment)return trackSpanQueryOptions(flags,telemetry),invalidArguments(client,deployment.error);let columns=Object.values(spanColumns).filter(column=>column!==spanColumns["span.kind"]&&column!==spanColumns["request.id"]&&column!==spanColumns.environment);if(columnsOption!==void 0){if(json)return invalidArguments(client,"`--columns` cannot be combined with `--json` or `--non-interactive`.");let names=columnsOption.split(",").map(name=>name.trim());if(names.some(name=>!Object.hasOwn(spanColumns,name)))return invalidArguments(client,`Invalid column selection. Available columns: ${Object.keys(spanColumns).join(", ")}.`);if(new Set(names).size!==names.length)return invalidArguments(client,"Columns cannot repeat. List each column once.");columns=names.map(name=>spanColumns[name])}let resolved=flags["--next"]!==void 0?resolveSpanContinuation(client,flags,telemetry):await resolveSpanQuery(client,flags,telemetry);if("exitCode"in resolved)return resolved.exitCode;let query=resolved;deployment.warning&&client.stdout.write(warningLine(deployment.warning));let interactionOverride=explicitInteractionOverride(client.argv),nextPageArgs=token=>["traces search",`--next ${token}`,...json?["--json"]:[],...interactionOverride?[interactionOverride]:[],...flags["--limit"]!==void 0?[`--limit ${flags["--limit"]}`]:[],...columnsOption!==void 0?[`--columns ${quoteArg(columnsOption)}`]:[]].join(" "),pages=fetchEventPages(client,spanEventsRequest(query),query.limit,query.startCursor),spans=[],excludedIntervals=new Map,received=0,resumeCursor=query.startCursor,result;for(json||output_manager_default.spinner("Searching spans\u2026");;){let page;try{page=await pages.next()}catch(err){return reportFailure2(err)}if(page.done){result=page.value;break}let parsed=spansSchema.safeParse(page.value.events);if(!parsed.success)return reportFailure2(new InvalidEventsResponseError);for(let interval of page.value.excludedIntervals)excludedIntervals.set(`${interval.start}/${interval.end}`,interval);json?client.stdout.write(page.value.events.map(event=>recordLine("span",event)).join("")):spans.push(...parsed.data),received+=page.value.events.length,resumeCursor=page.value.nextCursor??void 0}json||output_manager_default.stopSpinner();let intervals=sortIntervals(excludedIntervals.values()),nextToken=result.nextCursor?spanContinuationToken(query,result.nextCursor):null;if(json)return client.stdout.write(summaryLine({recordsReturned:received,timeRange:query.timeRange,pagination:{hasMore:result.hasMore,next:nextToken},excludedIntervals:intervals})),0;return printSpans(client,spans,columns),intervals.length>0&&output_manager_default.warning("Results omit part of this window: some data is unavailable to this query. Use --json to see the excluded intervals."),result.hasMore&&(output_manager_default.log("More spans matched."),nextToken?(output_manager_default.print(`
118
+ `)}async function search(client,telemetry){let parsedArgs;try{parsedArgs=parseArguments(client.argv.slice(2),{...getFlagsSpecification(searchSubcommand.options),"-j":"--json"})}catch(err){return invalidArguments(client,err instanceof Error?err.message:String(err))}let{flags}=parsedArgs,json=!!(flags["--json"]||client.nonInteractive),columnsOption=flags["--columns"];if(telemetry.trackCliOptionColumns(columnsOption),parsedArgs.args.slice(2).length>0)return trackSpanQueryOptions(flags,telemetry),invalidArguments(client,`Unexpected argument: ${parsedArgs.args.slice(2)[0]}.`);let deployment=getRenamedOption(flags,"--deployment","--deployment-id",{json});if("error"in deployment)return trackSpanQueryOptions(flags,telemetry),invalidArguments(client,deployment.error);let trace=getRenamedOption(flags,"--trace","--trace-id",{json});if("error"in trace)return trackSpanQueryOptions(flags,telemetry),invalidArguments(client,trace.error);let span=getRenamedOption(flags,"--span","--span-id",{json});if("error"in span)return trackSpanQueryOptions(flags,telemetry),invalidArguments(client,span.error);let columns=Object.values(spanColumns).filter(column=>column!==spanColumns["span.kind"]&&column!==spanColumns["request.id"]&&column!==spanColumns.environment);if(columnsOption!==void 0){if(json)return invalidArguments(client,"`--columns` cannot be combined with `--json` or `--non-interactive`.");let names=columnsOption.split(",").map(name=>name.trim());if(names.some(name=>!Object.hasOwn(spanColumns,name)))return invalidArguments(client,`Invalid column selection. Available columns: ${Object.keys(spanColumns).join(", ")}.`);if(new Set(names).size!==names.length)return invalidArguments(client,"Columns cannot repeat. List each column once.");columns=names.map(name=>spanColumns[name])}let resolved=flags["--next"]!==void 0?resolveSpanContinuation(client,flags,telemetry):await resolveSpanQuery(client,flags,telemetry);if("exitCode"in resolved)return resolved.exitCode;let query=resolved;for(let{warning}of[deployment,trace,span])warning&&client.stdout.write(warningLine(warning));let interactionOverride=explicitInteractionOverride(client.argv),nextPageArgs=token=>["traces search",`--next ${token}`,...json?["--json"]:[],...interactionOverride?[interactionOverride]:[],...flags["--limit"]!==void 0?[`--limit ${flags["--limit"]}`]:[],...columnsOption!==void 0?[`--columns ${quoteArg(columnsOption)}`]:[]].join(" "),pages=fetchEventPages(client,spanEventsRequest(query),query.limit,query.startCursor),spans=[],excludedIntervals=new Map,received=0,resumeCursor=query.startCursor,result;for(json||output_manager_default.spinner("Searching spans\u2026");;){let page;try{page=await pages.next()}catch(err){return reportFailure2(err)}if(page.done){result=page.value;break}let parsed=spansSchema.safeParse(page.value.events);if(!parsed.success)return reportFailure2(new InvalidEventsResponseError);for(let interval of page.value.excludedIntervals)excludedIntervals.set(`${interval.start}/${interval.end}`,interval);json?client.stdout.write(page.value.events.map(event=>recordLine("span",event)).join("")):spans.push(...parsed.data),received+=page.value.events.length,resumeCursor=page.value.nextCursor??void 0}json||output_manager_default.stopSpinner();let intervals=sortIntervals(excludedIntervals.values()),nextToken=result.nextCursor?spanContinuationToken(query,result.nextCursor):null;if(json)return client.stdout.write(summaryLine({recordsReturned:received,timeRange:query.timeRange,pagination:{hasMore:result.hasMore,next:nextToken},excludedIntervals:intervals})),0;return printSpans(client,spans,columns),intervals.length>0&&output_manager_default.warning("Results omit part of this window: some data is unavailable to this query. Use --json to see the excluded intervals."),result.hasMore&&(output_manager_default.log("More spans matched."),nextToken?(output_manager_default.print(`
119
119
  `),printNextPageCommand(getCommandNamePlain(nextPageArgs(nextToken)))):output_manager_default.print(`Narrow the query or increase --limit to see the rest.
120
120
  `)),0;function reportFailure2(err){json||output_manager_default.stopSpinner(),err instanceof InvalidEventsResponseError&&(err=new Error(INVALID_RESPONSE_MESSAGE)),addSpanQueryIssueDetails(err),query.startCursor&&received===0&&isAPIError(err)&&err.status===400&&(err.serverMessage=`${err.serverMessage}. The cursor may have expired. Run the search again without --next.`,err.message=`${err.serverMessage} (${err.status})`);let retryToken=received>0&&resumeCursor&&!(err instanceof RecordTooLargeError)?spanContinuationToken(query,resumeCursor):null;if(json&&received>0)return writeJsonError(client,{status:"error",reason:tracingErrorReason(err),message:tracingErrorMessage(err),...isAPIError(err)&&err.status===429?getErrorRecovery(err,client):{},data:progressFor(query,received,retryToken,excludedIntervals),...retryToken?{next:[{command:getCommandNamePlain(nextPageArgs(retryToken)),when:"Retry the failed page"}]}:{}},1);!json&&spans.length>0&&printSpans(client,spans,columns);let exitCode=handleTracingApiError(client,err);return received>0&&(output_manager_default.error(`Output is incomplete: ${received} spans were printed before the failure.`),retryToken&&output_manager_default.print(`Retry the failed page:
121
121
  ${getCommandName(nextPageArgs(retryToken))}
122
- `)),exitCode}}function explicitInteractionOverride(argv){let args=argv.slice(2),end=args.indexOf("--");for(let arg of end===-1?args:args.slice(0,end)){if(arg==="--non-interactive=false")return"--non-interactive=false";if(arg==="--non-interactive"||arg.startsWith("--non-interactive="))return"--non-interactive"}}function progressFor(query,received,retryToken,excludedIntervals){return{recordsReturned:received,outputIncomplete:!0,timeRange:query.timeRange,pagination:{hasMore:!0,next:retryToken},excludedIntervals:sortIntervals(excludedIntervals.values())}}var COMMAND_CONFIG3={inspect:getCommandAliases(getSubcommand),create:getCommandAliases(createSubcommand2),search:getCommandAliases(searchSubcommand),config:getCommandAliases(tracesConfigCommand)},SUBCOMMAND_METADATA={[getSubcommand.name]:getSubcommand,[createSubcommand2.name]:createSubcommand2,[searchSubcommand.name]:searchSubcommand};async function traces(client){let telemetry=new TracesTelemetryClient({opts:{store:client.telemetryEventStore}}),parsedArgs,flagsSpecification=getFlagsSpecification(tracesCommand.options);try{parsedArgs=parseArguments(client.argv.slice(2),flagsSpecification,{permissive:!0})}catch(err){return invalidArguments(client,err instanceof Error?err.message:String(err))}let{subcommand,subcommandOriginal,args}=getSubcommand2(parsedArgs.args.slice(1),COMMAND_CONFIG3),needHelp=!!parsedArgs.flags["--help"];if(subcommand===tracesConfigCommand.name)return(await import("./chunks/config-ZFIC7N4D.js")).default(client,{args,needHelp,subcommandOriginal,telemetry});if(needHelp){telemetry.trackCliFlagHelp("traces",subcommandOriginal);let subMetadata=typeof subcommand=="string"?SUBCOMMAND_METADATA[subcommand]:void 0;return output_manager_default.print(help(subMetadata??tracesCommand,{parent:subMetadata?tracesCommand:void 0,columns:client.stderr.columns})),0}if(subcommand===createSubcommand2.name){let args2=client.argv.slice(4);return runCurl(client,{forceTrace:!0,args:args2})}return subcommand===searchSubcommand.name?(telemetry.trackCliSubcommandSearch(subcommandOriginal||subcommand),search(client,telemetry)):(subcommandOriginal==="get"&&warnDeprecatedSubcommand(client,"traces get","traces inspect"),get(client,telemetry))}export{main2 as ci,drains,health,main as pull,traces};
122
+ `)),exitCode}}function explicitInteractionOverride(argv){let args=argv.slice(2),end=args.indexOf("--");for(let arg of end===-1?args:args.slice(0,end)){if(arg==="--non-interactive=false")return"--non-interactive=false";if(arg==="--non-interactive"||arg.startsWith("--non-interactive="))return"--non-interactive"}}function progressFor(query,received,retryToken,excludedIntervals){return{recordsReturned:received,outputIncomplete:!0,timeRange:query.timeRange,pagination:{hasMore:!0,next:retryToken},excludedIntervals:sortIntervals(excludedIntervals.values())}}var COMMAND_CONFIG3={inspect:getCommandAliases(getSubcommand),create:getCommandAliases(createSubcommand2),search:getCommandAliases(searchSubcommand),config:getCommandAliases(tracesConfigCommand)},SUBCOMMAND_METADATA={[getSubcommand.name]:getSubcommand,[createSubcommand2.name]:createSubcommand2,[searchSubcommand.name]:searchSubcommand};async function traces(client){let telemetry=new TracesTelemetryClient({opts:{store:client.telemetryEventStore}}),parsedArgs,flagsSpecification=getFlagsSpecification(tracesCommand.options);try{parsedArgs=parseArguments(client.argv.slice(2),flagsSpecification,{permissive:!0})}catch(err){return invalidArguments(client,err instanceof Error?err.message:String(err))}let{subcommand,subcommandOriginal,args}=getSubcommand2(parsedArgs.args.slice(1),COMMAND_CONFIG3),needHelp=!!parsedArgs.flags["--help"];if(subcommand===tracesConfigCommand.name)return(await import("./chunks/config-RMOHN5YT.js")).default(client,{args,needHelp,subcommandOriginal,telemetry});if(needHelp){telemetry.trackCliFlagHelp("traces",subcommandOriginal);let subMetadata=typeof subcommand=="string"?SUBCOMMAND_METADATA[subcommand]:void 0;return output_manager_default.print(help(subMetadata??tracesCommand,{parent:subMetadata?tracesCommand:void 0,columns:client.stderr.columns})),0}if(subcommand===createSubcommand2.name){let args2=client.argv.slice(4);return runCurl(client,{forceTrace:!0,args:args2})}return subcommand===searchSubcommand.name?(telemetry.trackCliSubcommandSearch(subcommandOriginal||subcommand),search(client,telemetry)):(subcommandOriginal==="get"&&warnDeprecatedSubcommand(client,"traces get","traces inspect"),get(client,telemetry))}export{main2 as ci,drains,health,main as pull,traces};