cf 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (266) hide show
  1. package/dist/_meta/agent-context.json +189 -187
  2. package/dist/_meta/commands.json +2591 -2248
  3. package/dist/_meta/hand-written-commands.json +146 -1
  4. package/dist/_meta/schemas.json +1548 -1313
  5. package/dist/{abuse-reports-BbaHw4ST.mjs → abuse-reports-CDFjJ2e8.mjs} +1 -1
  6. package/dist/{access-D6Xz892p.mjs → access-BoT1waG4.mjs} +1 -1
  7. package/dist/{account-DvxcqeaK.mjs → account-agnMUKWj.mjs} +1 -1
  8. package/dist/{account-tags-CeqfEWpz.mjs → account-tags-BRMMHCee.mjs} +1 -1
  9. package/dist/{accounts-Bx-8BMH9.mjs → accounts-Cut77dAt.mjs} +2 -2
  10. package/dist/{acm--0opdSGE.mjs → acm-C8WgXNCl.mjs} +1 -1
  11. package/dist/{addressing-BS1ynzLA.mjs → addressing-CR8EV42x.mjs} +1 -1
  12. package/dist/{agent-context-BPhyrSns.mjs → agent-context-Wj5TRRbW.mjs} +1 -1
  13. package/dist/{agent-memory-DczzpEw5.mjs → agent-memory-CVJpKKZy.mjs} +1 -1
  14. package/dist/{ai-CDdCTcQl.mjs → ai-BbNYt-yI.mjs} +1 -1
  15. package/dist/{ai-audit-Bx9KMQYh.mjs → ai-audit-mVajM-2i.mjs} +1 -1
  16. package/dist/{ai-gateway-BSXJEaYS.mjs → ai-gateway-BsepSA_v.mjs} +2 -2
  17. package/dist/{ai-search-DRQj1aMu.mjs → ai-search-DbEJqm5-.mjs} +1 -1
  18. package/dist/{ai-security-C_Rb0lGT.mjs → ai-security-DmyB5EYk.mjs} +1 -1
  19. package/dist/{alerting-BAR9eFs2.mjs → alerting-dmy3hd8O.mjs} +3 -3
  20. package/dist/analytics-B1xBMla0.mjs +5 -0
  21. package/dist/{analytics_engine-DkEzlhfT.mjs → analytics_engine-DazCn3iC.mjs} +1 -1
  22. package/dist/{api-security-jA0lOk6a.mjs → api-security-0HXCzfHk.mjs} +1 -1
  23. package/dist/{argo-Cz4pDagx.mjs → argo-DSHsE8zv.mjs} +1 -1
  24. package/dist/{artifacts-BcLTGfAv.mjs → artifacts-CwiU9Mxu.mjs} +1 -1
  25. package/dist/{audit-logs-DbIv4n6u.mjs → audit-logs-DwFtMDwH.mjs} +1 -1
  26. package/dist/{auth-rW5d3jtr.mjs → auth-B0ZyXc3y.mjs} +1 -1
  27. package/dist/{auth-tvDdC1J-.mjs → auth-DWxtJ918.mjs} +2 -2
  28. package/dist/{billing-Md87QjqW.mjs → billing-Cbpadkgu.mjs} +1 -1
  29. package/dist/{bot-management-VHMo4hpU.mjs → bot-management-B6M2Vyyn.mjs} +1 -1
  30. package/dist/{botnet-feed-BHqfo3sa.mjs → botnet-feed-Dn8UuE4h.mjs} +1 -1
  31. package/dist/{brand-protection-HUeR6Pof.mjs → brand-protection-B5R0b3pu.mjs} +1 -1
  32. package/dist/{browser-extension-199oZg3X.mjs → browser-extension-D55pYZf_.mjs} +1 -1
  33. package/dist/{browser-run-DDasyux-.mjs → browser-run-C1b2VkGB.mjs} +1 -1
  34. package/dist/build-CP2JUfV1.mjs +2 -0
  35. package/dist/{builds-B-lXn6JR.mjs → builds-CVEXO_4a.mjs} +8 -8
  36. package/dist/{cache-CevKpiTM.mjs → cache-BU5xX82E.mjs} +1 -1
  37. package/dist/{certificate-authorities-DAg-aO1B.mjs → certificate-authorities--tZTWJWD.mjs} +1 -1
  38. package/dist/cf-BV2HLCQm.mjs +18 -0
  39. package/dist/{chunk-QBZBEHZB-BuiXJn8j.mjs → chunk-QBZBEHZB-BcCMlc8C.mjs} +1 -1
  40. package/dist/chunk-XLADBZ7F-DgFrtUhW.mjs +103 -0
  41. package/dist/{client-certificates-Bay7oPLE.mjs → client-certificates-DX84qeYG.mjs} +1 -1
  42. package/dist/{client-side-security-CbU9xn0k.mjs → client-side-security-DsSO2rZQ.mjs} +1 -1
  43. package/dist/{cloud-connector-AH2ClcSL.mjs → cloud-connector-cf8qlxap.mjs} +1 -1
  44. package/dist/{cloudforce-one-DwOfS75V.mjs → cloudforce-one-DzVXorbu.mjs} +2 -2
  45. package/dist/command-BL6weJf3.mjs +3 -0
  46. package/dist/command-DYrspBc0.mjs +2 -0
  47. package/dist/{completions-nPO9PdSu.mjs → completions-Dn621okY.mjs} +1 -1
  48. package/dist/{config-B8lwPpVl.mjs → config-BY6KpMZs.mjs} +1 -1
  49. package/dist/config.d.mts +1 -1729
  50. package/dist/config.mjs +1 -1
  51. package/dist/{connector-interrupts-DcLrqM2V.mjs → connector-interrupts-DqpqPPkp.mjs} +1 -1
  52. package/dist/{connector-telemetry-events-PrJWgNs9.mjs → connector-telemetry-events-CCD-_B-8.mjs} +1 -1
  53. package/dist/{connector-telemetry-snapshots-CIjJm5yu.mjs → connector-telemetry-snapshots-D3CeGGhk.mjs} +1 -1
  54. package/dist/{connectors-CEAy30E-.mjs → connectors-aPQspZdg.mjs} +1 -1
  55. package/dist/{containers-BsbDqbSn.mjs → containers-D0Kjl8h-.mjs} +1 -1
  56. package/dist/{content-scan-BdK936iO.mjs → content-scan-BVx18XmS.mjs} +1 -1
  57. package/dist/{cps-oP97-qkm.mjs → cps-ByazyM0x.mjs} +1 -1
  58. package/dist/{csamScanner-DUNN4INg.mjs → csamScanner-OG5lQxBC.mjs} +1 -1
  59. package/dist/{ct-alerting-dV_gsV2w.mjs → ct-alerting-BJx5n8Zf.mjs} +1 -1
  60. package/dist/{custom-certificates-DYspvjo4.mjs → custom-certificates-BuJ2e9TA.mjs} +1 -1
  61. package/dist/{custom-csrs-DjSWLQRu.mjs → custom-csrs-CR_5qbST.mjs} +1 -1
  62. package/dist/{custom-hostnames-df1lH6IY.mjs → custom-hostnames-BzDTsQXb.mjs} +1 -1
  63. package/dist/{custom-nameservers-CLTbN-9R.mjs → custom-nameservers-OfMPRGkD.mjs} +1 -1
  64. package/dist/custom-pages-BmGXoTIo.mjs +3 -0
  65. package/dist/d1-DedC8N0N.mjs +21 -0
  66. package/dist/data-security-B2UB26ry.mjs +7 -0
  67. package/dist/{dcv-delegation-_r6Vc6VL.mjs → dcv-delegation-C11vmzbG.mjs} +1 -1
  68. package/dist/{deploy-QTGENpOM.mjs → deploy-BtETDvDA.mjs} +1 -1
  69. package/dist/{deploy-input-C7W1Bsji.mjs → deploy-input-BoLTdQzS.mjs} +1 -1
  70. package/dist/{dev-CAubuxCc.mjs → dev-B5WcIpEr.mjs} +2 -2
  71. package/dist/{diagnostics-B0DRh714.mjs → diagnostics-Cf6BLpAo.mjs} +1 -1
  72. package/dist/dialog-Bud0hiYv.mjs +2 -0
  73. package/dist/{dist-DW5BPGFs.mjs → dist-BRg_z9Ut.mjs} +1 -1
  74. package/dist/{shared-YJtB5KZB.mjs → dist-CFQREIRi.mjs} +86 -86
  75. package/dist/dist-CyisSore.mjs +371 -0
  76. package/dist/dist-Dr4Hg_Up.mjs +48 -0
  77. package/dist/{dls-CFzTHcZM.mjs → dls-R6PvHbhj.mjs} +1 -1
  78. package/dist/{dns-Dw6u-NV1.mjs → dns-Cl8se64c.mjs} +1 -1
  79. package/dist/{dns-firewall-CIPptslp.mjs → dns-firewall-WtmKilDT.mjs} +1 -1
  80. package/dist/dry-run-YSQndLvt.mjs +2 -0
  81. package/dist/{durable-objects-CCkeqqBq.mjs → durable-objects-jfVU6yp_.mjs} +1 -1
  82. package/dist/{email-auth-kdxO51Oz.mjs → email-auth-DPmZ85eW.mjs} +1 -1
  83. package/dist/{email-routing-BLggZdQq.mjs → email-routing-Bf6DbNTr.mjs} +1 -1
  84. package/dist/{email-security-DjADlgdM.mjs → email-security-DTifjSxM.mjs} +1 -1
  85. package/dist/{email-sending-Cz7E7GoP.mjs → email-sending-Dm3WkFHV.mjs} +1 -1
  86. package/dist/{error-sanitization-DfLijlBJ.mjs → error-sanitization-D8zuyPj_.mjs} +1 -1
  87. package/dist/{fieldExtractors-BWaMi6lD.mjs → fieldExtractors-CeXZL0-I.mjs} +1 -1
  88. package/dist/{firewall-5t6OBIOl.mjs → firewall-D5N2APXO.mjs} +1 -1
  89. package/dist/{flagship-CzG_VoNR.mjs → flagship-sUOy9jei.mjs} +1 -1
  90. package/dist/{fraud-UOg_69Ob.mjs → fraud-WLW2Ep1Z.mjs} +1 -1
  91. package/dist/{google-tag-gateway-DirkD-Q2.mjs → google-tag-gateway-lbww1FaJ.mjs} +1 -1
  92. package/dist/{healthchecks-BkHZGTp1.mjs → healthchecks-0ih8Qjiw.mjs} +1 -1
  93. package/dist/{hostnames-EUYOZm21.mjs → hostnames-Ba6FuL8K.mjs} +1 -1
  94. package/dist/{hyperdrive-ZoLJlJCL.mjs → hyperdrive-DMqcU639.mjs} +1 -1
  95. package/dist/{iam-BQ2xSgYN.mjs → iam-CXlYm0uC.mjs} +1 -1
  96. package/dist/{images-CkEq6ScP.mjs → images-D_g1oli6.mjs} +1 -1
  97. package/dist/index.mjs +1 -1
  98. package/dist/{intel-DDWEdGyl.mjs → intel-B8bS0ARd.mjs} +1 -1
  99. package/dist/interactive-CGOh-aYq.mjs +32 -0
  100. package/dist/{ips-54Qmy-Uw.mjs → ips-68fzniN4.mjs} +1 -1
  101. package/dist/{keyless-certificates-CXHLc3Qz.mjs → keyless-certificates-CeLnqBvX.mjs} +1 -1
  102. package/dist/{keys-rvI4TC3Z.mjs → keys-DkVdS2lF.mjs} +1 -1
  103. package/dist/{kv-CAeN1zBy.mjs → kv-gDAN50BQ.mjs} +1 -1
  104. package/dist/{leaked-credential-checks-CbbwtG-p.mjs → leaked-credential-checks-DfnvHpvg.mjs} +1 -1
  105. package/dist/{lifecycle-XswDq0ZB.mjs → lifecycle-CadF_i2n.mjs} +1 -1
  106. package/dist/{load-balancers-BFwdwAIU.mjs → load-balancers-m0HqyXPZ.mjs} +1 -1
  107. package/dist/{local-C6XsFD_W.mjs → local-BwL_gesw.mjs} +1 -1
  108. package/dist/{local-runtime-BUGCbx8r.mjs → local-runtime-Dj8k-p62.mjs} +1 -1
  109. package/dist/{logo-matches-Y3PxVn7t.mjs → logo-matches-DPbHlsKQ.mjs} +1 -1
  110. package/dist/{logos-BN8SvJhS.mjs → logos-DFBJFAYJ.mjs} +1 -1
  111. package/dist/{logpush-BnLA4WVm.mjs → logpush-gzmlZayc.mjs} +1 -1
  112. package/dist/logs-BuzwQgt5.mjs +18 -0
  113. package/dist/{magic-cloud-networking-wPuLwu-F.mjs → magic-cloud-networking-BbHCi1Vp.mjs} +1 -1
  114. package/dist/{magic-network-monitoring-BNERUpxS.mjs → magic-network-monitoring-kWMmnPTG.mjs} +1 -1
  115. package/dist/{magic-transit-6tvVOECW.mjs → magic-transit-ClSmJDKw.mjs} +1 -1
  116. package/dist/{managed-defense-AYwBOYIH.mjs → managed-defense-EOihg1UR.mjs} +1 -1
  117. package/dist/{managed-transforms-HZZNrkC7.mjs → managed-transforms-BZ_XdGE2.mjs} +1 -1
  118. package/dist/{matches-Dp91L3dL.mjs → matches-B6sG0_fr.mjs} +1 -1
  119. package/dist/{mcp-P7pcieiT.mjs → mcp--kK0vS5i.mjs} +1 -1
  120. package/dist/{mesh-DjFrk6PL.mjs → mesh-DfXYUHOO.mjs} +1 -1
  121. package/dist/{mtls-certificates-DZMoef2H.mjs → mtls-certificates-DZd-0X7l.mjs} +1 -1
  122. package/dist/{network-7cd1U6-I.mjs → network-U6f_5ihp.mjs} +1 -1
  123. package/dist/{network-interconnects-CQ7cPZjK.mjs → network-interconnects-DKZGTiYM.mjs} +1 -1
  124. package/dist/oauth-BdVr2hJp.mjs +14 -0
  125. package/dist/{oauth-clients-P9t-eMnx.mjs → oauth-clients-CY3OkPhC.mjs} +1 -1
  126. package/dist/{oauth-scopes-C3r9Qh_y.mjs → oauth-scopes-BTY7_5L-.mjs} +1 -1
  127. package/dist/{observability-M1DnLhMR.mjs → observability-Bsp-LdmJ.mjs} +1 -1
  128. package/dist/{open-PBXRGS4R-DARSUDEI.mjs → open-PBXRGS4R-ClEt4E8F.mjs} +3 -3
  129. package/dist/{organization-cUE7GDCt.mjs → organization-BSeMdj-7.mjs} +1 -1
  130. package/dist/{organizations-C-Hcpd0w.mjs → organizations-BroR48Nv.mjs} +1 -1
  131. package/dist/{origin-ca-certificates-C8cJMyQH.mjs → origin-ca-certificates-jC-EMn6W.mjs} +1 -1
  132. package/dist/{origin-post-quantum-encryption-DjZJCk8M.mjs → origin-post-quantum-encryption-DIspLvA0.mjs} +1 -1
  133. package/dist/{origin-tls-client-auth-BsjR5EAV.mjs → origin-tls-client-auth-CZ_nUEcM.mjs} +1 -1
  134. package/dist/{page-rules-B-zq1EUb.mjs → page-rules-ZcdjPohY.mjs} +1 -1
  135. package/dist/{pages-B6YpkPos.mjs → pages-W4tKa7xk.mjs} +1 -1
  136. package/dist/pay-per-crawl-BNM1mJmP.mjs +5 -0
  137. package/dist/pay-per-use-DKxlnkH3.mjs +2 -0
  138. package/dist/{pipelines-BJc_RylD.mjs → pipelines-Dug0BR-c.mjs} +1 -1
  139. package/dist/{precursor-CLQu7suY.mjs → precursor-D-11DkRU.mjs} +1 -1
  140. package/dist/previews-D_Nv4dR6.mjs +4 -0
  141. package/dist/{progress-V6SZV3Ux.mjs → progress-a5IKeKni.mjs} +1 -1
  142. package/dist/project-settings-Bc3wYHo8.mjs +3 -0
  143. package/dist/prompt-BP8XrQSj.mjs +3 -0
  144. package/dist/{queries-DSrrket-.mjs → queries-BdA2vJoe.mjs} +1 -1
  145. package/dist/{queues-Tf7kPBpn.mjs → queues-Bu06ZqUE.mjs} +1 -1
  146. package/dist/{r2-DmKNnxtC.mjs → r2-COC9wMKb.mjs} +1 -1
  147. package/dist/{r2-data-catalog-DBxoifOq.mjs → r2-data-catalog-CX5Rl5Qx.mjs} +1 -1
  148. package/dist/{radar-Csk7Ab-b.mjs → radar-L-yoLIHF.mjs} +1 -1
  149. package/dist/{raw-fetch-BVYQR6C5.mjs → raw-fetch-DNH2V8qH.mjs} +1 -1
  150. package/dist/{realtime-CDehZVhV.mjs → realtime-JKIiXfzi.mjs} +1 -1
  151. package/dist/{registrar-vflzeNQ9.mjs → registrar-_dYUZrK0.mjs} +2 -2
  152. package/dist/{registrar-sandbox-BxVdfnam.mjs → registrar-sandbox-D1yfW_Q_.mjs} +2 -2
  153. package/dist/{registry-CWUfXloz.mjs → registry-BrtVdMrC.mjs} +1 -1
  154. package/dist/{reporting-BaPZ1PHN.mjs → reporting-3fyoMcmb.mjs} +1 -1
  155. package/dist/request-headers-BhQQAfJt.mjs +2 -0
  156. package/dist/{request-tracers-C_UVBexV.mjs → request-tracers-TisEth2p.mjs} +1 -1
  157. package/dist/{resolve-B8CyM1mi.mjs → resolve-CYUp6YgC.mjs} +1 -1
  158. package/dist/{resource-sharing-CoB4S9j1.mjs → resource-sharing-C4-dnohU.mjs} +1 -1
  159. package/dist/{resource-tagging-CUiUC5g4.mjs → resource-tagging-BRDifKqM.mjs} +1 -1
  160. package/dist/{rules-4O8076_s.mjs → rules-BCF3gIkw.mjs} +2 -2
  161. package/dist/{rulesets-C84MxTYo.mjs → rulesets-wp6rllt3.mjs} +1 -1
  162. package/dist/{rum-Bvwkrntx.mjs → rum-B77awgoB.mjs} +1 -1
  163. package/dist/run-BS8otL3u.mjs +2 -0
  164. package/dist/{schema-C8hU6G9R.mjs → schema-DmuJtMN5.mjs} +1 -1
  165. package/dist/{schema-flags-DC4c6dka.mjs → schema-flags-CUGxFeZe.mjs} +4 -4
  166. package/dist/{scim-BvxQmde6.mjs → scim-C9BmUYil.mjs} +1 -1
  167. package/dist/{sdk-C12y5qCN.mjs → sdk-Bvqx-_3z.mjs} +1 -1
  168. package/dist/{secrets-store-DOKWiC-j.mjs → secrets-store-ckkZR2dM.mjs} +1 -1
  169. package/dist/{security-center-Bhy_aC-w.mjs → security-center-BCahKT57.mjs} +1 -1
  170. package/dist/{security-txt-L7HJ9tq5.mjs → security-txt-0SI5du7I.mjs} +1 -1
  171. package/dist/shared-D0B-7q-D.mjs +2 -0
  172. package/dist/{smart-shield-COMXuQ1S.mjs → smart-shield-BDPbrZa4.mjs} +1 -1
  173. package/dist/{snippets-DffQhlKt.mjs → snippets-CVRR_h0i.mjs} +1 -1
  174. package/dist/spawn-DP4T92ss.mjs +519 -0
  175. package/dist/{spectrum-Cmf7SqQE.mjs → spectrum-CjNXQIQE.mjs} +3 -3
  176. package/dist/{speed-m8cdhLFS.mjs → speed-CrXCHk3h.mjs} +1 -1
  177. package/dist/src-BbnV77C4.mjs +108 -0
  178. package/dist/{ssl-D4ffsdSw.mjs → ssl-DKORhHkh.mjs} +1 -1
  179. package/dist/{startup-profile-Dx95Y5cl.mjs → startup-profile-CBIH6yZy.mjs} +3 -3
  180. package/dist/{state-CHif8Y5I.mjs → state-QUu6HfxC.mjs} +1 -1
  181. package/dist/{stream-DPF5fojV.mjs → stream-wY3zi3FK.mjs} +1 -1
  182. package/dist/{submit-Br8hfP0_.mjs → submit-B-4oCBSk.mjs} +1 -1
  183. package/dist/{tags-Bnt4JuxQ.mjs → tags-5uJEkYJZ.mjs} +1 -1
  184. package/dist/{telemetry-DjGNSlkU.mjs → telemetry-2s9Y3FaN.mjs} +1 -1
  185. package/dist/{telemetry-Ch1vCICm.mjs → telemetry-n3NJourL.mjs} +1 -1
  186. package/dist/{tenant-D8u0CxoC.mjs → tenant-BkFvv2o3.mjs} +1 -1
  187. package/dist/{tenant-custom-nameservers-BrWMyslZ.mjs → tenant-custom-nameservers-DcjC1q0r.mjs} +1 -1
  188. package/dist/{tools-D9RZkZRc.mjs → tools-Dz1JCrHd.mjs} +1 -1
  189. package/dist/tunnel-Cd4ipbvJ.mjs +2 -0
  190. package/dist/{tunnels-BkNPpTHa.mjs → tunnels-9Zg3ePwD.mjs} +1 -1
  191. package/dist/{turnstile-MgwRECJv.mjs → turnstile-BTwKYpzD.mjs} +1 -1
  192. package/dist/{url-info-Ddp7MgcI.mjs → url-info-D7Y61BFd.mjs} +1 -1
  193. package/dist/{url-normalization-3ptK9ntV.mjs → url-normalization-B4n8HiNQ.mjs} +1 -1
  194. package/dist/{url-scanner-Psb9ollR.mjs → url-scanner-CiCIltSQ.mjs} +1 -1
  195. package/dist/{user-DWdshcIu.mjs → user-DDFDGJ0Y.mjs} +1 -1
  196. package/dist/{values-CDKQL1z2.mjs → values-DRznB_Cl.mjs} +1 -1
  197. package/dist/{vectorize-CTYYUyQj.mjs → vectorize-CbznPhzq.mjs} +1 -1
  198. package/dist/waiting-rooms-CKP5hYBK.mjs +11 -0
  199. package/dist/{web-assets-CpDwDEx8.mjs → web-assets-C-ZoSkkh.mjs} +1 -1
  200. package/dist/{web3-YsjDyAzH.mjs → web3-DwlN4dOw.mjs} +1 -1
  201. package/dist/{workers-builds-BWo5vUA9.mjs → workers-builds-ECw_x_kp.mjs} +1 -1
  202. package/dist/{workers-for-platforms-ASJsxYdM.mjs → workers-for-platforms-BYGy46R6.mjs} +2 -2
  203. package/dist/{workers-vpc-RkTnRvA2.mjs → workers-vpc-CCosFcxz.mjs} +1 -1
  204. package/dist/workers-zFMrbUkg.mjs +6 -0
  205. package/dist/{workflows-KrIFI9ns.mjs → workflows-C8GXGDRW.mjs} +1 -1
  206. package/dist/{zaraz-DglXbVzZ.mjs → zaraz-B5UIREaz.mjs} +1 -1
  207. package/dist/{zero-trust-RilTdSjX.mjs → zero-trust-DUp0XoIo.mjs} +50 -50
  208. package/dist/{zone-DsBtVkvT.mjs → zone-BGLkk-mL.mjs} +1 -1
  209. package/dist/{zones-BFxvWFQW.mjs → zones-CwYjNXMH.mjs} +1 -1
  210. package/package.json +11 -11
  211. package/dist/analytics-BaUZwNc5.mjs +0 -4
  212. package/dist/build-0QlYUfFS.mjs +0 -2
  213. package/dist/cf-C11NGkjx.mjs +0 -18
  214. package/dist/chunk-LQW53VED-CoECHA3R.mjs +0 -119
  215. package/dist/command-CMzMsll4.mjs +0 -2
  216. package/dist/custom-pages-DzKnSgL3.mjs +0 -3
  217. package/dist/d1-JBEqjJoj.mjs +0 -20
  218. package/dist/data-security-CIktWnXt.mjs +0 -7
  219. package/dist/dist-12KzRsBM.mjs +0 -387
  220. package/dist/dist-BCVqQpg2.mjs +0 -2
  221. package/dist/dist-Cp3uJN1x.mjs +0 -48
  222. package/dist/dist-S9K_8gq9.mjs +0 -9
  223. package/dist/dry-run-DiVy1lVo.mjs +0 -2
  224. package/dist/interactive-B2E03Fs-.mjs +0 -11
  225. package/dist/interactive-_B-EqD0Y.mjs +0 -23
  226. package/dist/logexplorer-D8rOPB5I.mjs +0 -17
  227. package/dist/logs-CDo7Y5sA.mjs +0 -3
  228. package/dist/oauth-DH3kMXSs.mjs +0 -14
  229. package/dist/pay-per-crawl-B4wx0lUb.mjs +0 -4
  230. package/dist/prompt-DjRTpML4.mjs +0 -3
  231. package/dist/public-BMg6-Hxh-BfUOZTDP.mjs +0 -2
  232. package/dist/request-headers-CC4eHmI2.mjs +0 -3
  233. package/dist/run-CRfinkSe.mjs +0 -2
  234. package/dist/schemas-O_ZNaF8R.mjs +0 -65
  235. package/dist/spawn-C1AISA2V.mjs +0 -526
  236. package/dist/src-C8phrg-8.mjs +0 -109
  237. package/dist/waiting-rooms-BUdmwXDY.mjs +0 -11
  238. package/dist/workers-BKKxaZcz.mjs +0 -6
  239. /package/dist/{alerts-B2SJO4nd.mjs → alerts-CarPLL8k.mjs} +0 -0
  240. /package/dist/{autorag-iNjZXw1n.mjs → autorag-zK-3harf.mjs} +0 -0
  241. /package/dist/{body-parser-DIlfApuJ.mjs → body-parser-Cmw7PZ7a.mjs} +0 -0
  242. /package/dist/{brands-BrVnNrT3.mjs → brands-CpgTsX8h.mjs} +0 -0
  243. /package/dist/{clear-an9o3dJ3.mjs → clear-C5gzBA8G.mjs} +0 -0
  244. /package/dist/{cli-types-CrSoSMPF.mjs → cli-types-abvWQN3T.mjs} +0 -0
  245. /package/dist/{connector-telemetry-events-latest-BqWfopFc.mjs → connector-telemetry-events-latest-BY-dbhQZ.mjs} +0 -0
  246. /package/dist/{connector-telemetry-snapshots-latest-C1m9U1En.mjs → connector-telemetry-snapshots-latest-DoMvHvCO.mjs} +0 -0
  247. /package/dist/{domain-info-B0Ykqv5l.mjs → domain-info-Cw3G4nap.mjs} +0 -0
  248. /package/dist/{health-CIUg1C5o.mjs → health-DkEXPkS6.mjs} +0 -0
  249. /package/dist/{input-validation-BxchZ9jE.mjs → input-validation-nF-0Ze2h.mjs} +0 -0
  250. /package/dist/{internal-DmpATljO.mjs → internal-4fU2r5en.mjs} +0 -0
  251. /package/dist/{live-B66u3_0g.mjs → live-B4iGrwY2.mjs} +0 -0
  252. /package/dist/{metadata-D062SVyy.mjs → metadata-C5fJJr-k.mjs} +0 -0
  253. /package/dist/{output-COcSQsfn.mjs → output-Z2lQmPUW.mjs} +0 -0
  254. /package/dist/{rate-limit-analytics-BknoecoM.mjs → rate-limit-analytics-DNsAFIeM.mjs} +0 -0
  255. /package/dist/{rate-limits-cdChIg_S.mjs → rate-limits-CsOim7bm.mjs} +0 -0
  256. /package/dist/{ready-C-H2cwp_.mjs → ready-tTe-zcIw.mjs} +0 -0
  257. /package/dist/{recent-submissions-DyuH_n5u.mjs → recent-submissions-B3eTV5yC.mjs} +0 -0
  258. /package/dist/{refute-uSlzkQKq.mjs → refute-BY76YVrT.mjs} +0 -0
  259. /package/dist/{scan-logo-DMk--WT7.mjs → scan-logo-DdoF_a5y.mjs} +0 -0
  260. /package/dist/{scan-page-DEHnAOJo.mjs → scan-page-sSgLwwZN.mjs} +0 -0
  261. /package/dist/{search-BlKeSfVD.mjs → search-BFvQr-sl.mjs} +0 -0
  262. /package/dist/{signed-url-CiGmGkLQ.mjs → signed-url-Cr8hiZPJ.mjs} +0 -0
  263. /package/dist/{submission-info-DHlTHDrs.mjs → submission-info-DT2mLnu1.mjs} +0 -0
  264. /package/dist/{total-queries-D5WvVfYi.mjs → total-queries-6gs5iy9T.mjs} +0 -0
  265. /package/dist/{tracked-domains-9deBK9bp.mjs → tracked-domains-D6XKO2EV.mjs} +0 -0
  266. /package/dist/{verify-S-TmhUDr.mjs → verify-CM1NakP0.mjs} +0 -0
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
- import{t as e}from"./local-C6XsFD_W.mjs";import{f as t,g as n}from"./oauth-DH3kMXSs.mjs";import{r}from"./auth-tvDdC1J-.mjs";import{t as i}from"./output-COcSQsfn.mjs";import{t as a}from"./dry-run-DiVy1lVo.mjs";import{t as o}from"./progress-V6SZV3Ux.mjs";import{t as s}from"./run-CRfinkSe.mjs";import"./telemetry-Ch1vCICm.mjs";import{n as c,r as l,t as u}from"./body-parser-DIlfApuJ.mjs";import{n as d}from"./input-validation-BxchZ9jE.mjs";import{a as f,i as p,n as m}from"./prompt-DjRTpML4.mjs";import{t as h}from"./cli-types-CrSoSMPF.mjs";function ee(e){return e.option(`account-provider-id`,{type:`string`,description:`The account_provider_id field`}).option(`cost-in`,{type:`number`,description:`The cost_in field`}).option(`cost-out`,{type:`number`,description:`The cost_out field`}).option(`cost-type`,{type:`string`,description:`The cost_type field`,default:`tokens`}).option(`enable`,{type:`boolean`,description:`The enable field`}).option(`model`,{type:`string`,description:`The model field`}).option(`model-rule`,{type:`string`,description:`The model_rule field`,choices:[`equals`,`starts-with`,`contains`],default:`equals`}).option(`token-pricing-input-audio-tokens`,{type:`number`,description:`The token_pricing.input_audio_tokens field`}).option(`token-pricing-input-cache-creation-tokens`,{type:`number`,description:`The token_pricing.input_cache_creation_tokens field`}).option(`token-pricing-input-cached-tokens`,{type:`number`,description:`The token_pricing.input_cached_tokens field`}).option(`token-pricing-input-image-count`,{type:`number`,description:`The token_pricing.input_image_count field`}).option(`token-pricing-input-image-tokens`,{type:`number`,description:`The token_pricing.input_image_tokens field`}).option(`token-pricing-input-text-tokens`,{type:`number`,description:`The token_pricing.input_text_tokens field`}).option(`token-pricing-input-tokens`,{type:`number`,description:`The token_pricing.input_tokens field`}).option(`token-pricing-input-video-tokens`,{type:`number`,description:`The token_pricing.input_video_tokens field`}).option(`token-pricing-output-image-count`,{type:`number`,description:`The token_pricing.output_image_count field`}).option(`token-pricing-output-reasoning-tokens`,{type:`number`,description:`The token_pricing.output_reasoning_tokens field`}).option(`token-pricing-output-tokens`,{type:`number`,description:`The token_pricing.output_tokens field`}).option(`token-pricing-total-tokens`,{type:`number`,description:`The token_pricing.total_tokens field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const te={command:`create`,describe:`Creates a new AI Gateway.`,builder:ee,handler:async l=>s({command:`ai-gateway account-providers costs create`,classification:{safeFlags:[`enable`,`model-rule`,`dry-run`]}},l,async()=>{if(l.dryRun){a({command:`cf ai-gateway account-providers costs create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/custom-providers/costs`,pathParams:{},bodyKind:`json`,body:l.body===void 0?u({account_provider_id:d(l[`account-provider-id`],`account-provider-id`,`text`),cost_in:l[`cost-in`],cost_out:l[`cost-out`],cost_type:d(l[`cost-type`],`cost-type`,`text`),enable:l.enable,model:d(l.model,`model`,`text`),model_rule:d(l[`model-rule`],`model-rule`,`text`),token_pricing:{input_audio_tokens:l[`token-pricing-input-audio-tokens`],input_cache_creation_tokens:l[`token-pricing-input-cache-creation-tokens`],input_cached_tokens:l[`token-pricing-input-cached-tokens`],input_image_count:l[`token-pricing-input-image-count`],input_image_tokens:l[`token-pricing-input-image-tokens`],input_text_tokens:l[`token-pricing-input-text-tokens`],input_tokens:l[`token-pricing-input-tokens`],input_video_tokens:l[`token-pricing-input-video-tokens`],output_image_count:l[`token-pricing-output-image-count`],output_reasoning_tokens:l[`token-pricing-output-reasoning-tokens`],output_tokens:l[`token-pricing-output-tokens`],total_tokens:l[`token-pricing-total-tokens`]}}):c(l.body)});return}let s=await r(l),p=l.local?e:await t();if(l.accountId=p,l.body){let e=c(l.body);i(await o(`Creating`,async()=>s.aiGateway.accountProviders.costs.create({...e,account_id:p})),{successLabel:`Created`});return}l[`account-provider-id`]===void 0&&(l[`account-provider-id`]=await f(`account-provider-id`,`The account_provider_id field`)),l.model===void 0&&(l.model=await f(`model`,`The model field`));let m=u({account_provider_id:d(l[`account-provider-id`],`account-provider-id`,`text`),cost_in:l[`cost-in`],cost_out:l[`cost-out`],cost_type:d(l[`cost-type`],`cost-type`,`text`),enable:l.enable,model:d(l.model,`model`,`text`),model_rule:d(l[`model-rule`],`model-rule`,`text`),token_pricing:{input_audio_tokens:l[`token-pricing-input-audio-tokens`],input_cache_creation_tokens:l[`token-pricing-input-cache-creation-tokens`],input_cached_tokens:l[`token-pricing-input-cached-tokens`],input_image_count:l[`token-pricing-input-image-count`],input_image_tokens:l[`token-pricing-input-image-tokens`],input_text_tokens:l[`token-pricing-input-text-tokens`],input_tokens:l[`token-pricing-input-tokens`],input_video_tokens:l[`token-pricing-input-video-tokens`],output_image_count:l[`token-pricing-output-image-count`],output_reasoning_tokens:l[`token-pricing-output-reasoning-tokens`],output_tokens:l[`token-pricing-output-tokens`],total_tokens:l[`token-pricing-total-tokens`]}});i(await o(`Creating`,async()=>s.aiGateway.accountProviders.costs.create({...m,account_id:p})),{successLabel:`Created`})})};function g(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const _={command:`delete <id>`,describe:`Deletes an AI Gateway dataset.`,builder:g,handler:async c=>s({command:`ai-gateway account-providers costs delete`,classification:{safeFlags:[`dry-run`,`force`],shortFlagAliases:{f:{canonical:`force`,type:`boolean`}}}},c,async()=>{if(c.dryRun){a({command:`cf ai-gateway account-providers costs delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/custom-providers/costs/${c.id==null?`<id>`:encodeURIComponent(String(c.id))}`,pathParams:{id:String(c.id??``)},bodyKind:`none`});return}let s=await r(c),l=c.local?e:await t();if(c.accountId=l,!await m({force:!!c.force})){process.stderr.write(`Aborted.
2
+ import{t as e}from"./local-BwL_gesw.mjs";import{f as t,g as n}from"./oauth-BdVr2hJp.mjs";import{r}from"./auth-DWxtJ918.mjs";import{t as i}from"./output-Z2lQmPUW.mjs";import{t as a}from"./dry-run-YSQndLvt.mjs";import{t as o}from"./progress-a5IKeKni.mjs";import{t as s}from"./run-BS8otL3u.mjs";import"./telemetry-n3NJourL.mjs";import{n as c,r as l,t as u}from"./body-parser-Cmw7PZ7a.mjs";import{n as d}from"./input-validation-nF-0Ze2h.mjs";import{a as f,i as p,n as m}from"./prompt-BP8XrQSj.mjs";import{t as h}from"./cli-types-abvWQN3T.mjs";function ee(e){return e.option(`account-provider-id`,{type:`string`,description:`The account_provider_id field`}).option(`cost-in`,{type:`number`,description:`The cost_in field`}).option(`cost-out`,{type:`number`,description:`The cost_out field`}).option(`cost-type`,{type:`string`,description:`The cost_type field`,default:`tokens`}).option(`enable`,{type:`boolean`,description:`The enable field`}).option(`model`,{type:`string`,description:`The model field`}).option(`model-rule`,{type:`string`,description:`The model_rule field`,choices:[`equals`,`starts-with`,`contains`],default:`equals`}).option(`token-pricing-input-audio-tokens`,{type:`number`,description:`The token_pricing.input_audio_tokens field`}).option(`token-pricing-input-cache-creation-tokens`,{type:`number`,description:`The token_pricing.input_cache_creation_tokens field`}).option(`token-pricing-input-cached-tokens`,{type:`number`,description:`The token_pricing.input_cached_tokens field`}).option(`token-pricing-input-image-count`,{type:`number`,description:`The token_pricing.input_image_count field`}).option(`token-pricing-input-image-tokens`,{type:`number`,description:`The token_pricing.input_image_tokens field`}).option(`token-pricing-input-text-tokens`,{type:`number`,description:`The token_pricing.input_text_tokens field`}).option(`token-pricing-input-tokens`,{type:`number`,description:`The token_pricing.input_tokens field`}).option(`token-pricing-input-video-tokens`,{type:`number`,description:`The token_pricing.input_video_tokens field`}).option(`token-pricing-output-image-count`,{type:`number`,description:`The token_pricing.output_image_count field`}).option(`token-pricing-output-reasoning-tokens`,{type:`number`,description:`The token_pricing.output_reasoning_tokens field`}).option(`token-pricing-output-tokens`,{type:`number`,description:`The token_pricing.output_tokens field`}).option(`token-pricing-total-tokens`,{type:`number`,description:`The token_pricing.total_tokens field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const te={command:`create`,describe:`Creates a new AI Gateway.`,builder:ee,handler:async l=>s({command:`ai-gateway account-providers costs create`,classification:{safeFlags:[`enable`,`model-rule`,`dry-run`]}},l,async()=>{if(l.dryRun){a({command:`cf ai-gateway account-providers costs create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/custom-providers/costs`,pathParams:{},bodyKind:`json`,body:l.body===void 0?u({account_provider_id:d(l[`account-provider-id`],`account-provider-id`,`text`),cost_in:l[`cost-in`],cost_out:l[`cost-out`],cost_type:d(l[`cost-type`],`cost-type`,`text`),enable:l.enable,model:d(l.model,`model`,`text`),model_rule:d(l[`model-rule`],`model-rule`,`text`),token_pricing:{input_audio_tokens:l[`token-pricing-input-audio-tokens`],input_cache_creation_tokens:l[`token-pricing-input-cache-creation-tokens`],input_cached_tokens:l[`token-pricing-input-cached-tokens`],input_image_count:l[`token-pricing-input-image-count`],input_image_tokens:l[`token-pricing-input-image-tokens`],input_text_tokens:l[`token-pricing-input-text-tokens`],input_tokens:l[`token-pricing-input-tokens`],input_video_tokens:l[`token-pricing-input-video-tokens`],output_image_count:l[`token-pricing-output-image-count`],output_reasoning_tokens:l[`token-pricing-output-reasoning-tokens`],output_tokens:l[`token-pricing-output-tokens`],total_tokens:l[`token-pricing-total-tokens`]}}):c(l.body)});return}let s=await r(l),p=l.local?e:await t();if(l.accountId=p,l.body){let e=c(l.body);i(await o(`Creating`,async()=>s.aiGateway.accountProviders.costs.create({...e,account_id:p})),{successLabel:`Created`});return}l[`account-provider-id`]===void 0&&(l[`account-provider-id`]=await f(`account-provider-id`,`The account_provider_id field`)),l.model===void 0&&(l.model=await f(`model`,`The model field`));let m=u({account_provider_id:d(l[`account-provider-id`],`account-provider-id`,`text`),cost_in:l[`cost-in`],cost_out:l[`cost-out`],cost_type:d(l[`cost-type`],`cost-type`,`text`),enable:l.enable,model:d(l.model,`model`,`text`),model_rule:d(l[`model-rule`],`model-rule`,`text`),token_pricing:{input_audio_tokens:l[`token-pricing-input-audio-tokens`],input_cache_creation_tokens:l[`token-pricing-input-cache-creation-tokens`],input_cached_tokens:l[`token-pricing-input-cached-tokens`],input_image_count:l[`token-pricing-input-image-count`],input_image_tokens:l[`token-pricing-input-image-tokens`],input_text_tokens:l[`token-pricing-input-text-tokens`],input_tokens:l[`token-pricing-input-tokens`],input_video_tokens:l[`token-pricing-input-video-tokens`],output_image_count:l[`token-pricing-output-image-count`],output_reasoning_tokens:l[`token-pricing-output-reasoning-tokens`],output_tokens:l[`token-pricing-output-tokens`],total_tokens:l[`token-pricing-total-tokens`]}});i(await o(`Creating`,async()=>s.aiGateway.accountProviders.costs.create({...m,account_id:p})),{successLabel:`Created`})})};function g(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const _={command:`delete <id>`,describe:`Deletes an AI Gateway dataset.`,builder:g,handler:async c=>s({command:`ai-gateway account-providers costs delete`,classification:{safeFlags:[`dry-run`,`force`],shortFlagAliases:{f:{canonical:`force`,type:`boolean`}}}},c,async()=>{if(c.dryRun){a({command:`cf ai-gateway account-providers costs delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/custom-providers/costs/${c.id==null?`<id>`:encodeURIComponent(String(c.id))}`,pathParams:{id:String(c.id??``)},bodyKind:`none`});return}let s=await r(c),l=c.local?e:await t();if(c.accountId=l,!await m({force:!!c.force})){process.stderr.write(`Aborted.
3
3
  `);return}i(await o(`Deleting`,async()=>s.aiGateway.accountProviders.costs.delete({account_id:l,id:c.id})),{successLabel:`Deleted`})})};function v(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const y={command:`get <id>`,describe:`Retrieves details for a specific AI Gateway dataset.`,builder:v,handler:async c=>s({command:`ai-gateway account-providers costs get`,classification:{safeFlags:[`dry-run`]}},c,async()=>{if(c.dryRun){a({command:`cf ai-gateway account-providers costs get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/custom-providers/costs/${c.id==null?`<id>`:encodeURIComponent(String(c.id))}`,pathParams:{id:String(c.id??``)},bodyKind:`none`});return}let s=await r(c),l=c.local?e:await t();c.accountId=l,i(await o(`Loading`,async()=>s.aiGateway.accountProviders.costs.get({account_id:l,id:c.id})),{successLabel:`Loaded`})})};function b(e){return e.option(`page`,{type:`number`,description:`Page`}).option(`per-page`,{type:`number`,description:`Per page`}).option(`enable`,{type:`boolean`,description:`Enable`}).option(`account-provider-id`,{type:`string`,description:`Account provider ID`}).option(`model-rule`,{type:`string`,description:`Model rule`,choices:[`equals`,`starts-with`,`contains`]}).option(`cost-type`,{type:`string`,description:`Cost type`}).option(`search`,{type:`string`,description:`Search by model, changed_by`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const x={command:`list`,describe:`Lists all AI Gateway evaluator types configured for the account.`,builder:h(b),handler:async c=>s({command:`ai-gateway account-providers costs list`,classification:{safeFlags:[`enable`,`model-rule`,`dry-run`]}},c,async()=>{let s={page:c.page,per_page:c[`per-page`],enable:c.enable,account_provider_id:c[`account-provider-id`],model_rule:c[`model-rule`],cost_type:c[`cost-type`],search:c.search};if(c.dryRun){a({command:`cf ai-gateway account-providers costs list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/custom-providers/costs`,pathParams:{},query:s,bodyKind:`none`});return}let l=await r(c),u=c.local?e:await t();c.accountId=u,i(await o(`Loading`,async()=>l.aiGateway.accountProviders.costs.list({account_id:u,...s})),{successLabel:`Loaded`})})};function S(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`cost-in`,{type:`number`,description:`The cost_in field`}).option(`cost-out`,{type:`number`,description:`The cost_out field`}).option(`cost-type`,{type:`string`,description:`The cost_type field`}).option(`enable`,{type:`boolean`,description:`The enable field`}).option(`model`,{type:`string`,description:`The model field`}).option(`model-rule`,{type:`string`,description:`The model_rule field`,choices:[`equals`,`starts-with`,`contains`]}).option(`token-pricing-input-audio-tokens`,{type:`number`,description:`The token_pricing.input_audio_tokens field`}).option(`token-pricing-input-cache-creation-tokens`,{type:`number`,description:`The token_pricing.input_cache_creation_tokens field`}).option(`token-pricing-input-cached-tokens`,{type:`number`,description:`The token_pricing.input_cached_tokens field`}).option(`token-pricing-input-image-count`,{type:`number`,description:`The token_pricing.input_image_count field`}).option(`token-pricing-input-image-tokens`,{type:`number`,description:`The token_pricing.input_image_tokens field`}).option(`token-pricing-input-text-tokens`,{type:`number`,description:`The token_pricing.input_text_tokens field`}).option(`token-pricing-input-tokens`,{type:`number`,description:`The token_pricing.input_tokens field`}).option(`token-pricing-input-video-tokens`,{type:`number`,description:`The token_pricing.input_video_tokens field`}).option(`token-pricing-output-image-count`,{type:`number`,description:`The token_pricing.output_image_count field`}).option(`token-pricing-output-reasoning-tokens`,{type:`number`,description:`The token_pricing.output_reasoning_tokens field`}).option(`token-pricing-output-tokens`,{type:`number`,description:`The token_pricing.output_tokens field`}).option(`token-pricing-total-tokens`,{type:`number`,description:`The token_pricing.total_tokens field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const C={command:`update <id>`,describe:`Updates an existing AI Gateway dataset.`,builder:S,handler:async l=>s({command:`ai-gateway account-providers costs update`,classification:{safeFlags:[`enable`,`model-rule`,`dry-run`]}},l,async()=>{if(l.dryRun){a({command:`cf ai-gateway account-providers costs update`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/custom-providers/costs/${l.id==null?`<id>`:encodeURIComponent(String(l.id))}`,pathParams:{id:String(l.id??``)},bodyKind:`json`,body:l.body===void 0?u({cost_in:l[`cost-in`],cost_out:l[`cost-out`],cost_type:d(l[`cost-type`],`cost-type`,`text`),enable:l.enable,model:d(l.model,`model`,`text`),model_rule:d(l[`model-rule`],`model-rule`,`text`),token_pricing:{input_audio_tokens:l[`token-pricing-input-audio-tokens`],input_cache_creation_tokens:l[`token-pricing-input-cache-creation-tokens`],input_cached_tokens:l[`token-pricing-input-cached-tokens`],input_image_count:l[`token-pricing-input-image-count`],input_image_tokens:l[`token-pricing-input-image-tokens`],input_text_tokens:l[`token-pricing-input-text-tokens`],input_tokens:l[`token-pricing-input-tokens`],input_video_tokens:l[`token-pricing-input-video-tokens`],output_image_count:l[`token-pricing-output-image-count`],output_reasoning_tokens:l[`token-pricing-output-reasoning-tokens`],output_tokens:l[`token-pricing-output-tokens`],total_tokens:l[`token-pricing-total-tokens`]}}):c(l.body)});return}let s=await r(l),f=l.local?e:await t();if(l.accountId=f,l.body){let e=c(l.body);i(await o(`Updating`,async()=>s.aiGateway.accountProviders.costs.update({...e,account_id:f,id:l.id})),{successLabel:`Updated`});return}let p=u({cost_in:l[`cost-in`],cost_out:l[`cost-out`],cost_type:d(l[`cost-type`],`cost-type`,`text`),enable:l.enable,model:d(l.model,`model`,`text`),model_rule:d(l[`model-rule`],`model-rule`,`text`),token_pricing:{input_audio_tokens:l[`token-pricing-input-audio-tokens`],input_cache_creation_tokens:l[`token-pricing-input-cache-creation-tokens`],input_cached_tokens:l[`token-pricing-input-cached-tokens`],input_image_count:l[`token-pricing-input-image-count`],input_image_tokens:l[`token-pricing-input-image-tokens`],input_text_tokens:l[`token-pricing-input-text-tokens`],input_tokens:l[`token-pricing-input-tokens`],input_video_tokens:l[`token-pricing-input-video-tokens`],output_image_count:l[`token-pricing-output-image-count`],output_reasoning_tokens:l[`token-pricing-output-reasoning-tokens`],output_tokens:l[`token-pricing-output-tokens`],total_tokens:l[`token-pricing-total-tokens`]}});i(await o(`Updating`,async()=>s.aiGateway.accountProviders.costs.update({...p,account_id:f,id:l.id})),{successLabel:`Updated`})})},w={command:`costs`,describe:`Operations for account-providers.costs`,builder:e=>e.command(te).command(_).command(y).command(x).command(C).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function T(e){return e.option(`base-url`,{type:`string`,description:`The base_url field`}).option(`beta`,{type:`boolean`,description:`The beta field`}).option(`curl-example`,{type:`string`,description:`The curl_example field`}).option(`description`,{type:`string`,description:`The description field`}).option(`enable`,{type:`boolean`,description:`The enable field`}).option(`headers`,{type:`string`,description:`The headers field`}).option(`js-example`,{type:`string`,description:`The js_example field`}).option(`link`,{type:`string`,description:`The link field`}).option(`name`,{type:`string`,description:`The name field`}).option(`position`,{type:`number`,description:`The position field`}).option(`slug`,{type:`string`,description:`The slug field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const E={command:`create`,describe:`Creates a new AI Gateway.`,builder:T,handler:async l=>s({command:`ai-gateway account-providers create`,classification:{safeFlags:[`beta`,`enable`,`dry-run`]}},l,async()=>{if(l.dryRun){a({command:`cf ai-gateway account-providers create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/custom-providers`,pathParams:{},bodyKind:`json`,body:l.body===void 0?u({base_url:d(l[`base-url`],`base-url`,`text`),beta:l.beta,curl_example:d(l[`curl-example`],`curl-example`,`text`),description:d(l.description,`description`,`text`),enable:l.enable,headers:d(l.headers,`headers`,`text`),js_example:d(l[`js-example`],`js-example`,`text`),link:d(l.link,`link`,`text`),name:d(l.name,`name`,`text`),position:l.position,slug:d(l.slug,`slug`,`text`)}):c(l.body)});return}let s=await r(l),p=l.local?e:await t();if(l.accountId=p,l.body){let e=c(l.body);i(await o(`Creating`,async()=>s.aiGateway.accountProviders.create({...e,account_id:p})),{successLabel:`Created`});return}l[`base-url`]===void 0&&(l[`base-url`]=await f(`base-url`,`The base_url field`)),l.name===void 0&&(l.name=await f(`name`,`The name field`)),l.slug===void 0&&(l.slug=await f(`slug`,`The slug field`));let m=u({base_url:d(l[`base-url`],`base-url`,`text`),beta:l.beta,curl_example:d(l[`curl-example`],`curl-example`,`text`),description:d(l.description,`description`,`text`),enable:l.enable,headers:d(l.headers,`headers`,`text`),js_example:d(l[`js-example`],`js-example`,`text`),link:d(l.link,`link`,`text`),name:d(l.name,`name`,`text`),position:l.position,slug:d(l.slug,`slug`,`text`)});i(await o(`Creating`,async()=>s.aiGateway.accountProviders.create({...m,account_id:p})),{successLabel:`Created`})})};function D(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const O={command:`delete <id>`,describe:`Deletes an AI Gateway dataset.`,builder:D,handler:async c=>s({command:`ai-gateway account-providers delete`,classification:{safeFlags:[`dry-run`,`force`],shortFlagAliases:{f:{canonical:`force`,type:`boolean`}}}},c,async()=>{if(c.dryRun){a({command:`cf ai-gateway account-providers delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/custom-providers/${c.id==null?`<id>`:encodeURIComponent(String(c.id))}`,pathParams:{id:String(c.id??``)},bodyKind:`none`});return}let s=await r(c),l=c.local?e:await t();if(c.accountId=l,!await m({force:!!c.force})){process.stderr.write(`Aborted.
4
4
  `);return}i(await o(`Deleting`,async()=>s.aiGateway.accountProviders.delete({account_id:l,id:c.id})),{successLabel:`Deleted`})})};function k(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const A={command:`get <id>`,describe:`Retrieves details for a specific AI Gateway dataset.`,builder:k,handler:async c=>s({command:`ai-gateway account-providers get`,classification:{safeFlags:[`dry-run`]}},c,async()=>{if(c.dryRun){a({command:`cf ai-gateway account-providers get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/custom-providers/${c.id==null?`<id>`:encodeURIComponent(String(c.id))}`,pathParams:{id:String(c.id??``)},bodyKind:`none`});return}let s=await r(c),l=c.local?e:await t();c.accountId=l,i(await o(`Loading`,async()=>s.aiGateway.accountProviders.get({account_id:l,id:c.id})),{successLabel:`Loaded`})})};function j(e){return e.option(`page`,{type:`number`,description:`Page`}).option(`per-page`,{type:`number`,description:`Per page`}).option(`beta`,{type:`boolean`,description:`Beta`}).option(`enable`,{type:`boolean`,description:`Enable`}).option(`search`,{type:`string`,description:`Search by id, name, slug`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const M={command:`list`,describe:`Lists all AI Gateway evaluator types configured for the account.`,builder:j,handler:async c=>s({command:`ai-gateway account-providers list`,classification:{safeFlags:[`beta`,`enable`,`dry-run`]}},c,async()=>{let s={page:c.page,per_page:c[`per-page`],beta:c.beta,enable:c.enable,search:c.search};if(c.dryRun){a({command:`cf ai-gateway account-providers list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/custom-providers`,pathParams:{},query:s,bodyKind:`none`});return}let l=await r(c),u=c.local?e:await t();c.accountId=u,i(await o(`Loading`,async()=>l.aiGateway.accountProviders.list({account_id:u,...s})),{successLabel:`Loaded`})})};function N(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`base-url`,{type:`string`,description:`The base_url field`}).option(`beta`,{type:`boolean`,description:`The beta field`}).option(`curl-example`,{type:`string`,description:`The curl_example field`}).option(`description`,{type:`string`,description:`The description field`}).option(`enable`,{type:`boolean`,description:`The enable field`}).option(`headers`,{type:`string`,description:`The headers field`}).option(`js-example`,{type:`string`,description:`The js_example field`}).option(`link`,{type:`string`,description:`The link field`}).option(`logo`,{type:`string`,description:`The logo field`}).option(`name`,{type:`string`,description:`The name field`}).option(`position`,{type:`number`,description:`The position field`}).option(`slug`,{type:`string`,description:`The slug field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const P={command:`update <id>`,describe:`Updates an existing AI Gateway dataset.`,builder:N,handler:async l=>s({command:`ai-gateway account-providers update`,classification:{safeFlags:[`beta`,`enable`,`dry-run`]}},l,async()=>{if(l.dryRun){a({command:`cf ai-gateway account-providers update`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/custom-providers/${l.id==null?`<id>`:encodeURIComponent(String(l.id))}`,pathParams:{id:String(l.id??``)},bodyKind:`json`,body:l.body===void 0?u({base_url:d(l[`base-url`],`base-url`,`text`),beta:l.beta,curl_example:d(l[`curl-example`],`curl-example`,`text`),description:d(l.description,`description`,`text`),enable:l.enable,headers:d(l.headers,`headers`,`text`),js_example:d(l[`js-example`],`js-example`,`text`),link:d(l.link,`link`,`text`),logo:d(l.logo,`logo`,`text`),name:d(l.name,`name`,`text`),position:l.position,slug:d(l.slug,`slug`,`text`)}):c(l.body)});return}let s=await r(l),f=l.local?e:await t();if(l.accountId=f,l.body){let e=c(l.body);i(await o(`Updating`,async()=>s.aiGateway.accountProviders.update({...e,account_id:f,id:l.id})),{successLabel:`Updated`});return}let p=u({base_url:d(l[`base-url`],`base-url`,`text`),beta:l.beta,curl_example:d(l[`curl-example`],`curl-example`,`text`),description:d(l.description,`description`,`text`),enable:l.enable,headers:d(l.headers,`headers`,`text`),js_example:d(l[`js-example`],`js-example`,`text`),link:d(l.link,`link`,`text`),logo:d(l.logo,`logo`,`text`),name:d(l.name,`name`,`text`),position:l.position,slug:d(l.slug,`slug`,`text`)});i(await o(`Updating`,async()=>s.aiGateway.accountProviders.update({...p,account_id:f,id:l.id})),{successLabel:`Updated`})})},F={command:`account-providers`,describe:`Operations for account-providers`,builder:e=>e.command(E).command(O).command(A).command(M).command(P).command(w).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function I(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const L={command:`credit-balance`,describe:`Retrieve the current credit balance, payment method info, and top-up configuration.`,builder:I,handler:async c=>s({command:`ai-gateway billing credit-balance`,classification:{safeFlags:[`dry-run`]}},c,async()=>{if(c.dryRun){a({command:`cf ai-gateway billing credit-balance`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/billing/credit-balance`,pathParams:{},bodyKind:`none`});return}let s=await r(c),l=c.local?e:await t();c.accountId=l,i(await o(`Loading`,async()=>s.aiGateway.billing.creditBalance({account_id:l})),{successLabel:`Loaded`})})};function R(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const z={command:`get-topup-limits`,describe:`Retrieve the minimum and maximum allowed top-up amounts (in cents) for this account.`,builder:R,handler:async c=>s({command:`ai-gateway billing get-topup-limits`,classification:{safeFlags:[`dry-run`]}},c,async()=>{if(c.dryRun){a({command:`cf ai-gateway billing get-topup-limits`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/billing/topup/limits`,pathParams:{},bodyKind:`none`});return}let s=await r(c),l=c.local?e:await t();c.accountId=l,i(await o(`Loading`,async()=>s.aiGateway.billing.getTopupLimits({account_id:l})),{successLabel:`Loaded`})})};function B(e){return e.option(`type`,{type:`string`,description:`Filter invoice type: auto, manual, or all.`,choices:[`auto`,`all`,`manual`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const V={command:`invoice-history`,describe:`Retrieve a list of past invoices with pagination, optionally filtered by type.`,builder:h(B),handler:async c=>s({command:`ai-gateway billing invoice-history`,classification:{safeFlags:[`type`,`dry-run`]}},c,async()=>{let s={type:c.type};if(c.dryRun){a({command:`cf ai-gateway billing invoice-history`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/billing/invoice-history`,pathParams:{},query:s,bodyKind:`none`});return}let l=await r(c),u=c.local?e:await t();c.accountId=u,i(await o(`Loading`,async()=>l.aiGateway.billing.invoiceHistory({account_id:u,...s})),{successLabel:`Loaded`})})};function H(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const U={command:`invoice-preview`,describe:`Retrieve a preview of the upcoming invoice including line items and tax.`,builder:H,handler:async c=>s({command:`ai-gateway billing invoice-preview`,classification:{safeFlags:[`dry-run`]}},c,async()=>{if(c.dryRun){a({command:`cf ai-gateway billing invoice-preview`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/billing/invoice-preview`,pathParams:{},bodyKind:`none`});return}let s=await r(c),l=c.local?e:await t();c.accountId=l,i(await o(`Loading`,async()=>s.aiGateway.billing.invoicePreview({account_id:l})),{successLabel:`Loaded`})})};function W(e){return e.option(`amount`,{type:`number`,description:`Spending limit amount in cents (min 100).`}).option(`duration`,{type:`string`,description:`Spending limit duration.`,choices:[`daily`,`weekly`,`monthly`]}).option(`strategy`,{type:`string`,description:`Spending limit strategy.`,choices:[`fixed`,`sliding`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const G={command:`create`,describe:`Deprecated: spending limits can no longer be created, enabled, or modified and this endpoint always responds 403. Use the new AI Gateway spend limits instead: https://developers.cloudflare.com/ai-gateway/features/spend-limits/. Existing limits can be removed via DELETE /spending-limit.`,builder:W,handler:async l=>s({command:`ai-gateway billing spending-limit create`,classification:{safeFlags:[`duration`,`strategy`,`dry-run`]}},l,async()=>{if(l.dryRun){a({command:`cf ai-gateway billing spending-limit create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/billing/spending-limit`,pathParams:{},bodyKind:`json`,body:l.body===void 0?u({amount:l.amount,duration:d(l.duration,`duration`,`text`),strategy:d(l.strategy,`strategy`,`text`)}):c(l.body)});return}let s=await r(l),f=l.local?e:await t();if(l.accountId=f,l.body){let e=c(l.body);i(await o(`Creating`,async()=>s.aiGateway.billing.spendingLimit.create({...e,account_id:f})),{successLabel:`Created`});return}if(l.amount===void 0)throw Error(`--amount is required (or pass --body with this field set).`);l.duration===void 0&&(l.duration=await p(`duration`,`Spending limit duration.`,[`daily`,`weekly`,`monthly`])),l.strategy===void 0&&(l.strategy=await p(`strategy`,`Spending limit strategy.`,[`fixed`,`sliding`]));let m=u({amount:l.amount,duration:d(l.duration,`duration`,`text`),strategy:d(l.strategy,`strategy`,`text`)});i(await o(`Creating`,async()=>s.aiGateway.billing.spendingLimit.create({...m,account_id:f})),{successLabel:`Created`})})};function K(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const q={command:`delete`,describe:`Remove the spending limit for the account.`,builder:K,handler:async c=>s({command:`ai-gateway billing spending-limit delete`,classification:{safeFlags:[`dry-run`,`force`],shortFlagAliases:{f:{canonical:`force`,type:`boolean`}}}},c,async()=>{if(c.dryRun){a({command:`cf ai-gateway billing spending-limit delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/billing/spending-limit`,pathParams:{},bodyKind:`none`});return}let s=await r(c),l=c.local?e:await t();if(c.accountId=l,!await m({force:!!c.force})){process.stderr.write(`Aborted.
5
5
  `);return}i(await o(`Deleting`,async()=>s.aiGateway.billing.spendingLimit.delete({account_id:l})),{successLabel:`Deleted`})})};function J(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Y={command:`get`,describe:`Retrieve the current spending limit configuration for the account.`,builder:J,handler:async c=>s({command:`ai-gateway billing spending-limit get`,classification:{safeFlags:[`dry-run`]}},c,async()=>{if(c.dryRun){a({command:`cf ai-gateway billing spending-limit get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/billing/spending-limit`,pathParams:{},bodyKind:`none`});return}let s=await r(c),l=c.local?e:await t();c.accountId=l,i(await o(`Loading`,async()=>s.aiGateway.billing.spendingLimit.get({account_id:l})),{successLabel:`Loaded`})})},X={command:`spending-limit`,describe:`Operations for billing.spending-limit`,builder:e=>e.command(G).command(q).command(Y).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Z(e){return e.option(`amount`,{type:`number`,description:`Auto top-up amount in cents (min 1000).`}).option(`threshold`,{type:`number`,description:`Balance threshold in cents that triggers auto top-up (min 500).`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const Q={command:`create`,describe:`Configure auto top-up with a balance threshold and top-up amount. Dashboard sessions only: API token, OAuth, and service credentials are rejected with 403.`,builder:Z,handler:async l=>s({command:`ai-gateway billing topup config create`,classification:{safeFlags:[`dry-run`]}},l,async()=>{if(l.dryRun){a({command:`cf ai-gateway billing topup config create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/billing/topup/config`,pathParams:{},bodyKind:`json`,body:l.body===void 0?u({amount:l.amount,threshold:l.threshold}):c(l.body)});return}let s=await r(l),d=l.local?e:await t();if(l.accountId=d,l.body){let e=c(l.body);i(await o(`Creating`,async()=>s.aiGateway.billing.topup.config.create({...e,account_id:d})),{successLabel:`Created`});return}if(l.amount===void 0)throw Error(`--amount is required (or pass --body with this field set).`);if(l.threshold===void 0)throw Error(`--threshold is required (or pass --body with this field set).`);let f=u({amount:l.amount,threshold:l.threshold});i(await o(`Creating`,async()=>s.aiGateway.billing.topup.config.create({...f,account_id:d})),{successLabel:`Created`})})};function ne(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const re={command:`delete`,describe:`Remove the auto top-up configuration for the account. Dashboard sessions only: API token, OAuth, and service credentials are rejected with 403.`,builder:ne,handler:async c=>s({command:`ai-gateway billing topup config delete`,classification:{safeFlags:[`dry-run`,`force`],shortFlagAliases:{f:{canonical:`force`,type:`boolean`}}}},c,async()=>{if(c.dryRun){a({command:`cf ai-gateway billing topup config delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/billing/topup/config`,pathParams:{},bodyKind:`none`});return}let s=await r(c),l=c.local?e:await t();if(c.accountId=l,!await m({force:!!c.force})){process.stderr.write(`Aborted.
6
- `);return}i(await o(`Deleting`,async()=>s.aiGateway.billing.topup.config.delete({account_id:l})),{successLabel:`Deleted`})})};function ie(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const ae={command:`get`,describe:`Retrieve the current auto top-up threshold, amount, and any error state.`,builder:ie,handler:async c=>s({command:`ai-gateway billing topup config get`,classification:{safeFlags:[`dry-run`]}},c,async()=>{if(c.dryRun){a({command:`cf ai-gateway billing topup config get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/billing/topup/config`,pathParams:{},bodyKind:`none`});return}let s=await r(c),l=c.local?e:await t();c.accountId=l,i(await o(`Loading`,async()=>s.aiGateway.billing.topup.config.get({account_id:l})),{successLabel:`Loaded`})})},oe={command:`config`,describe:`Operations for billing.topup.config`,builder:e=>e.command(Q).command(re).command(ae).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function se(e){return e.option(`amount`,{type:`number`,description:`Top-up amount in cents (min 1000).`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const ce={command:`create`,describe:`Create a credit top-up for the given account, charged to the account's default payment method.`,builder:se,handler:async l=>s({command:`ai-gateway billing topup create`,classification:{safeFlags:[`dry-run`]}},l,async()=>{if(l.dryRun){a({command:`cf ai-gateway billing topup create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/billing/topup`,pathParams:{},bodyKind:`json`,body:l.body===void 0?u({amount:l.amount}):c(l.body)});return}let s=await r(l),d=l.local?e:await t();if(l.accountId=d,l.body){let e=c(l.body);i(await o(`Creating`,async()=>s.aiGateway.billing.topup.create({...e,account_id:d})),{successLabel:`Created`});return}if(l.amount===void 0)throw Error(`--amount is required (or pass --body with this field set).`);let f=u({amount:l.amount});i(await o(`Creating`,async()=>s.aiGateway.billing.topup.create({...f,account_id:d})),{successLabel:`Created`})})};function le(e){return e.option(`payment-methods`,{type:`string`,description:`Account-level payment methods, forwarded by the dashboard. Provide as a JSON array of objects or @path/to/file.json.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const ue={command:`eligibility`,describe:`Determine whether an account can self-serve a credit top-up, and if not, why. The dashboard forwards the account's payment-method list in the body; the reason logic is owned here.`,builder:le,handler:async d=>s({command:`ai-gateway billing topup eligibility`,classification:{safeFlags:[`dry-run`]}},d,async()=>{if(d.dryRun){a({command:`cf ai-gateway billing topup eligibility`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/billing/topup/eligibility`,pathParams:{},bodyKind:`json`,body:d.body===void 0?u({payment_methods:l(d[`payment-methods`],`payment-methods`)}):c(d.body)});return}let s=await r(d),f=d.local?e:await t();if(d.accountId=f,d.body){let e=c(d.body);i(await o(`Creating`,async()=>s.aiGateway.billing.topup.eligibility({...e,account_id:f})),{successLabel:`Created`});return}let p=u({payment_methods:l(d[`payment-methods`],`payment-methods`)});i(await o(`Creating`,async()=>s.aiGateway.billing.topup.eligibility({...p,account_id:f})),{successLabel:`Created`})})};function de(e){return e.option(`payment-intent-id`,{type:`string`,description:`Stripe invoice ID to check status for.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const fe={command:`status`,describe:`Get the payment processing status of a top-up by its invoice ID.`,builder:de,handler:async l=>s({command:`ai-gateway billing topup status`,classification:{safeFlags:[`dry-run`]}},l,async()=>{if(l.dryRun){a({command:`cf ai-gateway billing topup status`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/billing/topup/status`,pathParams:{},bodyKind:`json`,body:l.body===void 0?u({payment_intent_id:d(l[`payment-intent-id`],`payment-intent-id`,`text`)}):c(l.body)});return}let s=await r(l),p=l.local?e:await t();if(l.accountId=p,l.body){let e=c(l.body);i(await o(`Creating`,async()=>s.aiGateway.billing.topup.status({...e,account_id:p})),{successLabel:`Created`});return}l[`payment-intent-id`]===void 0&&(l[`payment-intent-id`]=await f(`payment-intent-id`,`Stripe invoice ID to check status for.`));let m=u({payment_intent_id:d(l[`payment-intent-id`],`payment-intent-id`,`text`)});i(await o(`Creating`,async()=>s.aiGateway.billing.topup.status({...m,account_id:p})),{successLabel:`Created`})})},pe={command:`topup`,describe:`Operations for billing.topup`,builder:e=>e.command(ce).command(ue).command(fe).command(oe).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function me(e){return e.option(`value-grouping-window`,{type:`string`,description:`Grouping window for usage data.`,choices:[`day`,`hour`],demandOption:!0}).option(`start-time`,{type:`number`,description:`Start time as Unix timestamp in milliseconds.`}).option(`end-time`,{type:`number`,description:`End time as Unix timestamp in milliseconds.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const he={command:`usage-history`,describe:`Retrieve aggregated usage meter event summaries for the given time range.`,builder:h(me),handler:async c=>s({command:`ai-gateway billing usage-history`,classification:{safeFlags:[`value-grouping-window`,`dry-run`]}},c,async()=>{let s={value_grouping_window:c[`value-grouping-window`],start_time:c[`start-time`],end_time:c[`end-time`]};if(c.dryRun){a({command:`cf ai-gateway billing usage-history`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/billing/usage-history`,pathParams:{},query:s,bodyKind:`none`});return}let l=await r(c),u=c.local?e:await t();c.accountId=u,i(await o(`Loading`,async()=>l.aiGateway.billing.usageHistory({account_id:u,...s})),{successLabel:`Loaded`})})},ge={command:`billing`,describe:`Operations for billing`,builder:e=>e.command(L).command(z).command(V).command(U).command(he).command(X).command(pe).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function _e(e){return e.positional(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`domain`,{type:`string`,description:`the customer-owned custom hostname`}).option(`min-tls`,{type:`string`,description:`The minTLS field`,choices:[`1.0`,`1.1`,`1.2`,`1.3`]}).option(`zone-id`,{type:`string`,description:`Cloudflare Zone ID owning the custom hostname`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const ve={command:`create <gateway-id>`,describe:`Provisions a Cloudflare-for-SaaS custom hostname and returns the CNAME target to point DNS at.`,builder:_e,handler:async l=>s({command:`ai-gateway custom-domains create`,classification:{safeFlags:[`min-tls`,`dry-run`]}},l,async()=>{if(l.dryRun){a({command:`cf ai-gateway custom-domains create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${l[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(l[`gateway-id`]))}/custom-domains`,pathParams:{"gateway-id":String(l[`gateway-id`]??``)},bodyKind:`json`,body:l.body===void 0?u({domain:d(l.domain,`domain`,`text`),minTLS:d(l[`min-tls`],`min-tls`,`text`),zone_id:d(l[`zone-id`],`zone-id`,`text`)}):c(l.body)});return}let s=await r(l),p=l.local?e:await t();if(l.accountId=p,l.body){let e=c(l.body);i(await o(`Creating`,async()=>s.aiGateway.customDomains.create({...e,account_id:p,gateway_id:l[`gateway-id`]})),{successLabel:`Created`});return}l.domain===void 0&&(l.domain=await f(`domain`,`the customer-owned custom hostname`)),l[`zone-id`]===void 0&&(l[`zone-id`]=await f(`zone-id`,`Cloudflare Zone ID owning the custom hostname`));let m=u({domain:d(l.domain,`domain`,`text`),minTLS:d(l[`min-tls`],`min-tls`,`text`),zone_id:d(l[`zone-id`],`zone-id`,`text`)});i(await o(`Creating`,async()=>s.aiGateway.customDomains.create({...m,account_id:p,gateway_id:l[`gateway-id`]})),{successLabel:`Created`})})};function ye(e){return e.positional(`hostname`,{type:`string`,description:`the customer-owned custom hostname`,demandOption:!0}).option(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const be={command:`delete <hostname>`,describe:`Deletes an AI Gateway dataset.`,builder:ye,handler:async c=>s({command:`ai-gateway custom-domains delete`,classification:{safeFlags:[`dry-run`,`force`],shortFlagAliases:{f:{canonical:`force`,type:`boolean`}}}},c,async()=>{if(c.dryRun){a({command:`cf ai-gateway custom-domains delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${c[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(c[`gateway-id`]))}/custom-domains/${c.hostname==null?`<hostname>`:encodeURIComponent(String(c.hostname))}`,pathParams:{"gateway-id":String(c[`gateway-id`]??``),hostname:String(c.hostname??``)},bodyKind:`none`});return}let s=await r(c),l=c.local?e:await t();if(c.accountId=l,!await m({force:!!c.force})){process.stderr.write(`Aborted.
6
+ `);return}i(await o(`Deleting`,async()=>s.aiGateway.billing.topup.config.delete({account_id:l})),{successLabel:`Deleted`})})};function ie(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const ae={command:`get`,describe:`Retrieve the current auto top-up threshold, amount, and any error state.`,builder:ie,handler:async c=>s({command:`ai-gateway billing topup config get`,classification:{safeFlags:[`dry-run`]}},c,async()=>{if(c.dryRun){a({command:`cf ai-gateway billing topup config get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/billing/topup/config`,pathParams:{},bodyKind:`none`});return}let s=await r(c),l=c.local?e:await t();c.accountId=l,i(await o(`Loading`,async()=>s.aiGateway.billing.topup.config.get({account_id:l})),{successLabel:`Loaded`})})},oe={command:`config`,describe:`Operations for billing.topup.config`,builder:e=>e.command(Q).command(re).command(ae).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function se(e){return e.option(`amount`,{type:`number`,description:`Top-up amount in cents (min 1000).`}).option(`payment-method-id`,{type:`string`,description:`Stripe PaymentMethod to charge instead of the customer's default payment method.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const ce={command:`create`,describe:`Create a credit top-up for the given account, charged to the account's default payment method.`,builder:se,handler:async l=>s({command:`ai-gateway billing topup create`,classification:{safeFlags:[`dry-run`]}},l,async()=>{if(l.dryRun){a({command:`cf ai-gateway billing topup create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/billing/topup`,pathParams:{},bodyKind:`json`,body:l.body===void 0?u({amount:l.amount,payment_method_id:d(l[`payment-method-id`],`payment-method-id`,`text`)}):c(l.body)});return}let s=await r(l),f=l.local?e:await t();if(l.accountId=f,l.body){let e=c(l.body);i(await o(`Creating`,async()=>s.aiGateway.billing.topup.create({...e,account_id:f})),{successLabel:`Created`});return}if(l.amount===void 0)throw Error(`--amount is required (or pass --body with this field set).`);let p=u({amount:l.amount,payment_method_id:d(l[`payment-method-id`],`payment-method-id`,`text`)});i(await o(`Creating`,async()=>s.aiGateway.billing.topup.create({...p,account_id:f})),{successLabel:`Created`})})};function le(e){return e.option(`payment-methods`,{type:`string`,description:`Account-level payment methods, forwarded by the dashboard. Provide as a JSON array of objects or @path/to/file.json.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const ue={command:`eligibility`,describe:`Determine whether an account can self-serve a credit top-up, and if not, why. The dashboard forwards the account's payment-method list in the body; the reason logic is owned here.`,builder:le,handler:async d=>s({command:`ai-gateway billing topup eligibility`,classification:{safeFlags:[`dry-run`]}},d,async()=>{if(d.dryRun){a({command:`cf ai-gateway billing topup eligibility`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/billing/topup/eligibility`,pathParams:{},bodyKind:`json`,body:d.body===void 0?u({payment_methods:l(d[`payment-methods`],`payment-methods`)}):c(d.body)});return}let s=await r(d),f=d.local?e:await t();if(d.accountId=f,d.body){let e=c(d.body);i(await o(`Creating`,async()=>s.aiGateway.billing.topup.eligibility({...e,account_id:f})),{successLabel:`Created`});return}let p=u({payment_methods:l(d[`payment-methods`],`payment-methods`)});i(await o(`Creating`,async()=>s.aiGateway.billing.topup.eligibility({...p,account_id:f})),{successLabel:`Created`})})};function de(e){return e.option(`payment-intent-id`,{type:`string`,description:`Stripe invoice ID to check status for.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const fe={command:`status`,describe:`Get the payment processing status of a top-up by its invoice ID.`,builder:de,handler:async l=>s({command:`ai-gateway billing topup status`,classification:{safeFlags:[`dry-run`]}},l,async()=>{if(l.dryRun){a({command:`cf ai-gateway billing topup status`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/billing/topup/status`,pathParams:{},bodyKind:`json`,body:l.body===void 0?u({payment_intent_id:d(l[`payment-intent-id`],`payment-intent-id`,`text`)}):c(l.body)});return}let s=await r(l),p=l.local?e:await t();if(l.accountId=p,l.body){let e=c(l.body);i(await o(`Creating`,async()=>s.aiGateway.billing.topup.status({...e,account_id:p})),{successLabel:`Created`});return}l[`payment-intent-id`]===void 0&&(l[`payment-intent-id`]=await f(`payment-intent-id`,`Stripe invoice ID to check status for.`));let m=u({payment_intent_id:d(l[`payment-intent-id`],`payment-intent-id`,`text`)});i(await o(`Creating`,async()=>s.aiGateway.billing.topup.status({...m,account_id:p})),{successLabel:`Created`})})},pe={command:`topup`,describe:`Operations for billing.topup`,builder:e=>e.command(ce).command(ue).command(fe).command(oe).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function me(e){return e.option(`value-grouping-window`,{type:`string`,description:`Grouping window for usage data.`,choices:[`day`,`hour`],demandOption:!0}).option(`start-time`,{type:`number`,description:`Start time as Unix timestamp in milliseconds.`}).option(`end-time`,{type:`number`,description:`End time as Unix timestamp in milliseconds.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const he={command:`usage-history`,describe:`Retrieve aggregated usage meter event summaries for the given time range.`,builder:h(me),handler:async c=>s({command:`ai-gateway billing usage-history`,classification:{safeFlags:[`value-grouping-window`,`dry-run`]}},c,async()=>{let s={value_grouping_window:c[`value-grouping-window`],start_time:c[`start-time`],end_time:c[`end-time`]};if(c.dryRun){a({command:`cf ai-gateway billing usage-history`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/billing/usage-history`,pathParams:{},query:s,bodyKind:`none`});return}let l=await r(c),u=c.local?e:await t();c.accountId=u,i(await o(`Loading`,async()=>l.aiGateway.billing.usageHistory({account_id:u,...s})),{successLabel:`Loaded`})})},ge={command:`billing`,describe:`Operations for billing`,builder:e=>e.command(L).command(z).command(V).command(U).command(he).command(X).command(pe).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function _e(e){return e.positional(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`domain`,{type:`string`,description:`the customer-owned custom hostname`}).option(`min-tls`,{type:`string`,description:`The minTLS field`,choices:[`1.0`,`1.1`,`1.2`,`1.3`]}).option(`zone-id`,{type:`string`,description:`Cloudflare Zone ID owning the custom hostname`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const ve={command:`create <gateway-id>`,describe:`Provisions a Cloudflare-for-SaaS custom hostname and returns the CNAME target to point DNS at.`,builder:_e,handler:async l=>s({command:`ai-gateway custom-domains create`,classification:{safeFlags:[`min-tls`,`dry-run`]}},l,async()=>{if(l.dryRun){a({command:`cf ai-gateway custom-domains create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${l[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(l[`gateway-id`]))}/custom-domains`,pathParams:{"gateway-id":String(l[`gateway-id`]??``)},bodyKind:`json`,body:l.body===void 0?u({domain:d(l.domain,`domain`,`text`),minTLS:d(l[`min-tls`],`min-tls`,`text`),zone_id:d(l[`zone-id`],`zone-id`,`text`)}):c(l.body)});return}let s=await r(l),p=l.local?e:await t();if(l.accountId=p,l.body){let e=c(l.body);i(await o(`Creating`,async()=>s.aiGateway.customDomains.create({...e,account_id:p,gateway_id:l[`gateway-id`]})),{successLabel:`Created`});return}l.domain===void 0&&(l.domain=await f(`domain`,`the customer-owned custom hostname`)),l[`zone-id`]===void 0&&(l[`zone-id`]=await f(`zone-id`,`Cloudflare Zone ID owning the custom hostname`));let m=u({domain:d(l.domain,`domain`,`text`),minTLS:d(l[`min-tls`],`min-tls`,`text`),zone_id:d(l[`zone-id`],`zone-id`,`text`)});i(await o(`Creating`,async()=>s.aiGateway.customDomains.create({...m,account_id:p,gateway_id:l[`gateway-id`]})),{successLabel:`Created`})})};function ye(e){return e.positional(`hostname`,{type:`string`,description:`the customer-owned custom hostname`,demandOption:!0}).option(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const be={command:`delete <hostname>`,describe:`Deletes an AI Gateway dataset.`,builder:ye,handler:async c=>s({command:`ai-gateway custom-domains delete`,classification:{safeFlags:[`dry-run`,`force`],shortFlagAliases:{f:{canonical:`force`,type:`boolean`}}}},c,async()=>{if(c.dryRun){a({command:`cf ai-gateway custom-domains delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${c[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(c[`gateway-id`]))}/custom-domains/${c.hostname==null?`<hostname>`:encodeURIComponent(String(c.hostname))}`,pathParams:{"gateway-id":String(c[`gateway-id`]??``),hostname:String(c.hostname??``)},bodyKind:`none`});return}let s=await r(c),l=c.local?e:await t();if(c.accountId=l,!await m({force:!!c.force})){process.stderr.write(`Aborted.
7
7
  `);return}i(await o(`Deleting`,async()=>s.aiGateway.customDomains.delete({account_id:l,gateway_id:c[`gateway-id`],hostname:c.hostname})),{successLabel:`Deleted`})})};function xe(e){return e.positional(`hostname`,{type:`string`,description:`the customer-owned custom hostname`,demandOption:!0}).option(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Se={command:`get <hostname>`,describe:`Retrieves details for a specific AI Gateway dataset.`,builder:xe,handler:async c=>s({command:`ai-gateway custom-domains get`,classification:{safeFlags:[`dry-run`]}},c,async()=>{if(c.dryRun){a({command:`cf ai-gateway custom-domains get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${c[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(c[`gateway-id`]))}/custom-domains/${c.hostname==null?`<hostname>`:encodeURIComponent(String(c.hostname))}`,pathParams:{"gateway-id":String(c[`gateway-id`]??``),hostname:String(c.hostname??``)},bodyKind:`none`});return}let s=await r(c),l=c.local?e:await t();c.accountId=l,i(await o(`Loading`,async()=>s.aiGateway.customDomains.get({account_id:l,gateway_id:c[`gateway-id`],hostname:c.hostname})),{successLabel:`Loaded`})})};function Ce(e){return e.option(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`page`,{type:`number`,description:`Page`}).option(`per-page`,{type:`number`,description:`Per page`}).option(`status`,{type:`string`,description:`Status`,choices:[`initializing`,`pending_dcv`,`active`,`blocked`,`error`]}).option(`search`,{type:`string`,description:`Search by hostname`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const we={command:`list`,describe:`Lists all AI Gateway evaluator types configured for the account.`,builder:h(Ce),handler:async c=>s({command:`ai-gateway custom-domains list`,classification:{safeFlags:[`status`,`dry-run`]}},c,async()=>{let s={page:c.page,per_page:c[`per-page`],status:c.status,search:c.search};if(c.dryRun){a({command:`cf ai-gateway custom-domains list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${c[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(c[`gateway-id`]))}/custom-domains`,pathParams:{"gateway-id":String(c[`gateway-id`]??``)},query:s,bodyKind:`none`});return}let l=await r(c),u=c.local?e:await t();c.accountId=u,i(await o(`Loading`,async()=>l.aiGateway.customDomains.list({account_id:u,gateway_id:c[`gateway-id`],...s})),{successLabel:`Loaded`})})},Te={command:`custom-domains`,describe:`Operations for custom-domains`,builder:e=>e.command(ve).command(be).command(Se).command(we).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Ee(e){return e.positional(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`enable`,{type:`boolean`,description:`The enable field`}).option(`filters`,{type:`string`,description:`The filters field. Provide as a JSON array of objects or @path/to/file.json.`}).option(`name`,{type:`string`,description:`The name field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const De={command:`create <gateway-id>`,describe:`Creates a new AI Gateway.`,builder:Ee,handler:async p=>s({command:`ai-gateway datasets create`,classification:{safeFlags:[`enable`,`dry-run`]}},p,async()=>{if(p.dryRun){a({command:`cf ai-gateway datasets create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${p[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(p[`gateway-id`]))}/datasets`,pathParams:{"gateway-id":String(p[`gateway-id`]??``)},bodyKind:`json`,body:p.body===void 0?u({enable:p.enable,filters:l(p.filters,`filters`),name:d(p.name,`name`,`text`)}):c(p.body)});return}let s=await r(p),m=p.local?e:await t();if(p.accountId=m,p.body){let e=c(p.body);i(await o(`Creating`,async()=>s.aiGateway.datasets.create({...e,account_id:m,gateway_id:p[`gateway-id`]})),{successLabel:`Created`});return}if(p.enable===void 0)throw Error(`--enable is required (or pass --body with this field set).`);if(p.filters===void 0)throw Error(`--filters is required (or pass --body with this field set).`);p.name===void 0&&(p.name=await f(`name`,`The name field`));let h=u({enable:p.enable,filters:l(p.filters,`filters`),name:d(p.name,`name`,`text`)});i(await o(`Creating`,async()=>s.aiGateway.datasets.create({...h,account_id:m,gateway_id:p[`gateway-id`]})),{successLabel:`Created`})})};function Oe(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const ke={command:`delete <id>`,describe:`Deletes an AI Gateway dataset.`,builder:Oe,handler:async c=>s({command:`ai-gateway datasets delete`,classification:{safeFlags:[`dry-run`,`force`],shortFlagAliases:{f:{canonical:`force`,type:`boolean`}}}},c,async()=>{if(c.dryRun){a({command:`cf ai-gateway datasets delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${c[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(c[`gateway-id`]))}/datasets/${c.id==null?`<id>`:encodeURIComponent(String(c.id))}`,pathParams:{"gateway-id":String(c[`gateway-id`]??``),id:String(c.id??``)},bodyKind:`none`});return}let s=await r(c),l=c.local?e:await t();if(c.accountId=l,!await m({force:!!c.force})){process.stderr.write(`Aborted.
8
8
  `);return}i(await o(`Deleting`,async()=>s.aiGateway.datasets.delete({account_id:l,gateway_id:c[`gateway-id`],id:c.id})),{successLabel:`Deleted`})})};function Ae(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const je={command:`get <id>`,describe:`Retrieves details for a specific AI Gateway dataset.`,builder:Ae,handler:async c=>s({command:`ai-gateway datasets get`,classification:{safeFlags:[`dry-run`]}},c,async()=>{if(c.dryRun){a({command:`cf ai-gateway datasets get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${c[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(c[`gateway-id`]))}/datasets/${c.id==null?`<id>`:encodeURIComponent(String(c.id))}`,pathParams:{"gateway-id":String(c[`gateway-id`]??``),id:String(c.id??``)},bodyKind:`none`});return}let s=await r(c),l=c.local?e:await t();c.accountId=l,i(await o(`Loading`,async()=>s.aiGateway.datasets.get({account_id:l,gateway_id:c[`gateway-id`],id:c.id})),{successLabel:`Loaded`})})};function Me(e){return e.option(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`page`,{type:`number`,description:`Page`}).option(`per-page`,{type:`number`,description:`Per page`}).option(`name`,{type:`string`,description:`Name`}).option(`enable`,{type:`boolean`,description:`Enable`}).option(`search`,{type:`string`,description:`Search by id, name, filters`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Ne={command:`list`,describe:`Lists all AI Gateway evaluator types configured for the account.`,builder:Me,handler:async c=>s({command:`ai-gateway datasets list`,classification:{safeFlags:[`enable`,`dry-run`]}},c,async()=>{let s={page:c.page,per_page:c[`per-page`],name:c.name,enable:c.enable,search:c.search};if(c.dryRun){a({command:`cf ai-gateway datasets list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${c[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(c[`gateway-id`]))}/datasets`,pathParams:{"gateway-id":String(c[`gateway-id`]??``)},query:s,bodyKind:`none`});return}let l=await r(c),u=c.local?e:await t();c.accountId=u,i(await o(`Loading`,async()=>l.aiGateway.datasets.list({account_id:u,gateway_id:c[`gateway-id`],...s})),{successLabel:`Loaded`})})};function Pe(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`enable`,{type:`boolean`,description:`The enable field`}).option(`filters`,{type:`string`,description:`The filters field. Provide as a JSON array of objects or @path/to/file.json.`}).option(`name`,{type:`string`,description:`The name field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const Fe={command:`update <id>`,describe:`Updates an existing AI Gateway dataset.`,builder:Pe,handler:async p=>s({command:`ai-gateway datasets update`,classification:{safeFlags:[`enable`,`dry-run`]}},p,async()=>{if(p.dryRun){a({command:`cf ai-gateway datasets update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${p[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(p[`gateway-id`]))}/datasets/${p.id==null?`<id>`:encodeURIComponent(String(p.id))}`,pathParams:{"gateway-id":String(p[`gateway-id`]??``),id:String(p.id??``)},bodyKind:`json`,body:p.body===void 0?u({enable:p.enable,filters:l(p.filters,`filters`),name:d(p.name,`name`,`text`)}):c(p.body)});return}let s=await r(p),m=p.local?e:await t();if(p.accountId=m,p.body){let e=c(p.body);i(await o(`Updating`,async()=>s.aiGateway.datasets.update({...e,account_id:m,gateway_id:p[`gateway-id`],id:p.id})),{successLabel:`Updated`});return}if(p.enable===void 0)throw Error(`--enable is required (or pass --body with this field set).`);if(p.filters===void 0)throw Error(`--filters is required (or pass --body with this field set).`);p.name===void 0&&(p.name=await f(`name`,`The name field`));let h=u({enable:p.enable,filters:l(p.filters,`filters`),name:d(p.name,`name`,`text`)});i(await o(`Updating`,async()=>s.aiGateway.datasets.update({...h,account_id:m,gateway_id:p[`gateway-id`],id:p.id})),{successLabel:`Updated`})})},Ie={command:`datasets`,describe:`Curated collections of gateway logs used as inputs for evaluations and fine-tuning`,builder:e=>e.command(De).command(ke).command(je).command(Ne).command(Fe).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Le(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`gateway-id`,{type:`string`,description:`Gateway ID`,demandOption:!0}).option(`version-id`,{type:`string`,description:`The version_id field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const Re={command:`create-deployment <id>`,describe:`Create a new AI Gateway Dynamic Route Deployment.`,builder:Le,handler:async l=>s({command:`ai-gateway dynamic-routing create-deployment`,classification:{safeFlags:[`dry-run`]}},l,async()=>{if(l.dryRun){a({command:`cf ai-gateway dynamic-routing create-deployment`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${l[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(l[`gateway-id`]))}/routes/${l.id==null?`<id>`:encodeURIComponent(String(l.id))}/deployments`,pathParams:{"gateway-id":String(l[`gateway-id`]??``),id:String(l.id??``)},bodyKind:`json`,body:l.body===void 0?u({version_id:d(l[`version-id`],`version-id`,`text`)}):c(l.body)});return}let s=await r(l),p=l.local?e:await t();if(l.accountId=p,l.body){let e=c(l.body);i(await o(`Creating`,async()=>s.aiGateway.dynamicRouting.createDeployment({...e,account_id:p,gateway_id:l[`gateway-id`],id:l.id})),{successLabel:`Created`});return}l[`version-id`]===void 0&&(l[`version-id`]=await f(`version-id`,`The version_id field`));let m=u({version_id:d(l[`version-id`],`version-id`,`text`)});i(await o(`Creating`,async()=>s.aiGateway.dynamicRouting.createDeployment({...m,account_id:p,gateway_id:l[`gateway-id`],id:l.id})),{successLabel:`Created`})})};function ze(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`gateway-id`,{type:`string`,description:`Gateway ID`,demandOption:!0}).option(`elements`,{type:`string`,description:`The elements field. Provide as a JSON array of objects or @path/to/file.json.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const Be={command:`create-version <id>`,describe:`Create a new AI Gateway Dynamic Route Version.`,builder:ze,handler:async d=>s({command:`ai-gateway dynamic-routing create-version`,classification:{safeFlags:[`dry-run`]}},d,async()=>{if(d.dryRun){a({command:`cf ai-gateway dynamic-routing create-version`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${d[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(d[`gateway-id`]))}/routes/${d.id==null?`<id>`:encodeURIComponent(String(d.id))}/versions`,pathParams:{"gateway-id":String(d[`gateway-id`]??``),id:String(d.id??``)},bodyKind:`json`,body:d.body===void 0?u({elements:l(d.elements,`elements`)}):c(d.body)});return}let s=await r(d),f=d.local?e:await t();if(d.accountId=f,d.body){let e=c(d.body);i(await o(`Creating`,async()=>s.aiGateway.dynamicRouting.createVersion({...e,account_id:f,gateway_id:d[`gateway-id`],id:d.id})),{successLabel:`Created`});return}if(d.elements===void 0)throw Error(`--elements is required (or pass --body with this field set).`);let p=u({elements:l(d.elements,`elements`)});i(await o(`Creating`,async()=>s.aiGateway.dynamicRouting.createVersion({...p,account_id:f,gateway_id:d[`gateway-id`],id:d.id})),{successLabel:`Created`})})};function Ve(e){return e.positional(`gateway-id`,{type:`string`,description:`Gateway ID`,demandOption:!0}).option(`elements`,{type:`string`,description:`The elements field. Provide as a JSON array of objects or @path/to/file.json.`}).option(`name`,{type:`string`,description:`The name field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const He={command:`create <gateway-id>`,describe:`Create a new AI Gateway Dynamic Route.`,builder:Ve,handler:async p=>s({command:`ai-gateway dynamic-routing create`,classification:{safeFlags:[`dry-run`]}},p,async()=>{if(p.dryRun){a({command:`cf ai-gateway dynamic-routing create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${p[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(p[`gateway-id`]))}/routes`,pathParams:{"gateway-id":String(p[`gateway-id`]??``)},bodyKind:`json`,body:p.body===void 0?u({elements:l(p.elements,`elements`),name:d(p.name,`name`,`text`)}):c(p.body)});return}let s=await r(p),m=p.local?e:await t();if(p.accountId=m,p.body){let e=c(p.body);i(await o(`Creating`,async()=>s.aiGateway.dynamicRouting.create({...e,account_id:m,gateway_id:p[`gateway-id`]})),{successLabel:`Created`});return}if(p.elements===void 0)throw Error(`--elements is required (or pass --body with this field set).`);p.name===void 0&&(p.name=await f(`name`,`The name field`));let h=u({elements:l(p.elements,`elements`),name:d(p.name,`name`,`text`)});i(await o(`Creating`,async()=>s.aiGateway.dynamicRouting.create({...h,account_id:m,gateway_id:p[`gateway-id`]})),{successLabel:`Created`})})};function Ue(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`gateway-id`,{type:`string`,description:`Gateway ID`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const We={command:`delete <id>`,describe:`Delete an AI Gateway Dynamic Route.`,builder:Ue,handler:async c=>s({command:`ai-gateway dynamic-routing delete`,classification:{safeFlags:[`dry-run`,`force`],shortFlagAliases:{f:{canonical:`force`,type:`boolean`}}}},c,async()=>{if(c.dryRun){a({command:`cf ai-gateway dynamic-routing delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${c[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(c[`gateway-id`]))}/routes/${c.id==null?`<id>`:encodeURIComponent(String(c.id))}`,pathParams:{"gateway-id":String(c[`gateway-id`]??``),id:String(c.id??``)},bodyKind:`none`});return}let s=await r(c),l=c.local?e:await t();if(c.accountId=l,!await m({force:!!c.force})){process.stderr.write(`Aborted.
9
9
  `);return}i(await o(`Deleting`,async()=>s.aiGateway.dynamicRouting.delete({account_id:l,gateway_id:c[`gateway-id`],id:c.id})),{successLabel:`Deleted`})})};function Ge(e){return e.positional(`version-id`,{type:`string`,description:`Version ID`,demandOption:!0}).option(`gateway-id`,{type:`string`,description:`Gateway ID`,demandOption:!0}).option(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Ke={command:`get-version <version-id>`,describe:`Get an AI Gateway Dynamic Route Version.`,builder:Ge,handler:async c=>s({command:`ai-gateway dynamic-routing get-version`,classification:{safeFlags:[`dry-run`]}},c,async()=>{if(c.dryRun){a({command:`cf ai-gateway dynamic-routing get-version`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${c[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(c[`gateway-id`]))}/routes/${c.id==null?`<id>`:encodeURIComponent(String(c.id))}/versions/${c[`version-id`]==null?`<version-id>`:encodeURIComponent(String(c[`version-id`]))}`,pathParams:{"gateway-id":String(c[`gateway-id`]??``),id:String(c.id??``),"version-id":String(c[`version-id`]??``)},bodyKind:`none`});return}let s=await r(c),l=c.local?e:await t();c.accountId=l,i(await o(`Loading`,async()=>s.aiGateway.dynamicRouting.getVersion({account_id:l,gateway_id:c[`gateway-id`],id:c.id,version_id:c[`version-id`]})),{successLabel:`Loaded`})})};function qe(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`gateway-id`,{type:`string`,description:`Gateway ID`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Je={command:`get <id>`,describe:`Get an AI Gateway Dynamic Route.`,builder:qe,handler:async c=>s({command:`ai-gateway dynamic-routing get`,classification:{safeFlags:[`dry-run`]}},c,async()=>{if(c.dryRun){a({command:`cf ai-gateway dynamic-routing get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${c[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(c[`gateway-id`]))}/routes/${c.id==null?`<id>`:encodeURIComponent(String(c.id))}`,pathParams:{"gateway-id":String(c[`gateway-id`]??``),id:String(c.id??``)},bodyKind:`none`});return}let s=await r(c),l=c.local?e:await t();c.accountId=l,i(await o(`Loading`,async()=>s.aiGateway.dynamicRouting.get({account_id:l,gateway_id:c[`gateway-id`],id:c.id})),{successLabel:`Loaded`})})};function Ye(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`gateway-id`,{type:`string`,description:`Gateway ID`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Xe={command:`list-deployments <id>`,describe:`List all AI Gateway Dynamic Route Deployments.`,builder:Ye,handler:async c=>s({command:`ai-gateway dynamic-routing list-deployments`,classification:{safeFlags:[`dry-run`]}},c,async()=>{if(c.dryRun){a({command:`cf ai-gateway dynamic-routing list-deployments`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${c[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(c[`gateway-id`]))}/routes/${c.id==null?`<id>`:encodeURIComponent(String(c.id))}/deployments`,pathParams:{"gateway-id":String(c[`gateway-id`]??``),id:String(c.id??``)},bodyKind:`none`});return}let s=await r(c),l=c.local?e:await t();c.accountId=l,i(await o(`Loading`,async()=>s.aiGateway.dynamicRouting.listDeployments({account_id:l,gateway_id:c[`gateway-id`],id:c.id})),{successLabel:`Loaded`})})};function Ze(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`gateway-id`,{type:`string`,description:`Gateway ID`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Qe={command:`list-versions <id>`,describe:`List all AI Gateway Dynamic Route Versions.`,builder:Ze,handler:async c=>s({command:`ai-gateway dynamic-routing list-versions`,classification:{safeFlags:[`dry-run`]}},c,async()=>{if(c.dryRun){a({command:`cf ai-gateway dynamic-routing list-versions`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${c[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(c[`gateway-id`]))}/routes/${c.id==null?`<id>`:encodeURIComponent(String(c.id))}/versions`,pathParams:{"gateway-id":String(c[`gateway-id`]??``),id:String(c.id??``)},bodyKind:`none`});return}let s=await r(c),l=c.local?e:await t();c.accountId=l,i(await o(`Loading`,async()=>s.aiGateway.dynamicRouting.listVersions({account_id:l,gateway_id:c[`gateway-id`],id:c.id})),{successLabel:`Loaded`})})};function $e(e){return e.option(`gateway-id`,{type:`string`,description:`Gateway ID`,demandOption:!0}).option(`page`,{type:`number`,description:`Page number`}).option(`per-page`,{type:`number`,description:`Number of routes per page`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const et={command:`list`,describe:`List all AI Gateway Dynamic Routes.`,builder:$e,handler:async c=>s({command:`ai-gateway dynamic-routing list`,classification:{safeFlags:[`dry-run`]}},c,async()=>{let s={page:c.page,per_page:c[`per-page`]};if(c.dryRun){a({command:`cf ai-gateway dynamic-routing list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${c[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(c[`gateway-id`]))}/routes`,pathParams:{"gateway-id":String(c[`gateway-id`]??``)},query:s,bodyKind:`none`});return}let l=await r(c),u=c.local?e:await t();c.accountId=u,i(await o(`Loading`,async()=>l.aiGateway.dynamicRouting.list({account_id:u,gateway_id:c[`gateway-id`],...s})),{successLabel:`Loaded`})})};function tt(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`gateway-id`,{type:`string`,description:`Gateway ID`,demandOption:!0}).option(`name`,{type:`string`,description:`The name field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const nt={command:`update <id>`,describe:`Update an AI Gateway Dynamic Route.`,builder:tt,handler:async l=>s({command:`ai-gateway dynamic-routing update`,classification:{safeFlags:[`dry-run`]}},l,async()=>{if(l.dryRun){a({command:`cf ai-gateway dynamic-routing update`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${l[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(l[`gateway-id`]))}/routes/${l.id==null?`<id>`:encodeURIComponent(String(l.id))}`,pathParams:{"gateway-id":String(l[`gateway-id`]??``),id:String(l.id??``)},bodyKind:`json`,body:l.body===void 0?u({name:d(l.name,`name`,`text`)}):c(l.body)});return}let s=await r(l),p=l.local?e:await t();if(l.accountId=p,l.body){let e=c(l.body);i(await o(`Updating`,async()=>s.aiGateway.dynamicRouting.update({...e,account_id:p,gateway_id:l[`gateway-id`],id:l.id})),{successLabel:`Updated`});return}l.name===void 0&&(l.name=await f(`name`,`The name field`));let m=u({name:d(l.name,`name`,`text`)});i(await o(`Updating`,async()=>s.aiGateway.dynamicRouting.update({...m,account_id:p,gateway_id:l[`gateway-id`],id:l.id})),{successLabel:`Updated`})})},rt={command:`dynamic-routing`,describe:`Route requests across multiple AI providers with fallback, load-balancing, and versioned deployments`,builder:e=>e.command(He).command(Re).command(Be).command(We).command(Je).command(Ke).command(et).command(Xe).command(Qe).command(nt).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function it(e){return e.option(`page`,{type:`number`,description:`Page`}).option(`per-page`,{type:`number`,description:`Per page`}).option(`order-by`,{type:`string`,description:`Order by`}).option(`order-by-direction`,{type:`string`,description:`Order by direction`,choices:[`asc`,`desc`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const at={command:`list`,describe:`Lists all available evaluator types for scoring AI gateway responses.`,builder:h(it),handler:async c=>s({command:`ai-gateway evaluation-types list`,classification:{safeFlags:[`order-by-direction`,`dry-run`]}},c,async()=>{let s={page:c.page,per_page:c[`per-page`],order_by:c[`order-by`],order_by_direction:c[`order-by-direction`]};if(c.dryRun){a({command:`cf ai-gateway evaluation-types list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/evaluation-types`,pathParams:{},query:s,bodyKind:`none`});return}let l=await r(c),u=c.local?e:await t();c.accountId=u,i(await o(`Loading`,async()=>l.aiGateway.evaluationTypes.list({account_id:u,...s})),{successLabel:`Loaded`})})},ot={command:`evaluation-types`,describe:`Available evaluator types for scoring AI gateway responses (accuracy, toxicity, etc.)`,builder:e=>e.command(at).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function st(e){return e.positional(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`dataset-ids`,{type:`string`,array:!0,description:`The dataset_ids field`}).option(`evaluation-type-ids`,{type:`string`,array:!0,description:`The evaluation_type_ids field`}).option(`name`,{type:`string`,description:`The name field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const ct={command:`create <gateway-id>`,describe:`Creates a new AI Gateway.`,builder:st,handler:async l=>s({command:`ai-gateway evaluations create`,classification:{safeFlags:[`dry-run`]}},l,async()=>{if(l.dryRun){a({command:`cf ai-gateway evaluations create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${l[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(l[`gateway-id`]))}/evaluations`,pathParams:{"gateway-id":String(l[`gateway-id`]??``)},bodyKind:`json`,body:l.body===void 0?u({dataset_ids:l[`dataset-ids`],evaluation_type_ids:l[`evaluation-type-ids`],name:d(l.name,`name`,`text`)}):c(l.body)});return}let s=await r(l),p=l.local?e:await t();if(l.accountId=p,l.body){let e=c(l.body);i(await o(`Creating`,async()=>s.aiGateway.evaluations.create({...e,account_id:p,gateway_id:l[`gateway-id`]})),{successLabel:`Created`});return}if(l[`dataset-ids`]===void 0)throw Error(`--dataset-ids is required (or pass --body with this field set).`);if(l[`evaluation-type-ids`]===void 0)throw Error(`--evaluation-type-ids is required (or pass --body with this field set).`);l.name===void 0&&(l.name=await f(`name`,`The name field`));let m=u({dataset_ids:l[`dataset-ids`],evaluation_type_ids:l[`evaluation-type-ids`],name:d(l.name,`name`,`text`)});i(await o(`Creating`,async()=>s.aiGateway.evaluations.create({...m,account_id:p,gateway_id:l[`gateway-id`]})),{successLabel:`Created`})})};function lt(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const ut={command:`delete <id>`,describe:`Deletes an AI Gateway dataset.`,builder:lt,handler:async c=>s({command:`ai-gateway evaluations delete`,classification:{safeFlags:[`dry-run`,`force`],shortFlagAliases:{f:{canonical:`force`,type:`boolean`}}}},c,async()=>{if(c.dryRun){a({command:`cf ai-gateway evaluations delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${c[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(c[`gateway-id`]))}/evaluations/${c.id==null?`<id>`:encodeURIComponent(String(c.id))}`,pathParams:{"gateway-id":String(c[`gateway-id`]??``),id:String(c.id??``)},bodyKind:`none`});return}let s=await r(c),l=c.local?e:await t();if(c.accountId=l,!await m({force:!!c.force})){process.stderr.write(`Aborted.
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{t as e}from"./local-C6XsFD_W.mjs";import{f as t,g as n}from"./oauth-DH3kMXSs.mjs";import{a as r,r as i}from"./auth-tvDdC1J-.mjs";import{t as a}from"./output-COcSQsfn.mjs";import{t as o}from"./dry-run-DiVy1lVo.mjs";import{t as s}from"./progress-V6SZV3Ux.mjs";import{t as c}from"./run-CRfinkSe.mjs";import"./telemetry-Ch1vCICm.mjs";import{n as l,r as u,t as d}from"./body-parser-DIlfApuJ.mjs";import{n as f,t as p}from"./input-validation-BxchZ9jE.mjs";import{a as m,i as h,n as g}from"./prompt-DjRTpML4.mjs";import{t as _}from"./cli-types-CrSoSMPF.mjs";import{n as ee,t as te}from"./raw-fetch-BVYQR6C5.mjs";function v(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`ai-search-options-cache-cache-threshold`,{type:`string`,description:`The ai_search_options.cache.cache_threshold field`,choices:[`super_strict_match`,`close_enough`,`flexible_friend`,`anything_goes`]}).option(`ai-search-options-cache-enabled`,{type:`boolean`,description:`The ai_search_options.cache.enabled field`}).option(`ai-search-options-query-rewrite-enabled`,{type:`boolean`,description:`The ai_search_options.query_rewrite.enabled field`}).option(`ai-search-options-query-rewrite-model`,{type:`string`,description:`A Workers AI model ID or an AI Gateway model ID compatible with the OpenAI Chat Completions API. An empty string uses the configured or default model.`}).option(`ai-search-options-query-rewrite-rewrite-prompt`,{type:`string`,description:`The ai_search_options.query_rewrite.rewrite_prompt field`}).option(`ai-search-options-reranking-enabled`,{type:`boolean`,description:`The ai_search_options.reranking.enabled field`}).option(`ai-search-options-reranking-match-threshold`,{type:`number`,description:`The ai_search_options.reranking.match_threshold field`}).option(`ai-search-options-reranking-model`,{type:`string`,description:`The ai_search_options.reranking.model field`}).option(`ai-search-options-retrieval-context-expansion`,{type:`number`,description:`The ai_search_options.retrieval.context_expansion field`}).option(`ai-search-options-retrieval-fusion-method`,{type:`string`,description:`The ai_search_options.retrieval.fusion_method field`,choices:[`max`,`rrf`]}).option(`ai-search-options-retrieval-keyword-match-mode`,{type:`string`,description:`Controls which documents are candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term, ranked by BM25 relevance. When omitted, falls back to the instance-level retrieval_options.keyword_match_mode, then to 'and'.`,choices:[`and`,`or`]}).option(`ai-search-options-retrieval-match-threshold`,{type:`number`,description:`The ai_search_options.retrieval.match_threshold field`}).option(`ai-search-options-retrieval-max-num-results`,{type:`number`,description:`The ai_search_options.retrieval.max_num_results field`}).option(`ai-search-options-retrieval-retrieval-type`,{type:`string`,description:`The ai_search_options.retrieval.retrieval_type field`,choices:[`vector`,`keyword`,`hybrid`]}).option(`ai-search-options-retrieval-return-on-failure`,{type:`boolean`,description:`The ai_search_options.retrieval.return_on_failure field`}).option(`messages`,{type:`string`,description:`The messages field. Provide as a JSON array of objects or @path/to/file.json.`}).option(`model`,{type:`string`,description:`A Workers AI model ID or an AI Gateway model ID compatible with the OpenAI Chat Completions API. An empty string uses the configured or default model.`}).option(`stream`,{type:`boolean`,description:`The stream field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const y={command:`chat-completions <id>`,describe:`Performs a chat completion request against an AI Search instance, using indexed content as context for generating responses.`,builder:v,handler:async r=>c({command:`ai-search chat-completions`,classification:{safeFlags:[`ai-search-options-cache-cache-threshold`,`ai-search-options-cache-enabled`,`ai-search-options-query-rewrite-enabled`,`ai-search-options-reranking-enabled`,`ai-search-options-retrieval-fusion-method`,`ai-search-options-retrieval-keyword-match-mode`,`ai-search-options-retrieval-retrieval-type`,`ai-search-options-retrieval-return-on-failure`,`stream`,`dry-run`]}},r,async()=>{if(r.dryRun){o({command:`cf ai-search chat-completions`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}/chat/completions`,pathParams:{id:String(r.id??``),name:String(r.name??``)},bodyKind:`json`,body:r.body===void 0?d({ai_search_options:{cache:{cache_threshold:f(r[`ai-search-options-cache-cache-threshold`],`ai-search-options-cache-cache-threshold`,`text`),enabled:r[`ai-search-options-cache-enabled`]},query_rewrite:{enabled:r[`ai-search-options-query-rewrite-enabled`],model:f(r[`ai-search-options-query-rewrite-model`],`ai-search-options-query-rewrite-model`,`text`),rewrite_prompt:f(r[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:r[`ai-search-options-reranking-enabled`],match_threshold:r[`ai-search-options-reranking-match-threshold`],model:f(r[`ai-search-options-reranking-model`],`ai-search-options-reranking-model`,`text`)},retrieval:{context_expansion:r[`ai-search-options-retrieval-context-expansion`],fusion_method:f(r[`ai-search-options-retrieval-fusion-method`],`ai-search-options-retrieval-fusion-method`,`text`),keyword_match_mode:f(r[`ai-search-options-retrieval-keyword-match-mode`],`ai-search-options-retrieval-keyword-match-mode`,`text`),match_threshold:r[`ai-search-options-retrieval-match-threshold`],max_num_results:r[`ai-search-options-retrieval-max-num-results`],retrieval_type:f(r[`ai-search-options-retrieval-retrieval-type`],`ai-search-options-retrieval-retrieval-type`,`text`),return_on_failure:r[`ai-search-options-retrieval-return-on-failure`]}},messages:u(r.messages,`messages`),model:f(r.model,`model`,`text`),stream:r.stream}):l(r.body)});return}let c=await i(r),p=r.local?e:await t();if(r.accountId=p,r.body){let e=l(r.body);a(await s(`Creating`,async()=>c.aiSearch.chatCompletions({...e,account_id:p,name:r.name,id:r.id})),{successLabel:`Created`});return}if(r.messages===void 0)throw Error(`--messages is required (or pass --body with this field set).`);let m=d({ai_search_options:{cache:{cache_threshold:f(r[`ai-search-options-cache-cache-threshold`],`ai-search-options-cache-cache-threshold`,`text`),enabled:r[`ai-search-options-cache-enabled`]},query_rewrite:{enabled:r[`ai-search-options-query-rewrite-enabled`],model:f(r[`ai-search-options-query-rewrite-model`],`ai-search-options-query-rewrite-model`,`text`),rewrite_prompt:f(r[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:r[`ai-search-options-reranking-enabled`],match_threshold:r[`ai-search-options-reranking-match-threshold`],model:f(r[`ai-search-options-reranking-model`],`ai-search-options-reranking-model`,`text`)},retrieval:{context_expansion:r[`ai-search-options-retrieval-context-expansion`],fusion_method:f(r[`ai-search-options-retrieval-fusion-method`],`ai-search-options-retrieval-fusion-method`,`text`),keyword_match_mode:f(r[`ai-search-options-retrieval-keyword-match-mode`],`ai-search-options-retrieval-keyword-match-mode`,`text`),match_threshold:r[`ai-search-options-retrieval-match-threshold`],max_num_results:r[`ai-search-options-retrieval-max-num-results`],retrieval_type:f(r[`ai-search-options-retrieval-retrieval-type`],`ai-search-options-retrieval-retrieval-type`,`text`),return_on_failure:r[`ai-search-options-retrieval-return-on-failure`]}},messages:u(r.messages,`messages`),model:f(r.model,`model`,`text`),stream:r.stream});a(await s(`Creating`,async()=>c.aiSearch.chatCompletions({...m,account_id:p,name:r.name,id:r.id})),{successLabel:`Created`})})};function b(e){return e.positional(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).positional(`id`,{type:`string`,description:`Unique ID for the new AI Search instance.`,demandOption:!0}).option(`ai-gateway-id`,{type:`string`,description:`The ai_gateway_id field`}).option(`ai-search-model`,{type:`string`,description:`A Workers AI model ID or an AI Gateway model ID compatible with the OpenAI Chat Completions API. An empty string uses the configured or default model.`}).option(`cache`,{type:`boolean`,description:`The cache field`,default:!0}).option(`cache-threshold`,{type:`string`,description:`The cache_threshold field`,choices:[`super_strict_match`,`close_enough`,`flexible_friend`,`anything_goes`],default:`close_enough`}).option(`chunk`,{type:`boolean`,description:`The chunk field`,default:!0}).option(`chunk-overlap`,{type:`number`,description:`The chunk_overlap field`,default:10}).option(`chunk-size`,{type:`number`,description:`The chunk_size field`}).option(`custom-metadata`,{type:`string`,description:`The custom_metadata field. Provide as a JSON array of objects or @path/to/file.json.`}).option(`embedding-model`,{type:`string`,description:`The embedding_model field`}).option(`fusion-method`,{type:`string`,description:`The fusion_method field`,choices:[`max`,`rrf`],default:`rrf`}).option(`hybrid-search-enabled`,{type:`boolean`,description:`Deprecated — use index_method instead.`,default:!1}).option(`index-method-keyword`,{type:`boolean`,description:`Enable keyword (BM25) storage backend.`}).option(`index-method-vector`,{type:`boolean`,description:`Enable vector (embedding) storage backend.`}).option(`indexing-options-keyword-tokenizer`,{type:`string`,description:`Tokenizer used for keyword search indexing. porter provides word-level tokenization with Porter stemming (good for natural language queries). trigram enables character-level substring matching (good for partial matches, code, identifiers). Changing this triggers a full re-index. Defaults to porter.`,choices:[`porter`,`trigram`]}).option(`indexing-options-use-ocr`,{type:`boolean`,description:`Enables OCR ingestion for PDFs and images. Changing this triggers a full re-index. Defaults to false.`}).option(`max-num-results`,{type:`number`,description:`The max_num_results field`,default:10}).option(`metadata-created-from-aisearch-wizard`,{type:`boolean`,description:`The metadata.created_from_aisearch_wizard field`}).option(`metadata-worker-domain`,{type:`string`,description:`The metadata.worker_domain field`}).option(`public-endpoint-params-authorized-hosts`,{type:`string`,array:!0,description:`The public_endpoint_params.authorized_hosts field`}).option(`public-endpoint-params-chat-completions-endpoint-disabled`,{type:`boolean`,description:`Disable chat completions endpoint for this public endpoint`}).option(`public-endpoint-params-custom-domains`,{type:`string`,array:!0,description:`Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged).`}).option(`public-endpoint-params-default-domain-enabled`,{type:`boolean`,description:`When false, the instance is reachable only via a registered custom domain and the default <public_endpoint_id>.search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true.`}).option(`public-endpoint-params-enabled`,{type:`boolean`,description:`The public_endpoint_params.enabled field`}).option(`public-endpoint-params-mcp-description`,{type:`string`,description:`The public_endpoint_params.mcp.description field`}).option(`public-endpoint-params-mcp-disabled`,{type:`boolean`,description:`Disable MCP endpoint for this public endpoint`}).option(`public-endpoint-params-rate-limit-period-ms`,{type:`number`,description:`The public_endpoint_params.rate_limit.period_ms field`}).option(`public-endpoint-params-rate-limit-requests`,{type:`number`,description:`The public_endpoint_params.rate_limit.requests field`}).option(`public-endpoint-params-rate-limit-technique`,{type:`string`,description:`The public_endpoint_params.rate_limit.technique field`,choices:[`fixed`,`sliding`]}).option(`public-endpoint-params-search-endpoint-disabled`,{type:`boolean`,description:`Disable search endpoint for this public endpoint`}).option(`reranking`,{type:`boolean`,description:`The reranking field`,default:!1}).option(`reranking-model`,{type:`string`,description:`The reranking_model field`}).option(`retrieval-options-keyword-match-mode`,{type:`string`,description:`Controls which documents are candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term, ranked by BM25 relevance. When omitted on an update, the existing stored value is preserved; when never set, search falls back to 'and'.`,choices:[`and`,`or`]}).option(`rewrite-model`,{type:`string`,description:`A Workers AI model ID or an AI Gateway model ID compatible with the OpenAI Chat Completions API. An empty string uses the configured or default model.`}).option(`rewrite-query`,{type:`boolean`,description:`The rewrite_query field`,default:!1}).option(`score-threshold`,{type:`number`,description:`The score_threshold field`,default:.4}).option(`source`,{type:`string`,description:`The source field`}).option(`source-params-exclude-items`,{type:`string`,array:!0,description:`List of path patterns to exclude. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /admin/** matches /admin/users and /admin/settings/advanced). Most accounts are limited to 10 rules; contact support to raise it.`}).option(`source-params-include-items`,{type:`string`,array:!0,description:`List of path patterns to include. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /blog/** matches /blog/post and /blog/2024/post). Most accounts are limited to 10 rules; contact support to raise it.`}).option(`source-params-prefix`,{type:`string`,description:`The source_params.prefix field`}).option(`source-params-r2-jurisdiction`,{type:`string`,description:`The source_params.r2_jurisdiction field`}).option(`source-params-web-crawler-discover-options-depth`,{type:`number`,description:`Maximum link-follow depth from the seed URL.`}).option(`source-params-web-crawler-discover-options-include-external-links`,{type:`boolean`,description:"Follow links that point outside the source domain. Must stay `false` — discover crawls are restricted to the zone you own."}).option(`source-params-web-crawler-discover-options-include-subdomains`,{type:`boolean`,description:`Follow links to subdomains of the source host.`}).option(`source-params-web-crawler-discover-options-limit`,{type:`number`,description:`Maximum number of pages to crawl (1-100000).`}).option(`source-params-web-crawler-discover-options-max-age`,{type:`number`,description:`Maximum content age in seconds to accept (0–604800).`}).option(`source-params-web-crawler-discover-options-source`,{type:`string`,description:`Where the crawler looks for URLs: 'sitemaps' reads sitemap XML only, 'links' follows page links only, 'all' does both.`,choices:[`all`,`sitemaps`,`links`]}).option(`source-params-web-crawler-parse-options-include-images`,{type:`boolean`,description:`The source_params.web_crawler.parse_options.include_images field`}).option(`source-params-web-crawler-parse-options-specific-sitemaps`,{type:`string`,array:!0,description:`List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'.`}).option(`source-params-web-crawler-parse-options-use-browser-rendering`,{type:`boolean`,description:`The source_params.web_crawler.parse_options.use_browser_rendering field`}).option(`source-params-web-crawler-parse-type`,{type:`string`,description:`How URLs are discovered. 'sitemap' reads XML sitemaps; 'discover' follows links recursively and requires the source to be a Verified zone on this account.`,choices:[`sitemap`,`discover`]}).option(`token-id`,{type:`string`,description:`The token_id field`}).option(`type`,{type:`string`,description:`The type field`,choices:[`r2`,`web-crawler`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`}).check(e=>{if([`index-method-keyword`,`index-method-vector`].some(t=>e[t]!==void 0)){let t=[`index-method-keyword`,`index-method-vector`].filter(t=>e[t]===void 0);if(t.length>0)throw Error(`${t.map(e=>`--`+e).join(`, `)} ${t.length===1?`is`:`are`} required when any --index_method-* flag is set`)}return!0})}const x={command:`create <name> <id>`,describe:`Create a new AI Search instance with the given configuration.`,builder:b,handler:async r=>c({command:`ai-search create`,classification:{safeFlags:`cache.cache-threshold.chunk.fusion-method.hybrid-search-enabled.index-method-keyword.index-method-vector.indexing-options-keyword-tokenizer.indexing-options-use-ocr.metadata-created-from-aisearch-wizard.public-endpoint-params-chat-completions-endpoint-disabled.public-endpoint-params-default-domain-enabled.public-endpoint-params-enabled.public-endpoint-params-mcp-disabled.public-endpoint-params-rate-limit-technique.public-endpoint-params-search-endpoint-disabled.reranking.retrieval-options-keyword-match-mode.rewrite-query.source-params-web-crawler-discover-options-include-external-links.source-params-web-crawler-discover-options-include-subdomains.source-params-web-crawler-discover-options-source.source-params-web-crawler-parse-options-include-images.source-params-web-crawler-parse-options-use-browser-rendering.source-params-web-crawler-parse-type.type.dry-run`.split(`.`)}},r,async()=>{if(r.dryRun){o({command:`cf ai-search create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances`,pathParams:{name:String(r.name??``)},bodyKind:`json`,body:r.body===void 0?d({ai_gateway_id:f(r[`ai-gateway-id`],`ai-gateway-id`,`text`),ai_search_model:f(r[`ai-search-model`],`ai-search-model`,`text`),cache:r.cache,cache_threshold:f(r[`cache-threshold`],`cache-threshold`,`text`),chunk:r.chunk,chunk_overlap:r[`chunk-overlap`],chunk_size:r[`chunk-size`],custom_metadata:u(r[`custom-metadata`],`custom-metadata`),embedding_model:f(r[`embedding-model`],`embedding-model`,`text`),fusion_method:f(r[`fusion-method`],`fusion-method`,`text`),hybrid_search_enabled:r[`hybrid-search-enabled`],index_method:{keyword:r[`index-method-keyword`],vector:r[`index-method-vector`]},indexing_options:{keyword_tokenizer:f(r[`indexing-options-keyword-tokenizer`],`indexing-options-keyword-tokenizer`,`text`),use_ocr:r[`indexing-options-use-ocr`]},max_num_results:r[`max-num-results`],metadata:{created_from_aisearch_wizard:r[`metadata-created-from-aisearch-wizard`],worker_domain:f(r[`metadata-worker-domain`],`metadata-worker-domain`,`text`)},public_endpoint_params:{authorized_hosts:r[`public-endpoint-params-authorized-hosts`],chat_completions_endpoint:{disabled:r[`public-endpoint-params-chat-completions-endpoint-disabled`]},custom_domains:r[`public-endpoint-params-custom-domains`],default_domain_enabled:r[`public-endpoint-params-default-domain-enabled`],enabled:r[`public-endpoint-params-enabled`],mcp:{description:f(r[`public-endpoint-params-mcp-description`],`public-endpoint-params-mcp-description`,`text`),disabled:r[`public-endpoint-params-mcp-disabled`]},rate_limit:{period_ms:r[`public-endpoint-params-rate-limit-period-ms`],requests:r[`public-endpoint-params-rate-limit-requests`],technique:f(r[`public-endpoint-params-rate-limit-technique`],`public-endpoint-params-rate-limit-technique`,`text`)},search_endpoint:{disabled:r[`public-endpoint-params-search-endpoint-disabled`]}},reranking:r.reranking,reranking_model:f(r[`reranking-model`],`reranking-model`,`text`),retrieval_options:{keyword_match_mode:f(r[`retrieval-options-keyword-match-mode`],`retrieval-options-keyword-match-mode`,`text`)},rewrite_model:f(r[`rewrite-model`],`rewrite-model`,`text`),rewrite_query:r[`rewrite-query`],score_threshold:r[`score-threshold`],source:f(r.source,`source`,`text`),source_params:{exclude_items:r[`source-params-exclude-items`],include_items:r[`source-params-include-items`],prefix:f(r[`source-params-prefix`],`source-params-prefix`,`text`),r2_jurisdiction:f(r[`source-params-r2-jurisdiction`],`source-params-r2-jurisdiction`,`text`),web_crawler:{discover_options:{depth:r[`source-params-web-crawler-discover-options-depth`],include_external_links:r[`source-params-web-crawler-discover-options-include-external-links`],include_subdomains:r[`source-params-web-crawler-discover-options-include-subdomains`],limit:r[`source-params-web-crawler-discover-options-limit`],max_age:r[`source-params-web-crawler-discover-options-max-age`],source:f(r[`source-params-web-crawler-discover-options-source`],`source-params-web-crawler-discover-options-source`,`text`)},parse_options:{include_images:r[`source-params-web-crawler-parse-options-include-images`],specific_sitemaps:r[`source-params-web-crawler-parse-options-specific-sitemaps`],use_browser_rendering:r[`source-params-web-crawler-parse-options-use-browser-rendering`]},parse_type:f(r[`source-params-web-crawler-parse-type`],`source-params-web-crawler-parse-type`,`text`)}},token_id:f(r[`token-id`],`token-id`,`text`),type:f(r.type,`type`,`text`),id:r.id}):l(r.body)});return}let c=await i(r),p=r.local?e:await t();if(r.accountId=p,r.body){let e=l(r.body);a(await s(`Creating`,async()=>c.aiSearch.create({...e,account_id:p,name:r.name})),{successLabel:`Created`});return}let m=d({ai_gateway_id:f(r[`ai-gateway-id`],`ai-gateway-id`,`text`),ai_search_model:f(r[`ai-search-model`],`ai-search-model`,`text`),cache:r.cache,cache_threshold:f(r[`cache-threshold`],`cache-threshold`,`text`),chunk:r.chunk,chunk_overlap:r[`chunk-overlap`],chunk_size:r[`chunk-size`],custom_metadata:u(r[`custom-metadata`],`custom-metadata`),embedding_model:f(r[`embedding-model`],`embedding-model`,`text`),fusion_method:f(r[`fusion-method`],`fusion-method`,`text`),hybrid_search_enabled:r[`hybrid-search-enabled`],index_method:{keyword:r[`index-method-keyword`],vector:r[`index-method-vector`]},indexing_options:{keyword_tokenizer:f(r[`indexing-options-keyword-tokenizer`],`indexing-options-keyword-tokenizer`,`text`),use_ocr:r[`indexing-options-use-ocr`]},max_num_results:r[`max-num-results`],metadata:{created_from_aisearch_wizard:r[`metadata-created-from-aisearch-wizard`],worker_domain:f(r[`metadata-worker-domain`],`metadata-worker-domain`,`text`)},public_endpoint_params:{authorized_hosts:r[`public-endpoint-params-authorized-hosts`],chat_completions_endpoint:{disabled:r[`public-endpoint-params-chat-completions-endpoint-disabled`]},custom_domains:r[`public-endpoint-params-custom-domains`],default_domain_enabled:r[`public-endpoint-params-default-domain-enabled`],enabled:r[`public-endpoint-params-enabled`],mcp:{description:f(r[`public-endpoint-params-mcp-description`],`public-endpoint-params-mcp-description`,`text`),disabled:r[`public-endpoint-params-mcp-disabled`]},rate_limit:{period_ms:r[`public-endpoint-params-rate-limit-period-ms`],requests:r[`public-endpoint-params-rate-limit-requests`],technique:f(r[`public-endpoint-params-rate-limit-technique`],`public-endpoint-params-rate-limit-technique`,`text`)},search_endpoint:{disabled:r[`public-endpoint-params-search-endpoint-disabled`]}},reranking:r.reranking,reranking_model:f(r[`reranking-model`],`reranking-model`,`text`),retrieval_options:{keyword_match_mode:f(r[`retrieval-options-keyword-match-mode`],`retrieval-options-keyword-match-mode`,`text`)},rewrite_model:f(r[`rewrite-model`],`rewrite-model`,`text`),rewrite_query:r[`rewrite-query`],score_threshold:r[`score-threshold`],source:f(r.source,`source`,`text`),source_params:{exclude_items:r[`source-params-exclude-items`],include_items:r[`source-params-include-items`],prefix:f(r[`source-params-prefix`],`source-params-prefix`,`text`),r2_jurisdiction:f(r[`source-params-r2-jurisdiction`],`source-params-r2-jurisdiction`,`text`),web_crawler:{discover_options:{depth:r[`source-params-web-crawler-discover-options-depth`],include_external_links:r[`source-params-web-crawler-discover-options-include-external-links`],include_subdomains:r[`source-params-web-crawler-discover-options-include-subdomains`],limit:r[`source-params-web-crawler-discover-options-limit`],max_age:r[`source-params-web-crawler-discover-options-max-age`],source:f(r[`source-params-web-crawler-discover-options-source`],`source-params-web-crawler-discover-options-source`,`text`)},parse_options:{include_images:r[`source-params-web-crawler-parse-options-include-images`],specific_sitemaps:r[`source-params-web-crawler-parse-options-specific-sitemaps`],use_browser_rendering:r[`source-params-web-crawler-parse-options-use-browser-rendering`]},parse_type:f(r[`source-params-web-crawler-parse-type`],`source-params-web-crawler-parse-type`,`text`)}},token_id:f(r[`token-id`],`token-id`,`text`),type:f(r.type,`type`,`text`),id:r.id});a(await s(`Creating`,async()=>c.aiSearch.create({...m,account_id:p,name:r.name})),{successLabel:`Created`})})};function S(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const C={command:`delete <id>`,describe:`Permanently delete an AI Search instance and all its indexed data.`,builder:S,handler:async r=>c({command:`ai-search delete`,classification:{safeFlags:[`dry-run`,`force`],shortFlagAliases:{f:{canonical:`force`,type:`boolean`}}}},r,async()=>{if(r.dryRun){o({command:`cf ai-search delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}`,pathParams:{id:String(r.id??``),name:String(r.name??``)},bodyKind:`none`});return}let c=await i(r),l=r.local?e:await t();if(r.accountId=l,!await g({force:!!r.force,message:`This operation permanently deletes the AI Search instance and all its indexed data.`})){process.stderr.write(`Aborted.
2
+ import{t as e}from"./local-BwL_gesw.mjs";import{f as t,g as n}from"./oauth-BdVr2hJp.mjs";import{a as r,r as i}from"./auth-DWxtJ918.mjs";import{t as a}from"./output-Z2lQmPUW.mjs";import{t as o}from"./dry-run-YSQndLvt.mjs";import{t as s}from"./progress-a5IKeKni.mjs";import{t as c}from"./run-BS8otL3u.mjs";import"./telemetry-n3NJourL.mjs";import{n as l,r as u,t as d}from"./body-parser-Cmw7PZ7a.mjs";import{n as f,t as p}from"./input-validation-nF-0Ze2h.mjs";import{a as m,i as h,n as g}from"./prompt-BP8XrQSj.mjs";import{t as _}from"./cli-types-abvWQN3T.mjs";import{n as ee,t as te}from"./raw-fetch-DNH2V8qH.mjs";function v(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`ai-search-options-cache-cache-threshold`,{type:`string`,description:`The ai_search_options.cache.cache_threshold field`,choices:[`super_strict_match`,`close_enough`,`flexible_friend`,`anything_goes`]}).option(`ai-search-options-cache-enabled`,{type:`boolean`,description:`The ai_search_options.cache.enabled field`}).option(`ai-search-options-query-rewrite-enabled`,{type:`boolean`,description:`The ai_search_options.query_rewrite.enabled field`}).option(`ai-search-options-query-rewrite-model`,{type:`string`,description:`A Workers AI model ID or an AI Gateway model ID compatible with the OpenAI Chat Completions API. An empty string uses the configured or default model.`}).option(`ai-search-options-query-rewrite-rewrite-prompt`,{type:`string`,description:`The ai_search_options.query_rewrite.rewrite_prompt field`}).option(`ai-search-options-reranking-enabled`,{type:`boolean`,description:`The ai_search_options.reranking.enabled field`}).option(`ai-search-options-reranking-match-threshold`,{type:`number`,description:`The ai_search_options.reranking.match_threshold field`}).option(`ai-search-options-reranking-model`,{type:`string`,description:`The ai_search_options.reranking.model field`}).option(`ai-search-options-retrieval-context-expansion`,{type:`number`,description:`The ai_search_options.retrieval.context_expansion field`}).option(`ai-search-options-retrieval-fusion-method`,{type:`string`,description:`The ai_search_options.retrieval.fusion_method field`,choices:[`max`,`rrf`]}).option(`ai-search-options-retrieval-keyword-match-mode`,{type:`string`,description:`Controls which documents are candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term, ranked by BM25 relevance. When omitted, falls back to the instance-level retrieval_options.keyword_match_mode, then to 'and'.`,choices:[`and`,`or`]}).option(`ai-search-options-retrieval-match-threshold`,{type:`number`,description:`The ai_search_options.retrieval.match_threshold field`}).option(`ai-search-options-retrieval-max-num-results`,{type:`number`,description:`The ai_search_options.retrieval.max_num_results field`}).option(`ai-search-options-retrieval-retrieval-type`,{type:`string`,description:`The ai_search_options.retrieval.retrieval_type field`,choices:[`vector`,`keyword`,`hybrid`]}).option(`ai-search-options-retrieval-return-on-failure`,{type:`boolean`,description:`The ai_search_options.retrieval.return_on_failure field`}).option(`messages`,{type:`string`,description:`The messages field. Provide as a JSON array of objects or @path/to/file.json.`}).option(`model`,{type:`string`,description:`A Workers AI model ID or an AI Gateway model ID compatible with the OpenAI Chat Completions API. An empty string uses the configured or default model.`}).option(`stream`,{type:`boolean`,description:`The stream field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const y={command:`chat-completions <id>`,describe:`Performs a chat completion request against an AI Search instance, using indexed content as context for generating responses.`,builder:v,handler:async r=>c({command:`ai-search chat-completions`,classification:{safeFlags:[`ai-search-options-cache-cache-threshold`,`ai-search-options-cache-enabled`,`ai-search-options-query-rewrite-enabled`,`ai-search-options-reranking-enabled`,`ai-search-options-retrieval-fusion-method`,`ai-search-options-retrieval-keyword-match-mode`,`ai-search-options-retrieval-retrieval-type`,`ai-search-options-retrieval-return-on-failure`,`stream`,`dry-run`]}},r,async()=>{if(r.dryRun){o({command:`cf ai-search chat-completions`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}/chat/completions`,pathParams:{id:String(r.id??``),name:String(r.name??``)},bodyKind:`json`,body:r.body===void 0?d({ai_search_options:{cache:{cache_threshold:f(r[`ai-search-options-cache-cache-threshold`],`ai-search-options-cache-cache-threshold`,`text`),enabled:r[`ai-search-options-cache-enabled`]},query_rewrite:{enabled:r[`ai-search-options-query-rewrite-enabled`],model:f(r[`ai-search-options-query-rewrite-model`],`ai-search-options-query-rewrite-model`,`text`),rewrite_prompt:f(r[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:r[`ai-search-options-reranking-enabled`],match_threshold:r[`ai-search-options-reranking-match-threshold`],model:f(r[`ai-search-options-reranking-model`],`ai-search-options-reranking-model`,`text`)},retrieval:{context_expansion:r[`ai-search-options-retrieval-context-expansion`],fusion_method:f(r[`ai-search-options-retrieval-fusion-method`],`ai-search-options-retrieval-fusion-method`,`text`),keyword_match_mode:f(r[`ai-search-options-retrieval-keyword-match-mode`],`ai-search-options-retrieval-keyword-match-mode`,`text`),match_threshold:r[`ai-search-options-retrieval-match-threshold`],max_num_results:r[`ai-search-options-retrieval-max-num-results`],retrieval_type:f(r[`ai-search-options-retrieval-retrieval-type`],`ai-search-options-retrieval-retrieval-type`,`text`),return_on_failure:r[`ai-search-options-retrieval-return-on-failure`]}},messages:u(r.messages,`messages`),model:f(r.model,`model`,`text`),stream:r.stream}):l(r.body)});return}let c=await i(r),p=r.local?e:await t();if(r.accountId=p,r.body){let e=l(r.body);a(await s(`Creating`,async()=>c.aiSearch.chatCompletions({...e,account_id:p,name:r.name,id:r.id})),{successLabel:`Created`});return}if(r.messages===void 0)throw Error(`--messages is required (or pass --body with this field set).`);let m=d({ai_search_options:{cache:{cache_threshold:f(r[`ai-search-options-cache-cache-threshold`],`ai-search-options-cache-cache-threshold`,`text`),enabled:r[`ai-search-options-cache-enabled`]},query_rewrite:{enabled:r[`ai-search-options-query-rewrite-enabled`],model:f(r[`ai-search-options-query-rewrite-model`],`ai-search-options-query-rewrite-model`,`text`),rewrite_prompt:f(r[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:r[`ai-search-options-reranking-enabled`],match_threshold:r[`ai-search-options-reranking-match-threshold`],model:f(r[`ai-search-options-reranking-model`],`ai-search-options-reranking-model`,`text`)},retrieval:{context_expansion:r[`ai-search-options-retrieval-context-expansion`],fusion_method:f(r[`ai-search-options-retrieval-fusion-method`],`ai-search-options-retrieval-fusion-method`,`text`),keyword_match_mode:f(r[`ai-search-options-retrieval-keyword-match-mode`],`ai-search-options-retrieval-keyword-match-mode`,`text`),match_threshold:r[`ai-search-options-retrieval-match-threshold`],max_num_results:r[`ai-search-options-retrieval-max-num-results`],retrieval_type:f(r[`ai-search-options-retrieval-retrieval-type`],`ai-search-options-retrieval-retrieval-type`,`text`),return_on_failure:r[`ai-search-options-retrieval-return-on-failure`]}},messages:u(r.messages,`messages`),model:f(r.model,`model`,`text`),stream:r.stream});a(await s(`Creating`,async()=>c.aiSearch.chatCompletions({...m,account_id:p,name:r.name,id:r.id})),{successLabel:`Created`})})};function b(e){return e.positional(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).positional(`id`,{type:`string`,description:`Unique ID for the new AI Search instance.`,demandOption:!0}).option(`ai-gateway-id`,{type:`string`,description:`The ai_gateway_id field`}).option(`ai-search-model`,{type:`string`,description:`A Workers AI model ID or an AI Gateway model ID compatible with the OpenAI Chat Completions API. An empty string uses the configured or default model.`}).option(`cache`,{type:`boolean`,description:`The cache field`,default:!0}).option(`cache-threshold`,{type:`string`,description:`The cache_threshold field`,choices:[`super_strict_match`,`close_enough`,`flexible_friend`,`anything_goes`],default:`close_enough`}).option(`chunk`,{type:`boolean`,description:`The chunk field`,default:!0}).option(`chunk-overlap`,{type:`number`,description:`The chunk_overlap field`,default:10}).option(`chunk-size`,{type:`number`,description:`The chunk_size field`}).option(`custom-metadata`,{type:`string`,description:`The custom_metadata field. Provide as a JSON array of objects or @path/to/file.json.`}).option(`embedding-model`,{type:`string`,description:`The embedding_model field`}).option(`fusion-method`,{type:`string`,description:`The fusion_method field`,choices:[`max`,`rrf`],default:`rrf`}).option(`hybrid-search-enabled`,{type:`boolean`,description:`Deprecated — use index_method instead.`,default:!1}).option(`index-method-keyword`,{type:`boolean`,description:`Enable keyword (BM25) storage backend.`}).option(`index-method-vector`,{type:`boolean`,description:`Enable vector (embedding) storage backend.`}).option(`indexing-options-keyword-tokenizer`,{type:`string`,description:`Tokenizer used for keyword search indexing. porter provides word-level tokenization with Porter stemming (good for natural language queries). trigram enables character-level substring matching (good for partial matches, code, identifiers). Changing this triggers a full re-index. Defaults to porter.`,choices:[`porter`,`trigram`]}).option(`indexing-options-use-ocr`,{type:`boolean`,description:`Enables OCR ingestion for PDFs and images. Changing this triggers a full re-index. Defaults to false.`}).option(`max-num-results`,{type:`number`,description:`The max_num_results field`,default:10}).option(`metadata-created-from-aisearch-wizard`,{type:`boolean`,description:`The metadata.created_from_aisearch_wizard field`}).option(`metadata-worker-domain`,{type:`string`,description:`The metadata.worker_domain field`}).option(`public-endpoint-params-authorized-hosts`,{type:`string`,array:!0,description:`The public_endpoint_params.authorized_hosts field`}).option(`public-endpoint-params-chat-completions-endpoint-disabled`,{type:`boolean`,description:`Disable chat completions endpoint for this public endpoint`}).option(`public-endpoint-params-custom-domains`,{type:`string`,array:!0,description:`Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged).`}).option(`public-endpoint-params-default-domain-enabled`,{type:`boolean`,description:`When false, the instance is reachable only via a registered custom domain and the default <public_endpoint_id>.search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true.`}).option(`public-endpoint-params-enabled`,{type:`boolean`,description:`The public_endpoint_params.enabled field`}).option(`public-endpoint-params-mcp-description`,{type:`string`,description:`The public_endpoint_params.mcp.description field`}).option(`public-endpoint-params-mcp-disabled`,{type:`boolean`,description:`Disable MCP endpoint for this public endpoint`}).option(`public-endpoint-params-rate-limit-period-ms`,{type:`number`,description:`The public_endpoint_params.rate_limit.period_ms field`}).option(`public-endpoint-params-rate-limit-requests`,{type:`number`,description:`The public_endpoint_params.rate_limit.requests field`}).option(`public-endpoint-params-rate-limit-technique`,{type:`string`,description:`The public_endpoint_params.rate_limit.technique field`,choices:[`fixed`,`sliding`]}).option(`public-endpoint-params-search-endpoint-disabled`,{type:`boolean`,description:`Disable search endpoint for this public endpoint`}).option(`reranking`,{type:`boolean`,description:`The reranking field`,default:!1}).option(`reranking-model`,{type:`string`,description:`The reranking_model field`}).option(`retrieval-options-keyword-match-mode`,{type:`string`,description:`Controls which documents are candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term, ranked by BM25 relevance. When omitted on an update, the existing stored value is preserved; when never set, search falls back to 'and'.`,choices:[`and`,`or`]}).option(`rewrite-model`,{type:`string`,description:`A Workers AI model ID or an AI Gateway model ID compatible with the OpenAI Chat Completions API. An empty string uses the configured or default model.`}).option(`rewrite-query`,{type:`boolean`,description:`The rewrite_query field`,default:!1}).option(`score-threshold`,{type:`number`,description:`The score_threshold field`,default:.4}).option(`source`,{type:`string`,description:`The source field`}).option(`source-params-exclude-items`,{type:`string`,array:!0,description:`List of path patterns to exclude. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /admin/** matches /admin/users and /admin/settings/advanced). Most accounts are limited to 10 rules; contact support to raise it.`}).option(`source-params-include-items`,{type:`string`,array:!0,description:`List of path patterns to include. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /blog/** matches /blog/post and /blog/2024/post). Most accounts are limited to 10 rules; contact support to raise it.`}).option(`source-params-prefix`,{type:`string`,description:`The source_params.prefix field`}).option(`source-params-r2-jurisdiction`,{type:`string`,description:`The source_params.r2_jurisdiction field`}).option(`source-params-web-crawler-discover-options-depth`,{type:`number`,description:`Maximum link-follow depth from the seed URL.`}).option(`source-params-web-crawler-discover-options-include-external-links`,{type:`boolean`,description:"Follow links that point outside the source domain. Must stay `false` — discover crawls are restricted to the zone you own."}).option(`source-params-web-crawler-discover-options-include-subdomains`,{type:`boolean`,description:`Follow links to subdomains of the source host.`}).option(`source-params-web-crawler-discover-options-limit`,{type:`number`,description:`Maximum number of pages to crawl (1-100000).`}).option(`source-params-web-crawler-discover-options-max-age`,{type:`number`,description:`Maximum content age in seconds to accept (0–604800).`}).option(`source-params-web-crawler-discover-options-source`,{type:`string`,description:`Where the crawler looks for URLs: 'sitemaps' reads sitemap XML only, 'links' follows page links only, 'all' does both.`,choices:[`all`,`sitemaps`,`links`]}).option(`source-params-web-crawler-parse-options-include-images`,{type:`boolean`,description:`The source_params.web_crawler.parse_options.include_images field`}).option(`source-params-web-crawler-parse-options-specific-sitemaps`,{type:`string`,array:!0,description:`List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'.`}).option(`source-params-web-crawler-parse-options-use-browser-rendering`,{type:`boolean`,description:`The source_params.web_crawler.parse_options.use_browser_rendering field`}).option(`source-params-web-crawler-parse-type`,{type:`string`,description:`How URLs are discovered. 'sitemap' reads XML sitemaps; 'discover' follows links recursively and requires the source to be a Verified zone on this account.`,choices:[`sitemap`,`discover`]}).option(`token-id`,{type:`string`,description:`The token_id field`}).option(`type`,{type:`string`,description:`The type field`,choices:[`r2`,`web-crawler`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`}).check(e=>{if([`index-method-keyword`,`index-method-vector`].some(t=>e[t]!==void 0)){let t=[`index-method-keyword`,`index-method-vector`].filter(t=>e[t]===void 0);if(t.length>0)throw Error(`${t.map(e=>`--`+e).join(`, `)} ${t.length===1?`is`:`are`} required when any --index_method-* flag is set`)}return!0})}const x={command:`create <name> <id>`,describe:`Create a new AI Search instance with the given configuration.`,builder:b,handler:async r=>c({command:`ai-search create`,classification:{safeFlags:`cache.cache-threshold.chunk.fusion-method.hybrid-search-enabled.index-method-keyword.index-method-vector.indexing-options-keyword-tokenizer.indexing-options-use-ocr.metadata-created-from-aisearch-wizard.public-endpoint-params-chat-completions-endpoint-disabled.public-endpoint-params-default-domain-enabled.public-endpoint-params-enabled.public-endpoint-params-mcp-disabled.public-endpoint-params-rate-limit-technique.public-endpoint-params-search-endpoint-disabled.reranking.retrieval-options-keyword-match-mode.rewrite-query.source-params-web-crawler-discover-options-include-external-links.source-params-web-crawler-discover-options-include-subdomains.source-params-web-crawler-discover-options-source.source-params-web-crawler-parse-options-include-images.source-params-web-crawler-parse-options-use-browser-rendering.source-params-web-crawler-parse-type.type.dry-run`.split(`.`)}},r,async()=>{if(r.dryRun){o({command:`cf ai-search create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances`,pathParams:{name:String(r.name??``)},bodyKind:`json`,body:r.body===void 0?d({ai_gateway_id:f(r[`ai-gateway-id`],`ai-gateway-id`,`text`),ai_search_model:f(r[`ai-search-model`],`ai-search-model`,`text`),cache:r.cache,cache_threshold:f(r[`cache-threshold`],`cache-threshold`,`text`),chunk:r.chunk,chunk_overlap:r[`chunk-overlap`],chunk_size:r[`chunk-size`],custom_metadata:u(r[`custom-metadata`],`custom-metadata`),embedding_model:f(r[`embedding-model`],`embedding-model`,`text`),fusion_method:f(r[`fusion-method`],`fusion-method`,`text`),hybrid_search_enabled:r[`hybrid-search-enabled`],index_method:{keyword:r[`index-method-keyword`],vector:r[`index-method-vector`]},indexing_options:{keyword_tokenizer:f(r[`indexing-options-keyword-tokenizer`],`indexing-options-keyword-tokenizer`,`text`),use_ocr:r[`indexing-options-use-ocr`]},max_num_results:r[`max-num-results`],metadata:{created_from_aisearch_wizard:r[`metadata-created-from-aisearch-wizard`],worker_domain:f(r[`metadata-worker-domain`],`metadata-worker-domain`,`text`)},public_endpoint_params:{authorized_hosts:r[`public-endpoint-params-authorized-hosts`],chat_completions_endpoint:{disabled:r[`public-endpoint-params-chat-completions-endpoint-disabled`]},custom_domains:r[`public-endpoint-params-custom-domains`],default_domain_enabled:r[`public-endpoint-params-default-domain-enabled`],enabled:r[`public-endpoint-params-enabled`],mcp:{description:f(r[`public-endpoint-params-mcp-description`],`public-endpoint-params-mcp-description`,`text`),disabled:r[`public-endpoint-params-mcp-disabled`]},rate_limit:{period_ms:r[`public-endpoint-params-rate-limit-period-ms`],requests:r[`public-endpoint-params-rate-limit-requests`],technique:f(r[`public-endpoint-params-rate-limit-technique`],`public-endpoint-params-rate-limit-technique`,`text`)},search_endpoint:{disabled:r[`public-endpoint-params-search-endpoint-disabled`]}},reranking:r.reranking,reranking_model:f(r[`reranking-model`],`reranking-model`,`text`),retrieval_options:{keyword_match_mode:f(r[`retrieval-options-keyword-match-mode`],`retrieval-options-keyword-match-mode`,`text`)},rewrite_model:f(r[`rewrite-model`],`rewrite-model`,`text`),rewrite_query:r[`rewrite-query`],score_threshold:r[`score-threshold`],source:f(r.source,`source`,`text`),source_params:{exclude_items:r[`source-params-exclude-items`],include_items:r[`source-params-include-items`],prefix:f(r[`source-params-prefix`],`source-params-prefix`,`text`),r2_jurisdiction:f(r[`source-params-r2-jurisdiction`],`source-params-r2-jurisdiction`,`text`),web_crawler:{discover_options:{depth:r[`source-params-web-crawler-discover-options-depth`],include_external_links:r[`source-params-web-crawler-discover-options-include-external-links`],include_subdomains:r[`source-params-web-crawler-discover-options-include-subdomains`],limit:r[`source-params-web-crawler-discover-options-limit`],max_age:r[`source-params-web-crawler-discover-options-max-age`],source:f(r[`source-params-web-crawler-discover-options-source`],`source-params-web-crawler-discover-options-source`,`text`)},parse_options:{include_images:r[`source-params-web-crawler-parse-options-include-images`],specific_sitemaps:r[`source-params-web-crawler-parse-options-specific-sitemaps`],use_browser_rendering:r[`source-params-web-crawler-parse-options-use-browser-rendering`]},parse_type:f(r[`source-params-web-crawler-parse-type`],`source-params-web-crawler-parse-type`,`text`)}},token_id:f(r[`token-id`],`token-id`,`text`),type:f(r.type,`type`,`text`),id:r.id}):l(r.body)});return}let c=await i(r),p=r.local?e:await t();if(r.accountId=p,r.body){let e=l(r.body);a(await s(`Creating`,async()=>c.aiSearch.create({...e,account_id:p,name:r.name})),{successLabel:`Created`});return}let m=d({ai_gateway_id:f(r[`ai-gateway-id`],`ai-gateway-id`,`text`),ai_search_model:f(r[`ai-search-model`],`ai-search-model`,`text`),cache:r.cache,cache_threshold:f(r[`cache-threshold`],`cache-threshold`,`text`),chunk:r.chunk,chunk_overlap:r[`chunk-overlap`],chunk_size:r[`chunk-size`],custom_metadata:u(r[`custom-metadata`],`custom-metadata`),embedding_model:f(r[`embedding-model`],`embedding-model`,`text`),fusion_method:f(r[`fusion-method`],`fusion-method`,`text`),hybrid_search_enabled:r[`hybrid-search-enabled`],index_method:{keyword:r[`index-method-keyword`],vector:r[`index-method-vector`]},indexing_options:{keyword_tokenizer:f(r[`indexing-options-keyword-tokenizer`],`indexing-options-keyword-tokenizer`,`text`),use_ocr:r[`indexing-options-use-ocr`]},max_num_results:r[`max-num-results`],metadata:{created_from_aisearch_wizard:r[`metadata-created-from-aisearch-wizard`],worker_domain:f(r[`metadata-worker-domain`],`metadata-worker-domain`,`text`)},public_endpoint_params:{authorized_hosts:r[`public-endpoint-params-authorized-hosts`],chat_completions_endpoint:{disabled:r[`public-endpoint-params-chat-completions-endpoint-disabled`]},custom_domains:r[`public-endpoint-params-custom-domains`],default_domain_enabled:r[`public-endpoint-params-default-domain-enabled`],enabled:r[`public-endpoint-params-enabled`],mcp:{description:f(r[`public-endpoint-params-mcp-description`],`public-endpoint-params-mcp-description`,`text`),disabled:r[`public-endpoint-params-mcp-disabled`]},rate_limit:{period_ms:r[`public-endpoint-params-rate-limit-period-ms`],requests:r[`public-endpoint-params-rate-limit-requests`],technique:f(r[`public-endpoint-params-rate-limit-technique`],`public-endpoint-params-rate-limit-technique`,`text`)},search_endpoint:{disabled:r[`public-endpoint-params-search-endpoint-disabled`]}},reranking:r.reranking,reranking_model:f(r[`reranking-model`],`reranking-model`,`text`),retrieval_options:{keyword_match_mode:f(r[`retrieval-options-keyword-match-mode`],`retrieval-options-keyword-match-mode`,`text`)},rewrite_model:f(r[`rewrite-model`],`rewrite-model`,`text`),rewrite_query:r[`rewrite-query`],score_threshold:r[`score-threshold`],source:f(r.source,`source`,`text`),source_params:{exclude_items:r[`source-params-exclude-items`],include_items:r[`source-params-include-items`],prefix:f(r[`source-params-prefix`],`source-params-prefix`,`text`),r2_jurisdiction:f(r[`source-params-r2-jurisdiction`],`source-params-r2-jurisdiction`,`text`),web_crawler:{discover_options:{depth:r[`source-params-web-crawler-discover-options-depth`],include_external_links:r[`source-params-web-crawler-discover-options-include-external-links`],include_subdomains:r[`source-params-web-crawler-discover-options-include-subdomains`],limit:r[`source-params-web-crawler-discover-options-limit`],max_age:r[`source-params-web-crawler-discover-options-max-age`],source:f(r[`source-params-web-crawler-discover-options-source`],`source-params-web-crawler-discover-options-source`,`text`)},parse_options:{include_images:r[`source-params-web-crawler-parse-options-include-images`],specific_sitemaps:r[`source-params-web-crawler-parse-options-specific-sitemaps`],use_browser_rendering:r[`source-params-web-crawler-parse-options-use-browser-rendering`]},parse_type:f(r[`source-params-web-crawler-parse-type`],`source-params-web-crawler-parse-type`,`text`)}},token_id:f(r[`token-id`],`token-id`,`text`),type:f(r.type,`type`,`text`),id:r.id});a(await s(`Creating`,async()=>c.aiSearch.create({...m,account_id:p,name:r.name})),{successLabel:`Created`})})};function S(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const C={command:`delete <id>`,describe:`Permanently delete an AI Search instance and all its indexed data.`,builder:S,handler:async r=>c({command:`ai-search delete`,classification:{safeFlags:[`dry-run`,`force`],shortFlagAliases:{f:{canonical:`force`,type:`boolean`}}}},r,async()=>{if(r.dryRun){o({command:`cf ai-search delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}`,pathParams:{id:String(r.id??``),name:String(r.name??``)},bodyKind:`none`});return}let c=await i(r),l=r.local?e:await t();if(r.accountId=l,!await g({force:!!r.force,message:`This operation permanently deletes the AI Search instance and all its indexed data.`})){process.stderr.write(`Aborted.
3
3
  `);return}a(await s(`Deleting`,async()=>c.aiSearch.delete({account_id:l,name:r.name,id:r.id})),{successLabel:`Deleted`})})};function w(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const T={command:`get <id>`,describe:`Retrieve the configuration and status of an AI Search instance.`,builder:w,handler:async r=>c({command:`ai-search get`,classification:{safeFlags:[`dry-run`]}},r,async()=>{if(r.dryRun){o({command:`cf ai-search get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}`,pathParams:{id:String(r.id??``),name:String(r.name??``)},bodyKind:`none`});return}let c=await i(r),l=r.local?e:await t();r.accountId=l,a(await s(`Loading`,async()=>c.aiSearch.get({account_id:l,name:r.name,id:r.id})),{successLabel:`Loaded`})})};function E(e){return e.positional(`item-id`,{type:`string`,description:`Indexed item ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`limit`,{type:`number`,description:`Limit`}).option(`offset`,{type:`number`,description:`Offset`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const D={command:`chunks <item-id>`,describe:`Lists chunks for a specific item in an AI Search instance, including their text content.`,builder:E,handler:async r=>c({command:`ai-search items chunks`,classification:{safeFlags:[`dry-run`]}},r,async()=>{let c={limit:r.limit,offset:r.offset};if(r.dryRun){o({command:`cf ai-search items chunks`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}/items/${r[`item-id`]==null?`<item-id>`:encodeURIComponent(String(r[`item-id`]))}/chunks`,pathParams:{id:String(r.id??``),"item-id":String(r[`item-id`]??``),name:String(r.name??``)},query:c,bodyKind:`none`});return}let l=await i(r),u=r.local?e:await t();r.accountId=u,a(await s(`Loading`,async()=>l.aiSearch.items.chunks({account_id:u,name:r.name,id:r.id,item_id:r[`item-id`],...c})),{successLabel:`Loaded`})})};function O(e){return e.positional(`item-id`,{type:`string`,description:`Indexed item ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const k={command:`delete <item-id>`,describe:`Deletes a file from a managed AI Search instance and triggers a reindex.`,builder:O,handler:async r=>c({command:`ai-search items delete`,classification:{safeFlags:[`dry-run`,`force`],shortFlagAliases:{f:{canonical:`force`,type:`boolean`}}}},r,async()=>{if(r.dryRun){o({command:`cf ai-search items delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}/items/${r[`item-id`]==null?`<item-id>`:encodeURIComponent(String(r[`item-id`]))}`,pathParams:{id:String(r.id??``),"item-id":String(r[`item-id`]??``),name:String(r.name??``)},bodyKind:`none`});return}let c=await i(r),l=r.local?e:await t();if(r.accountId=l,!await g({force:!!r.force})){process.stderr.write(`Aborted.
4
4
  `);return}a(await s(`Deleting`,async()=>c.aiSearch.items.delete({account_id:l,name:r.name,id:r.id,item_id:r[`item-id`]})),{successLabel:`Deleted`})})};function A(e){return e.positional(`item-id`,{type:`string`,description:`Indexed item ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`text`,{type:`boolean`,description:`Decode the response body as UTF-8 text instead of writing raw bytes`,default:!1})}const j={command:`download <item-id>`,describe:`Downloads the raw file content for a specific item from the managed AI Search instance storage.`,builder:A,handler:async r=>c({command:`ai-search items download`,classification:{safeFlags:[`dry-run`,`text`]}},r,async()=>{if(r.dryRun){o({command:`cf ai-search items download`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}/items/${r[`item-id`]==null?`<item-id>`:encodeURIComponent(String(r[`item-id`]))}/download`,pathParams:{id:String(r.id??``),"item-id":String(r[`item-id`]??``),name:String(r.name??``)},bodyKind:`none`});return}await i(r);let a=r.local?e:await t();r.accountId=a;let c=await s(`Loading`,async()=>te(`/accounts/${a}/ai-search/namespaces/${encodeURIComponent(String(r.name))}/instances/${encodeURIComponent(String(r.id))}/items/${encodeURIComponent(String(r[`item-id`]))}/download`,{method:`GET`,local:r.local===!0,persistTo:r.persistTo}));ee(r.text===!0?c.toString(`utf-8`):c)})};function M(e){return e.positional(`item-id`,{type:`string`,description:`Indexed item ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const N={command:`get <item-id>`,describe:`Retrieves a specific indexed item from an AI Search instance.`,builder:M,handler:async r=>c({command:`ai-search items get`,classification:{safeFlags:[`dry-run`]}},r,async()=>{if(r.dryRun){o({command:`cf ai-search items get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}/items/${r[`item-id`]==null?`<item-id>`:encodeURIComponent(String(r[`item-id`]))}`,pathParams:{id:String(r.id??``),"item-id":String(r[`item-id`]??``),name:String(r.name??``)},bodyKind:`none`});return}let c=await i(r),l=r.local?e:await t();r.accountId=l,a(await s(`Loading`,async()=>c.aiSearch.items.get({account_id:l,name:r.name,id:r.id,item_id:r[`item-id`]})),{successLabel:`Loaded`})})};function P(e){return e.option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`page`,{type:`number`,description:`Page`}).option(`per-page`,{type:`number`,description:`Per page`}).option(`search`,{type:`string`,description:`Search`}).option(`sort-by`,{type:`string`,description:`Sort order for items. "status" (default) sorts by status priority then last_seen_at. "modified_at" sorts by file modification time (most recent first), falling back to created_at.`,choices:[`status`,`modified_at`]}).option(`status`,{type:`string`,description:`Status`,choices:[`queued`,`running`,`completed`,`error`,`skipped`,`outdated`]}).option(`source`,{type:`string`,description:`Filter items by source_id. Use "builtin" for uploaded files, or a source identifier like "web-crawler:https://example.com".`}).option(`metadata-filter`,{type:`string`,description:`JSON-encoded metadata filter using Vectorize filter syntax. Examples: {"folder":"reports/"}, {"timestamp":{"$gte":1700000000000}}, {"folder":{"$in":["docs/","reports/"]}}`}).option(`item-id`,{type:`string`,description:`Filter items by their unique ID. Returns at most one item.`}).option(`key`,{type:`string`,description:"Filter items by their exact key (object key / filename). Keys are unique per source, so combine with `source` to disambiguate across data sources."}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const F={command:`list`,describe:`Lists indexed items in an AI Search instance.`,builder:_(P),handler:async r=>c({command:`ai-search items list`,classification:{safeFlags:[`sort-by`,`status`,`dry-run`]}},r,async()=>{let c={page:r.page,per_page:r[`per-page`],search:r.search,sort_by:r[`sort-by`],status:r.status,source:r.source,metadata_filter:r[`metadata-filter`],item_id:r[`item-id`],key:r.key};if(r.dryRun){o({command:`cf ai-search items list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}/items`,pathParams:{id:String(r.id??``),name:String(r.name??``)},query:c,bodyKind:`none`});return}let l=await i(r),u=r.local?e:await t();r.accountId=u,a(await s(`Loading`,async()=>l.aiSearch.items.list({account_id:u,name:r.name,id:r.id,...c})),{successLabel:`Loaded`})})};function I(e){return e.positional(`item-id`,{type:`string`,description:`Indexed item ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`limit`,{type:`number`,description:`Limit`}).option(`cursor`,{type:`string`,description:`Cursor`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const L={command:`logs <item-id>`,describe:`Lists processing logs for a specific item in an AI Search instance.`,builder:I,handler:async r=>c({command:`ai-search items logs`,classification:{safeFlags:[`dry-run`]}},r,async()=>{let c={limit:r.limit,cursor:r.cursor};if(r.dryRun){o({command:`cf ai-search items logs`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}/items/${r[`item-id`]==null?`<item-id>`:encodeURIComponent(String(r[`item-id`]))}/logs`,pathParams:{id:String(r.id??``),"item-id":String(r[`item-id`]??``),name:String(r.name??``)},query:c,bodyKind:`none`});return}let l=await i(r),u=r.local?e:await t();r.accountId=u,a(await s(`Loading`,async()=>l.aiSearch.items.logs({account_id:u,name:r.name,id:r.id,item_id:r[`item-id`],...c})),{successLabel:`Loaded`})})};function R(e){return e.positional(`item-id`,{type:`string`,description:`Indexed item ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`next-action`,{type:`string`,description:`The next_action field`,choices:[`INDEX`]}).option(`wait-for-completion`,{type:`boolean`,description:"Wait for indexing to fully complete before responding. On RAGs with vector indexing enabled, this additionally waits for Vectorize ingestion confirmation (up to 40s) so the returned item reflects a queryable state. On timeout the item is returned in `running` state and the background alarm continues polling. Defaults to false."}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const z={command:`sync <item-id>`,describe:`Syncs an item to an AI Search instance index.`,builder:R,handler:async r=>c({command:`ai-search items sync`,classification:{safeFlags:[`next-action`,`wait-for-completion`,`dry-run`]}},r,async()=>{if(r.dryRun){o({command:`cf ai-search items sync`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}/items/${r[`item-id`]==null?`<item-id>`:encodeURIComponent(String(r[`item-id`]))}`,pathParams:{id:String(r.id??``),"item-id":String(r[`item-id`]??``),name:String(r.name??``)},bodyKind:`json`,body:r.body===void 0?d({next_action:f(r[`next-action`],`next-action`,`text`),wait_for_completion:r[`wait-for-completion`]}):l(r.body)});return}let c=await i(r),u=r.local?e:await t();if(r.accountId=u,r.body){let e=l(r.body);a(await s(`Updating`,async()=>c.aiSearch.items.sync({...e,account_id:u,name:r.name,id:r.id,item_id:r[`item-id`]})),{successLabel:`Updated`});return}r[`next-action`]===void 0&&(r[`next-action`]=await h(`next-action`,`The next_action field`,[`INDEX`]));let p=d({next_action:f(r[`next-action`],`next-action`,`text`),wait_for_completion:r[`wait-for-completion`]});a(await s(`Updating`,async()=>c.aiSearch.items.sync({...p,account_id:u,name:r.name,id:r.id,item_id:r[`item-id`]})),{successLabel:`Updated`})})};function B(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`}).option(`file`,{type:`string`,description:`Path to a file to upload as the request body`}).option(`metadata`,{type:`string`,description:`JSON string of custom metadata key-value pairs.`}).option(`wait-for-completion`,{type:`boolean`,description:"Wait for indexing to fully complete before responding. On RAGs with vector indexing enabled, this additionally waits for Vectorize ingestion confirmation (up to 40s) so the returned item reflects a queryable state. On timeout the item is returned in `running` state and the background alarm continues polling. Defaults to false."})}const V={command:`upload <id>`,describe:`Uploads a file to a managed AI Search instance via multipart/form-data.`,builder:B,handler:async l=>c({command:`ai-search items upload`,classification:{safeFlags:[`dry-run`]}},l,async()=>{if(l.dryRun){o({command:`cf ai-search items upload`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${l.name==null?`<name>`:encodeURIComponent(String(l.name))}/instances/${l.id==null?`<id>`:encodeURIComponent(String(l.id))}/items`,pathParams:{id:String(l.id??``),name:String(l.name??``)},bodyKind:`multipart`,body:{body:l.body,file:l.file,metadata:l.metadata,"wait-for-completion":l[`wait-for-completion`]}});return}let c=await i(l),u=l.local?e:await t();if(l.accountId=u,l.file!==void 0||l.body!==void 0||l.metadata!==void 0||l[`wait-for-completion`]!==void 0){let e=new FormData;if(l.file){let t=p(l.file);e.append(`file`,new Blob([t]),l.file.split(/[\\/]/).filter(Boolean).pop())}else l.body!==void 0&&e.append(`file`,l.body);l.metadata!==void 0&&e.append(`metadata`,String(f(l.metadata,`metadata`,`text`)??``)),l[`wait-for-completion`]!==void 0&&e.append(`wait_for_completion`,String(l[`wait-for-completion`])),a(await s(`Creating`,async()=>r(c,`POST`,`/accounts/${u}/ai-search/namespaces/${encodeURIComponent(String(l.name))}/instances/${encodeURIComponent(String(l.id))}/items`,{body:e})),{successLabel:`Created`});return}if(l.body){let e=f(l.body,`body`,`binary`);a(await s(`Creating`,async()=>r(c,`POST`,`/accounts/${u}/ai-search/namespaces/${encodeURIComponent(String(l.name))}/instances/${encodeURIComponent(String(l.id))}/items`,{body:e,headers:{"Content-Type":`multipart/form-data`}})),{successLabel:`Created`});return}if(l.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)})};function H(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`key`,{type:`string`,description:`Item key / filename. Must not exceed 128 characters.`}).option(`next-action`,{type:`string`,description:`The next_action field`,choices:[`INDEX`]}).option(`wait-for-completion`,{type:`boolean`,description:"Wait for indexing to fully complete before responding. On RAGs with vector indexing enabled, this additionally waits for Vectorize ingestion confirmation (up to 40s) so the returned item reflects a queryable state. On timeout the item is returned in `running` state and the background alarm continues polling. Defaults to false."}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const U={command:`upsert <id>`,describe:`Creates or updates an indexed item in an AI Search instance.`,builder:H,handler:async r=>c({command:`ai-search items upsert`,classification:{safeFlags:[`next-action`,`wait-for-completion`,`dry-run`]}},r,async()=>{if(r.dryRun){o({command:`cf ai-search items upsert`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}/items`,pathParams:{id:String(r.id??``),name:String(r.name??``)},bodyKind:`json`,body:r.body===void 0?d({key:f(r.key,`key`,`text`),next_action:f(r[`next-action`],`next-action`,`text`),wait_for_completion:r[`wait-for-completion`]}):l(r.body)});return}let c=await i(r),u=r.local?e:await t();if(r.accountId=u,r.body){let e=l(r.body);a(await s(`Updating`,async()=>c.aiSearch.items.upsert({...e,account_id:u,name:r.name,id:r.id})),{successLabel:`Updated`});return}r.key===void 0&&(r.key=await m(`key`,`Item key / filename. Must not exceed 128 characters.`)),r[`next-action`]===void 0&&(r[`next-action`]=await h(`next-action`,`The next_action field`,[`INDEX`]));let p=d({key:f(r.key,`key`,`text`),next_action:f(r[`next-action`],`next-action`,`text`),wait_for_completion:r[`wait-for-completion`]});a(await s(`Updating`,async()=>c.aiSearch.items.upsert({...p,account_id:u,name:r.name,id:r.id})),{successLabel:`Updated`})})},W={command:`items`,describe:`Content indexed by AI Search instances`,builder:e=>e.command(D).command(k).command(j).command(N).command(F).command(L).command(z).command(V).command(U).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function G(e){return e.positional(`job-id`,{type:`string`,description:`Indexing job ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`action`,{type:`string`,description:`The action field`,choices:[`cancel`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const K={command:`cancel <job-id>`,describe:`Cancel an in-progress indexing job for an AI Search instance.`,builder:G,handler:async r=>c({command:`ai-search jobs cancel`,classification:{safeFlags:[`action`,`dry-run`,`force`],shortFlagAliases:{f:{canonical:`force`,type:`boolean`}}}},r,async()=>{if(r.dryRun){o({command:`cf ai-search jobs cancel`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}/jobs/${r[`job-id`]==null?`<job-id>`:encodeURIComponent(String(r[`job-id`]))}`,pathParams:{id:String(r.id??``),"job-id":String(r[`job-id`]??``),name:String(r.name??``)},bodyKind:`json`,body:r.body===void 0?d({action:f(r.action,`action`,`text`)}):l(r.body)});return}let c=await i(r),u=r.local?e:await t();if(r.accountId=u,!await g({force:!!r.force,message:`This operation cancels the running indexing job.`})){process.stderr.write(`Aborted.
5
5
  `);return}if(r.body){let e=l(r.body);a(await s(`Deleting`,async()=>c.aiSearch.jobs.cancel({...e,account_id:u,name:r.name,id:r.id,job_id:r[`job-id`]})),{successLabel:`Deleted`});return}r.action===void 0&&(r.action=await h(`action`,`The action field`,[`cancel`]));let p=d({action:f(r.action,`action`,`text`)});a(await s(`Deleting`,async()=>c.aiSearch.jobs.cancel({...p,account_id:u,name:r.name,id:r.id,job_id:r[`job-id`]})),{successLabel:`Deleted`})})};function q(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`description`,{type:`string`,description:`The description field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const J={command:`create <id>`,describe:`Creates a new indexing job for an AI Search instance.`,builder:q,handler:async r=>c({command:`ai-search jobs create`,classification:{safeFlags:[`dry-run`]}},r,async()=>{if(r.dryRun){o({command:`cf ai-search jobs create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}/jobs`,pathParams:{id:String(r.id??``),name:String(r.name??``)},bodyKind:`json`,body:r.body===void 0?d({description:f(r.description,`description`,`text`)}):l(r.body)});return}let c=await i(r),u=r.local?e:await t();if(r.accountId=u,r.body){let e=l(r.body);a(await s(`Creating`,async()=>c.aiSearch.jobs.create({...e,account_id:u,name:r.name,id:r.id})),{successLabel:`Created`});return}let p=d({description:f(r.description,`description`,`text`)});a(await s(`Creating`,async()=>c.aiSearch.jobs.create({...p,account_id:u,name:r.name,id:r.id})),{successLabel:`Created`})})};function Y(e){return e.positional(`job-id`,{type:`string`,description:`Indexing job ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const X={command:`get <job-id>`,describe:`Retrieves details for a specific AI Search indexing job.`,builder:Y,handler:async r=>c({command:`ai-search jobs get`,classification:{safeFlags:[`dry-run`]}},r,async()=>{if(r.dryRun){o({command:`cf ai-search jobs get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}/jobs/${r[`job-id`]==null?`<job-id>`:encodeURIComponent(String(r[`job-id`]))}`,pathParams:{id:String(r.id??``),"job-id":String(r[`job-id`]??``),name:String(r.name??``)},bodyKind:`none`});return}let c=await i(r),l=r.local?e:await t();r.accountId=l,a(await s(`Loading`,async()=>c.aiSearch.jobs.get({account_id:l,name:r.name,id:r.id,job_id:r[`job-id`]})),{successLabel:`Loaded`})})};function Z(e){return e.option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`page`,{type:`number`,description:`Page`}).option(`per-page`,{type:`number`,description:`Per page`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Q={command:`list`,describe:`Lists indexing jobs for an AI Search instance.`,builder:Z,handler:async r=>c({command:`ai-search jobs list`,classification:{safeFlags:[`dry-run`]}},r,async()=>{let c={page:r.page,per_page:r[`per-page`]};if(r.dryRun){o({command:`cf ai-search jobs list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}/jobs`,pathParams:{id:String(r.id??``),name:String(r.name??``)},query:c,bodyKind:`none`});return}let l=await i(r),u=r.local?e:await t();r.accountId=u,a(await s(`Loading`,async()=>l.aiSearch.jobs.list({account_id:u,name:r.name,id:r.id,...c})),{successLabel:`Loaded`})})};function ne(e){return e.positional(`job-id`,{type:`string`,description:`Indexing job ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`page`,{type:`number`,description:`Page`}).option(`per-page`,{type:`number`,description:`Per page`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const re={command:`logs <job-id>`,describe:`Lists log entries for an AI Search indexing job.`,builder:ne,handler:async r=>c({command:`ai-search jobs logs`,classification:{safeFlags:[`dry-run`]}},r,async()=>{let c={page:r.page,per_page:r[`per-page`]};if(r.dryRun){o({command:`cf ai-search jobs logs`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}/jobs/${r[`job-id`]==null?`<job-id>`:encodeURIComponent(String(r[`job-id`]))}/logs`,pathParams:{id:String(r.id??``),"job-id":String(r[`job-id`]??``),name:String(r.name??``)},query:c,bodyKind:`none`});return}let l=await i(r),u=r.local?e:await t();r.accountId=u,a(await s(`Loading`,async()=>l.aiSearch.jobs.logs({account_id:u,name:r.name,id:r.id,job_id:r[`job-id`],...c})),{successLabel:`Loaded`})})},ie={command:`jobs`,describe:`Indexing job lifecycle for AI Search instances`,builder:e=>e.command(K).command(J).command(X).command(Q).command(re).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function ae(e){return e.option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`page`,{type:`number`,description:`Page number (1-indexed).`}).option(`per-page`,{type:`number`,description:`Number of results per page.`}).option(`search`,{type:`string`,description:`Filter instances whose id contains this string (case-insensitive).`}).option(`order-by`,{type:`string`,description:`Field to order results by.`,choices:[`created_at`]}).option(`order-by-direction`,{type:`string`,description:`Order direction.`,choices:[`asc`,`desc`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const oe={command:`list`,describe:`List all AI Search instances in the account.`,builder:_(ae),handler:async r=>c({command:`ai-search list`,classification:{safeFlags:[`order-by`,`order-by-direction`,`dry-run`]}},r,async()=>{let c={page:r.page,per_page:r[`per-page`],search:r.search,order_by:r[`order-by`],order_by_direction:r[`order-by-direction`]};if(r.dryRun){o({command:`cf ai-search list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances`,pathParams:{name:String(r.name??``)},query:c,bodyKind:`none`});return}let l=await i(r),u=r.local?e:await t();r.accountId=u,a(await s(`Loading`,async()=>l.aiSearch.list({account_id:u,name:r.name,...c})),{successLabel:`Loaded`})})};function se(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace currently containing the instance.`,demandOption:!0}).option(`destination-namespace`,{type:`string`,description:`Target namespace to move the instance into.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const ce={command:`move <id>`,describe:`Moves an instance from its current namespace to the specified target namespace. Use 'default' with --destination-namespace to move the instance back to the default namespace. Fails with 400 if the target namespace already has an instance with the same id (ids must be unique within a namespace — the same id can exist in different namespaces).`,builder:se,handler:async r=>c({command:`ai-search move`,classification:{safeFlags:[`dry-run`]}},r,async()=>{if(r.dryRun){o({command:`cf ai-search move`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}`,pathParams:{name:String(r.name??``),id:String(r.id??``)},bodyKind:`json`,body:r.body===void 0?d({new_namespace:f(r[`destination-namespace`],`destination-namespace`,`text`)}):l(r.body)});return}let c=await i(r),u=r.local?e:await t();if(r.accountId=u,r.body){let e=l(r.body);a(await s(`Updating`,async()=>c.aiSearch.move({...e,account_id:u,name:r.name,id:r.id})),{successLabel:`Updated`});return}r[`destination-namespace`]===void 0&&(r[`destination-namespace`]=await m(`destination-namespace`,`Target namespace to move the instance into.`));let p=d({new_namespace:f(r[`destination-namespace`],`destination-namespace`,`text`)});a(await s(`Updating`,async()=>c.aiSearch.move({...p,account_id:u,name:r.name,id:r.id})),{successLabel:`Updated`})})};function le(e){return e.positional(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`ai-search-options-cache-cache-threshold`,{type:`string`,description:`The ai_search_options.cache.cache_threshold field`,choices:[`super_strict_match`,`close_enough`,`flexible_friend`,`anything_goes`]}).option(`ai-search-options-cache-enabled`,{type:`boolean`,description:`The ai_search_options.cache.enabled field`}).option(`ai-search-options-instance-ids`,{type:`string`,array:!0,description:`The ai_search_options.instance_ids field`}).option(`ai-search-options-query-rewrite-enabled`,{type:`boolean`,description:`The ai_search_options.query_rewrite.enabled field`}).option(`ai-search-options-query-rewrite-model`,{type:`string`,description:`A Workers AI model ID or an AI Gateway model ID compatible with the OpenAI Chat Completions API. An empty string uses the configured or default model.`}).option(`ai-search-options-query-rewrite-rewrite-prompt`,{type:`string`,description:`The ai_search_options.query_rewrite.rewrite_prompt field`}).option(`ai-search-options-reranking-enabled`,{type:`boolean`,description:`The ai_search_options.reranking.enabled field`}).option(`ai-search-options-reranking-match-threshold`,{type:`number`,description:`The ai_search_options.reranking.match_threshold field`,default:.4}).option(`ai-search-options-reranking-model`,{type:`string`,description:`The ai_search_options.reranking.model field`}).option(`ai-search-options-retrieval-context-expansion`,{type:`number`,description:`The ai_search_options.retrieval.context_expansion field`,default:0}).option(`ai-search-options-retrieval-fusion-method`,{type:`string`,description:`The ai_search_options.retrieval.fusion_method field`,choices:[`max`,`rrf`]}).option(`ai-search-options-retrieval-keyword-match-mode`,{type:`string`,description:`Controls which documents are candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term, ranked by BM25 relevance. When omitted, falls back to the instance-level retrieval_options.keyword_match_mode, then to 'and'.`,choices:[`and`,`or`]}).option(`ai-search-options-retrieval-match-threshold`,{type:`number`,description:`The ai_search_options.retrieval.match_threshold field`,default:.4}).option(`ai-search-options-retrieval-max-num-results`,{type:`number`,description:`The ai_search_options.retrieval.max_num_results field`,default:10}).option(`ai-search-options-retrieval-retrieval-type`,{type:`string`,description:`The ai_search_options.retrieval.retrieval_type field`,choices:[`vector`,`keyword`,`hybrid`]}).option(`ai-search-options-retrieval-return-on-failure`,{type:`boolean`,description:`The ai_search_options.retrieval.return_on_failure field`,default:!0}).option(`messages`,{type:`string`,description:`The messages field. Provide as a JSON array of objects or @path/to/file.json.`}).option(`model`,{type:`string`,description:`A Workers AI model ID or an AI Gateway model ID compatible with the OpenAI Chat Completions API. An empty string uses the configured or default model.`}).option(`stream`,{type:`boolean`,description:`The stream field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const ue={command:`multi-chat-completions <name>`,describe:`Performs a chat completion request against multiple AI Search instances in parallel, merging retrieved content as context for generating a response.`,builder:le,handler:async r=>c({command:`ai-search multi-chat-completions`,classification:{safeFlags:[`ai-search-options-cache-cache-threshold`,`ai-search-options-cache-enabled`,`ai-search-options-query-rewrite-enabled`,`ai-search-options-reranking-enabled`,`ai-search-options-retrieval-fusion-method`,`ai-search-options-retrieval-keyword-match-mode`,`ai-search-options-retrieval-retrieval-type`,`ai-search-options-retrieval-return-on-failure`,`stream`,`dry-run`]}},r,async()=>{if(r.dryRun){o({command:`cf ai-search multi-chat-completions`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/chat/completions`,pathParams:{name:String(r.name??``)},bodyKind:`json`,body:r.body===void 0?d({ai_search_options:{cache:{cache_threshold:f(r[`ai-search-options-cache-cache-threshold`],`ai-search-options-cache-cache-threshold`,`text`),enabled:r[`ai-search-options-cache-enabled`]},instance_ids:r[`ai-search-options-instance-ids`],query_rewrite:{enabled:r[`ai-search-options-query-rewrite-enabled`],model:f(r[`ai-search-options-query-rewrite-model`],`ai-search-options-query-rewrite-model`,`text`),rewrite_prompt:f(r[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:r[`ai-search-options-reranking-enabled`],match_threshold:r[`ai-search-options-reranking-match-threshold`],model:f(r[`ai-search-options-reranking-model`],`ai-search-options-reranking-model`,`text`)},retrieval:{context_expansion:r[`ai-search-options-retrieval-context-expansion`],fusion_method:f(r[`ai-search-options-retrieval-fusion-method`],`ai-search-options-retrieval-fusion-method`,`text`),keyword_match_mode:f(r[`ai-search-options-retrieval-keyword-match-mode`],`ai-search-options-retrieval-keyword-match-mode`,`text`),match_threshold:r[`ai-search-options-retrieval-match-threshold`],max_num_results:r[`ai-search-options-retrieval-max-num-results`],retrieval_type:f(r[`ai-search-options-retrieval-retrieval-type`],`ai-search-options-retrieval-retrieval-type`,`text`),return_on_failure:r[`ai-search-options-retrieval-return-on-failure`]}},messages:u(r.messages,`messages`),model:f(r.model,`model`,`text`),stream:r.stream}):l(r.body)});return}let c=await i(r),p=r.local?e:await t();if(r.accountId=p,r.body){let e=l(r.body);a(await s(`Creating`,async()=>c.aiSearch.multiChatCompletions({...e,account_id:p,name:r.name})),{successLabel:`Created`});return}if(r[`ai-search-options-instance-ids`]===void 0)throw Error(`--ai-search-options-instance-ids is required (or pass --body with this field set).`);if(r.messages===void 0)throw Error(`--messages is required (or pass --body with this field set).`);let m=d({ai_search_options:{cache:{cache_threshold:f(r[`ai-search-options-cache-cache-threshold`],`ai-search-options-cache-cache-threshold`,`text`),enabled:r[`ai-search-options-cache-enabled`]},instance_ids:r[`ai-search-options-instance-ids`],query_rewrite:{enabled:r[`ai-search-options-query-rewrite-enabled`],model:f(r[`ai-search-options-query-rewrite-model`],`ai-search-options-query-rewrite-model`,`text`),rewrite_prompt:f(r[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:r[`ai-search-options-reranking-enabled`],match_threshold:r[`ai-search-options-reranking-match-threshold`],model:f(r[`ai-search-options-reranking-model`],`ai-search-options-reranking-model`,`text`)},retrieval:{context_expansion:r[`ai-search-options-retrieval-context-expansion`],fusion_method:f(r[`ai-search-options-retrieval-fusion-method`],`ai-search-options-retrieval-fusion-method`,`text`),keyword_match_mode:f(r[`ai-search-options-retrieval-keyword-match-mode`],`ai-search-options-retrieval-keyword-match-mode`,`text`),match_threshold:r[`ai-search-options-retrieval-match-threshold`],max_num_results:r[`ai-search-options-retrieval-max-num-results`],retrieval_type:f(r[`ai-search-options-retrieval-retrieval-type`],`ai-search-options-retrieval-retrieval-type`,`text`),return_on_failure:r[`ai-search-options-retrieval-return-on-failure`]}},messages:u(r.messages,`messages`),model:f(r.model,`model`,`text`),stream:r.stream});a(await s(`Creating`,async()=>c.aiSearch.multiChatCompletions({...m,account_id:p,name:r.name})),{successLabel:`Created`})})};function de(e){return e.positional(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).positional(`query`,{type:`string`,description:`Text to search for.`}).option(`ai-search-options-cache-cache-threshold`,{type:`string`,description:`The ai_search_options.cache.cache_threshold field`,choices:[`super_strict_match`,`close_enough`,`flexible_friend`,`anything_goes`]}).option(`ai-search-options-cache-enabled`,{type:`boolean`,description:`The ai_search_options.cache.enabled field`}).option(`ai-search-options-instance-ids`,{type:`string`,array:!0,description:`The ai_search_options.instance_ids field`}).option(`ai-search-options-query-rewrite-enabled`,{type:`boolean`,description:`The ai_search_options.query_rewrite.enabled field`}).option(`ai-search-options-query-rewrite-model`,{type:`string`,description:`A Workers AI model ID or an AI Gateway model ID compatible with the OpenAI Chat Completions API. An empty string uses the configured or default model.`}).option(`ai-search-options-query-rewrite-rewrite-prompt`,{type:`string`,description:`The ai_search_options.query_rewrite.rewrite_prompt field`}).option(`ai-search-options-reranking-enabled`,{type:`boolean`,description:`The ai_search_options.reranking.enabled field`}).option(`ai-search-options-reranking-match-threshold`,{type:`number`,description:`The ai_search_options.reranking.match_threshold field`,default:.4}).option(`ai-search-options-reranking-model`,{type:`string`,description:`The ai_search_options.reranking.model field`}).option(`ai-search-options-retrieval-context-expansion`,{type:`number`,description:`The ai_search_options.retrieval.context_expansion field`,default:0}).option(`ai-search-options-retrieval-fusion-method`,{type:`string`,description:`The ai_search_options.retrieval.fusion_method field`,choices:[`max`,`rrf`]}).option(`ai-search-options-retrieval-keyword-match-mode`,{type:`string`,description:`Controls which documents are candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term, ranked by BM25 relevance. When omitted, falls back to the instance-level retrieval_options.keyword_match_mode, then to 'and'.`,choices:[`and`,`or`]}).option(`ai-search-options-retrieval-match-threshold`,{type:`number`,description:`The ai_search_options.retrieval.match_threshold field`,default:.4}).option(`ai-search-options-retrieval-max-num-results`,{type:`number`,description:`The ai_search_options.retrieval.max_num_results field`,default:10}).option(`ai-search-options-retrieval-retrieval-type`,{type:`string`,description:`The ai_search_options.retrieval.retrieval_type field`,choices:[`vector`,`keyword`,`hybrid`]}).option(`ai-search-options-retrieval-return-on-failure`,{type:`boolean`,description:`The ai_search_options.retrieval.return_on_failure field`,default:!0}).option(`messages`,{type:`string`,description:"OpenAI-compatible message array. For multimodal queries, set the last user message's `content` to an array of typed parts: `[{type:'text', text:'…'}, {type:'image_url', image_url:{url:'…'}}]`. Image inputs require the RAG's embedding_model to declare 'image' in supported_modalities. Provide as a JSON array of objects or @path/to/file.json."}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const fe={command:`multi-search <name> <query>`,describe:`Performs a semantic search query against multiple AI Search instances in parallel, merging the retrieved results into a single ranked response.`,builder:de,handler:async r=>c({command:`ai-search multi-search`,classification:{safeFlags:[`ai-search-options-cache-cache-threshold`,`ai-search-options-cache-enabled`,`ai-search-options-query-rewrite-enabled`,`ai-search-options-reranking-enabled`,`ai-search-options-retrieval-fusion-method`,`ai-search-options-retrieval-keyword-match-mode`,`ai-search-options-retrieval-retrieval-type`,`ai-search-options-retrieval-return-on-failure`,`dry-run`]}},r,async()=>{if(r.dryRun){o({command:`cf ai-search multi-search`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/search`,pathParams:{name:String(r.name??``)},bodyKind:`json`,body:r.body===void 0?d({ai_search_options:{cache:{cache_threshold:f(r[`ai-search-options-cache-cache-threshold`],`ai-search-options-cache-cache-threshold`,`text`),enabled:r[`ai-search-options-cache-enabled`]},instance_ids:r[`ai-search-options-instance-ids`],query_rewrite:{enabled:r[`ai-search-options-query-rewrite-enabled`],model:f(r[`ai-search-options-query-rewrite-model`],`ai-search-options-query-rewrite-model`,`text`),rewrite_prompt:f(r[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:r[`ai-search-options-reranking-enabled`],match_threshold:r[`ai-search-options-reranking-match-threshold`],model:f(r[`ai-search-options-reranking-model`],`ai-search-options-reranking-model`,`text`)},retrieval:{context_expansion:r[`ai-search-options-retrieval-context-expansion`],fusion_method:f(r[`ai-search-options-retrieval-fusion-method`],`ai-search-options-retrieval-fusion-method`,`text`),keyword_match_mode:f(r[`ai-search-options-retrieval-keyword-match-mode`],`ai-search-options-retrieval-keyword-match-mode`,`text`),match_threshold:r[`ai-search-options-retrieval-match-threshold`],max_num_results:r[`ai-search-options-retrieval-max-num-results`],retrieval_type:f(r[`ai-search-options-retrieval-retrieval-type`],`ai-search-options-retrieval-retrieval-type`,`text`),return_on_failure:r[`ai-search-options-retrieval-return-on-failure`]}},messages:u(r.messages,`messages`),query:r.query}):l(r.body)});return}let c=await i(r),p=r.local?e:await t();if(r.accountId=p,r.body){let e=l(r.body);a(await s(`Creating`,async()=>c.aiSearch.multiSearch({...e,account_id:p,name:r.name})),{successLabel:`Created`});return}if(r[`ai-search-options-instance-ids`]===void 0)throw Error(`--ai-search-options-instance-ids is required (or pass --body with this field set).`);let m=d({ai_search_options:{cache:{cache_threshold:f(r[`ai-search-options-cache-cache-threshold`],`ai-search-options-cache-cache-threshold`,`text`),enabled:r[`ai-search-options-cache-enabled`]},instance_ids:r[`ai-search-options-instance-ids`],query_rewrite:{enabled:r[`ai-search-options-query-rewrite-enabled`],model:f(r[`ai-search-options-query-rewrite-model`],`ai-search-options-query-rewrite-model`,`text`),rewrite_prompt:f(r[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:r[`ai-search-options-reranking-enabled`],match_threshold:r[`ai-search-options-reranking-match-threshold`],model:f(r[`ai-search-options-reranking-model`],`ai-search-options-reranking-model`,`text`)},retrieval:{context_expansion:r[`ai-search-options-retrieval-context-expansion`],fusion_method:f(r[`ai-search-options-retrieval-fusion-method`],`ai-search-options-retrieval-fusion-method`,`text`),keyword_match_mode:f(r[`ai-search-options-retrieval-keyword-match-mode`],`ai-search-options-retrieval-keyword-match-mode`,`text`),match_threshold:r[`ai-search-options-retrieval-match-threshold`],max_num_results:r[`ai-search-options-retrieval-max-num-results`],retrieval_type:f(r[`ai-search-options-retrieval-retrieval-type`],`ai-search-options-retrieval-retrieval-type`,`text`),return_on_failure:r[`ai-search-options-retrieval-return-on-failure`]}},messages:u(r.messages,`messages`),query:r.query});a(await s(`Creating`,async()=>c.aiSearch.multiSearch({...m,account_id:p,name:r.name})),{successLabel:`Created`})})};function pe(e){return e.positional(`namespace`,{type:`string`,description:`Name for the new namespace.`,demandOption:!0}).option(`description`,{type:`string`,description:`Optional description for the namespace. Max 256 characters.`}).option(`public-endpoint-params-authorized-hosts`,{type:`string`,array:!0,description:`The public_endpoint_params.authorized_hosts field`}).option(`public-endpoint-params-chat-completions-endpoint-disabled`,{type:`boolean`,description:`Disable chat completions endpoint for this public endpoint`}).option(`public-endpoint-params-custom-domains`,{type:`string`,array:!0,description:`Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged).`}).option(`public-endpoint-params-default-domain-enabled`,{type:`boolean`,description:`When false, the instance is reachable only via a registered custom domain and the default <public_endpoint_id>.search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true.`}).option(`public-endpoint-params-enabled`,{type:`boolean`,description:`The public_endpoint_params.enabled field`}).option(`public-endpoint-params-instances-allowed`,{type:`string`,array:!0,description:`Instance IDs exposed through the namespace public endpoint. Empty means nothing is searchable. Every ID must be an existing instance in this namespace, and the list cannot exceed the account's multi-instance search limit.`}).option(`public-endpoint-params-mcp-description`,{type:`string`,description:`The public_endpoint_params.mcp.description field`}).option(`public-endpoint-params-mcp-disabled`,{type:`boolean`,description:`Disable MCP endpoint for this public endpoint`}).option(`public-endpoint-params-rate-limit-period-ms`,{type:`number`,description:`The public_endpoint_params.rate_limit.period_ms field`}).option(`public-endpoint-params-rate-limit-requests`,{type:`number`,description:`The public_endpoint_params.rate_limit.requests field`}).option(`public-endpoint-params-rate-limit-technique`,{type:`string`,description:`The public_endpoint_params.rate_limit.technique field`,choices:[`fixed`,`sliding`]}).option(`public-endpoint-params-search-endpoint-disabled`,{type:`boolean`,description:`Disable search endpoint for this public endpoint`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const me={command:`create <namespace>`,describe:`Create a namespace for organizing AI Search instances.`,builder:pe,handler:async r=>c({command:`ai-search namespace create`,classification:{safeFlags:[`public-endpoint-params-chat-completions-endpoint-disabled`,`public-endpoint-params-default-domain-enabled`,`public-endpoint-params-enabled`,`public-endpoint-params-mcp-disabled`,`public-endpoint-params-rate-limit-technique`,`public-endpoint-params-search-endpoint-disabled`,`dry-run`]}},r,async()=>{if(r.dryRun){o({command:`cf ai-search namespace create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces`,pathParams:{},bodyKind:`json`,body:r.body===void 0?d({description:f(r.description,`description`,`text`),public_endpoint_params:{authorized_hosts:r[`public-endpoint-params-authorized-hosts`],chat_completions_endpoint:{disabled:r[`public-endpoint-params-chat-completions-endpoint-disabled`]},custom_domains:r[`public-endpoint-params-custom-domains`],default_domain_enabled:r[`public-endpoint-params-default-domain-enabled`],enabled:r[`public-endpoint-params-enabled`],instances_allowed:r[`public-endpoint-params-instances-allowed`],mcp:{description:f(r[`public-endpoint-params-mcp-description`],`public-endpoint-params-mcp-description`,`text`),disabled:r[`public-endpoint-params-mcp-disabled`]},rate_limit:{period_ms:r[`public-endpoint-params-rate-limit-period-ms`],requests:r[`public-endpoint-params-rate-limit-requests`],technique:f(r[`public-endpoint-params-rate-limit-technique`],`public-endpoint-params-rate-limit-technique`,`text`)},search_endpoint:{disabled:r[`public-endpoint-params-search-endpoint-disabled`]}},name:r.namespace}):l(r.body)});return}let c=await i(r),u=r.local?e:await t();if(r.accountId=u,r.body){let e=l(r.body);a(await s(`Creating`,async()=>c.aiSearch.namespace.create({...e,account_id:u})),{successLabel:`Created`});return}let p=d({description:f(r.description,`description`,`text`),public_endpoint_params:{authorized_hosts:r[`public-endpoint-params-authorized-hosts`],chat_completions_endpoint:{disabled:r[`public-endpoint-params-chat-completions-endpoint-disabled`]},custom_domains:r[`public-endpoint-params-custom-domains`],default_domain_enabled:r[`public-endpoint-params-default-domain-enabled`],enabled:r[`public-endpoint-params-enabled`],instances_allowed:r[`public-endpoint-params-instances-allowed`],mcp:{description:f(r[`public-endpoint-params-mcp-description`],`public-endpoint-params-mcp-description`,`text`),disabled:r[`public-endpoint-params-mcp-disabled`]},rate_limit:{period_ms:r[`public-endpoint-params-rate-limit-period-ms`],requests:r[`public-endpoint-params-rate-limit-requests`],technique:f(r[`public-endpoint-params-rate-limit-technique`],`public-endpoint-params-rate-limit-technique`,`text`)},search_endpoint:{disabled:r[`public-endpoint-params-search-endpoint-disabled`]}},name:r.namespace});a(await s(`Creating`,async()=>c.aiSearch.namespace.create({...p,account_id:u})),{successLabel:`Created`})})};function he(e){return e.positional(`name`,{type:`string`,description:`Namespace to delete.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const ge={command:`delete <name>`,describe:`Permanently delete a namespace. The namespace must be empty (no instances), and the default namespace cannot be deleted.`,builder:he,handler:async r=>c({command:`ai-search namespace delete`,classification:{safeFlags:[`dry-run`,`force`],shortFlagAliases:{f:{canonical:`force`,type:`boolean`}}}},r,async()=>{if(r.dryRun){o({command:`cf ai-search namespace delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}`,pathParams:{name:String(r.name??``)},bodyKind:`none`});return}let c=await i(r),l=r.local?e:await t();if(r.accountId=l,!await g({force:!!r.force,message:`This operation permanently deletes the namespace.`})){process.stderr.write(`Aborted.
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
- import{h as e}from"./oauth-DH3kMXSs.mjs";import{r as t}from"./auth-tvDdC1J-.mjs";import{t as n}from"./output-COcSQsfn.mjs";import{t as r}from"./dry-run-DiVy1lVo.mjs";import{t as i}from"./progress-V6SZV3Ux.mjs";import{t as a}from"./run-CRfinkSe.mjs";import"./telemetry-Ch1vCICm.mjs";import{n as o,r as s,t as c}from"./body-parser-DIlfApuJ.mjs";import{n as l}from"./prompt-DjRTpML4.mjs";function u(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const d={command:`get`,describe:"Get the custom topic categories defined for the zone. While AI Security for Apps is enabled, it scores every incoming prompt against these topics and writes the scores to the `cf.llm.prompt.custom_topic_categories` field, keyed by topic label. Topics can be configured while the detection is disabled, but no prompt is scored until you enable it.",builder:u,handler:async o=>a({command:`ai-security custom-topics get`,classification:{safeFlags:[`dry-run`]}},o,async()=>{if(o.dryRun){r({command:`cf ai-security custom-topics get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${o.zone??o.zoneId??`<zone>`}/ai-security/custom-topics`,pathParams:{"zone-id":String(o.zone??o[`zone-id`]??``)},bodyKind:`none`});return}let a=await t(o),s=await e({zone:o.zone},a,{quiet:o.quiet});o.zoneId=s,n(await i(`Loading`,async()=>a.aiSecurity.customTopics.get({zone_id:s})),{successLabel:`Loaded`})})};function f(e){return e.option(`topics`,{type:`string`,description:`Custom topic categories for AI Security for Apps content detection. Provide as a JSON array of objects or @path/to/file.json.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const p={command:`update`,describe:"Update the custom topic list of the zone, overwriting it entirely with the topics in the request, so include every topic you want to keep. Changes can take up to a minute to propagate. Each entry has a `label`, used to reference the topic in rule expressions and analytics, and a `topic` description, which the classifier scores prompts against while AI Security for Apps is enabled. The following rules apply: - A zone can hold at most 20 topics. - `label` must be 2–20 characters, using only lowercase letters (a–z), digits (0–9), and hyphens. - `topic` must be 2–50 printable ASCII characters. - Labels must be unique within the zone, and so must topic descriptions.",builder:f,handler:async u=>a({command:`ai-security custom-topics update`,classification:{safeFlags:[`dry-run`,`force`],shortFlagAliases:{f:{canonical:`force`,type:`boolean`}}}},u,async()=>{if(u.dryRun){r({command:`cf ai-security custom-topics update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${u.zone??u.zoneId??`<zone>`}/ai-security/custom-topics`,pathParams:{"zone-id":String(u.zone??u[`zone-id`]??``)},bodyKind:`json`,body:u.body===void 0?c({topics:s(u.topics,`topics`)}):o(u.body)});return}let a=await t(u),d=await e({zone:u.zone},a,{quiet:u.quiet});if(u.zoneId=d,!await l({force:!!u.force,message:`This operation overwrites the AI Security for Apps custom topics for a zone.`})){process.stderr.write(`Aborted.
2
+ import{h as e}from"./oauth-BdVr2hJp.mjs";import{r as t}from"./auth-DWxtJ918.mjs";import{t as n}from"./output-Z2lQmPUW.mjs";import{t as r}from"./dry-run-YSQndLvt.mjs";import{t as i}from"./progress-a5IKeKni.mjs";import{t as a}from"./run-BS8otL3u.mjs";import"./telemetry-n3NJourL.mjs";import{n as o,r as s,t as c}from"./body-parser-Cmw7PZ7a.mjs";import{n as l}from"./prompt-BP8XrQSj.mjs";function u(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const d={command:`get`,describe:"Get the custom topic categories defined for the zone. While AI Security for Apps is enabled, it scores every incoming prompt against these topics and writes the scores to the `cf.llm.prompt.custom_topic_categories` field, keyed by topic label. Topics can be configured while the detection is disabled, but no prompt is scored until you enable it.",builder:u,handler:async o=>a({command:`ai-security custom-topics get`,classification:{safeFlags:[`dry-run`]}},o,async()=>{if(o.dryRun){r({command:`cf ai-security custom-topics get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${o.zone??o.zoneId??`<zone>`}/ai-security/custom-topics`,pathParams:{"zone-id":String(o.zone??o[`zone-id`]??``)},bodyKind:`none`});return}let a=await t(o),s=await e({zone:o.zone},a,{quiet:o.quiet});o.zoneId=s,n(await i(`Loading`,async()=>a.aiSecurity.customTopics.get({zone_id:s})),{successLabel:`Loaded`})})};function f(e){return e.option(`topics`,{type:`string`,description:`Custom topic categories for AI Security for Apps content detection. Provide as a JSON array of objects or @path/to/file.json.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const p={command:`update`,describe:"Update the custom topic list of the zone, overwriting it entirely with the topics in the request, so include every topic you want to keep. Changes can take up to a minute to propagate. Each entry has a `label`, used to reference the topic in rule expressions and analytics, and a `topic` description, which the classifier scores prompts against while AI Security for Apps is enabled. The following rules apply: - A zone can hold at most 20 topics. - `label` must be 2–20 characters, using only lowercase letters (a–z), digits (0–9), and hyphens. - `topic` must be 2–50 printable ASCII characters. - Labels must be unique within the zone, and so must topic descriptions.",builder:f,handler:async u=>a({command:`ai-security custom-topics update`,classification:{safeFlags:[`dry-run`,`force`],shortFlagAliases:{f:{canonical:`force`,type:`boolean`}}}},u,async()=>{if(u.dryRun){r({command:`cf ai-security custom-topics update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${u.zone??u.zoneId??`<zone>`}/ai-security/custom-topics`,pathParams:{"zone-id":String(u.zone??u[`zone-id`]??``)},bodyKind:`json`,body:u.body===void 0?c({topics:s(u.topics,`topics`)}):o(u.body)});return}let a=await t(u),d=await e({zone:u.zone},a,{quiet:u.quiet});if(u.zoneId=d,!await l({force:!!u.force,message:`This operation overwrites the AI Security for Apps custom topics for a zone.`})){process.stderr.write(`Aborted.
3
3
  `);return}if(u.body){let e=o(u.body);n(await i(`Deleting`,async()=>a.aiSecurity.customTopics.update({body:e,zone_id:d})),{successLabel:`Deleted`});return}let f=c({topics:s(u.topics,`topics`)});n(await i(`Deleting`,async()=>a.aiSecurity.customTopics.update({body:f,zone_id:d})),{successLabel:`Deleted`})})},m={command:`custom-topics`,describe:`Organization-specific topic categories used by AI Security for Apps content detection`,builder:e=>e.command(d).command(p).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function h(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const g={command:`get`,describe:"Get the current AI Security for Apps status for the zone. While enabled, Cloudflare scans prompts sent to endpoints labeled `cf-llm` for personally identifiable information, unsafe topics, and prompt injection attempts.",builder:h,handler:async o=>a({command:`ai-security get`,classification:{safeFlags:[`dry-run`]}},o,async()=>{if(o.dryRun){r({command:`cf ai-security get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${o.zone??o.zoneId??`<zone>`}/ai-security/settings`,pathParams:{"zone-id":String(o.zone??o[`zone-id`]??``)},bodyKind:`none`});return}let a=await t(o),s=await e({zone:o.zone},a,{quiet:o.quiet});o.zoneId=s,n(await i(`Loading`,async()=>a.aiSecurity.get({zone_id:s})),{successLabel:`Loaded`})})};function _(e){return e.option(`enabled`,{type:`boolean`,description:`Whether AI Security for Apps is enabled on the zone.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1}).option(`body`,{type:`string`,description:`AI Security for Apps enablement status for a zone.`})}const v={command:`update`,describe:"Update the AI Security for Apps status for the zone, enabling or disabling the detection. The detection results are exposed as `cf.llm.prompt.*` fields for use in custom rules and rate limiting rules; changes can take up to a minute to propagate.",builder:_,handler:async s=>a({command:`ai-security update`,classification:{safeFlags:[`enabled`,`dry-run`,`force`],shortFlagAliases:{f:{canonical:`force`,type:`boolean`}}}},s,async()=>{if(s.dryRun){r({command:`cf ai-security update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${s.zone??s.zoneId??`<zone>`}/ai-security/settings`,pathParams:{"zone-id":String(s.zone??s[`zone-id`]??``)},bodyKind:`json`,body:s.body===void 0?c({enabled:s.enabled}):o(s.body)});return}let a=await t(s),u=await e({zone:s.zone},a,{quiet:s.quiet});if(s.zoneId=u,!await l({force:!!s.force,message:`This operation toggles AI Security for Apps for a zone.`})){process.stderr.write(`Aborted.
4
4
  `);return}if(s.body){let e=o(s.body);n(await i(`Deleting`,async()=>a.aiSecurity.update({body:e,zone_id:u})),{successLabel:`Deleted`});return}let d=c({enabled:s.enabled});n(await i(`Deleting`,async()=>a.aiSecurity.update({body:d,zone_id:u})),{successLabel:`Deleted`})})},y={command:`ai-security`,describe:`Detect prompt injection, PII, and unsafe topics in traffic to your AI applications`,builder:e=>e.command(g).command(v).command(m).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{y as default};