worker-configuration.d.ts 401 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848
  1. /* eslint-disable */
  2. // Generated by Wrangler by running `wrangler types` (hash: b739a9c19cff1463949c4db47674ed86)
  3. // Runtime types generated with workerd@1.20260114.0 2025-09-27
  4. declare namespace Cloudflare {
  5. interface GlobalProps {
  6. mainModule: typeof import("./src/index");
  7. }
  8. interface Env {
  9. }
  10. }
  11. interface Env extends Cloudflare.Env {}
  12. // Begin runtime types
  13. /*! *****************************************************************************
  14. Copyright (c) Cloudflare. All rights reserved.
  15. Copyright (c) Microsoft Corporation. All rights reserved.
  16. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  17. this file except in compliance with the License. You may obtain a copy of the
  18. License at http://www.apache.org/licenses/LICENSE-2.0
  19. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  20. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  21. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  22. MERCHANTABLITY OR NON-INFRINGEMENT.
  23. See the Apache Version 2.0 License for specific language governing permissions
  24. and limitations under the License.
  25. ***************************************************************************** */
  26. /* eslint-disable */
  27. // noinspection JSUnusedGlobalSymbols
  28. declare var onmessage: never;
  29. /**
  30. * The **`DOMException`** interface represents an abnormal event (called an **exception**) that occurs as a result of calling a method or accessing a property of a web API.
  31. *
  32. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException)
  33. */
  34. declare class DOMException extends Error {
  35. constructor(message?: string, name?: string);
  36. /**
  37. * The **`message`** read-only property of the a message or description associated with the given error name.
  38. *
  39. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/message)
  40. */
  41. readonly message: string;
  42. /**
  43. * The **`name`** read-only property of the one of the strings associated with an error name.
  44. *
  45. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/name)
  46. */
  47. readonly name: string;
  48. /**
  49. * The **`code`** read-only property of the DOMException interface returns one of the legacy error code constants, or `0` if none match.
  50. * @deprecated
  51. *
  52. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/code)
  53. */
  54. readonly code: number;
  55. static readonly INDEX_SIZE_ERR: number;
  56. static readonly DOMSTRING_SIZE_ERR: number;
  57. static readonly HIERARCHY_REQUEST_ERR: number;
  58. static readonly WRONG_DOCUMENT_ERR: number;
  59. static readonly INVALID_CHARACTER_ERR: number;
  60. static readonly NO_DATA_ALLOWED_ERR: number;
  61. static readonly NO_MODIFICATION_ALLOWED_ERR: number;
  62. static readonly NOT_FOUND_ERR: number;
  63. static readonly NOT_SUPPORTED_ERR: number;
  64. static readonly INUSE_ATTRIBUTE_ERR: number;
  65. static readonly INVALID_STATE_ERR: number;
  66. static readonly SYNTAX_ERR: number;
  67. static readonly INVALID_MODIFICATION_ERR: number;
  68. static readonly NAMESPACE_ERR: number;
  69. static readonly INVALID_ACCESS_ERR: number;
  70. static readonly VALIDATION_ERR: number;
  71. static readonly TYPE_MISMATCH_ERR: number;
  72. static readonly SECURITY_ERR: number;
  73. static readonly NETWORK_ERR: number;
  74. static readonly ABORT_ERR: number;
  75. static readonly URL_MISMATCH_ERR: number;
  76. static readonly QUOTA_EXCEEDED_ERR: number;
  77. static readonly TIMEOUT_ERR: number;
  78. static readonly INVALID_NODE_TYPE_ERR: number;
  79. static readonly DATA_CLONE_ERR: number;
  80. get stack(): any;
  81. set stack(value: any);
  82. }
  83. type WorkerGlobalScopeEventMap = {
  84. fetch: FetchEvent;
  85. scheduled: ScheduledEvent;
  86. queue: QueueEvent;
  87. unhandledrejection: PromiseRejectionEvent;
  88. rejectionhandled: PromiseRejectionEvent;
  89. };
  90. declare abstract class WorkerGlobalScope extends EventTarget<WorkerGlobalScopeEventMap> {
  91. EventTarget: typeof EventTarget;
  92. }
  93. /* The **`console`** object provides access to the debugging console (e.g., the Web console in Firefox). *
  94. * The **`console`** object provides access to the debugging console (e.g., the Web console in Firefox).
  95. *
  96. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console)
  97. */
  98. interface Console {
  99. "assert"(condition?: boolean, ...data: any[]): void;
  100. /**
  101. * The **`console.clear()`** static method clears the console if possible.
  102. *
  103. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/clear_static)
  104. */
  105. clear(): void;
  106. /**
  107. * The **`console.count()`** static method logs the number of times that this particular call to `count()` has been called.
  108. *
  109. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/count_static)
  110. */
  111. count(label?: string): void;
  112. /**
  113. * The **`console.countReset()`** static method resets counter used with console/count_static.
  114. *
  115. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/countReset_static)
  116. */
  117. countReset(label?: string): void;
  118. /**
  119. * The **`console.debug()`** static method outputs a message to the console at the 'debug' log level.
  120. *
  121. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/debug_static)
  122. */
  123. debug(...data: any[]): void;
  124. /**
  125. * The **`console.dir()`** static method displays a list of the properties of the specified JavaScript object.
  126. *
  127. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/dir_static)
  128. */
  129. dir(item?: any, options?: any): void;
  130. /**
  131. * The **`console.dirxml()`** static method displays an interactive tree of the descendant elements of the specified XML/HTML element.
  132. *
  133. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/dirxml_static)
  134. */
  135. dirxml(...data: any[]): void;
  136. /**
  137. * The **`console.error()`** static method outputs a message to the console at the 'error' log level.
  138. *
  139. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/error_static)
  140. */
  141. error(...data: any[]): void;
  142. /**
  143. * The **`console.group()`** static method creates a new inline group in the Web console log, causing any subsequent console messages to be indented by an additional level, until console/groupEnd_static is called.
  144. *
  145. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/group_static)
  146. */
  147. group(...data: any[]): void;
  148. /**
  149. * The **`console.groupCollapsed()`** static method creates a new inline group in the console.
  150. *
  151. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/groupCollapsed_static)
  152. */
  153. groupCollapsed(...data: any[]): void;
  154. /**
  155. * The **`console.groupEnd()`** static method exits the current inline group in the console.
  156. *
  157. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/groupEnd_static)
  158. */
  159. groupEnd(): void;
  160. /**
  161. * The **`console.info()`** static method outputs a message to the console at the 'info' log level.
  162. *
  163. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/info_static)
  164. */
  165. info(...data: any[]): void;
  166. /**
  167. * The **`console.log()`** static method outputs a message to the console.
  168. *
  169. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)
  170. */
  171. log(...data: any[]): void;
  172. /**
  173. * The **`console.table()`** static method displays tabular data as a table.
  174. *
  175. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/table_static)
  176. */
  177. table(tabularData?: any, properties?: string[]): void;
  178. /**
  179. * The **`console.time()`** static method starts a timer you can use to track how long an operation takes.
  180. *
  181. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/time_static)
  182. */
  183. time(label?: string): void;
  184. /**
  185. * The **`console.timeEnd()`** static method stops a timer that was previously started by calling console/time_static.
  186. *
  187. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/timeEnd_static)
  188. */
  189. timeEnd(label?: string): void;
  190. /**
  191. * The **`console.timeLog()`** static method logs the current value of a timer that was previously started by calling console/time_static.
  192. *
  193. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/timeLog_static)
  194. */
  195. timeLog(label?: string, ...data: any[]): void;
  196. timeStamp(label?: string): void;
  197. /**
  198. * The **`console.trace()`** static method outputs a stack trace to the console.
  199. *
  200. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/trace_static)
  201. */
  202. trace(...data: any[]): void;
  203. /**
  204. * The **`console.warn()`** static method outputs a warning message to the console at the 'warning' log level.
  205. *
  206. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/warn_static)
  207. */
  208. warn(...data: any[]): void;
  209. }
  210. declare const console: Console;
  211. type BufferSource = ArrayBufferView | ArrayBuffer;
  212. type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array;
  213. declare namespace WebAssembly {
  214. class CompileError extends Error {
  215. constructor(message?: string);
  216. }
  217. class RuntimeError extends Error {
  218. constructor(message?: string);
  219. }
  220. type ValueType = "anyfunc" | "externref" | "f32" | "f64" | "i32" | "i64" | "v128";
  221. interface GlobalDescriptor {
  222. value: ValueType;
  223. mutable?: boolean;
  224. }
  225. class Global {
  226. constructor(descriptor: GlobalDescriptor, value?: any);
  227. value: any;
  228. valueOf(): any;
  229. }
  230. type ImportValue = ExportValue | number;
  231. type ModuleImports = Record<string, ImportValue>;
  232. type Imports = Record<string, ModuleImports>;
  233. type ExportValue = Function | Global | Memory | Table;
  234. type Exports = Record<string, ExportValue>;
  235. class Instance {
  236. constructor(module: Module, imports?: Imports);
  237. readonly exports: Exports;
  238. }
  239. interface MemoryDescriptor {
  240. initial: number;
  241. maximum?: number;
  242. shared?: boolean;
  243. }
  244. class Memory {
  245. constructor(descriptor: MemoryDescriptor);
  246. readonly buffer: ArrayBuffer;
  247. grow(delta: number): number;
  248. }
  249. type ImportExportKind = "function" | "global" | "memory" | "table";
  250. interface ModuleExportDescriptor {
  251. kind: ImportExportKind;
  252. name: string;
  253. }
  254. interface ModuleImportDescriptor {
  255. kind: ImportExportKind;
  256. module: string;
  257. name: string;
  258. }
  259. abstract class Module {
  260. static customSections(module: Module, sectionName: string): ArrayBuffer[];
  261. static exports(module: Module): ModuleExportDescriptor[];
  262. static imports(module: Module): ModuleImportDescriptor[];
  263. }
  264. type TableKind = "anyfunc" | "externref";
  265. interface TableDescriptor {
  266. element: TableKind;
  267. initial: number;
  268. maximum?: number;
  269. }
  270. class Table {
  271. constructor(descriptor: TableDescriptor, value?: any);
  272. readonly length: number;
  273. get(index: number): any;
  274. grow(delta: number, value?: any): number;
  275. set(index: number, value?: any): void;
  276. }
  277. function instantiate(module: Module, imports?: Imports): Promise<Instance>;
  278. function validate(bytes: BufferSource): boolean;
  279. }
  280. /**
  281. * The **`ServiceWorkerGlobalScope`** interface of the Service Worker API represents the global execution context of a service worker.
  282. * Available only in secure contexts.
  283. *
  284. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ServiceWorkerGlobalScope)
  285. */
  286. interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
  287. DOMException: typeof DOMException;
  288. WorkerGlobalScope: typeof WorkerGlobalScope;
  289. btoa(data: string): string;
  290. atob(data: string): string;
  291. setTimeout(callback: (...args: any[]) => void, msDelay?: number): number;
  292. setTimeout<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;
  293. clearTimeout(timeoutId: number | null): void;
  294. setInterval(callback: (...args: any[]) => void, msDelay?: number): number;
  295. setInterval<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;
  296. clearInterval(timeoutId: number | null): void;
  297. queueMicrotask(task: Function): void;
  298. structuredClone<T>(value: T, options?: StructuredSerializeOptions): T;
  299. reportError(error: any): void;
  300. fetch(input: RequestInfo | URL, init?: RequestInit<RequestInitCfProperties>): Promise<Response>;
  301. self: ServiceWorkerGlobalScope;
  302. crypto: Crypto;
  303. caches: CacheStorage;
  304. scheduler: Scheduler;
  305. performance: Performance;
  306. Cloudflare: Cloudflare;
  307. readonly origin: string;
  308. Event: typeof Event;
  309. ExtendableEvent: typeof ExtendableEvent;
  310. CustomEvent: typeof CustomEvent;
  311. PromiseRejectionEvent: typeof PromiseRejectionEvent;
  312. FetchEvent: typeof FetchEvent;
  313. TailEvent: typeof TailEvent;
  314. TraceEvent: typeof TailEvent;
  315. ScheduledEvent: typeof ScheduledEvent;
  316. MessageEvent: typeof MessageEvent;
  317. CloseEvent: typeof CloseEvent;
  318. ReadableStreamDefaultReader: typeof ReadableStreamDefaultReader;
  319. ReadableStreamBYOBReader: typeof ReadableStreamBYOBReader;
  320. ReadableStream: typeof ReadableStream;
  321. WritableStream: typeof WritableStream;
  322. WritableStreamDefaultWriter: typeof WritableStreamDefaultWriter;
  323. TransformStream: typeof TransformStream;
  324. ByteLengthQueuingStrategy: typeof ByteLengthQueuingStrategy;
  325. CountQueuingStrategy: typeof CountQueuingStrategy;
  326. ErrorEvent: typeof ErrorEvent;
  327. MessageChannel: typeof MessageChannel;
  328. MessagePort: typeof MessagePort;
  329. EventSource: typeof EventSource;
  330. ReadableStreamBYOBRequest: typeof ReadableStreamBYOBRequest;
  331. ReadableStreamDefaultController: typeof ReadableStreamDefaultController;
  332. ReadableByteStreamController: typeof ReadableByteStreamController;
  333. WritableStreamDefaultController: typeof WritableStreamDefaultController;
  334. TransformStreamDefaultController: typeof TransformStreamDefaultController;
  335. CompressionStream: typeof CompressionStream;
  336. DecompressionStream: typeof DecompressionStream;
  337. TextEncoderStream: typeof TextEncoderStream;
  338. TextDecoderStream: typeof TextDecoderStream;
  339. Headers: typeof Headers;
  340. Body: typeof Body;
  341. Request: typeof Request;
  342. Response: typeof Response;
  343. WebSocket: typeof WebSocket;
  344. WebSocketPair: typeof WebSocketPair;
  345. WebSocketRequestResponsePair: typeof WebSocketRequestResponsePair;
  346. AbortController: typeof AbortController;
  347. AbortSignal: typeof AbortSignal;
  348. TextDecoder: typeof TextDecoder;
  349. TextEncoder: typeof TextEncoder;
  350. navigator: Navigator;
  351. Navigator: typeof Navigator;
  352. URL: typeof URL;
  353. URLSearchParams: typeof URLSearchParams;
  354. URLPattern: typeof URLPattern;
  355. Blob: typeof Blob;
  356. File: typeof File;
  357. FormData: typeof FormData;
  358. Crypto: typeof Crypto;
  359. SubtleCrypto: typeof SubtleCrypto;
  360. CryptoKey: typeof CryptoKey;
  361. CacheStorage: typeof CacheStorage;
  362. Cache: typeof Cache;
  363. FixedLengthStream: typeof FixedLengthStream;
  364. IdentityTransformStream: typeof IdentityTransformStream;
  365. HTMLRewriter: typeof HTMLRewriter;
  366. }
  367. declare function addEventListener<Type extends keyof WorkerGlobalScopeEventMap>(type: Type, handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[Type]>, options?: EventTargetAddEventListenerOptions | boolean): void;
  368. declare function removeEventListener<Type extends keyof WorkerGlobalScopeEventMap>(type: Type, handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[Type]>, options?: EventTargetEventListenerOptions | boolean): void;
  369. /**
  370. * The **`dispatchEvent()`** method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order.
  371. *
  372. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)
  373. */
  374. declare function dispatchEvent(event: WorkerGlobalScopeEventMap[keyof WorkerGlobalScopeEventMap]): boolean;
  375. /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/btoa) */
  376. declare function btoa(data: string): string;
  377. /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/atob) */
  378. declare function atob(data: string): string;
  379. /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setTimeout) */
  380. declare function setTimeout(callback: (...args: any[]) => void, msDelay?: number): number;
  381. /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setTimeout) */
  382. declare function setTimeout<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;
  383. /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/clearTimeout) */
  384. declare function clearTimeout(timeoutId: number | null): void;
  385. /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setInterval) */
  386. declare function setInterval(callback: (...args: any[]) => void, msDelay?: number): number;
  387. /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setInterval) */
  388. declare function setInterval<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;
  389. /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/clearInterval) */
  390. declare function clearInterval(timeoutId: number | null): void;
  391. /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/queueMicrotask) */
  392. declare function queueMicrotask(task: Function): void;
  393. /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/structuredClone) */
  394. declare function structuredClone<T>(value: T, options?: StructuredSerializeOptions): T;
  395. /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/reportError) */
  396. declare function reportError(error: any): void;
  397. /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/fetch) */
  398. declare function fetch(input: RequestInfo | URL, init?: RequestInit<RequestInitCfProperties>): Promise<Response>;
  399. declare const self: ServiceWorkerGlobalScope;
  400. /**
  401. * The Web Crypto API provides a set of low-level functions for common cryptographic tasks.
  402. * The Workers runtime implements the full surface of this API, but with some differences in
  403. * the [supported algorithms](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/#supported-algorithms)
  404. * compared to those implemented in most browsers.
  405. *
  406. * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/)
  407. */
  408. declare const crypto: Crypto;
  409. /**
  410. * The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache.
  411. *
  412. * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/)
  413. */
  414. declare const caches: CacheStorage;
  415. declare const scheduler: Scheduler;
  416. /**
  417. * The Workers runtime supports a subset of the Performance API, used to measure timing and performance,
  418. * as well as timing of subrequests and other operations.
  419. *
  420. * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/)
  421. */
  422. declare const performance: Performance;
  423. declare const Cloudflare: Cloudflare;
  424. declare const origin: string;
  425. declare const navigator: Navigator;
  426. interface TestController {
  427. }
  428. interface ExecutionContext<Props = unknown> {
  429. waitUntil(promise: Promise<any>): void;
  430. passThroughOnException(): void;
  431. readonly props: Props;
  432. }
  433. type ExportedHandlerFetchHandler<Env = unknown, CfHostMetadata = unknown> = (request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>, env: Env, ctx: ExecutionContext) => Response | Promise<Response>;
  434. type ExportedHandlerTailHandler<Env = unknown> = (events: TraceItem[], env: Env, ctx: ExecutionContext) => void | Promise<void>;
  435. type ExportedHandlerTraceHandler<Env = unknown> = (traces: TraceItem[], env: Env, ctx: ExecutionContext) => void | Promise<void>;
  436. type ExportedHandlerTailStreamHandler<Env = unknown> = (event: TailStream.TailEvent<TailStream.Onset>, env: Env, ctx: ExecutionContext) => TailStream.TailEventHandlerType | Promise<TailStream.TailEventHandlerType>;
  437. type ExportedHandlerScheduledHandler<Env = unknown> = (controller: ScheduledController, env: Env, ctx: ExecutionContext) => void | Promise<void>;
  438. type ExportedHandlerQueueHandler<Env = unknown, Message = unknown> = (batch: MessageBatch<Message>, env: Env, ctx: ExecutionContext) => void | Promise<void>;
  439. type ExportedHandlerTestHandler<Env = unknown> = (controller: TestController, env: Env, ctx: ExecutionContext) => void | Promise<void>;
  440. interface ExportedHandler<Env = unknown, QueueHandlerMessage = unknown, CfHostMetadata = unknown> {
  441. fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>;
  442. tail?: ExportedHandlerTailHandler<Env>;
  443. trace?: ExportedHandlerTraceHandler<Env>;
  444. tailStream?: ExportedHandlerTailStreamHandler<Env>;
  445. scheduled?: ExportedHandlerScheduledHandler<Env>;
  446. test?: ExportedHandlerTestHandler<Env>;
  447. email?: EmailExportedHandler<Env>;
  448. queue?: ExportedHandlerQueueHandler<Env, QueueHandlerMessage>;
  449. }
  450. interface StructuredSerializeOptions {
  451. transfer?: any[];
  452. }
  453. declare abstract class Navigator {
  454. sendBeacon(url: string, body?: BodyInit): boolean;
  455. readonly userAgent: string;
  456. readonly hardwareConcurrency: number;
  457. readonly language: string;
  458. readonly languages: string[];
  459. }
  460. interface AlarmInvocationInfo {
  461. readonly isRetry: boolean;
  462. readonly retryCount: number;
  463. }
  464. interface Cloudflare {
  465. readonly compatibilityFlags: Record<string, boolean>;
  466. }
  467. interface DurableObject {
  468. fetch(request: Request): Response | Promise<Response>;
  469. alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
  470. webSocketMessage?(ws: WebSocket, message: string | ArrayBuffer): void | Promise<void>;
  471. webSocketClose?(ws: WebSocket, code: number, reason: string, wasClean: boolean): void | Promise<void>;
  472. webSocketError?(ws: WebSocket, error: unknown): void | Promise<void>;
  473. }
  474. type DurableObjectStub<T extends Rpc.DurableObjectBranded | undefined = undefined> = Fetcher<T, "alarm" | "webSocketMessage" | "webSocketClose" | "webSocketError"> & {
  475. readonly id: DurableObjectId;
  476. readonly name?: string;
  477. };
  478. interface DurableObjectId {
  479. toString(): string;
  480. equals(other: DurableObjectId): boolean;
  481. readonly name?: string;
  482. }
  483. declare abstract class DurableObjectNamespace<T extends Rpc.DurableObjectBranded | undefined = undefined> {
  484. newUniqueId(options?: DurableObjectNamespaceNewUniqueIdOptions): DurableObjectId;
  485. idFromName(name: string): DurableObjectId;
  486. idFromString(id: string): DurableObjectId;
  487. get(id: DurableObjectId, options?: DurableObjectNamespaceGetDurableObjectOptions): DurableObjectStub<T>;
  488. getByName(name: string, options?: DurableObjectNamespaceGetDurableObjectOptions): DurableObjectStub<T>;
  489. jurisdiction(jurisdiction: DurableObjectJurisdiction): DurableObjectNamespace<T>;
  490. }
  491. type DurableObjectJurisdiction = "eu" | "fedramp" | "fedramp-high";
  492. interface DurableObjectNamespaceNewUniqueIdOptions {
  493. jurisdiction?: DurableObjectJurisdiction;
  494. }
  495. type DurableObjectLocationHint = "wnam" | "enam" | "sam" | "weur" | "eeur" | "apac" | "oc" | "afr" | "me";
  496. type DurableObjectRoutingMode = "primary-only";
  497. interface DurableObjectNamespaceGetDurableObjectOptions {
  498. locationHint?: DurableObjectLocationHint;
  499. routingMode?: DurableObjectRoutingMode;
  500. }
  501. interface DurableObjectClass<_T extends Rpc.DurableObjectBranded | undefined = undefined> {
  502. }
  503. interface DurableObjectState<Props = unknown> {
  504. waitUntil(promise: Promise<any>): void;
  505. readonly props: Props;
  506. readonly id: DurableObjectId;
  507. readonly storage: DurableObjectStorage;
  508. container?: Container;
  509. blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
  510. acceptWebSocket(ws: WebSocket, tags?: string[]): void;
  511. getWebSockets(tag?: string): WebSocket[];
  512. setWebSocketAutoResponse(maybeReqResp?: WebSocketRequestResponsePair): void;
  513. getWebSocketAutoResponse(): WebSocketRequestResponsePair | null;
  514. getWebSocketAutoResponseTimestamp(ws: WebSocket): Date | null;
  515. setHibernatableWebSocketEventTimeout(timeoutMs?: number): void;
  516. getHibernatableWebSocketEventTimeout(): number | null;
  517. getTags(ws: WebSocket): string[];
  518. abort(reason?: string): void;
  519. }
  520. interface DurableObjectTransaction {
  521. get<T = unknown>(key: string, options?: DurableObjectGetOptions): Promise<T | undefined>;
  522. get<T = unknown>(keys: string[], options?: DurableObjectGetOptions): Promise<Map<string, T>>;
  523. list<T = unknown>(options?: DurableObjectListOptions): Promise<Map<string, T>>;
  524. put<T>(key: string, value: T, options?: DurableObjectPutOptions): Promise<void>;
  525. put<T>(entries: Record<string, T>, options?: DurableObjectPutOptions): Promise<void>;
  526. delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>;
  527. delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>;
  528. rollback(): void;
  529. getAlarm(options?: DurableObjectGetAlarmOptions): Promise<number | null>;
  530. setAlarm(scheduledTime: number | Date, options?: DurableObjectSetAlarmOptions): Promise<void>;
  531. deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
  532. }
  533. interface DurableObjectStorage {
  534. get<T = unknown>(key: string, options?: DurableObjectGetOptions): Promise<T | undefined>;
  535. get<T = unknown>(keys: string[], options?: DurableObjectGetOptions): Promise<Map<string, T>>;
  536. list<T = unknown>(options?: DurableObjectListOptions): Promise<Map<string, T>>;
  537. put<T>(key: string, value: T, options?: DurableObjectPutOptions): Promise<void>;
  538. put<T>(entries: Record<string, T>, options?: DurableObjectPutOptions): Promise<void>;
  539. delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>;
  540. delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>;
  541. deleteAll(options?: DurableObjectPutOptions): Promise<void>;
  542. transaction<T>(closure: (txn: DurableObjectTransaction) => Promise<T>): Promise<T>;
  543. getAlarm(options?: DurableObjectGetAlarmOptions): Promise<number | null>;
  544. setAlarm(scheduledTime: number | Date, options?: DurableObjectSetAlarmOptions): Promise<void>;
  545. deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
  546. sync(): Promise<void>;
  547. sql: SqlStorage;
  548. kv: SyncKvStorage;
  549. transactionSync<T>(closure: () => T): T;
  550. getCurrentBookmark(): Promise<string>;
  551. getBookmarkForTime(timestamp: number | Date): Promise<string>;
  552. onNextSessionRestoreBookmark(bookmark: string): Promise<string>;
  553. }
  554. interface DurableObjectListOptions {
  555. start?: string;
  556. startAfter?: string;
  557. end?: string;
  558. prefix?: string;
  559. reverse?: boolean;
  560. limit?: number;
  561. allowConcurrency?: boolean;
  562. noCache?: boolean;
  563. }
  564. interface DurableObjectGetOptions {
  565. allowConcurrency?: boolean;
  566. noCache?: boolean;
  567. }
  568. interface DurableObjectGetAlarmOptions {
  569. allowConcurrency?: boolean;
  570. }
  571. interface DurableObjectPutOptions {
  572. allowConcurrency?: boolean;
  573. allowUnconfirmed?: boolean;
  574. noCache?: boolean;
  575. }
  576. interface DurableObjectSetAlarmOptions {
  577. allowConcurrency?: boolean;
  578. allowUnconfirmed?: boolean;
  579. }
  580. declare class WebSocketRequestResponsePair {
  581. constructor(request: string, response: string);
  582. get request(): string;
  583. get response(): string;
  584. }
  585. interface AnalyticsEngineDataset {
  586. writeDataPoint(event?: AnalyticsEngineDataPoint): void;
  587. }
  588. interface AnalyticsEngineDataPoint {
  589. indexes?: ((ArrayBuffer | string) | null)[];
  590. doubles?: number[];
  591. blobs?: ((ArrayBuffer | string) | null)[];
  592. }
  593. /**
  594. * The **`Event`** interface represents an event which takes place on an `EventTarget`.
  595. *
  596. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event)
  597. */
  598. declare class Event {
  599. constructor(type: string, init?: EventInit);
  600. /**
  601. * The **`type`** read-only property of the Event interface returns a string containing the event's type.
  602. *
  603. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/type)
  604. */
  605. get type(): string;
  606. /**
  607. * The **`eventPhase`** read-only property of the being evaluated.
  608. *
  609. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/eventPhase)
  610. */
  611. get eventPhase(): number;
  612. /**
  613. * The read-only **`composed`** property of the or not the event will propagate across the shadow DOM boundary into the standard DOM.
  614. *
  615. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composed)
  616. */
  617. get composed(): boolean;
  618. /**
  619. * The **`bubbles`** read-only property of the Event interface indicates whether the event bubbles up through the DOM tree or not.
  620. *
  621. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/bubbles)
  622. */
  623. get bubbles(): boolean;
  624. /**
  625. * The **`cancelable`** read-only property of the Event interface indicates whether the event can be canceled, and therefore prevented as if the event never happened.
  626. *
  627. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelable)
  628. */
  629. get cancelable(): boolean;
  630. /**
  631. * The **`defaultPrevented`** read-only property of the Event interface returns a boolean value indicating whether or not the call to Event.preventDefault() canceled the event.
  632. *
  633. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/defaultPrevented)
  634. */
  635. get defaultPrevented(): boolean;
  636. /**
  637. * The Event property **`returnValue`** indicates whether the default action for this event has been prevented or not.
  638. * @deprecated
  639. *
  640. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/returnValue)
  641. */
  642. get returnValue(): boolean;
  643. /**
  644. * The **`currentTarget`** read-only property of the Event interface identifies the element to which the event handler has been attached.
  645. *
  646. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/currentTarget)
  647. */
  648. get currentTarget(): EventTarget | undefined;
  649. /**
  650. * The read-only **`target`** property of the dispatched.
  651. *
  652. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/target)
  653. */
  654. get target(): EventTarget | undefined;
  655. /**
  656. * The deprecated **`Event.srcElement`** is an alias for the Event.target property.
  657. * @deprecated
  658. *
  659. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/srcElement)
  660. */
  661. get srcElement(): EventTarget | undefined;
  662. /**
  663. * The **`timeStamp`** read-only property of the Event interface returns the time (in milliseconds) at which the event was created.
  664. *
  665. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/timeStamp)
  666. */
  667. get timeStamp(): number;
  668. /**
  669. * The **`isTrusted`** read-only property of the when the event was generated by the user agent (including via user actions and programmatic methods such as HTMLElement.focus()), and `false` when the event was dispatched via The only exception is the `click` event, which initializes the `isTrusted` property to `false` in user agents.
  670. *
  671. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/isTrusted)
  672. */
  673. get isTrusted(): boolean;
  674. /**
  675. * The **`cancelBubble`** property of the Event interface is deprecated.
  676. * @deprecated
  677. *
  678. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelBubble)
  679. */
  680. get cancelBubble(): boolean;
  681. /**
  682. * The **`cancelBubble`** property of the Event interface is deprecated.
  683. * @deprecated
  684. *
  685. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelBubble)
  686. */
  687. set cancelBubble(value: boolean);
  688. /**
  689. * The **`stopImmediatePropagation()`** method of the If several listeners are attached to the same element for the same event type, they are called in the order in which they were added.
  690. *
  691. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopImmediatePropagation)
  692. */
  693. stopImmediatePropagation(): void;
  694. /**
  695. * The **`preventDefault()`** method of the Event interface tells the user agent that if the event does not get explicitly handled, its default action should not be taken as it normally would be.
  696. *
  697. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/preventDefault)
  698. */
  699. preventDefault(): void;
  700. /**
  701. * The **`stopPropagation()`** method of the Event interface prevents further propagation of the current event in the capturing and bubbling phases.
  702. *
  703. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopPropagation)
  704. */
  705. stopPropagation(): void;
  706. /**
  707. * The **`composedPath()`** method of the Event interface returns the event's path which is an array of the objects on which listeners will be invoked.
  708. *
  709. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composedPath)
  710. */
  711. composedPath(): EventTarget[];
  712. static readonly NONE: number;
  713. static readonly CAPTURING_PHASE: number;
  714. static readonly AT_TARGET: number;
  715. static readonly BUBBLING_PHASE: number;
  716. }
  717. interface EventInit {
  718. bubbles?: boolean;
  719. cancelable?: boolean;
  720. composed?: boolean;
  721. }
  722. type EventListener<EventType extends Event = Event> = (event: EventType) => void;
  723. interface EventListenerObject<EventType extends Event = Event> {
  724. handleEvent(event: EventType): void;
  725. }
  726. type EventListenerOrEventListenerObject<EventType extends Event = Event> = EventListener<EventType> | EventListenerObject<EventType>;
  727. /**
  728. * The **`EventTarget`** interface is implemented by objects that can receive events and may have listeners for them.
  729. *
  730. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget)
  731. */
  732. declare class EventTarget<EventMap extends Record<string, Event> = Record<string, Event>> {
  733. constructor();
  734. /**
  735. * The **`addEventListener()`** method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.
  736. *
  737. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener)
  738. */
  739. addEventListener<Type extends keyof EventMap>(type: Type, handler: EventListenerOrEventListenerObject<EventMap[Type]>, options?: EventTargetAddEventListenerOptions | boolean): void;
  740. /**
  741. * The **`removeEventListener()`** method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target.
  742. *
  743. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener)
  744. */
  745. removeEventListener<Type extends keyof EventMap>(type: Type, handler: EventListenerOrEventListenerObject<EventMap[Type]>, options?: EventTargetEventListenerOptions | boolean): void;
  746. /**
  747. * The **`dispatchEvent()`** method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order.
  748. *
  749. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)
  750. */
  751. dispatchEvent(event: EventMap[keyof EventMap]): boolean;
  752. }
  753. interface EventTargetEventListenerOptions {
  754. capture?: boolean;
  755. }
  756. interface EventTargetAddEventListenerOptions {
  757. capture?: boolean;
  758. passive?: boolean;
  759. once?: boolean;
  760. signal?: AbortSignal;
  761. }
  762. interface EventTargetHandlerObject {
  763. handleEvent: (event: Event) => any | undefined;
  764. }
  765. /**
  766. * The **`AbortController`** interface represents a controller object that allows you to abort one or more Web requests as and when desired.
  767. *
  768. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController)
  769. */
  770. declare class AbortController {
  771. constructor();
  772. /**
  773. * The **`signal`** read-only property of the AbortController interface returns an AbortSignal object instance, which can be used to communicate with/abort an asynchronous operation as desired.
  774. *
  775. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController/signal)
  776. */
  777. get signal(): AbortSignal;
  778. /**
  779. * The **`abort()`** method of the AbortController interface aborts an asynchronous operation before it has completed.
  780. *
  781. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController/abort)
  782. */
  783. abort(reason?: any): void;
  784. }
  785. /**
  786. * The **`AbortSignal`** interface represents a signal object that allows you to communicate with an asynchronous operation (such as a fetch request) and abort it if required via an AbortController object.
  787. *
  788. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal)
  789. */
  790. declare abstract class AbortSignal extends EventTarget {
  791. /**
  792. * The **`AbortSignal.abort()`** static method returns an AbortSignal that is already set as aborted (and which does not trigger an AbortSignal/abort_event event).
  793. *
  794. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_static)
  795. */
  796. static abort(reason?: any): AbortSignal;
  797. /**
  798. * The **`AbortSignal.timeout()`** static method returns an AbortSignal that will automatically abort after a specified time.
  799. *
  800. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/timeout_static)
  801. */
  802. static timeout(delay: number): AbortSignal;
  803. /**
  804. * The **`AbortSignal.any()`** static method takes an iterable of abort signals and returns an AbortSignal.
  805. *
  806. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/any_static)
  807. */
  808. static any(signals: AbortSignal[]): AbortSignal;
  809. /**
  810. * The **`aborted`** read-only property returns a value that indicates whether the asynchronous operations the signal is communicating with are aborted (`true`) or not (`false`).
  811. *
  812. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/aborted)
  813. */
  814. get aborted(): boolean;
  815. /**
  816. * The **`reason`** read-only property returns a JavaScript value that indicates the abort reason.
  817. *
  818. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/reason)
  819. */
  820. get reason(): any;
  821. /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_event) */
  822. get onabort(): any | null;
  823. /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_event) */
  824. set onabort(value: any | null);
  825. /**
  826. * The **`throwIfAborted()`** method throws the signal's abort AbortSignal.reason if the signal has been aborted; otherwise it does nothing.
  827. *
  828. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/throwIfAborted)
  829. */
  830. throwIfAborted(): void;
  831. }
  832. interface Scheduler {
  833. wait(delay: number, maybeOptions?: SchedulerWaitOptions): Promise<void>;
  834. }
  835. interface SchedulerWaitOptions {
  836. signal?: AbortSignal;
  837. }
  838. /**
  839. * The **`ExtendableEvent`** interface extends the lifetime of the `install` and `activate` events dispatched on the global scope as part of the service worker lifecycle.
  840. *
  841. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ExtendableEvent)
  842. */
  843. declare abstract class ExtendableEvent extends Event {
  844. /**
  845. * The **`ExtendableEvent.waitUntil()`** method tells the event dispatcher that work is ongoing.
  846. *
  847. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ExtendableEvent/waitUntil)
  848. */
  849. waitUntil(promise: Promise<any>): void;
  850. }
  851. /**
  852. * The **`CustomEvent`** interface represents events initialized by an application for any purpose.
  853. *
  854. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomEvent)
  855. */
  856. declare class CustomEvent<T = any> extends Event {
  857. constructor(type: string, init?: CustomEventCustomEventInit);
  858. /**
  859. * The read-only **`detail`** property of the CustomEvent interface returns any data passed when initializing the event.
  860. *
  861. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomEvent/detail)
  862. */
  863. get detail(): T;
  864. }
  865. interface CustomEventCustomEventInit {
  866. bubbles?: boolean;
  867. cancelable?: boolean;
  868. composed?: boolean;
  869. detail?: any;
  870. }
  871. /**
  872. * The **`Blob`** interface represents a blob, which is a file-like object of immutable, raw data; they can be read as text or binary data, or converted into a ReadableStream so its methods can be used for processing the data.
  873. *
  874. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob)
  875. */
  876. declare class Blob {
  877. constructor(type?: ((ArrayBuffer | ArrayBufferView) | string | Blob)[], options?: BlobOptions);
  878. /**
  879. * The **`size`** read-only property of the Blob interface returns the size of the Blob or File in bytes.
  880. *
  881. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/size)
  882. */
  883. get size(): number;
  884. /**
  885. * The **`type`** read-only property of the Blob interface returns the MIME type of the file.
  886. *
  887. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/type)
  888. */
  889. get type(): string;
  890. /**
  891. * The **`slice()`** method of the Blob interface creates and returns a new `Blob` object which contains data from a subset of the blob on which it's called.
  892. *
  893. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/slice)
  894. */
  895. slice(start?: number, end?: number, type?: string): Blob;
  896. /**
  897. * The **`arrayBuffer()`** method of the Blob interface returns a Promise that resolves with the contents of the blob as binary data contained in an ArrayBuffer.
  898. *
  899. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/arrayBuffer)
  900. */
  901. arrayBuffer(): Promise<ArrayBuffer>;
  902. /**
  903. * The **`bytes()`** method of the Blob interface returns a Promise that resolves with a Uint8Array containing the contents of the blob as an array of bytes.
  904. *
  905. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/bytes)
  906. */
  907. bytes(): Promise<Uint8Array>;
  908. /**
  909. * The **`text()`** method of the string containing the contents of the blob, interpreted as UTF-8.
  910. *
  911. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/text)
  912. */
  913. text(): Promise<string>;
  914. /**
  915. * The **`stream()`** method of the Blob interface returns a ReadableStream which upon reading returns the data contained within the `Blob`.
  916. *
  917. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/stream)
  918. */
  919. stream(): ReadableStream;
  920. }
  921. interface BlobOptions {
  922. type?: string;
  923. }
  924. /**
  925. * The **`File`** interface provides information about files and allows JavaScript in a web page to access their content.
  926. *
  927. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/File)
  928. */
  929. declare class File extends Blob {
  930. constructor(bits: ((ArrayBuffer | ArrayBufferView) | string | Blob)[] | undefined, name: string, options?: FileOptions);
  931. /**
  932. * The **`name`** read-only property of the File interface returns the name of the file represented by a File object.
  933. *
  934. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/name)
  935. */
  936. get name(): string;
  937. /**
  938. * The **`lastModified`** read-only property of the File interface provides the last modified date of the file as the number of milliseconds since the Unix epoch (January 1, 1970 at midnight).
  939. *
  940. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/lastModified)
  941. */
  942. get lastModified(): number;
  943. }
  944. interface FileOptions {
  945. type?: string;
  946. lastModified?: number;
  947. }
  948. /**
  949. * The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache.
  950. *
  951. * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/)
  952. */
  953. declare abstract class CacheStorage {
  954. /**
  955. * The **`open()`** method of the the Cache object matching the `cacheName`.
  956. *
  957. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CacheStorage/open)
  958. */
  959. open(cacheName: string): Promise<Cache>;
  960. readonly default: Cache;
  961. }
  962. /**
  963. * The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache.
  964. *
  965. * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/)
  966. */
  967. declare abstract class Cache {
  968. /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#delete) */
  969. delete(request: RequestInfo | URL, options?: CacheQueryOptions): Promise<boolean>;
  970. /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#match) */
  971. match(request: RequestInfo | URL, options?: CacheQueryOptions): Promise<Response | undefined>;
  972. /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#put) */
  973. put(request: RequestInfo | URL, response: Response): Promise<void>;
  974. }
  975. interface CacheQueryOptions {
  976. ignoreMethod?: boolean;
  977. }
  978. /**
  979. * The Web Crypto API provides a set of low-level functions for common cryptographic tasks.
  980. * The Workers runtime implements the full surface of this API, but with some differences in
  981. * the [supported algorithms](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/#supported-algorithms)
  982. * compared to those implemented in most browsers.
  983. *
  984. * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/)
  985. */
  986. declare abstract class Crypto {
  987. /**
  988. * The **`Crypto.subtle`** read-only property returns a cryptographic operations.
  989. * Available only in secure contexts.
  990. *
  991. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/subtle)
  992. */
  993. get subtle(): SubtleCrypto;
  994. /**
  995. * The **`Crypto.getRandomValues()`** method lets you get cryptographically strong random values.
  996. *
  997. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/getRandomValues)
  998. */
  999. getRandomValues<T extends Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | BigInt64Array | BigUint64Array>(buffer: T): T;
  1000. /**
  1001. * The **`randomUUID()`** method of the Crypto interface is used to generate a v4 UUID using a cryptographically secure random number generator.
  1002. * Available only in secure contexts.
  1003. *
  1004. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/randomUUID)
  1005. */
  1006. randomUUID(): string;
  1007. DigestStream: typeof DigestStream;
  1008. }
  1009. /**
  1010. * The **`SubtleCrypto`** interface of the Web Crypto API provides a number of low-level cryptographic functions.
  1011. * Available only in secure contexts.
  1012. *
  1013. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto)
  1014. */
  1015. declare abstract class SubtleCrypto {
  1016. /**
  1017. * The **`encrypt()`** method of the SubtleCrypto interface encrypts data.
  1018. *
  1019. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/encrypt)
  1020. */
  1021. encrypt(algorithm: string | SubtleCryptoEncryptAlgorithm, key: CryptoKey, plainText: ArrayBuffer | ArrayBufferView): Promise<ArrayBuffer>;
  1022. /**
  1023. * The **`decrypt()`** method of the SubtleCrypto interface decrypts some encrypted data.
  1024. *
  1025. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/decrypt)
  1026. */
  1027. decrypt(algorithm: string | SubtleCryptoEncryptAlgorithm, key: CryptoKey, cipherText: ArrayBuffer | ArrayBufferView): Promise<ArrayBuffer>;
  1028. /**
  1029. * The **`sign()`** method of the SubtleCrypto interface generates a digital signature.
  1030. *
  1031. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/sign)
  1032. */
  1033. sign(algorithm: string | SubtleCryptoSignAlgorithm, key: CryptoKey, data: ArrayBuffer | ArrayBufferView): Promise<ArrayBuffer>;
  1034. /**
  1035. * The **`verify()`** method of the SubtleCrypto interface verifies a digital signature.
  1036. *
  1037. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/verify)
  1038. */
  1039. verify(algorithm: string | SubtleCryptoSignAlgorithm, key: CryptoKey, signature: ArrayBuffer | ArrayBufferView, data: ArrayBuffer | ArrayBufferView): Promise<boolean>;
  1040. /**
  1041. * The **`digest()`** method of the SubtleCrypto interface generates a _digest_ of the given data, using the specified hash function.
  1042. *
  1043. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/digest)
  1044. */
  1045. digest(algorithm: string | SubtleCryptoHashAlgorithm, data: ArrayBuffer | ArrayBufferView): Promise<ArrayBuffer>;
  1046. /**
  1047. * The **`generateKey()`** method of the SubtleCrypto interface is used to generate a new key (for symmetric algorithms) or key pair (for public-key algorithms).
  1048. *
  1049. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/generateKey)
  1050. */
  1051. generateKey(algorithm: string | SubtleCryptoGenerateKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise<CryptoKey | CryptoKeyPair>;
  1052. /**
  1053. * The **`deriveKey()`** method of the SubtleCrypto interface can be used to derive a secret key from a master key.
  1054. *
  1055. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/deriveKey)
  1056. */
  1057. deriveKey(algorithm: string | SubtleCryptoDeriveKeyAlgorithm, baseKey: CryptoKey, derivedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise<CryptoKey>;
  1058. /**
  1059. * The **`deriveBits()`** method of the key.
  1060. *
  1061. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/deriveBits)
  1062. */
  1063. deriveBits(algorithm: string | SubtleCryptoDeriveKeyAlgorithm, baseKey: CryptoKey, length?: number | null): Promise<ArrayBuffer>;
  1064. /**
  1065. * The **`importKey()`** method of the SubtleCrypto interface imports a key: that is, it takes as input a key in an external, portable format and gives you a CryptoKey object that you can use in the Web Crypto API.
  1066. *
  1067. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/importKey)
  1068. */
  1069. importKey(format: string, keyData: (ArrayBuffer | ArrayBufferView) | JsonWebKey, algorithm: string | SubtleCryptoImportKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise<CryptoKey>;
  1070. /**
  1071. * The **`exportKey()`** method of the SubtleCrypto interface exports a key: that is, it takes as input a CryptoKey object and gives you the key in an external, portable format.
  1072. *
  1073. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/exportKey)
  1074. */
  1075. exportKey(format: string, key: CryptoKey): Promise<ArrayBuffer | JsonWebKey>;
  1076. /**
  1077. * The **`wrapKey()`** method of the SubtleCrypto interface 'wraps' a key.
  1078. *
  1079. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/wrapKey)
  1080. */
  1081. wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: string | SubtleCryptoEncryptAlgorithm): Promise<ArrayBuffer>;
  1082. /**
  1083. * The **`unwrapKey()`** method of the SubtleCrypto interface 'unwraps' a key.
  1084. *
  1085. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/unwrapKey)
  1086. */
  1087. unwrapKey(format: string, wrappedKey: ArrayBuffer | ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string | SubtleCryptoEncryptAlgorithm, unwrappedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise<CryptoKey>;
  1088. timingSafeEqual(a: ArrayBuffer | ArrayBufferView, b: ArrayBuffer | ArrayBufferView): boolean;
  1089. }
  1090. /**
  1091. * The **`CryptoKey`** interface of the Web Crypto API represents a cryptographic key obtained from one of the SubtleCrypto methods SubtleCrypto.generateKey, SubtleCrypto.deriveKey, SubtleCrypto.importKey, or SubtleCrypto.unwrapKey.
  1092. * Available only in secure contexts.
  1093. *
  1094. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey)
  1095. */
  1096. declare abstract class CryptoKey {
  1097. /**
  1098. * The read-only **`type`** property of the CryptoKey interface indicates which kind of key is represented by the object.
  1099. *
  1100. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/type)
  1101. */
  1102. readonly type: string;
  1103. /**
  1104. * The read-only **`extractable`** property of the CryptoKey interface indicates whether or not the key may be extracted using `SubtleCrypto.exportKey()` or `SubtleCrypto.wrapKey()`.
  1105. *
  1106. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/extractable)
  1107. */
  1108. readonly extractable: boolean;
  1109. /**
  1110. * The read-only **`algorithm`** property of the CryptoKey interface returns an object describing the algorithm for which this key can be used, and any associated extra parameters.
  1111. *
  1112. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/algorithm)
  1113. */
  1114. readonly algorithm: CryptoKeyKeyAlgorithm | CryptoKeyAesKeyAlgorithm | CryptoKeyHmacKeyAlgorithm | CryptoKeyRsaKeyAlgorithm | CryptoKeyEllipticKeyAlgorithm | CryptoKeyArbitraryKeyAlgorithm;
  1115. /**
  1116. * The read-only **`usages`** property of the CryptoKey interface indicates what can be done with the key.
  1117. *
  1118. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/usages)
  1119. */
  1120. readonly usages: string[];
  1121. }
  1122. interface CryptoKeyPair {
  1123. publicKey: CryptoKey;
  1124. privateKey: CryptoKey;
  1125. }
  1126. interface JsonWebKey {
  1127. kty: string;
  1128. use?: string;
  1129. key_ops?: string[];
  1130. alg?: string;
  1131. ext?: boolean;
  1132. crv?: string;
  1133. x?: string;
  1134. y?: string;
  1135. d?: string;
  1136. n?: string;
  1137. e?: string;
  1138. p?: string;
  1139. q?: string;
  1140. dp?: string;
  1141. dq?: string;
  1142. qi?: string;
  1143. oth?: RsaOtherPrimesInfo[];
  1144. k?: string;
  1145. }
  1146. interface RsaOtherPrimesInfo {
  1147. r?: string;
  1148. d?: string;
  1149. t?: string;
  1150. }
  1151. interface SubtleCryptoDeriveKeyAlgorithm {
  1152. name: string;
  1153. salt?: (ArrayBuffer | ArrayBufferView);
  1154. iterations?: number;
  1155. hash?: (string | SubtleCryptoHashAlgorithm);
  1156. $public?: CryptoKey;
  1157. info?: (ArrayBuffer | ArrayBufferView);
  1158. }
  1159. interface SubtleCryptoEncryptAlgorithm {
  1160. name: string;
  1161. iv?: (ArrayBuffer | ArrayBufferView);
  1162. additionalData?: (ArrayBuffer | ArrayBufferView);
  1163. tagLength?: number;
  1164. counter?: (ArrayBuffer | ArrayBufferView);
  1165. length?: number;
  1166. label?: (ArrayBuffer | ArrayBufferView);
  1167. }
  1168. interface SubtleCryptoGenerateKeyAlgorithm {
  1169. name: string;
  1170. hash?: (string | SubtleCryptoHashAlgorithm);
  1171. modulusLength?: number;
  1172. publicExponent?: (ArrayBuffer | ArrayBufferView);
  1173. length?: number;
  1174. namedCurve?: string;
  1175. }
  1176. interface SubtleCryptoHashAlgorithm {
  1177. name: string;
  1178. }
  1179. interface SubtleCryptoImportKeyAlgorithm {
  1180. name: string;
  1181. hash?: (string | SubtleCryptoHashAlgorithm);
  1182. length?: number;
  1183. namedCurve?: string;
  1184. compressed?: boolean;
  1185. }
  1186. interface SubtleCryptoSignAlgorithm {
  1187. name: string;
  1188. hash?: (string | SubtleCryptoHashAlgorithm);
  1189. dataLength?: number;
  1190. saltLength?: number;
  1191. }
  1192. interface CryptoKeyKeyAlgorithm {
  1193. name: string;
  1194. }
  1195. interface CryptoKeyAesKeyAlgorithm {
  1196. name: string;
  1197. length: number;
  1198. }
  1199. interface CryptoKeyHmacKeyAlgorithm {
  1200. name: string;
  1201. hash: CryptoKeyKeyAlgorithm;
  1202. length: number;
  1203. }
  1204. interface CryptoKeyRsaKeyAlgorithm {
  1205. name: string;
  1206. modulusLength: number;
  1207. publicExponent: ArrayBuffer | ArrayBufferView;
  1208. hash?: CryptoKeyKeyAlgorithm;
  1209. }
  1210. interface CryptoKeyEllipticKeyAlgorithm {
  1211. name: string;
  1212. namedCurve: string;
  1213. }
  1214. interface CryptoKeyArbitraryKeyAlgorithm {
  1215. name: string;
  1216. hash?: CryptoKeyKeyAlgorithm;
  1217. namedCurve?: string;
  1218. length?: number;
  1219. }
  1220. declare class DigestStream extends WritableStream<ArrayBuffer | ArrayBufferView> {
  1221. constructor(algorithm: string | SubtleCryptoHashAlgorithm);
  1222. readonly digest: Promise<ArrayBuffer>;
  1223. get bytesWritten(): number | bigint;
  1224. }
  1225. /**
  1226. * The **`TextDecoder`** interface represents a decoder for a specific text encoding, such as `UTF-8`, `ISO-8859-2`, `KOI8-R`, `GBK`, etc.
  1227. *
  1228. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoder)
  1229. */
  1230. declare class TextDecoder {
  1231. constructor(label?: string, options?: TextDecoderConstructorOptions);
  1232. /**
  1233. * The **`TextDecoder.decode()`** method returns a string containing text decoded from the buffer passed as a parameter.
  1234. *
  1235. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoder/decode)
  1236. */
  1237. decode(input?: (ArrayBuffer | ArrayBufferView), options?: TextDecoderDecodeOptions): string;
  1238. get encoding(): string;
  1239. get fatal(): boolean;
  1240. get ignoreBOM(): boolean;
  1241. }
  1242. /**
  1243. * The **`TextEncoder`** interface takes a stream of code points as input and emits a stream of UTF-8 bytes.
  1244. *
  1245. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder)
  1246. */
  1247. declare class TextEncoder {
  1248. constructor();
  1249. /**
  1250. * The **`TextEncoder.encode()`** method takes a string as input, and returns a Global_Objects/Uint8Array containing the text given in parameters encoded with the specific method for that TextEncoder object.
  1251. *
  1252. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder/encode)
  1253. */
  1254. encode(input?: string): Uint8Array;
  1255. /**
  1256. * The **`TextEncoder.encodeInto()`** method takes a string to encode and a destination Uint8Array to put resulting UTF-8 encoded text into, and returns a dictionary object indicating the progress of the encoding.
  1257. *
  1258. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder/encodeInto)
  1259. */
  1260. encodeInto(input: string, buffer: Uint8Array): TextEncoderEncodeIntoResult;
  1261. get encoding(): string;
  1262. }
  1263. interface TextDecoderConstructorOptions {
  1264. fatal: boolean;
  1265. ignoreBOM: boolean;
  1266. }
  1267. interface TextDecoderDecodeOptions {
  1268. stream: boolean;
  1269. }
  1270. interface TextEncoderEncodeIntoResult {
  1271. read: number;
  1272. written: number;
  1273. }
  1274. /**
  1275. * The **`ErrorEvent`** interface represents events providing information related to errors in scripts or in files.
  1276. *
  1277. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent)
  1278. */
  1279. declare class ErrorEvent extends Event {
  1280. constructor(type: string, init?: ErrorEventErrorEventInit);
  1281. /**
  1282. * The **`filename`** read-only property of the ErrorEvent interface returns a string containing the name of the script file in which the error occurred.
  1283. *
  1284. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/filename)
  1285. */
  1286. get filename(): string;
  1287. /**
  1288. * The **`message`** read-only property of the ErrorEvent interface returns a string containing a human-readable error message describing the problem.
  1289. *
  1290. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/message)
  1291. */
  1292. get message(): string;
  1293. /**
  1294. * The **`lineno`** read-only property of the ErrorEvent interface returns an integer containing the line number of the script file on which the error occurred.
  1295. *
  1296. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/lineno)
  1297. */
  1298. get lineno(): number;
  1299. /**
  1300. * The **`colno`** read-only property of the ErrorEvent interface returns an integer containing the column number of the script file on which the error occurred.
  1301. *
  1302. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/colno)
  1303. */
  1304. get colno(): number;
  1305. /**
  1306. * The **`error`** read-only property of the ErrorEvent interface returns a JavaScript value, such as an Error or DOMException, representing the error associated with this event.
  1307. *
  1308. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/error)
  1309. */
  1310. get error(): any;
  1311. }
  1312. interface ErrorEventErrorEventInit {
  1313. message?: string;
  1314. filename?: string;
  1315. lineno?: number;
  1316. colno?: number;
  1317. error?: any;
  1318. }
  1319. /**
  1320. * The **`MessageEvent`** interface represents a message received by a target object.
  1321. *
  1322. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent)
  1323. */
  1324. declare class MessageEvent extends Event {
  1325. constructor(type: string, initializer: MessageEventInit);
  1326. /**
  1327. * The **`data`** read-only property of the The data sent by the message emitter; this can be any data type, depending on what originated this event.
  1328. *
  1329. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/data)
  1330. */
  1331. readonly data: any;
  1332. /**
  1333. * The **`origin`** read-only property of the origin of the message emitter.
  1334. *
  1335. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/origin)
  1336. */
  1337. readonly origin: string | null;
  1338. /**
  1339. * The **`lastEventId`** read-only property of the unique ID for the event.
  1340. *
  1341. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/lastEventId)
  1342. */
  1343. readonly lastEventId: string;
  1344. /**
  1345. * The **`source`** read-only property of the a WindowProxy, MessagePort, or a `MessageEventSource` (which can be a WindowProxy, message emitter.
  1346. *
  1347. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/source)
  1348. */
  1349. readonly source: MessagePort | null;
  1350. /**
  1351. * The **`ports`** read-only property of the containing all MessagePort objects sent with the message, in order.
  1352. *
  1353. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/ports)
  1354. */
  1355. readonly ports: MessagePort[];
  1356. }
  1357. interface MessageEventInit {
  1358. data: ArrayBuffer | string;
  1359. }
  1360. /**
  1361. * The **`PromiseRejectionEvent`** interface represents events which are sent to the global script context when JavaScript Promises are rejected.
  1362. *
  1363. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent)
  1364. */
  1365. declare abstract class PromiseRejectionEvent extends Event {
  1366. /**
  1367. * The PromiseRejectionEvent interface's **`promise`** read-only property indicates the JavaScript rejected.
  1368. *
  1369. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent/promise)
  1370. */
  1371. readonly promise: Promise<any>;
  1372. /**
  1373. * The PromiseRejectionEvent **`reason`** read-only property is any JavaScript value or Object which provides the reason passed into Promise.reject().
  1374. *
  1375. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent/reason)
  1376. */
  1377. readonly reason: any;
  1378. }
  1379. /**
  1380. * The **`FormData`** interface provides a way to construct a set of key/value pairs representing form fields and their values, which can be sent using the Window/fetch, XMLHttpRequest.send() or navigator.sendBeacon() methods.
  1381. *
  1382. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData)
  1383. */
  1384. declare class FormData {
  1385. constructor();
  1386. /**
  1387. * The **`append()`** method of the FormData interface appends a new value onto an existing key inside a `FormData` object, or adds the key if it does not already exist.
  1388. *
  1389. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append)
  1390. */
  1391. append(name: string, value: string): void;
  1392. /**
  1393. * The **`append()`** method of the FormData interface appends a new value onto an existing key inside a `FormData` object, or adds the key if it does not already exist.
  1394. *
  1395. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append)
  1396. */
  1397. append(name: string, value: Blob, filename?: string): void;
  1398. /**
  1399. * The **`delete()`** method of the FormData interface deletes a key and its value(s) from a `FormData` object.
  1400. *
  1401. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/delete)
  1402. */
  1403. delete(name: string): void;
  1404. /**
  1405. * The **`get()`** method of the FormData interface returns the first value associated with a given key from within a `FormData` object.
  1406. *
  1407. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/get)
  1408. */
  1409. get(name: string): (File | string) | null;
  1410. /**
  1411. * The **`getAll()`** method of the FormData interface returns all the values associated with a given key from within a `FormData` object.
  1412. *
  1413. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/getAll)
  1414. */
  1415. getAll(name: string): (File | string)[];
  1416. /**
  1417. * The **`has()`** method of the FormData interface returns whether a `FormData` object contains a certain key.
  1418. *
  1419. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/has)
  1420. */
  1421. has(name: string): boolean;
  1422. /**
  1423. * The **`set()`** method of the FormData interface sets a new value for an existing key inside a `FormData` object, or adds the key/value if it does not already exist.
  1424. *
  1425. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set)
  1426. */
  1427. set(name: string, value: string): void;
  1428. /**
  1429. * The **`set()`** method of the FormData interface sets a new value for an existing key inside a `FormData` object, or adds the key/value if it does not already exist.
  1430. *
  1431. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set)
  1432. */
  1433. set(name: string, value: Blob, filename?: string): void;
  1434. /* Returns an array of key, value pairs for every entry in the list. */
  1435. entries(): IterableIterator<[
  1436. key: string,
  1437. value: File | string
  1438. ]>;
  1439. /* Returns a list of keys in the list. */
  1440. keys(): IterableIterator<string>;
  1441. /* Returns a list of values in the list. */
  1442. values(): IterableIterator<(File | string)>;
  1443. forEach<This = unknown>(callback: (this: This, value: File | string, key: string, parent: FormData) => void, thisArg?: This): void;
  1444. [Symbol.iterator](): IterableIterator<[
  1445. key: string,
  1446. value: File | string
  1447. ]>;
  1448. }
  1449. interface ContentOptions {
  1450. html?: boolean;
  1451. }
  1452. declare class HTMLRewriter {
  1453. constructor();
  1454. on(selector: string, handlers: HTMLRewriterElementContentHandlers): HTMLRewriter;
  1455. onDocument(handlers: HTMLRewriterDocumentContentHandlers): HTMLRewriter;
  1456. transform(response: Response): Response;
  1457. }
  1458. interface HTMLRewriterElementContentHandlers {
  1459. element?(element: Element): void | Promise<void>;
  1460. comments?(comment: Comment): void | Promise<void>;
  1461. text?(element: Text): void | Promise<void>;
  1462. }
  1463. interface HTMLRewriterDocumentContentHandlers {
  1464. doctype?(doctype: Doctype): void | Promise<void>;
  1465. comments?(comment: Comment): void | Promise<void>;
  1466. text?(text: Text): void | Promise<void>;
  1467. end?(end: DocumentEnd): void | Promise<void>;
  1468. }
  1469. interface Doctype {
  1470. readonly name: string | null;
  1471. readonly publicId: string | null;
  1472. readonly systemId: string | null;
  1473. }
  1474. interface Element {
  1475. tagName: string;
  1476. readonly attributes: IterableIterator<string[]>;
  1477. readonly removed: boolean;
  1478. readonly namespaceURI: string;
  1479. getAttribute(name: string): string | null;
  1480. hasAttribute(name: string): boolean;
  1481. setAttribute(name: string, value: string): Element;
  1482. removeAttribute(name: string): Element;
  1483. before(content: string | ReadableStream | Response, options?: ContentOptions): Element;
  1484. after(content: string | ReadableStream | Response, options?: ContentOptions): Element;
  1485. prepend(content: string | ReadableStream | Response, options?: ContentOptions): Element;
  1486. append(content: string | ReadableStream | Response, options?: ContentOptions): Element;
  1487. replace(content: string | ReadableStream | Response, options?: ContentOptions): Element;
  1488. remove(): Element;
  1489. removeAndKeepContent(): Element;
  1490. setInnerContent(content: string | ReadableStream | Response, options?: ContentOptions): Element;
  1491. onEndTag(handler: (tag: EndTag) => void | Promise<void>): void;
  1492. }
  1493. interface EndTag {
  1494. name: string;
  1495. before(content: string | ReadableStream | Response, options?: ContentOptions): EndTag;
  1496. after(content: string | ReadableStream | Response, options?: ContentOptions): EndTag;
  1497. remove(): EndTag;
  1498. }
  1499. interface Comment {
  1500. text: string;
  1501. readonly removed: boolean;
  1502. before(content: string, options?: ContentOptions): Comment;
  1503. after(content: string, options?: ContentOptions): Comment;
  1504. replace(content: string, options?: ContentOptions): Comment;
  1505. remove(): Comment;
  1506. }
  1507. interface Text {
  1508. readonly text: string;
  1509. readonly lastInTextNode: boolean;
  1510. readonly removed: boolean;
  1511. before(content: string | ReadableStream | Response, options?: ContentOptions): Text;
  1512. after(content: string | ReadableStream | Response, options?: ContentOptions): Text;
  1513. replace(content: string | ReadableStream | Response, options?: ContentOptions): Text;
  1514. remove(): Text;
  1515. }
  1516. interface DocumentEnd {
  1517. append(content: string, options?: ContentOptions): DocumentEnd;
  1518. }
  1519. /**
  1520. * This is the event type for `fetch` events dispatched on the ServiceWorkerGlobalScope.
  1521. *
  1522. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent)
  1523. */
  1524. declare abstract class FetchEvent extends ExtendableEvent {
  1525. /**
  1526. * The **`request`** read-only property of the the event handler.
  1527. *
  1528. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/request)
  1529. */
  1530. readonly request: Request;
  1531. /**
  1532. * The **`respondWith()`** method of allows you to provide a promise for a Response yourself.
  1533. *
  1534. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/respondWith)
  1535. */
  1536. respondWith(promise: Response | Promise<Response>): void;
  1537. passThroughOnException(): void;
  1538. }
  1539. type HeadersInit = Headers | Iterable<Iterable<string>> | Record<string, string>;
  1540. /**
  1541. * The **`Headers`** interface of the Fetch API allows you to perform various actions on HTTP request and response headers.
  1542. *
  1543. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers)
  1544. */
  1545. declare class Headers {
  1546. constructor(init?: HeadersInit);
  1547. /**
  1548. * The **`get()`** method of the Headers interface returns a byte string of all the values of a header within a `Headers` object with a given name.
  1549. *
  1550. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/get)
  1551. */
  1552. get(name: string): string | null;
  1553. getAll(name: string): string[];
  1554. /**
  1555. * The **`getSetCookie()`** method of the Headers interface returns an array containing the values of all Set-Cookie headers associated with a response.
  1556. *
  1557. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/getSetCookie)
  1558. */
  1559. getSetCookie(): string[];
  1560. /**
  1561. * The **`has()`** method of the Headers interface returns a boolean stating whether a `Headers` object contains a certain header.
  1562. *
  1563. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/has)
  1564. */
  1565. has(name: string): boolean;
  1566. /**
  1567. * The **`set()`** method of the Headers interface sets a new value for an existing header inside a `Headers` object, or adds the header if it does not already exist.
  1568. *
  1569. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/set)
  1570. */
  1571. set(name: string, value: string): void;
  1572. /**
  1573. * The **`append()`** method of the Headers interface appends a new value onto an existing header inside a `Headers` object, or adds the header if it does not already exist.
  1574. *
  1575. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/append)
  1576. */
  1577. append(name: string, value: string): void;
  1578. /**
  1579. * The **`delete()`** method of the Headers interface deletes a header from the current `Headers` object.
  1580. *
  1581. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/delete)
  1582. */
  1583. delete(name: string): void;
  1584. forEach<This = unknown>(callback: (this: This, value: string, key: string, parent: Headers) => void, thisArg?: This): void;
  1585. /* Returns an iterator allowing to go through all key/value pairs contained in this object. */
  1586. entries(): IterableIterator<[
  1587. key: string,
  1588. value: string
  1589. ]>;
  1590. /* Returns an iterator allowing to go through all keys of the key/value pairs contained in this object. */
  1591. keys(): IterableIterator<string>;
  1592. /* Returns an iterator allowing to go through all values of the key/value pairs contained in this object. */
  1593. values(): IterableIterator<string>;
  1594. [Symbol.iterator](): IterableIterator<[
  1595. key: string,
  1596. value: string
  1597. ]>;
  1598. }
  1599. type BodyInit = ReadableStream<Uint8Array> | string | ArrayBuffer | ArrayBufferView | Blob | URLSearchParams | FormData;
  1600. declare abstract class Body {
  1601. /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/body) */
  1602. get body(): ReadableStream | null;
  1603. /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bodyUsed) */
  1604. get bodyUsed(): boolean;
  1605. /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/arrayBuffer) */
  1606. arrayBuffer(): Promise<ArrayBuffer>;
  1607. /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bytes) */
  1608. bytes(): Promise<Uint8Array>;
  1609. /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/text) */
  1610. text(): Promise<string>;
  1611. /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/json) */
  1612. json<T>(): Promise<T>;
  1613. /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/formData) */
  1614. formData(): Promise<FormData>;
  1615. /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/blob) */
  1616. blob(): Promise<Blob>;
  1617. }
  1618. /**
  1619. * The **`Response`** interface of the Fetch API represents the response to a request.
  1620. *
  1621. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
  1622. */
  1623. declare var Response: {
  1624. prototype: Response;
  1625. new (body?: BodyInit | null, init?: ResponseInit): Response;
  1626. error(): Response;
  1627. redirect(url: string, status?: number): Response;
  1628. json(any: any, maybeInit?: (ResponseInit | Response)): Response;
  1629. };
  1630. /**
  1631. * The **`Response`** interface of the Fetch API represents the response to a request.
  1632. *
  1633. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
  1634. */
  1635. interface Response extends Body {
  1636. /**
  1637. * The **`clone()`** method of the Response interface creates a clone of a response object, identical in every way, but stored in a different variable.
  1638. *
  1639. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/clone)
  1640. */
  1641. clone(): Response;
  1642. /**
  1643. * The **`status`** read-only property of the Response interface contains the HTTP status codes of the response.
  1644. *
  1645. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/status)
  1646. */
  1647. status: number;
  1648. /**
  1649. * The **`statusText`** read-only property of the Response interface contains the status message corresponding to the HTTP status code in Response.status.
  1650. *
  1651. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/statusText)
  1652. */
  1653. statusText: string;
  1654. /**
  1655. * The **`headers`** read-only property of the with the response.
  1656. *
  1657. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/headers)
  1658. */
  1659. headers: Headers;
  1660. /**
  1661. * The **`ok`** read-only property of the Response interface contains a Boolean stating whether the response was successful (status in the range 200-299) or not.
  1662. *
  1663. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/ok)
  1664. */
  1665. ok: boolean;
  1666. /**
  1667. * The **`redirected`** read-only property of the Response interface indicates whether or not the response is the result of a request you made which was redirected.
  1668. *
  1669. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/redirected)
  1670. */
  1671. redirected: boolean;
  1672. /**
  1673. * The **`url`** read-only property of the Response interface contains the URL of the response.
  1674. *
  1675. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/url)
  1676. */
  1677. url: string;
  1678. webSocket: WebSocket | null;
  1679. cf: any | undefined;
  1680. /**
  1681. * The **`type`** read-only property of the Response interface contains the type of the response.
  1682. *
  1683. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/type)
  1684. */
  1685. type: "default" | "error";
  1686. }
  1687. interface ResponseInit {
  1688. status?: number;
  1689. statusText?: string;
  1690. headers?: HeadersInit;
  1691. cf?: any;
  1692. webSocket?: (WebSocket | null);
  1693. encodeBody?: "automatic" | "manual";
  1694. }
  1695. type RequestInfo<CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>> = Request<CfHostMetadata, Cf> | string;
  1696. /**
  1697. * The **`Request`** interface of the Fetch API represents a resource request.
  1698. *
  1699. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request)
  1700. */
  1701. declare var Request: {
  1702. prototype: Request;
  1703. new <CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>>(input: RequestInfo<CfProperties> | URL, init?: RequestInit<Cf>): Request<CfHostMetadata, Cf>;
  1704. };
  1705. /**
  1706. * The **`Request`** interface of the Fetch API represents a resource request.
  1707. *
  1708. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request)
  1709. */
  1710. interface Request<CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>> extends Body {
  1711. /**
  1712. * The **`clone()`** method of the Request interface creates a copy of the current `Request` object.
  1713. *
  1714. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/clone)
  1715. */
  1716. clone(): Request<CfHostMetadata, Cf>;
  1717. /**
  1718. * The **`method`** read-only property of the `POST`, etc.) A String indicating the method of the request.
  1719. *
  1720. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/method)
  1721. */
  1722. method: string;
  1723. /**
  1724. * The **`url`** read-only property of the Request interface contains the URL of the request.
  1725. *
  1726. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/url)
  1727. */
  1728. url: string;
  1729. /**
  1730. * The **`headers`** read-only property of the with the request.
  1731. *
  1732. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/headers)
  1733. */
  1734. headers: Headers;
  1735. /**
  1736. * The **`redirect`** read-only property of the Request interface contains the mode for how redirects are handled.
  1737. *
  1738. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/redirect)
  1739. */
  1740. redirect: string;
  1741. fetcher: Fetcher | null;
  1742. /**
  1743. * The read-only **`signal`** property of the Request interface returns the AbortSignal associated with the request.
  1744. *
  1745. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/signal)
  1746. */
  1747. signal: AbortSignal;
  1748. cf: Cf | undefined;
  1749. /**
  1750. * The **`integrity`** read-only property of the Request interface contains the subresource integrity value of the request.
  1751. *
  1752. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/integrity)
  1753. */
  1754. integrity: string;
  1755. /**
  1756. * The **`keepalive`** read-only property of the Request interface contains the request's `keepalive` setting (`true` or `false`), which indicates whether the browser will keep the associated request alive if the page that initiated it is unloaded before the request is complete.
  1757. *
  1758. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/keepalive)
  1759. */
  1760. keepalive: boolean;
  1761. /**
  1762. * The **`cache`** read-only property of the Request interface contains the cache mode of the request.
  1763. *
  1764. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/cache)
  1765. */
  1766. cache?: "no-store" | "no-cache";
  1767. }
  1768. interface RequestInit<Cf = CfProperties> {
  1769. /* A string to set request's method. */
  1770. method?: string;
  1771. /* A Headers object, an object literal, or an array of two-item arrays to set request's headers. */
  1772. headers?: HeadersInit;
  1773. /* A BodyInit object or null to set request's body. */
  1774. body?: BodyInit | null;
  1775. /* A string indicating whether request follows redirects, results in an error upon encountering a redirect, or returns the redirect (in an opaque fashion). Sets request's redirect. */
  1776. redirect?: string;
  1777. fetcher?: (Fetcher | null);
  1778. cf?: Cf;
  1779. /* A string indicating how the request will interact with the browser's cache to set request's cache. */
  1780. cache?: "no-store" | "no-cache";
  1781. /* A cryptographic hash of the resource to be fetched by request. Sets request's integrity. */
  1782. integrity?: string;
  1783. /* An AbortSignal to set request's signal. */
  1784. signal?: (AbortSignal | null);
  1785. encodeResponseBody?: "automatic" | "manual";
  1786. }
  1787. type Service<T extends (new (...args: any[]) => Rpc.WorkerEntrypointBranded) | Rpc.WorkerEntrypointBranded | ExportedHandler<any, any, any> | undefined = undefined> = T extends new (...args: any[]) => Rpc.WorkerEntrypointBranded ? Fetcher<InstanceType<T>> : T extends Rpc.WorkerEntrypointBranded ? Fetcher<T> : T extends Exclude<Rpc.EntrypointBranded, Rpc.WorkerEntrypointBranded> ? never : Fetcher<undefined>;
  1788. type Fetcher<T extends Rpc.EntrypointBranded | undefined = undefined, Reserved extends string = never> = (T extends Rpc.EntrypointBranded ? Rpc.Provider<T, Reserved | "fetch" | "connect"> : unknown) & {
  1789. fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
  1790. connect(address: SocketAddress | string, options?: SocketOptions): Socket;
  1791. };
  1792. interface KVNamespaceListKey<Metadata, Key extends string = string> {
  1793. name: Key;
  1794. expiration?: number;
  1795. metadata?: Metadata;
  1796. }
  1797. type KVNamespaceListResult<Metadata, Key extends string = string> = {
  1798. list_complete: false;
  1799. keys: KVNamespaceListKey<Metadata, Key>[];
  1800. cursor: string;
  1801. cacheStatus: string | null;
  1802. } | {
  1803. list_complete: true;
  1804. keys: KVNamespaceListKey<Metadata, Key>[];
  1805. cacheStatus: string | null;
  1806. };
  1807. interface KVNamespace<Key extends string = string> {
  1808. get(key: Key, options?: Partial<KVNamespaceGetOptions<undefined>>): Promise<string | null>;
  1809. get(key: Key, type: "text"): Promise<string | null>;
  1810. get<ExpectedValue = unknown>(key: Key, type: "json"): Promise<ExpectedValue | null>;
  1811. get(key: Key, type: "arrayBuffer"): Promise<ArrayBuffer | null>;
  1812. get(key: Key, type: "stream"): Promise<ReadableStream | null>;
  1813. get(key: Key, options?: KVNamespaceGetOptions<"text">): Promise<string | null>;
  1814. get<ExpectedValue = unknown>(key: Key, options?: KVNamespaceGetOptions<"json">): Promise<ExpectedValue | null>;
  1815. get(key: Key, options?: KVNamespaceGetOptions<"arrayBuffer">): Promise<ArrayBuffer | null>;
  1816. get(key: Key, options?: KVNamespaceGetOptions<"stream">): Promise<ReadableStream | null>;
  1817. get(key: Array<Key>, type: "text"): Promise<Map<string, string | null>>;
  1818. get<ExpectedValue = unknown>(key: Array<Key>, type: "json"): Promise<Map<string, ExpectedValue | null>>;
  1819. get(key: Array<Key>, options?: Partial<KVNamespaceGetOptions<undefined>>): Promise<Map<string, string | null>>;
  1820. get(key: Array<Key>, options?: KVNamespaceGetOptions<"text">): Promise<Map<string, string | null>>;
  1821. get<ExpectedValue = unknown>(key: Array<Key>, options?: KVNamespaceGetOptions<"json">): Promise<Map<string, ExpectedValue | null>>;
  1822. list<Metadata = unknown>(options?: KVNamespaceListOptions): Promise<KVNamespaceListResult<Metadata, Key>>;
  1823. put(key: Key, value: string | ArrayBuffer | ArrayBufferView | ReadableStream, options?: KVNamespacePutOptions): Promise<void>;
  1824. getWithMetadata<Metadata = unknown>(key: Key, options?: Partial<KVNamespaceGetOptions<undefined>>): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
  1825. getWithMetadata<Metadata = unknown>(key: Key, type: "text"): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
  1826. getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(key: Key, type: "json"): Promise<KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>;
  1827. getWithMetadata<Metadata = unknown>(key: Key, type: "arrayBuffer"): Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>;
  1828. getWithMetadata<Metadata = unknown>(key: Key, type: "stream"): Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>;
  1829. getWithMetadata<Metadata = unknown>(key: Key, options: KVNamespaceGetOptions<"text">): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
  1830. getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(key: Key, options: KVNamespaceGetOptions<"json">): Promise<KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>;
  1831. getWithMetadata<Metadata = unknown>(key: Key, options: KVNamespaceGetOptions<"arrayBuffer">): Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>;
  1832. getWithMetadata<Metadata = unknown>(key: Key, options: KVNamespaceGetOptions<"stream">): Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>;
  1833. getWithMetadata<Metadata = unknown>(key: Array<Key>, type: "text"): Promise<Map<string, KVNamespaceGetWithMetadataResult<string, Metadata>>>;
  1834. getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(key: Array<Key>, type: "json"): Promise<Map<string, KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>>;
  1835. getWithMetadata<Metadata = unknown>(key: Array<Key>, options?: Partial<KVNamespaceGetOptions<undefined>>): Promise<Map<string, KVNamespaceGetWithMetadataResult<string, Metadata>>>;
  1836. getWithMetadata<Metadata = unknown>(key: Array<Key>, options?: KVNamespaceGetOptions<"text">): Promise<Map<string, KVNamespaceGetWithMetadataResult<string, Metadata>>>;
  1837. getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(key: Array<Key>, options?: KVNamespaceGetOptions<"json">): Promise<Map<string, KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>>;
  1838. delete(key: Key): Promise<void>;
  1839. }
  1840. interface KVNamespaceListOptions {
  1841. limit?: number;
  1842. prefix?: (string | null);
  1843. cursor?: (string | null);
  1844. }
  1845. interface KVNamespaceGetOptions<Type> {
  1846. type: Type;
  1847. cacheTtl?: number;
  1848. }
  1849. interface KVNamespacePutOptions {
  1850. expiration?: number;
  1851. expirationTtl?: number;
  1852. metadata?: (any | null);
  1853. }
  1854. interface KVNamespaceGetWithMetadataResult<Value, Metadata> {
  1855. value: Value | null;
  1856. metadata: Metadata | null;
  1857. cacheStatus: string | null;
  1858. }
  1859. type QueueContentType = "text" | "bytes" | "json" | "v8";
  1860. interface Queue<Body = unknown> {
  1861. send(message: Body, options?: QueueSendOptions): Promise<void>;
  1862. sendBatch(messages: Iterable<MessageSendRequest<Body>>, options?: QueueSendBatchOptions): Promise<void>;
  1863. }
  1864. interface QueueSendOptions {
  1865. contentType?: QueueContentType;
  1866. delaySeconds?: number;
  1867. }
  1868. interface QueueSendBatchOptions {
  1869. delaySeconds?: number;
  1870. }
  1871. interface MessageSendRequest<Body = unknown> {
  1872. body: Body;
  1873. contentType?: QueueContentType;
  1874. delaySeconds?: number;
  1875. }
  1876. interface QueueRetryOptions {
  1877. delaySeconds?: number;
  1878. }
  1879. interface Message<Body = unknown> {
  1880. readonly id: string;
  1881. readonly timestamp: Date;
  1882. readonly body: Body;
  1883. readonly attempts: number;
  1884. retry(options?: QueueRetryOptions): void;
  1885. ack(): void;
  1886. }
  1887. interface QueueEvent<Body = unknown> extends ExtendableEvent {
  1888. readonly messages: readonly Message<Body>[];
  1889. readonly queue: string;
  1890. retryAll(options?: QueueRetryOptions): void;
  1891. ackAll(): void;
  1892. }
  1893. interface MessageBatch<Body = unknown> {
  1894. readonly messages: readonly Message<Body>[];
  1895. readonly queue: string;
  1896. retryAll(options?: QueueRetryOptions): void;
  1897. ackAll(): void;
  1898. }
  1899. interface R2Error extends Error {
  1900. readonly name: string;
  1901. readonly code: number;
  1902. readonly message: string;
  1903. readonly action: string;
  1904. readonly stack: any;
  1905. }
  1906. interface R2ListOptions {
  1907. limit?: number;
  1908. prefix?: string;
  1909. cursor?: string;
  1910. delimiter?: string;
  1911. startAfter?: string;
  1912. include?: ("httpMetadata" | "customMetadata")[];
  1913. }
  1914. declare abstract class R2Bucket {
  1915. head(key: string): Promise<R2Object | null>;
  1916. get(key: string, options: R2GetOptions & {
  1917. onlyIf: R2Conditional | Headers;
  1918. }): Promise<R2ObjectBody | R2Object | null>;
  1919. get(key: string, options?: R2GetOptions): Promise<R2ObjectBody | null>;
  1920. put(key: string, value: ReadableStream | ArrayBuffer | ArrayBufferView | string | null | Blob, options?: R2PutOptions & {
  1921. onlyIf: R2Conditional | Headers;
  1922. }): Promise<R2Object | null>;
  1923. put(key: string, value: ReadableStream | ArrayBuffer | ArrayBufferView | string | null | Blob, options?: R2PutOptions): Promise<R2Object>;
  1924. createMultipartUpload(key: string, options?: R2MultipartOptions): Promise<R2MultipartUpload>;
  1925. resumeMultipartUpload(key: string, uploadId: string): R2MultipartUpload;
  1926. delete(keys: string | string[]): Promise<void>;
  1927. list(options?: R2ListOptions): Promise<R2Objects>;
  1928. }
  1929. interface R2MultipartUpload {
  1930. readonly key: string;
  1931. readonly uploadId: string;
  1932. uploadPart(partNumber: number, value: ReadableStream | (ArrayBuffer | ArrayBufferView) | string | Blob, options?: R2UploadPartOptions): Promise<R2UploadedPart>;
  1933. abort(): Promise<void>;
  1934. complete(uploadedParts: R2UploadedPart[]): Promise<R2Object>;
  1935. }
  1936. interface R2UploadedPart {
  1937. partNumber: number;
  1938. etag: string;
  1939. }
  1940. declare abstract class R2Object {
  1941. readonly key: string;
  1942. readonly version: string;
  1943. readonly size: number;
  1944. readonly etag: string;
  1945. readonly httpEtag: string;
  1946. readonly checksums: R2Checksums;
  1947. readonly uploaded: Date;
  1948. readonly httpMetadata?: R2HTTPMetadata;
  1949. readonly customMetadata?: Record<string, string>;
  1950. readonly range?: R2Range;
  1951. readonly storageClass: string;
  1952. readonly ssecKeyMd5?: string;
  1953. writeHttpMetadata(headers: Headers): void;
  1954. }
  1955. interface R2ObjectBody extends R2Object {
  1956. get body(): ReadableStream;
  1957. get bodyUsed(): boolean;
  1958. arrayBuffer(): Promise<ArrayBuffer>;
  1959. bytes(): Promise<Uint8Array>;
  1960. text(): Promise<string>;
  1961. json<T>(): Promise<T>;
  1962. blob(): Promise<Blob>;
  1963. }
  1964. type R2Range = {
  1965. offset: number;
  1966. length?: number;
  1967. } | {
  1968. offset?: number;
  1969. length: number;
  1970. } | {
  1971. suffix: number;
  1972. };
  1973. interface R2Conditional {
  1974. etagMatches?: string;
  1975. etagDoesNotMatch?: string;
  1976. uploadedBefore?: Date;
  1977. uploadedAfter?: Date;
  1978. secondsGranularity?: boolean;
  1979. }
  1980. interface R2GetOptions {
  1981. onlyIf?: (R2Conditional | Headers);
  1982. range?: (R2Range | Headers);
  1983. ssecKey?: (ArrayBuffer | string);
  1984. }
  1985. interface R2PutOptions {
  1986. onlyIf?: (R2Conditional | Headers);
  1987. httpMetadata?: (R2HTTPMetadata | Headers);
  1988. customMetadata?: Record<string, string>;
  1989. md5?: ((ArrayBuffer | ArrayBufferView) | string);
  1990. sha1?: ((ArrayBuffer | ArrayBufferView) | string);
  1991. sha256?: ((ArrayBuffer | ArrayBufferView) | string);
  1992. sha384?: ((ArrayBuffer | ArrayBufferView) | string);
  1993. sha512?: ((ArrayBuffer | ArrayBufferView) | string);
  1994. storageClass?: string;
  1995. ssecKey?: (ArrayBuffer | string);
  1996. }
  1997. interface R2MultipartOptions {
  1998. httpMetadata?: (R2HTTPMetadata | Headers);
  1999. customMetadata?: Record<string, string>;
  2000. storageClass?: string;
  2001. ssecKey?: (ArrayBuffer | string);
  2002. }
  2003. interface R2Checksums {
  2004. readonly md5?: ArrayBuffer;
  2005. readonly sha1?: ArrayBuffer;
  2006. readonly sha256?: ArrayBuffer;
  2007. readonly sha384?: ArrayBuffer;
  2008. readonly sha512?: ArrayBuffer;
  2009. toJSON(): R2StringChecksums;
  2010. }
  2011. interface R2StringChecksums {
  2012. md5?: string;
  2013. sha1?: string;
  2014. sha256?: string;
  2015. sha384?: string;
  2016. sha512?: string;
  2017. }
  2018. interface R2HTTPMetadata {
  2019. contentType?: string;
  2020. contentLanguage?: string;
  2021. contentDisposition?: string;
  2022. contentEncoding?: string;
  2023. cacheControl?: string;
  2024. cacheExpiry?: Date;
  2025. }
  2026. type R2Objects = {
  2027. objects: R2Object[];
  2028. delimitedPrefixes: string[];
  2029. } & ({
  2030. truncated: true;
  2031. cursor: string;
  2032. } | {
  2033. truncated: false;
  2034. });
  2035. interface R2UploadPartOptions {
  2036. ssecKey?: (ArrayBuffer | string);
  2037. }
  2038. declare abstract class ScheduledEvent extends ExtendableEvent {
  2039. readonly scheduledTime: number;
  2040. readonly cron: string;
  2041. noRetry(): void;
  2042. }
  2043. interface ScheduledController {
  2044. readonly scheduledTime: number;
  2045. readonly cron: string;
  2046. noRetry(): void;
  2047. }
  2048. interface QueuingStrategy<T = any> {
  2049. highWaterMark?: (number | bigint);
  2050. size?: (chunk: T) => number | bigint;
  2051. }
  2052. interface UnderlyingSink<W = any> {
  2053. type?: string;
  2054. start?: (controller: WritableStreamDefaultController) => void | Promise<void>;
  2055. write?: (chunk: W, controller: WritableStreamDefaultController) => void | Promise<void>;
  2056. abort?: (reason: any) => void | Promise<void>;
  2057. close?: () => void | Promise<void>;
  2058. }
  2059. interface UnderlyingByteSource {
  2060. type: "bytes";
  2061. autoAllocateChunkSize?: number;
  2062. start?: (controller: ReadableByteStreamController) => void | Promise<void>;
  2063. pull?: (controller: ReadableByteStreamController) => void | Promise<void>;
  2064. cancel?: (reason: any) => void | Promise<void>;
  2065. }
  2066. interface UnderlyingSource<R = any> {
  2067. type?: "" | undefined;
  2068. start?: (controller: ReadableStreamDefaultController<R>) => void | Promise<void>;
  2069. pull?: (controller: ReadableStreamDefaultController<R>) => void | Promise<void>;
  2070. cancel?: (reason: any) => void | Promise<void>;
  2071. expectedLength?: (number | bigint);
  2072. }
  2073. interface Transformer<I = any, O = any> {
  2074. readableType?: string;
  2075. writableType?: string;
  2076. start?: (controller: TransformStreamDefaultController<O>) => void | Promise<void>;
  2077. transform?: (chunk: I, controller: TransformStreamDefaultController<O>) => void | Promise<void>;
  2078. flush?: (controller: TransformStreamDefaultController<O>) => void | Promise<void>;
  2079. cancel?: (reason: any) => void | Promise<void>;
  2080. expectedLength?: number;
  2081. }
  2082. interface StreamPipeOptions {
  2083. preventAbort?: boolean;
  2084. preventCancel?: boolean;
  2085. /**
  2086. * Pipes this readable stream to a given writable stream destination. The way in which the piping process behaves under various error conditions can be customized with a number of passed options. It returns a promise that fulfills when the piping process completes successfully, or rejects if any errors were encountered.
  2087. *
  2088. * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
  2089. *
  2090. * Errors and closures of the source and destination streams propagate as follows:
  2091. *
  2092. * An error in this source readable stream will abort destination, unless preventAbort is truthy. The returned promise will be rejected with the source's error, or with any error that occurs during aborting the destination.
  2093. *
  2094. * An error in destination will cancel this source readable stream, unless preventCancel is truthy. The returned promise will be rejected with the destination's error, or with any error that occurs during canceling the source.
  2095. *
  2096. * When this source readable stream closes, destination will be closed, unless preventClose is truthy. The returned promise will be fulfilled once this process completes, unless an error is encountered while closing the destination, in which case it will be rejected with that error.
  2097. *
  2098. * If destination starts out closed or closing, this source readable stream will be canceled, unless preventCancel is true. The returned promise will be rejected with an error indicating piping to a closed stream failed, or with any error that occurs during canceling the source.
  2099. *
  2100. * The signal option can be set to an AbortSignal to allow aborting an ongoing pipe operation via the corresponding AbortController. In this case, this source readable stream will be canceled, and destination aborted, unless the respective options preventCancel or preventAbort are set.
  2101. */
  2102. preventClose?: boolean;
  2103. signal?: AbortSignal;
  2104. }
  2105. type ReadableStreamReadResult<R = any> = {
  2106. done: false;
  2107. value: R;
  2108. } | {
  2109. done: true;
  2110. value?: undefined;
  2111. };
  2112. /**
  2113. * The `ReadableStream` interface of the Streams API represents a readable stream of byte data.
  2114. *
  2115. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream)
  2116. */
  2117. interface ReadableStream<R = any> {
  2118. /**
  2119. * The **`locked`** read-only property of the ReadableStream interface returns whether or not the readable stream is locked to a reader.
  2120. *
  2121. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/locked)
  2122. */
  2123. get locked(): boolean;
  2124. /**
  2125. * The **`cancel()`** method of the ReadableStream interface returns a Promise that resolves when the stream is canceled.
  2126. *
  2127. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/cancel)
  2128. */
  2129. cancel(reason?: any): Promise<void>;
  2130. /**
  2131. * The **`getReader()`** method of the ReadableStream interface creates a reader and locks the stream to it.
  2132. *
  2133. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/getReader)
  2134. */
  2135. getReader(): ReadableStreamDefaultReader<R>;
  2136. /**
  2137. * The **`getReader()`** method of the ReadableStream interface creates a reader and locks the stream to it.
  2138. *
  2139. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/getReader)
  2140. */
  2141. getReader(options: ReadableStreamGetReaderOptions): ReadableStreamBYOBReader;
  2142. /**
  2143. * The **`pipeThrough()`** method of the ReadableStream interface provides a chainable way of piping the current stream through a transform stream or any other writable/readable pair.
  2144. *
  2145. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/pipeThrough)
  2146. */
  2147. pipeThrough<T>(transform: ReadableWritablePair<T, R>, options?: StreamPipeOptions): ReadableStream<T>;
  2148. /**
  2149. * The **`pipeTo()`** method of the ReadableStream interface pipes the current `ReadableStream` to a given WritableStream and returns a Promise that fulfills when the piping process completes successfully, or rejects if any errors were encountered.
  2150. *
  2151. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/pipeTo)
  2152. */
  2153. pipeTo(destination: WritableStream<R>, options?: StreamPipeOptions): Promise<void>;
  2154. /**
  2155. * The **`tee()`** method of the two-element array containing the two resulting branches as new ReadableStream instances.
  2156. *
  2157. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/tee)
  2158. */
  2159. tee(): [
  2160. ReadableStream<R>,
  2161. ReadableStream<R>
  2162. ];
  2163. values(options?: ReadableStreamValuesOptions): AsyncIterableIterator<R>;
  2164. [Symbol.asyncIterator](options?: ReadableStreamValuesOptions): AsyncIterableIterator<R>;
  2165. }
  2166. /**
  2167. * The `ReadableStream` interface of the Streams API represents a readable stream of byte data.
  2168. *
  2169. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream)
  2170. */
  2171. declare const ReadableStream: {
  2172. prototype: ReadableStream;
  2173. new (underlyingSource: UnderlyingByteSource, strategy?: QueuingStrategy<Uint8Array>): ReadableStream<Uint8Array>;
  2174. new <R = any>(underlyingSource?: UnderlyingSource<R>, strategy?: QueuingStrategy<R>): ReadableStream<R>;
  2175. };
  2176. /**
  2177. * The **`ReadableStreamDefaultReader`** interface of the Streams API represents a default reader that can be used to read stream data supplied from a network (such as a fetch request).
  2178. *
  2179. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader)
  2180. */
  2181. declare class ReadableStreamDefaultReader<R = any> {
  2182. constructor(stream: ReadableStream);
  2183. get closed(): Promise<void>;
  2184. cancel(reason?: any): Promise<void>;
  2185. /**
  2186. * The **`read()`** method of the ReadableStreamDefaultReader interface returns a Promise providing access to the next chunk in the stream's internal queue.
  2187. *
  2188. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader/read)
  2189. */
  2190. read(): Promise<ReadableStreamReadResult<R>>;
  2191. /**
  2192. * The **`releaseLock()`** method of the ReadableStreamDefaultReader interface releases the reader's lock on the stream.
  2193. *
  2194. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader/releaseLock)
  2195. */
  2196. releaseLock(): void;
  2197. }
  2198. /**
  2199. * The `ReadableStreamBYOBReader` interface of the Streams API defines a reader for a ReadableStream that supports zero-copy reading from an underlying byte source.
  2200. *
  2201. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader)
  2202. */
  2203. declare class ReadableStreamBYOBReader {
  2204. constructor(stream: ReadableStream);
  2205. get closed(): Promise<void>;
  2206. cancel(reason?: any): Promise<void>;
  2207. /**
  2208. * The **`read()`** method of the ReadableStreamBYOBReader interface is used to read data into a view on a user-supplied buffer from an associated readable byte stream.
  2209. *
  2210. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/read)
  2211. */
  2212. read<T extends ArrayBufferView>(view: T): Promise<ReadableStreamReadResult<T>>;
  2213. /**
  2214. * The **`releaseLock()`** method of the ReadableStreamBYOBReader interface releases the reader's lock on the stream.
  2215. *
  2216. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/releaseLock)
  2217. */
  2218. releaseLock(): void;
  2219. readAtLeast<T extends ArrayBufferView>(minElements: number, view: T): Promise<ReadableStreamReadResult<T>>;
  2220. }
  2221. interface ReadableStreamBYOBReaderReadableStreamBYOBReaderReadOptions {
  2222. min?: number;
  2223. }
  2224. interface ReadableStreamGetReaderOptions {
  2225. /**
  2226. * Creates a ReadableStreamBYOBReader and locks the stream to the new reader.
  2227. *
  2228. * This call behaves the same way as the no-argument variant, except that it only works on readable byte streams, i.e. streams which were constructed specifically with the ability to handle "bring your own buffer" reading. The returned BYOB reader provides the ability to directly read individual chunks from the stream via its read() method, into developer-supplied buffers, allowing more precise control over allocation.
  2229. */
  2230. mode: "byob";
  2231. }
  2232. /**
  2233. * The **`ReadableStreamBYOBRequest`** interface of the Streams API represents a 'pull request' for data from an underlying source that will made as a zero-copy transfer to a consumer (bypassing the stream's internal queues).
  2234. *
  2235. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest)
  2236. */
  2237. declare abstract class ReadableStreamBYOBRequest {
  2238. /**
  2239. * The **`view`** getter property of the ReadableStreamBYOBRequest interface returns the current view.
  2240. *
  2241. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/view)
  2242. */
  2243. get view(): Uint8Array | null;
  2244. /**
  2245. * The **`respond()`** method of the ReadableStreamBYOBRequest interface is used to signal to the associated readable byte stream that the specified number of bytes were written into the ReadableStreamBYOBRequest.view.
  2246. *
  2247. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/respond)
  2248. */
  2249. respond(bytesWritten: number): void;
  2250. /**
  2251. * The **`respondWithNewView()`** method of the ReadableStreamBYOBRequest interface specifies a new view that the consumer of the associated readable byte stream should write to instead of ReadableStreamBYOBRequest.view.
  2252. *
  2253. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/respondWithNewView)
  2254. */
  2255. respondWithNewView(view: ArrayBuffer | ArrayBufferView): void;
  2256. get atLeast(): number | null;
  2257. }
  2258. /**
  2259. * The **`ReadableStreamDefaultController`** interface of the Streams API represents a controller allowing control of a ReadableStream's state and internal queue.
  2260. *
  2261. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController)
  2262. */
  2263. declare abstract class ReadableStreamDefaultController<R = any> {
  2264. /**
  2265. * The **`desiredSize`** read-only property of the required to fill the stream's internal queue.
  2266. *
  2267. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/desiredSize)
  2268. */
  2269. get desiredSize(): number | null;
  2270. /**
  2271. * The **`close()`** method of the ReadableStreamDefaultController interface closes the associated stream.
  2272. *
  2273. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/close)
  2274. */
  2275. close(): void;
  2276. /**
  2277. * The **`enqueue()`** method of the ```js-nolint enqueue(chunk) ``` - `chunk` - : The chunk to enqueue.
  2278. *
  2279. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/enqueue)
  2280. */
  2281. enqueue(chunk?: R): void;
  2282. /**
  2283. * The **`error()`** method of the with the associated stream to error.
  2284. *
  2285. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/error)
  2286. */
  2287. error(reason: any): void;
  2288. }
  2289. /**
  2290. * The **`ReadableByteStreamController`** interface of the Streams API represents a controller for a readable byte stream.
  2291. *
  2292. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController)
  2293. */
  2294. declare abstract class ReadableByteStreamController {
  2295. /**
  2296. * The **`byobRequest`** read-only property of the ReadableByteStreamController interface returns the current BYOB request, or `null` if there are no pending requests.
  2297. *
  2298. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/byobRequest)
  2299. */
  2300. get byobRequest(): ReadableStreamBYOBRequest | null;
  2301. /**
  2302. * The **`desiredSize`** read-only property of the ReadableByteStreamController interface returns the number of bytes required to fill the stream's internal queue to its 'desired size'.
  2303. *
  2304. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/desiredSize)
  2305. */
  2306. get desiredSize(): number | null;
  2307. /**
  2308. * The **`close()`** method of the ReadableByteStreamController interface closes the associated stream.
  2309. *
  2310. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/close)
  2311. */
  2312. close(): void;
  2313. /**
  2314. * The **`enqueue()`** method of the ReadableByteStreamController interface enqueues a given chunk on the associated readable byte stream (the chunk is copied into the stream's internal queues).
  2315. *
  2316. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/enqueue)
  2317. */
  2318. enqueue(chunk: ArrayBuffer | ArrayBufferView): void;
  2319. /**
  2320. * The **`error()`** method of the ReadableByteStreamController interface causes any future interactions with the associated stream to error with the specified reason.
  2321. *
  2322. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/error)
  2323. */
  2324. error(reason: any): void;
  2325. }
  2326. /**
  2327. * The **`WritableStreamDefaultController`** interface of the Streams API represents a controller allowing control of a WritableStream's state.
  2328. *
  2329. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController)
  2330. */
  2331. declare abstract class WritableStreamDefaultController {
  2332. /**
  2333. * The read-only **`signal`** property of the WritableStreamDefaultController interface returns the AbortSignal associated with the controller.
  2334. *
  2335. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController/signal)
  2336. */
  2337. get signal(): AbortSignal;
  2338. /**
  2339. * The **`error()`** method of the with the associated stream to error.
  2340. *
  2341. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController/error)
  2342. */
  2343. error(reason?: any): void;
  2344. }
  2345. /**
  2346. * The **`TransformStreamDefaultController`** interface of the Streams API provides methods to manipulate the associated ReadableStream and WritableStream.
  2347. *
  2348. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController)
  2349. */
  2350. declare abstract class TransformStreamDefaultController<O = any> {
  2351. /**
  2352. * The **`desiredSize`** read-only property of the TransformStreamDefaultController interface returns the desired size to fill the queue of the associated ReadableStream.
  2353. *
  2354. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/desiredSize)
  2355. */
  2356. get desiredSize(): number | null;
  2357. /**
  2358. * The **`enqueue()`** method of the TransformStreamDefaultController interface enqueues the given chunk in the readable side of the stream.
  2359. *
  2360. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/enqueue)
  2361. */
  2362. enqueue(chunk?: O): void;
  2363. /**
  2364. * The **`error()`** method of the TransformStreamDefaultController interface errors both sides of the stream.
  2365. *
  2366. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/error)
  2367. */
  2368. error(reason: any): void;
  2369. /**
  2370. * The **`terminate()`** method of the TransformStreamDefaultController interface closes the readable side and errors the writable side of the stream.
  2371. *
  2372. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/terminate)
  2373. */
  2374. terminate(): void;
  2375. }
  2376. interface ReadableWritablePair<R = any, W = any> {
  2377. readable: ReadableStream<R>;
  2378. /**
  2379. * Provides a convenient, chainable way of piping this readable stream through a transform stream (or any other { writable, readable } pair). It simply pipes the stream into the writable side of the supplied pair, and returns the readable side for further use.
  2380. *
  2381. * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
  2382. */
  2383. writable: WritableStream<W>;
  2384. }
  2385. /**
  2386. * The **`WritableStream`** interface of the Streams API provides a standard abstraction for writing streaming data to a destination, known as a sink.
  2387. *
  2388. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream)
  2389. */
  2390. declare class WritableStream<W = any> {
  2391. constructor(underlyingSink?: UnderlyingSink, queuingStrategy?: QueuingStrategy);
  2392. /**
  2393. * The **`locked`** read-only property of the WritableStream interface returns a boolean indicating whether the `WritableStream` is locked to a writer.
  2394. *
  2395. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/locked)
  2396. */
  2397. get locked(): boolean;
  2398. /**
  2399. * The **`abort()`** method of the WritableStream interface aborts the stream, signaling that the producer can no longer successfully write to the stream and it is to be immediately moved to an error state, with any queued writes discarded.
  2400. *
  2401. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/abort)
  2402. */
  2403. abort(reason?: any): Promise<void>;
  2404. /**
  2405. * The **`close()`** method of the WritableStream interface closes the associated stream.
  2406. *
  2407. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/close)
  2408. */
  2409. close(): Promise<void>;
  2410. /**
  2411. * The **`getWriter()`** method of the WritableStream interface returns a new instance of WritableStreamDefaultWriter and locks the stream to that instance.
  2412. *
  2413. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/getWriter)
  2414. */
  2415. getWriter(): WritableStreamDefaultWriter<W>;
  2416. }
  2417. /**
  2418. * The **`WritableStreamDefaultWriter`** interface of the Streams API is the object returned by WritableStream.getWriter() and once created locks the writer to the `WritableStream` ensuring that no other streams can write to the underlying sink.
  2419. *
  2420. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter)
  2421. */
  2422. declare class WritableStreamDefaultWriter<W = any> {
  2423. constructor(stream: WritableStream);
  2424. /**
  2425. * The **`closed`** read-only property of the the stream errors or the writer's lock is released.
  2426. *
  2427. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/closed)
  2428. */
  2429. get closed(): Promise<void>;
  2430. /**
  2431. * The **`ready`** read-only property of the that resolves when the desired size of the stream's internal queue transitions from non-positive to positive, signaling that it is no longer applying backpressure.
  2432. *
  2433. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/ready)
  2434. */
  2435. get ready(): Promise<void>;
  2436. /**
  2437. * The **`desiredSize`** read-only property of the to fill the stream's internal queue.
  2438. *
  2439. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/desiredSize)
  2440. */
  2441. get desiredSize(): number | null;
  2442. /**
  2443. * The **`abort()`** method of the the producer can no longer successfully write to the stream and it is to be immediately moved to an error state, with any queued writes discarded.
  2444. *
  2445. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/abort)
  2446. */
  2447. abort(reason?: any): Promise<void>;
  2448. /**
  2449. * The **`close()`** method of the stream.
  2450. *
  2451. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/close)
  2452. */
  2453. close(): Promise<void>;
  2454. /**
  2455. * The **`write()`** method of the operation.
  2456. *
  2457. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/write)
  2458. */
  2459. write(chunk?: W): Promise<void>;
  2460. /**
  2461. * The **`releaseLock()`** method of the corresponding stream.
  2462. *
  2463. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/releaseLock)
  2464. */
  2465. releaseLock(): void;
  2466. }
  2467. /**
  2468. * The **`TransformStream`** interface of the Streams API represents a concrete implementation of the pipe chain _transform stream_ concept.
  2469. *
  2470. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream)
  2471. */
  2472. declare class TransformStream<I = any, O = any> {
  2473. constructor(transformer?: Transformer<I, O>, writableStrategy?: QueuingStrategy<I>, readableStrategy?: QueuingStrategy<O>);
  2474. /**
  2475. * The **`readable`** read-only property of the TransformStream interface returns the ReadableStream instance controlled by this `TransformStream`.
  2476. *
  2477. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream/readable)
  2478. */
  2479. get readable(): ReadableStream<O>;
  2480. /**
  2481. * The **`writable`** read-only property of the TransformStream interface returns the WritableStream instance controlled by this `TransformStream`.
  2482. *
  2483. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream/writable)
  2484. */
  2485. get writable(): WritableStream<I>;
  2486. }
  2487. declare class FixedLengthStream extends IdentityTransformStream {
  2488. constructor(expectedLength: number | bigint, queuingStrategy?: IdentityTransformStreamQueuingStrategy);
  2489. }
  2490. declare class IdentityTransformStream extends TransformStream<ArrayBuffer | ArrayBufferView, Uint8Array> {
  2491. constructor(queuingStrategy?: IdentityTransformStreamQueuingStrategy);
  2492. }
  2493. interface IdentityTransformStreamQueuingStrategy {
  2494. highWaterMark?: (number | bigint);
  2495. }
  2496. interface ReadableStreamValuesOptions {
  2497. preventCancel?: boolean;
  2498. }
  2499. /**
  2500. * The **`CompressionStream`** interface of the Compression Streams API is an API for compressing a stream of data.
  2501. *
  2502. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CompressionStream)
  2503. */
  2504. declare class CompressionStream extends TransformStream<ArrayBuffer | ArrayBufferView, Uint8Array> {
  2505. constructor(format: "gzip" | "deflate" | "deflate-raw");
  2506. }
  2507. /**
  2508. * The **`DecompressionStream`** interface of the Compression Streams API is an API for decompressing a stream of data.
  2509. *
  2510. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DecompressionStream)
  2511. */
  2512. declare class DecompressionStream extends TransformStream<ArrayBuffer | ArrayBufferView, Uint8Array> {
  2513. constructor(format: "gzip" | "deflate" | "deflate-raw");
  2514. }
  2515. /**
  2516. * The **`TextEncoderStream`** interface of the Encoding API converts a stream of strings into bytes in the UTF-8 encoding.
  2517. *
  2518. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoderStream)
  2519. */
  2520. declare class TextEncoderStream extends TransformStream<string, Uint8Array> {
  2521. constructor();
  2522. get encoding(): string;
  2523. }
  2524. /**
  2525. * The **`TextDecoderStream`** interface of the Encoding API converts a stream of text in a binary encoding, such as UTF-8 etc., to a stream of strings.
  2526. *
  2527. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoderStream)
  2528. */
  2529. declare class TextDecoderStream extends TransformStream<ArrayBuffer | ArrayBufferView, string> {
  2530. constructor(label?: string, options?: TextDecoderStreamTextDecoderStreamInit);
  2531. get encoding(): string;
  2532. get fatal(): boolean;
  2533. get ignoreBOM(): boolean;
  2534. }
  2535. interface TextDecoderStreamTextDecoderStreamInit {
  2536. fatal?: boolean;
  2537. ignoreBOM?: boolean;
  2538. }
  2539. /**
  2540. * The **`ByteLengthQueuingStrategy`** interface of the Streams API provides a built-in byte length queuing strategy that can be used when constructing streams.
  2541. *
  2542. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy)
  2543. */
  2544. declare class ByteLengthQueuingStrategy implements QueuingStrategy<ArrayBufferView> {
  2545. constructor(init: QueuingStrategyInit);
  2546. /**
  2547. * The read-only **`ByteLengthQueuingStrategy.highWaterMark`** property returns the total number of bytes that can be contained in the internal queue before backpressure is applied.
  2548. *
  2549. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy/highWaterMark)
  2550. */
  2551. get highWaterMark(): number;
  2552. /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy/size) */
  2553. get size(): (chunk?: any) => number;
  2554. }
  2555. /**
  2556. * The **`CountQueuingStrategy`** interface of the Streams API provides a built-in chunk counting queuing strategy that can be used when constructing streams.
  2557. *
  2558. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy)
  2559. */
  2560. declare class CountQueuingStrategy implements QueuingStrategy {
  2561. constructor(init: QueuingStrategyInit);
  2562. /**
  2563. * The read-only **`CountQueuingStrategy.highWaterMark`** property returns the total number of chunks that can be contained in the internal queue before backpressure is applied.
  2564. *
  2565. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy/highWaterMark)
  2566. */
  2567. get highWaterMark(): number;
  2568. /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy/size) */
  2569. get size(): (chunk?: any) => number;
  2570. }
  2571. interface QueuingStrategyInit {
  2572. /**
  2573. * Creates a new ByteLengthQueuingStrategy with the provided high water mark.
  2574. *
  2575. * Note that the provided high water mark will not be validated ahead of time. Instead, if it is negative, NaN, or not a number, the resulting ByteLengthQueuingStrategy will cause the corresponding stream constructor to throw.
  2576. */
  2577. highWaterMark: number;
  2578. }
  2579. interface ScriptVersion {
  2580. id?: string;
  2581. tag?: string;
  2582. message?: string;
  2583. }
  2584. declare abstract class TailEvent extends ExtendableEvent {
  2585. readonly events: TraceItem[];
  2586. readonly traces: TraceItem[];
  2587. }
  2588. interface TraceItem {
  2589. readonly event: (TraceItemFetchEventInfo | TraceItemJsRpcEventInfo | TraceItemScheduledEventInfo | TraceItemAlarmEventInfo | TraceItemQueueEventInfo | TraceItemEmailEventInfo | TraceItemTailEventInfo | TraceItemCustomEventInfo | TraceItemHibernatableWebSocketEventInfo) | null;
  2590. readonly eventTimestamp: number | null;
  2591. readonly logs: TraceLog[];
  2592. readonly exceptions: TraceException[];
  2593. readonly diagnosticsChannelEvents: TraceDiagnosticChannelEvent[];
  2594. readonly scriptName: string | null;
  2595. readonly entrypoint?: string;
  2596. readonly scriptVersion?: ScriptVersion;
  2597. readonly dispatchNamespace?: string;
  2598. readonly scriptTags?: string[];
  2599. readonly durableObjectId?: string;
  2600. readonly outcome: string;
  2601. readonly executionModel: string;
  2602. readonly truncated: boolean;
  2603. readonly cpuTime: number;
  2604. readonly wallTime: number;
  2605. }
  2606. interface TraceItemAlarmEventInfo {
  2607. readonly scheduledTime: Date;
  2608. }
  2609. interface TraceItemCustomEventInfo {
  2610. }
  2611. interface TraceItemScheduledEventInfo {
  2612. readonly scheduledTime: number;
  2613. readonly cron: string;
  2614. }
  2615. interface TraceItemQueueEventInfo {
  2616. readonly queue: string;
  2617. readonly batchSize: number;
  2618. }
  2619. interface TraceItemEmailEventInfo {
  2620. readonly mailFrom: string;
  2621. readonly rcptTo: string;
  2622. readonly rawSize: number;
  2623. }
  2624. interface TraceItemTailEventInfo {
  2625. readonly consumedEvents: TraceItemTailEventInfoTailItem[];
  2626. }
  2627. interface TraceItemTailEventInfoTailItem {
  2628. readonly scriptName: string | null;
  2629. }
  2630. interface TraceItemFetchEventInfo {
  2631. readonly response?: TraceItemFetchEventInfoResponse;
  2632. readonly request: TraceItemFetchEventInfoRequest;
  2633. }
  2634. interface TraceItemFetchEventInfoRequest {
  2635. readonly cf?: any;
  2636. readonly headers: Record<string, string>;
  2637. readonly method: string;
  2638. readonly url: string;
  2639. getUnredacted(): TraceItemFetchEventInfoRequest;
  2640. }
  2641. interface TraceItemFetchEventInfoResponse {
  2642. readonly status: number;
  2643. }
  2644. interface TraceItemJsRpcEventInfo {
  2645. readonly rpcMethod: string;
  2646. }
  2647. interface TraceItemHibernatableWebSocketEventInfo {
  2648. readonly getWebSocketEvent: TraceItemHibernatableWebSocketEventInfoMessage | TraceItemHibernatableWebSocketEventInfoClose | TraceItemHibernatableWebSocketEventInfoError;
  2649. }
  2650. interface TraceItemHibernatableWebSocketEventInfoMessage {
  2651. readonly webSocketEventType: string;
  2652. }
  2653. interface TraceItemHibernatableWebSocketEventInfoClose {
  2654. readonly webSocketEventType: string;
  2655. readonly code: number;
  2656. readonly wasClean: boolean;
  2657. }
  2658. interface TraceItemHibernatableWebSocketEventInfoError {
  2659. readonly webSocketEventType: string;
  2660. }
  2661. interface TraceLog {
  2662. readonly timestamp: number;
  2663. readonly level: string;
  2664. readonly message: any;
  2665. }
  2666. interface TraceException {
  2667. readonly timestamp: number;
  2668. readonly message: string;
  2669. readonly name: string;
  2670. readonly stack?: string;
  2671. }
  2672. interface TraceDiagnosticChannelEvent {
  2673. readonly timestamp: number;
  2674. readonly channel: string;
  2675. readonly message: any;
  2676. }
  2677. interface TraceMetrics {
  2678. readonly cpuTime: number;
  2679. readonly wallTime: number;
  2680. }
  2681. interface UnsafeTraceMetrics {
  2682. fromTrace(item: TraceItem): TraceMetrics;
  2683. }
  2684. /**
  2685. * The **`URL`** interface is used to parse, construct, normalize, and encode URL.
  2686. *
  2687. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL)
  2688. */
  2689. declare class URL {
  2690. constructor(url: string | URL, base?: string | URL);
  2691. /**
  2692. * The **`origin`** read-only property of the URL interface returns a string containing the Unicode serialization of the origin of the represented URL.
  2693. *
  2694. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/origin)
  2695. */
  2696. get origin(): string;
  2697. /**
  2698. * The **`href`** property of the URL interface is a string containing the whole URL.
  2699. *
  2700. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/href)
  2701. */
  2702. get href(): string;
  2703. /**
  2704. * The **`href`** property of the URL interface is a string containing the whole URL.
  2705. *
  2706. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/href)
  2707. */
  2708. set href(value: string);
  2709. /**
  2710. * The **`protocol`** property of the URL interface is a string containing the protocol or scheme of the URL, including the final `':'`.
  2711. *
  2712. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/protocol)
  2713. */
  2714. get protocol(): string;
  2715. /**
  2716. * The **`protocol`** property of the URL interface is a string containing the protocol or scheme of the URL, including the final `':'`.
  2717. *
  2718. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/protocol)
  2719. */
  2720. set protocol(value: string);
  2721. /**
  2722. * The **`username`** property of the URL interface is a string containing the username component of the URL.
  2723. *
  2724. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/username)
  2725. */
  2726. get username(): string;
  2727. /**
  2728. * The **`username`** property of the URL interface is a string containing the username component of the URL.
  2729. *
  2730. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/username)
  2731. */
  2732. set username(value: string);
  2733. /**
  2734. * The **`password`** property of the URL interface is a string containing the password component of the URL.
  2735. *
  2736. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/password)
  2737. */
  2738. get password(): string;
  2739. /**
  2740. * The **`password`** property of the URL interface is a string containing the password component of the URL.
  2741. *
  2742. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/password)
  2743. */
  2744. set password(value: string);
  2745. /**
  2746. * The **`host`** property of the URL interface is a string containing the host, which is the URL.hostname, and then, if the port of the URL is nonempty, a `':'`, followed by the URL.port of the URL.
  2747. *
  2748. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/host)
  2749. */
  2750. get host(): string;
  2751. /**
  2752. * The **`host`** property of the URL interface is a string containing the host, which is the URL.hostname, and then, if the port of the URL is nonempty, a `':'`, followed by the URL.port of the URL.
  2753. *
  2754. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/host)
  2755. */
  2756. set host(value: string);
  2757. /**
  2758. * The **`hostname`** property of the URL interface is a string containing either the domain name or IP address of the URL.
  2759. *
  2760. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hostname)
  2761. */
  2762. get hostname(): string;
  2763. /**
  2764. * The **`hostname`** property of the URL interface is a string containing either the domain name or IP address of the URL.
  2765. *
  2766. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hostname)
  2767. */
  2768. set hostname(value: string);
  2769. /**
  2770. * The **`port`** property of the URL interface is a string containing the port number of the URL.
  2771. *
  2772. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/port)
  2773. */
  2774. get port(): string;
  2775. /**
  2776. * The **`port`** property of the URL interface is a string containing the port number of the URL.
  2777. *
  2778. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/port)
  2779. */
  2780. set port(value: string);
  2781. /**
  2782. * The **`pathname`** property of the URL interface represents a location in a hierarchical structure.
  2783. *
  2784. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/pathname)
  2785. */
  2786. get pathname(): string;
  2787. /**
  2788. * The **`pathname`** property of the URL interface represents a location in a hierarchical structure.
  2789. *
  2790. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/pathname)
  2791. */
  2792. set pathname(value: string);
  2793. /**
  2794. * The **`search`** property of the URL interface is a search string, also called a _query string_, that is a string containing a `'?'` followed by the parameters of the URL.
  2795. *
  2796. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/search)
  2797. */
  2798. get search(): string;
  2799. /**
  2800. * The **`search`** property of the URL interface is a search string, also called a _query string_, that is a string containing a `'?'` followed by the parameters of the URL.
  2801. *
  2802. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/search)
  2803. */
  2804. set search(value: string);
  2805. /**
  2806. * The **`hash`** property of the URL interface is a string containing a `'#'` followed by the fragment identifier of the URL.
  2807. *
  2808. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hash)
  2809. */
  2810. get hash(): string;
  2811. /**
  2812. * The **`hash`** property of the URL interface is a string containing a `'#'` followed by the fragment identifier of the URL.
  2813. *
  2814. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hash)
  2815. */
  2816. set hash(value: string);
  2817. /**
  2818. * The **`searchParams`** read-only property of the access to the [MISSING: httpmethod('GET')] decoded query arguments contained in the URL.
  2819. *
  2820. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/searchParams)
  2821. */
  2822. get searchParams(): URLSearchParams;
  2823. /**
  2824. * The **`toJSON()`** method of the URL interface returns a string containing a serialized version of the URL, although in practice it seems to have the same effect as ```js-nolint toJSON() ``` None.
  2825. *
  2826. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/toJSON)
  2827. */
  2828. toJSON(): string;
  2829. /*function toString() { [native code] }*/
  2830. toString(): string;
  2831. /**
  2832. * The **`URL.canParse()`** static method of the URL interface returns a boolean indicating whether or not an absolute URL, or a relative URL combined with a base URL, are parsable and valid.
  2833. *
  2834. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/canParse_static)
  2835. */
  2836. static canParse(url: string, base?: string): boolean;
  2837. /**
  2838. * The **`URL.parse()`** static method of the URL interface returns a newly created URL object representing the URL defined by the parameters.
  2839. *
  2840. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/parse_static)
  2841. */
  2842. static parse(url: string, base?: string): URL | null;
  2843. /**
  2844. * The **`createObjectURL()`** static method of the URL interface creates a string containing a URL representing the object given in the parameter.
  2845. *
  2846. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/createObjectURL_static)
  2847. */
  2848. static createObjectURL(object: File | Blob): string;
  2849. /**
  2850. * The **`revokeObjectURL()`** static method of the URL interface releases an existing object URL which was previously created by calling Call this method when you've finished using an object URL to let the browser know not to keep the reference to the file any longer.
  2851. *
  2852. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/revokeObjectURL_static)
  2853. */
  2854. static revokeObjectURL(object_url: string): void;
  2855. }
  2856. /**
  2857. * The **`URLSearchParams`** interface defines utility methods to work with the query string of a URL.
  2858. *
  2859. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams)
  2860. */
  2861. declare class URLSearchParams {
  2862. constructor(init?: (Iterable<Iterable<string>> | Record<string, string> | string));
  2863. /**
  2864. * The **`size`** read-only property of the URLSearchParams interface indicates the total number of search parameter entries.
  2865. *
  2866. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/size)
  2867. */
  2868. get size(): number;
  2869. /**
  2870. * The **`append()`** method of the URLSearchParams interface appends a specified key/value pair as a new search parameter.
  2871. *
  2872. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/append)
  2873. */
  2874. append(name: string, value: string): void;
  2875. /**
  2876. * The **`delete()`** method of the URLSearchParams interface deletes specified parameters and their associated value(s) from the list of all search parameters.
  2877. *
  2878. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/delete)
  2879. */
  2880. delete(name: string, value?: string): void;
  2881. /**
  2882. * The **`get()`** method of the URLSearchParams interface returns the first value associated to the given search parameter.
  2883. *
  2884. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/get)
  2885. */
  2886. get(name: string): string | null;
  2887. /**
  2888. * The **`getAll()`** method of the URLSearchParams interface returns all the values associated with a given search parameter as an array.
  2889. *
  2890. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/getAll)
  2891. */
  2892. getAll(name: string): string[];
  2893. /**
  2894. * The **`has()`** method of the URLSearchParams interface returns a boolean value that indicates whether the specified parameter is in the search parameters.
  2895. *
  2896. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/has)
  2897. */
  2898. has(name: string, value?: string): boolean;
  2899. /**
  2900. * The **`set()`** method of the URLSearchParams interface sets the value associated with a given search parameter to the given value.
  2901. *
  2902. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/set)
  2903. */
  2904. set(name: string, value: string): void;
  2905. /**
  2906. * The **`URLSearchParams.sort()`** method sorts all key/value pairs contained in this object in place and returns `undefined`.
  2907. *
  2908. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/sort)
  2909. */
  2910. sort(): void;
  2911. /* Returns an array of key, value pairs for every entry in the search params. */
  2912. entries(): IterableIterator<[
  2913. key: string,
  2914. value: string
  2915. ]>;
  2916. /* Returns a list of keys in the search params. */
  2917. keys(): IterableIterator<string>;
  2918. /* Returns a list of values in the search params. */
  2919. values(): IterableIterator<string>;
  2920. forEach<This = unknown>(callback: (this: This, value: string, key: string, parent: URLSearchParams) => void, thisArg?: This): void;
  2921. /*function toString() { [native code] }*/
  2922. toString(): string;
  2923. [Symbol.iterator](): IterableIterator<[
  2924. key: string,
  2925. value: string
  2926. ]>;
  2927. }
  2928. declare class URLPattern {
  2929. constructor(input?: (string | URLPatternInit), baseURL?: (string | URLPatternOptions), patternOptions?: URLPatternOptions);
  2930. get protocol(): string;
  2931. get username(): string;
  2932. get password(): string;
  2933. get hostname(): string;
  2934. get port(): string;
  2935. get pathname(): string;
  2936. get search(): string;
  2937. get hash(): string;
  2938. get hasRegExpGroups(): boolean;
  2939. test(input?: (string | URLPatternInit), baseURL?: string): boolean;
  2940. exec(input?: (string | URLPatternInit), baseURL?: string): URLPatternResult | null;
  2941. }
  2942. interface URLPatternInit {
  2943. protocol?: string;
  2944. username?: string;
  2945. password?: string;
  2946. hostname?: string;
  2947. port?: string;
  2948. pathname?: string;
  2949. search?: string;
  2950. hash?: string;
  2951. baseURL?: string;
  2952. }
  2953. interface URLPatternComponentResult {
  2954. input: string;
  2955. groups: Record<string, string>;
  2956. }
  2957. interface URLPatternResult {
  2958. inputs: (string | URLPatternInit)[];
  2959. protocol: URLPatternComponentResult;
  2960. username: URLPatternComponentResult;
  2961. password: URLPatternComponentResult;
  2962. hostname: URLPatternComponentResult;
  2963. port: URLPatternComponentResult;
  2964. pathname: URLPatternComponentResult;
  2965. search: URLPatternComponentResult;
  2966. hash: URLPatternComponentResult;
  2967. }
  2968. interface URLPatternOptions {
  2969. ignoreCase?: boolean;
  2970. }
  2971. /**
  2972. * A `CloseEvent` is sent to clients using WebSockets when the connection is closed.
  2973. *
  2974. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent)
  2975. */
  2976. declare class CloseEvent extends Event {
  2977. constructor(type: string, initializer?: CloseEventInit);
  2978. /**
  2979. * The **`code`** read-only property of the CloseEvent interface returns a WebSocket connection close code indicating the reason the connection was closed.
  2980. *
  2981. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/code)
  2982. */
  2983. readonly code: number;
  2984. /**
  2985. * The **`reason`** read-only property of the CloseEvent interface returns the WebSocket connection close reason the server gave for closing the connection; that is, a concise human-readable prose explanation for the closure.
  2986. *
  2987. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/reason)
  2988. */
  2989. readonly reason: string;
  2990. /**
  2991. * The **`wasClean`** read-only property of the CloseEvent interface returns `true` if the connection closed cleanly.
  2992. *
  2993. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/wasClean)
  2994. */
  2995. readonly wasClean: boolean;
  2996. }
  2997. interface CloseEventInit {
  2998. code?: number;
  2999. reason?: string;
  3000. wasClean?: boolean;
  3001. }
  3002. type WebSocketEventMap = {
  3003. close: CloseEvent;
  3004. message: MessageEvent;
  3005. open: Event;
  3006. error: ErrorEvent;
  3007. };
  3008. /**
  3009. * The `WebSocket` object provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection.
  3010. *
  3011. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket)
  3012. */
  3013. declare var WebSocket: {
  3014. prototype: WebSocket;
  3015. new (url: string, protocols?: (string[] | string)): WebSocket;
  3016. readonly READY_STATE_CONNECTING: number;
  3017. readonly CONNECTING: number;
  3018. readonly READY_STATE_OPEN: number;
  3019. readonly OPEN: number;
  3020. readonly READY_STATE_CLOSING: number;
  3021. readonly CLOSING: number;
  3022. readonly READY_STATE_CLOSED: number;
  3023. readonly CLOSED: number;
  3024. };
  3025. /**
  3026. * The `WebSocket` object provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection.
  3027. *
  3028. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket)
  3029. */
  3030. interface WebSocket extends EventTarget<WebSocketEventMap> {
  3031. accept(): void;
  3032. /**
  3033. * The **`WebSocket.send()`** method enqueues the specified data to be transmitted to the server over the WebSocket connection, increasing the value of `bufferedAmount` by the number of bytes needed to contain the data.
  3034. *
  3035. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/send)
  3036. */
  3037. send(message: (ArrayBuffer | ArrayBufferView) | string): void;
  3038. /**
  3039. * The **`WebSocket.close()`** method closes the already `CLOSED`, this method does nothing.
  3040. *
  3041. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/close)
  3042. */
  3043. close(code?: number, reason?: string): void;
  3044. serializeAttachment(attachment: any): void;
  3045. deserializeAttachment(): any | null;
  3046. /**
  3047. * The **`WebSocket.readyState`** read-only property returns the current state of the WebSocket connection.
  3048. *
  3049. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/readyState)
  3050. */
  3051. readyState: number;
  3052. /**
  3053. * The **`WebSocket.url`** read-only property returns the absolute URL of the WebSocket as resolved by the constructor.
  3054. *
  3055. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/url)
  3056. */
  3057. url: string | null;
  3058. /**
  3059. * The **`WebSocket.protocol`** read-only property returns the name of the sub-protocol the server selected; this will be one of the strings specified in the `protocols` parameter when creating the WebSocket object, or the empty string if no connection is established.
  3060. *
  3061. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/protocol)
  3062. */
  3063. protocol: string | null;
  3064. /**
  3065. * The **`WebSocket.extensions`** read-only property returns the extensions selected by the server.
  3066. *
  3067. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/extensions)
  3068. */
  3069. extensions: string | null;
  3070. }
  3071. declare const WebSocketPair: {
  3072. new (): {
  3073. 0: WebSocket;
  3074. 1: WebSocket;
  3075. };
  3076. };
  3077. interface SqlStorage {
  3078. exec<T extends Record<string, SqlStorageValue>>(query: string, ...bindings: any[]): SqlStorageCursor<T>;
  3079. get databaseSize(): number;
  3080. Cursor: typeof SqlStorageCursor;
  3081. Statement: typeof SqlStorageStatement;
  3082. }
  3083. declare abstract class SqlStorageStatement {
  3084. }
  3085. type SqlStorageValue = ArrayBuffer | string | number | null;
  3086. declare abstract class SqlStorageCursor<T extends Record<string, SqlStorageValue>> {
  3087. next(): {
  3088. done?: false;
  3089. value: T;
  3090. } | {
  3091. done: true;
  3092. value?: never;
  3093. };
  3094. toArray(): T[];
  3095. one(): T;
  3096. raw<U extends SqlStorageValue[]>(): IterableIterator<U>;
  3097. columnNames: string[];
  3098. get rowsRead(): number;
  3099. get rowsWritten(): number;
  3100. [Symbol.iterator](): IterableIterator<T>;
  3101. }
  3102. interface Socket {
  3103. get readable(): ReadableStream;
  3104. get writable(): WritableStream;
  3105. get closed(): Promise<void>;
  3106. get opened(): Promise<SocketInfo>;
  3107. get upgraded(): boolean;
  3108. get secureTransport(): "on" | "off" | "starttls";
  3109. close(): Promise<void>;
  3110. startTls(options?: TlsOptions): Socket;
  3111. }
  3112. interface SocketOptions {
  3113. secureTransport?: string;
  3114. allowHalfOpen: boolean;
  3115. highWaterMark?: (number | bigint);
  3116. }
  3117. interface SocketAddress {
  3118. hostname: string;
  3119. port: number;
  3120. }
  3121. interface TlsOptions {
  3122. expectedServerHostname?: string;
  3123. }
  3124. interface SocketInfo {
  3125. remoteAddress?: string;
  3126. localAddress?: string;
  3127. }
  3128. /**
  3129. * The **`EventSource`** interface is web content's interface to server-sent events.
  3130. *
  3131. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource)
  3132. */
  3133. declare class EventSource extends EventTarget {
  3134. constructor(url: string, init?: EventSourceEventSourceInit);
  3135. /**
  3136. * The **`close()`** method of the EventSource interface closes the connection, if one is made, and sets the ```js-nolint close() ``` None.
  3137. *
  3138. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close)
  3139. */
  3140. close(): void;
  3141. /**
  3142. * The **`url`** read-only property of the URL of the source.
  3143. *
  3144. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url)
  3145. */
  3146. get url(): string;
  3147. /**
  3148. * The **`withCredentials`** read-only property of the the `EventSource` object was instantiated with CORS credentials set.
  3149. *
  3150. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
  3151. */
  3152. get withCredentials(): boolean;
  3153. /**
  3154. * The **`readyState`** read-only property of the connection.
  3155. *
  3156. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState)
  3157. */
  3158. get readyState(): number;
  3159. /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
  3160. get onopen(): any | null;
  3161. /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
  3162. set onopen(value: any | null);
  3163. /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
  3164. get onmessage(): any | null;
  3165. /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
  3166. set onmessage(value: any | null);
  3167. /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
  3168. get onerror(): any | null;
  3169. /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
  3170. set onerror(value: any | null);
  3171. static readonly CONNECTING: number;
  3172. static readonly OPEN: number;
  3173. static readonly CLOSED: number;
  3174. static from(stream: ReadableStream): EventSource;
  3175. }
  3176. interface EventSourceEventSourceInit {
  3177. withCredentials?: boolean;
  3178. fetcher?: Fetcher;
  3179. }
  3180. interface Container {
  3181. get running(): boolean;
  3182. start(options?: ContainerStartupOptions): void;
  3183. monitor(): Promise<void>;
  3184. destroy(error?: any): Promise<void>;
  3185. signal(signo: number): void;
  3186. getTcpPort(port: number): Fetcher;
  3187. setInactivityTimeout(durationMs: number | bigint): Promise<void>;
  3188. }
  3189. interface ContainerStartupOptions {
  3190. entrypoint?: string[];
  3191. enableInternet: boolean;
  3192. env?: Record<string, string>;
  3193. hardTimeout?: (number | bigint);
  3194. }
  3195. /**
  3196. * The **`MessagePort`** interface of the Channel Messaging API represents one of the two ports of a MessageChannel, allowing messages to be sent from one port and listening out for them arriving at the other.
  3197. *
  3198. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort)
  3199. */
  3200. declare abstract class MessagePort extends EventTarget {
  3201. /**
  3202. * The **`postMessage()`** method of the transfers ownership of objects to other browsing contexts.
  3203. *
  3204. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/postMessage)
  3205. */
  3206. postMessage(data?: any, options?: (any[] | MessagePortPostMessageOptions)): void;
  3207. /**
  3208. * The **`close()`** method of the MessagePort interface disconnects the port, so it is no longer active.
  3209. *
  3210. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/close)
  3211. */
  3212. close(): void;
  3213. /**
  3214. * The **`start()`** method of the MessagePort interface starts the sending of messages queued on the port.
  3215. *
  3216. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/start)
  3217. */
  3218. start(): void;
  3219. get onmessage(): any | null;
  3220. set onmessage(value: any | null);
  3221. }
  3222. /**
  3223. * The **`MessageChannel`** interface of the Channel Messaging API allows us to create a new message channel and send data through it via its two MessagePort properties.
  3224. *
  3225. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel)
  3226. */
  3227. declare class MessageChannel {
  3228. constructor();
  3229. /**
  3230. * The **`port1`** read-only property of the the port attached to the context that originated the channel.
  3231. *
  3232. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port1)
  3233. */
  3234. readonly port1: MessagePort;
  3235. /**
  3236. * The **`port2`** read-only property of the the port attached to the context at the other end of the channel, which the message is initially sent to.
  3237. *
  3238. * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port2)
  3239. */
  3240. readonly port2: MessagePort;
  3241. }
  3242. interface MessagePortPostMessageOptions {
  3243. transfer?: any[];
  3244. }
  3245. type LoopbackForExport<T extends (new (...args: any[]) => Rpc.EntrypointBranded) | ExportedHandler<any, any, any> | undefined = undefined> = T extends new (...args: any[]) => Rpc.WorkerEntrypointBranded ? LoopbackServiceStub<InstanceType<T>> : T extends new (...args: any[]) => Rpc.DurableObjectBranded ? LoopbackDurableObjectClass<InstanceType<T>> : T extends ExportedHandler<any, any, any> ? LoopbackServiceStub<undefined> : undefined;
  3246. type LoopbackServiceStub<T extends Rpc.WorkerEntrypointBranded | undefined = undefined> = Fetcher<T> & (T extends CloudflareWorkersModule.WorkerEntrypoint<any, infer Props> ? (opts: {
  3247. props?: Props;
  3248. }) => Fetcher<T> : (opts: {
  3249. props?: any;
  3250. }) => Fetcher<T>);
  3251. type LoopbackDurableObjectClass<T extends Rpc.DurableObjectBranded | undefined = undefined> = DurableObjectClass<T> & (T extends CloudflareWorkersModule.DurableObject<any, infer Props> ? (opts: {
  3252. props?: Props;
  3253. }) => DurableObjectClass<T> : (opts: {
  3254. props?: any;
  3255. }) => DurableObjectClass<T>);
  3256. interface SyncKvStorage {
  3257. get<T = unknown>(key: string): T | undefined;
  3258. list<T = unknown>(options?: SyncKvListOptions): Iterable<[
  3259. string,
  3260. T
  3261. ]>;
  3262. put<T>(key: string, value: T): void;
  3263. delete(key: string): boolean;
  3264. }
  3265. interface SyncKvListOptions {
  3266. start?: string;
  3267. startAfter?: string;
  3268. end?: string;
  3269. prefix?: string;
  3270. reverse?: boolean;
  3271. limit?: number;
  3272. }
  3273. interface WorkerStub {
  3274. getEntrypoint<T extends Rpc.WorkerEntrypointBranded | undefined>(name?: string, options?: WorkerStubEntrypointOptions): Fetcher<T>;
  3275. }
  3276. interface WorkerStubEntrypointOptions {
  3277. props?: any;
  3278. }
  3279. interface WorkerLoader {
  3280. get(name: string | null, getCode: () => WorkerLoaderWorkerCode | Promise<WorkerLoaderWorkerCode>): WorkerStub;
  3281. }
  3282. interface WorkerLoaderModule {
  3283. js?: string;
  3284. cjs?: string;
  3285. text?: string;
  3286. data?: ArrayBuffer;
  3287. json?: any;
  3288. py?: string;
  3289. wasm?: ArrayBuffer;
  3290. }
  3291. interface WorkerLoaderWorkerCode {
  3292. compatibilityDate: string;
  3293. compatibilityFlags?: string[];
  3294. allowExperimental?: boolean;
  3295. mainModule: string;
  3296. modules: Record<string, WorkerLoaderModule | string>;
  3297. env?: any;
  3298. globalOutbound?: (Fetcher | null);
  3299. tails?: Fetcher[];
  3300. streamingTails?: Fetcher[];
  3301. }
  3302. /**
  3303. * The Workers runtime supports a subset of the Performance API, used to measure timing and performance,
  3304. * as well as timing of subrequests and other operations.
  3305. *
  3306. * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/)
  3307. */
  3308. declare abstract class Performance {
  3309. /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/#performancetimeorigin) */
  3310. get timeOrigin(): number;
  3311. /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/#performancenow) */
  3312. now(): number;
  3313. }
  3314. type AiImageClassificationInput = {
  3315. image: number[];
  3316. };
  3317. type AiImageClassificationOutput = {
  3318. score?: number;
  3319. label?: string;
  3320. }[];
  3321. declare abstract class BaseAiImageClassification {
  3322. inputs: AiImageClassificationInput;
  3323. postProcessedOutputs: AiImageClassificationOutput;
  3324. }
  3325. type AiImageToTextInput = {
  3326. image: number[];
  3327. prompt?: string;
  3328. max_tokens?: number;
  3329. temperature?: number;
  3330. top_p?: number;
  3331. top_k?: number;
  3332. seed?: number;
  3333. repetition_penalty?: number;
  3334. frequency_penalty?: number;
  3335. presence_penalty?: number;
  3336. raw?: boolean;
  3337. messages?: RoleScopedChatInput[];
  3338. };
  3339. type AiImageToTextOutput = {
  3340. description: string;
  3341. };
  3342. declare abstract class BaseAiImageToText {
  3343. inputs: AiImageToTextInput;
  3344. postProcessedOutputs: AiImageToTextOutput;
  3345. }
  3346. type AiImageTextToTextInput = {
  3347. image: string;
  3348. prompt?: string;
  3349. max_tokens?: number;
  3350. temperature?: number;
  3351. ignore_eos?: boolean;
  3352. top_p?: number;
  3353. top_k?: number;
  3354. seed?: number;
  3355. repetition_penalty?: number;
  3356. frequency_penalty?: number;
  3357. presence_penalty?: number;
  3358. raw?: boolean;
  3359. messages?: RoleScopedChatInput[];
  3360. };
  3361. type AiImageTextToTextOutput = {
  3362. description: string;
  3363. };
  3364. declare abstract class BaseAiImageTextToText {
  3365. inputs: AiImageTextToTextInput;
  3366. postProcessedOutputs: AiImageTextToTextOutput;
  3367. }
  3368. type AiMultimodalEmbeddingsInput = {
  3369. image: string;
  3370. text: string[];
  3371. };
  3372. type AiIMultimodalEmbeddingsOutput = {
  3373. data: number[][];
  3374. shape: number[];
  3375. };
  3376. declare abstract class BaseAiMultimodalEmbeddings {
  3377. inputs: AiImageTextToTextInput;
  3378. postProcessedOutputs: AiImageTextToTextOutput;
  3379. }
  3380. type AiObjectDetectionInput = {
  3381. image: number[];
  3382. };
  3383. type AiObjectDetectionOutput = {
  3384. score?: number;
  3385. label?: string;
  3386. }[];
  3387. declare abstract class BaseAiObjectDetection {
  3388. inputs: AiObjectDetectionInput;
  3389. postProcessedOutputs: AiObjectDetectionOutput;
  3390. }
  3391. type AiSentenceSimilarityInput = {
  3392. source: string;
  3393. sentences: string[];
  3394. };
  3395. type AiSentenceSimilarityOutput = number[];
  3396. declare abstract class BaseAiSentenceSimilarity {
  3397. inputs: AiSentenceSimilarityInput;
  3398. postProcessedOutputs: AiSentenceSimilarityOutput;
  3399. }
  3400. type AiAutomaticSpeechRecognitionInput = {
  3401. audio: number[];
  3402. };
  3403. type AiAutomaticSpeechRecognitionOutput = {
  3404. text?: string;
  3405. words?: {
  3406. word: string;
  3407. start: number;
  3408. end: number;
  3409. }[];
  3410. vtt?: string;
  3411. };
  3412. declare abstract class BaseAiAutomaticSpeechRecognition {
  3413. inputs: AiAutomaticSpeechRecognitionInput;
  3414. postProcessedOutputs: AiAutomaticSpeechRecognitionOutput;
  3415. }
  3416. type AiSummarizationInput = {
  3417. input_text: string;
  3418. max_length?: number;
  3419. };
  3420. type AiSummarizationOutput = {
  3421. summary: string;
  3422. };
  3423. declare abstract class BaseAiSummarization {
  3424. inputs: AiSummarizationInput;
  3425. postProcessedOutputs: AiSummarizationOutput;
  3426. }
  3427. type AiTextClassificationInput = {
  3428. text: string;
  3429. };
  3430. type AiTextClassificationOutput = {
  3431. score?: number;
  3432. label?: string;
  3433. }[];
  3434. declare abstract class BaseAiTextClassification {
  3435. inputs: AiTextClassificationInput;
  3436. postProcessedOutputs: AiTextClassificationOutput;
  3437. }
  3438. type AiTextEmbeddingsInput = {
  3439. text: string | string[];
  3440. };
  3441. type AiTextEmbeddingsOutput = {
  3442. shape: number[];
  3443. data: number[][];
  3444. };
  3445. declare abstract class BaseAiTextEmbeddings {
  3446. inputs: AiTextEmbeddingsInput;
  3447. postProcessedOutputs: AiTextEmbeddingsOutput;
  3448. }
  3449. type RoleScopedChatInput = {
  3450. role: "user" | "assistant" | "system" | "tool" | (string & NonNullable<unknown>);
  3451. content: string;
  3452. name?: string;
  3453. };
  3454. type AiTextGenerationToolLegacyInput = {
  3455. name: string;
  3456. description: string;
  3457. parameters?: {
  3458. type: "object" | (string & NonNullable<unknown>);
  3459. properties: {
  3460. [key: string]: {
  3461. type: string;
  3462. description?: string;
  3463. };
  3464. };
  3465. required: string[];
  3466. };
  3467. };
  3468. type AiTextGenerationToolInput = {
  3469. type: "function" | (string & NonNullable<unknown>);
  3470. function: {
  3471. name: string;
  3472. description: string;
  3473. parameters?: {
  3474. type: "object" | (string & NonNullable<unknown>);
  3475. properties: {
  3476. [key: string]: {
  3477. type: string;
  3478. description?: string;
  3479. };
  3480. };
  3481. required: string[];
  3482. };
  3483. };
  3484. };
  3485. type AiTextGenerationFunctionsInput = {
  3486. name: string;
  3487. code: string;
  3488. };
  3489. type AiTextGenerationResponseFormat = {
  3490. type: string;
  3491. json_schema?: any;
  3492. };
  3493. type AiTextGenerationInput = {
  3494. prompt?: string;
  3495. raw?: boolean;
  3496. stream?: boolean;
  3497. max_tokens?: number;
  3498. temperature?: number;
  3499. top_p?: number;
  3500. top_k?: number;
  3501. seed?: number;
  3502. repetition_penalty?: number;
  3503. frequency_penalty?: number;
  3504. presence_penalty?: number;
  3505. messages?: RoleScopedChatInput[];
  3506. response_format?: AiTextGenerationResponseFormat;
  3507. tools?: AiTextGenerationToolInput[] | AiTextGenerationToolLegacyInput[] | (object & NonNullable<unknown>);
  3508. functions?: AiTextGenerationFunctionsInput[];
  3509. };
  3510. type AiTextGenerationToolLegacyOutput = {
  3511. name: string;
  3512. arguments: unknown;
  3513. };
  3514. type AiTextGenerationToolOutput = {
  3515. id: string;
  3516. type: "function";
  3517. function: {
  3518. name: string;
  3519. arguments: string;
  3520. };
  3521. };
  3522. type UsageTags = {
  3523. prompt_tokens: number;
  3524. completion_tokens: number;
  3525. total_tokens: number;
  3526. };
  3527. type AiTextGenerationOutput = {
  3528. response?: string;
  3529. tool_calls?: AiTextGenerationToolLegacyOutput[] & AiTextGenerationToolOutput[];
  3530. usage?: UsageTags;
  3531. };
  3532. declare abstract class BaseAiTextGeneration {
  3533. inputs: AiTextGenerationInput;
  3534. postProcessedOutputs: AiTextGenerationOutput;
  3535. }
  3536. type AiTextToSpeechInput = {
  3537. prompt: string;
  3538. lang?: string;
  3539. };
  3540. type AiTextToSpeechOutput = Uint8Array | {
  3541. audio: string;
  3542. };
  3543. declare abstract class BaseAiTextToSpeech {
  3544. inputs: AiTextToSpeechInput;
  3545. postProcessedOutputs: AiTextToSpeechOutput;
  3546. }
  3547. type AiTextToImageInput = {
  3548. prompt: string;
  3549. negative_prompt?: string;
  3550. height?: number;
  3551. width?: number;
  3552. image?: number[];
  3553. image_b64?: string;
  3554. mask?: number[];
  3555. num_steps?: number;
  3556. strength?: number;
  3557. guidance?: number;
  3558. seed?: number;
  3559. };
  3560. type AiTextToImageOutput = ReadableStream<Uint8Array>;
  3561. declare abstract class BaseAiTextToImage {
  3562. inputs: AiTextToImageInput;
  3563. postProcessedOutputs: AiTextToImageOutput;
  3564. }
  3565. type AiTranslationInput = {
  3566. text: string;
  3567. target_lang: string;
  3568. source_lang?: string;
  3569. };
  3570. type AiTranslationOutput = {
  3571. translated_text?: string;
  3572. };
  3573. declare abstract class BaseAiTranslation {
  3574. inputs: AiTranslationInput;
  3575. postProcessedOutputs: AiTranslationOutput;
  3576. }
  3577. /**
  3578. * Workers AI support for OpenAI's Responses API
  3579. * Reference: https://github.com/openai/openai-node/blob/master/src/resources/responses/responses.ts
  3580. *
  3581. * It's a stripped down version from its source.
  3582. * It currently supports basic function calling, json mode and accepts images as input.
  3583. *
  3584. * It does not include types for WebSearch, CodeInterpreter, FileInputs, MCP, CustomTools.
  3585. * We plan to add those incrementally as model + platform capabilities evolve.
  3586. */
  3587. type ResponsesInput = {
  3588. background?: boolean | null;
  3589. conversation?: string | ResponseConversationParam | null;
  3590. include?: Array<ResponseIncludable> | null;
  3591. input?: string | ResponseInput;
  3592. instructions?: string | null;
  3593. max_output_tokens?: number | null;
  3594. parallel_tool_calls?: boolean | null;
  3595. previous_response_id?: string | null;
  3596. prompt_cache_key?: string;
  3597. reasoning?: Reasoning | null;
  3598. safety_identifier?: string;
  3599. service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
  3600. stream?: boolean | null;
  3601. stream_options?: StreamOptions | null;
  3602. temperature?: number | null;
  3603. text?: ResponseTextConfig;
  3604. tool_choice?: ToolChoiceOptions | ToolChoiceFunction;
  3605. tools?: Array<Tool>;
  3606. top_p?: number | null;
  3607. truncation?: "auto" | "disabled" | null;
  3608. };
  3609. type ResponsesOutput = {
  3610. id?: string;
  3611. created_at?: number;
  3612. output_text?: string;
  3613. error?: ResponseError | null;
  3614. incomplete_details?: ResponseIncompleteDetails | null;
  3615. instructions?: string | Array<ResponseInputItem> | null;
  3616. object?: "response";
  3617. output?: Array<ResponseOutputItem>;
  3618. parallel_tool_calls?: boolean;
  3619. temperature?: number | null;
  3620. tool_choice?: ToolChoiceOptions | ToolChoiceFunction;
  3621. tools?: Array<Tool>;
  3622. top_p?: number | null;
  3623. max_output_tokens?: number | null;
  3624. previous_response_id?: string | null;
  3625. prompt?: ResponsePrompt | null;
  3626. reasoning?: Reasoning | null;
  3627. safety_identifier?: string;
  3628. service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
  3629. status?: ResponseStatus;
  3630. text?: ResponseTextConfig;
  3631. truncation?: "auto" | "disabled" | null;
  3632. usage?: ResponseUsage;
  3633. };
  3634. type EasyInputMessage = {
  3635. content: string | ResponseInputMessageContentList;
  3636. role: "user" | "assistant" | "system" | "developer";
  3637. type?: "message";
  3638. };
  3639. type ResponsesFunctionTool = {
  3640. name: string;
  3641. parameters: {
  3642. [key: string]: unknown;
  3643. } | null;
  3644. strict: boolean | null;
  3645. type: "function";
  3646. description?: string | null;
  3647. };
  3648. type ResponseIncompleteDetails = {
  3649. reason?: "max_output_tokens" | "content_filter";
  3650. };
  3651. type ResponsePrompt = {
  3652. id: string;
  3653. variables?: {
  3654. [key: string]: string | ResponseInputText | ResponseInputImage;
  3655. } | null;
  3656. version?: string | null;
  3657. };
  3658. type Reasoning = {
  3659. effort?: ReasoningEffort | null;
  3660. generate_summary?: "auto" | "concise" | "detailed" | null;
  3661. summary?: "auto" | "concise" | "detailed" | null;
  3662. };
  3663. type ResponseContent = ResponseInputText | ResponseInputImage | ResponseOutputText | ResponseOutputRefusal | ResponseContentReasoningText;
  3664. type ResponseContentReasoningText = {
  3665. text: string;
  3666. type: "reasoning_text";
  3667. };
  3668. type ResponseConversationParam = {
  3669. id: string;
  3670. };
  3671. type ResponseCreatedEvent = {
  3672. response: Response;
  3673. sequence_number: number;
  3674. type: "response.created";
  3675. };
  3676. type ResponseCustomToolCallOutput = {
  3677. call_id: string;
  3678. output: string | Array<ResponseInputText | ResponseInputImage>;
  3679. type: "custom_tool_call_output";
  3680. id?: string;
  3681. };
  3682. type ResponseError = {
  3683. code: "server_error" | "rate_limit_exceeded" | "invalid_prompt" | "vector_store_timeout" | "invalid_image" | "invalid_image_format" | "invalid_base64_image" | "invalid_image_url" | "image_too_large" | "image_too_small" | "image_parse_error" | "image_content_policy_violation" | "invalid_image_mode" | "image_file_too_large" | "unsupported_image_media_type" | "empty_image_file" | "failed_to_download_image" | "image_file_not_found";
  3684. message: string;
  3685. };
  3686. type ResponseErrorEvent = {
  3687. code: string | null;
  3688. message: string;
  3689. param: string | null;
  3690. sequence_number: number;
  3691. type: "error";
  3692. };
  3693. type ResponseFailedEvent = {
  3694. response: Response;
  3695. sequence_number: number;
  3696. type: "response.failed";
  3697. };
  3698. type ResponseFormatText = {
  3699. type: "text";
  3700. };
  3701. type ResponseFormatJSONObject = {
  3702. type: "json_object";
  3703. };
  3704. type ResponseFormatTextConfig = ResponseFormatText | ResponseFormatTextJSONSchemaConfig | ResponseFormatJSONObject;
  3705. type ResponseFormatTextJSONSchemaConfig = {
  3706. name: string;
  3707. schema: {
  3708. [key: string]: unknown;
  3709. };
  3710. type: "json_schema";
  3711. description?: string;
  3712. strict?: boolean | null;
  3713. };
  3714. type ResponseFunctionCallArgumentsDeltaEvent = {
  3715. delta: string;
  3716. item_id: string;
  3717. output_index: number;
  3718. sequence_number: number;
  3719. type: "response.function_call_arguments.delta";
  3720. };
  3721. type ResponseFunctionCallArgumentsDoneEvent = {
  3722. arguments: string;
  3723. item_id: string;
  3724. name: string;
  3725. output_index: number;
  3726. sequence_number: number;
  3727. type: "response.function_call_arguments.done";
  3728. };
  3729. type ResponseFunctionCallOutputItem = ResponseInputTextContent | ResponseInputImageContent;
  3730. type ResponseFunctionCallOutputItemList = Array<ResponseFunctionCallOutputItem>;
  3731. type ResponseFunctionToolCall = {
  3732. arguments: string;
  3733. call_id: string;
  3734. name: string;
  3735. type: "function_call";
  3736. id?: string;
  3737. status?: "in_progress" | "completed" | "incomplete";
  3738. };
  3739. interface ResponseFunctionToolCallItem extends ResponseFunctionToolCall {
  3740. id: string;
  3741. }
  3742. type ResponseFunctionToolCallOutputItem = {
  3743. id: string;
  3744. call_id: string;
  3745. output: string | Array<ResponseInputText | ResponseInputImage>;
  3746. type: "function_call_output";
  3747. status?: "in_progress" | "completed" | "incomplete";
  3748. };
  3749. type ResponseIncludable = "message.input_image.image_url" | "message.output_text.logprobs";
  3750. type ResponseIncompleteEvent = {
  3751. response: Response;
  3752. sequence_number: number;
  3753. type: "response.incomplete";
  3754. };
  3755. type ResponseInput = Array<ResponseInputItem>;
  3756. type ResponseInputContent = ResponseInputText | ResponseInputImage;
  3757. type ResponseInputImage = {
  3758. detail: "low" | "high" | "auto";
  3759. type: "input_image";
  3760. /**
  3761. * Base64 encoded image
  3762. */
  3763. image_url?: string | null;
  3764. };
  3765. type ResponseInputImageContent = {
  3766. type: "input_image";
  3767. detail?: "low" | "high" | "auto" | null;
  3768. /**
  3769. * Base64 encoded image
  3770. */
  3771. image_url?: string | null;
  3772. };
  3773. type ResponseInputItem = EasyInputMessage | ResponseInputItemMessage | ResponseOutputMessage | ResponseFunctionToolCall | ResponseInputItemFunctionCallOutput | ResponseReasoningItem;
  3774. type ResponseInputItemFunctionCallOutput = {
  3775. call_id: string;
  3776. output: string | ResponseFunctionCallOutputItemList;
  3777. type: "function_call_output";
  3778. id?: string | null;
  3779. status?: "in_progress" | "completed" | "incomplete" | null;
  3780. };
  3781. type ResponseInputItemMessage = {
  3782. content: ResponseInputMessageContentList;
  3783. role: "user" | "system" | "developer";
  3784. status?: "in_progress" | "completed" | "incomplete";
  3785. type?: "message";
  3786. };
  3787. type ResponseInputMessageContentList = Array<ResponseInputContent>;
  3788. type ResponseInputMessageItem = {
  3789. id: string;
  3790. content: ResponseInputMessageContentList;
  3791. role: "user" | "system" | "developer";
  3792. status?: "in_progress" | "completed" | "incomplete";
  3793. type?: "message";
  3794. };
  3795. type ResponseInputText = {
  3796. text: string;
  3797. type: "input_text";
  3798. };
  3799. type ResponseInputTextContent = {
  3800. text: string;
  3801. type: "input_text";
  3802. };
  3803. type ResponseItem = ResponseInputMessageItem | ResponseOutputMessage | ResponseFunctionToolCallItem | ResponseFunctionToolCallOutputItem;
  3804. type ResponseOutputItem = ResponseOutputMessage | ResponseFunctionToolCall | ResponseReasoningItem;
  3805. type ResponseOutputItemAddedEvent = {
  3806. item: ResponseOutputItem;
  3807. output_index: number;
  3808. sequence_number: number;
  3809. type: "response.output_item.added";
  3810. };
  3811. type ResponseOutputItemDoneEvent = {
  3812. item: ResponseOutputItem;
  3813. output_index: number;
  3814. sequence_number: number;
  3815. type: "response.output_item.done";
  3816. };
  3817. type ResponseOutputMessage = {
  3818. id: string;
  3819. content: Array<ResponseOutputText | ResponseOutputRefusal>;
  3820. role: "assistant";
  3821. status: "in_progress" | "completed" | "incomplete";
  3822. type: "message";
  3823. };
  3824. type ResponseOutputRefusal = {
  3825. refusal: string;
  3826. type: "refusal";
  3827. };
  3828. type ResponseOutputText = {
  3829. text: string;
  3830. type: "output_text";
  3831. logprobs?: Array<Logprob>;
  3832. };
  3833. type ResponseReasoningItem = {
  3834. id: string;
  3835. summary: Array<ResponseReasoningSummaryItem>;
  3836. type: "reasoning";
  3837. content?: Array<ResponseReasoningContentItem>;
  3838. encrypted_content?: string | null;
  3839. status?: "in_progress" | "completed" | "incomplete";
  3840. };
  3841. type ResponseReasoningSummaryItem = {
  3842. text: string;
  3843. type: "summary_text";
  3844. };
  3845. type ResponseReasoningContentItem = {
  3846. text: string;
  3847. type: "reasoning_text";
  3848. };
  3849. type ResponseReasoningTextDeltaEvent = {
  3850. content_index: number;
  3851. delta: string;
  3852. item_id: string;
  3853. output_index: number;
  3854. sequence_number: number;
  3855. type: "response.reasoning_text.delta";
  3856. };
  3857. type ResponseReasoningTextDoneEvent = {
  3858. content_index: number;
  3859. item_id: string;
  3860. output_index: number;
  3861. sequence_number: number;
  3862. text: string;
  3863. type: "response.reasoning_text.done";
  3864. };
  3865. type ResponseRefusalDeltaEvent = {
  3866. content_index: number;
  3867. delta: string;
  3868. item_id: string;
  3869. output_index: number;
  3870. sequence_number: number;
  3871. type: "response.refusal.delta";
  3872. };
  3873. type ResponseRefusalDoneEvent = {
  3874. content_index: number;
  3875. item_id: string;
  3876. output_index: number;
  3877. refusal: string;
  3878. sequence_number: number;
  3879. type: "response.refusal.done";
  3880. };
  3881. type ResponseStatus = "completed" | "failed" | "in_progress" | "cancelled" | "queued" | "incomplete";
  3882. type ResponseStreamEvent = ResponseCompletedEvent | ResponseCreatedEvent | ResponseErrorEvent | ResponseFunctionCallArgumentsDeltaEvent | ResponseFunctionCallArgumentsDoneEvent | ResponseFailedEvent | ResponseIncompleteEvent | ResponseOutputItemAddedEvent | ResponseOutputItemDoneEvent | ResponseReasoningTextDeltaEvent | ResponseReasoningTextDoneEvent | ResponseRefusalDeltaEvent | ResponseRefusalDoneEvent | ResponseTextDeltaEvent | ResponseTextDoneEvent;
  3883. type ResponseCompletedEvent = {
  3884. response: Response;
  3885. sequence_number: number;
  3886. type: "response.completed";
  3887. };
  3888. type ResponseTextConfig = {
  3889. format?: ResponseFormatTextConfig;
  3890. verbosity?: "low" | "medium" | "high" | null;
  3891. };
  3892. type ResponseTextDeltaEvent = {
  3893. content_index: number;
  3894. delta: string;
  3895. item_id: string;
  3896. logprobs: Array<Logprob>;
  3897. output_index: number;
  3898. sequence_number: number;
  3899. type: "response.output_text.delta";
  3900. };
  3901. type ResponseTextDoneEvent = {
  3902. content_index: number;
  3903. item_id: string;
  3904. logprobs: Array<Logprob>;
  3905. output_index: number;
  3906. sequence_number: number;
  3907. text: string;
  3908. type: "response.output_text.done";
  3909. };
  3910. type Logprob = {
  3911. token: string;
  3912. logprob: number;
  3913. top_logprobs?: Array<TopLogprob>;
  3914. };
  3915. type TopLogprob = {
  3916. token?: string;
  3917. logprob?: number;
  3918. };
  3919. type ResponseUsage = {
  3920. input_tokens: number;
  3921. output_tokens: number;
  3922. total_tokens: number;
  3923. };
  3924. type Tool = ResponsesFunctionTool;
  3925. type ToolChoiceFunction = {
  3926. name: string;
  3927. type: "function";
  3928. };
  3929. type ToolChoiceOptions = "none";
  3930. type ReasoningEffort = "minimal" | "low" | "medium" | "high" | null;
  3931. type StreamOptions = {
  3932. include_obfuscation?: boolean;
  3933. };
  3934. type Ai_Cf_Baai_Bge_Base_En_V1_5_Input = {
  3935. text: string | string[];
  3936. /**
  3937. * The pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy.
  3938. */
  3939. pooling?: "mean" | "cls";
  3940. } | {
  3941. /**
  3942. * Batch of the embeddings requests to run using async-queue
  3943. */
  3944. requests: {
  3945. text: string | string[];
  3946. /**
  3947. * The pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy.
  3948. */
  3949. pooling?: "mean" | "cls";
  3950. }[];
  3951. };
  3952. type Ai_Cf_Baai_Bge_Base_En_V1_5_Output = {
  3953. shape?: number[];
  3954. /**
  3955. * Embeddings of the requested text values
  3956. */
  3957. data?: number[][];
  3958. /**
  3959. * The pooling method used in the embedding process.
  3960. */
  3961. pooling?: "mean" | "cls";
  3962. } | Ai_Cf_Baai_Bge_Base_En_V1_5_AsyncResponse;
  3963. interface Ai_Cf_Baai_Bge_Base_En_V1_5_AsyncResponse {
  3964. /**
  3965. * The async request id that can be used to obtain the results.
  3966. */
  3967. request_id?: string;
  3968. }
  3969. declare abstract class Base_Ai_Cf_Baai_Bge_Base_En_V1_5 {
  3970. inputs: Ai_Cf_Baai_Bge_Base_En_V1_5_Input;
  3971. postProcessedOutputs: Ai_Cf_Baai_Bge_Base_En_V1_5_Output;
  3972. }
  3973. type Ai_Cf_Openai_Whisper_Input = string | {
  3974. /**
  3975. * An array of integers that represent the audio data constrained to 8-bit unsigned integer values
  3976. */
  3977. audio: number[];
  3978. };
  3979. interface Ai_Cf_Openai_Whisper_Output {
  3980. /**
  3981. * The transcription
  3982. */
  3983. text: string;
  3984. word_count?: number;
  3985. words?: {
  3986. word?: string;
  3987. /**
  3988. * The second this word begins in the recording
  3989. */
  3990. start?: number;
  3991. /**
  3992. * The ending second when the word completes
  3993. */
  3994. end?: number;
  3995. }[];
  3996. vtt?: string;
  3997. }
  3998. declare abstract class Base_Ai_Cf_Openai_Whisper {
  3999. inputs: Ai_Cf_Openai_Whisper_Input;
  4000. postProcessedOutputs: Ai_Cf_Openai_Whisper_Output;
  4001. }
  4002. type Ai_Cf_Meta_M2M100_1_2B_Input = {
  4003. /**
  4004. * The text to be translated
  4005. */
  4006. text: string;
  4007. /**
  4008. * The language code of the source text (e.g., 'en' for English). Defaults to 'en' if not specified
  4009. */
  4010. source_lang?: string;
  4011. /**
  4012. * The language code to translate the text into (e.g., 'es' for Spanish)
  4013. */
  4014. target_lang: string;
  4015. } | {
  4016. /**
  4017. * Batch of the embeddings requests to run using async-queue
  4018. */
  4019. requests: {
  4020. /**
  4021. * The text to be translated
  4022. */
  4023. text: string;
  4024. /**
  4025. * The language code of the source text (e.g., 'en' for English). Defaults to 'en' if not specified
  4026. */
  4027. source_lang?: string;
  4028. /**
  4029. * The language code to translate the text into (e.g., 'es' for Spanish)
  4030. */
  4031. target_lang: string;
  4032. }[];
  4033. };
  4034. type Ai_Cf_Meta_M2M100_1_2B_Output = {
  4035. /**
  4036. * The translated text in the target language
  4037. */
  4038. translated_text?: string;
  4039. } | Ai_Cf_Meta_M2M100_1_2B_AsyncResponse;
  4040. interface Ai_Cf_Meta_M2M100_1_2B_AsyncResponse {
  4041. /**
  4042. * The async request id that can be used to obtain the results.
  4043. */
  4044. request_id?: string;
  4045. }
  4046. declare abstract class Base_Ai_Cf_Meta_M2M100_1_2B {
  4047. inputs: Ai_Cf_Meta_M2M100_1_2B_Input;
  4048. postProcessedOutputs: Ai_Cf_Meta_M2M100_1_2B_Output;
  4049. }
  4050. type Ai_Cf_Baai_Bge_Small_En_V1_5_Input = {
  4051. text: string | string[];
  4052. /**
  4053. * The pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy.
  4054. */
  4055. pooling?: "mean" | "cls";
  4056. } | {
  4057. /**
  4058. * Batch of the embeddings requests to run using async-queue
  4059. */
  4060. requests: {
  4061. text: string | string[];
  4062. /**
  4063. * The pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy.
  4064. */
  4065. pooling?: "mean" | "cls";
  4066. }[];
  4067. };
  4068. type Ai_Cf_Baai_Bge_Small_En_V1_5_Output = {
  4069. shape?: number[];
  4070. /**
  4071. * Embeddings of the requested text values
  4072. */
  4073. data?: number[][];
  4074. /**
  4075. * The pooling method used in the embedding process.
  4076. */
  4077. pooling?: "mean" | "cls";
  4078. } | Ai_Cf_Baai_Bge_Small_En_V1_5_AsyncResponse;
  4079. interface Ai_Cf_Baai_Bge_Small_En_V1_5_AsyncResponse {
  4080. /**
  4081. * The async request id that can be used to obtain the results.
  4082. */
  4083. request_id?: string;
  4084. }
  4085. declare abstract class Base_Ai_Cf_Baai_Bge_Small_En_V1_5 {
  4086. inputs: Ai_Cf_Baai_Bge_Small_En_V1_5_Input;
  4087. postProcessedOutputs: Ai_Cf_Baai_Bge_Small_En_V1_5_Output;
  4088. }
  4089. type Ai_Cf_Baai_Bge_Large_En_V1_5_Input = {
  4090. text: string | string[];
  4091. /**
  4092. * The pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy.
  4093. */
  4094. pooling?: "mean" | "cls";
  4095. } | {
  4096. /**
  4097. * Batch of the embeddings requests to run using async-queue
  4098. */
  4099. requests: {
  4100. text: string | string[];
  4101. /**
  4102. * The pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy.
  4103. */
  4104. pooling?: "mean" | "cls";
  4105. }[];
  4106. };
  4107. type Ai_Cf_Baai_Bge_Large_En_V1_5_Output = {
  4108. shape?: number[];
  4109. /**
  4110. * Embeddings of the requested text values
  4111. */
  4112. data?: number[][];
  4113. /**
  4114. * The pooling method used in the embedding process.
  4115. */
  4116. pooling?: "mean" | "cls";
  4117. } | Ai_Cf_Baai_Bge_Large_En_V1_5_AsyncResponse;
  4118. interface Ai_Cf_Baai_Bge_Large_En_V1_5_AsyncResponse {
  4119. /**
  4120. * The async request id that can be used to obtain the results.
  4121. */
  4122. request_id?: string;
  4123. }
  4124. declare abstract class Base_Ai_Cf_Baai_Bge_Large_En_V1_5 {
  4125. inputs: Ai_Cf_Baai_Bge_Large_En_V1_5_Input;
  4126. postProcessedOutputs: Ai_Cf_Baai_Bge_Large_En_V1_5_Output;
  4127. }
  4128. type Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Input = string | {
  4129. /**
  4130. * The input text prompt for the model to generate a response.
  4131. */
  4132. prompt?: string;
  4133. /**
  4134. * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
  4135. */
  4136. raw?: boolean;
  4137. /**
  4138. * Controls the creativity of the AI's responses by adjusting how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
  4139. */
  4140. top_p?: number;
  4141. /**
  4142. * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
  4143. */
  4144. top_k?: number;
  4145. /**
  4146. * Random seed for reproducibility of the generation.
  4147. */
  4148. seed?: number;
  4149. /**
  4150. * Penalty for repeated tokens; higher values discourage repetition.
  4151. */
  4152. repetition_penalty?: number;
  4153. /**
  4154. * Decreases the likelihood of the model repeating the same lines verbatim.
  4155. */
  4156. frequency_penalty?: number;
  4157. /**
  4158. * Increases the likelihood of the model introducing new topics.
  4159. */
  4160. presence_penalty?: number;
  4161. image: number[] | (string & NonNullable<unknown>);
  4162. /**
  4163. * The maximum number of tokens to generate in the response.
  4164. */
  4165. max_tokens?: number;
  4166. };
  4167. interface Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Output {
  4168. description?: string;
  4169. }
  4170. declare abstract class Base_Ai_Cf_Unum_Uform_Gen2_Qwen_500M {
  4171. inputs: Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Input;
  4172. postProcessedOutputs: Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Output;
  4173. }
  4174. type Ai_Cf_Openai_Whisper_Tiny_En_Input = string | {
  4175. /**
  4176. * An array of integers that represent the audio data constrained to 8-bit unsigned integer values
  4177. */
  4178. audio: number[];
  4179. };
  4180. interface Ai_Cf_Openai_Whisper_Tiny_En_Output {
  4181. /**
  4182. * The transcription
  4183. */
  4184. text: string;
  4185. word_count?: number;
  4186. words?: {
  4187. word?: string;
  4188. /**
  4189. * The second this word begins in the recording
  4190. */
  4191. start?: number;
  4192. /**
  4193. * The ending second when the word completes
  4194. */
  4195. end?: number;
  4196. }[];
  4197. vtt?: string;
  4198. }
  4199. declare abstract class Base_Ai_Cf_Openai_Whisper_Tiny_En {
  4200. inputs: Ai_Cf_Openai_Whisper_Tiny_En_Input;
  4201. postProcessedOutputs: Ai_Cf_Openai_Whisper_Tiny_En_Output;
  4202. }
  4203. interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
  4204. /**
  4205. * Base64 encoded value of the audio data.
  4206. */
  4207. audio: string;
  4208. /**
  4209. * Supported tasks are 'translate' or 'transcribe'.
  4210. */
  4211. task?: string;
  4212. /**
  4213. * The language of the audio being transcribed or translated.
  4214. */
  4215. language?: string;
  4216. /**
  4217. * Preprocess the audio with a voice activity detection model.
  4218. */
  4219. vad_filter?: boolean;
  4220. /**
  4221. * A text prompt to help provide context to the model on the contents of the audio.
  4222. */
  4223. initial_prompt?: string;
  4224. /**
  4225. * The prefix it appended the the beginning of the output of the transcription and can guide the transcription result.
  4226. */
  4227. prefix?: string;
  4228. }
  4229. interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output {
  4230. transcription_info?: {
  4231. /**
  4232. * The language of the audio being transcribed or translated.
  4233. */
  4234. language?: string;
  4235. /**
  4236. * The confidence level or probability of the detected language being accurate, represented as a decimal between 0 and 1.
  4237. */
  4238. language_probability?: number;
  4239. /**
  4240. * The total duration of the original audio file, in seconds.
  4241. */
  4242. duration?: number;
  4243. /**
  4244. * The duration of the audio after applying Voice Activity Detection (VAD) to remove silent or irrelevant sections, in seconds.
  4245. */
  4246. duration_after_vad?: number;
  4247. };
  4248. /**
  4249. * The complete transcription of the audio.
  4250. */
  4251. text: string;
  4252. /**
  4253. * The total number of words in the transcription.
  4254. */
  4255. word_count?: number;
  4256. segments?: {
  4257. /**
  4258. * The starting time of the segment within the audio, in seconds.
  4259. */
  4260. start?: number;
  4261. /**
  4262. * The ending time of the segment within the audio, in seconds.
  4263. */
  4264. end?: number;
  4265. /**
  4266. * The transcription of the segment.
  4267. */
  4268. text?: string;
  4269. /**
  4270. * The temperature used in the decoding process, controlling randomness in predictions. Lower values result in more deterministic outputs.
  4271. */
  4272. temperature?: number;
  4273. /**
  4274. * The average log probability of the predictions for the words in this segment, indicating overall confidence.
  4275. */
  4276. avg_logprob?: number;
  4277. /**
  4278. * The compression ratio of the input to the output, measuring how much the text was compressed during the transcription process.
  4279. */
  4280. compression_ratio?: number;
  4281. /**
  4282. * The probability that the segment contains no speech, represented as a decimal between 0 and 1.
  4283. */
  4284. no_speech_prob?: number;
  4285. words?: {
  4286. /**
  4287. * The individual word transcribed from the audio.
  4288. */
  4289. word?: string;
  4290. /**
  4291. * The starting time of the word within the audio, in seconds.
  4292. */
  4293. start?: number;
  4294. /**
  4295. * The ending time of the word within the audio, in seconds.
  4296. */
  4297. end?: number;
  4298. }[];
  4299. }[];
  4300. /**
  4301. * The transcription in WebVTT format, which includes timing and text information for use in subtitles.
  4302. */
  4303. vtt?: string;
  4304. }
  4305. declare abstract class Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo {
  4306. inputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input;
  4307. postProcessedOutputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output;
  4308. }
  4309. type Ai_Cf_Baai_Bge_M3_Input = Ai_Cf_Baai_Bge_M3_Input_QueryAnd_Contexts | Ai_Cf_Baai_Bge_M3_Input_Embedding | {
  4310. /**
  4311. * Batch of the embeddings requests to run using async-queue
  4312. */
  4313. requests: (Ai_Cf_Baai_Bge_M3_Input_QueryAnd_Contexts_1 | Ai_Cf_Baai_Bge_M3_Input_Embedding_1)[];
  4314. };
  4315. interface Ai_Cf_Baai_Bge_M3_Input_QueryAnd_Contexts {
  4316. /**
  4317. * A query you wish to perform against the provided contexts. If no query is provided the model with respond with embeddings for contexts
  4318. */
  4319. query?: string;
  4320. /**
  4321. * List of provided contexts. Note that the index in this array is important, as the response will refer to it.
  4322. */
  4323. contexts: {
  4324. /**
  4325. * One of the provided context content
  4326. */
  4327. text?: string;
  4328. }[];
  4329. /**
  4330. * When provided with too long context should the model error out or truncate the context to fit?
  4331. */
  4332. truncate_inputs?: boolean;
  4333. }
  4334. interface Ai_Cf_Baai_Bge_M3_Input_Embedding {
  4335. text: string | string[];
  4336. /**
  4337. * When provided with too long context should the model error out or truncate the context to fit?
  4338. */
  4339. truncate_inputs?: boolean;
  4340. }
  4341. interface Ai_Cf_Baai_Bge_M3_Input_QueryAnd_Contexts_1 {
  4342. /**
  4343. * A query you wish to perform against the provided contexts. If no query is provided the model with respond with embeddings for contexts
  4344. */
  4345. query?: string;
  4346. /**
  4347. * List of provided contexts. Note that the index in this array is important, as the response will refer to it.
  4348. */
  4349. contexts: {
  4350. /**
  4351. * One of the provided context content
  4352. */
  4353. text?: string;
  4354. }[];
  4355. /**
  4356. * When provided with too long context should the model error out or truncate the context to fit?
  4357. */
  4358. truncate_inputs?: boolean;
  4359. }
  4360. interface Ai_Cf_Baai_Bge_M3_Input_Embedding_1 {
  4361. text: string | string[];
  4362. /**
  4363. * When provided with too long context should the model error out or truncate the context to fit?
  4364. */
  4365. truncate_inputs?: boolean;
  4366. }
  4367. type Ai_Cf_Baai_Bge_M3_Output = Ai_Cf_Baai_Bge_M3_Ouput_Query | Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts | Ai_Cf_Baai_Bge_M3_Ouput_Embedding | Ai_Cf_Baai_Bge_M3_AsyncResponse;
  4368. interface Ai_Cf_Baai_Bge_M3_Ouput_Query {
  4369. response?: {
  4370. /**
  4371. * Index of the context in the request
  4372. */
  4373. id?: number;
  4374. /**
  4375. * Score of the context under the index.
  4376. */
  4377. score?: number;
  4378. }[];
  4379. }
  4380. interface Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts {
  4381. response?: number[][];
  4382. shape?: number[];
  4383. /**
  4384. * The pooling method used in the embedding process.
  4385. */
  4386. pooling?: "mean" | "cls";
  4387. }
  4388. interface Ai_Cf_Baai_Bge_M3_Ouput_Embedding {
  4389. shape?: number[];
  4390. /**
  4391. * Embeddings of the requested text values
  4392. */
  4393. data?: number[][];
  4394. /**
  4395. * The pooling method used in the embedding process.
  4396. */
  4397. pooling?: "mean" | "cls";
  4398. }
  4399. interface Ai_Cf_Baai_Bge_M3_AsyncResponse {
  4400. /**
  4401. * The async request id that can be used to obtain the results.
  4402. */
  4403. request_id?: string;
  4404. }
  4405. declare abstract class Base_Ai_Cf_Baai_Bge_M3 {
  4406. inputs: Ai_Cf_Baai_Bge_M3_Input;
  4407. postProcessedOutputs: Ai_Cf_Baai_Bge_M3_Output;
  4408. }
  4409. interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input {
  4410. /**
  4411. * A text description of the image you want to generate.
  4412. */
  4413. prompt: string;
  4414. /**
  4415. * The number of diffusion steps; higher values can improve quality but take longer.
  4416. */
  4417. steps?: number;
  4418. }
  4419. interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output {
  4420. /**
  4421. * The generated image in Base64 format.
  4422. */
  4423. image?: string;
  4424. }
  4425. declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell {
  4426. inputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input;
  4427. postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output;
  4428. }
  4429. type Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Input = Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Prompt | Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Messages;
  4430. interface Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Prompt {
  4431. /**
  4432. * The input text prompt for the model to generate a response.
  4433. */
  4434. prompt: string;
  4435. image?: number[] | (string & NonNullable<unknown>);
  4436. /**
  4437. * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
  4438. */
  4439. raw?: boolean;
  4440. /**
  4441. * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
  4442. */
  4443. stream?: boolean;
  4444. /**
  4445. * The maximum number of tokens to generate in the response.
  4446. */
  4447. max_tokens?: number;
  4448. /**
  4449. * Controls the randomness of the output; higher values produce more random results.
  4450. */
  4451. temperature?: number;
  4452. /**
  4453. * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
  4454. */
  4455. top_p?: number;
  4456. /**
  4457. * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
  4458. */
  4459. top_k?: number;
  4460. /**
  4461. * Random seed for reproducibility of the generation.
  4462. */
  4463. seed?: number;
  4464. /**
  4465. * Penalty for repeated tokens; higher values discourage repetition.
  4466. */
  4467. repetition_penalty?: number;
  4468. /**
  4469. * Decreases the likelihood of the model repeating the same lines verbatim.
  4470. */
  4471. frequency_penalty?: number;
  4472. /**
  4473. * Increases the likelihood of the model introducing new topics.
  4474. */
  4475. presence_penalty?: number;
  4476. /**
  4477. * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
  4478. */
  4479. lora?: string;
  4480. }
  4481. interface Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Messages {
  4482. /**
  4483. * An array of message objects representing the conversation history.
  4484. */
  4485. messages: {
  4486. /**
  4487. * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
  4488. */
  4489. role?: string;
  4490. /**
  4491. * The tool call id. Must be supplied for tool calls for Mistral-3. If you don't know what to put here you can fall back to 000000001
  4492. */
  4493. tool_call_id?: string;
  4494. content?: string | {
  4495. /**
  4496. * Type of the content provided
  4497. */
  4498. type?: string;
  4499. text?: string;
  4500. image_url?: {
  4501. /**
  4502. * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
  4503. */
  4504. url?: string;
  4505. };
  4506. }[] | {
  4507. /**
  4508. * Type of the content provided
  4509. */
  4510. type?: string;
  4511. text?: string;
  4512. image_url?: {
  4513. /**
  4514. * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
  4515. */
  4516. url?: string;
  4517. };
  4518. };
  4519. }[];
  4520. image?: number[] | (string & NonNullable<unknown>);
  4521. functions?: {
  4522. name: string;
  4523. code: string;
  4524. }[];
  4525. /**
  4526. * A list of tools available for the assistant to use.
  4527. */
  4528. tools?: ({
  4529. /**
  4530. * The name of the tool. More descriptive the better.
  4531. */
  4532. name: string;
  4533. /**
  4534. * A brief description of what the tool does.
  4535. */
  4536. description: string;
  4537. /**
  4538. * Schema defining the parameters accepted by the tool.
  4539. */
  4540. parameters: {
  4541. /**
  4542. * The type of the parameters object (usually 'object').
  4543. */
  4544. type: string;
  4545. /**
  4546. * List of required parameter names.
  4547. */
  4548. required?: string[];
  4549. /**
  4550. * Definitions of each parameter.
  4551. */
  4552. properties: {
  4553. [k: string]: {
  4554. /**
  4555. * The data type of the parameter.
  4556. */
  4557. type: string;
  4558. /**
  4559. * A description of the expected parameter.
  4560. */
  4561. description: string;
  4562. };
  4563. };
  4564. };
  4565. } | {
  4566. /**
  4567. * Specifies the type of tool (e.g., 'function').
  4568. */
  4569. type: string;
  4570. /**
  4571. * Details of the function tool.
  4572. */
  4573. function: {
  4574. /**
  4575. * The name of the function.
  4576. */
  4577. name: string;
  4578. /**
  4579. * A brief description of what the function does.
  4580. */
  4581. description: string;
  4582. /**
  4583. * Schema defining the parameters accepted by the function.
  4584. */
  4585. parameters: {
  4586. /**
  4587. * The type of the parameters object (usually 'object').
  4588. */
  4589. type: string;
  4590. /**
  4591. * List of required parameter names.
  4592. */
  4593. required?: string[];
  4594. /**
  4595. * Definitions of each parameter.
  4596. */
  4597. properties: {
  4598. [k: string]: {
  4599. /**
  4600. * The data type of the parameter.
  4601. */
  4602. type: string;
  4603. /**
  4604. * A description of the expected parameter.
  4605. */
  4606. description: string;
  4607. };
  4608. };
  4609. };
  4610. };
  4611. })[];
  4612. /**
  4613. * If true, the response will be streamed back incrementally.
  4614. */
  4615. stream?: boolean;
  4616. /**
  4617. * The maximum number of tokens to generate in the response.
  4618. */
  4619. max_tokens?: number;
  4620. /**
  4621. * Controls the randomness of the output; higher values produce more random results.
  4622. */
  4623. temperature?: number;
  4624. /**
  4625. * Controls the creativity of the AI's responses by adjusting how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
  4626. */
  4627. top_p?: number;
  4628. /**
  4629. * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
  4630. */
  4631. top_k?: number;
  4632. /**
  4633. * Random seed for reproducibility of the generation.
  4634. */
  4635. seed?: number;
  4636. /**
  4637. * Penalty for repeated tokens; higher values discourage repetition.
  4638. */
  4639. repetition_penalty?: number;
  4640. /**
  4641. * Decreases the likelihood of the model repeating the same lines verbatim.
  4642. */
  4643. frequency_penalty?: number;
  4644. /**
  4645. * Increases the likelihood of the model introducing new topics.
  4646. */
  4647. presence_penalty?: number;
  4648. }
  4649. type Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output = {
  4650. /**
  4651. * The generated text response from the model
  4652. */
  4653. response?: string;
  4654. /**
  4655. * An array of tool calls requests made during the response generation
  4656. */
  4657. tool_calls?: {
  4658. /**
  4659. * The arguments passed to be passed to the tool call request
  4660. */
  4661. arguments?: object;
  4662. /**
  4663. * The name of the tool to be called
  4664. */
  4665. name?: string;
  4666. }[];
  4667. };
  4668. declare abstract class Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct {
  4669. inputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Input;
  4670. postProcessedOutputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output;
  4671. }
  4672. type Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Input = Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Prompt | Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Messages | Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Async_Batch;
  4673. interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Prompt {
  4674. /**
  4675. * The input text prompt for the model to generate a response.
  4676. */
  4677. prompt: string;
  4678. /**
  4679. * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
  4680. */
  4681. lora?: string;
  4682. response_format?: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode;
  4683. /**
  4684. * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
  4685. */
  4686. raw?: boolean;
  4687. /**
  4688. * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
  4689. */
  4690. stream?: boolean;
  4691. /**
  4692. * The maximum number of tokens to generate in the response.
  4693. */
  4694. max_tokens?: number;
  4695. /**
  4696. * Controls the randomness of the output; higher values produce more random results.
  4697. */
  4698. temperature?: number;
  4699. /**
  4700. * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
  4701. */
  4702. top_p?: number;
  4703. /**
  4704. * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
  4705. */
  4706. top_k?: number;
  4707. /**
  4708. * Random seed for reproducibility of the generation.
  4709. */
  4710. seed?: number;
  4711. /**
  4712. * Penalty for repeated tokens; higher values discourage repetition.
  4713. */
  4714. repetition_penalty?: number;
  4715. /**
  4716. * Decreases the likelihood of the model repeating the same lines verbatim.
  4717. */
  4718. frequency_penalty?: number;
  4719. /**
  4720. * Increases the likelihood of the model introducing new topics.
  4721. */
  4722. presence_penalty?: number;
  4723. }
  4724. interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode {
  4725. type?: "json_object" | "json_schema";
  4726. json_schema?: unknown;
  4727. }
  4728. interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Messages {
  4729. /**
  4730. * An array of message objects representing the conversation history.
  4731. */
  4732. messages: {
  4733. /**
  4734. * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
  4735. */
  4736. role: string;
  4737. /**
  4738. * The content of the message as a string.
  4739. */
  4740. content: string;
  4741. }[];
  4742. functions?: {
  4743. name: string;
  4744. code: string;
  4745. }[];
  4746. /**
  4747. * A list of tools available for the assistant to use.
  4748. */
  4749. tools?: ({
  4750. /**
  4751. * The name of the tool. More descriptive the better.
  4752. */
  4753. name: string;
  4754. /**
  4755. * A brief description of what the tool does.
  4756. */
  4757. description: string;
  4758. /**
  4759. * Schema defining the parameters accepted by the tool.
  4760. */
  4761. parameters: {
  4762. /**
  4763. * The type of the parameters object (usually 'object').
  4764. */
  4765. type: string;
  4766. /**
  4767. * List of required parameter names.
  4768. */
  4769. required?: string[];
  4770. /**
  4771. * Definitions of each parameter.
  4772. */
  4773. properties: {
  4774. [k: string]: {
  4775. /**
  4776. * The data type of the parameter.
  4777. */
  4778. type: string;
  4779. /**
  4780. * A description of the expected parameter.
  4781. */
  4782. description: string;
  4783. };
  4784. };
  4785. };
  4786. } | {
  4787. /**
  4788. * Specifies the type of tool (e.g., 'function').
  4789. */
  4790. type: string;
  4791. /**
  4792. * Details of the function tool.
  4793. */
  4794. function: {
  4795. /**
  4796. * The name of the function.
  4797. */
  4798. name: string;
  4799. /**
  4800. * A brief description of what the function does.
  4801. */
  4802. description: string;
  4803. /**
  4804. * Schema defining the parameters accepted by the function.
  4805. */
  4806. parameters: {
  4807. /**
  4808. * The type of the parameters object (usually 'object').
  4809. */
  4810. type: string;
  4811. /**
  4812. * List of required parameter names.
  4813. */
  4814. required?: string[];
  4815. /**
  4816. * Definitions of each parameter.
  4817. */
  4818. properties: {
  4819. [k: string]: {
  4820. /**
  4821. * The data type of the parameter.
  4822. */
  4823. type: string;
  4824. /**
  4825. * A description of the expected parameter.
  4826. */
  4827. description: string;
  4828. };
  4829. };
  4830. };
  4831. };
  4832. })[];
  4833. response_format?: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode_1;
  4834. /**
  4835. * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
  4836. */
  4837. raw?: boolean;
  4838. /**
  4839. * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
  4840. */
  4841. stream?: boolean;
  4842. /**
  4843. * The maximum number of tokens to generate in the response.
  4844. */
  4845. max_tokens?: number;
  4846. /**
  4847. * Controls the randomness of the output; higher values produce more random results.
  4848. */
  4849. temperature?: number;
  4850. /**
  4851. * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
  4852. */
  4853. top_p?: number;
  4854. /**
  4855. * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
  4856. */
  4857. top_k?: number;
  4858. /**
  4859. * Random seed for reproducibility of the generation.
  4860. */
  4861. seed?: number;
  4862. /**
  4863. * Penalty for repeated tokens; higher values discourage repetition.
  4864. */
  4865. repetition_penalty?: number;
  4866. /**
  4867. * Decreases the likelihood of the model repeating the same lines verbatim.
  4868. */
  4869. frequency_penalty?: number;
  4870. /**
  4871. * Increases the likelihood of the model introducing new topics.
  4872. */
  4873. presence_penalty?: number;
  4874. }
  4875. interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode_1 {
  4876. type?: "json_object" | "json_schema";
  4877. json_schema?: unknown;
  4878. }
  4879. interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Async_Batch {
  4880. requests?: {
  4881. /**
  4882. * User-supplied reference. This field will be present in the response as well it can be used to reference the request and response. It's NOT validated to be unique.
  4883. */
  4884. external_reference?: string;
  4885. /**
  4886. * Prompt for the text generation model
  4887. */
  4888. prompt?: string;
  4889. /**
  4890. * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
  4891. */
  4892. stream?: boolean;
  4893. /**
  4894. * The maximum number of tokens to generate in the response.
  4895. */
  4896. max_tokens?: number;
  4897. /**
  4898. * Controls the randomness of the output; higher values produce more random results.
  4899. */
  4900. temperature?: number;
  4901. /**
  4902. * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
  4903. */
  4904. top_p?: number;
  4905. /**
  4906. * Random seed for reproducibility of the generation.
  4907. */
  4908. seed?: number;
  4909. /**
  4910. * Penalty for repeated tokens; higher values discourage repetition.
  4911. */
  4912. repetition_penalty?: number;
  4913. /**
  4914. * Decreases the likelihood of the model repeating the same lines verbatim.
  4915. */
  4916. frequency_penalty?: number;
  4917. /**
  4918. * Increases the likelihood of the model introducing new topics.
  4919. */
  4920. presence_penalty?: number;
  4921. response_format?: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode_2;
  4922. }[];
  4923. }
  4924. interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode_2 {
  4925. type?: "json_object" | "json_schema";
  4926. json_schema?: unknown;
  4927. }
  4928. type Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Output = {
  4929. /**
  4930. * The generated text response from the model
  4931. */
  4932. response: string;
  4933. /**
  4934. * Usage statistics for the inference request
  4935. */
  4936. usage?: {
  4937. /**
  4938. * Total number of tokens in input
  4939. */
  4940. prompt_tokens?: number;
  4941. /**
  4942. * Total number of tokens in output
  4943. */
  4944. completion_tokens?: number;
  4945. /**
  4946. * Total number of input and output tokens
  4947. */
  4948. total_tokens?: number;
  4949. };
  4950. /**
  4951. * An array of tool calls requests made during the response generation
  4952. */
  4953. tool_calls?: {
  4954. /**
  4955. * The arguments passed to be passed to the tool call request
  4956. */
  4957. arguments?: object;
  4958. /**
  4959. * The name of the tool to be called
  4960. */
  4961. name?: string;
  4962. }[];
  4963. } | string | Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_AsyncResponse;
  4964. interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_AsyncResponse {
  4965. /**
  4966. * The async request id that can be used to obtain the results.
  4967. */
  4968. request_id?: string;
  4969. }
  4970. declare abstract class Base_Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast {
  4971. inputs: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Input;
  4972. postProcessedOutputs: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Output;
  4973. }
  4974. interface Ai_Cf_Meta_Llama_Guard_3_8B_Input {
  4975. /**
  4976. * An array of message objects representing the conversation history.
  4977. */
  4978. messages: {
  4979. /**
  4980. * The role of the message sender must alternate between 'user' and 'assistant'.
  4981. */
  4982. role: "user" | "assistant";
  4983. /**
  4984. * The content of the message as a string.
  4985. */
  4986. content: string;
  4987. }[];
  4988. /**
  4989. * The maximum number of tokens to generate in the response.
  4990. */
  4991. max_tokens?: number;
  4992. /**
  4993. * Controls the randomness of the output; higher values produce more random results.
  4994. */
  4995. temperature?: number;
  4996. /**
  4997. * Dictate the output format of the generated response.
  4998. */
  4999. response_format?: {
  5000. /**
  5001. * Set to json_object to process and output generated text as JSON.
  5002. */
  5003. type?: string;
  5004. };
  5005. }
  5006. interface Ai_Cf_Meta_Llama_Guard_3_8B_Output {
  5007. response?: string | {
  5008. /**
  5009. * Whether the conversation is safe or not.
  5010. */
  5011. safe?: boolean;
  5012. /**
  5013. * A list of what hazard categories predicted for the conversation, if the conversation is deemed unsafe.
  5014. */
  5015. categories?: string[];
  5016. };
  5017. /**
  5018. * Usage statistics for the inference request
  5019. */
  5020. usage?: {
  5021. /**
  5022. * Total number of tokens in input
  5023. */
  5024. prompt_tokens?: number;
  5025. /**
  5026. * Total number of tokens in output
  5027. */
  5028. completion_tokens?: number;
  5029. /**
  5030. * Total number of input and output tokens
  5031. */
  5032. total_tokens?: number;
  5033. };
  5034. }
  5035. declare abstract class Base_Ai_Cf_Meta_Llama_Guard_3_8B {
  5036. inputs: Ai_Cf_Meta_Llama_Guard_3_8B_Input;
  5037. postProcessedOutputs: Ai_Cf_Meta_Llama_Guard_3_8B_Output;
  5038. }
  5039. interface Ai_Cf_Baai_Bge_Reranker_Base_Input {
  5040. /**
  5041. * A query you wish to perform against the provided contexts.
  5042. */
  5043. /**
  5044. * Number of returned results starting with the best score.
  5045. */
  5046. top_k?: number;
  5047. /**
  5048. * List of provided contexts. Note that the index in this array is important, as the response will refer to it.
  5049. */
  5050. contexts: {
  5051. /**
  5052. * One of the provided context content
  5053. */
  5054. text?: string;
  5055. }[];
  5056. }
  5057. interface Ai_Cf_Baai_Bge_Reranker_Base_Output {
  5058. response?: {
  5059. /**
  5060. * Index of the context in the request
  5061. */
  5062. id?: number;
  5063. /**
  5064. * Score of the context under the index.
  5065. */
  5066. score?: number;
  5067. }[];
  5068. }
  5069. declare abstract class Base_Ai_Cf_Baai_Bge_Reranker_Base {
  5070. inputs: Ai_Cf_Baai_Bge_Reranker_Base_Input;
  5071. postProcessedOutputs: Ai_Cf_Baai_Bge_Reranker_Base_Output;
  5072. }
  5073. type Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Input = Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Prompt | Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Messages;
  5074. interface Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Prompt {
  5075. /**
  5076. * The input text prompt for the model to generate a response.
  5077. */
  5078. prompt: string;
  5079. /**
  5080. * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
  5081. */
  5082. lora?: string;
  5083. response_format?: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_JSON_Mode;
  5084. /**
  5085. * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
  5086. */
  5087. raw?: boolean;
  5088. /**
  5089. * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
  5090. */
  5091. stream?: boolean;
  5092. /**
  5093. * The maximum number of tokens to generate in the response.
  5094. */
  5095. max_tokens?: number;
  5096. /**
  5097. * Controls the randomness of the output; higher values produce more random results.
  5098. */
  5099. temperature?: number;
  5100. /**
  5101. * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
  5102. */
  5103. top_p?: number;
  5104. /**
  5105. * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
  5106. */
  5107. top_k?: number;
  5108. /**
  5109. * Random seed for reproducibility of the generation.
  5110. */
  5111. seed?: number;
  5112. /**
  5113. * Penalty for repeated tokens; higher values discourage repetition.
  5114. */
  5115. repetition_penalty?: number;
  5116. /**
  5117. * Decreases the likelihood of the model repeating the same lines verbatim.
  5118. */
  5119. frequency_penalty?: number;
  5120. /**
  5121. * Increases the likelihood of the model introducing new topics.
  5122. */
  5123. presence_penalty?: number;
  5124. }
  5125. interface Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_JSON_Mode {
  5126. type?: "json_object" | "json_schema";
  5127. json_schema?: unknown;
  5128. }
  5129. interface Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Messages {
  5130. /**
  5131. * An array of message objects representing the conversation history.
  5132. */
  5133. messages: {
  5134. /**
  5135. * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
  5136. */
  5137. role: string;
  5138. /**
  5139. * The content of the message as a string.
  5140. */
  5141. content: string;
  5142. }[];
  5143. functions?: {
  5144. name: string;
  5145. code: string;
  5146. }[];
  5147. /**
  5148. * A list of tools available for the assistant to use.
  5149. */
  5150. tools?: ({
  5151. /**
  5152. * The name of the tool. More descriptive the better.
  5153. */
  5154. name: string;
  5155. /**
  5156. * A brief description of what the tool does.
  5157. */
  5158. description: string;
  5159. /**
  5160. * Schema defining the parameters accepted by the tool.
  5161. */
  5162. parameters: {
  5163. /**
  5164. * The type of the parameters object (usually 'object').
  5165. */
  5166. type: string;
  5167. /**
  5168. * List of required parameter names.
  5169. */
  5170. required?: string[];
  5171. /**
  5172. * Definitions of each parameter.
  5173. */
  5174. properties: {
  5175. [k: string]: {
  5176. /**
  5177. * The data type of the parameter.
  5178. */
  5179. type: string;
  5180. /**
  5181. * A description of the expected parameter.
  5182. */
  5183. description: string;
  5184. };
  5185. };
  5186. };
  5187. } | {
  5188. /**
  5189. * Specifies the type of tool (e.g., 'function').
  5190. */
  5191. type: string;
  5192. /**
  5193. * Details of the function tool.
  5194. */
  5195. function: {
  5196. /**
  5197. * The name of the function.
  5198. */
  5199. name: string;
  5200. /**
  5201. * A brief description of what the function does.
  5202. */
  5203. description: string;
  5204. /**
  5205. * Schema defining the parameters accepted by the function.
  5206. */
  5207. parameters: {
  5208. /**
  5209. * The type of the parameters object (usually 'object').
  5210. */
  5211. type: string;
  5212. /**
  5213. * List of required parameter names.
  5214. */
  5215. required?: string[];
  5216. /**
  5217. * Definitions of each parameter.
  5218. */
  5219. properties: {
  5220. [k: string]: {
  5221. /**
  5222. * The data type of the parameter.
  5223. */
  5224. type: string;
  5225. /**
  5226. * A description of the expected parameter.
  5227. */
  5228. description: string;
  5229. };
  5230. };
  5231. };
  5232. };
  5233. })[];
  5234. response_format?: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_JSON_Mode_1;
  5235. /**
  5236. * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
  5237. */
  5238. raw?: boolean;
  5239. /**
  5240. * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
  5241. */
  5242. stream?: boolean;
  5243. /**
  5244. * The maximum number of tokens to generate in the response.
  5245. */
  5246. max_tokens?: number;
  5247. /**
  5248. * Controls the randomness of the output; higher values produce more random results.
  5249. */
  5250. temperature?: number;
  5251. /**
  5252. * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
  5253. */
  5254. top_p?: number;
  5255. /**
  5256. * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
  5257. */
  5258. top_k?: number;
  5259. /**
  5260. * Random seed for reproducibility of the generation.
  5261. */
  5262. seed?: number;
  5263. /**
  5264. * Penalty for repeated tokens; higher values discourage repetition.
  5265. */
  5266. repetition_penalty?: number;
  5267. /**
  5268. * Decreases the likelihood of the model repeating the same lines verbatim.
  5269. */
  5270. frequency_penalty?: number;
  5271. /**
  5272. * Increases the likelihood of the model introducing new topics.
  5273. */
  5274. presence_penalty?: number;
  5275. }
  5276. interface Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_JSON_Mode_1 {
  5277. type?: "json_object" | "json_schema";
  5278. json_schema?: unknown;
  5279. }
  5280. type Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Output = {
  5281. /**
  5282. * The generated text response from the model
  5283. */
  5284. response: string;
  5285. /**
  5286. * Usage statistics for the inference request
  5287. */
  5288. usage?: {
  5289. /**
  5290. * Total number of tokens in input
  5291. */
  5292. prompt_tokens?: number;
  5293. /**
  5294. * Total number of tokens in output
  5295. */
  5296. completion_tokens?: number;
  5297. /**
  5298. * Total number of input and output tokens
  5299. */
  5300. total_tokens?: number;
  5301. };
  5302. /**
  5303. * An array of tool calls requests made during the response generation
  5304. */
  5305. tool_calls?: {
  5306. /**
  5307. * The arguments passed to be passed to the tool call request
  5308. */
  5309. arguments?: object;
  5310. /**
  5311. * The name of the tool to be called
  5312. */
  5313. name?: string;
  5314. }[];
  5315. };
  5316. declare abstract class Base_Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct {
  5317. inputs: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Input;
  5318. postProcessedOutputs: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Output;
  5319. }
  5320. type Ai_Cf_Qwen_Qwq_32B_Input = Ai_Cf_Qwen_Qwq_32B_Prompt | Ai_Cf_Qwen_Qwq_32B_Messages;
  5321. interface Ai_Cf_Qwen_Qwq_32B_Prompt {
  5322. /**
  5323. * The input text prompt for the model to generate a response.
  5324. */
  5325. prompt: string;
  5326. /**
  5327. * JSON schema that should be fulfilled for the response.
  5328. */
  5329. guided_json?: object;
  5330. /**
  5331. * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
  5332. */
  5333. raw?: boolean;
  5334. /**
  5335. * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
  5336. */
  5337. stream?: boolean;
  5338. /**
  5339. * The maximum number of tokens to generate in the response.
  5340. */
  5341. max_tokens?: number;
  5342. /**
  5343. * Controls the randomness of the output; higher values produce more random results.
  5344. */
  5345. temperature?: number;
  5346. /**
  5347. * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
  5348. */
  5349. top_p?: number;
  5350. /**
  5351. * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
  5352. */
  5353. top_k?: number;
  5354. /**
  5355. * Random seed for reproducibility of the generation.
  5356. */
  5357. seed?: number;
  5358. /**
  5359. * Penalty for repeated tokens; higher values discourage repetition.
  5360. */
  5361. repetition_penalty?: number;
  5362. /**
  5363. * Decreases the likelihood of the model repeating the same lines verbatim.
  5364. */
  5365. frequency_penalty?: number;
  5366. /**
  5367. * Increases the likelihood of the model introducing new topics.
  5368. */
  5369. presence_penalty?: number;
  5370. }
  5371. interface Ai_Cf_Qwen_Qwq_32B_Messages {
  5372. /**
  5373. * An array of message objects representing the conversation history.
  5374. */
  5375. messages: {
  5376. /**
  5377. * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
  5378. */
  5379. role?: string;
  5380. /**
  5381. * The tool call id. Must be supplied for tool calls for Mistral-3. If you don't know what to put here you can fall back to 000000001
  5382. */
  5383. tool_call_id?: string;
  5384. content?: string | {
  5385. /**
  5386. * Type of the content provided
  5387. */
  5388. type?: string;
  5389. text?: string;
  5390. image_url?: {
  5391. /**
  5392. * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
  5393. */
  5394. url?: string;
  5395. };
  5396. }[] | {
  5397. /**
  5398. * Type of the content provided
  5399. */
  5400. type?: string;
  5401. text?: string;
  5402. image_url?: {
  5403. /**
  5404. * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
  5405. */
  5406. url?: string;
  5407. };
  5408. };
  5409. }[];
  5410. functions?: {
  5411. name: string;
  5412. code: string;
  5413. }[];
  5414. /**
  5415. * A list of tools available for the assistant to use.
  5416. */
  5417. tools?: ({
  5418. /**
  5419. * The name of the tool. More descriptive the better.
  5420. */
  5421. name: string;
  5422. /**
  5423. * A brief description of what the tool does.
  5424. */
  5425. description: string;
  5426. /**
  5427. * Schema defining the parameters accepted by the tool.
  5428. */
  5429. parameters: {
  5430. /**
  5431. * The type of the parameters object (usually 'object').
  5432. */
  5433. type: string;
  5434. /**
  5435. * List of required parameter names.
  5436. */
  5437. required?: string[];
  5438. /**
  5439. * Definitions of each parameter.
  5440. */
  5441. properties: {
  5442. [k: string]: {
  5443. /**
  5444. * The data type of the parameter.
  5445. */
  5446. type: string;
  5447. /**
  5448. * A description of the expected parameter.
  5449. */
  5450. description: string;
  5451. };
  5452. };
  5453. };
  5454. } | {
  5455. /**
  5456. * Specifies the type of tool (e.g., 'function').
  5457. */
  5458. type: string;
  5459. /**
  5460. * Details of the function tool.
  5461. */
  5462. function: {
  5463. /**
  5464. * The name of the function.
  5465. */
  5466. name: string;
  5467. /**
  5468. * A brief description of what the function does.
  5469. */
  5470. description: string;
  5471. /**
  5472. * Schema defining the parameters accepted by the function.
  5473. */
  5474. parameters: {
  5475. /**
  5476. * The type of the parameters object (usually 'object').
  5477. */
  5478. type: string;
  5479. /**
  5480. * List of required parameter names.
  5481. */
  5482. required?: string[];
  5483. /**
  5484. * Definitions of each parameter.
  5485. */
  5486. properties: {
  5487. [k: string]: {
  5488. /**
  5489. * The data type of the parameter.
  5490. */
  5491. type: string;
  5492. /**
  5493. * A description of the expected parameter.
  5494. */
  5495. description: string;
  5496. };
  5497. };
  5498. };
  5499. };
  5500. })[];
  5501. /**
  5502. * JSON schema that should be fulfilled for the response.
  5503. */
  5504. guided_json?: object;
  5505. /**
  5506. * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
  5507. */
  5508. raw?: boolean;
  5509. /**
  5510. * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
  5511. */
  5512. stream?: boolean;
  5513. /**
  5514. * The maximum number of tokens to generate in the response.
  5515. */
  5516. max_tokens?: number;
  5517. /**
  5518. * Controls the randomness of the output; higher values produce more random results.
  5519. */
  5520. temperature?: number;
  5521. /**
  5522. * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
  5523. */
  5524. top_p?: number;
  5525. /**
  5526. * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
  5527. */
  5528. top_k?: number;
  5529. /**
  5530. * Random seed for reproducibility of the generation.
  5531. */
  5532. seed?: number;
  5533. /**
  5534. * Penalty for repeated tokens; higher values discourage repetition.
  5535. */
  5536. repetition_penalty?: number;
  5537. /**
  5538. * Decreases the likelihood of the model repeating the same lines verbatim.
  5539. */
  5540. frequency_penalty?: number;
  5541. /**
  5542. * Increases the likelihood of the model introducing new topics.
  5543. */
  5544. presence_penalty?: number;
  5545. }
  5546. type Ai_Cf_Qwen_Qwq_32B_Output = {
  5547. /**
  5548. * The generated text response from the model
  5549. */
  5550. response: string;
  5551. /**
  5552. * Usage statistics for the inference request
  5553. */
  5554. usage?: {
  5555. /**
  5556. * Total number of tokens in input
  5557. */
  5558. prompt_tokens?: number;
  5559. /**
  5560. * Total number of tokens in output
  5561. */
  5562. completion_tokens?: number;
  5563. /**
  5564. * Total number of input and output tokens
  5565. */
  5566. total_tokens?: number;
  5567. };
  5568. /**
  5569. * An array of tool calls requests made during the response generation
  5570. */
  5571. tool_calls?: {
  5572. /**
  5573. * The arguments passed to be passed to the tool call request
  5574. */
  5575. arguments?: object;
  5576. /**
  5577. * The name of the tool to be called
  5578. */
  5579. name?: string;
  5580. }[];
  5581. };
  5582. declare abstract class Base_Ai_Cf_Qwen_Qwq_32B {
  5583. inputs: Ai_Cf_Qwen_Qwq_32B_Input;
  5584. postProcessedOutputs: Ai_Cf_Qwen_Qwq_32B_Output;
  5585. }
  5586. type Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Input = Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Prompt | Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Messages;
  5587. interface Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Prompt {
  5588. /**
  5589. * The input text prompt for the model to generate a response.
  5590. */
  5591. prompt: string;
  5592. /**
  5593. * JSON schema that should be fulfilled for the response.
  5594. */
  5595. guided_json?: object;
  5596. /**
  5597. * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
  5598. */
  5599. raw?: boolean;
  5600. /**
  5601. * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
  5602. */
  5603. stream?: boolean;
  5604. /**
  5605. * The maximum number of tokens to generate in the response.
  5606. */
  5607. max_tokens?: number;
  5608. /**
  5609. * Controls the randomness of the output; higher values produce more random results.
  5610. */
  5611. temperature?: number;
  5612. /**
  5613. * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
  5614. */
  5615. top_p?: number;
  5616. /**
  5617. * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
  5618. */
  5619. top_k?: number;
  5620. /**
  5621. * Random seed for reproducibility of the generation.
  5622. */
  5623. seed?: number;
  5624. /**
  5625. * Penalty for repeated tokens; higher values discourage repetition.
  5626. */
  5627. repetition_penalty?: number;
  5628. /**
  5629. * Decreases the likelihood of the model repeating the same lines verbatim.
  5630. */
  5631. frequency_penalty?: number;
  5632. /**
  5633. * Increases the likelihood of the model introducing new topics.
  5634. */
  5635. presence_penalty?: number;
  5636. }
  5637. interface Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Messages {
  5638. /**
  5639. * An array of message objects representing the conversation history.
  5640. */
  5641. messages: {
  5642. /**
  5643. * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
  5644. */
  5645. role?: string;
  5646. /**
  5647. * The tool call id. Must be supplied for tool calls for Mistral-3. If you don't know what to put here you can fall back to 000000001
  5648. */
  5649. tool_call_id?: string;
  5650. content?: string | {
  5651. /**
  5652. * Type of the content provided
  5653. */
  5654. type?: string;
  5655. text?: string;
  5656. image_url?: {
  5657. /**
  5658. * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
  5659. */
  5660. url?: string;
  5661. };
  5662. }[] | {
  5663. /**
  5664. * Type of the content provided
  5665. */
  5666. type?: string;
  5667. text?: string;
  5668. image_url?: {
  5669. /**
  5670. * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
  5671. */
  5672. url?: string;
  5673. };
  5674. };
  5675. }[];
  5676. functions?: {
  5677. name: string;
  5678. code: string;
  5679. }[];
  5680. /**
  5681. * A list of tools available for the assistant to use.
  5682. */
  5683. tools?: ({
  5684. /**
  5685. * The name of the tool. More descriptive the better.
  5686. */
  5687. name: string;
  5688. /**
  5689. * A brief description of what the tool does.
  5690. */
  5691. description: string;
  5692. /**
  5693. * Schema defining the parameters accepted by the tool.
  5694. */
  5695. parameters: {
  5696. /**
  5697. * The type of the parameters object (usually 'object').
  5698. */
  5699. type: string;
  5700. /**
  5701. * List of required parameter names.
  5702. */
  5703. required?: string[];
  5704. /**
  5705. * Definitions of each parameter.
  5706. */
  5707. properties: {
  5708. [k: string]: {
  5709. /**
  5710. * The data type of the parameter.
  5711. */
  5712. type: string;
  5713. /**
  5714. * A description of the expected parameter.
  5715. */
  5716. description: string;
  5717. };
  5718. };
  5719. };
  5720. } | {
  5721. /**
  5722. * Specifies the type of tool (e.g., 'function').
  5723. */
  5724. type: string;
  5725. /**
  5726. * Details of the function tool.
  5727. */
  5728. function: {
  5729. /**
  5730. * The name of the function.
  5731. */
  5732. name: string;
  5733. /**
  5734. * A brief description of what the function does.
  5735. */
  5736. description: string;
  5737. /**
  5738. * Schema defining the parameters accepted by the function.
  5739. */
  5740. parameters: {
  5741. /**
  5742. * The type of the parameters object (usually 'object').
  5743. */
  5744. type: string;
  5745. /**
  5746. * List of required parameter names.
  5747. */
  5748. required?: string[];
  5749. /**
  5750. * Definitions of each parameter.
  5751. */
  5752. properties: {
  5753. [k: string]: {
  5754. /**
  5755. * The data type of the parameter.
  5756. */
  5757. type: string;
  5758. /**
  5759. * A description of the expected parameter.
  5760. */
  5761. description: string;
  5762. };
  5763. };
  5764. };
  5765. };
  5766. })[];
  5767. /**
  5768. * JSON schema that should be fulfilled for the response.
  5769. */
  5770. guided_json?: object;
  5771. /**
  5772. * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
  5773. */
  5774. raw?: boolean;
  5775. /**
  5776. * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
  5777. */
  5778. stream?: boolean;
  5779. /**
  5780. * The maximum number of tokens to generate in the response.
  5781. */
  5782. max_tokens?: number;
  5783. /**
  5784. * Controls the randomness of the output; higher values produce more random results.
  5785. */
  5786. temperature?: number;
  5787. /**
  5788. * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
  5789. */
  5790. top_p?: number;
  5791. /**
  5792. * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
  5793. */
  5794. top_k?: number;
  5795. /**
  5796. * Random seed for reproducibility of the generation.
  5797. */
  5798. seed?: number;
  5799. /**
  5800. * Penalty for repeated tokens; higher values discourage repetition.
  5801. */
  5802. repetition_penalty?: number;
  5803. /**
  5804. * Decreases the likelihood of the model repeating the same lines verbatim.
  5805. */
  5806. frequency_penalty?: number;
  5807. /**
  5808. * Increases the likelihood of the model introducing new topics.
  5809. */
  5810. presence_penalty?: number;
  5811. }
  5812. type Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Output = {
  5813. /**
  5814. * The generated text response from the model
  5815. */
  5816. response: string;
  5817. /**
  5818. * Usage statistics for the inference request
  5819. */
  5820. usage?: {
  5821. /**
  5822. * Total number of tokens in input
  5823. */
  5824. prompt_tokens?: number;
  5825. /**
  5826. * Total number of tokens in output
  5827. */
  5828. completion_tokens?: number;
  5829. /**
  5830. * Total number of input and output tokens
  5831. */
  5832. total_tokens?: number;
  5833. };
  5834. /**
  5835. * An array of tool calls requests made during the response generation
  5836. */
  5837. tool_calls?: {
  5838. /**
  5839. * The arguments passed to be passed to the tool call request
  5840. */
  5841. arguments?: object;
  5842. /**
  5843. * The name of the tool to be called
  5844. */
  5845. name?: string;
  5846. }[];
  5847. };
  5848. declare abstract class Base_Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct {
  5849. inputs: Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Input;
  5850. postProcessedOutputs: Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Output;
  5851. }
  5852. type Ai_Cf_Google_Gemma_3_12B_It_Input = Ai_Cf_Google_Gemma_3_12B_It_Prompt | Ai_Cf_Google_Gemma_3_12B_It_Messages;
  5853. interface Ai_Cf_Google_Gemma_3_12B_It_Prompt {
  5854. /**
  5855. * The input text prompt for the model to generate a response.
  5856. */
  5857. prompt: string;
  5858. /**
  5859. * JSON schema that should be fulfilled for the response.
  5860. */
  5861. guided_json?: object;
  5862. /**
  5863. * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
  5864. */
  5865. raw?: boolean;
  5866. /**
  5867. * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
  5868. */
  5869. stream?: boolean;
  5870. /**
  5871. * The maximum number of tokens to generate in the response.
  5872. */
  5873. max_tokens?: number;
  5874. /**
  5875. * Controls the randomness of the output; higher values produce more random results.
  5876. */
  5877. temperature?: number;
  5878. /**
  5879. * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
  5880. */
  5881. top_p?: number;
  5882. /**
  5883. * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
  5884. */
  5885. top_k?: number;
  5886. /**
  5887. * Random seed for reproducibility of the generation.
  5888. */
  5889. seed?: number;
  5890. /**
  5891. * Penalty for repeated tokens; higher values discourage repetition.
  5892. */
  5893. repetition_penalty?: number;
  5894. /**
  5895. * Decreases the likelihood of the model repeating the same lines verbatim.
  5896. */
  5897. frequency_penalty?: number;
  5898. /**
  5899. * Increases the likelihood of the model introducing new topics.
  5900. */
  5901. presence_penalty?: number;
  5902. }
  5903. interface Ai_Cf_Google_Gemma_3_12B_It_Messages {
  5904. /**
  5905. * An array of message objects representing the conversation history.
  5906. */
  5907. messages: {
  5908. /**
  5909. * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
  5910. */
  5911. role?: string;
  5912. content?: string | {
  5913. /**
  5914. * Type of the content provided
  5915. */
  5916. type?: string;
  5917. text?: string;
  5918. image_url?: {
  5919. /**
  5920. * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
  5921. */
  5922. url?: string;
  5923. };
  5924. }[];
  5925. }[];
  5926. functions?: {
  5927. name: string;
  5928. code: string;
  5929. }[];
  5930. /**
  5931. * A list of tools available for the assistant to use.
  5932. */
  5933. tools?: ({
  5934. /**
  5935. * The name of the tool. More descriptive the better.
  5936. */
  5937. name: string;
  5938. /**
  5939. * A brief description of what the tool does.
  5940. */
  5941. description: string;
  5942. /**
  5943. * Schema defining the parameters accepted by the tool.
  5944. */
  5945. parameters: {
  5946. /**
  5947. * The type of the parameters object (usually 'object').
  5948. */
  5949. type: string;
  5950. /**
  5951. * List of required parameter names.
  5952. */
  5953. required?: string[];
  5954. /**
  5955. * Definitions of each parameter.
  5956. */
  5957. properties: {
  5958. [k: string]: {
  5959. /**
  5960. * The data type of the parameter.
  5961. */
  5962. type: string;
  5963. /**
  5964. * A description of the expected parameter.
  5965. */
  5966. description: string;
  5967. };
  5968. };
  5969. };
  5970. } | {
  5971. /**
  5972. * Specifies the type of tool (e.g., 'function').
  5973. */
  5974. type: string;
  5975. /**
  5976. * Details of the function tool.
  5977. */
  5978. function: {
  5979. /**
  5980. * The name of the function.
  5981. */
  5982. name: string;
  5983. /**
  5984. * A brief description of what the function does.
  5985. */
  5986. description: string;
  5987. /**
  5988. * Schema defining the parameters accepted by the function.
  5989. */
  5990. parameters: {
  5991. /**
  5992. * The type of the parameters object (usually 'object').
  5993. */
  5994. type: string;
  5995. /**
  5996. * List of required parameter names.
  5997. */
  5998. required?: string[];
  5999. /**
  6000. * Definitions of each parameter.
  6001. */
  6002. properties: {
  6003. [k: string]: {
  6004. /**
  6005. * The data type of the parameter.
  6006. */
  6007. type: string;
  6008. /**
  6009. * A description of the expected parameter.
  6010. */
  6011. description: string;
  6012. };
  6013. };
  6014. };
  6015. };
  6016. })[];
  6017. /**
  6018. * JSON schema that should be fulfilled for the response.
  6019. */
  6020. guided_json?: object;
  6021. /**
  6022. * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
  6023. */
  6024. raw?: boolean;
  6025. /**
  6026. * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
  6027. */
  6028. stream?: boolean;
  6029. /**
  6030. * The maximum number of tokens to generate in the response.
  6031. */
  6032. max_tokens?: number;
  6033. /**
  6034. * Controls the randomness of the output; higher values produce more random results.
  6035. */
  6036. temperature?: number;
  6037. /**
  6038. * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
  6039. */
  6040. top_p?: number;
  6041. /**
  6042. * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
  6043. */
  6044. top_k?: number;
  6045. /**
  6046. * Random seed for reproducibility of the generation.
  6047. */
  6048. seed?: number;
  6049. /**
  6050. * Penalty for repeated tokens; higher values discourage repetition.
  6051. */
  6052. repetition_penalty?: number;
  6053. /**
  6054. * Decreases the likelihood of the model repeating the same lines verbatim.
  6055. */
  6056. frequency_penalty?: number;
  6057. /**
  6058. * Increases the likelihood of the model introducing new topics.
  6059. */
  6060. presence_penalty?: number;
  6061. }
  6062. type Ai_Cf_Google_Gemma_3_12B_It_Output = {
  6063. /**
  6064. * The generated text response from the model
  6065. */
  6066. response: string;
  6067. /**
  6068. * Usage statistics for the inference request
  6069. */
  6070. usage?: {
  6071. /**
  6072. * Total number of tokens in input
  6073. */
  6074. prompt_tokens?: number;
  6075. /**
  6076. * Total number of tokens in output
  6077. */
  6078. completion_tokens?: number;
  6079. /**
  6080. * Total number of input and output tokens
  6081. */
  6082. total_tokens?: number;
  6083. };
  6084. /**
  6085. * An array of tool calls requests made during the response generation
  6086. */
  6087. tool_calls?: {
  6088. /**
  6089. * The arguments passed to be passed to the tool call request
  6090. */
  6091. arguments?: object;
  6092. /**
  6093. * The name of the tool to be called
  6094. */
  6095. name?: string;
  6096. }[];
  6097. };
  6098. declare abstract class Base_Ai_Cf_Google_Gemma_3_12B_It {
  6099. inputs: Ai_Cf_Google_Gemma_3_12B_It_Input;
  6100. postProcessedOutputs: Ai_Cf_Google_Gemma_3_12B_It_Output;
  6101. }
  6102. type Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Input = Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Prompt | Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages | Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Async_Batch;
  6103. interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Prompt {
  6104. /**
  6105. * The input text prompt for the model to generate a response.
  6106. */
  6107. prompt: string;
  6108. /**
  6109. * JSON schema that should be fulfilled for the response.
  6110. */
  6111. guided_json?: object;
  6112. response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
  6113. /**
  6114. * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
  6115. */
  6116. raw?: boolean;
  6117. /**
  6118. * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
  6119. */
  6120. stream?: boolean;
  6121. /**
  6122. * The maximum number of tokens to generate in the response.
  6123. */
  6124. max_tokens?: number;
  6125. /**
  6126. * Controls the randomness of the output; higher values produce more random results.
  6127. */
  6128. temperature?: number;
  6129. /**
  6130. * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
  6131. */
  6132. top_p?: number;
  6133. /**
  6134. * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
  6135. */
  6136. top_k?: number;
  6137. /**
  6138. * Random seed for reproducibility of the generation.
  6139. */
  6140. seed?: number;
  6141. /**
  6142. * Penalty for repeated tokens; higher values discourage repetition.
  6143. */
  6144. repetition_penalty?: number;
  6145. /**
  6146. * Decreases the likelihood of the model repeating the same lines verbatim.
  6147. */
  6148. frequency_penalty?: number;
  6149. /**
  6150. * Increases the likelihood of the model introducing new topics.
  6151. */
  6152. presence_penalty?: number;
  6153. }
  6154. interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode {
  6155. type?: "json_object" | "json_schema";
  6156. json_schema?: unknown;
  6157. }
  6158. interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages {
  6159. /**
  6160. * An array of message objects representing the conversation history.
  6161. */
  6162. messages: {
  6163. /**
  6164. * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
  6165. */
  6166. role?: string;
  6167. /**
  6168. * The tool call id. If you don't know what to put here you can fall back to 000000001
  6169. */
  6170. tool_call_id?: string;
  6171. content?: string | {
  6172. /**
  6173. * Type of the content provided
  6174. */
  6175. type?: string;
  6176. text?: string;
  6177. image_url?: {
  6178. /**
  6179. * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
  6180. */
  6181. url?: string;
  6182. };
  6183. }[] | {
  6184. /**
  6185. * Type of the content provided
  6186. */
  6187. type?: string;
  6188. text?: string;
  6189. image_url?: {
  6190. /**
  6191. * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
  6192. */
  6193. url?: string;
  6194. };
  6195. };
  6196. }[];
  6197. functions?: {
  6198. name: string;
  6199. code: string;
  6200. }[];
  6201. /**
  6202. * A list of tools available for the assistant to use.
  6203. */
  6204. tools?: ({
  6205. /**
  6206. * The name of the tool. More descriptive the better.
  6207. */
  6208. name: string;
  6209. /**
  6210. * A brief description of what the tool does.
  6211. */
  6212. description: string;
  6213. /**
  6214. * Schema defining the parameters accepted by the tool.
  6215. */
  6216. parameters: {
  6217. /**
  6218. * The type of the parameters object (usually 'object').
  6219. */
  6220. type: string;
  6221. /**
  6222. * List of required parameter names.
  6223. */
  6224. required?: string[];
  6225. /**
  6226. * Definitions of each parameter.
  6227. */
  6228. properties: {
  6229. [k: string]: {
  6230. /**
  6231. * The data type of the parameter.
  6232. */
  6233. type: string;
  6234. /**
  6235. * A description of the expected parameter.
  6236. */
  6237. description: string;
  6238. };
  6239. };
  6240. };
  6241. } | {
  6242. /**
  6243. * Specifies the type of tool (e.g., 'function').
  6244. */
  6245. type: string;
  6246. /**
  6247. * Details of the function tool.
  6248. */
  6249. function: {
  6250. /**
  6251. * The name of the function.
  6252. */
  6253. name: string;
  6254. /**
  6255. * A brief description of what the function does.
  6256. */
  6257. description: string;
  6258. /**
  6259. * Schema defining the parameters accepted by the function.
  6260. */
  6261. parameters: {
  6262. /**
  6263. * The type of the parameters object (usually 'object').
  6264. */
  6265. type: string;
  6266. /**
  6267. * List of required parameter names.
  6268. */
  6269. required?: string[];
  6270. /**
  6271. * Definitions of each parameter.
  6272. */
  6273. properties: {
  6274. [k: string]: {
  6275. /**
  6276. * The data type of the parameter.
  6277. */
  6278. type: string;
  6279. /**
  6280. * A description of the expected parameter.
  6281. */
  6282. description: string;
  6283. };
  6284. };
  6285. };
  6286. };
  6287. })[];
  6288. response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
  6289. /**
  6290. * JSON schema that should be fulfilled for the response.
  6291. */
  6292. guided_json?: object;
  6293. /**
  6294. * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
  6295. */
  6296. raw?: boolean;
  6297. /**
  6298. * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
  6299. */
  6300. stream?: boolean;
  6301. /**
  6302. * The maximum number of tokens to generate in the response.
  6303. */
  6304. max_tokens?: number;
  6305. /**
  6306. * Controls the randomness of the output; higher values produce more random results.
  6307. */
  6308. temperature?: number;
  6309. /**
  6310. * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
  6311. */
  6312. top_p?: number;
  6313. /**
  6314. * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
  6315. */
  6316. top_k?: number;
  6317. /**
  6318. * Random seed for reproducibility of the generation.
  6319. */
  6320. seed?: number;
  6321. /**
  6322. * Penalty for repeated tokens; higher values discourage repetition.
  6323. */
  6324. repetition_penalty?: number;
  6325. /**
  6326. * Decreases the likelihood of the model repeating the same lines verbatim.
  6327. */
  6328. frequency_penalty?: number;
  6329. /**
  6330. * Increases the likelihood of the model introducing new topics.
  6331. */
  6332. presence_penalty?: number;
  6333. }
  6334. interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Async_Batch {
  6335. requests: (Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Prompt_Inner | Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages_Inner)[];
  6336. }
  6337. interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Prompt_Inner {
  6338. /**
  6339. * The input text prompt for the model to generate a response.
  6340. */
  6341. prompt: string;
  6342. /**
  6343. * JSON schema that should be fulfilled for the response.
  6344. */
  6345. guided_json?: object;
  6346. response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
  6347. /**
  6348. * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
  6349. */
  6350. raw?: boolean;
  6351. /**
  6352. * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
  6353. */
  6354. stream?: boolean;
  6355. /**
  6356. * The maximum number of tokens to generate in the response.
  6357. */
  6358. max_tokens?: number;
  6359. /**
  6360. * Controls the randomness of the output; higher values produce more random results.
  6361. */
  6362. temperature?: number;
  6363. /**
  6364. * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
  6365. */
  6366. top_p?: number;
  6367. /**
  6368. * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
  6369. */
  6370. top_k?: number;
  6371. /**
  6372. * Random seed for reproducibility of the generation.
  6373. */
  6374. seed?: number;
  6375. /**
  6376. * Penalty for repeated tokens; higher values discourage repetition.
  6377. */
  6378. repetition_penalty?: number;
  6379. /**
  6380. * Decreases the likelihood of the model repeating the same lines verbatim.
  6381. */
  6382. frequency_penalty?: number;
  6383. /**
  6384. * Increases the likelihood of the model introducing new topics.
  6385. */
  6386. presence_penalty?: number;
  6387. }
  6388. interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages_Inner {
  6389. /**
  6390. * An array of message objects representing the conversation history.
  6391. */
  6392. messages: {
  6393. /**
  6394. * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
  6395. */
  6396. role?: string;
  6397. /**
  6398. * The tool call id. If you don't know what to put here you can fall back to 000000001
  6399. */
  6400. tool_call_id?: string;
  6401. content?: string | {
  6402. /**
  6403. * Type of the content provided
  6404. */
  6405. type?: string;
  6406. text?: string;
  6407. image_url?: {
  6408. /**
  6409. * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
  6410. */
  6411. url?: string;
  6412. };
  6413. }[] | {
  6414. /**
  6415. * Type of the content provided
  6416. */
  6417. type?: string;
  6418. text?: string;
  6419. image_url?: {
  6420. /**
  6421. * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
  6422. */
  6423. url?: string;
  6424. };
  6425. };
  6426. }[];
  6427. functions?: {
  6428. name: string;
  6429. code: string;
  6430. }[];
  6431. /**
  6432. * A list of tools available for the assistant to use.
  6433. */
  6434. tools?: ({
  6435. /**
  6436. * The name of the tool. More descriptive the better.
  6437. */
  6438. name: string;
  6439. /**
  6440. * A brief description of what the tool does.
  6441. */
  6442. description: string;
  6443. /**
  6444. * Schema defining the parameters accepted by the tool.
  6445. */
  6446. parameters: {
  6447. /**
  6448. * The type of the parameters object (usually 'object').
  6449. */
  6450. type: string;
  6451. /**
  6452. * List of required parameter names.
  6453. */
  6454. required?: string[];
  6455. /**
  6456. * Definitions of each parameter.
  6457. */
  6458. properties: {
  6459. [k: string]: {
  6460. /**
  6461. * The data type of the parameter.
  6462. */
  6463. type: string;
  6464. /**
  6465. * A description of the expected parameter.
  6466. */
  6467. description: string;
  6468. };
  6469. };
  6470. };
  6471. } | {
  6472. /**
  6473. * Specifies the type of tool (e.g., 'function').
  6474. */
  6475. type: string;
  6476. /**
  6477. * Details of the function tool.
  6478. */
  6479. function: {
  6480. /**
  6481. * The name of the function.
  6482. */
  6483. name: string;
  6484. /**
  6485. * A brief description of what the function does.
  6486. */
  6487. description: string;
  6488. /**
  6489. * Schema defining the parameters accepted by the function.
  6490. */
  6491. parameters: {
  6492. /**
  6493. * The type of the parameters object (usually 'object').
  6494. */
  6495. type: string;
  6496. /**
  6497. * List of required parameter names.
  6498. */
  6499. required?: string[];
  6500. /**
  6501. * Definitions of each parameter.
  6502. */
  6503. properties: {
  6504. [k: string]: {
  6505. /**
  6506. * The data type of the parameter.
  6507. */
  6508. type: string;
  6509. /**
  6510. * A description of the expected parameter.
  6511. */
  6512. description: string;
  6513. };
  6514. };
  6515. };
  6516. };
  6517. })[];
  6518. response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
  6519. /**
  6520. * JSON schema that should be fulfilled for the response.
  6521. */
  6522. guided_json?: object;
  6523. /**
  6524. * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
  6525. */
  6526. raw?: boolean;
  6527. /**
  6528. * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
  6529. */
  6530. stream?: boolean;
  6531. /**
  6532. * The maximum number of tokens to generate in the response.
  6533. */
  6534. max_tokens?: number;
  6535. /**
  6536. * Controls the randomness of the output; higher values produce more random results.
  6537. */
  6538. temperature?: number;
  6539. /**
  6540. * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
  6541. */
  6542. top_p?: number;
  6543. /**
  6544. * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
  6545. */
  6546. top_k?: number;
  6547. /**
  6548. * Random seed for reproducibility of the generation.
  6549. */
  6550. seed?: number;
  6551. /**
  6552. * Penalty for repeated tokens; higher values discourage repetition.
  6553. */
  6554. repetition_penalty?: number;
  6555. /**
  6556. * Decreases the likelihood of the model repeating the same lines verbatim.
  6557. */
  6558. frequency_penalty?: number;
  6559. /**
  6560. * Increases the likelihood of the model introducing new topics.
  6561. */
  6562. presence_penalty?: number;
  6563. }
  6564. type Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Output = {
  6565. /**
  6566. * The generated text response from the model
  6567. */
  6568. response: string;
  6569. /**
  6570. * Usage statistics for the inference request
  6571. */
  6572. usage?: {
  6573. /**
  6574. * Total number of tokens in input
  6575. */
  6576. prompt_tokens?: number;
  6577. /**
  6578. * Total number of tokens in output
  6579. */
  6580. completion_tokens?: number;
  6581. /**
  6582. * Total number of input and output tokens
  6583. */
  6584. total_tokens?: number;
  6585. };
  6586. /**
  6587. * An array of tool calls requests made during the response generation
  6588. */
  6589. tool_calls?: {
  6590. /**
  6591. * The tool call id.
  6592. */
  6593. id?: string;
  6594. /**
  6595. * Specifies the type of tool (e.g., 'function').
  6596. */
  6597. type?: string;
  6598. /**
  6599. * Details of the function tool.
  6600. */
  6601. function?: {
  6602. /**
  6603. * The name of the tool to be called
  6604. */
  6605. name?: string;
  6606. /**
  6607. * The arguments passed to be passed to the tool call request
  6608. */
  6609. arguments?: object;
  6610. };
  6611. }[];
  6612. };
  6613. declare abstract class Base_Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct {
  6614. inputs: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Input;
  6615. postProcessedOutputs: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Output;
  6616. }
  6617. type Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Input = Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Prompt | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Async_Batch;
  6618. interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Prompt {
  6619. /**
  6620. * The input text prompt for the model to generate a response.
  6621. */
  6622. prompt: string;
  6623. /**
  6624. * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
  6625. */
  6626. lora?: string;
  6627. response_format?: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode;
  6628. /**
  6629. * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
  6630. */
  6631. raw?: boolean;
  6632. /**
  6633. * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
  6634. */
  6635. stream?: boolean;
  6636. /**
  6637. * The maximum number of tokens to generate in the response.
  6638. */
  6639. max_tokens?: number;
  6640. /**
  6641. * Controls the randomness of the output; higher values produce more random results.
  6642. */
  6643. temperature?: number;
  6644. /**
  6645. * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
  6646. */
  6647. top_p?: number;
  6648. /**
  6649. * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
  6650. */
  6651. top_k?: number;
  6652. /**
  6653. * Random seed for reproducibility of the generation.
  6654. */
  6655. seed?: number;
  6656. /**
  6657. * Penalty for repeated tokens; higher values discourage repetition.
  6658. */
  6659. repetition_penalty?: number;
  6660. /**
  6661. * Decreases the likelihood of the model repeating the same lines verbatim.
  6662. */
  6663. frequency_penalty?: number;
  6664. /**
  6665. * Increases the likelihood of the model introducing new topics.
  6666. */
  6667. presence_penalty?: number;
  6668. }
  6669. interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode {
  6670. type?: "json_object" | "json_schema";
  6671. json_schema?: unknown;
  6672. }
  6673. interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages {
  6674. /**
  6675. * An array of message objects representing the conversation history.
  6676. */
  6677. messages: {
  6678. /**
  6679. * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
  6680. */
  6681. role: string;
  6682. /**
  6683. * The content of the message as a string.
  6684. */
  6685. content: string;
  6686. }[];
  6687. functions?: {
  6688. name: string;
  6689. code: string;
  6690. }[];
  6691. /**
  6692. * A list of tools available for the assistant to use.
  6693. */
  6694. tools?: ({
  6695. /**
  6696. * The name of the tool. More descriptive the better.
  6697. */
  6698. name: string;
  6699. /**
  6700. * A brief description of what the tool does.
  6701. */
  6702. description: string;
  6703. /**
  6704. * Schema defining the parameters accepted by the tool.
  6705. */
  6706. parameters: {
  6707. /**
  6708. * The type of the parameters object (usually 'object').
  6709. */
  6710. type: string;
  6711. /**
  6712. * List of required parameter names.
  6713. */
  6714. required?: string[];
  6715. /**
  6716. * Definitions of each parameter.
  6717. */
  6718. properties: {
  6719. [k: string]: {
  6720. /**
  6721. * The data type of the parameter.
  6722. */
  6723. type: string;
  6724. /**
  6725. * A description of the expected parameter.
  6726. */
  6727. description: string;
  6728. };
  6729. };
  6730. };
  6731. } | {
  6732. /**
  6733. * Specifies the type of tool (e.g., 'function').
  6734. */
  6735. type: string;
  6736. /**
  6737. * Details of the function tool.
  6738. */
  6739. function: {
  6740. /**
  6741. * The name of the function.
  6742. */
  6743. name: string;
  6744. /**
  6745. * A brief description of what the function does.
  6746. */
  6747. description: string;
  6748. /**
  6749. * Schema defining the parameters accepted by the function.
  6750. */
  6751. parameters: {
  6752. /**
  6753. * The type of the parameters object (usually 'object').
  6754. */
  6755. type: string;
  6756. /**
  6757. * List of required parameter names.
  6758. */
  6759. required?: string[];
  6760. /**
  6761. * Definitions of each parameter.
  6762. */
  6763. properties: {
  6764. [k: string]: {
  6765. /**
  6766. * The data type of the parameter.
  6767. */
  6768. type: string;
  6769. /**
  6770. * A description of the expected parameter.
  6771. */
  6772. description: string;
  6773. };
  6774. };
  6775. };
  6776. };
  6777. })[];
  6778. response_format?: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_1;
  6779. /**
  6780. * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
  6781. */
  6782. raw?: boolean;
  6783. /**
  6784. * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
  6785. */
  6786. stream?: boolean;
  6787. /**
  6788. * The maximum number of tokens to generate in the response.
  6789. */
  6790. max_tokens?: number;
  6791. /**
  6792. * Controls the randomness of the output; higher values produce more random results.
  6793. */
  6794. temperature?: number;
  6795. /**
  6796. * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
  6797. */
  6798. top_p?: number;
  6799. /**
  6800. * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
  6801. */
  6802. top_k?: number;
  6803. /**
  6804. * Random seed for reproducibility of the generation.
  6805. */
  6806. seed?: number;
  6807. /**
  6808. * Penalty for repeated tokens; higher values discourage repetition.
  6809. */
  6810. repetition_penalty?: number;
  6811. /**
  6812. * Decreases the likelihood of the model repeating the same lines verbatim.
  6813. */
  6814. frequency_penalty?: number;
  6815. /**
  6816. * Increases the likelihood of the model introducing new topics.
  6817. */
  6818. presence_penalty?: number;
  6819. }
  6820. interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_1 {
  6821. type?: "json_object" | "json_schema";
  6822. json_schema?: unknown;
  6823. }
  6824. interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Async_Batch {
  6825. requests: (Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Prompt_1 | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages_1)[];
  6826. }
  6827. interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Prompt_1 {
  6828. /**
  6829. * The input text prompt for the model to generate a response.
  6830. */
  6831. prompt: string;
  6832. /**
  6833. * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
  6834. */
  6835. lora?: string;
  6836. response_format?: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_2;
  6837. /**
  6838. * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
  6839. */
  6840. raw?: boolean;
  6841. /**
  6842. * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
  6843. */
  6844. stream?: boolean;
  6845. /**
  6846. * The maximum number of tokens to generate in the response.
  6847. */
  6848. max_tokens?: number;
  6849. /**
  6850. * Controls the randomness of the output; higher values produce more random results.
  6851. */
  6852. temperature?: number;
  6853. /**
  6854. * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
  6855. */
  6856. top_p?: number;
  6857. /**
  6858. * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
  6859. */
  6860. top_k?: number;
  6861. /**
  6862. * Random seed for reproducibility of the generation.
  6863. */
  6864. seed?: number;
  6865. /**
  6866. * Penalty for repeated tokens; higher values discourage repetition.
  6867. */
  6868. repetition_penalty?: number;
  6869. /**
  6870. * Decreases the likelihood of the model repeating the same lines verbatim.
  6871. */
  6872. frequency_penalty?: number;
  6873. /**
  6874. * Increases the likelihood of the model introducing new topics.
  6875. */
  6876. presence_penalty?: number;
  6877. }
  6878. interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_2 {
  6879. type?: "json_object" | "json_schema";
  6880. json_schema?: unknown;
  6881. }
  6882. interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages_1 {
  6883. /**
  6884. * An array of message objects representing the conversation history.
  6885. */
  6886. messages: {
  6887. /**
  6888. * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
  6889. */
  6890. role: string;
  6891. /**
  6892. * The content of the message as a string.
  6893. */
  6894. content: string;
  6895. }[];
  6896. functions?: {
  6897. name: string;
  6898. code: string;
  6899. }[];
  6900. /**
  6901. * A list of tools available for the assistant to use.
  6902. */
  6903. tools?: ({
  6904. /**
  6905. * The name of the tool. More descriptive the better.
  6906. */
  6907. name: string;
  6908. /**
  6909. * A brief description of what the tool does.
  6910. */
  6911. description: string;
  6912. /**
  6913. * Schema defining the parameters accepted by the tool.
  6914. */
  6915. parameters: {
  6916. /**
  6917. * The type of the parameters object (usually 'object').
  6918. */
  6919. type: string;
  6920. /**
  6921. * List of required parameter names.
  6922. */
  6923. required?: string[];
  6924. /**
  6925. * Definitions of each parameter.
  6926. */
  6927. properties: {
  6928. [k: string]: {
  6929. /**
  6930. * The data type of the parameter.
  6931. */
  6932. type: string;
  6933. /**
  6934. * A description of the expected parameter.
  6935. */
  6936. description: string;
  6937. };
  6938. };
  6939. };
  6940. } | {
  6941. /**
  6942. * Specifies the type of tool (e.g., 'function').
  6943. */
  6944. type: string;
  6945. /**
  6946. * Details of the function tool.
  6947. */
  6948. function: {
  6949. /**
  6950. * The name of the function.
  6951. */
  6952. name: string;
  6953. /**
  6954. * A brief description of what the function does.
  6955. */
  6956. description: string;
  6957. /**
  6958. * Schema defining the parameters accepted by the function.
  6959. */
  6960. parameters: {
  6961. /**
  6962. * The type of the parameters object (usually 'object').
  6963. */
  6964. type: string;
  6965. /**
  6966. * List of required parameter names.
  6967. */
  6968. required?: string[];
  6969. /**
  6970. * Definitions of each parameter.
  6971. */
  6972. properties: {
  6973. [k: string]: {
  6974. /**
  6975. * The data type of the parameter.
  6976. */
  6977. type: string;
  6978. /**
  6979. * A description of the expected parameter.
  6980. */
  6981. description: string;
  6982. };
  6983. };
  6984. };
  6985. };
  6986. })[];
  6987. response_format?: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_3;
  6988. /**
  6989. * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
  6990. */
  6991. raw?: boolean;
  6992. /**
  6993. * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
  6994. */
  6995. stream?: boolean;
  6996. /**
  6997. * The maximum number of tokens to generate in the response.
  6998. */
  6999. max_tokens?: number;
  7000. /**
  7001. * Controls the randomness of the output; higher values produce more random results.
  7002. */
  7003. temperature?: number;
  7004. /**
  7005. * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
  7006. */
  7007. top_p?: number;
  7008. /**
  7009. * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
  7010. */
  7011. top_k?: number;
  7012. /**
  7013. * Random seed for reproducibility of the generation.
  7014. */
  7015. seed?: number;
  7016. /**
  7017. * Penalty for repeated tokens; higher values discourage repetition.
  7018. */
  7019. repetition_penalty?: number;
  7020. /**
  7021. * Decreases the likelihood of the model repeating the same lines verbatim.
  7022. */
  7023. frequency_penalty?: number;
  7024. /**
  7025. * Increases the likelihood of the model introducing new topics.
  7026. */
  7027. presence_penalty?: number;
  7028. }
  7029. interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_3 {
  7030. type?: "json_object" | "json_schema";
  7031. json_schema?: unknown;
  7032. }
  7033. type Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Output = Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Chat_Completion_Response | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Text_Completion_Response | string | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_AsyncResponse;
  7034. interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Chat_Completion_Response {
  7035. /**
  7036. * Unique identifier for the completion
  7037. */
  7038. id?: string;
  7039. /**
  7040. * Object type identifier
  7041. */
  7042. object?: "chat.completion";
  7043. /**
  7044. * Unix timestamp of when the completion was created
  7045. */
  7046. created?: number;
  7047. /**
  7048. * Model used for the completion
  7049. */
  7050. model?: string;
  7051. /**
  7052. * List of completion choices
  7053. */
  7054. choices?: {
  7055. /**
  7056. * Index of the choice in the list
  7057. */
  7058. index?: number;
  7059. /**
  7060. * The message generated by the model
  7061. */
  7062. message?: {
  7063. /**
  7064. * Role of the message author
  7065. */
  7066. role: string;
  7067. /**
  7068. * The content of the message
  7069. */
  7070. content: string;
  7071. /**
  7072. * Internal reasoning content (if available)
  7073. */
  7074. reasoning_content?: string;
  7075. /**
  7076. * Tool calls made by the assistant
  7077. */
  7078. tool_calls?: {
  7079. /**
  7080. * Unique identifier for the tool call
  7081. */
  7082. id: string;
  7083. /**
  7084. * Type of tool call
  7085. */
  7086. type: "function";
  7087. function: {
  7088. /**
  7089. * Name of the function to call
  7090. */
  7091. name: string;
  7092. /**
  7093. * JSON string of arguments for the function
  7094. */
  7095. arguments: string;
  7096. };
  7097. }[];
  7098. };
  7099. /**
  7100. * Reason why the model stopped generating
  7101. */
  7102. finish_reason?: string;
  7103. /**
  7104. * Stop reason (may be null)
  7105. */
  7106. stop_reason?: string | null;
  7107. /**
  7108. * Log probabilities (if requested)
  7109. */
  7110. logprobs?: {} | null;
  7111. }[];
  7112. /**
  7113. * Usage statistics for the inference request
  7114. */
  7115. usage?: {
  7116. /**
  7117. * Total number of tokens in input
  7118. */
  7119. prompt_tokens?: number;
  7120. /**
  7121. * Total number of tokens in output
  7122. */
  7123. completion_tokens?: number;
  7124. /**
  7125. * Total number of input and output tokens
  7126. */
  7127. total_tokens?: number;
  7128. };
  7129. /**
  7130. * Log probabilities for the prompt (if requested)
  7131. */
  7132. prompt_logprobs?: {} | null;
  7133. }
  7134. interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Text_Completion_Response {
  7135. /**
  7136. * Unique identifier for the completion
  7137. */
  7138. id?: string;
  7139. /**
  7140. * Object type identifier
  7141. */
  7142. object?: "text_completion";
  7143. /**
  7144. * Unix timestamp of when the completion was created
  7145. */
  7146. created?: number;
  7147. /**
  7148. * Model used for the completion
  7149. */
  7150. model?: string;
  7151. /**
  7152. * List of completion choices
  7153. */
  7154. choices?: {
  7155. /**
  7156. * Index of the choice in the list
  7157. */
  7158. index: number;
  7159. /**
  7160. * The generated text completion
  7161. */
  7162. text: string;
  7163. /**
  7164. * Reason why the model stopped generating
  7165. */
  7166. finish_reason: string;
  7167. /**
  7168. * Stop reason (may be null)
  7169. */
  7170. stop_reason?: string | null;
  7171. /**
  7172. * Log probabilities (if requested)
  7173. */
  7174. logprobs?: {} | null;
  7175. /**
  7176. * Log probabilities for the prompt (if requested)
  7177. */
  7178. prompt_logprobs?: {} | null;
  7179. }[];
  7180. /**
  7181. * Usage statistics for the inference request
  7182. */
  7183. usage?: {
  7184. /**
  7185. * Total number of tokens in input
  7186. */
  7187. prompt_tokens?: number;
  7188. /**
  7189. * Total number of tokens in output
  7190. */
  7191. completion_tokens?: number;
  7192. /**
  7193. * Total number of input and output tokens
  7194. */
  7195. total_tokens?: number;
  7196. };
  7197. }
  7198. interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_AsyncResponse {
  7199. /**
  7200. * The async request id that can be used to obtain the results.
  7201. */
  7202. request_id?: string;
  7203. }
  7204. declare abstract class Base_Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8 {
  7205. inputs: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Input;
  7206. postProcessedOutputs: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Output;
  7207. }
  7208. interface Ai_Cf_Deepgram_Nova_3_Input {
  7209. audio: {
  7210. body: object;
  7211. contentType: string;
  7212. };
  7213. /**
  7214. * Sets how the model will interpret strings submitted to the custom_topic param. When strict, the model will only return topics submitted using the custom_topic param. When extended, the model will return its own detected topics in addition to those submitted using the custom_topic param.
  7215. */
  7216. custom_topic_mode?: "extended" | "strict";
  7217. /**
  7218. * Custom topics you want the model to detect within your input audio or text if present Submit up to 100
  7219. */
  7220. custom_topic?: string;
  7221. /**
  7222. * Sets how the model will interpret intents submitted to the custom_intent param. When strict, the model will only return intents submitted using the custom_intent param. When extended, the model will return its own detected intents in addition those submitted using the custom_intents param
  7223. */
  7224. custom_intent_mode?: "extended" | "strict";
  7225. /**
  7226. * Custom intents you want the model to detect within your input audio if present
  7227. */
  7228. custom_intent?: string;
  7229. /**
  7230. * Identifies and extracts key entities from content in submitted audio
  7231. */
  7232. detect_entities?: boolean;
  7233. /**
  7234. * Identifies the dominant language spoken in submitted audio
  7235. */
  7236. detect_language?: boolean;
  7237. /**
  7238. * Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0
  7239. */
  7240. diarize?: boolean;
  7241. /**
  7242. * Identify and extract key entities from content in submitted audio
  7243. */
  7244. dictation?: boolean;
  7245. /**
  7246. * Specify the expected encoding of your submitted audio
  7247. */
  7248. encoding?: "linear16" | "flac" | "mulaw" | "amr-nb" | "amr-wb" | "opus" | "speex" | "g729";
  7249. /**
  7250. * Arbitrary key-value pairs that are attached to the API response for usage in downstream processing
  7251. */
  7252. extra?: string;
  7253. /**
  7254. * Filler Words can help transcribe interruptions in your audio, like 'uh' and 'um'
  7255. */
  7256. filler_words?: boolean;
  7257. /**
  7258. * Key term prompting can boost or suppress specialized terminology and brands.
  7259. */
  7260. keyterm?: string;
  7261. /**
  7262. * Keywords can boost or suppress specialized terminology and brands.
  7263. */
  7264. keywords?: string;
  7265. /**
  7266. * The BCP-47 language tag that hints at the primary spoken language. Depending on the Model and API endpoint you choose only certain languages are available.
  7267. */
  7268. language?: string;
  7269. /**
  7270. * Spoken measurements will be converted to their corresponding abbreviations.
  7271. */
  7272. measurements?: boolean;
  7273. /**
  7274. * Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip.
  7275. */
  7276. mip_opt_out?: boolean;
  7277. /**
  7278. * Mode of operation for the model representing broad area of topic that will be talked about in the supplied audio
  7279. */
  7280. mode?: "general" | "medical" | "finance";
  7281. /**
  7282. * Transcribe each audio channel independently.
  7283. */
  7284. multichannel?: boolean;
  7285. /**
  7286. * Numerals converts numbers from written format to numerical format.
  7287. */
  7288. numerals?: boolean;
  7289. /**
  7290. * Splits audio into paragraphs to improve transcript readability.
  7291. */
  7292. paragraphs?: boolean;
  7293. /**
  7294. * Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely.
  7295. */
  7296. profanity_filter?: boolean;
  7297. /**
  7298. * Add punctuation and capitalization to the transcript.
  7299. */
  7300. punctuate?: boolean;
  7301. /**
  7302. * Redaction removes sensitive information from your transcripts.
  7303. */
  7304. redact?: string;
  7305. /**
  7306. * Search for terms or phrases in submitted audio and replaces them.
  7307. */
  7308. replace?: string;
  7309. /**
  7310. * Search for terms or phrases in submitted audio.
  7311. */
  7312. search?: string;
  7313. /**
  7314. * Recognizes the sentiment throughout a transcript or text.
  7315. */
  7316. sentiment?: boolean;
  7317. /**
  7318. * Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability.
  7319. */
  7320. smart_format?: boolean;
  7321. /**
  7322. * Detect topics throughout a transcript or text.
  7323. */
  7324. topics?: boolean;
  7325. /**
  7326. * Segments speech into meaningful semantic units.
  7327. */
  7328. utterances?: boolean;
  7329. /**
  7330. * Seconds to wait before detecting a pause between words in submitted audio.
  7331. */
  7332. utt_split?: number;
  7333. /**
  7334. * The number of channels in the submitted audio
  7335. */
  7336. channels?: number;
  7337. /**
  7338. * Specifies whether the streaming endpoint should provide ongoing transcription updates as more audio is received. When set to true, the endpoint sends continuous updates, meaning transcription results may evolve over time. Note: Supported only for webosockets.
  7339. */
  7340. interim_results?: boolean;
  7341. /**
  7342. * Indicates how long model will wait to detect whether a speaker has finished speaking or pauses for a significant period of time. When set to a value, the streaming endpoint immediately finalizes the transcription for the processed time range and returns the transcript with a speech_final parameter set to true. Can also be set to false to disable endpointing
  7343. */
  7344. endpointing?: string;
  7345. /**
  7346. * Indicates that speech has started. You'll begin receiving Speech Started messages upon speech starting. Note: Supported only for webosockets.
  7347. */
  7348. vad_events?: boolean;
  7349. /**
  7350. * Indicates how long model will wait to send an UtteranceEnd message after a word has been transcribed. Use with interim_results. Note: Supported only for webosockets.
  7351. */
  7352. utterance_end_ms?: boolean;
  7353. }
  7354. interface Ai_Cf_Deepgram_Nova_3_Output {
  7355. results?: {
  7356. channels?: {
  7357. alternatives?: {
  7358. confidence?: number;
  7359. transcript?: string;
  7360. words?: {
  7361. confidence?: number;
  7362. end?: number;
  7363. start?: number;
  7364. word?: string;
  7365. }[];
  7366. }[];
  7367. }[];
  7368. summary?: {
  7369. result?: string;
  7370. short?: string;
  7371. };
  7372. sentiments?: {
  7373. segments?: {
  7374. text?: string;
  7375. start_word?: number;
  7376. end_word?: number;
  7377. sentiment?: string;
  7378. sentiment_score?: number;
  7379. }[];
  7380. average?: {
  7381. sentiment?: string;
  7382. sentiment_score?: number;
  7383. };
  7384. };
  7385. };
  7386. }
  7387. declare abstract class Base_Ai_Cf_Deepgram_Nova_3 {
  7388. inputs: Ai_Cf_Deepgram_Nova_3_Input;
  7389. postProcessedOutputs: Ai_Cf_Deepgram_Nova_3_Output;
  7390. }
  7391. interface Ai_Cf_Qwen_Qwen3_Embedding_0_6B_Input {
  7392. queries?: string | string[];
  7393. /**
  7394. * Optional instruction for the task
  7395. */
  7396. instruction?: string;
  7397. documents?: string | string[];
  7398. text?: string | string[];
  7399. }
  7400. interface Ai_Cf_Qwen_Qwen3_Embedding_0_6B_Output {
  7401. data?: number[][];
  7402. shape?: number[];
  7403. }
  7404. declare abstract class Base_Ai_Cf_Qwen_Qwen3_Embedding_0_6B {
  7405. inputs: Ai_Cf_Qwen_Qwen3_Embedding_0_6B_Input;
  7406. postProcessedOutputs: Ai_Cf_Qwen_Qwen3_Embedding_0_6B_Output;
  7407. }
  7408. type Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Input = {
  7409. /**
  7410. * readable stream with audio data and content-type specified for that data
  7411. */
  7412. audio: {
  7413. body: object;
  7414. contentType: string;
  7415. };
  7416. /**
  7417. * type of data PCM data that's sent to the inference server as raw array
  7418. */
  7419. dtype?: "uint8" | "float32" | "float64";
  7420. } | {
  7421. /**
  7422. * base64 encoded audio data
  7423. */
  7424. audio: string;
  7425. /**
  7426. * type of data PCM data that's sent to the inference server as raw array
  7427. */
  7428. dtype?: "uint8" | "float32" | "float64";
  7429. };
  7430. interface Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Output {
  7431. /**
  7432. * if true, end-of-turn was detected
  7433. */
  7434. is_complete?: boolean;
  7435. /**
  7436. * probability of the end-of-turn detection
  7437. */
  7438. probability?: number;
  7439. }
  7440. declare abstract class Base_Ai_Cf_Pipecat_Ai_Smart_Turn_V2 {
  7441. inputs: Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Input;
  7442. postProcessedOutputs: Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Output;
  7443. }
  7444. declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_120B {
  7445. inputs: ResponsesInput;
  7446. postProcessedOutputs: ResponsesOutput;
  7447. }
  7448. declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_20B {
  7449. inputs: ResponsesInput;
  7450. postProcessedOutputs: ResponsesOutput;
  7451. }
  7452. interface Ai_Cf_Leonardo_Phoenix_1_0_Input {
  7453. /**
  7454. * A text description of the image you want to generate.
  7455. */
  7456. prompt: string;
  7457. /**
  7458. * Controls how closely the generated image should adhere to the prompt; higher values make the image more aligned with the prompt
  7459. */
  7460. guidance?: number;
  7461. /**
  7462. * Random seed for reproducibility of the image generation
  7463. */
  7464. seed?: number;
  7465. /**
  7466. * The height of the generated image in pixels
  7467. */
  7468. height?: number;
  7469. /**
  7470. * The width of the generated image in pixels
  7471. */
  7472. width?: number;
  7473. /**
  7474. * The number of diffusion steps; higher values can improve quality but take longer
  7475. */
  7476. num_steps?: number;
  7477. /**
  7478. * Specify what to exclude from the generated images
  7479. */
  7480. negative_prompt?: string;
  7481. }
  7482. /**
  7483. * The generated image in JPEG format
  7484. */
  7485. type Ai_Cf_Leonardo_Phoenix_1_0_Output = string;
  7486. declare abstract class Base_Ai_Cf_Leonardo_Phoenix_1_0 {
  7487. inputs: Ai_Cf_Leonardo_Phoenix_1_0_Input;
  7488. postProcessedOutputs: Ai_Cf_Leonardo_Phoenix_1_0_Output;
  7489. }
  7490. interface Ai_Cf_Leonardo_Lucid_Origin_Input {
  7491. /**
  7492. * A text description of the image you want to generate.
  7493. */
  7494. prompt: string;
  7495. /**
  7496. * Controls how closely the generated image should adhere to the prompt; higher values make the image more aligned with the prompt
  7497. */
  7498. guidance?: number;
  7499. /**
  7500. * Random seed for reproducibility of the image generation
  7501. */
  7502. seed?: number;
  7503. /**
  7504. * The height of the generated image in pixels
  7505. */
  7506. height?: number;
  7507. /**
  7508. * The width of the generated image in pixels
  7509. */
  7510. width?: number;
  7511. /**
  7512. * The number of diffusion steps; higher values can improve quality but take longer
  7513. */
  7514. num_steps?: number;
  7515. /**
  7516. * The number of diffusion steps; higher values can improve quality but take longer
  7517. */
  7518. steps?: number;
  7519. }
  7520. interface Ai_Cf_Leonardo_Lucid_Origin_Output {
  7521. /**
  7522. * The generated image in Base64 format.
  7523. */
  7524. image?: string;
  7525. }
  7526. declare abstract class Base_Ai_Cf_Leonardo_Lucid_Origin {
  7527. inputs: Ai_Cf_Leonardo_Lucid_Origin_Input;
  7528. postProcessedOutputs: Ai_Cf_Leonardo_Lucid_Origin_Output;
  7529. }
  7530. interface Ai_Cf_Deepgram_Aura_1_Input {
  7531. /**
  7532. * Speaker used to produce the audio.
  7533. */
  7534. speaker?: "angus" | "asteria" | "arcas" | "orion" | "orpheus" | "athena" | "luna" | "zeus" | "perseus" | "helios" | "hera" | "stella";
  7535. /**
  7536. * Encoding of the output audio.
  7537. */
  7538. encoding?: "linear16" | "flac" | "mulaw" | "alaw" | "mp3" | "opus" | "aac";
  7539. /**
  7540. * Container specifies the file format wrapper for the output audio. The available options depend on the encoding type..
  7541. */
  7542. container?: "none" | "wav" | "ogg";
  7543. /**
  7544. * The text content to be converted to speech
  7545. */
  7546. text: string;
  7547. /**
  7548. * Sample Rate specifies the sample rate for the output audio. Based on the encoding, different sample rates are supported. For some encodings, the sample rate is not configurable
  7549. */
  7550. sample_rate?: number;
  7551. /**
  7552. * The bitrate of the audio in bits per second. Choose from predefined ranges or specific values based on the encoding type.
  7553. */
  7554. bit_rate?: number;
  7555. }
  7556. /**
  7557. * The generated audio in MP3 format
  7558. */
  7559. type Ai_Cf_Deepgram_Aura_1_Output = string;
  7560. declare abstract class Base_Ai_Cf_Deepgram_Aura_1 {
  7561. inputs: Ai_Cf_Deepgram_Aura_1_Input;
  7562. postProcessedOutputs: Ai_Cf_Deepgram_Aura_1_Output;
  7563. }
  7564. interface Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Input {
  7565. /**
  7566. * Input text to translate. Can be a single string or a list of strings.
  7567. */
  7568. text: string | string[];
  7569. /**
  7570. * Target language to translate to
  7571. */
  7572. target_language: "asm_Beng" | "awa_Deva" | "ben_Beng" | "bho_Deva" | "brx_Deva" | "doi_Deva" | "eng_Latn" | "gom_Deva" | "gon_Deva" | "guj_Gujr" | "hin_Deva" | "hne_Deva" | "kan_Knda" | "kas_Arab" | "kas_Deva" | "kha_Latn" | "lus_Latn" | "mag_Deva" | "mai_Deva" | "mal_Mlym" | "mar_Deva" | "mni_Beng" | "mni_Mtei" | "npi_Deva" | "ory_Orya" | "pan_Guru" | "san_Deva" | "sat_Olck" | "snd_Arab" | "snd_Deva" | "tam_Taml" | "tel_Telu" | "urd_Arab" | "unr_Deva";
  7573. }
  7574. interface Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Output {
  7575. /**
  7576. * Translated texts
  7577. */
  7578. translations: string[];
  7579. }
  7580. declare abstract class Base_Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B {
  7581. inputs: Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Input;
  7582. postProcessedOutputs: Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Output;
  7583. }
  7584. type Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Input = Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Prompt | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Async_Batch;
  7585. interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Prompt {
  7586. /**
  7587. * The input text prompt for the model to generate a response.
  7588. */
  7589. prompt: string;
  7590. /**
  7591. * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
  7592. */
  7593. lora?: string;
  7594. response_format?: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode;
  7595. /**
  7596. * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
  7597. */
  7598. raw?: boolean;
  7599. /**
  7600. * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
  7601. */
  7602. stream?: boolean;
  7603. /**
  7604. * The maximum number of tokens to generate in the response.
  7605. */
  7606. max_tokens?: number;
  7607. /**
  7608. * Controls the randomness of the output; higher values produce more random results.
  7609. */
  7610. temperature?: number;
  7611. /**
  7612. * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
  7613. */
  7614. top_p?: number;
  7615. /**
  7616. * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
  7617. */
  7618. top_k?: number;
  7619. /**
  7620. * Random seed for reproducibility of the generation.
  7621. */
  7622. seed?: number;
  7623. /**
  7624. * Penalty for repeated tokens; higher values discourage repetition.
  7625. */
  7626. repetition_penalty?: number;
  7627. /**
  7628. * Decreases the likelihood of the model repeating the same lines verbatim.
  7629. */
  7630. frequency_penalty?: number;
  7631. /**
  7632. * Increases the likelihood of the model introducing new topics.
  7633. */
  7634. presence_penalty?: number;
  7635. }
  7636. interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode {
  7637. type?: "json_object" | "json_schema";
  7638. json_schema?: unknown;
  7639. }
  7640. interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages {
  7641. /**
  7642. * An array of message objects representing the conversation history.
  7643. */
  7644. messages: {
  7645. /**
  7646. * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
  7647. */
  7648. role: string;
  7649. /**
  7650. * The content of the message as a string.
  7651. */
  7652. content: string;
  7653. }[];
  7654. functions?: {
  7655. name: string;
  7656. code: string;
  7657. }[];
  7658. /**
  7659. * A list of tools available for the assistant to use.
  7660. */
  7661. tools?: ({
  7662. /**
  7663. * The name of the tool. More descriptive the better.
  7664. */
  7665. name: string;
  7666. /**
  7667. * A brief description of what the tool does.
  7668. */
  7669. description: string;
  7670. /**
  7671. * Schema defining the parameters accepted by the tool.
  7672. */
  7673. parameters: {
  7674. /**
  7675. * The type of the parameters object (usually 'object').
  7676. */
  7677. type: string;
  7678. /**
  7679. * List of required parameter names.
  7680. */
  7681. required?: string[];
  7682. /**
  7683. * Definitions of each parameter.
  7684. */
  7685. properties: {
  7686. [k: string]: {
  7687. /**
  7688. * The data type of the parameter.
  7689. */
  7690. type: string;
  7691. /**
  7692. * A description of the expected parameter.
  7693. */
  7694. description: string;
  7695. };
  7696. };
  7697. };
  7698. } | {
  7699. /**
  7700. * Specifies the type of tool (e.g., 'function').
  7701. */
  7702. type: string;
  7703. /**
  7704. * Details of the function tool.
  7705. */
  7706. function: {
  7707. /**
  7708. * The name of the function.
  7709. */
  7710. name: string;
  7711. /**
  7712. * A brief description of what the function does.
  7713. */
  7714. description: string;
  7715. /**
  7716. * Schema defining the parameters accepted by the function.
  7717. */
  7718. parameters: {
  7719. /**
  7720. * The type of the parameters object (usually 'object').
  7721. */
  7722. type: string;
  7723. /**
  7724. * List of required parameter names.
  7725. */
  7726. required?: string[];
  7727. /**
  7728. * Definitions of each parameter.
  7729. */
  7730. properties: {
  7731. [k: string]: {
  7732. /**
  7733. * The data type of the parameter.
  7734. */
  7735. type: string;
  7736. /**
  7737. * A description of the expected parameter.
  7738. */
  7739. description: string;
  7740. };
  7741. };
  7742. };
  7743. };
  7744. })[];
  7745. response_format?: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_1;
  7746. /**
  7747. * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
  7748. */
  7749. raw?: boolean;
  7750. /**
  7751. * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
  7752. */
  7753. stream?: boolean;
  7754. /**
  7755. * The maximum number of tokens to generate in the response.
  7756. */
  7757. max_tokens?: number;
  7758. /**
  7759. * Controls the randomness of the output; higher values produce more random results.
  7760. */
  7761. temperature?: number;
  7762. /**
  7763. * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
  7764. */
  7765. top_p?: number;
  7766. /**
  7767. * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
  7768. */
  7769. top_k?: number;
  7770. /**
  7771. * Random seed for reproducibility of the generation.
  7772. */
  7773. seed?: number;
  7774. /**
  7775. * Penalty for repeated tokens; higher values discourage repetition.
  7776. */
  7777. repetition_penalty?: number;
  7778. /**
  7779. * Decreases the likelihood of the model repeating the same lines verbatim.
  7780. */
  7781. frequency_penalty?: number;
  7782. /**
  7783. * Increases the likelihood of the model introducing new topics.
  7784. */
  7785. presence_penalty?: number;
  7786. }
  7787. interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_1 {
  7788. type?: "json_object" | "json_schema";
  7789. json_schema?: unknown;
  7790. }
  7791. interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Async_Batch {
  7792. requests: (Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Prompt_1 | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages_1)[];
  7793. }
  7794. interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Prompt_1 {
  7795. /**
  7796. * The input text prompt for the model to generate a response.
  7797. */
  7798. prompt: string;
  7799. /**
  7800. * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
  7801. */
  7802. lora?: string;
  7803. response_format?: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_2;
  7804. /**
  7805. * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
  7806. */
  7807. raw?: boolean;
  7808. /**
  7809. * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
  7810. */
  7811. stream?: boolean;
  7812. /**
  7813. * The maximum number of tokens to generate in the response.
  7814. */
  7815. max_tokens?: number;
  7816. /**
  7817. * Controls the randomness of the output; higher values produce more random results.
  7818. */
  7819. temperature?: number;
  7820. /**
  7821. * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
  7822. */
  7823. top_p?: number;
  7824. /**
  7825. * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
  7826. */
  7827. top_k?: number;
  7828. /**
  7829. * Random seed for reproducibility of the generation.
  7830. */
  7831. seed?: number;
  7832. /**
  7833. * Penalty for repeated tokens; higher values discourage repetition.
  7834. */
  7835. repetition_penalty?: number;
  7836. /**
  7837. * Decreases the likelihood of the model repeating the same lines verbatim.
  7838. */
  7839. frequency_penalty?: number;
  7840. /**
  7841. * Increases the likelihood of the model introducing new topics.
  7842. */
  7843. presence_penalty?: number;
  7844. }
  7845. interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_2 {
  7846. type?: "json_object" | "json_schema";
  7847. json_schema?: unknown;
  7848. }
  7849. interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages_1 {
  7850. /**
  7851. * An array of message objects representing the conversation history.
  7852. */
  7853. messages: {
  7854. /**
  7855. * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
  7856. */
  7857. role: string;
  7858. /**
  7859. * The content of the message as a string.
  7860. */
  7861. content: string;
  7862. }[];
  7863. functions?: {
  7864. name: string;
  7865. code: string;
  7866. }[];
  7867. /**
  7868. * A list of tools available for the assistant to use.
  7869. */
  7870. tools?: ({
  7871. /**
  7872. * The name of the tool. More descriptive the better.
  7873. */
  7874. name: string;
  7875. /**
  7876. * A brief description of what the tool does.
  7877. */
  7878. description: string;
  7879. /**
  7880. * Schema defining the parameters accepted by the tool.
  7881. */
  7882. parameters: {
  7883. /**
  7884. * The type of the parameters object (usually 'object').
  7885. */
  7886. type: string;
  7887. /**
  7888. * List of required parameter names.
  7889. */
  7890. required?: string[];
  7891. /**
  7892. * Definitions of each parameter.
  7893. */
  7894. properties: {
  7895. [k: string]: {
  7896. /**
  7897. * The data type of the parameter.
  7898. */
  7899. type: string;
  7900. /**
  7901. * A description of the expected parameter.
  7902. */
  7903. description: string;
  7904. };
  7905. };
  7906. };
  7907. } | {
  7908. /**
  7909. * Specifies the type of tool (e.g., 'function').
  7910. */
  7911. type: string;
  7912. /**
  7913. * Details of the function tool.
  7914. */
  7915. function: {
  7916. /**
  7917. * The name of the function.
  7918. */
  7919. name: string;
  7920. /**
  7921. * A brief description of what the function does.
  7922. */
  7923. description: string;
  7924. /**
  7925. * Schema defining the parameters accepted by the function.
  7926. */
  7927. parameters: {
  7928. /**
  7929. * The type of the parameters object (usually 'object').
  7930. */
  7931. type: string;
  7932. /**
  7933. * List of required parameter names.
  7934. */
  7935. required?: string[];
  7936. /**
  7937. * Definitions of each parameter.
  7938. */
  7939. properties: {
  7940. [k: string]: {
  7941. /**
  7942. * The data type of the parameter.
  7943. */
  7944. type: string;
  7945. /**
  7946. * A description of the expected parameter.
  7947. */
  7948. description: string;
  7949. };
  7950. };
  7951. };
  7952. };
  7953. })[];
  7954. response_format?: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_3;
  7955. /**
  7956. * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
  7957. */
  7958. raw?: boolean;
  7959. /**
  7960. * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
  7961. */
  7962. stream?: boolean;
  7963. /**
  7964. * The maximum number of tokens to generate in the response.
  7965. */
  7966. max_tokens?: number;
  7967. /**
  7968. * Controls the randomness of the output; higher values produce more random results.
  7969. */
  7970. temperature?: number;
  7971. /**
  7972. * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.
  7973. */
  7974. top_p?: number;
  7975. /**
  7976. * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.
  7977. */
  7978. top_k?: number;
  7979. /**
  7980. * Random seed for reproducibility of the generation.
  7981. */
  7982. seed?: number;
  7983. /**
  7984. * Penalty for repeated tokens; higher values discourage repetition.
  7985. */
  7986. repetition_penalty?: number;
  7987. /**
  7988. * Decreases the likelihood of the model repeating the same lines verbatim.
  7989. */
  7990. frequency_penalty?: number;
  7991. /**
  7992. * Increases the likelihood of the model introducing new topics.
  7993. */
  7994. presence_penalty?: number;
  7995. }
  7996. interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_3 {
  7997. type?: "json_object" | "json_schema";
  7998. json_schema?: unknown;
  7999. }
  8000. type Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Output = Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Chat_Completion_Response | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Text_Completion_Response | string | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_AsyncResponse;
  8001. interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Chat_Completion_Response {
  8002. /**
  8003. * Unique identifier for the completion
  8004. */
  8005. id?: string;
  8006. /**
  8007. * Object type identifier
  8008. */
  8009. object?: "chat.completion";
  8010. /**
  8011. * Unix timestamp of when the completion was created
  8012. */
  8013. created?: number;
  8014. /**
  8015. * Model used for the completion
  8016. */
  8017. model?: string;
  8018. /**
  8019. * List of completion choices
  8020. */
  8021. choices?: {
  8022. /**
  8023. * Index of the choice in the list
  8024. */
  8025. index?: number;
  8026. /**
  8027. * The message generated by the model
  8028. */
  8029. message?: {
  8030. /**
  8031. * Role of the message author
  8032. */
  8033. role: string;
  8034. /**
  8035. * The content of the message
  8036. */
  8037. content: string;
  8038. /**
  8039. * Internal reasoning content (if available)
  8040. */
  8041. reasoning_content?: string;
  8042. /**
  8043. * Tool calls made by the assistant
  8044. */
  8045. tool_calls?: {
  8046. /**
  8047. * Unique identifier for the tool call
  8048. */
  8049. id: string;
  8050. /**
  8051. * Type of tool call
  8052. */
  8053. type: "function";
  8054. function: {
  8055. /**
  8056. * Name of the function to call
  8057. */
  8058. name: string;
  8059. /**
  8060. * JSON string of arguments for the function
  8061. */
  8062. arguments: string;
  8063. };
  8064. }[];
  8065. };
  8066. /**
  8067. * Reason why the model stopped generating
  8068. */
  8069. finish_reason?: string;
  8070. /**
  8071. * Stop reason (may be null)
  8072. */
  8073. stop_reason?: string | null;
  8074. /**
  8075. * Log probabilities (if requested)
  8076. */
  8077. logprobs?: {} | null;
  8078. }[];
  8079. /**
  8080. * Usage statistics for the inference request
  8081. */
  8082. usage?: {
  8083. /**
  8084. * Total number of tokens in input
  8085. */
  8086. prompt_tokens?: number;
  8087. /**
  8088. * Total number of tokens in output
  8089. */
  8090. completion_tokens?: number;
  8091. /**
  8092. * Total number of input and output tokens
  8093. */
  8094. total_tokens?: number;
  8095. };
  8096. /**
  8097. * Log probabilities for the prompt (if requested)
  8098. */
  8099. prompt_logprobs?: {} | null;
  8100. }
  8101. interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Text_Completion_Response {
  8102. /**
  8103. * Unique identifier for the completion
  8104. */
  8105. id?: string;
  8106. /**
  8107. * Object type identifier
  8108. */
  8109. object?: "text_completion";
  8110. /**
  8111. * Unix timestamp of when the completion was created
  8112. */
  8113. created?: number;
  8114. /**
  8115. * Model used for the completion
  8116. */
  8117. model?: string;
  8118. /**
  8119. * List of completion choices
  8120. */
  8121. choices?: {
  8122. /**
  8123. * Index of the choice in the list
  8124. */
  8125. index: number;
  8126. /**
  8127. * The generated text completion
  8128. */
  8129. text: string;
  8130. /**
  8131. * Reason why the model stopped generating
  8132. */
  8133. finish_reason: string;
  8134. /**
  8135. * Stop reason (may be null)
  8136. */
  8137. stop_reason?: string | null;
  8138. /**
  8139. * Log probabilities (if requested)
  8140. */
  8141. logprobs?: {} | null;
  8142. /**
  8143. * Log probabilities for the prompt (if requested)
  8144. */
  8145. prompt_logprobs?: {} | null;
  8146. }[];
  8147. /**
  8148. * Usage statistics for the inference request
  8149. */
  8150. usage?: {
  8151. /**
  8152. * Total number of tokens in input
  8153. */
  8154. prompt_tokens?: number;
  8155. /**
  8156. * Total number of tokens in output
  8157. */
  8158. completion_tokens?: number;
  8159. /**
  8160. * Total number of input and output tokens
  8161. */
  8162. total_tokens?: number;
  8163. };
  8164. }
  8165. interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_AsyncResponse {
  8166. /**
  8167. * The async request id that can be used to obtain the results.
  8168. */
  8169. request_id?: string;
  8170. }
  8171. declare abstract class Base_Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It {
  8172. inputs: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Input;
  8173. postProcessedOutputs: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Output;
  8174. }
  8175. interface Ai_Cf_Pfnet_Plamo_Embedding_1B_Input {
  8176. /**
  8177. * Input text to embed. Can be a single string or a list of strings.
  8178. */
  8179. text: string | string[];
  8180. }
  8181. interface Ai_Cf_Pfnet_Plamo_Embedding_1B_Output {
  8182. /**
  8183. * Embedding vectors, where each vector is a list of floats.
  8184. */
  8185. data: number[][];
  8186. /**
  8187. * Shape of the embedding data as [number_of_embeddings, embedding_dimension].
  8188. *
  8189. * @minItems 2
  8190. * @maxItems 2
  8191. */
  8192. shape: [
  8193. number,
  8194. number
  8195. ];
  8196. }
  8197. declare abstract class Base_Ai_Cf_Pfnet_Plamo_Embedding_1B {
  8198. inputs: Ai_Cf_Pfnet_Plamo_Embedding_1B_Input;
  8199. postProcessedOutputs: Ai_Cf_Pfnet_Plamo_Embedding_1B_Output;
  8200. }
  8201. interface Ai_Cf_Deepgram_Flux_Input {
  8202. /**
  8203. * Encoding of the audio stream. Currently only supports raw signed little-endian 16-bit PCM.
  8204. */
  8205. encoding: "linear16";
  8206. /**
  8207. * Sample rate of the audio stream in Hz.
  8208. */
  8209. sample_rate: string;
  8210. /**
  8211. * End-of-turn confidence required to fire an eager end-of-turn event. When set, enables EagerEndOfTurn and TurnResumed events. Valid Values 0.3 - 0.9.
  8212. */
  8213. eager_eot_threshold?: string;
  8214. /**
  8215. * End-of-turn confidence required to finish a turn. Valid Values 0.5 - 0.9.
  8216. */
  8217. eot_threshold?: string;
  8218. /**
  8219. * A turn will be finished when this much time has passed after speech, regardless of EOT confidence.
  8220. */
  8221. eot_timeout_ms?: string;
  8222. /**
  8223. * Keyterm prompting can improve recognition of specialized terminology. Pass multiple keyterm query parameters to boost multiple keyterms.
  8224. */
  8225. keyterm?: string;
  8226. /**
  8227. * Opts out requests from the Deepgram Model Improvement Program. Refer to Deepgram Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip
  8228. */
  8229. mip_opt_out?: "true" | "false";
  8230. /**
  8231. * Label your requests for the purpose of identification during usage reporting
  8232. */
  8233. tag?: string;
  8234. }
  8235. /**
  8236. * Output will be returned as websocket messages.
  8237. */
  8238. interface Ai_Cf_Deepgram_Flux_Output {
  8239. /**
  8240. * The unique identifier of the request (uuid)
  8241. */
  8242. request_id?: string;
  8243. /**
  8244. * Starts at 0 and increments for each message the server sends to the client.
  8245. */
  8246. sequence_id?: number;
  8247. /**
  8248. * The type of event being reported.
  8249. */
  8250. event?: "Update" | "StartOfTurn" | "EagerEndOfTurn" | "TurnResumed" | "EndOfTurn";
  8251. /**
  8252. * The index of the current turn
  8253. */
  8254. turn_index?: number;
  8255. /**
  8256. * Start time in seconds of the audio range that was transcribed
  8257. */
  8258. audio_window_start?: number;
  8259. /**
  8260. * End time in seconds of the audio range that was transcribed
  8261. */
  8262. audio_window_end?: number;
  8263. /**
  8264. * Text that was said over the course of the current turn
  8265. */
  8266. transcript?: string;
  8267. /**
  8268. * The words in the transcript
  8269. */
  8270. words?: {
  8271. /**
  8272. * The individual punctuated, properly-cased word from the transcript
  8273. */
  8274. word: string;
  8275. /**
  8276. * Confidence that this word was transcribed correctly
  8277. */
  8278. confidence: number;
  8279. }[];
  8280. /**
  8281. * Confidence that no more speech is coming in this turn
  8282. */
  8283. end_of_turn_confidence?: number;
  8284. }
  8285. declare abstract class Base_Ai_Cf_Deepgram_Flux {
  8286. inputs: Ai_Cf_Deepgram_Flux_Input;
  8287. postProcessedOutputs: Ai_Cf_Deepgram_Flux_Output;
  8288. }
  8289. interface Ai_Cf_Deepgram_Aura_2_En_Input {
  8290. /**
  8291. * Speaker used to produce the audio.
  8292. */
  8293. speaker?: "amalthea" | "andromeda" | "apollo" | "arcas" | "aries" | "asteria" | "athena" | "atlas" | "aurora" | "callista" | "cora" | "cordelia" | "delia" | "draco" | "electra" | "harmonia" | "helena" | "hera" | "hermes" | "hyperion" | "iris" | "janus" | "juno" | "jupiter" | "luna" | "mars" | "minerva" | "neptune" | "odysseus" | "ophelia" | "orion" | "orpheus" | "pandora" | "phoebe" | "pluto" | "saturn" | "thalia" | "theia" | "vesta" | "zeus";
  8294. /**
  8295. * Encoding of the output audio.
  8296. */
  8297. encoding?: "linear16" | "flac" | "mulaw" | "alaw" | "mp3" | "opus" | "aac";
  8298. /**
  8299. * Container specifies the file format wrapper for the output audio. The available options depend on the encoding type..
  8300. */
  8301. container?: "none" | "wav" | "ogg";
  8302. /**
  8303. * The text content to be converted to speech
  8304. */
  8305. text: string;
  8306. /**
  8307. * Sample Rate specifies the sample rate for the output audio. Based on the encoding, different sample rates are supported. For some encodings, the sample rate is not configurable
  8308. */
  8309. sample_rate?: number;
  8310. /**
  8311. * The bitrate of the audio in bits per second. Choose from predefined ranges or specific values based on the encoding type.
  8312. */
  8313. bit_rate?: number;
  8314. }
  8315. /**
  8316. * The generated audio in MP3 format
  8317. */
  8318. type Ai_Cf_Deepgram_Aura_2_En_Output = string;
  8319. declare abstract class Base_Ai_Cf_Deepgram_Aura_2_En {
  8320. inputs: Ai_Cf_Deepgram_Aura_2_En_Input;
  8321. postProcessedOutputs: Ai_Cf_Deepgram_Aura_2_En_Output;
  8322. }
  8323. interface Ai_Cf_Deepgram_Aura_2_Es_Input {
  8324. /**
  8325. * Speaker used to produce the audio.
  8326. */
  8327. speaker?: "sirio" | "nestor" | "carina" | "celeste" | "alvaro" | "diana" | "aquila" | "selena" | "estrella" | "javier";
  8328. /**
  8329. * Encoding of the output audio.
  8330. */
  8331. encoding?: "linear16" | "flac" | "mulaw" | "alaw" | "mp3" | "opus" | "aac";
  8332. /**
  8333. * Container specifies the file format wrapper for the output audio. The available options depend on the encoding type..
  8334. */
  8335. container?: "none" | "wav" | "ogg";
  8336. /**
  8337. * The text content to be converted to speech
  8338. */
  8339. text: string;
  8340. /**
  8341. * Sample Rate specifies the sample rate for the output audio. Based on the encoding, different sample rates are supported. For some encodings, the sample rate is not configurable
  8342. */
  8343. sample_rate?: number;
  8344. /**
  8345. * The bitrate of the audio in bits per second. Choose from predefined ranges or specific values based on the encoding type.
  8346. */
  8347. bit_rate?: number;
  8348. }
  8349. /**
  8350. * The generated audio in MP3 format
  8351. */
  8352. type Ai_Cf_Deepgram_Aura_2_Es_Output = string;
  8353. declare abstract class Base_Ai_Cf_Deepgram_Aura_2_Es {
  8354. inputs: Ai_Cf_Deepgram_Aura_2_Es_Input;
  8355. postProcessedOutputs: Ai_Cf_Deepgram_Aura_2_Es_Output;
  8356. }
  8357. interface AiModels {
  8358. "@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
  8359. "@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
  8360. "@cf/runwayml/stable-diffusion-v1-5-inpainting": BaseAiTextToImage;
  8361. "@cf/runwayml/stable-diffusion-v1-5-img2img": BaseAiTextToImage;
  8362. "@cf/lykon/dreamshaper-8-lcm": BaseAiTextToImage;
  8363. "@cf/bytedance/stable-diffusion-xl-lightning": BaseAiTextToImage;
  8364. "@cf/myshell-ai/melotts": BaseAiTextToSpeech;
  8365. "@cf/google/embeddinggemma-300m": BaseAiTextEmbeddings;
  8366. "@cf/microsoft/resnet-50": BaseAiImageClassification;
  8367. "@cf/meta/llama-2-7b-chat-int8": BaseAiTextGeneration;
  8368. "@cf/mistral/mistral-7b-instruct-v0.1": BaseAiTextGeneration;
  8369. "@cf/meta/llama-2-7b-chat-fp16": BaseAiTextGeneration;
  8370. "@hf/thebloke/llama-2-13b-chat-awq": BaseAiTextGeneration;
  8371. "@hf/thebloke/mistral-7b-instruct-v0.1-awq": BaseAiTextGeneration;
  8372. "@hf/thebloke/zephyr-7b-beta-awq": BaseAiTextGeneration;
  8373. "@hf/thebloke/openhermes-2.5-mistral-7b-awq": BaseAiTextGeneration;
  8374. "@hf/thebloke/neural-chat-7b-v3-1-awq": BaseAiTextGeneration;
  8375. "@hf/thebloke/llamaguard-7b-awq": BaseAiTextGeneration;
  8376. "@hf/thebloke/deepseek-coder-6.7b-base-awq": BaseAiTextGeneration;
  8377. "@hf/thebloke/deepseek-coder-6.7b-instruct-awq": BaseAiTextGeneration;
  8378. "@cf/deepseek-ai/deepseek-math-7b-instruct": BaseAiTextGeneration;
  8379. "@cf/defog/sqlcoder-7b-2": BaseAiTextGeneration;
  8380. "@cf/openchat/openchat-3.5-0106": BaseAiTextGeneration;
  8381. "@cf/tiiuae/falcon-7b-instruct": BaseAiTextGeneration;
  8382. "@cf/thebloke/discolm-german-7b-v1-awq": BaseAiTextGeneration;
  8383. "@cf/qwen/qwen1.5-0.5b-chat": BaseAiTextGeneration;
  8384. "@cf/qwen/qwen1.5-7b-chat-awq": BaseAiTextGeneration;
  8385. "@cf/qwen/qwen1.5-14b-chat-awq": BaseAiTextGeneration;
  8386. "@cf/tinyllama/tinyllama-1.1b-chat-v1.0": BaseAiTextGeneration;
  8387. "@cf/microsoft/phi-2": BaseAiTextGeneration;
  8388. "@cf/qwen/qwen1.5-1.8b-chat": BaseAiTextGeneration;
  8389. "@cf/mistral/mistral-7b-instruct-v0.2-lora": BaseAiTextGeneration;
  8390. "@hf/nousresearch/hermes-2-pro-mistral-7b": BaseAiTextGeneration;
  8391. "@hf/nexusflow/starling-lm-7b-beta": BaseAiTextGeneration;
  8392. "@hf/google/gemma-7b-it": BaseAiTextGeneration;
  8393. "@cf/meta-llama/llama-2-7b-chat-hf-lora": BaseAiTextGeneration;
  8394. "@cf/google/gemma-2b-it-lora": BaseAiTextGeneration;
  8395. "@cf/google/gemma-7b-it-lora": BaseAiTextGeneration;
  8396. "@hf/mistral/mistral-7b-instruct-v0.2": BaseAiTextGeneration;
  8397. "@cf/meta/llama-3-8b-instruct": BaseAiTextGeneration;
  8398. "@cf/fblgit/una-cybertron-7b-v2-bf16": BaseAiTextGeneration;
  8399. "@cf/meta/llama-3-8b-instruct-awq": BaseAiTextGeneration;
  8400. "@cf/meta/llama-3.1-8b-instruct-fp8": BaseAiTextGeneration;
  8401. "@cf/meta/llama-3.1-8b-instruct-awq": BaseAiTextGeneration;
  8402. "@cf/meta/llama-3.2-3b-instruct": BaseAiTextGeneration;
  8403. "@cf/meta/llama-3.2-1b-instruct": BaseAiTextGeneration;
  8404. "@cf/deepseek-ai/deepseek-r1-distill-qwen-32b": BaseAiTextGeneration;
  8405. "@cf/ibm-granite/granite-4.0-h-micro": BaseAiTextGeneration;
  8406. "@cf/facebook/bart-large-cnn": BaseAiSummarization;
  8407. "@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText;
  8408. "@cf/baai/bge-base-en-v1.5": Base_Ai_Cf_Baai_Bge_Base_En_V1_5;
  8409. "@cf/openai/whisper": Base_Ai_Cf_Openai_Whisper;
  8410. "@cf/meta/m2m100-1.2b": Base_Ai_Cf_Meta_M2M100_1_2B;
  8411. "@cf/baai/bge-small-en-v1.5": Base_Ai_Cf_Baai_Bge_Small_En_V1_5;
  8412. "@cf/baai/bge-large-en-v1.5": Base_Ai_Cf_Baai_Bge_Large_En_V1_5;
  8413. "@cf/unum/uform-gen2-qwen-500m": Base_Ai_Cf_Unum_Uform_Gen2_Qwen_500M;
  8414. "@cf/openai/whisper-tiny-en": Base_Ai_Cf_Openai_Whisper_Tiny_En;
  8415. "@cf/openai/whisper-large-v3-turbo": Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo;
  8416. "@cf/baai/bge-m3": Base_Ai_Cf_Baai_Bge_M3;
  8417. "@cf/black-forest-labs/flux-1-schnell": Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell;
  8418. "@cf/meta/llama-3.2-11b-vision-instruct": Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct;
  8419. "@cf/meta/llama-3.3-70b-instruct-fp8-fast": Base_Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast;
  8420. "@cf/meta/llama-guard-3-8b": Base_Ai_Cf_Meta_Llama_Guard_3_8B;
  8421. "@cf/baai/bge-reranker-base": Base_Ai_Cf_Baai_Bge_Reranker_Base;
  8422. "@cf/qwen/qwen2.5-coder-32b-instruct": Base_Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct;
  8423. "@cf/qwen/qwq-32b": Base_Ai_Cf_Qwen_Qwq_32B;
  8424. "@cf/mistralai/mistral-small-3.1-24b-instruct": Base_Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct;
  8425. "@cf/google/gemma-3-12b-it": Base_Ai_Cf_Google_Gemma_3_12B_It;
  8426. "@cf/meta/llama-4-scout-17b-16e-instruct": Base_Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct;
  8427. "@cf/qwen/qwen3-30b-a3b-fp8": Base_Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8;
  8428. "@cf/deepgram/nova-3": Base_Ai_Cf_Deepgram_Nova_3;
  8429. "@cf/qwen/qwen3-embedding-0.6b": Base_Ai_Cf_Qwen_Qwen3_Embedding_0_6B;
  8430. "@cf/pipecat-ai/smart-turn-v2": Base_Ai_Cf_Pipecat_Ai_Smart_Turn_V2;
  8431. "@cf/openai/gpt-oss-120b": Base_Ai_Cf_Openai_Gpt_Oss_120B;
  8432. "@cf/openai/gpt-oss-20b": Base_Ai_Cf_Openai_Gpt_Oss_20B;
  8433. "@cf/leonardo/phoenix-1.0": Base_Ai_Cf_Leonardo_Phoenix_1_0;
  8434. "@cf/leonardo/lucid-origin": Base_Ai_Cf_Leonardo_Lucid_Origin;
  8435. "@cf/deepgram/aura-1": Base_Ai_Cf_Deepgram_Aura_1;
  8436. "@cf/ai4bharat/indictrans2-en-indic-1B": Base_Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B;
  8437. "@cf/aisingapore/gemma-sea-lion-v4-27b-it": Base_Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It;
  8438. "@cf/pfnet/plamo-embedding-1b": Base_Ai_Cf_Pfnet_Plamo_Embedding_1B;
  8439. "@cf/deepgram/flux": Base_Ai_Cf_Deepgram_Flux;
  8440. "@cf/deepgram/aura-2-en": Base_Ai_Cf_Deepgram_Aura_2_En;
  8441. "@cf/deepgram/aura-2-es": Base_Ai_Cf_Deepgram_Aura_2_Es;
  8442. }
  8443. type AiOptions = {
  8444. /**
  8445. * Send requests as an asynchronous batch job, only works for supported models
  8446. * https://developers.cloudflare.com/workers-ai/features/batch-api
  8447. */
  8448. queueRequest?: boolean;
  8449. /**
  8450. * Establish websocket connections, only works for supported models
  8451. */
  8452. websocket?: boolean;
  8453. /**
  8454. * Tag your requests to group and view them in Cloudflare dashboard.
  8455. *
  8456. * Rules:
  8457. * Tags must only contain letters, numbers, and the symbols: : - . / @
  8458. * Each tag can have maximum 50 characters.
  8459. * Maximum 5 tags are allowed each request.
  8460. * Duplicate tags will removed.
  8461. */
  8462. tags?: string[];
  8463. gateway?: GatewayOptions;
  8464. returnRawResponse?: boolean;
  8465. prefix?: string;
  8466. extraHeaders?: object;
  8467. };
  8468. type AiModelsSearchParams = {
  8469. author?: string;
  8470. hide_experimental?: boolean;
  8471. page?: number;
  8472. per_page?: number;
  8473. search?: string;
  8474. source?: number;
  8475. task?: string;
  8476. };
  8477. type AiModelsSearchObject = {
  8478. id: string;
  8479. source: number;
  8480. name: string;
  8481. description: string;
  8482. task: {
  8483. id: string;
  8484. name: string;
  8485. description: string;
  8486. };
  8487. tags: string[];
  8488. properties: {
  8489. property_id: string;
  8490. value: string;
  8491. }[];
  8492. };
  8493. interface InferenceUpstreamError extends Error {
  8494. }
  8495. interface AiInternalError extends Error {
  8496. }
  8497. type AiModelListType = Record<string, any>;
  8498. declare abstract class Ai<AiModelList extends AiModelListType = AiModels> {
  8499. aiGatewayLogId: string | null;
  8500. gateway(gatewayId: string): AiGateway;
  8501. autorag(autoragId: string): AutoRAG;
  8502. run<Name extends keyof AiModelList, Options extends AiOptions, InputOptions extends AiModelList[Name]["inputs"]>(model: Name, inputs: InputOptions, options?: Options): Promise<Options extends {
  8503. returnRawResponse: true;
  8504. } | {
  8505. websocket: true;
  8506. } ? Response : InputOptions extends {
  8507. stream: true;
  8508. } ? ReadableStream : AiModelList[Name]["postProcessedOutputs"]>;
  8509. models(params?: AiModelsSearchParams): Promise<AiModelsSearchObject[]>;
  8510. toMarkdown(): ToMarkdownService;
  8511. toMarkdown(files: MarkdownDocument[], options?: ConversionRequestOptions): Promise<ConversionResponse[]>;
  8512. toMarkdown(files: MarkdownDocument, options?: ConversionRequestOptions): Promise<ConversionResponse>;
  8513. }
  8514. type GatewayRetries = {
  8515. maxAttempts?: 1 | 2 | 3 | 4 | 5;
  8516. retryDelayMs?: number;
  8517. backoff?: 'constant' | 'linear' | 'exponential';
  8518. };
  8519. type GatewayOptions = {
  8520. id: string;
  8521. cacheKey?: string;
  8522. cacheTtl?: number;
  8523. skipCache?: boolean;
  8524. metadata?: Record<string, number | string | boolean | null | bigint>;
  8525. collectLog?: boolean;
  8526. eventId?: string;
  8527. requestTimeoutMs?: number;
  8528. retries?: GatewayRetries;
  8529. };
  8530. type UniversalGatewayOptions = Exclude<GatewayOptions, 'id'> & {
  8531. /**
  8532. ** @deprecated
  8533. */
  8534. id?: string;
  8535. };
  8536. type AiGatewayPatchLog = {
  8537. score?: number | null;
  8538. feedback?: -1 | 1 | null;
  8539. metadata?: Record<string, number | string | boolean | null | bigint> | null;
  8540. };
  8541. type AiGatewayLog = {
  8542. id: string;
  8543. provider: string;
  8544. model: string;
  8545. model_type?: string;
  8546. path: string;
  8547. duration: number;
  8548. request_type?: string;
  8549. request_content_type?: string;
  8550. status_code: number;
  8551. response_content_type?: string;
  8552. success: boolean;
  8553. cached: boolean;
  8554. tokens_in?: number;
  8555. tokens_out?: number;
  8556. metadata?: Record<string, number | string | boolean | null | bigint>;
  8557. step?: number;
  8558. cost?: number;
  8559. custom_cost?: boolean;
  8560. request_size: number;
  8561. request_head?: string;
  8562. request_head_complete: boolean;
  8563. response_size: number;
  8564. response_head?: string;
  8565. response_head_complete: boolean;
  8566. created_at: Date;
  8567. };
  8568. type AIGatewayProviders = 'workers-ai' | 'anthropic' | 'aws-bedrock' | 'azure-openai' | 'google-vertex-ai' | 'huggingface' | 'openai' | 'perplexity-ai' | 'replicate' | 'groq' | 'cohere' | 'google-ai-studio' | 'mistral' | 'grok' | 'openrouter' | 'deepseek' | 'cerebras' | 'cartesia' | 'elevenlabs' | 'adobe-firefly';
  8569. type AIGatewayHeaders = {
  8570. 'cf-aig-metadata': Record<string, number | string | boolean | null | bigint> | string;
  8571. 'cf-aig-custom-cost': {
  8572. per_token_in?: number;
  8573. per_token_out?: number;
  8574. } | {
  8575. total_cost?: number;
  8576. } | string;
  8577. 'cf-aig-cache-ttl': number | string;
  8578. 'cf-aig-skip-cache': boolean | string;
  8579. 'cf-aig-cache-key': string;
  8580. 'cf-aig-event-id': string;
  8581. 'cf-aig-request-timeout': number | string;
  8582. 'cf-aig-max-attempts': number | string;
  8583. 'cf-aig-retry-delay': number | string;
  8584. 'cf-aig-backoff': string;
  8585. 'cf-aig-collect-log': boolean | string;
  8586. Authorization: string;
  8587. 'Content-Type': string;
  8588. [key: string]: string | number | boolean | object;
  8589. };
  8590. type AIGatewayUniversalRequest = {
  8591. provider: AIGatewayProviders | string; // eslint-disable-line
  8592. endpoint: string;
  8593. headers: Partial<AIGatewayHeaders>;
  8594. query: unknown;
  8595. };
  8596. interface AiGatewayInternalError extends Error {
  8597. }
  8598. interface AiGatewayLogNotFound extends Error {
  8599. }
  8600. declare abstract class AiGateway {
  8601. patchLog(logId: string, data: AiGatewayPatchLog): Promise<void>;
  8602. getLog(logId: string): Promise<AiGatewayLog>;
  8603. run(data: AIGatewayUniversalRequest | AIGatewayUniversalRequest[], options?: {
  8604. gateway?: UniversalGatewayOptions;
  8605. extraHeaders?: object;
  8606. }): Promise<Response>;
  8607. getUrl(provider?: AIGatewayProviders | string): Promise<string>; // eslint-disable-line
  8608. }
  8609. interface AutoRAGInternalError extends Error {
  8610. }
  8611. interface AutoRAGNotFoundError extends Error {
  8612. }
  8613. interface AutoRAGUnauthorizedError extends Error {
  8614. }
  8615. interface AutoRAGNameNotSetError extends Error {
  8616. }
  8617. type ComparisonFilter = {
  8618. key: string;
  8619. type: 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte';
  8620. value: string | number | boolean;
  8621. };
  8622. type CompoundFilter = {
  8623. type: 'and' | 'or';
  8624. filters: ComparisonFilter[];
  8625. };
  8626. type AutoRagSearchRequest = {
  8627. query: string;
  8628. filters?: CompoundFilter | ComparisonFilter;
  8629. max_num_results?: number;
  8630. ranking_options?: {
  8631. ranker?: string;
  8632. score_threshold?: number;
  8633. };
  8634. reranking?: {
  8635. enabled?: boolean;
  8636. model?: string;
  8637. };
  8638. rewrite_query?: boolean;
  8639. };
  8640. type AutoRagAiSearchRequest = AutoRagSearchRequest & {
  8641. stream?: boolean;
  8642. system_prompt?: string;
  8643. };
  8644. type AutoRagAiSearchRequestStreaming = Omit<AutoRagAiSearchRequest, 'stream'> & {
  8645. stream: true;
  8646. };
  8647. type AutoRagSearchResponse = {
  8648. object: 'vector_store.search_results.page';
  8649. search_query: string;
  8650. data: {
  8651. file_id: string;
  8652. filename: string;
  8653. score: number;
  8654. attributes: Record<string, string | number | boolean | null>;
  8655. content: {
  8656. type: 'text';
  8657. text: string;
  8658. }[];
  8659. }[];
  8660. has_more: boolean;
  8661. next_page: string | null;
  8662. };
  8663. type AutoRagListResponse = {
  8664. id: string;
  8665. enable: boolean;
  8666. type: string;
  8667. source: string;
  8668. vectorize_name: string;
  8669. paused: boolean;
  8670. status: string;
  8671. }[];
  8672. type AutoRagAiSearchResponse = AutoRagSearchResponse & {
  8673. response: string;
  8674. };
  8675. declare abstract class AutoRAG {
  8676. list(): Promise<AutoRagListResponse>;
  8677. search(params: AutoRagSearchRequest): Promise<AutoRagSearchResponse>;
  8678. aiSearch(params: AutoRagAiSearchRequestStreaming): Promise<Response>;
  8679. aiSearch(params: AutoRagAiSearchRequest): Promise<AutoRagAiSearchResponse>;
  8680. aiSearch(params: AutoRagAiSearchRequest): Promise<AutoRagAiSearchResponse | Response>;
  8681. }
  8682. interface BasicImageTransformations {
  8683. /**
  8684. * Maximum width in image pixels. The value must be an integer.
  8685. */
  8686. width?: number;
  8687. /**
  8688. * Maximum height in image pixels. The value must be an integer.
  8689. */
  8690. height?: number;
  8691. /**
  8692. * Resizing mode as a string. It affects interpretation of width and height
  8693. * options:
  8694. * - scale-down: Similar to contain, but the image is never enlarged. If
  8695. * the image is larger than given width or height, it will be resized.
  8696. * Otherwise its original size will be kept.
  8697. * - contain: Resizes to maximum size that fits within the given width and
  8698. * height. If only a single dimension is given (e.g. only width), the
  8699. * image will be shrunk or enlarged to exactly match that dimension.
  8700. * Aspect ratio is always preserved.
  8701. * - cover: Resizes (shrinks or enlarges) to fill the entire area of width
  8702. * and height. If the image has an aspect ratio different from the ratio
  8703. * of width and height, it will be cropped to fit.
  8704. * - crop: The image will be shrunk and cropped to fit within the area
  8705. * specified by width and height. The image will not be enlarged. For images
  8706. * smaller than the given dimensions it's the same as scale-down. For
  8707. * images larger than the given dimensions, it's the same as cover.
  8708. * See also trim.
  8709. * - pad: Resizes to the maximum size that fits within the given width and
  8710. * height, and then fills the remaining area with a background color
  8711. * (white by default). Use of this mode is not recommended, as the same
  8712. * effect can be more efficiently achieved with the contain mode and the
  8713. * CSS object-fit: contain property.
  8714. * - squeeze: Stretches and deforms to the width and height given, even if it
  8715. * breaks aspect ratio
  8716. */
  8717. fit?: "scale-down" | "contain" | "cover" | "crop" | "pad" | "squeeze";
  8718. /**
  8719. * Image segmentation using artificial intelligence models. Sets pixels not
  8720. * within selected segment area to transparent e.g "foreground" sets every
  8721. * background pixel as transparent.
  8722. */
  8723. segment?: "foreground";
  8724. /**
  8725. * When cropping with fit: "cover", this defines the side or point that should
  8726. * be left uncropped. The value is either a string
  8727. * "left", "right", "top", "bottom", "auto", or "center" (the default),
  8728. * or an object {x, y} containing focal point coordinates in the original
  8729. * image expressed as fractions ranging from 0.0 (top or left) to 1.0
  8730. * (bottom or right), 0.5 being the center. {fit: "cover", gravity: "top"} will
  8731. * crop bottom or left and right sides as necessary, but won’t crop anything
  8732. * from the top. {fit: "cover", gravity: {x:0.5, y:0.2}} will crop each side to
  8733. * preserve as much as possible around a point at 20% of the height of the
  8734. * source image.
  8735. */
  8736. gravity?: 'face' | 'left' | 'right' | 'top' | 'bottom' | 'center' | 'auto' | 'entropy' | BasicImageTransformationsGravityCoordinates;
  8737. /**
  8738. * Background color to add underneath the image. Applies only to images with
  8739. * transparency (such as PNG). Accepts any CSS color (#RRGGBB, rgba(…),
  8740. * hsl(…), etc.)
  8741. */
  8742. background?: string;
  8743. /**
  8744. * Number of degrees (90, 180, 270) to rotate the image by. width and height
  8745. * options refer to axes after rotation.
  8746. */
  8747. rotate?: 0 | 90 | 180 | 270 | 360;
  8748. }
  8749. interface BasicImageTransformationsGravityCoordinates {
  8750. x?: number;
  8751. y?: number;
  8752. mode?: 'remainder' | 'box-center';
  8753. }
  8754. /**
  8755. * In addition to the properties you can set in the RequestInit dict
  8756. * that you pass as an argument to the Request constructor, you can
  8757. * set certain properties of a `cf` object to control how Cloudflare
  8758. * features are applied to that new Request.
  8759. *
  8760. * Note: Currently, these properties cannot be tested in the
  8761. * playground.
  8762. */
  8763. interface RequestInitCfProperties extends Record<string, unknown> {
  8764. cacheEverything?: boolean;
  8765. /**
  8766. * A request's cache key is what determines if two requests are
  8767. * "the same" for caching purposes. If a request has the same cache key
  8768. * as some previous request, then we can serve the same cached response for
  8769. * both. (e.g. 'some-key')
  8770. *
  8771. * Only available for Enterprise customers.
  8772. */
  8773. cacheKey?: string;
  8774. /**
  8775. * This allows you to append additional Cache-Tag response headers
  8776. * to the origin response without modifications to the origin server.
  8777. * This will allow for greater control over the Purge by Cache Tag feature
  8778. * utilizing changes only in the Workers process.
  8779. *
  8780. * Only available for Enterprise customers.
  8781. */
  8782. cacheTags?: string[];
  8783. /**
  8784. * Force response to be cached for a given number of seconds. (e.g. 300)
  8785. */
  8786. cacheTtl?: number;
  8787. /**
  8788. * Force response to be cached for a given number of seconds based on the Origin status code.
  8789. * (e.g. { '200-299': 86400, '404': 1, '500-599': 0 })
  8790. */
  8791. cacheTtlByStatus?: Record<string, number>;
  8792. scrapeShield?: boolean;
  8793. apps?: boolean;
  8794. image?: RequestInitCfPropertiesImage;
  8795. minify?: RequestInitCfPropertiesImageMinify;
  8796. mirage?: boolean;
  8797. polish?: "lossy" | "lossless" | "off";
  8798. r2?: RequestInitCfPropertiesR2;
  8799. /**
  8800. * Redirects the request to an alternate origin server. You can use this,
  8801. * for example, to implement load balancing across several origins.
  8802. * (e.g.us-east.example.com)
  8803. *
  8804. * Note - For security reasons, the hostname set in resolveOverride must
  8805. * be proxied on the same Cloudflare zone of the incoming request.
  8806. * Otherwise, the setting is ignored. CNAME hosts are allowed, so to
  8807. * resolve to a host under a different domain or a DNS only domain first
  8808. * declare a CNAME record within your own zone’s DNS mapping to the
  8809. * external hostname, set proxy on Cloudflare, then set resolveOverride
  8810. * to point to that CNAME record.
  8811. */
  8812. resolveOverride?: string;
  8813. }
  8814. interface RequestInitCfPropertiesImageDraw extends BasicImageTransformations {
  8815. /**
  8816. * Absolute URL of the image file to use for the drawing. It can be any of
  8817. * the supported file formats. For drawing of watermarks or non-rectangular
  8818. * overlays we recommend using PNG or WebP images.
  8819. */
  8820. url: string;
  8821. /**
  8822. * Floating-point number between 0 (transparent) and 1 (opaque).
  8823. * For example, opacity: 0.5 makes overlay semitransparent.
  8824. */
  8825. opacity?: number;
  8826. /**
  8827. * - If set to true, the overlay image will be tiled to cover the entire
  8828. * area. This is useful for stock-photo-like watermarks.
  8829. * - If set to "x", the overlay image will be tiled horizontally only
  8830. * (form a line).
  8831. * - If set to "y", the overlay image will be tiled vertically only
  8832. * (form a line).
  8833. */
  8834. repeat?: true | "x" | "y";
  8835. /**
  8836. * Position of the overlay image relative to a given edge. Each property is
  8837. * an offset in pixels. 0 aligns exactly to the edge. For example, left: 10
  8838. * positions left side of the overlay 10 pixels from the left edge of the
  8839. * image it's drawn over. bottom: 0 aligns bottom of the overlay with bottom
  8840. * of the background image.
  8841. *
  8842. * Setting both left & right, or both top & bottom is an error.
  8843. *
  8844. * If no position is specified, the image will be centered.
  8845. */
  8846. top?: number;
  8847. left?: number;
  8848. bottom?: number;
  8849. right?: number;
  8850. }
  8851. interface RequestInitCfPropertiesImage extends BasicImageTransformations {
  8852. /**
  8853. * Device Pixel Ratio. Default 1. Multiplier for width/height that makes it
  8854. * easier to specify higher-DPI sizes in <img srcset>.
  8855. */
  8856. dpr?: number;
  8857. /**
  8858. * Allows you to trim your image. Takes dpr into account and is performed before
  8859. * resizing or rotation.
  8860. *
  8861. * It can be used as:
  8862. * - left, top, right, bottom - it will specify the number of pixels to cut
  8863. * off each side
  8864. * - width, height - the width/height you'd like to end up with - can be used
  8865. * in combination with the properties above
  8866. * - border - this will automatically trim the surroundings of an image based on
  8867. * it's color. It consists of three properties:
  8868. * - color: rgb or hex representation of the color you wish to trim (todo: verify the rgba bit)
  8869. * - tolerance: difference from color to treat as color
  8870. * - keep: the number of pixels of border to keep
  8871. */
  8872. trim?: "border" | {
  8873. top?: number;
  8874. bottom?: number;
  8875. left?: number;
  8876. right?: number;
  8877. width?: number;
  8878. height?: number;
  8879. border?: boolean | {
  8880. color?: string;
  8881. tolerance?: number;
  8882. keep?: number;
  8883. };
  8884. };
  8885. /**
  8886. * Quality setting from 1-100 (useful values are in 60-90 range). Lower values
  8887. * make images look worse, but load faster. The default is 85. It applies only
  8888. * to JPEG and WebP images. It doesn’t have any effect on PNG.
  8889. */
  8890. quality?: number | "low" | "medium-low" | "medium-high" | "high";
  8891. /**
  8892. * Output format to generate. It can be:
  8893. * - avif: generate images in AVIF format.
  8894. * - webp: generate images in Google WebP format. Set quality to 100 to get
  8895. * the WebP-lossless format.
  8896. * - json: instead of generating an image, outputs information about the
  8897. * image, in JSON format. The JSON object will contain image size
  8898. * (before and after resizing), source image’s MIME type, file size, etc.
  8899. * - jpeg: generate images in JPEG format.
  8900. * - png: generate images in PNG format.
  8901. */
  8902. format?: "avif" | "webp" | "json" | "jpeg" | "png" | "baseline-jpeg" | "png-force" | "svg";
  8903. /**
  8904. * Whether to preserve animation frames from input files. Default is true.
  8905. * Setting it to false reduces animations to still images. This setting is
  8906. * recommended when enlarging images or processing arbitrary user content,
  8907. * because large GIF animations can weigh tens or even hundreds of megabytes.
  8908. * It is also useful to set anim:false when using format:"json" to get the
  8909. * response quicker without the number of frames.
  8910. */
  8911. anim?: boolean;
  8912. /**
  8913. * What EXIF data should be preserved in the output image. Note that EXIF
  8914. * rotation and embedded color profiles are always applied ("baked in" into
  8915. * the image), and aren't affected by this option. Note that if the Polish
  8916. * feature is enabled, all metadata may have been removed already and this
  8917. * option may have no effect.
  8918. * - keep: Preserve most of EXIF metadata, including GPS location if there's
  8919. * any.
  8920. * - copyright: Only keep the copyright tag, and discard everything else.
  8921. * This is the default behavior for JPEG files.
  8922. * - none: Discard all invisible EXIF metadata. Currently WebP and PNG
  8923. * output formats always discard metadata.
  8924. */
  8925. metadata?: "keep" | "copyright" | "none";
  8926. /**
  8927. * Strength of sharpening filter to apply to the image. Floating-point
  8928. * number between 0 (no sharpening, default) and 10 (maximum). 1.0 is a
  8929. * recommended value for downscaled images.
  8930. */
  8931. sharpen?: number;
  8932. /**
  8933. * Radius of a blur filter (approximate gaussian). Maximum supported radius
  8934. * is 250.
  8935. */
  8936. blur?: number;
  8937. /**
  8938. * Overlays are drawn in the order they appear in the array (last array
  8939. * entry is the topmost layer).
  8940. */
  8941. draw?: RequestInitCfPropertiesImageDraw[];
  8942. /**
  8943. * Fetching image from authenticated origin. Setting this property will
  8944. * pass authentication headers (Authorization, Cookie, etc.) through to
  8945. * the origin.
  8946. */
  8947. "origin-auth"?: "share-publicly";
  8948. /**
  8949. * Adds a border around the image. The border is added after resizing. Border
  8950. * width takes dpr into account, and can be specified either using a single
  8951. * width property, or individually for each side.
  8952. */
  8953. border?: {
  8954. color: string;
  8955. width: number;
  8956. } | {
  8957. color: string;
  8958. top: number;
  8959. right: number;
  8960. bottom: number;
  8961. left: number;
  8962. };
  8963. /**
  8964. * Increase brightness by a factor. A value of 1.0 equals no change, a value
  8965. * of 0.5 equals half brightness, and a value of 2.0 equals twice as bright.
  8966. * 0 is ignored.
  8967. */
  8968. brightness?: number;
  8969. /**
  8970. * Increase contrast by a factor. A value of 1.0 equals no change, a value of
  8971. * 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is
  8972. * ignored.
  8973. */
  8974. contrast?: number;
  8975. /**
  8976. * Increase exposure by a factor. A value of 1.0 equals no change, a value of
  8977. * 0.5 darkens the image, and a value of 2.0 lightens the image. 0 is ignored.
  8978. */
  8979. gamma?: number;
  8980. /**
  8981. * Increase contrast by a factor. A value of 1.0 equals no change, a value of
  8982. * 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is
  8983. * ignored.
  8984. */
  8985. saturation?: number;
  8986. /**
  8987. * Flips the images horizontally, vertically, or both. Flipping is applied before
  8988. * rotation, so if you apply flip=h,rotate=90 then the image will be flipped
  8989. * horizontally, then rotated by 90 degrees.
  8990. */
  8991. flip?: 'h' | 'v' | 'hv';
  8992. /**
  8993. * Slightly reduces latency on a cache miss by selecting a
  8994. * quickest-to-compress file format, at a cost of increased file size and
  8995. * lower image quality. It will usually override the format option and choose
  8996. * JPEG over WebP or AVIF. We do not recommend using this option, except in
  8997. * unusual circumstances like resizing uncacheable dynamically-generated
  8998. * images.
  8999. */
  9000. compression?: "fast";
  9001. }
  9002. interface RequestInitCfPropertiesImageMinify {
  9003. javascript?: boolean;
  9004. css?: boolean;
  9005. html?: boolean;
  9006. }
  9007. interface RequestInitCfPropertiesR2 {
  9008. /**
  9009. * Colo id of bucket that an object is stored in
  9010. */
  9011. bucketColoId?: number;
  9012. }
  9013. /**
  9014. * Request metadata provided by Cloudflare's edge.
  9015. */
  9016. type IncomingRequestCfProperties<HostMetadata = unknown> = IncomingRequestCfPropertiesBase & IncomingRequestCfPropertiesBotManagementEnterprise & IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<HostMetadata> & IncomingRequestCfPropertiesGeographicInformation & IncomingRequestCfPropertiesCloudflareAccessOrApiShield;
  9017. interface IncomingRequestCfPropertiesBase extends Record<string, unknown> {
  9018. /**
  9019. * [ASN](https://www.iana.org/assignments/as-numbers/as-numbers.xhtml) of the incoming request.
  9020. *
  9021. * @example 395747
  9022. */
  9023. asn?: number;
  9024. /**
  9025. * The organization which owns the ASN of the incoming request.
  9026. *
  9027. * @example "Google Cloud"
  9028. */
  9029. asOrganization?: string;
  9030. /**
  9031. * The original value of the `Accept-Encoding` header if Cloudflare modified it.
  9032. *
  9033. * @example "gzip, deflate, br"
  9034. */
  9035. clientAcceptEncoding?: string;
  9036. /**
  9037. * The number of milliseconds it took for the request to reach your worker.
  9038. *
  9039. * @example 22
  9040. */
  9041. clientTcpRtt?: number;
  9042. /**
  9043. * The three-letter [IATA](https://en.wikipedia.org/wiki/IATA_airport_code)
  9044. * airport code of the data center that the request hit.
  9045. *
  9046. * @example "DFW"
  9047. */
  9048. colo: string;
  9049. /**
  9050. * Represents the upstream's response to a
  9051. * [TCP `keepalive` message](https://tldp.org/HOWTO/TCP-Keepalive-HOWTO/overview.html)
  9052. * from cloudflare.
  9053. *
  9054. * For workers with no upstream, this will always be `1`.
  9055. *
  9056. * @example 3
  9057. */
  9058. edgeRequestKeepAliveStatus: IncomingRequestCfPropertiesEdgeRequestKeepAliveStatus;
  9059. /**
  9060. * The HTTP Protocol the request used.
  9061. *
  9062. * @example "HTTP/2"
  9063. */
  9064. httpProtocol: string;
  9065. /**
  9066. * The browser-requested prioritization information in the request object.
  9067. *
  9068. * If no information was set, defaults to the empty string `""`
  9069. *
  9070. * @example "weight=192;exclusive=0;group=3;group-weight=127"
  9071. * @default ""
  9072. */
  9073. requestPriority: string;
  9074. /**
  9075. * The TLS version of the connection to Cloudflare.
  9076. * In requests served over plaintext (without TLS), this property is the empty string `""`.
  9077. *
  9078. * @example "TLSv1.3"
  9079. */
  9080. tlsVersion: string;
  9081. /**
  9082. * The cipher for the connection to Cloudflare.
  9083. * In requests served over plaintext (without TLS), this property is the empty string `""`.
  9084. *
  9085. * @example "AEAD-AES128-GCM-SHA256"
  9086. */
  9087. tlsCipher: string;
  9088. /**
  9089. * Metadata containing the [`HELLO`](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2) and [`FINISHED`](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9) messages from this request's TLS handshake.
  9090. *
  9091. * If the incoming request was served over plaintext (without TLS) this field is undefined.
  9092. */
  9093. tlsExportedAuthenticator?: IncomingRequestCfPropertiesExportedAuthenticatorMetadata;
  9094. }
  9095. interface IncomingRequestCfPropertiesBotManagementBase {
  9096. /**
  9097. * Cloudflare’s [level of certainty](https://developers.cloudflare.com/bots/concepts/bot-score/) that a request comes from a bot,
  9098. * represented as an integer percentage between `1` (almost certainly a bot) and `99` (almost certainly human).
  9099. *
  9100. * @example 54
  9101. */
  9102. score: number;
  9103. /**
  9104. * A boolean value that is true if the request comes from a good bot, like Google or Bing.
  9105. * Most customers choose to allow this traffic. For more details, see [Traffic from known bots](https://developers.cloudflare.com/firewall/known-issues-and-faq/#how-does-firewall-rules-handle-traffic-from-known-bots).
  9106. */
  9107. verifiedBot: boolean;
  9108. /**
  9109. * A boolean value that is true if the request originates from a
  9110. * Cloudflare-verified proxy service.
  9111. */
  9112. corporateProxy: boolean;
  9113. /**
  9114. * A boolean value that's true if the request matches [file extensions](https://developers.cloudflare.com/bots/reference/static-resources/) for many types of static resources.
  9115. */
  9116. staticResource: boolean;
  9117. /**
  9118. * List of IDs that correlate to the Bot Management heuristic detections made on a request (you can have multiple heuristic detections on the same request).
  9119. */
  9120. detectionIds: number[];
  9121. }
  9122. interface IncomingRequestCfPropertiesBotManagement {
  9123. /**
  9124. * Results of Cloudflare's Bot Management analysis
  9125. */
  9126. botManagement: IncomingRequestCfPropertiesBotManagementBase;
  9127. /**
  9128. * Duplicate of `botManagement.score`.
  9129. *
  9130. * @deprecated
  9131. */
  9132. clientTrustScore: number;
  9133. }
  9134. interface IncomingRequestCfPropertiesBotManagementEnterprise extends IncomingRequestCfPropertiesBotManagement {
  9135. /**
  9136. * Results of Cloudflare's Bot Management analysis
  9137. */
  9138. botManagement: IncomingRequestCfPropertiesBotManagementBase & {
  9139. /**
  9140. * A [JA3 Fingerprint](https://developers.cloudflare.com/bots/concepts/ja3-fingerprint/) to help profile specific SSL/TLS clients
  9141. * across different destination IPs, Ports, and X509 certificates.
  9142. */
  9143. ja3Hash: string;
  9144. };
  9145. }
  9146. interface IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<HostMetadata> {
  9147. /**
  9148. * Custom metadata set per-host in [Cloudflare for SaaS](https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/).
  9149. *
  9150. * This field is only present if you have Cloudflare for SaaS enabled on your account
  9151. * and you have followed the [required steps to enable it]((https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/domain-support/custom-metadata/)).
  9152. */
  9153. hostMetadata?: HostMetadata;
  9154. }
  9155. interface IncomingRequestCfPropertiesCloudflareAccessOrApiShield {
  9156. /**
  9157. * Information about the client certificate presented to Cloudflare.
  9158. *
  9159. * This is populated when the incoming request is served over TLS using
  9160. * either Cloudflare Access or API Shield (mTLS)
  9161. * and the presented SSL certificate has a valid
  9162. * [Certificate Serial Number](https://ldapwiki.com/wiki/Certificate%20Serial%20Number)
  9163. * (i.e., not `null` or `""`).
  9164. *
  9165. * Otherwise, a set of placeholder values are used.
  9166. *
  9167. * The property `certPresented` will be set to `"1"` when
  9168. * the object is populated (i.e. the above conditions were met).
  9169. */
  9170. tlsClientAuth: IncomingRequestCfPropertiesTLSClientAuth | IncomingRequestCfPropertiesTLSClientAuthPlaceholder;
  9171. }
  9172. /**
  9173. * Metadata about the request's TLS handshake
  9174. */
  9175. interface IncomingRequestCfPropertiesExportedAuthenticatorMetadata {
  9176. /**
  9177. * The client's [`HELLO` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2), encoded in hexadecimal
  9178. *
  9179. * @example "44372ba35fa1270921d318f34c12f155dc87b682cf36a790cfaa3ba8737a1b5d"
  9180. */
  9181. clientHandshake: string;
  9182. /**
  9183. * The server's [`HELLO` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2), encoded in hexadecimal
  9184. *
  9185. * @example "44372ba35fa1270921d318f34c12f155dc87b682cf36a790cfaa3ba8737a1b5d"
  9186. */
  9187. serverHandshake: string;
  9188. /**
  9189. * The client's [`FINISHED` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9), encoded in hexadecimal
  9190. *
  9191. * @example "084ee802fe1348f688220e2a6040a05b2199a761f33cf753abb1b006792d3f8b"
  9192. */
  9193. clientFinished: string;
  9194. /**
  9195. * The server's [`FINISHED` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9), encoded in hexadecimal
  9196. *
  9197. * @example "084ee802fe1348f688220e2a6040a05b2199a761f33cf753abb1b006792d3f8b"
  9198. */
  9199. serverFinished: string;
  9200. }
  9201. /**
  9202. * Geographic data about the request's origin.
  9203. */
  9204. interface IncomingRequestCfPropertiesGeographicInformation {
  9205. /**
  9206. * The [ISO 3166-1 Alpha 2](https://www.iso.org/iso-3166-country-codes.html) country code the request originated from.
  9207. *
  9208. * If your worker is [configured to accept TOR connections](https://support.cloudflare.com/hc/en-us/articles/203306930-Understanding-Cloudflare-Tor-support-and-Onion-Routing), this may also be `"T1"`, indicating a request that originated over TOR.
  9209. *
  9210. * If Cloudflare is unable to determine where the request originated this property is omitted.
  9211. *
  9212. * The country code `"T1"` is used for requests originating on TOR.
  9213. *
  9214. * @example "GB"
  9215. */
  9216. country?: Iso3166Alpha2Code | "T1";
  9217. /**
  9218. * If present, this property indicates that the request originated in the EU
  9219. *
  9220. * @example "1"
  9221. */
  9222. isEUCountry?: "1";
  9223. /**
  9224. * A two-letter code indicating the continent the request originated from.
  9225. *
  9226. * @example "AN"
  9227. */
  9228. continent?: ContinentCode;
  9229. /**
  9230. * The city the request originated from
  9231. *
  9232. * @example "Austin"
  9233. */
  9234. city?: string;
  9235. /**
  9236. * Postal code of the incoming request
  9237. *
  9238. * @example "78701"
  9239. */
  9240. postalCode?: string;
  9241. /**
  9242. * Latitude of the incoming request
  9243. *
  9244. * @example "30.27130"
  9245. */
  9246. latitude?: string;
  9247. /**
  9248. * Longitude of the incoming request
  9249. *
  9250. * @example "-97.74260"
  9251. */
  9252. longitude?: string;
  9253. /**
  9254. * Timezone of the incoming request
  9255. *
  9256. * @example "America/Chicago"
  9257. */
  9258. timezone?: string;
  9259. /**
  9260. * If known, the ISO 3166-2 name for the first level region associated with
  9261. * the IP address of the incoming request
  9262. *
  9263. * @example "Texas"
  9264. */
  9265. region?: string;
  9266. /**
  9267. * If known, the ISO 3166-2 code for the first-level region associated with
  9268. * the IP address of the incoming request
  9269. *
  9270. * @example "TX"
  9271. */
  9272. regionCode?: string;
  9273. /**
  9274. * Metro code (DMA) of the incoming request
  9275. *
  9276. * @example "635"
  9277. */
  9278. metroCode?: string;
  9279. }
  9280. /** Data about the incoming request's TLS certificate */
  9281. interface IncomingRequestCfPropertiesTLSClientAuth {
  9282. /** Always `"1"`, indicating that the certificate was presented */
  9283. certPresented: "1";
  9284. /**
  9285. * Result of certificate verification.
  9286. *
  9287. * @example "FAILED:self signed certificate"
  9288. */
  9289. certVerified: Exclude<CertVerificationStatus, "NONE">;
  9290. /** The presented certificate's revokation status.
  9291. *
  9292. * - A value of `"1"` indicates the certificate has been revoked
  9293. * - A value of `"0"` indicates the certificate has not been revoked
  9294. */
  9295. certRevoked: "1" | "0";
  9296. /**
  9297. * The certificate issuer's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html)
  9298. *
  9299. * @example "CN=cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
  9300. */
  9301. certIssuerDN: string;
  9302. /**
  9303. * The certificate subject's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html)
  9304. *
  9305. * @example "CN=*.cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
  9306. */
  9307. certSubjectDN: string;
  9308. /**
  9309. * The certificate issuer's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html) ([RFC 2253](https://www.rfc-editor.org/rfc/rfc2253.html) formatted)
  9310. *
  9311. * @example "CN=cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
  9312. */
  9313. certIssuerDNRFC2253: string;
  9314. /**
  9315. * The certificate subject's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html) ([RFC 2253](https://www.rfc-editor.org/rfc/rfc2253.html) formatted)
  9316. *
  9317. * @example "CN=*.cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
  9318. */
  9319. certSubjectDNRFC2253: string;
  9320. /** The certificate issuer's distinguished name (legacy policies) */
  9321. certIssuerDNLegacy: string;
  9322. /** The certificate subject's distinguished name (legacy policies) */
  9323. certSubjectDNLegacy: string;
  9324. /**
  9325. * The certificate's serial number
  9326. *
  9327. * @example "00936EACBE07F201DF"
  9328. */
  9329. certSerial: string;
  9330. /**
  9331. * The certificate issuer's serial number
  9332. *
  9333. * @example "2489002934BDFEA34"
  9334. */
  9335. certIssuerSerial: string;
  9336. /**
  9337. * The certificate's Subject Key Identifier
  9338. *
  9339. * @example "BB:AF:7E:02:3D:FA:A6:F1:3C:84:8E:AD:EE:38:98:EC:D9:32:32:D4"
  9340. */
  9341. certSKI: string;
  9342. /**
  9343. * The certificate issuer's Subject Key Identifier
  9344. *
  9345. * @example "BB:AF:7E:02:3D:FA:A6:F1:3C:84:8E:AD:EE:38:98:EC:D9:32:32:D4"
  9346. */
  9347. certIssuerSKI: string;
  9348. /**
  9349. * The certificate's SHA-1 fingerprint
  9350. *
  9351. * @example "6b9109f323999e52259cda7373ff0b4d26bd232e"
  9352. */
  9353. certFingerprintSHA1: string;
  9354. /**
  9355. * The certificate's SHA-256 fingerprint
  9356. *
  9357. * @example "acf77cf37b4156a2708e34c4eb755f9b5dbbe5ebb55adfec8f11493438d19e6ad3f157f81fa3b98278453d5652b0c1fd1d71e5695ae4d709803a4d3f39de9dea"
  9358. */
  9359. certFingerprintSHA256: string;
  9360. /**
  9361. * The effective starting date of the certificate
  9362. *
  9363. * @example "Dec 22 19:39:00 2018 GMT"
  9364. */
  9365. certNotBefore: string;
  9366. /**
  9367. * The effective expiration date of the certificate
  9368. *
  9369. * @example "Dec 22 19:39:00 2018 GMT"
  9370. */
  9371. certNotAfter: string;
  9372. }
  9373. /** Placeholder values for TLS Client Authorization */
  9374. interface IncomingRequestCfPropertiesTLSClientAuthPlaceholder {
  9375. certPresented: "0";
  9376. certVerified: "NONE";
  9377. certRevoked: "0";
  9378. certIssuerDN: "";
  9379. certSubjectDN: "";
  9380. certIssuerDNRFC2253: "";
  9381. certSubjectDNRFC2253: "";
  9382. certIssuerDNLegacy: "";
  9383. certSubjectDNLegacy: "";
  9384. certSerial: "";
  9385. certIssuerSerial: "";
  9386. certSKI: "";
  9387. certIssuerSKI: "";
  9388. certFingerprintSHA1: "";
  9389. certFingerprintSHA256: "";
  9390. certNotBefore: "";
  9391. certNotAfter: "";
  9392. }
  9393. /** Possible outcomes of TLS verification */
  9394. declare type CertVerificationStatus =
  9395. /** Authentication succeeded */
  9396. "SUCCESS"
  9397. /** No certificate was presented */
  9398. | "NONE"
  9399. /** Failed because the certificate was self-signed */
  9400. | "FAILED:self signed certificate"
  9401. /** Failed because the certificate failed a trust chain check */
  9402. | "FAILED:unable to verify the first certificate"
  9403. /** Failed because the certificate not yet valid */
  9404. | "FAILED:certificate is not yet valid"
  9405. /** Failed because the certificate is expired */
  9406. | "FAILED:certificate has expired"
  9407. /** Failed for another unspecified reason */
  9408. | "FAILED";
  9409. /**
  9410. * An upstream endpoint's response to a TCP `keepalive` message from Cloudflare.
  9411. */
  9412. declare type IncomingRequestCfPropertiesEdgeRequestKeepAliveStatus = 0 /** Unknown */ | 1 /** no keepalives (not found) */ | 2 /** no connection re-use, opening keepalive connection failed */ | 3 /** no connection re-use, keepalive accepted and saved */ | 4 /** connection re-use, refused by the origin server (`TCP FIN`) */ | 5; /** connection re-use, accepted by the origin server */
  9413. /** ISO 3166-1 Alpha-2 codes */
  9414. declare type Iso3166Alpha2Code = "AD" | "AE" | "AF" | "AG" | "AI" | "AL" | "AM" | "AO" | "AQ" | "AR" | "AS" | "AT" | "AU" | "AW" | "AX" | "AZ" | "BA" | "BB" | "BD" | "BE" | "BF" | "BG" | "BH" | "BI" | "BJ" | "BL" | "BM" | "BN" | "BO" | "BQ" | "BR" | "BS" | "BT" | "BV" | "BW" | "BY" | "BZ" | "CA" | "CC" | "CD" | "CF" | "CG" | "CH" | "CI" | "CK" | "CL" | "CM" | "CN" | "CO" | "CR" | "CU" | "CV" | "CW" | "CX" | "CY" | "CZ" | "DE" | "DJ" | "DK" | "DM" | "DO" | "DZ" | "EC" | "EE" | "EG" | "EH" | "ER" | "ES" | "ET" | "FI" | "FJ" | "FK" | "FM" | "FO" | "FR" | "GA" | "GB" | "GD" | "GE" | "GF" | "GG" | "GH" | "GI" | "GL" | "GM" | "GN" | "GP" | "GQ" | "GR" | "GS" | "GT" | "GU" | "GW" | "GY" | "HK" | "HM" | "HN" | "HR" | "HT" | "HU" | "ID" | "IE" | "IL" | "IM" | "IN" | "IO" | "IQ" | "IR" | "IS" | "IT" | "JE" | "JM" | "JO" | "JP" | "KE" | "KG" | "KH" | "KI" | "KM" | "KN" | "KP" | "KR" | "KW" | "KY" | "KZ" | "LA" | "LB" | "LC" | "LI" | "LK" | "LR" | "LS" | "LT" | "LU" | "LV" | "LY" | "MA" | "MC" | "MD" | "ME" | "MF" | "MG" | "MH" | "MK" | "ML" | "MM" | "MN" | "MO" | "MP" | "MQ" | "MR" | "MS" | "MT" | "MU" | "MV" | "MW" | "MX" | "MY" | "MZ" | "NA" | "NC" | "NE" | "NF" | "NG" | "NI" | "NL" | "NO" | "NP" | "NR" | "NU" | "NZ" | "OM" | "PA" | "PE" | "PF" | "PG" | "PH" | "PK" | "PL" | "PM" | "PN" | "PR" | "PS" | "PT" | "PW" | "PY" | "QA" | "RE" | "RO" | "RS" | "RU" | "RW" | "SA" | "SB" | "SC" | "SD" | "SE" | "SG" | "SH" | "SI" | "SJ" | "SK" | "SL" | "SM" | "SN" | "SO" | "SR" | "SS" | "ST" | "SV" | "SX" | "SY" | "SZ" | "TC" | "TD" | "TF" | "TG" | "TH" | "TJ" | "TK" | "TL" | "TM" | "TN" | "TO" | "TR" | "TT" | "TV" | "TW" | "TZ" | "UA" | "UG" | "UM" | "US" | "UY" | "UZ" | "VA" | "VC" | "VE" | "VG" | "VI" | "VN" | "VU" | "WF" | "WS" | "YE" | "YT" | "ZA" | "ZM" | "ZW";
  9415. /** The 2-letter continent codes Cloudflare uses */
  9416. declare type ContinentCode = "AF" | "AN" | "AS" | "EU" | "NA" | "OC" | "SA";
  9417. type CfProperties<HostMetadata = unknown> = IncomingRequestCfProperties<HostMetadata> | RequestInitCfProperties;
  9418. interface D1Meta {
  9419. duration: number;
  9420. size_after: number;
  9421. rows_read: number;
  9422. rows_written: number;
  9423. last_row_id: number;
  9424. changed_db: boolean;
  9425. changes: number;
  9426. /**
  9427. * The region of the database instance that executed the query.
  9428. */
  9429. served_by_region?: string;
  9430. /**
  9431. * True if-and-only-if the database instance that executed the query was the primary.
  9432. */
  9433. served_by_primary?: boolean;
  9434. timings?: {
  9435. /**
  9436. * The duration of the SQL query execution by the database instance. It doesn't include any network time.
  9437. */
  9438. sql_duration_ms: number;
  9439. };
  9440. /**
  9441. * Number of total attempts to execute the query, due to automatic retries.
  9442. * Note: All other fields in the response like `timings` only apply to the last attempt.
  9443. */
  9444. total_attempts?: number;
  9445. }
  9446. interface D1Response {
  9447. success: true;
  9448. meta: D1Meta & Record<string, unknown>;
  9449. error?: never;
  9450. }
  9451. type D1Result<T = unknown> = D1Response & {
  9452. results: T[];
  9453. };
  9454. interface D1ExecResult {
  9455. count: number;
  9456. duration: number;
  9457. }
  9458. type D1SessionConstraint =
  9459. // Indicates that the first query should go to the primary, and the rest queries
  9460. // using the same D1DatabaseSession will go to any replica that is consistent with
  9461. // the bookmark maintained by the session (returned by the first query).
  9462. 'first-primary'
  9463. // Indicates that the first query can go anywhere (primary or replica), and the rest queries
  9464. // using the same D1DatabaseSession will go to any replica that is consistent with
  9465. // the bookmark maintained by the session (returned by the first query).
  9466. | 'first-unconstrained';
  9467. type D1SessionBookmark = string;
  9468. declare abstract class D1Database {
  9469. prepare(query: string): D1PreparedStatement;
  9470. batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>;
  9471. exec(query: string): Promise<D1ExecResult>;
  9472. /**
  9473. * Creates a new D1 Session anchored at the given constraint or the bookmark.
  9474. * All queries executed using the created session will have sequential consistency,
  9475. * meaning that all writes done through the session will be visible in subsequent reads.
  9476. *
  9477. * @param constraintOrBookmark Either the session constraint or the explicit bookmark to anchor the created session.
  9478. */
  9479. withSession(constraintOrBookmark?: D1SessionBookmark | D1SessionConstraint): D1DatabaseSession;
  9480. /**
  9481. * @deprecated dump() will be removed soon, only applies to deprecated alpha v1 databases.
  9482. */
  9483. dump(): Promise<ArrayBuffer>;
  9484. }
  9485. declare abstract class D1DatabaseSession {
  9486. prepare(query: string): D1PreparedStatement;
  9487. batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>;
  9488. /**
  9489. * @returns The latest session bookmark across all executed queries on the session.
  9490. * If no query has been executed yet, `null` is returned.
  9491. */
  9492. getBookmark(): D1SessionBookmark | null;
  9493. }
  9494. declare abstract class D1PreparedStatement {
  9495. bind(...values: unknown[]): D1PreparedStatement;
  9496. first<T = unknown>(colName: string): Promise<T | null>;
  9497. first<T = Record<string, unknown>>(): Promise<T | null>;
  9498. run<T = Record<string, unknown>>(): Promise<D1Result<T>>;
  9499. all<T = Record<string, unknown>>(): Promise<D1Result<T>>;
  9500. raw<T = unknown[]>(options: {
  9501. columnNames: true;
  9502. }): Promise<[
  9503. string[],
  9504. ...T[]
  9505. ]>;
  9506. raw<T = unknown[]>(options?: {
  9507. columnNames?: false;
  9508. }): Promise<T[]>;
  9509. }
  9510. // `Disposable` was added to TypeScript's standard lib types in version 5.2.
  9511. // To support older TypeScript versions, define an empty `Disposable` interface.
  9512. // Users won't be able to use `using`/`Symbol.dispose` without upgrading to 5.2,
  9513. // but this will ensure type checking on older versions still passes.
  9514. // TypeScript's interface merging will ensure our empty interface is effectively
  9515. // ignored when `Disposable` is included in the standard lib.
  9516. interface Disposable {
  9517. }
  9518. /**
  9519. * An email message that can be sent from a Worker.
  9520. */
  9521. interface EmailMessage {
  9522. /**
  9523. * Envelope From attribute of the email message.
  9524. */
  9525. readonly from: string;
  9526. /**
  9527. * Envelope To attribute of the email message.
  9528. */
  9529. readonly to: string;
  9530. }
  9531. /**
  9532. * An email message that is sent to a consumer Worker and can be rejected/forwarded.
  9533. */
  9534. interface ForwardableEmailMessage extends EmailMessage {
  9535. /**
  9536. * Stream of the email message content.
  9537. */
  9538. readonly raw: ReadableStream<Uint8Array>;
  9539. /**
  9540. * An [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
  9541. */
  9542. readonly headers: Headers;
  9543. /**
  9544. * Size of the email message content.
  9545. */
  9546. readonly rawSize: number;
  9547. /**
  9548. * Reject this email message by returning a permanent SMTP error back to the connecting client including the given reason.
  9549. * @param reason The reject reason.
  9550. * @returns void
  9551. */
  9552. setReject(reason: string): void;
  9553. /**
  9554. * Forward this email message to a verified destination address of the account.
  9555. * @param rcptTo Verified destination address.
  9556. * @param headers A [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
  9557. * @returns A promise that resolves when the email message is forwarded.
  9558. */
  9559. forward(rcptTo: string, headers?: Headers): Promise<void>;
  9560. /**
  9561. * Reply to the sender of this email message with a new EmailMessage object.
  9562. * @param message The reply message.
  9563. * @returns A promise that resolves when the email message is replied.
  9564. */
  9565. reply(message: EmailMessage): Promise<void>;
  9566. }
  9567. /**
  9568. * A binding that allows a Worker to send email messages.
  9569. */
  9570. interface SendEmail {
  9571. send(message: EmailMessage): Promise<void>;
  9572. }
  9573. declare abstract class EmailEvent extends ExtendableEvent {
  9574. readonly message: ForwardableEmailMessage;
  9575. }
  9576. declare type EmailExportedHandler<Env = unknown> = (message: ForwardableEmailMessage, env: Env, ctx: ExecutionContext) => void | Promise<void>;
  9577. declare module "cloudflare:email" {
  9578. let _EmailMessage: {
  9579. prototype: EmailMessage;
  9580. new (from: string, to: string, raw: ReadableStream | string): EmailMessage;
  9581. };
  9582. export { _EmailMessage as EmailMessage };
  9583. }
  9584. /**
  9585. * Hello World binding to serve as an explanatory example. DO NOT USE
  9586. */
  9587. interface HelloWorldBinding {
  9588. /**
  9589. * Retrieve the current stored value
  9590. */
  9591. get(): Promise<{
  9592. value: string;
  9593. ms?: number;
  9594. }>;
  9595. /**
  9596. * Set a new stored value
  9597. */
  9598. set(value: string): Promise<void>;
  9599. }
  9600. interface Hyperdrive {
  9601. /**
  9602. * Connect directly to Hyperdrive as if it's your database, returning a TCP socket.
  9603. *
  9604. * Calling this method returns an identical socket to if you call
  9605. * `connect("host:port")` using the `host` and `port` fields from this object.
  9606. * Pick whichever approach works better with your preferred DB client library.
  9607. *
  9608. * Note that this socket is not yet authenticated -- it's expected that your
  9609. * code (or preferably, the client library of your choice) will authenticate
  9610. * using the information in this class's readonly fields.
  9611. */
  9612. connect(): Socket;
  9613. /**
  9614. * A valid DB connection string that can be passed straight into the typical
  9615. * client library/driver/ORM. This will typically be the easiest way to use
  9616. * Hyperdrive.
  9617. */
  9618. readonly connectionString: string;
  9619. /*
  9620. * A randomly generated hostname that is only valid within the context of the
  9621. * currently running Worker which, when passed into `connect()` function from
  9622. * the "cloudflare:sockets" module, will connect to the Hyperdrive instance
  9623. * for your database.
  9624. */
  9625. readonly host: string;
  9626. /*
  9627. * The port that must be paired the the host field when connecting.
  9628. */
  9629. readonly port: number;
  9630. /*
  9631. * The username to use when authenticating to your database via Hyperdrive.
  9632. * Unlike the host and password, this will be the same every time
  9633. */
  9634. readonly user: string;
  9635. /*
  9636. * The randomly generated password to use when authenticating to your
  9637. * database via Hyperdrive. Like the host field, this password is only valid
  9638. * within the context of the currently running Worker instance from which
  9639. * it's read.
  9640. */
  9641. readonly password: string;
  9642. /*
  9643. * The name of the database to connect to.
  9644. */
  9645. readonly database: string;
  9646. }
  9647. // Copyright (c) 2024 Cloudflare, Inc.
  9648. // Licensed under the Apache 2.0 license found in the LICENSE file or at:
  9649. // https://opensource.org/licenses/Apache-2.0
  9650. type ImageInfoResponse = {
  9651. format: 'image/svg+xml';
  9652. } | {
  9653. format: string;
  9654. fileSize: number;
  9655. width: number;
  9656. height: number;
  9657. };
  9658. type ImageTransform = {
  9659. width?: number;
  9660. height?: number;
  9661. background?: string;
  9662. blur?: number;
  9663. border?: {
  9664. color?: string;
  9665. width?: number;
  9666. } | {
  9667. top?: number;
  9668. bottom?: number;
  9669. left?: number;
  9670. right?: number;
  9671. };
  9672. brightness?: number;
  9673. contrast?: number;
  9674. fit?: 'scale-down' | 'contain' | 'pad' | 'squeeze' | 'cover' | 'crop';
  9675. flip?: 'h' | 'v' | 'hv';
  9676. gamma?: number;
  9677. segment?: 'foreground';
  9678. gravity?: 'face' | 'left' | 'right' | 'top' | 'bottom' | 'center' | 'auto' | 'entropy' | {
  9679. x?: number;
  9680. y?: number;
  9681. mode: 'remainder' | 'box-center';
  9682. };
  9683. rotate?: 0 | 90 | 180 | 270;
  9684. saturation?: number;
  9685. sharpen?: number;
  9686. trim?: 'border' | {
  9687. top?: number;
  9688. bottom?: number;
  9689. left?: number;
  9690. right?: number;
  9691. width?: number;
  9692. height?: number;
  9693. border?: boolean | {
  9694. color?: string;
  9695. tolerance?: number;
  9696. keep?: number;
  9697. };
  9698. };
  9699. };
  9700. type ImageDrawOptions = {
  9701. opacity?: number;
  9702. repeat?: boolean | string;
  9703. top?: number;
  9704. left?: number;
  9705. bottom?: number;
  9706. right?: number;
  9707. };
  9708. type ImageInputOptions = {
  9709. encoding?: 'base64';
  9710. };
  9711. type ImageOutputOptions = {
  9712. format: 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp' | 'image/avif' | 'rgb' | 'rgba';
  9713. quality?: number;
  9714. background?: string;
  9715. anim?: boolean;
  9716. };
  9717. interface ImagesBinding {
  9718. /**
  9719. * Get image metadata (type, width and height)
  9720. * @throws {@link ImagesError} with code 9412 if input is not an image
  9721. * @param stream The image bytes
  9722. */
  9723. info(stream: ReadableStream<Uint8Array>, options?: ImageInputOptions): Promise<ImageInfoResponse>;
  9724. /**
  9725. * Begin applying a series of transformations to an image
  9726. * @param stream The image bytes
  9727. * @returns A transform handle
  9728. */
  9729. input(stream: ReadableStream<Uint8Array>, options?: ImageInputOptions): ImageTransformer;
  9730. }
  9731. interface ImageTransformer {
  9732. /**
  9733. * Apply transform next, returning a transform handle.
  9734. * You can then apply more transformations, draw, or retrieve the output.
  9735. * @param transform
  9736. */
  9737. transform(transform: ImageTransform): ImageTransformer;
  9738. /**
  9739. * Draw an image on this transformer, returning a transform handle.
  9740. * You can then apply more transformations, draw, or retrieve the output.
  9741. * @param image The image (or transformer that will give the image) to draw
  9742. * @param options The options configuring how to draw the image
  9743. */
  9744. draw(image: ReadableStream<Uint8Array> | ImageTransformer, options?: ImageDrawOptions): ImageTransformer;
  9745. /**
  9746. * Retrieve the image that results from applying the transforms to the
  9747. * provided input
  9748. * @param options Options that apply to the output e.g. output format
  9749. */
  9750. output(options: ImageOutputOptions): Promise<ImageTransformationResult>;
  9751. }
  9752. type ImageTransformationOutputOptions = {
  9753. encoding?: 'base64';
  9754. };
  9755. interface ImageTransformationResult {
  9756. /**
  9757. * The image as a response, ready to store in cache or return to users
  9758. */
  9759. response(): Response;
  9760. /**
  9761. * The content type of the returned image
  9762. */
  9763. contentType(): string;
  9764. /**
  9765. * The bytes of the response
  9766. */
  9767. image(options?: ImageTransformationOutputOptions): ReadableStream<Uint8Array>;
  9768. }
  9769. interface ImagesError extends Error {
  9770. readonly code: number;
  9771. readonly message: string;
  9772. readonly stack?: string;
  9773. }
  9774. /**
  9775. * Media binding for transforming media streams.
  9776. * Provides the entry point for media transformation operations.
  9777. */
  9778. interface MediaBinding {
  9779. /**
  9780. * Creates a media transformer from an input stream.
  9781. * @param media - The input media bytes
  9782. * @returns A MediaTransformer instance for applying transformations
  9783. */
  9784. input(media: ReadableStream<Uint8Array>): MediaTransformer;
  9785. }
  9786. /**
  9787. * Media transformer for applying transformation operations to media content.
  9788. * Handles sizing, fitting, and other input transformation parameters.
  9789. */
  9790. interface MediaTransformer {
  9791. /**
  9792. * Applies transformation options to the media content.
  9793. * @param transform - Configuration for how the media should be transformed
  9794. * @returns A generator for producing the transformed media output
  9795. */
  9796. transform(transform: MediaTransformationInputOptions): MediaTransformationGenerator;
  9797. }
  9798. /**
  9799. * Generator for producing media transformation results.
  9800. * Configures the output format and parameters for the transformed media.
  9801. */
  9802. interface MediaTransformationGenerator {
  9803. /**
  9804. * Generates the final media output with specified options.
  9805. * @param output - Configuration for the output format and parameters
  9806. * @returns The final transformation result containing the transformed media
  9807. */
  9808. output(output: MediaTransformationOutputOptions): MediaTransformationResult;
  9809. }
  9810. /**
  9811. * Result of a media transformation operation.
  9812. * Provides multiple ways to access the transformed media content.
  9813. */
  9814. interface MediaTransformationResult {
  9815. /**
  9816. * Returns the transformed media as a readable stream of bytes.
  9817. * @returns A stream containing the transformed media data
  9818. */
  9819. media(): ReadableStream<Uint8Array>;
  9820. /**
  9821. * Returns the transformed media as an HTTP response object.
  9822. * @returns The transformed media as a Response, ready to store in cache or return to users
  9823. */
  9824. response(): Response;
  9825. /**
  9826. * Returns the MIME type of the transformed media.
  9827. * @returns The content type string (e.g., 'image/jpeg', 'video/mp4')
  9828. */
  9829. contentType(): string;
  9830. }
  9831. /**
  9832. * Configuration options for transforming media input.
  9833. * Controls how the media should be resized and fitted.
  9834. */
  9835. type MediaTransformationInputOptions = {
  9836. /** How the media should be resized to fit the specified dimensions */
  9837. fit?: 'contain' | 'cover' | 'scale-down';
  9838. /** Target width in pixels */
  9839. width?: number;
  9840. /** Target height in pixels */
  9841. height?: number;
  9842. };
  9843. /**
  9844. * Configuration options for Media Transformations output.
  9845. * Controls the format, timing, and type of the generated output.
  9846. */
  9847. type MediaTransformationOutputOptions = {
  9848. /**
  9849. * Output mode determining the type of media to generate
  9850. */
  9851. mode?: 'video' | 'spritesheet' | 'frame' | 'audio';
  9852. /** Whether to include audio in the output */
  9853. audio?: boolean;
  9854. /**
  9855. * Starting timestamp for frame extraction or start time for clips. (e.g. '2s').
  9856. */
  9857. time?: string;
  9858. /**
  9859. * Duration for video clips, audio extraction, and spritesheet generation (e.g. '5s').
  9860. */
  9861. duration?: string;
  9862. /**
  9863. * Number of frames in the spritesheet.
  9864. */
  9865. imageCount?: number;
  9866. /**
  9867. * Output format for the generated media.
  9868. */
  9869. format?: 'jpg' | 'png' | 'm4a';
  9870. };
  9871. /**
  9872. * Error object for media transformation operations.
  9873. * Extends the standard Error interface with additional media-specific information.
  9874. */
  9875. interface MediaError extends Error {
  9876. readonly code: number;
  9877. readonly message: string;
  9878. readonly stack?: string;
  9879. }
  9880. declare module 'cloudflare:node' {
  9881. interface NodeStyleServer {
  9882. listen(...args: unknown[]): this;
  9883. address(): {
  9884. port?: number | null | undefined;
  9885. };
  9886. }
  9887. export function httpServerHandler(port: number): ExportedHandler;
  9888. export function httpServerHandler(options: {
  9889. port: number;
  9890. }): ExportedHandler;
  9891. export function httpServerHandler(server: NodeStyleServer): ExportedHandler;
  9892. }
  9893. type Params<P extends string = any> = Record<P, string | string[]>;
  9894. type EventContext<Env, P extends string, Data> = {
  9895. request: Request<unknown, IncomingRequestCfProperties<unknown>>;
  9896. functionPath: string;
  9897. waitUntil: (promise: Promise<any>) => void;
  9898. passThroughOnException: () => void;
  9899. next: (input?: Request | string, init?: RequestInit) => Promise<Response>;
  9900. env: Env & {
  9901. ASSETS: {
  9902. fetch: typeof fetch;
  9903. };
  9904. };
  9905. params: Params<P>;
  9906. data: Data;
  9907. };
  9908. type PagesFunction<Env = unknown, Params extends string = any, Data extends Record<string, unknown> = Record<string, unknown>> = (context: EventContext<Env, Params, Data>) => Response | Promise<Response>;
  9909. type EventPluginContext<Env, P extends string, Data, PluginArgs> = {
  9910. request: Request<unknown, IncomingRequestCfProperties<unknown>>;
  9911. functionPath: string;
  9912. waitUntil: (promise: Promise<any>) => void;
  9913. passThroughOnException: () => void;
  9914. next: (input?: Request | string, init?: RequestInit) => Promise<Response>;
  9915. env: Env & {
  9916. ASSETS: {
  9917. fetch: typeof fetch;
  9918. };
  9919. };
  9920. params: Params<P>;
  9921. data: Data;
  9922. pluginArgs: PluginArgs;
  9923. };
  9924. type PagesPluginFunction<Env = unknown, Params extends string = any, Data extends Record<string, unknown> = Record<string, unknown>, PluginArgs = unknown> = (context: EventPluginContext<Env, Params, Data, PluginArgs>) => Response | Promise<Response>;
  9925. declare module "assets:*" {
  9926. export const onRequest: PagesFunction;
  9927. }
  9928. // Copyright (c) 2022-2023 Cloudflare, Inc.
  9929. // Licensed under the Apache 2.0 license found in the LICENSE file or at:
  9930. // https://opensource.org/licenses/Apache-2.0
  9931. declare module "cloudflare:pipelines" {
  9932. export abstract class PipelineTransformationEntrypoint<Env = unknown, I extends PipelineRecord = PipelineRecord, O extends PipelineRecord = PipelineRecord> {
  9933. protected env: Env;
  9934. protected ctx: ExecutionContext;
  9935. constructor(ctx: ExecutionContext, env: Env);
  9936. /**
  9937. * run receives an array of PipelineRecord which can be
  9938. * transformed and returned to the pipeline
  9939. * @param records Incoming records from the pipeline to be transformed
  9940. * @param metadata Information about the specific pipeline calling the transformation entrypoint
  9941. * @returns A promise containing the transformed PipelineRecord array
  9942. */
  9943. public run(records: I[], metadata: PipelineBatchMetadata): Promise<O[]>;
  9944. }
  9945. export type PipelineRecord = Record<string, unknown>;
  9946. export type PipelineBatchMetadata = {
  9947. pipelineId: string;
  9948. pipelineName: string;
  9949. };
  9950. export interface Pipeline<T extends PipelineRecord = PipelineRecord> {
  9951. /**
  9952. * The Pipeline interface represents the type of a binding to a Pipeline
  9953. *
  9954. * @param records The records to send to the pipeline
  9955. */
  9956. send(records: T[]): Promise<void>;
  9957. }
  9958. }
  9959. // PubSubMessage represents an incoming PubSub message.
  9960. // The message includes metadata about the broker, the client, and the payload
  9961. // itself.
  9962. // https://developers.cloudflare.com/pub-sub/
  9963. interface PubSubMessage {
  9964. // Message ID
  9965. readonly mid: number;
  9966. // MQTT broker FQDN in the form mqtts://BROKER.NAMESPACE.cloudflarepubsub.com:PORT
  9967. readonly broker: string;
  9968. // The MQTT topic the message was sent on.
  9969. readonly topic: string;
  9970. // The client ID of the client that published this message.
  9971. readonly clientId: string;
  9972. // The unique identifier (JWT ID) used by the client to authenticate, if token
  9973. // auth was used.
  9974. readonly jti?: string;
  9975. // A Unix timestamp (seconds from Jan 1, 1970), set when the Pub/Sub Broker
  9976. // received the message from the client.
  9977. readonly receivedAt: number;
  9978. // An (optional) string with the MIME type of the payload, if set by the
  9979. // client.
  9980. readonly contentType: string;
  9981. // Set to 1 when the payload is a UTF-8 string
  9982. // https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901063
  9983. readonly payloadFormatIndicator: number;
  9984. // Pub/Sub (MQTT) payloads can be UTF-8 strings, or byte arrays.
  9985. // You can use payloadFormatIndicator to inspect this before decoding.
  9986. payload: string | Uint8Array;
  9987. }
  9988. // JsonWebKey extended by kid parameter
  9989. interface JsonWebKeyWithKid extends JsonWebKey {
  9990. // Key Identifier of the JWK
  9991. readonly kid: string;
  9992. }
  9993. interface RateLimitOptions {
  9994. key: string;
  9995. }
  9996. interface RateLimitOutcome {
  9997. success: boolean;
  9998. }
  9999. interface RateLimit {
  10000. /**
  10001. * Rate limit a request based on the provided options.
  10002. * @see https://developers.cloudflare.com/workers/runtime-apis/bindings/rate-limit/
  10003. * @returns A promise that resolves with the outcome of the rate limit.
  10004. */
  10005. limit(options: RateLimitOptions): Promise<RateLimitOutcome>;
  10006. }
  10007. // Namespace for RPC utility types. Unfortunately, we can't use a `module` here as these types need
  10008. // to referenced by `Fetcher`. This is included in the "importable" version of the types which
  10009. // strips all `module` blocks.
  10010. declare namespace Rpc {
  10011. // Branded types for identifying `WorkerEntrypoint`/`DurableObject`/`Target`s.
  10012. // TypeScript uses *structural* typing meaning anything with the same shape as type `T` is a `T`.
  10013. // For the classes exported by `cloudflare:workers` we want *nominal* typing (i.e. we only want to
  10014. // accept `WorkerEntrypoint` from `cloudflare:workers`, not any other class with the same shape)
  10015. export const __RPC_STUB_BRAND: '__RPC_STUB_BRAND';
  10016. export const __RPC_TARGET_BRAND: '__RPC_TARGET_BRAND';
  10017. export const __WORKER_ENTRYPOINT_BRAND: '__WORKER_ENTRYPOINT_BRAND';
  10018. export const __DURABLE_OBJECT_BRAND: '__DURABLE_OBJECT_BRAND';
  10019. export const __WORKFLOW_ENTRYPOINT_BRAND: '__WORKFLOW_ENTRYPOINT_BRAND';
  10020. export interface RpcTargetBranded {
  10021. [__RPC_TARGET_BRAND]: never;
  10022. }
  10023. export interface WorkerEntrypointBranded {
  10024. [__WORKER_ENTRYPOINT_BRAND]: never;
  10025. }
  10026. export interface DurableObjectBranded {
  10027. [__DURABLE_OBJECT_BRAND]: never;
  10028. }
  10029. export interface WorkflowEntrypointBranded {
  10030. [__WORKFLOW_ENTRYPOINT_BRAND]: never;
  10031. }
  10032. export type EntrypointBranded = WorkerEntrypointBranded | DurableObjectBranded | WorkflowEntrypointBranded;
  10033. // Types that can be used through `Stub`s
  10034. export type Stubable = RpcTargetBranded | ((...args: any[]) => any);
  10035. // Types that can be passed over RPC
  10036. // The reason for using a generic type here is to build a serializable subset of structured
  10037. // cloneable composite types. This allows types defined with the "interface" keyword to pass the
  10038. // serializable check as well. Otherwise, only types defined with the "type" keyword would pass.
  10039. type Serializable<T> =
  10040. // Structured cloneables
  10041. BaseType
  10042. // Structured cloneable composites
  10043. | Map<T extends Map<infer U, unknown> ? Serializable<U> : never, T extends Map<unknown, infer U> ? Serializable<U> : never> | Set<T extends Set<infer U> ? Serializable<U> : never> | ReadonlyArray<T extends ReadonlyArray<infer U> ? Serializable<U> : never> | {
  10044. [K in keyof T]: K extends number | string ? Serializable<T[K]> : never;
  10045. }
  10046. // Special types
  10047. | Stub<Stubable>
  10048. // Serialized as stubs, see `Stubify`
  10049. | Stubable;
  10050. // Base type for all RPC stubs, including common memory management methods.
  10051. // `T` is used as a marker type for unwrapping `Stub`s later.
  10052. interface StubBase<T extends Stubable> extends Disposable {
  10053. [__RPC_STUB_BRAND]: T;
  10054. dup(): this;
  10055. }
  10056. export type Stub<T extends Stubable> = Provider<T> & StubBase<T>;
  10057. // This represents all the types that can be sent as-is over an RPC boundary
  10058. type BaseType = void | undefined | null | boolean | number | bigint | string | TypedArray | ArrayBuffer | DataView | Date | Error | RegExp | ReadableStream<Uint8Array> | WritableStream<Uint8Array> | Request | Response | Headers;
  10059. // Recursively rewrite all `Stubable` types with `Stub`s
  10060. // prettier-ignore
  10061. type Stubify<T> = T extends Stubable ? Stub<T> : T extends Map<infer K, infer V> ? Map<Stubify<K>, Stubify<V>> : T extends Set<infer V> ? Set<Stubify<V>> : T extends Array<infer V> ? Array<Stubify<V>> : T extends ReadonlyArray<infer V> ? ReadonlyArray<Stubify<V>> : T extends BaseType ? T : T extends {
  10062. [key: string | number]: any;
  10063. } ? {
  10064. [K in keyof T]: Stubify<T[K]>;
  10065. } : T;
  10066. // Recursively rewrite all `Stub<T>`s with the corresponding `T`s.
  10067. // Note we use `StubBase` instead of `Stub` here to avoid circular dependencies:
  10068. // `Stub` depends on `Provider`, which depends on `Unstubify`, which would depend on `Stub`.
  10069. // prettier-ignore
  10070. type Unstubify<T> = T extends StubBase<infer V> ? V : T extends Map<infer K, infer V> ? Map<Unstubify<K>, Unstubify<V>> : T extends Set<infer V> ? Set<Unstubify<V>> : T extends Array<infer V> ? Array<Unstubify<V>> : T extends ReadonlyArray<infer V> ? ReadonlyArray<Unstubify<V>> : T extends BaseType ? T : T extends {
  10071. [key: string | number]: unknown;
  10072. } ? {
  10073. [K in keyof T]: Unstubify<T[K]>;
  10074. } : T;
  10075. type UnstubifyAll<A extends any[]> = {
  10076. [I in keyof A]: Unstubify<A[I]>;
  10077. };
  10078. // Utility type for adding `Provider`/`Disposable`s to `object` types only.
  10079. // Note `unknown & T` is equivalent to `T`.
  10080. type MaybeProvider<T> = T extends object ? Provider<T> : unknown;
  10081. type MaybeDisposable<T> = T extends object ? Disposable : unknown;
  10082. // Type for method return or property on an RPC interface.
  10083. // - Stubable types are replaced by stubs.
  10084. // - Serializable types are passed by value, with stubable types replaced by stubs
  10085. // and a top-level `Disposer`.
  10086. // Everything else can't be passed over PRC.
  10087. // Technically, we use custom thenables here, but they quack like `Promise`s.
  10088. // Intersecting with `(Maybe)Provider` allows pipelining.
  10089. // prettier-ignore
  10090. type Result<R> = R extends Stubable ? Promise<Stub<R>> & Provider<R> : R extends Serializable<R> ? Promise<Stubify<R> & MaybeDisposable<R>> & MaybeProvider<R> : never;
  10091. // Type for method or property on an RPC interface.
  10092. // For methods, unwrap `Stub`s in parameters, and rewrite returns to be `Result`s.
  10093. // Unwrapping `Stub`s allows calling with `Stubable` arguments.
  10094. // For properties, rewrite types to be `Result`s.
  10095. // In each case, unwrap `Promise`s.
  10096. type MethodOrProperty<V> = V extends (...args: infer P) => infer R ? (...args: UnstubifyAll<P>) => Result<Awaited<R>> : Result<Awaited<V>>;
  10097. // Type for the callable part of an `Provider` if `T` is callable.
  10098. // This is intersected with methods/properties.
  10099. type MaybeCallableProvider<T> = T extends (...args: any[]) => any ? MethodOrProperty<T> : unknown;
  10100. // Base type for all other types providing RPC-like interfaces.
  10101. // Rewrites all methods/properties to be `MethodOrProperty`s, while preserving callable types.
  10102. // `Reserved` names (e.g. stub method names like `dup()`) and symbols can't be accessed over RPC.
  10103. export type Provider<T extends object, Reserved extends string = never> = MaybeCallableProvider<T> & Pick<{
  10104. [K in keyof T]: MethodOrProperty<T[K]>;
  10105. }, Exclude<keyof T, Reserved | symbol | keyof StubBase<never>>>;
  10106. }
  10107. declare namespace Cloudflare {
  10108. // Type of `env`.
  10109. //
  10110. // The specific project can extend `Env` by redeclaring it in project-specific files. Typescript
  10111. // will merge all declarations.
  10112. //
  10113. // You can use `wrangler types` to generate the `Env` type automatically.
  10114. interface Env {
  10115. }
  10116. // Project-specific parameters used to inform types.
  10117. //
  10118. // This interface is, again, intended to be declared in project-specific files, and then that
  10119. // declaration will be merged with this one.
  10120. //
  10121. // A project should have a declaration like this:
  10122. //
  10123. // interface GlobalProps {
  10124. // // Declares the main module's exports. Used to populate Cloudflare.Exports aka the type
  10125. // // of `ctx.exports`.
  10126. // mainModule: typeof import("my-main-module");
  10127. //
  10128. // // Declares which of the main module's exports are configured with durable storage, and
  10129. // // thus should behave as Durable Object namsepace bindings.
  10130. // durableNamespaces: "MyDurableObject" | "AnotherDurableObject";
  10131. // }
  10132. //
  10133. // You can use `wrangler types` to generate `GlobalProps` automatically.
  10134. interface GlobalProps {
  10135. }
  10136. // Evaluates to the type of a property in GlobalProps, defaulting to `Default` if it is not
  10137. // present.
  10138. type GlobalProp<K extends string, Default> = K extends keyof GlobalProps ? GlobalProps[K] : Default;
  10139. // The type of the program's main module exports, if known. Requires `GlobalProps` to declare the
  10140. // `mainModule` property.
  10141. type MainModule = GlobalProp<"mainModule", {}>;
  10142. // The type of ctx.exports, which contains loopback bindings for all top-level exports.
  10143. type Exports = {
  10144. [K in keyof MainModule]: LoopbackForExport<MainModule[K]>
  10145. // If the export is listed in `durableNamespaces`, then it is also a
  10146. // DurableObjectNamespace.
  10147. & (K extends GlobalProp<"durableNamespaces", never> ? MainModule[K] extends new (...args: any[]) => infer DoInstance ? DoInstance extends Rpc.DurableObjectBranded ? DurableObjectNamespace<DoInstance> : DurableObjectNamespace<undefined> : DurableObjectNamespace<undefined> : {});
  10148. };
  10149. }
  10150. declare namespace CloudflareWorkersModule {
  10151. export type RpcStub<T extends Rpc.Stubable> = Rpc.Stub<T>;
  10152. export const RpcStub: {
  10153. new <T extends Rpc.Stubable>(value: T): Rpc.Stub<T>;
  10154. };
  10155. export abstract class RpcTarget implements Rpc.RpcTargetBranded {
  10156. [Rpc.__RPC_TARGET_BRAND]: never;
  10157. }
  10158. // `protected` fields don't appear in `keyof`s, so can't be accessed over RPC
  10159. export abstract class WorkerEntrypoint<Env = Cloudflare.Env, Props = {}> implements Rpc.WorkerEntrypointBranded {
  10160. [Rpc.__WORKER_ENTRYPOINT_BRAND]: never;
  10161. protected ctx: ExecutionContext<Props>;
  10162. protected env: Env;
  10163. constructor(ctx: ExecutionContext, env: Env);
  10164. email?(message: ForwardableEmailMessage): void | Promise<void>;
  10165. fetch?(request: Request): Response | Promise<Response>;
  10166. queue?(batch: MessageBatch<unknown>): void | Promise<void>;
  10167. scheduled?(controller: ScheduledController): void | Promise<void>;
  10168. tail?(events: TraceItem[]): void | Promise<void>;
  10169. tailStream?(event: TailStream.TailEvent<TailStream.Onset>): TailStream.TailEventHandlerType | Promise<TailStream.TailEventHandlerType>;
  10170. test?(controller: TestController): void | Promise<void>;
  10171. trace?(traces: TraceItem[]): void | Promise<void>;
  10172. }
  10173. export abstract class DurableObject<Env = Cloudflare.Env, Props = {}> implements Rpc.DurableObjectBranded {
  10174. [Rpc.__DURABLE_OBJECT_BRAND]: never;
  10175. protected ctx: DurableObjectState<Props>;
  10176. protected env: Env;
  10177. constructor(ctx: DurableObjectState, env: Env);
  10178. alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
  10179. fetch?(request: Request): Response | Promise<Response>;
  10180. webSocketMessage?(ws: WebSocket, message: string | ArrayBuffer): void | Promise<void>;
  10181. webSocketClose?(ws: WebSocket, code: number, reason: string, wasClean: boolean): void | Promise<void>;
  10182. webSocketError?(ws: WebSocket, error: unknown): void | Promise<void>;
  10183. }
  10184. export type WorkflowDurationLabel = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';
  10185. export type WorkflowSleepDuration = `${number} ${WorkflowDurationLabel}${'s' | ''}` | number;
  10186. export type WorkflowDelayDuration = WorkflowSleepDuration;
  10187. export type WorkflowTimeoutDuration = WorkflowSleepDuration;
  10188. export type WorkflowRetentionDuration = WorkflowSleepDuration;
  10189. export type WorkflowBackoff = 'constant' | 'linear' | 'exponential';
  10190. export type WorkflowStepConfig = {
  10191. retries?: {
  10192. limit: number;
  10193. delay: WorkflowDelayDuration | number;
  10194. backoff?: WorkflowBackoff;
  10195. };
  10196. timeout?: WorkflowTimeoutDuration | number;
  10197. };
  10198. export type WorkflowEvent<T> = {
  10199. payload: Readonly<T>;
  10200. timestamp: Date;
  10201. instanceId: string;
  10202. };
  10203. export type WorkflowStepEvent<T> = {
  10204. payload: Readonly<T>;
  10205. timestamp: Date;
  10206. type: string;
  10207. };
  10208. export abstract class WorkflowStep {
  10209. do<T extends Rpc.Serializable<T>>(name: string, callback: () => Promise<T>): Promise<T>;
  10210. do<T extends Rpc.Serializable<T>>(name: string, config: WorkflowStepConfig, callback: () => Promise<T>): Promise<T>;
  10211. sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
  10212. sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
  10213. waitForEvent<T extends Rpc.Serializable<T>>(name: string, options: {
  10214. type: string;
  10215. timeout?: WorkflowTimeoutDuration | number;
  10216. }): Promise<WorkflowStepEvent<T>>;
  10217. }
  10218. export abstract class WorkflowEntrypoint<Env = unknown, T extends Rpc.Serializable<T> | unknown = unknown> implements Rpc.WorkflowEntrypointBranded {
  10219. [Rpc.__WORKFLOW_ENTRYPOINT_BRAND]: never;
  10220. protected ctx: ExecutionContext;
  10221. protected env: Env;
  10222. constructor(ctx: ExecutionContext, env: Env);
  10223. run(event: Readonly<WorkflowEvent<T>>, step: WorkflowStep): Promise<unknown>;
  10224. }
  10225. export function waitUntil(promise: Promise<unknown>): void;
  10226. export function withEnv(newEnv: unknown, fn: () => unknown): unknown;
  10227. export function withExports(newExports: unknown, fn: () => unknown): unknown;
  10228. export function withEnvAndExports(newEnv: unknown, newExports: unknown, fn: () => unknown): unknown;
  10229. export const env: Cloudflare.Env;
  10230. export const exports: Cloudflare.Exports;
  10231. }
  10232. declare module 'cloudflare:workers' {
  10233. export = CloudflareWorkersModule;
  10234. }
  10235. interface SecretsStoreSecret {
  10236. /**
  10237. * Get a secret from the Secrets Store, returning a string of the secret value
  10238. * if it exists, or throws an error if it does not exist
  10239. */
  10240. get(): Promise<string>;
  10241. }
  10242. declare module "cloudflare:sockets" {
  10243. function _connect(address: string | SocketAddress, options?: SocketOptions): Socket;
  10244. export { _connect as connect };
  10245. }
  10246. type MarkdownDocument = {
  10247. name: string;
  10248. blob: Blob;
  10249. };
  10250. type ConversionResponse = {
  10251. name: string;
  10252. mimeType: string;
  10253. format: 'markdown';
  10254. tokens: number;
  10255. data: string;
  10256. } | {
  10257. name: string;
  10258. mimeType: string;
  10259. format: 'error';
  10260. error: string;
  10261. };
  10262. type ImageConversionOptions = {
  10263. descriptionLanguage?: 'en' | 'es' | 'fr' | 'it' | 'pt' | 'de';
  10264. };
  10265. type EmbeddedImageConversionOptions = ImageConversionOptions & {
  10266. convert?: boolean;
  10267. maxConvertedImages?: number;
  10268. };
  10269. type ConversionOptions = {
  10270. html?: {
  10271. images?: EmbeddedImageConversionOptions & {
  10272. convertOGImage?: boolean;
  10273. };
  10274. };
  10275. docx?: {
  10276. images?: EmbeddedImageConversionOptions;
  10277. };
  10278. image?: ImageConversionOptions;
  10279. pdf?: {
  10280. images?: EmbeddedImageConversionOptions;
  10281. metadata?: boolean;
  10282. };
  10283. };
  10284. type ConversionRequestOptions = {
  10285. gateway?: GatewayOptions;
  10286. extraHeaders?: object;
  10287. conversionOptions?: ConversionOptions;
  10288. };
  10289. type SupportedFileFormat = {
  10290. mimeType: string;
  10291. extension: string;
  10292. };
  10293. declare abstract class ToMarkdownService {
  10294. transform(files: MarkdownDocument[], options?: ConversionRequestOptions): Promise<ConversionResponse[]>;
  10295. transform(files: MarkdownDocument, options?: ConversionRequestOptions): Promise<ConversionResponse>;
  10296. supported(): Promise<SupportedFileFormat[]>;
  10297. }
  10298. declare namespace TailStream {
  10299. interface Header {
  10300. readonly name: string;
  10301. readonly value: string;
  10302. }
  10303. interface FetchEventInfo {
  10304. readonly type: "fetch";
  10305. readonly method: string;
  10306. readonly url: string;
  10307. readonly cfJson?: object;
  10308. readonly headers: Header[];
  10309. }
  10310. interface JsRpcEventInfo {
  10311. readonly type: "jsrpc";
  10312. }
  10313. interface ScheduledEventInfo {
  10314. readonly type: "scheduled";
  10315. readonly scheduledTime: Date;
  10316. readonly cron: string;
  10317. }
  10318. interface AlarmEventInfo {
  10319. readonly type: "alarm";
  10320. readonly scheduledTime: Date;
  10321. }
  10322. interface QueueEventInfo {
  10323. readonly type: "queue";
  10324. readonly queueName: string;
  10325. readonly batchSize: number;
  10326. }
  10327. interface EmailEventInfo {
  10328. readonly type: "email";
  10329. readonly mailFrom: string;
  10330. readonly rcptTo: string;
  10331. readonly rawSize: number;
  10332. }
  10333. interface TraceEventInfo {
  10334. readonly type: "trace";
  10335. readonly traces: (string | null)[];
  10336. }
  10337. interface HibernatableWebSocketEventInfoMessage {
  10338. readonly type: "message";
  10339. }
  10340. interface HibernatableWebSocketEventInfoError {
  10341. readonly type: "error";
  10342. }
  10343. interface HibernatableWebSocketEventInfoClose {
  10344. readonly type: "close";
  10345. readonly code: number;
  10346. readonly wasClean: boolean;
  10347. }
  10348. interface HibernatableWebSocketEventInfo {
  10349. readonly type: "hibernatableWebSocket";
  10350. readonly info: HibernatableWebSocketEventInfoClose | HibernatableWebSocketEventInfoError | HibernatableWebSocketEventInfoMessage;
  10351. }
  10352. interface CustomEventInfo {
  10353. readonly type: "custom";
  10354. }
  10355. interface FetchResponseInfo {
  10356. readonly type: "fetch";
  10357. readonly statusCode: number;
  10358. }
  10359. type EventOutcome = "ok" | "canceled" | "exception" | "unknown" | "killSwitch" | "daemonDown" | "exceededCpu" | "exceededMemory" | "loadShed" | "responseStreamDisconnected" | "scriptNotFound";
  10360. interface ScriptVersion {
  10361. readonly id: string;
  10362. readonly tag?: string;
  10363. readonly message?: string;
  10364. }
  10365. interface Onset {
  10366. readonly type: "onset";
  10367. readonly attributes: Attribute[];
  10368. // id for the span being opened by this Onset event.
  10369. readonly spanId: string;
  10370. readonly dispatchNamespace?: string;
  10371. readonly entrypoint?: string;
  10372. readonly executionModel: string;
  10373. readonly scriptName?: string;
  10374. readonly scriptTags?: string[];
  10375. readonly scriptVersion?: ScriptVersion;
  10376. readonly info: FetchEventInfo | JsRpcEventInfo | ScheduledEventInfo | AlarmEventInfo | QueueEventInfo | EmailEventInfo | TraceEventInfo | HibernatableWebSocketEventInfo | CustomEventInfo;
  10377. }
  10378. interface Outcome {
  10379. readonly type: "outcome";
  10380. readonly outcome: EventOutcome;
  10381. readonly cpuTime: number;
  10382. readonly wallTime: number;
  10383. }
  10384. interface SpanOpen {
  10385. readonly type: "spanOpen";
  10386. readonly name: string;
  10387. // id for the span being opened by this SpanOpen event.
  10388. readonly spanId: string;
  10389. readonly info?: FetchEventInfo | JsRpcEventInfo | Attributes;
  10390. }
  10391. interface SpanClose {
  10392. readonly type: "spanClose";
  10393. readonly outcome: EventOutcome;
  10394. }
  10395. interface DiagnosticChannelEvent {
  10396. readonly type: "diagnosticChannel";
  10397. readonly channel: string;
  10398. readonly message: any;
  10399. }
  10400. interface Exception {
  10401. readonly type: "exception";
  10402. readonly name: string;
  10403. readonly message: string;
  10404. readonly stack?: string;
  10405. }
  10406. interface Log {
  10407. readonly type: "log";
  10408. readonly level: "debug" | "error" | "info" | "log" | "warn";
  10409. readonly message: object;
  10410. }
  10411. // This marks the worker handler return information.
  10412. // This is separate from Outcome because the worker invocation can live for a long time after
  10413. // returning. For example - Websockets that return an http upgrade response but then continue
  10414. // streaming information or SSE http connections.
  10415. interface Return {
  10416. readonly type: "return";
  10417. readonly info?: FetchResponseInfo;
  10418. }
  10419. interface Attribute {
  10420. readonly name: string;
  10421. readonly value: string | string[] | boolean | boolean[] | number | number[] | bigint | bigint[];
  10422. }
  10423. interface Attributes {
  10424. readonly type: "attributes";
  10425. readonly info: Attribute[];
  10426. }
  10427. type EventType = Onset | Outcome | SpanOpen | SpanClose | DiagnosticChannelEvent | Exception | Log | Return | Attributes;
  10428. // Context in which this trace event lives.
  10429. interface SpanContext {
  10430. // Single id for the entire top-level invocation
  10431. // This should be a new traceId for the first worker stage invoked in the eyeball request and then
  10432. // same-account service-bindings should reuse the same traceId but cross-account service-bindings
  10433. // should use a new traceId.
  10434. readonly traceId: string;
  10435. // spanId in which this event is handled
  10436. // for Onset and SpanOpen events this would be the parent span id
  10437. // for Outcome and SpanClose these this would be the span id of the opening Onset and SpanOpen events
  10438. // For Hibernate and Mark this would be the span under which they were emitted.
  10439. // spanId is not set ONLY if:
  10440. // 1. This is an Onset event
  10441. // 2. We are not inheriting any SpanContext. (e.g. this is a cross-account service binding or a new top-level invocation)
  10442. readonly spanId?: string;
  10443. }
  10444. interface TailEvent<Event extends EventType> {
  10445. // invocation id of the currently invoked worker stage.
  10446. // invocation id will always be unique to every Onset event and will be the same until the Outcome event.
  10447. readonly invocationId: string;
  10448. // Inherited spanContext for this event.
  10449. readonly spanContext: SpanContext;
  10450. readonly timestamp: Date;
  10451. readonly sequence: number;
  10452. readonly event: Event;
  10453. }
  10454. type TailEventHandler<Event extends EventType = EventType> = (event: TailEvent<Event>) => void | Promise<void>;
  10455. type TailEventHandlerObject = {
  10456. outcome?: TailEventHandler<Outcome>;
  10457. spanOpen?: TailEventHandler<SpanOpen>;
  10458. spanClose?: TailEventHandler<SpanClose>;
  10459. diagnosticChannel?: TailEventHandler<DiagnosticChannelEvent>;
  10460. exception?: TailEventHandler<Exception>;
  10461. log?: TailEventHandler<Log>;
  10462. return?: TailEventHandler<Return>;
  10463. attributes?: TailEventHandler<Attributes>;
  10464. };
  10465. type TailEventHandlerType = TailEventHandler | TailEventHandlerObject;
  10466. }
  10467. // Copyright (c) 2022-2023 Cloudflare, Inc.
  10468. // Licensed under the Apache 2.0 license found in the LICENSE file or at:
  10469. // https://opensource.org/licenses/Apache-2.0
  10470. /**
  10471. * Data types supported for holding vector metadata.
  10472. */
  10473. type VectorizeVectorMetadataValue = string | number | boolean | string[];
  10474. /**
  10475. * Additional information to associate with a vector.
  10476. */
  10477. type VectorizeVectorMetadata = VectorizeVectorMetadataValue | Record<string, VectorizeVectorMetadataValue>;
  10478. type VectorFloatArray = Float32Array | Float64Array;
  10479. interface VectorizeError {
  10480. code?: number;
  10481. error: string;
  10482. }
  10483. /**
  10484. * Comparison logic/operation to use for metadata filtering.
  10485. *
  10486. * This list is expected to grow as support for more operations are released.
  10487. */
  10488. type VectorizeVectorMetadataFilterOp = '$eq' | '$ne' | '$lt' | '$lte' | '$gt' | '$gte';
  10489. type VectorizeVectorMetadataFilterCollectionOp = '$in' | '$nin';
  10490. /**
  10491. * Filter criteria for vector metadata used to limit the retrieved query result set.
  10492. */
  10493. type VectorizeVectorMetadataFilter = {
  10494. [field: string]: Exclude<VectorizeVectorMetadataValue, string[]> | null | {
  10495. [Op in VectorizeVectorMetadataFilterOp]?: Exclude<VectorizeVectorMetadataValue, string[]> | null;
  10496. } | {
  10497. [Op in VectorizeVectorMetadataFilterCollectionOp]?: Exclude<VectorizeVectorMetadataValue, string[]>[];
  10498. };
  10499. };
  10500. /**
  10501. * Supported distance metrics for an index.
  10502. * Distance metrics determine how other "similar" vectors are determined.
  10503. */
  10504. type VectorizeDistanceMetric = "euclidean" | "cosine" | "dot-product";
  10505. /**
  10506. * Metadata return levels for a Vectorize query.
  10507. *
  10508. * Default to "none".
  10509. *
  10510. * @property all Full metadata for the vector return set, including all fields (including those un-indexed) without truncation. This is a more expensive retrieval, as it requires additional fetching & reading of un-indexed data.
  10511. * @property indexed Return all metadata fields configured for indexing in the vector return set. This level of retrieval is "free" in that no additional overhead is incurred returning this data. However, note that indexed metadata is subject to truncation (especially for larger strings).
  10512. * @property none No indexed metadata will be returned.
  10513. */
  10514. type VectorizeMetadataRetrievalLevel = "all" | "indexed" | "none";
  10515. interface VectorizeQueryOptions {
  10516. topK?: number;
  10517. namespace?: string;
  10518. returnValues?: boolean;
  10519. returnMetadata?: boolean | VectorizeMetadataRetrievalLevel;
  10520. filter?: VectorizeVectorMetadataFilter;
  10521. }
  10522. /**
  10523. * Information about the configuration of an index.
  10524. */
  10525. type VectorizeIndexConfig = {
  10526. dimensions: number;
  10527. metric: VectorizeDistanceMetric;
  10528. } | {
  10529. preset: string; // keep this generic, as we'll be adding more presets in the future and this is only in a read capacity
  10530. };
  10531. /**
  10532. * Metadata about an existing index.
  10533. *
  10534. * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
  10535. * See {@link VectorizeIndexInfo} for its post-beta equivalent.
  10536. */
  10537. interface VectorizeIndexDetails {
  10538. /** The unique ID of the index */
  10539. readonly id: string;
  10540. /** The name of the index. */
  10541. name: string;
  10542. /** (optional) A human readable description for the index. */
  10543. description?: string;
  10544. /** The index configuration, including the dimension size and distance metric. */
  10545. config: VectorizeIndexConfig;
  10546. /** The number of records containing vectors within the index. */
  10547. vectorsCount: number;
  10548. }
  10549. /**
  10550. * Metadata about an existing index.
  10551. */
  10552. interface VectorizeIndexInfo {
  10553. /** The number of records containing vectors within the index. */
  10554. vectorCount: number;
  10555. /** Number of dimensions the index has been configured for. */
  10556. dimensions: number;
  10557. /** ISO 8601 datetime of the last processed mutation on in the index. All changes before this mutation will be reflected in the index state. */
  10558. processedUpToDatetime: number;
  10559. /** UUIDv4 of the last mutation processed by the index. All changes before this mutation will be reflected in the index state. */
  10560. processedUpToMutation: number;
  10561. }
  10562. /**
  10563. * Represents a single vector value set along with its associated metadata.
  10564. */
  10565. interface VectorizeVector {
  10566. /** The ID for the vector. This can be user-defined, and must be unique. It should uniquely identify the object, and is best set based on the ID of what the vector represents. */
  10567. id: string;
  10568. /** The vector values */
  10569. values: VectorFloatArray | number[];
  10570. /** The namespace this vector belongs to. */
  10571. namespace?: string;
  10572. /** Metadata associated with the vector. Includes the values of other fields and potentially additional details. */
  10573. metadata?: Record<string, VectorizeVectorMetadata>;
  10574. }
  10575. /**
  10576. * Represents a matched vector for a query along with its score and (if specified) the matching vector information.
  10577. */
  10578. type VectorizeMatch = Pick<Partial<VectorizeVector>, "values"> & Omit<VectorizeVector, "values"> & {
  10579. /** The score or rank for similarity, when returned as a result */
  10580. score: number;
  10581. };
  10582. /**
  10583. * A set of matching {@link VectorizeMatch} for a particular query.
  10584. */
  10585. interface VectorizeMatches {
  10586. matches: VectorizeMatch[];
  10587. count: number;
  10588. }
  10589. /**
  10590. * Results of an operation that performed a mutation on a set of vectors.
  10591. * Here, `ids` is a list of vectors that were successfully processed.
  10592. *
  10593. * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
  10594. * See {@link VectorizeAsyncMutation} for its post-beta equivalent.
  10595. */
  10596. interface VectorizeVectorMutation {
  10597. /* List of ids of vectors that were successfully processed. */
  10598. ids: string[];
  10599. /* Total count of the number of processed vectors. */
  10600. count: number;
  10601. }
  10602. /**
  10603. * Result type indicating a mutation on the Vectorize Index.
  10604. * Actual mutations are processed async where the `mutationId` is the unique identifier for the operation.
  10605. */
  10606. interface VectorizeAsyncMutation {
  10607. /** The unique identifier for the async mutation operation containing the changeset. */
  10608. mutationId: string;
  10609. }
  10610. /**
  10611. * A Vectorize Vector Search Index for querying vectors/embeddings.
  10612. *
  10613. * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
  10614. * See {@link Vectorize} for its new implementation.
  10615. */
  10616. declare abstract class VectorizeIndex {
  10617. /**
  10618. * Get information about the currently bound index.
  10619. * @returns A promise that resolves with information about the current index.
  10620. */
  10621. public describe(): Promise<VectorizeIndexDetails>;
  10622. /**
  10623. * Use the provided vector to perform a similarity search across the index.
  10624. * @param vector Input vector that will be used to drive the similarity search.
  10625. * @param options Configuration options to massage the returned data.
  10626. * @returns A promise that resolves with matched and scored vectors.
  10627. */
  10628. public query(vector: VectorFloatArray | number[], options?: VectorizeQueryOptions): Promise<VectorizeMatches>;
  10629. /**
  10630. * Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown.
  10631. * @param vectors List of vectors that will be inserted.
  10632. * @returns A promise that resolves with the ids & count of records that were successfully processed.
  10633. */
  10634. public insert(vectors: VectorizeVector[]): Promise<VectorizeVectorMutation>;
  10635. /**
  10636. * Upsert a list of vectors into the index dataset. If a provided id exists, it will be replaced with the new values.
  10637. * @param vectors List of vectors that will be upserted.
  10638. * @returns A promise that resolves with the ids & count of records that were successfully processed.
  10639. */
  10640. public upsert(vectors: VectorizeVector[]): Promise<VectorizeVectorMutation>;
  10641. /**
  10642. * Delete a list of vectors with a matching id.
  10643. * @param ids List of vector ids that should be deleted.
  10644. * @returns A promise that resolves with the ids & count of records that were successfully processed (and thus deleted).
  10645. */
  10646. public deleteByIds(ids: string[]): Promise<VectorizeVectorMutation>;
  10647. /**
  10648. * Get a list of vectors with a matching id.
  10649. * @param ids List of vector ids that should be returned.
  10650. * @returns A promise that resolves with the raw unscored vectors matching the id set.
  10651. */
  10652. public getByIds(ids: string[]): Promise<VectorizeVector[]>;
  10653. }
  10654. /**
  10655. * A Vectorize Vector Search Index for querying vectors/embeddings.
  10656. *
  10657. * Mutations in this version are async, returning a mutation id.
  10658. */
  10659. declare abstract class Vectorize {
  10660. /**
  10661. * Get information about the currently bound index.
  10662. * @returns A promise that resolves with information about the current index.
  10663. */
  10664. public describe(): Promise<VectorizeIndexInfo>;
  10665. /**
  10666. * Use the provided vector to perform a similarity search across the index.
  10667. * @param vector Input vector that will be used to drive the similarity search.
  10668. * @param options Configuration options to massage the returned data.
  10669. * @returns A promise that resolves with matched and scored vectors.
  10670. */
  10671. public query(vector: VectorFloatArray | number[], options?: VectorizeQueryOptions): Promise<VectorizeMatches>;
  10672. /**
  10673. * Use the provided vector-id to perform a similarity search across the index.
  10674. * @param vectorId Id for a vector in the index against which the index should be queried.
  10675. * @param options Configuration options to massage the returned data.
  10676. * @returns A promise that resolves with matched and scored vectors.
  10677. */
  10678. public queryById(vectorId: string, options?: VectorizeQueryOptions): Promise<VectorizeMatches>;
  10679. /**
  10680. * Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown.
  10681. * @param vectors List of vectors that will be inserted.
  10682. * @returns A promise that resolves with a unique identifier of a mutation containing the insert changeset.
  10683. */
  10684. public insert(vectors: VectorizeVector[]): Promise<VectorizeAsyncMutation>;
  10685. /**
  10686. * Upsert a list of vectors into the index dataset. If a provided id exists, it will be replaced with the new values.
  10687. * @param vectors List of vectors that will be upserted.
  10688. * @returns A promise that resolves with a unique identifier of a mutation containing the upsert changeset.
  10689. */
  10690. public upsert(vectors: VectorizeVector[]): Promise<VectorizeAsyncMutation>;
  10691. /**
  10692. * Delete a list of vectors with a matching id.
  10693. * @param ids List of vector ids that should be deleted.
  10694. * @returns A promise that resolves with a unique identifier of a mutation containing the delete changeset.
  10695. */
  10696. public deleteByIds(ids: string[]): Promise<VectorizeAsyncMutation>;
  10697. /**
  10698. * Get a list of vectors with a matching id.
  10699. * @param ids List of vector ids that should be returned.
  10700. * @returns A promise that resolves with the raw unscored vectors matching the id set.
  10701. */
  10702. public getByIds(ids: string[]): Promise<VectorizeVector[]>;
  10703. }
  10704. /**
  10705. * The interface for "version_metadata" binding
  10706. * providing metadata about the Worker Version using this binding.
  10707. */
  10708. type WorkerVersionMetadata = {
  10709. /** The ID of the Worker Version using this binding */
  10710. id: string;
  10711. /** The tag of the Worker Version using this binding */
  10712. tag: string;
  10713. /** The timestamp of when the Worker Version was uploaded */
  10714. timestamp: string;
  10715. };
  10716. interface DynamicDispatchLimits {
  10717. /**
  10718. * Limit CPU time in milliseconds.
  10719. */
  10720. cpuMs?: number;
  10721. /**
  10722. * Limit number of subrequests.
  10723. */
  10724. subRequests?: number;
  10725. }
  10726. interface DynamicDispatchOptions {
  10727. /**
  10728. * Limit resources of invoked Worker script.
  10729. */
  10730. limits?: DynamicDispatchLimits;
  10731. /**
  10732. * Arguments for outbound Worker script, if configured.
  10733. */
  10734. outbound?: {
  10735. [key: string]: any;
  10736. };
  10737. }
  10738. interface DispatchNamespace {
  10739. /**
  10740. * @param name Name of the Worker script.
  10741. * @param args Arguments to Worker script.
  10742. * @param options Options for Dynamic Dispatch invocation.
  10743. * @returns A Fetcher object that allows you to send requests to the Worker script.
  10744. * @throws If the Worker script does not exist in this dispatch namespace, an error will be thrown.
  10745. */
  10746. get(name: string, args?: {
  10747. [key: string]: any;
  10748. }, options?: DynamicDispatchOptions): Fetcher;
  10749. }
  10750. declare module 'cloudflare:workflows' {
  10751. /**
  10752. * NonRetryableError allows for a user to throw a fatal error
  10753. * that makes a Workflow instance fail immediately without triggering a retry
  10754. */
  10755. export class NonRetryableError extends Error {
  10756. public constructor(message: string, name?: string);
  10757. }
  10758. }
  10759. declare abstract class Workflow<PARAMS = unknown> {
  10760. /**
  10761. * Get a handle to an existing instance of the Workflow.
  10762. * @param id Id for the instance of this Workflow
  10763. * @returns A promise that resolves with a handle for the Instance
  10764. */
  10765. public get(id: string): Promise<WorkflowInstance>;
  10766. /**
  10767. * Create a new instance and return a handle to it. If a provided id exists, an error will be thrown.
  10768. * @param options Options when creating an instance including id and params
  10769. * @returns A promise that resolves with a handle for the Instance
  10770. */
  10771. public create(options?: WorkflowInstanceCreateOptions<PARAMS>): Promise<WorkflowInstance>;
  10772. /**
  10773. * Create a batch of instances and return handle for all of them. If a provided id exists, an error will be thrown.
  10774. * `createBatch` is limited at 100 instances at a time or when the RPC limit for the batch (1MiB) is reached.
  10775. * @param batch List of Options when creating an instance including name and params
  10776. * @returns A promise that resolves with a list of handles for the created instances.
  10777. */
  10778. public createBatch(batch: WorkflowInstanceCreateOptions<PARAMS>[]): Promise<WorkflowInstance[]>;
  10779. }
  10780. type WorkflowDurationLabel = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';
  10781. type WorkflowSleepDuration = `${number} ${WorkflowDurationLabel}${'s' | ''}` | number;
  10782. type WorkflowRetentionDuration = WorkflowSleepDuration;
  10783. interface WorkflowInstanceCreateOptions<PARAMS = unknown> {
  10784. /**
  10785. * An id for your Workflow instance. Must be unique within the Workflow.
  10786. */
  10787. id?: string;
  10788. /**
  10789. * The event payload the Workflow instance is triggered with
  10790. */
  10791. params?: PARAMS;
  10792. /**
  10793. * The retention policy for Workflow instance.
  10794. * Defaults to the maximum retention period available for the owner's account.
  10795. */
  10796. retention?: {
  10797. successRetention?: WorkflowRetentionDuration;
  10798. errorRetention?: WorkflowRetentionDuration;
  10799. };
  10800. }
  10801. type InstanceStatus = {
  10802. status: 'queued' // means that instance is waiting to be started (see concurrency limits)
  10803. | 'running' | 'paused' | 'errored' | 'terminated' // user terminated the instance while it was running
  10804. | 'complete' | 'waiting' // instance is hibernating and waiting for sleep or event to finish
  10805. | 'waitingForPause' // instance is finishing the current work to pause
  10806. | 'unknown';
  10807. error?: {
  10808. name: string;
  10809. message: string;
  10810. };
  10811. output?: unknown;
  10812. };
  10813. interface WorkflowError {
  10814. code?: number;
  10815. message: string;
  10816. }
  10817. declare abstract class WorkflowInstance {
  10818. public id: string;
  10819. /**
  10820. * Pause the instance.
  10821. */
  10822. public pause(): Promise<void>;
  10823. /**
  10824. * Resume the instance. If it is already running, an error will be thrown.
  10825. */
  10826. public resume(): Promise<void>;
  10827. /**
  10828. * Terminate the instance. If it is errored, terminated or complete, an error will be thrown.
  10829. */
  10830. public terminate(): Promise<void>;
  10831. /**
  10832. * Restart the instance.
  10833. */
  10834. public restart(): Promise<void>;
  10835. /**
  10836. * Returns the current status of the instance.
  10837. */
  10838. public status(): Promise<InstanceStatus>;
  10839. /**
  10840. * Send an event to this instance.
  10841. */
  10842. public sendEvent({ type, payload, }: {
  10843. type: string;
  10844. payload: unknown;
  10845. }): Promise<void>;
  10846. }