- /accounts/vault/<name>/: kleine verschlüsselte Geräte-Einstellungen (UserVault) - static/js/ai.js: DioraAI (SDK 0.133.0 gebündelt in static/vendor), Vorschläge zum Abhaken - static/js/app/55-library-tools.js: ✦ Ordnen (Ordner, Serien, Titel/Autor, Zeitschrift) und ⇩ XML-Export - docs/ai.md, docs/library.md Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
20 lines
213 KiB
JavaScript
20 lines
213 KiB
JavaScript
/* @anthropic-ai/sdk 0.133.0 (MIT), bundled for the browser with esbuild 0.28.2: see docs/ai.md. */
|
|
var al=Object.create;var $i=Object.defineProperty;var cl=Object.getOwnPropertyDescriptor;var ll=Object.getOwnPropertyNames;var ul=Object.getPrototypeOf,dl=Object.prototype.hasOwnProperty;var Hr=(r,n,e)=>()=>{if(e)throw e[0];try{return r&&(n=r(r=0)),n}catch(t){throw e=[t],t}};var Bs=(r,n)=>()=>{try{return n||r((n={exports:{}}).exports,n),n.exports}catch(e){throw n=0,e}},Qo=(r,n)=>{for(var e in n)$i(r,e,{get:n[e],enumerable:!0})},hl=(r,n,e,t)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of ll(n))!dl.call(r,s)&&s!==e&&$i(r,s,{get:()=>n[s],enumerable:!(t=cl(n,s))||t.enumerable});return r};var fl=(r,n,e)=>(e=r!=null?al(ul(r)):{},hl(n||!r||!r.__esModule?$i(e,"default",{value:r,enumerable:!0}):e,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 qe,Ue=Hr(()=>{qe=r=>{if(r instanceof Error)return r;if(typeof r=="object"&&r!==null){try{let n=Object.prototype.toString.call(r);if(n==="[object Error]"||n==="[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 k,D,V,Ae,Wr,Hs,Dr,zr,qr,Ur,jr,Kr,Vr,Jr,B=Hr(()=>{Ue();k=(()=>{class r extends Error{}return r})(),D=class r extends k{constructor(n,e,t,s,i){super(`${r.makeMessage(n,e,t)}`),this.status=n,this.headers=s,this.requestID=s?.get("request-id"),this.workspaceID=s?.get("anthropic-workspace-id"),this.error=e,this.type=i??null}static makeMessage(n,e,t){let s=e?.message?typeof e.message=="string"?e.message:JSON.stringify(e.message):e?JSON.stringify(e):t;return n&&s?`${n} ${s}`:n?`${n} status code (no body)`:s||"(no status code or body)"}static generate(n,e,t,s){if(!n||!s)return new Ae({message:t,cause:qe(e)});let i=e,o=i?.error?.type;return n===400?new Dr(n,i,t,s,o):n===401?new zr(n,i,t,s,o):n===403?new qr(n,i,t,s,o):n===404?new Ur(n,i,t,s,o):n===409?new jr(n,i,t,s,o):n===422?new Kr(n,i,t,s,o):n===429?new Vr(n,i,t,s,o):n>=500?new Jr(n,i,t,s,o):new r(n,i,t,s,o)}},V=class extends D{constructor({message:n}={}){super(void 0,void 0,n||"Request was aborted.",void 0)}},Ae=class extends D{constructor({message:n,cause:e}){super(void 0,void 0,n||"Connection error.",void 0),e&&(this.cause=e)}},Wr=class extends Ae{constructor({message:n}={}){super({message:n??"Request timed out."})}},Hs=class extends k{constructor(n,{cause:e}={}){super(n??"Retryable error."),e!==void 0&&(this.cause=e)}},Dr=class extends D{},zr=class extends D{},qr=class extends D{},Ur=class extends D{},jr=class extends D{},Kr=class extends D{},Vr=class extends D{},Jr=class extends D{}});var ge={};Qo(ge,{child_process:()=>Al,crypto:()=>Pl,fs:()=>Rl,os:()=>Il,path:()=>El,stream:()=>Tl,util:()=>Ml});function je(r){return new Proxy({},{get(n,e){if(typeof e!="symbol")throw new k(`\`${r}.${e}\` is not available in this environment; it needs a Node.js-compatible runtime`)}})}var Al,Pl,Rl,Il,El,Tl,Ml,we=Hr(()=>{B();Al=je("child_process"),Pl=je("crypto"),Rl=je("fs"),Il=je("os"),El=je("path"),Tl=je("stream"),Ml=je("util")});var ic=Bs(se=>{"use strict";var mu=se&&se.__extends||(function(){var r=function(n,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,s){t.__proto__=s}||function(t,s){for(var i in s)s.hasOwnProperty(i)&&(t[i]=s[i])},r(n,e)};return function(n,e){r(n,e);function t(){this.constructor=n}n.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}})();Object.defineProperty(se,"__esModule",{value:!0});var U=256,_o=(function(){function r(n){n===void 0&&(n="="),this._paddingCharacter=n}return r.prototype.encodedLength=function(n){return this._paddingCharacter?(n+2)/3*4|0:(n*8+5)/6|0},r.prototype.encode=function(n){for(var e="",t=0;t<n.length-2;t+=3){var s=n[t]<<16|n[t+1]<<8|n[t+2];e+=this._encodeByte(s>>>18&63),e+=this._encodeByte(s>>>12&63),e+=this._encodeByte(s>>>6&63),e+=this._encodeByte(s>>>0&63)}var i=n.length-t;if(i>0){var s=n[t]<<16|(i===2?n[t+1]<<8:0);e+=this._encodeByte(s>>>18&63),e+=this._encodeByte(s>>>12&63),i===2?e+=this._encodeByte(s>>>6&63):e+=this._paddingCharacter||"",e+=this._paddingCharacter||""}return e},r.prototype.maxDecodedLength=function(n){return this._paddingCharacter?n/4*3|0:(n*6+7)/8|0},r.prototype.decodedLength=function(n){return this.maxDecodedLength(n.length-this._getPaddingLength(n))},r.prototype.decode=function(n){if(n.length===0)return new Uint8Array(0);for(var e=this._getPaddingLength(n),t=n.length-e,s=new Uint8Array(this.maxDecodedLength(t)),i=0,o=0,c=0,f=0,d=0,b=0,p=0;o<t-4;o+=4)f=this._decodeChar(n.charCodeAt(o+0)),d=this._decodeChar(n.charCodeAt(o+1)),b=this._decodeChar(n.charCodeAt(o+2)),p=this._decodeChar(n.charCodeAt(o+3)),s[i++]=f<<2|d>>>4,s[i++]=d<<4|b>>>2,s[i++]=b<<6|p,c|=f&U,c|=d&U,c|=b&U,c|=p&U;if(o<t-1&&(f=this._decodeChar(n.charCodeAt(o)),d=this._decodeChar(n.charCodeAt(o+1)),s[i++]=f<<2|d>>>4,c|=f&U,c|=d&U),o<t-2&&(b=this._decodeChar(n.charCodeAt(o+2)),s[i++]=d<<4|b>>>2,c|=b&U),o<t-3&&(p=this._decodeChar(n.charCodeAt(o+3)),s[i++]=b<<6|p,c|=p&U),c!==0)throw new Error("Base64Coder: incorrect characters for decoding");return s},r.prototype._encodeByte=function(n){var e=n;return e+=65,e+=25-n>>>8&6,e+=51-n>>>8&-75,e+=61-n>>>8&-15,e+=62-n>>>8&3,String.fromCharCode(e)},r.prototype._decodeChar=function(n){var e=U;return e+=(42-n&n-44)>>>8&-U+n-43+62,e+=(46-n&n-48)>>>8&-U+n-47+63,e+=(47-n&n-58)>>>8&-U+n-48+52,e+=(64-n&n-91)>>>8&-U+n-65+0,e+=(96-n&n-123)>>>8&-U+n-97+26,e},r.prototype._getPaddingLength=function(n){var e=0;if(this._paddingCharacter){for(var t=n.length-1;t>=0&&n[t]===this._paddingCharacter;t--)e++;if(n.length<4||e>2)throw new Error("Base64Coder: incorrect padding")}return e},r})();se.Coder=_o;var hs=new _o;function _u(r){return hs.encode(r)}se.encode=_u;function gu(r){return hs.decode(r)}se.decode=gu;var sc=(function(r){mu(n,r);function n(){return r!==null&&r.apply(this,arguments)||this}return n.prototype._encodeByte=function(e){var t=e;return t+=65,t+=25-e>>>8&6,t+=51-e>>>8&-75,t+=61-e>>>8&-13,t+=62-e>>>8&49,String.fromCharCode(t)},n.prototype._decodeChar=function(e){var t=U;return t+=(44-e&e-46)>>>8&-U+e-45+62,t+=(94-e&e-96)>>>8&-U+e-95+63,t+=(47-e&e-58)>>>8&-U+e-48+52,t+=(64-e&e-91)>>>8&-U+e-65+0,t+=(96-e&e-123)>>>8&-U+e-97+26,t},n})(_o);se.URLSafeCoder=sc;var nc=new sc;function wu(r){return nc.encode(r)}se.encodeURLSafe=wu;function bu(r){return nc.decode(r)}se.decodeURLSafe=bu;se.encodedLength=function(r){return hs.encodedLength(r)};se.maxDecodedLength=function(r){return hs.maxDecodedLength(r)};se.decodedLength=function(r){return hs.decodedLength(r)}});var ac=Bs((oc,vn)=>{(function(r,n){var e={};n(e);var t=e.default;for(var s in e)t[s]=e[s];typeof vn=="object"&&typeof vn.exports=="object"?vn.exports=t:typeof define=="function"&&define.amd?define(function(){return t}):r.sha256=t})(oc,function(r){"use strict";r.__esModule=!0,r.digestLength=32,r.blockSize=64;var n=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(p,g,y,_,v){for(var A,R,S,E,x,P,L,M,F,H,q,ae,ze;v>=64;){for(A=g[0],R=g[1],S=g[2],E=g[3],x=g[4],P=g[5],L=g[6],M=g[7],H=0;H<16;H++)q=_+H*4,p[H]=(y[q]&255)<<24|(y[q+1]&255)<<16|(y[q+2]&255)<<8|y[q+3]&255;for(H=16;H<64;H++)F=p[H-2],ae=(F>>>17|F<<15)^(F>>>19|F<<13)^F>>>10,F=p[H-15],ze=(F>>>7|F<<25)^(F>>>18|F<<14)^F>>>3,p[H]=(ae+p[H-7]|0)+(ze+p[H-16]|0);for(H=0;H<64;H++)ae=(((x>>>6|x<<26)^(x>>>11|x<<21)^(x>>>25|x<<7))+(x&P^~x&L)|0)+(M+(n[H]+p[H]|0)|0)|0,ze=((A>>>2|A<<30)^(A>>>13|A<<19)^(A>>>22|A<<10))+(A&R^A&S^R&S)|0,M=L,L=P,P=x,x=E+ae|0,E=S,S=R,R=A,A=ae+ze|0;g[0]+=A,g[1]+=R,g[2]+=S,g[3]+=E,g[4]+=x,g[5]+=P,g[6]+=L,g[7]+=M,_+=64,v-=64}return _}var t=(function(){function p(){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 p.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},p.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()},p.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 _=0;if(this.bytesHashed+=y,this.bufferLength>0){for(;this.bufferLength<64&&y>0;)this.buffer[this.bufferLength++]=g[_++],y--;this.bufferLength===64&&(e(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(y>=64&&(_=e(this.temp,this.state,g,_,y),y%=64);y>0;)this.buffer[this.bufferLength++]=g[_++],y--;return this},p.prototype.finish=function(g){if(!this.finished){var y=this.bytesHashed,_=this.bufferLength,v=y/536870912|0,A=y<<3,R=y%64<56?64:128;this.buffer[_]=128;for(var S=_+1;S<R-8;S++)this.buffer[S]=0;this.buffer[R-8]=v>>>24&255,this.buffer[R-7]=v>>>16&255,this.buffer[R-6]=v>>>8&255,this.buffer[R-5]=v>>>0&255,this.buffer[R-4]=A>>>24&255,this.buffer[R-3]=A>>>16&255,this.buffer[R-2]=A>>>8&255,this.buffer[R-1]=A>>>0&255,e(this.temp,this.state,this.buffer,0,R),this.finished=!0}for(var S=0;S<8;S++)g[S*4+0]=this.state[S]>>>24&255,g[S*4+1]=this.state[S]>>>16&255,g[S*4+2]=this.state[S]>>>8&255,g[S*4+3]=this.state[S]>>>0&255;return this},p.prototype.digest=function(){var g=new Uint8Array(this.digestLength);return this.finish(g),g},p.prototype._saveState=function(g){for(var y=0;y<this.state.length;y++)g[y]=this.state[y]},p.prototype._restoreState=function(g,y){for(var _=0;_<this.state.length;_++)this.state[_]=g[_];this.bytesHashed=y,this.finished=!1,this.bufferLength=0},p})();r.Hash=t;var s=(function(){function p(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 _=0;_<g.length;_++)y[_]=g[_];for(var _=0;_<y.length;_++)y[_]^=54;this.inner.update(y);for(var _=0;_<y.length;_++)y[_]^=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 _=0;_<y.length;_++)y[_]=0}return p.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},p.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()},p.prototype.update=function(g){return this.inner.update(g),this},p.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},p.prototype.digest=function(){var g=new Uint8Array(this.digestLength);return this.finish(g),g},p})();r.HMAC=s;function i(p){var g=new t().update(p),y=g.digest();return g.clean(),y}r.hash=i,r.default=i;function o(p,g){var y=new s(p).update(g),_=y.digest();return y.clean(),_}r.hmac=o;function c(p,g,y,_){var v=_[0];if(v===0)throw new Error("hkdf: cannot expand more");g.reset(),v>1&&g.update(p),y&&g.update(y),g.update(_),g.finish(p),_[0]++}var f=new Uint8Array(r.digestLength);function d(p,g,y,_){g===void 0&&(g=f),_===void 0&&(_=32);for(var v=new Uint8Array([1]),A=o(g,p),R=new s(A),S=new Uint8Array(R.digestLength),E=S.length,x=new Uint8Array(_),P=0;P<_;P++)E===S.length&&(c(S,R,y,v),E=0),x[P]=S[E++];return R.clean(),S.fill(0),v.fill(0),x}r.hkdf=d;function b(p,g,y,_){for(var v=new s(p),A=v.digestLength,R=new Uint8Array(4),S=new Uint8Array(A),E=new Uint8Array(A),x=new Uint8Array(_),P=0;P*A<_;P++){var L=P+1;R[0]=L>>>24&255,R[1]=L>>>16&255,R[2]=L>>>8&255,R[3]=L>>>0&255,v.reset(),v.update(g),v.update(R),v.finish(E);for(var M=0;M<A;M++)S[M]=E[M];for(var M=2;M<=y;M++){v.reset(),v.update(E).finish(E);for(var F=0;F<A;F++)S[F]^=E[F]}for(var M=0;M<A&&P*A+M<_;M++)x[P*A+M]=S[M]}for(var P=0;P<A;P++)S[P]=E[P]=0;for(var P=0;P<4;P++)R[P]=0;return v.clean(),x}r.pbkdf2=b})});var lc=Bs(go=>{"use strict";Object.defineProperty(go,"__esModule",{value:!0});go.timingSafeEqual=yu;function cc(r,n=""){if(!r)throw new Error(n)}function yu(r,n){if(r.byteLength!==n.byteLength)return!1;r instanceof DataView||(r=new DataView(ArrayBuffer.isView(r)?r.buffer:r)),n instanceof DataView||(n=new DataView(ArrayBuffer.isView(n)?n.buffer:n)),cc(r instanceof DataView),cc(n instanceof DataView);let e=r.byteLength,t=0,s=-1;for(;++s<e;)t|=r.getUint8(s)^n.getUint8(s);return t===0}});var hc=Bs(wt=>{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.Webhook=wt.WebhookVerificationError=void 0;var uc=ic(),ku=ac(),Su=lc(),dc=300,wo=class r extends Error{constructor(n){super(n),Object.setPrototypeOf(this,r.prototype),this.name="ExtendableError",this.stack=new Error(n).stack}},Oe=class r extends wo{constructor(n){super(n),Object.setPrototypeOf(this,r.prototype),this.name="WebhookVerificationError"}};wt.WebhookVerificationError=Oe;var xn=class r{constructor(n,e){if(e?.format==="raw")n instanceof Uint8Array?this.key=n:this.key=Uint8Array.from(n,t=>t.charCodeAt(0));else{if(typeof n!="string")throw new Error("Expected secret to be of type string");n.startsWith(r.prefix)&&(n=n.substring(r.prefix.length)),this.key=uc.decode(n)}if(this.key.length===0)throw new Error("Secret can't be empty.")}verify(n,e,t){var s;let i=(s=t?.jsonParse)!==null&&s!==void 0?s:!0,o={};for(let v of Object.keys(e))o[v.toLowerCase()]=e[v];let c=o["webhook-id"],f=o["webhook-signature"],d=o["webhook-timestamp"];if(!f||!c||!d)throw new Oe("Missing required headers");let b=this.verifyTimestamp(d),g=this.sign(c,b,n).split(",")[1],y=f.split(" "),_=new globalThis.TextEncoder;for(let v of y){let[A,R]=v.split(",");if(A==="v1"&&(0,Su.timingSafeEqual)(_.encode(R),_.encode(g))){let S=n.toString();return S===""?void 0:i?JSON.parse(S):void 0}}throw new Oe("No matching signature found")}sign(n,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 s=new TextEncoder,i=Math.floor(e.getTime()/1e3),o=s.encode(`${n}.${i}.${t}`);return`v1,${uc.encode(ku.hmac(this.key,o))}`}verifyTimestamp(n){let e=Math.floor(Date.now()/1e3),t=parseInt(n,10);if(Number.isNaN(t))throw new Oe("Invalid Signature Headers");if(e-t>dc)throw new Oe("Message timestamp too old");if(t>e+dc)throw new Oe("Message timestamp too new");return new Date(t*1e3)}};wt.Webhook=xn;xn.prefix="whsec_"});function Mc(r,n){if(!(r>=qn))throw new k(`${n} must be at least ${qn}ms (got ${r}); to run without memory sync, pass \`memorySyncIntervalMs: null\` to the worker instead`)}var Tc,qn,vo=Hr(()=>{B();Tc=15e3,qn=5e3});var Oc={};Qo(Oc,{BashSession:()=>Ro,BashTimeoutError:()=>Po,DEFAULT_MEMORY_SYNC_INTERVAL_MS:()=>Tc,MARKER_PATH:()=>Xu,MEMORY_FLUSH_TIMEOUT_MS:()=>Yu,MIN_MEMORY_SYNC_INTERVAL_MS:()=>qn,SessionMemoryError:()=>xo,SessionMemoryStores:()=>Ao,betaAgentToolset20260401:()=>ed,betaBashTool:()=>rd,betaEditTool:()=>id,betaGlobTool:()=>od,betaGrepTool:()=>ad,betaReadTool:()=>sd,betaWriteTool:()=>nd,extractSkillArchive:()=>Zu,resolvePath:()=>td,setupSkills:()=>Qu});function W(r){throw new k(`${r} requires Node.js or a Node-compatible runtime`)}function Qu(r){return W("setupSkills")}function Zu(r,n){return W("extractSkillArchive")}function ed(r){return W("betaAgentToolset20260401")}function td(r,n){return W("resolvePath")}function rd(r){return W("betaBashTool")}function sd(r){return W("betaReadTool")}function nd(r){return W("betaWriteTool")}function id(r){return W("betaEditTool")}function od(r){return W("betaGlobTool")}function ad(r){return W("betaGrepTool")}var Yu,Xu,xo,Ao,Po,Ro,Cc=Hr(()=>{B();vo();Yu=3e4,Xu=".anthropic-memory-store",xo=class extends k{constructor(n,e){super(n),this.name="SessionMemoryError",e!==void 0&&(this.cause=e)}},Ao=class{constructor(n,e){W("SessionMemoryStores")}get roots(){return W("SessionMemoryStores")}get readOnlyRoots(){return W("SessionMemoryStores")}download(n){return W("SessionMemoryStores")}finish(){return W("SessionMemoryStores")}syncAll(n){return W("SessionMemoryStores")}syncIfDue(){return W("SessionMemoryStores")}flushWrites(n){return W("SessionMemoryStores")}dispose(){return W("SessionMemoryStores")}};Po=class extends k{constructor(n){super(`bash command timed out after ${n}ms`),this.name="BashTimeoutError",this.timeoutMs=n}},Ro=class{constructor(n,e){W("BashSession")}get closed(){return W("BashSession")}exec(n,e={}){return W("BashSession")}close(){W("BashSession")}}});function m(r,n,e,t,s){if(t==="m")throw new TypeError("Private method is not writable");if(t==="a"&&!s)throw new TypeError("Private accessor was defined without a setter");if(typeof n=="function"?r!==n||!s:!n.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t==="a"?s.call(r,e):s?s.value=e:n.set(r,e),e}function a(r,n,e,t){if(e==="a"&&!t)throw new TypeError("Private accessor was defined without a getter");if(typeof n=="function"?r!==n||!t:!n.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:n.get(r)}B();var ml=/^[a-z][a-z0-9+.-]*:/i,Zo=r=>ml.test(r),Y=r=>(Y=Array.isArray,Y(r)),Ni=Y;function Gr(r){return typeof r!="object"?{}:r??{}}function Li(r){if(!r)return!0;for(let n in r)return!1;return!0}function ea(r,n){return Object.prototype.hasOwnProperty.call(r,n)}function Fi(r){return r!=null&&typeof r=="object"&&!Array.isArray(r)}var Ws=(r,n)=>{if(typeof n!="number"||!Number.isInteger(n))throw new k(`${r} must be an integer`);if(n<0)throw new k(`${r} must be a positive integer`);return n};var Ds=r=>{try{return JSON.parse(r)}catch{return}};var he=(r,n)=>new Promise(e=>{if(n?.aborted)return e();let t=()=>{clearTimeout(s),e()},s=setTimeout(()=>{n?.removeEventListener("abort",t),e()},r);n?.addEventListener("abort",t,{once:!0})});Ue();var ce="0.133.0";var na=()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u";function _l(){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 gl=()=>{let r=_l();if(r==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":ce,"X-Stainless-OS":ra(Deno.build.os),"X-Stainless-Arch":ta(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":ce,"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":ce,"X-Stainless-OS":ra(globalThis.process.platform??"unknown"),"X-Stainless-Arch":ta(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let n=wl();return n?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":ce,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${n.browser}`,"X-Stainless-Runtime-Version":n.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":ce,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function wl(){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:n,pattern:e}of r){let t=e.exec(navigator.userAgent);if(t){let s=t[1]||0,i=t[2]||0,o=t[3]||0;return{browser:n,version:`${s}.${i}.${o}`}}}return null}var ta=r=>r==="x32"?"x32":r==="x86_64"||r==="x64"?"x64":r==="arm"?"arm":r==="aarch64"||r==="arm64"?"arm64":r?`other:${r}`:"unknown",ra=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"),sa,Yr=()=>sa??(sa=gl());var zs=new WeakMap,ia=typeof globalThis.FinalizationRegistry=="function"?new globalThis.FinalizationRegistry(r=>me(r)):null;function bl(r,n){return()=>r.removeEventListener("abort",n)}function oa(r,n,e){zs.set(r,bl(n,e))}function aa(r,n){zs.has(n)&&ia?.register(r,n,n)}function me(r){let n=zs.get(r);n&&(zs.delete(r),ia?.unregister(r),n())}function ca(){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 Bi(...r){let n=globalThis.ReadableStream;if(typeof n>"u")throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new n(...r)}function qs(r){let n=Symbol.asyncIterator in r?r[Symbol.asyncIterator]():r[Symbol.iterator]();return Bi({start(){},async pull(e){let{done:t,value:s}=await n.next();t?e.close():e.enqueue(s)},async cancel(){await n.return?.()}})}function Xr(r){if(r[Symbol.asyncIterator])return r;let n=r.getReader();return{async next(){try{let e=await n.read();return e?.done&&n.releaseLock(),e}catch(e){throw n.releaseLock(),e}},async return(){let e=n.cancel();return n.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function la(r){if(r===null||typeof r!="object")return;if(r[Symbol.asyncIterator]){await r[Symbol.asyncIterator]().return?.();return}let n=r.getReader(),e=n.cancel();n.releaseLock(),await e}var ua=({headers:r,body:n})=>({bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(n)});var Hi="RFC3986",Wi=r=>String(r),Di={RFC1738:r=>String(r).replace(/%20/g,"+"),RFC3986:Wi},da="RFC1738";var Us=(r,n)=>(Us=Object.hasOwn??Function.prototype.call.bind(Object.prototype.hasOwnProperty),Us(r,n)),_e=(()=>{let r=[];for(let n=0;n<256;++n)r.push("%"+((n<16?"0":"")+n.toString(16)).toUpperCase());return r})();var zi=1024,ha=(r,n,e,t,s)=>{if(r.length===0)return r;let i=r;if(typeof r=="symbol"?i=Symbol.prototype.toString.call(r):typeof r!="string"&&(i=String(r)),e==="iso-8859-1")return escape(i).replace(/%u[0-9a-f]{4}/gi,function(c){return"%26%23"+parseInt(c.slice(2),16)+"%3B"});let o="";for(let c=0;c<i.length;c+=zi){let f=i.length>=zi?i.slice(c,c+zi):i,d=[];for(let b=0;b<f.length;++b){let p=f.charCodeAt(b);if(p===45||p===46||p===95||p===126||p>=48&&p<=57||p>=65&&p<=90||p>=97&&p<=122||s===da&&(p===40||p===41)){d[d.length]=f.charAt(b);continue}if(p<128){d[d.length]=_e[p];continue}if(p<2048){d[d.length]=_e[192|p>>6]+_e[128|p&63];continue}if(p<55296||p>=57344){d[d.length]=_e[224|p>>12]+_e[128|p>>6&63]+_e[128|p&63];continue}b+=1,p=65536+((p&1023)<<10|f.charCodeAt(b)&1023),d[d.length]=_e[240|p>>18]+_e[128|p>>12&63]+_e[128|p>>6&63]+_e[128|p&63]}o+=d.join("")}return o};function fa(r){return!r||typeof r!="object"?!1:!!(r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer(r))}function qi(r,n){if(Y(r)){let e=[];for(let t=0;t<r.length;t+=1)e.push(n(r[t]));return e}return n(r)}var ma={brackets(r){return String(r)+"[]"},comma:"comma",indices(r,n){return String(r)+"["+n+"]"},repeat(r){return String(r)}},_a=function(r,n){Array.prototype.push.apply(r,Y(n)?n:[n])},pa,K={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:ha,encodeValuesOnly:!1,format:Hi,formatter:Wi,indices:!1,serializeDate(r){return(pa??(pa=Function.prototype.call.bind(Date.prototype.toISOString)))(r)},skipNulls:!1,strictNullHandling:!1};function Sl(r){return typeof r=="string"||typeof r=="number"||typeof r=="boolean"||typeof r=="symbol"||typeof r=="bigint"}var Ui={};function ga(r,n,e,t,s,i,o,c,f,d,b,p,g,y,_,v,A,R){let S=r,E=R,x=0,P=!1;for(;(E=E.get(Ui))!==void 0&&!P;){let q=E.get(r);if(x+=1,typeof q<"u"){if(q===x)throw new RangeError("Cyclic object value");P=!0}typeof E.get(Ui)>"u"&&(x=0)}if(typeof d=="function"?S=d(n,S):S instanceof Date?S=g?.(S):e==="comma"&&Y(S)&&(S=qi(S,function(q){return q instanceof Date?g?.(q):q})),S===null){if(i)return f&&!v?f(n,K.encoder,A,"key",y):n;S=""}if(Sl(S)||fa(S)){if(f){let q=v?n:f(n,K.encoder,A,"key",y);return[_?.(q)+"="+_?.(f(S,K.encoder,A,"value",y))]}return[_?.(n)+"="+_?.(String(S))]}let L=[];if(typeof S>"u")return L;let M;if(e==="comma"&&Y(S))v&&f&&(S=qi(S,f)),M=[{value:S.length>0?S.join(",")||null:void 0}];else if(Y(d))M=d;else{let q=Object.keys(S);M=b?q.sort(b):q}let F=c?String(n).replace(/\./g,"%2E"):String(n),H=t&&Y(S)&&S.length===1?F+"[]":F;if(s&&Y(S)&&S.length===0)return H+"[]";for(let q=0;q<M.length;++q){let ae=M[q],ze=typeof ae=="object"&&typeof ae.value<"u"?ae.value:S[ae];if(o&&ze===null)continue;let Ci=p&&c?ae.replace(/\./g,"%2E"):ae,ol=Y(S)?typeof e=="function"?e(H,Ci):H:H+(p?"."+Ci:"["+Ci+"]");R.set(r,x);let Xo=new WeakMap;Xo.set(Ui,R),_a(L,ga(ze,ol,e,t,s,i,o,c,e==="comma"&&v&&Y(S)?null:f,d,b,p,g,y,_,v,A,Xo))}return L}function vl(r=K){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 n=r.charset||K.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=Hi;if(typeof r.format<"u"){if(!Us(Di,r.format))throw new TypeError("Unknown format option provided.");e=r.format}let t=Di[e],s=K.filter;(typeof r.filter=="function"||Y(r.filter))&&(s=r.filter);let i;if(r.arrayFormat&&r.arrayFormat in ma?i=r.arrayFormat:"indices"in r?i=r.indices?"indices":"repeat":i=K.arrayFormat,"commaRoundTrip"in r&&typeof r.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");let o=typeof r.allowDots>"u"?r.encodeDotInKeys?!0:K.allowDots:!!r.allowDots;return{addQueryPrefix:typeof r.addQueryPrefix=="boolean"?r.addQueryPrefix:K.addQueryPrefix,allowDots:o,allowEmptyArrays:typeof r.allowEmptyArrays=="boolean"?!!r.allowEmptyArrays:K.allowEmptyArrays,arrayFormat:i,charset:n,charsetSentinel:typeof r.charsetSentinel=="boolean"?r.charsetSentinel:K.charsetSentinel,commaRoundTrip:!!r.commaRoundTrip,delimiter:typeof r.delimiter>"u"?K.delimiter:r.delimiter,encode:typeof r.encode=="boolean"?r.encode:K.encode,encodeDotInKeys:typeof r.encodeDotInKeys=="boolean"?r.encodeDotInKeys:K.encodeDotInKeys,encoder:typeof r.encoder=="function"?r.encoder:K.encoder,encodeValuesOnly:typeof r.encodeValuesOnly=="boolean"?r.encodeValuesOnly:K.encodeValuesOnly,filter:s,format:e,formatter:t,serializeDate:typeof r.serializeDate=="function"?r.serializeDate:K.serializeDate,skipNulls:typeof r.skipNulls=="boolean"?r.skipNulls:K.skipNulls,sort:typeof r.sort=="function"?r.sort:null,strictNullHandling:typeof r.strictNullHandling=="boolean"?r.strictNullHandling:K.strictNullHandling}}function wa(r,n={}){let e=r,t=vl(n),s,i;typeof t.filter=="function"?(i=t.filter,e=i("",e)):Y(t.filter)&&(i=t.filter,s=i);let o=[];if(typeof e!="object"||e===null)return"";let c=ma[t.arrayFormat],f=c==="comma"&&t.commaRoundTrip;s||(s=Object.keys(e)),t.sort&&s.sort(t.sort);let d=new WeakMap;for(let g=0;g<s.length;++g){let y=s[g];t.skipNulls&&e[y]===null||_a(o,ga(e[y],y,c,f,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,d))}let b=o.join(t.delimiter),p=t.addQueryPrefix===!0?"?":"";return t.charsetSentinel&&(t.charset==="iso-8859-1"?p+="utf8=%26%2310003%3B&":p+="utf8=%E2%9C%93&"),b.length>0?p+b:""}function ba(r){return wa(r,{arrayFormat:"brackets"})}B();B();var ka="urn:ietf:params:oauth:grant-type:jwt-bearer",Sa="refresh_token",js="/v1/oauth/token",Ke="oauth-2025-04-20",va="oidc-federation-2026-04-01",xa=120,at=30,Aa=5,ya=1<<20;function Ks(r){if(!r)return;let n;try{n=new URL(r)}catch(t){throw new O(`Invalid token endpoint base URL "${r}": ${t}`)}if(n.protocol==="https:")return;let e=n.hostname.toLowerCase().replace(/^\[|\]$/g,"");if(!(n.protocol==="http:"&&(e==="localhost"||e==="127.0.0.1"||e==="::1")))throw new O(`Refusing to send credential over non-https token endpoint "${r}"`)}async function Vs(r,n){let e=await Cl(r),t;try{t=JSON.parse(e)}catch{throw new O(`Token endpoint returned non-JSON response (status ${r.status})`,r.status,Q(e),n)}if(!t.access_token)throw new O(`Token endpoint response missing access_token: ${JSON.stringify(Q(t))}`,r.status,Q(t),n);if(t.token_type&&t.token_type.toLowerCase()!=="bearer")throw new O(`Token endpoint response: unsupported token_type "${t.token_type}" (want Bearer)`,r.status,Q(t),n);return t}var ji=2e3,Ol=new Set(["error","error_description","error_uri"]);function Q(r){if(r==null)return r;if(typeof r=="string"){let n;try{n=JSON.parse(r)}catch{return r.length<=ji?r:r.slice(0,ji)+`... <${r.length-ji} more chars>`}return JSON.stringify(Q(n))}if(typeof r=="object"&&!Array.isArray(r)){let n={};for(let[e,t]of Object.entries(r))Ol.has(e)&&(n[e]=t);return n}return null}async function Js(r,n=e=>console.warn(`anthropic-sdk: ${e}`)){if(typeof process>"u"||process.platform==="win32")return;let{fs:e}=await Promise.resolve().then(()=>(we(),ge)),t=r,s;try{t=await e.promises.realpath(r),s=await e.promises.stat(t)}catch{return}let i=s.mode&511;if(i&18)throw new O(`Credentials file at ${t} is group/world-writable (mode 0o${i.toString(8)}); this allows other local users to plant tokens. Run \`chmod 600 ${t}\`.`);if(i&36)throw new O(`Credentials file at ${t} is group/world-readable (mode 0o${i.toString(8)}); run \`chmod 600 ${t}\` before retrying.`);typeof process.getuid=="function"&&s.uid!==process.getuid()&&n(`credentials file at ${t} is owned by uid ${s.uid} (current process uid ${process.getuid()}); verify this is intentional.`)}async function Gs(r,n){let{fs:e,path:t}=await Promise.resolve().then(()=>(we(),ge)),s=t.dirname(r);await e.promises.mkdir(s,{recursive:!0,mode:448});let i=`${r}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;try{let o=await e.promises.open(i,"w",384);try{await o.writeFile(JSON.stringify(n,null,2)),await o.sync()}finally{await o.close()}await e.promises.rename(i,r)}catch(o){throw await e.promises.unlink(i).catch(()=>{}),o}try{let o=await e.promises.open(s,"r");try{await o.sync()}finally{await o.close()}}catch{}}async function Cl(r){if(!r.body)return"";let n=r.body.getReader(),e=[],t=0;for(;;){let{done:i,value:o}=await n.read();if(i)break;if(t+o.length>ya){let c=ya-t;c>0&&e.push(o.subarray(0,c)),await n.cancel();break}e.push(o),t+=o.length}let s;if(e.length===1)s=e[0];else{s=new Uint8Array(e.reduce((o,c)=>o+c.length,0));let i=0;for(let o of e)s.set(o,i),i+=o.length}return new TextDecoder("utf-8").decode(s)}var O=class extends k{constructor(n,e=null,t=null,s=null){super(n),this.statusCode=e,this.body=t,this.requestId=s}};function fe(){return Math.floor(Date.now()/1e3)}var Ys=class{constructor(n,e){this.cached=null,this.pendingRefresh=null,this.nextForce=!1,this.lastAdvisoryError=0,this.provider=n,this.onAdvisoryRefreshError=e}async getToken(){let n=this.nextForce;this.nextForce=!1;let e=this.cached;if(n||e==null)return(await this.refresh(n)).token;if(e.expiresAt==null)return e.token;let t=e.expiresAt-fe();return t>xa?e.token:t>at?(this.backgroundRefresh(),e.token):(await this.refresh()).token}invalidate(){this.cached=null,this.nextForce=!0}refresh(n=!1){return this.pendingRefresh&&!n?this.pendingRefresh:this.doRefresh(n)}backgroundRefresh(){this.pendingRefresh||fe()-this.lastAdvisoryError<Aa||this.doRefresh().catch(n=>{this.lastAdvisoryError=fe(),this.onAdvisoryRefreshError?.(n)})}doRefresh(n=!1){return this.pendingRefresh=this.provider(n?{forceRefresh:!0}:void 0).then(e=>(this.cached=e,this.pendingRefresh=null,e),e=>{throw this.pendingRefresh=null,e}),this.pendingRefresh}};var I=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};B();function Ia(r){let n=0;for(let s of r)n+=s.length;let e=new Uint8Array(n),t=0;for(let s of r)e.set(s,t),t+=s.length;return e}var Pa;function Xs(r){let n;return(Pa??(n=new globalThis.TextEncoder,Pa=n.encode.bind(n)))(r)}var Ra;function Qr(r){let n;return(Ra??(n=new globalThis.TextDecoder,Ra=n.decode.bind(n)))(r)}var Ea=r=>{if(typeof globalThis.Buffer<"u"){let n=globalThis.Buffer.from(r,"base64");return new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}if(typeof atob<"u"){let n=atob(r),e=new Uint8Array(n.length);for(let t=0;t<n.length;t++)e[t]=n.charCodeAt(t);return e}throw new k("Cannot decode base64 string; Expected `Buffer` or `atob` to be defined")};var Zr="warn",Zs={off:0,error:200,warn:300,info:400,debug:500},en=(r,n,e)=>{if(r){if(ea(Zs,r))return r;e.warn(`${n} was set to ${JSON.stringify(r)}, expected one of ${JSON.stringify(Object.keys(Zs))}`)}};function ct(){}function Qs(r,n,e){return!n||Zs[r]>Zs[e]?ct:n[r].bind(n)}var $l={error:ct,warn:ct,info:ct,debug:ct},Ta=new WeakMap;function Vi(r,n){let e=Ta.get(r);if(e&&e[0]===n)return e[1];let t={error:Qs("error",r,n),warn:Qs("warn",r,n),info:Qs("info",r,n),debug:Qs("debug",r,n)};return Ta.set(r,[n,t]),t}function T(r){let n=r.logger,e=r.logLevel??"off";return n?Vi(n,e):$l}var Ma,Ki;function Oa(){let r=I("ANTHROPIC_LOG");return(!Ki||r!==Ma)&&(Ma=r,Ki=Vi(console,en(r,"process.env['ANTHROPIC_LOG']",Vi(console,Zr))??Zr)),Ki}function be(r,n,e){r.debug!==ct&&r.debug(n,Nl(e))}var Nl=r=>(r.options&&(r.options={...r.options},delete r.options.headers),r.headers&&(r.headers=Object.fromEntries((r.headers instanceof Headers?[...r.headers]:Object.entries(r.headers)).map(([n,e])=>[n,n.toLowerCase()==="authorization"||n.toLowerCase()==="api-key"||n.toLowerCase()==="x-api-key"||n.toLowerCase()==="cookie"||n.toLowerCase()==="set-cookie"?"***":e]))),"retryOfRequestLogID"in r&&(r.retryOfRequestLogID&&(r.retryOf=r.retryOfRequestLogID),delete r.retryOfRequestLogID),r);var tn=function(){let{crypto:r}=globalThis;if(r?.randomUUID)return tn=r.randomUUID.bind(r),r.randomUUID();let n=new Uint8Array(1),e=r?()=>r.getRandomValues(n)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,t=>(+t^e()&15>>+t/4).toString(16))};var rn="1.0",Ll=/^[A-Za-z0-9_.-]+$/;function Ca(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(!Ll.test(r))throw new Error(`profile name "${r}" contains disallowed characters (allowed: letters, digits, '_', '.', '-')`)}var $a=async r=>{var n,e;let t=await Ji();if(t===null)return null;let s=r??await La();if(s===null)return null;Ca(s);let{fs:i,path:o}=await Promise.resolve().then(()=>(we(),ge)),c=o.join(t,"configs",`${s}.json`),f;try{f=await i.promises.readFile(c,"utf-8")}catch(p){if(p?.code!=="ENOENT")throw new Error(`failed to read config file ${c}: ${p}`);f=null}if(f===null){let p=I("ANTHROPIC_ORGANIZATION_ID"),g=I("ANTHROPIC_IDENTITY_TOKEN_FILE"),y=I("ANTHROPIC_FEDERATION_RULE_ID");return y&&p?{fromFile:!1,config:{organization_id:p,workspace_id:I("ANTHROPIC_WORKSPACE_ID"),base_url:I("ANTHROPIC_BASE_URL"),authentication:{type:"oidc_federation",federation_rule_id:y,service_account_id:I("ANTHROPIC_SERVICE_ACCOUNT_ID"),identity_token:g?{source:"file",path:g}:void 0,scope:I("ANTHROPIC_SCOPE")}}}:null}let d;try{d=JSON.parse(f)}catch(p){throw new Error(`failed to parse config file ${c}: ${p}`)}if(!d.authentication)throw new Error(`config file ${c} is missing "authentication"`);let b=d.authentication.type;if(b!=="oidc_federation"&&b!=="user_oauth")throw new Error(`authentication.type "${b}" is not a known authentication type`);if(d.organization_id??(d.organization_id=I("ANTHROPIC_ORGANIZATION_ID")),d.workspace_id??(d.workspace_id=I("ANTHROPIC_WORKSPACE_ID")),d.base_url??(d.base_url=I("ANTHROPIC_BASE_URL")),(n=d.authentication).scope??(n.scope=I("ANTHROPIC_SCOPE")),d.authentication.type==="oidc_federation"){if(!d.authentication.identity_token){let p=I("ANTHROPIC_IDENTITY_TOKEN_FILE");p&&(d.authentication.identity_token={source:"file",path:p})}d.authentication.federation_rule_id||(d.authentication.federation_rule_id=I("ANTHROPIC_FEDERATION_RULE_ID")??""),(e=d.authentication).service_account_id??(e.service_account_id=I("ANTHROPIC_SERVICE_ACCOUNT_ID"))}return{config:d,fromFile:!0}};var Na=async(r,n)=>{if(r?.authentication.credentials_path)return r.authentication.credentials_path;let e=await Ji();if(!e)return null;let t=n??await La();if(!t)return null;Ca(t);let{path:s}=await Promise.resolve().then(()=>(we(),ge));return s.join(e,"credentials",`${t}.json`)},Ji=async()=>{if(!Fl())return null;let{path:r}=await Promise.resolve().then(()=>(we(),ge)),n=I("ANTHROPIC_CONFIG_DIR");if(n)return n;if(Yr()["X-Stainless-OS"]==="Windows"){let i=I("APPDATA");if(i)return r.join(i,"Anthropic");let o=I("USERPROFILE");return o?r.join(o,"AppData","Roaming","Anthropic"):null}let t=I("XDG_CONFIG_HOME");if(t)return r.join(t,"anthropic");let s=I("HOME");return s?r.join(s,".config","anthropic"):null},Fl=()=>{let r=Yr()["X-Stainless-Runtime"];return r==="node"||r==="deno"},La=async()=>{let r=await Ji();if(!r)return null;let n=I("ANTHROPIC_PROFILE");if(n)return n;let{fs:e,path:t}=await Promise.resolve().then(()=>(we(),ge)),s=t.join(r,"active_config");try{return(await e.promises.readFile(s,"utf-8")).trim()||"default"}catch(i){if(i?.code!=="ENOENT")throw new Error(`failed to read ${s}: ${i}`);return"default"}};B();function Gi(r){if(!r)throw new k("Identity token file path is empty");return async()=>{let{fs:n}=await Promise.resolve().then(()=>(we(),ge)),e;try{e=await n.promises.readFile(r,"utf-8")}catch(s){throw new k(`Failed to read identity token file at ${r}: ${s}`)}let t=e.trim();if(!t)throw new k(`Identity token file at ${r} is empty`);return t}}function Fa(r){if(!r)throw new k("Identity token value is empty");return()=>r}function Ba(r){return async()=>{Ks(r.baseURL);let n=await r.identityTokenProvider();if(n.length>16*1024)throw new O(`Identity token is ${Math.ceil(n.length/1024)} KiB, exceeds the 16 KiB assertion limit`);let e={grant_type:ka,assertion:n,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}${js}`,s;try{s=await r.fetch(t,{method:"POST",headers:{"Content-Type":"application/json","anthropic-beta":`${Ke},${va}`,"User-Agent":r.userAgent||`anthropic-sdk-typescript/${ce} oidcFederationProvider`},body:JSON.stringify(e)})}catch(f){throw new O(`Failed to reach token endpoint ${t}: ${f}`)}let i=s.headers.get("Request-Id");if(!s.ok){let f=await s.text().catch(()=>""),d=Q(f),b="";throw s.status===401&&(b=` 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 O(`Token exchange failed with status ${s.status}${i?` (request-id ${i})`:""}: ${d}${b}`,s.status,d,i)}let o=await Vs(s,i),c=Number(o.expires_in);if(!Number.isFinite(c))throw new O(`Token endpoint response missing required fields: ${JSON.stringify(Q(o))}`,s.status,Q(o),i);return{token:o.access_token,expiresAt:fe()+c}}}function Ha(r){return async n=>{let{fs:e}=await Promise.resolve().then(()=>(we(),ge));await Js(r.credentialsPath,r.onSafetyWarning);let t;try{t=await e.promises.readFile(r.credentialsPath,"utf-8")}catch(A){throw new O(`Credentials file not found at ${r.credentialsPath}: ${A}`)}let s;try{s=JSON.parse(t)}catch(A){throw new O(`Credentials file at ${r.credentialsPath} is not valid JSON: ${A}`)}let i=s.access_token;if(!i)throw new O(`Credentials file at ${r.credentialsPath} must include 'access_token'`);let o=s.expires_at;if(!n?.forceRefresh&&(o==null||fe()<o-at))return{token:i,expiresAt:o??null};let c=s.refresh_token;if(!r.clientId||!c)throw new O(`Access token at ${r.credentialsPath} has expired and no refresh is available (client_id ${r.clientId?"set":"empty"}, refresh_token ${c?"set":"empty"})`);Ks(r.baseURL);let f={grant_type:Sa,refresh_token:c,client_id:r.clientId},d=`${r.baseURL}${js}`,b;try{b=await r.fetch(d,{method:"POST",headers:{"Content-Type":"application/json","anthropic-beta":Ke,"User-Agent":r.userAgent||`anthropic-sdk-typescript/${ce} userOAuthProvider`},body:JSON.stringify(f)})}catch(A){throw new O(`User OAuth refresh failed to reach token endpoint: ${A}`)}let p=b.headers.get("Request-Id");if(!b.ok){let A=await b.text().catch(()=>"");throw new O(`User OAuth refresh failed (HTTP ${b.status}): ${Q(A)}`,b.status,Q(A),p)}let g=await Vs(b,p),y=Number(g.expires_in);if(!Number.isFinite(y))throw new O(`User OAuth refresh response missing or invalid expires_in: ${JSON.stringify(Q(g))}`,b.status,Q(g),p);let _=fe()+y,v=g.refresh_token||c;return await Gs(r.credentialsPath,{...s,version:rn,type:"oauth_token",access_token:g.access_token,expires_at:_,refresh_token:v}),{token:g.access_token,expiresAt:_}}}function Yi(r,n){let e=r.authentication.credentials_path??null,t=(r.base_url||n.baseURL).replace(/\/+$/,""),s=Bl(r,e,t,n),i={};return r.workspace_id&&r.authentication.type==="user_oauth"&&(i["anthropic-workspace-id"]=r.workspace_id),{provider:s,extraHeaders:i,baseURL:r.base_url||void 0}}async function Wa(r,n){let e=await $a(n);if(!e)return null;let{config:t,fromFile:s}=e,i=t.authentication.credentials_path||!s?t:{...t,authentication:{...t.authentication,credentials_path:await Na(t,n)??void 0}};return Yi(i,r)}function Bl(r,n,e,t){switch(r.authentication.type){case"oidc_federation":{let s=r.authentication,i=Hl(s);if(!i)throw new O("oidc_federation config requires an identity token (set authentication.identity_token, ANTHROPIC_IDENTITY_TOKEN_FILE, or ANTHROPIC_IDENTITY_TOKEN)");if(!s.federation_rule_id)throw new O("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 O("oidc_federation config requires organization_id (set ANTHROPIC_ORGANIZATION_ID or config.organization_id)");let o=Ba({identityTokenProvider:i,federationRuleId:s.federation_rule_id,organizationId:r.organization_id,serviceAccountId:s.service_account_id,workspaceId:r.workspace_id,baseURL:e,fetch:t.fetch,userAgent:t.userAgent});return n?Wl(o,n,t.onCacheWriteError,t.onSafetyWarning):o}case"user_oauth":{if(!n)throw new O("user_oauth config requires authentication.credentials_path (or load via a profile so it defaults to <config_dir>/credentials/<profile>.json)");return Ha({credentialsPath:n,clientId:r.authentication.client_id,baseURL:e,fetch:t.fetch,userAgent:t.userAgent,onSafetyWarning:t.onSafetyWarning})}default:{let s=r.authentication.type;throw new O(`authentication.type "${s}" is not a known authentication type`)}}}function Hl(r){if(r.identity_token){let t=r.identity_token.source;if(t!=="file")throw new O(`identity_token.source "${t}" is not supported by this SDK version (only "file")`);if(!r.identity_token.path)throw new O('identity_token.source "file" requires a non-empty path');return Gi(r.identity_token.path)}let n=I("ANTHROPIC_IDENTITY_TOKEN_FILE");if(n)return Gi(n);let e=I("ANTHROPIC_IDENTITY_TOKEN");return e?Fa(e):null}function Wl(r,n,e,t){return async s=>{let{fs:i}=await Promise.resolve().then(()=>(we(),ge));await Js(n,t);let o;try{let f=await i.promises.readFile(n,"utf-8");o=JSON.parse(f);let d=o?.access_token;if(d&&!s?.forceRefresh){let b=o?.expires_at;if(b==null||fe()<b-at)return{token:d,expiresAt:b??null}}}catch(f){f?.code!=="ENOENT"&&!(f instanceof SyntaxError)&&e?.(f)}let c=await r(s);try{await Gs(n,{...o??{},version:rn,type:"oauth_token",access_token:c.token,expires_at:c.expiresAt})}catch(f){e?.(f)}return c}}Ue();B();var te,re,es=(()=>{class r{constructor(){te.set(this,void 0),re.set(this,void 0),m(this,te,new Uint8Array,"f"),m(this,re,null,"f")}decode(e){if(e==null)return[];let t=e instanceof ArrayBuffer?new Uint8Array(e):typeof e=="string"?Xs(e):e;m(this,te,Ia([a(this,te,"f"),t]),"f");let s=[],i;for(;(i=Dl(a(this,te,"f"),a(this,re,"f")))!=null;){if(i.carriage&&a(this,re,"f")==null){m(this,re,i.index,"f");continue}if(a(this,re,"f")!=null&&(i.index!==a(this,re,"f")+1||i.carriage)){s.push(Qr(a(this,te,"f").subarray(0,a(this,re,"f")-1))),m(this,te,a(this,te,"f").subarray(a(this,re,"f")),"f"),m(this,re,null,"f");continue}let o=a(this,re,"f")!==null?i.preceding-1:i.preceding,c=Qr(a(this,te,"f").subarray(0,o));s.push(c),m(this,te,a(this,te,"f").subarray(i.index),"f"),m(this,re,null,"f")}return s}flush(){return a(this,te,"f").length?this.decode(`
|
|
`):[]}}return te=new WeakMap,re=new WeakMap,r.NEWLINE_CHARS=new Set([`
|
|
`,"\r"]),r.NEWLINE_REGEXP=/\r\n|[\n\r]/g,r})();function Dl(r,n){for(let s=n??0;s<r.length;s++){if(r[s]===10)return{preceding:s,index:s+1,carriage:!1};if(r[s]===13)return{preceding:s,index:s+1,carriage:!0}}return null}Ue();B();var ts,ye=(()=>{class r{constructor(e,t,s){this.iterator=e,ts.set(this,void 0),this.controller=t,m(this,ts,s,"f")}static rawEvents(e,t=new AbortController){return Da(e,t)}static fromSSEResponse(e,t,s){let i=!1,o=s?T(s):console;async function*c(){if(i)throw new k("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let f=!1;try{for await(let d of Da(e,t)){if(d.event==="completion")try{yield JSON.parse(d.data)}catch(b){throw o.error("Could not parse message into JSON:",d.data),o.error("From chunk:",d.raw),b}if(d.event==="message_start"||d.event==="message_delta"||d.event==="message_stop"||d.event==="content_block_start"||d.event==="content_block_delta"||d.event==="content_block_stop"||d.event==="message"||d.event==="user.message"||d.event==="user.interrupt"||d.event==="user.tool_confirmation"||d.event==="user.custom_tool_result"||d.event==="user.tool_result"||d.event==="agent.message"||d.event==="agent.thinking"||d.event==="agent.tool_use"||d.event==="agent.tool_result"||d.event==="agent.mcp_tool_use"||d.event==="agent.mcp_tool_result"||d.event==="agent.custom_tool_use"||d.event==="agent.thread_context_compacted"||d.event==="session.status_running"||d.event==="session.status_idle"||d.event==="session.status_rescheduled"||d.event==="session.status_terminated"||d.event==="session.error"||d.event==="session.deleted"||d.event==="session.updated"||d.event==="span.model_request_start"||d.event==="span.model_request_end"||d.event==="span.outcome_evaluation_start"||d.event==="span.outcome_evaluation_ongoing"||d.event==="span.outcome_evaluation_end"||d.event==="user.define_outcome"||d.event==="agent.thread_message_received"||d.event==="agent.thread_message_sent"||d.event==="agent.session_thread_message_received"||d.event==="agent.session_thread_message_sent"||d.event==="session.thread_created"||d.event==="session.thread_status_created"||d.event==="session.thread_status_running"||d.event==="session.thread_status_idle"||d.event==="session.thread_status_rescheduled"||d.event==="session.thread_status_terminated"||d.event==="event_start"||d.event==="event_delta"||d.event==="system.message"||d.event==="workflow_run.created"||d.event==="workflow_run.status_running"||d.event==="workflow_run.status_idle"||d.event==="workflow_run.status_ended"||d.event==="workflow_run.error"||d.event==="workflow_run.phase_started"||d.event==="workflow_run.phase_ended")try{yield JSON.parse(d.data)}catch(b){throw o.error("Could not parse message into JSON:",d.data),o.error("From chunk:",d.raw),b}if(d.event!=="ping"&&d.event==="error"){let b=Ds(d.data)??d.data,p=b?.error?.type;throw new D(void 0,b,void 0,e.headers,p)}}f=!0}catch(d){if(de(d))return;throw d}finally{f||t.abort(),me(t)}}return new r(c,t,s)}static fromReadableStream(e,t,s){let i=!1;async function*o(){let f=new es,d=Xr(e);for await(let b of d)for(let p of f.decode(b))yield p;for(let b of f.flush())yield b}async function*c(){if(i)throw new k("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");i=!0;let f=!1;try{for await(let d of o())f||d&&(yield JSON.parse(d));f=!0}catch(d){if(de(d))return;throw d}finally{f||t.abort(),me(t)}}return new r(c,t,s)}[(ts=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let e=[],t=[],s=this.iterator(),i=o=>({next:()=>{if(o.length===0){let c=s.next();e.push(c),t.push(c)}return o.shift()}});return[new r(()=>i(e),this.controller,a(this,ts,"f")),new r(()=>i(t),this.controller,a(this,ts,"f"))]}toReadableStream(){let e=this,t;return Bi({async start(){t=e[Symbol.asyncIterator]()},async pull(s){try{let{value:i,done:o}=await t.next();if(o)return s.close();let c=Xs(JSON.stringify(i)+`
|
|
`);s.enqueue(c)}catch(i){s.error(i)}},async cancel(){await t.return?.()}})}}return r})();async function*Da(r,n){if(!r.body)throw n.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new k("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 k("Attempted to iterate over a response with no body");let e=new Xi,t=new es,s=Xr(r.body);for await(let i of s)for(let o of t.decode(i)){let c=e.decode(o);c&&(yield c)}for(let i of t.flush()){let o=e.decode(i);o&&(yield o)}}var Xi=class{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(n){if(n.endsWith("\r")&&(n=n.substring(0,n.length-1)),!n){if(!this.event&&!this.data.length)return null;let i={event:this.event,data:this.data.join(`
|
|
`),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],i}if(this.chunks.push(n),n.startsWith(":"))return null;let[e,t,s]=zl(n,":");return s.startsWith(" ")&&(s=s.substring(1)),e==="event"?this.event=s:e==="data"&&this.data.push(s),null}};function zl(r,n){let e=r.indexOf(n);return e!==-1?[r.substring(0,e),n,r.substring(e+n.length)]:[r,"",""]}async function sn(r,n){let{response:e,requestLogID:t,retryOfRequestLogID:s,startTime:i}=n,o=await(async()=>{if(n.options.stream)return T(r).debug("response",e.status,e.url,e.headers,e.body),ye.fromSSEResponse(e,n.controller,r);if(e.status===204)return null;if(n.options.__binaryResponse)return e;let f=e.headers.get("content-type")?.split(";")[0]?.trim();if(f?.includes("application/json")||f?.endsWith("+json")){if(e.headers.get("content-length")==="0")return;let g=await e.json();return rs(g,e)}return await e.text()})().finally(()=>{!n.options.stream&&!n.options.__binaryResponse&&me(n.controller)});return be(T(r),`[${t}] response parsed`,{retryOfRequestLogID:s,url:e.url,status:e.status,body:o,durationMs:Date.now()-i}),o}function rs(r,n){return!r||typeof r!="object"||Array.isArray(r)?r:Object.defineProperties(r,{_request_id:{value:n.headers.get("request-id"),enumerable:!1},_workspace_id:{value:n.headers.get("anthropic-workspace-id"),enumerable:!1}})}B();var qa=new WeakSet;function Qi(r){return typeof r=="object"&&r!==null&&qa.has(r)}function Ua(r){let n=new Set;for(;typeof r=="object"&&r!==null&&!n.has(r);){if(n.add(r),Qi(r)||de(r)||r instanceof Ae||r instanceof Hs)return!0;r=r.cause}return!1}function Zi(r,n,e,t){return async(s,i={})=>{if(n.length===0)return r.call(void 0,s,i);let o=i.headers instanceof Headers?i.headers:new Headers(i.headers),c=await Ul(r,n,e,t)({...i,headers:o,url:typeof s=="string"?s:s instanceof URL?s.href:s.url});if(c.bodyUsed||c.body?.locked)throw new k("middleware consumed the response body; use response.clone() to inspect it, or return new Response(body, response) to consume and replace it");return c}}function ql(r,n){let e=new WeakMap;return{options:r,logger:n?T(n):Oa(),parse(t){if(r?.stream&&t.ok)return za(t,r,n);let s=e.get(t);return s||(s=za(t,r,n),e.set(t,s)),s}}}async function za(r,n,e){if(r.bodyUsed||r.body?.locked)throw new k("cannot ctx.parse() a response whose body was already consumed; call ctx.parse() instead of reading the body, or read via response.clone()");if(n?.stream&&r.ok)return ye.fromSSEResponse(r.clone(),new AbortController,e);if(r.status===204)return null;if(n?.__binaryResponse)return r;let s=r.headers.get("content-type")?.split(";")[0]?.trim();return s?.includes("application/json")||s?.endsWith("+json")?r.headers.get("content-length")==="0"?void 0:rs(await r.clone().json(),r):await r.clone().text()}function Ul(r,n,e,t){let s=async({url:o,...c})=>{try{return await r.call(void 0,o,c)}catch(f){let d=qe(f);throw qa.add(d),d}},i=ql(e,t);for(let o=n.length-1;o>=0;o--){let c=n[o],f=s;s=async d=>c(d,f,i)}return s}B();var ss,nn=(()=>{class r extends Promise{constructor(e,t,s=sn){super(i=>{i(null)}),this.responsePromise=t,this.parseResponse=s,ss.set(this,void 0),m(this,ss,e,"f")}_thenUnwrap(e){return new r(a(this,ss,"f"),this.responsePromise,async(t,s)=>rs(e(await this.parseResponse(t,s),s),s.response))}asResponse(){return this.responsePromise.then(e=>e.response)}async withResponse(){let[e,t]=await Promise.all([this.parse(),this.asResponse()]);return{data:e,response:t,request_id:t.headers.get("request-id"),workspace_id:t.headers.get("anthropic-workspace-id")}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(e=>this.parseResponse(a(this,ss,"f"),e))),this.parsedPromise}then(e,t){return this.parse().then(e,t)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}}return ss=new WeakMap,r})();var on,eo=(()=>{class r{constructor(e,t,s,i){on.set(this,void 0),m(this,on,e,"f"),this.options=i,this.response=t,this.body=s}hasNextPage(){return this.getPaginatedItems().length?this.nextPageRequestOptions()!=null:!1}async getNextPage(){let e=this.nextPageRequestOptions();if(!e)throw new k("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await a(this,on,"f").requestAPIList(this.constructor,e)}async*iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e}async*[(on=new WeakMap,Symbol.asyncIterator)](){for await(let e of this.iterPages())for(let t of e.getPaginatedItems())yield t}}return r})(),ja=(()=>{class r extends nn{constructor(e,t,s){super(e,t,async(i,o)=>new s(i,o.response,await sn(i,o),o.options))}async*[Symbol.asyncIterator](){let e=await this;for await(let t of e)yield t}}return r})(),C=class extends eo{constructor(n,e,t,s){super(n,e,t,s),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:{...Gr(this.options.query),before_id:e}}:null}let n=this.last_id;return n?{...this.options,query:{...Gr(this.options.query),after_id:n}}:null}};var w=class extends eo{constructor(n,e,t,s){super(n,e,t,s),this.data=t.data||[],this.next_page=t.next_page||null}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.nextPageRequestOptions()!=null}nextPageRequestOptions(){let n=this.next_page;return n?{...this.options,query:{...Gr(this.options.query),page:n}}:null}},an=class extends eo{constructor(n,e,t,s){super(n,e,t,s),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 n=this.next_page;return n?{...this.options,query:{...Gr(this.options.query),page:n}}:null}};var ro=()=>{if(typeof File>"u"){let{process:r}=globalThis,n=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."+(n?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}};function Ve(r,n,e){return ro(),new File(r,n??"",e)}function ns(r,n){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 n?e.split(/[\\/]/).pop()||void 0:e}var so=r=>r!=null&&typeof r=="object"&&typeof r[Symbol.asyncIterator]=="function";var J=async(r,n,e=!0)=>({...r,body:await Vl(r.body,n,e)}),Ka=new WeakMap;function Kl(r){let n=typeof r=="function"?r:r.fetch,e=Ka.get(n);if(e)return e;let t=(async()=>{try{let s="Response"in n?n.Response:(await n("data:,")).constructor,i=new FormData;return i.toString()!==await new s(i).text()}catch{return!0}})();return Ka.set(n,t),t}var Vl=async(r,n,e=!0)=>{if(!await Kl(n))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(([s,i])=>to(t,s,i,e))),t};var to=async(r,n,e,t)=>{if(e!==void 0){if(e==null)throw new TypeError(`Received null for "${n}"; to pass null in FormData, you must use the string 'null'`);if(typeof e=="string"||typeof e=="number"||typeof e=="boolean")r.append(n,String(e));else if(e instanceof Response){let s={},i=e.headers.get("Content-Type");i&&(s={type:i}),r.append(n,Ve([await e.blob()],ns(e,t),s))}else if(so(e))r.append(n,Ve([await new Response(qs(e)).blob()],ns(e,t)));else if(e instanceof Blob){let i=typeof File<"u"&&e instanceof File?e.name:ns(e,t);r.append(n,Ve([e],i,{type:e.type}))}else if(Array.isArray(e))await Promise.all(e.map(s=>to(r,n+"[]",s,t)));else{if(typeof e.then=="function")throw new TypeError(`Received a Promise for "${n}"; await it first, e.g. \`await toFile(...)\``);if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))throw new TypeError(`Received ${e.constructor.name} for "${n}"; to upload raw bytes, wrap them with \`await toFile(bytes, 'filename')\``);if(typeof e=="object")await Promise.all(Object.entries(e).map(([s,i])=>to(r,`${n}[${s}]`,i,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 Va=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",Jl=r=>r!=null&&typeof r=="object"&&typeof r.name=="string"&&typeof r.lastModified=="number"&&Va(r),Gl=r=>r!=null&&typeof r=="object"&&typeof r.url=="string"&&typeof r.blob=="function";async function io(r,n,e){if(ro(),r=await r,n||(n=r instanceof File?r.name:ns(r,!0)),Jl(r))return r instanceof File&&n==null&&e==null?r:Ve([await r.arrayBuffer()],n??r.name,{type:r.type,lastModified:r.lastModified,...e});if(Gl(r)){let s=await r.blob();return n||(n=new URL(r.url).pathname.split(/[\\/]/).pop()),Ve(await no(s),n,e)}let t=await no(r);if(!e?.type){let s=t.find(i=>typeof i=="object"&&"type"in i&&i.type);typeof s=="string"&&(e={...e,type:s})}return Ve(t,n,e)}async function no(r){let n=[];if(typeof r=="string"||ArrayBuffer.isView(r)||r instanceof ArrayBuffer)n.push(r);else if(Va(r))n.push(r instanceof Blob?r:await r.arrayBuffer());else if(so(r))for await(let e of r)n.push(...await no(e));else{let e=r?.constructor?.name;throw new Error(`Unexpected data type: ${typeof r}${e?`; constructor: ${e}`:""}${Yl(r)}`)}return n}function Yl(r){return typeof r!="object"||r===null?"":`; props: [${Object.getOwnPropertyNames(r).map(e=>`"${e}"`).join(", ")}]`}var h=class{constructor(n){this._client=n}};var Ja=Symbol.for("brand.privateNullableHeaders");function*Ql(r){if(!r)return;if(Ja in r){let{values:t,nulls:s}=r;yield*t.entries();for(let i of s)yield[i,null];return}let n=!1,e;r instanceof Headers?e=r.entries():Ni(r)?e=r:(n=!0,e=Object.entries(r??{}));for(let t of e){let s=t[0];if(typeof s!="string")throw new TypeError("expected header name to be a string");let i=Ni(t[1])?t[1]:[t[1]],o=!1;for(let c of i)c!==void 0&&(n&&!o&&(o=!0,yield[s,cn]),yield[s,c])}}var cn=Symbol("clear"),Zl=new Set(["x-stainless-helper"]),eu=(r,n)=>{let e=r?r.split(",").map(t=>t.trim()).filter(Boolean):[];for(let t of n.split(",").map(s=>s.trim()))t&&!e.includes(t)&&e.push(t);return e.join(", ")},u=r=>{let n=new Headers,e=new Set;for(let t of r){let s=new Set;for(let[i,o]of Ql(t)){let c=i.toLowerCase();if(Zl.has(c)){if(o===cn)continue;o===null?(n.delete(i),e.add(c)):(n.set(i,eu(n.get(i),o)),e.delete(c));continue}(o===cn||!s.has(c))&&(n.delete(i),s.add(c),o===cn)||(o===null?(n.delete(i),e.add(c)):(n.append(i,o),e.delete(c)))}}return{[Ja]:!0,values:n,nulls:e}};var Ge="x-stainless-helper",lt="x-stainless-helper-method";function ln(r){return{[Ge]:r}}var Pe=Symbol("anthropic.sdk.stainlessHelper");function Je(r){return typeof r=="object"&&r!==null&&Pe in r}function oo(r,n){let e=new Set;if(r)for(let t of r)Je(t)&&e.add(t[Pe]);if(n)for(let t of n){Je(t)&&e.add(t[Pe]);let s=t.content;if(Array.isArray(s))for(let i of s){Je(i)&&e.add(i[Pe]);let o=i?.tool?.definition;Je(o)&&e.add(o[Pe])}}return Array.from(e)}function un(r,n){let e=oo(r,n);return e.length===0?{}:{[Ge]:e.join(", ")}}function dn(r){return Je(r)?{[Ge]:r[Pe]}:{}}Ue();B();function Ga(r){return r?.output_config?.format}function ao(r,n,e){let t=Ga(n);return!n||!("parse"in(t??{}))?{...r,content:r.content.map(s=>s.type==="text"?Object.defineProperty({...s},"parsed_output",{value:null,enumerable:!1}):s),parsed_output:null}:co(r,n,e)}function co(r,n,e){let t=null,s=r.content.map(i=>{if(i.type==="text"){let o=tu(n,i.text);return t===null&&(t=o),Object.defineProperty({...i},"parsed_output",{value:o,enumerable:!1})}return i});return{...r,content:s,parsed_output:t}}function tu(r,n){let e=Ga(r);if(e?.type!=="json_schema")return null;try{return"parse"in e?e.parse(n):JSON.parse(n)}catch(t){throw new k(`Failed to parse structured output: ${t}`)}}var ru=r=>{let n=0,e=[];for(;n<r.length;){let t=r[n];if(t==="\\"){n++;continue}if(t==="{"){e.push({type:"brace",value:"{"}),n++;continue}if(t==="}"){e.push({type:"brace",value:"}"}),n++;continue}if(t==="["){e.push({type:"paren",value:"["}),n++;continue}if(t==="]"){e.push({type:"paren",value:"]"}),n++;continue}if(t===":"){e.push({type:"separator",value:":"}),n++;continue}if(t===","){e.push({type:"delimiter",value:","}),n++;continue}if(t==='"'){let c=n+1,f=c,d=!1;for(;;){if(f=r.indexOf('"',f),f===-1){d=!0;break}let b=0,p=f-1;for(;p>=c&&r[p]==="\\";)b++,p--;if(b%2===0)break;f++}d?n=r.length:(e.push({type:"string",value:r.slice(c,f)}),n=f+1);continue}if(t&&/\s/.test(t)){n++;continue}let i=/[0-9]/;if(t&&i.test(t)||t==="-"||t==="."){let c="";for(t==="-"&&(c+=t,t=r[++n]);t&&(i.test(t)||t==="."||t==="e"||t==="E"||(t==="-"||t==="+")&&(c[c.length-1]==="e"||c[c.length-1]==="E"));)c+=t,t=r[++n];e.push({type:"number",value:c,unterminated:n===r.length});continue}let o=/[a-z]/i;if(t&&o.test(t)){let c="";for(;t&&o.test(t)&&n!==r.length;)c+=t,t=r[++n];if(c=="true"||c=="false"||c==="null")e.push({type:"name",value:c});else{n++;continue}continue}n++}return e},su=r=>{let n=[];for(let i of r)(i.type==="brace"||i.type==="paren")&&(i.value==="{"||i.value==="["?n.push(i.value):n.pop());let e=n[n.length-1],t=r.length,s=/^-?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][-+]?[0-9]+)?$/;for(;t>0;){let i=r[t-1];switch(i.type){case"separator":t--;continue;case"number":if(i.unterminated||!s.test(i.value)){t--;continue}break;case"string":let o=r[t-2];if(e==="{"&&(o?.type==="delimiter"||o?.type==="brace"&&o.value==="{")){t--;continue}break;case"delimiter":t--;break}break}return r.slice(0,t)},nu=r=>{let n=[];return r.map(e=>{e.type==="brace"&&(e.value==="{"?n.push("}"):n.splice(n.lastIndexOf("}"),1)),e.type==="paren"&&(e.value==="["?n.push("]"):n.splice(n.lastIndexOf("]"),1))}),n.length>0&&n.reverse().map(e=>{e==="}"?r.push({type:"brace",value:"}"}):e==="]"&&r.push({type:"paren",value:"]"})}),r},iu=r=>{let n="";return r.map(e=>{e.type==="string"?n+='"'+e.value+'"':n+=e.value}),n},Ya=r=>JSON.parse(iu(nu(su(ru(r)))));var Te="__json_buf";function hn(r,n){let e={};for(let i of Object.keys(r))i!=="input"&&(e[i]=r[i]);Object.defineProperty(e,Te,{value:n,enumerable:!1,writable:!0});let t,s=!1;return Object.defineProperty(e,"input",{enumerable:!0,configurable:!0,get(){return s||(t=n?Ya(n):{},s=!0),t}}),e}var le,Me,ut,is,fn,os,as,pn,cs,ke,ls,mn,_n,Ye,gn,wn,bn,us,lo,Xa,uo,ho,fo,po,Qa;function mo(r){return r.type==="tool_use"||r.type==="server_tool_use"}var Za=(()=>{class r{constructor(e,t){le.add(this),this.messages=[],this.receivedMessages=[],Me.set(this,void 0),ut.set(this,null),this.controller=new AbortController,is.set(this,void 0),fn.set(this,()=>{}),os.set(this,()=>{}),as.set(this,void 0),pn.set(this,()=>{}),cs.set(this,()=>{}),ke.set(this,{}),ls.set(this,!1),mn.set(this,!1),_n.set(this,!1),Ye.set(this,!1),gn.set(this,void 0),wn.set(this,void 0),bn.set(this,void 0),us.set(this,void 0),uo.set(this,s=>{if(m(this,mn,!0,"f"),de(s)&&(s=new V),s instanceof V)return m(this,_n,!0,"f"),this._emit("abort",s);if(s instanceof k)return this._emit("error",s);if(s instanceof Error){let i=new k(s.message);return i.cause=s,this._emit("error",i)}return this._emit("error",new k(String(s)))}),m(this,is,new Promise((s,i)=>{m(this,fn,s,"f"),m(this,os,i,"f")}),"f"),m(this,as,new Promise((s,i)=>{m(this,pn,s,"f"),m(this,cs,i,"f")}),"f"),a(this,is,"f").catch(()=>{}),a(this,as,"f").catch(()=>{}),m(this,ut,e,"f"),m(this,us,t?.logger??console,"f")}get response(){return a(this,gn,"f")}get request_id(){return a(this,wn,"f")}get workspace_id(){return a(this,bn,"f")}async withResponse(){m(this,Ye,!0,"f");let e=await a(this,is,"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,s,{logger:i}={}){let o=new r(t,{logger:i});for(let c of t.messages)o._addMessageParam(c);return m(o,ut,{...t,stream:!0},"f"),o._run(()=>o._createMessage(e,{...t,stream:!0},{...s,headers:{...s?.headers,[lt]:"stream"}})),o}_run(e){e().then(()=>{this._emitFinal(),this._emit("end")},a(this,uo,"f"))}_addMessageParam(e){this.messages.push(e)}_addMessage(e,t=!0){this.receivedMessages.push(e),t&&this._emit("message",e)}async _createMessage(e,t,s){let i=s?.signal,o;i&&(i.aborted&&this.controller.abort(),o=this.controller.abort.bind(this.controller),i.addEventListener("abort",o));try{a(this,le,"m",ho).call(this);let{response:c,data:f}=await e.create({...t,stream:!0},{...s,signal:this.controller.signal}).withResponse();this._connected(c);for await(let d of f)a(this,le,"m",fo).call(this,d);if(f.controller.signal?.aborted)throw new V;a(this,le,"m",po).call(this)}finally{i&&o&&i.removeEventListener("abort",o)}}_connected(e){this.ended||(m(this,gn,e,"f"),m(this,wn,e?.headers.get("request-id"),"f"),m(this,bn,e?.headers.get("anthropic-workspace-id"),"f"),a(this,fn,"f").call(this,e),this._emit("connect"))}get ended(){return a(this,ls,"f")}get errored(){return a(this,mn,"f")}get aborted(){return a(this,_n,"f")}abort(){this.controller.abort()}on(e,t){return(a(this,ke,"f")[e]||(a(this,ke,"f")[e]=[])).push({listener:t}),this}off(e,t){let s=a(this,ke,"f")[e];if(!s)return this;let i=s.findIndex(o=>o.listener===t);return i>=0&&s.splice(i,1),this}once(e,t){return(a(this,ke,"f")[e]||(a(this,ke,"f")[e]=[])).push({listener:t,once:!0}),this}emitted(e){return new Promise((t,s)=>{m(this,Ye,!0,"f"),e!=="error"&&this.once("error",s),this.once(e,t)})}async done(){m(this,Ye,!0,"f"),await a(this,as,"f")}get currentMessage(){return a(this,Me,"f")}async finalMessage(){return await this.done(),a(this,le,"m",lo).call(this)}async finalText(){return await this.done(),a(this,le,"m",Xa).call(this)}_emit(e,...t){if(a(this,ls,"f"))return;e==="end"&&(m(this,ls,!0,"f"),a(this,pn,"f").call(this));let s=a(this,ke,"f")[e];if(s&&(a(this,ke,"f")[e]=s.filter(i=>!i.once),s.forEach(({listener:i})=>i(...t))),e==="abort"){let i=t[0];!a(this,Ye,"f")&&!s?.length&&Promise.reject(i),a(this,os,"f").call(this,i),a(this,cs,"f").call(this,i),this._emit("end");return}if(e==="error"){let i=t[0];!a(this,Ye,"f")&&!s?.length&&Promise.reject(i),a(this,os,"f").call(this,i),a(this,cs,"f").call(this,i),this._emit("end")}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit("finalMessage",a(this,le,"m",lo).call(this))}async _fromReadableStream(e,t){let s=t?.signal,i;s&&(s.aborted&&this.controller.abort(),i=this.controller.abort.bind(this.controller),s.addEventListener("abort",i));try{a(this,le,"m",ho).call(this),this._connected(null);let o=ye.fromReadableStream(e,this.controller);for await(let c of o)a(this,le,"m",fo).call(this,c);if(o.controller.signal?.aborted)throw new V;a(this,le,"m",po).call(this)}finally{s&&i&&s.removeEventListener("abort",i)}}[(Me=new WeakMap,ut=new WeakMap,is=new WeakMap,fn=new WeakMap,os=new WeakMap,as=new WeakMap,pn=new WeakMap,cs=new WeakMap,ke=new WeakMap,ls=new WeakMap,mn=new WeakMap,_n=new WeakMap,Ye=new WeakMap,gn=new WeakMap,wn=new WeakMap,bn=new WeakMap,us=new WeakMap,uo=new WeakMap,le=new WeakSet,lo=function(){if(this.receivedMessages.length===0)throw new k("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},Xa=function(){if(this.receivedMessages.length===0)throw new k("stream ended without producing a Message with role=assistant");let t=this.receivedMessages.at(-1).content.filter(s=>s.type==="text").map(s=>s.text);if(t.length===0)throw new k("stream ended without producing a content block with type=text");return t.join(" ")},ho=function(){this.ended||m(this,Me,void 0,"f")},fo=function(t){if(this.ended)return;let s=a(this,le,"m",Qa).call(this,t);switch(this._emit("streamEvent",t,s),t.type){case"content_block_delta":{let i=s.content.at(-1);switch(t.delta.type){case"text_delta":{i.type==="text"&&this._emit("text",t.delta.text,i.text||"");break}case"citations_delta":{i.type==="text"&&this._emit("citation",t.delta.citation,i.citations??[]);break}case"input_json_delta":{mo(i)&&a(this,ke,"f").inputJson?.length&&this._emit("inputJson",t.delta.partial_json,i.input);break}case"thinking_delta":{i.type==="thinking"&&this._emit("thinking",t.delta.thinking,i.thinking);break}case"signature_delta":{i.type==="thinking"&&this._emit("signature",i.signature);break}default:t.delta}break}case"message_stop":{this._addMessageParam(s),this._addMessage(ao(s,a(this,ut,"f"),{logger:a(this,us,"f")}),!0);break}case"content_block_stop":{this._emit("contentBlock",s.content.at(-1));break}case"message_start":{m(this,Me,s,"f");break}case"content_block_start":case"message_delta":break}},po=function(){if(this.ended)throw new k("stream has ended, this shouldn't happen");let t=a(this,Me,"f");if(!t)throw new k("request ended without sending any chunks");return m(this,Me,void 0,"f"),ao(t,a(this,ut,"f"),{logger:a(this,us,"f")})},Qa=function(t){let s=a(this,Me,"f");if(t.type==="message_start"){if(s)throw new k(`Unexpected event order, got ${t.type} before receiving "message_stop"`);return t.message}if(!s)throw new k(`Unexpected event order, got ${t.type} before "message_start"`);switch(t.type){case"message_stop":return s;case"message_delta":return s.stop_reason=t.delta.stop_reason,s.stop_sequence=t.delta.stop_sequence,s.stop_details=t.delta.stop_details,s.usage.output_tokens=t.usage.output_tokens,t.delta.container!=null&&(s.container=t.delta.container),t.usage.input_tokens!=null&&(s.usage.input_tokens=t.usage.input_tokens),t.usage.cache_creation_input_tokens!=null&&(s.usage.cache_creation_input_tokens=t.usage.cache_creation_input_tokens),t.usage.cache_read_input_tokens!=null&&(s.usage.cache_read_input_tokens=t.usage.cache_read_input_tokens),t.usage.server_tool_use!=null&&(s.usage.server_tool_use=t.usage.server_tool_use),t.usage.output_tokens_details!=null&&(s.usage.output_tokens_details=t.usage.output_tokens_details),s;case"content_block_start":return s.content.push({...t.content_block}),s;case"content_block_delta":{let i=s.content.at(t.index);switch(t.delta.type){case"text_delta":{i?.type==="text"&&(s.content[t.index]={...i,text:(i.text||"")+t.delta.text});break}case"citations_delta":{i?.type==="text"&&(s.content[t.index]={...i,citations:[...i.citations??[],t.delta.citation]});break}case"input_json_delta":{if(i&&mo(i)){let o=(i[Te]||"")+t.delta.partial_json;s.content[t.index]=hn(i,o)}break}case"thinking_delta":{i?.type==="thinking"&&(s.content[t.index]={...i,thinking:i.thinking+t.delta.thinking});break}case"signature_delta":{i?.type==="thinking"&&(s.content[t.index]={...i,signature:t.delta.signature});break}default:t.delta}return s}case"content_block_stop":{let i=s.content.at(t.index);return i&&mo(i)&&Te in i&&Object.defineProperty(i,"input",{value:i.input,enumerable:!0,configurable:!0,writable:!0}),s}}},Symbol.asyncIterator)](){let e=[],t=[],s=!1;return this.on("streamEvent",i=>{let o=t.shift();o?o.resolve(i):e.push(i)}),this.on("end",()=>{s=!0;for(let i of t)i.resolve(void 0);t.length=0}),this.on("abort",i=>{s=!0;for(let o of t)o.reject(i);t.length=0}),this.on("error",i=>{s=!0;for(let o of t)o.reject(i);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:s?{value:void 0,done:!0}:new Promise((o,c)=>t.push({resolve:o,reject:c})).then(o=>o?{value:o,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new ye(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}return r})();B();var yn,kn=(()=>{class r{constructor(e,t){this.iterator=e,yn.set(this,!1),this.controller=t}async*decoder(){if(a(this,yn,"f"))throw new k("Cannot iterate over a consumed stream.");m(this,yn,!0,"f");let e=new es;for await(let t of this.iterator)for(let s of e.decode(t))yield JSON.parse(s);for(let t of e.flush())yield JSON.parse(t)}[(yn=new WeakMap,Symbol.asyncIterator)](){return this.decoder()}static fromResponse(e,t){if(!e.body)throw t.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new k("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 k("Attempted to iterate over a response with no body");return new r(Xr(e.body),t)}}return r})();B();function tc(r){return r.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}var ec=Object.freeze(Object.create(null)),ou=(r=tc)=>function(e,...t){if(e.length===1)return e[0];let s=!1,i=[],o=e.reduce((b,p,g)=>{/[?#]/.test(p)&&(s=!0);let y=t[g],_=(s?encodeURIComponent:r)(""+y);return g!==t.length&&(y==null||typeof y=="object"&&y.toString===Object.getPrototypeOf(Object.getPrototypeOf(y.hasOwnProperty??ec)??ec)?.toString)&&(_=y+"",i.push({start:b.length+p.length,length:_.length,error:`Value of type ${Object.prototype.toString.call(y).slice(8,-1)} is not a valid path parameter`})),!s&&_===""&&i.push({start:b.length+p.length,length:0,error:`Value "" can't be safely passed as a path parameter`}),b+p+(g===t.length?"":_)},""),c=o.split(/[?#]/,1)[0],f=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi,d;for(;(d=f.exec(c))!==null;)i.push({start:d.index,length:d[0].length,error:`Value "${d[0]}" can't be safely passed as a path parameter`});if(i.sort((b,p)=>b.start-p.start),i.length>0){let b=[];for(let g of i)for(let y=g.start;y<g.start+Math.max(1,g.length);y++)b[y]="^";let p=Array.from(b,g=>g??" ").join("");throw new k(`Path parameters result in path with invalid segments:
|
|
${i.map(g=>g.error).join(`
|
|
`)}
|
|
${o}
|
|
${p}`)}return o},l=ou(tc);var dt=class extends h{create(n,e){let{user_profile_id:t,workspace_id:s,...i}=n;return this._client.post("/v1/messages/batches",{body:i,...e,headers:u([{...t!=null?{"anthropic-user-profile-id":t}:void 0,...s!=null?{"anthropic-workspace-id":s}:void 0},e?.headers])})}retrieve(n,e={},t){let{workspace_id:s}=e??{};return this._client.get(l`/v1/messages/batches/${n}`,{...t,headers:u([{...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers])})}list(n={},e){let{workspace_id:t,...s}=n??{};return this._client.getAPIList("/v1/messages/batches",C,{query:s,...e,headers:u([{...t!=null?{"anthropic-workspace-id":t}:void 0},e?.headers])})}delete(n,e={},t){let{workspace_id:s}=e??{};return this._client.delete(l`/v1/messages/batches/${n}`,{...t,headers:u([{...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers])})}cancel(n,e={},t){let{workspace_id:s}=e??{};return this._client.post(l`/v1/messages/batches/${n}/cancel`,{...t,headers:u([{...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers])})}async results(n,e={},t){let s=await this.retrieve(n,e,t);if(!s.results_url)throw new k(`No batch \`results_url\`; Has it finished processing? ${s.processing_status} - ${s.id}`);let{workspace_id:i}=e??{};return this._client.get(s.results_url,{...t,headers:u([{Accept:"application/binary",...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers]),stream:!0,__binaryResponse:!0})._thenUnwrap((o,c)=>kn.fromResponse(c.response,c.controller))}};var Sn={"claude-opus-4@20250514":8192,"anthropic.claude-opus-4-1-20250805-v1:0":8192,"claude-opus-4-1@20250805":8192};var ds=(()=>{class r extends h{constructor(){super(...arguments),this.batches=new dt(this._client)}create(e,t){let{user_profile_id:s,workspace_id:i,...o}=e;o.model in rc&&console.warn(`The model '${o.model}' is deprecated and will reach end-of-life on ${rc[o.model]}
|
|
Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`),cu.includes(o.model)&&o.thinking&&o.thinking.type==="enabled"&&console.warn(`Using Claude with ${o.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 c=t?.timeout??this._client._options.timeout;if(!o.stream&&c==null){let d=Sn[o.model]??void 0;c=this._client.calculateNonstreamingTimeout(o.max_tokens,d)}let f=un(o.tools,o.messages);return this._client.post("/v1/messages",{body:o,timeout:c??6e5,...t,headers:u([{...s!=null?{"anthropic-user-profile-id":s}:void 0,...i!=null?{"anthropic-workspace-id":i}:void 0},f,t?.headers]),stream:e.stream??!1})}parse(e,t){return this.create(e,t).then(s=>co(s,e,{logger:this._client.logger??console}))}stream(e,t){return Za.createMessage(this,e,t,{logger:this._client.logger??console})}countTokens(e,t){let{user_profile_id:s,workspace_id:i,...o}=e;return this._client.post("/v1/messages/count_tokens",{body:o,...t,headers:u([{...s!=null?{"anthropic-user-profile-id":s}:void 0,...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}}return r.Batches=dt,r})();var rc={"claude-sonnet-4-5":"November 30th, 2026","claude-sonnet-4-5-20250929":"November 30th, 2026"},cu=["claude-mythos-preview","claude-opus-4-6"];var ht=class extends h{retrieve(n,e={},t){let{betas:s,workspace_id:i}=e??{};return this._client.get(l`/v1/deployment_runs/${n}?beta=true`,{...t,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}list(n={},e){let{betas:t,workspace_id:s,...i}=n??{};return this._client.getAPIList("/v1/deployment_runs?beta=true",w,{query:i,...e,headers:u([{"anthropic-beta":[...t??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},e?.headers])})}};var ft=class extends h{create(n,e){let{betas:t,workspace_id:s,...i}=n;return this._client.post("/v1/deployments?beta=true",{body:i,...e,headers:u([{"anthropic-beta":[...t??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},e?.headers])})}retrieve(n,e={},t){let{betas:s,workspace_id:i}=e??{};return this._client.get(l`/v1/deployments/${n}?beta=true`,{...t,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}update(n,e,t){let{betas:s,workspace_id:i,...o}=e;return this._client.post(l`/v1/deployments/${n}?beta=true`,{body:o,...t,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}list(n={},e){let{betas:t,workspace_id:s,...i}=n??{};return this._client.getAPIList("/v1/deployments?beta=true",w,{query:i,...e,headers:u([{"anthropic-beta":[...t??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},e?.headers])})}archive(n,e={},t){let{betas:s,workspace_id:i}=e??{};return this._client.post(l`/v1/deployments/${n}/archive?beta=true`,{...t,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}pause(n,e={},t){let{betas:s,workspace_id:i}=e??{};return this._client.post(l`/v1/deployments/${n}/pause?beta=true`,{...t,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}run(n,e={},t){let{betas:s,workspace_id:i}=e??{};return this._client.post(l`/v1/deployments/${n}/run?beta=true`,{...t,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}unpause(n,e={},t){let{betas:s,workspace_id:i}=e??{};return this._client.post(l`/v1/deployments/${n}/unpause?beta=true`,{...t,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}};var pt=class extends h{create(n,e){let{betas:t,workspace_id:s,...i}=n;return this._client.post("/v1/dreams?beta=true",{body:i,...e,headers:u([{"anthropic-beta":[...t??[],"dreaming-2026-04-21"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},e?.headers])})}retrieve(n,e={},t){let{betas:s,workspace_id:i}=e??{};return this._client.get(l`/v1/dreams/${n}?beta=true`,{...t,headers:u([{"anthropic-beta":[...s??[],"dreaming-2026-04-21"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}list(n={},e){let{betas:t,workspace_id:s,...i}=n??{};return this._client.getAPIList("/v1/dreams?beta=true",w,{query:i,...e,headers:u([{"anthropic-beta":[...t??[],"dreaming-2026-04-21"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},e?.headers])})}archive(n,e={},t){let{betas:s,workspace_id:i}=e??{};return this._client.post(l`/v1/dreams/${n}/archive?beta=true`,{...t,headers:u([{"anthropic-beta":[...s??[],"dreaming-2026-04-21"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}cancel(n,e={},t){let{betas:s,workspace_id:i}=e??{};return this._client.post(l`/v1/dreams/${n}/cancel?beta=true`,{...t,headers:u([{"anthropic-beta":[...s??[],"dreaming-2026-04-21"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}};var mt=class extends h{list(n={},e){let{betas:t,workspace_id:s,...i}=n??{};return this._client.getAPIList("/v1/files?beta=true",w,{query:i,...e,headers:u([{...t?.toString()!=null?{"anthropic-beta":t?.toString()}:void 0,...s!=null?{"anthropic-workspace-id":s}:void 0},e?.headers])})}delete(n,e={},t){let{betas:s,workspace_id:i}=e??{};return this._client.delete(l`/v1/files/${n}?beta=true`,{...t,headers:u([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0,...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}download(n,e={},t){let{betas:s,workspace_id:i}=e??{};return this._client.get(l`/v1/files/${n}/content?beta=true`,{...t,headers:u([{Accept:"application/binary",...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0,...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers]),__binaryResponse:!0})}retrieveMetadata(n,e={},t){let{betas:s,workspace_id:i}=e??{};return this._client.get(l`/v1/files/${n}?beta=true`,{...t,headers:u([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0,...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}upload(n,e){let{betas:t,workspace_id:s,...i}=n;return this._client.post("/v1/files?beta=true",J({body:i,...e,headers:u([{...t?.toString()!=null?{"anthropic-beta":t?.toString()}:void 0,...s!=null?{"anthropic-workspace-id":s}:void 0},dn(i.file),e?.headers])},this._client))}};var _t=class extends h{retrieve(n,e={},t){let{betas:s,workspace_id:i}=e??{};return this._client.get(l`/v1/models/${n}?beta=true`,{...t,headers:u([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0,...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}list(n={},e){let{betas:t,workspace_id:s,...i}=n??{};return this._client.getAPIList("/v1/models?beta=true",C,{query:i,...e,headers:u([{...t?.toString()!=null?{"anthropic-beta":t?.toString()}:void 0,...s!=null?{"anthropic-workspace-id":s}:void 0},e?.headers])})}};var gt=class extends h{create(n,e){let{betas:t,workspace_id:s,...i}=n;return this._client.post("/v1/user_profiles?beta=true",{body:i,...e,headers:u([{"anthropic-beta":[...t??[],"user-profiles-2026-08-18"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},e?.headers])})}retrieve(n,e={},t){let{betas:s,workspace_id:i}=e??{};return this._client.get(l`/v1/user_profiles/${n}?beta=true`,{...t,headers:u([{"anthropic-beta":[...s??[],"user-profiles-2026-08-18"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}update(n,e,t){let{betas:s,workspace_id:i,...o}=e;return this._client.post(l`/v1/user_profiles/${n}?beta=true`,{body:o,...t,headers:u([{"anthropic-beta":[...s??[],"user-profiles-2026-08-18"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}list(n={},e){let{betas:t,workspace_id:s,...i}=n??{};return this._client.getAPIList("/v1/user_profiles?beta=true",w,{query:i,...e,headers:u([{"anthropic-beta":[...t??[],"user-profiles-2026-08-18"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},e?.headers])})}createEnrollmentURL(n,e={},t){let{betas:s,workspace_id:i}=e??{};return this._client.post(l`/v1/user_profiles/${n}/enrollment_url?beta=true`,{...t,headers:u([{"anthropic-beta":[...s??[],"user-profiles-2026-08-18"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}};var fc=fl(hc(),1),bt=class extends h{parseUnverified(n){return JSON.parse(n)}unwrap(n,e){let t=e?.headers;if(t==null)throw new Error("Webhook headers are required in order to verify the signature");let s=e.key===void 0?this._client.webhookKey:e.key;if(!s)throw new Error("Webhook key must not be null or empty in order to unwrap");return new fc.Webhook(s).verify(n,t),JSON.parse(n)}};var yt=class extends h{list(n,e={},t){let{betas:s,workspace_id:i,...o}=e??{};return this._client.getAPIList(l`/v1/agents/${n}/versions?beta=true`,w,{query:o,...t,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}};var An=(()=>{class r extends h{constructor(){super(...arguments),this.versions=new yt(this._client)}create(e,t){let{betas:s,workspace_id:i,...o}=e;return this._client.post("/v1/agents?beta=true",{body:o,...t,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}retrieve(e,t={},s){let{betas:i,workspace_id:o,...c}=t??{};return this._client.get(l`/v1/agents/${e}?beta=true`,{query:c,...s,headers:u([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},s?.headers])})}update(e,t,s){let{betas:i,workspace_id:o,...c}=t;return this._client.post(l`/v1/agents/${e}?beta=true`,{body:c,...s,headers:u([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},s?.headers])})}list(e={},t){let{betas:s,workspace_id:i,...o}=e??{};return this._client.getAPIList("/v1/agents?beta=true",w,{query:o,...t,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}archive(e,t={},s){let{betas:i,workspace_id:o}=t??{};return this._client.post(l`/v1/agents/${e}/archive?beta=true`,{...s,headers:u([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},s?.headers])})}}return r.Versions=yt,r})();B();function Ce(r,n){if(!r)return()=>{};if(r.aborted)return n.abort(),()=>{};let e=()=>n.abort();return r.addEventListener("abort",e),()=>r.removeEventListener("abort",e)}B();function $e(r,n){return r instanceof D&&r.status===n}function Pu(r){return r instanceof D&&typeof r.status=="number"&&r.status>=400&&r.status<500}function Xe(r){return Pu(r)&&!$e(r,408)&&!$e(r,409)&&!$e(r,429)}function Pn(r,n,e){return Math.min(n*2**r,e)}function pc(r,n){return r+Math.random()*(n-r)}function Rn(r){return r*(1-Math.random()*.25)}B();function In(r,{authToken:n,helper:e}){if(!n)throw new k(`copyClientForHelper: expected a non-empty authToken but received ${JSON.stringify(n)}`);let t=r,s=t._options.defaultHeaders,i=t._authState?.extraHeaders,o=i?Object.fromEntries(Object.entries(i).filter(([f])=>{let d=f.toLowerCase();return d!=="authorization"&&d!=="x-api-key"})):void 0,c=u([o,s,{[Ge]:e}]);return r.withOptions({apiKey:null,authToken:n,baseURL:r.baseURL,credentials:void 0,defaultHeaders:c})}var kt,En,ue,Tn,Mn,On,fs,ps,St,vt,Cn,xt,ms,Ru=999,Iu=1e3,Eu=6e4,Tu=3e5,_s=(()=>{class r{constructor(e){kt.set(this,void 0),En.set(this,!1),ue.set(this,void 0),Tn.set(this,void 0),Mn.set(this,void 0),On.set(this,void 0),fs.set(this,void 0),ps.set(this,void 0),St.set(this,void 0),this.client=e.client,this.environmentId=e.environmentId,this.environmentKey=e.environmentKey,this.workerId=e.workerId??Cu(),m(this,kt,In(e.client,{authToken:e.environmentKey,helper:"environments-work-poller"}),"f"),m(this,Mn,e.autoStop??!0,"f"),m(this,On,e.drain??!1,"f"),m(this,fs,e.blockMs===void 0?Ru:e.blockMs,"f"),m(this,ps,e.reclaimOlderThanMs??null,"f"),m(this,St,e.requestOptions,"f"),m(this,ue,new AbortController,"f"),m(this,Tn,Ce(e.signal,a(this,ue,"f")),"f")}get signal(){return a(this,ue,"f").signal}abort(){a(this,ue,"f").abort()}async*[(kt=new WeakMap,En=new WeakMap,ue=new WeakMap,Tn=new WeakMap,Mn=new WeakMap,On=new WeakMap,fs=new WeakMap,ps=new WeakMap,St=new WeakMap,Symbol.asyncIterator)](){if(a(this,En,"f"))throw new k("Cannot iterate over a consumed WorkPoller");m(this,En,!0,"f");let e=T(this.client);e.info("poller starting",{component:"work-poller",environment_id:this.environmentId});let t=new Ou(e,this.environmentId);try{let s=0;for(;!a(this,ue,"f").signal.aborted;){let i;try{i=await a(this,kt,"f").beta.environments.work.poll(this.environmentId,{"Anthropic-Worker-ID":this.workerId,...a(this,fs,"f")!==null?{block_ms:a(this,fs,"f")}:{},...a(this,ps,"f")!==null?{reclaim_older_than_ms:a(this,ps,"f")}:{}},{headers:u([a(this,St,"f")?.headers]),signal:a(this,ue,"f").signal})}catch(o){if(a(this,ue,"f").signal.aborted)return;if(Xe(o))throw e.error("poll failed permanently, stopping poller",{error:String(o)}),o;let c=Rn(Mu(s));e.warn("poll failed, backing off",{error:String(o),backoff_ms:c}),s++,await he(c,a(this,ue,"f").signal);continue}if(s=0,i==null){if(a(this,On,"f"))return;t.onEmptyPoll(),await he(pc(1e3,3e3),a(this,ue,"f").signal);continue}t.onClaim(),e.info("claimed work",{component:"work-poller",environment_id:this.environmentId,work_id:i.id,work_type:i.data.type});try{await a(this,kt,"f").beta.environments.work.ack(i.id,{environment_id:i.environment_id},{headers:u([a(this,St,"f")?.headers]),signal:a(this,ue,"f").signal})}catch(o){e.error("ack failed",{work_id:i.id,error:String(o)});continue}try{yield i}finally{if(a(this,Mn,"f"))try{await a(this,kt,"f").beta.environments.work.stop(i.id,{environment_id:i.environment_id},{headers:u([a(this,St,"f")?.headers])})}catch(o){$e(o,409)||e.warn("stop failed",{work_id:i.id,error:String(o)})}}}}finally{a(this,Tn,"f").call(this)}}}return r})();function Mu(r){return Pn(r,Iu,Eu)}var Ou=(()=>{class r{constructor(e,t){vt.set(this,void 0),Cn.set(this,void 0),xt.set(this,void 0),ms.set(this,0),m(this,vt,e,"f"),m(this,Cn,t,"f")}onEmptyPoll(){let e=Date.now(),t={component:"work-poller",environment_id:a(this,Cn,"f")};a(this,xt,"f")===void 0?(m(this,xt,m(this,ms,e,"f"),"f"),a(this,vt,"f").info("idle; polling for work",t)):e-a(this,ms,"f")>=Tu?(m(this,ms,e,"f"),a(this,vt,"f").info(`still polling; idle for ${Math.round((e-a(this,xt,"f"))/1e3)}s`,t)):a(this,vt,"f").debug("poll returned no work",t)}onClaim(){m(this,xt,void 0,"f")}}return vt=new WeakMap,Cn=new WeakMap,xt=new WeakMap,ms=new WeakMap,r})();function Cu(){let n=globalThis.process?.env?.HOSTNAME;return n?`${n}-${tn()}`:tn()}B();B();var At,Ne,Pt,mc=(()=>{class r{constructor(){At.set(this,[]),Ne.set(this,[]),Pt.set(this,!1)}push(e){if(a(this,Pt,"f"))return!1;let t=a(this,Ne,"f").shift();return t?t({done:!1,value:e}):a(this,At,"f").push(e),!0}close(){if(!a(this,Pt,"f"))for(m(this,Pt,!0,"f");a(this,Ne,"f").length>0;)a(this,Ne,"f").shift()({done:!0,value:void 0})}next(e){return a(this,At,"f").length>0?Promise.resolve({done:!1,value:a(this,At,"f").shift()}):a(this,Pt,"f")||e?.aborted?Promise.resolve({done:!0,value:void 0}):new Promise(t=>{let s=o=>{e?.removeEventListener("abort",i),t(o)},i=()=>{let o=a(this,Ne,"f").indexOf(s);o>=0&&a(this,Ne,"f").splice(o,1),t({done:!0,value:void 0})};a(this,Ne,"f").push(s),e?.addEventListener("abort",i,{once:!0})})}tryShift(){return a(this,At,"f").shift()}}return At=new WeakMap,Ne=new WeakMap,Pt=new WeakMap,r})();var Rt=(()=>{class r extends Error{constructor(e){let t=typeof e=="string"?e:e.map(s=>s.type==="text"?s.text:`[${s.type}]`).join(" ");super(t),this.name="ToolError",this.content=e}}return r})();var $u="\\x00-\\x1f\\x7f-\\x9f\\u061c\\u200e\\u200f\\u2028\\u2029\\u202a-\\u202e\\u2066-\\u2069",Nu=new RegExp(`[${$u}]+`,"g"),Lu=/[\uD800-\uDFFF]/gu;function gs(r){return r.replace(Lu,"\uFFFD")}var _c=4096,Fu=200;function Bu(r,n=_c){return wc(gs(r).replace(Nu," ").trim(),n)}function Hu(r){return Bu(r,Fu)}function Re(r){return Hu(r).replace(/[' ]+/g," ").trim()}function $n(r){return`Error: ${r instanceof Error?r.message:String(r)}`}function gc(r){return wc(gs($n(r)),_c)}function wc(r,n){if(r.length<=n)return r;let e=0,t=0;for(let s of r){if(t===n)break;t+=1,e+=s.length}return r.slice(0,e)}function bc(r){return typeof r=="string"?gs(r):r.filter(n=>n.type==="text"&&n.text!=="").map(n=>({...n,text:gs(n.text)}))}function bo(r){return"name"in r?r.name:"mcp_server_name"in r?r.mcp_server_name:r.type}function yo(r){return r instanceof Rt?r.content:$n(r)}async function yc(r,n,e){try{let t=r.parse?r.parse(n):n;return{content:await r.run(t,e),isError:!1}}catch(t){return{content:yo(t),isError:!0}}}var ws,Nn,It,Qe,pe,z,Ln,G,Fn,bs,Bn,j,Et,ne,Tt,Le,Mt,Ie,Hn,ys,ie,Wn,kc,Sc,vc,xc,ko,Ac,Dn,zn,So,Pc,Rc;var Ic=500,Wu=1e4,Du=12e4,zu=3e4,qu=1e3,Uu=3e4,ju=5*6e4,Ku=6e4;function Ec(r){return r.type!=="session.status_idle"?!1:r.stop_reason?.type!=="requires_action"}var Vu=(()=>{class r{constructor(e,t){ws.set(this,void 0),Nn.set(this,void 0),It.set(this,new Set),Qe.set(this,!1),pe.set(this,void 0),m(this,ws,e,"f"),m(this,Nn,t,"f")}noteEvent(e){e.type!=="user.tool_confirmation"&&(Ec(e)?this.arm():this.disarm())}block(e){a(this,It,"f").add(e),a(this,pe,"f")!==void 0&&(m(this,Qe,!0,"f"),clearTimeout(a(this,pe,"f")),m(this,pe,void 0,"f"))}unblock(e){a(this,It,"f").delete(e),a(this,It,"f").size===0&&a(this,Qe,"f")&&this.arm()}arm(){if(!(a(this,ws,"f")<=0)){if(a(this,It,"f").size>0){m(this,Qe,!0,"f");return}m(this,Qe,!1,"f"),a(this,pe,"f")!==void 0&&clearTimeout(a(this,pe,"f")),m(this,pe,setTimeout(a(this,Nn,"f"),a(this,ws,"f")),"f")}}disarm(){m(this,Qe,!1,"f"),a(this,pe,"f")!==void 0&&(clearTimeout(a(this,pe,"f")),m(this,pe,void 0,"f"))}}return ws=new WeakMap,Nn=new WeakMap,It=new WeakMap,Qe=new WeakMap,pe=new WeakMap,r})(),ks=(()=>{class r{constructor(e,t){z.add(this),Ln.set(this,!1),G.set(this,void 0),Fn.set(this,void 0),bs.set(this,void 0),Bn.set(this,void 0),j.set(this,void 0),Et.set(this,new Set),ne.set(this,new Set),Tt.set(this,new Map),Le.set(this,new Map),Mt.set(this,new mc),Ie.set(this,0),Hn.set(this,ju),ys.set(this,null),ie.set(this,void 0),this.client=t.client,this.sessionId=e,this.tools=t.tools,this.maxIdleMs=t.maxIdleMs??Ku,m(this,j,T(t.client),"f"),m(this,Bn,new Map(t.tools.map(s=>[bo(s),s])),"f"),m(this,G,new AbortController,"f"),m(this,Fn,Ce(t.signal,a(this,G,"f")),"f"),m(this,bs,t.requestOptions,"f"),m(this,ie,new Vu(this.maxIdleMs,()=>{a(this,j,"f").info("session idle after its turn ended; stopping",{component:"session-tool-runner",session_id:this.sessionId,max_idle_ms:this.maxIdleMs}),a(this,G,"f").abort()}),"f")}get signal(){return a(this,G,"f").signal}abort(){a(this,G,"f").abort()}_setSendRetryWindow(e){m(this,Hn,e,"f")}async*[(Ln=new WeakMap,G=new WeakMap,Fn=new WeakMap,bs=new WeakMap,Bn=new WeakMap,j=new WeakMap,Et=new WeakMap,ne=new WeakMap,Tt=new WeakMap,Le=new WeakMap,Mt=new WeakMap,Ie=new WeakMap,Hn=new WeakMap,ys=new WeakMap,ie=new WeakMap,z=new WeakSet,Symbol.asyncIterator)](){if(a(this,Ln,"f"))throw new k("Cannot iterate over a consumed SessionToolRunner");m(this,Ln,!0,"f"),a(this,j,"f").info("session tool runner starting",{component:"session-tool-runner",session_id:this.sessionId});let e=a(this,z,"m",kc).call(this).catch(t=>{a(this,G,"f").signal.aborted||a(this,j,"f").error("stream loop failed",{error:String(t)}),a(this,G,"f").abort()});try{for(;;){let s=await a(this,Mt,"f").next(a(this,G,"f").signal);if(s.done)break;yield s.value}await e;let t;for(;(t=a(this,Mt,"f").tryShift())!==void 0;)yield t}finally{a(this,G,"f").abort(),a(this,ie,"f").disarm(),await e;try{await a(this,z,"m",Rc).call(this)}catch(t){a(this,j,"f").warn("drain failed",{error:String(t)})}a(this,Mt,"f").close();for(let t of this.tools)try{await t.close?.()}catch(s){a(this,j,"f").warn("tool.close failed",{tool:bo(t),error:String(s)})}a(this,Fn,"f").call(this)}}}return Wn=function(){return{...a(this,bs,"f"),headers:u([ln("session-tool-runner"),a(this,bs,"f")?.headers]),signal:a(this,G,"f").signal}},kc=async function(){let e=a(this,G,"f"),t=Ic;for(;!e.signal.aborted;){try{let s=await this.client.beta.sessions.events.stream(this.sessionId,{},a(this,z,"m",Wn).call(this));await a(this,z,"m",Sc).call(this);for await(let i of s)if(t=Ic,await a(this,z,"m",xc).call(this,i))return}catch(s){if(e.signal.throwIfAborted(),Xe(s))throw a(this,j,"f").error("permanent stream failure, shutting down",{error:String(s)}),e.abort(),s;a(this,j,"f").warn("stream disconnected, reconnecting",{error:String(s),backoff_ms:t})}e.signal.throwIfAborted(),await he(t,e.signal),t=Math.min(t*2,Wu)}},Sc=async function(){let e=a(this,G,"f"),t=[],s=!1;try{for await(let c of this.client.beta.sessions.events.list(this.sessionId,{limit:1e3},a(this,z,"m",Wn).call(this)))a(this,z,"m",vc).call(this,c,t),c.type!=="user.tool_confirmation"&&(s=Ec(c))}catch(c){e.signal.throwIfAborted(),a(this,j,"f").warn("reconcile list failed",{error:String(c)});for(let f of t)a(this,Et,"f").delete(f.id);return}let i=t.filter(c=>!a(this,ne,"f").has(c.id));a(this,ie,"f").disarm();for(let c of i)await a(this,z,"m",ko).call(this,c);for(let c of[...a(this,Le,"f").values()]){let f=a(this,Tt,"f").get(c.id);f!==void 0&&await a(this,z,"m",Dn).call(this,c,f)}let o=i.filter(c=>!a(this,ne,"f").has(c.id)&&!a(this,Le,"f").has(c.id));s&&o.length===0?a(this,ie,"f").arm():a(this,ie,"f").disarm()},vc=function(e,t){e.type==="agent.tool_use"||e.type==="agent.custom_tool_use"?(a(this,Et,"f").add(e.id),a(this,ne,"f").has(e.id)||t.push(e)):e.type==="user.tool_result"?a(this,ne,"f").add(e.tool_use_id):e.type==="user.custom_tool_result"?a(this,ne,"f").add(e.custom_tool_use_id):e.type==="user.tool_confirmation"&&(a(this,ne,"f").has(e.tool_use_id)||a(this,Tt,"f").set(e.tool_use_id,e.result))},xc=async function(e){switch(a(this,ie,"f").noteEvent(e),e.type){case"agent.tool_use":case"agent.custom_tool_use":return a(this,Et,"f").has(e.id)||(a(this,Et,"f").add(e.id),await a(this,z,"m",ko).call(this,e)),!1;case"user.tool_confirmation":return await a(this,z,"m",Ac).call(this,e),!1;case"user.tool_result":return a(this,ne,"f").add(e.tool_use_id),!1;case"user.custom_tool_result":return a(this,ne,"f").add(e.custom_tool_use_id),!1;case"session.status_terminated":case"session.deleted":return a(this,j,"f").info("session terminated",{component:"session-tool-runner",session_id:this.sessionId}),a(this,G,"f").abort(),!0;default:return!1}},ko=async function(e){let t=e.evaluated_permission,s=t==="deny"?"deny":a(this,Tt,"f").get(e.id);if(s===void 0){t===void 0||t==="allow"?await a(this,z,"m",So).call(this,e,void 0):a(this,Le,"f").has(e.id)||(a(this,j,"f").info("tool call awaiting confirmation; holding",{component:"session-tool-runner",session_id:this.sessionId,tool:e.name,tool_use_id:e.id}),a(this,Le,"f").set(e.id,e),a(this,ie,"f").block(e.id));return}await a(this,z,"m",Dn).call(this,e,s)},Ac=async function(e){a(this,Tt,"f").set(e.tool_use_id,e.result);let t=a(this,Le,"f").get(e.tool_use_id);t!==void 0&&await a(this,z,"m",Dn).call(this,t,e.result)},Dn=async function(e,t){let s=a(this,Le,"f").delete(e.id);if(t==="allow"){a(this,j,"f").info("tool call confirmed",{component:"session-tool-runner",session_id:this.sessionId,tool:e.name,tool_use_id:e.id}),s||a(this,ie,"f").block(e.id);try{await a(this,z,"m",So).call(this,e,"allow")}finally{a(this,ie,"f").unblock(e.id)}return}s&&a(this,ie,"f").unblock(e.id),a(this,ne,"f").add(e.id),a(this,j,"f").info("tool call denied; not executing",{component:"session-tool-runner",session_id:this.sessionId,tool:e.name,tool_use_id:e.id}),a(this,z,"m",zn).call(this,{event:e,toolUseId:e.id,name:e.name,isError:!1,posted:!1,confirmation:"deny"})},zn=function(e){a(this,Mt,"f").push(e)},So=async function(e,t){var s,i;if(!a(this,ne,"f").has(e.id)){a(this,j,"f").info("executing tool",{component:"session-tool-runner",session_id:this.sessionId,tool:e.name,tool_use_id:e.id}),m(this,Ie,(s=a(this,Ie,"f"),s++,s),"f");try{let o=a(this,Bn,"f").get(e.name);if(!o){a(this,j,"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"&&a(this,ie,"f").disarm(),a(this,z,"m",zn).call(this,{event:e,toolUseId:e.id,name:e.name,isError:!1,posted:!1,confirmation:t});return}let c,f,d=new AbortController,b=Ce(a(this,G,"f").signal,d),p=setTimeout(()=>d.abort(),Du);try{let _=await yc(o,e.input,{toolUse:e,toolUseBlock:e,signal:d.signal});c=_.content,f=_.isError}finally{clearTimeout(p),b()}let g=Ju(e,f,Gu(c)),y=await a(this,z,"m",Pc).call(this,g,e.id);a(this,z,"m",zn).call(this,{event:e,result:g,toolUseId:e.id,name:e.name,isError:f,posted:y,confirmation:t})}finally{m(this,Ie,(i=a(this,Ie,"f"),i--,i),"f"),a(this,Ie,"f")===0&&a(this,ys,"f")?.call(this)}}},Pc=async function(e,t){let s=a(this,G,"f"),i=Date.now(),o,c=0;for(;;){c++,s.signal.throwIfAborted();try{return await this.client.beta.sessions.events.send(this.sessionId,{events:[e]},a(this,z,"m",Wn).call(this)),a(this,ne,"f").add(t),!0}catch(f){if(o=f,Xe(f))break;let d=a(this,Hn,"f")-(Date.now()-i);if(d<=0)break;let b=Math.min(Rn(Pn(c-1,qu,Uu)),d);a(this,j,"f").warn("tool result send failed; retrying",{tool_use_id:t,attempt:c,backoff_ms:b,error:String(f)}),await he(b,s.signal)}}return a(this,j,"f").error("failed to send tool result",{tool_use_id:t,attempts:c,error:String(o)}),!1},Rc=async function(){a(this,Ie,"f")!==0&&(await Promise.race([new Promise(e=>m(this,ys,e,"f")),he(zu)]),m(this,ys,null,"f"),a(this,Ie,"f")>0&&a(this,j,"f").warn("drain timeout exceeded"))},r})();function Ju(r,n,e){return r.type==="agent.custom_tool_use"?{type:"user.custom_tool_result",custom_tool_use_id:r.id,is_error:n,content:e}:{type:"user.tool_result",tool_use_id:r.id,is_error:n,content:e}}function Gu(r){if(typeof r=="string")return[{type:"text",text:r||"(no output)"}];let n=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 n.length>0?n:[{type:"text",text:"(no output)"}]}vo();var Un,Ss,Io,vs,Ot,$c=3e4,cd=9e4,ld="NO_HEARTBEAT";function ud(r){return r.resources.some(n=>n.type==="memory_store")}function dd(r){if(!r)return null;let n;try{let t=r.replace(/-/g,"+").replace(/_/g,"/"),s=t.padEnd(Math.ceil(t.length/4)*4,"=");n=JSON.parse(Qr(Ea(s)))}catch{return null}if(n===null||typeof n!="object"||Array.isArray(n))return null;let e=n.sessions_token;return typeof e=="string"&&e!==""?e:null}var Eo=(()=>{class r{constructor(e){if(Un.add(this),Ss.set(this,void 0),e.unrestrictedPaths!==void 0)throw new k("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&&Mc(e.memorySyncIntervalMs,"memorySyncIntervalMs"),this.memorySyncIntervalMs=e.memorySyncIntervalMs,this.memorySyncDeletions=e.memorySyncDeletions??"enabled",this.workerId=e.workerId,this.requestOptions=e.requestOptions,m(this,Ss,e.signal,"f")}async run(e){let{environmentId:t,environmentKey:s}=this;if(t===void 0||s===void 0)throw new k("EnvironmentWorker.run: environmentId and environmentKey are required to poll for work");let i=e??a(this,Ss,"f"),o=new _s({client:this.client,environmentId:t,environmentKey:s,...this.workerId!==void 0?{workerId:this.workerId}:{},...i?{signal:i}:{},...this.requestOptions!==void 0?{requestOptions:this.requestOptions}:{},autoStop:!1});for await(let c of o)try{await a(this,Un,"m",Io).call(this,c,s,o.signal)}catch(f){if(o.signal?.aborted)throw f;T(this.client).error("work item failed",{work_id:c.id,error:String(f)})}}async handleItem(e){let t=e?.workId??I("ANTHROPIC_WORK_ID"),s=e?.environmentId??I("ANTHROPIC_ENVIRONMENT_ID"),i=e?.sessionId??I("ANTHROPIC_SESSION_ID"),o=(e?.environmentKey??this.environmentKey??I("ANTHROPIC_ENVIRONMENT_KEY"))||void 0,c=e?.workSecret||I("ANTHROPIC_WORK_SECRET")||null;if(!t)throw new k("handleItem: workId is required \u2014 pass it or set ANTHROPIC_WORK_ID");if(!s)throw new k("handleItem: environmentId is required \u2014 pass it or set ANTHROPIC_ENVIRONMENT_ID");if(!i)throw new k("handleItem: sessionId is required \u2014 pass it or set ANTHROPIC_SESSION_ID");if(!o&&!c)throw new k("handleItem: environmentKey is required when there is no work secret \u2014 pass it, construct the worker with it, or set ANTHROPIC_ENVIRONMENT_KEY");let f={id:t,environment_id:s,secret:c,data:{type:"session",id:i}};await a(this,Un,"m",Io).call(this,f,o,e?.signal??a(this,Ss,"f"))}}return Ss=new WeakMap,Un=new WeakSet,Io=async function(e,t,s){let i=T(this.client),o=dd(e.secret),c=o??t;if(c===void 0)throw new k("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&&o===null&&i.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 f=In(this.client,{authToken:c,helper:"environments-worker"}),d=e.data.id,b=new AbortController,p=Ce(s,b),g=new fd(b),y=await Promise.resolve().then(()=>(Cc(),Oc)),_,v,A=md(f,e,g,i,this.requestOptions,x=>{_=x,v?._setSendRetryWindow(x)}).catch(x=>{b.signal.aborted||i.error("heartbeat loop failed",{work_id:e.id,error:String(x)}),b.abort()}),R=async()=>{},S,E=!1;try{if(e.data.type!=="session"){i.debug("skipping non-session work item",{work_id:e.id,type:e.data.type});return}let x=await f.beta.sessions.retrieve(d);if(o===null&&this.memorySyncIntervalMs!==null&&ud(x))throw new y.SessionMemoryError(`cannot mount the session's memories: the work item carried no sessions token (work_id=${e.id}, session_id=${d}); 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 P={workdir:this.workdir,client:f,session:x,...this.maxFileBytes!==void 0?{maxFileBytes:this.maxFileBytes}:{}};try{R=await y.setupSkills(P)}catch(M){i.warn("skill setup failed",{session_id:d,work_id:e.id,error:String(M)})}o!==null&&this.memorySyncIntervalMs!==null?(S=new y.SessionMemoryStores(f,{workdir:this.workdir,...this.memorySyncIntervalMs!==void 0?{syncIntervalMs:this.memorySyncIntervalMs}:{},syncDeletions:this.memorySyncDeletions}),await S.download(x),P.allowedRoots=S.roots,P.readOnlyRoots=S.readOnlyRoots):i.debug("memory stores disabled for this item",{work_id:e.id});let L=typeof this.tools=="function"?this.tools(P):this.tools??y.betaAgentToolset20260401(P);v=new ks(d,{client:f,tools:L,...this.maxIdleMs!==void 0?{maxIdleMs:this.maxIdleMs}:{},...this.requestOptions!==void 0?{requestOptions:this.requestOptions}:{},signal:b.signal}),_!==void 0&&v._setSendRetryWindow(_);for await(let M of v)S&&await S.syncIfDue();E=!b.signal.aborted}finally{try{await R().catch(x=>{i.warn("skill cleanup failed",{session_id:d,work_id:e.id,error:String(x)})})}finally{if(S){let x=y.MEMORY_FLUSH_TIMEOUT_MS;E&&await Nc(S.finish(),x)&&i.warn(`final memory sync cut off after ${x}ms; the flush that follows still uploads changed files`,{session_id:d,work_id:e.id});let P=new AbortController;await Nc(S.flushWrites(P.signal),x)&&(P.abort(),i.warn(`memory flush cut off after ${x}ms; changed files it had not uploaded yet are not saved`,{session_id:d,work_id:e.id})),await S.dispose().catch(M=>{i.warn("memory store cleanup failed",{session_id:d,work_id:e.id,error:String(M)})})}}g.finish("runner_done"),p(),await A,g.lost?i.info("lease lost; released without stopping it",{session_id:d,work_id:e.id}):await hd(f,e,i,this.requestOptions)}},r})();async function Nc(r,n){let e;try{return await Promise.race([r.then(()=>!1,()=>!1),new Promise(t=>{e=setTimeout(()=>t(!0),n)})])}finally{e!==void 0&&clearTimeout(e)}}async function hd(r,n,e,t){try{await r.beta.environments.work.stop(n.id,{environment_id:n.environment_id,force:!0},{...t,headers:u([t?.headers])})}catch(s){$e(s,409)||e.error("force-stop on exit failed",{work_id:n.id,error:String(s)})}}var fd=(()=>{class r{constructor(e){vs.set(this,void 0),Ot.set(this,void 0),m(this,vs,e,"f")}get signal(){return a(this,vs,"f").signal}finish(e){m(this,Ot,a(this,Ot,"f")??e,"f"),a(this,vs,"f").abort()}get lost(){return a(this,Ot,"f")==="lease_lost"||a(this,Ot,"f")==="assumed_lost"}}return vs=new WeakMap,Ot=new WeakMap,r})();function pd(r){let n=r instanceof D?r.error:void 0;for(let e of["error","details","current_state"]){if(!Fi(n))return{};n=n[e]}return Fi(n)?n:{}}async function md(r,n,e,t,s,i){let o=$c,c=cd,f=Date.now(),d=ld,b=async()=>{let p=new AbortController,g=Ce(e.signal,p),y=setTimeout(()=>p.abort(),o);try{let _=await r.beta.environments.work.heartbeat(n.id,{environment_id:n.environment_id,expected_last_heartbeat:d},{...s,headers:u([s?.headers]),signal:p.signal});f=Date.now(),d=_.last_heartbeat,_.ttl_seconds>0&&(c=_.ttl_seconds*1e3,o=Math.max(1e3,Math.min(c/2,$c)),i?.(c)),(_.state==="stopping"||_.state==="stopped")&&(t.info("heartbeat signals shutdown",{work_id:n.id,state:_.state}),e.finish("control_plane_stop")),_.lease_extended||(t.warn("lease not extended, shutting down",{work_id:n.id}),e.finish("control_plane_stop"))}catch(_){if(e.signal.throwIfAborted(),$e(_,412)){let v=pd(_);t.error("lease lost: heartbeat precondition failed",{work_id:n.id,server_state:v.state,server_ttl_seconds:v.ttl_seconds,server_last_heartbeat:v.last_heartbeat}),e.finish("lease_lost");return}if(Xe(_))throw t.error("permanent heartbeat failure",{work_id:n.id,error:String(_)}),e.finish("heartbeat_rejected"),_;if(Date.now()-f>c){t.error("lease assumed lost: no successful heartbeat in ttl",{work_id:n.id,ttl_ms:c,error:String(_)}),e.finish("assumed_lost");return}t.warn("transient heartbeat failure",{work_id:n.id,error:String(_)})}finally{clearTimeout(y),g()}};for(await b();!e.signal.aborted;)await he(o,e.signal),e.signal.throwIfAborted(),await b()}var jn=(()=>{class r extends h{retrieve(e,t,s){let{environment_id:i,betas:o,workspace_id:c}=t;return this._client.get(l`/v1/environments/${i}/work/${e}?beta=true`,{...s,headers:u([{"anthropic-beta":[...o??[],"managed-agents-2026-04-01"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers])})}update(e,t,s){let{environment_id:i,betas:o,workspace_id:c,...f}=t;return this._client.post(l`/v1/environments/${i}/work/${e}?beta=true`,{body:f,...s,headers:u([{"anthropic-beta":[...o??[],"managed-agents-2026-04-01"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers])})}list(e,t={},s){let{betas:i,...o}=t??{};return this._client.getAPIList(l`/v1/environments/${e}/work?beta=true`,w,{query:o,...s,headers:u([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString()},s?.headers])})}ack(e,t,s){let{environment_id:i,betas:o}=t;return this._client.post(l`/v1/environments/${i}/work/${e}/ack?beta=true`,{...s,headers:u([{"anthropic-beta":[...o??[],"managed-agents-2026-04-01"].toString()},s?.headers])})}heartbeat(e,t,s){let{environment_id:i,desired_ttl_seconds:o,expected_last_heartbeat:c,betas:f}=t;return this._client.post(l`/v1/environments/${i}/work/${e}/heartbeat?beta=true`,{query:{desired_ttl_seconds:o,expected_last_heartbeat:c},...s,headers:u([{"anthropic-beta":[...f??[],"managed-agents-2026-04-01"].toString()},s?.headers])})}poll(e,t={},s){let{betas:i,"Anthropic-Worker-ID":o,...c}=t??{};return this._client.get(l`/v1/environments/${e}/work/poll?beta=true`,{query:c,...s,headers:u([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...o!=null?{"Anthropic-Worker-ID":o}:void 0},s?.headers])})}stats(e,t={},s){let{betas:i,workspace_id:o}=t??{};return this._client.get(l`/v1/environments/${e}/work/stats?beta=true`,{...s,headers:u([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},s?.headers])})}stop(e,t,s){let{environment_id:i,betas:o,workspace_id:c,...f}=t;return this._client.post(l`/v1/environments/${i}/work/${e}/stop?beta=true`,{body:f,...s,headers:u([{"anthropic-beta":[...o??[],"managed-agents-2026-04-01"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers])})}poller(e){return new _s({...e,client:this._client})}worker(e){return new Eo({...e,client:this._client})}}return r.WorkPoller=_s,r.EnvironmentWorker=Eo,r})();var Kn=(()=>{class r extends h{constructor(){super(...arguments),this.work=new jn(this._client)}create(e,t){let{betas:s,workspace_id:i,...o}=e;return this._client.post("/v1/environments?beta=true",{body:o,...t,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}retrieve(e,t={},s){let{betas:i,workspace_id:o}=t??{};return this._client.get(l`/v1/environments/${e}?beta=true`,{...s,headers:u([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},s?.headers])})}update(e,t,s){let{betas:i,workspace_id:o,...c}=t;return this._client.post(l`/v1/environments/${e}?beta=true`,{body:c,...s,headers:u([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},s?.headers])})}list(e={},t){let{betas:s,workspace_id:i,...o}=e??{};return this._client.getAPIList("/v1/environments?beta=true",w,{query:o,...t,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}delete(e,t={},s){let{betas:i,workspace_id:o}=t??{};return this._client.delete(l`/v1/environments/${e}?beta=true`,{...s,headers:u([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},s?.headers])})}archive(e,t={},s){let{betas:i,workspace_id:o}=t??{};return this._client.post(l`/v1/environments/${e}/archive?beta=true`,{...s,headers:u([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},s?.headers])})}}return r.Work=jn,r})();var Ct=class extends h{create(n,e,t){let{view:s,betas:i,workspace_id:o,...c}=e;return this._client.post(l`/v1/memory_stores/${n}/memories?beta=true`,{query:{view:s},body:c,...t,headers:u([{"anthropic-beta":[...i??[],"agent-memory-2026-07-22"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},t?.headers])})}retrieve(n,e,t){let{memory_store_id:s,betas:i,workspace_id:o,...c}=e;return this._client.get(l`/v1/memory_stores/${s}/memories/${n}?beta=true`,{query:c,...t,headers:u([{"anthropic-beta":[...i??[],"agent-memory-2026-07-22"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},t?.headers])})}update(n,e,t){let{memory_store_id:s,view:i,betas:o,workspace_id:c,...f}=e;return this._client.post(l`/v1/memory_stores/${s}/memories/${n}?beta=true`,{query:{view:i},body:f,...t,headers:u([{"anthropic-beta":[...o??[],"agent-memory-2026-07-22"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},t?.headers])})}list(n,e={},t){let{betas:s,workspace_id:i,...o}=e??{};return this._client.getAPIList(l`/v1/memory_stores/${n}/memories?beta=true`,w,{query:o,...t,headers:u([{"anthropic-beta":[...s??[],"agent-memory-2026-07-22"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}delete(n,e,t){let{memory_store_id:s,expected_content_sha256:i,betas:o,workspace_id:c}=e;return this._client.delete(l`/v1/memory_stores/${s}/memories/${n}?beta=true`,{query:{expected_content_sha256:i},...t,headers:u([{"anthropic-beta":[...o??[],"agent-memory-2026-07-22"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},t?.headers])})}};var $t=class extends h{retrieve(n,e,t){let{memory_store_id:s,betas:i,workspace_id:o,...c}=e;return this._client.get(l`/v1/memory_stores/${s}/memory_versions/${n}?beta=true`,{query:c,...t,headers:u([{"anthropic-beta":[...i??[],"agent-memory-2026-07-22"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},t?.headers])})}list(n,e={},t){let{betas:s,workspace_id:i,...o}=e??{};return this._client.getAPIList(l`/v1/memory_stores/${n}/memory_versions?beta=true`,w,{query:o,...t,headers:u([{"anthropic-beta":[...s??[],"agent-memory-2026-07-22"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}redact(n,e,t){let{memory_store_id:s,betas:i,workspace_id:o}=e;return this._client.post(l`/v1/memory_stores/${s}/memory_versions/${n}/redact?beta=true`,{...t,headers:u([{"anthropic-beta":[...i??[],"agent-memory-2026-07-22"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},t?.headers])})}};var Vn=(()=>{class r extends h{constructor(){super(...arguments),this.memories=new Ct(this._client),this.memoryVersions=new $t(this._client)}create(e,t){let{betas:s,workspace_id:i,...o}=e;return this._client.post("/v1/memory_stores?beta=true",{body:o,...t,headers:u([{"anthropic-beta":[...s??[],"agent-memory-2026-07-22"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}retrieve(e,t={},s){let{betas:i,workspace_id:o}=t??{};return this._client.get(l`/v1/memory_stores/${e}?beta=true`,{...s,headers:u([{"anthropic-beta":[...i??[],"agent-memory-2026-07-22"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},s?.headers])})}update(e,t,s){let{betas:i,workspace_id:o,...c}=t;return this._client.post(l`/v1/memory_stores/${e}?beta=true`,{body:c,...s,headers:u([{"anthropic-beta":[...i??[],"agent-memory-2026-07-22"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},s?.headers])})}list(e={},t){let{betas:s,workspace_id:i,...o}=e??{};return this._client.getAPIList("/v1/memory_stores?beta=true",w,{query:o,...t,headers:u([{"anthropic-beta":[...s??[],"agent-memory-2026-07-22"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}delete(e,t={},s){let{betas:i,workspace_id:o}=t??{};return this._client.delete(l`/v1/memory_stores/${e}?beta=true`,{...s,headers:u([{"anthropic-beta":[...i??[],"agent-memory-2026-07-22"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},s?.headers])})}archive(e,t={},s){let{betas:i,workspace_id:o}=t??{};return this._client.post(l`/v1/memory_stores/${e}/archive?beta=true`,{...s,headers:u([{"anthropic-beta":[...i??[],"agent-memory-2026-07-22"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},s?.headers])})}}return r.Memories=Ct,r.MemoryVersions=$t,r})();var Nt=class extends h{create(n,e){let{betas:t,user_profile_id:s,workspace_id:i,...o}=n;return this._client.post("/v1/messages/batches?beta=true",{body:o,...e,headers:u([{"anthropic-beta":[...t??[],"message-batches-2024-09-24"].toString(),...s!=null?{"anthropic-user-profile-id":s}:void 0,...i!=null?{"anthropic-workspace-id":i}:void 0},e?.headers])})}retrieve(n,e={},t){let{betas:s,workspace_id:i}=e??{};return this._client.get(l`/v1/messages/batches/${n}?beta=true`,{...t,headers:u([{"anthropic-beta":[...s??[],"message-batches-2024-09-24"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}list(n={},e){let{betas:t,workspace_id:s,...i}=n??{};return this._client.getAPIList("/v1/messages/batches?beta=true",C,{query:i,...e,headers:u([{"anthropic-beta":[...t??[],"message-batches-2024-09-24"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},e?.headers])})}delete(n,e={},t){let{betas:s,workspace_id:i}=e??{};return this._client.delete(l`/v1/messages/batches/${n}?beta=true`,{...t,headers:u([{"anthropic-beta":[...s??[],"message-batches-2024-09-24"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}cancel(n,e={},t){let{betas:s,workspace_id:i}=e??{};return this._client.post(l`/v1/messages/batches/${n}/cancel?beta=true`,{...t,headers:u([{"anthropic-beta":[...s??[],"message-batches-2024-09-24"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}async results(n,e={},t){let s=await this.retrieve(n,e,t);if(!s.results_url)throw new k(`No batch \`results_url\`; Has it finished processing? ${s.processing_status} - ${s.id}`);let{betas:i,workspace_id:o}=e??{};return this._client.get(s.results_url,{...t,headers:u([{"anthropic-beta":[...i??[],"message-batches-2024-09-24"].toString(),Accept:"application/binary",...o!=null?{"anthropic-workspace-id":o}:void 0},t?.headers]),stream:!0,__binaryResponse:!0})._thenUnwrap((c,f)=>kn.fromResponse(f.response,f.controller))}};B();function Lc(r){return r?.output_format??r?.output_config?.format}function To(r,n,e){let t=Lc(n);return!n||!("parse"in(t??{}))?{...r,content:r.content.map(s=>{if(s.type==="text"){let i=Object.defineProperty({...s},"parsed_output",{value:null,enumerable:!1});return Object.defineProperty(i,"parsed",{get(){return e.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead."),null},enumerable:!1})}return s}),parsed_output:null}:Mo(r,n,e)}function Mo(r,n,e){let t=null,s=r.content.map(i=>{if(i.type==="text"){let o=Sd(n,i.text);t===null&&(t=o);let c=Object.defineProperty({...i},"parsed_output",{value:o,enumerable:!1});return Object.defineProperty(c,"parsed",{get(){return e.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead."),o},enumerable:!1})}return i});return{...r,content:s,parsed_output:t}}function Sd(r,n){let e=Lc(r);if(e?.type!=="json_schema")return null;try{return"parse"in e?e.parse(n):JSON.parse(n)}catch(t){throw new k(`Failed to parse structured output: ${t}`)}}Ue();var Z,Fe,Lt,xs,Jn,As,Ps,Gn,Rs,Se,Is,Yn,Xn,Ze,Qn,Zn,ei,Es,Oo,Fc,Ts,Co,$o,No,Bc,Lo;function Fo(r){return r.type==="tool_use"||r.type==="server_tool_use"||r.type==="mcp_tool_use"}var ti=(()=>{class r{constructor(e,t){Z.add(this),this.messages=[],this.receivedMessages=[],Fe.set(this,void 0),Lt.set(this,null),this.controller=new AbortController,xs.set(this,void 0),Jn.set(this,()=>{}),As.set(this,()=>{}),Ps.set(this,void 0),Gn.set(this,()=>{}),Rs.set(this,()=>{}),Se.set(this,{}),Is.set(this,!1),Yn.set(this,!1),Xn.set(this,!1),Ze.set(this,!1),Qn.set(this,void 0),Zn.set(this,void 0),ei.set(this,void 0),Es.set(this,void 0),Ts.set(this,s=>{if(m(this,Yn,!0,"f"),de(s)&&(s=new V),s instanceof V)return m(this,Xn,!0,"f"),this._emit("abort",s);if(s instanceof k)return this._emit("error",s);if(s instanceof Error){let i=new k(s.message);return i.cause=s,this._emit("error",i)}return this._emit("error",new k(String(s)))}),m(this,xs,new Promise((s,i)=>{m(this,Jn,s,"f"),m(this,As,i,"f")}),"f"),m(this,Ps,new Promise((s,i)=>{m(this,Gn,s,"f"),m(this,Rs,i,"f")}),"f"),a(this,xs,"f").catch(()=>{}),a(this,Ps,"f").catch(()=>{}),m(this,Lt,e,"f"),m(this,Es,t?.logger??console,"f")}get response(){return a(this,Qn,"f")}get request_id(){return a(this,Zn,"f")}get workspace_id(){return a(this,ei,"f")}async withResponse(){m(this,Ze,!0,"f");let e=await a(this,xs,"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,s,{logger:i}={}){let o=new r(t,{logger:i});for(let c of t.messages)o._addMessageParam(c);return m(o,Lt,{...t,stream:!0},"f"),o._run(()=>o._createMessage(e,{...t,stream:!0},{...s,headers:{...s?.headers,[lt]:"stream"}})),o}_run(e){e().then(()=>{this._emitFinal(),this._emit("end")},a(this,Ts,"f"))}_addMessageParam(e){this.messages.push(e)}_addMessage(e,t=!0){this.receivedMessages.push(e),t&&this._emit("message",e)}async _createMessage(e,t,s){let i=s?.signal,o;i&&(i.aborted&&this.controller.abort(),o=this.controller.abort.bind(this.controller),i.addEventListener("abort",o));try{a(this,Z,"m",Co).call(this);let{response:c,data:f}=await e.create({...t,stream:!0},{...s,signal:this.controller.signal}).withResponse();this._connected(c);for await(let d of f)a(this,Z,"m",$o).call(this,d);if(f.controller.signal?.aborted)throw new V;a(this,Z,"m",No).call(this)}finally{i&&o&&i.removeEventListener("abort",o)}}_connected(e){this.ended||(m(this,Qn,e,"f"),m(this,Zn,e?.headers.get("request-id"),"f"),m(this,ei,e?.headers.get("anthropic-workspace-id"),"f"),a(this,Jn,"f").call(this,e),this._emit("connect"))}get ended(){return a(this,Is,"f")}get errored(){return a(this,Yn,"f")}get aborted(){return a(this,Xn,"f")}abort(){this.controller.abort()}on(e,t){return(a(this,Se,"f")[e]||(a(this,Se,"f")[e]=[])).push({listener:t}),this}off(e,t){let s=a(this,Se,"f")[e];if(!s)return this;let i=s.findIndex(o=>o.listener===t);return i>=0&&s.splice(i,1),this}once(e,t){return(a(this,Se,"f")[e]||(a(this,Se,"f")[e]=[])).push({listener:t,once:!0}),this}emitted(e){return new Promise((t,s)=>{m(this,Ze,!0,"f"),e!=="error"&&this.once("error",s),this.once(e,t)})}async done(){m(this,Ze,!0,"f"),await a(this,Ps,"f")}get currentMessage(){return a(this,Fe,"f")}async finalMessage(){return await this.done(),a(this,Z,"m",Oo).call(this)}async finalText(){return await this.done(),a(this,Z,"m",Fc).call(this)}_emit(e,...t){if(a(this,Is,"f"))return;e==="end"&&(m(this,Is,!0,"f"),a(this,Gn,"f").call(this));let s=a(this,Se,"f")[e];if(s&&(a(this,Se,"f")[e]=s.filter(i=>!i.once),s.forEach(({listener:i})=>i(...t))),e==="abort"){let i=t[0];!a(this,Ze,"f")&&!s?.length&&Promise.reject(i),a(this,As,"f").call(this,i),a(this,Rs,"f").call(this,i),this._emit("end");return}if(e==="error"){let i=t[0];!a(this,Ze,"f")&&!s?.length&&Promise.reject(i),a(this,As,"f").call(this,i),a(this,Rs,"f").call(this,i),this._emit("end")}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit("finalMessage",a(this,Z,"m",Oo).call(this))}async _fromReadableStream(e,t){let s=t?.signal,i;s&&(s.aborted&&this.controller.abort(),i=this.controller.abort.bind(this.controller),s.addEventListener("abort",i));try{a(this,Z,"m",Co).call(this),this._connected(null);let o=ye.fromReadableStream(e,this.controller);for await(let c of o)a(this,Z,"m",$o).call(this,c);if(o.controller.signal?.aborted)throw new V;a(this,Z,"m",No).call(this)}finally{s&&i&&s.removeEventListener("abort",i)}}[(Fe=new WeakMap,Lt=new WeakMap,xs=new WeakMap,Jn=new WeakMap,As=new WeakMap,Ps=new WeakMap,Gn=new WeakMap,Rs=new WeakMap,Se=new WeakMap,Is=new WeakMap,Yn=new WeakMap,Xn=new WeakMap,Ze=new WeakMap,Qn=new WeakMap,Zn=new WeakMap,ei=new WeakMap,Es=new WeakMap,Ts=new WeakMap,Z=new WeakSet,Oo=function(){if(this.receivedMessages.length===0)throw new k("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},Fc=function(){if(this.receivedMessages.length===0)throw new k("stream ended without producing a Message with role=assistant");let t=this.receivedMessages.at(-1).content.filter(s=>s.type==="text").map(s=>s.text);if(t.length===0)throw new k("stream ended without producing a content block with type=text");return t.join(" ")},Co=function(){this.ended||m(this,Fe,void 0,"f")},$o=function(t){if(this.ended)return;let s=a(this,Z,"m",Bc).call(this,t);switch(this._emit("streamEvent",t,s),t.type){case"content_block_delta":{let i=s.content.at(-1);switch(t.delta.type){case"text_delta":{i.type==="text"&&this._emit("text",t.delta.text,i.text||"");break}case"citations_delta":{i.type==="text"&&this._emit("citation",t.delta.citation,i.citations??[]);break}case"input_json_delta":{if(Fo(i)&&a(this,Se,"f").inputJson?.length){let o;try{o=i.input}catch(c){a(this,Ts,"f").call(this,a(this,Z,"m",Lo).call(this,i,c));break}this._emit("inputJson",t.delta.partial_json,o)}break}case"thinking_delta":{i.type==="thinking"&&this._emit("thinking",t.delta.thinking,i.thinking);break}case"signature_delta":{i.type==="thinking"&&this._emit("signature",i.signature);break}case"compaction_delta":{i.type==="compaction"&&i.content&&this._emit("compaction",i.content);break}default:t.delta}break}case"message_stop":{this._addMessageParam(s),this._addMessage(To(s,a(this,Lt,"f"),{logger:a(this,Es,"f")}),!0);break}case"content_block_stop":{this._emit("contentBlock",s.content.at(-1));break}case"message_start":{m(this,Fe,s,"f");break}case"content_block_start":case"message_delta":break}},No=function(){if(this.ended)throw new k("stream has ended, this shouldn't happen");let t=a(this,Fe,"f");if(!t)throw new k("request ended without sending any chunks");return m(this,Fe,void 0,"f"),To(t,a(this,Lt,"f"),{logger:a(this,Es,"f")})},Bc=function(t){let s=a(this,Fe,"f");if(t.type==="message_start"){if(s)throw new k(`Unexpected event order, got ${t.type} before receiving "message_stop"`);return t.message}if(!s)throw new k(`Unexpected event order, got ${t.type} before "message_start"`);switch(t.type){case"message_stop":return s;case"message_delta":return s.stop_reason=t.delta.stop_reason,s.stop_sequence=t.delta.stop_sequence,s.stop_details=t.delta.stop_details,s.usage.output_tokens=t.usage.output_tokens,t.delta.container!=null&&(s.container=t.delta.container),t.context_management!=null&&(s.context_management=t.context_management),t.input_transformations!=null&&(s.input_transformations=t.input_transformations),t.usage.input_tokens!=null&&(s.usage.input_tokens=t.usage.input_tokens),t.usage.cache_creation_input_tokens!=null&&(s.usage.cache_creation_input_tokens=t.usage.cache_creation_input_tokens),t.usage.cache_read_input_tokens!=null&&(s.usage.cache_read_input_tokens=t.usage.cache_read_input_tokens),t.usage.server_tool_use!=null&&(s.usage.server_tool_use=t.usage.server_tool_use),t.usage.iterations!=null&&(s.usage.iterations=t.usage.iterations),t.usage.fallback_credit!=null&&(s.usage.fallback_credit=t.usage.fallback_credit),t.usage.output_tokens_details!=null&&(s.usage.output_tokens_details=t.usage.output_tokens_details),s;case"content_block_start":return s.content.push(t.content_block),t.content_block.type==="fallback"&&(s.model=t.content_block.to.model),s;case"content_block_delta":{let i=s.content.at(t.index);switch(t.delta.type){case"text_delta":{i?.type==="text"&&(s.content[t.index]={...i,text:(i.text||"")+t.delta.text});break}case"citations_delta":{i?.type==="text"&&(s.content[t.index]={...i,citations:[...i.citations??[],t.delta.citation]});break}case"input_json_delta":{if(i&&Fo(i)){let o=(i[Te]||"")+t.delta.partial_json;s.content[t.index]=hn(i,o)}break}case"thinking_delta":{i?.type==="thinking"&&(s.content[t.index]={...i,thinking:i.thinking+t.delta.thinking});break}case"signature_delta":{i?.type==="thinking"&&(s.content[t.index]={...i,signature:t.delta.signature});break}case"compaction_delta":{if(i?.type==="compaction"){let o={...i,content:t.delta.content};"encrypted_content"in t.delta&&(o.encrypted_content=t.delta.encrypted_content),s.content[t.index]=o}break}default:t.delta}return s}case"content_block_stop":{let i=s.content.at(t.index);if(i&&Fo(i)&&Te in i){let o;try{o=i.input}catch(c){o={},a(this,Ts,"f").call(this,a(this,Z,"m",Lo).call(this,i,c))}Object.defineProperty(i,"input",{value:o,enumerable:!0,configurable:!0,writable:!0})}return s}}},Lo=function(t,s){let i=t[Te];return new k(`Unable to parse tool parameter JSON from model. Please retry your request or adjust your prompt. Error: ${s}. JSON: ${i}`)},Symbol.asyncIterator)](){let e=[],t=[],s=!1;return this.on("streamEvent",i=>{let o=t.shift();o?o.resolve(i):e.push(i)}),this.on("end",()=>{s=!0;for(let i of t)i.resolve(void 0);t.length=0}),this.on("abort",i=>{s=!0;for(let o of t)o.reject(i);t.length=0}),this.on("error",i=>{s=!0;for(let o of t)o.reject(i);t.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:s?{value:void 0,done:!0}:new Promise((o,c)=>t.push({resolve:o,reject:c})).then(o=>o?{value:o,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new ye(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}return r})();var Hc={browser_toolset_20260801:"browser",computer_toolset_20260801:"computer"};function Be(r){return Hc[r.type]}function Ft(r){return"run"in r&&r.type!=null&&Object.prototype.hasOwnProperty.call(Hc,r.type)}B();B();var Ms=class extends k{constructor(n,e){super(n),this.name="ToolsetUsageError",e&&"cause"in e&&(this.cause=e.cause)}};var He=class extends Ms{constructor(n,e){super(n,e),this.name="ToolsetContractError"}};var Dc="Not executed: an earlier action in this turn failed.",Wc={browser:Dc,computer:"Not executed: an earlier computer action in this turn failed."};function zc(r){return Object.prototype.hasOwnProperty.call(Wc,r)?Wc[r]:Dc}function Os(r,n,e=!1){return e&&(n===""||Array.isArray(n)&&n.length===0)&&(n="The tool call failed with an empty error message."),{type:"tool_result",tool_use_id:r.id,toolset_name:r.toolset_name??null,content:n,...e?{is_error:!0}:{}}}function vd(r,n){if(r instanceof Ms)throw r;xd(n.signal)}function xd(r){if(r?.aborted)throw new V}async function qc(r,n,e={}){let t=Be(r);if(n.toolset_name!==t)throw new He(`tool_use ${JSON.stringify(n.id)} (toolset_name=${JSON.stringify(n.toolset_name??null)}, name=${JSON.stringify(n.name)}) is not a member call of the ${JSON.stringify(t)} toolset`);let s={...e,toolUse:n,toolUseBlock:n};try{return Os(n,await r.run(s,n))}catch(i){return vd(i,s),Os(n,bc(i instanceof Rt?i.content:gc(i)),!0)}}B();var Ht=class extends h{retrieve(n,e){return this._client.get(l`/v1/organizations/api_keys/${n}?beta=true`,e)}update(n,e,t){return this._client.post(l`/v1/organizations/api_keys/${n}?beta=true`,{body:e,...t})}list(n={},e){return this._client.getAPIList("/v1/organizations/api_keys?beta=true",C,{query:n,...e})}};var Wt=class extends h{list(n,e){return this._client.getAPIList("/v1/organizations/analytics/artifacts?beta=true",w,{query:n,...e})}};var Dt=class extends h{list(n={},e){return this._client.getAPIList("/v1/organizations/analytics/connectors?beta=true",w,{query:n,...e})}};var zt=class extends h{list(n,e){return this._client.getAPIList("/v1/organizations/analytics/cost_report?beta=true",w,{query:n,...e})}};var qt=class extends h{list(n={},e){return this._client.getAPIList("/v1/organizations/analytics/plugins?beta=true",w,{query:n,...e})}};var Ut=class extends h{list(n={},e){return this._client.getAPIList("/v1/organizations/analytics/skills?beta=true",w,{query:n,...e})}};var jt=class extends h{list(n,e){return this._client.getAPIList("/v1/organizations/analytics/summaries?beta=true",w,{query:n,...e})}};var Kt=class extends h{list(n,e){return this._client.getAPIList("/v1/organizations/analytics/usage_report?beta=true",w,{query:n,...e})}};var Vt=class extends h{list(n,e){return this._client.getAPIList("/v1/organizations/analytics/user_cost_report?beta=true",w,{query:n,...e})}};var Jt=class extends h{list(n,e){return this._client.getAPIList("/v1/organizations/analytics/user_usage_report?beta=true",w,{query:n,...e})}};var Gt=class extends h{list(n={},e){return this._client.getAPIList("/v1/organizations/analytics/users?beta=true",w,{query:n,...e})}};var Yt=class extends h{list(n={},e){return this._client.getAPIList("/v1/organizations/analytics/apps/chat/projects?beta=true",w,{query:n,...e})}};var si=(()=>{class r extends h{constructor(){super(...arguments),this.projects=new Yt(this._client)}}return r.Projects=Yt,r})();var ni=(()=>{class r extends h{constructor(){super(...arguments),this.chat=new si(this._client)}}return r.Chat=si,r})();var ii=(()=>{class r extends h{constructor(){super(...arguments),this.summaries=new jt(this._client),this.users=new Gt(this._client),this.apps=new ni(this._client),this.connectors=new Dt(this._client),this.plugins=new qt(this._client),this.skills=new Ut(this._client),this.artifacts=new Wt(this._client),this.usageReport=new Kt(this._client),this.userUsageReport=new Jt(this._client),this.costReport=new zt(this._client),this.userCostReport=new Vt(this._client)}}return r.Summaries=jt,r.Users=Gt,r.Apps=ni,r.Connectors=Dt,r.Plugins=qt,r.Skills=Ut,r.Artifacts=Wt,r.UsageReport=Kt,r.UserUsageReport=Jt,r.CostReport=zt,r.UserCostReport=Vt,r})();var Xt=class extends h{retrieve(n){return this._client.get("/v1/organizations/compliance_settings?beta=true",n)}update(n,e){return this._client.post("/v1/organizations/compliance_settings?beta=true",{body:n,...e})}};var Qt=class extends h{create(n,e){return this._client.post("/v1/organizations/external_keys?beta=true",{body:n,...e})}retrieve(n,e){return this._client.get(l`/v1/organizations/external_keys/${n}?beta=true`,e)}update(n,e,t){return this._client.post(l`/v1/organizations/external_keys/${n}?beta=true`,{body:e,...t})}list(n={},e){return this._client.getAPIList("/v1/organizations/external_keys?beta=true",w,{query:n,...e})}delete(n,e){return this._client.delete(l`/v1/organizations/external_keys/${n}?beta=true`,e)}validate(n,e){return this._client.post(l`/v1/organizations/external_keys/${n}/validate?beta=true`,e)}};var Zt=class extends h{create(n,e){let{betas:t,...s}=n;return this._client.post("/v1/organizations/federation_issuers?beta=true",{body:s,...e,headers:u([{...t?.toString()!=null?{"anthropic-beta":t?.toString()}:void 0},e?.headers])})}retrieve(n,e={},t){let{betas:s}=e??{};return this._client.get(l`/v1/organizations/federation_issuers/${n}?beta=true`,{...t,headers:u([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},t?.headers])})}update(n,e,t){let{betas:s,...i}=e;return this._client.post(l`/v1/organizations/federation_issuers/${n}?beta=true`,{body:i,...t,headers:u([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},t?.headers])})}list(n={},e){let{betas:t,...s}=n??{};return this._client.getAPIList("/v1/organizations/federation_issuers?beta=true",w,{query:s,...e,headers:u([{...t?.toString()!=null?{"anthropic-beta":t?.toString()}:void 0},e?.headers])})}archive(n,e={},t){let{betas:s}=e??{};return this._client.post(l`/v1/organizations/federation_issuers/${n}/archive?beta=true`,{...t,headers:u([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},t?.headers])})}};var er=class extends h{list(n,e={},t){let{betas:s,...i}=e??{};return this._client.getAPIList(l`/v1/organizations/federation_rules/${n}/workspaces?beta=true`,w,{query:i,...t,headers:u([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},t?.headers])})}add(n,e,t){let{betas:s,...i}=e;return this._client.post(l`/v1/organizations/federation_rules/${n}/workspaces?beta=true`,{body:i,...t,headers:u([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},t?.headers])})}remove(n,e,t){let{federation_rule_id:s,betas:i}=e;return this._client.delete(l`/v1/organizations/federation_rules/${s}/workspaces/${n}?beta=true`,{...t,headers:u([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},t?.headers])})}};var oi=(()=>{class r extends h{constructor(){super(...arguments),this.workspaces=new er(this._client)}create(e,t){let{betas:s,...i}=e;return this._client.post("/v1/organizations/federation_rules?beta=true",{body:i,...t,headers:u([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},t?.headers])})}retrieve(e,t={},s){let{betas:i}=t??{};return this._client.get(l`/v1/organizations/federation_rules/${e}?beta=true`,{...s,headers:u([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},s?.headers])})}update(e,t,s){let{betas:i,...o}=t;return this._client.post(l`/v1/organizations/federation_rules/${e}?beta=true`,{body:o,...s,headers:u([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},s?.headers])})}list(e={},t){let{betas:s,...i}=e??{};return this._client.getAPIList("/v1/organizations/federation_rules?beta=true",w,{query:i,...t,headers:u([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},t?.headers])})}archive(e,t={},s){let{betas:i}=t??{};return this._client.post(l`/v1/organizations/federation_rules/${e}/archive?beta=true`,{...s,headers:u([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},s?.headers])})}}return r.Workspaces=er,r})();var ai=(()=>{class r extends h{constructor(){super(...arguments),this.issuers=new Zt(this._client),this.rules=new oi(this._client)}}return r.Issuers=Zt,r.Rules=oi,r})();var tr=class extends h{create(n,e){return this._client.post("/v1/organizations/invites?beta=true",{body:n,...e})}retrieve(n,e){return this._client.get(l`/v1/organizations/invites/${n}?beta=true`,e)}list(n={},e){return this._client.getAPIList("/v1/organizations/invites?beta=true",C,{query:n,...e})}delete(n,e){return this._client.delete(l`/v1/organizations/invites/${n}?beta=true`,e)}};var rr=class extends h{retrieve(n,e={},t){let{betas:s,...i}=e??{};return this._client.get(l`/v1/organizations/plugin_marketplaces/${n}?beta=true`,{query:i,...t,headers:u([{"anthropic-beta":[...s??[],"ce-plugins-2026-09-01"].toString()},t?.headers])})}update(n,e,t){let{betas:s,...i}=e;return this._client.post(l`/v1/organizations/plugin_marketplaces/${n}?beta=true`,{body:i,...t,headers:u([{"anthropic-beta":[...s??[],"ce-plugins-2026-09-01"].toString()},t?.headers])})}list(n={},e){let{betas:t,...s}=n??{};return this._client.getAPIList("/v1/organizations/plugin_marketplaces?beta=true",w,{query:s,...e,headers:u([{"anthropic-beta":[...t??[],"ce-plugins-2026-09-01"].toString()},e?.headers])})}validateArchive(n,e){let{betas:t,...s}=n;return this._client.post("/v1/organizations/plugin_marketplaces/validate_archive?beta=true",J({body:s,...e,headers:u([{"anthropic-beta":[...t??[],"ce-plugins-2026-09-01"].toString()},e?.headers])},this._client))}validateRepository(n,e){let{betas:t,...s}=n;return this._client.post("/v1/organizations/plugin_marketplaces/validate_repository?beta=true",{body:s,...e,headers:u([{"anthropic-beta":[...t??[],"ce-plugins-2026-09-01"].toString()},e?.headers])})}};var sr=class extends h{list(n={},e){return this._client.getAPIList("/v1/organizations/rate_limits?beta=true",w,{query:n,...e})}};var nr=class extends h{retrieve(n,e){return this._client.get(l`/v1/organizations/users/${n}?beta=true`,e)}update(n,e,t){return this._client.post(l`/v1/organizations/users/${n}?beta=true`,{body:e,...t})}list(n={},e){return this._client.getAPIList("/v1/organizations/users?beta=true",C,{query:n,...e})}remove(n,e){return this._client.delete(l`/v1/organizations/users/${n}?beta=true`,e)}};var ir=class extends h{list(n,e={},t){let{betas:s,...i}=e??{};return this._client.getAPIList(l`/v1/organizations/plugins/${n}/installation_settings?beta=true`,w,{query:i,...t,headers:u([{"anthropic-beta":[...s??[],"ce-plugins-2026-09-01"].toString()},t?.headers])})}remove(n,e,t){let{plugin_id:s,betas:i}=e;return this._client.delete(l`/v1/organizations/plugins/${s}/installation_settings/${n}?beta=true`,{...t,headers:u([{"anthropic-beta":[...i??[],"ce-plugins-2026-09-01"].toString()},t?.headers])})}set(n,e,t){let{plugin_id:s,betas:i,...o}=e;return this._client.post(l`/v1/organizations/plugins/${s}/installation_settings/${n}?beta=true`,{body:o,...t,headers:u([{"anthropic-beta":[...i??[],"ce-plugins-2026-09-01"].toString()},t?.headers])})}};var or=class extends h{list(n,e={},t){let{betas:s,...i}=e??{};return this._client.getAPIList(l`/v1/organizations/plugins/${n}/shares?beta=true`,w,{query:i,...t,headers:u([{"anthropic-beta":[...s??[],"ce-plugins-2026-09-01"].toString()},t?.headers])})}};var ar=class extends h{create(n,e,t){let{betas:s,...i}=e;return this._client.post(l`/v1/organizations/plugins/${n}/versions?beta=true`,J({body:i,...t,headers:u([{"anthropic-beta":[...s??[],"ce-plugins-2026-09-01"].toString()},t?.headers])},this._client))}retrieve(n,e,t){let{plugin_id:s,betas:i,...o}=e;return this._client.get(l`/v1/organizations/plugins/${s}/versions/${n}?beta=true`,{query:o,...t,headers:u([{"anthropic-beta":[...i??[],"ce-plugins-2026-09-01"].toString()},t?.headers])})}list(n,e={},t){let{betas:s,...i}=e??{};return this._client.getAPIList(l`/v1/organizations/plugins/${n}/versions?beta=true`,w,{query:i,...t,headers:u([{"anthropic-beta":[...s??[],"ce-plugins-2026-09-01"].toString()},t?.headers])})}download(n,e,t){let{plugin_id:s,betas:i,...o}=e;return this._client.get(l`/v1/organizations/plugins/${s}/versions/${n}/content?beta=true`,{query:o,...t,headers:u([{"anthropic-beta":[...i??[],"ce-plugins-2026-09-01"].toString(),Accept:"application/binary"},t?.headers]),__binaryResponse:!0})}};var ci=(()=>{class r extends h{constructor(){super(...arguments),this.versions=new ar(this._client),this.installationSettings=new ir(this._client),this.shares=new or(this._client)}create(e,t){let{betas:s,...i}=e;return this._client.post("/v1/organizations/plugins?beta=true",J({body:i,...t,headers:u([{"anthropic-beta":[...s??[],"ce-plugins-2026-09-01"].toString()},t?.headers])},this._client))}retrieve(e,t={},s){let{betas:i,...o}=t??{};return this._client.get(l`/v1/organizations/plugins/${e}?beta=true`,{query:o,...s,headers:u([{"anthropic-beta":[...i??[],"ce-plugins-2026-09-01"].toString()},s?.headers])})}update(e,t,s){let{betas:i,...o}=t;return this._client.post(l`/v1/organizations/plugins/${e}?beta=true`,{body:o,...s,headers:u([{"anthropic-beta":[...i??[],"ce-plugins-2026-09-01"].toString()},s?.headers])})}list(e={},t){let{betas:s,...i}=e??{};return this._client.getAPIList("/v1/organizations/plugins?beta=true",w,{query:i,...t,headers:u([{"anthropic-beta":[...s??[],"ce-plugins-2026-09-01"].toString()},t?.headers])})}delete(e,t={},s){let{betas:i}=t??{};return this._client.delete(l`/v1/organizations/plugins/${e}?beta=true`,{...s,headers:u([{"anthropic-beta":[...i??[],"ce-plugins-2026-09-01"].toString()},s?.headers])})}}return r.Versions=ar,r.InstallationSettings=ir,r.Shares=or,r})();var cr=class extends h{list(n,e={},t){return this._client.getAPIList(l`/v1/organizations/rbac_groups/${n}/members?beta=true`,w,{query:e,...t})}add(n,e,t){return this._client.post(l`/v1/organizations/rbac_groups/${n}/members?beta=true`,{body:e,...t})}remove(n,e,t){let{rbac_group_id:s}=e;return this._client.delete(l`/v1/organizations/rbac_groups/${s}/members/${n}?beta=true`,t)}};var li=(()=>{class r extends h{constructor(){super(...arguments),this.members=new cr(this._client)}create(e,t){return this._client.post("/v1/organizations/rbac_groups?beta=true",{body:e,...t})}retrieve(e,t){return this._client.get(l`/v1/organizations/rbac_groups/${e}?beta=true`,t)}update(e,t,s){return this._client.post(l`/v1/organizations/rbac_groups/${e}?beta=true`,{body:t,...s})}list(e={},t){return this._client.getAPIList("/v1/organizations/rbac_groups?beta=true",w,{query:e,...t})}delete(e,t){return this._client.delete(l`/v1/organizations/rbac_groups/${e}?beta=true`,t)}}return r.Members=cr,r})();var lr=class extends h{list(n,e={},t){return this._client.getAPIList(l`/v1/organizations/rbac_roles/${n}/permissions?beta=true`,w,{query:e,...t})}};var ui=(()=>{class r extends h{constructor(){super(...arguments),this.permissions=new lr(this._client)}retrieve(e,t){return this._client.get(l`/v1/organizations/rbac_roles/${e}?beta=true`,t)}list(e={},t){return this._client.getAPIList("/v1/organizations/rbac_roles?beta=true",w,{query:e,...t})}}return r.Permissions=lr,r})();var ur=class extends h{list(n,e={},t){let{betas:s,...i}=e??{};return this._client.getAPIList(l`/v1/organizations/service_accounts/${n}/workspaces?beta=true`,w,{query:i,...t,headers:u([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},t?.headers])})}add(n,e,t){let{betas:s,...i}=e;return this._client.post(l`/v1/organizations/service_accounts/${n}/workspaces?beta=true`,{body:i,...t,headers:u([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},t?.headers])})}remove(n,e,t){let{service_account_id:s,betas:i}=e;return this._client.delete(l`/v1/organizations/service_accounts/${s}/workspaces/${n}?beta=true`,{...t,headers:u([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},t?.headers])})}};var di=(()=>{class r extends h{constructor(){super(...arguments),this.workspaces=new ur(this._client)}create(e,t){let{betas:s,...i}=e;return this._client.post("/v1/organizations/service_accounts?beta=true",{body:i,...t,headers:u([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},t?.headers])})}retrieve(e,t={},s){let{betas:i}=t??{};return this._client.get(l`/v1/organizations/service_accounts/${e}?beta=true`,{...s,headers:u([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},s?.headers])})}update(e,t,s){let{betas:i,...o}=t;return this._client.post(l`/v1/organizations/service_accounts/${e}?beta=true`,{body:o,...s,headers:u([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},s?.headers])})}list(e={},t){let{betas:s,...i}=e??{};return this._client.getAPIList("/v1/organizations/service_accounts?beta=true",w,{query:i,...t,headers:u([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},t?.headers])})}archive(e,t={},s){let{betas:i}=t??{};return this._client.post(l`/v1/organizations/service_accounts/${e}/archive?beta=true`,{...s,headers:u([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},s?.headers])})}}return r.Workspaces=ur,r})();var dr=class extends h{list(n={},e){return this._client.getAPIList("/v1/organizations/spend_limits/effective?beta=true",w,{query:n,...e})}};var hr=class extends h{retrieve(n,e){return this._client.get(l`/v1/organizations/spend_limit_increase_requests/${n}?beta=true`,e)}list(n={},e){return this._client.getAPIList("/v1/organizations/spend_limit_increase_requests?beta=true",w,{query:n,...e})}approve(n,e,t){return this._client.post(l`/v1/organizations/spend_limit_increase_requests/${n}/approve?beta=true`,{body:e,...t})}deny(n,e,t){return this._client.post(l`/v1/organizations/spend_limit_increase_requests/${n}/deny?beta=true`,{body:e,...t})}};var hi=(()=>{class r extends h{constructor(){super(...arguments),this.effective=new dr(this._client),this.increaseRequests=new hr(this._client)}retrieve(e,t){return this._client.get(l`/v1/organizations/spend_limits/${e}?beta=true`,t)}list(e={},t){let{betas:s,...i}=e??{};return this._client.getAPIList("/v1/organizations/spend_limits?beta=true",w,{query:i,...t,headers:u([{"anthropic-beta":[...s??[],"spend-limit-reads-2026-09-26"].toString()},t?.headers])})}delete(e,t){return this._client.delete(l`/v1/organizations/spend_limits/${e}?beta=true`,t)}set(e,t){let{betas:s,...i}=e;return this._client.post("/v1/organizations/spend_limits?beta=true",{body:i,...t,headers:u([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},t?.headers])})}}return r.Effective=dr,r.IncreaseRequests=hr,r})();var fr=class extends h{retrieve(n,e,t){let{workspace_id:s}=e;return this._client.get(l`/v1/organizations/workspaces/${s}/members/${n}?beta=true`,t)}update(n,e,t){let{workspace_id:s,...i}=e;return this._client.post(l`/v1/organizations/workspaces/${s}/members/${n}?beta=true`,{body:i,...t})}list(n,e={},t){return this._client.getAPIList(l`/v1/organizations/workspaces/${n}/members?beta=true`,C,{query:e,...t})}add(n,e,t){return this._client.post(l`/v1/organizations/workspaces/${n}/members?beta=true`,{body:e,...t})}remove(n,e,t){let{workspace_id:s}=e;return this._client.delete(l`/v1/organizations/workspaces/${s}/members/${n}?beta=true`,t)}};var pr=class extends h{list(n,e={},t){return this._client.getAPIList(l`/v1/organizations/workspaces/${n}/rate_limits?beta=true`,w,{query:e,...t})}};var mr=class extends h{retrieve(n,e,t){let{workspace_id:s,betas:i}=e;return this._client.get(l`/v1/organizations/workspaces/${s}/service_accounts/${n}?beta=true`,{...t,headers:u([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},t?.headers])})}update(n,e,t){let{workspace_id:s,betas:i,...o}=e;return this._client.post(l`/v1/organizations/workspaces/${s}/service_accounts/${n}?beta=true`,{body:o,...t,headers:u([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},t?.headers])})}list(n,e={},t){let{betas:s,...i}=e??{};return this._client.getAPIList(l`/v1/organizations/workspaces/${n}/service_accounts?beta=true`,w,{query:i,...t,headers:u([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},t?.headers])})}add(n,e,t){let{betas:s,...i}=e;return this._client.post(l`/v1/organizations/workspaces/${n}/service_accounts?beta=true`,{body:i,...t,headers:u([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},t?.headers])})}remove(n,e,t){let{workspace_id:s,betas:i}=e;return this._client.delete(l`/v1/organizations/workspaces/${s}/service_accounts/${n}?beta=true`,{...t,headers:u([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},t?.headers])})}};var fi=(()=>{class r extends h{constructor(){super(...arguments),this.rateLimits=new pr(this._client),this.members=new fr(this._client),this.serviceAccounts=new mr(this._client)}create(e,t){let{betas:s,...i}=e;return this._client.post("/v1/organizations/workspaces?beta=true",{body:i,...t,headers:u([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},t?.headers])})}retrieve(e,t){return this._client.get(l`/v1/organizations/workspaces/${e}?beta=true`,t)}update(e,t,s){return this._client.post(l`/v1/organizations/workspaces/${e}?beta=true`,{body:t,...s})}list(e={},t){return this._client.getAPIList("/v1/organizations/workspaces?beta=true",C,{query:e,...t})}archive(e,t){return this._client.post(l`/v1/organizations/workspaces/${e}/archive?beta=true`,t)}}return r.RateLimits=pr,r.Members=fr,r.ServiceAccounts=mr,r})();var pi=(()=>{class r extends h{constructor(){super(...arguments),this.apiKeys=new Ht(this._client),this.externalKeys=new Qt(this._client),this.federation=new ai(this._client),this.invites=new tr(this._client),this.serviceAccounts=new di(this._client),this.users=new nr(this._client),this.workspaces=new fi(this._client),this.rateLimits=new sr(this._client),this.complianceSettings=new Xt(this._client),this.analytics=new ii(this._client),this.spendLimits=new hi(this._client),this.rbacGroups=new li(this._client),this.rbacRoles=new ui(this._client),this.plugins=new ci(this._client),this.pluginMarketplaces=new rr(this._client)}retrieve(e){return this._client.get("/v1/organizations/me?beta=true",e)}}return r.APIKeys=Ht,r.ExternalKeys=Qt,r.Federation=ai,r.Invites=tr,r.ServiceAccounts=di,r.Users=nr,r.Workspaces=fi,r.RateLimits=sr,r.ComplianceSettings=Xt,r.Analytics=ii,r.SpendLimits=hi,r.RBACGroups=li,r.RBACRoles=ui,r.Plugins=ci,r.PluginMarketplaces=rr,r})();var mi=(()=>{class r extends h{list(e,t={},s){let{betas:i,workspace_id:o,...c}=t??{};return this._client.getAPIList(l`/v1/sessions/${e}/events?beta=true`,w,{query:c,...s,headers:u([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},s?.headers])})}send(e,t,s){let{betas:i,workspace_id:o,...c}=t;return this._client.post(l`/v1/sessions/${e}/events?beta=true`,{body:c,...s,headers:u([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},s?.headers])})}stream(e,t={},s){let{betas:i,workspace_id:o,...c}=t??{};return this._client.get(l`/v1/sessions/${e}/events/stream?beta=true`,{query:c,...s,headers:u([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},s?.headers]),stream:!0})}toolRunner(e,t){return new ks(e,{...t,client:this._client})}}return r.SessionToolRunner=ks,r})();var _r=class extends h{retrieve(n,e,t){let{session_id:s,betas:i,workspace_id:o}=e;return this._client.get(l`/v1/sessions/${s}/resources/${n}?beta=true`,{...t,headers:u([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},t?.headers])})}update(n,e,t){let{session_id:s,betas:i,workspace_id:o,...c}=e;return this._client.post(l`/v1/sessions/${s}/resources/${n}?beta=true`,{body:c,...t,headers:u([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},t?.headers])})}list(n,e={},t){let{betas:s,workspace_id:i,...o}=e??{};return this._client.getAPIList(l`/v1/sessions/${n}/resources?beta=true`,w,{query:o,...t,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}delete(n,e,t){let{session_id:s,betas:i,workspace_id:o}=e;return this._client.delete(l`/v1/sessions/${s}/resources/${n}?beta=true`,{...t,headers:u([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},t?.headers])})}add(n,e,t){let{betas:s,workspace_id:i,...o}=e;return this._client.post(l`/v1/sessions/${n}/resources?beta=true`,{body:o,...t,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}};var gr=class extends h{list(n,e,t){let{session_id:s,betas:i,workspace_id:o,...c}=e;return this._client.getAPIList(l`/v1/sessions/${s}/threads/${n}/events?beta=true`,w,{query:c,...t,headers:u([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},t?.headers])})}stream(n,e,t){let{session_id:s,betas:i,workspace_id:o,...c}=e;return this._client.get(l`/v1/sessions/${s}/threads/${n}/stream?beta=true`,{query:c,...t,headers:u([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},t?.headers]),stream:!0})}};var _i=(()=>{class r extends h{constructor(){super(...arguments),this.events=new gr(this._client)}retrieve(e,t,s){let{session_id:i,betas:o,workspace_id:c}=t;return this._client.get(l`/v1/sessions/${i}/threads/${e}?beta=true`,{...s,headers:u([{"anthropic-beta":[...o??[],"managed-agents-2026-04-01"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers])})}list(e,t={},s){let{betas:i,workspace_id:o,...c}=t??{};return this._client.getAPIList(l`/v1/sessions/${e}/threads?beta=true`,w,{query:c,...s,headers:u([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},s?.headers])})}archive(e,t,s){let{session_id:i,betas:o,workspace_id:c}=t;return this._client.post(l`/v1/sessions/${i}/threads/${e}/archive?beta=true`,{...s,headers:u([{"anthropic-beta":[...o??[],"managed-agents-2026-04-01"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},s?.headers])})}}return r.Events=gr,r})();var gi=(()=>{class r extends h{constructor(){super(...arguments),this.events=new mi(this._client),this.resources=new _r(this._client),this.threads=new _i(this._client)}create(e,t){let{betas:s,workspace_id:i,...o}=e;return this._client.post("/v1/sessions?beta=true",{body:o,...t,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}retrieve(e,t={},s){let{betas:i,workspace_id:o}=t??{};return this._client.get(l`/v1/sessions/${e}?beta=true`,{...s,headers:u([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},s?.headers])})}update(e,t,s){let{betas:i,workspace_id:o,...c}=t;return this._client.post(l`/v1/sessions/${e}?beta=true`,{body:c,...s,headers:u([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},s?.headers])})}list(e={},t){let{betas:s,workspace_id:i,...o}=e??{};return this._client.getAPIList("/v1/sessions?beta=true",an,{query:o,...t,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}delete(e,t={},s){let{betas:i,workspace_id:o}=t??{};return this._client.delete(l`/v1/sessions/${e}?beta=true`,{...s,headers:u([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},s?.headers])})}archive(e,t={},s){let{betas:i,workspace_id:o}=t??{};return this._client.post(l`/v1/sessions/${e}/archive?beta=true`,{...s,headers:u([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},s?.headers])})}}return r.Events=mi,r.Resources=_r,r.Threads=_i,r})();var wr=class extends h{create(n,e,t){let{betas:s,workspace_id:i,...o}=e;return this._client.post(l`/v1/skills/${n}/versions?beta=true`,J({body:o,...t,headers:u([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0,...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])},this._client,!1))}retrieve(n,e,t){let{skill_id:s,betas:i,workspace_id:o}=e;return this._client.get(l`/v1/skills/${s}/versions/${n}?beta=true`,{...t,headers:u([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...o!=null?{"anthropic-workspace-id":o}:void 0},t?.headers])})}list(n,e={},t){let{betas:s,workspace_id:i,...o}=e??{};return this._client.getAPIList(l`/v1/skills/${n}/versions?beta=true`,w,{query:o,...t,headers:u([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0,...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}delete(n,e,t){let{skill_id:s,betas:i,workspace_id:o}=e;return this._client.delete(l`/v1/skills/${s}/versions/${n}?beta=true`,{...t,headers:u([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...o!=null?{"anthropic-workspace-id":o}:void 0},t?.headers])})}download(n,e,t){let{skill_id:s,betas:i,workspace_id:o}=e;return this._client.get(l`/v1/skills/${s}/versions/${n}/content?beta=true`,{...t,headers:u([{Accept:"application/binary",...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...o!=null?{"anthropic-workspace-id":o}:void 0},t?.headers]),__binaryResponse:!0})}};var wi=(()=>{class r extends h{constructor(){super(...arguments),this.versions=new wr(this._client)}create(e,t){let{betas:s,workspace_id:i,...o}=e;return this._client.post("/v1/skills?beta=true",J({body:o,...t,headers:u([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0,...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])},this._client,!1))}retrieve(e,t={},s){let{betas:i,workspace_id:o}=t??{};return this._client.get(l`/v1/skills/${e}?beta=true`,{...s,headers:u([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...o!=null?{"anthropic-workspace-id":o}:void 0},s?.headers])})}list(e={},t){let{betas:s,workspace_id:i,...o}=e??{};return this._client.getAPIList("/v1/skills?beta=true",w,{query:o,...t,headers:u([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0,...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}delete(e,t={},s){let{betas:i,workspace_id:o}=t??{};return this._client.delete(l`/v1/skills/${e}?beta=true`,{...s,headers:u([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...o!=null?{"anthropic-workspace-id":o}:void 0},s?.headers])})}}return r.Versions=wr,r})();var br=class extends h{create(n,e,t){let{betas:s,workspace_id:i,...o}=e;return this._client.post(l`/v1/tunnels/${n}/certificates?beta=true`,{body:o,...t,headers:u([{"anthropic-beta":[...s??[],"mcp-tunnels-2026-06-22"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}retrieve(n,e,t){let{tunnel_id:s,betas:i,workspace_id:o}=e;return this._client.get(l`/v1/tunnels/${s}/certificates/${n}?beta=true`,{...t,headers:u([{"anthropic-beta":[...i??[],"mcp-tunnels-2026-06-22"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},t?.headers])})}list(n,e={},t){let{betas:s,workspace_id:i,...o}=e??{};return this._client.getAPIList(l`/v1/tunnels/${n}/certificates?beta=true`,w,{query:o,...t,headers:u([{"anthropic-beta":[...s??[],"mcp-tunnels-2026-06-22"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}archive(n,e,t){let{tunnel_id:s,betas:i,workspace_id:o}=e;return this._client.post(l`/v1/tunnels/${s}/certificates/${n}/archive?beta=true`,{...t,headers:u([{"anthropic-beta":[...i??[],"mcp-tunnels-2026-06-22"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},t?.headers])})}};var bi=(()=>{class r extends h{constructor(){super(...arguments),this.certificates=new br(this._client)}create(e,t){let{betas:s,workspace_id:i,...o}=e;return this._client.post("/v1/tunnels?beta=true",{body:o,...t,headers:u([{"anthropic-beta":[...s??[],"mcp-tunnels-2026-06-22"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}retrieve(e,t={},s){let{betas:i,workspace_id:o}=t??{};return this._client.get(l`/v1/tunnels/${e}?beta=true`,{...s,headers:u([{"anthropic-beta":[...i??[],"mcp-tunnels-2026-06-22"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},s?.headers])})}list(e={},t){let{betas:s,workspace_id:i,...o}=e??{};return this._client.getAPIList("/v1/tunnels?beta=true",w,{query:o,...t,headers:u([{"anthropic-beta":[...s??[],"mcp-tunnels-2026-06-22"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}archive(e,t={},s){let{betas:i,workspace_id:o}=t??{};return this._client.post(l`/v1/tunnels/${e}/archive?beta=true`,{...s,headers:u([{"anthropic-beta":[...i??[],"mcp-tunnels-2026-06-22"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},s?.headers])})}revealToken(e,t={},s){let{betas:i,workspace_id:o}=t??{};return this._client.post(l`/v1/tunnels/${e}/reveal_token?beta=true`,{...s,headers:u([{"anthropic-beta":[...i??[],"mcp-tunnels-2026-06-22"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},s?.headers])})}rotateToken(e,t,s){let{betas:i,workspace_id:o,...c}=t;return this._client.post(l`/v1/tunnels/${e}/rotate_token?beta=true`,{body:c,...s,headers:u([{"anthropic-beta":[...i??[],"mcp-tunnels-2026-06-22"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},s?.headers])})}}return r.Certificates=br,r})();var yr=class extends h{create(n,e,t){let{betas:s,workspace_id:i,...o}=e;return this._client.post(l`/v1/vaults/${n}/credentials?beta=true`,{body:o,...t,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}retrieve(n,e,t){let{vault_id:s,betas:i,workspace_id:o}=e;return this._client.get(l`/v1/vaults/${s}/credentials/${n}?beta=true`,{...t,headers:u([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},t?.headers])})}update(n,e,t){let{vault_id:s,betas:i,workspace_id:o,...c}=e;return this._client.post(l`/v1/vaults/${s}/credentials/${n}?beta=true`,{body:c,...t,headers:u([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},t?.headers])})}list(n,e={},t){let{betas:s,workspace_id:i,...o}=e??{};return this._client.getAPIList(l`/v1/vaults/${n}/credentials?beta=true`,w,{query:o,...t,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}delete(n,e,t){let{vault_id:s,betas:i,workspace_id:o}=e;return this._client.delete(l`/v1/vaults/${s}/credentials/${n}?beta=true`,{...t,headers:u([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},t?.headers])})}archive(n,e,t){let{vault_id:s,betas:i,workspace_id:o}=e;return this._client.post(l`/v1/vaults/${s}/credentials/${n}/archive?beta=true`,{...t,headers:u([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},t?.headers])})}mcpOAuthValidate(n,e,t){let{vault_id:s,betas:i,workspace_id:o}=e;return this._client.post(l`/v1/vaults/${s}/credentials/${n}/mcp_oauth_validate?beta=true`,{...t,headers:u([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},t?.headers])})}};var yi=(()=>{class r extends h{constructor(){super(...arguments),this.credentials=new yr(this._client)}create(e,t){let{betas:s,workspace_id:i,...o}=e;return this._client.post("/v1/vaults?beta=true",{body:o,...t,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}retrieve(e,t={},s){let{betas:i,workspace_id:o}=t??{};return this._client.get(l`/v1/vaults/${e}?beta=true`,{...s,headers:u([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},s?.headers])})}update(e,t,s){let{betas:i,workspace_id:o,...c}=t;return this._client.post(l`/v1/vaults/${e}?beta=true`,{body:c,...s,headers:u([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},s?.headers])})}list(e={},t){let{betas:s,workspace_id:i,...o}=e??{};return this._client.getAPIList("/v1/vaults?beta=true",w,{query:o,...t,headers:u([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}delete(e,t={},s){let{betas:i,workspace_id:o}=t??{};return this._client.delete(l`/v1/vaults/${e}?beta=true`,{...s,headers:u([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},s?.headers])})}archive(e,t={},s){let{betas:i,workspace_id:o}=t??{};return this._client.post(l`/v1/vaults/${e}/archive?beta=true`,{...s,headers:u([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...o!=null?{"anthropic-workspace-id":o}:void 0},s?.headers])})}}return r.Credentials=yr,r})();var Ee,ki,et,kr,Si,tt,Sr,vi,Uc,xi,Ai,Bo=(()=>{class r extends ti{constructor(e,t){super(e),Ee.add(this),ki.set(this,void 0),et.set(this,0),kr.set(this,[]),Si.set(this,[]),tt.set(this,void 0),Sr.set(this,[]),vi.set(this,!1),m(this,ki,t,"f")}get toolCalls(){return a(this,Si,"f")}static start(e,t,s,i){let o=new r({...t,stream:!0},i);for(let c of t.messages)o._addMessageParam(c);return o._run(()=>o._createMessage(e,{...t,stream:!0},{...s,headers:{...s?.headers,[lt]:"stream"}})),o}_emit(e,...t){var s;if(e!=="streamEvent"||this.ended){super._emit(e,...t);return}m(this,et,(s=a(this,et,"f"),s++,s),"f");let[i,o]=t,c=i.type==="content_block_stop"?o.content[i.index]:void 0,f=c?.type==="tool_use"?c:void 0;f&&a(this,Si,"f").push(f),super._emit(e,...t),a(this,Ee,"m",Uc).call(this,i,f),a(this,Ee,"m",xi).call(this)}[(ki=new WeakMap,et=new WeakMap,kr=new WeakMap,Si=new WeakMap,tt=new WeakMap,Sr=new WeakMap,vi=new WeakMap,Ee=new WeakSet,Symbol.asyncIterator)](){let e=super[Symbol.asyncIterator](),t={handled:a(this,et,"f")};a(this,kr,"f").push(t);let s=!1;return{next:async()=>{s&&(s=!1,t.handled++,a(this,Ee,"m",xi).call(this));try{let i=await e.next();return s=!i.done,i.done&&a(this,Ee,"m",Ai).call(this,t),i}catch(i){throw a(this,Ee,"m",Ai).call(this,t),i}},return:async()=>{let i=e.return?.();return a(this,Ee,"m",Ai).call(this,t),await i??{value:void 0,done:!0}}}}}return Uc=function(e,t){if(a(this,vi,"f"))return;if(e.type==="content_block_start"&&e.content_block.type==="fallback"){m(this,vi,!0,"f"),m(this,tt,void 0,"f");return}let s=e.type==="content_block_start"||e.type==="message_delta"&&e.delta.stop_reason==="tool_use";a(this,tt,"f")&&s&&(a(this,Sr,"f").push({toolUse:a(this,tt,"f"),event:a(this,et,"f")}),m(this,tt,void 0,"f")),t&&m(this,tt,t,"f")},xi=function(){if(this.errored||this.controller.signal.aborted)return;let e=Math.min(a(this,et,"f"),...a(this,kr,"f").map(t=>t.handled));for(;a(this,Sr,"f")[0]&&a(this,Sr,"f")[0].event<=e;)a(this,ki,"f").call(this,a(this,Sr,"f").shift().toolUse)},Ai=function(e){let t=a(this,kr,"f").indexOf(e);t>=0&&(a(this,kr,"f").splice(t,1),a(this,Ee,"m",xi).call(this))},r})();function Ho(){let r,n;return{promise:new Promise((t,s)=>{r=t,n=s}),resolve:r,reject:n}}var N,vr,rt,$,X,ee,We,ve,De,Cs,oe,xe,xr,Ar,st,Wo,jc,Do,zo,$s,Pi,Kc,qo,Uo,Ri,Vc,jo,Jc="a tool runner's toolsets come only from its tools param; change them with setMessagesParams(), or build a new runner",Rh="a tool runner's toolsets come only from its tools param; remove it there with setMessagesParams(), or build a new runner without it",Jo=(()=>{class r{constructor(e,t,s){N.add(this),this.client=e,vr.set(this,!1),rt.set(this,!1),$.set(this,void 0),X.set(this,void 0),ee.set(this,void 0),We.set(this,void 0),ve.set(this,void 0),De.set(this,void 0),Cs.set(this,0),oe.set(this,{status:"idle"}),xe.set(this,void 0),xr.set(this,null),Ar.set(this,new Map),st.set(this,[]),Gc(t),Ih(t),Yc(t),m(this,$,{params:{...t,messages:JSON.parse(JSON.stringify(Xc(t.messages)))}},"f");let i=oo(t.tools,t.messages);m(this,X,{...s,headers:u([ln("BetaToolRunner"),i.length?{[Ge]:i.join(", ")}:void 0,s?.headers])},"f"),m(this,De,Ho(),"f")}async*[(vr=new WeakMap,rt=new WeakMap,$=new WeakMap,X=new WeakMap,ee=new WeakMap,We=new WeakMap,ve=new WeakMap,De=new WeakMap,Cs=new WeakMap,oe=new WeakMap,xe=new WeakMap,xr=new WeakMap,Ar=new WeakMap,st=new WeakMap,N=new WeakSet,Symbol.asyncIterator)](){var e;if(a(this,vr,"f"))throw new k("Cannot iterate over a consumed stream");m(this,vr,!0,"f"),m(this,rt,!0,"f"),m(this,ve,void 0,"f");try{for(;;)try{if(a(this,$,"f").params.max_iterations&&a(this,Cs,"f")>=a(this,$,"f").params.max_iterations)break;if(a(this,N,"m",Vc).call(this),a(this,oe,"f").status==="scheduled"&&Zc(a(this,xr,"f"))!=="resume"){yield*a(this,N,"m",zo).call(this,a(this,oe,"f").config);continue}m(this,rt,!1,"f"),m(this,ve,void 0,"f"),m(this,Cs,(e=a(this,Cs,"f"),e++,e),"f"),m(this,ee,void 0,"f");let{max_iterations:t,runToolsEagerly:s,...i}=a(this,$,"f").params;if(yield*a(this,N,"m",Wo).call(this,i),a(this,rt,"f"))m(this,xr,null,"f");else{let c=await a(this,ee,"f"),f=Zc(c.stop_reason);m(this,xr,c.stop_reason,"f"),a(this,$,"f").params.messages.push({role:c.role,content:c.content});let{container:d}=a(this,$,"f").params;if(c.container&&(d==null?a(this,$,"f").params.container=c.container.id:typeof d=="object"&&d.id==null&&(a(this,$,"f").params.container={...d,id:c.container.id})),f==="stop"){yield*a(this,N,"m",qo).call(this);break}if(f==="resume")continue}let o=await a(this,N,"m",Uo).call(this,a(this,$,"f").params.messages.at(-1));if(o)a(this,$,"f").params.messages.push(o);else if(!a(this,rt,"f")){yield*a(this,N,"m",qo).call(this);break}}finally{a(this,We,"f")?.abort(),m(this,We,void 0,"f")}if(await a(this,N,"m",Do).call(this),!a(this,ee,"f"))throw new k("ToolRunner concluded without a message from the server");a(this,De,"f").resolve(await a(this,ee,"f"))}catch(t){throw m(this,vr,!1,"f"),a(this,De,"f").promise.catch(()=>{}),a(this,De,"f").reject(t),m(this,De,Ho(),"f"),t}}setMessagesParams(e){let t=typeof e=="function"?e(a(this,$,"f").params):e;if(Gc(t),Yc(t),a(this,oe,"f").status!=="idle"&&Ko(t),a(this,oe,"f").status==="in_flight"&&t.messages!==a(this,$,"f").params.messages)throw new k("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.");a(this,$,"f").params=t,m(this,rt,!0,"f"),m(this,ve,void 0,"f")}setRequestOptions(e){typeof e=="function"?m(this,X,e(a(this,X,"f")),"f"):m(this,X,{...a(this,X,"f"),...e},"f")}async generateToolResponse(e=a(this,X,"f").signal){let t=await a(this,ee,"f")??this.params.messages.at(-1);return t?a(this,N,"m",Uo).call(this,t,e):null}deferToolCall(e){let t=typeof e=="string"?e:e.id;a(this,xe,"f")&&!a(this,xe,"f").has(t)&&a(this,xe,"f").set(t,{status:"held"})}get deferredToolCalls(){let e=a(this,We,"f"),t=a(this,xe,"f");return!(e instanceof Bo)||!t?[]:e.toolCalls.filter(s=>t.get(s.id)?.status==="held")}done(){return a(this,De,"f").promise}async runUntilDone(){if(!a(this,vr,"f"))for await(let e of this);return this.done()}get params(){return a(this,$,"f").params}pushMessages(...e){this.setMessagesParams(t=>({...t,messages:[...t.messages,...e]}))}compactBeforeNextTurn(e){a(this,oe,"f").status!=="in_flight"&&(Ko(a(this,$,"f").params),m(this,oe,{status:"scheduled",config:e??{type:"summarize"}},"f"))}addTools(...e){let t=a(this,N,"m",Ri).call(this);for(let s of e){if(Ft(s))throw new He(`addTools() can't add the '${Re(Be(s))}' toolset: ${Jc}`);let i=Mh(s);if(t.has(i))throw new He(`addTools() can't replace the '${Re(i)}' toolset: ${Jc}`)}for(let s of e)"name"in s&&a(this,Ar,"f").set(s.name,"run"in s?s:null),a(this,st,"f").push({type:"addition",tool:s})}removeTools(...e){let t=a(this,N,"m",Ri).call(this);for(let s of e){let i=typeof s=="string"?s:s.name;if(t.has(i))throw new He(`removeTools() can't remove the '${Re(i)}' toolset: ${Rh}`)}for(let s of e){let i=typeof s=="string"?s:s.name;a(this,Ar,"f").set(i,null),a(this,st,"f").push({type:"removal",name:i})}}then(e,t){return this.runUntilDone().then(e,t)}}return Wo=async function*(e){await a(this,N,"m",Do).call(this),m(this,xe,void 0,"f"),e={...e,...e.tools&&{tools:e.tools.map(Vo)},messages:Xc(e.messages)},e.stream?(m(this,We,a(this,$,"f").params.runToolsEagerly?a(this,N,"m",jc).call(this,e):this.client.beta.messages.stream({...e},a(this,X,"f")),"f"),m(this,ee,a(this,We,"f").finalMessage(),"f"),a(this,ee,"f").catch(()=>{}),yield a(this,We,"f")):(m(this,ee,this.client.beta.messages.create({...e,stream:!1},a(this,X,"f")),"f"),yield a(this,ee,"f"))},jc=function(e){let t=new Map;m(this,xe,t,"f");let s=new Map;return Bo.start(this.client.beta.messages,e,a(this,X,"f"),i=>{let o=t.has(i.id),c=!i.toolset_name&&a(this,N,"m",Ri).call(this).has(i.name),f=c?i.name:i.toolset_name;if(f){if(o||c||s.has(f)){s.set(f,"waiting");return}s.set(f,"running");let b=el(a(this,$,"f").params,f,i,a(this,X,"f"));t.set(i.id,{status:"started",result:b}),b.then(({is_error:p})=>{p||s.get(f)==="waiting"?s.set(f,"waiting"):s.delete(f)},()=>s.set(f,"waiting"));return}if(o)return;let d=tl(a(this,N,"m",$s).call(this),a(this,N,"m",Pi).call(this),i,a(this,X,"f"));d.catch(()=>{}),t.set(i.id,{status:"started",result:d})})},Do=async function(){let e=[...a(this,xe,"f")?.values()??[]].filter(t=>t.status==="started");await Promise.allSettled(e.map(t=>t.result))},zo=async function*(e){Ko(a(this,$,"f").params);let{max_iterations:t,runToolsEagerly:s,...i}=a(this,$,"f").params,o=Eh(i);m(this,oe,{status:"in_flight"},"f"),m(this,ve,void 0,"f");let c=a(this,ee,"f");try{yield*a(this,N,"m",Wo).call(this,{...o,compaction:e});let f=await a(this,ee,"f");f.content.some(d=>d.type==="compaction"&&d.content)?(a(this,N,"m",Kc).call(this),a(this,$,"f").params.messages=[{role:f.role,content:f.content}]):(T(this.client).warn("Compaction produced no summary; keeping the conversation as it is."),m(this,ee,c,"f"))}finally{m(this,oe,{status:"idle"},"f")}},$s=function(){let e=new Map;for(let t of a(this,$,"f").params.tools)"run"in t&&"name"in t&&e.set(t.name,t);for(let[t,s]of a(this,Ar,"f"))s?e.set(t,s):e.delete(t);return e},Pi=function(){let e=new Set(a(this,N,"m",$s).call(this).keys());for(let t of[...a(this,$,"f").params.messages,a(this,N,"m",jo).call(this)])if(typeof t.content!="string"){for(let s of t.content)if(t.role==="system")Qc(s,e);else if(t.role==="assistant"&&s.type==="compaction")for(let i of s.tool_changes??[])Qc(i,e)}return e},Kc=function(){let e=a(this,N,"m",Pi).call(this);for(let t of a(this,N,"m",$s).call(this).keys())e.has(t)||a(this,Ar,"f").set(t,null)},qo=async function*(){if(a(this,oe,"f").status!=="scheduled")return;let e=a(this,$,"f").params.messages.at(-1)?.content;if(Array.isArray(e)&&e.some(t=>t.type==="tool_use")){T(this.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."),m(this,oe,{status:"idle"},"f");return}yield*a(this,N,"m",zo).call(this,a(this,oe,"f").config)},Uo=async function(e,t=a(this,X,"f").signal){return a(this,ve,"f")!==void 0?a(this,ve,"f"):(m(this,ve,Th(a(this,$,"f").params,a(this,N,"m",$s).call(this),a(this,N,"m",Pi).call(this),e,{...a(this,X,"f"),signal:t},a(this,xe,"f")),"f"),a(this,ve,"f"))},Ri=function(){return new Set(a(this,$,"f").params.tools.filter(Ft).map(Be))},Vc=function(){a(this,xr,"f")==="pause_turn"||a(this,st,"f").length===0||(a(this,$,"f").params.messages.push(a(this,N,"m",jo).call(this)),m(this,st,[],"f"))},jo=function(){let e=[];for(let t of a(this,st,"f")){if(t.type==="removal"){e.push({type:"tool_removal",tool:{type:"tool_reference",name:t.name}});continue}let s=Vo(t.tool);e.push({type:"tool_addition",tool:{type:"tool_definition",definition:s}})}return{role:"system",content:e}},r})();function Gc(r){if("compaction"in r&&r.compaction!=null)throw new k("`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 Ih(r){if("compactionControl"in r&&r.compactionControl!=null)throw new k("`compactionControl` has been removed from the tool runner. Use server-side compaction instead: call `runner.compactBeforeNextTurn()` when the conversation should be compacted.")}function Yc(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 Ko(r){if(r.context_management?.edits?.some(n=>n.type.startsWith("compact_")))throw new k("`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 Eh(r){let{context_management:n,stop_sequences:e,output_format:t,...s}=r,i=({format:o,...c})=>c;return(s.tool_choice?.type==="any"||s.tool_choice?.type==="tool")&&delete s.tool_choice,s.output_config&&(s.output_config=i(s.output_config)),Array.isArray(s.fallbacks)&&(s.fallbacks=s.fallbacks.map(o=>o.output_config?{...o,output_config:i(o.output_config)}:o)),s}function Vo(r){if(!("run"in r))return r;let n=ri,e="toJSON"in r&&typeof r.toJSON=="function"?r.toJSON():r;return{...Object.fromEntries(Object.entries(e).filter(([t])=>n.includes(t))),...Je(r)&&{[Pe]:r[Pe]}}}function Xc(r){return r.map(n=>{if(n.role!=="system"||typeof n.content=="string")return n;let e=n.content.map(t=>t.type==="tool_addition"&&t.tool.type==="tool_definition"?{...t,tool:{...t.tool,definition:Vo(t.tool.definition)}}:t);return{...n,content:e}})}async function Th(r,n,e,t,s,i){if(!t||t.role!=="assistant"||!t.content||typeof t.content=="string")return null;let o=t.content.filter(d=>d.type==="tool_use");if(o.length===0)return null;let c=new Map;return{role:"user",content:await Promise.all(o.map(async d=>{let b=i?.get(d.id),p=b?.status==="started"?b.result:void 0;if(d.toolset_name){let _=d.toolset_name,v=c.get(_)??{tail:Promise.resolve(),failed:!1};c.set(_,v);let A=r.tools.some(S=>Ft(S)&&Be(S)===_),R=p??v.tail.then(()=>v.failed?Os(d,zc(_),!0):el(r,_,d,s));return v.tail=R.then(({is_error:S})=>{S&&A&&(v.failed=!0)},()=>{v.failed=!0}),i?.set(d.id,{status:"started",result:R}),R}if(p)return p;if(!(e.has(d.name)?n.get(d.name):void 0)&&r.tools.some(_=>Ft(_)&&Be(_)===d.name)){let _=c.get(d.name)??{tail:Promise.resolve(),failed:!1};return c.set(d.name,_),_.tail=_.tail.then(()=>{_.failed=!0}),Ch(d)}let y=tl(n,e,d,s);return i?.set(d.id,{status:"started",result:y}),y}))}}async function el(r,n,e,t){let s=r.tools.find(i=>Ft(i)&&Be(i)===n);return s?qc(s,e,{signal:t?.signal}):Os(e,`Error: Toolset '${Re(n)}' member '${Re(e.name)}' not found`,!0)}async function tl(r,n,e,t){let s=n.has(e.name)?r.get(e.name):void 0;if(!s)return Oh(e);try{let i=e.input;"parse"in s&&s.parse&&(i=s.parse(i));let o=await s.run(i,{toolUse:e,toolUseBlock:e,signal:t?.signal});return{type:"tool_result",tool_use_id:e.id,content:o}}catch(i){return{type:"tool_result",tool_use_id:e.id,content:yo(i),is_error:!0}}}function Mh(r){return(r.type??"custom").replace(/_\d{8}$/,"").replace(/_toolset$/,"")}function Oh(r){return{type:"tool_result",tool_use_id:r.id,content:`Error: Tool '${r.name}' not found`,is_error:!0}}function Ch(r){return{type:"tool_result",tool_use_id:r.id,content:`Error: the '${Re(r.name)}' toolset could not run this call${$h(r.input)}; nothing in the batch was executed`,is_error:!0}}function $h(r){let n=typeof r=="object"&&r!==null?r:{};if(!("actions"in n)){let i="action"in n?n.action:void 0;return typeof i=="string"?`: the call has no 'actions' list (action: '${Re(i)}')`:": the call has no 'actions' list"}let{actions:e}=n;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[i,o]of e.entries()){let c=typeof o=="object"&&o!==null&&"action"in o?o.action:void 0;if(typeof c!="string")return`: action ${i} must be an object with a string 'action' field`;t.push(`'${Re(c)}'`)}let s=t.length>10?`, and ${t.length-10} more`:"";return`: its actions could not be run as sent (actions: ${t.slice(0,10).join(", ")}${s})`}function Qc(r,n){switch(r.type){case"tool_removal":case"tool_addition":Nh(r,n);break}}function Nh(r,n){let e=Lh(r.tool);e!==void 0&&(r.type==="tool_removal"?n.delete(e):n.add(e))}function Lh(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 Zc(r){if(r===null)return"stop";switch(r){case"tool_use":return"run_tools";case"pause_turn":case"compaction":return"resume";case"end_turn":case"stop_sequence":case"max_tokens":case"model_context_window_exceeded":case"refusal":return"stop";default:return"stop"}}var rl={"claude-sonnet-4-5":"November 30th, 2026","claude-sonnet-4-5-20250929":"November 30th, 2026"},Fh=["claude-mythos-preview","claude-opus-4-6"],Bt=(()=>{class r extends h{constructor(){super(...arguments),this.batches=new Nt(this._client)}create(e,t){let s=sl(e),{betas:i,user_profile_id:o,workspace_id:c,...f}=s;f.model in rl&&console.warn(`The model '${f.model}' is deprecated and will reach end-of-life on ${rl[f.model]}
|
|
Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`),Fh.includes(f.model)&&f.thinking&&f.thinking.type==="enabled"&&console.warn(`Using Claude with ${f.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 d=t?.timeout??this._client._options.timeout;if(!f.stream&&d==null){let p=Sn[f.model]??void 0;d=this._client.calculateNonstreamingTimeout(f.max_tokens,p)}let b=un(f.tools,f.messages);return this._client.post("/v1/messages?beta=true",{body:f,timeout:d??6e5,...t,headers:u([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...o!=null?{"anthropic-user-profile-id":o}:void 0,...c!=null?{"anthropic-workspace-id":c}:void 0},b,t?.headers]),stream:s.stream??!1})}parse(e,t){return t={...t,headers:u([{"anthropic-beta":[...e.betas??[],"structured-outputs-2025-12-15"].toString()},t?.headers])},this.create(e,t).then(s=>Mo(s,e,{logger:this._client.logger??console}))}stream(e,t){return ti.createMessage(this,e,t)}countTokens(e,t){let s=sl(e),{betas:i,user_profile_id:o,workspace_id:c,...f}=s;return this._client.post("/v1/messages/count_tokens?beta=true",{body:f,...t,headers:u([{"anthropic-beta":[...i??[],"token-counting-2024-11-01"].toString(),...o!=null?{"anthropic-user-profile-id":o}:void 0,...c!=null?{"anthropic-workspace-id":c}:void 0},t?.headers])})}toolRunner(e,t){return new Jo(this._client,e,t)}}return r.Batches=Nt,r.BetaToolRunner=Jo,r.ToolError=Rt,r})();function sl(r){if(!r.output_format)return r;if(r.output_config?.format)throw new k("Both output_format and output_config.format were provided. Please use only output_config.format (output_format is deprecated).");let{output_format:n,...e}=r;return{...e,output_config:{...r.output_config,format:n}}}var ri=["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 Ns=(()=>{class r extends h{constructor(){super(...arguments),this.models=new _t(this._client),this.messages=new Bt(this._client),this.agents=new An(this._client),this.environments=new Kn(this._client),this.sessions=new gi(this._client),this.deployments=new ft(this._client),this.deploymentRuns=new ht(this._client),this.vaults=new yi(this._client),this.memoryStores=new Vn(this._client),this.files=new mt(this._client),this.skills=new wi(this._client),this.webhooks=new bt(this._client),this.userProfiles=new gt(this._client),this.dreams=new pt(this._client),this.tunnels=new bi(this._client),this.organization=new pi(this._client)}}return r.Models=_t,r.Messages=Bt,r.Agents=An,r.Environments=Kn,r.Sessions=gi,r.Deployments=ft,r.DeploymentRuns=ht,r.Vaults=yi,r.MemoryStores=Vn,r.Files=mt,r.Skills=wi,r.Webhooks=bt,r.UserProfiles=gt,r.Dreams=pt,r.Tunnels=bi,r.Organization=pi,r})();var nt=class extends h{create(n,e){let{betas:t,workspace_id:s,...i}=n;return this._client.post("/v1/complete",{body:i,timeout:this._client._options.timeout??6e5,...e,headers:u([{...t?.toString()!=null?{"anthropic-beta":t?.toString()}:void 0,...s!=null?{"anthropic-workspace-id":s}:void 0},e?.headers]),stream:n.stream??!1})}};var it=class extends h{list(n={},e){let{workspace_id:t,...s}=n??{};return this._client.getAPIList("/v1/files",w,{query:s,...e,headers:u([{...t!=null?{"anthropic-workspace-id":t}:void 0},e?.headers])})}delete(n,e={},t){let{workspace_id:s}=e??{};return this._client.delete(l`/v1/files/${n}`,{...t,headers:u([{...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers])})}download(n,e={},t){let{workspace_id:s}=e??{};return this._client.get(l`/v1/files/${n}/content`,{...t,headers:u([{Accept:"application/binary",...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers]),__binaryResponse:!0})}retrieveMetadata(n,e={},t){let{workspace_id:s}=e??{};return this._client.get(l`/v1/files/${n}`,{...t,headers:u([{...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers])})}upload(n,e){let{workspace_id:t,...s}=n;return this._client.post("/v1/files",J({body:s,...e,headers:u([{...t!=null?{"anthropic-workspace-id":t}:void 0},dn(s.file),e?.headers])},this._client))}};var ot=class extends h{retrieve(n,e={},t){let{betas:s,workspace_id:i}=e??{};return this._client.get(l`/v1/models/${n}`,{...t,headers:u([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0,...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}list(n={},e){let{betas:t,workspace_id:s,...i}=n??{};return this._client.getAPIList("/v1/models",C,{query:i,...e,headers:u([{...t?.toString()!=null?{"anthropic-beta":t?.toString()}:void 0,...s!=null?{"anthropic-workspace-id":s}:void 0},e?.headers])})}};var Pr=class extends h{retrieve(n,e){return this._client.get(l`/v1/organizations/api_keys/${n}`,e)}update(n,e,t){return this._client.post(l`/v1/organizations/api_keys/${n}`,{body:e,...t})}list(n={},e){return this._client.getAPIList("/v1/organizations/api_keys",C,{query:n,...e})}};var Rr=class extends h{retrieve(n){return this._client.get("/v1/organizations/compliance_settings",n)}update(n,e){return this._client.post("/v1/organizations/compliance_settings",{body:n,...e})}};var Ir=class extends h{create(n,e){return this._client.post("/v1/organizations/external_keys",{body:n,...e})}retrieve(n,e){return this._client.get(l`/v1/organizations/external_keys/${n}`,e)}update(n,e,t){return this._client.post(l`/v1/organizations/external_keys/${n}`,{body:e,...t})}list(n={},e){return this._client.getAPIList("/v1/organizations/external_keys",w,{query:n,...e})}delete(n,e){return this._client.delete(l`/v1/organizations/external_keys/${n}`,e)}validate(n,e){return this._client.post(l`/v1/organizations/external_keys/${n}/validate`,e)}};var Er=class extends h{create(n,e){return this._client.post("/v1/organizations/invites",{body:n,...e})}retrieve(n,e){return this._client.get(l`/v1/organizations/invites/${n}`,e)}list(n={},e){return this._client.getAPIList("/v1/organizations/invites",C,{query:n,...e})}delete(n,e){return this._client.delete(l`/v1/organizations/invites/${n}`,e)}};var Tr=class extends h{list(n={},e){return this._client.getAPIList("/v1/organizations/rate_limits",w,{query:n,...e})}};var Mr=class extends h{retrieve(n,e){return this._client.get(l`/v1/organizations/users/${n}`,e)}update(n,e,t){return this._client.post(l`/v1/organizations/users/${n}`,{body:e,...t})}list(n={},e){return this._client.getAPIList("/v1/organizations/users",C,{query:n,...e})}remove(n,e){return this._client.delete(l`/v1/organizations/users/${n}`,e)}};var Or=class extends h{create(n,e){return this._client.post("/v1/organizations/federation_issuers",{body:n,...e})}retrieve(n,e){return this._client.get(l`/v1/organizations/federation_issuers/${n}`,e)}update(n,e,t){return this._client.post(l`/v1/organizations/federation_issuers/${n}`,{body:e,...t})}list(n={},e){return this._client.getAPIList("/v1/organizations/federation_issuers",w,{query:n,...e})}archive(n,e){return this._client.post(l`/v1/organizations/federation_issuers/${n}/archive`,e)}};var Cr=class extends h{list(n,e={},t){return this._client.getAPIList(l`/v1/organizations/federation_rules/${n}/workspaces`,w,{query:e,...t})}add(n,e,t){return this._client.post(l`/v1/organizations/federation_rules/${n}/workspaces`,{body:e,...t})}remove(n,e,t){let{federation_rule_id:s}=e;return this._client.delete(l`/v1/organizations/federation_rules/${s}/workspaces/${n}`,t)}};var Ii=(()=>{class r extends h{constructor(){super(...arguments),this.workspaces=new Cr(this._client)}create(e,t){return this._client.post("/v1/organizations/federation_rules",{body:e,...t})}retrieve(e,t){return this._client.get(l`/v1/organizations/federation_rules/${e}`,t)}update(e,t,s){return this._client.post(l`/v1/organizations/federation_rules/${e}`,{body:t,...s})}list(e={},t){return this._client.getAPIList("/v1/organizations/federation_rules",w,{query:e,...t})}archive(e,t){return this._client.post(l`/v1/organizations/federation_rules/${e}/archive`,t)}}return r.Workspaces=Cr,r})();var Ei=(()=>{class r extends h{constructor(){super(...arguments),this.issuers=new Or(this._client),this.rules=new Ii(this._client)}}return r.Issuers=Or,r.Rules=Ii,r})();var $r=class extends h{list(n,e={},t){return this._client.getAPIList(l`/v1/organizations/service_accounts/${n}/workspaces`,w,{query:e,...t})}add(n,e,t){return this._client.post(l`/v1/organizations/service_accounts/${n}/workspaces`,{body:e,...t})}remove(n,e,t){let{service_account_id:s}=e;return this._client.delete(l`/v1/organizations/service_accounts/${s}/workspaces/${n}`,t)}};var Ti=(()=>{class r extends h{constructor(){super(...arguments),this.workspaces=new $r(this._client)}create(e,t){return this._client.post("/v1/organizations/service_accounts",{body:e,...t})}retrieve(e,t){return this._client.get(l`/v1/organizations/service_accounts/${e}`,t)}update(e,t,s){return this._client.post(l`/v1/organizations/service_accounts/${e}`,{body:t,...s})}list(e={},t){return this._client.getAPIList("/v1/organizations/service_accounts",w,{query:e,...t})}archive(e,t){return this._client.post(l`/v1/organizations/service_accounts/${e}/archive`,t)}}return r.Workspaces=$r,r})();var Nr=class extends h{retrieve(n,e,t){let{workspace_id:s}=e;return this._client.get(l`/v1/organizations/workspaces/${s}/members/${n}`,t)}update(n,e,t){let{workspace_id:s,...i}=e;return this._client.post(l`/v1/organizations/workspaces/${s}/members/${n}`,{body:i,...t})}list(n,e={},t){return this._client.getAPIList(l`/v1/organizations/workspaces/${n}/members`,C,{query:e,...t})}add(n,e,t){return this._client.post(l`/v1/organizations/workspaces/${n}/members`,{body:e,...t})}remove(n,e,t){let{workspace_id:s}=e;return this._client.delete(l`/v1/organizations/workspaces/${s}/members/${n}`,t)}};var Lr=class extends h{list(n,e={},t){return this._client.getAPIList(l`/v1/organizations/workspaces/${n}/rate_limits`,w,{query:e,...t})}};var Fr=class extends h{retrieve(n,e,t){let{workspace_id:s}=e;return this._client.get(l`/v1/organizations/workspaces/${s}/service_accounts/${n}`,t)}update(n,e,t){let{workspace_id:s,...i}=e;return this._client.post(l`/v1/organizations/workspaces/${s}/service_accounts/${n}`,{body:i,...t})}list(n,e={},t){return this._client.getAPIList(l`/v1/organizations/workspaces/${n}/service_accounts`,w,{query:e,...t})}add(n,e,t){return this._client.post(l`/v1/organizations/workspaces/${n}/service_accounts`,{body:e,...t})}remove(n,e,t){let{workspace_id:s}=e;return this._client.delete(l`/v1/organizations/workspaces/${s}/service_accounts/${n}`,t)}};var Mi=(()=>{class r extends h{constructor(){super(...arguments),this.rateLimits=new Lr(this._client),this.members=new Nr(this._client),this.serviceAccounts=new Fr(this._client)}create(e,t){return this._client.post("/v1/organizations/workspaces",{body:e,...t})}retrieve(e,t){return this._client.get(l`/v1/organizations/workspaces/${e}`,t)}update(e,t,s){return this._client.post(l`/v1/organizations/workspaces/${e}`,{body:t,...s})}list(e={},t){return this._client.getAPIList("/v1/organizations/workspaces",C,{query:e,...t})}archive(e,t){return this._client.post(l`/v1/organizations/workspaces/${e}/archive`,t)}}return r.RateLimits=Lr,r.Members=Nr,r.ServiceAccounts=Fr,r})();var Ls=(()=>{class r extends h{constructor(){super(...arguments),this.apiKeys=new Pr(this._client),this.externalKeys=new Ir(this._client),this.federation=new Ei(this._client),this.invites=new Er(this._client),this.serviceAccounts=new Ti(this._client),this.users=new Mr(this._client),this.workspaces=new Mi(this._client),this.rateLimits=new Tr(this._client),this.complianceSettings=new Rr(this._client)}retrieve(e){return this._client.get("/v1/organizations/me",e)}}return r.APIKeys=Pr,r.ExternalKeys=Ir,r.Federation=Ei,r.Invites=Er,r.ServiceAccounts=Ti,r.Users=Mr,r.Workspaces=Mi,r.RateLimits=Tr,r.ComplianceSettings=Rr,r})();var Br=class extends h{create(n,e,t){let{workspace_id:s,...i}=e;return this._client.post(l`/v1/skills/${n}/versions`,J({body:i,...t,headers:u([{...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers])},this._client,!1))}retrieve(n,e,t){let{skill_id:s,workspace_id:i}=e;return this._client.get(l`/v1/skills/${s}/versions/${n}`,{...t,headers:u([{...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}list(n,e={},t){let{workspace_id:s,...i}=e??{};return this._client.getAPIList(l`/v1/skills/${n}/versions`,w,{query:i,...t,headers:u([{...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers])})}delete(n,e,t){let{skill_id:s,workspace_id:i}=e;return this._client.delete(l`/v1/skills/${s}/versions/${n}`,{...t,headers:u([{...i!=null?{"anthropic-workspace-id":i}:void 0},t?.headers])})}};var Fs=(()=>{class r extends h{constructor(){super(...arguments),this.versions=new Br(this._client)}create(e,t){let{workspace_id:s,...i}=e;return this._client.post("/v1/skills",J({body:i,...t,headers:u([{...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers])},this._client,!1))}retrieve(e,t={},s){let{workspace_id:i}=t??{};return this._client.get(l`/v1/skills/${e}`,{...s,headers:u([{...i!=null?{"anthropic-workspace-id":i}:void 0},s?.headers])})}list(e={},t){let{workspace_id:s,...i}=e??{};return this._client.getAPIList("/v1/skills",w,{query:i,...t,headers:u([{...s!=null?{"anthropic-workspace-id":s}:void 0},t?.headers])})}delete(e,t={},s){let{workspace_id:i}=t??{};return this._client.delete(l`/v1/skills/${e}`,{...s,headers:u([{...i!=null?{"anthropic-workspace-id":i}:void 0},s?.headers])})}}return r.Versions=Br,r})();var Go,Yo,Oi,nl,sf="\\n\\nHuman:",nf="\\n\\nAssistant:",of=(()=>{class r{get credentials(){return this._authState.provider}constructor({baseURL:e=I("ANTHROPIC_BASE_URL"),apiKey:t,authToken:s,webhookKey:i=I("ANTHROPIC_WEBHOOK_SIGNING_KEY")??null,...o}={}){if(Go.add(this),this._requestAuthFlags=new WeakMap,Oi.set(this,void 0),t===void 0&&(t=o.profile!=null?null:I("ANTHROPIC_API_KEY")??null),s===void 0&&(s=o.profile!=null?null:I("ANTHROPIC_AUTH_TOKEN")??null),o.profile!=null&&(o.credentials!=null||o.config!=null))throw new TypeError("Pass at most one of `profile`, `credentials`, or `config`.");let c={apiKey:t,authToken:s,webhookKey:i,...o,baseURL:e||"https://api.anthropic.com"};if(!c.dangerouslyAllowBrowser&&na())throw new k(`It looks like you're running in a browser-like environment.
|
|
|
|
This is disabled by default, as it risks exposing your secret API credentials to attackers.
|
|
If you understand the risks and have appropriate mitigations in place,
|
|
you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
|
|
|
|
new Anthropic({ apiKey, dangerouslyAllowBrowser: true });
|
|
`);this.baseURL=c.baseURL,this._baseURLIsExplicit=o.__baseURLIsExplicit??!!e,this.timeout=c.timeout??Yo.DEFAULT_TIMEOUT,this.logger=c.logger??console,this.logLevel=Zr,this.logLevel=en(c.logLevel,"ClientOptions.logLevel",T(this))??en(I("ANTHROPIC_LOG"),"process.env['ANTHROPIC_LOG']",T(this))??Zr,this.fetchOptions=c.fetchOptions,this.maxRetries=Ws("maxRetries",c.maxRetries??2),this.fetch=c.fetch??ca(),m(this,Oi,ua,"f"),this.middleware=[...c.middleware??[]];let f=I("ANTHROPIC_CUSTOM_HEADERS");if(f){let b={};for(let p of f.split(`
|
|
`)){let g=p.indexOf(":");g>=0&&(b[p.substring(0,g).trim()]=p.substring(g+1).trim())}c.defaultHeaders={...b,...c.defaultHeaders}}let d=o.__auth;if(delete c.__auth,delete c.__baseURLIsExplicit,this._options=c,this.apiKey=typeof t=="string"?t:null,this.authToken=s,this.webhookKey=i,d)this._authState=d,!this._baseURLIsExplicit&&d.baseURL&&(this.baseURL=d.baseURL);else if(this._authState={provider:null,tokenCache:null,resolution:null,error:null,extraHeaders:{}},this.apiKey==null&&this.authToken==null){let b=c.credentials??null;if(b)this._authState.provider=b,this._authState.tokenCache=this._makeTokenCache(b);else if(c.config!=null){let p=Yi(c.config,this._credentialResolverOptions());this._authState.provider=p.provider,this._authState.tokenCache=this._makeTokenCache(p.provider),this._authState.extraHeaders=p.extraHeaders,this._applyCredentialBaseURL(p.baseURL)}else c.profile!=null?this._authState.resolution=this._resolveDefaultCredentials(c.profile):this._shouldResolveDefaultCredentials()&&(this._authState.resolution=this._resolveDefaultCredentials())}}_shouldResolveDefaultCredentials(){return!0}_applyCredentialBaseURL(e){if(!e)return;let t=e.replace(/\/+$/,"");this._authState.baseURL=t,this._baseURLIsExplicit||(this.baseURL=t)}_credentialResolverOptions(){return{baseURL:this.baseURL,fetch:this._credentialsFetch(),userAgent:this.getUserAgent(),onCacheWriteError:e=>{T(this).debug("credential cache write failed (best-effort)",e)},onSafetyWarning:e=>{T(this).warn(e)}}}_credentialsFetch(){return Zi(this.fetch,this.middleware,void 0,this)}_makeTokenCache(e){return new Ys(e,t=>{T(this).debug("advisory token refresh failed; serving cached token",t)})}withOptions(e){let t="credentials"in e||"config"in e||"profile"in e,s="apiKey"in e||"authToken"in e||t,i={...this._options,...this._baseURLIsExplicit?{baseURL:this.baseURL}:{},maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,middleware:this.middleware,apiKey:this.apiKey,authToken:this.authToken,webhookKey:this.webhookKey,credentials:this.credentials,...t?{credentials:void 0,config:void 0,profile:void 0}:{},...e,__auth:s?void 0:this._authState,__baseURLIsExplicit:"baseURL"in e?!0:this._baseURLIsExplicit};return new this.constructor(i)}async _resolveDefaultCredentials(e){try{let t=await Wa(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 k(`Profile "${e}" could not be resolved (no <config_dir>/configs/${e}.json found).`)}catch(t){this._authState.error=t}finally{this._authState.resolution=null}}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:e,nulls:t}){if(!(e.get("x-api-key")||e.get("authorization"))){if(this._authState.error)throw this._authState.error;if(!(this._authState.tokenCache||this._authState.resolution)&&!(this.apiKey&&e.get("x-api-key"))&&!t.has("x-api-key")&&!(this.authToken&&e.get("authorization"))&&!t.has("authorization"))throw new Error('Could not resolve authentication method. Expected one of apiKey, authToken, credentials, config, or profile to be set. Or for one of the "X-Api-Key" or "Authorization" headers to be explicitly omitted')}}_authFlags(e){let t=this._requestAuthFlags.get(e);return t||(t={usedTokenCache:!1,didRefreshFor401:!1},this._requestAuthFlags.set(e,t)),t}async authHeaders(e){if(this._authState.resolution&&await this._authState.resolution,!this._authState.error){if(this._authState.tokenCache&&this.apiKey==null){let t=await this._authState.tokenCache.getToken();return this._authFlags(e).usedTokenCache=!0,u([{Authorization:`Bearer ${t}`}])}return u([await this.apiKeyAuth(e),await this.bearerAuth(e)])}}async apiKeyAuth(e){if(this.apiKey!=null)return u([{"X-Api-Key":this.apiKey}])}async bearerAuth(e){if(this.authToken!=null)return u([{Authorization:`Bearer ${this.authToken}`}])}stringifyQuery(e){return ba(e)}getUserAgent(){return`Anthropic/JS ${ce}`}makeStatusError(e,t,s,i){return D.generate(e,t,s,i)}buildURL(e,t,s){let i=!a(this,Go,"m",nl).call(this)&&s||this.baseURL,o=Zo(e)?new URL(e):new URL(i+(i.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),c=this.defaultQuery(),f=Object.fromEntries(o.searchParams);return(!Li(c)||!Li(f))&&(t={...f,...c,...t}),typeof t=="object"&&t&&!Array.isArray(t)&&(o.search=this.stringifyQuery(t)),o.toString()}_calculateNonstreamingTimeout(e){if(3600*e/128e3>600)throw new k("Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#streaming-responses for more details");return 600*1e3}async prepareOptions(e){}async prepareRequest(e,{url:t,options:s}){if(this._authState.tokenCache&&this.apiKey==null){let i=e.headers instanceof Headers?e.headers:new Headers(e.headers);for(let[c,f]of Object.entries(this._authState.extraHeaders))i.has(c)||i.set(c,f);let o=i.get("anthropic-beta")?.split(",").map(c=>c.trim());o?.includes(Ke)||i.set("anthropic-beta",[...o??[],Ke].join(",")),e.headers=i}}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,s){return this.request(Promise.resolve(s).then(i=>({method:e,path:t,...i})))}request(e,t=null){return new nn(this,this.makeRequest(e,t,void 0))}async makeRequest(e,t,s){let i=await e,o=Ws("maxRetries",i.maxRetries??this.maxRetries);this.isStreamBody(i.body)&&(o=0),t==null&&(t=o,this._requestAuthFlags.delete(i)),await this.prepareOptions(i);let{req:c,url:f,timeout:d}=await this.buildRequest(i,{retryCount:o-t}),b="log_"+(Math.random()*(1<<24)|0).toString(16).padStart(6,"0"),p=s===void 0?"":`, retryOf: ${s}`,g=Date.now();if(i.signal?.aborted)throw new V;let y=new AbortController,_=await this.fetchWithTimeout(f,c,d,y,i,{requestLogID:b,retryOfRequestLogID:s}).catch(qe),v=Date.now();if(_ instanceof globalThis.Error){me(y);let S=`retrying, ${t} attempts remaining`;if(i.signal?.aborted)throw new V;let E=de(_)||/timed? ?out/i.test(String(_)+("cause"in _?String(_.cause):"")),x=this.middleware.length>0||!!i.middleware?.length||this.backendMiddleware().length>0;if(x&&!E&&!Ua(_))throw T(this).info(`[${b}] middleware error (not retryable)`),be(T(this),`[${b}] middleware error (not retryable)`,{retryOfRequestLogID:s,url:f,durationMs:v-g,message:_.message}),_;if(t)return T(this).info(`[${b}] connection ${E?"timed out":"failed"} - ${S}`),be(T(this),`[${b}] connection ${E?"timed out":"failed"} (${S})`,{retryOfRequestLogID:s,url:f,durationMs:v-g,message:_.message}),this.retryRequest(i,t,s??b);throw T(this).info(`[${b}] connection ${E?"timed out":"failed"} - error; no more retries left`),be(T(this),`[${b}] connection ${E?"timed out":"failed"} (error; no more retries left)`,{retryOfRequestLogID:s,url:f,durationMs:v-g,message:_.message}),E?new Wr:x&&!Qi(_)?_:new Ae({cause:_})}let A=[..._.headers.entries()].filter(([S])=>S==="request-id"||S==="anthropic-workspace-id").map(([S,E])=>", "+S+": "+JSON.stringify(E)).join(""),R=`[${b}${p}${A}] ${c.method} ${f} ${_.ok?"succeeded":"failed"} with status ${_.status} in ${v-g}ms`;if(!_.ok){let S=await this.shouldRetry(_,i);if(t&&S){let F=`retrying, ${t} attempts remaining`;return await la(_.body),me(y),T(this).info(`${R} - ${F}`),be(T(this),`[${b}] response error (${F})`,{retryOfRequestLogID:s,url:_.url,status:_.status,headers:_.headers,durationMs:v-g}),this.retryRequest(i,t,s??b,_.headers)}let E=S?"error; no more retries left":"error; not retryable";T(this).info(`${R} - ${E}`);let x=await _.text().catch(F=>qe(F).message),P=Ds(x),L=P?void 0:x;throw be(T(this),`[${b}] response error (${E})`,{retryOfRequestLogID:s,url:_.url,status:_.status,headers:_.headers,message:L,durationMs:Date.now()-g}),me(y),this.makeStatusError(_.status,P,L,_.headers)}return T(this).info(R),be(T(this),`[${b}] response start`,{retryOfRequestLogID:s,url:_.url,status:_.status,headers:_.headers,durationMs:v-g}),aa(_.body??_,y),{response:_,options:i,controller:y,requestLogID:b,retryOfRequestLogID:s,startTime:g}}getAPIList(e,t,s){return this.requestAPIList(t,s&&"then"in s?s.then(i=>({method:"get",path:e,...i})):{method:"get",path:e,...s})}requestAPIList(e,t){let s=this.makeRequest(t,null,void 0);return new ja(this,s,e)}async fetchWithTimeout(e,t,s,i,o,c){let{signal:f,method:d,...b}=t||{},p=this._makeAbort(i);f&&(f.addEventListener("abort",p,{once:!0}),oa(i,f,p));let g=globalThis.ReadableStream&&b.body instanceof globalThis.ReadableStream||typeof b.body=="object"&&b.body!==null&&Symbol.asyncIterator in b.body,y={signal:i.signal,...g?{duplex:"half"}:{},method:"GET",...b};d&&(y.method=d.toUpperCase());let _=this.fetch,v=async(x,P)=>{let L=setTimeout(p,s);try{return await _.call(void 0,x,P)}finally{clearTimeout(L)}},A=o===void 0?v:(async(x,P={})=>{let L=typeof x=="string"?x:x instanceof URL?x.href:x.url;return P.headers=P.headers instanceof Headers?P.headers:new Headers(P.headers),await this.prepareRequest(P,{url:L,options:o}),c&&be(T(this),`[${c.requestLogID}] sending request`,{retryOfRequestLogID:c.retryOfRequestLogID,method:P.method,url:L,options:o,headers:P.headers}),v(x,P)}),R=o?.middleware,S=this.backendMiddleware(),E=R?.length||S.length?[...this.middleware,...R??[],...S]:this.middleware;return await Zi(A,E,o,this)(e,y)}async shouldRetry(e,t){let s=this._authFlags(t);if(e.status===401&&this._authState.tokenCache&&s.usedTokenCache&&!s.didRefreshFor401)return s.didRefreshFor401=!0,this._authState.tokenCache.invalidate(),!0;let i=e.headers.get("x-should-retry");return i==="true"?!0:i==="false"?!1:e.status===408||e.status===409||e.status===429||e.status>=500}async retryRequest(e,t,s,i){let o,c=i?.get("retry-after-ms");if(c){let d=parseFloat(c);Number.isNaN(d)||(o=d)}let f=i?.get("retry-after");if(f&&!o){let d=parseFloat(f);Number.isNaN(d)?o=Date.parse(f)-Date.now():o=d*1e3}if(o===void 0||!(o>0&&o<=2**31-1)){let d=e.maxRetries??this.maxRetries;o=this.calculateDefaultRetryTimeoutMillis(t,d)}return await he(o,e.signal??void 0),this.makeRequest(e,t-1,s)}calculateDefaultRetryTimeoutMillis(e,t){let o=t-e,c=Math.min(.5*Math.pow(2,o),8),f=1-Math.random()*.25;return c*f*1e3}calculateNonstreamingTimeout(e,t){if(36e5*e/128e3>6e5||t!=null&&e>t)throw new k("Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#long-requests for more details");return 6e5}async buildRequest(e,{retryCount:t=0}={}){let s={...e},{method:i,path:o,query:c,defaultBaseURL:f}=s;this._authState.resolution&&await this._authState.resolution,!this._baseURLIsExplicit&&this._authState.baseURL&&this.baseURL!==this._authState.baseURL&&(this.baseURL=this._authState.baseURL);let d=this.buildURL(o,c,f);"timeout"in s&&Ws("timeout",s.timeout),s.timeout=s.timeout??this.timeout;let{bodyHeaders:b,body:p}=this.buildBody({options:s}),g=await this.buildHeaders({options:e,method:i,bodyHeaders:b,retryCount:t,timeout:s.timeout});return{req:{method:i,headers:g,...s.signal&&{signal:s.signal},...globalThis.ReadableStream&&p instanceof globalThis.ReadableStream&&{duplex:"half"},...p&&{body:p},...this.fetchOptions??{},...s.fetchOptions??{}},url:d,timeout:s.timeout}}async buildHeaders({options:e,method:t,bodyHeaders:s,retryCount:i,timeout:o}){let c=u([{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(i),"X-Stainless-Timeout":String(Math.trunc(o/1e3)),...Yr(),...this._options.dangerouslyAllowBrowser?{"anthropic-dangerous-direct-browser-access":"true"}:void 0,"anthropic-version":"2023-06-01"},await this.authHeaders(e),this._options.defaultHeaders,s,e.headers]);return this.validateHeaders(c),c.values}_makeAbort(e){return()=>e.abort()}buildBody({options:{body:e,headers:t}}){if(!e)return{bodyHeaders:void 0,body:void 0};let s=u([t]);return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof DataView||typeof e=="string"&&s.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:qs(e)}:typeof e=="object"&&s.values.get("content-type")==="application/x-www-form-urlencoded"?{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery(e)}:a(this,Oi,"f").call(this,{body:e,headers:s})}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 Yo=r,Oi=new WeakMap,Go=new WeakSet,nl=function(){return this.baseURL!=="https://api.anthropic.com"},r.Anthropic=Yo,r.DEFAULT_TIMEOUT=6e5,r.AnthropicError=k,r.APIError=D,r.APIConnectionError=Ae,r.APIConnectionTimeoutError=Wr,r.APIUserAbortError=V,r.NotFoundError=Ur,r.ConflictError=jr,r.RateLimitError=Vr,r.BadRequestError=Dr,r.AuthenticationError=zr,r.InternalServerError=Jr,r.PermissionDeniedError=qr,r.UnprocessableEntityError=Kr,r.toFile=io,r.HUMAN_PROMPT=sf,r.AI_PROMPT=nf,r})(),il=(()=>{class r extends of{constructor(){super(...arguments),this.completions=new nt(this),this.messages=new ds(this),this.models=new ot(this),this.files=new it(this),this.skills=new Fs(this),this.organization=new Ls(this),this.beta=new Ns(this)}}return r.Completions=nt,r.Messages=ds,r.Models=ot,r.Files=it,r.Skills=Fs,r.Organization=Ls,r.Beta=Ns,r})();export{il as default};
|