cf 0.3.0 → 0.5.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 (228) hide show
  1. package/README.md +7 -1
  2. package/dist/_meta/agent-context.json +26 -21
  3. package/dist/_meta/commands.json +7696 -18100
  4. package/dist/_meta/schemas.json +6411 -13925
  5. package/dist/{abuse-reports-dMIfUJ8v.mjs → abuse-reports-Ina5TlsU.mjs} +2 -2
  6. package/dist/{accounts-Kx1epdA1.mjs → accounts-B_joQcMi.mjs} +9 -9
  7. package/dist/{acm-Utu252kC.mjs → acm-_kIHqYME.mjs} +2 -2
  8. package/dist/{addressing-CBq7Z7Vq.mjs → addressing-CaFlw8y1.mjs} +10 -10
  9. package/dist/{agent-context-BGTU299M.mjs → agent-context-DMPfi54f.mjs} +1 -1
  10. package/dist/ai-CqnhNb_c.mjs +2 -0
  11. package/dist/ai-gateway-pgYGI519.mjs +8 -0
  12. package/dist/ai-search-eqQMPQol.mjs +7 -0
  13. package/dist/ai_gateway--vuVLnOm.mjs +4 -0
  14. package/dist/{alerting-CqmEIaKn.mjs → alerting-CPxHiYHb.mjs} +5 -5
  15. package/dist/{analytics-Dv-X8x7D.mjs → analytics-DSSRDZz8.mjs} +1 -1
  16. package/dist/analytics_engine-gWyfnsCs.mjs +2 -0
  17. package/dist/{api-gateway-CNv0IHTU.mjs → api-gateway-BXXGFCVR.mjs} +10 -10
  18. package/dist/argo-aC6A3JyX.mjs +2 -0
  19. package/dist/artifacts-HD4V2xpK.mjs +4 -0
  20. package/dist/audit-logs-BuExU_nz.mjs +2 -0
  21. package/dist/auth-CSC4yhEJ.mjs +9 -0
  22. package/dist/auth-D5hNsOFq.mjs +5 -0
  23. package/dist/billing-COaghyxl.mjs +2 -0
  24. package/dist/bot-management-DmEzeV1Y.mjs +5 -0
  25. package/dist/botnet-feed-ByEAXAkw.mjs +3 -0
  26. package/dist/brand-protection-dPrGe8sL.mjs +3 -0
  27. package/dist/browser-rendering-BiSGnpBf.mjs +4 -0
  28. package/dist/{build-DYkGW4dh.mjs → build-HuS9-R0V.mjs} +131 -131
  29. package/dist/{cache-DsoW6Xwv.mjs → cache-CY-7Lt71.mjs} +4 -4
  30. package/dist/calls-wOQGDWPl.mjs +4 -0
  31. package/dist/certificate-authorities-CtqzAtxQ.mjs +2 -0
  32. package/dist/chunk-6IEM75FG-BEjRFMGh.mjs +2 -0
  33. package/dist/client-certificates-CRf41xLe.mjs +3 -0
  34. package/dist/cloud-connector-BA5IRZUP.mjs +2 -0
  35. package/dist/{cloudforce-one-2Bhz8YdW.mjs → cloudforce-one-Bq_qPAWs.mjs} +20 -20
  36. package/dist/{completions-BwRpZQVn.mjs → completions-DOeHPdCG.mjs} +2 -2
  37. package/dist/config-B5k-XbwS.mjs +2 -0
  38. package/dist/connectivity-Bx3MgTHX.mjs +3 -0
  39. package/dist/connector-interrupts-D7ylweJZ.mjs +2 -0
  40. package/dist/connector-telemetry-events-6izV1kbP.mjs +2 -0
  41. package/dist/connector-telemetry-snapshots-BnjKbyxX.mjs +2 -0
  42. package/dist/connectors-DRt4e6d_.mjs +3 -0
  43. package/dist/content-scanning-Cd2vy5Sz.mjs +4 -0
  44. package/dist/context-jpewmual.mjs +2 -0
  45. package/dist/{custom-certificates-aAiEguR7.mjs → custom-certificates-DYE-9epx.mjs} +3 -3
  46. package/dist/{custom-hostnames-AG5yBHIi.mjs → custom-hostnames-CtuTdFcX.mjs} +4 -4
  47. package/dist/custom-nameservers-CWqA51in.mjs +3 -0
  48. package/dist/custom-pages-DeUKEFGe.mjs +4 -0
  49. package/dist/d1-DvWY9Gp4.mjs +4 -0
  50. package/dist/data-security-BPo6dIWu.mjs +6 -0
  51. package/dist/dcv-delegation-Bgf86J-r.mjs +2 -0
  52. package/dist/{deploy-CQial3kN.mjs → deploy-dVrgDUOp.mjs} +1 -1
  53. package/dist/{dev-B38LfCTl.mjs → dev-C01_Lby6.mjs} +1 -1
  54. package/dist/diagnostics-6nKPmVgz.mjs +3 -0
  55. package/dist/{dispatch-namespaces-DmHvoBOg.mjs → dispatch-namespaces-64lXx2WJ.mjs} +6 -6
  56. package/dist/dist-C6zxsVdY.mjs +306 -0
  57. package/dist/{dist-AIcZFk0U.mjs → dist-t_YrL25p.mjs} +7 -7
  58. package/dist/{dns-VMhQSr5n.mjs → dns-ClciFGxx.mjs} +13 -13
  59. package/dist/dns-firewall-DfUmXDCe.mjs +57 -0
  60. package/dist/durable-objects-CMaYZ-YU.mjs +2 -0
  61. package/dist/{email-routing-tIR2SFu-.mjs → email-routing-CGXhFqF5.mjs} +9 -9
  62. package/dist/{email-security-Ca1id3rZ.mjs → email-security-D5viPq8S.mjs} +7 -7
  63. package/dist/email-sending-C2jpc3gh.mjs +3 -0
  64. package/dist/{filters-A4dg_a68.mjs → filters-bzsFcWt0.mjs} +3 -3
  65. package/dist/{firewall-DWPQgYd9.mjs → firewall-DYZcTtIC.mjs} +10 -10
  66. package/dist/{fraud-BMkSsJGU.mjs → fraud-C03MtdZb.mjs} +1 -1
  67. package/dist/google-tag-gateway-Dfy887yA.mjs +2 -0
  68. package/dist/{healthchecks-CtIfrFql.mjs → healthchecks-DRoAlWgr.mjs} +3 -3
  69. package/dist/hostnames-CFgIVI3s.mjs +3 -0
  70. package/dist/hyperdrive-C7-gwTSV.mjs +18 -0
  71. package/dist/iam-DqVPzGrb.mjs +6 -0
  72. package/dist/images-BYfl4YgR.mjs +7 -0
  73. package/dist/index.mjs +1 -1
  74. package/dist/intel-duTEPIHc.mjs +3 -0
  75. package/dist/{ips-K4bzaGqd.mjs → ips-nv9INuWZ.mjs} +1 -1
  76. package/dist/keyless-certificates-CRCDVd3g.mjs +3 -0
  77. package/dist/{kv-8o27w_pY.mjs → kv-CZoV4tiv.mjs} +4 -4
  78. package/dist/leaked-credential-checks-DNIBg7Pe.mjs +3 -0
  79. package/dist/{load-balancers-DtG8nj25.mjs → load-balancers--OMg0HNt.mjs} +5 -5
  80. package/dist/{logpush-4L0njy1d.mjs → logpush-C0_lZTyY.mjs} +3 -3
  81. package/dist/{logs-B_Yp95hv.mjs → logs-BtpWZQfV.mjs} +2 -2
  82. package/dist/magic-cloud-networking-u6rwYbGg.mjs +5 -0
  83. package/dist/{magic-network-monitoring-BnwvM4-I.mjs → magic-network-monitoring-CKgQyRj4.mjs} +3 -3
  84. package/dist/{magic-transit-CXDyvhxq.mjs → magic-transit-CLhMcJ_-.mjs} +32 -33
  85. package/dist/managed-transforms-D0Z2mlth.mjs +3 -0
  86. package/dist/mtls-certificates-BL65NK5T.mjs +3 -0
  87. package/dist/{network-interconnects-rrr7red3.mjs → network-interconnects-Bgu9gmaG.mjs} +5 -5
  88. package/dist/oauth-Bk-F-tIO.mjs +52 -0
  89. package/dist/{observability-DWvpqnQJ.mjs → observability-BynRbTF4.mjs} +3 -3
  90. package/dist/open-YWOUIZ5Y-3jqSKAB1.mjs +4 -0
  91. package/dist/{organizations-T77D50Sq.mjs → organizations-BqJHyvMK.mjs} +3 -3
  92. package/dist/origin-ca-certificates-BGvYwm3C.mjs +3 -0
  93. package/dist/origin-post-quantum-encryption-9KOE8YPI.mjs +2 -0
  94. package/dist/{origin-tls-client-auth-CaVW1Ztp.mjs → origin-tls-client-auth-d3snC3vr.mjs} +3 -3
  95. package/dist/{output-BJFNwj7b.mjs → output-B6fBFRqe.mjs} +1 -1
  96. package/dist/{page-rules-CjZPTMQX.mjs → page-rules-EZHJePmn.mjs} +4 -4
  97. package/dist/{page-shield-D5RRNJCY.mjs → page-shield-CXJioWPs.mjs} +5 -5
  98. package/dist/{pages-CWJtJnL0.mjs → pages-D4aYteKk.mjs} +8 -8
  99. package/dist/{pipelines-B0L_7j9e.mjs → pipelines-G8Iusxq-.mjs} +5 -5
  100. package/dist/progress-DrDErV9w.mjs +2 -0
  101. package/dist/queues-DEkbKqZX.mjs +6 -0
  102. package/dist/{r2-DQIcyRtA.mjs → r2-CV0IkCAW.mjs} +9 -9
  103. package/dist/r2-data-catalog-NtqGC_a_.mjs +14 -0
  104. package/dist/radar-D986zPJr.mjs +2 -0
  105. package/dist/{rate-limits-DcrQV6Ar.mjs → rate-limits-B2wRsUX1.mjs} +3 -3
  106. package/dist/raw-fetch-_n0lMAnD.mjs +2 -0
  107. package/dist/{realtime-kit-CaquuVOE.mjs → realtime-kit-Ld3c5eU6.mjs} +9 -9
  108. package/dist/{registrar-Ko-xZemf.mjs → registrar-CDIwTz3G.mjs} +6 -6
  109. package/dist/request-tracers-D7SFMDik.mjs +2 -0
  110. package/dist/resource-sharing-YIQ04jXE.mjs +5 -0
  111. package/dist/{resource-tagging-C3qtLzCz.mjs → resource-tagging-Bd6Y03sg.mjs} +7 -7
  112. package/dist/rules-DHjLP5Kx.mjs +4 -0
  113. package/dist/{rulesets-CBgpeSvJ.mjs → rulesets-q4QABpKs.mjs} +7 -7
  114. package/dist/rum-SmT4HZmM.mjs +4 -0
  115. package/dist/{schema-D16TgWBg.mjs → schema-BR31o4P6.mjs} +1 -1
  116. package/dist/{schema-validation-Dgv_opM3.mjs → schema-validation-vVetgC_P.mjs} +5 -5
  117. package/dist/{scim-DdSEr4kZ.mjs → scim-ChOkZpNx.mjs} +2 -2
  118. package/dist/{session-COHHdS7A.mjs → sdk-DhIhH6GB.mjs} +4 -4
  119. package/dist/{secrets-store-7BfyvJLb.mjs → secrets-store-BAK9G12O.mjs} +12 -12
  120. package/dist/security-center-eScuYDKP.mjs +2 -0
  121. package/dist/security-txt-x7R4gmQu.mjs +3 -0
  122. package/dist/session-DHYCE-PM.mjs +93 -0
  123. package/dist/shared-BAjo72Lz.mjs +2 -0
  124. package/dist/{smart-shield-TeWZFnH2.mjs → smart-shield-CWlSsNi8.mjs} +2 -2
  125. package/dist/snippets-DrlgYJYp.mjs +4 -0
  126. package/dist/{spawn-DcppKGI5.mjs → spawn-CCGzKlC4.mjs} +1 -1
  127. package/dist/{spectrum-CTTZID8u.mjs → spectrum-pVGxb7u5.mjs} +6 -6
  128. package/dist/speed-ZFrMWDgd.mjs +4 -0
  129. package/dist/src-DU7FBCOX.mjs +108 -0
  130. package/dist/ssl-9JY05sYt.mjs +15 -0
  131. package/dist/stream-tRU39b8K.mjs +14 -0
  132. package/dist/{tenants-Bd7NGQ_m.mjs → tenants-HLGUazms.mjs} +1 -1
  133. package/dist/{token-validation-DAgtFOvs.mjs → token-validation-_VdamKpz.mjs} +4 -4
  134. package/dist/{tools-DXQmfFuE.mjs → tools-D_hfUU_Z.mjs} +1 -1
  135. package/dist/{turnstile-cfdaO4ca.mjs → turnstile-BRzXd28B.mjs} +4 -4
  136. package/dist/{ui-D4KtlMh9.mjs → ui-erjBdVKL.mjs} +1 -1
  137. package/dist/url-normalization-D-NxuLtN.mjs +3 -0
  138. package/dist/url-scanner-BzzR6iDx.mjs +2 -0
  139. package/dist/{user-CAo-yCJA.mjs → user-C4omq__w.mjs} +2 -2
  140. package/dist/vectorize-By6EqcNR.mjs +4 -0
  141. package/dist/{versions-CUwWJWmy.mjs → versions-CBHwWPAM.mjs} +1 -1
  142. package/dist/{waiting-rooms-Dln5ICg5.mjs → waiting-rooms-u6KwrzWd.mjs} +6 -6
  143. package/dist/{web3-HQJRm38W.mjs → web3-DQ5dmE9W.mjs} +3 -3
  144. package/dist/{workers-Dg7ddG2Q.mjs → workers-D8Be7_as.mjs} +14 -14
  145. package/dist/workers-builds-BE3W3qNk.mjs +7 -0
  146. package/dist/{workflows-VquuSh2J.mjs → workflows-BWWufqFA.mjs} +3 -3
  147. package/dist/zaraz-Bsa9AvVL.mjs +2 -0
  148. package/dist/{zero-trust-CP96wnSh.mjs → zero-trust-UNVZFnKu.mjs} +87 -87
  149. package/dist/zero_trust-B0_Rk4p2.mjs +3 -0
  150. package/dist/zones-BXtdwt6E.mjs +21 -0
  151. package/package.json +4 -4
  152. package/dist/ai-DOOKLPkG.mjs +0 -2
  153. package/dist/ai-gateway-Cj1T3avF.mjs +0 -8
  154. package/dist/ai-search-CQF_Sn7d.mjs +0 -7
  155. package/dist/ai_gateway-C3fH22C0.mjs +0 -4
  156. package/dist/analytics_engine-DdXVR8z2.mjs +0 -2
  157. package/dist/argo-CX_A4kcn.mjs +0 -2
  158. package/dist/audit-logs-BfBf3oo-.mjs +0 -2
  159. package/dist/auth-SyWhMmPu.mjs +0 -6
  160. package/dist/auth-ffdf9yR0.mjs +0 -135
  161. package/dist/autorag-BuGhGTeZ.mjs +0 -2
  162. package/dist/billing-PoG81XaQ.mjs +0 -2
  163. package/dist/bot-management-CFvtVx62.mjs +0 -5
  164. package/dist/botnet-feed-B-M4Yu0W.mjs +0 -3
  165. package/dist/brand-protection-D05Eg-_6.mjs +0 -3
  166. package/dist/browser-rendering-xu8F_Rrv.mjs +0 -4
  167. package/dist/calls-CZbO7TyR.mjs +0 -4
  168. package/dist/certificate-authorities-D2yr7_3t.mjs +0 -2
  169. package/dist/client-certificates-MJcDsTId.mjs +0 -3
  170. package/dist/cloud-connector-DWOrN2eM.mjs +0 -2
  171. package/dist/config-DYzlVxcB.mjs +0 -2
  172. package/dist/connectivity-BX8C7tvK.mjs +0 -3
  173. package/dist/content-scanning-r6uzMO1r.mjs +0 -4
  174. package/dist/context-DGlHRGWM.mjs +0 -2
  175. package/dist/custom-nameservers-D1DtlRue.mjs +0 -3
  176. package/dist/custom-pages-DQCi2plU.mjs +0 -4
  177. package/dist/d1-DbnYhw45.mjs +0 -4
  178. package/dist/data-security-D_EtYBfo.mjs +0 -6
  179. package/dist/dcv-delegation-CHspSzTI.mjs +0 -2
  180. package/dist/diagnostics-BJQGjVJn.mjs +0 -3
  181. package/dist/dist-DNBSHor6.mjs +0 -301
  182. package/dist/dns-firewall-B4DVXFBQ.mjs +0 -57
  183. package/dist/durable-objects-CTboySEo.mjs +0 -2
  184. package/dist/email-sending-DwWKc5jC.mjs +0 -3
  185. package/dist/google-tag-gateway-BGD49nRC.mjs +0 -2
  186. package/dist/hostnames-BiomxukN.mjs +0 -3
  187. package/dist/hyperdrive-Da104VaQ.mjs +0 -18
  188. package/dist/iam-BIGKo0WW.mjs +0 -6
  189. package/dist/images-BO8FbDAa.mjs +0 -5
  190. package/dist/intel-CY6_79v8.mjs +0 -3
  191. package/dist/keyless-certificates-CZC-L8gM.mjs +0 -3
  192. package/dist/leaked-credential-checks-qLzRyu85.mjs +0 -3
  193. package/dist/magic-cloud-networking-CSOM3EM-.mjs +0 -5
  194. package/dist/managed-transforms-D15yVbZx.mjs +0 -3
  195. package/dist/mtls-certificates-D8k0AXWK.mjs +0 -3
  196. package/dist/origin-ca-certificates-DXIvD8H5.mjs +0 -3
  197. package/dist/origin-post-quantum-encryption-C8oOczyV.mjs +0 -2
  198. package/dist/progress-CrCGTq7N.mjs +0 -2
  199. package/dist/queues-CN6DPhRR.mjs +0 -6
  200. package/dist/r2-data-catalog-Bbo93TJx.mjs +0 -14
  201. package/dist/radar-Bxb0WX8V.mjs +0 -2
  202. package/dist/raw-fetch-Dlccg0Tr.mjs +0 -2
  203. package/dist/request-tracers-DOW_reTJ.mjs +0 -2
  204. package/dist/resource-sharing-D7TX0JV0.mjs +0 -5
  205. package/dist/rules-BXRADHL5.mjs +0 -4
  206. package/dist/rum-BjPptTUP.mjs +0 -4
  207. package/dist/security-center-DAy6AKtT.mjs +0 -2
  208. package/dist/security-txt-xAMb7K6Y.mjs +0 -3
  209. package/dist/shared-AGtpXwwL.mjs +0 -2
  210. package/dist/snippets-CCSsCXVs.mjs +0 -4
  211. package/dist/speed-CuzTE0AL.mjs +0 -4
  212. package/dist/src-BW6vfAwE.mjs +0 -108
  213. package/dist/ssl-BWA2LdwC.mjs +0 -15
  214. package/dist/stream-GFsIZ-pP.mjs +0 -14
  215. package/dist/url-normalization-B5RN4nLD.mjs +0 -3
  216. package/dist/url-scanner-BrZ1L9OC.mjs +0 -2
  217. package/dist/vectorize-C7_oQlaI.mjs +0 -4
  218. package/dist/workers-builds-AVfx8IyL.mjs +0 -7
  219. package/dist/zaraz-xYSWIV4P.mjs +0 -2
  220. package/dist/zones-BSgmZ9WC.mjs +0 -21
  221. /package/dist/{body-parser-DKa8Ipg1.mjs → body-parser-DWSy7uZ8.mjs} +0 -0
  222. /package/dist/{cli-types-CRIDdDw3.mjs → cli-types-BeyOc81z.mjs} +0 -0
  223. /package/dist/{input-validation-zEO81MWN.mjs → input-validation-_fMCApaH.mjs} +0 -0
  224. /package/dist/{lib-Eu1wXxuh.mjs → lib-4PQI6yRW.mjs} +0 -0
  225. /package/dist/{local-VJaJ3BZ1.mjs → local-CYc9q7l2.mjs} +0 -0
  226. /package/dist/{metadata-5VwHPW6C.mjs → metadata-OOwvpR8m.mjs} +0 -0
  227. /package/dist/{resolve-4-OSeHlK.mjs → resolve-C3h-mwp7.mjs} +0 -0
  228. /package/dist/{theme-BklJDrb2.mjs → theme-DbNbIY4d.mjs} +0 -0
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env node
2
- import{C as e,D as t,T as n,_ as r,i,n as a}from"./auth-ffdf9yR0.mjs";import{n as o,t as s}from"./body-parser-DKa8Ipg1.mjs";import{t as c}from"./output-BJFNwj7b.mjs";import{n as l,t as u}from"./progress-CrCGTq7N.mjs";import{n as d}from"./input-validation-zEO81MWN.mjs";import{t as f}from"./local-VJaJ3BZ1.mjs";import{t as p}from"./cli-types-CRIDdDw3.mjs";function m(e){return e.option(`authentication`,{type:`boolean`,description:`The authentication field`}).option(`cache-invalidate-on-update`,{type:`boolean`,description:`The cache_invalidate_on_update field`}).option(`cache-ttl`,{type:`number`,description:`The cache_ttl field`}).option(`collect-logs`,{type:`boolean`,description:`The collect_logs field`}).option(`id`,{type:`string`,description:`gateway id`}).option(`log-management`,{type:`number`,description:`The log_management field`}).option(`log-management-strategy`,{type:`string`,description:`The log_management_strategy field`,choices:[`STOP_INSERTING`,`DELETE_OLDEST`]}).option(`logpush`,{type:`boolean`,description:`The logpush field`}).option(`logpush-public-key`,{type:`string`,description:`The logpush_public_key field`}).option(`rate-limiting-interval`,{type:`number`,description:`The rate_limiting_interval field`}).option(`rate-limiting-limit`,{type:`number`,description:`The rate_limiting_limit field`}).option(`rate-limiting-technique`,{type:`string`,description:`The rate_limiting_technique field`,choices:[`fixed`,`sliding`]}).option(`retry-backoff`,{type:`string`,description:`Backoff strategy for retry delays`,choices:[`constant`,`linear`,`exponential`]}).option(`retry-delay`,{type:`number`,description:`Delay between retry attempts in milliseconds (0-5000)`}).option(`retry-max-attempts`,{type:`number`,description:`Maximum number of retry attempts for failed requests (1-5)`}).option(`workers-ai-billing-mode`,{type:`string`,description:`Controls how Workers AI inference calls routed through this gateway are billed. Only 'postpaid' is currently supported.`,choices:[`postpaid`],default:`postpaid`}).option(`zdr`,{type:`boolean`,description:`The zdr field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const ee={command:`create`,describe:`Creates a new AI Gateway.`,builder:m,handler:async n=>{if(n.dryRun){l({command:`cf ai-gateway create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/gateways`,pathParams:{},bodyKind:`json`,body:n.body===void 0?s({authentication:n.authentication,cache_invalidate_on_update:n[`cache-invalidate-on-update`],cache_ttl:n[`cache-ttl`],collect_logs:n[`collect-logs`],id:d(n.id,`id`,`text`),log_management:n[`log-management`],log_management_strategy:d(n[`log-management-strategy`],`log-management-strategy`,`text`),logpush:n.logpush,logpush_public_key:d(n[`logpush-public-key`],`logpush-public-key`,`text`),rate_limiting_interval:n[`rate-limiting-interval`],rate_limiting_limit:n[`rate-limiting-limit`],rate_limiting_technique:d(n[`rate-limiting-technique`],`rate-limiting-technique`,`text`),retry_backoff:d(n[`retry-backoff`],`retry-backoff`,`text`),retry_delay:n[`retry-delay`],retry_max_attempts:n[`retry-max-attempts`],workers_ai_billing_mode:d(n[`workers-ai-billing-mode`],`workers-ai-billing-mode`,`text`),zdr:n.zdr}):o(n.body)});return}let i=await a(n),p=n.local?f:await r(i);if(n.accountId=p,n.body){let e=o(n.body);c(await u(`Creating`,async()=>i.aiGateway.create({...e,account_id:p})),{successLabel:`Created`});return}if(n[`cache-invalidate-on-update`]===void 0)throw Error(`--cache-invalidate-on-update is required (or pass --body with this field set).`);if(n[`cache-ttl`]===void 0)throw Error(`--cache-ttl is required (or pass --body with this field set).`);if(n[`collect-logs`]===void 0)throw Error(`--collect-logs is required (or pass --body with this field set).`);if(n.id===void 0&&(n.id=await t(`id`,`gateway id`)),n[`rate-limiting-interval`]===void 0)throw Error(`--rate-limiting-interval is required (or pass --body with this field set).`);if(n[`rate-limiting-limit`]===void 0)throw Error(`--rate-limiting-limit is required (or pass --body with this field set).`);let m=s({authentication:n.authentication,cache_invalidate_on_update:n[`cache-invalidate-on-update`],cache_ttl:n[`cache-ttl`],collect_logs:n[`collect-logs`],id:d(n.id,`id`,`text`),log_management:n[`log-management`],log_management_strategy:d(n[`log-management-strategy`],`log-management-strategy`,`text`),logpush:n.logpush,logpush_public_key:d(n[`logpush-public-key`],`logpush-public-key`,`text`),rate_limiting_interval:n[`rate-limiting-interval`],rate_limiting_limit:n[`rate-limiting-limit`],rate_limiting_technique:d(n[`rate-limiting-technique`],`rate-limiting-technique`,`text`),retry_backoff:d(n[`retry-backoff`],`retry-backoff`,`text`),retry_delay:n[`retry-delay`],retry_max_attempts:n[`retry-max-attempts`],workers_ai_billing_mode:d(n[`workers-ai-billing-mode`],`workers-ai-billing-mode`,`text`),zdr:n.zdr});c(await u(`Creating`,async()=>i.aiGateway.create({...m,account_id:p})),{successLabel:`Created`})}};function te(e){return e.positional(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`enable`,{type:`boolean`,description:`The enable field`}).option(`name`,{type:`string`,description:`The name field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const h={command:`create <gateway-id>`,describe:`Creates a new AI Gateway.`,builder:te,handler:async n=>{if(n.dryRun){l({command:`cf ai-gateway datasets create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/gateways/${n[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(n[`gateway-id`]))}/datasets`,pathParams:{"gateway-id":String(n[`gateway-id`]??``)},bodyKind:`json`,body:n.body===void 0?s({enable:n.enable,name:d(n.name,`name`,`text`)}):o(n.body)});return}let i=await a(n),p=n.local?f:await r(i);if(n.accountId=p,n.body){let e=o(n.body);c(await u(`Creating`,async()=>i.aiGateway.datasets.create({...e,account_id:p,gateway_id:n[`gateway-id`]})),{successLabel:`Created`});return}if(n.enable===void 0)throw Error(`--enable is required (or pass --body with this field set).`);n.name===void 0&&(n.name=await t(`name`,`The name field`));let m=s({enable:n.enable,name:d(n.name,`name`,`text`)});c(await u(`Creating`,async()=>i.aiGateway.datasets.create({...m,account_id:p,gateway_id:n[`gateway-id`]})),{successLabel:`Created`})}};function g(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const _={command:`delete <id>`,describe:`Deletes an AI Gateway dataset.`,builder:g,handler:async t=>{if(t.dryRun){l({command:`cf ai-gateway datasets delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/gateways/${t[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(t[`gateway-id`]))}/datasets/${t.id==null?`<id>`:encodeURIComponent(String(t.id))}`,pathParams:{"gateway-id":String(t[`gateway-id`]??``),id:String(t.id??``)},bodyKind:`none`});return}let i=await a(t),o=t.local?f:await r(i);if(t.accountId=o,!await n({force:!!t.force})){process.stderr.write(`Aborted.
3
- `);return}c(await u(`Deleting`,async()=>i.aiGateway.datasets.delete({account_id:o,gateway_id:t[`gateway-id`],id:t.id})),{successLabel:`Deleted`})}};function v(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const y={command:`get <id>`,describe:`Retrieves details for a specific AI Gateway dataset.`,builder:v,handler:async t=>{if(t.dryRun){l({command:`cf ai-gateway datasets get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/gateways/${t[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(t[`gateway-id`]))}/datasets/${t.id==null?`<id>`:encodeURIComponent(String(t.id))}`,pathParams:{"gateway-id":String(t[`gateway-id`]??``),id:String(t.id??``)},bodyKind:`none`});return}let n=await a(t),i=t.local?f:await r(n);t.accountId=i,c(await u(`Loading`,async()=>n.aiGateway.datasets.get({account_id:i,gateway_id:t[`gateway-id`],id:t.id})),{successLabel:`Loaded`})}};function b(e){return e.option(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`page`,{type:`number`,description:`Page`}).option(`per-page`,{type:`number`,description:`Per page`}).option(`name`,{type:`string`,description:`Name`}).option(`enable`,{type:`boolean`,description:`Enable`}).option(`search`,{type:`string`,description:`Search by id, name, filters`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const x={command:`list`,describe:`Lists all AI Gateway evaluator types configured for the account.`,builder:b,handler:async t=>{let n={page:t.page,per_page:t[`per-page`],name:t.name,enable:t.enable,search:t.search};if(t.dryRun){l({command:`cf ai-gateway datasets list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/gateways/${t[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(t[`gateway-id`]))}/datasets`,pathParams:{"gateway-id":String(t[`gateway-id`]??``)},query:n,bodyKind:`none`});return}let i=await a(t),o=t.local?f:await r(i);t.accountId=o,c(await u(`Loading`,async()=>i.aiGateway.datasets.list({account_id:o,gateway_id:t[`gateway-id`],...n})),{successLabel:`Loaded`})}};function S(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`enable`,{type:`boolean`,description:`The enable field`}).option(`name`,{type:`string`,description:`The name field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const C={command:`update <id>`,describe:`Updates an existing AI Gateway dataset.`,builder:S,handler:async n=>{if(n.dryRun){l({command:`cf ai-gateway datasets update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/gateways/${n[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(n[`gateway-id`]))}/datasets/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}`,pathParams:{"gateway-id":String(n[`gateway-id`]??``),id:String(n.id??``)},bodyKind:`json`,body:n.body===void 0?s({enable:n.enable,name:d(n.name,`name`,`text`)}):o(n.body)});return}let i=await a(n),p=n.local?f:await r(i);if(n.accountId=p,n.body){let e=o(n.body);c(await u(`Updating`,async()=>i.aiGateway.datasets.update({...e,account_id:p,gateway_id:n[`gateway-id`],id:n.id})),{successLabel:`Updated`});return}if(n.enable===void 0)throw Error(`--enable is required (or pass --body with this field set).`);n.name===void 0&&(n.name=await t(`name`,`The name field`));let m=s({enable:n.enable,name:d(n.name,`name`,`text`)});c(await u(`Updating`,async()=>i.aiGateway.datasets.update({...m,account_id:p,gateway_id:n[`gateway-id`],id:n.id})),{successLabel:`Updated`})}},w={command:`datasets`,describe:`Curated collections of gateway logs used as inputs for evaluations and fine-tuning`,builder:e=>e.command(h).command(_).command(y).command(x).command(C).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function T(e){return e.positional(`id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const E={command:`delete <id>`,describe:`Deletes an AI Gateway dataset.`,builder:T,handler:async t=>{if(t.dryRun){l({command:`cf ai-gateway delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/gateways/${t.id==null?`<id>`:encodeURIComponent(String(t.id))}`,pathParams:{id:String(t.id??``)},bodyKind:`none`});return}let i=await a(t),o=t.local?f:await r(i);if(t.accountId=o,!await n({force:!!t.force})){process.stderr.write(`Aborted.
4
- `);return}c(await u(`Deleting`,async()=>i.aiGateway.delete({account_id:o,id:t.id})),{successLabel:`Deleted`})}};function D(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`gateway-id`,{type:`string`,description:`Gateway ID`,demandOption:!0}).option(`version-id`,{type:`string`,description:`The version_id field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const O={command:`create-deployment <id>`,describe:`Create a new AI Gateway Dynamic Route Deployment.`,builder:D,handler:async n=>{if(n.dryRun){l({command:`cf ai-gateway dynamic-routing create-deployment`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/gateways/${n[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(n[`gateway-id`]))}/routes/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}/deployments`,pathParams:{"gateway-id":String(n[`gateway-id`]??``),id:String(n.id??``)},bodyKind:`json`,body:n.body===void 0?s({version_id:d(n[`version-id`],`version-id`,`text`)}):o(n.body)});return}let i=await a(n),p=n.local?f:await r(i);if(n.accountId=p,n.body){let e=o(n.body);c(await u(`Creating`,async()=>i.aiGateway.dynamicRouting.createDeployment({...e,account_id:p,gateway_id:n[`gateway-id`],id:n.id})),{successLabel:`Created`});return}n[`version-id`]===void 0&&(n[`version-id`]=await t(`version-id`,`The version_id field`));let m=s({version_id:d(n[`version-id`],`version-id`,`text`)});c(await u(`Creating`,async()=>i.aiGateway.dynamicRouting.createDeployment({...m,account_id:p,gateway_id:n[`gateway-id`],id:n.id})),{successLabel:`Created`})}};function k(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`gateway-id`,{type:`string`,description:`Gateway ID`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const A={command:`create-version <id>`,describe:`Create a new AI Gateway Dynamic Route Version.`,builder:k,handler:async t=>{if(t.dryRun){l({command:`cf ai-gateway dynamic-routing create-version`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/gateways/${t[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(t[`gateway-id`]))}/routes/${t.id==null?`<id>`:encodeURIComponent(String(t.id))}/versions`,pathParams:{"gateway-id":String(t[`gateway-id`]??``),id:String(t.id??``)},bodyKind:`json`,body:t.body===void 0?void 0:o(t.body)});return}let n=await a(t),s=t.local?f:await r(n);if(t.accountId=s,t.body){let e=o(t.body);c(await u(`Creating`,async()=>n.aiGateway.dynamicRouting.createVersion({...e,account_id:s,gateway_id:t[`gateway-id`],id:t.id})),{successLabel:`Created`});return}c(await u(`Creating`,async()=>i(n,`POST`,`/accounts/${s}/ai-gateway/gateways/${encodeURIComponent(String(t[`gateway-id`]))}/routes/${encodeURIComponent(String(t.id))}/versions`)),{successLabel:`Created`})}};function j(e){return e.positional(`gateway-id`,{type:`string`,description:`Gateway ID`,demandOption:!0}).option(`name`,{type:`string`,description:`The name field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const M={command:`create <gateway-id>`,describe:`Create a new AI Gateway Dynamic Route.`,builder:j,handler:async n=>{if(n.dryRun){l({command:`cf ai-gateway dynamic-routing create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/gateways/${n[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(n[`gateway-id`]))}/routes`,pathParams:{"gateway-id":String(n[`gateway-id`]??``)},bodyKind:`json`,body:n.body===void 0?s({name:d(n.name,`name`,`text`)}):o(n.body)});return}let i=await a(n),p=n.local?f:await r(i);if(n.accountId=p,n.body){let e=o(n.body);c(await u(`Creating`,async()=>i.aiGateway.dynamicRouting.create({...e,account_id:p,gateway_id:n[`gateway-id`]})),{successLabel:`Created`});return}n.name===void 0&&(n.name=await t(`name`,`The name field`));let m=s({name:d(n.name,`name`,`text`)});c(await u(`Creating`,async()=>i.aiGateway.dynamicRouting.create({...m,account_id:p,gateway_id:n[`gateway-id`]})),{successLabel:`Created`})}};function N(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`gateway-id`,{type:`string`,description:`Gateway ID`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const P={command:`delete <id>`,describe:`Delete an AI Gateway Dynamic Route.`,builder:N,handler:async t=>{if(t.dryRun){l({command:`cf ai-gateway dynamic-routing delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/gateways/${t[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(t[`gateway-id`]))}/routes/${t.id==null?`<id>`:encodeURIComponent(String(t.id))}`,pathParams:{"gateway-id":String(t[`gateway-id`]??``),id:String(t.id??``)},bodyKind:`none`});return}let i=await a(t),o=t.local?f:await r(i);if(t.accountId=o,!await n({force:!!t.force})){process.stderr.write(`Aborted.
5
- `);return}c(await u(`Deleting`,async()=>i.aiGateway.dynamicRouting.delete({account_id:o,gateway_id:t[`gateway-id`],id:t.id})),{successLabel:`Deleted`})}};function F(e){return e.positional(`version-id`,{type:`string`,description:`Version ID`,demandOption:!0}).option(`gateway-id`,{type:`string`,description:`Gateway ID`,demandOption:!0}).option(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const I={command:`get-version <version-id>`,describe:`Get an AI Gateway Dynamic Route Version.`,builder:F,handler:async t=>{if(t.dryRun){l({command:`cf ai-gateway dynamic-routing get-version`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/gateways/${t[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(t[`gateway-id`]))}/routes/${t.id==null?`<id>`:encodeURIComponent(String(t.id))}/versions/${t[`version-id`]==null?`<version-id>`:encodeURIComponent(String(t[`version-id`]))}`,pathParams:{"gateway-id":String(t[`gateway-id`]??``),id:String(t.id??``),"version-id":String(t[`version-id`]??``)},bodyKind:`none`});return}let n=await a(t),i=t.local?f:await r(n);t.accountId=i,c(await u(`Loading`,async()=>n.aiGateway.dynamicRouting.getVersion({account_id:i,gateway_id:t[`gateway-id`],id:t.id,version_id:t[`version-id`]})),{successLabel:`Loaded`})}};function L(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`gateway-id`,{type:`string`,description:`Gateway ID`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const R={command:`get <id>`,describe:`Get an AI Gateway Dynamic Route.`,builder:L,handler:async t=>{if(t.dryRun){l({command:`cf ai-gateway dynamic-routing get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/gateways/${t[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(t[`gateway-id`]))}/routes/${t.id==null?`<id>`:encodeURIComponent(String(t.id))}`,pathParams:{"gateway-id":String(t[`gateway-id`]??``),id:String(t.id??``)},bodyKind:`none`});return}let n=await a(t),i=t.local?f:await r(n);t.accountId=i,c(await u(`Loading`,async()=>n.aiGateway.dynamicRouting.get({account_id:i,gateway_id:t[`gateway-id`],id:t.id})),{successLabel:`Loaded`})}};function z(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`gateway-id`,{type:`string`,description:`Gateway ID`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const B={command:`list-deployments <id>`,describe:`List all AI Gateway Dynamic Route Deployments.`,builder:z,handler:async t=>{if(t.dryRun){l({command:`cf ai-gateway dynamic-routing list-deployments`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/gateways/${t[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(t[`gateway-id`]))}/routes/${t.id==null?`<id>`:encodeURIComponent(String(t.id))}/deployments`,pathParams:{"gateway-id":String(t[`gateway-id`]??``),id:String(t.id??``)},bodyKind:`none`});return}let n=await a(t),i=t.local?f:await r(n);t.accountId=i,c(await u(`Loading`,async()=>n.aiGateway.dynamicRouting.listDeployments({account_id:i,gateway_id:t[`gateway-id`],id:t.id})),{successLabel:`Loaded`})}};function V(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`gateway-id`,{type:`string`,description:`Gateway ID`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const H={command:`list-versions <id>`,describe:`List all AI Gateway Dynamic Route Versions.`,builder:V,handler:async t=>{if(t.dryRun){l({command:`cf ai-gateway dynamic-routing list-versions`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/gateways/${t[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(t[`gateway-id`]))}/routes/${t.id==null?`<id>`:encodeURIComponent(String(t.id))}/versions`,pathParams:{"gateway-id":String(t[`gateway-id`]??``),id:String(t.id??``)},bodyKind:`none`});return}let n=await a(t),i=t.local?f:await r(n);t.accountId=i,c(await u(`Loading`,async()=>n.aiGateway.dynamicRouting.listVersions({account_id:i,gateway_id:t[`gateway-id`],id:t.id})),{successLabel:`Loaded`})}};function U(e){return e.option(`gateway-id`,{type:`string`,description:`Gateway ID`,demandOption:!0}).option(`page`,{type:`number`,description:`Page number`}).option(`per-page`,{type:`number`,description:`Number of routes per page`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const W={command:`list`,describe:`List all AI Gateway Dynamic Routes.`,builder:U,handler:async t=>{let n={page:t.page,per_page:t[`per-page`]};if(t.dryRun){l({command:`cf ai-gateway dynamic-routing list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/gateways/${t[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(t[`gateway-id`]))}/routes`,pathParams:{"gateway-id":String(t[`gateway-id`]??``)},query:n,bodyKind:`none`});return}let i=await a(t),o=t.local?f:await r(i);t.accountId=o,c(await u(`Loading`,async()=>i.aiGateway.dynamicRouting.list({account_id:o,gateway_id:t[`gateway-id`],...n})),{successLabel:`Loaded`})}};function G(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`gateway-id`,{type:`string`,description:`Gateway ID`,demandOption:!0}).option(`name`,{type:`string`,description:`The name field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const K={command:`update <id>`,describe:`Update an AI Gateway Dynamic Route.`,builder:G,handler:async n=>{if(n.dryRun){l({command:`cf ai-gateway dynamic-routing update`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/gateways/${n[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(n[`gateway-id`]))}/routes/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}`,pathParams:{"gateway-id":String(n[`gateway-id`]??``),id:String(n.id??``)},bodyKind:`json`,body:n.body===void 0?s({name:d(n.name,`name`,`text`)}):o(n.body)});return}let i=await a(n),p=n.local?f:await r(i);if(n.accountId=p,n.body){let e=o(n.body);c(await u(`Updating`,async()=>i.aiGateway.dynamicRouting.update({...e,account_id:p,gateway_id:n[`gateway-id`],id:n.id})),{successLabel:`Updated`});return}n.name===void 0&&(n.name=await t(`name`,`The name field`));let m=s({name:d(n.name,`name`,`text`)});c(await u(`Updating`,async()=>i.aiGateway.dynamicRouting.update({...m,account_id:p,gateway_id:n[`gateway-id`],id:n.id})),{successLabel:`Updated`})}},q={command:`dynamic-routing`,describe:`Operations for dynamic-routing`,builder:e=>e.command(M).command(O).command(A).command(P).command(R).command(I).command(W).command(B).command(H).command(K).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function J(e){return e.option(`page`,{type:`number`,description:`Page`}).option(`per-page`,{type:`number`,description:`Per page`}).option(`order-by`,{type:`string`,description:`Order by`}).option(`order-by-direction`,{type:`string`,description:`Order by direction`,choices:[`asc`,`desc`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Y={command:`list`,describe:`Lists all available evaluator types for scoring AI gateway responses.`,builder:p(J),handler:async t=>{let n={page:t.page,per_page:t[`per-page`],order_by:t[`order-by`],order_by_direction:t[`order-by-direction`]};if(t.dryRun){l({command:`cf ai-gateway evaluation-types list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/evaluation-types`,pathParams:{},query:n,bodyKind:`none`});return}let i=await a(t),o=t.local?f:await r(i);t.accountId=o,c(await u(`Loading`,async()=>i.aiGateway.evaluationTypes.list({account_id:o,...n})),{successLabel:`Loaded`})}},X={command:`evaluation-types`,describe:`Operations for evaluation-types`,builder:e=>e.command(Y).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Z(e){return e.positional(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`dataset-ids`,{type:`string`,array:!0,description:`The dataset_ids field`}).option(`evaluation-type-ids`,{type:`string`,array:!0,description:`The evaluation_type_ids field`}).option(`name`,{type:`string`,description:`The name field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const Q={command:`create <gateway-id>`,describe:`Creates a new AI Gateway.`,builder:Z,handler:async n=>{if(n.dryRun){l({command:`cf ai-gateway evaluations create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/gateways/${n[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(n[`gateway-id`]))}/evaluations`,pathParams:{"gateway-id":String(n[`gateway-id`]??``)},bodyKind:`json`,body:n.body===void 0?s({dataset_ids:n[`dataset-ids`],evaluation_type_ids:n[`evaluation-type-ids`],name:d(n.name,`name`,`text`)}):o(n.body)});return}let i=await a(n),p=n.local?f:await r(i);if(n.accountId=p,n.body){let e=o(n.body);c(await u(`Creating`,async()=>i.aiGateway.evaluations.create({...e,account_id:p,gateway_id:n[`gateway-id`]})),{successLabel:`Created`});return}if(n[`dataset-ids`]===void 0)throw Error(`--dataset-ids is required (or pass --body with this field set).`);if(n[`evaluation-type-ids`]===void 0)throw Error(`--evaluation-type-ids is required (or pass --body with this field set).`);n.name===void 0&&(n.name=await t(`name`,`The name field`));let m=s({dataset_ids:n[`dataset-ids`],evaluation_type_ids:n[`evaluation-type-ids`],name:d(n.name,`name`,`text`)});c(await u(`Creating`,async()=>i.aiGateway.evaluations.create({...m,account_id:p,gateway_id:n[`gateway-id`]})),{successLabel:`Created`})}};function ne(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const re={command:`delete <id>`,describe:`Deletes an AI Gateway dataset.`,builder:ne,handler:async t=>{if(t.dryRun){l({command:`cf ai-gateway evaluations delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/gateways/${t[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(t[`gateway-id`]))}/evaluations/${t.id==null?`<id>`:encodeURIComponent(String(t.id))}`,pathParams:{"gateway-id":String(t[`gateway-id`]??``),id:String(t.id??``)},bodyKind:`none`});return}let i=await a(t),o=t.local?f:await r(i);if(t.accountId=o,!await n({force:!!t.force})){process.stderr.write(`Aborted.
6
- `);return}c(await u(`Deleting`,async()=>i.aiGateway.evaluations.delete({account_id:o,gateway_id:t[`gateway-id`],id:t.id})),{successLabel:`Deleted`})}};function ie(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const ae={command:`get <id>`,describe:`Retrieves details for a specific AI Gateway dataset.`,builder:ie,handler:async t=>{if(t.dryRun){l({command:`cf ai-gateway evaluations get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/gateways/${t[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(t[`gateway-id`]))}/evaluations/${t.id==null?`<id>`:encodeURIComponent(String(t.id))}`,pathParams:{"gateway-id":String(t[`gateway-id`]??``),id:String(t.id??``)},bodyKind:`none`});return}let n=await a(t),i=t.local?f:await r(n);t.accountId=i,c(await u(`Loading`,async()=>n.aiGateway.evaluations.get({account_id:i,gateway_id:t[`gateway-id`],id:t.id})),{successLabel:`Loaded`})}};function oe(e){return e.option(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`page`,{type:`number`,description:`Page`}).option(`per-page`,{type:`number`,description:`Per page`}).option(`name`,{type:`string`,description:`Name`}).option(`processed`,{type:`boolean`,description:`Processed`}).option(`search`,{type:`string`,description:`Search by id, name`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const se={command:`list`,describe:`Lists all AI Gateway evaluator types configured for the account.`,builder:oe,handler:async t=>{let n={page:t.page,per_page:t[`per-page`],name:t.name,processed:t.processed,search:t.search};if(t.dryRun){l({command:`cf ai-gateway evaluations list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/gateways/${t[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(t[`gateway-id`]))}/evaluations`,pathParams:{"gateway-id":String(t[`gateway-id`]??``)},query:n,bodyKind:`none`});return}let i=await a(t),o=t.local?f:await r(i);t.accountId=o,c(await u(`Loading`,async()=>i.aiGateway.evaluations.list({account_id:o,gateway_id:t[`gateway-id`],...n})),{successLabel:`Loaded`})}},ce={command:`evaluations`,describe:`Run quality evaluations against gateway logs or datasets to score model outputs`,builder:e=>e.command(Q).command(re).command(ae).command(se).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function le(e){return e.positional(`id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const ue={command:`get <id>`,describe:`Retrieves details for a specific AI Gateway dataset.`,builder:le,handler:async t=>{if(t.dryRun){l({command:`cf ai-gateway get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/gateways/${t.id==null?`<id>`:encodeURIComponent(String(t.id))}`,pathParams:{id:String(t.id??``)},bodyKind:`none`});return}let n=await a(t),i=t.local?f:await r(n);t.accountId=i,c(await u(`Loading`,async()=>n.aiGateway.get({account_id:i,id:t.id})),{successLabel:`Loaded`})}};function de(e){return e.option(`page`,{type:`number`,description:`Page`}).option(`per-page`,{type:`number`,description:`Per page`}).option(`search`,{type:`string`,description:`Search by id`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const fe={command:`list`,describe:`Lists all AI Gateway evaluator types configured for the account.`,builder:de,handler:async t=>{let n={page:t.page,per_page:t[`per-page`],search:t.search};if(t.dryRun){l({command:`cf ai-gateway list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/gateways`,pathParams:{},query:n,bodyKind:`none`});return}let i=await a(t),o=t.local?f:await r(i);t.accountId=o,c(await u(`Loading`,async()=>i.aiGateway.list({account_id:o,...n})),{successLabel:`Loaded`})}};function pe(e){return e.positional(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`order-by`,{type:`string`,description:`Order by`,choices:[`created_at`,`provider`,`model`,`model_type`,`success`,`cached`,`cost`,`tokens_in`,`tokens_out`,`duration`,`feedback`]}).option(`order-by-direction`,{type:`string`,description:`Order by direction`,choices:[`asc`,`desc`]}).option(`filters`,{type:`string`,description:`Filters`}).option(`limit`,{type:`number`,description:`Limit`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const me={command:`delete <gateway-id>`,describe:`Deletes gateway log entries matching the specified criteria.`,builder:p(pe),handler:async t=>{let i={order_by:t[`order-by`],order_by_direction:t[`order-by-direction`],filters:t.filters,limit:t.limit};if(t.dryRun){l({command:`cf ai-gateway logs delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/gateways/${t[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(t[`gateway-id`]))}/logs`,pathParams:{"gateway-id":String(t[`gateway-id`]??``)},query:i,bodyKind:`none`});return}let o=await a(t),s=t.local?f:await r(o);if(t.accountId=s,!await n({force:!!t.force})){process.stderr.write(`Aborted.
7
- `);return}c(await u(`Deleting`,async()=>o.aiGateway.logs.delete({account_id:s,gateway_id:t[`gateway-id`],...i})),{successLabel:`Deleted`})}};function he(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`feedback`,{type:`number`,description:`The feedback field`}).option(`score`,{type:`number`,description:`The score field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const ge={command:`edit <id>`,describe:`Updates metadata for an AI Gateway log entry.`,builder:he,handler:async t=>{if(t.dryRun){l({command:`cf ai-gateway logs edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/gateways/${t[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(t[`gateway-id`]))}/logs/${t.id==null?`<id>`:encodeURIComponent(String(t.id))}`,pathParams:{id:String(t.id??``),"gateway-id":String(t[`gateway-id`]??``)},bodyKind:`json`,body:t.body===void 0?s({feedback:t.feedback,score:t.score}):o(t.body)});return}let n=await a(t),i=t.local?f:await r(n);if(t.accountId=i,t.body){let e=o(t.body);c(await u(`Updating`,async()=>n.aiGateway.logs.edit({...e,account_id:i,gateway_id:t[`gateway-id`],id:t.id})),{successLabel:`Updated`});return}let d=s({feedback:t.feedback,score:t.score});c(await u(`Updating`,async()=>n.aiGateway.logs.edit({...d,account_id:i,gateway_id:t[`gateway-id`],id:t.id})),{successLabel:`Updated`})}};function _e(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const ve={command:`get <id>`,describe:`Retrieves detailed information for a specific AI Gateway log entry.`,builder:_e,handler:async t=>{if(t.dryRun){l({command:`cf ai-gateway logs get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/gateways/${t[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(t[`gateway-id`]))}/logs/${t.id==null?`<id>`:encodeURIComponent(String(t.id))}`,pathParams:{id:String(t.id??``),"gateway-id":String(t[`gateway-id`]??``)},bodyKind:`none`});return}let n=await a(t),i=t.local?f:await r(n);t.accountId=i,c(await u(`Loading`,async()=>n.aiGateway.logs.get({account_id:i,gateway_id:t[`gateway-id`],id:t.id})),{successLabel:`Loaded`})}};function ye(e){return e.option(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`search`,{type:`string`,description:`Search`}).option(`page`,{type:`number`,description:`Page`}).option(`per-page`,{type:`number`,description:`Per page`}).option(`order-by`,{type:`string`,description:`Order by`,choices:[`created_at`,`provider`,`model`,`model_type`,`success`,`cached`]}).option(`order-by-direction`,{type:`string`,description:`Order by direction`,choices:[`asc`,`desc`]}).option(`filters`,{type:`string`,description:`Filters`}).option(`meta-info`,{type:`boolean`,description:`Meta info`}).option(`direction`,{type:`string`,description:`Direction`,choices:[`asc`,`desc`]}).option(`start-date`,{type:`string`,description:`Start date`}).option(`end-date`,{type:`string`,description:`End date`}).option(`min-cost`,{type:`number`,description:`Min cost`}).option(`max-cost`,{type:`number`,description:`Max cost`}).option(`min-tokens-in`,{type:`number`,description:`Min tokens in`}).option(`max-tokens-in`,{type:`number`,description:`Max tokens in`}).option(`min-tokens-out`,{type:`number`,description:`Min tokens out`}).option(`max-tokens-out`,{type:`number`,description:`Max tokens out`}).option(`min-total-tokens`,{type:`number`,description:`Min total tokens`}).option(`max-total-tokens`,{type:`number`,description:`Max total tokens`}).option(`min-duration`,{type:`number`,description:`Min duration`}).option(`max-duration`,{type:`number`,description:`Max duration`}).option(`feedback`,{type:`string`,description:`Feedback`,choices:[`-1`]}).option(`success`,{type:`boolean`,description:`Success`}).option(`cached`,{type:`boolean`,description:`Cached`}).option(`model`,{type:`string`,description:`Model`}).option(`model-type`,{type:`string`,description:`Model type`}).option(`provider`,{type:`string`,description:`Provider`}).option(`request-content-type`,{type:`string`,description:`Request content type`}).option(`response-content-type`,{type:`string`,description:`Response content type`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const be={command:`list`,describe:`Lists request/response log entries for the AI gateway with filtering and pagination.`,builder:p(ye),handler:async t=>{let n={search:t.search,page:t.page,per_page:t[`per-page`],order_by:t[`order-by`],order_by_direction:t[`order-by-direction`],filters:t.filters,meta_info:t[`meta-info`],direction:t.direction,start_date:t[`start-date`],end_date:t[`end-date`],min_cost:t[`min-cost`],max_cost:t[`max-cost`],min_tokens_in:t[`min-tokens-in`],max_tokens_in:t[`max-tokens-in`],min_tokens_out:t[`min-tokens-out`],max_tokens_out:t[`max-tokens-out`],min_total_tokens:t[`min-total-tokens`],max_total_tokens:t[`max-total-tokens`],min_duration:t[`min-duration`],max_duration:t[`max-duration`],feedback:t.feedback,success:t.success,cached:t.cached,model:t.model,model_type:t[`model-type`],provider:t.provider,request_content_type:t[`request-content-type`],response_content_type:t[`response-content-type`]};if(t.dryRun){l({command:`cf ai-gateway logs list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/gateways/${t[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(t[`gateway-id`]))}/logs`,pathParams:{"gateway-id":String(t[`gateway-id`]??``)},query:n,bodyKind:`none`});return}let i=await a(t),o=t.local?f:await r(i);t.accountId=o,c(await u(`Loading`,async()=>i.aiGateway.logs.list({account_id:o,gateway_id:t[`gateway-id`],...n})),{successLabel:`Loaded`})}};function xe(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Se={command:`request <id>`,describe:`Retrieves the original request payload for an AI Gateway log entry.`,builder:xe,handler:async t=>{if(t.dryRun){l({command:`cf ai-gateway logs request`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/gateways/${t[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(t[`gateway-id`]))}/logs/${t.id==null?`<id>`:encodeURIComponent(String(t.id))}/request`,pathParams:{id:String(t.id??``),"gateway-id":String(t[`gateway-id`]??``)},bodyKind:`none`});return}let n=await a(t),i=t.local?f:await r(n);t.accountId=i,c(await u(`Loading`,async()=>n.aiGateway.logs.request({account_id:i,gateway_id:t[`gateway-id`],id:t.id})),{successLabel:`Loaded`})}};function Ce(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const we={command:`response <id>`,describe:`Retrieves the response payload for an AI Gateway log entry.`,builder:Ce,handler:async t=>{if(t.dryRun){l({command:`cf ai-gateway logs response`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/gateways/${t[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(t[`gateway-id`]))}/logs/${t.id==null?`<id>`:encodeURIComponent(String(t.id))}/response`,pathParams:{id:String(t.id??``),"gateway-id":String(t[`gateway-id`]??``)},bodyKind:`none`});return}let n=await a(t),i=t.local?f:await r(n);t.accountId=i,c(await u(`Loading`,async()=>n.aiGateway.logs.response({account_id:i,gateway_id:t[`gateway-id`],id:t.id})),{successLabel:`Loaded`})}},Te={command:`logs`,describe:`Operations for logs`,builder:e=>e.command(me).command(ge).command(ve).command(be).command(Se).command(we).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Ee(e){return e.positional(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`alias`,{type:`string`,description:`The alias field`}).option(`default-config`,{type:`boolean`,description:`The default_config field`}).option(`provider-slug`,{type:`string`,description:`The provider_slug field`}).option(`rate-limit`,{type:`number`,description:`The rate_limit field`}).option(`rate-limit-period`,{type:`number`,description:`The rate_limit_period field`,default:60}).option(`secret`,{type:`string`,description:`The secret field`}).option(`secret-id`,{type:`string`,description:`The secret_id field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const De={command:`create <gateway-id>`,describe:`Creates a new AI Gateway.`,builder:Ee,handler:async n=>{if(n.dryRun){l({command:`cf ai-gateway provider-configs create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/gateways/${n[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(n[`gateway-id`]))}/provider_configs`,pathParams:{"gateway-id":String(n[`gateway-id`]??``)},bodyKind:`json`,body:n.body===void 0?s({alias:d(n.alias,`alias`,`text`),default_config:n[`default-config`],provider_slug:d(n[`provider-slug`],`provider-slug`,`text`),rate_limit:n[`rate-limit`],rate_limit_period:n[`rate-limit-period`],secret:d(n.secret,`secret`,`text`),secret_id:d(n[`secret-id`],`secret-id`,`text`)}):o(n.body)});return}let i=await a(n),p=n.local?f:await r(i);if(n.accountId=p,n.body){let e=o(n.body);c(await u(`Creating`,async()=>i.aiGateway.providerConfigs.create({...e,account_id:p,gateway_id:n[`gateway-id`]})),{successLabel:`Created`});return}if(n.alias===void 0&&(n.alias=await t(`alias`,`The alias field`)),n[`default-config`]===void 0)throw Error(`--default-config is required (or pass --body with this field set).`);n[`provider-slug`]===void 0&&(n[`provider-slug`]=await t(`provider-slug`,`The provider_slug field`));let m=s({alias:d(n.alias,`alias`,`text`),default_config:n[`default-config`],provider_slug:d(n[`provider-slug`],`provider-slug`,`text`),rate_limit:n[`rate-limit`],rate_limit_period:n[`rate-limit-period`],secret:d(n.secret,`secret`,`text`),secret_id:d(n[`secret-id`],`secret-id`,`text`)});c(await u(`Creating`,async()=>i.aiGateway.providerConfigs.create({...m,account_id:p,gateway_id:n[`gateway-id`]})),{successLabel:`Created`})}};function $(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const Oe={command:`delete <id>`,describe:`Deletes an AI Gateway dataset.`,builder:$,handler:async t=>{if(t.dryRun){l({command:`cf ai-gateway provider-configs delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/gateways/${t[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(t[`gateway-id`]))}/provider_configs/${t.id==null?`<id>`:encodeURIComponent(String(t.id))}`,pathParams:{"gateway-id":String(t[`gateway-id`]??``),id:String(t.id??``)},bodyKind:`none`});return}let i=await a(t),o=t.local?f:await r(i);if(t.accountId=o,!await n({force:!!t.force})){process.stderr.write(`Aborted.
8
- `);return}c(await u(`Deleting`,async()=>i.aiGateway.providerConfigs.delete({account_id:o,gateway_id:t[`gateway-id`],id:t.id})),{successLabel:`Deleted`})}};function ke(e){return e.option(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`page`,{type:`number`,description:`Page`}).option(`per-page`,{type:`number`,description:`Per page`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Ae={command:`list`,describe:`Lists all AI Gateway evaluator types configured for the account.`,builder:ke,handler:async t=>{let n={page:t.page,per_page:t[`per-page`]};if(t.dryRun){l({command:`cf ai-gateway provider-configs list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/gateways/${t[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(t[`gateway-id`]))}/provider_configs`,pathParams:{"gateway-id":String(t[`gateway-id`]??``)},query:n,bodyKind:`none`});return}let i=await a(t),o=t.local?f:await r(i);t.accountId=o,c(await u(`Loading`,async()=>i.aiGateway.providerConfigs.list({account_id:o,gateway_id:t[`gateway-id`],...n})),{successLabel:`Loaded`})}};function je(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`secret`,{type:`string`,description:`The secret field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const Me={command:`update <id>`,describe:`Updates an existing AI Gateway dataset.`,builder:je,handler:async n=>{if(n.dryRun){l({command:`cf ai-gateway provider-configs update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/gateways/${n[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(n[`gateway-id`]))}/provider_configs/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}`,pathParams:{"gateway-id":String(n[`gateway-id`]??``),id:String(n.id??``)},bodyKind:`json`,body:n.body===void 0?s({secret:d(n.secret,`secret`,`text`)}):o(n.body)});return}let i=await a(n),p=n.local?f:await r(i);if(n.accountId=p,n.body){let e=o(n.body);c(await u(`Updating`,async()=>i.aiGateway.providerConfigs.update({...e,account_id:p,gateway_id:n[`gateway-id`],id:n.id})),{successLabel:`Updated`});return}n.secret===void 0&&(n.secret=await t(`secret`,`The secret field`));let m=s({secret:d(n.secret,`secret`,`text`)});c(await u(`Updating`,async()=>i.aiGateway.providerConfigs.update({...m,account_id:p,gateway_id:n[`gateway-id`],id:n.id})),{successLabel:`Updated`})}},Ne={command:`provider-configs`,describe:`Store API keys and endpoint settings for each upstream AI provider`,builder:e=>e.command(De).command(Oe).command(Ae).command(Me).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Pe(e){return e.positional(`id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`authentication`,{type:`boolean`,description:`The authentication field`}).option(`cache-invalidate-on-update`,{type:`boolean`,description:`The cache_invalidate_on_update field`}).option(`cache-ttl`,{type:`number`,description:`The cache_ttl field`}).option(`collect-logs`,{type:`boolean`,description:`The collect_logs field`}).option(`guardrails-prompt-p1`,{type:`string`,description:`The guardrails.prompt.P1 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-prompt-s1`,{type:`string`,description:`The guardrails.prompt.S1 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-prompt-s10`,{type:`string`,description:`The guardrails.prompt.S10 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-prompt-s11`,{type:`string`,description:`The guardrails.prompt.S11 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-prompt-s12`,{type:`string`,description:`The guardrails.prompt.S12 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-prompt-s13`,{type:`string`,description:`The guardrails.prompt.S13 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-prompt-s2`,{type:`string`,description:`The guardrails.prompt.S2 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-prompt-s3`,{type:`string`,description:`The guardrails.prompt.S3 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-prompt-s4`,{type:`string`,description:`The guardrails.prompt.S4 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-prompt-s5`,{type:`string`,description:`The guardrails.prompt.S5 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-prompt-s6`,{type:`string`,description:`The guardrails.prompt.S6 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-prompt-s7`,{type:`string`,description:`The guardrails.prompt.S7 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-prompt-s8`,{type:`string`,description:`The guardrails.prompt.S8 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-prompt-s9`,{type:`string`,description:`The guardrails.prompt.S9 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-response-p1`,{type:`string`,description:`The guardrails.response.P1 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-response-s1`,{type:`string`,description:`The guardrails.response.S1 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-response-s10`,{type:`string`,description:`The guardrails.response.S10 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-response-s11`,{type:`string`,description:`The guardrails.response.S11 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-response-s12`,{type:`string`,description:`The guardrails.response.S12 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-response-s13`,{type:`string`,description:`The guardrails.response.S13 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-response-s2`,{type:`string`,description:`The guardrails.response.S2 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-response-s3`,{type:`string`,description:`The guardrails.response.S3 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-response-s4`,{type:`string`,description:`The guardrails.response.S4 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-response-s5`,{type:`string`,description:`The guardrails.response.S5 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-response-s6`,{type:`string`,description:`The guardrails.response.S6 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-response-s7`,{type:`string`,description:`The guardrails.response.S7 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-response-s8`,{type:`string`,description:`The guardrails.response.S8 field`,choices:[`FLAG`,`BLOCK`]}).option(`guardrails-response-s9`,{type:`string`,description:`The guardrails.response.S9 field`,choices:[`FLAG`,`BLOCK`]}).option(`log-management`,{type:`number`,description:`The log_management field`}).option(`log-management-strategy`,{type:`string`,description:`The log_management_strategy field`,choices:[`STOP_INSERTING`,`DELETE_OLDEST`]}).option(`logpush`,{type:`boolean`,description:`The logpush field`}).option(`logpush-public-key`,{type:`string`,description:`The logpush_public_key field`}).option(`rate-limiting-interval`,{type:`number`,description:`The rate_limiting_interval field`}).option(`rate-limiting-limit`,{type:`number`,description:`The rate_limiting_limit field`}).option(`rate-limiting-technique`,{type:`string`,description:`The rate_limiting_technique field`,choices:[`fixed`,`sliding`]}).option(`retry-backoff`,{type:`string`,description:`Backoff strategy for retry delays`,choices:[`constant`,`linear`,`exponential`]}).option(`retry-delay`,{type:`number`,description:`Delay between retry attempts in milliseconds (0-5000)`}).option(`retry-max-attempts`,{type:`number`,description:`Maximum number of retry attempts for failed requests (1-5)`}).option(`spend-limits-enabled`,{type:`boolean`,description:`The spend_limits.enabled field`}).option(`store-id`,{type:`string`,description:`The store_id field`}).option(`stripe-authorization`,{type:`string`,description:`The stripe.authorization field`}).option(`workers-ai-billing-mode`,{type:`string`,description:`Controls how Workers AI inference calls routed through this gateway are billed. Only 'postpaid' is currently supported.`,choices:[`postpaid`]}).option(`zdr`,{type:`boolean`,description:`The zdr field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`}).check(e=>{if([`stripe-authorization`].some(t=>e[t]!==void 0)){let t=[`stripe-authorization`].filter(t=>e[t]===void 0);if(t.length>0)throw Error(`${t.map(e=>`--`+e).join(`, `)} ${t.length===1?`is`:`are`} required when any --stripe-* flag is set`)}return!0})}const Fe={command:`update <id>`,describe:`Updates an existing AI Gateway dataset.`,builder:Pe,handler:async t=>{if(t.dryRun){l({command:`cf ai-gateway update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/gateways/${t.id==null?`<id>`:encodeURIComponent(String(t.id))}`,pathParams:{id:String(t.id??``)},bodyKind:`json`,body:t.body===void 0?s({authentication:t.authentication,cache_invalidate_on_update:t[`cache-invalidate-on-update`],cache_ttl:t[`cache-ttl`],collect_logs:t[`collect-logs`],guardrails:{prompt:{P1:d(t[`guardrails-prompt-p1`],`guardrails-prompt-p1`,`text`),S1:d(t[`guardrails-prompt-s1`],`guardrails-prompt-s1`,`text`),S10:d(t[`guardrails-prompt-s10`],`guardrails-prompt-s10`,`text`),S11:d(t[`guardrails-prompt-s11`],`guardrails-prompt-s11`,`text`),S12:d(t[`guardrails-prompt-s12`],`guardrails-prompt-s12`,`text`),S13:d(t[`guardrails-prompt-s13`],`guardrails-prompt-s13`,`text`),S2:d(t[`guardrails-prompt-s2`],`guardrails-prompt-s2`,`text`),S3:d(t[`guardrails-prompt-s3`],`guardrails-prompt-s3`,`text`),S4:d(t[`guardrails-prompt-s4`],`guardrails-prompt-s4`,`text`),S5:d(t[`guardrails-prompt-s5`],`guardrails-prompt-s5`,`text`),S6:d(t[`guardrails-prompt-s6`],`guardrails-prompt-s6`,`text`),S7:d(t[`guardrails-prompt-s7`],`guardrails-prompt-s7`,`text`),S8:d(t[`guardrails-prompt-s8`],`guardrails-prompt-s8`,`text`),S9:d(t[`guardrails-prompt-s9`],`guardrails-prompt-s9`,`text`)},response:{P1:d(t[`guardrails-response-p1`],`guardrails-response-p1`,`text`),S1:d(t[`guardrails-response-s1`],`guardrails-response-s1`,`text`),S10:d(t[`guardrails-response-s10`],`guardrails-response-s10`,`text`),S11:d(t[`guardrails-response-s11`],`guardrails-response-s11`,`text`),S12:d(t[`guardrails-response-s12`],`guardrails-response-s12`,`text`),S13:d(t[`guardrails-response-s13`],`guardrails-response-s13`,`text`),S2:d(t[`guardrails-response-s2`],`guardrails-response-s2`,`text`),S3:d(t[`guardrails-response-s3`],`guardrails-response-s3`,`text`),S4:d(t[`guardrails-response-s4`],`guardrails-response-s4`,`text`),S5:d(t[`guardrails-response-s5`],`guardrails-response-s5`,`text`),S6:d(t[`guardrails-response-s6`],`guardrails-response-s6`,`text`),S7:d(t[`guardrails-response-s7`],`guardrails-response-s7`,`text`),S8:d(t[`guardrails-response-s8`],`guardrails-response-s8`,`text`),S9:d(t[`guardrails-response-s9`],`guardrails-response-s9`,`text`)}},log_management:t[`log-management`],log_management_strategy:d(t[`log-management-strategy`],`log-management-strategy`,`text`),logpush:t.logpush,logpush_public_key:d(t[`logpush-public-key`],`logpush-public-key`,`text`),rate_limiting_interval:t[`rate-limiting-interval`],rate_limiting_limit:t[`rate-limiting-limit`],rate_limiting_technique:d(t[`rate-limiting-technique`],`rate-limiting-technique`,`text`),retry_backoff:d(t[`retry-backoff`],`retry-backoff`,`text`),retry_delay:t[`retry-delay`],retry_max_attempts:t[`retry-max-attempts`],spend_limits:{enabled:t[`spend-limits-enabled`]},store_id:d(t[`store-id`],`store-id`,`text`),stripe:{authorization:d(t[`stripe-authorization`],`stripe-authorization`,`text`)},workers_ai_billing_mode:d(t[`workers-ai-billing-mode`],`workers-ai-billing-mode`,`text`),zdr:t.zdr}):o(t.body)});return}let n=await a(t),i=t.local?f:await r(n);if(t.accountId=i,t.body){let e=o(t.body);c(await u(`Updating`,async()=>n.aiGateway.update({...e,account_id:i,id:t.id})),{successLabel:`Updated`});return}if(t[`cache-invalidate-on-update`]===void 0)throw Error(`--cache-invalidate-on-update is required (or pass --body with this field set).`);if(t[`cache-ttl`]===void 0)throw Error(`--cache-ttl is required (or pass --body with this field set).`);if(t[`collect-logs`]===void 0)throw Error(`--collect-logs is required (or pass --body with this field set).`);if(t[`rate-limiting-interval`]===void 0)throw Error(`--rate-limiting-interval is required (or pass --body with this field set).`);if(t[`rate-limiting-limit`]===void 0)throw Error(`--rate-limiting-limit is required (or pass --body with this field set).`);let p=s({authentication:t.authentication,cache_invalidate_on_update:t[`cache-invalidate-on-update`],cache_ttl:t[`cache-ttl`],collect_logs:t[`collect-logs`],guardrails:{prompt:{P1:d(t[`guardrails-prompt-p1`],`guardrails-prompt-p1`,`text`),S1:d(t[`guardrails-prompt-s1`],`guardrails-prompt-s1`,`text`),S10:d(t[`guardrails-prompt-s10`],`guardrails-prompt-s10`,`text`),S11:d(t[`guardrails-prompt-s11`],`guardrails-prompt-s11`,`text`),S12:d(t[`guardrails-prompt-s12`],`guardrails-prompt-s12`,`text`),S13:d(t[`guardrails-prompt-s13`],`guardrails-prompt-s13`,`text`),S2:d(t[`guardrails-prompt-s2`],`guardrails-prompt-s2`,`text`),S3:d(t[`guardrails-prompt-s3`],`guardrails-prompt-s3`,`text`),S4:d(t[`guardrails-prompt-s4`],`guardrails-prompt-s4`,`text`),S5:d(t[`guardrails-prompt-s5`],`guardrails-prompt-s5`,`text`),S6:d(t[`guardrails-prompt-s6`],`guardrails-prompt-s6`,`text`),S7:d(t[`guardrails-prompt-s7`],`guardrails-prompt-s7`,`text`),S8:d(t[`guardrails-prompt-s8`],`guardrails-prompt-s8`,`text`),S9:d(t[`guardrails-prompt-s9`],`guardrails-prompt-s9`,`text`)},response:{P1:d(t[`guardrails-response-p1`],`guardrails-response-p1`,`text`),S1:d(t[`guardrails-response-s1`],`guardrails-response-s1`,`text`),S10:d(t[`guardrails-response-s10`],`guardrails-response-s10`,`text`),S11:d(t[`guardrails-response-s11`],`guardrails-response-s11`,`text`),S12:d(t[`guardrails-response-s12`],`guardrails-response-s12`,`text`),S13:d(t[`guardrails-response-s13`],`guardrails-response-s13`,`text`),S2:d(t[`guardrails-response-s2`],`guardrails-response-s2`,`text`),S3:d(t[`guardrails-response-s3`],`guardrails-response-s3`,`text`),S4:d(t[`guardrails-response-s4`],`guardrails-response-s4`,`text`),S5:d(t[`guardrails-response-s5`],`guardrails-response-s5`,`text`),S6:d(t[`guardrails-response-s6`],`guardrails-response-s6`,`text`),S7:d(t[`guardrails-response-s7`],`guardrails-response-s7`,`text`),S8:d(t[`guardrails-response-s8`],`guardrails-response-s8`,`text`),S9:d(t[`guardrails-response-s9`],`guardrails-response-s9`,`text`)}},log_management:t[`log-management`],log_management_strategy:d(t[`log-management-strategy`],`log-management-strategy`,`text`),logpush:t.logpush,logpush_public_key:d(t[`logpush-public-key`],`logpush-public-key`,`text`),rate_limiting_interval:t[`rate-limiting-interval`],rate_limiting_limit:t[`rate-limiting-limit`],rate_limiting_technique:d(t[`rate-limiting-technique`],`rate-limiting-technique`,`text`),retry_backoff:d(t[`retry-backoff`],`retry-backoff`,`text`),retry_delay:t[`retry-delay`],retry_max_attempts:t[`retry-max-attempts`],spend_limits:{enabled:t[`spend-limits-enabled`]},store_id:d(t[`store-id`],`store-id`,`text`),stripe:{authorization:d(t[`stripe-authorization`],`stripe-authorization`,`text`)},workers_ai_billing_mode:d(t[`workers-ai-billing-mode`],`workers-ai-billing-mode`,`text`),zdr:t.zdr});c(await u(`Updating`,async()=>n.aiGateway.update({...p,account_id:i,id:t.id})),{successLabel:`Updated`})}};function Ie(e){return e.positional(`provider`,{type:`string`,description:`Provider`,demandOption:!0}).option(`gateway-id`,{type:`string`,description:`gateway id`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Le={command:`get <provider>`,describe:`Retrieves the endpoint URL for an AI Gateway.`,builder:Ie,handler:async t=>{if(t.dryRun){l({command:`cf ai-gateway urls get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/gateways/${t[`gateway-id`]==null?`<gateway-id>`:encodeURIComponent(String(t[`gateway-id`]))}/url/${t.provider==null?`<provider>`:encodeURIComponent(String(t.provider))}`,pathParams:{"gateway-id":String(t[`gateway-id`]??``),provider:String(t.provider??``)},bodyKind:`none`});return}let n=await a(t),i=t.local?f:await r(n);t.accountId=i,c(await u(`Loading`,async()=>n.aiGateway.urls.get({account_id:i,gateway_id:t[`gateway-id`],provider:t.provider})),{successLabel:`Loaded`})}},Re={command:`urls`,describe:`Operations for urls`,builder:e=>e.command(Le).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},ze={command:`ai-gateway`,describe:`Proxy, cache, rate-limit, and observe requests to AI providers — OpenAI, Anthropic, Workers AI, and more`,builder:e=>e.command(ee).command(E).command(ue).command(fe).command(Fe).command(w).command(q).command(X).command(ce).command(Te).command(Ne).command(Re).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{ze as default};
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env node
2
- import{C as e,D as t,E as n,T as r,_ as i,i as a,n as o}from"./auth-ffdf9yR0.mjs";import{n as s,t as c}from"./body-parser-DKa8Ipg1.mjs";import{t as l}from"./output-BJFNwj7b.mjs";import{n as u,t as d}from"./progress-CrCGTq7N.mjs";import{n as f,t as p}from"./input-validation-zEO81MWN.mjs";import{t as m}from"./local-VJaJ3BZ1.mjs";import{t as h}from"./cli-types-CRIDdDw3.mjs";import{n as ee,t as te}from"./raw-fetch-Dlccg0Tr.mjs";function g(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.`,demandOption:!0}).option(`ai-search-options-cache-cache-threshold`,{type:`string`,description:`The ai_search_options.cache.cache_threshold field`,choices:[`super_strict_match`,`close_enough`,`flexible_friend`,`anything_goes`]}).option(`ai-search-options-cache-enabled`,{type:`boolean`,description:`The ai_search_options.cache.enabled field`}).option(`ai-search-options-query-rewrite-enabled`,{type:`boolean`,description:`The ai_search_options.query_rewrite.enabled field`}).option(`ai-search-options-query-rewrite-rewrite-prompt`,{type:`string`,description:`The ai_search_options.query_rewrite.rewrite_prompt field`}).option(`ai-search-options-reranking-enabled`,{type:`boolean`,description:`The ai_search_options.reranking.enabled field`}).option(`ai-search-options-reranking-match-threshold`,{type:`number`,description:`The ai_search_options.reranking.match_threshold field`,default:.4}).option(`ai-search-options-retrieval-context-expansion`,{type:`number`,description:`The ai_search_options.retrieval.context_expansion field`,default:0}).option(`ai-search-options-retrieval-fusion-method`,{type:`string`,description:`The ai_search_options.retrieval.fusion_method field`,choices:[`max`,`rrf`]}).option(`ai-search-options-retrieval-keyword-match-mode`,{type:`string`,description:`Controls which documents are candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term, ranked by BM25 relevance. When omitted, falls back to the instance-level retrieval_options.keyword_match_mode, then to 'and'.`,choices:[`and`,`or`]}).option(`ai-search-options-retrieval-match-threshold`,{type:`number`,description:`The ai_search_options.retrieval.match_threshold field`,default:.4}).option(`ai-search-options-retrieval-max-num-results`,{type:`number`,description:`The ai_search_options.retrieval.max_num_results field`,default:10}).option(`ai-search-options-retrieval-retrieval-type`,{type:`string`,description:`The ai_search_options.retrieval.retrieval_type field`,choices:[`vector`,`keyword`,`hybrid`]}).option(`ai-search-options-retrieval-return-on-failure`,{type:`boolean`,description:`The ai_search_options.retrieval.return_on_failure field`,default:!0}).option(`stream`,{type:`boolean`,description:`The stream field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const _={command:`chat-completions <id>`,describe:`Performs a chat completion request against an AI Search instance, using indexed content as context for generating responses.`,builder:g,handler:async t=>{if(t.dryRun){u({command:`cf ai-search chat-completions`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-search/instances/${t.id==null?`<id>`:encodeURIComponent(String(t.id))}/chat/completions`,pathParams:{id:String(t.id??``)},bodyKind:`json`,body:t.body===void 0?c({ai_search_options:{cache:{cache_threshold:f(t[`ai-search-options-cache-cache-threshold`],`ai-search-options-cache-cache-threshold`,`text`),enabled:t[`ai-search-options-cache-enabled`]},query_rewrite:{enabled:t[`ai-search-options-query-rewrite-enabled`],rewrite_prompt:f(t[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:t[`ai-search-options-reranking-enabled`],match_threshold:t[`ai-search-options-reranking-match-threshold`]},retrieval:{context_expansion:t[`ai-search-options-retrieval-context-expansion`],fusion_method:f(t[`ai-search-options-retrieval-fusion-method`],`ai-search-options-retrieval-fusion-method`,`text`),keyword_match_mode:f(t[`ai-search-options-retrieval-keyword-match-mode`],`ai-search-options-retrieval-keyword-match-mode`,`text`),match_threshold:t[`ai-search-options-retrieval-match-threshold`],max_num_results:t[`ai-search-options-retrieval-max-num-results`],retrieval_type:f(t[`ai-search-options-retrieval-retrieval-type`],`ai-search-options-retrieval-retrieval-type`,`text`),return_on_failure:t[`ai-search-options-retrieval-return-on-failure`]}},stream:t.stream}):s(t.body)});return}let n=await o(t),r=t.local?m:await i(n);if(t.accountId=r,t.body){let e=s(t.body);l(await d(`Creating`,async()=>n.aiSearch.chatCompletions({...e,account_id:r,id:t.id})),{successLabel:`Created`});return}let a=c({ai_search_options:{cache:{cache_threshold:f(t[`ai-search-options-cache-cache-threshold`],`ai-search-options-cache-cache-threshold`,`text`),enabled:t[`ai-search-options-cache-enabled`]},query_rewrite:{enabled:t[`ai-search-options-query-rewrite-enabled`],rewrite_prompt:f(t[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:t[`ai-search-options-reranking-enabled`],match_threshold:t[`ai-search-options-reranking-match-threshold`]},retrieval:{context_expansion:t[`ai-search-options-retrieval-context-expansion`],fusion_method:f(t[`ai-search-options-retrieval-fusion-method`],`ai-search-options-retrieval-fusion-method`,`text`),keyword_match_mode:f(t[`ai-search-options-retrieval-keyword-match-mode`],`ai-search-options-retrieval-keyword-match-mode`,`text`),match_threshold:t[`ai-search-options-retrieval-match-threshold`],max_num_results:t[`ai-search-options-retrieval-max-num-results`],retrieval_type:f(t[`ai-search-options-retrieval-retrieval-type`],`ai-search-options-retrieval-retrieval-type`,`text`),return_on_failure:t[`ai-search-options-retrieval-return-on-failure`]}},stream:t.stream});l(await d(`Creating`,async()=>n.aiSearch.chatCompletions({...a,account_id:r,id:t.id})),{successLabel:`Created`})}};function v(e){return e.option(`ai-gateway-id`,{type:`string`,description:`The ai_gateway_id field`}).option(`ai-search-model`,{type:`string`,description:`The ai_search_model field`,choices:`@cf/meta/llama-3.3-70b-instruct-fp8-fast,@cf/zai-org/glm-4.7-flash,@cf/meta/llama-3.1-8b-instruct-fast,@cf/meta/llama-3.1-8b-instruct-fp8,@cf/meta/llama-4-scout-17b-16e-instruct,@cf/qwen/qwen3-30b-a3b-fp8,@cf/deepseek-ai/deepseek-r1-distill-qwen-32b,@cf/moonshotai/kimi-k2-instruct,@cf/google/gemma-3-12b-it,@cf/google/gemma-4-26b-a4b-it,@cf/moonshotai/kimi-k2.5,anthropic/claude-3-7-sonnet,anthropic/claude-sonnet-4,anthropic/claude-opus-4,anthropic/claude-3-5-haiku,cerebras/qwen-3-235b-a22b-instruct,cerebras/qwen-3-235b-a22b-thinking,cerebras/llama-3.3-70b,cerebras/llama-4-maverick-17b-128e-instruct,cerebras/llama-4-scout-17b-16e-instruct,cerebras/gpt-oss-120b,google-ai-studio/gemini-2.5-flash,google-ai-studio/gemini-2.5-pro,grok/grok-4,groq/llama-3.3-70b-versatile,groq/llama-3.1-8b-instant,openai/gpt-5,openai/gpt-5-mini,openai/gpt-5-nano`.split(`,`)}).option(`cache`,{type:`boolean`,description:`The cache field`,default:!0}).option(`cache-threshold`,{type:`string`,description:`The cache_threshold field`,choices:[`super_strict_match`,`close_enough`,`flexible_friend`,`anything_goes`],default:`close_enough`}).option(`chunk`,{type:`boolean`,description:`The chunk field`,default:!0}).option(`chunk-overlap`,{type:`number`,description:`The chunk_overlap field`,default:10}).option(`chunk-size`,{type:`number`,description:`The chunk_size field`}).option(`embedding-model`,{type:`string`,description:`The embedding_model field`,choices:[`@cf/qwen/qwen3-embedding-0.6b`,`@cf/qwen/qwen3-vl-embedding-2b`,`@cf/baai/bge-m3`,`@cf/baai/bge-large-en-v1.5`,`@cf/google/embeddinggemma-300m`,`google-ai-studio/gemini-embedding-001`,`google-ai-studio/gemini-embedding-2-preview`,`google-ai-studio/gemini-embedding-2`,`openai/text-embedding-3-small`,`openai/text-embedding-3-large`]}).option(`fusion-method`,{type:`string`,description:`The fusion_method field`,choices:[`max`,`rrf`],default:`rrf`}).option(`hybrid-search-enabled`,{type:`boolean`,description:`Deprecated — use index_method instead.`,default:!1}).option(`id`,{type:`string`,description:`AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.`}).option(`index-method-keyword`,{type:`boolean`,description:`Enable keyword (BM25) storage backend.`}).option(`index-method-vector`,{type:`boolean`,description:`Enable vector (embedding) storage backend.`}).option(`indexing-options-keyword-tokenizer`,{type:`string`,description:`Tokenizer used for keyword search indexing. porter provides word-level tokenization with Porter stemming (good for natural language queries). trigram enables character-level substring matching (good for partial matches, code, identifiers). Changing this triggers a full re-index. Defaults to porter.`,choices:[`porter`,`trigram`],default:`porter`}).option(`max-num-results`,{type:`number`,description:`The max_num_results field`,default:10}).option(`metadata-created-from-aisearch-wizard`,{type:`boolean`,description:`The metadata.created_from_aisearch_wizard field`}).option(`metadata-worker-domain`,{type:`string`,description:`The metadata.worker_domain field`}).option(`public-endpoint-params-authorized-hosts`,{type:`string`,array:!0,description:`The public_endpoint_params.authorized_hosts field`}).option(`public-endpoint-params-chat-completions-endpoint-disabled`,{type:`boolean`,description:`Disable chat completions endpoint for this public endpoint`,default:!1}).option(`public-endpoint-params-custom-domains`,{type:`string`,array:!0,description:`Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged).`}).option(`public-endpoint-params-enabled`,{type:`boolean`,description:`The public_endpoint_params.enabled field`,default:!1}).option(`public-endpoint-params-mcp-description`,{type:`string`,description:`The public_endpoint_params.mcp.description field`,default:`Finds exactly what you're looking for`}).option(`public-endpoint-params-mcp-disabled`,{type:`boolean`,description:`Disable MCP endpoint for this public endpoint`,default:!1}).option(`public-endpoint-params-rate-limit-period-ms`,{type:`number`,description:`The public_endpoint_params.rate_limit.period_ms field`}).option(`public-endpoint-params-rate-limit-requests`,{type:`number`,description:`The public_endpoint_params.rate_limit.requests field`}).option(`public-endpoint-params-rate-limit-technique`,{type:`string`,description:`The public_endpoint_params.rate_limit.technique field`,choices:[`fixed`,`sliding`]}).option(`public-endpoint-params-search-endpoint-disabled`,{type:`boolean`,description:`Disable search endpoint for this public endpoint`,default:!1}).option(`reranking`,{type:`boolean`,description:`The reranking field`,default:!1}).option(`reranking-model`,{type:`string`,description:`The reranking_model field`,choices:[`@cf/baai/bge-reranker-base`]}).option(`retrieval-options-keyword-match-mode`,{type:`string`,description:`Controls which documents are candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term, ranked by BM25 relevance. When omitted on an update, the existing stored value is preserved; when never set, search falls back to 'and'.`,choices:[`and`,`or`]}).option(`rewrite-model`,{type:`string`,description:`The rewrite_model field`,choices:`@cf/meta/llama-3.3-70b-instruct-fp8-fast,@cf/zai-org/glm-4.7-flash,@cf/meta/llama-3.1-8b-instruct-fast,@cf/meta/llama-3.1-8b-instruct-fp8,@cf/meta/llama-4-scout-17b-16e-instruct,@cf/qwen/qwen3-30b-a3b-fp8,@cf/deepseek-ai/deepseek-r1-distill-qwen-32b,@cf/moonshotai/kimi-k2-instruct,@cf/google/gemma-3-12b-it,@cf/google/gemma-4-26b-a4b-it,@cf/moonshotai/kimi-k2.5,anthropic/claude-3-7-sonnet,anthropic/claude-sonnet-4,anthropic/claude-opus-4,anthropic/claude-3-5-haiku,cerebras/qwen-3-235b-a22b-instruct,cerebras/qwen-3-235b-a22b-thinking,cerebras/llama-3.3-70b,cerebras/llama-4-maverick-17b-128e-instruct,cerebras/llama-4-scout-17b-16e-instruct,cerebras/gpt-oss-120b,google-ai-studio/gemini-2.5-flash,google-ai-studio/gemini-2.5-pro,grok/grok-4,groq/llama-3.3-70b-versatile,groq/llama-3.1-8b-instant,openai/gpt-5,openai/gpt-5-mini,openai/gpt-5-nano`.split(`,`)}).option(`rewrite-query`,{type:`boolean`,description:`The rewrite_query field`,default:!1}).option(`score-threshold`,{type:`number`,description:`The score_threshold field`,default:.4}).option(`source`,{type:`string`,description:`The source field`}).option(`source-params-exclude-items`,{type:`string`,array:!0,description:`List of path patterns to exclude. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /admin/** matches /admin/users and /admin/settings/advanced)`}).option(`source-params-include-items`,{type:`string`,array:!0,description:`List of path patterns to include. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /blog/** matches /blog/post and /blog/2024/post)`}).option(`source-params-prefix`,{type:`string`,description:`The source_params.prefix field`}).option(`source-params-r2-jurisdiction`,{type:`string`,description:`The source_params.r2_jurisdiction field`,default:`default`}).option(`source-params-web-crawler-parse-options-include-images`,{type:`boolean`,description:`The source_params.web_crawler.parse_options.include_images field`,default:!1}).option(`source-params-web-crawler-parse-options-specific-sitemaps`,{type:`string`,array:!0,description:`List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'.`}).option(`source-params-web-crawler-parse-options-use-browser-rendering`,{type:`boolean`,description:`The source_params.web_crawler.parse_options.use_browser_rendering field`,default:!0}).option(`source-params-web-crawler-parse-type`,{type:`string`,description:`The source_params.web_crawler.parse_type field`,choices:[`sitemap`,`crawl`],default:`sitemap`}).option(`token-id`,{type:`string`,description:`The token_id field`}).option(`type`,{type:`string`,description:`The type field`,choices:[`r2`,`web-crawler`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`}).check(e=>{if([`index-method-keyword`,`index-method-vector`].some(t=>e[t]!==void 0)){let t=[`index-method-keyword`,`index-method-vector`].filter(t=>e[t]===void 0);if(t.length>0)throw Error(`${t.map(e=>`--`+e).join(`, `)} ${t.length===1?`is`:`are`} required when any --index_method-* flag is set`)}return!0})}const y={command:`create`,describe:`Create a new AI Search instance with the given configuration.`,builder:v,handler:async n=>{if(n.dryRun){u({command:`cf ai-search create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-search/instances`,pathParams:{},bodyKind:`json`,body:n.body===void 0?c({ai_gateway_id:f(n[`ai-gateway-id`],`ai-gateway-id`,`text`),ai_search_model:f(n[`ai-search-model`],`ai-search-model`,`text`),cache:n.cache,cache_threshold:f(n[`cache-threshold`],`cache-threshold`,`text`),chunk:n.chunk,chunk_overlap:n[`chunk-overlap`],chunk_size:n[`chunk-size`],embedding_model:f(n[`embedding-model`],`embedding-model`,`text`),fusion_method:f(n[`fusion-method`],`fusion-method`,`text`),hybrid_search_enabled:n[`hybrid-search-enabled`],id:f(n.id,`id`,`text`),index_method:{keyword:n[`index-method-keyword`],vector:n[`index-method-vector`]},indexing_options:{keyword_tokenizer:f(n[`indexing-options-keyword-tokenizer`],`indexing-options-keyword-tokenizer`,`text`)},max_num_results:n[`max-num-results`],metadata:{created_from_aisearch_wizard:n[`metadata-created-from-aisearch-wizard`],worker_domain:f(n[`metadata-worker-domain`],`metadata-worker-domain`,`text`)},public_endpoint_params:{authorized_hosts:n[`public-endpoint-params-authorized-hosts`],chat_completions_endpoint:{disabled:n[`public-endpoint-params-chat-completions-endpoint-disabled`]},custom_domains:n[`public-endpoint-params-custom-domains`],enabled:n[`public-endpoint-params-enabled`],mcp:{description:f(n[`public-endpoint-params-mcp-description`],`public-endpoint-params-mcp-description`,`text`),disabled:n[`public-endpoint-params-mcp-disabled`]},rate_limit:{period_ms:n[`public-endpoint-params-rate-limit-period-ms`],requests:n[`public-endpoint-params-rate-limit-requests`],technique:f(n[`public-endpoint-params-rate-limit-technique`],`public-endpoint-params-rate-limit-technique`,`text`)},search_endpoint:{disabled:n[`public-endpoint-params-search-endpoint-disabled`]}},reranking:n.reranking,reranking_model:f(n[`reranking-model`],`reranking-model`,`text`),retrieval_options:{keyword_match_mode:f(n[`retrieval-options-keyword-match-mode`],`retrieval-options-keyword-match-mode`,`text`)},rewrite_model:f(n[`rewrite-model`],`rewrite-model`,`text`),rewrite_query:n[`rewrite-query`],score_threshold:n[`score-threshold`],source:f(n.source,`source`,`text`),source_params:{exclude_items:n[`source-params-exclude-items`],include_items:n[`source-params-include-items`],prefix:f(n[`source-params-prefix`],`source-params-prefix`,`text`),r2_jurisdiction:f(n[`source-params-r2-jurisdiction`],`source-params-r2-jurisdiction`,`text`),web_crawler:{parse_options:{include_images:n[`source-params-web-crawler-parse-options-include-images`],specific_sitemaps:n[`source-params-web-crawler-parse-options-specific-sitemaps`],use_browser_rendering:n[`source-params-web-crawler-parse-options-use-browser-rendering`]},parse_type:f(n[`source-params-web-crawler-parse-type`],`source-params-web-crawler-parse-type`,`text`)}},token_id:f(n[`token-id`],`token-id`,`text`),type:f(n.type,`type`,`text`)}):s(n.body)});return}let r=await o(n),a=n.local?m:await i(r);if(n.accountId=a,n.body){let e=s(n.body);l(await d(`Creating`,async()=>r.aiSearch.create({...e,account_id:a})),{successLabel:`Created`});return}n.id===void 0&&(n.id=await t(`id`,`AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.`));let p=c({ai_gateway_id:f(n[`ai-gateway-id`],`ai-gateway-id`,`text`),ai_search_model:f(n[`ai-search-model`],`ai-search-model`,`text`),cache:n.cache,cache_threshold:f(n[`cache-threshold`],`cache-threshold`,`text`),chunk:n.chunk,chunk_overlap:n[`chunk-overlap`],chunk_size:n[`chunk-size`],embedding_model:f(n[`embedding-model`],`embedding-model`,`text`),fusion_method:f(n[`fusion-method`],`fusion-method`,`text`),hybrid_search_enabled:n[`hybrid-search-enabled`],id:f(n.id,`id`,`text`),index_method:{keyword:n[`index-method-keyword`],vector:n[`index-method-vector`]},indexing_options:{keyword_tokenizer:f(n[`indexing-options-keyword-tokenizer`],`indexing-options-keyword-tokenizer`,`text`)},max_num_results:n[`max-num-results`],metadata:{created_from_aisearch_wizard:n[`metadata-created-from-aisearch-wizard`],worker_domain:f(n[`metadata-worker-domain`],`metadata-worker-domain`,`text`)},public_endpoint_params:{authorized_hosts:n[`public-endpoint-params-authorized-hosts`],chat_completions_endpoint:{disabled:n[`public-endpoint-params-chat-completions-endpoint-disabled`]},custom_domains:n[`public-endpoint-params-custom-domains`],enabled:n[`public-endpoint-params-enabled`],mcp:{description:f(n[`public-endpoint-params-mcp-description`],`public-endpoint-params-mcp-description`,`text`),disabled:n[`public-endpoint-params-mcp-disabled`]},rate_limit:{period_ms:n[`public-endpoint-params-rate-limit-period-ms`],requests:n[`public-endpoint-params-rate-limit-requests`],technique:f(n[`public-endpoint-params-rate-limit-technique`],`public-endpoint-params-rate-limit-technique`,`text`)},search_endpoint:{disabled:n[`public-endpoint-params-search-endpoint-disabled`]}},reranking:n.reranking,reranking_model:f(n[`reranking-model`],`reranking-model`,`text`),retrieval_options:{keyword_match_mode:f(n[`retrieval-options-keyword-match-mode`],`retrieval-options-keyword-match-mode`,`text`)},rewrite_model:f(n[`rewrite-model`],`rewrite-model`,`text`),rewrite_query:n[`rewrite-query`],score_threshold:n[`score-threshold`],source:f(n.source,`source`,`text`),source_params:{exclude_items:n[`source-params-exclude-items`],include_items:n[`source-params-include-items`],prefix:f(n[`source-params-prefix`],`source-params-prefix`,`text`),r2_jurisdiction:f(n[`source-params-r2-jurisdiction`],`source-params-r2-jurisdiction`,`text`),web_crawler:{parse_options:{include_images:n[`source-params-web-crawler-parse-options-include-images`],specific_sitemaps:n[`source-params-web-crawler-parse-options-specific-sitemaps`],use_browser_rendering:n[`source-params-web-crawler-parse-options-use-browser-rendering`]},parse_type:f(n[`source-params-web-crawler-parse-type`],`source-params-web-crawler-parse-type`,`text`)}},token_id:f(n[`token-id`],`token-id`,`text`),type:f(n.type,`type`,`text`)});l(await d(`Creating`,async()=>r.aiSearch.create({...p,account_id:a})),{successLabel:`Created`})}};function b(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 x={command:`delete <id>`,describe:`Permanently delete an AI Search instance and all its indexed data.`,builder:b,handler:async t=>{if(t.dryRun){u({command:`cf ai-search delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-search/instances/${t.id==null?`<id>`:encodeURIComponent(String(t.id))}`,pathParams:{id:String(t.id??``)},bodyKind:`none`});return}let n=await o(t),a=t.local?m:await i(n);if(t.accountId=a,!await r({force:!!t.force,message:`This will permanently delete the AI Search instance and all its indexed data.`})){process.stderr.write(`Aborted.
3
- `);return}l(await d(`Deleting`,async()=>n.aiSearch.delete({account_id:a,id:t.id})),{successLabel:`Deleted`})}};function S(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 C={command:`get <id>`,describe:`Retrieve the configuration and status of an AI Search instance.`,builder:S,handler:async t=>{if(t.dryRun){u({command:`cf ai-search get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-search/instances/${t.id==null?`<id>`:encodeURIComponent(String(t.id))}`,pathParams:{id:String(t.id??``)},bodyKind:`none`});return}let n=await o(t),r=t.local?m:await i(n);t.accountId=r,l(await d(`Loading`,async()=>n.aiSearch.get({account_id:r,id:t.id})),{successLabel:`Loaded`})}};function w(e){return e.positional(`job-id`,{type:`string`,description:`Job ID`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.`,demandOption:!0}).option(`action`,{type:`string`,description:`The action field`,choices:[`cancel`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const T={command:`cancel <job-id>`,describe:`Cancel an in-progress indexing job for an AI Search instance.`,builder:w,handler:async t=>{if(t.dryRun){u({command:`cf ai-search jobs cancel`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-search/instances/${t.id==null?`<id>`:encodeURIComponent(String(t.id))}/jobs/${t[`job-id`]==null?`<job-id>`:encodeURIComponent(String(t[`job-id`]))}`,pathParams:{id:String(t.id??``),"job-id":String(t[`job-id`]??``)},bodyKind:`json`,body:t.body===void 0?c({action:f(t.action,`action`,`text`)}):s(t.body)});return}let a=await o(t),p=t.local?m:await i(a);if(t.accountId=p,!await r({force:!!t.force,message:`This will cancel the running indexing job.`})){process.stderr.write(`Aborted.
4
- `);return}if(t.body){let e=s(t.body);l(await d(`Deleting`,async()=>a.aiSearch.jobs.cancel({...e,account_id:p,id:t.id,job_id:t[`job-id`]})),{successLabel:`Deleted`});return}t.action===void 0&&(t.action=await n(`action`,`The action field`,[`cancel`]));let h=c({action:f(t.action,`action`,`text`)});l(await d(`Deleting`,async()=>a.aiSearch.jobs.cancel({...h,account_id:p,id:t.id,job_id:t[`job-id`]})),{successLabel:`Deleted`})}};function E(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.`,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 D={command:`create <id>`,describe:`Creates a new indexing job for an AI Search instance.`,builder:E,handler:async t=>{if(t.dryRun){u({command:`cf ai-search jobs create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-search/instances/${t.id==null?`<id>`:encodeURIComponent(String(t.id))}/jobs`,pathParams:{id:String(t.id??``)},bodyKind:`json`,body:t.body===void 0?c({description:f(t.description,`description`,`text`)}):s(t.body)});return}let n=await o(t),r=t.local?m:await i(n);if(t.accountId=r,t.body){let e=s(t.body);l(await d(`Creating`,async()=>n.aiSearch.jobs.create({...e,account_id:r,id:t.id})),{successLabel:`Created`});return}let a=c({description:f(t.description,`description`,`text`)});l(await d(`Creating`,async()=>n.aiSearch.jobs.create({...a,account_id:r,id:t.id})),{successLabel:`Created`})}};function O(e){return e.positional(`job-id`,{type:`string`,description:`Job ID`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const k={command:`get <job-id>`,describe:`Retrieves details for a specific AI Search indexing job.`,builder:O,handler:async t=>{if(t.dryRun){u({command:`cf ai-search jobs get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-search/instances/${t.id==null?`<id>`:encodeURIComponent(String(t.id))}/jobs/${t[`job-id`]==null?`<job-id>`:encodeURIComponent(String(t[`job-id`]))}`,pathParams:{id:String(t.id??``),"job-id":String(t[`job-id`]??``)},bodyKind:`none`});return}let n=await o(t),r=t.local?m:await i(n);t.accountId=r,l(await d(`Loading`,async()=>n.aiSearch.jobs.get({account_id:r,id:t.id,job_id:t[`job-id`]})),{successLabel:`Loaded`})}};function A(e){return e.option(`id`,{type:`string`,description:`AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.`,demandOption:!0}).option(`page`,{type:`number`,description:`Page`}).option(`per-page`,{type:`number`,description:`Per page`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const j={command:`list`,describe:`Lists indexing jobs for an AI Search instance.`,builder:A,handler:async t=>{let n={page:t.page,per_page:t[`per-page`]};if(t.dryRun){u({command:`cf ai-search jobs list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-search/instances/${t.id==null?`<id>`:encodeURIComponent(String(t.id))}/jobs`,pathParams:{id:String(t.id??``)},query:n,bodyKind:`none`});return}let r=await o(t),a=t.local?m:await i(r);t.accountId=a,l(await d(`Loading`,async()=>r.aiSearch.jobs.list({account_id:a,id:t.id,...n})),{successLabel:`Loaded`})}};function M(e){return e.positional(`job-id`,{type:`string`,description:`Job ID`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.`,demandOption:!0}).option(`page`,{type:`number`,description:`Page`}).option(`per-page`,{type:`number`,description:`Per page`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const N={command:`logs <job-id>`,describe:`Lists log entries for an AI Search indexing job.`,builder:M,handler:async t=>{let n={page:t.page,per_page:t[`per-page`]};if(t.dryRun){u({command:`cf ai-search jobs logs`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-search/instances/${t.id==null?`<id>`:encodeURIComponent(String(t.id))}/jobs/${t[`job-id`]==null?`<job-id>`:encodeURIComponent(String(t[`job-id`]))}/logs`,pathParams:{id:String(t.id??``),"job-id":String(t[`job-id`]??``)},query:n,bodyKind:`none`});return}let r=await o(t),a=t.local?m:await i(r);t.accountId=a,l(await d(`Loading`,async()=>r.aiSearch.jobs.logs({account_id:a,id:t.id,job_id:t[`job-id`],...n})),{successLabel:`Loaded`})}},P={command:`jobs`,describe:`Operations for jobs`,builder:e=>e.command(T).command(D).command(k).command(j).command(N).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function F(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 instances whose id contains this string (case-insensitive).`}).option(`namespace`,{type:`string`,description:`Filter by namespace.`}).option(`order-by`,{type:`string`,description:`Field to order results by.`,choices:[`created_at`]}).option(`order-by-direction`,{type:`string`,description:`Order direction.`,choices:[`asc`,`desc`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const I={command:`list`,describe:`List all AI Search instances in the account.`,builder:h(F),handler:async t=>{let n={page:t.page,per_page:t[`per-page`],search:t.search,namespace:t.namespace,order_by:t[`order-by`],order_by_direction:t[`order-by-direction`]};if(t.dryRun){u({command:`cf ai-search list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-search/instances`,pathParams:{},query:n,bodyKind:`none`});return}let r=await o(t),a=t.local?m:await i(r);t.accountId=a,l(await d(`Loading`,async()=>r.aiSearch.list({account_id:a,...n})),{successLabel:`Loaded`})}};function L(e){return e.option(`description`,{type:`string`,description:`Optional description for the namespace. Max 256 characters.`}).option(`name`,{type:`string`,description:`The name field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const R={command:`create`,describe:`Create a new namespace.`,builder:L,handler:async n=>{if(n.dryRun){u({command:`cf ai-search namespace create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-search/namespaces`,pathParams:{},bodyKind:`json`,body:n.body===void 0?c({description:f(n.description,`description`,`text`),name:f(n.name,`name`,`text`)}):s(n.body)});return}let r=await o(n),a=n.local?m:await i(r);if(n.accountId=a,n.body){let e=s(n.body);l(await d(`Creating`,async()=>r.aiSearch.namespace.create({...e,account_id:a})),{successLabel:`Created`});return}n.name===void 0&&(n.name=await t(`name`,`The name field`));let p=c({description:f(n.description,`description`,`text`),name:f(n.name,`name`,`text`)});l(await d(`Creating`,async()=>r.aiSearch.namespace.create({...p,account_id:a})),{successLabel:`Created`})}};function z(e){return e.positional(`name`,{type:`string`,description:`Name`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const B={command:`delete <name>`,describe:`Permanently delete a namespace. The namespace must be empty (no instances).`,builder:z,handler:async t=>{if(t.dryRun){u({command:`cf ai-search namespace delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-search/namespaces/${t.name==null?`<name>`:encodeURIComponent(String(t.name))}`,pathParams:{name:String(t.name??``)},bodyKind:`none`});return}let n=await o(t),a=t.local?m:await i(n);if(t.accountId=a,!await r({force:!!t.force,message:`This will permanently delete the namespace.`})){process.stderr.write(`Aborted.
5
- `);return}l(await d(`Deleting`,async()=>n.aiSearch.namespace.delete({account_id:a,name:t.name})),{successLabel:`Deleted`})}};function V(e){return e.positional(`name`,{type:`string`,description:`Name`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const H={command:`get <name>`,describe:`Read namespace.`,builder:V,handler:async t=>{if(t.dryRun){u({command:`cf ai-search namespace get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-search/namespaces/${t.name==null?`<name>`:encodeURIComponent(String(t.name))}`,pathParams:{name:String(t.name??``)},bodyKind:`none`});return}let n=await o(t),r=t.local?m:await i(n);t.accountId=r,l(await d(`Loading`,async()=>n.aiSearch.namespace.get({account_id:r,name:t.name})),{successLabel:`Loaded`})}};function U(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 W={command:`list`,describe:`List namespaces.`,builder:U,handler:async t=>{let n={page:t.page,per_page:t[`per-page`],search:t.search};if(t.dryRun){u({command:`cf ai-search namespace list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-search/namespaces`,pathParams:{},query:n,bodyKind:`none`});return}let r=await o(t),a=t.local?m:await i(r);t.accountId=a,l(await d(`Loading`,async()=>r.aiSearch.namespace.list({account_id:a,...n})),{successLabel:`Loaded`})}};function G(e){return e.positional(`name`,{type:`string`,description:`Name`,demandOption:!0}).option(`description`,{type:`string`,description:`Optional description for the namespace. Max 256 characters.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const K={command:`update <name>`,describe:`Update namespace.`,builder:G,handler:async t=>{if(t.dryRun){u({command:`cf ai-search namespace update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-search/namespaces/${t.name==null?`<name>`:encodeURIComponent(String(t.name))}`,pathParams:{name:String(t.name??``)},bodyKind:`json`,body:t.body===void 0?c({description:f(t.description,`description`,`text`)}):s(t.body)});return}let n=await o(t),r=t.local?m:await i(n);if(t.accountId=r,t.body){let e=s(t.body);l(await d(`Updating`,async()=>n.aiSearch.namespace.update({...e,account_id:r,name:t.name})),{successLabel:`Updated`});return}let a=c({description:f(t.description,`description`,`text`)});l(await d(`Updating`,async()=>n.aiSearch.namespace.update({...a,account_id:r,name:t.name})),{successLabel:`Updated`})}},q={command:`namespace`,describe:`Operations for namespace`,builder:e=>e.command(R).command(B).command(H).command(W).command(K).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function J(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace name`,demandOption:!0}).option(`ai-search-options-cache-cache-threshold`,{type:`string`,description:`The ai_search_options.cache.cache_threshold field`,choices:[`super_strict_match`,`close_enough`,`flexible_friend`,`anything_goes`]}).option(`ai-search-options-cache-enabled`,{type:`boolean`,description:`The ai_search_options.cache.enabled field`}).option(`ai-search-options-query-rewrite-enabled`,{type:`boolean`,description:`The ai_search_options.query_rewrite.enabled field`}).option(`ai-search-options-query-rewrite-rewrite-prompt`,{type:`string`,description:`The ai_search_options.query_rewrite.rewrite_prompt field`}).option(`ai-search-options-reranking-enabled`,{type:`boolean`,description:`The ai_search_options.reranking.enabled field`}).option(`ai-search-options-reranking-match-threshold`,{type:`number`,description:`The ai_search_options.reranking.match_threshold field`,default:.4}).option(`ai-search-options-retrieval-context-expansion`,{type:`number`,description:`The ai_search_options.retrieval.context_expansion field`,default:0}).option(`ai-search-options-retrieval-fusion-method`,{type:`string`,description:`The ai_search_options.retrieval.fusion_method field`,choices:[`max`,`rrf`]}).option(`ai-search-options-retrieval-keyword-match-mode`,{type:`string`,description:`Controls which documents are candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term, ranked by BM25 relevance. When omitted, falls back to the instance-level retrieval_options.keyword_match_mode, then to 'and'.`,choices:[`and`,`or`]}).option(`ai-search-options-retrieval-match-threshold`,{type:`number`,description:`The ai_search_options.retrieval.match_threshold field`,default:.4}).option(`ai-search-options-retrieval-max-num-results`,{type:`number`,description:`The ai_search_options.retrieval.max_num_results field`,default:10}).option(`ai-search-options-retrieval-retrieval-type`,{type:`string`,description:`The ai_search_options.retrieval.retrieval_type field`,choices:[`vector`,`keyword`,`hybrid`]}).option(`ai-search-options-retrieval-return-on-failure`,{type:`boolean`,description:`The ai_search_options.retrieval.return_on_failure field`,default:!0}).option(`stream`,{type:`boolean`,description:`The stream field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const Y={command:`completions <id>`,describe:`Performs a chat completion request against an AI Search instance, using indexed content as context for generating responses.`,builder:J,handler:async t=>{if(t.dryRun){u({command:`cf ai-search namespaces instances chat completions`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-search/namespaces/${t.name==null?`<name>`:encodeURIComponent(String(t.name))}/instances/${t.id==null?`<id>`:encodeURIComponent(String(t.id))}/chat/completions`,pathParams:{id:String(t.id??``),name:String(t.name??``)},bodyKind:`json`,body:t.body===void 0?c({ai_search_options:{cache:{cache_threshold:f(t[`ai-search-options-cache-cache-threshold`],`ai-search-options-cache-cache-threshold`,`text`),enabled:t[`ai-search-options-cache-enabled`]},query_rewrite:{enabled:t[`ai-search-options-query-rewrite-enabled`],rewrite_prompt:f(t[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:t[`ai-search-options-reranking-enabled`],match_threshold:t[`ai-search-options-reranking-match-threshold`]},retrieval:{context_expansion:t[`ai-search-options-retrieval-context-expansion`],fusion_method:f(t[`ai-search-options-retrieval-fusion-method`],`ai-search-options-retrieval-fusion-method`,`text`),keyword_match_mode:f(t[`ai-search-options-retrieval-keyword-match-mode`],`ai-search-options-retrieval-keyword-match-mode`,`text`),match_threshold:t[`ai-search-options-retrieval-match-threshold`],max_num_results:t[`ai-search-options-retrieval-max-num-results`],retrieval_type:f(t[`ai-search-options-retrieval-retrieval-type`],`ai-search-options-retrieval-retrieval-type`,`text`),return_on_failure:t[`ai-search-options-retrieval-return-on-failure`]}},stream:t.stream}):s(t.body)});return}let n=await o(t),r=t.local?m:await i(n);if(t.accountId=r,t.body){let e=s(t.body);l(await d(`Creating`,async()=>n.aiSearch.namespaces.instances.chat.completions({...e,account_id:r,name:t.name,id:t.id})),{successLabel:`Created`});return}let a=c({ai_search_options:{cache:{cache_threshold:f(t[`ai-search-options-cache-cache-threshold`],`ai-search-options-cache-cache-threshold`,`text`),enabled:t[`ai-search-options-cache-enabled`]},query_rewrite:{enabled:t[`ai-search-options-query-rewrite-enabled`],rewrite_prompt:f(t[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:t[`ai-search-options-reranking-enabled`],match_threshold:t[`ai-search-options-reranking-match-threshold`]},retrieval:{context_expansion:t[`ai-search-options-retrieval-context-expansion`],fusion_method:f(t[`ai-search-options-retrieval-fusion-method`],`ai-search-options-retrieval-fusion-method`,`text`),keyword_match_mode:f(t[`ai-search-options-retrieval-keyword-match-mode`],`ai-search-options-retrieval-keyword-match-mode`,`text`),match_threshold:t[`ai-search-options-retrieval-match-threshold`],max_num_results:t[`ai-search-options-retrieval-max-num-results`],retrieval_type:f(t[`ai-search-options-retrieval-retrieval-type`],`ai-search-options-retrieval-retrieval-type`,`text`),return_on_failure:t[`ai-search-options-retrieval-return-on-failure`]}},stream:t.stream});l(await d(`Creating`,async()=>n.aiSearch.namespaces.instances.chat.completions({...a,account_id:r,name:t.name,id:t.id})),{successLabel:`Created`})}},X={command:`chat`,describe:`Namespaces for organizing and managing AI Search instances, items, and jobs`,builder:e=>e.command(Y).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Z(e){return e.option(`name`,{type:`string`,description:`Namespace name`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.`,demandOption:!0}).option(`item-id`,{type:`string`,description:`Item 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 Q={command:`list`,describe:`Lists chunks for a specific item in an AI Search instance, including their text content.`,builder:Z,handler:async t=>{let n={limit:t.limit,offset:t.offset};if(t.dryRun){u({command:`cf ai-search namespaces instances items chunks list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-search/namespaces/${t.name==null?`<name>`:encodeURIComponent(String(t.name))}/instances/${t.id==null?`<id>`:encodeURIComponent(String(t.id))}/items/${t[`item-id`]==null?`<item-id>`:encodeURIComponent(String(t[`item-id`]))}/chunks`,pathParams:{id:String(t.id??``),"item-id":String(t[`item-id`]??``),name:String(t.name??``)},query:n,bodyKind:`none`});return}let r=await o(t),a=t.local?m:await i(r);t.accountId=a,l(await d(`Loading`,async()=>r.aiSearch.namespaces.instances.items.chunks.list({account_id:a,name:t.name,id:t.id,item_id:t[`item-id`],...n})),{successLabel:`Loaded`})}},ne={command:`chunks`,describe:`Namespaces for organizing and managing AI Search instances, items, and jobs`,builder:e=>e.command(Q).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function re(e){return e.positional(`item-id`,{type:`string`,description:`Item ID`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace name`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`text`,{type:`boolean`,description:`Decode the response body as UTF-8 text instead of writing raw bytes`,default:!1})}const ie={command:`get <item-id>`,describe:`Downloads the raw file content for a specific item from the managed AI Search instance storage.`,builder:re,handler:async t=>{if(t.dryRun){u({command:`cf ai-search namespaces instances items content get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-search/namespaces/${t.name==null?`<name>`:encodeURIComponent(String(t.name))}/instances/${t.id==null?`<id>`:encodeURIComponent(String(t.id))}/items/${t[`item-id`]==null?`<item-id>`:encodeURIComponent(String(t[`item-id`]))}/download`,pathParams:{id:String(t.id??``),"item-id":String(t[`item-id`]??``),name:String(t.name??``)},bodyKind:`none`});return}let n=await o(t),r=t.local?m:await i(n);t.accountId=r;let a=await d(`Loading`,async()=>te(`/accounts/${r}/ai-search/namespaces/${encodeURIComponent(String(t.name))}/instances/${encodeURIComponent(String(t.id))}/items/${encodeURIComponent(String(t[`item-id`]))}/download`,{method:`GET`,localEndpoint:t.local?t.localEndpoint:void 0}));ee(t.text===!0?a.toString(`utf-8`):a)}},ae={command:`content`,describe:`Namespaces for organizing and managing AI Search instances, items, and jobs`,builder:e=>e.command(ie).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function oe(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace name`,demandOption:!0}).option(`key`,{type:`string`,description:`Item key / filename. Must not exceed 128 characters.`}).option(`next-action`,{type:`string`,description:`The next_action field`,choices:[`INDEX`]}).option(`wait-for-completion`,{type:`boolean`,description:"Wait for indexing to fully complete before responding. On RAGs with vector indexing enabled, this additionally waits for Vectorize ingestion confirmation (up to 40s) so the returned item reflects a queryable state. On timeout the item is returned in `running` state and the background alarm continues polling. Defaults to false."}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const se={command:`update <id>`,describe:`Creates or updates an indexed item in an AI Search instance.`,builder:oe,handler:async r=>{if(r.dryRun){u({command:`cf ai-search namespaces instances items create or update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<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?c({key:f(r.key,`key`,`text`),next_action:f(r[`next-action`],`next-action`,`text`),wait_for_completion:r[`wait-for-completion`]}):s(r.body)});return}let a=await o(r),p=r.local?m:await i(a);if(r.accountId=p,r.body){let e=s(r.body);l(await d(`Updating`,async()=>a.aiSearch.namespaces.instances.items.create.or.update({...e,account_id:p,name:r.name,id:r.id})),{successLabel:`Updated`});return}r.key===void 0&&(r.key=await t(`key`,`Item key / filename. Must not exceed 128 characters.`)),r[`next-action`]===void 0&&(r[`next-action`]=await n(`next-action`,`The next_action field`,[`INDEX`]));let h=c({key:f(r.key,`key`,`text`),next_action:f(r[`next-action`],`next-action`,`text`),wait_for_completion:r[`wait-for-completion`]});l(await d(`Updating`,async()=>a.aiSearch.namespaces.instances.items.create.or.update({...h,account_id:p,name:r.name,id:r.id})),{successLabel:`Updated`})}},ce={command:`or`,describe:`Namespaces for organizing and managing AI Search instances, items, and jobs`,builder:e=>e.command(se).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},le={command:`create`,describe:`Operations for namespaces.instances.items.create`,builder:e=>e.command(ce).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function ue(e){return e.positional(`item-id`,{type:`string`,description:`Item ID`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace name`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const de={command:`delete <item-id>`,describe:`Deletes a file from a managed AI Search instance and triggers a reindex.`,builder:ue,handler:async t=>{if(t.dryRun){u({command:`cf ai-search namespaces instances items delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-search/namespaces/${t.name==null?`<name>`:encodeURIComponent(String(t.name))}/instances/${t.id==null?`<id>`:encodeURIComponent(String(t.id))}/items/${t[`item-id`]==null?`<item-id>`:encodeURIComponent(String(t[`item-id`]))}`,pathParams:{id:String(t.id??``),"item-id":String(t[`item-id`]??``),name:String(t.name??``)},bodyKind:`none`});return}let n=await o(t),a=t.local?m:await i(n);if(t.accountId=a,!await r({force:!!t.force})){process.stderr.write(`Aborted.
6
- `);return}l(await d(`Deleting`,async()=>n.aiSearch.namespaces.instances.items.delete({account_id:a,name:t.name,id:t.id,item_id:t[`item-id`]})),{successLabel:`Deleted`})}};function fe(e){return e.positional(`item-id`,{type:`string`,description:`Item ID`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace name`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const pe={command:`get <item-id>`,describe:`Retrieves a specific indexed item from an AI Search instance.`,builder:fe,handler:async t=>{if(t.dryRun){u({command:`cf ai-search namespaces instances items get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-search/namespaces/${t.name==null?`<name>`:encodeURIComponent(String(t.name))}/instances/${t.id==null?`<id>`:encodeURIComponent(String(t.id))}/items/${t[`item-id`]==null?`<item-id>`:encodeURIComponent(String(t[`item-id`]))}`,pathParams:{id:String(t.id??``),"item-id":String(t[`item-id`]??``),name:String(t.name??``)},bodyKind:`none`});return}let n=await o(t),r=t.local?m:await i(n);t.accountId=r,l(await d(`Loading`,async()=>n.aiSearch.namespaces.instances.items.get({account_id:r,name:t.name,id:t.id,item_id:t[`item-id`]})),{successLabel:`Loaded`})}};function me(e){return e.option(`name`,{type:`string`,description:`Namespace name`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.`,demandOption:!0}).option(`page`,{type:`number`,description:`Page`}).option(`per-page`,{type:`number`,description:`Per page`}).option(`search`,{type:`string`,description:`Search`}).option(`sort-by`,{type:`string`,description:`Sort order for items. "status" (default) sorts by status priority then last_seen_at. "modified_at" sorts by file modification time (most recent first), falling back to created_at.`,choices:[`status`,`modified_at`]}).option(`status`,{type:`string`,description:`Status`,choices:[`queued`,`running`,`completed`,`error`,`skipped`,`outdated`]}).option(`source`,{type:`string`,description:`Filter items by source_id. Use "builtin" for uploaded files, or a source identifier like "web-crawler:https://example.com".`}).option(`metadata-filter`,{type:`string`,description:`JSON-encoded metadata filter using Vectorize filter syntax. Examples: {"folder":"reports/"}, {"timestamp":{"$gte":1700000000000}}, {"folder":{"$in":["docs/","reports/"]}}`}).option(`item-id`,{type:`string`,description:`Filter items by their unique ID. Returns at most one item.`}).option(`key`,{type:`string`,description:"Filter items by their exact key (object key / filename). Keys are unique per source, so combine with `source` to disambiguate across data sources."}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const he={command:`list`,describe:`Lists indexed items in an AI Search instance.`,builder:h(me),handler:async t=>{let n={page:t.page,per_page:t[`per-page`],search:t.search,sort_by:t[`sort-by`],status:t.status,source:t.source,metadata_filter:t[`metadata-filter`],item_id:t[`item-id`],key:t.key};if(t.dryRun){u({command:`cf ai-search namespaces instances items list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-search/namespaces/${t.name==null?`<name>`:encodeURIComponent(String(t.name))}/instances/${t.id==null?`<id>`:encodeURIComponent(String(t.id))}/items`,pathParams:{id:String(t.id??``),name:String(t.name??``)},query:n,bodyKind:`none`});return}let r=await o(t),a=t.local?m:await i(r);t.accountId=a,l(await d(`Loading`,async()=>r.aiSearch.namespaces.instances.items.list({account_id:a,name:t.name,id:t.id,...n})),{successLabel:`Loaded`})}};function ge(e){return e.positional(`item-id`,{type:`string`,description:`Item ID`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace name`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.`,demandOption:!0}).option(`limit`,{type:`number`,description:`Limit`}).option(`cursor`,{type:`string`,description:`Cursor`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const _e={command:`logs <item-id>`,describe:`Lists processing logs for a specific item in an AI Search instance.`,builder:ge,handler:async t=>{let n={limit:t.limit,cursor:t.cursor};if(t.dryRun){u({command:`cf ai-search namespaces instances items logs`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-search/namespaces/${t.name==null?`<name>`:encodeURIComponent(String(t.name))}/instances/${t.id==null?`<id>`:encodeURIComponent(String(t.id))}/items/${t[`item-id`]==null?`<item-id>`:encodeURIComponent(String(t[`item-id`]))}/logs`,pathParams:{id:String(t.id??``),"item-id":String(t[`item-id`]??``),name:String(t.name??``)},query:n,bodyKind:`none`});return}let r=await o(t),a=t.local?m:await i(r);t.accountId=a,l(await d(`Loading`,async()=>r.aiSearch.namespaces.instances.items.logs({account_id:a,name:t.name,id:t.id,item_id:t[`item-id`],...n})),{successLabel:`Loaded`})}};function ve(e){return e.positional(`item-id`,{type:`string`,description:`Item ID`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace name`,demandOption:!0}).option(`id`,{type:`string`,description:`AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.`,demandOption:!0}).option(`next-action`,{type:`string`,description:`The next_action field`,choices:[`INDEX`]}).option(`wait-for-completion`,{type:`boolean`,description:"Wait for indexing to fully complete before responding. On RAGs with vector indexing enabled, this additionally waits for Vectorize ingestion confirmation (up to 40s) so the returned item reflects a queryable state. On timeout the item is returned in `running` state and the background alarm continues polling. Defaults to false."}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const ye={command:`sync <item-id>`,describe:`Syncs an item to an AI Search instance index.`,builder:ve,handler:async t=>{if(t.dryRun){u({command:`cf ai-search namespaces instances items sync`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-search/namespaces/${t.name==null?`<name>`:encodeURIComponent(String(t.name))}/instances/${t.id==null?`<id>`:encodeURIComponent(String(t.id))}/items/${t[`item-id`]==null?`<item-id>`:encodeURIComponent(String(t[`item-id`]))}`,pathParams:{id:String(t.id??``),"item-id":String(t[`item-id`]??``),name:String(t.name??``)},bodyKind:`json`,body:t.body===void 0?c({next_action:f(t[`next-action`],`next-action`,`text`),wait_for_completion:t[`wait-for-completion`]}):s(t.body)});return}let r=await o(t),a=t.local?m:await i(r);if(t.accountId=a,t.body){let e=s(t.body);l(await d(`Updating`,async()=>r.aiSearch.namespaces.instances.items.sync({...e,account_id:a,name:t.name,id:t.id,item_id:t[`item-id`]})),{successLabel:`Updated`});return}t[`next-action`]===void 0&&(t[`next-action`]=await n(`next-action`,`The next_action field`,[`INDEX`]));let p=c({next_action:f(t[`next-action`],`next-action`,`text`),wait_for_completion:t[`wait-for-completion`]});l(await d(`Updating`,async()=>r.aiSearch.namespaces.instances.items.sync({...p,account_id:a,name:t.name,id:t.id,item_id:t[`item-id`]})),{successLabel:`Updated`})}};function be(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.`,demandOption:!0}).option(`name`,{type:`string`,description:`Namespace name`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`}).option(`file`,{type:`string`,description:`Path to a file to upload as the request body`}).option(`metadata`,{type:`string`,description:`JSON string of custom metadata key-value pairs.`}).option(`wait-for-completion`,{type:`boolean`,description:"Wait for indexing to fully complete before responding. On RAGs with vector indexing enabled, this additionally waits for Vectorize ingestion confirmation (up to 40s) so the returned item reflects a queryable state. On timeout the item is returned in `running` state and the background alarm continues polling. Defaults to false."})}const xe={command:`upload <id>`,describe:`Uploads a file to a managed AI Search instance via multipart/form-data.`,builder:be,handler:async t=>{if(t.dryRun){u({command:`cf ai-search namespaces instances items upload`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-search/namespaces/${t.name==null?`<name>`:encodeURIComponent(String(t.name))}/instances/${t.id==null?`<id>`:encodeURIComponent(String(t.id))}/items`,pathParams:{id:String(t.id??``),name:String(t.name??``)},bodyKind:`multipart`,body:{body:t.body,file:t.file,metadata:t.metadata,"wait-for-completion":t[`wait-for-completion`]}});return}let n=await o(t),r=t.local?m:await i(n);if(t.accountId=r,t.file!==void 0||t.body!==void 0||t.metadata!==void 0||t[`wait-for-completion`]!==void 0){let e=new FormData;if(t.file){let n=p(t.file);e.append(`file`,new Blob([n]),t.file.split(/[\\/]/).filter(Boolean).pop())}else t.body!==void 0&&e.append(`file`,t.body);t.metadata!==void 0&&e.append(`metadata`,String(f(t.metadata,`metadata`,`text`)??``)),t[`wait-for-completion`]!==void 0&&e.append(`wait_for_completion`,String(t[`wait-for-completion`])),l(await d(`Creating`,async()=>a(n,`POST`,`/accounts/${r}/ai-search/namespaces/${encodeURIComponent(String(t.name))}/instances/${encodeURIComponent(String(t.id))}/items`,{body:e})),{successLabel:`Created`});return}if(t.body){let e=f(t.body,`body`,`binary`);l(await d(`Creating`,async()=>a(n,`POST`,`/accounts/${r}/ai-search/namespaces/${encodeURIComponent(String(t.name))}/instances/${encodeURIComponent(String(t.id))}/items`,{body:e,headers:{"Content-Type":`multipart/form-data`}})),{successLabel:`Created`});return}if(t.body===void 0)throw Error(`--body is required for this command. Pass --body '<json>' or --body @path/to/file.json.`)}},Se={command:`items`,describe:`Namespaces for organizing and managing AI Search instances, items, and jobs`,builder:e=>e.command(de).command(pe).command(he).command(_e).command(ye).command(xe).command(ne).command(ae).command(le).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},Ce={command:`instances`,describe:`Operations for namespaces.instances`,builder:e=>e.command(X).command(Se).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function we(e){return e.positional(`id`,{type:`string`,description:`Instance id.`,demandOption:!0}).option(`name`,{type:`string`,description:`Current namespace of the instance.`,demandOption:!0}).option(`new-namespace`,{type:`string`,description:`Target namespace to move the instance into.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const Te={command:`instance <id>`,describe:`Moves an instance from its current namespace to the specified target namespace. Use 'default' as new_namespace to move the instance back to the default namespace. Fails with 400 if the target namespace already has an instance with the same id (ids must be unique within a namespace — the same id can exist in different namespaces).`,builder:we,handler:async n=>{if(n.dryRun){u({command:`cf ai-search namespaces move instance`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-search/namespaces/${n.name==null?`<name>`:encodeURIComponent(String(n.name))}/instances/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}`,pathParams:{name:String(n.name??``),id:String(n.id??``)},bodyKind:`json`,body:n.body===void 0?c({new_namespace:f(n[`new-namespace`],`new-namespace`,`text`)}):s(n.body)});return}let r=await o(n),a=n.local?m:await i(r);if(n.accountId=a,n.body){let e=s(n.body);l(await d(`Updating`,async()=>r.aiSearch.namespaces.move.instance({...e,account_id:a,name:n.name,id:n.id})),{successLabel:`Updated`});return}n[`new-namespace`]===void 0&&(n[`new-namespace`]=await t(`new-namespace`,`Target namespace to move the instance into.`));let p=c({new_namespace:f(n[`new-namespace`],`new-namespace`,`text`)});l(await d(`Updating`,async()=>r.aiSearch.namespaces.move.instance({...p,account_id:a,name:n.name,id:n.id})),{successLabel:`Updated`})}},Ee={command:`move`,describe:`Operations for namespaces.move`,builder:e=>e.command(Te).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function De(e){return e.positional(`name`,{type:`string`,description:`Namespace name`,demandOption:!0}).option(`ai-search-options-cache-cache-threshold`,{type:`string`,description:`The ai_search_options.cache.cache_threshold field`,choices:[`super_strict_match`,`close_enough`,`flexible_friend`,`anything_goes`]}).option(`ai-search-options-cache-enabled`,{type:`boolean`,description:`The ai_search_options.cache.enabled field`}).option(`ai-search-options-instance-ids`,{type:`string`,array:!0,description:`The ai_search_options.instance_ids field`}).option(`ai-search-options-query-rewrite-enabled`,{type:`boolean`,description:`The ai_search_options.query_rewrite.enabled field`}).option(`ai-search-options-query-rewrite-rewrite-prompt`,{type:`string`,description:`The ai_search_options.query_rewrite.rewrite_prompt field`}).option(`ai-search-options-reranking-enabled`,{type:`boolean`,description:`The ai_search_options.reranking.enabled field`}).option(`ai-search-options-reranking-match-threshold`,{type:`number`,description:`The ai_search_options.reranking.match_threshold field`,default:.4}).option(`ai-search-options-retrieval-context-expansion`,{type:`number`,description:`The ai_search_options.retrieval.context_expansion field`,default:0}).option(`ai-search-options-retrieval-fusion-method`,{type:`string`,description:`The ai_search_options.retrieval.fusion_method field`,choices:[`max`,`rrf`]}).option(`ai-search-options-retrieval-keyword-match-mode`,{type:`string`,description:`Controls which documents are candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term, ranked by BM25 relevance. When omitted, falls back to the instance-level retrieval_options.keyword_match_mode, then to 'and'.`,choices:[`and`,`or`]}).option(`ai-search-options-retrieval-match-threshold`,{type:`number`,description:`The ai_search_options.retrieval.match_threshold field`,default:.4}).option(`ai-search-options-retrieval-max-num-results`,{type:`number`,description:`The ai_search_options.retrieval.max_num_results field`,default:10}).option(`ai-search-options-retrieval-retrieval-type`,{type:`string`,description:`The ai_search_options.retrieval.retrieval_type field`,choices:[`vector`,`keyword`,`hybrid`]}).option(`ai-search-options-retrieval-return-on-failure`,{type:`boolean`,description:`The ai_search_options.retrieval.return_on_failure field`,default:!0}).option(`stream`,{type:`boolean`,description:`The stream field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const Oe={command:`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:De,handler:async t=>{if(t.dryRun){u({command:`cf ai-search namespaces multi instance chat completions`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-search/namespaces/${t.name==null?`<name>`:encodeURIComponent(String(t.name))}/chat/completions`,pathParams:{name:String(t.name??``)},bodyKind:`json`,body:t.body===void 0?c({ai_search_options:{cache:{cache_threshold:f(t[`ai-search-options-cache-cache-threshold`],`ai-search-options-cache-cache-threshold`,`text`),enabled:t[`ai-search-options-cache-enabled`]},instance_ids:t[`ai-search-options-instance-ids`],query_rewrite:{enabled:t[`ai-search-options-query-rewrite-enabled`],rewrite_prompt:f(t[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:t[`ai-search-options-reranking-enabled`],match_threshold:t[`ai-search-options-reranking-match-threshold`]},retrieval:{context_expansion:t[`ai-search-options-retrieval-context-expansion`],fusion_method:f(t[`ai-search-options-retrieval-fusion-method`],`ai-search-options-retrieval-fusion-method`,`text`),keyword_match_mode:f(t[`ai-search-options-retrieval-keyword-match-mode`],`ai-search-options-retrieval-keyword-match-mode`,`text`),match_threshold:t[`ai-search-options-retrieval-match-threshold`],max_num_results:t[`ai-search-options-retrieval-max-num-results`],retrieval_type:f(t[`ai-search-options-retrieval-retrieval-type`],`ai-search-options-retrieval-retrieval-type`,`text`),return_on_failure:t[`ai-search-options-retrieval-return-on-failure`]}},stream:t.stream}):s(t.body)});return}let n=await o(t),r=t.local?m:await i(n);if(t.accountId=r,t.body){let e=s(t.body);l(await d(`Creating`,async()=>n.aiSearch.namespaces.multi.instance.chat.completions({...e,account_id:r,name:t.name})),{successLabel:`Created`});return}if(t[`ai-search-options-instance-ids`]===void 0)throw Error(`--ai-search-options-instance-ids is required (or pass --body with this field set).`);let a=c({ai_search_options:{cache:{cache_threshold:f(t[`ai-search-options-cache-cache-threshold`],`ai-search-options-cache-cache-threshold`,`text`),enabled:t[`ai-search-options-cache-enabled`]},instance_ids:t[`ai-search-options-instance-ids`],query_rewrite:{enabled:t[`ai-search-options-query-rewrite-enabled`],rewrite_prompt:f(t[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:t[`ai-search-options-reranking-enabled`],match_threshold:t[`ai-search-options-reranking-match-threshold`]},retrieval:{context_expansion:t[`ai-search-options-retrieval-context-expansion`],fusion_method:f(t[`ai-search-options-retrieval-fusion-method`],`ai-search-options-retrieval-fusion-method`,`text`),keyword_match_mode:f(t[`ai-search-options-retrieval-keyword-match-mode`],`ai-search-options-retrieval-keyword-match-mode`,`text`),match_threshold:t[`ai-search-options-retrieval-match-threshold`],max_num_results:t[`ai-search-options-retrieval-max-num-results`],retrieval_type:f(t[`ai-search-options-retrieval-retrieval-type`],`ai-search-options-retrieval-retrieval-type`,`text`),return_on_failure:t[`ai-search-options-retrieval-return-on-failure`]}},stream:t.stream});l(await d(`Creating`,async()=>n.aiSearch.namespaces.multi.instance.chat.completions({...a,account_id:r,name:t.name})),{successLabel:`Created`})}},ke={command:`chat`,describe:`Namespaces for organizing and managing AI Search instances, items, and jobs`,builder:e=>e.command(Oe).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Ae(e){return e.positional(`name`,{type:`string`,description:`Namespace name`,demandOption:!0}).option(`ai-search-options-cache-cache-threshold`,{type:`string`,description:`The ai_search_options.cache.cache_threshold field`,choices:[`super_strict_match`,`close_enough`,`flexible_friend`,`anything_goes`]}).option(`ai-search-options-cache-enabled`,{type:`boolean`,description:`The ai_search_options.cache.enabled field`}).option(`ai-search-options-instance-ids`,{type:`string`,array:!0,description:`The ai_search_options.instance_ids field`}).option(`ai-search-options-query-rewrite-enabled`,{type:`boolean`,description:`The ai_search_options.query_rewrite.enabled field`}).option(`ai-search-options-query-rewrite-rewrite-prompt`,{type:`string`,description:`The ai_search_options.query_rewrite.rewrite_prompt field`}).option(`ai-search-options-reranking-enabled`,{type:`boolean`,description:`The ai_search_options.reranking.enabled field`}).option(`ai-search-options-reranking-match-threshold`,{type:`number`,description:`The ai_search_options.reranking.match_threshold field`,default:.4}).option(`ai-search-options-retrieval-context-expansion`,{type:`number`,description:`The ai_search_options.retrieval.context_expansion field`,default:0}).option(`ai-search-options-retrieval-fusion-method`,{type:`string`,description:`The ai_search_options.retrieval.fusion_method field`,choices:[`max`,`rrf`]}).option(`ai-search-options-retrieval-keyword-match-mode`,{type:`string`,description:`Controls which documents are candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term, ranked by BM25 relevance. When omitted, falls back to the instance-level retrieval_options.keyword_match_mode, then to 'and'.`,choices:[`and`,`or`]}).option(`ai-search-options-retrieval-match-threshold`,{type:`number`,description:`The ai_search_options.retrieval.match_threshold field`,default:.4}).option(`ai-search-options-retrieval-max-num-results`,{type:`number`,description:`The ai_search_options.retrieval.max_num_results field`,default:10}).option(`ai-search-options-retrieval-retrieval-type`,{type:`string`,description:`The ai_search_options.retrieval.retrieval_type field`,choices:[`vector`,`keyword`,`hybrid`]}).option(`ai-search-options-retrieval-return-on-failure`,{type:`boolean`,description:`The ai_search_options.retrieval.return_on_failure field`,default:!0}).option(`query`,{type:`string`,description:`A simple text query string. Alternative to 'messages' — provide either this or 'messages', not both.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const je={command:`search <name>`,describe:`Performs a semantic search query against multiple AI Search instances in parallel, merging the retrieved results into a single ranked response.`,builder:Ae,handler:async t=>{if(t.dryRun){u({command:`cf ai-search namespaces multi instance search`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-search/namespaces/${t.name==null?`<name>`:encodeURIComponent(String(t.name))}/search`,pathParams:{name:String(t.name??``)},bodyKind:`json`,body:t.body===void 0?c({ai_search_options:{cache:{cache_threshold:f(t[`ai-search-options-cache-cache-threshold`],`ai-search-options-cache-cache-threshold`,`text`),enabled:t[`ai-search-options-cache-enabled`]},instance_ids:t[`ai-search-options-instance-ids`],query_rewrite:{enabled:t[`ai-search-options-query-rewrite-enabled`],rewrite_prompt:f(t[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:t[`ai-search-options-reranking-enabled`],match_threshold:t[`ai-search-options-reranking-match-threshold`]},retrieval:{context_expansion:t[`ai-search-options-retrieval-context-expansion`],fusion_method:f(t[`ai-search-options-retrieval-fusion-method`],`ai-search-options-retrieval-fusion-method`,`text`),keyword_match_mode:f(t[`ai-search-options-retrieval-keyword-match-mode`],`ai-search-options-retrieval-keyword-match-mode`,`text`),match_threshold:t[`ai-search-options-retrieval-match-threshold`],max_num_results:t[`ai-search-options-retrieval-max-num-results`],retrieval_type:f(t[`ai-search-options-retrieval-retrieval-type`],`ai-search-options-retrieval-retrieval-type`,`text`),return_on_failure:t[`ai-search-options-retrieval-return-on-failure`]}},query:f(t.query,`query`,`text`)}):s(t.body)});return}let n=await o(t),r=t.local?m:await i(n);if(t.accountId=r,t.body){let e=s(t.body);l(await d(`Loading`,async()=>n.aiSearch.namespaces.multi.instance.search({...e,account_id:r,name:t.name})),{successLabel:`Loaded`});return}if(t[`ai-search-options-instance-ids`]===void 0)throw Error(`--ai-search-options-instance-ids is required (or pass --body with this field set).`);let a=c({ai_search_options:{cache:{cache_threshold:f(t[`ai-search-options-cache-cache-threshold`],`ai-search-options-cache-cache-threshold`,`text`),enabled:t[`ai-search-options-cache-enabled`]},instance_ids:t[`ai-search-options-instance-ids`],query_rewrite:{enabled:t[`ai-search-options-query-rewrite-enabled`],rewrite_prompt:f(t[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:t[`ai-search-options-reranking-enabled`],match_threshold:t[`ai-search-options-reranking-match-threshold`]},retrieval:{context_expansion:t[`ai-search-options-retrieval-context-expansion`],fusion_method:f(t[`ai-search-options-retrieval-fusion-method`],`ai-search-options-retrieval-fusion-method`,`text`),keyword_match_mode:f(t[`ai-search-options-retrieval-keyword-match-mode`],`ai-search-options-retrieval-keyword-match-mode`,`text`),match_threshold:t[`ai-search-options-retrieval-match-threshold`],max_num_results:t[`ai-search-options-retrieval-max-num-results`],retrieval_type:f(t[`ai-search-options-retrieval-retrieval-type`],`ai-search-options-retrieval-retrieval-type`,`text`),return_on_failure:t[`ai-search-options-retrieval-return-on-failure`]}},query:f(t.query,`query`,`text`)});l(await d(`Loading`,async()=>n.aiSearch.namespaces.multi.instance.search({...a,account_id:r,name:t.name})),{successLabel:`Loaded`})}},Me={command:`instance`,describe:`Namespaces for organizing and managing AI Search instances, items, and jobs`,builder:e=>e.command(je).command(ke).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},Ne={command:`multi`,describe:`Operations for namespaces.multi`,builder:e=>e.command(Me).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},Pe={command:`namespaces`,describe:`Operations for namespaces`,builder:e=>e.command(Ce).command(Ee).command(Ne).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Fe(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.`,demandOption:!0}).option(`ai-search-options-cache-cache-threshold`,{type:`string`,description:`The ai_search_options.cache.cache_threshold field`,choices:[`super_strict_match`,`close_enough`,`flexible_friend`,`anything_goes`]}).option(`ai-search-options-cache-enabled`,{type:`boolean`,description:`The ai_search_options.cache.enabled field`}).option(`ai-search-options-query-rewrite-enabled`,{type:`boolean`,description:`The ai_search_options.query_rewrite.enabled field`}).option(`ai-search-options-query-rewrite-rewrite-prompt`,{type:`string`,description:`The ai_search_options.query_rewrite.rewrite_prompt field`}).option(`ai-search-options-reranking-enabled`,{type:`boolean`,description:`The ai_search_options.reranking.enabled field`}).option(`ai-search-options-reranking-match-threshold`,{type:`number`,description:`The ai_search_options.reranking.match_threshold field`,default:.4}).option(`ai-search-options-retrieval-context-expansion`,{type:`number`,description:`The ai_search_options.retrieval.context_expansion field`,default:0}).option(`ai-search-options-retrieval-fusion-method`,{type:`string`,description:`The ai_search_options.retrieval.fusion_method field`,choices:[`max`,`rrf`]}).option(`ai-search-options-retrieval-keyword-match-mode`,{type:`string`,description:`Controls which documents are candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term, ranked by BM25 relevance. When omitted, falls back to the instance-level retrieval_options.keyword_match_mode, then to 'and'.`,choices:[`and`,`or`]}).option(`ai-search-options-retrieval-match-threshold`,{type:`number`,description:`The ai_search_options.retrieval.match_threshold field`,default:.4}).option(`ai-search-options-retrieval-max-num-results`,{type:`number`,description:`The ai_search_options.retrieval.max_num_results field`,default:10}).option(`ai-search-options-retrieval-retrieval-type`,{type:`string`,description:`The ai_search_options.retrieval.retrieval_type field`,choices:[`vector`,`keyword`,`hybrid`]}).option(`ai-search-options-retrieval-return-on-failure`,{type:`boolean`,description:`The ai_search_options.retrieval.return_on_failure field`,default:!0}).option(`query`,{type:`string`,description:`A simple text query string. Alternative to 'messages' — provide either this or 'messages', not both.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const Ie={command:`search <id>`,describe:`Executes a semantic search query against an AI Search instance to find relevant indexed content.`,builder:Fe,handler:async t=>{if(t.dryRun){u({command:`cf ai-search search`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-search/instances/${t.id==null?`<id>`:encodeURIComponent(String(t.id))}/search`,pathParams:{id:String(t.id??``)},bodyKind:`json`,body:t.body===void 0?c({ai_search_options:{cache:{cache_threshold:f(t[`ai-search-options-cache-cache-threshold`],`ai-search-options-cache-cache-threshold`,`text`),enabled:t[`ai-search-options-cache-enabled`]},query_rewrite:{enabled:t[`ai-search-options-query-rewrite-enabled`],rewrite_prompt:f(t[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:t[`ai-search-options-reranking-enabled`],match_threshold:t[`ai-search-options-reranking-match-threshold`]},retrieval:{context_expansion:t[`ai-search-options-retrieval-context-expansion`],fusion_method:f(t[`ai-search-options-retrieval-fusion-method`],`ai-search-options-retrieval-fusion-method`,`text`),keyword_match_mode:f(t[`ai-search-options-retrieval-keyword-match-mode`],`ai-search-options-retrieval-keyword-match-mode`,`text`),match_threshold:t[`ai-search-options-retrieval-match-threshold`],max_num_results:t[`ai-search-options-retrieval-max-num-results`],retrieval_type:f(t[`ai-search-options-retrieval-retrieval-type`],`ai-search-options-retrieval-retrieval-type`,`text`),return_on_failure:t[`ai-search-options-retrieval-return-on-failure`]}},query:f(t.query,`query`,`text`)}):s(t.body)});return}let n=await o(t),r=t.local?m:await i(n);if(t.accountId=r,t.body){let e=s(t.body);l(await d(`Loading`,async()=>n.aiSearch.search({...e,account_id:r,id:t.id})),{successLabel:`Loaded`});return}let a=c({ai_search_options:{cache:{cache_threshold:f(t[`ai-search-options-cache-cache-threshold`],`ai-search-options-cache-cache-threshold`,`text`),enabled:t[`ai-search-options-cache-enabled`]},query_rewrite:{enabled:t[`ai-search-options-query-rewrite-enabled`],rewrite_prompt:f(t[`ai-search-options-query-rewrite-rewrite-prompt`],`ai-search-options-query-rewrite-rewrite-prompt`,`text`)},reranking:{enabled:t[`ai-search-options-reranking-enabled`],match_threshold:t[`ai-search-options-reranking-match-threshold`]},retrieval:{context_expansion:t[`ai-search-options-retrieval-context-expansion`],fusion_method:f(t[`ai-search-options-retrieval-fusion-method`],`ai-search-options-retrieval-fusion-method`,`text`),keyword_match_mode:f(t[`ai-search-options-retrieval-keyword-match-mode`],`ai-search-options-retrieval-keyword-match-mode`,`text`),match_threshold:t[`ai-search-options-retrieval-match-threshold`],max_num_results:t[`ai-search-options-retrieval-max-num-results`],retrieval_type:f(t[`ai-search-options-retrieval-retrieval-type`],`ai-search-options-retrieval-retrieval-type`,`text`),return_on_failure:t[`ai-search-options-retrieval-return-on-failure`]}},query:f(t.query,`query`,`text`)});l(await d(`Loading`,async()=>n.aiSearch.search({...a,account_id:r,id:t.id})),{successLabel:`Loaded`})}};function Le(e){return e.positional(`id`,{type:`string`,description:`AI Search instance ID. Lowercase alphanumeric, hyphens, and underscores.`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const Re={command:`stats <id>`,describe:`Retrieve usage and indexing statistics for an AI Search instance.`,builder:Le,handler:async t=>{if(t.dryRun){u({command:`cf ai-search stats`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-search/instances/${t.id==null?`<id>`:encodeURIComponent(String(t.id))}/stats`,pathParams:{id:String(t.id??``)},bodyKind:`none`});return}let n=await o(t),r=t.local?m:await i(n);t.accountId=r,l(await d(`Loading`,async()=>n.aiSearch.stats({account_id:r,id:t.id})),{successLabel:`Loaded`})}};function ze(e){return e.option(`cf-api-id`,{type:`string`,description:`The cf_api_id field`}).option(`cf-api-key`,{type:`string`,description:`The cf_api_key field`}).option(`legacy`,{type:`boolean`,description:`The legacy field`,default:!0}).option(`name`,{type:`string`,description:`The name field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const Be={command:`create`,describe:`Create a new token.`,builder:ze,handler:async n=>{if(n.dryRun){u({command:`cf ai-search tokens create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-search/tokens`,pathParams:{},bodyKind:`json`,body:n.body===void 0?c({cf_api_id:f(n[`cf-api-id`],`cf-api-id`,`text`),cf_api_key:f(n[`cf-api-key`],`cf-api-key`,`text`),legacy:n.legacy,name:f(n.name,`name`,`text`)}):s(n.body)});return}let r=await o(n),a=n.local?m:await i(r);if(n.accountId=a,n.body){let e=s(n.body);l(await d(`Creating`,async()=>r.aiSearch.tokens.create({...e,account_id:a})),{successLabel:`Created`});return}n[`cf-api-id`]===void 0&&(n[`cf-api-id`]=await t(`cf-api-id`,`The cf_api_id field`)),n[`cf-api-key`]===void 0&&(n[`cf-api-key`]=await t(`cf-api-key`,`The cf_api_key field`,{kind:`secret`})),n.name===void 0&&(n.name=await t(`name`,`The name field`));let p=c({cf_api_id:f(n[`cf-api-id`],`cf-api-id`,`text`),cf_api_key:f(n[`cf-api-key`],`cf-api-key`,`text`),legacy:n.legacy,name:f(n.name,`name`,`text`)});l(await d(`Creating`,async()=>r.aiSearch.tokens.create({...p,account_id:a})),{successLabel:`Created`})}};function Ve(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const $={command:`delete <id>`,describe:`Delete token.`,builder:Ve,handler:async t=>{if(t.dryRun){u({command:`cf ai-search tokens delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-search/tokens/${t.id==null?`<id>`:encodeURIComponent(String(t.id))}`,pathParams:{id:String(t.id??``)},bodyKind:`none`});return}let n=await o(t),a=t.local?m:await i(n);if(t.accountId=a,!await r({force:!!t.force})){process.stderr.write(`Aborted.
7
- `);return}l(await d(`Deleting`,async()=>n.aiSearch.tokens.delete({account_id:a,id:t.id})),{successLabel:`Deleted`})}};function He(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 Ue={command:`list`,describe:`List tokens.`,builder:He,handler:async t=>{let n={page:t.page,per_page:t[`per-page`],search:t.search};if(t.dryRun){u({command:`cf ai-search tokens list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-search/tokens`,pathParams:{},query:n,bodyKind:`none`});return}let r=await o(t),a=t.local?m:await i(r);t.accountId=a,l(await d(`Loading`,async()=>r.aiSearch.tokens.list({account_id:a,...n})),{successLabel:`Loaded`})}};function We(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 Ge={command:`read <id>`,describe:`Read token.`,builder:We,handler:async t=>{if(t.dryRun){u({command:`cf ai-search tokens read`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-search/tokens/${t.id==null?`<id>`:encodeURIComponent(String(t.id))}`,pathParams:{id:String(t.id??``)},bodyKind:`none`});return}let n=await o(t),r=t.local?m:await i(n);t.accountId=r,l(await d(`Loading`,async()=>n.aiSearch.tokens.read({account_id:r,id:t.id})),{successLabel:`Loaded`})}};function Ke(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`cf-api-id`,{type:`string`,description:`The cf_api_id field`}).option(`cf-api-key`,{type:`string`,description:`The cf_api_key field`}).option(`legacy`,{type:`boolean`,description:`The legacy field`}).option(`name`,{type:`string`,description:`The name field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const qe={command:`update <id>`,describe:`Update token.`,builder:Ke,handler:async n=>{if(n.dryRun){u({command:`cf ai-search tokens update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-search/tokens/${n.id==null?`<id>`:encodeURIComponent(String(n.id))}`,pathParams:{id:String(n.id??``)},bodyKind:`json`,body:n.body===void 0?c({cf_api_id:f(n[`cf-api-id`],`cf-api-id`,`text`),cf_api_key:f(n[`cf-api-key`],`cf-api-key`,`text`),legacy:n.legacy,name:f(n.name,`name`,`text`)}):s(n.body)});return}let r=await o(n),a=n.local?m:await i(r);if(n.accountId=a,n.body){let e=s(n.body);l(await d(`Updating`,async()=>r.aiSearch.tokens.update({...e,account_id:a,id:n.id})),{successLabel:`Updated`});return}n[`cf-api-id`]===void 0&&(n[`cf-api-id`]=await t(`cf-api-id`,`The cf_api_id field`)),n[`cf-api-key`]===void 0&&(n[`cf-api-key`]=await t(`cf-api-key`,`The cf_api_key field`,{kind:`secret`})),n.name===void 0&&(n.name=await t(`name`,`The name field`));let p=c({cf_api_id:f(n[`cf-api-id`],`cf-api-id`,`text`),cf_api_key:f(n[`cf-api-key`],`cf-api-key`,`text`),legacy:n.legacy,name:f(n.name,`name`,`text`)});l(await d(`Updating`,async()=>r.aiSearch.tokens.update({...p,account_id:a,id:n.id})),{successLabel:`Updated`})}},Je={command:`tokens`,describe:`Scoped authentication tokens that grant access to specific AI Search instances`,builder:e=>e.command(Be).command($).command(Ue).command(Ge).command(qe).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function Ye(e){return e.positional(`id`,{type:`string`,description:`ID`,demandOption:!0}).option(`ai-gateway-id`,{type:`string`,description:`The ai_gateway_id field`}).option(`ai-search-model`,{type:`string`,description:`The ai_search_model field`,choices:`@cf/meta/llama-3.3-70b-instruct-fp8-fast,@cf/zai-org/glm-4.7-flash,@cf/meta/llama-3.1-8b-instruct-fast,@cf/meta/llama-3.1-8b-instruct-fp8,@cf/meta/llama-4-scout-17b-16e-instruct,@cf/qwen/qwen3-30b-a3b-fp8,@cf/deepseek-ai/deepseek-r1-distill-qwen-32b,@cf/moonshotai/kimi-k2-instruct,@cf/google/gemma-3-12b-it,@cf/google/gemma-4-26b-a4b-it,@cf/moonshotai/kimi-k2.5,anthropic/claude-3-7-sonnet,anthropic/claude-sonnet-4,anthropic/claude-opus-4,anthropic/claude-3-5-haiku,cerebras/qwen-3-235b-a22b-instruct,cerebras/qwen-3-235b-a22b-thinking,cerebras/llama-3.3-70b,cerebras/llama-4-maverick-17b-128e-instruct,cerebras/llama-4-scout-17b-16e-instruct,cerebras/gpt-oss-120b,google-ai-studio/gemini-2.5-flash,google-ai-studio/gemini-2.5-pro,grok/grok-4,groq/llama-3.3-70b-versatile,groq/llama-3.1-8b-instant,openai/gpt-5,openai/gpt-5-mini,openai/gpt-5-nano`.split(`,`)}).option(`cache`,{type:`boolean`,description:`The cache field`}).option(`cache-threshold`,{type:`string`,description:`The cache_threshold field`,choices:[`super_strict_match`,`close_enough`,`flexible_friend`,`anything_goes`]}).option(`chunk`,{type:`boolean`,description:`The chunk field`}).option(`chunk-overlap`,{type:`number`,description:`The chunk_overlap field`}).option(`chunk-size`,{type:`number`,description:`The chunk_size field`}).option(`embedding-model`,{type:`string`,description:`The embedding_model field`,choices:[`@cf/qwen/qwen3-embedding-0.6b`,`@cf/qwen/qwen3-vl-embedding-2b`,`@cf/baai/bge-m3`,`@cf/baai/bge-large-en-v1.5`,`@cf/google/embeddinggemma-300m`,`google-ai-studio/gemini-embedding-001`,`google-ai-studio/gemini-embedding-2-preview`,`google-ai-studio/gemini-embedding-2`,`openai/text-embedding-3-small`,`openai/text-embedding-3-large`]}).option(`fusion-method`,{type:`string`,description:`The fusion_method field`,choices:[`max`,`rrf`]}).option(`index-method-keyword`,{type:`boolean`,description:`Enable keyword (BM25) storage backend.`}).option(`index-method-vector`,{type:`boolean`,description:`Enable vector (embedding) storage backend.`}).option(`indexing-options-keyword-tokenizer`,{type:`string`,description:`Tokenizer used for keyword search indexing. porter provides word-level tokenization with Porter stemming (good for natural language queries). trigram enables character-level substring matching (good for partial matches, code, identifiers). Changing this triggers a full re-index. Defaults to porter.`,choices:[`porter`,`trigram`]}).option(`max-num-results`,{type:`number`,description:`The max_num_results field`}).option(`metadata-created-from-aisearch-wizard`,{type:`boolean`,description:`The metadata.created_from_aisearch_wizard field`}).option(`metadata-worker-domain`,{type:`string`,description:`The metadata.worker_domain field`}).option(`paused`,{type:`boolean`,description:`The paused field`}).option(`public-endpoint-params-authorized-hosts`,{type:`string`,array:!0,description:`The public_endpoint_params.authorized_hosts field`}).option(`public-endpoint-params-chat-completions-endpoint-disabled`,{type:`boolean`,description:`Disable chat completions endpoint for this public endpoint`}).option(`public-endpoint-params-custom-domains`,{type:`string`,array:!0,description:`Custom domain hostnames that alias this public endpoint. GET and create responses return the current set; on update (PUT) this field is only echoed back when supplied in the request body, otherwise it is null (omit it to leave domains unchanged).`}).option(`public-endpoint-params-enabled`,{type:`boolean`,description:`The public_endpoint_params.enabled field`}).option(`public-endpoint-params-mcp-description`,{type:`string`,description:`The public_endpoint_params.mcp.description field`}).option(`public-endpoint-params-mcp-disabled`,{type:`boolean`,description:`Disable MCP endpoint for this public endpoint`}).option(`public-endpoint-params-rate-limit-period-ms`,{type:`number`,description:`The public_endpoint_params.rate_limit.period_ms field`}).option(`public-endpoint-params-rate-limit-requests`,{type:`number`,description:`The public_endpoint_params.rate_limit.requests field`}).option(`public-endpoint-params-rate-limit-technique`,{type:`string`,description:`The public_endpoint_params.rate_limit.technique field`,choices:[`fixed`,`sliding`]}).option(`public-endpoint-params-search-endpoint-disabled`,{type:`boolean`,description:`Disable search endpoint for this public endpoint`}).option(`reranking`,{type:`boolean`,description:`The reranking field`}).option(`reranking-model`,{type:`string`,description:`The reranking_model field`,choices:[`@cf/baai/bge-reranker-base`]}).option(`retrieval-options-keyword-match-mode`,{type:`string`,description:`Controls which documents are candidates for BM25 scoring. 'and' restricts candidates to documents containing all query terms; 'or' includes any document containing at least one term, ranked by BM25 relevance. When omitted on an update, the existing stored value is preserved; when never set, search falls back to 'and'.`,choices:[`and`,`or`]}).option(`rewrite-model`,{type:`string`,description:`The rewrite_model field`,choices:`@cf/meta/llama-3.3-70b-instruct-fp8-fast,@cf/zai-org/glm-4.7-flash,@cf/meta/llama-3.1-8b-instruct-fast,@cf/meta/llama-3.1-8b-instruct-fp8,@cf/meta/llama-4-scout-17b-16e-instruct,@cf/qwen/qwen3-30b-a3b-fp8,@cf/deepseek-ai/deepseek-r1-distill-qwen-32b,@cf/moonshotai/kimi-k2-instruct,@cf/google/gemma-3-12b-it,@cf/google/gemma-4-26b-a4b-it,@cf/moonshotai/kimi-k2.5,anthropic/claude-3-7-sonnet,anthropic/claude-sonnet-4,anthropic/claude-opus-4,anthropic/claude-3-5-haiku,cerebras/qwen-3-235b-a22b-instruct,cerebras/qwen-3-235b-a22b-thinking,cerebras/llama-3.3-70b,cerebras/llama-4-maverick-17b-128e-instruct,cerebras/llama-4-scout-17b-16e-instruct,cerebras/gpt-oss-120b,google-ai-studio/gemini-2.5-flash,google-ai-studio/gemini-2.5-pro,grok/grok-4,groq/llama-3.3-70b-versatile,groq/llama-3.1-8b-instant,openai/gpt-5,openai/gpt-5-mini,openai/gpt-5-nano`.split(`,`)}).option(`rewrite-query`,{type:`boolean`,description:`The rewrite_query field`}).option(`score-threshold`,{type:`number`,description:`The score_threshold field`}).option(`source`,{type:`string`,description:`The source field`}).option(`source-params-exclude-items`,{type:`string`,array:!0,description:`List of path patterns to exclude. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /admin/** matches /admin/users and /admin/settings/advanced)`}).option(`source-params-include-items`,{type:`string`,array:!0,description:`List of path patterns to include. Uses micromatch glob syntax: * matches within a path segment, ** matches across path segments (e.g., /blog/** matches /blog/post and /blog/2024/post)`}).option(`source-params-prefix`,{type:`string`,description:`The source_params.prefix field`}).option(`source-params-r2-jurisdiction`,{type:`string`,description:`The source_params.r2_jurisdiction field`}).option(`source-params-web-crawler-parse-options-include-images`,{type:`boolean`,description:`The source_params.web_crawler.parse_options.include_images field`}).option(`source-params-web-crawler-parse-options-specific-sitemaps`,{type:`string`,array:!0,description:`List of specific sitemap URLs to use for crawling. Only valid when parse_type is 'sitemap'.`}).option(`source-params-web-crawler-parse-options-use-browser-rendering`,{type:`boolean`,description:`The source_params.web_crawler.parse_options.use_browser_rendering field`}).option(`source-params-web-crawler-parse-type`,{type:`string`,description:`The source_params.web_crawler.parse_type field`,choices:[`sitemap`,`crawl`]}).option(`summarization`,{type:`boolean`,description:`The summarization field`}).option(`summarization-model`,{type:`string`,description:`The summarization_model field`,choices:`@cf/meta/llama-3.3-70b-instruct-fp8-fast,@cf/zai-org/glm-4.7-flash,@cf/meta/llama-3.1-8b-instruct-fast,@cf/meta/llama-3.1-8b-instruct-fp8,@cf/meta/llama-4-scout-17b-16e-instruct,@cf/qwen/qwen3-30b-a3b-fp8,@cf/deepseek-ai/deepseek-r1-distill-qwen-32b,@cf/moonshotai/kimi-k2-instruct,@cf/google/gemma-3-12b-it,@cf/google/gemma-4-26b-a4b-it,@cf/moonshotai/kimi-k2.5,anthropic/claude-3-7-sonnet,anthropic/claude-sonnet-4,anthropic/claude-opus-4,anthropic/claude-3-5-haiku,cerebras/qwen-3-235b-a22b-instruct,cerebras/qwen-3-235b-a22b-thinking,cerebras/llama-3.3-70b,cerebras/llama-4-maverick-17b-128e-instruct,cerebras/llama-4-scout-17b-16e-instruct,cerebras/gpt-oss-120b,google-ai-studio/gemini-2.5-flash,google-ai-studio/gemini-2.5-pro,grok/grok-4,groq/llama-3.3-70b-versatile,groq/llama-3.1-8b-instant,openai/gpt-5,openai/gpt-5-mini,openai/gpt-5-nano`.split(`,`)}).option(`system-prompt-ai-search`,{type:`string`,description:`The system_prompt_ai_search field`}).option(`system-prompt-index-summarization`,{type:`string`,description:`The system_prompt_index_summarization field`}).option(`system-prompt-rewrite-query`,{type:`string`,description:`The system_prompt_rewrite_query field`}).option(`token-id`,{type:`string`,description:`The token_id field`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`}).check(e=>{if([`index-method-keyword`,`index-method-vector`].some(t=>e[t]!==void 0)){let t=[`index-method-keyword`,`index-method-vector`].filter(t=>e[t]===void 0);if(t.length>0)throw Error(`${t.map(e=>`--`+e).join(`, `)} ${t.length===1?`is`:`are`} required when any --index_method-* flag is set`)}return!0})}const Xe={command:`update <id>`,describe:`Update the configuration of an AI Search instance.`,builder:Ye,handler:async t=>{if(t.dryRun){u({command:`cf ai-search update`,method:`PUT`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-search/instances/${t.id==null?`<id>`:encodeURIComponent(String(t.id))}`,pathParams:{id:String(t.id??``)},bodyKind:`json`,body:t.body===void 0?c({ai_gateway_id:f(t[`ai-gateway-id`],`ai-gateway-id`,`text`),ai_search_model:f(t[`ai-search-model`],`ai-search-model`,`text`),cache:t.cache,cache_threshold:f(t[`cache-threshold`],`cache-threshold`,`text`),chunk:t.chunk,chunk_overlap:t[`chunk-overlap`],chunk_size:t[`chunk-size`],embedding_model:f(t[`embedding-model`],`embedding-model`,`text`),fusion_method:f(t[`fusion-method`],`fusion-method`,`text`),index_method:{keyword:t[`index-method-keyword`],vector:t[`index-method-vector`]},indexing_options:{keyword_tokenizer:f(t[`indexing-options-keyword-tokenizer`],`indexing-options-keyword-tokenizer`,`text`)},max_num_results:t[`max-num-results`],metadata:{created_from_aisearch_wizard:t[`metadata-created-from-aisearch-wizard`],worker_domain:f(t[`metadata-worker-domain`],`metadata-worker-domain`,`text`)},paused:t.paused,public_endpoint_params:{authorized_hosts:t[`public-endpoint-params-authorized-hosts`],chat_completions_endpoint:{disabled:t[`public-endpoint-params-chat-completions-endpoint-disabled`]},custom_domains:t[`public-endpoint-params-custom-domains`],enabled:t[`public-endpoint-params-enabled`],mcp:{description:f(t[`public-endpoint-params-mcp-description`],`public-endpoint-params-mcp-description`,`text`),disabled:t[`public-endpoint-params-mcp-disabled`]},rate_limit:{period_ms:t[`public-endpoint-params-rate-limit-period-ms`],requests:t[`public-endpoint-params-rate-limit-requests`],technique:f(t[`public-endpoint-params-rate-limit-technique`],`public-endpoint-params-rate-limit-technique`,`text`)},search_endpoint:{disabled:t[`public-endpoint-params-search-endpoint-disabled`]}},reranking:t.reranking,reranking_model:f(t[`reranking-model`],`reranking-model`,`text`),retrieval_options:{keyword_match_mode:f(t[`retrieval-options-keyword-match-mode`],`retrieval-options-keyword-match-mode`,`text`)},rewrite_model:f(t[`rewrite-model`],`rewrite-model`,`text`),rewrite_query:t[`rewrite-query`],score_threshold:t[`score-threshold`],source:f(t.source,`source`,`text`),source_params:{exclude_items:t[`source-params-exclude-items`],include_items:t[`source-params-include-items`],prefix:f(t[`source-params-prefix`],`source-params-prefix`,`text`),r2_jurisdiction:f(t[`source-params-r2-jurisdiction`],`source-params-r2-jurisdiction`,`text`),web_crawler:{parse_options:{include_images:t[`source-params-web-crawler-parse-options-include-images`],specific_sitemaps:t[`source-params-web-crawler-parse-options-specific-sitemaps`],use_browser_rendering:t[`source-params-web-crawler-parse-options-use-browser-rendering`]},parse_type:f(t[`source-params-web-crawler-parse-type`],`source-params-web-crawler-parse-type`,`text`)}},summarization:t.summarization,summarization_model:f(t[`summarization-model`],`summarization-model`,`text`),system_prompt_ai_search:f(t[`system-prompt-ai-search`],`system-prompt-ai-search`,`text`),system_prompt_index_summarization:f(t[`system-prompt-index-summarization`],`system-prompt-index-summarization`,`text`),system_prompt_rewrite_query:f(t[`system-prompt-rewrite-query`],`system-prompt-rewrite-query`,`text`),token_id:f(t[`token-id`],`token-id`,`text`)}):s(t.body)});return}let n=await o(t),r=t.local?m:await i(n);if(t.accountId=r,t.body){let e=s(t.body);l(await d(`Updating`,async()=>n.aiSearch.update({...e,account_id:r,id:t.id})),{successLabel:`Updated`});return}let a=c({ai_gateway_id:f(t[`ai-gateway-id`],`ai-gateway-id`,`text`),ai_search_model:f(t[`ai-search-model`],`ai-search-model`,`text`),cache:t.cache,cache_threshold:f(t[`cache-threshold`],`cache-threshold`,`text`),chunk:t.chunk,chunk_overlap:t[`chunk-overlap`],chunk_size:t[`chunk-size`],embedding_model:f(t[`embedding-model`],`embedding-model`,`text`),fusion_method:f(t[`fusion-method`],`fusion-method`,`text`),index_method:{keyword:t[`index-method-keyword`],vector:t[`index-method-vector`]},indexing_options:{keyword_tokenizer:f(t[`indexing-options-keyword-tokenizer`],`indexing-options-keyword-tokenizer`,`text`)},max_num_results:t[`max-num-results`],metadata:{created_from_aisearch_wizard:t[`metadata-created-from-aisearch-wizard`],worker_domain:f(t[`metadata-worker-domain`],`metadata-worker-domain`,`text`)},paused:t.paused,public_endpoint_params:{authorized_hosts:t[`public-endpoint-params-authorized-hosts`],chat_completions_endpoint:{disabled:t[`public-endpoint-params-chat-completions-endpoint-disabled`]},custom_domains:t[`public-endpoint-params-custom-domains`],enabled:t[`public-endpoint-params-enabled`],mcp:{description:f(t[`public-endpoint-params-mcp-description`],`public-endpoint-params-mcp-description`,`text`),disabled:t[`public-endpoint-params-mcp-disabled`]},rate_limit:{period_ms:t[`public-endpoint-params-rate-limit-period-ms`],requests:t[`public-endpoint-params-rate-limit-requests`],technique:f(t[`public-endpoint-params-rate-limit-technique`],`public-endpoint-params-rate-limit-technique`,`text`)},search_endpoint:{disabled:t[`public-endpoint-params-search-endpoint-disabled`]}},reranking:t.reranking,reranking_model:f(t[`reranking-model`],`reranking-model`,`text`),retrieval_options:{keyword_match_mode:f(t[`retrieval-options-keyword-match-mode`],`retrieval-options-keyword-match-mode`,`text`)},rewrite_model:f(t[`rewrite-model`],`rewrite-model`,`text`),rewrite_query:t[`rewrite-query`],score_threshold:t[`score-threshold`],source:f(t.source,`source`,`text`),source_params:{exclude_items:t[`source-params-exclude-items`],include_items:t[`source-params-include-items`],prefix:f(t[`source-params-prefix`],`source-params-prefix`,`text`),r2_jurisdiction:f(t[`source-params-r2-jurisdiction`],`source-params-r2-jurisdiction`,`text`),web_crawler:{parse_options:{include_images:t[`source-params-web-crawler-parse-options-include-images`],specific_sitemaps:t[`source-params-web-crawler-parse-options-specific-sitemaps`],use_browser_rendering:t[`source-params-web-crawler-parse-options-use-browser-rendering`]},parse_type:f(t[`source-params-web-crawler-parse-type`],`source-params-web-crawler-parse-type`,`text`)}},summarization:t.summarization,summarization_model:f(t[`summarization-model`],`summarization-model`,`text`),system_prompt_ai_search:f(t[`system-prompt-ai-search`],`system-prompt-ai-search`,`text`),system_prompt_index_summarization:f(t[`system-prompt-index-summarization`],`system-prompt-index-summarization`,`text`),system_prompt_rewrite_query:f(t[`system-prompt-rewrite-query`],`system-prompt-rewrite-query`,`text`),token_id:f(t[`token-id`],`token-id`,`text`)});l(await d(`Updating`,async()=>n.aiSearch.update({...a,account_id:r,id:t.id})),{successLabel:`Updated`})}},Ze={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(_).command(y).command(x).command(C).command(I).command(Ie).command(Re).command(Xe).command(P).command(q).command(Pe).command(Je).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{Ze as default};
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env node
2
- import{C as e,D as t,E as n,T as r,_ as i,n as a}from"./auth-ffdf9yR0.mjs";import{n as o,t as s}from"./body-parser-DKa8Ipg1.mjs";import{t as c}from"./output-BJFNwj7b.mjs";import{n as l,t as u}from"./progress-CrCGTq7N.mjs";import{n as d}from"./input-validation-zEO81MWN.mjs";import{t as f}from"./local-VJaJ3BZ1.mjs";import{t as p}from"./cli-types-CRIDdDw3.mjs";function m(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const h={command:`credit_balance`,describe:`Retrieve the current credit balance, payment method info, and top-up configuration.`,builder:m,handler:async t=>{if(t.dryRun){l({command:`cf ai_gateway billing credit_balance`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/billing/credit-balance`,pathParams:{},bodyKind:`none`});return}let n=await a(t),r=t.local?f:await i(n);t.accountId=r,c(await u(`Loading`,async()=>n.aiGateway.billing.creditBalance({account_id:r})),{successLabel:`Loaded`})}};function g(e){return e.option(`type`,{type:`string`,description:`Filter invoice type: auto, manual, or all.`,choices:[`auto`,`all`,`manual`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const _={command:`invoice_history`,describe:`Retrieve a list of past invoices with pagination, optionally filtered by type.`,builder:p(g),handler:async t=>{let n={type:t.type};if(t.dryRun){l({command:`cf ai_gateway billing invoice_history`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/billing/invoice-history`,pathParams:{},query:n,bodyKind:`none`});return}let r=await a(t),o=t.local?f:await i(r);t.accountId=o,c(await u(`Loading`,async()=>r.aiGateway.billing.invoiceHistory({account_id:o,...n})),{successLabel:`Loaded`})}};function v(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const y={command:`invoice_preview`,describe:`Retrieve a preview of the upcoming invoice including line items and tax.`,builder:v,handler:async t=>{if(t.dryRun){l({command:`cf ai_gateway billing invoice_preview`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/billing/invoice-preview`,pathParams:{},bodyKind:`none`});return}let n=await a(t),r=t.local?f:await i(n);t.accountId=r,c(await u(`Loading`,async()=>n.aiGateway.billing.invoicePreview({account_id:r})),{successLabel:`Loaded`})}};function b(e){return e.option(`amount`,{type:`number`,description:`Spending limit amount in cents (min 100).`}).option(`duration`,{type:`string`,description:`Spending limit duration.`,choices:[`daily`,`weekly`,`monthly`]}).option(`strategy`,{type:`string`,description:`Spending limit strategy.`,choices:[`fixed`,`sliding`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const x={command:`create`,describe:`Deprecated: spending limits can no longer be created, enabled, or modified and this endpoint always responds 403. Use the new AI Gateway spend limits instead: https://developers.cloudflare.com/ai-gateway/features/spend-limits/. Existing limits can be removed via DELETE /spending-limit.`,builder:b,handler:async t=>{if(t.dryRun){l({command:`cf ai_gateway billing spending_limit create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/billing/spending-limit`,pathParams:{},bodyKind:`json`,body:t.body===void 0?s({amount:t.amount,duration:d(t.duration,`duration`,`text`),strategy:d(t.strategy,`strategy`,`text`)}):o(t.body)});return}let r=await a(t),p=t.local?f:await i(r);if(t.accountId=p,t.body){let e=o(t.body);c(await u(`Creating`,async()=>r.aiGateway.billing.spendingLimit.create({...e,account_id:p})),{successLabel:`Created`});return}if(t.amount===void 0)throw Error(`--amount is required (or pass --body with this field set).`);t.duration===void 0&&(t.duration=await n(`duration`,`Spending limit duration.`,[`daily`,`weekly`,`monthly`])),t.strategy===void 0&&(t.strategy=await n(`strategy`,`Spending limit strategy.`,[`fixed`,`sliding`]));let m=s({amount:t.amount,duration:d(t.duration,`duration`,`text`),strategy:d(t.strategy,`strategy`,`text`)});c(await u(`Creating`,async()=>r.aiGateway.billing.spendingLimit.create({...m,account_id:p})),{successLabel:`Created`})}};function S(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const C={command:`delete`,describe:`Remove the spending limit for the account.`,builder:S,handler:async t=>{if(t.dryRun){l({command:`cf ai_gateway billing spending_limit delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/billing/spending-limit`,pathParams:{},bodyKind:`none`});return}let n=await a(t),o=t.local?f:await i(n);if(t.accountId=o,!await r({force:!!t.force})){process.stderr.write(`Aborted.
3
- `);return}c(await u(`Deleting`,async()=>n.aiGateway.billing.spendingLimit.delete({account_id:o})),{successLabel:`Deleted`})}};function w(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const T={command:`get`,describe:`Retrieve the current spending limit configuration for the account.`,builder:w,handler:async t=>{if(t.dryRun){l({command:`cf ai_gateway billing spending_limit get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/billing/spending-limit`,pathParams:{},bodyKind:`none`});return}let n=await a(t),r=t.local?f:await i(n);t.accountId=r,c(await u(`Loading`,async()=>n.aiGateway.billing.spendingLimit.get({account_id:r})),{successLabel:`Loaded`})}},E={command:`spending_limit`,describe:`Operations for billing.spending_limit`,builder:e=>e.command(x).command(C).command(T).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function D(e){return e.option(`amount`,{type:`number`,description:`Auto top-up amount in cents (min 1000).`}).option(`threshold`,{type:`number`,description:`Balance threshold in cents that triggers auto top-up (min 500).`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const O={command:`create`,describe:`Configure auto top-up with a balance threshold and top-up amount.`,builder:D,handler:async t=>{if(t.dryRun){l({command:`cf ai_gateway billing topup config create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/billing/topup/config`,pathParams:{},bodyKind:`json`,body:t.body===void 0?s({amount:t.amount,threshold:t.threshold}):o(t.body)});return}let n=await a(t),r=t.local?f:await i(n);if(t.accountId=r,t.body){let e=o(t.body);c(await u(`Creating`,async()=>n.aiGateway.billing.topup.config.create({...e,account_id:r})),{successLabel:`Created`});return}if(t.amount===void 0)throw Error(`--amount is required (or pass --body with this field set).`);if(t.threshold===void 0)throw Error(`--threshold is required (or pass --body with this field set).`);let d=s({amount:t.amount,threshold:t.threshold});c(await u(`Creating`,async()=>n.aiGateway.billing.topup.config.create({...d,account_id:r})),{successLabel:`Created`})}};function k(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`force`,{type:`boolean`,alias:`f`,description:`Skip confirmation (useful in scripts and CI)`,default:!1})}const A={command:`delete`,describe:`Remove the auto top-up configuration for the account.`,builder:k,handler:async t=>{if(t.dryRun){l({command:`cf ai_gateway billing topup config delete`,method:`DELETE`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/billing/topup/config`,pathParams:{},bodyKind:`none`});return}let n=await a(t),o=t.local?f:await i(n);if(t.accountId=o,!await r({force:!!t.force})){process.stderr.write(`Aborted.
4
- `);return}c(await u(`Deleting`,async()=>n.aiGateway.billing.topup.config.delete({account_id:o})),{successLabel:`Deleted`})}};function j(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const M={command:`get`,describe:`Retrieve the current auto top-up threshold, amount, and any error state.`,builder:j,handler:async t=>{if(t.dryRun){l({command:`cf ai_gateway billing topup config get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/billing/topup/config`,pathParams:{},bodyKind:`none`});return}let n=await a(t),r=t.local?f:await i(n);t.accountId=r,c(await u(`Loading`,async()=>n.aiGateway.billing.topup.config.get({account_id:r})),{successLabel:`Loaded`})}},N={command:`config`,describe:`Operations for billing.topup.config`,builder:e=>e.command(O).command(A).command(M).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function P(e){return e.option(`amount`,{type:`number`,description:`Top-up amount in cents (min 1000).`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const F={command:`create`,describe:`Create a credit top-up via Stripe PaymentIntent for the given account.`,builder:P,handler:async t=>{if(t.dryRun){l({command:`cf ai_gateway billing topup create`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/billing/topup`,pathParams:{},bodyKind:`json`,body:t.body===void 0?s({amount:t.amount}):o(t.body)});return}let n=await a(t),r=t.local?f:await i(n);if(t.accountId=r,t.body){let e=o(t.body);c(await u(`Creating`,async()=>n.aiGateway.billing.topup.create({...e,account_id:r})),{successLabel:`Created`});return}if(t.amount===void 0)throw Error(`--amount is required (or pass --body with this field set).`);let d=s({amount:t.amount});c(await u(`Creating`,async()=>n.aiGateway.billing.topup.create({...d,account_id:r})),{successLabel:`Created`})}};function I(e){return e.option(`payment-intent-id`,{type:`string`,description:`Stripe invoice ID to check status for.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`})}const L={command:`status`,describe:`Get the payment processing status of a top-up by its invoice ID.`,builder:I,handler:async n=>{if(n.dryRun){l({command:`cf ai_gateway billing topup status`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/billing/topup/status`,pathParams:{},bodyKind:`json`,body:n.body===void 0?s({payment_intent_id:d(n[`payment-intent-id`],`payment-intent-id`,`text`)}):o(n.body)});return}let r=await a(n),p=n.local?f:await i(r);if(n.accountId=p,n.body){let e=o(n.body);c(await u(`Creating`,async()=>r.aiGateway.billing.topup.status({...e,account_id:p})),{successLabel:`Created`});return}n[`payment-intent-id`]===void 0&&(n[`payment-intent-id`]=await t(`payment-intent-id`,`Stripe invoice ID to check status for.`));let m=s({payment_intent_id:d(n[`payment-intent-id`],`payment-intent-id`,`text`)});c(await u(`Creating`,async()=>r.aiGateway.billing.topup.status({...m,account_id:p})),{successLabel:`Created`})}},R={command:`topup`,describe:`Operations for billing.topup`,builder:e=>e.command(F).command(L).command(N).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function z(e){return e.option(`value-grouping-window`,{type:`string`,description:`Grouping window for usage data.`,choices:[`day`,`hour`],demandOption:!0}).option(`start-time`,{type:`number`,description:`Start time as Unix timestamp in milliseconds.`}).option(`end-time`,{type:`number`,description:`End time as Unix timestamp in milliseconds.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const B={command:`usage_history`,describe:`Retrieve aggregated usage meter event summaries for the given time range.`,builder:p(z),handler:async t=>{let n={value_grouping_window:t[`value-grouping-window`],start_time:t[`start-time`],end_time:t[`end-time`]};if(t.dryRun){l({command:`cf ai_gateway billing usage_history`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/ai-gateway/billing/usage-history`,pathParams:{},query:n,bodyKind:`none`});return}let r=await a(t),o=t.local?f:await i(r);t.accountId=o,c(await u(`Loading`,async()=>r.aiGateway.billing.usageHistory({account_id:o,...n})),{successLabel:`Loaded`})}},V={command:`billing`,describe:`Operations for billing`,builder:e=>e.command(h).command(_).command(y).command(B).command(E).command(R).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},H={command:`ai_gateway`,describe:`ai_gateway`,builder:e=>e.command(V).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{H as default};
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import{C as e,_ as t,i as n,n as r}from"./auth-ffdf9yR0.mjs";import{t as i}from"./output-BJFNwj7b.mjs";import{n as a,t as o}from"./progress-CrCGTq7N.mjs";import{n as s,t as c}from"./input-validation-zEO81MWN.mjs";import{t as l}from"./local-VJaJ3BZ1.mjs";function u(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Raw JSON request body (bypasses individual flags)`}).option(`file`,{type:`string`,description:`Path to a file to upload as the request body`})}const d={command:`query`,describe:`Executes a SQL query against Workers Analytics Engine data. Pass the SQL query in the request body as plain text. The response uses newline-delimited JSON (NDJSON) by default, or a single JSON object when the query includes a FORMAT JSON clause. Prefer this method for longer queries that may exceed URL length limits.`,builder:u,handler:async u=>{if(u.dryRun){a({command:`cf analytics_engine sql query`,method:`POST`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/analytics_engine/sql`,pathParams:{},bodyKind:`octet-stream`,body:u.body});return}let d=await r(u),f=u.local?l:await t(d);if(u.accountId=f,u.file){let e=c(u.file);i(await o(`Loading`,async()=>n(d,`POST`,`/accounts/${f}/analytics_engine/sql`,{body:e,headers:{"Content-Type":`text/plain`}})),{successLabel:`Loaded`});return}if(u.body){let e=s(u.body,`body`,`binary`);i(await o(`Loading`,async()=>n(d,`POST`,`/accounts/${f}/analytics_engine/sql`,{body:e,headers:{"Content-Type":`text/plain`}})),{successLabel:`Loaded`});return}i(await o(`Loading`,async()=>d.analyticsEngine.sql.query({account_id:f})),{successLabel:`Loaded`})}},f={command:`sql`,describe:`Operations for sql`,builder:e=>e.command(d).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},p={command:`analytics_engine`,describe:`analytics_engine`,builder:e=>e.command(f).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{p as default};
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import{E as e,S as t,n}from"./auth-ffdf9yR0.mjs";import{n as r,t as i}from"./body-parser-DKa8Ipg1.mjs";import{t as a}from"./output-BJFNwj7b.mjs";import{n as o,t as s}from"./progress-CrCGTq7N.mjs";import{n as c}from"./input-validation-zEO81MWN.mjs";function l(e){return e.option(`value`,{type:`string`,description:`Specifies the enablement value of Argo Smart Routing.`,choices:[`on`,`off`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Configures the enablement of Argo Smart Routing.`})}const u={command:`edit`,describe:`Configures the value of the Argo Smart Routing enablement setting.`,builder:l,handler:async l=>{if(l.dryRun){o({command:`cf argo smart-routing edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${l.zone??l.zoneId??`<zone>`}/argo/smart_routing`,pathParams:{"zone-id":String(l.zone??l[`zone-id`]??``)},bodyKind:`json`,body:l.body===void 0?i({value:c(l.value,`value`,`text`)}):r(l.body)});return}let u=await n(l),d=await t({zone:l.zone},u,{quiet:l.quiet});if(l.zoneId=d,l.body){let e=r(l.body);a(await s(`Updating`,async()=>u.argo.smartRouting.edit({...e,zone_id:d})),{successLabel:`Updated`});return}l.value===void 0&&(l.value=await e(`value`,`Specifies the enablement value of Argo Smart Routing.`,[`on`,`off`]));let f=i({value:c(l.value,`value`,`text`)});a(await s(`Updating`,async()=>u.argo.smartRouting.edit({...f,zone_id:d})),{successLabel:`Updated`})}};function d(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const f={command:`get`,describe:`Retrieves the value of Argo Smart Routing enablement setting.`,builder:d,handler:async e=>{if(e.dryRun){o({command:`cf argo smart-routing get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/argo/smart_routing`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`none`});return}let r=await n(e),i=await t({zone:e.zone},r,{quiet:e.quiet});e.zoneId=i,a(await s(`Loading`,async()=>r.argo.smartRouting.get({zone_id:i})),{successLabel:`Loaded`})}},p={command:`smart-routing`,describe:`Route traffic through the fastest network paths to your origin using real-time latency data`,builder:e=>e.command(u).command(f).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};function m(e){return e.option(`value`,{type:`string`,description:`Enables Tiered Caching.`,choices:[`on`,`off`]}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1}).option(`body`,{type:`string`,description:`Update enablement of Tiered Caching.`})}const h={command:`edit`,describe:`Tiered Cache works by dividing Cloudflare's data centers into a hierarchy of lower-tiers and upper-tiers. If content is not cached in lower-tier data centers (generally the ones closest to a visitor), the lower-tier must ask an upper-tier to see if it has the content. If the upper-tier does not have the content, only the upper-tier can ask the origin for content. This practice improves bandwidth efficiency by limiting the number of data centers that can ask the origin for content, which reduces origin load and makes websites more cost-effective to operate. Additionally, Tiered Cache concentrates connections to origin servers so they come from a small number of data centers rather than the full set of network locations. This results in fewer open connections using server resources.`,builder:m,handler:async l=>{if(l.dryRun){o({command:`cf argo tiered-caching edit`,method:`PATCH`,url:`https://api.cloudflare.com/client/v4/zones/${l.zone??l.zoneId??`<zone>`}/argo/tiered_caching`,pathParams:{"zone-id":String(l.zone??l[`zone-id`]??``)},bodyKind:`json`,body:l.body===void 0?i({value:c(l.value,`value`,`text`)}):r(l.body)});return}let u=await n(l),d=await t({zone:l.zone},u,{quiet:l.quiet});if(l.zoneId=d,l.body){let e=r(l.body);a(await s(`Updating`,async()=>u.argo.tieredCaching.edit({...e,zone_id:d})),{successLabel:`Updated`});return}l.value===void 0&&(l.value=await e(`value`,`Enables Tiered Caching.`,[`on`,`off`]));let f=i({value:c(l.value,`value`,`text`)});a(await s(`Updating`,async()=>u.argo.tieredCaching.edit({...f,zone_id:d})),{successLabel:`Updated`})}};function g(e){return e.option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const _={command:`get`,describe:`Tiered Cache works by dividing Cloudflare's data centers into a hierarchy of lower-tiers and upper-tiers. If content is not cached in lower-tier data centers (generally the ones closest to a visitor), the lower-tier must ask an upper-tier to see if it has the content. If the upper-tier does not have the content, only the upper-tier can ask the origin for content. This practice improves bandwidth efficiency by limiting the number of data centers that can ask the origin for content, which reduces origin load and makes websites more cost-effective to operate. Additionally, Tiered Cache concentrates connections to origin servers so they come from a small number of data centers rather than the full set of network locations. This results in fewer open connections using server resources.`,builder:g,handler:async e=>{if(e.dryRun){o({command:`cf argo tiered-caching get`,method:`GET`,url:`https://api.cloudflare.com/client/v4/zones/${e.zone??e.zoneId??`<zone>`}/argo/tiered_caching`,pathParams:{"zone-id":String(e.zone??e[`zone-id`]??``)},bodyKind:`none`});return}let r=await n(e),i=await t({zone:e.zone},r,{quiet:e.quiet});e.zoneId=i,a(await s(`Loading`,async()=>r.argo.tieredCaching.get({zone_id:i})),{successLabel:`Loaded`})}},v={command:`tiered-caching`,describe:`Reduce origin load by having upper-tier data centers serve cache misses before reaching your origin`,builder:e=>e.command(h).command(_).demandCommand(1,`Please specify a subcommand`),handler:()=>{}},y={command:`argo`,describe:`Network optimization features that speed up and improve reliability of traffic to your origins`,builder:e=>e.command(p).command(v).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{y as default};
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import{C as e,_ as t,n}from"./auth-ffdf9yR0.mjs";import{t as r}from"./output-BJFNwj7b.mjs";import{n as i,t as a}from"./progress-CrCGTq7N.mjs";import{t as o}from"./local-VJaJ3BZ1.mjs";import{t as s}from"./cli-types-CRIDdDw3.mjs";function c(e){return e.option(`id`,{type:`string`,description:`Finds a specific log by its ID.`}).option(`export`,{type:`boolean`,description:`Indicates that this request is an export of logs in CSV format.`}).option(`action-type`,{type:`string`,description:`Filters by the action type.`}).option(`actor-ip`,{type:`string`,description:`Filters by the IP address of the request that made the change by specific IP address or valid CIDR Range.`}).option(`actor-email`,{type:`string`,description:`Filters by the email address of the actor that made the change.`}).option(`since`,{type:`string`,description:"Limits the returned results to logs newer than the specified date. A `full-date` that conforms to RFC3339."}).option(`before`,{type:`string`,description:"Limits the returned results to logs older than the specified date. A `full-date` that conforms to RFC3339."}).option(`zone-name`,{type:`string`,description:`Filters by the name of the zone associated to the change.`}).option(`direction`,{type:`string`,description:`Changes the direction of the chronological sorting.`,choices:[`desc`,`asc`]}).option(`per-page`,{type:`number`,description:`Sets the number of results to return per page.`}).option(`page`,{type:`number`,description:`Defines which page of results to return.`}).option(`hide-user-logs`,{type:`boolean`,description:`Indicates whether or not to hide user level audit logs.`}).option(`dry-run`,{type:`boolean`,description:`Validate and show what would happen without executing`,default:!1})}const l={command:`list`,describe:`Gets a list of audit logs for an account. Can be filtered by who made the change, on which zone, and the timeframe of the change.`,builder:s(c),handler:async s=>{let c={id:s.id,export:s.export,"action.type":s[`action-type`],"actor.ip":s[`actor-ip`],"actor.email":s[`actor-email`],since:s.since,before:s.before,"zone.name":s[`zone-name`],direction:s.direction,per_page:s[`per-page`],page:s.page,hide_user_logs:s[`hide-user-logs`]};if(s.dryRun){i({command:`cf audit-logs list`,method:`GET`,url:`https://api.cloudflare.com/client/v4/accounts/${e()??`<account-id>`}/audit_logs`,pathParams:{},query:c,bodyKind:`none`});return}let l=await n(s),u=s.local?o:await t(l);s.accountId=u,r(await a(`Loading`,async()=>l.auditLogs.list({account_id:u,...c})),{successLabel:`Loaded`})}},u={command:`audit-logs`,describe:`Immutable audit trail of actions taken by account members — who changed what and when`,builder:e=>e.command(l).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{u as default};
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env node
2
- import{a as e}from"./theme-BklJDrb2.mjs";import{i as t,n,r,t as i}from"./ui-D4KtlMh9.mjs";import{c as a,d as o,l as s,o as c,r as l,s as u,t as d,u as f}from"./auth-ffdf9yR0.mjs";import{t as p}from"./output-BJFNwj7b.mjs";const m={command:`login`,describe:`Authenticate with Cloudflare`,builder:e=>e.option(`force`,{type:`boolean`,alias:`f`,description:`Force re-authentication even if already logged in`,default:!1}),handler:async o=>{if(!o.force&&a()){if(await u()){let t=s();console.log(n(`You are already logged in.`)),console.log(`${e.info(`Config file:`)} ${e.muted(c())}`),t.accessToken&&console.log(`${e.info(`Token expires:`)} ${new Date(t.accessToken.expiry).toLocaleString()}`),console.log(i(`Run ${e.code(`cf auth login --force`)} to re-authenticate, or ${e.code(`cf auth logout`)} to log out.`));return}console.log(t(`Existing tokens are invalid or expired. Starting fresh login...
3
- `))}else o.force&&a()&&console.log(n(`Re-authenticating...
4
- `));if(console.log(n(`Starting OAuth login flow...
5
- `)),!await f()){console.log(t(`CLOUDFLARE_API_TOKEN is set and takes precedence. Unset it to log in via OAuth.`));return}let l=s();console.log(`
6
- `+r(`Successfully authenticated!`)),console.log(`${e.info(`Config file:`)} ${e.muted(c())}`),l.scopes&&console.log(`${e.info(`Scopes:`)} ${l.scopes.join(`, `)}`),l.accessToken&&console.log(`${e.info(`Token expires:`)} ${new Date(l.accessToken.expiry).toLocaleString()}`)}},h={command:`logout`,describe:`Log out and remove stored credentials`,handler:async()=>{let s=a(),l=!!process.env.CLOUDFLARE_API_TOKEN;if(!s){l?(console.log(n(`No cf OAuth credentials found, but CLOUDFLARE_API_TOKEN environment variable is set.`)),console.log(n(`Unset it with: unset CLOUDFLARE_API_TOKEN`))):(console.log(n(`You are not currently logged in.`)),console.log(i(`Run ${e.code(`cf auth login`)} to authenticate.`)));return}console.log(n(`Logging out...`)),await o(),console.log(r(`Successfully logged out.`)),console.log(`${e.info(`Removed:`)} OAuth tokens from ${e.muted(c())}`),l&&(console.log(``),console.log(t(`CLOUDFLARE_API_TOKEN environment variable is still set.`)),console.log(n(`You will remain authenticated via the env var. Unset it with: unset CLOUDFLARE_API_TOKEN`)))}},g={command:`whoami`,describe:`Show current user and authentication status`,builder:e=>e,handler:async e=>{let t=process.env.CLOUDFLARE_API_TOKEN,n=s(),r;r=t?`CLOUDFLARE_API_TOKEN environment variable`:n.accessToken?`OAuth token from ${c()}`:`none`;let i;try{i=await l()}catch{p({authenticated:!1,error:`Not logged in`});return}let a=d({apiToken:i}),o=!1,u;try{let e=await a.user.get();o=!0,e&&`email`in e&&typeof e.email==`string`&&(u=e.email)}catch(e){o=!1,process.env.DEBUG&&console.error(`Token verification error:`,e)}let f={authenticated:!0,authSource:r,tokenValid:o,...u&&{email:u}};n.accessToken&&(f.scopes=n.scopes,f.expiresAt=n.accessToken.expiry),p(f)}},_={command:`auth`,describe:`Authentication commands (login, logout, whoami)`,builder:e=>e.command(m).command(h).command(g).demandCommand(1,`Please specify a subcommand`),handler:()=>{}};export{_ as default};