dsh-open-artifact 0.19.1 → 0.19.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/lib/client.js +1 -1
- package/lib/index.js +3 -3
- package/package.json +1 -1
- package/skills/open-artifact/SKILL.md +1 -1
- package/vendor/home/assets/{browser-models-CuvEg0Hm.js → browser-models-CEM3keW0.js} +4 -4
- package/vendor/home/assets/{main-Bfz_QbAb.js → main-CD6mLXro.js} +2 -2
- package/vendor/home/assets/main-CudjUC-z.css +1 -0
- package/vendor/home/assets/{node.browser-Dg3f5wnV.js → node.browser-5FosC0Jx.js} +1 -1
- package/vendor/home/assets/{node.browser-CA5eNPFK.js → node.browser-DZzq1E_m.js} +1 -1
- package/vendor/home/index.html +2 -2
- package/vendor/open-artifact.mjs +19 -8
- package/vendor/runtime.json +1 -1
- package/vendor/shell/assets/{browser-models-D6sLTStW.js → browser-models-DiCdSmg7.js} +4 -4
- package/vendor/shell/assets/index-CudjUC-z.css +1 -0
- package/vendor/{type-server/shell/assets/index-DUlkQIc2.js → shell/assets/index-K1SKNjv-.js} +19 -19
- package/vendor/shell/assets/{node.browser-Dom693pr.js → node.browser-DF3wedOZ.js} +1 -1
- package/vendor/shell/assets/{node.browser-JBLNXGXd.js → node.browser-mz1-CgQF.js} +1 -1
- package/vendor/shell/index.html +2 -2
- package/vendor/type-server/cli.mjs +26 -4
- package/vendor/type-server/editors/design/assets/{index-CWVS8sEC.js → index-UWsnN0RP.js} +118 -118
- package/vendor/type-server/editors/design/index.html +1 -1
- package/vendor/type-server/editors/slides/assets/{index-DNd0a5AT.js → index-Cd8_0xQf.js} +103 -103
- package/vendor/type-server/editors/slides/assets/{src-QKaUghQ7.js → src-YYMn9WN3.js} +1 -1
- package/vendor/type-server/editors/slides/index.html +1 -1
- package/vendor/type-server/editors/whiteboard/assets/{gif-jobs-CvntHyno.js → gif-jobs-D1FISsUT.js} +1 -1
- package/vendor/type-server/editors/whiteboard/assets/{index-ifqwq1AR.js → index-BfYFnyuU.js} +89 -89
- package/vendor/type-server/editors/whiteboard/assets/{index-BIiUMoHl.js → index-C7gRSC0a.js} +2 -2
- package/vendor/type-server/editors/whiteboard/index.html +1 -1
- package/vendor/type-server/shell/assets/{browser-models-D6sLTStW.js → browser-models-DiCdSmg7.js} +4 -4
- package/vendor/type-server/shell/assets/index-CudjUC-z.css +1 -0
- package/vendor/{shell/assets/index-DUlkQIc2.js → type-server/shell/assets/index-K1SKNjv-.js} +19 -19
- package/vendor/type-server/shell/assets/{node.browser-Dom693pr.js → node.browser-DF3wedOZ.js} +1 -1
- package/vendor/type-server/shell/assets/{node.browser-JBLNXGXd.js → node.browser-mz1-CgQF.js} +1 -1
- package/vendor/type-server/shell/index.html +2 -2
- package/vendor/home/assets/main-DK7ftEF8.css +0 -1
- package/vendor/shell/assets/index-DK7ftEF8.css +0 -1
- package/vendor/type-server/shell/assets/index-DK7ftEF8.css +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/node.browser-
|
|
2
|
-
import{_ as Fe,O as L,S as Bi,s as Uf,r as Ff}from"./main-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/node.browser-5FosC0Jx.js","assets/main-CD6mLXro.js","assets/RuntimeUpdate-kcFXr6yv.js","assets/main-CudjUC-z.css","assets/node.browser-DZzq1E_m.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{_ as Fe,O as L,S as Bi,s as Uf,r as Ff}from"./main-CD6mLXro.js";import{bK as ki,bL as xs,bM as r_,bN as Wf,bO as Ts,bP as jf,bQ as Hf,bR as Kf,bS as Df,bT as n_,bU as Lc,bV as Gf,bW as Vf,bX as Jf,bY as Yf,bZ as Uc,b_ as i_,b$ as Xf,bp as Dr,c0 as Qf,c1 as Zf,c2 as eg,c3 as tg,bk as Ei,bj as Fc,c4 as As,c5 as rg,c6 as ng,c7 as ig,c8 as sg,a$ as Ct,bq as ag,c9 as og}from"./RuntimeUpdate-kcFXr6yv.js";const s_=/^[a-z0-9][a-z0-9._-]{0,40}$/i;class N extends Error{code;text;status;modelNotFound;detail;constructor(n,e,r={}){super(e),this.name="SampleFailure",this.code=n,r.text!==void 0&&(this.text=r.text),r.status!==void 0&&(this.status=r.status),r.modelNotFound&&(this.modelNotFound=!0),r.detail&&(this.detail=r.detail)}toJSON(){return{code:this.code,message:this.message,...this.text?{text:this.text}:{}}}}const Ii="[key]",Wc=6;function li(t,n){if(!n||n.length<Wc||!t)return t;let e=t.split(n).join(Ii);for(let r=n.length-1;r>=Wc;r--){const i=n.slice(0,r),s=n.slice(n.length-r);e.includes(i)&&(e=e.split(i).join(Ii)),e.includes(s)&&(e=e.split(s).join(Ii))}return e}function cg(t,n){const e=li(t.message,n),r=t.detail===void 0?void 0:li(t.detail,n);return e===t.message&&r===t.detail?t:new N(t.code,e,{...t.text!==void 0?{text:t.text}:{},...t.status!==void 0?{status:t.status}:{},...t.modelNotFound?{modelNotFound:!0}:{},...r?{detail:r}:{}})}const jc="refused the key. Check the key in the model settings.",a_="answered with a redirect, which Open Artifact does not follow. Enter the final address of the endpoint in the model settings.",o_={redirect:"manual"};function c_(t){return t.type==="opaqueredirect"||t.status>=300&&t.status<400}function Se(t){if(t instanceof N)return t;const n=t instanceof Error?t.message:String(t);return new N("upstream_error",n||"The model source failed.")}function se(t){return new N("cancelled","The call was cancelled.",t?{text:t}:{})}const lg=/context(?:[ _-]length| window)|too long|too many tokens|maximum (?:context|input|prompt)|exceeds? the (?:maximum|limit)|prompt is too large|input is too large|token limit/i,ug=/api[ _-]?key|API_KEY_INVALID|unauthenticated|invalid authentication|permission denied/i,dg=/model\b[^.]*\b(?:not found|does not exist|not exist|unknown|is not supported|not available|unavailable)|no such model|unknown model|model_not_found|invalid model/i;function Xs(t,n,e){const r=n?`${e}: ${n}`:`${e} answered HTTP ${t}.`;return t===401||t===403?new N("session_expired",`${e} ${jc}`,{status:t,...n?{detail:n}:{}}):t===429?new N("rate_limited",r,{status:t}):t===413?new N("prompt_too_large",r,{status:t}):t===404?new N("upstream_error",r,{status:t,modelNotFound:!0}):t===400||t===422?ug.test(n)&&/invalid|not valid|missing|expired/i.test(n)?new N("session_expired",`${e} ${jc}`,{status:t,detail:n}):lg.test(n)?new N("prompt_too_large",r,{status:t}):dg.test(n)?new N("upstream_error",r,{status:t,modelNotFound:!0}):new N("invalid_request",r,{status:t}):new N("upstream_error",r,{status:t})}function Qs(t){try{const n=JSON.parse(t),r=Array.isArray(n)?n[0]:n;if(r&&typeof r.error=="object"&&r.error!==null){const i=r.error,s=Array.isArray(i.details)?i.details.map(l=>l?.reason).find(l=>typeof l=="string"):void 0,c=[typeof i.message=="string"?i.message:"",typeof s=="string"?`(${s})`:""].filter(Boolean).join(" ");if(c)return c}if(r&&typeof r.error=="string")return r.error;if(r&&typeof r.message=="string")return r.message}catch{}return t.trim().slice(0,500)}function l_(t,n){const e=new AbortController;let r=null,i,s;const a=d=>{e.signal.aborted||(r=d,e.abort(new Error(d==="idle"?"The model source went silent.":"The round ran out of time.")))},c=()=>{e.signal.aborted||e.abort(t.reason)};t.aborted?c():t.addEventListener("abort",c,{once:!0}),n.timeoutMs&&(i=setTimeout(()=>a("timeout"),n.timeoutMs));const l=()=>{!n.idleMs||e.signal.aborted||(s&&clearTimeout(s),s=setTimeout(()=>a("idle"),n.idleMs))};return l(),{signal:e.signal,reason:()=>r,touch:l,dispose:()=>{i&&clearTimeout(i),s&&clearTimeout(s),t.removeEventListener("abort",c)}}}async function*u_(t,n){const e=t.getReader(),r=new TextDecoder;let i="",s=[],a;const c=()=>{if(!s.length)return a=void 0,null;const l=a===void 0?{data:s.join(`
|
|
3
3
|
`)}:{event:a,data:s.join(`
|
|
4
4
|
`)};return s=[],a=void 0,l};try{for(;;){const{value:l,done:d}=await e.read();if(d)break;n?.(),i+=r.decode(l,{stream:!0});let _;for(;(_=i.indexOf(`
|
|
5
5
|
`))>=0;){const h=i.slice(0,_).replace(/\r$/,"");if(i=i.slice(_+1),h===""){const y=c();y&&(yield y);continue}if(h.startsWith(":"))continue;const p=h.indexOf(":"),f=p<0?h:h.slice(0,p);let b=p<0?"":h.slice(p+1);b.startsWith(" ")&&(b=b.slice(1)),f==="data"?s.push(b):f==="event"&&(a=b)}}if(!i.trim()){const l=c();l&&(yield l)}}finally{e.releaseLock()}}function hg(t,n){const e=typeof t=="string"?[{role:"user",content:t}]:t,r=[];for(const a of e){const c=r[r.length-1];c&&c.role===a.role?c.content=`${c.content}
|
|
@@ -54,10 +54,10 @@ ${a}`}:e.push({role:"user",content:a})}else e.push(i);return e}}function Kg(t){r
|
|
|
54
54
|
${s.map(p=>p.error).join(`
|
|
55
55
|
`)}
|
|
56
56
|
${a}
|
|
57
|
-
${h}`)}return a},m=bb(bp);var Ea=(()=>{class t extends R{}return t._errorName="FileNotDownloadableError",t})(),Sa=(()=>{class t extends R{}return t._errorName="StorageQuotaExceededError",t})(),xa=(()=>{class t extends Ye{}return t._errorName="FileExpiredError",t})(),yl=(()=>{class t extends k{list(e={},r){const{workspace_id:i,...s}=e??{};return this._client.getAPIList("/v1/files",z,{query:s,...r,headers:g([{...i!=null?{"anthropic-workspace-id":i}:void 0},r?.headers]),__span:u(this._client,"anthropic.files.list",r,{route:"/v1/files",queryParams:["ids","limit","page"]})})}delete(e,r={},i){const{workspace_id:s}=r??{};return this._client.delete(m`/v1/files/${e}`,{...i,headers:g([{...s!=null?{"anthropic-workspace-id":s}:void 0},i?.headers]),__span:u(this._client,"anthropic.files.delete",i,{route:"/v1/files/{file_id}",attributes:{"anthropic.file.id":e}})})}download(e,r={},i){const{workspace_id:s}=r??{};return this._client.get(m`/v1/files/${e}/content`,{...i,headers:g([{Accept:"application/binary",...s!=null?{"anthropic-workspace-id":s}:void 0},i?.headers]),__binaryResponse:!0,__span:u(this._client,"anthropic.files.download",i,{route:"/v1/files/{file_id}/content",attributes:{"anthropic.file.id":e}})})}retrieveMetadata(e,r={},i){const{workspace_id:s}=r??{};return this._client.get(m`/v1/files/${e}`,{...i,headers:g([{...s!=null?{"anthropic-workspace-id":s}:void 0},i?.headers]),__span:u(this._client,"anthropic.files.retrieve_metadata",i,{route:"/v1/files/{file_id}",attributes:{"anthropic.file.id":e}})})}upload(e,r){const{workspace_id:i,...s}=e;return this._client.post("/v1/files",Xe({body:s,...r,headers:g([{...i!=null?{"anthropic-workspace-id":i}:void 0},yp(s.file),r?.headers]),__span:u(this._client,"anthropic.files.upload",r,{route:"/v1/files",createdIDAttribute:"anthropic.file.id"})},this._client))}}return t.FileNotDownloadableError=Ea,t.StorageQuotaExceededError=Sa,t.FileExpiredError=xa,t})(),wp=(()=>{class t extends R{}return t._errorName="ClaudeCodeKeyCreatorNotMemberError",t})(),vp=(()=>{class t extends R{}return t._errorName="ClaudeCodeVersionTooOldError",t})(),kp=(()=>{class t extends R{}return t._errorName="CMEKKeyDisabledError",t})(),Ep=(()=>{class t extends R{}return t._errorName="CMEKKeyNetworkBlockedError",t})(),Sp=(()=>{class t extends R{}return t._errorName="OrganizationOnHoldError",t})(),xp=(()=>{class t extends R{}return t._errorName="OrganizationTypeNotSupportedError",t})(),Tp=(()=>{class t extends R{}return t._errorName="ParentOrganizationRequiredError",t})(),Ap=(()=>{class t extends R{}return t._errorName="RequestBodyEncodingInvalidError",t})(),Rp=(()=>{class t extends R{}return t._errorName="RequestBodyEncodingUnsupportedError",t})(),zp=(()=>{class t extends R{}return t._errorName="WorkspaceHumanReviewDisabledError",t})(),Pp=(()=>{class t extends Si{}return t._errorName="LinkedOrganizationBillingUnavailableError",t})(),Cp=(()=>{class t extends Si{}return t._errorName="LinkedOrganizationSpendLimitReachedError",t})(),Op=(()=>{class t extends oe{}return t._errorName="SandboxEgressRestrictedError",t})(),Np=(()=>{class t extends na{}return t._errorName="RequestBodyTooLargeAfterDecodingError",t})(),Mp=(()=>{class t extends rn{}return t._errorName="ContractSpendLimitReachedError",t})(),$p=(()=>{class t extends rn{}return t._errorName="EnforcedSpendLimitReachedError",t})(),Bp=(()=>{class t extends rn{}return t._errorName="RampLimitExceededError",t})(),Ip=(()=>{class t extends ot{}return t._errorName="CMEKContextUnavailableError",t})(),qp=(()=>{class t extends ot{}return t._errorName="CMEKKeyUnreachableError",t})();class bl extends k{retrieve(n,e={},r){const{betas:i,workspace_id:s}=e??{};return this._client.get(m`/v1/deployment_runs/${n}`,{...r,headers:g([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.deployment_runs.retrieve",r,{route:"/v1/deployment_runs/{deployment_run_id}",attributes:{"anthropic.deployment_run.id":n}})})}list(n={},e){const{betas:r,workspace_id:i,...s}=n??{};return this._client.getAPIList("/v1/deployment_runs",z,{query:s,...e,headers:g([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.deployment_runs.list",e,{route:"/v1/deployment_runs",queryParams:["created_at[gt]","created_at[gte]","created_at[lt]","created_at[lte]","deployment_id","has_error","limit","page","trigger_type"]})})}}class wl extends k{create(n,e){const{betas:r,workspace_id:i,...s}=n;return this._client.post("/v1/deployments",{body:s,...e,headers:g([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.deployments.create",e,{route:"/v1/deployments",createdIDAttribute:"anthropic.deployment.id"})})}retrieve(n,e={},r){const{betas:i,workspace_id:s}=e??{};return this._client.get(m`/v1/deployments/${n}`,{...r,headers:g([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.deployments.retrieve",r,{route:"/v1/deployments/{deployment_id}",attributes:{"anthropic.deployment.id":n}})})}update(n,e,r){const{betas:i,workspace_id:s,...a}=e;return this._client.post(m`/v1/deployments/${n}`,{body:a,...r,headers:g([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.deployments.update",r,{route:"/v1/deployments/{deployment_id}",attributes:{"anthropic.deployment.id":n}})})}list(n={},e){const{betas:r,workspace_id:i,...s}=n??{};return this._client.getAPIList("/v1/deployments",z,{query:s,...e,headers:g([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.deployments.list",e,{route:"/v1/deployments",queryParams:["agent_id","created_at[gte]","created_at[lte]","include_archived","limit","page","status"]})})}archive(n,e={},r){const{betas:i,workspace_id:s}=e??{};return this._client.post(m`/v1/deployments/${n}/archive`,{...r,headers:g([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.deployments.archive",r,{route:"/v1/deployments/{deployment_id}/archive",attributes:{"anthropic.deployment.id":n}})})}pause(n,e={},r){const{betas:i,workspace_id:s}=e??{};return this._client.post(m`/v1/deployments/${n}/pause`,{...r,headers:g([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.deployments.pause",r,{route:"/v1/deployments/{deployment_id}/pause",attributes:{"anthropic.deployment.id":n}})})}run(n,e={},r){const{betas:i,workspace_id:s}=e??{};return this._client.post(m`/v1/deployments/${n}/run`,{...r,headers:g([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.deployments.run",r,{route:"/v1/deployments/{deployment_id}/run",attributes:{"anthropic.deployment.id":n}})})}unpause(n,e={},r){const{betas:i,workspace_id:s}=e??{};return this._client.post(m`/v1/deployments/${n}/unpause`,{...r,headers:g([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.deployments.unpause",r,{route:"/v1/deployments/{deployment_id}/unpause",attributes:{"anthropic.deployment.id":n}})})}}class vl extends k{create(n,e){const{betas:r,workspace_id:i,...s}=n;return this._client.post("/v1/dreams",{body:s,...e,headers:g([{"anthropic-beta":[...r??[],"dreaming-2026-04-21"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.dreams.create",e,{route:"/v1/dreams",createdIDAttribute:"anthropic.dream.id"})})}retrieve(n,e={},r){const{betas:i,workspace_id:s}=e??{};return this._client.get(m`/v1/dreams/${n}`,{...r,headers:g([{"anthropic-beta":[...i??[],"dreaming-2026-04-21"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.dreams.retrieve",r,{route:"/v1/dreams/{dream_id}",attributes:{"anthropic.dream.id":n}})})}list(n={},e){const{betas:r,workspace_id:i,...s}=n??{};return this._client.getAPIList("/v1/dreams",z,{query:s,...e,headers:g([{"anthropic-beta":[...r??[],"dreaming-2026-04-21"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.dreams.list",e,{route:"/v1/dreams",queryParams:["created_at[gt]","created_at[lt]","include_archived","limit","page","statuses"]})})}archive(n,e={},r){const{betas:i,workspace_id:s}=e??{};return this._client.post(m`/v1/dreams/${n}/archive`,{...r,headers:g([{"anthropic-beta":[...i??[],"dreaming-2026-04-21"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.dreams.archive",r,{route:"/v1/dreams/{dream_id}/archive",attributes:{"anthropic.dream.id":n}})})}cancel(n,e={},r){const{betas:i,workspace_id:s}=e??{};return this._client.post(m`/v1/dreams/${n}/cancel`,{...r,headers:g([{"anthropic-beta":[...i??[],"dreaming-2026-04-21"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.dreams.cancel",r,{route:"/v1/dreams/{dream_id}/cancel",attributes:{"anthropic.dream.id":n}})})}}class kl extends k{list(n={},e){const{betas:r,workspace_id:i,...s}=n??{};return this._client.getAPIList("/v1/files",z,{query:s,...e,headers:g([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0,...i!=null?{"anthropic-workspace-id":i}:void 0},e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.files.list",e,{route:"/v1/files",queryParams:["ids","limit","page","scope_id"]})})}delete(n,e={},r){const{betas:i,workspace_id:s}=e??{};return this._client.delete(m`/v1/files/${n}`,{...r,headers:g([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.files.delete",r,{route:"/v1/files/{file_id}",attributes:{"anthropic.file.id":n}})})}download(n,e={},r){const{betas:i,workspace_id:s}=e??{};return this._client.get(m`/v1/files/${n}/content`,{...r,headers:g([{Accept:"application/binary",...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__binaryResponse:!0,__span:u(this._client,"anthropic.files.download",r,{route:"/v1/files/{file_id}/content",attributes:{"anthropic.file.id":n}})})}retrieveMetadata(n,e={},r){const{betas:i,workspace_id:s}=e??{};return this._client.get(m`/v1/files/${n}`,{...r,headers:g([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.files.retrieve_metadata",r,{route:"/v1/files/{file_id}",attributes:{"anthropic.file.id":n}})})}upload(n,e){const{betas:r,workspace_id:i,...s}=n;return this._client.post("/v1/files",Xe({body:s,...e,headers:g([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0,...i!=null?{"anthropic-workspace-id":i}:void 0},yp(s.file),e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.files.upload",e,{route:"/v1/files",createdIDAttribute:"anthropic.file.id"})},this._client))}}let El=class extends k{retrieve(n,e={},r){const{betas:i,workspace_id:s}=e??{};return this._client.get(m`/v1/models/${n}`,{...r,headers:g([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.models.retrieve",r,{route:"/v1/models/{model_id}",attributes:{"anthropic.model.id":n}})})}list(n={},e){const{betas:r,workspace_id:i,...s}=n??{};return this._client.getAPIList("/v1/models",de,{query:s,...e,headers:g([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0,...i!=null?{"anthropic-workspace-id":i}:void 0},e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.models.list",e,{route:"/v1/models",queryParams:["after_id","before_id","lifecycle","limit"]})})}};var ct={},_e={},Sl;function wb(){if(Sl)return _e;Sl=1;var t=_e&&_e.__extends||(function(){var _=function(h,p){return _=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(f,b){f.__proto__=b}||function(f,b){for(var y in b)b.hasOwnProperty(y)&&(f[y]=b[y])},_(h,p)};return function(h,p){_(h,p);function f(){this.constructor=h}h.prototype=p===null?Object.create(p):(f.prototype=p.prototype,new f)}})();Object.defineProperty(_e,"__esModule",{value:!0});var n=256,e=(function(){function _(h){h===void 0&&(h="="),this._paddingCharacter=h}return _.prototype.encodedLength=function(h){return this._paddingCharacter?(h+2)/3*4|0:(h*8+5)/6|0},_.prototype.encode=function(h){for(var p="",f=0;f<h.length-2;f+=3){var b=h[f]<<16|h[f+1]<<8|h[f+2];p+=this._encodeByte(b>>>18&63),p+=this._encodeByte(b>>>12&63),p+=this._encodeByte(b>>>6&63),p+=this._encodeByte(b>>>0&63)}var y=h.length-f;if(y>0){var b=h[f]<<16|(y===2?h[f+1]<<8:0);p+=this._encodeByte(b>>>18&63),p+=this._encodeByte(b>>>12&63),y===2?p+=this._encodeByte(b>>>6&63):p+=this._paddingCharacter||"",p+=this._paddingCharacter||""}return p},_.prototype.maxDecodedLength=function(h){return this._paddingCharacter?h/4*3|0:(h*6+7)/8|0},_.prototype.decodedLength=function(h){return this.maxDecodedLength(h.length-this._getPaddingLength(h))},_.prototype.decode=function(h){if(h.length===0)return new Uint8Array(0);for(var p=this._getPaddingLength(h),f=h.length-p,b=new Uint8Array(this.maxDecodedLength(f)),y=0,w=0,E=0,S=0,T=0,x=0,A=0;w<f-4;w+=4)S=this._decodeChar(h.charCodeAt(w+0)),T=this._decodeChar(h.charCodeAt(w+1)),x=this._decodeChar(h.charCodeAt(w+2)),A=this._decodeChar(h.charCodeAt(w+3)),b[y++]=S<<2|T>>>4,b[y++]=T<<4|x>>>2,b[y++]=x<<6|A,E|=S&n,E|=T&n,E|=x&n,E|=A&n;if(w<f-1&&(S=this._decodeChar(h.charCodeAt(w)),T=this._decodeChar(h.charCodeAt(w+1)),b[y++]=S<<2|T>>>4,E|=S&n,E|=T&n),w<f-2&&(x=this._decodeChar(h.charCodeAt(w+2)),b[y++]=T<<4|x>>>2,E|=x&n),w<f-3&&(A=this._decodeChar(h.charCodeAt(w+3)),b[y++]=x<<6|A,E|=A&n),E!==0)throw new Error("Base64Coder: incorrect characters for decoding");return b},_.prototype._encodeByte=function(h){var p=h;return p+=65,p+=25-h>>>8&6,p+=51-h>>>8&-75,p+=61-h>>>8&-15,p+=62-h>>>8&3,String.fromCharCode(p)},_.prototype._decodeChar=function(h){var p=n;return p+=(42-h&h-44)>>>8&-n+h-43+62,p+=(46-h&h-48)>>>8&-n+h-47+63,p+=(47-h&h-58)>>>8&-n+h-48+52,p+=(64-h&h-91)>>>8&-n+h-65+0,p+=(96-h&h-123)>>>8&-n+h-97+26,p},_.prototype._getPaddingLength=function(h){var p=0;if(this._paddingCharacter){for(var f=h.length-1;f>=0&&h[f]===this._paddingCharacter;f--)p++;if(h.length<4||p>2)throw new Error("Base64Coder: incorrect padding")}return p},_})();_e.Coder=e;var r=new e;function i(_){return r.encode(_)}_e.encode=i;function s(_){return r.decode(_)}_e.decode=s;var a=(function(_){t(h,_);function h(){return _!==null&&_.apply(this,arguments)||this}return h.prototype._encodeByte=function(p){var f=p;return f+=65,f+=25-p>>>8&6,f+=51-p>>>8&-75,f+=61-p>>>8&-13,f+=62-p>>>8&49,String.fromCharCode(f)},h.prototype._decodeChar=function(p){var f=n;return f+=(44-p&p-46)>>>8&-n+p-45+62,f+=(94-p&p-96)>>>8&-n+p-95+63,f+=(47-p&p-58)>>>8&-n+p-48+52,f+=(64-p&p-91)>>>8&-n+p-65+0,f+=(96-p&p-123)>>>8&-n+p-97+26,f},h})(e);_e.URLSafeCoder=a;var c=new a;function l(_){return c.encode(_)}_e.encodeURLSafe=l;function d(_){return c.decode(_)}return _e.decodeURLSafe=d,_e.encodedLength=function(_){return r.encodedLength(_)},_e.maxDecodedLength=function(_){return r.maxDecodedLength(_)},_e.decodedLength=function(_){return r.decodedLength(_)},_e}var ni={exports:{}},vb=ni.exports,xl;function kb(){return xl||(xl=1,(function(t){(function(n,e){var r={};e(r);var i=r.default;for(var s in r)i[s]=r[s];t.exports=i})(vb,function(n){n.__esModule=!0,n.digestLength=32,n.blockSize=64;var e=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function r(p,f,b,y,w){for(var E,S,T,x,A,O,$,U,W,C,F,Q,he;w>=64;){for(E=f[0],S=f[1],T=f[2],x=f[3],A=f[4],O=f[5],$=f[6],U=f[7],C=0;C<16;C++)F=y+C*4,p[C]=(b[F]&255)<<24|(b[F+1]&255)<<16|(b[F+2]&255)<<8|b[F+3]&255;for(C=16;C<64;C++)W=p[C-2],Q=(W>>>17|W<<15)^(W>>>19|W<<13)^W>>>10,W=p[C-15],he=(W>>>7|W<<25)^(W>>>18|W<<14)^W>>>3,p[C]=(Q+p[C-7]|0)+(he+p[C-16]|0);for(C=0;C<64;C++)Q=(((A>>>6|A<<26)^(A>>>11|A<<21)^(A>>>25|A<<7))+(A&O^~A&$)|0)+(U+(e[C]+p[C]|0)|0)|0,he=((E>>>2|E<<30)^(E>>>13|E<<19)^(E>>>22|E<<10))+(E&S^E&T^S&T)|0,U=$,$=O,O=A,A=x+Q|0,x=T,T=S,S=E,E=Q+he|0;f[0]+=E,f[1]+=S,f[2]+=T,f[3]+=x,f[4]+=A,f[5]+=O,f[6]+=$,f[7]+=U,y+=64,w-=64}return y}var i=(function(){function p(){this.digestLength=n.digestLength,this.blockSize=n.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return 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 f=0;f<this.buffer.length;f++)this.buffer[f]=0;for(var f=0;f<this.temp.length;f++)this.temp[f]=0;this.reset()},p.prototype.update=function(f,b){if(b===void 0&&(b=f.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");var y=0;if(this.bytesHashed+=b,this.bufferLength>0){for(;this.bufferLength<64&&b>0;)this.buffer[this.bufferLength++]=f[y++],b--;this.bufferLength===64&&(r(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(b>=64&&(y=r(this.temp,this.state,f,y,b),b%=64);b>0;)this.buffer[this.bufferLength++]=f[y++],b--;return this},p.prototype.finish=function(f){if(!this.finished){var b=this.bytesHashed,y=this.bufferLength,w=b/536870912|0,E=b<<3,S=b%64<56?64:128;this.buffer[y]=128;for(var T=y+1;T<S-8;T++)this.buffer[T]=0;this.buffer[S-8]=w>>>24&255,this.buffer[S-7]=w>>>16&255,this.buffer[S-6]=w>>>8&255,this.buffer[S-5]=w>>>0&255,this.buffer[S-4]=E>>>24&255,this.buffer[S-3]=E>>>16&255,this.buffer[S-2]=E>>>8&255,this.buffer[S-1]=E>>>0&255,r(this.temp,this.state,this.buffer,0,S),this.finished=!0}for(var T=0;T<8;T++)f[T*4+0]=this.state[T]>>>24&255,f[T*4+1]=this.state[T]>>>16&255,f[T*4+2]=this.state[T]>>>8&255,f[T*4+3]=this.state[T]>>>0&255;return this},p.prototype.digest=function(){var f=new Uint8Array(this.digestLength);return this.finish(f),f},p.prototype._saveState=function(f){for(var b=0;b<this.state.length;b++)f[b]=this.state[b]},p.prototype._restoreState=function(f,b){for(var y=0;y<this.state.length;y++)this.state[y]=f[y];this.bytesHashed=b,this.finished=!1,this.bufferLength=0},p})();n.Hash=i;var s=(function(){function p(f){this.inner=new i,this.outer=new i,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var b=new Uint8Array(this.blockSize);if(f.length>this.blockSize)new i().update(f).finish(b).clean();else for(var y=0;y<f.length;y++)b[y]=f[y];for(var y=0;y<b.length;y++)b[y]^=54;this.inner.update(b);for(var y=0;y<b.length;y++)b[y]^=106;this.outer.update(b),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate);for(var y=0;y<b.length;y++)b[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 f=0;f<this.istate.length;f++)this.ostate[f]=this.istate[f]=0;this.inner.clean(),this.outer.clean()},p.prototype.update=function(f){return this.inner.update(f),this},p.prototype.finish=function(f){return this.outer.finished?this.outer.finish(f):(this.inner.finish(f),this.outer.update(f,this.digestLength).finish(f)),this},p.prototype.digest=function(){var f=new Uint8Array(this.digestLength);return this.finish(f),f},p})();n.HMAC=s;function a(p){var f=new i().update(p),b=f.digest();return f.clean(),b}n.hash=a,n.default=a;function c(p,f){var b=new s(p).update(f),y=b.digest();return b.clean(),y}n.hmac=c;function l(p,f,b,y){var w=y[0];if(w===0)throw new Error("hkdf: cannot expand more");f.reset(),w>1&&f.update(p),b&&f.update(b),f.update(y),f.finish(p),y[0]++}var d=new Uint8Array(n.digestLength);function _(p,f,b,y){f===void 0&&(f=d),y===void 0&&(y=32);for(var w=new Uint8Array([1]),E=c(f,p),S=new s(E),T=new Uint8Array(S.digestLength),x=T.length,A=new Uint8Array(y),O=0;O<y;O++)x===T.length&&(l(T,S,b,w),x=0),A[O]=T[x++];return S.clean(),T.fill(0),w.fill(0),A}n.hkdf=_;function h(p,f,b,y){for(var w=new s(p),E=w.digestLength,S=new Uint8Array(4),T=new Uint8Array(E),x=new Uint8Array(E),A=new Uint8Array(y),O=0;O*E<y;O++){var $=O+1;S[0]=$>>>24&255,S[1]=$>>>16&255,S[2]=$>>>8&255,S[3]=$>>>0&255,w.reset(),w.update(f),w.update(S),w.finish(x);for(var U=0;U<E;U++)T[U]=x[U];for(var U=2;U<=b;U++){w.reset(),w.update(x).finish(x);for(var W=0;W<E;W++)T[W]^=x[W]}for(var U=0;U<E&&O*E+U<y;U++)A[O*E+U]=T[U]}for(var O=0;O<E;O++)T[O]=x[O]=0;for(var O=0;O<4;O++)S[O]=0;return w.clean(),A}n.pbkdf2=h})})(ni)),ni.exports}var un={},Tl;function Eb(){if(Tl)return un;Tl=1,Object.defineProperty(un,"__esModule",{value:!0}),un.timingSafeEqual=n;function t(e,r=""){if(!e)throw new Error(r)}function n(e,r){if(e.byteLength!==r.byteLength)return!1;e instanceof DataView||(e=new DataView(ArrayBuffer.isView(e)?e.buffer:e)),r instanceof DataView||(r=new DataView(ArrayBuffer.isView(r)?r.buffer:r)),t(e instanceof DataView),t(r instanceof DataView);const i=e.byteLength;let s=0,a=-1;for(;++a<i;)s|=e.getUint8(a)^r.getUint8(a);return s===0}return un}var Al;function Sb(){if(Al)return ct;Al=1,Object.defineProperty(ct,"__esModule",{value:!0}),ct.Webhook=ct.WebhookVerificationError=void 0;const t=wb(),n=kb(),e=Eb(),r=300;class i extends Error{constructor(d){super(d),Object.setPrototypeOf(this,i.prototype),this.name="ExtendableError",this.stack=new Error(d).stack}}class s extends i{constructor(d){super(d),Object.setPrototypeOf(this,s.prototype),this.name="WebhookVerificationError"}}ct.WebhookVerificationError=s;function a(l){if(typeof l=="string")return new TextEncoder().encode(l);if(ArrayBuffer.isView(l)&&l.BYTES_PER_ELEMENT===1)return new Uint8Array(l.buffer,l.byteOffset,l.byteLength);throw new Error("Expected payload to be of type string, Buffer or Uint8Array.")}class c{constructor(d,_){if(_?.format==="raw")d instanceof Uint8Array?this.key=d:this.key=Uint8Array.from(d,h=>h.charCodeAt(0));else{if(typeof d!="string")throw new Error("Expected secret to be of type string");d.startsWith(c.prefix)&&(d=d.substring(c.prefix.length)),this.key=t.decode(d)}if(this.key.length===0)throw new Error("Secret can't be empty.")}verify(d,_,h){var p;const f=(p=h?.jsonParse)!==null&&p!==void 0?p:!0,b={};for(const $ of Object.keys(_))b[$.toLowerCase()]=_[$];const y=b["webhook-id"],w=b["webhook-signature"],E=b["webhook-timestamp"];if(!w||!y||!E)throw new s("Missing required headers");const S=this.verifyTimestamp(E),T=a(d),x=new globalThis.TextEncoder,A=x.encode(this.sign(y,S,T));if(!w.split(" ").some($=>(0,e.timingSafeEqual)(x.encode($),A)))throw new s("No matching signature found");if(T.length!==0&&f)return JSON.parse(typeof d=="string"?d:new TextDecoder().decode(T))}sign(d,_,h){const p=a(h),f=Math.floor(_.getTime()/1e3),b=new TextEncoder().encode(`${d}.${f}.`),y=new Uint8Array(b.length+p.length);return y.set(b),y.set(p,b.length),`v1,${t.encode(n.hmac(this.key,y))}`}endpointVerificationResponse(d){const _=new TextEncoder,h=n.hmac(this.key,_.encode("wev-v1"));return`v1,${t.encode(n.hmac(h,_.encode(d)))}`}verifyEndpointVerificationResponse(d,_){if(!_)throw new s("Missing challenge response");const h=new globalThis.TextEncoder,p=h.encode(this.endpointVerificationResponse(d));if(!(0,e.timingSafeEqual)(h.encode(_),p))throw new s("No matching signature found")}verifyTimestamp(d){const _=Math.floor(Date.now()/1e3),h=parseInt(d,10);if(Number.isNaN(h))throw new s("Invalid Signature Headers");if(_-h>r)throw new s("Message timestamp too old");if(h>_+r)throw new s("Message timestamp too new");return new Date(h*1e3)}}return ct.Webhook=c,c.prefix="whsec_",ct}var xb=Sb();let Rl=class extends k{parseUnverified(n){return JSON.parse(n)}unwrap(n,e){const r=e?.headers;if(r==null)throw new Error("Webhook headers are required in order to verify the signature");const i=e.key===void 0?this._client.webhookKey:e.key;if(!i)throw new Error("Webhook key must not be null or empty in order to unwrap");return new xb.Webhook(i).verify(n,r),JSON.parse(n)}},zl=class extends k{list(n,e={},r){const{betas:i,workspace_id:s,...a}=e??{};return this._client.getAPIList(m`/v1/agents/${n}/versions`,z,{query:a,...r,headers:g([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.agents.versions.list",r,{route:"/v1/agents/{agent_id}/versions",queryParams:["limit","page"],attributes:{"gen_ai.agent.id":n}})})}};var Pl=(()=>{class t extends k{constructor(){super(...arguments),this.versions=new zl(this._client)}create(e,r){const{betas:i,workspace_id:s,...a}=e;return this._client.post("/v1/agents",{body:a,...r,headers:g([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.agents.create",r,{route:"/v1/agents",createdIDAttribute:"gen_ai.agent.id"})})}retrieve(e,r={},i){const{betas:s,workspace_id:a,...c}=r??{};return this._client.get(m`/v1/agents/${e}`,{query:c,...i,headers:g([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.agents.retrieve",i,{route:"/v1/agents/{agent_id}",queryParams:["version"],attributes:{"gen_ai.agent.id":e}})})}update(e,r,i){const{betas:s,workspace_id:a,...c}=r;return this._client.post(m`/v1/agents/${e}`,{body:c,...i,headers:g([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.agents.update",i,{route:"/v1/agents/{agent_id}",attributes:{"gen_ai.agent.id":e}})})}list(e={},r){const{betas:i,workspace_id:s,...a}=e??{};return this._client.getAPIList("/v1/agents",z,{query:a,...r,headers:g([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.agents.list",r,{route:"/v1/agents",queryParams:["created_at[gte]","created_at[lte]","include_archived","limit","page"]})})}archive(e,r={},i){const{betas:s,workspace_id:a}=r??{};return this._client.post(m`/v1/agents/${e}/archive`,{...i,headers:g([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.agents.archive",i,{route:"/v1/agents/{agent_id}/archive",attributes:{"gen_ai.agent.id":e}})})}}return t.Versions=zl,t})();class Cl extends k{retrieve(n,e={},r){const{betas:i}=e??{};return this._client.get(m`/v1/compliance/review/cases/${n}`,{...r,headers:g([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.compliance.review.cases.retrieve",r,{route:"/v1/compliance/review/cases/{case_id}",attributes:{"anthropic.compliance.review.case.id":n}})})}list(n={},e){const{betas:r,...i}=n??{};return this._client.getAPIList("/v1/compliance/review/cases",z,{query:i,...e,headers:g([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.compliance.review.cases.list",e,{route:"/v1/compliance/review/cases",queryParams:["created_at[gt]","created_at[gte]","created_at[lt]","created_at[lte]","limit","order","order_by","page","status","updated_at[gt]","updated_at[gte]","updated_at[lt]","updated_at[lte]","user_profile_id"]})})}respond(n,e,r){const{betas:i,...s}=e;return this._client.post(m`/v1/compliance/review/cases/${n}/respond`,{body:s,...r,headers:g([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.compliance.review.cases.respond",r,{route:"/v1/compliance/review/cases/{case_id}/respond",attributes:{"anthropic.compliance.review.case.id":n}})})}}class Ol extends k{retrieve(n,e={},r){const{betas:i,user_profile_id:s}=e??{};return this._client.get(m`/v1/compliance/review/items/${n}`,{...r,headers:g([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...s!=null?{"anthropic-user-profile-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.compliance.review.items.retrieve",r,{route:"/v1/compliance/review/items/{item_id}",attributes:{"anthropic.compliance.review.item.id":n}})})}}class Nl extends k{list(n={},e){const{betas:r,...i}=n??{};return this._client.getAPIList("/v1/compliance/review/notices",z,{query:i,...e,headers:g([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.compliance.review.notices.list",e,{route:"/v1/compliance/review/notices",queryParams:["case_id","created_at[gt]","created_at[gte]","created_at[lt]","created_at[lte]","limit","order","page"]})})}}var Ml=(()=>{class t extends k{constructor(){super(...arguments),this.cases=new Cl(this._client),this.notices=new Nl(this._client),this.items=new Ol(this._client)}}return t.Cases=Cl,t.Notices=Nl,t.Items=Ol,t})(),$l=(()=>{class t extends k{constructor(){super(...arguments),this.review=new Ml(this._client)}}return t.Review=Ml,t})();let Us=function(){const{crypto:t}=globalThis;if(t?.randomUUID)return Us=t.randomUUID.bind(t),t.randomUUID();const n=new Uint8Array(1),e=t?()=>t.getRandomValues(n)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,r=>(+r^e()&15>>+r/4).toString(16))};function Zr(t,n){if(!t)return()=>{};if(t.aborted)return n.abort(),()=>{};const e=()=>n.abort();return t.addEventListener("abort",e),()=>t.removeEventListener("abort",e)}function er(t,n){return t instanceof K&&t.status===n}function Tb(t){return t instanceof K&&typeof t.status=="number"&&t.status>=400&&t.status<500}function gi(t){return Tb(t)&&!er(t,408)&&!er(t,409)&&!er(t,429)}function Lp(t,n,e){return Math.min(n*2**t,e)}function Ab(t,n){return t+Math.random()*(n-t)}function Up(t){return t*(1-Math.random()*.25)}function Fp(t,{authToken:n,helper:e}){if(!n)throw new P(`copyClientForHelper: expected a non-empty authToken but received ${JSON.stringify(n)}`);const r=t._options.defaultHeaders,i=t._authState?.extraHeaders,s=i?Object.fromEntries(Object.entries(i).filter(([c])=>{const l=c.toLowerCase();return l!=="authorization"&&l!=="x-api-key"})):void 0,a=g([s,r,{[nn]:e}]);return a.values.delete("x-api-key"),a.values.delete("authorization"),a.nulls.delete("authorization"),t.withOptions({authToken:n,baseURL:t.baseURL,defaultHeaders:a})}var Rb={},Nt,dn,pe,hn,_n,pn,_r,pr,Mt,$t,fn,Bt,fr;const zb=999,Pb=1e3,Cb=6e4,Ob=3e5;var Fs=(()=>{class t{constructor(e){Nt.set(this,void 0),dn.set(this,!1),pe.set(this,void 0),hn.set(this,void 0),_n.set(this,void 0),pn.set(this,void 0),_r.set(this,void 0),pr.set(this,void 0),Mt.set(this,void 0),this.client=e.client,this.environmentId=e.environmentId,this.environmentKey=e.environmentKey,this.workerId=e.workerId??$b(),v(this,Nt,Fp(e.client,{authToken:e.environmentKey,helper:"environments-work-poller"})),v(this,_n,e.autoStop??!0),v(this,pn,e.drain??!1),v(this,_r,e.blockMs===void 0?zb:e.blockMs),v(this,pr,e.reclaimOlderThanMs??null),v(this,Mt,e.requestOptions),v(this,pe,new AbortController),v(this,hn,Zr(e.signal,o(this,pe,"f")))}get signal(){return o(this,pe,"f").signal}abort(){o(this,pe,"f").abort()}async*[(Nt=new WeakMap,dn=new WeakMap,pe=new WeakMap,hn=new WeakMap,_n=new WeakMap,pn=new WeakMap,_r=new WeakMap,pr=new WeakMap,Mt=new WeakMap,Symbol.asyncIterator)](){if(o(this,dn,"f"))throw new P("Cannot iterate over a consumed WorkPoller");v(this,dn,!0);let e=xe.active();const r=B(this.client);r.info("poller starting",{component:"work-poller",environment_id:this.environmentId});const i=new Mb(r,this.environmentId);try{let s=0;for(;!o(this,pe,"f").signal.aborted;){let a;try{a=await o(this,Nt,"f").beta.environments.work.poll(this.environmentId,{"Anthropic-Worker-ID":this.workerId,...o(this,_r,"f")!==null?{block_ms:o(this,_r,"f")}:{},...o(this,pr,"f")!==null?{reclaim_older_than_ms:o(this,pr,"f")}:{}},{headers:g([o(this,Mt,"f")?.headers]),signal:o(this,pe,"f").signal})}catch(c){if(o(this,pe,"f").signal.aborted)return;if(gi(c))throw r.error("poll failed permanently, stopping poller",{error:String(c)}),c;const l=Up(Nb(s));r.warn("poll failed, backing off",{error:String(c),backoff_ms:l}),s++,await kt(l,o(this,pe,"f").signal);continue}if(s=0,a==null){if(o(this,pn,"f"))return;i.onEmptyPoll(),await kt(Ab(1e3,3e3),o(this,pe,"f").signal);continue}i.onClaim(),this._workSpan=H(this.client,()=>fb(this.client,a,e)),r.info("claimed work",{component:"work-poller",environment_id:this.environmentId,work_id:a.id,work_type:a.data.type});try{await o(this,Nt,"f").beta.environments.work.ack(a.id,{environment_id:a.environment_id},{headers:g([o(this,Mt,"f")?.headers]),signal:o(this,pe,"f").signal})}catch(c){r.error("ack failed",{work_id:a.id,error:String(c)}),H(this.client,()=>fp(this._workSpan,o(this,pe,"f").signal,c));continue}try{yield a,e=xe.active()}finally{if(o(this,_n,"f"))try{await o(this,Nt,"f").beta.environments.work.stop(a.id,{environment_id:a.environment_id},{headers:g([o(this,Mt,"f")?.headers])})}catch(c){er(c,409)||r.warn("stop failed",{work_id:a.id,error:String(c)})}H(this.client,()=>pp(this._workSpan,o(this,pe,"f").signal))}}}finally{o(this,hn,"f").call(this)}}}return t})();function Nb(t){return Lp(t,Pb,Cb)}var Mb=(()=>{class t{constructor(e,r){$t.set(this,void 0),fn.set(this,void 0),Bt.set(this,void 0),fr.set(this,0),v(this,$t,e),v(this,fn,r)}onEmptyPoll(){const e=Date.now(),r={component:"work-poller",environment_id:o(this,fn,"f")};o(this,Bt,"f")===void 0?(v(this,Bt,v(this,fr,e,"f")),o(this,$t,"f").info("idle; polling for work",r)):e-o(this,fr,"f")>=Ob?(v(this,fr,e),o(this,$t,"f").info(`still polling; idle for ${Math.round((e-o(this,Bt,"f"))/1e3)}s`,r)):o(this,$t,"f").debug("poll returned no work",r)}onClaim(){v(this,Bt,void 0)}}return $t=new WeakMap,fn=new WeakMap,Bt=new WeakMap,fr=new WeakMap,t})();function $b(){const n=Rb?.HOSTNAME;return n?`${n}-${Us()}`:Us()}const Bb=t=>{if(typeof globalThis.Buffer<"u"){const n=globalThis.Buffer.from(t,"base64");return new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}if(typeof atob<"u"){const n=atob(t),e=new Uint8Array(n.length);for(let r=0;r<n.length;r++)e[r]=n.charCodeAt(r);return e}throw new P("Cannot decode base64 string; Expected `Buffer` or `atob` to be defined")};var It,Qe,qt,Ib=(()=>{class t{constructor(){It.set(this,[]),Qe.set(this,[]),qt.set(this,!1)}push(e){if(o(this,qt,"f"))return!1;const r=o(this,Qe,"f").shift();return r?r({done:!1,value:e}):o(this,It,"f").push(e),!0}close(){if(!o(this,qt,"f"))for(v(this,qt,!0);o(this,Qe,"f").length>0;)o(this,Qe,"f").shift()({done:!0,value:void 0})}next(e){return o(this,It,"f").length>0?Promise.resolve({done:!1,value:o(this,It,"f").shift()}):o(this,qt,"f")||e?.aborted?Promise.resolve({done:!0,value:void 0}):new Promise(r=>{const i=a=>{e?.removeEventListener("abort",s),r(a)},s=()=>{const a=o(this,Qe,"f").indexOf(i);a>=0&&o(this,Qe,"f").splice(a,1),r({done:!0,value:void 0})};o(this,Qe,"f").push(i),e?.addEventListener("abort",s,{once:!0})})}tryShift(){return o(this,It,"f").shift()}}return It=new WeakMap,Qe=new WeakMap,qt=new WeakMap,t})(),Ta=(()=>{class t extends Error{constructor(e){const r=typeof e=="string"?e:e.map(i=>i.type==="text"?i.text:`[${i.type}]`).join(" ");super(r),this.name="ToolError",this.content=e}}return t})();const qb="\\x00-\\x1f\\x7f-\\x9f\\u061c\\u200e\\u200f\\u2028\\u2029\\u202a-\\u202e\\u2066-\\u2069",Lb=new RegExp(`[${qb}]+`,"g"),Ub=/[\uD800-\uDFFF]/gu;function mi(t){return t.replace(Ub,"�")}const Wp=4096,Fb=200;function Wb(t,n=Wp){return Hp(mi(t).replace(Lb," ").trim(),n)}function jb(t){return Wb(t,Fb)}function at(t){return jb(t).replace(/[' ]+/g," ").trim()}function jp(t){return`Error: ${t instanceof Error?t.message:String(t)}`}function Hb(t){return Hp(mi(jp(t)),Wp)}function Hp(t,n){if(t.length<=n)return t;let e=0,r=0;for(const i of t){if(r===n)break;r+=1,e+=i.length}return t.slice(0,e)}function Kb(t){return typeof t=="string"?mi(t):t.filter(n=>n.type==="text"&&n.text!=="").map(n=>({...n,text:mi(n.text)}))}function Bl(t){return"name"in t?t.name:"mcp_server_name"in t?t.mcp_server_name:t.type}function Db(t){return t instanceof Ta?t.content:jp(t)}async function Kp(t,n,e){try{const r=t.parse?t.parse(n):n;return{content:await t.run(r,e),isError:!1}}catch(r){return{content:Db(r),isError:!0}}}var gr,gn,Lt,lt,Ut,ze,j,mn,ee,yn,Ft,bn,J,Wt,ke,jt,Ne,mr,Ht,We,wn,yr,ie,vn,br,wr,kn,Il,ql,Ll,Gi,Ul,En,Sn,Vi,Fl,xn,Tn,Ji,Wl,jl;const Hl=500,Gb=1e4,Vb=12e4,Jb=3e4,Yb=1e3,Xb=3e4,Qb=5*6e4,Zb=6e4;function Dp(t){return t.type!=="session.status_idle"?!1:t.stop_reason?.type!=="requires_action"}function Gp(t){return t.type==="user.tool_confirmation"||t.type==="session.thread_status_terminated"}var ew=(()=>{class t{constructor(e,r){gr.set(this,void 0),gn.set(this,void 0),Lt.set(this,new Set),lt.set(this,!1),Ut.set(this,!1),ze.set(this,void 0),v(this,gr,e),v(this,gn,r)}noteEvent(e){o(this,Ut,"f")&&e.type==="session.thread_status_terminated"&&this.disarm(),!Gp(e)&&(v(this,Ut,!1),Dp(e)?this.arm():this.disarm())}noteHistoryRead(e){v(this,Ut,!e)}block(e){o(this,Lt,"f").add(e),o(this,ze,"f")!==void 0&&(v(this,lt,!0),clearTimeout(o(this,ze,"f")),v(this,ze,void 0))}unblock(e){o(this,Lt,"f").delete(e),o(this,Lt,"f").size===0&&o(this,lt,"f")&&this.arm()}abandon(e){o(this,Ut,"f")&&this.disarm(),this.unblock(e)}arm(){if(!(o(this,gr,"f")<=0)){if(o(this,Lt,"f").size>0){v(this,lt,!0);return}v(this,lt,!1),o(this,ze,"f")!==void 0&&clearTimeout(o(this,ze,"f")),v(this,ze,setTimeout(o(this,gn,"f"),o(this,gr,"f")))}}disarm(){v(this,lt,!1),o(this,ze,"f")!==void 0&&(clearTimeout(o(this,ze,"f")),v(this,ze,void 0))}}return gr=new WeakMap,gn=new WeakMap,Lt=new WeakMap,lt=new WeakMap,Ut=new WeakMap,ze=new WeakMap,t})(),Ws=(()=>{class t{constructor(e,r){j.add(this),mn.set(this,!1),ee.set(this,void 0),yn.set(this,void 0),Ft.set(this,void 0),bn.set(this,void 0),J.set(this,void 0),Wt.set(this,new Set),ke.set(this,new Set),jt.set(this,new Map),Ne.set(this,new Map),mr.set(this,new Set),Ht.set(this,new Ib),We.set(this,0),wn.set(this,Qb),yr.set(this,null),ie.set(this,void 0),vn.set(this,void 0),br.set(this,void 0),wr.set(this,!1),this.client=r.client,this.sessionId=e,this.tools=r.tools,this.maxIdleMs=r.maxIdleMs??Zb,v(this,J,B(r.client)),v(this,bn,new Map(r.tools.map(i=>[Bl(i),i]))),v(this,ee,new AbortController),v(this,yn,Zr(r.signal,o(this,ee,"f"))),v(this,Ft,r.requestOptions),v(this,ie,new ew(this.maxIdleMs,()=>{o(this,J,"f").info("session idle after its turn ended; stopping",{component:"session-tool-runner",session_id:this.sessionId,max_idle_ms:this.maxIdleMs}),o(this,ee,"f").abort()}))}get signal(){return o(this,ee,"f").signal}abort(){o(this,ee,"f").abort()}_setSendRetryWindow(e){v(this,wn,e)}async*[(mn=new WeakMap,ee=new WeakMap,yn=new WeakMap,Ft=new WeakMap,bn=new WeakMap,J=new WeakMap,Wt=new WeakMap,ke=new WeakMap,jt=new WeakMap,Ne=new WeakMap,mr=new WeakMap,Ht=new WeakMap,We=new WeakMap,wn=new WeakMap,yr=new WeakMap,ie=new WeakMap,vn=new WeakMap,br=new WeakMap,wr=new WeakMap,j=new WeakSet,Symbol.asyncIterator)](){if(o(this,mn,"f"))throw new P("Cannot iterate over a consumed SessionToolRunner");v(this,mn,!0),v(this,vn,this.client._tracer?xe.active():void 0),o(this,J,"f").info("session tool runner starting",{component:"session-tool-runner",session_id:this.sessionId});const e=o(this,j,"m",Il).call(this).catch(r=>{o(this,ee,"f").signal.aborted||o(this,J,"f").error("stream loop failed",{error:String(r)}),o(this,ee,"f").abort()});try{for(;;){const i=await o(this,Ht,"f").next(o(this,ee,"f").signal);if(i.done)break;yield i.value}await e;let r;for(;(r=o(this,Ht,"f").tryShift())!==void 0;)yield r}finally{o(this,ee,"f").abort(),o(this,ie,"f").disarm(),await e;try{await o(this,j,"m",jl).call(this)}catch(r){o(this,J,"f").warn("drain failed",{error:String(r)})}o(this,Ht,"f").close();for(const r of this.tools)try{await r.close?.()}catch(i){o(this,J,"f").warn("tool.close failed",{tool:Bl(r),error:String(i)})}o(this,yn,"f").call(this)}}}return kn=function(){return{...o(this,Ft,"f"),headers:g([va("session-tool-runner"),o(this,Ft,"f")?.headers]),signal:o(this,ee,"f").signal}},Il=async function(){const e=o(this,ee,"f");let r=Hl;for(;!e.signal.aborted;){try{const i=await this.client.beta.sessions.events.stream(this.sessionId,{},o(this,j,"m",kn).call(this));await o(this,j,"m",ql).call(this);for await(const s of i)if(r=Hl,await o(this,j,"m",Ul).call(this,s))return}catch(i){if(e.signal.throwIfAborted(),gi(i))throw o(this,J,"f").error("permanent stream failure, shutting down",{error:String(i)}),e.abort(),i;o(this,J,"f").warn("stream disconnected, reconnecting",{error:String(i),backoff_ms:r})}e.signal.throwIfAborted(),await kt(r,e.signal),r=Math.min(r*2,Gb)}},ql=async function(){const e=o(this,ee,"f"),r=[];let i=!1;v(this,wr,!1);try{for await(const c of this.client.beta.sessions.events.list(this.sessionId,{limit:1e3},o(this,j,"m",kn).call(this)))o(this,j,"m",Ll).call(this,c,r),Gp(c)||(i=Dp(c))}catch(c){e.signal.throwIfAborted(),o(this,J,"f").warn("reconcile list failed",{error:String(c)});for(const l of r)o(this,Wt,"f").delete(l.id);o(this,ie,"f").noteHistoryRead(!1),o(this,j,"m",Sn).call(this);return}v(this,wr,!0),o(this,ie,"f").noteHistoryRead(!0),o(this,j,"m",Sn).call(this);const s=r.filter(c=>!o(this,ke,"f").has(c.id));o(this,ie,"f").disarm();for(const c of s)await o(this,j,"m",Vi).call(this,c);for(const c of[...o(this,Ne,"f").values()]){const l=o(this,jt,"f").get(c.id);l!==void 0&&await o(this,j,"m",xn).call(this,c,l)}const a=s.filter(c=>!o(this,ke,"f").has(c.id)&&!o(this,j,"m",En).call(this,c)&&!o(this,Ne,"f").has(c.id));i&&a.length===0?o(this,ie,"f").arm():o(this,ie,"f").disarm()},Ll=function(e,r){o(this,j,"m",Gi).call(this,e),e.type==="agent.tool_use"||e.type==="agent.custom_tool_use"?(o(this,Wt,"f").add(e.id),o(this,ke,"f").has(e.id)||r.push(e)):e.type==="user.tool_result"?o(this,ke,"f").add(e.tool_use_id):e.type==="user.custom_tool_result"?o(this,ke,"f").add(e.custom_tool_use_id):e.type==="user.tool_confirmation"?o(this,ke,"f").has(e.tool_use_id)||o(this,jt,"f").set(e.tool_use_id,e.result):e.type==="session.thread_status_terminated"&&o(this,mr,"f").add(e.session_thread_id)},Gi=function(e){if(!(!this.client._tracer||o(this,br,"f")!==void 0))switch(e.type){case"session.thread_status_running":case"session.thread_status_idle":case"session.thread_status_rescheduled":case"session.thread_status_terminated":v(this,br,e.session_thread_id)}},Ul=async function(e){switch(o(this,ie,"f").noteEvent(e),o(this,wr,"f")&&o(this,j,"m",Gi).call(this,e),e.type){case"agent.tool_use":case"agent.custom_tool_use":return o(this,Wt,"f").has(e.id)||(o(this,Wt,"f").add(e.id),await o(this,j,"m",Vi).call(this,e)),!1;case"user.tool_confirmation":return await o(this,j,"m",Fl).call(this,e),!1;case"user.tool_result":return o(this,ke,"f").add(e.tool_use_id),!1;case"user.custom_tool_result":return o(this,ke,"f").add(e.custom_tool_use_id),!1;case"session.thread_status_terminated":return o(this,mr,"f").add(e.session_thread_id),o(this,j,"m",Sn).call(this),!1;case"session.status_terminated":case"session.deleted":return o(this,J,"f").info("session terminated",{component:"session-tool-runner",session_id:this.sessionId}),o(this,ee,"f").abort(),!0;default:return!1}},En=function(e){return!!e.session_thread_id&&o(this,mr,"f").has(e.session_thread_id)},Sn=function(){for(const e of o(this,Ne,"f").values())o(this,j,"m",En).call(this,e)&&(o(this,J,"f").info("session thread terminated; not executing",{component:"session-tool-runner",session_id:this.sessionId,session_thread_id:e.session_thread_id,tool:e.name,tool_use_id:e.id}),o(this,Ne,"f").delete(e.id),o(this,ie,"f").abandon(e.id))},Vi=async function(e){if(o(this,j,"m",En).call(this,e)){o(this,J,"f").debug("session thread terminated; not executing",{component:"session-tool-runner",session_id:this.sessionId,session_thread_id:e.session_thread_id,tool:e.name,tool_use_id:e.id});return}const r=e.evaluated_permission,i=r==="deny"?"deny":o(this,jt,"f").get(e.id);if(i===void 0){r===void 0||r==="allow"?await o(this,j,"m",Ji).call(this,e,void 0):o(this,Ne,"f").has(e.id)||(o(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}),o(this,Ne,"f").set(e.id,e),o(this,ie,"f").block(e.id));return}await o(this,j,"m",xn).call(this,e,i)},Fl=async function(e){o(this,jt,"f").set(e.tool_use_id,e.result);const r=o(this,Ne,"f").get(e.tool_use_id);r!==void 0&&await o(this,j,"m",xn).call(this,r,e.result)},xn=async function(e,r){const i=o(this,Ne,"f").delete(e.id);if(r==="allow"){o(this,J,"f").info("tool call confirmed",{component:"session-tool-runner",session_id:this.sessionId,tool:e.name,tool_use_id:e.id}),i||o(this,ie,"f").block(e.id);try{await o(this,j,"m",Ji).call(this,e,"allow")}finally{o(this,ie,"f").unblock(e.id)}return}i&&o(this,ie,"f").unblock(e.id),o(this,ke,"f").add(e.id),o(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}),o(this,j,"m",Tn).call(this,{event:e,toolUseId:e.id,name:e.name,isError:!1,posted:!1,confirmation:"deny"})},Tn=function(e){o(this,Ht,"f").push(e)},Ji=async function(e,r){var i,s;if(!o(this,ke,"f").has(e.id)){o(this,J,"f").info("executing tool",{component:"session-tool-runner",session_id:this.sessionId,tool:e.name,tool_use_id:e.id}),v(this,We,(i=o(this,We,"f"),i++,i));try{const a=o(this,bn,"f").get(e.name);if(!a){o(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}),r==="allow"&&o(this,ie,"f").disarm(),o(this,j,"m",Tn).call(this,{event:e,toolUseId:e.id,name:e.name,isError:!1,posted:!1,confirmation:r});return}let c,l;const d=o(this,Ft,"f")?.openTelemetry?.conversationId??(e.session_thread_id||o(this,br,"f")),_=new AbortController,h=Zr(o(this,ee,"f").signal,_),p=setTimeout(()=>_.abort(),Vb);try{const y={signal:o(this,ee,"f").signal,conversationId:d,sessionID:this.sessionId,parentContext:o(this,vn,"f")},w=await ka(this.client,a,e,y,async()=>{const E=await Kp(a,e.input,{toolUse:e,toolUseBlock:e,signal:_.signal}),S=rw(E.content),T=this.client._tracer?S.map((x,A)=>{const O=typeof E.content=="string"?void 0:E.content[A];return O&&O.type!=="text"&&x.type==="text"?O:x}):S;return{sent:S,content:T,isError:E.isError}});c=w.sent,l=w.isError}finally{clearTimeout(p),h()}const f=tw(e,l,c),b=await o(this,j,"m",Wl).call(this,f,e.id,d);o(this,j,"m",Tn).call(this,{event:e,result:f,toolUseId:e.id,name:e.name,isError:l,posted:b,confirmation:r})}finally{v(this,We,(s=o(this,We,"f"),s--,s)),o(this,We,"f")===0&&o(this,yr,"f")?.call(this)}}},Wl=async function(e,r,i){const s=o(this,ee,"f"),a=Date.now();let c,l=0;for(;;){l++,s.signal.throwIfAborted();try{return await this.client.beta.sessions.events.send(this.sessionId,{events:[e]},{...o(this,j,"m",kn).call(this),openTelemetry:{conversationId:i}}),o(this,ke,"f").add(r),!0}catch(d){if(c=d,gi(d))break;const _=o(this,wn,"f")-(Date.now()-a);if(_<=0)break;const h=Math.min(Up(Lp(l-1,Yb,Xb)),_);o(this,J,"f").warn("tool result send failed; retrying",{tool_use_id:r,attempt:l,backoff_ms:h,error:String(d)}),await kt(h,s.signal)}}return o(this,J,"f").error("failed to send tool result",{tool_use_id:r,attempts:l,error:String(c)}),!1},jl=async function(){o(this,We,"f")!==0&&(await Promise.race([new Promise(e=>v(this,yr,e)),kt(Jb)]),v(this,yr,null),o(this,We,"f")>0&&o(this,J,"f").warn("drain timeout exceeded"))},t})();function tw(t,n,e){return t.type==="agent.custom_tool_use"?{type:"user.custom_tool_result",custom_tool_use_id:t.id,is_error:n,content:e}:{type:"user.tool_result",tool_use_id:t.id,is_error:n,content:e}}function rw(t){if(typeof t=="string")return[{type:"text",text:t||"(no output)"}];const n=t.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(r=>({type:"text",text:r.text})),citations:{enabled:e.citations?.enabled??!1}}:{type:"text",text:JSON.stringify(e)});return n.length>0?n:[{type:"text",text:"(no output)"}]}const dk=15e3,Kl=5e3;function nw(t,n){if(!(t>=Kl))throw new P(`${n} must be at least ${Kl}ms (got ${t}); to run without memory sync, pass \`memorySyncIntervalMs: null\` to the worker instead`)}var An,vr,Yi,kr,ut;const Dl=3e4,iw=9e4,sw="NO_HEARTBEAT";function aw(t){return t.resources.some(n=>n.type==="memory_store")}function ow(t){if(!t)return null;let n;try{const r=t.replace(/-/g,"+").replace(/_/g,"/"),i=r.padEnd(Math.ceil(r.length/4)*4,"=");n=JSON.parse(Ns(Bb(i)))}catch{return null}if(n===null||typeof n!="object"||Array.isArray(n))return null;const e=n.sessions_token;return typeof e=="string"&&e!==""?e:null}var Gl=(()=>{class t{constructor(e){if(An.add(this),vr.set(this,void 0),e.unrestrictedPaths!==void 0)throw new P("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&&nw(e.memorySyncIntervalMs,"memorySyncIntervalMs"),this.memorySyncIntervalMs=e.memorySyncIntervalMs,this.memorySyncDeletions=e.memorySyncDeletions??"enabled",this.workerId=e.workerId,this.requestOptions=e.requestOptions,v(this,vr,e.signal)}async run(e){const{environmentId:r,environmentKey:i}=this;if(r===void 0||i===void 0)throw new P("EnvironmentWorker.run: environmentId and environmentKey are required to poll for work");const s=e??o(this,vr,"f"),a=new Fs({client:this.client,environmentId:r,environmentKey:i,...this.workerId!==void 0?{workerId:this.workerId}:{},...s?{signal:s}:{},...this.requestOptions!==void 0?{requestOptions:this.requestOptions}:{},autoStop:!1});for await(const c of a){const l=a._workSpan;try{await gb(this.client,l,a.signal,()=>o(this,An,"m",Yi).call(this,c,i,a.signal,l))}catch(d){if(a.signal?.aborted)throw d;B(this.client).error("work item failed",{work_id:c.id,error:String(d)})}}}async handleItem(e){const r=e?.workId??I("ANTHROPIC_WORK_ID"),i=e?.environmentId??I("ANTHROPIC_ENVIRONMENT_ID"),s=e?.sessionId??I("ANTHROPIC_SESSION_ID"),a=(e?.environmentKey??this.environmentKey??I("ANTHROPIC_ENVIRONMENT_KEY"))||void 0,c=e?.workSecret||I("ANTHROPIC_WORK_SECRET")||null;if(!r)throw new P("handleItem: workId is required — pass it or set ANTHROPIC_WORK_ID");if(!i)throw new P("handleItem: environmentId is required — pass it or set ANTHROPIC_ENVIRONMENT_ID");if(!s)throw new P("handleItem: sessionId is required — pass it or set ANTHROPIC_SESSION_ID");if(!a&&!c)throw new P("handleItem: environmentKey is required when there is no work secret — pass it, construct the worker with it, or set ANTHROPIC_ENVIRONMENT_KEY");const l={id:r,environment_id:i,secret:c,data:{type:"session",id:s}};await o(this,An,"m",Yi).call(this,l,a,e?.signal??o(this,vr,"f"))}}return vr=new WeakMap,An=new WeakSet,Yi=async function(e,r,i,s){const a=B(this.client),c=ow(e.secret),l=c??r;if(l===void 0)throw new P("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&&c===null&&a.warn("work item carried a secret payload but no sessions token could be extracted; falling back to the environment key",{work_id:e.id});const d=Fp(this.client,{authToken:l,helper:"environments-worker"}),_=e.data.id,h=new AbortController,p=Zr(i,h),f=new lw(h),b=await Fe(()=>import("./node.browser-Dg3f5wnV.js"),__vite__mapDeps([0,1,2,3]));let y,w;const E=dw(d,e,f,a,this.requestOptions,A=>{y=A,w?._setSendRetryWindow(A)}).catch(A=>{h.signal.aborted||a.error("heartbeat loop failed",{work_id:e.id,error:String(A)}),h.abort()});let S=async()=>{},T,x=!1;try{if(e.data.type!=="session"){a.debug("skipping non-session work item",{work_id:e.id,type:e.data.type});return}const A=await d.beta.sessions.retrieve(_);if(A.status==="terminated"){a.info("skipping the work item of a terminated session",{session_id:_,work_id:e.id});return}if(c===null&&this.memorySyncIntervalMs!==null&&aw(A))throw new b.SessionMemoryError(`cannot mount the session's memories: the work item carried no sessions token (work_id=${e.id}, session_id=${_}); 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`);const O={workdir:this.workdir,client:d,session:A,...this.maxFileBytes!==void 0?{maxFileBytes:this.maxFileBytes}:{}};try{S=await b.setupSkills(O)}catch(U){a.warn("skill setup failed",{session_id:_,work_id:e.id,error:String(U)})}c!==null&&this.memorySyncIntervalMs!==null?(T=new b.SessionMemoryStores(d,{workdir:this.workdir,...this.memorySyncIntervalMs!==void 0?{syncIntervalMs:this.memorySyncIntervalMs}:{},syncDeletions:this.memorySyncDeletions}),await T.download(A),O.allowedRoots=T.roots,O.readOnlyRoots=T.readOnlyRoots):a.debug("memory stores disabled for this item",{work_id:e.id});const $=typeof this.tools=="function"?this.tools(O):this.tools??b.betaAgentToolset20260401(O);w=new Ws(_,{client:d,tools:$,...this.maxIdleMs!==void 0?{maxIdleMs:this.maxIdleMs}:{},...this.requestOptions!==void 0?{requestOptions:this.requestOptions}:{},signal:h.signal}),y!==void 0&&w._setSendRetryWindow(y);for await(const U of w)T&&await T.syncIfDue();x=!h.signal.aborted}finally{try{await S().catch(A=>{a.warn("skill cleanup failed",{session_id:_,work_id:e.id,error:String(A)})})}finally{if(T){const A=b.MEMORY_FLUSH_TIMEOUT_MS;x&&await Vl(T.finish(),A)&&a.warn(`final memory sync cut off after ${A}ms; the flush that follows still uploads changed files`,{session_id:_,work_id:e.id});const O=new AbortController;await Vl(T.flushWrites(O.signal),A)&&(O.abort(),a.warn(`memory flush cut off after ${A}ms; changed files it had not uploaded yet are not saved`,{session_id:_,work_id:e.id})),await T.dispose().catch(U=>{a.warn("memory store cleanup failed",{session_id:_,work_id:e.id,error:String(U)})})}}f.finish("runner_done"),p(),await E,f.lost?a.info("lease lost; released without stopping it",{session_id:_,work_id:e.id}):await cw(d,e,a,this.requestOptions),(f.lost||f.rejected)&&H(this.client,()=>s?.end())}},t})();async function Vl(t,n){let e;try{return await Promise.race([t.then(()=>!1,()=>!1),new Promise(r=>{e=setTimeout(()=>r(!0),n)})])}finally{e!==void 0&&clearTimeout(e)}}async function cw(t,n,e,r){try{await t.beta.environments.work.stop(n.id,{environment_id:n.environment_id,force:!0},{...r,headers:g([r?.headers])})}catch(i){er(i,409)||e.error("force-stop on exit failed",{work_id:n.id,error:String(i)})}}var lw=(()=>{class t{constructor(e){kr.set(this,void 0),ut.set(this,void 0),v(this,kr,e)}get signal(){return o(this,kr,"f").signal}finish(e){v(this,ut,o(this,ut,"f")??e),o(this,kr,"f").abort()}get lost(){return o(this,ut,"f")==="lease_lost"||o(this,ut,"f")==="assumed_lost"}get rejected(){return o(this,ut,"f")==="heartbeat_rejected"}}return kr=new WeakMap,ut=new WeakMap,t})();function uw(t){let n=t instanceof K?t.error:void 0;for(const e of["error","details","current_state"]){if(!ae(n))return{};n=n[e]}return ae(n)?n:{}}async function dw(t,n,e,r,i,s){let a=Dl,c=iw,l=Date.now(),d=sw;const _=async()=>{const h=new AbortController,p=Zr(e.signal,h),f=setTimeout(()=>h.abort(),a);try{const b=await t.beta.environments.work.heartbeat(n.id,{environment_id:n.environment_id,expected_last_heartbeat:d},{...i,headers:g([i?.headers]),signal:h.signal});l=Date.now(),d=b.last_heartbeat,b.ttl_seconds>0&&(c=b.ttl_seconds*1e3,a=Math.max(1e3,Math.min(c/2,Dl)),s?.(c)),(b.state==="stopping"||b.state==="stopped")&&(r.info("heartbeat signals shutdown",{work_id:n.id,state:b.state}),e.finish("heartbeat_stop")),b.lease_extended||(r.warn("lease not extended, shutting down",{work_id:n.id}),e.finish("heartbeat_stop"))}catch(b){if(e.signal.throwIfAborted(),er(b,412)){const y=uw(b);r.error("lease lost: heartbeat precondition failed",{work_id:n.id,server_state:y.state,server_ttl_seconds:y.ttl_seconds,server_last_heartbeat:y.last_heartbeat}),e.finish("lease_lost");return}if(gi(b))throw r.error("permanent heartbeat failure",{work_id:n.id,error:String(b)}),e.finish("heartbeat_rejected"),b;if(Date.now()-l>c){r.error("lease assumed lost: no successful heartbeat in ttl",{work_id:n.id,ttl_ms:c,error:String(b)}),e.finish("assumed_lost");return}r.warn("transient heartbeat failure",{work_id:n.id,error:String(b)})}finally{clearTimeout(f),p()}};for(await _();!e.signal.aborted;)await kt(a,e.signal),e.signal.throwIfAborted(),await _()}var Aa=(()=>{class t extends ra{}return t._errorName="BetaHeartbeatPreconditionFailedError",t})(),Jl=(()=>{class t extends k{retrieve(e,r,i){const{environment_id:s,betas:a,workspace_id:c}=r;return this._client.get(m`/v1/environments/${s}/work/${e}`,{...i,headers:g([{"anthropic-beta":[...a??[],"managed-agents-2026-04-01"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.environments.work.retrieve",i,{route:"/v1/environments/{environment_id}/work/{work_id}",attributes:{"anthropic.environment.id":s,"anthropic.environment.work.id":e}})})}update(e,r,i){const{environment_id:s,betas:a,workspace_id:c,...l}=r;return this._client.post(m`/v1/environments/${s}/work/${e}`,{body:l,...i,headers:g([{"anthropic-beta":[...a??[],"managed-agents-2026-04-01"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.environments.work.update",i,{route:"/v1/environments/{environment_id}/work/{work_id}",attributes:{"anthropic.environment.id":s,"anthropic.environment.work.id":e}})})}list(e,r={},i){const{betas:s,...a}=r??{};return this._client.getAPIList(m`/v1/environments/${e}/work`,z,{query:a,...i,headers:g([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.environments.work.list",i,{route:"/v1/environments/{environment_id}/work",queryParams:["limit","page"],attributes:{"anthropic.environment.id":e}})})}ack(e,r,i){const{environment_id:s,betas:a}=r;return this._client.post(m`/v1/environments/${s}/work/${e}/ack`,{...i,headers:g([{"anthropic-beta":[...a??[],"managed-agents-2026-04-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.environments.work.ack",i,{route:"/v1/environments/{environment_id}/work/{work_id}/ack",attributes:{"anthropic.environment.id":s,"anthropic.environment.work.id":e}})})}heartbeat(e,r,i){const{environment_id:s,desired_ttl_seconds:a,expected_last_heartbeat:c,betas:l}=r;return this._client.post(m`/v1/environments/${s}/work/${e}/heartbeat`,{query:{desired_ttl_seconds:a,expected_last_heartbeat:c},...i,headers:g([{"anthropic-beta":[...l??[],"managed-agents-2026-04-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.environments.work.heartbeat",i,{route:"/v1/environments/{environment_id}/work/{work_id}/heartbeat",queryParams:["desired_ttl_seconds","expected_last_heartbeat"],attributes:{"anthropic.environment.id":s,"anthropic.environment.work.id":e}})})}poll(e,r={},i){const{betas:s,"Anthropic-Worker-ID":a,...c}=r??{};return this._client.get(m`/v1/environments/${e}/work/poll`,{query:c,...i,headers:g([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"Anthropic-Worker-ID":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.environments.work.poll",i,{route:"/v1/environments/{environment_id}/work/poll",queryParams:["block_ms","reclaim_older_than_ms"],attributes:{"anthropic.environment.id":e}})})}stats(e,r={},i){const{betas:s,workspace_id:a}=r??{};return this._client.get(m`/v1/environments/${e}/work/stats`,{...i,headers:g([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.environments.work.stats",i,{route:"/v1/environments/{environment_id}/work/stats",attributes:{"anthropic.environment.id":e}})})}stop(e,r,i){const{environment_id:s,betas:a,workspace_id:c,...l}=r;return this._client.post(m`/v1/environments/${s}/work/${e}/stop`,{body:l,...i,headers:g([{"anthropic-beta":[...a??[],"managed-agents-2026-04-01"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.environments.work.stop",i,{route:"/v1/environments/{environment_id}/work/{work_id}/stop",attributes:{"anthropic.environment.id":s,"anthropic.environment.work.id":e}})})}poller(e){return new Fs({...e,client:this._client})}worker(e){return new Gl({...e,client:this._client})}}return t.BetaHeartbeatPreconditionFailedError=Aa,t.WorkPoller=Fs,t.EnvironmentWorker=Gl,t})(),Ra=(()=>{class t extends R{}return t._errorName="BetaEnvironmentArchivedError",t})(),za=(()=>{class t extends R{}return t._errorName="BetaInvalidConfigTypeChangeError",t})(),Pa=(()=>{class t extends R{}return t._errorName="BetaInvalidMetadataError",t})(),Ca=(()=>{class t extends oe{}return t._errorName="BetaEnvironmentCreateDisabledError",t})(),Oa=(()=>{class t extends oe{}return t._errorName="BetaEnvironmentUpdateDisabledError",t})(),Na=(()=>{class t extends Ye{}return t._errorName="BetaEnvironmentNotFoundError",t})(),Yl=(()=>{class t extends k{constructor(){super(...arguments),this.work=new Jl(this._client)}create(e,r){const{betas:i,workspace_id:s,...a}=e;return this._client.post("/v1/environments",{body:a,...r,headers:g([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.environments.create",r,{route:"/v1/environments",createdIDAttribute:"anthropic.environment.id"})})}retrieve(e,r={},i){const{betas:s,workspace_id:a}=r??{};return this._client.get(m`/v1/environments/${e}`,{...i,headers:g([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.environments.retrieve",i,{route:"/v1/environments/{environment_id}",attributes:{"anthropic.environment.id":e}})})}update(e,r,i){const{betas:s,workspace_id:a,...c}=r;return this._client.post(m`/v1/environments/${e}`,{body:c,...i,headers:g([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.environments.update",i,{route:"/v1/environments/{environment_id}",attributes:{"anthropic.environment.id":e}})})}list(e={},r){const{betas:i,workspace_id:s,...a}=e??{};return this._client.getAPIList("/v1/environments",z,{query:a,...r,headers:g([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.environments.list",r,{route:"/v1/environments",queryParams:["include_archived","limit","page"]})})}delete(e,r={},i){const{betas:s,workspace_id:a}=r??{};return this._client.delete(m`/v1/environments/${e}`,{...i,headers:g([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.environments.delete",i,{route:"/v1/environments/{environment_id}",attributes:{"anthropic.environment.id":e}})})}archive(e,r={},i){const{betas:s,workspace_id:a}=r??{};return this._client.post(m`/v1/environments/${e}/archive`,{...i,headers:g([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.environments.archive",i,{route:"/v1/environments/{environment_id}/archive",attributes:{"anthropic.environment.id":e}})})}}return t.BetaEnvironmentArchivedError=Ra,t.BetaInvalidConfigTypeChangeError=za,t.BetaInvalidMetadataError=Pa,t.BetaEnvironmentCreateDisabledError=Ca,t.BetaEnvironmentUpdateDisabledError=Oa,t.BetaEnvironmentNotFoundError=Na,t.Work=Jl,t.BetaHeartbeatPreconditionFailedError=Aa,t})();class Xl extends k{create(n,e,r){const{view:i,betas:s,workspace_id:a,...c}=e;return this._client.post(m`/v1/memory_stores/${n}/memories`,{query:{view:i},body:c,...r,headers:g([{"anthropic-beta":[...s??[],"agent-memory-2026-07-22"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.memory_stores.memories.create",r,{route:"/v1/memory_stores/{memory_store_id}/memories",queryParams:["view"],attributes:{"gen_ai.memory.store.id":n},createdIDAttribute:"gen_ai.memory.record.id"})})}retrieve(n,e,r){const{memory_store_id:i,betas:s,workspace_id:a,...c}=e;return this._client.get(m`/v1/memory_stores/${i}/memories/${n}`,{query:c,...r,headers:g([{"anthropic-beta":[...s??[],"agent-memory-2026-07-22"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.memory_stores.memories.retrieve",r,{route:"/v1/memory_stores/{memory_store_id}/memories/{memory_id}",queryParams:["view"],attributes:{"gen_ai.memory.store.id":i,"gen_ai.memory.record.id":n}})})}update(n,e,r){const{memory_store_id:i,view:s,betas:a,workspace_id:c,...l}=e;return this._client.post(m`/v1/memory_stores/${i}/memories/${n}`,{query:{view:s},body:l,...r,headers:g([{"anthropic-beta":[...a??[],"agent-memory-2026-07-22"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.memory_stores.memories.update",r,{route:"/v1/memory_stores/{memory_store_id}/memories/{memory_id}",queryParams:["view"],attributes:{"gen_ai.memory.store.id":i,"gen_ai.memory.record.id":n}})})}list(n,e={},r){const{betas:i,workspace_id:s,...a}=e??{};return this._client.getAPIList(m`/v1/memory_stores/${n}/memories`,z,{query:a,...r,headers:g([{"anthropic-beta":[...i??[],"agent-memory-2026-07-22"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.memory_stores.memories.list",r,{route:"/v1/memory_stores/{memory_store_id}/memories",queryParams:["depth","limit","page","path_prefix","view"],contentQueryParams:["page"],attributes:{"gen_ai.memory.store.id":n}})})}delete(n,e,r){const{memory_store_id:i,expected_content_sha256:s,betas:a,workspace_id:c}=e;return this._client.delete(m`/v1/memory_stores/${i}/memories/${n}`,{query:{expected_content_sha256:s},...r,headers:g([{"anthropic-beta":[...a??[],"agent-memory-2026-07-22"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.memory_stores.memories.delete",r,{route:"/v1/memory_stores/{memory_store_id}/memories/{memory_id}",queryParams:["expected_content_sha256"],attributes:{"gen_ai.memory.store.id":i,"gen_ai.memory.record.id":n}})})}}class Ql extends k{retrieve(n,e,r){const{memory_store_id:i,betas:s,workspace_id:a,...c}=e;return this._client.get(m`/v1/memory_stores/${i}/memory_versions/${n}`,{query:c,...r,headers:g([{"anthropic-beta":[...s??[],"agent-memory-2026-07-22"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.memory_stores.memory_versions.retrieve",r,{route:"/v1/memory_stores/{memory_store_id}/memory_versions/{memory_version_id}",queryParams:["view"],attributes:{"gen_ai.memory.store.id":i,"anthropic.memory_store.memory_version.id":n}})})}list(n,e={},r){const{betas:i,workspace_id:s,...a}=e??{};return this._client.getAPIList(m`/v1/memory_stores/${n}/memory_versions`,z,{query:a,...r,headers:g([{"anthropic-beta":[...i??[],"agent-memory-2026-07-22"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.memory_stores.memory_versions.list",r,{route:"/v1/memory_stores/{memory_store_id}/memory_versions",queryParams:["api_key_id","created_at[gte]","created_at[lte]","limit","memory_id","operation","page","service_account_id","session_id","view"],attributes:{"gen_ai.memory.store.id":n}})})}redact(n,e,r){const{memory_store_id:i,betas:s,workspace_id:a}=e;return this._client.post(m`/v1/memory_stores/${i}/memory_versions/${n}/redact`,{...r,headers:g([{"anthropic-beta":[...s??[],"agent-memory-2026-07-22"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.memory_stores.memory_versions.redact",r,{route:"/v1/memory_stores/{memory_store_id}/memory_versions/{memory_version_id}/redact",attributes:{"gen_ai.memory.store.id":i,"anthropic.memory_store.memory_version.id":n}})})}}var Zl=(()=>{class t extends k{constructor(){super(...arguments),this.memories=new Xl(this._client),this.memoryVersions=new Ql(this._client)}create(e,r){const{betas:i,workspace_id:s,...a}=e;return this._client.post("/v1/memory_stores",{body:a,...r,headers:g([{"anthropic-beta":[...i??[],"agent-memory-2026-07-22"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.memory_stores.create",r,{route:"/v1/memory_stores",createdIDAttribute:"gen_ai.memory.store.id"})})}retrieve(e,r={},i){const{betas:s,workspace_id:a}=r??{};return this._client.get(m`/v1/memory_stores/${e}`,{...i,headers:g([{"anthropic-beta":[...s??[],"agent-memory-2026-07-22"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.memory_stores.retrieve",i,{route:"/v1/memory_stores/{memory_store_id}",attributes:{"gen_ai.memory.store.id":e}})})}update(e,r,i){const{betas:s,workspace_id:a,...c}=r;return this._client.post(m`/v1/memory_stores/${e}`,{body:c,...i,headers:g([{"anthropic-beta":[...s??[],"agent-memory-2026-07-22"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.memory_stores.update",i,{route:"/v1/memory_stores/{memory_store_id}",attributes:{"gen_ai.memory.store.id":e}})})}list(e={},r){const{betas:i,workspace_id:s,...a}=e??{};return this._client.getAPIList("/v1/memory_stores",z,{query:a,...r,headers:g([{"anthropic-beta":[...i??[],"agent-memory-2026-07-22"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.memory_stores.list",r,{route:"/v1/memory_stores",queryParams:["created_at[gte]","created_at[lte]","include_archived","limit","page"]})})}delete(e,r={},i){const{betas:s,workspace_id:a}=r??{};return this._client.delete(m`/v1/memory_stores/${e}`,{...i,headers:g([{"anthropic-beta":[...s??[],"agent-memory-2026-07-22"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.memory_stores.delete",i,{route:"/v1/memory_stores/{memory_store_id}",attributes:{"gen_ai.memory.store.id":e}})})}archive(e,r={},i){const{betas:s,workspace_id:a}=r??{};return this._client.post(m`/v1/memory_stores/${e}/archive`,{...i,headers:g([{"anthropic-beta":[...s??[],"agent-memory-2026-07-22"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.memory_stores.archive",i,{route:"/v1/memory_stores/{memory_store_id}/archive",attributes:{"gen_ai.memory.store.id":e}})})}}return t.Memories=Xl,t.MemoryVersions=Ql,t})(),Vp=(()=>{class t{constructor(e,r,i){this.iterator=e,this.response=i,this.controller=r}async*decoder(){const e=this.iterator;if(!e)throw new P("Cannot iterate over a consumed stream.");this.iterator=void 0;const r=new W_;for await(const i of e)for(const s of r.decode(i))yield JSON.parse(s);for(const i of r.flush())yield JSON.parse(i)}[Symbol.asyncIterator](){return this.decoder()}static fromResponse(e,r){if(!e.body)throw r.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new P("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 P("Attempted to iterate over a response with no body");return new t(aa(e.body),r,e)}}return t})();let eu=class extends k{create(n,e){const{betas:r,user_profile_id:i,workspace_id:s,...a}=n;return this._client.post("/v1/messages/batches",{body:a,...e,headers:g([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0,...i!=null?{"anthropic-user-profile-id":i}:void 0,...s!=null?{"anthropic-workspace-id":s}:void 0},e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.messages.batches.create",e,{route:"/v1/messages/batches",attributes:{"anthropic.message.batch.request_count":a.requests?.length},createdIDAttribute:"anthropic.message.batch.id"})})}retrieve(n,e={},r){const{betas:i,workspace_id:s}=e??{};return this._client.get(m`/v1/messages/batches/${n}`,{...r,headers:g([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.messages.batches.retrieve",r,{route:"/v1/messages/batches/{message_batch_id}",attributes:{"anthropic.message.batch.id":n}})})}list(n={},e){const{betas:r,workspace_id:i,...s}=n??{};return this._client.getAPIList("/v1/messages/batches",de,{query:s,...e,headers:g([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0,...i!=null?{"anthropic-workspace-id":i}:void 0},e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.messages.batches.list",e,{route:"/v1/messages/batches",queryParams:["after_id","before_id","limit"]})})}delete(n,e={},r){const{betas:i,workspace_id:s}=e??{};return this._client.delete(m`/v1/messages/batches/${n}`,{...r,headers:g([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.messages.batches.delete",r,{route:"/v1/messages/batches/{message_batch_id}",attributes:{"anthropic.message.batch.id":n}})})}cancel(n,e={},r){const{betas:i,workspace_id:s}=e??{};return this._client.post(m`/v1/messages/batches/${n}/cancel`,{...r,headers:g([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.messages.batches.cancel",r,{route:"/v1/messages/batches/{message_batch_id}/cancel",attributes:{"anthropic.message.batch.id":n}})})}async results(n,e={},r){const i=await this.retrieve(n,e,r);if(!i.results_url)throw new P(`No batch \`results_url\`; Has it finished processing? ${i.processing_status} - ${i.id}`);const{betas:s,workspace_id:a}=e??{};return this._client.get(i.results_url,{...r,headers:g([{Accept:"application/binary",...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0,...a!=null?{"anthropic-workspace-id":a}:void 0},r?.headers]),stream:!0,__qualifiers:{beta:"true"},__binaryResponse:!0,__span:u(this._client,"anthropic.messages.batches.results",r,{route:"/v1/messages/batches/{message_batch_id}/results",attributes:{"anthropic.message.batch.id":n}})})._thenUnwrap((c,l)=>Vp.fromResponse(l.response,l.controller))}};const Jp={"claude-opus-4@20250514":8192,"anthropic.claude-opus-4-1-20250805-v1:0":8192,"claude-opus-4-1@20250805":8192},yi={"claude-mythos-preview":"June 30th, 2026","claude-opus-4-5":"January 22nd, 2027","claude-opus-4-5-20251101":"January 22nd, 2027","claude-sonnet-4-5":"November 30th, 2026","claude-sonnet-4-5-20250929":"November 30th, 2026"},Yp=["claude-opus-4-6","claude-mythos-preview"];function Xp(t){return t?.output_format??t?.output_config?.format}function tu(t,n,e){const r=Xp(n);return!n||!("parse"in(r??{}))?{...t,content:t.content.map(i=>{if(i.type==="text"){const s=Object.defineProperty({...i},"parsed_output",{value:null,enumerable:!1});return Object.defineProperty(s,"parsed",{get(){return e.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead."),null},enumerable:!1})}return i}),parsed_output:null}:Ma(t,n,e)}function Ma(t,n,e){let r=null;const i=t.content.map(s=>{if(s.type==="text"){const a=hw(n,s.text);r===null&&(r=a);const c=Object.defineProperty({...s},"parsed_output",{value:a,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."),a},enumerable:!1})}return s});return{...t,content:i,parsed_output:r}}function hw(t,n){const e=Xp(t);if(e?.type!=="json_schema")return null;try{return"parse"in e?e.parse(n):JSON.parse(n)}catch(r){throw new P(`Failed to parse structured output: ${r}`)}}function Qp(t,n){const{betas:e,user_profile_id:r,workspace_id:i,tools:s,messages:a}=t;return g([{...e?.toString()!=null?{"anthropic-beta":e?.toString()}:void 0,...r!=null?{"anthropic-user-profile-id":r}:void 0,...i!=null?{"anthropic-workspace-id":i}:void 0},mp(s,a),n?.headers])}function _w(t,n,e){if(!t._tracer)return;const r=Qp(n,e);return u(t,"anthropic.messages.create",e,Oi(t,{body:js(n),headers:r,stream:!0}))}function js(t){if(!t.output_format)return t;$a(t);const{output_format:n,...e}=t;return{...e,output_config:{...t.output_config,format:n}}}function $a(t){if(t.output_format&&t.output_config?.format)throw new P("Both output_format and output_config.format were provided. Please use only output_config.format (output_format is deprecated).")}const Zp=["true","false","null"],ef=t=>t===" "||t===" "||t===`
|
|
57
|
+
${h}`)}return a},m=bb(bp);var Ea=(()=>{class t extends R{}return t._errorName="FileNotDownloadableError",t})(),Sa=(()=>{class t extends R{}return t._errorName="StorageQuotaExceededError",t})(),xa=(()=>{class t extends Ye{}return t._errorName="FileExpiredError",t})(),yl=(()=>{class t extends k{list(e={},r){const{workspace_id:i,...s}=e??{};return this._client.getAPIList("/v1/files",z,{query:s,...r,headers:g([{...i!=null?{"anthropic-workspace-id":i}:void 0},r?.headers]),__span:u(this._client,"anthropic.files.list",r,{route:"/v1/files",queryParams:["ids","limit","page"]})})}delete(e,r={},i){const{workspace_id:s}=r??{};return this._client.delete(m`/v1/files/${e}`,{...i,headers:g([{...s!=null?{"anthropic-workspace-id":s}:void 0},i?.headers]),__span:u(this._client,"anthropic.files.delete",i,{route:"/v1/files/{file_id}",attributes:{"anthropic.file.id":e}})})}download(e,r={},i){const{workspace_id:s}=r??{};return this._client.get(m`/v1/files/${e}/content`,{...i,headers:g([{Accept:"application/binary",...s!=null?{"anthropic-workspace-id":s}:void 0},i?.headers]),__binaryResponse:!0,__span:u(this._client,"anthropic.files.download",i,{route:"/v1/files/{file_id}/content",attributes:{"anthropic.file.id":e}})})}retrieveMetadata(e,r={},i){const{workspace_id:s}=r??{};return this._client.get(m`/v1/files/${e}`,{...i,headers:g([{...s!=null?{"anthropic-workspace-id":s}:void 0},i?.headers]),__span:u(this._client,"anthropic.files.retrieve_metadata",i,{route:"/v1/files/{file_id}",attributes:{"anthropic.file.id":e}})})}upload(e,r){const{workspace_id:i,...s}=e;return this._client.post("/v1/files",Xe({body:s,...r,headers:g([{...i!=null?{"anthropic-workspace-id":i}:void 0},yp(s.file),r?.headers]),__span:u(this._client,"anthropic.files.upload",r,{route:"/v1/files",createdIDAttribute:"anthropic.file.id"})},this._client))}}return t.FileNotDownloadableError=Ea,t.StorageQuotaExceededError=Sa,t.FileExpiredError=xa,t})(),wp=(()=>{class t extends R{}return t._errorName="ClaudeCodeKeyCreatorNotMemberError",t})(),vp=(()=>{class t extends R{}return t._errorName="ClaudeCodeVersionTooOldError",t})(),kp=(()=>{class t extends R{}return t._errorName="CMEKKeyDisabledError",t})(),Ep=(()=>{class t extends R{}return t._errorName="CMEKKeyNetworkBlockedError",t})(),Sp=(()=>{class t extends R{}return t._errorName="OrganizationOnHoldError",t})(),xp=(()=>{class t extends R{}return t._errorName="OrganizationTypeNotSupportedError",t})(),Tp=(()=>{class t extends R{}return t._errorName="ParentOrganizationRequiredError",t})(),Ap=(()=>{class t extends R{}return t._errorName="RequestBodyEncodingInvalidError",t})(),Rp=(()=>{class t extends R{}return t._errorName="RequestBodyEncodingUnsupportedError",t})(),zp=(()=>{class t extends R{}return t._errorName="WorkspaceHumanReviewDisabledError",t})(),Pp=(()=>{class t extends Si{}return t._errorName="LinkedOrganizationBillingUnavailableError",t})(),Cp=(()=>{class t extends Si{}return t._errorName="LinkedOrganizationSpendLimitReachedError",t})(),Op=(()=>{class t extends oe{}return t._errorName="SandboxEgressRestrictedError",t})(),Np=(()=>{class t extends na{}return t._errorName="RequestBodyTooLargeAfterDecodingError",t})(),Mp=(()=>{class t extends rn{}return t._errorName="ContractSpendLimitReachedError",t})(),$p=(()=>{class t extends rn{}return t._errorName="EnforcedSpendLimitReachedError",t})(),Bp=(()=>{class t extends rn{}return t._errorName="RampLimitExceededError",t})(),Ip=(()=>{class t extends ot{}return t._errorName="CMEKContextUnavailableError",t})(),qp=(()=>{class t extends ot{}return t._errorName="CMEKKeyUnreachableError",t})();class bl extends k{retrieve(n,e={},r){const{betas:i,workspace_id:s}=e??{};return this._client.get(m`/v1/deployment_runs/${n}`,{...r,headers:g([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.deployment_runs.retrieve",r,{route:"/v1/deployment_runs/{deployment_run_id}",attributes:{"anthropic.deployment_run.id":n}})})}list(n={},e){const{betas:r,workspace_id:i,...s}=n??{};return this._client.getAPIList("/v1/deployment_runs",z,{query:s,...e,headers:g([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.deployment_runs.list",e,{route:"/v1/deployment_runs",queryParams:["created_at[gt]","created_at[gte]","created_at[lt]","created_at[lte]","deployment_id","has_error","limit","page","trigger_type"]})})}}class wl extends k{create(n,e){const{betas:r,workspace_id:i,...s}=n;return this._client.post("/v1/deployments",{body:s,...e,headers:g([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.deployments.create",e,{route:"/v1/deployments",createdIDAttribute:"anthropic.deployment.id"})})}retrieve(n,e={},r){const{betas:i,workspace_id:s}=e??{};return this._client.get(m`/v1/deployments/${n}`,{...r,headers:g([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.deployments.retrieve",r,{route:"/v1/deployments/{deployment_id}",attributes:{"anthropic.deployment.id":n}})})}update(n,e,r){const{betas:i,workspace_id:s,...a}=e;return this._client.post(m`/v1/deployments/${n}`,{body:a,...r,headers:g([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.deployments.update",r,{route:"/v1/deployments/{deployment_id}",attributes:{"anthropic.deployment.id":n}})})}list(n={},e){const{betas:r,workspace_id:i,...s}=n??{};return this._client.getAPIList("/v1/deployments",z,{query:s,...e,headers:g([{"anthropic-beta":[...r??[],"managed-agents-2026-04-01"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.deployments.list",e,{route:"/v1/deployments",queryParams:["agent_id","created_at[gte]","created_at[lte]","include_archived","limit","page","status"]})})}archive(n,e={},r){const{betas:i,workspace_id:s}=e??{};return this._client.post(m`/v1/deployments/${n}/archive`,{...r,headers:g([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.deployments.archive",r,{route:"/v1/deployments/{deployment_id}/archive",attributes:{"anthropic.deployment.id":n}})})}pause(n,e={},r){const{betas:i,workspace_id:s}=e??{};return this._client.post(m`/v1/deployments/${n}/pause`,{...r,headers:g([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.deployments.pause",r,{route:"/v1/deployments/{deployment_id}/pause",attributes:{"anthropic.deployment.id":n}})})}run(n,e={},r){const{betas:i,workspace_id:s}=e??{};return this._client.post(m`/v1/deployments/${n}/run`,{...r,headers:g([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.deployments.run",r,{route:"/v1/deployments/{deployment_id}/run",attributes:{"anthropic.deployment.id":n}})})}unpause(n,e={},r){const{betas:i,workspace_id:s}=e??{};return this._client.post(m`/v1/deployments/${n}/unpause`,{...r,headers:g([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.deployments.unpause",r,{route:"/v1/deployments/{deployment_id}/unpause",attributes:{"anthropic.deployment.id":n}})})}}class vl extends k{create(n,e){const{betas:r,workspace_id:i,...s}=n;return this._client.post("/v1/dreams",{body:s,...e,headers:g([{"anthropic-beta":[...r??[],"dreaming-2026-04-21"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.dreams.create",e,{route:"/v1/dreams",createdIDAttribute:"anthropic.dream.id"})})}retrieve(n,e={},r){const{betas:i,workspace_id:s}=e??{};return this._client.get(m`/v1/dreams/${n}`,{...r,headers:g([{"anthropic-beta":[...i??[],"dreaming-2026-04-21"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.dreams.retrieve",r,{route:"/v1/dreams/{dream_id}",attributes:{"anthropic.dream.id":n}})})}list(n={},e){const{betas:r,workspace_id:i,...s}=n??{};return this._client.getAPIList("/v1/dreams",z,{query:s,...e,headers:g([{"anthropic-beta":[...r??[],"dreaming-2026-04-21"].toString(),...i!=null?{"anthropic-workspace-id":i}:void 0},e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.dreams.list",e,{route:"/v1/dreams",queryParams:["created_at[gt]","created_at[lt]","include_archived","limit","page","statuses"]})})}archive(n,e={},r){const{betas:i,workspace_id:s}=e??{};return this._client.post(m`/v1/dreams/${n}/archive`,{...r,headers:g([{"anthropic-beta":[...i??[],"dreaming-2026-04-21"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.dreams.archive",r,{route:"/v1/dreams/{dream_id}/archive",attributes:{"anthropic.dream.id":n}})})}cancel(n,e={},r){const{betas:i,workspace_id:s}=e??{};return this._client.post(m`/v1/dreams/${n}/cancel`,{...r,headers:g([{"anthropic-beta":[...i??[],"dreaming-2026-04-21"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.dreams.cancel",r,{route:"/v1/dreams/{dream_id}/cancel",attributes:{"anthropic.dream.id":n}})})}}class kl extends k{list(n={},e){const{betas:r,workspace_id:i,...s}=n??{};return this._client.getAPIList("/v1/files",z,{query:s,...e,headers:g([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0,...i!=null?{"anthropic-workspace-id":i}:void 0},e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.files.list",e,{route:"/v1/files",queryParams:["ids","limit","page","scope_id"]})})}delete(n,e={},r){const{betas:i,workspace_id:s}=e??{};return this._client.delete(m`/v1/files/${n}`,{...r,headers:g([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.files.delete",r,{route:"/v1/files/{file_id}",attributes:{"anthropic.file.id":n}})})}download(n,e={},r){const{betas:i,workspace_id:s}=e??{};return this._client.get(m`/v1/files/${n}/content`,{...r,headers:g([{Accept:"application/binary",...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__binaryResponse:!0,__span:u(this._client,"anthropic.files.download",r,{route:"/v1/files/{file_id}/content",attributes:{"anthropic.file.id":n}})})}retrieveMetadata(n,e={},r){const{betas:i,workspace_id:s}=e??{};return this._client.get(m`/v1/files/${n}`,{...r,headers:g([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.files.retrieve_metadata",r,{route:"/v1/files/{file_id}",attributes:{"anthropic.file.id":n}})})}upload(n,e){const{betas:r,workspace_id:i,...s}=n;return this._client.post("/v1/files",Xe({body:s,...e,headers:g([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0,...i!=null?{"anthropic-workspace-id":i}:void 0},yp(s.file),e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.files.upload",e,{route:"/v1/files",createdIDAttribute:"anthropic.file.id"})},this._client))}}let El=class extends k{retrieve(n,e={},r){const{betas:i,workspace_id:s}=e??{};return this._client.get(m`/v1/models/${n}`,{...r,headers:g([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.models.retrieve",r,{route:"/v1/models/{model_id}",attributes:{"anthropic.model.id":n}})})}list(n={},e){const{betas:r,workspace_id:i,...s}=n??{};return this._client.getAPIList("/v1/models",de,{query:s,...e,headers:g([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0,...i!=null?{"anthropic-workspace-id":i}:void 0},e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.models.list",e,{route:"/v1/models",queryParams:["after_id","before_id","lifecycle","limit"]})})}};var ct={},_e={},Sl;function wb(){if(Sl)return _e;Sl=1;var t=_e&&_e.__extends||(function(){var _=function(h,p){return _=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(f,b){f.__proto__=b}||function(f,b){for(var y in b)b.hasOwnProperty(y)&&(f[y]=b[y])},_(h,p)};return function(h,p){_(h,p);function f(){this.constructor=h}h.prototype=p===null?Object.create(p):(f.prototype=p.prototype,new f)}})();Object.defineProperty(_e,"__esModule",{value:!0});var n=256,e=(function(){function _(h){h===void 0&&(h="="),this._paddingCharacter=h}return _.prototype.encodedLength=function(h){return this._paddingCharacter?(h+2)/3*4|0:(h*8+5)/6|0},_.prototype.encode=function(h){for(var p="",f=0;f<h.length-2;f+=3){var b=h[f]<<16|h[f+1]<<8|h[f+2];p+=this._encodeByte(b>>>18&63),p+=this._encodeByte(b>>>12&63),p+=this._encodeByte(b>>>6&63),p+=this._encodeByte(b>>>0&63)}var y=h.length-f;if(y>0){var b=h[f]<<16|(y===2?h[f+1]<<8:0);p+=this._encodeByte(b>>>18&63),p+=this._encodeByte(b>>>12&63),y===2?p+=this._encodeByte(b>>>6&63):p+=this._paddingCharacter||"",p+=this._paddingCharacter||""}return p},_.prototype.maxDecodedLength=function(h){return this._paddingCharacter?h/4*3|0:(h*6+7)/8|0},_.prototype.decodedLength=function(h){return this.maxDecodedLength(h.length-this._getPaddingLength(h))},_.prototype.decode=function(h){if(h.length===0)return new Uint8Array(0);for(var p=this._getPaddingLength(h),f=h.length-p,b=new Uint8Array(this.maxDecodedLength(f)),y=0,w=0,E=0,S=0,T=0,x=0,A=0;w<f-4;w+=4)S=this._decodeChar(h.charCodeAt(w+0)),T=this._decodeChar(h.charCodeAt(w+1)),x=this._decodeChar(h.charCodeAt(w+2)),A=this._decodeChar(h.charCodeAt(w+3)),b[y++]=S<<2|T>>>4,b[y++]=T<<4|x>>>2,b[y++]=x<<6|A,E|=S&n,E|=T&n,E|=x&n,E|=A&n;if(w<f-1&&(S=this._decodeChar(h.charCodeAt(w)),T=this._decodeChar(h.charCodeAt(w+1)),b[y++]=S<<2|T>>>4,E|=S&n,E|=T&n),w<f-2&&(x=this._decodeChar(h.charCodeAt(w+2)),b[y++]=T<<4|x>>>2,E|=x&n),w<f-3&&(A=this._decodeChar(h.charCodeAt(w+3)),b[y++]=x<<6|A,E|=A&n),E!==0)throw new Error("Base64Coder: incorrect characters for decoding");return b},_.prototype._encodeByte=function(h){var p=h;return p+=65,p+=25-h>>>8&6,p+=51-h>>>8&-75,p+=61-h>>>8&-15,p+=62-h>>>8&3,String.fromCharCode(p)},_.prototype._decodeChar=function(h){var p=n;return p+=(42-h&h-44)>>>8&-n+h-43+62,p+=(46-h&h-48)>>>8&-n+h-47+63,p+=(47-h&h-58)>>>8&-n+h-48+52,p+=(64-h&h-91)>>>8&-n+h-65+0,p+=(96-h&h-123)>>>8&-n+h-97+26,p},_.prototype._getPaddingLength=function(h){var p=0;if(this._paddingCharacter){for(var f=h.length-1;f>=0&&h[f]===this._paddingCharacter;f--)p++;if(h.length<4||p>2)throw new Error("Base64Coder: incorrect padding")}return p},_})();_e.Coder=e;var r=new e;function i(_){return r.encode(_)}_e.encode=i;function s(_){return r.decode(_)}_e.decode=s;var a=(function(_){t(h,_);function h(){return _!==null&&_.apply(this,arguments)||this}return h.prototype._encodeByte=function(p){var f=p;return f+=65,f+=25-p>>>8&6,f+=51-p>>>8&-75,f+=61-p>>>8&-13,f+=62-p>>>8&49,String.fromCharCode(f)},h.prototype._decodeChar=function(p){var f=n;return f+=(44-p&p-46)>>>8&-n+p-45+62,f+=(94-p&p-96)>>>8&-n+p-95+63,f+=(47-p&p-58)>>>8&-n+p-48+52,f+=(64-p&p-91)>>>8&-n+p-65+0,f+=(96-p&p-123)>>>8&-n+p-97+26,f},h})(e);_e.URLSafeCoder=a;var c=new a;function l(_){return c.encode(_)}_e.encodeURLSafe=l;function d(_){return c.decode(_)}return _e.decodeURLSafe=d,_e.encodedLength=function(_){return r.encodedLength(_)},_e.maxDecodedLength=function(_){return r.maxDecodedLength(_)},_e.decodedLength=function(_){return r.decodedLength(_)},_e}var ni={exports:{}},vb=ni.exports,xl;function kb(){return xl||(xl=1,(function(t){(function(n,e){var r={};e(r);var i=r.default;for(var s in r)i[s]=r[s];t.exports=i})(vb,function(n){n.__esModule=!0,n.digestLength=32,n.blockSize=64;var e=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function r(p,f,b,y,w){for(var E,S,T,x,A,O,$,U,W,C,F,Q,he;w>=64;){for(E=f[0],S=f[1],T=f[2],x=f[3],A=f[4],O=f[5],$=f[6],U=f[7],C=0;C<16;C++)F=y+C*4,p[C]=(b[F]&255)<<24|(b[F+1]&255)<<16|(b[F+2]&255)<<8|b[F+3]&255;for(C=16;C<64;C++)W=p[C-2],Q=(W>>>17|W<<15)^(W>>>19|W<<13)^W>>>10,W=p[C-15],he=(W>>>7|W<<25)^(W>>>18|W<<14)^W>>>3,p[C]=(Q+p[C-7]|0)+(he+p[C-16]|0);for(C=0;C<64;C++)Q=(((A>>>6|A<<26)^(A>>>11|A<<21)^(A>>>25|A<<7))+(A&O^~A&$)|0)+(U+(e[C]+p[C]|0)|0)|0,he=((E>>>2|E<<30)^(E>>>13|E<<19)^(E>>>22|E<<10))+(E&S^E&T^S&T)|0,U=$,$=O,O=A,A=x+Q|0,x=T,T=S,S=E,E=Q+he|0;f[0]+=E,f[1]+=S,f[2]+=T,f[3]+=x,f[4]+=A,f[5]+=O,f[6]+=$,f[7]+=U,y+=64,w-=64}return y}var i=(function(){function p(){this.digestLength=n.digestLength,this.blockSize=n.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return 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 f=0;f<this.buffer.length;f++)this.buffer[f]=0;for(var f=0;f<this.temp.length;f++)this.temp[f]=0;this.reset()},p.prototype.update=function(f,b){if(b===void 0&&(b=f.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");var y=0;if(this.bytesHashed+=b,this.bufferLength>0){for(;this.bufferLength<64&&b>0;)this.buffer[this.bufferLength++]=f[y++],b--;this.bufferLength===64&&(r(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(b>=64&&(y=r(this.temp,this.state,f,y,b),b%=64);b>0;)this.buffer[this.bufferLength++]=f[y++],b--;return this},p.prototype.finish=function(f){if(!this.finished){var b=this.bytesHashed,y=this.bufferLength,w=b/536870912|0,E=b<<3,S=b%64<56?64:128;this.buffer[y]=128;for(var T=y+1;T<S-8;T++)this.buffer[T]=0;this.buffer[S-8]=w>>>24&255,this.buffer[S-7]=w>>>16&255,this.buffer[S-6]=w>>>8&255,this.buffer[S-5]=w>>>0&255,this.buffer[S-4]=E>>>24&255,this.buffer[S-3]=E>>>16&255,this.buffer[S-2]=E>>>8&255,this.buffer[S-1]=E>>>0&255,r(this.temp,this.state,this.buffer,0,S),this.finished=!0}for(var T=0;T<8;T++)f[T*4+0]=this.state[T]>>>24&255,f[T*4+1]=this.state[T]>>>16&255,f[T*4+2]=this.state[T]>>>8&255,f[T*4+3]=this.state[T]>>>0&255;return this},p.prototype.digest=function(){var f=new Uint8Array(this.digestLength);return this.finish(f),f},p.prototype._saveState=function(f){for(var b=0;b<this.state.length;b++)f[b]=this.state[b]},p.prototype._restoreState=function(f,b){for(var y=0;y<this.state.length;y++)this.state[y]=f[y];this.bytesHashed=b,this.finished=!1,this.bufferLength=0},p})();n.Hash=i;var s=(function(){function p(f){this.inner=new i,this.outer=new i,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var b=new Uint8Array(this.blockSize);if(f.length>this.blockSize)new i().update(f).finish(b).clean();else for(var y=0;y<f.length;y++)b[y]=f[y];for(var y=0;y<b.length;y++)b[y]^=54;this.inner.update(b);for(var y=0;y<b.length;y++)b[y]^=106;this.outer.update(b),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate);for(var y=0;y<b.length;y++)b[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 f=0;f<this.istate.length;f++)this.ostate[f]=this.istate[f]=0;this.inner.clean(),this.outer.clean()},p.prototype.update=function(f){return this.inner.update(f),this},p.prototype.finish=function(f){return this.outer.finished?this.outer.finish(f):(this.inner.finish(f),this.outer.update(f,this.digestLength).finish(f)),this},p.prototype.digest=function(){var f=new Uint8Array(this.digestLength);return this.finish(f),f},p})();n.HMAC=s;function a(p){var f=new i().update(p),b=f.digest();return f.clean(),b}n.hash=a,n.default=a;function c(p,f){var b=new s(p).update(f),y=b.digest();return b.clean(),y}n.hmac=c;function l(p,f,b,y){var w=y[0];if(w===0)throw new Error("hkdf: cannot expand more");f.reset(),w>1&&f.update(p),b&&f.update(b),f.update(y),f.finish(p),y[0]++}var d=new Uint8Array(n.digestLength);function _(p,f,b,y){f===void 0&&(f=d),y===void 0&&(y=32);for(var w=new Uint8Array([1]),E=c(f,p),S=new s(E),T=new Uint8Array(S.digestLength),x=T.length,A=new Uint8Array(y),O=0;O<y;O++)x===T.length&&(l(T,S,b,w),x=0),A[O]=T[x++];return S.clean(),T.fill(0),w.fill(0),A}n.hkdf=_;function h(p,f,b,y){for(var w=new s(p),E=w.digestLength,S=new Uint8Array(4),T=new Uint8Array(E),x=new Uint8Array(E),A=new Uint8Array(y),O=0;O*E<y;O++){var $=O+1;S[0]=$>>>24&255,S[1]=$>>>16&255,S[2]=$>>>8&255,S[3]=$>>>0&255,w.reset(),w.update(f),w.update(S),w.finish(x);for(var U=0;U<E;U++)T[U]=x[U];for(var U=2;U<=b;U++){w.reset(),w.update(x).finish(x);for(var W=0;W<E;W++)T[W]^=x[W]}for(var U=0;U<E&&O*E+U<y;U++)A[O*E+U]=T[U]}for(var O=0;O<E;O++)T[O]=x[O]=0;for(var O=0;O<4;O++)S[O]=0;return w.clean(),A}n.pbkdf2=h})})(ni)),ni.exports}var un={},Tl;function Eb(){if(Tl)return un;Tl=1,Object.defineProperty(un,"__esModule",{value:!0}),un.timingSafeEqual=n;function t(e,r=""){if(!e)throw new Error(r)}function n(e,r){if(e.byteLength!==r.byteLength)return!1;e instanceof DataView||(e=new DataView(ArrayBuffer.isView(e)?e.buffer:e)),r instanceof DataView||(r=new DataView(ArrayBuffer.isView(r)?r.buffer:r)),t(e instanceof DataView),t(r instanceof DataView);const i=e.byteLength;let s=0,a=-1;for(;++a<i;)s|=e.getUint8(a)^r.getUint8(a);return s===0}return un}var Al;function Sb(){if(Al)return ct;Al=1,Object.defineProperty(ct,"__esModule",{value:!0}),ct.Webhook=ct.WebhookVerificationError=void 0;const t=wb(),n=kb(),e=Eb(),r=300;class i extends Error{constructor(d){super(d),Object.setPrototypeOf(this,i.prototype),this.name="ExtendableError",this.stack=new Error(d).stack}}class s extends i{constructor(d){super(d),Object.setPrototypeOf(this,s.prototype),this.name="WebhookVerificationError"}}ct.WebhookVerificationError=s;function a(l){if(typeof l=="string")return new TextEncoder().encode(l);if(ArrayBuffer.isView(l)&&l.BYTES_PER_ELEMENT===1)return new Uint8Array(l.buffer,l.byteOffset,l.byteLength);throw new Error("Expected payload to be of type string, Buffer or Uint8Array.")}class c{constructor(d,_){if(_?.format==="raw")d instanceof Uint8Array?this.key=d:this.key=Uint8Array.from(d,h=>h.charCodeAt(0));else{if(typeof d!="string")throw new Error("Expected secret to be of type string");d.startsWith(c.prefix)&&(d=d.substring(c.prefix.length)),this.key=t.decode(d)}if(this.key.length===0)throw new Error("Secret can't be empty.")}verify(d,_,h){var p;const f=(p=h?.jsonParse)!==null&&p!==void 0?p:!0,b={};for(const $ of Object.keys(_))b[$.toLowerCase()]=_[$];const y=b["webhook-id"],w=b["webhook-signature"],E=b["webhook-timestamp"];if(!w||!y||!E)throw new s("Missing required headers");const S=this.verifyTimestamp(E),T=a(d),x=new globalThis.TextEncoder,A=x.encode(this.sign(y,S,T));if(!w.split(" ").some($=>(0,e.timingSafeEqual)(x.encode($),A)))throw new s("No matching signature found");if(T.length!==0&&f)return JSON.parse(typeof d=="string"?d:new TextDecoder().decode(T))}sign(d,_,h){const p=a(h),f=Math.floor(_.getTime()/1e3),b=new TextEncoder().encode(`${d}.${f}.`),y=new Uint8Array(b.length+p.length);return y.set(b),y.set(p,b.length),`v1,${t.encode(n.hmac(this.key,y))}`}endpointVerificationResponse(d){const _=new TextEncoder,h=n.hmac(this.key,_.encode("wev-v1"));return`v1,${t.encode(n.hmac(h,_.encode(d)))}`}verifyEndpointVerificationResponse(d,_){if(!_)throw new s("Missing challenge response");const h=new globalThis.TextEncoder,p=h.encode(this.endpointVerificationResponse(d));if(!(0,e.timingSafeEqual)(h.encode(_),p))throw new s("No matching signature found")}verifyTimestamp(d){const _=Math.floor(Date.now()/1e3),h=parseInt(d,10);if(Number.isNaN(h))throw new s("Invalid Signature Headers");if(_-h>r)throw new s("Message timestamp too old");if(h>_+r)throw new s("Message timestamp too new");return new Date(h*1e3)}}return ct.Webhook=c,c.prefix="whsec_",ct}var xb=Sb();let Rl=class extends k{parseUnverified(n){return JSON.parse(n)}unwrap(n,e){const r=e?.headers;if(r==null)throw new Error("Webhook headers are required in order to verify the signature");const i=e.key===void 0?this._client.webhookKey:e.key;if(!i)throw new Error("Webhook key must not be null or empty in order to unwrap");return new xb.Webhook(i).verify(n,r),JSON.parse(n)}},zl=class extends k{list(n,e={},r){const{betas:i,workspace_id:s,...a}=e??{};return this._client.getAPIList(m`/v1/agents/${n}/versions`,z,{query:a,...r,headers:g([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.agents.versions.list",r,{route:"/v1/agents/{agent_id}/versions",queryParams:["limit","page"],attributes:{"gen_ai.agent.id":n}})})}};var Pl=(()=>{class t extends k{constructor(){super(...arguments),this.versions=new zl(this._client)}create(e,r){const{betas:i,workspace_id:s,...a}=e;return this._client.post("/v1/agents",{body:a,...r,headers:g([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.agents.create",r,{route:"/v1/agents",createdIDAttribute:"gen_ai.agent.id"})})}retrieve(e,r={},i){const{betas:s,workspace_id:a,...c}=r??{};return this._client.get(m`/v1/agents/${e}`,{query:c,...i,headers:g([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.agents.retrieve",i,{route:"/v1/agents/{agent_id}",queryParams:["version"],attributes:{"gen_ai.agent.id":e}})})}update(e,r,i){const{betas:s,workspace_id:a,...c}=r;return this._client.post(m`/v1/agents/${e}`,{body:c,...i,headers:g([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.agents.update",i,{route:"/v1/agents/{agent_id}",attributes:{"gen_ai.agent.id":e}})})}list(e={},r){const{betas:i,workspace_id:s,...a}=e??{};return this._client.getAPIList("/v1/agents",z,{query:a,...r,headers:g([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.agents.list",r,{route:"/v1/agents",queryParams:["created_at[gte]","created_at[lte]","include_archived","limit","page"]})})}archive(e,r={},i){const{betas:s,workspace_id:a}=r??{};return this._client.post(m`/v1/agents/${e}/archive`,{...i,headers:g([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.agents.archive",i,{route:"/v1/agents/{agent_id}/archive",attributes:{"gen_ai.agent.id":e}})})}}return t.Versions=zl,t})();class Cl extends k{retrieve(n,e={},r){const{betas:i}=e??{};return this._client.get(m`/v1/compliance/review/cases/${n}`,{...r,headers:g([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.compliance.review.cases.retrieve",r,{route:"/v1/compliance/review/cases/{case_id}",attributes:{"anthropic.compliance.review.case.id":n}})})}list(n={},e){const{betas:r,...i}=n??{};return this._client.getAPIList("/v1/compliance/review/cases",z,{query:i,...e,headers:g([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.compliance.review.cases.list",e,{route:"/v1/compliance/review/cases",queryParams:["created_at[gt]","created_at[gte]","created_at[lt]","created_at[lte]","limit","order","order_by","page","status","updated_at[gt]","updated_at[gte]","updated_at[lt]","updated_at[lte]","user_profile_id"]})})}respond(n,e,r){const{betas:i,...s}=e;return this._client.post(m`/v1/compliance/review/cases/${n}/respond`,{body:s,...r,headers:g([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.compliance.review.cases.respond",r,{route:"/v1/compliance/review/cases/{case_id}/respond",attributes:{"anthropic.compliance.review.case.id":n}})})}}class Ol extends k{retrieve(n,e={},r){const{betas:i,user_profile_id:s}=e??{};return this._client.get(m`/v1/compliance/review/items/${n}`,{...r,headers:g([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...s!=null?{"anthropic-user-profile-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.compliance.review.items.retrieve",r,{route:"/v1/compliance/review/items/{item_id}",attributes:{"anthropic.compliance.review.item.id":n}})})}}class Nl extends k{list(n={},e){const{betas:r,...i}=n??{};return this._client.getAPIList("/v1/compliance/review/notices",z,{query:i,...e,headers:g([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.compliance.review.notices.list",e,{route:"/v1/compliance/review/notices",queryParams:["case_id","created_at[gt]","created_at[gte]","created_at[lt]","created_at[lte]","limit","order","page"]})})}}var Ml=(()=>{class t extends k{constructor(){super(...arguments),this.cases=new Cl(this._client),this.notices=new Nl(this._client),this.items=new Ol(this._client)}}return t.Cases=Cl,t.Notices=Nl,t.Items=Ol,t})(),$l=(()=>{class t extends k{constructor(){super(...arguments),this.review=new Ml(this._client)}}return t.Review=Ml,t})();let Us=function(){const{crypto:t}=globalThis;if(t?.randomUUID)return Us=t.randomUUID.bind(t),t.randomUUID();const n=new Uint8Array(1),e=t?()=>t.getRandomValues(n)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,r=>(+r^e()&15>>+r/4).toString(16))};function Zr(t,n){if(!t)return()=>{};if(t.aborted)return n.abort(),()=>{};const e=()=>n.abort();return t.addEventListener("abort",e),()=>t.removeEventListener("abort",e)}function er(t,n){return t instanceof K&&t.status===n}function Tb(t){return t instanceof K&&typeof t.status=="number"&&t.status>=400&&t.status<500}function gi(t){return Tb(t)&&!er(t,408)&&!er(t,409)&&!er(t,429)}function Lp(t,n,e){return Math.min(n*2**t,e)}function Ab(t,n){return t+Math.random()*(n-t)}function Up(t){return t*(1-Math.random()*.25)}function Fp(t,{authToken:n,helper:e}){if(!n)throw new P(`copyClientForHelper: expected a non-empty authToken but received ${JSON.stringify(n)}`);const r=t._options.defaultHeaders,i=t._authState?.extraHeaders,s=i?Object.fromEntries(Object.entries(i).filter(([c])=>{const l=c.toLowerCase();return l!=="authorization"&&l!=="x-api-key"})):void 0,a=g([s,r,{[nn]:e}]);return a.values.delete("x-api-key"),a.values.delete("authorization"),a.nulls.delete("authorization"),t.withOptions({authToken:n,baseURL:t.baseURL,defaultHeaders:a})}var Rb={},Nt,dn,pe,hn,_n,pn,_r,pr,Mt,$t,fn,Bt,fr;const zb=999,Pb=1e3,Cb=6e4,Ob=3e5;var Fs=(()=>{class t{constructor(e){Nt.set(this,void 0),dn.set(this,!1),pe.set(this,void 0),hn.set(this,void 0),_n.set(this,void 0),pn.set(this,void 0),_r.set(this,void 0),pr.set(this,void 0),Mt.set(this,void 0),this.client=e.client,this.environmentId=e.environmentId,this.environmentKey=e.environmentKey,this.workerId=e.workerId??$b(),v(this,Nt,Fp(e.client,{authToken:e.environmentKey,helper:"environments-work-poller"})),v(this,_n,e.autoStop??!0),v(this,pn,e.drain??!1),v(this,_r,e.blockMs===void 0?zb:e.blockMs),v(this,pr,e.reclaimOlderThanMs??null),v(this,Mt,e.requestOptions),v(this,pe,new AbortController),v(this,hn,Zr(e.signal,o(this,pe,"f")))}get signal(){return o(this,pe,"f").signal}abort(){o(this,pe,"f").abort()}async*[(Nt=new WeakMap,dn=new WeakMap,pe=new WeakMap,hn=new WeakMap,_n=new WeakMap,pn=new WeakMap,_r=new WeakMap,pr=new WeakMap,Mt=new WeakMap,Symbol.asyncIterator)](){if(o(this,dn,"f"))throw new P("Cannot iterate over a consumed WorkPoller");v(this,dn,!0);let e=xe.active();const r=B(this.client);r.info("poller starting",{component:"work-poller",environment_id:this.environmentId});const i=new Mb(r,this.environmentId);try{let s=0;for(;!o(this,pe,"f").signal.aborted;){let a;try{a=await o(this,Nt,"f").beta.environments.work.poll(this.environmentId,{"Anthropic-Worker-ID":this.workerId,...o(this,_r,"f")!==null?{block_ms:o(this,_r,"f")}:{},...o(this,pr,"f")!==null?{reclaim_older_than_ms:o(this,pr,"f")}:{}},{headers:g([o(this,Mt,"f")?.headers]),signal:o(this,pe,"f").signal})}catch(c){if(o(this,pe,"f").signal.aborted)return;if(gi(c))throw r.error("poll failed permanently, stopping poller",{error:String(c)}),c;const l=Up(Nb(s));r.warn("poll failed, backing off",{error:String(c),backoff_ms:l}),s++,await kt(l,o(this,pe,"f").signal);continue}if(s=0,a==null){if(o(this,pn,"f"))return;i.onEmptyPoll(),await kt(Ab(1e3,3e3),o(this,pe,"f").signal);continue}i.onClaim(),this._workSpan=H(this.client,()=>fb(this.client,a,e)),r.info("claimed work",{component:"work-poller",environment_id:this.environmentId,work_id:a.id,work_type:a.data.type});try{await o(this,Nt,"f").beta.environments.work.ack(a.id,{environment_id:a.environment_id},{headers:g([o(this,Mt,"f")?.headers]),signal:o(this,pe,"f").signal})}catch(c){r.error("ack failed",{work_id:a.id,error:String(c)}),H(this.client,()=>fp(this._workSpan,o(this,pe,"f").signal,c));continue}try{yield a,e=xe.active()}finally{if(o(this,_n,"f"))try{await o(this,Nt,"f").beta.environments.work.stop(a.id,{environment_id:a.environment_id},{headers:g([o(this,Mt,"f")?.headers])})}catch(c){er(c,409)||r.warn("stop failed",{work_id:a.id,error:String(c)})}H(this.client,()=>pp(this._workSpan,o(this,pe,"f").signal))}}}finally{o(this,hn,"f").call(this)}}}return t})();function Nb(t){return Lp(t,Pb,Cb)}var Mb=(()=>{class t{constructor(e,r){$t.set(this,void 0),fn.set(this,void 0),Bt.set(this,void 0),fr.set(this,0),v(this,$t,e),v(this,fn,r)}onEmptyPoll(){const e=Date.now(),r={component:"work-poller",environment_id:o(this,fn,"f")};o(this,Bt,"f")===void 0?(v(this,Bt,v(this,fr,e,"f")),o(this,$t,"f").info("idle; polling for work",r)):e-o(this,fr,"f")>=Ob?(v(this,fr,e),o(this,$t,"f").info(`still polling; idle for ${Math.round((e-o(this,Bt,"f"))/1e3)}s`,r)):o(this,$t,"f").debug("poll returned no work",r)}onClaim(){v(this,Bt,void 0)}}return $t=new WeakMap,fn=new WeakMap,Bt=new WeakMap,fr=new WeakMap,t})();function $b(){const n=Rb?.HOSTNAME;return n?`${n}-${Us()}`:Us()}const Bb=t=>{if(typeof globalThis.Buffer<"u"){const n=globalThis.Buffer.from(t,"base64");return new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}if(typeof atob<"u"){const n=atob(t),e=new Uint8Array(n.length);for(let r=0;r<n.length;r++)e[r]=n.charCodeAt(r);return e}throw new P("Cannot decode base64 string; Expected `Buffer` or `atob` to be defined")};var It,Qe,qt,Ib=(()=>{class t{constructor(){It.set(this,[]),Qe.set(this,[]),qt.set(this,!1)}push(e){if(o(this,qt,"f"))return!1;const r=o(this,Qe,"f").shift();return r?r({done:!1,value:e}):o(this,It,"f").push(e),!0}close(){if(!o(this,qt,"f"))for(v(this,qt,!0);o(this,Qe,"f").length>0;)o(this,Qe,"f").shift()({done:!0,value:void 0})}next(e){return o(this,It,"f").length>0?Promise.resolve({done:!1,value:o(this,It,"f").shift()}):o(this,qt,"f")||e?.aborted?Promise.resolve({done:!0,value:void 0}):new Promise(r=>{const i=a=>{e?.removeEventListener("abort",s),r(a)},s=()=>{const a=o(this,Qe,"f").indexOf(i);a>=0&&o(this,Qe,"f").splice(a,1),r({done:!0,value:void 0})};o(this,Qe,"f").push(i),e?.addEventListener("abort",s,{once:!0})})}tryShift(){return o(this,It,"f").shift()}}return It=new WeakMap,Qe=new WeakMap,qt=new WeakMap,t})(),Ta=(()=>{class t extends Error{constructor(e){const r=typeof e=="string"?e:e.map(i=>i.type==="text"?i.text:`[${i.type}]`).join(" ");super(r),this.name="ToolError",this.content=e}}return t})();const qb="\\x00-\\x1f\\x7f-\\x9f\\u061c\\u200e\\u200f\\u2028\\u2029\\u202a-\\u202e\\u2066-\\u2069",Lb=new RegExp(`[${qb}]+`,"g"),Ub=/[\uD800-\uDFFF]/gu;function mi(t){return t.replace(Ub,"�")}const Wp=4096,Fb=200;function Wb(t,n=Wp){return Hp(mi(t).replace(Lb," ").trim(),n)}function jb(t){return Wb(t,Fb)}function at(t){return jb(t).replace(/[' ]+/g," ").trim()}function jp(t){return`Error: ${t instanceof Error?t.message:String(t)}`}function Hb(t){return Hp(mi(jp(t)),Wp)}function Hp(t,n){if(t.length<=n)return t;let e=0,r=0;for(const i of t){if(r===n)break;r+=1,e+=i.length}return t.slice(0,e)}function Kb(t){return typeof t=="string"?mi(t):t.filter(n=>n.type==="text"&&n.text!=="").map(n=>({...n,text:mi(n.text)}))}function Bl(t){return"name"in t?t.name:"mcp_server_name"in t?t.mcp_server_name:t.type}function Db(t){return t instanceof Ta?t.content:jp(t)}async function Kp(t,n,e){try{const r=t.parse?t.parse(n):n;return{content:await t.run(r,e),isError:!1}}catch(r){return{content:Db(r),isError:!0}}}var gr,gn,Lt,lt,Ut,ze,j,mn,ee,yn,Ft,bn,J,Wt,ke,jt,Ne,mr,Ht,We,wn,yr,ie,vn,br,wr,kn,Il,ql,Ll,Gi,Ul,En,Sn,Vi,Fl,xn,Tn,Ji,Wl,jl;const Hl=500,Gb=1e4,Vb=12e4,Jb=3e4,Yb=1e3,Xb=3e4,Qb=5*6e4,Zb=6e4;function Dp(t){return t.type!=="session.status_idle"?!1:t.stop_reason?.type!=="requires_action"}function Gp(t){return t.type==="user.tool_confirmation"||t.type==="session.thread_status_terminated"}var ew=(()=>{class t{constructor(e,r){gr.set(this,void 0),gn.set(this,void 0),Lt.set(this,new Set),lt.set(this,!1),Ut.set(this,!1),ze.set(this,void 0),v(this,gr,e),v(this,gn,r)}noteEvent(e){o(this,Ut,"f")&&e.type==="session.thread_status_terminated"&&this.disarm(),!Gp(e)&&(v(this,Ut,!1),Dp(e)?this.arm():this.disarm())}noteHistoryRead(e){v(this,Ut,!e)}block(e){o(this,Lt,"f").add(e),o(this,ze,"f")!==void 0&&(v(this,lt,!0),clearTimeout(o(this,ze,"f")),v(this,ze,void 0))}unblock(e){o(this,Lt,"f").delete(e),o(this,Lt,"f").size===0&&o(this,lt,"f")&&this.arm()}abandon(e){o(this,Ut,"f")&&this.disarm(),this.unblock(e)}arm(){if(!(o(this,gr,"f")<=0)){if(o(this,Lt,"f").size>0){v(this,lt,!0);return}v(this,lt,!1),o(this,ze,"f")!==void 0&&clearTimeout(o(this,ze,"f")),v(this,ze,setTimeout(o(this,gn,"f"),o(this,gr,"f")))}}disarm(){v(this,lt,!1),o(this,ze,"f")!==void 0&&(clearTimeout(o(this,ze,"f")),v(this,ze,void 0))}}return gr=new WeakMap,gn=new WeakMap,Lt=new WeakMap,lt=new WeakMap,Ut=new WeakMap,ze=new WeakMap,t})(),Ws=(()=>{class t{constructor(e,r){j.add(this),mn.set(this,!1),ee.set(this,void 0),yn.set(this,void 0),Ft.set(this,void 0),bn.set(this,void 0),J.set(this,void 0),Wt.set(this,new Set),ke.set(this,new Set),jt.set(this,new Map),Ne.set(this,new Map),mr.set(this,new Set),Ht.set(this,new Ib),We.set(this,0),wn.set(this,Qb),yr.set(this,null),ie.set(this,void 0),vn.set(this,void 0),br.set(this,void 0),wr.set(this,!1),this.client=r.client,this.sessionId=e,this.tools=r.tools,this.maxIdleMs=r.maxIdleMs??Zb,v(this,J,B(r.client)),v(this,bn,new Map(r.tools.map(i=>[Bl(i),i]))),v(this,ee,new AbortController),v(this,yn,Zr(r.signal,o(this,ee,"f"))),v(this,Ft,r.requestOptions),v(this,ie,new ew(this.maxIdleMs,()=>{o(this,J,"f").info("session idle after its turn ended; stopping",{component:"session-tool-runner",session_id:this.sessionId,max_idle_ms:this.maxIdleMs}),o(this,ee,"f").abort()}))}get signal(){return o(this,ee,"f").signal}abort(){o(this,ee,"f").abort()}_setSendRetryWindow(e){v(this,wn,e)}async*[(mn=new WeakMap,ee=new WeakMap,yn=new WeakMap,Ft=new WeakMap,bn=new WeakMap,J=new WeakMap,Wt=new WeakMap,ke=new WeakMap,jt=new WeakMap,Ne=new WeakMap,mr=new WeakMap,Ht=new WeakMap,We=new WeakMap,wn=new WeakMap,yr=new WeakMap,ie=new WeakMap,vn=new WeakMap,br=new WeakMap,wr=new WeakMap,j=new WeakSet,Symbol.asyncIterator)](){if(o(this,mn,"f"))throw new P("Cannot iterate over a consumed SessionToolRunner");v(this,mn,!0),v(this,vn,this.client._tracer?xe.active():void 0),o(this,J,"f").info("session tool runner starting",{component:"session-tool-runner",session_id:this.sessionId});const e=o(this,j,"m",Il).call(this).catch(r=>{o(this,ee,"f").signal.aborted||o(this,J,"f").error("stream loop failed",{error:String(r)}),o(this,ee,"f").abort()});try{for(;;){const i=await o(this,Ht,"f").next(o(this,ee,"f").signal);if(i.done)break;yield i.value}await e;let r;for(;(r=o(this,Ht,"f").tryShift())!==void 0;)yield r}finally{o(this,ee,"f").abort(),o(this,ie,"f").disarm(),await e;try{await o(this,j,"m",jl).call(this)}catch(r){o(this,J,"f").warn("drain failed",{error:String(r)})}o(this,Ht,"f").close();for(const r of this.tools)try{await r.close?.()}catch(i){o(this,J,"f").warn("tool.close failed",{tool:Bl(r),error:String(i)})}o(this,yn,"f").call(this)}}}return kn=function(){return{...o(this,Ft,"f"),headers:g([va("session-tool-runner"),o(this,Ft,"f")?.headers]),signal:o(this,ee,"f").signal}},Il=async function(){const e=o(this,ee,"f");let r=Hl;for(;!e.signal.aborted;){try{const i=await this.client.beta.sessions.events.stream(this.sessionId,{},o(this,j,"m",kn).call(this));await o(this,j,"m",ql).call(this);for await(const s of i)if(r=Hl,await o(this,j,"m",Ul).call(this,s))return}catch(i){if(e.signal.throwIfAborted(),gi(i))throw o(this,J,"f").error("permanent stream failure, shutting down",{error:String(i)}),e.abort(),i;o(this,J,"f").warn("stream disconnected, reconnecting",{error:String(i),backoff_ms:r})}e.signal.throwIfAborted(),await kt(r,e.signal),r=Math.min(r*2,Gb)}},ql=async function(){const e=o(this,ee,"f"),r=[];let i=!1;v(this,wr,!1);try{for await(const c of this.client.beta.sessions.events.list(this.sessionId,{limit:1e3},o(this,j,"m",kn).call(this)))o(this,j,"m",Ll).call(this,c,r),Gp(c)||(i=Dp(c))}catch(c){e.signal.throwIfAborted(),o(this,J,"f").warn("reconcile list failed",{error:String(c)});for(const l of r)o(this,Wt,"f").delete(l.id);o(this,ie,"f").noteHistoryRead(!1),o(this,j,"m",Sn).call(this);return}v(this,wr,!0),o(this,ie,"f").noteHistoryRead(!0),o(this,j,"m",Sn).call(this);const s=r.filter(c=>!o(this,ke,"f").has(c.id));o(this,ie,"f").disarm();for(const c of s)await o(this,j,"m",Vi).call(this,c);for(const c of[...o(this,Ne,"f").values()]){const l=o(this,jt,"f").get(c.id);l!==void 0&&await o(this,j,"m",xn).call(this,c,l)}const a=s.filter(c=>!o(this,ke,"f").has(c.id)&&!o(this,j,"m",En).call(this,c)&&!o(this,Ne,"f").has(c.id));i&&a.length===0?o(this,ie,"f").arm():o(this,ie,"f").disarm()},Ll=function(e,r){o(this,j,"m",Gi).call(this,e),e.type==="agent.tool_use"||e.type==="agent.custom_tool_use"?(o(this,Wt,"f").add(e.id),o(this,ke,"f").has(e.id)||r.push(e)):e.type==="user.tool_result"?o(this,ke,"f").add(e.tool_use_id):e.type==="user.custom_tool_result"?o(this,ke,"f").add(e.custom_tool_use_id):e.type==="user.tool_confirmation"?o(this,ke,"f").has(e.tool_use_id)||o(this,jt,"f").set(e.tool_use_id,e.result):e.type==="session.thread_status_terminated"&&o(this,mr,"f").add(e.session_thread_id)},Gi=function(e){if(!(!this.client._tracer||o(this,br,"f")!==void 0))switch(e.type){case"session.thread_status_running":case"session.thread_status_idle":case"session.thread_status_rescheduled":case"session.thread_status_terminated":v(this,br,e.session_thread_id)}},Ul=async function(e){switch(o(this,ie,"f").noteEvent(e),o(this,wr,"f")&&o(this,j,"m",Gi).call(this,e),e.type){case"agent.tool_use":case"agent.custom_tool_use":return o(this,Wt,"f").has(e.id)||(o(this,Wt,"f").add(e.id),await o(this,j,"m",Vi).call(this,e)),!1;case"user.tool_confirmation":return await o(this,j,"m",Fl).call(this,e),!1;case"user.tool_result":return o(this,ke,"f").add(e.tool_use_id),!1;case"user.custom_tool_result":return o(this,ke,"f").add(e.custom_tool_use_id),!1;case"session.thread_status_terminated":return o(this,mr,"f").add(e.session_thread_id),o(this,j,"m",Sn).call(this),!1;case"session.status_terminated":case"session.deleted":return o(this,J,"f").info("session terminated",{component:"session-tool-runner",session_id:this.sessionId}),o(this,ee,"f").abort(),!0;default:return!1}},En=function(e){return!!e.session_thread_id&&o(this,mr,"f").has(e.session_thread_id)},Sn=function(){for(const e of o(this,Ne,"f").values())o(this,j,"m",En).call(this,e)&&(o(this,J,"f").info("session thread terminated; not executing",{component:"session-tool-runner",session_id:this.sessionId,session_thread_id:e.session_thread_id,tool:e.name,tool_use_id:e.id}),o(this,Ne,"f").delete(e.id),o(this,ie,"f").abandon(e.id))},Vi=async function(e){if(o(this,j,"m",En).call(this,e)){o(this,J,"f").debug("session thread terminated; not executing",{component:"session-tool-runner",session_id:this.sessionId,session_thread_id:e.session_thread_id,tool:e.name,tool_use_id:e.id});return}const r=e.evaluated_permission,i=r==="deny"?"deny":o(this,jt,"f").get(e.id);if(i===void 0){r===void 0||r==="allow"?await o(this,j,"m",Ji).call(this,e,void 0):o(this,Ne,"f").has(e.id)||(o(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}),o(this,Ne,"f").set(e.id,e),o(this,ie,"f").block(e.id));return}await o(this,j,"m",xn).call(this,e,i)},Fl=async function(e){o(this,jt,"f").set(e.tool_use_id,e.result);const r=o(this,Ne,"f").get(e.tool_use_id);r!==void 0&&await o(this,j,"m",xn).call(this,r,e.result)},xn=async function(e,r){const i=o(this,Ne,"f").delete(e.id);if(r==="allow"){o(this,J,"f").info("tool call confirmed",{component:"session-tool-runner",session_id:this.sessionId,tool:e.name,tool_use_id:e.id}),i||o(this,ie,"f").block(e.id);try{await o(this,j,"m",Ji).call(this,e,"allow")}finally{o(this,ie,"f").unblock(e.id)}return}i&&o(this,ie,"f").unblock(e.id),o(this,ke,"f").add(e.id),o(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}),o(this,j,"m",Tn).call(this,{event:e,toolUseId:e.id,name:e.name,isError:!1,posted:!1,confirmation:"deny"})},Tn=function(e){o(this,Ht,"f").push(e)},Ji=async function(e,r){var i,s;if(!o(this,ke,"f").has(e.id)){o(this,J,"f").info("executing tool",{component:"session-tool-runner",session_id:this.sessionId,tool:e.name,tool_use_id:e.id}),v(this,We,(i=o(this,We,"f"),i++,i));try{const a=o(this,bn,"f").get(e.name);if(!a){o(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}),r==="allow"&&o(this,ie,"f").disarm(),o(this,j,"m",Tn).call(this,{event:e,toolUseId:e.id,name:e.name,isError:!1,posted:!1,confirmation:r});return}let c,l;const d=o(this,Ft,"f")?.openTelemetry?.conversationId??(e.session_thread_id||o(this,br,"f")),_=new AbortController,h=Zr(o(this,ee,"f").signal,_),p=setTimeout(()=>_.abort(),Vb);try{const y={signal:o(this,ee,"f").signal,conversationId:d,sessionID:this.sessionId,parentContext:o(this,vn,"f")},w=await ka(this.client,a,e,y,async()=>{const E=await Kp(a,e.input,{toolUse:e,toolUseBlock:e,signal:_.signal}),S=rw(E.content),T=this.client._tracer?S.map((x,A)=>{const O=typeof E.content=="string"?void 0:E.content[A];return O&&O.type!=="text"&&x.type==="text"?O:x}):S;return{sent:S,content:T,isError:E.isError}});c=w.sent,l=w.isError}finally{clearTimeout(p),h()}const f=tw(e,l,c),b=await o(this,j,"m",Wl).call(this,f,e.id,d);o(this,j,"m",Tn).call(this,{event:e,result:f,toolUseId:e.id,name:e.name,isError:l,posted:b,confirmation:r})}finally{v(this,We,(s=o(this,We,"f"),s--,s)),o(this,We,"f")===0&&o(this,yr,"f")?.call(this)}}},Wl=async function(e,r,i){const s=o(this,ee,"f"),a=Date.now();let c,l=0;for(;;){l++,s.signal.throwIfAborted();try{return await this.client.beta.sessions.events.send(this.sessionId,{events:[e]},{...o(this,j,"m",kn).call(this),openTelemetry:{conversationId:i}}),o(this,ke,"f").add(r),!0}catch(d){if(c=d,gi(d))break;const _=o(this,wn,"f")-(Date.now()-a);if(_<=0)break;const h=Math.min(Up(Lp(l-1,Yb,Xb)),_);o(this,J,"f").warn("tool result send failed; retrying",{tool_use_id:r,attempt:l,backoff_ms:h,error:String(d)}),await kt(h,s.signal)}}return o(this,J,"f").error("failed to send tool result",{tool_use_id:r,attempts:l,error:String(c)}),!1},jl=async function(){o(this,We,"f")!==0&&(await Promise.race([new Promise(e=>v(this,yr,e)),kt(Jb)]),v(this,yr,null),o(this,We,"f")>0&&o(this,J,"f").warn("drain timeout exceeded"))},t})();function tw(t,n,e){return t.type==="agent.custom_tool_use"?{type:"user.custom_tool_result",custom_tool_use_id:t.id,is_error:n,content:e}:{type:"user.tool_result",tool_use_id:t.id,is_error:n,content:e}}function rw(t){if(typeof t=="string")return[{type:"text",text:t||"(no output)"}];const n=t.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(r=>({type:"text",text:r.text})),citations:{enabled:e.citations?.enabled??!1}}:{type:"text",text:JSON.stringify(e)});return n.length>0?n:[{type:"text",text:"(no output)"}]}const dk=15e3,Kl=5e3;function nw(t,n){if(!(t>=Kl))throw new P(`${n} must be at least ${Kl}ms (got ${t}); to run without memory sync, pass \`memorySyncIntervalMs: null\` to the worker instead`)}var An,vr,Yi,kr,ut;const Dl=3e4,iw=9e4,sw="NO_HEARTBEAT";function aw(t){return t.resources.some(n=>n.type==="memory_store")}function ow(t){if(!t)return null;let n;try{const r=t.replace(/-/g,"+").replace(/_/g,"/"),i=r.padEnd(Math.ceil(r.length/4)*4,"=");n=JSON.parse(Ns(Bb(i)))}catch{return null}if(n===null||typeof n!="object"||Array.isArray(n))return null;const e=n.sessions_token;return typeof e=="string"&&e!==""?e:null}var Gl=(()=>{class t{constructor(e){if(An.add(this),vr.set(this,void 0),e.unrestrictedPaths!==void 0)throw new P("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&&nw(e.memorySyncIntervalMs,"memorySyncIntervalMs"),this.memorySyncIntervalMs=e.memorySyncIntervalMs,this.memorySyncDeletions=e.memorySyncDeletions??"enabled",this.workerId=e.workerId,this.requestOptions=e.requestOptions,v(this,vr,e.signal)}async run(e){const{environmentId:r,environmentKey:i}=this;if(r===void 0||i===void 0)throw new P("EnvironmentWorker.run: environmentId and environmentKey are required to poll for work");const s=e??o(this,vr,"f"),a=new Fs({client:this.client,environmentId:r,environmentKey:i,...this.workerId!==void 0?{workerId:this.workerId}:{},...s?{signal:s}:{},...this.requestOptions!==void 0?{requestOptions:this.requestOptions}:{},autoStop:!1});for await(const c of a){const l=a._workSpan;try{await gb(this.client,l,a.signal,()=>o(this,An,"m",Yi).call(this,c,i,a.signal,l))}catch(d){if(a.signal?.aborted)throw d;B(this.client).error("work item failed",{work_id:c.id,error:String(d)})}}}async handleItem(e){const r=e?.workId??I("ANTHROPIC_WORK_ID"),i=e?.environmentId??I("ANTHROPIC_ENVIRONMENT_ID"),s=e?.sessionId??I("ANTHROPIC_SESSION_ID"),a=(e?.environmentKey??this.environmentKey??I("ANTHROPIC_ENVIRONMENT_KEY"))||void 0,c=e?.workSecret||I("ANTHROPIC_WORK_SECRET")||null;if(!r)throw new P("handleItem: workId is required — pass it or set ANTHROPIC_WORK_ID");if(!i)throw new P("handleItem: environmentId is required — pass it or set ANTHROPIC_ENVIRONMENT_ID");if(!s)throw new P("handleItem: sessionId is required — pass it or set ANTHROPIC_SESSION_ID");if(!a&&!c)throw new P("handleItem: environmentKey is required when there is no work secret — pass it, construct the worker with it, or set ANTHROPIC_ENVIRONMENT_KEY");const l={id:r,environment_id:i,secret:c,data:{type:"session",id:s}};await o(this,An,"m",Yi).call(this,l,a,e?.signal??o(this,vr,"f"))}}return vr=new WeakMap,An=new WeakSet,Yi=async function(e,r,i,s){const a=B(this.client),c=ow(e.secret),l=c??r;if(l===void 0)throw new P("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&&c===null&&a.warn("work item carried a secret payload but no sessions token could be extracted; falling back to the environment key",{work_id:e.id});const d=Fp(this.client,{authToken:l,helper:"environments-worker"}),_=e.data.id,h=new AbortController,p=Zr(i,h),f=new lw(h),b=await Fe(()=>import("./node.browser-5FosC0Jx.js"),__vite__mapDeps([0,1,2,3]));let y,w;const E=dw(d,e,f,a,this.requestOptions,A=>{y=A,w?._setSendRetryWindow(A)}).catch(A=>{h.signal.aborted||a.error("heartbeat loop failed",{work_id:e.id,error:String(A)}),h.abort()});let S=async()=>{},T,x=!1;try{if(e.data.type!=="session"){a.debug("skipping non-session work item",{work_id:e.id,type:e.data.type});return}const A=await d.beta.sessions.retrieve(_);if(A.status==="terminated"){a.info("skipping the work item of a terminated session",{session_id:_,work_id:e.id});return}if(c===null&&this.memorySyncIntervalMs!==null&&aw(A))throw new b.SessionMemoryError(`cannot mount the session's memories: the work item carried no sessions token (work_id=${e.id}, session_id=${_}); 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`);const O={workdir:this.workdir,client:d,session:A,...this.maxFileBytes!==void 0?{maxFileBytes:this.maxFileBytes}:{}};try{S=await b.setupSkills(O)}catch(U){a.warn("skill setup failed",{session_id:_,work_id:e.id,error:String(U)})}c!==null&&this.memorySyncIntervalMs!==null?(T=new b.SessionMemoryStores(d,{workdir:this.workdir,...this.memorySyncIntervalMs!==void 0?{syncIntervalMs:this.memorySyncIntervalMs}:{},syncDeletions:this.memorySyncDeletions}),await T.download(A),O.allowedRoots=T.roots,O.readOnlyRoots=T.readOnlyRoots):a.debug("memory stores disabled for this item",{work_id:e.id});const $=typeof this.tools=="function"?this.tools(O):this.tools??b.betaAgentToolset20260401(O);w=new Ws(_,{client:d,tools:$,...this.maxIdleMs!==void 0?{maxIdleMs:this.maxIdleMs}:{},...this.requestOptions!==void 0?{requestOptions:this.requestOptions}:{},signal:h.signal}),y!==void 0&&w._setSendRetryWindow(y);for await(const U of w)T&&await T.syncIfDue();x=!h.signal.aborted}finally{try{await S().catch(A=>{a.warn("skill cleanup failed",{session_id:_,work_id:e.id,error:String(A)})})}finally{if(T){const A=b.MEMORY_FLUSH_TIMEOUT_MS;x&&await Vl(T.finish(),A)&&a.warn(`final memory sync cut off after ${A}ms; the flush that follows still uploads changed files`,{session_id:_,work_id:e.id});const O=new AbortController;await Vl(T.flushWrites(O.signal),A)&&(O.abort(),a.warn(`memory flush cut off after ${A}ms; changed files it had not uploaded yet are not saved`,{session_id:_,work_id:e.id})),await T.dispose().catch(U=>{a.warn("memory store cleanup failed",{session_id:_,work_id:e.id,error:String(U)})})}}f.finish("runner_done"),p(),await E,f.lost?a.info("lease lost; released without stopping it",{session_id:_,work_id:e.id}):await cw(d,e,a,this.requestOptions),(f.lost||f.rejected)&&H(this.client,()=>s?.end())}},t})();async function Vl(t,n){let e;try{return await Promise.race([t.then(()=>!1,()=>!1),new Promise(r=>{e=setTimeout(()=>r(!0),n)})])}finally{e!==void 0&&clearTimeout(e)}}async function cw(t,n,e,r){try{await t.beta.environments.work.stop(n.id,{environment_id:n.environment_id,force:!0},{...r,headers:g([r?.headers])})}catch(i){er(i,409)||e.error("force-stop on exit failed",{work_id:n.id,error:String(i)})}}var lw=(()=>{class t{constructor(e){kr.set(this,void 0),ut.set(this,void 0),v(this,kr,e)}get signal(){return o(this,kr,"f").signal}finish(e){v(this,ut,o(this,ut,"f")??e),o(this,kr,"f").abort()}get lost(){return o(this,ut,"f")==="lease_lost"||o(this,ut,"f")==="assumed_lost"}get rejected(){return o(this,ut,"f")==="heartbeat_rejected"}}return kr=new WeakMap,ut=new WeakMap,t})();function uw(t){let n=t instanceof K?t.error:void 0;for(const e of["error","details","current_state"]){if(!ae(n))return{};n=n[e]}return ae(n)?n:{}}async function dw(t,n,e,r,i,s){let a=Dl,c=iw,l=Date.now(),d=sw;const _=async()=>{const h=new AbortController,p=Zr(e.signal,h),f=setTimeout(()=>h.abort(),a);try{const b=await t.beta.environments.work.heartbeat(n.id,{environment_id:n.environment_id,expected_last_heartbeat:d},{...i,headers:g([i?.headers]),signal:h.signal});l=Date.now(),d=b.last_heartbeat,b.ttl_seconds>0&&(c=b.ttl_seconds*1e3,a=Math.max(1e3,Math.min(c/2,Dl)),s?.(c)),(b.state==="stopping"||b.state==="stopped")&&(r.info("heartbeat signals shutdown",{work_id:n.id,state:b.state}),e.finish("heartbeat_stop")),b.lease_extended||(r.warn("lease not extended, shutting down",{work_id:n.id}),e.finish("heartbeat_stop"))}catch(b){if(e.signal.throwIfAborted(),er(b,412)){const y=uw(b);r.error("lease lost: heartbeat precondition failed",{work_id:n.id,server_state:y.state,server_ttl_seconds:y.ttl_seconds,server_last_heartbeat:y.last_heartbeat}),e.finish("lease_lost");return}if(gi(b))throw r.error("permanent heartbeat failure",{work_id:n.id,error:String(b)}),e.finish("heartbeat_rejected"),b;if(Date.now()-l>c){r.error("lease assumed lost: no successful heartbeat in ttl",{work_id:n.id,ttl_ms:c,error:String(b)}),e.finish("assumed_lost");return}r.warn("transient heartbeat failure",{work_id:n.id,error:String(b)})}finally{clearTimeout(f),p()}};for(await _();!e.signal.aborted;)await kt(a,e.signal),e.signal.throwIfAborted(),await _()}var Aa=(()=>{class t extends ra{}return t._errorName="BetaHeartbeatPreconditionFailedError",t})(),Jl=(()=>{class t extends k{retrieve(e,r,i){const{environment_id:s,betas:a,workspace_id:c}=r;return this._client.get(m`/v1/environments/${s}/work/${e}`,{...i,headers:g([{"anthropic-beta":[...a??[],"managed-agents-2026-04-01"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.environments.work.retrieve",i,{route:"/v1/environments/{environment_id}/work/{work_id}",attributes:{"anthropic.environment.id":s,"anthropic.environment.work.id":e}})})}update(e,r,i){const{environment_id:s,betas:a,workspace_id:c,...l}=r;return this._client.post(m`/v1/environments/${s}/work/${e}`,{body:l,...i,headers:g([{"anthropic-beta":[...a??[],"managed-agents-2026-04-01"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.environments.work.update",i,{route:"/v1/environments/{environment_id}/work/{work_id}",attributes:{"anthropic.environment.id":s,"anthropic.environment.work.id":e}})})}list(e,r={},i){const{betas:s,...a}=r??{};return this._client.getAPIList(m`/v1/environments/${e}/work`,z,{query:a,...i,headers:g([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.environments.work.list",i,{route:"/v1/environments/{environment_id}/work",queryParams:["limit","page"],attributes:{"anthropic.environment.id":e}})})}ack(e,r,i){const{environment_id:s,betas:a}=r;return this._client.post(m`/v1/environments/${s}/work/${e}/ack`,{...i,headers:g([{"anthropic-beta":[...a??[],"managed-agents-2026-04-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.environments.work.ack",i,{route:"/v1/environments/{environment_id}/work/{work_id}/ack",attributes:{"anthropic.environment.id":s,"anthropic.environment.work.id":e}})})}heartbeat(e,r,i){const{environment_id:s,desired_ttl_seconds:a,expected_last_heartbeat:c,betas:l}=r;return this._client.post(m`/v1/environments/${s}/work/${e}/heartbeat`,{query:{desired_ttl_seconds:a,expected_last_heartbeat:c},...i,headers:g([{"anthropic-beta":[...l??[],"managed-agents-2026-04-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.environments.work.heartbeat",i,{route:"/v1/environments/{environment_id}/work/{work_id}/heartbeat",queryParams:["desired_ttl_seconds","expected_last_heartbeat"],attributes:{"anthropic.environment.id":s,"anthropic.environment.work.id":e}})})}poll(e,r={},i){const{betas:s,"Anthropic-Worker-ID":a,...c}=r??{};return this._client.get(m`/v1/environments/${e}/work/poll`,{query:c,...i,headers:g([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"Anthropic-Worker-ID":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.environments.work.poll",i,{route:"/v1/environments/{environment_id}/work/poll",queryParams:["block_ms","reclaim_older_than_ms"],attributes:{"anthropic.environment.id":e}})})}stats(e,r={},i){const{betas:s,workspace_id:a}=r??{};return this._client.get(m`/v1/environments/${e}/work/stats`,{...i,headers:g([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.environments.work.stats",i,{route:"/v1/environments/{environment_id}/work/stats",attributes:{"anthropic.environment.id":e}})})}stop(e,r,i){const{environment_id:s,betas:a,workspace_id:c,...l}=r;return this._client.post(m`/v1/environments/${s}/work/${e}/stop`,{body:l,...i,headers:g([{"anthropic-beta":[...a??[],"managed-agents-2026-04-01"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.environments.work.stop",i,{route:"/v1/environments/{environment_id}/work/{work_id}/stop",attributes:{"anthropic.environment.id":s,"anthropic.environment.work.id":e}})})}poller(e){return new Fs({...e,client:this._client})}worker(e){return new Gl({...e,client:this._client})}}return t.BetaHeartbeatPreconditionFailedError=Aa,t.WorkPoller=Fs,t.EnvironmentWorker=Gl,t})(),Ra=(()=>{class t extends R{}return t._errorName="BetaEnvironmentArchivedError",t})(),za=(()=>{class t extends R{}return t._errorName="BetaInvalidConfigTypeChangeError",t})(),Pa=(()=>{class t extends R{}return t._errorName="BetaInvalidMetadataError",t})(),Ca=(()=>{class t extends oe{}return t._errorName="BetaEnvironmentCreateDisabledError",t})(),Oa=(()=>{class t extends oe{}return t._errorName="BetaEnvironmentUpdateDisabledError",t})(),Na=(()=>{class t extends Ye{}return t._errorName="BetaEnvironmentNotFoundError",t})(),Yl=(()=>{class t extends k{constructor(){super(...arguments),this.work=new Jl(this._client)}create(e,r){const{betas:i,workspace_id:s,...a}=e;return this._client.post("/v1/environments",{body:a,...r,headers:g([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.environments.create",r,{route:"/v1/environments",createdIDAttribute:"anthropic.environment.id"})})}retrieve(e,r={},i){const{betas:s,workspace_id:a}=r??{};return this._client.get(m`/v1/environments/${e}`,{...i,headers:g([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.environments.retrieve",i,{route:"/v1/environments/{environment_id}",attributes:{"anthropic.environment.id":e}})})}update(e,r,i){const{betas:s,workspace_id:a,...c}=r;return this._client.post(m`/v1/environments/${e}`,{body:c,...i,headers:g([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.environments.update",i,{route:"/v1/environments/{environment_id}",attributes:{"anthropic.environment.id":e}})})}list(e={},r){const{betas:i,workspace_id:s,...a}=e??{};return this._client.getAPIList("/v1/environments",z,{query:a,...r,headers:g([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.environments.list",r,{route:"/v1/environments",queryParams:["include_archived","limit","page"]})})}delete(e,r={},i){const{betas:s,workspace_id:a}=r??{};return this._client.delete(m`/v1/environments/${e}`,{...i,headers:g([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.environments.delete",i,{route:"/v1/environments/{environment_id}",attributes:{"anthropic.environment.id":e}})})}archive(e,r={},i){const{betas:s,workspace_id:a}=r??{};return this._client.post(m`/v1/environments/${e}/archive`,{...i,headers:g([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.environments.archive",i,{route:"/v1/environments/{environment_id}/archive",attributes:{"anthropic.environment.id":e}})})}}return t.BetaEnvironmentArchivedError=Ra,t.BetaInvalidConfigTypeChangeError=za,t.BetaInvalidMetadataError=Pa,t.BetaEnvironmentCreateDisabledError=Ca,t.BetaEnvironmentUpdateDisabledError=Oa,t.BetaEnvironmentNotFoundError=Na,t.Work=Jl,t.BetaHeartbeatPreconditionFailedError=Aa,t})();class Xl extends k{create(n,e,r){const{view:i,betas:s,workspace_id:a,...c}=e;return this._client.post(m`/v1/memory_stores/${n}/memories`,{query:{view:i},body:c,...r,headers:g([{"anthropic-beta":[...s??[],"agent-memory-2026-07-22"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.memory_stores.memories.create",r,{route:"/v1/memory_stores/{memory_store_id}/memories",queryParams:["view"],attributes:{"gen_ai.memory.store.id":n},createdIDAttribute:"gen_ai.memory.record.id"})})}retrieve(n,e,r){const{memory_store_id:i,betas:s,workspace_id:a,...c}=e;return this._client.get(m`/v1/memory_stores/${i}/memories/${n}`,{query:c,...r,headers:g([{"anthropic-beta":[...s??[],"agent-memory-2026-07-22"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.memory_stores.memories.retrieve",r,{route:"/v1/memory_stores/{memory_store_id}/memories/{memory_id}",queryParams:["view"],attributes:{"gen_ai.memory.store.id":i,"gen_ai.memory.record.id":n}})})}update(n,e,r){const{memory_store_id:i,view:s,betas:a,workspace_id:c,...l}=e;return this._client.post(m`/v1/memory_stores/${i}/memories/${n}`,{query:{view:s},body:l,...r,headers:g([{"anthropic-beta":[...a??[],"agent-memory-2026-07-22"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.memory_stores.memories.update",r,{route:"/v1/memory_stores/{memory_store_id}/memories/{memory_id}",queryParams:["view"],attributes:{"gen_ai.memory.store.id":i,"gen_ai.memory.record.id":n}})})}list(n,e={},r){const{betas:i,workspace_id:s,...a}=e??{};return this._client.getAPIList(m`/v1/memory_stores/${n}/memories`,z,{query:a,...r,headers:g([{"anthropic-beta":[...i??[],"agent-memory-2026-07-22"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.memory_stores.memories.list",r,{route:"/v1/memory_stores/{memory_store_id}/memories",queryParams:["depth","limit","page","path_prefix","view"],contentQueryParams:["page"],attributes:{"gen_ai.memory.store.id":n}})})}delete(n,e,r){const{memory_store_id:i,expected_content_sha256:s,betas:a,workspace_id:c}=e;return this._client.delete(m`/v1/memory_stores/${i}/memories/${n}`,{query:{expected_content_sha256:s},...r,headers:g([{"anthropic-beta":[...a??[],"agent-memory-2026-07-22"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.memory_stores.memories.delete",r,{route:"/v1/memory_stores/{memory_store_id}/memories/{memory_id}",queryParams:["expected_content_sha256"],attributes:{"gen_ai.memory.store.id":i,"gen_ai.memory.record.id":n}})})}}class Ql extends k{retrieve(n,e,r){const{memory_store_id:i,betas:s,workspace_id:a,...c}=e;return this._client.get(m`/v1/memory_stores/${i}/memory_versions/${n}`,{query:c,...r,headers:g([{"anthropic-beta":[...s??[],"agent-memory-2026-07-22"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.memory_stores.memory_versions.retrieve",r,{route:"/v1/memory_stores/{memory_store_id}/memory_versions/{memory_version_id}",queryParams:["view"],attributes:{"gen_ai.memory.store.id":i,"anthropic.memory_store.memory_version.id":n}})})}list(n,e={},r){const{betas:i,workspace_id:s,...a}=e??{};return this._client.getAPIList(m`/v1/memory_stores/${n}/memory_versions`,z,{query:a,...r,headers:g([{"anthropic-beta":[...i??[],"agent-memory-2026-07-22"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.memory_stores.memory_versions.list",r,{route:"/v1/memory_stores/{memory_store_id}/memory_versions",queryParams:["api_key_id","created_at[gte]","created_at[lte]","limit","memory_id","operation","page","service_account_id","session_id","view"],attributes:{"gen_ai.memory.store.id":n}})})}redact(n,e,r){const{memory_store_id:i,betas:s,workspace_id:a}=e;return this._client.post(m`/v1/memory_stores/${i}/memory_versions/${n}/redact`,{...r,headers:g([{"anthropic-beta":[...s??[],"agent-memory-2026-07-22"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.memory_stores.memory_versions.redact",r,{route:"/v1/memory_stores/{memory_store_id}/memory_versions/{memory_version_id}/redact",attributes:{"gen_ai.memory.store.id":i,"anthropic.memory_store.memory_version.id":n}})})}}var Zl=(()=>{class t extends k{constructor(){super(...arguments),this.memories=new Xl(this._client),this.memoryVersions=new Ql(this._client)}create(e,r){const{betas:i,workspace_id:s,...a}=e;return this._client.post("/v1/memory_stores",{body:a,...r,headers:g([{"anthropic-beta":[...i??[],"agent-memory-2026-07-22"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.memory_stores.create",r,{route:"/v1/memory_stores",createdIDAttribute:"gen_ai.memory.store.id"})})}retrieve(e,r={},i){const{betas:s,workspace_id:a}=r??{};return this._client.get(m`/v1/memory_stores/${e}`,{...i,headers:g([{"anthropic-beta":[...s??[],"agent-memory-2026-07-22"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.memory_stores.retrieve",i,{route:"/v1/memory_stores/{memory_store_id}",attributes:{"gen_ai.memory.store.id":e}})})}update(e,r,i){const{betas:s,workspace_id:a,...c}=r;return this._client.post(m`/v1/memory_stores/${e}`,{body:c,...i,headers:g([{"anthropic-beta":[...s??[],"agent-memory-2026-07-22"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.memory_stores.update",i,{route:"/v1/memory_stores/{memory_store_id}",attributes:{"gen_ai.memory.store.id":e}})})}list(e={},r){const{betas:i,workspace_id:s,...a}=e??{};return this._client.getAPIList("/v1/memory_stores",z,{query:a,...r,headers:g([{"anthropic-beta":[...i??[],"agent-memory-2026-07-22"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.memory_stores.list",r,{route:"/v1/memory_stores",queryParams:["created_at[gte]","created_at[lte]","include_archived","limit","page"]})})}delete(e,r={},i){const{betas:s,workspace_id:a}=r??{};return this._client.delete(m`/v1/memory_stores/${e}`,{...i,headers:g([{"anthropic-beta":[...s??[],"agent-memory-2026-07-22"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.memory_stores.delete",i,{route:"/v1/memory_stores/{memory_store_id}",attributes:{"gen_ai.memory.store.id":e}})})}archive(e,r={},i){const{betas:s,workspace_id:a}=r??{};return this._client.post(m`/v1/memory_stores/${e}/archive`,{...i,headers:g([{"anthropic-beta":[...s??[],"agent-memory-2026-07-22"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.memory_stores.archive",i,{route:"/v1/memory_stores/{memory_store_id}/archive",attributes:{"gen_ai.memory.store.id":e}})})}}return t.Memories=Xl,t.MemoryVersions=Ql,t})(),Vp=(()=>{class t{constructor(e,r,i){this.iterator=e,this.response=i,this.controller=r}async*decoder(){const e=this.iterator;if(!e)throw new P("Cannot iterate over a consumed stream.");this.iterator=void 0;const r=new W_;for await(const i of e)for(const s of r.decode(i))yield JSON.parse(s);for(const i of r.flush())yield JSON.parse(i)}[Symbol.asyncIterator](){return this.decoder()}static fromResponse(e,r){if(!e.body)throw r.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new P("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 P("Attempted to iterate over a response with no body");return new t(aa(e.body),r,e)}}return t})();let eu=class extends k{create(n,e){const{betas:r,user_profile_id:i,workspace_id:s,...a}=n;return this._client.post("/v1/messages/batches",{body:a,...e,headers:g([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0,...i!=null?{"anthropic-user-profile-id":i}:void 0,...s!=null?{"anthropic-workspace-id":s}:void 0},e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.messages.batches.create",e,{route:"/v1/messages/batches",attributes:{"anthropic.message.batch.request_count":a.requests?.length},createdIDAttribute:"anthropic.message.batch.id"})})}retrieve(n,e={},r){const{betas:i,workspace_id:s}=e??{};return this._client.get(m`/v1/messages/batches/${n}`,{...r,headers:g([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.messages.batches.retrieve",r,{route:"/v1/messages/batches/{message_batch_id}",attributes:{"anthropic.message.batch.id":n}})})}list(n={},e){const{betas:r,workspace_id:i,...s}=n??{};return this._client.getAPIList("/v1/messages/batches",de,{query:s,...e,headers:g([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0,...i!=null?{"anthropic-workspace-id":i}:void 0},e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.messages.batches.list",e,{route:"/v1/messages/batches",queryParams:["after_id","before_id","limit"]})})}delete(n,e={},r){const{betas:i,workspace_id:s}=e??{};return this._client.delete(m`/v1/messages/batches/${n}`,{...r,headers:g([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.messages.batches.delete",r,{route:"/v1/messages/batches/{message_batch_id}",attributes:{"anthropic.message.batch.id":n}})})}cancel(n,e={},r){const{betas:i,workspace_id:s}=e??{};return this._client.post(m`/v1/messages/batches/${n}/cancel`,{...r,headers:g([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.messages.batches.cancel",r,{route:"/v1/messages/batches/{message_batch_id}/cancel",attributes:{"anthropic.message.batch.id":n}})})}async results(n,e={},r){const i=await this.retrieve(n,e,r);if(!i.results_url)throw new P(`No batch \`results_url\`; Has it finished processing? ${i.processing_status} - ${i.id}`);const{betas:s,workspace_id:a}=e??{};return this._client.get(i.results_url,{...r,headers:g([{Accept:"application/binary",...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0,...a!=null?{"anthropic-workspace-id":a}:void 0},r?.headers]),stream:!0,__qualifiers:{beta:"true"},__binaryResponse:!0,__span:u(this._client,"anthropic.messages.batches.results",r,{route:"/v1/messages/batches/{message_batch_id}/results",attributes:{"anthropic.message.batch.id":n}})})._thenUnwrap((c,l)=>Vp.fromResponse(l.response,l.controller))}};const Jp={"claude-opus-4@20250514":8192,"anthropic.claude-opus-4-1-20250805-v1:0":8192,"claude-opus-4-1@20250805":8192},yi={"claude-mythos-preview":"June 30th, 2026","claude-opus-4-5":"January 22nd, 2027","claude-opus-4-5-20251101":"January 22nd, 2027","claude-sonnet-4-5":"November 30th, 2026","claude-sonnet-4-5-20250929":"November 30th, 2026"},Yp=["claude-opus-4-6","claude-mythos-preview"];function Xp(t){return t?.output_format??t?.output_config?.format}function tu(t,n,e){const r=Xp(n);return!n||!("parse"in(r??{}))?{...t,content:t.content.map(i=>{if(i.type==="text"){const s=Object.defineProperty({...i},"parsed_output",{value:null,enumerable:!1});return Object.defineProperty(s,"parsed",{get(){return e.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead."),null},enumerable:!1})}return i}),parsed_output:null}:Ma(t,n,e)}function Ma(t,n,e){let r=null;const i=t.content.map(s=>{if(s.type==="text"){const a=hw(n,s.text);r===null&&(r=a);const c=Object.defineProperty({...s},"parsed_output",{value:a,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."),a},enumerable:!1})}return s});return{...t,content:i,parsed_output:r}}function hw(t,n){const e=Xp(t);if(e?.type!=="json_schema")return null;try{return"parse"in e?e.parse(n):JSON.parse(n)}catch(r){throw new P(`Failed to parse structured output: ${r}`)}}function Qp(t,n){const{betas:e,user_profile_id:r,workspace_id:i,tools:s,messages:a}=t;return g([{...e?.toString()!=null?{"anthropic-beta":e?.toString()}:void 0,...r!=null?{"anthropic-user-profile-id":r}:void 0,...i!=null?{"anthropic-workspace-id":i}:void 0},mp(s,a),n?.headers])}function _w(t,n,e){if(!t._tracer)return;const r=Qp(n,e);return u(t,"anthropic.messages.create",e,Oi(t,{body:js(n),headers:r,stream:!0}))}function js(t){if(!t.output_format)return t;$a(t);const{output_format:n,...e}=t;return{...e,output_config:{...t.output_config,format:n}}}function $a(t){if(t.output_format&&t.output_config?.format)throw new P("Both output_format and output_config.format were provided. Please use only output_config.format (output_format is deprecated).")}const Zp=["true","false","null"],ef=t=>t===" "||t===" "||t===`
|
|
58
58
|
`||t==="\r",pw=(t,n)=>Zp.some(e=>e!==t&&e.startsWith(t))&&[...n].every(ef),fw=t=>{let n=0,e=[];for(;n<t.length;){let r=t[n];if(r==="{"){e.push({type:"brace",value:"{"}),n++;continue}if(r==="}"){e.push({type:"brace",value:"}"}),n++;continue}if(r==="["){e.push({type:"paren",value:"["}),n++;continue}if(r==="]"){e.push({type:"paren",value:"]"}),n++;continue}if(r===":"){e.push({type:"separator",value:":"}),n++;continue}if(r===","){e.push({type:"delimiter",value:","}),n++;continue}if(r==='"'){const a=n+1;let c=a,l=!1;for(;;){if(c=t.indexOf('"',c),c===-1){l=!0;break}let d=0,_=c-1;for(;_>=a&&t[_]==="\\";)d++,_--;if(d%2===0)break;c++}l?n=t.length:(e.push({type:"string",value:t.slice(a,c)}),n=c+1);continue}if(ef(r)){n++;continue}let i=/[0-9]/;if(r&&i.test(r)||r==="-"||r==="."){let a="";for(r==="-"&&(a+=r,r=t[++n]);r&&(i.test(r)||r==="."||r==="e"||r==="E"||(r==="-"||r==="+")&&(a[a.length-1]==="e"||a[a.length-1]==="E"));)a+=r,r=t[++n];e.push({type:"number",value:a,unterminated:n===t.length});continue}let s=/[a-z]/i;if(r&&s.test(r)){let a="";for(;r&&s.test(r)&&n!==t.length;)a+=r,r=t[++n];if(Zp.includes(a))e.push({type:"name",value:a});else if(!pw(a,t.slice(n)))return null;continue}return null}return e},gw=t=>{let n=[];for(const s of t)(s.type==="brace"||s.type==="paren")&&(s.value==="{"||s.value==="["?n.push(s.value):n.pop());let e=n[n.length-1],r=t.length,i=/^-?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][-+]?[0-9]+)?$/;for(;r>0;){let s=t[r-1];switch(s.type){case"separator":r--;continue;case"number":if(s.unterminated||!i.test(s.value)){r--;continue}break;case"string":let a=t[r-2];if(e==="{"&&(a?.type==="delimiter"||a?.type==="brace"&&a.value==="{")){r--;continue}break;case"delimiter":r--;break}break}return t.slice(0,r)},mw=t=>{let n=[];for(const e of t)if(!(e.type!=="brace"&&e.type!=="paren")){if(e.value==="{")n.push("}");else if(e.value==="[")n.push("]");else if(n.pop()!==e.value)return null}return n.length>0&&n.reverse().map(e=>{e==="}"?t.push({type:"brace",value:"}"}):e==="]"&&t.push({type:"paren",value:"]"})}),t},ru=t=>t?.type==="string"||t?.type==="number"||t?.type==="name",yw=t=>{let n="";return t.map((e,r)=>{ru(t[r-1])&&ru(e)&&(n+=" "),e.type==="string"?n+='"'+e.value+'"':n+=e.value}),n},bw=t=>{const n=fw(t),e=n&&mw(gw(n));return JSON.parse(e?yw(e):t)},tr="__json_buf";function tf(t,n){const e={};for(const s of Object.keys(t))s!=="input"&&(e[s]=t[s]);Object.defineProperty(e,tr,{value:n,enumerable:!1,writable:!0});let r,i=!1;return Object.defineProperty(e,"input",{enumerable:!0,configurable:!0,get(){return i||(r=n?bw(n):{},i=!0),r}}),e}var fe,Ze,Me,Er,Rn,Sr,xr,zn,Tr,$e,Ar,Pn,Cn,dt,On,Nn,Mn,Rr,Be,ce,zr,Xi,nu,Pr,Qi,Zi,es,iu,ts;function rs(t){return t.type==="tool_use"||t.type==="server_tool_use"||t.type==="mcp_tool_use"}var Ba=(()=>{class t{constructor(e,r){fe.add(this),this.messages=[],this.receivedMessages=[],Ze.set(this,void 0),Me.set(this,null),this.controller=new AbortController,Er.set(this,void 0),Rn.set(this,()=>{}),Sr.set(this,()=>{}),xr.set(this,void 0),zn.set(this,()=>{}),Tr.set(this,()=>{}),$e.set(this,{}),Ar.set(this,!1),Pn.set(this,!1),Cn.set(this,!1),dt.set(this,!1),On.set(this,void 0),Nn.set(this,void 0),Mn.set(this,void 0),Rr.set(this,void 0),Be.set(this,void 0),ce.set(this,void 0),zr.set(this,void 0),Pr.set(this,i=>{if(v(this,Pn,!0),o(this,ce,"f")&&(o(this,ce,"f").streamed=void 0),Tt(i)&&(i=new be),i instanceof be)return v(this,Cn,!0),this._emit("abort",i);if(i instanceof P)return this._emit("error",i);if(i instanceof Error){const s=new P(i.message);return s.cause=i,this._emit("error",s)}return this._emit("error",new P(String(i)))}),v(this,Er,new Promise((i,s)=>{v(this,Rn,i,"f"),v(this,Sr,s,"f")})),v(this,xr,new Promise((i,s)=>{v(this,zn,i,"f"),v(this,Tr,s,"f")})),o(this,Er,"f").catch(()=>{}),o(this,xr,"f").catch(()=>{}),v(this,Me,e),v(this,Rr,r?.logger??console),v(this,Be,r?.client)}get response(){return o(this,On,"f")}get request_id(){return o(this,Nn,"f")}get workspace_id(){return o(this,Mn,"f")}async withResponse(){v(this,dt,!0);const e=await o(this,Er,"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){const r=new t(null);return r._run(()=>r._fromReadableStream(e)),r}static createMessage(e,r,i,{logger:s,client:a}={}){const c=new t(r,{logger:s,client:a});for(const l of r.messages)c._addMessageParam(l);return v(c,Me,{...r,stream:!0}),c._run(()=>c._createMessage((l,d)=>e.create(l,d),{...r,stream:!0},{...i,headers:{...i?.headers,[wa]:"stream"}})),c}_start(e,r,i,s){for(const l of r.messages)this._addMessageParam(l);const a=o(this,Be,"f");v(this,Be,void 0);const c=(l,d)=>e(l,d)._thenUnwrap((_,{options:h})=>(v(this,Be,a),v(this,ce,h.__span),v(this,zr,h.body),_));this._run(()=>this._createMessage(c,{...r,stream:!0},i).finally(s))}_run(e){e().then(()=>{this._emitFinal(),this._emit("end")},o(this,Pr,"f"))}_addMessageParam(e){this.messages.push(e)}_addMessage(e,r=!0){this.receivedMessages.push(e),r&&this._emit("message",e)}async _createMessage(e,r,i){const s=i?.signal;let a;s&&(s.aborted&&this.controller.abort(),a=this.controller.abort.bind(this.controller),s.addEventListener("abort",a));try{o(this,fe,"m",Qi).call(this),v(this,ce,i?.__span??(o(this,Be,"f")&&_w(o(this,Be,"f"),r,i)),"f");const{response:c,data:l}=await e({...r,stream:!0},{...i,__span:o(this,ce,"f"),signal:this.controller.signal}).withResponse();try{this._connected(c)}catch(d){throw o(this,ce,"f")&&(o(this,ce,"f").failure=d),l.controller.abort(),d}for await(const d of l)try{o(this,fe,"m",Zi).call(this,d)}catch(_){throw o(this,ce,"f")&&(o(this,ce,"f").failure=_),_}if(l.controller.signal?.aborted)throw new be;o(this,fe,"m",es).call(this)}finally{s&&a&&s.removeEventListener("abort",a)}}_connected(e){this.ended||(v(this,On,e),v(this,Nn,e?.headers.get("request-id")),v(this,Mn,e?.headers.get("anthropic-workspace-id")),o(this,Rn,"f").call(this,e),this._emit("connect"))}get ended(){return o(this,Ar,"f")}get errored(){return o(this,Pn,"f")}get aborted(){return o(this,Cn,"f")}abort(){this.controller.abort()}on(e,r){return(o(this,$e,"f")[e]||(o(this,$e,"f")[e]=[])).push({listener:r}),this}off(e,r){const i=o(this,$e,"f")[e];if(!i)return this;const s=i.findIndex(a=>a.listener===r);return s>=0&&i.splice(s,1),this}once(e,r){return(o(this,$e,"f")[e]||(o(this,$e,"f")[e]=[])).push({listener:r,once:!0}),this}emitted(e){return new Promise((r,i)=>{v(this,dt,!0),e!=="error"&&this.once("error",i),this.once(e,r)})}async done(){v(this,dt,!0),await o(this,xr,"f")}get currentMessage(){return o(this,Ze,"f")}async finalMessage(){return await this.done(),o(this,fe,"m",Xi).call(this)}async finalText(){return await this.done(),o(this,fe,"m",nu).call(this)}_emit(e,...r){if(o(this,Ar,"f"))return;e==="end"&&(v(this,Ar,!0),o(this,zn,"f").call(this));const i=o(this,$e,"f")[e];if(i&&(o(this,$e,"f")[e]=i.filter(s=>!s.once),i.forEach(({listener:s})=>s(...r))),e==="abort"){const s=r[0];!o(this,dt,"f")&&!i?.length&&Promise.reject(s),o(this,Sr,"f").call(this,s),o(this,Tr,"f").call(this,s),this._emit("end");return}if(e==="error"){const s=r[0];!o(this,dt,"f")&&!i?.length&&Promise.reject(s),o(this,Sr,"f").call(this,s),o(this,Tr,"f").call(this,s),this._emit("end")}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit("finalMessage",o(this,fe,"m",Xi).call(this))}_deliverEvent(e,r){this._emit("_rawEvent",e),r&&this._emit("streamEvent",e,r)}async _fromReadableStream(e,r){const i=r?.signal;let s;i&&(i.aborted&&this.controller.abort(),s=this.controller.abort.bind(this.controller),i.addEventListener("abort",s));try{o(this,fe,"m",Qi).call(this),this._connected(null);const a=Je.fromReadableStream(e,this.controller);for await(const c of a)o(this,fe,"m",Zi).call(this,c);if(a.controller.signal?.aborted)throw new be;o(this,fe,"m",es).call(this)}finally{i&&s&&i.removeEventListener("abort",s)}}[(Ze=new WeakMap,Me=new WeakMap,Er=new WeakMap,Rn=new WeakMap,Sr=new WeakMap,xr=new WeakMap,zn=new WeakMap,Tr=new WeakMap,$e=new WeakMap,Ar=new WeakMap,Pn=new WeakMap,Cn=new WeakMap,dt=new WeakMap,On=new WeakMap,Nn=new WeakMap,Mn=new WeakMap,Rr=new WeakMap,Be=new WeakMap,ce=new WeakMap,zr=new WeakMap,Pr=new WeakMap,fe=new WeakSet,Xi=function(){if(this.receivedMessages.length===0)throw new P("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},nu=function(){if(this.receivedMessages.length===0)throw new P("stream ended without producing a Message with role=assistant");const r=this.receivedMessages.at(-1).content.filter(i=>i.type==="text").map(i=>i.text);if(r.length===0)throw new P("stream ended without producing a content block with type=text");return r.join(" ")},Qi=function(){this.ended||v(this,Ze,void 0)},Zi=function(r){if(this.ended)return;const i=o(this,fe,"m",iu).call(this,r);if(this._deliverEvent(r,i),!!i)switch(r.type){case"content_block_delta":{const s=i.content.at(-1);switch(r.delta.type){case"text_delta":{s.type==="text"&&this._emit("text",r.delta.text,s.text||"");break}case"citations_delta":{s.type==="text"&&this._emit("citation",r.delta.citation,s.citations??[]);break}case"input_json_delta":{if(rs(s)&&o(this,$e,"f").inputJson?.length){let a;try{a=s.input}catch(c){o(this,Pr,"f").call(this,o(this,fe,"m",ts).call(this,s,c));break}this._emit("inputJson",r.delta.partial_json,a)}break}case"thinking_delta":{s.type==="thinking"&&this._emit("thinking",r.delta.thinking,s.thinking);break}case"signature_delta":{s.type==="thinking"&&this._emit("signature",s.signature);break}case"compaction_delta":{s.type==="compaction"&&s.content&&this._emit("compaction",s.content);break}default:r.delta}break}case"message_stop":{o(this,Be,"f")&&o(this,ce,"f")&&o(this,Me,"f")&&ba(o(this,Be,"f"),o(this,ce,"f"),o(this,zr,"f")??o(this,Me,"f"),i),this._addMessageParam(i),this._addMessage(tu(i,o(this,Me,"f"),{logger:o(this,Rr,"f")}),!0);break}case"content_block_stop":{this._emit("contentBlock",i.content.at(-1));break}case"message_start":{v(this,Ze,i),o(this,ce,"f")&&o(this,Me,"f")&&(o(this,ce,"f").streamed={body:o(this,zr,"f")??o(this,Me,"f"),message:i});break}}},es=function(){if(this.ended)throw new P("stream has ended, this shouldn't happen");const r=o(this,Ze,"f");if(!r)throw new P("request ended without sending any chunks");return v(this,Ze,void 0),tu(r,o(this,Me,"f"),{logger:o(this,Rr,"f")})},iu=function(r){let i=o(this,Ze,"f");if(r.type==="message_start"){if(i)throw new P(`Unexpected event order, got ${r.type} before receiving "message_stop"`);return r.message}if(i)switch(r.type){case"message_stop":return i;case"message_delta":return i.stop_reason=r.delta.stop_reason,i.stop_sequence=r.delta.stop_sequence,i.stop_details=r.delta.stop_details,i.usage.output_tokens=r.usage.output_tokens,r.delta.container!=null&&(i.container=r.delta.container),r.context_management!=null&&(i.context_management=r.context_management),r.input_transformations!=null&&(i.input_transformations=r.input_transformations),r.usage.input_tokens!=null&&(i.usage.input_tokens=r.usage.input_tokens),r.usage.cache_creation_input_tokens!=null&&(i.usage.cache_creation_input_tokens=r.usage.cache_creation_input_tokens),r.usage.cache_read_input_tokens!=null&&(i.usage.cache_read_input_tokens=r.usage.cache_read_input_tokens),r.usage.server_tool_use!=null&&(i.usage.server_tool_use=r.usage.server_tool_use),r.usage.iterations!=null&&(i.usage.iterations=r.usage.iterations),r.usage.fallback_credit!=null&&(i.usage.fallback_credit=r.usage.fallback_credit),r.usage.output_tokens_details!=null&&(i.usage.output_tokens_details=r.usage.output_tokens_details),i;case"content_block_start":return i.content.push(r.content_block),r.content_block.type==="fallback"&&(i.model=r.content_block.to.model),i;case"content_block_delta":{const s=i.content.at(r.index);switch(r.delta.type){case"text_delta":{s?.type==="text"&&(i.content[r.index]={...s,text:(s.text||"")+r.delta.text});break}case"citations_delta":{s?.type==="text"&&(i.content[r.index]={...s,citations:[...s.citations??[],r.delta.citation]});break}case"input_json_delta":{if(s&&rs(s)){const a=(s[tr]||"")+r.delta.partial_json;i.content[r.index]=tf(s,a)}break}case"thinking_delta":{s?.type==="thinking"&&(i.content[r.index]={...s,thinking:s.thinking+r.delta.thinking});break}case"signature_delta":{s?.type==="thinking"&&(i.content[r.index]={...s,signature:r.delta.signature});break}case"compaction_delta":{if(s?.type==="compaction"){const a={...s,content:r.delta.content};"encrypted_content"in r.delta&&(a.encrypted_content=r.delta.encrypted_content),i.content[r.index]=a}break}default:r.delta}return i}case"content_block_stop":{const s=i.content.at(r.index);if(s&&rs(s)&&tr in s){let a;try{a=s.input}catch(c){a={},o(this,Pr,"f").call(this,o(this,fe,"m",ts).call(this,s,c))}Object.defineProperty(s,"input",{value:a,enumerable:!0,configurable:!0,writable:!0})}return i}default:return i}},ts=function(r,i){const s=r[tr];return new P(`Unable to parse tool parameter JSON from model. Please retry your request or adjust your prompt. Error: ${i}. JSON: ${s}`)},Symbol.asyncIterator)](){const e=[],r=[];let i=!1;return this.on("_rawEvent",s=>{const a=r.shift();a?a.resolve(s):e.push(s)}),this.on("end",()=>{i=!0;for(const s of r)s.resolve(void 0);r.length=0}),this.on("abort",s=>{i=!0;for(const a of r)a.reject(s);r.length=0}),this.on("error",s=>{i=!0;for(const a of r)a.reject(s);r.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:i?{value:void 0,done:!0}:new Promise((a,c)=>r.push({resolve:a,reject:c})).then(a=>a?{value:a,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new Je(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}return t})();const rf={browser_toolset_20260801:"browser",computer_toolset_20260801:"computer"};function sr(t){return rf[t.type]}function en(t){return"run"in t&&t.type!=null&&Object.prototype.hasOwnProperty.call(rf,t.type)}var nf=(()=>{class t extends P{constructor(e,r){super(e),r&&"cause"in r&&(this.cause=r.cause)}}return t._errorName="ToolsetUsageError",t})(),ii=(()=>{class t extends nf{}return t._errorName="ToolsetContractError",t})();const sf="Not executed: an earlier action in this turn failed.",su={browser:sf,computer:"Not executed: an earlier computer action in this turn failed."};function ww(t){return Object.prototype.hasOwnProperty.call(su,t)?su[t]:sf}function bi(t,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:t.id,toolset_name:t.toolset_name??null,content:n,...e?{is_error:!0}:{}}}function vw(t,n){if(t instanceof nf)throw t;kw(n.signal)}function kw(t){if(t?.aborted)throw new be}async function Ew(t,n,e={}){const r=sr(t);if(n.toolset_name!==r)throw new ii(`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(r)} toolset`);const i={...e,toolUse:n,toolUseBlock:n};try{return bi(n,await t.run(i,n))}catch(s){return vw(s,i),bi(n,Kb(s instanceof Ta?s.content:Hb(s)),!0)}}let au=class extends k{retrieve(n,e){return this._client.get(m`/v1/organizations/api_keys/${n}`,{...e,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.api_keys.retrieve",e,{route:"/v1/organizations/api_keys/{api_key_id}",attributes:{"anthropic.organization.api_key.id":n}})})}update(n,e,r){return this._client.post(m`/v1/organizations/api_keys/${n}`,{body:e,...r,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.api_keys.update",r,{route:"/v1/organizations/api_keys/{api_key_id}",attributes:{"anthropic.organization.api_key.id":n}})})}list(n={},e){return this._client.getAPIList("/v1/organizations/api_keys",de,{query:n,...e,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.api_keys.list",e,{route:"/v1/organizations/api_keys",queryParams:["after_id","before_id","created_by_user_id","limit","status","workspace_id"]})})}},ou=class extends k{list(n,e){return this._client.getAPIList("/v1/organizations/analytics/artifacts",z,{query:n,...e,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.analytics.artifacts.list",e,{route:"/v1/organizations/analytics/artifacts",queryParams:["date","filter","group_by","limit","page"]})})}},cu=class extends k{list(n={},e){return this._client.getAPIList("/v1/organizations/analytics/connectors",z,{query:n,...e,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.analytics.connectors.list",e,{route:"/v1/organizations/analytics/connectors",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"],contentQueryParams:["filter"]})})}};class lu extends k{list(n,e){const{betas:r,...i}=n;return this._client.getAPIList("/v1/organizations/analytics/cost",cr,{query:i,...e,headers:g([{"anthropic-beta":[...r??[],"analytics-usage-cost-2026-08-24"].toString()},e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.analytics.cost.list",e,{route:"/v1/organizations/analytics/cost",queryParams:["actor_ids","actor_types","agent_ids","api_key_ids","claude_tag_categories","claude_tag_user_ids","context_windows","deployment_ids","ending_at","environment_ids","exclude_deleted_users","group_by","inference_geos","limit","models","order","order_by","organization_ids","page","products","rbac_group_ids","service_tiers","session_ids","slack_channel_ids","speeds","starting_at","time_bucket_width","user_profile_ids","workspace_ids"]})})}}class uu extends k{list(n,e){return this._client.getAPIList("/v1/organizations/analytics/cost_report",cr,{query:n,...e,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.analytics.cost_report.list",e,{route:"/v1/organizations/analytics/cost_report",queryParams:["bucket_width","claude_tag_categories","claude_tag_user_ids","context_windows","ending_at","group_by","inference_geos","limit","models","page","products","rbac_group_ids","slack_channel_ids","speeds","starting_at","user_ids"]})})}}let du=class extends k{list(n={},e){return this._client.getAPIList("/v1/organizations/analytics/plugins",z,{query:n,...e,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.analytics.plugins.list",e,{route:"/v1/organizations/analytics/plugins",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"],contentQueryParams:["filter"]})})}},hu=class extends k{list(n={},e){return this._client.getAPIList("/v1/organizations/analytics/skills",z,{query:n,...e,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.analytics.skills.list",e,{route:"/v1/organizations/analytics/skills",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"],contentQueryParams:["filter"]})})}},_u=class extends k{list(n,e){return this._client.getAPIList("/v1/organizations/analytics/summaries",z,{query:n,...e,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.analytics.summaries.list",e,{route:"/v1/organizations/analytics/summaries",queryParams:["ending_date","filter","limit","page","starting_date"]})})}};class pu extends k{list(n,e){const{betas:r,...i}=n;return this._client.getAPIList("/v1/organizations/analytics/usage",cr,{query:i,...e,headers:g([{"anthropic-beta":[...r??[],"analytics-usage-cost-2026-08-24"].toString()},e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.analytics.usage.list",e,{route:"/v1/organizations/analytics/usage",queryParams:["actor_ids","actor_types","agent_ids","api_key_ids","claude_tag_categories","claude_tag_user_ids","context_windows","deployment_ids","ending_at","environment_ids","exclude_deleted_users","group_by","inference_geos","limit","models","order","order_by","organization_ids","page","products","rbac_group_ids","service_tiers","session_ids","slack_channel_ids","speeds","starting_at","time_bucket_width","user_profile_ids","workspace_ids"]})})}}class fu extends k{list(n,e){return this._client.getAPIList("/v1/organizations/analytics/usage_report",cr,{query:n,...e,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.analytics.usage_report.list",e,{route:"/v1/organizations/analytics/usage_report",queryParams:["bucket_width","claude_tag_categories","claude_tag_user_ids","context_windows","ending_at","group_by","inference_geos","limit","models","page","products","rbac_group_ids","slack_channel_ids","speeds","starting_at","user_ids"]})})}}class gu extends k{list(n,e){return this._client.getAPIList("/v1/organizations/analytics/user_cost_report",cr,{query:n,...e,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.analytics.user_cost_report.list",e,{route:"/v1/organizations/analytics/user_cost_report",queryParams:["bucket_width","claude_tag_categories","claude_tag_user_ids","context_windows","ending_at","exclude_deleted_users","group_by","inference_geos","limit","models","order","order_by","page","products","rbac_group_ids","slack_channel_ids","speeds","starting_at","user_ids"]})})}}class mu extends k{list(n,e){return this._client.getAPIList("/v1/organizations/analytics/user_usage_report",cr,{query:n,...e,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.analytics.user_usage_report.list",e,{route:"/v1/organizations/analytics/user_usage_report",queryParams:["bucket_width","claude_tag_categories","claude_tag_user_ids","context_windows","ending_at","exclude_deleted_users","group_by","inference_geos","limit","models","order","order_by","page","products","rbac_group_ids","slack_channel_ids","speeds","starting_at","user_ids"]})})}}let yu=class extends k{list(n={},e){return this._client.getAPIList("/v1/organizations/analytics/users",z,{query:n,...e,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.analytics.users.list",e,{route:"/v1/organizations/analytics/users",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"],contentQueryParams:["page"]})})}},bu=class extends k{list(n={},e){return this._client.getAPIList("/v1/organizations/analytics/apps/chat/projects",z,{query:n,...e,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.analytics.apps.chat.projects.list",e,{route:"/v1/organizations/analytics/apps/chat/projects",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"]})})}};var wu=(()=>{class t extends k{constructor(){super(...arguments),this.projects=new bu(this._client)}}return t.Projects=bu,t})(),vu=(()=>{class t extends k{constructor(){super(...arguments),this.chat=new wu(this._client)}}return t.Chat=wu,t})(),ku=(()=>{class t extends k{constructor(){super(...arguments),this.summaries=new _u(this._client),this.users=new yu(this._client),this.apps=new vu(this._client),this.connectors=new cu(this._client),this.plugins=new du(this._client),this.skills=new hu(this._client),this.artifacts=new ou(this._client),this.usage=new pu(this._client),this.cost=new lu(this._client),this.usageReport=new fu(this._client),this.userUsageReport=new mu(this._client),this.costReport=new uu(this._client),this.userCostReport=new gu(this._client)}}return t.Summaries=_u,t.Users=yu,t.Apps=vu,t.Connectors=cu,t.Plugins=du,t.Skills=hu,t.Artifacts=ou,t.Usage=pu,t.Cost=lu,t.UsageReport=fu,t.UserUsageReport=mu,t.CostReport=uu,t.UserCostReport=gu,t})();let Eu=class extends k{retrieve(n={},e){const{betas:r}=n??{};return this._client.get("/v1/organizations/compliance_settings",{...e,headers:g([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.compliance_settings.retrieve",e,{route:"/v1/organizations/compliance_settings"})})}update(n,e){const{betas:r,...i}=n;return this._client.post("/v1/organizations/compliance_settings",{body:i,...e,headers:g([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.compliance_settings.update",e,{route:"/v1/organizations/compliance_settings"})})}},Su=class extends k{create(n,e){return this._client.post("/v1/organizations/external_keys",{body:n,...e,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.external_keys.create",e,{route:"/v1/organizations/external_keys",createdIDAttribute:"anthropic.organization.external_key.id"})})}retrieve(n,e){return this._client.get(m`/v1/organizations/external_keys/${n}`,{...e,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.external_keys.retrieve",e,{route:"/v1/organizations/external_keys/{external_key_id}",attributes:{"anthropic.organization.external_key.id":n}})})}update(n,e,r){return this._client.post(m`/v1/organizations/external_keys/${n}`,{body:e,...r,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.external_keys.update",r,{route:"/v1/organizations/external_keys/{external_key_id}",attributes:{"anthropic.organization.external_key.id":n}})})}list(n={},e){return this._client.getAPIList("/v1/organizations/external_keys",z,{query:n,...e,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.external_keys.list",e,{route:"/v1/organizations/external_keys",queryParams:["limit","page"]})})}delete(n,e){return this._client.delete(m`/v1/organizations/external_keys/${n}`,{...e,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.external_keys.delete",e,{route:"/v1/organizations/external_keys/{external_key_id}",attributes:{"anthropic.organization.external_key.id":n}})})}validate(n,e){return this._client.post(m`/v1/organizations/external_keys/${n}/validate`,{...e,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.external_keys.validate",e,{route:"/v1/organizations/external_keys/{external_key_id}/validate",attributes:{"anthropic.organization.external_key.id":n}})})}};var Ia=(()=>{class t extends R{}return t._errorName="BetaExternalStorageInUseError",t})(),qa=(()=>{class t extends R{}return t._errorName="BetaExternalStorageInWorkspacePolicyError",t})(),La=(()=>{class t extends R{}return t._errorName="BetaExternalStorageNotAvailableError",t})(),Ua=(()=>{class t extends R{}return t._errorName="BetaGrantRequiredError",t})(),Fa=(()=>{class t extends R{}return t._errorName="BetaInvalidStorageARNError",t})(),Wa=(()=>{class t extends R{}return t._errorName="BetaProviderNotAllowedError",t})(),ja=(()=>{class t extends R{}return t._errorName="BetaStorageAttachLimitReachedError",t})(),Ha=(()=>{class t extends R{}return t._errorName="BetaStorageNotAttachableError",t})(),Ka=(()=>{class t extends R{}return t._errorName="BetaStorageProfileStillRequiredError",t})(),Da=(()=>{class t extends R{}return t._errorName="BetaStorageVerificationFailedError",t})(),Ga=(()=>{class t extends R{}return t._errorName="BetaUnsupportedRegionError",t})(),Va=(()=>{class t extends ue{}return t._errorName="BetaStorageAlreadyRegisteredError",t})(),Ja=(()=>{class t extends ue{}return t._errorName="BetaStorageChangedConcurrentlyError",t})(),xu=(()=>{class t extends k{create(e,r){const{betas:i,...s}=e;return this._client.post("/v1/organizations/external_storage",{body:s,...r,headers:g([{"anthropic-beta":[...i??[],"efs-2026-10-01"].toString()},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.external_storage.create",r,{route:"/v1/organizations/external_storage",createdIDAttribute:"anthropic.organization.external_storage.id"})})}retrieve(e,r={},i){const{betas:s}=r??{};return this._client.get(m`/v1/organizations/external_storage/${e}`,{...i,headers:g([{"anthropic-beta":[...s??[],"efs-2026-10-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.external_storage.retrieve",i,{route:"/v1/organizations/external_storage/{external_storage_id}",attributes:{"anthropic.organization.external_storage.id":e}})})}update(e,r,i){const{betas:s,...a}=r;return this._client.post(m`/v1/organizations/external_storage/${e}`,{body:a,...i,headers:g([{"anthropic-beta":[...s??[],"efs-2026-10-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.external_storage.update",i,{route:"/v1/organizations/external_storage/{external_storage_id}",attributes:{"anthropic.organization.external_storage.id":e}})})}list(e={},r){const{betas:i,...s}=e??{};return this._client.getAPIList("/v1/organizations/external_storage",z,{query:s,...r,headers:g([{"anthropic-beta":[...i??[],"efs-2026-10-01"].toString()},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.external_storage.list",r,{route:"/v1/organizations/external_storage",queryParams:["limit","page","user_profile_ids"]})})}delete(e,r={},i){const{betas:s}=r??{};return this._client.delete(m`/v1/organizations/external_storage/${e}`,{...i,headers:g([{"anthropic-beta":[...s??[],"efs-2026-10-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.external_storage.delete",i,{route:"/v1/organizations/external_storage/{external_storage_id}",attributes:{"anthropic.organization.external_storage.id":e}})})}activate(e,r={},i){const{betas:s}=r??{};return this._client.post(m`/v1/organizations/external_storage/${e}/activate`,{...i,headers:g([{"anthropic-beta":[...s??[],"efs-2026-10-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.external_storage.activate",i,{route:"/v1/organizations/external_storage/{external_storage_id}/activate",attributes:{"anthropic.organization.external_storage.id":e}})})}}return t.BetaExternalStorageInUseError=Ia,t.BetaExternalStorageInWorkspacePolicyError=qa,t.BetaExternalStorageNotAvailableError=La,t.BetaGrantRequiredError=Ua,t.BetaInvalidStorageARNError=Fa,t.BetaProviderNotAllowedError=Wa,t.BetaStorageAttachLimitReachedError=ja,t.BetaStorageNotAttachableError=Ha,t.BetaStorageProfileStillRequiredError=Ka,t.BetaStorageVerificationFailedError=Da,t.BetaUnsupportedRegionError=Ga,t.BetaStorageAlreadyRegisteredError=Va,t.BetaStorageChangedConcurrentlyError=Ja,t})();let Tu=class extends k{create(n,e){return this._client.post("/v1/organizations/invites",{body:n,...e,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.invites.create",e,{route:"/v1/organizations/invites",createdIDAttribute:"anthropic.organization.invite.id"})})}retrieve(n,e){return this._client.get(m`/v1/organizations/invites/${n}`,{...e,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.invites.retrieve",e,{route:"/v1/organizations/invites/{invite_id}",attributes:{"anthropic.organization.invite.id":n}})})}list(n={},e){return this._client.getAPIList("/v1/organizations/invites",de,{query:n,...e,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.invites.list",e,{route:"/v1/organizations/invites",queryParams:["after_id","before_id","email","limit","roles","statuses"]})})}delete(n,e){return this._client.delete(m`/v1/organizations/invites/${n}`,{...e,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.invites.delete",e,{route:"/v1/organizations/invites/{invite_id}",attributes:{"anthropic.organization.invite.id":n}})})}};class Au extends k{retrieve(n,e={},r){const{betas:i,...s}=e??{};return this._client.get(m`/v1/organizations/plugin_marketplaces/${n}`,{query:s,...r,headers:g([{"anthropic-beta":[...i??[],"ce-plugins-2026-09-01"].toString()},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.plugin_marketplaces.retrieve",r,{route:"/v1/organizations/plugin_marketplaces/{marketplace_id}",queryParams:["organization_id"],attributes:{"anthropic.organization.plugin_marketplace.id":n}})})}update(n,e,r){const{betas:i,...s}=e;return this._client.post(m`/v1/organizations/plugin_marketplaces/${n}`,{body:s,...r,headers:g([{"anthropic-beta":[...i??[],"ce-plugins-2026-09-01"].toString()},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.plugin_marketplaces.update",r,{route:"/v1/organizations/plugin_marketplaces/{marketplace_id}",attributes:{"anthropic.organization.plugin_marketplace.id":n}})})}list(n={},e){const{betas:r,...i}=n??{};return this._client.getAPIList("/v1/organizations/plugin_marketplaces",z,{query:i,...e,headers:g([{"anthropic-beta":[...r??[],"ce-plugins-2026-09-01"].toString()},e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.plugin_marketplaces.list",e,{route:"/v1/organizations/plugin_marketplaces",queryParams:["limit","organization_id","owner_type","page","source"]})})}validateArchive(n,e){const{betas:r,...i}=n;return this._client.post("/v1/organizations/plugin_marketplaces/validate_archive",Xe({body:i,...e,headers:g([{"anthropic-beta":[...r??[],"ce-plugins-2026-09-01"].toString()},e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.plugin_marketplaces.validate_archive",e,{route:"/v1/organizations/plugin_marketplaces/validate_archive"})},this._client))}validateRepository(n,e){const{betas:r,...i}=n;return this._client.post("/v1/organizations/plugin_marketplaces/validate_repository",{body:i,...e,headers:g([{"anthropic-beta":[...r??[],"ce-plugins-2026-09-01"].toString()},e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.plugin_marketplaces.validate_repository",e,{route:"/v1/organizations/plugin_marketplaces/validate_repository"})})}}let Ru=class extends k{list(n={},e){return this._client.getAPIList("/v1/organizations/rate_limits",z,{query:n,...e,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.rate_limits.list",e,{route:"/v1/organizations/rate_limits",queryParams:["group_type","limit","model","page"]})})}};var Ya=(()=>{class t extends R{}return t._errorName="BetaCannotSignOutPrimaryOwnerError",t})(),Xa=(()=>{class t extends R{}return t._errorName="BetaCannotSignOutSelfError",t})(),Qa=(()=>{class t extends oe{}return t._errorName="BetaCannotSignOutManagedMemberError",t})(),Za=(()=>{class t extends oe{}return t._errorName="BetaCannotSignOutMembershipAdminError",t})(),eo=(()=>{class t extends oe{}return t._errorName="BetaCannotSignOutOwnerError",t})(),to=(()=>{class t extends oe{}return t._errorName="BetaCannotSignOutPrivilegedMemberError",t})(),zu=(()=>{class t extends k{retrieve(e,r){return this._client.get(m`/v1/organizations/users/${e}`,{...r,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.users.retrieve",r,{route:"/v1/organizations/users/{user_id}",attributes:{"anthropic.organization.user.id":e}})})}update(e,r,i){return this._client.post(m`/v1/organizations/users/${e}`,{body:r,...i,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.users.update",i,{route:"/v1/organizations/users/{user_id}",attributes:{"anthropic.organization.user.id":e}})})}list(e={},r){return this._client.getAPIList("/v1/organizations/users",de,{query:e,...r,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.users.list",r,{route:"/v1/organizations/users",queryParams:["after_id","before_id","email","limit","roles"]})})}remove(e,r){return this._client.delete(m`/v1/organizations/users/${e}`,{...r,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.users.remove",r,{route:"/v1/organizations/users/{user_id}",attributes:{"anthropic.organization.user.id":e}})})}signOut(e,r={},i){const{betas:s}=r??{};return this._client.post(m`/v1/organizations/users/${e}/sign_out`,{...i,headers:g([{"anthropic-beta":[...s??[],"admin-user-sign-out-2026-10-08"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.users.sign_out",i,{route:"/v1/organizations/users/{user_id}/sign_out",attributes:{"anthropic.organization.user.id":e}})})}}return t.BetaCannotSignOutPrimaryOwnerError=Ya,t.BetaCannotSignOutSelfError=Xa,t.BetaCannotSignOutManagedMemberError=Qa,t.BetaCannotSignOutMembershipAdminError=Za,t.BetaCannotSignOutOwnerError=eo,t.BetaCannotSignOutPrivilegedMemberError=to,t})();class Pu extends k{create(n,e){const{betas:r,...i}=n;return this._client.post("/v1/organizations/webhooks",{body:i,...e,headers:g([{"anthropic-beta":[...r??[],"webhooks-2026-10-07"].toString()},e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.webhooks.create",e,{route:"/v1/organizations/webhooks",createdIDAttribute:"anthropic.organization.webhook.id"})})}retrieve(n,e={},r){const{betas:i}=e??{};return this._client.get(m`/v1/organizations/webhooks/${n}`,{...r,headers:g([{"anthropic-beta":[...i??[],"webhooks-2026-10-07"].toString()},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.webhooks.retrieve",r,{route:"/v1/organizations/webhooks/{webhook_endpoint_id}",attributes:{"anthropic.organization.webhook.id":n}})})}update(n,e,r){const{betas:i,...s}=e;return this._client.post(m`/v1/organizations/webhooks/${n}`,{body:s,...r,headers:g([{"anthropic-beta":[...i??[],"webhooks-2026-10-07"].toString()},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.webhooks.update",r,{route:"/v1/organizations/webhooks/{webhook_endpoint_id}",attributes:{"anthropic.organization.webhook.id":n}})})}list(n={},e){const{betas:r,...i}=n??{};return this._client.getAPIList("/v1/organizations/webhooks",de,{query:i,...e,headers:g([{"anthropic-beta":[...r??[],"webhooks-2026-10-07"].toString()},e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.webhooks.list",e,{route:"/v1/organizations/webhooks",queryParams:["after_id","before_id","limit","order"]})})}delete(n,e={},r){const{betas:i}=e??{};return this._client.delete(m`/v1/organizations/webhooks/${n}`,{...r,headers:g([{"anthropic-beta":[...i??[],"webhooks-2026-10-07"].toString()},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.webhooks.delete",r,{route:"/v1/organizations/webhooks/{webhook_endpoint_id}",attributes:{"anthropic.organization.webhook.id":n}})})}regenerateSigningSecret(n,e={},r){const{betas:i}=e??{};return this._client.post(m`/v1/organizations/webhooks/${n}/regenerate_signing_secret`,{...r,headers:g([{"anthropic-beta":[...i??[],"webhooks-2026-10-07"].toString()},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.webhooks.regenerate_signing_secret",r,{route:"/v1/organizations/webhooks/{webhook_endpoint_id}/regenerate_signing_secret",attributes:{"anthropic.organization.webhook.id":n}})})}}class Cu extends k{retrieve(n={},e){const{betas:r}=n??{};return this._client.get("/v1/organizations/claude_code/managed_settings/configuration",{...e,headers:g([{"anthropic-beta":[...r??[],"ce-claude-code-managed-settings-2026-10-06"].toString()},e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.claude_code.managed_settings.configuration.retrieve",e,{route:"/v1/organizations/claude_code/managed_settings/configuration"})})}update(n,e){const{betas:r,...i}=n;return this._client.post("/v1/organizations/claude_code/managed_settings/configuration",{body:i,...e,headers:g([{"anthropic-beta":[...r??[],"ce-claude-code-managed-settings-2026-10-06"].toString()},e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.claude_code.managed_settings.configuration.update",e,{route:"/v1/organizations/claude_code/managed_settings/configuration"})})}}class Ou extends k{retrieve(n={},e){const{betas:r}=n??{};return this._client.get("/v1/organizations/claude_code/managed_settings/rbac_group_default",{...e,headers:g([{"anthropic-beta":[...r??[],"ce-claude-code-managed-settings-2026-10-06"].toString()},e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.claude_code.managed_settings.rbac_group_default.retrieve",e,{route:"/v1/organizations/claude_code/managed_settings/rbac_group_default"})})}update(n,e){const{betas:r,...i}=n;return this._client.post("/v1/organizations/claude_code/managed_settings/rbac_group_default",{body:i,...e,headers:g([{"anthropic-beta":[...r??[],"ce-claude-code-managed-settings-2026-10-06"].toString()},e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.claude_code.managed_settings.rbac_group_default.update",e,{route:"/v1/organizations/claude_code/managed_settings/rbac_group_default"})})}}let Nu=class extends k{retrieve(n,e={},r){const{betas:i}=e??{};return this._client.get(m`/v1/organizations/claude_code/managed_settings/rbac_groups/${n}`,{...r,headers:g([{"anthropic-beta":[...i??[],"ce-claude-code-managed-settings-2026-10-06"].toString()},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.claude_code.managed_settings.rbac_groups.retrieve",r,{route:"/v1/organizations/claude_code/managed_settings/rbac_groups/{rbac_group_id}",attributes:{"anthropic.organization.claude_code.managed_setting.rbac_group.id":n}})})}list(n={},e){const{betas:r,...i}=n??{};return this._client.getAPIList("/v1/organizations/claude_code/managed_settings/rbac_groups",z,{query:i,...e,headers:g([{"anthropic-beta":[...r??[],"ce-claude-code-managed-settings-2026-10-06"].toString()},e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.claude_code.managed_settings.rbac_groups.list",e,{route:"/v1/organizations/claude_code/managed_settings/rbac_groups",queryParams:["limit","page"]})})}delete(n,e={},r){const{betas:i}=e??{};return this._client.delete(m`/v1/organizations/claude_code/managed_settings/rbac_groups/${n}`,{...r,headers:g([{"anthropic-beta":[...i??[],"ce-claude-code-managed-settings-2026-10-06"].toString()},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.claude_code.managed_settings.rbac_groups.delete",r,{route:"/v1/organizations/claude_code/managed_settings/rbac_groups/{rbac_group_id}",attributes:{"anthropic.organization.claude_code.managed_setting.rbac_group.id":n}})})}set(n,e,r){const{betas:i,...s}=e;return this._client.post(m`/v1/organizations/claude_code/managed_settings/rbac_groups/${n}`,{body:s,...r,headers:g([{"anthropic-beta":[...i??[],"ce-claude-code-managed-settings-2026-10-06"].toString()},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.claude_code.managed_settings.rbac_groups.set",r,{route:"/v1/organizations/claude_code/managed_settings/rbac_groups/{rbac_group_id}",attributes:{"anthropic.organization.claude_code.managed_setting.rbac_group.id":n}})})}};var ro=(()=>{class t extends R{}return t._errorName="BetaCMEKFeatureUnsupportedError",t})(),no=(()=>{class t extends R{}return t._errorName="BetaRBACGroupOrderLimitExceededError",t})(),io=(()=>{class t extends R{}return t._errorName="BetaSettingsDocumentLimitExceededError",t})(),so=(()=>{class t extends R{}return t._errorName="BetaSettingsHistoryLimitExceededError",t})(),ao=(()=>{class t extends Ye{}return t._errorName="BetaRBACGroupManagedSettingsNotFoundError",t})(),Mu=(()=>{class t extends k{constructor(){super(...arguments),this.configuration=new Cu(this._client),this.rbacGroups=new Nu(this._client),this.rbacGroupDefault=new Ou(this._client)}}return t.BetaCMEKFeatureUnsupportedError=ro,t.BetaRBACGroupOrderLimitExceededError=no,t.BetaSettingsDocumentLimitExceededError=io,t.BetaSettingsHistoryLimitExceededError=so,t.BetaRBACGroupManagedSettingsNotFoundError=ao,t.Configuration=Cu,t.RBACGroups=Nu,t.RBACGroupDefault=Ou,t})(),$u=(()=>{class t extends k{constructor(){super(...arguments),this.managedSettings=new Mu(this._client)}}return t.ManagedSettings=Mu,t.BetaCMEKFeatureUnsupportedError=ro,t.BetaRBACGroupOrderLimitExceededError=no,t.BetaSettingsDocumentLimitExceededError=io,t.BetaSettingsHistoryLimitExceededError=so,t.BetaRBACGroupManagedSettingsNotFoundError=ao,t})();class Bu extends k{create(n,e){const{betas:r,...i}=n;return this._client.post("/v1/organizations/claude_tag/slack_channels",{body:i,...e,headers:g([{"anthropic-beta":[...r??[],"experimental-claude-tag-2026-10-21"].toString()},e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.claude_tag.slack_channels.create",e,{route:"/v1/organizations/claude_tag/slack_channels",createdIDAttribute:"anthropic.organization.claude_tag.slack_channel.id"})})}retrieve(n,e={},r){const{betas:i,...s}=e??{};return this._client.get(m`/v1/organizations/claude_tag/slack_channels/${n}`,{query:s,...r,headers:g([{"anthropic-beta":[...i??[],"experimental-claude-tag-2026-10-21"].toString()},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.claude_tag.slack_channels.retrieve",r,{route:"/v1/organizations/claude_tag/slack_channels/{id}",queryParams:["include_inherited"],attributes:{"anthropic.organization.claude_tag.slack_channel.id":n}})})}update(n,e,r){const{betas:i,...s}=e;return this._client.post(m`/v1/organizations/claude_tag/slack_channels/${n}`,{body:s,...r,headers:g([{"anthropic-beta":[...i??[],"experimental-claude-tag-2026-10-21"].toString()},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.claude_tag.slack_channels.update",r,{route:"/v1/organizations/claude_tag/slack_channels/{id}",attributes:{"anthropic.organization.claude_tag.slack_channel.id":n}})})}list(n,e){const{betas:r,...i}=n;return this._client.getAPIList("/v1/organizations/claude_tag/slack_channels",z,{query:i,...e,headers:g([{"anthropic-beta":[...r??[],"experimental-claude-tag-2026-10-21"].toString()},e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.claude_tag.slack_channels.list",e,{route:"/v1/organizations/claude_tag/slack_channels",queryParams:["include_inherited","limit","page","slack_channel_id","slack_workspace_id"]})})}delete(n,e={},r){const{betas:i}=e??{};return this._client.delete(m`/v1/organizations/claude_tag/slack_channels/${n}`,{...r,headers:g([{"anthropic-beta":[...i??[],"experimental-claude-tag-2026-10-21"].toString()},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.claude_tag.slack_channels.delete",r,{route:"/v1/organizations/claude_tag/slack_channels/{id}",attributes:{"anthropic.organization.claude_tag.slack_channel.id":n}})})}}class Iu extends k{retrieve(n,e={},r){const{betas:i,...s}=e??{};return this._client.get(m`/v1/organizations/claude_tag/slack_workspaces/${n}`,{query:s,...r,headers:g([{"anthropic-beta":[...i??[],"experimental-claude-tag-2026-10-21"].toString()},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.claude_tag.slack_workspaces.retrieve",r,{route:"/v1/organizations/claude_tag/slack_workspaces/{id}",queryParams:["include_inherited"],attributes:{"anthropic.organization.claude_tag.slack_workspace.id":n}})})}update(n,e,r){const{betas:i,...s}=e;return this._client.post(m`/v1/organizations/claude_tag/slack_workspaces/${n}`,{body:s,...r,headers:g([{"anthropic-beta":[...i??[],"experimental-claude-tag-2026-10-21"].toString()},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.claude_tag.slack_workspaces.update",r,{route:"/v1/organizations/claude_tag/slack_workspaces/{id}",attributes:{"anthropic.organization.claude_tag.slack_workspace.id":n}})})}list(n={},e){const{betas:r,...i}=n??{};return this._client.getAPIList("/v1/organizations/claude_tag/slack_workspaces",z,{query:i,...e,headers:g([{"anthropic-beta":[...r??[],"experimental-claude-tag-2026-10-21"].toString()},e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.claude_tag.slack_workspaces.list",e,{route:"/v1/organizations/claude_tag/slack_workspaces",queryParams:["include_inherited","limit","page","slack_workspace_id"]})})}}class qu extends k{create(n,e,r){const{target:i,betas:s}=e;return this._client.post(m`/v1/organizations/claude_tag/bundles/${n}/targets`,{body:i,...r,headers:g([{"anthropic-beta":[...s??[],"experimental-claude-tag-2026-10-21"].toString()},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.claude_tag.bundles.targets.create",r,{route:"/v1/organizations/claude_tag/bundles/{bundle_id}/targets",attributes:{"anthropic.organization.claude_tag.bundle.id":n}})})}retrieve(n,e,r){const{bundle_id:i,betas:s}=e;return this._client.get(m`/v1/organizations/claude_tag/bundles/${i}/targets/${n}`,{...r,headers:g([{"anthropic-beta":[...s??[],"experimental-claude-tag-2026-10-21"].toString()},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.claude_tag.bundles.targets.retrieve",r,{route:"/v1/organizations/claude_tag/bundles/{bundle_id}/targets/{target_id}",attributes:{"anthropic.organization.claude_tag.bundle.id":i,"anthropic.organization.claude_tag.bundle.target.id":n}})})}list(n,e={},r){const{betas:i,...s}=e??{};return this._client.getAPIList(m`/v1/organizations/claude_tag/bundles/${n}/targets`,z,{query:s,...r,headers:g([{"anthropic-beta":[...i??[],"experimental-claude-tag-2026-10-21"].toString()},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.claude_tag.bundles.targets.list",r,{route:"/v1/organizations/claude_tag/bundles/{bundle_id}/targets",queryParams:["limit","page"],attributes:{"anthropic.organization.claude_tag.bundle.id":n}})})}delete(n,e,r){const{bundle_id:i,betas:s}=e;return this._client.delete(m`/v1/organizations/claude_tag/bundles/${i}/targets/${n}`,{...r,headers:g([{"anthropic-beta":[...s??[],"experimental-claude-tag-2026-10-21"].toString()},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.claude_tag.bundles.targets.delete",r,{route:"/v1/organizations/claude_tag/bundles/{bundle_id}/targets/{target_id}",attributes:{"anthropic.organization.claude_tag.bundle.id":i,"anthropic.organization.claude_tag.bundle.target.id":n}})})}}var Lu=(()=>{class t extends k{constructor(){super(...arguments),this.targets=new qu(this._client)}retrieve(e,r={},i){const{betas:s}=r??{};return this._client.get(m`/v1/organizations/claude_tag/bundles/${e}`,{...i,headers:g([{"anthropic-beta":[...s??[],"experimental-claude-tag-2026-10-21"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.claude_tag.bundles.retrieve",i,{route:"/v1/organizations/claude_tag/bundles/{bundle_id}",attributes:{"anthropic.organization.claude_tag.bundle.id":e}})})}update(e,r,i){const{betas:s,...a}=r;return this._client.post(m`/v1/organizations/claude_tag/bundles/${e}`,{body:a,...i,headers:g([{"anthropic-beta":[...s??[],"experimental-claude-tag-2026-10-21"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.claude_tag.bundles.update",i,{route:"/v1/organizations/claude_tag/bundles/{bundle_id}",attributes:{"anthropic.organization.claude_tag.bundle.id":e}})})}list(e={},r){const{betas:i,...s}=e??{};return this._client.getAPIList("/v1/organizations/claude_tag/bundles",z,{query:s,...r,headers:g([{"anthropic-beta":[...i??[],"experimental-claude-tag-2026-10-21"].toString()},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.claude_tag.bundles.list",r,{route:"/v1/organizations/claude_tag/bundles",queryParams:["limit","page"]})})}}return t.Targets=qu,t})(),oo=(()=>{class t extends R{}return t._errorName="BetaBundleAttachmentNotSupportedError",t})(),co=(()=>{class t extends R{}return t._errorName="BetaBundleOnCallError",t})(),lo=(()=>{class t extends R{}return t._errorName="BetaSlackChannelSetUpSettingsRefusedError",t})(),uo=(()=>{class t extends oe{}return t._errorName="BetaAPIKeyScopeMissingError",t})(),ho=(()=>{class t extends oe{}return t._errorName="BetaClaudeTagWritesNotEnabledError",t})(),_o=(()=>{class t extends oe{}return t._errorName="BetaComplianceConfigurationRestrictedError",t})(),po=(()=>{class t extends oe{}return t._errorName="BetaOrganizationLevelScopedAPIKeyRequiredError",t})(),fo=(()=>{class t extends Ye{}return t._errorName="BetaSlackChannelSetUpEnvironmentNotFoundError",t})(),go=(()=>{class t extends ue{}return t._errorName="BetaSlackChannelSetUpSettingsConflictError",t})(),Uu=(()=>{class t extends k{constructor(){super(...arguments),this.slackChannels=new Bu(this._client),this.slackWorkspaces=new Iu(this._client),this.bundles=new Lu(this._client)}}return t.BetaBundleAttachmentNotSupportedError=oo,t.BetaBundleOnCallError=co,t.BetaSlackChannelSetUpSettingsRefusedError=lo,t.BetaAPIKeyScopeMissingError=uo,t.BetaClaudeTagWritesNotEnabledError=ho,t.BetaComplianceConfigurationRestrictedError=_o,t.BetaOrganizationLevelScopedAPIKeyRequiredError=po,t.BetaSlackChannelSetUpEnvironmentNotFoundError=fo,t.BetaSlackChannelSetUpSettingsConflictError=go,t.SlackChannels=Bu,t.SlackWorkspaces=Iu,t.Bundles=Lu,t})();let Fu=class extends k{create(n,e){const{betas:r,...i}=n;return this._client.post("/v1/organizations/federation_issuers",{body:i,...e,headers:g([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.federation.issuers.create",e,{route:"/v1/organizations/federation_issuers",createdIDAttribute:"anthropic.organization.federation_issuer.id"})})}retrieve(n,e={},r){const{betas:i}=e??{};return this._client.get(m`/v1/organizations/federation_issuers/${n}`,{...r,headers:g([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.federation.issuers.retrieve",r,{route:"/v1/organizations/federation_issuers/{federation_issuer_id}",attributes:{"anthropic.organization.federation_issuer.id":n}})})}update(n,e,r){const{betas:i,...s}=e;return this._client.post(m`/v1/organizations/federation_issuers/${n}`,{body:s,...r,headers:g([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.federation.issuers.update",r,{route:"/v1/organizations/federation_issuers/{federation_issuer_id}",attributes:{"anthropic.organization.federation_issuer.id":n}})})}list(n={},e){const{betas:r,...i}=n??{};return this._client.getAPIList("/v1/organizations/federation_issuers",z,{query:i,...e,headers:g([{...r?.toString()!=null?{"anthropic-beta":r?.toString()}:void 0},e?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.federation.issuers.list",e,{route:"/v1/organizations/federation_issuers",queryParams:["include_archived","limit","page"]})})}archive(n,e={},r){const{betas:i}=e??{};return this._client.post(m`/v1/organizations/federation_issuers/${n}/archive`,{...r,headers:g([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.federation.issuers.archive",r,{route:"/v1/organizations/federation_issuers/{federation_issuer_id}/archive",attributes:{"anthropic.organization.federation_issuer.id":n}})})}},Wu=class extends k{list(n,e={},r){const{betas:i,...s}=e??{};return this._client.getAPIList(m`/v1/organizations/federation_rules/${n}/workspaces`,z,{query:s,...r,headers:g([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.federation.rules.workspaces.list",r,{route:"/v1/organizations/federation_rules/{federation_rule_id}/workspaces",queryParams:["limit","page"],attributes:{"anthropic.organization.federation_rule.id":n}})})}add(n,e,r){const{betas:i,...s}=e;return this._client.post(m`/v1/organizations/federation_rules/${n}/workspaces`,{body:s,...r,headers:g([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.federation.rules.workspaces.add",r,{route:"/v1/organizations/federation_rules/{federation_rule_id}/workspaces",attributes:{"anthropic.organization.federation_rule.id":n},createdIDAttribute:"anthropic.organization.federation_rule.workspace.id",createdIDField:"workspace_id"})})}remove(n,e,r){const{federation_rule_id:i,betas:s}=e;return this._client.delete(m`/v1/organizations/federation_rules/${i}/workspaces/${n}`,{...r,headers:g([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.federation.rules.workspaces.remove",r,{route:"/v1/organizations/federation_rules/{federation_rule_id}/workspaces/{workspace_id}",attributes:{"anthropic.organization.federation_rule.id":i,"anthropic.organization.federation_rule.workspace.id":n}})})}};var ju=(()=>{class t extends k{constructor(){super(...arguments),this.workspaces=new Wu(this._client)}create(e,r){const{betas:i,...s}=e;return this._client.post("/v1/organizations/federation_rules",{body:s,...r,headers:g([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.federation.rules.create",r,{route:"/v1/organizations/federation_rules",createdIDAttribute:"anthropic.organization.federation_rule.id"})})}retrieve(e,r={},i){const{betas:s}=r??{};return this._client.get(m`/v1/organizations/federation_rules/${e}`,{...i,headers:g([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.federation.rules.retrieve",i,{route:"/v1/organizations/federation_rules/{federation_rule_id}",attributes:{"anthropic.organization.federation_rule.id":e}})})}update(e,r,i){const{betas:s,...a}=r;return this._client.post(m`/v1/organizations/federation_rules/${e}`,{body:a,...i,headers:g([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.federation.rules.update",i,{route:"/v1/organizations/federation_rules/{federation_rule_id}",attributes:{"anthropic.organization.federation_rule.id":e}})})}list(e={},r){const{betas:i,...s}=e??{};return this._client.getAPIList("/v1/organizations/federation_rules",z,{query:s,...r,headers:g([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.federation.rules.list",r,{route:"/v1/organizations/federation_rules",queryParams:["include_archived","issuer_id","limit","page"]})})}archive(e,r={},i){const{betas:s}=r??{};return this._client.post(m`/v1/organizations/federation_rules/${e}/archive`,{...i,headers:g([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.federation.rules.archive",i,{route:"/v1/organizations/federation_rules/{federation_rule_id}/archive",attributes:{"anthropic.organization.federation_rule.id":e}})})}}return t.Workspaces=Wu,t})(),Hu=(()=>{class t extends k{constructor(){super(...arguments),this.issuers=new Fu(this._client),this.rules=new ju(this._client)}}return t.Issuers=Fu,t.Rules=ju,t})();class Ku extends k{list(n,e={},r){const{betas:i,...s}=e??{};return this._client.getAPIList(m`/v1/organizations/plugins/${n}/installation_settings`,z,{query:s,...r,headers:g([{"anthropic-beta":[...i??[],"ce-plugins-2026-09-01"].toString()},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.plugins.installation_settings.list",r,{route:"/v1/organizations/plugins/{plugin_id}/installation_settings",queryParams:["limit","organization_id","page","target_type"],attributes:{"anthropic.organization.plugin.id":n}})})}remove(n,e,r){const{plugin_id:i,betas:s}=e;return this._client.delete(m`/v1/organizations/plugins/${i}/installation_settings/${n}`,{...r,headers:g([{"anthropic-beta":[...s??[],"ce-plugins-2026-09-01"].toString()},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.plugins.installation_settings.remove",r,{route:"/v1/organizations/plugins/{plugin_id}/installation_settings/{target}",attributes:{"anthropic.organization.plugin.id":i,"anthropic.organization.plugin.installation_setting.id":n}})})}set(n,e,r){const{plugin_id:i,betas:s,...a}=e;return this._client.post(m`/v1/organizations/plugins/${i}/installation_settings/${n}`,{body:a,...r,headers:g([{"anthropic-beta":[...s??[],"ce-plugins-2026-09-01"].toString()},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.plugins.installation_settings.set",r,{route:"/v1/organizations/plugins/{plugin_id}/installation_settings/{target}",attributes:{"anthropic.organization.plugin.id":i,"anthropic.organization.plugin.installation_setting.id":n}})})}}class Du extends k{list(n,e={},r){const{betas:i,...s}=e??{};return this._client.getAPIList(m`/v1/organizations/plugins/${n}/shares`,z,{query:s,...r,headers:g([{"anthropic-beta":[...i??[],"ce-plugins-2026-09-01"].toString()},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.plugins.shares.list",r,{route:"/v1/organizations/plugins/{plugin_id}/shares",queryParams:["limit","organization_id","page","target_type"],attributes:{"anthropic.organization.plugin.id":n}})})}}let Gu=class extends k{create(n,e,r){const{betas:i,...s}=e;return this._client.post(m`/v1/organizations/plugins/${n}/versions`,Xe({body:s,...r,headers:g([{"anthropic-beta":[...i??[],"ce-plugins-2026-09-01"].toString()},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.plugins.versions.create",r,{route:"/v1/organizations/plugins/{plugin_id}/versions",attributes:{"anthropic.organization.plugin.id":n},createdIDAttribute:"anthropic.organization.plugin.version.id"})},this._client))}retrieve(n,e,r){const{plugin_id:i,betas:s,...a}=e;return this._client.get(m`/v1/organizations/plugins/${i}/versions/${n}`,{query:a,...r,headers:g([{"anthropic-beta":[...s??[],"ce-plugins-2026-09-01"].toString()},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.plugins.versions.retrieve",r,{route:"/v1/organizations/plugins/{plugin_id}/versions/{version}",queryParams:["organization_id"],attributes:{"anthropic.organization.plugin.id":i,"anthropic.organization.plugin.version.id":n}})})}list(n,e={},r){const{betas:i,...s}=e??{};return this._client.getAPIList(m`/v1/organizations/plugins/${n}/versions`,z,{query:s,...r,headers:g([{"anthropic-beta":[...i??[],"ce-plugins-2026-09-01"].toString()},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.plugins.versions.list",r,{route:"/v1/organizations/plugins/{plugin_id}/versions",queryParams:["limit","organization_id","page"],attributes:{"anthropic.organization.plugin.id":n}})})}download(n,e,r){const{plugin_id:i,betas:s,...a}=e;return this._client.get(m`/v1/organizations/plugins/${i}/versions/${n}/content`,{query:a,...r,headers:g([{"anthropic-beta":[...s??[],"ce-plugins-2026-09-01"].toString(),Accept:"application/binary"},r?.headers]),__qualifiers:{beta:"true"},__binaryResponse:!0,__span:u(this._client,"anthropic.organization.plugins.versions.download",r,{route:"/v1/organizations/plugins/{plugin_id}/versions/{version}/content",queryParams:["organization_id"],attributes:{"anthropic.organization.plugin.id":i,"anthropic.organization.plugin.version.id":n}})})}};var mo=(()=>{class t extends R{}return t._errorName="BetaScanFailedError",t})(),yo=(()=>{class t extends ue{}return t._errorName="BetaPluginNameTakenError",t})(),bo=(()=>{class t extends ue{}return t._errorName="BetaScanPendingError",t})(),wo=(()=>{class t extends ue{}return t._errorName="BetaSkillNameTakenError",t})(),vo=(()=>{class t extends ot{}return t._errorName="BetaRegistrationPendingError",t})(),Vu=(()=>{class t extends k{constructor(){super(...arguments),this.versions=new Gu(this._client),this.installationSettings=new Ku(this._client),this.shares=new Du(this._client)}create(e,r){const{betas:i,...s}=e;return this._client.post("/v1/organizations/plugins",Xe({body:s,...r,headers:g([{"anthropic-beta":[...i??[],"ce-plugins-2026-09-01"].toString()},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.plugins.create",r,{route:"/v1/organizations/plugins",createdIDAttribute:"anthropic.organization.plugin.id"})},this._client))}retrieve(e,r={},i){const{betas:s,...a}=r??{};return this._client.get(m`/v1/organizations/plugins/${e}`,{query:a,...i,headers:g([{"anthropic-beta":[...s??[],"ce-plugins-2026-09-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.plugins.retrieve",i,{route:"/v1/organizations/plugins/{plugin_id}",queryParams:["organization_id"],attributes:{"anthropic.organization.plugin.id":e}})})}update(e,r,i){const{betas:s,...a}=r;return this._client.post(m`/v1/organizations/plugins/${e}`,{body:a,...i,headers:g([{"anthropic-beta":[...s??[],"ce-plugins-2026-09-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.plugins.update",i,{route:"/v1/organizations/plugins/{plugin_id}",attributes:{"anthropic.organization.plugin.id":e}})})}list(e={},r){const{betas:i,...s}=e??{};return this._client.getAPIList("/v1/organizations/plugins",z,{query:s,...r,headers:g([{"anthropic-beta":[...i??[],"ce-plugins-2026-09-01"].toString()},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.plugins.list",r,{route:"/v1/organizations/plugins",queryParams:["created_at[gt]","created_at[gte]","created_at[lt]","created_at[lte]","limit","marketplace_id","organization_id","owner_type","owner_user_id","page"]})})}delete(e,r={},i){const{betas:s}=r??{};return this._client.delete(m`/v1/organizations/plugins/${e}`,{...i,headers:g([{"anthropic-beta":[...s??[],"ce-plugins-2026-09-01"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.plugins.delete",i,{route:"/v1/organizations/plugins/{plugin_id}",attributes:{"anthropic.organization.plugin.id":e}})})}}return t.BetaScanFailedError=mo,t.BetaPluginNameTakenError=yo,t.BetaScanPendingError=bo,t.BetaSkillNameTakenError=wo,t.BetaRegistrationPendingError=vo,t.Versions=Gu,t.InstallationSettings=Ku,t.Shares=Du,t})();let Ju=class extends k{retrieve(n,e={},r){const{betas:i}=e??{};return this._client.get(m`/v1/organizations/providers/google/projects/${n}/data_controls`,{...r,headers:g([{"anthropic-beta":[...i??[],"google-managed-data-controls-2026-09-01"].toString()},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.providers.google.projects.data_controls.retrieve",r,{route:"/v1/organizations/providers/google/projects/{project_number}/data_controls",attributes:{"anthropic.organization.provider.google.project.id":n}})})}update(n,e,r){const{betas:i,...s}=e;return this._client.post(m`/v1/organizations/providers/google/projects/${n}/data_controls`,{body:s,...r,headers:g([{"anthropic-beta":[...i??[],"google-managed-data-controls-2026-09-01"].toString()},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.providers.google.projects.data_controls.update",r,{route:"/v1/organizations/providers/google/projects/{project_number}/data_controls",attributes:{"anthropic.organization.provider.google.project.id":n}})})}};var Yu=(()=>{class t extends k{constructor(){super(...arguments),this.dataControls=new Ju(this._client)}}return t.DataControls=Ju,t})(),Xu=(()=>{class t extends k{constructor(){super(...arguments),this.projects=new Yu(this._client)}}return t.Projects=Yu,t})(),Qu=(()=>{class t extends k{constructor(){super(...arguments),this.google=new Xu(this._client)}}return t.Google=Xu,t})();let Zu=class extends k{list(n,e={},r){return this._client.getAPIList(m`/v1/organizations/rbac_groups/${n}/members`,z,{query:e,...r,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.rbac_groups.members.list",r,{route:"/v1/organizations/rbac_groups/{rbac_group_id}/members",queryParams:["limit","page"],attributes:{"anthropic.organization.rbac_group.id":n}})})}add(n,e,r){return this._client.post(m`/v1/organizations/rbac_groups/${n}/members`,{body:e,...r,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.rbac_groups.members.add",r,{route:"/v1/organizations/rbac_groups/{rbac_group_id}/members",attributes:{"anthropic.organization.rbac_group.id":n},createdIDAttribute:"anthropic.organization.rbac_group.member.id",createdIDField:"user_id"})})}remove(n,e,r){const{rbac_group_id:i}=e;return this._client.delete(m`/v1/organizations/rbac_groups/${i}/members/${n}`,{...r,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.rbac_groups.members.remove",r,{route:"/v1/organizations/rbac_groups/{rbac_group_id}/members/{user_id}",attributes:{"anthropic.organization.rbac_group.id":i,"anthropic.organization.rbac_group.member.id":n}})})}};var ko=(()=>{class t extends Ye{}return t._errorName="BetaRBACGroupNotFoundError",t})(),ed=(()=>{class t extends k{constructor(){super(...arguments),this.members=new Zu(this._client)}create(e,r){return this._client.post("/v1/organizations/rbac_groups",{body:e,...r,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.rbac_groups.create",r,{route:"/v1/organizations/rbac_groups",createdIDAttribute:"anthropic.organization.rbac_group.id"})})}retrieve(e,r){return this._client.get(m`/v1/organizations/rbac_groups/${e}`,{...r,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.rbac_groups.retrieve",r,{route:"/v1/organizations/rbac_groups/{rbac_group_id}",attributes:{"anthropic.organization.rbac_group.id":e}})})}update(e,r,i){return this._client.post(m`/v1/organizations/rbac_groups/${e}`,{body:r,...i,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.rbac_groups.update",i,{route:"/v1/organizations/rbac_groups/{rbac_group_id}",attributes:{"anthropic.organization.rbac_group.id":e}})})}list(e={},r){return this._client.getAPIList("/v1/organizations/rbac_groups",z,{query:e,...r,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.rbac_groups.list",r,{route:"/v1/organizations/rbac_groups",queryParams:["limit","page"]})})}delete(e,r){return this._client.delete(m`/v1/organizations/rbac_groups/${e}`,{...r,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.rbac_groups.delete",r,{route:"/v1/organizations/rbac_groups/{rbac_group_id}",attributes:{"anthropic.organization.rbac_group.id":e}})})}}return t.BetaRBACGroupNotFoundError=ko,t.Members=Zu,t})();let td=class extends k{list(n,e={},r){return this._client.getAPIList(m`/v1/organizations/rbac_roles/${n}/permissions`,z,{query:e,...r,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.rbac_roles.permissions.list",r,{route:"/v1/organizations/rbac_roles/{rbac_role_id}/permissions",queryParams:["limit","page"],attributes:{"anthropic.organization.rbac_role.id":n}})})}};var rd=(()=>{class t extends k{constructor(){super(...arguments),this.permissions=new td(this._client)}retrieve(e,r){return this._client.get(m`/v1/organizations/rbac_roles/${e}`,{...r,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.rbac_roles.retrieve",r,{route:"/v1/organizations/rbac_roles/{rbac_role_id}",attributes:{"anthropic.organization.rbac_role.id":e}})})}list(e={},r){return this._client.getAPIList("/v1/organizations/rbac_roles",z,{query:e,...r,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.rbac_roles.list",r,{route:"/v1/organizations/rbac_roles",queryParams:["limit","page"]})})}}return t.Permissions=td,t})();let nd=class extends k{list(n,e={},r){const{betas:i,...s}=e??{};return this._client.getAPIList(m`/v1/organizations/service_accounts/${n}/workspaces`,z,{query:s,...r,headers:g([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.service_accounts.workspaces.list",r,{route:"/v1/organizations/service_accounts/{service_account_id}/workspaces",queryParams:["limit","page"],attributes:{"anthropic.organization.service_account.id":n}})})}add(n,e,r){const{betas:i,...s}=e;return this._client.post(m`/v1/organizations/service_accounts/${n}/workspaces`,{body:s,...r,headers:g([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.service_accounts.workspaces.add",r,{route:"/v1/organizations/service_accounts/{service_account_id}/workspaces",attributes:{"anthropic.organization.service_account.id":n},createdIDAttribute:"anthropic.organization.service_account.workspace.id",createdIDField:"workspace_id"})})}remove(n,e,r){const{service_account_id:i,betas:s}=e;return this._client.delete(m`/v1/organizations/service_accounts/${i}/workspaces/${n}`,{...r,headers:g([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.service_accounts.workspaces.remove",r,{route:"/v1/organizations/service_accounts/{service_account_id}/workspaces/{workspace_id}",attributes:{"anthropic.organization.service_account.id":i,"anthropic.organization.service_account.workspace.id":n}})})}};var id=(()=>{class t extends k{constructor(){super(...arguments),this.workspaces=new nd(this._client)}create(e,r){const{betas:i,...s}=e;return this._client.post("/v1/organizations/service_accounts",{body:s,...r,headers:g([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.service_accounts.create",r,{route:"/v1/organizations/service_accounts",createdIDAttribute:"anthropic.organization.service_account.id"})})}retrieve(e,r={},i){const{betas:s}=r??{};return this._client.get(m`/v1/organizations/service_accounts/${e}`,{...i,headers:g([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.service_accounts.retrieve",i,{route:"/v1/organizations/service_accounts/{service_account_id}",attributes:{"anthropic.organization.service_account.id":e}})})}update(e,r,i){const{betas:s,...a}=r;return this._client.post(m`/v1/organizations/service_accounts/${e}`,{body:a,...i,headers:g([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.service_accounts.update",i,{route:"/v1/organizations/service_accounts/{service_account_id}",attributes:{"anthropic.organization.service_account.id":e}})})}list(e={},r){const{betas:i,...s}=e??{};return this._client.getAPIList("/v1/organizations/service_accounts",z,{query:s,...r,headers:g([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.service_accounts.list",r,{route:"/v1/organizations/service_accounts",queryParams:["include_archived","limit","page"]})})}archive(e,r={},i){const{betas:s}=r??{};return this._client.post(m`/v1/organizations/service_accounts/${e}/archive`,{...i,headers:g([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.service_accounts.archive",i,{route:"/v1/organizations/service_accounts/{service_account_id}/archive",attributes:{"anthropic.organization.service_account.id":e}})})}}return t.Workspaces=nd,t})();let sd=class extends k{list(n={},e){return this._client.getAPIList("/v1/organizations/spend_limits/effective",z,{query:n,...e,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.spend_limits.effective.list",e,{route:"/v1/organizations/spend_limits/effective",queryParams:["limit","page","period","user_ids"]})})}},ad=class extends k{retrieve(n,e){return this._client.get(m`/v1/organizations/spend_limit_increase_requests/${n}`,{...e,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.spend_limits.increase_requests.retrieve",e,{route:"/v1/organizations/spend_limit_increase_requests/{spend_limit_increase_request_id}",attributes:{"anthropic.organization.spend_limit_increase_request.id":n}})})}list(n={},e){return this._client.getAPIList("/v1/organizations/spend_limit_increase_requests",z,{query:n,...e,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.spend_limits.increase_requests.list",e,{route:"/v1/organizations/spend_limit_increase_requests",queryParams:["actor_ids","limit","page","status"]})})}approve(n,e,r){return this._client.post(m`/v1/organizations/spend_limit_increase_requests/${n}/approve`,{body:e,...r,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.spend_limits.increase_requests.approve",r,{route:"/v1/organizations/spend_limit_increase_requests/{spend_limit_increase_request_id}/approve",attributes:{"anthropic.organization.spend_limit_increase_request.id":n}})})}deny(n,e,r){return this._client.post(m`/v1/organizations/spend_limit_increase_requests/${n}/deny`,{body:e,...r,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.spend_limits.increase_requests.deny",r,{route:"/v1/organizations/spend_limit_increase_requests/{spend_limit_increase_request_id}/deny",attributes:{"anthropic.organization.spend_limit_increase_request.id":n}})})}};var Eo=(()=>{class t extends oe{}return t._errorName="BetaSpendLimitsAdminAPIWritesNotEnabledError",t})(),od=(()=>{class t extends k{constructor(){super(...arguments),this.effective=new sd(this._client),this.increaseRequests=new ad(this._client)}retrieve(e,r){return this._client.get(m`/v1/organizations/spend_limits/${e}`,{...r,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.spend_limits.retrieve",r,{route:"/v1/organizations/spend_limits/{spend_limit_id}",attributes:{"anthropic.organization.spend_limit.id":e}})})}list(e={},r){const{betas:i,...s}=e??{};return this._client.getAPIList("/v1/organizations/spend_limits",z,{query:s,...r,headers:g([{"anthropic-beta":[...i??[],"spend-limit-reads-2026-09-26"].toString()},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.spend_limits.list",r,{route:"/v1/organizations/spend_limits",queryParams:["limit","page","scope_type","workspace_id"]})})}delete(e,r){return this._client.delete(m`/v1/organizations/spend_limits/${e}`,{...r,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.spend_limits.delete",r,{route:"/v1/organizations/spend_limits/{spend_limit_id}",attributes:{"anthropic.organization.spend_limit.id":e}})})}set(e,r){const{betas:i,...s}=e;return this._client.post("/v1/organizations/spend_limits",{body:s,...r,headers:g([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.spend_limits.set",r,{route:"/v1/organizations/spend_limits",createdIDAttribute:"anthropic.organization.spend_limit.id"})})}}return t.BetaSpendLimitsAdminAPIWritesNotEnabledError=Eo,t.Effective=sd,t.IncreaseRequests=ad,t})();let cd=class extends k{list(n,e={},r){const{betas:i,...s}=e??{};return this._client.getAPIList(m`/v1/organizations/telemetry_destinations/${n}/workspaces`,z,{query:s,...r,headers:g([{"anthropic-beta":[...i??[],"telemetry-destinations-2026-08-11"].toString()},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.telemetry_destinations.workspaces.list",r,{route:"/v1/organizations/telemetry_destinations/{destination_id}/workspaces",queryParams:["limit","page"],attributes:{"anthropic.organization.telemetry_destination.id":n}})})}add(n,e,r){const{destination_id:i,betas:s}=e;return this._client.post(m`/v1/organizations/telemetry_destinations/${i}/workspaces/${n}`,{...r,headers:g([{"anthropic-beta":[...s??[],"telemetry-destinations-2026-08-11"].toString()},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.telemetry_destinations.workspaces.add",r,{route:"/v1/organizations/telemetry_destinations/{destination_id}/workspaces/{workspace_id}",attributes:{"anthropic.organization.telemetry_destination.id":i,"anthropic.organization.telemetry_destination.workspace.id":n}})})}remove(n,e,r){const{destination_id:i,betas:s}=e;return this._client.delete(m`/v1/organizations/telemetry_destinations/${i}/workspaces/${n}`,{...r,headers:g([{"anthropic-beta":[...s??[],"telemetry-destinations-2026-08-11"].toString()},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.telemetry_destinations.workspaces.remove",r,{route:"/v1/organizations/telemetry_destinations/{destination_id}/workspaces/{workspace_id}",attributes:{"anthropic.organization.telemetry_destination.id":i,"anthropic.organization.telemetry_destination.workspace.id":n}})})}};var ld=(()=>{class t extends k{constructor(){super(...arguments),this.workspaces=new cd(this._client)}create(e,r){const{betas:i,...s}=e;return this._client.post("/v1/organizations/telemetry_destinations",{body:s,...r,headers:g([{"anthropic-beta":[...i??[],"telemetry-destinations-2026-08-11"].toString()},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.telemetry_destinations.create",r,{route:"/v1/organizations/telemetry_destinations",createdIDAttribute:"anthropic.organization.telemetry_destination.id"})})}retrieve(e,r={},i){const{betas:s}=r??{};return this._client.get(m`/v1/organizations/telemetry_destinations/${e}`,{...i,headers:g([{"anthropic-beta":[...s??[],"telemetry-destinations-2026-08-11"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.telemetry_destinations.retrieve",i,{route:"/v1/organizations/telemetry_destinations/{destination_id}",attributes:{"anthropic.organization.telemetry_destination.id":e}})})}update(e,r,i){const{betas:s,...a}=r;return this._client.post(m`/v1/organizations/telemetry_destinations/${e}`,{body:a,...i,headers:g([{"anthropic-beta":[...s??[],"telemetry-destinations-2026-08-11"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.telemetry_destinations.update",i,{route:"/v1/organizations/telemetry_destinations/{destination_id}",attributes:{"anthropic.organization.telemetry_destination.id":e}})})}list(e={},r){const{betas:i,...s}=e??{};return this._client.getAPIList("/v1/organizations/telemetry_destinations",z,{query:s,...r,headers:g([{"anthropic-beta":[...i??[],"telemetry-destinations-2026-08-11"].toString()},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.telemetry_destinations.list",r,{route:"/v1/organizations/telemetry_destinations",queryParams:["limit","page","workspace_ids"]})})}delete(e,r={},i){const{betas:s}=r??{};return this._client.delete(m`/v1/organizations/telemetry_destinations/${e}`,{...i,headers:g([{"anthropic-beta":[...s??[],"telemetry-destinations-2026-08-11"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.telemetry_destinations.delete",i,{route:"/v1/organizations/telemetry_destinations/{destination_id}",attributes:{"anthropic.organization.telemetry_destination.id":e}})})}test(e,r={},i){const{betas:s}=r??{};return this._client.post(m`/v1/organizations/telemetry_destinations/${e}/test`,{...i,headers:g([{"anthropic-beta":[...s??[],"telemetry-destinations-2026-08-11"].toString()},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.telemetry_destinations.test",i,{route:"/v1/organizations/telemetry_destinations/{destination_id}/test",attributes:{"anthropic.organization.telemetry_destination.id":e}})})}}return t.Workspaces=cd,t})();let ud=class extends k{retrieve(n,e,r){const{workspace_id:i}=e;return this._client.get(m`/v1/organizations/workspaces/${i}/members/${n}`,{...r,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.workspaces.members.retrieve",r,{route:"/v1/organizations/workspaces/{workspace_id}/members/{user_id}",attributes:{"anthropic.organization.workspace.id":i,"anthropic.organization.workspace.member.id":n}})})}update(n,e,r){const{workspace_id:i,...s}=e;return this._client.post(m`/v1/organizations/workspaces/${i}/members/${n}`,{body:s,...r,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.workspaces.members.update",r,{route:"/v1/organizations/workspaces/{workspace_id}/members/{user_id}",attributes:{"anthropic.organization.workspace.id":i,"anthropic.organization.workspace.member.id":n}})})}list(n,e={},r){return this._client.getAPIList(m`/v1/organizations/workspaces/${n}/members`,de,{query:e,...r,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.workspaces.members.list",r,{route:"/v1/organizations/workspaces/{workspace_id}/members",queryParams:["after_id","before_id","limit"],attributes:{"anthropic.organization.workspace.id":n}})})}add(n,e,r){return this._client.post(m`/v1/organizations/workspaces/${n}/members`,{body:e,...r,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.workspaces.members.add",r,{route:"/v1/organizations/workspaces/{workspace_id}/members",attributes:{"anthropic.organization.workspace.id":n},createdIDAttribute:"anthropic.organization.workspace.member.id",createdIDField:"user_id"})})}remove(n,e,r){const{workspace_id:i}=e;return this._client.delete(m`/v1/organizations/workspaces/${i}/members/${n}`,{...r,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.workspaces.members.remove",r,{route:"/v1/organizations/workspaces/{workspace_id}/members/{user_id}",attributes:{"anthropic.organization.workspace.id":i,"anthropic.organization.workspace.member.id":n}})})}},dd=class extends k{update(n,e,r){const{workspace_id:i,...s}=e;return this._client.post(m`/v1/organizations/workspaces/${i}/rate_limits/${n}`,{body:s,...r,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.workspaces.rate_limits.update",r,{route:"/v1/organizations/workspaces/{workspace_id}/rate_limits/{rate_limit_id}",attributes:{"anthropic.organization.workspace.id":i,"anthropic.organization.workspace.rate_limit.id":n}})})}list(n,e={},r){return this._client.getAPIList(m`/v1/organizations/workspaces/${n}/rate_limits`,z,{query:e,...r,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.workspaces.rate_limits.list",r,{route:"/v1/organizations/workspaces/{workspace_id}/rate_limits",queryParams:["group_type","include_inherited","limit","page"],attributes:{"anthropic.organization.workspace.id":n}})})}},hd=class extends k{retrieve(n,e,r){const{workspace_id:i,betas:s}=e;return this._client.get(m`/v1/organizations/workspaces/${i}/service_accounts/${n}`,{...r,headers:g([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.workspaces.service_accounts.retrieve",r,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id}",attributes:{"anthropic.organization.workspace.id":i,"anthropic.organization.workspace.service_account.id":n}})})}update(n,e,r){const{workspace_id:i,betas:s,...a}=e;return this._client.post(m`/v1/organizations/workspaces/${i}/service_accounts/${n}`,{body:a,...r,headers:g([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.workspaces.service_accounts.update",r,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id}",attributes:{"anthropic.organization.workspace.id":i,"anthropic.organization.workspace.service_account.id":n}})})}list(n,e={},r){const{betas:i,...s}=e??{};return this._client.getAPIList(m`/v1/organizations/workspaces/${n}/service_accounts`,z,{query:s,...r,headers:g([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.workspaces.service_accounts.list",r,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts",queryParams:["limit","page"],attributes:{"anthropic.organization.workspace.id":n}})})}add(n,e,r){const{betas:i,...s}=e;return this._client.post(m`/v1/organizations/workspaces/${n}/service_accounts`,{body:s,...r,headers:g([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.workspaces.service_accounts.add",r,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts",attributes:{"anthropic.organization.workspace.id":n},createdIDAttribute:"anthropic.organization.workspace.service_account.id",createdIDField:"service_account_id"})})}remove(n,e,r){const{workspace_id:i,betas:s}=e;return this._client.delete(m`/v1/organizations/workspaces/${i}/service_accounts/${n}`,{...r,headers:g([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.workspaces.service_accounts.remove",r,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id}",attributes:{"anthropic.organization.workspace.id":i,"anthropic.organization.workspace.service_account.id":n}})})}};var So=(()=>{class t extends R{}return t._errorName="BetaHumanReviewOnWithExternalStorageError",t})(),xo=(()=>{class t extends R{}return t._errorName="BetaTranscriptsStorageRequiredError",t})(),To=(()=>{class t extends ue{}return t._errorName="BetaWorkspaceChangedConcurrentlyError",t})(),_d=(()=>{class t extends k{constructor(){super(...arguments),this.rateLimits=new dd(this._client),this.members=new ud(this._client),this.serviceAccounts=new hd(this._client)}create(e,r){const{betas:i,...s}=e;return this._client.post("/v1/organizations/workspaces",{body:s,...r,headers:g([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.workspaces.create",r,{route:"/v1/organizations/workspaces",createdIDAttribute:"anthropic.organization.workspace.id"})})}retrieve(e,r={},i){const{betas:s}=r??{};return this._client.get(m`/v1/organizations/workspaces/${e}`,{...i,headers:g([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.workspaces.retrieve",i,{route:"/v1/organizations/workspaces/{workspace_id}",attributes:{"anthropic.organization.workspace.id":e}})})}update(e,r,i){const{betas:s,...a}=r;return this._client.post(m`/v1/organizations/workspaces/${e}`,{body:a,...i,headers:g([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.workspaces.update",i,{route:"/v1/organizations/workspaces/{workspace_id}",attributes:{"anthropic.organization.workspace.id":e}})})}list(e={},r){const{betas:i,...s}=e??{};return this._client.getAPIList("/v1/organizations/workspaces",de,{query:s,...r,headers:g([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.workspaces.list",r,{route:"/v1/organizations/workspaces",queryParams:["after_id","before_id","ids","include_archived","include_default","limit"]})})}archive(e,r={},i){const{betas:s}=r??{};return this._client.post(m`/v1/organizations/workspaces/${e}/archive`,{...i,headers:g([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.workspaces.archive",i,{route:"/v1/organizations/workspaces/{workspace_id}/archive",attributes:{"anthropic.organization.workspace.id":e}})})}}return t.BetaHumanReviewOnWithExternalStorageError=So,t.BetaTranscriptsStorageRequiredError=xo,t.BetaWorkspaceChangedConcurrentlyError=To,t.RateLimits=dd,t.Members=ud,t.ServiceAccounts=hd,t})(),Ao=(()=>{class t extends R{}return t._errorName="BetaApprovalRequiredError",t})(),Ro=(()=>{class t extends R{}return t._errorName="BetaHumanReviewNotAvailableError",t})(),zo=(()=>{class t extends R{}return t._errorName="BetaOrganizationNotEligibleError",t})(),Po=(()=>{class t extends ot{}return t._errorName="BetaAuthorizationCheckUnavailableError",t})(),pd=(()=>{class t extends k{constructor(){super(...arguments),this.apiKeys=new au(this._client),this.externalKeys=new Su(this._client),this.federation=new Hu(this._client),this.invites=new Tu(this._client),this.serviceAccounts=new id(this._client),this.externalStorage=new xu(this._client),this.providers=new Qu(this._client),this.users=new zu(this._client),this.workspaces=new _d(this._client),this.rateLimits=new Ru(this._client),this.complianceSettings=new Eu(this._client),this.analytics=new ku(this._client),this.spendLimits=new od(this._client),this.rbacGroups=new ed(this._client),this.rbacRoles=new rd(this._client),this.plugins=new Vu(this._client),this.pluginMarketplaces=new Au(this._client),this.telemetryDestinations=new ld(this._client),this.webhooks=new Pu(this._client),this.claudeCode=new $u(this._client),this.claudeTag=new Uu(this._client)}retrieve(e){return this._client.get("/v1/organizations/me",{...e,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.organization.retrieve",e,{route:"/v1/organizations/me"})})}}return t.BetaApprovalRequiredError=Ao,t.BetaHumanReviewNotAvailableError=Ro,t.BetaOrganizationNotEligibleError=zo,t.BetaAuthorizationCheckUnavailableError=Po,t.APIKeys=au,t.ExternalKeys=Su,t.Federation=Hu,t.Invites=Tu,t.ServiceAccounts=id,t.ExternalStorage=xu,t.BetaExternalStorageInUseError=Ia,t.BetaExternalStorageInWorkspacePolicyError=qa,t.BetaExternalStorageNotAvailableError=La,t.BetaGrantRequiredError=Ua,t.BetaInvalidStorageARNError=Fa,t.BetaProviderNotAllowedError=Wa,t.BetaStorageAttachLimitReachedError=ja,t.BetaStorageNotAttachableError=Ha,t.BetaStorageProfileStillRequiredError=Ka,t.BetaStorageVerificationFailedError=Da,t.BetaUnsupportedRegionError=Ga,t.BetaStorageAlreadyRegisteredError=Va,t.BetaStorageChangedConcurrentlyError=Ja,t.Providers=Qu,t.Users=zu,t.BetaCannotSignOutPrimaryOwnerError=Ya,t.BetaCannotSignOutSelfError=Xa,t.BetaCannotSignOutManagedMemberError=Qa,t.BetaCannotSignOutMembershipAdminError=Za,t.BetaCannotSignOutOwnerError=eo,t.BetaCannotSignOutPrivilegedMemberError=to,t.Workspaces=_d,t.BetaHumanReviewOnWithExternalStorageError=So,t.BetaTranscriptsStorageRequiredError=xo,t.BetaWorkspaceChangedConcurrentlyError=To,t.RateLimits=Ru,t.ComplianceSettings=Eu,t.Analytics=ku,t.SpendLimits=od,t.BetaSpendLimitsAdminAPIWritesNotEnabledError=Eo,t.RBACGroups=ed,t.BetaRBACGroupNotFoundError=ko,t.RBACRoles=rd,t.Plugins=Vu,t.BetaScanFailedError=mo,t.BetaPluginNameTakenError=yo,t.BetaScanPendingError=bo,t.BetaSkillNameTakenError=wo,t.BetaRegistrationPendingError=vo,t.PluginMarketplaces=Au,t.TelemetryDestinations=ld,t.Webhooks=Pu,t.ClaudeCode=$u,t.ClaudeTag=Uu,t.BetaBundleAttachmentNotSupportedError=oo,t.BetaBundleOnCallError=co,t.BetaSlackChannelSetUpSettingsRefusedError=lo,t.BetaAPIKeyScopeMissingError=uo,t.BetaClaudeTagWritesNotEnabledError=ho,t.BetaComplianceConfigurationRestrictedError=_o,t.BetaOrganizationLevelScopedAPIKeyRequiredError=po,t.BetaSlackChannelSetUpEnvironmentNotFoundError=fo,t.BetaSlackChannelSetUpSettingsConflictError=go,t})(),fd=(()=>{class t extends k{list(e,r={},i){const{betas:s,workspace_id:a,...c}=r??{};return this._client.getAPIList(m`/v1/sessions/${e}/events`,z,{query:c,...i,headers:g([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.sessions.events.list",i,{route:"/v1/sessions/{session_id}/events",queryParams:["created_at[gt]","created_at[gte]","created_at[lt]","created_at[lte]","limit","order","page","types"],attributes:{"anthropic.session.id":e}})})}send(e,r,i){const{betas:s,workspace_id:a,...c}=r;return this._client.post(m`/v1/sessions/${e}/events`,{body:c,...i,headers:g([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.sessions.events.send",i,{route:"/v1/sessions/{session_id}/events",attributes:{"anthropic.session.id":e}})})}stream(e,r={},i){const{betas:s,workspace_id:a,...c}=r??{};return this._client.get(m`/v1/sessions/${e}/events/stream`,{query:c,...i,headers:g([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),stream:!0,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.sessions.events.stream",i,{route:"/v1/sessions/{session_id}/events/stream",queryParams:["event_deltas"],attributes:{"anthropic.session.id":e}})})}toolRunner(e,r){return new Ws(e,{...r,client:this._client})}}return t.SessionToolRunner=Ws,t})();class gd extends k{retrieve(n,e,r){const{session_id:i,betas:s,workspace_id:a}=e;return this._client.get(m`/v1/sessions/${i}/resources/${n}`,{...r,headers:g([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.sessions.resources.retrieve",r,{route:"/v1/sessions/{session_id}/resources/{resource_id}",attributes:{"anthropic.session.id":i,"anthropic.session.resource.id":n}})})}update(n,e,r){const{session_id:i,betas:s,workspace_id:a,...c}=e;return this._client.post(m`/v1/sessions/${i}/resources/${n}`,{body:c,...r,headers:g([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.sessions.resources.update",r,{route:"/v1/sessions/{session_id}/resources/{resource_id}",attributes:{"anthropic.session.id":i,"anthropic.session.resource.id":n}})})}list(n,e={},r){const{betas:i,workspace_id:s,...a}=e??{};return this._client.getAPIList(m`/v1/sessions/${n}/resources`,z,{query:a,...r,headers:g([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.sessions.resources.list",r,{route:"/v1/sessions/{session_id}/resources",queryParams:["limit","page"],attributes:{"anthropic.session.id":n}})})}delete(n,e,r){const{session_id:i,betas:s,workspace_id:a}=e;return this._client.delete(m`/v1/sessions/${i}/resources/${n}`,{...r,headers:g([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.sessions.resources.delete",r,{route:"/v1/sessions/{session_id}/resources/{resource_id}",attributes:{"anthropic.session.id":i,"anthropic.session.resource.id":n}})})}add(n,e,r){const{betas:i,workspace_id:s,...a}=e;return this._client.post(m`/v1/sessions/${n}/resources`,{body:a,...r,headers:g([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.sessions.resources.add",r,{route:"/v1/sessions/{session_id}/resources",attributes:{"anthropic.session.id":n},createdIDAttribute:"anthropic.session.resource.id"})})}}class md extends k{list(n,e,r){const{session_id:i,betas:s,workspace_id:a,...c}=e;return this._client.getAPIList(m`/v1/sessions/${i}/threads/${n}/events`,z,{query:c,...r,headers:g([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.sessions.threads.events.list",r,{route:"/v1/sessions/{session_id}/threads/{thread_id}/events",queryParams:["limit","page"],attributes:{"anthropic.session.id":i,"anthropic.session.thread.id":n}})})}stream(n,e,r){const{session_id:i,betas:s,workspace_id:a,...c}=e;return this._client.get(m`/v1/sessions/${i}/threads/${n}/stream`,{query:c,...r,headers:g([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},r?.headers]),stream:!0,__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.sessions.threads.events.stream",r,{route:"/v1/sessions/{session_id}/threads/{thread_id}/stream",queryParams:["event_deltas"],attributes:{"anthropic.session.id":i,"anthropic.session.thread.id":n}})})}}var yd=(()=>{class t extends k{constructor(){super(...arguments),this.events=new md(this._client)}retrieve(e,r,i){const{session_id:s,betas:a,workspace_id:c}=r;return this._client.get(m`/v1/sessions/${s}/threads/${e}`,{...i,headers:g([{"anthropic-beta":[...a??[],"managed-agents-2026-04-01"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.sessions.threads.retrieve",i,{route:"/v1/sessions/{session_id}/threads/{thread_id}",attributes:{"anthropic.session.id":s,"anthropic.session.thread.id":e}})})}list(e,r={},i){const{betas:s,workspace_id:a,...c}=r??{};return this._client.getAPIList(m`/v1/sessions/${e}/threads`,z,{query:c,...i,headers:g([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.sessions.threads.list",i,{route:"/v1/sessions/{session_id}/threads",queryParams:["limit","page","statuses"],attributes:{"anthropic.session.id":e}})})}archive(e,r,i){const{session_id:s,betas:a,workspace_id:c}=r;return this._client.post(m`/v1/sessions/${s}/threads/${e}/archive`,{...i,headers:g([{"anthropic-beta":[...a??[],"managed-agents-2026-04-01"].toString(),...c!=null?{"anthropic-workspace-id":c}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.sessions.threads.archive",i,{route:"/v1/sessions/{session_id}/threads/{thread_id}/archive",attributes:{"anthropic.session.id":s,"anthropic.session.thread.id":e}})})}}return t.Events=md,t})(),bd=(()=>{class t extends k{constructor(){super(...arguments),this.events=new fd(this._client),this.resources=new gd(this._client),this.threads=new yd(this._client)}create(e,r){const{betas:i,workspace_id:s,...a}=e,c={body:a,...r,headers:g([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"}};return this._client.post("/v1/sessions",{...c,__span:u(this._client,"anthropic.sessions.create",r,{route:"/v1/sessions",attributes:cb(a),createdIDAttribute:"anthropic.session.id",request:c})})}retrieve(e,r={},i){const{betas:s,workspace_id:a}=r??{};return this._client.get(m`/v1/sessions/${e}`,{...i,headers:g([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.sessions.retrieve",i,{route:"/v1/sessions/{session_id}",attributes:{"anthropic.session.id":e}})})}update(e,r,i){const{betas:s,workspace_id:a,...c}=r;return this._client.post(m`/v1/sessions/${e}`,{body:c,...i,headers:g([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.sessions.update",i,{route:"/v1/sessions/{session_id}",attributes:{"anthropic.session.id":e}})})}list(e={},r){const{betas:i,workspace_id:s,...a}=e??{};return this._client.getAPIList("/v1/sessions",yb,{query:a,...r,headers:g([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.sessions.list",r,{route:"/v1/sessions",queryParams:["agent_id","agent_version","created_at[gt]","created_at[gte]","created_at[lt]","created_at[lte]","deployment_id","include_archived","limit","memory_store_id","order","page","statuses"]})})}delete(e,r={},i){const{betas:s,workspace_id:a}=r??{};return this._client.delete(m`/v1/sessions/${e}`,{...i,headers:g([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.sessions.delete",i,{route:"/v1/sessions/{session_id}",attributes:{"anthropic.session.id":e}})})}archive(e,r={},i){const{betas:s,workspace_id:a}=r??{};return this._client.post(m`/v1/sessions/${e}/archive`,{...i,headers:g([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.sessions.archive",i,{route:"/v1/sessions/{session_id}/archive",attributes:{"anthropic.session.id":e}})})}}return t.Events=fd,t.Resources=gd,t.Threads=yd,t})();let wd=class extends k{create(n,e,r){const{betas:i,workspace_id:s,...a}=e;return this._client.post(m`/v1/skills/${n}/versions`,Xe({body:a,...r,headers:g([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.skills.versions.create",r,{route:"/v1/skills/{skill_id}/versions",attributes:{"anthropic.skill.id":n},createdIDAttribute:"anthropic.skill.version.id"})},this._client,!1))}retrieve(n,e,r){const{skill_id:i,betas:s,workspace_id:a}=e;return this._client.get(m`/v1/skills/${i}/versions/${n}`,{...r,headers:g([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0,...a!=null?{"anthropic-workspace-id":a}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.skills.versions.retrieve",r,{route:"/v1/skills/{skill_id}/versions/{version}",attributes:{"anthropic.skill.id":i,"anthropic.skill.version.id":n}})})}list(n,e={},r){const{betas:i,workspace_id:s,...a}=e??{};return this._client.getAPIList(m`/v1/skills/${n}/versions`,z,{query:a,...r,headers:g([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.skills.versions.list",r,{route:"/v1/skills/{skill_id}/versions",queryParams:["limit","page"],attributes:{"anthropic.skill.id":n}})})}delete(n,e,r){const{skill_id:i,betas:s,workspace_id:a}=e;return this._client.delete(m`/v1/skills/${i}/versions/${n}`,{...r,headers:g([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0,...a!=null?{"anthropic-workspace-id":a}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.skills.versions.delete",r,{route:"/v1/skills/{skill_id}/versions/{version}",attributes:{"anthropic.skill.id":i,"anthropic.skill.version.id":n}})})}download(n,e,r){const{skill_id:i,betas:s,workspace_id:a}=e;return this._client.get(m`/v1/skills/${i}/versions/${n}/content`,{...r,headers:g([{Accept:"application/binary",...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0,...a!=null?{"anthropic-workspace-id":a}:void 0},r?.headers]),__qualifiers:{beta:"true"},__binaryResponse:!0,__span:u(this._client,"anthropic.skills.versions.download",r,{route:"/v1/skills/{skill_id}/versions/{version}/content",attributes:{"anthropic.skill.id":i,"anthropic.skill.version.id":n}})})}};var vd=(()=>{class t extends k{constructor(){super(...arguments),this.versions=new wd(this._client)}create(e,r){const{betas:i,workspace_id:s,...a}=e;return this._client.post("/v1/skills",Xe({body:a,...r,headers:g([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.skills.create",r,{route:"/v1/skills",createdIDAttribute:"anthropic.skill.id"})},this._client,!1))}retrieve(e,r={},i){const{betas:s,workspace_id:a}=r??{};return this._client.get(m`/v1/skills/${e}`,{...i,headers:g([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0,...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.skills.retrieve",i,{route:"/v1/skills/{skill_id}",attributes:{"anthropic.skill.id":e}})})}list(e={},r){const{betas:i,workspace_id:s,...a}=e??{};return this._client.getAPIList("/v1/skills",z,{query:a,...r,headers:g([{...i?.toString()!=null?{"anthropic-beta":i?.toString()}:void 0,...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.skills.list",r,{route:"/v1/skills",queryParams:["limit","page","source"]})})}delete(e,r={},i){const{betas:s,workspace_id:a}=r??{};return this._client.delete(m`/v1/skills/${e}`,{...i,headers:g([{...s?.toString()!=null?{"anthropic-beta":s?.toString()}:void 0,...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.skills.delete",i,{route:"/v1/skills/{skill_id}",attributes:{"anthropic.skill.id":e}})})}}return t.Versions=wd,t})();class kd extends k{create(n,e,r){const{betas:i,workspace_id:s,...a}=e;return this._client.post(m`/v1/tunnels/${n}/certificates`,{body:a,...r,headers:g([{"anthropic-beta":[...i??[],"mcp-tunnels-2026-06-22"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.tunnels.certificates.create",r,{route:"/v1/tunnels/{tunnel_id}/certificates",attributes:{"anthropic.tunnel.id":n},createdIDAttribute:"anthropic.tunnel.certificate.id"})})}retrieve(n,e,r){const{tunnel_id:i,betas:s,workspace_id:a}=e;return this._client.get(m`/v1/tunnels/${i}/certificates/${n}`,{...r,headers:g([{"anthropic-beta":[...s??[],"mcp-tunnels-2026-06-22"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.tunnels.certificates.retrieve",r,{route:"/v1/tunnels/{tunnel_id}/certificates/{certificate_id}",attributes:{"anthropic.tunnel.id":i,"anthropic.tunnel.certificate.id":n}})})}list(n,e={},r){const{betas:i,workspace_id:s,...a}=e??{};return this._client.getAPIList(m`/v1/tunnels/${n}/certificates`,z,{query:a,...r,headers:g([{"anthropic-beta":[...i??[],"mcp-tunnels-2026-06-22"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.tunnels.certificates.list",r,{route:"/v1/tunnels/{tunnel_id}/certificates",queryParams:["include_archived","limit","page"],attributes:{"anthropic.tunnel.id":n}})})}archive(n,e,r){const{tunnel_id:i,betas:s,workspace_id:a}=e;return this._client.post(m`/v1/tunnels/${i}/certificates/${n}/archive`,{...r,headers:g([{"anthropic-beta":[...s??[],"mcp-tunnels-2026-06-22"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.tunnels.certificates.archive",r,{route:"/v1/tunnels/{tunnel_id}/certificates/{certificate_id}/archive",attributes:{"anthropic.tunnel.id":i,"anthropic.tunnel.certificate.id":n}})})}}var Ed=(()=>{class t extends k{constructor(){super(...arguments),this.certificates=new kd(this._client)}create(e,r){const{betas:i,workspace_id:s,...a}=e;return this._client.post("/v1/tunnels",{body:a,...r,headers:g([{"anthropic-beta":[...i??[],"mcp-tunnels-2026-06-22"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.tunnels.create",r,{route:"/v1/tunnels",createdIDAttribute:"anthropic.tunnel.id"})})}retrieve(e,r={},i){const{betas:s,workspace_id:a}=r??{};return this._client.get(m`/v1/tunnels/${e}`,{...i,headers:g([{"anthropic-beta":[...s??[],"mcp-tunnels-2026-06-22"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.tunnels.retrieve",i,{route:"/v1/tunnels/{tunnel_id}",attributes:{"anthropic.tunnel.id":e}})})}list(e={},r){const{betas:i,workspace_id:s,...a}=e??{};return this._client.getAPIList("/v1/tunnels",z,{query:a,...r,headers:g([{"anthropic-beta":[...i??[],"mcp-tunnels-2026-06-22"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.tunnels.list",r,{route:"/v1/tunnels",queryParams:["include_archived","limit","page"]})})}archive(e,r={},i){const{betas:s,workspace_id:a}=r??{};return this._client.post(m`/v1/tunnels/${e}/archive`,{...i,headers:g([{"anthropic-beta":[...s??[],"mcp-tunnels-2026-06-22"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.tunnels.archive",i,{route:"/v1/tunnels/{tunnel_id}/archive",attributes:{"anthropic.tunnel.id":e}})})}revealToken(e,r={},i){const{betas:s,workspace_id:a}=r??{};return this._client.post(m`/v1/tunnels/${e}/reveal_token`,{...i,headers:g([{"anthropic-beta":[...s??[],"mcp-tunnels-2026-06-22"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.tunnels.reveal_token",i,{route:"/v1/tunnels/{tunnel_id}/reveal_token",attributes:{"anthropic.tunnel.id":e}})})}rotateToken(e,r,i){const{betas:s,workspace_id:a,...c}=r;return this._client.post(m`/v1/tunnels/${e}/rotate_token`,{body:c,...i,headers:g([{"anthropic-beta":[...s??[],"mcp-tunnels-2026-06-22"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.tunnels.rotate_token",i,{route:"/v1/tunnels/{tunnel_id}/rotate_token",attributes:{"anthropic.tunnel.id":e}})})}}return t.Certificates=kd,t})();let Sd=class extends k{create(n,e,r){const{betas:i,workspace_id:s,...a}=e;return this._client.post(m`/v1/user_profiles/${n}/action_urls`,{body:a,...r,headers:g([{"anthropic-beta":[...i??[],"user-profiles-2026-08-18"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.user_profiles.action_urls.create",r,{route:"/v1/user_profiles/{user_profile_id}/action_urls",attributes:{"anthropic.user_profile.id":n}})})}};class xd extends k{retrieve(n,e={},r){const{betas:i,workspace_id:s}=e??{};return this._client.get(m`/v1/user_profiles/${n}/providers/google/data_controls`,{...r,headers:g([{"anthropic-beta":[...i??[],"user-profiles-2026-09-04,google-managed-data-controls-2026-09-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.user_profiles.providers.google.data_controls.retrieve",r,{route:"/v1/user_profiles/{user_profile_id}/providers/google/data_controls",attributes:{"anthropic.user_profile.id":n}})})}update(n,e,r){const{betas:i,workspace_id:s,...a}=e;return this._client.post(m`/v1/user_profiles/${n}/providers/google/data_controls`,{body:a,...r,headers:g([{"anthropic-beta":[...i??[],"user-profiles-2026-09-04,google-managed-data-controls-2026-09-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.user_profiles.providers.google.data_controls.update",r,{route:"/v1/user_profiles/{user_profile_id}/providers/google/data_controls",attributes:{"anthropic.user_profile.id":n}})})}}var Td=(()=>{class t extends k{constructor(){super(...arguments),this.dataControls=new xd(this._client)}}return t.DataControls=xd,t})(),Ad=(()=>{class t extends k{constructor(){super(...arguments),this.google=new Td(this._client)}}return t.Google=Td,t})(),Rd=(()=>{class t extends k{constructor(){super(...arguments),this.actionURLs=new Sd(this._client),this.providers=new Ad(this._client)}create(e,r){const{betas:i,workspace_id:s,...a}=e;return this._client.post("/v1/user_profiles",{body:a,...r,headers:g([{"anthropic-beta":[...i??[],"user-profiles-2026-08-18"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.user_profiles.create",r,{route:"/v1/user_profiles",createdIDAttribute:"anthropic.user_profile.id"})})}retrieve(e,r={},i){const{betas:s,workspace_id:a}=r??{};return this._client.get(m`/v1/user_profiles/${e}`,{...i,headers:g([{"anthropic-beta":[...s??[],"user-profiles-2026-08-18"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.user_profiles.retrieve",i,{route:"/v1/user_profiles/{user_profile_id}",attributes:{"anthropic.user_profile.id":e}})})}update(e,r,i){const{betas:s,workspace_id:a,...c}=r;return this._client.post(m`/v1/user_profiles/${e}`,{body:c,...i,headers:g([{"anthropic-beta":[...s??[],"user-profiles-2026-08-18"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.user_profiles.update",i,{route:"/v1/user_profiles/{user_profile_id}",attributes:{"anthropic.user_profile.id":e}})})}list(e={},r){const{betas:i,workspace_id:s,...a}=e??{};return this._client.getAPIList("/v1/user_profiles",z,{query:a,...r,headers:g([{"anthropic-beta":[...i??[],"user-profiles-2026-08-18"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.user_profiles.list",r,{route:"/v1/user_profiles",queryParams:["limit","order","order_by","page"]})})}delete(e,r={},i){const{betas:s,workspace_id:a}=r??{};return this._client.delete(m`/v1/user_profiles/${e}`,{...i,headers:g([{"anthropic-beta":[...s??[],"user-profiles-2026-08-18"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.user_profiles.delete",i,{route:"/v1/user_profiles/{user_profile_id}",attributes:{"anthropic.user_profile.id":e}})})}createEnrollmentURL(e,r={},i){const{betas:s,workspace_id:a}=r??{};return this._client.post(m`/v1/user_profiles/${e}/enrollment_url`,{...i,headers:g([{"anthropic-beta":[...s??[],"user-profiles-2026-08-18"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.user_profiles.create_enrollment_url",i,{route:"/v1/user_profiles/{user_profile_id}/enrollment_url",attributes:{"anthropic.user_profile.id":e}})})}}return t.ActionURLs=Sd,t.Providers=Ad,t})();class zd extends k{create(n,e,r){const{betas:i,workspace_id:s,...a}=e;return this._client.post(m`/v1/vaults/${n}/credentials`,{body:a,...r,headers:g([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.vaults.credentials.create",r,{route:"/v1/vaults/{vault_id}/credentials",attributes:{"anthropic.vault.id":n},createdIDAttribute:"anthropic.vault.credential.id"})})}retrieve(n,e,r){const{vault_id:i,betas:s,workspace_id:a}=e;return this._client.get(m`/v1/vaults/${i}/credentials/${n}`,{...r,headers:g([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.vaults.credentials.retrieve",r,{route:"/v1/vaults/{vault_id}/credentials/{credential_id}",attributes:{"anthropic.vault.id":i,"anthropic.vault.credential.id":n}})})}update(n,e,r){const{vault_id:i,betas:s,workspace_id:a,...c}=e;return this._client.post(m`/v1/vaults/${i}/credentials/${n}`,{body:c,...r,headers:g([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.vaults.credentials.update",r,{route:"/v1/vaults/{vault_id}/credentials/{credential_id}",attributes:{"anthropic.vault.id":i,"anthropic.vault.credential.id":n}})})}list(n,e={},r){const{betas:i,workspace_id:s,...a}=e??{};return this._client.getAPIList(m`/v1/vaults/${n}/credentials`,z,{query:a,...r,headers:g([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.vaults.credentials.list",r,{route:"/v1/vaults/{vault_id}/credentials",queryParams:["include_archived","limit","page"],attributes:{"anthropic.vault.id":n}})})}delete(n,e,r){const{vault_id:i,betas:s,workspace_id:a}=e;return this._client.delete(m`/v1/vaults/${i}/credentials/${n}`,{...r,headers:g([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.vaults.credentials.delete",r,{route:"/v1/vaults/{vault_id}/credentials/{credential_id}",attributes:{"anthropic.vault.id":i,"anthropic.vault.credential.id":n}})})}archive(n,e,r){const{vault_id:i,betas:s,workspace_id:a}=e;return this._client.post(m`/v1/vaults/${i}/credentials/${n}/archive`,{...r,headers:g([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.vaults.credentials.archive",r,{route:"/v1/vaults/{vault_id}/credentials/{credential_id}/archive",attributes:{"anthropic.vault.id":i,"anthropic.vault.credential.id":n}})})}mcpOAuthValidate(n,e,r){const{vault_id:i,betas:s,workspace_id:a}=e;return this._client.post(m`/v1/vaults/${i}/credentials/${n}/mcp_oauth_validate`,{...r,headers:g([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.vaults.credentials.mcp_oauth_validate",r,{route:"/v1/vaults/{vault_id}/credentials/{credential_id}/mcp_oauth_validate",attributes:{"anthropic.vault.id":i,"anthropic.vault.credential.id":n}})})}}var Pd=(()=>{class t extends k{constructor(){super(...arguments),this.credentials=new zd(this._client)}create(e,r){const{betas:i,workspace_id:s,...a}=e;return this._client.post("/v1/vaults",{body:a,...r,headers:g([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.vaults.create",r,{route:"/v1/vaults",createdIDAttribute:"anthropic.vault.id"})})}retrieve(e,r={},i){const{betas:s,workspace_id:a}=r??{};return this._client.get(m`/v1/vaults/${e}`,{...i,headers:g([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.vaults.retrieve",i,{route:"/v1/vaults/{vault_id}",attributes:{"anthropic.vault.id":e}})})}update(e,r,i){const{betas:s,workspace_id:a,...c}=r;return this._client.post(m`/v1/vaults/${e}`,{body:c,...i,headers:g([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.vaults.update",i,{route:"/v1/vaults/{vault_id}",attributes:{"anthropic.vault.id":e}})})}list(e={},r){const{betas:i,workspace_id:s,...a}=e??{};return this._client.getAPIList("/v1/vaults",z,{query:a,...r,headers:g([{"anthropic-beta":[...i??[],"managed-agents-2026-04-01"].toString(),...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.vaults.list",r,{route:"/v1/vaults",queryParams:["include_archived","limit","page"]})})}delete(e,r={},i){const{betas:s,workspace_id:a}=r??{};return this._client.delete(m`/v1/vaults/${e}`,{...i,headers:g([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.vaults.delete",i,{route:"/v1/vaults/{vault_id}",attributes:{"anthropic.vault.id":e}})})}archive(e,r={},i){const{betas:s,workspace_id:a}=r??{};return this._client.post(m`/v1/vaults/${e}/archive`,{...i,headers:g([{"anthropic-beta":[...s??[],"managed-agents-2026-04-01"].toString(),...a!=null?{"anthropic-workspace-id":a}:void 0},i?.headers]),__qualifiers:{beta:"true"},__span:u(this._client,"anthropic.vaults.archive",i,{route:"/v1/vaults/{vault_id}/archive",attributes:{"anthropic.vault.id":e}})})}}return t.Credentials=zd,t})(),je,$n,ht,Kt,Bn,_t,Dt,In,Cd,qn,Ln,Od=(()=>{class t extends Ba{constructor(e,r,i){super(e,{client:i}),je.add(this),$n.set(this,void 0),ht.set(this,0),Kt.set(this,[]),Bn.set(this,[]),_t.set(this,void 0),Dt.set(this,[]),In.set(this,!1),v(this,$n,r)}get toolCalls(){return o(this,Bn,"f")}_deliverEvent(e,r){var i;v(this,ht,(i=o(this,ht,"f"),i++,i));const s=e.type==="content_block_stop"?r?.content[e.index]:void 0,a=s?.type==="tool_use"?s:void 0;a&&o(this,Bn,"f").push(a),super._deliverEvent(e,r),o(this,je,"m",Cd).call(this,e,a),o(this,je,"m",qn).call(this)}[($n=new WeakMap,ht=new WeakMap,Kt=new WeakMap,Bn=new WeakMap,_t=new WeakMap,Dt=new WeakMap,In=new WeakMap,je=new WeakSet,Symbol.asyncIterator)](){const e=super[Symbol.asyncIterator](),r={handled:o(this,ht,"f")};o(this,Kt,"f").push(r);let i=!1;return{next:async()=>{i&&(i=!1,r.handled++,o(this,je,"m",qn).call(this));try{const s=await e.next();return i=!s.done,s.done&&o(this,je,"m",Ln).call(this,r),s}catch(s){throw o(this,je,"m",Ln).call(this,r),s}},return:async()=>{const s=e.return?.();return o(this,je,"m",Ln).call(this,r),await s??{value:void 0,done:!0}}}}}return Cd=function(e,r){if(o(this,In,"f"))return;if(e.type==="content_block_start"&&e.content_block.type==="fallback"){v(this,In,!0),v(this,_t,void 0);return}const i=e.type==="content_block_start"||e.type==="message_delta"&&e.delta.stop_reason==="tool_use";o(this,_t,"f")&&i&&(o(this,Dt,"f").push({toolUse:o(this,_t,"f"),event:o(this,ht,"f")}),v(this,_t,void 0)),r&&v(this,_t,r)},qn=function(){if(this.errored||this.controller.signal.aborted)return;const e=Math.min(o(this,ht,"f"),...o(this,Kt,"f").map(r=>r.handled));for(;o(this,Dt,"f")[0]&&o(this,Dt,"f")[0].event<=e;)o(this,$n,"f").call(this,o(this,Dt,"f").shift().toolUse)},Ln=function(e){const r=o(this,Kt,"f").indexOf(e);r>=0&&(o(this,Kt,"f").splice(r,1),o(this,je,"m",qn).call(this))},t})();function Nd(){let t,n;return{promise:new Promise((r,i)=>{t=r,n=i}),resolve:t,reject:n}}var te,re,X,Y,G,V,et,Md,ns,Cr,$d,is,ss,Bd,as,Id;class Sw{constructor(n,e,r){this.fields=n,this.ownMessages=e,this.ownCreateOnly=r,this.deferredMessages=[],this.replacementHistory=null,this.createOnly=cf(n)}}var af=(()=>{class t{constructor({params:e,options:r,threading:i,logger:s}){te.add(this),re.set(this,void 0),X.set(this,[]),Y.set(this,[]),G.set(this,void 0),V.set(this,null),et.set(this,void 0);const{messages:a,unsupportedRequestBehavior:c,...l}=e;si(l),this.options=r,this.unsupportedRequestBehavior=c??"error",v(this,re,l),v(this,G,i?{type:"create",replacesLostThread:!1}:{type:"never_threaded"}),v(this,et,s),this.push(a??[])}get threading(){return o(this,G,"f").type==="create"||o(this,G,"f").type==="continue"}get previousMessageId(){return o(this,G,"f").type==="continue"?o(this,G,"f").previousMessageId:null}get messages(){const e=o(this,V,"f")?.replacementHistory?.slice()??[...o(this,X,"f"),...o(this,Y,"f")].map(r=>r.param);return o(this,V,"f")&&e.push(...o(this,V,"f").deferredMessages.map(Qt)),e}get params(){const e=o(this,G,"f").type==="create"?o(this,V,"f")?.ownCreateOnly:void 0;return{...o(this,re,"f"),...e,messages:this.messages}}push(e){if(o(this,V,"f")){o(this,V,"f").deferredMessages.push(...e);return}for(const r of e)o(this,te,"m",ns).call(this,r)||o(this,Y,"f").push({param:Qt(r),reply:null})}update(e={},r={}){si(e),v(this,re,{...o(this,re,"f"),...wt(e)}),this.options={...this.options,...wt(r)};for(const i of os)e[i]!==void 0&&delete o(this,V,"f")?.ownCreateOnly[i]}fork(e=o(this,re,"f")){const r=new t({params:{...e,unsupportedRequestBehavior:this.unsupportedRequestBehavior},options:this.options,threading:o(this,G,"f").type!=="never_threaded",logger:o(this,et,"f")});return this.threading||r.stopThreading(),o(this,V,"f")?.replacementHistory?v(r,Y,o(this,V,"f").replacementHistory.map(i=>({param:i,reply:null}))):(v(r,X,[...o(this,X,"f")]),v(r,Y,[...o(this,Y,"f")])),o(this,V,"f")&&r.push(o(this,V,"f").deferredMessages),r}setParams({messages:e,...r}){v(this,re,r),o(this,V,"f")&&(o(this,V,"f").ownCreateOnly={}),this.setMessages(e)}setMessages(e){const r=[...o(this,X,"f"),...o(this,Y,"f")];if(o(this,V,"f")){const s=r.map(a=>a.param);qd(e,s)?(o(this,V,"f").replacementHistory=null,o(this,V,"f").deferredMessages=e.slice(s.length)):(o(this,V,"f").replacementHistory=e,o(this,V,"f").deferredMessages=[]);return}qd(e,o(this,X,"f").map(s=>s.param))||(v(this,X,[]),this.threading&&v(this,G,{type:"create",replacesLostThread:!1})),v(this,Y,[]);const i=new Map(r.filter(s=>s.reply).map(s=>[s.param.content,s]));for(const s of e.slice(o(this,X,"f").length))o(this,te,"m",ns).call(this,s)||o(this,Y,"f").push({...i.get(s.content)??{reply:null},param:Qt(s)})}get hasTurnToSend(){return o(this,Y,"f").length>0||of(o(this,X,"f").at(-1)?.reply?.stop_reason)}startTurn(e,r){if(o(this,V,"f"))throw new P("Another `send()`, `parse()` or `stream()` is already in progress on this thread");si(r);const i=o(this,Y,"f").length;this.push(e);const s=o(this,Y,"f").slice(i);o(this,te,"m",$d).call(this);const a={};return r.system!==void 0&&(a.system=r.system),r.tools!==void 0&&(a.tools=r.tools),v(this,V,new Sw({...o(this,re,"f"),...wt(r)},s,a))}endTurn(e){v(this,V,null),v(this,Y,o(this,Y,"f").filter(r=>!e.ownMessages.includes(r))),e.replacementHistory&&this.setMessages(e.replacementHistory),this.push(e.deferredMessages)}recoversFrom(e){if(!(e instanceof K))return!1;const r=this.unsupportedRequestBehavior==="continue_unthreaded",i=Aw(e);if(i!==null&&o(this,G,"f").type==="continue")return i==="thread_not_found"&&o(this,G,"f").replacesLostThread&&r?(o(this,et,"f").info(`The server lost the thread again right after a replay; continuing without a thread: previous_message_id=${o(this,G,"f").previousMessageId}`),this.stopThreading()):o(this,te,"m",Cr).call(this,i),!0;const s=zw(e);return s!==null&&this.threading&&r?(o(this,et,"f").info(`The server cannot thread this request; continuing without a thread: unsupported=${s.join(",")}`),this.stopThreading(),!0):!1}stopThreading(){this.threading&&v(this,G,{type:"unthreaded"})}recordPartialReply(e,r){o(this,te,"m",is).call(this,e)||(o(this,te,"m",ss).call(this,Pw(e,r),{partial:!0}),this.previousMessageId!==null&&o(this,te,"m",Cr).call(this,"stream_ended_before_message_stop"))}recordReply(e,r){o(this,te,"m",is).call(this,r)||(o(this,te,"m",ss).call(this,r,{partial:!1}),o(this,G,"f").type==="create"&&v(this,re,{...o(this,re,"f"),...e.ownCreateOnly}),this.threading&&(v(this,G,{type:"continue",previousMessageId:r.id,createdWith:e.createOnly,replacesLostThread:o(this,G,"f").type==="create"&&o(this,G,"f").replacesLostThread}),r.usage.iterations?.some(i=>i.type==="fallback_message")&&o(this,te,"m",Cr).call(this,"fallback_message")),r.container&&o(this,te,"m",Bd).call(this,r.container.id))}buildCreateArguments(e,r,{stream:i}){o(this,te,"m",as).call(this,e.createOnly);const s=o(this,G,"f");let a=s.type==="continue"?[]:o(this,X,"f").map(l=>l.param);if(s.type!=="never_threaded"){const l=o(this,X,"f").map(d=>d.reply!==null).lastIndexOf(!0)+1;a=a.map((d,_)=>_<l?Ks(d):d)}const c={...e.fields,messages:[...a,...o(this,Y,"f").map(l=>l.param)]};if(this.threading&&!c.betas?.includes(Hs)&&(c.betas=[...c.betas??[],Hs]),s.type==="create")c.thread={type:"create"};else if(s.type==="continue"){c.thread={type:"continue",previous_message_id:s.previousMessageId};for(const l of os)delete c[l]}return{params:c,options:o(this,te,"m",Id).call(this,r,{stream:i})}}checkNextTurn(e){o(this,te,"m",as).call(this,cf({...o(this,re,"f"),...wt(e)}))}}return re=new WeakMap,X=new WeakMap,Y=new WeakMap,G=new WeakMap,V=new WeakMap,et=new WeakMap,te=new WeakSet,Md=function(){for(const e of[o(this,Y,"f"),o(this,X,"f")])for(let r=e.length-1;r>=0;r--)if(e[r].reply)return e[r].reply;return null},ns=function(e){if("id"in e)return e.id===o(this,te,"a",Md)?.id;const r=o(this,Y,"f").at(-1)??o(this,X,"f").at(-1);return r?.reply!=null&&Mi(e,r.param)},Cr=function(e){o(this,et,"f").info(`Replaying the full message history under a new thread: reason=${e} previous_message_id=${this.previousMessageId}`),v(this,G,{type:"create",replacesLostThread:e==="thread_not_found"})},$d=function(){const e=o(this,X,"f").at(-1);if(o(this,Y,"f").length||!e||e.reply&&!e.partial)return;e.reply&&o(this,X,"f").pop();let r=o(this,X,"f").length;for(;r>0&&!o(this,X,"f")[r-1].reply;)r-=1;v(this,Y,o(this,X,"f").splice(r)),o(this,et,"f").info(`Re-sending the turn whose reply ended before \`message_stop\`: partial_reply_id=${e.reply?.id??null}`)},is=function(e){return e.stop_reason!=="refusal"||o(this,G,"f").type==="never_threaded"?!1:(this.previousMessageId!==null&&o(this,te,"m",Cr).call(this,"refusal"),!0)},ss=function(e,{partial:r}){o(this,X,"f").push(...o(this,Y,"f")),v(this,Y,[]),e&&o(this,X,"f").push({param:Qt(e),reply:e,partial:r})},Bd=function(e){const{container:r}=o(this,re,"f");r==null?v(this,re,{...o(this,re,"f"),container:e}):typeof r=="object"&&r.id==null&&v(this,re,{...o(this,re,"f"),container:{...r,id:e}})},as=function(e){if(o(this,G,"f").type!=="continue")return;const{createdWith:r}=o(this,G,"f"),i=os.filter(s=>e[s]!==r[s]);if(i.length){const s=i.map(a=>`\`${a}\``).join(" and ");throw new P(`Cannot change ${s} on a thread: the server keeps the \`system\` and \`tools\` the thread was created with. To change them, start a new thread from \`thread.params\`.`+(i.includes("tools")?" To add or remove tools on this thread, send `tool_addition` or `tool_removal` blocks in a `system` message.":""))}},Id=function(e,{stream:r}){const i={...this.options,...wt(e)};return r&&(i.headers=g([{[wa]:"stream"},i.headers])),o(this,G,"f").type!=="never_threaded"&&(i.headers=g([i.headers,va("message-thread")])),this.threading&&(i.headers=Tw(i.headers)),i},t})();const xw=["pause_turn","compaction"];function of(t){return xw.some(n=>n===t)}const Hs="message-threads-2026-08-12",os=["system","tools"];function cf(t){return{system:JSON.stringify(t.system),tools:JSON.stringify(t.tools)}}function Tw(t){const n=g([t]).values.get("anthropic-beta");return n===null?t:g([t,{"anthropic-beta":K_(n,Hs)}])}function Aw(t){const n=lf(t)?.error_code;return Rw.find(e=>e===n)??null}const Rw=["thread_not_found","thread_already_continued","thread_continue_in_flight"];function zw(t){const n=lf(t);if(n?.error_code!=="thread_unsupported_request")return null;const e=n.unsupported;return Array.isArray(e)?e.map(String):[]}function lf(t){const e=t.error?.error?.details;return ae(e)?e:null}function si(t){if("thread"in t&&t.thread!==void 0)throw new TypeError("`thread` cannot be set here. The message thread sets it for each request itself.")}function wt(t){return Object.fromEntries(Object.entries(t).filter(([,n])=>n!==void 0))}function Pw(t,n){const e=t.content.slice(0,n),r=t.content[n];return r?.type==="text"&&r.text&&e.push(r),e.length?{...t,content:e}:null}function Ks(t){if(!ae(t))return t;const{cache_control:n,...e}=t;for(const r of["content","source","tool","definition","tool_references"]){const i=e[r];Array.isArray(i)?e[r]=i.map(Ks):ae(i)&&(e[r]=Ks(i))}return e}function qd(t,n){return n.length<=t.length&&n.every((e,r)=>Mi(e,t[r]))}function Mi(t,n){const[e,r]=[Qt(t),Qt(n)];return Object.keys({...e,...r}).every(s=>e[s]===r[s]||JSON.stringify(e[s])===JSON.stringify(r[s]))}function Qt(t){return"id"in t?{role:t.role,content:t.content}:t}function Ld(t){return t===void 0?[]:Cs(t)?t:[t]}function uf(t){const{stream:n,max_iterations:e,runToolsEagerly:r,thread:i,...s}=t;if(i!==void 0&&i!==!1)throw new TypeError("`thread` cannot be set in the params of a tool runner. The runner sets it for each request itself. To run without a message thread, pass `thread: false`.");return{settings:{stream:n,max_iterations:e,runToolsEagerly:r},thread:i,threadParams:s}}var q,Gt,pt,M,He,le,Un,Pe,ge,Ke,Ie,tt,Or,De,Ee,qe,Vt,Jt,ft,Nr,cs,Fn,Ud,ls,us,Fd,Mr,Wn,Wd,jd,ds,jn,Hn,Hd,hs;const Kd="a tool runner's toolsets come only from its tools param; change them with setMessagesParams(), or build a new runner",Cw="a tool runner's toolsets come only from its tools param; remove it there with setMessagesParams(), or build a new runner without it";var Ds=(()=>{class t{constructor(e,r,i){q.add(this),Gt.set(this,!1),pt.set(this,!1),M.set(this,void 0),He.set(this,void 0),le.set(this,void 0),Un.set(this,void 0),Pe.set(this,void 0),ge.set(this,void 0),Ke.set(this,void 0),Ie.set(this,void 0),tt.set(this,void 0),Or.set(this,0),De.set(this,void 0),Ee.set(this,{status:"idle"}),qe.set(this,void 0),Vt.set(this,null),Jt.set(this,new Map),ft.set(this,[]);const{thread:s,settings:a}="_state"in e?{thread:e,settings:r}:e.beta.messages._toolRunnerThread(r);Dd(s._state.params),Gd(a),v(this,M,s),v(this,He,wt(a));const{tools:c,messages:l}=s._state.params,d=gp(c,l);"_state"in e||s._state.setMessages(JSON.parse(JSON.stringify(Vd(l)))),v(this,le,{...i}),v(this,Un,g([va("BetaToolRunner"),d.length?{[nn]:d.join(", ")}:void 0])),v(this,tt,Nd())}async*[(Gt=new WeakMap,pt=new WeakMap,M=new WeakMap,He=new WeakMap,le=new WeakMap,Un=new WeakMap,Pe=new WeakMap,ge=new WeakMap,Ke=new WeakMap,Ie=new WeakMap,tt=new WeakMap,Or=new WeakMap,De=new WeakMap,Ee=new WeakMap,qe=new WeakMap,Vt=new WeakMap,Jt=new WeakMap,ft=new WeakMap,q=new WeakSet,Nr=function(r){return o(this,De,"f")?xe.with(o(this,De,"f"),r):r()},Symbol.asyncIterator)](){var e;if(o(this,Gt,"f"))throw new P("Cannot iterate over a consumed stream");v(this,Gt,!0),v(this,pt,!0),v(this,Ie,void 0);const r=H(o(this,M,"f")._client,()=>mb(o(this,M,"f")._client,this.params,o(this,le,"f").openTelemetry?.conversationId));v(this,De,r&&Pt.setSpan(xe.active(),r));try{for(;;)try{if(o(this,He,"f").max_iterations&&o(this,Or,"f")>=o(this,He,"f").max_iterations)break;if(o(this,q,"m",Hd).call(this),o(this,Ee,"f").status==="scheduled"&&Xd(o(this,Vt,"f"))!=="resume"){yield*o(this,q,"m",us).call(this,o(this,Ee,"f").config);continue}v(this,pt,!1,"f"),v(this,Ie,void 0,"f"),v(this,Or,(e=o(this,Or,"f"),e++,e),"f"),v(this,ge,void 0,"f"),yield*o(this,q,"m",cs).call(this,o(this,M,"f"));const i=o(this,Pe,"f");if(v(this,Pe,void 0,"f"),await o(this,q,"m",Nr).call(this,async()=>{let a;if(o(this,pt,"f"))v(this,Vt,null,"f"),o(this,Ke,"f")?.abort(),o(this,M,"f")._state.checkNextTurn($r(o(this,M,"f"))),o(this,M,"f")._state.setMessages(i),a=i.at(-1);else{const l=await o(this,ge,"f"),d=Xd(l.stop_reason);if(v(this,Vt,l.stop_reason,"f"),d==="stop")return"stop";if(d==="resume")return"continue";a=Iw(o(this,M,"f").messages)}Jd(a)&&o(this,M,"f")._state.checkNextTurn($r(o(this,M,"f")));const c=await o(this,q,"m",ds).call(this,a,o(this,le,"f").signal,o(this,De,"f"));if(c){const l=o(this,M,"f").messages,d=l.map(_=>_.role).lastIndexOf("assistant")+1;o(this,M,"f")._state.setMessages([...l.slice(0,d),c,...l.slice(d)])}else if(!o(this,pt,"f")&&!o(this,M,"f")._state.hasTurnToSend)return"stop";return"continue"})==="stop"){yield*o(this,q,"m",jd).call(this);break}}finally{o(this,Ke,"f")?.abort(),v(this,Ke,void 0,"f")}if(await o(this,q,"m",ls).call(this),!o(this,ge,"f"))throw new P("ToolRunner concluded without a message from the server");o(this,tt,"f").resolve(await o(this,ge,"f")),H(o(this,M,"f")._client,()=>r?.setStatus({code:zt.OK}))}catch(i){throw r&&H(o(this,M,"f")._client,()=>st(r,i)),v(this,Gt,!1),v(this,Pe,void 0),o(this,tt,"f").promise.catch(()=>{}),o(this,tt,"f").reject(i),v(this,tt,Nd()),i}finally{H(o(this,M,"f")._client,()=>r?.end()),v(this,De,void 0)}}setMessagesParams(e){const r=typeof e=="function"?e(this.params):e;if(Dd(r),o(this,Ee,"f").status!=="idle"&&_s(r),o(this,Ee,"f").status==="in_flight"&&!Nw(r.messages,o(this,M,"f").messages))throw new P(Ow);const{settings:i,threadParams:s}=uf(r);Gd(i),v(this,He,wt(i)),o(this,Pe,"f")?(v(this,Pe,s.messages),o(this,M,"f")._state.setParams({...s,messages:o(this,M,"f").messages})):o(this,M,"f")._state.setParams(s),v(this,pt,!0),v(this,Ie,void 0)}setRequestOptions(e){typeof e=="function"?v(this,le,e(o(this,le,"f"))):v(this,le,{...o(this,le,"f"),...e})}async generateToolResponse(e=o(this,le,"f").signal){const r=o(this,M,"f")._client._tracer?xe.active():void 0,i=await o(this,ge,"f")??o(this,M,"f").messages.at(-1);return i?o(this,q,"m",ds).call(this,i,e,r):null}deferToolCall(e){const r=typeof e=="string"?e:e.id;o(this,qe,"f")&&!o(this,qe,"f").has(r)&&o(this,qe,"f").set(r,{status:"held"})}get deferredToolCalls(){const e=o(this,Ke,"f"),r=o(this,qe,"f");return!(e instanceof Od)||!r?[]:e.toolCalls.filter(i=>r.get(i.id)?.status==="held")}done(){return o(this,tt,"f").promise}async runUntilDone(){if(!o(this,Gt,"f"))for await(const e of this);return this.done()}get params(){return{...o(this,M,"f")._state.params,...o(this,Pe,"f")&&{messages:[...o(this,Pe,"f")]},...o(this,He,"f")}}pushMessages(...e){this.setMessagesParams(r=>({...r,messages:[...r.messages,...e]}))}compactBeforeNextTurn(e){o(this,Ee,"f").status!=="in_flight"&&(_s(this.params),v(this,Ee,{status:"scheduled",config:e??{type:"summarize"}}))}addTools(...e){const r=o(this,q,"m",jn).call(this);for(const i of e){if(en(i))throw new ii(`addTools() can't add the '${at(sr(i))}' toolset: ${Kd}`);const s=qw(i);if(r.has(s))throw new ii(`addTools() can't replace the '${at(s)}' toolset: ${Kd}`)}for(const i of e)"name"in i&&o(this,Jt,"f").set(i.name,"run"in i?i:null),o(this,ft,"f").push({type:"addition",tool:i})}removeTools(...e){const r=o(this,q,"m",jn).call(this);for(const i of e){const s=typeof i=="string"?i:i.name;if(r.has(s))throw new ii(`removeTools() can't remove the '${at(s)}' toolset: ${Cw}`)}for(const i of e){const s=typeof i=="string"?i:i.name;o(this,Jt,"f").set(s,null),o(this,ft,"f").push({type:"removal",name:s})}}then(e,r){return this.runUntilDone().then(e,r)}}return cs=async function*(e){await o(this,q,"m",ls).call(this),v(this,qe,void 0);const r=e.messages;r.some($w)&&o(this,q,"m",Nr).call(this,()=>e._state.setMessages(Vd(r)));const{tools:i}=e._state.params;o(this,He,"f").stream?(v(this,Ke,o(this,q,"m",Nr).call(this,()=>o(this,He,"f").runToolsEagerly?o(this,q,"m",Ud).call(this,e):e.stream(void 0,$r(e),o(this,q,"m",Fn).call(this,e)))),i&&e.update({tools:i}),e===o(this,M,"f")&&v(this,Pe,e.messages),v(this,ge,o(this,Ke,"f").finalMessage()),o(this,ge,"f").catch(()=>{}),yield o(this,Ke,"f")):(v(this,ge,o(this,q,"m",Nr).call(this,()=>e.send(void 0,$r(e),o(this,q,"m",Fn).call(this,e)))),i&&e.update({tools:i}),e===o(this,M,"f")&&v(this,Pe,e.messages),yield o(this,ge,"f"))},Fn=function(e){const{headers:r=e._state.options.headers}=o(this,le,"f");return{...o(this,le,"f"),headers:g([o(this,Un,"f"),r])}},Ud=function(e){const r=new Map;v(this,qe,r);const i=new Map,s=c=>{const l=r.has(c.id),d=!c.toolset_name&&o(this,q,"m",jn).call(this).has(c.name),_=d?c.name:c.toolset_name;if(_){if(l||d||i.has(_)){i.set(_,"waiting");return}i.set(_,"running");const p=df(o(this,q,"m",Hn).call(this),_,c,o(this,le,"f"),o(this,M,"f")._client,o(this,De,"f"));r.set(c.id,{status:"started",result:p}),p.then(({is_error:f})=>{f||i.get(_)==="waiting"?i.set(_,"waiting"):i.delete(_)},()=>i.set(_,"waiting"));return}if(l)return;const h=hf(o(this,q,"m",Mr).call(this),o(this,q,"m",Wn).call(this),c,o(this,le,"f"),o(this,M,"f")._client,o(this,De,"f"));h.catch(()=>{}),r.set(c.id,{status:"started",result:h})},a=new Od(e._state.params,s,e._client);return e._stream(a,void 0,$r(e),o(this,q,"m",Fn).call(this,e)),a},ls=async function(){const e=[...o(this,qe,"f")?.values()??[]].filter(r=>r.status==="started");await Promise.allSettled(e.map(r=>r.result))},us=async function*(e){_s(this.params),v(this,Ee,{status:"in_flight"}),v(this,Ie,void 0);const r=o(this,ge,"f"),i=o(this,q,"m",Fd).call(this,e),s=o(this,M,"f").messages.length;try{yield*o(this,q,"m",cs).call(this,i);const a=await o(this,ge,"f");if(a.content.some(c=>c.type==="compaction"&&c.content)){o(this,q,"m",Wd).call(this);const c={role:a.role,content:a.content},l=o(this,M,"f").messages.slice(s).filter(d=>!Mi(d,c));o(this,M,"f")._state.setMessages([c,...l])}else B(o(this,M,"f")._client).warn("Compaction produced no summary; keeping the conversation as it is."),v(this,ge,r,"f")}finally{v(this,Ee,{status:"idle"}),i._state.threading||o(this,M,"f")._state.stopThreading()}},Fd=function(e){const{messages:r,...i}=Mw(o(this,M,"f")._state.params),s=o(this,M,"f").fork();return s._state=o(this,M,"f")._state.fork({...i,compaction:e}),s},Mr=function(){const e=new Map;for(const r of o(this,M,"f")._state.params.tools??[])"run"in r&&"name"in r&&e.set(r.name,r);for(const[r,i]of o(this,Jt,"f"))i?e.set(r,i):e.delete(r);return e},Wn=function(){const e=new Set(o(this,q,"m",Mr).call(this).keys());for(const r of[...this.params.messages,o(this,q,"m",hs).call(this)])if(Array.isArray(r.content)){for(const i of r.content)if(r.role==="system")Yd(i,e);else if(r.role==="assistant"&&i.type==="compaction")for(const s of i.tool_changes??[])Yd(s,e)}return e},Wd=function(){const e=o(this,q,"m",Wn).call(this);for(const r of o(this,q,"m",Mr).call(this).keys())e.has(r)||o(this,Jt,"f").set(r,null)},jd=async function*(){if(o(this,Ee,"f").status==="scheduled"){if(Jd(o(this,M,"f").messages.at(-1))){B(o(this,M,"f")._client).warn("The pending compaction was skipped because the last turn ended with tool calls that were not run. Call `compactBeforeNextTurn()` again if you continue the conversation."),v(this,Ee,{status:"idle"});return}yield*o(this,q,"m",us).call(this,o(this,Ee,"f").config)}},ds=async function(e,r,i){return o(this,Ie,"f")!==void 0?o(this,Ie,"f"):(v(this,Ie,Bw(o(this,q,"m",Hn).call(this),o(this,q,"m",Mr).call(this),o(this,q,"m",Wn).call(this),e,{...o(this,le,"f"),signal:r},o(this,qe,"f"),o(this,M,"f")._client,i)),o(this,Ie,"f"))},jn=function(){return new Set(o(this,q,"m",Hn).call(this).tools.filter(en).map(sr))},Hn=function(){return{...this.params,tools:o(this,M,"f")._state.params.tools??[]}},Hd=function(){o(this,Vt,"f")==="pause_turn"||o(this,ft,"f").length===0||(o(this,M,"f").append(o(this,q,"m",hs).call(this)),v(this,ft,[]))},hs=function(){const e=[];for(const r of o(this,ft,"f")){if(r.type==="removal"){e.push({type:"tool_removal",tool:{type:"tool_reference",name:r.name}});continue}const i=Co(r.tool);e.push({type:"tool_addition",tool:{type:"tool_definition",definition:i}})}return{role:"system",content:e}},t})();const Ow="Message params can't be changed while the conversation is being compacted, because the compaction response is about to replace them. Change them after this iteration instead.";function Nw(t,n){return t.length===n.length&&t.every((e,r)=>Mi(e,n[r]))}function Dd(t){if("compaction"in t&&t.compaction!=null)throw new P("`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 Gd(t){if(t.runToolsEagerly&&!t.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 _s(t){if(t.context_management?.edits?.some(n=>n.type.startsWith("compact_")))throw new P("`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 Mw(t){const{context_management:n,stop_sequences:e,output_format:r,...i}=t,s=({format:a,...c})=>c;return(i.tool_choice?.type==="any"||i.tool_choice?.type==="tool")&&delete i.tool_choice,i.output_config&&(i.output_config=s(i.output_config)),Array.isArray(i.fallbacks)&&(i.fallbacks=i.fallbacks.map(a=>a.output_config?{...a,output_config:s(a.output_config)}:a)),i}function Co(t){if(!("run"in t))return t;const n=Hw,e="toJSON"in t&&typeof t.toJSON=="function"?t.toJSON():t;return{...Object.fromEntries(Object.entries(e).filter(([r])=>n.includes(r))),...vt(t)&&{[Ve]:t[Ve]}}}function $r(t){const{tools:n}=t._state.params;return n?{tools:n.map(Co)}:{}}function Vd(t){return t.map(n=>{if(n.role!=="system"||!Array.isArray(n.content))return n;const e=n.content.map(r=>r.type==="tool_addition"&&r.tool.type==="tool_definition"?{...r,tool:{...r.tool,definition:Co(r.tool.definition)}}:r);return{...n,content:e}})}function $w(t){return t.role==="system"&&Array.isArray(t.content)&&t.content.some(n=>n.type==="tool_addition"&&n.tool.type==="tool_definition"&&"run"in n.tool.definition)}async function Bw(t,n,e,r,i,s,a,c){if(!r||r.role!=="assistant"||!r.content||typeof r.content=="string")return null;const l=r.content.filter(h=>h.type==="tool_use");if(l.length===0)return null;const d=new Map;return{role:"user",content:await Promise.all(l.map(async h=>{const p=s?.get(h.id),f=p?.status==="started"?p.result:void 0;if(h.toolset_name){const w=h.toolset_name,E=d.get(w)??{tail:Promise.resolve(),failed:!1};d.set(w,E);const S=t.tools.some(x=>en(x)&&sr(x)===w),T=f??E.tail.then(()=>E.failed?bi(h,ww(w),!0):df(t,w,h,i,a,c));return E.tail=T.then(({is_error:x})=>{x&&S&&(E.failed=!0)},()=>{E.failed=!0}),s?.set(h.id,{status:"started",result:T}),T}if(f)return f;if(!(e.has(h.name)?n.get(h.name):void 0)&&t.tools.some(w=>en(w)&&sr(w)===h.name)){const w=d.get(h.name)??{tail:Promise.resolve(),failed:!1};return d.set(h.name,w),w.tail=w.tail.then(()=>{w.failed=!0}),Uw(h)}const y=hf(n,e,h,i,a,c);return s?.set(h.id,{status:"started",result:y}),y}))}}async function df(t,n,e,r,i,s){const a=t.tools.find(d=>en(d)&&sr(d)===n);if(!a)return bi(e,`Error: Toolset '${at(n)}' member '${at(e.name)}' not found`,!0);const c={signal:r?.signal,conversationId:r?.openTelemetry?.conversationId,parentContext:s};return(await ka(i,a,e,c,async()=>{const d=await Ew(a,e,{signal:r?.signal});return{block:d,content:d.content??[],isError:d.is_error===!0}})).block}async function hf(t,n,e,r,i,s){const a=n.has(e.name)?t.get(e.name):void 0;if(!a)return Lw(e);const c={signal:r?.signal,conversationId:r?.openTelemetry?.conversationId,parentContext:s},l=await ka(i,a,e,c,()=>Kp(a,e.input,{toolUse:e,toolUseBlock:e,signal:r?.signal}));return{type:"tool_result",tool_use_id:e.id,content:l.content,...l.isError?{is_error:!0}:void 0}}function Iw(t){for(let n=t.length-1;n>=0;n--){const e=t[n];if(e.role==="assistant")return e;if(e.role==="user"&&Array.isArray(e.content)&&e.content.some(r=>r.type==="tool_result"))return}}function Jd(t){return Array.isArray(t?.content)&&t.content.some(n=>n.type==="tool_use")}function qw(t){return(t.type??"custom").replace(/_\d{8}$/,"").replace(/_toolset$/,"")}function Lw(t){return{type:"tool_result",tool_use_id:t.id,content:`Error: Tool '${t.name}' not found`,is_error:!0}}function Uw(t){return{type:"tool_result",tool_use_id:t.id,content:`Error: the '${at(t.name)}' toolset could not run this call${Fw(t.input)}; nothing in the batch was executed`,is_error:!0}}function Fw(t){const n=typeof t=="object"&&t!==null?t:{};if(!("actions"in n)){const s="action"in n?n.action:void 0;return typeof s=="string"?`: the call has no 'actions' list (action: '${at(s)}')`:": the call has no 'actions' list"}const{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";const r=[];for(const[s,a]of e.entries()){const c=typeof a=="object"&&a!==null&&"action"in a?a.action:void 0;if(typeof c!="string")return`: action ${s} must be an object with a string 'action' field`;r.push(`'${at(c)}'`)}const i=r.length>10?`, and ${r.length-10} more`:"";return`: its actions could not be run as sent (actions: ${r.slice(0,10).join(", ")}${i})`}function Yd(t,n){switch(t.type){case"tool_removal":case"tool_addition":Ww(t,n);break}}function Ww(t,n){const e=jw(t.tool);e!==void 0&&(t.type==="tool_removal"?n.delete(e):n.add(e))}function jw(t){switch(t.type){case"tool_reference":return t.name;case"tool_definition":return"name"in t.definition?t.definition.name:void 0;default:return}}function Xd(t){if(t===null)return"stop";if(of(t))return"resume";switch(t){case"tool_use":return"run_tools";case"end_turn":case"stop_sequence":case"max_tokens":case"model_context_window_exceeded":case"refusal":return"stop";default:return"stop"}}class tn{constructor(n,e,r){if(!n._supportsMessageThreads)throw new P("Message threads are not available on this client; use `client.beta.messages.create()` with the full `messages` instead");$a(e),this._client=n,this._state=new af({params:e,options:r??{},threading:!0,logger:B(n)})}static _fromState(n,e){const r=Object.create(tn.prototype);return Object.assign(r,{_client:n,_state:e})}get messages(){return this._state.messages}get previousMessageId(){return this._state.previousMessageId}get params(){return{...this._state.params,unsupportedRequestBehavior:this._state.unsupportedRequestBehavior}}append(...n){this._state.push(n)}send(n,e={},r={}){return this._send(n,e,r,i=>i)}parse(n,e={},r={}){return this._send(n,e,r,i=>Ma(i,this._state.params,{logger:B(this._client)}))}_send(n,e,r,i){const s=this._state.startTurn(Ld(n),e),a=(async()=>{try{const{request:c,props:l}=await this._createWithRecovery(s,r,{stream:!1}),d=await c;return this._state.recordReply(s,d),{props:l,reply:d}}finally{this._state.endTurn(s)}})();return new Qr(this._client,a.then(({props:c})=>c),async()=>{const{props:c,reply:l}=await a;return Pi(i(l),c.response)})}stream(n,e={},r={}){const i=new Ba(this._state.params,{logger:B(this._client),client:this._client});return this._stream(i,n,e,r),i}_stream(n,e,r,i){const s=this._state.startTurn(Ld(e),r);let a,c=0,l=!1;n.on("streamEvent",(h,p)=>{l||(a=p,h.type==="content_block_stop"&&(c+=1),h.type==="message_stop"&&(l=!0,this._state.recordReply(s,p),this._state.endTurn(s)))});const d=()=>{l||(l=!0,a&&this._state.recordPartialReply(a,c),this._state.endTurn(s))};n.controller.signal.addEventListener("abort",d,{once:!0});const _=(h,p)=>new Qr(this._client,this._createWithRecovery(s,{...i,signal:p?.signal},{stream:!0}).then(({props:f})=>f));n._start(_,this._state.params,{signal:i.signal??this._state.options.signal},d)}update(n={},e={}){this._state.update(n,e)}toolRunner(n={},e={}){return si(n),new Ds(this,n,e)}fork(){return tn._fromState(this._client,this._state.fork())}async _createWithRecovery(n,e,{stream:r}){for(;;){const{params:i,options:s}=this._state.buildCreateArguments(n,e,{stream:r}),a=this._client.beta.messages.create({...i,stream:r},s);try{return{request:a,props:await a._responseProps()}}catch(c){if(!this._state.recoversFrom(c))throw c}}}}var Qd=(()=>{class t extends k{constructor(){super(...arguments),this.batches=new eu(this._client)}create(e,r){const i=js(e),{betas:s,user_profile_id:a,workspace_id:c,...l}=i;l.model in yi&&console.warn(`The model '${l.model}' is deprecated and will reach end-of-life on ${yi[l.model]}
|
|
59
59
|
Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`),Yp.includes(l.model)&&l.thinking&&l.thinking.type==="enabled"&&console.warn(`Using Claude with ${l.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=r?.timeout??this._client._options.timeout;if(!l.stream&&d==null){const f=Jp[l.model]??void 0;d=this._client.calculateNonstreamingTimeout(l.max_tokens,f)}const _={body:l,timeout:d??6e5,...r,headers:Qp(i,r),stream:i.stream??!1,__qualifiers:{beta:"true"}},h=this._client._tracer&&u(this._client,"anthropic.messages.create",r,Oi(this._client,_));up(this._client,h,l);const p=this._client.post("/v1/messages",{..._,__span:h});return h?p._thenUnwrap(f=>(dp(this._client,h,l,f),f)):p}parse(e,r){return r={...r,headers:g([{"anthropic-beta":[...e.betas??[],"structured-outputs-2025-12-15"].toString()},r?.headers])},this.create(e,r).then(i=>Ma(i,e,{logger:this._client.logger??console}))}stream(e,r){return Ba.createMessage(this,e,r,{client:this._client})}countTokens(e,r){const i=js(e),{betas:s,user_profile_id:a,workspace_id:c,...l}=i,d={body:l,...r,headers:g([{"anthropic-beta":[...s??[],"token-counting-2024-11-01"].toString(),...a!=null?{"anthropic-user-profile-id":a}:void 0,...c!=null?{"anthropic-workspace-id":c}:void 0},r?.headers]),__qualifiers:{beta:"true"}};return this._client.post("/v1/messages/count_tokens",{...d,__span:u(this._client,"anthropic.messages.count_tokens",r,{route:"/v1/messages/count_tokens",request:d})})}toolRunner(e,r){return new Ds(this._client,e,r)}_toolRunnerThread(e){$a(e);const{settings:r,thread:i,threadParams:s}=uf(e),a=new af({params:{...s,unsupportedRequestBehavior:"continue_unthreaded"},options:{},threading:i!==!1&&this._client._supportsMessageThreads,logger:B(this._client)});return{thread:tn._fromState(this._client,a),settings:r}}thread(e,r){return new tn(this._client,e,r)}}return t.Batches=eu,t.BetaToolRunner=Ds,t.ToolError=Ta,t})();const Hw=["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 Oo=(()=>{class t extends R{}return t._errorName="BetaCMEKNotApprovedError",t})(),No=(()=>{class t extends R{}return t._errorName="BetaExternalKeyNotFoundError",t})(),Mo=(()=>{class t extends R{}return t._errorName="BetaExternalKeyProviderMismatchError",t})(),$o=(()=>{class t extends R{}return t._errorName="BetaGCPProjectNotVerifiedError",t})(),Bo=(()=>{class t extends R{}return t._errorName="BetaOrganizationNotEnrolledInBetaError",t})(),Io=(()=>{class t extends R{}return t._errorName="BetaRegionNotSupportedError",t})(),qo=(()=>{class t extends R{}return t._errorName="BetaRequestBodyTimeoutError",t})(),Lo=(()=>{class t extends R{}return t._errorName="BetaStorageNotApprovedError",t})(),Uo=(()=>{class t extends R{}return t._errorName="BetaUnsupportedCharsetError",t})(),Fo=(()=>{class t extends ue{}return t._errorName="BetaGCPProjectControlledByAnotherOrganizationError",t})(),Wo=(()=>{class t extends ue{}return t._errorName="BetaStorageInUseError",t})(),Zd=(()=>{class t extends k{constructor(){super(...arguments),this.models=new El(this._client),this.messages=new Qd(this._client),this.agents=new Pl(this._client),this.environments=new Yl(this._client),this.sessions=new bd(this._client),this.deployments=new wl(this._client),this.deploymentRuns=new bl(this._client),this.vaults=new Pd(this._client),this.memoryStores=new Zl(this._client),this.files=new kl(this._client),this.skills=new vd(this._client),this.webhooks=new Rl(this._client),this.userProfiles=new Rd(this._client),this.dreams=new vl(this._client),this.tunnels=new Ed(this._client),this.compliance=new $l(this._client),this.organization=new pd(this._client)}}return t.BetaCMEKNotApprovedError=Oo,t.BetaExternalKeyNotFoundError=No,t.BetaExternalKeyProviderMismatchError=Mo,t.BetaGCPProjectNotVerifiedError=$o,t.BetaOrganizationNotEnrolledInBetaError=Bo,t.BetaRegionNotSupportedError=Io,t.BetaRequestBodyTimeoutError=qo,t.BetaStorageNotApprovedError=Lo,t.BetaUnsupportedCharsetError=Uo,t.BetaGCPProjectControlledByAnotherOrganizationError=Fo,t.BetaStorageInUseError=Wo,t.Models=El,t.Messages=Qd,t.Agents=Pl,t.Environments=Yl,t.BetaEnvironmentArchivedError=Ra,t.BetaInvalidConfigTypeChangeError=za,t.BetaInvalidMetadataError=Pa,t.BetaEnvironmentCreateDisabledError=Ca,t.BetaEnvironmentUpdateDisabledError=Oa,t.BetaEnvironmentNotFoundError=Na,t.Sessions=bd,t.Deployments=wl,t.DeploymentRuns=bl,t.Vaults=Pd,t.MemoryStores=Zl,t.Files=kl,t.Skills=vd,t.Webhooks=Rl,t.UserProfiles=Rd,t.Dreams=vl,t.Tunnels=Ed,t.Compliance=$l,t.Organization=pd,t.BetaApprovalRequiredError=Ao,t.BetaHumanReviewNotAvailableError=Ro,t.BetaOrganizationNotEligibleError=zo,t.BetaAuthorizationCheckUnavailableError=Po,t})();function _f(t,n){const{user_profile_id:e,workspace_id:r,tools:i,messages:s}=t;return g([{...e!=null?{"anthropic-user-profile-id":e}:void 0,...r!=null?{"anthropic-workspace-id":r}:void 0},mp(i,s),n?.headers])}function Kw(t,n,e){if(!t._tracer)return;const r=_f(n,e);return u(t,"anthropic.messages.create",e,Oi(t,{body:n,headers:r,stream:!0}))}function pf(t){return t?.output_config?.format}function eh(t,n,e){const r=pf(n);return!n||!("parse"in(r??{}))?{...t,content:t.content.map(i=>i.type==="text"?Object.defineProperty({...i},"parsed_output",{value:null,enumerable:!1}):i),parsed_output:null}:ff(t,n)}function ff(t,n,e){let r=null;const i=t.content.map(s=>{if(s.type==="text"){const a=Dw(n,s.text);return r===null&&(r=a),Object.defineProperty({...s},"parsed_output",{value:a,enumerable:!1})}return s});return{...t,content:i,parsed_output:r}}function Dw(t,n){const e=pf(t);if(e?.type!=="json_schema")return null;try{return"parse"in e?e.parse(n):JSON.parse(n)}catch(r){throw new P(`Failed to parse structured output: ${r}`)}}var Ae,rt,Le,Br,Kn,Ir,qr,Dn,Lr,Ue,Ur,Gn,Vn,gt,Jn,Yn,Xn,Fr,mt,me,ps,th,fs,gs,ms,ys,rh;function bs(t){return t.type==="tool_use"||t.type==="server_tool_use"}var Gw=(()=>{class t{constructor(e,r){Ae.add(this),this.messages=[],this.receivedMessages=[],rt.set(this,void 0),Le.set(this,null),this.controller=new AbortController,Br.set(this,void 0),Kn.set(this,()=>{}),Ir.set(this,()=>{}),qr.set(this,void 0),Dn.set(this,()=>{}),Lr.set(this,()=>{}),Ue.set(this,{}),Ur.set(this,!1),Gn.set(this,!1),Vn.set(this,!1),gt.set(this,!1),Jn.set(this,void 0),Yn.set(this,void 0),Xn.set(this,void 0),Fr.set(this,void 0),mt.set(this,void 0),me.set(this,void 0),fs.set(this,i=>{if(v(this,Gn,!0),o(this,me,"f")&&(o(this,me,"f").streamed=void 0),Tt(i)&&(i=new be),i instanceof be)return v(this,Vn,!0),this._emit("abort",i);if(i instanceof P)return this._emit("error",i);if(i instanceof Error){const s=new P(i.message);return s.cause=i,this._emit("error",s)}return this._emit("error",new P(String(i)))}),v(this,Br,new Promise((i,s)=>{v(this,Kn,i,"f"),v(this,Ir,s,"f")})),v(this,qr,new Promise((i,s)=>{v(this,Dn,i,"f"),v(this,Lr,s,"f")})),o(this,Br,"f").catch(()=>{}),o(this,qr,"f").catch(()=>{}),v(this,Le,e),v(this,Fr,r?.logger??console),v(this,mt,r?.client)}get response(){return o(this,Jn,"f")}get request_id(){return o(this,Yn,"f")}get workspace_id(){return o(this,Xn,"f")}async withResponse(){v(this,gt,!0);const e=await o(this,Br,"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){const r=new t(null);return r._run(()=>r._fromReadableStream(e)),r}static createMessage(e,r,i,{logger:s,client:a}={}){const c=new t(r,{logger:s,client:a});for(const l of r.messages)c._addMessageParam(l);return v(c,Le,{...r,stream:!0}),c._run(()=>c._createMessage(e,{...r,stream:!0},{...i,headers:{...i?.headers,[wa]:"stream"}})),c}_run(e){e().then(()=>{this._emitFinal(),this._emit("end")},o(this,fs,"f"))}_addMessageParam(e){this.messages.push(e)}_addMessage(e,r=!0){this.receivedMessages.push(e),r&&this._emit("message",e)}async _createMessage(e,r,i){const s=i?.signal;let a;s&&(s.aborted&&this.controller.abort(),a=this.controller.abort.bind(this.controller),s.addEventListener("abort",a));try{o(this,Ae,"m",gs).call(this),v(this,me,i?.__span??(o(this,mt,"f")&&Kw(o(this,mt,"f"),r,i)),"f");const{response:c,data:l}=await e.create({...r,stream:!0},{...i,__span:o(this,me,"f"),signal:this.controller.signal}).withResponse();try{this._connected(c)}catch(d){throw o(this,me,"f")&&(o(this,me,"f").failure=d),l.controller.abort(),d}for await(const d of l)try{o(this,Ae,"m",ms).call(this,d)}catch(_){throw o(this,me,"f")&&(o(this,me,"f").failure=_),_}if(l.controller.signal?.aborted)throw new be;o(this,Ae,"m",ys).call(this)}finally{s&&a&&s.removeEventListener("abort",a)}}_connected(e){this.ended||(v(this,Jn,e),v(this,Yn,e?.headers.get("request-id")),v(this,Xn,e?.headers.get("anthropic-workspace-id")),o(this,Kn,"f").call(this,e),this._emit("connect"))}get ended(){return o(this,Ur,"f")}get errored(){return o(this,Gn,"f")}get aborted(){return o(this,Vn,"f")}abort(){this.controller.abort()}on(e,r){return(o(this,Ue,"f")[e]||(o(this,Ue,"f")[e]=[])).push({listener:r}),this}off(e,r){const i=o(this,Ue,"f")[e];if(!i)return this;const s=i.findIndex(a=>a.listener===r);return s>=0&&i.splice(s,1),this}once(e,r){return(o(this,Ue,"f")[e]||(o(this,Ue,"f")[e]=[])).push({listener:r,once:!0}),this}emitted(e){return new Promise((r,i)=>{v(this,gt,!0),e!=="error"&&this.once("error",i),this.once(e,r)})}async done(){v(this,gt,!0),await o(this,qr,"f")}get currentMessage(){return o(this,rt,"f")}async finalMessage(){return await this.done(),o(this,Ae,"m",ps).call(this)}async finalText(){return await this.done(),o(this,Ae,"m",th).call(this)}_emit(e,...r){if(o(this,Ur,"f"))return;e==="end"&&(v(this,Ur,!0),o(this,Dn,"f").call(this));const i=o(this,Ue,"f")[e];if(i&&(o(this,Ue,"f")[e]=i.filter(s=>!s.once),i.forEach(({listener:s})=>s(...r))),e==="abort"){const s=r[0];!o(this,gt,"f")&&!i?.length&&Promise.reject(s),o(this,Ir,"f").call(this,s),o(this,Lr,"f").call(this,s),this._emit("end");return}if(e==="error"){const s=r[0];!o(this,gt,"f")&&!i?.length&&Promise.reject(s),o(this,Ir,"f").call(this,s),o(this,Lr,"f").call(this,s),this._emit("end")}}_emitFinal(){this.receivedMessages.at(-1)&&this._emit("finalMessage",o(this,Ae,"m",ps).call(this))}async _fromReadableStream(e,r){const i=r?.signal;let s;i&&(i.aborted&&this.controller.abort(),s=this.controller.abort.bind(this.controller),i.addEventListener("abort",s));try{o(this,Ae,"m",gs).call(this),this._connected(null);const a=Je.fromReadableStream(e,this.controller);for await(const c of a)o(this,Ae,"m",ms).call(this,c);if(a.controller.signal?.aborted)throw new be;o(this,Ae,"m",ys).call(this)}finally{i&&s&&i.removeEventListener("abort",s)}}[(rt=new WeakMap,Le=new WeakMap,Br=new WeakMap,Kn=new WeakMap,Ir=new WeakMap,qr=new WeakMap,Dn=new WeakMap,Lr=new WeakMap,Ue=new WeakMap,Ur=new WeakMap,Gn=new WeakMap,Vn=new WeakMap,gt=new WeakMap,Jn=new WeakMap,Yn=new WeakMap,Xn=new WeakMap,Fr=new WeakMap,mt=new WeakMap,me=new WeakMap,fs=new WeakMap,Ae=new WeakSet,ps=function(){if(this.receivedMessages.length===0)throw new P("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},th=function(){if(this.receivedMessages.length===0)throw new P("stream ended without producing a Message with role=assistant");const r=this.receivedMessages.at(-1).content.filter(i=>i.type==="text").map(i=>i.text);if(r.length===0)throw new P("stream ended without producing a content block with type=text");return r.join(" ")},gs=function(){this.ended||v(this,rt,void 0)},ms=function(r){if(this.ended)return;const i=o(this,Ae,"m",rh).call(this,r);if(this._emit("_rawEvent",r),!!i)switch(this._emit("streamEvent",r,i),r.type){case"content_block_delta":{const s=i.content.at(-1);switch(r.delta.type){case"text_delta":{s.type==="text"&&this._emit("text",r.delta.text,s.text||"");break}case"citations_delta":{s.type==="text"&&this._emit("citation",r.delta.citation,s.citations??[]);break}case"input_json_delta":{bs(s)&&o(this,Ue,"f").inputJson?.length&&this._emit("inputJson",r.delta.partial_json,s.input);break}case"thinking_delta":{s.type==="thinking"&&this._emit("thinking",r.delta.thinking,s.thinking);break}case"signature_delta":{s.type==="thinking"&&this._emit("signature",s.signature);break}default:r.delta}break}case"message_stop":{o(this,mt,"f")&&o(this,me,"f")&&o(this,Le,"f")&&ba(o(this,mt,"f"),o(this,me,"f"),o(this,Le,"f"),i),this._addMessageParam(i),this._addMessage(eh(i,o(this,Le,"f"),{logger:o(this,Fr,"f")}),!0);break}case"content_block_stop":{this._emit("contentBlock",i.content.at(-1));break}case"message_start":{v(this,rt,i),o(this,me,"f")&&o(this,Le,"f")&&(o(this,me,"f").streamed={body:o(this,Le,"f"),message:i});break}}},ys=function(){if(this.ended)throw new P("stream has ended, this shouldn't happen");const r=o(this,rt,"f");if(!r)throw new P("request ended without sending any chunks");return v(this,rt,void 0),eh(r,o(this,Le,"f"),{logger:o(this,Fr,"f")})},rh=function(r){let i=o(this,rt,"f");if(r.type==="message_start"){if(i)throw new P(`Unexpected event order, got ${r.type} before receiving "message_stop"`);return r.message}if(i)switch(r.type){case"message_stop":return i;case"message_delta":return i.stop_reason=r.delta.stop_reason,i.stop_sequence=r.delta.stop_sequence,i.stop_details=r.delta.stop_details,i.usage.output_tokens=r.usage.output_tokens,r.delta.container!=null&&(i.container=r.delta.container),r.usage.input_tokens!=null&&(i.usage.input_tokens=r.usage.input_tokens),r.usage.cache_creation_input_tokens!=null&&(i.usage.cache_creation_input_tokens=r.usage.cache_creation_input_tokens),r.usage.cache_read_input_tokens!=null&&(i.usage.cache_read_input_tokens=r.usage.cache_read_input_tokens),r.usage.server_tool_use!=null&&(i.usage.server_tool_use=r.usage.server_tool_use),r.usage.output_tokens_details!=null&&(i.usage.output_tokens_details=r.usage.output_tokens_details),i;case"content_block_start":return i.content.push({...r.content_block}),i;case"content_block_delta":{const s=i.content.at(r.index);switch(r.delta.type){case"text_delta":{s?.type==="text"&&(i.content[r.index]={...s,text:(s.text||"")+r.delta.text});break}case"citations_delta":{s?.type==="text"&&(i.content[r.index]={...s,citations:[...s.citations??[],r.delta.citation]});break}case"input_json_delta":{if(s&&bs(s)){const a=(s[tr]||"")+r.delta.partial_json;i.content[r.index]=tf(s,a)}break}case"thinking_delta":{s?.type==="thinking"&&(i.content[r.index]={...s,thinking:s.thinking+r.delta.thinking});break}case"signature_delta":{s?.type==="thinking"&&(i.content[r.index]={...s,signature:r.delta.signature});break}default:r.delta}return i}case"content_block_stop":{const s=i.content.at(r.index);return s&&bs(s)&&tr in s&&Object.defineProperty(s,"input",{value:s.input,enumerable:!0,configurable:!0,writable:!0}),i}default:return i}},Symbol.asyncIterator)](){const e=[],r=[];let i=!1;return this.on("_rawEvent",s=>{const a=r.shift();a?a.resolve(s):e.push(s)}),this.on("end",()=>{i=!0;for(const s of r)s.resolve(void 0);r.length=0}),this.on("abort",s=>{i=!0;for(const a of r)a.reject(s);r.length=0}),this.on("error",s=>{i=!0;for(const a of r)a.reject(s);r.length=0}),{next:async()=>e.length?{value:e.shift(),done:!1}:i?{value:void 0,done:!0}:new Promise((a,c)=>r.push({resolve:a,reject:c})).then(a=>a?{value:a,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new Je(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}return t})();class nh extends k{create(n,e){const{user_profile_id:r,workspace_id:i,...s}=n;return this._client.post("/v1/messages/batches",{body:s,...e,headers:g([{...r!=null?{"anthropic-user-profile-id":r}:void 0,...i!=null?{"anthropic-workspace-id":i}:void 0},e?.headers]),__span:u(this._client,"anthropic.messages.batches.create",e,{route:"/v1/messages/batches",attributes:{"anthropic.message.batch.request_count":s.requests?.length},createdIDAttribute:"anthropic.message.batch.id"})})}retrieve(n,e={},r){const{workspace_id:i}=e??{};return this._client.get(m`/v1/messages/batches/${n}`,{...r,headers:g([{...i!=null?{"anthropic-workspace-id":i}:void 0},r?.headers]),__span:u(this._client,"anthropic.messages.batches.retrieve",r,{route:"/v1/messages/batches/{message_batch_id}",attributes:{"anthropic.message.batch.id":n}})})}list(n={},e){const{workspace_id:r,...i}=n??{};return this._client.getAPIList("/v1/messages/batches",de,{query:i,...e,headers:g([{...r!=null?{"anthropic-workspace-id":r}:void 0},e?.headers]),__span:u(this._client,"anthropic.messages.batches.list",e,{route:"/v1/messages/batches",queryParams:["after_id","before_id","limit"]})})}delete(n,e={},r){const{workspace_id:i}=e??{};return this._client.delete(m`/v1/messages/batches/${n}`,{...r,headers:g([{...i!=null?{"anthropic-workspace-id":i}:void 0},r?.headers]),__span:u(this._client,"anthropic.messages.batches.delete",r,{route:"/v1/messages/batches/{message_batch_id}",attributes:{"anthropic.message.batch.id":n}})})}cancel(n,e={},r){const{workspace_id:i}=e??{};return this._client.post(m`/v1/messages/batches/${n}/cancel`,{...r,headers:g([{...i!=null?{"anthropic-workspace-id":i}:void 0},r?.headers]),__span:u(this._client,"anthropic.messages.batches.cancel",r,{route:"/v1/messages/batches/{message_batch_id}/cancel",attributes:{"anthropic.message.batch.id":n}})})}async results(n,e={},r){const i=await this.retrieve(n,e,r);if(!i.results_url)throw new P(`No batch \`results_url\`; Has it finished processing? ${i.processing_status} - ${i.id}`);const{workspace_id:s}=e??{};return this._client.get(i.results_url,{...r,headers:g([{Accept:"application/binary",...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),stream:!0,__binaryResponse:!0,__span:u(this._client,"anthropic.messages.batches.results",r,{route:"/v1/messages/batches/{message_batch_id}/results",attributes:{"anthropic.message.batch.id":n}})})._thenUnwrap((a,c)=>Vp.fromResponse(c.response,c.controller))}}var jo=(()=>{class t extends R{}return t._errorName="AvailableToolsLimitExceededError",t})(),Ho=(()=>{class t extends R{}return t._errorName="CompactionBlockAmbiguousError",t})(),Ko=(()=>{class t extends R{}return t._errorName="CompactionBlockMisplacedError",t})(),Do=(()=>{class t extends R{}return t._errorName="CompactionContentMismatchError",t})(),Go=(()=>{class t extends R{}return t._errorName="CompactionIncompleteTurnError",t})(),Vo=(()=>{class t extends R{}return t._errorName="CompactionNothingToSummarizeError",t})(),Jo=(()=>{class t extends R{}return t._errorName="CompactionSignatureInvalidError",t})(),Yo=(()=>{class t extends R{}return t._errorName="CompactionTooManyToolReferencesError",t})(),Xo=(()=>{class t extends R{}return t._errorName="CompactionToolChangesMismatchError",t})(),Qo=(()=>{class t extends R{}return t._errorName="ImageDimensionsTooLargeError",t})(),Zo=(()=>{class t extends R{}return t._errorName="ThreadAlreadyContinuedError",t})(),ec=(()=>{class t extends R{}return t._errorName="ThreadContinueInFlightError",t})(),tc=(()=>{class t extends R{}return t._errorName="ThreadFingerprintMismatchError",t})(),rc=(()=>{class t extends R{}return t._errorName="ThreadUnsupportedRequestError",t})(),nc=(()=>{class t extends R{}return t._errorName="ToolNameConflictError",t})(),ic=(()=>{class t extends R{}return t._errorName="ToolReferenceUnresolvedError",t})(),sc=(()=>{class t extends Ye{}return t._errorName="ThreadNotFoundError",t})(),ac=(()=>{class t extends ia{}return t._errorName="CompactionUnavailableError",t})(),ih=(()=>{class t extends k{constructor(){super(...arguments),this.batches=new nh(this._client)}create(e,r){const{user_profile_id:i,workspace_id:s,...a}=e;a.model in yi&&console.warn(`The model '${a.model}' is deprecated and will reach end-of-life on ${yi[a.model]}
|
|
60
|
-
Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`),Yp.includes(a.model)&&a.thinking&&a.thinking.type==="enabled"&&console.warn(`Using Claude with ${a.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`);let c=r?.timeout??this._client._options.timeout;if(!a.stream&&c==null){const h=Jp[a.model]??void 0;c=this._client.calculateNonstreamingTimeout(a.max_tokens,h)}const l={body:a,timeout:c??6e5,...r,headers:_f(e,r),stream:e.stream??!1},d=this._client._tracer&&u(this._client,"anthropic.messages.create",r,Oi(this._client,l));up(this._client,d,a);const _=this._client.post("/v1/messages",{...l,__span:d});return d?_._thenUnwrap(h=>(dp(this._client,d,a,h),h)):_}parse(e,r){return this.create(e,r).then(i=>ff(i,e,{logger:this._client.logger??console}))}stream(e,r){const i=e;return Gw.createMessage(this,i,r,{logger:this._client.logger??console,client:this._client})}countTokens(e,r){const{user_profile_id:i,workspace_id:s,...a}=e,c={body:a,...r,headers:g([{...i!=null?{"anthropic-user-profile-id":i}:void 0,...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers])};return this._client.post("/v1/messages/count_tokens",{...c,__span:u(this._client,"anthropic.messages.count_tokens",r,{route:"/v1/messages/count_tokens",request:c})})}}return t.AvailableToolsLimitExceededError=jo,t.CompactionBlockAmbiguousError=Ho,t.CompactionBlockMisplacedError=Ko,t.CompactionContentMismatchError=Do,t.CompactionIncompleteTurnError=Go,t.CompactionNothingToSummarizeError=Vo,t.CompactionSignatureInvalidError=Jo,t.CompactionTooManyToolReferencesError=Yo,t.CompactionToolChangesMismatchError=Xo,t.ImageDimensionsTooLargeError=Qo,t.ThreadAlreadyContinuedError=Zo,t.ThreadContinueInFlightError=ec,t.ThreadFingerprintMismatchError=tc,t.ThreadUnsupportedRequestError=rc,t.ToolNameConflictError=nc,t.ToolReferenceUnresolvedError=ic,t.ThreadNotFoundError=sc,t.CompactionUnavailableError=ac,t.Batches=nh,t})(),oc=(()=>{class t extends R{}return t._errorName="OrgAPIKeyLimitExceededError",t})(),cc=(()=>{class t extends R{}return t._errorName="WorkspaceAPIKeyLimitExceededError",t})(),sh=(()=>{class t extends k{retrieve(e,r){return this._client.get(m`/v1/organizations/api_keys/${e}`,{...r,__span:u(this._client,"anthropic.organization.api_keys.retrieve",r,{route:"/v1/organizations/api_keys/{api_key_id}",attributes:{"anthropic.organization.api_key.id":e}})})}update(e,r,i){return this._client.post(m`/v1/organizations/api_keys/${e}`,{body:r,...i,__span:u(this._client,"anthropic.organization.api_keys.update",i,{route:"/v1/organizations/api_keys/{api_key_id}",attributes:{"anthropic.organization.api_key.id":e}})})}list(e={},r){return this._client.getAPIList("/v1/organizations/api_keys",de,{query:e,...r,__span:u(this._client,"anthropic.organization.api_keys.list",r,{route:"/v1/organizations/api_keys",queryParams:["after_id","before_id","created_by_user_id","limit","status","workspace_id"]})})}}return t.OrgAPIKeyLimitExceededError=oc,t.WorkspaceAPIKeyLimitExceededError=cc,t})(),lc=(()=>{class t extends R{}return t._errorName="ExternalKeyInWorkspacePolicyError",t})(),uc=(()=>{class t extends R{}return t._errorName="ExternalKeyValidationFailedError",t})(),dc=(()=>{class t extends R{}return t._errorName="ExternalKeyValidationTimedOutError",t})(),hc=(()=>{class t extends ue{}return t._errorName="ExternalKeyChangedError",t})(),ah=(()=>{class t extends k{create(e,r){return this._client.post("/v1/organizations/external_keys",{body:e,...r,__span:u(this._client,"anthropic.organization.external_keys.create",r,{route:"/v1/organizations/external_keys",createdIDAttribute:"anthropic.organization.external_key.id"})})}retrieve(e,r){return this._client.get(m`/v1/organizations/external_keys/${e}`,{...r,__span:u(this._client,"anthropic.organization.external_keys.retrieve",r,{route:"/v1/organizations/external_keys/{external_key_id}",attributes:{"anthropic.organization.external_key.id":e}})})}update(e,r,i){return this._client.post(m`/v1/organizations/external_keys/${e}`,{body:r,...i,__span:u(this._client,"anthropic.organization.external_keys.update",i,{route:"/v1/organizations/external_keys/{external_key_id}",attributes:{"anthropic.organization.external_key.id":e}})})}list(e={},r){return this._client.getAPIList("/v1/organizations/external_keys",z,{query:e,...r,__span:u(this._client,"anthropic.organization.external_keys.list",r,{route:"/v1/organizations/external_keys",queryParams:["limit","page"]})})}delete(e,r){return this._client.delete(m`/v1/organizations/external_keys/${e}`,{...r,__span:u(this._client,"anthropic.organization.external_keys.delete",r,{route:"/v1/organizations/external_keys/{external_key_id}",attributes:{"anthropic.organization.external_key.id":e}})})}validate(e,r){return this._client.post(m`/v1/organizations/external_keys/${e}/validate`,{...r,__span:u(this._client,"anthropic.organization.external_keys.validate",r,{route:"/v1/organizations/external_keys/{external_key_id}/validate",attributes:{"anthropic.organization.external_key.id":e}})})}}return t.ExternalKeyInWorkspacePolicyError=lc,t.ExternalKeyValidationFailedError=uc,t.ExternalKeyValidationTimedOutError=dc,t.ExternalKeyChangedError=hc,t})(),_c=(()=>{class t extends R{}return t._errorName="AlreadyMemberError",t})(),pc=(()=>{class t extends R{}return t._errorName="CannotInviteEmailsWithUnverifiedDomainsError",t})(),fc=(()=>{class t extends R{}return t._errorName="EmailDomainNotAllowedError",t})(),gc=(()=>{class t extends R{}return t._errorName="InviteAlreadyExistsError",t})(),oh=(()=>{class t extends k{create(e,r){return this._client.post("/v1/organizations/invites",{body:e,...r,__span:u(this._client,"anthropic.organization.invites.create",r,{route:"/v1/organizations/invites",createdIDAttribute:"anthropic.organization.invite.id"})})}retrieve(e,r){return this._client.get(m`/v1/organizations/invites/${e}`,{...r,__span:u(this._client,"anthropic.organization.invites.retrieve",r,{route:"/v1/organizations/invites/{invite_id}",attributes:{"anthropic.organization.invite.id":e}})})}list(e={},r){return this._client.getAPIList("/v1/organizations/invites",de,{query:e,...r,__span:u(this._client,"anthropic.organization.invites.list",r,{route:"/v1/organizations/invites",queryParams:["after_id","before_id","email","limit","roles","statuses"]})})}delete(e,r){return this._client.delete(m`/v1/organizations/invites/${e}`,{...r,__span:u(this._client,"anthropic.organization.invites.delete",r,{route:"/v1/organizations/invites/{invite_id}",attributes:{"anthropic.organization.invite.id":e}})})}}return t.AlreadyMemberError=_c,t.CannotInviteEmailsWithUnverifiedDomainsError=pc,t.EmailDomainNotAllowedError=fc,t.InviteAlreadyExistsError=gc,t})();class ch extends k{retrieve(n){return this._client.get("/v1/organizations/compliance_settings",{...n,__span:u(this._client,"anthropic.organization.compliance_settings.retrieve",n,{route:"/v1/organizations/compliance_settings"})})}update(n,e){return this._client.post("/v1/organizations/compliance_settings",{body:n,...e,__span:u(this._client,"anthropic.organization.compliance_settings.update",e,{route:"/v1/organizations/compliance_settings"})})}}let lh=class extends k{list(n={},e){return this._client.getAPIList("/v1/organizations/rate_limits",z,{query:n,...e,__span:u(this._client,"anthropic.organization.rate_limits.list",e,{route:"/v1/organizations/rate_limits",queryParams:["group_type","limit","model","page"]})})}};var mc=(()=>{class t extends R{}return t._errorName="CannotRemoveLastMemberError",t})(),uh=(()=>{class t extends k{retrieve(e,r){return this._client.get(m`/v1/organizations/users/${e}`,{...r,__span:u(this._client,"anthropic.organization.users.retrieve",r,{route:"/v1/organizations/users/{user_id}",attributes:{"anthropic.organization.user.id":e}})})}update(e,r,i){return this._client.post(m`/v1/organizations/users/${e}`,{body:r,...i,__span:u(this._client,"anthropic.organization.users.update",i,{route:"/v1/organizations/users/{user_id}",attributes:{"anthropic.organization.user.id":e}})})}list(e={},r){return this._client.getAPIList("/v1/organizations/users",de,{query:e,...r,__span:u(this._client,"anthropic.organization.users.list",r,{route:"/v1/organizations/users",queryParams:["after_id","before_id","email","limit","roles"]})})}remove(e,r){return this._client.delete(m`/v1/organizations/users/${e}`,{...r,__span:u(this._client,"anthropic.organization.users.remove",r,{route:"/v1/organizations/users/{user_id}",attributes:{"anthropic.organization.user.id":e}})})}}return t.CannotRemoveLastMemberError=mc,t})();class dh extends k{list(n,e){return this._client.getAPIList("/v1/organizations/analytics/artifacts",z,{query:n,...e,__span:u(this._client,"anthropic.organization.analytics.artifacts.list",e,{route:"/v1/organizations/analytics/artifacts",queryParams:["date","filter","group_by","limit","page"]})})}}class hh extends k{list(n={},e){return this._client.getAPIList("/v1/organizations/analytics/connectors",z,{query:n,...e,__span:u(this._client,"anthropic.organization.analytics.connectors.list",e,{route:"/v1/organizations/analytics/connectors",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"],contentQueryParams:["filter"]})})}}class _h extends k{list(n={},e){return this._client.getAPIList("/v1/organizations/analytics/plugins",z,{query:n,...e,__span:u(this._client,"anthropic.organization.analytics.plugins.list",e,{route:"/v1/organizations/analytics/plugins",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"],contentQueryParams:["filter"]})})}}let ph=class extends k{list(n={},e){return this._client.getAPIList("/v1/organizations/analytics/skills",z,{query:n,...e,__span:u(this._client,"anthropic.organization.analytics.skills.list",e,{route:"/v1/organizations/analytics/skills",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"],contentQueryParams:["filter"]})})}};class fh extends k{list(n,e){return this._client.getAPIList("/v1/organizations/analytics/summaries",z,{query:n,...e,__span:u(this._client,"anthropic.organization.analytics.summaries.list",e,{route:"/v1/organizations/analytics/summaries",queryParams:["ending_date","filter","limit","page","starting_date"]})})}}class gh extends k{list(n={},e){return this._client.getAPIList("/v1/organizations/analytics/users",z,{query:n,...e,__span:u(this._client,"anthropic.organization.analytics.users.list",e,{route:"/v1/organizations/analytics/users",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"],contentQueryParams:["page"]})})}}class mh extends k{list(n={},e){return this._client.getAPIList("/v1/organizations/analytics/apps/chat/projects",z,{query:n,...e,__span:u(this._client,"anthropic.organization.analytics.apps.chat.projects.list",e,{route:"/v1/organizations/analytics/apps/chat/projects",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"]})})}}var yh=(()=>{class t extends k{constructor(){super(...arguments),this.projects=new mh(this._client)}}return t.Projects=mh,t})(),bh=(()=>{class t extends k{constructor(){super(...arguments),this.chat=new yh(this._client)}}return t.Chat=yh,t})(),wh=(()=>{class t extends k{constructor(){super(...arguments),this.summaries=new fh(this._client),this.users=new gh(this._client),this.apps=new bh(this._client),this.connectors=new hh(this._client),this.plugins=new _h(this._client),this.skills=new ph(this._client),this.artifacts=new dh(this._client)}}return t.Summaries=fh,t.Users=gh,t.Apps=bh,t.Connectors=hh,t.Plugins=_h,t.Skills=ph,t.Artifacts=dh,t})();class vh extends k{create(n,e){return this._client.post("/v1/organizations/federation_issuers",{body:n,...e,__span:u(this._client,"anthropic.organization.federation.issuers.create",e,{route:"/v1/organizations/federation_issuers",createdIDAttribute:"anthropic.organization.federation_issuer.id"})})}retrieve(n,e){return this._client.get(m`/v1/organizations/federation_issuers/${n}`,{...e,__span:u(this._client,"anthropic.organization.federation.issuers.retrieve",e,{route:"/v1/organizations/federation_issuers/{federation_issuer_id}",attributes:{"anthropic.organization.federation_issuer.id":n}})})}update(n,e,r){return this._client.post(m`/v1/organizations/federation_issuers/${n}`,{body:e,...r,__span:u(this._client,"anthropic.organization.federation.issuers.update",r,{route:"/v1/organizations/federation_issuers/{federation_issuer_id}",attributes:{"anthropic.organization.federation_issuer.id":n}})})}list(n={},e){return this._client.getAPIList("/v1/organizations/federation_issuers",z,{query:n,...e,__span:u(this._client,"anthropic.organization.federation.issuers.list",e,{route:"/v1/organizations/federation_issuers",queryParams:["include_archived","limit","page"]})})}archive(n,e){return this._client.post(m`/v1/organizations/federation_issuers/${n}/archive`,{...e,__span:u(this._client,"anthropic.organization.federation.issuers.archive",e,{route:"/v1/organizations/federation_issuers/{federation_issuer_id}/archive",attributes:{"anthropic.organization.federation_issuer.id":n}})})}}let kh=class extends k{list(n,e={},r){return this._client.getAPIList(m`/v1/organizations/federation_rules/${n}/workspaces`,z,{query:e,...r,__span:u(this._client,"anthropic.organization.federation.rules.workspaces.list",r,{route:"/v1/organizations/federation_rules/{federation_rule_id}/workspaces",queryParams:["limit","page"],attributes:{"anthropic.organization.federation_rule.id":n}})})}add(n,e,r){return this._client.post(m`/v1/organizations/federation_rules/${n}/workspaces`,{body:e,...r,__span:u(this._client,"anthropic.organization.federation.rules.workspaces.add",r,{route:"/v1/organizations/federation_rules/{federation_rule_id}/workspaces",attributes:{"anthropic.organization.federation_rule.id":n},createdIDAttribute:"anthropic.organization.federation_rule.workspace.id",createdIDField:"workspace_id"})})}remove(n,e,r){const{federation_rule_id:i}=e;return this._client.delete(m`/v1/organizations/federation_rules/${i}/workspaces/${n}`,{...r,__span:u(this._client,"anthropic.organization.federation.rules.workspaces.remove",r,{route:"/v1/organizations/federation_rules/{federation_rule_id}/workspaces/{workspace_id}",attributes:{"anthropic.organization.federation_rule.id":i,"anthropic.organization.federation_rule.workspace.id":n}})})}};var Eh=(()=>{class t extends k{constructor(){super(...arguments),this.workspaces=new kh(this._client)}create(e,r){return this._client.post("/v1/organizations/federation_rules",{body:e,...r,__span:u(this._client,"anthropic.organization.federation.rules.create",r,{route:"/v1/organizations/federation_rules",createdIDAttribute:"anthropic.organization.federation_rule.id"})})}retrieve(e,r){return this._client.get(m`/v1/organizations/federation_rules/${e}`,{...r,__span:u(this._client,"anthropic.organization.federation.rules.retrieve",r,{route:"/v1/organizations/federation_rules/{federation_rule_id}",attributes:{"anthropic.organization.federation_rule.id":e}})})}update(e,r,i){return this._client.post(m`/v1/organizations/federation_rules/${e}`,{body:r,...i,__span:u(this._client,"anthropic.organization.federation.rules.update",i,{route:"/v1/organizations/federation_rules/{federation_rule_id}",attributes:{"anthropic.organization.federation_rule.id":e}})})}list(e={},r){return this._client.getAPIList("/v1/organizations/federation_rules",z,{query:e,...r,__span:u(this._client,"anthropic.organization.federation.rules.list",r,{route:"/v1/organizations/federation_rules",queryParams:["include_archived","issuer_id","limit","page"]})})}archive(e,r){return this._client.post(m`/v1/organizations/federation_rules/${e}/archive`,{...r,__span:u(this._client,"anthropic.organization.federation.rules.archive",r,{route:"/v1/organizations/federation_rules/{federation_rule_id}/archive",attributes:{"anthropic.organization.federation_rule.id":e}})})}}return t.Workspaces=kh,t})(),Sh=(()=>{class t extends k{constructor(){super(...arguments),this.issuers=new vh(this._client),this.rules=new Eh(this._client)}}return t.Issuers=vh,t.Rules=Eh,t})();let xh=class extends k{list(n,e={},r){return this._client.getAPIList(m`/v1/organizations/rbac_groups/${n}/members`,z,{query:e,...r,__span:u(this._client,"anthropic.organization.rbac_groups.members.list",r,{route:"/v1/organizations/rbac_groups/{rbac_group_id}/members",queryParams:["limit","page"],attributes:{"anthropic.organization.rbac_group.id":n}})})}add(n,e,r){return this._client.post(m`/v1/organizations/rbac_groups/${n}/members`,{body:e,...r,__span:u(this._client,"anthropic.organization.rbac_groups.members.add",r,{route:"/v1/organizations/rbac_groups/{rbac_group_id}/members",attributes:{"anthropic.organization.rbac_group.id":n},createdIDAttribute:"anthropic.organization.rbac_group.member.id",createdIDField:"user_id"})})}remove(n,e,r){const{rbac_group_id:i}=e;return this._client.delete(m`/v1/organizations/rbac_groups/${i}/members/${n}`,{...r,__span:u(this._client,"anthropic.organization.rbac_groups.members.remove",r,{route:"/v1/organizations/rbac_groups/{rbac_group_id}/members/{user_id}",attributes:{"anthropic.organization.rbac_group.id":i,"anthropic.organization.rbac_group.member.id":n}})})}};var yc=(()=>{class t extends R{}return t._errorName="RBACGroupGrantsOwnerAccessError",t})(),bc=(()=>{class t extends R{}return t._errorName="RBACGroupOwnerAccessUnconfirmedError",t})(),Th=(()=>{class t extends k{constructor(){super(...arguments),this.members=new xh(this._client)}create(e,r){return this._client.post("/v1/organizations/rbac_groups",{body:e,...r,__span:u(this._client,"anthropic.organization.rbac_groups.create",r,{route:"/v1/organizations/rbac_groups",createdIDAttribute:"anthropic.organization.rbac_group.id"})})}retrieve(e,r){return this._client.get(m`/v1/organizations/rbac_groups/${e}`,{...r,__span:u(this._client,"anthropic.organization.rbac_groups.retrieve",r,{route:"/v1/organizations/rbac_groups/{rbac_group_id}",attributes:{"anthropic.organization.rbac_group.id":e}})})}update(e,r,i){return this._client.post(m`/v1/organizations/rbac_groups/${e}`,{body:r,...i,__span:u(this._client,"anthropic.organization.rbac_groups.update",i,{route:"/v1/organizations/rbac_groups/{rbac_group_id}",attributes:{"anthropic.organization.rbac_group.id":e}})})}list(e={},r){return this._client.getAPIList("/v1/organizations/rbac_groups",z,{query:e,...r,__span:u(this._client,"anthropic.organization.rbac_groups.list",r,{route:"/v1/organizations/rbac_groups",queryParams:["limit","page"]})})}delete(e,r){return this._client.delete(m`/v1/organizations/rbac_groups/${e}`,{...r,__span:u(this._client,"anthropic.organization.rbac_groups.delete",r,{route:"/v1/organizations/rbac_groups/{rbac_group_id}",attributes:{"anthropic.organization.rbac_group.id":e}})})}}return t.RBACGroupGrantsOwnerAccessError=yc,t.RBACGroupOwnerAccessUnconfirmedError=bc,t.Members=xh,t})();class Ah extends k{list(n,e={},r){return this._client.getAPIList(m`/v1/organizations/rbac_roles/${n}/permissions`,z,{query:e,...r,__span:u(this._client,"anthropic.organization.rbac_roles.permissions.list",r,{route:"/v1/organizations/rbac_roles/{rbac_role_id}/permissions",queryParams:["limit","page"],attributes:{"anthropic.organization.rbac_role.id":n}})})}}var Rh=(()=>{class t extends k{constructor(){super(...arguments),this.permissions=new Ah(this._client)}retrieve(e,r){return this._client.get(m`/v1/organizations/rbac_roles/${e}`,{...r,__span:u(this._client,"anthropic.organization.rbac_roles.retrieve",r,{route:"/v1/organizations/rbac_roles/{rbac_role_id}",attributes:{"anthropic.organization.rbac_role.id":e}})})}list(e={},r){return this._client.getAPIList("/v1/organizations/rbac_roles",z,{query:e,...r,__span:u(this._client,"anthropic.organization.rbac_roles.list",r,{route:"/v1/organizations/rbac_roles",queryParams:["limit","page"]})})}}return t.Permissions=Ah,t})();let zh=class extends k{list(n,e={},r){return this._client.getAPIList(m`/v1/organizations/service_accounts/${n}/workspaces`,z,{query:e,...r,__span:u(this._client,"anthropic.organization.service_accounts.workspaces.list",r,{route:"/v1/organizations/service_accounts/{service_account_id}/workspaces",queryParams:["limit","page"],attributes:{"anthropic.organization.service_account.id":n}})})}add(n,e,r){return this._client.post(m`/v1/organizations/service_accounts/${n}/workspaces`,{body:e,...r,__span:u(this._client,"anthropic.organization.service_accounts.workspaces.add",r,{route:"/v1/organizations/service_accounts/{service_account_id}/workspaces",attributes:{"anthropic.organization.service_account.id":n},createdIDAttribute:"anthropic.organization.service_account.workspace.id",createdIDField:"workspace_id"})})}remove(n,e,r){const{service_account_id:i}=e;return this._client.delete(m`/v1/organizations/service_accounts/${i}/workspaces/${n}`,{...r,__span:u(this._client,"anthropic.organization.service_accounts.workspaces.remove",r,{route:"/v1/organizations/service_accounts/{service_account_id}/workspaces/{workspace_id}",attributes:{"anthropic.organization.service_account.id":i,"anthropic.organization.service_account.workspace.id":n}})})}};var Ph=(()=>{class t extends k{constructor(){super(...arguments),this.workspaces=new zh(this._client)}create(e,r){return this._client.post("/v1/organizations/service_accounts",{body:e,...r,__span:u(this._client,"anthropic.organization.service_accounts.create",r,{route:"/v1/organizations/service_accounts",createdIDAttribute:"anthropic.organization.service_account.id"})})}retrieve(e,r){return this._client.get(m`/v1/organizations/service_accounts/${e}`,{...r,__span:u(this._client,"anthropic.organization.service_accounts.retrieve",r,{route:"/v1/organizations/service_accounts/{service_account_id}",attributes:{"anthropic.organization.service_account.id":e}})})}update(e,r,i){return this._client.post(m`/v1/organizations/service_accounts/${e}`,{body:r,...i,__span:u(this._client,"anthropic.organization.service_accounts.update",i,{route:"/v1/organizations/service_accounts/{service_account_id}",attributes:{"anthropic.organization.service_account.id":e}})})}list(e={},r){return this._client.getAPIList("/v1/organizations/service_accounts",z,{query:e,...r,__span:u(this._client,"anthropic.organization.service_accounts.list",r,{route:"/v1/organizations/service_accounts",queryParams:["include_archived","limit","page"]})})}archive(e,r){return this._client.post(m`/v1/organizations/service_accounts/${e}/archive`,{...r,__span:u(this._client,"anthropic.organization.service_accounts.archive",r,{route:"/v1/organizations/service_accounts/{service_account_id}/archive",attributes:{"anthropic.organization.service_account.id":e}})})}}return t.Workspaces=zh,t})();class Ch extends k{list(n={},e){return this._client.getAPIList("/v1/organizations/spend_limits/effective",z,{query:n,...e,__span:u(this._client,"anthropic.organization.spend_limits.effective.list",e,{route:"/v1/organizations/spend_limits/effective",queryParams:["limit","page","period","user_ids"]})})}}class Oh extends k{retrieve(n,e){return this._client.get(m`/v1/organizations/spend_limit_increase_requests/${n}`,{...e,__span:u(this._client,"anthropic.organization.spend_limits.increase_requests.retrieve",e,{route:"/v1/organizations/spend_limit_increase_requests/{spend_limit_increase_request_id}",attributes:{"anthropic.organization.spend_limit_increase_request.id":n}})})}list(n={},e){return this._client.getAPIList("/v1/organizations/spend_limit_increase_requests",z,{query:n,...e,__span:u(this._client,"anthropic.organization.spend_limits.increase_requests.list",e,{route:"/v1/organizations/spend_limit_increase_requests",queryParams:["actor_ids","limit","page","status"]})})}approve(n,e,r){return this._client.post(m`/v1/organizations/spend_limit_increase_requests/${n}/approve`,{body:e,...r,__span:u(this._client,"anthropic.organization.spend_limits.increase_requests.approve",r,{route:"/v1/organizations/spend_limit_increase_requests/{spend_limit_increase_request_id}/approve",attributes:{"anthropic.organization.spend_limit_increase_request.id":n}})})}deny(n,e,r){return this._client.post(m`/v1/organizations/spend_limit_increase_requests/${n}/deny`,{body:e,...r,__span:u(this._client,"anthropic.organization.spend_limits.increase_requests.deny",r,{route:"/v1/organizations/spend_limit_increase_requests/{spend_limit_increase_request_id}/deny",attributes:{"anthropic.organization.spend_limit_increase_request.id":n}})})}}var Nh=(()=>{class t extends k{constructor(){super(...arguments),this.effective=new Ch(this._client),this.increaseRequests=new Oh(this._client)}}return t.Effective=Ch,t.IncreaseRequests=Oh,t})();class Mh extends k{retrieve(n,e,r){const{workspace_id:i}=e;return this._client.get(m`/v1/organizations/workspaces/${i}/members/${n}`,{...r,__span:u(this._client,"anthropic.organization.workspaces.members.retrieve",r,{route:"/v1/organizations/workspaces/{workspace_id}/members/{user_id}",attributes:{"anthropic.organization.workspace.id":i,"anthropic.organization.workspace.member.id":n}})})}update(n,e,r){const{workspace_id:i,...s}=e;return this._client.post(m`/v1/organizations/workspaces/${i}/members/${n}`,{body:s,...r,__span:u(this._client,"anthropic.organization.workspaces.members.update",r,{route:"/v1/organizations/workspaces/{workspace_id}/members/{user_id}",attributes:{"anthropic.organization.workspace.id":i,"anthropic.organization.workspace.member.id":n}})})}list(n,e={},r){return this._client.getAPIList(m`/v1/organizations/workspaces/${n}/members`,de,{query:e,...r,__span:u(this._client,"anthropic.organization.workspaces.members.list",r,{route:"/v1/organizations/workspaces/{workspace_id}/members",queryParams:["after_id","before_id","limit"],attributes:{"anthropic.organization.workspace.id":n}})})}add(n,e,r){return this._client.post(m`/v1/organizations/workspaces/${n}/members`,{body:e,...r,__span:u(this._client,"anthropic.organization.workspaces.members.add",r,{route:"/v1/organizations/workspaces/{workspace_id}/members",attributes:{"anthropic.organization.workspace.id":n},createdIDAttribute:"anthropic.organization.workspace.member.id",createdIDField:"user_id"})})}remove(n,e,r){const{workspace_id:i}=e;return this._client.delete(m`/v1/organizations/workspaces/${i}/members/${n}`,{...r,__span:u(this._client,"anthropic.organization.workspaces.members.remove",r,{route:"/v1/organizations/workspaces/{workspace_id}/members/{user_id}",attributes:{"anthropic.organization.workspace.id":i,"anthropic.organization.workspace.member.id":n}})})}}class $h extends k{update(n,e,r){const{workspace_id:i,...s}=e;return this._client.post(m`/v1/organizations/workspaces/${i}/rate_limits/${n}`,{body:s,...r,__span:u(this._client,"anthropic.organization.workspaces.rate_limits.update",r,{route:"/v1/organizations/workspaces/{workspace_id}/rate_limits/{rate_limit_id}",attributes:{"anthropic.organization.workspace.id":i,"anthropic.organization.workspace.rate_limit.id":n}})})}list(n,e={},r){return this._client.getAPIList(m`/v1/organizations/workspaces/${n}/rate_limits`,z,{query:e,...r,__span:u(this._client,"anthropic.organization.workspaces.rate_limits.list",r,{route:"/v1/organizations/workspaces/{workspace_id}/rate_limits",queryParams:["group_type","include_inherited","limit","page"],attributes:{"anthropic.organization.workspace.id":n}})})}}class Bh extends k{retrieve(n,e,r){const{workspace_id:i}=e;return this._client.get(m`/v1/organizations/workspaces/${i}/service_accounts/${n}`,{...r,__span:u(this._client,"anthropic.organization.workspaces.service_accounts.retrieve",r,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id}",attributes:{"anthropic.organization.workspace.id":i,"anthropic.organization.workspace.service_account.id":n}})})}update(n,e,r){const{workspace_id:i,...s}=e;return this._client.post(m`/v1/organizations/workspaces/${i}/service_accounts/${n}`,{body:s,...r,__span:u(this._client,"anthropic.organization.workspaces.service_accounts.update",r,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id}",attributes:{"anthropic.organization.workspace.id":i,"anthropic.organization.workspace.service_account.id":n}})})}list(n,e={},r){return this._client.getAPIList(m`/v1/organizations/workspaces/${n}/service_accounts`,z,{query:e,...r,__span:u(this._client,"anthropic.organization.workspaces.service_accounts.list",r,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts",queryParams:["limit","page"],attributes:{"anthropic.organization.workspace.id":n}})})}add(n,e,r){return this._client.post(m`/v1/organizations/workspaces/${n}/service_accounts`,{body:e,...r,__span:u(this._client,"anthropic.organization.workspaces.service_accounts.add",r,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts",attributes:{"anthropic.organization.workspace.id":n},createdIDAttribute:"anthropic.organization.workspace.service_account.id",createdIDField:"service_account_id"})})}remove(n,e,r){const{workspace_id:i}=e;return this._client.delete(m`/v1/organizations/workspaces/${i}/service_accounts/${n}`,{...r,__span:u(this._client,"anthropic.organization.workspaces.service_accounts.remove",r,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id}",attributes:{"anthropic.organization.workspace.id":i,"anthropic.organization.workspace.service_account.id":n}})})}}var wc=(()=>{class t extends R{}return t._errorName="KeyProfileMismatchError",t})(),vc=(()=>{class t extends R{}return t._errorName="StorageProfileMismatchError",t})(),kc=(()=>{class t extends R{}return t._errorName="WorkspaceMemberLimitExceededError",t})(),Ec=(()=>{class t extends R{}return t._errorName="WorkspacePolicyViolationError",t})(),Sc=(()=>{class t extends ue{}return t._errorName="StorageAttachedDuringArchiveError",t})(),xc=(()=>{class t extends ot{}return t._errorName="WorkspaceCreatedIncompleteError",t})(),Ih=(()=>{class t extends k{constructor(){super(...arguments),this.rateLimits=new $h(this._client),this.members=new Mh(this._client),this.serviceAccounts=new Bh(this._client)}create(e,r){return this._client.post("/v1/organizations/workspaces",{body:e,...r,__span:u(this._client,"anthropic.organization.workspaces.create",r,{route:"/v1/organizations/workspaces",createdIDAttribute:"anthropic.organization.workspace.id"})})}retrieve(e,r){return this._client.get(m`/v1/organizations/workspaces/${e}`,{...r,__span:u(this._client,"anthropic.organization.workspaces.retrieve",r,{route:"/v1/organizations/workspaces/{workspace_id}",attributes:{"anthropic.organization.workspace.id":e}})})}update(e,r,i){return this._client.post(m`/v1/organizations/workspaces/${e}`,{body:r,...i,__span:u(this._client,"anthropic.organization.workspaces.update",i,{route:"/v1/organizations/workspaces/{workspace_id}",attributes:{"anthropic.organization.workspace.id":e}})})}list(e={},r){return this._client.getAPIList("/v1/organizations/workspaces",de,{query:e,...r,__span:u(this._client,"anthropic.organization.workspaces.list",r,{route:"/v1/organizations/workspaces",queryParams:["after_id","before_id","ids","include_archived","include_default","limit"]})})}archive(e,r){return this._client.post(m`/v1/organizations/workspaces/${e}/archive`,{...r,__span:u(this._client,"anthropic.organization.workspaces.archive",r,{route:"/v1/organizations/workspaces/{workspace_id}/archive",attributes:{"anthropic.organization.workspace.id":e}})})}}return t.KeyProfileMismatchError=wc,t.StorageProfileMismatchError=vc,t.WorkspaceMemberLimitExceededError=kc,t.WorkspacePolicyViolationError=Ec,t.StorageAttachedDuringArchiveError=Sc,t.WorkspaceCreatedIncompleteError=xc,t.RateLimits=$h,t.Members=Mh,t.ServiceAccounts=Bh,t})(),Tc=(()=>{class t extends R{}return t._errorName="OrgMemberLimitExceededError",t})(),Ac=(()=>{class t extends Ye{}return t._errorName="RBACRoleNotFoundError",t})(),Rc=(()=>{class t extends ue{}return t._errorName="ConcurrentMembershipChangeError",t})(),zc=(()=>{class t extends ot{}return t._errorName="ChangeOutcomeUnknownError",t})(),qh=(()=>{class t extends k{constructor(){super(...arguments),this.apiKeys=new sh(this._client),this.externalKeys=new ah(this._client),this.federation=new Sh(this._client),this.invites=new oh(this._client),this.serviceAccounts=new Ph(this._client),this.users=new uh(this._client),this.workspaces=new Ih(this._client),this.rateLimits=new lh(this._client),this.complianceSettings=new ch(this._client),this.analytics=new wh(this._client),this.spendLimits=new Nh(this._client),this.rbacGroups=new Th(this._client),this.rbacRoles=new Rh(this._client)}retrieve(e){return this._client.get("/v1/organizations/me",{...e,__span:u(this._client,"anthropic.organization.retrieve",e,{route:"/v1/organizations/me"})})}}return t.OrgMemberLimitExceededError=Tc,t.RBACRoleNotFoundError=Ac,t.ConcurrentMembershipChangeError=Rc,t.ChangeOutcomeUnknownError=zc,t.APIKeys=sh,t.OrgAPIKeyLimitExceededError=oc,t.WorkspaceAPIKeyLimitExceededError=cc,t.ExternalKeys=ah,t.ExternalKeyInWorkspacePolicyError=lc,t.ExternalKeyValidationFailedError=uc,t.ExternalKeyValidationTimedOutError=dc,t.ExternalKeyChangedError=hc,t.Federation=Sh,t.Invites=oh,t.AlreadyMemberError=_c,t.CannotInviteEmailsWithUnverifiedDomainsError=pc,t.EmailDomainNotAllowedError=fc,t.InviteAlreadyExistsError=gc,t.ServiceAccounts=Ph,t.Users=uh,t.CannotRemoveLastMemberError=mc,t.Workspaces=Ih,t.KeyProfileMismatchError=wc,t.StorageProfileMismatchError=vc,t.WorkspaceMemberLimitExceededError=kc,t.WorkspacePolicyViolationError=Ec,t.StorageAttachedDuringArchiveError=Sc,t.WorkspaceCreatedIncompleteError=xc,t.RateLimits=lh,t.ComplianceSettings=ch,t.Analytics=wh,t.SpendLimits=Nh,t.RBACGroups=Th,t.RBACGroupGrantsOwnerAccessError=yc,t.RBACGroupOwnerAccessUnconfirmedError=bc,t.RBACRoles=Rh,t})();class Lh extends k{create(n,e,r){const{workspace_id:i,...s}=e;return this._client.post(m`/v1/skills/${n}/versions`,Xe({body:s,...r,headers:g([{...i!=null?{"anthropic-workspace-id":i}:void 0},r?.headers]),__span:u(this._client,"anthropic.skills.versions.create",r,{route:"/v1/skills/{skill_id}/versions",attributes:{"anthropic.skill.id":n},createdIDAttribute:"anthropic.skill.version.id"})},this._client,!1))}retrieve(n,e,r){const{skill_id:i,workspace_id:s}=e;return this._client.get(m`/v1/skills/${i}/versions/${n}`,{...r,headers:g([{...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__span:u(this._client,"anthropic.skills.versions.retrieve",r,{route:"/v1/skills/{skill_id}/versions/{version}",attributes:{"anthropic.skill.id":i,"anthropic.skill.version.id":n}})})}list(n,e={},r){const{workspace_id:i,...s}=e??{};return this._client.getAPIList(m`/v1/skills/${n}/versions`,z,{query:s,...r,headers:g([{...i!=null?{"anthropic-workspace-id":i}:void 0},r?.headers]),__span:u(this._client,"anthropic.skills.versions.list",r,{route:"/v1/skills/{skill_id}/versions",queryParams:["limit","page"],attributes:{"anthropic.skill.id":n}})})}delete(n,e,r){const{skill_id:i,workspace_id:s}=e;return this._client.delete(m`/v1/skills/${i}/versions/${n}`,{...r,headers:g([{...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__span:u(this._client,"anthropic.skills.versions.delete",r,{route:"/v1/skills/{skill_id}/versions/{version}",attributes:{"anthropic.skill.id":i,"anthropic.skill.version.id":n}})})}}var Pc=(()=>{class t extends ue{}return t._errorName="SkillReadBlockedUndecryptableError",t})(),Uh=(()=>{class t extends k{constructor(){super(...arguments),this.versions=new Lh(this._client)}create(e,r){const{workspace_id:i,...s}=e;return this._client.post("/v1/skills",Xe({body:s,...r,headers:g([{...i!=null?{"anthropic-workspace-id":i}:void 0},r?.headers]),__span:u(this._client,"anthropic.skills.create",r,{route:"/v1/skills",createdIDAttribute:"anthropic.skill.id"})},this._client,!1))}retrieve(e,r={},i){const{workspace_id:s}=r??{};return this._client.get(m`/v1/skills/${e}`,{...i,headers:g([{...s!=null?{"anthropic-workspace-id":s}:void 0},i?.headers]),__span:u(this._client,"anthropic.skills.retrieve",i,{route:"/v1/skills/{skill_id}",attributes:{"anthropic.skill.id":e}})})}list(e={},r){const{workspace_id:i,...s}=e??{};return this._client.getAPIList("/v1/skills",z,{query:s,...r,headers:g([{...i!=null?{"anthropic-workspace-id":i}:void 0},r?.headers]),__span:u(this._client,"anthropic.skills.list",r,{route:"/v1/skills",queryParams:["limit","page","source"]})})}delete(e,r={},i){const{workspace_id:s}=r??{};return this._client.delete(m`/v1/skills/${e}`,{...i,headers:g([{...s!=null?{"anthropic-workspace-id":s}:void 0},i?.headers]),__span:u(this._client,"anthropic.skills.delete",i,{route:"/v1/skills/{skill_id}",attributes:{"anthropic.skill.id":e}})})}}return t.SkillReadBlockedUndecryptableError=Pc,t.Versions=Lh,t})();class Fh extends k{create(n,e,r){const{workspace_id:i,...s}=e;return this._client.post(m`/v1/user_profiles/${n}/action_urls`,{body:s,...r,headers:g([{...i!=null?{"anthropic-workspace-id":i}:void 0},r?.headers]),__span:u(this._client,"anthropic.user_profiles.action_urls.create",r,{route:"/v1/user_profiles/{user_profile_id}/action_urls",attributes:{"anthropic.user_profile.id":n}})})}}var Cc=(()=>{class t extends R{}return t._errorName="UserProfileNotFoundError",t})(),Oc=(()=>{class t extends R{}return t._errorName="UserProfileRequiredError",t})(),Nc=(()=>{class t extends oe{}return t._errorName="UserProfileBillingNotAuthorizedError",t})(),Mc=(()=>{class t extends oe{}return t._errorName="UserProfileNotBillableError",t})(),Wh=(()=>{class t extends k{constructor(){super(...arguments),this.actionURLs=new Fh(this._client)}create(e,r){const{workspace_id:i,...s}=e;return this._client.post("/v1/user_profiles",{body:s,...r,headers:g([{...i!=null?{"anthropic-workspace-id":i}:void 0},r?.headers]),__span:u(this._client,"anthropic.user_profiles.create",r,{route:"/v1/user_profiles",createdIDAttribute:"anthropic.user_profile.id"})})}retrieve(e,r={},i){const{workspace_id:s}=r??{};return this._client.get(m`/v1/user_profiles/${e}`,{...i,headers:g([{...s!=null?{"anthropic-workspace-id":s}:void 0},i?.headers]),__span:u(this._client,"anthropic.user_profiles.retrieve",i,{route:"/v1/user_profiles/{user_profile_id}",attributes:{"anthropic.user_profile.id":e}})})}update(e,r,i){const{workspace_id:s,...a}=r;return this._client.post(m`/v1/user_profiles/${e}`,{body:a,...i,headers:g([{...s!=null?{"anthropic-workspace-id":s}:void 0},i?.headers]),__span:u(this._client,"anthropic.user_profiles.update",i,{route:"/v1/user_profiles/{user_profile_id}",attributes:{"anthropic.user_profile.id":e}})})}list(e={},r){const{workspace_id:i,...s}=e??{};return this._client.getAPIList("/v1/user_profiles",z,{query:s,...r,headers:g([{...i!=null?{"anthropic-workspace-id":i}:void 0},r?.headers]),__span:u(this._client,"anthropic.user_profiles.list",r,{route:"/v1/user_profiles",queryParams:["enforcement_status","limit","order","order_by","page"]})})}delete(e,r={},i){const{workspace_id:s}=r??{};return this._client.delete(m`/v1/user_profiles/${e}`,{...i,headers:g([{...s!=null?{"anthropic-workspace-id":s}:void 0},i?.headers]),__span:u(this._client,"anthropic.user_profiles.delete",i,{route:"/v1/user_profiles/{user_profile_id}",attributes:{"anthropic.user_profile.id":e}})})}}return t.UserProfileNotFoundError=Cc,t.UserProfileRequiredError=Oc,t.UserProfileBillingNotAuthorizedError=Nc,t.UserProfileNotBillableError=Mc,t.ActionURLs=Fh,t})();const Vw=new Map([["400 already_member",_c],["400 approval_required",Ao],["400 available_tools_limit_exceeded",jo],["400 bundle_attachment_not_supported",oo],["400 bundle_on_call",co],["400 cannot_invite_emails_with_unverified_domains",pc],["400 cannot_remove_last_member",mc],["400 cannot_sign_out_primary_owner",Ya],["400 cannot_sign_out_self",Xa],["400 claude_code_key_creator_not_member",wp],["400 claude_code_version_too_old",vp],["400 cmek_feature_unsupported",ro],["400 cmek_key_disabled",kp],["400 cmek_key_network_blocked",Ep],["400 cmek_not_approved",Oo],["400 compaction_block_ambiguous",Ho],["400 compaction_block_misplaced",Ko],["400 compaction_content_mismatch",Do],["400 compaction_incomplete_turn",Go],["400 compaction_nothing_to_summarize",Vo],["400 compaction_signature_invalid",Jo],["400 compaction_too_many_tool_references",Yo],["400 compaction_tool_changes_mismatch",Xo],["400 email_domain_not_allowed",fc],["400 environment_archived",Ra],["400 external_key_in_workspace_policy",lc],["400 external_key_not_found",No],["400 external_key_provider_mismatch",Mo],["400 external_key_validation_failed",uc],["400 external_key_validation_timed_out",dc],["400 external_storage_in_use",Ia],["400 external_storage_in_workspace_policy",qa],["400 external_storage_not_available",La],["400 file_not_downloadable",Ea],["400 gcp_project_not_verified",$o],["400 grant_required",Ua],["400 human_review_not_available",Ro],["400 human_review_on_with_external_storage",So],["400 image_dimensions_too_large",Qo],["400 invalid_config_type_change",za],["400 invalid_metadata",Pa],["400 invalid_storage_arn",Fa],["400 invite_already_exists",gc],["400 key_profile_mismatch",wc],["400 org_api_key_limit_exceeded",oc],["400 org_member_limit_exceeded",Tc],["400 organization_not_eligible",zo],["400 organization_not_enrolled_in_beta",Bo],["400 organization_on_hold",Sp],["400 organization_type_not_supported",xp],["400 parent_organization_required",Tp],["400 provider_not_allowed",Wa],["400 rbac_group_grants_owner_access",yc],["400 rbac_group_order_limit_exceeded",no],["400 rbac_group_owner_access_unconfirmed",bc],["400 region_not_supported",Io],["400 request_body_encoding_invalid",Ap],["400 request_body_encoding_unsupported",Rp],["400 request_body_timeout",qo],["400 scan_failed",mo],["400 settings_document_limit_exceeded",io],["400 settings_history_limit_exceeded",so],["400 slack_channel_set_up_settings_refused",lo],["400 storage_attach_limit_reached",ja],["400 storage_not_approved",Lo],["400 storage_not_attachable",Ha],["400 storage_profile_mismatch",vc],["400 storage_profile_still_required",Ka],["400 storage_quota_exceeded",Sa],["400 storage_verification_failed",Da],["400 thread_already_continued",Zo],["400 thread_continue_in_flight",ec],["400 thread_fingerprint_mismatch",tc],["400 thread_unsupported_request",rc],["400 tool_name_conflict",nc],["400 tool_reference_unresolved",ic],["400 transcripts_storage_required",xo],["400 unsupported_charset",Uo],["400 unsupported_region",Ga],["400 user_profile_not_found",Cc],["400 user_profile_required",Oc],["400 workspace_api_key_limit_exceeded",cc],["400 workspace_human_review_disabled",zp],["400 workspace_member_limit_exceeded",kc],["400 workspace_policy_violation",Ec],["402 linked_organization_billing_unavailable",Pp],["402 linked_organization_spend_limit_reached",Cp],["403 api_key_scope_missing",uo],["403 cannot_sign_out_managed_member",Qa],["403 cannot_sign_out_membership_admin",Za],["403 cannot_sign_out_owner",eo],["403 cannot_sign_out_privileged_member",to],["403 claude_tag_writes_not_enabled",ho],["403 compliance_configuration_restricted",_o],["403 environment_create_disabled",Ca],["403 environment_update_disabled",Oa],["403 organization_level_scoped_api_key_required",po],["403 sandbox_egress_restricted",Op],["403 spend_limits_admin_api_writes_not_enabled",Eo],["403 user_profile_billing_not_authorized",Nc],["403 user_profile_not_billable",Mc],["404 environment_not_found",Na],["404 file_expired",xa],["404 rbac_group_managed_settings_not_found",ao],["404 rbac_group_not_found",ko],["404 rbac_role_not_found",Ac],["404 slack_channel_set_up_environment_not_found",fo],["404 thread_not_found",sc],["409 concurrent_membership_change",Rc],["409 external_key_changed",hc],["409 gcp_project_controlled_by_another_organization",Fo],["409 plugin_name_taken",yo],["409 scan_pending",bo],["409 skill_name_taken",wo],["409 skill_read_blocked_undecryptable",Pc],["409 slack_channel_set_up_settings_conflict",go],["409 storage_already_registered",Va],["409 storage_attached_during_archive",Sc],["409 storage_changed_concurrently",Ja],["409 storage_in_use",Wo],["409 workspace_changed_concurrently",To],["412 heartbeat_precondition_failed",Aa],["413 request_body_too_large_after_decoding",Np],["429 contract_spend_limit_reached",Mp],["429 enforced_spend_limit_reached",$p],["429 ramp_limit_exceeded",Bp],["503 authorization_check_unavailable",Po],["503 change_outcome_unknown",zc],["503 cmek_context_unavailable",Ip],["503 cmek_key_unreachable",qp],["503 registration_pending",vo],["503 workspace_created_incomplete",xc],["529 compaction_unavailable",ac]]),Jw="urn:ietf:params:oauth:grant-type:jwt-bearer",Yw="refresh_token",gf="/v1/oauth/token",wi="oauth-2025-04-20",Xw="oidc-federation-2026-04-01",Qw=120,$c=30,Zw=5,jh=1<<20;function mf(t){if(!t)return;let n;try{n=new URL(t)}catch(r){throw new D(`Invalid token endpoint base URL "${t}": ${r}`)}if(n.protocol==="https:")return;const e=n.hostname.toLowerCase().replace(/^\[|\]$/g,"");if(!(n.protocol==="http:"&&(e==="localhost"||e==="127.0.0.1"||e==="::1")))throw new D(`Refusing to send credential over non-https token endpoint "${t}"`)}async function yf(t,n){const e=await tv(t);let r;try{r=JSON.parse(e)}catch{throw new D(`Token endpoint returned non-JSON response (status ${t.status})`,t.status,Re(e),n)}if(!r.access_token)throw new D(`Token endpoint response missing access_token: ${JSON.stringify(Re(r))}`,t.status,Re(r),n);if(r.token_type&&r.token_type.toLowerCase()!=="bearer")throw new D(`Token endpoint response: unsupported token_type "${r.token_type}" (want Bearer)`,t.status,Re(r),n);return r}const ws=2e3,ev=new Set(["error","error_description","error_uri"]);function Re(t){if(t==null)return t;if(typeof t=="string"){let n;try{n=JSON.parse(t)}catch{return t.length<=ws?t:t.slice(0,ws)+`... <${t.length-ws} more chars>`}return JSON.stringify(Re(n))}if(typeof t=="object"&&!Array.isArray(t)){const n={};for(const[e,r]of Object.entries(t))ev.has(e)&&(n[e]=r);return n}return null}async function bf(t,n=e=>console.warn(`anthropic-sdk: ${e}`)){if(typeof process>"u"||process.platform==="win32")return;const{fs:e}=await Fe(async()=>{const{fs:a}=await import("./node.browser-CA5eNPFK.js");return{fs:a}},__vite__mapDeps([4,1,2,3]));let r=t,i;try{r=await e.promises.realpath(t),i=await e.promises.stat(r)}catch{return}const s=i.mode&511;if(s&18)throw new D(`Credentials file at ${r} is group/world-writable (mode 0o${s.toString(8)}); this allows other local users to plant tokens. Run \`chmod 600 ${r}\`.`);if(s&36)throw new D(`Credentials file at ${r} is group/world-readable (mode 0o${s.toString(8)}); run \`chmod 600 ${r}\` before retrying.`);typeof process.getuid=="function"&&i.uid!==process.getuid()&&n(`credentials file at ${r} is owned by uid ${i.uid} (current process uid ${process.getuid()}); verify this is intentional.`)}async function wf(t,n){const{fs:e,path:r}=await Fe(async()=>{const{fs:a,path:c}=await import("./node.browser-CA5eNPFK.js");return{fs:a,path:c}},__vite__mapDeps([4,1,2,3])),i=r.dirname(t);await e.promises.mkdir(i,{recursive:!0,mode:448});const s=`${t}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;try{const a=await e.promises.open(s,"w",384);try{await a.writeFile(JSON.stringify(n,null,2)),await a.sync()}finally{await a.close()}await e.promises.rename(s,t)}catch(a){throw await e.promises.unlink(s).catch(()=>{}),a}try{const a=await e.promises.open(i,"r");try{await a.sync()}finally{await a.close()}}catch{}}async function tv(t){if(!t.body)return"";const n=t.body.getReader(),e=[];let r=0;for(;;){const{done:s,value:a}=await n.read();if(s)break;if(r+a.length>jh){const c=jh-r;c>0&&e.push(a.subarray(0,c)),await n.cancel();break}e.push(a),r+=a.length}let i;if(e.length===1)i=e[0];else{i=new Uint8Array(e.reduce((a,c)=>a+c.length,0));let s=0;for(const a of e)i.set(a,s),s+=a.length}return new TextDecoder("utf-8").decode(i)}var D=(()=>{class t extends P{constructor(e,r=null,i=null,s=null){super(e),this.statusCode=r,this.body=i,this.requestId=s}}return t._errorName="WorkloadIdentityError",t})();function St(){return Math.floor(Date.now()/1e3)}class rv{constructor(n,e){this.cached=null,this.pendingRefresh=null,this.nextForce=!1,this.lastAdvisoryError=0,this.provider=n,this.onAdvisoryRefreshError=e}async getToken(){const n=this.nextForce;this.nextForce=!1;const e=this.cached;if(n||e==null)return(await this.refresh(n)).token;if(e.expiresAt==null)return e.token;const r=e.expiresAt-St();return r>Qw?e.token:r>$c?(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||St()-this.lastAdvisoryError<Zw||this.doRefresh().catch(n=>{this.lastAdvisoryError=St(),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}}const vf="1.0",nv=/^[A-Za-z0-9_.-]+$/;function kf(t){if(!t)throw new Error("profile name is empty");if(t==="."||t==="..")throw new Error(`profile name "${t}" is not allowed`);if(t.includes("/")||t.includes("\\"))throw new Error(`profile name "${t}" must not contain path separators`);if(!nv.test(t))throw new Error(`profile name "${t}" contains disallowed characters (allowed: letters, digits, '_', '.', '-')`)}const iv=async t=>{var n,e;const r=await Bc();if(r===null)return null;const i=t==null&&I("ANTHROPIC_PROFILE")!=null;let s=null;if(t==null&&!i){const f=I("ANTHROPIC_ORGANIZATION_ID"),b=I("ANTHROPIC_IDENTITY_TOKEN_FILE"),y=I("ANTHROPIC_FEDERATION_RULE_ID");if(y&&f&&(s={fromFile:!1,config:{organization_id:f,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:b?{source:"file",path:b}:void 0,scope:I("ANTHROPIC_SCOPE")}}},b||I("ANTHROPIC_IDENTITY_TOKEN")))return s}const a=t??await Ef();if(a===null)return null;kf(a);const{fs:c,path:l}=await Fe(async()=>{const{fs:f,path:b}=await import("./node.browser-CA5eNPFK.js");return{fs:f,path:b}},__vite__mapDeps([4,1,2,3])),d=l.join(r,"configs",`${a}.json`);let _;try{_=await c.promises.readFile(d,"utf-8")}catch(f){if(f?.code!=="ENOENT")throw new Error(`failed to read config file ${d}: ${f}`);if(i)throw new P(`ANTHROPIC_PROFILE names the profile "${a}", but ${d} does not exist. Set ANTHROPIC_PROFILE to a profile that exists, or unset it.`,{cause:f});return s}let h;try{h=JSON.parse(_)}catch(f){throw new Error(`failed to parse config file ${d}: ${f}`)}if(!h.authentication)throw new Error(`config file ${d} is missing "authentication"`);const p=h.authentication.type;if(p!=="oidc_federation"&&p!=="user_oauth")throw new Error(`authentication.type "${p}" is not a known authentication type`);if(h.organization_id??(h.organization_id=I("ANTHROPIC_ORGANIZATION_ID")),h.workspace_id??(h.workspace_id=I("ANTHROPIC_WORKSPACE_ID")),h.base_url??(h.base_url=I("ANTHROPIC_BASE_URL")),(n=h.authentication).scope??(n.scope=I("ANTHROPIC_SCOPE")),h.authentication.type==="oidc_federation"){if(!h.authentication.identity_token){const f=I("ANTHROPIC_IDENTITY_TOKEN_FILE");f&&(h.authentication.identity_token={source:"file",path:f})}h.authentication.federation_rule_id||(h.authentication.federation_rule_id=I("ANTHROPIC_FEDERATION_RULE_ID")??""),(e=h.authentication).service_account_id??(e.service_account_id=I("ANTHROPIC_SERVICE_ACCOUNT_ID"))}return{config:h,fromFile:!0}},sv=async(t,n)=>{if(t?.authentication.credentials_path)return t.authentication.credentials_path;const e=await Bc();if(!e)return null;const r=n??await Ef();if(!r)return null;kf(r);const{path:i}=await Fe(async()=>{const{path:s}=await import("./node.browser-CA5eNPFK.js");return{path:s}},__vite__mapDeps([4,1,2,3]));return i.join(e,"credentials",`${r}.json`)},Bc=async()=>{if(!av())return null;const{path:t}=await Fe(async()=>{const{path:s}=await import("./node.browser-CA5eNPFK.js");return{path:s}},__vite__mapDeps([4,1,2,3])),n=I("ANTHROPIC_CONFIG_DIR");if(n)return n;if(sa()["X-Stainless-OS"]==="Windows"){const s=I("APPDATA");if(s)return t.join(s,"Anthropic");const a=I("USERPROFILE");return a?t.join(a,"AppData","Roaming","Anthropic"):null}const r=I("XDG_CONFIG_HOME");if(r)return t.join(r,"anthropic");const i=I("HOME");return i?t.join(i,".config","anthropic"):null},av=()=>{const t=sa()["X-Stainless-Runtime"];return t==="node"||t==="deno"},Ef=async()=>{const t=await Bc();if(!t)return null;const n=I("ANTHROPIC_PROFILE");if(n)return n;const{fs:e,path:r}=await Fe(async()=>{const{fs:s,path:a}=await import("./node.browser-CA5eNPFK.js");return{fs:s,path:a}},__vite__mapDeps([4,1,2,3])),i=r.join(t,"active_config");try{return(await e.promises.readFile(i,"utf-8")).trim()||"default"}catch(s){if(s?.code!=="ENOENT")throw new Error(`failed to read ${i}: ${s}`);return"default"}};function Hh(t){if(!t)throw new P("Identity token file path is empty");return async()=>{const{fs:n}=await Fe(async()=>{const{fs:i}=await import("./node.browser-CA5eNPFK.js");return{fs:i}},__vite__mapDeps([4,1,2,3]));let e;try{e=await n.promises.readFile(t,"utf-8")}catch(i){throw new P(`Failed to read identity token file at ${t}: ${i}`)}const r=e.trim();if(!r)throw new P(`Identity token file at ${t} is empty`);return r}}function ov(t){if(!t)throw new P("Identity token value is empty");return()=>t}function cv(t){return async()=>{mf(t.baseURL);const n=await t.identityTokenProvider();if(n.length>16*1024)throw new D(`Identity token is ${Math.ceil(n.length/1024)} KiB, exceeds the 16 KiB assertion limit`);const e={grant_type:Jw,assertion:n,federation_rule_id:t.federationRuleId,organization_id:t.organizationId};t.serviceAccountId&&(e.service_account_id=t.serviceAccountId),t.workspaceId&&(e.workspace_id=t.workspaceId);const r=`${t.baseURL}${gf}`;let i;try{i=await t.fetch(r,{method:"POST",redirect:"manual",headers:{"Content-Type":"application/json","anthropic-beta":`${wi},${Xw}`,"User-Agent":t.userAgent||`anthropic-sdk-typescript/${Ge} oidcFederationProvider`},body:JSON.stringify(e)})}catch(l){throw new D(`Failed to reach token endpoint ${r}: ${l}`)}const s=i.headers.get("Request-Id");if(!i.ok){const l=await i.text().catch(()=>""),d=Re(l);let _="";throw i.status===401&&(_=` Ensure your federation rule matches your identity token. ${t.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 D(`Token exchange failed with status ${i.status}${s?` (request-id ${s})`:""}: ${d}${_}`,i.status,d,s)}const a=await yf(i,s),c=Number(a.expires_in);if(!Number.isFinite(c))throw new D(`Token endpoint response missing required fields: ${JSON.stringify(Re(a))}`,i.status,Re(a),s);return{token:a.access_token,expiresAt:St()+c}}}function lv(t){return async n=>{const{fs:e}=await Fe(async()=>{const{fs:w}=await import("./node.browser-CA5eNPFK.js");return{fs:w}},__vite__mapDeps([4,1,2,3]));await bf(t.credentialsPath,t.onSafetyWarning);let r;try{r=await e.promises.readFile(t.credentialsPath,"utf-8")}catch(w){throw new D(`Credentials file not found at ${t.credentialsPath}: ${w}`)}let i;try{i=JSON.parse(r)}catch(w){throw new D(`Credentials file at ${t.credentialsPath} is not valid JSON: ${w}`)}const s=i.access_token;if(!s)throw new D(`Credentials file at ${t.credentialsPath} must include 'access_token'`);const a=i.expires_at;if(!n?.forceRefresh&&(a==null||St()<a-$c))return{token:s,expiresAt:a??null};const c=i.refresh_token;if(!t.clientId||!c)throw new D(`Access token at ${t.credentialsPath} has expired and no refresh is available (client_id ${t.clientId?"set":"empty"}, refresh_token ${c?"set":"empty"})`);mf(t.baseURL);const l={grant_type:Yw,refresh_token:c,client_id:t.clientId},d=`${t.baseURL}${gf}`;let _;try{_=await t.fetch(d,{method:"POST",redirect:"manual",headers:{"Content-Type":"application/json","anthropic-beta":wi,"User-Agent":t.userAgent||`anthropic-sdk-typescript/${Ge} userOAuthProvider`},body:JSON.stringify(l)})}catch(w){throw new D(`User OAuth refresh failed to reach token endpoint: ${w}`)}const h=_.headers.get("Request-Id");if(!_.ok){const w=await _.text().catch(()=>"");throw new D(`User OAuth refresh failed (HTTP ${_.status}): ${Re(w)}`,_.status,Re(w),h)}const p=await yf(_,h),f=Number(p.expires_in);if(!Number.isFinite(f))throw new D(`User OAuth refresh response missing or invalid expires_in: ${JSON.stringify(Re(p))}`,_.status,Re(p),h);const b=St()+f,y=p.refresh_token||c;return await wf(t.credentialsPath,{...i,version:vf,type:"oauth_token",access_token:p.access_token,expires_at:b,refresh_token:y}),{token:p.access_token,expiresAt:b}}}function Sf(t,n){const e=t.authentication.credentials_path??null,r=(t.base_url||n.baseURL).replace(/\/+$/,""),i=dv(t,e,r,n),s={};return t.workspace_id&&t.authentication.type==="user_oauth"&&(s["anthropic-workspace-id"]=t.workspace_id),{provider:i,extraHeaders:s,baseURL:t.base_url||void 0}}async function uv(t,n){const e=await iv(n);if(!e)return null;const{config:r,fromFile:i}=e,s=r.authentication.credentials_path||!i?r:{...r,authentication:{...r.authentication,credentials_path:await sv(r,n)??void 0}};return Sf(s,t)}function dv(t,n,e,r){switch(t.authentication.type){case"oidc_federation":{const i=t.authentication,s=hv(i);if(!s)throw new D("oidc_federation config requires an identity token (set authentication.identity_token, ANTHROPIC_IDENTITY_TOKEN_FILE, or ANTHROPIC_IDENTITY_TOKEN)");if(!i.federation_rule_id)throw new D("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(!t.organization_id)throw new D("oidc_federation config requires organization_id (set ANTHROPIC_ORGANIZATION_ID or config.organization_id)");const a=cv({identityTokenProvider:s,federationRuleId:i.federation_rule_id,organizationId:t.organization_id,serviceAccountId:i.service_account_id,workspaceId:t.workspace_id,baseURL:e,fetch:r.fetch,userAgent:r.userAgent});return n?_v(a,n,r.onCacheWriteError,r.onSafetyWarning):a}case"user_oauth":{if(!n)throw new D("user_oauth config requires authentication.credentials_path (or load via a profile so it defaults to <config_dir>/credentials/<profile>.json)");return lv({credentialsPath:n,clientId:t.authentication.client_id,baseURL:e,fetch:r.fetch,userAgent:r.userAgent,onSafetyWarning:r.onSafetyWarning})}default:{const i=t.authentication.type;throw new D(`authentication.type "${i}" is not a known authentication type`)}}}function hv(t){if(t.identity_token){const r=t.identity_token.source;if(r!=="file")throw new D(`identity_token.source "${r}" is not supported by this SDK version (only "file")`);if(!t.identity_token.path)throw new D('identity_token.source "file" requires a non-empty path');return Hh(t.identity_token.path)}const n=I("ANTHROPIC_IDENTITY_TOKEN_FILE");if(n)return Hh(n);const e=I("ANTHROPIC_IDENTITY_TOKEN");return e?ov(e):null}function _v(t,n,e,r){return async i=>{const{fs:s}=await Fe(async()=>{const{fs:l}=await import("./node.browser-CA5eNPFK.js");return{fs:l}},__vite__mapDeps([4,1,2,3]));await bf(n,r);let a;try{const l=await s.promises.readFile(n,"utf-8");a=JSON.parse(l);const d=a?.access_token;if(d&&!i?.forceRefresh){const _=a?.expires_at;if(_==null||St()<_-$c)return{token:d,expiresAt:_??null}}}catch(l){l?.code!=="ENOENT"&&!(l instanceof SyntaxError)&&e?.(l)}const c=await t(i);try{await wf(n,{...a??{},version:vf,type:"oauth_token",access_token:c.token,expires_at:c.expiresAt})}catch(l){e?.(l)}return c}}const xf=new WeakSet;function Tf(t){return typeof t=="object"&&t!==null&&xf.has(t)}function pv(t){const n=new Set;for(;typeof t=="object"&&t!==null&&!n.has(t);){if(n.add(t),Tf(t)||Tt(t)||t instanceof At||t instanceof Zg)return!0;t=t.cause}return!1}function Kh(t,n,e,r){return async(i,s={})=>{if(n.length===0)return t.call(void 0,i,s);const a=s.headers instanceof Headers?s.headers:new Headers(s.headers),c=await gv(t,n,e,r)({...s,headers:a,url:typeof i=="string"?i:i instanceof URL?i.href:i.url});if(c.bodyUsed||c.body?.locked)throw new P("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 fv(t,n){const e=new WeakMap;return{options:t,logger:n?B(n):j_(),parse(r){if(t?.stream&&r.ok)return Dh(r,t,n);let i=e.get(r);return i||(i=Dh(r,t,n),e.set(r,i)),i}}}async function Dh(t,n,e){if(t.bodyUsed||t.body?.locked)throw new P("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&&t.ok)return Je.fromSSEResponse(t.clone(),new AbortController,e);if(t.status===204)return null;if(n?.__binaryResponse)return t;const i=t.headers.get("content-type")?.split(";")[0]?.trim();return i?.includes("application/json")||i?.endsWith("+json")?t.headers.get("content-length")==="0"?void 0:Pi(await t.clone().json(),t):await t.clone().text()}function gv(t,n,e,r){let i=async({url:a,...c})=>{try{return await t.call(void 0,a,c)}catch(l){const d=jr(l);throw xf.add(d),d}};const s=fv(e,r);for(let a=n.length-1;a>=0;a--){const c=n[a],l=i;i=async d=>c(d,l,s)}return i}const Af=t=>t!=null&&typeof t=="object"&&typeof t.size=="number"&&typeof t.type=="string"&&typeof t.text=="function"&&typeof t.slice=="function"&&typeof t.arrayBuffer=="function",mv=t=>t!=null&&typeof t=="object"&&typeof t.name=="string"&&typeof t.lastModified=="number"&&Af(t),yv=t=>t!=null&&typeof t=="object"&&typeof t.url=="string"&&typeof t.blob=="function";async function bv(t,n,e){if(rp(),t=await t,n||(n=t instanceof File?t.name:ri(t,!0)),mv(t))return t instanceof File&&n==null&&e==null?t:Zt([await t.arrayBuffer()],n??t.name,{type:t.type,lastModified:t.lastModified,...e});if(yv(t)){const i=await t.blob();return n||(n=new URL(t.url).pathname.split(/[\\/]/).pop()),Zt(await Gs(i),n,e)}const r=await Gs(t);if(!e?.type){const i=r.find(s=>typeof s=="object"&&"type"in s&&s.type);typeof i=="string"&&(e={...e,type:i})}return Zt(r,n,e)}async function Gs(t){let n=[];if(typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer)n.push(t);else if(Af(t))n.push(t instanceof Blob?t:await t.arrayBuffer());else if(ma(t))for await(const e of t)n.push(...await Gs(e));else{const e=t?.constructor?.name;throw new Error(`Unexpected data type: ${typeof t}${e?`; constructor: ${e}`:""}${wv(t)}`)}return n}function wv(t){return typeof t!="object"||t===null?"":`; props: [${Object.getOwnPropertyNames(t).map(e=>`"${e}"`).join(", ")}]`}class Gh extends k{retrieve(n,e={},r){const{workspace_id:i}=e??{};return this._client.get(m`/v1/models/${n}`,{...r,headers:g([{...i!=null?{"anthropic-workspace-id":i}:void 0},r?.headers]),__span:u(this._client,"anthropic.models.retrieve",r,{route:"/v1/models/{model_id}",attributes:{"anthropic.model.id":n}})})}list(n={},e){const{workspace_id:r,...i}=n??{};return this._client.getAPIList("/v1/models",de,{query:i,...e,headers:g([{...r!=null?{"anthropic-workspace-id":r}:void 0},e?.headers]),__span:u(this._client,"anthropic.models.list",e,{route:"/v1/models",queryParams:["after_id","before_id","lifecycle","limit"]})})}}var vs,ks,Qn,Yt,yt,Vh;let Jh=!1;var vv=(()=>{class t{get credentials(){return this._authState.provider}get openTelemetry(){return o(this,yt,"f")}_instrumentationScope(){return{version:Ge}}constructor({baseURL:e=I("ANTHROPIC_BASE_URL"),apiKey:r,authToken:i,webhookKey:s=I("ANTHROPIC_WEBHOOK_SIGNING_KEY")??null,...a}={}){vs.add(this),this._requestAuthFlags=new WeakMap,Qn.set(this,void 0),Yt.set(this,void 0),yt.set(this,void 0),this._genAIProviderName="anthropic",this._supportsMessageThreads=!1;const c={apiKey:r,authToken:i,...a},l=Ot.filter(w=>c[w]!=null);if(l.length>1){const w=E=>E.map(S=>`\`${S}\``).join(", ");throw new TypeError(`Pass at most one of ${w(Ot)}. Received ${w(l)}.`)}const[d]=l,_=d!=null?null:{apiKey:r===void 0?I("ANTHROPIC_API_KEY"):void 0,authToken:i===void 0?I("ANTHROPIC_AUTH_TOKEN"):void 0},h=d!=null?{type:d,value:c[d]}:_?.apiKey!=null?{type:"apiKey",value:_.apiKey}:_?.authToken!=null?{type:"authToken",value:_.authToken}:{type:"defaultChain"},p={apiKey:h.type==="apiKey"?h.value:null,authToken:h.type==="authToken"?h.value:null,webhookKey:s,...a,baseURL:e||"https://api.anthropic.com"};if(!p.dangerouslyAllowBrowser&&im())throw new P(`It looks like you're running in a browser-like environment.
|
|
60
|
+
Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`),Yp.includes(a.model)&&a.thinking&&a.thinking.type==="enabled"&&console.warn(`Using Claude with ${a.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`);let c=r?.timeout??this._client._options.timeout;if(!a.stream&&c==null){const h=Jp[a.model]??void 0;c=this._client.calculateNonstreamingTimeout(a.max_tokens,h)}const l={body:a,timeout:c??6e5,...r,headers:_f(e,r),stream:e.stream??!1},d=this._client._tracer&&u(this._client,"anthropic.messages.create",r,Oi(this._client,l));up(this._client,d,a);const _=this._client.post("/v1/messages",{...l,__span:d});return d?_._thenUnwrap(h=>(dp(this._client,d,a,h),h)):_}parse(e,r){return this.create(e,r).then(i=>ff(i,e,{logger:this._client.logger??console}))}stream(e,r){const i=e;return Gw.createMessage(this,i,r,{logger:this._client.logger??console,client:this._client})}countTokens(e,r){const{user_profile_id:i,workspace_id:s,...a}=e,c={body:a,...r,headers:g([{...i!=null?{"anthropic-user-profile-id":i}:void 0,...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers])};return this._client.post("/v1/messages/count_tokens",{...c,__span:u(this._client,"anthropic.messages.count_tokens",r,{route:"/v1/messages/count_tokens",request:c})})}}return t.AvailableToolsLimitExceededError=jo,t.CompactionBlockAmbiguousError=Ho,t.CompactionBlockMisplacedError=Ko,t.CompactionContentMismatchError=Do,t.CompactionIncompleteTurnError=Go,t.CompactionNothingToSummarizeError=Vo,t.CompactionSignatureInvalidError=Jo,t.CompactionTooManyToolReferencesError=Yo,t.CompactionToolChangesMismatchError=Xo,t.ImageDimensionsTooLargeError=Qo,t.ThreadAlreadyContinuedError=Zo,t.ThreadContinueInFlightError=ec,t.ThreadFingerprintMismatchError=tc,t.ThreadUnsupportedRequestError=rc,t.ToolNameConflictError=nc,t.ToolReferenceUnresolvedError=ic,t.ThreadNotFoundError=sc,t.CompactionUnavailableError=ac,t.Batches=nh,t})(),oc=(()=>{class t extends R{}return t._errorName="OrgAPIKeyLimitExceededError",t})(),cc=(()=>{class t extends R{}return t._errorName="WorkspaceAPIKeyLimitExceededError",t})(),sh=(()=>{class t extends k{retrieve(e,r){return this._client.get(m`/v1/organizations/api_keys/${e}`,{...r,__span:u(this._client,"anthropic.organization.api_keys.retrieve",r,{route:"/v1/organizations/api_keys/{api_key_id}",attributes:{"anthropic.organization.api_key.id":e}})})}update(e,r,i){return this._client.post(m`/v1/organizations/api_keys/${e}`,{body:r,...i,__span:u(this._client,"anthropic.organization.api_keys.update",i,{route:"/v1/organizations/api_keys/{api_key_id}",attributes:{"anthropic.organization.api_key.id":e}})})}list(e={},r){return this._client.getAPIList("/v1/organizations/api_keys",de,{query:e,...r,__span:u(this._client,"anthropic.organization.api_keys.list",r,{route:"/v1/organizations/api_keys",queryParams:["after_id","before_id","created_by_user_id","limit","status","workspace_id"]})})}}return t.OrgAPIKeyLimitExceededError=oc,t.WorkspaceAPIKeyLimitExceededError=cc,t})(),lc=(()=>{class t extends R{}return t._errorName="ExternalKeyInWorkspacePolicyError",t})(),uc=(()=>{class t extends R{}return t._errorName="ExternalKeyValidationFailedError",t})(),dc=(()=>{class t extends R{}return t._errorName="ExternalKeyValidationTimedOutError",t})(),hc=(()=>{class t extends ue{}return t._errorName="ExternalKeyChangedError",t})(),ah=(()=>{class t extends k{create(e,r){return this._client.post("/v1/organizations/external_keys",{body:e,...r,__span:u(this._client,"anthropic.organization.external_keys.create",r,{route:"/v1/organizations/external_keys",createdIDAttribute:"anthropic.organization.external_key.id"})})}retrieve(e,r){return this._client.get(m`/v1/organizations/external_keys/${e}`,{...r,__span:u(this._client,"anthropic.organization.external_keys.retrieve",r,{route:"/v1/organizations/external_keys/{external_key_id}",attributes:{"anthropic.organization.external_key.id":e}})})}update(e,r,i){return this._client.post(m`/v1/organizations/external_keys/${e}`,{body:r,...i,__span:u(this._client,"anthropic.organization.external_keys.update",i,{route:"/v1/organizations/external_keys/{external_key_id}",attributes:{"anthropic.organization.external_key.id":e}})})}list(e={},r){return this._client.getAPIList("/v1/organizations/external_keys",z,{query:e,...r,__span:u(this._client,"anthropic.organization.external_keys.list",r,{route:"/v1/organizations/external_keys",queryParams:["limit","page"]})})}delete(e,r){return this._client.delete(m`/v1/organizations/external_keys/${e}`,{...r,__span:u(this._client,"anthropic.organization.external_keys.delete",r,{route:"/v1/organizations/external_keys/{external_key_id}",attributes:{"anthropic.organization.external_key.id":e}})})}validate(e,r){return this._client.post(m`/v1/organizations/external_keys/${e}/validate`,{...r,__span:u(this._client,"anthropic.organization.external_keys.validate",r,{route:"/v1/organizations/external_keys/{external_key_id}/validate",attributes:{"anthropic.organization.external_key.id":e}})})}}return t.ExternalKeyInWorkspacePolicyError=lc,t.ExternalKeyValidationFailedError=uc,t.ExternalKeyValidationTimedOutError=dc,t.ExternalKeyChangedError=hc,t})(),_c=(()=>{class t extends R{}return t._errorName="AlreadyMemberError",t})(),pc=(()=>{class t extends R{}return t._errorName="CannotInviteEmailsWithUnverifiedDomainsError",t})(),fc=(()=>{class t extends R{}return t._errorName="EmailDomainNotAllowedError",t})(),gc=(()=>{class t extends R{}return t._errorName="InviteAlreadyExistsError",t})(),oh=(()=>{class t extends k{create(e,r){return this._client.post("/v1/organizations/invites",{body:e,...r,__span:u(this._client,"anthropic.organization.invites.create",r,{route:"/v1/organizations/invites",createdIDAttribute:"anthropic.organization.invite.id"})})}retrieve(e,r){return this._client.get(m`/v1/organizations/invites/${e}`,{...r,__span:u(this._client,"anthropic.organization.invites.retrieve",r,{route:"/v1/organizations/invites/{invite_id}",attributes:{"anthropic.organization.invite.id":e}})})}list(e={},r){return this._client.getAPIList("/v1/organizations/invites",de,{query:e,...r,__span:u(this._client,"anthropic.organization.invites.list",r,{route:"/v1/organizations/invites",queryParams:["after_id","before_id","email","limit","roles","statuses"]})})}delete(e,r){return this._client.delete(m`/v1/organizations/invites/${e}`,{...r,__span:u(this._client,"anthropic.organization.invites.delete",r,{route:"/v1/organizations/invites/{invite_id}",attributes:{"anthropic.organization.invite.id":e}})})}}return t.AlreadyMemberError=_c,t.CannotInviteEmailsWithUnverifiedDomainsError=pc,t.EmailDomainNotAllowedError=fc,t.InviteAlreadyExistsError=gc,t})();class ch extends k{retrieve(n){return this._client.get("/v1/organizations/compliance_settings",{...n,__span:u(this._client,"anthropic.organization.compliance_settings.retrieve",n,{route:"/v1/organizations/compliance_settings"})})}update(n,e){return this._client.post("/v1/organizations/compliance_settings",{body:n,...e,__span:u(this._client,"anthropic.organization.compliance_settings.update",e,{route:"/v1/organizations/compliance_settings"})})}}let lh=class extends k{list(n={},e){return this._client.getAPIList("/v1/organizations/rate_limits",z,{query:n,...e,__span:u(this._client,"anthropic.organization.rate_limits.list",e,{route:"/v1/organizations/rate_limits",queryParams:["group_type","limit","model","page"]})})}};var mc=(()=>{class t extends R{}return t._errorName="CannotRemoveLastMemberError",t})(),uh=(()=>{class t extends k{retrieve(e,r){return this._client.get(m`/v1/organizations/users/${e}`,{...r,__span:u(this._client,"anthropic.organization.users.retrieve",r,{route:"/v1/organizations/users/{user_id}",attributes:{"anthropic.organization.user.id":e}})})}update(e,r,i){return this._client.post(m`/v1/organizations/users/${e}`,{body:r,...i,__span:u(this._client,"anthropic.organization.users.update",i,{route:"/v1/organizations/users/{user_id}",attributes:{"anthropic.organization.user.id":e}})})}list(e={},r){return this._client.getAPIList("/v1/organizations/users",de,{query:e,...r,__span:u(this._client,"anthropic.organization.users.list",r,{route:"/v1/organizations/users",queryParams:["after_id","before_id","email","limit","roles"]})})}remove(e,r){return this._client.delete(m`/v1/organizations/users/${e}`,{...r,__span:u(this._client,"anthropic.organization.users.remove",r,{route:"/v1/organizations/users/{user_id}",attributes:{"anthropic.organization.user.id":e}})})}}return t.CannotRemoveLastMemberError=mc,t})();class dh extends k{list(n,e){return this._client.getAPIList("/v1/organizations/analytics/artifacts",z,{query:n,...e,__span:u(this._client,"anthropic.organization.analytics.artifacts.list",e,{route:"/v1/organizations/analytics/artifacts",queryParams:["date","filter","group_by","limit","page"]})})}}class hh extends k{list(n={},e){return this._client.getAPIList("/v1/organizations/analytics/connectors",z,{query:n,...e,__span:u(this._client,"anthropic.organization.analytics.connectors.list",e,{route:"/v1/organizations/analytics/connectors",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"],contentQueryParams:["filter"]})})}}class _h extends k{list(n={},e){return this._client.getAPIList("/v1/organizations/analytics/plugins",z,{query:n,...e,__span:u(this._client,"anthropic.organization.analytics.plugins.list",e,{route:"/v1/organizations/analytics/plugins",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"],contentQueryParams:["filter"]})})}}let ph=class extends k{list(n={},e){return this._client.getAPIList("/v1/organizations/analytics/skills",z,{query:n,...e,__span:u(this._client,"anthropic.organization.analytics.skills.list",e,{route:"/v1/organizations/analytics/skills",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"],contentQueryParams:["filter"]})})}};class fh extends k{list(n,e){return this._client.getAPIList("/v1/organizations/analytics/summaries",z,{query:n,...e,__span:u(this._client,"anthropic.organization.analytics.summaries.list",e,{route:"/v1/organizations/analytics/summaries",queryParams:["ending_date","filter","limit","page","starting_date"]})})}}class gh extends k{list(n={},e){return this._client.getAPIList("/v1/organizations/analytics/users",z,{query:n,...e,__span:u(this._client,"anthropic.organization.analytics.users.list",e,{route:"/v1/organizations/analytics/users",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"],contentQueryParams:["page"]})})}}class mh extends k{list(n={},e){return this._client.getAPIList("/v1/organizations/analytics/apps/chat/projects",z,{query:n,...e,__span:u(this._client,"anthropic.organization.analytics.apps.chat.projects.list",e,{route:"/v1/organizations/analytics/apps/chat/projects",queryParams:["date","ending_date","filter","group_by","limit","order","order_by","page","starting_date"]})})}}var yh=(()=>{class t extends k{constructor(){super(...arguments),this.projects=new mh(this._client)}}return t.Projects=mh,t})(),bh=(()=>{class t extends k{constructor(){super(...arguments),this.chat=new yh(this._client)}}return t.Chat=yh,t})(),wh=(()=>{class t extends k{constructor(){super(...arguments),this.summaries=new fh(this._client),this.users=new gh(this._client),this.apps=new bh(this._client),this.connectors=new hh(this._client),this.plugins=new _h(this._client),this.skills=new ph(this._client),this.artifacts=new dh(this._client)}}return t.Summaries=fh,t.Users=gh,t.Apps=bh,t.Connectors=hh,t.Plugins=_h,t.Skills=ph,t.Artifacts=dh,t})();class vh extends k{create(n,e){return this._client.post("/v1/organizations/federation_issuers",{body:n,...e,__span:u(this._client,"anthropic.organization.federation.issuers.create",e,{route:"/v1/organizations/federation_issuers",createdIDAttribute:"anthropic.organization.federation_issuer.id"})})}retrieve(n,e){return this._client.get(m`/v1/organizations/federation_issuers/${n}`,{...e,__span:u(this._client,"anthropic.organization.federation.issuers.retrieve",e,{route:"/v1/organizations/federation_issuers/{federation_issuer_id}",attributes:{"anthropic.organization.federation_issuer.id":n}})})}update(n,e,r){return this._client.post(m`/v1/organizations/federation_issuers/${n}`,{body:e,...r,__span:u(this._client,"anthropic.organization.federation.issuers.update",r,{route:"/v1/organizations/federation_issuers/{federation_issuer_id}",attributes:{"anthropic.organization.federation_issuer.id":n}})})}list(n={},e){return this._client.getAPIList("/v1/organizations/federation_issuers",z,{query:n,...e,__span:u(this._client,"anthropic.organization.federation.issuers.list",e,{route:"/v1/organizations/federation_issuers",queryParams:["include_archived","limit","page"]})})}archive(n,e){return this._client.post(m`/v1/organizations/federation_issuers/${n}/archive`,{...e,__span:u(this._client,"anthropic.organization.federation.issuers.archive",e,{route:"/v1/organizations/federation_issuers/{federation_issuer_id}/archive",attributes:{"anthropic.organization.federation_issuer.id":n}})})}}let kh=class extends k{list(n,e={},r){return this._client.getAPIList(m`/v1/organizations/federation_rules/${n}/workspaces`,z,{query:e,...r,__span:u(this._client,"anthropic.organization.federation.rules.workspaces.list",r,{route:"/v1/organizations/federation_rules/{federation_rule_id}/workspaces",queryParams:["limit","page"],attributes:{"anthropic.organization.federation_rule.id":n}})})}add(n,e,r){return this._client.post(m`/v1/organizations/federation_rules/${n}/workspaces`,{body:e,...r,__span:u(this._client,"anthropic.organization.federation.rules.workspaces.add",r,{route:"/v1/organizations/federation_rules/{federation_rule_id}/workspaces",attributes:{"anthropic.organization.federation_rule.id":n},createdIDAttribute:"anthropic.organization.federation_rule.workspace.id",createdIDField:"workspace_id"})})}remove(n,e,r){const{federation_rule_id:i}=e;return this._client.delete(m`/v1/organizations/federation_rules/${i}/workspaces/${n}`,{...r,__span:u(this._client,"anthropic.organization.federation.rules.workspaces.remove",r,{route:"/v1/organizations/federation_rules/{federation_rule_id}/workspaces/{workspace_id}",attributes:{"anthropic.organization.federation_rule.id":i,"anthropic.organization.federation_rule.workspace.id":n}})})}};var Eh=(()=>{class t extends k{constructor(){super(...arguments),this.workspaces=new kh(this._client)}create(e,r){return this._client.post("/v1/organizations/federation_rules",{body:e,...r,__span:u(this._client,"anthropic.organization.federation.rules.create",r,{route:"/v1/organizations/federation_rules",createdIDAttribute:"anthropic.organization.federation_rule.id"})})}retrieve(e,r){return this._client.get(m`/v1/organizations/federation_rules/${e}`,{...r,__span:u(this._client,"anthropic.organization.federation.rules.retrieve",r,{route:"/v1/organizations/federation_rules/{federation_rule_id}",attributes:{"anthropic.organization.federation_rule.id":e}})})}update(e,r,i){return this._client.post(m`/v1/organizations/federation_rules/${e}`,{body:r,...i,__span:u(this._client,"anthropic.organization.federation.rules.update",i,{route:"/v1/organizations/federation_rules/{federation_rule_id}",attributes:{"anthropic.organization.federation_rule.id":e}})})}list(e={},r){return this._client.getAPIList("/v1/organizations/federation_rules",z,{query:e,...r,__span:u(this._client,"anthropic.organization.federation.rules.list",r,{route:"/v1/organizations/federation_rules",queryParams:["include_archived","issuer_id","limit","page"]})})}archive(e,r){return this._client.post(m`/v1/organizations/federation_rules/${e}/archive`,{...r,__span:u(this._client,"anthropic.organization.federation.rules.archive",r,{route:"/v1/organizations/federation_rules/{federation_rule_id}/archive",attributes:{"anthropic.organization.federation_rule.id":e}})})}}return t.Workspaces=kh,t})(),Sh=(()=>{class t extends k{constructor(){super(...arguments),this.issuers=new vh(this._client),this.rules=new Eh(this._client)}}return t.Issuers=vh,t.Rules=Eh,t})();let xh=class extends k{list(n,e={},r){return this._client.getAPIList(m`/v1/organizations/rbac_groups/${n}/members`,z,{query:e,...r,__span:u(this._client,"anthropic.organization.rbac_groups.members.list",r,{route:"/v1/organizations/rbac_groups/{rbac_group_id}/members",queryParams:["limit","page"],attributes:{"anthropic.organization.rbac_group.id":n}})})}add(n,e,r){return this._client.post(m`/v1/organizations/rbac_groups/${n}/members`,{body:e,...r,__span:u(this._client,"anthropic.organization.rbac_groups.members.add",r,{route:"/v1/organizations/rbac_groups/{rbac_group_id}/members",attributes:{"anthropic.organization.rbac_group.id":n},createdIDAttribute:"anthropic.organization.rbac_group.member.id",createdIDField:"user_id"})})}remove(n,e,r){const{rbac_group_id:i}=e;return this._client.delete(m`/v1/organizations/rbac_groups/${i}/members/${n}`,{...r,__span:u(this._client,"anthropic.organization.rbac_groups.members.remove",r,{route:"/v1/organizations/rbac_groups/{rbac_group_id}/members/{user_id}",attributes:{"anthropic.organization.rbac_group.id":i,"anthropic.organization.rbac_group.member.id":n}})})}};var yc=(()=>{class t extends R{}return t._errorName="RBACGroupGrantsOwnerAccessError",t})(),bc=(()=>{class t extends R{}return t._errorName="RBACGroupOwnerAccessUnconfirmedError",t})(),Th=(()=>{class t extends k{constructor(){super(...arguments),this.members=new xh(this._client)}create(e,r){return this._client.post("/v1/organizations/rbac_groups",{body:e,...r,__span:u(this._client,"anthropic.organization.rbac_groups.create",r,{route:"/v1/organizations/rbac_groups",createdIDAttribute:"anthropic.organization.rbac_group.id"})})}retrieve(e,r){return this._client.get(m`/v1/organizations/rbac_groups/${e}`,{...r,__span:u(this._client,"anthropic.organization.rbac_groups.retrieve",r,{route:"/v1/organizations/rbac_groups/{rbac_group_id}",attributes:{"anthropic.organization.rbac_group.id":e}})})}update(e,r,i){return this._client.post(m`/v1/organizations/rbac_groups/${e}`,{body:r,...i,__span:u(this._client,"anthropic.organization.rbac_groups.update",i,{route:"/v1/organizations/rbac_groups/{rbac_group_id}",attributes:{"anthropic.organization.rbac_group.id":e}})})}list(e={},r){return this._client.getAPIList("/v1/organizations/rbac_groups",z,{query:e,...r,__span:u(this._client,"anthropic.organization.rbac_groups.list",r,{route:"/v1/organizations/rbac_groups",queryParams:["limit","page"]})})}delete(e,r){return this._client.delete(m`/v1/organizations/rbac_groups/${e}`,{...r,__span:u(this._client,"anthropic.organization.rbac_groups.delete",r,{route:"/v1/organizations/rbac_groups/{rbac_group_id}",attributes:{"anthropic.organization.rbac_group.id":e}})})}}return t.RBACGroupGrantsOwnerAccessError=yc,t.RBACGroupOwnerAccessUnconfirmedError=bc,t.Members=xh,t})();class Ah extends k{list(n,e={},r){return this._client.getAPIList(m`/v1/organizations/rbac_roles/${n}/permissions`,z,{query:e,...r,__span:u(this._client,"anthropic.organization.rbac_roles.permissions.list",r,{route:"/v1/organizations/rbac_roles/{rbac_role_id}/permissions",queryParams:["limit","page"],attributes:{"anthropic.organization.rbac_role.id":n}})})}}var Rh=(()=>{class t extends k{constructor(){super(...arguments),this.permissions=new Ah(this._client)}retrieve(e,r){return this._client.get(m`/v1/organizations/rbac_roles/${e}`,{...r,__span:u(this._client,"anthropic.organization.rbac_roles.retrieve",r,{route:"/v1/organizations/rbac_roles/{rbac_role_id}",attributes:{"anthropic.organization.rbac_role.id":e}})})}list(e={},r){return this._client.getAPIList("/v1/organizations/rbac_roles",z,{query:e,...r,__span:u(this._client,"anthropic.organization.rbac_roles.list",r,{route:"/v1/organizations/rbac_roles",queryParams:["limit","page"]})})}}return t.Permissions=Ah,t})();let zh=class extends k{list(n,e={},r){return this._client.getAPIList(m`/v1/organizations/service_accounts/${n}/workspaces`,z,{query:e,...r,__span:u(this._client,"anthropic.organization.service_accounts.workspaces.list",r,{route:"/v1/organizations/service_accounts/{service_account_id}/workspaces",queryParams:["limit","page"],attributes:{"anthropic.organization.service_account.id":n}})})}add(n,e,r){return this._client.post(m`/v1/organizations/service_accounts/${n}/workspaces`,{body:e,...r,__span:u(this._client,"anthropic.organization.service_accounts.workspaces.add",r,{route:"/v1/organizations/service_accounts/{service_account_id}/workspaces",attributes:{"anthropic.organization.service_account.id":n},createdIDAttribute:"anthropic.organization.service_account.workspace.id",createdIDField:"workspace_id"})})}remove(n,e,r){const{service_account_id:i}=e;return this._client.delete(m`/v1/organizations/service_accounts/${i}/workspaces/${n}`,{...r,__span:u(this._client,"anthropic.organization.service_accounts.workspaces.remove",r,{route:"/v1/organizations/service_accounts/{service_account_id}/workspaces/{workspace_id}",attributes:{"anthropic.organization.service_account.id":i,"anthropic.organization.service_account.workspace.id":n}})})}};var Ph=(()=>{class t extends k{constructor(){super(...arguments),this.workspaces=new zh(this._client)}create(e,r){return this._client.post("/v1/organizations/service_accounts",{body:e,...r,__span:u(this._client,"anthropic.organization.service_accounts.create",r,{route:"/v1/organizations/service_accounts",createdIDAttribute:"anthropic.organization.service_account.id"})})}retrieve(e,r){return this._client.get(m`/v1/organizations/service_accounts/${e}`,{...r,__span:u(this._client,"anthropic.organization.service_accounts.retrieve",r,{route:"/v1/organizations/service_accounts/{service_account_id}",attributes:{"anthropic.organization.service_account.id":e}})})}update(e,r,i){return this._client.post(m`/v1/organizations/service_accounts/${e}`,{body:r,...i,__span:u(this._client,"anthropic.organization.service_accounts.update",i,{route:"/v1/organizations/service_accounts/{service_account_id}",attributes:{"anthropic.organization.service_account.id":e}})})}list(e={},r){return this._client.getAPIList("/v1/organizations/service_accounts",z,{query:e,...r,__span:u(this._client,"anthropic.organization.service_accounts.list",r,{route:"/v1/organizations/service_accounts",queryParams:["include_archived","limit","page"]})})}archive(e,r){return this._client.post(m`/v1/organizations/service_accounts/${e}/archive`,{...r,__span:u(this._client,"anthropic.organization.service_accounts.archive",r,{route:"/v1/organizations/service_accounts/{service_account_id}/archive",attributes:{"anthropic.organization.service_account.id":e}})})}}return t.Workspaces=zh,t})();class Ch extends k{list(n={},e){return this._client.getAPIList("/v1/organizations/spend_limits/effective",z,{query:n,...e,__span:u(this._client,"anthropic.organization.spend_limits.effective.list",e,{route:"/v1/organizations/spend_limits/effective",queryParams:["limit","page","period","user_ids"]})})}}class Oh extends k{retrieve(n,e){return this._client.get(m`/v1/organizations/spend_limit_increase_requests/${n}`,{...e,__span:u(this._client,"anthropic.organization.spend_limits.increase_requests.retrieve",e,{route:"/v1/organizations/spend_limit_increase_requests/{spend_limit_increase_request_id}",attributes:{"anthropic.organization.spend_limit_increase_request.id":n}})})}list(n={},e){return this._client.getAPIList("/v1/organizations/spend_limit_increase_requests",z,{query:n,...e,__span:u(this._client,"anthropic.organization.spend_limits.increase_requests.list",e,{route:"/v1/organizations/spend_limit_increase_requests",queryParams:["actor_ids","limit","page","status"]})})}approve(n,e,r){return this._client.post(m`/v1/organizations/spend_limit_increase_requests/${n}/approve`,{body:e,...r,__span:u(this._client,"anthropic.organization.spend_limits.increase_requests.approve",r,{route:"/v1/organizations/spend_limit_increase_requests/{spend_limit_increase_request_id}/approve",attributes:{"anthropic.organization.spend_limit_increase_request.id":n}})})}deny(n,e,r){return this._client.post(m`/v1/organizations/spend_limit_increase_requests/${n}/deny`,{body:e,...r,__span:u(this._client,"anthropic.organization.spend_limits.increase_requests.deny",r,{route:"/v1/organizations/spend_limit_increase_requests/{spend_limit_increase_request_id}/deny",attributes:{"anthropic.organization.spend_limit_increase_request.id":n}})})}}var Nh=(()=>{class t extends k{constructor(){super(...arguments),this.effective=new Ch(this._client),this.increaseRequests=new Oh(this._client)}}return t.Effective=Ch,t.IncreaseRequests=Oh,t})();class Mh extends k{retrieve(n,e,r){const{workspace_id:i}=e;return this._client.get(m`/v1/organizations/workspaces/${i}/members/${n}`,{...r,__span:u(this._client,"anthropic.organization.workspaces.members.retrieve",r,{route:"/v1/organizations/workspaces/{workspace_id}/members/{user_id}",attributes:{"anthropic.organization.workspace.id":i,"anthropic.organization.workspace.member.id":n}})})}update(n,e,r){const{workspace_id:i,...s}=e;return this._client.post(m`/v1/organizations/workspaces/${i}/members/${n}`,{body:s,...r,__span:u(this._client,"anthropic.organization.workspaces.members.update",r,{route:"/v1/organizations/workspaces/{workspace_id}/members/{user_id}",attributes:{"anthropic.organization.workspace.id":i,"anthropic.organization.workspace.member.id":n}})})}list(n,e={},r){return this._client.getAPIList(m`/v1/organizations/workspaces/${n}/members`,de,{query:e,...r,__span:u(this._client,"anthropic.organization.workspaces.members.list",r,{route:"/v1/organizations/workspaces/{workspace_id}/members",queryParams:["after_id","before_id","limit"],attributes:{"anthropic.organization.workspace.id":n}})})}add(n,e,r){return this._client.post(m`/v1/organizations/workspaces/${n}/members`,{body:e,...r,__span:u(this._client,"anthropic.organization.workspaces.members.add",r,{route:"/v1/organizations/workspaces/{workspace_id}/members",attributes:{"anthropic.organization.workspace.id":n},createdIDAttribute:"anthropic.organization.workspace.member.id",createdIDField:"user_id"})})}remove(n,e,r){const{workspace_id:i}=e;return this._client.delete(m`/v1/organizations/workspaces/${i}/members/${n}`,{...r,__span:u(this._client,"anthropic.organization.workspaces.members.remove",r,{route:"/v1/organizations/workspaces/{workspace_id}/members/{user_id}",attributes:{"anthropic.organization.workspace.id":i,"anthropic.organization.workspace.member.id":n}})})}}class $h extends k{update(n,e,r){const{workspace_id:i,...s}=e;return this._client.post(m`/v1/organizations/workspaces/${i}/rate_limits/${n}`,{body:s,...r,__span:u(this._client,"anthropic.organization.workspaces.rate_limits.update",r,{route:"/v1/organizations/workspaces/{workspace_id}/rate_limits/{rate_limit_id}",attributes:{"anthropic.organization.workspace.id":i,"anthropic.organization.workspace.rate_limit.id":n}})})}list(n,e={},r){return this._client.getAPIList(m`/v1/organizations/workspaces/${n}/rate_limits`,z,{query:e,...r,__span:u(this._client,"anthropic.organization.workspaces.rate_limits.list",r,{route:"/v1/organizations/workspaces/{workspace_id}/rate_limits",queryParams:["group_type","include_inherited","limit","page"],attributes:{"anthropic.organization.workspace.id":n}})})}}class Bh extends k{retrieve(n,e,r){const{workspace_id:i}=e;return this._client.get(m`/v1/organizations/workspaces/${i}/service_accounts/${n}`,{...r,__span:u(this._client,"anthropic.organization.workspaces.service_accounts.retrieve",r,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id}",attributes:{"anthropic.organization.workspace.id":i,"anthropic.organization.workspace.service_account.id":n}})})}update(n,e,r){const{workspace_id:i,...s}=e;return this._client.post(m`/v1/organizations/workspaces/${i}/service_accounts/${n}`,{body:s,...r,__span:u(this._client,"anthropic.organization.workspaces.service_accounts.update",r,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id}",attributes:{"anthropic.organization.workspace.id":i,"anthropic.organization.workspace.service_account.id":n}})})}list(n,e={},r){return this._client.getAPIList(m`/v1/organizations/workspaces/${n}/service_accounts`,z,{query:e,...r,__span:u(this._client,"anthropic.organization.workspaces.service_accounts.list",r,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts",queryParams:["limit","page"],attributes:{"anthropic.organization.workspace.id":n}})})}add(n,e,r){return this._client.post(m`/v1/organizations/workspaces/${n}/service_accounts`,{body:e,...r,__span:u(this._client,"anthropic.organization.workspaces.service_accounts.add",r,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts",attributes:{"anthropic.organization.workspace.id":n},createdIDAttribute:"anthropic.organization.workspace.service_account.id",createdIDField:"service_account_id"})})}remove(n,e,r){const{workspace_id:i}=e;return this._client.delete(m`/v1/organizations/workspaces/${i}/service_accounts/${n}`,{...r,__span:u(this._client,"anthropic.organization.workspaces.service_accounts.remove",r,{route:"/v1/organizations/workspaces/{workspace_id}/service_accounts/{service_account_id}",attributes:{"anthropic.organization.workspace.id":i,"anthropic.organization.workspace.service_account.id":n}})})}}var wc=(()=>{class t extends R{}return t._errorName="KeyProfileMismatchError",t})(),vc=(()=>{class t extends R{}return t._errorName="StorageProfileMismatchError",t})(),kc=(()=>{class t extends R{}return t._errorName="WorkspaceMemberLimitExceededError",t})(),Ec=(()=>{class t extends R{}return t._errorName="WorkspacePolicyViolationError",t})(),Sc=(()=>{class t extends ue{}return t._errorName="StorageAttachedDuringArchiveError",t})(),xc=(()=>{class t extends ot{}return t._errorName="WorkspaceCreatedIncompleteError",t})(),Ih=(()=>{class t extends k{constructor(){super(...arguments),this.rateLimits=new $h(this._client),this.members=new Mh(this._client),this.serviceAccounts=new Bh(this._client)}create(e,r){return this._client.post("/v1/organizations/workspaces",{body:e,...r,__span:u(this._client,"anthropic.organization.workspaces.create",r,{route:"/v1/organizations/workspaces",createdIDAttribute:"anthropic.organization.workspace.id"})})}retrieve(e,r){return this._client.get(m`/v1/organizations/workspaces/${e}`,{...r,__span:u(this._client,"anthropic.organization.workspaces.retrieve",r,{route:"/v1/organizations/workspaces/{workspace_id}",attributes:{"anthropic.organization.workspace.id":e}})})}update(e,r,i){return this._client.post(m`/v1/organizations/workspaces/${e}`,{body:r,...i,__span:u(this._client,"anthropic.organization.workspaces.update",i,{route:"/v1/organizations/workspaces/{workspace_id}",attributes:{"anthropic.organization.workspace.id":e}})})}list(e={},r){return this._client.getAPIList("/v1/organizations/workspaces",de,{query:e,...r,__span:u(this._client,"anthropic.organization.workspaces.list",r,{route:"/v1/organizations/workspaces",queryParams:["after_id","before_id","ids","include_archived","include_default","limit"]})})}archive(e,r){return this._client.post(m`/v1/organizations/workspaces/${e}/archive`,{...r,__span:u(this._client,"anthropic.organization.workspaces.archive",r,{route:"/v1/organizations/workspaces/{workspace_id}/archive",attributes:{"anthropic.organization.workspace.id":e}})})}}return t.KeyProfileMismatchError=wc,t.StorageProfileMismatchError=vc,t.WorkspaceMemberLimitExceededError=kc,t.WorkspacePolicyViolationError=Ec,t.StorageAttachedDuringArchiveError=Sc,t.WorkspaceCreatedIncompleteError=xc,t.RateLimits=$h,t.Members=Mh,t.ServiceAccounts=Bh,t})(),Tc=(()=>{class t extends R{}return t._errorName="OrgMemberLimitExceededError",t})(),Ac=(()=>{class t extends Ye{}return t._errorName="RBACRoleNotFoundError",t})(),Rc=(()=>{class t extends ue{}return t._errorName="ConcurrentMembershipChangeError",t})(),zc=(()=>{class t extends ot{}return t._errorName="ChangeOutcomeUnknownError",t})(),qh=(()=>{class t extends k{constructor(){super(...arguments),this.apiKeys=new sh(this._client),this.externalKeys=new ah(this._client),this.federation=new Sh(this._client),this.invites=new oh(this._client),this.serviceAccounts=new Ph(this._client),this.users=new uh(this._client),this.workspaces=new Ih(this._client),this.rateLimits=new lh(this._client),this.complianceSettings=new ch(this._client),this.analytics=new wh(this._client),this.spendLimits=new Nh(this._client),this.rbacGroups=new Th(this._client),this.rbacRoles=new Rh(this._client)}retrieve(e){return this._client.get("/v1/organizations/me",{...e,__span:u(this._client,"anthropic.organization.retrieve",e,{route:"/v1/organizations/me"})})}}return t.OrgMemberLimitExceededError=Tc,t.RBACRoleNotFoundError=Ac,t.ConcurrentMembershipChangeError=Rc,t.ChangeOutcomeUnknownError=zc,t.APIKeys=sh,t.OrgAPIKeyLimitExceededError=oc,t.WorkspaceAPIKeyLimitExceededError=cc,t.ExternalKeys=ah,t.ExternalKeyInWorkspacePolicyError=lc,t.ExternalKeyValidationFailedError=uc,t.ExternalKeyValidationTimedOutError=dc,t.ExternalKeyChangedError=hc,t.Federation=Sh,t.Invites=oh,t.AlreadyMemberError=_c,t.CannotInviteEmailsWithUnverifiedDomainsError=pc,t.EmailDomainNotAllowedError=fc,t.InviteAlreadyExistsError=gc,t.ServiceAccounts=Ph,t.Users=uh,t.CannotRemoveLastMemberError=mc,t.Workspaces=Ih,t.KeyProfileMismatchError=wc,t.StorageProfileMismatchError=vc,t.WorkspaceMemberLimitExceededError=kc,t.WorkspacePolicyViolationError=Ec,t.StorageAttachedDuringArchiveError=Sc,t.WorkspaceCreatedIncompleteError=xc,t.RateLimits=lh,t.ComplianceSettings=ch,t.Analytics=wh,t.SpendLimits=Nh,t.RBACGroups=Th,t.RBACGroupGrantsOwnerAccessError=yc,t.RBACGroupOwnerAccessUnconfirmedError=bc,t.RBACRoles=Rh,t})();class Lh extends k{create(n,e,r){const{workspace_id:i,...s}=e;return this._client.post(m`/v1/skills/${n}/versions`,Xe({body:s,...r,headers:g([{...i!=null?{"anthropic-workspace-id":i}:void 0},r?.headers]),__span:u(this._client,"anthropic.skills.versions.create",r,{route:"/v1/skills/{skill_id}/versions",attributes:{"anthropic.skill.id":n},createdIDAttribute:"anthropic.skill.version.id"})},this._client,!1))}retrieve(n,e,r){const{skill_id:i,workspace_id:s}=e;return this._client.get(m`/v1/skills/${i}/versions/${n}`,{...r,headers:g([{...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__span:u(this._client,"anthropic.skills.versions.retrieve",r,{route:"/v1/skills/{skill_id}/versions/{version}",attributes:{"anthropic.skill.id":i,"anthropic.skill.version.id":n}})})}list(n,e={},r){const{workspace_id:i,...s}=e??{};return this._client.getAPIList(m`/v1/skills/${n}/versions`,z,{query:s,...r,headers:g([{...i!=null?{"anthropic-workspace-id":i}:void 0},r?.headers]),__span:u(this._client,"anthropic.skills.versions.list",r,{route:"/v1/skills/{skill_id}/versions",queryParams:["limit","page"],attributes:{"anthropic.skill.id":n}})})}delete(n,e,r){const{skill_id:i,workspace_id:s}=e;return this._client.delete(m`/v1/skills/${i}/versions/${n}`,{...r,headers:g([{...s!=null?{"anthropic-workspace-id":s}:void 0},r?.headers]),__span:u(this._client,"anthropic.skills.versions.delete",r,{route:"/v1/skills/{skill_id}/versions/{version}",attributes:{"anthropic.skill.id":i,"anthropic.skill.version.id":n}})})}}var Pc=(()=>{class t extends ue{}return t._errorName="SkillReadBlockedUndecryptableError",t})(),Uh=(()=>{class t extends k{constructor(){super(...arguments),this.versions=new Lh(this._client)}create(e,r){const{workspace_id:i,...s}=e;return this._client.post("/v1/skills",Xe({body:s,...r,headers:g([{...i!=null?{"anthropic-workspace-id":i}:void 0},r?.headers]),__span:u(this._client,"anthropic.skills.create",r,{route:"/v1/skills",createdIDAttribute:"anthropic.skill.id"})},this._client,!1))}retrieve(e,r={},i){const{workspace_id:s}=r??{};return this._client.get(m`/v1/skills/${e}`,{...i,headers:g([{...s!=null?{"anthropic-workspace-id":s}:void 0},i?.headers]),__span:u(this._client,"anthropic.skills.retrieve",i,{route:"/v1/skills/{skill_id}",attributes:{"anthropic.skill.id":e}})})}list(e={},r){const{workspace_id:i,...s}=e??{};return this._client.getAPIList("/v1/skills",z,{query:s,...r,headers:g([{...i!=null?{"anthropic-workspace-id":i}:void 0},r?.headers]),__span:u(this._client,"anthropic.skills.list",r,{route:"/v1/skills",queryParams:["limit","page","source"]})})}delete(e,r={},i){const{workspace_id:s}=r??{};return this._client.delete(m`/v1/skills/${e}`,{...i,headers:g([{...s!=null?{"anthropic-workspace-id":s}:void 0},i?.headers]),__span:u(this._client,"anthropic.skills.delete",i,{route:"/v1/skills/{skill_id}",attributes:{"anthropic.skill.id":e}})})}}return t.SkillReadBlockedUndecryptableError=Pc,t.Versions=Lh,t})();class Fh extends k{create(n,e,r){const{workspace_id:i,...s}=e;return this._client.post(m`/v1/user_profiles/${n}/action_urls`,{body:s,...r,headers:g([{...i!=null?{"anthropic-workspace-id":i}:void 0},r?.headers]),__span:u(this._client,"anthropic.user_profiles.action_urls.create",r,{route:"/v1/user_profiles/{user_profile_id}/action_urls",attributes:{"anthropic.user_profile.id":n}})})}}var Cc=(()=>{class t extends R{}return t._errorName="UserProfileNotFoundError",t})(),Oc=(()=>{class t extends R{}return t._errorName="UserProfileRequiredError",t})(),Nc=(()=>{class t extends oe{}return t._errorName="UserProfileBillingNotAuthorizedError",t})(),Mc=(()=>{class t extends oe{}return t._errorName="UserProfileNotBillableError",t})(),Wh=(()=>{class t extends k{constructor(){super(...arguments),this.actionURLs=new Fh(this._client)}create(e,r){const{workspace_id:i,...s}=e;return this._client.post("/v1/user_profiles",{body:s,...r,headers:g([{...i!=null?{"anthropic-workspace-id":i}:void 0},r?.headers]),__span:u(this._client,"anthropic.user_profiles.create",r,{route:"/v1/user_profiles",createdIDAttribute:"anthropic.user_profile.id"})})}retrieve(e,r={},i){const{workspace_id:s}=r??{};return this._client.get(m`/v1/user_profiles/${e}`,{...i,headers:g([{...s!=null?{"anthropic-workspace-id":s}:void 0},i?.headers]),__span:u(this._client,"anthropic.user_profiles.retrieve",i,{route:"/v1/user_profiles/{user_profile_id}",attributes:{"anthropic.user_profile.id":e}})})}update(e,r,i){const{workspace_id:s,...a}=r;return this._client.post(m`/v1/user_profiles/${e}`,{body:a,...i,headers:g([{...s!=null?{"anthropic-workspace-id":s}:void 0},i?.headers]),__span:u(this._client,"anthropic.user_profiles.update",i,{route:"/v1/user_profiles/{user_profile_id}",attributes:{"anthropic.user_profile.id":e}})})}list(e={},r){const{workspace_id:i,...s}=e??{};return this._client.getAPIList("/v1/user_profiles",z,{query:s,...r,headers:g([{...i!=null?{"anthropic-workspace-id":i}:void 0},r?.headers]),__span:u(this._client,"anthropic.user_profiles.list",r,{route:"/v1/user_profiles",queryParams:["enforcement_status","limit","order","order_by","page"]})})}delete(e,r={},i){const{workspace_id:s}=r??{};return this._client.delete(m`/v1/user_profiles/${e}`,{...i,headers:g([{...s!=null?{"anthropic-workspace-id":s}:void 0},i?.headers]),__span:u(this._client,"anthropic.user_profiles.delete",i,{route:"/v1/user_profiles/{user_profile_id}",attributes:{"anthropic.user_profile.id":e}})})}}return t.UserProfileNotFoundError=Cc,t.UserProfileRequiredError=Oc,t.UserProfileBillingNotAuthorizedError=Nc,t.UserProfileNotBillableError=Mc,t.ActionURLs=Fh,t})();const Vw=new Map([["400 already_member",_c],["400 approval_required",Ao],["400 available_tools_limit_exceeded",jo],["400 bundle_attachment_not_supported",oo],["400 bundle_on_call",co],["400 cannot_invite_emails_with_unverified_domains",pc],["400 cannot_remove_last_member",mc],["400 cannot_sign_out_primary_owner",Ya],["400 cannot_sign_out_self",Xa],["400 claude_code_key_creator_not_member",wp],["400 claude_code_version_too_old",vp],["400 cmek_feature_unsupported",ro],["400 cmek_key_disabled",kp],["400 cmek_key_network_blocked",Ep],["400 cmek_not_approved",Oo],["400 compaction_block_ambiguous",Ho],["400 compaction_block_misplaced",Ko],["400 compaction_content_mismatch",Do],["400 compaction_incomplete_turn",Go],["400 compaction_nothing_to_summarize",Vo],["400 compaction_signature_invalid",Jo],["400 compaction_too_many_tool_references",Yo],["400 compaction_tool_changes_mismatch",Xo],["400 email_domain_not_allowed",fc],["400 environment_archived",Ra],["400 external_key_in_workspace_policy",lc],["400 external_key_not_found",No],["400 external_key_provider_mismatch",Mo],["400 external_key_validation_failed",uc],["400 external_key_validation_timed_out",dc],["400 external_storage_in_use",Ia],["400 external_storage_in_workspace_policy",qa],["400 external_storage_not_available",La],["400 file_not_downloadable",Ea],["400 gcp_project_not_verified",$o],["400 grant_required",Ua],["400 human_review_not_available",Ro],["400 human_review_on_with_external_storage",So],["400 image_dimensions_too_large",Qo],["400 invalid_config_type_change",za],["400 invalid_metadata",Pa],["400 invalid_storage_arn",Fa],["400 invite_already_exists",gc],["400 key_profile_mismatch",wc],["400 org_api_key_limit_exceeded",oc],["400 org_member_limit_exceeded",Tc],["400 organization_not_eligible",zo],["400 organization_not_enrolled_in_beta",Bo],["400 organization_on_hold",Sp],["400 organization_type_not_supported",xp],["400 parent_organization_required",Tp],["400 provider_not_allowed",Wa],["400 rbac_group_grants_owner_access",yc],["400 rbac_group_order_limit_exceeded",no],["400 rbac_group_owner_access_unconfirmed",bc],["400 region_not_supported",Io],["400 request_body_encoding_invalid",Ap],["400 request_body_encoding_unsupported",Rp],["400 request_body_timeout",qo],["400 scan_failed",mo],["400 settings_document_limit_exceeded",io],["400 settings_history_limit_exceeded",so],["400 slack_channel_set_up_settings_refused",lo],["400 storage_attach_limit_reached",ja],["400 storage_not_approved",Lo],["400 storage_not_attachable",Ha],["400 storage_profile_mismatch",vc],["400 storage_profile_still_required",Ka],["400 storage_quota_exceeded",Sa],["400 storage_verification_failed",Da],["400 thread_already_continued",Zo],["400 thread_continue_in_flight",ec],["400 thread_fingerprint_mismatch",tc],["400 thread_unsupported_request",rc],["400 tool_name_conflict",nc],["400 tool_reference_unresolved",ic],["400 transcripts_storage_required",xo],["400 unsupported_charset",Uo],["400 unsupported_region",Ga],["400 user_profile_not_found",Cc],["400 user_profile_required",Oc],["400 workspace_api_key_limit_exceeded",cc],["400 workspace_human_review_disabled",zp],["400 workspace_member_limit_exceeded",kc],["400 workspace_policy_violation",Ec],["402 linked_organization_billing_unavailable",Pp],["402 linked_organization_spend_limit_reached",Cp],["403 api_key_scope_missing",uo],["403 cannot_sign_out_managed_member",Qa],["403 cannot_sign_out_membership_admin",Za],["403 cannot_sign_out_owner",eo],["403 cannot_sign_out_privileged_member",to],["403 claude_tag_writes_not_enabled",ho],["403 compliance_configuration_restricted",_o],["403 environment_create_disabled",Ca],["403 environment_update_disabled",Oa],["403 organization_level_scoped_api_key_required",po],["403 sandbox_egress_restricted",Op],["403 spend_limits_admin_api_writes_not_enabled",Eo],["403 user_profile_billing_not_authorized",Nc],["403 user_profile_not_billable",Mc],["404 environment_not_found",Na],["404 file_expired",xa],["404 rbac_group_managed_settings_not_found",ao],["404 rbac_group_not_found",ko],["404 rbac_role_not_found",Ac],["404 slack_channel_set_up_environment_not_found",fo],["404 thread_not_found",sc],["409 concurrent_membership_change",Rc],["409 external_key_changed",hc],["409 gcp_project_controlled_by_another_organization",Fo],["409 plugin_name_taken",yo],["409 scan_pending",bo],["409 skill_name_taken",wo],["409 skill_read_blocked_undecryptable",Pc],["409 slack_channel_set_up_settings_conflict",go],["409 storage_already_registered",Va],["409 storage_attached_during_archive",Sc],["409 storage_changed_concurrently",Ja],["409 storage_in_use",Wo],["409 workspace_changed_concurrently",To],["412 heartbeat_precondition_failed",Aa],["413 request_body_too_large_after_decoding",Np],["429 contract_spend_limit_reached",Mp],["429 enforced_spend_limit_reached",$p],["429 ramp_limit_exceeded",Bp],["503 authorization_check_unavailable",Po],["503 change_outcome_unknown",zc],["503 cmek_context_unavailable",Ip],["503 cmek_key_unreachable",qp],["503 registration_pending",vo],["503 workspace_created_incomplete",xc],["529 compaction_unavailable",ac]]),Jw="urn:ietf:params:oauth:grant-type:jwt-bearer",Yw="refresh_token",gf="/v1/oauth/token",wi="oauth-2025-04-20",Xw="oidc-federation-2026-04-01",Qw=120,$c=30,Zw=5,jh=1<<20;function mf(t){if(!t)return;let n;try{n=new URL(t)}catch(r){throw new D(`Invalid token endpoint base URL "${t}": ${r}`)}if(n.protocol==="https:")return;const e=n.hostname.toLowerCase().replace(/^\[|\]$/g,"");if(!(n.protocol==="http:"&&(e==="localhost"||e==="127.0.0.1"||e==="::1")))throw new D(`Refusing to send credential over non-https token endpoint "${t}"`)}async function yf(t,n){const e=await tv(t);let r;try{r=JSON.parse(e)}catch{throw new D(`Token endpoint returned non-JSON response (status ${t.status})`,t.status,Re(e),n)}if(!r.access_token)throw new D(`Token endpoint response missing access_token: ${JSON.stringify(Re(r))}`,t.status,Re(r),n);if(r.token_type&&r.token_type.toLowerCase()!=="bearer")throw new D(`Token endpoint response: unsupported token_type "${r.token_type}" (want Bearer)`,t.status,Re(r),n);return r}const ws=2e3,ev=new Set(["error","error_description","error_uri"]);function Re(t){if(t==null)return t;if(typeof t=="string"){let n;try{n=JSON.parse(t)}catch{return t.length<=ws?t:t.slice(0,ws)+`... <${t.length-ws} more chars>`}return JSON.stringify(Re(n))}if(typeof t=="object"&&!Array.isArray(t)){const n={};for(const[e,r]of Object.entries(t))ev.has(e)&&(n[e]=r);return n}return null}async function bf(t,n=e=>console.warn(`anthropic-sdk: ${e}`)){if(typeof process>"u"||process.platform==="win32")return;const{fs:e}=await Fe(async()=>{const{fs:a}=await import("./node.browser-DZzq1E_m.js");return{fs:a}},__vite__mapDeps([4,1,2,3]));let r=t,i;try{r=await e.promises.realpath(t),i=await e.promises.stat(r)}catch{return}const s=i.mode&511;if(s&18)throw new D(`Credentials file at ${r} is group/world-writable (mode 0o${s.toString(8)}); this allows other local users to plant tokens. Run \`chmod 600 ${r}\`.`);if(s&36)throw new D(`Credentials file at ${r} is group/world-readable (mode 0o${s.toString(8)}); run \`chmod 600 ${r}\` before retrying.`);typeof process.getuid=="function"&&i.uid!==process.getuid()&&n(`credentials file at ${r} is owned by uid ${i.uid} (current process uid ${process.getuid()}); verify this is intentional.`)}async function wf(t,n){const{fs:e,path:r}=await Fe(async()=>{const{fs:a,path:c}=await import("./node.browser-DZzq1E_m.js");return{fs:a,path:c}},__vite__mapDeps([4,1,2,3])),i=r.dirname(t);await e.promises.mkdir(i,{recursive:!0,mode:448});const s=`${t}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;try{const a=await e.promises.open(s,"w",384);try{await a.writeFile(JSON.stringify(n,null,2)),await a.sync()}finally{await a.close()}await e.promises.rename(s,t)}catch(a){throw await e.promises.unlink(s).catch(()=>{}),a}try{const a=await e.promises.open(i,"r");try{await a.sync()}finally{await a.close()}}catch{}}async function tv(t){if(!t.body)return"";const n=t.body.getReader(),e=[];let r=0;for(;;){const{done:s,value:a}=await n.read();if(s)break;if(r+a.length>jh){const c=jh-r;c>0&&e.push(a.subarray(0,c)),await n.cancel();break}e.push(a),r+=a.length}let i;if(e.length===1)i=e[0];else{i=new Uint8Array(e.reduce((a,c)=>a+c.length,0));let s=0;for(const a of e)i.set(a,s),s+=a.length}return new TextDecoder("utf-8").decode(i)}var D=(()=>{class t extends P{constructor(e,r=null,i=null,s=null){super(e),this.statusCode=r,this.body=i,this.requestId=s}}return t._errorName="WorkloadIdentityError",t})();function St(){return Math.floor(Date.now()/1e3)}class rv{constructor(n,e){this.cached=null,this.pendingRefresh=null,this.nextForce=!1,this.lastAdvisoryError=0,this.provider=n,this.onAdvisoryRefreshError=e}async getToken(){const n=this.nextForce;this.nextForce=!1;const e=this.cached;if(n||e==null)return(await this.refresh(n)).token;if(e.expiresAt==null)return e.token;const r=e.expiresAt-St();return r>Qw?e.token:r>$c?(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||St()-this.lastAdvisoryError<Zw||this.doRefresh().catch(n=>{this.lastAdvisoryError=St(),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}}const vf="1.0",nv=/^[A-Za-z0-9_.-]+$/;function kf(t){if(!t)throw new Error("profile name is empty");if(t==="."||t==="..")throw new Error(`profile name "${t}" is not allowed`);if(t.includes("/")||t.includes("\\"))throw new Error(`profile name "${t}" must not contain path separators`);if(!nv.test(t))throw new Error(`profile name "${t}" contains disallowed characters (allowed: letters, digits, '_', '.', '-')`)}const iv=async t=>{var n,e;const r=await Bc();if(r===null)return null;const i=t==null&&I("ANTHROPIC_PROFILE")!=null;let s=null;if(t==null&&!i){const f=I("ANTHROPIC_ORGANIZATION_ID"),b=I("ANTHROPIC_IDENTITY_TOKEN_FILE"),y=I("ANTHROPIC_FEDERATION_RULE_ID");if(y&&f&&(s={fromFile:!1,config:{organization_id:f,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:b?{source:"file",path:b}:void 0,scope:I("ANTHROPIC_SCOPE")}}},b||I("ANTHROPIC_IDENTITY_TOKEN")))return s}const a=t??await Ef();if(a===null)return null;kf(a);const{fs:c,path:l}=await Fe(async()=>{const{fs:f,path:b}=await import("./node.browser-DZzq1E_m.js");return{fs:f,path:b}},__vite__mapDeps([4,1,2,3])),d=l.join(r,"configs",`${a}.json`);let _;try{_=await c.promises.readFile(d,"utf-8")}catch(f){if(f?.code!=="ENOENT")throw new Error(`failed to read config file ${d}: ${f}`);if(i)throw new P(`ANTHROPIC_PROFILE names the profile "${a}", but ${d} does not exist. Set ANTHROPIC_PROFILE to a profile that exists, or unset it.`,{cause:f});return s}let h;try{h=JSON.parse(_)}catch(f){throw new Error(`failed to parse config file ${d}: ${f}`)}if(!h.authentication)throw new Error(`config file ${d} is missing "authentication"`);const p=h.authentication.type;if(p!=="oidc_federation"&&p!=="user_oauth")throw new Error(`authentication.type "${p}" is not a known authentication type`);if(h.organization_id??(h.organization_id=I("ANTHROPIC_ORGANIZATION_ID")),h.workspace_id??(h.workspace_id=I("ANTHROPIC_WORKSPACE_ID")),h.base_url??(h.base_url=I("ANTHROPIC_BASE_URL")),(n=h.authentication).scope??(n.scope=I("ANTHROPIC_SCOPE")),h.authentication.type==="oidc_federation"){if(!h.authentication.identity_token){const f=I("ANTHROPIC_IDENTITY_TOKEN_FILE");f&&(h.authentication.identity_token={source:"file",path:f})}h.authentication.federation_rule_id||(h.authentication.federation_rule_id=I("ANTHROPIC_FEDERATION_RULE_ID")??""),(e=h.authentication).service_account_id??(e.service_account_id=I("ANTHROPIC_SERVICE_ACCOUNT_ID"))}return{config:h,fromFile:!0}},sv=async(t,n)=>{if(t?.authentication.credentials_path)return t.authentication.credentials_path;const e=await Bc();if(!e)return null;const r=n??await Ef();if(!r)return null;kf(r);const{path:i}=await Fe(async()=>{const{path:s}=await import("./node.browser-DZzq1E_m.js");return{path:s}},__vite__mapDeps([4,1,2,3]));return i.join(e,"credentials",`${r}.json`)},Bc=async()=>{if(!av())return null;const{path:t}=await Fe(async()=>{const{path:s}=await import("./node.browser-DZzq1E_m.js");return{path:s}},__vite__mapDeps([4,1,2,3])),n=I("ANTHROPIC_CONFIG_DIR");if(n)return n;if(sa()["X-Stainless-OS"]==="Windows"){const s=I("APPDATA");if(s)return t.join(s,"Anthropic");const a=I("USERPROFILE");return a?t.join(a,"AppData","Roaming","Anthropic"):null}const r=I("XDG_CONFIG_HOME");if(r)return t.join(r,"anthropic");const i=I("HOME");return i?t.join(i,".config","anthropic"):null},av=()=>{const t=sa()["X-Stainless-Runtime"];return t==="node"||t==="deno"},Ef=async()=>{const t=await Bc();if(!t)return null;const n=I("ANTHROPIC_PROFILE");if(n)return n;const{fs:e,path:r}=await Fe(async()=>{const{fs:s,path:a}=await import("./node.browser-DZzq1E_m.js");return{fs:s,path:a}},__vite__mapDeps([4,1,2,3])),i=r.join(t,"active_config");try{return(await e.promises.readFile(i,"utf-8")).trim()||"default"}catch(s){if(s?.code!=="ENOENT")throw new Error(`failed to read ${i}: ${s}`);return"default"}};function Hh(t){if(!t)throw new P("Identity token file path is empty");return async()=>{const{fs:n}=await Fe(async()=>{const{fs:i}=await import("./node.browser-DZzq1E_m.js");return{fs:i}},__vite__mapDeps([4,1,2,3]));let e;try{e=await n.promises.readFile(t,"utf-8")}catch(i){throw new P(`Failed to read identity token file at ${t}: ${i}`)}const r=e.trim();if(!r)throw new P(`Identity token file at ${t} is empty`);return r}}function ov(t){if(!t)throw new P("Identity token value is empty");return()=>t}function cv(t){return async()=>{mf(t.baseURL);const n=await t.identityTokenProvider();if(n.length>16*1024)throw new D(`Identity token is ${Math.ceil(n.length/1024)} KiB, exceeds the 16 KiB assertion limit`);const e={grant_type:Jw,assertion:n,federation_rule_id:t.federationRuleId,organization_id:t.organizationId};t.serviceAccountId&&(e.service_account_id=t.serviceAccountId),t.workspaceId&&(e.workspace_id=t.workspaceId);const r=`${t.baseURL}${gf}`;let i;try{i=await t.fetch(r,{method:"POST",redirect:"manual",headers:{"Content-Type":"application/json","anthropic-beta":`${wi},${Xw}`,"User-Agent":t.userAgent||`anthropic-sdk-typescript/${Ge} oidcFederationProvider`},body:JSON.stringify(e)})}catch(l){throw new D(`Failed to reach token endpoint ${r}: ${l}`)}const s=i.headers.get("Request-Id");if(!i.ok){const l=await i.text().catch(()=>""),d=Re(l);let _="";throw i.status===401&&(_=` Ensure your federation rule matches your identity token. ${t.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 D(`Token exchange failed with status ${i.status}${s?` (request-id ${s})`:""}: ${d}${_}`,i.status,d,s)}const a=await yf(i,s),c=Number(a.expires_in);if(!Number.isFinite(c))throw new D(`Token endpoint response missing required fields: ${JSON.stringify(Re(a))}`,i.status,Re(a),s);return{token:a.access_token,expiresAt:St()+c}}}function lv(t){return async n=>{const{fs:e}=await Fe(async()=>{const{fs:w}=await import("./node.browser-DZzq1E_m.js");return{fs:w}},__vite__mapDeps([4,1,2,3]));await bf(t.credentialsPath,t.onSafetyWarning);let r;try{r=await e.promises.readFile(t.credentialsPath,"utf-8")}catch(w){throw new D(`Credentials file not found at ${t.credentialsPath}: ${w}`)}let i;try{i=JSON.parse(r)}catch(w){throw new D(`Credentials file at ${t.credentialsPath} is not valid JSON: ${w}`)}const s=i.access_token;if(!s)throw new D(`Credentials file at ${t.credentialsPath} must include 'access_token'`);const a=i.expires_at;if(!n?.forceRefresh&&(a==null||St()<a-$c))return{token:s,expiresAt:a??null};const c=i.refresh_token;if(!t.clientId||!c)throw new D(`Access token at ${t.credentialsPath} has expired and no refresh is available (client_id ${t.clientId?"set":"empty"}, refresh_token ${c?"set":"empty"})`);mf(t.baseURL);const l={grant_type:Yw,refresh_token:c,client_id:t.clientId},d=`${t.baseURL}${gf}`;let _;try{_=await t.fetch(d,{method:"POST",redirect:"manual",headers:{"Content-Type":"application/json","anthropic-beta":wi,"User-Agent":t.userAgent||`anthropic-sdk-typescript/${Ge} userOAuthProvider`},body:JSON.stringify(l)})}catch(w){throw new D(`User OAuth refresh failed to reach token endpoint: ${w}`)}const h=_.headers.get("Request-Id");if(!_.ok){const w=await _.text().catch(()=>"");throw new D(`User OAuth refresh failed (HTTP ${_.status}): ${Re(w)}`,_.status,Re(w),h)}const p=await yf(_,h),f=Number(p.expires_in);if(!Number.isFinite(f))throw new D(`User OAuth refresh response missing or invalid expires_in: ${JSON.stringify(Re(p))}`,_.status,Re(p),h);const b=St()+f,y=p.refresh_token||c;return await wf(t.credentialsPath,{...i,version:vf,type:"oauth_token",access_token:p.access_token,expires_at:b,refresh_token:y}),{token:p.access_token,expiresAt:b}}}function Sf(t,n){const e=t.authentication.credentials_path??null,r=(t.base_url||n.baseURL).replace(/\/+$/,""),i=dv(t,e,r,n),s={};return t.workspace_id&&t.authentication.type==="user_oauth"&&(s["anthropic-workspace-id"]=t.workspace_id),{provider:i,extraHeaders:s,baseURL:t.base_url||void 0}}async function uv(t,n){const e=await iv(n);if(!e)return null;const{config:r,fromFile:i}=e,s=r.authentication.credentials_path||!i?r:{...r,authentication:{...r.authentication,credentials_path:await sv(r,n)??void 0}};return Sf(s,t)}function dv(t,n,e,r){switch(t.authentication.type){case"oidc_federation":{const i=t.authentication,s=hv(i);if(!s)throw new D("oidc_federation config requires an identity token (set authentication.identity_token, ANTHROPIC_IDENTITY_TOKEN_FILE, or ANTHROPIC_IDENTITY_TOKEN)");if(!i.federation_rule_id)throw new D("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(!t.organization_id)throw new D("oidc_federation config requires organization_id (set ANTHROPIC_ORGANIZATION_ID or config.organization_id)");const a=cv({identityTokenProvider:s,federationRuleId:i.federation_rule_id,organizationId:t.organization_id,serviceAccountId:i.service_account_id,workspaceId:t.workspace_id,baseURL:e,fetch:r.fetch,userAgent:r.userAgent});return n?_v(a,n,r.onCacheWriteError,r.onSafetyWarning):a}case"user_oauth":{if(!n)throw new D("user_oauth config requires authentication.credentials_path (or load via a profile so it defaults to <config_dir>/credentials/<profile>.json)");return lv({credentialsPath:n,clientId:t.authentication.client_id,baseURL:e,fetch:r.fetch,userAgent:r.userAgent,onSafetyWarning:r.onSafetyWarning})}default:{const i=t.authentication.type;throw new D(`authentication.type "${i}" is not a known authentication type`)}}}function hv(t){if(t.identity_token){const r=t.identity_token.source;if(r!=="file")throw new D(`identity_token.source "${r}" is not supported by this SDK version (only "file")`);if(!t.identity_token.path)throw new D('identity_token.source "file" requires a non-empty path');return Hh(t.identity_token.path)}const n=I("ANTHROPIC_IDENTITY_TOKEN_FILE");if(n)return Hh(n);const e=I("ANTHROPIC_IDENTITY_TOKEN");return e?ov(e):null}function _v(t,n,e,r){return async i=>{const{fs:s}=await Fe(async()=>{const{fs:l}=await import("./node.browser-DZzq1E_m.js");return{fs:l}},__vite__mapDeps([4,1,2,3]));await bf(n,r);let a;try{const l=await s.promises.readFile(n,"utf-8");a=JSON.parse(l);const d=a?.access_token;if(d&&!i?.forceRefresh){const _=a?.expires_at;if(_==null||St()<_-$c)return{token:d,expiresAt:_??null}}}catch(l){l?.code!=="ENOENT"&&!(l instanceof SyntaxError)&&e?.(l)}const c=await t(i);try{await wf(n,{...a??{},version:vf,type:"oauth_token",access_token:c.token,expires_at:c.expiresAt})}catch(l){e?.(l)}return c}}const xf=new WeakSet;function Tf(t){return typeof t=="object"&&t!==null&&xf.has(t)}function pv(t){const n=new Set;for(;typeof t=="object"&&t!==null&&!n.has(t);){if(n.add(t),Tf(t)||Tt(t)||t instanceof At||t instanceof Zg)return!0;t=t.cause}return!1}function Kh(t,n,e,r){return async(i,s={})=>{if(n.length===0)return t.call(void 0,i,s);const a=s.headers instanceof Headers?s.headers:new Headers(s.headers),c=await gv(t,n,e,r)({...s,headers:a,url:typeof i=="string"?i:i instanceof URL?i.href:i.url});if(c.bodyUsed||c.body?.locked)throw new P("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 fv(t,n){const e=new WeakMap;return{options:t,logger:n?B(n):j_(),parse(r){if(t?.stream&&r.ok)return Dh(r,t,n);let i=e.get(r);return i||(i=Dh(r,t,n),e.set(r,i)),i}}}async function Dh(t,n,e){if(t.bodyUsed||t.body?.locked)throw new P("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&&t.ok)return Je.fromSSEResponse(t.clone(),new AbortController,e);if(t.status===204)return null;if(n?.__binaryResponse)return t;const i=t.headers.get("content-type")?.split(";")[0]?.trim();return i?.includes("application/json")||i?.endsWith("+json")?t.headers.get("content-length")==="0"?void 0:Pi(await t.clone().json(),t):await t.clone().text()}function gv(t,n,e,r){let i=async({url:a,...c})=>{try{return await t.call(void 0,a,c)}catch(l){const d=jr(l);throw xf.add(d),d}};const s=fv(e,r);for(let a=n.length-1;a>=0;a--){const c=n[a],l=i;i=async d=>c(d,l,s)}return i}const Af=t=>t!=null&&typeof t=="object"&&typeof t.size=="number"&&typeof t.type=="string"&&typeof t.text=="function"&&typeof t.slice=="function"&&typeof t.arrayBuffer=="function",mv=t=>t!=null&&typeof t=="object"&&typeof t.name=="string"&&typeof t.lastModified=="number"&&Af(t),yv=t=>t!=null&&typeof t=="object"&&typeof t.url=="string"&&typeof t.blob=="function";async function bv(t,n,e){if(rp(),t=await t,n||(n=t instanceof File?t.name:ri(t,!0)),mv(t))return t instanceof File&&n==null&&e==null?t:Zt([await t.arrayBuffer()],n??t.name,{type:t.type,lastModified:t.lastModified,...e});if(yv(t)){const i=await t.blob();return n||(n=new URL(t.url).pathname.split(/[\\/]/).pop()),Zt(await Gs(i),n,e)}const r=await Gs(t);if(!e?.type){const i=r.find(s=>typeof s=="object"&&"type"in s&&s.type);typeof i=="string"&&(e={...e,type:i})}return Zt(r,n,e)}async function Gs(t){let n=[];if(typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer)n.push(t);else if(Af(t))n.push(t instanceof Blob?t:await t.arrayBuffer());else if(ma(t))for await(const e of t)n.push(...await Gs(e));else{const e=t?.constructor?.name;throw new Error(`Unexpected data type: ${typeof t}${e?`; constructor: ${e}`:""}${wv(t)}`)}return n}function wv(t){return typeof t!="object"||t===null?"":`; props: [${Object.getOwnPropertyNames(t).map(e=>`"${e}"`).join(", ")}]`}class Gh extends k{retrieve(n,e={},r){const{workspace_id:i}=e??{};return this._client.get(m`/v1/models/${n}`,{...r,headers:g([{...i!=null?{"anthropic-workspace-id":i}:void 0},r?.headers]),__span:u(this._client,"anthropic.models.retrieve",r,{route:"/v1/models/{model_id}",attributes:{"anthropic.model.id":n}})})}list(n={},e){const{workspace_id:r,...i}=n??{};return this._client.getAPIList("/v1/models",de,{query:i,...e,headers:g([{...r!=null?{"anthropic-workspace-id":r}:void 0},e?.headers]),__span:u(this._client,"anthropic.models.list",e,{route:"/v1/models",queryParams:["after_id","before_id","lifecycle","limit"]})})}}var vs,ks,Qn,Yt,yt,Vh;let Jh=!1;var vv=(()=>{class t{get credentials(){return this._authState.provider}get openTelemetry(){return o(this,yt,"f")}_instrumentationScope(){return{version:Ge}}constructor({baseURL:e=I("ANTHROPIC_BASE_URL"),apiKey:r,authToken:i,webhookKey:s=I("ANTHROPIC_WEBHOOK_SIGNING_KEY")??null,...a}={}){vs.add(this),this._requestAuthFlags=new WeakMap,Qn.set(this,void 0),Yt.set(this,void 0),yt.set(this,void 0),this._genAIProviderName="anthropic",this._supportsMessageThreads=!1;const c={apiKey:r,authToken:i,...a},l=Ot.filter(w=>c[w]!=null);if(l.length>1){const w=E=>E.map(S=>`\`${S}\``).join(", ");throw new TypeError(`Pass at most one of ${w(Ot)}. Received ${w(l)}.`)}const[d]=l,_=d!=null?null:{apiKey:r===void 0?I("ANTHROPIC_API_KEY"):void 0,authToken:i===void 0?I("ANTHROPIC_AUTH_TOKEN"):void 0},h=d!=null?{type:d,value:c[d]}:_?.apiKey!=null?{type:"apiKey",value:_.apiKey}:_?.authToken!=null?{type:"authToken",value:_.authToken}:{type:"defaultChain"},p={apiKey:h.type==="apiKey"?h.value:null,authToken:h.type==="authToken"?h.value:null,webhookKey:s,...a,baseURL:e||"https://api.anthropic.com"};if(!p.dangerouslyAllowBrowser&&im())throw new P(`It looks like you're running in a browser-like environment.
|
|
61
61
|
|
|
62
62
|
This is disabled by default, as it risks exposing your secret API credentials to attackers.
|
|
63
63
|
If you understand the risks and have appropriate mitigations in place,
|