noskills 5.0.0 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/README.md +25 -1123
  2. package/dist/launcher.js +162 -0
  3. package/dist/noskills.js +38 -0
  4. package/package.json +31 -16
  5. package/noskills.js +0 -146
  6. package/ts/chunks/ajan-bridge-6UUIUFAV.js +0 -1
  7. package/ts/chunks/anthropic-ICVQ5GK6.js +0 -1
  8. package/ts/chunks/approve-R7MCYHCS.js +0 -1
  9. package/ts/chunks/ask-GBLFPNFX.js +0 -2
  10. package/ts/chunks/block-YEKLMXHR.js +0 -1
  11. package/ts/chunks/cancel-7NS4WM2N.js +0 -1
  12. package/ts/chunks/chunk-2CLD527I.js +0 -1
  13. package/ts/chunks/chunk-34AWV7DB.js +0 -1
  14. package/ts/chunks/chunk-3M26Y3NG.js +0 -27
  15. package/ts/chunks/chunk-3QVRJO3V.js +0 -1
  16. package/ts/chunks/chunk-5ALJRBMW.js +0 -22
  17. package/ts/chunks/chunk-5NMDE2VZ.js +0 -4
  18. package/ts/chunks/chunk-6BKTY7SA.js +0 -4
  19. package/ts/chunks/chunk-6M7PCVUR.js +0 -1
  20. package/ts/chunks/chunk-6O2RXYTM.js +0 -3
  21. package/ts/chunks/chunk-7DIQYKPL.js +0 -3
  22. package/ts/chunks/chunk-7J6R2D2K.js +0 -2
  23. package/ts/chunks/chunk-ATNTR7M5.js +0 -1
  24. package/ts/chunks/chunk-AW3XJGEP.js +0 -1
  25. package/ts/chunks/chunk-BRC46A3N.js +0 -39
  26. package/ts/chunks/chunk-C5LYQDQH.js +0 -368
  27. package/ts/chunks/chunk-CCYWFSXR.js +0 -3
  28. package/ts/chunks/chunk-CL55MNGD.js +0 -1
  29. package/ts/chunks/chunk-CSP2GUD4.js +0 -29
  30. package/ts/chunks/chunk-D2UKX2VW.js +0 -2
  31. package/ts/chunks/chunk-DGYDUGTM.js +0 -1
  32. package/ts/chunks/chunk-FB3Z7XYQ.js +0 -1
  33. package/ts/chunks/chunk-FLLYK5FU.js +0 -1
  34. package/ts/chunks/chunk-GCPGG4YB.js +0 -1
  35. package/ts/chunks/chunk-HISXAZ4Y.js +0 -1
  36. package/ts/chunks/chunk-HLDPASM6.js +0 -3
  37. package/ts/chunks/chunk-HNQA5O2S.js +0 -2
  38. package/ts/chunks/chunk-HUP7XWW6.js +0 -1
  39. package/ts/chunks/chunk-I4Z2RF7L.js +0 -31
  40. package/ts/chunks/chunk-J3XNDEMU.js +0 -4
  41. package/ts/chunks/chunk-K6FVY52W.js +0 -5
  42. package/ts/chunks/chunk-KQJGXVWX.js +0 -91
  43. package/ts/chunks/chunk-M4U4Y3XQ.js +0 -7
  44. package/ts/chunks/chunk-M6CAJL36.js +0 -1
  45. package/ts/chunks/chunk-MPHTBN7E.js +0 -1
  46. package/ts/chunks/chunk-NYIFCLEG.js +0 -1
  47. package/ts/chunks/chunk-RRDWQKZY.js +0 -1
  48. package/ts/chunks/chunk-RVNSKPFL.js +0 -1
  49. package/ts/chunks/chunk-S5F2DAAG.js +0 -5
  50. package/ts/chunks/chunk-SCYP2G2T.js +0 -3
  51. package/ts/chunks/chunk-SWP6BJR6.js +0 -147
  52. package/ts/chunks/chunk-SWRVSRYY.js +0 -5
  53. package/ts/chunks/chunk-T2X4E35X.js +0 -1
  54. package/ts/chunks/chunk-TDLTCTV4.js +0 -1
  55. package/ts/chunks/chunk-TKBGNLNV.js +0 -1
  56. package/ts/chunks/chunk-UY4YFVSW.js +0 -3
  57. package/ts/chunks/chunk-V5ZXCJPI.js +0 -2
  58. package/ts/chunks/chunk-W46BJM2F.js +0 -1
  59. package/ts/chunks/chunk-W7KQFMHV.js +0 -1
  60. package/ts/chunks/chunk-XGRZPTAD.js +0 -24
  61. package/ts/chunks/chunk-XTQFSF6C.js +0 -1
  62. package/ts/chunks/chunk-YN3SHWBR.js +0 -1
  63. package/ts/chunks/chunk-ZAY6LSJD.js +0 -2
  64. package/ts/chunks/chunk-ZGVXR3EC.js +0 -8
  65. package/ts/chunks/chunk-ZW5C5IGT.js +0 -32
  66. package/ts/chunks/claude-code-J2V5WSGZ.js +0 -1
  67. package/ts/chunks/concern-EDWQHU4H.js +0 -1
  68. package/ts/chunks/config-E7BDBHPK.js +0 -1
  69. package/ts/chunks/decision-ledger-5QXKZSV2.js +0 -1
  70. package/ts/chunks/delegate-LVQQ3GCV.js +0 -1
  71. package/ts/chunks/diagrams-2F5ZYXA7.js +0 -1
  72. package/ts/chunks/diagrams-H62JGTIS.js +0 -1
  73. package/ts/chunks/dist-3MH5UCQU.js +0 -12
  74. package/ts/chunks/done-U3TOSZIX.js +0 -1
  75. package/ts/chunks/followup-J2HJU3ZT.js +0 -1
  76. package/ts/chunks/free-73WMLMCT.js +0 -1
  77. package/ts/chunks/gemini-GA6P4M7D.js +0 -1
  78. package/ts/chunks/init-6CVDGRY2.js +0 -1
  79. package/ts/chunks/invoke-hook-2TMKWL7I.js +0 -15
  80. package/ts/chunks/kiro-BJSKSAUC.js +0 -1
  81. package/ts/chunks/learn-7Q2VWZMI.js +0 -7
  82. package/ts/chunks/ledger-XR4AHZRX.js +0 -2
  83. package/ts/chunks/list-CUQCPXZH.js +0 -1
  84. package/ts/chunks/manager-WTLJ5C2I.js +0 -3
  85. package/ts/chunks/mod-BZA5TFW7.js +0 -1
  86. package/ts/chunks/mod-RWA5ZPYH.js +0 -1
  87. package/ts/chunks/mod-X372UNSQ.js +0 -1
  88. package/ts/chunks/mod-XVE4ZWPY.js +0 -1
  89. package/ts/chunks/multipart-parser-DKDFOZKD.js +0 -2
  90. package/ts/chunks/next-CEYZSYGB.js +0 -20
  91. package/ts/chunks/node-33JV5VS3.js +0 -15
  92. package/ts/chunks/node-XYP2DQHR.js +0 -74
  93. package/ts/chunks/node-ZSGIX7K3.js +0 -1
  94. package/ts/chunks/ollama-X6OGN5BW.js +0 -1
  95. package/ts/chunks/openai-TV7KLQ2C.js +0 -1
  96. package/ts/chunks/openai-YPM2E7QS.js +0 -30
  97. package/ts/chunks/opencode-AK6WWZRF.js +0 -1
  98. package/ts/chunks/pack-EOUSZGJT.js +0 -5
  99. package/ts/chunks/plan-export-ZBINRAAS.js +0 -3
  100. package/ts/chunks/purge-GPMC5A6Y.js +0 -5
  101. package/ts/chunks/reopen-LPVNZN5I.js +0 -1
  102. package/ts/chunks/reset-RNLPXGWQ.js +0 -1
  103. package/ts/chunks/review-ZGAY5XCN.js +0 -1
  104. package/ts/chunks/rule-SNBQ4VZD.js +0 -6
  105. package/ts/chunks/run-4TDP4C7Z.js +0 -3
  106. package/ts/chunks/sdk-MEVPL5WT.js +0 -1
  107. package/ts/chunks/session-J7TSLNEH.js +0 -1
  108. package/ts/chunks/spec-3NSPFDIC.js +0 -1
  109. package/ts/chunks/src-HXQVVTGQ.js +0 -3
  110. package/ts/chunks/status-DIEA2OGR.js +0 -1
  111. package/ts/chunks/sync-HZNKILSP.js +0 -1
  112. package/ts/chunks/validate-MWHDOF2F.js +0 -1
  113. package/ts/chunks/vertexai-ARXI4AMJ.js +0 -1
  114. package/ts/chunks/watch-P6HABMAS.js +0 -7
  115. package/ts/chunks/web-BMIC3VJQ.js +0 -1
  116. package/ts/chunks/wontfix-6UKEYTVB.js +0 -1
  117. package/ts/noskills.js +0 -2
@@ -1,29 +0,0 @@
1
- import{a as St,b as Pe,c as Q,d as va,e as Te}from"./chunk-RRDWQKZY.js";import{c as wa,e as Dh}from"./chunk-HISXAZ4Y.js";var rp=wa(Ee=>{"use strict";var Q_=Ee&&Ee.__extends||(function(){var r=function(i,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var s in n)n.hasOwnProperty(s)&&(t[s]=n[s])},r(i,e)};return function(i,e){r(i,e);function t(){this.constructor=i}i.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}})();Object.defineProperty(Ee,"__esModule",{value:!0});var X=256,jl=(function(){function r(i){i===void 0&&(i="="),this._paddingCharacter=i}return r.prototype.encodedLength=function(i){return this._paddingCharacter?(i+2)/3*4|0:(i*8+5)/6|0},r.prototype.encode=function(i){for(var e="",t=0;t<i.length-2;t+=3){var n=i[t]<<16|i[t+1]<<8|i[t+2];e+=this._encodeByte(n>>>18&63),e+=this._encodeByte(n>>>12&63),e+=this._encodeByte(n>>>6&63),e+=this._encodeByte(n>>>0&63)}var s=i.length-t;if(s>0){var n=i[t]<<16|(s===2?i[t+1]<<8:0);e+=this._encodeByte(n>>>18&63),e+=this._encodeByte(n>>>12&63),s===2?e+=this._encodeByte(n>>>6&63):e+=this._paddingCharacter||"",e+=this._paddingCharacter||""}return e},r.prototype.maxDecodedLength=function(i){return this._paddingCharacter?i/4*3|0:(i*6+7)/8|0},r.prototype.decodedLength=function(i){return this.maxDecodedLength(i.length-this._getPaddingLength(i))},r.prototype.decode=function(i){if(i.length===0)return new Uint8Array(0);for(var e=this._getPaddingLength(i),t=i.length-e,n=new Uint8Array(this.maxDecodedLength(t)),s=0,a=0,l=0,p=0,h=0,m=0,_=0;a<t-4;a+=4)p=this._decodeChar(i.charCodeAt(a+0)),h=this._decodeChar(i.charCodeAt(a+1)),m=this._decodeChar(i.charCodeAt(a+2)),_=this._decodeChar(i.charCodeAt(a+3)),n[s++]=p<<2|h>>>4,n[s++]=h<<4|m>>>2,n[s++]=m<<6|_,l|=p&X,l|=h&X,l|=m&X,l|=_&X;if(a<t-1&&(p=this._decodeChar(i.charCodeAt(a)),h=this._decodeChar(i.charCodeAt(a+1)),n[s++]=p<<2|h>>>4,l|=p&X,l|=h&X),a<t-2&&(m=this._decodeChar(i.charCodeAt(a+2)),n[s++]=h<<4|m>>>2,l|=m&X),a<t-3&&(_=this._decodeChar(i.charCodeAt(a+3)),n[s++]=m<<6|_,l|=_&X),l!==0)throw new Error("Base64Coder: incorrect characters for decoding");return n},r.prototype._encodeByte=function(i){var e=i;return e+=65,e+=25-i>>>8&6,e+=51-i>>>8&-75,e+=61-i>>>8&-15,e+=62-i>>>8&3,String.fromCharCode(e)},r.prototype._decodeChar=function(i){var e=X;return e+=(42-i&i-44)>>>8&-X+i-43+62,e+=(46-i&i-48)>>>8&-X+i-47+63,e+=(47-i&i-58)>>>8&-X+i-48+52,e+=(64-i&i-91)>>>8&-X+i-65+0,e+=(96-i&i-123)>>>8&-X+i-97+26,e},r.prototype._getPaddingLength=function(i){var e=0;if(this._paddingCharacter){for(var t=i.length-1;t>=0&&i[t]===this._paddingCharacter;t--)e++;if(i.length<4||e>2)throw new Error("Base64Coder: incorrect padding")}return e},r})();Ee.Coder=jl;var Un=new jl;function X_(r){return Un.encode(r)}Ee.encode=X_;function Z_(r){return Un.decode(r)}Ee.decode=Z_;var ep=(function(r){Q_(i,r);function i(){return r!==null&&r.apply(this,arguments)||this}return i.prototype._encodeByte=function(e){var t=e;return t+=65,t+=25-e>>>8&6,t+=51-e>>>8&-75,t+=61-e>>>8&-13,t+=62-e>>>8&49,String.fromCharCode(t)},i.prototype._decodeChar=function(e){var t=X;return t+=(44-e&e-46)>>>8&-X+e-45+62,t+=(94-e&e-96)>>>8&-X+e-95+63,t+=(47-e&e-58)>>>8&-X+e-48+52,t+=(64-e&e-91)>>>8&-X+e-65+0,t+=(96-e&e-123)>>>8&-X+e-97+26,t},i})(jl);Ee.URLSafeCoder=ep;var tp=new ep;function ef(r){return tp.encode(r)}Ee.encodeURLSafe=ef;function tf(r){return tp.decode(r)}Ee.decodeURLSafe=tf;Ee.encodedLength=function(r){return Un.encodedLength(r)};Ee.maxDecodedLength=function(r){return Un.maxDecodedLength(r)};Ee.decodedLength=function(r){return Un.decodedLength(r)}});var np=wa((ip,wo)=>{(function(r,i){var e={};i(e);var t=e.default;for(var n in e)t[n]=e[n];typeof wo=="object"&&typeof wo.exports=="object"?wo.exports=t:typeof define=="function"&&define.amd?define(function(){return t}):r.sha256=t})(ip,function(r){"use strict";r.__esModule=!0,r.digestLength=32,r.blockSize=64;var i=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 e(_,g,y,v,k){for(var E,T,x,C,P,A,O,B,L,$,H,ae,oe;k>=64;){for(E=g[0],T=g[1],x=g[2],C=g[3],P=g[4],A=g[5],O=g[6],B=g[7],$=0;$<16;$++)H=v+$*4,_[$]=(y[H]&255)<<24|(y[H+1]&255)<<16|(y[H+2]&255)<<8|y[H+3]&255;for($=16;$<64;$++)L=_[$-2],ae=(L>>>17|L<<15)^(L>>>19|L<<13)^L>>>10,L=_[$-15],oe=(L>>>7|L<<25)^(L>>>18|L<<14)^L>>>3,_[$]=(ae+_[$-7]|0)+(oe+_[$-16]|0);for($=0;$<64;$++)ae=(((P>>>6|P<<26)^(P>>>11|P<<21)^(P>>>25|P<<7))+(P&A^~P&O)|0)+(B+(i[$]+_[$]|0)|0)|0,oe=((E>>>2|E<<30)^(E>>>13|E<<19)^(E>>>22|E<<10))+(E&T^E&x^T&x)|0,B=O,O=A,A=P,P=C+ae|0,C=x,x=T,T=E,E=ae+oe|0;g[0]+=E,g[1]+=T,g[2]+=x,g[3]+=C,g[4]+=P,g[5]+=A,g[6]+=O,g[7]+=B,v+=64,k-=64}return v}var t=(function(){function _(){this.digestLength=r.digestLength,this.blockSize=r.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 _.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},_.prototype.clean=function(){for(var g=0;g<this.buffer.length;g++)this.buffer[g]=0;for(var g=0;g<this.temp.length;g++)this.temp[g]=0;this.reset()},_.prototype.update=function(g,y){if(y===void 0&&(y=g.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");var v=0;if(this.bytesHashed+=y,this.bufferLength>0){for(;this.bufferLength<64&&y>0;)this.buffer[this.bufferLength++]=g[v++],y--;this.bufferLength===64&&(e(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(y>=64&&(v=e(this.temp,this.state,g,v,y),y%=64);y>0;)this.buffer[this.bufferLength++]=g[v++],y--;return this},_.prototype.finish=function(g){if(!this.finished){var y=this.bytesHashed,v=this.bufferLength,k=y/536870912|0,E=y<<3,T=y%64<56?64:128;this.buffer[v]=128;for(var x=v+1;x<T-8;x++)this.buffer[x]=0;this.buffer[T-8]=k>>>24&255,this.buffer[T-7]=k>>>16&255,this.buffer[T-6]=k>>>8&255,this.buffer[T-5]=k>>>0&255,this.buffer[T-4]=E>>>24&255,this.buffer[T-3]=E>>>16&255,this.buffer[T-2]=E>>>8&255,this.buffer[T-1]=E>>>0&255,e(this.temp,this.state,this.buffer,0,T),this.finished=!0}for(var x=0;x<8;x++)g[x*4+0]=this.state[x]>>>24&255,g[x*4+1]=this.state[x]>>>16&255,g[x*4+2]=this.state[x]>>>8&255,g[x*4+3]=this.state[x]>>>0&255;return this},_.prototype.digest=function(){var g=new Uint8Array(this.digestLength);return this.finish(g),g},_.prototype._saveState=function(g){for(var y=0;y<this.state.length;y++)g[y]=this.state[y]},_.prototype._restoreState=function(g,y){for(var v=0;v<this.state.length;v++)this.state[v]=g[v];this.bytesHashed=y,this.finished=!1,this.bufferLength=0},_})();r.Hash=t;var n=(function(){function _(g){this.inner=new t,this.outer=new t,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var y=new Uint8Array(this.blockSize);if(g.length>this.blockSize)new t().update(g).finish(y).clean();else for(var v=0;v<g.length;v++)y[v]=g[v];for(var v=0;v<y.length;v++)y[v]^=54;this.inner.update(y);for(var v=0;v<y.length;v++)y[v]^=106;this.outer.update(y),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate);for(var v=0;v<y.length;v++)y[v]=0}return _.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},_.prototype.clean=function(){for(var g=0;g<this.istate.length;g++)this.ostate[g]=this.istate[g]=0;this.inner.clean(),this.outer.clean()},_.prototype.update=function(g){return this.inner.update(g),this},_.prototype.finish=function(g){return this.outer.finished?this.outer.finish(g):(this.inner.finish(g),this.outer.update(g,this.digestLength).finish(g)),this},_.prototype.digest=function(){var g=new Uint8Array(this.digestLength);return this.finish(g),g},_})();r.HMAC=n;function s(_){var g=new t().update(_),y=g.digest();return g.clean(),y}r.hash=s,r.default=s;function a(_,g){var y=new n(_).update(g),v=y.digest();return y.clean(),v}r.hmac=a;function l(_,g,y,v){var k=v[0];if(k===0)throw new Error("hkdf: cannot expand more");g.reset(),k>1&&g.update(_),y&&g.update(y),g.update(v),g.finish(_),v[0]++}var p=new Uint8Array(r.digestLength);function h(_,g,y,v){g===void 0&&(g=p),v===void 0&&(v=32);for(var k=new Uint8Array([1]),E=a(g,_),T=new n(E),x=new Uint8Array(T.digestLength),C=x.length,P=new Uint8Array(v),A=0;A<v;A++)C===x.length&&(l(x,T,y,k),C=0),P[A]=x[C++];return T.clean(),x.fill(0),k.fill(0),P}r.hkdf=h;function m(_,g,y,v){for(var k=new n(_),E=k.digestLength,T=new Uint8Array(4),x=new Uint8Array(E),C=new Uint8Array(E),P=new Uint8Array(v),A=0;A*E<v;A++){var O=A+1;T[0]=O>>>24&255,T[1]=O>>>16&255,T[2]=O>>>8&255,T[3]=O>>>0&255,k.reset(),k.update(g),k.update(T),k.finish(C);for(var B=0;B<E;B++)x[B]=C[B];for(var B=2;B<=y;B++){k.reset(),k.update(C).finish(C);for(var L=0;L<E;L++)x[L]^=C[L]}for(var B=0;B<E&&A*E+B<v;B++)P[A*E+B]=x[B]}for(var A=0;A<E;A++)x[A]=C[A]=0;for(var A=0;A<4;A++)T[A]=0;return k.clean(),P}r.pbkdf2=m})});var ap=wa(Kl=>{"use strict";Object.defineProperty(Kl,"__esModule",{value:!0});Kl.timingSafeEqual=rf;function sp(r,i=""){if(!r)throw new Error(i)}function rf(r,i){if(r.byteLength!==i.byteLength)return!1;r instanceof DataView||(r=new DataView(ArrayBuffer.isView(r)?r.buffer:r)),i instanceof DataView||(i=new DataView(ArrayBuffer.isView(i)?i.buffer:i)),sp(r instanceof DataView),sp(i instanceof DataView);let e=r.byteLength,t=0,n=-1;for(;++n<e;)t|=r.getUint8(n)^i.getUint8(n);return t===0}});var lp=wa(pr=>{"use strict";Object.defineProperty(pr,"__esModule",{value:!0});pr.Webhook=pr.WebhookVerificationError=void 0;var op=rp(),nf=np(),sf=ap(),cp=300,Dl=class r extends Error{constructor(i){super(i),Object.setPrototypeOf(this,r.prototype),this.name="ExtendableError",this.stack=new Error(i).stack}},dt=class r extends Dl{constructor(i){super(i),Object.setPrototypeOf(this,r.prototype),this.name="WebhookVerificationError"}};pr.WebhookVerificationError=dt;var vo=class r{constructor(i,e){if(e?.format==="raw")i instanceof Uint8Array?this.key=i:this.key=Uint8Array.from(i,t=>t.charCodeAt(0));else{if(typeof i!="string")throw new Error("Expected secret to be of type string");i.startsWith(r.prefix)&&(i=i.substring(r.prefix.length)),this.key=op.decode(i)}if(this.key.length===0)throw new Error("Secret can't be empty.")}verify(i,e,t){var n;let s=(n=t?.jsonParse)!==null&&n!==void 0?n:!0,a={};for(let k of Object.keys(e))a[k.toLowerCase()]=e[k];let l=a["webhook-id"],p=a["webhook-signature"],h=a["webhook-timestamp"];if(!p||!l||!h)throw new dt("Missing required headers");let m=this.verifyTimestamp(h),g=this.sign(l,m,i).split(",")[1],y=p.split(" "),v=new globalThis.TextEncoder;for(let k of y){let[E,T]=k.split(",");if(E==="v1"&&(0,sf.timingSafeEqual)(v.encode(T),v.encode(g))){let x=i.toString();return x===""?void 0:s?JSON.parse(x):void 0}}throw new dt("No matching signature found")}sign(i,e,t){if(typeof t!="string")if(t.constructor.name==="Buffer")t=t.toString();else throw new Error("Expected payload to be of type string or Buffer.");let n=new TextEncoder,s=Math.floor(e.getTime()/1e3),a=n.encode(`${i}.${s}.${t}`);return`v1,${op.encode(nf.hmac(this.key,a))}`}verifyTimestamp(i){let e=Math.floor(Date.now()/1e3),t=parseInt(i,10);if(Number.isNaN(t))throw new dt("Invalid Signature Headers");if(e-t>cp)throw new dt("Message timestamp too old");if(t>e+cp)throw new dt("Message timestamp too new");return new Date(t*1e3)}};pr.Webhook=vo;vo.prefix="whsec_"});function b(r,i,e,t,n){if(t==="m")throw new TypeError("Private method is not writable");if(t==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof i=="function"?r!==i||!n:!i.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t==="a"?n.call(r,e):n?n.value=e:i.set(r,e),e}function o(r,i,e,t){if(e==="a"&&!t)throw new TypeError("Private accessor was defined without a getter");if(typeof i=="function"?r!==i||!t:!i.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?t:e==="a"?t.call(r):t?t.value:i.get(r)}function de(r){return typeof r=="object"&&r!==null&&("name"in r&&r.name==="AbortError"||"message"in r&&String(r.message).includes("FetchRequestCanceledException"))}var ct=r=>{if(r instanceof Error)return r;if(typeof r=="object"&&r!==null){try{let i=Object.prototype.toString.call(r);if(i==="[object Error]"||i==="[object DOMException]"){let e=new Error(r.message,r.cause?{cause:r.cause}:{});return r.stack&&(e.stack=r.stack),r.cause&&!e.cause&&(e.cause=r.cause),r.name&&(e.name=r.name),e}}catch{}try{return new Error(JSON.stringify(r))}catch{}}return new Error(r)};var S=(()=>{class r extends Error{constructor(e,t){super(e,t),Object.defineProperty(this,"name",{value:new.target._errorName,writable:!0,configurable:!0})}}return r._errorName="AnthropicError",r})(),F=(()=>{class r extends S{constructor(e,t,n,s,a){super(`${r.makeMessage(e,t,n)}`),this.status=e,this.headers=s,this.requestID=s?.get("request-id"),this.workspaceID=s?.get("anthropic-workspace-id"),this.error=t;let l=t??{};this.apiMessage=l.error?.message??null,this.type=a??l.error?.type??null;let p=l.error?.details?.error_code;this.errorCode=typeof p=="string"?p:null,this.details=l.error?.details??null}static makeMessage(e,t,n){let s=t?.message?typeof t.message=="string"?t.message:JSON.stringify(t.message):t?JSON.stringify(t):n;return e&&s?`${e} ${s}`:e?`${e} status code (no body)`:s||"(no status code or body)"}static generate(e,t,n,s){if(!e||!s)return new Le({message:n,cause:ct(t)});let a=t,l=Vh.get(e);return l?new l(e,a,n,s):e>=500?new lt(e,a,n,s):new r(e,a,n,s)}}return r._errorName="APIError",r})(),ee=(()=>{class r extends F{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0)}}return r._errorName="APIUserAbortError",r})(),Le=(()=>{class r extends F{constructor({message:e,cause:t}){super(void 0,void 0,e||"Connection error.",void 0),t&&(this.cause=t)}}return r._errorName="APIConnectionError",r})(),Dt=(()=>{class r extends Le{constructor({message:e}={}){super({message:e??"Request timed out."})}}return r._errorName="APIConnectionTimeoutError",r})(),gl=(()=>{class r extends S{constructor(e,{cause:t}={}){super(e??"Retryable error."),t!==void 0&&(this.cause=t)}}return r._errorName="RetryableError",r})(),R=(()=>{class r extends F{}return r._errorName="BadRequestError",r})(),ka=(()=>{class r extends F{}return r._errorName="AuthenticationError",r})(),G=(()=>{class r extends F{}return r._errorName="PermissionDeniedError",r})(),Re=(()=>{class r extends F{}return r._errorName="NotFoundError",r})(),Ea=(()=>{class r extends F{}return r._errorName="RequestTimeoutError",r})(),le=(()=>{class r extends F{}return r._errorName="ConflictError",r})(),Vt=(()=>{class r extends F{}return r._errorName="PreconditionFailedError",r})(),Gt=(()=>{class r extends F{}return r._errorName="ContentTooLargeError",r})(),Sa=(()=>{class r extends F{}return r._errorName="UnprocessableEntityError",r})(),At=(()=>{class r extends F{}return r._errorName="RateLimitError",r})(),Aa=(()=>{class r extends F{}return r._errorName="RequestHeaderFieldsTooLargeError",r})(),xa=(()=>{class r extends F{}return r._errorName="ClientClosedRequestError",r})(),lt=(()=>{class r extends F{}return r._errorName="InternalServerError",r})(),Pa=(()=>{class r extends lt{}return r._errorName="NotImplementedError",r})(),Qe=(()=>{class r extends lt{}return r._errorName="ServiceUnavailableError",r})(),Ta=(()=>{class r extends lt{}return r._errorName="GatewayTimeoutError",r})(),Jt=(()=>{class r extends lt{}return r._errorName="OverloadedError",r})(),Vh=new Map([[400,R],[401,ka],[403,G],[404,Re],[408,Ea],[409,le],[412,Vt],[413,Gt],[422,Sa],[429,At],[431,Aa],[499,xa],[501,Pa],[503,Qe],[504,Ta],[529,Jt]]);var Jh=/^[a-z][a-z0-9+.-]*:/i,Gu=r=>Jh.test(r),ue=r=>(ue=Array.isArray,ue(r)),En=ue;function Yt(r){return typeof r!="object"?{}:r??{}}function bl(r){if(!r)return!0;for(let i in r)return!1;return!0}function Ju(r,i){return Object.prototype.hasOwnProperty.call(r,i)}function J(r){return r!=null&&typeof r=="object"&&!Array.isArray(r)}var Ra=(r,i)=>{if(typeof i!="number"||!Number.isInteger(i))throw new S(`${r} must be an integer`);if(i<0)throw new S(`${r} must be a positive integer`);return i},xt=["apiKey","authToken","credentials","config","profile"];var Pt=r=>{try{return JSON.parse(r)}catch{return}};var Oe=(r,i)=>new Promise(e=>{if(i?.aborted)return e();let t=()=>{clearTimeout(n),e()},n=setTimeout(()=>{i?.removeEventListener("abort",t),e()},r);i?.addEventListener("abort",t,{once:!0})});var we="1.7.0";var Zu=()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u";function Yh(){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 Qh=()=>{let r=Yh();if(r==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":we,"X-Stainless-OS":Qu(Deno.build.os),"X-Stainless-Arch":Yu(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":we,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process?.version??"unknown"};if(r==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":we,"X-Stainless-OS":Qu(globalThis.process.platform??"unknown"),"X-Stainless-Arch":Yu(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let i=Xh();return i?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":we,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${i.browser}`,"X-Stainless-Runtime-Version":i.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":we,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function Xh(){if(typeof navigator>"u"||!navigator)return null;let r=[{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:i,pattern:e}of r){let t=e.exec(navigator.userAgent);if(t){let n=t[1]||0,s=t[2]||0,a=t[3]||0;return{browser:i,version:`${n}.${s}.${a}`}}}return null}var Yu=r=>r==="x32"?"x32":r==="x86_64"||r==="x64"?"x64":r==="arm"?"arm":r==="aarch64"||r==="arm64"?"arm64":r?`other:${r}`:"unknown",Qu=r=>(r=r.toLowerCase(),r.includes("ios")?"iOS":r==="android"?"Android":r==="darwin"?"MacOS":r==="win32"?"Windows":r==="freebsd"?"FreeBSD":r==="openbsd"?"OpenBSD":r==="linux"?"Linux":r?`Other:${r}`:"Unknown"),Xu,Sn=()=>Xu??(Xu=Qh());var Ca=new WeakMap,ed=typeof globalThis.FinalizationRegistry=="function"?new globalThis.FinalizationRegistry(r=>$e(r)):null;function Zh(r,i){return()=>r.removeEventListener("abort",i)}function td(r,i,e){Ca.set(r,Zh(i,e))}function rd(r,i){Ca.has(i)&&ed?.register(r,i,i)}function $e(r){let i=Ca.get(r);i&&(Ca.delete(r),ed?.unregister(r),i())}function nd(){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 yl(...r){let i=globalThis.ReadableStream;if(typeof i>"u")throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new i(...r)}function Ia(r){let i=Symbol.asyncIterator in r?r[Symbol.asyncIterator]():r[Symbol.iterator]();return yl({start(){},async pull(e){let{done:t,value:n}=await i.next();t?e.close():e.enqueue(n)},async cancel(){await i.return?.()}})}function e_(r){if(r[Symbol.asyncIterator])return r[Symbol.asyncIterator]();let i=r.getReader();return{async next(){try{let e=await i.read();return e?.done&&i.releaseLock(),e}catch(e){throw i.releaseLock(),e}},async return(){let e=i.cancel();return i.releaseLock(),await e,{done:!0,value:void 0}}}}var id=typeof FinalizationRegistry>"u"?void 0:new FinalizationRegistry(async r=>{try{await r.return?.()}catch{}});async function*An(r){let i=e_(r),e={};id?.register(e,i,e);try{for await(let t of{[Symbol.asyncIterator]:()=>i})yield t}finally{id?.unregister(e)}}async function za(r){if(r===null||typeof r!="object")return;if(r[Symbol.asyncIterator]){await r[Symbol.asyncIterator]().return?.();return}let i=r.getReader(),e=i.cancel();i.releaseLock(),await e}var Oa=class{},sd=({headers:r,body:i})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(i)});function cd(r){let i=0;for(let n of r)i+=n.length;let e=new Uint8Array(i),t=0;for(let n of r)e.set(n,t),t+=n.length;return e}var ad;function xn(r){let i;return(ad??(i=new globalThis.TextEncoder,ad=i.encode.bind(i)))(r)}var od;function Pn(r){let i;return(od??(i=new globalThis.TextDecoder,od=i.decode.bind(i)))(r)}var ve,ke,Na=(()=>{class r{constructor(){ve.set(this,void 0),ke.set(this,void 0),b(this,ve,new Uint8Array,"f"),b(this,ke,null,"f")}decode(e){if(e==null)return[];let t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e=="string"?xn(e):e;b(this,ve,cd([o(this,ve,"f"),t]),"f");let n=[],s;for(;(s=i_(o(this,ve,"f"),o(this,ke,"f")))!=null;){if(s.carriage&&o(this,ke,"f")==null){b(this,ke,s.index,"f");continue}if(o(this,ke,"f")!=null&&(s.index!==o(this,ke,"f")+1||s.carriage)){n.push(Pn(o(this,ve,"f").subarray(0,o(this,ke,"f")-1))),b(this,ve,o(this,ve,"f").subarray(o(this,ke,"f")),"f"),b(this,ke,null,"f");continue}let a=o(this,ke,"f")!==null?s.preceding-1:s.preceding,l=Pn(o(this,ve,"f").subarray(0,a));n.push(l),b(this,ve,o(this,ve,"f").subarray(s.index),"f"),b(this,ke,null,"f")}return n}flush(){return o(this,ve,"f").length?this.decode(`
2
- `):[]}}return ve=new WeakMap,ke=new WeakMap,r.NEWLINE_CHARS=new Set([`
3
- `,"\r"]),r.NEWLINE_REGEXP=/\r\n|[\n\r]/g,r})();function i_(r,i){for(let n=i??0;n<r.length;n++){if(r[n]===10)return{preceding:n,index:n+1,carriage:!1};if(r[n]===13)return{preceding:n,index:n+1,carriage:!0}}return null}var z=r=>{if(typeof globalThis.process<"u")return globalThis.process.env?.[r]?.trim()||void 0;if(typeof globalThis.Deno<"u")return globalThis.Deno.env?.get?.(r)?.trim()||void 0};var Tn="warn",qa={off:0,error:200,warn:300,info:400,debug:500},Ba=(r,i,e)=>{if(r){if(Ju(qa,r))return r;e.warn(`${i} was set to ${JSON.stringify(r)}, expected one of ${JSON.stringify(Object.keys(qa))}`)}};function Qt(){}function Ma(r,i,e){return!i||qa[r]>qa[e]?Qt:i[r].bind(i)}var n_={error:Qt,warn:Qt,info:Qt,debug:Qt},ld=new WeakMap;function vl(r,i){let e=ld.get(r);if(e&&e[0]===i)return e[1];let t={error:Ma("error",r,i),warn:Ma("warn",r,i),info:Ma("info",r,i),debug:Ma("debug",r,i)};return ld.set(r,[i,t]),t}function I(r){let i=r.logger,e=r.logLevel??"off";return i?vl(i,e):n_}var ud,wl;function La(){let r=z("ANTHROPIC_LOG");return(!wl||r!==ud)&&(ud=r,wl=vl(console,Ba(r,"process.env['ANTHROPIC_LOG']",vl(console,Tn))??Tn)),wl}function Fe(r,i,e){r.debug!==Qt&&r.debug(i,s_(e))}var s_=r=>(r.options&&(r.options={...r.options},delete r.options.headers,delete r.options.__span),r.headers&&(r.headers=Object.fromEntries((r.headers instanceof Headers?[...r.headers]:Object.entries(r.headers)).map(([i,e])=>[i,i.toLowerCase()==="authorization"||i.toLowerCase()==="proxy-authorization"||i.toLowerCase()==="api-key"||i.toLowerCase()==="x-api-key"||i.toLowerCase()==="x-amz-security-token"||i.toLowerCase()==="cookie"||i.toLowerCase()==="set-cookie"?"***":e]))),"retryOfRequestLogID"in r&&(r.retryOfRequestLogID&&(r.retryOf=r.retryOfRequestLogID),delete r.retryOfRequestLogID),r);var Rn,re=(()=>{class r{constructor(e,t,n){this.iterator=e,Rn.set(this,void 0),this.controller=t,b(this,Rn,n,"f")}static rawEvents(e,t=new AbortController){return dd(e,t)}static fromSSEResponse(e,t,n){let s=!1,a=n?I(n):console;async function*l(){if(s)throw new S("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");s=!0;let p=!1;try{for await(let h of dd(e,t))if(h.event!=="ping"&&h.event!==null)if(h.event==="error"){let m=Pt(h.data)??h.data,_=m?.error?.type;throw new F(void 0,m,void 0,e.headers,_)}else{if(!h.data)continue;try{yield JSON.parse(h.data)}catch(m){throw a.error("Could not parse message into JSON:",h.data),a.error("From chunk:",h.raw),m}}p=!0}catch(h){if(de(h))return;throw h}finally{p||t.abort(),$e(t)}}return new r(l,t,n)}static fromReadableStream(e,t,n){let s=!1;async function*a(){let p=new Na,h=An(e);for await(let m of h)for(let _ of p.decode(m))yield _;for(let m of p.flush())yield m}async function*l(){if(s)throw new S("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");s=!0;let p=!1;try{for await(let h of a())p||h&&(yield JSON.parse(h));p=!0}catch(h){if(de(h))return;throw h}finally{p||t.abort(),$e(t)}}return new r(l,t,n)}[(Rn=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let e=[],t=[],n=this[Symbol.asyncIterator](),s=a=>({next:()=>{if(a.length===0){let l=n.next();e.push(l),t.push(l)}return a.shift()}});return[new r(()=>s(e),this.controller,o(this,Rn,"f")),new r(()=>s(t),this.controller,o(this,Rn,"f"))]}toReadableStream(){let e=this,t;return yl({async start(){t=e[Symbol.asyncIterator]()},async pull(n){try{let{value:s,done:a}=await t.next();if(a)return n.close();let l=xn(JSON.stringify(s)+`
4
- `);n.enqueue(l)}catch(s){n.error(s)}},async cancel(){await t.return?.()}})}}return r})();async function*dd(r,i){if(!r.body)throw i.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new S("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 S("Attempted to iterate over a response with no body");let e=new TextDecoder("utf-8",{ignoreBOM:!0}),t="",n=null,s=[],a=[],l=p=>{if(p.charCodeAt(0)===65279&&(p=p.slice(1)),!p){if(!n&&!s.length)return null;let g={event:n,data:s.join(`
5
- `),raw:a};return n=null,s=[],a=[],g}a.push(p);let h=p.indexOf(":");if(h===0)return null;let m=h===-1?p:p.slice(0,h);if(m!=="event"&&m!=="data")return null;let _=h===-1?"":p.slice(p.charCodeAt(h+1)===32?h+2:h+1);return m==="event"?n=_:s.push(_),null};for await(let p of An(r.body)){if(p==null)continue;t+=e.decode(typeof p=="string"?xn(p):p,{stream:!0});let h=0;if(t.includes("\r"))for(let m=0;m<t.length;m++){let _=t[m];if(_!==`
6
- `&&_!=="\r")continue;if(_==="\r"&&m+1===t.length)break;let g=l(t.slice(h,m));_==="\r"&&t[m+1]===`
7
- `&&m++,h=m+1,g&&(yield g)}else{let m;for(;(m=t.indexOf(`
8
- `,h))!==-1;){let _=l(t.slice(h,m));h=m+1,_&&(yield _)}}t=t.slice(h)}if(t+=e.decode(),t)for(let p of t.replace(/\r$/,"").split(/\r\n|[\n\r]/)){let h=l(p);h&&(yield h)}}var pd=Symbol.for("brand.privateNullableHeaders");function*a_(r){if(!r)return;if(pd in r){let{values:t,nulls:n}=r;yield*t.entries();for(let s of n)yield[s,null];return}let i=!1,e;r instanceof Headers?e=r.entries():En(r)?e=r:(i=!0,e=Object.entries(r??{}));for(let t of e){let n=t[0];if(typeof n!="string")throw new TypeError("expected header name to be a string");let s=En(t[1])?t[1]:[t[1]],a=!1;for(let l of s)l!==void 0&&(i&&!a&&(a=!0,yield[n,$a]),yield[n,l])}}var $a=Symbol("clear"),o_=new Set(["x-stainless-helper"]),Cn=(r,i)=>{let e=r?r.split(",").map(t=>t.trim()).filter(Boolean):[];for(let t of i.split(",").map(n=>n.trim()))t&&!e.includes(t)&&e.push(t);return e.join(", ")},d=r=>{let i=new Headers,e=new Set;for(let t of r){let n=new Set;for(let[s,a]of a_(t)){let l=s.toLowerCase();if(o_.has(l)){if(a===$a)continue;a===null?(i.delete(s),e.add(l)):(i.set(s,Cn(i.get(s),a)),e.delete(l));continue}(a===$a||!n.has(l))&&(i.delete(s),n.add(l),a===$a)||(a===null?(i.delete(s),e.add(l)):(i.append(s,a),e.delete(l)))}}return{[pd]:!0,values:i,nulls:e}};var hd="com.anthropic.sdk.typescript",c_="error.type",In="gen_ai.conversation.id",Tt="gen_ai.provider.name",l_="http.request.method",u_="http.request.resend_count",Fa="http.response.status_code",d_="http.route",p_="server.address",h_="server.port",__="url.full",f_="url.path",m_="url.query",g_="url.scheme",b_="anthropic.session.thread.id",y_=75e4;function _d(r){let{tracerProvider:i,propagation:e,traces:t}=r===!1?{traces:!1}:r??w_(),{enabled:n,contentMode:s,maxContentBytes:a}=typeof t=="boolean"?{enabled:t}:t??{};return Object.freeze({tracerProvider:i,propagation:e??!0,traces:Object.freeze({enabled:n??!0,contentMode:s==="content"?"content":"metadata_only",maxContentBytes:a!==void 0&&Number.isInteger(a)&&a>=1?a:y_})})}function w_(){return{propagation:z("ANTHROPIC_OPEN_TELEMETRY_PROPAGATION")?.toLowerCase()!=="false",traces:{enabled:z("ANTHROPIC_OPEN_TELEMETRY")?.toLowerCase()!=="false",contentMode:z("ANTHROPIC_OPEN_TELEMETRY_TRACES_CONTENT_MODE")?.toLowerCase()==="content"?"content":"metadata_only",maxContentBytes:Number(/^\d+$/.exec(z("ANTHROPIC_OPEN_TELEMETRY_TRACES_MAX_CONTENT_BYTES")??"")?.[0]??NaN)}}}function fd(r,i,e){if(!r.traces.enabled)return;let t=e!==void 0?`${hd}.${e}`:hd;return(r.tracerProvider??Te.getTracerProvider()).getTracer(t,i)}function M(r,i){try{return i()}catch(e){r&&I(r).debug("could not record telemetry",e);return}}function c(r,i,e,t){if(e?.__span)return e.__span;let n=r._tracer;if(n)return M(r,()=>{let s=Date.now(),a=t?.attributes?.[b_],l=e?.openTelemetry?.conversationId??(typeof a=="string"?a:void 0),p=n.startSpan(i,{kind:St.CLIENT,attributes:{[Tt]:r._genAIProviderName,...E_(r.baseURL),...l!=null?{[In]:l}:void 0,...t?.route!=null?{[d_]:t.route}:void 0,...v_(r,i,t?.request),...t?.attributes}});if(!p.isRecording()&&!(r.openTelemetry.propagation?Object.keys(vd(p)).length>0:Te.isSpanContextValid(p.spanContext())))return;let{request:h,...m}=t??{};return{...m,span:p,name:i,startTime:s}})}function md(r,i){if(r.createdIDAttribute===void 0||typeof i!="object"||i===null)return;let e=i[r.createdIDField??"id"];typeof e=="string"&&r.span.setAttribute(r.createdIDAttribute,e)}var Ua={"anthropic.messages.create":{constants:{"gen_ai.operation.name":"chat"},request:[["gen_ai.request.model",["model"],"string"],["gen_ai.request.max_tokens",["max_tokens"],"integer"],["gen_ai.request.reasoning.level",["output_config","effort"],"string"],["anthropic.request.service_tier",["service_tier"],"string"],["anthropic.thinking.type",["thinking","type"],"string"],["anthropic.thinking.budget_tokens",["thinking","budget_tokens"],"integer"]],requestHeaders:[["anthropic.beta","anthropic-beta",{array:"string"}]],stream:"gen_ai.request.stream",response:[["gen_ai.response.id",["id"],"string"],["gen_ai.response.model",["model"],"string"],["gen_ai.usage.cache_write.input_tokens",["usage","cache_creation_input_tokens"],"integer"],["gen_ai.usage.cache_read.input_tokens",["usage","cache_read_input_tokens"],"integer"],["anthropic.usage.cache_creation.ephemeral_5m_input_tokens",["usage","cache_creation","ephemeral_5m_input_tokens"],"integer"],["anthropic.usage.cache_creation.ephemeral_1h_input_tokens",["usage","cache_creation","ephemeral_1h_input_tokens"],"integer"],["anthropic.response.service_tier",["usage","service_tier"],"string"],["gen_ai.usage.output_tokens",["usage","output_tokens"],"integer"],["gen_ai.usage.reasoning.output_tokens",["usage","output_tokens_details","thinking_tokens"],"integer"],["anthropic.message.stop_reason",["stop_reason"],"string"]]},"anthropic.messages.count_tokens":{request:[["gen_ai.request.model",["model"],"string"]],response:[["anthropic.message.count_tokens.input_tokens",["input_tokens"],"integer"]]},"anthropic.sessions.create":{request:[["anthropic.session.environment.id",["environment_id"],"string"]],response:[["gen_ai.agent.name",["agent","name"],"string"],["gen_ai.request.model",["agent","model","id"],"string"]]}};function v_(r,i,e){let t=Ua[i];if(!t)return{};let n={...t.constants};for(let[a,l,p]of t.request??[]){let h=M(r,()=>El(gd(e?.body,l),p));h!==void 0&&(n[a]=h)}let{requestHeaders:s}=t;return s&&M(r,()=>{let a=d([r._options.defaultHeaders,e?.headers]).values;for(let[l,p,h]of s){let m=k_(a.get(p),h);m!==void 0&&(n[l]=m)}}),t.stream!==void 0&&e?.stream&&(n[t.stream]=!0),n}function kl(r,i,e){for(let[t,n,s]of Ua[i]?.response??[])try{let a=El(gd(e,n),s);a!==void 0&&r.setAttribute(t,a)}catch{}}function gd(r,i){let e=r;for(let t of i){if(typeof e!="object"||e===null)return;e=e[t]}return e}function El(r,i){if(typeof i=="object")return Array.isArray(r)&&r.every(e=>El(e,i.array)!==void 0)?[...r]:void 0;switch(typeof r){case"string":return i==="string"||i==="unknown"?r:void 0;case"boolean":return i==="boolean"||i==="unknown"?r:void 0;case"number":return i==="integer"||i==="number"||i==="unknown"?r:void 0;default:return}}function k_(r,i){let e=(r??"").split(",").map(t=>t.trim()).filter(Boolean);if(!(r==null||e.length===0))return typeof i=="object"?e:r}function E_(r){try{let{hostname:i,port:e,protocol:t}=new URL(r);return{[p_]:i.replace(/^\[(.*)\]$/,"$1"),[h_]:e?Number(e):t==="http:"?80:443}}catch{return{}}}function bd(r,i,e,t=!1){if(r.attempts=(r.attempts??0)+1,r.attempts>1){r.span.setAttribute(u_,r.attempts-1);return}r.span.setAttribute(l_,i);try{let{protocol:n,host:s,pathname:a,search:l}=new URL(e),p=A_(l.slice(1),r.queryParams,r.contentQueryParams);if(r.span.setAttributes({[g_]:n.slice(0,-1),[f_]:a}),p?.content&&!t)return;r.span.setAttributes({...p!==void 0?{[m_]:p.value}:void 0,[__]:`${n}//${s}${a}${p!==void 0?`?${p.value}`:""}`})}catch{}}var S_=["email","path_prefix","expected_content_sha256"];function A_(r,i,e){if(!r||!i?.length)return;let t=!1,n=r.split("&").filter(s=>{try{let a=decodeURIComponent(s.split("=",1)[0]),l=i.includes(a)||!a.endsWith("[]")?a:a.slice(0,-2);return i.includes(l)?(t||(t=S_.includes(l)||!!e?.includes(l)),!0):!1}catch{return!1}});return n.length?{value:n.join("&"),content:t}:void 0}function yd(r,i){let e=d([i]).values;for(let[t,n]of Object.entries(vd(r)))e.set(t,n);return e}function ut(r,i){if(r.isRecording())try{switch(x_(r,i),Ha(r,i.response??(i.status==="error"&&i.error instanceof F?i.error:void 0)),i.status){case"success":i.options.__span&&kl(r,i.options.__span.name,i.data),r.setStatus({code:Pe.OK});break;case"error":Ce(r,i.error);break}}finally{r.end()}}function Sl(r,i,e){let t=r[Symbol.asyncIterator],n=!1,s=p=>{if(!n){n=!0,i.removeEventListener("abort",a);try{e.onEnd(p)}catch{}}},a=()=>s({reason:"canceled"});if(i.aborted)return a();i.addEventListener("abort",a,{once:!0});let l=!1;r[Symbol.asyncIterator]=function(){let p=t.call(this);if(l)return p;l=!0,i.removeEventListener("abort",a);let h={async next(){let m;try{m=await p.next()}catch(_){throw s({reason:"failed",error:_}),_}if(m.done)s({reason:i.aborted?"canceled":"completed"});else if(!n)try{e.onItem?.(m.value)}catch{}return m},async return(m){return a(),await p.return?.(m)??{done:!0,value:m}},async throw(m){if(a(),p.throw)return p.throw(m);throw m},[Symbol.asyncIterator]:()=>h};return h}}function wd(r,i,e){if(!r.isRecording())return;r.setAttribute(Fa,e.response.status),Ha(r,e.response);let t=i instanceof re;Sl(i,e.controller.signal,{onEnd(n){n.reason==="failed"?Ce(r,n.error):n.reason==="completed"&&!t&&r.setStatus({code:Pe.OK}),r.end()}})}function x_(r,i){let e=i.response?.status??(i.status==="error"&&i.error instanceof F?i.error.status:void 0);e!==void 0&&r.setAttribute(Fa,e)}var P_=[["anthropic.request.id","request-id"],["anthropic.organization.id","anthropic-organization-id"],["anthropic.workspace.id","anthropic-workspace-id"]];function Ha(r,i){let e;try{e=i?.headers}catch{return}for(let[t,n]of P_)try{let s=e?.get(n);s&&r.setAttribute(t,s)}catch{}}function Ce(r,i,e){i instanceof ee||de(i)||(r.setStatus({code:Pe.ERROR}),r.setAttribute(c_,e??T_(i)))}function vd(r){let i={};return va.inject(Te.setSpan(Q.active(),r),i),i}function T_(r){if(r instanceof Dt)return"client_timeout_error";if(r instanceof Le)return"connection_error";if(r instanceof F){if(r.type)return r.type;if(r.status!==void 0)return String(r.status)}return"client_error"}var Al="RFC3986",xl=r=>String(r),Pl={RFC1738:r=>String(r).replace(/%20/g,"+"),RFC3986:xl},kd="RFC1738";var Wa=(r,i)=>(Wa=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),Wa(r,i)),Ue=(()=>{let r=[];for(let i=0;i<256;++i)r.push("%"+((i<16?"0":"")+i.toString(16)).toUpperCase());return r})();var Tl=1024,Ed=(r,i,e,t,n)=>{if(r.length===0)return r;let s=r;if(typeof r=="symbol"?s=Symbol.prototype.toString.call(r):typeof r!="string"&&(s=String(r)),e==="iso-8859-1")return escape(s).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<s.length;l+=Tl){let p=s.length>=Tl?s.slice(l,l+Tl):s,h=[];for(let m=0;m<p.length;++m){let _=p.charCodeAt(m);if(_===45||_===46||_===95||_===126||_>=48&&_<=57||_>=65&&_<=90||_>=97&&_<=122||n===kd&&(_===40||_===41)){h[h.length]=p.charAt(m);continue}if(_<128){h[h.length]=Ue[_];continue}if(_<2048){h[h.length]=Ue[192|_>>6]+Ue[128|_&63];continue}if(_<55296||_>=57344){h[h.length]=Ue[224|_>>12]+Ue[128|_>>6&63]+Ue[128|_&63];continue}m+=1,_=65536+((_&1023)<<10|p.charCodeAt(m)&1023),h[h.length]=Ue[240|_>>18]+Ue[128|_>>12&63]+Ue[128|_>>6&63]+Ue[128|_&63]}a+=h.join("")}return a};function Sd(r){return!r||typeof r!="object"?!1:!!(r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer(r))}function Rl(r,i){if(ue(r)){let e=[];for(let t=0;t<r.length;t+=1)e.push(i(r[t]));return e}return i(r)}var xd={brackets(r){return String(r)+"[]"},comma:"comma",indices(r,i){return String(r)+"["+i+"]"},repeat(r){return String(r)}},Pd=function(r,i){Array.prototype.push.apply(r,ue(i)?i:[i])},Ad,te={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:Ed,encodeValuesOnly:!1,format:Al,formatter:xl,indices:!1,serializeDate(r){return(Ad??(Ad=Function.prototype.call.bind(Date.prototype.toISOString)))(r)},skipNulls:!1,strictNullHandling:!1};function R_(r){return typeof r=="string"||typeof r=="number"||typeof r=="boolean"||typeof r=="symbol"||typeof r=="bigint"}var Cl={};function Td(r,i,e,t,n,s,a,l,p,h,m,_,g,y,v,k,E,T){let x=r,C=T,P=0,A=!1;for(;(C=C.get(Cl))!==void 0&&!A;){let H=C.get(r);if(P+=1,typeof H<"u"){if(H===P)throw new RangeError("Cyclic object value");A=!0}typeof C.get(Cl)>"u"&&(P=0)}if(typeof h=="function"?x=h(i,x):x instanceof Date?x=g?.(x):e==="comma"&&ue(x)&&(x=Rl(x,function(H){return H instanceof Date?g?.(H):H})),x===null){if(s)return p&&!k?p(i,te.encoder,E,"key",y):i;x=""}if(R_(x)||Sd(x)){if(p){let H=k?i:p(i,te.encoder,E,"key",y);return[v?.(H)+"="+v?.(p(x,te.encoder,E,"value",y))]}return[v?.(i)+"="+v?.(String(x))]}let O=[];if(typeof x>"u")return O;let B;if(e==="comma"&&ue(x))k&&p&&(x=Rl(x,p)),B=[{value:x.length>0?x.join(",")||null:void 0}];else if(ue(h))B=h;else{let H=Object.keys(x);B=m?H.sort(m):H}let L=l?String(i).replace(/\./g,"%2E"):String(i),$=t&&ue(x)&&x.length===1?L+"[]":L;if(n&&ue(x)&&x.length===0)return $+"[]";for(let H=0;H<B.length;++H){let ae=B[H],oe=typeof ae=="object"&&typeof ae.value<"u"?ae.value:x[ae];if(a&&oe===null)continue;let Ye=_&&l?ae.replace(/\./g,"%2E"):ae,ya=ue(x)?typeof e=="function"?e($,Ye):$:$+(_?"."+Ye:"["+Ye+"]");T.set(r,P);let Kt=new WeakMap;Kt.set(Cl,T),Pd(O,Td(oe,ya,e,t,n,s,a,l,e==="comma"&&k&&ue(x)?null:p,h,m,_,g,y,v,k,E,Kt))}return O}function C_(r=te){if(typeof r.allowEmptyArrays<"u"&&typeof r.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof r.encodeDotInKeys<"u"&&typeof r.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(r.encoder!==null&&typeof r.encoder<"u"&&typeof r.encoder!="function")throw new TypeError("Encoder has to be a function.");let i=r.charset||te.charset;if(typeof r.charset<"u"&&r.charset!=="utf-8"&&r.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let e=Al;if(typeof r.format<"u"){if(!Wa(Pl,r.format))throw new TypeError("Unknown format option provided.");e=r.format}let t=Pl[e],n=te.filter;(typeof r.filter=="function"||ue(r.filter))&&(n=r.filter);let s;if(r.arrayFormat&&r.arrayFormat in xd?s=r.arrayFormat:"indices"in r?s=r.indices?"indices":"repeat":s=te.arrayFormat,"commaRoundTrip"in r&&typeof r.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");let a=typeof r.allowDots>"u"?r.encodeDotInKeys?!0:te.allowDots:!!r.allowDots;return{addQueryPrefix:typeof r.addQueryPrefix=="boolean"?r.addQueryPrefix:te.addQueryPrefix,allowDots:a,allowEmptyArrays:typeof r.allowEmptyArrays=="boolean"?!!r.allowEmptyArrays:te.allowEmptyArrays,arrayFormat:s,charset:i,charsetSentinel:typeof r.charsetSentinel=="boolean"?r.charsetSentinel:te.charsetSentinel,commaRoundTrip:!!r.commaRoundTrip,delimiter:typeof r.delimiter>"u"?te.delimiter:r.delimiter,encode:typeof r.encode=="boolean"?r.encode:te.encode,encodeDotInKeys:typeof r.encodeDotInKeys=="boolean"?r.encodeDotInKeys:te.encodeDotInKeys,encoder:typeof r.encoder=="function"?r.encoder:te.encoder,encodeValuesOnly:typeof r.encodeValuesOnly=="boolean"?r.encodeValuesOnly:te.encodeValuesOnly,filter:n,format:e,formatter:t,serializeDate:typeof r.serializeDate=="function"?r.serializeDate:te.serializeDate,skipNulls:typeof r.skipNulls=="boolean"?r.skipNulls:te.skipNulls,sort:typeof r.sort=="function"?r.sort:null,strictNullHandling:typeof r.strictNullHandling=="boolean"?r.strictNullHandling:te.strictNullHandling}}function Rd(r,i={}){let e=r,t=C_(i),n,s;typeof t.filter=="function"?(s=t.filter,e=s("",e)):ue(t.filter)&&(s=t.filter,n=s);let a=[];if(typeof e!="object"||e===null)return"";let l=xd[t.arrayFormat],p=l==="comma"&&t.commaRoundTrip;n||(n=Object.keys(e)),t.sort&&n.sort(t.sort);let h=new WeakMap;for(let g=0;g<n.length;++g){let y=n[g];t.skipNulls&&e[y]===null||Pd(a,Td(e[y],y,l,p,t.allowEmptyArrays,t.strictNullHandling,t.skipNulls,t.encodeDotInKeys,t.encode?t.encoder:null,t.filter,t.sort,t.allowDots,t.serializeDate,t.format,t.formatter,t.encodeValuesOnly,t.charset,h))}let m=a.join(t.delimiter),_=t.addQueryPrefix===!0?"?":"";return t.charsetSentinel&&(t.charset==="iso-8859-1"?_+="utf8=%26%2310003%3B&":_+="utf8=%E2%9C%93&"),m.length>0?_+m:""}function Cd(r){return Rd(r,{arrayFormat:"brackets"})}var f=class{constructor(i){this._client=i}};async function ja(r,i){let{response:e,requestLogID:t,retryOfRequestLogID:n,startTime:s}=i,a=await(async()=>{if(i.options.stream)return I(r).debug("response",e.status,e.url,e.headers,e.body),re.fromSSEResponse(e,i.controller,r);if(e.status===204)return null;if(i.options.__binaryResponse)return e;let p=e.headers.get("content-type")?.split(";")[0]?.trim();if(p?.includes("application/json")||p?.endsWith("+json")){if(e.headers.get("content-length")==="0")return;let g=await e.json();return Rt(g,e)}return await e.text()})().finally(()=>{!i.options.stream&&!i.options.__binaryResponse&&$e(i.controller)});return Fe(I(r),`[${t}] response parsed`,{retryOfRequestLogID:n,url:e.url,status:e.status,body:a,durationMs:Date.now()-s}),a}function Rt(r,i){return!r||typeof r!="object"||Array.isArray(r)?r:Object.defineProperties(r,{_request_id:{value:i.headers.get("request-id"),enumerable:!1},_workspace_id:{value:i.headers.get("anthropic-workspace-id"),enumerable:!1}})}var zl=()=>{if(typeof File>"u"){let{process:r}=globalThis,i=typeof r?.versions?.node=="string"&&parseInt(r.versions.node.split("."))<20;throw new Error("`File` is not defined as a global, which is required for file uploads."+(i?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function Ct(r,i,e){return zl(),new File(r,i??"",e)}function zn(r,i){let e=typeof r=="object"&&r!==null&&("name"in r&&r.name&&String(r.name)||"url"in r&&r.url&&String(r.url)||"filename"in r&&r.filename&&String(r.filename)||"path"in r&&r.path&&String(r.path))||"";return i?e.split(/[\\/]/).pop()||void 0:e}var On=r=>r!=null&&typeof r=="object"&&typeof r[Symbol.asyncIterator]=="function";var ie=async(r,i,e=!0)=>{try{return{...r,body:await O_(r.body,i,e)}}catch(t){let n=r.__span?.span;throw n&&M(typeof i=="function"?void 0:i,()=>ut(n,{status:"error",options:r,error:t})),t}},Id=new WeakMap;function z_(r){let i=typeof r=="function"?r:r.fetch,e=Id.get(i);if(e)return e;let t=(async()=>{try{let n="Response"in i?i.Response:(await i("data:,")).constructor,s=new FormData;return s.toString()!==await new n(s).text()}catch{return!0}})();return Id.set(i,t),t}var O_=async(r,i,e=!0)=>{if(!await z_(i))throw new TypeError("The provided fetch function does not support file uploads with the current global FormData class.");let t=new FormData;return await Promise.all(Object.entries(r||{}).map(([n,s])=>Il(t,n,s,e))),t};var Il=async(r,i,e,t)=>{if(e!==void 0){if(e==null)throw new TypeError(`Received null for "${i}"; to pass null in FormData, you must use the string 'null'`);if(typeof e=="string"||typeof e=="number"||typeof e=="boolean")r.append(i,String(e));else if(e instanceof Response){let n={},s=e.headers.get("Content-Type");s&&(n={type:s}),r.append(i,Ct([await e.blob()],zn(e,t),n))}else if(On(e))r.append(i,Ct([await new Response(Ia(e)).blob()],zn(e,t)));else if(e instanceof Blob){let s=typeof File<"u"&&e instanceof File?e.name:zn(e,t);r.append(i,Ct([e],s,{type:e.type}))}else if(Array.isArray(e))await Promise.all(e.map(n=>Il(r,i+"[]",n,t)));else{if(typeof e.then=="function")throw new TypeError(`Received a Promise for "${i}"; await it first, e.g. \`await toFile(...)\``);if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))throw new TypeError(`Received ${e.constructor.name} for "${i}"; to upload raw bytes, wrap them with \`await toFile(bytes, 'filename')\``);if(typeof e=="object")await Promise.all(Object.entries(e).map(([n,s])=>Il(r,`${i}[${n}]`,s,t)));else throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${e} instead`)}}};var zd="gen_ai.agent.id",Xt="gen_ai.input.messages",Ol="gen_ai.operation.name",It="gen_ai.output.messages",Ka="gen_ai.output.type",Od="gen_ai.request.model",Da="gen_ai.request.stop_sequences",Nd="gen_ai.response.time_to_first_chunk",Zt="gen_ai.system_instructions",Md="gen_ai.tool.call.arguments",qd="gen_ai.tool.call.id",Bd="gen_ai.tool.description",Ld="gen_ai.tool.name",$d="gen_ai.tool.type",Fd="gen_ai.usage.input_tokens",Ud="execute_tool",Hd="invoke_agent",Va="json",Wd="function",jd="anthropic.content.truncated",Nn="anthropic.tool_result.content",Kd="anthropic.toolset.name",Dd="anthropic.usage.compaction.input_tokens",Vd="anthropic.usage.compaction.output_tokens";function qn(r,i,e,t){let n=r.span,s=r.requestContentSize;if(e!==void 0&&s!==void 0){let l=JSON.stringify([{role:"assistant",parts:Ga(e)}]);if(s+3*l.length<=t||s+Ja(l)<=t){n.setAttribute(It,l);return}}let a=ql(n,{[Da]:i.stop_sequences?.length?[...i.stop_sequences]:void 0,[Zt]:i.system===void 0?void 0:Ga(i.system),[Xt]:i.messages.map(l=>({role:l.role,parts:Ga(l.content)})),[It]:e===void 0?void 0:[{role:"assistant",parts:Ga(e)}]},t);e===void 0&&(r.requestContentSize=a)}function Ga(r){return typeof r=="string"?[{type:"text",content:r}]:r?.map(N_)??[]}function N_(r){switch(r.type){case"text":return{type:"text",content:r.text};case"thinking":return{type:"reasoning",content:r.thinking};case"tool_use":return{type:"tool_call",id:r.id,name:r.name,arguments:r.input,...typeof r.toolset_name=="string"?{anthropic_toolset_name:r.toolset_name}:void 0};case"server_tool_use":return{type:"tool_call",id:r.id,name:r.name,arguments:r.input};case"mcp_tool_use":return{type:"tool_call",id:r.id,name:r.name,arguments:r.input,anthropic_mcp_server_name:r.server_name};case"tool_result":return{type:"tool_call_response",id:r.tool_use_id,response:Ml(r.content)};default:return typeof r.type!="string"?{type:"anthropic_unknown"}:r.type.endsWith("_tool_result")&&"tool_use_id"in r?{type:"tool_call_response",id:r.tool_use_id,response:M_(r.content)}:{type:`anthropic_${r.type}`}}}function Ml(r){return r==null?[]:typeof r=="string"?[{type:"text",text:r}]:r.map(i=>i.type==="text"||i.type==="search_result"?Mn(i):typeof i.type!="string"?{type:"unknown"}:{type:i.type})}function M_(r){return r==null?[]:typeof r=="string"?[{type:"text",text:r}]:Array.isArray(r)?r.map(i=>i.type==="text"||i.type==="search_result"||i.type==="web_search_result"?Mn(i):typeof i.type!="string"?{type:"unknown"}:{type:i.type}):[Mn(r)]}function Mn(r){if(Array.isArray(r))return r.map(Mn);if(typeof r!="object"||r===null)return r;let{type:i,file_type:e}=r;if(i==="image"||i==="document")return{type:i};let t=i==="text_editor_code_execution_view_result"&&(e==="image"||e==="pdf");return Object.fromEntries(Object.entries(r).filter(([n])=>!n.startsWith("encrypted_")&&!(n==="content"&&t)).map(([n,s])=>[n,Mn(s)]))}function ql(r,i,e){let{[Da]:t,[Zt]:n,[Xt]:s,[It]:a,[Nn]:l,...p}=i,h={[Zt]:n,[Xt]:s,[It]:a},m={},_=l?.map(P=>JSON.stringify(P)),y=3*([...t??[],..._??[]].reduce((P,A)=>P+A.length+1,2)+Nl(p,m)+Nl(h,m))<=e?P=>3*P.length:Ja,v=()=>Object.keys(h).reduce((P,A)=>P+y(m[A]??""),0),k=t?.reduce((P,A)=>P+y(A),0)??0,E=t!==void 0&&k<=e,T=E?k:0,x=t!==void 0&&!E;for(let P of Object.keys(p)){let A=y(m[P]??"");A>e?(delete m[P],x=!0):T+=A}let C=v();if(T+C>e){let{truncated:P,...A}=q_(h,T+C-e);x||(x=P),Nl(A,m),C=v()}if(T+=C,_!==void 0){let P=L_(_,e-T,y);m[Nn]=P.json,T+=P.size,x||(x=P.truncated)}x&&r.setAttribute(jd,!0),E&&r.setAttribute(Da,t);for(let[P,A]of Object.entries(m))r.setAttribute(P,A);return T}function Nl(r,i){let e=0;for(let[t,n]of Object.entries(r))n!==void 0&&(i[t]=JSON.stringify(n),e+=i[t].length);return e}function q_(r,i){let e=h=>h?.map(m=>({...m,parts:[...m.parts]})),t=r[Zt]?.slice(),n=e(r[Xt]),s=e(r[It]),a=[t??[],...[...n??[],...s??[]].map(({parts:h})=>h)],l=a.reduce((h,m)=>h+m.length,0),p=!1;for(let h of a){let m=0;for(;i>0&&m<h.length;){let _=h[m],g=Ja(JSON.stringify(_)),y=_.content;if(l===1&&_.type==="text"&&typeof y=="string"){let v=B_(_,y,g-i);v!==y&&(h[m]={..._,content:v},p=!0);break}i-=g+(m+1<h.length?1:0),m++,l--,p=!0}h.splice(0,m)}return{[Zt]:t,[Xt]:n,[It]:s,truncated:p}}function B_(r,i,e){let t=e-Ja(JSON.stringify({...r,content:""})),n=i.slice(0,Math.max(t,0)),s=JSON.stringify(n),a=0,l=0,p=0;for(;a<n.length;){let h=s.codePointAt(1+l),m=h>65535?2:1,_=h!==92?m:s[2+l]==="u"?6:2;if(p+=h<128?_:h<2048?2:h<65536?3:4,p>t)break;l+=_,a+=m}return i.slice(0,a)}function L_(r,i,e){let t=[],n=2;for(let s of r){let a=n+(t.length===0?0:1)+e(s);if(a>i)break;t.push(s),n=a}return{json:"["+t.join(",")+"]",size:n,truncated:t.length<r.length}}function Ja(r){let i=0;for(let e=0;e<r.length;e++){let t=r.charCodeAt(e);t<128?i+=1:t<2048?i+=2:t>=55296&&t<56320&&(r.charCodeAt(e+1)&64512)===56320?(i+=4,e++):i+=3}return i}function Ya(r,i,e){if(!J(i)||(typeof i.input_tokens=="number"&&r.setAttribute(Fd,Gd(i)),!e))return;let n=(Array.isArray(i.iterations)?i.iterations:[]).filter(s=>J(s)&&s.type==="compaction");n.length>0&&(r.setAttribute(Dd,n.reduce((s,a)=>s+Gd(a),0)),r.setAttribute(Vd,n.reduce((s,a)=>s+Jd(a,"output_tokens"),0)))}var $_=["input_tokens","cache_read_input_tokens","cache_creation_input_tokens"];function Gd(r){return $_.reduce((i,e)=>i+Jd(r,e),0)}function Jd(r,i){let e=r[i];return typeof e=="number"?e:0}function Xe(r,i){let e=M(r,()=>{let t=J(i.body)?i.body.output_config:void 0,n=J(t)?t.format:void 0;return J(n)&&n.type==="json_schema"?{[Ka]:Va}:{}});return{route:"/v1/messages",request:i,attributes:e}}function Bl(r){return M(void 0,()=>{let i=J(r)?r.agent:void 0,e=J(i)?i.id:i;return typeof e=="string"?{[zd]:e}:{}})}function Bn(r,i,e){if(!i?.span.isRecording())return i;try{let{contentMode:t,maxContentBytes:n}=r.openTelemetry.traces;t==="content"&&qn(i,e,void 0,n)}catch(t){I(r).debug("could not record the request on its span",t)}return i}function Ln(r,i,e,t){if(!(!i?.span.isRecording()||t instanceof re))try{Ya(i.span,t.usage,!0);let{contentMode:n,maxContentBytes:s}=r.openTelemetry.traces;n==="content"&&qn(i,e,t.content,s)}catch(n){I(r).debug("could not record the response on its span",n)}}function Yd(){let r=new Set(["traceparent","tracestate","baggage"]);try{for(let i of va.fields())r.add(i.toLowerCase())}catch(i){La().debug("could not record telemetry",i)}return r}function Qa(r){let i=Yd(),e=Array.from(r.entries()).filter(([t])=>i.has(t));for(let[t]of e)r.delete(t);return e}function Ll(r){return(i,e,t)=>{let n=new Headers(i.headers),s=Qa(n);return r({...i,headers:n},a=>{let l=new Headers(a.headers);for(let[p,h]of s)l.set(p,h);return e({...a,headers:l})},t)}}function er(r,i,e,t){if(!(!i.span.isRecording()||r.openTelemetry.traces.contentMode!=="content"))try{qn(i,e,t.content,r.openTelemetry.traces.maxContentBytes)}catch(n){I(r).debug("could not record the streamed message on its span",n)}}function $l(r,i,e,t){t.options.__span?.name==="anthropic.messages.create"&&e instanceof re?U_(r,i,e,t):wd(i,e,t)}function U_(r,i,e,t){if(!i.isRecording())return;i.setAttribute(Fa,t.response.status),Ha(i,t.response);let n=t.options.__span,s=n?.startTime,a,l,p=!1,h=!1,m=!1;Sl(e,t.controller.signal,{onItem(_){try{switch(_.type){case"message_start":{let g={..._.message};l={..._.message.usage},a={};for(let[,[y]]of Ua[n?.name??""]?.response??[])y!==void 0&&y!=="usage"&&(a[y]=g[y]);break}case"content_block_start":{let g=_.content_block;a&&J(g)&&g.type==="fallback"&&J(g.to)&&(a.model=g.to.model);break}case"message_delta":if(a&&l){let g=J(_.usage)?_.usage:{};l.output_tokens=g.output_tokens;for(let y of W_)g[y]!=null&&(l[y]=g[y]);_.delta.stop_reason!=null&&(a.stop_reason=_.delta.stop_reason),h=!0}break;case"message_stop":m=!0;break;case"content_block_delta":!p&&s!==void 0&&i.setAttribute(Nd,(Date.now()-s)/1e3),p=!0;break;case"content_block_stop":break;default:}}catch(g){I(r).debug("could not record the stream on its span",g)}},onEnd(_){try{if(a&&l&&n){let y=h||m,v={...a,usage:l};if(!y)for(let k of H_)v=Qd(v,k);kl(i,n.name,v),Ya(i,l,y)}}catch(y){I(r).debug("could not record the stream on its span",y)}let g=n?.failure;!m&&n?.streamed&&g===void 0&&er(r,n,n.streamed.body,n.streamed.message),_.reason==="failed"?Ce(i,_.error):g!==void 0?Ce(i,g,"client_error"):_.reason==="completed"&&(m?i.setStatus({code:Pe.OK}):Ce(i,new S("The stream ended before message_stop."),"api_error")),M(r,()=>i.end())}})}var H_=[["stop_reason"],["usage","output_tokens"],["usage","output_tokens_details"]],W_=["input_tokens","cache_creation_input_tokens","cache_read_input_tokens","output_tokens_details","iterations"];function Qd(r,i){let[e,...t]=i;if(e===void 0||!(e in r))return r;if(t.length===0){let{[e]:s,...a}=r;return a}let n=r[e];return J(n)?{...r,[e]:Qd(n,t)}:r}function Fl(r,i,e){return r._tracer?.startSpan("anthropic.environment.work",{kind:St.INTERNAL,attributes:{[Tt]:r._genAIProviderName,"anthropic.environment.id":i.environment_id,"anthropic.environment.work.id":i.id,"anthropic.session.id":i.data.id}},e)}function Xa(r,i){r?.isRecording()&&(i.aborted||r.setStatus({code:Pe.OK}),r.end())}function Za(r,i,e){r?.isRecording()&&(i.aborted||Ce(r,e),r.end())}async function Ul(r,i,e,t){if(!i)return t();try{await Q.with(Te.setSpan(Q.active(),i),t)}catch(n){throw M(r,()=>Za(i,e,n)),n}M(r,()=>Xa(i,e))}var He="x-stainless-helper",tr="x-stainless-helper-method";function rr(r){return{[He]:r}}var Ne=Symbol("anthropic.sdk.stainlessHelper");function Ze(r){return typeof r=="object"&&r!==null&&Ne in r}function Hl(r,i){let e=new Set;if(r)for(let t of r)Ze(t)&&e.add(t[Ne]);if(i)for(let t of i){Ze(t)&&e.add(t[Ne]);let n=t.content;if(Array.isArray(n))for(let s of n){Ze(s)&&e.add(s[Ne]);let a=s?.tool?.definition;Ze(a)&&e.add(a[Ne])}}return Array.from(e)}function eo(r,i){let e=Hl(r,i);return e.length===0?{}:{[He]:e.join(", ")}}function to(r){return Ze(r)?{[He]:r[Ne]}:{}}function Wl(r,i,e){if(!r._tracer)return;let t=i.output_config?.format?.type==="json_schema"||i.output_format?.type==="json_schema";return r._tracer.startSpan("anthropic.messages.tool_runner",{kind:St.INTERNAL,attributes:{[Ol]:Hd,[Tt]:r._genAIProviderName,[Od]:i.model,...t?{[Ka]:Va}:void 0,...e!=null?{[In]:e}:void 0}})}async function ir(r,i,e,t,n){let s=r._tracer;if(!s)return n();let{signal:a,conversationId:l,sessionID:p,parentContext:h=Q.active()}=t,m="description"in i?i.description:void 0,_={[Ol]:Ud,[Tt]:r._genAIProviderName,[Ld]:e.name,..."toolset_name"in e&&typeof e.toolset_name=="string"?{[Kd]:e.toolset_name}:void 0,...m?{[Bd]:m}:void 0,[qd]:e.id,[$d]:Wd,...l!=null?{[In]:l}:void 0,...p!=null?{"anthropic.session.id":p}:void 0,..."session_thread_id"in e&&e.session_thread_id!=null?{"anthropic.session.thread.id":e.session_thread_id}:void 0},g=e.type==="agent.tool_use"?"anthropic.tool_use":Ze(i)&&i[Ne]==="mcpTool"?"anthropic.mcp_tool_use":"anthropic.custom_tool_use",y=M(r,()=>s.startSpan(`${g} ${e.name}`,{kind:St.INTERNAL,attributes:_},h));if(!y)return n();let v;try{return v=await Q.with(Te.setSpan(h,y),n),v}finally{let k=v!==void 0&&!v.isError,E=!k&&a?.aborted===!0,{contentMode:T,maxContentBytes:x}=r.openTelemetry.traces;if(T==="content"&&y.isRecording())try{ql(y,{[Md]:e.input,[Nn]:v&&!E?Ml(v.content):void 0},x)}catch(C){I(r).debug("could not record the tool run on its span",C)}M(r,()=>{k?y.setStatus({code:Pe.OK}):E||Ce(y,v,"tool_error"),y.end()})}}var Ie,et=(()=>{class r extends Promise{constructor(e,t,n=ja){super(s=>{s(null)}),this.responsePromise=t,this.parseResponse=n,Ie.set(this,void 0),b(this,Ie,e,"f")}_responseProps(){return this.responsePromise}_thenUnwrap(e){return new r(o(this,Ie,"f"),this.responsePromise,async(t,n)=>Rt(e(await this.parseResponse(t,n),n),n.response))}asResponse(){return this.responsePromise.then(e=>{let t=e.options.__span?.span;if(t&&!this.parsedPromise){let n={status:"success",...e,data:void 0};M(o(this,Ie,"f"),()=>ut(t,n))}return 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"),workspace_id:t.headers.get("anthropic-workspace-id")}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(e=>this.parseResponseTraced(e))),this.parsedPromise}async parseResponseTraced(e){let t=e.options.__span;if(!t)return this.parseResponse(o(this,Ie,"f"),e);let{span:n}=t,s;try{s=await this.parseResponse(o(this,Ie,"f"),e)}catch(l){let p={status:"error",...e,error:l};throw M(o(this,Ie,"f"),()=>ut(n,p)),l}let a={status:"success",...e,data:s};return M(o(this,Ie,"f"),()=>md(t,s)),e.options.stream&&On(s)?M(o(this,Ie,"f"),()=>$l(o(this,Ie,"f"),n,s,e)):M(o(this,Ie,"f"),()=>ut(n,a)),s}then(e,t){return this.parse().then(e,t)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}}return Ie=new WeakMap,r})();var $n,io=(()=>{class r{constructor(e,t,n,s){$n.set(this,void 0),b(this,$n,e,"f"),this.options=s,this.response=t,this.body=n}hasNextPage(){return this.getPaginatedItems().length?this.nextPageRequestOptions()!=null:!1}async getNextPage(){let e=this.nextPageRequestOptions();if(!e)throw new S("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");let t=this.options.__span;return await o(this,$n,"f").requestAPIList(this.constructor,{...e,__span:t&&c(o(this,$n,"f"),t.name,{openTelemetry:this.options.openTelemetry},{route:t.route,queryParams:t.queryParams,contentQueryParams:t.contentQueryParams,attributes:t.attributes,request:e})})}async*iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e}async*[($n=new WeakMap,Symbol.asyncIterator)](){for await(let e of this.iterPages())for(let t of e.getPaginatedItems())yield t}}return r})(),no=(()=>{class r extends et{constructor(e,t,n){super(e,t,async(s,a)=>new n(s,a.response,await ja(s,a),a.options))}async*[Symbol.asyncIterator](){let e=await this;for await(let t of e)yield t}}return r})(),U=class extends io{constructor(i,e,t,n){super(i,e,t,n),this.data=t.data||[],this.has_more=t.has_more||!1,this.first_id=t.first_id||null,this.last_id=t.last_id||null}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more===!1?!1:super.hasNextPage()}nextPageRequestOptions(){if(this.options.query?.before_id){let e=this.first_id;return e?{...this.options,query:{...Yt(this.options.query),before_id:e}}:null}let i=this.last_id;return i?{...this.options,query:{...Yt(this.options.query),after_id:i}}:null}};var w=class extends io{constructor(i,e,t,n){super(i,e,t,n),this.data=t.data||[],this.next_page=t.next_page||null}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.nextPageRequestOptions()!=null}nextPageRequestOptions(){let i=this.next_page;return i?{...this.options,query:{...Yt(this.options.query),page:i}}:null}},ro=class extends io{constructor(i,e,t,n){super(i,e,t,n),this.data=t.data||[],this.next_page=t.next_page||null,this.prev_page=t.prev_page||null}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.nextPageRequestOptions()!=null}nextPageRequestOptions(){let i=this.next_page;return i?{...this.options,query:{...Yt(this.options.query),page:i}}:null}},_e=class extends io{constructor(i,e,t,n){super(i,e,t,n),this.data=t.data||[],this.next_page=t.next_page||null,this.has_more=t.has_more||!1,this.data_refreshed_at=t.data_refreshed_at||null}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.has_more===!1?!1:this.nextPageRequestOptions()!=null}nextPageRequestOptions(){let i=this.next_page;return i?{...this.options,query:{...Yt(this.options.query),page:i}}:null}};function Zd(r){return r.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}var Xd=Object.freeze(Object.create(null)),K_=(r=Zd)=>function(e,...t){if(e.length===1)return e[0];let n=!1,s=[],a=e.reduce((m,_,g)=>{/[?#]/.test(_)&&(n=!0);let y=t[g],v=(n?encodeURIComponent:r)(""+y);return g!==t.length&&(y==null||typeof y=="object"&&y.toString===Object.getPrototypeOf(Object.getPrototypeOf(y.hasOwnProperty??Xd)??Xd)?.toString)&&(v=y+"",s.push({start:m.length+_.length,length:v.length,error:`Value of type ${Object.prototype.toString.call(y).slice(8,-1)} is not a valid path parameter`})),!n&&(v===""||v.startsWith(";"))&&s.push({start:m.length+_.length,length:v.length,error:`Value "${v}" can't be safely passed as a path parameter`}),m+_+(g===t.length?"":v)},""),l=a.split(/[?#]/,1)[0],p=/(?<=^|\/)(?:\.|%2e){1,2}(?:;[^/]*)?(?=\/|$)/gi,h;for(;(h=p.exec(l))!==null;)s.push({start:h.index,length:h[0].length,error:`Value "${h[0]}" can't be safely passed as a path parameter`});if(s.sort((m,_)=>m.start-_.start),s.length>0){let m=[];for(let g of s)for(let y=g.start;y<g.start+Math.max(1,g.length);y++)m[y]="^";let _=Array.from(m,g=>g??" ").join("");throw new S(`Path parameters result in path with invalid segments:
9
- ${s.map(g=>g.error).join(`
10
- `)}
11
- ${a}
12
- ${_}`)}return a},u=K_(Zd);var nr=(()=>{class r extends R{}return r._errorName="FileNotDownloadableError",r})(),sr=(()=>{class r extends R{}return r._errorName="StorageQuotaExceededError",r})(),ar=(()=>{class r extends Re{}return r._errorName="FileExpiredError",r})(),Fn=(()=>{class r extends f{list(e={},t){let{workspace_id:n,...s}=e??{};return this._client.getAPIList("/v1/files",w,{query:s,...t,headers:d([{...n!=null?{"anthropic-workspace-id":n}:void 0},t?.headers]),__span:c(this._client,"anthropic.files.list",t,{route:"/v1/files",queryParams:["ids","limit","page"]})})}delete(e,t={},n){let{workspace_id:s}=t??{};return this._client.delete(u`/v1/files/${e}`,{...n,headers:d([{...s!=null?{"anthropic-workspace-id":s}:void 0},n?.headers]),__span:c(this._client,"anthropic.files.delete",n,{route:"/v1/files/{file_id}",attributes:{"anthropic.file.id":e}})})}download(e,t={},n){let{workspace_id:s}=t??{};return this._client.get(u`/v1/files/${e}/content`,{...n,headers:d([{Accept:"application/binary",...s!=null?{"anthropic-workspace-id":s}:void 0},n?.headers]),__binaryResponse:!0,__span:c(this._client,"anthropic.files.download",n,{route:"/v1/files/{file_id}/content",attributes:{"anthropic.file.id":e}})})}retrieveMetadata(e,t={},n){let{workspace_id:s}=t??{};return this._client.get(u`/v1/files/${e}`,{...n,headers:d([{...s!=null?{"anthropic-workspace-id":s}:void 0},n?.headers]),__span:c(this._client,"anthropic.files.retrieve_metadata",n,{route:"/v1/files/{file_id}",attributes:{"anthropic.file.id":e}})})}upload(e,t){let{workspace_id:n,...s}=e;return this._client.post("/v1/files",ie({body:s,...t,headers:d([{...n!=null?{"anthropic-workspace-id":n}:void 0},to(s.file),t?.headers]),__span:c(this._client,"anthropic.files.upload",t,{route:"/v1/files",createdIDAttribute:"anthropic.file.id"})},this._client))}}return r.FileNotDownloadableError=nr,r.StorageQuotaExceededError=sr,r.FileExpiredError=ar,r})();var so=(()=>{class r extends R{}return r._errorName="ClaudeCodeKeyCreatorNotMemberError",r})(),ao=(()=>{class r extends R{}return r._errorName="ClaudeCodeVersionTooOldError",r})(),oo=(()=>{class r extends R{}return r._errorName="CMEKKeyDisabledError",r})(),co=(()=>{class r extends R{}return r._errorName="CMEKKeyNetworkBlockedError",r})(),lo=(()=>{class r extends R{}return r._errorName="OrganizationOnHoldError",r})(),uo=(()=>{class r extends R{}return r._errorName="OrganizationTypeNotSupportedError",r})(),po=(()=>{class r extends R{}return r._errorName="RequestBodyEncodingInvalidError",r})(),ho=(()=>{class r extends R{}return r._errorName="RequestBodyEncodingUnsupportedError",r})(),_o=(()=>{class r extends G{}return r._errorName="SandboxEgressRestrictedError",r})(),fo=(()=>{class r extends Gt{}return r._errorName="RequestBodyTooLargeAfterDecodingError",r})(),mo=(()=>{class r extends At{}return r._errorName="EnforcedSpendLimitReachedError",r})(),go=(()=>{class r extends At{}return r._errorName="RampLimitExceededError",r})(),bo=(()=>{class r extends Qe{}return r._errorName="CMEKContextUnavailableError",r})(),yo=(()=>{class r extends Qe{}return r._errorName="CMEKKeyUnreachableError",r})();var or=class extends f{retrieve(i,e={},t){let{betas:n,workspace_id:s}=e??{};return this._client.get(u`/v1/deployment_runs/${i}`,{...t,headers:d([{"anthropic-beta":[...n??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.deployment_runs.retrieve",t,{route:"/v1/deployment_runs/{deployment_run_id}",attributes:{"anthropic.deployment_run.id":i}})})}list(i={},e){let{betas:t,workspace_id:n,...s}=i??{};return this._client.getAPIList("/v1/deployment_runs",w,{query:s,...e,headers:d([{"anthropic-beta":[...t??[],"managed-agents-2026-04-01"].toString(),...n!=null?{"anthropic-workspace-id":n}:void 0},e?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.deployment_runs.list",e,{route:"/v1/deployment_runs",queryParams:["created_at[gt]","created_at[gte]","created_at[lt]","created_at[lte]","deployment_id","has_error","limit","page","trigger_type"]})})}};var cr=class extends f{create(i,e){let{betas:t,workspace_id:n,...s}=i;return this._client.post("/v1/deployments",{body:s,...e,headers:d([{"anthropic-beta":[...t??[],"managed-agents-2026-04-01"].toString(),...n!=null?{"anthropic-workspace-id":n}:void 0},e?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.deployments.create",e,{route:"/v1/deployments",createdIDAttribute:"anthropic.deployment.id"})})}retrieve(i,e={},t){let{betas:n,workspace_id:s}=e??{};return this._client.get(u`/v1/deployments/${i}`,{...t,headers:d([{"anthropic-beta":[...n??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.deployments.retrieve",t,{route:"/v1/deployments/{deployment_id}",attributes:{"anthropic.deployment.id":i}})})}update(i,e,t){let{betas:n,workspace_id:s,...a}=e;return this._client.post(u`/v1/deployments/${i}`,{body:a,...t,headers:d([{"anthropic-beta":[...n??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.deployments.update",t,{route:"/v1/deployments/{deployment_id}",attributes:{"anthropic.deployment.id":i}})})}list(i={},e){let{betas:t,workspace_id:n,...s}=i??{};return this._client.getAPIList("/v1/deployments",w,{query:s,...e,headers:d([{"anthropic-beta":[...t??[],"managed-agents-2026-04-01"].toString(),...n!=null?{"anthropic-workspace-id":n}:void 0},e?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.deployments.list",e,{route:"/v1/deployments",queryParams:["agent_id","created_at[gte]","created_at[lte]","include_archived","limit","page","status"]})})}archive(i,e={},t){let{betas:n,workspace_id:s}=e??{};return this._client.post(u`/v1/deployments/${i}/archive`,{...t,headers:d([{"anthropic-beta":[...n??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.deployments.archive",t,{route:"/v1/deployments/{deployment_id}/archive",attributes:{"anthropic.deployment.id":i}})})}pause(i,e={},t){let{betas:n,workspace_id:s}=e??{};return this._client.post(u`/v1/deployments/${i}/pause`,{...t,headers:d([{"anthropic-beta":[...n??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.deployments.pause",t,{route:"/v1/deployments/{deployment_id}/pause",attributes:{"anthropic.deployment.id":i}})})}run(i,e={},t){let{betas:n,workspace_id:s}=e??{};return this._client.post(u`/v1/deployments/${i}/run`,{...t,headers:d([{"anthropic-beta":[...n??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.deployments.run",t,{route:"/v1/deployments/{deployment_id}/run",attributes:{"anthropic.deployment.id":i}})})}unpause(i,e={},t){let{betas:n,workspace_id:s}=e??{};return this._client.post(u`/v1/deployments/${i}/unpause`,{...t,headers:d([{"anthropic-beta":[...n??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.deployments.unpause",t,{route:"/v1/deployments/{deployment_id}/unpause",attributes:{"anthropic.deployment.id":i}})})}};var lr=class extends f{create(i,e){let{betas:t,workspace_id:n,...s}=i;return this._client.post("/v1/dreams",{body:s,...e,headers:d([{"anthropic-beta":[...t??[],"dreaming-2026-04-21"].toString(),...n!=null?{"anthropic-workspace-id":n}:void 0},e?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.dreams.create",e,{route:"/v1/dreams",createdIDAttribute:"anthropic.dream.id"})})}retrieve(i,e={},t){let{betas:n,workspace_id:s}=e??{};return this._client.get(u`/v1/dreams/${i}`,{...t,headers:d([{"anthropic-beta":[...n??[],"dreaming-2026-04-21"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.dreams.retrieve",t,{route:"/v1/dreams/{dream_id}",attributes:{"anthropic.dream.id":i}})})}list(i={},e){let{betas:t,workspace_id:n,...s}=i??{};return this._client.getAPIList("/v1/dreams",w,{query:s,...e,headers:d([{"anthropic-beta":[...t??[],"dreaming-2026-04-21"].toString(),...n!=null?{"anthropic-workspace-id":n}:void 0},e?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.dreams.list",e,{route:"/v1/dreams",queryParams:["created_at[gt]","created_at[lt]","include_archived","limit","page","statuses"]})})}archive(i,e={},t){let{betas:n,workspace_id:s}=e??{};return this._client.post(u`/v1/dreams/${i}/archive`,{...t,headers:d([{"anthropic-beta":[...n??[],"dreaming-2026-04-21"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.dreams.archive",t,{route:"/v1/dreams/{dream_id}/archive",attributes:{"anthropic.dream.id":i}})})}cancel(i,e={},t){let{betas:n,workspace_id:s}=e??{};return this._client.post(u`/v1/dreams/${i}/cancel`,{...t,headers:d([{"anthropic-beta":[...n??[],"dreaming-2026-04-21"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.dreams.cancel",t,{route:"/v1/dreams/{dream_id}/cancel",attributes:{"anthropic.dream.id":i}})})}};var ur=class extends f{list(i={},e){let{betas:t,workspace_id:n,...s}=i??{};return this._client.getAPIList("/v1/files",w,{query:s,...e,headers:d([{...t?.toString()!=null?{"anthropic-beta":t?.toString()}:void 0,...n!=null?{"anthropic-workspace-id":n}:void 0},e?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.files.list",e,{route:"/v1/files",queryParams:["ids","limit","page","scope_id"]})})}delete(i,e={},t){let{betas:n,workspace_id:s}=e??{};return this._client.delete(u`/v1/files/${i}`,{...t,headers:d([{...n?.toString()!=null?{"anthropic-beta":n?.toString()}:void 0,...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.files.delete",t,{route:"/v1/files/{file_id}",attributes:{"anthropic.file.id":i}})})}download(i,e={},t){let{betas:n,workspace_id:s}=e??{};return this._client.get(u`/v1/files/${i}/content`,{...t,headers:d([{Accept:"application/binary",...n?.toString()!=null?{"anthropic-beta":n?.toString()}:void 0,...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__binaryResponse:!0,__span:c(this._client,"anthropic.files.download",t,{route:"/v1/files/{file_id}/content",attributes:{"anthropic.file.id":i}})})}retrieveMetadata(i,e={},t){let{betas:n,workspace_id:s}=e??{};return this._client.get(u`/v1/files/${i}`,{...t,headers:d([{...n?.toString()!=null?{"anthropic-beta":n?.toString()}:void 0,...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.files.retrieve_metadata",t,{route:"/v1/files/{file_id}",attributes:{"anthropic.file.id":i}})})}upload(i,e){let{betas:t,workspace_id:n,...s}=i;return this._client.post("/v1/files",ie({body:s,...e,headers:d([{...t?.toString()!=null?{"anthropic-beta":t?.toString()}:void 0,...n!=null?{"anthropic-workspace-id":n}:void 0},to(s.file),e?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.files.upload",e,{route:"/v1/files",createdIDAttribute:"anthropic.file.id"})},this._client))}};var dr=class extends f{retrieve(i,e={},t){let{betas:n,workspace_id:s}=e??{};return this._client.get(u`/v1/models/${i}`,{...t,headers:d([{...n?.toString()!=null?{"anthropic-beta":n?.toString()}:void 0,...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.models.retrieve",t,{route:"/v1/models/{model_id}",attributes:{"anthropic.model.id":i}})})}list(i={},e){let{betas:t,workspace_id:n,...s}=i??{};return this._client.getAPIList("/v1/models",U,{query:s,...e,headers:d([{...t?.toString()!=null?{"anthropic-beta":t?.toString()}:void 0,...n!=null?{"anthropic-workspace-id":n}:void 0},e?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.models.list",e,{route:"/v1/models",queryParams:["after_id","before_id","lifecycle","limit"]})})}};var up=Dh(lp(),1),hr=class extends f{parseUnverified(i){return JSON.parse(i)}unwrap(i,e){let t=e?.headers;if(t==null)throw new Error("Webhook headers are required in order to verify the signature");let n=e.key===void 0?this._client.webhookKey:e.key;if(!n)throw new Error("Webhook key must not be null or empty in order to unwrap");return new up.Webhook(n).verify(i,t),JSON.parse(i)}};var _r=class extends f{list(i,e={},t){let{betas:n,workspace_id:s,...a}=e??{};return this._client.getAPIList(u`/v1/agents/${i}/versions`,w,{query:a,...t,headers:d([{"anthropic-beta":[...n??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.agents.versions.list",t,{route:"/v1/agents/{agent_id}/versions",queryParams:["limit","page"],attributes:{"gen_ai.agent.id":i}})})}};var ko=(()=>{class r extends f{constructor(){super(...arguments),this.versions=new _r(this._client)}create(e,t){let{betas:n,workspace_id:s,...a}=e;return this._client.post("/v1/agents",{body:a,...t,headers:d([{"anthropic-beta":[...n??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.agents.create",t,{route:"/v1/agents",createdIDAttribute:"gen_ai.agent.id"})})}retrieve(e,t={},n){let{betas:s,workspace_id:a,...l}=t??{};return this._client.get(u`/v1/agents/${e}`,{query:l,...n,headers:d([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.agents.retrieve",n,{route:"/v1/agents/{agent_id}",queryParams:["version"],attributes:{"gen_ai.agent.id":e}})})}update(e,t,n){let{betas:s,workspace_id:a,...l}=t;return this._client.post(u`/v1/agents/${e}`,{body:l,...n,headers:d([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.agents.update",n,{route:"/v1/agents/{agent_id}",attributes:{"gen_ai.agent.id":e}})})}list(e={},t){let{betas:n,workspace_id:s,...a}=e??{};return this._client.getAPIList("/v1/agents",w,{query:a,...t,headers:d([{"anthropic-beta":[...n??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.agents.list",t,{route:"/v1/agents",queryParams:["created_at[gte]","created_at[lte]","include_archived","limit","page"]})})}archive(e,t={},n){let{betas:s,workspace_id:a}=t??{};return this._client.post(u`/v1/agents/${e}/archive`,{...n,headers:d([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.agents.archive",n,{route:"/v1/agents/{agent_id}/archive",attributes:{"gen_ai.agent.id":e}})})}}return r.Versions=_r,r})();var Eo=function(){let{crypto:r}=globalThis;if(r?.randomUUID)return Eo=r.randomUUID.bind(r),r.randomUUID();let i=new Uint8Array(1),e=r?()=>r.getRandomValues(i)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,t=>(+t^e()&15>>+t/4).toString(16))};function pt(r,i){if(!r)return()=>{};if(r.aborted)return i.abort(),()=>{};let e=()=>i.abort();return r.addEventListener("abort",e),()=>r.removeEventListener("abort",e)}function ht(r,i){return r instanceof F&&r.status===i}function lf(r){return r instanceof F&&typeof r.status=="number"&&r.status>=400&&r.status<500}function zt(r){return lf(r)&&!ht(r,408)&&!ht(r,409)&&!ht(r,429)}function So(r,i,e){return Math.min(i*2**r,e)}function dp(r,i){return r+Math.random()*(i-r)}function Ao(r){return r*(1-Math.random()*.25)}function xo(r,{authToken:i,helper:e}){if(!i)throw new S(`copyClientForHelper: expected a non-empty authToken but received ${JSON.stringify(i)}`);let t=r._options.defaultHeaders,n=r._authState?.extraHeaders,s=n?Object.fromEntries(Object.entries(n).filter(([l])=>{let p=l.toLowerCase();return p!=="authorization"&&p!=="x-api-key"})):void 0,a=d([s,t,{[He]:e}]);return a.values.delete("x-api-key"),a.values.delete("authorization"),a.nulls.delete("authorization"),r.withOptions({authToken:i,baseURL:r.baseURL,defaultHeaders:a})}var fr,Po,fe,To,Ro,Co,Hn,Wn,mr,gr,Io,br,jn,uf=999,df=1e3,pf=6e4,hf=3e5,Kn=(()=>{class r{constructor(e){fr.set(this,void 0),Po.set(this,!1),fe.set(this,void 0),To.set(this,void 0),Ro.set(this,void 0),Co.set(this,void 0),Hn.set(this,void 0),Wn.set(this,void 0),mr.set(this,void 0),this.client=e.client,this.environmentId=e.environmentId,this.environmentKey=e.environmentKey,this.workerId=e.workerId??mf(),b(this,fr,xo(e.client,{authToken:e.environmentKey,helper:"environments-work-poller"}),"f"),b(this,Ro,e.autoStop??!0,"f"),b(this,Co,e.drain??!1,"f"),b(this,Hn,e.blockMs===void 0?uf:e.blockMs,"f"),b(this,Wn,e.reclaimOlderThanMs??null,"f"),b(this,mr,e.requestOptions,"f"),b(this,fe,new AbortController,"f"),b(this,To,pt(e.signal,o(this,fe,"f")),"f")}get signal(){return o(this,fe,"f").signal}abort(){o(this,fe,"f").abort()}async*[(fr=new WeakMap,Po=new WeakMap,fe=new WeakMap,To=new WeakMap,Ro=new WeakMap,Co=new WeakMap,Hn=new WeakMap,Wn=new WeakMap,mr=new WeakMap,Symbol.asyncIterator)](){if(o(this,Po,"f"))throw new S("Cannot iterate over a consumed WorkPoller");b(this,Po,!0,"f");let e=Q.active(),t=I(this.client);t.info("poller starting",{component:"work-poller",environment_id:this.environmentId});let n=new ff(t,this.environmentId);try{let s=0;for(;!o(this,fe,"f").signal.aborted;){let a;try{a=await o(this,fr,"f").beta.environments.work.poll(this.environmentId,{"Anthropic-Worker-ID":this.workerId,...o(this,Hn,"f")!==null?{block_ms:o(this,Hn,"f")}:{},...o(this,Wn,"f")!==null?{reclaim_older_than_ms:o(this,Wn,"f")}:{}},{headers:d([o(this,mr,"f")?.headers]),signal:o(this,fe,"f").signal})}catch(l){if(o(this,fe,"f").signal.aborted)return;if(zt(l))throw t.error("poll failed permanently, stopping poller",{error:String(l)}),l;let p=Ao(_f(s));t.warn("poll failed, backing off",{error:String(l),backoff_ms:p}),s++,await Oe(p,o(this,fe,"f").signal);continue}if(s=0,a==null){if(o(this,Co,"f"))return;n.onEmptyPoll(),await Oe(dp(1e3,3e3),o(this,fe,"f").signal);continue}n.onClaim(),this._workSpan=M(this.client,()=>Fl(this.client,a,e)),t.info("claimed work",{component:"work-poller",environment_id:this.environmentId,work_id:a.id,work_type:a.data.type});try{await o(this,fr,"f").beta.environments.work.ack(a.id,{environment_id:a.environment_id},{headers:d([o(this,mr,"f")?.headers]),signal:o(this,fe,"f").signal})}catch(l){t.error("ack failed",{work_id:a.id,error:String(l)}),M(this.client,()=>Za(this._workSpan,o(this,fe,"f").signal,l));continue}try{yield a,e=Q.active()}finally{if(o(this,Ro,"f"))try{await o(this,fr,"f").beta.environments.work.stop(a.id,{environment_id:a.environment_id},{headers:d([o(this,mr,"f")?.headers])})}catch(l){ht(l,409)||t.warn("stop failed",{work_id:a.id,error:String(l)})}M(this.client,()=>Xa(this._workSpan,o(this,fe,"f").signal))}}}finally{o(this,To,"f").call(this)}}}return r})();function _f(r){return So(r,df,pf)}var ff=(()=>{class r{constructor(e,t){gr.set(this,void 0),Io.set(this,void 0),br.set(this,void 0),jn.set(this,0),b(this,gr,e,"f"),b(this,Io,t,"f")}onEmptyPoll(){let e=Date.now(),t={component:"work-poller",environment_id:o(this,Io,"f")};o(this,br,"f")===void 0?(b(this,br,b(this,jn,e,"f"),"f"),o(this,gr,"f").info("idle; polling for work",t)):e-o(this,jn,"f")>=hf?(b(this,jn,e,"f"),o(this,gr,"f").info(`still polling; idle for ${Math.round((e-o(this,br,"f"))/1e3)}s`,t)):o(this,gr,"f").debug("poll returned no work",t)}onClaim(){b(this,br,void 0,"f")}}return gr=new WeakMap,Io=new WeakMap,br=new WeakMap,jn=new WeakMap,r})();function mf(){let i=globalThis.process?.env?.HOSTNAME;return i?`${i}-${Eo()}`:Eo()}var pp=r=>{if(typeof globalThis.Buffer<"u"){let i=globalThis.Buffer.from(r,"base64");return new Uint8Array(i.buffer,i.byteOffset,i.byteLength)}if(typeof atob<"u"){let i=atob(r),e=new Uint8Array(i.length);for(let t=0;t<i.length;t++)e[t]=i.charCodeAt(t);return e}throw new S("Cannot decode base64 string; Expected `Buffer` or `atob` to be defined")};var yr,_t,wr,hp=(()=>{class r{constructor(){yr.set(this,[]),_t.set(this,[]),wr.set(this,!1)}push(e){if(o(this,wr,"f"))return!1;let t=o(this,_t,"f").shift();return t?t({done:!1,value:e}):o(this,yr,"f").push(e),!0}close(){if(!o(this,wr,"f"))for(b(this,wr,!0,"f");o(this,_t,"f").length>0;)o(this,_t,"f").shift()({done:!0,value:void 0})}next(e){return o(this,yr,"f").length>0?Promise.resolve({done:!1,value:o(this,yr,"f").shift()}):o(this,wr,"f")||e?.aborted?Promise.resolve({done:!0,value:void 0}):new Promise(t=>{let n=a=>{e?.removeEventListener("abort",s),t(a)},s=()=>{let a=o(this,_t,"f").indexOf(n);a>=0&&o(this,_t,"f").splice(a,1),t({done:!0,value:void 0})};o(this,_t,"f").push(n),e?.addEventListener("abort",s,{once:!0})})}tryShift(){return o(this,yr,"f").shift()}}return yr=new WeakMap,_t=new WeakMap,wr=new WeakMap,r})();var vr=(()=>{class r extends Error{constructor(e){let t=typeof e=="string"?e:e.map(n=>n.type==="text"?n.text:`[${n.type}]`).join(" ");super(t),this.name="ToolError",this.content=e}}return r})();var gf="\\x00-\\x1f\\x7f-\\x9f\\u061c\\u200e\\u200f\\u2028\\u2029\\u202a-\\u202e\\u2066-\\u2069",bf=new RegExp(`[${gf}]+`,"g"),yf=/[\uD800-\uDFFF]/gu;function Dn(r){return r.replace(yf,"\uFFFD")}var _p=4096,wf=200;function vf(r,i=_p){return mp(Dn(r).replace(bf," ").trim(),i)}function kf(r){return vf(r,wf)}function tt(r){return kf(r).replace(/[' ]+/g," ").trim()}function zo(r){return`Error: ${r instanceof Error?r.message:String(r)}`}function fp(r){return mp(Dn(zo(r)),_p)}function mp(r,i){if(r.length<=i)return r;let e=0,t=0;for(let n of r){if(t===i)break;t+=1,e+=n.length}return r.slice(0,e)}function gp(r){return typeof r=="string"?Dn(r):r.filter(i=>i.type==="text"&&i.text!=="").map(i=>({...i,text:Dn(i.text)}))}function Vl(r){return"name"in r?r.name:"mcp_server_name"in r?r.mcp_server_name:r.type}function Ef(r){return r instanceof vr?r.content:zo(r)}async function Oo(r,i,e){try{let t=r.parse?r.parse(i):i;return{content:await r.run(t,e),isError:!1}}catch(t){return{content:Ef(t),isError:!0}}}var Vn,No,kr,Ot,Me,j,Mo,ne,qo,Er,Bo,Z,Sr,Se,Ar,ft,xr,rt,Lo,Gn,Ae,$o,Jn,Yn,Fo,bp,yp,wp,Gl,vp,Jl,kp,Uo,Ho,Yl,Ep,Sp;var Ap=500,Sf=1e4,Af=12e4,xf=3e4,Pf=1e3,Tf=3e4,Rf=5*6e4,Cf=6e4;function xp(r){return r.type!=="session.status_idle"?!1:r.stop_reason?.type!=="requires_action"}var If=(()=>{class r{constructor(e,t){Vn.set(this,void 0),No.set(this,void 0),kr.set(this,new Set),Ot.set(this,!1),Me.set(this,void 0),b(this,Vn,e,"f"),b(this,No,t,"f")}noteEvent(e){e.type!=="user.tool_confirmation"&&(xp(e)?this.arm():this.disarm())}block(e){o(this,kr,"f").add(e),o(this,Me,"f")!==void 0&&(b(this,Ot,!0,"f"),clearTimeout(o(this,Me,"f")),b(this,Me,void 0,"f"))}unblock(e){o(this,kr,"f").delete(e),o(this,kr,"f").size===0&&o(this,Ot,"f")&&this.arm()}arm(){if(!(o(this,Vn,"f")<=0)){if(o(this,kr,"f").size>0){b(this,Ot,!0,"f");return}b(this,Ot,!1,"f"),o(this,Me,"f")!==void 0&&clearTimeout(o(this,Me,"f")),b(this,Me,setTimeout(o(this,No,"f"),o(this,Vn,"f")),"f")}}disarm(){b(this,Ot,!1,"f"),o(this,Me,"f")!==void 0&&(clearTimeout(o(this,Me,"f")),b(this,Me,void 0,"f"))}}return Vn=new WeakMap,No=new WeakMap,kr=new WeakMap,Ot=new WeakMap,Me=new WeakMap,r})(),Qn=(()=>{class r{constructor(e,t){j.add(this),Mo.set(this,!1),ne.set(this,void 0),qo.set(this,void 0),Er.set(this,void 0),Bo.set(this,void 0),Z.set(this,void 0),Sr.set(this,new Set),Se.set(this,new Set),Ar.set(this,new Map),ft.set(this,new Map),xr.set(this,new hp),rt.set(this,0),Lo.set(this,Rf),Gn.set(this,null),Ae.set(this,void 0),$o.set(this,void 0),Jn.set(this,void 0),Yn.set(this,!1),this.client=t.client,this.sessionId=e,this.tools=t.tools,this.maxIdleMs=t.maxIdleMs??Cf,b(this,Z,I(t.client),"f"),b(this,Bo,new Map(t.tools.map(n=>[Vl(n),n])),"f"),b(this,ne,new AbortController,"f"),b(this,qo,pt(t.signal,o(this,ne,"f")),"f"),b(this,Er,t.requestOptions,"f"),b(this,Ae,new If(this.maxIdleMs,()=>{o(this,Z,"f").info("session idle after its turn ended; stopping",{component:"session-tool-runner",session_id:this.sessionId,max_idle_ms:this.maxIdleMs}),o(this,ne,"f").abort()}),"f")}get signal(){return o(this,ne,"f").signal}abort(){o(this,ne,"f").abort()}_setSendRetryWindow(e){b(this,Lo,e,"f")}async*[(Mo=new WeakMap,ne=new WeakMap,qo=new WeakMap,Er=new WeakMap,Bo=new WeakMap,Z=new WeakMap,Sr=new WeakMap,Se=new WeakMap,Ar=new WeakMap,ft=new WeakMap,xr=new WeakMap,rt=new WeakMap,Lo=new WeakMap,Gn=new WeakMap,Ae=new WeakMap,$o=new WeakMap,Jn=new WeakMap,Yn=new WeakMap,j=new WeakSet,Symbol.asyncIterator)](){if(o(this,Mo,"f"))throw new S("Cannot iterate over a consumed SessionToolRunner");b(this,Mo,!0,"f"),b(this,$o,this.client._tracer?Q.active():void 0,"f"),o(this,Z,"f").info("session tool runner starting",{component:"session-tool-runner",session_id:this.sessionId});let e=o(this,j,"m",bp).call(this).catch(t=>{o(this,ne,"f").signal.aborted||o(this,Z,"f").error("stream loop failed",{error:String(t)}),o(this,ne,"f").abort()});try{for(;;){let n=await o(this,xr,"f").next(o(this,ne,"f").signal);if(n.done)break;yield n.value}await e;let t;for(;(t=o(this,xr,"f").tryShift())!==void 0;)yield t}finally{o(this,ne,"f").abort(),o(this,Ae,"f").disarm(),await e;try{await o(this,j,"m",Sp).call(this)}catch(t){o(this,Z,"f").warn("drain failed",{error:String(t)})}o(this,xr,"f").close();for(let t of this.tools)try{await t.close?.()}catch(n){o(this,Z,"f").warn("tool.close failed",{tool:Vl(t),error:String(n)})}o(this,qo,"f").call(this)}}}return Fo=function(){return{...o(this,Er,"f"),headers:d([rr("session-tool-runner"),o(this,Er,"f")?.headers]),signal:o(this,ne,"f").signal}},bp=async function(){let e=o(this,ne,"f"),t=Ap;for(;!e.signal.aborted;){try{let n=await this.client.beta.sessions.events.stream(this.sessionId,{},o(this,j,"m",Fo).call(this));await o(this,j,"m",yp).call(this);for await(let s of n)if(t=Ap,await o(this,j,"m",vp).call(this,s))return}catch(n){if(e.signal.throwIfAborted(),zt(n))throw o(this,Z,"f").error("permanent stream failure, shutting down",{error:String(n)}),e.abort(),n;o(this,Z,"f").warn("stream disconnected, reconnecting",{error:String(n),backoff_ms:t})}e.signal.throwIfAborted(),await Oe(t,e.signal),t=Math.min(t*2,Sf)}},yp=async function(){let e=o(this,ne,"f"),t=[],n=!1;b(this,Yn,!1,"f");try{for await(let l of this.client.beta.sessions.events.list(this.sessionId,{limit:1e3},o(this,j,"m",Fo).call(this)))o(this,j,"m",wp).call(this,l,t),l.type!=="user.tool_confirmation"&&(n=xp(l))}catch(l){e.signal.throwIfAborted(),o(this,Z,"f").warn("reconcile list failed",{error:String(l)});for(let p of t)o(this,Sr,"f").delete(p.id);return}b(this,Yn,!0,"f");let s=t.filter(l=>!o(this,Se,"f").has(l.id));o(this,Ae,"f").disarm();for(let l of s)await o(this,j,"m",Jl).call(this,l);for(let l of[...o(this,ft,"f").values()]){let p=o(this,Ar,"f").get(l.id);p!==void 0&&await o(this,j,"m",Uo).call(this,l,p)}let a=s.filter(l=>!o(this,Se,"f").has(l.id)&&!o(this,ft,"f").has(l.id));n&&a.length===0?o(this,Ae,"f").arm():o(this,Ae,"f").disarm()},wp=function(e,t){o(this,j,"m",Gl).call(this,e),e.type==="agent.tool_use"||e.type==="agent.custom_tool_use"?(o(this,Sr,"f").add(e.id),o(this,Se,"f").has(e.id)||t.push(e)):e.type==="user.tool_result"?o(this,Se,"f").add(e.tool_use_id):e.type==="user.custom_tool_result"?o(this,Se,"f").add(e.custom_tool_use_id):e.type==="user.tool_confirmation"&&(o(this,Se,"f").has(e.tool_use_id)||o(this,Ar,"f").set(e.tool_use_id,e.result))},Gl=function(e){if(!(!this.client._tracer||o(this,Jn,"f")!==void 0))switch(e.type){case"session.thread_status_running":case"session.thread_status_idle":case"session.thread_status_rescheduled":case"session.thread_status_terminated":b(this,Jn,e.session_thread_id,"f")}},vp=async function(e){switch(o(this,Ae,"f").noteEvent(e),o(this,Yn,"f")&&o(this,j,"m",Gl).call(this,e),e.type){case"agent.tool_use":case"agent.custom_tool_use":return o(this,Sr,"f").has(e.id)||(o(this,Sr,"f").add(e.id),await o(this,j,"m",Jl).call(this,e)),!1;case"user.tool_confirmation":return await o(this,j,"m",kp).call(this,e),!1;case"user.tool_result":return o(this,Se,"f").add(e.tool_use_id),!1;case"user.custom_tool_result":return o(this,Se,"f").add(e.custom_tool_use_id),!1;case"session.status_terminated":case"session.deleted":return o(this,Z,"f").info("session terminated",{component:"session-tool-runner",session_id:this.sessionId}),o(this,ne,"f").abort(),!0;default:return!1}},Jl=async function(e){let t=e.evaluated_permission,n=t==="deny"?"deny":o(this,Ar,"f").get(e.id);if(n===void 0){t===void 0||t==="allow"?await o(this,j,"m",Yl).call(this,e,void 0):o(this,ft,"f").has(e.id)||(o(this,Z,"f").info("tool call awaiting confirmation; holding",{component:"session-tool-runner",session_id:this.sessionId,tool:e.name,tool_use_id:e.id}),o(this,ft,"f").set(e.id,e),o(this,Ae,"f").block(e.id));return}await o(this,j,"m",Uo).call(this,e,n)},kp=async function(e){o(this,Ar,"f").set(e.tool_use_id,e.result);let t=o(this,ft,"f").get(e.tool_use_id);t!==void 0&&await o(this,j,"m",Uo).call(this,t,e.result)},Uo=async function(e,t){let n=o(this,ft,"f").delete(e.id);if(t==="allow"){o(this,Z,"f").info("tool call confirmed",{component:"session-tool-runner",session_id:this.sessionId,tool:e.name,tool_use_id:e.id}),n||o(this,Ae,"f").block(e.id);try{await o(this,j,"m",Yl).call(this,e,"allow")}finally{o(this,Ae,"f").unblock(e.id)}return}n&&o(this,Ae,"f").unblock(e.id),o(this,Se,"f").add(e.id),o(this,Z,"f").info("tool call denied; not executing",{component:"session-tool-runner",session_id:this.sessionId,tool:e.name,tool_use_id:e.id}),o(this,j,"m",Ho).call(this,{event:e,toolUseId:e.id,name:e.name,isError:!1,posted:!1,confirmation:"deny"})},Ho=function(e){o(this,xr,"f").push(e)},Yl=async function(e,t){var n,s;if(!o(this,Se,"f").has(e.id)){o(this,Z,"f").info("executing tool",{component:"session-tool-runner",session_id:this.sessionId,tool:e.name,tool_use_id:e.id}),b(this,rt,(n=o(this,rt,"f"),n++,n),"f");try{let a=o(this,Bo,"f").get(e.name);if(!a){o(this,Z,"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}),t==="allow"&&o(this,Ae,"f").disarm(),o(this,j,"m",Ho).call(this,{event:e,toolUseId:e.id,name:e.name,isError:!1,posted:!1,confirmation:t});return}let l,p,h=o(this,Er,"f")?.openTelemetry?.conversationId??(e.session_thread_id||o(this,Jn,"f")),m=new AbortController,_=pt(o(this,ne,"f").signal,m),g=setTimeout(()=>m.abort(),Af);try{let k={signal:o(this,ne,"f").signal,conversationId:h,sessionID:this.sessionId,parentContext:o(this,$o,"f")},E=await ir(this.client,a,e,k,async()=>{let T=await Oo(a,e.input,{toolUse:e,toolUseBlock:e,signal:m.signal}),x=Of(T.content),C=this.client._tracer?x.map((P,A)=>{let O=typeof T.content=="string"?void 0:T.content[A];return O&&O.type!=="text"&&P.type==="text"?O:P}):x;return{sent:x,content:C,isError:T.isError}});l=E.sent,p=E.isError}finally{clearTimeout(g),_()}let y=zf(e,p,l),v=await o(this,j,"m",Ep).call(this,y,e.id,h);o(this,j,"m",Ho).call(this,{event:e,result:y,toolUseId:e.id,name:e.name,isError:p,posted:v,confirmation:t})}finally{b(this,rt,(s=o(this,rt,"f"),s--,s),"f"),o(this,rt,"f")===0&&o(this,Gn,"f")?.call(this)}}},Ep=async function(e,t,n){let s=o(this,ne,"f"),a=Date.now(),l,p=0;for(;;){p++,s.signal.throwIfAborted();try{return await this.client.beta.sessions.events.send(this.sessionId,{events:[e]},{...o(this,j,"m",Fo).call(this),openTelemetry:{conversationId:n}}),o(this,Se,"f").add(t),!0}catch(h){if(l=h,zt(h))break;let m=o(this,Lo,"f")-(Date.now()-a);if(m<=0)break;let _=Math.min(Ao(So(p-1,Pf,Tf)),m);o(this,Z,"f").warn("tool result send failed; retrying",{tool_use_id:t,attempt:p,backoff_ms:_,error:String(h)}),await Oe(_,s.signal)}}return o(this,Z,"f").error("failed to send tool result",{tool_use_id:t,attempts:p,error:String(l)}),!1},Sp=async function(){o(this,rt,"f")!==0&&(await Promise.race([new Promise(e=>b(this,Gn,e,"f")),Oe(xf)]),b(this,Gn,null,"f"),o(this,rt,"f")>0&&o(this,Z,"f").warn("drain timeout exceeded"))},r})();function zf(r,i,e){return r.type==="agent.custom_tool_use"?{type:"user.custom_tool_result",custom_tool_use_id:r.id,is_error:i,content:e}:{type:"user.tool_result",tool_use_id:r.id,is_error:i,content:e}}function Of(r){if(typeof r=="string")return[{type:"text",text:r||"(no output)"}];let i=r.map(e=>e.type==="text"?{type:"text",text:e.text||"(no output)"}:e.type==="image"||e.type==="document"?e:e.type==="search_result"?{type:"search_result",source:e.source,title:e.title,content:e.content.map(t=>({type:"text",text:t.text})),citations:{enabled:e.citations?.enabled??!1}}:{type:"text",text:JSON.stringify(e)});return i.length>0?i:[{type:"text",text:"(no output)"}]}var jk=15e3,Pp=5e3;function Tp(r,i){if(!(r>=Pp))throw new S(`${i} must be at least ${Pp}ms (got ${r}); to run without memory sync, pass \`memorySyncIntervalMs: null\` to the worker instead`)}var Wo,Xn,Ql,Zn,Nt,Rp=3e4,Nf=9e4,Mf="NO_HEARTBEAT";function qf(r){return r.resources.some(i=>i.type==="memory_store")}function Bf(r){if(!r)return null;let i;try{let t=r.replace(/-/g,"+").replace(/_/g,"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");i=JSON.parse(Pn(pp(n)))}catch{return null}if(i===null||typeof i!="object"||Array.isArray(i))return null;let e=i.sessions_token;return typeof e=="string"&&e!==""?e:null}var Xl=(()=>{class r{constructor(e){if(Wo.add(this),Xn.set(this,void 0),e.unrestrictedPaths!==void 0)throw new S("The `unrestrictedPaths` option you passed to EnvironmentWorker (or client.beta.environments.work.worker()) is no longer supported. The worker's file tools (read, write, edit, glob, grep) are now always confined to `workdir` plus the session's memory folders. Remove `unrestrictedPaths` from your options; to let the file tools reach any other directory, add it to `AgentToolContext.allowedRoots` from a `tools` factory.");this.client=e.client,this.environmentId=e.environmentId,this.environmentKey=e.environmentKey,this.tools=e.tools,this.workdir=e.workdir??process.cwd(),this.maxFileBytes=e.maxFileBytes,this.maxIdleMs=e.maxIdleMs,e.memorySyncIntervalMs!=null&&Tp(e.memorySyncIntervalMs,"memorySyncIntervalMs"),this.memorySyncIntervalMs=e.memorySyncIntervalMs,this.memorySyncDeletions=e.memorySyncDeletions??"enabled",this.workerId=e.workerId,this.requestOptions=e.requestOptions,b(this,Xn,e.signal,"f")}async run(e){let{environmentId:t,environmentKey:n}=this;if(t===void 0||n===void 0)throw new S("EnvironmentWorker.run: environmentId and environmentKey are required to poll for work");let s=e??o(this,Xn,"f"),a=new Kn({client:this.client,environmentId:t,environmentKey:n,...this.workerId!==void 0?{workerId:this.workerId}:{},...s?{signal:s}:{},...this.requestOptions!==void 0?{requestOptions:this.requestOptions}:{},autoStop:!1});for await(let l of a){let p=a._workSpan;try{await Ul(this.client,p,a.signal,()=>o(this,Wo,"m",Ql).call(this,l,n,a.signal,p))}catch(h){if(a.signal?.aborted)throw h;I(this.client).error("work item failed",{work_id:l.id,error:String(h)})}}}async handleItem(e){let t=e?.workId??z("ANTHROPIC_WORK_ID"),n=e?.environmentId??z("ANTHROPIC_ENVIRONMENT_ID"),s=e?.sessionId??z("ANTHROPIC_SESSION_ID"),a=(e?.environmentKey??this.environmentKey??z("ANTHROPIC_ENVIRONMENT_KEY"))||void 0,l=e?.workSecret||z("ANTHROPIC_WORK_SECRET")||null;if(!t)throw new S("handleItem: workId is required \u2014 pass it or set ANTHROPIC_WORK_ID");if(!n)throw new S("handleItem: environmentId is required \u2014 pass it or set ANTHROPIC_ENVIRONMENT_ID");if(!s)throw new S("handleItem: sessionId is required \u2014 pass it or set ANTHROPIC_SESSION_ID");if(!a&&!l)throw new S("handleItem: environmentKey is required when there is no work secret \u2014 pass it, construct the worker with it, or set ANTHROPIC_ENVIRONMENT_KEY");let p={id:t,environment_id:n,secret:l,data:{type:"session",id:s}};await o(this,Wo,"m",Ql).call(this,p,a,e?.signal??o(this,Xn,"f"))}}return Xn=new WeakMap,Wo=new WeakSet,Ql=async function(e,t,n,s){let a=I(this.client),l=Bf(e.secret),p=l??t;if(p===void 0)throw new S("handleItem: the work item carried a secret payload but no sessions token could be extracted, and there is no environment key to fall back to; the poller must issue a secret whose payload carries `sessions_token`, or provide the environment key (pass it, construct the worker with it, or set ANTHROPIC_ENVIRONMENT_KEY)");e.secret&&l===null&&a.warn("work item carried a secret payload but no sessions token could be extracted; falling back to the environment key",{work_id:e.id});let h=xo(this.client,{authToken:p,helper:"environments-worker"}),m=e.data.id,_=new AbortController,g=pt(n,_),y=new $f(_),v=await import("./node-33JV5VS3.js"),k,E,T=Uf(h,e,y,a,this.requestOptions,A=>{k=A,E?._setSendRetryWindow(A)}).catch(A=>{_.signal.aborted||a.error("heartbeat loop failed",{work_id:e.id,error:String(A)}),_.abort()}),x=async()=>{},C,P=!1;try{if(e.data.type!=="session"){a.debug("skipping non-session work item",{work_id:e.id,type:e.data.type});return}let A=await h.beta.sessions.retrieve(m);if(l===null&&this.memorySyncIntervalMs!==null&&qf(A))throw new v.SessionMemoryError(`cannot mount the session's memories: the work item carried no sessions token (work_id=${e.id}, session_id=${m}); the memory endpoints reject the environment key, so the poller must issue a per-item \`secret\` carrying \`sessions_token\`, or set \`memorySyncIntervalMs: null\` to run without memory`);let O={workdir:this.workdir,client:h,session:A,...this.maxFileBytes!==void 0?{maxFileBytes:this.maxFileBytes}:{}};try{x=await v.setupSkills(O)}catch(L){a.warn("skill setup failed",{session_id:m,work_id:e.id,error:String(L)})}l!==null&&this.memorySyncIntervalMs!==null?(C=new v.SessionMemoryStores(h,{workdir:this.workdir,...this.memorySyncIntervalMs!==void 0?{syncIntervalMs:this.memorySyncIntervalMs}:{},syncDeletions:this.memorySyncDeletions}),await C.download(A),O.allowedRoots=C.roots,O.readOnlyRoots=C.readOnlyRoots):a.debug("memory stores disabled for this item",{work_id:e.id});let B=typeof this.tools=="function"?this.tools(O):this.tools??v.betaAgentToolset20260401(O);E=new Qn(m,{client:h,tools:B,...this.maxIdleMs!==void 0?{maxIdleMs:this.maxIdleMs}:{},...this.requestOptions!==void 0?{requestOptions:this.requestOptions}:{},signal:_.signal}),k!==void 0&&E._setSendRetryWindow(k);for await(let L of E)C&&await C.syncIfDue();P=!_.signal.aborted}finally{try{await x().catch(A=>{a.warn("skill cleanup failed",{session_id:m,work_id:e.id,error:String(A)})})}finally{if(C){let A=v.MEMORY_FLUSH_TIMEOUT_MS;P&&await Cp(C.finish(),A)&&a.warn(`final memory sync cut off after ${A}ms; the flush that follows still uploads changed files`,{session_id:m,work_id:e.id});let O=new AbortController;await Cp(C.flushWrites(O.signal),A)&&(O.abort(),a.warn(`memory flush cut off after ${A}ms; changed files it had not uploaded yet are not saved`,{session_id:m,work_id:e.id})),await C.dispose().catch(L=>{a.warn("memory store cleanup failed",{session_id:m,work_id:e.id,error:String(L)})})}}y.finish("runner_done"),g(),await T,y.lost?a.info("lease lost; released without stopping it",{session_id:m,work_id:e.id}):await Lf(h,e,a,this.requestOptions),(y.lost||y.rejected)&&M(this.client,()=>s?.end())}},r})();async function Cp(r,i){let e;try{return await Promise.race([r.then(()=>!1,()=>!1),new Promise(t=>{e=setTimeout(()=>t(!0),i)})])}finally{e!==void 0&&clearTimeout(e)}}async function Lf(r,i,e,t){try{await r.beta.environments.work.stop(i.id,{environment_id:i.environment_id,force:!0},{...t,headers:d([t?.headers])})}catch(n){ht(n,409)||e.error("force-stop on exit failed",{work_id:i.id,error:String(n)})}}var $f=(()=>{class r{constructor(e){Zn.set(this,void 0),Nt.set(this,void 0),b(this,Zn,e,"f")}get signal(){return o(this,Zn,"f").signal}finish(e){b(this,Nt,o(this,Nt,"f")??e,"f"),o(this,Zn,"f").abort()}get lost(){return o(this,Nt,"f")==="lease_lost"||o(this,Nt,"f")==="assumed_lost"}get rejected(){return o(this,Nt,"f")==="heartbeat_rejected"}}return Zn=new WeakMap,Nt=new WeakMap,r})();function Ff(r){let i=r instanceof F?r.error:void 0;for(let e of["error","details","current_state"]){if(!J(i))return{};i=i[e]}return J(i)?i:{}}async function Uf(r,i,e,t,n,s){let a=Rp,l=Nf,p=Date.now(),h=Mf,m=async()=>{let _=new AbortController,g=pt(e.signal,_),y=setTimeout(()=>_.abort(),a);try{let v=await r.beta.environments.work.heartbeat(i.id,{environment_id:i.environment_id,expected_last_heartbeat:h},{...n,headers:d([n?.headers]),signal:_.signal});p=Date.now(),h=v.last_heartbeat,v.ttl_seconds>0&&(l=v.ttl_seconds*1e3,a=Math.max(1e3,Math.min(l/2,Rp)),s?.(l)),(v.state==="stopping"||v.state==="stopped")&&(t.info("heartbeat signals shutdown",{work_id:i.id,state:v.state}),e.finish("heartbeat_stop")),v.lease_extended||(t.warn("lease not extended, shutting down",{work_id:i.id}),e.finish("heartbeat_stop"))}catch(v){if(e.signal.throwIfAborted(),ht(v,412)){let k=Ff(v);t.error("lease lost: heartbeat precondition failed",{work_id:i.id,server_state:k.state,server_ttl_seconds:k.ttl_seconds,server_last_heartbeat:k.last_heartbeat}),e.finish("lease_lost");return}if(zt(v))throw t.error("permanent heartbeat failure",{work_id:i.id,error:String(v)}),e.finish("heartbeat_rejected"),v;if(Date.now()-p>l){t.error("lease assumed lost: no successful heartbeat in ttl",{work_id:i.id,ttl_ms:l,error:String(v)}),e.finish("assumed_lost");return}t.warn("transient heartbeat failure",{work_id:i.id,error:String(v)})}finally{clearTimeout(y),g()}};for(await m();!e.signal.aborted;)await Oe(a,e.signal),e.signal.throwIfAborted(),await m()}var es=(()=>{class r extends Vt{}return r._errorName="BetaHeartbeatPreconditionFailedError",r})(),jo=(()=>{class r extends f{retrieve(e,t,n){let{environment_id:s,betas:a,workspace_id:l}=t;return this._client.get(u`/v1/environments/${s}/work/${e}`,{...n,headers:d([{"anthropic-beta":[...a??[],"managed-agents-2026-04-01"].toString(),...l!=null?{"anthropic-workspace-id":l}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.environments.work.retrieve",n,{route:"/v1/environments/{environment_id}/work/{work_id}",attributes:{"anthropic.environment.id":s,"anthropic.environment.work.id":e}})})}update(e,t,n){let{environment_id:s,betas:a,workspace_id:l,...p}=t;return this._client.post(u`/v1/environments/${s}/work/${e}`,{body:p,...n,headers:d([{"anthropic-beta":[...a??[],"managed-agents-2026-04-01"].toString(),...l!=null?{"anthropic-workspace-id":l}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.environments.work.update",n,{route:"/v1/environments/{environment_id}/work/{work_id}",attributes:{"anthropic.environment.id":s,"anthropic.environment.work.id":e}})})}list(e,t={},n){let{betas:s,...a}=t??{};return this._client.getAPIList(u`/v1/environments/${e}/work`,w,{query:a,...n,headers:d([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.environments.work.list",n,{route:"/v1/environments/{environment_id}/work",queryParams:["limit","page"],attributes:{"anthropic.environment.id":e}})})}ack(e,t,n){let{environment_id:s,betas:a}=t;return this._client.post(u`/v1/environments/${s}/work/${e}/ack`,{...n,headers:d([{"anthropic-beta":[...a??[],"managed-agents-2026-04-01"].toString()},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.environments.work.ack",n,{route:"/v1/environments/{environment_id}/work/{work_id}/ack",attributes:{"anthropic.environment.id":s,"anthropic.environment.work.id":e}})})}heartbeat(e,t,n){let{environment_id:s,desired_ttl_seconds:a,expected_last_heartbeat:l,betas:p}=t;return this._client.post(u`/v1/environments/${s}/work/${e}/heartbeat`,{query:{desired_ttl_seconds:a,expected_last_heartbeat:l},...n,headers:d([{"anthropic-beta":[...p??[],"managed-agents-2026-04-01"].toString()},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.environments.work.heartbeat",n,{route:"/v1/environments/{environment_id}/work/{work_id}/heartbeat",queryParams:["desired_ttl_seconds","expected_last_heartbeat"],attributes:{"anthropic.environment.id":s,"anthropic.environment.work.id":e}})})}poll(e,t={},n){let{betas:s,"Anthropic-Worker-ID":a,...l}=t??{};return this._client.get(u`/v1/environments/${e}/work/poll`,{query:l,...n,headers:d([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"Anthropic-Worker-ID":a}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.environments.work.poll",n,{route:"/v1/environments/{environment_id}/work/poll",queryParams:["block_ms","reclaim_older_than_ms"],attributes:{"anthropic.environment.id":e}})})}stats(e,t={},n){let{betas:s,workspace_id:a}=t??{};return this._client.get(u`/v1/environments/${e}/work/stats`,{...n,headers:d([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.environments.work.stats",n,{route:"/v1/environments/{environment_id}/work/stats",attributes:{"anthropic.environment.id":e}})})}stop(e,t,n){let{environment_id:s,betas:a,workspace_id:l,...p}=t;return this._client.post(u`/v1/environments/${s}/work/${e}/stop`,{body:p,...n,headers:d([{"anthropic-beta":[...a??[],"managed-agents-2026-04-01"].toString(),...l!=null?{"anthropic-workspace-id":l}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.environments.work.stop",n,{route:"/v1/environments/{environment_id}/work/{work_id}/stop",attributes:{"anthropic.environment.id":s,"anthropic.environment.work.id":e}})})}poller(e){return new Kn({...e,client:this._client})}worker(e){return new Xl({...e,client:this._client})}}return r.BetaHeartbeatPreconditionFailedError=es,r.WorkPoller=Kn,r.EnvironmentWorker=Xl,r})();var ts=(()=>{class r extends R{}return r._errorName="BetaEnvironmentArchivedError",r})(),rs=(()=>{class r extends R{}return r._errorName="BetaInvalidConfigTypeChangeError",r})(),is=(()=>{class r extends R{}return r._errorName="BetaInvalidMetadataError",r})(),ns=(()=>{class r extends G{}return r._errorName="BetaEnvironmentCreateDisabledError",r})(),ss=(()=>{class r extends G{}return r._errorName="BetaEnvironmentUpdateDisabledError",r})(),as=(()=>{class r extends Re{}return r._errorName="BetaEnvironmentNotFoundError",r})(),Ko=(()=>{class r extends f{constructor(){super(...arguments),this.work=new jo(this._client)}create(e,t){let{betas:n,workspace_id:s,...a}=e;return this._client.post("/v1/environments",{body:a,...t,headers:d([{"anthropic-beta":[...n??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.environments.create",t,{route:"/v1/environments",createdIDAttribute:"anthropic.environment.id"})})}retrieve(e,t={},n){let{betas:s,workspace_id:a}=t??{};return this._client.get(u`/v1/environments/${e}`,{...n,headers:d([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.environments.retrieve",n,{route:"/v1/environments/{environment_id}",attributes:{"anthropic.environment.id":e}})})}update(e,t,n){let{betas:s,workspace_id:a,...l}=t;return this._client.post(u`/v1/environments/${e}`,{body:l,...n,headers:d([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.environments.update",n,{route:"/v1/environments/{environment_id}",attributes:{"anthropic.environment.id":e}})})}list(e={},t){let{betas:n,workspace_id:s,...a}=e??{};return this._client.getAPIList("/v1/environments",w,{query:a,...t,headers:d([{"anthropic-beta":[...n??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.environments.list",t,{route:"/v1/environments",queryParams:["include_archived","limit","page"]})})}delete(e,t={},n){let{betas:s,workspace_id:a}=t??{};return this._client.delete(u`/v1/environments/${e}`,{...n,headers:d([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.environments.delete",n,{route:"/v1/environments/{environment_id}",attributes:{"anthropic.environment.id":e}})})}archive(e,t={},n){let{betas:s,workspace_id:a}=t??{};return this._client.post(u`/v1/environments/${e}/archive`,{...n,headers:d([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.environments.archive",n,{route:"/v1/environments/{environment_id}/archive",attributes:{"anthropic.environment.id":e}})})}}return r.BetaEnvironmentArchivedError=ts,r.BetaInvalidConfigTypeChangeError=rs,r.BetaInvalidMetadataError=is,r.BetaEnvironmentCreateDisabledError=ns,r.BetaEnvironmentUpdateDisabledError=ss,r.BetaEnvironmentNotFoundError=as,r.Work=jo,r.BetaHeartbeatPreconditionFailedError=es,r})();var Pr=class extends f{create(i,e,t){let{view:n,betas:s,workspace_id:a,...l}=e;return this._client.post(u`/v1/memory_stores/${i}/memories`,{query:{view:n},body:l,...t,headers:d([{"anthropic-beta":[...s??[],"agent-memory-2026-07-22"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.memory_stores.memories.create",t,{route:"/v1/memory_stores/{memory_store_id}/memories",queryParams:["view"],attributes:{"gen_ai.memory.store.id":i},createdIDAttribute:"gen_ai.memory.record.id"})})}retrieve(i,e,t){let{memory_store_id:n,betas:s,workspace_id:a,...l}=e;return this._client.get(u`/v1/memory_stores/${n}/memories/${i}`,{query:l,...t,headers:d([{"anthropic-beta":[...s??[],"agent-memory-2026-07-22"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.memory_stores.memories.retrieve",t,{route:"/v1/memory_stores/{memory_store_id}/memories/{memory_id}",queryParams:["view"],attributes:{"gen_ai.memory.store.id":n,"gen_ai.memory.record.id":i}})})}update(i,e,t){let{memory_store_id:n,view:s,betas:a,workspace_id:l,...p}=e;return this._client.post(u`/v1/memory_stores/${n}/memories/${i}`,{query:{view:s},body:p,...t,headers:d([{"anthropic-beta":[...a??[],"agent-memory-2026-07-22"].toString(),...l!=null?{"anthropic-workspace-id":l}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.memory_stores.memories.update",t,{route:"/v1/memory_stores/{memory_store_id}/memories/{memory_id}",queryParams:["view"],attributes:{"gen_ai.memory.store.id":n,"gen_ai.memory.record.id":i}})})}list(i,e={},t){let{betas:n,workspace_id:s,...a}=e??{};return this._client.getAPIList(u`/v1/memory_stores/${i}/memories`,w,{query:a,...t,headers:d([{"anthropic-beta":[...n??[],"agent-memory-2026-07-22"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.memory_stores.memories.list",t,{route:"/v1/memory_stores/{memory_store_id}/memories",queryParams:["depth","limit","page","path_prefix","view"],contentQueryParams:["page"],attributes:{"gen_ai.memory.store.id":i}})})}delete(i,e,t){let{memory_store_id:n,expected_content_sha256:s,betas:a,workspace_id:l}=e;return this._client.delete(u`/v1/memory_stores/${n}/memories/${i}`,{query:{expected_content_sha256:s},...t,headers:d([{"anthropic-beta":[...a??[],"agent-memory-2026-07-22"].toString(),...l!=null?{"anthropic-workspace-id":l}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.memory_stores.memories.delete",t,{route:"/v1/memory_stores/{memory_store_id}/memories/{memory_id}",queryParams:["expected_content_sha256"],attributes:{"gen_ai.memory.store.id":n,"gen_ai.memory.record.id":i}})})}};var Tr=class extends f{retrieve(i,e,t){let{memory_store_id:n,betas:s,workspace_id:a,...l}=e;return this._client.get(u`/v1/memory_stores/${n}/memory_versions/${i}`,{query:l,...t,headers:d([{"anthropic-beta":[...s??[],"agent-memory-2026-07-22"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.memory_stores.memory_versions.retrieve",t,{route:"/v1/memory_stores/{memory_store_id}/memory_versions/{memory_version_id}",queryParams:["view"],attributes:{"gen_ai.memory.store.id":n,"anthropic.memory_store.memory_version.id":i}})})}list(i,e={},t){let{betas:n,workspace_id:s,...a}=e??{};return this._client.getAPIList(u`/v1/memory_stores/${i}/memory_versions`,w,{query:a,...t,headers:d([{"anthropic-beta":[...n??[],"agent-memory-2026-07-22"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.memory_stores.memory_versions.list",t,{route:"/v1/memory_stores/{memory_store_id}/memory_versions",queryParams:["api_key_id","created_at[gte]","created_at[lte]","limit","memory_id","operation","page","service_account_id","session_id","view"],attributes:{"gen_ai.memory.store.id":i}})})}redact(i,e,t){let{memory_store_id:n,betas:s,workspace_id:a}=e;return this._client.post(u`/v1/memory_stores/${n}/memory_versions/${i}/redact`,{...t,headers:d([{"anthropic-beta":[...s??[],"agent-memory-2026-07-22"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.memory_stores.memory_versions.redact",t,{route:"/v1/memory_stores/{memory_store_id}/memory_versions/{memory_version_id}/redact",attributes:{"gen_ai.memory.store.id":n,"anthropic.memory_store.memory_version.id":i}})})}};var Do=(()=>{class r extends f{constructor(){super(...arguments),this.memories=new Pr(this._client),this.memoryVersions=new Tr(this._client)}create(e,t){let{betas:n,workspace_id:s,...a}=e;return this._client.post("/v1/memory_stores",{body:a,...t,headers:d([{"anthropic-beta":[...n??[],"agent-memory-2026-07-22"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.memory_stores.create",t,{route:"/v1/memory_stores",createdIDAttribute:"gen_ai.memory.store.id"})})}retrieve(e,t={},n){let{betas:s,workspace_id:a}=t??{};return this._client.get(u`/v1/memory_stores/${e}`,{...n,headers:d([{"anthropic-beta":[...s??[],"agent-memory-2026-07-22"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.memory_stores.retrieve",n,{route:"/v1/memory_stores/{memory_store_id}",attributes:{"gen_ai.memory.store.id":e}})})}update(e,t,n){let{betas:s,workspace_id:a,...l}=t;return this._client.post(u`/v1/memory_stores/${e}`,{body:l,...n,headers:d([{"anthropic-beta":[...s??[],"agent-memory-2026-07-22"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.memory_stores.update",n,{route:"/v1/memory_stores/{memory_store_id}",attributes:{"gen_ai.memory.store.id":e}})})}list(e={},t){let{betas:n,workspace_id:s,...a}=e??{};return this._client.getAPIList("/v1/memory_stores",w,{query:a,...t,headers:d([{"anthropic-beta":[...n??[],"agent-memory-2026-07-22"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.memory_stores.list",t,{route:"/v1/memory_stores",queryParams:["created_at[gte]","created_at[lte]","include_archived","limit","page"]})})}delete(e,t={},n){let{betas:s,workspace_id:a}=t??{};return this._client.delete(u`/v1/memory_stores/${e}`,{...n,headers:d([{"anthropic-beta":[...s??[],"agent-memory-2026-07-22"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.memory_stores.delete",n,{route:"/v1/memory_stores/{memory_store_id}",attributes:{"gen_ai.memory.store.id":e}})})}archive(e,t={},n){let{betas:s,workspace_id:a}=t??{};return this._client.post(u`/v1/memory_stores/${e}/archive`,{...n,headers:d([{"anthropic-beta":[...s??[],"agent-memory-2026-07-22"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.memory_stores.archive",n,{route:"/v1/memory_stores/{memory_store_id}/archive",attributes:{"gen_ai.memory.store.id":e}})})}}return r.Memories=Pr,r.MemoryVersions=Tr,r})();var Vo=(()=>{class r{constructor(e,t,n){this.iterator=e,this.response=n,this.controller=t}async*decoder(){let e=this.iterator;if(!e)throw new S("Cannot iterate over a consumed stream.");this.iterator=void 0;let t=new Na;for await(let n of e)for(let s of t.decode(n))yield JSON.parse(s);for(let n of t.flush())yield JSON.parse(n)}[Symbol.asyncIterator](){return this.decoder()}static fromResponse(e,t){if(!e.body)throw t.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new S("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 S("Attempted to iterate over a response with no body");return new r(An(e.body),t,e)}}return r})();var Rr=class extends f{create(i,e){let{betas:t,user_profile_id:n,workspace_id:s,...a}=i;return this._client.post("/v1/messages/batches",{body:a,...e,headers:d([{"anthropic-beta":[...t??[],"message-batches-2024-09-24"].toString(),...n!=null?{"anthropic-user-profile-id":n}:void 0,...s!=null?{"anthropic-workspace-id":s}:void 0},e?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.messages.batches.create",e,{route:"/v1/messages/batches",attributes:{"anthropic.message.batch.request_count":a.requests?.length},createdIDAttribute:"anthropic.message.batch.id"})})}retrieve(i,e={},t){let{betas:n,workspace_id:s}=e??{};return this._client.get(u`/v1/messages/batches/${i}`,{...t,headers:d([{"anthropic-beta":[...n??[],"message-batches-2024-09-24"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.messages.batches.retrieve",t,{route:"/v1/messages/batches/{message_batch_id}",attributes:{"anthropic.message.batch.id":i}})})}list(i={},e){let{betas:t,workspace_id:n,...s}=i??{};return this._client.getAPIList("/v1/messages/batches",U,{query:s,...e,headers:d([{"anthropic-beta":[...t??[],"message-batches-2024-09-24"].toString(),...n!=null?{"anthropic-workspace-id":n}:void 0},e?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.messages.batches.list",e,{route:"/v1/messages/batches",queryParams:["after_id","before_id","limit"]})})}delete(i,e={},t){let{betas:n,workspace_id:s}=e??{};return this._client.delete(u`/v1/messages/batches/${i}`,{...t,headers:d([{"anthropic-beta":[...n??[],"message-batches-2024-09-24"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.messages.batches.delete",t,{route:"/v1/messages/batches/{message_batch_id}",attributes:{"anthropic.message.batch.id":i}})})}cancel(i,e={},t){let{betas:n,workspace_id:s}=e??{};return this._client.post(u`/v1/messages/batches/${i}/cancel`,{...t,headers:d([{"anthropic-beta":[...n??[],"message-batches-2024-09-24"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.messages.batches.cancel",t,{route:"/v1/messages/batches/{message_batch_id}/cancel",attributes:{"anthropic.message.batch.id":i}})})}async results(i,e={},t){let n=await this.retrieve(i,e,t);if(!n.results_url)throw new S(`No batch \`results_url\`; Has it finished processing? ${n.processing_status} - ${n.id}`);let{betas:s,workspace_id:a}=e??{};return this._client.get(n.results_url,{...t,headers:d([{"anthropic-beta":[...s??[],"message-batches-2024-09-24"].toString(),Accept:"application/binary",...a!=null?{"anthropic-workspace-id":a}:void 0},t?.headers]),stream:!0,__qualifiers:{beta:"true"},__binaryResponse:!0,__span:c(this._client,"anthropic.messages.batches.results",t,{route:"/v1/messages/batches/{message_batch_id}/results",attributes:{"anthropic.message.batch.id":i}})})._thenUnwrap((l,p)=>Vo.fromResponse(p.response,p.controller))}};var Go={"claude-opus-4@20250514":8192,"anthropic.claude-opus-4-1-20250805-v1:0":8192,"claude-opus-4-1@20250805":8192};function Ip(r){return r?.output_format??r?.output_config?.format}function Zl(r,i,e){let t=Ip(i);return!i||!("parse"in(t??{}))?{...r,content:r.content.map(n=>{if(n.type==="text"){let s=Object.defineProperty({...n},"parsed_output",{value:null,enumerable:!1});return Object.defineProperty(s,"parsed",{get(){return e.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead."),null},enumerable:!1})}return n}),parsed_output:null}:os(r,i,e)}function os(r,i,e){let t=null,n=r.content.map(s=>{if(s.type==="text"){let a=Gf(i,s.text);t===null&&(t=a);let l=Object.defineProperty({...s},"parsed_output",{value:a,enumerable:!1});return Object.defineProperty(l,"parsed",{get(){return e.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead."),a},enumerable:!1})}return s});return{...r,content:n,parsed_output:t}}function Gf(r,i){let e=Ip(r);if(e?.type!=="json_schema")return null;try{return"parse"in e?e.parse(i):JSON.parse(i)}catch(t){throw new S(`Failed to parse structured output: ${t}`)}}function eu(r,i){let{betas:e,user_profile_id:t,workspace_id:n,tools:s,messages:a}=r;return d([{...e?.toString()!=null?{"anthropic-beta":e?.toString()}:void 0,...t!=null?{"anthropic-user-profile-id":t}:void 0,...n!=null?{"anthropic-workspace-id":n}:void 0},eo(s,a),i?.headers])}function zp(r,i,e){if(!r._tracer)return;let t=eu(i,e);return c(r,"anthropic.messages.create",e,Xe(r,{body:Jo(i),headers:t,stream:!0}))}function Jo(r){if(!r.output_format)return r;cs(r);let{output_format:i,...e}=r;return{...e,output_config:{...r.output_config,format:i}}}function cs(r){if(r.output_format&&r.output_config?.format)throw new S("Both output_format and output_config.format were provided. Please use only output_config.format (output_format is deprecated).")}var Jf=r=>{let i=0,e=[];for(;i<r.length;){let t=r[i];if(t==="\\"){i++;continue}if(t==="{"){e.push({type:"brace",value:"{"}),i++;continue}if(t==="}"){e.push({type:"brace",value:"}"}),i++;continue}if(t==="["){e.push({type:"paren",value:"["}),i++;continue}if(t==="]"){e.push({type:"paren",value:"]"}),i++;continue}if(t===":"){e.push({type:"separator",value:":"}),i++;continue}if(t===","){e.push({type:"delimiter",value:","}),i++;continue}if(t==='"'){let l=i+1,p=l,h=!1;for(;;){if(p=r.indexOf('"',p),p===-1){h=!0;break}let m=0,_=p-1;for(;_>=l&&r[_]==="\\";)m++,_--;if(m%2===0)break;p++}h?i=r.length:(e.push({type:"string",value:r.slice(l,p)}),i=p+1);continue}if(t&&/\s/.test(t)){i++;continue}let s=/[0-9]/;if(t&&s.test(t)||t==="-"||t==="."){let l="";for(t==="-"&&(l+=t,t=r[++i]);t&&(s.test(t)||t==="."||t==="e"||t==="E"||(t==="-"||t==="+")&&(l[l.length-1]==="e"||l[l.length-1]==="E"));)l+=t,t=r[++i];e.push({type:"number",value:l,unterminated:i===r.length});continue}let a=/[a-z]/i;if(t&&a.test(t)){let l="";for(;t&&a.test(t)&&i!==r.length;)l+=t,t=r[++i];if(l=="true"||l=="false"||l==="null")e.push({type:"name",value:l});else{i++;continue}continue}i++}return e},Yf=r=>{let i=[];for(let s of r)(s.type==="brace"||s.type==="paren")&&(s.value==="{"||s.value==="["?i.push(s.value):i.pop());let e=i[i.length-1],t=r.length,n=/^-?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][-+]?[0-9]+)?$/;for(;t>0;){let s=r[t-1];switch(s.type){case"separator":t--;continue;case"number":if(s.unterminated||!n.test(s.value)){t--;continue}break;case"string":let a=r[t-2];if(e==="{"&&(a?.type==="delimiter"||a?.type==="brace"&&a.value==="{")){t--;continue}break;case"delimiter":t--;break}break}return r.slice(0,t)},Qf=r=>{let i=[];return r.map(e=>{e.type==="brace"&&(e.value==="{"?i.push("}"):i.splice(i.lastIndexOf("}"),1)),e.type==="paren"&&(e.value==="["?i.push("]"):i.splice(i.lastIndexOf("]"),1))}),i.length>0&&i.reverse().map(e=>{e==="}"?r.push({type:"brace",value:"}"}):e==="]"&&r.push({type:"paren",value:"]"})}),r},Xf=r=>{let i="";return r.map(e=>{e.type==="string"?i+='"'+e.value+'"':i+=e.value}),i},Op=r=>JSON.parse(Xf(Qf(Yf(Jf(r)))));var mt="__json_buf";function Yo(r,i){let e={};for(let s of Object.keys(r))s!=="input"&&(e[s]=r[s]);Object.defineProperty(e,mt,{value:i,enumerable:!1,writable:!0});let t,n=!1;return Object.defineProperty(e,"input",{enumerable:!0,configurable:!0,get(){return n||(t=i?Op(i):{},n=!0),t}}),e}var me,gt,We,ls,Qo,us,ds,Xo,ps,je,hs,Zo,ec,Mt,tc,rc,ic,_s,Ke,pe,fs,tu,Np,ms,ru,iu,nu,Mp,su;function au(r){return r.type==="tool_use"||r.type==="server_tool_use"||r.type==="mcp_tool_use"}var Cr=(()=>{class r{constructor(e,t){me.add(this),this.messages=[],this.receivedMessages=[],gt.set(this,void 0),We.set(this,null),this.controller=new AbortController,ls.set(this,void 0),Qo.set(this,()=>{}),us.set(this,()=>{}),ds.set(this,void 0),Xo.set(this,()=>{}),ps.set(this,()=>{}),je.set(this,{}),hs.set(this,!1),Zo.set(this,!1),ec.set(this,!1),Mt.set(this,!1),tc.set(this,void 0),rc.set(this,void 0),ic.set(this,void 0),_s.set(this,void 0),Ke.set(this,void 0),pe.set(this,void 0),fs.set(this,void 0),ms.set(this,n=>{if(b(this,Zo,!0,"f"),o(this,pe,"f")&&(o(this,pe,"f").streamed=void 0),de(n)&&(n=new ee),n instanceof ee)return b(this,ec,!0,"f"),this._emit("abort",n);if(n instanceof S)return this._emit("error",n);if(n instanceof Error){let s=new S(n.message);return s.cause=n,this._emit("error",s)}return this._emit("error",new S(String(n)))}),b(this,ls,new Promise((n,s)=>{b(this,Qo,n,"f"),b(this,us,s,"f")}),"f"),b(this,ds,new Promise((n,s)=>{b(this,Xo,n,"f"),b(this,ps,s,"f")}),"f"),o(this,ls,"f").catch(()=>{}),o(this,ds,"f").catch(()=>{}),b(this,We,e,"f"),b(this,_s,t?.logger??console,"f"),b(this,Ke,t?.client,"f")}get response(){return o(this,tc,"f")}get request_id(){return o(this,rc,"f")}get workspace_id(){return o(this,ic,"f")}async withResponse(){b(this,Mt,!0,"f");let e=await o(this,ls,"f");if(!e)throw new Error("Could not resolve a `Response` object");return{data:this,response:e,request_id:e.headers.get("request-id"),workspace_id:e.headers.get("anthropic-workspace-id")}}static fromReadableStream(e){let t=new r(null);return t._run(()=>t._fromReadableStream(e)),t}static createMessage(e,t,n,{logger:s,client:a}={}){let l=new r(t,{logger:s,client:a});for(let p of t.messages)l._addMessageParam(p);return b(l,We,{...t,stream:!0},"f"),l._run(()=>l._createMessage((p,h)=>e.create(p,h),{...t,stream:!0},{...n,headers:{...n?.headers,[tr]:"stream"}})),l}_start(e,t,n,s){for(let p of t.messages)this._addMessageParam(p);let a=o(this,Ke,"f");b(this,Ke,void 0,"f");let l=(p,h)=>e(p,h)._thenUnwrap((m,{options:_})=>(b(this,Ke,a,"f"),b(this,pe,_.__span,"f"),b(this,fs,_.body,"f"),m));this._run(()=>this._createMessage(l,{...t,stream:!0},n).finally(s))}_run(e){e().then(()=>{this._emitFinal(),this._emit("end")},o(this,ms,"f"))}_addMessageParam(e){this.messages.push(e)}_addMessage(e,t=!0){this.receivedMessages.push(e),t&&this._emit("message",e)}async _createMessage(e,t,n){let s=n?.signal,a;s&&(s.aborted&&this.controller.abort(),a=this.controller.abort.bind(this.controller),s.addEventListener("abort",a));try{o(this,me,"m",ru).call(this),b(this,pe,n?.__span??(o(this,Ke,"f")&&zp(o(this,Ke,"f"),t,n)),"f");let{response:l,data:p}=await e({...t,stream:!0},{...n,__span:o(this,pe,"f"),signal:this.controller.signal}).withResponse();try{this._connected(l)}catch(h){throw o(this,pe,"f")&&(o(this,pe,"f").failure=h),p.controller.abort(),h}for await(let h of p)try{o(this,me,"m",iu).call(this,h)}catch(m){throw o(this,pe,"f")&&(o(this,pe,"f").failure=m),m}if(p.controller.signal?.aborted)throw new ee;o(this,me,"m",nu).call(this)}finally{s&&a&&s.removeEventListener("abort",a)}}_connected(e){this.ended||(b(this,tc,e,"f"),b(this,rc,e?.headers.get("request-id"),"f"),b(this,ic,e?.headers.get("anthropic-workspace-id"),"f"),o(this,Qo,"f").call(this,e),this._emit("connect"))}get ended(){return o(this,hs,"f")}get errored(){return o(this,Zo,"f")}get aborted(){return o(this,ec,"f")}abort(){this.controller.abort()}on(e,t){return(o(this,je,"f")[e]||(o(this,je,"f")[e]=[])).push({listener:t}),this}off(e,t){let n=o(this,je,"f")[e];if(!n)return this;let s=n.findIndex(a=>a.listener===t);return s>=0&&n.splice(s,1),this}once(e,t){return(o(this,je,"f")[e]||(o(this,je,"f")[e]=[])).push({listener:t,once:!0}),this}emitted(e){return new Promise((t,n)=>{b(this,Mt,!0,"f"),e!=="error"&&this.once("error",n),this.once(e,t)})}async done(){b(this,Mt,!0,"f"),await o(this,ds,"f")}get currentMessage(){return o(this,gt,"f")}async finalMessage(){return await this.done(),o(this,me,"m",tu).call(this)}async finalText(){return await this.done(),o(this,me,"m",Np).call(this)}_emit(e,...t){if(o(this,hs,"f"))return;e==="end"&&(b(this,hs,!0,"f"),o(this,Xo,"f").call(this));let n=o(this,je,"f")[e];if(n&&(o(this,je,"f")[e]=n.filter(s=>!s.once),n.forEach(({listener:s})=>s(...t))),e==="abort"){let s=t[0];!o(this,Mt,"f")&&!n?.length&&Promise.reject(s),o(this,us,"f").call(this,s),o(this,ps,"f").call(this,s),this._emit("end");return}if(e==="error"){let s=t[0];!o(this,Mt,"f")&&!n?.length&&Promise.reject(s),o(this,us,"f").call(this,s),o(this,ps,"f").call(this,s),this._emit("end")}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit("finalMessage",o(this,me,"m",tu).call(this))}_deliverEvent(e,t){this._emit("_rawEvent",e),t&&this._emit("streamEvent",e,t)}async _fromReadableStream(e,t){let n=t?.signal,s;n&&(n.aborted&&this.controller.abort(),s=this.controller.abort.bind(this.controller),n.addEventListener("abort",s));try{o(this,me,"m",ru).call(this),this._connected(null);let a=re.fromReadableStream(e,this.controller);for await(let l of a)o(this,me,"m",iu).call(this,l);if(a.controller.signal?.aborted)throw new ee;o(this,me,"m",nu).call(this)}finally{n&&s&&n.removeEventListener("abort",s)}}[(gt=new WeakMap,We=new WeakMap,ls=new WeakMap,Qo=new WeakMap,us=new WeakMap,ds=new WeakMap,Xo=new WeakMap,ps=new WeakMap,je=new WeakMap,hs=new WeakMap,Zo=new WeakMap,ec=new WeakMap,Mt=new WeakMap,tc=new WeakMap,rc=new WeakMap,ic=new WeakMap,_s=new WeakMap,Ke=new WeakMap,pe=new WeakMap,fs=new WeakMap,ms=new WeakMap,me=new WeakSet,tu=function(){if(this.receivedMessages.length===0)throw new S("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},Np=function(){if(this.receivedMessages.length===0)throw new S("stream ended without producing a Message with role=assistant");let t=this.receivedMessages.at(-1).content.filter(n=>n.type==="text").map(n=>n.text);if(t.length===0)throw new S("stream ended without producing a content block with type=text");return t.join(" ")},ru=function(){this.ended||b(this,gt,void 0,"f")},iu=function(t){if(this.ended)return;let n=o(this,me,"m",Mp).call(this,t);if(this._deliverEvent(t,n),!!n)switch(t.type){case"content_block_delta":{let s=n.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(au(s)&&o(this,je,"f").inputJson?.length){let a;try{a=s.input}catch(l){o(this,ms,"f").call(this,o(this,me,"m",su).call(this,s,l));break}this._emit("inputJson",t.delta.partial_json,a)}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":{o(this,Ke,"f")&&o(this,pe,"f")&&o(this,We,"f")&&er(o(this,Ke,"f"),o(this,pe,"f"),o(this,fs,"f")??o(this,We,"f"),n),this._addMessageParam(n),this._addMessage(Zl(n,o(this,We,"f"),{logger:o(this,_s,"f")}),!0);break}case"content_block_stop":{this._emit("contentBlock",n.content.at(-1));break}case"message_start":{b(this,gt,n,"f"),o(this,pe,"f")&&o(this,We,"f")&&(o(this,pe,"f").streamed={body:o(this,fs,"f")??o(this,We,"f"),message:n});break}case"content_block_start":case"message_delta":break}},nu=function(){if(this.ended)throw new S("stream has ended, this shouldn't happen");let t=o(this,gt,"f");if(!t)throw new S("request ended without sending any chunks");return b(this,gt,void 0,"f"),Zl(t,o(this,We,"f"),{logger:o(this,_s,"f")})},Mp=function(t){let n=o(this,gt,"f");if(t.type==="message_start"){if(n)throw new S(`Unexpected event order, got ${t.type} before receiving "message_stop"`);return t.message}if(n)switch(t.type){case"message_stop":return n;case"message_delta":return n.stop_reason=t.delta.stop_reason,n.stop_sequence=t.delta.stop_sequence,n.stop_details=t.delta.stop_details,n.usage.output_tokens=t.usage.output_tokens,t.delta.container!=null&&(n.container=t.delta.container),t.context_management!=null&&(n.context_management=t.context_management),t.input_transformations!=null&&(n.input_transformations=t.input_transformations),t.usage.input_tokens!=null&&(n.usage.input_tokens=t.usage.input_tokens),t.usage.cache_creation_input_tokens!=null&&(n.usage.cache_creation_input_tokens=t.usage.cache_creation_input_tokens),t.usage.cache_read_input_tokens!=null&&(n.usage.cache_read_input_tokens=t.usage.cache_read_input_tokens),t.usage.server_tool_use!=null&&(n.usage.server_tool_use=t.usage.server_tool_use),t.usage.iterations!=null&&(n.usage.iterations=t.usage.iterations),t.usage.fallback_credit!=null&&(n.usage.fallback_credit=t.usage.fallback_credit),t.usage.output_tokens_details!=null&&(n.usage.output_tokens_details=t.usage.output_tokens_details),n;case"content_block_start":return n.content.push(t.content_block),t.content_block.type==="fallback"&&(n.model=t.content_block.to.model),n;case"content_block_delta":{let s=n.content.at(t.index);switch(t.delta.type){case"text_delta":{s?.type==="text"&&(n.content[t.index]={...s,text:(s.text||"")+t.delta.text});break}case"citations_delta":{s?.type==="text"&&(n.content[t.index]={...s,citations:[...s.citations??[],t.delta.citation]});break}case"input_json_delta":{if(s&&au(s)){let a=(s[mt]||"")+t.delta.partial_json;n.content[t.index]=Yo(s,a)}break}case"thinking_delta":{s?.type==="thinking"&&(n.content[t.index]={...s,thinking:s.thinking+t.delta.thinking});break}case"signature_delta":{s?.type==="thinking"&&(n.content[t.index]={...s,signature:t.delta.signature});break}case"compaction_delta":{if(s?.type==="compaction"){let a={...s,content:t.delta.content};"encrypted_content"in t.delta&&(a.encrypted_content=t.delta.encrypted_content),n.content[t.index]=a}break}default:t.delta}return n}case"content_block_stop":{let s=n.content.at(t.index);if(s&&au(s)&&mt in s){let a;try{a=s.input}catch(l){a={},o(this,ms,"f").call(this,o(this,me,"m",su).call(this,s,l))}Object.defineProperty(s,"input",{value:a,enumerable:!0,configurable:!0,writable:!0})}return n}default:return n}},su=function(t,n){let s=t[mt];return new S(`Unable to parse tool parameter JSON from model. Please retry your request or adjust your prompt. Error: ${n}. JSON: ${s}`)},Symbol.asyncIterator)](){let e=[],t=[],n=!1;return this.on("_rawEvent",s=>{let a=t.shift();a?a.resolve(s):e.push(s)}),this.on("end",()=>{n=!0;for(let s of t)s.resolve(void 0);t.length=0}),this.on("abort",s=>{n=!0;for(let a of t)a.reject(s);t.length=0}),this.on("error",s=>{n=!0;for(let a of t)a.reject(s);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:n?{value:void 0,done:!0}:new Promise((a,l)=>t.push({resolve:a,reject:l})).then(a=>a?{value:a,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new re(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}return r})();var qp={browser_toolset_20260801:"browser",computer_toolset_20260801:"computer"};function bt(r){return qp[r.type]}function Ir(r){return"run"in r&&r.type!=null&&Object.prototype.hasOwnProperty.call(qp,r.type)}var ou=(()=>{class r extends S{constructor(e,t){super(e),t&&"cause"in t&&(this.cause=t.cause)}}return r._errorName="ToolsetUsageError",r})();var zr=(()=>{class r extends ou{}return r._errorName="ToolsetContractError",r})();var Lp="Not executed: an earlier action in this turn failed.",Bp={browser:Lp,computer:"Not executed: an earlier computer action in this turn failed."};function $p(r){return Object.prototype.hasOwnProperty.call(Bp,r)?Bp[r]:Lp}function gs(r,i,e=!1){return e&&(i===""||Array.isArray(i)&&i.length===0)&&(i="The tool call failed with an empty error message."),{type:"tool_result",tool_use_id:r.id,toolset_name:r.toolset_name??null,content:i,...e?{is_error:!0}:{}}}function Zf(r,i){if(r instanceof ou)throw r;em(i.signal)}function em(r){if(r?.aborted)throw new ee}async function Fp(r,i,e={}){let t=bt(r);if(i.toolset_name!==t)throw new zr(`tool_use ${JSON.stringify(i.id)} (toolset_name=${JSON.stringify(i.toolset_name??null)}, name=${JSON.stringify(i.name)}) is not a member call of the ${JSON.stringify(t)} toolset`);let n={...e,toolUse:i,toolUseBlock:i};try{return gs(i,await r.run(n,i))}catch(s){return Zf(s,n),gs(i,gp(s instanceof vr?s.content:fp(s)),!0)}}var Nr=class extends f{retrieve(i,e){return this._client.get(u`/v1/organizations/api_keys/${i}`,{...e,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.api_keys.retrieve",e,{route:"/v1/organizations/api_keys/{api_key_id}",attributes:{"anthropic.organization.api_key.id":i}})})}update(i,e,t){return this._client.post(u`/v1/organizations/api_keys/${i}`,{body:e,...t,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.api_keys.update",t,{route:"/v1/organizations/api_keys/{api_key_id}",attributes:{"anthropic.organization.api_key.id":i}})})}list(i={},e){return this._client.getAPIList("/v1/organizations/api_keys",U,{query:i,...e,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.api_keys.list",e,{route:"/v1/organizations/api_keys",queryParams:["after_id","before_id","created_by_user_id","limit","status","workspace_id"]})})}};var Mr=class extends f{list(i,e){return this._client.getAPIList("/v1/organizations/analytics/artifacts",w,{query:i,...e,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.analytics.artifacts.list",e,{route:"/v1/organizations/analytics/artifacts",queryParams:["date","filter","group_by","limit","page"]})})}};var qr=class extends f{list(i={},e){return this._client.getAPIList("/v1/organizations/analytics/connectors",w,{query:i,...e,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.analytics.connectors.list",e,{route:"/v1/organizations/analytics/connectors",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"],contentQueryParams:["filter"]})})}};var Br=class extends f{list(i,e){let{betas:t,...n}=i;return this._client.getAPIList("/v1/organizations/analytics/cost",_e,{query:n,...e,headers:d([{"anthropic-beta":[...t??[],"analytics-usage-cost-2026-08-24"].toString()},e?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.analytics.cost.list",e,{route:"/v1/organizations/analytics/cost",queryParams:["actor_ids","actor_types","agent_ids","api_key_ids","claude_tag_categories","claude_tag_user_ids","context_windows","deployment_ids","ending_at","environment_ids","exclude_deleted_users","group_by","inference_geos","limit","models","order","order_by","organization_ids","page","products","rbac_group_ids","service_tiers","session_ids","slack_channel_ids","speeds","starting_at","time_bucket_width","user_profile_ids","workspace_ids"]})})}};var Lr=class extends f{list(i,e){return this._client.getAPIList("/v1/organizations/analytics/cost_report",_e,{query:i,...e,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.analytics.cost_report.list",e,{route:"/v1/organizations/analytics/cost_report",queryParams:["bucket_width","claude_tag_categories","claude_tag_user_ids","context_windows","ending_at","group_by","inference_geos","limit","models","page","products","rbac_group_ids","slack_channel_ids","speeds","starting_at","user_ids"]})})}};var $r=class extends f{list(i={},e){return this._client.getAPIList("/v1/organizations/analytics/plugins",w,{query:i,...e,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.analytics.plugins.list",e,{route:"/v1/organizations/analytics/plugins",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"],contentQueryParams:["filter"]})})}};var Fr=class extends f{list(i={},e){return this._client.getAPIList("/v1/organizations/analytics/skills",w,{query:i,...e,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.analytics.skills.list",e,{route:"/v1/organizations/analytics/skills",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"],contentQueryParams:["filter"]})})}};var Ur=class extends f{list(i,e){return this._client.getAPIList("/v1/organizations/analytics/summaries",w,{query:i,...e,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.analytics.summaries.list",e,{route:"/v1/organizations/analytics/summaries",queryParams:["ending_date","filter","limit","page","starting_date"]})})}};var Hr=class extends f{list(i,e){let{betas:t,...n}=i;return this._client.getAPIList("/v1/organizations/analytics/usage",_e,{query:n,...e,headers:d([{"anthropic-beta":[...t??[],"analytics-usage-cost-2026-08-24"].toString()},e?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.analytics.usage.list",e,{route:"/v1/organizations/analytics/usage",queryParams:["actor_ids","actor_types","agent_ids","api_key_ids","claude_tag_categories","claude_tag_user_ids","context_windows","deployment_ids","ending_at","environment_ids","exclude_deleted_users","group_by","inference_geos","limit","models","order","order_by","organization_ids","page","products","rbac_group_ids","service_tiers","session_ids","slack_channel_ids","speeds","starting_at","time_bucket_width","user_profile_ids","workspace_ids"]})})}};var Wr=class extends f{list(i,e){return this._client.getAPIList("/v1/organizations/analytics/usage_report",_e,{query:i,...e,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.analytics.usage_report.list",e,{route:"/v1/organizations/analytics/usage_report",queryParams:["bucket_width","claude_tag_categories","claude_tag_user_ids","context_windows","ending_at","group_by","inference_geos","limit","models","page","products","rbac_group_ids","slack_channel_ids","speeds","starting_at","user_ids"]})})}};var jr=class extends f{list(i,e){return this._client.getAPIList("/v1/organizations/analytics/user_cost_report",_e,{query:i,...e,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.analytics.user_cost_report.list",e,{route:"/v1/organizations/analytics/user_cost_report",queryParams:["bucket_width","claude_tag_categories","claude_tag_user_ids","context_windows","ending_at","exclude_deleted_users","group_by","inference_geos","limit","models","order","order_by","page","products","rbac_group_ids","slack_channel_ids","speeds","starting_at","user_ids"]})})}};var Kr=class extends f{list(i,e){return this._client.getAPIList("/v1/organizations/analytics/user_usage_report",_e,{query:i,...e,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.analytics.user_usage_report.list",e,{route:"/v1/organizations/analytics/user_usage_report",queryParams:["bucket_width","claude_tag_categories","claude_tag_user_ids","context_windows","ending_at","exclude_deleted_users","group_by","inference_geos","limit","models","order","order_by","page","products","rbac_group_ids","slack_channel_ids","speeds","starting_at","user_ids"]})})}};var Dr=class extends f{list(i={},e){return this._client.getAPIList("/v1/organizations/analytics/users",w,{query:i,...e,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.analytics.users.list",e,{route:"/v1/organizations/analytics/users",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"],contentQueryParams:["page"]})})}};var Vr=class extends f{list(i={},e){return this._client.getAPIList("/v1/organizations/analytics/apps/chat/projects",w,{query:i,...e,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.analytics.apps.chat.projects.list",e,{route:"/v1/organizations/analytics/apps/chat/projects",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"]})})}};var sc=(()=>{class r extends f{constructor(){super(...arguments),this.projects=new Vr(this._client)}}return r.Projects=Vr,r})();var ac=(()=>{class r extends f{constructor(){super(...arguments),this.chat=new sc(this._client)}}return r.Chat=sc,r})();var oc=(()=>{class r extends f{constructor(){super(...arguments),this.summaries=new Ur(this._client),this.users=new Dr(this._client),this.apps=new ac(this._client),this.connectors=new qr(this._client),this.plugins=new $r(this._client),this.skills=new Fr(this._client),this.artifacts=new Mr(this._client),this.usage=new Hr(this._client),this.cost=new Br(this._client),this.usageReport=new Wr(this._client),this.userUsageReport=new Kr(this._client),this.costReport=new Lr(this._client),this.userCostReport=new jr(this._client)}}return r.Summaries=Ur,r.Users=Dr,r.Apps=ac,r.Connectors=qr,r.Plugins=$r,r.Skills=Fr,r.Artifacts=Mr,r.Usage=Hr,r.Cost=Br,r.UsageReport=Wr,r.UserUsageReport=Kr,r.CostReport=Lr,r.UserCostReport=jr,r})();var bs=(()=>{class r extends R{}return r._errorName="BetaCannotSignOutPrimaryOwnerError",r})(),ys=(()=>{class r extends R{}return r._errorName="BetaCannotSignOutSelfError",r})(),ws=(()=>{class r extends G{}return r._errorName="BetaCannotSignOutManagedMemberError",r})(),vs=(()=>{class r extends G{}return r._errorName="BetaCannotSignOutMembershipAdminError",r})(),ks=(()=>{class r extends G{}return r._errorName="BetaCannotSignOutOwnerError",r})(),Es=(()=>{class r extends G{}return r._errorName="BetaCannotSignOutPrivilegedMemberError",r})(),cc=(()=>{class r extends f{retrieve(e,t){return this._client.get(u`/v1/organizations/users/${e}`,{...t,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.users.retrieve",t,{route:"/v1/organizations/users/{user_id}",attributes:{"anthropic.organization.user.id":e}})})}update(e,t,n){return this._client.post(u`/v1/organizations/users/${e}`,{body:t,...n,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.users.update",n,{route:"/v1/organizations/users/{user_id}",attributes:{"anthropic.organization.user.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/users",U,{query:e,...t,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.users.list",t,{route:"/v1/organizations/users",queryParams:["after_id","before_id","email","limit","roles"]})})}remove(e,t){return this._client.delete(u`/v1/organizations/users/${e}`,{...t,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.users.remove",t,{route:"/v1/organizations/users/{user_id}",attributes:{"anthropic.organization.user.id":e}})})}signOut(e,t={},n){let{betas:s}=t??{};return this._client.post(u`/v1/organizations/users/${e}/sign_out`,{...n,headers:d([{"anthropic-beta":[...s??[],"admin-user-sign-out-2026-10-08"].toString()},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.users.sign_out",n,{route:"/v1/organizations/users/{user_id}/sign_out",attributes:{"anthropic.organization.user.id":e}})})}}return r.BetaCannotSignOutPrimaryOwnerError=bs,r.BetaCannotSignOutSelfError=ys,r.BetaCannotSignOutManagedMemberError=ws,r.BetaCannotSignOutMembershipAdminError=vs,r.BetaCannotSignOutOwnerError=ks,r.BetaCannotSignOutPrivilegedMemberError=Es,r})();var Gr=class extends f{list(i,e={},t){let{betas:n,...s}=e??{};return this._client.getAPIList(u`/v1/organizations/plugins/${i}/installation_settings`,w,{query:s,...t,headers:d([{"anthropic-beta":[...n??[],"ce-plugins-2026-09-01"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.plugins.installation_settings.list",t,{route:"/v1/organizations/plugins/{plugin_id}/installation_settings",queryParams:["limit","organization_id","page","target_type"],attributes:{"anthropic.organization.plugin.id":i}})})}remove(i,e,t){let{plugin_id:n,betas:s}=e;return this._client.delete(u`/v1/organizations/plugins/${n}/installation_settings/${i}`,{...t,headers:d([{"anthropic-beta":[...s??[],"ce-plugins-2026-09-01"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.plugins.installation_settings.remove",t,{route:"/v1/organizations/plugins/{plugin_id}/installation_settings/{target}",attributes:{"anthropic.organization.plugin.id":n,"anthropic.organization.plugin.installation_setting.id":i}})})}set(i,e,t){let{plugin_id:n,betas:s,...a}=e;return this._client.post(u`/v1/organizations/plugins/${n}/installation_settings/${i}`,{body:a,...t,headers:d([{"anthropic-beta":[...s??[],"ce-plugins-2026-09-01"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.plugins.installation_settings.set",t,{route:"/v1/organizations/plugins/{plugin_id}/installation_settings/{target}",attributes:{"anthropic.organization.plugin.id":n,"anthropic.organization.plugin.installation_setting.id":i}})})}};var Jr=class extends f{list(i,e={},t){let{betas:n,...s}=e??{};return this._client.getAPIList(u`/v1/organizations/plugins/${i}/shares`,w,{query:s,...t,headers:d([{"anthropic-beta":[...n??[],"ce-plugins-2026-09-01"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.plugins.shares.list",t,{route:"/v1/organizations/plugins/{plugin_id}/shares",queryParams:["limit","organization_id","page","target_type"],attributes:{"anthropic.organization.plugin.id":i}})})}};var Yr=class extends f{create(i,e,t){let{betas:n,...s}=e;return this._client.post(u`/v1/organizations/plugins/${i}/versions`,ie({body:s,...t,headers:d([{"anthropic-beta":[...n??[],"ce-plugins-2026-09-01"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.plugins.versions.create",t,{route:"/v1/organizations/plugins/{plugin_id}/versions",attributes:{"anthropic.organization.plugin.id":i},createdIDAttribute:"anthropic.organization.plugin.version.id"})},this._client))}retrieve(i,e,t){let{plugin_id:n,betas:s,...a}=e;return this._client.get(u`/v1/organizations/plugins/${n}/versions/${i}`,{query:a,...t,headers:d([{"anthropic-beta":[...s??[],"ce-plugins-2026-09-01"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.plugins.versions.retrieve",t,{route:"/v1/organizations/plugins/{plugin_id}/versions/{version}",queryParams:["organization_id"],attributes:{"anthropic.organization.plugin.id":n,"anthropic.organization.plugin.version.id":i}})})}list(i,e={},t){let{betas:n,...s}=e??{};return this._client.getAPIList(u`/v1/organizations/plugins/${i}/versions`,w,{query:s,...t,headers:d([{"anthropic-beta":[...n??[],"ce-plugins-2026-09-01"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.plugins.versions.list",t,{route:"/v1/organizations/plugins/{plugin_id}/versions",queryParams:["limit","organization_id","page"],attributes:{"anthropic.organization.plugin.id":i}})})}download(i,e,t){let{plugin_id:n,betas:s,...a}=e;return this._client.get(u`/v1/organizations/plugins/${n}/versions/${i}/content`,{query:a,...t,headers:d([{"anthropic-beta":[...s??[],"ce-plugins-2026-09-01"].toString(),Accept:"application/binary"},t?.headers]),__qualifiers:{beta:"true"},__binaryResponse:!0,__span:c(this._client,"anthropic.organization.plugins.versions.download",t,{route:"/v1/organizations/plugins/{plugin_id}/versions/{version}/content",queryParams:["organization_id"],attributes:{"anthropic.organization.plugin.id":n,"anthropic.organization.plugin.version.id":i}})})}};var Ss=(()=>{class r extends R{}return r._errorName="BetaScanFailedError",r})(),As=(()=>{class r extends le{}return r._errorName="BetaPluginNameTakenError",r})(),xs=(()=>{class r extends le{}return r._errorName="BetaScanPendingError",r})(),Ps=(()=>{class r extends le{}return r._errorName="BetaSkillNameTakenError",r})(),Ts=(()=>{class r extends Qe{}return r._errorName="BetaRegistrationPendingError",r})(),lc=(()=>{class r extends f{constructor(){super(...arguments),this.versions=new Yr(this._client),this.installationSettings=new Gr(this._client),this.shares=new Jr(this._client)}create(e,t){let{betas:n,...s}=e;return this._client.post("/v1/organizations/plugins",ie({body:s,...t,headers:d([{"anthropic-beta":[...n??[],"ce-plugins-2026-09-01"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.plugins.create",t,{route:"/v1/organizations/plugins",createdIDAttribute:"anthropic.organization.plugin.id"})},this._client))}retrieve(e,t={},n){let{betas:s,...a}=t??{};return this._client.get(u`/v1/organizations/plugins/${e}`,{query:a,...n,headers:d([{"anthropic-beta":[...s??[],"ce-plugins-2026-09-01"].toString()},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.plugins.retrieve",n,{route:"/v1/organizations/plugins/{plugin_id}",queryParams:["organization_id"],attributes:{"anthropic.organization.plugin.id":e}})})}update(e,t,n){let{betas:s,...a}=t;return this._client.post(u`/v1/organizations/plugins/${e}`,{body:a,...n,headers:d([{"anthropic-beta":[...s??[],"ce-plugins-2026-09-01"].toString()},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.plugins.update",n,{route:"/v1/organizations/plugins/{plugin_id}",attributes:{"anthropic.organization.plugin.id":e}})})}list(e={},t){let{betas:n,...s}=e??{};return this._client.getAPIList("/v1/organizations/plugins",w,{query:s,...t,headers:d([{"anthropic-beta":[...n??[],"ce-plugins-2026-09-01"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.plugins.list",t,{route:"/v1/organizations/plugins",queryParams:["created_at[gt]","created_at[gte]","created_at[lt]","created_at[lte]","limit","marketplace_id","organization_id","owner_type","owner_user_id","page"]})})}delete(e,t={},n){let{betas:s}=t??{};return this._client.delete(u`/v1/organizations/plugins/${e}`,{...n,headers:d([{"anthropic-beta":[...s??[],"ce-plugins-2026-09-01"].toString()},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.plugins.delete",n,{route:"/v1/organizations/plugins/{plugin_id}",attributes:{"anthropic.organization.plugin.id":e}})})}}return r.BetaScanFailedError=Ss,r.BetaPluginNameTakenError=As,r.BetaScanPendingError=xs,r.BetaSkillNameTakenError=Ps,r.BetaRegistrationPendingError=Ts,r.Versions=Yr,r.InstallationSettings=Gr,r.Shares=Jr,r})();var Qr=class extends f{create(i,e){let{betas:t,...n}=i;return this._client.post("/v1/organizations/claude_tag/slack_channels",{body:n,...e,headers:d([{"anthropic-beta":[...t??[],"experimental-claude-tag-2026-10-21"].toString()},e?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.claude_tag.slack_channels.create",e,{route:"/v1/organizations/claude_tag/slack_channels",createdIDAttribute:"anthropic.organization.claude_tag.slack_channel.id"})})}retrieve(i,e={},t){let{betas:n,...s}=e??{};return this._client.get(u`/v1/organizations/claude_tag/slack_channels/${i}`,{query:s,...t,headers:d([{"anthropic-beta":[...n??[],"experimental-claude-tag-2026-10-21"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.claude_tag.slack_channels.retrieve",t,{route:"/v1/organizations/claude_tag/slack_channels/{id}",queryParams:["include_inherited"],attributes:{"anthropic.organization.claude_tag.slack_channel.id":i}})})}update(i,e,t){let{betas:n,...s}=e;return this._client.post(u`/v1/organizations/claude_tag/slack_channels/${i}`,{body:s,...t,headers:d([{"anthropic-beta":[...n??[],"experimental-claude-tag-2026-10-21"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.claude_tag.slack_channels.update",t,{route:"/v1/organizations/claude_tag/slack_channels/{id}",attributes:{"anthropic.organization.claude_tag.slack_channel.id":i}})})}list(i,e){let{betas:t,...n}=i;return this._client.getAPIList("/v1/organizations/claude_tag/slack_channels",w,{query:n,...e,headers:d([{"anthropic-beta":[...t??[],"experimental-claude-tag-2026-10-21"].toString()},e?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.claude_tag.slack_channels.list",e,{route:"/v1/organizations/claude_tag/slack_channels",queryParams:["include_inherited","limit","page","slack_channel_id","slack_workspace_id"]})})}delete(i,e={},t){let{betas:n}=e??{};return this._client.delete(u`/v1/organizations/claude_tag/slack_channels/${i}`,{...t,headers:d([{"anthropic-beta":[...n??[],"experimental-claude-tag-2026-10-21"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.claude_tag.slack_channels.delete",t,{route:"/v1/organizations/claude_tag/slack_channels/{id}",attributes:{"anthropic.organization.claude_tag.slack_channel.id":i}})})}};var Xr=class extends f{retrieve(i,e={},t){let{betas:n,...s}=e??{};return this._client.get(u`/v1/organizations/claude_tag/slack_workspaces/${i}`,{query:s,...t,headers:d([{"anthropic-beta":[...n??[],"experimental-claude-tag-2026-10-21"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.claude_tag.slack_workspaces.retrieve",t,{route:"/v1/organizations/claude_tag/slack_workspaces/{id}",queryParams:["include_inherited"],attributes:{"anthropic.organization.claude_tag.slack_workspace.id":i}})})}update(i,e,t){let{betas:n,...s}=e;return this._client.post(u`/v1/organizations/claude_tag/slack_workspaces/${i}`,{body:s,...t,headers:d([{"anthropic-beta":[...n??[],"experimental-claude-tag-2026-10-21"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.claude_tag.slack_workspaces.update",t,{route:"/v1/organizations/claude_tag/slack_workspaces/{id}",attributes:{"anthropic.organization.claude_tag.slack_workspace.id":i}})})}list(i={},e){let{betas:t,...n}=i??{};return this._client.getAPIList("/v1/organizations/claude_tag/slack_workspaces",w,{query:n,...e,headers:d([{"anthropic-beta":[...t??[],"experimental-claude-tag-2026-10-21"].toString()},e?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.claude_tag.slack_workspaces.list",e,{route:"/v1/organizations/claude_tag/slack_workspaces",queryParams:["include_inherited","limit","page","slack_workspace_id"]})})}};var Zr=class extends f{create(i,e,t){let{target:n,betas:s}=e;return this._client.post(u`/v1/organizations/claude_tag/bundles/${i}/targets`,{body:n,...t,headers:d([{"anthropic-beta":[...s??[],"experimental-claude-tag-2026-10-21"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.claude_tag.bundles.targets.create",t,{route:"/v1/organizations/claude_tag/bundles/{bundle_id}/targets",attributes:{"anthropic.organization.claude_tag.bundle.id":i}})})}retrieve(i,e,t){let{bundle_id:n,betas:s}=e;return this._client.get(u`/v1/organizations/claude_tag/bundles/${n}/targets/${i}`,{...t,headers:d([{"anthropic-beta":[...s??[],"experimental-claude-tag-2026-10-21"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.claude_tag.bundles.targets.retrieve",t,{route:"/v1/organizations/claude_tag/bundles/{bundle_id}/targets/{target_id}",attributes:{"anthropic.organization.claude_tag.bundle.id":n,"anthropic.organization.claude_tag.bundle.target.id":i}})})}list(i,e={},t){let{betas:n,...s}=e??{};return this._client.getAPIList(u`/v1/organizations/claude_tag/bundles/${i}/targets`,w,{query:s,...t,headers:d([{"anthropic-beta":[...n??[],"experimental-claude-tag-2026-10-21"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.claude_tag.bundles.targets.list",t,{route:"/v1/organizations/claude_tag/bundles/{bundle_id}/targets",queryParams:["limit","page"],attributes:{"anthropic.organization.claude_tag.bundle.id":i}})})}delete(i,e,t){let{bundle_id:n,betas:s}=e;return this._client.delete(u`/v1/organizations/claude_tag/bundles/${n}/targets/${i}`,{...t,headers:d([{"anthropic-beta":[...s??[],"experimental-claude-tag-2026-10-21"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.claude_tag.bundles.targets.delete",t,{route:"/v1/organizations/claude_tag/bundles/{bundle_id}/targets/{target_id}",attributes:{"anthropic.organization.claude_tag.bundle.id":n,"anthropic.organization.claude_tag.bundle.target.id":i}})})}};var uc=(()=>{class r extends f{constructor(){super(...arguments),this.targets=new Zr(this._client)}retrieve(e,t={},n){let{betas:s}=t??{};return this._client.get(u`/v1/organizations/claude_tag/bundles/${e}`,{...n,headers:d([{"anthropic-beta":[...s??[],"experimental-claude-tag-2026-10-21"].toString()},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.claude_tag.bundles.retrieve",n,{route:"/v1/organizations/claude_tag/bundles/{bundle_id}",attributes:{"anthropic.organization.claude_tag.bundle.id":e}})})}list(e={},t){let{betas:n,...s}=e??{};return this._client.getAPIList("/v1/organizations/claude_tag/bundles",w,{query:s,...t,headers:d([{"anthropic-beta":[...n??[],"experimental-claude-tag-2026-10-21"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.claude_tag.bundles.list",t,{route:"/v1/organizations/claude_tag/bundles",queryParams:["limit","page"]})})}}return r.Targets=Zr,r})();var Rs=(()=>{class r extends R{}return r._errorName="BetaSlackChannelSetUpSettingsRefusedError",r})(),Cs=(()=>{class r extends G{}return r._errorName="BetaAPIKeyScopeMissingError",r})(),Is=(()=>{class r extends G{}return r._errorName="BetaClaudeTagWritesNotEnabledError",r})(),zs=(()=>{class r extends G{}return r._errorName="BetaComplianceConfigurationRestrictedError",r})(),Os=(()=>{class r extends G{}return r._errorName="BetaOrganizationLevelScopedAPIKeyRequiredError",r})(),Ns=(()=>{class r extends Re{}return r._errorName="BetaSlackChannelSetUpEnvironmentNotFoundError",r})(),Ms=(()=>{class r extends le{}return r._errorName="BetaSlackChannelSetUpSettingsConflictError",r})(),dc=(()=>{class r extends f{constructor(){super(...arguments),this.slackChannels=new Qr(this._client),this.slackWorkspaces=new Xr(this._client),this.bundles=new uc(this._client)}}return r.BetaSlackChannelSetUpSettingsRefusedError=Rs,r.BetaAPIKeyScopeMissingError=Cs,r.BetaClaudeTagWritesNotEnabledError=Is,r.BetaComplianceConfigurationRestrictedError=zs,r.BetaOrganizationLevelScopedAPIKeyRequiredError=Os,r.BetaSlackChannelSetUpEnvironmentNotFoundError=Ns,r.BetaSlackChannelSetUpSettingsConflictError=Ms,r.SlackChannels=Qr,r.SlackWorkspaces=Xr,r.Bundles=uc,r})();var ei=class extends f{list(i={},e){return this._client.getAPIList("/v1/organizations/spend_limits/effective",w,{query:i,...e,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.spend_limits.effective.list",e,{route:"/v1/organizations/spend_limits/effective",queryParams:["limit","page","period","user_ids"]})})}};var ti=class extends f{retrieve(i,e){return this._client.get(u`/v1/organizations/spend_limit_increase_requests/${i}`,{...e,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.spend_limits.increase_requests.retrieve",e,{route:"/v1/organizations/spend_limit_increase_requests/{spend_limit_increase_request_id}",attributes:{"anthropic.organization.spend_limit_increase_request.id":i}})})}list(i={},e){return this._client.getAPIList("/v1/organizations/spend_limit_increase_requests",w,{query:i,...e,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.spend_limits.increase_requests.list",e,{route:"/v1/organizations/spend_limit_increase_requests",queryParams:["actor_ids","limit","page","status"]})})}approve(i,e,t){return this._client.post(u`/v1/organizations/spend_limit_increase_requests/${i}/approve`,{body:e,...t,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.spend_limits.increase_requests.approve",t,{route:"/v1/organizations/spend_limit_increase_requests/{spend_limit_increase_request_id}/approve",attributes:{"anthropic.organization.spend_limit_increase_request.id":i}})})}deny(i,e,t){return this._client.post(u`/v1/organizations/spend_limit_increase_requests/${i}/deny`,{body:e,...t,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.spend_limits.increase_requests.deny",t,{route:"/v1/organizations/spend_limit_increase_requests/{spend_limit_increase_request_id}/deny",attributes:{"anthropic.organization.spend_limit_increase_request.id":i}})})}};var qs=(()=>{class r extends G{}return r._errorName="BetaSpendLimitsAdminAPIWritesNotEnabledError",r})(),pc=(()=>{class r extends f{constructor(){super(...arguments),this.effective=new ei(this._client),this.increaseRequests=new ti(this._client)}retrieve(e,t){return this._client.get(u`/v1/organizations/spend_limits/${e}`,{...t,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.spend_limits.retrieve",t,{route:"/v1/organizations/spend_limits/{spend_limit_id}",attributes:{"anthropic.organization.spend_limit.id":e}})})}list(e={},t){let{betas:n,...s}=e??{};return this._client.getAPIList("/v1/organizations/spend_limits",w,{query:s,...t,headers:d([{"anthropic-beta":[...n??[],"spend-limit-reads-2026-09-26"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.spend_limits.list",t,{route:"/v1/organizations/spend_limits",queryParams:["limit","page","scope_type","workspace_id"]})})}delete(e,t){return this._client.delete(u`/v1/organizations/spend_limits/${e}`,{...t,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.spend_limits.delete",t,{route:"/v1/organizations/spend_limits/{spend_limit_id}",attributes:{"anthropic.organization.spend_limit.id":e}})})}set(e,t){let{betas:n,...s}=e;return this._client.post("/v1/organizations/spend_limits",{body:s,...t,headers:d([{...n?.toString()!=null?{"anthropic-beta":n?.toString()}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.spend_limits.set",t,{route:"/v1/organizations/spend_limits",createdIDAttribute:"anthropic.organization.spend_limit.id"})})}}return r.BetaSpendLimitsAdminAPIWritesNotEnabledError=qs,r.Effective=ei,r.IncreaseRequests=ti,r})();var ri=class extends f{retrieve(i){return this._client.get("/v1/organizations/compliance_settings",{...i,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.compliance_settings.retrieve",i,{route:"/v1/organizations/compliance_settings"})})}update(i,e){return this._client.post("/v1/organizations/compliance_settings",{body:i,...e,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.compliance_settings.update",e,{route:"/v1/organizations/compliance_settings"})})}};var ii=class extends f{create(i,e){return this._client.post("/v1/organizations/external_keys",{body:i,...e,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.external_keys.create",e,{route:"/v1/organizations/external_keys",createdIDAttribute:"anthropic.organization.external_key.id"})})}retrieve(i,e){return this._client.get(u`/v1/organizations/external_keys/${i}`,{...e,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.external_keys.retrieve",e,{route:"/v1/organizations/external_keys/{external_key_id}",attributes:{"anthropic.organization.external_key.id":i}})})}update(i,e,t){return this._client.post(u`/v1/organizations/external_keys/${i}`,{body:e,...t,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.external_keys.update",t,{route:"/v1/organizations/external_keys/{external_key_id}",attributes:{"anthropic.organization.external_key.id":i}})})}list(i={},e){return this._client.getAPIList("/v1/organizations/external_keys",w,{query:i,...e,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.external_keys.list",e,{route:"/v1/organizations/external_keys",queryParams:["limit","page"]})})}delete(i,e){return this._client.delete(u`/v1/organizations/external_keys/${i}`,{...e,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.external_keys.delete",e,{route:"/v1/organizations/external_keys/{external_key_id}",attributes:{"anthropic.organization.external_key.id":i}})})}validate(i,e){return this._client.post(u`/v1/organizations/external_keys/${i}/validate`,{...e,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.external_keys.validate",e,{route:"/v1/organizations/external_keys/{external_key_id}/validate",attributes:{"anthropic.organization.external_key.id":i}})})}};var ni=class extends f{create(i,e){let{betas:t,...n}=i;return this._client.post("/v1/organizations/federation_issuers",{body:n,...e,headers:d([{...t?.toString()!=null?{"anthropic-beta":t?.toString()}:void 0},e?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.federation.issuers.create",e,{route:"/v1/organizations/federation_issuers",createdIDAttribute:"anthropic.organization.federation_issuer.id"})})}retrieve(i,e={},t){let{betas:n}=e??{};return this._client.get(u`/v1/organizations/federation_issuers/${i}`,{...t,headers:d([{...n?.toString()!=null?{"anthropic-beta":n?.toString()}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.federation.issuers.retrieve",t,{route:"/v1/organizations/federation_issuers/{federation_issuer_id}",attributes:{"anthropic.organization.federation_issuer.id":i}})})}update(i,e,t){let{betas:n,...s}=e;return this._client.post(u`/v1/organizations/federation_issuers/${i}`,{body:s,...t,headers:d([{...n?.toString()!=null?{"anthropic-beta":n?.toString()}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.federation.issuers.update",t,{route:"/v1/organizations/federation_issuers/{federation_issuer_id}",attributes:{"anthropic.organization.federation_issuer.id":i}})})}list(i={},e){let{betas:t,...n}=i??{};return this._client.getAPIList("/v1/organizations/federation_issuers",w,{query:n,...e,headers:d([{...t?.toString()!=null?{"anthropic-beta":t?.toString()}:void 0},e?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.federation.issuers.list",e,{route:"/v1/organizations/federation_issuers",queryParams:["include_archived","limit","page"]})})}archive(i,e={},t){let{betas:n}=e??{};return this._client.post(u`/v1/organizations/federation_issuers/${i}/archive`,{...t,headers:d([{...n?.toString()!=null?{"anthropic-beta":n?.toString()}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.federation.issuers.archive",t,{route:"/v1/organizations/federation_issuers/{federation_issuer_id}/archive",attributes:{"anthropic.organization.federation_issuer.id":i}})})}};var si=class extends f{list(i,e={},t){let{betas:n,...s}=e??{};return this._client.getAPIList(u`/v1/organizations/federation_rules/${i}/workspaces`,w,{query:s,...t,headers:d([{...n?.toString()!=null?{"anthropic-beta":n?.toString()}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.federation.rules.workspaces.list",t,{route:"/v1/organizations/federation_rules/{federation_rule_id}/workspaces",queryParams:["limit","page"],attributes:{"anthropic.organization.federation_rule.id":i}})})}add(i,e,t){let{betas:n,...s}=e;return this._client.post(u`/v1/organizations/federation_rules/${i}/workspaces`,{body:s,...t,headers:d([{...n?.toString()!=null?{"anthropic-beta":n?.toString()}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.federation.rules.workspaces.add",t,{route:"/v1/organizations/federation_rules/{federation_rule_id}/workspaces",attributes:{"anthropic.organization.federation_rule.id":i},createdIDAttribute:"anthropic.organization.federation_rule.workspace.id",createdIDField:"workspace_id"})})}remove(i,e,t){let{federation_rule_id:n,betas:s}=e;return this._client.delete(u`/v1/organizations/federation_rules/${n}/workspaces/${i}`,{...t,headers:d([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.federation.rules.workspaces.remove",t,{route:"/v1/organizations/federation_rules/{federation_rule_id}/workspaces/{workspace_id}",attributes:{"anthropic.organization.federation_rule.id":n,"anthropic.organization.federation_rule.workspace.id":i}})})}};var hc=(()=>{class r extends f{constructor(){super(...arguments),this.workspaces=new si(this._client)}create(e,t){let{betas:n,...s}=e;return this._client.post("/v1/organizations/federation_rules",{body:s,...t,headers:d([{...n?.toString()!=null?{"anthropic-beta":n?.toString()}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.federation.rules.create",t,{route:"/v1/organizations/federation_rules",createdIDAttribute:"anthropic.organization.federation_rule.id"})})}retrieve(e,t={},n){let{betas:s}=t??{};return this._client.get(u`/v1/organizations/federation_rules/${e}`,{...n,headers:d([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.federation.rules.retrieve",n,{route:"/v1/organizations/federation_rules/{federation_rule_id}",attributes:{"anthropic.organization.federation_rule.id":e}})})}update(e,t,n){let{betas:s,...a}=t;return this._client.post(u`/v1/organizations/federation_rules/${e}`,{body:a,...n,headers:d([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.federation.rules.update",n,{route:"/v1/organizations/federation_rules/{federation_rule_id}",attributes:{"anthropic.organization.federation_rule.id":e}})})}list(e={},t){let{betas:n,...s}=e??{};return this._client.getAPIList("/v1/organizations/federation_rules",w,{query:s,...t,headers:d([{...n?.toString()!=null?{"anthropic-beta":n?.toString()}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.federation.rules.list",t,{route:"/v1/organizations/federation_rules",queryParams:["include_archived","issuer_id","limit","page"]})})}archive(e,t={},n){let{betas:s}=t??{};return this._client.post(u`/v1/organizations/federation_rules/${e}/archive`,{...n,headers:d([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.federation.rules.archive",n,{route:"/v1/organizations/federation_rules/{federation_rule_id}/archive",attributes:{"anthropic.organization.federation_rule.id":e}})})}}return r.Workspaces=si,r})();var _c=(()=>{class r extends f{constructor(){super(...arguments),this.issuers=new ni(this._client),this.rules=new hc(this._client)}}return r.Issuers=ni,r.Rules=hc,r})();var ai=class extends f{create(i,e){return this._client.post("/v1/organizations/invites",{body:i,...e,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.invites.create",e,{route:"/v1/organizations/invites",createdIDAttribute:"anthropic.organization.invite.id"})})}retrieve(i,e){return this._client.get(u`/v1/organizations/invites/${i}`,{...e,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.invites.retrieve",e,{route:"/v1/organizations/invites/{invite_id}",attributes:{"anthropic.organization.invite.id":i}})})}list(i={},e){return this._client.getAPIList("/v1/organizations/invites",U,{query:i,...e,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.invites.list",e,{route:"/v1/organizations/invites",queryParams:["after_id","before_id","email","limit","roles","statuses"]})})}delete(i,e){return this._client.delete(u`/v1/organizations/invites/${i}`,{...e,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.invites.delete",e,{route:"/v1/organizations/invites/{invite_id}",attributes:{"anthropic.organization.invite.id":i}})})}};var oi=class extends f{retrieve(i,e={},t){let{betas:n,...s}=e??{};return this._client.get(u`/v1/organizations/plugin_marketplaces/${i}`,{query:s,...t,headers:d([{"anthropic-beta":[...n??[],"ce-plugins-2026-09-01"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.plugin_marketplaces.retrieve",t,{route:"/v1/organizations/plugin_marketplaces/{marketplace_id}",queryParams:["organization_id"],attributes:{"anthropic.organization.plugin_marketplace.id":i}})})}update(i,e,t){let{betas:n,...s}=e;return this._client.post(u`/v1/organizations/plugin_marketplaces/${i}`,{body:s,...t,headers:d([{"anthropic-beta":[...n??[],"ce-plugins-2026-09-01"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.plugin_marketplaces.update",t,{route:"/v1/organizations/plugin_marketplaces/{marketplace_id}",attributes:{"anthropic.organization.plugin_marketplace.id":i}})})}list(i={},e){let{betas:t,...n}=i??{};return this._client.getAPIList("/v1/organizations/plugin_marketplaces",w,{query:n,...e,headers:d([{"anthropic-beta":[...t??[],"ce-plugins-2026-09-01"].toString()},e?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.plugin_marketplaces.list",e,{route:"/v1/organizations/plugin_marketplaces",queryParams:["limit","organization_id","owner_type","page","source"]})})}validateArchive(i,e){let{betas:t,...n}=i;return this._client.post("/v1/organizations/plugin_marketplaces/validate_archive",ie({body:n,...e,headers:d([{"anthropic-beta":[...t??[],"ce-plugins-2026-09-01"].toString()},e?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.plugin_marketplaces.validate_archive",e,{route:"/v1/organizations/plugin_marketplaces/validate_archive"})},this._client))}validateRepository(i,e){let{betas:t,...n}=i;return this._client.post("/v1/organizations/plugin_marketplaces/validate_repository",{body:n,...e,headers:d([{"anthropic-beta":[...t??[],"ce-plugins-2026-09-01"].toString()},e?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.plugin_marketplaces.validate_repository",e,{route:"/v1/organizations/plugin_marketplaces/validate_repository"})})}};var ci=class extends f{list(i={},e){return this._client.getAPIList("/v1/organizations/rate_limits",w,{query:i,...e,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.rate_limits.list",e,{route:"/v1/organizations/rate_limits",queryParams:["group_type","limit","model","page"]})})}};var li=class extends f{create(i,e){let{betas:t,...n}=i;return this._client.post("/v1/organizations/webhooks",{body:n,...e,headers:d([{"anthropic-beta":[...t??[],"webhooks-2026-10-07"].toString()},e?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.webhooks.create",e,{route:"/v1/organizations/webhooks",createdIDAttribute:"anthropic.organization.webhook.id"})})}retrieve(i,e={},t){let{betas:n}=e??{};return this._client.get(u`/v1/organizations/webhooks/${i}`,{...t,headers:d([{"anthropic-beta":[...n??[],"webhooks-2026-10-07"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.webhooks.retrieve",t,{route:"/v1/organizations/webhooks/{webhook_endpoint_id}",attributes:{"anthropic.organization.webhook.id":i}})})}update(i,e,t){let{betas:n,...s}=e;return this._client.post(u`/v1/organizations/webhooks/${i}`,{body:s,...t,headers:d([{"anthropic-beta":[...n??[],"webhooks-2026-10-07"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.webhooks.update",t,{route:"/v1/organizations/webhooks/{webhook_endpoint_id}",attributes:{"anthropic.organization.webhook.id":i}})})}list(i={},e){let{betas:t,...n}=i??{};return this._client.getAPIList("/v1/organizations/webhooks",U,{query:n,...e,headers:d([{"anthropic-beta":[...t??[],"webhooks-2026-10-07"].toString()},e?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.webhooks.list",e,{route:"/v1/organizations/webhooks",queryParams:["after_id","before_id","limit","order"]})})}delete(i,e={},t){let{betas:n}=e??{};return this._client.delete(u`/v1/organizations/webhooks/${i}`,{...t,headers:d([{"anthropic-beta":[...n??[],"webhooks-2026-10-07"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.webhooks.delete",t,{route:"/v1/organizations/webhooks/{webhook_endpoint_id}",attributes:{"anthropic.organization.webhook.id":i}})})}regenerateSigningSecret(i,e={},t){let{betas:n}=e??{};return this._client.post(u`/v1/organizations/webhooks/${i}/regenerate_signing_secret`,{...t,headers:d([{"anthropic-beta":[...n??[],"webhooks-2026-10-07"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.webhooks.regenerate_signing_secret",t,{route:"/v1/organizations/webhooks/{webhook_endpoint_id}/regenerate_signing_secret",attributes:{"anthropic.organization.webhook.id":i}})})}};var ui=class extends f{list(i,e={},t){return this._client.getAPIList(u`/v1/organizations/rbac_groups/${i}/members`,w,{query:e,...t,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.rbac_groups.members.list",t,{route:"/v1/organizations/rbac_groups/{rbac_group_id}/members",queryParams:["limit","page"],attributes:{"anthropic.organization.rbac_group.id":i}})})}add(i,e,t){return this._client.post(u`/v1/organizations/rbac_groups/${i}/members`,{body:e,...t,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.rbac_groups.members.add",t,{route:"/v1/organizations/rbac_groups/{rbac_group_id}/members",attributes:{"anthropic.organization.rbac_group.id":i},createdIDAttribute:"anthropic.organization.rbac_group.member.id",createdIDField:"user_id"})})}remove(i,e,t){let{rbac_group_id:n}=e;return this._client.delete(u`/v1/organizations/rbac_groups/${n}/members/${i}`,{...t,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.rbac_groups.members.remove",t,{route:"/v1/organizations/rbac_groups/{rbac_group_id}/members/{user_id}",attributes:{"anthropic.organization.rbac_group.id":n,"anthropic.organization.rbac_group.member.id":i}})})}};var fc=(()=>{class r extends f{constructor(){super(...arguments),this.members=new ui(this._client)}create(e,t){return this._client.post("/v1/organizations/rbac_groups",{body:e,...t,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.rbac_groups.create",t,{route:"/v1/organizations/rbac_groups",createdIDAttribute:"anthropic.organization.rbac_group.id"})})}retrieve(e,t){return this._client.get(u`/v1/organizations/rbac_groups/${e}`,{...t,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.rbac_groups.retrieve",t,{route:"/v1/organizations/rbac_groups/{rbac_group_id}",attributes:{"anthropic.organization.rbac_group.id":e}})})}update(e,t,n){return this._client.post(u`/v1/organizations/rbac_groups/${e}`,{body:t,...n,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.rbac_groups.update",n,{route:"/v1/organizations/rbac_groups/{rbac_group_id}",attributes:{"anthropic.organization.rbac_group.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/rbac_groups",w,{query:e,...t,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.rbac_groups.list",t,{route:"/v1/organizations/rbac_groups",queryParams:["limit","page"]})})}delete(e,t){return this._client.delete(u`/v1/organizations/rbac_groups/${e}`,{...t,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.rbac_groups.delete",t,{route:"/v1/organizations/rbac_groups/{rbac_group_id}",attributes:{"anthropic.organization.rbac_group.id":e}})})}}return r.Members=ui,r})();var di=class extends f{list(i,e={},t){return this._client.getAPIList(u`/v1/organizations/rbac_roles/${i}/permissions`,w,{query:e,...t,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.rbac_roles.permissions.list",t,{route:"/v1/organizations/rbac_roles/{rbac_role_id}/permissions",queryParams:["limit","page"],attributes:{"anthropic.organization.rbac_role.id":i}})})}};var mc=(()=>{class r extends f{constructor(){super(...arguments),this.permissions=new di(this._client)}retrieve(e,t){return this._client.get(u`/v1/organizations/rbac_roles/${e}`,{...t,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.rbac_roles.retrieve",t,{route:"/v1/organizations/rbac_roles/{rbac_role_id}",attributes:{"anthropic.organization.rbac_role.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/rbac_roles",w,{query:e,...t,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.rbac_roles.list",t,{route:"/v1/organizations/rbac_roles",queryParams:["limit","page"]})})}}return r.Permissions=di,r})();var pi=class extends f{list(i,e={},t){let{betas:n,...s}=e??{};return this._client.getAPIList(u`/v1/organizations/service_accounts/${i}/workspaces`,w,{query:s,...t,headers:d([{...n?.toString()!=null?{"anthropic-beta":n?.toString()}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.service_accounts.workspaces.list",t,{route:"/v1/organizations/service_accounts/{service_account_id}/workspaces",queryParams:["limit","page"],attributes:{"anthropic.organization.service_account.id":i}})})}add(i,e,t){let{betas:n,...s}=e;return this._client.post(u`/v1/organizations/service_accounts/${i}/workspaces`,{body:s,...t,headers:d([{...n?.toString()!=null?{"anthropic-beta":n?.toString()}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.service_accounts.workspaces.add",t,{route:"/v1/organizations/service_accounts/{service_account_id}/workspaces",attributes:{"anthropic.organization.service_account.id":i},createdIDAttribute:"anthropic.organization.service_account.workspace.id",createdIDField:"workspace_id"})})}remove(i,e,t){let{service_account_id:n,betas:s}=e;return this._client.delete(u`/v1/organizations/service_accounts/${n}/workspaces/${i}`,{...t,headers:d([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.service_accounts.workspaces.remove",t,{route:"/v1/organizations/service_accounts/{service_account_id}/workspaces/{workspace_id}",attributes:{"anthropic.organization.service_account.id":n,"anthropic.organization.service_account.workspace.id":i}})})}};var gc=(()=>{class r extends f{constructor(){super(...arguments),this.workspaces=new pi(this._client)}create(e,t){let{betas:n,...s}=e;return this._client.post("/v1/organizations/service_accounts",{body:s,...t,headers:d([{...n?.toString()!=null?{"anthropic-beta":n?.toString()}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.service_accounts.create",t,{route:"/v1/organizations/service_accounts",createdIDAttribute:"anthropic.organization.service_account.id"})})}retrieve(e,t={},n){let{betas:s}=t??{};return this._client.get(u`/v1/organizations/service_accounts/${e}`,{...n,headers:d([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.service_accounts.retrieve",n,{route:"/v1/organizations/service_accounts/{service_account_id}",attributes:{"anthropic.organization.service_account.id":e}})})}update(e,t,n){let{betas:s,...a}=t;return this._client.post(u`/v1/organizations/service_accounts/${e}`,{body:a,...n,headers:d([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.service_accounts.update",n,{route:"/v1/organizations/service_accounts/{service_account_id}",attributes:{"anthropic.organization.service_account.id":e}})})}list(e={},t){let{betas:n,...s}=e??{};return this._client.getAPIList("/v1/organizations/service_accounts",w,{query:s,...t,headers:d([{...n?.toString()!=null?{"anthropic-beta":n?.toString()}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.service_accounts.list",t,{route:"/v1/organizations/service_accounts",queryParams:["include_archived","limit","page"]})})}archive(e,t={},n){let{betas:s}=t??{};return this._client.post(u`/v1/organizations/service_accounts/${e}/archive`,{...n,headers:d([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.service_accounts.archive",n,{route:"/v1/organizations/service_accounts/{service_account_id}/archive",attributes:{"anthropic.organization.service_account.id":e}})})}}return r.Workspaces=pi,r})();var hi=class extends f{list(i,e={},t){let{betas:n,...s}=e??{};return this._client.getAPIList(u`/v1/organizations/telemetry_destinations/${i}/workspaces`,w,{query:s,...t,headers:d([{"anthropic-beta":[...n??[],"telemetry-destinations-2026-08-11"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.telemetry_destinations.workspaces.list",t,{route:"/v1/organizations/telemetry_destinations/{destination_id}/workspaces",queryParams:["limit","page"],attributes:{"anthropic.organization.telemetry_destination.id":i}})})}add(i,e,t){let{destination_id:n,betas:s}=e;return this._client.post(u`/v1/organizations/telemetry_destinations/${n}/workspaces/${i}`,{...t,headers:d([{"anthropic-beta":[...s??[],"telemetry-destinations-2026-08-11"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.telemetry_destinations.workspaces.add",t,{route:"/v1/organizations/telemetry_destinations/{destination_id}/workspaces/{workspace_id}",attributes:{"anthropic.organization.telemetry_destination.id":n,"anthropic.organization.telemetry_destination.workspace.id":i}})})}remove(i,e,t){let{destination_id:n,betas:s}=e;return this._client.delete(u`/v1/organizations/telemetry_destinations/${n}/workspaces/${i}`,{...t,headers:d([{"anthropic-beta":[...s??[],"telemetry-destinations-2026-08-11"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.telemetry_destinations.workspaces.remove",t,{route:"/v1/organizations/telemetry_destinations/{destination_id}/workspaces/{workspace_id}",attributes:{"anthropic.organization.telemetry_destination.id":n,"anthropic.organization.telemetry_destination.workspace.id":i}})})}};var bc=(()=>{class r extends f{constructor(){super(...arguments),this.workspaces=new hi(this._client)}create(e,t){let{betas:n,...s}=e;return this._client.post("/v1/organizations/telemetry_destinations",{body:s,...t,headers:d([{"anthropic-beta":[...n??[],"telemetry-destinations-2026-08-11"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.telemetry_destinations.create",t,{route:"/v1/organizations/telemetry_destinations",createdIDAttribute:"anthropic.organization.telemetry_destination.id"})})}retrieve(e,t={},n){let{betas:s}=t??{};return this._client.get(u`/v1/organizations/telemetry_destinations/${e}`,{...n,headers:d([{"anthropic-beta":[...s??[],"telemetry-destinations-2026-08-11"].toString()},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.telemetry_destinations.retrieve",n,{route:"/v1/organizations/telemetry_destinations/{destination_id}",attributes:{"anthropic.organization.telemetry_destination.id":e}})})}update(e,t,n){let{betas:s,...a}=t;return this._client.post(u`/v1/organizations/telemetry_destinations/${e}`,{body:a,...n,headers:d([{"anthropic-beta":[...s??[],"telemetry-destinations-2026-08-11"].toString()},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.telemetry_destinations.update",n,{route:"/v1/organizations/telemetry_destinations/{destination_id}",attributes:{"anthropic.organization.telemetry_destination.id":e}})})}list(e={},t){let{betas:n,...s}=e??{};return this._client.getAPIList("/v1/organizations/telemetry_destinations",w,{query:s,...t,headers:d([{"anthropic-beta":[...n??[],"telemetry-destinations-2026-08-11"].toString()},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.telemetry_destinations.list",t,{route:"/v1/organizations/telemetry_destinations",queryParams:["limit","page","workspace_ids"]})})}delete(e,t={},n){let{betas:s}=t??{};return this._client.delete(u`/v1/organizations/telemetry_destinations/${e}`,{...n,headers:d([{"anthropic-beta":[...s??[],"telemetry-destinations-2026-08-11"].toString()},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.telemetry_destinations.delete",n,{route:"/v1/organizations/telemetry_destinations/{destination_id}",attributes:{"anthropic.organization.telemetry_destination.id":e}})})}test(e,t={},n){let{betas:s}=t??{};return this._client.post(u`/v1/organizations/telemetry_destinations/${e}/test`,{...n,headers:d([{"anthropic-beta":[...s??[],"telemetry-destinations-2026-08-11"].toString()},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.telemetry_destinations.test",n,{route:"/v1/organizations/telemetry_destinations/{destination_id}/test",attributes:{"anthropic.organization.telemetry_destination.id":e}})})}}return r.Workspaces=hi,r})();var _i=class extends f{retrieve(i,e,t){let{workspace_id:n}=e;return this._client.get(u`/v1/organizations/workspaces/${n}/members/${i}`,{...t,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.workspaces.members.retrieve",t,{route:"/v1/organizations/workspaces/{workspace_id}/members/{user_id}",attributes:{"anthropic.organization.workspace.id":n,"anthropic.organization.workspace.member.id":i}})})}update(i,e,t){let{workspace_id:n,...s}=e;return this._client.post(u`/v1/organizations/workspaces/${n}/members/${i}`,{body:s,...t,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.workspaces.members.update",t,{route:"/v1/organizations/workspaces/{workspace_id}/members/{user_id}",attributes:{"anthropic.organization.workspace.id":n,"anthropic.organization.workspace.member.id":i}})})}list(i,e={},t){return this._client.getAPIList(u`/v1/organizations/workspaces/${i}/members`,U,{query:e,...t,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.workspaces.members.list",t,{route:"/v1/organizations/workspaces/{workspace_id}/members",queryParams:["after_id","before_id","limit"],attributes:{"anthropic.organization.workspace.id":i}})})}add(i,e,t){return this._client.post(u`/v1/organizations/workspaces/${i}/members`,{body:e,...t,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.workspaces.members.add",t,{route:"/v1/organizations/workspaces/{workspace_id}/members",attributes:{"anthropic.organization.workspace.id":i},createdIDAttribute:"anthropic.organization.workspace.member.id",createdIDField:"user_id"})})}remove(i,e,t){let{workspace_id:n}=e;return this._client.delete(u`/v1/organizations/workspaces/${n}/members/${i}`,{...t,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.workspaces.members.remove",t,{route:"/v1/organizations/workspaces/{workspace_id}/members/{user_id}",attributes:{"anthropic.organization.workspace.id":n,"anthropic.organization.workspace.member.id":i}})})}};var fi=class extends f{update(i,e,t){let{workspace_id:n,...s}=e;return this._client.post(u`/v1/organizations/workspaces/${n}/rate_limits/${i}`,{body:s,...t,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.workspaces.rate_limits.update",t,{route:"/v1/organizations/workspaces/{workspace_id}/rate_limits/{rate_limit_id}",attributes:{"anthropic.organization.workspace.id":n,"anthropic.organization.workspace.rate_limit.id":i}})})}list(i,e={},t){return this._client.getAPIList(u`/v1/organizations/workspaces/${i}/rate_limits`,w,{query:e,...t,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.workspaces.rate_limits.list",t,{route:"/v1/organizations/workspaces/{workspace_id}/rate_limits",queryParams:["group_type","include_inherited","limit","page"],attributes:{"anthropic.organization.workspace.id":i}})})}};var mi=class extends f{retrieve(i,e,t){let{workspace_id:n,betas:s}=e;return this._client.get(u`/v1/organizations/workspaces/${n}/service_accounts/${i}`,{...t,headers:d([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.workspaces.service_accounts.retrieve",t,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id}",attributes:{"anthropic.organization.workspace.id":n,"anthropic.organization.workspace.service_account.id":i}})})}update(i,e,t){let{workspace_id:n,betas:s,...a}=e;return this._client.post(u`/v1/organizations/workspaces/${n}/service_accounts/${i}`,{body:a,...t,headers:d([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.workspaces.service_accounts.update",t,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id}",attributes:{"anthropic.organization.workspace.id":n,"anthropic.organization.workspace.service_account.id":i}})})}list(i,e={},t){let{betas:n,...s}=e??{};return this._client.getAPIList(u`/v1/organizations/workspaces/${i}/service_accounts`,w,{query:s,...t,headers:d([{...n?.toString()!=null?{"anthropic-beta":n?.toString()}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.workspaces.service_accounts.list",t,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts",queryParams:["limit","page"],attributes:{"anthropic.organization.workspace.id":i}})})}add(i,e,t){let{betas:n,...s}=e;return this._client.post(u`/v1/organizations/workspaces/${i}/service_accounts`,{body:s,...t,headers:d([{...n?.toString()!=null?{"anthropic-beta":n?.toString()}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.workspaces.service_accounts.add",t,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts",attributes:{"anthropic.organization.workspace.id":i},createdIDAttribute:"anthropic.organization.workspace.service_account.id",createdIDField:"service_account_id"})})}remove(i,e,t){let{workspace_id:n,betas:s}=e;return this._client.delete(u`/v1/organizations/workspaces/${n}/service_accounts/${i}`,{...t,headers:d([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.workspaces.service_accounts.remove",t,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id}",attributes:{"anthropic.organization.workspace.id":n,"anthropic.organization.workspace.service_account.id":i}})})}};var yc=(()=>{class r extends f{constructor(){super(...arguments),this.rateLimits=new fi(this._client),this.members=new _i(this._client),this.serviceAccounts=new mi(this._client)}create(e,t){let{betas:n,...s}=e;return this._client.post("/v1/organizations/workspaces",{body:s,...t,headers:d([{...n?.toString()!=null?{"anthropic-beta":n?.toString()}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.workspaces.create",t,{route:"/v1/organizations/workspaces",createdIDAttribute:"anthropic.organization.workspace.id"})})}retrieve(e,t){return this._client.get(u`/v1/organizations/workspaces/${e}`,{...t,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.workspaces.retrieve",t,{route:"/v1/organizations/workspaces/{workspace_id}",attributes:{"anthropic.organization.workspace.id":e}})})}update(e,t,n){return this._client.post(u`/v1/organizations/workspaces/${e}`,{body:t,...n,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.workspaces.update",n,{route:"/v1/organizations/workspaces/{workspace_id}",attributes:{"anthropic.organization.workspace.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/workspaces",U,{query:e,...t,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.workspaces.list",t,{route:"/v1/organizations/workspaces",queryParams:["after_id","before_id","ids","include_archived","include_default","limit"]})})}archive(e,t){return this._client.post(u`/v1/organizations/workspaces/${e}/archive`,{...t,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.workspaces.archive",t,{route:"/v1/organizations/workspaces/{workspace_id}/archive",attributes:{"anthropic.organization.workspace.id":e}})})}}return r.RateLimits=fi,r.Members=_i,r.ServiceAccounts=mi,r})();var wc=(()=>{class r extends f{constructor(){super(...arguments),this.apiKeys=new Nr(this._client),this.externalKeys=new ii(this._client),this.federation=new _c(this._client),this.invites=new ai(this._client),this.serviceAccounts=new gc(this._client),this.users=new cc(this._client),this.workspaces=new yc(this._client),this.rateLimits=new ci(this._client),this.complianceSettings=new ri(this._client),this.analytics=new oc(this._client),this.spendLimits=new pc(this._client),this.rbacGroups=new fc(this._client),this.rbacRoles=new mc(this._client),this.plugins=new lc(this._client),this.pluginMarketplaces=new oi(this._client),this.telemetryDestinations=new bc(this._client),this.webhooks=new li(this._client),this.claudeTag=new dc(this._client)}retrieve(e){return this._client.get("/v1/organizations/me",{...e,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.organization.retrieve",e,{route:"/v1/organizations/me"})})}}return r.APIKeys=Nr,r.ExternalKeys=ii,r.Federation=_c,r.Invites=ai,r.ServiceAccounts=gc,r.Users=cc,r.BetaCannotSignOutPrimaryOwnerError=bs,r.BetaCannotSignOutSelfError=ys,r.BetaCannotSignOutManagedMemberError=ws,r.BetaCannotSignOutMembershipAdminError=vs,r.BetaCannotSignOutOwnerError=ks,r.BetaCannotSignOutPrivilegedMemberError=Es,r.Workspaces=yc,r.RateLimits=ci,r.ComplianceSettings=ri,r.Analytics=oc,r.SpendLimits=pc,r.BetaSpendLimitsAdminAPIWritesNotEnabledError=qs,r.RBACGroups=fc,r.RBACRoles=mc,r.Plugins=lc,r.BetaScanFailedError=Ss,r.BetaPluginNameTakenError=As,r.BetaScanPendingError=xs,r.BetaSkillNameTakenError=Ps,r.BetaRegistrationPendingError=Ts,r.PluginMarketplaces=oi,r.TelemetryDestinations=bc,r.Webhooks=li,r.ClaudeTag=dc,r.BetaSlackChannelSetUpSettingsRefusedError=Rs,r.BetaAPIKeyScopeMissingError=Cs,r.BetaClaudeTagWritesNotEnabledError=Is,r.BetaComplianceConfigurationRestrictedError=zs,r.BetaOrganizationLevelScopedAPIKeyRequiredError=Os,r.BetaSlackChannelSetUpEnvironmentNotFoundError=Ns,r.BetaSlackChannelSetUpSettingsConflictError=Ms,r})();var vc=(()=>{class r extends f{list(e,t={},n){let{betas:s,workspace_id:a,...l}=t??{};return this._client.getAPIList(u`/v1/sessions/${e}/events`,w,{query:l,...n,headers:d([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.sessions.events.list",n,{route:"/v1/sessions/{session_id}/events",queryParams:["created_at[gt]","created_at[gte]","created_at[lt]","created_at[lte]","limit","order","page","types"],attributes:{"anthropic.session.id":e}})})}send(e,t,n){let{betas:s,workspace_id:a,...l}=t;return this._client.post(u`/v1/sessions/${e}/events`,{body:l,...n,headers:d([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.sessions.events.send",n,{route:"/v1/sessions/{session_id}/events",attributes:{"anthropic.session.id":e}})})}stream(e,t={},n){let{betas:s,workspace_id:a,...l}=t??{};return this._client.get(u`/v1/sessions/${e}/events/stream`,{query:l,...n,headers:d([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},n?.headers]),stream:!0,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.sessions.events.stream",n,{route:"/v1/sessions/{session_id}/events/stream",queryParams:["event_deltas"],attributes:{"anthropic.session.id":e}})})}toolRunner(e,t){return new Qn(e,{...t,client:this._client})}}return r.SessionToolRunner=Qn,r})();var gi=class extends f{retrieve(i,e,t){let{session_id:n,betas:s,workspace_id:a}=e;return this._client.get(u`/v1/sessions/${n}/resources/${i}`,{...t,headers:d([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.sessions.resources.retrieve",t,{route:"/v1/sessions/{session_id}/resources/{resource_id}",attributes:{"anthropic.session.id":n,"anthropic.session.resource.id":i}})})}update(i,e,t){let{session_id:n,betas:s,workspace_id:a,...l}=e;return this._client.post(u`/v1/sessions/${n}/resources/${i}`,{body:l,...t,headers:d([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.sessions.resources.update",t,{route:"/v1/sessions/{session_id}/resources/{resource_id}",attributes:{"anthropic.session.id":n,"anthropic.session.resource.id":i}})})}list(i,e={},t){let{betas:n,workspace_id:s,...a}=e??{};return this._client.getAPIList(u`/v1/sessions/${i}/resources`,w,{query:a,...t,headers:d([{"anthropic-beta":[...n??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.sessions.resources.list",t,{route:"/v1/sessions/{session_id}/resources",queryParams:["limit","page"],attributes:{"anthropic.session.id":i}})})}delete(i,e,t){let{session_id:n,betas:s,workspace_id:a}=e;return this._client.delete(u`/v1/sessions/${n}/resources/${i}`,{...t,headers:d([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.sessions.resources.delete",t,{route:"/v1/sessions/{session_id}/resources/{resource_id}",attributes:{"anthropic.session.id":n,"anthropic.session.resource.id":i}})})}add(i,e,t){let{betas:n,workspace_id:s,...a}=e;return this._client.post(u`/v1/sessions/${i}/resources`,{body:a,...t,headers:d([{"anthropic-beta":[...n??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.sessions.resources.add",t,{route:"/v1/sessions/{session_id}/resources",attributes:{"anthropic.session.id":i},createdIDAttribute:"anthropic.session.resource.id"})})}};var bi=class extends f{list(i,e,t){let{session_id:n,betas:s,workspace_id:a,...l}=e;return this._client.getAPIList(u`/v1/sessions/${n}/threads/${i}/events`,w,{query:l,...t,headers:d([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.sessions.threads.events.list",t,{route:"/v1/sessions/{session_id}/threads/{thread_id}/events",queryParams:["limit","page"],attributes:{"anthropic.session.id":n,"anthropic.session.thread.id":i}})})}stream(i,e,t){let{session_id:n,betas:s,workspace_id:a,...l}=e;return this._client.get(u`/v1/sessions/${n}/threads/${i}/stream`,{query:l,...t,headers:d([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},t?.headers]),stream:!0,__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.sessions.threads.events.stream",t,{route:"/v1/sessions/{session_id}/threads/{thread_id}/stream",queryParams:["event_deltas"],attributes:{"anthropic.session.id":n,"anthropic.session.thread.id":i}})})}};var kc=(()=>{class r extends f{constructor(){super(...arguments),this.events=new bi(this._client)}retrieve(e,t,n){let{session_id:s,betas:a,workspace_id:l}=t;return this._client.get(u`/v1/sessions/${s}/threads/${e}`,{...n,headers:d([{"anthropic-beta":[...a??[],"managed-agents-2026-04-01"].toString(),...l!=null?{"anthropic-workspace-id":l}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.sessions.threads.retrieve",n,{route:"/v1/sessions/{session_id}/threads/{thread_id}",attributes:{"anthropic.session.id":s,"anthropic.session.thread.id":e}})})}list(e,t={},n){let{betas:s,workspace_id:a,...l}=t??{};return this._client.getAPIList(u`/v1/sessions/${e}/threads`,w,{query:l,...n,headers:d([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.sessions.threads.list",n,{route:"/v1/sessions/{session_id}/threads",queryParams:["limit","page","statuses"],attributes:{"anthropic.session.id":e}})})}archive(e,t,n){let{session_id:s,betas:a,workspace_id:l}=t;return this._client.post(u`/v1/sessions/${s}/threads/${e}/archive`,{...n,headers:d([{"anthropic-beta":[...a??[],"managed-agents-2026-04-01"].toString(),...l!=null?{"anthropic-workspace-id":l}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.sessions.threads.archive",n,{route:"/v1/sessions/{session_id}/threads/{thread_id}/archive",attributes:{"anthropic.session.id":s,"anthropic.session.thread.id":e}})})}}return r.Events=bi,r})();var Ec=(()=>{class r extends f{constructor(){super(...arguments),this.events=new vc(this._client),this.resources=new gi(this._client),this.threads=new kc(this._client)}create(e,t){let{betas:n,workspace_id:s,...a}=e,l={body:a,...t,headers:d([{"anthropic-beta":[...n??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"}};return this._client.post("/v1/sessions",{...l,__span:c(this._client,"anthropic.sessions.create",t,{route:"/v1/sessions",attributes:Bl(a),createdIDAttribute:"anthropic.session.id",request:l})})}retrieve(e,t={},n){let{betas:s,workspace_id:a}=t??{};return this._client.get(u`/v1/sessions/${e}`,{...n,headers:d([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.sessions.retrieve",n,{route:"/v1/sessions/{session_id}",attributes:{"anthropic.session.id":e}})})}update(e,t,n){let{betas:s,workspace_id:a,...l}=t;return this._client.post(u`/v1/sessions/${e}`,{body:l,...n,headers:d([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.sessions.update",n,{route:"/v1/sessions/{session_id}",attributes:{"anthropic.session.id":e}})})}list(e={},t){let{betas:n,workspace_id:s,...a}=e??{};return this._client.getAPIList("/v1/sessions",ro,{query:a,...t,headers:d([{"anthropic-beta":[...n??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.sessions.list",t,{route:"/v1/sessions",queryParams:["agent_id","agent_version","created_at[gt]","created_at[gte]","created_at[lt]","created_at[lte]","deployment_id","include_archived","limit","memory_store_id","order","page","statuses"]})})}delete(e,t={},n){let{betas:s,workspace_id:a}=t??{};return this._client.delete(u`/v1/sessions/${e}`,{...n,headers:d([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.sessions.delete",n,{route:"/v1/sessions/{session_id}",attributes:{"anthropic.session.id":e}})})}archive(e,t={},n){let{betas:s,workspace_id:a}=t??{};return this._client.post(u`/v1/sessions/${e}/archive`,{...n,headers:d([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.sessions.archive",n,{route:"/v1/sessions/{session_id}/archive",attributes:{"anthropic.session.id":e}})})}}return r.Events=vc,r.Resources=gi,r.Threads=kc,r})();var yi=class extends f{create(i,e,t){let{betas:n,workspace_id:s,...a}=e;return this._client.post(u`/v1/skills/${i}/versions`,ie({body:a,...t,headers:d([{...n?.toString()!=null?{"anthropic-beta":n?.toString()}:void 0,...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.skills.versions.create",t,{route:"/v1/skills/{skill_id}/versions",attributes:{"anthropic.skill.id":i},createdIDAttribute:"anthropic.skill.version.id"})},this._client,!1))}retrieve(i,e,t){let{skill_id:n,betas:s,workspace_id:a}=e;return this._client.get(u`/v1/skills/${n}/versions/${i}`,{...t,headers:d([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0,...a!=null?{"anthropic-workspace-id":a}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.skills.versions.retrieve",t,{route:"/v1/skills/{skill_id}/versions/{version}",attributes:{"anthropic.skill.id":n,"anthropic.skill.version.id":i}})})}list(i,e={},t){let{betas:n,workspace_id:s,...a}=e??{};return this._client.getAPIList(u`/v1/skills/${i}/versions`,w,{query:a,...t,headers:d([{...n?.toString()!=null?{"anthropic-beta":n?.toString()}:void 0,...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.skills.versions.list",t,{route:"/v1/skills/{skill_id}/versions",queryParams:["limit","page"],attributes:{"anthropic.skill.id":i}})})}delete(i,e,t){let{skill_id:n,betas:s,workspace_id:a}=e;return this._client.delete(u`/v1/skills/${n}/versions/${i}`,{...t,headers:d([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0,...a!=null?{"anthropic-workspace-id":a}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.skills.versions.delete",t,{route:"/v1/skills/{skill_id}/versions/{version}",attributes:{"anthropic.skill.id":n,"anthropic.skill.version.id":i}})})}download(i,e,t){let{skill_id:n,betas:s,workspace_id:a}=e;return this._client.get(u`/v1/skills/${n}/versions/${i}/content`,{...t,headers:d([{Accept:"application/binary",...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0,...a!=null?{"anthropic-workspace-id":a}:void 0},t?.headers]),__qualifiers:{beta:"true"},__binaryResponse:!0,__span:c(this._client,"anthropic.skills.versions.download",t,{route:"/v1/skills/{skill_id}/versions/{version}/content",attributes:{"anthropic.skill.id":n,"anthropic.skill.version.id":i}})})}};var Sc=(()=>{class r extends f{constructor(){super(...arguments),this.versions=new yi(this._client)}create(e,t){let{betas:n,workspace_id:s,...a}=e;return this._client.post("/v1/skills",ie({body:a,...t,headers:d([{...n?.toString()!=null?{"anthropic-beta":n?.toString()}:void 0,...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.skills.create",t,{route:"/v1/skills",createdIDAttribute:"anthropic.skill.id"})},this._client,!1))}retrieve(e,t={},n){let{betas:s,workspace_id:a}=t??{};return this._client.get(u`/v1/skills/${e}`,{...n,headers:d([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0,...a!=null?{"anthropic-workspace-id":a}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.skills.retrieve",n,{route:"/v1/skills/{skill_id}",attributes:{"anthropic.skill.id":e}})})}list(e={},t){let{betas:n,workspace_id:s,...a}=e??{};return this._client.getAPIList("/v1/skills",w,{query:a,...t,headers:d([{...n?.toString()!=null?{"anthropic-beta":n?.toString()}:void 0,...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.skills.list",t,{route:"/v1/skills",queryParams:["limit","page","source"]})})}delete(e,t={},n){let{betas:s,workspace_id:a}=t??{};return this._client.delete(u`/v1/skills/${e}`,{...n,headers:d([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0,...a!=null?{"anthropic-workspace-id":a}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.skills.delete",n,{route:"/v1/skills/{skill_id}",attributes:{"anthropic.skill.id":e}})})}}return r.Versions=yi,r})();var wi=class extends f{create(i,e,t){let{betas:n,workspace_id:s,...a}=e;return this._client.post(u`/v1/tunnels/${i}/certificates`,{body:a,...t,headers:d([{"anthropic-beta":[...n??[],"mcp-tunnels-2026-06-22"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.tunnels.certificates.create",t,{route:"/v1/tunnels/{tunnel_id}/certificates",attributes:{"anthropic.tunnel.id":i},createdIDAttribute:"anthropic.tunnel.certificate.id"})})}retrieve(i,e,t){let{tunnel_id:n,betas:s,workspace_id:a}=e;return this._client.get(u`/v1/tunnels/${n}/certificates/${i}`,{...t,headers:d([{"anthropic-beta":[...s??[],"mcp-tunnels-2026-06-22"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.tunnels.certificates.retrieve",t,{route:"/v1/tunnels/{tunnel_id}/certificates/{certificate_id}",attributes:{"anthropic.tunnel.id":n,"anthropic.tunnel.certificate.id":i}})})}list(i,e={},t){let{betas:n,workspace_id:s,...a}=e??{};return this._client.getAPIList(u`/v1/tunnels/${i}/certificates`,w,{query:a,...t,headers:d([{"anthropic-beta":[...n??[],"mcp-tunnels-2026-06-22"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.tunnels.certificates.list",t,{route:"/v1/tunnels/{tunnel_id}/certificates",queryParams:["include_archived","limit","page"],attributes:{"anthropic.tunnel.id":i}})})}archive(i,e,t){let{tunnel_id:n,betas:s,workspace_id:a}=e;return this._client.post(u`/v1/tunnels/${n}/certificates/${i}/archive`,{...t,headers:d([{"anthropic-beta":[...s??[],"mcp-tunnels-2026-06-22"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.tunnels.certificates.archive",t,{route:"/v1/tunnels/{tunnel_id}/certificates/{certificate_id}/archive",attributes:{"anthropic.tunnel.id":n,"anthropic.tunnel.certificate.id":i}})})}};var Ac=(()=>{class r extends f{constructor(){super(...arguments),this.certificates=new wi(this._client)}create(e,t){let{betas:n,workspace_id:s,...a}=e;return this._client.post("/v1/tunnels",{body:a,...t,headers:d([{"anthropic-beta":[...n??[],"mcp-tunnels-2026-06-22"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.tunnels.create",t,{route:"/v1/tunnels",createdIDAttribute:"anthropic.tunnel.id"})})}retrieve(e,t={},n){let{betas:s,workspace_id:a}=t??{};return this._client.get(u`/v1/tunnels/${e}`,{...n,headers:d([{"anthropic-beta":[...s??[],"mcp-tunnels-2026-06-22"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.tunnels.retrieve",n,{route:"/v1/tunnels/{tunnel_id}",attributes:{"anthropic.tunnel.id":e}})})}list(e={},t){let{betas:n,workspace_id:s,...a}=e??{};return this._client.getAPIList("/v1/tunnels",w,{query:a,...t,headers:d([{"anthropic-beta":[...n??[],"mcp-tunnels-2026-06-22"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.tunnels.list",t,{route:"/v1/tunnels",queryParams:["include_archived","limit","page"]})})}archive(e,t={},n){let{betas:s,workspace_id:a}=t??{};return this._client.post(u`/v1/tunnels/${e}/archive`,{...n,headers:d([{"anthropic-beta":[...s??[],"mcp-tunnels-2026-06-22"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.tunnels.archive",n,{route:"/v1/tunnels/{tunnel_id}/archive",attributes:{"anthropic.tunnel.id":e}})})}revealToken(e,t={},n){let{betas:s,workspace_id:a}=t??{};return this._client.post(u`/v1/tunnels/${e}/reveal_token`,{...n,headers:d([{"anthropic-beta":[...s??[],"mcp-tunnels-2026-06-22"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.tunnels.reveal_token",n,{route:"/v1/tunnels/{tunnel_id}/reveal_token",attributes:{"anthropic.tunnel.id":e}})})}rotateToken(e,t,n){let{betas:s,workspace_id:a,...l}=t;return this._client.post(u`/v1/tunnels/${e}/rotate_token`,{body:l,...n,headers:d([{"anthropic-beta":[...s??[],"mcp-tunnels-2026-06-22"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.tunnels.rotate_token",n,{route:"/v1/tunnels/{tunnel_id}/rotate_token",attributes:{"anthropic.tunnel.id":e}})})}}return r.Certificates=wi,r})();var vi=class extends f{create(i,e,t){let{betas:n,workspace_id:s,...a}=e;return this._client.post(u`/v1/user_profiles/${i}/action_urls`,{body:a,...t,headers:d([{"anthropic-beta":[...n??[],"user-profiles-2026-08-18"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.user_profiles.action_urls.create",t,{route:"/v1/user_profiles/{user_profile_id}/action_urls",attributes:{"anthropic.user_profile.id":i}})})}};var xc=(()=>{class r extends f{constructor(){super(...arguments),this.actionURLs=new vi(this._client)}create(e,t){let{betas:n,workspace_id:s,...a}=e;return this._client.post("/v1/user_profiles",{body:a,...t,headers:d([{"anthropic-beta":[...n??[],"user-profiles-2026-08-18"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.user_profiles.create",t,{route:"/v1/user_profiles",createdIDAttribute:"anthropic.user_profile.id"})})}retrieve(e,t={},n){let{betas:s,workspace_id:a}=t??{};return this._client.get(u`/v1/user_profiles/${e}`,{...n,headers:d([{"anthropic-beta":[...s??[],"user-profiles-2026-08-18"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.user_profiles.retrieve",n,{route:"/v1/user_profiles/{user_profile_id}",attributes:{"anthropic.user_profile.id":e}})})}update(e,t,n){let{betas:s,workspace_id:a,...l}=t;return this._client.post(u`/v1/user_profiles/${e}`,{body:l,...n,headers:d([{"anthropic-beta":[...s??[],"user-profiles-2026-08-18"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.user_profiles.update",n,{route:"/v1/user_profiles/{user_profile_id}",attributes:{"anthropic.user_profile.id":e}})})}list(e={},t){let{betas:n,workspace_id:s,...a}=e??{};return this._client.getAPIList("/v1/user_profiles",w,{query:a,...t,headers:d([{"anthropic-beta":[...n??[],"user-profiles-2026-08-18"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.user_profiles.list",t,{route:"/v1/user_profiles",queryParams:["limit","order","order_by","page"]})})}delete(e,t={},n){let{betas:s,workspace_id:a}=t??{};return this._client.delete(u`/v1/user_profiles/${e}`,{...n,headers:d([{"anthropic-beta":[...s??[],"user-profiles-2026-08-18"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.user_profiles.delete",n,{route:"/v1/user_profiles/{user_profile_id}",attributes:{"anthropic.user_profile.id":e}})})}createEnrollmentURL(e,t={},n){let{betas:s,workspace_id:a}=t??{};return this._client.post(u`/v1/user_profiles/${e}/enrollment_url`,{...n,headers:d([{"anthropic-beta":[...s??[],"user-profiles-2026-08-18"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.user_profiles.create_enrollment_url",n,{route:"/v1/user_profiles/{user_profile_id}/enrollment_url",attributes:{"anthropic.user_profile.id":e}})})}}return r.ActionURLs=vi,r})();var ki=class extends f{create(i,e,t){let{betas:n,workspace_id:s,...a}=e;return this._client.post(u`/v1/vaults/${i}/credentials`,{body:a,...t,headers:d([{"anthropic-beta":[...n??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.vaults.credentials.create",t,{route:"/v1/vaults/{vault_id}/credentials",attributes:{"anthropic.vault.id":i},createdIDAttribute:"anthropic.vault.credential.id"})})}retrieve(i,e,t){let{vault_id:n,betas:s,workspace_id:a}=e;return this._client.get(u`/v1/vaults/${n}/credentials/${i}`,{...t,headers:d([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.vaults.credentials.retrieve",t,{route:"/v1/vaults/{vault_id}/credentials/{credential_id}",attributes:{"anthropic.vault.id":n,"anthropic.vault.credential.id":i}})})}update(i,e,t){let{vault_id:n,betas:s,workspace_id:a,...l}=e;return this._client.post(u`/v1/vaults/${n}/credentials/${i}`,{body:l,...t,headers:d([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.vaults.credentials.update",t,{route:"/v1/vaults/{vault_id}/credentials/{credential_id}",attributes:{"anthropic.vault.id":n,"anthropic.vault.credential.id":i}})})}list(i,e={},t){let{betas:n,workspace_id:s,...a}=e??{};return this._client.getAPIList(u`/v1/vaults/${i}/credentials`,w,{query:a,...t,headers:d([{"anthropic-beta":[...n??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.vaults.credentials.list",t,{route:"/v1/vaults/{vault_id}/credentials",queryParams:["include_archived","limit","page"],attributes:{"anthropic.vault.id":i}})})}delete(i,e,t){let{vault_id:n,betas:s,workspace_id:a}=e;return this._client.delete(u`/v1/vaults/${n}/credentials/${i}`,{...t,headers:d([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.vaults.credentials.delete",t,{route:"/v1/vaults/{vault_id}/credentials/{credential_id}",attributes:{"anthropic.vault.id":n,"anthropic.vault.credential.id":i}})})}archive(i,e,t){let{vault_id:n,betas:s,workspace_id:a}=e;return this._client.post(u`/v1/vaults/${n}/credentials/${i}/archive`,{...t,headers:d([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.vaults.credentials.archive",t,{route:"/v1/vaults/{vault_id}/credentials/{credential_id}/archive",attributes:{"anthropic.vault.id":n,"anthropic.vault.credential.id":i}})})}mcpOAuthValidate(i,e,t){let{vault_id:n,betas:s,workspace_id:a}=e;return this._client.post(u`/v1/vaults/${n}/credentials/${i}/mcp_oauth_validate`,{...t,headers:d([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.vaults.credentials.mcp_oauth_validate",t,{route:"/v1/vaults/{vault_id}/credentials/{credential_id}/mcp_oauth_validate",attributes:{"anthropic.vault.id":n,"anthropic.vault.credential.id":i}})})}};var Pc=(()=>{class r extends f{constructor(){super(...arguments),this.credentials=new ki(this._client)}create(e,t){let{betas:n,workspace_id:s,...a}=e;return this._client.post("/v1/vaults",{body:a,...t,headers:d([{"anthropic-beta":[...n??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.vaults.create",t,{route:"/v1/vaults",createdIDAttribute:"anthropic.vault.id"})})}retrieve(e,t={},n){let{betas:s,workspace_id:a}=t??{};return this._client.get(u`/v1/vaults/${e}`,{...n,headers:d([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.vaults.retrieve",n,{route:"/v1/vaults/{vault_id}",attributes:{"anthropic.vault.id":e}})})}update(e,t,n){let{betas:s,workspace_id:a,...l}=t;return this._client.post(u`/v1/vaults/${e}`,{body:l,...n,headers:d([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.vaults.update",n,{route:"/v1/vaults/{vault_id}",attributes:{"anthropic.vault.id":e}})})}list(e={},t){let{betas:n,workspace_id:s,...a}=e??{};return this._client.getAPIList("/v1/vaults",w,{query:a,...t,headers:d([{"anthropic-beta":[...n??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.vaults.list",t,{route:"/v1/vaults",queryParams:["include_archived","limit","page"]})})}delete(e,t={},n){let{betas:s,workspace_id:a}=t??{};return this._client.delete(u`/v1/vaults/${e}`,{...n,headers:d([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.vaults.delete",n,{route:"/v1/vaults/{vault_id}",attributes:{"anthropic.vault.id":e}})})}archive(e,t={},n){let{betas:s,workspace_id:a}=t??{};return this._client.post(u`/v1/vaults/${e}/archive`,{...n,headers:d([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},n?.headers]),__qualifiers:{beta:"true"},__span:c(this._client,"anthropic.vaults.archive",n,{route:"/v1/vaults/{vault_id}/archive",attributes:{"anthropic.vault.id":e}})})}}return r.Credentials=ki,r})();var it,Tc,qt,Ei,Rc,Bt,Si,Cc,Up,Ic,zc,cu=(()=>{class r extends Cr{constructor(e,t,n){super(e,{client:n}),it.add(this),Tc.set(this,void 0),qt.set(this,0),Ei.set(this,[]),Rc.set(this,[]),Bt.set(this,void 0),Si.set(this,[]),Cc.set(this,!1),b(this,Tc,t,"f")}get toolCalls(){return o(this,Rc,"f")}_deliverEvent(e,t){var n;b(this,qt,(n=o(this,qt,"f"),n++,n),"f");let s=e.type==="content_block_stop"?t?.content[e.index]:void 0,a=s?.type==="tool_use"?s:void 0;a&&o(this,Rc,"f").push(a),super._deliverEvent(e,t),o(this,it,"m",Up).call(this,e,a),o(this,it,"m",Ic).call(this)}[(Tc=new WeakMap,qt=new WeakMap,Ei=new WeakMap,Rc=new WeakMap,Bt=new WeakMap,Si=new WeakMap,Cc=new WeakMap,it=new WeakSet,Symbol.asyncIterator)](){let e=super[Symbol.asyncIterator](),t={handled:o(this,qt,"f")};o(this,Ei,"f").push(t);let n=!1;return{next:async()=>{n&&(n=!1,t.handled++,o(this,it,"m",Ic).call(this));try{let s=await e.next();return n=!s.done,s.done&&o(this,it,"m",zc).call(this,t),s}catch(s){throw o(this,it,"m",zc).call(this,t),s}},return:async()=>{let s=e.return?.();return o(this,it,"m",zc).call(this,t),await s??{value:void 0,done:!0}}}}}return Up=function(e,t){if(o(this,Cc,"f"))return;if(e.type==="content_block_start"&&e.content_block.type==="fallback"){b(this,Cc,!0,"f"),b(this,Bt,void 0,"f");return}let n=e.type==="content_block_start"||e.type==="message_delta"&&e.delta.stop_reason==="tool_use";o(this,Bt,"f")&&n&&(o(this,Si,"f").push({toolUse:o(this,Bt,"f"),event:o(this,qt,"f")}),b(this,Bt,void 0,"f")),t&&b(this,Bt,t,"f")},Ic=function(){if(this.errored||this.controller.signal.aborted)return;let e=Math.min(o(this,qt,"f"),...o(this,Ei,"f").map(t=>t.handled));for(;o(this,Si,"f")[0]&&o(this,Si,"f")[0].event<=e;)o(this,Tc,"f").call(this,o(this,Si,"f").shift().toolUse)},zc=function(e){let t=o(this,Ei,"f").indexOf(e);t>=0&&(o(this,Ei,"f").splice(t,1),o(this,it,"m",Ic).call(this))},r})();function lu(){let r,i;return{promise:new Promise((t,n)=>{r=t,i=n}),resolve:r,reject:i}}var se,ce,Y,V,K,D,yt,Hp,uu,Bs,Wp,du,pu,jp,hu,Kp,fu=class{constructor(i,e,t){this.fields=i,this.ownMessages=e,this.ownCreateOnly=t,this.deferredMessages=[],this.replacementHistory=null,this.createOnly=Vp(i)}},Oc=(()=>{class r{constructor({params:e,options:t,threading:n,logger:s}){se.add(this),ce.set(this,void 0),Y.set(this,[]),V.set(this,[]),K.set(this,void 0),D.set(this,null),yt.set(this,void 0);let{messages:a,unsupportedRequestBehavior:l,...p}=e;Ls(p),this.options=t,this.unsupportedRequestBehavior=l??"error",b(this,ce,p,"f"),b(this,K,n?{type:"create",replacesLostThread:!1}:{type:"never_threaded"},"f"),b(this,yt,s,"f"),this.push(a??[])}get threading(){return o(this,K,"f").type==="create"||o(this,K,"f").type==="continue"}get previousMessageId(){return o(this,K,"f").type==="continue"?o(this,K,"f").previousMessageId:null}get messages(){let e=o(this,D,"f")?.replacementHistory?.slice()??[...o(this,Y,"f"),...o(this,V,"f")].map(t=>t.param);return o(this,D,"f")&&e.push(...o(this,D,"f").deferredMessages.map(Ai)),e}get params(){let e=o(this,K,"f").type==="create"?o(this,D,"f")?.ownCreateOnly:void 0;return{...o(this,ce,"f"),...e,messages:this.messages}}push(e){if(o(this,D,"f")){o(this,D,"f").deferredMessages.push(...e);return}for(let t of e)o(this,se,"m",uu).call(this,t)||o(this,V,"f").push({param:Ai(t),reply:null})}update(e={},t={}){Ls(e),b(this,ce,{...o(this,ce,"f"),...wt(e)},"f"),this.options={...this.options,...wt(t)};for(let n of _u)e[n]!==void 0&&delete o(this,D,"f")?.ownCreateOnly[n]}fork(e=o(this,ce,"f")){let t=new r({params:{...e,unsupportedRequestBehavior:this.unsupportedRequestBehavior},options:this.options,threading:o(this,K,"f").type!=="never_threaded",logger:o(this,yt,"f")});return this.threading||t.stopThreading(),o(this,D,"f")?.replacementHistory?b(t,V,o(this,D,"f").replacementHistory.map(n=>({param:n,reply:null})),"f"):(b(t,Y,[...o(this,Y,"f")],"f"),b(t,V,[...o(this,V,"f")],"f")),o(this,D,"f")&&t.push(o(this,D,"f").deferredMessages),t}setParams({messages:e,...t}){b(this,ce,t,"f"),o(this,D,"f")&&(o(this,D,"f").ownCreateOnly={}),this.setMessages(e)}setMessages(e){let t=[...o(this,Y,"f"),...o(this,V,"f")];if(o(this,D,"f")){let s=t.map(a=>a.param);Dp(e,s)?(o(this,D,"f").replacementHistory=null,o(this,D,"f").deferredMessages=e.slice(s.length)):(o(this,D,"f").replacementHistory=e,o(this,D,"f").deferredMessages=[]);return}Dp(e,o(this,Y,"f").map(s=>s.param))||(b(this,Y,[],"f"),this.threading&&b(this,K,{type:"create",replacesLostThread:!1},"f")),b(this,V,[],"f");let n=new Map(t.filter(s=>s.reply).map(s=>[s.param.content,s]));for(let s of e.slice(o(this,Y,"f").length))o(this,se,"m",uu).call(this,s)||o(this,V,"f").push({...n.get(s.content)??{reply:null},param:Ai(s)})}get hasTurnToSend(){return o(this,V,"f").length>0||bu(o(this,Y,"f").at(-1)?.reply?.stop_reason)}startTurn(e,t){if(o(this,D,"f"))throw new S("Another `send()`, `parse()` or `stream()` is already in progress on this thread");Ls(t);let n=o(this,V,"f").length;this.push(e);let s=o(this,V,"f").slice(n);o(this,se,"m",Wp).call(this);let a={};return t.system!==void 0&&(a.system=t.system),t.tools!==void 0&&(a.tools=t.tools),b(this,D,new fu({...o(this,ce,"f"),...wt(t)},s,a),"f")}endTurn(e){b(this,D,null,"f"),b(this,V,o(this,V,"f").filter(t=>!e.ownMessages.includes(t)),"f"),e.replacementHistory&&this.setMessages(e.replacementHistory),this.push(e.deferredMessages)}recoversFrom(e){if(!(e instanceof F))return!1;let t=this.unsupportedRequestBehavior==="continue_unthreaded",n=gg(e);if(n!==null&&o(this,K,"f").type==="continue")return n==="thread_not_found"&&o(this,K,"f").replacesLostThread&&t?(o(this,yt,"f").info(`The server lost the thread again right after a replay; continuing without a thread: previous_message_id=${o(this,K,"f").previousMessageId}`),this.stopThreading()):o(this,se,"m",Bs).call(this,n),!0;let s=yg(e);return s!==null&&this.threading&&t?(o(this,yt,"f").info(`The server cannot thread this request; continuing without a thread: unsupported=${s.join(",")}`),this.stopThreading(),!0):!1}stopThreading(){this.threading&&b(this,K,{type:"unthreaded"},"f")}recordPartialReply(e,t){o(this,se,"m",du).call(this,e)||(o(this,se,"m",pu).call(this,wg(e,t),{partial:!0}),this.previousMessageId!==null&&o(this,se,"m",Bs).call(this,"stream_ended_before_message_stop"))}recordReply(e,t){o(this,se,"m",du).call(this,t)||(o(this,se,"m",pu).call(this,t,{partial:!1}),o(this,K,"f").type==="create"&&b(this,ce,{...o(this,ce,"f"),...e.ownCreateOnly},"f"),this.threading&&(b(this,K,{type:"continue",previousMessageId:t.id,createdWith:e.createOnly,replacesLostThread:o(this,K,"f").type==="create"&&o(this,K,"f").replacesLostThread},"f"),t.usage.iterations?.some(n=>n.type==="fallback_message")&&o(this,se,"m",Bs).call(this,"fallback_message")),t.container&&o(this,se,"m",jp).call(this,t.container.id))}buildCreateArguments(e,t,{stream:n}){o(this,se,"m",hu).call(this,e.createOnly);let s=o(this,K,"f"),a=s.type==="continue"?[]:o(this,Y,"f").map(p=>p.param);if(s.type!=="never_threaded"){let p=o(this,Y,"f").map(h=>h.reply!==null).lastIndexOf(!0)+1;a=a.map((h,m)=>m<p?gu(h):h)}let l={...e.fields,messages:[...a,...o(this,V,"f").map(p=>p.param)]};if(this.threading&&!l.betas?.includes(mu)&&(l.betas=[...l.betas??[],mu]),s.type==="create")l.thread={type:"create"};else if(s.type==="continue"){l.thread={type:"continue",previous_message_id:s.previousMessageId};for(let p of _u)delete l[p]}return{params:l,options:o(this,se,"m",Kp).call(this,t,{stream:n})}}checkNextTurn(e){o(this,se,"m",hu).call(this,Vp({...o(this,ce,"f"),...wt(e)}))}}return ce=new WeakMap,Y=new WeakMap,V=new WeakMap,K=new WeakMap,D=new WeakMap,yt=new WeakMap,se=new WeakSet,Hp=function(){for(let e of[o(this,V,"f"),o(this,Y,"f")])for(let t=e.length-1;t>=0;t--)if(e[t].reply)return e[t].reply;return null},uu=function(e){if("id"in e)return e.id===o(this,se,"a",Hp)?.id;let t=o(this,V,"f").at(-1)??o(this,Y,"f").at(-1);return t?.reply!=null&&$s(e,t.param)},Bs=function(e){o(this,yt,"f").info(`Replaying the full message history under a new thread: reason=${e} previous_message_id=${this.previousMessageId}`),b(this,K,{type:"create",replacesLostThread:e==="thread_not_found"},"f")},Wp=function(){let e=o(this,Y,"f").at(-1);if(o(this,V,"f").length||!e||e.reply&&!e.partial)return;e.reply&&o(this,Y,"f").pop();let t=o(this,Y,"f").length;for(;t>0&&!o(this,Y,"f")[t-1].reply;)t-=1;b(this,V,o(this,Y,"f").splice(t),"f"),o(this,yt,"f").info(`Re-sending the turn whose reply ended before \`message_stop\`: partial_reply_id=${e.reply?.id??null}`)},du=function(e){return e.stop_reason!=="refusal"||o(this,K,"f").type==="never_threaded"?!1:(this.previousMessageId!==null&&o(this,se,"m",Bs).call(this,"refusal"),!0)},pu=function(e,{partial:t}){o(this,Y,"f").push(...o(this,V,"f")),b(this,V,[],"f"),e&&o(this,Y,"f").push({param:Ai(e),reply:e,partial:t})},jp=function(e){let{container:t}=o(this,ce,"f");t==null?b(this,ce,{...o(this,ce,"f"),container:e},"f"):typeof t=="object"&&t.id==null&&b(this,ce,{...o(this,ce,"f"),container:{...t,id:e}},"f")},hu=function(e){if(o(this,K,"f").type!=="continue")return;let{createdWith:t}=o(this,K,"f"),n=_u.filter(s=>e[s]!==t[s]);if(n.length){let s=n.map(a=>`\`${a}\``).join(" and ");throw new S(`Cannot change ${s} on a thread: the server keeps the \`system\` and \`tools\` the thread was created with. To change them, start a new thread from \`thread.params\`.`+(n.includes("tools")?" To add or remove tools on this thread, send `tool_addition` or `tool_removal` blocks in a `system` message.":""))}},Kp=function(e,{stream:t}){let n={...this.options,...wt(e)};return t&&(n.headers=d([{[tr]:"stream"},n.headers])),o(this,K,"f").type!=="never_threaded"&&(n.headers=d([n.headers,rr("message-thread")])),this.threading&&(n.headers=mg(n.headers)),n},r})(),fg=["pause_turn","compaction"];function bu(r){return fg.some(i=>i===r)}var mu="message-threads-2026-08-12",_u=["system","tools"];function Vp(r){return{system:JSON.stringify(r.system),tools:JSON.stringify(r.tools)}}function mg(r){let i=d([r]).values.get("anthropic-beta");return i===null?r:d([r,{"anthropic-beta":Cn(i,mu)}])}function gg(r){let i=Gp(r)?.error_code;return bg.find(e=>e===i)??null}var bg=["thread_not_found","thread_already_continued","thread_continue_in_flight"];function yg(r){let i=Gp(r);if(i?.error_code!=="thread_unsupported_request")return null;let e=i.unsupported;return Array.isArray(e)?e.map(String):[]}function Gp(r){let e=r.error?.error?.details;return J(e)?e:null}function Ls(r){if("thread"in r&&r.thread!==void 0)throw new TypeError("`thread` cannot be set here. The message thread sets it for each request itself.")}function wt(r){return Object.fromEntries(Object.entries(r).filter(([,i])=>i!==void 0))}function wg(r,i){let e=r.content.slice(0,i),t=r.content[i];return t?.type==="text"&&t.text&&e.push(t),e.length?{...r,content:e}:null}function gu(r){if(!J(r))return r;let{cache_control:i,...e}=r;for(let t of["content","source","tool","definition","tool_references"]){let n=e[t];Array.isArray(n)?e[t]=n.map(gu):J(n)&&(e[t]=gu(n))}return e}function Dp(r,i){return i.length<=r.length&&i.every((e,t)=>$s(e,r[t]))}function $s(r,i){let[e,t]=[Ai(r),Ai(i)];return Object.keys({...e,...t}).every(s=>e[s]===t[s]||JSON.stringify(e[s])===JSON.stringify(t[s]))}function Ai(r){return"id"in r?{role:r.role,content:r.content}:r}function yu(r){return r===void 0?[]:En(r)?r:[r]}function Nc(r){let{stream:i,max_iterations:e,runToolsEagerly:t,thread:n,...s}=r;if(n!==void 0&&n!==!1)throw new TypeError("`thread` cannot be set in the params of a tool runner. The runner sets it for each request itself. To run without a message thread, pass `thread: false`.");return{settings:{stream:i,max_iterations:e,runToolsEagerly:t},thread:n,threadParams:s}}var q,xi,Lt,N,nt,he,Mc,qe,ge,st,De,vt,Fs,at,xe,Ve,Pi,Ti,$t,Us,wu,qc,Jp,vu,ku,Yp,Hs,Bc,Qp,Xp,Eu,Lc,$c,Zp,Su,eh="a tool runner's toolsets come only from its tools param; change them with setMessagesParams(), or build a new runner",vg="a tool runner's toolsets come only from its tools param; remove it there with setMessagesParams(), or build a new runner without it",js=(()=>{class r{constructor(e,t,n){q.add(this),xi.set(this,!1),Lt.set(this,!1),N.set(this,void 0),nt.set(this,void 0),he.set(this,void 0),Mc.set(this,void 0),qe.set(this,void 0),ge.set(this,void 0),st.set(this,void 0),De.set(this,void 0),vt.set(this,void 0),Fs.set(this,0),at.set(this,void 0),xe.set(this,{status:"idle"}),Ve.set(this,void 0),Pi.set(this,null),Ti.set(this,new Map),$t.set(this,[]);let{thread:s,settings:a}="_state"in e?{thread:e,settings:t}:e.beta.messages._toolRunnerThread(t);th(s._state.params),rh(a),b(this,N,s,"f"),b(this,nt,wt(a),"f");let{tools:l,messages:p}=s._state.params,h=Hl(l,p);"_state"in e||s._state.setMessages(JSON.parse(JSON.stringify(ih(p)))),b(this,he,{...n},"f"),b(this,Mc,d([rr("BetaToolRunner"),h.length?{[He]:h.join(", ")}:void 0]),"f"),b(this,vt,lu(),"f")}async*[(xi=new WeakMap,Lt=new WeakMap,N=new WeakMap,nt=new WeakMap,he=new WeakMap,Mc=new WeakMap,qe=new WeakMap,ge=new WeakMap,st=new WeakMap,De=new WeakMap,vt=new WeakMap,Fs=new WeakMap,at=new WeakMap,xe=new WeakMap,Ve=new WeakMap,Pi=new WeakMap,Ti=new WeakMap,$t=new WeakMap,q=new WeakSet,Us=function(t){return o(this,at,"f")?Q.with(o(this,at,"f"),t):t()},Symbol.asyncIterator)](){var e;if(o(this,xi,"f"))throw new S("Cannot iterate over a consumed stream");b(this,xi,!0,"f"),b(this,Lt,!0,"f"),b(this,De,void 0,"f");let t=M(o(this,N,"f")._client,()=>Wl(o(this,N,"f")._client,this.params,o(this,he,"f").openTelemetry?.conversationId));b(this,at,t&&Te.setSpan(Q.active(),t),"f");try{for(;;)try{if(o(this,nt,"f").max_iterations&&o(this,Fs,"f")>=o(this,nt,"f").max_iterations)break;if(o(this,q,"m",Zp).call(this),o(this,xe,"f").status==="scheduled"&&ah(o(this,Pi,"f"))!=="resume"){yield*o(this,q,"m",ku).call(this,o(this,xe,"f").config);continue}b(this,Lt,!1,"f"),b(this,De,void 0,"f"),b(this,Fs,(e=o(this,Fs,"f"),e++,e),"f"),b(this,ge,void 0,"f"),yield*o(this,q,"m",wu).call(this,o(this,N,"f"));let n=o(this,qe,"f");if(b(this,qe,void 0,"f"),await o(this,q,"m",Us).call(this,async()=>{let a;if(o(this,Lt,"f"))b(this,Pi,null,"f"),o(this,st,"f")?.abort(),o(this,N,"f")._state.checkNextTurn(Ws(o(this,N,"f"))),o(this,N,"f")._state.setMessages(n),a=n.at(-1);else{let p=await o(this,ge,"f"),h=ah(p.stop_reason);if(b(this,Pi,p.stop_reason,"f"),h==="stop")return"stop";if(h==="resume")return"continue";a=Pg(o(this,N,"f").messages)}nh(a)&&o(this,N,"f")._state.checkNextTurn(Ws(o(this,N,"f")));let l=await o(this,q,"m",Eu).call(this,a,o(this,he,"f").signal,o(this,at,"f"));if(l){let p=o(this,N,"f").messages,h=p.map(m=>m.role).lastIndexOf("assistant")+1;o(this,N,"f")._state.setMessages([...p.slice(0,h),l,...p.slice(h)])}else if(!o(this,Lt,"f")&&!o(this,N,"f")._state.hasTurnToSend)return"stop";return"continue"})==="stop"){yield*o(this,q,"m",Xp).call(this);break}}finally{o(this,st,"f")?.abort(),b(this,st,void 0,"f")}if(await o(this,q,"m",vu).call(this),!o(this,ge,"f"))throw new S("ToolRunner concluded without a message from the server");o(this,vt,"f").resolve(await o(this,ge,"f")),M(o(this,N,"f")._client,()=>t?.setStatus({code:Pe.OK}))}catch(n){throw t&&M(o(this,N,"f")._client,()=>Ce(t,n)),b(this,xi,!1,"f"),b(this,qe,void 0,"f"),o(this,vt,"f").promise.catch(()=>{}),o(this,vt,"f").reject(n),b(this,vt,lu(),"f"),n}finally{M(o(this,N,"f")._client,()=>t?.end()),b(this,at,void 0,"f")}}setMessagesParams(e){let t=typeof e=="function"?e(this.params):e;if(th(t),o(this,xe,"f").status!=="idle"&&Au(t),o(this,xe,"f").status==="in_flight"&&!Eg(t.messages,o(this,N,"f").messages))throw new S(kg);let{settings:n,threadParams:s}=Nc(t);rh(n),b(this,nt,wt(n),"f"),o(this,qe,"f")?(b(this,qe,s.messages,"f"),o(this,N,"f")._state.setParams({...s,messages:o(this,N,"f").messages})):o(this,N,"f")._state.setParams(s),b(this,Lt,!0,"f"),b(this,De,void 0,"f")}setRequestOptions(e){typeof e=="function"?b(this,he,e(o(this,he,"f")),"f"):b(this,he,{...o(this,he,"f"),...e},"f")}async generateToolResponse(e=o(this,he,"f").signal){let t=o(this,N,"f")._client._tracer?Q.active():void 0,n=await o(this,ge,"f")??o(this,N,"f").messages.at(-1);return n?o(this,q,"m",Eu).call(this,n,e,t):null}deferToolCall(e){let t=typeof e=="string"?e:e.id;o(this,Ve,"f")&&!o(this,Ve,"f").has(t)&&o(this,Ve,"f").set(t,{status:"held"})}get deferredToolCalls(){let e=o(this,st,"f"),t=o(this,Ve,"f");return!(e instanceof cu)||!t?[]:e.toolCalls.filter(n=>t.get(n.id)?.status==="held")}done(){return o(this,vt,"f").promise}async runUntilDone(){if(!o(this,xi,"f"))for await(let e of this);return this.done()}get params(){return{...o(this,N,"f")._state.params,...o(this,qe,"f")&&{messages:[...o(this,qe,"f")]},...o(this,nt,"f")}}pushMessages(...e){this.setMessagesParams(t=>({...t,messages:[...t.messages,...e]}))}compactBeforeNextTurn(e){o(this,xe,"f").status!=="in_flight"&&(Au(this.params),b(this,xe,{status:"scheduled",config:e??{type:"summarize"}},"f"))}addTools(...e){let t=o(this,q,"m",Lc).call(this);for(let n of e){if(Ir(n))throw new zr(`addTools() can't add the '${tt(bt(n))}' toolset: ${eh}`);let s=Tg(n);if(t.has(s))throw new zr(`addTools() can't replace the '${tt(s)}' toolset: ${eh}`)}for(let n of e)"name"in n&&o(this,Ti,"f").set(n.name,"run"in n?n:null),o(this,$t,"f").push({type:"addition",tool:n})}removeTools(...e){let t=o(this,q,"m",Lc).call(this);for(let n of e){let s=typeof n=="string"?n:n.name;if(t.has(s))throw new zr(`removeTools() can't remove the '${tt(s)}' toolset: ${vg}`)}for(let n of e){let s=typeof n=="string"?n:n.name;o(this,Ti,"f").set(s,null),o(this,$t,"f").push({type:"removal",name:s})}}then(e,t){return this.runUntilDone().then(e,t)}}return wu=async function*(e){await o(this,q,"m",vu).call(this),b(this,Ve,void 0,"f");let t=e.messages;t.some(Ag)&&o(this,q,"m",Us).call(this,()=>e._state.setMessages(ih(t)));let{tools:n}=e._state.params;o(this,nt,"f").stream?(b(this,st,o(this,q,"m",Us).call(this,()=>o(this,nt,"f").runToolsEagerly?o(this,q,"m",Jp).call(this,e):e.stream(void 0,Ws(e),o(this,q,"m",qc).call(this,e))),"f"),n&&e.update({tools:n}),e===o(this,N,"f")&&b(this,qe,e.messages,"f"),b(this,ge,o(this,st,"f").finalMessage(),"f"),o(this,ge,"f").catch(()=>{}),yield o(this,st,"f")):(b(this,ge,o(this,q,"m",Us).call(this,()=>e.send(void 0,Ws(e),o(this,q,"m",qc).call(this,e))),"f"),n&&e.update({tools:n}),e===o(this,N,"f")&&b(this,qe,e.messages,"f"),yield o(this,ge,"f"))},qc=function(e){let{headers:t=e._state.options.headers}=o(this,he,"f");return{...o(this,he,"f"),headers:d([o(this,Mc,"f"),t])}},Jp=function(e){let t=new Map;b(this,Ve,t,"f");let n=new Map,s=l=>{let p=t.has(l.id),h=!l.toolset_name&&o(this,q,"m",Lc).call(this).has(l.name),m=h?l.name:l.toolset_name;if(m){if(p||h||n.has(m)){n.set(m,"waiting");return}n.set(m,"running");let g=oh(o(this,q,"m",$c).call(this),m,l,o(this,he,"f"),o(this,N,"f")._client,o(this,at,"f"));t.set(l.id,{status:"started",result:g}),g.then(({is_error:y})=>{y||n.get(m)==="waiting"?n.set(m,"waiting"):n.delete(m)},()=>n.set(m,"waiting"));return}if(p)return;let _=ch(o(this,q,"m",Hs).call(this),o(this,q,"m",Bc).call(this),l,o(this,he,"f"),o(this,N,"f")._client,o(this,at,"f"));_.catch(()=>{}),t.set(l.id,{status:"started",result:_})},a=new cu(e._state.params,s,e._client);return e._stream(a,void 0,Ws(e),o(this,q,"m",qc).call(this,e)),a},vu=async function(){let e=[...o(this,Ve,"f")?.values()??[]].filter(t=>t.status==="started");await Promise.allSettled(e.map(t=>t.result))},ku=async function*(e){Au(this.params),b(this,xe,{status:"in_flight"},"f"),b(this,De,void 0,"f");let t=o(this,ge,"f"),n=o(this,q,"m",Yp).call(this,e),s=o(this,N,"f").messages.length;try{yield*o(this,q,"m",wu).call(this,n);let a=await o(this,ge,"f");if(a.content.some(l=>l.type==="compaction"&&l.content)){o(this,q,"m",Qp).call(this);let l={role:a.role,content:a.content},p=o(this,N,"f").messages.slice(s).filter(h=>!$s(h,l));o(this,N,"f")._state.setMessages([l,...p])}else I(o(this,N,"f")._client).warn("Compaction produced no summary; keeping the conversation as it is."),b(this,ge,t,"f")}finally{b(this,xe,{status:"idle"},"f"),n._state.threading||o(this,N,"f")._state.stopThreading()}},Yp=function(e){let{messages:t,...n}=Sg(o(this,N,"f")._state.params),s=o(this,N,"f").fork();return s._state=o(this,N,"f")._state.fork({...n,compaction:e}),s},Hs=function(){let e=new Map;for(let t of o(this,N,"f")._state.params.tools??[])"run"in t&&"name"in t&&e.set(t.name,t);for(let[t,n]of o(this,Ti,"f"))n?e.set(t,n):e.delete(t);return e},Bc=function(){let e=new Set(o(this,q,"m",Hs).call(this).keys());for(let t of[...this.params.messages,o(this,q,"m",Su).call(this)])if(Array.isArray(t.content)){for(let n of t.content)if(t.role==="system")sh(n,e);else if(t.role==="assistant"&&n.type==="compaction")for(let s of n.tool_changes??[])sh(s,e)}return e},Qp=function(){let e=o(this,q,"m",Bc).call(this);for(let t of o(this,q,"m",Hs).call(this).keys())e.has(t)||o(this,Ti,"f").set(t,null)},Xp=async function*(){if(o(this,xe,"f").status==="scheduled"){if(nh(o(this,N,"f").messages.at(-1))){I(o(this,N,"f")._client).warn("The pending compaction was skipped because the last turn ended with tool calls that were not run. Call `compactBeforeNextTurn()` again if you continue the conversation."),b(this,xe,{status:"idle"},"f");return}yield*o(this,q,"m",ku).call(this,o(this,xe,"f").config)}},Eu=async function(e,t,n){return o(this,De,"f")!==void 0?o(this,De,"f"):(b(this,De,xg(o(this,q,"m",$c).call(this),o(this,q,"m",Hs).call(this),o(this,q,"m",Bc).call(this),e,{...o(this,he,"f"),signal:t},o(this,Ve,"f"),o(this,N,"f")._client,n),"f"),o(this,De,"f"))},Lc=function(){return new Set(o(this,q,"m",$c).call(this).tools.filter(Ir).map(bt))},$c=function(){return{...this.params,tools:o(this,N,"f")._state.params.tools??[]}},Zp=function(){o(this,Pi,"f")==="pause_turn"||o(this,$t,"f").length===0||(o(this,N,"f").append(o(this,q,"m",Su).call(this)),b(this,$t,[],"f"))},Su=function(){let e=[];for(let t of o(this,$t,"f")){if(t.type==="removal"){e.push({type:"tool_removal",tool:{type:"tool_reference",name:t.name}});continue}let n=xu(t.tool);e.push({type:"tool_addition",tool:{type:"tool_definition",definition:n}})}return{role:"system",content:e}},r})(),kg="Message params can't be changed while the conversation is being compacted, because the compaction response is about to replace them. Change them after this iteration instead.";function Eg(r,i){return r.length===i.length&&r.every((e,t)=>$s(e,i[t]))}function th(r){if("compaction"in r&&r.compaction!=null)throw new S("`compaction` cannot be set on a tool runner: every request in the loop would compact again. Call `runner.compactBeforeNextTurn()` when the conversation should be compacted instead.")}function rh(r){if(r.runToolsEagerly&&!r.stream)throw new TypeError("`runToolsEagerly: true` needs `stream: true` in the tool runner's params, because a reply that isn't streamed arrives whole.")}function Au(r){if(r.context_management?.edits?.some(i=>i.type.startsWith("compact_")))throw new S("`compactBeforeNextTurn()` can't be used while `context_management` has a compaction edit, because the API doesn't accept a compaction block together with one. Remove the edit first.")}function Sg(r){let{context_management:i,stop_sequences:e,output_format:t,...n}=r,s=({format:a,...l})=>l;return(n.tool_choice?.type==="any"||n.tool_choice?.type==="tool")&&delete n.tool_choice,n.output_config&&(n.output_config=s(n.output_config)),Array.isArray(n.fallbacks)&&(n.fallbacks=n.fallbacks.map(a=>a.output_config?{...a,output_config:s(a.output_config)}:a)),n}function xu(r){if(!("run"in r))return r;let i=nc,e="toJSON"in r&&typeof r.toJSON=="function"?r.toJSON():r;return{...Object.fromEntries(Object.entries(e).filter(([t])=>i.includes(t))),...Ze(r)&&{[Ne]:r[Ne]}}}function Ws(r){let{tools:i}=r._state.params;return i?{tools:i.map(xu)}:{}}function ih(r){return r.map(i=>{if(i.role!=="system"||!Array.isArray(i.content))return i;let e=i.content.map(t=>t.type==="tool_addition"&&t.tool.type==="tool_definition"?{...t,tool:{...t.tool,definition:xu(t.tool.definition)}}:t);return{...i,content:e}})}function Ag(r){return r.role==="system"&&Array.isArray(r.content)&&r.content.some(i=>i.type==="tool_addition"&&i.tool.type==="tool_definition"&&"run"in i.tool.definition)}async function xg(r,i,e,t,n,s,a,l){if(!t||t.role!=="assistant"||!t.content||typeof t.content=="string")return null;let p=t.content.filter(_=>_.type==="tool_use");if(p.length===0)return null;let h=new Map;return{role:"user",content:await Promise.all(p.map(async _=>{let g=s?.get(_.id),y=g?.status==="started"?g.result:void 0;if(_.toolset_name){let E=_.toolset_name,T=h.get(E)??{tail:Promise.resolve(),failed:!1};h.set(E,T);let x=r.tools.some(P=>Ir(P)&&bt(P)===E),C=y??T.tail.then(()=>T.failed?gs(_,$p(E),!0):oh(r,E,_,n,a,l));return T.tail=C.then(({is_error:P})=>{P&&x&&(T.failed=!0)},()=>{T.failed=!0}),s?.set(_.id,{status:"started",result:C}),C}if(y)return y;if(!(e.has(_.name)?i.get(_.name):void 0)&&r.tools.some(E=>Ir(E)&&bt(E)===_.name)){let E=h.get(_.name)??{tail:Promise.resolve(),failed:!1};return h.set(_.name,E),E.tail=E.tail.then(()=>{E.failed=!0}),Cg(_)}let k=ch(i,e,_,n,a,l);return s?.set(_.id,{status:"started",result:k}),k}))}}async function oh(r,i,e,t,n,s){let a=r.tools.find(h=>Ir(h)&&bt(h)===i);if(!a)return gs(e,`Error: Toolset '${tt(i)}' member '${tt(e.name)}' not found`,!0);let l={signal:t?.signal,conversationId:t?.openTelemetry?.conversationId,parentContext:s};return(await ir(n,a,e,l,async()=>{let h=await Fp(a,e,{signal:t?.signal});return{block:h,content:h.content??[],isError:h.is_error===!0}})).block}async function ch(r,i,e,t,n,s){let a=i.has(e.name)?r.get(e.name):void 0;if(!a)return Rg(e);let l={signal:t?.signal,conversationId:t?.openTelemetry?.conversationId,parentContext:s},p=await ir(n,a,e,l,()=>Oo(a,e.input,{toolUse:e,toolUseBlock:e,signal:t?.signal}));return{type:"tool_result",tool_use_id:e.id,content:p.content,...p.isError?{is_error:!0}:void 0}}function Pg(r){for(let i=r.length-1;i>=0;i--){let e=r[i];if(e.role==="assistant")return e;if(e.role==="user"&&Array.isArray(e.content)&&e.content.some(t=>t.type==="tool_result"))return}}function nh(r){return Array.isArray(r?.content)&&r.content.some(i=>i.type==="tool_use")}function Tg(r){return(r.type??"custom").replace(/_\d{8}$/,"").replace(/_toolset$/,"")}function Rg(r){return{type:"tool_result",tool_use_id:r.id,content:`Error: Tool '${r.name}' not found`,is_error:!0}}function Cg(r){return{type:"tool_result",tool_use_id:r.id,content:`Error: the '${tt(r.name)}' toolset could not run this call${Ig(r.input)}; nothing in the batch was executed`,is_error:!0}}function Ig(r){let i=typeof r=="object"&&r!==null?r:{};if(!("actions"in i)){let s="action"in i?i.action:void 0;return typeof s=="string"?`: the call has no 'actions' list (action: '${tt(s)}')`:": the call has no 'actions' list"}let{actions:e}=i;if(typeof e=="string")return": 'actions' is text, not a list of actions";if(!Array.isArray(e))return": 'actions' is not a list of actions";if(e.length===0)return": the 'actions' list is empty";let t=[];for(let[s,a]of e.entries()){let l=typeof a=="object"&&a!==null&&"action"in a?a.action:void 0;if(typeof l!="string")return`: action ${s} must be an object with a string 'action' field`;t.push(`'${tt(l)}'`)}let n=t.length>10?`, and ${t.length-10} more`:"";return`: its actions could not be run as sent (actions: ${t.slice(0,10).join(", ")}${n})`}function sh(r,i){switch(r.type){case"tool_removal":case"tool_addition":zg(r,i);break}}function zg(r,i){let e=Og(r.tool);e!==void 0&&(r.type==="tool_removal"?i.delete(e):i.add(e))}function Og(r){switch(r.type){case"tool_reference":return r.name;case"tool_definition":return"name"in r.definition?r.definition.name:void 0;default:return}}function ah(r){if(r===null)return"stop";if(bu(r))return"resume";switch(r){case"tool_use":return"run_tools";case"end_turn":case"stop_sequence":case"max_tokens":case"model_context_window_exceeded":case"refusal":return"stop";default:return"stop"}}var Ks=class r{constructor(i,e,t){if(!i._supportsMessageThreads)throw new S("Message threads are not available on this client; use `client.beta.messages.create()` with the full `messages` instead");cs(e),this._client=i,this._state=new Oc({params:e,options:t??{},threading:!0,logger:I(i)})}static _fromState(i,e){let t=Object.create(r.prototype);return Object.assign(t,{_client:i,_state:e})}get messages(){return this._state.messages}get previousMessageId(){return this._state.previousMessageId}get params(){return{...this._state.params,unsupportedRequestBehavior:this._state.unsupportedRequestBehavior}}append(...i){this._state.push(i)}send(i,e={},t={}){return this._send(i,e,t,n=>n)}parse(i,e={},t={}){return this._send(i,e,t,n=>os(n,this._state.params,{logger:I(this._client)}))}_send(i,e,t,n){let s=this._state.startTurn(yu(i),e),a=(async()=>{try{let{request:l,props:p}=await this._createWithRecovery(s,t,{stream:!1}),h=await l;return this._state.recordReply(s,h),{props:p,reply:h}}finally{this._state.endTurn(s)}})();return new et(this._client,a.then(({props:l})=>l),async()=>{let{props:l,reply:p}=await a;return Rt(n(p),l.response)})}stream(i,e={},t={}){let n=new Cr(this._state.params,{logger:I(this._client),client:this._client});return this._stream(n,i,e,t),n}_stream(i,e,t,n){let s=this._state.startTurn(yu(e),t),a,l=0,p=!1;i.on("streamEvent",(_,g)=>{p||(a=g,_.type==="content_block_stop"&&(l+=1),_.type==="message_stop"&&(p=!0,this._state.recordReply(s,g),this._state.endTurn(s)))});let h=()=>{p||(p=!0,a&&this._state.recordPartialReply(a,l),this._state.endTurn(s))};i.controller.signal.addEventListener("abort",h,{once:!0});let m=(_,g)=>new et(this._client,this._createWithRecovery(s,{...n,signal:g?.signal},{stream:!0}).then(({props:y})=>y));i._start(m,this._state.params,{signal:n.signal??this._state.options.signal},h)}update(i={},e={}){this._state.update(i,e)}toolRunner(i={},e={}){return Ls(i),new js(this,i,e)}fork(){return r._fromState(this._client,this._state.fork())}async _createWithRecovery(i,e,{stream:t}){for(;;){let{params:n,options:s}=this._state.buildCreateArguments(i,e,{stream:t}),a=this._client.beta.messages.create({...n,stream:t},s);try{return{request:a,props:await a._responseProps()}}catch(l){if(!this._state.recoversFrom(l))throw l}}}};var lh={"claude-sonnet-4-5":"November 30th, 2026","claude-sonnet-4-5-20250929":"November 30th, 2026"},Ng=["claude-mythos-preview","claude-opus-4-6"],Or=(()=>{class r extends f{constructor(){super(...arguments),this.batches=new Rr(this._client)}create(e,t){let n=Jo(e),{betas:s,user_profile_id:a,workspace_id:l,...p}=n;p.model in lh&&console.warn(`The model '${p.model}' is deprecated and will reach end-of-life on ${lh[p.model]}
13
- Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`),Ng.includes(p.model)&&p.thinking&&p.thinking.type==="enabled"&&console.warn(`Using Claude with ${p.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 h=t?.timeout??this._client._options.timeout;if(!p.stream&&h==null){let y=Go[p.model]??void 0;h=this._client.calculateNonstreamingTimeout(p.max_tokens,y)}let m={body:p,timeout:h??6e5,...t,headers:eu(n,t),stream:n.stream??!1,__qualifiers:{beta:"true"}},_=this._client._tracer&&c(this._client,"anthropic.messages.create",t,Xe(this._client,m));Bn(this._client,_,p);let g=this._client.post("/v1/messages",{...m,__span:_});return _?g._thenUnwrap(y=>(Ln(this._client,_,p,y),y)):g}parse(e,t){return t={...t,headers:d([{"anthropic-beta":[...e.betas??[],"structured-outputs-2025-12-15"].toString()},t?.headers])},this.create(e,t).then(n=>os(n,e,{logger:this._client.logger??console}))}stream(e,t){return Cr.createMessage(this,e,t,{client:this._client})}countTokens(e,t){let n=Jo(e),{betas:s,user_profile_id:a,workspace_id:l,...p}=n,h={body:p,...t,headers:d([{"anthropic-beta":[...s??[],"token-counting-2024-11-01"].toString(),...a!=null?{"anthropic-user-profile-id":a}:void 0,...l!=null?{"anthropic-workspace-id":l}:void 0},t?.headers]),__qualifiers:{beta:"true"}};return this._client.post("/v1/messages/count_tokens",{...h,__span:c(this._client,"anthropic.messages.count_tokens",t,{route:"/v1/messages/count_tokens",request:h})})}toolRunner(e,t){return new js(this._client,e,t)}_toolRunnerThread(e){cs(e);let{settings:t,thread:n,threadParams:s}=Nc(e),a=new Oc({params:{...s,unsupportedRequestBehavior:"continue_unthreaded"},options:{},threading:n!==!1&&this._client._supportsMessageThreads,logger:I(this._client)});return{thread:Ks._fromState(this._client,a),settings:t}}thread(e,t){return new Ks(this._client,e,t)}}return r.Batches=Rr,r.BetaToolRunner=js,r.ToolError=vr,r})();var nc=["input_schema","name","allowed_callers","cache_control","defer_loading","description","eager_input_streaming","input_examples","strict","type","configs","display_height_px","display_width_px","display_number","enable_zoom","max_characters"];var Ri=(()=>{class r extends R{}return r._errorName="BetaOrganizationNotEnrolledInBetaError",r})(),Ci=(()=>{class r extends R{}return r._errorName="BetaUnsupportedCharsetError",r})(),Ds=(()=>{class r extends f{constructor(){super(...arguments),this.models=new dr(this._client),this.messages=new Or(this._client),this.agents=new ko(this._client),this.environments=new Ko(this._client),this.sessions=new Ec(this._client),this.deployments=new cr(this._client),this.deploymentRuns=new or(this._client),this.vaults=new Pc(this._client),this.memoryStores=new Do(this._client),this.files=new ur(this._client),this.skills=new Sc(this._client),this.webhooks=new hr(this._client),this.userProfiles=new xc(this._client),this.dreams=new lr(this._client),this.tunnels=new Ac(this._client),this.organization=new wc(this._client)}}return r.BetaOrganizationNotEnrolledInBetaError=Ri,r.BetaUnsupportedCharsetError=Ci,r.Models=dr,r.Messages=Or,r.Agents=ko,r.Environments=Ko,r.BetaEnvironmentArchivedError=ts,r.BetaInvalidConfigTypeChangeError=rs,r.BetaInvalidMetadataError=is,r.BetaEnvironmentCreateDisabledError=ns,r.BetaEnvironmentUpdateDisabledError=ss,r.BetaEnvironmentNotFoundError=as,r.Sessions=Ec,r.Deployments=cr,r.DeploymentRuns=or,r.Vaults=Pc,r.MemoryStores=Do,r.Files=ur,r.Skills=Sc,r.Webhooks=hr,r.UserProfiles=xc,r.Dreams=lr,r.Tunnels=Ac,r.Organization=wc,r})();function Pu(r,i){let{user_profile_id:e,workspace_id:t,tools:n,messages:s}=r;return d([{...e!=null?{"anthropic-user-profile-id":e}:void 0,...t!=null?{"anthropic-workspace-id":t}:void 0},eo(n,s),i?.headers])}function uh(r,i,e){if(!r._tracer)return;let t=Pu(i,e);return c(r,"anthropic.messages.create",e,Xe(r,{body:i,headers:t,stream:!0}))}function dh(r){return r?.output_config?.format}function Tu(r,i,e){let t=dh(i);return!i||!("parse"in(t??{}))?{...r,content:r.content.map(n=>n.type==="text"?Object.defineProperty({...n},"parsed_output",{value:null,enumerable:!1}):n),parsed_output:null}:Ru(r,i,e)}function Ru(r,i,e){let t=null,n=r.content.map(s=>{if(s.type==="text"){let a=qg(i,s.text);return t===null&&(t=a),Object.defineProperty({...s},"parsed_output",{value:a,enumerable:!1})}return s});return{...r,content:n,parsed_output:t}}function qg(r,i){let e=dh(r);if(e?.type!=="json_schema")return null;try{return"parse"in e?e.parse(i):JSON.parse(i)}catch(t){throw new S(`Failed to parse structured output: ${t}`)}}var ze,kt,Ge,Vs,Fc,Gs,Js,Uc,Ys,Je,Qs,Hc,Wc,Ft,jc,Kc,Dc,Xs,Ut,be,Cu,ph,Iu,zu,Ou,Nu,hh;function Mu(r){return r.type==="tool_use"||r.type==="server_tool_use"}var _h=(()=>{class r{constructor(e,t){ze.add(this),this.messages=[],this.receivedMessages=[],kt.set(this,void 0),Ge.set(this,null),this.controller=new AbortController,Vs.set(this,void 0),Fc.set(this,()=>{}),Gs.set(this,()=>{}),Js.set(this,void 0),Uc.set(this,()=>{}),Ys.set(this,()=>{}),Je.set(this,{}),Qs.set(this,!1),Hc.set(this,!1),Wc.set(this,!1),Ft.set(this,!1),jc.set(this,void 0),Kc.set(this,void 0),Dc.set(this,void 0),Xs.set(this,void 0),Ut.set(this,void 0),be.set(this,void 0),Iu.set(this,n=>{if(b(this,Hc,!0,"f"),o(this,be,"f")&&(o(this,be,"f").streamed=void 0),de(n)&&(n=new ee),n instanceof ee)return b(this,Wc,!0,"f"),this._emit("abort",n);if(n instanceof S)return this._emit("error",n);if(n instanceof Error){let s=new S(n.message);return s.cause=n,this._emit("error",s)}return this._emit("error",new S(String(n)))}),b(this,Vs,new Promise((n,s)=>{b(this,Fc,n,"f"),b(this,Gs,s,"f")}),"f"),b(this,Js,new Promise((n,s)=>{b(this,Uc,n,"f"),b(this,Ys,s,"f")}),"f"),o(this,Vs,"f").catch(()=>{}),o(this,Js,"f").catch(()=>{}),b(this,Ge,e,"f"),b(this,Xs,t?.logger??console,"f"),b(this,Ut,t?.client,"f")}get response(){return o(this,jc,"f")}get request_id(){return o(this,Kc,"f")}get workspace_id(){return o(this,Dc,"f")}async withResponse(){b(this,Ft,!0,"f");let e=await o(this,Vs,"f");if(!e)throw new Error("Could not resolve a `Response` object");return{data:this,response:e,request_id:e.headers.get("request-id"),workspace_id:e.headers.get("anthropic-workspace-id")}}static fromReadableStream(e){let t=new r(null);return t._run(()=>t._fromReadableStream(e)),t}static createMessage(e,t,n,{logger:s,client:a}={}){let l=new r(t,{logger:s,client:a});for(let p of t.messages)l._addMessageParam(p);return b(l,Ge,{...t,stream:!0},"f"),l._run(()=>l._createMessage(e,{...t,stream:!0},{...n,headers:{...n?.headers,[tr]:"stream"}})),l}_run(e){e().then(()=>{this._emitFinal(),this._emit("end")},o(this,Iu,"f"))}_addMessageParam(e){this.messages.push(e)}_addMessage(e,t=!0){this.receivedMessages.push(e),t&&this._emit("message",e)}async _createMessage(e,t,n){let s=n?.signal,a;s&&(s.aborted&&this.controller.abort(),a=this.controller.abort.bind(this.controller),s.addEventListener("abort",a));try{o(this,ze,"m",zu).call(this),b(this,be,n?.__span??(o(this,Ut,"f")&&uh(o(this,Ut,"f"),t,n)),"f");let{response:l,data:p}=await e.create({...t,stream:!0},{...n,__span:o(this,be,"f"),signal:this.controller.signal}).withResponse();try{this._connected(l)}catch(h){throw o(this,be,"f")&&(o(this,be,"f").failure=h),p.controller.abort(),h}for await(let h of p)try{o(this,ze,"m",Ou).call(this,h)}catch(m){throw o(this,be,"f")&&(o(this,be,"f").failure=m),m}if(p.controller.signal?.aborted)throw new ee;o(this,ze,"m",Nu).call(this)}finally{s&&a&&s.removeEventListener("abort",a)}}_connected(e){this.ended||(b(this,jc,e,"f"),b(this,Kc,e?.headers.get("request-id"),"f"),b(this,Dc,e?.headers.get("anthropic-workspace-id"),"f"),o(this,Fc,"f").call(this,e),this._emit("connect"))}get ended(){return o(this,Qs,"f")}get errored(){return o(this,Hc,"f")}get aborted(){return o(this,Wc,"f")}abort(){this.controller.abort()}on(e,t){return(o(this,Je,"f")[e]||(o(this,Je,"f")[e]=[])).push({listener:t}),this}off(e,t){let n=o(this,Je,"f")[e];if(!n)return this;let s=n.findIndex(a=>a.listener===t);return s>=0&&n.splice(s,1),this}once(e,t){return(o(this,Je,"f")[e]||(o(this,Je,"f")[e]=[])).push({listener:t,once:!0}),this}emitted(e){return new Promise((t,n)=>{b(this,Ft,!0,"f"),e!=="error"&&this.once("error",n),this.once(e,t)})}async done(){b(this,Ft,!0,"f"),await o(this,Js,"f")}get currentMessage(){return o(this,kt,"f")}async finalMessage(){return await this.done(),o(this,ze,"m",Cu).call(this)}async finalText(){return await this.done(),o(this,ze,"m",ph).call(this)}_emit(e,...t){if(o(this,Qs,"f"))return;e==="end"&&(b(this,Qs,!0,"f"),o(this,Uc,"f").call(this));let n=o(this,Je,"f")[e];if(n&&(o(this,Je,"f")[e]=n.filter(s=>!s.once),n.forEach(({listener:s})=>s(...t))),e==="abort"){let s=t[0];!o(this,Ft,"f")&&!n?.length&&Promise.reject(s),o(this,Gs,"f").call(this,s),o(this,Ys,"f").call(this,s),this._emit("end");return}if(e==="error"){let s=t[0];!o(this,Ft,"f")&&!n?.length&&Promise.reject(s),o(this,Gs,"f").call(this,s),o(this,Ys,"f").call(this,s),this._emit("end")}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit("finalMessage",o(this,ze,"m",Cu).call(this))}async _fromReadableStream(e,t){let n=t?.signal,s;n&&(n.aborted&&this.controller.abort(),s=this.controller.abort.bind(this.controller),n.addEventListener("abort",s));try{o(this,ze,"m",zu).call(this),this._connected(null);let a=re.fromReadableStream(e,this.controller);for await(let l of a)o(this,ze,"m",Ou).call(this,l);if(a.controller.signal?.aborted)throw new ee;o(this,ze,"m",Nu).call(this)}finally{n&&s&&n.removeEventListener("abort",s)}}[(kt=new WeakMap,Ge=new WeakMap,Vs=new WeakMap,Fc=new WeakMap,Gs=new WeakMap,Js=new WeakMap,Uc=new WeakMap,Ys=new WeakMap,Je=new WeakMap,Qs=new WeakMap,Hc=new WeakMap,Wc=new WeakMap,Ft=new WeakMap,jc=new WeakMap,Kc=new WeakMap,Dc=new WeakMap,Xs=new WeakMap,Ut=new WeakMap,be=new WeakMap,Iu=new WeakMap,ze=new WeakSet,Cu=function(){if(this.receivedMessages.length===0)throw new S("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},ph=function(){if(this.receivedMessages.length===0)throw new S("stream ended without producing a Message with role=assistant");let t=this.receivedMessages.at(-1).content.filter(n=>n.type==="text").map(n=>n.text);if(t.length===0)throw new S("stream ended without producing a content block with type=text");return t.join(" ")},zu=function(){this.ended||b(this,kt,void 0,"f")},Ou=function(t){if(this.ended)return;let n=o(this,ze,"m",hh).call(this,t);if(this._emit("_rawEvent",t),!!n)switch(this._emit("streamEvent",t,n),t.type){case"content_block_delta":{let s=n.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":{Mu(s)&&o(this,Je,"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":{o(this,Ut,"f")&&o(this,be,"f")&&o(this,Ge,"f")&&er(o(this,Ut,"f"),o(this,be,"f"),o(this,Ge,"f"),n),this._addMessageParam(n),this._addMessage(Tu(n,o(this,Ge,"f"),{logger:o(this,Xs,"f")}),!0);break}case"content_block_stop":{this._emit("contentBlock",n.content.at(-1));break}case"message_start":{b(this,kt,n,"f"),o(this,be,"f")&&o(this,Ge,"f")&&(o(this,be,"f").streamed={body:o(this,Ge,"f"),message:n});break}case"content_block_start":case"message_delta":break}},Nu=function(){if(this.ended)throw new S("stream has ended, this shouldn't happen");let t=o(this,kt,"f");if(!t)throw new S("request ended without sending any chunks");return b(this,kt,void 0,"f"),Tu(t,o(this,Ge,"f"),{logger:o(this,Xs,"f")})},hh=function(t){let n=o(this,kt,"f");if(t.type==="message_start"){if(n)throw new S(`Unexpected event order, got ${t.type} before receiving "message_stop"`);return t.message}if(n)switch(t.type){case"message_stop":return n;case"message_delta":return n.stop_reason=t.delta.stop_reason,n.stop_sequence=t.delta.stop_sequence,n.stop_details=t.delta.stop_details,n.usage.output_tokens=t.usage.output_tokens,t.delta.container!=null&&(n.container=t.delta.container),t.usage.input_tokens!=null&&(n.usage.input_tokens=t.usage.input_tokens),t.usage.cache_creation_input_tokens!=null&&(n.usage.cache_creation_input_tokens=t.usage.cache_creation_input_tokens),t.usage.cache_read_input_tokens!=null&&(n.usage.cache_read_input_tokens=t.usage.cache_read_input_tokens),t.usage.server_tool_use!=null&&(n.usage.server_tool_use=t.usage.server_tool_use),t.usage.output_tokens_details!=null&&(n.usage.output_tokens_details=t.usage.output_tokens_details),n;case"content_block_start":return n.content.push({...t.content_block}),n;case"content_block_delta":{let s=n.content.at(t.index);switch(t.delta.type){case"text_delta":{s?.type==="text"&&(n.content[t.index]={...s,text:(s.text||"")+t.delta.text});break}case"citations_delta":{s?.type==="text"&&(n.content[t.index]={...s,citations:[...s.citations??[],t.delta.citation]});break}case"input_json_delta":{if(s&&Mu(s)){let a=(s[mt]||"")+t.delta.partial_json;n.content[t.index]=Yo(s,a)}break}case"thinking_delta":{s?.type==="thinking"&&(n.content[t.index]={...s,thinking:s.thinking+t.delta.thinking});break}case"signature_delta":{s?.type==="thinking"&&(n.content[t.index]={...s,signature:t.delta.signature});break}default:t.delta}return n}case"content_block_stop":{let s=n.content.at(t.index);return s&&Mu(s)&&mt in s&&Object.defineProperty(s,"input",{value:s.input,enumerable:!0,configurable:!0,writable:!0}),n}default:return n}},Symbol.asyncIterator)](){let e=[],t=[],n=!1;return this.on("_rawEvent",s=>{let a=t.shift();a?a.resolve(s):e.push(s)}),this.on("end",()=>{n=!0;for(let s of t)s.resolve(void 0);t.length=0}),this.on("abort",s=>{n=!0;for(let a of t)a.reject(s);t.length=0}),this.on("error",s=>{n=!0;for(let a of t)a.reject(s);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:n?{value:void 0,done:!0}:new Promise((a,l)=>t.push({resolve:a,reject:l})).then(a=>a?{value:a,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new re(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}return r})();var Ii=class extends f{create(i,e){let{user_profile_id:t,workspace_id:n,...s}=i;return this._client.post("/v1/messages/batches",{body:s,...e,headers:d([{...t!=null?{"anthropic-user-profile-id":t}:void 0,...n!=null?{"anthropic-workspace-id":n}:void 0},e?.headers]),__span:c(this._client,"anthropic.messages.batches.create",e,{route:"/v1/messages/batches",attributes:{"anthropic.message.batch.request_count":s.requests?.length},createdIDAttribute:"anthropic.message.batch.id"})})}retrieve(i,e={},t){let{workspace_id:n}=e??{};return this._client.get(u`/v1/messages/batches/${i}`,{...t,headers:d([{...n!=null?{"anthropic-workspace-id":n}:void 0},t?.headers]),__span:c(this._client,"anthropic.messages.batches.retrieve",t,{route:"/v1/messages/batches/{message_batch_id}",attributes:{"anthropic.message.batch.id":i}})})}list(i={},e){let{workspace_id:t,...n}=i??{};return this._client.getAPIList("/v1/messages/batches",U,{query:n,...e,headers:d([{...t!=null?{"anthropic-workspace-id":t}:void 0},e?.headers]),__span:c(this._client,"anthropic.messages.batches.list",e,{route:"/v1/messages/batches",queryParams:["after_id","before_id","limit"]})})}delete(i,e={},t){let{workspace_id:n}=e??{};return this._client.delete(u`/v1/messages/batches/${i}`,{...t,headers:d([{...n!=null?{"anthropic-workspace-id":n}:void 0},t?.headers]),__span:c(this._client,"anthropic.messages.batches.delete",t,{route:"/v1/messages/batches/{message_batch_id}",attributes:{"anthropic.message.batch.id":i}})})}cancel(i,e={},t){let{workspace_id:n}=e??{};return this._client.post(u`/v1/messages/batches/${i}/cancel`,{...t,headers:d([{...n!=null?{"anthropic-workspace-id":n}:void 0},t?.headers]),__span:c(this._client,"anthropic.messages.batches.cancel",t,{route:"/v1/messages/batches/{message_batch_id}/cancel",attributes:{"anthropic.message.batch.id":i}})})}async results(i,e={},t){let n=await this.retrieve(i,e,t);if(!n.results_url)throw new S(`No batch \`results_url\`; Has it finished processing? ${n.processing_status} - ${n.id}`);let{workspace_id:s}=e??{};return this._client.get(n.results_url,{...t,headers:d([{Accept:"application/binary",...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),stream:!0,__binaryResponse:!0,__span:c(this._client,"anthropic.messages.batches.results",t,{route:"/v1/messages/batches/{message_batch_id}/results",attributes:{"anthropic.message.batch.id":i}})})._thenUnwrap((a,l)=>Vo.fromResponse(l.response,l.controller))}};var zi=(()=>{class r extends R{}return r._errorName="AvailableToolsLimitExceededError",r})(),Oi=(()=>{class r extends R{}return r._errorName="CompactionBlockAmbiguousError",r})(),Ni=(()=>{class r extends R{}return r._errorName="CompactionBlockMisplacedError",r})(),Mi=(()=>{class r extends R{}return r._errorName="CompactionContentMismatchError",r})(),qi=(()=>{class r extends R{}return r._errorName="CompactionIncompleteTurnError",r})(),Bi=(()=>{class r extends R{}return r._errorName="CompactionNothingToSummarizeError",r})(),Li=(()=>{class r extends R{}return r._errorName="CompactionSignatureInvalidError",r})(),$i=(()=>{class r extends R{}return r._errorName="CompactionTooManyToolReferencesError",r})(),Fi=(()=>{class r extends R{}return r._errorName="CompactionToolChangesMismatchError",r})(),Ui=(()=>{class r extends R{}return r._errorName="ThreadAlreadyContinuedError",r})(),Hi=(()=>{class r extends R{}return r._errorName="ThreadContinueInFlightError",r})(),Wi=(()=>{class r extends R{}return r._errorName="ThreadFingerprintMismatchError",r})(),ji=(()=>{class r extends R{}return r._errorName="ThreadUnsupportedRequestError",r})(),Ki=(()=>{class r extends R{}return r._errorName="ToolNameConflictError",r})(),Di=(()=>{class r extends R{}return r._errorName="ToolReferenceUnresolvedError",r})(),Vi=(()=>{class r extends Re{}return r._errorName="ThreadNotFoundError",r})(),Gi=(()=>{class r extends Jt{}return r._errorName="CompactionUnavailableError",r})(),Zs=(()=>{class r extends f{constructor(){super(...arguments),this.batches=new Ii(this._client)}create(e,t){let{user_profile_id:n,workspace_id:s,...a}=e;a.model in fh&&console.warn(`The model '${a.model}' is deprecated and will reach end-of-life on ${fh[a.model]}
14
- Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`),Lg.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=t?.timeout??this._client._options.timeout;if(!a.stream&&l==null){let _=Go[a.model]??void 0;l=this._client.calculateNonstreamingTimeout(a.max_tokens,_)}let p={body:a,timeout:l??6e5,...t,headers:Pu(e,t),stream:e.stream??!1},h=this._client._tracer&&c(this._client,"anthropic.messages.create",t,Xe(this._client,p));Bn(this._client,h,a);let m=this._client.post("/v1/messages",{...p,__span:h});return h?m._thenUnwrap(_=>(Ln(this._client,h,a,_),_)):m}parse(e,t){return this.create(e,t).then(n=>Ru(n,e,{logger:this._client.logger??console}))}stream(e,t){let n=e;return _h.createMessage(this,n,t,{logger:this._client.logger??console,client:this._client})}countTokens(e,t){let{user_profile_id:n,workspace_id:s,...a}=e,l={body:a,...t,headers:d([{...n!=null?{"anthropic-user-profile-id":n}:void 0,...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers])};return this._client.post("/v1/messages/count_tokens",{...l,__span:c(this._client,"anthropic.messages.count_tokens",t,{route:"/v1/messages/count_tokens",request:l})})}}return r.AvailableToolsLimitExceededError=zi,r.CompactionBlockAmbiguousError=Oi,r.CompactionBlockMisplacedError=Ni,r.CompactionContentMismatchError=Mi,r.CompactionIncompleteTurnError=qi,r.CompactionNothingToSummarizeError=Bi,r.CompactionSignatureInvalidError=Li,r.CompactionTooManyToolReferencesError=$i,r.CompactionToolChangesMismatchError=Fi,r.ThreadAlreadyContinuedError=Ui,r.ThreadContinueInFlightError=Hi,r.ThreadFingerprintMismatchError=Wi,r.ThreadUnsupportedRequestError=ji,r.ToolNameConflictError=Ki,r.ToolReferenceUnresolvedError=Di,r.ThreadNotFoundError=Vi,r.CompactionUnavailableError=Gi,r.Batches=Ii,r})();var fh={"claude-sonnet-4-5":"November 30th, 2026","claude-sonnet-4-5-20250929":"November 30th, 2026"},Lg=["claude-mythos-preview","claude-opus-4-6"];var ea=(()=>{class r extends R{}return r._errorName="OrgAPIKeyLimitExceededError",r})(),ta=(()=>{class r extends R{}return r._errorName="WorkspaceAPIKeyLimitExceededError",r})(),Vc=(()=>{class r extends f{retrieve(e,t){return this._client.get(u`/v1/organizations/api_keys/${e}`,{...t,__span:c(this._client,"anthropic.organization.api_keys.retrieve",t,{route:"/v1/organizations/api_keys/{api_key_id}",attributes:{"anthropic.organization.api_key.id":e}})})}update(e,t,n){return this._client.post(u`/v1/organizations/api_keys/${e}`,{body:t,...n,__span:c(this._client,"anthropic.organization.api_keys.update",n,{route:"/v1/organizations/api_keys/{api_key_id}",attributes:{"anthropic.organization.api_key.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/api_keys",U,{query:e,...t,__span:c(this._client,"anthropic.organization.api_keys.list",t,{route:"/v1/organizations/api_keys",queryParams:["after_id","before_id","created_by_user_id","limit","status","workspace_id"]})})}}return r.OrgAPIKeyLimitExceededError=ea,r.WorkspaceAPIKeyLimitExceededError=ta,r})();var ra=(()=>{class r extends R{}return r._errorName="ExternalKeyInWorkspacePolicyError",r})(),ia=(()=>{class r extends R{}return r._errorName="ExternalKeyValidationFailedError",r})(),na=(()=>{class r extends R{}return r._errorName="ExternalKeyValidationTimedOutError",r})(),sa=(()=>{class r extends le{}return r._errorName="ExternalKeyChangedError",r})(),Gc=(()=>{class r extends f{create(e,t){return this._client.post("/v1/organizations/external_keys",{body:e,...t,__span:c(this._client,"anthropic.organization.external_keys.create",t,{route:"/v1/organizations/external_keys",createdIDAttribute:"anthropic.organization.external_key.id"})})}retrieve(e,t){return this._client.get(u`/v1/organizations/external_keys/${e}`,{...t,__span:c(this._client,"anthropic.organization.external_keys.retrieve",t,{route:"/v1/organizations/external_keys/{external_key_id}",attributes:{"anthropic.organization.external_key.id":e}})})}update(e,t,n){return this._client.post(u`/v1/organizations/external_keys/${e}`,{body:t,...n,__span:c(this._client,"anthropic.organization.external_keys.update",n,{route:"/v1/organizations/external_keys/{external_key_id}",attributes:{"anthropic.organization.external_key.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/external_keys",w,{query:e,...t,__span:c(this._client,"anthropic.organization.external_keys.list",t,{route:"/v1/organizations/external_keys",queryParams:["limit","page"]})})}delete(e,t){return this._client.delete(u`/v1/organizations/external_keys/${e}`,{...t,__span:c(this._client,"anthropic.organization.external_keys.delete",t,{route:"/v1/organizations/external_keys/{external_key_id}",attributes:{"anthropic.organization.external_key.id":e}})})}validate(e,t){return this._client.post(u`/v1/organizations/external_keys/${e}/validate`,{...t,__span:c(this._client,"anthropic.organization.external_keys.validate",t,{route:"/v1/organizations/external_keys/{external_key_id}/validate",attributes:{"anthropic.organization.external_key.id":e}})})}}return r.ExternalKeyInWorkspacePolicyError=ra,r.ExternalKeyValidationFailedError=ia,r.ExternalKeyValidationTimedOutError=na,r.ExternalKeyChangedError=sa,r})();var aa=(()=>{class r extends R{}return r._errorName="AlreadyMemberError",r})(),oa=(()=>{class r extends R{}return r._errorName="CannotInviteEmailsWithUnverifiedDomainsError",r})(),ca=(()=>{class r extends R{}return r._errorName="EmailDomainNotAllowedError",r})(),la=(()=>{class r extends R{}return r._errorName="InviteAlreadyExistsError",r})(),Jc=(()=>{class r extends f{create(e,t){return this._client.post("/v1/organizations/invites",{body:e,...t,__span:c(this._client,"anthropic.organization.invites.create",t,{route:"/v1/organizations/invites",createdIDAttribute:"anthropic.organization.invite.id"})})}retrieve(e,t){return this._client.get(u`/v1/organizations/invites/${e}`,{...t,__span:c(this._client,"anthropic.organization.invites.retrieve",t,{route:"/v1/organizations/invites/{invite_id}",attributes:{"anthropic.organization.invite.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/invites",U,{query:e,...t,__span:c(this._client,"anthropic.organization.invites.list",t,{route:"/v1/organizations/invites",queryParams:["after_id","before_id","email","limit","roles","statuses"]})})}delete(e,t){return this._client.delete(u`/v1/organizations/invites/${e}`,{...t,__span:c(this._client,"anthropic.organization.invites.delete",t,{route:"/v1/organizations/invites/{invite_id}",attributes:{"anthropic.organization.invite.id":e}})})}}return r.AlreadyMemberError=aa,r.CannotInviteEmailsWithUnverifiedDomainsError=oa,r.EmailDomainNotAllowedError=ca,r.InviteAlreadyExistsError=la,r})();var Ji=class extends f{retrieve(i){return this._client.get("/v1/organizations/compliance_settings",{...i,__span:c(this._client,"anthropic.organization.compliance_settings.retrieve",i,{route:"/v1/organizations/compliance_settings"})})}update(i,e){return this._client.post("/v1/organizations/compliance_settings",{body:i,...e,__span:c(this._client,"anthropic.organization.compliance_settings.update",e,{route:"/v1/organizations/compliance_settings"})})}};var Yi=class extends f{list(i={},e){return this._client.getAPIList("/v1/organizations/rate_limits",w,{query:i,...e,__span:c(this._client,"anthropic.organization.rate_limits.list",e,{route:"/v1/organizations/rate_limits",queryParams:["group_type","limit","model","page"]})})}};var ua=(()=>{class r extends R{}return r._errorName="CannotRemoveLastMemberError",r})(),Yc=(()=>{class r extends f{retrieve(e,t){return this._client.get(u`/v1/organizations/users/${e}`,{...t,__span:c(this._client,"anthropic.organization.users.retrieve",t,{route:"/v1/organizations/users/{user_id}",attributes:{"anthropic.organization.user.id":e}})})}update(e,t,n){return this._client.post(u`/v1/organizations/users/${e}`,{body:t,...n,__span:c(this._client,"anthropic.organization.users.update",n,{route:"/v1/organizations/users/{user_id}",attributes:{"anthropic.organization.user.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/users",U,{query:e,...t,__span:c(this._client,"anthropic.organization.users.list",t,{route:"/v1/organizations/users",queryParams:["after_id","before_id","email","limit","roles"]})})}remove(e,t){return this._client.delete(u`/v1/organizations/users/${e}`,{...t,__span:c(this._client,"anthropic.organization.users.remove",t,{route:"/v1/organizations/users/{user_id}",attributes:{"anthropic.organization.user.id":e}})})}}return r.CannotRemoveLastMemberError=ua,r})();var Qi=class extends f{list(i,e){return this._client.getAPIList("/v1/organizations/analytics/artifacts",w,{query:i,...e,__span:c(this._client,"anthropic.organization.analytics.artifacts.list",e,{route:"/v1/organizations/analytics/artifacts",queryParams:["date","filter","group_by","limit","page"]})})}};var Xi=class extends f{list(i={},e){return this._client.getAPIList("/v1/organizations/analytics/connectors",w,{query:i,...e,__span:c(this._client,"anthropic.organization.analytics.connectors.list",e,{route:"/v1/organizations/analytics/connectors",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"],contentQueryParams:["filter"]})})}};var Zi=class extends f{list(i={},e){return this._client.getAPIList("/v1/organizations/analytics/plugins",w,{query:i,...e,__span:c(this._client,"anthropic.organization.analytics.plugins.list",e,{route:"/v1/organizations/analytics/plugins",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"],contentQueryParams:["filter"]})})}};var en=class extends f{list(i={},e){return this._client.getAPIList("/v1/organizations/analytics/skills",w,{query:i,...e,__span:c(this._client,"anthropic.organization.analytics.skills.list",e,{route:"/v1/organizations/analytics/skills",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"],contentQueryParams:["filter"]})})}};var tn=class extends f{list(i,e){return this._client.getAPIList("/v1/organizations/analytics/summaries",w,{query:i,...e,__span:c(this._client,"anthropic.organization.analytics.summaries.list",e,{route:"/v1/organizations/analytics/summaries",queryParams:["ending_date","filter","limit","page","starting_date"]})})}};var rn=class extends f{list(i={},e){return this._client.getAPIList("/v1/organizations/analytics/users",w,{query:i,...e,__span:c(this._client,"anthropic.organization.analytics.users.list",e,{route:"/v1/organizations/analytics/users",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"],contentQueryParams:["page"]})})}};var nn=class extends f{list(i={},e){return this._client.getAPIList("/v1/organizations/analytics/apps/chat/projects",w,{query:i,...e,__span:c(this._client,"anthropic.organization.analytics.apps.chat.projects.list",e,{route:"/v1/organizations/analytics/apps/chat/projects",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"]})})}};var Qc=(()=>{class r extends f{constructor(){super(...arguments),this.projects=new nn(this._client)}}return r.Projects=nn,r})();var Xc=(()=>{class r extends f{constructor(){super(...arguments),this.chat=new Qc(this._client)}}return r.Chat=Qc,r})();var Zc=(()=>{class r extends f{constructor(){super(...arguments),this.summaries=new tn(this._client),this.users=new rn(this._client),this.apps=new Xc(this._client),this.connectors=new Xi(this._client),this.plugins=new Zi(this._client),this.skills=new en(this._client),this.artifacts=new Qi(this._client)}}return r.Summaries=tn,r.Users=rn,r.Apps=Xc,r.Connectors=Xi,r.Plugins=Zi,r.Skills=en,r.Artifacts=Qi,r})();var sn=class extends f{create(i,e){return this._client.post("/v1/organizations/federation_issuers",{body:i,...e,__span:c(this._client,"anthropic.organization.federation.issuers.create",e,{route:"/v1/organizations/federation_issuers",createdIDAttribute:"anthropic.organization.federation_issuer.id"})})}retrieve(i,e){return this._client.get(u`/v1/organizations/federation_issuers/${i}`,{...e,__span:c(this._client,"anthropic.organization.federation.issuers.retrieve",e,{route:"/v1/organizations/federation_issuers/{federation_issuer_id}",attributes:{"anthropic.organization.federation_issuer.id":i}})})}update(i,e,t){return this._client.post(u`/v1/organizations/federation_issuers/${i}`,{body:e,...t,__span:c(this._client,"anthropic.organization.federation.issuers.update",t,{route:"/v1/organizations/federation_issuers/{federation_issuer_id}",attributes:{"anthropic.organization.federation_issuer.id":i}})})}list(i={},e){return this._client.getAPIList("/v1/organizations/federation_issuers",w,{query:i,...e,__span:c(this._client,"anthropic.organization.federation.issuers.list",e,{route:"/v1/organizations/federation_issuers",queryParams:["include_archived","limit","page"]})})}archive(i,e){return this._client.post(u`/v1/organizations/federation_issuers/${i}/archive`,{...e,__span:c(this._client,"anthropic.organization.federation.issuers.archive",e,{route:"/v1/organizations/federation_issuers/{federation_issuer_id}/archive",attributes:{"anthropic.organization.federation_issuer.id":i}})})}};var an=class extends f{list(i,e={},t){return this._client.getAPIList(u`/v1/organizations/federation_rules/${i}/workspaces`,w,{query:e,...t,__span:c(this._client,"anthropic.organization.federation.rules.workspaces.list",t,{route:"/v1/organizations/federation_rules/{federation_rule_id}/workspaces",queryParams:["limit","page"],attributes:{"anthropic.organization.federation_rule.id":i}})})}add(i,e,t){return this._client.post(u`/v1/organizations/federation_rules/${i}/workspaces`,{body:e,...t,__span:c(this._client,"anthropic.organization.federation.rules.workspaces.add",t,{route:"/v1/organizations/federation_rules/{federation_rule_id}/workspaces",attributes:{"anthropic.organization.federation_rule.id":i},createdIDAttribute:"anthropic.organization.federation_rule.workspace.id",createdIDField:"workspace_id"})})}remove(i,e,t){let{federation_rule_id:n}=e;return this._client.delete(u`/v1/organizations/federation_rules/${n}/workspaces/${i}`,{...t,__span:c(this._client,"anthropic.organization.federation.rules.workspaces.remove",t,{route:"/v1/organizations/federation_rules/{federation_rule_id}/workspaces/{workspace_id}",attributes:{"anthropic.organization.federation_rule.id":n,"anthropic.organization.federation_rule.workspace.id":i}})})}};var el=(()=>{class r extends f{constructor(){super(...arguments),this.workspaces=new an(this._client)}create(e,t){return this._client.post("/v1/organizations/federation_rules",{body:e,...t,__span:c(this._client,"anthropic.organization.federation.rules.create",t,{route:"/v1/organizations/federation_rules",createdIDAttribute:"anthropic.organization.federation_rule.id"})})}retrieve(e,t){return this._client.get(u`/v1/organizations/federation_rules/${e}`,{...t,__span:c(this._client,"anthropic.organization.federation.rules.retrieve",t,{route:"/v1/organizations/federation_rules/{federation_rule_id}",attributes:{"anthropic.organization.federation_rule.id":e}})})}update(e,t,n){return this._client.post(u`/v1/organizations/federation_rules/${e}`,{body:t,...n,__span:c(this._client,"anthropic.organization.federation.rules.update",n,{route:"/v1/organizations/federation_rules/{federation_rule_id}",attributes:{"anthropic.organization.federation_rule.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/federation_rules",w,{query:e,...t,__span:c(this._client,"anthropic.organization.federation.rules.list",t,{route:"/v1/organizations/federation_rules",queryParams:["include_archived","issuer_id","limit","page"]})})}archive(e,t){return this._client.post(u`/v1/organizations/federation_rules/${e}/archive`,{...t,__span:c(this._client,"anthropic.organization.federation.rules.archive",t,{route:"/v1/organizations/federation_rules/{federation_rule_id}/archive",attributes:{"anthropic.organization.federation_rule.id":e}})})}}return r.Workspaces=an,r})();var tl=(()=>{class r extends f{constructor(){super(...arguments),this.issuers=new sn(this._client),this.rules=new el(this._client)}}return r.Issuers=sn,r.Rules=el,r})();var on=class extends f{list(i,e={},t){return this._client.getAPIList(u`/v1/organizations/rbac_groups/${i}/members`,w,{query:e,...t,__span:c(this._client,"anthropic.organization.rbac_groups.members.list",t,{route:"/v1/organizations/rbac_groups/{rbac_group_id}/members",queryParams:["limit","page"],attributes:{"anthropic.organization.rbac_group.id":i}})})}add(i,e,t){return this._client.post(u`/v1/organizations/rbac_groups/${i}/members`,{body:e,...t,__span:c(this._client,"anthropic.organization.rbac_groups.members.add",t,{route:"/v1/organizations/rbac_groups/{rbac_group_id}/members",attributes:{"anthropic.organization.rbac_group.id":i},createdIDAttribute:"anthropic.organization.rbac_group.member.id",createdIDField:"user_id"})})}remove(i,e,t){let{rbac_group_id:n}=e;return this._client.delete(u`/v1/organizations/rbac_groups/${n}/members/${i}`,{...t,__span:c(this._client,"anthropic.organization.rbac_groups.members.remove",t,{route:"/v1/organizations/rbac_groups/{rbac_group_id}/members/{user_id}",attributes:{"anthropic.organization.rbac_group.id":n,"anthropic.organization.rbac_group.member.id":i}})})}};var da=(()=>{class r extends R{}return r._errorName="RBACGroupGrantsOwnerAccessError",r})(),pa=(()=>{class r extends R{}return r._errorName="RBACGroupOwnerAccessUnconfirmedError",r})(),rl=(()=>{class r extends f{constructor(){super(...arguments),this.members=new on(this._client)}create(e,t){return this._client.post("/v1/organizations/rbac_groups",{body:e,...t,__span:c(this._client,"anthropic.organization.rbac_groups.create",t,{route:"/v1/organizations/rbac_groups",createdIDAttribute:"anthropic.organization.rbac_group.id"})})}retrieve(e,t){return this._client.get(u`/v1/organizations/rbac_groups/${e}`,{...t,__span:c(this._client,"anthropic.organization.rbac_groups.retrieve",t,{route:"/v1/organizations/rbac_groups/{rbac_group_id}",attributes:{"anthropic.organization.rbac_group.id":e}})})}update(e,t,n){return this._client.post(u`/v1/organizations/rbac_groups/${e}`,{body:t,...n,__span:c(this._client,"anthropic.organization.rbac_groups.update",n,{route:"/v1/organizations/rbac_groups/{rbac_group_id}",attributes:{"anthropic.organization.rbac_group.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/rbac_groups",w,{query:e,...t,__span:c(this._client,"anthropic.organization.rbac_groups.list",t,{route:"/v1/organizations/rbac_groups",queryParams:["limit","page"]})})}delete(e,t){return this._client.delete(u`/v1/organizations/rbac_groups/${e}`,{...t,__span:c(this._client,"anthropic.organization.rbac_groups.delete",t,{route:"/v1/organizations/rbac_groups/{rbac_group_id}",attributes:{"anthropic.organization.rbac_group.id":e}})})}}return r.RBACGroupGrantsOwnerAccessError=da,r.RBACGroupOwnerAccessUnconfirmedError=pa,r.Members=on,r})();var cn=class extends f{list(i,e={},t){return this._client.getAPIList(u`/v1/organizations/rbac_roles/${i}/permissions`,w,{query:e,...t,__span:c(this._client,"anthropic.organization.rbac_roles.permissions.list",t,{route:"/v1/organizations/rbac_roles/{rbac_role_id}/permissions",queryParams:["limit","page"],attributes:{"anthropic.organization.rbac_role.id":i}})})}};var il=(()=>{class r extends f{constructor(){super(...arguments),this.permissions=new cn(this._client)}retrieve(e,t){return this._client.get(u`/v1/organizations/rbac_roles/${e}`,{...t,__span:c(this._client,"anthropic.organization.rbac_roles.retrieve",t,{route:"/v1/organizations/rbac_roles/{rbac_role_id}",attributes:{"anthropic.organization.rbac_role.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/rbac_roles",w,{query:e,...t,__span:c(this._client,"anthropic.organization.rbac_roles.list",t,{route:"/v1/organizations/rbac_roles",queryParams:["limit","page"]})})}}return r.Permissions=cn,r})();var ln=class extends f{list(i,e={},t){return this._client.getAPIList(u`/v1/organizations/service_accounts/${i}/workspaces`,w,{query:e,...t,__span:c(this._client,"anthropic.organization.service_accounts.workspaces.list",t,{route:"/v1/organizations/service_accounts/{service_account_id}/workspaces",queryParams:["limit","page"],attributes:{"anthropic.organization.service_account.id":i}})})}add(i,e,t){return this._client.post(u`/v1/organizations/service_accounts/${i}/workspaces`,{body:e,...t,__span:c(this._client,"anthropic.organization.service_accounts.workspaces.add",t,{route:"/v1/organizations/service_accounts/{service_account_id}/workspaces",attributes:{"anthropic.organization.service_account.id":i},createdIDAttribute:"anthropic.organization.service_account.workspace.id",createdIDField:"workspace_id"})})}remove(i,e,t){let{service_account_id:n}=e;return this._client.delete(u`/v1/organizations/service_accounts/${n}/workspaces/${i}`,{...t,__span:c(this._client,"anthropic.organization.service_accounts.workspaces.remove",t,{route:"/v1/organizations/service_accounts/{service_account_id}/workspaces/{workspace_id}",attributes:{"anthropic.organization.service_account.id":n,"anthropic.organization.service_account.workspace.id":i}})})}};var nl=(()=>{class r extends f{constructor(){super(...arguments),this.workspaces=new ln(this._client)}create(e,t){return this._client.post("/v1/organizations/service_accounts",{body:e,...t,__span:c(this._client,"anthropic.organization.service_accounts.create",t,{route:"/v1/organizations/service_accounts",createdIDAttribute:"anthropic.organization.service_account.id"})})}retrieve(e,t){return this._client.get(u`/v1/organizations/service_accounts/${e}`,{...t,__span:c(this._client,"anthropic.organization.service_accounts.retrieve",t,{route:"/v1/organizations/service_accounts/{service_account_id}",attributes:{"anthropic.organization.service_account.id":e}})})}update(e,t,n){return this._client.post(u`/v1/organizations/service_accounts/${e}`,{body:t,...n,__span:c(this._client,"anthropic.organization.service_accounts.update",n,{route:"/v1/organizations/service_accounts/{service_account_id}",attributes:{"anthropic.organization.service_account.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/service_accounts",w,{query:e,...t,__span:c(this._client,"anthropic.organization.service_accounts.list",t,{route:"/v1/organizations/service_accounts",queryParams:["include_archived","limit","page"]})})}archive(e,t){return this._client.post(u`/v1/organizations/service_accounts/${e}/archive`,{...t,__span:c(this._client,"anthropic.organization.service_accounts.archive",t,{route:"/v1/organizations/service_accounts/{service_account_id}/archive",attributes:{"anthropic.organization.service_account.id":e}})})}}return r.Workspaces=ln,r})();var un=class extends f{list(i={},e){return this._client.getAPIList("/v1/organizations/spend_limits/effective",w,{query:i,...e,__span:c(this._client,"anthropic.organization.spend_limits.effective.list",e,{route:"/v1/organizations/spend_limits/effective",queryParams:["limit","page","period","user_ids"]})})}};var dn=class extends f{retrieve(i,e){return this._client.get(u`/v1/organizations/spend_limit_increase_requests/${i}`,{...e,__span:c(this._client,"anthropic.organization.spend_limits.increase_requests.retrieve",e,{route:"/v1/organizations/spend_limit_increase_requests/{spend_limit_increase_request_id}",attributes:{"anthropic.organization.spend_limit_increase_request.id":i}})})}list(i={},e){return this._client.getAPIList("/v1/organizations/spend_limit_increase_requests",w,{query:i,...e,__span:c(this._client,"anthropic.organization.spend_limits.increase_requests.list",e,{route:"/v1/organizations/spend_limit_increase_requests",queryParams:["actor_ids","limit","page","status"]})})}approve(i,e,t){return this._client.post(u`/v1/organizations/spend_limit_increase_requests/${i}/approve`,{body:e,...t,__span:c(this._client,"anthropic.organization.spend_limits.increase_requests.approve",t,{route:"/v1/organizations/spend_limit_increase_requests/{spend_limit_increase_request_id}/approve",attributes:{"anthropic.organization.spend_limit_increase_request.id":i}})})}deny(i,e,t){return this._client.post(u`/v1/organizations/spend_limit_increase_requests/${i}/deny`,{body:e,...t,__span:c(this._client,"anthropic.organization.spend_limits.increase_requests.deny",t,{route:"/v1/organizations/spend_limit_increase_requests/{spend_limit_increase_request_id}/deny",attributes:{"anthropic.organization.spend_limit_increase_request.id":i}})})}};var sl=(()=>{class r extends f{constructor(){super(...arguments),this.effective=new un(this._client),this.increaseRequests=new dn(this._client)}}return r.Effective=un,r.IncreaseRequests=dn,r})();var pn=class extends f{retrieve(i,e,t){let{workspace_id:n}=e;return this._client.get(u`/v1/organizations/workspaces/${n}/members/${i}`,{...t,__span:c(this._client,"anthropic.organization.workspaces.members.retrieve",t,{route:"/v1/organizations/workspaces/{workspace_id}/members/{user_id}",attributes:{"anthropic.organization.workspace.id":n,"anthropic.organization.workspace.member.id":i}})})}update(i,e,t){let{workspace_id:n,...s}=e;return this._client.post(u`/v1/organizations/workspaces/${n}/members/${i}`,{body:s,...t,__span:c(this._client,"anthropic.organization.workspaces.members.update",t,{route:"/v1/organizations/workspaces/{workspace_id}/members/{user_id}",attributes:{"anthropic.organization.workspace.id":n,"anthropic.organization.workspace.member.id":i}})})}list(i,e={},t){return this._client.getAPIList(u`/v1/organizations/workspaces/${i}/members`,U,{query:e,...t,__span:c(this._client,"anthropic.organization.workspaces.members.list",t,{route:"/v1/organizations/workspaces/{workspace_id}/members",queryParams:["after_id","before_id","limit"],attributes:{"anthropic.organization.workspace.id":i}})})}add(i,e,t){return this._client.post(u`/v1/organizations/workspaces/${i}/members`,{body:e,...t,__span:c(this._client,"anthropic.organization.workspaces.members.add",t,{route:"/v1/organizations/workspaces/{workspace_id}/members",attributes:{"anthropic.organization.workspace.id":i},createdIDAttribute:"anthropic.organization.workspace.member.id",createdIDField:"user_id"})})}remove(i,e,t){let{workspace_id:n}=e;return this._client.delete(u`/v1/organizations/workspaces/${n}/members/${i}`,{...t,__span:c(this._client,"anthropic.organization.workspaces.members.remove",t,{route:"/v1/organizations/workspaces/{workspace_id}/members/{user_id}",attributes:{"anthropic.organization.workspace.id":n,"anthropic.organization.workspace.member.id":i}})})}};var hn=class extends f{update(i,e,t){let{workspace_id:n,...s}=e;return this._client.post(u`/v1/organizations/workspaces/${n}/rate_limits/${i}`,{body:s,...t,__span:c(this._client,"anthropic.organization.workspaces.rate_limits.update",t,{route:"/v1/organizations/workspaces/{workspace_id}/rate_limits/{rate_limit_id}",attributes:{"anthropic.organization.workspace.id":n,"anthropic.organization.workspace.rate_limit.id":i}})})}list(i,e={},t){return this._client.getAPIList(u`/v1/organizations/workspaces/${i}/rate_limits`,w,{query:e,...t,__span:c(this._client,"anthropic.organization.workspaces.rate_limits.list",t,{route:"/v1/organizations/workspaces/{workspace_id}/rate_limits",queryParams:["group_type","include_inherited","limit","page"],attributes:{"anthropic.organization.workspace.id":i}})})}};var _n=class extends f{retrieve(i,e,t){let{workspace_id:n}=e;return this._client.get(u`/v1/organizations/workspaces/${n}/service_accounts/${i}`,{...t,__span:c(this._client,"anthropic.organization.workspaces.service_accounts.retrieve",t,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id}",attributes:{"anthropic.organization.workspace.id":n,"anthropic.organization.workspace.service_account.id":i}})})}update(i,e,t){let{workspace_id:n,...s}=e;return this._client.post(u`/v1/organizations/workspaces/${n}/service_accounts/${i}`,{body:s,...t,__span:c(this._client,"anthropic.organization.workspaces.service_accounts.update",t,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id}",attributes:{"anthropic.organization.workspace.id":n,"anthropic.organization.workspace.service_account.id":i}})})}list(i,e={},t){return this._client.getAPIList(u`/v1/organizations/workspaces/${i}/service_accounts`,w,{query:e,...t,__span:c(this._client,"anthropic.organization.workspaces.service_accounts.list",t,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts",queryParams:["limit","page"],attributes:{"anthropic.organization.workspace.id":i}})})}add(i,e,t){return this._client.post(u`/v1/organizations/workspaces/${i}/service_accounts`,{body:e,...t,__span:c(this._client,"anthropic.organization.workspaces.service_accounts.add",t,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts",attributes:{"anthropic.organization.workspace.id":i},createdIDAttribute:"anthropic.organization.workspace.service_account.id",createdIDField:"service_account_id"})})}remove(i,e,t){let{workspace_id:n}=e;return this._client.delete(u`/v1/organizations/workspaces/${n}/service_accounts/${i}`,{...t,__span:c(this._client,"anthropic.organization.workspaces.service_accounts.remove",t,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id}",attributes:{"anthropic.organization.workspace.id":n,"anthropic.organization.workspace.service_account.id":i}})})}};var ha=(()=>{class r extends R{}return r._errorName="KeyProfileMismatchError",r})(),_a=(()=>{class r extends R{}return r._errorName="WorkspaceMemberLimitExceededError",r})(),fa=(()=>{class r extends R{}return r._errorName="WorkspacePolicyViolationError",r})(),al=(()=>{class r extends f{constructor(){super(...arguments),this.rateLimits=new hn(this._client),this.members=new pn(this._client),this.serviceAccounts=new _n(this._client)}create(e,t){return this._client.post("/v1/organizations/workspaces",{body:e,...t,__span:c(this._client,"anthropic.organization.workspaces.create",t,{route:"/v1/organizations/workspaces",createdIDAttribute:"anthropic.organization.workspace.id"})})}retrieve(e,t){return this._client.get(u`/v1/organizations/workspaces/${e}`,{...t,__span:c(this._client,"anthropic.organization.workspaces.retrieve",t,{route:"/v1/organizations/workspaces/{workspace_id}",attributes:{"anthropic.organization.workspace.id":e}})})}update(e,t,n){return this._client.post(u`/v1/organizations/workspaces/${e}`,{body:t,...n,__span:c(this._client,"anthropic.organization.workspaces.update",n,{route:"/v1/organizations/workspaces/{workspace_id}",attributes:{"anthropic.organization.workspace.id":e}})})}list(e={},t){return this._client.getAPIList("/v1/organizations/workspaces",U,{query:e,...t,__span:c(this._client,"anthropic.organization.workspaces.list",t,{route:"/v1/organizations/workspaces",queryParams:["after_id","before_id","ids","include_archived","include_default","limit"]})})}archive(e,t){return this._client.post(u`/v1/organizations/workspaces/${e}/archive`,{...t,__span:c(this._client,"anthropic.organization.workspaces.archive",t,{route:"/v1/organizations/workspaces/{workspace_id}/archive",attributes:{"anthropic.organization.workspace.id":e}})})}}return r.KeyProfileMismatchError=ha,r.WorkspaceMemberLimitExceededError=_a,r.WorkspacePolicyViolationError=fa,r.RateLimits=hn,r.Members=pn,r.ServiceAccounts=_n,r})();var fn=(()=>{class r extends R{}return r._errorName="OrgMemberLimitExceededError",r})(),mn=(()=>{class r extends le{}return r._errorName="ConcurrentMembershipChangeError",r})(),ma=(()=>{class r extends f{constructor(){super(...arguments),this.apiKeys=new Vc(this._client),this.externalKeys=new Gc(this._client),this.federation=new tl(this._client),this.invites=new Jc(this._client),this.serviceAccounts=new nl(this._client),this.users=new Yc(this._client),this.workspaces=new al(this._client),this.rateLimits=new Yi(this._client),this.complianceSettings=new Ji(this._client),this.analytics=new Zc(this._client),this.spendLimits=new sl(this._client),this.rbacGroups=new rl(this._client),this.rbacRoles=new il(this._client)}retrieve(e){return this._client.get("/v1/organizations/me",{...e,__span:c(this._client,"anthropic.organization.retrieve",e,{route:"/v1/organizations/me"})})}}return r.OrgMemberLimitExceededError=fn,r.ConcurrentMembershipChangeError=mn,r.APIKeys=Vc,r.OrgAPIKeyLimitExceededError=ea,r.WorkspaceAPIKeyLimitExceededError=ta,r.ExternalKeys=Gc,r.ExternalKeyInWorkspacePolicyError=ra,r.ExternalKeyValidationFailedError=ia,r.ExternalKeyValidationTimedOutError=na,r.ExternalKeyChangedError=sa,r.Federation=tl,r.Invites=Jc,r.AlreadyMemberError=aa,r.CannotInviteEmailsWithUnverifiedDomainsError=oa,r.EmailDomainNotAllowedError=ca,r.InviteAlreadyExistsError=la,r.ServiceAccounts=nl,r.Users=Yc,r.CannotRemoveLastMemberError=ua,r.Workspaces=al,r.KeyProfileMismatchError=ha,r.WorkspaceMemberLimitExceededError=_a,r.WorkspacePolicyViolationError=fa,r.RateLimits=Yi,r.ComplianceSettings=Ji,r.Analytics=Zc,r.SpendLimits=sl,r.RBACGroups=rl,r.RBACGroupGrantsOwnerAccessError=da,r.RBACGroupOwnerAccessUnconfirmedError=pa,r.RBACRoles=il,r})();var gn=class extends f{create(i,e,t){let{workspace_id:n,...s}=e;return this._client.post(u`/v1/skills/${i}/versions`,ie({body:s,...t,headers:d([{...n!=null?{"anthropic-workspace-id":n}:void 0},t?.headers]),__span:c(this._client,"anthropic.skills.versions.create",t,{route:"/v1/skills/{skill_id}/versions",attributes:{"anthropic.skill.id":i},createdIDAttribute:"anthropic.skill.version.id"})},this._client,!1))}retrieve(i,e,t){let{skill_id:n,workspace_id:s}=e;return this._client.get(u`/v1/skills/${n}/versions/${i}`,{...t,headers:d([{...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__span:c(this._client,"anthropic.skills.versions.retrieve",t,{route:"/v1/skills/{skill_id}/versions/{version}",attributes:{"anthropic.skill.id":n,"anthropic.skill.version.id":i}})})}list(i,e={},t){let{workspace_id:n,...s}=e??{};return this._client.getAPIList(u`/v1/skills/${i}/versions`,w,{query:s,...t,headers:d([{...n!=null?{"anthropic-workspace-id":n}:void 0},t?.headers]),__span:c(this._client,"anthropic.skills.versions.list",t,{route:"/v1/skills/{skill_id}/versions",queryParams:["limit","page"],attributes:{"anthropic.skill.id":i}})})}delete(i,e,t){let{skill_id:n,workspace_id:s}=e;return this._client.delete(u`/v1/skills/${n}/versions/${i}`,{...t,headers:d([{...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__span:c(this._client,"anthropic.skills.versions.delete",t,{route:"/v1/skills/{skill_id}/versions/{version}",attributes:{"anthropic.skill.id":n,"anthropic.skill.version.id":i}})})}};var bn=(()=>{class r extends le{}return r._errorName="SkillReadBlockedUndecryptableError",r})(),ga=(()=>{class r extends f{constructor(){super(...arguments),this.versions=new gn(this._client)}create(e,t){let{workspace_id:n,...s}=e;return this._client.post("/v1/skills",ie({body:s,...t,headers:d([{...n!=null?{"anthropic-workspace-id":n}:void 0},t?.headers]),__span:c(this._client,"anthropic.skills.create",t,{route:"/v1/skills",createdIDAttribute:"anthropic.skill.id"})},this._client,!1))}retrieve(e,t={},n){let{workspace_id:s}=t??{};return this._client.get(u`/v1/skills/${e}`,{...n,headers:d([{...s!=null?{"anthropic-workspace-id":s}:void 0},n?.headers]),__span:c(this._client,"anthropic.skills.retrieve",n,{route:"/v1/skills/{skill_id}",attributes:{"anthropic.skill.id":e}})})}list(e={},t){let{workspace_id:n,...s}=e??{};return this._client.getAPIList("/v1/skills",w,{query:s,...t,headers:d([{...n!=null?{"anthropic-workspace-id":n}:void 0},t?.headers]),__span:c(this._client,"anthropic.skills.list",t,{route:"/v1/skills",queryParams:["limit","page","source"]})})}delete(e,t={},n){let{workspace_id:s}=t??{};return this._client.delete(u`/v1/skills/${e}`,{...n,headers:d([{...s!=null?{"anthropic-workspace-id":s}:void 0},n?.headers]),__span:c(this._client,"anthropic.skills.delete",n,{route:"/v1/skills/{skill_id}",attributes:{"anthropic.skill.id":e}})})}}return r.SkillReadBlockedUndecryptableError=bn,r.Versions=gn,r})();var yn=class extends f{create(i,e,t){let{workspace_id:n,...s}=e;return this._client.post(u`/v1/user_profiles/${i}/action_urls`,{body:s,...t,headers:d([{...n!=null?{"anthropic-workspace-id":n}:void 0},t?.headers]),__span:c(this._client,"anthropic.user_profiles.action_urls.create",t,{route:"/v1/user_profiles/{user_profile_id}/action_urls",attributes:{"anthropic.user_profile.id":i}})})}};var wn=(()=>{class r extends R{}return r._errorName="UserProfileNotFoundError",r})(),ba=(()=>{class r extends f{constructor(){super(...arguments),this.actionURLs=new yn(this._client)}create(e,t){let{workspace_id:n,...s}=e;return this._client.post("/v1/user_profiles",{body:s,...t,headers:d([{...n!=null?{"anthropic-workspace-id":n}:void 0},t?.headers]),__span:c(this._client,"anthropic.user_profiles.create",t,{route:"/v1/user_profiles",createdIDAttribute:"anthropic.user_profile.id"})})}retrieve(e,t={},n){let{workspace_id:s}=t??{};return this._client.get(u`/v1/user_profiles/${e}`,{...n,headers:d([{...s!=null?{"anthropic-workspace-id":s}:void 0},n?.headers]),__span:c(this._client,"anthropic.user_profiles.retrieve",n,{route:"/v1/user_profiles/{user_profile_id}",attributes:{"anthropic.user_profile.id":e}})})}update(e,t,n){let{workspace_id:s,...a}=t;return this._client.post(u`/v1/user_profiles/${e}`,{body:a,...n,headers:d([{...s!=null?{"anthropic-workspace-id":s}:void 0},n?.headers]),__span:c(this._client,"anthropic.user_profiles.update",n,{route:"/v1/user_profiles/{user_profile_id}",attributes:{"anthropic.user_profile.id":e}})})}list(e={},t){let{workspace_id:n,...s}=e??{};return this._client.getAPIList("/v1/user_profiles",w,{query:s,...t,headers:d([{...n!=null?{"anthropic-workspace-id":n}:void 0},t?.headers]),__span:c(this._client,"anthropic.user_profiles.list",t,{route:"/v1/user_profiles",queryParams:["enforcement_status","limit","order","order_by","page"]})})}delete(e,t={},n){let{workspace_id:s}=t??{};return this._client.delete(u`/v1/user_profiles/${e}`,{...n,headers:d([{...s!=null?{"anthropic-workspace-id":s}:void 0},n?.headers]),__span:c(this._client,"anthropic.user_profiles.delete",n,{route:"/v1/user_profiles/{user_profile_id}",attributes:{"anthropic.user_profile.id":e}})})}}return r.UserProfileNotFoundError=wn,r.ActionURLs=yn,r})();var mh=new Map([["400 already_member",aa],["400 available_tools_limit_exceeded",zi],["400 cannot_invite_emails_with_unverified_domains",oa],["400 cannot_remove_last_member",ua],["400 cannot_sign_out_primary_owner",bs],["400 cannot_sign_out_self",ys],["400 claude_code_key_creator_not_member",so],["400 claude_code_version_too_old",ao],["400 cmek_key_disabled",oo],["400 cmek_key_network_blocked",co],["400 compaction_block_ambiguous",Oi],["400 compaction_block_misplaced",Ni],["400 compaction_content_mismatch",Mi],["400 compaction_incomplete_turn",qi],["400 compaction_nothing_to_summarize",Bi],["400 compaction_signature_invalid",Li],["400 compaction_too_many_tool_references",$i],["400 compaction_tool_changes_mismatch",Fi],["400 email_domain_not_allowed",ca],["400 environment_archived",ts],["400 external_key_in_workspace_policy",ra],["400 external_key_validation_failed",ia],["400 external_key_validation_timed_out",na],["400 file_not_downloadable",nr],["400 invalid_config_type_change",rs],["400 invalid_metadata",is],["400 invite_already_exists",la],["400 key_profile_mismatch",ha],["400 org_api_key_limit_exceeded",ea],["400 org_member_limit_exceeded",fn],["400 organization_not_enrolled_in_beta",Ri],["400 organization_on_hold",lo],["400 organization_type_not_supported",uo],["400 rbac_group_grants_owner_access",da],["400 rbac_group_owner_access_unconfirmed",pa],["400 request_body_encoding_invalid",po],["400 request_body_encoding_unsupported",ho],["400 scan_failed",Ss],["400 slack_channel_set_up_settings_refused",Rs],["400 storage_quota_exceeded",sr],["400 thread_already_continued",Ui],["400 thread_continue_in_flight",Hi],["400 thread_fingerprint_mismatch",Wi],["400 thread_unsupported_request",ji],["400 tool_name_conflict",Ki],["400 tool_reference_unresolved",Di],["400 unsupported_charset",Ci],["400 user_profile_not_found",wn],["400 workspace_api_key_limit_exceeded",ta],["400 workspace_member_limit_exceeded",_a],["400 workspace_policy_violation",fa],["403 api_key_scope_missing",Cs],["403 cannot_sign_out_managed_member",ws],["403 cannot_sign_out_membership_admin",vs],["403 cannot_sign_out_owner",ks],["403 cannot_sign_out_privileged_member",Es],["403 claude_tag_writes_not_enabled",Is],["403 compliance_configuration_restricted",zs],["403 environment_create_disabled",ns],["403 environment_update_disabled",ss],["403 organization_level_scoped_api_key_required",Os],["403 sandbox_egress_restricted",_o],["403 spend_limits_admin_api_writes_not_enabled",qs],["404 environment_not_found",as],["404 file_expired",ar],["404 slack_channel_set_up_environment_not_found",Ns],["404 thread_not_found",Vi],["409 concurrent_membership_change",mn],["409 external_key_changed",sa],["409 plugin_name_taken",As],["409 scan_pending",xs],["409 skill_name_taken",Ps],["409 skill_read_blocked_undecryptable",bn],["409 slack_channel_set_up_settings_conflict",Ms],["412 heartbeat_precondition_failed",es],["413 request_body_too_large_after_decoding",fo],["429 enforced_spend_limit_reached",mo],["429 ramp_limit_exceeded",go],["503 cmek_context_unavailable",bo],["503 cmek_key_unreachable",yo],["503 registration_pending",Ts],["529 compaction_unavailable",Gi]]);var bh="urn:ietf:params:oauth:grant-type:jwt-bearer",yh="refresh_token",ol="/v1/oauth/token",Ht="oauth-2025-04-20",wh="oidc-federation-2026-04-01",vh=120,vn=30,kh=5,gh=1<<20;function cl(r){if(!r)return;let i;try{i=new URL(r)}catch(t){throw new W(`Invalid token endpoint base URL "${r}": ${t}`)}if(i.protocol==="https:")return;let e=i.hostname.toLowerCase().replace(/^\[|\]$/g,"");if(!(i.protocol==="http:"&&(e==="localhost"||e==="127.0.0.1"||e==="::1")))throw new W(`Refusing to send credential over non-https token endpoint "${r}"`)}async function ll(r,i){let e=await vb(r),t;try{t=JSON.parse(e)}catch{throw new W(`Token endpoint returned non-JSON response (status ${r.status})`,r.status,ye(e),i)}if(!t.access_token)throw new W(`Token endpoint response missing access_token: ${JSON.stringify(ye(t))}`,r.status,ye(t),i);if(t.token_type&&t.token_type.toLowerCase()!=="bearer")throw new W(`Token endpoint response: unsupported token_type "${t.token_type}" (want Bearer)`,r.status,ye(t),i);return t}var qu=2e3,wb=new Set(["error","error_description","error_uri"]);function ye(r){if(r==null)return r;if(typeof r=="string"){let i;try{i=JSON.parse(r)}catch{return r.length<=qu?r:r.slice(0,qu)+`... <${r.length-qu} more chars>`}return JSON.stringify(ye(i))}if(typeof r=="object"&&!Array.isArray(r)){let i={};for(let[e,t]of Object.entries(r))wb.has(e)&&(i[e]=t);return i}return null}async function ul(r,i=e=>console.warn(`anthropic-sdk: ${e}`)){if(typeof process>"u"||process.platform==="win32")return;let{fs:e}=await import("./node-ZSGIX7K3.js"),t=r,n;try{t=await e.promises.realpath(r),n=await e.promises.stat(t)}catch{return}let s=n.mode&511;if(s&18)throw new W(`Credentials file at ${t} is group/world-writable (mode 0o${s.toString(8)}); this allows other local users to plant tokens. Run \`chmod 600 ${t}\`.`);if(s&36)throw new W(`Credentials file at ${t} is group/world-readable (mode 0o${s.toString(8)}); run \`chmod 600 ${t}\` before retrying.`);typeof process.getuid=="function"&&n.uid!==process.getuid()&&i(`credentials file at ${t} is owned by uid ${n.uid} (current process uid ${process.getuid()}); verify this is intentional.`)}async function dl(r,i){let{fs:e,path:t}=await import("./node-ZSGIX7K3.js"),n=t.dirname(r);await e.promises.mkdir(n,{recursive:!0,mode:448});let s=`${r}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;try{let a=await e.promises.open(s,"w",384);try{await a.writeFile(JSON.stringify(i,null,2)),await a.sync()}finally{await a.close()}await e.promises.rename(s,r)}catch(a){throw await e.promises.unlink(s).catch(()=>{}),a}try{let a=await e.promises.open(n,"r");try{await a.sync()}finally{await a.close()}}catch{}}async function vb(r){if(!r.body)return"";let i=r.body.getReader(),e=[],t=0;for(;;){let{done:s,value:a}=await i.read();if(s)break;if(t+a.length>gh){let l=gh-t;l>0&&e.push(a.subarray(0,l)),await i.cancel();break}e.push(a),t+=a.length}let n;if(e.length===1)n=e[0];else{n=new Uint8Array(e.reduce((a,l)=>a+l.length,0));let s=0;for(let a of e)n.set(a,s),s+=a.length}return new TextDecoder("utf-8").decode(n)}var W=(()=>{class r extends S{constructor(e,t=null,n=null,s=null){super(e),this.statusCode=t,this.body=n,this.requestId=s}}return r._errorName="WorkloadIdentityError",r})();function Be(){return Math.floor(Date.now()/1e3)}var pl=class{constructor(i,e){this.cached=null,this.pendingRefresh=null,this.nextForce=!1,this.lastAdvisoryError=0,this.provider=i,this.onAdvisoryRefreshError=e}async getToken(){let i=this.nextForce;this.nextForce=!1;let e=this.cached;if(i||e==null)return(await this.refresh(i)).token;if(e.expiresAt==null)return e.token;let t=e.expiresAt-Be();return t>vh?e.token:t>vn?(this.backgroundRefresh(),e.token):(await this.refresh()).token}invalidate(){this.cached=null,this.nextForce=!0}refresh(i=!1){return this.pendingRefresh&&!i?this.pendingRefresh:this.doRefresh(i)}backgroundRefresh(){this.pendingRefresh||Be()-this.lastAdvisoryError<kh||this.doRefresh().catch(i=>{this.lastAdvisoryError=Be(),this.onAdvisoryRefreshError?.(i)})}doRefresh(i=!1){return this.pendingRefresh=this.provider(i?{forceRefresh:!0}:void 0).then(e=>(this.cached=e,this.pendingRefresh=null,e),e=>{throw this.pendingRefresh=null,e}),this.pendingRefresh}};var hl="1.0",kb=/^[A-Za-z0-9_.-]+$/;function Eh(r){if(!r)throw new Error("profile name is empty");if(r==="."||r==="..")throw new Error(`profile name "${r}" is not allowed`);if(r.includes("/")||r.includes("\\"))throw new Error(`profile name "${r}" must not contain path separators`);if(!kb.test(r))throw new Error(`profile name "${r}" contains disallowed characters (allowed: letters, digits, '_', '.', '-')`)}var Sh=async r=>{var i,e;let t=await Bu();if(t===null)return null;let n=r==null&&z("ANTHROPIC_PROFILE")!=null,s=null;if(r==null&&!n){let y=z("ANTHROPIC_ORGANIZATION_ID"),v=z("ANTHROPIC_IDENTITY_TOKEN_FILE"),k=z("ANTHROPIC_FEDERATION_RULE_ID");if(k&&y&&(s={fromFile:!1,config:{organization_id:y,workspace_id:z("ANTHROPIC_WORKSPACE_ID"),base_url:z("ANTHROPIC_BASE_URL"),authentication:{type:"oidc_federation",federation_rule_id:k,service_account_id:z("ANTHROPIC_SERVICE_ACCOUNT_ID"),identity_token:v?{source:"file",path:v}:void 0,scope:z("ANTHROPIC_SCOPE")}}},v||z("ANTHROPIC_IDENTITY_TOKEN")))return s}let a=r??await xh();if(a===null)return null;Eh(a);let{fs:l,path:p}=await import("./node-ZSGIX7K3.js"),h=p.join(t,"configs",`${a}.json`),m;try{m=await l.promises.readFile(h,"utf-8")}catch(y){if(y?.code!=="ENOENT")throw new Error(`failed to read config file ${h}: ${y}`);if(n)throw new S(`ANTHROPIC_PROFILE names the profile "${a}", but ${h} does not exist. Set ANTHROPIC_PROFILE to a profile that exists, or unset it.`,{cause:y});return s}let _;try{_=JSON.parse(m)}catch(y){throw new Error(`failed to parse config file ${h}: ${y}`)}if(!_.authentication)throw new Error(`config file ${h} is missing "authentication"`);let g=_.authentication.type;if(g!=="oidc_federation"&&g!=="user_oauth")throw new Error(`authentication.type "${g}" is not a known authentication type`);if(_.organization_id??(_.organization_id=z("ANTHROPIC_ORGANIZATION_ID")),_.workspace_id??(_.workspace_id=z("ANTHROPIC_WORKSPACE_ID")),_.base_url??(_.base_url=z("ANTHROPIC_BASE_URL")),(i=_.authentication).scope??(i.scope=z("ANTHROPIC_SCOPE")),_.authentication.type==="oidc_federation"){if(!_.authentication.identity_token){let y=z("ANTHROPIC_IDENTITY_TOKEN_FILE");y&&(_.authentication.identity_token={source:"file",path:y})}_.authentication.federation_rule_id||(_.authentication.federation_rule_id=z("ANTHROPIC_FEDERATION_RULE_ID")??""),(e=_.authentication).service_account_id??(e.service_account_id=z("ANTHROPIC_SERVICE_ACCOUNT_ID"))}return{config:_,fromFile:!0}};var Ah=async(r,i)=>{if(r?.authentication.credentials_path)return r.authentication.credentials_path;let e=await Bu();if(!e)return null;let t=i??await xh();if(!t)return null;Eh(t);let{path:n}=await import("./node-ZSGIX7K3.js");return n.join(e,"credentials",`${t}.json`)},Bu=async()=>{if(!Eb())return null;let{path:r}=await import("./node-ZSGIX7K3.js"),i=z("ANTHROPIC_CONFIG_DIR");if(i)return i;if(Sn()["X-Stainless-OS"]==="Windows"){let s=z("APPDATA");if(s)return r.join(s,"Anthropic");let a=z("USERPROFILE");return a?r.join(a,"AppData","Roaming","Anthropic"):null}let t=z("XDG_CONFIG_HOME");if(t)return r.join(t,"anthropic");let n=z("HOME");return n?r.join(n,".config","anthropic"):null},Eb=()=>{let r=Sn()["X-Stainless-Runtime"];return r==="node"||r==="deno"},xh=async()=>{let r=await Bu();if(!r)return null;let i=z("ANTHROPIC_PROFILE");if(i)return i;let{fs:e,path:t}=await import("./node-ZSGIX7K3.js"),n=t.join(r,"active_config");try{return(await e.promises.readFile(n,"utf-8")).trim()||"default"}catch(s){if(s?.code!=="ENOENT")throw new Error(`failed to read ${n}: ${s}`);return"default"}};function Lu(r){if(!r)throw new S("Identity token file path is empty");return async()=>{let{fs:i}=await import("./node-ZSGIX7K3.js"),e;try{e=await i.promises.readFile(r,"utf-8")}catch(n){throw new S(`Failed to read identity token file at ${r}: ${n}`)}let t=e.trim();if(!t)throw new S(`Identity token file at ${r} is empty`);return t}}function Ph(r){if(!r)throw new S("Identity token value is empty");return()=>r}function Th(r){return async()=>{cl(r.baseURL);let i=await r.identityTokenProvider();if(i.length>16*1024)throw new W(`Identity token is ${Math.ceil(i.length/1024)} KiB, exceeds the 16 KiB assertion limit`);let e={grant_type:bh,assertion:i,federation_rule_id:r.federationRuleId,organization_id:r.organizationId};r.serviceAccountId&&(e.service_account_id=r.serviceAccountId),r.workspaceId&&(e.workspace_id=r.workspaceId);let t=`${r.baseURL}${ol}`,n;try{n=await r.fetch(t,{method:"POST",redirect:"manual",headers:{"Content-Type":"application/json","anthropic-beta":`${Ht},${wh}`,"User-Agent":r.userAgent||`anthropic-sdk-typescript/${we} oidcFederationProvider`},body:JSON.stringify(e)})}catch(p){throw new W(`Failed to reach token endpoint ${t}: ${p}`)}let s=n.headers.get("Request-Id");if(!n.ok){let p=await n.text().catch(()=>""),h=ye(p),m="";throw n.status===401&&(m=` Ensure your federation rule matches your identity token. ${r.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 W(`Token exchange failed with status ${n.status}${s?` (request-id ${s})`:""}: ${h}${m}`,n.status,h,s)}let a=await ll(n,s),l=Number(a.expires_in);if(!Number.isFinite(l))throw new W(`Token endpoint response missing required fields: ${JSON.stringify(ye(a))}`,n.status,ye(a),s);return{token:a.access_token,expiresAt:Be()+l}}}function Rh(r){return async i=>{let{fs:e}=await import("./node-ZSGIX7K3.js");await ul(r.credentialsPath,r.onSafetyWarning);let t;try{t=await e.promises.readFile(r.credentialsPath,"utf-8")}catch(E){throw new W(`Credentials file not found at ${r.credentialsPath}: ${E}`)}let n;try{n=JSON.parse(t)}catch(E){throw new W(`Credentials file at ${r.credentialsPath} is not valid JSON: ${E}`)}let s=n.access_token;if(!s)throw new W(`Credentials file at ${r.credentialsPath} must include 'access_token'`);let a=n.expires_at;if(!i?.forceRefresh&&(a==null||Be()<a-vn))return{token:s,expiresAt:a??null};let l=n.refresh_token;if(!r.clientId||!l)throw new W(`Access token at ${r.credentialsPath} has expired and no refresh is available (client_id ${r.clientId?"set":"empty"}, refresh_token ${l?"set":"empty"})`);cl(r.baseURL);let p={grant_type:yh,refresh_token:l,client_id:r.clientId},h=`${r.baseURL}${ol}`,m;try{m=await r.fetch(h,{method:"POST",redirect:"manual",headers:{"Content-Type":"application/json","anthropic-beta":Ht,"User-Agent":r.userAgent||`anthropic-sdk-typescript/${we} userOAuthProvider`},body:JSON.stringify(p)})}catch(E){throw new W(`User OAuth refresh failed to reach token endpoint: ${E}`)}let _=m.headers.get("Request-Id");if(!m.ok){let E=await m.text().catch(()=>"");throw new W(`User OAuth refresh failed (HTTP ${m.status}): ${ye(E)}`,m.status,ye(E),_)}let g=await ll(m,_),y=Number(g.expires_in);if(!Number.isFinite(y))throw new W(`User OAuth refresh response missing or invalid expires_in: ${JSON.stringify(ye(g))}`,m.status,ye(g),_);let v=Be()+y,k=g.refresh_token||l;return await dl(r.credentialsPath,{...n,version:hl,type:"oauth_token",access_token:g.access_token,expires_at:v,refresh_token:k}),{token:g.access_token,expiresAt:v}}}function $u(r,i){let e=r.authentication.credentials_path??null,t=(r.base_url||i.baseURL).replace(/\/+$/,""),n=Sb(r,e,t,i),s={};return r.workspace_id&&r.authentication.type==="user_oauth"&&(s["anthropic-workspace-id"]=r.workspace_id),{provider:n,extraHeaders:s,baseURL:r.base_url||void 0}}async function Ch(r,i){let e=await Sh(i);if(!e)return null;let{config:t,fromFile:n}=e,s=t.authentication.credentials_path||!n?t:{...t,authentication:{...t.authentication,credentials_path:await Ah(t,i)??void 0}};return $u(s,r)}function Sb(r,i,e,t){switch(r.authentication.type){case"oidc_federation":{let n=r.authentication,s=Ab(n);if(!s)throw new W("oidc_federation config requires an identity token (set authentication.identity_token, ANTHROPIC_IDENTITY_TOKEN_FILE, or ANTHROPIC_IDENTITY_TOKEN)");if(!n.federation_rule_id)throw new W("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(!r.organization_id)throw new W("oidc_federation config requires organization_id (set ANTHROPIC_ORGANIZATION_ID or config.organization_id)");let a=Th({identityTokenProvider:s,federationRuleId:n.federation_rule_id,organizationId:r.organization_id,serviceAccountId:n.service_account_id,workspaceId:r.workspace_id,baseURL:e,fetch:t.fetch,userAgent:t.userAgent});return i?xb(a,i,t.onCacheWriteError,t.onSafetyWarning):a}case"user_oauth":{if(!i)throw new W("user_oauth config requires authentication.credentials_path (or load via a profile so it defaults to <config_dir>/credentials/<profile>.json)");return Rh({credentialsPath:i,clientId:r.authentication.client_id,baseURL:e,fetch:t.fetch,userAgent:t.userAgent,onSafetyWarning:t.onSafetyWarning})}default:{let n=r.authentication.type;throw new W(`authentication.type "${n}" is not a known authentication type`)}}}function Ab(r){if(r.identity_token){let t=r.identity_token.source;if(t!=="file")throw new W(`identity_token.source "${t}" is not supported by this SDK version (only "file")`);if(!r.identity_token.path)throw new W('identity_token.source "file" requires a non-empty path');return Lu(r.identity_token.path)}let i=z("ANTHROPIC_IDENTITY_TOKEN_FILE");if(i)return Lu(i);let e=z("ANTHROPIC_IDENTITY_TOKEN");return e?Ph(e):null}function xb(r,i,e,t){return async n=>{let{fs:s}=await import("./node-ZSGIX7K3.js");await ul(i,t);let a;try{let p=await s.promises.readFile(i,"utf-8");a=JSON.parse(p);let h=a?.access_token;if(h&&!n?.forceRefresh){let m=a?.expires_at;if(m==null||Be()<m-vn)return{token:h,expiresAt:m??null}}}catch(p){p?.code!=="ENOENT"&&!(p instanceof SyntaxError)&&e?.(p)}let l=await r(n);try{await dl(i,{...a??{},version:hl,type:"oauth_token",access_token:l.token,expires_at:l.expiresAt})}catch(p){e?.(p)}return l}}var zh=new WeakSet;function Fu(r){return typeof r=="object"&&r!==null&&zh.has(r)}function Oh(r){let i=new Set;for(;typeof r=="object"&&r!==null&&!i.has(r);){if(i.add(r),Fu(r)||de(r)||r instanceof Le||r instanceof gl)return!0;r=r.cause}return!1}function Uu(r,i,e,t){return async(n,s={})=>{if(i.length===0)return r.call(void 0,n,s);let a=s.headers instanceof Headers?s.headers:new Headers(s.headers),l=await Tb(r,i,e,t)({...s,headers:a,url:typeof n=="string"?n:n instanceof URL?n.href:n.url});if(l.bodyUsed||l.body?.locked)throw new S("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 Pb(r,i){let e=new WeakMap;return{options:r,logger:i?I(i):La(),parse(t){if(r?.stream&&t.ok)return Ih(t,r,i);let n=e.get(t);return n||(n=Ih(t,r,i),e.set(t,n)),n}}}async function Ih(r,i,e){if(r.bodyUsed||r.body?.locked)throw new S("cannot ctx.parse() a response whose body was already consumed; call ctx.parse() instead of reading the body, or read via response.clone()");if(i?.stream&&r.ok)return re.fromSSEResponse(r.clone(),new AbortController,e);if(r.status===204)return null;if(i?.__binaryResponse)return r;let n=r.headers.get("content-type")?.split(";")[0]?.trim();return n?.includes("application/json")||n?.endsWith("+json")?r.headers.get("content-length")==="0"?void 0:Rt(await r.clone().json(),r):await r.clone().text()}function Tb(r,i,e,t){let n=async({url:a,...l})=>{try{return await r.call(void 0,a,l)}catch(p){let h=ct(p);throw zh.add(h),h}},s=Pb(e,t);for(let a=i.length-1;a>=0;a--){let l=i[a],p=n;n=async h=>l(h,p,s)}return n}var Nh=r=>r!=null&&typeof r=="object"&&typeof r.size=="number"&&typeof r.type=="string"&&typeof r.text=="function"&&typeof r.slice=="function"&&typeof r.arrayBuffer=="function",Rb=r=>r!=null&&typeof r=="object"&&typeof r.name=="string"&&typeof r.lastModified=="number"&&Nh(r),Cb=r=>r!=null&&typeof r=="object"&&typeof r.url=="string"&&typeof r.blob=="function";async function _l(r,i,e){if(zl(),r=await r,i||(i=r instanceof File?r.name:zn(r,!0)),Rb(r))return r instanceof File&&i==null&&e==null?r:Ct([await r.arrayBuffer()],i??r.name,{type:r.type,lastModified:r.lastModified,...e});if(Cb(r)){let n=await r.blob();return i||(i=new URL(r.url).pathname.split(/[\\/]/).pop()),Ct(await Hu(n),i,e)}let t=await Hu(r);if(!e?.type){let n=t.find(s=>typeof s=="object"&&"type"in s&&s.type);typeof n=="string"&&(e={...e,type:n})}return Ct(t,i,e)}async function Hu(r){let i=[];if(typeof r=="string"||ArrayBuffer.isView(r)||r instanceof ArrayBuffer)i.push(r);else if(Nh(r))i.push(r instanceof Blob?r:await r.arrayBuffer());else if(On(r))for await(let e of r)i.push(...await Hu(e));else{let e=r?.constructor?.name;throw new Error(`Unexpected data type: ${typeof r}${e?`; constructor: ${e}`:""}${Ib(r)}`)}return i}function Ib(r){return typeof r!="object"||r===null?"":`; props: [${Object.getOwnPropertyNames(r).map(e=>`"${e}"`).join(", ")}]`}var Wt=class extends f{retrieve(i,e={},t){let{workspace_id:n}=e??{};return this._client.get(u`/v1/models/${i}`,{...t,headers:d([{...n!=null?{"anthropic-workspace-id":n}:void 0},t?.headers]),__span:c(this._client,"anthropic.models.retrieve",t,{route:"/v1/models/{model_id}",attributes:{"anthropic.model.id":i}})})}list(i={},e){let{workspace_id:t,...n}=i??{};return this._client.getAPIList("/v1/models",U,{query:n,...e,headers:d([{...t!=null?{"anthropic-workspace-id":t}:void 0},e?.headers]),__span:c(this._client,"anthropic.models.list",e,{route:"/v1/models",queryParams:["after_id","before_id","lifecycle","limit"]})})}};var Wu,ju,fl,kn,jt,Mh,qh=!1,Bh=(()=>{class r{get credentials(){return this._authState.provider}get openTelemetry(){return o(this,jt,"f")}_instrumentationScope(){return{version:we}}constructor({baseURL:e=z("ANTHROPIC_BASE_URL"),apiKey:t,authToken:n,webhookKey:s=z("ANTHROPIC_WEBHOOK_SIGNING_KEY")??null,...a}={}){Wu.add(this),this._requestAuthFlags=new WeakMap,fl.set(this,void 0),kn.set(this,void 0),jt.set(this,void 0),this._genAIProviderName="anthropic",this._supportsMessageThreads=!1;let l={apiKey:t,authToken:n,...a},p=xt.filter(E=>l[E]!=null);if(p.length>1){let E=T=>T.map(x=>`\`${x}\``).join(", ");throw new TypeError(`Pass at most one of ${E(xt)}. Received ${E(p)}.`)}let[h]=p,m=h!=null?null:{apiKey:t===void 0?z("ANTHROPIC_API_KEY"):void 0,authToken:n===void 0?z("ANTHROPIC_AUTH_TOKEN"):void 0},_=h!=null?{type:h,value:l[h]}:m?.apiKey!=null?{type:"apiKey",value:m.apiKey}:m?.authToken!=null?{type:"authToken",value:m.authToken}:{type:"defaultChain"},g={apiKey:_.type==="apiKey"?_.value:null,authToken:_.type==="authToken"?_.value:null,webhookKey:s,...a,baseURL:e||"https://api.anthropic.com"};if(!g.dangerouslyAllowBrowser&&Zu())throw new S(`It looks like you're running in a browser-like environment.
15
-
16
- This is disabled by default, as it risks exposing your secret API credentials to attackers.
17
- If you understand the risks and have appropriate mitigations in place,
18
- you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
19
-
20
- new Anthropic({ apiKey, dangerouslyAllowBrowser: true });
21
- `);this.baseURL=g.baseURL,this._baseURLIsExplicit=a.__baseURLIsExplicit??!!e,this.timeout=g.timeout??ju.DEFAULT_TIMEOUT,this.logger=g.logger??console,this.logLevel=Tn,this.logLevel=Ba(g.logLevel,"ClientOptions.logLevel",I(this))??Ba(z("ANTHROPIC_LOG"),"process.env['ANTHROPIC_LOG']",I(this))??Tn,m?.apiKey!=null&&m.authToken!=null&&!qh&&(qh=!0,I(this).warn("Anthropic: ANTHROPIC_API_KEY and ANTHROPIC_AUTH_TOKEN are both set. Using ANTHROPIC_API_KEY.")),this.fetchOptions=g.fetchOptions,this.maxRetries=Ra("maxRetries",g.maxRetries??2);let y=this._instrumentationScope();b(this,jt,_d(g.openTelemetry),"f"),g.openTelemetry=o(this,jt,"f"),this._tracer=M(this,()=>fd(o(this,jt,"f"),y.version,y.platform)),this.fetch=g.fetch??nd(),b(this,fl,sd,"f"),this.middleware=[...g.middleware??[]];let v=z("ANTHROPIC_CUSTOM_HEADERS");if(v){let E={};for(let T of v.split(`
22
- `)){let x=T.indexOf(":");x>=0&&(E[T.substring(0,x).trim()]=T.substring(x+1).trim())}g.defaultHeaders={...E,...g.defaultHeaders}}let k=a.__auth;if(delete g.__auth,delete g.__baseURLIsExplicit,this._options=g,this.apiKey=typeof g.apiKey=="string"?g.apiKey:null,b(this,kn,typeof g.apiKey=="function"?g.apiKey:null,"f"),this.authToken=g.authToken??null,this.webhookKey=s,k)this._authState=k,!this._baseURLIsExplicit&&k.baseURL&&(this.baseURL=k.baseURL);else switch(this._authState={provider:null,tokenCache:null,resolution:null,error:null,extraHeaders:{}},_.type){case"apiKey":case"authToken":break;case"credentials":this._authState.provider=_.value,this._authState.tokenCache=this._makeTokenCache(_.value);break;case"config":{let E=$u(_.value,this._credentialResolverOptions());this._authState.provider=E.provider,this._authState.tokenCache=this._makeTokenCache(E.provider),this._authState.extraHeaders=E.extraHeaders,this._applyCredentialBaseURL(E.baseURL);break}case"profile":this._authState.resolution=this._resolveDefaultCredentials(_.value);break;case"defaultChain":this._shouldResolveDefaultCredentials()&&(this._authState.resolution=this._resolveDefaultCredentials());break;default:}}_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=>{I(this).debug("credential cache write failed (best-effort)",e)},onSafetyWarning:e=>{I(this).warn(e)}}}_credentialsFetch(){return Uu(this.fetch,this.middleware,void 0,this)}_makeTokenCache(e){return new pl(e,t=>{I(this).debug("advisory token refresh failed; serving cached token",t)})}withOptions(e){e={...e};for(let a of xt)e[a]===void 0&&delete e[a];let t=xt.some(a=>a in e),n=xt.some(a=>e[a]!=null),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??o(this,kn,"f"),authToken:this.authToken,webhookKey:this.webhookKey,...n?Object.fromEntries(xt.map(a=>[a,null])):{},...e,openTelemetry:e.openTelemetry??o(this,jt,"f"),__auth:t?void 0:this._authState,__baseURLIsExplicit:"baseURL"in e?!0:this._baseURLIsExplicit};return new this.constructor(s)}async _resolveDefaultCredentials(e){try{let t=await Ch(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 S(`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("authorization"))&&!t.has("authorization")&&!(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 the "Authorization" header 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(o(this,kn,"f")&&this.apiKey==null){let t;try{t=await o(this,kn,"f").call(this)}catch(n){throw new S(`The \`apiKey\` function failed: ${ct(n).message}`,{cause:n})}if(!t)throw new S(`The \`apiKey\` function must return a non-empty string. It returned ${JSON.stringify(t)}.`);return d([{Authorization:`Bearer ${t}`}])}if(this._authState.tokenCache&&this.apiKey==null){let t=await this._authState.tokenCache.getToken();return this._authFlags(e).usedTokenCache=!0,d([{Authorization:`Bearer ${t}`}])}return d([await this.bearerAuth(e),await this.apiKeyAuth(e)])}}async apiKeyAuth(e){if(this.apiKey!=null)return d([{Authorization:`Bearer ${this.apiKey}`}])}async bearerAuth(e){if(this.authToken!=null)return d([{Authorization:`Bearer ${this.authToken}`}])}stringifyQuery(e){return Cd(e)}getUserAgent(){return`Anthropic/JS ${we}`}makeStatusError(e,t,n,s){let l=(t??{}).error?.details?.error_code,p=typeof l=="string"?mh.get(`${e} ${l}`):void 0;return p?new p(e,t,n,s):F.generate(e,t,n,s)}buildURL(e,t,n){let s=!o(this,Wu,"m",Mh).call(this)&&n||this.baseURL,a=Gu(e)?new URL(e):new URL(s+(s.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),l=this.defaultQuery(),p=Object.fromEntries(a.searchParams);return(!bl(l)||!bl(p))&&(t={...p,...l,...t}),typeof t=="object"&&t&&!Array.isArray(t)&&(a.search=this.stringifyQuery(t)),a.toString()}_calculateNonstreamingTimeout(e){if(3600*e/128e3>600)throw new S("Streaming is required for operations that may take longer than 10 minutes. See https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/typescript#streaming-responses for more details");return 600*1e3}async prepareOptions(e){}async prepareRequest(e,{url:t,options:n}){if(this._authState.tokenCache&&this.apiKey==null){let s=e.headers instanceof Headers?e.headers:new Headers(e.headers);for(let[l,p]of Object.entries(this._authState.extraHeaders))s.has(l)||s.set(l,p);let a=s.get("anthropic-beta")?.split(",").map(l=>l.trim());a?.includes(Ht)||s.set("anthropic-beta",[...a??[],Ht].join(",")),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,n){return this.request(Promise.resolve(n).then(s=>({method:e,path:t,...s})))}request(e,t=null){return this._tracer?new et(this,this.makeTracedRequest(e,t)):new et(this,this.makeRequest(e,t,void 0))}async makeTracedRequest(e,t){let n=await e,s=n.__span?.span;if(!s)return this.makeRequest(n,t,void 0);try{return await Q.with(Te.setSpan(Q.active(),s),()=>this.makeRequest(n,t,void 0,s))}catch(a){let l={status:"error",options:n,error:a};throw M(this,()=>ut(s,l)),a}}async makeRequest(e,t,n,s){let a=await e,l=Ra("maxRetries",a.maxRetries??this.maxRetries);this.isStreamBody(a.body)&&(l=0),t==null&&(t=l,this._requestAuthFlags.delete(a)),await this.prepareOptions(a);let{req:p,url:h,timeout:m}=await this.buildRequest(a,{retryCount:l-t}),_="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),g=n===void 0?"":`, retryOf: ${n}`;s&&this.openTelemetry.propagation&&(p.headers=M(this,()=>yd(s,p.headers))??p.headers);let y=Date.now();if(a.signal?.aborted)throw new ee;let v=new AbortController,k=await this.fetchWithTimeout(h,p,m,v,a,{requestLogID:_,retryOfRequestLogID:n}).catch(ct),E=Date.now();if(k instanceof globalThis.Error){$e(v);let C=`retrying, ${t} attempts remaining`;if(a.signal?.aborted)throw new ee;let P=de(k)||/timed? ?out/i.test(String(k)+("cause"in k?String(k.cause):"")),A=this.middleware.length>0||!!a.middleware?.length||this.backendMiddleware().length>0;if(A&&!P&&!Oh(k))throw I(this).info(`[${_}] middleware error (not retryable)`),Fe(I(this),`[${_}] middleware error (not retryable)`,{retryOfRequestLogID:n,url:h,durationMs:E-y,message:k.message}),k;if(t)return I(this).info(`[${_}] connection ${P?"timed out":"failed"} - ${C}`),Fe(I(this),`[${_}] connection ${P?"timed out":"failed"} (${C})`,{retryOfRequestLogID:n,url:h,durationMs:E-y,message:k.message}),this.retryRequest(a,t,n??_,s);throw I(this).info(`[${_}] connection ${P?"timed out":"failed"} - error; no more retries left`),Fe(I(this),`[${_}] connection ${P?"timed out":"failed"} (error; no more retries left)`,{retryOfRequestLogID:n,url:h,durationMs:E-y,message:k.message}),P?new Dt:A&&!Fu(k)?k:new Le({cause:k})}let T=[...k.headers.entries()].filter(([C])=>C==="request-id"||C==="anthropic-workspace-id").map(([C,P])=>", "+C+": "+JSON.stringify(P)).join(""),x=`[${_}${g}${T}] ${p.method} ${h} ${k.ok?"succeeded":"failed"} with status ${k.status} in ${E-y}ms`;if(!k.ok){let C=await this.shouldRetry(k,a);if(t&&C){let $=`retrying, ${t} attempts remaining`;return await za(k.body),$e(v),I(this).info(`${x} - ${$}`),Fe(I(this),`[${_}] response error (${$})`,{retryOfRequestLogID:n,url:k.url,status:k.status,headers:k.headers,durationMs:E-y}),this.retryRequest(a,t,n??_,s,k.headers)}let P=C?"error; no more retries left":"error; not retryable";I(this).info(`${x} - ${P}`);let A=await k.text().catch($=>ct($).message),O=Pt(A),B=O?void 0:A;throw Fe(I(this),`[${_}] response error (${P})`,{retryOfRequestLogID:n,url:k.url,status:k.status,headers:k.headers,body:O??A,durationMs:Date.now()-y}),$e(v),this.makeStatusError(k.status,O,B,k.headers)}return I(this).info(x),Fe(I(this),`[${_}] response start`,{retryOfRequestLogID:n,url:k.url,status:k.status,headers:k.headers,durationMs:E-y}),rd(k.body??k,v),{response:k,options:a,controller:v,requestLogID:_,retryOfRequestLogID:n,startTime:y}}getAPIList(e,t,n){return this.requestAPIList(t,n&&"then"in n?n.then(s=>({method:"get",path:e,...s})):{method:"get",path:e,...n})}requestAPIList(e,t){if(!this._tracer){let s=this.makeRequest(t,null,void 0);return new no(this,s,e)}let n=this.makeTracedRequest(t,null);return new no(this,n,e)}async fetchWithTimeout(e,t,n,s,a,l){let{signal:p,method:h,...m}=t||{},_=this._makeAbort(s);p&&(p.addEventListener("abort",_,{once:!0}),td(s,p,_));let g=globalThis.ReadableStream&&m.body instanceof globalThis.ReadableStream||typeof m.body=="object"&&m.body!==null&&Symbol.asyncIterator in m.body,y={signal:s.signal,...g?{duplex:"half"}:{},method:"GET",...m};h&&(y.method=h.toUpperCase());let v=this.fetch,k=async(P,A)=>{let O=setTimeout(_,n);try{return await v.call(void 0,P,A)}finally{clearTimeout(O)}},E=a===void 0?k:(async(P,A={})=>{let O=typeof P=="string"?P:P instanceof URL?P.href:P.url;A.headers=A.headers instanceof Headers?A.headers:new Headers(A.headers);let B=[];a.__span&&(A.headers=new Headers(A.headers),B=Qa(A.headers)),await this.prepareRequest(A,{url:O,options:a}),B.length&&(A.headers=d([A.headers,B]).values);let L=a.__span;return L&&M(this,()=>bd(L,A.method??"GET",O,this.openTelemetry.traces.contentMode==="content")),l&&Fe(I(this),`[${l.requestLogID}] sending request`,{retryOfRequestLogID:l.retryOfRequestLogID,method:A.method,url:O,options:a,headers:A.headers}),k(P,A)}),T=a?.middleware,x=a?.__span?this.backendMiddleware().map(Ll):this.backendMiddleware(),C=T?.length||x.length?[...this.middleware,...T??[],...x]:this.middleware;return await Uu(E,C,a,this)(e,y)}async shouldRetry(e,t){let n=this._authFlags(t);if(e.status===401&&this._authState.tokenCache&&n.usedTokenCache&&!n.didRefreshFor401)return n.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,n,s,a){let l,p=a?.get("retry-after-ms");if(p){let m=parseFloat(p);Number.isNaN(m)||(l=m)}let h=a?.get("retry-after");if(h&&!l){let m=parseFloat(h);Number.isNaN(m)?l=Date.parse(h)-Date.now():l=m*1e3}if(l===void 0||!(l>0&&l<=2**31-1)){let m=e.maxRetries??this.maxRetries;l=this.calculateDefaultRetryTimeoutMillis(t,m)}return await Oe(l,e.signal??void 0),this.makeRequest(e,t-1,n,s)}calculateDefaultRetryTimeoutMillis(e,t){let a=t-e,l=Math.min(.5*Math.pow(2,a),8),p=1-Math.random()*.25;return l*p*1e3}calculateNonstreamingTimeout(e,t){if(36e5*e/128e3>6e5||t!=null&&e>t)throw new S("Streaming is required for operations that may take longer than 10 minutes. See https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/typescript#long-requests for more details");return 6e5}async buildRequest(e,{retryCount:t=0}={}){let n={...e},{method:s,path:a,query:l,defaultBaseURL:p}=n;this._authState.resolution&&await this._authState.resolution,!this._baseURLIsExplicit&&this._authState.baseURL&&this.baseURL!==this._authState.baseURL&&(this.baseURL=this._authState.baseURL);let h=this.buildURL(a,l,p);"timeout"in n&&Ra("timeout",n.timeout),n.timeout=n.timeout??this.timeout;let{bodyHeaders:m,body:_}=this.buildBody({options:n}),g=await this.buildHeaders({options:e,method:s,bodyHeaders:m,retryCount:t,timeout:n.timeout});return{req:{method:s,headers:g,...n.signal&&{signal:n.signal},...globalThis.ReadableStream&&_ instanceof globalThis.ReadableStream&&{duplex:"half"},..._&&{body:_},...this.fetchOptions??{},...n.fetchOptions??{}},url:h,timeout:n.timeout}}async buildHeaders({options:e,method:t,bodyHeaders:n,retryCount:s,timeout:a}){let l=d([{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(s),"X-Stainless-Timeout":String(Math.trunc(a/1e3)),...Sn(),...this._options.dangerouslyAllowBrowser?{"anthropic-dangerous-direct-browser-access":"true"}:void 0,"anthropic-version":"2026-10-21"},await this.authHeaders(e),this._options.defaultHeaders,n,e.headers]);return this.validateHeaders(l),l.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:t}}){if(!e)return{bodyHeaders:void 0,body:void 0};let n=d([t]);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||typeof e=="string"&&n.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}:this.isStreamBody(e)?{bodyHeaders:void 0,body:Ia(e)}:typeof e=="object"&&n.values.get("content-type")==="application/x-www-form-urlencoded"?{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(e)}:o(this,fl,"f").call(this,{body:e,headers:n})}isStreamBody(e){return globalThis.ReadableStream&&e instanceof globalThis.ReadableStream?!0:typeof e=="object"&&e!==null&&(Symbol.asyncIterator in e||Symbol.iterator in e&&"next"in e&&typeof e.next=="function")}}return ju=r,fl=new WeakMap,kn=new WeakMap,jt=new WeakMap,Wu=new WeakSet,Mh=function(){return this.baseURL!=="https://api.anthropic.com"},r.Anthropic=ju,r.DEFAULT_TIMEOUT=6e5,r.AnthropicError=S,r.APIError=F,r.APIConnectionError=Le,r.APIConnectionTimeoutError=Dt,r.APIUserAbortError=ee,r.NotFoundError=Re,r.ConflictError=le,r.RateLimitError=At,r.BadRequestError=R,r.OverloadedError=Jt,r.AuthenticationError=ka,r.RequestTimeoutError=Ea,r.InternalServerError=lt,r.NotImplementedError=Pa,r.GatewayTimeoutError=Ta,r.ContentTooLargeError=Gt,r.PermissionDeniedError=G,r.PreconditionFailedError=Vt,r.ServiceUnavailableError=Qe,r.UnprocessableEntityError=Sa,r.ClientClosedRequestError=xa,r.RequestHeaderFieldsTooLargeError=Aa,r.toFile=_l,r})(),Lh=(()=>{class r extends Bh{constructor(){super(...arguments),this._supportsMessageThreads=!0,this.messages=new Zs(this),this.models=new Wt(this),this.files=new Fn(this),this.skills=new ga(this),this.userProfiles=new ba(this),this.organization=new ma(this),this.beta=new Ds(this)}}return r.Messages=Zs,r.AvailableToolsLimitExceededError=zi,r.CompactionBlockAmbiguousError=Oi,r.CompactionBlockMisplacedError=Ni,r.CompactionContentMismatchError=Mi,r.CompactionIncompleteTurnError=qi,r.CompactionNothingToSummarizeError=Bi,r.CompactionSignatureInvalidError=Li,r.CompactionTooManyToolReferencesError=$i,r.CompactionToolChangesMismatchError=Fi,r.ThreadAlreadyContinuedError=Ui,r.ThreadContinueInFlightError=Hi,r.ThreadFingerprintMismatchError=Wi,r.ThreadUnsupportedRequestError=ji,r.ToolNameConflictError=Ki,r.ToolReferenceUnresolvedError=Di,r.ThreadNotFoundError=Vi,r.CompactionUnavailableError=Gi,r.Models=Wt,r.Files=Fn,r.FileNotDownloadableError=nr,r.StorageQuotaExceededError=sr,r.FileExpiredError=ar,r.Skills=ga,r.SkillReadBlockedUndecryptableError=bn,r.UserProfiles=ba,r.UserProfileNotFoundError=wn,r.Organization=ma,r.OrgMemberLimitExceededError=fn,r.ConcurrentMembershipChangeError=mn,r.Beta=Ds,r.BetaOrganizationNotEnrolledInBetaError=Ri,r.BetaUnsupportedCharsetError=Ci,r.ClaudeCodeKeyCreatorNotMemberError=so,r.ClaudeCodeVersionTooOldError=ao,r.CMEKKeyDisabledError=oo,r.CMEKKeyNetworkBlockedError=co,r.OrganizationOnHoldError=lo,r.OrganizationTypeNotSupportedError=uo,r.RequestBodyEncodingInvalidError=po,r.RequestBodyEncodingUnsupportedError=ho,r.SandboxEgressRestrictedError=_o,r.RequestBodyTooLargeAfterDecodingError=fo,r.EnforcedSpendLimitReachedError=mo,r.RampLimitExceededError=go,r.CMEKContextUnavailableError=bo,r.CMEKKeyUnreachableError=yo,r})();var Wh=new TextEncoder,Nb=["fallback-credit-2026-07-01"];function Mb(r){let i=r.messages.flatMap(e=>{if(e.role==="system"||!Array.isArray(e.content))return[e];let t=e.content.filter(n=>n.type!=="fallback");return t.length===e.content.length?[e]:t.length>0?[{...e,content:t}]:[]});return{...r,messages:i}}function $h(r,i){let e={...r};for(let[t,n]of Object.entries(i))if(t==="output_config"&&n!=null){let s={...e[t]??{}};for(let[a,l]of Object.entries(n))ml(s,a,l);ml(e,t,Object.keys(s).length?s:null)}else ml(e,t,n);return i.thinking===void 0&&r.thinking?.type==="between_tools"&&(e.thinking={type:"disabled"}),e}function ml(r,i,e){e!==void 0&&(e===null?delete r[i]:r[i]=e)}function qb(r,i={}){let e=!1;return async(t,n,s)=>{let[a]=(s.options?.path??"").split("?");if(r.length===0||s.options?.method!=="post"||a!=="/v1/messages"||s.options.__qualifiers?.beta!=="true"||typeof s.options.body!="object"||s.options.body==null)return n(t);if(s.options.body.fallbacks!=null)throw new S("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 l=i.onError??(A=>s.logger.error(`anthropic-sdk: betaRefusalFallbackMiddleware: ${A.message}`));t=Ub(t,i.betas??Nb);let p=Mb(s.options.body),h=s.options.fallbackState,m=h?.index??-1;if(!Number.isInteger(m)||m<-1||m>=r.length)throw new S(`fallbackState.index ${m} is out of bounds for a chain of ${r.length} fallback(s); was the state shared with a different middleware?`);let _=A=>{h?h.index=A:e||(e=!0,s.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."))},g=m===-1?p:$h(p,r[m]),y=typeof t.body!="string"?t:{...t,body:JSON.stringify(g)},v=m===-1?await n(y):(await Du(n,s,r[m],y)).response;if(!v.ok)return v;if(s.options.stream===!0){let A=m+1;return A>=r.length||typeof y.body!="string"?v:Bb({request:y,response:v,next:n,ctx:s,fallbacks:r,firstHop:A,onError:l,pin:_})}let k=m,E=v,T=g.model,x=[];for(;k<r.length-1;){let A=await s.parse(E);if(A?.type!=="message"||A.stop_reason!=="refusal")break;k+=1,_(k);let O=r[k];x.push({type:"fallback",from:{model:T??A.model},to:{model:O.model},trigger:{type:"refusal",category:A.stop_details?.category??null}}),T=O.model,{response:E}=await Du(n,s,O,{...t,body:JSON.stringify({...$h(p,O),...A.stop_details?.fallback_credit_token?{fallback_credit_token:jh(A.stop_details.fallback_credit_token)}:void 0})})}if(x.length===0)return E;let C=await s.parse(E);if(C?.type!=="message"||C.stop_reason==="refusal"||!Array.isArray(C.content))return E;let P=new Headers(E.headers);return P.delete("content-length"),new Response(JSON.stringify({...C,content:[...x,...C.content]}),{status:E.status,statusText:E.statusText,headers:P})}}function Bb(r){let i=new AbortController,e=r.request.signal;e?.aborted?i.abort(e.reason):e?.addEventListener("abort",Wb(i,e),{once:!0});let t=Lb(r,i),n=new ReadableStream({async pull(s){try{let{value:a,done:l}=await t.next();if(l)return s.close();s.enqueue(a)}catch(a){s.error(a)}},async cancel(){i.abort(),await t.return?.(void 0)}});return new Response(n,r.response)}async function*Lb({request:r,response:i,next:e,ctx:t,fallbacks:n,firstHop:s,onError:a,pin:l},p){let h=yield*Fh({response:i,controller:p,indexBase:0,hasNext:!0,onError:a,splice:null});if(!h.refused)return;let m=h.nextIndex,_=h.refused.token,g=[],y=h.refused.hasPrefillClaim?Uh(h.blocks):[],v=h.model??"",k=h.refused.usage,E=h.refused.stopDetails,T=h.refused.inputTransformations,x=[Vu("message",h.model??"",h.refused.usage)];for(let C=s;C<n.length;C++){let P=n[C],{model:A}=P,{speed:O}=P,B=C+1<n.length;l(C);let L=m++;yield ot("content_block_start",{type:"content_block_start",index:L,content_block:{type:"fallback",from:{model:v},to:{model:A},trigger:{type:"refusal",category:E?.category??null}}}),yield ot("content_block_stop",{type:"content_block_stop",index:L});let $=[...g,...y],H=null,ae=null;for(let Ye=0;Ye<2;Ye++){let ya=$b(r,{model:A,speed:O,creditToken:_,continuation:$});ya.signal=p.signal;try{let Et=await Du(e,t,P,ya);H=Et.response,Et.droppedSpeed&&(O=null)}catch(Et){if(de(Et))throw Et;ae={kind:"request_failed",message:`fallback request failed: ${Et}`,model:A,status:null,detail:Et};break}if(H.ok)break;let Kt=await t.parse(H).catch(()=>null);if(Ye===0&&H.status===400&&y.length){t.logger.warn(`anthropic-sdk: betaRefusalFallbackMiddleware: fallback request with the partial output appended was rejected (HTTP 400: ${JSON.stringify(Kt)}); retrying without it`),$=g,H=null;continue}ae={kind:"request_failed",message:`fallback request failed: HTTP ${H.status}: ${JSON.stringify(Kt)}`,model:A,status:H.status,detail:Kt};break}if(ae){if(a(ae),B)continue;let Ye={...E,recommended_model:A};yield ot("message_delta",{type:"message_delta",context_management:null,delta:{stop_reason:"refusal",stop_sequence:null,container:null,stop_details:Ye},usage:k??{},...T!==void 0&&{input_transformations:T}}),yield ot("message_stop",{type:"message_stop"});return}let oe=yield*Fh({response:H,controller:p,indexBase:m,hasNext:B,onError:a,splice:{iterations:x,model:A}});if(!oe.refused)return;_=oe.refused.token,E=oe.refused.stopDetails,T=oe.refused.inputTransformations,g=$,y=oe.refused.hasPrefillClaim?Uh(oe.blocks):[],x.push(Vu("message",A,oe.refused.usage)),k=oe.refused.usage,v=A,m=oe.nextIndex}}async function*Fh(r){let{response:i,controller:e,indexBase:t,hasNext:n,onError:s,splice:a}=r,l=new Ku(t),p,h=null,m;for await(let _ of re.rawEvents(i,e)){let g=Pt(_.data);switch(g?.type){case"message_start":{if(p=g.message.model,h=g.message.usage,"input_transformations"in g.message&&(m=g.message.input_transformations),a)continue;break}case"content_block_start":{if(l.start(g),a){yield ot(g.type,g);continue}break}case"content_block_delta":{if(l.delta(g),a){yield ot(g.type,g);continue}break}case"content_block_stop":{if(l.stop(g),a){yield ot(g.type,g);continue}break}case"message_delta":{if(g.delta.stop_reason==="refusal"){let y=g.delta.stop_details?.type==="refusal"?g.delta.stop_details:null;if(y?.fallback_credit_token&&n){let v=Hh(g.usage,h);return yield*l.closeOpenBlocks(),{refused:{token:y.fallback_credit_token,hasPrefillClaim:y.fallback_has_prefill_claim===!0,usage:v,stopDetails:y,inputTransformations:a?m:void 0},model:p,blocks:l.contentBlocks(),nextIndex:l.nextIndex}}y?.fallback_credit_token?s({kind:"chain_exhausted",message:"refusal but no fallback entries remain",event:g}):s({kind:"no_credit_token",message:"refusal stop_details has no fallback_credit_token",event:g})}if(a){let y=Hh(g.usage,h);y.iterations=[...a.iterations,Vu("fallback_message",a.model,y)],g.usage=y,!("input_transformations"in g)&&m!==void 0&&(g.input_transformations=m),yield ot("message_delta",g);continue}break}}yield Hb(_)}return{refused:null,model:p,blocks:l.contentBlocks(),nextIndex:l.nextIndex}}var Ku=class{constructor(i=0){this.indexBase=i,this.blocks=[],this.open=[],this.nextIndex=i}contentBlocks(){return this.blocks.map(i=>i.block)}start(i){this.blocks.push({index:i.index,block:{...i.content_block}}),i.index+=this.indexBase,this.open.push(i.index),this.nextIndex=Math.max(this.nextIndex,i.index+1)}delta(i){Fb(this.blocks,i.index,i.delta),i.index+=this.indexBase}stop(i){i.index+=this.indexBase;let e=this.open.indexOf(i.index);e!==-1&&this.open.splice(e,1),this.nextIndex=Math.max(this.nextIndex,i.index+1)}*closeOpenBlocks(){for(let i of this.open)yield ot("content_block_stop",{type:"content_block_stop",index:i});this.open.length=0}};function jh(r){return{token:r,mode:"best_effort"}}function $b(r,{model:i,speed:e,creditToken:t,continuation:n}){let s=JSON.parse(r.body);return s.model=i,ml(s,"speed",e),s.fallback_credit_token=jh(t),s.thinking?.type==="between_tools"&&(s.thinking={type:"disabled"}),n.length&&(s.messages=[...s.messages,{role:"assistant",content:n}]),{...r,headers:new Headers(r.headers),body:JSON.stringify(s)}}async function Du(r,i,e,t){let n=await r(t);if(n.status!==429&&n.status!==529||e.speed!==void 0||typeof t.body!="string")return{response:n,droppedSpeed:!1};let{speed:s,...a}=JSON.parse(t.body);return s!=="fast"?{response:n,droppedSpeed:!1}:(i.logger.info(`anthropic-sdk: betaRefusalFallbackMiddleware: fast fallback request to ${e.model} was rejected (HTTP ${n.status}); retrying without \`speed\``),await za(n.body),{response:await r({...t,body:JSON.stringify(a)}),droppedSpeed:!0})}function Fb(r,i,e){let t=r.find(n=>n.index===i)?.block;if(t)switch(e.type){case"text_delta":{t.text=(t.text??"")+e.text;break}case"input_json_delta":{t._partial_json=(t._partial_json??"")+e.partial_json;break}case"citations_delta":(t.citations??(t.citations=[])).push(e.citation);break;case"thinking_delta":{t.thinking=(t.thinking??"")+e.thinking;break}case"signature_delta":{t.signature=e.signature;break}case"compaction_delta":{t.content=e.content,"encrypted_content"in e&&(t.encrypted_content=e.encrypted_content);break}default:}}function Uh(r){return r.map(i=>{if(typeof i?._partial_json!="string")return i;let{_partial_json:e,...t}=i;return{...t,input:Pt(e)??t.input}})}function Ub(r,i){let e=new Headers(r.headers),t=new Set(e.get("anthropic-beta")?.split(",").map(n=>n.trim()));for(let n of i)t.has(n)||(t.add(n),e.set("anthropic-beta",[...t].join(",")));return e.set(He,Cn(e.get(He),"fallback-refusal-middleware")),{...r,headers:e}}function ot(r,i){let e={event:r,data:JSON.stringify(i),raw:[]};return Wh.encode(Kh(e))}function Hb(r){return Wh.encode(r.raw.length?r.raw.join(`
23
- `)+`
24
-
25
- `:Kh(r))}function Vu(r,i,e){return{type:r,model:i,input_tokens:e?.input_tokens??0,output_tokens:e?.output_tokens??0,cache_read_input_tokens:e?.cache_read_input_tokens??0,cache_creation_input_tokens:e?.cache_creation_input_tokens??0,cache_creation:e?.cache_creation??null}}function Hh(r,i){let e={...i??{},...r??{}};for(let t of Object.keys(e))e[t]==null&&i?.[t]!=null&&(e[t]=i[t]);return e}function Kh(r){let i="";r.event!==null&&(i+=`event: ${r.event}
26
- `);for(let e of r.data.split(`
27
- `))i+=`data: ${e}
28
- `;return i+`
29
- `}function Wb(r,i){return()=>r.abort(i.reason)}export{b as a,o as b,S as c,F as d,ee as e,Le as f,Dt as g,gl as h,R as i,ka as j,G as k,Re as l,Ea as m,le as n,Vt as o,Gt as p,Sa as q,At as r,Aa as s,xa as t,lt as u,Pa as v,Qe as w,Ta as x,Jt as y,Oa as z,xn as A,Pn as B,I as C,et as D,no as E,ht as F,vr as G,jk as H,Pp as I,Tp as J,lu as K,_l as L,Bh as M,Lh as N,qb as O};