@anthropic-ai/claude-agent-sdk
Version:
SDK for building AI agents with Claude Code's capabilities. Programmatically interact with Claude to build autonomous agents that can understand codebases, edit files, and execute workflows.
17 lines (14 loc) • 2.57 kB
JavaScript
// (c) Anthropic PBC. All rights reserved. Use is subject to the Legal Agreements outlined here: https://code.claude.com/docs/en/legal-and-compliance.
// Version: 0.3.325
//! symbol-dispose-prelude: defines Symbol.dispose and Symbol.asyncDispose if missing, for this bundle's `using`.
if (typeof Symbol.dispose !== 'symbol') {
try {
Symbol.dispose = Symbol.for('Symbol.dispose')
} catch {}
}
if (typeof Symbol.asyncDispose !== 'symbol') {
try {
Symbol.asyncDispose = Symbol.for('Symbol.asyncDispose')
} catch {}
}
import{n}from"./core-msnqqcc2.mjs";import{Le,ae}from"./core-ds2jqcef.mjs";import{AsyncLocalStorage as y}from"async_hooks";import{constants as b}from"fs";import{appendFile as w,copyFile as P,lstat as S,mkdir as h,open as d,readdir as l,readFile as c,stat as B,unlink as v,writeFile as a}from"fs/promises";class p{read(r){return c(r,"utf8")}readBytes(r){return c(r)}write(r,e,t){return a(r,e,{encoding:"utf8",mode:t})}async mkdir(r,e){try{await h(r,{recursive:!0,mode:e})}catch(t){if(n(t)!=="EEXIST")throw t}}atomicWrite(r,e,t){return Le(r,e,t)}delete(r){return v(r)}list(r){return l(r)}append(r,e,t){return w(r,e,{encoding:"utf8",mode:t})}writeExclusive(r,e,t){return a(r,e,{encoding:"utf8",flag:"wx",mode:t})}writeBytesExclusive(r,e,t){return a(r,e,{flag:"wx",mode:t})}copy(r,e){return P(r,e)}async stat(r){return{mtimeMs:(await B(r)).mtimeMs}}async lstat(r){try{let e=await S(r);return{isSymbolicLink:e.isSymbolicLink(),isFile:e.isFile(),isDirectory:e.isDirectory(),mtimeMs:e.mtimeMs,nlink:e.nlink}}catch(e){if(n(e)==="ENOENT")return;throw e}}async listEntries(r){return(await l(r,{withFileTypes:!0})).map((t)=>({name:t.name,isDirectory:t.isDirectory(),isFile:t.isFile()}))}async readRange(r,e,t){m("readRange","offset",e),m("readRange","length",t);let s=await d(r,"r");try{return await f(s,e,t)}finally{await s.close()}}async readTail(r,e,t){m("readTail","maxBytes",e);let s=t?.noFollow?b.O_RDONLY|ae:"r",i=await d(r,s);try{let o=await i.stat();if(t?.noFollow&&!o.isFile())throw Object.assign(Error("ENXIO: not a regular file"),{code:"ENXIO",path:r});let{size:g}=o,u=Math.min(e,g);return await f(i,g-u,u)}finally{await i.close()}}}function m(r,e,t){if(!Number.isInteger(t)||t<0)throw RangeError(`${r}: ${e} must be a non-negative integer, got ${t}`)}async function f(r,e,t){if(t===0)return Buffer.alloc(0);let s=Buffer.alloc(t),i=0;while(i<t){let{bytesRead:o}=await r.read(s,i,t-i,e+i);if(o===0)break;i+=o}return i===t?s:Buffer.from(s.subarray(0,i))}var F=new y;function T(){return F.getStore()??new p}export{T as getStorageBackend};