@vercel/cli-support 66.0.0 → 66.1.0-snapshot-2d6d3c32d821

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 (70) hide show
  1. package/dist/chunks/add-6NUHCAMT.js +1 -1
  2. package/dist/chunks/add-GP25D55V.js +1 -1
  3. package/dist/chunks/{add-4BOS256T.js → add-KYJZONXY.js} +1 -1
  4. package/dist/chunks/{alerts-7YJBYDMI.js → alerts-MQ6Y3UFA.js} +1 -1
  5. package/dist/chunks/build-4VEEWVS5.js +1 -1
  6. package/dist/chunks/{chunk-PVLBQHWY.js → chunk-5PQVVJMD.js} +1 -1
  7. package/dist/chunks/chunk-MGZ3Z4PF.js +8 -0
  8. package/dist/chunks/chunk-PQSW6EAL.js +7 -0
  9. package/dist/chunks/{chunk-AOWC37HK.js → chunk-REKWV3XW.js} +1 -1
  10. package/dist/chunks/{chunk-ZJX3QG2F.js → chunk-TR4ENDFQ.js} +1 -1
  11. package/dist/chunks/chunk-UFCL2VBD.js +7 -0
  12. package/dist/chunks/chunk-WHL4PWDW.js +14 -0
  13. package/dist/chunks/{chunk-GQU7IE6F.js → chunk-XI7556MQ.js} +3 -3
  14. package/dist/chunks/{chunk-666NINFO.js → chunk-ZL3UMJMJ.js} +1 -1
  15. package/dist/chunks/clear-PLSWE5JH.js +1 -1
  16. package/dist/chunks/cli-embedded-KDIRH75G.js +81 -0
  17. package/dist/chunks/{config-KDYQYFS6.js → config-3LXTEKBJ.js} +1 -1
  18. package/dist/chunks/config-ORDPO5PD.js +1 -1
  19. package/dist/chunks/engine-I887QHnP-RUEEKCKH.js +18 -0
  20. package/dist/chunks/{image-5NJDI6SK.js → image-N5UWUO57.js} +1 -1
  21. package/dist/chunks/{inspect-MOJMM7QE.js → inspect-24Z5WVGT.js} +1 -1
  22. package/dist/chunks/inspect-33TQGRQI.js +1 -1
  23. package/dist/chunks/{inspect-QFX7W3LO.js → inspect-3TBVD5FW.js} +1 -1
  24. package/dist/chunks/inspect-GUVBQAGQ.js +1 -1
  25. package/dist/chunks/inspect-IVCRI5DD.js +1 -1
  26. package/dist/chunks/{list-ZAWJR23F.js → list-33O4PH2I.js} +1 -1
  27. package/dist/chunks/{list-3D4YRKNP.js → list-3ESADOVD.js} +1 -1
  28. package/dist/chunks/{list-VDUPJ44X.js → list-EZZOK7IM.js} +1 -1
  29. package/dist/chunks/login-2P4WOXB7.js +1 -1
  30. package/dist/chunks/ls-3VWIGXMW.js +1 -1
  31. package/dist/chunks/ls-76ADTPOK.js +1 -1
  32. package/dist/chunks/{ls-34MKKAM5.js → ls-H3VWUODQ.js} +1 -1
  33. package/dist/chunks/ls-KWYUFBK6.js +1 -1
  34. package/dist/chunks/ls-XBDD2PTU.js +1 -1
  35. package/dist/chunks/{notifications-AH37Q6MV.js → notifications-7R3WPEAA.js} +1 -1
  36. package/dist/chunks/{permissions-M2YMMWQ2.js → permissions-KNTBYUW6.js} +1 -1
  37. package/dist/chunks/push-PWMJ4P2K.js +1 -1
  38. package/dist/chunks/query-JNPBVPKH.js +1 -1
  39. package/dist/chunks/{raw-query-J5YDYUOK.js → raw-query-K2TZPPTU.js} +1 -1
  40. package/dist/chunks/rm-BYAPI3BU.js +1 -1
  41. package/dist/chunks/rm-CE52BWMX.js +1 -1
  42. package/dist/chunks/{rm-5K6VJI5E.js → rm-EFOCCDJP.js} +1 -1
  43. package/dist/chunks/rm-F2RNFFYF.js +1 -1
  44. package/dist/chunks/rule-inspect-BETOJVBA.js +1 -1
  45. package/dist/chunks/serving-Bulte-NO-VPBE6F4V.js +8 -0
  46. package/dist/chunks/update-5TDDKIDK.js +1 -1
  47. package/dist/commands/deploy/index.js +1 -1
  48. package/dist/commands/env/index.js +1 -1
  49. package/dist/commands/link/index.js +1 -1
  50. package/dist/commands/project/index.js +1 -1
  51. package/dist/commands-account.js +2 -2
  52. package/dist/commands-ai.js +74 -58
  53. package/dist/commands-blob.js +1 -1
  54. package/dist/commands-core.js +6 -6
  55. package/dist/commands-deployments.js +1 -1
  56. package/dist/commands-flags.js +1 -1
  57. package/dist/commands-integrations.js +1 -1
  58. package/dist/commands-observability.js +2 -2
  59. package/dist/commands-routing.js +1 -1
  60. package/dist/index.js +1 -1
  61. package/dist/package.json +3 -3
  62. package/dist/version.mjs +1 -1
  63. package/package.json +12 -12
  64. package/dist/chunks/chunk-BPQUJWX5.js +0 -11
  65. package/dist/chunks/chunk-MRCM5VF5.js +0 -8
  66. package/dist/chunks/chunk-SKYIWHB5.js +0 -7
  67. package/dist/chunks/chunk-TK7K6GCG.js +0 -7
  68. package/dist/chunks/cli-embedded-6SKYFUXJ.js +0 -65
  69. package/dist/chunks/engine-DkdkXQEy-VKQPUSSO.js +0 -17
  70. package/dist/chunks/serving-DKny38LK-WG5QDDEJ.js +0 -8
@@ -4,4 +4,4 @@ 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{getSubcommand}from"./chunk-ETV3C2CV.js";import{getCommandAliases}from"./chunk-GQU7IE6F.js";import"./chunk-QOLGACFD.js";import{tracesCommand}from"./chunk-DDPH26ZO.js";import{lsSubcommand,rmSubcommand,setSubcommand,tracesConfigCommand}from"./chunk-PIDEH4SJ.js";import"./chunk-IIK6GUVI.js";import"./chunk-C35SG42R.js";import"./chunk-2GBU6ULJ.js";import"./chunk-EJLYDHT7.js";import"./chunk-DOBV3XLO.js";import"./chunk-TK7K6GCG.js";import"./chunk-BMIYC2MH.js";import"./chunk-6CJFPT4F.js";import"./chunk-ZZD5W5KT.js";import"./chunk-VHSAI6FS.js";import"./chunk-F7L5SXJM.js";import"./chunk-GLCSWIB4.js";import"./chunk-XECELSF5.js";import"./chunk-6FYPSSL4.js";import"./chunk-UQZZX2J7.js";import"./chunk-UDZJCD5W.js";import"./chunk-5ZCSFPWG.js";import"./chunk-PY4WWD6Z.js";import"./chunk-XDYVJWGX.js";import"./chunk-JALVF3C2.js";import"./chunk-BPIGFKNN.js";import"./chunk-AB4WXRCO.js";import"./chunk-SYJXONEV.js";import"./chunk-KK5C7HVP.js";import{help}from"./chunk-7KCRYDGK.js";import"./chunk-GLIQ4KNY.js";import{TelemetryClient}from"./chunk-KDCODXVL.js";import"./chunk-NWGBDBZI.js";import"./chunk-DTUEHPME.js";import{warnDeprecatedSubcommand}from"./chunk-6GKP6VUF.js";import"./chunk-4NTBYNFR.js";import"./chunk-4SAVH3H7.js";import"./chunk-B4KA3ZH2.js";import"./chunk-BOJDM3O7.js";import{output_manager_default}from"./chunk-AP6DZGTK.js";import"./chunk-BLUPZPAS.js";import"./chunk-5MDNVAE6.js";import"./chunk-MCYG7CCE.js";import"./chunk-YHPPP3SF.js";import"./chunk-24SIHFEW.js";import"./chunk-CFJBDBYH.js";import"./chunk-2BKALEOP.js";import"./chunk-NB2WLB3J.js";import"./chunk-ISWW3DKF.js";import"./chunk-BRQUZ5NC.js";import"./chunk-BULSRTQE.js";import"./chunk-BZENIQ7N.js";var TracesConfigTelemetryClient=class extends TelemetryClient{trackCliSubcommandLs(actual){this.trackCliSubcommand({subcommand:"ls",value:actual})}trackCliSubcommandSet(actual){this.trackCliSubcommand({subcommand:"set",value:actual})}trackCliSubcommandRemove(actual){this.trackCliSubcommand({subcommand:"remove",value:actual})}};var COMMAND_CONFIG={ls:getCommandAliases(lsSubcommand),set:getCommandAliases(setSubcommand),remove:getCommandAliases(rmSubcommand)},SUBCOMMAND_METADATA={ls:lsSubcommand,set:setSubcommand,remove:rmSubcommand};async function config(client,{args,needHelp,subcommandOriginal,telemetry}){let{subcommand:action,subcommandOriginal:actionOriginal}=getSubcommand(args,COMMAND_CONFIG),actionMetadata=typeof action=="string"?SUBCOMMAND_METADATA[action]:void 0;function printHelp(command){return output_manager_default.print(help(command,{stream:client.stderr,parent:tracesCommand,columns:client.stderr.columns})),needHelp?0:2}if(needHelp)return telemetry.trackCliFlagHelp("traces",subcommandOriginal),printHelp(actionMetadata||tracesConfigCommand);telemetry.trackCliSubcommandConfig(subcommandOriginal);let configTelemetry=new TracesConfigTelemetryClient({opts:{store:client.telemetryEventStore}});switch(action){case"ls":return configTelemetry.trackCliSubcommandLs(actionOriginal),(await import("./ls-PCSUAESE.js")).default(client);case"set":return configTelemetry.trackCliSubcommandSet(actionOriginal),(await import("./set-6F6G2E7V.js")).default(client);case"remove":return configTelemetry.trackCliSubcommandRemove(actionOriginal),actionOriginal==="delete"&&warnDeprecatedSubcommand(client,"traces config delete","traces config remove"),(await import("./rm-E52J2HHP.js")).default(client);default:return printHelp(tracesConfigCommand)}}export{config as default};
7
+ import{getSubcommand}from"./chunk-ETV3C2CV.js";import{getCommandAliases}from"./chunk-XI7556MQ.js";import"./chunk-QOLGACFD.js";import{tracesCommand}from"./chunk-DDPH26ZO.js";import{lsSubcommand,rmSubcommand,setSubcommand,tracesConfigCommand}from"./chunk-PIDEH4SJ.js";import"./chunk-IIK6GUVI.js";import"./chunk-C35SG42R.js";import"./chunk-2GBU6ULJ.js";import"./chunk-EJLYDHT7.js";import"./chunk-DOBV3XLO.js";import"./chunk-UFCL2VBD.js";import"./chunk-BMIYC2MH.js";import"./chunk-6CJFPT4F.js";import"./chunk-ZZD5W5KT.js";import"./chunk-VHSAI6FS.js";import"./chunk-F7L5SXJM.js";import"./chunk-GLCSWIB4.js";import"./chunk-XECELSF5.js";import"./chunk-6FYPSSL4.js";import"./chunk-UQZZX2J7.js";import"./chunk-UDZJCD5W.js";import"./chunk-5ZCSFPWG.js";import"./chunk-PY4WWD6Z.js";import"./chunk-XDYVJWGX.js";import"./chunk-JALVF3C2.js";import"./chunk-BPIGFKNN.js";import"./chunk-AB4WXRCO.js";import"./chunk-SYJXONEV.js";import"./chunk-KK5C7HVP.js";import{help}from"./chunk-7KCRYDGK.js";import"./chunk-GLIQ4KNY.js";import{TelemetryClient}from"./chunk-KDCODXVL.js";import"./chunk-NWGBDBZI.js";import"./chunk-DTUEHPME.js";import{warnDeprecatedSubcommand}from"./chunk-6GKP6VUF.js";import"./chunk-4NTBYNFR.js";import"./chunk-4SAVH3H7.js";import"./chunk-B4KA3ZH2.js";import"./chunk-BOJDM3O7.js";import{output_manager_default}from"./chunk-AP6DZGTK.js";import"./chunk-BLUPZPAS.js";import"./chunk-5MDNVAE6.js";import"./chunk-MCYG7CCE.js";import"./chunk-YHPPP3SF.js";import"./chunk-24SIHFEW.js";import"./chunk-CFJBDBYH.js";import"./chunk-2BKALEOP.js";import"./chunk-NB2WLB3J.js";import"./chunk-ISWW3DKF.js";import"./chunk-BRQUZ5NC.js";import"./chunk-BULSRTQE.js";import"./chunk-BZENIQ7N.js";var TracesConfigTelemetryClient=class extends TelemetryClient{trackCliSubcommandLs(actual){this.trackCliSubcommand({subcommand:"ls",value:actual})}trackCliSubcommandSet(actual){this.trackCliSubcommand({subcommand:"set",value:actual})}trackCliSubcommandRemove(actual){this.trackCliSubcommand({subcommand:"remove",value:actual})}};var COMMAND_CONFIG={ls:getCommandAliases(lsSubcommand),set:getCommandAliases(setSubcommand),remove:getCommandAliases(rmSubcommand)},SUBCOMMAND_METADATA={ls:lsSubcommand,set:setSubcommand,remove:rmSubcommand};async function config(client,{args,needHelp,subcommandOriginal,telemetry}){let{subcommand:action,subcommandOriginal:actionOriginal}=getSubcommand(args,COMMAND_CONFIG),actionMetadata=typeof action=="string"?SUBCOMMAND_METADATA[action]:void 0;function printHelp(command){return output_manager_default.print(help(command,{stream:client.stderr,parent:tracesCommand,columns:client.stderr.columns})),needHelp?0:2}if(needHelp)return telemetry.trackCliFlagHelp("traces",subcommandOriginal),printHelp(actionMetadata||tracesConfigCommand);telemetry.trackCliSubcommandConfig(subcommandOriginal);let configTelemetry=new TracesConfigTelemetryClient({opts:{store:client.telemetryEventStore}});switch(action){case"ls":return configTelemetry.trackCliSubcommandLs(actionOriginal),(await import("./ls-PCSUAESE.js")).default(client);case"set":return configTelemetry.trackCliSubcommandSet(actionOriginal),(await import("./set-6F6G2E7V.js")).default(client);case"remove":return configTelemetry.trackCliSubcommandRemove(actionOriginal),actionOriginal==="delete"&&warnDeprecatedSubcommand(client,"traces config delete","traces config remove"),(await import("./rm-E52J2HHP.js")).default(client);default:return printHelp(tracesConfigCommand)}}export{config as default};
@@ -4,5 +4,5 @@ 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{repositoryPath}from"./chunk-DFVNL5ML.js";import{emitVcrArgParseError,handleVcrApiError,requireVcrRepository,resolveVcrScope,validateVcrJsonOutput}from"./chunk-6BN7Y3GF.js";import{outputError}from"./chunk-ZJNDLFZ7.js";import"./chunk-D3M2JG5C.js";import"./chunk-M32HBBPK.js";import{readOnOffOption,rewriteLegacyOnOffValues}from"./chunk-CFQPIYKY.js";import"./chunk-GD7AV7BO.js";import{configSubcommand}from"./chunk-BMIYC2MH.js";import"./chunk-6CJFPT4F.js";import"./chunk-ZZD5W5KT.js";import"./chunk-VHSAI6FS.js";import{printError}from"./chunk-CY5KJ42N.js";import"./chunk-CT77BGSW.js";import{AGENT_REASON,buildCommandWithGlobalFlags,outputAgentError}from"./chunk-PNWRO3XW.js";import"./chunk-DTUEHPME.js";import"./chunk-EUU3FHCX.js";import"./chunk-M7FED5YP.js";import"./chunk-4HR3I3ML.js";import"./chunk-LOA7SZWH.js";import"./chunk-LUX4PBJL.js";import"./chunk-MTZYPCZ7.js";import"./chunk-OPORM35X.js";import"./chunk-D6REP5QQ.js";import"./chunk-FBYA6LLM.js";import"./chunk-MY4MONOH.js";import"./chunk-7HLAWGY2.js";import"./chunk-MXTC4ZAQ.js";import{parseArguments}from"./chunk-LYL26S3N.js";import"./chunk-2VBFQZ72.js";import"./chunk-6GKP6VUF.js";import"./chunk-4NTBYNFR.js";import"./chunk-4SAVH3H7.js";import{isAPIError}from"./chunk-GOI2VVI7.js";import"./chunk-B4KA3ZH2.js";import"./chunk-BOJDM3O7.js";import{output_manager_default}from"./chunk-AP6DZGTK.js";import"./chunk-BLUPZPAS.js";import"./chunk-AW33SRYY.js";import"./chunk-5MDNVAE6.js";import"./chunk-OCR5CRTH.js";import"./chunk-7EJQLVWX.js";import"./chunk-SCV7XEEO.js";import"./chunk-MCYG7CCE.js";import"./chunk-YHPPP3SF.js";import{getFlagsSpecification}from"./chunk-CFJBDBYH.js";import"./chunk-2BKALEOP.js";import"./chunk-NB2WLB3J.js";import"./chunk-ISWW3DKF.js";import"./chunk-BRQUZ5NC.js";import"./chunk-BULSRTQE.js";import"./chunk-BZENIQ7N.js";var USAGE="vcr update <repository> --public";async function config(client,argv,telemetry){let rewritten=rewriteLegacyOnOffValues(argv,configSubcommand.options,client),parsedArgs;try{parsedArgs=parseArguments("error"in rewritten?argv:rewritten.args,getFlagsSpecification(configSubcommand.options))}catch(err){return emitVcrArgParseError(client,err,USAGE),printError(err),2}let fr=validateVcrJsonOutput(client,parsedArgs.flags);if(typeof fr=="number")return fr;if("error"in rewritten)return outputAgentError(client,{status:"error",reason:AGENT_REASON.INVALID_ARGUMENTS,message:rewritten.error},2),outputError(client,fr.jsonOutput,"INVALID_ARGUMENTS",rewritten.error);let repository=parsedArgs.args[0],project=parsedArgs.flags["--project"],visibility=readOnOffOption(client,parsedArgs.flags,{on:"--public",off:"--no-public"});if("error"in visibility){let err=new Error(visibility.error);return emitVcrArgParseError(client,err,USAGE),outputError(client,fr.jsonOutput,"INVALID_ARGUMENTS",visibility.error)}let desiredPublic=visibility.value;telemetry.trackCliOptionProject(project),telemetry.trackCliOptionFormat(parsedArgs.flags["--format"]),telemetry.trackCliOptionPublic(rewritten.legacy.get("--public")),rewritten.legacy.has("--public")||(telemetry.trackCliFlagPublic(parsedArgs.flags["--public"]),telemetry.trackCliFlagNoPublic(parsedArgs.flags["--no-public"]));let missingRepository=requireVcrRepository(client,repository,fr.jsonOutput,USAGE);if(typeof missingRepository=="number")return missingRepository;if(parsedArgs.args.length>1){let message="`vcr update` takes one repository. Pass --public or --no-public without a value.";return outputAgentError(client,{status:"error",reason:AGENT_REASON.INVALID_ARGUMENTS,message,next:[{command:buildCommandWithGlobalFlags(client.argv,USAGE),when:"Re-run with one repository"}]},2),outputError(client,fr.jsonOutput,"INVALID_ARGUMENTS",message)}if(desiredPublic===void 0){let message="Missing a setting to change. Pass --public to make the repository public, or --no-public to make it private.";return outputAgentError(client,{status:"error",reason:AGENT_REASON.MISSING_ARGUMENTS,message,next:[{command:buildCommandWithGlobalFlags(client.argv,USAGE),when:"Re-run with --public or --no-public"}]},2),outputError(client,fr.jsonOutput,"MISSING_ARGUMENTS",message)}let scope=await resolveVcrScope(client,{project,jsonOutput:fr.jsonOutput});if(typeof scope=="number")return scope;let path=repositoryPath(scope,repository);output_manager_default.spinner("Updating repository...");try{let updated=await client.fetch(path,{method:"PATCH",body:{public:desiredPublic}});if(fr.jsonOutput)client.stdout.write(`${JSON.stringify(updated,null,2)}
7
+ import{repositoryPath}from"./chunk-DFVNL5ML.js";import{emitVcrArgParseError,handleVcrApiError,requireVcrRepository,resolveVcrScope,validateVcrJsonOutput}from"./chunk-6BN7Y3GF.js";import{outputError}from"./chunk-ZJNDLFZ7.js";import"./chunk-M32HBBPK.js";import"./chunk-D3M2JG5C.js";import{readOnOffOption,rewriteLegacyOnOffValues}from"./chunk-CFQPIYKY.js";import"./chunk-GD7AV7BO.js";import{configSubcommand}from"./chunk-BMIYC2MH.js";import"./chunk-6CJFPT4F.js";import"./chunk-ZZD5W5KT.js";import"./chunk-VHSAI6FS.js";import{printError}from"./chunk-CY5KJ42N.js";import"./chunk-CT77BGSW.js";import{AGENT_REASON,buildCommandWithGlobalFlags,outputAgentError}from"./chunk-PNWRO3XW.js";import"./chunk-DTUEHPME.js";import"./chunk-EUU3FHCX.js";import"./chunk-M7FED5YP.js";import"./chunk-4HR3I3ML.js";import"./chunk-LOA7SZWH.js";import"./chunk-LUX4PBJL.js";import"./chunk-MTZYPCZ7.js";import"./chunk-OPORM35X.js";import"./chunk-D6REP5QQ.js";import"./chunk-FBYA6LLM.js";import"./chunk-MY4MONOH.js";import"./chunk-7HLAWGY2.js";import"./chunk-MXTC4ZAQ.js";import{parseArguments}from"./chunk-LYL26S3N.js";import"./chunk-2VBFQZ72.js";import"./chunk-6GKP6VUF.js";import"./chunk-4NTBYNFR.js";import"./chunk-4SAVH3H7.js";import{isAPIError}from"./chunk-GOI2VVI7.js";import"./chunk-B4KA3ZH2.js";import"./chunk-BOJDM3O7.js";import{output_manager_default}from"./chunk-AP6DZGTK.js";import"./chunk-BLUPZPAS.js";import"./chunk-AW33SRYY.js";import"./chunk-5MDNVAE6.js";import"./chunk-OCR5CRTH.js";import"./chunk-7EJQLVWX.js";import"./chunk-SCV7XEEO.js";import"./chunk-MCYG7CCE.js";import"./chunk-YHPPP3SF.js";import{getFlagsSpecification}from"./chunk-CFJBDBYH.js";import"./chunk-2BKALEOP.js";import"./chunk-NB2WLB3J.js";import"./chunk-ISWW3DKF.js";import"./chunk-BRQUZ5NC.js";import"./chunk-BULSRTQE.js";import"./chunk-BZENIQ7N.js";var USAGE="vcr update <repository> --public";async function config(client,argv,telemetry){let rewritten=rewriteLegacyOnOffValues(argv,configSubcommand.options,client),parsedArgs;try{parsedArgs=parseArguments("error"in rewritten?argv:rewritten.args,getFlagsSpecification(configSubcommand.options))}catch(err){return emitVcrArgParseError(client,err,USAGE),printError(err),2}let fr=validateVcrJsonOutput(client,parsedArgs.flags);if(typeof fr=="number")return fr;if("error"in rewritten)return outputAgentError(client,{status:"error",reason:AGENT_REASON.INVALID_ARGUMENTS,message:rewritten.error},2),outputError(client,fr.jsonOutput,"INVALID_ARGUMENTS",rewritten.error);let repository=parsedArgs.args[0],project=parsedArgs.flags["--project"],visibility=readOnOffOption(client,parsedArgs.flags,{on:"--public",off:"--no-public"});if("error"in visibility){let err=new Error(visibility.error);return emitVcrArgParseError(client,err,USAGE),outputError(client,fr.jsonOutput,"INVALID_ARGUMENTS",visibility.error)}let desiredPublic=visibility.value;telemetry.trackCliOptionProject(project),telemetry.trackCliOptionFormat(parsedArgs.flags["--format"]),telemetry.trackCliOptionPublic(rewritten.legacy.get("--public")),rewritten.legacy.has("--public")||(telemetry.trackCliFlagPublic(parsedArgs.flags["--public"]),telemetry.trackCliFlagNoPublic(parsedArgs.flags["--no-public"]));let missingRepository=requireVcrRepository(client,repository,fr.jsonOutput,USAGE);if(typeof missingRepository=="number")return missingRepository;if(parsedArgs.args.length>1){let message="`vcr update` takes one repository. Pass --public or --no-public without a value.";return outputAgentError(client,{status:"error",reason:AGENT_REASON.INVALID_ARGUMENTS,message,next:[{command:buildCommandWithGlobalFlags(client.argv,USAGE),when:"Re-run with one repository"}]},2),outputError(client,fr.jsonOutput,"INVALID_ARGUMENTS",message)}if(desiredPublic===void 0){let message="Missing a setting to change. Pass --public to make the repository public, or --no-public to make it private.";return outputAgentError(client,{status:"error",reason:AGENT_REASON.MISSING_ARGUMENTS,message,next:[{command:buildCommandWithGlobalFlags(client.argv,USAGE),when:"Re-run with --public or --no-public"}]},2),outputError(client,fr.jsonOutput,"MISSING_ARGUMENTS",message)}let scope=await resolveVcrScope(client,{project,jsonOutput:fr.jsonOutput});if(typeof scope=="number")return scope;let path=repositoryPath(scope,repository);output_manager_default.spinner("Updating repository...");try{let updated=await client.fetch(path,{method:"PATCH",body:{public:desiredPublic}});if(fr.jsonOutput)client.stdout.write(`${JSON.stringify(updated,null,2)}
8
8
  `);else{let isPublic=updated.repository?.public??desiredPublic;output_manager_default.success(`Repository ${updated.repository?.name??repository} is now ${isPublic?"public":"private"}`)}return 0}catch(err){if(isAPIError(err))return handleVcrApiError(client,err,fr.jsonOutput,{retry:{command:buildCommandWithGlobalFlags(client.argv,"vcr ls"),when:"List repositories to confirm the name or id"}});throw err}finally{output_manager_default.stopSpinner()}}export{config as default};
@@ -0,0 +1,18 @@
1
+ import { createRequire as __createRequire } from 'node:module';
2
+ import { fileURLToPath as __fileURLToPath } from 'node:url';
3
+ import { dirname as __dirname_ } from 'node:path';
4
+ const require = __createRequire(import.meta.url);
5
+ const __filename = __fileURLToPath(import.meta.url);
6
+ const __dirname = __dirname_(__filename);
7
+ import{DroppedError,ExternalEvent,ExternalLocation,actorParts,afterRetry,byVercelBot,channelOf,derivedId,displayText,extractMentions,isEmail,isThreadTarget,platformProfile,replaceMentions,shownName,vercelDeployments,viaText,waitUntil}from"./chunk-WHL4PWDW.js";import{ChannelPath,HttpError,LabelKey,MESSAGE_TEXT_MAX,NewLabels,badRequest,canonicalEmoji,fileSize,notFound,toStorable,typeOf}from"./chunk-MGZ3Z4PF.js";import{external_exports}from"./chunk-2AMO2VMV.js";import"./chunk-BZENIQ7N.js";var ROUTES=Symbol.for("board.syncRoutes");var ResolvedTarget=external_exports.object({target:external_exports.string().min(1),channel:external_exports.string().min(1),kind:external_exports.enum(["channel","thread"])}).strict(),UnreadableError=class extends Error{code;constructor(code,message){super(message),this.code=code}},channelMissing=error=>error instanceof UnreadableError&&error.code==="channel_not_found",ReceivedEvent=external_exports.object({event:ExternalEvent,raw:external_exports.unknown(),dedupe:external_exports.string().min(1)}),routed=new WeakMap,routesFor=provider=>routed.get(provider);var opensBlock=text=>/^(```|~~~|[-*+] |\d+[.)] |#{1,6} |>|\|)/.test(text),EventBase=external_exports.object({id:external_exports.string().min(1),platform:external_exports.string().min(1),key:external_exports.string().min(1),...ExternalLocation.shape,raw:external_exports.unknown()});var SyncOverrides=external_exports.object({root:external_exports.custom(value=>typeof value=="function").optional(),text:external_exports.string().optional(),labels:NewLabels.optional(),unset:external_exports.array(LabelKey).optional(),noSync:external_exports.boolean().optional()}).strict();function immutable(value){if(value&&typeof value=="object"){for(let item of Object.values(value))immutable(item);Object.freeze(value)}return value}var clampText=(raw,files=!1)=>{let text=toStorable(raw),trimmed=text.trim()===""?files?"":"(no text)":text;return trimmed.length>1e4?`${trimmed.slice(0,MESSAGE_TEXT_MAX-1).toWellFormed()}\u2026`:trimmed},fileNote=(file,why,name=file.name??"a file")=>`\u{1F4CE} ${name}${file.size!==void 0?` (${fileSize(file.size)})`:""} didn't come over: ${why}`,keepsNoFiles=error=>error instanceof HttpError&&error.code==="no_files",fileLink=(file,why)=>{let name=file.name??"a file";if(!file.url||!/^https?:\/\//.test(file.url))return fileNote(file,why);let label=name.replace(/[[\]\\]/g,char=>`\\${char}`),url=file.url.replace(/[ ()]/g,char=>`%${char.charCodeAt(0).toString(16).toUpperCase()}`);return fileNote(file,why,`[${label}](${url})`)},withNotes=(text,notes)=>notes.length?`${text.trim()?`${text}
8
+
9
+ `:""}${notes.join(`
10
+ `)}`:text,notesIn=text=>text.split(`
11
+ `).filter(line=>/^📎 .* didn't come over: /u.test(line)),linkKey=link=>JSON.stringify([link.url,link.message,link.snapshot,link.unavailable]),sameLinks=(a,b)=>a.length===b.length&&a.every((link,i)=>linkKey(link)===linkKey(b[i])),FILE_ATTEMPTS=3,EMAIL_TTL_MS=3e5,EMAIL_LOOKUPS_PER_MESSAGE_MAX=10,GATE_WAIT_MS=2e3,DELIVERY_ATTEMPTS=5,PULL_MS=24e4,NEVER=new AbortController().signal,jsonSafe=value=>{try{return JSON.parse(JSON.stringify(value??null))}catch{return null}},storableJson=value=>typeof value=="string"?toStorable(value):Array.isArray(value)?value.map(storableJson):value!==null&&typeof value=="object"?Object.fromEntries(Object.entries(value).map(([key,item])=>[toStorable(key),storableJson(item)])):value,describe=error=>{let code=error?.data?.error,text=typeof code=="string"?code:error instanceof Error?error.message:String(error);return toStorable(text.slice(0,500))||"unknown error"},missing=error=>error instanceof HttpError&&error.status===404;function keyedId(key,platform,id){return id.startsWith(`${key}:`)?id:`${key}:${id.startsWith(`${platform}:`)?id.slice(platform.length+1):id}`}function keyedText(key,platform,text){return key===platform?text:replaceMentions(text,token=>token.kind==="actor"&&token.actor.startsWith(`${platform}:`)?`@[${keyedId(key,platform,token.actor)}]`:null)}function keyedEvent(key,platform,event){if(!("author"in event))return event;let author={...event.author,id:keyedId(key,platform,event.author.id)};return event.kind!=="message"&&event.kind!=="edited"||key===platform?{...event,author}:{...event,author,...event.mentioned?{mentioned:event.mentioned.map(user=>({...user,id:keyedId(key,platform,user.id)}))}:{},text:keyedText(key,platform,event.text)}}function createSyncEngine(entries){let bound=null,host=()=>{if(!bound)throw new Error("sync used before board() bound it");return bound},me={self:"sync",origin:{via:{kind:"engine"}}};function call(method,input,signal=NEVER,caller=me){let backend=host().backend;return backend[method].call(backend,caller,input,signal)}let platformOf=key=>{let platform=entries[key];if(!platform)throw badRequest(`no sync entry named ${key}`);return platform},keyOf=target=>target.slice(0,target.indexOf(":")),here=key=>host().syncedHere(key),ours=async target=>entries[keyOf(target)]!==void 0&&await here(keyOf(target)),native=external=>external.slice(external.indexOf(":")+1);async function syncOf(thread){try{return await call("syncThread",{thread})}catch(error){if(missing(error))return null;throw error}}async function threadOf(root){try{let{message,replies}=await call("message",{id:root});return[message,...replies]}catch(error){if(missing(error))return[];throw error}}async function messageOf(id){return(await threadOf(id)).find(message=>message.id===id)??null}async function copiesOf(ids){return ids.length===0?{}:(await call("syncCopies",{message:[...new Set(ids)]})).copies}let find=(query,signal)=>call("syncFind",query,signal),principal=null;function principalNow(){if(principal)return principal;let asked=call("me",{}).then(me2=>me2.principal);return principal=asked,asked.catch(()=>{principal===asked&&(principal=null)}),asked}async function actorsNow(){let[{actors},me2]=await Promise.all([call("actors",{}),principalNow().catch(()=>null)]),state={byId:{},principal:me2};for(let actor of actors)state.byId[actor.id]={id:actor.id,kind:actor.kind,handle:actor.handle,name:actor.name,avatar:actor.avatar,...actor.via?{via:{...actor.via}}:{},...actor.platform?{platform:actor.platform}:{},...actor.verified?{verified:!0}:{}};return state}let RETRY_MS=6e4,resolutions=new Map;function resolve(key,name){let at=`${key}:${name}`,cached=resolutions.get(at);if(cached&&(!cached.failed||Date.now()-cached.at<RETRY_MS))return cached.id;let entry={id:platformOf(key).resolveChannel(name),failed:!1,at:Date.now()};return entry.id.catch(error=>{entry.failed=!0;let missing2=channelMissing(error);!missing2&&resolutions.get(at)===entry&&resolutions.delete(at),console.warn(`[board] sync ${key}: ${missing2?"skipping":"couldn't resolve"} ${name}: ${error.message}`)}),resolutions.set(at,entry),entry.id}function channelIn(key,target){if(!isThreadTarget(target))return native(target);try{let channel=platformOf(key).inboxChannel(key,target);return channel===null?null:native(channel)}catch{return null}}let emails=new Map;function emailMention(key,email){let at=`${key}${email.toLowerCase()}`,cached=emails.get(at);if(cached&&Date.now()-cached.at<EMAIL_TTL_MS)return cached.mention;emails.size>=1e3&&emails.clear();let platform=platformOf(key),mention=platform.findByEmail(email).then(user=>user?platform.mention({id:user.id,kind:"external",handle:user.handle,name:user.name,avatar:user.avatar}):null,()=>null);return emails.set(at,{at:Date.now(),mention}),mention}async function normalizeTarget(target){let at=target.indexOf(":");if(at<=0)throw badRequest(`sync targets look like <key>:<channel or thread>, got: ${target}`);let key=target.slice(0,at),platform=platformOf(key);try{let resolved=ResolvedTarget.parse(await platform.resolveTarget(target.slice(at+1)));if(resolved.kind==="channel"&&!platform.canStartThreads)throw new Error(`${platform.platform} cannot start threads; use an existing thread`);return{target:`${key}:${resolved.target}`,kind:resolved.kind}}catch(error){throw badRequest(`can't sync to ${target}: ${error.message}`)}}async function intake(key,received){let{event,raw,dedupe}=ReceivedEvent.parse(storableJson({...received,raw:jsonSafe(received.raw)}));for(let location of[event.channel,event.thread,"subthread"in event?event.subthread:null])if(location!==null&&!location.startsWith(`${key}:`))throw badRequest(`provider locations must belong to sync entry ${key}`);let routes=routesFor(platformOf(key)),kept=routes&&await routes(native(event.channel),name=>resolve(key,name)).catch(async error=>{if(await syncsThread(event.thread))return!0;throw error});routes&&!kept&&!await syncsThread(event.thread)||await call("inboxPush",{key,events:[{id:dedupe,event,raw}]})}async function syncsThread(thread){try{return(await find({thread},AbortSignal.timeout(GATE_WAIT_MS))).thread!==null}catch(error){let name=error?.name;if(name==="TimeoutError"||name==="AbortError")return!0;throw error}}async function handleWebhook(key,request){let platform=entries[key];if(!platform)throw notFound(`no sync entry named ${key}`);if(!await here(key))return new Response(null,{status:200});let response;try{response=await platform.receive(key,request,received=>intake(key,received))}catch(error){return error instanceof HttpError&&error.status===400?(console.error("[board] dropped an event the board refuses",error),new Response(null,{status:200})):(console.error("[board] intake failed",error),new Response("intake failed",{status:500}))}let pulling=pull([key]).catch(error=>console.error(`[board] couldn't pull ${key}'s inbox:`,describe(error)));return waitUntil(pulling),response}async function pull(keys=Object.keys(entries)){let ran=0,until=Date.now()+PULL_MS;for(let key of keys)if(await here(key))for(;Date.now()<until;){let{items}=await call("inboxNext",{key,limit:10});if(items.length===0)break;await Promise.all(items.map(item=>runItem(key,item))),ran+=items.length}return ran}async function runItem(key,item){let error;try{await inbound(key,{event:item.event,raw:item.raw},{id:item.id,attempt:item.attempt+1})}catch(failure){console.error(`[board] sync ${key} couldn't import ${item.id}:`,describe(failure)),error=describe(failure)}await call("inboxAck",{key,id:item.id,lease:item.lease,...error!==void 0?{error}:{}}).catch(failure=>console.error("[board] couldn't ack an inbox event:",describe(failure)))}async function resolveLinks(platform,links,linker,channel,previous=[]){if(links.length===0)return[];let resolved=[];for(let link of links){if(resolved.some(done=>done.url===link.url))continue;let id=(await find({thread:link.thread,message:link.message})).message,copy=id===null?null:await messageOf(id);if(copy&&!copy.deleted&&copy.channel===channel){resolved.push({url:link.url,message:copy.id,unavailable:null,snapshot:{author:copy.author?shownName(copy.author):copy.by.actor,text:copy.text,createdAt:copy.createdAt,files:copy.attachments.map(file=>({name:file.name,url:null}))}});continue}if(link.snapshot){resolved.push({url:link.url,message:null,snapshot:link.snapshot,unavailable:null});continue}let kept=previous.find(earlier=>earlier.url===link.url&&earlier.snapshot&&earlier.message===null);if(kept){resolved.push(kept);continue}let fetched=await platform.fetchLink(link,linker).catch(error=>({snapshot:null,unavailable:describe(error)}));resolved.push({url:link.url,message:null,snapshot:fetched.snapshot,unavailable:fetched.snapshot?null:(fetched.unavailable??"unknown").slice(0,300)})}return storableJson(resolved)}async function importFiles(platform,files,attempt){let attachments=[],notes=[],noFiles=null;for(let file of files.slice(0,10)){if(noFiles!==null){notes.push(fileLink(file,noFiles));continue}if(file.size!==void 0&&file.size>26214400){notes.push(fileNote(file,`over ${26214400/1024/1024} MB`));continue}let data;try{let fetched=await platform.fetchFile(file);if(fetched===null){notes.push(fileNote(file,`${platform.platform} can't hand it over`));continue}data=fetched}catch(error){if(attempt<FILE_ATTEMPTS)throw error;console.warn(`[board] couldn't fetch ${file.name??"a file"} from ${platform.platform}:`,describe(error)),notes.push(fileNote(file,`${platform.platform} wouldn't hand it over`));continue}if(data.byteLength>26214400){notes.push(fileNote(file,`over ${26214400/1024/1024} MB`));continue}if(data.byteLength===0){notes.push(fileNote(file,"it was empty"));continue}let name=file.name??`${file.type}`;try{attachments.push((await call("upload",{data,name,type:file.mimeType||typeOf(name)})).attachment)}catch(error){if(error instanceof HttpError&&(error.code==="too_large"||error.code==="no_direct_uploads")){notes.push(fileNote(file,`over ${4194304/1024/1024} MB`));continue}if(!keepsNoFiles(error))throw error;noFiles=error.message,notes.push(fileLink(file,noFiles))}}for(let file of files.slice(10))notes.push(fileNote(file,"a message carries at most 10"));return{attachments,notes}}async function inbound(key,received,meta){let platform=platformOf(key),item={...received,event:keyedEvent(key,platform.platform,received.event)},{event,raw}=item,linked=(await find({thread:event.thread})).thread??void 0;if(event.kind==="message"){let copied=(await find({thread:event.subthread??event.thread,message:event.message})).message;if(copied!==null){let origin=(await messageOf(copied))?.origin;if(!origin||origin.message!==event.message||(origin.subthread??origin.thread)!==(event.subthread??event.thread))return}}let author="author"in event?event.author:{id:`${key}:system`,handle:platform.platform,name:platform.platform,avatar:null,isBot:!0},typed,typedEvent=()=>typed??=immutable(platform.event({id:meta.id,key,event,raw})),imported,link,active=!0,sync={direction:"in",key,channel:native(event.channel),get event(){return typedEvent()},board:host().client({author,key,...originOf(key,event)},meta.id),import(channel,overrides={}){if(!active)throw badRequest("the sync function has finished");return imported??=importEvent(key,item,meta,linked,channel,overrides),imported},permalink(){let promise=link??platform.permalink(typedEvent());return link=promise,promise.catch(()=>{link===promise&&(link=void 0)}),promise},resolve:name=>resolve(key,name)};try{await platform.sync(sync),await imported}finally{active=!1}}async function importEvent(key,item,meta,linked,channel,overrides){let where=channel??(linked?(await syncOf(linked))?.channel:void 0);if(where===void 0)return{root:null,message:null};try{return await applyIncoming(key,item,meta,ChannelPath.parse(where),SyncOverrides.parse(overrides))}catch(error){if(!(error instanceof DroppedError))throw error;let thread=(await find({thread:item.event.thread})).thread;return{root:thread===null?null:(await syncOf(thread))?.root??null,message:null}}}function originOf(key,event){let platform=platformOf(key),thread=("subthread"in event?event.subthread:null)??event.thread;return{via:{kind:"sync",key,platform:platform.platform,channel:event.channel,thread},respond:async text=>{await platform.post(native(thread),"thread",{markdown:text})}}}async function applyIncoming(key,item,meta,channel,overrides){let{event,raw}=item,source=originOf(key,event),platform=platformOf(key),threadKey=(await find({thread:event.thread})).thread??void 0,synced=threadKey?await syncOf(threadKey):null,rootId=synced?.root,writeId=n=>derivedId("board-inbound",meta.id,String(n)),from={key,channel:source.via.channel,thread:source.via.thread},screened=async answer=>{if(!answer.dropped)return answer.message;for(let text of answer.dropped)await source.respond(text);throw new DroppedError(answer.dropped)},post=async({attachments=[],...input})=>({id:await screened(await call("syncImport",{op:"post",from:key,source:from,...input,origin:input.origin??null,...attachments.length?{attachments:attachments.map(file=>file.id)}:{}})),re:input.re??null}),result=message=>({root:message.re??message.id,message:message.id}),labels=(defaults={})=>{let merged={...defaults,...overrides.labels};for(let key2 of overrides.unset??[])delete merged[key2];return merged},rootDraft=draft=>{if(!overrides.root)return draft;let patch=overrides.root(immutable(structuredClone(draft)));if(patch&&typeof patch=="object"&&"then"in patch)throw badRequest("root overrides must be synchronous");let checked=SyncOverrides.pick({text:!0,labels:!0}).parse(patch);return{...draft,text:checked.text??draft.text,labels:{...draft.labels,...checked.labels}}},setLabels=(author,set,unset)=>call("syncImport",{op:"labels",author,from:key,origin:{thread:event.thread},set,unset}),setExtraLabels=async(author,id)=>{if(!overrides.labels&&!overrides.unset)return;let root=await messageOf(id),set=Object.fromEntries(Object.entries(overrides.labels??{}).filter(([key2,value])=>root?.labels[key2]!==value)),unset=(overrides.unset??[]).filter(key2=>root?.labels[key2]!==void 0);(Object.keys(set).length||unset.length)&&await setLabels(author,set,unset)};switch(event.kind){case"message":{let existing=(await find({thread:event.subthread??event.thread,message:event.message})).message;if(existing!==null)return{root:rootId??existing,message:existing};let{attachments,notes}=event.files?.length?await importFiles(platform,event.files,meta.attempt):{attachments:[],notes:[]},links=await resolveLinks(platform,event.links??[],{thread:event.subthread??event.thread,message:event.message},synced?.channel??channel),base={...links.length?{links}:{},...event.mentioned?.length?{mentioned:event.mentioned}:{},author:event.author,text:clampText(withNotes(overrides.text??event.text,notes),attachments.length>0),...attachments.length?{attachments}:{},origin:{channel:event.channel,thread:event.thread,subthread:event.subthread,message:event.message,context:event.context},id:await writeId(0)},reply={...base,...overrides.noSync?{noSync:!0}:{}};if(rootId!==void 0)return await setExtraLabels(event.author,rootId),result(await post({...reply,re:rootId}));let fetched=await platform.fetchRoot(native(event.thread));if(fetched===null){let draft2=rootDraft({text:event.text,labels:{},author:event.author,raw});return result(await post({...base,channel,text:clampText(withNotes(overrides.text??draft2.text,notes),attachments.length>0),labels:labels(draft2.labels)}))}let draft=rootDraft({...fetched,raw:fetched.raw??null}),root=await post({author:{...fetched.author,id:keyedId(key,platform.platform,fetched.author.id)},channel,text:clampText(draft.text),labels:labels(draft.labels),origin:{channel:event.channel,thread:event.thread,subthread:null,message:`root:${meta.id}`,context:null},id:await writeId(1)});return result(await post({...reply,re:root.id}))}case"edited":case"deleted":case"reaction":{let id=(await find({thread:event.subthread??event.thread,message:event.message})).message;if(id===null)return{root:rootId??null,message:null};let author="author"in event?event.author:{id:`${key}:system`,handle:platform.platform,name:platform.platform,avatar:null,isBot:!0},origin={thread:event.subthread??event.thread,message:event.message};if(rootId!==void 0&&await setExtraLabels(author,rootId),event.kind==="deleted")await call("syncImport",{op:"delete",author,from:key,origin});else if(event.kind==="edited"){let stored=await messageOf(id),text=clampText(withNotes(overrides.text??event.text,stored?notesIn(stored.text):[]),(stored?.attachments.length??0)>0),mentioned=event.mentioned?.length?{mentioned:event.mentioned}:{};stored&&!event.linksOnly&&stored.text!==text&&await screened(await call("syncImport",{op:"edit",author,from:key,origin,text,source:from,...mentioned}));let links=stored?await resolveLinks(platform,event.links??[],origin,stored.channel,stored.links):[];stored&&!sameLinks(links,stored.links)&&await call("syncImport",{op:"links",author,from:key,origin,links})}else{if(platform.singleReaction){let emoji=canonicalEmoji(event.emoji),as=new Set([author.id,`${await principalNow()}+${author.id}`]);for(let[held,actors]of Object.entries((await messageOf(id))?.reactions??{}))actors.some(actor=>as.has(actor))&&!(event.added&&held===emoji)&&await call("syncImport",{op:"react",author,from:key,origin,emoji:held,remove:!0})}(!platform.singleReaction||event.added)&&await call("syncImport",{op:"react",author,from:key,origin,emoji:event.emoji,remove:!event.added})}return{root:rootId??null,message:id}}case"lifecycle":{if(rootId!==void 0){let root2=await messageOf(rootId),createdHere=root2?.origin?.message===`lifecycle:${meta.id}`,desired=labels((createdHere?rootDraft({text:lifecycleText(event),labels:event.labels,author:event.author,raw}):null)?.labels??event.labels),owned=key2=>event.owns?.some(prefix=>key2.startsWith(prefix))??!1,set=Object.fromEntries(Object.entries(desired).filter(([key2,value])=>root2?.labels[key2]!==value)),unset=Object.keys(root2?.labels??{}).filter(key2=>!(key2 in desired)&&(event.unset.includes(key2)||overrides.unset?.includes(key2)||owned(key2)));if(root2&&!root2.deleted&&(Object.keys(set).length||unset.length)&&await setLabels(event.author,set,unset),event.retitled&&root2&&!root2.deleted&&root2.from===key&&root2.origin?.thread===event.thread){let text=clampText(overrides.text??rootDraft({text:lifecycleText(event),labels:root2.labels,author:event.author,raw}).text);root2.text!==text&&await screened(await call("syncImport",{op:"edit",author:event.author,from:key,origin:{thread:root2.origin.thread,message:root2.origin.message},text}))}return event.reply?result(await post({author:event.author,re:rootId,text:clampText(overrides.text??event.reply),...overrides.noSync?{noSync:!0}:{},id:await writeId(1)})):{root:rootId,message:createdHere?rootId:null}}if(!event.createRoot)return{root:null,message:null};let draft=rootDraft({text:lifecycleText(event),labels:event.labels,author:event.author,raw}),root=await post({author:event.author,channel,text:clampText(event.reply?draft.text:overrides.text??draft.text),labels:labels(draft.labels),origin:{channel:event.channel,thread:event.thread,subthread:null,message:`lifecycle:${meta.id}`,context:null},id:await writeId(0)});return event.reply?result(await post({author:event.author,re:root.id,text:clampText(overrides.text??event.reply),...overrides.noSync?{noSync:!0}:{},id:await writeId(1)})):result(root)}}}async function textFor(key,actors,text){let exact=extractMentions(text).flatMap(token=>token.kind==="actor"?[token.actor]:[]);if(exact.length===0)return text;let found=new Map,asked=0;for(let named of exact)actors.byId[named]||!isEmail(named)||found.has(named)||found.set(named,asked++<EMAIL_LOOKUPS_PER_MESSAGE_MAX?await emailMention(key,named):null);return replaceMentions(text,token=>{if(token.kind==="handle")return null;if(found.has(token.actor))return found.get(token.actor)??token.actor;let actor=actorNamed(token.actor,actors);return actor?nativeMention(key,actor.id,actors)??actor.name:unmetMention(key,token.actor,actors)})}function unmetMention(key,id,actors){let user=userOf(key,id,actors);if(user===null)return null;let platform=platformOf(key);return platform.mentionById(`${platform.platform}:${user}`)}function actorNamed(id,actors){return actors.byId[id]??(actors.principal?actors.byId[`${actors.principal}+${id}`]:void 0)??null}function userOf(key,actor,actors){let{principal:principal2,profile}=actorParts(actor),id=profile===null?actor:platformProfile(profile)!==null&&principal2===actors.principal?profile:null;return id?.startsWith(`${key}:`)?id.slice(key.length+1):null}function nativeMention(key,actor,actors){let account=actors.byId[actor],user=account?userOf(key,actor,actors):null;if(user===null)return null;let platform=platformOf(key);return platform.mention({...account,id:`${platform.platform}:${user}`})}async function render(key,target,message,actors,renderer){let actor=actors.byId[message.by.actor],own=actor?.name??message.by.actor,after=`${actor?.via?` ${viaText(actor.via)}`:""}${message.from?` (${actor?.platform??entries[message.from]?.platform??message.from})`:""}`,environment=actor?.kind==="deployment"&&!actor.via?/(?:@[^@/]+| \([^()]+\))$/.exec(own)?.[0]??"":"",name=`${own}${after}`,attribution=`${environment}${after}`,platform=platformOf(key),bot=byVercelBot(message,actor),body=(renderer??(input=>platform.render(input)))(immutable({message:{...structuredClone(message),text:displayText(message.text,bot)},author:actor?{...actor}:null,mentionOf:id=>nativeMention(key,id,actors),label:name,target}));if(typeof body!="string")throw badRequest("a provider renderer must return markdown");let labeled=`**${name}**: `,markdown=await textFor(key,actors,body.startsWith(labeled)&&opensBlock(body.slice(labeled.length))?`**${name}**:
12
+
13
+ ${body.slice(labeled.length)}`:body),deployments=bot?vercelDeployments(message.text):null;return{markdown,...actor?.verified?{as:{name,avatar:senderAvatar(message,actor),attribution}}:{},...deployments?{deployments}:{}}}function senderAvatar(message,actor){let builtIn=avatar=>!avatar||/\/avatars\/[a-z0-9-]+$/.test(avatar),own=actor?.avatar??null;if(!builtIn(own))return own;let username=actor?.handle.split("/")[0]??"",id=message.by.principal.slice(12);return!message.by.principal.startsWith("vercel:user:")||!username||/^user-/.test(username)||username.toLowerCase()===id.toLowerCase()?own:`https://vercel.com/api/www/avatar?u=${encodeURIComponent(username)}&s=64&format=png`}let attachmentNotes=message=>message.attachments.map(a=>`
14
+ \u{1F4CE} ${a.name} (${fileSize(a.size)}, on the board: #${message.id})`).join(""),renderFor=async(target,message,actors,noted=!1,renderer)=>{let key=keyOf(target),{markdown,...rest}=await render(key,target,message,actors,renderer);return{markdown:message.attachments.length>0&&(noted||!platformOf(key).uploadsFiles)?`${markdown}
15
+ ${attachmentNotes(message)}`:markdown,...rest,external:message.from!==null&&message.from!=="board"}};async function postReply(message,target,externalThread,actors,renderer){let replyCopy=message.replyTo===null?void 0:(await copiesOf([message.replyTo]))[message.replyTo]?.[target],place=replyCopy!==void 0&&replyCopy.thread!==externalThread?replyCopy.thread:externalThread,platform=platformOf(keyOf(target)),body=await renderFor(target,message,actors,!1,renderer),files,sentId;if(!body.markdown.trim()&&message.attachments.length&&platform.uploadsFiles)try{let sent=await uploadMessageFiles(message,target,place);sentId=sent.message,files=sent.files}catch(error){if(!platform.refusesFiles(error)&&!keepsNoFiles(error))throw error;body=await renderFor(target,message,actors,!0,renderer),sentId=(await platform.post(native(place),"thread",body)).message,files=null}else{if(!body.markdown.trim())throw badRequest("a renderer must return text unless the message has media");sentId=(await platform.post(native(place),"thread",body)).message}let external={thread:place,message:sentId,...files!==void 0?{files}:{}};return await recordDelivery(message,target,external),external}async function recordDelivery(message,target,copy){await call("syncReceipt",{kind:"message",message:message.id,target,external:{thread:copy.thread,message:copy.message},...copy.files!==void 0?{files:copy.files}:{}})}async function messageFiles(message){return Promise.all(message.attachments.map(async a=>{let{data}=await call("attachment",{id:a.id});return{data:data instanceof Uint8Array?data:new Uint8Array(await new Response(data).arrayBuffer()),filename:a.name,mimeType:a.type}}))}async function uploadMessageFiles(message,target,thread){return platformOf(keyOf(target)).uploadFiles(native(thread),await messageFiles(message))}async function deliverFiles(message,target,copy,actors,renderer){let platform=platformOf(keyOf(target));if(!platform.uploadsFiles||message.attachments.length===0||copy.files!==void 0)return;let ids;try{ids=(await uploadMessageFiles(message,target,copy.thread)).files}catch(error){if(!platform.refusesFiles(error)&&!keepsNoFiles(error))throw Object.assign(new Error(`files: ${describe(error)}`),{cause:error,data:{error:`files: ${describe(error)}`}});console.warn(`[board] ${target} won't take #${message.id}'s files (${describe(error)}); noting them in its text`),ids=null,await renderFor(target,message,actors,!0,renderer).then(body=>platform.edit(native(copy.thread),copy.message,body)).catch(edit=>console.warn(`[board] couldn't note #${message.id}'s files on ${target}:`,describe(edit)))}await call("syncReceipt",{kind:"files",message:message.id,target,files:ids})}let failed=(failures,id,target,error)=>{failures.some(failure=>failure.error===error)||failures.push({id,target,error})};async function settle(attempt,failures){if(failures.length!==0){if(attempt<DELIVERY_ATTEMPTS||afterRetry(attempt))throw failures[0].error;for(let{id,target,error}of failures)console.error(`[board] gave up ${target===null?`syncing #${id}`:`delivering #${id} to ${target}`}:`,describe(error)),target!==null&&await call("syncReceipt",{kind:"failed",message:id,target,error:describe(error)})}}async function offer(key,event,message,target,send){let sent,active=!0,finished=()=>badRequest("the sync function has finished"),sync={direction:"out",key,channel:target===null?null:channelIn(key,target),event:immutable(structuredClone(event)),message:immutable(structuredClone(message)),target,deliver(options={}){if(!active)throw finished();return sent??=target===null?Promise.resolve():send(options.render),sent},start(channel){if(!active)throw finished();return startThread(key,message,channel)},resolve:name=>resolve(key,name)};try{await platformOf(key).sync(sync),await sent}finally{active=!1}}async function startThread(key,message,channel){let{target,kind}=await normalizeTarget(`${key}:${channel}`),root=message.re===null?message:await messageOf(message.re);!root||root.deleted||root.noSync||target!==(root.origin?root.origin.channel??channelOf(root.origin.thread):null)&&await call("syncReceipt",{kind:"thread",message:root.id,target,targetKind:kind,cause:"config"})}async function deliverRoot(event,attempt){let starters=[];for(let key of Object.keys(entries))entries[key].canStartThreads&&await here(key)&&starters.push(key);if(event.payload.noSync||starters.length===0)return;let root=await messageOf(event.message.id);if(!root||root.deleted)return;let failures=[];for(let key of starters)try{await offer(key,event,root,null,async()=>{})}catch(error){failed(failures,root.id,null,error)}await settle(attempt,failures)}async function deliverThread(event,attempt){let{thread,target}=event.payload;if(!await ours(target)||(event.payload.kind??(isThreadTarget(target)?"thread":"channel"))==="thread")return;let synced=await syncOf(thread);if(!synced?.targets.includes(target))return;let[root,...replies]=await threadOf(synced.root);if(!root||root.id!==synced.root||root.deleted||root.noSync)return;let failures=[];try{await offer(keyOf(target),event,root,target,renderer=>backfill(synced,root,replies,target,failures,renderer))}catch(error){failed(failures,root.id,target,error)}await settle(attempt,failures)}async function backfill(synced,root,replies,target,failures,renderer){let actors=await actorsNow(),copies=await copiesOf([root.id,...replies.map(reply=>reply.id)]),rootFailed=error=>(failures.push({id:root.id,target,error}),error),externalThread=synced.external[target];if(externalThread){let copy=copies[root.id]?.[target];if(copy)try{await deliverFiles(root,target,copy,actors,renderer)}catch(error){throw rootFailed(error)}}else try{let platform=platformOf(keyOf(target)),body=await renderFor(target,root,actors,!1,renderer),mediaOnly=!body.markdown.trim()&&root.attachments.length>0&&platform.uploadsFiles;if(!body.markdown.trim()&&!mediaOnly)throw badRequest("a renderer must return text unless the message has media");let uploaded,sent=await(async()=>{if(!mediaOnly&&(root.attachments.length===0||!platform.startsThreadsWithFiles))return platform.post(native(target),"channel",body);try{let sent2=await platform.post(native(target),"channel",{...body,files:await messageFiles(root)});return uploaded=mediaOnly?sent2.files??[]:sent2.files,sent2}catch(error){if(!platform.refusesFiles(error)&&!keepsNoFiles(error))throw error;return uploaded=null,platform.post(native(target),"channel",await renderFor(target,root,actors,!0,renderer))}})();externalThread=`${keyOf(target)}:${sent.thread}`;let external={thread:externalThread,message:sent.message,...uploaded!==void 0?{files:uploaded}:{}};await recordDelivery(root,target,external),await deliverFiles(root,target,external,actors,renderer)}catch(error){throw rootFailed(error)}let mine=[];for(let reply of replies)if(!(reply.deleted||reply.noSync||cameFrom(reply,target)))try{await deliverFiles(reply,target,copies[reply.id]?.[target]??await postReply(reply,target,externalThread,actors,renderer),actors,renderer)}catch(error){mine.push({id:reply.id,target,error})}if(failures.push(...mine),mine.length)throw mine[0].error}let cameFrom=(message,target)=>message.origin?.thread===target||message.from!==null&&keyOf(target)===message.from;async function deliverPost(event,attempt){if(!event.message)return;if(event.message.re===null)return deliverRoot(event,attempt);if(event.payload.noSync)return;let synced=await syncOf(event.payload.thread);if(!synced||synced.targets.length===0)return;let thread=await threadOf(synced.root);if(thread[0]?.id!==synced.root||thread[0].noSync)return;let message=thread.find(found=>found.id===event.message.id);if(!message||message.deleted)return;let actors=await actorsNow(),failures=[];for(let target of synced.targets){let externalThread=synced.external[target];if(!(!await ours(target)||!externalThread)&&!cameFrom(message,target))try{await offer(keyOf(target),event,message,target,async renderer=>{let copy=(await copiesOf([message.id]))[message.id]?.[target]??await postReply(message,target,externalThread,actors,renderer);await deliverFiles(message,target,copy,actors,renderer)})}catch(error){failed(failures,message.id,target,error)}}await settle(attempt,failures)}async function deliverChange(event){let copies=(await copiesOf([event.payload.id]))[event.payload.id]??{};if(Object.keys(copies).length===0)return;let message=event.type==="message.edited"?await messageOf(event.payload.id):event.message??await messageOf(event.payload.id);if(!message||event.type==="message.edited"&&message.deleted)return;let actors=await actorsNow();for(let[target,copy]of Object.entries(copies))if(!(!await ours(target)||event.payload.from!==null&&keyOf(target)===event.payload.from))try{await offer(keyOf(target),event,message,target,async renderer=>{let platform=platformOf(keyOf(target)),thread=native(copy.thread);event.type==="message.edited"?await platform.edit(thread,copy.message,await renderFor(target,message,actors,copy.files===null,renderer)):event.type==="message.deleted"?(await platform.delete(thread,copy.message),copy.files?.length&&await platform.deleteFiles(copy.files)):event.type==="reaction.added"?await platform.react(thread,copy.message,canonicalEmoji(event.payload.emoji),!0):await platform.react(thread,copy.message,canonicalEmoji(event.payload.emoji),!1)})}catch(error){console.warn(`[board] skipped ${event.type} on ${target}:`,error.message)}}async function deliverLabels(event){let{id}=event.payload,copies=(await copiesOf([id]))[id]??{},after=event.message;if(!after||Object.keys(copies).length===0)return;let current=await messageOf(id);if(!current||current.deleted)return;let actors=await actorsNow(),message={...current,labels:after.labels},previous={...current,labels:event.before?.labels??{}};for(let[target,copy]of Object.entries(copies))if(await ours(target))try{await offer(keyOf(target),event,message,target,async renderer=>{let body=await renderFor(target,message,actors,copy.files===null,renderer);body.markdown!==(await renderFor(target,previous,actors,copy.files===null,renderer)).markdown&&await platformOf(keyOf(target)).edit(native(copy.thread),copy.message,body)})}catch(error){console.warn(`[board] skipped labels.changed on ${target}:`,describe(error))}}async function deliver(event,{attempt}){switch(event.type){case"thread.synced":return deliverThread(event,attempt);case"message.posted":return deliverPost(event,attempt);case"message.edited":case"message.deleted":case"reaction.added":case"reaction.removed":return deliverChange(event);case"labels.changed":return deliverLabels(event)}}async function typing(messages,status){let synced=messages[0]?await syncOf(messages[0].thread):null;if(!synced)return[];let externals=[];for(let external of new Set(Object.values(synced.external)))await ours(external)&&externals.push(external);return(await Promise.all(externals.map(async external=>{let key=keyOf(external);try{let platform=platformOf(key),latest=null;for(let i=messages.length-1;i>=0&&latest===null;i--){let origin=messages[i];!origin.deleted&&origin.origin?.thread===external&&(latest=origin.origin.message)}return await platform.startTyping(native(external),latest,status),external}catch(error){return console.warn(`[board] skipped typing on ${external}:`,describe(error)),null}}))).filter(external=>external!==null)}async function inboxChannel(key,channel){try{return`${key}:${await platformOf(key).resolveChannel(channel)}`}catch(error){throw badRequest(`can't resolve inbox channel: ${error.message}`)}}let unreadableStatus=code=>code==="unsupported"||code==="invalid_target"?400:code==="channel_not_found"?404:code==="ratelimited"?429:["no_client","list_failed","internal_error","fatal_error","service_unavailable","request_timeout"].includes(code)?502:403;async function readSource(key,target,limit,after){let platform=platformOf(key);try{let read=await platform.read(target,{limit,after});return{...read,messages:read.messages.map(message=>({...message,text:keyedText(key,platform.platform,message.text)}))}}catch(error){throw error instanceof UnreadableError?new HttpError(unreadableStatus(error.code),error.code,error.message):badRequest(`can't read ${target} from ${key}: ${describe(error)}`,"platform_error")}}async function joinSource(key,target){let platform=platformOf(key);try{return await platform.join(target)}catch(error){throw error instanceof UnreadableError?new HttpError(unreadableStatus(error.code),error.code,error.message):badRequest(`can't join ${target} on ${key}: ${describe(error)}`,"platform_error")}}return{entries,bind(next){bound=next},caller:me,deliver,receive:inbound,pull,normalizeTarget,handleWebhook,inboxChannel,typing,readSource,joinSource}}function lifecycleText(event){let head=event.url?`${event.title}
16
+ ${event.url}`:event.title;return event.body?`${head}
17
+
18
+ ${event.body}`:head}export{createSyncEngine,keyedId};
@@ -4,4 +4,4 @@ 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{getInvalidSubcommand}from"./chunk-TG2RCYTH.js";import{getSubcommand}from"./chunk-ETV3C2CV.js";import{getCommandAliases}from"./chunk-GQU7IE6F.js";import"./chunk-QOLGACFD.js";import"./chunk-DDPH26ZO.js";import"./chunk-PIDEH4SJ.js";import"./chunk-IIK6GUVI.js";import"./chunk-C35SG42R.js";import"./chunk-2GBU6ULJ.js";import"./chunk-EJLYDHT7.js";import"./chunk-DOBV3XLO.js";import"./chunk-TK7K6GCG.js";import"./chunk-BMIYC2MH.js";import"./chunk-6CJFPT4F.js";import"./chunk-ZZD5W5KT.js";import{imageRmSubcommand}from"./chunk-VHSAI6FS.js";import"./chunk-F7L5SXJM.js";import"./chunk-GLCSWIB4.js";import"./chunk-XECELSF5.js";import"./chunk-6FYPSSL4.js";import"./chunk-UQZZX2J7.js";import"./chunk-UDZJCD5W.js";import"./chunk-5ZCSFPWG.js";import"./chunk-PY4WWD6Z.js";import"./chunk-XDYVJWGX.js";import"./chunk-JALVF3C2.js";import"./chunk-BPIGFKNN.js";import"./chunk-AB4WXRCO.js";import"./chunk-SYJXONEV.js";import"./chunk-KK5C7HVP.js";import"./chunk-7KCRYDGK.js";import"./chunk-GLIQ4KNY.js";import{AGENT_REASON,buildCommandWithGlobalFlags,outputAgentError}from"./chunk-PNWRO3XW.js";import"./chunk-DTUEHPME.js";import"./chunk-2VBFQZ72.js";import{warnDeprecatedSubcommand}from"./chunk-6GKP6VUF.js";import"./chunk-GOI2VVI7.js";import"./chunk-B4KA3ZH2.js";import"./chunk-BOJDM3O7.js";import{output_manager_default}from"./chunk-AP6DZGTK.js";import"./chunk-BLUPZPAS.js";import"./chunk-5MDNVAE6.js";import"./chunk-MCYG7CCE.js";import"./chunk-YHPPP3SF.js";import"./chunk-24SIHFEW.js";import"./chunk-CFJBDBYH.js";import"./chunk-2BKALEOP.js";import"./chunk-NB2WLB3J.js";import"./chunk-ISWW3DKF.js";import"./chunk-BRQUZ5NC.js";import"./chunk-BULSRTQE.js";import"./chunk-BZENIQ7N.js";var IMAGE_CONFIG={ls:["ls","list"],inspect:["inspect","get"],delete:getCommandAliases(imageRmSubcommand)};async function image(client,argv,telemetry){let{subcommand,args,subcommandOriginal}=getSubcommand(argv,IMAGE_CONFIG);if(subcommand==null){let message=argv.length===0?getInvalidSubcommand(IMAGE_CONFIG):`Unknown "vcr image" subcommand "${argv[0]}".`;return outputAgentError(client,{status:"error",reason:AGENT_REASON.INVALID_ARGUMENTS,message,next:[{command:buildCommandWithGlobalFlags(client.argv,"vcr image --help"),when:"Show valid image subcommands"}]},2),output_manager_default.error(`${message} Run \`vercel vcr image --help\`.`),2}switch(subcommand){case"ls":return(await import("./ls-XBDD2PTU.js")).default(client,args,telemetry);case"inspect":return subcommandOriginal==="get"&&warnDeprecatedSubcommand(client,"vcr image get","vcr image inspect"),(await import("./inspect-GUVBQAGQ.js")).default(client,args,telemetry);case"delete":return subcommandOriginal==="remove"&&warnDeprecatedSubcommand(client,"vcr image remove","vcr image delete"),(await import("./rm-F2RNFFYF.js")).default(client,args,telemetry);default:return output_manager_default.error(`Unhandled image subcommand: ${subcommand}`),1}}export{image as default};
7
+ import{getInvalidSubcommand}from"./chunk-TG2RCYTH.js";import{getSubcommand}from"./chunk-ETV3C2CV.js";import{getCommandAliases}from"./chunk-XI7556MQ.js";import"./chunk-QOLGACFD.js";import"./chunk-DDPH26ZO.js";import"./chunk-PIDEH4SJ.js";import"./chunk-IIK6GUVI.js";import"./chunk-C35SG42R.js";import"./chunk-2GBU6ULJ.js";import"./chunk-EJLYDHT7.js";import"./chunk-DOBV3XLO.js";import"./chunk-UFCL2VBD.js";import"./chunk-BMIYC2MH.js";import"./chunk-6CJFPT4F.js";import"./chunk-ZZD5W5KT.js";import{imageRmSubcommand}from"./chunk-VHSAI6FS.js";import"./chunk-F7L5SXJM.js";import"./chunk-GLCSWIB4.js";import"./chunk-XECELSF5.js";import"./chunk-6FYPSSL4.js";import"./chunk-UQZZX2J7.js";import"./chunk-UDZJCD5W.js";import"./chunk-5ZCSFPWG.js";import"./chunk-PY4WWD6Z.js";import"./chunk-XDYVJWGX.js";import"./chunk-JALVF3C2.js";import"./chunk-BPIGFKNN.js";import"./chunk-AB4WXRCO.js";import"./chunk-SYJXONEV.js";import"./chunk-KK5C7HVP.js";import"./chunk-7KCRYDGK.js";import"./chunk-GLIQ4KNY.js";import{AGENT_REASON,buildCommandWithGlobalFlags,outputAgentError}from"./chunk-PNWRO3XW.js";import"./chunk-DTUEHPME.js";import"./chunk-2VBFQZ72.js";import{warnDeprecatedSubcommand}from"./chunk-6GKP6VUF.js";import"./chunk-GOI2VVI7.js";import"./chunk-B4KA3ZH2.js";import"./chunk-BOJDM3O7.js";import{output_manager_default}from"./chunk-AP6DZGTK.js";import"./chunk-BLUPZPAS.js";import"./chunk-5MDNVAE6.js";import"./chunk-MCYG7CCE.js";import"./chunk-YHPPP3SF.js";import"./chunk-24SIHFEW.js";import"./chunk-CFJBDBYH.js";import"./chunk-2BKALEOP.js";import"./chunk-NB2WLB3J.js";import"./chunk-ISWW3DKF.js";import"./chunk-BRQUZ5NC.js";import"./chunk-BULSRTQE.js";import"./chunk-BZENIQ7N.js";var IMAGE_CONFIG={ls:["ls","list"],inspect:["inspect","get"],delete:getCommandAliases(imageRmSubcommand)};async function image(client,argv,telemetry){let{subcommand,args,subcommandOriginal}=getSubcommand(argv,IMAGE_CONFIG);if(subcommand==null){let message=argv.length===0?getInvalidSubcommand(IMAGE_CONFIG):`Unknown "vcr image" subcommand "${argv[0]}".`;return outputAgentError(client,{status:"error",reason:AGENT_REASON.INVALID_ARGUMENTS,message,next:[{command:buildCommandWithGlobalFlags(client.argv,"vcr image --help"),when:"Show valid image subcommands"}]},2),output_manager_default.error(`${message} Run \`vercel vcr image --help\`.`),2}switch(subcommand){case"ls":return(await import("./ls-XBDD2PTU.js")).default(client,args,telemetry);case"inspect":return subcommandOriginal==="get"&&warnDeprecatedSubcommand(client,"vcr image get","vcr image inspect"),(await import("./inspect-GUVBQAGQ.js")).default(client,args,telemetry);case"delete":return subcommandOriginal==="remove"&&warnDeprecatedSubcommand(client,"vcr image remove","vcr image delete"),(await import("./rm-F2RNFFYF.js")).default(client,args,telemetry);default:return output_manager_default.error(`Unhandled image subcommand: ${subcommand}`),1}}export{image as default};
@@ -4,6 +4,6 @@ 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{parseThreadArg}from"./chunk-2S6PE6GB.js";import{actorLabel,displayPath,renderThreadDetail,threadAge,truncate}from"./chunk-YRKW42CD.js";import{getThread,handleCommentsParseError,inferBranch,listMessages,listThreads,resolveCommentsScope,threadNotFoundMessage,toApiErrorParts}from"./chunk-CMFG6TYZ.js";import{outputError}from"./chunk-ZJNDLFZ7.js";import"./chunk-AKOYIH3A.js";import"./chunk-D3M2JG5C.js";import"./chunk-TOTTVS5P.js";import"./chunk-QJY3QFK6.js";import"./chunk-C64AK7SW.js";import{canPrompt}from"./chunk-IQ7FPAI4.js";import{inspectSubcommand}from"./chunk-XECELSF5.js";import"./chunk-CY5KJ42N.js";import"./chunk-CT77BGSW.js";import"./chunk-PNWRO3XW.js";import"./chunk-DTUEHPME.js";import"./chunk-EUU3FHCX.js";import"./chunk-M7FED5YP.js";import"./chunk-4HR3I3ML.js";import"./chunk-LOA7SZWH.js";import"./chunk-LUX4PBJL.js";import"./chunk-MTZYPCZ7.js";import"./chunk-OPORM35X.js";import"./chunk-D6REP5QQ.js";import"./chunk-FBYA6LLM.js";import"./chunk-MY4MONOH.js";import"./chunk-7HLAWGY2.js";import"./chunk-MXTC4ZAQ.js";import{parseArguments}from"./chunk-LYL26S3N.js";import"./chunk-2VBFQZ72.js";import{validateJsonOutput}from"./chunk-6GKP6VUF.js";import"./chunk-4NTBYNFR.js";import"./chunk-4SAVH3H7.js";import{isAPIError}from"./chunk-GOI2VVI7.js";import"./chunk-B4KA3ZH2.js";import"./chunk-BOJDM3O7.js";import{output_manager_default}from"./chunk-AP6DZGTK.js";import"./chunk-BLUPZPAS.js";import"./chunk-AW33SRYY.js";import"./chunk-5MDNVAE6.js";import"./chunk-OCR5CRTH.js";import"./chunk-7EJQLVWX.js";import"./chunk-SCV7XEEO.js";import"./chunk-MCYG7CCE.js";import"./chunk-YHPPP3SF.js";import{getFlagsSpecification}from"./chunk-CFJBDBYH.js";import"./chunk-2BKALEOP.js";import"./chunk-NB2WLB3J.js";import"./chunk-ISWW3DKF.js";import"./chunk-BRQUZ5NC.js";import"./chunk-BULSRTQE.js";import"./chunk-BZENIQ7N.js";async function pickThread(client,jsonOutput){if(!canPrompt(client)||jsonOutput)return outputError(client,jsonOutput,"MISSING_THREAD","Pass a thread ID or URL: `vercel comments inspect <thread>`.");let scope=await resolveCommentsScope(client,{requireProject:!0,jsonOutput});if(typeof scope=="number")return scope;let focus=scope.linked?inferBranch(client.cwd):void 0;output_manager_default.spinner("Fetching comments\u2026");let response;try{response=await listThreads(client,scope.teamId,{projectId:scope.projectId,status:"unresolved",branch:focus?[focus.value]:void 0,limit:20})}finally{output_manager_default.stopSpinner()}return response.threads.length===0?outputError(client,jsonOutput,"NO_COMMENTS",`No unresolved comments${focus?` on ${focus.value}`:""} to pick from.`):client.input.select({message:"Select a comment",choices:response.threads.map(thread=>({name:`${threadAge(thread)} ${actorLabel(thread.messages[0]?.author)} ${displayPath(thread)} \u201C${truncate(thread.messages[0]?.text??"",48)}\u201D`,value:thread.id}))})}async function fetchAllMessages(client,teamId,thread){if(thread.messageCount<=thread.messages.length)return thread.messages;let all=[],cursor;do{let page=await listMessages(client,teamId,thread.id,{limit:100,cursor});all.push(...page.messages),cursor=page.pagination?.nextCursor}while(cursor&&all.length<thread.messageCount);return all}async function inspect(client,telemetry){let parsedArgs,flagsSpecification=getFlagsSpecification(inspectSubcommand.options);try{parsedArgs=parseArguments(client.argv.slice(2),flagsSpecification)}catch(err){return handleCommentsParseError(err,"inspect")}let formatResult=validateJsonOutput(parsedArgs.flags);if(!formatResult.valid)return output_manager_default.error(formatResult.error),2;let jsonOutput=formatResult.jsonOutput,showContext=!!parsedArgs.flags["--context"];telemetry.trackCliOptionFormat(parsedArgs.flags["--format"]),telemetry.trackCliFlagContext(parsedArgs.flags["--context"]),telemetry.trackCliOptionProject(parsedArgs.flags["--project"]);let threadInput=parsedArgs.args[2];telemetry.trackCliArgumentThread(threadInput);let threadId,urlTeamSlug;if(threadInput){let parsed=parseThreadArg(threadInput);if(!parsed)return outputError(client,jsonOutput,"INVALID_THREAD",`Could not extract a thread ID from "${threadInput}". Pass the thread ID or its vercel.com URL.`);threadId=parsed.id,urlTeamSlug=parsed.teamSlug}else{let picked=await pickThread(client,jsonOutput);if(typeof picked=="number")return picked;threadId=picked}let scope=await resolveCommentsScope(client,{project:parsedArgs.flags["--project"],requireProject:!1,jsonOutput,urlTeamSlug});if(typeof scope=="number")return scope;jsonOutput||output_manager_default.spinner("Fetching comment\u2026");let thread,messages;try{thread=await getThread(client,scope.teamId,threadId),messages=await fetchAllMessages(client,scope.teamId,thread)}catch(err){if(isAPIError(err)){let{code,message}=toApiErrorParts(err);return outputError(client,jsonOutput,code,err.status===404?threadNotFoundMessage(threadId,scope):message)}throw err}finally{output_manager_default.stopSpinner()}return jsonOutput?(client.stdout.write(`${JSON.stringify({...thread,messages},null,2)}
7
+ import{parseThreadArg}from"./chunk-2S6PE6GB.js";import{actorLabel,displayPath,renderThreadDetail,threadAge,truncate}from"./chunk-YRKW42CD.js";import{getThread,handleCommentsParseError,inferBranch,listMessages,listThreads,resolveCommentsScope,threadNotFoundMessage,toApiErrorParts}from"./chunk-CMFG6TYZ.js";import"./chunk-AKOYIH3A.js";import"./chunk-TOTTVS5P.js";import{outputError}from"./chunk-ZJNDLFZ7.js";import"./chunk-D3M2JG5C.js";import"./chunk-QJY3QFK6.js";import"./chunk-C64AK7SW.js";import{canPrompt}from"./chunk-IQ7FPAI4.js";import{inspectSubcommand}from"./chunk-XECELSF5.js";import"./chunk-CY5KJ42N.js";import"./chunk-CT77BGSW.js";import"./chunk-PNWRO3XW.js";import"./chunk-DTUEHPME.js";import"./chunk-EUU3FHCX.js";import"./chunk-M7FED5YP.js";import"./chunk-4HR3I3ML.js";import"./chunk-LOA7SZWH.js";import"./chunk-LUX4PBJL.js";import"./chunk-MTZYPCZ7.js";import"./chunk-OPORM35X.js";import"./chunk-D6REP5QQ.js";import"./chunk-FBYA6LLM.js";import"./chunk-MY4MONOH.js";import"./chunk-7HLAWGY2.js";import"./chunk-MXTC4ZAQ.js";import{parseArguments}from"./chunk-LYL26S3N.js";import"./chunk-2VBFQZ72.js";import{validateJsonOutput}from"./chunk-6GKP6VUF.js";import"./chunk-4NTBYNFR.js";import"./chunk-4SAVH3H7.js";import{isAPIError}from"./chunk-GOI2VVI7.js";import"./chunk-B4KA3ZH2.js";import"./chunk-BOJDM3O7.js";import{output_manager_default}from"./chunk-AP6DZGTK.js";import"./chunk-BLUPZPAS.js";import"./chunk-AW33SRYY.js";import"./chunk-5MDNVAE6.js";import"./chunk-OCR5CRTH.js";import"./chunk-7EJQLVWX.js";import"./chunk-SCV7XEEO.js";import"./chunk-MCYG7CCE.js";import"./chunk-YHPPP3SF.js";import{getFlagsSpecification}from"./chunk-CFJBDBYH.js";import"./chunk-2BKALEOP.js";import"./chunk-NB2WLB3J.js";import"./chunk-ISWW3DKF.js";import"./chunk-BRQUZ5NC.js";import"./chunk-BULSRTQE.js";import"./chunk-BZENIQ7N.js";async function pickThread(client,jsonOutput){if(!canPrompt(client)||jsonOutput)return outputError(client,jsonOutput,"MISSING_THREAD","Pass a thread ID or URL: `vercel comments inspect <thread>`.");let scope=await resolveCommentsScope(client,{requireProject:!0,jsonOutput});if(typeof scope=="number")return scope;let focus=scope.linked?inferBranch(client.cwd):void 0;output_manager_default.spinner("Fetching comments\u2026");let response;try{response=await listThreads(client,scope.teamId,{projectId:scope.projectId,status:"unresolved",branch:focus?[focus.value]:void 0,limit:20})}finally{output_manager_default.stopSpinner()}return response.threads.length===0?outputError(client,jsonOutput,"NO_COMMENTS",`No unresolved comments${focus?` on ${focus.value}`:""} to pick from.`):client.input.select({message:"Select a comment",choices:response.threads.map(thread=>({name:`${threadAge(thread)} ${actorLabel(thread.messages[0]?.author)} ${displayPath(thread)} \u201C${truncate(thread.messages[0]?.text??"",48)}\u201D`,value:thread.id}))})}async function fetchAllMessages(client,teamId,thread){if(thread.messageCount<=thread.messages.length)return thread.messages;let all=[],cursor;do{let page=await listMessages(client,teamId,thread.id,{limit:100,cursor});all.push(...page.messages),cursor=page.pagination?.nextCursor}while(cursor&&all.length<thread.messageCount);return all}async function inspect(client,telemetry){let parsedArgs,flagsSpecification=getFlagsSpecification(inspectSubcommand.options);try{parsedArgs=parseArguments(client.argv.slice(2),flagsSpecification)}catch(err){return handleCommentsParseError(err,"inspect")}let formatResult=validateJsonOutput(parsedArgs.flags);if(!formatResult.valid)return output_manager_default.error(formatResult.error),2;let jsonOutput=formatResult.jsonOutput,showContext=!!parsedArgs.flags["--context"];telemetry.trackCliOptionFormat(parsedArgs.flags["--format"]),telemetry.trackCliFlagContext(parsedArgs.flags["--context"]),telemetry.trackCliOptionProject(parsedArgs.flags["--project"]);let threadInput=parsedArgs.args[2];telemetry.trackCliArgumentThread(threadInput);let threadId,urlTeamSlug;if(threadInput){let parsed=parseThreadArg(threadInput);if(!parsed)return outputError(client,jsonOutput,"INVALID_THREAD",`Could not extract a thread ID from "${threadInput}". Pass the thread ID or its vercel.com URL.`);threadId=parsed.id,urlTeamSlug=parsed.teamSlug}else{let picked=await pickThread(client,jsonOutput);if(typeof picked=="number")return picked;threadId=picked}let scope=await resolveCommentsScope(client,{project:parsedArgs.flags["--project"],requireProject:!1,jsonOutput,urlTeamSlug});if(typeof scope=="number")return scope;jsonOutput||output_manager_default.spinner("Fetching comment\u2026");let thread,messages;try{thread=await getThread(client,scope.teamId,threadId),messages=await fetchAllMessages(client,scope.teamId,thread)}catch(err){if(isAPIError(err)){let{code,message}=toApiErrorParts(err);return outputError(client,jsonOutput,code,err.status===404?threadNotFoundMessage(threadId,scope):message)}throw err}finally{output_manager_default.stopSpinner()}return jsonOutput?(client.stdout.write(`${JSON.stringify({...thread,messages},null,2)}
8
8
  `),0):(output_manager_default.print(`${renderThreadDetail(thread,messages,{showContext})}
9
9
  `),0)}export{inspect as default};
@@ -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{repositoryPath,repositoryTagPath}from"./chunk-DFVNL5ML.js";import{emitVcrArgParseError,formatBytes,formatImageStatus,formatRelativeTime,formatTagReference,handleVcrApiError,requireVcrRepositoryAndTag,resolveVcrScope,validateVcrJsonOutput}from"./chunk-6BN7Y3GF.js";import"./chunk-ZJNDLFZ7.js";import"./chunk-D3M2JG5C.js";import"./chunk-M32HBBPK.js";import"./chunk-GD7AV7BO.js";import{tagsInspectSubcommand}from"./chunk-ZZD5W5KT.js";import{printError}from"./chunk-CY5KJ42N.js";import"./chunk-CT77BGSW.js";import"./chunk-PNWRO3XW.js";import"./chunk-DTUEHPME.js";import"./chunk-EUU3FHCX.js";import"./chunk-M7FED5YP.js";import"./chunk-4HR3I3ML.js";import"./chunk-LOA7SZWH.js";import"./chunk-LUX4PBJL.js";import"./chunk-MTZYPCZ7.js";import"./chunk-OPORM35X.js";import"./chunk-D6REP5QQ.js";import"./chunk-FBYA6LLM.js";import"./chunk-MY4MONOH.js";import"./chunk-7HLAWGY2.js";import"./chunk-MXTC4ZAQ.js";import{parseArguments}from"./chunk-LYL26S3N.js";import"./chunk-2VBFQZ72.js";import"./chunk-6GKP6VUF.js";import"./chunk-4NTBYNFR.js";import"./chunk-4SAVH3H7.js";import{isAPIError}from"./chunk-GOI2VVI7.js";import"./chunk-B4KA3ZH2.js";import"./chunk-BOJDM3O7.js";import{output_manager_default}from"./chunk-AP6DZGTK.js";import"./chunk-BLUPZPAS.js";import"./chunk-AW33SRYY.js";import"./chunk-5MDNVAE6.js";import"./chunk-OCR5CRTH.js";import"./chunk-7EJQLVWX.js";import"./chunk-SCV7XEEO.js";import"./chunk-MCYG7CCE.js";import"./chunk-YHPPP3SF.js";import{getFlagsSpecification}from"./chunk-CFJBDBYH.js";import"./chunk-2BKALEOP.js";import{require_source}from"./chunk-NB2WLB3J.js";import"./chunk-ISWW3DKF.js";import"./chunk-BRQUZ5NC.js";import"./chunk-BULSRTQE.js";import{__toESM}from"./chunk-BZENIQ7N.js";var import_chalk=__toESM(require_source(),1);function printTag(tag,scope,repository){output_manager_default.print(`
7
+ import{repositoryPath,repositoryTagPath}from"./chunk-DFVNL5ML.js";import{emitVcrArgParseError,formatBytes,formatImageStatus,formatRelativeTime,formatTagReference,handleVcrApiError,requireVcrRepositoryAndTag,resolveVcrScope,validateVcrJsonOutput}from"./chunk-6BN7Y3GF.js";import"./chunk-ZJNDLFZ7.js";import"./chunk-M32HBBPK.js";import"./chunk-D3M2JG5C.js";import"./chunk-GD7AV7BO.js";import{tagsInspectSubcommand}from"./chunk-ZZD5W5KT.js";import{printError}from"./chunk-CY5KJ42N.js";import"./chunk-CT77BGSW.js";import"./chunk-PNWRO3XW.js";import"./chunk-DTUEHPME.js";import"./chunk-EUU3FHCX.js";import"./chunk-M7FED5YP.js";import"./chunk-4HR3I3ML.js";import"./chunk-LOA7SZWH.js";import"./chunk-LUX4PBJL.js";import"./chunk-MTZYPCZ7.js";import"./chunk-OPORM35X.js";import"./chunk-D6REP5QQ.js";import"./chunk-FBYA6LLM.js";import"./chunk-MY4MONOH.js";import"./chunk-7HLAWGY2.js";import"./chunk-MXTC4ZAQ.js";import{parseArguments}from"./chunk-LYL26S3N.js";import"./chunk-2VBFQZ72.js";import"./chunk-6GKP6VUF.js";import"./chunk-4NTBYNFR.js";import"./chunk-4SAVH3H7.js";import{isAPIError}from"./chunk-GOI2VVI7.js";import"./chunk-B4KA3ZH2.js";import"./chunk-BOJDM3O7.js";import{output_manager_default}from"./chunk-AP6DZGTK.js";import"./chunk-BLUPZPAS.js";import"./chunk-AW33SRYY.js";import"./chunk-5MDNVAE6.js";import"./chunk-OCR5CRTH.js";import"./chunk-7EJQLVWX.js";import"./chunk-SCV7XEEO.js";import"./chunk-MCYG7CCE.js";import"./chunk-YHPPP3SF.js";import{getFlagsSpecification}from"./chunk-CFJBDBYH.js";import"./chunk-2BKALEOP.js";import{require_source}from"./chunk-NB2WLB3J.js";import"./chunk-ISWW3DKF.js";import"./chunk-BRQUZ5NC.js";import"./chunk-BULSRTQE.js";import{__toESM}from"./chunk-BZENIQ7N.js";var import_chalk=__toESM(require_source(),1);function printTag(tag,scope,repository){output_manager_default.print(`
8
8
  `),output_manager_default.print(` ${import_chalk.default.cyan("ID")} ${tag.imageId}
9
9
  `),output_manager_default.print(` ${import_chalk.default.cyan("Digest")} ${tag.manifestDigest}
10
10
  `),output_manager_default.print(` ${import_chalk.default.cyan("Image")} ${formatTagReference(scope.teamSlug,scope.projectName,repository.name,tag.tag)}
@@ -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{formatTriggerOperator,getGroupStartedAt,getGroupTitle,getGroupType,humanizeReference,normalizeTimestamp,renderAlertTable}from"./chunk-GHNHUSVK.js";import{resolveRulesTeam}from"./chunk-J5IDU6YN.js";import{resolveAlertsScope,scopeFromLinkedProject}from"./chunk-WLALGPNL.js";import{formatGranularity}from"./chunk-IVSSTHB6.js";import{outputError}from"./chunk-ZJNDLFZ7.js";import"./chunk-GHAY4PSD.js";import"./chunk-D3M2JG5C.js";import{truncateEnd,truncateMiddle}from"./chunk-TOTTVS5P.js";import{formatDate}from"./chunk-HRR57QNP.js";import"./chunk-GZNDA6SV.js";import"./chunk-PFD7LETF.js";import"./chunk-CJZE7647.js";import{inspectSubcommand}from"./chunk-6FYPSSL4.js";import{printError}from"./chunk-CY5KJ42N.js";import"./chunk-CT77BGSW.js";import{AGENT_REASON,buildCommandWithGlobalFlags,outputAgentError}from"./chunk-PNWRO3XW.js";import"./chunk-DTUEHPME.js";import{getLinkedProject}from"./chunk-EUU3FHCX.js";import"./chunk-M7FED5YP.js";import"./chunk-4HR3I3ML.js";import"./chunk-LOA7SZWH.js";import"./chunk-LUX4PBJL.js";import"./chunk-MTZYPCZ7.js";import"./chunk-OPORM35X.js";import"./chunk-D6REP5QQ.js";import"./chunk-FBYA6LLM.js";import"./chunk-MY4MONOH.js";import"./chunk-7HLAWGY2.js";import"./chunk-MXTC4ZAQ.js";import{parseArguments}from"./chunk-LYL26S3N.js";import"./chunk-2VBFQZ72.js";import{validateJsonOutput}from"./chunk-6GKP6VUF.js";import"./chunk-4NTBYNFR.js";import"./chunk-4SAVH3H7.js";import{isAPIError}from"./chunk-GOI2VVI7.js";import{packageName}from"./chunk-B4KA3ZH2.js";import"./chunk-BOJDM3O7.js";import{output_manager_default}from"./chunk-AP6DZGTK.js";import"./chunk-BLUPZPAS.js";import"./chunk-AW33SRYY.js";import"./chunk-5MDNVAE6.js";import"./chunk-OCR5CRTH.js";import"./chunk-7EJQLVWX.js";import"./chunk-SCV7XEEO.js";import"./chunk-MCYG7CCE.js";import"./chunk-YHPPP3SF.js";import{getFlagsSpecification}from"./chunk-CFJBDBYH.js";import"./chunk-2BKALEOP.js";import{require_source}from"./chunk-NB2WLB3J.js";import"./chunk-ISWW3DKF.js";import"./chunk-BRQUZ5NC.js";import"./chunk-BULSRTQE.js";import{__toESM}from"./chunk-BZENIQ7N.js";var import_chalk=__toESM(require_source(),1);var aggregationLabels={sum:"Sum",avg:"Average",min:"Min",max:"Max",p50:"P50",p75:"P75",p90:"P90",p95:"P95",p99:"P99",stddev:"Std Dev",unique:"Unique",persecond:"Per Second",percent:"Percent"},formatCustomAlertRatioBelowFivePercent=new Intl.NumberFormat("en-US",{maximumFractionDigits:2,minimumFractionDigits:2,style:"percent"}),formatCustomAlertRatioThresholdValue=new Intl.NumberFormat("en-US",{maximumFractionDigits:4,minimumFractionDigits:0,style:"percent"});function getGroupStatus(group){if(group.status)return group.status;let alerts=group.alerts??[];return alerts.some(alert=>alert.status==="active")?"active":alerts.length>0?"resolved":"-"}function humanizeLabel(value){return humanizeReference(value,{case:"title"})}function formatAlertFieldValue(value,maxLength=64){if(value==null)return;let displayValue=typeof value=="number"?formatNumber(value):String(value);if(displayValue)return truncateMiddle(displayValue,maxLength)}function formatNumber(value){let absValue=Math.abs(value),sign=value<0?"-":"";for(let[threshold,suffix]of[[1e9,"B"],[1e6,"M"],[1e3,"k"]])if(absValue>=threshold)return`${sign}${(absValue/threshold).toFixed(1).replace(/\.0$/,"")}${suffix}`;return Number.isInteger(value)?String(value):value.toFixed(2).replace(/\.?0+$/,"")}function parseFormattedNumber(value){let trimmed=value.trim();if(!trimmed)return;let number=Number(trimmed.replace(/,/g,""));return Number.isFinite(number)?number:void 0}function formatRatio(value){if(value.trim().endsWith("%"))return value;let number=parseFormattedNumber(value);if(number===void 0)return value;let percent=number*100;return percent>=5?`${Math.floor(percent)}%`:formatCustomAlertRatioBelowFivePercent.format(number)}function formatRatioThreshold(value){if(value.trim().endsWith("%"))return value;let number=parseFormattedNumber(value);return number===void 0?value:formatCustomAlertRatioThresholdValue.format(number)}function getAlertSonarQuery(alert){return alert.sonarQuery??alert.data?.sonarQuery}function getCustomAlertBaselineTitle(alert){let granularity=getAlertSonarQuery(alert)?.granularity;return(granularity&&("hours"in granularity||"days"in granularity)?"7-day baseline":"24-hour baseline").replace(/\b[a-z]/g,character=>character.toUpperCase())}function appendUnit(value,unit){return!unit||unit==="score"?value:unit==="ratio"?formatRatio(value):unit==="%"?value.endsWith("%")?value:`${value}%`:value.toLowerCase().includes(unit.toLowerCase())?value:`${value} ${unit}`}function formatThreshold(alert){let data=alert.data,formatted=alert.formattedValues?.formattedThreshold??(data?.triggerThreshold===void 0?void 0:formatNumber(data.triggerThreshold));if(!formatted)return;let operator=formatTriggerOperator(data?.triggerOperator),threshold=data?.triggerType==="anomaly"?`${formatted} z-score`:alert.unit==="ratio"?formatRatioThreshold(formatted):appendUnit(formatted,alert.unit);return[operator,threshold].filter(Boolean).join(" ")}function getRuleIds(alert){let ids=new Set,dataRuleId=alert.data?.ruleId;dataRuleId&&ids.add(dataRuleId);for(let ruleId of alert.rules??[])ruleId&&ids.add(ruleId);return[...ids]}function getAlertResolvedAt(alert){return normalizeTimestamp(alert.recordedResolvedAt??alert.resolvedAt)}function getSignalRows(alert){let rows=[],formattedValues=alert.formattedValues??{},observed=formattedValues.formattedCount,baseline=formattedValues.formattedAvg,change=[formattedValues.changeDirection,formattedValues.changeAmount].filter(Boolean).join(" "),zscore=alert.data?.zscore,threshold=formatThreshold(alert),minThreshold=alert.data?.minThreshold,isRatioFormulaAlert=!!getCustomAlertFormula(alert);return alert.eventLabel&&rows.push(["Event",alert.eventLabel]),alert.measureLabel&&rows.push(["Measure",alert.measureLabel]),observed&&rows.push(["Observed Value",appendUnit(observed,alert.unit)]),baseline&&rows.push([alert.type==="custom_alert"&&alert.data?.triggerType==="anomaly"?getCustomAlertBaselineTitle(alert):"Baseline",appendUnit(baseline,alert.unit)]),change&&rows.push(["Change",change]),zscore!==void 0&&rows.push(["Observed Deviation",`${formatNumber(zscore)} z-score`]),threshold&&rows.push(["Threshold",threshold]),minThreshold!==void 0&&!isRatioFormulaAlert&&rows.push(["Minimum",alert.unit==="ratio"?formatNumber(minThreshold):appendUnit(formatNumber(minThreshold),alert.unit)]),formattedValues.errorRate&&rows.push(["Error Rate",formattedValues.errorRate]),formattedValues.avgErrorRate&&rows.push(["Baseline Error Rate",formattedValues.avgErrorRate]),rows.push(...getFieldRows(alert)),rows}function getFieldRows(alert){let fields=alert.data?.fields;if(!fields)return[];let groupBy=getAlertSonarQuery(alert)?.groupBy??[];return[...groupBy,...Object.keys(fields).filter(key=>!groupBy.includes(key))].flatMap(key=>{let value=fields[key],displayValue=formatAlertFieldValue(value);return displayValue?[[humanizeLabel(key),displayValue]]:[]})}function formatAggregation(value){return value?aggregationLabels[value]??humanizeLabel(value):void 0}function formatQueryReference(value){return value?humanizeLabel(value):void 0}function formatRollupDetail(rollup,fallbackMeasure){if(!rollup)return;let aggregation=formatAggregation(rollup.aggregation),measure=fallbackMeasure??formatQueryReference(rollup.measure);return[aggregation,measure].filter(Boolean).join(" ")||void 0}function getPrimaryRollup(rollups){return Object.values(rollups??{})[0]}function getCustomAlertFormula(alert){let formula=alert.data?.formula;if(formula?.operator==="divide"&&formula.left&&formula.right)return{operator:formula.operator,left:formula.left,right:formula.right}}function getQueryRows(alert){if(alert.type!=="custom_alert")return[];let query=getAlertSonarQuery(alert);if(!query)return[];let formula=getCustomAlertFormula(alert),rows=[],addRow=(label,value)=>{value&&rows.push([label,truncateMiddle(value,120)])};if(addRow("Event",alert.eventLabel??formatQueryReference(query.event)),formula)addRow("Numerator",formatRollupDetail(query.rollups?.[formula.left])),addRow("Denominator",formatRollupDetail(query.rollups?.[formula.right]));else{let primaryRollup=getPrimaryRollup(query.rollups);addRow("Measure",alert.measureLabel??formatQueryReference(primaryRollup?.measure)),addRow("Aggregation",formatAggregation(primaryRollup?.aggregation))}addRow("Granularity",formatGranularity(query.granularity));let groupBy=query.groupBy?.filter(Boolean)??[];if(groupBy.length>0&&addRow("Group by",groupBy.map(humanizeLabel).join(", ")),formula&&typeof alert.data?.minThreshold=="number"&&addRow("Minimum Numerator",formatNumber(alert.data.minThreshold)),addRow("Filter by",query.filter?.trim()),formula)for(let[label,rollupName]of[["Numerator filter",formula.left],["Denominator filter",formula.right]])addRow(label,query.rollups?.[rollupName]?.filter?.trim());return rows}function getDetailRows(alert){let data=alert.data;if(!data)return[];let rows=[],addRow=(label,value)=>{let displayValue=formatAlertFieldValue(value);displayValue&&rows.push([label,displayValue])};return addRow("Route",data.route),addRow("Status Group",data.statusGroup),addRow("Deployment ID",data.deploymentId),rows}function renderAlertSections(alert){let lines=[],signalRows=getSignalRows(alert);signalRows.length>0&&(lines.push(import_chalk.default.cyan("Signals")),lines.push(renderAlertTable(signalRows,3)));let queryRows=getQueryRows(alert);return queryRows.length>0&&(lines.push(import_chalk.default.cyan("Query")),lines.push(renderAlertTable(queryRows,3))),lines.join(`
7
+ import{formatTriggerOperator,getGroupStartedAt,getGroupTitle,getGroupType,humanizeReference,normalizeTimestamp,renderAlertTable}from"./chunk-GHNHUSVK.js";import{resolveRulesTeam}from"./chunk-J5IDU6YN.js";import{resolveAlertsScope,scopeFromLinkedProject}from"./chunk-WLALGPNL.js";import{formatGranularity}from"./chunk-IVSSTHB6.js";import"./chunk-GHAY4PSD.js";import{truncateEnd,truncateMiddle}from"./chunk-TOTTVS5P.js";import{outputError}from"./chunk-ZJNDLFZ7.js";import"./chunk-D3M2JG5C.js";import{formatDate}from"./chunk-HRR57QNP.js";import"./chunk-GZNDA6SV.js";import"./chunk-PFD7LETF.js";import"./chunk-CJZE7647.js";import{inspectSubcommand}from"./chunk-6FYPSSL4.js";import{printError}from"./chunk-CY5KJ42N.js";import"./chunk-CT77BGSW.js";import{AGENT_REASON,buildCommandWithGlobalFlags,outputAgentError}from"./chunk-PNWRO3XW.js";import"./chunk-DTUEHPME.js";import{getLinkedProject}from"./chunk-EUU3FHCX.js";import"./chunk-M7FED5YP.js";import"./chunk-4HR3I3ML.js";import"./chunk-LOA7SZWH.js";import"./chunk-LUX4PBJL.js";import"./chunk-MTZYPCZ7.js";import"./chunk-OPORM35X.js";import"./chunk-D6REP5QQ.js";import"./chunk-FBYA6LLM.js";import"./chunk-MY4MONOH.js";import"./chunk-7HLAWGY2.js";import"./chunk-MXTC4ZAQ.js";import{parseArguments}from"./chunk-LYL26S3N.js";import"./chunk-2VBFQZ72.js";import{validateJsonOutput}from"./chunk-6GKP6VUF.js";import"./chunk-4NTBYNFR.js";import"./chunk-4SAVH3H7.js";import{isAPIError}from"./chunk-GOI2VVI7.js";import{packageName}from"./chunk-B4KA3ZH2.js";import"./chunk-BOJDM3O7.js";import{output_manager_default}from"./chunk-AP6DZGTK.js";import"./chunk-BLUPZPAS.js";import"./chunk-AW33SRYY.js";import"./chunk-5MDNVAE6.js";import"./chunk-OCR5CRTH.js";import"./chunk-7EJQLVWX.js";import"./chunk-SCV7XEEO.js";import"./chunk-MCYG7CCE.js";import"./chunk-YHPPP3SF.js";import{getFlagsSpecification}from"./chunk-CFJBDBYH.js";import"./chunk-2BKALEOP.js";import{require_source}from"./chunk-NB2WLB3J.js";import"./chunk-ISWW3DKF.js";import"./chunk-BRQUZ5NC.js";import"./chunk-BULSRTQE.js";import{__toESM}from"./chunk-BZENIQ7N.js";var import_chalk=__toESM(require_source(),1);var aggregationLabels={sum:"Sum",avg:"Average",min:"Min",max:"Max",p50:"P50",p75:"P75",p90:"P90",p95:"P95",p99:"P99",stddev:"Std Dev",unique:"Unique",persecond:"Per Second",percent:"Percent"},formatCustomAlertRatioBelowFivePercent=new Intl.NumberFormat("en-US",{maximumFractionDigits:2,minimumFractionDigits:2,style:"percent"}),formatCustomAlertRatioThresholdValue=new Intl.NumberFormat("en-US",{maximumFractionDigits:4,minimumFractionDigits:0,style:"percent"});function getGroupStatus(group){if(group.status)return group.status;let alerts=group.alerts??[];return alerts.some(alert=>alert.status==="active")?"active":alerts.length>0?"resolved":"-"}function humanizeLabel(value){return humanizeReference(value,{case:"title"})}function formatAlertFieldValue(value,maxLength=64){if(value==null)return;let displayValue=typeof value=="number"?formatNumber(value):String(value);if(displayValue)return truncateMiddle(displayValue,maxLength)}function formatNumber(value){let absValue=Math.abs(value),sign=value<0?"-":"";for(let[threshold,suffix]of[[1e9,"B"],[1e6,"M"],[1e3,"k"]])if(absValue>=threshold)return`${sign}${(absValue/threshold).toFixed(1).replace(/\.0$/,"")}${suffix}`;return Number.isInteger(value)?String(value):value.toFixed(2).replace(/\.?0+$/,"")}function parseFormattedNumber(value){let trimmed=value.trim();if(!trimmed)return;let number=Number(trimmed.replace(/,/g,""));return Number.isFinite(number)?number:void 0}function formatRatio(value){if(value.trim().endsWith("%"))return value;let number=parseFormattedNumber(value);if(number===void 0)return value;let percent=number*100;return percent>=5?`${Math.floor(percent)}%`:formatCustomAlertRatioBelowFivePercent.format(number)}function formatRatioThreshold(value){if(value.trim().endsWith("%"))return value;let number=parseFormattedNumber(value);return number===void 0?value:formatCustomAlertRatioThresholdValue.format(number)}function getAlertSonarQuery(alert){return alert.sonarQuery??alert.data?.sonarQuery}function getCustomAlertBaselineTitle(alert){let granularity=getAlertSonarQuery(alert)?.granularity;return(granularity&&("hours"in granularity||"days"in granularity)?"7-day baseline":"24-hour baseline").replace(/\b[a-z]/g,character=>character.toUpperCase())}function appendUnit(value,unit){return!unit||unit==="score"?value:unit==="ratio"?formatRatio(value):unit==="%"?value.endsWith("%")?value:`${value}%`:value.toLowerCase().includes(unit.toLowerCase())?value:`${value} ${unit}`}function formatThreshold(alert){let data=alert.data,formatted=alert.formattedValues?.formattedThreshold??(data?.triggerThreshold===void 0?void 0:formatNumber(data.triggerThreshold));if(!formatted)return;let operator=formatTriggerOperator(data?.triggerOperator),threshold=data?.triggerType==="anomaly"?`${formatted} z-score`:alert.unit==="ratio"?formatRatioThreshold(formatted):appendUnit(formatted,alert.unit);return[operator,threshold].filter(Boolean).join(" ")}function getRuleIds(alert){let ids=new Set,dataRuleId=alert.data?.ruleId;dataRuleId&&ids.add(dataRuleId);for(let ruleId of alert.rules??[])ruleId&&ids.add(ruleId);return[...ids]}function getAlertResolvedAt(alert){return normalizeTimestamp(alert.recordedResolvedAt??alert.resolvedAt)}function getSignalRows(alert){let rows=[],formattedValues=alert.formattedValues??{},observed=formattedValues.formattedCount,baseline=formattedValues.formattedAvg,change=[formattedValues.changeDirection,formattedValues.changeAmount].filter(Boolean).join(" "),zscore=alert.data?.zscore,threshold=formatThreshold(alert),minThreshold=alert.data?.minThreshold,isRatioFormulaAlert=!!getCustomAlertFormula(alert);return alert.eventLabel&&rows.push(["Event",alert.eventLabel]),alert.measureLabel&&rows.push(["Measure",alert.measureLabel]),observed&&rows.push(["Observed Value",appendUnit(observed,alert.unit)]),baseline&&rows.push([alert.type==="custom_alert"&&alert.data?.triggerType==="anomaly"?getCustomAlertBaselineTitle(alert):"Baseline",appendUnit(baseline,alert.unit)]),change&&rows.push(["Change",change]),zscore!==void 0&&rows.push(["Observed Deviation",`${formatNumber(zscore)} z-score`]),threshold&&rows.push(["Threshold",threshold]),minThreshold!==void 0&&!isRatioFormulaAlert&&rows.push(["Minimum",alert.unit==="ratio"?formatNumber(minThreshold):appendUnit(formatNumber(minThreshold),alert.unit)]),formattedValues.errorRate&&rows.push(["Error Rate",formattedValues.errorRate]),formattedValues.avgErrorRate&&rows.push(["Baseline Error Rate",formattedValues.avgErrorRate]),rows.push(...getFieldRows(alert)),rows}function getFieldRows(alert){let fields=alert.data?.fields;if(!fields)return[];let groupBy=getAlertSonarQuery(alert)?.groupBy??[];return[...groupBy,...Object.keys(fields).filter(key=>!groupBy.includes(key))].flatMap(key=>{let value=fields[key],displayValue=formatAlertFieldValue(value);return displayValue?[[humanizeLabel(key),displayValue]]:[]})}function formatAggregation(value){return value?aggregationLabels[value]??humanizeLabel(value):void 0}function formatQueryReference(value){return value?humanizeLabel(value):void 0}function formatRollupDetail(rollup,fallbackMeasure){if(!rollup)return;let aggregation=formatAggregation(rollup.aggregation),measure=fallbackMeasure??formatQueryReference(rollup.measure);return[aggregation,measure].filter(Boolean).join(" ")||void 0}function getPrimaryRollup(rollups){return Object.values(rollups??{})[0]}function getCustomAlertFormula(alert){let formula=alert.data?.formula;if(formula?.operator==="divide"&&formula.left&&formula.right)return{operator:formula.operator,left:formula.left,right:formula.right}}function getQueryRows(alert){if(alert.type!=="custom_alert")return[];let query=getAlertSonarQuery(alert);if(!query)return[];let formula=getCustomAlertFormula(alert),rows=[],addRow=(label,value)=>{value&&rows.push([label,truncateMiddle(value,120)])};if(addRow("Event",alert.eventLabel??formatQueryReference(query.event)),formula)addRow("Numerator",formatRollupDetail(query.rollups?.[formula.left])),addRow("Denominator",formatRollupDetail(query.rollups?.[formula.right]));else{let primaryRollup=getPrimaryRollup(query.rollups);addRow("Measure",alert.measureLabel??formatQueryReference(primaryRollup?.measure)),addRow("Aggregation",formatAggregation(primaryRollup?.aggregation))}addRow("Granularity",formatGranularity(query.granularity));let groupBy=query.groupBy?.filter(Boolean)??[];if(groupBy.length>0&&addRow("Group by",groupBy.map(humanizeLabel).join(", ")),formula&&typeof alert.data?.minThreshold=="number"&&addRow("Minimum Numerator",formatNumber(alert.data.minThreshold)),addRow("Filter by",query.filter?.trim()),formula)for(let[label,rollupName]of[["Numerator filter",formula.left],["Denominator filter",formula.right]])addRow(label,query.rollups?.[rollupName]?.filter?.trim());return rows}function getDetailRows(alert){let data=alert.data;if(!data)return[];let rows=[],addRow=(label,value)=>{let displayValue=formatAlertFieldValue(value);displayValue&&rows.push([label,displayValue])};return addRow("Route",data.route),addRow("Status Group",data.statusGroup),addRow("Deployment ID",data.deploymentId),rows}function renderAlertSections(alert){let lines=[],signalRows=getSignalRows(alert);signalRows.length>0&&(lines.push(import_chalk.default.cyan("Signals")),lines.push(renderAlertTable(signalRows,3)));let queryRows=getQueryRows(alert);return queryRows.length>0&&(lines.push(import_chalk.default.cyan("Query")),lines.push(renderAlertTable(queryRows,3))),lines.join(`
8
8
  `)}function renderAlert(alert,index,totalAlerts){let title=alert.title||`Alert ${index+1}`,ruleIds=getRuleIds(alert),resolvedAt=getAlertResolvedAt(alert),sections=renderAlertSections(alert),summaryRows=[["Alert id",alert.id||"-"],["Type",alert.type||"-"],["Status",alert.status||"-"],["Started At",formatDate(normalizeTimestamp(alert.recordedStartedAt??alert.startedAt))],...resolvedAt!==void 0?[["Resolved At",formatDate(resolvedAt)]]:[],...ruleIds.length>0?[["Rule id",ruleIds.map(id=>truncateMiddle(id,48)).join(", ")]]:[],...getDetailRows(alert)];return[import_chalk.default.bold(totalAlerts>1?`Alert ${index+1}: ${title}`:title),renderAlertTable(summaryRows,3),...sections?[sections]:[]].join(`
9
9
  `)}function printAlertGroup(group,groupId){let alerts=group.alerts??[],singleAlert=alerts.length===1?alerts[0]:void 0,singleAlertRuleIds=singleAlert?getRuleIds(singleAlert):[],singleAlertResolvedAt=singleAlert?getAlertResolvedAt(singleAlert):void 0,summaryRows=[["Title",truncateEnd(getGroupTitle(group),80)],["Group id",group.id||groupId],["Type",getGroupType(group)],["Status",getGroupStatus(group)],["Started At",formatDate(getGroupStartedAt(group))],...singleAlertResolvedAt!==void 0?[["Resolved At",formatDate(singleAlertResolvedAt)]]:[],["Alerts",String(alerts.length)],...singleAlert?.id?[["Alert id",singleAlert.id]]:[],...singleAlertRuleIds.length>0?[["Rule id",singleAlertRuleIds.map(id=>truncateMiddle(id,48)).join(", ")]]:[],...singleAlert?getDetailRows(singleAlert):[]],renderedAlerts=alerts.length>0?alerts.length===1?renderAlertSections(alerts[0]):alerts.map((alert,index)=>renderAlert(alert,index,alerts.length)).join(`
10
10
 
@@ -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{imagePath,repositoryPath}from"./chunk-DFVNL5ML.js";import{emitVcrArgParseError,formatBytes,formatImageReference,formatImageStatus,formatRelativeTime,handleVcrApiError,requireVcrRepositoryAndImageId,resolveVcrScope,validateVcrJsonOutput}from"./chunk-6BN7Y3GF.js";import"./chunk-ZJNDLFZ7.js";import"./chunk-D3M2JG5C.js";import"./chunk-M32HBBPK.js";import"./chunk-GD7AV7BO.js";import{imageInspectSubcommand}from"./chunk-VHSAI6FS.js";import{printError}from"./chunk-CY5KJ42N.js";import"./chunk-CT77BGSW.js";import"./chunk-PNWRO3XW.js";import"./chunk-DTUEHPME.js";import"./chunk-EUU3FHCX.js";import"./chunk-M7FED5YP.js";import"./chunk-4HR3I3ML.js";import"./chunk-LOA7SZWH.js";import"./chunk-LUX4PBJL.js";import"./chunk-MTZYPCZ7.js";import"./chunk-OPORM35X.js";import"./chunk-D6REP5QQ.js";import"./chunk-FBYA6LLM.js";import"./chunk-MY4MONOH.js";import"./chunk-7HLAWGY2.js";import"./chunk-MXTC4ZAQ.js";import{parseArguments}from"./chunk-LYL26S3N.js";import"./chunk-2VBFQZ72.js";import"./chunk-6GKP6VUF.js";import"./chunk-4NTBYNFR.js";import"./chunk-4SAVH3H7.js";import{isAPIError}from"./chunk-GOI2VVI7.js";import"./chunk-B4KA3ZH2.js";import"./chunk-BOJDM3O7.js";import{output_manager_default}from"./chunk-AP6DZGTK.js";import"./chunk-BLUPZPAS.js";import"./chunk-AW33SRYY.js";import"./chunk-5MDNVAE6.js";import"./chunk-OCR5CRTH.js";import"./chunk-7EJQLVWX.js";import"./chunk-SCV7XEEO.js";import"./chunk-MCYG7CCE.js";import"./chunk-YHPPP3SF.js";import{getFlagsSpecification}from"./chunk-CFJBDBYH.js";import"./chunk-2BKALEOP.js";import{require_source}from"./chunk-NB2WLB3J.js";import"./chunk-ISWW3DKF.js";import"./chunk-BRQUZ5NC.js";import"./chunk-BULSRTQE.js";import{__toESM}from"./chunk-BZENIQ7N.js";var import_chalk=__toESM(require_source(),1);function printImage(image,scope,repository){output_manager_default.print(`
7
+ import{imagePath,repositoryPath}from"./chunk-DFVNL5ML.js";import{emitVcrArgParseError,formatBytes,formatImageReference,formatImageStatus,formatRelativeTime,handleVcrApiError,requireVcrRepositoryAndImageId,resolveVcrScope,validateVcrJsonOutput}from"./chunk-6BN7Y3GF.js";import"./chunk-ZJNDLFZ7.js";import"./chunk-M32HBBPK.js";import"./chunk-D3M2JG5C.js";import"./chunk-GD7AV7BO.js";import{imageInspectSubcommand}from"./chunk-VHSAI6FS.js";import{printError}from"./chunk-CY5KJ42N.js";import"./chunk-CT77BGSW.js";import"./chunk-PNWRO3XW.js";import"./chunk-DTUEHPME.js";import"./chunk-EUU3FHCX.js";import"./chunk-M7FED5YP.js";import"./chunk-4HR3I3ML.js";import"./chunk-LOA7SZWH.js";import"./chunk-LUX4PBJL.js";import"./chunk-MTZYPCZ7.js";import"./chunk-OPORM35X.js";import"./chunk-D6REP5QQ.js";import"./chunk-FBYA6LLM.js";import"./chunk-MY4MONOH.js";import"./chunk-7HLAWGY2.js";import"./chunk-MXTC4ZAQ.js";import{parseArguments}from"./chunk-LYL26S3N.js";import"./chunk-2VBFQZ72.js";import"./chunk-6GKP6VUF.js";import"./chunk-4NTBYNFR.js";import"./chunk-4SAVH3H7.js";import{isAPIError}from"./chunk-GOI2VVI7.js";import"./chunk-B4KA3ZH2.js";import"./chunk-BOJDM3O7.js";import{output_manager_default}from"./chunk-AP6DZGTK.js";import"./chunk-BLUPZPAS.js";import"./chunk-AW33SRYY.js";import"./chunk-5MDNVAE6.js";import"./chunk-OCR5CRTH.js";import"./chunk-7EJQLVWX.js";import"./chunk-SCV7XEEO.js";import"./chunk-MCYG7CCE.js";import"./chunk-YHPPP3SF.js";import{getFlagsSpecification}from"./chunk-CFJBDBYH.js";import"./chunk-2BKALEOP.js";import{require_source}from"./chunk-NB2WLB3J.js";import"./chunk-ISWW3DKF.js";import"./chunk-BRQUZ5NC.js";import"./chunk-BULSRTQE.js";import{__toESM}from"./chunk-BZENIQ7N.js";var import_chalk=__toESM(require_source(),1);function printImage(image,scope,repository){output_manager_default.print(`
8
8
  `),output_manager_default.print(` ${import_chalk.default.cyan("ID")} ${image.id}
9
9
  `),output_manager_default.print(` ${import_chalk.default.cyan("Digest")} ${image.manifestDigest}
10
10
  `),output_manager_default.print(` ${import_chalk.default.cyan("Image")} ${formatImageReference(scope.teamSlug,scope.projectName,repository.name,image.manifestDigest)}
@@ -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{repositoryPath}from"./chunk-DFVNL5ML.js";import{emitVcrArgParseError,formatRelativeTime,handleVcrApiError,requireVcrRepository,resolveVcrScope,validateVcrJsonOutput}from"./chunk-6BN7Y3GF.js";import"./chunk-ZJNDLFZ7.js";import"./chunk-D3M2JG5C.js";import"./chunk-M32HBBPK.js";import"./chunk-GD7AV7BO.js";import{inspectSubcommand}from"./chunk-BMIYC2MH.js";import"./chunk-6CJFPT4F.js";import"./chunk-ZZD5W5KT.js";import"./chunk-VHSAI6FS.js";import{printError}from"./chunk-CY5KJ42N.js";import"./chunk-CT77BGSW.js";import"./chunk-PNWRO3XW.js";import"./chunk-DTUEHPME.js";import"./chunk-EUU3FHCX.js";import"./chunk-M7FED5YP.js";import"./chunk-4HR3I3ML.js";import"./chunk-LOA7SZWH.js";import"./chunk-LUX4PBJL.js";import"./chunk-MTZYPCZ7.js";import"./chunk-OPORM35X.js";import"./chunk-D6REP5QQ.js";import"./chunk-FBYA6LLM.js";import"./chunk-MY4MONOH.js";import"./chunk-7HLAWGY2.js";import"./chunk-MXTC4ZAQ.js";import{parseArguments}from"./chunk-LYL26S3N.js";import"./chunk-2VBFQZ72.js";import"./chunk-6GKP6VUF.js";import"./chunk-4NTBYNFR.js";import"./chunk-4SAVH3H7.js";import{isAPIError}from"./chunk-GOI2VVI7.js";import"./chunk-B4KA3ZH2.js";import"./chunk-BOJDM3O7.js";import{output_manager_default}from"./chunk-AP6DZGTK.js";import"./chunk-BLUPZPAS.js";import"./chunk-AW33SRYY.js";import"./chunk-5MDNVAE6.js";import"./chunk-OCR5CRTH.js";import"./chunk-7EJQLVWX.js";import"./chunk-SCV7XEEO.js";import"./chunk-MCYG7CCE.js";import"./chunk-YHPPP3SF.js";import{getFlagsSpecification}from"./chunk-CFJBDBYH.js";import"./chunk-2BKALEOP.js";import{require_source}from"./chunk-NB2WLB3J.js";import"./chunk-ISWW3DKF.js";import"./chunk-BRQUZ5NC.js";import"./chunk-BULSRTQE.js";import{__toESM}from"./chunk-BZENIQ7N.js";var import_chalk=__toESM(require_source(),1);function printRepository(repository){output_manager_default.print(`
7
+ import{repositoryPath}from"./chunk-DFVNL5ML.js";import{emitVcrArgParseError,formatRelativeTime,handleVcrApiError,requireVcrRepository,resolveVcrScope,validateVcrJsonOutput}from"./chunk-6BN7Y3GF.js";import"./chunk-ZJNDLFZ7.js";import"./chunk-M32HBBPK.js";import"./chunk-D3M2JG5C.js";import"./chunk-GD7AV7BO.js";import{inspectSubcommand}from"./chunk-BMIYC2MH.js";import"./chunk-6CJFPT4F.js";import"./chunk-ZZD5W5KT.js";import"./chunk-VHSAI6FS.js";import{printError}from"./chunk-CY5KJ42N.js";import"./chunk-CT77BGSW.js";import"./chunk-PNWRO3XW.js";import"./chunk-DTUEHPME.js";import"./chunk-EUU3FHCX.js";import"./chunk-M7FED5YP.js";import"./chunk-4HR3I3ML.js";import"./chunk-LOA7SZWH.js";import"./chunk-LUX4PBJL.js";import"./chunk-MTZYPCZ7.js";import"./chunk-OPORM35X.js";import"./chunk-D6REP5QQ.js";import"./chunk-FBYA6LLM.js";import"./chunk-MY4MONOH.js";import"./chunk-7HLAWGY2.js";import"./chunk-MXTC4ZAQ.js";import{parseArguments}from"./chunk-LYL26S3N.js";import"./chunk-2VBFQZ72.js";import"./chunk-6GKP6VUF.js";import"./chunk-4NTBYNFR.js";import"./chunk-4SAVH3H7.js";import{isAPIError}from"./chunk-GOI2VVI7.js";import"./chunk-B4KA3ZH2.js";import"./chunk-BOJDM3O7.js";import{output_manager_default}from"./chunk-AP6DZGTK.js";import"./chunk-BLUPZPAS.js";import"./chunk-AW33SRYY.js";import"./chunk-5MDNVAE6.js";import"./chunk-OCR5CRTH.js";import"./chunk-7EJQLVWX.js";import"./chunk-SCV7XEEO.js";import"./chunk-MCYG7CCE.js";import"./chunk-YHPPP3SF.js";import{getFlagsSpecification}from"./chunk-CFJBDBYH.js";import"./chunk-2BKALEOP.js";import{require_source}from"./chunk-NB2WLB3J.js";import"./chunk-ISWW3DKF.js";import"./chunk-BRQUZ5NC.js";import"./chunk-BULSRTQE.js";import{__toESM}from"./chunk-BZENIQ7N.js";var import_chalk=__toESM(require_source(),1);function printRepository(repository){output_manager_default.print(`
8
8
  `),output_manager_default.print(` ${import_chalk.default.cyan("Name")} ${repository.name}
9
9
  `),output_manager_default.print(` ${import_chalk.default.cyan("ID")} ${repository.id}
10
10
  `),output_manager_default.print(` ${import_chalk.default.cyan("Project ID")} ${repository.projectId}
@@ -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{handleValidationError,normalizeRepeatableStringFilters,outputError,validateAllProjectMutualExclusivity,validateIntegerRangeWithDefault,validateTimeBound,validateTimeOrder}from"./chunk-ZJNDLFZ7.js";import"./chunk-D3M2JG5C.js";import{INVALID_NEXT_MESSAGE,parseNumericCursor}from"./chunk-C6GY2G73.js";import{getCommandFlags}from"./chunk-XGTKHQTT.js";import{printNextPageCommand}from"./chunk-D44WCAOX.js";import{activityCommand}from"./chunk-UDZJCD5W.js";import{printError}from"./chunk-CY5KJ42N.js";import{getScope}from"./chunk-CT77BGSW.js";import"./chunk-PNWRO3XW.js";import"./chunk-DTUEHPME.js";import{getLinkedProject}from"./chunk-EUU3FHCX.js";import"./chunk-M7FED5YP.js";import"./chunk-4HR3I3ML.js";import{getProjectByNameOrId}from"./chunk-LOA7SZWH.js";import"./chunk-LUX4PBJL.js";import"./chunk-MTZYPCZ7.js";import"./chunk-OPORM35X.js";import"./chunk-D6REP5QQ.js";import"./chunk-FBYA6LLM.js";import"./chunk-MY4MONOH.js";import"./chunk-7HLAWGY2.js";import"./chunk-MXTC4ZAQ.js";import{parseArguments}from"./chunk-LYL26S3N.js";import"./chunk-2VBFQZ72.js";import{validateJsonOutput}from"./chunk-6GKP6VUF.js";import"./chunk-4NTBYNFR.js";import"./chunk-4SAVH3H7.js";import{ProjectNotFound,isAPIError}from"./chunk-GOI2VVI7.js";import{getCommandNamePlain}from"./chunk-B4KA3ZH2.js";import"./chunk-BOJDM3O7.js";import{output_manager_default}from"./chunk-AP6DZGTK.js";import"./chunk-BLUPZPAS.js";import"./chunk-AW33SRYY.js";import"./chunk-5MDNVAE6.js";import"./chunk-OCR5CRTH.js";import"./chunk-7EJQLVWX.js";import"./chunk-SCV7XEEO.js";import"./chunk-MCYG7CCE.js";import"./chunk-YHPPP3SF.js";import{getFlagsSpecification}from"./chunk-CFJBDBYH.js";import"./chunk-2BKALEOP.js";import{require_source}from"./chunk-NB2WLB3J.js";import"./chunk-ISWW3DKF.js";import"./chunk-BRQUZ5NC.js";import"./chunk-BULSRTQE.js";import{__toESM}from"./chunk-BZENIQ7N.js";var import_chalk=__toESM(require_source(),1);function validateNext(cursor){let next=parseNumericCursor(cursor);if(next===void 0)return{valid:!0,value:void 0};let date=new Date(next);return Number.isNaN(date.getTime())?{valid:!1,code:"INVALID_NEXT",message:INVALID_NEXT_MESSAGE}:{valid:!0,value:date}}function handleApiError(err,jsonOutput,client){return err.status===403?outputError(client,jsonOutput,"FORBIDDEN","You do not have permission to list activity events. Required permissions: Event: List or OwnEvent: List."):outputError(client,jsonOutput,err.code||"API_ERROR",err.serverMessage||`API error (${err.status}).`)}function formatActor(event){let principal=event.principal;return principal?principal.type==="system"?"system":principal.username?principal.username:principal.name?principal.name:principal.slug?principal.slug:principal.email?principal.email:event.principalId||"-":event.principalId||"-"}function formatTimestamp(createdAt){if(!Number.isFinite(createdAt)||createdAt<=0)return"-";let date=new Date(createdAt);return Number.isNaN(date.getTime())?"-":date.toISOString()}function formatEventText(text){return text.replace(/\s+/g," ").trim()}function printExpandedEvents(events){let lines=[""];events.forEach(event=>{lines.push(`${import_chalk.default.gray("-")} ${formatEventText(event.text)}`),lines.push(` ${import_chalk.default.cyan("Type".padEnd(14))}${event.type??"-"}`),lines.push(` ${import_chalk.default.cyan("Actor".padEnd(14))}${formatActor(event)}`),lines.push(` ${import_chalk.default.cyan("Timestamp".padEnd(14))}${formatTimestamp(event.createdAt)}`),lines.push(` ${import_chalk.default.cyan("ID".padEnd(14))}${event.id}`),lines.push("")}),output_manager_default.print(`${lines.join(`
7
+ import{handleValidationError,normalizeRepeatableStringFilters,outputError,validateAllProjectMutualExclusivity,validateIntegerRangeWithDefault,validateTimeBound,validateTimeOrder}from"./chunk-ZJNDLFZ7.js";import{INVALID_NEXT_MESSAGE,parseNumericCursor}from"./chunk-C6GY2G73.js";import"./chunk-D3M2JG5C.js";import{getCommandFlags}from"./chunk-XGTKHQTT.js";import{printNextPageCommand}from"./chunk-D44WCAOX.js";import{activityCommand}from"./chunk-UDZJCD5W.js";import{printError}from"./chunk-CY5KJ42N.js";import{getScope}from"./chunk-CT77BGSW.js";import"./chunk-PNWRO3XW.js";import"./chunk-DTUEHPME.js";import{getLinkedProject}from"./chunk-EUU3FHCX.js";import"./chunk-M7FED5YP.js";import"./chunk-4HR3I3ML.js";import{getProjectByNameOrId}from"./chunk-LOA7SZWH.js";import"./chunk-LUX4PBJL.js";import"./chunk-MTZYPCZ7.js";import"./chunk-OPORM35X.js";import"./chunk-D6REP5QQ.js";import"./chunk-FBYA6LLM.js";import"./chunk-MY4MONOH.js";import"./chunk-7HLAWGY2.js";import"./chunk-MXTC4ZAQ.js";import{parseArguments}from"./chunk-LYL26S3N.js";import"./chunk-2VBFQZ72.js";import{validateJsonOutput}from"./chunk-6GKP6VUF.js";import"./chunk-4NTBYNFR.js";import"./chunk-4SAVH3H7.js";import{ProjectNotFound,isAPIError}from"./chunk-GOI2VVI7.js";import{getCommandNamePlain}from"./chunk-B4KA3ZH2.js";import"./chunk-BOJDM3O7.js";import{output_manager_default}from"./chunk-AP6DZGTK.js";import"./chunk-BLUPZPAS.js";import"./chunk-AW33SRYY.js";import"./chunk-5MDNVAE6.js";import"./chunk-OCR5CRTH.js";import"./chunk-7EJQLVWX.js";import"./chunk-SCV7XEEO.js";import"./chunk-MCYG7CCE.js";import"./chunk-YHPPP3SF.js";import{getFlagsSpecification}from"./chunk-CFJBDBYH.js";import"./chunk-2BKALEOP.js";import{require_source}from"./chunk-NB2WLB3J.js";import"./chunk-ISWW3DKF.js";import"./chunk-BRQUZ5NC.js";import"./chunk-BULSRTQE.js";import{__toESM}from"./chunk-BZENIQ7N.js";var import_chalk=__toESM(require_source(),1);function validateNext(cursor){let next=parseNumericCursor(cursor);if(next===void 0)return{valid:!0,value:void 0};let date=new Date(next);return Number.isNaN(date.getTime())?{valid:!1,code:"INVALID_NEXT",message:INVALID_NEXT_MESSAGE}:{valid:!0,value:date}}function handleApiError(err,jsonOutput,client){return err.status===403?outputError(client,jsonOutput,"FORBIDDEN","You do not have permission to list activity events. Required permissions: Event: List or OwnEvent: List."):outputError(client,jsonOutput,err.code||"API_ERROR",err.serverMessage||`API error (${err.status}).`)}function formatActor(event){let principal=event.principal;return principal?principal.type==="system"?"system":principal.username?principal.username:principal.name?principal.name:principal.slug?principal.slug:principal.email?principal.email:event.principalId||"-":event.principalId||"-"}function formatTimestamp(createdAt){if(!Number.isFinite(createdAt)||createdAt<=0)return"-";let date=new Date(createdAt);return Number.isNaN(date.getTime())?"-":date.toISOString()}function formatEventText(text){return text.replace(/\s+/g," ").trim()}function printExpandedEvents(events){let lines=[""];events.forEach(event=>{lines.push(`${import_chalk.default.gray("-")} ${formatEventText(event.text)}`),lines.push(` ${import_chalk.default.cyan("Type".padEnd(14))}${event.type??"-"}`),lines.push(` ${import_chalk.default.cyan("Actor".padEnd(14))}${formatActor(event)}`),lines.push(` ${import_chalk.default.cyan("Timestamp".padEnd(14))}${formatTimestamp(event.createdAt)}`),lines.push(` ${import_chalk.default.cyan("ID".padEnd(14))}${event.id}`),lines.push("")}),output_manager_default.print(`${lines.join(`
8
8
  `)}
9
9
  `)}function trackTelemetry(flags,types,telemetry){telemetry.trackCliOptionType(types.length>0?types:void 0),telemetry.trackCliOptionSince(flags["--since"]),telemetry.trackCliOptionUntil(flags["--until"]),telemetry.trackCliOptionProject(flags["--project"]),telemetry.trackCliFlagAll(flags["--all"]),telemetry.trackCliOptionLimit(flags["--limit"]),telemetry.trackCliOptionNext(flags["--next"]),telemetry.trackCliOptionFormat(flags["--format"])}function parseFlags(client){let flagsSpecification=getFlagsSpecification(activityCommand.options);try{return parseArguments(client.argv.slice(2),flagsSpecification).flags}catch(err){return printError(err),2}}function resolveValidatedInputs(flags,jsonOutput,client,normalizedTypes){let limitResult=validateIntegerRangeWithDefault(flags["--limit"],{flag:"--limit",min:1,max:100,defaultValue:20});if(!limitResult.valid)return handleValidationError(limitResult,jsonOutput,client);let mutualResult=validateAllProjectMutualExclusivity(flags["--all"],flags["--project"]);if(!mutualResult.valid)return handleValidationError(mutualResult,jsonOutput,client);let sinceResult=validateTimeBound(flags["--since"]);if(!sinceResult.valid)return handleValidationError(sinceResult,jsonOutput,client);let nextResult=validateNext(flags["--next"]);if(!nextResult.valid)return handleValidationError(nextResult,jsonOutput,client);let until=nextResult.value;if(!until){let untilResult=validateTimeBound(flags["--until"]);if(!untilResult.valid)return handleValidationError(untilResult,jsonOutput,client);until=untilResult.value}let since=sinceResult.value,timeOrderResult=validateTimeOrder(since,until);return timeOrderResult.valid?{limit:limitResult.value,types:normalizedTypes,since,until}:handleValidationError(timeOrderResult,jsonOutput,client)}async function resolveScope(client,opts){if(opts.all||opts.project){let{team}=await getScope(client);if(!team)return outputError(client,opts.jsonOutput,"NO_TEAM","No team context found. Run `vercel switch` to select a team, or use `vercel link` in a project directory.");if(opts.all)return{teamId:team.id,teamSlug:team.slug};let projectResult;try{projectResult=await getProjectByNameOrId(client,opts.project,team.id)}catch(err){if(isAPIError(err))return outputError(client,opts.jsonOutput,err.code||"API_ERROR",err.serverMessage||(err.status===403?`You do not have permission to access project "${opts.project}" in team "${team.slug}".`:`API error (${err.status}).`));throw err}return projectResult instanceof ProjectNotFound?outputError(client,opts.jsonOutput,"PROJECT_NOT_FOUND",`Project "${opts.project}" was not found in team "${team.slug}".`):{teamId:team.id,teamSlug:team.slug,projectIds:[projectResult.id],projectName:projectResult.name}}let linkedProject=await getLinkedProject(client);if(linkedProject.status==="error")return linkedProject.exitCode;if(linkedProject.status==="not_linked")return outputError(client,opts.jsonOutput,"NOT_LINKED","No linked project found. Run `vercel link` to link a project, or use --project <name> or --all.");let isTeamProject=linkedProject.org.type==="team";return{projectIds:[linkedProject.project.id],projectName:linkedProject.project.name,teamId:isTeamProject?linkedProject.org.id:void 0,teamSlug:isTeamProject?linkedProject.org.slug:void 0}}function buildEventsQuery(params){let query=new URLSearchParams({limit:String(params.limit+1)});return params.types.length>0&&query.set("types",params.types.join(",")),params.since&&query.set("since",params.since.toISOString()),params.until&&query.set("until",params.until.toISOString()),params.scope.projectIds&&params.scope.projectIds.length>0&&query.set("projectIds",params.scope.projectIds.join(",")),params.scope.teamId&&query.set("teamId",params.scope.teamId),params.scope.teamSlug&&query.set("slug",params.scope.teamSlug),params.jsonOutput&&query.set("withPayload","true"),query}function paginateEvents(allEvents,limit){let events=allEvents.slice(0,limit),hasMore=allEvents.length>limit,lastVisibleEvent=events[events.length-1],next=hasMore&&typeof lastVisibleEvent?.createdAt=="number"?lastVisibleEvent.createdAt-1:null;return{events,next}}function printScopeHeader(scope){!scope.projectName&&scope.teamSlug?output_manager_default.log(`Showing all activity for team ${import_chalk.default.bold(scope.teamSlug)}`):scope.projectName&&scope.teamSlug?output_manager_default.log(`Showing activity for project ${import_chalk.default.bold(scope.projectName)} in team ${import_chalk.default.bold(scope.teamSlug)}`):scope.projectName&&output_manager_default.log(`Showing activity for project ${import_chalk.default.bold(scope.projectName)}`)}function printNextPageHint(flags,next){let commandFlags=getCommandFlags(flags,["--next"]);printNextPageCommand(getCommandNamePlain(`activity${commandFlags} --next ${next}`))}async function list(client,telemetry){let flags=parseFlags(client);if(typeof flags=="number")return flags;let formatResult=validateJsonOutput(flags);if(!formatResult.valid)return output_manager_default.error(formatResult.error),2;let jsonOutput=formatResult.jsonOutput,normalizedTypes=normalizeRepeatableStringFilters(flags["--type"]);trackTelemetry(flags,normalizedTypes,telemetry);let validatedInputs=resolveValidatedInputs(flags,jsonOutput,client,normalizedTypes);if(typeof validatedInputs=="number")return validatedInputs;let scope=await resolveScope(client,{project:flags["--project"],all:flags["--all"],jsonOutput});if(typeof scope=="number")return scope;let query=buildEventsQuery({limit:validatedInputs.limit,types:validatedInputs.types,since:validatedInputs.since,until:validatedInputs.until,scope,jsonOutput});output_manager_default.spinner("Fetching activity...");try{let response=await client.fetch(`/v3/events?${query.toString()}`,{useCurrentTeam:!1}),allEvents=Array.isArray(response.events)?response.events:[],{events,next}=paginateEvents(allEvents,validatedInputs.limit);if(jsonOutput){let jsonResponse={...(scope.teamSlug||scope.projectName)&&{scope:{...scope.teamSlug&&{teamSlug:scope.teamSlug},...scope.projectName&&{projectName:scope.projectName},...scope.projectIds&&{projectIds:scope.projectIds}}},events,pagination:{next}};return client.stdout.write(`${JSON.stringify(jsonResponse,null,2)}
10
10
  `),0}return printScopeHeader(scope),events.length===0?(output_manager_default.log("No activity events found."),0):(printExpandedEvents(events),next!==null&&printNextPageHint(flags,next),0)}catch(err){if(isAPIError(err))return handleApiError(err,jsonOutput,client);throw err}finally{output_manager_default.stopSpinner()}}export{list as default};
@@ -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{getGroupStartedAt,getGroupTitle,getGroupType,normalizeTimestamp,renderAlertTable}from"./chunk-GHNHUSVK.js";import{resolveAlertsScope}from"./chunk-WLALGPNL.js";import{handleValidationError,normalizeRepeatableStringFilters,outputError,validateAllProjectMutualExclusivity,validateOptionalIntegerRange,validateTimeBound,validateTimeOrder}from"./chunk-ZJNDLFZ7.js";import"./chunk-GHAY4PSD.js";import"./chunk-D3M2JG5C.js";import{truncateEnd}from"./chunk-TOTTVS5P.js";import{formatDate}from"./chunk-HRR57QNP.js";import"./chunk-GZNDA6SV.js";import"./chunk-PFD7LETF.js";import"./chunk-CJZE7647.js";import{alertsCommand}from"./chunk-6FYPSSL4.js";import{printError}from"./chunk-CY5KJ42N.js";import"./chunk-CT77BGSW.js";import{AGENT_REASON,buildCommandWithGlobalFlags,outputAgentError,shouldEmitNonInteractiveCommandError}from"./chunk-PNWRO3XW.js";import"./chunk-DTUEHPME.js";import"./chunk-EUU3FHCX.js";import"./chunk-M7FED5YP.js";import"./chunk-4HR3I3ML.js";import"./chunk-LOA7SZWH.js";import"./chunk-LUX4PBJL.js";import"./chunk-MTZYPCZ7.js";import"./chunk-OPORM35X.js";import"./chunk-D6REP5QQ.js";import"./chunk-FBYA6LLM.js";import"./chunk-MY4MONOH.js";import"./chunk-7HLAWGY2.js";import{require_ms}from"./chunk-MXTC4ZAQ.js";import{parseArguments}from"./chunk-LYL26S3N.js";import"./chunk-2VBFQZ72.js";import{validateJsonOutput}from"./chunk-6GKP6VUF.js";import"./chunk-4NTBYNFR.js";import"./chunk-4SAVH3H7.js";import{isAPIError}from"./chunk-GOI2VVI7.js";import"./chunk-B4KA3ZH2.js";import"./chunk-BOJDM3O7.js";import{output_manager_default}from"./chunk-AP6DZGTK.js";import"./chunk-BLUPZPAS.js";import"./chunk-AW33SRYY.js";import"./chunk-5MDNVAE6.js";import"./chunk-OCR5CRTH.js";import"./chunk-7EJQLVWX.js";import"./chunk-SCV7XEEO.js";import"./chunk-MCYG7CCE.js";import"./chunk-YHPPP3SF.js";import{getFlagsSpecification}from"./chunk-CFJBDBYH.js";import"./chunk-2BKALEOP.js";import{require_source}from"./chunk-NB2WLB3J.js";import"./chunk-ISWW3DKF.js";import"./chunk-BRQUZ5NC.js";import"./chunk-BULSRTQE.js";import{__toESM}from"./chunk-BZENIQ7N.js";var import_ms=__toESM(require_ms(),1),import_chalk=__toESM(require_source(),1);function handleApiError(err,jsonOutput,client){let message=err.status===401||err.status===403?"You do not have access to alerts in this scope. Pass --token <TOKEN> and --scope <team-slug> with Alerts read access.":err.status>=500?`The alerts endpoint failed on the server (${err.status}). Re-run with --debug and share the x-vercel-id from the failed request.`:err.serverMessage||`API error (${err.status}).`,reason=err.status===401?"not_authorized":err.status===403?"forbidden":err.status===404?AGENT_REASON.NOT_FOUND:err.status===429?"rate_limited":AGENT_REASON.API_ERROR;return outputAgentError(client,{status:"error",reason,message,...err.status===401||err.status===403?{hint:"Confirm team scope; use --scope <team-slug> if alerts belong to another team.",next:[{command:buildCommandWithGlobalFlags(client.argv,"whoami"),when:"See current user and team"},{command:buildCommandWithGlobalFlags(client.argv,"alerts"),when:"Retry listing alerts after fixing scope or permissions"}]}:{}},1),outputError(client,jsonOutput,err.code||"API_ERROR",message)}function getDefaultRange(){let to=new Date;return{from:new Date(to.getTime()-24*60*60*1e3).toISOString(),to:to.toISOString()}}function getStartedAt(group){return formatDate(getGroupStartedAt(group))}function getGroupResolvedAt(group){let resolvedTimes=(group.alerts??[]).map(alert=>normalizeTimestamp(alert.recordedResolvedAt??alert.resolvedAt)).filter(time=>time!==void 0);if(resolvedTimes.length>0)return Math.max(...resolvedTimes)}function getStatus(group){let normalizedStatus=(group.status||"").toLowerCase();if(normalizedStatus==="active")return"active";if(normalizedStatus==="resolved"){let startedAt=getGroupStartedAt(group),resolvedAt=getGroupResolvedAt(group);return startedAt&&resolvedAt&&resolvedAt>=startedAt?`resolved after ${(0,import_ms.default)(resolvedAt-startedAt)}`:"resolved"}return group.status||"-"}function getResolvedAt(group){return(group.status||"").toLowerCase()==="active"?"active":formatDate(getGroupResolvedAt(group))}function getAlertsCount(group){return String(group.alerts?.length??0)}function validationFailureForAgents(client,result,jsonOutput){return shouldEmitNonInteractiveCommandError(client)&&outputAgentError(client,{status:"error",reason:AGENT_REASON.INVALID_ARGUMENTS,message:result.message,next:[{command:buildCommandWithGlobalFlags(client.argv,"alerts --help"),when:"See valid `alerts` list options and examples"}]},2),handleValidationError(result,jsonOutput,client)}function printGroups(groups){if(groups.length===0){output_manager_default.log("No alerts found.");return}let rows=[["Title","Group id","Started At","Type","Status","Alerts"].map(h=>import_chalk.default.cyan(h)),...groups.map(group=>{let row=[import_chalk.default.bold(truncateEnd(getGroupTitle(group),80)),import_chalk.default.dim(group.id||"-"),getStartedAt(group),getGroupType(group)];return row.push(getStatus(group),getAlertsCount(group)),row})];output_manager_default.print(`
7
+ import{getGroupStartedAt,getGroupTitle,getGroupType,normalizeTimestamp,renderAlertTable}from"./chunk-GHNHUSVK.js";import{resolveAlertsScope}from"./chunk-WLALGPNL.js";import"./chunk-GHAY4PSD.js";import{truncateEnd}from"./chunk-TOTTVS5P.js";import{handleValidationError,normalizeRepeatableStringFilters,outputError,validateAllProjectMutualExclusivity,validateOptionalIntegerRange,validateTimeBound,validateTimeOrder}from"./chunk-ZJNDLFZ7.js";import"./chunk-D3M2JG5C.js";import{formatDate}from"./chunk-HRR57QNP.js";import"./chunk-GZNDA6SV.js";import"./chunk-PFD7LETF.js";import"./chunk-CJZE7647.js";import{alertsCommand}from"./chunk-6FYPSSL4.js";import{printError}from"./chunk-CY5KJ42N.js";import"./chunk-CT77BGSW.js";import{AGENT_REASON,buildCommandWithGlobalFlags,outputAgentError,shouldEmitNonInteractiveCommandError}from"./chunk-PNWRO3XW.js";import"./chunk-DTUEHPME.js";import"./chunk-EUU3FHCX.js";import"./chunk-M7FED5YP.js";import"./chunk-4HR3I3ML.js";import"./chunk-LOA7SZWH.js";import"./chunk-LUX4PBJL.js";import"./chunk-MTZYPCZ7.js";import"./chunk-OPORM35X.js";import"./chunk-D6REP5QQ.js";import"./chunk-FBYA6LLM.js";import"./chunk-MY4MONOH.js";import"./chunk-7HLAWGY2.js";import{require_ms}from"./chunk-MXTC4ZAQ.js";import{parseArguments}from"./chunk-LYL26S3N.js";import"./chunk-2VBFQZ72.js";import{validateJsonOutput}from"./chunk-6GKP6VUF.js";import"./chunk-4NTBYNFR.js";import"./chunk-4SAVH3H7.js";import{isAPIError}from"./chunk-GOI2VVI7.js";import"./chunk-B4KA3ZH2.js";import"./chunk-BOJDM3O7.js";import{output_manager_default}from"./chunk-AP6DZGTK.js";import"./chunk-BLUPZPAS.js";import"./chunk-AW33SRYY.js";import"./chunk-5MDNVAE6.js";import"./chunk-OCR5CRTH.js";import"./chunk-7EJQLVWX.js";import"./chunk-SCV7XEEO.js";import"./chunk-MCYG7CCE.js";import"./chunk-YHPPP3SF.js";import{getFlagsSpecification}from"./chunk-CFJBDBYH.js";import"./chunk-2BKALEOP.js";import{require_source}from"./chunk-NB2WLB3J.js";import"./chunk-ISWW3DKF.js";import"./chunk-BRQUZ5NC.js";import"./chunk-BULSRTQE.js";import{__toESM}from"./chunk-BZENIQ7N.js";var import_ms=__toESM(require_ms(),1),import_chalk=__toESM(require_source(),1);function handleApiError(err,jsonOutput,client){let message=err.status===401||err.status===403?"You do not have access to alerts in this scope. Pass --token <TOKEN> and --scope <team-slug> with Alerts read access.":err.status>=500?`The alerts endpoint failed on the server (${err.status}). Re-run with --debug and share the x-vercel-id from the failed request.`:err.serverMessage||`API error (${err.status}).`,reason=err.status===401?"not_authorized":err.status===403?"forbidden":err.status===404?AGENT_REASON.NOT_FOUND:err.status===429?"rate_limited":AGENT_REASON.API_ERROR;return outputAgentError(client,{status:"error",reason,message,...err.status===401||err.status===403?{hint:"Confirm team scope; use --scope <team-slug> if alerts belong to another team.",next:[{command:buildCommandWithGlobalFlags(client.argv,"whoami"),when:"See current user and team"},{command:buildCommandWithGlobalFlags(client.argv,"alerts"),when:"Retry listing alerts after fixing scope or permissions"}]}:{}},1),outputError(client,jsonOutput,err.code||"API_ERROR",message)}function getDefaultRange(){let to=new Date;return{from:new Date(to.getTime()-24*60*60*1e3).toISOString(),to:to.toISOString()}}function getStartedAt(group){return formatDate(getGroupStartedAt(group))}function getGroupResolvedAt(group){let resolvedTimes=(group.alerts??[]).map(alert=>normalizeTimestamp(alert.recordedResolvedAt??alert.resolvedAt)).filter(time=>time!==void 0);if(resolvedTimes.length>0)return Math.max(...resolvedTimes)}function getStatus(group){let normalizedStatus=(group.status||"").toLowerCase();if(normalizedStatus==="active")return"active";if(normalizedStatus==="resolved"){let startedAt=getGroupStartedAt(group),resolvedAt=getGroupResolvedAt(group);return startedAt&&resolvedAt&&resolvedAt>=startedAt?`resolved after ${(0,import_ms.default)(resolvedAt-startedAt)}`:"resolved"}return group.status||"-"}function getResolvedAt(group){return(group.status||"").toLowerCase()==="active"?"active":formatDate(getGroupResolvedAt(group))}function getAlertsCount(group){return String(group.alerts?.length??0)}function validationFailureForAgents(client,result,jsonOutput){return shouldEmitNonInteractiveCommandError(client)&&outputAgentError(client,{status:"error",reason:AGENT_REASON.INVALID_ARGUMENTS,message:result.message,next:[{command:buildCommandWithGlobalFlags(client.argv,"alerts --help"),when:"See valid `alerts` list options and examples"}]},2),handleValidationError(result,jsonOutput,client)}function printGroups(groups){if(groups.length===0){output_manager_default.log("No alerts found.");return}let rows=[["Title","Group id","Started At","Type","Status","Alerts"].map(h=>import_chalk.default.cyan(h)),...groups.map(group=>{let row=[import_chalk.default.bold(truncateEnd(getGroupTitle(group),80)),import_chalk.default.dim(group.id||"-"),getStartedAt(group),getGroupType(group)];return row.push(getStatus(group),getAlertsCount(group)),row})];output_manager_default.print(`
8
8
  ${renderAlertTable(rows,3)}
9
9
  `)}function printAiSections(groups){if(groups.length===0){output_manager_default.log("No alerts found.");return}let rendered=groups.map(group=>{let title=getGroupTitle(group),summary=group.ai?.currentSummary||"N/A",findings=group.ai?.keyFindings?.filter(Boolean)??[],findingsOutput=findings.length>0?findings.map(finding=>` - ${finding}`).join(`
10
10
  `):" - N/A";return[import_chalk.default.bold(title),` ${import_chalk.default.cyan("Resolved At:")} ${getResolvedAt(group)}`,` ${import_chalk.default.cyan("Summary:")} ${summary}`,` ${import_chalk.default.cyan("Key Findings:")}`,findingsOutput].join(`
@@ -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{renderThreadRow}from"./chunk-YRKW42CD.js";import{handleCommentsParseError,inferBranch,listThreads,resolveCommentsScope}from"./chunk-CMFG6TYZ.js";import{applyDeprecatedGitBranchFlag}from"./chunk-UE3YVFFX.js";import{handleValidationError,outputError,validateIntegerRangeWithDefault}from"./chunk-ZJNDLFZ7.js";import"./chunk-AKOYIH3A.js";import"./chunk-D3M2JG5C.js";import"./chunk-TOTTVS5P.js";import"./chunk-QJY3QFK6.js";import"./chunk-C64AK7SW.js";import{getRenamedOption,withWarnings}from"./chunk-FSZJSIOF.js";import{printNextPageCommand}from"./chunk-D44WCAOX.js";import{listSubcommand}from"./chunk-XECELSF5.js";import"./chunk-CY5KJ42N.js";import{getScope}from"./chunk-CT77BGSW.js";import"./chunk-PNWRO3XW.js";import"./chunk-DTUEHPME.js";import"./chunk-EUU3FHCX.js";import"./chunk-M7FED5YP.js";import"./chunk-4HR3I3ML.js";import"./chunk-LOA7SZWH.js";import"./chunk-LUX4PBJL.js";import"./chunk-MTZYPCZ7.js";import"./chunk-OPORM35X.js";import"./chunk-D6REP5QQ.js";import"./chunk-FBYA6LLM.js";import"./chunk-MY4MONOH.js";import"./chunk-7HLAWGY2.js";import"./chunk-MXTC4ZAQ.js";import{parseArguments}from"./chunk-LYL26S3N.js";import"./chunk-2VBFQZ72.js";import{validateJsonOutput}from"./chunk-6GKP6VUF.js";import"./chunk-4NTBYNFR.js";import"./chunk-4SAVH3H7.js";import{isAPIError}from"./chunk-GOI2VVI7.js";import{getCommandName,getCommandNamePlain}from"./chunk-B4KA3ZH2.js";import"./chunk-BOJDM3O7.js";import{output_manager_default}from"./chunk-AP6DZGTK.js";import"./chunk-BLUPZPAS.js";import"./chunk-AW33SRYY.js";import"./chunk-5MDNVAE6.js";import"./chunk-OCR5CRTH.js";import"./chunk-7EJQLVWX.js";import"./chunk-SCV7XEEO.js";import"./chunk-MCYG7CCE.js";import"./chunk-YHPPP3SF.js";import{getFlagsSpecification,stripSensitiveAuthArgs}from"./chunk-CFJBDBYH.js";import"./chunk-2BKALEOP.js";import{require_source}from"./chunk-NB2WLB3J.js";import"./chunk-ISWW3DKF.js";import"./chunk-BRQUZ5NC.js";import"./chunk-BULSRTQE.js";import{__toESM}from"./chunk-BZENIQ7N.js";var import_chalk=__toESM(require_source(),1);function validateStatus(value){let status=value??"unresolved";if(["unresolved","resolved","all"].includes(status))return status}async function resolveAuthors(client,authors,jsonOutput){if(!authors||authors.length===0)return;if(!authors.includes("me"))return authors;let{user}=await getScope(client);return user?authors.map(author=>author==="me"?user.id:author):outputError(client,jsonOutput,"USER_REQUIRED","Can't resolve `--author me` when authenticated as an app. Use an author ID with `--author`, or authenticate with a user token.")}function statusWord(status){return status==="all"?"":` ${status}`}function printActiveFilters(flags){let parts=[];flags["--author"]?.length&&parts.push(`--author ${flags["--author"].join(", ")} (takes a user ID or \`me\` \u2014 usernames match nothing)`);let pagePaths=flags["--page-path"]??flags["--page"];pagePaths?.length&&parts.push(`--page-path ${pagePaths.join(", ")}`),flags["--query"]&&parts.push(`--query ${flags["--query"]}`),flags["--content"]?.length&&parts.push(`--content ${flags["--content"].join(", ")}`),parts.length>0&&output_manager_default.log(`Filters: ${parts.join(" \xB7 ")}`)}function countLine(count,status){return`${count}${statusWord(status)} comment${count===1?"":"s"}`}var SCOPE_FLAG_NAMES=new Set(["--scope","-S","--project","-p","--team","-T"]);function argvFlagTokens(client){return stripSensitiveAuthArgs(client.argv.slice(3))}function scopeFlagsSuffix(client){let tokens=argvFlagTokens(client),out=[];for(let i=0;i<tokens.length;i++){let token=tokens[i],name=token.split("=")[0];SCOPE_FLAG_NAMES.has(name)&&(out.push(token),!token.includes("=")&&i+1<tokens.length&&out.push(tokens[++i]))}return out.length>0?` ${out.join(" ")}`:""}var RENAMED_LIST_FLAGS={"--page":"--page-path","--branch":"--git-branch","--content-id":"--content","--search":"--query"};function nextPageFlagsSuffix(client){let tokens=argvFlagTokens(client),out=[];for(let i=0;i<tokens.length;i++){let token=tokens[i];if(!token.startsWith("-"))continue;let name=token.split("=")[0];if(name==="--next"||name==="-N"){!token.includes("=")&&i+1<tokens.length&&i++;continue}let renamed=RENAMED_LIST_FLAGS[name];out.push(renamed?`${renamed}${token.slice(name.length)}`:token),!token.includes("=")&&i+1<tokens.length&&!tokens[i+1].startsWith("-")&&out.push(tokens[++i])}return out.length>0?` ${out.join(" ")}`:""}function shellSafe(value){return/^[A-Za-z0-9._/-]+$/.test(value)?value:`'${value.replace(/'/g,"'\\''")}'`}async function printEmptyState(client,scope,focus,params,status,flags){let probe;try{probe=await listThreads(client,scope.teamId,{...params,branch:void 0,cursor:void 0,limit:20})}catch{output_manager_default.log(`No${statusWord(status)} comments on ${focus.value}.`);return}let branches=new Map;for(let thread of probe.threads){let branch=thread.branch??"(no branch)";branches.set(branch,(branches.get(branch)??0)+1)}if(branches.size===0){output_manager_default.log(`No${statusWord(status)} comments in ${scope.projectName??"this project"} on any branch.`),printActiveFilters(flags);return}output_manager_default.log(`No${statusWord(status)} comments on ${focus.value}.`);let suffix=probe.pagination.nextCursor?"+":"",scopeSuffix=scopeFlagsSuffix(client);if(branches.size===1){let[branch,count]=[...branches.entries()][0];output_manager_default.log(`${count}${suffix}${statusWord(status)} on ${import_chalk.default.bold(branch)} \u2014 run ${getCommandName(`comments --git-branch ${shellSafe(branch)}${scopeSuffix}`)}`);return}let total=[...branches.values()].reduce((a,b)=>a+b,0);output_manager_default.log(`${total}${suffix}${statusWord(status)} on other branches \u2014 run ${getCommandName(`comments --all-branches${scopeSuffix}`)}`)}async function list(client,telemetry,defaultInvocation){let parsedArgs,flagsSpecification=getFlagsSpecification(listSubcommand.options);try{parsedArgs=parseArguments(client.argv.slice(2),flagsSpecification)}catch(err){return handleCommentsParseError(err,"list")}let flags=parsedArgs.flags,pagePaths=flags["--page-path"]??flags["--page"],expectedPositionals=defaultInvocation?1:2;if(parsedArgs.args.length>expectedPositionals)return output_manager_default.error(`Unknown ${defaultInvocation?"subcommand":"argument"} "${parsedArgs.args[expectedPositionals]}". Run \`vercel comments --help\` for usage.`),1;let formatResult=validateJsonOutput(flags);if(!formatResult.valid)return output_manager_default.error(formatResult.error),2;let jsonOutput=formatResult.jsonOutput;telemetry.trackCliOptionProject(flags["--project"]),telemetry.trackCliOptionGitBranch(flags["--git-branch"]),telemetry.trackCliOptionBranch(flags["--branch"]),telemetry.trackCliFlagAllBranches(flags["--all-branches"]),telemetry.trackCliOptionStatus(flags["--status"]),telemetry.trackCliOptionPagePath(flags["--page-path"]),telemetry.trackCliOptionPage(flags["--page"]),telemetry.trackCliOptionAuthor(flags["--author"]),telemetry.trackCliOptionContent(flags["--content"]),telemetry.trackCliOptionContentId(flags["--content-id"]),telemetry.trackCliOptionQuery(flags["--query"]),telemetry.trackCliOptionSearch(flags["--search"]),telemetry.trackCliOptionLimit(flags["--limit"]),telemetry.trackCliOptionNext(flags["--next"]),telemetry.trackCliOptionFormat(flags["--format"]);let branchError=applyDeprecatedGitBranchFlag(client,flags,"--branch");if(branchError)return outputError(client,jsonOutput,"MUTUAL_EXCLUSIVITY",branchError);let content=getRenamedOption(parsedArgs.flags,"--content","--content-id",{json:jsonOutput});if("error"in content)return outputError(client,jsonOutput,"INVALID_ARGUMENTS",content.error);let query=getRenamedOption(parsedArgs.flags,"--query","--search",{json:jsonOutput});if("error"in query)return outputError(client,jsonOutput,"INVALID_ARGUMENTS",query.error);flags["--content"]=content.value,delete flags["--content-id"],flags["--query"]=query.value,delete flags["--search"];let status=validateStatus(flags["--status"]);if(!status)return outputError(client,jsonOutput,"INVALID_STATUS",`Invalid --status "${flags["--status"]}". Valid values: unresolved, resolved, all.`);let limitResult=validateIntegerRangeWithDefault(flags["--limit"],{flag:"--limit",min:1,max:100,defaultValue:20});if(!limitResult.valid)return handleValidationError(limitResult,jsonOutput,client);if(flags["--git-branch"]&&flags["--all-branches"])return outputError(client,jsonOutput,"MUTUAL_EXCLUSIVITY","Cannot specify both --git-branch and --all-branches.");let scope=await resolveCommentsScope(client,{project:flags["--project"],requireProject:!0,jsonOutput});if(typeof scope=="number")return scope;let focus,branchFilter;if(flags["--git-branch"]&&flags["--git-branch"].length>0)branchFilter=flags["--git-branch"],focus={value:branchFilter.join(", "),source:"flag"};else if(!flags["--all-branches"]&&scope.linked){let inferred=inferBranch(client.cwd);inferred&&(focus=inferred,branchFilter=[inferred.value])}let authors=await resolveAuthors(client,flags["--author"],jsonOutput);if(typeof authors=="number")return authors;let params={projectId:scope.projectId,branch:branchFilter,status:status==="all"?void 0:status,page:pagePaths,author:authors,contentId:flags["--content"],search:flags["--query"],limit:limitResult.value,cursor:flags["--next"]};jsonOutput||output_manager_default.spinner("Fetching comments\u2026");let response;try{response=await listThreads(client,scope.teamId,params)}catch(err){if(isAPIError(err))return outputError(client,jsonOutput,err.code||"API_ERROR",err.serverMessage||`API error (${err.status}).`);throw err}finally{output_manager_default.stopSpinner()}let threads=response.threads??[],nextCursor=response.pagination?.nextCursor??null;if(jsonOutput){let envelope={scope:{teamId:scope.teamId,...scope.teamSlug&&{teamSlug:scope.teamSlug},...scope.projectId&&{projectId:scope.projectId},...scope.projectName&&{projectName:scope.projectName},...focus&&focus.source!=="flag"&&{inferredBranch:focus.value}},filters:{...status!=="all"&&{status},...focus&&{branch:{value:focus.value,source:focus.source}}},pagination:{nextCursor,next:nextCursor},threads};return client.stdout.write(`${JSON.stringify(withWarnings(envelope,[content.warning,query.warning]),null,2)}
7
+ import{renderThreadRow}from"./chunk-YRKW42CD.js";import{handleCommentsParseError,inferBranch,listThreads,resolveCommentsScope}from"./chunk-CMFG6TYZ.js";import{applyDeprecatedGitBranchFlag}from"./chunk-UE3YVFFX.js";import"./chunk-AKOYIH3A.js";import"./chunk-TOTTVS5P.js";import{handleValidationError,outputError,validateIntegerRangeWithDefault}from"./chunk-ZJNDLFZ7.js";import"./chunk-D3M2JG5C.js";import"./chunk-QJY3QFK6.js";import"./chunk-C64AK7SW.js";import{getRenamedOption,withWarnings}from"./chunk-FSZJSIOF.js";import{printNextPageCommand}from"./chunk-D44WCAOX.js";import{listSubcommand}from"./chunk-XECELSF5.js";import"./chunk-CY5KJ42N.js";import{getScope}from"./chunk-CT77BGSW.js";import"./chunk-PNWRO3XW.js";import"./chunk-DTUEHPME.js";import"./chunk-EUU3FHCX.js";import"./chunk-M7FED5YP.js";import"./chunk-4HR3I3ML.js";import"./chunk-LOA7SZWH.js";import"./chunk-LUX4PBJL.js";import"./chunk-MTZYPCZ7.js";import"./chunk-OPORM35X.js";import"./chunk-D6REP5QQ.js";import"./chunk-FBYA6LLM.js";import"./chunk-MY4MONOH.js";import"./chunk-7HLAWGY2.js";import"./chunk-MXTC4ZAQ.js";import{parseArguments}from"./chunk-LYL26S3N.js";import"./chunk-2VBFQZ72.js";import{validateJsonOutput}from"./chunk-6GKP6VUF.js";import"./chunk-4NTBYNFR.js";import"./chunk-4SAVH3H7.js";import{isAPIError}from"./chunk-GOI2VVI7.js";import{getCommandName,getCommandNamePlain}from"./chunk-B4KA3ZH2.js";import"./chunk-BOJDM3O7.js";import{output_manager_default}from"./chunk-AP6DZGTK.js";import"./chunk-BLUPZPAS.js";import"./chunk-AW33SRYY.js";import"./chunk-5MDNVAE6.js";import"./chunk-OCR5CRTH.js";import"./chunk-7EJQLVWX.js";import"./chunk-SCV7XEEO.js";import"./chunk-MCYG7CCE.js";import"./chunk-YHPPP3SF.js";import{getFlagsSpecification,stripSensitiveAuthArgs}from"./chunk-CFJBDBYH.js";import"./chunk-2BKALEOP.js";import{require_source}from"./chunk-NB2WLB3J.js";import"./chunk-ISWW3DKF.js";import"./chunk-BRQUZ5NC.js";import"./chunk-BULSRTQE.js";import{__toESM}from"./chunk-BZENIQ7N.js";var import_chalk=__toESM(require_source(),1);function validateStatus(value){let status=value??"unresolved";if(["unresolved","resolved","all"].includes(status))return status}async function resolveAuthors(client,authors,jsonOutput){if(!authors||authors.length===0)return;if(!authors.includes("me"))return authors;let{user}=await getScope(client);return user?authors.map(author=>author==="me"?user.id:author):outputError(client,jsonOutput,"USER_REQUIRED","Can't resolve `--author me` when authenticated as an app. Use an author ID with `--author`, or authenticate with a user token.")}function statusWord(status){return status==="all"?"":` ${status}`}function printActiveFilters(flags){let parts=[];flags["--author"]?.length&&parts.push(`--author ${flags["--author"].join(", ")} (takes a user ID or \`me\` \u2014 usernames match nothing)`);let pagePaths=flags["--page-path"]??flags["--page"];pagePaths?.length&&parts.push(`--page-path ${pagePaths.join(", ")}`),flags["--query"]&&parts.push(`--query ${flags["--query"]}`),flags["--content"]?.length&&parts.push(`--content ${flags["--content"].join(", ")}`),parts.length>0&&output_manager_default.log(`Filters: ${parts.join(" \xB7 ")}`)}function countLine(count,status){return`${count}${statusWord(status)} comment${count===1?"":"s"}`}var SCOPE_FLAG_NAMES=new Set(["--scope","-S","--project","-p","--team","-T"]);function argvFlagTokens(client){return stripSensitiveAuthArgs(client.argv.slice(3))}function scopeFlagsSuffix(client){let tokens=argvFlagTokens(client),out=[];for(let i=0;i<tokens.length;i++){let token=tokens[i],name=token.split("=")[0];SCOPE_FLAG_NAMES.has(name)&&(out.push(token),!token.includes("=")&&i+1<tokens.length&&out.push(tokens[++i]))}return out.length>0?` ${out.join(" ")}`:""}var RENAMED_LIST_FLAGS={"--page":"--page-path","--branch":"--git-branch","--content-id":"--content","--search":"--query"};function nextPageFlagsSuffix(client){let tokens=argvFlagTokens(client),out=[];for(let i=0;i<tokens.length;i++){let token=tokens[i];if(!token.startsWith("-"))continue;let name=token.split("=")[0];if(name==="--next"||name==="-N"){!token.includes("=")&&i+1<tokens.length&&i++;continue}let renamed=RENAMED_LIST_FLAGS[name];out.push(renamed?`${renamed}${token.slice(name.length)}`:token),!token.includes("=")&&i+1<tokens.length&&!tokens[i+1].startsWith("-")&&out.push(tokens[++i])}return out.length>0?` ${out.join(" ")}`:""}function shellSafe(value){return/^[A-Za-z0-9._/-]+$/.test(value)?value:`'${value.replace(/'/g,"'\\''")}'`}async function printEmptyState(client,scope,focus,params,status,flags){let probe;try{probe=await listThreads(client,scope.teamId,{...params,branch:void 0,cursor:void 0,limit:20})}catch{output_manager_default.log(`No${statusWord(status)} comments on ${focus.value}.`);return}let branches=new Map;for(let thread of probe.threads){let branch=thread.branch??"(no branch)";branches.set(branch,(branches.get(branch)??0)+1)}if(branches.size===0){output_manager_default.log(`No${statusWord(status)} comments in ${scope.projectName??"this project"} on any branch.`),printActiveFilters(flags);return}output_manager_default.log(`No${statusWord(status)} comments on ${focus.value}.`);let suffix=probe.pagination.nextCursor?"+":"",scopeSuffix=scopeFlagsSuffix(client);if(branches.size===1){let[branch,count]=[...branches.entries()][0];output_manager_default.log(`${count}${suffix}${statusWord(status)} on ${import_chalk.default.bold(branch)} \u2014 run ${getCommandName(`comments --git-branch ${shellSafe(branch)}${scopeSuffix}`)}`);return}let total=[...branches.values()].reduce((a,b)=>a+b,0);output_manager_default.log(`${total}${suffix}${statusWord(status)} on other branches \u2014 run ${getCommandName(`comments --all-branches${scopeSuffix}`)}`)}async function list(client,telemetry,defaultInvocation){let parsedArgs,flagsSpecification=getFlagsSpecification(listSubcommand.options);try{parsedArgs=parseArguments(client.argv.slice(2),flagsSpecification)}catch(err){return handleCommentsParseError(err,"list")}let flags=parsedArgs.flags,pagePaths=flags["--page-path"]??flags["--page"],expectedPositionals=defaultInvocation?1:2;if(parsedArgs.args.length>expectedPositionals)return output_manager_default.error(`Unknown ${defaultInvocation?"subcommand":"argument"} "${parsedArgs.args[expectedPositionals]}". Run \`vercel comments --help\` for usage.`),1;let formatResult=validateJsonOutput(flags);if(!formatResult.valid)return output_manager_default.error(formatResult.error),2;let jsonOutput=formatResult.jsonOutput;telemetry.trackCliOptionProject(flags["--project"]),telemetry.trackCliOptionGitBranch(flags["--git-branch"]),telemetry.trackCliOptionBranch(flags["--branch"]),telemetry.trackCliFlagAllBranches(flags["--all-branches"]),telemetry.trackCliOptionStatus(flags["--status"]),telemetry.trackCliOptionPagePath(flags["--page-path"]),telemetry.trackCliOptionPage(flags["--page"]),telemetry.trackCliOptionAuthor(flags["--author"]),telemetry.trackCliOptionContent(flags["--content"]),telemetry.trackCliOptionContentId(flags["--content-id"]),telemetry.trackCliOptionQuery(flags["--query"]),telemetry.trackCliOptionSearch(flags["--search"]),telemetry.trackCliOptionLimit(flags["--limit"]),telemetry.trackCliOptionNext(flags["--next"]),telemetry.trackCliOptionFormat(flags["--format"]);let branchError=applyDeprecatedGitBranchFlag(client,flags,"--branch");if(branchError)return outputError(client,jsonOutput,"MUTUAL_EXCLUSIVITY",branchError);let content=getRenamedOption(parsedArgs.flags,"--content","--content-id",{json:jsonOutput});if("error"in content)return outputError(client,jsonOutput,"INVALID_ARGUMENTS",content.error);let query=getRenamedOption(parsedArgs.flags,"--query","--search",{json:jsonOutput});if("error"in query)return outputError(client,jsonOutput,"INVALID_ARGUMENTS",query.error);flags["--content"]=content.value,delete flags["--content-id"],flags["--query"]=query.value,delete flags["--search"];let status=validateStatus(flags["--status"]);if(!status)return outputError(client,jsonOutput,"INVALID_STATUS",`Invalid --status "${flags["--status"]}". Valid values: unresolved, resolved, all.`);let limitResult=validateIntegerRangeWithDefault(flags["--limit"],{flag:"--limit",min:1,max:100,defaultValue:20});if(!limitResult.valid)return handleValidationError(limitResult,jsonOutput,client);if(flags["--git-branch"]&&flags["--all-branches"])return outputError(client,jsonOutput,"MUTUAL_EXCLUSIVITY","Cannot specify both --git-branch and --all-branches.");let scope=await resolveCommentsScope(client,{project:flags["--project"],requireProject:!0,jsonOutput});if(typeof scope=="number")return scope;let focus,branchFilter;if(flags["--git-branch"]&&flags["--git-branch"].length>0)branchFilter=flags["--git-branch"],focus={value:branchFilter.join(", "),source:"flag"};else if(!flags["--all-branches"]&&scope.linked){let inferred=inferBranch(client.cwd);inferred&&(focus=inferred,branchFilter=[inferred.value])}let authors=await resolveAuthors(client,flags["--author"],jsonOutput);if(typeof authors=="number")return authors;let params={projectId:scope.projectId,branch:branchFilter,status:status==="all"?void 0:status,page:pagePaths,author:authors,contentId:flags["--content"],search:flags["--query"],limit:limitResult.value,cursor:flags["--next"]};jsonOutput||output_manager_default.spinner("Fetching comments\u2026");let response;try{response=await listThreads(client,scope.teamId,params)}catch(err){if(isAPIError(err))return outputError(client,jsonOutput,err.code||"API_ERROR",err.serverMessage||`API error (${err.status}).`);throw err}finally{output_manager_default.stopSpinner()}let threads=response.threads??[],nextCursor=response.pagination?.nextCursor??null;if(jsonOutput){let envelope={scope:{teamId:scope.teamId,...scope.teamSlug&&{teamSlug:scope.teamSlug},...scope.projectId&&{projectId:scope.projectId},...scope.projectName&&{projectName:scope.projectName},...focus&&focus.source!=="flag"&&{inferredBranch:focus.value}},filters:{...status!=="all"&&{status},...focus&&{branch:{value:focus.value,source:focus.source}}},pagination:{nextCursor,next:nextCursor},threads};return client.stdout.write(`${JSON.stringify(withWarnings(envelope,[content.warning,query.warning]),null,2)}
8
8
  `),0}let branchLabel=focus?focus.value:"all branches";if(output_manager_default.log(`Comments in ${import_chalk.default.bold(scope.projectName??scope.projectId??"")} \xB7 ${branchLabel}`),threads.length===0)return focus?await printEmptyState(client,scope,focus,params,status,flags):(output_manager_default.log(`No${statusWord(status)} comments in ${scope.projectName??"this project"}.`),printActiveFilters(flags)),0;output_manager_default.print(`
9
9
  `);for(let thread of threads)output_manager_default.print(`${renderThreadRow(thread,{showBranch:!focus})}
10
10
 
@@ -4,6 +4,6 @@ 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{AUTH_FAILURE,CREDENTIAL_STORE_CONFLICT,VCR_ENGINES,VCR_LOGIN_USERNAME,emitVcrArgParseError,engineLogin,engineLogout,handleVcrApiError,isEngineInstalled,resolveRegistry,resolveVcrScope,stderrTail,validateVcrChoice,validateVcrJsonOutput}from"./chunk-6BN7Y3GF.js";import{outputError}from"./chunk-ZJNDLFZ7.js";import"./chunk-D3M2JG5C.js";import"./chunk-M32HBBPK.js";import"./chunk-GD7AV7BO.js";import{loginSubcommand}from"./chunk-BMIYC2MH.js";import"./chunk-6CJFPT4F.js";import"./chunk-ZZD5W5KT.js";import"./chunk-VHSAI6FS.js";import{printError}from"./chunk-CY5KJ42N.js";import"./chunk-CT77BGSW.js";import{AGENT_REASON,buildCommandWithGlobalFlags,outputAgentError}from"./chunk-PNWRO3XW.js";import"./chunk-DTUEHPME.js";import"./chunk-EUU3FHCX.js";import"./chunk-M7FED5YP.js";import"./chunk-4HR3I3ML.js";import"./chunk-LOA7SZWH.js";import"./chunk-LUX4PBJL.js";import"./chunk-MTZYPCZ7.js";import"./chunk-OPORM35X.js";import"./chunk-D6REP5QQ.js";import"./chunk-FBYA6LLM.js";import"./chunk-MY4MONOH.js";import"./chunk-7HLAWGY2.js";import"./chunk-MXTC4ZAQ.js";import{parseArguments}from"./chunk-LYL26S3N.js";import"./chunk-2VBFQZ72.js";import"./chunk-6GKP6VUF.js";import"./chunk-4NTBYNFR.js";import"./chunk-4SAVH3H7.js";import{isAPIError}from"./chunk-GOI2VVI7.js";import"./chunk-B4KA3ZH2.js";import"./chunk-BOJDM3O7.js";import{output_manager_default}from"./chunk-AP6DZGTK.js";import"./chunk-BLUPZPAS.js";import"./chunk-AW33SRYY.js";import"./chunk-5MDNVAE6.js";import"./chunk-OCR5CRTH.js";import"./chunk-7EJQLVWX.js";import"./chunk-SCV7XEEO.js";import"./chunk-MCYG7CCE.js";import"./chunk-YHPPP3SF.js";import{getFlagsSpecification}from"./chunk-CFJBDBYH.js";import"./chunk-2BKALEOP.js";import"./chunk-NB2WLB3J.js";import"./chunk-ISWW3DKF.js";import"./chunk-BRQUZ5NC.js";import"./chunk-BULSRTQE.js";import"./chunk-BZENIQ7N.js";var LOGIN_VALID_HOURS=12;async function login(client,argv,telemetry){let parsedArgs;try{parsedArgs=parseArguments(argv,getFlagsSpecification(loginSubcommand.options))}catch(err){return emitVcrArgParseError(client,err,"vcr login <engine> --project <name-or-id>"),printError(err),2}let fr=validateVcrJsonOutput(client,parsedArgs.flags);if(typeof fr=="number")return fr;let engineArg=parsedArgs.args[0],project=parsedArgs.flags["--project"];if(telemetry.trackCliArgumentEngine(engineArg),telemetry.trackCliOptionProject(project),telemetry.trackCliOptionFormat(parsedArgs.flags["--format"]),!engineArg){let message=`Missing engine. Choose one of: ${VCR_ENGINES.join(", ")}.`;return outputAgentError(client,{status:"error",reason:AGENT_REASON.MISSING_ARGUMENTS,message,next:[{command:buildCommandWithGlobalFlags(client.argv,"vcr login docker"),when:"Replace docker with the container tool you use"}]},2),outputError(client,fr.jsonOutput,"MISSING_ARGUMENTS",message)}let choiceError=validateVcrChoice(client,"engine",engineArg,VCR_ENGINES,fr.jsonOutput);if(typeof choiceError=="number")return choiceError;let engine=engineArg;if(!isEngineInstalled(engine)){let message=`\`${engine}\` is not installed or not on your PATH. Install it and try again.`;return outputAgentError(client,{status:"error",reason:"engine_not_found",message},1),outputError(client,fr.jsonOutput,"ENGINE_NOT_FOUND",message)}let scope=await resolveVcrScope(client,{project,jsonOutput:fr.jsonOutput});if(typeof scope=="number")return scope;let registry=resolveRegistry();output_manager_default.spinner(`Authenticating ${engine} with ${registry}...`);try{let{token}=await client.fetch(`/projects/${scope.projectId}/token`,{method:"POST",accountId:scope.teamId,body:JSON.stringify({source:"vercel-cli"}),headers:{"Content-Type":"application/json"}}),result=await engineLogin(engine,registry,token);if(result.exitCode!==0&&CREDENTIAL_STORE_CONFLICT.test(result.stderr)&&(output_manager_default.debug(`Stale ${registry} credential in the ${engine} credential store; running \`${engine} logout\` and retrying`),await engineLogout(engine,registry),result=await engineLogin(engine,registry,token)),result.exitCode!==0){let message=AUTH_FAILURE.test(result.stderr)?`Authentication to ${registry} as "${VCR_LOGIN_USERNAME}" was rejected. The OIDC token may be expired or lack access to this project.`:`\`${engine} login\` failed (exit code ${result.exitCode}).${stderrTail(result.stderr)?`
7
+ import{AUTH_FAILURE,CREDENTIAL_STORE_CONFLICT,VCR_ENGINES,VCR_LOGIN_USERNAME,emitVcrArgParseError,engineLogin,engineLogout,handleVcrApiError,isEngineInstalled,resolveRegistry,resolveVcrScope,stderrTail,validateVcrChoice,validateVcrJsonOutput}from"./chunk-6BN7Y3GF.js";import{outputError}from"./chunk-ZJNDLFZ7.js";import"./chunk-M32HBBPK.js";import"./chunk-D3M2JG5C.js";import"./chunk-GD7AV7BO.js";import{loginSubcommand}from"./chunk-BMIYC2MH.js";import"./chunk-6CJFPT4F.js";import"./chunk-ZZD5W5KT.js";import"./chunk-VHSAI6FS.js";import{printError}from"./chunk-CY5KJ42N.js";import"./chunk-CT77BGSW.js";import{AGENT_REASON,buildCommandWithGlobalFlags,outputAgentError}from"./chunk-PNWRO3XW.js";import"./chunk-DTUEHPME.js";import"./chunk-EUU3FHCX.js";import"./chunk-M7FED5YP.js";import"./chunk-4HR3I3ML.js";import"./chunk-LOA7SZWH.js";import"./chunk-LUX4PBJL.js";import"./chunk-MTZYPCZ7.js";import"./chunk-OPORM35X.js";import"./chunk-D6REP5QQ.js";import"./chunk-FBYA6LLM.js";import"./chunk-MY4MONOH.js";import"./chunk-7HLAWGY2.js";import"./chunk-MXTC4ZAQ.js";import{parseArguments}from"./chunk-LYL26S3N.js";import"./chunk-2VBFQZ72.js";import"./chunk-6GKP6VUF.js";import"./chunk-4NTBYNFR.js";import"./chunk-4SAVH3H7.js";import{isAPIError}from"./chunk-GOI2VVI7.js";import"./chunk-B4KA3ZH2.js";import"./chunk-BOJDM3O7.js";import{output_manager_default}from"./chunk-AP6DZGTK.js";import"./chunk-BLUPZPAS.js";import"./chunk-AW33SRYY.js";import"./chunk-5MDNVAE6.js";import"./chunk-OCR5CRTH.js";import"./chunk-7EJQLVWX.js";import"./chunk-SCV7XEEO.js";import"./chunk-MCYG7CCE.js";import"./chunk-YHPPP3SF.js";import{getFlagsSpecification}from"./chunk-CFJBDBYH.js";import"./chunk-2BKALEOP.js";import"./chunk-NB2WLB3J.js";import"./chunk-ISWW3DKF.js";import"./chunk-BRQUZ5NC.js";import"./chunk-BULSRTQE.js";import"./chunk-BZENIQ7N.js";var LOGIN_VALID_HOURS=12;async function login(client,argv,telemetry){let parsedArgs;try{parsedArgs=parseArguments(argv,getFlagsSpecification(loginSubcommand.options))}catch(err){return emitVcrArgParseError(client,err,"vcr login <engine> --project <name-or-id>"),printError(err),2}let fr=validateVcrJsonOutput(client,parsedArgs.flags);if(typeof fr=="number")return fr;let engineArg=parsedArgs.args[0],project=parsedArgs.flags["--project"];if(telemetry.trackCliArgumentEngine(engineArg),telemetry.trackCliOptionProject(project),telemetry.trackCliOptionFormat(parsedArgs.flags["--format"]),!engineArg){let message=`Missing engine. Choose one of: ${VCR_ENGINES.join(", ")}.`;return outputAgentError(client,{status:"error",reason:AGENT_REASON.MISSING_ARGUMENTS,message,next:[{command:buildCommandWithGlobalFlags(client.argv,"vcr login docker"),when:"Replace docker with the container tool you use"}]},2),outputError(client,fr.jsonOutput,"MISSING_ARGUMENTS",message)}let choiceError=validateVcrChoice(client,"engine",engineArg,VCR_ENGINES,fr.jsonOutput);if(typeof choiceError=="number")return choiceError;let engine=engineArg;if(!isEngineInstalled(engine)){let message=`\`${engine}\` is not installed or not on your PATH. Install it and try again.`;return outputAgentError(client,{status:"error",reason:"engine_not_found",message},1),outputError(client,fr.jsonOutput,"ENGINE_NOT_FOUND",message)}let scope=await resolveVcrScope(client,{project,jsonOutput:fr.jsonOutput});if(typeof scope=="number")return scope;let registry=resolveRegistry();output_manager_default.spinner(`Authenticating ${engine} with ${registry}...`);try{let{token}=await client.fetch(`/projects/${scope.projectId}/token`,{method:"POST",accountId:scope.teamId,body:JSON.stringify({source:"vercel-cli"}),headers:{"Content-Type":"application/json"}}),result=await engineLogin(engine,registry,token);if(result.exitCode!==0&&CREDENTIAL_STORE_CONFLICT.test(result.stderr)&&(output_manager_default.debug(`Stale ${registry} credential in the ${engine} credential store; running \`${engine} logout\` and retrying`),await engineLogout(engine,registry),result=await engineLogin(engine,registry,token)),result.exitCode!==0){let message=AUTH_FAILURE.test(result.stderr)?`Authentication to ${registry} as "${VCR_LOGIN_USERNAME}" was rejected. The OIDC token may be expired or lack access to this project.`:`\`${engine} login\` failed (exit code ${result.exitCode}).${stderrTail(result.stderr)?`
8
8
  ${stderrTail(result.stderr)}`:""}`;return outputAgentError(client,{status:"error",reason:AUTH_FAILURE.test(result.stderr)?"not_authorized":"command_failed",message,next:[{command:buildCommandWithGlobalFlags(client.argv,"whoami"),when:"See current user and team"}]},1),outputError(client,fr.jsonOutput,AUTH_FAILURE.test(result.stderr)?"NOT_AUTHORIZED":"COMMAND_FAILED",message)}return fr.jsonOutput?client.stdout.write(`${JSON.stringify({status:"success",engine,registry,username:VCR_LOGIN_USERNAME,validForHours:LOGIN_VALID_HOURS},null,2)}
9
9
  `):(output_manager_default.success(`Logged in to ${registry} as ${VCR_LOGIN_USERNAME} (${engine}).`),output_manager_default.log(`Credentials are valid for ~${LOGIN_VALID_HOURS} hours. Re-run \`${buildCommandWithGlobalFlags(client.argv,`vcr login ${engine}`)}\` to refresh.`)),0}catch(err){if(isAPIError(err))return handleVcrApiError(client,err,fr.jsonOutput);throw err}finally{output_manager_default.stopSpinner()}}export{login as default};
@@ -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{repositoryTagsPath}from"./chunk-DFVNL5ML.js";import{emitVcrArgParseError,formatBytes,formatDigest,formatRelativeTime,handleVcrApiError,requireVcrRepository,resolveVcrScope,validateVcrChoice,validateVcrJsonOutput}from"./chunk-6BN7Y3GF.js";import{outputError,validateOptionalIntegerRange}from"./chunk-ZJNDLFZ7.js";import"./chunk-D3M2JG5C.js";import"./chunk-M32HBBPK.js";import"./chunk-GD7AV7BO.js";import{table}from"./chunk-CJZE7647.js";import{printNextPageHint}from"./chunk-D44WCAOX.js";import{TAGS_SORT_BY_CHOICES,TAGS_SORT_ORDER_CHOICES,tagsLsSubcommand}from"./chunk-ZZD5W5KT.js";import{printError}from"./chunk-CY5KJ42N.js";import"./chunk-CT77BGSW.js";import{AGENT_REASON,outputAgentError}from"./chunk-PNWRO3XW.js";import"./chunk-DTUEHPME.js";import"./chunk-EUU3FHCX.js";import"./chunk-M7FED5YP.js";import"./chunk-4HR3I3ML.js";import"./chunk-LOA7SZWH.js";import"./chunk-LUX4PBJL.js";import"./chunk-MTZYPCZ7.js";import"./chunk-OPORM35X.js";import"./chunk-D6REP5QQ.js";import"./chunk-FBYA6LLM.js";import"./chunk-MY4MONOH.js";import"./chunk-7HLAWGY2.js";import"./chunk-MXTC4ZAQ.js";import{parseArguments}from"./chunk-LYL26S3N.js";import"./chunk-2VBFQZ72.js";import{warnDeprecatedOption}from"./chunk-6GKP6VUF.js";import"./chunk-4NTBYNFR.js";import"./chunk-4SAVH3H7.js";import{isAPIError}from"./chunk-GOI2VVI7.js";import"./chunk-B4KA3ZH2.js";import"./chunk-BOJDM3O7.js";import{output_manager_default}from"./chunk-AP6DZGTK.js";import"./chunk-BLUPZPAS.js";import"./chunk-AW33SRYY.js";import"./chunk-5MDNVAE6.js";import"./chunk-OCR5CRTH.js";import"./chunk-7EJQLVWX.js";import"./chunk-SCV7XEEO.js";import"./chunk-MCYG7CCE.js";import"./chunk-YHPPP3SF.js";import{getFlagsSpecification}from"./chunk-CFJBDBYH.js";import"./chunk-2BKALEOP.js";import{require_source}from"./chunk-NB2WLB3J.js";import"./chunk-ISWW3DKF.js";import"./chunk-BRQUZ5NC.js";import"./chunk-BULSRTQE.js";import{__toESM}from"./chunk-BZENIQ7N.js";var import_chalk=__toESM(require_source(),1);function printTags(list){if(list.tags.length===0){output_manager_default.log("No tags found.");return}let rows=[["Tag","Image ID","Digest","Arch","Size","Created"].map(h=>import_chalk.default.cyan(h)),...list.tags.map(tag=>[import_chalk.default.bold(tag.tag),import_chalk.default.dim(tag.imageId),import_chalk.default.dim(formatDigest(tag.manifestDigest)),tag.arch??"-",formatBytes(tag.sizeInBytes),formatRelativeTime(tag.createdAt)])],tableOutput=table(rows,{hsep:3}).split(`
7
+ import{repositoryTagsPath}from"./chunk-DFVNL5ML.js";import{emitVcrArgParseError,formatBytes,formatDigest,formatRelativeTime,handleVcrApiError,requireVcrRepository,resolveVcrScope,validateVcrChoice,validateVcrJsonOutput}from"./chunk-6BN7Y3GF.js";import{outputError,validateOptionalIntegerRange}from"./chunk-ZJNDLFZ7.js";import"./chunk-M32HBBPK.js";import"./chunk-D3M2JG5C.js";import"./chunk-GD7AV7BO.js";import{table}from"./chunk-CJZE7647.js";import{printNextPageHint}from"./chunk-D44WCAOX.js";import{TAGS_SORT_BY_CHOICES,TAGS_SORT_ORDER_CHOICES,tagsLsSubcommand}from"./chunk-ZZD5W5KT.js";import{printError}from"./chunk-CY5KJ42N.js";import"./chunk-CT77BGSW.js";import{AGENT_REASON,outputAgentError}from"./chunk-PNWRO3XW.js";import"./chunk-DTUEHPME.js";import"./chunk-EUU3FHCX.js";import"./chunk-M7FED5YP.js";import"./chunk-4HR3I3ML.js";import"./chunk-LOA7SZWH.js";import"./chunk-LUX4PBJL.js";import"./chunk-MTZYPCZ7.js";import"./chunk-OPORM35X.js";import"./chunk-D6REP5QQ.js";import"./chunk-FBYA6LLM.js";import"./chunk-MY4MONOH.js";import"./chunk-7HLAWGY2.js";import"./chunk-MXTC4ZAQ.js";import{parseArguments}from"./chunk-LYL26S3N.js";import"./chunk-2VBFQZ72.js";import{warnDeprecatedOption}from"./chunk-6GKP6VUF.js";import"./chunk-4NTBYNFR.js";import"./chunk-4SAVH3H7.js";import{isAPIError}from"./chunk-GOI2VVI7.js";import"./chunk-B4KA3ZH2.js";import"./chunk-BOJDM3O7.js";import{output_manager_default}from"./chunk-AP6DZGTK.js";import"./chunk-BLUPZPAS.js";import"./chunk-AW33SRYY.js";import"./chunk-5MDNVAE6.js";import"./chunk-OCR5CRTH.js";import"./chunk-7EJQLVWX.js";import"./chunk-SCV7XEEO.js";import"./chunk-MCYG7CCE.js";import"./chunk-YHPPP3SF.js";import{getFlagsSpecification}from"./chunk-CFJBDBYH.js";import"./chunk-2BKALEOP.js";import{require_source}from"./chunk-NB2WLB3J.js";import"./chunk-ISWW3DKF.js";import"./chunk-BRQUZ5NC.js";import"./chunk-BULSRTQE.js";import{__toESM}from"./chunk-BZENIQ7N.js";var import_chalk=__toESM(require_source(),1);function printTags(list){if(list.tags.length===0){output_manager_default.log("No tags found.");return}let rows=[["Tag","Image ID","Digest","Arch","Size","Created"].map(h=>import_chalk.default.cyan(h)),...list.tags.map(tag=>[import_chalk.default.bold(tag.tag),import_chalk.default.dim(tag.imageId),import_chalk.default.dim(formatDigest(tag.manifestDigest)),tag.arch??"-",formatBytes(tag.sizeInBytes),formatRelativeTime(tag.createdAt)])],tableOutput=table(rows,{hsep:3}).split(`
8
8
  `).map(line=>line.trimEnd()).join(`
9
9
  `).replace(/^/gm," ");output_manager_default.print(`
10
10
  ${tableOutput}