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.
Files changed (38) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/lib/client.js +1 -1
  3. package/lib/index.js +3 -3
  4. package/package.json +1 -1
  5. package/skills/open-artifact/SKILL.md +1 -1
  6. package/vendor/home/assets/{browser-models-CuvEg0Hm.js → browser-models-CEM3keW0.js} +4 -4
  7. package/vendor/home/assets/{main-Bfz_QbAb.js → main-CD6mLXro.js} +2 -2
  8. package/vendor/home/assets/main-CudjUC-z.css +1 -0
  9. package/vendor/home/assets/{node.browser-Dg3f5wnV.js → node.browser-5FosC0Jx.js} +1 -1
  10. package/vendor/home/assets/{node.browser-CA5eNPFK.js → node.browser-DZzq1E_m.js} +1 -1
  11. package/vendor/home/index.html +2 -2
  12. package/vendor/open-artifact.mjs +19 -8
  13. package/vendor/runtime.json +1 -1
  14. package/vendor/shell/assets/{browser-models-D6sLTStW.js → browser-models-DiCdSmg7.js} +4 -4
  15. package/vendor/shell/assets/index-CudjUC-z.css +1 -0
  16. package/vendor/{type-server/shell/assets/index-DUlkQIc2.js → shell/assets/index-K1SKNjv-.js} +19 -19
  17. package/vendor/shell/assets/{node.browser-Dom693pr.js → node.browser-DF3wedOZ.js} +1 -1
  18. package/vendor/shell/assets/{node.browser-JBLNXGXd.js → node.browser-mz1-CgQF.js} +1 -1
  19. package/vendor/shell/index.html +2 -2
  20. package/vendor/type-server/cli.mjs +26 -4
  21. package/vendor/type-server/editors/design/assets/{index-CWVS8sEC.js → index-UWsnN0RP.js} +118 -118
  22. package/vendor/type-server/editors/design/index.html +1 -1
  23. package/vendor/type-server/editors/slides/assets/{index-DNd0a5AT.js → index-Cd8_0xQf.js} +103 -103
  24. package/vendor/type-server/editors/slides/assets/{src-QKaUghQ7.js → src-YYMn9WN3.js} +1 -1
  25. package/vendor/type-server/editors/slides/index.html +1 -1
  26. package/vendor/type-server/editors/whiteboard/assets/{gif-jobs-CvntHyno.js → gif-jobs-D1FISsUT.js} +1 -1
  27. package/vendor/type-server/editors/whiteboard/assets/{index-ifqwq1AR.js → index-BfYFnyuU.js} +89 -89
  28. package/vendor/type-server/editors/whiteboard/assets/{index-BIiUMoHl.js → index-C7gRSC0a.js} +2 -2
  29. package/vendor/type-server/editors/whiteboard/index.html +1 -1
  30. package/vendor/type-server/shell/assets/{browser-models-D6sLTStW.js → browser-models-DiCdSmg7.js} +4 -4
  31. package/vendor/type-server/shell/assets/index-CudjUC-z.css +1 -0
  32. package/vendor/{shell/assets/index-DUlkQIc2.js → type-server/shell/assets/index-K1SKNjv-.js} +19 -19
  33. package/vendor/type-server/shell/assets/{node.browser-Dom693pr.js → node.browser-DF3wedOZ.js} +1 -1
  34. package/vendor/type-server/shell/assets/{node.browser-JBLNXGXd.js → node.browser-mz1-CgQF.js} +1 -1
  35. package/vendor/type-server/shell/index.html +2 -2
  36. package/vendor/home/assets/main-DK7ftEF8.css +0 -1
  37. package/vendor/shell/assets/index-DK7ftEF8.css +0 -1
  38. 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-Dom693pr.js","assets/index-DUlkQIc2.js","assets/index-DK7ftEF8.css","assets/node.browser-JBLNXGXd.js"])))=>i.map(i=>d[i]);
2
- import{M as wi,S as ks,a as Qh,b as $f,c as Es,d as qf,e as If,f as Lf,g as Uf,h as Zh,i as ye,j as q,k as $c,t as Se,l as Ff,m as Wf,n as jf,o as Hf,p as qc,q as e_,s as Kf,r as Dr,u as Df,v as Gf,w as Vf,x as Jf,N as t_,y as r_,R as n_,z as Vs,A as Js,D as ki,_ as Fe,H as i_,O as K,B as Ic,C as Ss,E as Lc,F as Yf,G as Xf,I as Qf,J as Bi,K as Zf,L as eg,P as Ct,Q as tg,T as rg,U as ng}from"./index-DUlkQIc2.js";function s_(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*a_(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(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/node.browser-DF3wedOZ.js","assets/index-K1SKNjv-.js","assets/index-CudjUC-z.css","assets/node.browser-mz1-CgQF.js"])))=>i.map(i=>d[i]);
2
+ import{M as wi,S as ks,a as Qh,b as $f,c as Es,d as qf,e as If,f as Lf,g as Uf,h as Zh,i as ye,j as q,k as $c,t as Se,l as Ff,m as Wf,n as jf,o as Hf,p as qc,q as e_,s as Kf,r as Dr,u as Df,v as Gf,w as Vf,x as Jf,N as t_,y as r_,R as n_,z as Vs,A as Js,D as ki,_ as Fe,H as i_,O as K,B as Ic,C as Ss,E as Lc,F as Yf,G as Xf,I as Qf,J as Bi,K as Zf,L as eg,P as Ct,Q as tg,T as rg,U as ng}from"./index-K1SKNjv-.js";function s_(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*a_(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 b=c();b&&(yield b);continue}if(h.startsWith(":"))continue;const p=h.indexOf(":"),f=p<0?h:h.slice(0,p);let y=p<0?"":h.slice(p+1);y.startsWith(" ")&&(y=y.slice(1)),f==="data"?s.push(y):f==="event"&&(a=y)}}if(!i.trim()){const l=c();l&&(yield l)}}finally{e.releaseLock()}}function ig(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 qg(t){r
54
54
  ${s.map(p=>p.error).join(`
55
55
  `)}
56
56
  ${a}
57
- ${h}`)}return a},m=dy(fp);var va=(()=>{class t extends R{}return t._errorName="FileNotDownloadableError",t})(),wa=(()=>{class t extends R{}return t._errorName="StorageQuotaExceededError",t})(),ka=(()=>{class t extends Ye{}return t._errorName="FileExpiredError",t})(),pl=(()=>{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},pp(s.file),r?.headers]),__span:u(this._client,"anthropic.files.upload",r,{route:"/v1/files",createdIDAttribute:"anthropic.file.id"})},this._client))}}return t.FileNotDownloadableError=va,t.StorageQuotaExceededError=wa,t.FileExpiredError=ka,t})(),gp=(()=>{class t extends R{}return t._errorName="ClaudeCodeKeyCreatorNotMemberError",t})(),mp=(()=>{class t extends R{}return t._errorName="ClaudeCodeVersionTooOldError",t})(),bp=(()=>{class t extends R{}return t._errorName="CMEKKeyDisabledError",t})(),yp=(()=>{class t extends R{}return t._errorName="CMEKKeyNetworkBlockedError",t})(),vp=(()=>{class t extends R{}return t._errorName="OrganizationOnHoldError",t})(),wp=(()=>{class t extends R{}return t._errorName="OrganizationTypeNotSupportedError",t})(),kp=(()=>{class t extends R{}return t._errorName="ParentOrganizationRequiredError",t})(),Ep=(()=>{class t extends R{}return t._errorName="RequestBodyEncodingInvalidError",t})(),Sp=(()=>{class t extends R{}return t._errorName="RequestBodyEncodingUnsupportedError",t})(),xp=(()=>{class t extends R{}return t._errorName="WorkspaceHumanReviewDisabledError",t})(),Tp=(()=>{class t extends Ei{}return t._errorName="LinkedOrganizationBillingUnavailableError",t})(),Ap=(()=>{class t extends Ei{}return t._errorName="LinkedOrganizationSpendLimitReachedError",t})(),Rp=(()=>{class t extends ae{}return t._errorName="SandboxEgressRestrictedError",t})(),zp=(()=>{class t extends ea{}return t._errorName="RequestBodyTooLargeAfterDecodingError",t})(),Pp=(()=>{class t extends rn{}return t._errorName="ContractSpendLimitReachedError",t})(),Cp=(()=>{class t extends rn{}return t._errorName="EnforcedSpendLimitReachedError",t})(),Op=(()=>{class t extends rn{}return t._errorName="RampLimitExceededError",t})(),Np=(()=>{class t extends ot{}return t._errorName="CMEKContextUnavailableError",t})(),Mp=(()=>{class t extends ot{}return t._errorName="CMEKKeyUnreachableError",t})();class fl 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 gl 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 ml 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 bl 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},pp(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 yl=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",ue,{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={},he={},vl;function hy(){if(vl)return he;vl=1;var t=he&&he.__extends||(function(){var _=function(h,p){return _=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(f,y){f.__proto__=y}||function(f,y){for(var b in y)y.hasOwnProperty(b)&&(f[b]=y[b])},_(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(he,"__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 y=h[f]<<16|h[f+1]<<8|h[f+2];p+=this._encodeByte(y>>>18&63),p+=this._encodeByte(y>>>12&63),p+=this._encodeByte(y>>>6&63),p+=this._encodeByte(y>>>0&63)}var b=h.length-f;if(b>0){var y=h[f]<<16|(b===2?h[f+1]<<8:0);p+=this._encodeByte(y>>>18&63),p+=this._encodeByte(y>>>12&63),b===2?p+=this._encodeByte(y>>>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,y=new Uint8Array(this.maxDecodedLength(f)),b=0,v=0,E=0,S=0,T=0,x=0,A=0;v<f-4;v+=4)S=this._decodeChar(h.charCodeAt(v+0)),T=this._decodeChar(h.charCodeAt(v+1)),x=this._decodeChar(h.charCodeAt(v+2)),A=this._decodeChar(h.charCodeAt(v+3)),y[b++]=S<<2|T>>>4,y[b++]=T<<4|x>>>2,y[b++]=x<<6|A,E|=S&n,E|=T&n,E|=x&n,E|=A&n;if(v<f-1&&(S=this._decodeChar(h.charCodeAt(v)),T=this._decodeChar(h.charCodeAt(v+1)),y[b++]=S<<2|T>>>4,E|=S&n,E|=T&n),v<f-2&&(x=this._decodeChar(h.charCodeAt(v+2)),y[b++]=T<<4|x>>>2,E|=x&n),v<f-3&&(A=this._decodeChar(h.charCodeAt(v+3)),y[b++]=x<<6|A,E|=A&n),E!==0)throw new Error("Base64Coder: incorrect characters for decoding");return y},_.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},_})();he.Coder=e;var r=new e;function i(_){return r.encode(_)}he.encode=i;function s(_){return r.decode(_)}he.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);he.URLSafeCoder=a;var c=new a;function l(_){return c.encode(_)}he.encodeURLSafe=l;function d(_){return c.decode(_)}return he.decodeURLSafe=d,he.encodedLength=function(_){return r.encodedLength(_)},he.maxDecodedLength=function(_){return r.maxDecodedLength(_)},he.decodedLength=function(_){return r.decodedLength(_)},he}var ni={exports:{}},_y=ni.exports,wl;function py(){return wl||(wl=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})(_y,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,y,b,v){for(var E,S,T,x,A,O,M,L,F,C,U,Q,de;v>=64;){for(E=f[0],S=f[1],T=f[2],x=f[3],A=f[4],O=f[5],M=f[6],L=f[7],C=0;C<16;C++)U=b+C*4,p[C]=(y[U]&255)<<24|(y[U+1]&255)<<16|(y[U+2]&255)<<8|y[U+3]&255;for(C=16;C<64;C++)F=p[C-2],Q=(F>>>17|F<<15)^(F>>>19|F<<13)^F>>>10,F=p[C-15],de=(F>>>7|F<<25)^(F>>>18|F<<14)^F>>>3,p[C]=(Q+p[C-7]|0)+(de+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&M)|0)+(L+(e[C]+p[C]|0)|0)|0,de=((E>>>2|E<<30)^(E>>>13|E<<19)^(E>>>22|E<<10))+(E&S^E&T^S&T)|0,L=M,M=O,O=A,A=x+Q|0,x=T,T=S,S=E,E=Q+de|0;f[0]+=E,f[1]+=S,f[2]+=T,f[3]+=x,f[4]+=A,f[5]+=O,f[6]+=M,f[7]+=L,b+=64,v-=64}return b}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,y){if(y===void 0&&(y=f.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");var b=0;if(this.bytesHashed+=y,this.bufferLength>0){for(;this.bufferLength<64&&y>0;)this.buffer[this.bufferLength++]=f[b++],y--;this.bufferLength===64&&(r(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(y>=64&&(b=r(this.temp,this.state,f,b,y),y%=64);y>0;)this.buffer[this.bufferLength++]=f[b++],y--;return this},p.prototype.finish=function(f){if(!this.finished){var y=this.bytesHashed,b=this.bufferLength,v=y/536870912|0,E=y<<3,S=y%64<56?64:128;this.buffer[b]=128;for(var T=b+1;T<S-8;T++)this.buffer[T]=0;this.buffer[S-8]=v>>>24&255,this.buffer[S-7]=v>>>16&255,this.buffer[S-6]=v>>>8&255,this.buffer[S-5]=v>>>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 y=0;y<this.state.length;y++)f[y]=this.state[y]},p.prototype._restoreState=function(f,y){for(var b=0;b<this.state.length;b++)this.state[b]=f[b];this.bytesHashed=y,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 y=new Uint8Array(this.blockSize);if(f.length>this.blockSize)new i().update(f).finish(y).clean();else for(var b=0;b<f.length;b++)y[b]=f[b];for(var b=0;b<y.length;b++)y[b]^=54;this.inner.update(y);for(var b=0;b<y.length;b++)y[b]^=106;this.outer.update(y),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate);for(var b=0;b<y.length;b++)y[b]=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),y=f.digest();return f.clean(),y}n.hash=a,n.default=a;function c(p,f){var y=new s(p).update(f),b=y.digest();return y.clean(),b}n.hmac=c;function l(p,f,y,b){var v=b[0];if(v===0)throw new Error("hkdf: cannot expand more");f.reset(),v>1&&f.update(p),y&&f.update(y),f.update(b),f.finish(p),b[0]++}var d=new Uint8Array(n.digestLength);function _(p,f,y,b){f===void 0&&(f=d),b===void 0&&(b=32);for(var v=new Uint8Array([1]),E=c(f,p),S=new s(E),T=new Uint8Array(S.digestLength),x=T.length,A=new Uint8Array(b),O=0;O<b;O++)x===T.length&&(l(T,S,y,v),x=0),A[O]=T[x++];return S.clean(),T.fill(0),v.fill(0),A}n.hkdf=_;function h(p,f,y,b){for(var v=new s(p),E=v.digestLength,S=new Uint8Array(4),T=new Uint8Array(E),x=new Uint8Array(E),A=new Uint8Array(b),O=0;O*E<b;O++){var M=O+1;S[0]=M>>>24&255,S[1]=M>>>16&255,S[2]=M>>>8&255,S[3]=M>>>0&255,v.reset(),v.update(f),v.update(S),v.finish(x);for(var L=0;L<E;L++)T[L]=x[L];for(var L=2;L<=y;L++){v.reset(),v.update(x).finish(x);for(var F=0;F<E;F++)T[F]^=x[F]}for(var L=0;L<E&&O*E+L<b;L++)A[O*E+L]=T[L]}for(var O=0;O<E;O++)T[O]=x[O]=0;for(var O=0;O<4;O++)S[O]=0;return v.clean(),A}n.pbkdf2=h})})(ni)),ni.exports}var un={},kl;function fy(){if(kl)return un;kl=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 El;function gy(){if(El)return ct;El=1,Object.defineProperty(ct,"__esModule",{value:!0}),ct.Webhook=ct.WebhookVerificationError=void 0;const t=hy(),n=py(),e=fy(),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,y={};for(const M of Object.keys(_))y[M.toLowerCase()]=_[M];const b=y["webhook-id"],v=y["webhook-signature"],E=y["webhook-timestamp"];if(!v||!b||!E)throw new s("Missing required headers");const S=this.verifyTimestamp(E),T=a(d),x=new globalThis.TextEncoder,A=x.encode(this.sign(b,S,T));if(!v.split(" ").some(M=>(0,e.timingSafeEqual)(x.encode(M),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),y=new TextEncoder().encode(`${d}.${f}.`),b=new Uint8Array(y.length+p.length);return b.set(y),b.set(p,y.length),`v1,${t.encode(n.hmac(this.key,b))}`}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 my=gy();let Sl=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 my.Webhook(i).verify(n,r),JSON.parse(n)}},xl=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 Tl=(()=>{class t extends k{constructor(){super(...arguments),this.versions=new xl(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=xl,t})();class Al 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 Rl 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 zl 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 Pl=(()=>{class t extends k{constructor(){super(...arguments),this.cases=new Al(this._client),this.notices=new zl(this._client),this.items=new Rl(this._client)}}return t.Cases=Al,t.Notices=zl,t.Items=Rl,t})(),Cl=(()=>{class t extends k{constructor(){super(...arguments),this.review=new Pl(this._client)}}return t.Review=Pl,t})();let qs=function(){const{crypto:t}=globalThis;if(t?.randomUUID)return qs=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 H&&t.status===n}function by(t){return t instanceof H&&typeof t.status=="number"&&t.status>=400&&t.status<500}function fi(t){return by(t)&&!er(t,408)&&!er(t,409)&&!er(t,429)}function Bp(t,n,e){return Math.min(n*2**t,e)}function yy(t,n){return t+Math.random()*(n-t)}function $p(t){return t*(1-Math.random()*.25)}function qp(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 vy={},Nt,dn,_e,hn,_n,pn,_r,pr,Mt,Bt,fn,$t,fr;const wy=999,ky=1e3,Ey=6e4,Sy=3e5;var Is=(()=>{class t{constructor(e){Nt.set(this,void 0),dn.set(this,!1),_e.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??Ay(),w(this,Nt,qp(e.client,{authToken:e.environmentKey,helper:"environments-work-poller"})),w(this,_n,e.autoStop??!0),w(this,pn,e.drain??!1),w(this,_r,e.blockMs===void 0?wy:e.blockMs),w(this,pr,e.reclaimOlderThanMs??null),w(this,Mt,e.requestOptions),w(this,_e,new AbortController),w(this,hn,Zr(e.signal,o(this,_e,"f")))}get signal(){return o(this,_e,"f").signal}abort(){o(this,_e,"f").abort()}async*[(Nt=new WeakMap,dn=new WeakMap,_e=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");w(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 Ty(r,this.environmentId);try{let s=0;for(;!o(this,_e,"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,_e,"f").signal})}catch(c){if(o(this,_e,"f").signal.aborted)return;if(fi(c))throw r.error("poll failed permanently, stopping poller",{error:String(c)}),c;const l=$p(xy(s));r.warn("poll failed, backing off",{error:String(c),backoff_ms:l}),s++,await kt(l,o(this,_e,"f").signal);continue}if(s=0,a==null){if(o(this,pn,"f"))return;i.onEmptyPoll(),await kt(yy(1e3,3e3),o(this,_e,"f").signal);continue}i.onClaim(),this._workSpan=j(this.client,()=>oy(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,_e,"f").signal})}catch(c){r.error("ack failed",{work_id:a.id,error:String(c)}),j(this.client,()=>dp(this._workSpan,o(this,_e,"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)})}j(this.client,()=>up(this._workSpan,o(this,_e,"f").signal))}}}finally{o(this,hn,"f").call(this)}}}return t})();function xy(t){return Bp(t,ky,Ey)}var Ty=(()=>{class t{constructor(e,r){Bt.set(this,void 0),fn.set(this,void 0),$t.set(this,void 0),fr.set(this,0),w(this,Bt,e),w(this,fn,r)}onEmptyPoll(){const e=Date.now(),r={component:"work-poller",environment_id:o(this,fn,"f")};o(this,$t,"f")===void 0?(w(this,$t,w(this,fr,e,"f")),o(this,Bt,"f").info("idle; polling for work",r)):e-o(this,fr,"f")>=Sy?(w(this,fr,e),o(this,Bt,"f").info(`still polling; idle for ${Math.round((e-o(this,$t,"f"))/1e3)}s`,r)):o(this,Bt,"f").debug("poll returned no work",r)}onClaim(){w(this,$t,void 0)}}return Bt=new WeakMap,fn=new WeakMap,$t=new WeakMap,fr=new WeakMap,t})();function Ay(){const n=vy?.HOSTNAME;return n?`${n}-${qs()}`:qs()}const Ry=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 qt,Qe,It,zy=(()=>{class t{constructor(){qt.set(this,[]),Qe.set(this,[]),It.set(this,!1)}push(e){if(o(this,It,"f"))return!1;const r=o(this,Qe,"f").shift();return r?r({done:!1,value:e}):o(this,qt,"f").push(e),!0}close(){if(!o(this,It,"f"))for(w(this,It,!0);o(this,Qe,"f").length>0;)o(this,Qe,"f").shift()({done:!0,value:void 0})}next(e){return o(this,qt,"f").length>0?Promise.resolve({done:!1,value:o(this,qt,"f").shift()}):o(this,It,"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,qt,"f").shift()}}return qt=new WeakMap,Qe=new WeakMap,It=new WeakMap,t})(),Ea=(()=>{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 Py="\\x00-\\x1f\\x7f-\\x9f\\u061c\\u200e\\u200f\\u2028\\u2029\\u202a-\\u202e\\u2066-\\u2069",Cy=new RegExp(`[${Py}]+`,"g"),Oy=/[\uD800-\uDFFF]/gu;function gi(t){return t.replace(Oy,"�")}const Ip=4096,Ny=200;function My(t,n=Ip){return Up(gi(t).replace(Cy," ").trim(),n)}function By(t){return My(t,Ny)}function at(t){return By(t).replace(/[' ]+/g," ").trim()}function Lp(t){return`Error: ${t instanceof Error?t.message:String(t)}`}function $y(t){return Up(gi(Lp(t)),Ip)}function Up(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 qy(t){return typeof t=="string"?gi(t):t.filter(n=>n.type==="text"&&n.text!=="").map(n=>({...n,text:gi(n.text)}))}function Ol(t){return"name"in t?t.name:"mcp_server_name"in t?t.mcp_server_name:t.type}function Iy(t){return t instanceof Ea?t.content:Lp(t)}async function Fp(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:Iy(r),isError:!0}}}var gr,gn,Lt,lt,Ut,ze,W,mn,ee,bn,Ft,yn,J,Wt,ke,jt,Ne,mr,Ht,We,vn,br,ie,wn,yr,vr,kn,Nl,Ml,Bl,Ki,$l,En,Sn,Di,ql,xn,Tn,Gi,Il,Ll;const Ul=500,Ly=1e4,Uy=12e4,Fy=3e4,Wy=1e3,jy=3e4,Hy=5*6e4,Ky=6e4;function Wp(t){return t.type!=="session.status_idle"?!1:t.stop_reason?.type!=="requires_action"}function jp(t){return t.type==="user.tool_confirmation"||t.type==="session.thread_status_terminated"}var Dy=(()=>{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),w(this,gr,e),w(this,gn,r)}noteEvent(e){o(this,Ut,"f")&&e.type==="session.thread_status_terminated"&&this.disarm(),!jp(e)&&(w(this,Ut,!1),Wp(e)?this.arm():this.disarm())}noteHistoryRead(e){w(this,Ut,!e)}block(e){o(this,Lt,"f").add(e),o(this,ze,"f")!==void 0&&(w(this,lt,!0),clearTimeout(o(this,ze,"f")),w(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){w(this,lt,!0);return}w(this,lt,!1),o(this,ze,"f")!==void 0&&clearTimeout(o(this,ze,"f")),w(this,ze,setTimeout(o(this,gn,"f"),o(this,gr,"f")))}}disarm(){w(this,lt,!1),o(this,ze,"f")!==void 0&&(clearTimeout(o(this,ze,"f")),w(this,ze,void 0))}}return gr=new WeakMap,gn=new WeakMap,Lt=new WeakMap,lt=new WeakMap,Ut=new WeakMap,ze=new WeakMap,t})(),Ls=(()=>{class t{constructor(e,r){W.add(this),mn.set(this,!1),ee.set(this,void 0),bn.set(this,void 0),Ft.set(this,void 0),yn.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 zy),We.set(this,0),vn.set(this,Hy),br.set(this,null),ie.set(this,void 0),wn.set(this,void 0),yr.set(this,void 0),vr.set(this,!1),this.client=r.client,this.sessionId=e,this.tools=r.tools,this.maxIdleMs=r.maxIdleMs??Ky,w(this,J,B(r.client)),w(this,yn,new Map(r.tools.map(i=>[Ol(i),i]))),w(this,ee,new AbortController),w(this,bn,Zr(r.signal,o(this,ee,"f"))),w(this,Ft,r.requestOptions),w(this,ie,new Dy(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){w(this,vn,e)}async*[(mn=new WeakMap,ee=new WeakMap,bn=new WeakMap,Ft=new WeakMap,yn=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,vn=new WeakMap,br=new WeakMap,ie=new WeakMap,wn=new WeakMap,yr=new WeakMap,vr=new WeakMap,W=new WeakSet,Symbol.asyncIterator)](){if(o(this,mn,"f"))throw new P("Cannot iterate over a consumed SessionToolRunner");w(this,mn,!0),w(this,wn,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,W,"m",Nl).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,W,"m",Ll).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:Ol(r),error:String(i)})}o(this,bn,"f").call(this)}}}return kn=function(){return{...o(this,Ft,"f"),headers:g([ba("session-tool-runner"),o(this,Ft,"f")?.headers]),signal:o(this,ee,"f").signal}},Nl=async function(){const e=o(this,ee,"f");let r=Ul;for(;!e.signal.aborted;){try{const i=await this.client.beta.sessions.events.stream(this.sessionId,{},o(this,W,"m",kn).call(this));await o(this,W,"m",Ml).call(this);for await(const s of i)if(r=Ul,await o(this,W,"m",$l).call(this,s))return}catch(i){if(e.signal.throwIfAborted(),fi(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,Ly)}},Ml=async function(){const e=o(this,ee,"f"),r=[];let i=!1;w(this,vr,!1);try{for await(const c of this.client.beta.sessions.events.list(this.sessionId,{limit:1e3},o(this,W,"m",kn).call(this)))o(this,W,"m",Bl).call(this,c,r),jp(c)||(i=Wp(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,W,"m",Sn).call(this);return}w(this,vr,!0),o(this,ie,"f").noteHistoryRead(!0),o(this,W,"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,W,"m",Di).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,W,"m",xn).call(this,c,l)}const a=s.filter(c=>!o(this,ke,"f").has(c.id)&&!o(this,W,"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()},Bl=function(e,r){o(this,W,"m",Ki).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)},Ki=function(e){if(!(!this.client._tracer||o(this,yr,"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":w(this,yr,e.session_thread_id)}},$l=async function(e){switch(o(this,ie,"f").noteEvent(e),o(this,vr,"f")&&o(this,W,"m",Ki).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,W,"m",Di).call(this,e)),!1;case"user.tool_confirmation":return await o(this,W,"m",ql).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,W,"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,W,"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))},Di=async function(e){if(o(this,W,"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,W,"m",Gi).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,W,"m",xn).call(this,e,i)},ql=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,W,"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,W,"m",Gi).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,W,"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)},Gi=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}),w(this,We,(i=o(this,We,"f"),i++,i));try{const a=o(this,yn,"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,W,"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,yr,"f")),_=new AbortController,h=Zr(o(this,ee,"f").signal,_),p=setTimeout(()=>_.abort(),Uy);try{const b={signal:o(this,ee,"f").signal,conversationId:d,sessionID:this.sessionId,parentContext:o(this,wn,"f")},v=await ya(this.client,a,e,b,async()=>{const E=await Fp(a,e.input,{toolUse:e,toolUseBlock:e,signal:_.signal}),S=Vy(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=v.sent,l=v.isError}finally{clearTimeout(p),h()}const f=Gy(e,l,c),y=await o(this,W,"m",Il).call(this,f,e.id,d);o(this,W,"m",Tn).call(this,{event:e,result:f,toolUseId:e.id,name:e.name,isError:l,posted:y,confirmation:r})}finally{w(this,We,(s=o(this,We,"f"),s--,s)),o(this,We,"f")===0&&o(this,br,"f")?.call(this)}}},Il=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,W,"m",kn).call(this),openTelemetry:{conversationId:i}}),o(this,ke,"f").add(r),!0}catch(d){if(c=d,fi(d))break;const _=o(this,vn,"f")-(Date.now()-a);if(_<=0)break;const h=Math.min($p(Bp(l-1,Wy,jy)),_);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},Ll=async function(){o(this,We,"f")!==0&&(await Promise.race([new Promise(e=>w(this,br,e)),kt(Fy)]),w(this,br,null),o(this,We,"f")>0&&o(this,J,"f").warn("drain timeout exceeded"))},t})();function Gy(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 Vy(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 Yw=15e3,Fl=5e3;function Jy(t,n){if(!(t>=Fl))throw new P(`${n} must be at least ${Fl}ms (got ${t}); to run without memory sync, pass \`memorySyncIntervalMs: null\` to the worker instead`)}var An,wr,Vi,kr,ut;const Wl=3e4,Yy=9e4,Xy="NO_HEARTBEAT";function Qy(t){return t.resources.some(n=>n.type==="memory_store")}function Zy(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(Ps(Ry(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 jl=(()=>{class t{constructor(e){if(An.add(this),wr.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&&Jy(e.memorySyncIntervalMs,"memorySyncIntervalMs"),this.memorySyncIntervalMs=e.memorySyncIntervalMs,this.memorySyncDeletions=e.memorySyncDeletions??"enabled",this.workerId=e.workerId,this.requestOptions=e.requestOptions,w(this,wr,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,wr,"f"),a=new Is({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 cy(this.client,l,a.signal,()=>o(this,An,"m",Vi).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??$("ANTHROPIC_WORK_ID"),i=e?.environmentId??$("ANTHROPIC_ENVIRONMENT_ID"),s=e?.sessionId??$("ANTHROPIC_SESSION_ID"),a=(e?.environmentKey??this.environmentKey??$("ANTHROPIC_ENVIRONMENT_KEY"))||void 0,c=e?.workSecret||$("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",Vi).call(this,l,a,e?.signal??o(this,wr,"f"))}}return wr=new WeakMap,An=new WeakSet,Vi=async function(e,r,i,s){const a=B(this.client),c=Zy(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=qp(this.client,{authToken:l,helper:"environments-worker"}),_=e.data.id,h=new AbortController,p=Zr(i,h),f=new tv(h),y=await Fe(()=>import("./node.browser-Dom693pr.js"),__vite__mapDeps([0,1,2]));let b,v;const E=nv(d,e,f,a,this.requestOptions,A=>{b=A,v?._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&&Qy(A))throw new y.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 y.setupSkills(O)}catch(L){a.warn("skill setup failed",{session_id:_,work_id:e.id,error:String(L)})}c!==null&&this.memorySyncIntervalMs!==null?(T=new y.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 M=typeof this.tools=="function"?this.tools(O):this.tools??y.betaAgentToolset20260401(O);v=new Ls(_,{client:d,tools:M,...this.maxIdleMs!==void 0?{maxIdleMs:this.maxIdleMs}:{},...this.requestOptions!==void 0?{requestOptions:this.requestOptions}:{},signal:h.signal}),b!==void 0&&v._setSendRetryWindow(b);for await(const L of v)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=y.MEMORY_FLUSH_TIMEOUT_MS;x&&await Hl(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 Hl(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(L=>{a.warn("memory store cleanup failed",{session_id:_,work_id:e.id,error:String(L)})})}}f.finish("runner_done"),p(),await E,f.lost?a.info("lease lost; released without stopping it",{session_id:_,work_id:e.id}):await ev(d,e,a,this.requestOptions),(f.lost||f.rejected)&&j(this.client,()=>s?.end())}},t})();async function Hl(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 ev(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 tv=(()=>{class t{constructor(e){kr.set(this,void 0),ut.set(this,void 0),w(this,kr,e)}get signal(){return o(this,kr,"f").signal}finish(e){w(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 rv(t){let n=t instanceof H?t.error:void 0;for(const e of["error","details","current_state"]){if(!se(n))return{};n=n[e]}return se(n)?n:{}}async function nv(t,n,e,r,i,s){let a=Wl,c=Yy,l=Date.now(),d=Xy;const _=async()=>{const h=new AbortController,p=Zr(e.signal,h),f=setTimeout(()=>h.abort(),a);try{const y=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=y.last_heartbeat,y.ttl_seconds>0&&(c=y.ttl_seconds*1e3,a=Math.max(1e3,Math.min(c/2,Wl)),s?.(c)),(y.state==="stopping"||y.state==="stopped")&&(r.info("heartbeat signals shutdown",{work_id:n.id,state:y.state}),e.finish("heartbeat_stop")),y.lease_extended||(r.warn("lease not extended, shutting down",{work_id:n.id}),e.finish("heartbeat_stop"))}catch(y){if(e.signal.throwIfAborted(),er(y,412)){const b=rv(y);r.error("lease lost: heartbeat precondition failed",{work_id:n.id,server_state:b.state,server_ttl_seconds:b.ttl_seconds,server_last_heartbeat:b.last_heartbeat}),e.finish("lease_lost");return}if(fi(y))throw r.error("permanent heartbeat failure",{work_id:n.id,error:String(y)}),e.finish("heartbeat_rejected"),y;if(Date.now()-l>c){r.error("lease assumed lost: no successful heartbeat in ttl",{work_id:n.id,ttl_ms:c,error:String(y)}),e.finish("assumed_lost");return}r.warn("transient heartbeat failure",{work_id:n.id,error:String(y)})}finally{clearTimeout(f),p()}};for(await _();!e.signal.aborted;)await kt(a,e.signal),e.signal.throwIfAborted(),await _()}var Sa=(()=>{class t extends Zs{}return t._errorName="BetaHeartbeatPreconditionFailedError",t})(),Kl=(()=>{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 Is({...e,client:this._client})}worker(e){return new jl({...e,client:this._client})}}return t.BetaHeartbeatPreconditionFailedError=Sa,t.WorkPoller=Is,t.EnvironmentWorker=jl,t})(),xa=(()=>{class t extends R{}return t._errorName="BetaEnvironmentArchivedError",t})(),Ta=(()=>{class t extends R{}return t._errorName="BetaInvalidConfigTypeChangeError",t})(),Aa=(()=>{class t extends R{}return t._errorName="BetaInvalidMetadataError",t})(),Ra=(()=>{class t extends ae{}return t._errorName="BetaEnvironmentCreateDisabledError",t})(),za=(()=>{class t extends ae{}return t._errorName="BetaEnvironmentUpdateDisabledError",t})(),Pa=(()=>{class t extends Ye{}return t._errorName="BetaEnvironmentNotFoundError",t})(),Dl=(()=>{class t extends k{constructor(){super(...arguments),this.work=new Kl(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=xa,t.BetaInvalidConfigTypeChangeError=Ta,t.BetaInvalidMetadataError=Aa,t.BetaEnvironmentCreateDisabledError=Ra,t.BetaEnvironmentUpdateDisabledError=za,t.BetaEnvironmentNotFoundError=Pa,t.Work=Kl,t.BetaHeartbeatPreconditionFailedError=Sa,t})();class Gl 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 Vl 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 Jl=(()=>{class t extends k{constructor(){super(...arguments),this.memories=new Gl(this._client),this.memoryVersions=new Vl(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=Gl,t.MemoryVersions=Vl,t})(),Hp=(()=>{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 I_;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(na(e.body),r,e)}}return t})();let Yl=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",ue,{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)=>Hp.fromResponse(l.response,l.controller))}};const Kp={"claude-opus-4@20250514":8192,"anthropic.claude-opus-4-1-20250805-v1:0":8192,"claude-opus-4-1@20250805":8192},mi={"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"},Dp=["claude-opus-4-6","claude-mythos-preview"];function Gp(t){return t?.output_format??t?.output_config?.format}function Xl(t,n,e){const r=Gp(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}:Ca(t,n,e)}function Ca(t,n,e){let r=null;const i=t.content.map(s=>{if(s.type==="text"){const a=iv(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 iv(t,n){const e=Gp(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 Vp(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},_p(s,a),n?.headers])}function sv(t,n,e){if(!t._tracer)return;const r=Vp(n,e);return u(t,"anthropic.messages.create",e,Ci(t,{body:Us(n),headers:r,stream:!0}))}function Us(t){if(!t.output_format)return t;Oa(t);const{output_format:n,...e}=t;return{...e,output_config:{...t.output_config,format:n}}}function Oa(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 Jp=["true","false","null"],Yp=t=>t===" "||t===" "||t===`
57
+ ${h}`)}return a},m=dy(fp);var va=(()=>{class t extends R{}return t._errorName="FileNotDownloadableError",t})(),wa=(()=>{class t extends R{}return t._errorName="StorageQuotaExceededError",t})(),ka=(()=>{class t extends Ye{}return t._errorName="FileExpiredError",t})(),pl=(()=>{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},pp(s.file),r?.headers]),__span:u(this._client,"anthropic.files.upload",r,{route:"/v1/files",createdIDAttribute:"anthropic.file.id"})},this._client))}}return t.FileNotDownloadableError=va,t.StorageQuotaExceededError=wa,t.FileExpiredError=ka,t})(),gp=(()=>{class t extends R{}return t._errorName="ClaudeCodeKeyCreatorNotMemberError",t})(),mp=(()=>{class t extends R{}return t._errorName="ClaudeCodeVersionTooOldError",t})(),bp=(()=>{class t extends R{}return t._errorName="CMEKKeyDisabledError",t})(),yp=(()=>{class t extends R{}return t._errorName="CMEKKeyNetworkBlockedError",t})(),vp=(()=>{class t extends R{}return t._errorName="OrganizationOnHoldError",t})(),wp=(()=>{class t extends R{}return t._errorName="OrganizationTypeNotSupportedError",t})(),kp=(()=>{class t extends R{}return t._errorName="ParentOrganizationRequiredError",t})(),Ep=(()=>{class t extends R{}return t._errorName="RequestBodyEncodingInvalidError",t})(),Sp=(()=>{class t extends R{}return t._errorName="RequestBodyEncodingUnsupportedError",t})(),xp=(()=>{class t extends R{}return t._errorName="WorkspaceHumanReviewDisabledError",t})(),Tp=(()=>{class t extends Ei{}return t._errorName="LinkedOrganizationBillingUnavailableError",t})(),Ap=(()=>{class t extends Ei{}return t._errorName="LinkedOrganizationSpendLimitReachedError",t})(),Rp=(()=>{class t extends ae{}return t._errorName="SandboxEgressRestrictedError",t})(),zp=(()=>{class t extends ea{}return t._errorName="RequestBodyTooLargeAfterDecodingError",t})(),Pp=(()=>{class t extends rn{}return t._errorName="ContractSpendLimitReachedError",t})(),Cp=(()=>{class t extends rn{}return t._errorName="EnforcedSpendLimitReachedError",t})(),Op=(()=>{class t extends rn{}return t._errorName="RampLimitExceededError",t})(),Np=(()=>{class t extends ot{}return t._errorName="CMEKContextUnavailableError",t})(),Mp=(()=>{class t extends ot{}return t._errorName="CMEKKeyUnreachableError",t})();class fl 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 gl 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 ml 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 bl 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},pp(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 yl=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",ue,{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={},he={},vl;function hy(){if(vl)return he;vl=1;var t=he&&he.__extends||(function(){var _=function(h,p){return _=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(f,y){f.__proto__=y}||function(f,y){for(var b in y)y.hasOwnProperty(b)&&(f[b]=y[b])},_(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(he,"__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 y=h[f]<<16|h[f+1]<<8|h[f+2];p+=this._encodeByte(y>>>18&63),p+=this._encodeByte(y>>>12&63),p+=this._encodeByte(y>>>6&63),p+=this._encodeByte(y>>>0&63)}var b=h.length-f;if(b>0){var y=h[f]<<16|(b===2?h[f+1]<<8:0);p+=this._encodeByte(y>>>18&63),p+=this._encodeByte(y>>>12&63),b===2?p+=this._encodeByte(y>>>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,y=new Uint8Array(this.maxDecodedLength(f)),b=0,v=0,E=0,S=0,T=0,x=0,A=0;v<f-4;v+=4)S=this._decodeChar(h.charCodeAt(v+0)),T=this._decodeChar(h.charCodeAt(v+1)),x=this._decodeChar(h.charCodeAt(v+2)),A=this._decodeChar(h.charCodeAt(v+3)),y[b++]=S<<2|T>>>4,y[b++]=T<<4|x>>>2,y[b++]=x<<6|A,E|=S&n,E|=T&n,E|=x&n,E|=A&n;if(v<f-1&&(S=this._decodeChar(h.charCodeAt(v)),T=this._decodeChar(h.charCodeAt(v+1)),y[b++]=S<<2|T>>>4,E|=S&n,E|=T&n),v<f-2&&(x=this._decodeChar(h.charCodeAt(v+2)),y[b++]=T<<4|x>>>2,E|=x&n),v<f-3&&(A=this._decodeChar(h.charCodeAt(v+3)),y[b++]=x<<6|A,E|=A&n),E!==0)throw new Error("Base64Coder: incorrect characters for decoding");return y},_.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},_})();he.Coder=e;var r=new e;function i(_){return r.encode(_)}he.encode=i;function s(_){return r.decode(_)}he.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);he.URLSafeCoder=a;var c=new a;function l(_){return c.encode(_)}he.encodeURLSafe=l;function d(_){return c.decode(_)}return he.decodeURLSafe=d,he.encodedLength=function(_){return r.encodedLength(_)},he.maxDecodedLength=function(_){return r.maxDecodedLength(_)},he.decodedLength=function(_){return r.decodedLength(_)},he}var ni={exports:{}},_y=ni.exports,wl;function py(){return wl||(wl=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})(_y,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,y,b,v){for(var E,S,T,x,A,O,M,L,F,C,U,Q,de;v>=64;){for(E=f[0],S=f[1],T=f[2],x=f[3],A=f[4],O=f[5],M=f[6],L=f[7],C=0;C<16;C++)U=b+C*4,p[C]=(y[U]&255)<<24|(y[U+1]&255)<<16|(y[U+2]&255)<<8|y[U+3]&255;for(C=16;C<64;C++)F=p[C-2],Q=(F>>>17|F<<15)^(F>>>19|F<<13)^F>>>10,F=p[C-15],de=(F>>>7|F<<25)^(F>>>18|F<<14)^F>>>3,p[C]=(Q+p[C-7]|0)+(de+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&M)|0)+(L+(e[C]+p[C]|0)|0)|0,de=((E>>>2|E<<30)^(E>>>13|E<<19)^(E>>>22|E<<10))+(E&S^E&T^S&T)|0,L=M,M=O,O=A,A=x+Q|0,x=T,T=S,S=E,E=Q+de|0;f[0]+=E,f[1]+=S,f[2]+=T,f[3]+=x,f[4]+=A,f[5]+=O,f[6]+=M,f[7]+=L,b+=64,v-=64}return b}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,y){if(y===void 0&&(y=f.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");var b=0;if(this.bytesHashed+=y,this.bufferLength>0){for(;this.bufferLength<64&&y>0;)this.buffer[this.bufferLength++]=f[b++],y--;this.bufferLength===64&&(r(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(y>=64&&(b=r(this.temp,this.state,f,b,y),y%=64);y>0;)this.buffer[this.bufferLength++]=f[b++],y--;return this},p.prototype.finish=function(f){if(!this.finished){var y=this.bytesHashed,b=this.bufferLength,v=y/536870912|0,E=y<<3,S=y%64<56?64:128;this.buffer[b]=128;for(var T=b+1;T<S-8;T++)this.buffer[T]=0;this.buffer[S-8]=v>>>24&255,this.buffer[S-7]=v>>>16&255,this.buffer[S-6]=v>>>8&255,this.buffer[S-5]=v>>>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 y=0;y<this.state.length;y++)f[y]=this.state[y]},p.prototype._restoreState=function(f,y){for(var b=0;b<this.state.length;b++)this.state[b]=f[b];this.bytesHashed=y,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 y=new Uint8Array(this.blockSize);if(f.length>this.blockSize)new i().update(f).finish(y).clean();else for(var b=0;b<f.length;b++)y[b]=f[b];for(var b=0;b<y.length;b++)y[b]^=54;this.inner.update(y);for(var b=0;b<y.length;b++)y[b]^=106;this.outer.update(y),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate);for(var b=0;b<y.length;b++)y[b]=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),y=f.digest();return f.clean(),y}n.hash=a,n.default=a;function c(p,f){var y=new s(p).update(f),b=y.digest();return y.clean(),b}n.hmac=c;function l(p,f,y,b){var v=b[0];if(v===0)throw new Error("hkdf: cannot expand more");f.reset(),v>1&&f.update(p),y&&f.update(y),f.update(b),f.finish(p),b[0]++}var d=new Uint8Array(n.digestLength);function _(p,f,y,b){f===void 0&&(f=d),b===void 0&&(b=32);for(var v=new Uint8Array([1]),E=c(f,p),S=new s(E),T=new Uint8Array(S.digestLength),x=T.length,A=new Uint8Array(b),O=0;O<b;O++)x===T.length&&(l(T,S,y,v),x=0),A[O]=T[x++];return S.clean(),T.fill(0),v.fill(0),A}n.hkdf=_;function h(p,f,y,b){for(var v=new s(p),E=v.digestLength,S=new Uint8Array(4),T=new Uint8Array(E),x=new Uint8Array(E),A=new Uint8Array(b),O=0;O*E<b;O++){var M=O+1;S[0]=M>>>24&255,S[1]=M>>>16&255,S[2]=M>>>8&255,S[3]=M>>>0&255,v.reset(),v.update(f),v.update(S),v.finish(x);for(var L=0;L<E;L++)T[L]=x[L];for(var L=2;L<=y;L++){v.reset(),v.update(x).finish(x);for(var F=0;F<E;F++)T[F]^=x[F]}for(var L=0;L<E&&O*E+L<b;L++)A[O*E+L]=T[L]}for(var O=0;O<E;O++)T[O]=x[O]=0;for(var O=0;O<4;O++)S[O]=0;return v.clean(),A}n.pbkdf2=h})})(ni)),ni.exports}var un={},kl;function fy(){if(kl)return un;kl=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 El;function gy(){if(El)return ct;El=1,Object.defineProperty(ct,"__esModule",{value:!0}),ct.Webhook=ct.WebhookVerificationError=void 0;const t=hy(),n=py(),e=fy(),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,y={};for(const M of Object.keys(_))y[M.toLowerCase()]=_[M];const b=y["webhook-id"],v=y["webhook-signature"],E=y["webhook-timestamp"];if(!v||!b||!E)throw new s("Missing required headers");const S=this.verifyTimestamp(E),T=a(d),x=new globalThis.TextEncoder,A=x.encode(this.sign(b,S,T));if(!v.split(" ").some(M=>(0,e.timingSafeEqual)(x.encode(M),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),y=new TextEncoder().encode(`${d}.${f}.`),b=new Uint8Array(y.length+p.length);return b.set(y),b.set(p,y.length),`v1,${t.encode(n.hmac(this.key,b))}`}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 my=gy();let Sl=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 my.Webhook(i).verify(n,r),JSON.parse(n)}},xl=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 Tl=(()=>{class t extends k{constructor(){super(...arguments),this.versions=new xl(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=xl,t})();class Al 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 Rl 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 zl 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 Pl=(()=>{class t extends k{constructor(){super(...arguments),this.cases=new Al(this._client),this.notices=new zl(this._client),this.items=new Rl(this._client)}}return t.Cases=Al,t.Notices=zl,t.Items=Rl,t})(),Cl=(()=>{class t extends k{constructor(){super(...arguments),this.review=new Pl(this._client)}}return t.Review=Pl,t})();let qs=function(){const{crypto:t}=globalThis;if(t?.randomUUID)return qs=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 H&&t.status===n}function by(t){return t instanceof H&&typeof t.status=="number"&&t.status>=400&&t.status<500}function fi(t){return by(t)&&!er(t,408)&&!er(t,409)&&!er(t,429)}function Bp(t,n,e){return Math.min(n*2**t,e)}function yy(t,n){return t+Math.random()*(n-t)}function $p(t){return t*(1-Math.random()*.25)}function qp(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 vy={},Nt,dn,_e,hn,_n,pn,_r,pr,Mt,Bt,fn,$t,fr;const wy=999,ky=1e3,Ey=6e4,Sy=3e5;var Is=(()=>{class t{constructor(e){Nt.set(this,void 0),dn.set(this,!1),_e.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??Ay(),w(this,Nt,qp(e.client,{authToken:e.environmentKey,helper:"environments-work-poller"})),w(this,_n,e.autoStop??!0),w(this,pn,e.drain??!1),w(this,_r,e.blockMs===void 0?wy:e.blockMs),w(this,pr,e.reclaimOlderThanMs??null),w(this,Mt,e.requestOptions),w(this,_e,new AbortController),w(this,hn,Zr(e.signal,o(this,_e,"f")))}get signal(){return o(this,_e,"f").signal}abort(){o(this,_e,"f").abort()}async*[(Nt=new WeakMap,dn=new WeakMap,_e=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");w(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 Ty(r,this.environmentId);try{let s=0;for(;!o(this,_e,"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,_e,"f").signal})}catch(c){if(o(this,_e,"f").signal.aborted)return;if(fi(c))throw r.error("poll failed permanently, stopping poller",{error:String(c)}),c;const l=$p(xy(s));r.warn("poll failed, backing off",{error:String(c),backoff_ms:l}),s++,await kt(l,o(this,_e,"f").signal);continue}if(s=0,a==null){if(o(this,pn,"f"))return;i.onEmptyPoll(),await kt(yy(1e3,3e3),o(this,_e,"f").signal);continue}i.onClaim(),this._workSpan=j(this.client,()=>oy(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,_e,"f").signal})}catch(c){r.error("ack failed",{work_id:a.id,error:String(c)}),j(this.client,()=>dp(this._workSpan,o(this,_e,"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)})}j(this.client,()=>up(this._workSpan,o(this,_e,"f").signal))}}}finally{o(this,hn,"f").call(this)}}}return t})();function xy(t){return Bp(t,ky,Ey)}var Ty=(()=>{class t{constructor(e,r){Bt.set(this,void 0),fn.set(this,void 0),$t.set(this,void 0),fr.set(this,0),w(this,Bt,e),w(this,fn,r)}onEmptyPoll(){const e=Date.now(),r={component:"work-poller",environment_id:o(this,fn,"f")};o(this,$t,"f")===void 0?(w(this,$t,w(this,fr,e,"f")),o(this,Bt,"f").info("idle; polling for work",r)):e-o(this,fr,"f")>=Sy?(w(this,fr,e),o(this,Bt,"f").info(`still polling; idle for ${Math.round((e-o(this,$t,"f"))/1e3)}s`,r)):o(this,Bt,"f").debug("poll returned no work",r)}onClaim(){w(this,$t,void 0)}}return Bt=new WeakMap,fn=new WeakMap,$t=new WeakMap,fr=new WeakMap,t})();function Ay(){const n=vy?.HOSTNAME;return n?`${n}-${qs()}`:qs()}const Ry=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 qt,Qe,It,zy=(()=>{class t{constructor(){qt.set(this,[]),Qe.set(this,[]),It.set(this,!1)}push(e){if(o(this,It,"f"))return!1;const r=o(this,Qe,"f").shift();return r?r({done:!1,value:e}):o(this,qt,"f").push(e),!0}close(){if(!o(this,It,"f"))for(w(this,It,!0);o(this,Qe,"f").length>0;)o(this,Qe,"f").shift()({done:!0,value:void 0})}next(e){return o(this,qt,"f").length>0?Promise.resolve({done:!1,value:o(this,qt,"f").shift()}):o(this,It,"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,qt,"f").shift()}}return qt=new WeakMap,Qe=new WeakMap,It=new WeakMap,t})(),Ea=(()=>{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 Py="\\x00-\\x1f\\x7f-\\x9f\\u061c\\u200e\\u200f\\u2028\\u2029\\u202a-\\u202e\\u2066-\\u2069",Cy=new RegExp(`[${Py}]+`,"g"),Oy=/[\uD800-\uDFFF]/gu;function gi(t){return t.replace(Oy,"�")}const Ip=4096,Ny=200;function My(t,n=Ip){return Up(gi(t).replace(Cy," ").trim(),n)}function By(t){return My(t,Ny)}function at(t){return By(t).replace(/[' ]+/g," ").trim()}function Lp(t){return`Error: ${t instanceof Error?t.message:String(t)}`}function $y(t){return Up(gi(Lp(t)),Ip)}function Up(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 qy(t){return typeof t=="string"?gi(t):t.filter(n=>n.type==="text"&&n.text!=="").map(n=>({...n,text:gi(n.text)}))}function Ol(t){return"name"in t?t.name:"mcp_server_name"in t?t.mcp_server_name:t.type}function Iy(t){return t instanceof Ea?t.content:Lp(t)}async function Fp(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:Iy(r),isError:!0}}}var gr,gn,Lt,lt,Ut,ze,W,mn,ee,bn,Ft,yn,J,Wt,ke,jt,Ne,mr,Ht,We,vn,br,ie,wn,yr,vr,kn,Nl,Ml,Bl,Ki,$l,En,Sn,Di,ql,xn,Tn,Gi,Il,Ll;const Ul=500,Ly=1e4,Uy=12e4,Fy=3e4,Wy=1e3,jy=3e4,Hy=5*6e4,Ky=6e4;function Wp(t){return t.type!=="session.status_idle"?!1:t.stop_reason?.type!=="requires_action"}function jp(t){return t.type==="user.tool_confirmation"||t.type==="session.thread_status_terminated"}var Dy=(()=>{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),w(this,gr,e),w(this,gn,r)}noteEvent(e){o(this,Ut,"f")&&e.type==="session.thread_status_terminated"&&this.disarm(),!jp(e)&&(w(this,Ut,!1),Wp(e)?this.arm():this.disarm())}noteHistoryRead(e){w(this,Ut,!e)}block(e){o(this,Lt,"f").add(e),o(this,ze,"f")!==void 0&&(w(this,lt,!0),clearTimeout(o(this,ze,"f")),w(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){w(this,lt,!0);return}w(this,lt,!1),o(this,ze,"f")!==void 0&&clearTimeout(o(this,ze,"f")),w(this,ze,setTimeout(o(this,gn,"f"),o(this,gr,"f")))}}disarm(){w(this,lt,!1),o(this,ze,"f")!==void 0&&(clearTimeout(o(this,ze,"f")),w(this,ze,void 0))}}return gr=new WeakMap,gn=new WeakMap,Lt=new WeakMap,lt=new WeakMap,Ut=new WeakMap,ze=new WeakMap,t})(),Ls=(()=>{class t{constructor(e,r){W.add(this),mn.set(this,!1),ee.set(this,void 0),bn.set(this,void 0),Ft.set(this,void 0),yn.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 zy),We.set(this,0),vn.set(this,Hy),br.set(this,null),ie.set(this,void 0),wn.set(this,void 0),yr.set(this,void 0),vr.set(this,!1),this.client=r.client,this.sessionId=e,this.tools=r.tools,this.maxIdleMs=r.maxIdleMs??Ky,w(this,J,B(r.client)),w(this,yn,new Map(r.tools.map(i=>[Ol(i),i]))),w(this,ee,new AbortController),w(this,bn,Zr(r.signal,o(this,ee,"f"))),w(this,Ft,r.requestOptions),w(this,ie,new Dy(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){w(this,vn,e)}async*[(mn=new WeakMap,ee=new WeakMap,bn=new WeakMap,Ft=new WeakMap,yn=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,vn=new WeakMap,br=new WeakMap,ie=new WeakMap,wn=new WeakMap,yr=new WeakMap,vr=new WeakMap,W=new WeakSet,Symbol.asyncIterator)](){if(o(this,mn,"f"))throw new P("Cannot iterate over a consumed SessionToolRunner");w(this,mn,!0),w(this,wn,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,W,"m",Nl).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,W,"m",Ll).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:Ol(r),error:String(i)})}o(this,bn,"f").call(this)}}}return kn=function(){return{...o(this,Ft,"f"),headers:g([ba("session-tool-runner"),o(this,Ft,"f")?.headers]),signal:o(this,ee,"f").signal}},Nl=async function(){const e=o(this,ee,"f");let r=Ul;for(;!e.signal.aborted;){try{const i=await this.client.beta.sessions.events.stream(this.sessionId,{},o(this,W,"m",kn).call(this));await o(this,W,"m",Ml).call(this);for await(const s of i)if(r=Ul,await o(this,W,"m",$l).call(this,s))return}catch(i){if(e.signal.throwIfAborted(),fi(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,Ly)}},Ml=async function(){const e=o(this,ee,"f"),r=[];let i=!1;w(this,vr,!1);try{for await(const c of this.client.beta.sessions.events.list(this.sessionId,{limit:1e3},o(this,W,"m",kn).call(this)))o(this,W,"m",Bl).call(this,c,r),jp(c)||(i=Wp(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,W,"m",Sn).call(this);return}w(this,vr,!0),o(this,ie,"f").noteHistoryRead(!0),o(this,W,"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,W,"m",Di).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,W,"m",xn).call(this,c,l)}const a=s.filter(c=>!o(this,ke,"f").has(c.id)&&!o(this,W,"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()},Bl=function(e,r){o(this,W,"m",Ki).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)},Ki=function(e){if(!(!this.client._tracer||o(this,yr,"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":w(this,yr,e.session_thread_id)}},$l=async function(e){switch(o(this,ie,"f").noteEvent(e),o(this,vr,"f")&&o(this,W,"m",Ki).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,W,"m",Di).call(this,e)),!1;case"user.tool_confirmation":return await o(this,W,"m",ql).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,W,"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,W,"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))},Di=async function(e){if(o(this,W,"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,W,"m",Gi).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,W,"m",xn).call(this,e,i)},ql=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,W,"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,W,"m",Gi).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,W,"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)},Gi=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}),w(this,We,(i=o(this,We,"f"),i++,i));try{const a=o(this,yn,"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,W,"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,yr,"f")),_=new AbortController,h=Zr(o(this,ee,"f").signal,_),p=setTimeout(()=>_.abort(),Uy);try{const b={signal:o(this,ee,"f").signal,conversationId:d,sessionID:this.sessionId,parentContext:o(this,wn,"f")},v=await ya(this.client,a,e,b,async()=>{const E=await Fp(a,e.input,{toolUse:e,toolUseBlock:e,signal:_.signal}),S=Vy(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=v.sent,l=v.isError}finally{clearTimeout(p),h()}const f=Gy(e,l,c),y=await o(this,W,"m",Il).call(this,f,e.id,d);o(this,W,"m",Tn).call(this,{event:e,result:f,toolUseId:e.id,name:e.name,isError:l,posted:y,confirmation:r})}finally{w(this,We,(s=o(this,We,"f"),s--,s)),o(this,We,"f")===0&&o(this,br,"f")?.call(this)}}},Il=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,W,"m",kn).call(this),openTelemetry:{conversationId:i}}),o(this,ke,"f").add(r),!0}catch(d){if(c=d,fi(d))break;const _=o(this,vn,"f")-(Date.now()-a);if(_<=0)break;const h=Math.min($p(Bp(l-1,Wy,jy)),_);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},Ll=async function(){o(this,We,"f")!==0&&(await Promise.race([new Promise(e=>w(this,br,e)),kt(Fy)]),w(this,br,null),o(this,We,"f")>0&&o(this,J,"f").warn("drain timeout exceeded"))},t})();function Gy(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 Vy(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 Yw=15e3,Fl=5e3;function Jy(t,n){if(!(t>=Fl))throw new P(`${n} must be at least ${Fl}ms (got ${t}); to run without memory sync, pass \`memorySyncIntervalMs: null\` to the worker instead`)}var An,wr,Vi,kr,ut;const Wl=3e4,Yy=9e4,Xy="NO_HEARTBEAT";function Qy(t){return t.resources.some(n=>n.type==="memory_store")}function Zy(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(Ps(Ry(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 jl=(()=>{class t{constructor(e){if(An.add(this),wr.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&&Jy(e.memorySyncIntervalMs,"memorySyncIntervalMs"),this.memorySyncIntervalMs=e.memorySyncIntervalMs,this.memorySyncDeletions=e.memorySyncDeletions??"enabled",this.workerId=e.workerId,this.requestOptions=e.requestOptions,w(this,wr,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,wr,"f"),a=new Is({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 cy(this.client,l,a.signal,()=>o(this,An,"m",Vi).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??$("ANTHROPIC_WORK_ID"),i=e?.environmentId??$("ANTHROPIC_ENVIRONMENT_ID"),s=e?.sessionId??$("ANTHROPIC_SESSION_ID"),a=(e?.environmentKey??this.environmentKey??$("ANTHROPIC_ENVIRONMENT_KEY"))||void 0,c=e?.workSecret||$("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",Vi).call(this,l,a,e?.signal??o(this,wr,"f"))}}return wr=new WeakMap,An=new WeakSet,Vi=async function(e,r,i,s){const a=B(this.client),c=Zy(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=qp(this.client,{authToken:l,helper:"environments-worker"}),_=e.data.id,h=new AbortController,p=Zr(i,h),f=new tv(h),y=await Fe(()=>import("./node.browser-DF3wedOZ.js"),__vite__mapDeps([0,1,2]));let b,v;const E=nv(d,e,f,a,this.requestOptions,A=>{b=A,v?._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&&Qy(A))throw new y.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 y.setupSkills(O)}catch(L){a.warn("skill setup failed",{session_id:_,work_id:e.id,error:String(L)})}c!==null&&this.memorySyncIntervalMs!==null?(T=new y.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 M=typeof this.tools=="function"?this.tools(O):this.tools??y.betaAgentToolset20260401(O);v=new Ls(_,{client:d,tools:M,...this.maxIdleMs!==void 0?{maxIdleMs:this.maxIdleMs}:{},...this.requestOptions!==void 0?{requestOptions:this.requestOptions}:{},signal:h.signal}),b!==void 0&&v._setSendRetryWindow(b);for await(const L of v)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=y.MEMORY_FLUSH_TIMEOUT_MS;x&&await Hl(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 Hl(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(L=>{a.warn("memory store cleanup failed",{session_id:_,work_id:e.id,error:String(L)})})}}f.finish("runner_done"),p(),await E,f.lost?a.info("lease lost; released without stopping it",{session_id:_,work_id:e.id}):await ev(d,e,a,this.requestOptions),(f.lost||f.rejected)&&j(this.client,()=>s?.end())}},t})();async function Hl(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 ev(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 tv=(()=>{class t{constructor(e){kr.set(this,void 0),ut.set(this,void 0),w(this,kr,e)}get signal(){return o(this,kr,"f").signal}finish(e){w(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 rv(t){let n=t instanceof H?t.error:void 0;for(const e of["error","details","current_state"]){if(!se(n))return{};n=n[e]}return se(n)?n:{}}async function nv(t,n,e,r,i,s){let a=Wl,c=Yy,l=Date.now(),d=Xy;const _=async()=>{const h=new AbortController,p=Zr(e.signal,h),f=setTimeout(()=>h.abort(),a);try{const y=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=y.last_heartbeat,y.ttl_seconds>0&&(c=y.ttl_seconds*1e3,a=Math.max(1e3,Math.min(c/2,Wl)),s?.(c)),(y.state==="stopping"||y.state==="stopped")&&(r.info("heartbeat signals shutdown",{work_id:n.id,state:y.state}),e.finish("heartbeat_stop")),y.lease_extended||(r.warn("lease not extended, shutting down",{work_id:n.id}),e.finish("heartbeat_stop"))}catch(y){if(e.signal.throwIfAborted(),er(y,412)){const b=rv(y);r.error("lease lost: heartbeat precondition failed",{work_id:n.id,server_state:b.state,server_ttl_seconds:b.ttl_seconds,server_last_heartbeat:b.last_heartbeat}),e.finish("lease_lost");return}if(fi(y))throw r.error("permanent heartbeat failure",{work_id:n.id,error:String(y)}),e.finish("heartbeat_rejected"),y;if(Date.now()-l>c){r.error("lease assumed lost: no successful heartbeat in ttl",{work_id:n.id,ttl_ms:c,error:String(y)}),e.finish("assumed_lost");return}r.warn("transient heartbeat failure",{work_id:n.id,error:String(y)})}finally{clearTimeout(f),p()}};for(await _();!e.signal.aborted;)await kt(a,e.signal),e.signal.throwIfAborted(),await _()}var Sa=(()=>{class t extends Zs{}return t._errorName="BetaHeartbeatPreconditionFailedError",t})(),Kl=(()=>{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 Is({...e,client:this._client})}worker(e){return new jl({...e,client:this._client})}}return t.BetaHeartbeatPreconditionFailedError=Sa,t.WorkPoller=Is,t.EnvironmentWorker=jl,t})(),xa=(()=>{class t extends R{}return t._errorName="BetaEnvironmentArchivedError",t})(),Ta=(()=>{class t extends R{}return t._errorName="BetaInvalidConfigTypeChangeError",t})(),Aa=(()=>{class t extends R{}return t._errorName="BetaInvalidMetadataError",t})(),Ra=(()=>{class t extends ae{}return t._errorName="BetaEnvironmentCreateDisabledError",t})(),za=(()=>{class t extends ae{}return t._errorName="BetaEnvironmentUpdateDisabledError",t})(),Pa=(()=>{class t extends Ye{}return t._errorName="BetaEnvironmentNotFoundError",t})(),Dl=(()=>{class t extends k{constructor(){super(...arguments),this.work=new Kl(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=xa,t.BetaInvalidConfigTypeChangeError=Ta,t.BetaInvalidMetadataError=Aa,t.BetaEnvironmentCreateDisabledError=Ra,t.BetaEnvironmentUpdateDisabledError=za,t.BetaEnvironmentNotFoundError=Pa,t.Work=Kl,t.BetaHeartbeatPreconditionFailedError=Sa,t})();class Gl 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 Vl 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 Jl=(()=>{class t extends k{constructor(){super(...arguments),this.memories=new Gl(this._client),this.memoryVersions=new Vl(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=Gl,t.MemoryVersions=Vl,t})(),Hp=(()=>{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 I_;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(na(e.body),r,e)}}return t})();let Yl=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",ue,{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)=>Hp.fromResponse(l.response,l.controller))}};const Kp={"claude-opus-4@20250514":8192,"anthropic.claude-opus-4-1-20250805-v1:0":8192,"claude-opus-4-1@20250805":8192},mi={"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"},Dp=["claude-opus-4-6","claude-mythos-preview"];function Gp(t){return t?.output_format??t?.output_config?.format}function Xl(t,n,e){const r=Gp(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}:Ca(t,n,e)}function Ca(t,n,e){let r=null;const i=t.content.map(s=>{if(s.type==="text"){const a=iv(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 iv(t,n){const e=Gp(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 Vp(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},_p(s,a),n?.headers])}function sv(t,n,e){if(!t._tracer)return;const r=Vp(n,e);return u(t,"anthropic.messages.create",e,Ci(t,{body:Us(n),headers:r,stream:!0}))}function Us(t){if(!t.output_format)return t;Oa(t);const{output_format:n,...e}=t;return{...e,output_config:{...t.output_config,format:n}}}function Oa(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 Jp=["true","false","null"],Yp=t=>t===" "||t===" "||t===`
58
58
  `||t==="\r",av=(t,n)=>Jp.some(e=>e!==t&&e.startsWith(t))&&[...n].every(Yp),ov=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(Yp(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(Jp.includes(a))e.push({type:"name",value:a});else if(!av(a,t.slice(n)))return null;continue}return null}return e},cv=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)},lv=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},Ql=t=>t?.type==="string"||t?.type==="number"||t?.type==="name",uv=t=>{let n="";return t.map((e,r)=>{Ql(t[r-1])&&Ql(e)&&(n+=" "),e.type==="string"?n+='"'+e.value+'"':n+=e.value}),n},dv=t=>{const n=ov(t),e=n&&lv(cv(n));return JSON.parse(e?uv(e):t)},tr="__json_buf";function Xp(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?dv(n):{},i=!0),r}}),e}var pe,Ze,Me,Er,Rn,Sr,xr,zn,Tr,Be,Ar,Pn,Cn,dt,On,Nn,Mn,Rr,$e,oe,zr,Ji,Zl,Pr,Yi,Xi,Qi,eu,Zi;function es(t){return t.type==="tool_use"||t.type==="server_tool_use"||t.type==="mcp_tool_use"}var Na=(()=>{class t{constructor(e,r){pe.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,()=>{}),Be.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),$e.set(this,void 0),oe.set(this,void 0),zr.set(this,void 0),Pr.set(this,i=>{if(w(this,Pn,!0),o(this,oe,"f")&&(o(this,oe,"f").streamed=void 0),Tt(i)&&(i=new be),i instanceof be)return w(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)))}),w(this,Er,new Promise((i,s)=>{w(this,Rn,i,"f"),w(this,Sr,s,"f")})),w(this,xr,new Promise((i,s)=>{w(this,zn,i,"f"),w(this,Tr,s,"f")})),o(this,Er,"f").catch(()=>{}),o(this,xr,"f").catch(()=>{}),w(this,Me,e),w(this,Rr,r?.logger??console),w(this,$e,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(){w(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 w(c,Me,{...r,stream:!0}),c._run(()=>c._createMessage((l,d)=>e.create(l,d),{...r,stream:!0},{...i,headers:{...i?.headers,[ma]:"stream"}})),c}_start(e,r,i,s){for(const l of r.messages)this._addMessageParam(l);const a=o(this,$e,"f");w(this,$e,void 0);const c=(l,d)=>e(l,d)._thenUnwrap((_,{options:h})=>(w(this,$e,a),w(this,oe,h.__span),w(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,pe,"m",Yi).call(this),w(this,oe,i?.__span??(o(this,$e,"f")&&sv(o(this,$e,"f"),r,i)),"f");const{response:c,data:l}=await e({...r,stream:!0},{...i,__span:o(this,oe,"f"),signal:this.controller.signal}).withResponse();try{this._connected(c)}catch(d){throw o(this,oe,"f")&&(o(this,oe,"f").failure=d),l.controller.abort(),d}for await(const d of l)try{o(this,pe,"m",Xi).call(this,d)}catch(_){throw o(this,oe,"f")&&(o(this,oe,"f").failure=_),_}if(l.controller.signal?.aborted)throw new be;o(this,pe,"m",Qi).call(this)}finally{s&&a&&s.removeEventListener("abort",a)}}_connected(e){this.ended||(w(this,On,e),w(this,Nn,e?.headers.get("request-id")),w(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,Be,"f")[e]||(o(this,Be,"f")[e]=[])).push({listener:r}),this}off(e,r){const i=o(this,Be,"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,Be,"f")[e]||(o(this,Be,"f")[e]=[])).push({listener:r,once:!0}),this}emitted(e){return new Promise((r,i)=>{w(this,dt,!0),e!=="error"&&this.once("error",i),this.once(e,r)})}async done(){w(this,dt,!0),await o(this,xr,"f")}get currentMessage(){return o(this,Ze,"f")}async finalMessage(){return await this.done(),o(this,pe,"m",Ji).call(this)}async finalText(){return await this.done(),o(this,pe,"m",Zl).call(this)}_emit(e,...r){if(o(this,Ar,"f"))return;e==="end"&&(w(this,Ar,!0),o(this,zn,"f").call(this));const i=o(this,Be,"f")[e];if(i&&(o(this,Be,"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,pe,"m",Ji).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,pe,"m",Yi).call(this),this._connected(null);const a=Je.fromReadableStream(e,this.controller);for await(const c of a)o(this,pe,"m",Xi).call(this,c);if(a.controller.signal?.aborted)throw new be;o(this,pe,"m",Qi).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,Be=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,$e=new WeakMap,oe=new WeakMap,zr=new WeakMap,Pr=new WeakMap,pe=new WeakSet,Ji=function(){if(this.receivedMessages.length===0)throw new P("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},Zl=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(" ")},Yi=function(){this.ended||w(this,Ze,void 0)},Xi=function(r){if(this.ended)return;const i=o(this,pe,"m",eu).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(es(s)&&o(this,Be,"f").inputJson?.length){let a;try{a=s.input}catch(c){o(this,Pr,"f").call(this,o(this,pe,"m",Zi).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,$e,"f")&&o(this,oe,"f")&&o(this,Me,"f")&&ga(o(this,$e,"f"),o(this,oe,"f"),o(this,zr,"f")??o(this,Me,"f"),i),this._addMessageParam(i),this._addMessage(Xl(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":{w(this,Ze,i),o(this,oe,"f")&&o(this,Me,"f")&&(o(this,oe,"f").streamed={body:o(this,zr,"f")??o(this,Me,"f"),message:i});break}}},Qi=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 w(this,Ze,void 0),Xl(r,o(this,Me,"f"),{logger:o(this,Rr,"f")})},eu=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&&es(s)){const a=(s[tr]||"")+r.delta.partial_json;i.content[r.index]=Xp(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&&es(s)&&tr in s){let a;try{a=s.input}catch(c){a={},o(this,Pr,"f").call(this,o(this,pe,"m",Zi).call(this,s,c))}Object.defineProperty(s,"input",{value:a,enumerable:!0,configurable:!0,writable:!0})}return i}default:return i}},Zi=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 Qp={browser_toolset_20260801:"browser",computer_toolset_20260801:"computer"};function sr(t){return Qp[t.type]}function en(t){return"run"in t&&t.type!=null&&Object.prototype.hasOwnProperty.call(Qp,t.type)}var Zp=(()=>{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 Zp{}return t._errorName="ToolsetContractError",t})();const ef="Not executed: an earlier action in this turn failed.",tu={browser:ef,computer:"Not executed: an earlier computer action in this turn failed."};function hv(t){return Object.prototype.hasOwnProperty.call(tu,t)?tu[t]:ef}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 _v(t,n){if(t instanceof Zp)throw t;pv(n.signal)}function pv(t){if(t?.aborted)throw new be}async function fv(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 _v(s,i),bi(n,qy(s instanceof Ea?s.content:$y(s)),!0)}}let ru=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",ue,{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"]})})}},nu=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"]})})}},iu=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 su 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 au 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 ou=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"]})})}},cu=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"]})})}},lu=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 uu 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 du 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 hu 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 _u 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 pu=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"]})})}},fu=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 gu=(()=>{class t extends k{constructor(){super(...arguments),this.projects=new fu(this._client)}}return t.Projects=fu,t})(),mu=(()=>{class t extends k{constructor(){super(...arguments),this.chat=new gu(this._client)}}return t.Chat=gu,t})(),bu=(()=>{class t extends k{constructor(){super(...arguments),this.summaries=new lu(this._client),this.users=new pu(this._client),this.apps=new mu(this._client),this.connectors=new iu(this._client),this.plugins=new ou(this._client),this.skills=new cu(this._client),this.artifacts=new nu(this._client),this.usage=new uu(this._client),this.cost=new su(this._client),this.usageReport=new du(this._client),this.userUsageReport=new _u(this._client),this.costReport=new au(this._client),this.userCostReport=new hu(this._client)}}return t.Summaries=lu,t.Users=pu,t.Apps=mu,t.Connectors=iu,t.Plugins=ou,t.Skills=cu,t.Artifacts=nu,t.Usage=uu,t.Cost=su,t.UsageReport=du,t.UserUsageReport=_u,t.CostReport=au,t.UserCostReport=hu,t})();let yu=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"})})}},vu=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 Ma=(()=>{class t extends R{}return t._errorName="BetaExternalStorageInUseError",t})(),Ba=(()=>{class t extends R{}return t._errorName="BetaExternalStorageInWorkspacePolicyError",t})(),$a=(()=>{class t extends R{}return t._errorName="BetaExternalStorageNotAvailableError",t})(),qa=(()=>{class t extends R{}return t._errorName="BetaGrantRequiredError",t})(),Ia=(()=>{class t extends R{}return t._errorName="BetaInvalidStorageARNError",t})(),La=(()=>{class t extends R{}return t._errorName="BetaProviderNotAllowedError",t})(),Ua=(()=>{class t extends R{}return t._errorName="BetaStorageAttachLimitReachedError",t})(),Fa=(()=>{class t extends R{}return t._errorName="BetaStorageNotAttachableError",t})(),Wa=(()=>{class t extends R{}return t._errorName="BetaStorageProfileStillRequiredError",t})(),ja=(()=>{class t extends R{}return t._errorName="BetaStorageVerificationFailedError",t})(),Ha=(()=>{class t extends R{}return t._errorName="BetaUnsupportedRegionError",t})(),Ka=(()=>{class t extends le{}return t._errorName="BetaStorageAlreadyRegisteredError",t})(),Da=(()=>{class t extends le{}return t._errorName="BetaStorageChangedConcurrentlyError",t})(),wu=(()=>{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=Ma,t.BetaExternalStorageInWorkspacePolicyError=Ba,t.BetaExternalStorageNotAvailableError=$a,t.BetaGrantRequiredError=qa,t.BetaInvalidStorageARNError=Ia,t.BetaProviderNotAllowedError=La,t.BetaStorageAttachLimitReachedError=Ua,t.BetaStorageNotAttachableError=Fa,t.BetaStorageProfileStillRequiredError=Wa,t.BetaStorageVerificationFailedError=ja,t.BetaUnsupportedRegionError=Ha,t.BetaStorageAlreadyRegisteredError=Ka,t.BetaStorageChangedConcurrentlyError=Da,t})();let ku=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",ue,{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 Eu 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 Su=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 Ga=(()=>{class t extends R{}return t._errorName="BetaCannotSignOutPrimaryOwnerError",t})(),Va=(()=>{class t extends R{}return t._errorName="BetaCannotSignOutSelfError",t})(),Ja=(()=>{class t extends ae{}return t._errorName="BetaCannotSignOutManagedMemberError",t})(),Ya=(()=>{class t extends ae{}return t._errorName="BetaCannotSignOutMembershipAdminError",t})(),Xa=(()=>{class t extends ae{}return t._errorName="BetaCannotSignOutOwnerError",t})(),Qa=(()=>{class t extends ae{}return t._errorName="BetaCannotSignOutPrivilegedMemberError",t})(),xu=(()=>{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",ue,{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=Ga,t.BetaCannotSignOutSelfError=Va,t.BetaCannotSignOutManagedMemberError=Ja,t.BetaCannotSignOutMembershipAdminError=Ya,t.BetaCannotSignOutOwnerError=Xa,t.BetaCannotSignOutPrivilegedMemberError=Qa,t})();class Tu 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",ue,{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 Au 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 Ru 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 zu=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 Za=(()=>{class t extends R{}return t._errorName="BetaCMEKFeatureUnsupportedError",t})(),eo=(()=>{class t extends R{}return t._errorName="BetaRBACGroupOrderLimitExceededError",t})(),to=(()=>{class t extends R{}return t._errorName="BetaSettingsDocumentLimitExceededError",t})(),ro=(()=>{class t extends R{}return t._errorName="BetaSettingsHistoryLimitExceededError",t})(),no=(()=>{class t extends Ye{}return t._errorName="BetaRBACGroupManagedSettingsNotFoundError",t})(),Pu=(()=>{class t extends k{constructor(){super(...arguments),this.configuration=new Au(this._client),this.rbacGroups=new zu(this._client),this.rbacGroupDefault=new Ru(this._client)}}return t.BetaCMEKFeatureUnsupportedError=Za,t.BetaRBACGroupOrderLimitExceededError=eo,t.BetaSettingsDocumentLimitExceededError=to,t.BetaSettingsHistoryLimitExceededError=ro,t.BetaRBACGroupManagedSettingsNotFoundError=no,t.Configuration=Au,t.RBACGroups=zu,t.RBACGroupDefault=Ru,t})(),Cu=(()=>{class t extends k{constructor(){super(...arguments),this.managedSettings=new Pu(this._client)}}return t.ManagedSettings=Pu,t.BetaCMEKFeatureUnsupportedError=Za,t.BetaRBACGroupOrderLimitExceededError=eo,t.BetaSettingsDocumentLimitExceededError=to,t.BetaSettingsHistoryLimitExceededError=ro,t.BetaRBACGroupManagedSettingsNotFoundError=no,t})();class Ou 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 Nu 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 Mu 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 Bu=(()=>{class t extends k{constructor(){super(...arguments),this.targets=new Mu(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=Mu,t})(),io=(()=>{class t extends R{}return t._errorName="BetaBundleAttachmentNotSupportedError",t})(),so=(()=>{class t extends R{}return t._errorName="BetaBundleOnCallError",t})(),ao=(()=>{class t extends R{}return t._errorName="BetaSlackChannelSetUpSettingsRefusedError",t})(),oo=(()=>{class t extends ae{}return t._errorName="BetaAPIKeyScopeMissingError",t})(),co=(()=>{class t extends ae{}return t._errorName="BetaClaudeTagWritesNotEnabledError",t})(),lo=(()=>{class t extends ae{}return t._errorName="BetaComplianceConfigurationRestrictedError",t})(),uo=(()=>{class t extends ae{}return t._errorName="BetaOrganizationLevelScopedAPIKeyRequiredError",t})(),ho=(()=>{class t extends Ye{}return t._errorName="BetaSlackChannelSetUpEnvironmentNotFoundError",t})(),_o=(()=>{class t extends le{}return t._errorName="BetaSlackChannelSetUpSettingsConflictError",t})(),$u=(()=>{class t extends k{constructor(){super(...arguments),this.slackChannels=new Ou(this._client),this.slackWorkspaces=new Nu(this._client),this.bundles=new Bu(this._client)}}return t.BetaBundleAttachmentNotSupportedError=io,t.BetaBundleOnCallError=so,t.BetaSlackChannelSetUpSettingsRefusedError=ao,t.BetaAPIKeyScopeMissingError=oo,t.BetaClaudeTagWritesNotEnabledError=co,t.BetaComplianceConfigurationRestrictedError=lo,t.BetaOrganizationLevelScopedAPIKeyRequiredError=uo,t.BetaSlackChannelSetUpEnvironmentNotFoundError=ho,t.BetaSlackChannelSetUpSettingsConflictError=_o,t.SlackChannels=Ou,t.SlackWorkspaces=Nu,t.Bundles=Bu,t})();let qu=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}})})}},Iu=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 Lu=(()=>{class t extends k{constructor(){super(...arguments),this.workspaces=new Iu(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=Iu,t})(),Uu=(()=>{class t extends k{constructor(){super(...arguments),this.issuers=new qu(this._client),this.rules=new Lu(this._client)}}return t.Issuers=qu,t.Rules=Lu,t})();class Fu 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 Wu 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 ju=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 po=(()=>{class t extends R{}return t._errorName="BetaScanFailedError",t})(),fo=(()=>{class t extends le{}return t._errorName="BetaPluginNameTakenError",t})(),go=(()=>{class t extends le{}return t._errorName="BetaScanPendingError",t})(),mo=(()=>{class t extends le{}return t._errorName="BetaSkillNameTakenError",t})(),bo=(()=>{class t extends ot{}return t._errorName="BetaRegistrationPendingError",t})(),Hu=(()=>{class t extends k{constructor(){super(...arguments),this.versions=new ju(this._client),this.installationSettings=new Fu(this._client),this.shares=new Wu(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=po,t.BetaPluginNameTakenError=fo,t.BetaScanPendingError=go,t.BetaSkillNameTakenError=mo,t.BetaRegistrationPendingError=bo,t.Versions=ju,t.InstallationSettings=Fu,t.Shares=Wu,t})();let Ku=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 Du=(()=>{class t extends k{constructor(){super(...arguments),this.dataControls=new Ku(this._client)}}return t.DataControls=Ku,t})(),Gu=(()=>{class t extends k{constructor(){super(...arguments),this.projects=new Du(this._client)}}return t.Projects=Du,t})(),Vu=(()=>{class t extends k{constructor(){super(...arguments),this.google=new Gu(this._client)}}return t.Google=Gu,t})();let Ju=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 yo=(()=>{class t extends Ye{}return t._errorName="BetaRBACGroupNotFoundError",t})(),Yu=(()=>{class t extends k{constructor(){super(...arguments),this.members=new Ju(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=yo,t.Members=Ju,t})();let Xu=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 Qu=(()=>{class t extends k{constructor(){super(...arguments),this.permissions=new Xu(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=Xu,t})();let Zu=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 ed=(()=>{class t extends k{constructor(){super(...arguments),this.workspaces=new Zu(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=Zu,t})();let td=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"]})})}},rd=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 vo=(()=>{class t extends ae{}return t._errorName="BetaSpendLimitsAdminAPIWritesNotEnabledError",t})(),nd=(()=>{class t extends k{constructor(){super(...arguments),this.effective=new td(this._client),this.increaseRequests=new rd(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=vo,t.Effective=td,t.IncreaseRequests=rd,t})();let id=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 sd=(()=>{class t extends k{constructor(){super(...arguments),this.workspaces=new id(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=id,t})();let ad=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`,ue,{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}})})}},od=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}})})}},cd=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 wo=(()=>{class t extends R{}return t._errorName="BetaHumanReviewOnWithExternalStorageError",t})(),ko=(()=>{class t extends R{}return t._errorName="BetaTranscriptsStorageRequiredError",t})(),Eo=(()=>{class t extends le{}return t._errorName="BetaWorkspaceChangedConcurrentlyError",t})(),ld=(()=>{class t extends k{constructor(){super(...arguments),this.rateLimits=new od(this._client),this.members=new ad(this._client),this.serviceAccounts=new cd(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",ue,{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=wo,t.BetaTranscriptsStorageRequiredError=ko,t.BetaWorkspaceChangedConcurrentlyError=Eo,t.RateLimits=od,t.Members=ad,t.ServiceAccounts=cd,t})(),So=(()=>{class t extends R{}return t._errorName="BetaApprovalRequiredError",t})(),xo=(()=>{class t extends R{}return t._errorName="BetaHumanReviewNotAvailableError",t})(),To=(()=>{class t extends R{}return t._errorName="BetaOrganizationNotEligibleError",t})(),Ao=(()=>{class t extends ot{}return t._errorName="BetaAuthorizationCheckUnavailableError",t})(),ud=(()=>{class t extends k{constructor(){super(...arguments),this.apiKeys=new ru(this._client),this.externalKeys=new vu(this._client),this.federation=new Uu(this._client),this.invites=new ku(this._client),this.serviceAccounts=new ed(this._client),this.externalStorage=new wu(this._client),this.providers=new Vu(this._client),this.users=new xu(this._client),this.workspaces=new ld(this._client),this.rateLimits=new Su(this._client),this.complianceSettings=new yu(this._client),this.analytics=new bu(this._client),this.spendLimits=new nd(this._client),this.rbacGroups=new Yu(this._client),this.rbacRoles=new Qu(this._client),this.plugins=new Hu(this._client),this.pluginMarketplaces=new Eu(this._client),this.telemetryDestinations=new sd(this._client),this.webhooks=new Tu(this._client),this.claudeCode=new Cu(this._client),this.claudeTag=new $u(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=So,t.BetaHumanReviewNotAvailableError=xo,t.BetaOrganizationNotEligibleError=To,t.BetaAuthorizationCheckUnavailableError=Ao,t.APIKeys=ru,t.ExternalKeys=vu,t.Federation=Uu,t.Invites=ku,t.ServiceAccounts=ed,t.ExternalStorage=wu,t.BetaExternalStorageInUseError=Ma,t.BetaExternalStorageInWorkspacePolicyError=Ba,t.BetaExternalStorageNotAvailableError=$a,t.BetaGrantRequiredError=qa,t.BetaInvalidStorageARNError=Ia,t.BetaProviderNotAllowedError=La,t.BetaStorageAttachLimitReachedError=Ua,t.BetaStorageNotAttachableError=Fa,t.BetaStorageProfileStillRequiredError=Wa,t.BetaStorageVerificationFailedError=ja,t.BetaUnsupportedRegionError=Ha,t.BetaStorageAlreadyRegisteredError=Ka,t.BetaStorageChangedConcurrentlyError=Da,t.Providers=Vu,t.Users=xu,t.BetaCannotSignOutPrimaryOwnerError=Ga,t.BetaCannotSignOutSelfError=Va,t.BetaCannotSignOutManagedMemberError=Ja,t.BetaCannotSignOutMembershipAdminError=Ya,t.BetaCannotSignOutOwnerError=Xa,t.BetaCannotSignOutPrivilegedMemberError=Qa,t.Workspaces=ld,t.BetaHumanReviewOnWithExternalStorageError=wo,t.BetaTranscriptsStorageRequiredError=ko,t.BetaWorkspaceChangedConcurrentlyError=Eo,t.RateLimits=Su,t.ComplianceSettings=yu,t.Analytics=bu,t.SpendLimits=nd,t.BetaSpendLimitsAdminAPIWritesNotEnabledError=vo,t.RBACGroups=Yu,t.BetaRBACGroupNotFoundError=yo,t.RBACRoles=Qu,t.Plugins=Hu,t.BetaScanFailedError=po,t.BetaPluginNameTakenError=fo,t.BetaScanPendingError=go,t.BetaSkillNameTakenError=mo,t.BetaRegistrationPendingError=bo,t.PluginMarketplaces=Eu,t.TelemetryDestinations=sd,t.Webhooks=Tu,t.ClaudeCode=Cu,t.ClaudeTag=$u,t.BetaBundleAttachmentNotSupportedError=io,t.BetaBundleOnCallError=so,t.BetaSlackChannelSetUpSettingsRefusedError=ao,t.BetaAPIKeyScopeMissingError=oo,t.BetaClaudeTagWritesNotEnabledError=co,t.BetaComplianceConfigurationRestrictedError=lo,t.BetaOrganizationLevelScopedAPIKeyRequiredError=uo,t.BetaSlackChannelSetUpEnvironmentNotFoundError=ho,t.BetaSlackChannelSetUpSettingsConflictError=_o,t})(),dd=(()=>{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 Ls(e,{...r,client:this._client})}}return t.SessionToolRunner=Ls,t})();class hd 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 _d 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 pd=(()=>{class t extends k{constructor(){super(...arguments),this.events=new _d(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=_d,t})(),fd=(()=>{class t extends k{constructor(){super(...arguments),this.events=new dd(this._client),this.resources=new hd(this._client),this.threads=new pd(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:ey(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",uy,{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=dd,t.Resources=hd,t.Threads=pd,t})();let gd=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 md=(()=>{class t extends k{constructor(){super(...arguments),this.versions=new gd(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=gd,t})();class bd 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 yd=(()=>{class t extends k{constructor(){super(...arguments),this.certificates=new bd(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=bd,t})();let vd=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 wd 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 kd=(()=>{class t extends k{constructor(){super(...arguments),this.dataControls=new wd(this._client)}}return t.DataControls=wd,t})(),Ed=(()=>{class t extends k{constructor(){super(...arguments),this.google=new kd(this._client)}}return t.Google=kd,t})(),Sd=(()=>{class t extends k{constructor(){super(...arguments),this.actionURLs=new vd(this._client),this.providers=new Ed(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=vd,t.Providers=Ed,t})();class xd 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 Td=(()=>{class t extends k{constructor(){super(...arguments),this.credentials=new xd(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=xd,t})(),je,Bn,ht,Kt,$n,_t,Dt,qn,Ad,In,Ln,Rd=(()=>{class t extends Na{constructor(e,r,i){super(e,{client:i}),je.add(this),Bn.set(this,void 0),ht.set(this,0),Kt.set(this,[]),$n.set(this,[]),_t.set(this,void 0),Dt.set(this,[]),qn.set(this,!1),w(this,Bn,r)}get toolCalls(){return o(this,$n,"f")}_deliverEvent(e,r){var i;w(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,$n,"f").push(a),super._deliverEvent(e,r),o(this,je,"m",Ad).call(this,e,a),o(this,je,"m",In).call(this)}[(Bn=new WeakMap,ht=new WeakMap,Kt=new WeakMap,$n=new WeakMap,_t=new WeakMap,Dt=new WeakMap,qn=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",In).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 Ad=function(e,r){if(o(this,qn,"f"))return;if(e.type==="content_block_start"&&e.content_block.type==="fallback"){w(this,qn,!0),w(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")}),w(this,_t,void 0)),r&&w(this,_t,r)},In=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,Bn,"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",In).call(this))},t})();function zd(){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,Pd,ts,Cr,Cd,rs,ns,Od,is,Nd;class gv{constructor(n,e,r){this.fields=n,this.ownMessages=e,this.ownCreateOnly=r,this.deferredMessages=[],this.replacementHistory=null,this.createOnly=nf(n)}}var tf=(()=>{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",w(this,re,l),w(this,G,i?{type:"create",replacesLostThread:!1}:{type:"never_threaded"}),w(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",ts).call(this,r)||o(this,Y,"f").push({param:Qt(r),reply:null})}update(e={},r={}){si(e),w(this,re,{...o(this,re,"f"),...vt(e)}),this.options={...this.options,...vt(r)};for(const i of ss)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?w(r,Y,o(this,V,"f").replacementHistory.map(i=>({param:i,reply:null}))):(w(r,X,[...o(this,X,"f")]),w(r,Y,[...o(this,Y,"f")])),o(this,V,"f")&&r.push(o(this,V,"f").deferredMessages),r}setParams({messages:e,...r}){w(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);Md(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}Md(e,o(this,X,"f").map(s=>s.param))||(w(this,X,[]),this.threading&&w(this,G,{type:"create",replacesLostThread:!1})),w(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",ts).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||rf(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",Cd).call(this);const a={};return r.system!==void 0&&(a.system=r.system),r.tools!==void 0&&(a.tools=r.tools),w(this,V,new gv({...o(this,re,"f"),...vt(r)},s,a))}endTurn(e){w(this,V,null),w(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 H))return!1;const r=this.unsupportedRequestBehavior==="continue_unthreaded",i=yv(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=wv(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&&w(this,G,{type:"unthreaded"})}recordPartialReply(e,r){o(this,te,"m",rs).call(this,e)||(o(this,te,"m",ns).call(this,kv(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",rs).call(this,r)||(o(this,te,"m",ns).call(this,r,{partial:!1}),o(this,G,"f").type==="create"&&w(this,re,{...o(this,re,"f"),...e.ownCreateOnly}),this.threading&&(w(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",Od).call(this,r.container.id))}buildCreateArguments(e,r,{stream:i}){o(this,te,"m",is).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?Ws(d):d)}const c={...e.fields,messages:[...a,...o(this,Y,"f").map(l=>l.param)]};if(this.threading&&!c.betas?.includes(Fs)&&(c.betas=[...c.betas??[],Fs]),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 ss)delete c[l]}return{params:c,options:o(this,te,"m",Nd).call(this,r,{stream:i})}}checkNextTurn(e){o(this,te,"m",is).call(this,nf({...o(this,re,"f"),...vt(e)}))}}return re=new WeakMap,X=new WeakMap,Y=new WeakMap,G=new WeakMap,V=new WeakMap,et=new WeakMap,te=new WeakSet,Pd=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},ts=function(e){if("id"in e)return e.id===o(this,te,"a",Pd)?.id;const r=o(this,Y,"f").at(-1)??o(this,X,"f").at(-1);return r?.reply!=null&&Ni(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}`),w(this,G,{type:"create",replacesLostThread:e==="thread_not_found"})},Cd=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;w(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}`)},rs=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)},ns=function(e,{partial:r}){o(this,X,"f").push(...o(this,Y,"f")),w(this,Y,[]),e&&o(this,X,"f").push({param:Qt(e),reply:e,partial:r})},Od=function(e){const{container:r}=o(this,re,"f");r==null?w(this,re,{...o(this,re,"f"),container:e}):typeof r=="object"&&r.id==null&&w(this,re,{...o(this,re,"f"),container:{...r,id:e}})},is=function(e){if(o(this,G,"f").type!=="continue")return;const{createdWith:r}=o(this,G,"f"),i=ss.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.":""))}},Nd=function(e,{stream:r}){const i={...this.options,...vt(e)};return r&&(i.headers=g([{[ma]:"stream"},i.headers])),o(this,G,"f").type!=="never_threaded"&&(i.headers=g([i.headers,ba("message-thread")])),this.threading&&(i.headers=bv(i.headers)),i},t})();const mv=["pause_turn","compaction"];function rf(t){return mv.some(n=>n===t)}const Fs="message-threads-2026-08-12",ss=["system","tools"];function nf(t){return{system:JSON.stringify(t.system),tools:JSON.stringify(t.tools)}}function bv(t){const n=g([t]).values.get("anthropic-beta");return n===null?t:g([t,{"anthropic-beta":F_(n,Fs)}])}function yv(t){const n=sf(t)?.error_code;return vv.find(e=>e===n)??null}const vv=["thread_not_found","thread_already_continued","thread_continue_in_flight"];function wv(t){const n=sf(t);if(n?.error_code!=="thread_unsupported_request")return null;const e=n.unsupported;return Array.isArray(e)?e.map(String):[]}function sf(t){const e=t.error?.error?.details;return se(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 vt(t){return Object.fromEntries(Object.entries(t).filter(([,n])=>n!==void 0))}function kv(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 Ws(t){if(!se(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(Ws):se(i)&&(e[r]=Ws(i))}return e}function Md(t,n){return n.length<=t.length&&n.every((e,r)=>Ni(e,t[r]))}function Ni(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 Bd(t){return t===void 0?[]:Rs(t)?t:[t]}function af(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 I,Gt,pt,N,He,ce,Un,Pe,fe,Ke,qe,tt,Or,De,Ee,Ie,Vt,Jt,ft,Nr,as,Fn,$d,os,cs,qd,Mr,Wn,Id,Ld,ls,jn,Hn,Ud,us;const Fd="a tool runner's toolsets come only from its tools param; change them with setMessagesParams(), or build a new runner",Ev="a tool runner's toolsets come only from its tools param; remove it there with setMessagesParams(), or build a new runner without it";var js=(()=>{class t{constructor(e,r,i){I.add(this),Gt.set(this,!1),pt.set(this,!1),N.set(this,void 0),He.set(this,void 0),ce.set(this,void 0),Un.set(this,void 0),Pe.set(this,void 0),fe.set(this,void 0),Ke.set(this,void 0),qe.set(this,void 0),tt.set(this,void 0),Or.set(this,0),De.set(this,void 0),Ee.set(this,{status:"idle"}),Ie.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);Wd(s._state.params),jd(a),w(this,N,s),w(this,He,vt(a));const{tools:c,messages:l}=s._state.params,d=hp(c,l);"_state"in e||s._state.setMessages(JSON.parse(JSON.stringify(Hd(l)))),w(this,ce,{...i}),w(this,Un,g([ba("BetaToolRunner"),d.length?{[nn]:d.join(", ")}:void 0])),w(this,tt,zd())}async*[(Gt=new WeakMap,pt=new WeakMap,N=new WeakMap,He=new WeakMap,ce=new WeakMap,Un=new WeakMap,Pe=new WeakMap,fe=new WeakMap,Ke=new WeakMap,qe=new WeakMap,tt=new WeakMap,Or=new WeakMap,De=new WeakMap,Ee=new WeakMap,Ie=new WeakMap,Vt=new WeakMap,Jt=new WeakMap,ft=new WeakMap,I=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");w(this,Gt,!0),w(this,pt,!0),w(this,qe,void 0);const r=j(o(this,N,"f")._client,()=>ly(o(this,N,"f")._client,this.params,o(this,ce,"f").openTelemetry?.conversationId));w(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,I,"m",Ud).call(this),o(this,Ee,"f").status==="scheduled"&&Gd(o(this,Vt,"f"))!=="resume"){yield*o(this,I,"m",cs).call(this,o(this,Ee,"f").config);continue}w(this,pt,!1,"f"),w(this,qe,void 0,"f"),w(this,Or,(e=o(this,Or,"f"),e++,e),"f"),w(this,fe,void 0,"f"),yield*o(this,I,"m",as).call(this,o(this,N,"f"));const i=o(this,Pe,"f");if(w(this,Pe,void 0,"f"),await o(this,I,"m",Nr).call(this,async()=>{let a;if(o(this,pt,"f"))w(this,Vt,null,"f"),o(this,Ke,"f")?.abort(),o(this,N,"f")._state.checkNextTurn(Br(o(this,N,"f"))),o(this,N,"f")._state.setMessages(i),a=i.at(-1);else{const l=await o(this,fe,"f"),d=Gd(l.stop_reason);if(w(this,Vt,l.stop_reason,"f"),d==="stop")return"stop";if(d==="resume")return"continue";a=zv(o(this,N,"f").messages)}Kd(a)&&o(this,N,"f")._state.checkNextTurn(Br(o(this,N,"f")));const c=await o(this,I,"m",ls).call(this,a,o(this,ce,"f").signal,o(this,De,"f"));if(c){const l=o(this,N,"f").messages,d=l.map(_=>_.role).lastIndexOf("assistant")+1;o(this,N,"f")._state.setMessages([...l.slice(0,d),c,...l.slice(d)])}else if(!o(this,pt,"f")&&!o(this,N,"f")._state.hasTurnToSend)return"stop";return"continue"})==="stop"){yield*o(this,I,"m",Ld).call(this);break}}finally{o(this,Ke,"f")?.abort(),w(this,Ke,void 0,"f")}if(await o(this,I,"m",os).call(this),!o(this,fe,"f"))throw new P("ToolRunner concluded without a message from the server");o(this,tt,"f").resolve(await o(this,fe,"f")),j(o(this,N,"f")._client,()=>r?.setStatus({code:zt.OK}))}catch(i){throw r&&j(o(this,N,"f")._client,()=>st(r,i)),w(this,Gt,!1),w(this,Pe,void 0),o(this,tt,"f").promise.catch(()=>{}),o(this,tt,"f").reject(i),w(this,tt,zd()),i}finally{j(o(this,N,"f")._client,()=>r?.end()),w(this,De,void 0)}}setMessagesParams(e){const r=typeof e=="function"?e(this.params):e;if(Wd(r),o(this,Ee,"f").status!=="idle"&&ds(r),o(this,Ee,"f").status==="in_flight"&&!xv(r.messages,o(this,N,"f").messages))throw new P(Sv);const{settings:i,threadParams:s}=af(r);jd(i),w(this,He,vt(i)),o(this,Pe,"f")?(w(this,Pe,s.messages),o(this,N,"f")._state.setParams({...s,messages:o(this,N,"f").messages})):o(this,N,"f")._state.setParams(s),w(this,pt,!0),w(this,qe,void 0)}setRequestOptions(e){typeof e=="function"?w(this,ce,e(o(this,ce,"f"))):w(this,ce,{...o(this,ce,"f"),...e})}async generateToolResponse(e=o(this,ce,"f").signal){const r=o(this,N,"f")._client._tracer?xe.active():void 0,i=await o(this,fe,"f")??o(this,N,"f").messages.at(-1);return i?o(this,I,"m",ls).call(this,i,e,r):null}deferToolCall(e){const r=typeof e=="string"?e:e.id;o(this,Ie,"f")&&!o(this,Ie,"f").has(r)&&o(this,Ie,"f").set(r,{status:"held"})}get deferredToolCalls(){const e=o(this,Ke,"f"),r=o(this,Ie,"f");return!(e instanceof Rd)||!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,N,"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"&&(ds(this.params),w(this,Ee,{status:"scheduled",config:e??{type:"summarize"}}))}addTools(...e){const r=o(this,I,"m",jn).call(this);for(const i of e){if(en(i))throw new ii(`addTools() can't add the '${at(sr(i))}' toolset: ${Fd}`);const s=Pv(i);if(r.has(s))throw new ii(`addTools() can't replace the '${at(s)}' toolset: ${Fd}`)}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,I,"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: ${Ev}`)}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 as=async function*(e){await o(this,I,"m",os).call(this),w(this,Ie,void 0);const r=e.messages;r.some(Av)&&o(this,I,"m",Nr).call(this,()=>e._state.setMessages(Hd(r)));const{tools:i}=e._state.params;o(this,He,"f").stream?(w(this,Ke,o(this,I,"m",Nr).call(this,()=>o(this,He,"f").runToolsEagerly?o(this,I,"m",$d).call(this,e):e.stream(void 0,Br(e),o(this,I,"m",Fn).call(this,e)))),i&&e.update({tools:i}),e===o(this,N,"f")&&w(this,Pe,e.messages),w(this,fe,o(this,Ke,"f").finalMessage()),o(this,fe,"f").catch(()=>{}),yield o(this,Ke,"f")):(w(this,fe,o(this,I,"m",Nr).call(this,()=>e.send(void 0,Br(e),o(this,I,"m",Fn).call(this,e)))),i&&e.update({tools:i}),e===o(this,N,"f")&&w(this,Pe,e.messages),yield o(this,fe,"f"))},Fn=function(e){const{headers:r=e._state.options.headers}=o(this,ce,"f");return{...o(this,ce,"f"),headers:g([o(this,Un,"f"),r])}},$d=function(e){const r=new Map;w(this,Ie,r);const i=new Map,s=c=>{const l=r.has(c.id),d=!c.toolset_name&&o(this,I,"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=of(o(this,I,"m",Hn).call(this),_,c,o(this,ce,"f"),o(this,N,"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=cf(o(this,I,"m",Mr).call(this),o(this,I,"m",Wn).call(this),c,o(this,ce,"f"),o(this,N,"f")._client,o(this,De,"f"));h.catch(()=>{}),r.set(c.id,{status:"started",result:h})},a=new Rd(e._state.params,s,e._client);return e._stream(a,void 0,Br(e),o(this,I,"m",Fn).call(this,e)),a},os=async function(){const e=[...o(this,Ie,"f")?.values()??[]].filter(r=>r.status==="started");await Promise.allSettled(e.map(r=>r.result))},cs=async function*(e){ds(this.params),w(this,Ee,{status:"in_flight"}),w(this,qe,void 0);const r=o(this,fe,"f"),i=o(this,I,"m",qd).call(this,e),s=o(this,N,"f").messages.length;try{yield*o(this,I,"m",as).call(this,i);const a=await o(this,fe,"f");if(a.content.some(c=>c.type==="compaction"&&c.content)){o(this,I,"m",Id).call(this);const c={role:a.role,content:a.content},l=o(this,N,"f").messages.slice(s).filter(d=>!Ni(d,c));o(this,N,"f")._state.setMessages([c,...l])}else B(o(this,N,"f")._client).warn("Compaction produced no summary; keeping the conversation as it is."),w(this,fe,r,"f")}finally{w(this,Ee,{status:"idle"}),i._state.threading||o(this,N,"f")._state.stopThreading()}},qd=function(e){const{messages:r,...i}=Tv(o(this,N,"f")._state.params),s=o(this,N,"f").fork();return s._state=o(this,N,"f")._state.fork({...i,compaction:e}),s},Mr=function(){const e=new Map;for(const r of o(this,N,"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,I,"m",Mr).call(this).keys());for(const r of[...this.params.messages,o(this,I,"m",us).call(this)])if(Array.isArray(r.content)){for(const i of r.content)if(r.role==="system")Dd(i,e);else if(r.role==="assistant"&&i.type==="compaction")for(const s of i.tool_changes??[])Dd(s,e)}return e},Id=function(){const e=o(this,I,"m",Wn).call(this);for(const r of o(this,I,"m",Mr).call(this).keys())e.has(r)||o(this,Jt,"f").set(r,null)},Ld=async function*(){if(o(this,Ee,"f").status==="scheduled"){if(Kd(o(this,N,"f").messages.at(-1))){B(o(this,N,"f")._client).warn("The pending compaction was skipped because the last turn ended with tool calls that were not run. Call `compactBeforeNextTurn()` again if you continue the conversation."),w(this,Ee,{status:"idle"});return}yield*o(this,I,"m",cs).call(this,o(this,Ee,"f").config)}},ls=async function(e,r,i){return o(this,qe,"f")!==void 0?o(this,qe,"f"):(w(this,qe,Rv(o(this,I,"m",Hn).call(this),o(this,I,"m",Mr).call(this),o(this,I,"m",Wn).call(this),e,{...o(this,ce,"f"),signal:r},o(this,Ie,"f"),o(this,N,"f")._client,i)),o(this,qe,"f"))},jn=function(){return new Set(o(this,I,"m",Hn).call(this).tools.filter(en).map(sr))},Hn=function(){return{...this.params,tools:o(this,N,"f")._state.params.tools??[]}},Ud=function(){o(this,Vt,"f")==="pause_turn"||o(this,ft,"f").length===0||(o(this,N,"f").append(o(this,I,"m",us).call(this)),w(this,ft,[]))},us=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=Ro(r.tool);e.push({type:"tool_addition",tool:{type:"tool_definition",definition:i}})}return{role:"system",content:e}},t})();const Sv="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 xv(t,n){return t.length===n.length&&t.every((e,r)=>Ni(e,n[r]))}function Wd(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 jd(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 ds(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 Tv(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 Ro(t){if(!("run"in t))return t;const n=$v,e="toJSON"in t&&typeof t.toJSON=="function"?t.toJSON():t;return{...Object.fromEntries(Object.entries(e).filter(([r])=>n.includes(r))),...wt(t)&&{[Ve]:t[Ve]}}}function Br(t){const{tools:n}=t._state.params;return n?{tools:n.map(Ro)}:{}}function Hd(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:Ro(r.tool.definition)}}:r);return{...n,content:e}})}function Av(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 Rv(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 v=h.toolset_name,E=d.get(v)??{tail:Promise.resolve(),failed:!1};d.set(v,E);const S=t.tools.some(x=>en(x)&&sr(x)===v),T=f??E.tail.then(()=>E.failed?bi(h,hv(v),!0):of(t,v,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(v=>en(v)&&sr(v)===h.name)){const v=d.get(h.name)??{tail:Promise.resolve(),failed:!1};return d.set(h.name,v),v.tail=v.tail.then(()=>{v.failed=!0}),Ov(h)}const b=cf(n,e,h,i,a,c);return s?.set(h.id,{status:"started",result:b}),b}))}}async function of(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 ya(i,a,e,c,async()=>{const d=await fv(a,e,{signal:r?.signal});return{block:d,content:d.content??[],isError:d.is_error===!0}})).block}async function cf(t,n,e,r,i,s){const a=n.has(e.name)?t.get(e.name):void 0;if(!a)return Cv(e);const c={signal:r?.signal,conversationId:r?.openTelemetry?.conversationId,parentContext:s},l=await ya(i,a,e,c,()=>Fp(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 zv(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 Kd(t){return Array.isArray(t?.content)&&t.content.some(n=>n.type==="tool_use")}function Pv(t){return(t.type??"custom").replace(/_\d{8}$/,"").replace(/_toolset$/,"")}function Cv(t){return{type:"tool_result",tool_use_id:t.id,content:`Error: Tool '${t.name}' not found`,is_error:!0}}function Ov(t){return{type:"tool_result",tool_use_id:t.id,content:`Error: the '${at(t.name)}' toolset could not run this call${Nv(t.input)}; nothing in the batch was executed`,is_error:!0}}function Nv(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 Dd(t,n){switch(t.type){case"tool_removal":case"tool_addition":Mv(t,n);break}}function Mv(t,n){const e=Bv(t.tool);e!==void 0&&(t.type==="tool_removal"?n.delete(e):n.add(e))}function Bv(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 Gd(t){if(t===null)return"stop";if(rf(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");Oa(e),this._client=n,this._state=new tf({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=>Ca(i,this._state.params,{logger:B(this._client)}))}_send(n,e,r,i){const s=this._state.startTurn(Bd(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 zi(i(l),c.response)})}stream(n,e={},r={}){const i=new Na(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(Bd(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 js(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 Vd=(()=>{class t extends k{constructor(){super(...arguments),this.batches=new Yl(this._client)}create(e,r){const i=Us(e),{betas:s,user_profile_id:a,workspace_id:c,...l}=i;l.model in mi&&console.warn(`The model '${l.model}' is deprecated and will reach end-of-life on ${mi[l.model]}
59
59
  Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`),Dp.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=Kp[l.model]??void 0;d=this._client.calculateNonstreamingTimeout(l.max_tokens,f)}const _={body:l,timeout:d??6e5,...r,headers:Vp(i,r),stream:i.stream??!1,__qualifiers:{beta:"true"}},h=this._client._tracer&&u(this._client,"anthropic.messages.create",r,Ci(this._client,_));ap(this._client,h,l);const p=this._client.post("/v1/messages",{..._,__span:h});return h?p._thenUnwrap(f=>(op(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=>Ca(i,e,{logger:this._client.logger??console}))}stream(e,r){return Na.createMessage(this,e,r,{client:this._client})}countTokens(e,r){const i=Us(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 js(this._client,e,r)}_toolRunnerThread(e){Oa(e);const{settings:r,thread:i,threadParams:s}=af(e),a=new tf({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=Yl,t.BetaToolRunner=js,t.ToolError=Ea,t})();const $v=["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 zo=(()=>{class t extends R{}return t._errorName="BetaCMEKNotApprovedError",t})(),Po=(()=>{class t extends R{}return t._errorName="BetaExternalKeyNotFoundError",t})(),Co=(()=>{class t extends R{}return t._errorName="BetaExternalKeyProviderMismatchError",t})(),Oo=(()=>{class t extends R{}return t._errorName="BetaGCPProjectNotVerifiedError",t})(),No=(()=>{class t extends R{}return t._errorName="BetaOrganizationNotEnrolledInBetaError",t})(),Mo=(()=>{class t extends R{}return t._errorName="BetaRegionNotSupportedError",t})(),Bo=(()=>{class t extends R{}return t._errorName="BetaRequestBodyTimeoutError",t})(),$o=(()=>{class t extends R{}return t._errorName="BetaStorageNotApprovedError",t})(),qo=(()=>{class t extends R{}return t._errorName="BetaUnsupportedCharsetError",t})(),Io=(()=>{class t extends le{}return t._errorName="BetaGCPProjectControlledByAnotherOrganizationError",t})(),Lo=(()=>{class t extends le{}return t._errorName="BetaStorageInUseError",t})(),Jd=(()=>{class t extends k{constructor(){super(...arguments),this.models=new yl(this._client),this.messages=new Vd(this._client),this.agents=new Tl(this._client),this.environments=new Dl(this._client),this.sessions=new fd(this._client),this.deployments=new gl(this._client),this.deploymentRuns=new fl(this._client),this.vaults=new Td(this._client),this.memoryStores=new Jl(this._client),this.files=new bl(this._client),this.skills=new md(this._client),this.webhooks=new Sl(this._client),this.userProfiles=new Sd(this._client),this.dreams=new ml(this._client),this.tunnels=new yd(this._client),this.compliance=new Cl(this._client),this.organization=new ud(this._client)}}return t.BetaCMEKNotApprovedError=zo,t.BetaExternalKeyNotFoundError=Po,t.BetaExternalKeyProviderMismatchError=Co,t.BetaGCPProjectNotVerifiedError=Oo,t.BetaOrganizationNotEnrolledInBetaError=No,t.BetaRegionNotSupportedError=Mo,t.BetaRequestBodyTimeoutError=Bo,t.BetaStorageNotApprovedError=$o,t.BetaUnsupportedCharsetError=qo,t.BetaGCPProjectControlledByAnotherOrganizationError=Io,t.BetaStorageInUseError=Lo,t.Models=yl,t.Messages=Vd,t.Agents=Tl,t.Environments=Dl,t.BetaEnvironmentArchivedError=xa,t.BetaInvalidConfigTypeChangeError=Ta,t.BetaInvalidMetadataError=Aa,t.BetaEnvironmentCreateDisabledError=Ra,t.BetaEnvironmentUpdateDisabledError=za,t.BetaEnvironmentNotFoundError=Pa,t.Sessions=fd,t.Deployments=gl,t.DeploymentRuns=fl,t.Vaults=Td,t.MemoryStores=Jl,t.Files=bl,t.Skills=md,t.Webhooks=Sl,t.UserProfiles=Sd,t.Dreams=ml,t.Tunnels=yd,t.Compliance=Cl,t.Organization=ud,t.BetaApprovalRequiredError=So,t.BetaHumanReviewNotAvailableError=xo,t.BetaOrganizationNotEligibleError=To,t.BetaAuthorizationCheckUnavailableError=Ao,t})();function lf(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},_p(i,s),n?.headers])}function qv(t,n,e){if(!t._tracer)return;const r=lf(n,e);return u(t,"anthropic.messages.create",e,Ci(t,{body:n,headers:r,stream:!0}))}function uf(t){return t?.output_config?.format}function Yd(t,n,e){const r=uf(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}:df(t,n)}function df(t,n,e){let r=null;const i=t.content.map(s=>{if(s.type==="text"){const a=Iv(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 Iv(t,n){const e=uf(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,$r,Kn,qr,Ir,Dn,Lr,Ue,Ur,Gn,Vn,gt,Jn,Yn,Xn,Fr,mt,ge,hs,Xd,_s,ps,fs,gs,Qd;function ms(t){return t.type==="tool_use"||t.type==="server_tool_use"}var Lv=(()=>{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,$r.set(this,void 0),Kn.set(this,()=>{}),qr.set(this,()=>{}),Ir.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),ge.set(this,void 0),_s.set(this,i=>{if(w(this,Gn,!0),o(this,ge,"f")&&(o(this,ge,"f").streamed=void 0),Tt(i)&&(i=new be),i instanceof be)return w(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)))}),w(this,$r,new Promise((i,s)=>{w(this,Kn,i,"f"),w(this,qr,s,"f")})),w(this,Ir,new Promise((i,s)=>{w(this,Dn,i,"f"),w(this,Lr,s,"f")})),o(this,$r,"f").catch(()=>{}),o(this,Ir,"f").catch(()=>{}),w(this,Le,e),w(this,Fr,r?.logger??console),w(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(){w(this,gt,!0);const e=await o(this,$r,"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 w(c,Le,{...r,stream:!0}),c._run(()=>c._createMessage(e,{...r,stream:!0},{...i,headers:{...i?.headers,[ma]:"stream"}})),c}_run(e){e().then(()=>{this._emitFinal(),this._emit("end")},o(this,_s,"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",ps).call(this),w(this,ge,i?.__span??(o(this,mt,"f")&&qv(o(this,mt,"f"),r,i)),"f");const{response:c,data:l}=await e.create({...r,stream:!0},{...i,__span:o(this,ge,"f"),signal:this.controller.signal}).withResponse();try{this._connected(c)}catch(d){throw o(this,ge,"f")&&(o(this,ge,"f").failure=d),l.controller.abort(),d}for await(const d of l)try{o(this,Ae,"m",fs).call(this,d)}catch(_){throw o(this,ge,"f")&&(o(this,ge,"f").failure=_),_}if(l.controller.signal?.aborted)throw new be;o(this,Ae,"m",gs).call(this)}finally{s&&a&&s.removeEventListener("abort",a)}}_connected(e){this.ended||(w(this,Jn,e),w(this,Yn,e?.headers.get("request-id")),w(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)=>{w(this,gt,!0),e!=="error"&&this.once("error",i),this.once(e,r)})}async done(){w(this,gt,!0),await o(this,Ir,"f")}get currentMessage(){return o(this,rt,"f")}async finalMessage(){return await this.done(),o(this,Ae,"m",hs).call(this)}async finalText(){return await this.done(),o(this,Ae,"m",Xd).call(this)}_emit(e,...r){if(o(this,Ur,"f"))return;e==="end"&&(w(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,qr,"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,qr,"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",hs).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",ps).call(this),this._connected(null);const a=Je.fromReadableStream(e,this.controller);for await(const c of a)o(this,Ae,"m",fs).call(this,c);if(a.controller.signal?.aborted)throw new be;o(this,Ae,"m",gs).call(this)}finally{i&&s&&i.removeEventListener("abort",s)}}[(rt=new WeakMap,Le=new WeakMap,$r=new WeakMap,Kn=new WeakMap,qr=new WeakMap,Ir=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,ge=new WeakMap,_s=new WeakMap,Ae=new WeakSet,hs=function(){if(this.receivedMessages.length===0)throw new P("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},Xd=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(" ")},ps=function(){this.ended||w(this,rt,void 0)},fs=function(r){if(this.ended)return;const i=o(this,Ae,"m",Qd).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":{ms(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,ge,"f")&&o(this,Le,"f")&&ga(o(this,mt,"f"),o(this,ge,"f"),o(this,Le,"f"),i),this._addMessageParam(i),this._addMessage(Yd(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":{w(this,rt,i),o(this,ge,"f")&&o(this,Le,"f")&&(o(this,ge,"f").streamed={body:o(this,Le,"f"),message:i});break}}},gs=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 w(this,rt,void 0),Yd(r,o(this,Le,"f"),{logger:o(this,Fr,"f")})},Qd=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&&ms(s)){const a=(s[tr]||"")+r.delta.partial_json;i.content[r.index]=Xp(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&&ms(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 Zd 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",ue,{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)=>Hp.fromResponse(c.response,c.controller))}}var Uo=(()=>{class t extends R{}return t._errorName="AvailableToolsLimitExceededError",t})(),Fo=(()=>{class t extends R{}return t._errorName="CompactionBlockAmbiguousError",t})(),Wo=(()=>{class t extends R{}return t._errorName="CompactionBlockMisplacedError",t})(),jo=(()=>{class t extends R{}return t._errorName="CompactionContentMismatchError",t})(),Ho=(()=>{class t extends R{}return t._errorName="CompactionIncompleteTurnError",t})(),Ko=(()=>{class t extends R{}return t._errorName="CompactionNothingToSummarizeError",t})(),Do=(()=>{class t extends R{}return t._errorName="CompactionSignatureInvalidError",t})(),Go=(()=>{class t extends R{}return t._errorName="CompactionTooManyToolReferencesError",t})(),Vo=(()=>{class t extends R{}return t._errorName="CompactionToolChangesMismatchError",t})(),Jo=(()=>{class t extends R{}return t._errorName="ImageDimensionsTooLargeError",t})(),Yo=(()=>{class t extends R{}return t._errorName="ThreadAlreadyContinuedError",t})(),Xo=(()=>{class t extends R{}return t._errorName="ThreadContinueInFlightError",t})(),Qo=(()=>{class t extends R{}return t._errorName="ThreadFingerprintMismatchError",t})(),Zo=(()=>{class t extends R{}return t._errorName="ThreadUnsupportedRequestError",t})(),ec=(()=>{class t extends R{}return t._errorName="ToolNameConflictError",t})(),tc=(()=>{class t extends R{}return t._errorName="ToolReferenceUnresolvedError",t})(),rc=(()=>{class t extends Ye{}return t._errorName="ThreadNotFoundError",t})(),nc=(()=>{class t extends ta{}return t._errorName="CompactionUnavailableError",t})(),eh=(()=>{class t extends k{constructor(){super(...arguments),this.batches=new Zd(this._client)}create(e,r){const{user_profile_id:i,workspace_id:s,...a}=e;a.model in mi&&console.warn(`The model '${a.model}' is deprecated and will reach end-of-life on ${mi[a.model]}
60
- Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`),Dp.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=Kp[a.model]??void 0;c=this._client.calculateNonstreamingTimeout(a.max_tokens,h)}const l={body:a,timeout:c??6e5,...r,headers:lf(e,r),stream:e.stream??!1},d=this._client._tracer&&u(this._client,"anthropic.messages.create",r,Ci(this._client,l));ap(this._client,d,a);const _=this._client.post("/v1/messages",{...l,__span:d});return d?_._thenUnwrap(h=>(op(this._client,d,a,h),h)):_}parse(e,r){return this.create(e,r).then(i=>df(i,e,{logger:this._client.logger??console}))}stream(e,r){const i=e;return Lv.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=Uo,t.CompactionBlockAmbiguousError=Fo,t.CompactionBlockMisplacedError=Wo,t.CompactionContentMismatchError=jo,t.CompactionIncompleteTurnError=Ho,t.CompactionNothingToSummarizeError=Ko,t.CompactionSignatureInvalidError=Do,t.CompactionTooManyToolReferencesError=Go,t.CompactionToolChangesMismatchError=Vo,t.ImageDimensionsTooLargeError=Jo,t.ThreadAlreadyContinuedError=Yo,t.ThreadContinueInFlightError=Xo,t.ThreadFingerprintMismatchError=Qo,t.ThreadUnsupportedRequestError=Zo,t.ToolNameConflictError=ec,t.ToolReferenceUnresolvedError=tc,t.ThreadNotFoundError=rc,t.CompactionUnavailableError=nc,t.Batches=Zd,t})(),ic=(()=>{class t extends R{}return t._errorName="OrgAPIKeyLimitExceededError",t})(),sc=(()=>{class t extends R{}return t._errorName="WorkspaceAPIKeyLimitExceededError",t})(),th=(()=>{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",ue,{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=ic,t.WorkspaceAPIKeyLimitExceededError=sc,t})(),ac=(()=>{class t extends R{}return t._errorName="ExternalKeyInWorkspacePolicyError",t})(),oc=(()=>{class t extends R{}return t._errorName="ExternalKeyValidationFailedError",t})(),cc=(()=>{class t extends R{}return t._errorName="ExternalKeyValidationTimedOutError",t})(),lc=(()=>{class t extends le{}return t._errorName="ExternalKeyChangedError",t})(),rh=(()=>{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=ac,t.ExternalKeyValidationFailedError=oc,t.ExternalKeyValidationTimedOutError=cc,t.ExternalKeyChangedError=lc,t})(),uc=(()=>{class t extends R{}return t._errorName="AlreadyMemberError",t})(),dc=(()=>{class t extends R{}return t._errorName="CannotInviteEmailsWithUnverifiedDomainsError",t})(),hc=(()=>{class t extends R{}return t._errorName="EmailDomainNotAllowedError",t})(),_c=(()=>{class t extends R{}return t._errorName="InviteAlreadyExistsError",t})(),nh=(()=>{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",ue,{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=uc,t.CannotInviteEmailsWithUnverifiedDomainsError=dc,t.EmailDomainNotAllowedError=hc,t.InviteAlreadyExistsError=_c,t})();class ih 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 sh=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 pc=(()=>{class t extends R{}return t._errorName="CannotRemoveLastMemberError",t})(),ah=(()=>{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",ue,{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=pc,t})();class oh 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 ch 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 lh 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 uh=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 dh 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 hh 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 _h 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 ph=(()=>{class t extends k{constructor(){super(...arguments),this.projects=new _h(this._client)}}return t.Projects=_h,t})(),fh=(()=>{class t extends k{constructor(){super(...arguments),this.chat=new ph(this._client)}}return t.Chat=ph,t})(),gh=(()=>{class t extends k{constructor(){super(...arguments),this.summaries=new dh(this._client),this.users=new hh(this._client),this.apps=new fh(this._client),this.connectors=new ch(this._client),this.plugins=new lh(this._client),this.skills=new uh(this._client),this.artifacts=new oh(this._client)}}return t.Summaries=dh,t.Users=hh,t.Apps=fh,t.Connectors=ch,t.Plugins=lh,t.Skills=uh,t.Artifacts=oh,t})();class mh 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 bh=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 yh=(()=>{class t extends k{constructor(){super(...arguments),this.workspaces=new bh(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=bh,t})(),vh=(()=>{class t extends k{constructor(){super(...arguments),this.issuers=new mh(this._client),this.rules=new yh(this._client)}}return t.Issuers=mh,t.Rules=yh,t})();let wh=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 fc=(()=>{class t extends R{}return t._errorName="RBACGroupGrantsOwnerAccessError",t})(),gc=(()=>{class t extends R{}return t._errorName="RBACGroupOwnerAccessUnconfirmedError",t})(),kh=(()=>{class t extends k{constructor(){super(...arguments),this.members=new wh(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=fc,t.RBACGroupOwnerAccessUnconfirmedError=gc,t.Members=wh,t})();class Eh 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 Sh=(()=>{class t extends k{constructor(){super(...arguments),this.permissions=new Eh(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=Eh,t})();let xh=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 Th=(()=>{class t extends k{constructor(){super(...arguments),this.workspaces=new xh(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=xh,t})();class Ah 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 Rh 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 zh=(()=>{class t extends k{constructor(){super(...arguments),this.effective=new Ah(this._client),this.increaseRequests=new Rh(this._client)}}return t.Effective=Ah,t.IncreaseRequests=Rh,t})();class Ph 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`,ue,{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 Ch 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 Oh 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 mc=(()=>{class t extends R{}return t._errorName="KeyProfileMismatchError",t})(),bc=(()=>{class t extends R{}return t._errorName="StorageProfileMismatchError",t})(),yc=(()=>{class t extends R{}return t._errorName="WorkspaceMemberLimitExceededError",t})(),vc=(()=>{class t extends R{}return t._errorName="WorkspacePolicyViolationError",t})(),wc=(()=>{class t extends le{}return t._errorName="StorageAttachedDuringArchiveError",t})(),kc=(()=>{class t extends ot{}return t._errorName="WorkspaceCreatedIncompleteError",t})(),Nh=(()=>{class t extends k{constructor(){super(...arguments),this.rateLimits=new Ch(this._client),this.members=new Ph(this._client),this.serviceAccounts=new Oh(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",ue,{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=mc,t.StorageProfileMismatchError=bc,t.WorkspaceMemberLimitExceededError=yc,t.WorkspacePolicyViolationError=vc,t.StorageAttachedDuringArchiveError=wc,t.WorkspaceCreatedIncompleteError=kc,t.RateLimits=Ch,t.Members=Ph,t.ServiceAccounts=Oh,t})(),Ec=(()=>{class t extends R{}return t._errorName="OrgMemberLimitExceededError",t})(),Sc=(()=>{class t extends Ye{}return t._errorName="RBACRoleNotFoundError",t})(),xc=(()=>{class t extends le{}return t._errorName="ConcurrentMembershipChangeError",t})(),Tc=(()=>{class t extends ot{}return t._errorName="ChangeOutcomeUnknownError",t})(),Mh=(()=>{class t extends k{constructor(){super(...arguments),this.apiKeys=new th(this._client),this.externalKeys=new rh(this._client),this.federation=new vh(this._client),this.invites=new nh(this._client),this.serviceAccounts=new Th(this._client),this.users=new ah(this._client),this.workspaces=new Nh(this._client),this.rateLimits=new sh(this._client),this.complianceSettings=new ih(this._client),this.analytics=new gh(this._client),this.spendLimits=new zh(this._client),this.rbacGroups=new kh(this._client),this.rbacRoles=new Sh(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=Ec,t.RBACRoleNotFoundError=Sc,t.ConcurrentMembershipChangeError=xc,t.ChangeOutcomeUnknownError=Tc,t.APIKeys=th,t.OrgAPIKeyLimitExceededError=ic,t.WorkspaceAPIKeyLimitExceededError=sc,t.ExternalKeys=rh,t.ExternalKeyInWorkspacePolicyError=ac,t.ExternalKeyValidationFailedError=oc,t.ExternalKeyValidationTimedOutError=cc,t.ExternalKeyChangedError=lc,t.Federation=vh,t.Invites=nh,t.AlreadyMemberError=uc,t.CannotInviteEmailsWithUnverifiedDomainsError=dc,t.EmailDomainNotAllowedError=hc,t.InviteAlreadyExistsError=_c,t.ServiceAccounts=Th,t.Users=ah,t.CannotRemoveLastMemberError=pc,t.Workspaces=Nh,t.KeyProfileMismatchError=mc,t.StorageProfileMismatchError=bc,t.WorkspaceMemberLimitExceededError=yc,t.WorkspacePolicyViolationError=vc,t.StorageAttachedDuringArchiveError=wc,t.WorkspaceCreatedIncompleteError=kc,t.RateLimits=sh,t.ComplianceSettings=ih,t.Analytics=gh,t.SpendLimits=zh,t.RBACGroups=kh,t.RBACGroupGrantsOwnerAccessError=fc,t.RBACGroupOwnerAccessUnconfirmedError=gc,t.RBACRoles=Sh,t})();class Bh 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 Ac=(()=>{class t extends le{}return t._errorName="SkillReadBlockedUndecryptableError",t})(),$h=(()=>{class t extends k{constructor(){super(...arguments),this.versions=new Bh(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=Ac,t.Versions=Bh,t})();class qh 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 Rc=(()=>{class t extends R{}return t._errorName="UserProfileNotFoundError",t})(),zc=(()=>{class t extends R{}return t._errorName="UserProfileRequiredError",t})(),Pc=(()=>{class t extends ae{}return t._errorName="UserProfileBillingNotAuthorizedError",t})(),Cc=(()=>{class t extends ae{}return t._errorName="UserProfileNotBillableError",t})(),Ih=(()=>{class t extends k{constructor(){super(...arguments),this.actionURLs=new qh(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=Rc,t.UserProfileRequiredError=zc,t.UserProfileBillingNotAuthorizedError=Pc,t.UserProfileNotBillableError=Cc,t.ActionURLs=qh,t})();const Uv=new Map([["400 already_member",uc],["400 approval_required",So],["400 available_tools_limit_exceeded",Uo],["400 bundle_attachment_not_supported",io],["400 bundle_on_call",so],["400 cannot_invite_emails_with_unverified_domains",dc],["400 cannot_remove_last_member",pc],["400 cannot_sign_out_primary_owner",Ga],["400 cannot_sign_out_self",Va],["400 claude_code_key_creator_not_member",gp],["400 claude_code_version_too_old",mp],["400 cmek_feature_unsupported",Za],["400 cmek_key_disabled",bp],["400 cmek_key_network_blocked",yp],["400 cmek_not_approved",zo],["400 compaction_block_ambiguous",Fo],["400 compaction_block_misplaced",Wo],["400 compaction_content_mismatch",jo],["400 compaction_incomplete_turn",Ho],["400 compaction_nothing_to_summarize",Ko],["400 compaction_signature_invalid",Do],["400 compaction_too_many_tool_references",Go],["400 compaction_tool_changes_mismatch",Vo],["400 email_domain_not_allowed",hc],["400 environment_archived",xa],["400 external_key_in_workspace_policy",ac],["400 external_key_not_found",Po],["400 external_key_provider_mismatch",Co],["400 external_key_validation_failed",oc],["400 external_key_validation_timed_out",cc],["400 external_storage_in_use",Ma],["400 external_storage_in_workspace_policy",Ba],["400 external_storage_not_available",$a],["400 file_not_downloadable",va],["400 gcp_project_not_verified",Oo],["400 grant_required",qa],["400 human_review_not_available",xo],["400 human_review_on_with_external_storage",wo],["400 image_dimensions_too_large",Jo],["400 invalid_config_type_change",Ta],["400 invalid_metadata",Aa],["400 invalid_storage_arn",Ia],["400 invite_already_exists",_c],["400 key_profile_mismatch",mc],["400 org_api_key_limit_exceeded",ic],["400 org_member_limit_exceeded",Ec],["400 organization_not_eligible",To],["400 organization_not_enrolled_in_beta",No],["400 organization_on_hold",vp],["400 organization_type_not_supported",wp],["400 parent_organization_required",kp],["400 provider_not_allowed",La],["400 rbac_group_grants_owner_access",fc],["400 rbac_group_order_limit_exceeded",eo],["400 rbac_group_owner_access_unconfirmed",gc],["400 region_not_supported",Mo],["400 request_body_encoding_invalid",Ep],["400 request_body_encoding_unsupported",Sp],["400 request_body_timeout",Bo],["400 scan_failed",po],["400 settings_document_limit_exceeded",to],["400 settings_history_limit_exceeded",ro],["400 slack_channel_set_up_settings_refused",ao],["400 storage_attach_limit_reached",Ua],["400 storage_not_approved",$o],["400 storage_not_attachable",Fa],["400 storage_profile_mismatch",bc],["400 storage_profile_still_required",Wa],["400 storage_quota_exceeded",wa],["400 storage_verification_failed",ja],["400 thread_already_continued",Yo],["400 thread_continue_in_flight",Xo],["400 thread_fingerprint_mismatch",Qo],["400 thread_unsupported_request",Zo],["400 tool_name_conflict",ec],["400 tool_reference_unresolved",tc],["400 transcripts_storage_required",ko],["400 unsupported_charset",qo],["400 unsupported_region",Ha],["400 user_profile_not_found",Rc],["400 user_profile_required",zc],["400 workspace_api_key_limit_exceeded",sc],["400 workspace_human_review_disabled",xp],["400 workspace_member_limit_exceeded",yc],["400 workspace_policy_violation",vc],["402 linked_organization_billing_unavailable",Tp],["402 linked_organization_spend_limit_reached",Ap],["403 api_key_scope_missing",oo],["403 cannot_sign_out_managed_member",Ja],["403 cannot_sign_out_membership_admin",Ya],["403 cannot_sign_out_owner",Xa],["403 cannot_sign_out_privileged_member",Qa],["403 claude_tag_writes_not_enabled",co],["403 compliance_configuration_restricted",lo],["403 environment_create_disabled",Ra],["403 environment_update_disabled",za],["403 organization_level_scoped_api_key_required",uo],["403 sandbox_egress_restricted",Rp],["403 spend_limits_admin_api_writes_not_enabled",vo],["403 user_profile_billing_not_authorized",Pc],["403 user_profile_not_billable",Cc],["404 environment_not_found",Pa],["404 file_expired",ka],["404 rbac_group_managed_settings_not_found",no],["404 rbac_group_not_found",yo],["404 rbac_role_not_found",Sc],["404 slack_channel_set_up_environment_not_found",ho],["404 thread_not_found",rc],["409 concurrent_membership_change",xc],["409 external_key_changed",lc],["409 gcp_project_controlled_by_another_organization",Io],["409 plugin_name_taken",fo],["409 scan_pending",go],["409 skill_name_taken",mo],["409 skill_read_blocked_undecryptable",Ac],["409 slack_channel_set_up_settings_conflict",_o],["409 storage_already_registered",Ka],["409 storage_attached_during_archive",wc],["409 storage_changed_concurrently",Da],["409 storage_in_use",Lo],["409 workspace_changed_concurrently",Eo],["412 heartbeat_precondition_failed",Sa],["413 request_body_too_large_after_decoding",zp],["429 contract_spend_limit_reached",Pp],["429 enforced_spend_limit_reached",Cp],["429 ramp_limit_exceeded",Op],["503 authorization_check_unavailable",Ao],["503 change_outcome_unknown",Tc],["503 cmek_context_unavailable",Np],["503 cmek_key_unreachable",Mp],["503 registration_pending",bo],["503 workspace_created_incomplete",kc],["529 compaction_unavailable",nc]]),Fv="urn:ietf:params:oauth:grant-type:jwt-bearer",Wv="refresh_token",hf="/v1/oauth/token",yi="oauth-2025-04-20",jv="oidc-federation-2026-04-01",Hv=120,Oc=30,Kv=5,Lh=1<<20;function _f(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 pf(t,n){const e=await Gv(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 bs=2e3,Dv=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<=bs?t:t.slice(0,bs)+`... <${t.length-bs} more chars>`}return JSON.stringify(Re(n))}if(typeof t=="object"&&!Array.isArray(t)){const n={};for(const[e,r]of Object.entries(t))Dv.has(e)&&(n[e]=r);return n}return null}async function ff(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-JBLNXGXd.js");return{fs:a}},__vite__mapDeps([3,1,2]));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 gf(t,n){const{fs:e,path:r}=await Fe(async()=>{const{fs:a,path:c}=await import("./node.browser-JBLNXGXd.js");return{fs:a,path:c}},__vite__mapDeps([3,1,2])),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 Gv(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>Lh){const c=Lh-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 Vv{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>Hv?e.token:r>Oc?(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<Kv||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 mf="1.0",Jv=/^[A-Za-z0-9_.-]+$/;function bf(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(!Jv.test(t))throw new Error(`profile name "${t}" contains disallowed characters (allowed: letters, digits, '_', '.', '-')`)}const Yv=async t=>{var n,e;const r=await Nc();if(r===null)return null;const i=t==null&&$("ANTHROPIC_PROFILE")!=null;let s=null;if(t==null&&!i){const f=$("ANTHROPIC_ORGANIZATION_ID"),y=$("ANTHROPIC_IDENTITY_TOKEN_FILE"),b=$("ANTHROPIC_FEDERATION_RULE_ID");if(b&&f&&(s={fromFile:!1,config:{organization_id:f,workspace_id:$("ANTHROPIC_WORKSPACE_ID"),base_url:$("ANTHROPIC_BASE_URL"),authentication:{type:"oidc_federation",federation_rule_id:b,service_account_id:$("ANTHROPIC_SERVICE_ACCOUNT_ID"),identity_token:y?{source:"file",path:y}:void 0,scope:$("ANTHROPIC_SCOPE")}}},y||$("ANTHROPIC_IDENTITY_TOKEN")))return s}const a=t??await yf();if(a===null)return null;bf(a);const{fs:c,path:l}=await Fe(async()=>{const{fs:f,path:y}=await import("./node.browser-JBLNXGXd.js");return{fs:f,path:y}},__vite__mapDeps([3,1,2])),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=$("ANTHROPIC_ORGANIZATION_ID")),h.workspace_id??(h.workspace_id=$("ANTHROPIC_WORKSPACE_ID")),h.base_url??(h.base_url=$("ANTHROPIC_BASE_URL")),(n=h.authentication).scope??(n.scope=$("ANTHROPIC_SCOPE")),h.authentication.type==="oidc_federation"){if(!h.authentication.identity_token){const f=$("ANTHROPIC_IDENTITY_TOKEN_FILE");f&&(h.authentication.identity_token={source:"file",path:f})}h.authentication.federation_rule_id||(h.authentication.federation_rule_id=$("ANTHROPIC_FEDERATION_RULE_ID")??""),(e=h.authentication).service_account_id??(e.service_account_id=$("ANTHROPIC_SERVICE_ACCOUNT_ID"))}return{config:h,fromFile:!0}},Xv=async(t,n)=>{if(t?.authentication.credentials_path)return t.authentication.credentials_path;const e=await Nc();if(!e)return null;const r=n??await yf();if(!r)return null;bf(r);const{path:i}=await Fe(async()=>{const{path:s}=await import("./node.browser-JBLNXGXd.js");return{path:s}},__vite__mapDeps([3,1,2]));return i.join(e,"credentials",`${r}.json`)},Nc=async()=>{if(!Qv())return null;const{path:t}=await Fe(async()=>{const{path:s}=await import("./node.browser-JBLNXGXd.js");return{path:s}},__vite__mapDeps([3,1,2])),n=$("ANTHROPIC_CONFIG_DIR");if(n)return n;if(ra()["X-Stainless-OS"]==="Windows"){const s=$("APPDATA");if(s)return t.join(s,"Anthropic");const a=$("USERPROFILE");return a?t.join(a,"AppData","Roaming","Anthropic"):null}const r=$("XDG_CONFIG_HOME");if(r)return t.join(r,"anthropic");const i=$("HOME");return i?t.join(i,".config","anthropic"):null},Qv=()=>{const t=ra()["X-Stainless-Runtime"];return t==="node"||t==="deno"},yf=async()=>{const t=await Nc();if(!t)return null;const n=$("ANTHROPIC_PROFILE");if(n)return n;const{fs:e,path:r}=await Fe(async()=>{const{fs:s,path:a}=await import("./node.browser-JBLNXGXd.js");return{fs:s,path:a}},__vite__mapDeps([3,1,2])),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 Uh(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-JBLNXGXd.js");return{fs:i}},__vite__mapDeps([3,1,2]));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 Zv(t){if(!t)throw new P("Identity token value is empty");return()=>t}function ew(t){return async()=>{_f(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:Fv,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}${hf}`;let i;try{i=await t.fetch(r,{method:"POST",redirect:"manual",headers:{"Content-Type":"application/json","anthropic-beta":`${yi},${jv}`,"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 pf(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 tw(t){return async n=>{const{fs:e}=await Fe(async()=>{const{fs:v}=await import("./node.browser-JBLNXGXd.js");return{fs:v}},__vite__mapDeps([3,1,2]));await ff(t.credentialsPath,t.onSafetyWarning);let r;try{r=await e.promises.readFile(t.credentialsPath,"utf-8")}catch(v){throw new D(`Credentials file not found at ${t.credentialsPath}: ${v}`)}let i;try{i=JSON.parse(r)}catch(v){throw new D(`Credentials file at ${t.credentialsPath} is not valid JSON: ${v}`)}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-Oc))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"})`);_f(t.baseURL);const l={grant_type:Wv,refresh_token:c,client_id:t.clientId},d=`${t.baseURL}${hf}`;let _;try{_=await t.fetch(d,{method:"POST",redirect:"manual",headers:{"Content-Type":"application/json","anthropic-beta":yi,"User-Agent":t.userAgent||`anthropic-sdk-typescript/${Ge} userOAuthProvider`},body:JSON.stringify(l)})}catch(v){throw new D(`User OAuth refresh failed to reach token endpoint: ${v}`)}const h=_.headers.get("Request-Id");if(!_.ok){const v=await _.text().catch(()=>"");throw new D(`User OAuth refresh failed (HTTP ${_.status}): ${Re(v)}`,_.status,Re(v),h)}const p=await pf(_,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 y=St()+f,b=p.refresh_token||c;return await gf(t.credentialsPath,{...i,version:mf,type:"oauth_token",access_token:p.access_token,expires_at:y,refresh_token:b}),{token:p.access_token,expiresAt:y}}}function vf(t,n){const e=t.authentication.credentials_path??null,r=(t.base_url||n.baseURL).replace(/\/+$/,""),i=nw(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 rw(t,n){const e=await Yv(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 Xv(r,n)??void 0}};return vf(s,t)}function nw(t,n,e,r){switch(t.authentication.type){case"oidc_federation":{const i=t.authentication,s=iw(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=ew({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?sw(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 tw({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 iw(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 Uh(t.identity_token.path)}const n=$("ANTHROPIC_IDENTITY_TOKEN_FILE");if(n)return Uh(n);const e=$("ANTHROPIC_IDENTITY_TOKEN");return e?Zv(e):null}function sw(t,n,e,r){return async i=>{const{fs:s}=await Fe(async()=>{const{fs:l}=await import("./node.browser-JBLNXGXd.js");return{fs:l}},__vite__mapDeps([3,1,2]));await ff(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()<_-Oc)return{token:d,expiresAt:_??null}}}catch(l){l?.code!=="ENOENT"&&!(l instanceof SyntaxError)&&e?.(l)}const c=await t(i);try{await gf(n,{...a??{},version:mf,type:"oauth_token",access_token:c.token,expires_at:c.expiresAt})}catch(l){e?.(l)}return c}}const wf=new WeakSet;function kf(t){return typeof t=="object"&&t!==null&&wf.has(t)}function aw(t){const n=new Set;for(;typeof t=="object"&&t!==null&&!n.has(t);){if(n.add(t),kf(t)||Tt(t)||t instanceof At||t instanceof Kg)return!0;t=t.cause}return!1}function Fh(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 cw(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 ow(t,n){const e=new WeakMap;return{options:t,logger:n?B(n):L_(),parse(r){if(t?.stream&&r.ok)return Wh(r,t,n);let i=e.get(r);return i||(i=Wh(r,t,n),e.set(r,i)),i}}}async function Wh(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:zi(await t.clone().json(),t):await t.clone().text()}function cw(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 wf.add(d),d}};const s=ow(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 Ef=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",lw=t=>t!=null&&typeof t=="object"&&typeof t.name=="string"&&typeof t.lastModified=="number"&&Ef(t),uw=t=>t!=null&&typeof t=="object"&&typeof t.url=="string"&&typeof t.blob=="function";async function dw(t,n,e){if(Q_(),t=await t,n||(n=t instanceof File?t.name:ri(t,!0)),lw(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(uw(t)){const i=await t.blob();return n||(n=new URL(t.url).pathname.split(/[\\/]/).pop()),Zt(await Hs(i),n,e)}const r=await Hs(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 Hs(t){let n=[];if(typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer)n.push(t);else if(Ef(t))n.push(t instanceof Blob?t:await t.arrayBuffer());else if(pa(t))for await(const e of t)n.push(...await Hs(e));else{const e=t?.constructor?.name;throw new Error(`Unexpected data type: ${typeof t}${e?`; constructor: ${e}`:""}${hw(t)}`)}return n}function hw(t){return typeof t!="object"||t===null?"":`; props: [${Object.getOwnPropertyNames(t).map(e=>`"${e}"`).join(", ")}]`}class jh 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",ue,{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 ys,vs,Qn,Yt,bt,Hh;let Kh=!1;var _w=(()=>{class t{get credentials(){return this._authState.provider}get openTelemetry(){return o(this,bt,"f")}_instrumentationScope(){return{version:Ge}}constructor({baseURL:e=$("ANTHROPIC_BASE_URL"),apiKey:r,authToken:i,webhookKey:s=$("ANTHROPIC_WEBHOOK_SIGNING_KEY")??null,...a}={}){ys.add(this),this._requestAuthFlags=new WeakMap,Qn.set(this,void 0),Yt.set(this,void 0),bt.set(this,void 0),this._genAIProviderName="anthropic",this._supportsMessageThreads=!1;const c={apiKey:r,authToken:i,...a},l=Ot.filter(v=>c[v]!=null);if(l.length>1){const v=E=>E.map(S=>`\`${S}\``).join(", ");throw new TypeError(`Pass at most one of ${v(Ot)}. Received ${v(l)}.`)}const[d]=l,_=d!=null?null:{apiKey:r===void 0?$("ANTHROPIC_API_KEY"):void 0,authToken:i===void 0?$("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&&Yg())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.`),Dp.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=Kp[a.model]??void 0;c=this._client.calculateNonstreamingTimeout(a.max_tokens,h)}const l={body:a,timeout:c??6e5,...r,headers:lf(e,r),stream:e.stream??!1},d=this._client._tracer&&u(this._client,"anthropic.messages.create",r,Ci(this._client,l));ap(this._client,d,a);const _=this._client.post("/v1/messages",{...l,__span:d});return d?_._thenUnwrap(h=>(op(this._client,d,a,h),h)):_}parse(e,r){return this.create(e,r).then(i=>df(i,e,{logger:this._client.logger??console}))}stream(e,r){const i=e;return Lv.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=Uo,t.CompactionBlockAmbiguousError=Fo,t.CompactionBlockMisplacedError=Wo,t.CompactionContentMismatchError=jo,t.CompactionIncompleteTurnError=Ho,t.CompactionNothingToSummarizeError=Ko,t.CompactionSignatureInvalidError=Do,t.CompactionTooManyToolReferencesError=Go,t.CompactionToolChangesMismatchError=Vo,t.ImageDimensionsTooLargeError=Jo,t.ThreadAlreadyContinuedError=Yo,t.ThreadContinueInFlightError=Xo,t.ThreadFingerprintMismatchError=Qo,t.ThreadUnsupportedRequestError=Zo,t.ToolNameConflictError=ec,t.ToolReferenceUnresolvedError=tc,t.ThreadNotFoundError=rc,t.CompactionUnavailableError=nc,t.Batches=Zd,t})(),ic=(()=>{class t extends R{}return t._errorName="OrgAPIKeyLimitExceededError",t})(),sc=(()=>{class t extends R{}return t._errorName="WorkspaceAPIKeyLimitExceededError",t})(),th=(()=>{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",ue,{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=ic,t.WorkspaceAPIKeyLimitExceededError=sc,t})(),ac=(()=>{class t extends R{}return t._errorName="ExternalKeyInWorkspacePolicyError",t})(),oc=(()=>{class t extends R{}return t._errorName="ExternalKeyValidationFailedError",t})(),cc=(()=>{class t extends R{}return t._errorName="ExternalKeyValidationTimedOutError",t})(),lc=(()=>{class t extends le{}return t._errorName="ExternalKeyChangedError",t})(),rh=(()=>{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=ac,t.ExternalKeyValidationFailedError=oc,t.ExternalKeyValidationTimedOutError=cc,t.ExternalKeyChangedError=lc,t})(),uc=(()=>{class t extends R{}return t._errorName="AlreadyMemberError",t})(),dc=(()=>{class t extends R{}return t._errorName="CannotInviteEmailsWithUnverifiedDomainsError",t})(),hc=(()=>{class t extends R{}return t._errorName="EmailDomainNotAllowedError",t})(),_c=(()=>{class t extends R{}return t._errorName="InviteAlreadyExistsError",t})(),nh=(()=>{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",ue,{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=uc,t.CannotInviteEmailsWithUnverifiedDomainsError=dc,t.EmailDomainNotAllowedError=hc,t.InviteAlreadyExistsError=_c,t})();class ih 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 sh=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 pc=(()=>{class t extends R{}return t._errorName="CannotRemoveLastMemberError",t})(),ah=(()=>{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",ue,{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=pc,t})();class oh 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 ch 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 lh 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 uh=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 dh 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 hh 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 _h 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 ph=(()=>{class t extends k{constructor(){super(...arguments),this.projects=new _h(this._client)}}return t.Projects=_h,t})(),fh=(()=>{class t extends k{constructor(){super(...arguments),this.chat=new ph(this._client)}}return t.Chat=ph,t})(),gh=(()=>{class t extends k{constructor(){super(...arguments),this.summaries=new dh(this._client),this.users=new hh(this._client),this.apps=new fh(this._client),this.connectors=new ch(this._client),this.plugins=new lh(this._client),this.skills=new uh(this._client),this.artifacts=new oh(this._client)}}return t.Summaries=dh,t.Users=hh,t.Apps=fh,t.Connectors=ch,t.Plugins=lh,t.Skills=uh,t.Artifacts=oh,t})();class mh 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 bh=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 yh=(()=>{class t extends k{constructor(){super(...arguments),this.workspaces=new bh(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=bh,t})(),vh=(()=>{class t extends k{constructor(){super(...arguments),this.issuers=new mh(this._client),this.rules=new yh(this._client)}}return t.Issuers=mh,t.Rules=yh,t})();let wh=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 fc=(()=>{class t extends R{}return t._errorName="RBACGroupGrantsOwnerAccessError",t})(),gc=(()=>{class t extends R{}return t._errorName="RBACGroupOwnerAccessUnconfirmedError",t})(),kh=(()=>{class t extends k{constructor(){super(...arguments),this.members=new wh(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=fc,t.RBACGroupOwnerAccessUnconfirmedError=gc,t.Members=wh,t})();class Eh 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 Sh=(()=>{class t extends k{constructor(){super(...arguments),this.permissions=new Eh(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=Eh,t})();let xh=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 Th=(()=>{class t extends k{constructor(){super(...arguments),this.workspaces=new xh(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=xh,t})();class Ah 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 Rh 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 zh=(()=>{class t extends k{constructor(){super(...arguments),this.effective=new Ah(this._client),this.increaseRequests=new Rh(this._client)}}return t.Effective=Ah,t.IncreaseRequests=Rh,t})();class Ph 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`,ue,{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 Ch 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 Oh 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 mc=(()=>{class t extends R{}return t._errorName="KeyProfileMismatchError",t})(),bc=(()=>{class t extends R{}return t._errorName="StorageProfileMismatchError",t})(),yc=(()=>{class t extends R{}return t._errorName="WorkspaceMemberLimitExceededError",t})(),vc=(()=>{class t extends R{}return t._errorName="WorkspacePolicyViolationError",t})(),wc=(()=>{class t extends le{}return t._errorName="StorageAttachedDuringArchiveError",t})(),kc=(()=>{class t extends ot{}return t._errorName="WorkspaceCreatedIncompleteError",t})(),Nh=(()=>{class t extends k{constructor(){super(...arguments),this.rateLimits=new Ch(this._client),this.members=new Ph(this._client),this.serviceAccounts=new Oh(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",ue,{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=mc,t.StorageProfileMismatchError=bc,t.WorkspaceMemberLimitExceededError=yc,t.WorkspacePolicyViolationError=vc,t.StorageAttachedDuringArchiveError=wc,t.WorkspaceCreatedIncompleteError=kc,t.RateLimits=Ch,t.Members=Ph,t.ServiceAccounts=Oh,t})(),Ec=(()=>{class t extends R{}return t._errorName="OrgMemberLimitExceededError",t})(),Sc=(()=>{class t extends Ye{}return t._errorName="RBACRoleNotFoundError",t})(),xc=(()=>{class t extends le{}return t._errorName="ConcurrentMembershipChangeError",t})(),Tc=(()=>{class t extends ot{}return t._errorName="ChangeOutcomeUnknownError",t})(),Mh=(()=>{class t extends k{constructor(){super(...arguments),this.apiKeys=new th(this._client),this.externalKeys=new rh(this._client),this.federation=new vh(this._client),this.invites=new nh(this._client),this.serviceAccounts=new Th(this._client),this.users=new ah(this._client),this.workspaces=new Nh(this._client),this.rateLimits=new sh(this._client),this.complianceSettings=new ih(this._client),this.analytics=new gh(this._client),this.spendLimits=new zh(this._client),this.rbacGroups=new kh(this._client),this.rbacRoles=new Sh(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=Ec,t.RBACRoleNotFoundError=Sc,t.ConcurrentMembershipChangeError=xc,t.ChangeOutcomeUnknownError=Tc,t.APIKeys=th,t.OrgAPIKeyLimitExceededError=ic,t.WorkspaceAPIKeyLimitExceededError=sc,t.ExternalKeys=rh,t.ExternalKeyInWorkspacePolicyError=ac,t.ExternalKeyValidationFailedError=oc,t.ExternalKeyValidationTimedOutError=cc,t.ExternalKeyChangedError=lc,t.Federation=vh,t.Invites=nh,t.AlreadyMemberError=uc,t.CannotInviteEmailsWithUnverifiedDomainsError=dc,t.EmailDomainNotAllowedError=hc,t.InviteAlreadyExistsError=_c,t.ServiceAccounts=Th,t.Users=ah,t.CannotRemoveLastMemberError=pc,t.Workspaces=Nh,t.KeyProfileMismatchError=mc,t.StorageProfileMismatchError=bc,t.WorkspaceMemberLimitExceededError=yc,t.WorkspacePolicyViolationError=vc,t.StorageAttachedDuringArchiveError=wc,t.WorkspaceCreatedIncompleteError=kc,t.RateLimits=sh,t.ComplianceSettings=ih,t.Analytics=gh,t.SpendLimits=zh,t.RBACGroups=kh,t.RBACGroupGrantsOwnerAccessError=fc,t.RBACGroupOwnerAccessUnconfirmedError=gc,t.RBACRoles=Sh,t})();class Bh 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 Ac=(()=>{class t extends le{}return t._errorName="SkillReadBlockedUndecryptableError",t})(),$h=(()=>{class t extends k{constructor(){super(...arguments),this.versions=new Bh(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=Ac,t.Versions=Bh,t})();class qh 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 Rc=(()=>{class t extends R{}return t._errorName="UserProfileNotFoundError",t})(),zc=(()=>{class t extends R{}return t._errorName="UserProfileRequiredError",t})(),Pc=(()=>{class t extends ae{}return t._errorName="UserProfileBillingNotAuthorizedError",t})(),Cc=(()=>{class t extends ae{}return t._errorName="UserProfileNotBillableError",t})(),Ih=(()=>{class t extends k{constructor(){super(...arguments),this.actionURLs=new qh(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=Rc,t.UserProfileRequiredError=zc,t.UserProfileBillingNotAuthorizedError=Pc,t.UserProfileNotBillableError=Cc,t.ActionURLs=qh,t})();const Uv=new Map([["400 already_member",uc],["400 approval_required",So],["400 available_tools_limit_exceeded",Uo],["400 bundle_attachment_not_supported",io],["400 bundle_on_call",so],["400 cannot_invite_emails_with_unverified_domains",dc],["400 cannot_remove_last_member",pc],["400 cannot_sign_out_primary_owner",Ga],["400 cannot_sign_out_self",Va],["400 claude_code_key_creator_not_member",gp],["400 claude_code_version_too_old",mp],["400 cmek_feature_unsupported",Za],["400 cmek_key_disabled",bp],["400 cmek_key_network_blocked",yp],["400 cmek_not_approved",zo],["400 compaction_block_ambiguous",Fo],["400 compaction_block_misplaced",Wo],["400 compaction_content_mismatch",jo],["400 compaction_incomplete_turn",Ho],["400 compaction_nothing_to_summarize",Ko],["400 compaction_signature_invalid",Do],["400 compaction_too_many_tool_references",Go],["400 compaction_tool_changes_mismatch",Vo],["400 email_domain_not_allowed",hc],["400 environment_archived",xa],["400 external_key_in_workspace_policy",ac],["400 external_key_not_found",Po],["400 external_key_provider_mismatch",Co],["400 external_key_validation_failed",oc],["400 external_key_validation_timed_out",cc],["400 external_storage_in_use",Ma],["400 external_storage_in_workspace_policy",Ba],["400 external_storage_not_available",$a],["400 file_not_downloadable",va],["400 gcp_project_not_verified",Oo],["400 grant_required",qa],["400 human_review_not_available",xo],["400 human_review_on_with_external_storage",wo],["400 image_dimensions_too_large",Jo],["400 invalid_config_type_change",Ta],["400 invalid_metadata",Aa],["400 invalid_storage_arn",Ia],["400 invite_already_exists",_c],["400 key_profile_mismatch",mc],["400 org_api_key_limit_exceeded",ic],["400 org_member_limit_exceeded",Ec],["400 organization_not_eligible",To],["400 organization_not_enrolled_in_beta",No],["400 organization_on_hold",vp],["400 organization_type_not_supported",wp],["400 parent_organization_required",kp],["400 provider_not_allowed",La],["400 rbac_group_grants_owner_access",fc],["400 rbac_group_order_limit_exceeded",eo],["400 rbac_group_owner_access_unconfirmed",gc],["400 region_not_supported",Mo],["400 request_body_encoding_invalid",Ep],["400 request_body_encoding_unsupported",Sp],["400 request_body_timeout",Bo],["400 scan_failed",po],["400 settings_document_limit_exceeded",to],["400 settings_history_limit_exceeded",ro],["400 slack_channel_set_up_settings_refused",ao],["400 storage_attach_limit_reached",Ua],["400 storage_not_approved",$o],["400 storage_not_attachable",Fa],["400 storage_profile_mismatch",bc],["400 storage_profile_still_required",Wa],["400 storage_quota_exceeded",wa],["400 storage_verification_failed",ja],["400 thread_already_continued",Yo],["400 thread_continue_in_flight",Xo],["400 thread_fingerprint_mismatch",Qo],["400 thread_unsupported_request",Zo],["400 tool_name_conflict",ec],["400 tool_reference_unresolved",tc],["400 transcripts_storage_required",ko],["400 unsupported_charset",qo],["400 unsupported_region",Ha],["400 user_profile_not_found",Rc],["400 user_profile_required",zc],["400 workspace_api_key_limit_exceeded",sc],["400 workspace_human_review_disabled",xp],["400 workspace_member_limit_exceeded",yc],["400 workspace_policy_violation",vc],["402 linked_organization_billing_unavailable",Tp],["402 linked_organization_spend_limit_reached",Ap],["403 api_key_scope_missing",oo],["403 cannot_sign_out_managed_member",Ja],["403 cannot_sign_out_membership_admin",Ya],["403 cannot_sign_out_owner",Xa],["403 cannot_sign_out_privileged_member",Qa],["403 claude_tag_writes_not_enabled",co],["403 compliance_configuration_restricted",lo],["403 environment_create_disabled",Ra],["403 environment_update_disabled",za],["403 organization_level_scoped_api_key_required",uo],["403 sandbox_egress_restricted",Rp],["403 spend_limits_admin_api_writes_not_enabled",vo],["403 user_profile_billing_not_authorized",Pc],["403 user_profile_not_billable",Cc],["404 environment_not_found",Pa],["404 file_expired",ka],["404 rbac_group_managed_settings_not_found",no],["404 rbac_group_not_found",yo],["404 rbac_role_not_found",Sc],["404 slack_channel_set_up_environment_not_found",ho],["404 thread_not_found",rc],["409 concurrent_membership_change",xc],["409 external_key_changed",lc],["409 gcp_project_controlled_by_another_organization",Io],["409 plugin_name_taken",fo],["409 scan_pending",go],["409 skill_name_taken",mo],["409 skill_read_blocked_undecryptable",Ac],["409 slack_channel_set_up_settings_conflict",_o],["409 storage_already_registered",Ka],["409 storage_attached_during_archive",wc],["409 storage_changed_concurrently",Da],["409 storage_in_use",Lo],["409 workspace_changed_concurrently",Eo],["412 heartbeat_precondition_failed",Sa],["413 request_body_too_large_after_decoding",zp],["429 contract_spend_limit_reached",Pp],["429 enforced_spend_limit_reached",Cp],["429 ramp_limit_exceeded",Op],["503 authorization_check_unavailable",Ao],["503 change_outcome_unknown",Tc],["503 cmek_context_unavailable",Np],["503 cmek_key_unreachable",Mp],["503 registration_pending",bo],["503 workspace_created_incomplete",kc],["529 compaction_unavailable",nc]]),Fv="urn:ietf:params:oauth:grant-type:jwt-bearer",Wv="refresh_token",hf="/v1/oauth/token",yi="oauth-2025-04-20",jv="oidc-federation-2026-04-01",Hv=120,Oc=30,Kv=5,Lh=1<<20;function _f(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 pf(t,n){const e=await Gv(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 bs=2e3,Dv=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<=bs?t:t.slice(0,bs)+`... <${t.length-bs} more chars>`}return JSON.stringify(Re(n))}if(typeof t=="object"&&!Array.isArray(t)){const n={};for(const[e,r]of Object.entries(t))Dv.has(e)&&(n[e]=r);return n}return null}async function ff(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-mz1-CgQF.js");return{fs:a}},__vite__mapDeps([3,1,2]));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 gf(t,n){const{fs:e,path:r}=await Fe(async()=>{const{fs:a,path:c}=await import("./node.browser-mz1-CgQF.js");return{fs:a,path:c}},__vite__mapDeps([3,1,2])),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 Gv(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>Lh){const c=Lh-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 Vv{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>Hv?e.token:r>Oc?(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<Kv||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 mf="1.0",Jv=/^[A-Za-z0-9_.-]+$/;function bf(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(!Jv.test(t))throw new Error(`profile name "${t}" contains disallowed characters (allowed: letters, digits, '_', '.', '-')`)}const Yv=async t=>{var n,e;const r=await Nc();if(r===null)return null;const i=t==null&&$("ANTHROPIC_PROFILE")!=null;let s=null;if(t==null&&!i){const f=$("ANTHROPIC_ORGANIZATION_ID"),y=$("ANTHROPIC_IDENTITY_TOKEN_FILE"),b=$("ANTHROPIC_FEDERATION_RULE_ID");if(b&&f&&(s={fromFile:!1,config:{organization_id:f,workspace_id:$("ANTHROPIC_WORKSPACE_ID"),base_url:$("ANTHROPIC_BASE_URL"),authentication:{type:"oidc_federation",federation_rule_id:b,service_account_id:$("ANTHROPIC_SERVICE_ACCOUNT_ID"),identity_token:y?{source:"file",path:y}:void 0,scope:$("ANTHROPIC_SCOPE")}}},y||$("ANTHROPIC_IDENTITY_TOKEN")))return s}const a=t??await yf();if(a===null)return null;bf(a);const{fs:c,path:l}=await Fe(async()=>{const{fs:f,path:y}=await import("./node.browser-mz1-CgQF.js");return{fs:f,path:y}},__vite__mapDeps([3,1,2])),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=$("ANTHROPIC_ORGANIZATION_ID")),h.workspace_id??(h.workspace_id=$("ANTHROPIC_WORKSPACE_ID")),h.base_url??(h.base_url=$("ANTHROPIC_BASE_URL")),(n=h.authentication).scope??(n.scope=$("ANTHROPIC_SCOPE")),h.authentication.type==="oidc_federation"){if(!h.authentication.identity_token){const f=$("ANTHROPIC_IDENTITY_TOKEN_FILE");f&&(h.authentication.identity_token={source:"file",path:f})}h.authentication.federation_rule_id||(h.authentication.federation_rule_id=$("ANTHROPIC_FEDERATION_RULE_ID")??""),(e=h.authentication).service_account_id??(e.service_account_id=$("ANTHROPIC_SERVICE_ACCOUNT_ID"))}return{config:h,fromFile:!0}},Xv=async(t,n)=>{if(t?.authentication.credentials_path)return t.authentication.credentials_path;const e=await Nc();if(!e)return null;const r=n??await yf();if(!r)return null;bf(r);const{path:i}=await Fe(async()=>{const{path:s}=await import("./node.browser-mz1-CgQF.js");return{path:s}},__vite__mapDeps([3,1,2]));return i.join(e,"credentials",`${r}.json`)},Nc=async()=>{if(!Qv())return null;const{path:t}=await Fe(async()=>{const{path:s}=await import("./node.browser-mz1-CgQF.js");return{path:s}},__vite__mapDeps([3,1,2])),n=$("ANTHROPIC_CONFIG_DIR");if(n)return n;if(ra()["X-Stainless-OS"]==="Windows"){const s=$("APPDATA");if(s)return t.join(s,"Anthropic");const a=$("USERPROFILE");return a?t.join(a,"AppData","Roaming","Anthropic"):null}const r=$("XDG_CONFIG_HOME");if(r)return t.join(r,"anthropic");const i=$("HOME");return i?t.join(i,".config","anthropic"):null},Qv=()=>{const t=ra()["X-Stainless-Runtime"];return t==="node"||t==="deno"},yf=async()=>{const t=await Nc();if(!t)return null;const n=$("ANTHROPIC_PROFILE");if(n)return n;const{fs:e,path:r}=await Fe(async()=>{const{fs:s,path:a}=await import("./node.browser-mz1-CgQF.js");return{fs:s,path:a}},__vite__mapDeps([3,1,2])),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 Uh(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-mz1-CgQF.js");return{fs:i}},__vite__mapDeps([3,1,2]));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 Zv(t){if(!t)throw new P("Identity token value is empty");return()=>t}function ew(t){return async()=>{_f(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:Fv,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}${hf}`;let i;try{i=await t.fetch(r,{method:"POST",redirect:"manual",headers:{"Content-Type":"application/json","anthropic-beta":`${yi},${jv}`,"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 pf(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 tw(t){return async n=>{const{fs:e}=await Fe(async()=>{const{fs:v}=await import("./node.browser-mz1-CgQF.js");return{fs:v}},__vite__mapDeps([3,1,2]));await ff(t.credentialsPath,t.onSafetyWarning);let r;try{r=await e.promises.readFile(t.credentialsPath,"utf-8")}catch(v){throw new D(`Credentials file not found at ${t.credentialsPath}: ${v}`)}let i;try{i=JSON.parse(r)}catch(v){throw new D(`Credentials file at ${t.credentialsPath} is not valid JSON: ${v}`)}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-Oc))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"})`);_f(t.baseURL);const l={grant_type:Wv,refresh_token:c,client_id:t.clientId},d=`${t.baseURL}${hf}`;let _;try{_=await t.fetch(d,{method:"POST",redirect:"manual",headers:{"Content-Type":"application/json","anthropic-beta":yi,"User-Agent":t.userAgent||`anthropic-sdk-typescript/${Ge} userOAuthProvider`},body:JSON.stringify(l)})}catch(v){throw new D(`User OAuth refresh failed to reach token endpoint: ${v}`)}const h=_.headers.get("Request-Id");if(!_.ok){const v=await _.text().catch(()=>"");throw new D(`User OAuth refresh failed (HTTP ${_.status}): ${Re(v)}`,_.status,Re(v),h)}const p=await pf(_,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 y=St()+f,b=p.refresh_token||c;return await gf(t.credentialsPath,{...i,version:mf,type:"oauth_token",access_token:p.access_token,expires_at:y,refresh_token:b}),{token:p.access_token,expiresAt:y}}}function vf(t,n){const e=t.authentication.credentials_path??null,r=(t.base_url||n.baseURL).replace(/\/+$/,""),i=nw(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 rw(t,n){const e=await Yv(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 Xv(r,n)??void 0}};return vf(s,t)}function nw(t,n,e,r){switch(t.authentication.type){case"oidc_federation":{const i=t.authentication,s=iw(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=ew({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?sw(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 tw({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 iw(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 Uh(t.identity_token.path)}const n=$("ANTHROPIC_IDENTITY_TOKEN_FILE");if(n)return Uh(n);const e=$("ANTHROPIC_IDENTITY_TOKEN");return e?Zv(e):null}function sw(t,n,e,r){return async i=>{const{fs:s}=await Fe(async()=>{const{fs:l}=await import("./node.browser-mz1-CgQF.js");return{fs:l}},__vite__mapDeps([3,1,2]));await ff(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()<_-Oc)return{token:d,expiresAt:_??null}}}catch(l){l?.code!=="ENOENT"&&!(l instanceof SyntaxError)&&e?.(l)}const c=await t(i);try{await gf(n,{...a??{},version:mf,type:"oauth_token",access_token:c.token,expires_at:c.expiresAt})}catch(l){e?.(l)}return c}}const wf=new WeakSet;function kf(t){return typeof t=="object"&&t!==null&&wf.has(t)}function aw(t){const n=new Set;for(;typeof t=="object"&&t!==null&&!n.has(t);){if(n.add(t),kf(t)||Tt(t)||t instanceof At||t instanceof Kg)return!0;t=t.cause}return!1}function Fh(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 cw(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 ow(t,n){const e=new WeakMap;return{options:t,logger:n?B(n):L_(),parse(r){if(t?.stream&&r.ok)return Wh(r,t,n);let i=e.get(r);return i||(i=Wh(r,t,n),e.set(r,i)),i}}}async function Wh(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:zi(await t.clone().json(),t):await t.clone().text()}function cw(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 wf.add(d),d}};const s=ow(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 Ef=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",lw=t=>t!=null&&typeof t=="object"&&typeof t.name=="string"&&typeof t.lastModified=="number"&&Ef(t),uw=t=>t!=null&&typeof t=="object"&&typeof t.url=="string"&&typeof t.blob=="function";async function dw(t,n,e){if(Q_(),t=await t,n||(n=t instanceof File?t.name:ri(t,!0)),lw(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(uw(t)){const i=await t.blob();return n||(n=new URL(t.url).pathname.split(/[\\/]/).pop()),Zt(await Hs(i),n,e)}const r=await Hs(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 Hs(t){let n=[];if(typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer)n.push(t);else if(Ef(t))n.push(t instanceof Blob?t:await t.arrayBuffer());else if(pa(t))for await(const e of t)n.push(...await Hs(e));else{const e=t?.constructor?.name;throw new Error(`Unexpected data type: ${typeof t}${e?`; constructor: ${e}`:""}${hw(t)}`)}return n}function hw(t){return typeof t!="object"||t===null?"":`; props: [${Object.getOwnPropertyNames(t).map(e=>`"${e}"`).join(", ")}]`}class jh 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",ue,{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 ys,vs,Qn,Yt,bt,Hh;let Kh=!1;var _w=(()=>{class t{get credentials(){return this._authState.provider}get openTelemetry(){return o(this,bt,"f")}_instrumentationScope(){return{version:Ge}}constructor({baseURL:e=$("ANTHROPIC_BASE_URL"),apiKey:r,authToken:i,webhookKey:s=$("ANTHROPIC_WEBHOOK_SIGNING_KEY")??null,...a}={}){ys.add(this),this._requestAuthFlags=new WeakMap,Qn.set(this,void 0),Yt.set(this,void 0),bt.set(this,void 0),this._genAIProviderName="anthropic",this._supportsMessageThreads=!1;const c={apiKey:r,authToken:i,...a},l=Ot.filter(v=>c[v]!=null);if(l.length>1){const v=E=>E.map(S=>`\`${S}\``).join(", ");throw new TypeError(`Pass at most one of ${v(Ot)}. Received ${v(l)}.`)}const[d]=l,_=d!=null?null:{apiKey:r===void 0?$("ANTHROPIC_API_KEY"):void 0,authToken:i===void 0?$("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&&Yg())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,