noskills 4.1.56 → 4.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +13 -0
- package/README.md +47 -10
- package/chunks/ajan-bridge-T5M4DPDT.js +1 -0
- package/chunks/anthropic-TS7EMQML.js +1 -0
- package/chunks/approve-HEW3VFYH.js +1 -0
- package/chunks/ask-AXHTCVD6.js +2 -0
- package/chunks/block-VN76CXZW.js +1 -0
- package/chunks/{browser-XLYVEO2J.js → browser-BGFD24RX.js} +1 -1
- package/chunks/bun-WZ7BVR7Y.js +1 -0
- package/chunks/cancel-7WRAST62.js +1 -0
- package/chunks/chunk-3ZJ3UGQL.js +48 -0
- package/chunks/chunk-4PF2MT7S.js +29 -0
- package/chunks/chunk-575Y3OEG.js +1 -0
- package/chunks/{chunk-DZTBXXB3.js → chunk-5DZHAHXW.js} +23 -23
- package/chunks/chunk-5PBNUBBY.js +3 -0
- package/chunks/{chunk-HNAHPI6V.js → chunk-5RLCKUIF.js} +1 -1
- package/chunks/chunk-6YSS6PEL.js +3 -0
- package/chunks/chunk-7GC46XEU.js +1 -0
- package/chunks/{chunk-LBPD4EIH.js → chunk-7PPUGTKL.js} +1 -1
- package/chunks/chunk-AUZWXMWA.js +27 -0
- package/chunks/chunk-CH6A3LES.js +91 -0
- package/chunks/{chunk-UG26APX2.js → chunk-CML74SNT.js} +1 -1
- package/chunks/chunk-CTTMQSHF.js +1 -0
- package/chunks/chunk-DBKXMYLF.js +4 -0
- package/chunks/chunk-DEHRWREM.js +1 -0
- package/chunks/chunk-EIGFDYGQ.js +1 -0
- package/chunks/chunk-EIMBEXUJ.js +1 -0
- package/chunks/chunk-EJYSOUEA.js +1 -0
- package/chunks/chunk-ENP4P2YH.js +0 -0
- package/chunks/{chunk-RJX4ZXQ4.js → chunk-EROZRDGT.js} +1 -1
- package/chunks/chunk-FE4MKOI4.js +1 -0
- package/chunks/chunk-GQTHILPL.js +5 -0
- package/chunks/chunk-HISXAZ4Y.js +1 -0
- package/chunks/chunk-I4Z2RF7L.js +31 -0
- package/chunks/chunk-IFE5SYGK.js +1 -0
- package/chunks/chunk-IGDFEGCH.js +2 -0
- package/chunks/chunk-JL3MAFYQ.js +1 -0
- package/chunks/chunk-JYVB6UAV.js +1 -0
- package/chunks/chunk-KJLEPI7T.js +1 -0
- package/chunks/chunk-KM64FL2X.js +1 -0
- package/chunks/chunk-KMLNG3EC.js +1 -0
- package/chunks/chunk-KRKOWSYW.js +148 -0
- package/chunks/chunk-KRRPOVQG.js +1 -0
- package/chunks/{chunk-CKETVOVQ.js → chunk-LJEWPIEI.js} +1 -1
- package/chunks/{chunk-VAP3TSYK.js → chunk-LN4NDYT6.js} +1 -1
- package/chunks/{chunk-Z3O5HAIO.js → chunk-NGCBWJML.js} +1 -1
- package/chunks/chunk-O4KKKYCH.js +1 -0
- package/chunks/chunk-OAWYVETM.js +1 -0
- package/chunks/chunk-PKEQKXZW.js +23 -0
- package/chunks/chunk-PRQ5CRIG.js +1 -0
- package/chunks/{chunk-SWYX6WYQ.js → chunk-PSX63TYP.js} +2 -2
- package/chunks/{chunk-5P46WSNG.js → chunk-Q4TI7EYT.js} +1 -1
- package/chunks/chunk-QKWJ72HI.js +3 -0
- package/chunks/chunk-RAQY37P6.js +1 -0
- package/chunks/{openai-QGEN33SU.js → chunk-S4MUTKHT.js} +3 -3
- package/chunks/chunk-SLO22P65.js +1 -0
- package/chunks/chunk-UE56BMAW.js +21 -0
- package/chunks/{chunk-O2NUECRA.js → chunk-VJRCTYGL.js} +1 -1
- package/chunks/chunk-VXU6XZ66.js +39 -0
- package/chunks/chunk-W4TQLLUK.js +7 -0
- package/chunks/{chunk-PKYW3S5P.js → chunk-XDRX4ZBJ.js} +1 -1
- package/chunks/{chunk-XNGHRJVK.js → chunk-Y5E7ZCCX.js} +1 -1
- package/chunks/chunk-Z7OYXH3J.js +1 -0
- package/chunks/claude-code-DIWRQKZA.js +1 -0
- package/chunks/cmd-46ZIHXLB.js +1 -0
- package/chunks/concern-QSENGU6C.js +1 -0
- package/chunks/{config-CZDLCSOC.js → config-S3UXTJN2.js} +1 -1
- package/chunks/decision-ledger-GY2W6VWL.js +1 -0
- package/chunks/delegate-WKXIER7E.js +1 -0
- package/chunks/deno-YM5PW6ZM.js +1 -0
- package/chunks/{diagrams-H7NLJF7W.js → diagrams-A7W2EBYV.js} +1 -1
- package/chunks/diagrams-CBCUA47B.js +1 -0
- package/chunks/{dist-UI3SRKS3.js → dist-3MH5UCQU.js} +3 -3
- package/chunks/done-WR3UFYJT.js +1 -0
- package/chunks/followup-5EGZEF5Q.js +1 -0
- package/chunks/free-KJQHRYZA.js +1 -0
- package/chunks/gemini-IWP24T63.js +1 -0
- package/chunks/init-437SU6XH.js +1 -0
- package/chunks/invoke-hook-LMCWNF65.js +13 -0
- package/chunks/kiro-THWCXS5L.js +1 -0
- package/chunks/{learn-KIZTV5OH.js → learn-ZTYKBZER.js} +1 -1
- package/chunks/ledger-FOOPJ2UO.js +1 -0
- package/chunks/list-HNGIOVBK.js +1 -0
- package/chunks/loader-command-3A5FK2RF.js +1 -0
- package/chunks/loader-reactor-YZM7HO4G.js +1 -0
- package/chunks/manager-2MOLEJ4Q.js +3 -0
- package/chunks/mod-6EZYRKWV.js +1 -0
- package/chunks/{mod-TYCXSLSH.js → mod-7VTKN6Q5.js} +1 -1
- package/chunks/mod-7X5TKHKC.js +1 -0
- package/chunks/mod-AJIRKRAH.js +1 -0
- package/chunks/mod-SFSUQWSB.js +8 -0
- package/chunks/mod-TGOMO3CJ.js +1 -0
- package/chunks/{multipart-parser-UVM6CEKF.js → multipart-parser-DKDFOZKD.js} +1 -1
- package/chunks/next-Y6FOPM4Z.js +15 -0
- package/chunks/node-AZK2C657.js +12 -0
- package/chunks/node-GQQ42DT2.js +68 -0
- package/chunks/node-J4GTOSL2.js +1 -0
- package/chunks/ollama-2KAMCXVL.js +1 -0
- package/chunks/openai-HHE35TAX.js +31 -0
- package/chunks/openai-YES2XJDU.js +1 -0
- package/chunks/opencode-S4M7WJTO.js +1 -0
- package/chunks/{pack-33LQ7SJT.js → pack-KUT53Z24.js} +4 -4
- package/chunks/plan-export-PG2BVRQZ.js +3 -0
- package/chunks/purge-JGNJNEET.js +4 -0
- package/chunks/reopen-RPDXN3CF.js +1 -0
- package/chunks/reset-RBCQO2RF.js +1 -0
- package/chunks/review-VMS5MYOV.js +1 -0
- package/chunks/{rule-XREVPB5P.js → rule-IB4VKSBC.js} +2 -2
- package/chunks/run-62PWXVII.js +3 -0
- package/chunks/sdk-FR7Z4YSC.js +1 -0
- package/chunks/{session-HBP5GGI2.js → session-Q43KMFL2.js} +1 -1
- package/chunks/spec-4RKLPOEM.js +1 -0
- package/chunks/{src-GLQPTDNR.js → src-HXQVVTGQ.js} +1 -1
- package/chunks/{status-P754FM5Y.js → status-OGLFEFF7.js} +1 -1
- package/chunks/sync-H35O5DN5.js +1 -0
- package/chunks/{unstable_chmod-RZ5DE3XZ.js → unstable_chmod-44MCKF3B.js} +1 -1
- package/chunks/validate-JX7UTAK5.js +1 -0
- package/chunks/vertexai-WF5CKMYI.js +1 -0
- package/chunks/watch-SOZDHLSC.js +8 -0
- package/chunks/web-3VGRM3W4.js +1 -0
- package/chunks/wontfix-RBOGLLWJ.js +1 -0
- package/chunks/workerd-I7MLRCLJ.js +1 -0
- package/noskills.js +1 -1
- package/package.json +2 -2
- package/chunks/anthropic-LDUWIUPL.js +0 -1
- package/chunks/approve-OIXULOYH.js +0 -1
- package/chunks/ask-VGI3BFZW.js +0 -2
- package/chunks/block-6L3XJKPC.js +0 -1
- package/chunks/bun-5VMFSLLY.js +0 -1
- package/chunks/cancel-6IH4L4BL.js +0 -1
- package/chunks/chunk-2GF5IUQD.js +0 -39
- package/chunks/chunk-2N4GTHXQ.js +0 -1
- package/chunks/chunk-5CNPFLE6.js +0 -1
- package/chunks/chunk-5MN3MWQN.js +0 -1
- package/chunks/chunk-65A35QPF.js +0 -1
- package/chunks/chunk-7UX6WIXX.js +0 -1
- package/chunks/chunk-AGPCY6XP.js +0 -1
- package/chunks/chunk-AGWPQX43.js +0 -31
- package/chunks/chunk-AP3YBNPX.js +0 -1
- package/chunks/chunk-BJ2X6GHW.js +0 -5
- package/chunks/chunk-D3IKJ7FF.js +0 -1
- package/chunks/chunk-EFG5UU32.js +0 -1
- package/chunks/chunk-H77MLIL5.js +0 -4
- package/chunks/chunk-JVCVWI3B.js +0 -3
- package/chunks/chunk-OLM5RTFK.js +0 -1
- package/chunks/chunk-OTRBRRIO.js +0 -1
- package/chunks/chunk-U5SHLIO4.js +0 -3
- package/chunks/chunk-UT6ZCLRA.js +0 -1
- package/chunks/chunk-XXBSEOQR.js +0 -148
- package/chunks/chunk-YSLRAWBK.js +0 -1
- package/chunks/chunk-YSSDQJTT.js +0 -91
- package/chunks/chunk-YTNM7A5Y.js +0 -3
- package/chunks/claude-code-BWCSAVK2.js +0 -1
- package/chunks/cmd-ZXO6KFK6.js +0 -1
- package/chunks/concern-RB444PUE.js +0 -1
- package/chunks/delegate-NEWTWM6L.js +0 -1
- package/chunks/deno-QOH6TCLQ.js +0 -1
- package/chunks/diagrams-I2QKL7WR.js +0 -1
- package/chunks/done-KCSWC5WY.js +0 -1
- package/chunks/followup-5IFWOU4E.js +0 -1
- package/chunks/free-R4ZTZ76O.js +0 -1
- package/chunks/gemini-YR5KT32S.js +0 -1
- package/chunks/init-JRL2FB64.js +0 -1
- package/chunks/invoke-hook-CYJM3RDY.js +0 -13
- package/chunks/kiro-RGYUKJAX.js +0 -3
- package/chunks/list-6EQP6VUL.js +0 -1
- package/chunks/manager-WDSQSVF6.js +0 -6
- package/chunks/mod-A77UWGGG.js +0 -1
- package/chunks/next-47KYGODA.js +0 -7
- package/chunks/node-3FTYLC7H.js +0 -67
- package/chunks/node-BPWE6I45.js +0 -1
- package/chunks/ollama-LTZ43OHQ.js +0 -3
- package/chunks/openai-Y74OQTVB.js +0 -23
- package/chunks/opencode-PZDL7VDP.js +0 -1
- package/chunks/purge-G22VY6CI.js +0 -4
- package/chunks/reopen-63HEEXO6.js +0 -1
- package/chunks/reset-UDDESCDH.js +0 -1
- package/chunks/review-BC5HZNOU.js +0 -1
- package/chunks/run-GI2ZJ7BS.js +0 -3
- package/chunks/sdk-6IMATOQ3.js +0 -40
- package/chunks/spec-CLMOWKHY.js +0 -1
- package/chunks/sync-LPYKBDG2.js +0 -1
- package/chunks/vertexai-RUXZ24C2.js +0 -1
- package/chunks/watch-MONZHLBZ.js +0 -8
- package/chunks/web-PEDL6264.js +0 -1
- package/chunks/wontfix-A6OZSA3P.js +0 -1
- package/chunks/workerd-IIQRIOBX.js +0 -1
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import{c as Hr,e as Bi}from"./chunk-HISXAZ4Y.js";var Jo=Hr(an=>{"use strict";Object.defineProperty(an,"__esModule",{value:!0});an.timingSafeEqual=void 0;function Wo(n,e=""){if(!n)throw new Error(e)}function Ia(n,e){if(n.byteLength!==e.byteLength)return!1;n instanceof DataView||(n=new DataView(ArrayBuffer.isView(n)?n.buffer:n)),e instanceof DataView||(e=new DataView(ArrayBuffer.isView(e)?e.buffer:e)),Wo(n instanceof DataView),Wo(e instanceof DataView);let t=n.byteLength,r=0,s=-1;for(;++s<t;)r|=n.getUint8(s)^e.getUint8(s);return r===0}an.timingSafeEqual=Ia});var zo=Hr(re=>{"use strict";var Pa=re&&re.__extends||(function(){var n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var o in s)s.hasOwnProperty(o)&&(r[o]=s[o])},n(e,t)};return function(e,t){n(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}})();Object.defineProperty(re,"__esModule",{value:!0});var U=256,hs=(function(){function n(e){e===void 0&&(e="="),this._paddingCharacter=e}return n.prototype.encodedLength=function(e){return this._paddingCharacter?(e+2)/3*4|0:(e*8+5)/6|0},n.prototype.encode=function(e){for(var t="",r=0;r<e.length-2;r+=3){var s=e[r]<<16|e[r+1]<<8|e[r+2];t+=this._encodeByte(s>>>18&63),t+=this._encodeByte(s>>>12&63),t+=this._encodeByte(s>>>6&63),t+=this._encodeByte(s>>>0&63)}var o=e.length-r;if(o>0){var s=e[r]<<16|(o===2?e[r+1]<<8:0);t+=this._encodeByte(s>>>18&63),t+=this._encodeByte(s>>>12&63),o===2?t+=this._encodeByte(s>>>6&63):t+=this._paddingCharacter||"",t+=this._paddingCharacter||""}return t},n.prototype.maxDecodedLength=function(e){return this._paddingCharacter?e/4*3|0:(e*6+7)/8|0},n.prototype.decodedLength=function(e){return this.maxDecodedLength(e.length-this._getPaddingLength(e))},n.prototype.decode=function(e){if(e.length===0)return new Uint8Array(0);for(var t=this._getPaddingLength(e),r=e.length-t,s=new Uint8Array(this.maxDecodedLength(r)),o=0,a=0,l=0,c=0,h=0,g=0,d=0;a<r-4;a+=4)c=this._decodeChar(e.charCodeAt(a+0)),h=this._decodeChar(e.charCodeAt(a+1)),g=this._decodeChar(e.charCodeAt(a+2)),d=this._decodeChar(e.charCodeAt(a+3)),s[o++]=c<<2|h>>>4,s[o++]=h<<4|g>>>2,s[o++]=g<<6|d,l|=c&U,l|=h&U,l|=g&U,l|=d&U;if(a<r-1&&(c=this._decodeChar(e.charCodeAt(a)),h=this._decodeChar(e.charCodeAt(a+1)),s[o++]=c<<2|h>>>4,l|=c&U,l|=h&U),a<r-2&&(g=this._decodeChar(e.charCodeAt(a+2)),s[o++]=h<<4|g>>>2,l|=g&U),a<r-3&&(d=this._decodeChar(e.charCodeAt(a+3)),s[o++]=g<<6|d,l|=d&U),l!==0)throw new Error("Base64Coder: incorrect characters for decoding");return s},n.prototype._encodeByte=function(e){var t=e;return t+=65,t+=25-e>>>8&6,t+=51-e>>>8&-75,t+=61-e>>>8&-15,t+=62-e>>>8&3,String.fromCharCode(t)},n.prototype._decodeChar=function(e){var t=U;return t+=(42-e&e-44)>>>8&-U+e-43+62,t+=(46-e&e-48)>>>8&-U+e-47+63,t+=(47-e&e-58)>>>8&-U+e-48+52,t+=(64-e&e-91)>>>8&-U+e-65+0,t+=(96-e&e-123)>>>8&-U+e-97+26,t},n.prototype._getPaddingLength=function(e){var t=0;if(this._paddingCharacter){for(var r=e.length-1;r>=0&&e[r]===this._paddingCharacter;r--)t++;if(e.length<4||t>2)throw new Error("Base64Coder: incorrect padding")}return t},n})();re.Coder=hs;var mr=new hs;function Ta(n){return mr.encode(n)}re.encode=Ta;function Oa(n){return mr.decode(n)}re.decode=Oa;var Ko=(function(n){Pa(e,n);function e(){return n!==null&&n.apply(this,arguments)||this}return e.prototype._encodeByte=function(t){var r=t;return r+=65,r+=25-t>>>8&6,r+=51-t>>>8&-75,r+=61-t>>>8&-13,r+=62-t>>>8&49,String.fromCharCode(r)},e.prototype._decodeChar=function(t){var r=U;return r+=(44-t&t-46)>>>8&-U+t-45+62,r+=(94-t&t-96)>>>8&-U+t-95+63,r+=(47-t&t-58)>>>8&-U+t-48+52,r+=(64-t&t-91)>>>8&-U+t-65+0,r+=(96-t&t-123)>>>8&-U+t-97+26,r},e})(hs);re.URLSafeCoder=Ko;var Vo=new Ko;function Ma(n){return Vo.encode(n)}re.encodeURLSafe=Ma;function Ca(n){return Vo.decode(n)}re.decodeURLSafe=Ca;re.encodedLength=function(n){return mr.encodedLength(n)};re.maxDecodedLength=function(n){return mr.maxDecodedLength(n)};re.decodedLength=function(n){return mr.decodedLength(n)}});var Go=Hr((Xo,cn)=>{(function(n,e){var t={};e(t);var r=t.default;for(var s in t)r[s]=t[s];typeof cn=="object"&&typeof cn.exports=="object"?cn.exports=r:typeof define=="function"&&define.amd?define(function(){return r}):n.sha256=r})(Xo,function(n){"use strict";n.__esModule=!0,n.digestLength=32,n.blockSize=64;var e=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function t(d,f,p,b,v){for(var x,k,w,E,A,P,O,I,F,M,$,z,ue;v>=64;){for(x=f[0],k=f[1],w=f[2],E=f[3],A=f[4],P=f[5],O=f[6],I=f[7],M=0;M<16;M++)$=b+M*4,d[M]=(p[$]&255)<<24|(p[$+1]&255)<<16|(p[$+2]&255)<<8|p[$+3]&255;for(M=16;M<64;M++)F=d[M-2],z=(F>>>17|F<<15)^(F>>>19|F<<13)^F>>>10,F=d[M-15],ue=(F>>>7|F<<25)^(F>>>18|F<<14)^F>>>3,d[M]=(z+d[M-7]|0)+(ue+d[M-16]|0);for(M=0;M<64;M++)z=(((A>>>6|A<<26)^(A>>>11|A<<21)^(A>>>25|A<<7))+(A&P^~A&O)|0)+(I+(e[M]+d[M]|0)|0)|0,ue=((x>>>2|x<<30)^(x>>>13|x<<19)^(x>>>22|x<<10))+(x&k^x&w^k&w)|0,I=O,O=P,P=A,A=E+z|0,E=w,w=k,k=x,x=z+ue|0;f[0]+=x,f[1]+=k,f[2]+=w,f[3]+=E,f[4]+=A,f[5]+=P,f[6]+=O,f[7]+=I,b+=64,v-=64}return b}var r=(function(){function d(){this.digestLength=n.digestLength,this.blockSize=n.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return d.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this},d.prototype.clean=function(){for(var f=0;f<this.buffer.length;f++)this.buffer[f]=0;for(var f=0;f<this.temp.length;f++)this.temp[f]=0;this.reset()},d.prototype.update=function(f,p){if(p===void 0&&(p=f.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");var b=0;if(this.bytesHashed+=p,this.bufferLength>0){for(;this.bufferLength<64&&p>0;)this.buffer[this.bufferLength++]=f[b++],p--;this.bufferLength===64&&(t(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(p>=64&&(b=t(this.temp,this.state,f,b,p),p%=64);p>0;)this.buffer[this.bufferLength++]=f[b++],p--;return this},d.prototype.finish=function(f){if(!this.finished){var p=this.bytesHashed,b=this.bufferLength,v=p/536870912|0,x=p<<3,k=p%64<56?64:128;this.buffer[b]=128;for(var w=b+1;w<k-8;w++)this.buffer[w]=0;this.buffer[k-8]=v>>>24&255,this.buffer[k-7]=v>>>16&255,this.buffer[k-6]=v>>>8&255,this.buffer[k-5]=v>>>0&255,this.buffer[k-4]=x>>>24&255,this.buffer[k-3]=x>>>16&255,this.buffer[k-2]=x>>>8&255,this.buffer[k-1]=x>>>0&255,t(this.temp,this.state,this.buffer,0,k),this.finished=!0}for(var w=0;w<8;w++)f[w*4+0]=this.state[w]>>>24&255,f[w*4+1]=this.state[w]>>>16&255,f[w*4+2]=this.state[w]>>>8&255,f[w*4+3]=this.state[w]>>>0&255;return this},d.prototype.digest=function(){var f=new Uint8Array(this.digestLength);return this.finish(f),f},d.prototype._saveState=function(f){for(var p=0;p<this.state.length;p++)f[p]=this.state[p]},d.prototype._restoreState=function(f,p){for(var b=0;b<this.state.length;b++)this.state[b]=f[b];this.bytesHashed=p,this.finished=!1,this.bufferLength=0},d})();n.Hash=r;var s=(function(){function d(f){this.inner=new r,this.outer=new r,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var p=new Uint8Array(this.blockSize);if(f.length>this.blockSize)new r().update(f).finish(p).clean();else for(var b=0;b<f.length;b++)p[b]=f[b];for(var b=0;b<p.length;b++)p[b]^=54;this.inner.update(p);for(var b=0;b<p.length;b++)p[b]^=106;this.outer.update(p),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate);for(var b=0;b<p.length;b++)p[b]=0}return d.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},d.prototype.clean=function(){for(var f=0;f<this.istate.length;f++)this.ostate[f]=this.istate[f]=0;this.inner.clean(),this.outer.clean()},d.prototype.update=function(f){return this.inner.update(f),this},d.prototype.finish=function(f){return this.outer.finished?this.outer.finish(f):(this.inner.finish(f),this.outer.update(f,this.digestLength).finish(f)),this},d.prototype.digest=function(){var f=new Uint8Array(this.digestLength);return this.finish(f),f},d})();n.HMAC=s;function o(d){var f=new r().update(d),p=f.digest();return f.clean(),p}n.hash=o,n.default=o;function a(d,f){var p=new s(d).update(f),b=p.digest();return p.clean(),b}n.hmac=a;function l(d,f,p,b){var v=b[0];if(v===0)throw new Error("hkdf: cannot expand more");f.reset(),v>1&&f.update(d),p&&f.update(p),f.update(b),f.finish(d),b[0]++}var c=new Uint8Array(n.digestLength);function h(d,f,p,b){f===void 0&&(f=c),b===void 0&&(b=32);for(var v=new Uint8Array([1]),x=a(f,d),k=new s(x),w=new Uint8Array(k.digestLength),E=w.length,A=new Uint8Array(b),P=0;P<b;P++)E===w.length&&(l(w,k,p,v),E=0),A[P]=w[E++];return k.clean(),w.fill(0),v.fill(0),A}n.hkdf=h;function g(d,f,p,b){for(var v=new s(d),x=v.digestLength,k=new Uint8Array(4),w=new Uint8Array(x),E=new Uint8Array(x),A=new Uint8Array(b),P=0;P*x<b;P++){var O=P+1;k[0]=O>>>24&255,k[1]=O>>>16&255,k[2]=O>>>8&255,k[3]=O>>>0&255,v.reset(),v.update(f),v.update(k),v.finish(E);for(var I=0;I<x;I++)w[I]=E[I];for(var I=2;I<=p;I++){v.reset(),v.update(E).finish(E);for(var F=0;F<x;F++)w[F]^=E[F]}for(var I=0;I<x&&P*x+I<b;I++)A[P*x+I]=w[I]}for(var P=0;P<x;P++)w[P]=E[P]=0;for(var P=0;P<4;P++)k[P]=0;return v.clean(),A}n.pbkdf2=g})});var Zo=Hr(It=>{"use strict";Object.defineProperty(It,"__esModule",{value:!0});It.Webhook=It.WebhookVerificationError=void 0;var Na=Jo(),Yo=zo(),$a=Go(),Qo=300,fs=class n extends Error{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype),this.name="ExtendableError",this.stack=new Error(e).stack}},Pe=class n extends fs{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype),this.name="WebhookVerificationError"}};It.WebhookVerificationError=Pe;var ln=class n{constructor(e,t){if(!e)throw new Error("Secret can't be empty.");if(t?.format==="raw")e instanceof Uint8Array?this.key=e:this.key=Uint8Array.from(e,r=>r.charCodeAt(0));else{if(typeof e!="string")throw new Error("Expected secret to be of type string");e.startsWith(n.prefix)&&(e=e.substring(n.prefix.length)),this.key=Yo.decode(e)}}verify(e,t){let r={};for(let f of Object.keys(t))r[f.toLowerCase()]=t[f];let s=r["webhook-id"],o=r["webhook-signature"],a=r["webhook-timestamp"];if(!o||!s||!a)throw new Pe("Missing required headers");let l=this.verifyTimestamp(a),h=this.sign(s,l,e).split(",")[1],g=o.split(" "),d=new globalThis.TextEncoder;for(let f of g){let[p,b]=f.split(",");if(p==="v1"&&(0,Na.timingSafeEqual)(d.encode(b),d.encode(h)))return JSON.parse(e.toString())}throw new Pe("No matching signature found")}sign(e,t,r){if(typeof r!="string")if(r.constructor.name==="Buffer")r=r.toString();else throw new Error("Expected payload to be of type string or Buffer.");let s=new TextEncoder,o=Math.floor(t.getTime()/1e3),a=s.encode(`${e}.${o}.${r}`);return`v1,${Yo.encode($a.hmac(this.key,a))}`}verifyTimestamp(e){let t=Math.floor(Date.now()/1e3),r=parseInt(e,10);if(isNaN(r))throw new Pe("Invalid Signature Headers");if(t-r>Qo)throw new Pe("Message timestamp too old");if(r>t+Qo)throw new Pe("Message timestamp too new");return new Date(r*1e3)}};It.Webhook=ln;ln.prefix="whsec_"});function _(n,e,t,r,s){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?n!==e||!s:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?s.call(n,t):s?s.value=t:e.set(n,t),t}function i(n,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?n!==e||!r:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(n):r?r.value:e.get(n)}var lt=function(){let{crypto:n}=globalThis;if(n?.randomUUID)return lt=n.randomUUID.bind(n),n.randomUUID();let e=new Uint8Array(1),t=n?()=>n.getRandomValues(e)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,r=>(+r^t()&15>>+r/4).toString(16))};function Z(n){return typeof n=="object"&&n!==null&&("name"in n&&n.name==="AbortError"||"message"in n&&String(n.message).includes("FetchRequestCanceledException"))}var We=n=>{if(n instanceof Error)return n;if(typeof n=="object"&&n!==null){try{if(Object.prototype.toString.call(n)==="[object Error]"){let e=new Error(n.message,n.cause?{cause:n.cause}:{});return n.stack&&(e.stack=n.stack),n.cause&&!e.cause&&(e.cause=n.cause),n.name&&(e.name=n.name),e}}catch{}try{return new Error(JSON.stringify(n))}catch{}}return new Error(n)};var y=class extends Error{},B=class n extends y{constructor(e,t,r,s,o){super(`${n.makeMessage(e,t,r)}`),this.status=e,this.headers=s,this.requestID=s?.get("request-id"),this.error=t,this.type=o??null}static makeMessage(e,t,r){let s=t?.message?typeof t.message=="string"?t.message:JSON.stringify(t.message):t?JSON.stringify(t):r;return e&&s?`${e} ${s}`:e?`${e} status code (no body)`:s||"(no status code or body)"}static generate(e,t,r,s){if(!e||!s)return new pe({message:r,cause:We(t)});let o=t,a=o?.error?.type;return e===400?new dt(e,o,r,s,a):e===401?new ht(e,o,r,s,a):e===403?new ft(e,o,r,s,a):e===404?new pt(e,o,r,s,a):e===409?new mt(e,o,r,s,a):e===422?new _t(e,o,r,s,a):e===429?new gt(e,o,r,s,a):e>=500?new bt(e,o,r,s,a):new n(e,o,r,s,a)}},J=class extends B{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}},pe=class extends B{constructor({message:e,cause:t}){super(void 0,void 0,e||"Connection error.",void 0),t&&(this.cause=t)}},ut=class extends pe{constructor({message:e}={}){super({message:e??"Request timed out."})}},tr=class extends y{constructor(e,{cause:t}={}){super(e??"Retryable error."),t!==void 0&&(this.cause=t)}},dt=class extends B{},ht=class extends B{},ft=class extends B{},pt=class extends B{},mt=class extends B{},_t=class extends B{},gt=class extends B{},bt=class extends B{};var ji=/^[a-z][a-z0-9+.-]*:/i,Ws=n=>ji.test(n),V=n=>(V=Array.isArray,V(n)),Un=V;function rr(n){return typeof n!="object"?{}:n??{}}function jn(n){if(!n)return!0;for(let e in n)return!1;return!0}function Js(n,e){return Object.prototype.hasOwnProperty.call(n,e)}var Ks=(n,e)=>{if(typeof e!="number"||!Number.isInteger(e))throw new y(`${n} must be an integer`);if(e<0)throw new y(`${n} must be a positive integer`);return e};var Je=n=>{try{return JSON.parse(n)}catch{return}};var de=(n,e)=>new Promise(t=>{if(e?.aborted)return t();let r=()=>{clearTimeout(s),t()},s=setTimeout(()=>{e?.removeEventListener("abort",r),t()},n);e?.addEventListener("abort",r,{once:!0})});var oe="0.115.0";var Gs=()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u";function qi(){return typeof Deno<"u"&&Deno.build!=null?"deno":typeof EdgeRuntime<"u"?"edge":Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]"?"node":"unknown"}var Wi=()=>{let n=qi();if(n==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":oe,"X-Stainless-OS":zs(Deno.build.os),"X-Stainless-Arch":Vs(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version=="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":oe,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(n==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":oe,"X-Stainless-OS":zs(globalThis.process.platform??"unknown"),"X-Stainless-Arch":Vs(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let e=Ji();return e?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":oe,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${e.browser}`,"X-Stainless-Runtime-Version":e.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":oe,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function Ji(){if(typeof navigator>"u"||!navigator)return null;let n=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(let{key:e,pattern:t}of n){let r=t.exec(navigator.userAgent);if(r){let s=r[1]||0,o=r[2]||0,a=r[3]||0;return{browser:e,version:`${s}.${o}.${a}`}}}return null}var Vs=n=>n==="x32"?"x32":n==="x86_64"||n==="x64"?"x64":n==="arm"?"arm":n==="aarch64"||n==="arm64"?"arm64":n?`other:${n}`:"unknown",zs=n=>(n=n.toLowerCase(),n.includes("ios")?"iOS":n==="android"?"Android":n==="darwin"?"MacOS":n==="win32"?"Windows":n==="freebsd"?"FreeBSD":n==="openbsd"?"OpenBSD":n==="linux"?"Linux":n?`Other:${n}`:"Unknown"),Xs,nr=()=>Xs??(Xs=Wi());var Lr=new WeakMap,Ys=typeof globalThis.FinalizationRegistry=="function"?new globalThis.FinalizationRegistry(n=>me(n)):null;function Ki(n,e){return()=>n.removeEventListener("abort",e)}function Qs(n,e,t){Lr.set(n,Ki(e,t))}function Zs(n,e){Lr.has(e)&&Ys?.register(n,e,e)}function me(n){let e=Lr.get(n);e&&(Lr.delete(n),Ys?.unregister(n),e())}function eo(){if(typeof fetch<"u")return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new Anthropic({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function qn(...n){let e=globalThis.ReadableStream;if(typeof e>"u")throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new e(...n)}function Dr(n){let e=Symbol.asyncIterator in n?n[Symbol.asyncIterator]():n[Symbol.iterator]();return qn({start(){},async pull(t){let{done:r,value:s}=await e.next();r?t.close():t.enqueue(s)},async cancel(){await e.return?.()}})}function sr(n){if(n[Symbol.asyncIterator])return n;let e=n.getReader();return{async next(){try{let t=await e.read();return t?.done&&e.releaseLock(),t}catch(t){throw e.releaseLock(),t}},async return(){let t=e.cancel();return e.releaseLock(),await t,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function to(n){if(n===null||typeof n!="object")return;if(n[Symbol.asyncIterator]){await n[Symbol.asyncIterator]().return?.();return}let e=n.getReader(),t=e.cancel();e.releaseLock(),await t}var Br=class{},ro=({headers:n,body:e})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(e)});var Wn="RFC3986",Jn=n=>String(n),Kn={RFC1738:n=>String(n).replace(/%20/g,"+"),RFC3986:Jn},no="RFC1738";var Ur=(n,e)=>(Ur=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),Ur(n,e)),_e=(()=>{let n=[];for(let e=0;e<256;++e)n.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return n})();var Vn=1024,so=(n,e,t,r,s)=>{if(n.length===0)return n;let o=n;if(typeof n=="symbol"?o=Symbol.prototype.toString.call(n):typeof n!="string"&&(o=String(n)),t==="iso-8859-1")return escape(o).replace(/%u[0-9a-f]{4}/gi,function(l){return"%26%23"+parseInt(l.slice(2),16)+"%3B"});let a="";for(let l=0;l<o.length;l+=Vn){let c=o.length>=Vn?o.slice(l,l+Vn):o,h=[];for(let g=0;g<c.length;++g){let d=c.charCodeAt(g);if(d===45||d===46||d===95||d===126||d>=48&&d<=57||d>=65&&d<=90||d>=97&&d<=122||s===no&&(d===40||d===41)){h[h.length]=c.charAt(g);continue}if(d<128){h[h.length]=_e[d];continue}if(d<2048){h[h.length]=_e[192|d>>6]+_e[128|d&63];continue}if(d<55296||d>=57344){h[h.length]=_e[224|d>>12]+_e[128|d>>6&63]+_e[128|d&63];continue}g+=1,d=65536+((d&1023)<<10|c.charCodeAt(g)&1023),h[h.length]=_e[240|d>>18]+_e[128|d>>12&63]+_e[128|d>>6&63]+_e[128|d&63]}a+=h.join("")}return a};function oo(n){return!n||typeof n!="object"?!1:!!(n.constructor&&n.constructor.isBuffer&&n.constructor.isBuffer(n))}function zn(n,e){if(V(n)){let t=[];for(let r=0;r<n.length;r+=1)t.push(e(n[r]));return t}return e(n)}var ao={brackets(n){return String(n)+"[]"},comma:"comma",indices(n,e){return String(n)+"["+e+"]"},repeat(n){return String(n)}},co=function(n,e){Array.prototype.push.apply(n,V(e)?e:[e])},io,j={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:so,encodeValuesOnly:!1,format:Wn,formatter:Jn,indices:!1,serializeDate(n){return(io??(io=Function.prototype.call.bind(Date.prototype.toISOString)))(n)},skipNulls:!1,strictNullHandling:!1};function Xi(n){return typeof n=="string"||typeof n=="number"||typeof n=="boolean"||typeof n=="symbol"||typeof n=="bigint"}var Xn={};function lo(n,e,t,r,s,o,a,l,c,h,g,d,f,p,b,v,x,k){let w=n,E=k,A=0,P=!1;for(;(E=E.get(Xn))!==void 0&&!P;){let $=E.get(n);if(A+=1,typeof $<"u"){if($===A)throw new RangeError("Cyclic object value");P=!0}typeof E.get(Xn)>"u"&&(A=0)}if(typeof h=="function"?w=h(e,w):w instanceof Date?w=f?.(w):t==="comma"&&V(w)&&(w=zn(w,function($){return $ instanceof Date?f?.($):$})),w===null){if(o)return c&&!v?c(e,j.encoder,x,"key",p):e;w=""}if(Xi(w)||oo(w)){if(c){let $=v?e:c(e,j.encoder,x,"key",p);return[b?.($)+"="+b?.(c(w,j.encoder,x,"value",p))]}return[b?.(e)+"="+b?.(String(w))]}let O=[];if(typeof w>"u")return O;let I;if(t==="comma"&&V(w))v&&c&&(w=zn(w,c)),I=[{value:w.length>0?w.join(",")||null:void 0}];else if(V(h))I=h;else{let $=Object.keys(w);I=g?$.sort(g):$}let F=l?String(e).replace(/\./g,"%2E"):String(e),M=r&&V(w)&&w.length===1?F+"[]":F;if(s&&V(w)&&w.length===0)return M+"[]";for(let $=0;$<I.length;++$){let z=I[$],ue=typeof z=="object"&&typeof z.value<"u"?z.value:w[z];if(a&&ue===null)continue;let Ie=d&&l?z.replace(/\./g,"%2E"):z,Di=V(w)?typeof t=="function"?t(M,Ie):M:M+(d?"."+Ie:"["+Ie+"]");k.set(n,A);let qs=new WeakMap;qs.set(Xn,k),co(O,lo(ue,Di,t,r,s,o,a,l,t==="comma"&&v&&V(w)?null:c,h,g,d,f,p,b,v,x,qs))}return O}function Gi(n=j){if(typeof n.allowEmptyArrays<"u"&&typeof n.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof n.encodeDotInKeys<"u"&&typeof n.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(n.encoder!==null&&typeof n.encoder<"u"&&typeof n.encoder!="function")throw new TypeError("Encoder has to be a function.");let e=n.charset||j.charset;if(typeof n.charset<"u"&&n.charset!=="utf-8"&&n.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let t=Wn;if(typeof n.format<"u"){if(!Ur(Kn,n.format))throw new TypeError("Unknown format option provided.");t=n.format}let r=Kn[t],s=j.filter;(typeof n.filter=="function"||V(n.filter))&&(s=n.filter);let o;if(n.arrayFormat&&n.arrayFormat in ao?o=n.arrayFormat:"indices"in n?o=n.indices?"indices":"repeat":o=j.arrayFormat,"commaRoundTrip"in n&&typeof n.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");let a=typeof n.allowDots>"u"?n.encodeDotInKeys?!0:j.allowDots:!!n.allowDots;return{addQueryPrefix:typeof n.addQueryPrefix=="boolean"?n.addQueryPrefix:j.addQueryPrefix,allowDots:a,allowEmptyArrays:typeof n.allowEmptyArrays=="boolean"?!!n.allowEmptyArrays:j.allowEmptyArrays,arrayFormat:o,charset:e,charsetSentinel:typeof n.charsetSentinel=="boolean"?n.charsetSentinel:j.charsetSentinel,commaRoundTrip:!!n.commaRoundTrip,delimiter:typeof n.delimiter>"u"?j.delimiter:n.delimiter,encode:typeof n.encode=="boolean"?n.encode:j.encode,encodeDotInKeys:typeof n.encodeDotInKeys=="boolean"?n.encodeDotInKeys:j.encodeDotInKeys,encoder:typeof n.encoder=="function"?n.encoder:j.encoder,encodeValuesOnly:typeof n.encodeValuesOnly=="boolean"?n.encodeValuesOnly:j.encodeValuesOnly,filter:s,format:t,formatter:r,serializeDate:typeof n.serializeDate=="function"?n.serializeDate:j.serializeDate,skipNulls:typeof n.skipNulls=="boolean"?n.skipNulls:j.skipNulls,sort:typeof n.sort=="function"?n.sort:null,strictNullHandling:typeof n.strictNullHandling=="boolean"?n.strictNullHandling:j.strictNullHandling}}function uo(n,e={}){let t=n,r=Gi(e),s,o;typeof r.filter=="function"?(o=r.filter,t=o("",t)):V(r.filter)&&(o=r.filter,s=o);let a=[];if(typeof t!="object"||t===null)return"";let l=ao[r.arrayFormat],c=l==="comma"&&r.commaRoundTrip;s||(s=Object.keys(t)),r.sort&&s.sort(r.sort);let h=new WeakMap;for(let f=0;f<s.length;++f){let p=s[f];r.skipNulls&&t[p]===null||co(a,lo(t[p],p,l,c,r.allowEmptyArrays,r.strictNullHandling,r.skipNulls,r.encodeDotInKeys,r.encode?r.encoder:null,r.filter,r.sort,r.allowDots,r.serializeDate,r.format,r.formatter,r.encodeValuesOnly,r.charset,h))}let g=a.join(r.delimiter),d=r.addQueryPrefix===!0?"?":"";return r.charsetSentinel&&(r.charset==="iso-8859-1"?d+="utf8=%26%2310003%3B&":d+="utf8=%E2%9C%93&"),g.length>0?d+g:""}function ho(n){return uo(n,{arrayFormat:"brackets"})}var po="urn:ietf:params:oauth:grant-type:jwt-bearer",mo="refresh_token",jr="/v1/oauth/token",Ke="oauth-2025-04-20",_o="oidc-federation-2026-04-01",go=120,yt=30,bo=5,fo=1<<20;function qr(n){if(!n)return;let e;try{e=new URL(n)}catch(r){throw new N(`Invalid token endpoint base URL "${n}": ${r}`)}if(e.protocol==="https:")return;let t=e.hostname.toLowerCase().replace(/^\[|\]$/g,"");if(!(e.protocol==="http:"&&(t==="localhost"||t==="127.0.0.1"||t==="::1")))throw new N(`Refusing to send credential over non-https token endpoint "${n}"`)}async function Wr(n,e){let t=await Zi(n),r;try{r=JSON.parse(t)}catch{throw new N(`Token endpoint returned non-JSON response (status ${n.status})`,n.status,X(t),e)}if(!r.access_token)throw new N(`Token endpoint response missing access_token: ${JSON.stringify(X(r))}`,n.status,X(r),e);if(r.token_type&&r.token_type.toLowerCase()!=="bearer")throw new N(`Token endpoint response: unsupported token_type "${r.token_type}" (want Bearer)`,n.status,X(r),e);return r}var Gn=2e3,Qi=new Set(["error","error_description","error_uri"]);function X(n){if(n==null)return n;if(typeof n=="string"){let e;try{e=JSON.parse(n)}catch{return n.length<=Gn?n:n.slice(0,Gn)+`... <${n.length-Gn} more chars>`}return JSON.stringify(X(e))}if(typeof n=="object"&&!Array.isArray(n)){let e={};for(let[t,r]of Object.entries(n))Qi.has(t)&&(e[t]=r);return e}return null}async function Jr(n,e=t=>console.warn(`anthropic-sdk: ${t}`)){if(typeof process>"u"||process.platform==="win32")return;let t=await import("node:fs"),r=n,s;try{r=await t.promises.realpath(n),s=await t.promises.stat(r)}catch{return}let o=s.mode&511;if(o&18)throw new N(`Credentials file at ${r} is group/world-writable (mode 0o${o.toString(8)}); this allows other local users to plant tokens. Run \`chmod 600 ${r}\`.`);if(o&36)throw new N(`Credentials file at ${r} is group/world-readable (mode 0o${o.toString(8)}); run \`chmod 600 ${r}\` before retrying.`);typeof process.getuid=="function"&&s.uid!==process.getuid()&&e(`credentials file at ${r} is owned by uid ${s.uid} (current process uid ${process.getuid()}); verify this is intentional.`)}async function Kr(n,e){let t=await import("node:fs"),s=(await import("node:path")).dirname(n);await t.promises.mkdir(s,{recursive:!0,mode:448});let o=`${n}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;try{let a=await t.promises.open(o,"w",384);try{await a.writeFile(JSON.stringify(e,null,2)),await a.sync()}finally{await a.close()}await t.promises.rename(o,n)}catch(a){throw await t.promises.unlink(o).catch(()=>{}),a}try{let a=await t.promises.open(s,"r");try{await a.sync()}finally{await a.close()}}catch{}}async function Zi(n){if(!n.body)return"";let e=n.body.getReader(),t=[],r=0;for(;;){let{done:o,value:a}=await e.read();if(o)break;if(r+a.length>fo){let l=fo-r;l>0&&t.push(a.subarray(0,l)),await e.cancel();break}t.push(a),r+=a.length}let s;if(t.length===1)s=t[0];else{s=new Uint8Array(t.reduce((a,l)=>a+l.length,0));let o=0;for(let a of t)s.set(a,o),o+=a.length}return new TextDecoder("utf-8").decode(s)}var N=class extends y{constructor(e,t=null,r=null,s=null){super(e),this.statusCode=t,this.body=r,this.requestId=s}};function he(){return Math.floor(Date.now()/1e3)}var Vr=class{constructor(e,t){this.cached=null,this.pendingRefresh=null,this.nextForce=!1,this.lastAdvisoryError=0,this.provider=e,this.onAdvisoryRefreshError=t}async getToken(){let e=this.nextForce;this.nextForce=!1;let t=this.cached;if(e||t==null)return(await this.refresh(e)).token;if(t.expiresAt==null)return t.token;let r=t.expiresAt-he();return r>go?t.token:r>yt?(this.backgroundRefresh(),t.token):(await this.refresh()).token}invalidate(){this.cached=null,this.nextForce=!0}refresh(e=!1){return this.pendingRefresh&&!e?this.pendingRefresh:this.doRefresh(e)}backgroundRefresh(){this.pendingRefresh||he()-this.lastAdvisoryError<bo||this.doRefresh().catch(e=>{this.lastAdvisoryError=he(),this.onAdvisoryRefreshError?.(e)})}doRefresh(e=!1){return this.pendingRefresh=this.provider(e?{forceRefresh:!0}:void 0).then(t=>(this.cached=t,this.pendingRefresh=null,t),t=>{throw this.pendingRefresh=null,t}),this.pendingRefresh}};var T=n=>{if(typeof globalThis.process<"u")return globalThis.process.env?.[n]?.trim()||void 0;if(typeof globalThis.Deno<"u")return globalThis.Deno.env?.get?.(n)?.trim()||void 0};function So(n){let e=0;for(let s of n)e+=s.length;let t=new Uint8Array(e),r=0;for(let s of n)t.set(s,r),r+=s.length;return t}var yo;function wt(n){let e;return(yo??(e=new globalThis.TextEncoder,yo=e.encode.bind(e)))(n)}var wo;function Yn(n){let e;return(wo??(e=new globalThis.TextDecoder,wo=e.decode.bind(e)))(n)}var ir="warn",Xr={off:0,error:200,warn:300,info:400,debug:500},Gr=(n,e,t)=>{if(n){if(Js(Xr,n))return n;t.warn(`${e} was set to ${JSON.stringify(n)}, expected one of ${JSON.stringify(Object.keys(Xr))}`)}};function or(){}function zr(n,e,t){return!e||Xr[n]>Xr[t]?or:e[n].bind(e)}var ea={error:or,warn:or,info:or,debug:or},xo=new WeakMap;function Zn(n,e){let t=xo.get(n);if(t&&t[0]===e)return t[1];let r={error:zr("error",n,e),warn:zr("warn",n,e),info:zr("info",n,e),debug:zr("debug",n,e)};return xo.set(n,[e,r]),r}function C(n){let e=n.logger,t=n.logLevel??"off";return e?Zn(e,t):ea}var ko,Qn;function Eo(){let n=T("ANTHROPIC_LOG");return(!Qn||n!==ko)&&(ko=n,Qn=Zn(console,Gr(n,"process.env['ANTHROPIC_LOG']",Zn(console,ir))??ir)),Qn}var ge=n=>(n.options&&(n.options={...n.options},delete n.options.headers),n.headers&&(n.headers=Object.fromEntries((n.headers instanceof Headers?[...n.headers]:Object.entries(n.headers)).map(([e,t])=>[e,e.toLowerCase()==="authorization"||e.toLowerCase()==="api-key"||e.toLowerCase()==="x-api-key"||e.toLowerCase()==="cookie"||e.toLowerCase()==="set-cookie"?"***":t]))),"retryOfRequestLogID"in n&&(n.retryOfRequestLogID&&(n.retryOf=n.retryOfRequestLogID),delete n.retryOfRequestLogID),n);var Yr="1.0",ta=/^[A-Za-z0-9_.-]+$/;function vo(n){if(!n)throw new Error("profile name is empty");if(n==="."||n==="..")throw new Error(`profile name "${n}" is not allowed`);if(n.includes("/")||n.includes("\\"))throw new Error(`profile name "${n}" must not contain path separators`);if(!ta.test(n))throw new Error(`profile name "${n}" contains disallowed characters (allowed: letters, digits, '_', '.', '-')`)}var Ao=async n=>{var e,t;let r=await es();if(r===null)return null;let s=n??await Io();if(s===null)return null;vo(s);let o=await import("node:fs"),l=(await import("node:path")).join(r,"configs",`${s}.json`),c;try{c=await o.promises.readFile(l,"utf-8")}catch(d){if(d?.code!=="ENOENT")throw new Error(`failed to read config file ${l}: ${d}`);c=null}if(c===null){let d=T("ANTHROPIC_ORGANIZATION_ID"),f=T("ANTHROPIC_IDENTITY_TOKEN_FILE"),p=T("ANTHROPIC_FEDERATION_RULE_ID");return p&&d?{fromFile:!1,config:{organization_id:d,workspace_id:T("ANTHROPIC_WORKSPACE_ID"),base_url:T("ANTHROPIC_BASE_URL"),authentication:{type:"oidc_federation",federation_rule_id:p,service_account_id:T("ANTHROPIC_SERVICE_ACCOUNT_ID"),identity_token:f?{source:"file",path:f}:void 0,scope:T("ANTHROPIC_SCOPE")}}}:null}let h;try{h=JSON.parse(c)}catch(d){throw new Error(`failed to parse config file ${l}: ${d}`)}if(!h.authentication)throw new Error(`config file ${l} is missing "authentication"`);let g=h.authentication.type;if(g!=="oidc_federation"&&g!=="user_oauth")throw new Error(`authentication.type "${g}" is not a known authentication type`);if(h.organization_id??(h.organization_id=T("ANTHROPIC_ORGANIZATION_ID")),h.workspace_id??(h.workspace_id=T("ANTHROPIC_WORKSPACE_ID")),h.base_url??(h.base_url=T("ANTHROPIC_BASE_URL")),(e=h.authentication).scope??(e.scope=T("ANTHROPIC_SCOPE")),h.authentication.type==="oidc_federation"){if(!h.authentication.identity_token){let d=T("ANTHROPIC_IDENTITY_TOKEN_FILE");d&&(h.authentication.identity_token={source:"file",path:d})}h.authentication.federation_rule_id||(h.authentication.federation_rule_id=T("ANTHROPIC_FEDERATION_RULE_ID")??""),(t=h.authentication).service_account_id??(t.service_account_id=T("ANTHROPIC_SERVICE_ACCOUNT_ID"))}return{config:h,fromFile:!0}};var Ro=async(n,e)=>{if(n?.authentication.credentials_path)return n.authentication.credentials_path;let t=await es();if(!t)return null;let r=e??await Io();return r?(vo(r),(await import("node:path")).join(t,"credentials",`${r}.json`)):null},es=async()=>{if(!ra())return null;let n=await import("node:path"),e=T("ANTHROPIC_CONFIG_DIR");if(e)return e;if(nr()["X-Stainless-OS"]==="Windows"){let o=T("APPDATA");if(o)return n.join(o,"Anthropic");let a=T("USERPROFILE");return a?n.join(a,"AppData","Roaming","Anthropic"):null}let r=T("XDG_CONFIG_HOME");if(r)return n.join(r,"anthropic");let s=T("HOME");return s?n.join(s,".config","anthropic"):null},ra=()=>{let n=nr()["X-Stainless-Runtime"];return n==="node"||n==="deno"},Io=async()=>{let n=await es();if(!n)return null;let e=T("ANTHROPIC_PROFILE");if(e)return e;let t=await import("node:fs"),s=(await import("node:path")).join(n,"active_config");try{return(await t.promises.readFile(s,"utf-8")).trim()||"default"}catch(o){if(o?.code!=="ENOENT")throw new Error(`failed to read ${s}: ${o}`);return"default"}};function ts(n){if(!n)throw new y("Identity token file path is empty");return async()=>{let e=await import("node:fs"),t;try{t=await e.promises.readFile(n,"utf-8")}catch(s){throw new y(`Failed to read identity token file at ${n}: ${s}`)}let r=t.trim();if(!r)throw new y(`Identity token file at ${n} is empty`);return r}}function Po(n){if(!n)throw new y("Identity token value is empty");return()=>n}function To(n){return async()=>{qr(n.baseURL);let e=await n.identityTokenProvider();if(e.length>16*1024)throw new N(`Identity token is ${Math.ceil(e.length/1024)} KiB, exceeds the 16 KiB assertion limit`);let t={grant_type:po,assertion:e,federation_rule_id:n.federationRuleId,organization_id:n.organizationId};n.serviceAccountId&&(t.service_account_id=n.serviceAccountId),n.workspaceId&&(t.workspace_id=n.workspaceId);let r=`${n.baseURL}${jr}`,s;try{s=await n.fetch(r,{method:"POST",headers:{"Content-Type":"application/json","anthropic-beta":`${Ke},${_o}`,"User-Agent":n.userAgent||`anthropic-sdk-typescript/${oe} oidcFederationProvider`},body:JSON.stringify(t)})}catch(c){throw new N(`Failed to reach token endpoint ${r}: ${c}`)}let o=s.headers.get("Request-Id");if(!s.ok){let c=await s.text().catch(()=>""),h=X(c),g="";throw s.status===401&&(g=` Ensure your federation rule matches your identity token. ${n.workspaceId?"":"If your federation rule is scoped to multiple workspaces, set the ANTHROPIC_WORKSPACE_ID environment variable, the 'workspace_id' config key, or the `workspaceId` option. "}View your authentication events in the Workload identity page of Claude Console for more details.`),new N(`Token exchange failed with status ${s.status}${o?` (request-id ${o})`:""}: ${h}${g}`,s.status,h,o)}let a=await Wr(s,o),l=Number(a.expires_in);if(!Number.isFinite(l))throw new N(`Token endpoint response missing required fields: ${JSON.stringify(X(a))}`,s.status,X(a),o);return{token:a.access_token,expiresAt:he()+l}}}function Oo(n){return async e=>{let t=await import("node:fs");await Jr(n.credentialsPath,n.onSafetyWarning);let r;try{r=await t.promises.readFile(n.credentialsPath,"utf-8")}catch(x){throw new N(`Credentials file not found at ${n.credentialsPath}: ${x}`)}let s;try{s=JSON.parse(r)}catch(x){throw new N(`Credentials file at ${n.credentialsPath} is not valid JSON: ${x}`)}let o=s.access_token;if(!o)throw new N(`Credentials file at ${n.credentialsPath} must include 'access_token'`);let a=s.expires_at;if(!e?.forceRefresh&&(a==null||he()<a-yt))return{token:o,expiresAt:a??null};let l=s.refresh_token;if(!n.clientId||!l)throw new N(`Access token at ${n.credentialsPath} has expired and no refresh is available (client_id ${n.clientId?"set":"empty"}, refresh_token ${l?"set":"empty"})`);qr(n.baseURL);let c={grant_type:mo,refresh_token:l,client_id:n.clientId},h=`${n.baseURL}${jr}`,g;try{g=await n.fetch(h,{method:"POST",headers:{"Content-Type":"application/json","anthropic-beta":Ke,"User-Agent":n.userAgent||`anthropic-sdk-typescript/${oe} userOAuthProvider`},body:JSON.stringify(c)})}catch(x){throw new N(`User OAuth refresh failed to reach token endpoint: ${x}`)}let d=g.headers.get("Request-Id");if(!g.ok){let x=await g.text().catch(()=>"");throw new N(`User OAuth refresh failed (HTTP ${g.status}): ${X(x)}`,g.status,X(x),d)}let f=await Wr(g,d),p=Number(f.expires_in);if(!Number.isFinite(p))throw new N(`User OAuth refresh response missing or invalid expires_in: ${JSON.stringify(X(f))}`,g.status,X(f),d);let b=he()+p,v=f.refresh_token||l;return await Kr(n.credentialsPath,{...s,version:Yr,type:"oauth_token",access_token:f.access_token,expires_at:b,refresh_token:v}),{token:f.access_token,expiresAt:b}}}function rs(n,e){let t=n.authentication.credentials_path??null,r=(n.base_url||e.baseURL).replace(/\/+$/,""),s=na(n,t,r,e),o={};return n.workspace_id&&n.authentication.type==="user_oauth"&&(o["anthropic-workspace-id"]=n.workspace_id),{provider:s,extraHeaders:o,baseURL:n.base_url||void 0}}async function Mo(n,e){let t=await Ao(e);if(!t)return null;let{config:r,fromFile:s}=t,o=r.authentication.credentials_path||!s?r:{...r,authentication:{...r.authentication,credentials_path:await Ro(r,e)??void 0}};return rs(o,n)}function na(n,e,t,r){switch(n.authentication.type){case"oidc_federation":{let s=n.authentication,o=sa(s);if(!o)throw new N("oidc_federation config requires an identity token (set authentication.identity_token, ANTHROPIC_IDENTITY_TOKEN_FILE, or ANTHROPIC_IDENTITY_TOKEN)");if(!s.federation_rule_id)throw new N("oidc_federation config requires 'federation_rule_id'. Set it in authentication.federation_rule_id in your profile, or via ANTHROPIC_FEDERATION_RULE_ID (profile takes precedence).");if(!n.organization_id)throw new N("oidc_federation config requires organization_id (set ANTHROPIC_ORGANIZATION_ID or config.organization_id)");let a=To({identityTokenProvider:o,federationRuleId:s.federation_rule_id,organizationId:n.organization_id,serviceAccountId:s.service_account_id,workspaceId:n.workspace_id,baseURL:t,fetch:r.fetch,userAgent:r.userAgent});return e?oa(a,e,r.onCacheWriteError,r.onSafetyWarning):a}case"user_oauth":{if(!e)throw new N("user_oauth config requires authentication.credentials_path (or load via a profile so it defaults to <config_dir>/credentials/<profile>.json)");return Oo({credentialsPath:e,clientId:n.authentication.client_id,baseURL:t,fetch:r.fetch,userAgent:r.userAgent,onSafetyWarning:r.onSafetyWarning})}default:{let s=n.authentication.type;throw new N(`authentication.type "${s}" is not a known authentication type`)}}}function sa(n){if(n.identity_token){let r=n.identity_token.source;if(r!=="file")throw new N(`identity_token.source "${r}" is not supported by this SDK version (only "file")`);if(!n.identity_token.path)throw new N('identity_token.source "file" requires a non-empty path');return ts(n.identity_token.path)}let e=T("ANTHROPIC_IDENTITY_TOKEN_FILE");if(e)return ts(e);let t=T("ANTHROPIC_IDENTITY_TOKEN");return t?Po(t):null}function oa(n,e,t,r){return async s=>{let o=await import("node:fs");await Jr(e,r);let a;try{let c=await o.promises.readFile(e,"utf-8");a=JSON.parse(c);let h=a?.access_token;if(h&&!s?.forceRefresh){let g=a?.expires_at;if(g==null||he()<g-yt)return{token:h,expiresAt:g??null}}}catch(c){c?.code!=="ENOENT"&&!(c instanceof SyntaxError)&&t?.(c)}let l=await n(s);try{await Kr(e,{...a??{},version:Yr,type:"oauth_token",access_token:l.token,expires_at:l.expiresAt})}catch(c){t?.(c)}return l}}var ee,te,Se=class{constructor(){ee.set(this,void 0),te.set(this,void 0),_(this,ee,new Uint8Array,"f"),_(this,te,null,"f")}decode(e){if(e==null)return[];let t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e=="string"?wt(e):e;_(this,ee,So([i(this,ee,"f"),t]),"f");let r=[],s;for(;(s=ia(i(this,ee,"f"),i(this,te,"f")))!=null;){if(s.carriage&&i(this,te,"f")==null){_(this,te,s.index,"f");continue}if(i(this,te,"f")!=null&&(s.index!==i(this,te,"f")+1||s.carriage)){r.push(Yn(i(this,ee,"f").subarray(0,i(this,te,"f")-1))),_(this,ee,i(this,ee,"f").subarray(i(this,te,"f")),"f"),_(this,te,null,"f");continue}let o=i(this,te,"f")!==null?s.preceding-1:s.preceding,a=Yn(i(this,ee,"f").subarray(0,o));r.push(a),_(this,ee,i(this,ee,"f").subarray(s.index),"f"),_(this,te,null,"f")}return r}flush(){return i(this,ee,"f").length?this.decode(`
|
|
2
|
+
`):[]}};ee=new WeakMap,te=new WeakMap;Se.NEWLINE_CHARS=new Set([`
|
|
3
|
+
`,"\r"]);Se.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function ia(n,e){for(let s=e??0;s<n.length;s++){if(n[s]===10)return{preceding:s,index:s+1,carriage:!1};if(n[s]===13)return{preceding:s,index:s+1,carriage:!0}}return null}function Co(n){for(let r=0;r<n.length-1;r++){if(n[r]===10&&n[r+1]===10||n[r]===13&&n[r+1]===13)return r+2;if(n[r]===13&&n[r+1]===10&&r+3<n.length&&n[r+2]===13&&n[r+3]===10)return r+4}return-1}var ar,G=class n{constructor(e,t,r){this.iterator=e,ar.set(this,void 0),this.controller=t,_(this,ar,r,"f")}static rawEvents(e,t=new AbortController){return No(e,t)}static fromSSEResponse(e,t,r){let s=!1,o=r?C(r):console;async function*a(){if(s)throw new y("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");s=!0;let l=!1;try{for await(let c of No(e,t)){if(c.event==="completion")try{yield JSON.parse(c.data)}catch(h){throw o.error("Could not parse message into JSON:",c.data),o.error("From chunk:",c.raw),h}if(c.event==="message_start"||c.event==="message_delta"||c.event==="message_stop"||c.event==="content_block_start"||c.event==="content_block_delta"||c.event==="content_block_stop"||c.event==="message"||c.event==="user.message"||c.event==="user.interrupt"||c.event==="user.tool_confirmation"||c.event==="user.custom_tool_result"||c.event==="user.tool_result"||c.event==="agent.message"||c.event==="agent.thinking"||c.event==="agent.tool_use"||c.event==="agent.tool_result"||c.event==="agent.mcp_tool_use"||c.event==="agent.mcp_tool_result"||c.event==="agent.custom_tool_use"||c.event==="agent.thread_context_compacted"||c.event==="session.status_running"||c.event==="session.status_idle"||c.event==="session.status_rescheduled"||c.event==="session.status_terminated"||c.event==="session.error"||c.event==="session.deleted"||c.event==="session.updated"||c.event==="span.model_request_start"||c.event==="span.model_request_end"||c.event==="span.outcome_evaluation_start"||c.event==="span.outcome_evaluation_ongoing"||c.event==="span.outcome_evaluation_end"||c.event==="user.define_outcome"||c.event==="agent.thread_message_received"||c.event==="agent.thread_message_sent"||c.event==="agent.session_thread_message_received"||c.event==="agent.session_thread_message_sent"||c.event==="session.thread_created"||c.event==="session.thread_status_created"||c.event==="session.thread_status_running"||c.event==="session.thread_status_idle"||c.event==="session.thread_status_rescheduled"||c.event==="session.thread_status_terminated"||c.event==="event_start"||c.event==="event_delta"||c.event==="system.message")try{yield JSON.parse(c.data)}catch(h){throw o.error("Could not parse message into JSON:",c.data),o.error("From chunk:",c.raw),h}if(c.event!=="ping"&&c.event==="error"){let h=Je(c.data)??c.data,g=h?.error?.type;throw new B(void 0,h,void 0,e.headers,g)}}l=!0}catch(c){if(Z(c))return;throw c}finally{l||t.abort(),me(t)}}return new n(a,t,r)}static fromReadableStream(e,t,r){let s=!1;async function*o(){let l=new Se,c=sr(e);for await(let h of c)for(let g of l.decode(h))yield g;for(let h of l.flush())yield h}async function*a(){if(s)throw new y("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");s=!0;let l=!1;try{for await(let c of o())l||c&&(yield JSON.parse(c));l=!0}catch(c){if(Z(c))return;throw c}finally{l||t.abort(),me(t)}}return new n(a,t,r)}[(ar=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let e=[],t=[],r=this.iterator(),s=o=>({next:()=>{if(o.length===0){let a=r.next();e.push(a),t.push(a)}return o.shift()}});return[new n(()=>s(e),this.controller,i(this,ar,"f")),new n(()=>s(t),this.controller,i(this,ar,"f"))]}toReadableStream(){let e=this,t;return qn({async start(){t=e[Symbol.asyncIterator]()},async pull(r){try{let{value:s,done:o}=await t.next();if(o)return r.close();let a=wt(JSON.stringify(s)+`
|
|
4
|
+
`);r.enqueue(a)}catch(s){r.error(s)}},async cancel(){await t.return?.()}})}};async function*No(n,e){if(!n.body)throw e.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new y("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api"):new y("Attempted to iterate over a response with no body");let t=new ns,r=new Se,s=sr(n.body);for await(let o of aa(s))for(let a of r.decode(o)){let l=t.decode(a);l&&(yield l)}for(let o of r.flush()){let a=t.decode(o);a&&(yield a)}}async function*aa(n){let e=new Uint8Array;for await(let t of n){if(t==null)continue;let r=t instanceof ArrayBuffer?new Uint8Array(t):typeof t=="string"?wt(t):t,s=new Uint8Array(e.length+r.length);s.set(e),s.set(r,e.length),e=s;let o;for(;(o=Co(e))!==-1;)yield e.slice(0,o),e=e.slice(o)}e.length>0&&(yield e)}var ns=class{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith("\r")&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;let o={event:this.event,data:this.data.join(`
|
|
5
|
+
`),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],o}if(this.chunks.push(e),e.startsWith(":"))return null;let[t,r,s]=ca(e,":");return s.startsWith(" ")&&(s=s.substring(1)),t==="event"?this.event=s:t==="data"&&this.data.push(s),null}};function ca(n,e){let t=n.indexOf(e);return t!==-1?[n.substring(0,t),e,n.substring(t+e.length)]:[n,"",""]}async function Qr(n,e){let{response:t,requestLogID:r,retryOfRequestLogID:s,startTime:o}=e,a=await(async()=>{if(e.options.stream)return C(n).debug("response",t.status,t.url,t.headers,t.body),G.fromSSEResponse(t,e.controller);if(t.status===204)return null;if(e.options.__binaryResponse)return t;let c=t.headers.get("content-type")?.split(";")[0]?.trim();if(c?.includes("application/json")||c?.endsWith("+json")){if(t.headers.get("content-length")==="0")return;let f=await t.json();return cr(f,t)}return await t.text()})().finally(()=>{!e.options.stream&&!e.options.__binaryResponse&&me(e.controller)});return C(n).debug(`[${r}] response parsed`,ge({retryOfRequestLogID:s,url:t.url,status:t.status,body:a,durationMs:Date.now()-o})),a}function cr(n,e){return!n||typeof n!="object"||Array.isArray(n)?n:Object.defineProperty(n,"_request_id",{value:e.headers.get("request-id"),enumerable:!1})}var Fo=new WeakSet;function ss(n){return typeof n=="object"&&n!==null&&Fo.has(n)}function Ho(n){let e=new Set;for(;typeof n=="object"&&n!==null&&!e.has(n);){if(e.add(n),ss(n)||Z(n)||n instanceof pe||n instanceof tr)return!0;n=n.cause}return!1}function os(n,e,t,r){return async(s,o={})=>{if(e.length===0)return n.call(void 0,s,o);let a=o.headers instanceof Headers?o.headers:new Headers(o.headers),l=await ua(n,e,t,r)({...o,headers:a,url:typeof s=="string"?s:s instanceof URL?s.href:s.url});if(l.bodyUsed||l.body?.locked)throw new y("middleware consumed the response body; use response.clone() to inspect it, or return new Response(body, response) to consume and replace it");return l}}function la(n,e){let t=new WeakMap;return{options:n,logger:e?C(e):Eo(),parse(r){if(n?.stream&&r.ok)return $o(r,n);let s=t.get(r);return s||(s=$o(r,n),t.set(r,s)),s}}}async function $o(n,e){if(n.bodyUsed||n.body?.locked)throw new y("cannot ctx.parse() a response whose body was already consumed; call ctx.parse() instead of reading the body, or read via response.clone()");if(e?.stream&&n.ok)return G.fromSSEResponse(n.clone(),new AbortController);if(n.status===204)return null;if(e?.__binaryResponse)return n;let r=n.headers.get("content-type")?.split(";")[0]?.trim();return r?.includes("application/json")||r?.endsWith("+json")?n.headers.get("content-length")==="0"?void 0:cr(await n.clone().json(),n):await n.clone().text()}function ua(n,e,t,r){let s=async({url:a,...l})=>{try{return await n.call(void 0,a,l)}catch(c){let h=We(c);throw Fo.add(h),h}},o=la(t,r);for(let a=e.length-1;a>=0;a--){let l=e[a],c=s;s=async h=>l(h,c,o)}return s}var lr,Ve=class n extends Promise{constructor(e,t,r=Qr){super(s=>{s(null)}),this.responsePromise=t,this.parseResponse=r,lr.set(this,void 0),_(this,lr,e,"f")}_thenUnwrap(e){return new n(i(this,lr,"f"),this.responsePromise,async(t,r)=>cr(e(await this.parseResponse(t,r),r),r.response))}asResponse(){return this.responsePromise.then(e=>e.response)}async withResponse(){let[e,t]=await Promise.all([this.parse(),this.asResponse()]);return{data:e,response:t,request_id:t.headers.get("request-id")}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(e=>this.parseResponse(i(this,lr,"f"),e))),this.parsedPromise}then(e,t){return this.parse().then(e,t)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}};lr=new WeakMap;var Zr,ur=class{constructor(e,t,r,s){Zr.set(this,void 0),_(this,Zr,e,"f"),this.options=s,this.response=t,this.body=r}hasNextPage(){return this.getPaginatedItems().length?this.nextPageRequestOptions()!=null:!1}async getNextPage(){let e=this.nextPageRequestOptions();if(!e)throw new y("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await i(this,Zr,"f").requestAPIList(this.constructor,e)}async*iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e}async*[(Zr=new WeakMap,Symbol.asyncIterator)](){for await(let e of this.iterPages())for(let t of e.getPaginatedItems())yield t}},dr=class extends Ve{constructor(e,t,r){super(e,t,async(s,o)=>new r(s,o.response,await Qr(s,o),o.options))}async*[Symbol.asyncIterator](){let e=await this;for await(let t of e)yield t}},ie=class extends ur{constructor(e,t,r,s){super(e,t,r,s),this.data=r.data||[],this.has_more=r.has_more||!1,this.first_id=r.first_id||null,this.last_id=r.last_id||null}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more===!1?!1:super.hasNextPage()}nextPageRequestOptions(){if(this.options.query?.before_id){let t=this.first_id;return t?{...this.options,query:{...rr(this.options.query),before_id:t}}:null}let e=this.last_id;return e?{...this.options,query:{...rr(this.options.query),after_id:e}}:null}};var R=class extends ur{constructor(e,t,r,s){super(e,t,r,s),this.data=r.data||[],this.next_page=r.next_page||null}getPaginatedItems(){return this.data??[]}nextPageRequestOptions(){let e=this.next_page;return e?{...this.options,query:{...rr(this.options.query),page:e}}:null}},en=class extends ur{constructor(e,t,r,s){super(e,t,r,s),this.data=r.data||[],this.next_page=r.next_page||null,this.prev_page=r.prev_page||null}getPaginatedItems(){return this.data??[]}nextPageRequestOptions(){let e=this.next_page;return e?{...this.options,query:{...rr(this.options.query),page:e}}:null}};var as=()=>{if(typeof File>"u"){let{process:n}=globalThis,e=typeof n?.versions?.node=="string"&&parseInt(n.versions.node.split("."))<20;throw new Error("`File` is not defined as a global, which is required for file uploads."+(e?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function ze(n,e,t){return as(),new File(n,e??"unknown_file",t)}function hr(n,e){let t=typeof n=="object"&&n!==null&&("name"in n&&n.name&&String(n.name)||"url"in n&&n.url&&String(n.url)||"filename"in n&&n.filename&&String(n.filename)||"path"in n&&n.path&&String(n.path))||"";return e?t.split(/[\\/]/).pop()||void 0:t}var cs=n=>n!=null&&typeof n=="object"&&typeof n[Symbol.asyncIterator]=="function";var St=async(n,e,t=!0)=>({...n,body:await fa(n.body,e,t)}),Lo=new WeakMap;function ha(n){let e=typeof n=="function"?n:n.fetch,t=Lo.get(e);if(t)return t;let r=(async()=>{try{let s="Response"in e?e.Response:(await e("data:,")).constructor,o=new FormData;return o.toString()!==await new s(o).text()}catch{return!0}})();return Lo.set(e,r),r}var fa=async(n,e,t=!0)=>{if(!await ha(e))throw new TypeError("The provided fetch function does not support file uploads with the current global FormData class.");let r=new FormData;return await Promise.all(Object.entries(n||{}).map(([s,o])=>is(r,s,o,t))),r},pa=n=>n instanceof Blob&&"name"in n;var is=async(n,e,t,r)=>{if(t!==void 0){if(t==null)throw new TypeError(`Received null for "${e}"; to pass null in FormData, you must use the string 'null'`);if(typeof t=="string"||typeof t=="number"||typeof t=="boolean")n.append(e,String(t));else if(t instanceof Response){let s={},o=t.headers.get("Content-Type");o&&(s={type:o}),n.append(e,ze([await t.blob()],hr(t,r),s))}else if(cs(t))n.append(e,ze([await new Response(Dr(t)).blob()],hr(t,r)));else if(pa(t))n.append(e,ze([t],hr(t,r),{type:t.type}));else if(Array.isArray(t))await Promise.all(t.map(s=>is(n,e+"[]",s,r)));else if(typeof t=="object")await Promise.all(Object.entries(t).map(([s,o])=>is(n,`${e}[${s}]`,o,r)));else throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${t} instead`)}};var Do=n=>n!=null&&typeof n=="object"&&typeof n.size=="number"&&typeof n.type=="string"&&typeof n.text=="function"&&typeof n.slice=="function"&&typeof n.arrayBuffer=="function",ma=n=>n!=null&&typeof n=="object"&&typeof n.name=="string"&&typeof n.lastModified=="number"&&Do(n),_a=n=>n!=null&&typeof n=="object"&&typeof n.url=="string"&&typeof n.blob=="function";async function tn(n,e,t){if(as(),n=await n,e||(e=hr(n,!0)),ma(n))return n instanceof File&&e==null&&t==null?n:ze([await n.arrayBuffer()],e??n.name,{type:n.type,lastModified:n.lastModified,...t});if(_a(n)){let s=await n.blob();return e||(e=new URL(n.url).pathname.split(/[\\/]/).pop()),ze(await ls(s),e,t)}let r=await ls(n);if(!t?.type){let s=r.find(o=>typeof o=="object"&&"type"in o&&o.type);typeof s=="string"&&(t={...t,type:s})}return ze(r,e,t)}async function ls(n){let e=[];if(typeof n=="string"||ArrayBuffer.isView(n)||n instanceof ArrayBuffer)e.push(n);else if(Do(n))e.push(n instanceof Blob?n:await n.arrayBuffer());else if(cs(n))for await(let t of n)e.push(...await ls(t));else{let t=n?.constructor?.name;throw new Error(`Unexpected data type: ${typeof n}${t?`; constructor: ${t}`:""}${ga(n)}`)}return e}function ga(n){return typeof n!="object"||n===null?"":`; props: [${Object.getOwnPropertyNames(n).map(t=>`"${t}"`).join(", ")}]`}var S=class{constructor(e){this._client=e}};var Bo=Symbol.for("brand.privateNullableHeaders");function*ya(n){if(!n)return;if(Bo in n){let{values:r,nulls:s}=n;yield*r.entries();for(let o of s)yield[o,null];return}let e=!1,t;n instanceof Headers?t=n.entries():Un(n)?t=n:(e=!0,t=Object.entries(n??{}));for(let r of t){let s=r[0];if(typeof s!="string")throw new TypeError("expected header name to be a string");let o=Un(r[1])?r[1]:[r[1]],a=!1;for(let l of o)l!==void 0&&(e&&!a&&(a=!0,yield[s,rn]),yield[s,l])}}var rn=Symbol("clear"),wa=new Set(["x-stainless-helper"]),us=(n,e)=>{let t=n?n.split(",").map(r=>r.trim()).filter(Boolean):[];for(let r of e.split(",").map(s=>s.trim()))r&&!t.includes(r)&&t.push(r);return t.join(", ")},u=n=>{let e=new Headers,t=new Set;for(let r of n){let s=new Set;for(let[o,a]of ya(r)){let l=o.toLowerCase();if(wa.has(l)){if(a===rn)continue;a===null?(e.delete(o),t.add(l)):(e.set(o,us(e.get(o),a)),t.delete(l));continue}(a===rn||!s.has(l))&&(e.delete(o),s.add(l),a===rn)||(a===null?(e.delete(o),t.add(l)):(e.append(o,a),t.delete(l)))}}return{[Bo]:!0,values:e,nulls:t}};function jo(n){return n.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}var Uo=Object.freeze(Object.create(null)),Sa=(n=jo)=>function(t,...r){if(t.length===1)return t[0];let s=!1,o=[],a=t.reduce((g,d,f)=>{/[?#]/.test(d)&&(s=!0);let p=r[f],b=(s?encodeURIComponent:n)(""+p);return f!==r.length&&(p==null||typeof p=="object"&&p.toString===Object.getPrototypeOf(Object.getPrototypeOf(p.hasOwnProperty??Uo)??Uo)?.toString)&&(b=p+"",o.push({start:g.length+d.length,length:b.length,error:`Value of type ${Object.prototype.toString.call(p).slice(8,-1)} is not a valid path parameter`})),g+d+(f===r.length?"":b)},""),l=a.split(/[?#]/,1)[0],c=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi,h;for(;(h=c.exec(l))!==null;)o.push({start:h.index,length:h[0].length,error:`Value "${h[0]}" can't be safely passed as a path parameter`});if(o.sort((g,d)=>g.start-d.start),o.length>0){let g=0,d=o.reduce((f,p)=>{let b=" ".repeat(p.start-g),v="^".repeat(p.length);return g=p.start+p.length,f+b+v},"");throw new y(`Path parameters result in path with invalid segments:
|
|
6
|
+
${o.map(f=>f.error).join(`
|
|
7
|
+
`)}
|
|
8
|
+
${a}
|
|
9
|
+
${d}`)}return a},m=Sa(jo);var xt=class extends S{retrieve(e,t={},r){let{betas:s}=t??{};return this._client.get(m`/v1/deployment_runs/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}list(e={},t){let{betas:r,...s}=e??{};return this._client.getAPIList("/v1/deployment_runs?beta=true",R,{query:s,...t,headers:u([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString()},t?.headers])})}};var kt=class extends S{create(e,t){let{betas:r,...s}=e;return this._client.post("/v1/deployments?beta=true",{body:s,...t,headers:u([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString()},t?.headers])})}retrieve(e,t={},r){let{betas:s}=t??{};return this._client.get(m`/v1/deployments/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}update(e,t,r){let{betas:s,...o}=t;return this._client.post(m`/v1/deployments/${e}?beta=true`,{body:o,...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}list(e={},t){let{betas:r,...s}=e??{};return this._client.getAPIList("/v1/deployments?beta=true",R,{query:s,...t,headers:u([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString()},t?.headers])})}archive(e,t={},r){let{betas:s}=t??{};return this._client.post(m`/v1/deployments/${e}/archive?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}pause(e,t={},r){let{betas:s}=t??{};return this._client.post(m`/v1/deployments/${e}/pause?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}run(e,t={},r){let{betas:s}=t??{};return this._client.post(m`/v1/deployments/${e}/run?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}unpause(e,t={},r){let{betas:s}=t??{};return this._client.post(m`/v1/deployments/${e}/unpause?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}};var Et=class extends S{create(e,t){let{betas:r,...s}=e;return this._client.post("/v1/dreams?beta=true",{body:s,...t,headers:u([{"anthropic-beta":[...r??[],"dreaming-2026-04-21"].toString()},t?.headers])})}retrieve(e,t={},r){let{betas:s}=t??{};return this._client.get(m`/v1/dreams/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"dreaming-2026-04-21"].toString()},r?.headers])})}list(e={},t){let{betas:r,...s}=e??{};return this._client.getAPIList("/v1/dreams?beta=true",R,{query:s,...t,headers:u([{"anthropic-beta":[...r??[],"dreaming-2026-04-21"].toString()},t?.headers])})}archive(e,t={},r){let{betas:s}=t??{};return this._client.post(m`/v1/dreams/${e}/archive?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"dreaming-2026-04-21"].toString()},r?.headers])})}cancel(e,t={},r){let{betas:s}=t??{};return this._client.post(m`/v1/dreams/${e}/cancel?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"dreaming-2026-04-21"].toString()},r?.headers])})}};var be="x-stainless-helper",sn="x-stainless-helper-method";function pr(n){return{[be]:n}}var fr=Symbol("anthropic.sdk.stainlessHelper");function nn(n){return typeof n=="object"&&n!==null&&fr in n}function ds(n,e){let t=new Set;if(n)for(let r of n)nn(r)&&t.add(r[fr]);if(e)for(let r of e){nn(r)&&t.add(r[fr]);let s=r.content;if(Array.isArray(s))for(let o of s)nn(o)&&t.add(o[fr])}return Array.from(t)}function on(n,e){let t=ds(n,e);return t.length===0?{}:{[be]:t.join(", ")}}function qo(n){return nn(n)?{[be]:n[fr]}:{}}var vt=class extends S{list(e={},t){let{betas:r,...s}=e??{};return this._client.getAPIList("/v1/files?beta=true",ie,{query:s,...t,headers:u([{"anthropic-beta":[...r??[],"files-api-2025-04-14"].toString()},t?.headers])})}delete(e,t={},r){let{betas:s}=t??{};return this._client.delete(m`/v1/files/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"files-api-2025-04-14"].toString()},r?.headers])})}download(e,t={},r){let{betas:s}=t??{};return this._client.get(m`/v1/files/${e}/content?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"files-api-2025-04-14"].toString(),Accept:"application/binary"},r?.headers]),__binaryResponse:!0})}retrieveMetadata(e,t={},r){let{betas:s}=t??{};return this._client.get(m`/v1/files/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"files-api-2025-04-14"].toString()},r?.headers])})}upload(e,t){let{betas:r,...s}=e;return this._client.post("/v1/files?beta=true",St({body:s,...t,headers:u([{"anthropic-beta":[...r??[],"files-api-2025-04-14"].toString()},qo(s.file),t?.headers])},this._client))}};var At=class extends S{retrieve(e,t={},r){let{betas:s}=t??{};return this._client.get(m`/v1/models/${e}?beta=true`,{...r,headers:u([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},r?.headers])})}list(e={},t){let{betas:r,...s}=e??{};return this._client.getAPIList("/v1/models?beta=true",ie,{query:s,...t,headers:u([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},t?.headers])})}};var Rt=class extends S{create(e,t){let{betas:r,...s}=e;return this._client.post("/v1/user_profiles?beta=true",{body:s,...t,headers:u([{"anthropic-beta":[...r??[],"user-profiles-2026-03-24"].toString()},t?.headers])})}retrieve(e,t={},r){let{betas:s}=t??{};return this._client.get(m`/v1/user_profiles/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"user-profiles-2026-03-24"].toString()},r?.headers])})}update(e,t,r){let{betas:s,...o}=t;return this._client.post(m`/v1/user_profiles/${e}?beta=true`,{body:o,...r,headers:u([{"anthropic-beta":[...s??[],"user-profiles-2026-03-24"].toString()},r?.headers])})}list(e={},t){let{betas:r,...s}=e??{};return this._client.getAPIList("/v1/user_profiles?beta=true",R,{query:s,...t,headers:u([{"anthropic-beta":[...r??[],"user-profiles-2026-03-24"].toString()},t?.headers])})}createEnrollmentURL(e,t={},r){let{betas:s}=t??{};return this._client.post(m`/v1/user_profiles/${e}/enrollment_url?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"user-profiles-2026-03-24"].toString()},r?.headers])})}};var ei=Bi(Zo(),1),Pt=class extends S{unwrap(e,{headers:t,key:r}){if(t!==void 0){let s=r===void 0?this._client.webhookKey:r;if(s===null)throw new Error("Webhook key must not be null in order to unwrap");new ei.Webhook(s).verify(e,t)}return JSON.parse(e)}};var Tt=class extends S{list(e,t={},r){let{betas:s,...o}=t??{};return this._client.getAPIList(m`/v1/agents/${e}/versions?beta=true`,R,{query:o,...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}};var Xe=class extends S{constructor(){super(...arguments),this.versions=new Tt(this._client)}create(e,t){let{betas:r,...s}=e;return this._client.post("/v1/agents?beta=true",{body:s,...t,headers:u([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString()},t?.headers])})}retrieve(e,t={},r){let{betas:s,...o}=t??{};return this._client.get(m`/v1/agents/${e}?beta=true`,{query:o,...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}update(e,t,r){let{betas:s,...o}=t;return this._client.post(m`/v1/agents/${e}?beta=true`,{body:o,...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}list(e={},t){let{betas:r,...s}=e??{};return this._client.getAPIList("/v1/agents?beta=true",R,{query:s,...t,headers:u([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString()},t?.headers])})}archive(e,t={},r){let{betas:s}=t??{};return this._client.post(m`/v1/agents/${e}/archive?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}};Xe.Versions=Tt;function Ge(n,e){if(!n)return()=>{};if(n.aborted)return e.abort(),()=>{};let t=()=>e.abort();return n.addEventListener("abort",t),()=>n.removeEventListener("abort",t)}function Te(n,e){return n instanceof B&&n.status===e}function ti(n){return n instanceof B&&typeof n.status=="number"&&n.status>=400&&n.status<500}function Oe(n){return ti(n)&&!Te(n,408)&&!Te(n,409)&&!Te(n,429)}function ri(n,e,t){return Math.min(e*2**n,t)}function ps(n,e){return n+Math.random()*(e-n)}function ni(n){return n*(1-Math.random()*.25)}function un(n,{authToken:e,helper:t}){if(!e)throw new y(`copyClientForHelper: expected a non-empty authToken but received ${JSON.stringify(e)}`);let r=n,s=r._options.defaultHeaders,o=r._authState?.extraHeaders,a=o?Object.fromEntries(Object.entries(o).filter(([c])=>{let h=c.toLowerCase();return h!=="authorization"&&h!=="x-api-key"})):void 0,l=u([a,s,{[be]:t}]);return n.withOptions({apiKey:null,authToken:e,baseURL:n.baseURL,credentials:void 0,defaultHeaders:l})}var Ot,dn,ae,hn,fn,pn,_r,gr,Mt,Da=999,Ba=1e3,Ua=6e4,Me=class{constructor(e){Ot.set(this,void 0),dn.set(this,!1),ae.set(this,void 0),hn.set(this,void 0),fn.set(this,void 0),pn.set(this,void 0),_r.set(this,void 0),gr.set(this,void 0),Mt.set(this,void 0),this.client=e.client,this.environmentId=e.environmentId,this.environmentKey=e.environmentKey,this.workerId=e.workerId??qa(),_(this,Ot,un(e.client,{authToken:e.environmentKey,helper:"environments-work-poller"}),"f"),_(this,fn,e.autoStop??!0,"f"),_(this,pn,e.drain??!1,"f"),_(this,_r,e.blockMs===void 0?Da:e.blockMs,"f"),_(this,gr,e.reclaimOlderThanMs??null,"f"),_(this,Mt,e.requestOptions,"f"),_(this,ae,new AbortController,"f"),_(this,hn,Ge(e.signal,i(this,ae,"f")),"f")}get signal(){return i(this,ae,"f").signal}abort(){i(this,ae,"f").abort()}async*[(Ot=new WeakMap,dn=new WeakMap,ae=new WeakMap,hn=new WeakMap,fn=new WeakMap,pn=new WeakMap,_r=new WeakMap,gr=new WeakMap,Mt=new WeakMap,Symbol.asyncIterator)](){if(i(this,dn,"f"))throw new y("Cannot iterate over a consumed WorkPoller");_(this,dn,!0,"f");let e=C(this.client);e.info("poller starting",{component:"work-poller",environment_id:this.environmentId});try{let t=0;for(;!i(this,ae,"f").signal.aborted;){let r;try{r=await i(this,Ot,"f").beta.environments.work.poll(this.environmentId,{"Anthropic-Worker-ID":this.workerId,...i(this,_r,"f")!==null?{block_ms:i(this,_r,"f")}:{},...i(this,gr,"f")!==null?{reclaim_older_than_ms:i(this,gr,"f")}:{}},{headers:u([i(this,Mt,"f")?.headers]),signal:i(this,ae,"f").signal})}catch(s){if(i(this,ae,"f").signal.aborted)return;if(Oe(s))throw e.error("poll failed permanently, stopping poller",{error:String(s)}),s;let o=ni(ja(t));e.warn("poll failed, backing off",{error:String(s),backoff_ms:o}),t++,await de(o,i(this,ae,"f").signal);continue}if(t=0,r==null){if(i(this,pn,"f"))return;await de(ps(1e3,3e3),i(this,ae,"f").signal);continue}e.info("claimed work",{component:"work-poller",environment_id:this.environmentId,work_id:r.id,work_type:r.data.type});try{await i(this,Ot,"f").beta.environments.work.ack(r.id,{environment_id:r.environment_id},{headers:u([i(this,Mt,"f")?.headers]),signal:i(this,ae,"f").signal})}catch(s){e.error("ack failed",{work_id:r.id,error:String(s)});continue}try{yield r}finally{if(i(this,fn,"f"))try{await i(this,Ot,"f").beta.environments.work.stop(r.id,{environment_id:r.environment_id},{headers:u([i(this,Mt,"f")?.headers])})}catch(s){Te(s,409)||e.warn("stop failed",{work_id:r.id,error:String(s)})}}}}finally{i(this,hn,"f").call(this)}}};function ja(n){return ri(n,Ba,Ua)}function qa(){let e=globalThis.process?.env?.HOSTNAME;return e?`${e}-${lt()}`:lt()}var Ct,Ce,Nt,mn=class{constructor(){Ct.set(this,[]),Ce.set(this,[]),Nt.set(this,!1)}push(e){if(i(this,Nt,"f"))return!1;let t=i(this,Ce,"f").shift();return t?t({done:!1,value:e}):i(this,Ct,"f").push(e),!0}close(){if(!i(this,Nt,"f"))for(_(this,Nt,!0,"f");i(this,Ce,"f").length>0;)i(this,Ce,"f").shift()({done:!0,value:void 0})}next(e){return i(this,Ct,"f").length>0?Promise.resolve({done:!1,value:i(this,Ct,"f").shift()}):i(this,Nt,"f")||e?.aborted?Promise.resolve({done:!0,value:void 0}):new Promise(t=>{let r=o=>{e?.removeEventListener("abort",s),t(o)},s=()=>{let o=i(this,Ce,"f").indexOf(r);o>=0&&i(this,Ce,"f").splice(o,1),t({done:!0,value:void 0})};i(this,Ce,"f").push(r),e?.addEventListener("abort",s,{once:!0})})}tryShift(){return i(this,Ct,"f").shift()}};Ct=new WeakMap,Ce=new WeakMap,Nt=new WeakMap;var xe=class extends Error{constructor(e){let t=typeof e=="string"?e:e.map(r=>r.type==="text"?r.text:`[${r.type}]`).join(" ");super(t),this.name="ToolError",this.content=e}};function ms(n){return"name"in n?n.name:n.mcp_server_name}function Wa(n){return n instanceof xe?n.content:`Error: ${n instanceof Error?n.message:String(n)}`}async function si(n,e,t){try{let r=n.parse?n.parse(e):e;return{content:await n.run(r,t),isError:!1}}catch(r){return{content:Wa(r),isError:!0}}}var br,Sn,$t,Ye,fe,L,_n,K,gn,yr,xn,q,Ht,ne,Lt,Ne,Ft,ke,wr,ce,bn,hi,oi,ii,ai,_s,ci,yn,wn,gs,li,fi;var ui=500,Ja=1e4,Ka=12e4,Va=3e4,di=3,za=6e4;function pi(n){return n.type==="session.status_idle"&&n.stop_reason?.type==="end_turn"}var bs=class{constructor(e,t){br.set(this,void 0),Sn.set(this,void 0),$t.set(this,new Set),Ye.set(this,!1),fe.set(this,void 0),_(this,br,e,"f"),_(this,Sn,t,"f")}noteEvent(e){e.type!=="user.tool_confirmation"&&(pi(e)?this.arm():this.disarm())}block(e){i(this,$t,"f").add(e),i(this,fe,"f")!==void 0&&(_(this,Ye,!0,"f"),clearTimeout(i(this,fe,"f")),_(this,fe,void 0,"f"))}unblock(e){i(this,$t,"f").delete(e),i(this,$t,"f").size===0&&i(this,Ye,"f")&&this.arm()}arm(){if(!(i(this,br,"f")<=0)){if(i(this,$t,"f").size>0){_(this,Ye,!0,"f");return}_(this,Ye,!1,"f"),i(this,fe,"f")!==void 0&&clearTimeout(i(this,fe,"f")),_(this,fe,setTimeout(i(this,Sn,"f"),i(this,br,"f")),"f")}}disarm(){_(this,Ye,!1,"f"),i(this,fe,"f")!==void 0&&(clearTimeout(i(this,fe,"f")),_(this,fe,void 0,"f"))}};br=new WeakMap,Sn=new WeakMap,$t=new WeakMap,Ye=new WeakMap,fe=new WeakMap;var $e=class{constructor(e,t){L.add(this),_n.set(this,!1),K.set(this,void 0),gn.set(this,void 0),yr.set(this,void 0),xn.set(this,void 0),q.set(this,void 0),Ht.set(this,new Set),ne.set(this,new Set),Lt.set(this,new Map),Ne.set(this,new Map),Ft.set(this,new mn),ke.set(this,0),wr.set(this,null),ce.set(this,void 0),this.client=t.client,this.sessionId=e,this.tools=t.tools,this.maxIdleMs=t.maxIdleMs??za,_(this,q,C(t.client),"f"),_(this,xn,new Map(t.tools.map(r=>[ms(r),r])),"f"),_(this,K,new AbortController,"f"),_(this,gn,Ge(t.signal,i(this,K,"f")),"f"),_(this,yr,t.requestOptions,"f"),_(this,ce,new bs(this.maxIdleMs,()=>{i(this,q,"f").info("session idle after end_turn; stopping",{component:"session-tool-runner",session_id:this.sessionId,max_idle_ms:this.maxIdleMs}),i(this,K,"f").abort()}),"f")}get signal(){return i(this,K,"f").signal}abort(){i(this,K,"f").abort()}async*[(_n=new WeakMap,K=new WeakMap,gn=new WeakMap,yr=new WeakMap,xn=new WeakMap,q=new WeakMap,Ht=new WeakMap,ne=new WeakMap,Lt=new WeakMap,Ne=new WeakMap,Ft=new WeakMap,ke=new WeakMap,wr=new WeakMap,ce=new WeakMap,L=new WeakSet,Symbol.asyncIterator)](){if(i(this,_n,"f"))throw new y("Cannot iterate over a consumed SessionToolRunner");_(this,_n,!0,"f"),i(this,q,"f").info("session tool runner starting",{component:"session-tool-runner",session_id:this.sessionId});let e=i(this,L,"m",hi).call(this).catch(t=>{i(this,K,"f").signal.aborted||i(this,q,"f").error("stream loop failed",{error:String(t)}),i(this,K,"f").abort()});try{for(;;){let r=await i(this,Ft,"f").next(i(this,K,"f").signal);if(r.done)break;yield r.value}await e;let t;for(;(t=i(this,Ft,"f").tryShift())!==void 0;)yield t}finally{i(this,K,"f").abort(),i(this,ce,"f").disarm(),await e;try{await i(this,L,"m",fi).call(this)}catch(t){i(this,q,"f").warn("drain failed",{error:String(t)})}i(this,Ft,"f").close();for(let t of this.tools)try{await t.close?.()}catch(r){i(this,q,"f").warn("tool.close failed",{tool:ms(t),error:String(r)})}i(this,gn,"f").call(this)}}};bn=function(){return{...i(this,yr,"f"),headers:u([pr("session-tool-runner"),i(this,yr,"f")?.headers]),signal:i(this,K,"f").signal}},hi=async function(){let e=i(this,K,"f"),t=ui;for(;!e.signal.aborted;){try{let r=await this.client.beta.sessions.events.stream(this.sessionId,{},i(this,L,"m",bn).call(this));await i(this,L,"m",oi).call(this);for await(let s of r)if(t=ui,await i(this,L,"m",ai).call(this,s))return}catch(r){if(e.signal.throwIfAborted(),Oe(r))throw i(this,q,"f").error("permanent stream failure, shutting down",{error:String(r)}),e.abort(),r;i(this,q,"f").warn("stream disconnected, reconnecting",{error:String(r),backoff_ms:t})}e.signal.throwIfAborted(),await de(t,e.signal),t=Math.min(t*2,Ja)}},oi=async function(){let e=i(this,K,"f"),t=[],r=!1;try{for await(let a of this.client.beta.sessions.events.list(this.sessionId,{limit:1e3},i(this,L,"m",bn).call(this)))i(this,L,"m",ii).call(this,a,t),r=pi(a)}catch(a){e.signal.throwIfAborted(),i(this,q,"f").warn("reconcile list failed",{error:String(a)});for(let l of t)i(this,Ht,"f").delete(l.id);return}let s=t.filter(a=>!i(this,ne,"f").has(a.id));i(this,ce,"f").disarm();for(let a of s)await i(this,L,"m",_s).call(this,a);for(let a of[...i(this,Ne,"f").values()]){let l=i(this,Lt,"f").get(a.id);l!==void 0&&await i(this,L,"m",yn).call(this,a,l)}let o=s.filter(a=>!i(this,ne,"f").has(a.id)&&!i(this,Ne,"f").has(a.id));r&&o.length===0?i(this,ce,"f").arm():i(this,ce,"f").disarm()},ii=function(e,t){e.type==="agent.tool_use"||e.type==="agent.custom_tool_use"?(i(this,Ht,"f").add(e.id),i(this,ne,"f").has(e.id)||t.push(e)):e.type==="user.tool_result"?i(this,ne,"f").add(e.tool_use_id):e.type==="user.custom_tool_result"?i(this,ne,"f").add(e.custom_tool_use_id):e.type==="user.tool_confirmation"&&(i(this,ne,"f").has(e.tool_use_id)||i(this,Lt,"f").set(e.tool_use_id,e.result))},ai=async function(e){switch(i(this,ce,"f").noteEvent(e),e.type){case"agent.tool_use":case"agent.custom_tool_use":return i(this,Ht,"f").has(e.id)||(i(this,Ht,"f").add(e.id),await i(this,L,"m",_s).call(this,e)),!1;case"user.tool_confirmation":return await i(this,L,"m",ci).call(this,e),!1;case"user.tool_result":return i(this,ne,"f").add(e.tool_use_id),!1;case"user.custom_tool_result":return i(this,ne,"f").add(e.custom_tool_use_id),!1;case"session.status_terminated":case"session.deleted":return i(this,q,"f").info("session terminated",{component:"session-tool-runner",session_id:this.sessionId}),i(this,K,"f").abort(),!0;default:return!1}},_s=async function(e){let t=e.evaluated_permission,r=t==="deny"?"deny":i(this,Lt,"f").get(e.id);if(r===void 0){t===void 0||t==="allow"?await i(this,L,"m",gs).call(this,e,void 0):i(this,Ne,"f").has(e.id)||(i(this,q,"f").info("tool call awaiting confirmation; holding",{component:"session-tool-runner",session_id:this.sessionId,tool:e.name,tool_use_id:e.id}),i(this,Ne,"f").set(e.id,e),i(this,ce,"f").block(e.id));return}await i(this,L,"m",yn).call(this,e,r)},ci=async function(e){i(this,Lt,"f").set(e.tool_use_id,e.result);let t=i(this,Ne,"f").get(e.tool_use_id);t!==void 0&&await i(this,L,"m",yn).call(this,t,e.result)},yn=async function(e,t){let r=i(this,Ne,"f").delete(e.id);if(t==="allow"){i(this,q,"f").info("tool call confirmed",{component:"session-tool-runner",session_id:this.sessionId,tool:e.name,tool_use_id:e.id}),r||i(this,ce,"f").block(e.id);try{await i(this,L,"m",gs).call(this,e,"allow")}finally{i(this,ce,"f").unblock(e.id)}return}r&&i(this,ce,"f").unblock(e.id),i(this,ne,"f").add(e.id),i(this,q,"f").info("tool call denied; not executing",{component:"session-tool-runner",session_id:this.sessionId,tool:e.name,tool_use_id:e.id}),i(this,L,"m",wn).call(this,{event:e,toolUseId:e.id,name:e.name,isError:!1,posted:!1,confirmation:"deny"})},wn=function(e){i(this,Ft,"f").push(e)},gs=async function(e,t){var r,s;if(!i(this,ne,"f").has(e.id)){i(this,q,"f").info("executing tool",{component:"session-tool-runner",session_id:this.sessionId,tool:e.name,tool_use_id:e.id}),_(this,ke,(r=i(this,ke,"f"),r++,r),"f");try{let o=i(this,xn,"f").get(e.name);if(!o){i(this,q,"f").info("tool not owned by this runner; leaving the tool_use_id pending for its owner",{component:"session-tool-runner",session_id:this.sessionId,tool:e.name,tool_use_id:e.id}),i(this,L,"m",wn).call(this,{event:e,toolUseId:e.id,name:e.name,isError:!1,posted:!1,confirmation:t});return}let a,l,c=new AbortController,h=Ge(i(this,K,"f").signal,c),g=setTimeout(()=>c.abort(),Ka);try{let p=await si(o,e.input,{toolUse:e,toolUseBlock:e,signal:c.signal});a=p.content,l=p.isError}finally{clearTimeout(g),h()}let d=Xa(e,l,Ga(a)),f=await i(this,L,"m",li).call(this,d,e.id);i(this,L,"m",wn).call(this,{event:e,result:d,toolUseId:e.id,name:e.name,isError:l,posted:f,confirmation:t})}finally{_(this,ke,(s=i(this,ke,"f"),s--,s),"f"),i(this,ke,"f")===0&&i(this,wr,"f")?.call(this)}}},li=async function(e,t){let r=i(this,K,"f"),s;for(let o=0;o<di;o++){r.signal.throwIfAborted();try{return await this.client.beta.sessions.events.send(this.sessionId,{events:[e]},i(this,L,"m",bn).call(this)),i(this,ne,"f").add(t),!0}catch(a){if(s=a,Oe(a))break;o<di-1&&await de((o+1)*1e3,r.signal)}}return i(this,q,"f").error("failed to send tool result",{tool_use_id:t,error:String(s)}),!1},fi=async function(){i(this,ke,"f")!==0&&(await Promise.race([new Promise(e=>_(this,wr,e,"f")),de(Va)]),_(this,wr,null,"f"),i(this,ke,"f")>0&&i(this,q,"f").warn("drain timeout exceeded"))};function Xa(n,e,t){return n.type==="agent.custom_tool_use"?{type:"user.custom_tool_result",custom_tool_use_id:n.id,is_error:e,content:t}:{type:"user.tool_result",tool_use_id:n.id,is_error:e,content:t}}function Ga(n){if(typeof n=="string")return[{type:"text",text:n||"(no output)"}];let e=n.map(t=>t.type==="text"?{type:"text",text:t.text||"(no output)"}:t.type==="image"||t.type==="document"?t:t.type==="search_result"?{type:"search_result",source:t.source,title:t.title,content:t.content.map(r=>({type:"text",text:r.text})),citations:{enabled:t.citations?.enabled??!1}}:{type:"text",text:JSON.stringify(t)});return e.length>0?e:[{type:"text",text:"(no output)"}]}var kn,Sr,ys,mi=3e4,Ya="NO_HEARTBEAT",Dt=class{constructor(e){kn.add(this),Sr.set(this,void 0),this.client=e.client,this.environmentId=e.environmentId,this.environmentKey=e.environmentKey,this.tools=e.tools,this.workdir=e.workdir??process.cwd(),this.unrestrictedPaths=e.unrestrictedPaths,this.maxFileBytes=e.maxFileBytes,this.maxIdleMs=e.maxIdleMs,this.workerId=e.workerId,this.requestOptions=e.requestOptions,_(this,Sr,e.signal,"f")}async run(e){let{environmentId:t,environmentKey:r}=this;if(t===void 0||r===void 0)throw new y("EnvironmentWorker.run: environmentId and environmentKey are required to poll for work");let s=e??i(this,Sr,"f"),o=new Me({client:this.client,environmentId:t,environmentKey:r,...this.workerId!==void 0?{workerId:this.workerId}:{},...s?{signal:s}:{},...this.requestOptions!==void 0?{requestOptions:this.requestOptions}:{},autoStop:!1});for await(let a of o)await i(this,kn,"m",ys).call(this,a,r,o.signal)}async handleItem(e){let t=e?.workId??T("ANTHROPIC_WORK_ID"),r=e?.environmentId??T("ANTHROPIC_ENVIRONMENT_ID"),s=e?.sessionId??T("ANTHROPIC_SESSION_ID"),o=e?.environmentKey??this.environmentKey??T("ANTHROPIC_ENVIRONMENT_KEY");if(!t)throw new y("handleItem: workId is required \u2014 pass it or set ANTHROPIC_WORK_ID");if(!r)throw new y("handleItem: environmentId is required \u2014 pass it or set ANTHROPIC_ENVIRONMENT_ID");if(!s)throw new y("handleItem: sessionId is required \u2014 pass it or set ANTHROPIC_SESSION_ID");if(!o)throw new y("handleItem: environmentKey is required \u2014 pass it, construct the worker with it, or set ANTHROPIC_ENVIRONMENT_KEY");let a={id:t,environment_id:r,data:{type:"session",id:s}};await i(this,kn,"m",ys).call(this,a,o,e?.signal??i(this,Sr,"f"))}};Sr=new WeakMap,kn=new WeakSet,ys=async function(e,t,r){let s=C(this.client),o=un(this.client,{authToken:t,helper:"environments-worker"}),a=e.data.id,l={workdir:this.workdir,client:this.client,sessionId:a,...this.unrestrictedPaths!==void 0?{unrestrictedPaths:this.unrestrictedPaths}:{},...this.maxFileBytes!==void 0?{maxFileBytes:this.maxFileBytes}:{}},c=await import("./node-AZK2C657.js"),h=async()=>{};try{h=await c.setupSkills(l)}catch(b){s.warn("skill setup failed",{session_id:a,work_id:e.id,error:String(b)})}let g=typeof this.tools=="function"?this.tools(l):this.tools??c.betaAgentToolset20260401(l),d=new AbortController,f=Ge(r,d),p=Za(o,e,d,s,this.requestOptions).catch(b=>{d.signal.aborted||s.error("heartbeat loop failed",{work_id:e.id,error:String(b)}),d.abort()});try{let b=new $e(a,{client:o,tools:g,...this.maxIdleMs!==void 0?{maxIdleMs:this.maxIdleMs}:{},...this.requestOptions!==void 0?{requestOptions:this.requestOptions}:{},signal:d.signal});for await(let v of b);}finally{d.abort(),f(),await p,await h().catch(b=>{s.warn("skill cleanup failed",{session_id:a,work_id:e.id,error:String(b)})}),await Qa(o,e,s,this.requestOptions)}};async function Qa(n,e,t,r){try{await n.beta.environments.work.stop(e.id,{environment_id:e.environment_id,force:!0},{...r,headers:u([r?.headers])})}catch(s){Te(s,409)||t.error("force-stop on exit failed",{work_id:e.id,error:String(s)})}}async function Za(n,e,t,r,s){let o=mi,a=Ya,l=async()=>{try{let c=await n.beta.environments.work.heartbeat(e.id,{environment_id:e.environment_id,expected_last_heartbeat:a},{...s,headers:u([s?.headers]),signal:t.signal});a=c.last_heartbeat,c.ttl_seconds>0&&(o=Math.max(1e3,Math.min(c.ttl_seconds*1e3/2,mi))),(c.state==="stopping"||c.state==="stopped")&&(r.info("heartbeat signals shutdown",{work_id:e.id,state:c.state}),t.abort()),c.lease_extended||(r.warn("lease not extended, shutting down",{work_id:e.id}),t.abort())}catch(c){if(t.signal.throwIfAborted(),Oe(c))throw r.error("permanent heartbeat failure",{work_id:e.id,error:String(c)}),t.abort(),c;r.warn("transient heartbeat failure",{work_id:e.id,error:String(c)})}};for(await l();!t.signal.aborted;)await de(o,t.signal),t.signal.throwIfAborted(),await l()}var Fe=class extends S{retrieve(e,t,r){let{environment_id:s,betas:o}=t;return this._client.get(m`/v1/environments/${s}/work/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...o??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}update(e,t,r){let{environment_id:s,betas:o,...a}=t;return this._client.post(m`/v1/environments/${s}/work/${e}?beta=true`,{body:a,...r,headers:u([{"anthropic-beta":[...o??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}list(e,t={},r){let{betas:s,...o}=t??{};return this._client.getAPIList(m`/v1/environments/${e}/work?beta=true`,R,{query:o,...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}ack(e,t,r){let{environment_id:s,betas:o}=t;return this._client.post(m`/v1/environments/${s}/work/${e}/ack?beta=true`,{...r,headers:u([{"anthropic-beta":[...o??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}heartbeat(e,t,r){let{environment_id:s,desired_ttl_seconds:o,expected_last_heartbeat:a,betas:l}=t;return this._client.post(m`/v1/environments/${s}/work/${e}/heartbeat?beta=true`,{query:{desired_ttl_seconds:o,expected_last_heartbeat:a},...r,headers:u([{"anthropic-beta":[...l??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}poll(e,t={},r){let{betas:s,"Anthropic-Worker-ID":o,...a}=t??{};return this._client.get(m`/v1/environments/${e}/work/poll?beta=true`,{query:a,...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...o!=null?{"Anthropic-Worker-ID":o}:void 0},r?.headers])})}stats(e,t={},r){let{betas:s}=t??{};return this._client.get(m`/v1/environments/${e}/work/stats?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}stop(e,t,r){let{environment_id:s,betas:o,...a}=t;return this._client.post(m`/v1/environments/${s}/work/${e}/stop?beta=true`,{body:a,...r,headers:u([{"anthropic-beta":[...o??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}poller(e){return new Me({...e,client:this._client})}worker(e){return new Dt({...e,client:this._client})}};Fe.WorkPoller=Me;Fe.EnvironmentWorker=Dt;var Qe=class extends S{constructor(){super(...arguments),this.work=new Fe(this._client)}create(e,t){let{betas:r,...s}=e;return this._client.post("/v1/environments?beta=true",{body:s,...t,headers:u([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString()},t?.headers])})}retrieve(e,t={},r){let{betas:s}=t??{};return this._client.get(m`/v1/environments/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}update(e,t,r){let{betas:s,...o}=t;return this._client.post(m`/v1/environments/${e}?beta=true`,{body:o,...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}list(e={},t){let{betas:r,...s}=e??{};return this._client.getAPIList("/v1/environments?beta=true",R,{query:s,...t,headers:u([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString()},t?.headers])})}delete(e,t={},r){let{betas:s}=t??{};return this._client.delete(m`/v1/environments/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}archive(e,t={},r){let{betas:s}=t??{};return this._client.post(m`/v1/environments/${e}/archive?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}};Qe.Work=Fe;var Bt=class extends S{create(e,t,r){let{view:s,betas:o,...a}=t;return this._client.post(m`/v1/memory_stores/${e}/memories?beta=true`,{query:{view:s},body:a,...r,headers:u([{"anthropic-beta":[...o??[],"agent-memory-2026-07-22"].toString()},r?.headers])})}retrieve(e,t,r){let{memory_store_id:s,betas:o,...a}=t;return this._client.get(m`/v1/memory_stores/${s}/memories/${e}?beta=true`,{query:a,...r,headers:u([{"anthropic-beta":[...o??[],"agent-memory-2026-07-22"].toString()},r?.headers])})}update(e,t,r){let{memory_store_id:s,view:o,betas:a,...l}=t;return this._client.post(m`/v1/memory_stores/${s}/memories/${e}?beta=true`,{query:{view:o},body:l,...r,headers:u([{"anthropic-beta":[...a??[],"agent-memory-2026-07-22"].toString()},r?.headers])})}list(e,t={},r){let{betas:s,...o}=t??{};return this._client.getAPIList(m`/v1/memory_stores/${e}/memories?beta=true`,R,{query:o,...r,headers:u([{"anthropic-beta":[...s??[],"agent-memory-2026-07-22"].toString()},r?.headers])})}delete(e,t,r){let{memory_store_id:s,expected_content_sha256:o,betas:a}=t;return this._client.delete(m`/v1/memory_stores/${s}/memories/${e}?beta=true`,{query:{expected_content_sha256:o},...r,headers:u([{"anthropic-beta":[...a??[],"agent-memory-2026-07-22"].toString()},r?.headers])})}};var Ut=class extends S{retrieve(e,t,r){let{memory_store_id:s,betas:o,...a}=t;return this._client.get(m`/v1/memory_stores/${s}/memory_versions/${e}?beta=true`,{query:a,...r,headers:u([{"anthropic-beta":[...o??[],"agent-memory-2026-07-22"].toString()},r?.headers])})}list(e,t={},r){let{betas:s,...o}=t??{};return this._client.getAPIList(m`/v1/memory_stores/${e}/memory_versions?beta=true`,R,{query:o,...r,headers:u([{"anthropic-beta":[...s??[],"agent-memory-2026-07-22"].toString()},r?.headers])})}redact(e,t,r){let{memory_store_id:s,betas:o}=t;return this._client.post(m`/v1/memory_stores/${s}/memory_versions/${e}/redact?beta=true`,{...r,headers:u([{"anthropic-beta":[...o??[],"agent-memory-2026-07-22"].toString()},r?.headers])})}};var He=class extends S{constructor(){super(...arguments),this.memories=new Bt(this._client),this.memoryVersions=new Ut(this._client)}create(e,t){let{betas:r,...s}=e;return this._client.post("/v1/memory_stores?beta=true",{body:s,...t,headers:u([{"anthropic-beta":[...r??[],"agent-memory-2026-07-22"].toString()},t?.headers])})}retrieve(e,t={},r){let{betas:s}=t??{};return this._client.get(m`/v1/memory_stores/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"agent-memory-2026-07-22"].toString()},r?.headers])})}update(e,t,r){let{betas:s,...o}=t;return this._client.post(m`/v1/memory_stores/${e}?beta=true`,{body:o,...r,headers:u([{"anthropic-beta":[...s??[],"agent-memory-2026-07-22"].toString()},r?.headers])})}list(e={},t){let{betas:r,...s}=e??{};return this._client.getAPIList("/v1/memory_stores?beta=true",R,{query:s,...t,headers:u([{"anthropic-beta":[...r??[],"agent-memory-2026-07-22"].toString()},t?.headers])})}delete(e,t={},r){let{betas:s}=t??{};return this._client.delete(m`/v1/memory_stores/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"agent-memory-2026-07-22"].toString()},r?.headers])})}archive(e,t={},r){let{betas:s}=t??{};return this._client.post(m`/v1/memory_stores/${e}/archive?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"agent-memory-2026-07-22"].toString()},r?.headers])})}};He.Memories=Bt;He.MemoryVersions=Ut;var jt=class n{constructor(e,t){this.iterator=e,this.controller=t}async*decoder(){let e=new Se;for await(let t of this.iterator)for(let r of e.decode(t))yield JSON.parse(r);for(let t of e.flush())yield JSON.parse(t)}[Symbol.asyncIterator](){return this.decoder()}static fromResponse(e,t){if(!e.body)throw t.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new y("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api"):new y("Attempted to iterate over a response with no body");return new n(sr(e.body),t)}};var qt=class extends S{create(e,t){let{betas:r,user_profile_id:s,...o}=e;return this._client.post("/v1/messages/batches?beta=true",{body:o,...t,headers:u([{"anthropic-beta":[...r??[],"message-batches-2024-09-24"].toString(),...s!=null?{"anthropic-user-profile-id":s}:void 0},t?.headers])})}retrieve(e,t={},r){let{betas:s}=t??{};return this._client.get(m`/v1/messages/batches/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"message-batches-2024-09-24"].toString()},r?.headers])})}list(e={},t){let{betas:r,...s}=e??{};return this._client.getAPIList("/v1/messages/batches?beta=true",ie,{query:s,...t,headers:u([{"anthropic-beta":[...r??[],"message-batches-2024-09-24"].toString()},t?.headers])})}delete(e,t={},r){let{betas:s}=t??{};return this._client.delete(m`/v1/messages/batches/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"message-batches-2024-09-24"].toString()},r?.headers])})}cancel(e,t={},r){let{betas:s}=t??{};return this._client.post(m`/v1/messages/batches/${e}/cancel?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"message-batches-2024-09-24"].toString()},r?.headers])})}async results(e,t={},r){let s=await this.retrieve(e);if(!s.results_url)throw new y(`No batch \`results_url\`; Has it finished processing? ${s.processing_status} - ${s.id}`);let{betas:o}=t??{};return this._client.get(s.results_url,{...r,headers:u([{"anthropic-beta":[...o??[],"message-batches-2024-09-24"].toString(),Accept:"application/binary"},r?.headers]),stream:!0,__binaryResponse:!0})._thenUnwrap((a,l)=>jt.fromResponse(l.response,l.controller))}};var En={"claude-opus-4-20250514":8192,"claude-opus-4-0":8192,"claude-4-opus-20250514":8192,"anthropic.claude-opus-4-20250514-v1:0":8192,"claude-opus-4@20250514":8192,"claude-opus-4-1-20250805":8192,"anthropic.claude-opus-4-1-20250805-v1:0":8192,"claude-opus-4-1@20250805":8192};function _i(n){return n?.output_format??n?.output_config?.format}function ws(n,e,t){let r=_i(e);return!e||!("parse"in(r??{}))?{...n,content:n.content.map(s=>{if(s.type==="text"){let o=Object.defineProperty({...s},"parsed_output",{value:null,enumerable:!1});return Object.defineProperty(o,"parsed",{get(){return t.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead."),null},enumerable:!1})}return s}),parsed_output:null}:Ss(n,e,t)}function Ss(n,e,t){let r=null,s=n.content.map(o=>{if(o.type==="text"){let a=ic(e,o.text);r===null&&(r=a);let l=Object.defineProperty({...o},"parsed_output",{value:a,enumerable:!1});return Object.defineProperty(l,"parsed",{get(){return t.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead."),a},enumerable:!1})}return o});return{...n,content:s,parsed_output:r}}function ic(n,e){let t=_i(n);if(t?.type!=="json_schema")return null;try{return"parse"in t?t.parse(e):JSON.parse(e)}catch(r){throw new y(`Failed to parse structured output: ${r}`)}}var ac=n=>{let e=0,t=[];for(;e<n.length;){let r=n[e];if(r==="\\"){e++;continue}if(r==="{"){t.push({type:"brace",value:"{"}),e++;continue}if(r==="}"){t.push({type:"brace",value:"}"}),e++;continue}if(r==="["){t.push({type:"paren",value:"["}),e++;continue}if(r==="]"){t.push({type:"paren",value:"]"}),e++;continue}if(r===":"){t.push({type:"separator",value:":"}),e++;continue}if(r===","){t.push({type:"delimiter",value:","}),e++;continue}if(r==='"'){let l="",c=!1;for(r=n[++e];r!=='"';){if(e===n.length){c=!0;break}if(r==="\\"){if(e++,e===n.length){c=!0;break}l+=r+n[e],r=n[++e]}else l+=r,r=n[++e]}r=n[++e],c||t.push({type:"string",value:l});continue}if(r&&/\s/.test(r)){e++;continue}let o=/[0-9]/;if(r&&o.test(r)||r==="-"||r==="."){let l="";for(r==="-"&&(l+=r,r=n[++e]);r&&(o.test(r)||r==="."||r==="e"||r==="E"||(r==="-"||r==="+")&&(l[l.length-1]==="e"||l[l.length-1]==="E"));)l+=r,r=n[++e];t.push({type:"number",value:l});continue}let a=/[a-z]/i;if(r&&a.test(r)){let l="";for(;r&&a.test(r)&&e!==n.length;)l+=r,r=n[++e];if(l=="true"||l=="false"||l==="null")t.push({type:"name",value:l});else{e++;continue}continue}e++}return t},Wt=n=>{if(n.length===0)return n;let e=n[n.length-1];switch(e.type){case"separator":return n=n.slice(0,n.length-1),Wt(n);break;case"number":let t=e.value[e.value.length-1];if(t==="."||t==="-"||t==="+"||t==="e"||t==="E")return n=n.slice(0,n.length-1),Wt(n);case"string":let r=n[n.length-2];if(r?.type==="delimiter")return n=n.slice(0,n.length-1),Wt(n);if(r?.type==="brace"&&r.value==="{")return n=n.slice(0,n.length-1),Wt(n);break;case"delimiter":return n=n.slice(0,n.length-1),Wt(n);break}return n},cc=n=>{let e=[];return n.map(t=>{t.type==="brace"&&(t.value==="{"?e.push("}"):e.splice(e.lastIndexOf("}"),1)),t.type==="paren"&&(t.value==="["?e.push("]"):e.splice(e.lastIndexOf("]"),1))}),e.length>0&&e.reverse().map(t=>{t==="}"?n.push({type:"brace",value:"}"}):t==="]"&&n.push({type:"paren",value:"]"})}),n},lc=n=>{let e="";return n.map(t=>{t.type==="string"?e+='"'+t.value+'"':e+=t.value}),e},gi=n=>JSON.parse(lc(cc(Wt(ac(n)))));var Le="__json_buf";function vn(n,e){let t={};for(let o of Object.keys(n))o!=="input"&&(t[o]=n[o]);Object.defineProperty(t,Le,{value:e,enumerable:!1,writable:!0});let r,s=!1;return Object.defineProperty(t,"input",{enumerable:!0,configurable:!0,get(){return s||(r=e?gi(e):{},s=!0),r}}),t}var Y,De,Jt,xr,An,kr,Er,Rn,vr,ye,Ar,In,Pn,Ze,Tn,On,Rr,xs,bi,Ir,ks,Es,vs,yi,As;function Rs(n){return n.type==="tool_use"||n.type==="server_tool_use"||n.type==="mcp_tool_use"}var Mn=class n{constructor(e,t){Y.add(this),this.messages=[],this.receivedMessages=[],De.set(this,void 0),Jt.set(this,null),this.controller=new AbortController,xr.set(this,void 0),An.set(this,()=>{}),kr.set(this,()=>{}),Er.set(this,void 0),Rn.set(this,()=>{}),vr.set(this,()=>{}),ye.set(this,{}),Ar.set(this,!1),In.set(this,!1),Pn.set(this,!1),Ze.set(this,!1),Tn.set(this,void 0),On.set(this,void 0),Rr.set(this,void 0),Ir.set(this,r=>{if(_(this,In,!0,"f"),Z(r)&&(r=new J),r instanceof J)return _(this,Pn,!0,"f"),this._emit("abort",r);if(r instanceof y)return this._emit("error",r);if(r instanceof Error){let s=new y(r.message);return s.cause=r,this._emit("error",s)}return this._emit("error",new y(String(r)))}),_(this,xr,new Promise((r,s)=>{_(this,An,r,"f"),_(this,kr,s,"f")}),"f"),_(this,Er,new Promise((r,s)=>{_(this,Rn,r,"f"),_(this,vr,s,"f")}),"f"),i(this,xr,"f").catch(()=>{}),i(this,Er,"f").catch(()=>{}),_(this,Jt,e,"f"),_(this,Rr,t?.logger??console,"f")}get response(){return i(this,Tn,"f")}get request_id(){return i(this,On,"f")}async withResponse(){_(this,Ze,!0,"f");let e=await i(this,xr,"f");if(!e)throw new Error("Could not resolve a `Response` object");return{data:this,response:e,request_id:e.headers.get("request-id")}}static fromReadableStream(e){let t=new n(null);return t._run(()=>t._fromReadableStream(e)),t}static createMessage(e,t,r,{logger:s}={}){let o=new n(t,{logger:s});for(let a of t.messages)o._addMessageParam(a);return _(o,Jt,{...t,stream:!0},"f"),o._run(()=>o._createMessage(e,{...t,stream:!0},{...r,headers:{...r?.headers,[sn]:"stream"}})),o}_run(e){e().then(()=>{this._emitFinal(),this._emit("end")},i(this,Ir,"f"))}_addMessageParam(e){this.messages.push(e)}_addMessage(e,t=!0){this.receivedMessages.push(e),t&&this._emit("message",e)}async _createMessage(e,t,r){let s=r?.signal,o;s&&(s.aborted&&this.controller.abort(),o=this.controller.abort.bind(this.controller),s.addEventListener("abort",o));try{i(this,Y,"m",ks).call(this);let{response:a,data:l}=await e.create({...t,stream:!0},{...r,signal:this.controller.signal}).withResponse();this._connected(a);for await(let c of l)i(this,Y,"m",Es).call(this,c);if(l.controller.signal?.aborted)throw new J;i(this,Y,"m",vs).call(this)}finally{s&&o&&s.removeEventListener("abort",o)}}_connected(e){this.ended||(_(this,Tn,e,"f"),_(this,On,e?.headers.get("request-id"),"f"),i(this,An,"f").call(this,e),this._emit("connect"))}get ended(){return i(this,Ar,"f")}get errored(){return i(this,In,"f")}get aborted(){return i(this,Pn,"f")}abort(){this.controller.abort()}on(e,t){return(i(this,ye,"f")[e]||(i(this,ye,"f")[e]=[])).push({listener:t}),this}off(e,t){let r=i(this,ye,"f")[e];if(!r)return this;let s=r.findIndex(o=>o.listener===t);return s>=0&&r.splice(s,1),this}once(e,t){return(i(this,ye,"f")[e]||(i(this,ye,"f")[e]=[])).push({listener:t,once:!0}),this}emitted(e){return new Promise((t,r)=>{_(this,Ze,!0,"f"),e!=="error"&&this.once("error",r),this.once(e,t)})}async done(){_(this,Ze,!0,"f"),await i(this,Er,"f")}get currentMessage(){return i(this,De,"f")}async finalMessage(){return await this.done(),i(this,Y,"m",xs).call(this)}async finalText(){return await this.done(),i(this,Y,"m",bi).call(this)}_emit(e,...t){if(i(this,Ar,"f"))return;e==="end"&&(_(this,Ar,!0,"f"),i(this,Rn,"f").call(this));let r=i(this,ye,"f")[e];if(r&&(i(this,ye,"f")[e]=r.filter(s=>!s.once),r.forEach(({listener:s})=>s(...t))),e==="abort"){let s=t[0];!i(this,Ze,"f")&&!r?.length&&Promise.reject(s),i(this,kr,"f").call(this,s),i(this,vr,"f").call(this,s),this._emit("end");return}if(e==="error"){let s=t[0];!i(this,Ze,"f")&&!r?.length&&Promise.reject(s),i(this,kr,"f").call(this,s),i(this,vr,"f").call(this,s),this._emit("end")}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit("finalMessage",i(this,Y,"m",xs).call(this))}async _fromReadableStream(e,t){let r=t?.signal,s;r&&(r.aborted&&this.controller.abort(),s=this.controller.abort.bind(this.controller),r.addEventListener("abort",s));try{i(this,Y,"m",ks).call(this),this._connected(null);let o=G.fromReadableStream(e,this.controller);for await(let a of o)i(this,Y,"m",Es).call(this,a);if(o.controller.signal?.aborted)throw new J;i(this,Y,"m",vs).call(this)}finally{r&&s&&r.removeEventListener("abort",s)}}[(De=new WeakMap,Jt=new WeakMap,xr=new WeakMap,An=new WeakMap,kr=new WeakMap,Er=new WeakMap,Rn=new WeakMap,vr=new WeakMap,ye=new WeakMap,Ar=new WeakMap,In=new WeakMap,Pn=new WeakMap,Ze=new WeakMap,Tn=new WeakMap,On=new WeakMap,Rr=new WeakMap,Ir=new WeakMap,Y=new WeakSet,xs=function(){if(this.receivedMessages.length===0)throw new y("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},bi=function(){if(this.receivedMessages.length===0)throw new y("stream ended without producing a Message with role=assistant");let t=this.receivedMessages.at(-1).content.filter(r=>r.type==="text").map(r=>r.text);if(t.length===0)throw new y("stream ended without producing a content block with type=text");return t.join(" ")},ks=function(){this.ended||_(this,De,void 0,"f")},Es=function(t){if(this.ended)return;let r=i(this,Y,"m",yi).call(this,t);switch(this._emit("streamEvent",t,r),t.type){case"content_block_delta":{let s=r.content.at(-1);switch(t.delta.type){case"text_delta":{s.type==="text"&&this._emit("text",t.delta.text,s.text||"");break}case"citations_delta":{s.type==="text"&&this._emit("citation",t.delta.citation,s.citations??[]);break}case"input_json_delta":{if(Rs(s)&&i(this,ye,"f").inputJson?.length){let o;try{o=s.input}catch(a){i(this,Ir,"f").call(this,i(this,Y,"m",As).call(this,s,a));break}this._emit("inputJson",t.delta.partial_json,o)}break}case"thinking_delta":{s.type==="thinking"&&this._emit("thinking",t.delta.thinking,s.thinking);break}case"signature_delta":{s.type==="thinking"&&this._emit("signature",s.signature);break}case"compaction_delta":{s.type==="compaction"&&s.content&&this._emit("compaction",s.content);break}default:t.delta}break}case"message_stop":{this._addMessageParam(r),this._addMessage(ws(r,i(this,Jt,"f"),{logger:i(this,Rr,"f")}),!0);break}case"content_block_stop":{this._emit("contentBlock",r.content.at(-1));break}case"message_start":{_(this,De,r,"f");break}case"content_block_start":case"message_delta":break}},vs=function(){if(this.ended)throw new y("stream has ended, this shouldn't happen");let t=i(this,De,"f");if(!t)throw new y("request ended without sending any chunks");return _(this,De,void 0,"f"),ws(t,i(this,Jt,"f"),{logger:i(this,Rr,"f")})},yi=function(t){let r=i(this,De,"f");if(t.type==="message_start"){if(r)throw new y(`Unexpected event order, got ${t.type} before receiving "message_stop"`);return t.message}if(!r)throw new y(`Unexpected event order, got ${t.type} before "message_start"`);switch(t.type){case"message_stop":return r;case"message_delta":return r.container=t.delta.container,r.stop_reason=t.delta.stop_reason,r.stop_sequence=t.delta.stop_sequence,t.delta.stop_details!=null&&(r.stop_details=t.delta.stop_details),r.usage.output_tokens=t.usage.output_tokens,r.context_management=t.context_management,t.usage.input_tokens!=null&&(r.usage.input_tokens=t.usage.input_tokens),t.usage.cache_creation_input_tokens!=null&&(r.usage.cache_creation_input_tokens=t.usage.cache_creation_input_tokens),t.usage.cache_read_input_tokens!=null&&(r.usage.cache_read_input_tokens=t.usage.cache_read_input_tokens),t.usage.server_tool_use!=null&&(r.usage.server_tool_use=t.usage.server_tool_use),t.usage.iterations!=null&&(r.usage.iterations=t.usage.iterations),t.usage.fallback_credit!=null&&(r.usage.fallback_credit=t.usage.fallback_credit),r;case"content_block_start":return r.content.push(t.content_block),t.content_block.type==="fallback"&&(r.model=t.content_block.to.model),r;case"content_block_delta":{let s=r.content.at(t.index);switch(t.delta.type){case"text_delta":{s?.type==="text"&&(r.content[t.index]={...s,text:(s.text||"")+t.delta.text});break}case"citations_delta":{s?.type==="text"&&(r.content[t.index]={...s,citations:[...s.citations??[],t.delta.citation]});break}case"input_json_delta":{if(s&&Rs(s)){let o=(s[Le]||"")+t.delta.partial_json;r.content[t.index]=vn(s,o)}break}case"thinking_delta":{s?.type==="thinking"&&(r.content[t.index]={...s,thinking:s.thinking+t.delta.thinking});break}case"signature_delta":{s?.type==="thinking"&&(r.content[t.index]={...s,signature:t.delta.signature});break}case"compaction_delta":{s?.type==="compaction"&&(r.content[t.index]={...s,content:(s.content||"")+t.delta.content,encrypted_content:t.delta.encrypted_content});break}default:t.delta}return r}case"content_block_stop":{let s=r.content.at(t.index);if(s&&Rs(s)&&Le in s){let o;try{o=s.input}catch(a){o={},i(this,Ir,"f").call(this,i(this,Y,"m",As).call(this,s,a))}Object.defineProperty(s,"input",{value:o,enumerable:!0,configurable:!0,writable:!0})}return r}}},As=function(t,r){let s=t[Le];return new y(`Unable to parse tool parameter JSON from model. Please retry your request or adjust your prompt. Error: ${r}. JSON: ${s}`)},Symbol.asyncIterator)](){let e=[],t=[],r=!1;return this.on("streamEvent",s=>{let o=t.shift();o?o.resolve(s):e.push(s)}),this.on("end",()=>{r=!0;for(let s of t)s.resolve(void 0);t.length=0}),this.on("abort",s=>{r=!0;for(let o of t)o.reject(s);t.length=0}),this.on("error",s=>{r=!0;for(let o of t)o.reject(s);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:r?{value:void 0,done:!0}:new Promise((o,a)=>t.push({resolve:o,reject:a})).then(o=>o?{value:o,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new G(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}};function Is(){let n,e;return{promise:new Promise((r,s)=>{n=r,e=s}),resolve:n,reject:e}}var wi=`You have been working on the task described above but have not yet completed it. Write a continuation summary that will allow you (or another instance of yourself) to resume work efficiently in a future context window where the conversation history will be replaced with this summary. Your summary should be structured, concise, and actionable. Include:
|
|
10
|
+
1. Task Overview
|
|
11
|
+
The user's core request and success criteria
|
|
12
|
+
Any clarifications or constraints they specified
|
|
13
|
+
2. Current State
|
|
14
|
+
What has been completed so far
|
|
15
|
+
Files created, modified, or analyzed (with paths if relevant)
|
|
16
|
+
Key outputs or artifacts produced
|
|
17
|
+
3. Important Discoveries
|
|
18
|
+
Technical constraints or requirements uncovered
|
|
19
|
+
Decisions made and their rationale
|
|
20
|
+
Errors encountered and how they were resolved
|
|
21
|
+
What approaches were tried that didn't work (and why)
|
|
22
|
+
4. Next Steps
|
|
23
|
+
Specific actions needed to complete the task
|
|
24
|
+
Any blockers or open questions to resolve
|
|
25
|
+
Priority order if multiple steps remain
|
|
26
|
+
5. Context to Preserve
|
|
27
|
+
User preferences or style requirements
|
|
28
|
+
Domain-specific details that aren't obvious
|
|
29
|
+
Any promises made to the user
|
|
30
|
+
Be concise but complete\u2014err on the side of including information that would prevent duplicate work or repeated mistakes. Write in a way that enables immediate resumption of the task.
|
|
31
|
+
Wrap your summary in <summary></summary> tags.`;var Pr,Kt,et,W,Q,se,Ee,Be,Tr,Si,Ps,Vt=class{constructor(e,t,r){Pr.add(this),this.client=e,Kt.set(this,!1),et.set(this,!1),W.set(this,void 0),Q.set(this,void 0),se.set(this,void 0),Ee.set(this,void 0),Be.set(this,void 0),Tr.set(this,0),_(this,W,{params:{...t,messages:structuredClone(t.messages)}},"f");let s=ds(t.tools,t.messages);_(this,Q,{...r,headers:u([pr("BetaToolRunner"),s.length?{[be]:s.join(", ")}:void 0,r?.headers])},"f"),_(this,Be,Is(),"f"),t.compactionControl?.enabled&&console.warn('Anthropic: The `compactionControl` parameter is deprecated and will be removed in a future version. Use server-side compaction instead by passing `edits: [{ type: "compact_20260112" }]` in the params passed to `toolRunner()`. See https://platform.claude.com/docs/en/build-with-claude/compaction')}async*[(Kt=new WeakMap,et=new WeakMap,W=new WeakMap,Q=new WeakMap,se=new WeakMap,Ee=new WeakMap,Be=new WeakMap,Tr=new WeakMap,Pr=new WeakSet,Si=async function(){let t=i(this,W,"f").params.compactionControl;if(!t||!t.enabled)return!1;let r=0;if(i(this,se,"f")!==void 0)try{let h=await i(this,se,"f");r=h.usage.input_tokens+(h.usage.cache_creation_input_tokens??0)+(h.usage.cache_read_input_tokens??0)+h.usage.output_tokens}catch{return!1}let s=t.contextTokenThreshold??1e5;if(r<s)return!1;let o=t.model??i(this,W,"f").params.model,a=t.summaryPrompt??wi,l=i(this,W,"f").params.messages;if(l[l.length-1].role==="assistant"){let h=l[l.length-1];if(Array.isArray(h.content)){let g=h.content.filter(d=>d.type!=="tool_use");g.length===0?l.pop():h.content=g}}let c=await this.client.beta.messages.create({model:o,messages:[...l,{role:"user",content:[{type:"text",text:a}]}],max_tokens:i(this,W,"f").params.max_tokens},{signal:i(this,Q,"f").signal,headers:u([i(this,Q,"f").headers,pr("compaction")])});if(c.content[0]?.type!=="text")throw new y("Expected text response for compaction");return i(this,W,"f").params.messages=[{role:"user",content:c.content}],!0},Symbol.asyncIterator)](){var e;if(i(this,Kt,"f"))throw new y("Cannot iterate over a consumed stream");_(this,Kt,!0,"f"),_(this,et,!0,"f"),_(this,Ee,void 0,"f");try{for(;;){let t;try{if(i(this,W,"f").params.max_iterations&&i(this,Tr,"f")>=i(this,W,"f").params.max_iterations)break;_(this,et,!1,"f"),_(this,Ee,void 0,"f"),_(this,Tr,(e=i(this,Tr,"f"),e++,e),"f"),_(this,se,void 0,"f");let{max_iterations:r,compactionControl:s,...o}=i(this,W,"f").params;if(o.stream?(t=this.client.beta.messages.stream({...o},i(this,Q,"f")),_(this,se,t.finalMessage(),"f"),i(this,se,"f").catch(()=>{}),yield t):(_(this,se,this.client.beta.messages.create({...o,stream:!1},i(this,Q,"f")),"f"),yield i(this,se,"f")),!await i(this,Pr,"m",Si).call(this)){if(!i(this,et,"f")){let c=await i(this,se,"f");if(i(this,W,"f").params.messages.push({role:c.role,content:c.content}),c.stop_reason==="refusal")break}let l=await i(this,Pr,"m",Ps).call(this,i(this,W,"f").params.messages.at(-1));if(l)i(this,W,"f").params.messages.push(l);else if(!i(this,et,"f"))break}}finally{t&&t.abort()}}if(!i(this,se,"f"))throw new y("ToolRunner concluded without a message from the server");i(this,Be,"f").resolve(await i(this,se,"f"))}catch(t){throw _(this,Kt,!1,"f"),i(this,Be,"f").promise.catch(()=>{}),i(this,Be,"f").reject(t),_(this,Be,Is(),"f"),t}}setMessagesParams(e){typeof e=="function"?i(this,W,"f").params=e(i(this,W,"f").params):i(this,W,"f").params=e,_(this,et,!0,"f"),_(this,Ee,void 0,"f")}setRequestOptions(e){typeof e=="function"?_(this,Q,e(i(this,Q,"f")),"f"):_(this,Q,{...i(this,Q,"f"),...e},"f")}async generateToolResponse(e=i(this,Q,"f").signal){let t=await i(this,se,"f")??this.params.messages.at(-1);return t?i(this,Pr,"m",Ps).call(this,t,e):null}done(){return i(this,Be,"f").promise}async runUntilDone(){if(!i(this,Kt,"f"))for await(let e of this);return this.done()}get params(){return i(this,W,"f").params}pushMessages(...e){this.setMessagesParams(t=>({...t,messages:[...t.messages,...e]}))}then(e,t){return this.runUntilDone().then(e,t)}};Ps=async function(e,t=i(this,Q,"f").signal){return i(this,Ee,"f")!==void 0?i(this,Ee,"f"):(_(this,Ee,dc(i(this,W,"f").params,e,{...i(this,Q,"f"),signal:t}),"f"),i(this,Ee,"f"))};async function dc(n,e=n.messages.at(-1),t){if(!e||e.role!=="assistant"||!e.content||typeof e.content=="string")return null;let r=e.content.filter(a=>a.type==="tool_use");if(r.length===0)return null;let s=fc(n);return{role:"user",content:await Promise.all(r.map(async a=>{let l=n.tools.find(c=>("name"in c?c.name:c.mcp_server_name)===a.name);if(!l||!("run"in l)||!s.has(a.name))return hc(a);try{let c=a.input;"parse"in l&&l.parse&&(c=l.parse(c));let h=await l.run(c,{toolUse:a,toolUseBlock:a,signal:t?.signal});return{type:"tool_result",tool_use_id:a.id,content:h}}catch(c){return{type:"tool_result",tool_use_id:a.id,content:c instanceof xe?c.content:`Error: ${c instanceof Error?c.message:String(c)}`,is_error:!0}}}))}}function hc(n){return{type:"tool_result",tool_use_id:n.id,content:`Error: Tool '${n.name}' not found`,is_error:!0}}function fc(n){let e=new Set;for(let t of n.tools)"run"in t&&e.add(t.name);for(let t of n.messages)if(!(t.role!=="system"||typeof t.content=="string"))for(let r of t.content)pc(r,e);return e}function pc(n,e){switch(n.type){case"tool_removal":case"tool_addition":xi(n,e);break;case"mid_conv_system":for(let t of n.content)(t.type==="tool_removal"||t.type==="tool_addition")&&xi(t,e);break;default:break}}function xi(n,e){let t=mc(n.tool);t!==void 0&&(n.type==="tool_removal"?e.delete(t):e.add(t))}function mc(n){if(n.type==="tool_reference")return n.name}var ki={"claude-1.3":"November 6th, 2024","claude-1.3-100k":"November 6th, 2024","claude-instant-1.1":"November 6th, 2024","claude-instant-1.1-100k":"November 6th, 2024","claude-instant-1.2":"November 6th, 2024","claude-3-sonnet-20240229":"July 21st, 2025","claude-3-opus-20240229":"January 5th, 2026","claude-2.1":"July 21st, 2025","claude-2.0":"July 21st, 2025","claude-3-7-sonnet-latest":"February 19th, 2026","claude-3-7-sonnet-20250219":"February 19th, 2026","claude-3-5-haiku-latest":"February 19th, 2026","claude-3-5-haiku-20241022":"February 19th, 2026","claude-opus-4-0":"June 15th, 2026","claude-opus-4-20250514":"June 15th, 2026","claude-sonnet-4-0":"June 15th, 2026","claude-sonnet-4-20250514":"June 15th, 2026","claude-opus-4-1":"August 5th, 2026","claude-opus-4-1-20250805":"August 5th, 2026","claude-mythos-preview":"June 30th, 2026"},_c=["claude-mythos-preview","claude-opus-4-6"],ve=class extends S{constructor(){super(...arguments),this.batches=new qt(this._client)}create(e,t){let r=Ei(e),{betas:s,user_profile_id:o,...a}=r;a.model in ki&&console.warn(`The model '${a.model}' is deprecated and will reach end-of-life on ${ki[a.model]}
|
|
32
|
+
Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`),_c.includes(a.model)&&a.thinking&&a.thinking.type==="enabled"&&console.warn(`Using Claude with ${a.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`);let l=this._client._options.timeout;if(!a.stream&&l==null){let h=En[a.model]??void 0;l=this._client.calculateNonstreamingTimeout(a.max_tokens,h)}let c=on(a.tools,a.messages);return this._client.post("/v1/messages?beta=true",{body:a,timeout:l??6e5,...t,headers:u([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0,...o!=null?{"anthropic-user-profile-id":o}:void 0},c,t?.headers]),stream:r.stream??!1})}parse(e,t){return t={...t,headers:u([{"anthropic-beta":[...e.betas??[],"structured-outputs-2025-12-15"].toString()},t?.headers])},this.create(e,t).then(r=>Ss(r,e,{logger:this._client.logger??console}))}stream(e,t){return Mn.createMessage(this,e,t)}countTokens(e,t){let r=Ei(e),{betas:s,user_profile_id:o,...a}=r;return this._client.post("/v1/messages/count_tokens?beta=true",{body:a,...t,headers:u([{"anthropic-beta":[...s??[],"token-counting-2024-11-01"].toString(),...o!=null?{"anthropic-user-profile-id":o}:void 0},t?.headers])})}toolRunner(e,t){return new Vt(this._client,e,t)}};function Ei(n){if(!n.output_format)return n;if(n.output_config?.format)throw new y("Both output_format and output_config.format were provided. Please use only output_config.format (output_format is deprecated).");let{output_format:e,...t}=n;return{...t,output_config:{...n.output_config,format:e}}}ve.Batches=qt;ve.BetaToolRunner=Vt;ve.ToolError=xe;var tt=class extends S{list(e,t={},r){let{betas:s,...o}=t??{};return this._client.getAPIList(m`/v1/sessions/${e}/events?beta=true`,R,{query:o,...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}send(e,t,r){let{betas:s,...o}=t;return this._client.post(m`/v1/sessions/${e}/events?beta=true`,{body:o,...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}stream(e,t={},r){let{betas:s,...o}=t??{};return this._client.get(m`/v1/sessions/${e}/events/stream?beta=true`,{query:o,...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers]),stream:!0})}toolRunner(e,t){return new $e(e,{...t,client:this._client})}};tt.SessionToolRunner=$e;var zt=class extends S{retrieve(e,t,r){let{session_id:s,betas:o}=t;return this._client.get(m`/v1/sessions/${s}/resources/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...o??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}update(e,t,r){let{session_id:s,betas:o,...a}=t;return this._client.post(m`/v1/sessions/${s}/resources/${e}?beta=true`,{body:a,...r,headers:u([{"anthropic-beta":[...o??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}list(e,t={},r){let{betas:s,...o}=t??{};return this._client.getAPIList(m`/v1/sessions/${e}/resources?beta=true`,R,{query:o,...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}delete(e,t,r){let{session_id:s,betas:o}=t;return this._client.delete(m`/v1/sessions/${s}/resources/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...o??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}add(e,t,r){let{betas:s,...o}=t;return this._client.post(m`/v1/sessions/${e}/resources?beta=true`,{body:o,...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}};var Xt=class extends S{list(e,t,r){let{session_id:s,betas:o,...a}=t;return this._client.getAPIList(m`/v1/sessions/${s}/threads/${e}/events?beta=true`,R,{query:a,...r,headers:u([{"anthropic-beta":[...o??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}stream(e,t,r){let{session_id:s,betas:o,...a}=t;return this._client.get(m`/v1/sessions/${s}/threads/${e}/stream?beta=true`,{query:a,...r,headers:u([{"anthropic-beta":[...o??[],"managed-agents-2026-04-01"].toString()},r?.headers]),stream:!0})}};var rt=class extends S{constructor(){super(...arguments),this.events=new Xt(this._client)}retrieve(e,t,r){let{session_id:s,betas:o}=t;return this._client.get(m`/v1/sessions/${s}/threads/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...o??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}list(e,t={},r){let{betas:s,...o}=t??{};return this._client.getAPIList(m`/v1/sessions/${e}/threads?beta=true`,R,{query:o,...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}archive(e,t,r){let{session_id:s,betas:o}=t;return this._client.post(m`/v1/sessions/${s}/threads/${e}/archive?beta=true`,{...r,headers:u([{"anthropic-beta":[...o??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}};rt.Events=Xt;var Ae=class extends S{constructor(){super(...arguments),this.events=new tt(this._client),this.resources=new zt(this._client),this.threads=new rt(this._client)}create(e,t){let{betas:r,...s}=e;return this._client.post("/v1/sessions?beta=true",{body:s,...t,headers:u([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString()},t?.headers])})}retrieve(e,t={},r){let{betas:s}=t??{};return this._client.get(m`/v1/sessions/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}update(e,t,r){let{betas:s,...o}=t;return this._client.post(m`/v1/sessions/${e}?beta=true`,{body:o,...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}list(e={},t){let{betas:r,...s}=e??{};return this._client.getAPIList("/v1/sessions?beta=true",en,{query:s,...t,headers:u([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString()},t?.headers])})}delete(e,t={},r){let{betas:s}=t??{};return this._client.delete(m`/v1/sessions/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}archive(e,t={},r){let{betas:s}=t??{};return this._client.post(m`/v1/sessions/${e}/archive?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}};Ae.Events=tt;Ae.Resources=zt;Ae.Threads=rt;var Gt=class extends S{create(e,t,r){let{betas:s,...o}=t;return this._client.post(m`/v1/skills/${e}/versions?beta=true`,St({body:o,...r,headers:u([{"anthropic-beta":[...s??[],"skills-2025-10-02"].toString()},r?.headers])},this._client,!1))}retrieve(e,t,r){let{skill_id:s,betas:o}=t;return this._client.get(m`/v1/skills/${s}/versions/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...o??[],"skills-2025-10-02"].toString()},r?.headers])})}list(e,t={},r){let{betas:s,...o}=t??{};return this._client.getAPIList(m`/v1/skills/${e}/versions?beta=true`,R,{query:o,...r,headers:u([{"anthropic-beta":[...s??[],"skills-2025-10-02"].toString()},r?.headers])})}delete(e,t,r){let{skill_id:s,betas:o}=t;return this._client.delete(m`/v1/skills/${s}/versions/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...o??[],"skills-2025-10-02"].toString()},r?.headers])})}download(e,t,r){let{skill_id:s,betas:o}=t;return this._client.get(m`/v1/skills/${s}/versions/${e}/content?beta=true`,{...r,headers:u([{"anthropic-beta":[...o??[],"skills-2025-10-02"].toString(),Accept:"application/binary"},r?.headers]),__binaryResponse:!0})}};var nt=class extends S{constructor(){super(...arguments),this.versions=new Gt(this._client)}create(e,t){let{betas:r,...s}=e;return this._client.post("/v1/skills?beta=true",St({body:s,...t,headers:u([{"anthropic-beta":[...r??[],"skills-2025-10-02"].toString()},t?.headers])},this._client,!1))}retrieve(e,t={},r){let{betas:s}=t??{};return this._client.get(m`/v1/skills/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"skills-2025-10-02"].toString()},r?.headers])})}list(e={},t){let{betas:r,...s}=e??{};return this._client.getAPIList("/v1/skills?beta=true",R,{query:s,...t,headers:u([{"anthropic-beta":[...r??[],"skills-2025-10-02"].toString()},t?.headers])})}delete(e,t={},r){let{betas:s}=t??{};return this._client.delete(m`/v1/skills/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"skills-2025-10-02"].toString()},r?.headers])})}};nt.Versions=Gt;var Yt=class extends S{create(e,t,r){let{betas:s,...o}=t;return this._client.post(m`/v1/tunnels/${e}/certificates?beta=true`,{body:o,...r,headers:u([{"anthropic-beta":[...s??[],"mcp-tunnels-2026-06-22"].toString()},r?.headers])})}retrieve(e,t,r){let{tunnel_id:s,betas:o}=t;return this._client.get(m`/v1/tunnels/${s}/certificates/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...o??[],"mcp-tunnels-2026-06-22"].toString()},r?.headers])})}list(e,t={},r){let{betas:s,...o}=t??{};return this._client.getAPIList(m`/v1/tunnels/${e}/certificates?beta=true`,R,{query:o,...r,headers:u([{"anthropic-beta":[...s??[],"mcp-tunnels-2026-06-22"].toString()},r?.headers])})}archive(e,t,r){let{tunnel_id:s,betas:o}=t;return this._client.post(m`/v1/tunnels/${s}/certificates/${e}/archive?beta=true`,{...r,headers:u([{"anthropic-beta":[...o??[],"mcp-tunnels-2026-06-22"].toString()},r?.headers])})}};var st=class extends S{constructor(){super(...arguments),this.certificates=new Yt(this._client)}create(e,t){let{betas:r,...s}=e;return this._client.post("/v1/tunnels?beta=true",{body:s,...t,headers:u([{"anthropic-beta":[...r??[],"mcp-tunnels-2026-06-22"].toString()},t?.headers])})}retrieve(e,t={},r){let{betas:s}=t??{};return this._client.get(m`/v1/tunnels/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"mcp-tunnels-2026-06-22"].toString()},r?.headers])})}list(e={},t){let{betas:r,...s}=e??{};return this._client.getAPIList("/v1/tunnels?beta=true",R,{query:s,...t,headers:u([{"anthropic-beta":[...r??[],"mcp-tunnels-2026-06-22"].toString()},t?.headers])})}archive(e,t={},r){let{betas:s}=t??{};return this._client.post(m`/v1/tunnels/${e}/archive?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"mcp-tunnels-2026-06-22"].toString()},r?.headers])})}revealToken(e,t={},r){let{betas:s}=t??{};return this._client.post(m`/v1/tunnels/${e}/reveal_token?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"mcp-tunnels-2026-06-22"].toString()},r?.headers])})}rotateToken(e,t,r){let{betas:s,...o}=t;return this._client.post(m`/v1/tunnels/${e}/rotate_token?beta=true`,{body:o,...r,headers:u([{"anthropic-beta":[...s??[],"mcp-tunnels-2026-06-22"].toString()},r?.headers])})}};st.Certificates=Yt;var Qt=class extends S{create(e,t,r){let{betas:s,...o}=t;return this._client.post(m`/v1/vaults/${e}/credentials?beta=true`,{body:o,...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}retrieve(e,t,r){let{vault_id:s,betas:o}=t;return this._client.get(m`/v1/vaults/${s}/credentials/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...o??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}update(e,t,r){let{vault_id:s,betas:o,...a}=t;return this._client.post(m`/v1/vaults/${s}/credentials/${e}?beta=true`,{body:a,...r,headers:u([{"anthropic-beta":[...o??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}list(e,t={},r){let{betas:s,...o}=t??{};return this._client.getAPIList(m`/v1/vaults/${e}/credentials?beta=true`,R,{query:o,...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}delete(e,t,r){let{vault_id:s,betas:o}=t;return this._client.delete(m`/v1/vaults/${s}/credentials/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...o??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}archive(e,t,r){let{vault_id:s,betas:o}=t;return this._client.post(m`/v1/vaults/${s}/credentials/${e}/archive?beta=true`,{...r,headers:u([{"anthropic-beta":[...o??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}mcpOAuthValidate(e,t,r){let{vault_id:s,betas:o}=t;return this._client.post(m`/v1/vaults/${s}/credentials/${e}/mcp_oauth_validate?beta=true`,{...r,headers:u([{"anthropic-beta":[...o??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}};var ot=class extends S{constructor(){super(...arguments),this.credentials=new Qt(this._client)}create(e,t){let{betas:r,...s}=e;return this._client.post("/v1/vaults?beta=true",{body:s,...t,headers:u([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString()},t?.headers])})}retrieve(e,t={},r){let{betas:s}=t??{};return this._client.get(m`/v1/vaults/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}update(e,t,r){let{betas:s,...o}=t;return this._client.post(m`/v1/vaults/${e}?beta=true`,{body:o,...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}list(e={},t){let{betas:r,...s}=e??{};return this._client.getAPIList("/v1/vaults?beta=true",R,{query:s,...t,headers:u([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString()},t?.headers])})}delete(e,t={},r){let{betas:s}=t??{};return this._client.delete(m`/v1/vaults/${e}?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}archive(e,t={},r){let{betas:s}=t??{};return this._client.post(m`/v1/vaults/${e}/archive?beta=true`,{...r,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},r?.headers])})}};ot.Credentials=Qt;var D=class extends S{constructor(){super(...arguments),this.models=new At(this._client),this.messages=new ve(this._client),this.agents=new Xe(this._client),this.environments=new Qe(this._client),this.sessions=new Ae(this._client),this.deployments=new kt(this._client),this.deploymentRuns=new xt(this._client),this.vaults=new ot(this._client),this.memoryStores=new He(this._client),this.files=new vt(this._client),this.skills=new nt(this._client),this.webhooks=new Pt(this._client),this.userProfiles=new Rt(this._client),this.dreams=new Et(this._client),this.tunnels=new st(this._client)}};D.Models=At;D.Messages=ve;D.Agents=Xe;D.Environments=Qe;D.Sessions=Ae;D.Deployments=kt;D.DeploymentRuns=xt;D.Vaults=ot;D.MemoryStores=He;D.Files=vt;D.Skills=nt;D.Webhooks=Pt;D.UserProfiles=Rt;D.Dreams=Et;D.Tunnels=st;var it=class extends S{create(e,t){let{betas:r,...s}=e;return this._client.post("/v1/complete",{body:s,timeout:this._client._options.timeout??6e5,...t,headers:u([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},t?.headers]),stream:e.stream??!1})}};function vi(n){return n?.output_config?.format}function Ts(n,e,t){let r=vi(e);return!e||!("parse"in(r??{}))?{...n,content:n.content.map(s=>s.type==="text"?Object.defineProperty({...s},"parsed_output",{value:null,enumerable:!1}):s),parsed_output:null}:Os(n,e,t)}function Os(n,e,t){let r=null,s=n.content.map(o=>{if(o.type==="text"){let a=Pc(e,o.text);return r===null&&(r=a),Object.defineProperty({...o},"parsed_output",{value:a,enumerable:!1})}return o});return{...n,content:s,parsed_output:r}}function Pc(n,e){let t=vi(n);if(t?.type!=="json_schema")return null;try{return"parse"in t?t.parse(e):JSON.parse(e)}catch(r){throw new y(`Failed to parse structured output: ${r}`)}}var le,Ue,Zt,Or,Cn,Mr,Cr,Nn,Nr,we,$r,$n,Fn,at,Hn,Ln,Fr,Ms,Ai,Cs,Ns,$s,Fs,Ri;function Hs(n){return n.type==="tool_use"||n.type==="server_tool_use"}var Dn=class n{constructor(e,t){le.add(this),this.messages=[],this.receivedMessages=[],Ue.set(this,void 0),Zt.set(this,null),this.controller=new AbortController,Or.set(this,void 0),Cn.set(this,()=>{}),Mr.set(this,()=>{}),Cr.set(this,void 0),Nn.set(this,()=>{}),Nr.set(this,()=>{}),we.set(this,{}),$r.set(this,!1),$n.set(this,!1),Fn.set(this,!1),at.set(this,!1),Hn.set(this,void 0),Ln.set(this,void 0),Fr.set(this,void 0),Cs.set(this,r=>{if(_(this,$n,!0,"f"),Z(r)&&(r=new J),r instanceof J)return _(this,Fn,!0,"f"),this._emit("abort",r);if(r instanceof y)return this._emit("error",r);if(r instanceof Error){let s=new y(r.message);return s.cause=r,this._emit("error",s)}return this._emit("error",new y(String(r)))}),_(this,Or,new Promise((r,s)=>{_(this,Cn,r,"f"),_(this,Mr,s,"f")}),"f"),_(this,Cr,new Promise((r,s)=>{_(this,Nn,r,"f"),_(this,Nr,s,"f")}),"f"),i(this,Or,"f").catch(()=>{}),i(this,Cr,"f").catch(()=>{}),_(this,Zt,e,"f"),_(this,Fr,t?.logger??console,"f")}get response(){return i(this,Hn,"f")}get request_id(){return i(this,Ln,"f")}async withResponse(){_(this,at,!0,"f");let e=await i(this,Or,"f");if(!e)throw new Error("Could not resolve a `Response` object");return{data:this,response:e,request_id:e.headers.get("request-id")}}static fromReadableStream(e){let t=new n(null);return t._run(()=>t._fromReadableStream(e)),t}static createMessage(e,t,r,{logger:s}={}){let o=new n(t,{logger:s});for(let a of t.messages)o._addMessageParam(a);return _(o,Zt,{...t,stream:!0},"f"),o._run(()=>o._createMessage(e,{...t,stream:!0},{...r,headers:{...r?.headers,[sn]:"stream"}})),o}_run(e){e().then(()=>{this._emitFinal(),this._emit("end")},i(this,Cs,"f"))}_addMessageParam(e){this.messages.push(e)}_addMessage(e,t=!0){this.receivedMessages.push(e),t&&this._emit("message",e)}async _createMessage(e,t,r){let s=r?.signal,o;s&&(s.aborted&&this.controller.abort(),o=this.controller.abort.bind(this.controller),s.addEventListener("abort",o));try{i(this,le,"m",Ns).call(this);let{response:a,data:l}=await e.create({...t,stream:!0},{...r,signal:this.controller.signal}).withResponse();this._connected(a);for await(let c of l)i(this,le,"m",$s).call(this,c);if(l.controller.signal?.aborted)throw new J;i(this,le,"m",Fs).call(this)}finally{s&&o&&s.removeEventListener("abort",o)}}_connected(e){this.ended||(_(this,Hn,e,"f"),_(this,Ln,e?.headers.get("request-id"),"f"),i(this,Cn,"f").call(this,e),this._emit("connect"))}get ended(){return i(this,$r,"f")}get errored(){return i(this,$n,"f")}get aborted(){return i(this,Fn,"f")}abort(){this.controller.abort()}on(e,t){return(i(this,we,"f")[e]||(i(this,we,"f")[e]=[])).push({listener:t}),this}off(e,t){let r=i(this,we,"f")[e];if(!r)return this;let s=r.findIndex(o=>o.listener===t);return s>=0&&r.splice(s,1),this}once(e,t){return(i(this,we,"f")[e]||(i(this,we,"f")[e]=[])).push({listener:t,once:!0}),this}emitted(e){return new Promise((t,r)=>{_(this,at,!0,"f"),e!=="error"&&this.once("error",r),this.once(e,t)})}async done(){_(this,at,!0,"f"),await i(this,Cr,"f")}get currentMessage(){return i(this,Ue,"f")}async finalMessage(){return await this.done(),i(this,le,"m",Ms).call(this)}async finalText(){return await this.done(),i(this,le,"m",Ai).call(this)}_emit(e,...t){if(i(this,$r,"f"))return;e==="end"&&(_(this,$r,!0,"f"),i(this,Nn,"f").call(this));let r=i(this,we,"f")[e];if(r&&(i(this,we,"f")[e]=r.filter(s=>!s.once),r.forEach(({listener:s})=>s(...t))),e==="abort"){let s=t[0];!i(this,at,"f")&&!r?.length&&Promise.reject(s),i(this,Mr,"f").call(this,s),i(this,Nr,"f").call(this,s),this._emit("end");return}if(e==="error"){let s=t[0];!i(this,at,"f")&&!r?.length&&Promise.reject(s),i(this,Mr,"f").call(this,s),i(this,Nr,"f").call(this,s),this._emit("end")}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit("finalMessage",i(this,le,"m",Ms).call(this))}async _fromReadableStream(e,t){let r=t?.signal,s;r&&(r.aborted&&this.controller.abort(),s=this.controller.abort.bind(this.controller),r.addEventListener("abort",s));try{i(this,le,"m",Ns).call(this),this._connected(null);let o=G.fromReadableStream(e,this.controller);for await(let a of o)i(this,le,"m",$s).call(this,a);if(o.controller.signal?.aborted)throw new J;i(this,le,"m",Fs).call(this)}finally{r&&s&&r.removeEventListener("abort",s)}}[(Ue=new WeakMap,Zt=new WeakMap,Or=new WeakMap,Cn=new WeakMap,Mr=new WeakMap,Cr=new WeakMap,Nn=new WeakMap,Nr=new WeakMap,we=new WeakMap,$r=new WeakMap,$n=new WeakMap,Fn=new WeakMap,at=new WeakMap,Hn=new WeakMap,Ln=new WeakMap,Fr=new WeakMap,Cs=new WeakMap,le=new WeakSet,Ms=function(){if(this.receivedMessages.length===0)throw new y("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},Ai=function(){if(this.receivedMessages.length===0)throw new y("stream ended without producing a Message with role=assistant");let t=this.receivedMessages.at(-1).content.filter(r=>r.type==="text").map(r=>r.text);if(t.length===0)throw new y("stream ended without producing a content block with type=text");return t.join(" ")},Ns=function(){this.ended||_(this,Ue,void 0,"f")},$s=function(t){if(this.ended)return;let r=i(this,le,"m",Ri).call(this,t);switch(this._emit("streamEvent",t,r),t.type){case"content_block_delta":{let s=r.content.at(-1);switch(t.delta.type){case"text_delta":{s.type==="text"&&this._emit("text",t.delta.text,s.text||"");break}case"citations_delta":{s.type==="text"&&this._emit("citation",t.delta.citation,s.citations??[]);break}case"input_json_delta":{Hs(s)&&i(this,we,"f").inputJson?.length&&this._emit("inputJson",t.delta.partial_json,s.input);break}case"thinking_delta":{s.type==="thinking"&&this._emit("thinking",t.delta.thinking,s.thinking);break}case"signature_delta":{s.type==="thinking"&&this._emit("signature",s.signature);break}default:t.delta}break}case"message_stop":{this._addMessageParam(r),this._addMessage(Ts(r,i(this,Zt,"f"),{logger:i(this,Fr,"f")}),!0);break}case"content_block_stop":{this._emit("contentBlock",r.content.at(-1));break}case"message_start":{_(this,Ue,r,"f");break}case"content_block_start":case"message_delta":break}},Fs=function(){if(this.ended)throw new y("stream has ended, this shouldn't happen");let t=i(this,Ue,"f");if(!t)throw new y("request ended without sending any chunks");return _(this,Ue,void 0,"f"),Ts(t,i(this,Zt,"f"),{logger:i(this,Fr,"f")})},Ri=function(t){let r=i(this,Ue,"f");if(t.type==="message_start"){if(r)throw new y(`Unexpected event order, got ${t.type} before receiving "message_stop"`);return t.message}if(!r)throw new y(`Unexpected event order, got ${t.type} before "message_start"`);switch(t.type){case"message_stop":return r;case"message_delta":return r.stop_reason=t.delta.stop_reason,r.stop_sequence=t.delta.stop_sequence,t.delta.stop_details!=null&&(r.stop_details=t.delta.stop_details),r.usage.output_tokens=t.usage.output_tokens,t.usage.input_tokens!=null&&(r.usage.input_tokens=t.usage.input_tokens),t.usage.cache_creation_input_tokens!=null&&(r.usage.cache_creation_input_tokens=t.usage.cache_creation_input_tokens),t.usage.cache_read_input_tokens!=null&&(r.usage.cache_read_input_tokens=t.usage.cache_read_input_tokens),t.usage.server_tool_use!=null&&(r.usage.server_tool_use=t.usage.server_tool_use),r;case"content_block_start":return r.content.push({...t.content_block}),r;case"content_block_delta":{let s=r.content.at(t.index);switch(t.delta.type){case"text_delta":{s?.type==="text"&&(r.content[t.index]={...s,text:(s.text||"")+t.delta.text});break}case"citations_delta":{s?.type==="text"&&(r.content[t.index]={...s,citations:[...s.citations??[],t.delta.citation]});break}case"input_json_delta":{if(s&&Hs(s)){let o=(s[Le]||"")+t.delta.partial_json;r.content[t.index]=vn(s,o)}break}case"thinking_delta":{s?.type==="thinking"&&(r.content[t.index]={...s,thinking:s.thinking+t.delta.thinking});break}case"signature_delta":{s?.type==="thinking"&&(r.content[t.index]={...s,signature:t.delta.signature});break}default:t.delta}return r}case"content_block_stop":{let s=r.content.at(t.index);return s&&Hs(s)&&Le in s&&Object.defineProperty(s,"input",{value:s.input,enumerable:!0,configurable:!0,writable:!0}),r}}},Symbol.asyncIterator)](){let e=[],t=[],r=!1;return this.on("streamEvent",s=>{let o=t.shift();o?o.resolve(s):e.push(s)}),this.on("end",()=>{r=!0;for(let s of t)s.resolve(void 0);t.length=0}),this.on("abort",s=>{r=!0;for(let o of t)o.reject(s);t.length=0}),this.on("error",s=>{r=!0;for(let o of t)o.reject(s);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:r?{value:void 0,done:!0}:new Promise((o,a)=>t.push({resolve:o,reject:a})).then(o=>o?{value:o,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new G(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}};var er=class extends S{create(e,t){let{user_profile_id:r,...s}=e;return this._client.post("/v1/messages/batches",{body:s,...t,headers:u([{...r!=null?{"anthropic-user-profile-id":r}:void 0},t?.headers])})}retrieve(e,t){return this._client.get(m`/v1/messages/batches/${e}`,t)}list(e={},t){return this._client.getAPIList("/v1/messages/batches",ie,{query:e,...t})}delete(e,t){return this._client.delete(m`/v1/messages/batches/${e}`,t)}cancel(e,t){return this._client.post(m`/v1/messages/batches/${e}/cancel`,t)}async results(e,t){let r=await this.retrieve(e);if(!r.results_url)throw new y(`No batch \`results_url\`; Has it finished processing? ${r.processing_status} - ${r.id}`);return this._client.get(r.results_url,{...t,headers:u([{Accept:"application/binary"},t?.headers]),stream:!0,__binaryResponse:!0})._thenUnwrap((s,o)=>jt.fromResponse(o.response,o.controller))}};var je=class extends S{constructor(){super(...arguments),this.batches=new er(this._client)}create(e,t){let{user_profile_id:r,...s}=e;s.model in Ii&&console.warn(`The model '${s.model}' is deprecated and will reach end-of-life on ${Ii[s.model]}
|
|
33
|
+
Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`),Oc.includes(s.model)&&s.thinking&&s.thinking.type==="enabled"&&console.warn(`Using Claude with ${s.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`);let o=this._client._options.timeout;if(!s.stream&&o==null){let l=En[s.model]??void 0;o=this._client.calculateNonstreamingTimeout(s.max_tokens,l)}let a=on(s.tools,s.messages);return this._client.post("/v1/messages",{body:s,timeout:o??6e5,...t,headers:u([{...r!=null?{"anthropic-user-profile-id":r}:void 0},a,t?.headers]),stream:e.stream??!1})}parse(e,t){return this.create(e,t).then(r=>Os(r,e,{logger:this._client.logger??console}))}stream(e,t){return Dn.createMessage(this,e,t,{logger:this._client.logger??console})}countTokens(e,t){let{user_profile_id:r,...s}=e;return this._client.post("/v1/messages/count_tokens",{body:s,...t,headers:u([{...r!=null?{"anthropic-user-profile-id":r}:void 0},t?.headers])})}},Ii={"claude-1.3":"November 6th, 2024","claude-1.3-100k":"November 6th, 2024","claude-instant-1.1":"November 6th, 2024","claude-instant-1.1-100k":"November 6th, 2024","claude-instant-1.2":"November 6th, 2024","claude-3-sonnet-20240229":"July 21st, 2025","claude-3-opus-20240229":"January 5th, 2026","claude-2.1":"July 21st, 2025","claude-2.0":"July 21st, 2025","claude-3-7-sonnet-latest":"February 19th, 2026","claude-3-7-sonnet-20250219":"February 19th, 2026","claude-3-5-haiku-latest":"February 19th, 2026","claude-3-5-haiku-20241022":"February 19th, 2026","claude-opus-4-0":"June 15th, 2026","claude-opus-4-20250514":"June 15th, 2026","claude-sonnet-4-0":"June 15th, 2026","claude-sonnet-4-20250514":"June 15th, 2026","claude-opus-4-1":"August 5th, 2026","claude-opus-4-1-20250805":"August 5th, 2026","claude-mythos-preview":"June 30th, 2026"},Oc=["claude-mythos-preview","claude-opus-4-6"];je.Batches=er;var ct=class extends S{retrieve(e,t={},r){let{betas:s}=t??{};return this._client.get(m`/v1/models/${e}`,{...r,headers:u([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},r?.headers])})}list(e={},t){let{betas:r,...s}=e??{};return this._client.getAPIList("/v1/models",ie,{query:s,...t,headers:u([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},t?.headers])})}};var Ls,Ds,Bn,Pi,Ti="\\n\\nHuman:",Oi="\\n\\nAssistant:",H=class{get credentials(){return this._authState.provider}constructor({baseURL:e=T("ANTHROPIC_BASE_URL"),apiKey:t,authToken:r,webhookKey:s=T("ANTHROPIC_WEBHOOK_SIGNING_KEY")??null,...o}={}){if(Ls.add(this),this._requestAuthFlags=new WeakMap,Bn.set(this,void 0),t===void 0&&(t=o.profile!=null?null:T("ANTHROPIC_API_KEY")??null),r===void 0&&(r=o.profile!=null?null:T("ANTHROPIC_AUTH_TOKEN")??null),o.profile!=null&&(o.credentials!=null||o.config!=null))throw new TypeError("Pass at most one of `profile`, `credentials`, or `config`.");let a={apiKey:t,authToken:r,webhookKey:s,...o,baseURL:e||"https://api.anthropic.com"};if(!a.dangerouslyAllowBrowser&&Gs())throw new y(`It looks like you're running in a browser-like environment.
|
|
34
|
+
|
|
35
|
+
This is disabled by default, as it risks exposing your secret API credentials to attackers.
|
|
36
|
+
If you understand the risks and have appropriate mitigations in place,
|
|
37
|
+
you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
|
|
38
|
+
|
|
39
|
+
new Anthropic({ apiKey, dangerouslyAllowBrowser: true });
|
|
40
|
+
`);this.baseURL=a.baseURL,this._baseURLIsExplicit=o.__baseURLIsExplicit??!!e,this.timeout=a.timeout??Ds.DEFAULT_TIMEOUT,this.logger=a.logger??console,this.logLevel=ir,this.logLevel=Gr(a.logLevel,"ClientOptions.logLevel",C(this))??Gr(T("ANTHROPIC_LOG"),"process.env['ANTHROPIC_LOG']",C(this))??ir,this.fetchOptions=a.fetchOptions,this.maxRetries=a.maxRetries??2,this.fetch=a.fetch??eo(),_(this,Bn,ro,"f"),this.middleware=[...a.middleware??[]];let l=T("ANTHROPIC_CUSTOM_HEADERS");if(l){let h={};for(let g of l.split(`
|
|
41
|
+
`)){let d=g.indexOf(":");d>=0&&(h[g.substring(0,d).trim()]=g.substring(d+1).trim())}a.defaultHeaders={...h,...a.defaultHeaders}}let c=o.__auth;if(delete a.__auth,delete a.__baseURLIsExplicit,this._options=a,this.apiKey=typeof t=="string"?t:null,this.authToken=r,this.webhookKey=s,c)this._authState=c,!this._baseURLIsExplicit&&c.baseURL&&(this.baseURL=c.baseURL);else if(this._authState={provider:null,tokenCache:null,resolution:null,error:null,extraHeaders:{}},this.apiKey==null&&this.authToken==null){let h=a.credentials??null;if(h)this._authState.provider=h,this._authState.tokenCache=this._makeTokenCache(h);else if(a.config!=null){let g=rs(a.config,this._credentialResolverOptions());this._authState.provider=g.provider,this._authState.tokenCache=this._makeTokenCache(g.provider),this._authState.extraHeaders=g.extraHeaders,this._applyCredentialBaseURL(g.baseURL)}else a.profile!=null?this._authState.resolution=this._resolveDefaultCredentials(a.profile):this._shouldResolveDefaultCredentials()&&(this._authState.resolution=this._resolveDefaultCredentials())}}_shouldResolveDefaultCredentials(){return!0}_applyCredentialBaseURL(e){if(!e)return;let t=e.replace(/\/+$/,"");this._authState.baseURL=t,this._baseURLIsExplicit||(this.baseURL=t)}_credentialResolverOptions(){return{baseURL:this.baseURL,fetch:this._credentialsFetch(),userAgent:this.getUserAgent(),onCacheWriteError:e=>{C(this).debug("credential cache write failed (best-effort)",e)},onSafetyWarning:e=>{C(this).warn(e)}}}_credentialsFetch(){return os(this.fetch,this.middleware,void 0,this)}_makeTokenCache(e){return new Vr(e,t=>{C(this).debug("advisory token refresh failed; serving cached token",t)})}withOptions(e){let t="credentials"in e||"config"in e||"profile"in e,r="apiKey"in e||"authToken"in e||t,s={...this._options,...this._baseURLIsExplicit?{baseURL:this.baseURL}:{},maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,middleware:this.middleware,apiKey:this.apiKey,authToken:this.authToken,webhookKey:this.webhookKey,credentials:this.credentials,...t?{credentials:void 0,config:void 0,profile:void 0}:{},...e,__auth:r?void 0:this._authState,__baseURLIsExplicit:"baseURL"in e?!0:this._baseURLIsExplicit};return new this.constructor(s)}async _resolveDefaultCredentials(e){try{let t=await Mo(this._credentialResolverOptions(),e);if(t)this._authState.provider=t.provider,this._authState.tokenCache=this._makeTokenCache(t.provider),this._authState.extraHeaders=t.extraHeaders,this._applyCredentialBaseURL(t.baseURL);else if(e!=null)throw new y(`Profile "${e}" could not be resolved (no <config_dir>/configs/${e}.json found).`)}catch(t){this._authState.error=t}finally{this._authState.resolution=null}}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:t}){if(!(e.get("x-api-key")||e.get("authorization"))){if(this._authState.error)throw this._authState.error;if(!(this._authState.tokenCache||this._authState.resolution)&&!(this.apiKey&&e.get("x-api-key"))&&!t.has("x-api-key")&&!(this.authToken&&e.get("authorization"))&&!t.has("authorization"))throw new Error('Could not resolve authentication method. Expected one of apiKey, authToken, credentials, config, or profile to be set. Or for one of the "X-Api-Key" or "Authorization" headers to be explicitly omitted')}}_authFlags(e){let t=this._requestAuthFlags.get(e);return t||(t={usedTokenCache:!1,didRefreshFor401:!1},this._requestAuthFlags.set(e,t)),t}async authHeaders(e){if(this._authState.resolution&&await this._authState.resolution,!this._authState.error){if(this._authState.tokenCache&&this.apiKey==null){let t=await this._authState.tokenCache.getToken();return this._authFlags(e).usedTokenCache=!0,u([{Authorization:`Bearer ${t}`}])}return u([await this.apiKeyAuth(e),await this.bearerAuth(e)])}}async apiKeyAuth(e){if(this.apiKey!=null)return u([{"X-Api-Key":this.apiKey}])}async bearerAuth(e){if(this.authToken!=null)return u([{Authorization:`Bearer ${this.authToken}`}])}stringifyQuery(e){return ho(e)}getUserAgent(){return`${this.constructor.name}/JS ${oe}`}defaultIdempotencyKey(){return`stainless-node-retry-${lt()}`}makeStatusError(e,t,r,s){return B.generate(e,t,r,s)}buildURL(e,t,r){let s=!i(this,Ls,"m",Pi).call(this)&&r||this.baseURL,o=Ws(e)?new URL(e):new URL(s+(s.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),a=this.defaultQuery(),l=Object.fromEntries(o.searchParams);return(!jn(a)||!jn(l))&&(t={...l,...a,...t}),typeof t=="object"&&t&&!Array.isArray(t)&&(o.search=this.stringifyQuery(t)),o.toString()}_calculateNonstreamingTimeout(e){if(3600*e/128e3>600)throw new y("Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#streaming-responses for more details");return 600*1e3}async prepareOptions(e){}async prepareRequest(e,{url:t,options:r}){if(this._authState.tokenCache&&this.apiKey==null){let s=e.headers instanceof Headers?e.headers:new Headers(e.headers);for(let[a,l]of Object.entries(this._authState.extraHeaders))s.has(a)||s.set(a,l);s.get("anthropic-beta")?.split(",").map(a=>a.trim())?.includes(Ke)||s.append("anthropic-beta",Ke),e.headers=s}}backendMiddleware(){return[]}get(e,t){return this.methodRequest("get",e,t)}post(e,t){return this.methodRequest("post",e,t)}patch(e,t){return this.methodRequest("patch",e,t)}put(e,t){return this.methodRequest("put",e,t)}delete(e,t){return this.methodRequest("delete",e,t)}methodRequest(e,t,r){return this.request(Promise.resolve(r).then(s=>({method:e,path:t,...s})))}request(e,t=null){return new Ve(this,this.makeRequest(e,t,void 0))}async makeRequest(e,t,r){let s=await e,o=s.maxRetries??this.maxRetries;t==null&&(t=o,this._requestAuthFlags.delete(s)),await this.prepareOptions(s);let{req:a,url:l,timeout:c}=await this.buildRequest(s,{retryCount:o-t}),h="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),g=r===void 0?"":`, retryOf: ${r}`,d=Date.now();if(s.signal?.aborted)throw new J;let f=new AbortController,p=await this.fetchWithTimeout(l,a,c,f,s,{requestLogID:h,retryOfRequestLogID:r}).catch(We),b=Date.now();if(p instanceof globalThis.Error){me(f);let k=`retrying, ${t} attempts remaining`;if(s.signal?.aborted)throw new J;let w=Z(p)||/timed? ?out/i.test(String(p)+("cause"in p?String(p.cause):"")),E=this.middleware.length>0||!!s.middleware?.length||this.backendMiddleware().length>0;if(E&&!w&&!Ho(p))throw C(this).info(`[${h}] middleware error (not retryable)`),C(this).debug(`[${h}] middleware error (not retryable)`,ge({retryOfRequestLogID:r,url:l,durationMs:b-d,message:p.message})),p;if(t)return C(this).info(`[${h}] connection ${w?"timed out":"failed"} - ${k}`),C(this).debug(`[${h}] connection ${w?"timed out":"failed"} (${k})`,ge({retryOfRequestLogID:r,url:l,durationMs:b-d,message:p.message})),this.retryRequest(s,t,r??h);throw C(this).info(`[${h}] connection ${w?"timed out":"failed"} - error; no more retries left`),C(this).debug(`[${h}] connection ${w?"timed out":"failed"} (error; no more retries left)`,ge({retryOfRequestLogID:r,url:l,durationMs:b-d,message:p.message})),w?new ut:E&&!ss(p)?p:new pe({cause:p})}let v=[...p.headers.entries()].filter(([k])=>k==="request-id").map(([k,w])=>", "+k+": "+JSON.stringify(w)).join(""),x=`[${h}${g}${v}] ${a.method} ${l} ${p.ok?"succeeded":"failed"} with status ${p.status} in ${b-d}ms`;if(!p.ok){let k=await this.shouldRetry(p,s);if(t&&k){let I=`retrying, ${t} attempts remaining`;return await to(p.body),me(f),C(this).info(`${x} - ${I}`),C(this).debug(`[${h}] response error (${I})`,ge({retryOfRequestLogID:r,url:p.url,status:p.status,headers:p.headers,durationMs:b-d})),this.retryRequest(s,t,r??h,p.headers)}let w=k?"error; no more retries left":"error; not retryable";C(this).info(`${x} - ${w}`);let E=await p.text().catch(I=>We(I).message),A=Je(E),P=A?void 0:E;throw C(this).debug(`[${h}] response error (${w})`,ge({retryOfRequestLogID:r,url:p.url,status:p.status,headers:p.headers,message:P,durationMs:Date.now()-d})),me(f),this.makeStatusError(p.status,A,P,p.headers)}return C(this).info(x),C(this).debug(`[${h}] response start`,ge({retryOfRequestLogID:r,url:p.url,status:p.status,headers:p.headers,durationMs:b-d})),Zs(p.body??p,f),{response:p,options:s,controller:f,requestLogID:h,retryOfRequestLogID:r,startTime:d}}getAPIList(e,t,r){return this.requestAPIList(t,r&&"then"in r?r.then(s=>({method:"get",path:e,...s})):{method:"get",path:e,...r})}requestAPIList(e,t){let r=this.makeRequest(t,null,void 0);return new dr(this,r,e)}async fetchWithTimeout(e,t,r,s,o,a){let{signal:l,method:c,...h}=t||{},g=this._makeAbort(s);l&&(l.addEventListener("abort",g,{once:!0}),Qs(s,l,g));let d=globalThis.ReadableStream&&h.body instanceof globalThis.ReadableStream||typeof h.body=="object"&&h.body!==null&&Symbol.asyncIterator in h.body,f={signal:s.signal,...d?{duplex:"half"}:{},method:"GET",...h};c&&(f.method=c.toUpperCase());let p=this.fetch,b=async(E,A)=>{let P=setTimeout(g,r);try{return await p.call(void 0,E,A)}finally{clearTimeout(P)}},v=o===void 0?b:(async(E,A={})=>{let P=typeof E=="string"?E:E instanceof URL?E.href:E.url;return A.headers=A.headers instanceof Headers?A.headers:new Headers(A.headers),await this.prepareRequest(A,{url:P,options:o}),a&&C(this).debug(`[${a.requestLogID}] sending request`,ge({retryOfRequestLogID:a.retryOfRequestLogID,method:A.method,url:P,options:o,headers:A.headers})),b(E,A)}),x=o?.middleware,k=this.backendMiddleware(),w=x?.length||k.length?[...this.middleware,...x??[],...k]:this.middleware;return await os(v,w,o,this)(e,f)}async shouldRetry(e,t){let r=this._authFlags(t);if(e.status===401&&this._authState.tokenCache&&r.usedTokenCache&&!r.didRefreshFor401)return r.didRefreshFor401=!0,this._authState.tokenCache.invalidate(),!0;let s=e.headers.get("x-should-retry");return s==="true"?!0:s==="false"?!1:e.status===408||e.status===409||e.status===429||e.status>=500}async retryRequest(e,t,r,s){let o,a=s?.get("retry-after-ms");if(a){let c=parseFloat(a);Number.isNaN(c)||(o=c)}let l=s?.get("retry-after");if(l&&!o){let c=parseFloat(l);Number.isNaN(c)?o=Date.parse(l)-Date.now():o=c*1e3}if(o===void 0){let c=e.maxRetries??this.maxRetries;o=this.calculateDefaultRetryTimeoutMillis(t,c)}return await de(o),this.makeRequest(e,t-1,r)}calculateDefaultRetryTimeoutMillis(e,t){let o=t-e,a=Math.min(.5*Math.pow(2,o),8),l=1-Math.random()*.25;return a*l*1e3}calculateNonstreamingTimeout(e,t){if(36e5*e/128e3>6e5||t!=null&&e>t)throw new y("Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#long-requests for more details");return 6e5}async buildRequest(e,{retryCount:t=0}={}){let r={...e},{method:s,path:o,query:a,defaultBaseURL:l}=r;this._authState.resolution&&await this._authState.resolution,!this._baseURLIsExplicit&&this._authState.baseURL&&this.baseURL!==this._authState.baseURL&&(this.baseURL=this._authState.baseURL);let c=this.buildURL(o,a,l);"timeout"in r&&Ks("timeout",r.timeout),r.timeout=r.timeout??this.timeout;let{bodyHeaders:h,body:g}=this.buildBody({options:r}),d=await this.buildHeaders({options:e,method:s,bodyHeaders:h,retryCount:t});return{req:{method:s,headers:d,...r.signal&&{signal:r.signal},...globalThis.ReadableStream&&g instanceof globalThis.ReadableStream&&{duplex:"half"},...g&&{body:g},...this.fetchOptions??{},...r.fetchOptions??{}},url:c,timeout:r.timeout}}async buildHeaders({options:e,method:t,bodyHeaders:r,retryCount:s}){let o={};this.idempotencyHeader&&t!=="get"&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),o[this.idempotencyHeader]=e.idempotencyKey);let a=u([o,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(s),...e.timeout?{"X-Stainless-Timeout":String(Math.trunc(e.timeout/1e3))}:{},...nr(),...this._options.dangerouslyAllowBrowser?{"anthropic-dangerous-direct-browser-access":"true"}:void 0,"anthropic-version":"2023-06-01"},await this.authHeaders(e),this._options.defaultHeaders,r,e.headers]);return this.validateHeaders(a),a.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:t}}){if(!e)return{bodyHeaders:void 0,body:void 0};let r=u([t]);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||typeof e=="string"&&r.values.has("content-type")||globalThis.Blob&&e instanceof globalThis.Blob||e instanceof FormData||e instanceof URLSearchParams||globalThis.ReadableStream&&e instanceof globalThis.ReadableStream?{bodyHeaders:void 0,body:e}:typeof e=="object"&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&typeof e.next=="function")?{bodyHeaders:void 0,body:Dr(e)}:typeof e=="object"&&r.values.get("content-type")==="application/x-www-form-urlencoded"?{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(e)}:i(this,Bn,"f").call(this,{body:e,headers:r})}};Ds=H,Bn=new WeakMap,Ls=new WeakSet,Pi=function(){return this.baseURL!=="https://api.anthropic.com"};H.Anthropic=Ds;H.HUMAN_PROMPT=Ti;H.AI_PROMPT=Oi;H.DEFAULT_TIMEOUT=6e5;H.AnthropicError=y;H.APIError=B;H.APIConnectionError=pe;H.APIConnectionTimeoutError=ut;H.APIUserAbortError=J;H.NotFoundError=pt;H.ConflictError=mt;H.RateLimitError=gt;H.BadRequestError=dt;H.AuthenticationError=ht;H.InternalServerError=bt;H.PermissionDeniedError=ft;H.UnprocessableEntityError=_t;H.toFile=tn;var qe=class extends H{constructor(){super(...arguments),this.completions=new it(this),this.messages=new je(this),this.models=new ct(this),this.beta=new D(this)}};qe.Completions=it;qe.Messages=je;qe.Models=ct;qe.Beta=D;var Fi=new TextEncoder,Cc=["fallback-credit-2026-07-01"];function Nc(n){let e=n.messages.map(t=>Array.isArray(t.content)?{...t,content:t.content.filter(r=>r.type!=="fallback")}:t).filter(t=>!Array.isArray(t.content)||t.content.length>0);return{...n,messages:e}}function Mi(n,e){let t={...n};for(let[r,s]of Object.entries(e))if(r==="output_config"&&s!=null){let o={...t[r]??{}};for(let[a,l]of Object.entries(s))Bs(o,a,l);Bs(t,r,Object.keys(o).length?o:null)}else Bs(t,r,s);return t}function Bs(n,e,t){t!==void 0&&(t===null?delete n[e]:n[e]=t)}function $c(n,e={}){let t=!1;return async(r,s,o)=>{let[a,l]=(o.options?.path??"").split("?");if(n.length===0||o.options?.method!=="post"||a!=="/v1/messages"||new URLSearchParams(l).get("beta")!=="true"||typeof o.options.body!="object"||o.options.body==null)return s(r);if(o.options.body.fallbacks!=null)throw new y("Sending the `fallbacks:` request param is not supported when using the `betaRefusalFallbackMiddleware`. You should either remove the middleware and send `fallbacks:` with the `server-side-fallback-2026-07-01` beta header to let the API handle refusal fallbacks, or omit the `fallbacks:` param if you'd like `betaRefusalFallbackMiddleware` to handle fallbacks on the client side.");let c=e.onError??(O=>o.logger.error(`anthropic-sdk: betaRefusalFallbackMiddleware: ${O.message}`));r=Bc(r,e.betas??Cc);let h=Nc(o.options.body),g=o.options.fallbackState,d=g?.index??-1;if(!Number.isInteger(d)||d<-1||d>=n.length)throw new y(`fallbackState.index ${d} is out of bounds for a chain of ${n.length} fallback(s); was the state shared with a different middleware?`);let f=O=>{g?g.index=O:t||(t=!0,o.logger.warn("anthropic-sdk: betaRefusalFallbackMiddleware fell back without a `fallbackState` request option; follow-up requests will retry models that already refused. Pass a shared `{ fallbackState: new BetaFallbackState() }` to pin them to the accepted model."))},p=d===-1?h:Mi(h,n[d]),b=typeof r.body!="string"?r:{...r,body:JSON.stringify(p)},v=await s(b);if(!v.ok)return v;if(o.options.stream===!0){let O=d+1;return O>=n.length||typeof b.body!="string"?v:Fc({request:b,response:v,next:s,ctx:o,fallbacks:n,firstHop:O,onError:c,pin:f})}let x=d,k=v,w=p.model,E=[];for(;x<n.length-1;){let O=await o.parse(k);if(O?.type!=="message"||O.stop_reason!=="refusal")break;x+=1,f(x);let I=n[x];E.push({type:"fallback",from:{model:w??O.model},to:{model:I.model},trigger:{type:"refusal",category:O.stop_details?.category??null}}),w=I.model,k=await s({...r,body:JSON.stringify({...Mi(h,I),...O.stop_details?.fallback_credit_token?{fallback_credit_token:Hi(O.stop_details.fallback_credit_token)}:void 0})})}if(E.length===0)return k;let A=await o.parse(k);if(A?.type!=="message"||A.stop_reason==="refusal"||!Array.isArray(A.content))return k;let P=new Headers(k.headers);return P.delete("content-length"),new Response(JSON.stringify({...A,content:[...E,...A.content]}),{status:k.status,statusText:k.statusText,headers:P})}}function Fc(n){let e=new AbortController,t=n.request.signal;t?.aborted?e.abort(t.reason):t?.addEventListener("abort",jc(e,t),{once:!0});let r=Hc(n,e),s=new ReadableStream({async pull(o){try{let{value:a,done:l}=await r.next();if(l)return o.close();o.enqueue(a)}catch(a){o.error(a)}},async cancel(){e.abort(),await r.return?.(void 0)}});return new Response(s,n.response)}async function*Hc({request:n,response:e,next:t,ctx:r,fallbacks:s,firstHop:o,onError:a,pin:l},c){let h=yield*Ci({response:e,controller:c,indexBase:0,hasNext:!0,onError:a,splice:null});if(!h.refused)return;let g=h.nextIndex,d=h.refused.token,f=[],p=h.refused.hasPrefillClaim?Ni(h.blocks):[],b=h.model??"",v=h.refused.usage,x=h.refused.stopDetails,k=[js("message",h.model??"",h.refused.usage)];for(let w=o;w<s.length;w++){let E=s[w].model,A=w+1<s.length;l(w);let P=g++;yield Re("content_block_start",{type:"content_block_start",index:P,content_block:{type:"fallback",from:{model:b},to:{model:E},trigger:{type:"refusal",category:x?.category??null}}}),yield Re("content_block_stop",{type:"content_block_stop",index:P});let O=[...f,...p],I=null,F=null;for(let $=0;$<2;$++){let z=Lc(n,{model:E,creditToken:d,continuation:O});z.signal=c.signal;try{I=await t(z)}catch(Ie){if(Z(Ie))throw Ie;F={kind:"request_failed",message:`fallback request failed: ${Ie}`,model:E,status:null,detail:Ie};break}if(I.ok)break;let ue=await r.parse(I).catch(()=>null);if($===0&&I.status===400&&p.length){r.logger.warn(`anthropic-sdk: betaRefusalFallbackMiddleware: fallback request with the partial output appended was rejected (HTTP 400: ${JSON.stringify(ue)}); retrying without it`),O=f,I=null;continue}F={kind:"request_failed",message:`fallback request failed: HTTP ${I.status}: ${JSON.stringify(ue)}`,model:E,status:I.status,detail:ue};break}if(F){if(a(F),A)continue;let $={...x,recommended_model:E};yield Re("message_delta",{type:"message_delta",context_management:null,delta:{stop_reason:"refusal",stop_sequence:null,container:null,stop_details:$},usage:v??{}}),yield Re("message_stop",{type:"message_stop"});return}let M=yield*Ci({response:I,controller:c,indexBase:g,hasNext:A,onError:a,splice:{iterations:k,model:E}});if(!M.refused)return;d=M.refused.token,x=M.refused.stopDetails,f=O,p=M.refused.hasPrefillClaim?Ni(M.blocks):[],k.push(js("message",E,M.refused.usage)),v=M.refused.usage,b=E,g=M.nextIndex}}async function*Ci(n){let{response:e,controller:t,indexBase:r,hasNext:s,onError:o,splice:a}=n,l=new Us(r),c,h=null;for await(let g of G.rawEvents(e,t)){let d=Je(g.data);switch(d?.type){case"message_start":{if(c=d.message.model,h=d.message.usage,a)continue;break}case"content_block_start":{if(l.start(d),a){yield Re(d.type,d);continue}break}case"content_block_delta":{if(l.delta(d),a){yield Re(d.type,d);continue}break}case"content_block_stop":{if(l.stop(d),a){yield Re(d.type,d);continue}break}case"message_delta":{if(d.delta.stop_reason==="refusal"){let f=d.delta.stop_details?.type==="refusal"?d.delta.stop_details:null;if(f?.fallback_credit_token&&s){let p=$i(d.usage,h);return yield*l.closeOpenBlocks(),{refused:{token:f.fallback_credit_token,hasPrefillClaim:f.fallback_has_prefill_claim===!0,usage:p,stopDetails:f},model:c,blocks:l.contentBlocks(),nextIndex:l.nextIndex}}f?.fallback_credit_token?o({kind:"chain_exhausted",message:"refusal but no fallback entries remain",event:d}):o({kind:"no_credit_token",message:"refusal stop_details has no fallback_credit_token",event:d})}if(a){let f=$i(d.usage,h);f.iterations=[...a.iterations,js("fallback_message",a.model,f)],d.usage=f,yield Re("message_delta",d);continue}break}}yield Uc(g)}return{refused:null,model:c,blocks:l.contentBlocks(),nextIndex:l.nextIndex}}var Us=class{constructor(e=0){this.indexBase=e,this.blocks=[],this.open=[],this.nextIndex=e}contentBlocks(){return this.blocks.map(e=>e.block)}start(e){this.blocks.push({index:e.index,block:{...e.content_block}}),e.index+=this.indexBase,this.open.push(e.index),this.nextIndex=Math.max(this.nextIndex,e.index+1)}delta(e){Dc(this.blocks,e.index,e.delta),e.index+=this.indexBase}stop(e){e.index+=this.indexBase;let t=this.open.indexOf(e.index);t!==-1&&this.open.splice(t,1),this.nextIndex=Math.max(this.nextIndex,e.index+1)}*closeOpenBlocks(){for(let e of this.open)yield Re("content_block_stop",{type:"content_block_stop",index:e});this.open.length=0}};function Hi(n){return{token:n,mode:"best_effort"}}function Lc(n,{model:e,creditToken:t,continuation:r}){let s=JSON.parse(n.body);return s.model=e,s.fallback_credit_token=Hi(t),r.length&&(s.messages=[...s.messages,{role:"assistant",content:r}]),{...n,headers:new Headers(n.headers),body:JSON.stringify(s)}}function Dc(n,e,t){let r=n.find(s=>s.index===e)?.block;if(r)switch(t.type){case"text_delta":{r.text=(r.text??"")+t.text;break}case"input_json_delta":{r._partial_json=(r._partial_json??"")+t.partial_json;break}case"citations_delta":(r.citations??(r.citations=[])).push(t.citation);break;case"thinking_delta":{r.thinking=(r.thinking??"")+t.thinking;break}case"signature_delta":{r.signature=t.signature;break}case"compaction_delta":break;default:}}function Ni(n){return n.map(e=>{if(typeof e?._partial_json!="string")return e;let{_partial_json:t,...r}=e;return{...r,input:Je(t)??r.input}})}function Bc(n,e){let t=new Headers(n.headers),r=new Set(t.get("anthropic-beta")?.split(",").map(s=>s.trim()));for(let s of e)r.has(s)||(t.append("anthropic-beta",s),r.add(s));return t.set(be,us(t.get(be),"fallback-refusal-middleware")),{...n,headers:t}}function Re(n,e){let t={event:n,data:JSON.stringify(e),raw:[]};return Fi.encode(Li(t))}function Uc(n){return Fi.encode(n.raw.length?n.raw.join(`
|
|
42
|
+
`)+`
|
|
43
|
+
|
|
44
|
+
`:Li(n))}function js(n,e,t){return{type:n,model:e,input_tokens:t?.input_tokens??0,output_tokens:t?.output_tokens??0,cache_read_input_tokens:t?.cache_read_input_tokens??0,cache_creation_input_tokens:t?.cache_creation_input_tokens??0,cache_creation:t?.cache_creation??null}}function $i(n,e){let t={...e??{},...n??{}};for(let r of Object.keys(t))t[r]==null&&e?.[r]!=null&&(t[r]=e[r]);return t}function Li(n){let e="";n.event!==null&&(e+=`event: ${n.event}
|
|
45
|
+
`);for(let t of n.data.split(`
|
|
46
|
+
`))e+=`data: ${t}
|
|
47
|
+
`;return e+`
|
|
48
|
+
`}function jc(n,e){return()=>n.abort(e.reason)}export{_ as a,i as b,y as c,B as d,J as e,pe as f,ut as g,tr as h,dt as i,ht as j,ft as k,pt as l,mt as m,_t as n,gt as o,bt as p,Br as q,C as r,Ve as s,dr as t,tn as u,xe as v,Is as w,Ti as x,Oi as y,H as z,qe as A,$c as B};
|