cf 0.6.0 → 0.7.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 (299) hide show
  1. package/dist/_meta/agent-context.json +78 -41
  2. package/dist/_meta/commands.json +19888 -21071
  3. package/dist/_meta/schemas.json +14305 -15328
  4. package/dist/abuse-reports-BsF9JZPW.mjs +8 -0
  5. package/dist/account-D8mYiWxQ.mjs +2 -0
  6. package/dist/accounts-CJci1Oez.mjs +23 -0
  7. package/dist/acm-CmCd985Q.mjs +3 -0
  8. package/dist/addressing-R7p6TRBe.mjs +12 -0
  9. package/dist/{agent-context-CKb6w43K.mjs → agent-context-Bzl5PGW-.mjs} +1 -1
  10. package/dist/ai-BzJg0RIX.mjs +3 -0
  11. package/dist/ai-audit-B0vJNOZG.mjs +2 -0
  12. package/dist/ai-gateway-D3vJR3My.mjs +10 -0
  13. package/dist/ai-search-CNg7W7U4.mjs +7 -0
  14. package/dist/alerting-_sdM0B0S.mjs +6 -0
  15. package/dist/alerts-dpT6Qsdu.mjs +2 -0
  16. package/dist/{analytics-CwFrx-Dr.mjs → analytics-BFBJhDrP.mjs} +1 -1
  17. package/dist/analytics_engine-CWhFvyeK.mjs +2 -0
  18. package/dist/{api-gateway-D9PMVVqL.mjs → api-gateway-D4AIEtUq.mjs} +10 -10
  19. package/dist/argo-Bjk6nFfs.mjs +2 -0
  20. package/dist/artifacts-Ba4b3iOa.mjs +4 -0
  21. package/dist/{audit-logs-BvQ9uwuy.mjs → audit-logs-BE0T5All.mjs} +1 -1
  22. package/dist/{auth-DX9KnJ0P.mjs → auth-CZ0E51rF.mjs} +3 -3
  23. package/dist/auth-D_zyQbDR.mjs +5 -0
  24. package/dist/autorag-Cnpp8PAG.mjs +2 -0
  25. package/dist/billing-Dz6Zj8Eq.mjs +2 -0
  26. package/dist/bot-management-pFwIbFi-.mjs +5 -0
  27. package/dist/botnet-feed-BY9uGChY.mjs +3 -0
  28. package/dist/brand-protection-DkPAk2Cz.mjs +3 -0
  29. package/dist/brands-CGpk9nZB.mjs +2 -0
  30. package/dist/browser-extension-D9P6Yv8i.mjs +3 -0
  31. package/dist/browser-run-DhHtz4y3.mjs +4 -0
  32. package/dist/build-CWuStmDi.mjs +2 -0
  33. package/dist/{cache-CeN5t6_W.mjs → cache-DVhkiIGK.mjs} +4 -4
  34. package/dist/calls-95zjvIcO.mjs +4 -0
  35. package/dist/certificate-authorities-BowBqbVq.mjs +2 -0
  36. package/dist/cf-BLT7uKJF.mjs +18 -0
  37. package/dist/chunk-2SIGYDH3-qXx_zE6v.mjs +397 -0
  38. package/dist/clear-DXx8WBAN.mjs +2 -0
  39. package/dist/client-certificates-D6mE4vJu.mjs +3 -0
  40. package/dist/cloud-connector-DmwsjeFN.mjs +2 -0
  41. package/dist/cloudforce-one-CG3TT7IN.mjs +23 -0
  42. package/dist/{completions-Bvzav4Mj.mjs → completions-DMc_PlIw.mjs} +2 -2
  43. package/dist/connectivity-DJkE3crz.mjs +3 -0
  44. package/dist/connector-interrupts-DTgQ7onV.mjs +2 -0
  45. package/dist/connector-telemetry-events-D0rTHDou.mjs +2 -0
  46. package/dist/connector-telemetry-snapshots--0QmD3z6.mjs +2 -0
  47. package/dist/connectors-zWaZTi2A.mjs +3 -0
  48. package/dist/content-scanning-CGvGf04y.mjs +4 -0
  49. package/dist/ct-alerting-ebSPSWNC.mjs +3 -0
  50. package/dist/{custom-certificates-CfRj7QZb.mjs → custom-certificates-CWUrPYLP.mjs} +4 -4
  51. package/dist/custom-csrs-CRtdrF9R.mjs +4 -0
  52. package/dist/{custom-hostnames-CcK7_17e.mjs → custom-hostnames-CVQSksqq.mjs} +4 -4
  53. package/dist/custom-nameservers-BRwbIdsX.mjs +3 -0
  54. package/dist/custom-pages-Ci8sTQX7.mjs +4 -0
  55. package/dist/d1-78Ym1P6D.mjs +4 -0
  56. package/dist/data-security-zmFoMwRU.mjs +6 -0
  57. package/dist/{dcv-delegation-BYsNl3qc.mjs → dcv-delegation-Dd4FZ2IG.mjs} +1 -1
  58. package/dist/{deploy-BzlPv3ro.mjs → deploy-CVvkZFjR.mjs} +1 -1
  59. package/dist/{dev-IOg-_s5_.mjs → dev-DSslyDXx.mjs} +1 -1
  60. package/dist/diagnostics-B8Ev5m_o.mjs +3 -0
  61. package/dist/dispatch-namespaces-Dm5vGeEP.mjs +7 -0
  62. package/dist/dist-BH-4NQOV.mjs +134 -0
  63. package/dist/dns-D7VAaCyO.mjs +29 -0
  64. package/dist/dns-firewall-ByLCsf0q.mjs +57 -0
  65. package/dist/domain-info-CRvKc2Lg.mjs +2 -0
  66. package/dist/durable-objects-BIpvyu9m.mjs +2 -0
  67. package/dist/email-auth-Cx--s8W4.mjs +2 -0
  68. package/dist/email-routing-CiDbivcN.mjs +10 -0
  69. package/dist/email-security-BYeAuSc6.mjs +12 -0
  70. package/dist/email-sending-Dg2rSmHH.mjs +4 -0
  71. package/dist/{filters-DKs-wEzt.mjs → filters-DZ8YnQ90.mjs} +3 -3
  72. package/dist/firewall-DEd1hs_I.mjs +11 -0
  73. package/dist/flagship-DVw7xGoP.mjs +4 -0
  74. package/dist/{fraud-D8WmLKyH.mjs → fraud-BbGS3FZs.mjs} +2 -2
  75. package/dist/google-tag-gateway-CBnRGYQR.mjs +2 -0
  76. package/dist/{healthchecks-BBtW8vRh.mjs → healthchecks-Da9N3ix4.mjs} +3 -3
  77. package/dist/{hostnames-Bh2IFxIw.mjs → hostnames-mimZu2tB.mjs} +2 -2
  78. package/dist/hyperdrive-BNdvxOos.mjs +21 -0
  79. package/dist/iam-DGQ-OgRl.mjs +6 -0
  80. package/dist/images-CI6Iy9ho.mjs +7 -0
  81. package/dist/index.mjs +1 -1
  82. package/dist/intel-BDB-aRtU.mjs +3 -0
  83. package/dist/internal-Czlp5Ekb.mjs +2 -0
  84. package/dist/{ips-BE7JbAnc.mjs → ips-B9UuPvsY.mjs} +1 -1
  85. package/dist/keyless-certificates-Ua9uJgPt.mjs +3 -0
  86. package/dist/kv-BHerx4dZ.mjs +5 -0
  87. package/dist/leaked-credential-checks-B8Vunj9h.mjs +3 -0
  88. package/dist/live-Ce7dZW7p.mjs +2 -0
  89. package/dist/load-balancers-DSjS5WKw.mjs +6 -0
  90. package/dist/logexplorer-DBIfTlRP.mjs +24 -0
  91. package/dist/logo-matches-C00iGpzW.mjs +2 -0
  92. package/dist/logos-CJLhx1go.mjs +3 -0
  93. package/dist/logpush-Cr1U-eK-.mjs +5 -0
  94. package/dist/logs-DMvtchc6.mjs +3 -0
  95. package/dist/magic-cloud-networking-FQfO8QWH.mjs +5 -0
  96. package/dist/magic-network-monitoring-CDd70fJQ.mjs +4 -0
  97. package/dist/magic-transit-DiKiPUax.mjs +110 -0
  98. package/dist/managed-transforms-fPVUTrAv.mjs +3 -0
  99. package/dist/matches-B0yHbQ2I.mjs +2 -0
  100. package/dist/moq-UgBawOXe.mjs +13 -0
  101. package/dist/mtls-certificates-xKUbC5EL.mjs +3 -0
  102. package/dist/network-interconnects-BJzOE2ny.mjs +41 -0
  103. package/dist/oauth-DBJ5GSFk.mjs +40 -0
  104. package/dist/observability-B-1y36QS.mjs +4 -0
  105. package/dist/organization-Dq3PClZ7.mjs +41 -0
  106. package/dist/organizations-AhsQkHyX.mjs +2 -0
  107. package/dist/origin-ca-certificates-CRgF0UyU.mjs +3 -0
  108. package/dist/origin-post-quantum-encryption-BXTx7DPa.mjs +2 -0
  109. package/dist/{origin-tls-client-auth-B30_2_dO.mjs → origin-tls-client-auth-BDw5q-6G.mjs} +3 -3
  110. package/dist/{page-rules-zQJGmTCd.mjs → page-rules-DqYQ23eg.mjs} +5 -5
  111. package/dist/{page-shield-CxQk5k9X.mjs → page-shield-DKdlZOLO.mjs} +5 -5
  112. package/dist/pages-BsXF11Kv.mjs +11 -0
  113. package/dist/pay-per-crawl-BGAwuAP3.mjs +2 -0
  114. package/dist/pipelines-D_QhSnGW.mjs +6 -0
  115. package/dist/progress-O88q63Bk.mjs +2 -0
  116. package/dist/{prompt-q3B7sM2A.mjs → prompt-DTAWiEm2.mjs} +1 -1
  117. package/dist/queries-CAE95-OH.mjs +3 -0
  118. package/dist/queues-BBz35Mqd.mjs +6 -0
  119. package/dist/r2-Zp99S5xF.mjs +21 -0
  120. package/dist/r2-data-catalog-BeVLZwrE.mjs +16 -0
  121. package/dist/radar-Cij-XVQJ.mjs +2 -0
  122. package/dist/rate-limit-analytics-CGviSPnJ.mjs +2 -0
  123. package/dist/rate-limits-DSdToIWv.mjs +5 -0
  124. package/dist/raw-fetch-DgezeshQ.mjs +2 -0
  125. package/dist/ready-DMpJvyaz.mjs +2 -0
  126. package/dist/realtime-kit-9rJcapfM.mjs +18 -0
  127. package/dist/recent-submissions-LS5IM-bm.mjs +2 -0
  128. package/dist/refute-BGTpr5sy.mjs +2 -0
  129. package/dist/registrar-CXViZlah.mjs +83 -0
  130. package/dist/registrar-sandbox-CvQyjXLJ.mjs +83 -0
  131. package/dist/request-tracers-DATfBnE9.mjs +2 -0
  132. package/dist/{resolve-DGD57PFH.mjs → resolve-Bs2sMRYS.mjs} +1 -1
  133. package/dist/resource-sharing-Cmhn6ghR.mjs +3 -0
  134. package/dist/resource-tagging-BTn05AOj.mjs +16 -0
  135. package/dist/rules-ens3OHme.mjs +4 -0
  136. package/dist/rulesets-bkreZRao.mjs +8 -0
  137. package/dist/rum-CpgXFcwl.mjs +4 -0
  138. package/dist/scan-logo-DUDIZJ2A.mjs +2 -0
  139. package/dist/scan-page-BqoQTk3R.mjs +2 -0
  140. package/dist/{schema-D8o6HcCr.mjs → schema-DCF4yEp_.mjs} +1 -1
  141. package/dist/{schema-validation-BWNDnnIT.mjs → schema-validation-Ca6o94ts.mjs} +5 -5
  142. package/dist/scim-C4oT8TMc.mjs +4 -0
  143. package/dist/sdk-pQ5kaGUX.mjs +3 -0
  144. package/dist/search-C4T5riPh.mjs +2 -0
  145. package/dist/secrets-store-CWEuiDNo.mjs +7 -0
  146. package/dist/security-center-BOvm7xy6.mjs +2 -0
  147. package/dist/{security-txt-CVpmJo29.mjs → security-txt-BCAUBctN.mjs} +2 -2
  148. package/dist/session-B1ARgLG7.mjs +2 -0
  149. package/dist/share-DhmVspmL.mjs +5 -0
  150. package/dist/{shared-DQI8NGja.mjs → shared-Bod3-Exx.mjs} +332 -332
  151. package/dist/signed-url-DA509wgp.mjs +2 -0
  152. package/dist/{smart-shield-BreBC1Ap.mjs → smart-shield-DZm4fn6z.mjs} +2 -2
  153. package/dist/{snippets-BAJoWMSJ.mjs → snippets-oQ0u26-z.mjs} +3 -3
  154. package/dist/{spawn-pmGERpdB.mjs → spawn-ChG5Xi9Z.mjs} +1 -1
  155. package/dist/{spectrum-DnIRLY95.mjs → spectrum-Cnkee5Ww.mjs} +6 -6
  156. package/dist/speed-DqNnvLBD.mjs +4 -0
  157. package/dist/{src-BQ1dr9xR.mjs → src-By-zTCHz.mjs} +9 -9
  158. package/dist/ssl-tS3CYZsZ.mjs +15 -0
  159. package/dist/state-OsdDJvdj.mjs +2 -0
  160. package/dist/stream-Bud9Os5V.mjs +14 -0
  161. package/dist/submission-info-DfIXmu-M.mjs +2 -0
  162. package/dist/submit-BtP8she2.mjs +2 -0
  163. package/dist/tenant-CMwHa-tU.mjs +2 -0
  164. package/dist/{token-validation-DUvtXWur.mjs → token-validation-BYC7HTok.mjs} +5 -5
  165. package/dist/{tools-CQtA5-cr.mjs → tools-Dru4l8yh.mjs} +1 -1
  166. package/dist/total-queries-DdLBNJzd.mjs +2 -0
  167. package/dist/tracked-domains-BbaY-IuY.mjs +2 -0
  168. package/dist/turnstile-CP4nScaL.mjs +23 -0
  169. package/dist/{ui-BrNwNHX9.mjs → ui-BNoF0KpD.mjs} +2 -2
  170. package/dist/url-info-Chs9h7Y-.mjs +2 -0
  171. package/dist/url-normalization-XYxW5Gj0.mjs +3 -0
  172. package/dist/url-scanner-D4pYNlO-.mjs +2 -0
  173. package/dist/user-DtefniLc.mjs +11 -0
  174. package/dist/vectorize-BeAY2g-7.mjs +4 -0
  175. package/dist/verify-D7J3F_NZ.mjs +2 -0
  176. package/dist/{versions-NUXxCr0s.mjs → versions-dMW3bLVv.mjs} +1 -1
  177. package/dist/waiting-rooms-K78HeeTg.mjs +11 -0
  178. package/dist/{web3-n3GW50u-.mjs → web3-Dhw79l4S.mjs} +3 -3
  179. package/dist/workers-builds-CuOAB3u4.mjs +7 -0
  180. package/dist/workers-l3zMNOU6.mjs +20 -0
  181. package/dist/workflows-rb7RYBKP.mjs +6 -0
  182. package/dist/{zaraz-9l7KuLqh.mjs → zaraz-CHecMYuo.mjs} +1 -1
  183. package/dist/zero-trust-DAZoa-Aj.mjs +117 -0
  184. package/dist/zone-BnnqJwW-.mjs +2 -0
  185. package/dist/zones-DpI2YikF.mjs +21 -0
  186. package/package.json +1 -1
  187. package/dist/abuse-reports-DUs4SKVx.mjs +0 -8
  188. package/dist/accounts-BIY8wNGA.mjs +0 -22
  189. package/dist/acm-SqcV8o5o.mjs +0 -3
  190. package/dist/addressing-CygRm0pN.mjs +0 -12
  191. package/dist/ai-BAmEAjN3.mjs +0 -2
  192. package/dist/ai-gateway-BENwPvvB.mjs +0 -8
  193. package/dist/ai-search-Bv_Whw3E.mjs +0 -7
  194. package/dist/ai_gateway-C6WP9oBH.mjs +0 -4
  195. package/dist/alerting-D_qWrsoY.mjs +0 -6
  196. package/dist/analytics_engine-BjV6XLyG.mjs +0 -2
  197. package/dist/argo-DwYGbyld.mjs +0 -2
  198. package/dist/artifacts-DKAjY_n4.mjs +0 -4
  199. package/dist/auth-TYwGydWg.mjs +0 -5
  200. package/dist/billing-CRTlRU88.mjs +0 -2
  201. package/dist/bot-management-DgW--8wM.mjs +0 -5
  202. package/dist/botnet-feed-CIX6ZORT.mjs +0 -3
  203. package/dist/brand-protection-ZikBtl0y.mjs +0 -3
  204. package/dist/browser-rendering-D_ZQVWn8.mjs +0 -4
  205. package/dist/build-Bgw8TV1p.mjs +0 -134
  206. package/dist/calls-Cv0ieVg4.mjs +0 -4
  207. package/dist/certificate-authorities-BzZnWCac.mjs +0 -2
  208. package/dist/client-certificates-BFuzeBrj.mjs +0 -3
  209. package/dist/cloud-connector-D5h8Dzzg.mjs +0 -2
  210. package/dist/cloudforce-one-aqDCIBMp.mjs +0 -21
  211. package/dist/config-B5k-XbwS.mjs +0 -2
  212. package/dist/connectivity-CjkXmEhO.mjs +0 -3
  213. package/dist/connector-interrupts-B7eSface.mjs +0 -2
  214. package/dist/connector-telemetry-events-F3Co8HUf.mjs +0 -2
  215. package/dist/connector-telemetry-snapshots-CQY8XMUg.mjs +0 -2
  216. package/dist/connectors-YYu_Vx3H.mjs +0 -3
  217. package/dist/content-scanning-BorfRGKT.mjs +0 -4
  218. package/dist/context-C-WbewL6.mjs +0 -2
  219. package/dist/custom-nameservers-BkKx0THn.mjs +0 -3
  220. package/dist/custom-pages-DamGVA75.mjs +0 -4
  221. package/dist/d1-sK0O5THv.mjs +0 -4
  222. package/dist/data-security-DsWpoWiS.mjs +0 -6
  223. package/dist/diagnostics-CH7T2WR3.mjs +0 -3
  224. package/dist/dispatch-namespaces-Bgj9XCRx.mjs +0 -7
  225. package/dist/dist-C6zxsVdY.mjs +0 -306
  226. package/dist/dns-firewall-VmQf3UVP.mjs +0 -57
  227. package/dist/dns-o7hUPMCG.mjs +0 -29
  228. package/dist/durable-objects-DgrTbvoF.mjs +0 -2
  229. package/dist/email-routing-owCvAEpf.mjs +0 -10
  230. package/dist/email-security-Dng3DVuf.mjs +0 -8
  231. package/dist/email-sending-bExMH4lu.mjs +0 -3
  232. package/dist/firewall-BLaTtX3r.mjs +0 -11
  233. package/dist/google-tag-gateway-DyCY43k0.mjs +0 -2
  234. package/dist/hyperdrive-DJm1eD-M.mjs +0 -18
  235. package/dist/iam-apCCcy7R.mjs +0 -6
  236. package/dist/images-Cxe45OHm.mjs +0 -7
  237. package/dist/intel-8V4h6H46.mjs +0 -3
  238. package/dist/keyless-certificates-CfJmXccT.mjs +0 -3
  239. package/dist/kv-Dz6then8.mjs +0 -5
  240. package/dist/leaked-credential-checks-BJ-zQMlx.mjs +0 -3
  241. package/dist/load-balancers-ilsGgudX.mjs +0 -6
  242. package/dist/logpush-BH14TtuA.mjs +0 -4
  243. package/dist/logs-B8-mkf_I.mjs +0 -3
  244. package/dist/magic-cloud-networking-DylCXoG4.mjs +0 -5
  245. package/dist/magic-network-monitoring-DnyrZy77.mjs +0 -4
  246. package/dist/magic-transit-B-kU5e3s.mjs +0 -89
  247. package/dist/managed-transforms-GC9Pq5dg.mjs +0 -3
  248. package/dist/mtls-certificates-BRlhWw_G.mjs +0 -3
  249. package/dist/network-interconnects-DuyoFD9_.mjs +0 -36
  250. package/dist/oauth-B5k80sip.mjs +0 -61
  251. package/dist/observability-9APhqFHo.mjs +0 -4
  252. package/dist/organizations-Dy3kiV_z.mjs +0 -41
  253. package/dist/origin-ca-certificates-2rwPoQdG.mjs +0 -3
  254. package/dist/origin-post-quantum-encryption-BnBLTvEO.mjs +0 -2
  255. package/dist/pages-5DKLs7CQ.mjs +0 -11
  256. package/dist/pipelines-DfGE44xo.mjs +0 -6
  257. package/dist/progress-CL8I-7YK.mjs +0 -2
  258. package/dist/queues-BoenUGIw.mjs +0 -6
  259. package/dist/r2-Cq_JCjK0.mjs +0 -21
  260. package/dist/r2-data-catalog-eLxltWdO.mjs +0 -14
  261. package/dist/radar-YNOCio6T.mjs +0 -2
  262. package/dist/rate-limits-CcAF3tMl.mjs +0 -5
  263. package/dist/raw-fetch-bIXC9D1m.mjs +0 -2
  264. package/dist/realtime-kit-4bCGviO5.mjs +0 -18
  265. package/dist/registrar-CfHlaOOf.mjs +0 -46
  266. package/dist/request-tracers-DlHawg5l.mjs +0 -2
  267. package/dist/resource-sharing-7FhuboJE.mjs +0 -5
  268. package/dist/resource-tagging-divcugVb.mjs +0 -16
  269. package/dist/rules-CAXkege8.mjs +0 -4
  270. package/dist/rulesets-CBsdc8IV.mjs +0 -8
  271. package/dist/rum-D0hHPNl9.mjs +0 -4
  272. package/dist/scim-CWLli4fi.mjs +0 -3
  273. package/dist/sdk-DhIhH6GB.mjs +0 -5
  274. package/dist/secrets-store-B7_HkE8I.mjs +0 -25
  275. package/dist/security-center-BQT21oiM.mjs +0 -2
  276. package/dist/session-B8r8LNQN.mjs +0 -93
  277. package/dist/speed-UYEVue28.mjs +0 -4
  278. package/dist/ssl-D3Pixs8M.mjs +0 -15
  279. package/dist/stream-BUsuOfQh.mjs +0 -14
  280. package/dist/tenants-BdWJTtcg.mjs +0 -2
  281. package/dist/turnstile-CAKVnS1L.mjs +0 -23
  282. package/dist/url-normalization-DA-RAxs4.mjs +0 -3
  283. package/dist/url-scanner-DmYu43f7.mjs +0 -2
  284. package/dist/user-Bah4wGGN.mjs +0 -10
  285. package/dist/vectorize-DhvVG2By.mjs +0 -4
  286. package/dist/waiting-rooms-DoOkT4Mu.mjs +0 -11
  287. package/dist/workers-D6IaQ_F0.mjs +0 -18
  288. package/dist/workers-builds-DYi0OMMU.mjs +0 -7
  289. package/dist/workflows-DrdXUQ2g.mjs +0 -4
  290. package/dist/zero-trust-D6V9GH2W.mjs +0 -118
  291. package/dist/zero_trust-BzXKAX_x.mjs +0 -3
  292. package/dist/zones-0MTkuaFk.mjs +0 -21
  293. /package/dist/{body-parser-DWSy7uZ8.mjs → body-parser-BO6mfo_W.mjs} +0 -0
  294. /package/dist/{cli-types-DGgEbf8K.mjs → cli-types-CFw6Xygp.mjs} +0 -0
  295. /package/dist/{input-validation-_fMCApaH.mjs → input-validation-BwUR9z8e.mjs} +0 -0
  296. /package/dist/{lib-4PQI6yRW.mjs → lib-Og5sB51C.mjs} +0 -0
  297. /package/dist/{local-CYc9q7l2.mjs → local-C6TLPAT6.mjs} +0 -0
  298. /package/dist/{metadata-MPDDi08e.mjs → metadata-Cnyws6iO.mjs} +0 -0
  299. /package/dist/{open-YWOUIZ5Y-3jqSKAB1.mjs → open-YWOUIZ5Y-CFRcYALi.mjs} +0 -0
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env node
2
- import{O as e,P as t}from"./oauth-B5k80sip.mjs";import{i as n,n as r}from"./auth-DX9KnJ0P.mjs";import{n as i,t as a}from"./body-parser-DWSy7uZ8.mjs";import{t as o}from"./output-B6fBFRqe.mjs";import{n as s,t as c}from"./progress-CL8I-7YK.mjs";import{n as l}from"./input-validation-_fMCApaH.mjs";import{t as u}from"./local-CYc9q7l2.mjs";import{r as d,t as f}from"./prompt-q3B7sM2A.mjs";import{t as p}from"./cli-types-DGgEbf8K.mjs";function m(e){return e.option(`authentication`,{type:`boolean`,description:`The authentication field`}).option(`cache-invalidate-on-update`,{type:`boolean`,description:`The cache_invalidate_on_update field`}).option(`cache-ttl`,{type:`number`,description:`The cache_ttl field`}).option(`collect-logs`,{type:`boolean`,description:`The collect_logs field`}).option(`id`,{type:`string`,description:`gateway id`}).option(`log-management`,{type:`number`,description:`The log_management field`}).option(`log-management-strategy`,{type:`string`,description:`The log_management_strategy field`,choices:[`STOP_INSERTING`,`DELETE_OLDEST`]}).option(`logpush`,{type:`boolean`,description:`The logpush field`}).option(`logpush-public-key`,{type:`string`,description:`The logpush_public_key field`}).option(`rate-limiting-interval`,{type:`number`,description:`The rate_limiting_interval field`}).option(`rate-limiting-limit`,{type:`number`,description:`The rate_limiting_limit field`}).option(`rate-limiting-technique`,{type:`string`,description:`The rate_limiting_technique field`,choices:[`fixed`,`sliding`]}).option(`retry-backoff`,{type:`string`,description:`Backoff strategy for retry delays`,choices:[`constant`,`linear`,`exponential`]}).option(`retry-delay`,{type:`number`,description:`Delay between retry attempts in milliseconds (0-5000)`}).option(`retry-max-attempts`,{type:`number`,description:`Maximum number of retry attempts for failed requests (1-5)`}).option(`workers-ai-billing-mode`,{type:`string`,description:`Controls how Workers AI inference calls routed through this gateway are billed. Only 'postpaid' is currently supported.`,choices:[`postpaid`],default:`postpaid`}).option(`zdr`,{type:`boolean`,description:`The zdr 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 ee={command:`create`,describe:`Creates a new AI Gateway.`,builder:m,handler:async n=>{if(n.dryRun){s({command:`cf ai-gateway create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/gateways`,pathParams:{},bodyKind:`json`,body:n.body===void 0?a({authentication:n.authentication,cache_invalidate_on_update:n[`cache-invalidate-on-update`],cache_ttl:n[`cache-ttl`],collect_logs:n[`collect-logs`],id:l(n.id,`id`,`text`),log_management:n[`log-management`],log_management_strategy:l(n[`log-management-strategy`],`log-management-strategy`,`text`),logpush:n.logpush,logpush_public_key:l(n[`logpush-public-key`],`logpush-public-key`,`text`),rate_limiting_interval:n[`rate-limiting-interval`],rate_limiting_limit:n[`rate-limiting-limit`],rate_limiting_technique:l(n[`rate-limiting-technique`],`rate-limiting-technique`,`text`),retry_backoff:l(n[`retry-backoff`],`retry-backoff`,`text`),retry_delay:n[`retry-delay`],retry_max_attempts:n[`retry-max-attempts`],workers_ai_billing_mode:l(n[`workers-ai-billing-mode`],`workers-ai-billing-mode`,`text`),zdr:n.zdr}):i(n.body)});return}let f=await r(n),p=n.local?u:await e();if(n.accountId=p,n.body){let e=i(n.body);o(await c(`Creating`,async()=>f.aiGateway.create({...e,account_id:p})),{successLabel:`Created`});return}if(n[`cache-invalidate-on-update`]===void 0)throw Error(`--cache-invalidate-on-update is required (or pass --body with this field set).`);if(n[`cache-ttl`]===void 0)throw Error(`--cache-ttl is required (or pass --body with this field set).`);if(n[`collect-logs`]===void 0)throw Error(`--collect-logs is required (or pass --body with this field set).`);if(n.id===void 0&&(n.id=await d(`id`,`gateway id`)),n[`rate-limiting-interval`]===void 0)throw Error(`--rate-limiting-interval is required (or pass --body with this field set).`);if(n[`rate-limiting-limit`]===void 0)throw Error(`--rate-limiting-limit is required (or pass --body with this field set).`);let m=a({authentication:n.authentication,cache_invalidate_on_update:n[`cache-invalidate-on-update`],cache_ttl:n[`cache-ttl`],collect_logs:n[`collect-logs`],id:l(n.id,`id`,`text`),log_management:n[`log-management`],log_management_strategy:l(n[`log-management-strategy`],`log-management-strategy`,`text`),logpush:n.logpush,logpush_public_key:l(n[`logpush-public-key`],`logpush-public-key`,`text`),rate_limiting_interval:n[`rate-limiting-interval`],rate_limiting_limit:n[`rate-limiting-limit`],rate_limiting_technique:l(n[`rate-limiting-technique`],`rate-limiting-technique`,`text`),retry_backoff:l(n[`retry-backoff`],`retry-backoff`,`text`),retry_delay:n[`retry-delay`],retry_max_attempts:n[`retry-max-attempts`],workers_ai_billing_mode:l(n[`workers-ai-billing-mode`],`workers-ai-billing-mode`,`text`),zdr:n.zdr});o(await c(`Creating`,async()=>f.aiGateway.create({...m,account_id:p})),{successLabel:`Created`})}};function te(e){return e.positional(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`enable`,{type:`boolean`,description:`The enable 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 h={command:`create <gateway-id>`,describe:`Creates a new AI Gateway.`,builder:te,handler:async n=>{if(n.dryRun){s({command:`cf ai-gateway datasets create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/gateways/${n[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(n[`gateway-id`]))}/datasets`,pathParams:{"gateway-id":String(n[`gateway-id`]??``)},bodyKind:`json`,body:n.body===void 0?a({enable:n.enable,name:l(n.name,`name`,`text`)}):i(n.body)});return}let f=await r(n),p=n.local?u:await e();if(n.accountId=p,n.body){let e=i(n.body);o(await c(`Creating`,async()=>f.aiGateway.datasets.create({...e,account_id:p,gateway_id:n[`gateway-id`]})),{successLabel:`Created`});return}if(n.enable===void 0)throw Error(`--enable is required (or pass --body with this field set).`);n.name===void 0&&(n.name=await d(`name`,`The name field`));let m=a({enable:n.enable,name:l(n.name,`name`,`text`)});o(await c(`Creating`,async()=>f.aiGateway.datasets.create({...m,account_id:p,gateway_id:n[`gateway-id`]})),{successLabel:`Created`})}};function g(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 _={command:`delete <id>`,describe:`Deletes an AI Gateway dataset.`,builder:g,handler:async n=>{if(n.dryRun){s({command:`cf ai-gateway datasets delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/gateways/${n[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(n[`gateway-id`]))}/datasets/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}`,pathParams:{"gateway-id":String(n[`gateway-id`]??``),id:String(n.id??``)},bodyKind:`none`});return}let i=await r(n),a=n.local?u:await e();if(n.accountId=a,!await f({force:!!n.force})){process.stderr.write(`Aborted.
3
- `);return}o(await c(`Deleting`,async()=>i.aiGateway.datasets.delete({account_id:a,gateway_id:n[`gateway-id`],id:n.id})),{successLabel:`Deleted`})}};function v(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 y={command:`get <id>`,describe:`Retrieves details for a specific AI Gateway dataset.`,builder:v,handler:async n=>{if(n.dryRun){s({command:`cf ai-gateway datasets get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/gateways/${n[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(n[`gateway-id`]))}/datasets/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}`,pathParams:{"gateway-id":String(n[`gateway-id`]??``),id:String(n.id??``)},bodyKind:`none`});return}let i=await r(n),a=n.local?u:await e();n.accountId=a,o(await c(`Loading`,async()=>i.aiGateway.datasets.get({account_id:a,gateway_id:n[`gateway-id`],id:n.id})),{successLabel:`Loaded`})}};function b(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 x={command:`list`,describe:`Lists all AI Gateway evaluator types configured for the account.`,builder:b,handler:async n=>{let i={page:n.page,per_page:n[`per-page`],name:n.name,enable:n.enable,search:n.search};if(n.dryRun){s({command:`cf ai-gateway datasets list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/gateways/${n[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(n[`gateway-id`]))}/datasets`,pathParams:{"gateway-id":String(n[`gateway-id`]??``)},query:i,bodyKind:`none`});return}let a=await r(n),l=n.local?u:await e();n.accountId=l,o(await c(`Loading`,async()=>a.aiGateway.datasets.list({account_id:l,gateway_id:n[`gateway-id`],...i})),{successLabel:`Loaded`})}};function S(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(`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 C={command:`update <id>`,describe:`Updates an existing AI Gateway dataset.`,builder:S,handler:async n=>{if(n.dryRun){s({command:`cf ai-gateway datasets update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/gateways/${n[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(n[`gateway-id`]))}/datasets/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}`,pathParams:{"gateway-id":String(n[`gateway-id`]??``),id:String(n.id??``)},bodyKind:`json`,body:n.body===void 0?a({enable:n.enable,name:l(n.name,`name`,`text`)}):i(n.body)});return}let f=await r(n),p=n.local?u:await e();if(n.accountId=p,n.body){let e=i(n.body);o(await c(`Updating`,async()=>f.aiGateway.datasets.update({...e,account_id:p,gateway_id:n[`gateway-id`],id:n.id})),{successLabel:`Updated`});return}if(n.enable===void 0)throw Error(`--enable is required (or pass --body with this field set).`);n.name===void 0&&(n.name=await d(`name`,`The name field`));let m=a({enable:n.enable,name:l(n.name,`name`,`text`)});o(await c(`Updating`,async()=>f.aiGateway.datasets.update({...m,account_id:p,gateway_id:n[`gateway-id`],id:n.id})),{successLabel:`Updated`})}},w={command:`datasets`,describe:`Curated collections of gateway logs used as inputs for evaluations and fine-tuning`,builder:e=>e.command(h).command(_).command(y).command(x).command(C).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function T(e){return e.positional(`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 E={command:`delete <id>`,describe:`Deletes an AI Gateway dataset.`,builder:T,handler:async n=>{if(n.dryRun){s({command:`cf ai-gateway delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/gateways/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}`,pathParams:{id:String(n.id??``)},bodyKind:`none`});return}let i=await r(n),a=n.local?u:await e();if(n.accountId=a,!await f({force:!!n.force})){process.stderr.write(`Aborted.
4
- `);return}o(await c(`Deleting`,async()=>i.aiGateway.delete({account_id:a,id:n.id})),{successLabel:`Deleted`})}};function D(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 O={command:`create-deployment <id>`,describe:`Create a new AI Gateway Dynamic Route Deployment.`,builder:D,handler:async n=>{if(n.dryRun){s({command:`cf ai-gateway dynamic-routing create-deployment`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/gateways/${n[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(n[`gateway-id`]))}/routes/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}/deployments`,pathParams:{"gateway-id":String(n[`gateway-id`]??``),id:String(n.id??``)},bodyKind:`json`,body:n.body===void 0?a({version_id:l(n[`version-id`],`version-id`,`text`)}):i(n.body)});return}let f=await r(n),p=n.local?u:await e();if(n.accountId=p,n.body){let e=i(n.body);o(await c(`Creating`,async()=>f.aiGateway.dynamicRouting.createDeployment({...e,account_id:p,gateway_id:n[`gateway-id`],id:n.id})),{successLabel:`Created`});return}n[`version-id`]===void 0&&(n[`version-id`]=await d(`version-id`,`The version_id field`));let m=a({version_id:l(n[`version-id`],`version-id`,`text`)});o(await c(`Creating`,async()=>f.aiGateway.dynamicRouting.createDeployment({...m,account_id:p,gateway_id:n[`gateway-id`],id:n.id})),{successLabel:`Created`})}};function k(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(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const A={command:`create-version <id>`,describe:`Create a new AI Gateway Dynamic Route Version.`,builder:k,handler:async a=>{if(a.dryRun){s({command:`cf ai-gateway dynamic-routing create-version`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/gateways/${a[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(a[`gateway-id`]))}/routes/${a.id==null?`<id>`:encodeURIComponent(String(a.id))}/versions`,pathParams:{"gateway-id":String(a[`gateway-id`]??``),id:String(a.id??``)},bodyKind:`json`,body:a.body===void 0?void 0:i(a.body)});return}let l=await r(a),d=a.local?u:await e();if(a.accountId=d,a.body){let e=i(a.body);o(await c(`Creating`,async()=>l.aiGateway.dynamicRouting.createVersion({...e,account_id:d,gateway_id:a[`gateway-id`],id:a.id})),{successLabel:`Created`});return}o(await c(`Creating`,async()=>n(l,`POST`,`/accounts/${d}/ai-gateway/gateways/${encodeURIComponent(String(a[`gateway-id`]))}/routes/${encodeURIComponent(String(a.id))}/versions`)),{successLabel:`Created`})}};function j(e){return e.positional(`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 M={command:`create <gateway-id>`,describe:`Create a new AI Gateway Dynamic Route.`,builder:j,handler:async n=>{if(n.dryRun){s({command:`cf ai-gateway dynamic-routing create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/gateways/${n[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(n[`gateway-id`]))}/routes`,pathParams:{"gateway-id":String(n[`gateway-id`]??``)},bodyKind:`json`,body:n.body===void 0?a({name:l(n.name,`name`,`text`)}):i(n.body)});return}let f=await r(n),p=n.local?u:await e();if(n.accountId=p,n.body){let e=i(n.body);o(await c(`Creating`,async()=>f.aiGateway.dynamicRouting.create({...e,account_id:p,gateway_id:n[`gateway-id`]})),{successLabel:`Created`});return}n.name===void 0&&(n.name=await d(`name`,`The name field`));let m=a({name:l(n.name,`name`,`text`)});o(await c(`Creating`,async()=>f.aiGateway.dynamicRouting.create({...m,account_id:p,gateway_id:n[`gateway-id`]})),{successLabel:`Created`})}};function N(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 P={command:`delete <id>`,describe:`Delete an AI Gateway Dynamic Route.`,builder:N,handler:async n=>{if(n.dryRun){s({command:`cf ai-gateway dynamic-routing delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/gateways/${n[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(n[`gateway-id`]))}/routes/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}`,pathParams:{"gateway-id":String(n[`gateway-id`]??``),id:String(n.id??``)},bodyKind:`none`});return}let i=await r(n),a=n.local?u:await e();if(n.accountId=a,!await f({force:!!n.force})){process.stderr.write(`Aborted.
5
- `);return}o(await c(`Deleting`,async()=>i.aiGateway.dynamicRouting.delete({account_id:a,gateway_id:n[`gateway-id`],id:n.id})),{successLabel:`Deleted`})}};function F(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 I={command:`get-version <version-id>`,describe:`Get an AI Gateway Dynamic Route Version.`,builder:F,handler:async n=>{if(n.dryRun){s({command:`cf ai-gateway dynamic-routing get-version`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/gateways/${n[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(n[`gateway-id`]))}/routes/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}/versions/${n[`version-id`]==null?`<version-id>`:encodeURIComponent(String(n[`version-id`]))}`,pathParams:{"gateway-id":String(n[`gateway-id`]??``),id:String(n.id??``),"version-id":String(n[`version-id`]??``)},bodyKind:`none`});return}let i=await r(n),a=n.local?u:await e();n.accountId=a,o(await c(`Loading`,async()=>i.aiGateway.dynamicRouting.getVersion({account_id:a,gateway_id:n[`gateway-id`],id:n.id,version_id:n[`version-id`]})),{successLabel:`Loaded`})}};function L(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 R={command:`get <id>`,describe:`Get an AI Gateway Dynamic Route.`,builder:L,handler:async n=>{if(n.dryRun){s({command:`cf ai-gateway dynamic-routing get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/gateways/${n[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(n[`gateway-id`]))}/routes/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}`,pathParams:{"gateway-id":String(n[`gateway-id`]??``),id:String(n.id??``)},bodyKind:`none`});return}let i=await r(n),a=n.local?u:await e();n.accountId=a,o(await c(`Loading`,async()=>i.aiGateway.dynamicRouting.get({account_id:a,gateway_id:n[`gateway-id`],id:n.id})),{successLabel:`Loaded`})}};function z(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 B={command:`list-deployments <id>`,describe:`List all AI Gateway Dynamic Route Deployments.`,builder:z,handler:async n=>{if(n.dryRun){s({command:`cf ai-gateway dynamic-routing list-deployments`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/gateways/${n[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(n[`gateway-id`]))}/routes/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}/deployments`,pathParams:{"gateway-id":String(n[`gateway-id`]??``),id:String(n.id??``)},bodyKind:`none`});return}let i=await r(n),a=n.local?u:await e();n.accountId=a,o(await c(`Loading`,async()=>i.aiGateway.dynamicRouting.listDeployments({account_id:a,gateway_id:n[`gateway-id`],id:n.id})),{successLabel:`Loaded`})}};function V(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 H={command:`list-versions <id>`,describe:`List all AI Gateway Dynamic Route Versions.`,builder:V,handler:async n=>{if(n.dryRun){s({command:`cf ai-gateway dynamic-routing list-versions`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/gateways/${n[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(n[`gateway-id`]))}/routes/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}/versions`,pathParams:{"gateway-id":String(n[`gateway-id`]??``),id:String(n.id??``)},bodyKind:`none`});return}let i=await r(n),a=n.local?u:await e();n.accountId=a,o(await c(`Loading`,async()=>i.aiGateway.dynamicRouting.listVersions({account_id:a,gateway_id:n[`gateway-id`],id:n.id})),{successLabel:`Loaded`})}};function U(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 W={command:`list`,describe:`List all AI Gateway Dynamic Routes.`,builder:U,handler:async n=>{let i={page:n.page,per_page:n[`per-page`]};if(n.dryRun){s({command:`cf ai-gateway dynamic-routing list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/gateways/${n[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(n[`gateway-id`]))}/routes`,pathParams:{"gateway-id":String(n[`gateway-id`]??``)},query:i,bodyKind:`none`});return}let a=await r(n),l=n.local?u:await e();n.accountId=l,o(await c(`Loading`,async()=>a.aiGateway.dynamicRouting.list({account_id:l,gateway_id:n[`gateway-id`],...i})),{successLabel:`Loaded`})}};function G(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 K={command:`update <id>`,describe:`Update an AI Gateway Dynamic Route.`,builder:G,handler:async n=>{if(n.dryRun){s({command:`cf ai-gateway dynamic-routing update`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/gateways/${n[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(n[`gateway-id`]))}/routes/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}`,pathParams:{"gateway-id":String(n[`gateway-id`]??``),id:String(n.id??``)},bodyKind:`json`,body:n.body===void 0?a({name:l(n.name,`name`,`text`)}):i(n.body)});return}let f=await r(n),p=n.local?u:await e();if(n.accountId=p,n.body){let e=i(n.body);o(await c(`Updating`,async()=>f.aiGateway.dynamicRouting.update({...e,account_id:p,gateway_id:n[`gateway-id`],id:n.id})),{successLabel:`Updated`});return}n.name===void 0&&(n.name=await d(`name`,`The name field`));let m=a({name:l(n.name,`name`,`text`)});o(await c(`Updating`,async()=>f.aiGateway.dynamicRouting.update({...m,account_id:p,gateway_id:n[`gateway-id`],id:n.id})),{successLabel:`Updated`})}},q={command:`dynamic-routing`,describe:`Operations for dynamic-routing`,builder:e=>e.command(M).command(O).command(A).command(P).command(R).command(I).command(W).command(B).command(H).command(K).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function J(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 Y={command:`list`,describe:`Lists all available evaluator types for scoring AI gateway responses.`,builder:p(J),handler:async n=>{let i={page:n.page,per_page:n[`per-page`],order_by:n[`order-by`],order_by_direction:n[`order-by-direction`]};if(n.dryRun){s({command:`cf ai-gateway evaluation-types list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/evaluation-types`,pathParams:{},query:i,bodyKind:`none`});return}let a=await r(n),l=n.local?u:await e();n.accountId=l,o(await c(`Loading`,async()=>a.aiGateway.evaluationTypes.list({account_id:l,...i})),{successLabel:`Loaded`})}},X={command:`evaluation-types`,describe:`Operations for evaluation-types`,builder:e=>e.command(Y).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Z(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 Q={command:`create <gateway-id>`,describe:`Creates a new AI Gateway.`,builder:Z,handler:async n=>{if(n.dryRun){s({command:`cf ai-gateway evaluations create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/gateways/${n[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(n[`gateway-id`]))}/evaluations`,pathParams:{"gateway-id":String(n[`gateway-id`]??``)},bodyKind:`json`,body:n.body===void 0?a({dataset_ids:n[`dataset-ids`],evaluation_type_ids:n[`evaluation-type-ids`],name:l(n.name,`name`,`text`)}):i(n.body)});return}let f=await r(n),p=n.local?u:await e();if(n.accountId=p,n.body){let e=i(n.body);o(await c(`Creating`,async()=>f.aiGateway.evaluations.create({...e,account_id:p,gateway_id:n[`gateway-id`]})),{successLabel:`Created`});return}if(n[`dataset-ids`]===void 0)throw Error(`--dataset-ids is required (or pass --body with this field set).`);if(n[`evaluation-type-ids`]===void 0)throw Error(`--evaluation-type-ids is required (or pass --body with this field set).`);n.name===void 0&&(n.name=await d(`name`,`The name field`));let m=a({dataset_ids:n[`dataset-ids`],evaluation_type_ids:n[`evaluation-type-ids`],name:l(n.name,`name`,`text`)});o(await c(`Creating`,async()=>f.aiGateway.evaluations.create({...m,account_id:p,gateway_id:n[`gateway-id`]})),{successLabel:`Created`})}};function ne(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 re={command:`delete <id>`,describe:`Deletes an AI Gateway dataset.`,builder:ne,handler:async n=>{if(n.dryRun){s({command:`cf ai-gateway evaluations delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/gateways/${n[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(n[`gateway-id`]))}/evaluations/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}`,pathParams:{"gateway-id":String(n[`gateway-id`]??``),id:String(n.id??``)},bodyKind:`none`});return}let i=await r(n),a=n.local?u:await e();if(n.accountId=a,!await f({force:!!n.force})){process.stderr.write(`Aborted.
6
- `);return}o(await c(`Deleting`,async()=>i.aiGateway.evaluations.delete({account_id:a,gateway_id:n[`gateway-id`],id:n.id})),{successLabel:`Deleted`})}};function ie(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 ae={command:`get <id>`,describe:`Retrieves details for a specific AI Gateway dataset.`,builder:ie,handler:async n=>{if(n.dryRun){s({command:`cf ai-gateway evaluations get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/gateways/${n[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(n[`gateway-id`]))}/evaluations/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}`,pathParams:{"gateway-id":String(n[`gateway-id`]??``),id:String(n.id??``)},bodyKind:`none`});return}let i=await r(n),a=n.local?u:await e();n.accountId=a,o(await c(`Loading`,async()=>i.aiGateway.evaluations.get({account_id:a,gateway_id:n[`gateway-id`],id:n.id})),{successLabel:`Loaded`})}};function oe(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(`processed`,{type:`boolean`,description:`Processed`}).option(`search`,{type:`string`,description:`Search by id, name`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const se={command:`list`,describe:`Lists all AI Gateway evaluator types configured for the account.`,builder:oe,handler:async n=>{let i={page:n.page,per_page:n[`per-page`],name:n.name,processed:n.processed,search:n.search};if(n.dryRun){s({command:`cf ai-gateway evaluations list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/gateways/${n[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(n[`gateway-id`]))}/evaluations`,pathParams:{"gateway-id":String(n[`gateway-id`]??``)},query:i,bodyKind:`none`});return}let a=await r(n),l=n.local?u:await e();n.accountId=l,o(await c(`Loading`,async()=>a.aiGateway.evaluations.list({account_id:l,gateway_id:n[`gateway-id`],...i})),{successLabel:`Loaded`})}},ce={command:`evaluations`,describe:`Run quality evaluations against gateway logs or datasets to score model outputs`,builder:e=>e.command(Q).command(re).command(ae).command(se).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function le(e){return e.positional(`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 ue={command:`get <id>`,describe:`Retrieves details for a specific AI Gateway dataset.`,builder:le,handler:async n=>{if(n.dryRun){s({command:`cf ai-gateway get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/gateways/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}`,pathParams:{id:String(n.id??``)},bodyKind:`none`});return}let i=await r(n),a=n.local?u:await e();n.accountId=a,o(await c(`Loading`,async()=>i.aiGateway.get({account_id:a,id:n.id})),{successLabel:`Loaded`})}};function de(e){return e.option(`page`,{type:`number`,description:`Page`}).option(`per-page`,{type:`number`,description:`Per page`}).option(`search`,{type:`string`,description:`Search by id`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const fe={command:`list`,describe:`Lists all AI Gateway evaluator types configured for the account.`,builder:de,handler:async n=>{let i={page:n.page,per_page:n[`per-page`],search:n.search};if(n.dryRun){s({command:`cf ai-gateway list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/gateways`,pathParams:{},query:i,bodyKind:`none`});return}let a=await r(n),l=n.local?u:await e();n.accountId=l,o(await c(`Loading`,async()=>a.aiGateway.list({account_id:l,...i})),{successLabel:`Loaded`})}};function pe(e){return e.positional(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`order-by`,{type:`string`,description:`Order by`,choices:[`created_at`,`provider`,`model`,`model_type`,`success`,`cached`,`cost`,`tokens_in`,`tokens_out`,`duration`,`feedback`]}).option(`order-by-direction`,{type:`string`,description:`Order by direction`,choices:[`asc`,`desc`]}).option(`filters`,{type:`string`,description:`Filters`}).option(`limit`,{type:`number`,description:`Limit`}).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 me={command:`delete <gateway-id>`,describe:`Deletes gateway log entries matching the specified criteria.`,builder:p(pe),handler:async n=>{let i={order_by:n[`order-by`],order_by_direction:n[`order-by-direction`],filters:n.filters,limit:n.limit};if(n.dryRun){s({command:`cf ai-gateway logs delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/gateways/${n[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(n[`gateway-id`]))}/logs`,pathParams:{"gateway-id":String(n[`gateway-id`]??``)},query:i,bodyKind:`none`});return}let a=await r(n),l=n.local?u:await e();if(n.accountId=l,!await f({force:!!n.force})){process.stderr.write(`Aborted.
7
- `);return}o(await c(`Deleting`,async()=>a.aiGateway.logs.delete({account_id:l,gateway_id:n[`gateway-id`],...i})),{successLabel:`Deleted`})}};function he(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`feedback`,{type:`number`,description:`The feedback field`}).option(`score`,{type:`number`,description:`The score 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 ge={command:`edit <id>`,describe:`Updates metadata for an AI Gateway log entry.`,builder:he,handler:async n=>{if(n.dryRun){s({command:`cf ai-gateway logs edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/gateways/${n[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(n[`gateway-id`]))}/logs/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}`,pathParams:{id:String(n.id??``),"gateway-id":String(n[`gateway-id`]??``)},bodyKind:`json`,body:n.body===void 0?a({feedback:n.feedback,score:n.score}):i(n.body)});return}let l=await r(n),d=n.local?u:await e();if(n.accountId=d,n.body){let e=i(n.body);o(await c(`Updating`,async()=>l.aiGateway.logs.edit({...e,account_id:d,gateway_id:n[`gateway-id`],id:n.id})),{successLabel:`Updated`});return}let f=a({feedback:n.feedback,score:n.score});o(await c(`Updating`,async()=>l.aiGateway.logs.edit({...f,account_id:d,gateway_id:n[`gateway-id`],id:n.id})),{successLabel:`Updated`})}};function _e(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 ve={command:`get <id>`,describe:`Retrieves detailed information for a specific AI Gateway log entry.`,builder:_e,handler:async n=>{if(n.dryRun){s({command:`cf ai-gateway logs get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/gateways/${n[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(n[`gateway-id`]))}/logs/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}`,pathParams:{id:String(n.id??``),"gateway-id":String(n[`gateway-id`]??``)},bodyKind:`none`});return}let i=await r(n),a=n.local?u:await e();n.accountId=a,o(await c(`Loading`,async()=>i.aiGateway.logs.get({account_id:a,gateway_id:n[`gateway-id`],id:n.id})),{successLabel:`Loaded`})}};function ye(e){return e.option(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`search`,{type:`string`,description:`Search`}).option(`page`,{type:`number`,description:`Page`}).option(`per-page`,{type:`number`,description:`Per page`}).option(`order-by`,{type:`string`,description:`Order by`,choices:[`created_at`,`provider`,`model`,`model_type`,`success`,`cached`]}).option(`order-by-direction`,{type:`string`,description:`Order by direction`,choices:[`asc`,`desc`]}).option(`filters`,{type:`string`,description:`Filters`}).option(`meta-info`,{type:`boolean`,description:`Meta info`}).option(`direction`,{type:`string`,description:`Direction`,choices:[`asc`,`desc`]}).option(`start-date`,{type:`string`,description:`Start date`}).option(`end-date`,{type:`string`,description:`End date`}).option(`min-cost`,{type:`number`,description:`Min cost`}).option(`max-cost`,{type:`number`,description:`Max cost`}).option(`min-tokens-in`,{type:`number`,description:`Min tokens in`}).option(`max-tokens-in`,{type:`number`,description:`Max tokens in`}).option(`min-tokens-out`,{type:`number`,description:`Min tokens out`}).option(`max-tokens-out`,{type:`number`,description:`Max tokens out`}).option(`min-total-tokens`,{type:`number`,description:`Min total tokens`}).option(`max-total-tokens`,{type:`number`,description:`Max total tokens`}).option(`min-duration`,{type:`number`,description:`Min duration`}).option(`max-duration`,{type:`number`,description:`Max duration`}).option(`feedback`,{type:`string`,description:`Feedback`,choices:[`-1`]}).option(`success`,{type:`boolean`,description:`Success`}).option(`cached`,{type:`boolean`,description:`Cached`}).option(`model`,{type:`string`,description:`Model`}).option(`model-type`,{type:`string`,description:`Model type`}).option(`provider`,{type:`string`,description:`Provider`}).option(`request-content-type`,{type:`string`,description:`Request content type`}).option(`response-content-type`,{type:`string`,description:`Response content type`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const be={command:`list`,describe:`Lists request/response log entries for the AI gateway with filtering and pagination.`,builder:p(ye),handler:async n=>{let i={search:n.search,page:n.page,per_page:n[`per-page`],order_by:n[`order-by`],order_by_direction:n[`order-by-direction`],filters:n.filters,meta_info:n[`meta-info`],direction:n.direction,start_date:n[`start-date`],end_date:n[`end-date`],min_cost:n[`min-cost`],max_cost:n[`max-cost`],min_tokens_in:n[`min-tokens-in`],max_tokens_in:n[`max-tokens-in`],min_tokens_out:n[`min-tokens-out`],max_tokens_out:n[`max-tokens-out`],min_total_tokens:n[`min-total-tokens`],max_total_tokens:n[`max-total-tokens`],min_duration:n[`min-duration`],max_duration:n[`max-duration`],feedback:n.feedback,success:n.success,cached:n.cached,model:n.model,model_type:n[`model-type`],provider:n.provider,request_content_type:n[`request-content-type`],response_content_type:n[`response-content-type`]};if(n.dryRun){s({command:`cf ai-gateway logs list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/gateways/${n[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(n[`gateway-id`]))}/logs`,pathParams:{"gateway-id":String(n[`gateway-id`]??``)},query:i,bodyKind:`none`});return}let a=await r(n),l=n.local?u:await e();n.accountId=l,o(await c(`Loading`,async()=>a.aiGateway.logs.list({account_id:l,gateway_id:n[`gateway-id`],...i})),{successLabel:`Loaded`})}};function xe(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 Se={command:`request <id>`,describe:`Retrieves the original request payload for an AI Gateway log entry.`,builder:xe,handler:async n=>{if(n.dryRun){s({command:`cf ai-gateway logs request`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/gateways/${n[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(n[`gateway-id`]))}/logs/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}/request`,pathParams:{id:String(n.id??``),"gateway-id":String(n[`gateway-id`]??``)},bodyKind:`none`});return}let i=await r(n),a=n.local?u:await e();n.accountId=a,o(await c(`Loading`,async()=>i.aiGateway.logs.request({account_id:a,gateway_id:n[`gateway-id`],id:n.id})),{successLabel:`Loaded`})}};function Ce(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 we={command:`response <id>`,describe:`Retrieves the response payload for an AI Gateway log entry.`,builder:Ce,handler:async n=>{if(n.dryRun){s({command:`cf ai-gateway logs response`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/gateways/${n[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(n[`gateway-id`]))}/logs/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}/response`,pathParams:{id:String(n.id??``),"gateway-id":String(n[`gateway-id`]??``)},bodyKind:`none`});return}let i=await r(n),a=n.local?u:await e();n.accountId=a,o(await c(`Loading`,async()=>i.aiGateway.logs.response({account_id:a,gateway_id:n[`gateway-id`],id:n.id})),{successLabel:`Loaded`})}},Te={command:`logs`,describe:`Operations for logs`,builder:e=>e.command(me).command(ge).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(`alias`,{type:`string`,description:`The alias field`}).option(`default-config`,{type:`boolean`,description:`The default_config field`}).option(`provider-slug`,{type:`string`,description:`The provider_slug field`}).option(`rate-limit`,{type:`number`,description:`The rate_limit field`}).option(`rate-limit-period`,{type:`number`,description:`The rate_limit_period field`,default:60}).option(`secret`,{type:`string`,description:`The secret field`}).option(`secret-id`,{type:`string`,description:`The secret_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 De={command:`create <gateway-id>`,describe:`Creates a new AI Gateway.`,builder:Ee,handler:async n=>{if(n.dryRun){s({command:`cf ai-gateway provider-configs create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/gateways/${n[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(n[`gateway-id`]))}/provider_configs`,pathParams:{"gateway-id":String(n[`gateway-id`]??``)},bodyKind:`json`,body:n.body===void 0?a({alias:l(n.alias,`alias`,`text`),default_config:n[`default-config`],provider_slug:l(n[`provider-slug`],`provider-slug`,`text`),rate_limit:n[`rate-limit`],rate_limit_period:n[`rate-limit-period`],secret:l(n.secret,`secret`,`text`),secret_id:l(n[`secret-id`],`secret-id`,`text`)}):i(n.body)});return}let f=await r(n),p=n.local?u:await e();if(n.accountId=p,n.body){let e=i(n.body);o(await c(`Creating`,async()=>f.aiGateway.providerConfigs.create({...e,account_id:p,gateway_id:n[`gateway-id`]})),{successLabel:`Created`});return}if(n.alias===void 0&&(n.alias=await d(`alias`,`The alias field`)),n[`default-config`]===void 0)throw Error(`--default-config is required (or pass --body with this field set).`);n[`provider-slug`]===void 0&&(n[`provider-slug`]=await d(`provider-slug`,`The provider_slug field`));let m=a({alias:l(n.alias,`alias`,`text`),default_config:n[`default-config`],provider_slug:l(n[`provider-slug`],`provider-slug`,`text`),rate_limit:n[`rate-limit`],rate_limit_period:n[`rate-limit-period`],secret:l(n.secret,`secret`,`text`),secret_id:l(n[`secret-id`],`secret-id`,`text`)});o(await c(`Creating`,async()=>f.aiGateway.providerConfigs.create({...m,account_id:p,gateway_id:n[`gateway-id`]})),{successLabel:`Created`})}};function $(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 Oe={command:`delete <id>`,describe:`Deletes an AI Gateway dataset.`,builder:$,handler:async n=>{if(n.dryRun){s({command:`cf ai-gateway provider-configs delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/gateways/${n[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(n[`gateway-id`]))}/provider_configs/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}`,pathParams:{"gateway-id":String(n[`gateway-id`]??``),id:String(n.id??``)},bodyKind:`none`});return}let i=await r(n),a=n.local?u:await e();if(n.accountId=a,!await f({force:!!n.force})){process.stderr.write(`Aborted.
8
- `);return}o(await c(`Deleting`,async()=>i.aiGateway.providerConfigs.delete({account_id:a,gateway_id:n[`gateway-id`],id:n.id})),{successLabel:`Deleted`})}};function ke(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(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Ae={command:`list`,describe:`Lists all AI Gateway evaluator types configured for the account.`,builder:ke,handler:async n=>{let i={page:n.page,per_page:n[`per-page`]};if(n.dryRun){s({command:`cf ai-gateway provider-configs list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/gateways/${n[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(n[`gateway-id`]))}/provider_configs`,pathParams:{"gateway-id":String(n[`gateway-id`]??``)},query:i,bodyKind:`none`});return}let a=await r(n),l=n.local?u:await e();n.accountId=l,o(await c(`Loading`,async()=>a.aiGateway.providerConfigs.list({account_id:l,gateway_id:n[`gateway-id`],...i})),{successLabel:`Loaded`})}};function je(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`secret`,{type:`string`,description:`The secret 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 Me={command:`update <id>`,describe:`Updates an existing AI Gateway dataset.`,builder:je,handler:async n=>{if(n.dryRun){s({command:`cf ai-gateway provider-configs update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/gateways/${n[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(n[`gateway-id`]))}/provider_configs/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}`,pathParams:{"gateway-id":String(n[`gateway-id`]??``),id:String(n.id??``)},bodyKind:`json`,body:n.body===void 0?a({secret:l(n.secret,`secret`,`text`)}):i(n.body)});return}let f=await r(n),p=n.local?u:await e();if(n.accountId=p,n.body){let e=i(n.body);o(await c(`Updating`,async()=>f.aiGateway.providerConfigs.update({...e,account_id:p,gateway_id:n[`gateway-id`],id:n.id})),{successLabel:`Updated`});return}n.secret===void 0&&(n.secret=await d(`secret`,`The secret field`));let m=a({secret:l(n.secret,`secret`,`text`)});o(await c(`Updating`,async()=>f.aiGateway.providerConfigs.update({...m,account_id:p,gateway_id:n[`gateway-id`],id:n.id})),{successLabel:`Updated`})}},Ne={command:`provider-configs`,describe:`Store API keys and endpoint settings for each upstream AI provider`,builder:e=>e.command(De).command(Oe).command(Ae).command(Me).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Pe(e){return e.positional(`id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`authentication`,{type:`boolean`,description:`The authentication field`}).option(`cache-invalidate-on-update`,{type:`boolean`,description:`The cache_invalidate_on_update field`}).option(`cache-ttl`,{type:`number`,description:`The cache_ttl field`}).option(`collect-logs`,{type:`boolean`,description:`The collect_logs field`}).option(`guardrails-prompt-p1`,{type:`string`,description:`The guardrails.prompt.P1 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-prompt-s1`,{type:`string`,description:`The guardrails.prompt.S1 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-prompt-s10`,{type:`string`,description:`The guardrails.prompt.S10 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-prompt-s11`,{type:`string`,description:`The guardrails.prompt.S11 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-prompt-s12`,{type:`string`,description:`The guardrails.prompt.S12 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-prompt-s13`,{type:`string`,description:`The guardrails.prompt.S13 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-prompt-s2`,{type:`string`,description:`The guardrails.prompt.S2 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-prompt-s3`,{type:`string`,description:`The guardrails.prompt.S3 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-prompt-s4`,{type:`string`,description:`The guardrails.prompt.S4 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-prompt-s5`,{type:`string`,description:`The guardrails.prompt.S5 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-prompt-s6`,{type:`string`,description:`The guardrails.prompt.S6 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-prompt-s7`,{type:`string`,description:`The guardrails.prompt.S7 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-prompt-s8`,{type:`string`,description:`The guardrails.prompt.S8 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-prompt-s9`,{type:`string`,description:`The guardrails.prompt.S9 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-response-p1`,{type:`string`,description:`The guardrails.response.P1 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-response-s1`,{type:`string`,description:`The guardrails.response.S1 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-response-s10`,{type:`string`,description:`The guardrails.response.S10 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-response-s11`,{type:`string`,description:`The guardrails.response.S11 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-response-s12`,{type:`string`,description:`The guardrails.response.S12 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-response-s13`,{type:`string`,description:`The guardrails.response.S13 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-response-s2`,{type:`string`,description:`The guardrails.response.S2 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-response-s3`,{type:`string`,description:`The guardrails.response.S3 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-response-s4`,{type:`string`,description:`The guardrails.response.S4 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-response-s5`,{type:`string`,description:`The guardrails.response.S5 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-response-s6`,{type:`string`,description:`The guardrails.response.S6 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-response-s7`,{type:`string`,description:`The guardrails.response.S7 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-response-s8`,{type:`string`,description:`The guardrails.response.S8 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-response-s9`,{type:`string`,description:`The guardrails.response.S9 field`,choices:[`FLAG`,`BLOCK`]}).option(`log-management`,{type:`number`,description:`The log_management field`}).option(`log-management-strategy`,{type:`string`,description:`The log_management_strategy field`,choices:[`STOP_INSERTING`,`DELETE_OLDEST`]}).option(`logpush`,{type:`boolean`,description:`The logpush field`}).option(`logpush-public-key`,{type:`string`,description:`The logpush_public_key field`}).option(`rate-limiting-interval`,{type:`number`,description:`The rate_limiting_interval field`}).option(`rate-limiting-limit`,{type:`number`,description:`The rate_limiting_limit field`}).option(`rate-limiting-technique`,{type:`string`,description:`The rate_limiting_technique field`,choices:[`fixed`,`sliding`]}).option(`retry-backoff`,{type:`string`,description:`Backoff strategy for retry delays`,choices:[`constant`,`linear`,`exponential`]}).option(`retry-delay`,{type:`number`,description:`Delay between retry attempts in milliseconds (0-5000)`}).option(`retry-max-attempts`,{type:`number`,description:`Maximum number of retry attempts for failed requests (1-5)`}).option(`spend-limits-enabled`,{type:`boolean`,description:`The spend_limits.enabled field`}).option(`store-id`,{type:`string`,description:`The store_id field`}).option(`stripe-authorization`,{type:`string`,description:`The stripe.authorization field`}).option(`workers-ai-billing-mode`,{type:`string`,description:`Controls how Workers AI inference calls routed through this gateway are billed. Only 'postpaid' is currently supported.`,choices:[`postpaid`]}).option(`zdr`,{type:`boolean`,description:`The zdr 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)`}).check(e=>{if([`stripe-authorization`].some(t=>e[t]!==void 0)){let t=[`stripe-authorization`].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 --stripe-* flag is set`)}return!0})}const Fe={command:`update <id>`,describe:`Updates an existing AI Gateway dataset.`,builder:Pe,handler:async n=>{if(n.dryRun){s({command:`cf ai-gateway update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/gateways/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}`,pathParams:{id:String(n.id??``)},bodyKind:`json`,body:n.body===void 0?a({authentication:n.authentication,cache_invalidate_on_update:n[`cache-invalidate-on-update`],cache_ttl:n[`cache-ttl`],collect_logs:n[`collect-logs`],guardrails:{prompt:{P1:l(n[`guardrails-prompt-p1`],`guardrails-prompt-p1`,`text`),S1:l(n[`guardrails-prompt-s1`],`guardrails-prompt-s1`,`text`),S10:l(n[`guardrails-prompt-s10`],`guardrails-prompt-s10`,`text`),S11:l(n[`guardrails-prompt-s11`],`guardrails-prompt-s11`,`text`),S12:l(n[`guardrails-prompt-s12`],`guardrails-prompt-s12`,`text`),S13:l(n[`guardrails-prompt-s13`],`guardrails-prompt-s13`,`text`),S2:l(n[`guardrails-prompt-s2`],`guardrails-prompt-s2`,`text`),S3:l(n[`guardrails-prompt-s3`],`guardrails-prompt-s3`,`text`),S4:l(n[`guardrails-prompt-s4`],`guardrails-prompt-s4`,`text`),S5:l(n[`guardrails-prompt-s5`],`guardrails-prompt-s5`,`text`),S6:l(n[`guardrails-prompt-s6`],`guardrails-prompt-s6`,`text`),S7:l(n[`guardrails-prompt-s7`],`guardrails-prompt-s7`,`text`),S8:l(n[`guardrails-prompt-s8`],`guardrails-prompt-s8`,`text`),S9:l(n[`guardrails-prompt-s9`],`guardrails-prompt-s9`,`text`)},response:{P1:l(n[`guardrails-response-p1`],`guardrails-response-p1`,`text`),S1:l(n[`guardrails-response-s1`],`guardrails-response-s1`,`text`),S10:l(n[`guardrails-response-s10`],`guardrails-response-s10`,`text`),S11:l(n[`guardrails-response-s11`],`guardrails-response-s11`,`text`),S12:l(n[`guardrails-response-s12`],`guardrails-response-s12`,`text`),S13:l(n[`guardrails-response-s13`],`guardrails-response-s13`,`text`),S2:l(n[`guardrails-response-s2`],`guardrails-response-s2`,`text`),S3:l(n[`guardrails-response-s3`],`guardrails-response-s3`,`text`),S4:l(n[`guardrails-response-s4`],`guardrails-response-s4`,`text`),S5:l(n[`guardrails-response-s5`],`guardrails-response-s5`,`text`),S6:l(n[`guardrails-response-s6`],`guardrails-response-s6`,`text`),S7:l(n[`guardrails-response-s7`],`guardrails-response-s7`,`text`),S8:l(n[`guardrails-response-s8`],`guardrails-response-s8`,`text`),S9:l(n[`guardrails-response-s9`],`guardrails-response-s9`,`text`)}},log_management:n[`log-management`],log_management_strategy:l(n[`log-management-strategy`],`log-management-strategy`,`text`),logpush:n.logpush,logpush_public_key:l(n[`logpush-public-key`],`logpush-public-key`,`text`),rate_limiting_interval:n[`rate-limiting-interval`],rate_limiting_limit:n[`rate-limiting-limit`],rate_limiting_technique:l(n[`rate-limiting-technique`],`rate-limiting-technique`,`text`),retry_backoff:l(n[`retry-backoff`],`retry-backoff`,`text`),retry_delay:n[`retry-delay`],retry_max_attempts:n[`retry-max-attempts`],spend_limits:{enabled:n[`spend-limits-enabled`]},store_id:l(n[`store-id`],`store-id`,`text`),stripe:{authorization:l(n[`stripe-authorization`],`stripe-authorization`,`text`)},workers_ai_billing_mode:l(n[`workers-ai-billing-mode`],`workers-ai-billing-mode`,`text`),zdr:n.zdr}):i(n.body)});return}let d=await r(n),f=n.local?u:await e();if(n.accountId=f,n.body){let e=i(n.body);o(await c(`Updating`,async()=>d.aiGateway.update({...e,account_id:f,id:n.id})),{successLabel:`Updated`});return}if(n[`cache-invalidate-on-update`]===void 0)throw Error(`--cache-invalidate-on-update is required (or pass --body with this field set).`);if(n[`cache-ttl`]===void 0)throw Error(`--cache-ttl is required (or pass --body with this field set).`);if(n[`collect-logs`]===void 0)throw Error(`--collect-logs is required (or pass --body with this field set).`);if(n[`rate-limiting-interval`]===void 0)throw Error(`--rate-limiting-interval is required (or pass --body with this field set).`);if(n[`rate-limiting-limit`]===void 0)throw Error(`--rate-limiting-limit is required (or pass --body with this field set).`);let p=a({authentication:n.authentication,cache_invalidate_on_update:n[`cache-invalidate-on-update`],cache_ttl:n[`cache-ttl`],collect_logs:n[`collect-logs`],guardrails:{prompt:{P1:l(n[`guardrails-prompt-p1`],`guardrails-prompt-p1`,`text`),S1:l(n[`guardrails-prompt-s1`],`guardrails-prompt-s1`,`text`),S10:l(n[`guardrails-prompt-s10`],`guardrails-prompt-s10`,`text`),S11:l(n[`guardrails-prompt-s11`],`guardrails-prompt-s11`,`text`),S12:l(n[`guardrails-prompt-s12`],`guardrails-prompt-s12`,`text`),S13:l(n[`guardrails-prompt-s13`],`guardrails-prompt-s13`,`text`),S2:l(n[`guardrails-prompt-s2`],`guardrails-prompt-s2`,`text`),S3:l(n[`guardrails-prompt-s3`],`guardrails-prompt-s3`,`text`),S4:l(n[`guardrails-prompt-s4`],`guardrails-prompt-s4`,`text`),S5:l(n[`guardrails-prompt-s5`],`guardrails-prompt-s5`,`text`),S6:l(n[`guardrails-prompt-s6`],`guardrails-prompt-s6`,`text`),S7:l(n[`guardrails-prompt-s7`],`guardrails-prompt-s7`,`text`),S8:l(n[`guardrails-prompt-s8`],`guardrails-prompt-s8`,`text`),S9:l(n[`guardrails-prompt-s9`],`guardrails-prompt-s9`,`text`)},response:{P1:l(n[`guardrails-response-p1`],`guardrails-response-p1`,`text`),S1:l(n[`guardrails-response-s1`],`guardrails-response-s1`,`text`),S10:l(n[`guardrails-response-s10`],`guardrails-response-s10`,`text`),S11:l(n[`guardrails-response-s11`],`guardrails-response-s11`,`text`),S12:l(n[`guardrails-response-s12`],`guardrails-response-s12`,`text`),S13:l(n[`guardrails-response-s13`],`guardrails-response-s13`,`text`),S2:l(n[`guardrails-response-s2`],`guardrails-response-s2`,`text`),S3:l(n[`guardrails-response-s3`],`guardrails-response-s3`,`text`),S4:l(n[`guardrails-response-s4`],`guardrails-response-s4`,`text`),S5:l(n[`guardrails-response-s5`],`guardrails-response-s5`,`text`),S6:l(n[`guardrails-response-s6`],`guardrails-response-s6`,`text`),S7:l(n[`guardrails-response-s7`],`guardrails-response-s7`,`text`),S8:l(n[`guardrails-response-s8`],`guardrails-response-s8`,`text`),S9:l(n[`guardrails-response-s9`],`guardrails-response-s9`,`text`)}},log_management:n[`log-management`],log_management_strategy:l(n[`log-management-strategy`],`log-management-strategy`,`text`),logpush:n.logpush,logpush_public_key:l(n[`logpush-public-key`],`logpush-public-key`,`text`),rate_limiting_interval:n[`rate-limiting-interval`],rate_limiting_limit:n[`rate-limiting-limit`],rate_limiting_technique:l(n[`rate-limiting-technique`],`rate-limiting-technique`,`text`),retry_backoff:l(n[`retry-backoff`],`retry-backoff`,`text`),retry_delay:n[`retry-delay`],retry_max_attempts:n[`retry-max-attempts`],spend_limits:{enabled:n[`spend-limits-enabled`]},store_id:l(n[`store-id`],`store-id`,`text`),stripe:{authorization:l(n[`stripe-authorization`],`stripe-authorization`,`text`)},workers_ai_billing_mode:l(n[`workers-ai-billing-mode`],`workers-ai-billing-mode`,`text`),zdr:n.zdr});o(await c(`Updating`,async()=>d.aiGateway.update({...p,account_id:f,id:n.id})),{successLabel:`Updated`})}};function Ie(e){return e.positional(`provider`,{type:`string`,description:`Provider`,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 Le={command:`get <provider>`,describe:`Retrieves the endpoint URL for an AI Gateway.`,builder:Ie,handler:async n=>{if(n.dryRun){s({command:`cf ai-gateway urls get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/gateways/${n[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(n[`gateway-id`]))}/url/${n.provider==null?`<provider>`:encodeURIComponent(String(n.provider))}`,pathParams:{"gateway-id":String(n[`gateway-id`]??``),provider:String(n.provider??``)},bodyKind:`none`});return}let i=await r(n),a=n.local?u:await e();n.accountId=a,o(await c(`Loading`,async()=>i.aiGateway.urls.get({account_id:a,gateway_id:n[`gateway-id`],provider:n.provider})),{successLabel:`Loaded`})}},Re={command:`urls`,describe:`Operations for urls`,builder:e=>e.command(Le).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},ze={command:`ai-gateway`,describe:`Proxy, cache, rate-limit, and observe requests to AI providers — OpenAI, Anthropic, Workers AI, and more`,builder:e=>e.command(ee).command(E).command(ue).command(fe).command(Fe).command(w).command(q).command(X).command(ce).command(Te).command(Ne).command(Re).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{ze as default};
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env node
2
- import{O as e,P as t}from"./oauth-B5k80sip.mjs";import{i as n,n as r}from"./auth-DX9KnJ0P.mjs";import{n as i,t as a}from"./body-parser-DWSy7uZ8.mjs";import{t as o}from"./output-B6fBFRqe.mjs";import{n as s,t as c}from"./progress-CL8I-7YK.mjs";import{n as l,t as u}from"./input-validation-_fMCApaH.mjs";import{t as d}from"./local-CYc9q7l2.mjs";import{n as f,r as p,t as m}from"./prompt-q3B7sM2A.mjs";import{t as h}from"./cli-types-DGgEbf8K.mjs";import{n as ee,t as te}from"./raw-fetch-bIXC9D1m.mjs";function g(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace name`,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-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-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(`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 _={command:`chat-completions <id>`,describe:`Performs a chat completion request against an AI Search instance, using indexed content as context for generating responses.`,builder:g,handler:async n=>{if(n.dryRun){s({command:`cf ai-search chat-completions`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}/chat/completions`,pathParams:{id:String(n.id??``),name:String(n.name??``)},bodyKind:`json`,body:n.body===void 0?a({ai_search_options:{cache:{cache_threshold:l(n[`ai-search-options-cache-cache-threshold`],`ai-search-options-cache-cache-threshold`,`text`),enabled:n[`ai-search-options-cache-enabled`]},query_rewrite:{enabled:n[`ai-search-options-query-rewrite-enabled`],rewrite_prompt:l(n[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:n[`ai-search-options-reranking-enabled`],match_threshold:n[`ai-search-options-reranking-match-threshold`]},retrieval:{context_expansion:n[`ai-search-options-retrieval-context-expansion`],fusion_method:l(n[`ai-search-options-retrieval-fusion-method`],`ai-search-options-retrieval-fusion-method`,`text`),keyword_match_mode:l(n[`ai-search-options-retrieval-keyword-match-mode`],`ai-search-options-retrieval-keyword-match-mode`,`text`),match_threshold:n[`ai-search-options-retrieval-match-threshold`],max_num_results:n[`ai-search-options-retrieval-max-num-results`],retrieval_type:l(n[`ai-search-options-retrieval-retrieval-type`],`ai-search-options-retrieval-retrieval-type`,`text`),return_on_failure:n[`ai-search-options-retrieval-return-on-failure`]}},stream:n.stream}):i(n.body)});return}let u=await r(n),f=n.local?d:await e();if(n.accountId=f,n.body){let e=i(n.body);o(await c(`Creating`,async()=>u.aiSearch.chatCompletions({...e,account_id:f,name:n.name,id:n.id})),{successLabel:`Created`});return}let p=a({ai_search_options:{cache:{cache_threshold:l(n[`ai-search-options-cache-cache-threshold`],`ai-search-options-cache-cache-threshold`,`text`),enabled:n[`ai-search-options-cache-enabled`]},query_rewrite:{enabled:n[`ai-search-options-query-rewrite-enabled`],rewrite_prompt:l(n[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:n[`ai-search-options-reranking-enabled`],match_threshold:n[`ai-search-options-reranking-match-threshold`]},retrieval:{context_expansion:n[`ai-search-options-retrieval-context-expansion`],fusion_method:l(n[`ai-search-options-retrieval-fusion-method`],`ai-search-options-retrieval-fusion-method`,`text`),keyword_match_mode:l(n[`ai-search-options-retrieval-keyword-match-mode`],`ai-search-options-retrieval-keyword-match-mode`,`text`),match_threshold:n[`ai-search-options-retrieval-match-threshold`],max_num_results:n[`ai-search-options-retrieval-max-num-results`],retrieval_type:l(n[`ai-search-options-retrieval-retrieval-type`],`ai-search-options-retrieval-retrieval-type`,`text`),return_on_failure:n[`ai-search-options-retrieval-return-on-failure`]}},stream:n.stream});o(await c(`Creating`,async()=>u.aiSearch.chatCompletions({...p,account_id:f,name:n.name,id:n.id})),{successLabel:`Created`})}};function v(e){return e.positional(`name`,{type:`string`,description:`Namespace name`,demandOption:!0}).option(`ai-gateway-id`,{type:`string`,description:`The ai_gateway_id field`}).option(`ai-search-model`,{type:`string`,description:`The ai_search_model field`,choices:`@cf/meta/llama-3.3-70b-instruct-fp8-fast,@cf/zai-org/glm-4.7-flash,@cf/meta/llama-3.1-8b-instruct-fast,@cf/meta/llama-3.1-8b-instruct-fp8,@cf/meta/llama-4-scout-17b-16e-instruct,@cf/qwen/qwen3-30b-a3b-fp8,@cf/deepseek-ai/deepseek-r1-distill-qwen-32b,@cf/moonshotai/kimi-k2-instruct,@cf/google/gemma-3-12b-it,@cf/google/gemma-4-26b-a4b-it,@cf/moonshotai/kimi-k2.5,anthropic/claude-3-7-sonnet,anthropic/claude-sonnet-4,anthropic/claude-opus-4,anthropic/claude-3-5-haiku,cerebras/qwen-3-235b-a22b-instruct,cerebras/qwen-3-235b-a22b-thinking,cerebras/llama-3.3-70b,cerebras/llama-4-maverick-17b-128e-instruct,cerebras/llama-4-scout-17b-16e-instruct,cerebras/gpt-oss-120b,google-ai-studio/gemini-2.5-flash,google-ai-studio/gemini-2.5-pro,grok/grok-4,groq/llama-3.3-70b-versatile,groq/llama-3.1-8b-instant,openai/gpt-5,openai/gpt-5-mini,openai/gpt-5-nano`.split(`,`)}).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(`embedding-model`,{type:`string`,description:`The embedding_model field`,choices:[`@cf/qwen/qwen3-embedding-0.6b`,`@cf/qwen/qwen3-vl-embedding-2b`,`@cf/baai/bge-m3`,`@cf/baai/bge-large-en-v1.5`,`@cf/google/embeddinggemma-300m`,`google-ai-studio/gemini-embedding-001`,`google-ai-studio/gemini-embedding-2-preview`,`google-ai-studio/gemini-embedding-2`,`openai/text-embedding-3-small`,`openai/text-embedding-3-large`]}).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(`id`,{type:`string`,description:`AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.`}).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`],default:`porter`}).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`,default:!1}).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.`,default:!0}).option(`public-endpoint-params-enabled`,{type:`boolean`,description:`The public_endpoint_params.enabled field`,default:!1}).option(`public-endpoint-params-mcp-description`,{type:`string`,description:`The public_endpoint_params.mcp.description field`,default:`Finds exactly what you're looking for`}).option(`public-endpoint-params-mcp-disabled`,{type:`boolean`,description:`Disable MCP endpoint for this public endpoint`,default:!1}).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`,default:!1}).option(`reranking`,{type:`boolean`,description:`The reranking field`,default:!1}).option(`reranking-model`,{type:`string`,description:`The reranking_model field`,choices:[`@cf/baai/bge-reranker-base`]}).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:`The rewrite_model field`,choices:`@cf/meta/llama-3.3-70b-instruct-fp8-fast,@cf/zai-org/glm-4.7-flash,@cf/meta/llama-3.1-8b-instruct-fast,@cf/meta/llama-3.1-8b-instruct-fp8,@cf/meta/llama-4-scout-17b-16e-instruct,@cf/qwen/qwen3-30b-a3b-fp8,@cf/deepseek-ai/deepseek-r1-distill-qwen-32b,@cf/moonshotai/kimi-k2-instruct,@cf/google/gemma-3-12b-it,@cf/google/gemma-4-26b-a4b-it,@cf/moonshotai/kimi-k2.5,anthropic/claude-3-7-sonnet,anthropic/claude-sonnet-4,anthropic/claude-opus-4,anthropic/claude-3-5-haiku,cerebras/qwen-3-235b-a22b-instruct,cerebras/qwen-3-235b-a22b-thinking,cerebras/llama-3.3-70b,cerebras/llama-4-maverick-17b-128e-instruct,cerebras/llama-4-scout-17b-16e-instruct,cerebras/gpt-oss-120b,google-ai-studio/gemini-2.5-flash,google-ai-studio/gemini-2.5-pro,grok/grok-4,groq/llama-3.3-70b-versatile,groq/llama-3.1-8b-instant,openai/gpt-5,openai/gpt-5-mini,openai/gpt-5-nano`.split(`,`)}).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)`}).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)`}).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`,default:`default`}).option(`source-params-web-crawler-parse-options-include-images`,{type:`boolean`,description:`The source_params.web_crawler.parse_options.include_images field`,default:!1}).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`,default:!0}).option(`source-params-web-crawler-parse-type`,{type:`string`,description:`The source_params.web_crawler.parse_type field`,choices:[`sitemap`,`crawl`],default:`sitemap`}).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 y={command:`create <name>`,describe:`Create a new AI Search instance with the given configuration.`,builder:v,handler:async n=>{if(n.dryRun){s({command:`cf ai-search create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances`,pathParams:{name:String(n.name??``)},bodyKind:`json`,body:n.body===void 0?a({ai_gateway_id:l(n[`ai-gateway-id`],`ai-gateway-id`,`text`),ai_search_model:l(n[`ai-search-model`],`ai-search-model`,`text`),cache:n.cache,cache_threshold:l(n[`cache-threshold`],`cache-threshold`,`text`),chunk:n.chunk,chunk_overlap:n[`chunk-overlap`],chunk_size:n[`chunk-size`],embedding_model:l(n[`embedding-model`],`embedding-model`,`text`),fusion_method:l(n[`fusion-method`],`fusion-method`,`text`),hybrid_search_enabled:n[`hybrid-search-enabled`],id:l(n.id,`id`,`text`),index_method:{keyword:n[`index-method-keyword`],vector:n[`index-method-vector`]},indexing_options:{keyword_tokenizer:l(n[`indexing-options-keyword-tokenizer`],`indexing-options-keyword-tokenizer`,`text`)},max_num_results:n[`max-num-results`],metadata:{created_from_aisearch_wizard:n[`metadata-created-from-aisearch-wizard`],worker_domain:l(n[`metadata-worker-domain`],`metadata-worker-domain`,`text`)},public_endpoint_params:{authorized_hosts:n[`public-endpoint-params-authorized-hosts`],chat_completions_endpoint:{disabled:n[`public-endpoint-params-chat-completions-endpoint-disabled`]},custom_domains:n[`public-endpoint-params-custom-domains`],default_domain_enabled:n[`public-endpoint-params-default-domain-enabled`],enabled:n[`public-endpoint-params-enabled`],mcp:{description:l(n[`public-endpoint-params-mcp-description`],`public-endpoint-params-mcp-description`,`text`),disabled:n[`public-endpoint-params-mcp-disabled`]},rate_limit:{period_ms:n[`public-endpoint-params-rate-limit-period-ms`],requests:n[`public-endpoint-params-rate-limit-requests`],technique:l(n[`public-endpoint-params-rate-limit-technique`],`public-endpoint-params-rate-limit-technique`,`text`)},search_endpoint:{disabled:n[`public-endpoint-params-search-endpoint-disabled`]}},reranking:n.reranking,reranking_model:l(n[`reranking-model`],`reranking-model`,`text`),retrieval_options:{keyword_match_mode:l(n[`retrieval-options-keyword-match-mode`],`retrieval-options-keyword-match-mode`,`text`)},rewrite_model:l(n[`rewrite-model`],`rewrite-model`,`text`),rewrite_query:n[`rewrite-query`],score_threshold:n[`score-threshold`],source:l(n.source,`source`,`text`),source_params:{exclude_items:n[`source-params-exclude-items`],include_items:n[`source-params-include-items`],prefix:l(n[`source-params-prefix`],`source-params-prefix`,`text`),r2_jurisdiction:l(n[`source-params-r2-jurisdiction`],`source-params-r2-jurisdiction`,`text`),web_crawler:{parse_options:{include_images:n[`source-params-web-crawler-parse-options-include-images`],specific_sitemaps:n[`source-params-web-crawler-parse-options-specific-sitemaps`],use_browser_rendering:n[`source-params-web-crawler-parse-options-use-browser-rendering`]},parse_type:l(n[`source-params-web-crawler-parse-type`],`source-params-web-crawler-parse-type`,`text`)}},token_id:l(n[`token-id`],`token-id`,`text`),type:l(n.type,`type`,`text`)}):i(n.body)});return}let u=await r(n),f=n.local?d:await e();if(n.accountId=f,n.body){let e=i(n.body);o(await c(`Creating`,async()=>u.aiSearch.create({...e,account_id:f,name:n.name})),{successLabel:`Created`});return}n.id===void 0&&(n.id=await p(`id`,`AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.`));let m=a({ai_gateway_id:l(n[`ai-gateway-id`],`ai-gateway-id`,`text`),ai_search_model:l(n[`ai-search-model`],`ai-search-model`,`text`),cache:n.cache,cache_threshold:l(n[`cache-threshold`],`cache-threshold`,`text`),chunk:n.chunk,chunk_overlap:n[`chunk-overlap`],chunk_size:n[`chunk-size`],embedding_model:l(n[`embedding-model`],`embedding-model`,`text`),fusion_method:l(n[`fusion-method`],`fusion-method`,`text`),hybrid_search_enabled:n[`hybrid-search-enabled`],id:l(n.id,`id`,`text`),index_method:{keyword:n[`index-method-keyword`],vector:n[`index-method-vector`]},indexing_options:{keyword_tokenizer:l(n[`indexing-options-keyword-tokenizer`],`indexing-options-keyword-tokenizer`,`text`)},max_num_results:n[`max-num-results`],metadata:{created_from_aisearch_wizard:n[`metadata-created-from-aisearch-wizard`],worker_domain:l(n[`metadata-worker-domain`],`metadata-worker-domain`,`text`)},public_endpoint_params:{authorized_hosts:n[`public-endpoint-params-authorized-hosts`],chat_completions_endpoint:{disabled:n[`public-endpoint-params-chat-completions-endpoint-disabled`]},custom_domains:n[`public-endpoint-params-custom-domains`],default_domain_enabled:n[`public-endpoint-params-default-domain-enabled`],enabled:n[`public-endpoint-params-enabled`],mcp:{description:l(n[`public-endpoint-params-mcp-description`],`public-endpoint-params-mcp-description`,`text`),disabled:n[`public-endpoint-params-mcp-disabled`]},rate_limit:{period_ms:n[`public-endpoint-params-rate-limit-period-ms`],requests:n[`public-endpoint-params-rate-limit-requests`],technique:l(n[`public-endpoint-params-rate-limit-technique`],`public-endpoint-params-rate-limit-technique`,`text`)},search_endpoint:{disabled:n[`public-endpoint-params-search-endpoint-disabled`]}},reranking:n.reranking,reranking_model:l(n[`reranking-model`],`reranking-model`,`text`),retrieval_options:{keyword_match_mode:l(n[`retrieval-options-keyword-match-mode`],`retrieval-options-keyword-match-mode`,`text`)},rewrite_model:l(n[`rewrite-model`],`rewrite-model`,`text`),rewrite_query:n[`rewrite-query`],score_threshold:n[`score-threshold`],source:l(n.source,`source`,`text`),source_params:{exclude_items:n[`source-params-exclude-items`],include_items:n[`source-params-include-items`],prefix:l(n[`source-params-prefix`],`source-params-prefix`,`text`),r2_jurisdiction:l(n[`source-params-r2-jurisdiction`],`source-params-r2-jurisdiction`,`text`),web_crawler:{parse_options:{include_images:n[`source-params-web-crawler-parse-options-include-images`],specific_sitemaps:n[`source-params-web-crawler-parse-options-specific-sitemaps`],use_browser_rendering:n[`source-params-web-crawler-parse-options-use-browser-rendering`]},parse_type:l(n[`source-params-web-crawler-parse-type`],`source-params-web-crawler-parse-type`,`text`)}},token_id:l(n[`token-id`],`token-id`,`text`),type:l(n.type,`type`,`text`)});o(await c(`Creating`,async()=>u.aiSearch.create({...m,account_id:f,name:n.name})),{successLabel:`Created`})}};function b(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace name`,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 x={command:`delete <id>`,describe:`Permanently delete an AI Search instance and all its indexed data.`,builder:b,handler:async n=>{if(n.dryRun){s({command:`cf ai-search delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}`,pathParams:{id:String(n.id??``),name:String(n.name??``)},bodyKind:`none`});return}let i=await r(n),a=n.local?d:await e();if(n.accountId=a,!await m({force:!!n.force,message:`This will permanently delete the AI Search instance and all its indexed data.`})){process.stderr.write(`Aborted.
3
- `);return}o(await c(`Deleting`,async()=>i.aiSearch.delete({account_id:a,name:n.name,id:n.id})),{successLabel:`Deleted`})}};function S(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace name`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const C={command:`get <id>`,describe:`Retrieve the configuration and status of an AI Search instance.`,builder:S,handler:async n=>{if(n.dryRun){s({command:`cf ai-search get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}`,pathParams:{id:String(n.id??``),name:String(n.name??``)},bodyKind:`none`});return}let i=await r(n),a=n.local?d:await e();n.accountId=a,o(await c(`Loading`,async()=>i.aiSearch.get({account_id:a,name:n.name,id:n.id})),{successLabel:`Loaded`})}};function w(e){return e.positional(`item-id`,{type:`string`,description:`Item ID`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace name`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.`,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 T={command:`chunks <item-id>`,describe:`Lists chunks for a specific item in an AI Search instance, including their text content.`,builder:w,handler:async n=>{let i={limit:n.limit,offset:n.offset};if(n.dryRun){s({command:`cf ai-search items chunks`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}/items/${n[`item-id`]==null?`<item-id>`:encodeURIComponent(String(n[`item-id`]))}/chunks`,pathParams:{id:String(n.id??``),"item-id":String(n[`item-id`]??``),name:String(n.name??``)},query:i,bodyKind:`none`});return}let a=await r(n),l=n.local?d:await e();n.accountId=l,o(await c(`Loading`,async()=>a.aiSearch.items.chunks({account_id:l,name:n.name,id:n.id,item_id:n[`item-id`],...i})),{successLabel:`Loaded`})}};function E(e){return e.positional(`item-id`,{type:`string`,description:`Item ID`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace name`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.`,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 D={command:`delete <item-id>`,describe:`Deletes a file from a managed AI Search instance and triggers a reindex.`,builder:E,handler:async n=>{if(n.dryRun){s({command:`cf ai-search items delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}/items/${n[`item-id`]==null?`<item-id>`:encodeURIComponent(String(n[`item-id`]))}`,pathParams:{id:String(n.id??``),"item-id":String(n[`item-id`]??``),name:String(n.name??``)},bodyKind:`none`});return}let i=await r(n),a=n.local?d:await e();if(n.accountId=a,!await m({force:!!n.force})){process.stderr.write(`Aborted.
4
- `);return}o(await c(`Deleting`,async()=>i.aiSearch.items.delete({account_id:a,name:n.name,id:n.id,item_id:n[`item-id`]})),{successLabel:`Deleted`})}};function O(e){return e.positional(`item-id`,{type:`string`,description:`Item ID`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace name`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.`,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 k={command:`download <item-id>`,describe:`Downloads the raw file content for a specific item from the managed AI Search instance storage.`,builder:O,handler:async n=>{if(n.dryRun){s({command:`cf ai-search items download`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}/items/${n[`item-id`]==null?`<item-id>`:encodeURIComponent(String(n[`item-id`]))}/download`,pathParams:{id:String(n.id??``),"item-id":String(n[`item-id`]??``),name:String(n.name??``)},bodyKind:`none`});return}await r(n);let i=n.local?d:await e();n.accountId=i;let a=await c(`Loading`,async()=>te(`/accounts/${i}/ai-search/namespaces/${encodeURIComponent(String(n.name))}/instances/${encodeURIComponent(String(n.id))}/items/${encodeURIComponent(String(n[`item-id`]))}/download`,{method:`GET`,localEndpoint:n.local?n.localEndpoint:void 0}));ee(n.text===!0?a.toString(`utf-8`):a)}};function A(e){return e.positional(`item-id`,{type:`string`,description:`Item ID`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace name`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const j={command:`get <item-id>`,describe:`Retrieves a specific indexed item from an AI Search instance.`,builder:A,handler:async n=>{if(n.dryRun){s({command:`cf ai-search items get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}/items/${n[`item-id`]==null?`<item-id>`:encodeURIComponent(String(n[`item-id`]))}`,pathParams:{id:String(n.id??``),"item-id":String(n[`item-id`]??``),name:String(n.name??``)},bodyKind:`none`});return}let i=await r(n),a=n.local?d:await e();n.accountId=a,o(await c(`Loading`,async()=>i.aiSearch.items.get({account_id:a,name:n.name,id:n.id,item_id:n[`item-id`]})),{successLabel:`Loaded`})}};function M(e){return e.option(`name`,{type:`string`,description:`Namespace name`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.`,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 N={command:`list`,describe:`Lists indexed items in an AI Search instance.`,builder:h(M),handler:async n=>{let i={page:n.page,per_page:n[`per-page`],search:n.search,sort_by:n[`sort-by`],status:n.status,source:n.source,metadata_filter:n[`metadata-filter`],item_id:n[`item-id`],key:n.key};if(n.dryRun){s({command:`cf ai-search items list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}/items`,pathParams:{id:String(n.id??``),name:String(n.name??``)},query:i,bodyKind:`none`});return}let a=await r(n),l=n.local?d:await e();n.accountId=l,o(await c(`Loading`,async()=>a.aiSearch.items.list({account_id:l,name:n.name,id:n.id,...i})),{successLabel:`Loaded`})}};function P(e){return e.positional(`item-id`,{type:`string`,description:`Item ID`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace name`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.`,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 F={command:`logs <item-id>`,describe:`Lists processing logs for a specific item in an AI Search instance.`,builder:P,handler:async n=>{let i={limit:n.limit,cursor:n.cursor};if(n.dryRun){s({command:`cf ai-search items logs`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}/items/${n[`item-id`]==null?`<item-id>`:encodeURIComponent(String(n[`item-id`]))}/logs`,pathParams:{id:String(n.id??``),"item-id":String(n[`item-id`]??``),name:String(n.name??``)},query:i,bodyKind:`none`});return}let a=await r(n),l=n.local?d:await e();n.accountId=l,o(await c(`Loading`,async()=>a.aiSearch.items.logs({account_id:l,name:n.name,id:n.id,item_id:n[`item-id`],...i})),{successLabel:`Loaded`})}};function I(e){return e.positional(`item-id`,{type:`string`,description:`Item ID`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace name`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.`,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 L={command:`sync <item-id>`,describe:`Syncs an item to an AI Search instance index.`,builder:I,handler:async n=>{if(n.dryRun){s({command:`cf ai-search items sync`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}/items/${n[`item-id`]==null?`<item-id>`:encodeURIComponent(String(n[`item-id`]))}`,pathParams:{id:String(n.id??``),"item-id":String(n[`item-id`]??``),name:String(n.name??``)},bodyKind:`json`,body:n.body===void 0?a({next_action:l(n[`next-action`],`next-action`,`text`),wait_for_completion:n[`wait-for-completion`]}):i(n.body)});return}let u=await r(n),p=n.local?d:await e();if(n.accountId=p,n.body){let e=i(n.body);o(await c(`Updating`,async()=>u.aiSearch.items.sync({...e,account_id:p,name:n.name,id:n.id,item_id:n[`item-id`]})),{successLabel:`Updated`});return}n[`next-action`]===void 0&&(n[`next-action`]=await f(`next-action`,`The next_action field`,[`INDEX`]));let m=a({next_action:l(n[`next-action`],`next-action`,`text`),wait_for_completion:n[`wait-for-completion`]});o(await c(`Updating`,async()=>u.aiSearch.items.sync({...m,account_id:p,name:n.name,id:n.id,item_id:n[`item-id`]})),{successLabel:`Updated`})}};function R(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace name`,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 z={command:`upload <id>`,describe:`Uploads a file to a managed AI Search instance via multipart/form-data.`,builder:R,handler:async i=>{if(i.dryRun){s({command:`cf ai-search items upload`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-search/namespaces/${i.name==null?`<name>`:encodeURIComponent(String(i.name))}/instances/${i.id==null?`<id>`:encodeURIComponent(String(i.id))}/items`,pathParams:{id:String(i.id??``),name:String(i.name??``)},bodyKind:`multipart`,body:{body:i.body,file:i.file,metadata:i.metadata,"wait-for-completion":i[`wait-for-completion`]}});return}let a=await r(i),f=i.local?d:await e();if(i.accountId=f,i.file!==void 0||i.body!==void 0||i.metadata!==void 0||i[`wait-for-completion`]!==void 0){let e=new FormData;if(i.file){let t=u(i.file);e.append(`file`,new Blob([t]),i.file.split(/[\\/]/).filter(Boolean).pop())}else i.body!==void 0&&e.append(`file`,i.body);i.metadata!==void 0&&e.append(`metadata`,String(l(i.metadata,`metadata`,`text`)??``)),i[`wait-for-completion`]!==void 0&&e.append(`wait_for_completion`,String(i[`wait-for-completion`])),o(await c(`Creating`,async()=>n(a,`POST`,`/accounts/${f}/ai-search/namespaces/${encodeURIComponent(String(i.name))}/instances/${encodeURIComponent(String(i.id))}/items`,{body:e})),{successLabel:`Created`});return}if(i.body){let e=l(i.body,`body`,`binary`);o(await c(`Creating`,async()=>n(a,`POST`,`/accounts/${f}/ai-search/namespaces/${encodeURIComponent(String(i.name))}/instances/${encodeURIComponent(String(i.id))}/items`,{body:e,headers:{"Content-Type":`multipart/form-data`}})),{successLabel:`Created`});return}if(i.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}};function B(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace name`,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 V={command:`upsert <id>`,describe:`Creates or updates an indexed item in an AI Search instance.`,builder:B,handler:async n=>{if(n.dryRun){s({command:`cf ai-search items upsert`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}/items`,pathParams:{id:String(n.id??``),name:String(n.name??``)},bodyKind:`json`,body:n.body===void 0?a({key:l(n.key,`key`,`text`),next_action:l(n[`next-action`],`next-action`,`text`),wait_for_completion:n[`wait-for-completion`]}):i(n.body)});return}let u=await r(n),m=n.local?d:await e();if(n.accountId=m,n.body){let e=i(n.body);o(await c(`Updating`,async()=>u.aiSearch.items.upsert({...e,account_id:m,name:n.name,id:n.id})),{successLabel:`Updated`});return}n.key===void 0&&(n.key=await p(`key`,`Item key / filename. Must not exceed 128 characters.`)),n[`next-action`]===void 0&&(n[`next-action`]=await f(`next-action`,`The next_action field`,[`INDEX`]));let h=a({key:l(n.key,`key`,`text`),next_action:l(n[`next-action`],`next-action`,`text`),wait_for_completion:n[`wait-for-completion`]});o(await c(`Updating`,async()=>u.aiSearch.items.upsert({...h,account_id:m,name:n.name,id:n.id})),{successLabel:`Updated`})}},H={command:`items`,describe:`Operations for items`,builder:e=>e.command(T).command(D).command(k).command(j).command(N).command(F).command(L).command(z).command(V).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function U(e){return e.positional(`job-id`,{type:`string`,description:`Job ID`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace name`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.`,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 W={command:`cancel <job-id>`,describe:`Cancel an in-progress indexing job for an AI Search instance.`,builder:U,handler:async n=>{if(n.dryRun){s({command:`cf ai-search jobs cancel`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}/jobs/${n[`job-id`]==null?`<job-id>`:encodeURIComponent(String(n[`job-id`]))}`,pathParams:{id:String(n.id??``),"job-id":String(n[`job-id`]??``),name:String(n.name??``)},bodyKind:`json`,body:n.body===void 0?a({action:l(n.action,`action`,`text`)}):i(n.body)});return}let u=await r(n),p=n.local?d:await e();if(n.accountId=p,!await m({force:!!n.force,message:`This will cancel the running indexing job.`})){process.stderr.write(`Aborted.
5
- `);return}if(n.body){let e=i(n.body);o(await c(`Deleting`,async()=>u.aiSearch.jobs.cancel({...e,account_id:p,name:n.name,id:n.id,job_id:n[`job-id`]})),{successLabel:`Deleted`});return}n.action===void 0&&(n.action=await f(`action`,`The action field`,[`cancel`]));let h=a({action:l(n.action,`action`,`text`)});o(await c(`Deleting`,async()=>u.aiSearch.jobs.cancel({...h,account_id:p,name:n.name,id:n.id,job_id:n[`job-id`]})),{successLabel:`Deleted`})}};function G(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace name`,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 K={command:`create <id>`,describe:`Creates a new indexing job for an AI Search instance.`,builder:G,handler:async n=>{if(n.dryRun){s({command:`cf ai-search jobs create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}/jobs`,pathParams:{id:String(n.id??``),name:String(n.name??``)},bodyKind:`json`,body:n.body===void 0?a({description:l(n.description,`description`,`text`)}):i(n.body)});return}let u=await r(n),f=n.local?d:await e();if(n.accountId=f,n.body){let e=i(n.body);o(await c(`Creating`,async()=>u.aiSearch.jobs.create({...e,account_id:f,name:n.name,id:n.id})),{successLabel:`Created`});return}let p=a({description:l(n.description,`description`,`text`)});o(await c(`Creating`,async()=>u.aiSearch.jobs.create({...p,account_id:f,name:n.name,id:n.id})),{successLabel:`Created`})}};function q(e){return e.positional(`job-id`,{type:`string`,description:`Job ID`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace name`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const J={command:`get <job-id>`,describe:`Retrieves details for a specific AI Search indexing job.`,builder:q,handler:async n=>{if(n.dryRun){s({command:`cf ai-search jobs get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}/jobs/${n[`job-id`]==null?`<job-id>`:encodeURIComponent(String(n[`job-id`]))}`,pathParams:{id:String(n.id??``),"job-id":String(n[`job-id`]??``),name:String(n.name??``)},bodyKind:`none`});return}let i=await r(n),a=n.local?d:await e();n.accountId=a,o(await c(`Loading`,async()=>i.aiSearch.jobs.get({account_id:a,name:n.name,id:n.id,job_id:n[`job-id`]})),{successLabel:`Loaded`})}};function Y(e){return e.option(`name`,{type:`string`,description:`Namespace name`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.`,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 X={command:`list`,describe:`Lists indexing jobs for an AI Search instance.`,builder:Y,handler:async n=>{let i={page:n.page,per_page:n[`per-page`]};if(n.dryRun){s({command:`cf ai-search jobs list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}/jobs`,pathParams:{id:String(n.id??``),name:String(n.name??``)},query:i,bodyKind:`none`});return}let a=await r(n),l=n.local?d:await e();n.accountId=l,o(await c(`Loading`,async()=>a.aiSearch.jobs.list({account_id:l,name:n.name,id:n.id,...i})),{successLabel:`Loaded`})}};function Z(e){return e.positional(`job-id`,{type:`string`,description:`Job ID`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace name`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.`,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:`logs <job-id>`,describe:`Lists log entries for an AI Search indexing job.`,builder:Z,handler:async n=>{let i={page:n.page,per_page:n[`per-page`]};if(n.dryRun){s({command:`cf ai-search jobs logs`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}/jobs/${n[`job-id`]==null?`<job-id>`:encodeURIComponent(String(n[`job-id`]))}/logs`,pathParams:{id:String(n.id??``),"job-id":String(n[`job-id`]??``),name:String(n.name??``)},query:i,bodyKind:`none`});return}let a=await r(n),l=n.local?d:await e();n.accountId=l,o(await c(`Loading`,async()=>a.aiSearch.jobs.logs({account_id:l,name:n.name,id:n.id,job_id:n[`job-id`],...i})),{successLabel:`Loaded`})}},ne={command:`jobs`,describe:`Operations for jobs`,builder:e=>e.command(W).command(K).command(J).command(X).command(Q).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function re(e){return e.option(`name`,{type:`string`,description:`Namespace name`,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(`namespace`,{type:`string`,description:`Filter by namespace.`}).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 ie={command:`list`,describe:`List all AI Search instances in the account.`,builder:h(re),handler:async n=>{let i={page:n.page,per_page:n[`per-page`],search:n.search,namespace:n.namespace,order_by:n[`order-by`],order_by_direction:n[`order-by-direction`]};if(n.dryRun){s({command:`cf ai-search list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances`,pathParams:{name:String(n.name??``)},query:i,bodyKind:`none`});return}let a=await r(n),l=n.local?d:await e();n.accountId=l,o(await c(`Loading`,async()=>a.aiSearch.list({account_id:l,name:n.name,...i})),{successLabel:`Loaded`})}};function ae(e){return e.positional(`id`,{type:`string`,description:`Instance id.`,demandOption:!0}).option(`name`,{type:`string`,description:`Current namespace of the instance.`,demandOption:!0}).option(`new-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 oe={command:`move <id>`,describe:`Moves an instance from its current namespace to the specified target namespace. Use 'default' as new_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:ae,handler:async n=>{if(n.dryRun){s({command:`cf ai-search move`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}`,pathParams:{name:String(n.name??``),id:String(n.id??``)},bodyKind:`json`,body:n.body===void 0?a({new_namespace:l(n[`new-namespace`],`new-namespace`,`text`)}):i(n.body)});return}let u=await r(n),f=n.local?d:await e();if(n.accountId=f,n.body){let e=i(n.body);o(await c(`Updating`,async()=>u.aiSearch.move({...e,account_id:f,name:n.name,id:n.id})),{successLabel:`Updated`});return}n[`new-namespace`]===void 0&&(n[`new-namespace`]=await p(`new-namespace`,`Target namespace to move the instance into.`));let m=a({new_namespace:l(n[`new-namespace`],`new-namespace`,`text`)});o(await c(`Updating`,async()=>u.aiSearch.move({...m,account_id:f,name:n.name,id:n.id})),{successLabel:`Updated`})}};function se(e){return e.positional(`name`,{type:`string`,description:`Namespace name`,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-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-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(`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 ce={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:se,handler:async n=>{if(n.dryRun){s({command:`cf ai-search multi-chat-completions`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/chat/completions`,pathParams:{name:String(n.name??``)},bodyKind:`json`,body:n.body===void 0?a({ai_search_options:{cache:{cache_threshold:l(n[`ai-search-options-cache-cache-threshold`],`ai-search-options-cache-cache-threshold`,`text`),enabled:n[`ai-search-options-cache-enabled`]},instance_ids:n[`ai-search-options-instance-ids`],query_rewrite:{enabled:n[`ai-search-options-query-rewrite-enabled`],rewrite_prompt:l(n[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:n[`ai-search-options-reranking-enabled`],match_threshold:n[`ai-search-options-reranking-match-threshold`]},retrieval:{context_expansion:n[`ai-search-options-retrieval-context-expansion`],fusion_method:l(n[`ai-search-options-retrieval-fusion-method`],`ai-search-options-retrieval-fusion-method`,`text`),keyword_match_mode:l(n[`ai-search-options-retrieval-keyword-match-mode`],`ai-search-options-retrieval-keyword-match-mode`,`text`),match_threshold:n[`ai-search-options-retrieval-match-threshold`],max_num_results:n[`ai-search-options-retrieval-max-num-results`],retrieval_type:l(n[`ai-search-options-retrieval-retrieval-type`],`ai-search-options-retrieval-retrieval-type`,`text`),return_on_failure:n[`ai-search-options-retrieval-return-on-failure`]}},stream:n.stream}):i(n.body)});return}let u=await r(n),f=n.local?d:await e();if(n.accountId=f,n.body){let e=i(n.body);o(await c(`Creating`,async()=>u.aiSearch.multiChatCompletions({...e,account_id:f,name:n.name})),{successLabel:`Created`});return}if(n[`ai-search-options-instance-ids`]===void 0)throw Error(`--ai-search-options-instance-ids is required (or pass --body with this field set).`);let p=a({ai_search_options:{cache:{cache_threshold:l(n[`ai-search-options-cache-cache-threshold`],`ai-search-options-cache-cache-threshold`,`text`),enabled:n[`ai-search-options-cache-enabled`]},instance_ids:n[`ai-search-options-instance-ids`],query_rewrite:{enabled:n[`ai-search-options-query-rewrite-enabled`],rewrite_prompt:l(n[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:n[`ai-search-options-reranking-enabled`],match_threshold:n[`ai-search-options-reranking-match-threshold`]},retrieval:{context_expansion:n[`ai-search-options-retrieval-context-expansion`],fusion_method:l(n[`ai-search-options-retrieval-fusion-method`],`ai-search-options-retrieval-fusion-method`,`text`),keyword_match_mode:l(n[`ai-search-options-retrieval-keyword-match-mode`],`ai-search-options-retrieval-keyword-match-mode`,`text`),match_threshold:n[`ai-search-options-retrieval-match-threshold`],max_num_results:n[`ai-search-options-retrieval-max-num-results`],retrieval_type:l(n[`ai-search-options-retrieval-retrieval-type`],`ai-search-options-retrieval-retrieval-type`,`text`),return_on_failure:n[`ai-search-options-retrieval-return-on-failure`]}},stream:n.stream});o(await c(`Creating`,async()=>u.aiSearch.multiChatCompletions({...p,account_id:f,name:n.name})),{successLabel:`Created`})}};function le(e){return e.positional(`name`,{type:`string`,description:`Namespace name`,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-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-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(`query`,{type:`string`,description:`A simple text query string. Alternative to 'messages' — provide either this or 'messages', not both.`}).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-search <name>`,describe:`Performs a semantic search query against multiple AI Search instances in parallel, merging the retrieved results into a single ranked response.`,builder:le,handler:async n=>{if(n.dryRun){s({command:`cf ai-search multi-search`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/search`,pathParams:{name:String(n.name??``)},bodyKind:`json`,body:n.body===void 0?a({ai_search_options:{cache:{cache_threshold:l(n[`ai-search-options-cache-cache-threshold`],`ai-search-options-cache-cache-threshold`,`text`),enabled:n[`ai-search-options-cache-enabled`]},instance_ids:n[`ai-search-options-instance-ids`],query_rewrite:{enabled:n[`ai-search-options-query-rewrite-enabled`],rewrite_prompt:l(n[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:n[`ai-search-options-reranking-enabled`],match_threshold:n[`ai-search-options-reranking-match-threshold`]},retrieval:{context_expansion:n[`ai-search-options-retrieval-context-expansion`],fusion_method:l(n[`ai-search-options-retrieval-fusion-method`],`ai-search-options-retrieval-fusion-method`,`text`),keyword_match_mode:l(n[`ai-search-options-retrieval-keyword-match-mode`],`ai-search-options-retrieval-keyword-match-mode`,`text`),match_threshold:n[`ai-search-options-retrieval-match-threshold`],max_num_results:n[`ai-search-options-retrieval-max-num-results`],retrieval_type:l(n[`ai-search-options-retrieval-retrieval-type`],`ai-search-options-retrieval-retrieval-type`,`text`),return_on_failure:n[`ai-search-options-retrieval-return-on-failure`]}},query:l(n.query,`query`,`text`)}):i(n.body)});return}let u=await r(n),f=n.local?d:await e();if(n.accountId=f,n.body){let e=i(n.body);o(await c(`Creating`,async()=>u.aiSearch.multiSearch({...e,account_id:f,name:n.name})),{successLabel:`Created`});return}if(n[`ai-search-options-instance-ids`]===void 0)throw Error(`--ai-search-options-instance-ids is required (or pass --body with this field set).`);let p=a({ai_search_options:{cache:{cache_threshold:l(n[`ai-search-options-cache-cache-threshold`],`ai-search-options-cache-cache-threshold`,`text`),enabled:n[`ai-search-options-cache-enabled`]},instance_ids:n[`ai-search-options-instance-ids`],query_rewrite:{enabled:n[`ai-search-options-query-rewrite-enabled`],rewrite_prompt:l(n[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:n[`ai-search-options-reranking-enabled`],match_threshold:n[`ai-search-options-reranking-match-threshold`]},retrieval:{context_expansion:n[`ai-search-options-retrieval-context-expansion`],fusion_method:l(n[`ai-search-options-retrieval-fusion-method`],`ai-search-options-retrieval-fusion-method`,`text`),keyword_match_mode:l(n[`ai-search-options-retrieval-keyword-match-mode`],`ai-search-options-retrieval-keyword-match-mode`,`text`),match_threshold:n[`ai-search-options-retrieval-match-threshold`],max_num_results:n[`ai-search-options-retrieval-max-num-results`],retrieval_type:l(n[`ai-search-options-retrieval-retrieval-type`],`ai-search-options-retrieval-retrieval-type`,`text`),return_on_failure:n[`ai-search-options-retrieval-return-on-failure`]}},query:l(n.query,`query`,`text`)});o(await c(`Creating`,async()=>u.aiSearch.multiSearch({...p,account_id:f,name:n.name})),{successLabel:`Created`})}};function de(e){return e.option(`description`,{type:`string`,description:`Optional description for the namespace. Max 256 characters.`}).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:`create`,describe:`Create a new namespace.`,builder:de,handler:async n=>{if(n.dryRun){s({command:`cf ai-search namespace create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-search/namespaces`,pathParams:{},bodyKind:`json`,body:n.body===void 0?a({description:l(n.description,`description`,`text`),name:l(n.name,`name`,`text`)}):i(n.body)});return}let u=await r(n),f=n.local?d:await e();if(n.accountId=f,n.body){let e=i(n.body);o(await c(`Creating`,async()=>u.aiSearch.namespace.create({...e,account_id:f})),{successLabel:`Created`});return}n.name===void 0&&(n.name=await p(`name`,`The name field`));let m=a({description:l(n.description,`description`,`text`),name:l(n.name,`name`,`text`)});o(await c(`Creating`,async()=>u.aiSearch.namespace.create({...m,account_id:f})),{successLabel:`Created`})}};function pe(e){return e.positional(`name`,{type:`string`,description:`Name`,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 me={command:`delete <name>`,describe:`Permanently delete a namespace. The namespace must be empty (no instances).`,builder:pe,handler:async n=>{if(n.dryRun){s({command:`cf ai-search namespace delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}`,pathParams:{name:String(n.name??``)},bodyKind:`none`});return}let i=await r(n),a=n.local?d:await e();if(n.accountId=a,!await m({force:!!n.force,message:`This will permanently delete the namespace.`})){process.stderr.write(`Aborted.
6
- `);return}o(await c(`Deleting`,async()=>i.aiSearch.namespace.delete({account_id:a,name:n.name})),{successLabel:`Deleted`})}};function he(e){return e.positional(`name`,{type:`string`,description:`Name`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const ge={command:`get <name>`,describe:`Read namespace.`,builder:he,handler:async n=>{if(n.dryRun){s({command:`cf ai-search namespace get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}`,pathParams:{name:String(n.name??``)},bodyKind:`none`});return}let i=await r(n),a=n.local?d:await e();n.accountId=a,o(await c(`Loading`,async()=>i.aiSearch.namespace.get({account_id:a,name:n.name})),{successLabel:`Loaded`})}};function _e(e){return e.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 namespaces whose name or description contains this string (case-insensitive).`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const ve={command:`list`,describe:`List namespaces.`,builder:_e,handler:async n=>{let i={page:n.page,per_page:n[`per-page`],search:n.search};if(n.dryRun){s({command:`cf ai-search namespace list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-search/namespaces`,pathParams:{},query:i,bodyKind:`none`});return}let a=await r(n),l=n.local?d:await e();n.accountId=l,o(await c(`Loading`,async()=>a.aiSearch.namespace.list({account_id:l,...i})),{successLabel:`Loaded`})}};function ye(e){return e.positional(`name`,{type:`string`,description:`Name`,demandOption:!0}).option(`description`,{type:`string`,description:`Optional description for the namespace. Max 256 characters.`}).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:`update <name>`,describe:`Update namespace.`,builder:ye,handler:async n=>{if(n.dryRun){s({command:`cf ai-search namespace update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}`,pathParams:{name:String(n.name??``)},bodyKind:`json`,body:n.body===void 0?a({description:l(n.description,`description`,`text`)}):i(n.body)});return}let u=await r(n),f=n.local?d:await e();if(n.accountId=f,n.body){let e=i(n.body);o(await c(`Updating`,async()=>u.aiSearch.namespace.update({...e,account_id:f,name:n.name})),{successLabel:`Updated`});return}let p=a({description:l(n.description,`description`,`text`)});o(await c(`Updating`,async()=>u.aiSearch.namespace.update({...p,account_id:f,name:n.name})),{successLabel:`Updated`})}},xe={command:`namespace`,describe:`Operations for namespace`,builder:e=>e.command(fe).command(me).command(ge).command(ve).command(be).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Se(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace name`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Ce={command:`purge-cache <id>`,describe:`Purges all cached search results for an AI Search instance. A new internal cache key is generated, immediately orphaning all prior cached entries.`,builder:Se,handler:async n=>{if(n.dryRun){s({command:`cf ai-search purge-cache`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}/purge_cache`,pathParams:{id:String(n.id??``),name:String(n.name??``)},bodyKind:`none`});return}let i=await r(n),a=n.local?d:await e();n.accountId=a,o(await c(`Creating`,async()=>i.aiSearch.purgeCache({account_id:a,name:n.name,id:n.id})),{successLabel:`Created`})}};function we(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace name`,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-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-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(`query`,{type:`string`,description:`A simple text query string. Alternative to 'messages' — provide either this or 'messages', not both.`}).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:`search <id>`,describe:`Executes a semantic search query against an AI Search instance to find relevant indexed content.`,builder:we,handler:async n=>{if(n.dryRun){s({command:`cf ai-search search`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}/search`,pathParams:{id:String(n.id??``),name:String(n.name??``)},bodyKind:`json`,body:n.body===void 0?a({ai_search_options:{cache:{cache_threshold:l(n[`ai-search-options-cache-cache-threshold`],`ai-search-options-cache-cache-threshold`,`text`),enabled:n[`ai-search-options-cache-enabled`]},query_rewrite:{enabled:n[`ai-search-options-query-rewrite-enabled`],rewrite_prompt:l(n[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:n[`ai-search-options-reranking-enabled`],match_threshold:n[`ai-search-options-reranking-match-threshold`]},retrieval:{context_expansion:n[`ai-search-options-retrieval-context-expansion`],fusion_method:l(n[`ai-search-options-retrieval-fusion-method`],`ai-search-options-retrieval-fusion-method`,`text`),keyword_match_mode:l(n[`ai-search-options-retrieval-keyword-match-mode`],`ai-search-options-retrieval-keyword-match-mode`,`text`),match_threshold:n[`ai-search-options-retrieval-match-threshold`],max_num_results:n[`ai-search-options-retrieval-max-num-results`],retrieval_type:l(n[`ai-search-options-retrieval-retrieval-type`],`ai-search-options-retrieval-retrieval-type`,`text`),return_on_failure:n[`ai-search-options-retrieval-return-on-failure`]}},query:l(n.query,`query`,`text`)}):i(n.body)});return}let u=await r(n),f=n.local?d:await e();if(n.accountId=f,n.body){let e=i(n.body);o(await c(`Loading`,async()=>u.aiSearch.search({...e,account_id:f,name:n.name,id:n.id})),{successLabel:`Loaded`});return}let p=a({ai_search_options:{cache:{cache_threshold:l(n[`ai-search-options-cache-cache-threshold`],`ai-search-options-cache-cache-threshold`,`text`),enabled:n[`ai-search-options-cache-enabled`]},query_rewrite:{enabled:n[`ai-search-options-query-rewrite-enabled`],rewrite_prompt:l(n[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:n[`ai-search-options-reranking-enabled`],match_threshold:n[`ai-search-options-reranking-match-threshold`]},retrieval:{context_expansion:n[`ai-search-options-retrieval-context-expansion`],fusion_method:l(n[`ai-search-options-retrieval-fusion-method`],`ai-search-options-retrieval-fusion-method`,`text`),keyword_match_mode:l(n[`ai-search-options-retrieval-keyword-match-mode`],`ai-search-options-retrieval-keyword-match-mode`,`text`),match_threshold:n[`ai-search-options-retrieval-match-threshold`],max_num_results:n[`ai-search-options-retrieval-max-num-results`],retrieval_type:l(n[`ai-search-options-retrieval-retrieval-type`],`ai-search-options-retrieval-retrieval-type`,`text`),return_on_failure:n[`ai-search-options-retrieval-return-on-failure`]}},query:l(n.query,`query`,`text`)});o(await c(`Loading`,async()=>u.aiSearch.search({...p,account_id:f,name:n.name,id:n.id})),{successLabel:`Loaded`})}};function Ee(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace name`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const De={command:`stats <id>`,describe:`Retrieve usage and indexing statistics for an AI Search instance.`,builder:Ee,handler:async n=>{if(n.dryRun){s({command:`cf ai-search stats`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}/stats`,pathParams:{id:String(n.id??``),name:String(n.name??``)},bodyKind:`none`});return}let i=await r(n),a=n.local?d:await e();n.accountId=a,o(await c(`Loading`,async()=>i.aiSearch.stats({account_id:a,name:n.name,id:n.id})),{successLabel:`Loaded`})}};function $(e){return e.option(`cf-api-id`,{type:`string`,description:`The cf_api_id field`}).option(`cf-api-key`,{type:`string`,description:`The cf_api_key field`}).option(`legacy`,{type:`boolean`,description:`The legacy field`,default:!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 Oe={command:`create`,describe:`Create a new token.`,builder:$,handler:async n=>{if(n.dryRun){s({command:`cf ai-search tokens create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-search/tokens`,pathParams:{},bodyKind:`json`,body:n.body===void 0?a({cf_api_id:l(n[`cf-api-id`],`cf-api-id`,`text`),cf_api_key:l(n[`cf-api-key`],`cf-api-key`,`text`),legacy:n.legacy,name:l(n.name,`name`,`text`)}):i(n.body)});return}let u=await r(n),f=n.local?d:await e();if(n.accountId=f,n.body){let e=i(n.body);o(await c(`Creating`,async()=>u.aiSearch.tokens.create({...e,account_id:f})),{successLabel:`Created`});return}n[`cf-api-id`]===void 0&&(n[`cf-api-id`]=await p(`cf-api-id`,`The cf_api_id field`)),n[`cf-api-key`]===void 0&&(n[`cf-api-key`]=await p(`cf-api-key`,`The cf_api_key field`,{kind:`secret`})),n.name===void 0&&(n.name=await p(`name`,`The name field`));let m=a({cf_api_id:l(n[`cf-api-id`],`cf-api-id`,`text`),cf_api_key:l(n[`cf-api-key`],`cf-api-key`,`text`),legacy:n.legacy,name:l(n.name,`name`,`text`)});o(await c(`Creating`,async()=>u.aiSearch.tokens.create({...m,account_id:f})),{successLabel:`Created`})}};function ke(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 Ae={command:`delete <id>`,describe:`Delete token.`,builder:ke,handler:async n=>{if(n.dryRun){s({command:`cf ai-search tokens delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-search/tokens/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}`,pathParams:{id:String(n.id??``)},bodyKind:`none`});return}let i=await r(n),a=n.local?d:await e();if(n.accountId=a,!await m({force:!!n.force})){process.stderr.write(`Aborted.
7
- `);return}o(await c(`Deleting`,async()=>i.aiSearch.tokens.delete({account_id:a,id:n.id})),{successLabel:`Deleted`})}};function je(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 Me={command:`get <id>`,describe:`Read token.`,builder:je,handler:async n=>{if(n.dryRun){s({command:`cf ai-search tokens get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-search/tokens/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}`,pathParams:{id:String(n.id??``)},bodyKind:`none`});return}let i=await r(n),a=n.local?d:await e();n.accountId=a,o(await c(`Loading`,async()=>i.aiSearch.tokens.get({account_id:a,id:n.id})),{successLabel:`Loaded`})}};function Ne(e){return e.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 tokens whose name contains this string (case-insensitive).`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Pe={command:`list`,describe:`List tokens.`,builder:Ne,handler:async n=>{let i={page:n.page,per_page:n[`per-page`],search:n.search};if(n.dryRun){s({command:`cf ai-search tokens list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-search/tokens`,pathParams:{},query:i,bodyKind:`none`});return}let a=await r(n),l=n.local?d:await e();n.accountId=l,o(await c(`Loading`,async()=>a.aiSearch.tokens.list({account_id:l,...i})),{successLabel:`Loaded`})}};function Fe(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`cf-api-id`,{type:`string`,description:`The cf_api_id field`}).option(`cf-api-key`,{type:`string`,description:`The cf_api_key field`}).option(`legacy`,{type:`boolean`,description:`The legacy 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 Ie={command:`update <id>`,describe:`Update token.`,builder:Fe,handler:async n=>{if(n.dryRun){s({command:`cf ai-search tokens update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-search/tokens/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}`,pathParams:{id:String(n.id??``)},bodyKind:`json`,body:n.body===void 0?a({cf_api_id:l(n[`cf-api-id`],`cf-api-id`,`text`),cf_api_key:l(n[`cf-api-key`],`cf-api-key`,`text`),legacy:n.legacy,name:l(n.name,`name`,`text`)}):i(n.body)});return}let u=await r(n),f=n.local?d:await e();if(n.accountId=f,n.body){let e=i(n.body);o(await c(`Updating`,async()=>u.aiSearch.tokens.update({...e,account_id:f,id:n.id})),{successLabel:`Updated`});return}n[`cf-api-id`]===void 0&&(n[`cf-api-id`]=await p(`cf-api-id`,`The cf_api_id field`)),n[`cf-api-key`]===void 0&&(n[`cf-api-key`]=await p(`cf-api-key`,`The cf_api_key field`,{kind:`secret`})),n.name===void 0&&(n.name=await p(`name`,`The name field`));let m=a({cf_api_id:l(n[`cf-api-id`],`cf-api-id`,`text`),cf_api_key:l(n[`cf-api-key`],`cf-api-key`,`text`),legacy:n.legacy,name:l(n.name,`name`,`text`)});o(await c(`Updating`,async()=>u.aiSearch.tokens.update({...m,account_id:f,id:n.id})),{successLabel:`Updated`})}},Le={command:`tokens`,describe:`Operations for tokens`,builder:e=>e.command(Oe).command(Ae).command(Me).command(Pe).command(Ie).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Re(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace name`,demandOption:!0}).option(`ai-gateway-id`,{type:`string`,description:`The ai_gateway_id field`}).option(`ai-search-model`,{type:`string`,description:`The ai_search_model field`,choices:`@cf/meta/llama-3.3-70b-instruct-fp8-fast,@cf/zai-org/glm-4.7-flash,@cf/meta/llama-3.1-8b-instruct-fast,@cf/meta/llama-3.1-8b-instruct-fp8,@cf/meta/llama-4-scout-17b-16e-instruct,@cf/qwen/qwen3-30b-a3b-fp8,@cf/deepseek-ai/deepseek-r1-distill-qwen-32b,@cf/moonshotai/kimi-k2-instruct,@cf/google/gemma-3-12b-it,@cf/google/gemma-4-26b-a4b-it,@cf/moonshotai/kimi-k2.5,anthropic/claude-3-7-sonnet,anthropic/claude-sonnet-4,anthropic/claude-opus-4,anthropic/claude-3-5-haiku,cerebras/qwen-3-235b-a22b-instruct,cerebras/qwen-3-235b-a22b-thinking,cerebras/llama-3.3-70b,cerebras/llama-4-maverick-17b-128e-instruct,cerebras/llama-4-scout-17b-16e-instruct,cerebras/gpt-oss-120b,google-ai-studio/gemini-2.5-flash,google-ai-studio/gemini-2.5-pro,grok/grok-4,groq/llama-3.3-70b-versatile,groq/llama-3.1-8b-instant,openai/gpt-5,openai/gpt-5-mini,openai/gpt-5-nano`.split(`,`)}).option(`cache`,{type:`boolean`,description:`The cache field`}).option(`cache-threshold`,{type:`string`,description:`The cache_threshold field`,choices:[`super_strict_match`,`close_enough`,`flexible_friend`,`anything_goes`]}).option(`chunk`,{type:`boolean`,description:`The chunk field`}).option(`chunk-overlap`,{type:`number`,description:`The chunk_overlap field`}).option(`chunk-size`,{type:`number`,description:`The chunk_size field`}).option(`embedding-model`,{type:`string`,description:`The embedding_model field`,choices:[`@cf/qwen/qwen3-embedding-0.6b`,`@cf/qwen/qwen3-vl-embedding-2b`,`@cf/baai/bge-m3`,`@cf/baai/bge-large-en-v1.5`,`@cf/google/embeddinggemma-300m`,`google-ai-studio/gemini-embedding-001`,`google-ai-studio/gemini-embedding-2-preview`,`google-ai-studio/gemini-embedding-2`,`openai/text-embedding-3-small`,`openai/text-embedding-3-large`]}).option(`fusion-method`,{type:`string`,description:`The fusion_method field`,choices:[`max`,`rrf`]}).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(`max-num-results`,{type:`number`,description:`The max_num_results field`}).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(`paused`,{type:`boolean`,description:`The paused 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`}).option(`reranking-model`,{type:`string`,description:`The reranking_model field`,choices:[`@cf/baai/bge-reranker-base`]}).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:`The rewrite_model field`,choices:`@cf/meta/llama-3.3-70b-instruct-fp8-fast,@cf/zai-org/glm-4.7-flash,@cf/meta/llama-3.1-8b-instruct-fast,@cf/meta/llama-3.1-8b-instruct-fp8,@cf/meta/llama-4-scout-17b-16e-instruct,@cf/qwen/qwen3-30b-a3b-fp8,@cf/deepseek-ai/deepseek-r1-distill-qwen-32b,@cf/moonshotai/kimi-k2-instruct,@cf/google/gemma-3-12b-it,@cf/google/gemma-4-26b-a4b-it,@cf/moonshotai/kimi-k2.5,anthropic/claude-3-7-sonnet,anthropic/claude-sonnet-4,anthropic/claude-opus-4,anthropic/claude-3-5-haiku,cerebras/qwen-3-235b-a22b-instruct,cerebras/qwen-3-235b-a22b-thinking,cerebras/llama-3.3-70b,cerebras/llama-4-maverick-17b-128e-instruct,cerebras/llama-4-scout-17b-16e-instruct,cerebras/gpt-oss-120b,google-ai-studio/gemini-2.5-flash,google-ai-studio/gemini-2.5-pro,grok/grok-4,groq/llama-3.3-70b-versatile,groq/llama-3.1-8b-instant,openai/gpt-5,openai/gpt-5-mini,openai/gpt-5-nano`.split(`,`)}).option(`rewrite-query`,{type:`boolean`,description:`The rewrite_query field`}).option(`score-threshold`,{type:`number`,description:`The score_threshold field`}).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)`}).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)`}).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-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:`The source_params.web_crawler.parse_type field`,choices:[`sitemap`,`crawl`]}).option(`summarization`,{type:`boolean`,description:`The summarization field`}).option(`summarization-model`,{type:`string`,description:`The summarization_model field`,choices:`@cf/meta/llama-3.3-70b-instruct-fp8-fast,@cf/zai-org/glm-4.7-flash,@cf/meta/llama-3.1-8b-instruct-fast,@cf/meta/llama-3.1-8b-instruct-fp8,@cf/meta/llama-4-scout-17b-16e-instruct,@cf/qwen/qwen3-30b-a3b-fp8,@cf/deepseek-ai/deepseek-r1-distill-qwen-32b,@cf/moonshotai/kimi-k2-instruct,@cf/google/gemma-3-12b-it,@cf/google/gemma-4-26b-a4b-it,@cf/moonshotai/kimi-k2.5,anthropic/claude-3-7-sonnet,anthropic/claude-sonnet-4,anthropic/claude-opus-4,anthropic/claude-3-5-haiku,cerebras/qwen-3-235b-a22b-instruct,cerebras/qwen-3-235b-a22b-thinking,cerebras/llama-3.3-70b,cerebras/llama-4-maverick-17b-128e-instruct,cerebras/llama-4-scout-17b-16e-instruct,cerebras/gpt-oss-120b,google-ai-studio/gemini-2.5-flash,google-ai-studio/gemini-2.5-pro,grok/grok-4,groq/llama-3.3-70b-versatile,groq/llama-3.1-8b-instant,openai/gpt-5,openai/gpt-5-mini,openai/gpt-5-nano`.split(`,`)}).option(`system-prompt-ai-search`,{type:`string`,description:`The system_prompt_ai_search field`}).option(`system-prompt-index-summarization`,{type:`string`,description:`The system_prompt_index_summarization field`}).option(`system-prompt-rewrite-query`,{type:`string`,description:`The system_prompt_rewrite_query field`}).option(`token-id`,{type:`string`,description:`The token_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)`}).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 ze={command:`update <id>`,describe:`Update the configuration of an AI Search instance.`,builder:Re,handler:async n=>{if(n.dryRun){s({command:`cf ai-search update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}`,pathParams:{id:String(n.id??``),name:String(n.name??``)},bodyKind:`json`,body:n.body===void 0?a({ai_gateway_id:l(n[`ai-gateway-id`],`ai-gateway-id`,`text`),ai_search_model:l(n[`ai-search-model`],`ai-search-model`,`text`),cache:n.cache,cache_threshold:l(n[`cache-threshold`],`cache-threshold`,`text`),chunk:n.chunk,chunk_overlap:n[`chunk-overlap`],chunk_size:n[`chunk-size`],embedding_model:l(n[`embedding-model`],`embedding-model`,`text`),fusion_method:l(n[`fusion-method`],`fusion-method`,`text`),index_method:{keyword:n[`index-method-keyword`],vector:n[`index-method-vector`]},indexing_options:{keyword_tokenizer:l(n[`indexing-options-keyword-tokenizer`],`indexing-options-keyword-tokenizer`,`text`)},max_num_results:n[`max-num-results`],metadata:{created_from_aisearch_wizard:n[`metadata-created-from-aisearch-wizard`],worker_domain:l(n[`metadata-worker-domain`],`metadata-worker-domain`,`text`)},paused:n.paused,public_endpoint_params:{authorized_hosts:n[`public-endpoint-params-authorized-hosts`],chat_completions_endpoint:{disabled:n[`public-endpoint-params-chat-completions-endpoint-disabled`]},custom_domains:n[`public-endpoint-params-custom-domains`],default_domain_enabled:n[`public-endpoint-params-default-domain-enabled`],enabled:n[`public-endpoint-params-enabled`],mcp:{description:l(n[`public-endpoint-params-mcp-description`],`public-endpoint-params-mcp-description`,`text`),disabled:n[`public-endpoint-params-mcp-disabled`]},rate_limit:{period_ms:n[`public-endpoint-params-rate-limit-period-ms`],requests:n[`public-endpoint-params-rate-limit-requests`],technique:l(n[`public-endpoint-params-rate-limit-technique`],`public-endpoint-params-rate-limit-technique`,`text`)},search_endpoint:{disabled:n[`public-endpoint-params-search-endpoint-disabled`]}},reranking:n.reranking,reranking_model:l(n[`reranking-model`],`reranking-model`,`text`),retrieval_options:{keyword_match_mode:l(n[`retrieval-options-keyword-match-mode`],`retrieval-options-keyword-match-mode`,`text`)},rewrite_model:l(n[`rewrite-model`],`rewrite-model`,`text`),rewrite_query:n[`rewrite-query`],score_threshold:n[`score-threshold`],source:l(n.source,`source`,`text`),source_params:{exclude_items:n[`source-params-exclude-items`],include_items:n[`source-params-include-items`],prefix:l(n[`source-params-prefix`],`source-params-prefix`,`text`),r2_jurisdiction:l(n[`source-params-r2-jurisdiction`],`source-params-r2-jurisdiction`,`text`),web_crawler:{parse_options:{include_images:n[`source-params-web-crawler-parse-options-include-images`],specific_sitemaps:n[`source-params-web-crawler-parse-options-specific-sitemaps`],use_browser_rendering:n[`source-params-web-crawler-parse-options-use-browser-rendering`]},parse_type:l(n[`source-params-web-crawler-parse-type`],`source-params-web-crawler-parse-type`,`text`)}},summarization:n.summarization,summarization_model:l(n[`summarization-model`],`summarization-model`,`text`),system_prompt_ai_search:l(n[`system-prompt-ai-search`],`system-prompt-ai-search`,`text`),system_prompt_index_summarization:l(n[`system-prompt-index-summarization`],`system-prompt-index-summarization`,`text`),system_prompt_rewrite_query:l(n[`system-prompt-rewrite-query`],`system-prompt-rewrite-query`,`text`),token_id:l(n[`token-id`],`token-id`,`text`)}):i(n.body)});return}let u=await r(n),f=n.local?d:await e();if(n.accountId=f,n.body){let e=i(n.body);o(await c(`Updating`,async()=>u.aiSearch.update({...e,account_id:f,name:n.name,id:n.id})),{successLabel:`Updated`});return}let p=a({ai_gateway_id:l(n[`ai-gateway-id`],`ai-gateway-id`,`text`),ai_search_model:l(n[`ai-search-model`],`ai-search-model`,`text`),cache:n.cache,cache_threshold:l(n[`cache-threshold`],`cache-threshold`,`text`),chunk:n.chunk,chunk_overlap:n[`chunk-overlap`],chunk_size:n[`chunk-size`],embedding_model:l(n[`embedding-model`],`embedding-model`,`text`),fusion_method:l(n[`fusion-method`],`fusion-method`,`text`),index_method:{keyword:n[`index-method-keyword`],vector:n[`index-method-vector`]},indexing_options:{keyword_tokenizer:l(n[`indexing-options-keyword-tokenizer`],`indexing-options-keyword-tokenizer`,`text`)},max_num_results:n[`max-num-results`],metadata:{created_from_aisearch_wizard:n[`metadata-created-from-aisearch-wizard`],worker_domain:l(n[`metadata-worker-domain`],`metadata-worker-domain`,`text`)},paused:n.paused,public_endpoint_params:{authorized_hosts:n[`public-endpoint-params-authorized-hosts`],chat_completions_endpoint:{disabled:n[`public-endpoint-params-chat-completions-endpoint-disabled`]},custom_domains:n[`public-endpoint-params-custom-domains`],default_domain_enabled:n[`public-endpoint-params-default-domain-enabled`],enabled:n[`public-endpoint-params-enabled`],mcp:{description:l(n[`public-endpoint-params-mcp-description`],`public-endpoint-params-mcp-description`,`text`),disabled:n[`public-endpoint-params-mcp-disabled`]},rate_limit:{period_ms:n[`public-endpoint-params-rate-limit-period-ms`],requests:n[`public-endpoint-params-rate-limit-requests`],technique:l(n[`public-endpoint-params-rate-limit-technique`],`public-endpoint-params-rate-limit-technique`,`text`)},search_endpoint:{disabled:n[`public-endpoint-params-search-endpoint-disabled`]}},reranking:n.reranking,reranking_model:l(n[`reranking-model`],`reranking-model`,`text`),retrieval_options:{keyword_match_mode:l(n[`retrieval-options-keyword-match-mode`],`retrieval-options-keyword-match-mode`,`text`)},rewrite_model:l(n[`rewrite-model`],`rewrite-model`,`text`),rewrite_query:n[`rewrite-query`],score_threshold:n[`score-threshold`],source:l(n.source,`source`,`text`),source_params:{exclude_items:n[`source-params-exclude-items`],include_items:n[`source-params-include-items`],prefix:l(n[`source-params-prefix`],`source-params-prefix`,`text`),r2_jurisdiction:l(n[`source-params-r2-jurisdiction`],`source-params-r2-jurisdiction`,`text`),web_crawler:{parse_options:{include_images:n[`source-params-web-crawler-parse-options-include-images`],specific_sitemaps:n[`source-params-web-crawler-parse-options-specific-sitemaps`],use_browser_rendering:n[`source-params-web-crawler-parse-options-use-browser-rendering`]},parse_type:l(n[`source-params-web-crawler-parse-type`],`source-params-web-crawler-parse-type`,`text`)}},summarization:n.summarization,summarization_model:l(n[`summarization-model`],`summarization-model`,`text`),system_prompt_ai_search:l(n[`system-prompt-ai-search`],`system-prompt-ai-search`,`text`),system_prompt_index_summarization:l(n[`system-prompt-index-summarization`],`system-prompt-index-summarization`,`text`),system_prompt_rewrite_query:l(n[`system-prompt-rewrite-query`],`system-prompt-rewrite-query`,`text`),token_id:l(n[`token-id`],`token-id`,`text`)});o(await c(`Updating`,async()=>u.aiSearch.update({...p,account_id:f,name:n.name,id:n.id})),{successLabel:`Updated`})}},Be={command:`ai-search`,describe:`ai-search`,builder:e=>e.command(_).command(y).command(x).command(C).command(ie).command(oe).command(ce).command(ue).command(Ce).command(Te).command(De).command(ze).command(H).command(ne).command(xe).command(Le).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{Be as default};
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env node
2
- import{O as e,P as t}from"./oauth-B5k80sip.mjs";import{n}from"./auth-DX9KnJ0P.mjs";import{n as r,t as i}from"./body-parser-DWSy7uZ8.mjs";import{t as a}from"./output-B6fBFRqe.mjs";import{n as o,t as s}from"./progress-CL8I-7YK.mjs";import{n as c}from"./input-validation-_fMCApaH.mjs";import{t as l}from"./local-CYc9q7l2.mjs";import{n as u,r as d,t as f}from"./prompt-q3B7sM2A.mjs";import{t as p}from"./cli-types-DGgEbf8K.mjs";function m(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const h={command:`credit_balance`,describe:`Retrieve the current credit balance, payment method info, and top-up configuration.`,builder:m,handler:async r=>{if(r.dryRun){o({command:`cf ai_gateway billing credit_balance`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/billing/credit-balance`,pathParams:{},bodyKind:`none`});return}let i=await n(r),c=r.local?l:await e();r.accountId=c,a(await s(`Loading`,async()=>i.aiGateway.billing.creditBalance({account_id:c})),{successLabel:`Loaded`})}};function g(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 _={command:`invoice_history`,describe:`Retrieve a list of past invoices with pagination, optionally filtered by type.`,builder:p(g),handler:async r=>{let i={type:r.type};if(r.dryRun){o({command:`cf ai_gateway billing invoice_history`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/billing/invoice-history`,pathParams:{},query:i,bodyKind:`none`});return}let c=await n(r),u=r.local?l:await e();r.accountId=u,a(await s(`Loading`,async()=>c.aiGateway.billing.invoiceHistory({account_id:u,...i})),{successLabel:`Loaded`})}};function v(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const y={command:`invoice_preview`,describe:`Retrieve a preview of the upcoming invoice including line items and tax.`,builder:v,handler:async r=>{if(r.dryRun){o({command:`cf ai_gateway billing invoice_preview`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/billing/invoice-preview`,pathParams:{},bodyKind:`none`});return}let i=await n(r),c=r.local?l:await e();r.accountId=c,a(await s(`Loading`,async()=>i.aiGateway.billing.invoicePreview({account_id:c})),{successLabel:`Loaded`})}};function b(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 x={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:b,handler:async d=>{if(d.dryRun){o({command:`cf ai_gateway billing spending_limit create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/billing/spending-limit`,pathParams:{},bodyKind:`json`,body:d.body===void 0?i({amount:d.amount,duration:c(d.duration,`duration`,`text`),strategy:c(d.strategy,`strategy`,`text`)}):r(d.body)});return}let f=await n(d),p=d.local?l:await e();if(d.accountId=p,d.body){let e=r(d.body);a(await s(`Creating`,async()=>f.aiGateway.billing.spendingLimit.create({...e,account_id:p})),{successLabel:`Created`});return}if(d.amount===void 0)throw Error(`--amount is required (or pass --body with this field set).`);d.duration===void 0&&(d.duration=await u(`duration`,`Spending limit duration.`,[`daily`,`weekly`,`monthly`])),d.strategy===void 0&&(d.strategy=await u(`strategy`,`Spending limit strategy.`,[`fixed`,`sliding`]));let m=i({amount:d.amount,duration:c(d.duration,`duration`,`text`),strategy:c(d.strategy,`strategy`,`text`)});a(await s(`Creating`,async()=>f.aiGateway.billing.spendingLimit.create({...m,account_id:p})),{successLabel:`Created`})}};function S(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 C={command:`delete`,describe:`Remove the spending limit for the account.`,builder:S,handler:async r=>{if(r.dryRun){o({command:`cf ai_gateway billing spending_limit delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/billing/spending-limit`,pathParams:{},bodyKind:`none`});return}let i=await n(r),c=r.local?l:await e();if(r.accountId=c,!await f({force:!!r.force})){process.stderr.write(`Aborted.
3
- `);return}a(await s(`Deleting`,async()=>i.aiGateway.billing.spendingLimit.delete({account_id:c})),{successLabel:`Deleted`})}};function w(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const T={command:`get`,describe:`Retrieve the current spending limit configuration for the account.`,builder:w,handler:async r=>{if(r.dryRun){o({command:`cf ai_gateway billing spending_limit get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/billing/spending-limit`,pathParams:{},bodyKind:`none`});return}let i=await n(r),c=r.local?l:await e();r.accountId=c,a(await s(`Loading`,async()=>i.aiGateway.billing.spendingLimit.get({account_id:c})),{successLabel:`Loaded`})}},E={command:`spending_limit`,describe:`Operations for billing.spending_limit`,builder:e=>e.command(x).command(C).command(T).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function D(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 O={command:`create`,describe:`Configure auto top-up with a balance threshold and top-up amount.`,builder:D,handler:async c=>{if(c.dryRun){o({command:`cf ai_gateway billing topup config create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/billing/topup/config`,pathParams:{},bodyKind:`json`,body:c.body===void 0?i({amount:c.amount,threshold:c.threshold}):r(c.body)});return}let u=await n(c),d=c.local?l:await e();if(c.accountId=d,c.body){let e=r(c.body);a(await s(`Creating`,async()=>u.aiGateway.billing.topup.config.create({...e,account_id:d})),{successLabel:`Created`});return}if(c.amount===void 0)throw Error(`--amount is required (or pass --body with this field set).`);if(c.threshold===void 0)throw Error(`--threshold is required (or pass --body with this field set).`);let f=i({amount:c.amount,threshold:c.threshold});a(await s(`Creating`,async()=>u.aiGateway.billing.topup.config.create({...f,account_id:d})),{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 A={command:`delete`,describe:`Remove the auto top-up configuration for the account.`,builder:k,handler:async r=>{if(r.dryRun){o({command:`cf ai_gateway billing topup config delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/billing/topup/config`,pathParams:{},bodyKind:`none`});return}let i=await n(r),c=r.local?l:await e();if(r.accountId=c,!await f({force:!!r.force})){process.stderr.write(`Aborted.
4
- `);return}a(await s(`Deleting`,async()=>i.aiGateway.billing.topup.config.delete({account_id:c})),{successLabel:`Deleted`})}};function j(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const M={command:`get`,describe:`Retrieve the current auto top-up threshold, amount, and any error state.`,builder:j,handler:async r=>{if(r.dryRun){o({command:`cf ai_gateway billing topup config get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/billing/topup/config`,pathParams:{},bodyKind:`none`});return}let i=await n(r),c=r.local?l:await e();r.accountId=c,a(await s(`Loading`,async()=>i.aiGateway.billing.topup.config.get({account_id:c})),{successLabel:`Loaded`})}},N={command:`config`,describe:`Operations for billing.topup.config`,builder:e=>e.command(O).command(A).command(M).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function P(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 F={command:`create`,describe:`Create a credit top-up via Stripe PaymentIntent for the given account.`,builder:P,handler:async c=>{if(c.dryRun){o({command:`cf ai_gateway billing topup create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/billing/topup`,pathParams:{},bodyKind:`json`,body:c.body===void 0?i({amount:c.amount}):r(c.body)});return}let u=await n(c),d=c.local?l:await e();if(c.accountId=d,c.body){let e=r(c.body);a(await s(`Creating`,async()=>u.aiGateway.billing.topup.create({...e,account_id:d})),{successLabel:`Created`});return}if(c.amount===void 0)throw Error(`--amount is required (or pass --body with this field set).`);let f=i({amount:c.amount});a(await s(`Creating`,async()=>u.aiGateway.billing.topup.create({...f,account_id:d})),{successLabel:`Created`})}};function I(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 L={command:`status`,describe:`Get the payment processing status of a top-up by its invoice ID.`,builder:I,handler:async u=>{if(u.dryRun){o({command:`cf ai_gateway billing topup status`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/billing/topup/status`,pathParams:{},bodyKind:`json`,body:u.body===void 0?i({payment_intent_id:c(u[`payment-intent-id`],`payment-intent-id`,`text`)}):r(u.body)});return}let f=await n(u),p=u.local?l:await e();if(u.accountId=p,u.body){let e=r(u.body);a(await s(`Creating`,async()=>f.aiGateway.billing.topup.status({...e,account_id:p})),{successLabel:`Created`});return}u[`payment-intent-id`]===void 0&&(u[`payment-intent-id`]=await d(`payment-intent-id`,`Stripe invoice ID to check status for.`));let m=i({payment_intent_id:c(u[`payment-intent-id`],`payment-intent-id`,`text`)});a(await s(`Creating`,async()=>f.aiGateway.billing.topup.status({...m,account_id:p})),{successLabel:`Created`})}},R={command:`topup`,describe:`Operations for billing.topup`,builder:e=>e.command(F).command(L).command(N).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function z(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 B={command:`usage_history`,describe:`Retrieve aggregated usage meter event summaries for the given time range.`,builder:p(z),handler:async r=>{let i={value_grouping_window:r[`value-grouping-window`],start_time:r[`start-time`],end_time:r[`end-time`]};if(r.dryRun){o({command:`cf ai_gateway billing usage_history`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/ai-gateway/billing/usage-history`,pathParams:{},query:i,bodyKind:`none`});return}let c=await n(r),u=r.local?l:await e();r.accountId=u,a(await s(`Loading`,async()=>c.aiGateway.billing.usageHistory({account_id:u,...i})),{successLabel:`Loaded`})}},V={command:`billing`,describe:`Operations for billing`,builder:e=>e.command(h).command(_).command(y).command(B).command(E).command(R).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},H={command:`ai_gateway`,describe:`ai_gateway`,builder:e=>e.command(V).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{H as default};
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env node
2
- import{O as e,P as t}from"./oauth-B5k80sip.mjs";import{n}from"./auth-DX9KnJ0P.mjs";import{n as r,t as i}from"./body-parser-DWSy7uZ8.mjs";import{t as a}from"./output-B6fBFRqe.mjs";import{n as o,t as s}from"./progress-CL8I-7YK.mjs";import{n as c}from"./input-validation-_fMCApaH.mjs";import{t as l}from"./local-CYc9q7l2.mjs";import{n as u,r as d,t as f}from"./prompt-q3B7sM2A.mjs";function p(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const m={command:`list`,describe:`Gets a list of all alert types for which an account is eligible.`,builder:p,handler:async r=>{if(r.dryRun){o({command:`cf alerting available-alerts list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/alerting/v3/available_alerts`,pathParams:{},bodyKind:`none`});return}let i=await n(r),c=r.local?l:await e();r.accountId=c,a(await s(`Loading`,async()=>i.alerting.availableAlerts.list({account_id:c})),{successLabel:`Loaded`})}},h={command:`available-alerts`,describe:`List the alert types available for your account based on enabled products`,builder:e=>e.command(m).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function ee(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 a list of all delivery mechanism types for which an account is eligible.`,builder:ee,handler:async r=>{if(r.dryRun){o({command:`cf alerting destinations eligible get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/alerting/v3/destinations/eligible`,pathParams:{},bodyKind:`none`});return}let i=await n(r),c=r.local?l:await e();r.accountId=c,a(await s(`Loading`,async()=>i.alerting.destinations.eligible.get({account_id:c})),{successLabel:`Loaded`})}},_={command:`eligible`,describe:`Delivery mechanisms for alerts — email, PagerDuty integrations, and webhook endpoints`,builder:e=>e.command(g).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function v(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const y={command:`create`,describe:`Creates a new token for integrating with PagerDuty.`,builder:v,handler:async r=>{if(r.dryRun){o({command:`cf alerting destinations pagerduty create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/alerting/v3/destinations/pagerduty/connect`,pathParams:{},bodyKind:`none`});return}let i=await n(r),c=r.local?l:await e();r.accountId=c,a(await s(`Creating`,async()=>i.alerting.destinations.pagerduty.create({account_id:c})),{successLabel:`Created`})}};function b(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 x={command:`delete`,describe:`Deletes all the PagerDuty Services connected to the account.`,builder:b,handler:async r=>{if(r.dryRun){o({command:`cf alerting destinations pagerduty delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/alerting/v3/destinations/pagerduty`,pathParams:{},bodyKind:`none`});return}let i=await n(r),c=r.local?l:await e();if(r.accountId=c,!await f({force:!!r.force})){process.stderr.write(`Aborted.
3
- `);return}a(await s(`Deleting`,async()=>i.alerting.destinations.pagerduty.delete({account_id:c})),{successLabel:`Deleted`})}};function S(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const C={command:`get`,describe:`Get a list of all configured PagerDuty services.`,builder:S,handler:async r=>{if(r.dryRun){o({command:`cf alerting destinations pagerduty get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/alerting/v3/destinations/pagerduty`,pathParams:{},bodyKind:`none`});return}let i=await n(r),c=r.local?l:await e();r.accountId=c,a(await s(`Loading`,async()=>i.alerting.destinations.pagerduty.get({account_id:c})),{successLabel:`Loaded`})}};function w(e){return e.positional(`token-id`,{type:`string`,description:`The token integration key`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const T={command:`link <token-id>`,describe:`Links PagerDuty with the account using the integration token.`,builder:w,handler:async r=>{if(r.dryRun){o({command:`cf alerting destinations pagerduty link`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/alerting/v3/destinations/pagerduty/connect/${r[`token-id`]==null?`<token-id>`:encodeURIComponent(String(r[`token-id`]))}`,pathParams:{"token-id":String(r[`token-id`]??``)},bodyKind:`none`});return}let i=await n(r),c=r.local?l:await e();r.accountId=c,a(await s(`Loading`,async()=>i.alerting.destinations.pagerduty.link({account_id:c,token_id:r[`token-id`]})),{successLabel:`Loaded`})}},E={command:`pagerduty`,describe:`Delivery mechanisms for alerts — email, PagerDuty integrations, and webhook endpoints`,builder:e=>e.command(y).command(x).command(C).command(T).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function D(e){return e.option(`name`,{type:`string`,description:`The name of the webhook destination. This will be included in the request body when you receive a webhook notification.`}).option(`secret`,{type:`string`,description:"Optional secret that will be passed in the `cf-webhook-auth` header when dispatching generic webhook notifications or formatted for supported destinations. Secrets are not returned in any API response body."}).option(`url`,{type:`string`,description:`The POST endpoint to call when dispatching a notification.`}).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 O={command:`create`,describe:`Creates a new webhook destination.`,builder:D,handler:async u=>{if(u.dryRun){o({command:`cf alerting destinations webhooks create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/alerting/v3/destinations/webhooks`,pathParams:{},bodyKind:`json`,body:u.body===void 0?i({name:c(u.name,`name`,`text`),secret:c(u.secret,`secret`,`text`),url:c(u.url,`url`,`text`)}):r(u.body)});return}let f=await n(u),p=u.local?l:await e();if(u.accountId=p,u.body){let e=r(u.body);a(await s(`Creating`,async()=>f.alerting.destinations.webhooks.create({...e,account_id:p})),{successLabel:`Created`});return}u.name===void 0&&(u.name=await d(`name`,`The name of the webhook destination. This will be included in the request body when you receive a webhook notification.`)),u.url===void 0&&(u.url=await d(`url`,`The POST endpoint to call when dispatching a notification.`));let m=i({name:c(u.name,`name`,`text`),secret:c(u.secret,`secret`,`text`),url:c(u.url,`url`,`text`)});a(await s(`Creating`,async()=>f.alerting.destinations.webhooks.create({...m,account_id:p})),{successLabel:`Created`})}};function k(e){return e.positional(`webhook-id`,{type:`string`,description:`The unique identifier of a webhook`,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 A={command:`delete <webhook-id>`,describe:`Delete a configured webhook destination.`,builder:k,handler:async r=>{if(r.dryRun){o({command:`cf alerting destinations webhooks delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/alerting/v3/destinations/webhooks/${r[`webhook-id`]==null?`<webhook-id>`:encodeURIComponent(String(r[`webhook-id`]))}`,pathParams:{"webhook-id":String(r[`webhook-id`]??``)},bodyKind:`none`});return}let i=await n(r),c=r.local?l:await e();if(r.accountId=c,!await f({force:!!r.force})){process.stderr.write(`Aborted.
4
- `);return}a(await s(`Deleting`,async()=>i.alerting.destinations.webhooks.delete({account_id:c,webhook_id:r[`webhook-id`]})),{successLabel:`Deleted`})}};function j(e){return e.positional(`webhook-id`,{type:`string`,description:`The unique identifier of a webhook`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const M={command:`get <webhook-id>`,describe:`Get details for a single webhooks destination.`,builder:j,handler:async r=>{if(r.dryRun){o({command:`cf alerting destinations webhooks get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/alerting/v3/destinations/webhooks/${r[`webhook-id`]==null?`<webhook-id>`:encodeURIComponent(String(r[`webhook-id`]))}`,pathParams:{"webhook-id":String(r[`webhook-id`]??``)},bodyKind:`none`});return}let i=await n(r),c=r.local?l:await e();r.accountId=c,a(await s(`Loading`,async()=>i.alerting.destinations.webhooks.get({account_id:c,webhook_id:r[`webhook-id`]})),{successLabel:`Loaded`})}};function N(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const P={command:`list`,describe:`Gets a list of all configured webhook destinations.`,builder:N,handler:async r=>{if(r.dryRun){o({command:`cf alerting destinations webhooks list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/alerting/v3/destinations/webhooks`,pathParams:{},bodyKind:`none`});return}let i=await n(r),c=r.local?l:await e();r.accountId=c,a(await s(`Loading`,async()=>i.alerting.destinations.webhooks.list({account_id:c})),{successLabel:`Loaded`})}};function F(e){return e.positional(`webhook-id`,{type:`string`,description:`The unique identifier of a webhook`,demandOption:!0}).option(`name`,{type:`string`,description:`The name of the webhook destination. This will be included in the request body when you receive a webhook notification.`}).option(`secret`,{type:`string`,description:"Optional secret that will be passed in the `cf-webhook-auth` header when dispatching generic webhook notifications or formatted for supported destinations. Secrets are not returned in any API response body."}).option(`url`,{type:`string`,description:`The POST endpoint to call when dispatching a notification.`}).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 I={command:`update <webhook-id>`,describe:`Update a webhook destination.`,builder:F,handler:async u=>{if(u.dryRun){o({command:`cf alerting destinations webhooks update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/alerting/v3/destinations/webhooks/${u[`webhook-id`]==null?`<webhook-id>`:encodeURIComponent(String(u[`webhook-id`]))}`,pathParams:{"webhook-id":String(u[`webhook-id`]??``)},bodyKind:`json`,body:u.body===void 0?i({name:c(u.name,`name`,`text`),secret:c(u.secret,`secret`,`text`),url:c(u.url,`url`,`text`)}):r(u.body)});return}let f=await n(u),p=u.local?l:await e();if(u.accountId=p,u.body){let e=r(u.body);a(await s(`Updating`,async()=>f.alerting.destinations.webhooks.update({...e,account_id:p,webhook_id:u[`webhook-id`]})),{successLabel:`Updated`});return}u.name===void 0&&(u.name=await d(`name`,`The name of the webhook destination. This will be included in the request body when you receive a webhook notification.`)),u.url===void 0&&(u.url=await d(`url`,`The POST endpoint to call when dispatching a notification.`));let m=i({name:c(u.name,`name`,`text`),secret:c(u.secret,`secret`,`text`),url:c(u.url,`url`,`text`)});a(await s(`Updating`,async()=>f.alerting.destinations.webhooks.update({...m,account_id:p,webhook_id:u[`webhook-id`]})),{successLabel:`Updated`})}},L={command:`webhooks`,describe:`Delivery mechanisms for alerts — email, PagerDuty integrations, and webhook endpoints`,builder:e=>e.command(O).command(A).command(M).command(P).command(I).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},R={command:`destinations`,describe:`Operations for destinations`,builder:e=>e.command(_).command(E).command(L).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function z(e){return e.option(`per-page`,{type:`number`,description:`Number of items per page.`}).option(`before`,{type:`string`,description:`Limit the returned results to history records older than the specified date. This must be a timestamp that conforms to RFC3339.`}).option(`page`,{type:`number`,description:`Page number of paginated results.`}).option(`since`,{type:`string`,description:`Limit the returned results to history records newer than the specified date. This must be a timestamp that conforms to RFC3339.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const te={command:`list`,describe:"Gets a list of history records for notifications sent to an account. The records are displayed for last `x` number of days based on the zone plan (free = 30, pro = 30, biz = 30, ent = 90).",builder:z,handler:async r=>{let i={per_page:r[`per-page`],before:r.before,page:r.page,since:r.since};if(r.dryRun){o({command:`cf alerting history list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/alerting/v3/history`,pathParams:{},query:i,bodyKind:`none`});return}let c=await n(r),u=r.local?l:await e();r.accountId=u,a(await s(`Loading`,async()=>c.alerting.history.list({account_id:u,...i})),{successLabel:`Loaded`})}},B={command:`history`,describe:`Browse previously sent alert notifications and their delivery status`,builder:e=>e.command(te).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function V(e){return e.option(`alert-interval`,{type:`string`,description:`Optional specification of how often to re-alert from the same incident, not support on all alert types.`}).option(`alert-type`,{type:`string`,description:`Refers to which event will trigger a Notification dispatch. You can use the endpoint to get available alert types which then will give you a list of possible values.`,choices:`abuse_report_alert.access_custom_certificate_expiration_type.advanced_ddos_attack_l4_alert.advanced_ddos_attack_l7_alert.advanced_http_alert_error.bgp_hijack_notification.billing_usage_alert.block_notification_block_removed.block_notification_new_block.block_notification_review_rejected.bot_traffic_basic_alert.brand_protection_alert.brand_protection_digest.clickhouse_alert_fw_anomaly.clickhouse_alert_fw_ent_anomaly.cloudforce_one_request_notification.cni_maintenance_notification.custom_analytics.custom_bot_detection_alert.custom_ssl_certificate_event_type.dedicated_ssl_certificate_event_type.device_connectivity_anomaly_alert.dos_attack_l4.dos_attack_l7.expiring_service_token_alert.failing_logpush_job_disabled_alert.fbm_auto_advertisement.fbm_dosd_attack.fbm_volumetric_attack.health_check_status_notification.hostname_aop_custom_certificate_expiration_type.http_alert_edge_error.http_alert_origin_error.image_notification.image_resizing_notification.incident_alert.load_balancing_health_alert.load_balancing_pool_enablement_alert.logo_match_alert.magic_tunnel_health_check_event.magic_wan_tunnel_health.maintenance_event_notification.mtls_certificate_store_certificate_expiration_type.pages_event_alert.radar_notification.real_origin_monitoring.scriptmonitor_alert_new_code_change_detections.scriptmonitor_alert_new_hosts.scriptmonitor_alert_new_malicious_hosts.scriptmonitor_alert_new_malicious_scripts.scriptmonitor_alert_new_malicious_url.scriptmonitor_alert_new_max_length_resource_url.scriptmonitor_alert_new_resources.secondary_dns_all_primaries_failing.secondary_dns_primaries_failing.secondary_dns_warning.secondary_dns_zone_successfully_updated.secondary_dns_zone_validation_warning.security_insights_alert.sentinel_alert.stream_live_notifications.synthetic_test_latency_alert.synthetic_test_low_availability_alert.traffic_anomalies_alert.tunnel_health_event.tunnel_update_event.universal_ssl_event_type.web_analytics_metrics_update.zone_aop_custom_certificate_expiration_type`.split(`.`)}).option(`description`,{type:`string`,description:`Optional description for the Notification policy.`}).option(`enabled`,{type:`boolean`,description:`Whether or not the Notification policy is enabled.`,default:!0}).option(`filters-actions`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-affected-asns`,{type:`string`,array:!0,description:`Used for configuring radar_notification`}).option(`filters-affected-components`,{type:`string`,array:!0,description:`Used for configuring incident_alert`}).option(`filters-affected-locations`,{type:`string`,array:!0,description:`Used for configuring radar_notification`}).option(`filters-airport-code`,{type:`string`,array:!0,description:`Used for configuring maintenance_event_notification`}).option(`filters-alert-trigger-preferences`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-alert-trigger-preferences-value`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-enabled`,{type:`string`,array:!0,description:`Used for configuring load_balancing_pool_enablement_alert`}).option(`filters-environment`,{type:`string`,array:!0,description:`Used for configuring pages_event_alert`}).option(`filters-event`,{type:`string`,array:!0,description:`Used for configuring pages_event_alert`}).option(`filters-event-source`,{type:`string`,array:!0,description:`Used for configuring load_balancing_health_alert`}).option(`filters-event-type`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-group-by`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-health-check-id`,{type:`string`,array:!0,description:`Used for configuring health_check_status_notification`}).option(`filters-incident-impact`,{type:`string`,array:!0,description:`Used for configuring incident_alert`}).option(`filters-input-id`,{type:`string`,array:!0,description:`Used for configuring stream_live_notifications`}).option(`filters-insight-class`,{type:`string`,array:!0,description:`Used for configuring security_insights_alert`}).option(`filters-limit`,{type:`string`,array:!0,description:`Used for configuring billing_usage_alert`}).option(`filters-logo-tag`,{type:`string`,array:!0,description:`Used for configuring logo_match_alert`}).option(`filters-megabits-per-second`,{type:`string`,array:!0,description:`Used for configuring advanced_ddos_attack_l4_alert`}).option(`filters-new-health`,{type:`string`,array:!0,description:`Used for configuring load_balancing_health_alert`}).option(`filters-new-status`,{type:`string`,array:!0,description:`Used for configuring tunnel_health_event`}).option(`filters-packets-per-second`,{type:`string`,array:!0,description:`Used for configuring advanced_ddos_attack_l4_alert`}).option(`filters-pool-id`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-pop-names`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-product`,{type:`string`,array:!0,description:`Used for configuring billing_usage_alert`}).option(`filters-project-id`,{type:`string`,array:!0,description:`Used for configuring pages_event_alert`}).option(`filters-protocol`,{type:`string`,array:!0,description:`Used for configuring advanced_ddos_attack_l4_alert`}).option(`filters-query-tag`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-requests-per-second`,{type:`string`,array:!0,description:`Used for configuring advanced_ddos_attack_l7_alert`}).option(`filters-selectors`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-services`,{type:`string`,array:!0,description:`Used for configuring clickhouse_alert_fw_ent_anomaly`}).option(`filters-slo`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-status`,{type:`string`,array:!0,description:`Used for configuring health_check_status_notification`}).option(`filters-target-hostname`,{type:`string`,array:!0,description:`Used for configuring advanced_ddos_attack_l7_alert`}).option(`filters-target-ip`,{type:`string`,array:!0,description:`Used for configuring advanced_ddos_attack_l4_alert`}).option(`filters-target-zone-name`,{type:`string`,array:!0,description:`Used for configuring advanced_ddos_attack_l7_alert`}).option(`filters-traffic-exclusions`,{type:`string`,array:!0,description:`Used for configuring traffic_anomalies_alert`}).option(`filters-tunnel-id`,{type:`string`,array:!0,description:`Used for configuring tunnel_health_event`}).option(`filters-tunnel-name`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-type`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-where`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-zones`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`name`,{type:`string`,description:`Name of the policy.`}).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 H={command:`create`,describe:`Creates a new Notification policy.`,builder:V,handler:async f=>{if(f.dryRun){o({command:`cf alerting policies create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/alerting/v3/policies`,pathParams:{},bodyKind:`json`,body:f.body===void 0?i({alert_interval:c(f[`alert-interval`],`alert-interval`,`text`),alert_type:c(f[`alert-type`],`alert-type`,`text`),description:c(f.description,`description`,`text`),enabled:f.enabled,filters:{actions:f[`filters-actions`],affected_asns:f[`filters-affected-asns`],affected_components:f[`filters-affected-components`],affected_locations:f[`filters-affected-locations`],airport_code:f[`filters-airport-code`],alert_trigger_preferences:f[`filters-alert-trigger-preferences`],alert_trigger_preferences_value:f[`filters-alert-trigger-preferences-value`],enabled:f[`filters-enabled`],environment:f[`filters-environment`],event:f[`filters-event`],event_source:f[`filters-event-source`],event_type:f[`filters-event-type`],group_by:f[`filters-group-by`],health_check_id:f[`filters-health-check-id`],incident_impact:f[`filters-incident-impact`],input_id:f[`filters-input-id`],insight_class:f[`filters-insight-class`],limit:f[`filters-limit`],logo_tag:f[`filters-logo-tag`],megabits_per_second:f[`filters-megabits-per-second`],new_health:f[`filters-new-health`],new_status:f[`filters-new-status`],packets_per_second:f[`filters-packets-per-second`],pool_id:f[`filters-pool-id`],pop_names:f[`filters-pop-names`],product:f[`filters-product`],project_id:f[`filters-project-id`],protocol:f[`filters-protocol`],query_tag:f[`filters-query-tag`],requests_per_second:f[`filters-requests-per-second`],selectors:f[`filters-selectors`],services:f[`filters-services`],slo:f[`filters-slo`],status:f[`filters-status`],target_hostname:f[`filters-target-hostname`],target_ip:f[`filters-target-ip`],target_zone_name:f[`filters-target-zone-name`],traffic_exclusions:f[`filters-traffic-exclusions`],tunnel_id:f[`filters-tunnel-id`],tunnel_name:f[`filters-tunnel-name`],type:f[`filters-type`],where:f[`filters-where`],zones:f[`filters-zones`]},name:c(f.name,`name`,`text`)}):r(f.body)});return}let p=await n(f),m=f.local?l:await e();if(f.accountId=m,f.body){let e=r(f.body);a(await s(`Creating`,async()=>p.alerting.policies.create({...e,account_id:m})),{successLabel:`Created`});return}if(f[`alert-type`]===void 0&&(f[`alert-type`]=await u(`alert-type`,`Refers to which event will trigger a Notification dispatch. You can use the endpoint to get available alert types which then will give you a list of possible values.`,`abuse_report_alert.access_custom_certificate_expiration_type.advanced_ddos_attack_l4_alert.advanced_ddos_attack_l7_alert.advanced_http_alert_error.bgp_hijack_notification.billing_usage_alert.block_notification_block_removed.block_notification_new_block.block_notification_review_rejected.bot_traffic_basic_alert.brand_protection_alert.brand_protection_digest.clickhouse_alert_fw_anomaly.clickhouse_alert_fw_ent_anomaly.cloudforce_one_request_notification.cni_maintenance_notification.custom_analytics.custom_bot_detection_alert.custom_ssl_certificate_event_type.dedicated_ssl_certificate_event_type.device_connectivity_anomaly_alert.dos_attack_l4.dos_attack_l7.expiring_service_token_alert.failing_logpush_job_disabled_alert.fbm_auto_advertisement.fbm_dosd_attack.fbm_volumetric_attack.health_check_status_notification.hostname_aop_custom_certificate_expiration_type.http_alert_edge_error.http_alert_origin_error.image_notification.image_resizing_notification.incident_alert.load_balancing_health_alert.load_balancing_pool_enablement_alert.logo_match_alert.magic_tunnel_health_check_event.magic_wan_tunnel_health.maintenance_event_notification.mtls_certificate_store_certificate_expiration_type.pages_event_alert.radar_notification.real_origin_monitoring.scriptmonitor_alert_new_code_change_detections.scriptmonitor_alert_new_hosts.scriptmonitor_alert_new_malicious_hosts.scriptmonitor_alert_new_malicious_scripts.scriptmonitor_alert_new_malicious_url.scriptmonitor_alert_new_max_length_resource_url.scriptmonitor_alert_new_resources.secondary_dns_all_primaries_failing.secondary_dns_primaries_failing.secondary_dns_warning.secondary_dns_zone_successfully_updated.secondary_dns_zone_validation_warning.security_insights_alert.sentinel_alert.stream_live_notifications.synthetic_test_latency_alert.synthetic_test_low_availability_alert.traffic_anomalies_alert.tunnel_health_event.tunnel_update_event.universal_ssl_event_type.web_analytics_metrics_update.zone_aop_custom_certificate_expiration_type`.split(`.`))),f.enabled===void 0)throw Error(`--enabled is required (or pass --body with this field set).`);f.name===void 0&&(f.name=await d(`name`,`Name of the policy.`));let h=i({alert_interval:c(f[`alert-interval`],`alert-interval`,`text`),alert_type:c(f[`alert-type`],`alert-type`,`text`),description:c(f.description,`description`,`text`),enabled:f.enabled,filters:{actions:f[`filters-actions`],affected_asns:f[`filters-affected-asns`],affected_components:f[`filters-affected-components`],affected_locations:f[`filters-affected-locations`],airport_code:f[`filters-airport-code`],alert_trigger_preferences:f[`filters-alert-trigger-preferences`],alert_trigger_preferences_value:f[`filters-alert-trigger-preferences-value`],enabled:f[`filters-enabled`],environment:f[`filters-environment`],event:f[`filters-event`],event_source:f[`filters-event-source`],event_type:f[`filters-event-type`],group_by:f[`filters-group-by`],health_check_id:f[`filters-health-check-id`],incident_impact:f[`filters-incident-impact`],input_id:f[`filters-input-id`],insight_class:f[`filters-insight-class`],limit:f[`filters-limit`],logo_tag:f[`filters-logo-tag`],megabits_per_second:f[`filters-megabits-per-second`],new_health:f[`filters-new-health`],new_status:f[`filters-new-status`],packets_per_second:f[`filters-packets-per-second`],pool_id:f[`filters-pool-id`],pop_names:f[`filters-pop-names`],product:f[`filters-product`],project_id:f[`filters-project-id`],protocol:f[`filters-protocol`],query_tag:f[`filters-query-tag`],requests_per_second:f[`filters-requests-per-second`],selectors:f[`filters-selectors`],services:f[`filters-services`],slo:f[`filters-slo`],status:f[`filters-status`],target_hostname:f[`filters-target-hostname`],target_ip:f[`filters-target-ip`],target_zone_name:f[`filters-target-zone-name`],traffic_exclusions:f[`filters-traffic-exclusions`],tunnel_id:f[`filters-tunnel-id`],tunnel_name:f[`filters-tunnel-name`],type:f[`filters-type`],where:f[`filters-where`],zones:f[`filters-zones`]},name:c(f.name,`name`,`text`)});a(await s(`Creating`,async()=>p.alerting.policies.create({...h,account_id:m})),{successLabel:`Created`})}};function U(e){return e.positional(`policy-id`,{type:`string`,description:`The unique identifier of a notification policy`,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 W={command:`delete <policy-id>`,describe:`Delete a Notification policy.`,builder:U,handler:async r=>{if(r.dryRun){o({command:`cf alerting policies delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/alerting/v3/policies/${r[`policy-id`]==null?`<policy-id>`:encodeURIComponent(String(r[`policy-id`]))}`,pathParams:{"policy-id":String(r[`policy-id`]??``)},bodyKind:`none`});return}let i=await n(r),c=r.local?l:await e();if(r.accountId=c,!await f({force:!!r.force})){process.stderr.write(`Aborted.
5
- `);return}a(await s(`Deleting`,async()=>i.alerting.policies.delete({account_id:c,policy_id:r[`policy-id`]})),{successLabel:`Deleted`})}};function G(e){return e.positional(`policy-id`,{type:`string`,description:`The unique identifier of a notification policy`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const K={command:`get <policy-id>`,describe:`Get details for a single policy.`,builder:G,handler:async r=>{if(r.dryRun){o({command:`cf alerting policies get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/alerting/v3/policies/${r[`policy-id`]==null?`<policy-id>`:encodeURIComponent(String(r[`policy-id`]))}`,pathParams:{"policy-id":String(r[`policy-id`]??``)},bodyKind:`none`});return}let i=await n(r),c=r.local?l:await e();r.accountId=c,a(await s(`Loading`,async()=>i.alerting.policies.get({account_id:c,policy_id:r[`policy-id`]})),{successLabel:`Loaded`})}};function q(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const J={command:`list`,describe:`Get a list of all Notification policies.`,builder:q,handler:async r=>{if(r.dryRun){o({command:`cf alerting policies list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/alerting/v3/policies`,pathParams:{},bodyKind:`none`});return}let i=await n(r),c=r.local?l:await e();r.accountId=c,a(await s(`Loading`,async()=>i.alerting.policies.list({account_id:c})),{successLabel:`Loaded`})}};function Y(e){return e.positional(`policy-id`,{type:`string`,description:`The unique identifier of a notification policy`,demandOption:!0}).option(`alert-interval`,{type:`string`,description:`Optional specification of how often to re-alert from the same incident, not support on all alert types.`}).option(`alert-type`,{type:`string`,description:`Refers to which event will trigger a Notification dispatch. You can use the endpoint to get available alert types which then will give you a list of possible values.`,choices:`abuse_report_alert.access_custom_certificate_expiration_type.advanced_ddos_attack_l4_alert.advanced_ddos_attack_l7_alert.advanced_http_alert_error.bgp_hijack_notification.billing_usage_alert.block_notification_block_removed.block_notification_new_block.block_notification_review_rejected.bot_traffic_basic_alert.brand_protection_alert.brand_protection_digest.clickhouse_alert_fw_anomaly.clickhouse_alert_fw_ent_anomaly.cloudforce_one_request_notification.cni_maintenance_notification.custom_analytics.custom_bot_detection_alert.custom_ssl_certificate_event_type.dedicated_ssl_certificate_event_type.device_connectivity_anomaly_alert.dos_attack_l4.dos_attack_l7.expiring_service_token_alert.failing_logpush_job_disabled_alert.fbm_auto_advertisement.fbm_dosd_attack.fbm_volumetric_attack.health_check_status_notification.hostname_aop_custom_certificate_expiration_type.http_alert_edge_error.http_alert_origin_error.image_notification.image_resizing_notification.incident_alert.load_balancing_health_alert.load_balancing_pool_enablement_alert.logo_match_alert.magic_tunnel_health_check_event.magic_wan_tunnel_health.maintenance_event_notification.mtls_certificate_store_certificate_expiration_type.pages_event_alert.radar_notification.real_origin_monitoring.scriptmonitor_alert_new_code_change_detections.scriptmonitor_alert_new_hosts.scriptmonitor_alert_new_malicious_hosts.scriptmonitor_alert_new_malicious_scripts.scriptmonitor_alert_new_malicious_url.scriptmonitor_alert_new_max_length_resource_url.scriptmonitor_alert_new_resources.secondary_dns_all_primaries_failing.secondary_dns_primaries_failing.secondary_dns_warning.secondary_dns_zone_successfully_updated.secondary_dns_zone_validation_warning.security_insights_alert.sentinel_alert.stream_live_notifications.synthetic_test_latency_alert.synthetic_test_low_availability_alert.traffic_anomalies_alert.tunnel_health_event.tunnel_update_event.universal_ssl_event_type.web_analytics_metrics_update.zone_aop_custom_certificate_expiration_type`.split(`.`)}).option(`description`,{type:`string`,description:`Optional description for the Notification policy.`}).option(`enabled`,{type:`boolean`,description:`Whether or not the Notification policy is enabled.`}).option(`filters-actions`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-affected-asns`,{type:`string`,array:!0,description:`Used for configuring radar_notification`}).option(`filters-affected-components`,{type:`string`,array:!0,description:`Used for configuring incident_alert`}).option(`filters-affected-locations`,{type:`string`,array:!0,description:`Used for configuring radar_notification`}).option(`filters-airport-code`,{type:`string`,array:!0,description:`Used for configuring maintenance_event_notification`}).option(`filters-alert-trigger-preferences`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-alert-trigger-preferences-value`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-enabled`,{type:`string`,array:!0,description:`Used for configuring load_balancing_pool_enablement_alert`}).option(`filters-environment`,{type:`string`,array:!0,description:`Used for configuring pages_event_alert`}).option(`filters-event`,{type:`string`,array:!0,description:`Used for configuring pages_event_alert`}).option(`filters-event-source`,{type:`string`,array:!0,description:`Used for configuring load_balancing_health_alert`}).option(`filters-event-type`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-group-by`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-health-check-id`,{type:`string`,array:!0,description:`Used for configuring health_check_status_notification`}).option(`filters-incident-impact`,{type:`string`,array:!0,description:`Used for configuring incident_alert`}).option(`filters-input-id`,{type:`string`,array:!0,description:`Used for configuring stream_live_notifications`}).option(`filters-insight-class`,{type:`string`,array:!0,description:`Used for configuring security_insights_alert`}).option(`filters-limit`,{type:`string`,array:!0,description:`Used for configuring billing_usage_alert`}).option(`filters-logo-tag`,{type:`string`,array:!0,description:`Used for configuring logo_match_alert`}).option(`filters-megabits-per-second`,{type:`string`,array:!0,description:`Used for configuring advanced_ddos_attack_l4_alert`}).option(`filters-new-health`,{type:`string`,array:!0,description:`Used for configuring load_balancing_health_alert`}).option(`filters-new-status`,{type:`string`,array:!0,description:`Used for configuring tunnel_health_event`}).option(`filters-packets-per-second`,{type:`string`,array:!0,description:`Used for configuring advanced_ddos_attack_l4_alert`}).option(`filters-pool-id`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-pop-names`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-product`,{type:`string`,array:!0,description:`Used for configuring billing_usage_alert`}).option(`filters-project-id`,{type:`string`,array:!0,description:`Used for configuring pages_event_alert`}).option(`filters-protocol`,{type:`string`,array:!0,description:`Used for configuring advanced_ddos_attack_l4_alert`}).option(`filters-query-tag`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-requests-per-second`,{type:`string`,array:!0,description:`Used for configuring advanced_ddos_attack_l7_alert`}).option(`filters-selectors`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-services`,{type:`string`,array:!0,description:`Used for configuring clickhouse_alert_fw_ent_anomaly`}).option(`filters-slo`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-status`,{type:`string`,array:!0,description:`Used for configuring health_check_status_notification`}).option(`filters-target-hostname`,{type:`string`,array:!0,description:`Used for configuring advanced_ddos_attack_l7_alert`}).option(`filters-target-ip`,{type:`string`,array:!0,description:`Used for configuring advanced_ddos_attack_l4_alert`}).option(`filters-target-zone-name`,{type:`string`,array:!0,description:`Used for configuring advanced_ddos_attack_l7_alert`}).option(`filters-traffic-exclusions`,{type:`string`,array:!0,description:`Used for configuring traffic_anomalies_alert`}).option(`filters-tunnel-id`,{type:`string`,array:!0,description:`Used for configuring tunnel_health_event`}).option(`filters-tunnel-name`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-type`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-where`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`filters-zones`,{type:`string`,array:!0,description:`Usage depends on specific alert type`}).option(`name`,{type:`string`,description:`Name of the policy.`}).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 X={command:`update <policy-id>`,describe:`Update a Notification policy.`,builder:Y,handler:async u=>{if(u.dryRun){o({command:`cf alerting policies update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/alerting/v3/policies/${u[`policy-id`]==null?`<policy-id>`:encodeURIComponent(String(u[`policy-id`]))}`,pathParams:{"policy-id":String(u[`policy-id`]??``)},bodyKind:`json`,body:u.body===void 0?i({alert_interval:c(u[`alert-interval`],`alert-interval`,`text`),alert_type:c(u[`alert-type`],`alert-type`,`text`),description:c(u.description,`description`,`text`),enabled:u.enabled,filters:{actions:u[`filters-actions`],affected_asns:u[`filters-affected-asns`],affected_components:u[`filters-affected-components`],affected_locations:u[`filters-affected-locations`],airport_code:u[`filters-airport-code`],alert_trigger_preferences:u[`filters-alert-trigger-preferences`],alert_trigger_preferences_value:u[`filters-alert-trigger-preferences-value`],enabled:u[`filters-enabled`],environment:u[`filters-environment`],event:u[`filters-event`],event_source:u[`filters-event-source`],event_type:u[`filters-event-type`],group_by:u[`filters-group-by`],health_check_id:u[`filters-health-check-id`],incident_impact:u[`filters-incident-impact`],input_id:u[`filters-input-id`],insight_class:u[`filters-insight-class`],limit:u[`filters-limit`],logo_tag:u[`filters-logo-tag`],megabits_per_second:u[`filters-megabits-per-second`],new_health:u[`filters-new-health`],new_status:u[`filters-new-status`],packets_per_second:u[`filters-packets-per-second`],pool_id:u[`filters-pool-id`],pop_names:u[`filters-pop-names`],product:u[`filters-product`],project_id:u[`filters-project-id`],protocol:u[`filters-protocol`],query_tag:u[`filters-query-tag`],requests_per_second:u[`filters-requests-per-second`],selectors:u[`filters-selectors`],services:u[`filters-services`],slo:u[`filters-slo`],status:u[`filters-status`],target_hostname:u[`filters-target-hostname`],target_ip:u[`filters-target-ip`],target_zone_name:u[`filters-target-zone-name`],traffic_exclusions:u[`filters-traffic-exclusions`],tunnel_id:u[`filters-tunnel-id`],tunnel_name:u[`filters-tunnel-name`],type:u[`filters-type`],where:u[`filters-where`],zones:u[`filters-zones`]},name:c(u.name,`name`,`text`)}):r(u.body)});return}let d=await n(u),f=u.local?l:await e();if(u.accountId=f,u.body){let e=r(u.body);a(await s(`Updating`,async()=>d.alerting.policies.update({...e,account_id:f,policy_id:u[`policy-id`]})),{successLabel:`Updated`});return}let p=i({alert_interval:c(u[`alert-interval`],`alert-interval`,`text`),alert_type:c(u[`alert-type`],`alert-type`,`text`),description:c(u.description,`description`,`text`),enabled:u.enabled,filters:{actions:u[`filters-actions`],affected_asns:u[`filters-affected-asns`],affected_components:u[`filters-affected-components`],affected_locations:u[`filters-affected-locations`],airport_code:u[`filters-airport-code`],alert_trigger_preferences:u[`filters-alert-trigger-preferences`],alert_trigger_preferences_value:u[`filters-alert-trigger-preferences-value`],enabled:u[`filters-enabled`],environment:u[`filters-environment`],event:u[`filters-event`],event_source:u[`filters-event-source`],event_type:u[`filters-event-type`],group_by:u[`filters-group-by`],health_check_id:u[`filters-health-check-id`],incident_impact:u[`filters-incident-impact`],input_id:u[`filters-input-id`],insight_class:u[`filters-insight-class`],limit:u[`filters-limit`],logo_tag:u[`filters-logo-tag`],megabits_per_second:u[`filters-megabits-per-second`],new_health:u[`filters-new-health`],new_status:u[`filters-new-status`],packets_per_second:u[`filters-packets-per-second`],pool_id:u[`filters-pool-id`],pop_names:u[`filters-pop-names`],product:u[`filters-product`],project_id:u[`filters-project-id`],protocol:u[`filters-protocol`],query_tag:u[`filters-query-tag`],requests_per_second:u[`filters-requests-per-second`],selectors:u[`filters-selectors`],services:u[`filters-services`],slo:u[`filters-slo`],status:u[`filters-status`],target_hostname:u[`filters-target-hostname`],target_ip:u[`filters-target-ip`],target_zone_name:u[`filters-target-zone-name`],traffic_exclusions:u[`filters-traffic-exclusions`],tunnel_id:u[`filters-tunnel-id`],tunnel_name:u[`filters-tunnel-name`],type:u[`filters-type`],where:u[`filters-where`],zones:u[`filters-zones`]},name:c(u.name,`name`,`text`)});a(await s(`Updating`,async()=>d.alerting.policies.update({...p,account_id:f,policy_id:u[`policy-id`]})),{successLabel:`Updated`})}},Z={command:`policies`,describe:`Notification policies that define which events trigger alerts and where they are delivered`,builder:e=>e.command(H).command(W).command(K).command(J).command(X).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Q(e){return e.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 ne={command:`create`,describe:`Creates a new silence for an account.`,builder:Q,handler:async i=>{if(i.dryRun){o({command:`cf alerting silences create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/alerting/v3/silences`,pathParams:{},bodyKind:`json`,body:i.body===void 0?void 0:r(i.body)});return}let c=await n(i),u=i.local?l:await e();if(i.accountId=u,i.body){let e=r(i.body);a(await s(`Creating`,async()=>c.alerting.silences.create({body:e,account_id:u})),{successLabel:`Created`});return}if(i.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}};function re(e){return e.positional(`silence-id`,{type:`string`,description:`Silence 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 ie={command:`delete <silence-id>`,describe:`Deletes an existing silence for an account.`,builder:re,handler:async r=>{if(r.dryRun){o({command:`cf alerting silences delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/alerting/v3/silences/${r[`silence-id`]==null?`<silence-id>`:encodeURIComponent(String(r[`silence-id`]))}`,pathParams:{"silence-id":String(r[`silence-id`]??``)},bodyKind:`none`});return}let i=await n(r),c=r.local?l:await e();if(r.accountId=c,!await f({force:!!r.force})){process.stderr.write(`Aborted.
6
- `);return}a(await s(`Deleting`,async()=>i.alerting.silences.delete({account_id:c,silence_id:r[`silence-id`]})),{successLabel:`Deleted`})}};function ae(e){return e.positional(`silence-id`,{type:`string`,description:`Silence ID`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const oe={command:`get <silence-id>`,describe:`Gets a specific silence for an account.`,builder:ae,handler:async r=>{if(r.dryRun){o({command:`cf alerting silences get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/alerting/v3/silences/${r[`silence-id`]==null?`<silence-id>`:encodeURIComponent(String(r[`silence-id`]))}`,pathParams:{"silence-id":String(r[`silence-id`]??``)},bodyKind:`none`});return}let i=await n(r),c=r.local?l:await e();r.accountId=c,a(await s(`Loading`,async()=>i.alerting.silences.get({account_id:c,silence_id:r[`silence-id`]})),{successLabel:`Loaded`})}};function $(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const se={command:`list`,describe:`Gets a list of silences for an account.`,builder:$,handler:async r=>{if(r.dryRun){o({command:`cf alerting silences list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/alerting/v3/silences`,pathParams:{},bodyKind:`none`});return}let i=await n(r),c=r.local?l:await e();r.accountId=c,a(await s(`Loading`,async()=>i.alerting.silences.list({account_id:c})),{successLabel:`Loaded`})}};function ce(e){return e.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 le={command:`update`,describe:`Updates existing silences for an account.`,builder:ce,handler:async i=>{if(i.dryRun){o({command:`cf alerting silences update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/alerting/v3/silences`,pathParams:{},bodyKind:`json`,body:i.body===void 0?void 0:r(i.body)});return}let c=await n(i),u=i.local?l:await e();if(i.accountId=u,i.body){let e=r(i.body);a(await s(`Updating`,async()=>c.alerting.silences.update({body:e,account_id:u})),{successLabel:`Updated`});return}if(i.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}},ue={command:`silences`,describe:`Silence windows that temporarily suppress alert notifications during maintenance`,builder:e=>e.command(ne).command(ie).command(oe).command(se).command(le).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},de={command:`alerting`,describe:`Notification policies, delivery destinations, silence windows, and alert history`,builder:e=>e.command(h).command(R).command(B).command(Z).command(ue).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{de as default};
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import{O as e,P as t}from"./oauth-B5k80sip.mjs";import{i as n,n as r}from"./auth-DX9KnJ0P.mjs";import{t as i}from"./output-B6fBFRqe.mjs";import{n as a,t as o}from"./progress-CL8I-7YK.mjs";import{n as s,t as c}from"./input-validation-_fMCApaH.mjs";import{t as l}from"./local-CYc9q7l2.mjs";function u(e){return e.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`})}const d={command:`query`,describe:`Executes a SQL query against Workers Analytics Engine data. Pass the SQL query in the request body as plain text. The response uses newline-delimited JSON (NDJSON) by default, or a single JSON object when the query includes a FORMAT JSON clause. Prefer this method for longer queries that may exceed URL length limits.`,builder:u,handler:async u=>{if(u.dryRun){a({command:`cf analytics_engine sql query`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${t()??`<account-id>`}/analytics_engine/sql`,pathParams:{},bodyKind:`octet-stream`,body:u.body});return}let d=await r(u),f=u.local?l:await e();if(u.accountId=f,u.file){let e=c(u.file);i(await o(`Loading`,async()=>n(d,`POST`,`/accounts/${f}/analytics_engine/sql`,{body:e,headers:{"Content-Type":`text/plain`}})),{successLabel:`Loaded`});return}if(u.body){let e=s(u.body,`body`,`binary`);i(await o(`Loading`,async()=>n(d,`POST`,`/accounts/${f}/analytics_engine/sql`,{body:e,headers:{"Content-Type":`text/plain`}})),{successLabel:`Loaded`});return}i(await o(`Loading`,async()=>d.analyticsEngine.sql.query({account_id:f})),{successLabel:`Loaded`})}},f={command:`sql`,describe:`Operations for sql`,builder:e=>e.command(d).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},p={command:`analytics_engine`,describe:`analytics_engine`,builder:e=>e.command(f).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{p as default};