cf 0.10.0 → 0.12.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 (352) hide show
  1. package/README.md +15 -5
  2. package/dist/_meta/agent-context.json +13 -5
  3. package/dist/_meta/commands.json +2393 -262
  4. package/dist/_meta/hand-written-commands.json +960 -0
  5. package/dist/_meta/schemas.json +1882 -155
  6. package/dist/{abuse-reports-CGF4zcKf.mjs → abuse-reports-D40QFl-y.mjs} +2 -2
  7. package/dist/{access-lhLJo1v2.mjs → access-Dl2IU1ID.mjs} +1 -1
  8. package/dist/account-CPbieCZ4.mjs +2 -0
  9. package/dist/{account-tags-B88TotoH.mjs → account-tags-skfP7H8k.mjs} +4 -4
  10. package/dist/{accounts-BSIAT_iP.mjs → accounts-CSgR6909.mjs} +12 -12
  11. package/dist/{acm-VULm1djv.mjs → acm-CVvCTaNk.mjs} +1 -1
  12. package/dist/{addressing-BHPBIkRY.mjs → addressing-Uq5hEDDP.mjs} +11 -11
  13. package/dist/{agent-context-KBy48G1b.mjs → agent-context-BvuDdaJb.mjs} +1 -1
  14. package/dist/agent-memory-BrHMIU0E.mjs +6 -0
  15. package/dist/ai-audit-BoZuL84i.mjs +2 -0
  16. package/dist/ai-gateway-DE50Jem1.mjs +13 -0
  17. package/dist/ai-search-Fx7NHCHB.mjs +7 -0
  18. package/dist/ai-security-DyLbY9kv.mjs +4 -0
  19. package/dist/ai-v2fP1r0s.mjs +5 -0
  20. package/dist/{alerting-Bl8OqViR.mjs → alerting-5mFZjTcD.mjs} +1 -1
  21. package/dist/analytics-BygTfozw.mjs +3 -0
  22. package/dist/analytics_engine-4L-q362P.mjs +2 -0
  23. package/dist/{api-security-4FVrD4n8.mjs → api-security-DjFsRYWx.mjs} +20 -20
  24. package/dist/argo-TzXPN7tz.mjs +2 -0
  25. package/dist/args-CDgWUP4J.mjs +2 -0
  26. package/dist/{artifacts-CVDGnr2V.mjs → artifacts-dEw2UUBV.mjs} +1 -1
  27. package/dist/audit-logs-CqY7zzwv.mjs +2 -0
  28. package/dist/auth-CPLdkOC7.mjs +5 -0
  29. package/dist/{auth-MQEamPN9.mjs → auth-DY_Y2bXC.mjs} +3 -3
  30. package/dist/billing-DHQuRT8S.mjs +3 -0
  31. package/dist/body-parser-BGVbwPeM.mjs +2 -0
  32. package/dist/bot-management-CfqG79hF.mjs +5 -0
  33. package/dist/botnet-feed-BOeNnDoH.mjs +3 -0
  34. package/dist/brand-protection-DYttrKIM.mjs +3 -0
  35. package/dist/{browser-extension-BtpCbh-2.mjs → browser-extension-CTUCdgfn.mjs} +1 -1
  36. package/dist/browser-run-373D4e1i.mjs +4 -0
  37. package/dist/build-D0ir_S70.mjs +2 -0
  38. package/dist/{cache-VyWK1SjY.mjs → cache-DJXBmc3w.mjs} +1 -1
  39. package/dist/{calls-BxoRYxs4.mjs → calls-COO0Eoz1.mjs} +1 -1
  40. package/dist/certificate-authorities-DbHLmKbd.mjs +2 -0
  41. package/dist/cf-yPz_IqW6.mjs +18 -0
  42. package/dist/chunk-LQW53VED-9MACsvSG.mjs +119 -0
  43. package/dist/chunk-QBZBEHZB-yeyhVUeD.mjs +2 -0
  44. package/dist/{client-certificates-DDUv8K0a.mjs → client-certificates-RBRqYP3f.mjs} +1 -1
  45. package/dist/{client-side-security-D4ysjwWT.mjs → client-side-security-HOmA37et.mjs} +1 -1
  46. package/dist/cloud-connector-C7hw1c1f.mjs +2 -0
  47. package/dist/cloudforce-one-DLOj76q4.mjs +36 -0
  48. package/dist/command-BV87D4tR.mjs +2 -0
  49. package/dist/{completions-BHE4pRjB.mjs → completions-BnD46cXe.mjs} +3 -3
  50. package/dist/config.d.mts +1451 -1366
  51. package/dist/config.mjs +1 -1
  52. package/dist/connector-interrupts-DY-z_LrH.mjs +2 -0
  53. package/dist/connector-telemetry-events-DCXmcAc9.mjs +2 -0
  54. package/dist/connector-telemetry-snapshots-D8GNuzx3.mjs +2 -0
  55. package/dist/{connectors-BqxYMMtQ.mjs → connectors-fEOn-J_i.mjs} +1 -1
  56. package/dist/containers-BDBsEs7-.mjs +58 -0
  57. package/dist/{content-scan-Dgd7A8KF.mjs → content-scan-Cmj9--XY.mjs} +1 -1
  58. package/dist/{csamScanner-DYL37wLc.mjs → csamScanner-BRXyMCyH.mjs} +1 -1
  59. package/dist/{ct-alerting-CkhSbfAs.mjs → ct-alerting-9AvYys-f.mjs} +1 -1
  60. package/dist/custom-certificates-C5qrlyhb.mjs +5 -0
  61. package/dist/custom-csrs-BgOnTbBW.mjs +3 -0
  62. package/dist/{custom-hostnames-q_nsnlye.mjs → custom-hostnames-CbQD9aYo.mjs} +1 -1
  63. package/dist/custom-nameservers-2ZajBkRC.mjs +3 -0
  64. package/dist/custom-pages-Buki_Cb8.mjs +3 -0
  65. package/dist/d1-n2in0cSF.mjs +20 -0
  66. package/dist/data-security-DzOQMkv3.mjs +7 -0
  67. package/dist/dcv-delegation-BTP9LCOm.mjs +2 -0
  68. package/dist/delegate.mjs +1 -1
  69. package/dist/deploy-BUSz35vq.mjs +2 -0
  70. package/dist/deploy-input-BvD9aRP1.mjs +2 -0
  71. package/dist/dev-DY_DquQx.mjs +4 -0
  72. package/dist/{diagnostics-BTH-8nJH.mjs → diagnostics-BvHV8kQb.mjs} +1 -1
  73. package/dist/{directory-BlH6N6Qy.mjs → directory-BeiSyg8A.mjs} +1 -1
  74. package/dist/{dispatch-namespaces-BCjH1JzB.mjs → dispatch-namespaces-Dp8Jjpwy.mjs} +1 -1
  75. package/dist/dist-BBx1io2f.mjs +2 -0
  76. package/dist/dist-Cb9TJ2VV.mjs +9 -0
  77. package/dist/dist-DV7LR38l.mjs +387 -0
  78. package/dist/dist-DvizctjW.mjs +48 -0
  79. package/dist/{dls-BF5iN78p.mjs → dls-BwoU29mS.mjs} +1 -1
  80. package/dist/{dns-CeCTNqRk.mjs → dns-DISAfuzj.mjs} +13 -13
  81. package/dist/{dns-firewall-B54MaLGm.mjs → dns-firewall-wBcCx_ua.mjs} +1 -1
  82. package/dist/{dot-prop-6SRZBKHT-wIVDg_fl.mjs → dot-prop-6SRZBKHT-wwGHcwAa.mjs} +1 -1
  83. package/dist/dry-run-ILZRVpnp.mjs +2 -0
  84. package/dist/durable-objects-DhDL3San.mjs +2 -0
  85. package/dist/email-auth-BROqK6-C.mjs +2 -0
  86. package/dist/email-routing-BZXHDAOO.mjs +6 -0
  87. package/dist/email-security-DVumybrk.mjs +18 -0
  88. package/dist/email-sending-CDQ3_wyz.mjs +7 -0
  89. package/dist/fieldExtractors-Cy1rxHEF.mjs +3 -0
  90. package/dist/{firewall-CBPGJ43p.mjs → firewall-C0g5X7Zd.mjs} +9 -9
  91. package/dist/flagship-fFBiZUz-.mjs +4 -0
  92. package/dist/{fraud-BIhS8pLf.mjs → fraud-CjIETOaM.mjs} +1 -1
  93. package/dist/google-tag-gateway-hPa5IHUx.mjs +2 -0
  94. package/dist/{healthchecks-FiXIk-KP.mjs → healthchecks-CoycpTf9.mjs} +1 -1
  95. package/dist/{hostnames-Bx0mykMR.mjs → hostnames-x_Yezxpr.mjs} +1 -1
  96. package/dist/{hyperdrive-C8qCabBF.mjs → hyperdrive-BlfrTwSq.mjs} +1 -1
  97. package/dist/iam-Bk7K_PPO.mjs +6 -0
  98. package/dist/images-BAEFb9q1.mjs +8 -0
  99. package/dist/index.mjs +1 -1
  100. package/dist/{intel-B-9Z_sJs.mjs → intel-DDkyJVaP.mjs} +1 -1
  101. package/dist/interactive-CRnq-B5I.mjs +11 -0
  102. package/dist/{interactive-DtsCYfrK.mjs → interactive-cytQzL94.mjs} +1 -1
  103. package/dist/ips-DU0ti0i0.mjs +2 -0
  104. package/dist/{keyless-certificates-THHvoXX3.mjs → keyless-certificates-E1P9jBTb.mjs} +1 -1
  105. package/dist/keys-DqldTZqH.mjs +2 -0
  106. package/dist/{kv-BFDUCnft.mjs → kv-CcfCfnwq.mjs} +1 -1
  107. package/dist/{leaked-credential-checks-DUlUCOoJ.mjs → leaked-credential-checks-CqmKaEbd.mjs} +1 -1
  108. package/dist/load-balancers-Dg4pDad1.mjs +6 -0
  109. package/dist/{local-D-aVNu6A.mjs → local-DGiIS1uM.mjs} +1 -1
  110. package/dist/local-runtime--IQr44qq.mjs +2 -0
  111. package/dist/logexplorer-Bu2mG5rh.mjs +17 -0
  112. package/dist/logo-matches-CWUzxY7G.mjs +2 -0
  113. package/dist/logos-BTfdkDPi.mjs +3 -0
  114. package/dist/{logpush-BK34mMQs.mjs → logpush-BZyay3h2.mjs} +1 -1
  115. package/dist/{logs-CLAqX9h2.mjs → logs-BqF7jjQO.mjs} +1 -1
  116. package/dist/{magic-cloud-networking-h_ozrC5S.mjs → magic-cloud-networking-Dhd8pTyM.mjs} +4 -4
  117. package/dist/magic-network-monitoring-D0FnkjuN.mjs +4 -0
  118. package/dist/magic-transit-B5skt0G7.mjs +111 -0
  119. package/dist/managed-transforms-B6X_crcJ.mjs +3 -0
  120. package/dist/matches-DeYaB4I0.mjs +2 -0
  121. package/dist/mcp-ChjBiMx2.mjs +4 -0
  122. package/dist/mesh-DRVAFLBX.mjs +4 -0
  123. package/dist/{moq-qmuVPAO0.mjs → moq-DE7VDEFS.mjs} +1 -1
  124. package/dist/mtls-certificates-Cbc3uAkN.mjs +3 -0
  125. package/dist/{network-D74cSy3t.mjs → network-CDPZNFbn.mjs} +1 -1
  126. package/dist/{network-interconnects-BJ0Nc48J.mjs → network-interconnects-CMRs_chR.mjs} +1 -1
  127. package/dist/oauth-DAa7SwkM.mjs +14 -0
  128. package/dist/{oauth-clients-Br-smLxQ.mjs → oauth-clients-DAI_gcuL.mjs} +1 -1
  129. package/dist/oauth-scopes-BE6xF4_h.mjs +2 -0
  130. package/dist/observability-DnyI8rPJ.mjs +4 -0
  131. package/dist/{open-PBXRGS4R-R-qesf18.mjs → open-PBXRGS4R-DIiYQyU9.mjs} +3 -3
  132. package/dist/{organization-NX7yCZrq.mjs → organization-yh0mSUdI.mjs} +6 -6
  133. package/dist/organizations-B3aU-RCG.mjs +2 -0
  134. package/dist/origin-ca-certificates-BaNWfVqf.mjs +3 -0
  135. package/dist/origin-post-quantum-encryption-CIUtQgyv.mjs +2 -0
  136. package/dist/origin-tls-client-auth-CvEpbX2Q.mjs +4 -0
  137. package/dist/{output-DrpYYfnB.mjs → output-BqDR9h74.mjs} +1 -1
  138. package/dist/page-rules-CzbyXbt6.mjs +27 -0
  139. package/dist/pages-CX8yefTI.mjs +14 -0
  140. package/dist/pay-per-crawl-v4vBOMWD.mjs +4 -0
  141. package/dist/pipelines-BZ1KGupx.mjs +6 -0
  142. package/dist/precursor-D42A9ay5.mjs +4 -0
  143. package/dist/progress-jYW64HY7.mjs +2 -0
  144. package/dist/project-settings-BN7tL0c7.mjs +3 -0
  145. package/dist/prompt-CyATfGUu.mjs +3 -0
  146. package/dist/{public-BwQqexwo-CNW_dPly.mjs → public-BMg6-Hxh-DgIH5obr.mjs} +1 -1
  147. package/dist/queries-xvETUjUE.mjs +3 -0
  148. package/dist/queues-CpqHDtxF.mjs +6 -0
  149. package/dist/{r2-data-catalog-Du7hN9jA.mjs → r2-data-catalog-DgKmlTKR.mjs} +1 -1
  150. package/dist/r2-jhmLvD1z.mjs +24 -0
  151. package/dist/radar-C2J16wpX.mjs +2 -0
  152. package/dist/{rate-limits-yBF3qoYD.mjs → rate-limits-CoH9Xma0.mjs} +1 -1
  153. package/dist/raw-fetch-CNKIypJ7.mjs +2 -0
  154. package/dist/{realtimekit-CIP7lP-a.mjs → realtimekit-CDs0Z5WW.mjs} +1 -1
  155. package/dist/registrar-BI5ewTAk.mjs +23 -0
  156. package/dist/{registrar-sandbox-DiXg8p_1.mjs → registrar-sandbox-al1znWMc.mjs} +4 -4
  157. package/dist/{registry-Bck_zFkz.mjs → registry-5-I2XLwF.mjs} +1 -1
  158. package/dist/reporting-CxsdHAH3.mjs +2 -0
  159. package/dist/request-tracers-DJJCncft.mjs +2 -0
  160. package/dist/{resource-sharing-D1pSDvtf.mjs → resource-sharing-qQGn8AEn.mjs} +1 -1
  161. package/dist/resource-tagging-aTtpX5e5.mjs +2 -0
  162. package/dist/rules-PpsDU89Q.mjs +4 -0
  163. package/dist/rulesets-DP12Aqik.mjs +5 -0
  164. package/dist/rum-DxvpzJYc.mjs +4 -0
  165. package/dist/{schema-B34Q9tLF.mjs → schema-DlLbiOJj.mjs} +1 -1
  166. package/dist/schema-flags-CTfQVGCs.mjs +5 -0
  167. package/dist/schemas-BFCBlp_W.mjs +65 -0
  168. package/dist/{scim-CcSyfKCH.mjs → scim-DJ4AVU20.mjs} +1 -1
  169. package/dist/{secrets-store-DFmvtphu.mjs → secrets-store-D6KDNo_s.mjs} +1 -1
  170. package/dist/security-center-008FMs_z.mjs +2 -0
  171. package/dist/{security-txt-DqnFpjMI.mjs → security-txt-CqcfrhlN.mjs} +1 -1
  172. package/dist/{share-BuwYUzOL.mjs → share-D5fzsVAJ.mjs} +4 -4
  173. package/dist/{deploy-input-CrvuoDGJ.mjs → shared-DlKGNPiT.mjs} +97 -99
  174. package/dist/smart-shield-DpFscIk8.mjs +4 -0
  175. package/dist/snippets-CCKgI2ZX.mjs +4 -0
  176. package/dist/spawn-C3_tJ3RB.mjs +526 -0
  177. package/dist/{spectrum-b7N1ZRAm.mjs → spectrum-LmdqY3ki.mjs} +1 -1
  178. package/dist/{speed-cw31yFva.mjs → speed-CEK36h3A.mjs} +1 -1
  179. package/dist/src-CEb2fgtT.mjs +108 -0
  180. package/dist/{ssl-CsEhRVTO.mjs → ssl-ChHUyaQm.mjs} +1 -1
  181. package/dist/startup-profile-Dpxg-MjV.mjs +17 -0
  182. package/dist/{state-Bb5Cbc_L.mjs → state-DeX23Kmg.mjs} +1 -1
  183. package/dist/{stream-DFOao6Gu.mjs → stream-DfUSELMX.mjs} +13 -13
  184. package/dist/submit-DF2G5CIz.mjs +2 -0
  185. package/dist/tags-nFJJHlLJ.mjs +2 -0
  186. package/dist/tenant-CRLw1oRU.mjs +2 -0
  187. package/dist/tenant-custom-nameservers-BvBQRDcs.mjs +3 -0
  188. package/dist/{tools-BHfBOZOU.mjs → tools-j8UGEtP1.mjs} +1 -1
  189. package/dist/{tunnel-DkMiNtVY.mjs → tunnel-CMQeBgmb.mjs} +1 -1
  190. package/dist/tunnels-iVA3MrdS.mjs +2 -0
  191. package/dist/turnstile-DQHP6-_b.mjs +23 -0
  192. package/dist/{ui-DE8CNn6c.mjs → ui-DJFcf61J.mjs} +1 -1
  193. package/dist/url-info-BVgdb_pf.mjs +2 -0
  194. package/dist/{url-normalization-ClfFiruK.mjs → url-normalization-BTcxLxIQ.mjs} +1 -1
  195. package/dist/url-scanner-DwuDZLPk.mjs +2 -0
  196. package/dist/user-I_MbB_KX.mjs +12 -0
  197. package/dist/values-S-Q7-5o8.mjs +2 -0
  198. package/dist/{vectorize-CVKu7lEt.mjs → vectorize-CNZdF_0A.mjs} +1 -1
  199. package/dist/waiting-rooms-Bo-OSsxu.mjs +11 -0
  200. package/dist/{web-assets-C2s9kzWf.mjs → web-assets-tlFzKdNL.mjs} +1 -1
  201. package/dist/web3-CdbfoZ2x.mjs +4 -0
  202. package/dist/workers-DQ9Q7czn.mjs +28 -0
  203. package/dist/{workers-builds-B55-oXOa.mjs → workers-builds-CGRhYx-x.mjs} +1 -1
  204. package/dist/{workflows-B-kGHxFu.mjs → workflows-BhEy-crm.mjs} +1 -1
  205. package/dist/zaraz-DbKvA_8C.mjs +2 -0
  206. package/dist/{zero-trust-DV3sIOvu.mjs → zero-trust-DrHCPVOc.mjs} +67 -66
  207. package/dist/zone-D2zrbJI2.mjs +2 -0
  208. package/dist/zones-DrpxQ_-A.mjs +21 -0
  209. package/package.json +12 -8
  210. package/dist/account-CYRm3yoN.mjs +0 -2
  211. package/dist/agent-memory-DDv_Gxr7.mjs +0 -6
  212. package/dist/ai-audit-BWZGvbca.mjs +0 -2
  213. package/dist/ai-gateway-jeB-sAgP.mjs +0 -13
  214. package/dist/ai-search-BmdskMjR.mjs +0 -7
  215. package/dist/ai-security-CsmfcaUx.mjs +0 -4
  216. package/dist/ai-viHB1tgI.mjs +0 -5
  217. package/dist/analytics-vOxw8Hy0.mjs +0 -3
  218. package/dist/analytics_engine-DO4-C0wD.mjs +0 -2
  219. package/dist/argo-CQfCgazW.mjs +0 -2
  220. package/dist/args-DlUhyGU0.mjs +0 -2
  221. package/dist/audit-logs-CzpwvQ6A.mjs +0 -2
  222. package/dist/auth-D0xZxAEa.mjs +0 -5
  223. package/dist/billing-aJgapeRm.mjs +0 -3
  224. package/dist/body-parser-C-c9gfH1.mjs +0 -2
  225. package/dist/bot-management-Y2q5d-pi.mjs +0 -5
  226. package/dist/botnet-feed-DANJqfmE.mjs +0 -3
  227. package/dist/brand-protection-CjpZWBjp.mjs +0 -3
  228. package/dist/browser-run-BFn9h2Tz.mjs +0 -4
  229. package/dist/build-DcflwvqN.mjs +0 -2
  230. package/dist/certificate-authorities-D7OAFxF_.mjs +0 -2
  231. package/dist/cf-C7DU4819.mjs +0 -18
  232. package/dist/chunk-LQW53VED-DLrXV-hE.mjs +0 -499
  233. package/dist/cloud-connector-Bhec6z2P.mjs +0 -2
  234. package/dist/cloudforce-one-J_hn9ss9.mjs +0 -36
  235. package/dist/connector-interrupts-Dycx8zFx.mjs +0 -2
  236. package/dist/connector-telemetry-events-BmxOSNtN.mjs +0 -2
  237. package/dist/connector-telemetry-snapshots-CdcqfKnH.mjs +0 -2
  238. package/dist/containers-CKW081JA.mjs +0 -54
  239. package/dist/custom-certificates-BzAOnEoT.mjs +0 -5
  240. package/dist/custom-csrs-CgzG3pd3.mjs +0 -3
  241. package/dist/custom-nameservers-BUBmfhUe.mjs +0 -3
  242. package/dist/custom-pages-M7jA2Hit.mjs +0 -3
  243. package/dist/d1-BFvMd6-S.mjs +0 -20
  244. package/dist/data-security-Bji4Or_j.mjs +0 -7
  245. package/dist/dcv-delegation-BuoRQ1Yh.mjs +0 -2
  246. package/dist/deploy-CZ7bgNDu.mjs +0 -2
  247. package/dist/dev-V10MG-Bg.mjs +0 -4
  248. package/dist/dist-CgrMkXFx.mjs +0 -72
  249. package/dist/durable-objects-D8FQORrL.mjs +0 -2
  250. package/dist/email-auth-DJK0Eb30.mjs +0 -2
  251. package/dist/email-routing-NpmiKIrl.mjs +0 -6
  252. package/dist/email-security-BLZ7WZ9Z.mjs +0 -18
  253. package/dist/email-sending-dn-353Nx.mjs +0 -7
  254. package/dist/fieldExtractors-ahysj57J.mjs +0 -3
  255. package/dist/flagship-BusjRNIb.mjs +0 -4
  256. package/dist/google-tag-gateway-TZZ3F1tV.mjs +0 -2
  257. package/dist/iam-Cj63Kjc6.mjs +0 -6
  258. package/dist/images-CBWXCDhy.mjs +0 -8
  259. package/dist/ips-qs9eGJnI.mjs +0 -2
  260. package/dist/keys-D7N0j4-x.mjs +0 -2
  261. package/dist/load-balancers-D2zbQ8fT.mjs +0 -6
  262. package/dist/local-runtime-Dh3keC5v.mjs +0 -2
  263. package/dist/logexplorer-CUsfZ_bS.mjs +0 -13
  264. package/dist/logo-matches-CJcthPHf.mjs +0 -2
  265. package/dist/logos-BS65zN8q.mjs +0 -3
  266. package/dist/magic-network-monitoring-C7tAPNKP.mjs +0 -4
  267. package/dist/magic-transit-BtsFePMx.mjs +0 -111
  268. package/dist/managed-transforms-Cm_KVCMB.mjs +0 -3
  269. package/dist/matches-InA1hwII.mjs +0 -2
  270. package/dist/mcp-mJ7bekNJ.mjs +0 -4
  271. package/dist/mesh-BK4S1Ezy.mjs +0 -4
  272. package/dist/mtls-certificates-CU4OAAXY.mjs +0 -3
  273. package/dist/oauth-B0ETkNcX.mjs +0 -15
  274. package/dist/oauth-scopes-D5bF11ju.mjs +0 -2
  275. package/dist/observability-BWE0Gg3V.mjs +0 -4
  276. package/dist/organizations-DLhiRt8g.mjs +0 -2
  277. package/dist/origin-ca-certificates-Ff4McZRQ.mjs +0 -3
  278. package/dist/origin-post-quantum-encryption-UuTr4_SW.mjs +0 -2
  279. package/dist/origin-tls-client-auth-DOJ1zlH3.mjs +0 -4
  280. package/dist/page-rules-BSz1gO-_.mjs +0 -18
  281. package/dist/pages-DVDogxPs.mjs +0 -14
  282. package/dist/pay-per-crawl-BrLXK7gT.mjs +0 -4
  283. package/dist/pipelines-BszRk4sM.mjs +0 -6
  284. package/dist/precursor-BPNjQr76.mjs +0 -4
  285. package/dist/progress-CsHIt3Tp.mjs +0 -2
  286. package/dist/prompt-DdegNPpg.mjs +0 -3
  287. package/dist/queries-JL1H1Biz.mjs +0 -3
  288. package/dist/queues-DpkYdRUE.mjs +0 -6
  289. package/dist/r2-CKozthw_.mjs +0 -24
  290. package/dist/radar-C-92vggG.mjs +0 -2
  291. package/dist/raw-fetch-CteyTOM2.mjs +0 -2
  292. package/dist/registrar-DKKN0M29.mjs +0 -21
  293. package/dist/reporting-fg_GKXe1.mjs +0 -2
  294. package/dist/request-tracers-CkMya96z.mjs +0 -2
  295. package/dist/resource-tagging-z48JGHCq.mjs +0 -2
  296. package/dist/rules-BTmNjDN-.mjs +0 -4
  297. package/dist/rulesets-CsoSM-17.mjs +0 -5
  298. package/dist/rum-DB4iO2q5.mjs +0 -4
  299. package/dist/schema-flags-iGoOriJt.mjs +0 -5
  300. package/dist/security-center-DFKeHq5c.mjs +0 -2
  301. package/dist/session-D6KHthHf.mjs +0 -2
  302. package/dist/shared-VppSAQf4.mjs +0 -2
  303. package/dist/smart-shield-D6X8L7p8.mjs +0 -4
  304. package/dist/snippets-DIpc9pb_.mjs +0 -4
  305. package/dist/spawn-O1RS01vr.mjs +0 -523
  306. package/dist/src-D_HETJNy.mjs +0 -108
  307. package/dist/submit--xTzyNPy.mjs +0 -2
  308. package/dist/tags-efICDkah.mjs +0 -2
  309. package/dist/tenant-CerHuToJ.mjs +0 -2
  310. package/dist/tenant-custom-nameservers-C4otMBm2.mjs +0 -3
  311. package/dist/triggers-BEsiiKAf.mjs +0 -2
  312. package/dist/tunnels-D0J8lJoI.mjs +0 -2
  313. package/dist/turnstile-CFmtY5bn.mjs +0 -23
  314. package/dist/url-info-DBCeRWwb.mjs +0 -2
  315. package/dist/url-scanner-CNyvg65L.mjs +0 -2
  316. package/dist/user-bifVEQq5.mjs +0 -12
  317. package/dist/values-OxkdP1tV.mjs +0 -2
  318. package/dist/versions-BVL-Ludh.mjs +0 -2
  319. package/dist/waiting-rooms-CmRAl51T.mjs +0 -11
  320. package/dist/web3-y_cY91V_.mjs +0 -4
  321. package/dist/workers-jDcq14GH.mjs +0 -24
  322. package/dist/zaraz-27zwjLvv.mjs +0 -2
  323. package/dist/zone-BJix2KQ9.mjs +0 -2
  324. package/dist/zones-Bkj5i92c.mjs +0 -21
  325. /package/dist/{alerts-CRmjqOZi.mjs → alerts-9PR5sQ_z.mjs} +0 -0
  326. /package/dist/{autorag-BD7cu5NU.mjs → autorag-Bevo1kIH.mjs} +0 -0
  327. /package/dist/{brands-BhALBkX2.mjs → brands-C4M04Man.mjs} +0 -0
  328. /package/dist/{chunk-6EUZQHAF-B7bSMYLe.mjs → chunk-6EUZQHAF-C3w62dek.mjs} +0 -0
  329. /package/dist/{clear-BgF8No7D.mjs → clear-DS0eRXOc.mjs} +0 -0
  330. /package/dist/{cli-types-BsTty22w.mjs → cli-types-C3nVfpSG.mjs} +0 -0
  331. /package/dist/{connector-telemetry-events-latest-BY2556uL.mjs → connector-telemetry-events-latest-CKKG6_pD.mjs} +0 -0
  332. /package/dist/{connector-telemetry-snapshots-latest-BHYdxUEF.mjs → connector-telemetry-snapshots-latest-Bv5OddJr.mjs} +0 -0
  333. /package/dist/{domain-info-C50W5GhA.mjs → domain-info-BUiaGCEq.mjs} +0 -0
  334. /package/dist/{health-BFNZqiAm.mjs → health-vX6Ml2Na.mjs} +0 -0
  335. /package/dist/{input-validation-Bav2M9F-.mjs → input-validation-1esLElok.mjs} +0 -0
  336. /package/dist/{internal-BTeSewwB.mjs → internal-ROz7anul.mjs} +0 -0
  337. /package/dist/{live-Dkiyu30_.mjs → live-CSxvigCS.mjs} +0 -0
  338. /package/dist/{metadata-8AkOftcB.mjs → metadata-DEqBUaSv.mjs} +0 -0
  339. /package/dist/{rate-limit-analytics-Dz-Wv1T0.mjs → rate-limit-analytics-CgHgKjmV.mjs} +0 -0
  340. /package/dist/{ready-TKOkKeRg.mjs → ready-6G9zVGPJ.mjs} +0 -0
  341. /package/dist/{recent-submissions-3Asm6eIi.mjs → recent-submissions-B3Smh-QM.mjs} +0 -0
  342. /package/dist/{refute-BVz9nMyd.mjs → refute-DjkmLSNe.mjs} +0 -0
  343. /package/dist/{resolve-CeBbH6Pq.mjs → resolve-DEvdeprv.mjs} +0 -0
  344. /package/dist/{scan-logo-ZteA-PUV.mjs → scan-logo-545qLcGs.mjs} +0 -0
  345. /package/dist/{scan-page-DWDSyzQ7.mjs → scan-page-DRQiVufl.mjs} +0 -0
  346. /package/dist/{search-DGNc37HK.mjs → search-CXbqFoqe.mjs} +0 -0
  347. /package/dist/{signed-url-B5Qpn2mn.mjs → signed-url-rU_nvgFA.mjs} +0 -0
  348. /package/dist/{submission-info-FjUolE6A.mjs → submission-info-D6PgXNQP.mjs} +0 -0
  349. /package/dist/{theme-CeVf-5qG.mjs → theme-CrIBazAF.mjs} +0 -0
  350. /package/dist/{total-queries-NHJj1HGq.mjs → total-queries-XkFyu8H5.mjs} +0 -0
  351. /package/dist/{tracked-domains-CniKVHIp.mjs → tracked-domains-CmcRXHj_.mjs} +0 -0
  352. /package/dist/{verify-DS1PWAJe.mjs → verify-CM1NakP0.mjs} +0 -0
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env node
2
+ import{t as e}from"./local-DGiIS1uM.mjs";import{f as t,g as n}from"./oauth-DAa7SwkM.mjs";import{r}from"./auth-DY_Y2bXC.mjs";import{t as i}from"./output-BqDR9h74.mjs";import{t as a}from"./dry-run-ILZRVpnp.mjs";import{t as o}from"./progress-jYW64HY7.mjs";import{n as s,r as c,t as l}from"./body-parser-BGVbwPeM.mjs";import{n as u}from"./input-validation-1esLElok.mjs";import{a as d,i as f,n as p}from"./prompt-CyATfGUu.mjs";import{t as m}from"./cli-types-C3nVfpSG.mjs";function h(e){return e.option(`account-provider-id`,{type:`string`,description:`The account_provider_id field`}).option(`cost-in`,{type:`number`,description:`The cost_in field`}).option(`cost-out`,{type:`number`,description:`The cost_out field`}).option(`cost-type`,{type:`string`,description:`The cost_type field`,default:`tokens`}).option(`enable`,{type:`boolean`,description:`The enable field`}).option(`model`,{type:`string`,description:`The model field`}).option(`model-rule`,{type:`string`,description:`The model_rule field`,choices:[`equals`,`starts-with`,`contains`],default:`equals`}).option(`token-pricing-input-audio-tokens`,{type:`number`,description:`The token_pricing.input_audio_tokens field`}).option(`token-pricing-input-cache-creation-tokens`,{type:`number`,description:`The token_pricing.input_cache_creation_tokens field`}).option(`token-pricing-input-cached-tokens`,{type:`number`,description:`The token_pricing.input_cached_tokens field`}).option(`token-pricing-input-image-count`,{type:`number`,description:`The token_pricing.input_image_count field`}).option(`token-pricing-input-image-tokens`,{type:`number`,description:`The token_pricing.input_image_tokens field`}).option(`token-pricing-input-text-tokens`,{type:`number`,description:`The token_pricing.input_text_tokens field`}).option(`token-pricing-input-tokens`,{type:`number`,description:`The token_pricing.input_tokens field`}).option(`token-pricing-input-video-tokens`,{type:`number`,description:`The token_pricing.input_video_tokens field`}).option(`token-pricing-output-image-count`,{type:`number`,description:`The token_pricing.output_image_count field`}).option(`token-pricing-output-reasoning-tokens`,{type:`number`,description:`The token_pricing.output_reasoning_tokens field`}).option(`token-pricing-output-tokens`,{type:`number`,description:`The token_pricing.output_tokens field`}).option(`token-pricing-total-tokens`,{type:`number`,description:`The token_pricing.total_tokens field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const ee={command:`create`,describe:`Creates a new AI Gateway.`,builder:h,handler:async c=>{if(c.dryRun){a({command:`cf ai-gateway account-providers costs create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/custom-providers/costs`,pathParams:{},bodyKind:`json`,body:c.body===void 0?l({account_provider_id:u(c[`account-provider-id`],`account-provider-id`,`text`),cost_in:c[`cost-in`],cost_out:c[`cost-out`],cost_type:u(c[`cost-type`],`cost-type`,`text`),enable:c.enable,model:u(c.model,`model`,`text`),model_rule:u(c[`model-rule`],`model-rule`,`text`),token_pricing:{input_audio_tokens:c[`token-pricing-input-audio-tokens`],input_cache_creation_tokens:c[`token-pricing-input-cache-creation-tokens`],input_cached_tokens:c[`token-pricing-input-cached-tokens`],input_image_count:c[`token-pricing-input-image-count`],input_image_tokens:c[`token-pricing-input-image-tokens`],input_text_tokens:c[`token-pricing-input-text-tokens`],input_tokens:c[`token-pricing-input-tokens`],input_video_tokens:c[`token-pricing-input-video-tokens`],output_image_count:c[`token-pricing-output-image-count`],output_reasoning_tokens:c[`token-pricing-output-reasoning-tokens`],output_tokens:c[`token-pricing-output-tokens`],total_tokens:c[`token-pricing-total-tokens`]}}):s(c.body)});return}let f=await r(c),p=c.local?e:await t();if(c.accountId=p,c.body){let e=s(c.body);i(await o(`Creating`,async()=>f.aiGateway.accountProviders.costs.create({...e,account_id:p})),{successLabel:`Created`});return}c[`account-provider-id`]===void 0&&(c[`account-provider-id`]=await d(`account-provider-id`,`The account_provider_id field`)),c.model===void 0&&(c.model=await d(`model`,`The model field`));let m=l({account_provider_id:u(c[`account-provider-id`],`account-provider-id`,`text`),cost_in:c[`cost-in`],cost_out:c[`cost-out`],cost_type:u(c[`cost-type`],`cost-type`,`text`),enable:c.enable,model:u(c.model,`model`,`text`),model_rule:u(c[`model-rule`],`model-rule`,`text`),token_pricing:{input_audio_tokens:c[`token-pricing-input-audio-tokens`],input_cache_creation_tokens:c[`token-pricing-input-cache-creation-tokens`],input_cached_tokens:c[`token-pricing-input-cached-tokens`],input_image_count:c[`token-pricing-input-image-count`],input_image_tokens:c[`token-pricing-input-image-tokens`],input_text_tokens:c[`token-pricing-input-text-tokens`],input_tokens:c[`token-pricing-input-tokens`],input_video_tokens:c[`token-pricing-input-video-tokens`],output_image_count:c[`token-pricing-output-image-count`],output_reasoning_tokens:c[`token-pricing-output-reasoning-tokens`],output_tokens:c[`token-pricing-output-tokens`],total_tokens:c[`token-pricing-total-tokens`]}});i(await o(`Creating`,async()=>f.aiGateway.accountProviders.costs.create({...m,account_id:p})),{successLabel:`Created`})}};function te(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 g={command:`delete <id>`,describe:`Deletes an AI Gateway dataset.`,builder:te,handler:async s=>{if(s.dryRun){a({command:`cf ai-gateway account-providers costs delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/custom-providers/costs/${s.id==null?`<id>`:encodeURIComponent(String(s.id))}`,pathParams:{id:String(s.id??``)},bodyKind:`none`});return}let c=await r(s),l=s.local?e:await t();if(s.accountId=l,!await p({force:!!s.force})){process.stderr.write(`Aborted.
3
+ `);return}i(await o(`Deleting`,async()=>c.aiGateway.accountProviders.costs.delete({account_id:l,id:s.id})),{successLabel:`Deleted`})}};function _(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 v={command:`get <id>`,describe:`Retrieves details for a specific AI Gateway dataset.`,builder:_,handler:async s=>{if(s.dryRun){a({command:`cf ai-gateway account-providers costs get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/custom-providers/costs/${s.id==null?`<id>`:encodeURIComponent(String(s.id))}`,pathParams:{id:String(s.id??``)},bodyKind:`none`});return}let c=await r(s),l=s.local?e:await t();s.accountId=l,i(await o(`Loading`,async()=>c.aiGateway.accountProviders.costs.get({account_id:l,id:s.id})),{successLabel:`Loaded`})}};function y(e){return e.option(`page`,{type:`number`,description:`Page`}).option(`per-page`,{type:`number`,description:`Per page`}).option(`enable`,{type:`boolean`,description:`Enable`}).option(`account-provider-id`,{type:`string`,description:`Account provider ID`}).option(`model-rule`,{type:`string`,description:`Model rule`,choices:[`equals`,`starts-with`,`contains`]}).option(`cost-type`,{type:`string`,description:`Cost type`}).option(`search`,{type:`string`,description:`Search by model, changed_by`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const b={command:`list`,describe:`Lists all AI Gateway evaluator types configured for the account.`,builder:m(y),handler:async s=>{let c={page:s.page,per_page:s[`per-page`],enable:s.enable,account_provider_id:s[`account-provider-id`],model_rule:s[`model-rule`],cost_type:s[`cost-type`],search:s.search};if(s.dryRun){a({command:`cf ai-gateway account-providers costs list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/custom-providers/costs`,pathParams:{},query:c,bodyKind:`none`});return}let l=await r(s),u=s.local?e:await t();s.accountId=u,i(await o(`Loading`,async()=>l.aiGateway.accountProviders.costs.list({account_id:u,...c})),{successLabel:`Loaded`})}};function x(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`cost-in`,{type:`number`,description:`The cost_in field`}).option(`cost-out`,{type:`number`,description:`The cost_out field`}).option(`cost-type`,{type:`string`,description:`The cost_type field`}).option(`enable`,{type:`boolean`,description:`The enable field`}).option(`model`,{type:`string`,description:`The model field`}).option(`model-rule`,{type:`string`,description:`The model_rule field`,choices:[`equals`,`starts-with`,`contains`]}).option(`token-pricing-input-audio-tokens`,{type:`number`,description:`The token_pricing.input_audio_tokens field`}).option(`token-pricing-input-cache-creation-tokens`,{type:`number`,description:`The token_pricing.input_cache_creation_tokens field`}).option(`token-pricing-input-cached-tokens`,{type:`number`,description:`The token_pricing.input_cached_tokens field`}).option(`token-pricing-input-image-count`,{type:`number`,description:`The token_pricing.input_image_count field`}).option(`token-pricing-input-image-tokens`,{type:`number`,description:`The token_pricing.input_image_tokens field`}).option(`token-pricing-input-text-tokens`,{type:`number`,description:`The token_pricing.input_text_tokens field`}).option(`token-pricing-input-tokens`,{type:`number`,description:`The token_pricing.input_tokens field`}).option(`token-pricing-input-video-tokens`,{type:`number`,description:`The token_pricing.input_video_tokens field`}).option(`token-pricing-output-image-count`,{type:`number`,description:`The token_pricing.output_image_count field`}).option(`token-pricing-output-reasoning-tokens`,{type:`number`,description:`The token_pricing.output_reasoning_tokens field`}).option(`token-pricing-output-tokens`,{type:`number`,description:`The token_pricing.output_tokens field`}).option(`token-pricing-total-tokens`,{type:`number`,description:`The token_pricing.total_tokens field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const S={command:`update <id>`,describe:`Updates an existing AI Gateway dataset.`,builder:x,handler:async c=>{if(c.dryRun){a({command:`cf ai-gateway account-providers costs update`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/custom-providers/costs/${c.id==null?`<id>`:encodeURIComponent(String(c.id))}`,pathParams:{id:String(c.id??``)},bodyKind:`json`,body:c.body===void 0?l({cost_in:c[`cost-in`],cost_out:c[`cost-out`],cost_type:u(c[`cost-type`],`cost-type`,`text`),enable:c.enable,model:u(c.model,`model`,`text`),model_rule:u(c[`model-rule`],`model-rule`,`text`),token_pricing:{input_audio_tokens:c[`token-pricing-input-audio-tokens`],input_cache_creation_tokens:c[`token-pricing-input-cache-creation-tokens`],input_cached_tokens:c[`token-pricing-input-cached-tokens`],input_image_count:c[`token-pricing-input-image-count`],input_image_tokens:c[`token-pricing-input-image-tokens`],input_text_tokens:c[`token-pricing-input-text-tokens`],input_tokens:c[`token-pricing-input-tokens`],input_video_tokens:c[`token-pricing-input-video-tokens`],output_image_count:c[`token-pricing-output-image-count`],output_reasoning_tokens:c[`token-pricing-output-reasoning-tokens`],output_tokens:c[`token-pricing-output-tokens`],total_tokens:c[`token-pricing-total-tokens`]}}):s(c.body)});return}let d=await r(c),f=c.local?e:await t();if(c.accountId=f,c.body){let e=s(c.body);i(await o(`Updating`,async()=>d.aiGateway.accountProviders.costs.update({...e,account_id:f,id:c.id})),{successLabel:`Updated`});return}let p=l({cost_in:c[`cost-in`],cost_out:c[`cost-out`],cost_type:u(c[`cost-type`],`cost-type`,`text`),enable:c.enable,model:u(c.model,`model`,`text`),model_rule:u(c[`model-rule`],`model-rule`,`text`),token_pricing:{input_audio_tokens:c[`token-pricing-input-audio-tokens`],input_cache_creation_tokens:c[`token-pricing-input-cache-creation-tokens`],input_cached_tokens:c[`token-pricing-input-cached-tokens`],input_image_count:c[`token-pricing-input-image-count`],input_image_tokens:c[`token-pricing-input-image-tokens`],input_text_tokens:c[`token-pricing-input-text-tokens`],input_tokens:c[`token-pricing-input-tokens`],input_video_tokens:c[`token-pricing-input-video-tokens`],output_image_count:c[`token-pricing-output-image-count`],output_reasoning_tokens:c[`token-pricing-output-reasoning-tokens`],output_tokens:c[`token-pricing-output-tokens`],total_tokens:c[`token-pricing-total-tokens`]}});i(await o(`Updating`,async()=>d.aiGateway.accountProviders.costs.update({...p,account_id:f,id:c.id})),{successLabel:`Updated`})}},C={command:`costs`,describe:`Operations for account-providers.costs`,builder:e=>e.command(ee).command(g).command(v).command(b).command(S).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function w(e){return e.option(`base-url`,{type:`string`,description:`The base_url field`}).option(`beta`,{type:`boolean`,description:`The beta field`}).option(`curl-example`,{type:`string`,description:`The curl_example field`}).option(`description`,{type:`string`,description:`The description field`}).option(`enable`,{type:`boolean`,description:`The enable field`}).option(`headers`,{type:`string`,description:`The headers field`}).option(`js-example`,{type:`string`,description:`The js_example field`}).option(`link`,{type:`string`,description:`The link field`}).option(`name`,{type:`string`,description:`The name field`}).option(`position`,{type:`number`,description:`The position field`}).option(`slug`,{type:`string`,description:`The slug field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const T={command:`create`,describe:`Creates a new AI Gateway.`,builder:w,handler:async c=>{if(c.dryRun){a({command:`cf ai-gateway account-providers create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/custom-providers`,pathParams:{},bodyKind:`json`,body:c.body===void 0?l({base_url:u(c[`base-url`],`base-url`,`text`),beta:c.beta,curl_example:u(c[`curl-example`],`curl-example`,`text`),description:u(c.description,`description`,`text`),enable:c.enable,headers:u(c.headers,`headers`,`text`),js_example:u(c[`js-example`],`js-example`,`text`),link:u(c.link,`link`,`text`),name:u(c.name,`name`,`text`),position:c.position,slug:u(c.slug,`slug`,`text`)}):s(c.body)});return}let f=await r(c),p=c.local?e:await t();if(c.accountId=p,c.body){let e=s(c.body);i(await o(`Creating`,async()=>f.aiGateway.accountProviders.create({...e,account_id:p})),{successLabel:`Created`});return}c[`base-url`]===void 0&&(c[`base-url`]=await d(`base-url`,`The base_url field`)),c.name===void 0&&(c.name=await d(`name`,`The name field`)),c.slug===void 0&&(c.slug=await d(`slug`,`The slug field`));let m=l({base_url:u(c[`base-url`],`base-url`,`text`),beta:c.beta,curl_example:u(c[`curl-example`],`curl-example`,`text`),description:u(c.description,`description`,`text`),enable:c.enable,headers:u(c.headers,`headers`,`text`),js_example:u(c[`js-example`],`js-example`,`text`),link:u(c.link,`link`,`text`),name:u(c.name,`name`,`text`),position:c.position,slug:u(c.slug,`slug`,`text`)});i(await o(`Creating`,async()=>f.aiGateway.accountProviders.create({...m,account_id:p})),{successLabel:`Created`})}};function E(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 D={command:`delete <id>`,describe:`Deletes an AI Gateway dataset.`,builder:E,handler:async s=>{if(s.dryRun){a({command:`cf ai-gateway account-providers delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/custom-providers/${s.id==null?`<id>`:encodeURIComponent(String(s.id))}`,pathParams:{id:String(s.id??``)},bodyKind:`none`});return}let c=await r(s),l=s.local?e:await t();if(s.accountId=l,!await p({force:!!s.force})){process.stderr.write(`Aborted.
4
+ `);return}i(await o(`Deleting`,async()=>c.aiGateway.accountProviders.delete({account_id:l,id:s.id})),{successLabel:`Deleted`})}};function O(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 k={command:`get <id>`,describe:`Retrieves details for a specific AI Gateway dataset.`,builder:O,handler:async s=>{if(s.dryRun){a({command:`cf ai-gateway account-providers get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/custom-providers/${s.id==null?`<id>`:encodeURIComponent(String(s.id))}`,pathParams:{id:String(s.id??``)},bodyKind:`none`});return}let c=await r(s),l=s.local?e:await t();s.accountId=l,i(await o(`Loading`,async()=>c.aiGateway.accountProviders.get({account_id:l,id:s.id})),{successLabel:`Loaded`})}};function A(e){return e.option(`page`,{type:`number`,description:`Page`}).option(`per-page`,{type:`number`,description:`Per page`}).option(`beta`,{type:`boolean`,description:`Beta`}).option(`enable`,{type:`boolean`,description:`Enable`}).option(`search`,{type:`string`,description:`Search by id, name, slug`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const j={command:`list`,describe:`Lists all AI Gateway evaluator types configured for the account.`,builder:A,handler:async s=>{let c={page:s.page,per_page:s[`per-page`],beta:s.beta,enable:s.enable,search:s.search};if(s.dryRun){a({command:`cf ai-gateway account-providers list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/custom-providers`,pathParams:{},query:c,bodyKind:`none`});return}let l=await r(s),u=s.local?e:await t();s.accountId=u,i(await o(`Loading`,async()=>l.aiGateway.accountProviders.list({account_id:u,...c})),{successLabel:`Loaded`})}};function M(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`base-url`,{type:`string`,description:`The base_url field`}).option(`beta`,{type:`boolean`,description:`The beta field`}).option(`curl-example`,{type:`string`,description:`The curl_example field`}).option(`description`,{type:`string`,description:`The description field`}).option(`enable`,{type:`boolean`,description:`The enable field`}).option(`headers`,{type:`string`,description:`The headers field`}).option(`js-example`,{type:`string`,description:`The js_example field`}).option(`link`,{type:`string`,description:`The link field`}).option(`logo`,{type:`string`,description:`The logo field`}).option(`name`,{type:`string`,description:`The name field`}).option(`position`,{type:`number`,description:`The position field`}).option(`slug`,{type:`string`,description:`The slug field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const N={command:`update <id>`,describe:`Updates an existing AI Gateway dataset.`,builder:M,handler:async c=>{if(c.dryRun){a({command:`cf ai-gateway account-providers update`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/custom-providers/${c.id==null?`<id>`:encodeURIComponent(String(c.id))}`,pathParams:{id:String(c.id??``)},bodyKind:`json`,body:c.body===void 0?l({base_url:u(c[`base-url`],`base-url`,`text`),beta:c.beta,curl_example:u(c[`curl-example`],`curl-example`,`text`),description:u(c.description,`description`,`text`),enable:c.enable,headers:u(c.headers,`headers`,`text`),js_example:u(c[`js-example`],`js-example`,`text`),link:u(c.link,`link`,`text`),logo:u(c.logo,`logo`,`text`),name:u(c.name,`name`,`text`),position:c.position,slug:u(c.slug,`slug`,`text`)}):s(c.body)});return}let d=await r(c),f=c.local?e:await t();if(c.accountId=f,c.body){let e=s(c.body);i(await o(`Updating`,async()=>d.aiGateway.accountProviders.update({...e,account_id:f,id:c.id})),{successLabel:`Updated`});return}let p=l({base_url:u(c[`base-url`],`base-url`,`text`),beta:c.beta,curl_example:u(c[`curl-example`],`curl-example`,`text`),description:u(c.description,`description`,`text`),enable:c.enable,headers:u(c.headers,`headers`,`text`),js_example:u(c[`js-example`],`js-example`,`text`),link:u(c.link,`link`,`text`),logo:u(c.logo,`logo`,`text`),name:u(c.name,`name`,`text`),position:c.position,slug:u(c.slug,`slug`,`text`)});i(await o(`Updating`,async()=>d.aiGateway.accountProviders.update({...p,account_id:f,id:c.id})),{successLabel:`Updated`})}},P={command:`account-providers`,describe:`Operations for account-providers`,builder:e=>e.command(T).command(D).command(k).command(j).command(N).command(C).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function F(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const I={command:`credit-balance`,describe:`Retrieve the current credit balance, payment method info, and top-up configuration.`,builder:F,handler:async s=>{if(s.dryRun){a({command:`cf ai-gateway billing credit-balance`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/billing/credit-balance`,pathParams:{},bodyKind:`none`});return}let c=await r(s),l=s.local?e:await t();s.accountId=l,i(await o(`Loading`,async()=>c.aiGateway.billing.creditBalance({account_id:l})),{successLabel:`Loaded`})}};function L(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const R={command:`get-topup-limits`,describe:`Retrieve the minimum and maximum allowed top-up amounts (in cents) for this account.`,builder:L,handler:async s=>{if(s.dryRun){a({command:`cf ai-gateway billing get-topup-limits`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/billing/topup/limits`,pathParams:{},bodyKind:`none`});return}let c=await r(s),l=s.local?e:await t();s.accountId=l,i(await o(`Loading`,async()=>c.aiGateway.billing.getTopupLimits({account_id:l})),{successLabel:`Loaded`})}};function z(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 B={command:`invoice-history`,describe:`Retrieve a list of past invoices with pagination, optionally filtered by type.`,builder:m(z),handler:async s=>{let c={type:s.type};if(s.dryRun){a({command:`cf ai-gateway billing invoice-history`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/billing/invoice-history`,pathParams:{},query:c,bodyKind:`none`});return}let l=await r(s),u=s.local?e:await t();s.accountId=u,i(await o(`Loading`,async()=>l.aiGateway.billing.invoiceHistory({account_id:u,...c})),{successLabel:`Loaded`})}};function V(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const H={command:`invoice-preview`,describe:`Retrieve a preview of the upcoming invoice including line items and tax.`,builder:V,handler:async s=>{if(s.dryRun){a({command:`cf ai-gateway billing invoice-preview`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/billing/invoice-preview`,pathParams:{},bodyKind:`none`});return}let c=await r(s),l=s.local?e:await t();s.accountId=l,i(await o(`Loading`,async()=>c.aiGateway.billing.invoicePreview({account_id:l})),{successLabel:`Loaded`})}};function U(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 W={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:U,handler:async c=>{if(c.dryRun){a({command:`cf ai-gateway billing spending-limit create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/billing/spending-limit`,pathParams:{},bodyKind:`json`,body:c.body===void 0?l({amount:c.amount,duration:u(c.duration,`duration`,`text`),strategy:u(c.strategy,`strategy`,`text`)}):s(c.body)});return}let d=await r(c),p=c.local?e:await t();if(c.accountId=p,c.body){let e=s(c.body);i(await o(`Creating`,async()=>d.aiGateway.billing.spendingLimit.create({...e,account_id:p})),{successLabel:`Created`});return}if(c.amount===void 0)throw Error(`--amount is required (or pass --body with this field set).`);c.duration===void 0&&(c.duration=await f(`duration`,`Spending limit duration.`,[`daily`,`weekly`,`monthly`])),c.strategy===void 0&&(c.strategy=await f(`strategy`,`Spending limit strategy.`,[`fixed`,`sliding`]));let m=l({amount:c.amount,duration:u(c.duration,`duration`,`text`),strategy:u(c.strategy,`strategy`,`text`)});i(await o(`Creating`,async()=>d.aiGateway.billing.spendingLimit.create({...m,account_id:p})),{successLabel:`Created`})}};function G(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 K={command:`delete`,describe:`Remove the spending limit for the account.`,builder:G,handler:async s=>{if(s.dryRun){a({command:`cf ai-gateway billing spending-limit delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/billing/spending-limit`,pathParams:{},bodyKind:`none`});return}let c=await r(s),l=s.local?e:await t();if(s.accountId=l,!await p({force:!!s.force})){process.stderr.write(`Aborted.
5
+ `);return}i(await o(`Deleting`,async()=>c.aiGateway.billing.spendingLimit.delete({account_id:l})),{successLabel:`Deleted`})}};function q(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const J={command:`get`,describe:`Retrieve the current spending limit configuration for the account.`,builder:q,handler:async s=>{if(s.dryRun){a({command:`cf ai-gateway billing spending-limit get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/billing/spending-limit`,pathParams:{},bodyKind:`none`});return}let c=await r(s),l=s.local?e:await t();s.accountId=l,i(await o(`Loading`,async()=>c.aiGateway.billing.spendingLimit.get({account_id:l})),{successLabel:`Loaded`})}},Y={command:`spending-limit`,describe:`Operations for billing.spending-limit`,builder:e=>e.command(W).command(K).command(J).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function X(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 Z={command:`create`,describe:`Configure auto top-up with a balance threshold and top-up amount.`,builder:X,handler:async c=>{if(c.dryRun){a({command:`cf ai-gateway billing topup config create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/billing/topup/config`,pathParams:{},bodyKind:`json`,body:c.body===void 0?l({amount:c.amount,threshold:c.threshold}):s(c.body)});return}let u=await r(c),d=c.local?e:await t();if(c.accountId=d,c.body){let e=s(c.body);i(await o(`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=l({amount:c.amount,threshold:c.threshold});i(await o(`Creating`,async()=>u.aiGateway.billing.topup.config.create({...f,account_id:d})),{successLabel:`Created`})}};function Q(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 ne={command:`delete`,describe:`Remove the auto top-up configuration for the account.`,builder:Q,handler:async s=>{if(s.dryRun){a({command:`cf ai-gateway billing topup config delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/billing/topup/config`,pathParams:{},bodyKind:`none`});return}let c=await r(s),l=s.local?e:await t();if(s.accountId=l,!await p({force:!!s.force})){process.stderr.write(`Aborted.
6
+ `);return}i(await o(`Deleting`,async()=>c.aiGateway.billing.topup.config.delete({account_id:l})),{successLabel:`Deleted`})}};function re(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const ie={command:`get`,describe:`Retrieve the current auto top-up threshold, amount, and any error state.`,builder:re,handler:async s=>{if(s.dryRun){a({command:`cf ai-gateway billing topup config get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/billing/topup/config`,pathParams:{},bodyKind:`none`});return}let c=await r(s),l=s.local?e:await t();s.accountId=l,i(await o(`Loading`,async()=>c.aiGateway.billing.topup.config.get({account_id:l})),{successLabel:`Loaded`})}},ae={command:`config`,describe:`Operations for billing.topup.config`,builder:e=>e.command(Z).command(ne).command(ie).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function oe(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 se={command:`create`,describe:`Create a credit top-up for the given account, charged to the account's default payment method.`,builder:oe,handler:async c=>{if(c.dryRun){a({command:`cf ai-gateway billing topup create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/billing/topup`,pathParams:{},bodyKind:`json`,body:c.body===void 0?l({amount:c.amount}):s(c.body)});return}let u=await r(c),d=c.local?e:await t();if(c.accountId=d,c.body){let e=s(c.body);i(await o(`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=l({amount:c.amount});i(await o(`Creating`,async()=>u.aiGateway.billing.topup.create({...f,account_id:d})),{successLabel:`Created`})}};function ce(e){return e.option(`payment-methods`,{type:`string`,description:`Account-level payment methods, forwarded by the dashboard. Provide as a JSON array of objects or @path/to/file.json.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const le={command:`eligibility`,describe:`Determine whether an account can self-serve a credit top-up, and if not, why. The dashboard forwards the account's payment-method list in the body; the reason logic is owned here.`,builder:ce,handler:async u=>{if(u.dryRun){a({command:`cf ai-gateway billing topup eligibility`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/billing/topup/eligibility`,pathParams:{},bodyKind:`json`,body:u.body===void 0?l({payment_methods:c(u[`payment-methods`],`payment-methods`)}):s(u.body)});return}let d=await r(u),f=u.local?e:await t();if(u.accountId=f,u.body){let e=s(u.body);i(await o(`Creating`,async()=>d.aiGateway.billing.topup.eligibility({...e,account_id:f})),{successLabel:`Created`});return}let p=l({payment_methods:c(u[`payment-methods`],`payment-methods`)});i(await o(`Creating`,async()=>d.aiGateway.billing.topup.eligibility({...p,account_id:f})),{successLabel:`Created`})}};function ue(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 de={command:`status`,describe:`Get the payment processing status of a top-up by its invoice ID.`,builder:ue,handler:async c=>{if(c.dryRun){a({command:`cf ai-gateway billing topup status`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/billing/topup/status`,pathParams:{},bodyKind:`json`,body:c.body===void 0?l({payment_intent_id:u(c[`payment-intent-id`],`payment-intent-id`,`text`)}):s(c.body)});return}let f=await r(c),p=c.local?e:await t();if(c.accountId=p,c.body){let e=s(c.body);i(await o(`Creating`,async()=>f.aiGateway.billing.topup.status({...e,account_id:p})),{successLabel:`Created`});return}c[`payment-intent-id`]===void 0&&(c[`payment-intent-id`]=await d(`payment-intent-id`,`Stripe invoice ID to check status for.`));let m=l({payment_intent_id:u(c[`payment-intent-id`],`payment-intent-id`,`text`)});i(await o(`Creating`,async()=>f.aiGateway.billing.topup.status({...m,account_id:p})),{successLabel:`Created`})}},fe={command:`topup`,describe:`Operations for billing.topup`,builder:e=>e.command(se).command(le).command(de).command(ae).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function pe(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 me={command:`usage-history`,describe:`Retrieve aggregated usage meter event summaries for the given time range.`,builder:m(pe),handler:async s=>{let c={value_grouping_window:s[`value-grouping-window`],start_time:s[`start-time`],end_time:s[`end-time`]};if(s.dryRun){a({command:`cf ai-gateway billing usage-history`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/billing/usage-history`,pathParams:{},query:c,bodyKind:`none`});return}let l=await r(s),u=s.local?e:await t();s.accountId=u,i(await o(`Loading`,async()=>l.aiGateway.billing.usageHistory({account_id:u,...c})),{successLabel:`Loaded`})}},he={command:`billing`,describe:`Operations for billing`,builder:e=>e.command(I).command(R).command(B).command(H).command(me).command(Y).command(fe).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function ge(e){return e.positional(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`domain`,{type:`string`,description:`the customer-owned custom hostname`}).option(`min-tls`,{type:`string`,description:`The minTLS field`,choices:[`1.0`,`1.1`,`1.2`,`1.3`]}).option(`zone-id`,{type:`string`,description:`Cloudflare Zone ID owning the custom hostname`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const _e={command:`create <gateway-id>`,describe:`Provisions a Cloudflare-for-SaaS custom hostname and returns the CNAME target to point DNS at.`,builder:ge,handler:async c=>{if(c.dryRun){a({command:`cf ai-gateway custom-domains create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${c[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(c[`gateway-id`]))}/custom-domains`,pathParams:{"gateway-id":String(c[`gateway-id`]??``)},bodyKind:`json`,body:c.body===void 0?l({domain:u(c.domain,`domain`,`text`),minTLS:u(c[`min-tls`],`min-tls`,`text`),zone_id:u(c[`zone-id`],`zone-id`,`text`)}):s(c.body)});return}let f=await r(c),p=c.local?e:await t();if(c.accountId=p,c.body){let e=s(c.body);i(await o(`Creating`,async()=>f.aiGateway.customDomains.create({...e,account_id:p,gateway_id:c[`gateway-id`]})),{successLabel:`Created`});return}c.domain===void 0&&(c.domain=await d(`domain`,`the customer-owned custom hostname`)),c[`zone-id`]===void 0&&(c[`zone-id`]=await d(`zone-id`,`Cloudflare Zone ID owning the custom hostname`));let m=l({domain:u(c.domain,`domain`,`text`),minTLS:u(c[`min-tls`],`min-tls`,`text`),zone_id:u(c[`zone-id`],`zone-id`,`text`)});i(await o(`Creating`,async()=>f.aiGateway.customDomains.create({...m,account_id:p,gateway_id:c[`gateway-id`]})),{successLabel:`Created`})}};function ve(e){return e.positional(`hostname`,{type:`string`,description:`the customer-owned custom hostname`,demandOption:!0}).option(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const ye={command:`delete <hostname>`,describe:`Deletes an AI Gateway dataset.`,builder:ve,handler:async s=>{if(s.dryRun){a({command:`cf ai-gateway custom-domains delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${s[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(s[`gateway-id`]))}/custom-domains/${s.hostname==null?`<hostname>`:encodeURIComponent(String(s.hostname))}`,pathParams:{"gateway-id":String(s[`gateway-id`]??``),hostname:String(s.hostname??``)},bodyKind:`none`});return}let c=await r(s),l=s.local?e:await t();if(s.accountId=l,!await p({force:!!s.force})){process.stderr.write(`Aborted.
7
+ `);return}i(await o(`Deleting`,async()=>c.aiGateway.customDomains.delete({account_id:l,gateway_id:s[`gateway-id`],hostname:s.hostname})),{successLabel:`Deleted`})}};function be(e){return e.positional(`hostname`,{type:`string`,description:`the customer-owned custom hostname`,demandOption:!0}).option(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const xe={command:`get <hostname>`,describe:`Retrieves details for a specific AI Gateway dataset.`,builder:be,handler:async s=>{if(s.dryRun){a({command:`cf ai-gateway custom-domains get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${s[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(s[`gateway-id`]))}/custom-domains/${s.hostname==null?`<hostname>`:encodeURIComponent(String(s.hostname))}`,pathParams:{"gateway-id":String(s[`gateway-id`]??``),hostname:String(s.hostname??``)},bodyKind:`none`});return}let c=await r(s),l=s.local?e:await t();s.accountId=l,i(await o(`Loading`,async()=>c.aiGateway.customDomains.get({account_id:l,gateway_id:s[`gateway-id`],hostname:s.hostname})),{successLabel:`Loaded`})}};function Se(e){return e.option(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`page`,{type:`number`,description:`Page`}).option(`per-page`,{type:`number`,description:`Per page`}).option(`status`,{type:`string`,description:`Status`,choices:[`initializing`,`pending_dcv`,`active`,`blocked`,`error`]}).option(`search`,{type:`string`,description:`Search by hostname`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Ce={command:`list`,describe:`Lists all AI Gateway evaluator types configured for the account.`,builder:m(Se),handler:async s=>{let c={page:s.page,per_page:s[`per-page`],status:s.status,search:s.search};if(s.dryRun){a({command:`cf ai-gateway custom-domains list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${s[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(s[`gateway-id`]))}/custom-domains`,pathParams:{"gateway-id":String(s[`gateway-id`]??``)},query:c,bodyKind:`none`});return}let l=await r(s),u=s.local?e:await t();s.accountId=u,i(await o(`Loading`,async()=>l.aiGateway.customDomains.list({account_id:u,gateway_id:s[`gateway-id`],...c})),{successLabel:`Loaded`})}},we={command:`custom-domains`,describe:`Operations for custom-domains`,builder:e=>e.command(_e).command(ye).command(xe).command(Ce).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Te(e){return e.positional(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`enable`,{type:`boolean`,description:`The enable field`}).option(`filters`,{type:`string`,description:`The filters field. Provide as a JSON array of objects or @path/to/file.json.`}).option(`name`,{type:`string`,description:`The name field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const Ee={command:`create <gateway-id>`,describe:`Creates a new AI Gateway.`,builder:Te,handler:async f=>{if(f.dryRun){a({command:`cf ai-gateway datasets create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${f[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(f[`gateway-id`]))}/datasets`,pathParams:{"gateway-id":String(f[`gateway-id`]??``)},bodyKind:`json`,body:f.body===void 0?l({enable:f.enable,filters:c(f.filters,`filters`),name:u(f.name,`name`,`text`)}):s(f.body)});return}let p=await r(f),m=f.local?e:await t();if(f.accountId=m,f.body){let e=s(f.body);i(await o(`Creating`,async()=>p.aiGateway.datasets.create({...e,account_id:m,gateway_id:f[`gateway-id`]})),{successLabel:`Created`});return}if(f.enable===void 0)throw Error(`--enable is required (or pass --body with this field set).`);if(f.filters===void 0)throw Error(`--filters is required (or pass --body with this field set).`);f.name===void 0&&(f.name=await d(`name`,`The name field`));let h=l({enable:f.enable,filters:c(f.filters,`filters`),name:u(f.name,`name`,`text`)});i(await o(`Creating`,async()=>p.aiGateway.datasets.create({...h,account_id:m,gateway_id:f[`gateway-id`]})),{successLabel:`Created`})}};function De(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:De,handler:async s=>{if(s.dryRun){a({command:`cf ai-gateway datasets delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${s[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(s[`gateway-id`]))}/datasets/${s.id==null?`<id>`:encodeURIComponent(String(s.id))}`,pathParams:{"gateway-id":String(s[`gateway-id`]??``),id:String(s.id??``)},bodyKind:`none`});return}let c=await r(s),l=s.local?e:await t();if(s.accountId=l,!await p({force:!!s.force})){process.stderr.write(`Aborted.
8
+ `);return}i(await o(`Deleting`,async()=>c.aiGateway.datasets.delete({account_id:l,gateway_id:s[`gateway-id`],id:s.id})),{successLabel:`Deleted`})}};function ke(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:ke,handler:async s=>{if(s.dryRun){a({command:`cf ai-gateway datasets get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${s[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(s[`gateway-id`]))}/datasets/${s.id==null?`<id>`:encodeURIComponent(String(s.id))}`,pathParams:{"gateway-id":String(s[`gateway-id`]??``),id:String(s.id??``)},bodyKind:`none`});return}let c=await r(s),l=s.local?e:await t();s.accountId=l,i(await o(`Loading`,async()=>c.aiGateway.datasets.get({account_id:l,gateway_id:s[`gateway-id`],id:s.id})),{successLabel:`Loaded`})}};function je(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 Me={command:`list`,describe:`Lists all AI Gateway evaluator types configured for the account.`,builder:je,handler:async s=>{let c={page:s.page,per_page:s[`per-page`],name:s.name,enable:s.enable,search:s.search};if(s.dryRun){a({command:`cf ai-gateway datasets list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${s[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(s[`gateway-id`]))}/datasets`,pathParams:{"gateway-id":String(s[`gateway-id`]??``)},query:c,bodyKind:`none`});return}let l=await r(s),u=s.local?e:await t();s.accountId=u,i(await o(`Loading`,async()=>l.aiGateway.datasets.list({account_id:u,gateway_id:s[`gateway-id`],...c})),{successLabel:`Loaded`})}};function Ne(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`enable`,{type:`boolean`,description:`The enable field`}).option(`filters`,{type:`string`,description:`The filters field. Provide as a JSON array of objects or @path/to/file.json.`}).option(`name`,{type:`string`,description:`The name field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const Pe={command:`update <id>`,describe:`Updates an existing AI Gateway dataset.`,builder:Ne,handler:async f=>{if(f.dryRun){a({command:`cf ai-gateway datasets update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${f[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(f[`gateway-id`]))}/datasets/${f.id==null?`<id>`:encodeURIComponent(String(f.id))}`,pathParams:{"gateway-id":String(f[`gateway-id`]??``),id:String(f.id??``)},bodyKind:`json`,body:f.body===void 0?l({enable:f.enable,filters:c(f.filters,`filters`),name:u(f.name,`name`,`text`)}):s(f.body)});return}let p=await r(f),m=f.local?e:await t();if(f.accountId=m,f.body){let e=s(f.body);i(await o(`Updating`,async()=>p.aiGateway.datasets.update({...e,account_id:m,gateway_id:f[`gateway-id`],id:f.id})),{successLabel:`Updated`});return}if(f.enable===void 0)throw Error(`--enable is required (or pass --body with this field set).`);if(f.filters===void 0)throw Error(`--filters is required (or pass --body with this field set).`);f.name===void 0&&(f.name=await d(`name`,`The name field`));let h=l({enable:f.enable,filters:c(f.filters,`filters`),name:u(f.name,`name`,`text`)});i(await o(`Updating`,async()=>p.aiGateway.datasets.update({...h,account_id:m,gateway_id:f[`gateway-id`],id:f.id})),{successLabel:`Updated`})}},Fe={command:`datasets`,describe:`Curated collections of gateway logs used as inputs for evaluations and fine-tuning`,builder:e=>e.command(Ee).command(Oe).command(Ae).command(Me).command(Pe).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Ie(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 Le={command:`create-deployment <id>`,describe:`Create a new AI Gateway Dynamic Route Deployment.`,builder:Ie,handler:async c=>{if(c.dryRun){a({command:`cf ai-gateway dynamic-routing create-deployment`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${c[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(c[`gateway-id`]))}/routes/${c.id==null?`<id>`:encodeURIComponent(String(c.id))}/deployments`,pathParams:{"gateway-id":String(c[`gateway-id`]??``),id:String(c.id??``)},bodyKind:`json`,body:c.body===void 0?l({version_id:u(c[`version-id`],`version-id`,`text`)}):s(c.body)});return}let f=await r(c),p=c.local?e:await t();if(c.accountId=p,c.body){let e=s(c.body);i(await o(`Creating`,async()=>f.aiGateway.dynamicRouting.createDeployment({...e,account_id:p,gateway_id:c[`gateway-id`],id:c.id})),{successLabel:`Created`});return}c[`version-id`]===void 0&&(c[`version-id`]=await d(`version-id`,`The version_id field`));let m=l({version_id:u(c[`version-id`],`version-id`,`text`)});i(await o(`Creating`,async()=>f.aiGateway.dynamicRouting.createDeployment({...m,account_id:p,gateway_id:c[`gateway-id`],id:c.id})),{successLabel:`Created`})}};function Re(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`gateway-id`,{type:`string`,description:`Gateway ID`,demandOption:!0}).option(`elements`,{type:`string`,description:`The elements field. Provide as a JSON array of objects or @path/to/file.json.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const ze={command:`create-version <id>`,describe:`Create a new AI Gateway Dynamic Route Version.`,builder:Re,handler:async u=>{if(u.dryRun){a({command:`cf ai-gateway dynamic-routing create-version`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${u[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(u[`gateway-id`]))}/routes/${u.id==null?`<id>`:encodeURIComponent(String(u.id))}/versions`,pathParams:{"gateway-id":String(u[`gateway-id`]??``),id:String(u.id??``)},bodyKind:`json`,body:u.body===void 0?l({elements:c(u.elements,`elements`)}):s(u.body)});return}let d=await r(u),f=u.local?e:await t();if(u.accountId=f,u.body){let e=s(u.body);i(await o(`Creating`,async()=>d.aiGateway.dynamicRouting.createVersion({...e,account_id:f,gateway_id:u[`gateway-id`],id:u.id})),{successLabel:`Created`});return}if(u.elements===void 0)throw Error(`--elements is required (or pass --body with this field set).`);let p=l({elements:c(u.elements,`elements`)});i(await o(`Creating`,async()=>d.aiGateway.dynamicRouting.createVersion({...p,account_id:f,gateway_id:u[`gateway-id`],id:u.id})),{successLabel:`Created`})}};function Be(e){return e.positional(`gateway-id`,{type:`string`,description:`Gateway ID`,demandOption:!0}).option(`elements`,{type:`string`,description:`The elements field. Provide as a JSON array of objects or @path/to/file.json.`}).option(`name`,{type:`string`,description:`The name field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const Ve={command:`create <gateway-id>`,describe:`Create a new AI Gateway Dynamic Route.`,builder:Be,handler:async f=>{if(f.dryRun){a({command:`cf ai-gateway dynamic-routing create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${f[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(f[`gateway-id`]))}/routes`,pathParams:{"gateway-id":String(f[`gateway-id`]??``)},bodyKind:`json`,body:f.body===void 0?l({elements:c(f.elements,`elements`),name:u(f.name,`name`,`text`)}):s(f.body)});return}let p=await r(f),m=f.local?e:await t();if(f.accountId=m,f.body){let e=s(f.body);i(await o(`Creating`,async()=>p.aiGateway.dynamicRouting.create({...e,account_id:m,gateway_id:f[`gateway-id`]})),{successLabel:`Created`});return}if(f.elements===void 0)throw Error(`--elements is required (or pass --body with this field set).`);f.name===void 0&&(f.name=await d(`name`,`The name field`));let h=l({elements:c(f.elements,`elements`),name:u(f.name,`name`,`text`)});i(await o(`Creating`,async()=>p.aiGateway.dynamicRouting.create({...h,account_id:m,gateway_id:f[`gateway-id`]})),{successLabel:`Created`})}};function He(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 Ue={command:`delete <id>`,describe:`Delete an AI Gateway Dynamic Route.`,builder:He,handler:async s=>{if(s.dryRun){a({command:`cf ai-gateway dynamic-routing delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${s[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(s[`gateway-id`]))}/routes/${s.id==null?`<id>`:encodeURIComponent(String(s.id))}`,pathParams:{"gateway-id":String(s[`gateway-id`]??``),id:String(s.id??``)},bodyKind:`none`});return}let c=await r(s),l=s.local?e:await t();if(s.accountId=l,!await p({force:!!s.force})){process.stderr.write(`Aborted.
9
+ `);return}i(await o(`Deleting`,async()=>c.aiGateway.dynamicRouting.delete({account_id:l,gateway_id:s[`gateway-id`],id:s.id})),{successLabel:`Deleted`})}};function We(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 Ge={command:`get-version <version-id>`,describe:`Get an AI Gateway Dynamic Route Version.`,builder:We,handler:async s=>{if(s.dryRun){a({command:`cf ai-gateway dynamic-routing get-version`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${s[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(s[`gateway-id`]))}/routes/${s.id==null?`<id>`:encodeURIComponent(String(s.id))}/versions/${s[`version-id`]==null?`<version-id>`:encodeURIComponent(String(s[`version-id`]))}`,pathParams:{"gateway-id":String(s[`gateway-id`]??``),id:String(s.id??``),"version-id":String(s[`version-id`]??``)},bodyKind:`none`});return}let c=await r(s),l=s.local?e:await t();s.accountId=l,i(await o(`Loading`,async()=>c.aiGateway.dynamicRouting.getVersion({account_id:l,gateway_id:s[`gateway-id`],id:s.id,version_id:s[`version-id`]})),{successLabel:`Loaded`})}};function Ke(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`gateway-id`,{type:`string`,description:`Gateway ID`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const qe={command:`get <id>`,describe:`Get an AI Gateway Dynamic Route.`,builder:Ke,handler:async s=>{if(s.dryRun){a({command:`cf ai-gateway dynamic-routing get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${s[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(s[`gateway-id`]))}/routes/${s.id==null?`<id>`:encodeURIComponent(String(s.id))}`,pathParams:{"gateway-id":String(s[`gateway-id`]??``),id:String(s.id??``)},bodyKind:`none`});return}let c=await r(s),l=s.local?e:await t();s.accountId=l,i(await o(`Loading`,async()=>c.aiGateway.dynamicRouting.get({account_id:l,gateway_id:s[`gateway-id`],id:s.id})),{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(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Ye={command:`list-deployments <id>`,describe:`List all AI Gateway Dynamic Route Deployments.`,builder:Je,handler:async s=>{if(s.dryRun){a({command:`cf ai-gateway dynamic-routing list-deployments`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${s[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(s[`gateway-id`]))}/routes/${s.id==null?`<id>`:encodeURIComponent(String(s.id))}/deployments`,pathParams:{"gateway-id":String(s[`gateway-id`]??``),id:String(s.id??``)},bodyKind:`none`});return}let c=await r(s),l=s.local?e:await t();s.accountId=l,i(await o(`Loading`,async()=>c.aiGateway.dynamicRouting.listDeployments({account_id:l,gateway_id:s[`gateway-id`],id:s.id})),{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 Ze={command:`list-versions <id>`,describe:`List all AI Gateway Dynamic Route Versions.`,builder:Xe,handler:async s=>{if(s.dryRun){a({command:`cf ai-gateway dynamic-routing list-versions`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${s[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(s[`gateway-id`]))}/routes/${s.id==null?`<id>`:encodeURIComponent(String(s.id))}/versions`,pathParams:{"gateway-id":String(s[`gateway-id`]??``),id:String(s.id??``)},bodyKind:`none`});return}let c=await r(s),l=s.local?e:await t();s.accountId=l,i(await o(`Loading`,async()=>c.aiGateway.dynamicRouting.listVersions({account_id:l,gateway_id:s[`gateway-id`],id:s.id})),{successLabel:`Loaded`})}};function Qe(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 $e={command:`list`,describe:`List all AI Gateway Dynamic Routes.`,builder:Qe,handler:async s=>{let c={page:s.page,per_page:s[`per-page`]};if(s.dryRun){a({command:`cf ai-gateway dynamic-routing list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${s[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(s[`gateway-id`]))}/routes`,pathParams:{"gateway-id":String(s[`gateway-id`]??``)},query:c,bodyKind:`none`});return}let l=await r(s),u=s.local?e:await t();s.accountId=u,i(await o(`Loading`,async()=>l.aiGateway.dynamicRouting.list({account_id:u,gateway_id:s[`gateway-id`],...c})),{successLabel:`Loaded`})}};function et(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 tt={command:`update <id>`,describe:`Update an AI Gateway Dynamic Route.`,builder:et,handler:async c=>{if(c.dryRun){a({command:`cf ai-gateway dynamic-routing update`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${c[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(c[`gateway-id`]))}/routes/${c.id==null?`<id>`:encodeURIComponent(String(c.id))}`,pathParams:{"gateway-id":String(c[`gateway-id`]??``),id:String(c.id??``)},bodyKind:`json`,body:c.body===void 0?l({name:u(c.name,`name`,`text`)}):s(c.body)});return}let f=await r(c),p=c.local?e:await t();if(c.accountId=p,c.body){let e=s(c.body);i(await o(`Updating`,async()=>f.aiGateway.dynamicRouting.update({...e,account_id:p,gateway_id:c[`gateway-id`],id:c.id})),{successLabel:`Updated`});return}c.name===void 0&&(c.name=await d(`name`,`The name field`));let m=l({name:u(c.name,`name`,`text`)});i(await o(`Updating`,async()=>f.aiGateway.dynamicRouting.update({...m,account_id:p,gateway_id:c[`gateway-id`],id:c.id})),{successLabel:`Updated`})}},nt={command:`dynamic-routing`,describe:`Route requests across multiple AI providers with fallback, load-balancing, and versioned deployments`,builder:e=>e.command(Ve).command(Le).command(ze).command(Ue).command(qe).command(Ge).command($e).command(Ye).command(Ze).command(tt).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function rt(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 it={command:`list`,describe:`Lists all available evaluator types for scoring AI gateway responses.`,builder:m(rt),handler:async s=>{let c={page:s.page,per_page:s[`per-page`],order_by:s[`order-by`],order_by_direction:s[`order-by-direction`]};if(s.dryRun){a({command:`cf ai-gateway evaluation-types list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/evaluation-types`,pathParams:{},query:c,bodyKind:`none`});return}let l=await r(s),u=s.local?e:await t();s.accountId=u,i(await o(`Loading`,async()=>l.aiGateway.evaluationTypes.list({account_id:u,...c})),{successLabel:`Loaded`})}},at={command:`evaluation-types`,describe:`Available evaluator types for scoring AI gateway responses (accuracy, toxicity, etc.)`,builder:e=>e.command(it).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function ot(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 st={command:`create <gateway-id>`,describe:`Creates a new AI Gateway.`,builder:ot,handler:async c=>{if(c.dryRun){a({command:`cf ai-gateway evaluations create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${c[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(c[`gateway-id`]))}/evaluations`,pathParams:{"gateway-id":String(c[`gateway-id`]??``)},bodyKind:`json`,body:c.body===void 0?l({dataset_ids:c[`dataset-ids`],evaluation_type_ids:c[`evaluation-type-ids`],name:u(c.name,`name`,`text`)}):s(c.body)});return}let f=await r(c),p=c.local?e:await t();if(c.accountId=p,c.body){let e=s(c.body);i(await o(`Creating`,async()=>f.aiGateway.evaluations.create({...e,account_id:p,gateway_id:c[`gateway-id`]})),{successLabel:`Created`});return}if(c[`dataset-ids`]===void 0)throw Error(`--dataset-ids is required (or pass --body with this field set).`);if(c[`evaluation-type-ids`]===void 0)throw Error(`--evaluation-type-ids is required (or pass --body with this field set).`);c.name===void 0&&(c.name=await d(`name`,`The name field`));let m=l({dataset_ids:c[`dataset-ids`],evaluation_type_ids:c[`evaluation-type-ids`],name:u(c.name,`name`,`text`)});i(await o(`Creating`,async()=>f.aiGateway.evaluations.create({...m,account_id:p,gateway_id:c[`gateway-id`]})),{successLabel:`Created`})}};function ct(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 lt={command:`delete <id>`,describe:`Deletes an AI Gateway dataset.`,builder:ct,handler:async s=>{if(s.dryRun){a({command:`cf ai-gateway evaluations delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${s[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(s[`gateway-id`]))}/evaluations/${s.id==null?`<id>`:encodeURIComponent(String(s.id))}`,pathParams:{"gateway-id":String(s[`gateway-id`]??``),id:String(s.id??``)},bodyKind:`none`});return}let c=await r(s),l=s.local?e:await t();if(s.accountId=l,!await p({force:!!s.force})){process.stderr.write(`Aborted.
10
+ `);return}i(await o(`Deleting`,async()=>c.aiGateway.evaluations.delete({account_id:l,gateway_id:s[`gateway-id`],id:s.id})),{successLabel:`Deleted`})}};function ut(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 dt={command:`get <id>`,describe:`Retrieves details for a specific AI Gateway dataset.`,builder:ut,handler:async s=>{if(s.dryRun){a({command:`cf ai-gateway evaluations get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${s[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(s[`gateway-id`]))}/evaluations/${s.id==null?`<id>`:encodeURIComponent(String(s.id))}`,pathParams:{"gateway-id":String(s[`gateway-id`]??``),id:String(s.id??``)},bodyKind:`none`});return}let c=await r(s),l=s.local?e:await t();s.accountId=l,i(await o(`Loading`,async()=>c.aiGateway.evaluations.get({account_id:l,gateway_id:s[`gateway-id`],id:s.id})),{successLabel:`Loaded`})}};function ft(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 pt={command:`list`,describe:`Lists all AI Gateway evaluator types configured for the account.`,builder:ft,handler:async s=>{let c={page:s.page,per_page:s[`per-page`],name:s.name,processed:s.processed,search:s.search};if(s.dryRun){a({command:`cf ai-gateway evaluations list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${s[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(s[`gateway-id`]))}/evaluations`,pathParams:{"gateway-id":String(s[`gateway-id`]??``)},query:c,bodyKind:`none`});return}let l=await r(s),u=s.local?e:await t();s.accountId=u,i(await o(`Loading`,async()=>l.aiGateway.evaluations.list({account_id:u,gateway_id:s[`gateway-id`],...c})),{successLabel:`Loaded`})}},mt={command:`evaluations`,describe:`Run quality evaluations against gateway logs or datasets to score model outputs`,builder:e=>e.command(st).command(lt).command(dt).command(pt).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function ht(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(`store-id`,{type:`string`,description:`The store_id field`}).option(`workers-ai-billing-mode`,{type:`string`,description:`Controls how Workers AI inference calls routed through this gateway are billed. 'postpaid' bills the account directly through Workers AI; 'unified' deducts credits via AI Gateway using neuron-based pricing and delegates billing to AI Gateway.`,choices:[`postpaid`,`unified`],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 gt={command:`create`,describe:`Creates a new AI Gateway.`,builder:ht,handler:async c=>{if(c.dryRun){a({command:`cf ai-gateway gateways create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways`,pathParams:{},bodyKind:`json`,body:c.body===void 0?l({authentication:c.authentication,cache_invalidate_on_update:c[`cache-invalidate-on-update`],cache_ttl:c[`cache-ttl`],collect_logs:c[`collect-logs`],id:u(c.id,`id`,`text`),log_management:c[`log-management`],log_management_strategy:u(c[`log-management-strategy`],`log-management-strategy`,`text`),logpush:c.logpush,logpush_public_key:u(c[`logpush-public-key`],`logpush-public-key`,`text`),rate_limiting_interval:c[`rate-limiting-interval`],rate_limiting_limit:c[`rate-limiting-limit`],rate_limiting_technique:u(c[`rate-limiting-technique`],`rate-limiting-technique`,`text`),retry_backoff:u(c[`retry-backoff`],`retry-backoff`,`text`),retry_delay:c[`retry-delay`],retry_max_attempts:c[`retry-max-attempts`],store_id:u(c[`store-id`],`store-id`,`text`),workers_ai_billing_mode:u(c[`workers-ai-billing-mode`],`workers-ai-billing-mode`,`text`),zdr:c.zdr}):s(c.body)});return}let f=await r(c),p=c.local?e:await t();if(c.accountId=p,c.body){let e=s(c.body);i(await o(`Creating`,async()=>f.aiGateway.gateways.create({...e,account_id:p})),{successLabel:`Created`});return}if(c[`cache-invalidate-on-update`]===void 0)throw Error(`--cache-invalidate-on-update is required (or pass --body with this field set).`);if(c[`cache-ttl`]===void 0)throw Error(`--cache-ttl is required (or pass --body with this field set).`);if(c[`collect-logs`]===void 0)throw Error(`--collect-logs is required (or pass --body with this field set).`);if(c.id===void 0&&(c.id=await d(`id`,`gateway id`)),c[`rate-limiting-interval`]===void 0)throw Error(`--rate-limiting-interval is required (or pass --body with this field set).`);if(c[`rate-limiting-limit`]===void 0)throw Error(`--rate-limiting-limit is required (or pass --body with this field set).`);let m=l({authentication:c.authentication,cache_invalidate_on_update:c[`cache-invalidate-on-update`],cache_ttl:c[`cache-ttl`],collect_logs:c[`collect-logs`],id:u(c.id,`id`,`text`),log_management:c[`log-management`],log_management_strategy:u(c[`log-management-strategy`],`log-management-strategy`,`text`),logpush:c.logpush,logpush_public_key:u(c[`logpush-public-key`],`logpush-public-key`,`text`),rate_limiting_interval:c[`rate-limiting-interval`],rate_limiting_limit:c[`rate-limiting-limit`],rate_limiting_technique:u(c[`rate-limiting-technique`],`rate-limiting-technique`,`text`),retry_backoff:u(c[`retry-backoff`],`retry-backoff`,`text`),retry_delay:c[`retry-delay`],retry_max_attempts:c[`retry-max-attempts`],store_id:u(c[`store-id`],`store-id`,`text`),workers_ai_billing_mode:u(c[`workers-ai-billing-mode`],`workers-ai-billing-mode`,`text`),zdr:c.zdr});i(await o(`Creating`,async()=>f.aiGateway.gateways.create({...m,account_id:p})),{successLabel:`Created`})}};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 vt={command:`delete <id>`,describe:`Deletes an AI Gateway dataset.`,builder:_t,handler:async s=>{if(s.dryRun){a({command:`cf ai-gateway gateways delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${s.id==null?`<id>`:encodeURIComponent(String(s.id))}`,pathParams:{id:String(s.id??``)},bodyKind:`none`});return}let c=await r(s),l=s.local?e:await t();if(s.accountId=l,!await p({force:!!s.force})){process.stderr.write(`Aborted.
11
+ `);return}i(await o(`Deleting`,async()=>c.aiGateway.gateways.delete({account_id:l,id:s.id})),{successLabel:`Deleted`})}};function yt(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 bt={command:`get <id>`,describe:`Retrieves details for a specific AI Gateway dataset.`,builder:yt,handler:async s=>{if(s.dryRun){a({command:`cf ai-gateway gateways get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${s.id==null?`<id>`:encodeURIComponent(String(s.id))}`,pathParams:{id:String(s.id??``)},bodyKind:`none`});return}let c=await r(s),l=s.local?e:await t();s.accountId=l,i(await o(`Loading`,async()=>c.aiGateway.gateways.get({account_id:l,id:s.id})),{successLabel:`Loaded`})}};function xt(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 St={command:`list`,describe:`Lists all AI Gateway evaluator types configured for the account.`,builder:xt,handler:async s=>{let c={page:s.page,per_page:s[`per-page`],search:s.search};if(s.dryRun){a({command:`cf ai-gateway gateways list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways`,pathParams:{},query:c,bodyKind:`none`});return}let l=await r(s),u=s.local?e:await t();s.accountId=u,i(await o(`Loading`,async()=>l.aiGateway.gateways.list({account_id:u,...c})),{successLabel:`Loaded`})}};function Ct(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 wt={command:`create <gateway-id>`,describe:`Creates a new AI Gateway.`,builder:Ct,handler:async c=>{if(c.dryRun){a({command:`cf ai-gateway gateways providers create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${c[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(c[`gateway-id`]))}/provider_configs`,pathParams:{"gateway-id":String(c[`gateway-id`]??``)},bodyKind:`json`,body:c.body===void 0?l({alias:u(c.alias,`alias`,`text`),default_config:c[`default-config`],provider_slug:u(c[`provider-slug`],`provider-slug`,`text`),rate_limit:c[`rate-limit`],rate_limit_period:c[`rate-limit-period`],secret:u(c.secret,`secret`,`text`),secret_id:u(c[`secret-id`],`secret-id`,`text`)}):s(c.body)});return}let f=await r(c),p=c.local?e:await t();if(c.accountId=p,c.body){let e=s(c.body);i(await o(`Creating`,async()=>f.aiGateway.gateways.providers.create({...e,account_id:p,gateway_id:c[`gateway-id`]})),{successLabel:`Created`});return}if(c.alias===void 0&&(c.alias=await d(`alias`,`The alias field`)),c[`default-config`]===void 0)throw Error(`--default-config is required (or pass --body with this field set).`);c[`provider-slug`]===void 0&&(c[`provider-slug`]=await d(`provider-slug`,`The provider_slug field`));let m=l({alias:u(c.alias,`alias`,`text`),default_config:c[`default-config`],provider_slug:u(c[`provider-slug`],`provider-slug`,`text`),rate_limit:c[`rate-limit`],rate_limit_period:c[`rate-limit-period`],secret:u(c.secret,`secret`,`text`),secret_id:u(c[`secret-id`],`secret-id`,`text`)});i(await o(`Creating`,async()=>f.aiGateway.gateways.providers.create({...m,account_id:p,gateway_id:c[`gateway-id`]})),{successLabel:`Created`})}};function Tt(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 Et={command:`delete <id>`,describe:`Deletes an AI Gateway dataset.`,builder:Tt,handler:async s=>{if(s.dryRun){a({command:`cf ai-gateway gateways providers delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${s[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(s[`gateway-id`]))}/provider_configs/${s.id==null?`<id>`:encodeURIComponent(String(s.id))}`,pathParams:{"gateway-id":String(s[`gateway-id`]??``),id:String(s.id??``)},bodyKind:`none`});return}let c=await r(s),l=s.local?e:await t();if(s.accountId=l,!await p({force:!!s.force})){process.stderr.write(`Aborted.
12
+ `);return}i(await o(`Deleting`,async()=>c.aiGateway.gateways.providers.delete({account_id:l,gateway_id:s[`gateway-id`],id:s.id})),{successLabel:`Deleted`})}};function Dt(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 Ot={command:`list`,describe:`Lists all AI Gateway evaluator types configured for the account.`,builder:Dt,handler:async s=>{let c={page:s.page,per_page:s[`per-page`]};if(s.dryRun){a({command:`cf ai-gateway gateways providers list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${s[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(s[`gateway-id`]))}/provider_configs`,pathParams:{"gateway-id":String(s[`gateway-id`]??``)},query:c,bodyKind:`none`});return}let l=await r(s),u=s.local?e:await t();s.accountId=u,i(await o(`Loading`,async()=>l.aiGateway.gateways.providers.list({account_id:u,gateway_id:s[`gateway-id`],...c})),{successLabel:`Loaded`})}};function kt(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 At={command:`update <id>`,describe:`Updates an existing AI Gateway dataset.`,builder:kt,handler:async c=>{if(c.dryRun){a({command:`cf ai-gateway gateways providers update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${c[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(c[`gateway-id`]))}/provider_configs/${c.id==null?`<id>`:encodeURIComponent(String(c.id))}`,pathParams:{"gateway-id":String(c[`gateway-id`]??``),id:String(c.id??``)},bodyKind:`json`,body:c.body===void 0?l({secret:u(c.secret,`secret`,`text`)}):s(c.body)});return}let f=await r(c),p=c.local?e:await t();if(c.accountId=p,c.body){let e=s(c.body);i(await o(`Updating`,async()=>f.aiGateway.gateways.providers.update({...e,account_id:p,gateway_id:c[`gateway-id`],id:c.id})),{successLabel:`Updated`});return}c.secret===void 0&&(c.secret=await d(`secret`,`The secret field`));let m=l({secret:u(c.secret,`secret`,`text`)});i(await o(`Updating`,async()=>f.aiGateway.gateways.providers.update({...m,account_id:p,gateway_id:c[`gateway-id`],id:c.id})),{successLabel:`Updated`})}},jt={command:`providers`,describe:`Operations for gateways.providers`,builder:e=>e.command(wt).command(Et).command(Ot).command(At).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Mt(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-classification`,{type:`boolean`,description:`The log_classification field`}).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(`otel`,{type:`string`,description:`The otel field. Provide as a JSON array of objects or @path/to/file.json.`}).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. 'postpaid' bills the account directly through Workers AI; 'unified' deducts credits via AI Gateway using neuron-based pricing and delegates billing to AI Gateway.`,choices:[`postpaid`,`unified`]}).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 Nt={command:`update <id>`,describe:`Updates an existing AI Gateway dataset.`,builder:Mt,handler:async d=>{if(d.dryRun){a({command:`cf ai-gateway gateways update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${d.id==null?`<id>`:encodeURIComponent(String(d.id))}`,pathParams:{id:String(d.id??``)},bodyKind:`json`,body:d.body===void 0?l({authentication:d.authentication,cache_invalidate_on_update:d[`cache-invalidate-on-update`],cache_ttl:d[`cache-ttl`],collect_logs:d[`collect-logs`],guardrails:{prompt:{P1:u(d[`guardrails-prompt-p1`],`guardrails-prompt-p1`,`text`),S1:u(d[`guardrails-prompt-s1`],`guardrails-prompt-s1`,`text`),S10:u(d[`guardrails-prompt-s10`],`guardrails-prompt-s10`,`text`),S11:u(d[`guardrails-prompt-s11`],`guardrails-prompt-s11`,`text`),S12:u(d[`guardrails-prompt-s12`],`guardrails-prompt-s12`,`text`),S13:u(d[`guardrails-prompt-s13`],`guardrails-prompt-s13`,`text`),S2:u(d[`guardrails-prompt-s2`],`guardrails-prompt-s2`,`text`),S3:u(d[`guardrails-prompt-s3`],`guardrails-prompt-s3`,`text`),S4:u(d[`guardrails-prompt-s4`],`guardrails-prompt-s4`,`text`),S5:u(d[`guardrails-prompt-s5`],`guardrails-prompt-s5`,`text`),S6:u(d[`guardrails-prompt-s6`],`guardrails-prompt-s6`,`text`),S7:u(d[`guardrails-prompt-s7`],`guardrails-prompt-s7`,`text`),S8:u(d[`guardrails-prompt-s8`],`guardrails-prompt-s8`,`text`),S9:u(d[`guardrails-prompt-s9`],`guardrails-prompt-s9`,`text`)},response:{P1:u(d[`guardrails-response-p1`],`guardrails-response-p1`,`text`),S1:u(d[`guardrails-response-s1`],`guardrails-response-s1`,`text`),S10:u(d[`guardrails-response-s10`],`guardrails-response-s10`,`text`),S11:u(d[`guardrails-response-s11`],`guardrails-response-s11`,`text`),S12:u(d[`guardrails-response-s12`],`guardrails-response-s12`,`text`),S13:u(d[`guardrails-response-s13`],`guardrails-response-s13`,`text`),S2:u(d[`guardrails-response-s2`],`guardrails-response-s2`,`text`),S3:u(d[`guardrails-response-s3`],`guardrails-response-s3`,`text`),S4:u(d[`guardrails-response-s4`],`guardrails-response-s4`,`text`),S5:u(d[`guardrails-response-s5`],`guardrails-response-s5`,`text`),S6:u(d[`guardrails-response-s6`],`guardrails-response-s6`,`text`),S7:u(d[`guardrails-response-s7`],`guardrails-response-s7`,`text`),S8:u(d[`guardrails-response-s8`],`guardrails-response-s8`,`text`),S9:u(d[`guardrails-response-s9`],`guardrails-response-s9`,`text`)}},log_classification:d[`log-classification`],log_management:d[`log-management`],log_management_strategy:u(d[`log-management-strategy`],`log-management-strategy`,`text`),logpush:d.logpush,logpush_public_key:u(d[`logpush-public-key`],`logpush-public-key`,`text`),otel:c(d.otel,`otel`),rate_limiting_interval:d[`rate-limiting-interval`],rate_limiting_limit:d[`rate-limiting-limit`],rate_limiting_technique:u(d[`rate-limiting-technique`],`rate-limiting-technique`,`text`),retry_backoff:u(d[`retry-backoff`],`retry-backoff`,`text`),retry_delay:d[`retry-delay`],retry_max_attempts:d[`retry-max-attempts`],spend_limits:{enabled:d[`spend-limits-enabled`]},store_id:u(d[`store-id`],`store-id`,`text`),stripe:{authorization:u(d[`stripe-authorization`],`stripe-authorization`,`text`)},workers_ai_billing_mode:u(d[`workers-ai-billing-mode`],`workers-ai-billing-mode`,`text`),zdr:d.zdr}):s(d.body)});return}let f=await r(d),p=d.local?e:await t();if(d.accountId=p,d.body){let e=s(d.body);i(await o(`Updating`,async()=>f.aiGateway.gateways.update({...e,account_id:p,id:d.id})),{successLabel:`Updated`});return}if(d[`cache-invalidate-on-update`]===void 0)throw Error(`--cache-invalidate-on-update is required (or pass --body with this field set).`);if(d[`cache-ttl`]===void 0)throw Error(`--cache-ttl is required (or pass --body with this field set).`);if(d[`collect-logs`]===void 0)throw Error(`--collect-logs is required (or pass --body with this field set).`);if(d[`rate-limiting-interval`]===void 0)throw Error(`--rate-limiting-interval is required (or pass --body with this field set).`);if(d[`rate-limiting-limit`]===void 0)throw Error(`--rate-limiting-limit is required (or pass --body with this field set).`);let m=l({authentication:d.authentication,cache_invalidate_on_update:d[`cache-invalidate-on-update`],cache_ttl:d[`cache-ttl`],collect_logs:d[`collect-logs`],guardrails:{prompt:{P1:u(d[`guardrails-prompt-p1`],`guardrails-prompt-p1`,`text`),S1:u(d[`guardrails-prompt-s1`],`guardrails-prompt-s1`,`text`),S10:u(d[`guardrails-prompt-s10`],`guardrails-prompt-s10`,`text`),S11:u(d[`guardrails-prompt-s11`],`guardrails-prompt-s11`,`text`),S12:u(d[`guardrails-prompt-s12`],`guardrails-prompt-s12`,`text`),S13:u(d[`guardrails-prompt-s13`],`guardrails-prompt-s13`,`text`),S2:u(d[`guardrails-prompt-s2`],`guardrails-prompt-s2`,`text`),S3:u(d[`guardrails-prompt-s3`],`guardrails-prompt-s3`,`text`),S4:u(d[`guardrails-prompt-s4`],`guardrails-prompt-s4`,`text`),S5:u(d[`guardrails-prompt-s5`],`guardrails-prompt-s5`,`text`),S6:u(d[`guardrails-prompt-s6`],`guardrails-prompt-s6`,`text`),S7:u(d[`guardrails-prompt-s7`],`guardrails-prompt-s7`,`text`),S8:u(d[`guardrails-prompt-s8`],`guardrails-prompt-s8`,`text`),S9:u(d[`guardrails-prompt-s9`],`guardrails-prompt-s9`,`text`)},response:{P1:u(d[`guardrails-response-p1`],`guardrails-response-p1`,`text`),S1:u(d[`guardrails-response-s1`],`guardrails-response-s1`,`text`),S10:u(d[`guardrails-response-s10`],`guardrails-response-s10`,`text`),S11:u(d[`guardrails-response-s11`],`guardrails-response-s11`,`text`),S12:u(d[`guardrails-response-s12`],`guardrails-response-s12`,`text`),S13:u(d[`guardrails-response-s13`],`guardrails-response-s13`,`text`),S2:u(d[`guardrails-response-s2`],`guardrails-response-s2`,`text`),S3:u(d[`guardrails-response-s3`],`guardrails-response-s3`,`text`),S4:u(d[`guardrails-response-s4`],`guardrails-response-s4`,`text`),S5:u(d[`guardrails-response-s5`],`guardrails-response-s5`,`text`),S6:u(d[`guardrails-response-s6`],`guardrails-response-s6`,`text`),S7:u(d[`guardrails-response-s7`],`guardrails-response-s7`,`text`),S8:u(d[`guardrails-response-s8`],`guardrails-response-s8`,`text`),S9:u(d[`guardrails-response-s9`],`guardrails-response-s9`,`text`)}},log_classification:d[`log-classification`],log_management:d[`log-management`],log_management_strategy:u(d[`log-management-strategy`],`log-management-strategy`,`text`),logpush:d.logpush,logpush_public_key:u(d[`logpush-public-key`],`logpush-public-key`,`text`),otel:c(d.otel,`otel`),rate_limiting_interval:d[`rate-limiting-interval`],rate_limiting_limit:d[`rate-limiting-limit`],rate_limiting_technique:u(d[`rate-limiting-technique`],`rate-limiting-technique`,`text`),retry_backoff:u(d[`retry-backoff`],`retry-backoff`,`text`),retry_delay:d[`retry-delay`],retry_max_attempts:d[`retry-max-attempts`],spend_limits:{enabled:d[`spend-limits-enabled`]},store_id:u(d[`store-id`],`store-id`,`text`),stripe:{authorization:u(d[`stripe-authorization`],`stripe-authorization`,`text`)},workers_ai_billing_mode:u(d[`workers-ai-billing-mode`],`workers-ai-billing-mode`,`text`),zdr:d.zdr});i(await o(`Updating`,async()=>f.aiGateway.gateways.update({...m,account_id:p,id:d.id})),{successLabel:`Updated`})}},Pt={command:`gateways`,describe:`Operations for gateways`,builder:e=>e.command(gt).command(vt).command(bt).command(St).command(Nt).command(jt).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Ft(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const It={command:`get`,describe:`Returns the canonical logging platform and migration availability for an account.`,builder:Ft,handler:async s=>{if(s.dryRun){a({command:`cf ai-gateway logging-state get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/logging-state`,pathParams:{},bodyKind:`none`});return}let c=await r(s),l=s.local?e:await t();s.accountId=l,i(await o(`Loading`,async()=>c.aiGateway.loggingState.get({account_id:l})),{successLabel:`Loaded`})}};function Lt(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Rt={command:`update`,describe:`Irreversibly migrates an eligible account to Workers Observability logging.`,builder:Lt,handler:async s=>{if(s.dryRun){a({command:`cf ai-gateway logging-state update`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/logging-state`,pathParams:{},bodyKind:`none`});return}let c=await r(s),l=s.local?e:await t();s.accountId=l,i(await o(`Updating`,async()=>c.aiGateway.loggingState.update({account_id:l})),{successLabel:`Updated`})}},zt={command:`logging-state`,describe:`Inspect and migrate the logging platform used by an AI Gateway account`,builder:e=>e.command(It).command(Rt).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Bt(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 $={command:`delete <gateway-id>`,describe:`Deletes gateway log entries matching the specified criteria.`,builder:m(Bt),handler:async s=>{let c={order_by:s[`order-by`],order_by_direction:s[`order-by-direction`],filters:s.filters,limit:s.limit};if(s.dryRun){a({command:`cf ai-gateway logs delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${s[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(s[`gateway-id`]))}/logs`,pathParams:{"gateway-id":String(s[`gateway-id`]??``)},query:c,bodyKind:`none`});return}let l=await r(s),u=s.local?e:await t();if(s.accountId=u,!await p({force:!!s.force})){process.stderr.write(`Aborted.
13
+ `);return}i(await o(`Deleting`,async()=>l.aiGateway.logs.delete({account_id:u,gateway_id:s[`gateway-id`],...c})),{successLabel:`Deleted`})}};function Vt(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 Ht={command:`edit <id>`,describe:`Updates metadata for an AI Gateway log entry.`,builder:Vt,handler:async c=>{if(c.dryRun){a({command:`cf ai-gateway logs edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${c[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(c[`gateway-id`]))}/logs/${c.id==null?`<id>`:encodeURIComponent(String(c.id))}`,pathParams:{id:String(c.id??``),"gateway-id":String(c[`gateway-id`]??``)},bodyKind:`json`,body:c.body===void 0?l({feedback:c.feedback,score:c.score}):s(c.body)});return}let u=await r(c),d=c.local?e:await t();if(c.accountId=d,c.body){let e=s(c.body);i(await o(`Updating`,async()=>u.aiGateway.logs.edit({...e,account_id:d,gateway_id:c[`gateway-id`],id:c.id})),{successLabel:`Updated`});return}let f=l({feedback:c.feedback,score:c.score});i(await o(`Updating`,async()=>u.aiGateway.logs.edit({...f,account_id:d,gateway_id:c[`gateway-id`],id:c.id})),{successLabel:`Updated`})}};function Ut(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 Wt={command:`get <id>`,describe:`Retrieves detailed information for a specific AI Gateway log entry.`,builder:Ut,handler:async s=>{if(s.dryRun){a({command:`cf ai-gateway logs get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${s[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(s[`gateway-id`]))}/logs/${s.id==null?`<id>`:encodeURIComponent(String(s.id))}`,pathParams:{id:String(s.id??``),"gateway-id":String(s[`gateway-id`]??``)},bodyKind:`none`});return}let c=await r(s),l=s.local?e:await t();s.accountId=l,i(await o(`Loading`,async()=>c.aiGateway.logs.get({account_id:l,gateway_id:s[`gateway-id`],id:s.id})),{successLabel:`Loaded`})}};function Gt(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 Kt={command:`list`,describe:`Lists request/response log entries for the AI gateway with filtering and pagination.`,builder:m(Gt),handler:async s=>{let c={search:s.search,page:s.page,per_page:s[`per-page`],order_by:s[`order-by`],order_by_direction:s[`order-by-direction`],filters:s.filters,meta_info:s[`meta-info`],direction:s.direction,start_date:s[`start-date`],end_date:s[`end-date`],min_cost:s[`min-cost`],max_cost:s[`max-cost`],min_tokens_in:s[`min-tokens-in`],max_tokens_in:s[`max-tokens-in`],min_tokens_out:s[`min-tokens-out`],max_tokens_out:s[`max-tokens-out`],min_total_tokens:s[`min-total-tokens`],max_total_tokens:s[`max-total-tokens`],min_duration:s[`min-duration`],max_duration:s[`max-duration`],feedback:s.feedback,success:s.success,cached:s.cached,model:s.model,model_type:s[`model-type`],provider:s.provider,request_content_type:s[`request-content-type`],response_content_type:s[`response-content-type`]};if(s.dryRun){a({command:`cf ai-gateway logs list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${s[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(s[`gateway-id`]))}/logs`,pathParams:{"gateway-id":String(s[`gateway-id`]??``)},query:c,bodyKind:`none`});return}let l=await r(s),u=s.local?e:await t();s.accountId=u,i(await o(`Loading`,async()=>l.aiGateway.logs.list({account_id:u,gateway_id:s[`gateway-id`],...c})),{successLabel:`Loaded`})}};function qt(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 Jt={command:`request <id>`,describe:`Retrieves the original request payload for an AI Gateway log entry.`,builder:qt,handler:async s=>{if(s.dryRun){a({command:`cf ai-gateway logs request`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${s[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(s[`gateway-id`]))}/logs/${s.id==null?`<id>`:encodeURIComponent(String(s.id))}/request`,pathParams:{id:String(s.id??``),"gateway-id":String(s[`gateway-id`]??``)},bodyKind:`none`});return}let c=await r(s),l=s.local?e:await t();s.accountId=l,i(await o(`Loading`,async()=>c.aiGateway.logs.request({account_id:l,gateway_id:s[`gateway-id`],id:s.id})),{successLabel:`Loaded`})}};function Yt(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 Xt={command:`response <id>`,describe:`Retrieves the response payload for an AI Gateway log entry.`,builder:Yt,handler:async s=>{if(s.dryRun){a({command:`cf ai-gateway logs response`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${s[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(s[`gateway-id`]))}/logs/${s.id==null?`<id>`:encodeURIComponent(String(s.id))}/response`,pathParams:{id:String(s.id??``),"gateway-id":String(s[`gateway-id`]??``)},bodyKind:`none`});return}let c=await r(s),l=s.local?e:await t();s.accountId=l,i(await o(`Loading`,async()=>c.aiGateway.logs.response({account_id:l,gateway_id:s[`gateway-id`],id:s.id})),{successLabel:`Loaded`})}},Zt={command:`logs`,describe:`Inspect individual request/response pairs that passed through the gateway`,builder:e=>e.command($).command(Ht).command(Wt).command(Kt).command(Jt).command(Xt).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Qt(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 $t={command:`get <provider>`,describe:`Retrieves the endpoint URL for an AI Gateway.`,builder:Qt,handler:async s=>{if(s.dryRun){a({command:`cf ai-gateway urls get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-gateway/gateways/${s[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(s[`gateway-id`]))}/url/${s.provider==null?`<provider>`:encodeURIComponent(String(s.provider))}`,pathParams:{"gateway-id":String(s[`gateway-id`]??``),provider:String(s.provider??``)},bodyKind:`none`});return}let c=await r(s),l=s.local?e:await t();s.accountId=l,i(await o(`Loading`,async()=>c.aiGateway.urls.get({account_id:l,gateway_id:s[`gateway-id`],provider:s.provider})),{successLabel:`Loaded`})}},en={command:`urls`,describe:`Retrieve the gateway's proxy URL used by clients to send inference requests`,builder:e=>e.command($t).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},tn={command:`ai-gateway`,describe:`Proxy, cache, rate-limit, and observe requests to AI providers — OpenAI, Anthropic, Workers AI, and more`,builder:e=>e.command(P).command(he).command(we).command(Fe).command(nt).command(at).command(mt).command(Pt).command(zt).command(Zt).command(en).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{tn as default};
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+ import{t as e}from"./local-DGiIS1uM.mjs";import{f as t,g as n}from"./oauth-DAa7SwkM.mjs";import{a as r,r as i}from"./auth-DY_Y2bXC.mjs";import{t as a}from"./output-BqDR9h74.mjs";import{t as o}from"./dry-run-ILZRVpnp.mjs";import{t as s}from"./progress-jYW64HY7.mjs";import{n as c,r as l,t as u}from"./body-parser-BGVbwPeM.mjs";import{n as d,t as f}from"./input-validation-1esLElok.mjs";import{a as p,i as m,n as h}from"./prompt-CyATfGUu.mjs";import{t as g}from"./cli-types-C3nVfpSG.mjs";import{n as ee,t as te}from"./raw-fetch-CNKIypJ7.mjs";function _(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`ai-search-options-cache-cache-threshold`,{type:`string`,description:`The ai_search_options.cache.cache_threshold field`,choices:[`super_strict_match`,`close_enough`,`flexible_friend`,`anything_goes`]}).option(`ai-search-options-cache-enabled`,{type:`boolean`,description:`The ai_search_options.cache.enabled field`}).option(`ai-search-options-query-rewrite-enabled`,{type:`boolean`,description:`The ai_search_options.query_rewrite.enabled field`}).option(`ai-search-options-query-rewrite-model`,{type:`string`,description:`A Workers AI model ID or an AI Gateway model ID compatible with the OpenAI Chat Completions API. An empty string uses the configured or default model.`}).option(`ai-search-options-query-rewrite-rewrite-prompt`,{type:`string`,description:`The ai_search_options.query_rewrite.rewrite_prompt field`}).option(`ai-search-options-reranking-enabled`,{type:`boolean`,description:`The ai_search_options.reranking.enabled field`}).option(`ai-search-options-reranking-match-threshold`,{type:`number`,description:`The ai_search_options.reranking.match_threshold field`}).option(`ai-search-options-reranking-model`,{type:`string`,description:`The ai_search_options.reranking.model field`}).option(`ai-search-options-retrieval-context-expansion`,{type:`number`,description:`The ai_search_options.retrieval.context_expansion field`}).option(`ai-search-options-retrieval-fusion-method`,{type:`string`,description:`The ai_search_options.retrieval.fusion_method field`,choices:[`max`,`rrf`]}).option(`ai-search-options-retrieval-keyword-match-mode`,{type:`string`,description:`Controls which documents are candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term, ranked by BM25 relevance. When omitted, falls back to the instance-level retrieval_options.keyword_match_mode, then to 'and'.`,choices:[`and`,`or`]}).option(`ai-search-options-retrieval-match-threshold`,{type:`number`,description:`The ai_search_options.retrieval.match_threshold field`}).option(`ai-search-options-retrieval-max-num-results`,{type:`number`,description:`The ai_search_options.retrieval.max_num_results field`}).option(`ai-search-options-retrieval-retrieval-type`,{type:`string`,description:`The ai_search_options.retrieval.retrieval_type field`,choices:[`vector`,`keyword`,`hybrid`]}).option(`ai-search-options-retrieval-return-on-failure`,{type:`boolean`,description:`The ai_search_options.retrieval.return_on_failure field`}).option(`messages`,{type:`string`,description:`The messages field. Provide as a JSON array of objects or @path/to/file.json.`}).option(`model`,{type:`string`,description:`A Workers AI model ID or an AI Gateway model ID compatible with the OpenAI Chat Completions API. An empty string uses the configured or default model.`}).option(`stream`,{type:`boolean`,description:`The stream field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const v={command:`chat-completions <id>`,describe:`Performs a chat completion request against an AI Search instance, using indexed content as context for generating responses.`,builder:_,handler:async r=>{if(r.dryRun){o({command:`cf ai-search chat-completions`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}/chat/completions`,pathParams:{id:String(r.id??``),name:String(r.name??``)},bodyKind:`json`,body:r.body===void 0?u({ai_search_options:{cache:{cache_threshold:d(r[`ai-search-options-cache-cache-threshold`],`ai-search-options-cache-cache-threshold`,`text`),enabled:r[`ai-search-options-cache-enabled`]},query_rewrite:{enabled:r[`ai-search-options-query-rewrite-enabled`],model:d(r[`ai-search-options-query-rewrite-model`],`ai-search-options-query-rewrite-model`,`text`),rewrite_prompt:d(r[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:r[`ai-search-options-reranking-enabled`],match_threshold:r[`ai-search-options-reranking-match-threshold`],model:d(r[`ai-search-options-reranking-model`],`ai-search-options-reranking-model`,`text`)},retrieval:{context_expansion:r[`ai-search-options-retrieval-context-expansion`],fusion_method:d(r[`ai-search-options-retrieval-fusion-method`],`ai-search-options-retrieval-fusion-method`,`text`),keyword_match_mode:d(r[`ai-search-options-retrieval-keyword-match-mode`],`ai-search-options-retrieval-keyword-match-mode`,`text`),match_threshold:r[`ai-search-options-retrieval-match-threshold`],max_num_results:r[`ai-search-options-retrieval-max-num-results`],retrieval_type:d(r[`ai-search-options-retrieval-retrieval-type`],`ai-search-options-retrieval-retrieval-type`,`text`),return_on_failure:r[`ai-search-options-retrieval-return-on-failure`]}},messages:l(r.messages,`messages`),model:d(r.model,`model`,`text`),stream:r.stream}):c(r.body)});return}let f=await i(r),p=r.local?e:await t();if(r.accountId=p,r.body){let e=c(r.body);a(await s(`Creating`,async()=>f.aiSearch.chatCompletions({...e,account_id:p,name:r.name,id:r.id})),{successLabel:`Created`});return}if(r.messages===void 0)throw Error(`--messages is required (or pass --body with this field set).`);let m=u({ai_search_options:{cache:{cache_threshold:d(r[`ai-search-options-cache-cache-threshold`],`ai-search-options-cache-cache-threshold`,`text`),enabled:r[`ai-search-options-cache-enabled`]},query_rewrite:{enabled:r[`ai-search-options-query-rewrite-enabled`],model:d(r[`ai-search-options-query-rewrite-model`],`ai-search-options-query-rewrite-model`,`text`),rewrite_prompt:d(r[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:r[`ai-search-options-reranking-enabled`],match_threshold:r[`ai-search-options-reranking-match-threshold`],model:d(r[`ai-search-options-reranking-model`],`ai-search-options-reranking-model`,`text`)},retrieval:{context_expansion:r[`ai-search-options-retrieval-context-expansion`],fusion_method:d(r[`ai-search-options-retrieval-fusion-method`],`ai-search-options-retrieval-fusion-method`,`text`),keyword_match_mode:d(r[`ai-search-options-retrieval-keyword-match-mode`],`ai-search-options-retrieval-keyword-match-mode`,`text`),match_threshold:r[`ai-search-options-retrieval-match-threshold`],max_num_results:r[`ai-search-options-retrieval-max-num-results`],retrieval_type:d(r[`ai-search-options-retrieval-retrieval-type`],`ai-search-options-retrieval-retrieval-type`,`text`),return_on_failure:r[`ai-search-options-retrieval-return-on-failure`]}},messages:l(r.messages,`messages`),model:d(r.model,`model`,`text`),stream:r.stream});a(await s(`Creating`,async()=>f.aiSearch.chatCompletions({...m,account_id:p,name:r.name,id:r.id})),{successLabel:`Created`})}};function y(e){return e.positional(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).positional(`id`,{type:`string`,description:`Unique ID for the new AI Search instance.`,demandOption:!0}).option(`ai-gateway-id`,{type:`string`,description:`The ai_gateway_id field`}).option(`ai-search-model`,{type:`string`,description:`A Workers AI model ID or an AI Gateway model ID compatible with the OpenAI Chat Completions API. An empty string uses the configured or default model.`}).option(`cache`,{type:`boolean`,description:`The cache field`,default:!0}).option(`cache-threshold`,{type:`string`,description:`The cache_threshold field`,choices:[`super_strict_match`,`close_enough`,`flexible_friend`,`anything_goes`],default:`close_enough`}).option(`chunk`,{type:`boolean`,description:`The chunk field`,default:!0}).option(`chunk-overlap`,{type:`number`,description:`The chunk_overlap field`,default:10}).option(`chunk-size`,{type:`number`,description:`The chunk_size field`}).option(`custom-metadata`,{type:`string`,description:`The custom_metadata field. Provide as a JSON array of objects or @path/to/file.json.`}).option(`embedding-model`,{type:`string`,description:`The embedding_model field`}).option(`fusion-method`,{type:`string`,description:`The fusion_method field`,choices:[`max`,`rrf`],default:`rrf`}).option(`hybrid-search-enabled`,{type:`boolean`,description:`Deprecated — use index_method instead.`,default:!1}).option(`index-method-keyword`,{type:`boolean`,description:`Enable keyword (BM25) storage backend.`}).option(`index-method-vector`,{type:`boolean`,description:`Enable vector (embedding) storage backend.`}).option(`indexing-options-keyword-tokenizer`,{type:`string`,description:`Tokenizer used for keyword search indexing. porter provides word-level tokenization with Porter stemming (good for natural language queries). trigram enables character-level substring matching (good for partial matches, code, identifiers). Changing this triggers a full re-index. Defaults to porter.`,choices:[`porter`,`trigram`]}).option(`max-num-results`,{type:`number`,description:`The max_num_results field`,default:10}).option(`metadata-created-from-aisearch-wizard`,{type:`boolean`,description:`The metadata.created_from_aisearch_wizard field`}).option(`metadata-worker-domain`,{type:`string`,description:`The metadata.worker_domain field`}).option(`public-endpoint-params-authorized-hosts`,{type:`string`,array:!0,description:`The public_endpoint_params.authorized_hosts field`}).option(`public-endpoint-params-chat-completions-endpoint-disabled`,{type:`boolean`,description:`Disable chat completions endpoint for this public endpoint`}).option(`public-endpoint-params-custom-domains`,{type:`string`,array:!0,description:`Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged).`}).option(`public-endpoint-params-default-domain-enabled`,{type:`boolean`,description:`When false, the instance is reachable only via a registered custom domain and the default <public_endpoint_id>.search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true.`}).option(`public-endpoint-params-enabled`,{type:`boolean`,description:`The public_endpoint_params.enabled field`}).option(`public-endpoint-params-mcp-description`,{type:`string`,description:`The public_endpoint_params.mcp.description field`}).option(`public-endpoint-params-mcp-disabled`,{type:`boolean`,description:`Disable MCP endpoint for this public endpoint`}).option(`public-endpoint-params-rate-limit-period-ms`,{type:`number`,description:`The public_endpoint_params.rate_limit.period_ms field`}).option(`public-endpoint-params-rate-limit-requests`,{type:`number`,description:`The public_endpoint_params.rate_limit.requests field`}).option(`public-endpoint-params-rate-limit-technique`,{type:`string`,description:`The public_endpoint_params.rate_limit.technique field`,choices:[`fixed`,`sliding`]}).option(`public-endpoint-params-search-endpoint-disabled`,{type:`boolean`,description:`Disable search endpoint for this public endpoint`}).option(`reranking`,{type:`boolean`,description:`The reranking field`,default:!1}).option(`reranking-model`,{type:`string`,description:`The reranking_model field`}).option(`retrieval-options-keyword-match-mode`,{type:`string`,description:`Controls which documents are candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term, ranked by BM25 relevance. When omitted on an update, the existing stored value is preserved; when never set, search falls back to 'and'.`,choices:[`and`,`or`]}).option(`rewrite-model`,{type:`string`,description:`A Workers AI model ID or an AI Gateway model ID compatible with the OpenAI Chat Completions API. An empty string uses the configured or default model.`}).option(`rewrite-query`,{type:`boolean`,description:`The rewrite_query field`,default:!1}).option(`score-threshold`,{type:`number`,description:`The score_threshold field`,default:.4}).option(`source`,{type:`string`,description:`The source field`}).option(`source-params-exclude-items`,{type:`string`,array:!0,description:`List of path patterns to exclude. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /admin/** matches /admin/users and /admin/settings/advanced). Most accounts are limited to 10 rules; contact support to raise it.`}).option(`source-params-include-items`,{type:`string`,array:!0,description:`List of path patterns to include. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /blog/** matches /blog/post and /blog/2024/post). Most accounts are limited to 10 rules; contact support to raise it.`}).option(`source-params-prefix`,{type:`string`,description:`The source_params.prefix field`}).option(`source-params-r2-jurisdiction`,{type:`string`,description:`The source_params.r2_jurisdiction field`}).option(`source-params-web-crawler-discover-options-depth`,{type:`number`,description:`Maximum link-follow depth from the seed URL.`}).option(`source-params-web-crawler-discover-options-include-external-links`,{type:`boolean`,description:"Follow links that point outside the source domain. Must stay `false` — discover crawls are restricted to the zone you own."}).option(`source-params-web-crawler-discover-options-include-subdomains`,{type:`boolean`,description:`Follow links to subdomains of the source host.`}).option(`source-params-web-crawler-discover-options-limit`,{type:`number`,description:`Maximum number of pages to crawl (1-100000).`}).option(`source-params-web-crawler-discover-options-max-age`,{type:`number`,description:`Maximum content age in seconds to accept (0–604800).`}).option(`source-params-web-crawler-discover-options-source`,{type:`string`,description:`Where the crawler looks for URLs: 'sitemaps' reads sitemap XML only, 'links' follows page links only, 'all' does both.`,choices:[`all`,`sitemaps`,`links`]}).option(`source-params-web-crawler-parse-options-include-images`,{type:`boolean`,description:`The source_params.web_crawler.parse_options.include_images field`}).option(`source-params-web-crawler-parse-options-specific-sitemaps`,{type:`string`,array:!0,description:`List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'.`}).option(`source-params-web-crawler-parse-options-use-browser-rendering`,{type:`boolean`,description:`The source_params.web_crawler.parse_options.use_browser_rendering field`}).option(`source-params-web-crawler-parse-type`,{type:`string`,description:`How URLs are discovered. 'sitemap' reads XML sitemaps; 'discover' follows links recursively and requires the source to be a Verified zone on this account.`,choices:[`sitemap`,`discover`]}).option(`token-id`,{type:`string`,description:`The token_id field`}).option(`type`,{type:`string`,description:`The type field`,choices:[`r2`,`web-crawler`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`}).check(e=>{if([`index-method-keyword`,`index-method-vector`].some(t=>e[t]!==void 0)){let t=[`index-method-keyword`,`index-method-vector`].filter(t=>e[t]===void 0);if(t.length>0)throw Error(`${t.map(e=>`--`+e).join(`, `)} ${t.length===1?`is`:`are`} required when any --index_method-* flag is set`)}return!0})}const b={command:`create <name> <id>`,describe:`Create a new AI Search instance with the given configuration.`,builder:y,handler:async r=>{if(r.dryRun){o({command:`cf ai-search create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances`,pathParams:{name:String(r.name??``)},bodyKind:`json`,body:r.body===void 0?u({ai_gateway_id:d(r[`ai-gateway-id`],`ai-gateway-id`,`text`),ai_search_model:d(r[`ai-search-model`],`ai-search-model`,`text`),cache:r.cache,cache_threshold:d(r[`cache-threshold`],`cache-threshold`,`text`),chunk:r.chunk,chunk_overlap:r[`chunk-overlap`],chunk_size:r[`chunk-size`],custom_metadata:l(r[`custom-metadata`],`custom-metadata`),embedding_model:d(r[`embedding-model`],`embedding-model`,`text`),fusion_method:d(r[`fusion-method`],`fusion-method`,`text`),hybrid_search_enabled:r[`hybrid-search-enabled`],index_method:{keyword:r[`index-method-keyword`],vector:r[`index-method-vector`]},indexing_options:{keyword_tokenizer:d(r[`indexing-options-keyword-tokenizer`],`indexing-options-keyword-tokenizer`,`text`)},max_num_results:r[`max-num-results`],metadata:{created_from_aisearch_wizard:r[`metadata-created-from-aisearch-wizard`],worker_domain:d(r[`metadata-worker-domain`],`metadata-worker-domain`,`text`)},public_endpoint_params:{authorized_hosts:r[`public-endpoint-params-authorized-hosts`],chat_completions_endpoint:{disabled:r[`public-endpoint-params-chat-completions-endpoint-disabled`]},custom_domains:r[`public-endpoint-params-custom-domains`],default_domain_enabled:r[`public-endpoint-params-default-domain-enabled`],enabled:r[`public-endpoint-params-enabled`],mcp:{description:d(r[`public-endpoint-params-mcp-description`],`public-endpoint-params-mcp-description`,`text`),disabled:r[`public-endpoint-params-mcp-disabled`]},rate_limit:{period_ms:r[`public-endpoint-params-rate-limit-period-ms`],requests:r[`public-endpoint-params-rate-limit-requests`],technique:d(r[`public-endpoint-params-rate-limit-technique`],`public-endpoint-params-rate-limit-technique`,`text`)},search_endpoint:{disabled:r[`public-endpoint-params-search-endpoint-disabled`]}},reranking:r.reranking,reranking_model:d(r[`reranking-model`],`reranking-model`,`text`),retrieval_options:{keyword_match_mode:d(r[`retrieval-options-keyword-match-mode`],`retrieval-options-keyword-match-mode`,`text`)},rewrite_model:d(r[`rewrite-model`],`rewrite-model`,`text`),rewrite_query:r[`rewrite-query`],score_threshold:r[`score-threshold`],source:d(r.source,`source`,`text`),source_params:{exclude_items:r[`source-params-exclude-items`],include_items:r[`source-params-include-items`],prefix:d(r[`source-params-prefix`],`source-params-prefix`,`text`),r2_jurisdiction:d(r[`source-params-r2-jurisdiction`],`source-params-r2-jurisdiction`,`text`),web_crawler:{discover_options:{depth:r[`source-params-web-crawler-discover-options-depth`],include_external_links:r[`source-params-web-crawler-discover-options-include-external-links`],include_subdomains:r[`source-params-web-crawler-discover-options-include-subdomains`],limit:r[`source-params-web-crawler-discover-options-limit`],max_age:r[`source-params-web-crawler-discover-options-max-age`],source:d(r[`source-params-web-crawler-discover-options-source`],`source-params-web-crawler-discover-options-source`,`text`)},parse_options:{include_images:r[`source-params-web-crawler-parse-options-include-images`],specific_sitemaps:r[`source-params-web-crawler-parse-options-specific-sitemaps`],use_browser_rendering:r[`source-params-web-crawler-parse-options-use-browser-rendering`]},parse_type:d(r[`source-params-web-crawler-parse-type`],`source-params-web-crawler-parse-type`,`text`)}},token_id:d(r[`token-id`],`token-id`,`text`),type:d(r.type,`type`,`text`),id:r.id}):c(r.body)});return}let f=await i(r),p=r.local?e:await t();if(r.accountId=p,r.body){let e=c(r.body);a(await s(`Creating`,async()=>f.aiSearch.create({...e,account_id:p,name:r.name})),{successLabel:`Created`});return}let m=u({ai_gateway_id:d(r[`ai-gateway-id`],`ai-gateway-id`,`text`),ai_search_model:d(r[`ai-search-model`],`ai-search-model`,`text`),cache:r.cache,cache_threshold:d(r[`cache-threshold`],`cache-threshold`,`text`),chunk:r.chunk,chunk_overlap:r[`chunk-overlap`],chunk_size:r[`chunk-size`],custom_metadata:l(r[`custom-metadata`],`custom-metadata`),embedding_model:d(r[`embedding-model`],`embedding-model`,`text`),fusion_method:d(r[`fusion-method`],`fusion-method`,`text`),hybrid_search_enabled:r[`hybrid-search-enabled`],index_method:{keyword:r[`index-method-keyword`],vector:r[`index-method-vector`]},indexing_options:{keyword_tokenizer:d(r[`indexing-options-keyword-tokenizer`],`indexing-options-keyword-tokenizer`,`text`)},max_num_results:r[`max-num-results`],metadata:{created_from_aisearch_wizard:r[`metadata-created-from-aisearch-wizard`],worker_domain:d(r[`metadata-worker-domain`],`metadata-worker-domain`,`text`)},public_endpoint_params:{authorized_hosts:r[`public-endpoint-params-authorized-hosts`],chat_completions_endpoint:{disabled:r[`public-endpoint-params-chat-completions-endpoint-disabled`]},custom_domains:r[`public-endpoint-params-custom-domains`],default_domain_enabled:r[`public-endpoint-params-default-domain-enabled`],enabled:r[`public-endpoint-params-enabled`],mcp:{description:d(r[`public-endpoint-params-mcp-description`],`public-endpoint-params-mcp-description`,`text`),disabled:r[`public-endpoint-params-mcp-disabled`]},rate_limit:{period_ms:r[`public-endpoint-params-rate-limit-period-ms`],requests:r[`public-endpoint-params-rate-limit-requests`],technique:d(r[`public-endpoint-params-rate-limit-technique`],`public-endpoint-params-rate-limit-technique`,`text`)},search_endpoint:{disabled:r[`public-endpoint-params-search-endpoint-disabled`]}},reranking:r.reranking,reranking_model:d(r[`reranking-model`],`reranking-model`,`text`),retrieval_options:{keyword_match_mode:d(r[`retrieval-options-keyword-match-mode`],`retrieval-options-keyword-match-mode`,`text`)},rewrite_model:d(r[`rewrite-model`],`rewrite-model`,`text`),rewrite_query:r[`rewrite-query`],score_threshold:r[`score-threshold`],source:d(r.source,`source`,`text`),source_params:{exclude_items:r[`source-params-exclude-items`],include_items:r[`source-params-include-items`],prefix:d(r[`source-params-prefix`],`source-params-prefix`,`text`),r2_jurisdiction:d(r[`source-params-r2-jurisdiction`],`source-params-r2-jurisdiction`,`text`),web_crawler:{discover_options:{depth:r[`source-params-web-crawler-discover-options-depth`],include_external_links:r[`source-params-web-crawler-discover-options-include-external-links`],include_subdomains:r[`source-params-web-crawler-discover-options-include-subdomains`],limit:r[`source-params-web-crawler-discover-options-limit`],max_age:r[`source-params-web-crawler-discover-options-max-age`],source:d(r[`source-params-web-crawler-discover-options-source`],`source-params-web-crawler-discover-options-source`,`text`)},parse_options:{include_images:r[`source-params-web-crawler-parse-options-include-images`],specific_sitemaps:r[`source-params-web-crawler-parse-options-specific-sitemaps`],use_browser_rendering:r[`source-params-web-crawler-parse-options-use-browser-rendering`]},parse_type:d(r[`source-params-web-crawler-parse-type`],`source-params-web-crawler-parse-type`,`text`)}},token_id:d(r[`token-id`],`token-id`,`text`),type:d(r.type,`type`,`text`),id:r.id});a(await s(`Creating`,async()=>f.aiSearch.create({...m,account_id:p,name:r.name})),{successLabel:`Created`})}};function x(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const S={command:`delete <id>`,describe:`Permanently delete an AI Search instance and all its indexed data.`,builder:x,handler:async r=>{if(r.dryRun){o({command:`cf ai-search delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}`,pathParams:{id:String(r.id??``),name:String(r.name??``)},bodyKind:`none`});return}let c=await i(r),l=r.local?e:await t();if(r.accountId=l,!await h({force:!!r.force,message:`This operation permanently deletes the AI Search instance and all its indexed data.`})){process.stderr.write(`Aborted.
3
+ `);return}a(await s(`Deleting`,async()=>c.aiSearch.delete({account_id:l,name:r.name,id:r.id})),{successLabel:`Deleted`})}};function C(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const w={command:`get <id>`,describe:`Retrieve the configuration and status of an AI Search instance.`,builder:C,handler:async r=>{if(r.dryRun){o({command:`cf ai-search get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}`,pathParams:{id:String(r.id??``),name:String(r.name??``)},bodyKind:`none`});return}let c=await i(r),l=r.local?e:await t();r.accountId=l,a(await s(`Loading`,async()=>c.aiSearch.get({account_id:l,name:r.name,id:r.id})),{successLabel:`Loaded`})}};function T(e){return e.positional(`item-id`,{type:`string`,description:`Indexed item ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`limit`,{type:`number`,description:`Limit`}).option(`offset`,{type:`number`,description:`Offset`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const E={command:`chunks <item-id>`,describe:`Lists chunks for a specific item in an AI Search instance, including their text content.`,builder:T,handler:async r=>{let c={limit:r.limit,offset:r.offset};if(r.dryRun){o({command:`cf ai-search items chunks`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}/items/${r[`item-id`]==null?`<item-id>`:encodeURIComponent(String(r[`item-id`]))}/chunks`,pathParams:{id:String(r.id??``),"item-id":String(r[`item-id`]??``),name:String(r.name??``)},query:c,bodyKind:`none`});return}let l=await i(r),u=r.local?e:await t();r.accountId=u,a(await s(`Loading`,async()=>l.aiSearch.items.chunks({account_id:u,name:r.name,id:r.id,item_id:r[`item-id`],...c})),{successLabel:`Loaded`})}};function D(e){return e.positional(`item-id`,{type:`string`,description:`Indexed item ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const O={command:`delete <item-id>`,describe:`Deletes a file from a managed AI Search instance and triggers a reindex.`,builder:D,handler:async r=>{if(r.dryRun){o({command:`cf ai-search items delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}/items/${r[`item-id`]==null?`<item-id>`:encodeURIComponent(String(r[`item-id`]))}`,pathParams:{id:String(r.id??``),"item-id":String(r[`item-id`]??``),name:String(r.name??``)},bodyKind:`none`});return}let c=await i(r),l=r.local?e:await t();if(r.accountId=l,!await h({force:!!r.force})){process.stderr.write(`Aborted.
4
+ `);return}a(await s(`Deleting`,async()=>c.aiSearch.items.delete({account_id:l,name:r.name,id:r.id,item_id:r[`item-id`]})),{successLabel:`Deleted`})}};function k(e){return e.positional(`item-id`,{type:`string`,description:`Indexed item ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`text`,{type:`boolean`,description:`Decode the response body as UTF-8 text instead of writing raw bytes`,default:!1})}const A={command:`download <item-id>`,describe:`Downloads the raw file content for a specific item from the managed AI Search instance storage.`,builder:k,handler:async r=>{if(r.dryRun){o({command:`cf ai-search items download`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}/items/${r[`item-id`]==null?`<item-id>`:encodeURIComponent(String(r[`item-id`]))}/download`,pathParams:{id:String(r.id??``),"item-id":String(r[`item-id`]??``),name:String(r.name??``)},bodyKind:`none`});return}await i(r);let a=r.local?e:await t();r.accountId=a;let c=await s(`Loading`,async()=>te(`/accounts/${a}/ai-search/namespaces/${encodeURIComponent(String(r.name))}/instances/${encodeURIComponent(String(r.id))}/items/${encodeURIComponent(String(r[`item-id`]))}/download`,{method:`GET`,local:r.local===!0,persistTo:r.persistTo}));ee(r.text===!0?c.toString(`utf-8`):c)}};function j(e){return e.positional(`item-id`,{type:`string`,description:`Indexed item ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const M={command:`get <item-id>`,describe:`Retrieves a specific indexed item from an AI Search instance.`,builder:j,handler:async r=>{if(r.dryRun){o({command:`cf ai-search items get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}/items/${r[`item-id`]==null?`<item-id>`:encodeURIComponent(String(r[`item-id`]))}`,pathParams:{id:String(r.id??``),"item-id":String(r[`item-id`]??``),name:String(r.name??``)},bodyKind:`none`});return}let c=await i(r),l=r.local?e:await t();r.accountId=l,a(await s(`Loading`,async()=>c.aiSearch.items.get({account_id:l,name:r.name,id:r.id,item_id:r[`item-id`]})),{successLabel:`Loaded`})}};function N(e){return e.option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`page`,{type:`number`,description:`Page`}).option(`per-page`,{type:`number`,description:`Per page`}).option(`search`,{type:`string`,description:`Search`}).option(`sort-by`,{type:`string`,description:`Sort order for items. "status" (default) sorts by status priority then last_seen_at. "modified_at" sorts by file modification time (most recent first), falling back to created_at.`,choices:[`status`,`modified_at`]}).option(`status`,{type:`string`,description:`Status`,choices:[`queued`,`running`,`completed`,`error`,`skipped`,`outdated`]}).option(`source`,{type:`string`,description:`Filter items by source_id. Use "builtin" for uploaded files, or a source identifier like "web-crawler:https://example.com".`}).option(`metadata-filter`,{type:`string`,description:`JSON-encoded metadata filter using Vectorize filter syntax. Examples: {"folder":"reports/"}, {"timestamp":{"$gte":1700000000000}}, {"folder":{"$in":["docs/","reports/"]}}`}).option(`item-id`,{type:`string`,description:`Filter items by their unique ID. Returns at most one item.`}).option(`key`,{type:`string`,description:"Filter items by their exact key (object key / filename). Keys are unique per source, so combine with `source` to disambiguate across data sources."}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const P={command:`list`,describe:`Lists indexed items in an AI Search instance.`,builder:g(N),handler:async r=>{let c={page:r.page,per_page:r[`per-page`],search:r.search,sort_by:r[`sort-by`],status:r.status,source:r.source,metadata_filter:r[`metadata-filter`],item_id:r[`item-id`],key:r.key};if(r.dryRun){o({command:`cf ai-search items list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}/items`,pathParams:{id:String(r.id??``),name:String(r.name??``)},query:c,bodyKind:`none`});return}let l=await i(r),u=r.local?e:await t();r.accountId=u,a(await s(`Loading`,async()=>l.aiSearch.items.list({account_id:u,name:r.name,id:r.id,...c})),{successLabel:`Loaded`})}};function F(e){return e.positional(`item-id`,{type:`string`,description:`Indexed item ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`limit`,{type:`number`,description:`Limit`}).option(`cursor`,{type:`string`,description:`Cursor`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const I={command:`logs <item-id>`,describe:`Lists processing logs for a specific item in an AI Search instance.`,builder:F,handler:async r=>{let c={limit:r.limit,cursor:r.cursor};if(r.dryRun){o({command:`cf ai-search items logs`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}/items/${r[`item-id`]==null?`<item-id>`:encodeURIComponent(String(r[`item-id`]))}/logs`,pathParams:{id:String(r.id??``),"item-id":String(r[`item-id`]??``),name:String(r.name??``)},query:c,bodyKind:`none`});return}let l=await i(r),u=r.local?e:await t();r.accountId=u,a(await s(`Loading`,async()=>l.aiSearch.items.logs({account_id:u,name:r.name,id:r.id,item_id:r[`item-id`],...c})),{successLabel:`Loaded`})}};function L(e){return e.positional(`item-id`,{type:`string`,description:`Indexed item ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`next-action`,{type:`string`,description:`The next_action field`,choices:[`INDEX`]}).option(`wait-for-completion`,{type:`boolean`,description:"Wait for indexing to fully complete before responding. On RAGs with vector indexing enabled, this additionally waits for Vectorize ingestion confirmation (up to 40s) so the returned item reflects a queryable state. On timeout the item is returned in `running` state and the background alarm continues polling. Defaults to false."}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const R={command:`sync <item-id>`,describe:`Syncs an item to an AI Search instance index.`,builder:L,handler:async r=>{if(r.dryRun){o({command:`cf ai-search items sync`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}/items/${r[`item-id`]==null?`<item-id>`:encodeURIComponent(String(r[`item-id`]))}`,pathParams:{id:String(r.id??``),"item-id":String(r[`item-id`]??``),name:String(r.name??``)},bodyKind:`json`,body:r.body===void 0?u({next_action:d(r[`next-action`],`next-action`,`text`),wait_for_completion:r[`wait-for-completion`]}):c(r.body)});return}let l=await i(r),f=r.local?e:await t();if(r.accountId=f,r.body){let e=c(r.body);a(await s(`Updating`,async()=>l.aiSearch.items.sync({...e,account_id:f,name:r.name,id:r.id,item_id:r[`item-id`]})),{successLabel:`Updated`});return}r[`next-action`]===void 0&&(r[`next-action`]=await m(`next-action`,`The next_action field`,[`INDEX`]));let p=u({next_action:d(r[`next-action`],`next-action`,`text`),wait_for_completion:r[`wait-for-completion`]});a(await s(`Updating`,async()=>l.aiSearch.items.sync({...p,account_id:f,name:r.name,id:r.id,item_id:r[`item-id`]})),{successLabel:`Updated`})}};function z(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`}).option(`file`,{type:`string`,description:`Path to a file to upload as the request body`}).option(`metadata`,{type:`string`,description:`JSON string of custom metadata key-value pairs.`}).option(`wait-for-completion`,{type:`boolean`,description:"Wait for indexing to fully complete before responding. On RAGs with vector indexing enabled, this additionally waits for Vectorize ingestion confirmation (up to 40s) so the returned item reflects a queryable state. On timeout the item is returned in `running` state and the background alarm continues polling. Defaults to false."})}const B={command:`upload <id>`,describe:`Uploads a file to a managed AI Search instance via multipart/form-data.`,builder:z,handler:async c=>{if(c.dryRun){o({command:`cf ai-search items upload`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${c.name==null?`<name>`:encodeURIComponent(String(c.name))}/instances/${c.id==null?`<id>`:encodeURIComponent(String(c.id))}/items`,pathParams:{id:String(c.id??``),name:String(c.name??``)},bodyKind:`multipart`,body:{body:c.body,file:c.file,metadata:c.metadata,"wait-for-completion":c[`wait-for-completion`]}});return}let l=await i(c),u=c.local?e:await t();if(c.accountId=u,c.file!==void 0||c.body!==void 0||c.metadata!==void 0||c[`wait-for-completion`]!==void 0){let e=new FormData;if(c.file){let t=f(c.file);e.append(`file`,new Blob([t]),c.file.split(/[\\/]/).filter(Boolean).pop())}else c.body!==void 0&&e.append(`file`,c.body);c.metadata!==void 0&&e.append(`metadata`,String(d(c.metadata,`metadata`,`text`)??``)),c[`wait-for-completion`]!==void 0&&e.append(`wait_for_completion`,String(c[`wait-for-completion`])),a(await s(`Creating`,async()=>r(l,`POST`,`/accounts/${u}/ai-search/namespaces/${encodeURIComponent(String(c.name))}/instances/${encodeURIComponent(String(c.id))}/items`,{body:e})),{successLabel:`Created`});return}if(c.body){let e=d(c.body,`body`,`binary`);a(await s(`Creating`,async()=>r(l,`POST`,`/accounts/${u}/ai-search/namespaces/${encodeURIComponent(String(c.name))}/instances/${encodeURIComponent(String(c.id))}/items`,{body:e,headers:{"Content-Type":`multipart/form-data`}})),{successLabel:`Created`});return}if(c.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}};function V(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`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 H={command:`upsert <id>`,describe:`Creates or updates an indexed item in an AI Search instance.`,builder:V,handler:async r=>{if(r.dryRun){o({command:`cf ai-search items upsert`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}/items`,pathParams:{id:String(r.id??``),name:String(r.name??``)},bodyKind:`json`,body:r.body===void 0?u({key:d(r.key,`key`,`text`),next_action:d(r[`next-action`],`next-action`,`text`),wait_for_completion:r[`wait-for-completion`]}):c(r.body)});return}let l=await i(r),f=r.local?e:await t();if(r.accountId=f,r.body){let e=c(r.body);a(await s(`Updating`,async()=>l.aiSearch.items.upsert({...e,account_id:f,name:r.name,id:r.id})),{successLabel:`Updated`});return}r.key===void 0&&(r.key=await p(`key`,`Item key / filename. Must not exceed 128 characters.`)),r[`next-action`]===void 0&&(r[`next-action`]=await m(`next-action`,`The next_action field`,[`INDEX`]));let h=u({key:d(r.key,`key`,`text`),next_action:d(r[`next-action`],`next-action`,`text`),wait_for_completion:r[`wait-for-completion`]});a(await s(`Updating`,async()=>l.aiSearch.items.upsert({...h,account_id:f,name:r.name,id:r.id})),{successLabel:`Updated`})}},U={command:`items`,describe:`Content indexed by AI Search instances`,builder:e=>e.command(E).command(O).command(A).command(M).command(P).command(I).command(R).command(B).command(H).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function W(e){return e.positional(`job-id`,{type:`string`,description:`Indexing job ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`action`,{type:`string`,description:`The action field`,choices:[`cancel`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const G={command:`cancel <job-id>`,describe:`Cancel an in-progress indexing job for an AI Search instance.`,builder:W,handler:async r=>{if(r.dryRun){o({command:`cf ai-search jobs cancel`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}/jobs/${r[`job-id`]==null?`<job-id>`:encodeURIComponent(String(r[`job-id`]))}`,pathParams:{id:String(r.id??``),"job-id":String(r[`job-id`]??``),name:String(r.name??``)},bodyKind:`json`,body:r.body===void 0?u({action:d(r.action,`action`,`text`)}):c(r.body)});return}let l=await i(r),f=r.local?e:await t();if(r.accountId=f,!await h({force:!!r.force,message:`This operation cancels the running indexing job.`})){process.stderr.write(`Aborted.
5
+ `);return}if(r.body){let e=c(r.body);a(await s(`Deleting`,async()=>l.aiSearch.jobs.cancel({...e,account_id:f,name:r.name,id:r.id,job_id:r[`job-id`]})),{successLabel:`Deleted`});return}r.action===void 0&&(r.action=await m(`action`,`The action field`,[`cancel`]));let p=u({action:d(r.action,`action`,`text`)});a(await s(`Deleting`,async()=>l.aiSearch.jobs.cancel({...p,account_id:f,name:r.name,id:r.id,job_id:r[`job-id`]})),{successLabel:`Deleted`})}};function K(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`description`,{type:`string`,description:`The description field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const q={command:`create <id>`,describe:`Creates a new indexing job for an AI Search instance.`,builder:K,handler:async r=>{if(r.dryRun){o({command:`cf ai-search jobs create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}/jobs`,pathParams:{id:String(r.id??``),name:String(r.name??``)},bodyKind:`json`,body:r.body===void 0?u({description:d(r.description,`description`,`text`)}):c(r.body)});return}let l=await i(r),f=r.local?e:await t();if(r.accountId=f,r.body){let e=c(r.body);a(await s(`Creating`,async()=>l.aiSearch.jobs.create({...e,account_id:f,name:r.name,id:r.id})),{successLabel:`Created`});return}let p=u({description:d(r.description,`description`,`text`)});a(await s(`Creating`,async()=>l.aiSearch.jobs.create({...p,account_id:f,name:r.name,id:r.id})),{successLabel:`Created`})}};function J(e){return e.positional(`job-id`,{type:`string`,description:`Indexing job ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Y={command:`get <job-id>`,describe:`Retrieves details for a specific AI Search indexing job.`,builder:J,handler:async r=>{if(r.dryRun){o({command:`cf ai-search jobs get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}/jobs/${r[`job-id`]==null?`<job-id>`:encodeURIComponent(String(r[`job-id`]))}`,pathParams:{id:String(r.id??``),"job-id":String(r[`job-id`]??``),name:String(r.name??``)},bodyKind:`none`});return}let c=await i(r),l=r.local?e:await t();r.accountId=l,a(await s(`Loading`,async()=>c.aiSearch.jobs.get({account_id:l,name:r.name,id:r.id,job_id:r[`job-id`]})),{successLabel:`Loaded`})}};function X(e){return e.option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`page`,{type:`number`,description:`Page`}).option(`per-page`,{type:`number`,description:`Per page`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Z={command:`list`,describe:`Lists indexing jobs for an AI Search instance.`,builder:X,handler:async r=>{let c={page:r.page,per_page:r[`per-page`]};if(r.dryRun){o({command:`cf ai-search jobs list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}/jobs`,pathParams:{id:String(r.id??``),name:String(r.name??``)},query:c,bodyKind:`none`});return}let l=await i(r),u=r.local?e:await t();r.accountId=u,a(await s(`Loading`,async()=>l.aiSearch.jobs.list({account_id:u,name:r.name,id:r.id,...c})),{successLabel:`Loaded`})}};function Q(e){return e.positional(`job-id`,{type:`string`,description:`Indexing job ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`page`,{type:`number`,description:`Page`}).option(`per-page`,{type:`number`,description:`Per page`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const ne={command:`logs <job-id>`,describe:`Lists log entries for an AI Search indexing job.`,builder:Q,handler:async r=>{let c={page:r.page,per_page:r[`per-page`]};if(r.dryRun){o({command:`cf ai-search jobs logs`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}/jobs/${r[`job-id`]==null?`<job-id>`:encodeURIComponent(String(r[`job-id`]))}/logs`,pathParams:{id:String(r.id??``),"job-id":String(r[`job-id`]??``),name:String(r.name??``)},query:c,bodyKind:`none`});return}let l=await i(r),u=r.local?e:await t();r.accountId=u,a(await s(`Loading`,async()=>l.aiSearch.jobs.logs({account_id:u,name:r.name,id:r.id,job_id:r[`job-id`],...c})),{successLabel:`Loaded`})}},re={command:`jobs`,describe:`Indexing job lifecycle for AI Search instances`,builder:e=>e.command(G).command(q).command(Y).command(Z).command(ne).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function ie(e){return e.option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`page`,{type:`number`,description:`Page number (1-indexed).`}).option(`per-page`,{type:`number`,description:`Number of results per page.`}).option(`search`,{type:`string`,description:`Filter instances whose id contains this string (case-insensitive).`}).option(`order-by`,{type:`string`,description:`Field to order results by.`,choices:[`created_at`]}).option(`order-by-direction`,{type:`string`,description:`Order direction.`,choices:[`asc`,`desc`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const ae={command:`list`,describe:`List all AI Search instances in the account.`,builder:g(ie),handler:async r=>{let c={page:r.page,per_page:r[`per-page`],search:r.search,order_by:r[`order-by`],order_by_direction:r[`order-by-direction`]};if(r.dryRun){o({command:`cf ai-search list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances`,pathParams:{name:String(r.name??``)},query:c,bodyKind:`none`});return}let l=await i(r),u=r.local?e:await t();r.accountId=u,a(await s(`Loading`,async()=>l.aiSearch.list({account_id:u,name:r.name,...c})),{successLabel:`Loaded`})}};function oe(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace currently containing the instance.`,demandOption:!0}).option(`destination-namespace`,{type:`string`,description:`Target namespace to move the instance into.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const se={command:`move <id>`,describe:`Moves an instance from its current namespace to the specified target namespace. Use 'default' with --destination-namespace to move the instance back to the default namespace. Fails with 400 if the target namespace already has an instance with the same id (ids must be unique within a namespace — the same id can exist in different namespaces).`,builder:oe,handler:async r=>{if(r.dryRun){o({command:`cf ai-search move`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}`,pathParams:{name:String(r.name??``),id:String(r.id??``)},bodyKind:`json`,body:r.body===void 0?u({new_namespace:d(r[`destination-namespace`],`destination-namespace`,`text`)}):c(r.body)});return}let l=await i(r),f=r.local?e:await t();if(r.accountId=f,r.body){let e=c(r.body);a(await s(`Updating`,async()=>l.aiSearch.move({...e,account_id:f,name:r.name,id:r.id})),{successLabel:`Updated`});return}r[`destination-namespace`]===void 0&&(r[`destination-namespace`]=await p(`destination-namespace`,`Target namespace to move the instance into.`));let m=u({new_namespace:d(r[`destination-namespace`],`destination-namespace`,`text`)});a(await s(`Updating`,async()=>l.aiSearch.move({...m,account_id:f,name:r.name,id:r.id})),{successLabel:`Updated`})}};function ce(e){return e.positional(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`ai-search-options-cache-cache-threshold`,{type:`string`,description:`The ai_search_options.cache.cache_threshold field`,choices:[`super_strict_match`,`close_enough`,`flexible_friend`,`anything_goes`]}).option(`ai-search-options-cache-enabled`,{type:`boolean`,description:`The ai_search_options.cache.enabled field`}).option(`ai-search-options-instance-ids`,{type:`string`,array:!0,description:`The ai_search_options.instance_ids field`}).option(`ai-search-options-query-rewrite-enabled`,{type:`boolean`,description:`The ai_search_options.query_rewrite.enabled field`}).option(`ai-search-options-query-rewrite-model`,{type:`string`,description:`A Workers AI model ID or an AI Gateway model ID compatible with the OpenAI Chat Completions API. An empty string uses the configured or default model.`}).option(`ai-search-options-query-rewrite-rewrite-prompt`,{type:`string`,description:`The ai_search_options.query_rewrite.rewrite_prompt field`}).option(`ai-search-options-reranking-enabled`,{type:`boolean`,description:`The ai_search_options.reranking.enabled field`}).option(`ai-search-options-reranking-match-threshold`,{type:`number`,description:`The ai_search_options.reranking.match_threshold field`,default:.4}).option(`ai-search-options-reranking-model`,{type:`string`,description:`The ai_search_options.reranking.model field`}).option(`ai-search-options-retrieval-context-expansion`,{type:`number`,description:`The ai_search_options.retrieval.context_expansion field`,default:0}).option(`ai-search-options-retrieval-fusion-method`,{type:`string`,description:`The ai_search_options.retrieval.fusion_method field`,choices:[`max`,`rrf`]}).option(`ai-search-options-retrieval-keyword-match-mode`,{type:`string`,description:`Controls which documents are candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term, ranked by BM25 relevance. When omitted, falls back to the instance-level retrieval_options.keyword_match_mode, then to 'and'.`,choices:[`and`,`or`]}).option(`ai-search-options-retrieval-match-threshold`,{type:`number`,description:`The ai_search_options.retrieval.match_threshold field`,default:.4}).option(`ai-search-options-retrieval-max-num-results`,{type:`number`,description:`The ai_search_options.retrieval.max_num_results field`,default:10}).option(`ai-search-options-retrieval-retrieval-type`,{type:`string`,description:`The ai_search_options.retrieval.retrieval_type field`,choices:[`vector`,`keyword`,`hybrid`]}).option(`ai-search-options-retrieval-return-on-failure`,{type:`boolean`,description:`The ai_search_options.retrieval.return_on_failure field`,default:!0}).option(`messages`,{type:`string`,description:`The messages field. Provide as a JSON array of objects or @path/to/file.json.`}).option(`model`,{type:`string`,description:`A Workers AI model ID or an AI Gateway model ID compatible with the OpenAI Chat Completions API. An empty string uses the configured or default model.`}).option(`stream`,{type:`boolean`,description:`The stream field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const le={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:ce,handler:async r=>{if(r.dryRun){o({command:`cf ai-search multi-chat-completions`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/chat/completions`,pathParams:{name:String(r.name??``)},bodyKind:`json`,body:r.body===void 0?u({ai_search_options:{cache:{cache_threshold:d(r[`ai-search-options-cache-cache-threshold`],`ai-search-options-cache-cache-threshold`,`text`),enabled:r[`ai-search-options-cache-enabled`]},instance_ids:r[`ai-search-options-instance-ids`],query_rewrite:{enabled:r[`ai-search-options-query-rewrite-enabled`],model:d(r[`ai-search-options-query-rewrite-model`],`ai-search-options-query-rewrite-model`,`text`),rewrite_prompt:d(r[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:r[`ai-search-options-reranking-enabled`],match_threshold:r[`ai-search-options-reranking-match-threshold`],model:d(r[`ai-search-options-reranking-model`],`ai-search-options-reranking-model`,`text`)},retrieval:{context_expansion:r[`ai-search-options-retrieval-context-expansion`],fusion_method:d(r[`ai-search-options-retrieval-fusion-method`],`ai-search-options-retrieval-fusion-method`,`text`),keyword_match_mode:d(r[`ai-search-options-retrieval-keyword-match-mode`],`ai-search-options-retrieval-keyword-match-mode`,`text`),match_threshold:r[`ai-search-options-retrieval-match-threshold`],max_num_results:r[`ai-search-options-retrieval-max-num-results`],retrieval_type:d(r[`ai-search-options-retrieval-retrieval-type`],`ai-search-options-retrieval-retrieval-type`,`text`),return_on_failure:r[`ai-search-options-retrieval-return-on-failure`]}},messages:l(r.messages,`messages`),model:d(r.model,`model`,`text`),stream:r.stream}):c(r.body)});return}let f=await i(r),p=r.local?e:await t();if(r.accountId=p,r.body){let e=c(r.body);a(await s(`Creating`,async()=>f.aiSearch.multiChatCompletions({...e,account_id:p,name:r.name})),{successLabel:`Created`});return}if(r[`ai-search-options-instance-ids`]===void 0)throw Error(`--ai-search-options-instance-ids is required (or pass --body with this field set).`);if(r.messages===void 0)throw Error(`--messages is required (or pass --body with this field set).`);let m=u({ai_search_options:{cache:{cache_threshold:d(r[`ai-search-options-cache-cache-threshold`],`ai-search-options-cache-cache-threshold`,`text`),enabled:r[`ai-search-options-cache-enabled`]},instance_ids:r[`ai-search-options-instance-ids`],query_rewrite:{enabled:r[`ai-search-options-query-rewrite-enabled`],model:d(r[`ai-search-options-query-rewrite-model`],`ai-search-options-query-rewrite-model`,`text`),rewrite_prompt:d(r[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:r[`ai-search-options-reranking-enabled`],match_threshold:r[`ai-search-options-reranking-match-threshold`],model:d(r[`ai-search-options-reranking-model`],`ai-search-options-reranking-model`,`text`)},retrieval:{context_expansion:r[`ai-search-options-retrieval-context-expansion`],fusion_method:d(r[`ai-search-options-retrieval-fusion-method`],`ai-search-options-retrieval-fusion-method`,`text`),keyword_match_mode:d(r[`ai-search-options-retrieval-keyword-match-mode`],`ai-search-options-retrieval-keyword-match-mode`,`text`),match_threshold:r[`ai-search-options-retrieval-match-threshold`],max_num_results:r[`ai-search-options-retrieval-max-num-results`],retrieval_type:d(r[`ai-search-options-retrieval-retrieval-type`],`ai-search-options-retrieval-retrieval-type`,`text`),return_on_failure:r[`ai-search-options-retrieval-return-on-failure`]}},messages:l(r.messages,`messages`),model:d(r.model,`model`,`text`),stream:r.stream});a(await s(`Creating`,async()=>f.aiSearch.multiChatCompletions({...m,account_id:p,name:r.name})),{successLabel:`Created`})}};function ue(e){return e.positional(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).positional(`query`,{type:`string`,description:`Text to search for.`}).option(`ai-search-options-cache-cache-threshold`,{type:`string`,description:`The ai_search_options.cache.cache_threshold field`,choices:[`super_strict_match`,`close_enough`,`flexible_friend`,`anything_goes`]}).option(`ai-search-options-cache-enabled`,{type:`boolean`,description:`The ai_search_options.cache.enabled field`}).option(`ai-search-options-instance-ids`,{type:`string`,array:!0,description:`The ai_search_options.instance_ids field`}).option(`ai-search-options-query-rewrite-enabled`,{type:`boolean`,description:`The ai_search_options.query_rewrite.enabled field`}).option(`ai-search-options-query-rewrite-model`,{type:`string`,description:`A Workers AI model ID or an AI Gateway model ID compatible with the OpenAI Chat Completions API. An empty string uses the configured or default model.`}).option(`ai-search-options-query-rewrite-rewrite-prompt`,{type:`string`,description:`The ai_search_options.query_rewrite.rewrite_prompt field`}).option(`ai-search-options-reranking-enabled`,{type:`boolean`,description:`The ai_search_options.reranking.enabled field`}).option(`ai-search-options-reranking-match-threshold`,{type:`number`,description:`The ai_search_options.reranking.match_threshold field`,default:.4}).option(`ai-search-options-reranking-model`,{type:`string`,description:`The ai_search_options.reranking.model field`}).option(`ai-search-options-retrieval-context-expansion`,{type:`number`,description:`The ai_search_options.retrieval.context_expansion field`,default:0}).option(`ai-search-options-retrieval-fusion-method`,{type:`string`,description:`The ai_search_options.retrieval.fusion_method field`,choices:[`max`,`rrf`]}).option(`ai-search-options-retrieval-keyword-match-mode`,{type:`string`,description:`Controls which documents are candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term, ranked by BM25 relevance. When omitted, falls back to the instance-level retrieval_options.keyword_match_mode, then to 'and'.`,choices:[`and`,`or`]}).option(`ai-search-options-retrieval-match-threshold`,{type:`number`,description:`The ai_search_options.retrieval.match_threshold field`,default:.4}).option(`ai-search-options-retrieval-max-num-results`,{type:`number`,description:`The ai_search_options.retrieval.max_num_results field`,default:10}).option(`ai-search-options-retrieval-retrieval-type`,{type:`string`,description:`The ai_search_options.retrieval.retrieval_type field`,choices:[`vector`,`keyword`,`hybrid`]}).option(`ai-search-options-retrieval-return-on-failure`,{type:`boolean`,description:`The ai_search_options.retrieval.return_on_failure field`,default:!0}).option(`messages`,{type:`string`,description:"OpenAI-compatible message array. For multimodal queries, set the last user message's `content` to an array of typed parts: `[{type:'text', text:'…'}, {type:'image_url', image_url:{url:'…'}}]`. Image inputs require the RAG's embedding_model to declare 'image' in supported_modalities. Provide as a JSON array of objects or @path/to/file.json."}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const de={command:`multi-search <name> <query>`,describe:`Performs a semantic search query against multiple AI Search instances in parallel, merging the retrieved results into a single ranked response.`,builder:ue,handler:async r=>{if(r.dryRun){o({command:`cf ai-search multi-search`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/search`,pathParams:{name:String(r.name??``)},bodyKind:`json`,body:r.body===void 0?u({ai_search_options:{cache:{cache_threshold:d(r[`ai-search-options-cache-cache-threshold`],`ai-search-options-cache-cache-threshold`,`text`),enabled:r[`ai-search-options-cache-enabled`]},instance_ids:r[`ai-search-options-instance-ids`],query_rewrite:{enabled:r[`ai-search-options-query-rewrite-enabled`],model:d(r[`ai-search-options-query-rewrite-model`],`ai-search-options-query-rewrite-model`,`text`),rewrite_prompt:d(r[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:r[`ai-search-options-reranking-enabled`],match_threshold:r[`ai-search-options-reranking-match-threshold`],model:d(r[`ai-search-options-reranking-model`],`ai-search-options-reranking-model`,`text`)},retrieval:{context_expansion:r[`ai-search-options-retrieval-context-expansion`],fusion_method:d(r[`ai-search-options-retrieval-fusion-method`],`ai-search-options-retrieval-fusion-method`,`text`),keyword_match_mode:d(r[`ai-search-options-retrieval-keyword-match-mode`],`ai-search-options-retrieval-keyword-match-mode`,`text`),match_threshold:r[`ai-search-options-retrieval-match-threshold`],max_num_results:r[`ai-search-options-retrieval-max-num-results`],retrieval_type:d(r[`ai-search-options-retrieval-retrieval-type`],`ai-search-options-retrieval-retrieval-type`,`text`),return_on_failure:r[`ai-search-options-retrieval-return-on-failure`]}},messages:l(r.messages,`messages`),query:r.query}):c(r.body)});return}let f=await i(r),p=r.local?e:await t();if(r.accountId=p,r.body){let e=c(r.body);a(await s(`Creating`,async()=>f.aiSearch.multiSearch({...e,account_id:p,name:r.name})),{successLabel:`Created`});return}if(r[`ai-search-options-instance-ids`]===void 0)throw Error(`--ai-search-options-instance-ids is required (or pass --body with this field set).`);let m=u({ai_search_options:{cache:{cache_threshold:d(r[`ai-search-options-cache-cache-threshold`],`ai-search-options-cache-cache-threshold`,`text`),enabled:r[`ai-search-options-cache-enabled`]},instance_ids:r[`ai-search-options-instance-ids`],query_rewrite:{enabled:r[`ai-search-options-query-rewrite-enabled`],model:d(r[`ai-search-options-query-rewrite-model`],`ai-search-options-query-rewrite-model`,`text`),rewrite_prompt:d(r[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:r[`ai-search-options-reranking-enabled`],match_threshold:r[`ai-search-options-reranking-match-threshold`],model:d(r[`ai-search-options-reranking-model`],`ai-search-options-reranking-model`,`text`)},retrieval:{context_expansion:r[`ai-search-options-retrieval-context-expansion`],fusion_method:d(r[`ai-search-options-retrieval-fusion-method`],`ai-search-options-retrieval-fusion-method`,`text`),keyword_match_mode:d(r[`ai-search-options-retrieval-keyword-match-mode`],`ai-search-options-retrieval-keyword-match-mode`,`text`),match_threshold:r[`ai-search-options-retrieval-match-threshold`],max_num_results:r[`ai-search-options-retrieval-max-num-results`],retrieval_type:d(r[`ai-search-options-retrieval-retrieval-type`],`ai-search-options-retrieval-retrieval-type`,`text`),return_on_failure:r[`ai-search-options-retrieval-return-on-failure`]}},messages:l(r.messages,`messages`),query:r.query});a(await s(`Creating`,async()=>f.aiSearch.multiSearch({...m,account_id:p,name:r.name})),{successLabel:`Created`})}};function fe(e){return e.positional(`namespace`,{type:`string`,description:`Name for the new namespace.`,demandOption:!0}).option(`description`,{type:`string`,description:`Optional description for the namespace. Max 256 characters.`}).option(`public-endpoint-params-authorized-hosts`,{type:`string`,array:!0,description:`The public_endpoint_params.authorized_hosts field`}).option(`public-endpoint-params-chat-completions-endpoint-disabled`,{type:`boolean`,description:`Disable chat completions endpoint for this public endpoint`}).option(`public-endpoint-params-custom-domains`,{type:`string`,array:!0,description:`Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged).`}).option(`public-endpoint-params-default-domain-enabled`,{type:`boolean`,description:`When false, the instance is reachable only via a registered custom domain and the default <public_endpoint_id>.search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true.`}).option(`public-endpoint-params-enabled`,{type:`boolean`,description:`The public_endpoint_params.enabled field`}).option(`public-endpoint-params-instances-allowed`,{type:`string`,array:!0,description:`Instance IDs exposed through the namespace public endpoint. Empty means nothing is searchable. Every ID must be an existing instance in this namespace, and the list cannot exceed the account's multi-instance search limit.`}).option(`public-endpoint-params-mcp-description`,{type:`string`,description:`The public_endpoint_params.mcp.description field`}).option(`public-endpoint-params-mcp-disabled`,{type:`boolean`,description:`Disable MCP endpoint for this public endpoint`}).option(`public-endpoint-params-rate-limit-period-ms`,{type:`number`,description:`The public_endpoint_params.rate_limit.period_ms field`}).option(`public-endpoint-params-rate-limit-requests`,{type:`number`,description:`The public_endpoint_params.rate_limit.requests field`}).option(`public-endpoint-params-rate-limit-technique`,{type:`string`,description:`The public_endpoint_params.rate_limit.technique field`,choices:[`fixed`,`sliding`]}).option(`public-endpoint-params-search-endpoint-disabled`,{type:`boolean`,description:`Disable search endpoint for this public endpoint`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const pe={command:`create <namespace>`,describe:`Create a namespace for organizing AI Search instances.`,builder:fe,handler:async r=>{if(r.dryRun){o({command:`cf ai-search namespace create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces`,pathParams:{},bodyKind:`json`,body:r.body===void 0?u({description:d(r.description,`description`,`text`),public_endpoint_params:{authorized_hosts:r[`public-endpoint-params-authorized-hosts`],chat_completions_endpoint:{disabled:r[`public-endpoint-params-chat-completions-endpoint-disabled`]},custom_domains:r[`public-endpoint-params-custom-domains`],default_domain_enabled:r[`public-endpoint-params-default-domain-enabled`],enabled:r[`public-endpoint-params-enabled`],instances_allowed:r[`public-endpoint-params-instances-allowed`],mcp:{description:d(r[`public-endpoint-params-mcp-description`],`public-endpoint-params-mcp-description`,`text`),disabled:r[`public-endpoint-params-mcp-disabled`]},rate_limit:{period_ms:r[`public-endpoint-params-rate-limit-period-ms`],requests:r[`public-endpoint-params-rate-limit-requests`],technique:d(r[`public-endpoint-params-rate-limit-technique`],`public-endpoint-params-rate-limit-technique`,`text`)},search_endpoint:{disabled:r[`public-endpoint-params-search-endpoint-disabled`]}},name:r.namespace}):c(r.body)});return}let l=await i(r),f=r.local?e:await t();if(r.accountId=f,r.body){let e=c(r.body);a(await s(`Creating`,async()=>l.aiSearch.namespace.create({...e,account_id:f})),{successLabel:`Created`});return}let p=u({description:d(r.description,`description`,`text`),public_endpoint_params:{authorized_hosts:r[`public-endpoint-params-authorized-hosts`],chat_completions_endpoint:{disabled:r[`public-endpoint-params-chat-completions-endpoint-disabled`]},custom_domains:r[`public-endpoint-params-custom-domains`],default_domain_enabled:r[`public-endpoint-params-default-domain-enabled`],enabled:r[`public-endpoint-params-enabled`],instances_allowed:r[`public-endpoint-params-instances-allowed`],mcp:{description:d(r[`public-endpoint-params-mcp-description`],`public-endpoint-params-mcp-description`,`text`),disabled:r[`public-endpoint-params-mcp-disabled`]},rate_limit:{period_ms:r[`public-endpoint-params-rate-limit-period-ms`],requests:r[`public-endpoint-params-rate-limit-requests`],technique:d(r[`public-endpoint-params-rate-limit-technique`],`public-endpoint-params-rate-limit-technique`,`text`)},search_endpoint:{disabled:r[`public-endpoint-params-search-endpoint-disabled`]}},name:r.namespace});a(await s(`Creating`,async()=>l.aiSearch.namespace.create({...p,account_id:f})),{successLabel:`Created`})}};function me(e){return e.positional(`name`,{type:`string`,description:`Namespace to delete.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const he={command:`delete <name>`,describe:`Permanently delete a namespace. The namespace must be empty (no instances), and the default namespace cannot be deleted.`,builder:me,handler:async r=>{if(r.dryRun){o({command:`cf ai-search namespace delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}`,pathParams:{name:String(r.name??``)},bodyKind:`none`});return}let c=await i(r),l=r.local?e:await t();if(r.accountId=l,!await h({force:!!r.force,message:`This operation permanently deletes the namespace.`})){process.stderr.write(`Aborted.
6
+ `);return}a(await s(`Deleting`,async()=>c.aiSearch.namespace.delete({account_id:l,name:r.name})),{successLabel:`Deleted`})}};function ge(e){return e.positional(`name`,{type:`string`,description:`Namespace to retrieve.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const _e={command:`get <name>`,describe:`Retrieve a namespace and its description.`,builder:ge,handler:async r=>{if(r.dryRun){o({command:`cf ai-search namespace get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}`,pathParams:{name:String(r.name??``)},bodyKind:`none`});return}let c=await i(r),l=r.local?e:await t();r.accountId=l,a(await s(`Loading`,async()=>c.aiSearch.namespace.get({account_id:l,name:r.name})),{successLabel:`Loaded`})}};function ve(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 ye={command:`list`,describe:`List namespaces in the account, including their descriptions and creation times.`,builder:ve,handler:async r=>{let c={page:r.page,per_page:r[`per-page`],search:r.search};if(r.dryRun){o({command:`cf ai-search namespace list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces`,pathParams:{},query:c,bodyKind:`none`});return}let l=await i(r),u=r.local?e:await t();r.accountId=u,a(await s(`Loading`,async()=>l.aiSearch.namespace.list({account_id:u,...c})),{successLabel:`Loaded`})}};function be(e){return e.positional(`name`,{type:`string`,description:`Namespace to update.`,demandOption:!0}).option(`description`,{type:`string`,description:`Optional description for the namespace. Max 256 characters.`}).option(`public-endpoint-params-authorized-hosts`,{type:`string`,array:!0,description:`The public_endpoint_params.authorized_hosts field`}).option(`public-endpoint-params-chat-completions-endpoint-disabled`,{type:`boolean`,description:`Disable chat completions endpoint for this public endpoint`}).option(`public-endpoint-params-custom-domains`,{type:`string`,array:!0,description:`Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged).`}).option(`public-endpoint-params-default-domain-enabled`,{type:`boolean`,description:`When false, the instance is reachable only via a registered custom domain and the default <public_endpoint_id>.search.ai.cloudflare.com host returns 404. Requires at least one custom domain. Defaults to true. public_endpoint_params is replaced wholesale on update, so resend default_domain_enabled on every update to keep the default host off — omitting it resets to true.`}).option(`public-endpoint-params-enabled`,{type:`boolean`,description:`The public_endpoint_params.enabled field`}).option(`public-endpoint-params-instances-allowed`,{type:`string`,array:!0,description:`Instance IDs exposed through the namespace public endpoint. Empty means nothing is searchable. Every ID must be an existing instance in this namespace, and the list cannot exceed the account's multi-instance search limit.`}).option(`public-endpoint-params-mcp-description`,{type:`string`,description:`The public_endpoint_params.mcp.description field`}).option(`public-endpoint-params-mcp-disabled`,{type:`boolean`,description:`Disable MCP endpoint for this public endpoint`}).option(`public-endpoint-params-rate-limit-period-ms`,{type:`number`,description:`The public_endpoint_params.rate_limit.period_ms field`}).option(`public-endpoint-params-rate-limit-requests`,{type:`number`,description:`The public_endpoint_params.rate_limit.requests field`}).option(`public-endpoint-params-rate-limit-technique`,{type:`string`,description:`The public_endpoint_params.rate_limit.technique field`,choices:[`fixed`,`sliding`]}).option(`public-endpoint-params-search-endpoint-disabled`,{type:`boolean`,description:`Disable search endpoint for this public endpoint`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const xe={command:`update <name>`,describe:`Update the description and/or the public endpoint configuration of an existing namespace. The default namespace's description cannot be modified, but its public endpoint can.`,builder:be,handler:async r=>{if(r.dryRun){o({command:`cf ai-search namespace update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}`,pathParams:{name:String(r.name??``)},bodyKind:`json`,body:r.body===void 0?u({description:d(r.description,`description`,`text`),public_endpoint_params:{authorized_hosts:r[`public-endpoint-params-authorized-hosts`],chat_completions_endpoint:{disabled:r[`public-endpoint-params-chat-completions-endpoint-disabled`]},custom_domains:r[`public-endpoint-params-custom-domains`],default_domain_enabled:r[`public-endpoint-params-default-domain-enabled`],enabled:r[`public-endpoint-params-enabled`],instances_allowed:r[`public-endpoint-params-instances-allowed`],mcp:{description:d(r[`public-endpoint-params-mcp-description`],`public-endpoint-params-mcp-description`,`text`),disabled:r[`public-endpoint-params-mcp-disabled`]},rate_limit:{period_ms:r[`public-endpoint-params-rate-limit-period-ms`],requests:r[`public-endpoint-params-rate-limit-requests`],technique:d(r[`public-endpoint-params-rate-limit-technique`],`public-endpoint-params-rate-limit-technique`,`text`)},search_endpoint:{disabled:r[`public-endpoint-params-search-endpoint-disabled`]}}}):c(r.body)});return}let l=await i(r),f=r.local?e:await t();if(r.accountId=f,r.body){let e=c(r.body);a(await s(`Updating`,async()=>l.aiSearch.namespace.update({...e,account_id:f,name:r.name})),{successLabel:`Updated`});return}let p=u({description:d(r.description,`description`,`text`),public_endpoint_params:{authorized_hosts:r[`public-endpoint-params-authorized-hosts`],chat_completions_endpoint:{disabled:r[`public-endpoint-params-chat-completions-endpoint-disabled`]},custom_domains:r[`public-endpoint-params-custom-domains`],default_domain_enabled:r[`public-endpoint-params-default-domain-enabled`],enabled:r[`public-endpoint-params-enabled`],instances_allowed:r[`public-endpoint-params-instances-allowed`],mcp:{description:d(r[`public-endpoint-params-mcp-description`],`public-endpoint-params-mcp-description`,`text`),disabled:r[`public-endpoint-params-mcp-disabled`]},rate_limit:{period_ms:r[`public-endpoint-params-rate-limit-period-ms`],requests:r[`public-endpoint-params-rate-limit-requests`],technique:d(r[`public-endpoint-params-rate-limit-technique`],`public-endpoint-params-rate-limit-technique`,`text`)},search_endpoint:{disabled:r[`public-endpoint-params-search-endpoint-disabled`]}}});a(await s(`Updating`,async()=>l.aiSearch.namespace.update({...p,account_id:f,name:r.name})),{successLabel:`Updated`})}},Se={command:`namespace`,describe:`Logical groupings for organizing AI Search instances`,builder:e=>e.command(pe).command(he).command(_e).command(ye).command(xe).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Ce(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const we={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:Ce,handler:async r=>{if(r.dryRun){o({command:`cf ai-search purge-cache`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}/purge_cache`,pathParams:{id:String(r.id??``),name:String(r.name??``)},bodyKind:`none`});return}let c=await i(r),l=r.local?e:await t();r.accountId=l,a(await s(`Creating`,async()=>c.aiSearch.purgeCache({account_id:l,name:r.name,id:r.id})),{successLabel:`Created`})}};function Te(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).positional(`query`,{type:`string`,description:`Text to search for.`}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`ai-search-options-cache-cache-threshold`,{type:`string`,description:`The ai_search_options.cache.cache_threshold field`,choices:[`super_strict_match`,`close_enough`,`flexible_friend`,`anything_goes`]}).option(`ai-search-options-cache-enabled`,{type:`boolean`,description:`The ai_search_options.cache.enabled field`}).option(`ai-search-options-query-rewrite-enabled`,{type:`boolean`,description:`The ai_search_options.query_rewrite.enabled field`}).option(`ai-search-options-query-rewrite-model`,{type:`string`,description:`A Workers AI model ID or an AI Gateway model ID compatible with the OpenAI Chat Completions API. An empty string uses the configured or default model.`}).option(`ai-search-options-query-rewrite-rewrite-prompt`,{type:`string`,description:`The ai_search_options.query_rewrite.rewrite_prompt field`}).option(`ai-search-options-reranking-enabled`,{type:`boolean`,description:`The ai_search_options.reranking.enabled field`}).option(`ai-search-options-reranking-match-threshold`,{type:`number`,description:`The ai_search_options.reranking.match_threshold field`}).option(`ai-search-options-reranking-model`,{type:`string`,description:`The ai_search_options.reranking.model field`}).option(`ai-search-options-retrieval-context-expansion`,{type:`number`,description:`The ai_search_options.retrieval.context_expansion field`}).option(`ai-search-options-retrieval-fusion-method`,{type:`string`,description:`The ai_search_options.retrieval.fusion_method field`,choices:[`max`,`rrf`]}).option(`ai-search-options-retrieval-keyword-match-mode`,{type:`string`,description:`Controls which documents are candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term, ranked by BM25 relevance. When omitted, falls back to the instance-level retrieval_options.keyword_match_mode, then to 'and'.`,choices:[`and`,`or`]}).option(`ai-search-options-retrieval-match-threshold`,{type:`number`,description:`The ai_search_options.retrieval.match_threshold field`}).option(`ai-search-options-retrieval-max-num-results`,{type:`number`,description:`The ai_search_options.retrieval.max_num_results field`}).option(`ai-search-options-retrieval-retrieval-type`,{type:`string`,description:`The ai_search_options.retrieval.retrieval_type field`,choices:[`vector`,`keyword`,`hybrid`]}).option(`ai-search-options-retrieval-return-on-failure`,{type:`boolean`,description:`The ai_search_options.retrieval.return_on_failure field`}).option(`messages`,{type:`string`,description:"OpenAI-compatible message array. For multimodal queries, set the last user message's `content` to an array of typed parts: `[{type:'text', text:'…'}, {type:'image_url', image_url:{url:'…'}}]`. Image inputs require the RAG's embedding_model to declare 'image' in supported_modalities. Provide as a JSON array of objects or @path/to/file.json."}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const Ee={command:`search <id> <query>`,describe:`Executes a semantic search query against an AI Search instance to find relevant indexed content.`,builder:Te,handler:async r=>{if(r.dryRun){o({command:`cf ai-search search`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}/search`,pathParams:{id:String(r.id??``),name:String(r.name??``)},bodyKind:`json`,body:r.body===void 0?u({ai_search_options:{cache:{cache_threshold:d(r[`ai-search-options-cache-cache-threshold`],`ai-search-options-cache-cache-threshold`,`text`),enabled:r[`ai-search-options-cache-enabled`]},query_rewrite:{enabled:r[`ai-search-options-query-rewrite-enabled`],model:d(r[`ai-search-options-query-rewrite-model`],`ai-search-options-query-rewrite-model`,`text`),rewrite_prompt:d(r[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:r[`ai-search-options-reranking-enabled`],match_threshold:r[`ai-search-options-reranking-match-threshold`],model:d(r[`ai-search-options-reranking-model`],`ai-search-options-reranking-model`,`text`)},retrieval:{context_expansion:r[`ai-search-options-retrieval-context-expansion`],fusion_method:d(r[`ai-search-options-retrieval-fusion-method`],`ai-search-options-retrieval-fusion-method`,`text`),keyword_match_mode:d(r[`ai-search-options-retrieval-keyword-match-mode`],`ai-search-options-retrieval-keyword-match-mode`,`text`),match_threshold:r[`ai-search-options-retrieval-match-threshold`],max_num_results:r[`ai-search-options-retrieval-max-num-results`],retrieval_type:d(r[`ai-search-options-retrieval-retrieval-type`],`ai-search-options-retrieval-retrieval-type`,`text`),return_on_failure:r[`ai-search-options-retrieval-return-on-failure`]}},messages:l(r.messages,`messages`),query:r.query}):c(r.body)});return}let f=await i(r),p=r.local?e:await t();if(r.accountId=p,r.body){let e=c(r.body);a(await s(`Loading`,async()=>f.aiSearch.search({...e,account_id:p,name:r.name,id:r.id})),{successLabel:`Loaded`});return}let m=u({ai_search_options:{cache:{cache_threshold:d(r[`ai-search-options-cache-cache-threshold`],`ai-search-options-cache-cache-threshold`,`text`),enabled:r[`ai-search-options-cache-enabled`]},query_rewrite:{enabled:r[`ai-search-options-query-rewrite-enabled`],model:d(r[`ai-search-options-query-rewrite-model`],`ai-search-options-query-rewrite-model`,`text`),rewrite_prompt:d(r[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:r[`ai-search-options-reranking-enabled`],match_threshold:r[`ai-search-options-reranking-match-threshold`],model:d(r[`ai-search-options-reranking-model`],`ai-search-options-reranking-model`,`text`)},retrieval:{context_expansion:r[`ai-search-options-retrieval-context-expansion`],fusion_method:d(r[`ai-search-options-retrieval-fusion-method`],`ai-search-options-retrieval-fusion-method`,`text`),keyword_match_mode:d(r[`ai-search-options-retrieval-keyword-match-mode`],`ai-search-options-retrieval-keyword-match-mode`,`text`),match_threshold:r[`ai-search-options-retrieval-match-threshold`],max_num_results:r[`ai-search-options-retrieval-max-num-results`],retrieval_type:d(r[`ai-search-options-retrieval-retrieval-type`],`ai-search-options-retrieval-retrieval-type`,`text`),return_on_failure:r[`ai-search-options-retrieval-return-on-failure`]}},messages:l(r.messages,`messages`),query:r.query});a(await s(`Loading`,async()=>f.aiSearch.search({...m,account_id:p,name:r.name,id:r.id})),{successLabel:`Loaded`})}};function De(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Oe={command:`stats <id>`,describe:`Retrieve usage and indexing statistics for an AI Search instance.`,builder:De,handler:async r=>{if(r.dryRun){o({command:`cf ai-search stats`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}/stats`,pathParams:{id:String(r.id??``),name:String(r.name??``)},bodyKind:`none`});return}let c=await i(r),l=r.local?e:await t();r.accountId=l,a(await s(`Loading`,async()=>c.aiSearch.stats({account_id:l,name:r.name,id:r.id})),{successLabel:`Loaded`})}};function ke(e){return e.positional(`name`,{type:`string`,description:`Human-readable name for the credential.`,demandOption:!0}).option(`api-token-id`,{type:`string`,description:`The cf_api_id field`}).option(`api-token`,{type:`string`,description:`The cf_api_key field`}).option(`legacy`,{type:`boolean`,description:`The legacy field`,default:!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 Ae={command:`create <name>`,describe:`Create a stored Cloudflare credential for an AI Search instance to access its data source.`,builder:ke,handler:async r=>{if(r.dryRun){o({command:`cf ai-search tokens create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/tokens`,pathParams:{},bodyKind:`json`,body:r.body===void 0?u({cf_api_id:d(r[`api-token-id`],`api-token-id`,`text`),cf_api_key:d(r[`api-token`],`api-token`,`text`),legacy:r.legacy,name:r.name}):c(r.body)});return}let l=await i(r),f=r.local?e:await t();if(r.accountId=f,r.body){let e=c(r.body);a(await s(`Creating`,async()=>l.aiSearch.tokens.create({...e,account_id:f})),{successLabel:`Created`});return}r[`api-token-id`]===void 0&&(r[`api-token-id`]=await p(`api-token-id`,`The cf_api_id field`)),r[`api-token`]===void 0&&(r[`api-token`]=await p(`api-token`,`The cf_api_key field`,{kind:`secret`}));let m=u({cf_api_id:d(r[`api-token-id`],`api-token-id`,`text`),cf_api_key:d(r[`api-token`],`api-token`,`text`),legacy:r.legacy,name:r.name});a(await s(`Creating`,async()=>l.aiSearch.tokens.create({...m,account_id:f})),{successLabel:`Created`})}};function je(e){return e.positional(`id`,{type:`string`,description:`Stored credential record 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 Me={command:`delete <id>`,describe:`Permanently delete a stored AI Search credential. Credentials in use by an instance cannot be deleted.`,builder:je,handler:async r=>{if(r.dryRun){o({command:`cf ai-search tokens delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/tokens/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}`,pathParams:{id:String(r.id??``)},bodyKind:`none`});return}let c=await i(r),l=r.local?e:await t();if(r.accountId=l,!await h({force:!!r.force,message:`This operation permanently deletes the stored credential.`})){process.stderr.write(`Aborted.
7
+ `);return}a(await s(`Deleting`,async()=>c.aiSearch.tokens.delete({account_id:l,id:r.id})),{successLabel:`Deleted`})}};function Ne(e){return e.positional(`id`,{type:`string`,description:`Stored credential record ID.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Pe={command:`get <id>`,describe:`Retrieve a stored AI Search credential without exposing its secret.`,builder:Ne,handler:async r=>{if(r.dryRun){o({command:`cf ai-search tokens get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/tokens/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}`,pathParams:{id:String(r.id??``)},bodyKind:`none`});return}let c=await i(r),l=r.local?e:await t();r.accountId=l,a(await s(`Loading`,async()=>c.aiSearch.tokens.get({account_id:l,id:r.id})),{successLabel:`Loaded`})}};function $(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 Fe={command:`list`,describe:`List stored AI Search credentials in the account without exposing their secrets.`,builder:$,handler:async r=>{let c={page:r.page,per_page:r[`per-page`],search:r.search};if(r.dryRun){o({command:`cf ai-search tokens list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/tokens`,pathParams:{},query:c,bodyKind:`none`});return}let l=await i(r),u=r.local?e:await t();r.accountId=u,a(await s(`Loading`,async()=>l.aiSearch.tokens.list({account_id:u,...c})),{successLabel:`Loaded`})}};function Ie(e){return e.positional(`id`,{type:`string`,description:`Stored credential record ID.`,demandOption:!0}).option(`api-token-id`,{type:`string`,description:`The cf_api_id field`}).option(`api-token`,{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 Le={command:`update <id>`,describe:`Replace a stored AI Search credential and invalidate cached credentials for instances that use it.`,builder:Ie,handler:async r=>{if(r.dryRun){o({command:`cf ai-search tokens update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/tokens/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}`,pathParams:{id:String(r.id??``)},bodyKind:`json`,body:r.body===void 0?u({cf_api_id:d(r[`api-token-id`],`api-token-id`,`text`),cf_api_key:d(r[`api-token`],`api-token`,`text`),legacy:r.legacy,name:d(r.name,`name`,`text`)}):c(r.body)});return}let l=await i(r),f=r.local?e:await t();if(r.accountId=f,r.body){let e=c(r.body);a(await s(`Updating`,async()=>l.aiSearch.tokens.update({...e,account_id:f,id:r.id})),{successLabel:`Updated`});return}r[`api-token-id`]===void 0&&(r[`api-token-id`]=await p(`api-token-id`,`The cf_api_id field`)),r[`api-token`]===void 0&&(r[`api-token`]=await p(`api-token`,`The cf_api_key field`,{kind:`secret`})),r.name===void 0&&(r.name=await p(`name`,`The name field`));let m=u({cf_api_id:d(r[`api-token-id`],`api-token-id`,`text`),cf_api_key:d(r[`api-token`],`api-token`,`text`),legacy:r.legacy,name:d(r.name,`name`,`text`)});a(await s(`Updating`,async()=>l.aiSearch.tokens.update({...m,account_id:f,id:r.id})),{successLabel:`Updated`})}},Re={command:`tokens`,describe:`Credentials used by AI Search instances`,builder:e=>e.command(Ae).command(Me).command(Pe).command(Fe).command(Le).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function ze(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace to use for this operation.`,demandOption:!0}).option(`ai-gateway-id`,{type:`string`,description:`The ai_gateway_id field`}).option(`ai-search-model`,{type:`string`,description:`A Workers AI model ID or an AI Gateway model ID compatible with the OpenAI Chat Completions API. An empty string uses the configured or default model.`}).option(`cache`,{type:`boolean`,description:`The cache field`}).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(`custom-metadata`,{type:`string`,description:`The custom_metadata field. Provide as a JSON array of objects or @path/to/file.json.`}).option(`embedding-model`,{type:`string`,description:`The embedding_model field`}).option(`fusion-method`,{type:`string`,description:`The fusion_method field`,choices:[`max`,`rrf`]}).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`}).option(`retrieval-options-keyword-match-mode`,{type:`string`,description:`Controls which documents are candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term, ranked by BM25 relevance. When omitted on an update, the existing stored value is preserved; when never set, search falls back to 'and'.`,choices:[`and`,`or`]}).option(`rewrite-model`,{type:`string`,description:`A Workers AI model ID or an AI Gateway model ID compatible with the OpenAI Chat Completions API. An empty string uses the configured or default model.`}).option(`rewrite-query`,{type:`boolean`,description:`The rewrite_query field`}).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). Most accounts are limited to 10 rules; contact support to raise it.`}).option(`source-params-include-items`,{type:`string`,array:!0,description:`List of path patterns to include. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /blog/** matches /blog/post and /blog/2024/post). Most accounts are limited to 10 rules; contact support to raise it.`}).option(`source-params-prefix`,{type:`string`,description:`The source_params.prefix field`}).option(`source-params-r2-jurisdiction`,{type:`string`,description:`The source_params.r2_jurisdiction field`}).option(`source-params-web-crawler-discover-options-depth`,{type:`number`,description:`Maximum link-follow depth from the seed URL.`}).option(`source-params-web-crawler-discover-options-include-external-links`,{type:`boolean`,description:"Follow links that point outside the source domain. Must stay `false` — discover crawls are restricted to the zone you own."}).option(`source-params-web-crawler-discover-options-include-subdomains`,{type:`boolean`,description:`Follow links to subdomains of the source host.`}).option(`source-params-web-crawler-discover-options-limit`,{type:`number`,description:`Maximum number of pages to crawl (1-100000).`}).option(`source-params-web-crawler-discover-options-max-age`,{type:`number`,description:`Maximum content age in seconds to accept (0–604800).`}).option(`source-params-web-crawler-discover-options-source`,{type:`string`,description:`Where the crawler looks for URLs: 'sitemaps' reads sitemap XML only, 'links' follows page links only, 'all' does both.`,choices:[`all`,`sitemaps`,`links`]}).option(`source-params-web-crawler-parse-options-include-images`,{type:`boolean`,description:`The source_params.web_crawler.parse_options.include_images field`}).option(`source-params-web-crawler-parse-options-specific-sitemaps`,{type:`string`,array:!0,description:`List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'.`}).option(`source-params-web-crawler-parse-options-use-browser-rendering`,{type:`boolean`,description:`The source_params.web_crawler.parse_options.use_browser_rendering field`}).option(`source-params-web-crawler-parse-type`,{type:`string`,description:`How URLs are discovered. 'sitemap' reads XML sitemaps; 'discover' follows links recursively and requires the source to be a Verified zone on this account.`,choices:[`sitemap`,`discover`]}).option(`summarization`,{type:`boolean`,description:`The summarization field`}).option(`summarization-model`,{type:`string`,description:`The summarization_model field`}).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 Be={command:`update <id>`,describe:`Update the configuration of an AI Search instance.`,builder:ze,handler:async r=>{if(r.dryRun){o({command:`cf ai-search update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${await n()??`<account-id>`}/ai-search/namespaces/${r.name==null?`<name>`:encodeURIComponent(String(r.name))}/instances/${r.id==null?`<id>`:encodeURIComponent(String(r.id))}`,pathParams:{id:String(r.id??``),name:String(r.name??``)},bodyKind:`json`,body:r.body===void 0?u({ai_gateway_id:d(r[`ai-gateway-id`],`ai-gateway-id`,`text`),ai_search_model:d(r[`ai-search-model`],`ai-search-model`,`text`),cache:r.cache,cache_threshold:d(r[`cache-threshold`],`cache-threshold`,`text`),chunk:r.chunk,chunk_overlap:r[`chunk-overlap`],chunk_size:r[`chunk-size`],custom_metadata:l(r[`custom-metadata`],`custom-metadata`),embedding_model:d(r[`embedding-model`],`embedding-model`,`text`),fusion_method:d(r[`fusion-method`],`fusion-method`,`text`),index_method:{keyword:r[`index-method-keyword`],vector:r[`index-method-vector`]},indexing_options:{keyword_tokenizer:d(r[`indexing-options-keyword-tokenizer`],`indexing-options-keyword-tokenizer`,`text`)},max_num_results:r[`max-num-results`],metadata:{created_from_aisearch_wizard:r[`metadata-created-from-aisearch-wizard`],worker_domain:d(r[`metadata-worker-domain`],`metadata-worker-domain`,`text`)},paused:r.paused,public_endpoint_params:{authorized_hosts:r[`public-endpoint-params-authorized-hosts`],chat_completions_endpoint:{disabled:r[`public-endpoint-params-chat-completions-endpoint-disabled`]},custom_domains:r[`public-endpoint-params-custom-domains`],default_domain_enabled:r[`public-endpoint-params-default-domain-enabled`],enabled:r[`public-endpoint-params-enabled`],mcp:{description:d(r[`public-endpoint-params-mcp-description`],`public-endpoint-params-mcp-description`,`text`),disabled:r[`public-endpoint-params-mcp-disabled`]},rate_limit:{period_ms:r[`public-endpoint-params-rate-limit-period-ms`],requests:r[`public-endpoint-params-rate-limit-requests`],technique:d(r[`public-endpoint-params-rate-limit-technique`],`public-endpoint-params-rate-limit-technique`,`text`)},search_endpoint:{disabled:r[`public-endpoint-params-search-endpoint-disabled`]}},reranking:r.reranking,reranking_model:d(r[`reranking-model`],`reranking-model`,`text`),retrieval_options:{keyword_match_mode:d(r[`retrieval-options-keyword-match-mode`],`retrieval-options-keyword-match-mode`,`text`)},rewrite_model:d(r[`rewrite-model`],`rewrite-model`,`text`),rewrite_query:r[`rewrite-query`],score_threshold:r[`score-threshold`],source:d(r.source,`source`,`text`),source_params:{exclude_items:r[`source-params-exclude-items`],include_items:r[`source-params-include-items`],prefix:d(r[`source-params-prefix`],`source-params-prefix`,`text`),r2_jurisdiction:d(r[`source-params-r2-jurisdiction`],`source-params-r2-jurisdiction`,`text`),web_crawler:{discover_options:{depth:r[`source-params-web-crawler-discover-options-depth`],include_external_links:r[`source-params-web-crawler-discover-options-include-external-links`],include_subdomains:r[`source-params-web-crawler-discover-options-include-subdomains`],limit:r[`source-params-web-crawler-discover-options-limit`],max_age:r[`source-params-web-crawler-discover-options-max-age`],source:d(r[`source-params-web-crawler-discover-options-source`],`source-params-web-crawler-discover-options-source`,`text`)},parse_options:{include_images:r[`source-params-web-crawler-parse-options-include-images`],specific_sitemaps:r[`source-params-web-crawler-parse-options-specific-sitemaps`],use_browser_rendering:r[`source-params-web-crawler-parse-options-use-browser-rendering`]},parse_type:d(r[`source-params-web-crawler-parse-type`],`source-params-web-crawler-parse-type`,`text`)}},summarization:r.summarization,summarization_model:d(r[`summarization-model`],`summarization-model`,`text`),system_prompt_ai_search:d(r[`system-prompt-ai-search`],`system-prompt-ai-search`,`text`),system_prompt_index_summarization:d(r[`system-prompt-index-summarization`],`system-prompt-index-summarization`,`text`),system_prompt_rewrite_query:d(r[`system-prompt-rewrite-query`],`system-prompt-rewrite-query`,`text`),token_id:d(r[`token-id`],`token-id`,`text`)}):c(r.body)});return}let f=await i(r),p=r.local?e:await t();if(r.accountId=p,r.body){let e=c(r.body);a(await s(`Updating`,async()=>f.aiSearch.update({...e,account_id:p,name:r.name,id:r.id})),{successLabel:`Updated`});return}let m=u({ai_gateway_id:d(r[`ai-gateway-id`],`ai-gateway-id`,`text`),ai_search_model:d(r[`ai-search-model`],`ai-search-model`,`text`),cache:r.cache,cache_threshold:d(r[`cache-threshold`],`cache-threshold`,`text`),chunk:r.chunk,chunk_overlap:r[`chunk-overlap`],chunk_size:r[`chunk-size`],custom_metadata:l(r[`custom-metadata`],`custom-metadata`),embedding_model:d(r[`embedding-model`],`embedding-model`,`text`),fusion_method:d(r[`fusion-method`],`fusion-method`,`text`),index_method:{keyword:r[`index-method-keyword`],vector:r[`index-method-vector`]},indexing_options:{keyword_tokenizer:d(r[`indexing-options-keyword-tokenizer`],`indexing-options-keyword-tokenizer`,`text`)},max_num_results:r[`max-num-results`],metadata:{created_from_aisearch_wizard:r[`metadata-created-from-aisearch-wizard`],worker_domain:d(r[`metadata-worker-domain`],`metadata-worker-domain`,`text`)},paused:r.paused,public_endpoint_params:{authorized_hosts:r[`public-endpoint-params-authorized-hosts`],chat_completions_endpoint:{disabled:r[`public-endpoint-params-chat-completions-endpoint-disabled`]},custom_domains:r[`public-endpoint-params-custom-domains`],default_domain_enabled:r[`public-endpoint-params-default-domain-enabled`],enabled:r[`public-endpoint-params-enabled`],mcp:{description:d(r[`public-endpoint-params-mcp-description`],`public-endpoint-params-mcp-description`,`text`),disabled:r[`public-endpoint-params-mcp-disabled`]},rate_limit:{period_ms:r[`public-endpoint-params-rate-limit-period-ms`],requests:r[`public-endpoint-params-rate-limit-requests`],technique:d(r[`public-endpoint-params-rate-limit-technique`],`public-endpoint-params-rate-limit-technique`,`text`)},search_endpoint:{disabled:r[`public-endpoint-params-search-endpoint-disabled`]}},reranking:r.reranking,reranking_model:d(r[`reranking-model`],`reranking-model`,`text`),retrieval_options:{keyword_match_mode:d(r[`retrieval-options-keyword-match-mode`],`retrieval-options-keyword-match-mode`,`text`)},rewrite_model:d(r[`rewrite-model`],`rewrite-model`,`text`),rewrite_query:r[`rewrite-query`],score_threshold:r[`score-threshold`],source:d(r.source,`source`,`text`),source_params:{exclude_items:r[`source-params-exclude-items`],include_items:r[`source-params-include-items`],prefix:d(r[`source-params-prefix`],`source-params-prefix`,`text`),r2_jurisdiction:d(r[`source-params-r2-jurisdiction`],`source-params-r2-jurisdiction`,`text`),web_crawler:{discover_options:{depth:r[`source-params-web-crawler-discover-options-depth`],include_external_links:r[`source-params-web-crawler-discover-options-include-external-links`],include_subdomains:r[`source-params-web-crawler-discover-options-include-subdomains`],limit:r[`source-params-web-crawler-discover-options-limit`],max_age:r[`source-params-web-crawler-discover-options-max-age`],source:d(r[`source-params-web-crawler-discover-options-source`],`source-params-web-crawler-discover-options-source`,`text`)},parse_options:{include_images:r[`source-params-web-crawler-parse-options-include-images`],specific_sitemaps:r[`source-params-web-crawler-parse-options-specific-sitemaps`],use_browser_rendering:r[`source-params-web-crawler-parse-options-use-browser-rendering`]},parse_type:d(r[`source-params-web-crawler-parse-type`],`source-params-web-crawler-parse-type`,`text`)}},summarization:r.summarization,summarization_model:d(r[`summarization-model`],`summarization-model`,`text`),system_prompt_ai_search:d(r[`system-prompt-ai-search`],`system-prompt-ai-search`,`text`),system_prompt_index_summarization:d(r[`system-prompt-index-summarization`],`system-prompt-index-summarization`,`text`),system_prompt_rewrite_query:d(r[`system-prompt-rewrite-query`],`system-prompt-rewrite-query`,`text`),token_id:d(r[`token-id`],`token-id`,`text`)});a(await s(`Updating`,async()=>f.aiSearch.update({...m,account_id:p,name:r.name,id:r.id})),{successLabel:`Updated`})}},Ve={command:`ai-search`,describe:`Managed search-as-a-service: crawl, index, and query content with AI-powered relevance and chat completions`,builder:e=>e.command(v).command(b).command(S).command(w).command(ae).command(se).command(le).command(de).command(we).command(Ee).command(Oe).command(Be).command(U).command(re).command(Se).command(Re).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{Ve as default};
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ import{h as e}from"./oauth-DAa7SwkM.mjs";import{r as t}from"./auth-DY_Y2bXC.mjs";import{t as n}from"./output-BqDR9h74.mjs";import{t as r}from"./dry-run-ILZRVpnp.mjs";import{t as i}from"./progress-jYW64HY7.mjs";import{n as a,r as o,t as s}from"./body-parser-BGVbwPeM.mjs";import{n as c}from"./prompt-CyATfGUu.mjs";function l(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const u={command:`get`,describe:"Get the custom topic categories defined for the zone. While AI Security for Apps is enabled, it scores every incoming prompt against these topics and writes the scores to the `cf.llm.prompt.custom_topic_categories` field, keyed by topic label. Topics can be configured while the detection is disabled, but no prompt is scored until you enable it.",builder:l,handler:async a=>{if(a.dryRun){r({command:`cf ai-security custom-topics get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${a.zone??a.zoneId??`<zone>`}/ai-security/custom-topics`,pathParams:{"zone-id":String(a.zone??a[`zone-id`]??``)},bodyKind:`none`});return}let o=await t(a),s=await e({zone:a.zone},o,{quiet:a.quiet});a.zoneId=s,n(await i(`Loading`,async()=>o.aiSecurity.customTopics.get({zone_id:s})),{successLabel:`Loaded`})}};function d(e){return e.option(`topics`,{type:`string`,description:`Custom topic categories for AI Security for Apps content detection. Provide as a JSON array of objects or @path/to/file.json.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const f={command:`update`,describe:"Update the custom topic list of the zone, overwriting it entirely with the topics in the request, so include every topic you want to keep. Changes can take up to a minute to propagate. Each entry has a `label`, used to reference the topic in rule expressions and analytics, and a `topic` description, which the classifier scores prompts against while AI Security for Apps is enabled. The following rules apply: - A zone can hold at most 20 topics. - `label` must be 2–20 characters, using only lowercase letters (a–z), digits (0–9), and hyphens. - `topic` must be 2–50 printable ASCII characters. - Labels must be unique within the zone, and so must topic descriptions.",builder:d,handler:async l=>{if(l.dryRun){r({command:`cf ai-security custom-topics update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${l.zone??l.zoneId??`<zone>`}/ai-security/custom-topics`,pathParams:{"zone-id":String(l.zone??l[`zone-id`]??``)},bodyKind:`json`,body:l.body===void 0?s({topics:o(l.topics,`topics`)}):a(l.body)});return}let u=await t(l),d=await e({zone:l.zone},u,{quiet:l.quiet});if(l.zoneId=d,!await c({force:!!l.force,message:`This operation overwrites the AI Security for Apps custom topics for a zone.`})){process.stderr.write(`Aborted.
3
+ `);return}if(l.body){let e=a(l.body);n(await i(`Deleting`,async()=>u.aiSecurity.customTopics.update({body:e,zone_id:d})),{successLabel:`Deleted`});return}let f=s({topics:o(l.topics,`topics`)});n(await i(`Deleting`,async()=>u.aiSecurity.customTopics.update({body:f,zone_id:d})),{successLabel:`Deleted`})}},p={command:`custom-topics`,describe:`Organization-specific topic categories used by AI Security for Apps content detection`,builder:e=>e.command(u).command(f).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function m(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const h={command:`get`,describe:"Get the current AI Security for Apps status for the zone. While enabled, Cloudflare scans prompts sent to endpoints labeled `cf-llm` for personally identifiable information, unsafe topics, and prompt injection attempts.",builder:m,handler:async a=>{if(a.dryRun){r({command:`cf ai-security get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${a.zone??a.zoneId??`<zone>`}/ai-security/settings`,pathParams:{"zone-id":String(a.zone??a[`zone-id`]??``)},bodyKind:`none`});return}let o=await t(a),s=await e({zone:a.zone},o,{quiet:a.quiet});a.zoneId=s,n(await i(`Loading`,async()=>o.aiSecurity.get({zone_id:s})),{successLabel:`Loaded`})}};function g(e){return e.option(`enabled`,{type:`boolean`,description:`Whether AI Security for Apps is enabled on the zone.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1}).option(`body`,{type:`string`,description:`AI Security for Apps enablement status for a zone.`})}const _={command:`update`,describe:"Update the AI Security for Apps status for the zone, enabling or disabling the detection. The detection results are exposed as `cf.llm.prompt.*` fields for use in custom rules and rate limiting rules; changes can take up to a minute to propagate.",builder:g,handler:async o=>{if(o.dryRun){r({command:`cf ai-security update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/zones/${o.zone??o.zoneId??`<zone>`}/ai-security/settings`,pathParams:{"zone-id":String(o.zone??o[`zone-id`]??``)},bodyKind:`json`,body:o.body===void 0?s({enabled:o.enabled}):a(o.body)});return}let l=await t(o),u=await e({zone:o.zone},l,{quiet:o.quiet});if(o.zoneId=u,!await c({force:!!o.force,message:`This operation toggles AI Security for Apps for a zone.`})){process.stderr.write(`Aborted.
4
+ `);return}if(o.body){let e=a(o.body);n(await i(`Deleting`,async()=>l.aiSecurity.update({body:e,zone_id:u})),{successLabel:`Deleted`});return}let d=s({enabled:o.enabled});n(await i(`Deleting`,async()=>l.aiSecurity.update({body:d,zone_id:u})),{successLabel:`Deleted`})}},v={command:`ai-security`,describe:`Detect prompt injection, PII, and unsafe topics in traffic to your AI applications`,builder:e=>e.command(h).command(_).command(p).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{v as default};