diora-web/static/vendor/anthropic-sdk-0.133.0.mjs

21 lines
213 KiB
JavaScript
Raw Normal View History

/* @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+
`):[]}}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
${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-
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!=
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}`}ma