@e2b/cli 2.7.2 → 2.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -216,7 +216,7 @@ ${HL}
216
216
  Try running with %s or get access `,Ue.cyan("sudo"))+`
217
217
  to the local update config store via
218
218
  `+Ue.cyan((0,x_.format)(" sudo chown -R $USER:$(id -gn $USER) %s ",Xc));rs.default.on("exit",()=>{console.error(Un(r,{textAlignment:"center"}))})}}check(){!this.config||this.config.get("optOut")||this.#n||(this.update=this.config.get("update"),this.update&&(this.update.current=this.#r,this.config.delete("update")),!(Date.now()-this.config.get("lastUpdateCheck")<this.#e)&&(0,EF.spawn)(rs.default.execPath,[Xx.default.join(TSe,"check.js"),JSON.stringify(this.#t)],{detached:!0,stdio:"ignore"}).unref())}async fetchInfo(){let{distTag:e}=this.#t,r=await Ax(this._packageName,{version:e});return{latest:r,current:this.#r,type:WT(this.#r,r)||e,name:this._packageName}}notify(e){let r=!this._shouldNotifyInNpmScript&&c3;if(!rs.default.stdout.isTTY||r||!this.update||!bF.default.gt(this.update.latest,this.update.current))return this;e={isGlobal:TF.default,isYarnGlobal:D3(),...e};let n;e.isYarnGlobal?n=`yarn global add ${this._packageName}`:e.isGlobal?n=`npm i -g ${this._packageName}`:Lx()?n=`yarn add ${this._packageName}`:n=`npm i ${this._packageName}`;let i="Update available "+Ue.dim("{currentVersion}")+Ue.reset(" \u2192 ")+Ue.green("{latestVersion}")+`
219
- Run `+Ue.cyan("{updateCommand}")+" to update",s=e.message||i;e.boxenOptions=e.boxenOptions||{padding:1,margin:1,textAlignment:"center",borderColor:"yellow",borderStyle:"round"};let a=Un(Qx(s,{packageName:this._packageName,currentVersion:this.update.current,latestVersion:this.update.latest,updateCommand:n}),e.boxenOptions);return e.defer===!1?console.error(a):(rs.default.on("exit",()=>{console.error(a)}),rs.default.on("SIGINT",()=>{console.error(""),rs.default.exit()})),this}};function Zx(t){let e=new of(t);return e.check(),e}u();var kF=J(FF(),1),{program:XJe,createCommand:ZJe,createArgument:JJe,createOption:eet,CommanderError:tet,InvalidArgumentError:lf,InvalidOptionArgumentError:ret,Command:$e,Argument:net,Option:Da,Help:iet}=kF.default;var fC={};cT(fC,{author:()=>YSe,bin:()=>JSe,bugs:()=>VSe,default:()=>rbe,dependencies:()=>ebe,description:()=>HSe,devDependencies:()=>XSe,engines:()=>tbe,files:()=>ZSe,homepage:()=>qSe,keywords:()=>zSe,license:()=>$Se,name:()=>GSe,publishConfig:()=>KSe,repository:()=>WSe,scripts:()=>QSe,sideEffects:()=>jSe,version:()=>pC});var GSe="@e2b/cli",pC="2.7.2",HSe="CLI for managing e2b sandbox templates",qSe="https://e2b.dev",$Se="MIT",YSe={name:"FoundryLabs, Inc.",email:"hello@e2b.dev",url:"https://e2b.dev"},VSe="https://github.com/e2b-dev/e2b/issues",WSe={type:"git",url:"https://github.com/e2b-dev/e2b",directory:"packages/cli"},KSe={access:"public"},zSe=["e2b","ai-agents","agents","ai","code-interpreter","sandbox","code","cli","runtime","vm","nodejs","javascript","typescript"],jSe=!1,QSe={prepublishOnly:"pnpm build",build:"tsc --noEmit --skipLibCheck && tsup --minify",dev:"tsup --watch",typecheck:"tsc --noEmit --skipLibCheck",lint:"eslint src",format:"prettier --write src","test:interactive":"pnpm build && ./dist/index.js",test:"vitest run","test:watch":"vitest watch","test:coverage":"vitest run --coverage","check-deps":"knip","generate-ref":"./scripts/generate_sdk_ref.sh"},XSe={"@types/command-exists":"^1.2.3","@types/handlebars":"^4.1.0","@types/inquirer":"^9.0.7","@types/json2md":"^1.5.4","@types/node":"^20.19.19","@types/npmcli__package-json":"^4.0.4","@types/statuses":"^2.0.5","@types/update-notifier":"6.0.5","@vitest/coverage-v8":"^3.2.4",json2md:"^2.0.1",knip:"^5.43.6",tsup:"^8.4.0",typescript:"^5.2.2",vitest:"^3.2.4"},ZSe=["dist","LICENSE","README","package.json"],JSe={e2b:"dist/index.js"},ebe={"@iarna/toml":"^2.2.5","@inquirer/prompts":"^7.9.0","@npmcli/package-json":"^5.2.1","async-listen":"^3.0.1",boxen:"^7.1.1",chalk:"^5.3.0","cli-highlight":"^2.1.11","command-exists":"^1.2.9",commander:"^11.1.0","console-table-printer":"^2.11.2","dockerfile-ast":"^0.6.1",e2b:"^2.11.2",handlebars:"^4.7.8",inquirer:"^12.10.0",open:"^9.1.0",statuses:"^2.0.1","strip-ansi":"^7.1.0","update-notifier":"^6.0.2",yup:"^1.3.2"},tbe={node:">=20"},rbe={name:GSe,version:pC,description:HSe,homepage:qSe,license:$Se,author:YSe,bugs:VSe,repository:WSe,publishConfig:KSe,keywords:zSe,sideEffects:jSe,scripts:QSe,devDependencies:XSe,files:ZSe,bin:JSe,dependencies:ebe,engines:tbe};u();u();var $D=J(WW());u();var Vl=J(require("path"));function vn(t){let e=process.cwd();return t?Vl.isAbsolute(t)?t:Vl.resolve(e,t):e}function KW(t){return Vl.relative(process.cwd(),t)}var cve="#FFB766";function wg(t){let e=Oe(t.email),r=t.teamName?Oe(t.teamName):lve("Log out and log in to get team name"),n=Oe(t.teamId);return`You are logged in as ${e},
219
+ Run `+Ue.cyan("{updateCommand}")+" to update",s=e.message||i;e.boxenOptions=e.boxenOptions||{padding:1,margin:1,textAlignment:"center",borderColor:"yellow",borderStyle:"round"};let a=Un(Qx(s,{packageName:this._packageName,currentVersion:this.update.current,latestVersion:this.update.latest,updateCommand:n}),e.boxenOptions);return e.defer===!1?console.error(a):(rs.default.on("exit",()=>{console.error(a)}),rs.default.on("SIGINT",()=>{console.error(""),rs.default.exit()})),this}};function Zx(t){let e=new of(t);return e.check(),e}u();var kF=J(FF(),1),{program:XJe,createCommand:ZJe,createArgument:JJe,createOption:eet,CommanderError:tet,InvalidArgumentError:lf,InvalidOptionArgumentError:ret,Command:$e,Argument:net,Option:Da,Help:iet}=kF.default;var fC={};cT(fC,{author:()=>YSe,bin:()=>JSe,bugs:()=>VSe,default:()=>rbe,dependencies:()=>ebe,description:()=>HSe,devDependencies:()=>XSe,engines:()=>tbe,files:()=>ZSe,homepage:()=>qSe,keywords:()=>zSe,license:()=>$Se,name:()=>GSe,publishConfig:()=>KSe,repository:()=>WSe,scripts:()=>QSe,sideEffects:()=>jSe,version:()=>pC});var GSe="@e2b/cli",pC="2.7.3",HSe="CLI for managing e2b sandbox templates",qSe="https://e2b.dev",$Se="MIT",YSe={name:"FoundryLabs, Inc.",email:"hello@e2b.dev",url:"https://e2b.dev"},VSe="https://github.com/e2b-dev/e2b/issues",WSe={type:"git",url:"https://github.com/e2b-dev/e2b",directory:"packages/cli"},KSe={access:"public"},zSe=["e2b","ai-agents","agents","ai","code-interpreter","sandbox","code","cli","runtime","vm","nodejs","javascript","typescript"],jSe=!1,QSe={prepublishOnly:"pnpm build",build:"tsc --noEmit --skipLibCheck && tsup --minify",dev:"tsup --watch",typecheck:"tsc --noEmit --skipLibCheck",lint:"eslint src",format:"prettier --write src","test:interactive":"pnpm build && ./dist/index.js",test:"vitest run","test:watch":"vitest watch","test:coverage":"vitest run --coverage","check-deps":"knip","generate-ref":"./scripts/generate_sdk_ref.sh"},XSe={"@types/command-exists":"^1.2.3","@types/handlebars":"^4.1.0","@types/inquirer":"^9.0.7","@types/json2md":"^1.5.4","@types/node":"^20.19.19","@types/npmcli__package-json":"^4.0.4","@types/statuses":"^2.0.5","@types/update-notifier":"6.0.5","@vitest/coverage-v8":"^3.2.4",json2md:"^2.0.1",knip:"^5.43.6",tsup:"^8.4.0",typescript:"^5.2.2",vitest:"^3.2.4"},ZSe=["dist","LICENSE","README","package.json"],JSe={e2b:"dist/index.js"},ebe={"@iarna/toml":"^2.2.5","@inquirer/prompts":"^7.9.0","@npmcli/package-json":"^5.2.1","async-listen":"^3.0.1",boxen:"^7.1.1",chalk:"^5.3.0","cli-highlight":"^2.1.11","command-exists":"^1.2.9",commander:"^11.1.0","console-table-printer":"^2.11.2","dockerfile-ast":"^0.6.1",e2b:"^2.11.2",handlebars:"^4.7.8",inquirer:"^12.10.0",open:"^9.1.0",statuses:"^2.0.1","strip-ansi":"^7.1.0","update-notifier":"^6.0.2",yup:"^1.3.2"},tbe={node:">=20"},rbe={name:GSe,version:pC,description:HSe,homepage:qSe,license:$Se,author:YSe,bugs:VSe,repository:WSe,publishConfig:KSe,keywords:zSe,sideEffects:jSe,scripts:QSe,devDependencies:XSe,files:ZSe,bin:JSe,dependencies:ebe,engines:tbe};u();u();var $D=J(WW());u();var Vl=J(require("path"));function vn(t){let e=process.cwd();return t?Vl.isAbsolute(t)?t:Vl.resolve(e,t):e}function KW(t){return Vl.relative(process.cwd(),t)}var cve="#FFB766";function wg(t){let e=Oe(t.email),r=t.teamName?Oe(t.teamName):lve("Log out and log in to get team name"),n=Oe(t.teamId);return`You are logged in as ${e},
220
220
  Selected team: ${r} (${n})`}function QW(t,e){let r=Oe(t.name),n=Oe(t.teamID),i=t.teamID==e?je(" (currently selected team)"):"";return`${r} (${n})${i}`}function rr(t,e){let r=YD(t.aliases),n=r?Oe(r):"",i=e?uve(" <-> ")+At(e):"";return`${`${t.templateID} `}${n}${i}`.trim()}function lve(t){return Ue.redBright(t)}function Hs(t,e){return Ue.redBright(`${t?`${t}
221
221
  `:""}${e?e.stack:""}
222
222
  `)}function uve(t){return Ue.dim(t)}function Oe(t){return Ue.bold(t)}function je(t){return Ue.hex(cve)(t)}function Lg(t){return Ue.blue(t)}function Dt(t){return Ue.blue(t)}function At(t){return t?Dt("./"+KW(t)):""}function XW(t){return Ue.blueBright(t)}function Wl(t){return Ue.underline(t)}function YD(t){if(t)return t.join(", ")}function Pg(t){return $D.default(t,{language:"typescript",ignoreIllegals:!0})}function Mg(t){return $D.default(t,{language:"python",ignoreIllegals:!0})}var dve={topLeft:"",topRight:"",bottomLeft:"",bottomRight:"",top:"",bottom:"",left:"",right:""},zW=2,jW=1;function Kl(t,e,r){return Un(t,{borderStyle:{...dve,top:"\u2500",bottom:r?"\u2500":""},titleAlignment:"center",float:"left",title:e?Oe(e):void 0,margin:{top:0,bottom:0,left:1,right:0},fullscreen:n=>[n,0],padding:{bottom:r?jW:0,left:zW,right:zW,top:jW}})}u();u();u();u();u();var fve=/\{[^{}]+\}/g,pve=()=>typeof process=="object"&&Number.parseInt(process?.versions?.node?.substring(0,2))>=18&&process.versions.undici;function mve(){return Math.random().toString(36).slice(2,11)}function Fg(t){let{baseUrl:e="",Request:r=globalThis.Request,fetch:n=globalThis.fetch,querySerializer:i,bodySerializer:s,headers:a,requestInitExt:o=void 0,...c}={...t};o=pve()?o:void 0,e=eK(e);let l=[];async function d(f,m){let{baseUrl:p,fetch:h=n,Request:_=r,headers:S,params:b={},parseAs:C="json",querySerializer:D,bodySerializer:N=s??_ve,body:U,...K}=m||{},$=e;p&&($=eK(p)??e);let w=typeof i=="function"?i:ZW(i);D&&(w=typeof D=="function"?D:ZW({...typeof i=="object"?i:{},...D}));let R=U===void 0?void 0:N(U,JW(a,S,b.header)),v=JW(R===void 0||R instanceof FormData?{}:{"Content-Type":"application/json"},a,S,b.header),G={redirect:"follow",...c,...K,body:R,headers:v},te,se,ce=new _(gve(f,{baseUrl:$,params:b,querySerializer:w}),G),re;for(let le in K)le in ce||(ce[le]=K[le]);if(l.length){te=mve(),se=Object.freeze({baseUrl:$,fetch:h,parseAs:C,querySerializer:w,bodySerializer:N});for(let le of l)if(le&&typeof le=="object"&&typeof le.onRequest=="function"){let Ee=await le.onRequest({request:ce,schemaPath:f,params:b,options:se,id:te});if(Ee)if(Ee instanceof _)ce=Ee;else if(Ee instanceof Response){re=Ee;break}else throw new Error("onRequest: must return new Request() or Response() when modifying the request")}}if(!re){try{re=await h(ce,o)}catch(le){let Ee=le;if(l.length)for(let be=l.length-1;be>=0;be--){let ut=l[be];if(ut&&typeof ut=="object"&&typeof ut.onError=="function"){let dt=await ut.onError({request:ce,error:Ee,schemaPath:f,params:b,options:se,id:te});if(dt){if(dt instanceof Response){Ee=void 0,re=dt;break}if(dt instanceof Error){Ee=dt;continue}throw new Error("onError: must return new Response() or instance of Error")}}}if(Ee)throw Ee}if(l.length)for(let le=l.length-1;le>=0;le--){let Ee=l[le];if(Ee&&typeof Ee=="object"&&typeof Ee.onResponse=="function"){let be=await Ee.onResponse({request:ce,response:re,schemaPath:f,params:b,options:se,id:te});if(be){if(!(be instanceof Response))throw new Error("onResponse: must return new Response() when modifying the response");re=be}}}}if(re.status===204||ce.method==="HEAD"||re.headers.get("Content-Length")==="0")return re.ok?{data:void 0,response:re}:{error:void 0,response:re};if(re.ok)return C==="stream"?{data:re.body,response:re}:{data:await re[C](),response:re};let ge=await re.text();try{ge=JSON.parse(ge)}catch{}return{error:ge,response:re}}return{request(f,m,p){return d(m,{...p,method:f.toUpperCase()})},GET(f,m){return d(f,{...m,method:"GET"})},PUT(f,m){return d(f,{...m,method:"PUT"})},POST(f,m){return d(f,{...m,method:"POST"})},DELETE(f,m){return d(f,{...m,method:"DELETE"})},OPTIONS(f,m){return d(f,{...m,method:"OPTIONS"})},HEAD(f,m){return d(f,{...m,method:"HEAD"})},PATCH(f,m){return d(f,{...m,method:"PATCH"})},TRACE(f,m){return d(f,{...m,method:"TRACE"})},use(...f){for(let m of f)if(m){if(typeof m!="object"||!("onRequest"in m||"onResponse"in m||"onError"in m))throw new Error("Middleware must be an object with one of `onRequest()`, `onResponse() or `onError()`");l.push(m)}},eject(...f){for(let m of f){let p=l.indexOf(m);p!==-1&&l.splice(p,1)}}}}function kg(t,e,r){if(e==null)return"";if(typeof e=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${r?.allowReserved===!0?e:encodeURIComponent(e)}`}function tK(t,e,r){if(!e||typeof e!="object")return"";let n=[],i={simple:",",label:".",matrix:";"}[r.style]||"&";if(r.style!=="deepObject"&&r.explode===!1){for(let o in e)n.push(o,r.allowReserved===!0?e[o]:encodeURIComponent(e[o]));let a=n.join(",");switch(r.style){case"form":return`${t}=${a}`;case"label":return`.${a}`;case"matrix":return`;${t}=${a}`;default:return a}}for(let a in e){let o=r.style==="deepObject"?`${t}[${a}]`:a;n.push(kg(o,e[a],r))}let s=n.join(i);return r.style==="label"||r.style==="matrix"?`${i}${s}`:s}function rK(t,e,r){if(!Array.isArray(e))return"";if(r.explode===!1){let s={form:",",spaceDelimited:"%20",pipeDelimited:"|"}[r.style]||",",a=(r.allowReserved===!0?e:e.map(o=>encodeURIComponent(o))).join(s);switch(r.style){case"simple":return a;case"label":return`.${a}`;case"matrix":return`;${t}=${a}`;default:return`${t}=${a}`}}let n={simple:",",label:".",matrix:";"}[r.style]||"&",i=[];for(let s of e)r.style==="simple"||r.style==="label"?i.push(r.allowReserved===!0?s:encodeURIComponent(s)):i.push(kg(t,s,r));return r.style==="label"||r.style==="matrix"?`${n}${i.join(n)}`:i.join(n)}function ZW(t){return function(r){let n=[];if(r&&typeof r=="object")for(let i in r){let s=r[i];if(s!=null){if(Array.isArray(s)){if(s.length===0)continue;n.push(rK(i,s,{style:"form",explode:!0,...t?.array,allowReserved:t?.allowReserved||!1}));continue}if(typeof s=="object"){n.push(tK(i,s,{style:"deepObject",explode:!0,...t?.object,allowReserved:t?.allowReserved||!1}));continue}n.push(kg(i,s,t))}}return n.join("&")}}function hve(t,e){let r=t;for(let n of t.match(fve)??[]){let i=n.substring(1,n.length-1),s=!1,a="simple";if(i.endsWith("*")&&(s=!0,i=i.substring(0,i.length-1)),i.startsWith(".")?(a="label",i=i.substring(1)):i.startsWith(";")&&(a="matrix",i=i.substring(1)),!e||e[i]===void 0||e[i]===null)continue;let o=e[i];if(Array.isArray(o)){r=r.replace(n,rK(i,o,{style:a,explode:s}));continue}if(typeof o=="object"){r=r.replace(n,tK(i,o,{style:a,explode:s}));continue}if(a==="matrix"){r=r.replace(n,`;${kg(i,o)}`);continue}r=r.replace(n,a==="label"?`.${encodeURIComponent(o)}`:encodeURIComponent(o))}return r}function _ve(t,e){return t instanceof FormData?t:e&&(e.get instanceof Function?e.get("Content-Type")??e.get("content-type"):e["Content-Type"]??e["content-type"])==="application/x-www-form-urlencoded"?new URLSearchParams(t).toString():JSON.stringify(t)}function gve(t,e){let r=`${e.baseUrl}${t}`;e.params?.path&&(r=hve(r,e.params.path));let n=e.querySerializer(e.params.query??{});return n.startsWith("?")&&(n=n.substring(1)),n&&(r+=`?${n}`),r}function JW(...t){let e=new Headers;for(let r of t){if(!r||typeof r!="object")continue;let n=r instanceof Headers?r.entries():Object.entries(r);for(let[i,s]of n)if(s===null)e.delete(i);else if(Array.isArray(s))for(let a of s)e.append(i,a);else s!==void 0&&e.set(i,s)}return e}function eK(t){return t.endsWith("/")?t.substring(0,t.length-1):t}u();var zD=J(VD());var Ug="2.13.0";u();var WD=J(VD());function Sve(){return globalThis.Bun?{runtime:"bun",version:globalThis.Bun.version}:globalThis.Deno?{runtime:"deno",version:globalThis.Deno.version.deno}:globalThis.process?.release?.name==="node"?{runtime:"node",version:WD.default.version||"unknown"}:typeof EdgeRuntime=="string"?{runtime:"vercel-edge",version:"unknown"}:globalThis.navigator?.userAgent==="Cloudflare-Workers"?{runtime:"cloudflare-worker",version:"unknown"}:typeof window<"u"?{runtime:"browser",version:WD.default.version||"unknown"}:{runtime:"unknown",version:"unknown"}}var{runtime:di,version:nK}=Sve();async function iK(t){if(typeof crypto<"u"){let i=new TextEncoder().encode(t),s=await crypto.subtle.digest("SHA-256",i),a=new Uint8Array(s);return btoa(String.fromCharCode(...a))}let{createHash:e}=require("crypto");return e("sha256").update(t,"utf8").digest().toString("base64")}function Gg(t){return Math.ceil(t/1e3)}function sK(t){if(di==="browser")throw new Error("Browser runtime is not supported for require");return require(t)}async function KD(t){if(di==="browser")throw new Error("Browser runtime is not supported for dynamic import");return await import(t)}function bve({onlyFirst:t=!1}={}){let i="(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";return new RegExp(i,t?void 0:"g")}function Hg(t){return t.replace(bve(),"")}function aK(t){return t instanceof Blob?t:typeof t=="string"||t instanceof ArrayBuffer?new Blob([t]):new Response(t).blob()}var oK={browser:typeof window<"u"&&zD.default.name||"unknown",lang:"js",lang_version:nK,package_version:Ug,publisher:"e2b",sdk_runtime:di,system:zD.default.os?.family||"unknown"};function tc(t){return di==="deno"?Deno.env.get(t):typeof process>"u"?"":process.env[t]}u();function qg(t){return new rc(`${t}: This error is likely due to sandbox timeout. You can modify the sandbox timeout by passing 'timeoutMs' when starting the sandbox or calling '.setTimeout' on the sandbox with the desired timeout.`)}var Pt=class extends Error{constructor(e,r){super(e),this.name="SandboxError",r&&(this.stack=r)}},rc=class extends Pt{constructor(e,r){super(e,r),this.name="TimeoutError"}},mt=class extends Pt{constructor(e,r){super(e,r),this.name="InvalidArgumentError"}},Pf=class extends Pt{constructor(e,r){super(e,r),this.name="NotEnoughSpaceError"}},Ir=class extends Pt{constructor(e,r){super(e,r),this.name="NotFoundError"}},Hn=class extends Error{constructor(e){super(e),this.name="AuthenticationError"}},nc=class extends Hn{constructor(e){super(e),this.name="GitAuthError"}},ic=class extends Pt{constructor(e,r){super(e,r),this.name="GitUpstreamError"}},tn=class extends Pt{constructor(e,r){super(e,r),this.name="TemplateError"}},zl=class extends Pt{constructor(e){super(e),this.name="RateLimitError"}},rn=class extends Error{constructor(e,r){super(e),this.name="BuildError",r&&(this.stack=r)}},qs=class extends rn{constructor(e,r){super(e,r),this.name="FileUploadError"}};u();function cK(t){return JSON.parse(JSON.stringify(t))}function lK(t){async function*e(r){for await(let n of r)t.debug?.("Response stream:",cK(n)),yield n}return r=>async n=>{t.info?.(`Request: POST ${n.url}`);let i=await r(n);return i.stream?{...i,message:e(i.message)}:(t.info?.("Response:",cK(i.message)),i)}}function $g(t){return{async onRequest({request:e}){return t.info?.(`Request ${e.method} ${e.url}`),e},async onResponse({response:e}){return e.status>=400?t.error?.("Response:",e.status,e.statusText):t.info?.("Response:",e.status,e.statusText),e}}}function ur(t,e=Pt,r){if(t.error===void 0)return;if(t.response.status===401){let i="Unauthorized, please check your credentials.",s=t.error?.message??t.error;return s?new Hn(`${i} - ${s}`):new Hn(i)}if(t.response.status===429){let i="Rate limit exceeded, please try again later",s=t.error?.message??t.error;return s?new zl(`${i} - ${s}`):new zl(i)}let n=t.error?.message??t.error;return new e(`${t.response.status}: ${n}`,r)}var Mt=class{api;constructor(e,r={requireAccessToken:!1,requireApiKey:!1}){if(r?.requireApiKey&&!e.apiKey)throw new Hn("API key is required, please visit the Team tab at https://e2b.dev/dashboard to get your API key. You can either set the environment variable `E2B_API_KEY` or you can pass it directly to the sandbox like Sandbox.create({ apiKey: 'e2b_...' })");if(r?.requireAccessToken&&!e.accessToken)throw new Hn("Access token is required, please visit the Personal tab at https://e2b.dev/dashboard to get your access token. You can set the environment variable `E2B_ACCESS_TOKEN` or pass the `accessToken` in options.");this.api=Fg({baseUrl:e.apiUrl,headers:{...oK,...e.apiKey&&{"X-API-KEY":e.apiKey},...e.accessToken&&{Authorization:`Bearer ${e.accessToken}`},...e.headers},querySerializer:{array:{style:"form",explode:!1}}}),e.logger&&this.api.use($g(e.logger))}};u();var Tve=6e4,Yg=3e5,Fa=50,ka="Keepalive-Ping-Interval",ht=class t{static envdPort=49983;debug;domain;apiUrl;sandboxUrl;logger;requestTimeoutMs;apiKey;accessToken;headers;constructor(e){this.apiKey=e?.apiKey||t.apiKey,this.debug=e?.debug||t.debug,this.domain=e?.domain||t.domain,this.accessToken=e?.accessToken||t.accessToken,this.requestTimeoutMs=e?.requestTimeoutMs??Tve,this.logger=e?.logger,this.headers=e?.headers||{},this.headers["User-Agent"]=`e2b-js-sdk/${Ug}`,this.apiUrl=e?.apiUrl||t.apiUrl||(this.debug?"http://localhost:3000":`https://api.${this.domain}`),this.sandboxUrl=e?.sandboxUrl||t.sandboxUrl}static get domain(){return tc("E2B_DOMAIN")||"e2b.app"}static get apiUrl(){return tc("E2B_API_URL")}static get sandboxUrl(){return tc("E2B_SANDBOX_URL")}static get debug(){return(tc("E2B_DEBUG")||"false").toLowerCase()==="true"}static get apiKey(){return tc("E2B_API_KEY")}static get accessToken(){return tc("E2B_ACCESS_TOKEN")}getSignal(e){let r=e??this.requestTimeoutMs;return r?AbortSignal.timeout(r):void 0}getSandboxUrl(e,r){return this.sandboxUrl?this.sandboxUrl:`${this.debug?"http":"https"}://${this.getHost(e,r.envdPort,r.sandboxDomain)}`}getHost(e,r,n){return this.debug?`localhost:${r}`:`${r}-${e}.${n??this.domain}`}},Ba="user";u();async function jD({path:t,operation:e,user:r,expirationInSeconds:n,envdAccessToken:i}){if(!i)throw new Error("Access token is not set and signature cannot be generated!");let s=n?Math.floor(Date.now()/1e3)+n:null,a;return r==null&&(r=""),s===null?a=`${t}:${e}:${r}:${i}`:a=`${t}:${e}:${r}:${i}:${s.toString()}`,{signature:"v1_"+(await iK(a)).replace(/=+$/,""),expiration:s}}u();u();u();u();var Me;(function(t){t[t.Canceled=1]="Canceled",t[t.Unknown=2]="Unknown",t[t.InvalidArgument=3]="InvalidArgument",t[t.DeadlineExceeded=4]="DeadlineExceeded",t[t.NotFound=5]="NotFound",t[t.AlreadyExists=6]="AlreadyExists",t[t.PermissionDenied=7]="PermissionDenied",t[t.ResourceExhausted=8]="ResourceExhausted",t[t.FailedPrecondition=9]="FailedPrecondition",t[t.Aborted=10]="Aborted",t[t.OutOfRange=11]="OutOfRange",t[t.Unimplemented=12]="Unimplemented",t[t.Internal=13]="Internal",t[t.Unavailable=14]="Unavailable",t[t.DataLoss=15]="DataLoss",t[t.Unauthenticated=16]="Unauthenticated"})(Me||(Me={}));u();u();function Mf(t,e){return t!==null&&typeof t=="object"&&"$typeName"in t&&typeof t.$typeName=="string"?e===void 0?!0:e.typeName===t.$typeName:!1}u();u();var z;(function(t){t[t.DOUBLE=1]="DOUBLE",t[t.FLOAT=2]="FLOAT",t[t.INT64=3]="INT64",t[t.UINT64=4]="UINT64",t[t.INT32=5]="INT32",t[t.FIXED64=6]="FIXED64",t[t.FIXED32=7]="FIXED32",t[t.BOOL=8]="BOOL",t[t.STRING=9]="STRING",t[t.BYTES=12]="BYTES",t[t.UINT32=13]="UINT32",t[t.SFIXED32=15]="SFIXED32",t[t.SFIXED64=16]="SFIXED64",t[t.SINT32=17]="SINT32",t[t.SINT64=18]="SINT64"})(z||(z={}));u();u();u();function dK(){let t=0,e=0;for(let n=0;n<28;n+=7){let i=this.buf[this.pos++];if(t|=(i&127)<<n,(i&128)==0)return this.assertBounds(),[t,e]}let r=this.buf[this.pos++];if(t|=(r&15)<<28,e=(r&112)>>4,(r&128)==0)return this.assertBounds(),[t,e];for(let n=3;n<=31;n+=7){let i=this.buf[this.pos++];if(e|=(i&127)<<n,(i&128)==0)return this.assertBounds(),[t,e]}throw new Error("invalid varint")}function Wg(t,e,r){for(let s=0;s<28;s=s+7){let a=t>>>s,o=!(!(a>>>7)&&e==0),c=(o?a|128:a)&255;if(r.push(c),!o)return}let n=t>>>28&15|(e&7)<<4,i=e>>3!=0;if(r.push((i?n|128:n)&255),!!i){for(let s=3;s<31;s=s+7){let a=e>>>s,o=!!(a>>>7),c=(o?a|128:a)&255;if(r.push(c),!o)return}r.push(e>>>31&1)}}var Vg=4294967296;function QD(t){let e=t[0]==="-";e&&(t=t.slice(1));let r=1e6,n=0,i=0;function s(a,o){let c=Number(t.slice(a,o));i*=r,n=n*r+c,n>=Vg&&(i=i+(n/Vg|0),n=n%Vg)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),e?pK(n,i):ZD(n,i)}function fK(t,e){let r=ZD(t,e),n=r.hi&2147483648;n&&(r=pK(r.lo,r.hi));let i=XD(r.lo,r.hi);return n?"-"+i:i}function XD(t,e){if({lo:t,hi:e}=yve(t,e),e<=2097151)return String(Vg*e+t);let r=t&16777215,n=(t>>>24|e<<8)&16777215,i=e>>16&65535,s=r+n*6777216+i*6710656,a=n+i*8147497,o=i*2,c=1e7;return s>=c&&(a+=Math.floor(s/c),s%=c),a>=c&&(o+=Math.floor(a/c),a%=c),o.toString()+uK(a)+uK(s)}function yve(t,e){return{lo:t>>>0,hi:e>>>0}}function ZD(t,e){return{lo:t|0,hi:e|0}}function pK(t,e){return e=~e,t?t=~t+1:e+=1,ZD(t,e)}var uK=t=>{let e=String(t);return"0000000".slice(e.length)+e};function JD(t,e){if(t>=0){for(;t>127;)e.push(t&127|128),t=t>>>7;e.push(t)}else{for(let r=0;r<9;r++)e.push(t&127|128),t=t>>7;e.push(1)}}function mK(){let t=this.buf[this.pos++],e=t&127;if((t&128)==0)return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(t&127)<<7,(t&128)==0)return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(t&127)<<14,(t&128)==0)return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(t&127)<<21,(t&128)==0)return this.assertBounds(),e;t=this.buf[this.pos++],e|=(t&15)<<28;for(let r=5;(t&128)!==0&&r<10;r++)t=this.buf[this.pos++];if((t&128)!=0)throw new Error("invalid varint");return this.assertBounds(),e>>>0}var _t=xve();function xve(){let t=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof t.getBigInt64=="function"&&typeof t.getBigUint64=="function"&&typeof t.setBigInt64=="function"&&typeof t.setBigUint64=="function"&&(typeof process!="object"||typeof process.env!="object"||process.env.BUF_BIGINT_DISABLE!=="1")){let r=BigInt("-9223372036854775808"),n=BigInt("9223372036854775807"),i=BigInt("0"),s=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(a){let o=typeof a=="bigint"?a:BigInt(a);if(o>n||o<r)throw new Error(`invalid int64: ${a}`);return o},uParse(a){let o=typeof a=="bigint"?a:BigInt(a);if(o>s||o<i)throw new Error(`invalid uint64: ${a}`);return o},enc(a){return t.setBigInt64(0,this.parse(a),!0),{lo:t.getInt32(0,!0),hi:t.getInt32(4,!0)}},uEnc(a){return t.setBigInt64(0,this.uParse(a),!0),{lo:t.getInt32(0,!0),hi:t.getInt32(4,!0)}},dec(a,o){return t.setInt32(0,a,!0),t.setInt32(4,o,!0),t.getBigInt64(0,!0)},uDec(a,o){return t.setInt32(0,a,!0),t.setInt32(4,o,!0),t.getBigUint64(0,!0)}}}return{zero:"0",supported:!1,parse(r){return typeof r!="string"&&(r=r.toString()),hK(r),r},uParse(r){return typeof r!="string"&&(r=r.toString()),_K(r),r},enc(r){return typeof r!="string"&&(r=r.toString()),hK(r),QD(r)},uEnc(r){return typeof r!="string"&&(r=r.toString()),_K(r),QD(r)},dec(r,n){return fK(r,n)},uDec(r,n){return XD(r,n)}}}function hK(t){if(!/^-?[0-9]+$/.test(t))throw new Error("invalid int64: "+t)}function _K(t){if(!/^[0-9]+$/.test(t))throw new Error("invalid uint64: "+t)}function qn(t,e){switch(t){case z.STRING:return"";case z.BOOL:return!1;case z.DOUBLE:case z.FLOAT:return 0;case z.INT64:case z.UINT64:case z.SFIXED64:case z.FIXED64:case z.SINT64:return e?"0":_t.zero;case z.BYTES:return new Uint8Array(0);default:return 0}}function gK(t,e){switch(t){case z.BOOL:return e===!1;case z.STRING:return e==="";case z.BYTES:return e instanceof Uint8Array&&!e.byteLength;default:return e==0}}u();u();var EK=2,Ui=Symbol.for("reflect unsafe local");function Kg(t,e){let r=t[e.localName].case;return r===void 0?r:e.fields.find(n=>n.localName===r)}function SK(t,e){let r=e.localName;if(e.oneof)return t[e.oneof.localName].case===r;if(e.presence!=EK)return t[r]!==void 0&&Object.prototype.hasOwnProperty.call(t,r);switch(e.fieldKind){case"list":return t[r].length>0;case"map":return Object.keys(t[r]).length>0;case"scalar":return!gK(e.scalar,t[r]);case"enum":return t[r]!==e.enum.values[0].number}throw new Error("message field with implicit presence")}function sc(t,e){return Object.prototype.hasOwnProperty.call(t,e)&&t[e]!==void 0}function zg(t,e){if(e.oneof){let r=t[e.oneof.localName];return r.case===e.localName?r.value:void 0}return t[e.localName]}function jg(t,e,r){e.oneof?t[e.oneof.localName]={case:e.localName,value:r}:t[e.localName]=r}function bK(t,e){let r=e.localName;if(e.oneof){let n=e.oneof.localName;t[n].case===r&&(t[n]={case:void 0})}else if(e.presence!=EK)delete t[r];else switch(e.fieldKind){case"map":t[r]={};break;case"list":t[r]=[];break;case"enum":t[r]=e.enum.values[0].number;break;case"scalar":t[r]=qn(e.scalar,e.longAsString);break}}function os(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function Ff(t,e){var r,n,i,s;if(os(t)&&Ui in t&&"add"in t&&"field"in t&&typeof t.field=="function"){if(e!==void 0){let a=e,o=t.field();return a.listKind==o.listKind&&a.scalar===o.scalar&&((r=a.message)===null||r===void 0?void 0:r.typeName)===((n=o.message)===null||n===void 0?void 0:n.typeName)&&((i=a.enum)===null||i===void 0?void 0:i.typeName)===((s=o.enum)===null||s===void 0?void 0:s.typeName)}return!0}return!1}function kf(t,e){var r,n,i,s;if(os(t)&&Ui in t&&"has"in t&&"field"in t&&typeof t.field=="function"){if(e!==void 0){let a=e,o=t.field();return a.mapKey===o.mapKey&&a.mapKind==o.mapKind&&a.scalar===o.scalar&&((r=a.message)===null||r===void 0?void 0:r.typeName)===((n=o.message)===null||n===void 0?void 0:n.typeName)&&((i=a.enum)===null||i===void 0?void 0:i.typeName)===((s=o.enum)===null||s===void 0?void 0:s.typeName)}return!0}return!1}function Bf(t,e){return os(t)&&Ui in t&&"desc"in t&&os(t.desc)&&t.desc.kind==="message"&&(e===void 0||t.desc.typeName==e.typeName)}u();function TK(t){return yK(t.$typeName)}function cs(t){let e=t.fields[0];return yK(t.typeName)&&e!==void 0&&e.fieldKind=="scalar"&&e.name=="value"&&e.number==1}function yK(t){return t.startsWith("google.protobuf.")&&["DoubleValue","FloatValue","Int64Value","UInt64Value","Int32Value","UInt32Value","BoolValue","StringValue","BytesValue"].includes(t.substring(16))}var Cve=999,Dve=998,Qg=2;function $r(t,e){if(Mf(e,t))return e;let r=vve(t);return e!==void 0&&Ave(t,r,e),r}function Ave(t,e,r){for(let n of t.members){let i=r[n.localName];if(i==null)continue;let s;if(n.kind=="oneof"){let a=Kg(r,n);if(!a)continue;s=a,i=zg(r,a)}else s=n;switch(s.fieldKind){case"message":i=tA(s,i);break;case"scalar":i=DK(s,i);break;case"list":i=Ove(s,i);break;case"map":i=Rve(s,i);break}jg(e,s,i)}return e}function DK(t,e){return t.scalar==z.BYTES?rA(e):e}function Rve(t,e){if(os(e)){if(t.scalar==z.BYTES)return xK(e,rA);if(t.mapKind=="message")return xK(e,r=>tA(t,r))}return e}function Ove(t,e){if(Array.isArray(e)){if(t.scalar==z.BYTES)return e.map(rA);if(t.listKind=="message")return e.map(r=>tA(t,r))}return e}function tA(t,e){if(t.fieldKind=="message"&&!t.oneof&&cs(t.message))return DK(t.message.fields[0],e);if(os(e)){if(t.message.typeName=="google.protobuf.Struct"&&t.parent.typeName!=="google.protobuf.Value")return e;if(!Mf(e,t.message))return $r(t.message,e)}return e}function rA(t){return Array.isArray(t)?new Uint8Array(t):t}function xK(t,e){let r={};for(let n of Object.entries(t))r[n[0]]=e(n[1]);return r}var Nve=Symbol(),CK=new WeakMap;function vve(t){let e;if(Ive(t)){let r=CK.get(t),n,i;if(r)({prototype:n,members:i}=r);else{n={},i=new Set;for(let s of t.members)s.kind!="oneof"&&(s.fieldKind!="scalar"&&s.fieldKind!="enum"||s.presence!=Qg&&(i.add(s),n[s.localName]=eA(s)));CK.set(t,{prototype:n,members:i})}e=Object.create(n),e.$typeName=t.typeName;for(let s of t.members)i.has(s)||s.kind=="field"&&(s.fieldKind=="message"||(s.fieldKind=="scalar"||s.fieldKind=="enum")&&s.presence!=Qg)||(e[s.localName]=eA(s))}else{e={$typeName:t.typeName};for(let r of t.members)(r.kind=="oneof"||r.presence==Qg)&&(e[r.localName]=eA(r))}return e}function Ive(t){switch(t.file.edition){case Cve:return!1;case Dve:return!0;default:return t.fields.some(e=>e.presence!=Qg&&e.fieldKind!="message"&&!e.oneof)}}function eA(t){if(t.kind=="oneof")return{case:void 0};if(t.fieldKind=="list")return[];if(t.fieldKind=="map")return{};if(t.fieldKind=="message")return Nve;let e=t.getDefaultValue();return e!==void 0?t.fieldKind=="scalar"&&t.longAsString?e.toString():e:t.fieldKind=="scalar"?qn(t.scalar,t.longAsString):t.enum.values[0].number}u();u();u();var wve=["FieldValueInvalidError","FieldListRangeError","ForeignFieldError"],br=class extends Error{constructor(e,r,n="FieldValueInvalidError"){super(r),this.name=n,this.field=()=>e}};function AK(t){return t instanceof Error&&wve.includes(t.name)&&"field"in t&&typeof t.field=="function"}u();u();var nA=Symbol.for("@bufbuild/protobuf/text-encoding");function Uf(){if(globalThis[nA]==null){let t=new globalThis.TextEncoder,e=new globalThis.TextDecoder;globalThis[nA]={encodeUtf8(r){return t.encode(r)},decodeUtf8(r){return e.decode(r)},checkUtf8(r){try{return encodeURIComponent(r),!0}catch{return!1}}}}return globalThis[nA]}var Zt;(function(t){t[t.Varint=0]="Varint",t[t.Bit64=1]="Bit64",t[t.LengthDelimited=2]="LengthDelimited",t[t.StartGroup=3]="StartGroup",t[t.EndGroup=4]="EndGroup",t[t.Bit32=5]="Bit32"})(Zt||(Zt={}));var sA=34028234663852886e22,aA=-34028234663852886e22,oA=4294967295,cA=2147483647,lA=-2147483648,Ua=class{constructor(e=Uf().encodeUtf8){this.encodeUtf8=e,this.stack=[],this.chunks=[],this.buf=[]}finish(){this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]);let e=0;for(let i=0;i<this.chunks.length;i++)e+=this.chunks[i].length;let r=new Uint8Array(e),n=0;for(let i=0;i<this.chunks.length;i++)r.set(this.chunks[i],n),n+=this.chunks[i].length;return this.chunks=[],r}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),r=this.stack.pop();if(!r)throw new Error("invalid state, fork stack empty");return this.chunks=r.chunks,this.buf=r.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,r){return this.uint32((e<<3|r)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(RK(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return iA(e),JD(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let r=this.encodeUtf8(e);return this.uint32(r.byteLength),this.raw(r)}float(e){Lve(e);let r=new Uint8Array(4);return new DataView(r.buffer).setFloat32(0,e,!0),this.raw(r)}double(e){let r=new Uint8Array(8);return new DataView(r.buffer).setFloat64(0,e,!0),this.raw(r)}fixed32(e){RK(e);let r=new Uint8Array(4);return new DataView(r.buffer).setUint32(0,e,!0),this.raw(r)}sfixed32(e){iA(e);let r=new Uint8Array(4);return new DataView(r.buffer).setInt32(0,e,!0),this.raw(r)}sint32(e){return iA(e),e=(e<<1^e>>31)>>>0,JD(e,this.buf),this}sfixed64(e){let r=new Uint8Array(8),n=new DataView(r.buffer),i=_t.enc(e);return n.setInt32(0,i.lo,!0),n.setInt32(4,i.hi,!0),this.raw(r)}fixed64(e){let r=new Uint8Array(8),n=new DataView(r.buffer),i=_t.uEnc(e);return n.setInt32(0,i.lo,!0),n.setInt32(4,i.hi,!0),this.raw(r)}int64(e){let r=_t.enc(e);return Wg(r.lo,r.hi,this.buf),this}sint64(e){let r=_t.enc(e),n=r.hi>>31,i=r.lo<<1^n,s=(r.hi<<1|r.lo>>>31)^n;return Wg(i,s,this.buf),this}uint64(e){let r=_t.uEnc(e);return Wg(r.lo,r.hi,this.buf),this}},ac=class{constructor(e,r=Uf().decodeUtf8){this.decodeUtf8=r,this.varint64=dK,this.uint32=mK,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength)}tag(){let e=this.uint32(),r=e>>>3,n=e&7;if(r<=0||n<0||n>5)throw new Error("illegal tag: field no "+r+" wire type "+n);return[r,n]}skip(e,r){let n=this.pos;switch(e){case Zt.Varint:for(;this.buf[this.pos++]&128;);break;case Zt.Bit64:this.pos+=4;case Zt.Bit32:this.pos+=4;break;case Zt.LengthDelimited:let i=this.uint32();this.pos+=i;break;case Zt.StartGroup:for(;;){let[s,a]=this.tag();if(a===Zt.EndGroup){if(r!==void 0&&s!==r)throw new Error("invalid end group tag");break}this.skip(a,s)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(n,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return _t.dec(...this.varint64())}uint64(){return _t.uDec(...this.varint64())}sint64(){let[e,r]=this.varint64(),n=-(e&1);return e=(e>>>1|(r&1)<<31)^n,r=r>>>1^n,_t.dec(e,r)}bool(){let[e,r]=this.varint64();return e!==0||r!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return _t.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return _t.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),r=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(r,r+e)}string(){return this.decodeUtf8(this.bytes())}};function iA(t){if(typeof t=="string")t=Number(t);else if(typeof t!="number")throw new Error("invalid int32: "+typeof t);if(!Number.isInteger(t)||t>cA||t<lA)throw new Error("invalid int32: "+t)}function RK(t){if(typeof t=="string")t=Number(t);else if(typeof t!="number")throw new Error("invalid uint32: "+typeof t);if(!Number.isInteger(t)||t>oA||t<0)throw new Error("invalid uint32: "+t)}function Lve(t){if(typeof t=="string"){let e=t;if(t=Number(t),Number.isNaN(t)&&e!=="NaN")throw new Error("invalid float32: "+e)}else if(typeof t!="number")throw new Error("invalid float32: "+typeof t);if(Number.isFinite(t)&&(t>sA||t<aA))throw new Error("invalid float32: "+t)}function $s(t,e){let r=t.fieldKind=="list"?Ff(e,t):t.fieldKind=="map"?kf(e,t):dA(t,e);if(r===!0)return;let n;switch(t.fieldKind){case"list":n=`expected ${IK(t)}, got ${dr(e)}`;break;case"map":n=`expected ${wK(t)}, got ${dr(e)}`;break;default:n=Xg(t,e,r)}return new br(t,n)}function uA(t,e,r){let n=dA(t,r);if(n!==!0)return new br(t,`list item #${e+1}: ${Xg(t,r,n)}`)}function OK(t,e,r){let n=NK(e,t.mapKey);if(n!==!0)return new br(t,`invalid map key: ${Xg({scalar:t.mapKey},e,n)}`);let i=dA(t,r);if(i!==!0)return new br(t,`map entry ${dr(e)}: ${Xg(t,r,i)}`)}function dA(t,e){return t.scalar!==void 0?NK(e,t.scalar):t.enum!==void 0?t.enum.open?Number.isInteger(e):t.enum.values.some(r=>r.number===e):Bf(e,t.message)}function NK(t,e){switch(e){case z.DOUBLE:return typeof t=="number";case z.FLOAT:return typeof t!="number"?!1:Number.isNaN(t)||!Number.isFinite(t)?!0:t>sA||t<aA?`${t.toFixed()} out of range`:!0;case z.INT32:case z.SFIXED32:case z.SINT32:return typeof t!="number"||!Number.isInteger(t)?!1:t>cA||t<lA?`${t.toFixed()} out of range`:!0;case z.FIXED32:case z.UINT32:return typeof t!="number"||!Number.isInteger(t)?!1:t>oA||t<0?`${t.toFixed()} out of range`:!0;case z.BOOL:return typeof t=="boolean";case z.STRING:return typeof t!="string"?!1:Uf().checkUtf8(t)||"invalid UTF8";case z.BYTES:return t instanceof Uint8Array;case z.INT64:case z.SFIXED64:case z.SINT64:if(typeof t=="bigint"||typeof t=="number"||typeof t=="string"&&t.length>0)try{return _t.parse(t),!0}catch{return`${t} out of range`}return!1;case z.FIXED64:case z.UINT64:if(typeof t=="bigint"||typeof t=="number"||typeof t=="string"&&t.length>0)try{return _t.uParse(t),!0}catch{return`${t} out of range`}return!1}}function Xg(t,e,r){return r=typeof r=="string"?`: ${r}`:`, got ${dr(e)}`,t.scalar!==void 0?`expected ${Pve(t.scalar)}`+r:t.enum!==void 0?`expected ${t.enum.toString()}`+r:`expected ${vK(t.message)}`+r}function dr(t){switch(typeof t){case"object":return t===null?"null":t instanceof Uint8Array?`Uint8Array(${t.length})`:Array.isArray(t)?`Array(${t.length})`:Ff(t)?IK(t.field()):kf(t)?wK(t.field()):Bf(t)?vK(t.desc):Mf(t)?`message ${t.$typeName}`:"object";case"string":return t.length>30?"string":`"${t.split('"').join('\\"')}"`;case"boolean":return String(t);case"number":return String(t);case"bigint":return String(t)+"n";default:return typeof t}}function vK(t){return`ReflectMessage (${t.typeName})`}function IK(t){switch(t.listKind){case"message":return`ReflectList (${t.message.toString()})`;case"enum":return`ReflectList (${t.enum.toString()})`;case"scalar":return`ReflectList (${z[t.scalar]})`}}function wK(t){switch(t.mapKind){case"message":return`ReflectMap (${z[t.mapKey]}, ${t.message.toString()})`;case"enum":return`ReflectMap (${z[t.mapKey]}, ${t.enum.toString()})`;case"scalar":return`ReflectMap (${z[t.mapKey]}, ${z[t.scalar]})`}}function Pve(t){switch(t){case z.STRING:return"string";case z.BOOL:return"boolean";case z.INT64:case z.SINT64:case z.SFIXED64:return"bigint (int64)";case z.UINT64:case z.FIXED64:return"bigint (uint64)";case z.BYTES:return"Uint8Array";case z.DOUBLE:return"number (float64)";case z.FLOAT:return"number (float32)";case z.FIXED32:case z.UINT32:return"number (uint32)";case z.INT32:case z.SFIXED32:case z.SINT32:return"number (int32)"}}function Yr(t,e,r=!0){return new Jg(t,e,r)}var Jg=class{get sortedFields(){var e;return(e=this._sortedFields)!==null&&e!==void 0?e:this._sortedFields=this.desc.fields.concat().sort((r,n)=>r.number-n.number)}constructor(e,r,n=!0){this.lists=new Map,this.maps=new Map,this.check=n,this.desc=e,this.message=this[Ui]=r??$r(e),this.fields=e.fields,this.oneofs=e.oneofs,this.members=e.members}findNumber(e){return this._fieldsByNumber||(this._fieldsByNumber=new Map(this.desc.fields.map(r=>[r.number,r]))),this._fieldsByNumber.get(e)}oneofCase(e){return Gf(this.message,e),Kg(this.message,e)}isSet(e){return Gf(this.message,e),SK(this.message,e)}clear(e){Gf(this.message,e),bK(this.message,e)}get(e){Gf(this.message,e);let r=zg(this.message,e);switch(e.fieldKind){case"list":let n=this.lists.get(e);return(!n||n[Ui]!==r)&&this.lists.set(e,n=new mA(e,r,this.check)),n;case"map":let i=this.maps.get(e);return(!i||i[Ui]!==r)&&this.maps.set(e,i=new hA(e,r,this.check)),i;case"message":return gA(e,r,this.check);case"scalar":return r===void 0?qn(e.scalar,!1):EA(e,r);case"enum":return r??e.enum.values[0].number}}set(e,r){if(Gf(this.message,e),this.check){let i=$s(e,r);if(i)throw i}let n;e.fieldKind=="message"?n=_A(e,r):kf(r)||Ff(r)?n=r[Ui]:n=SA(e,r),jg(this.message,e,n)}getUnknown(){return this.message.$unknown}setUnknown(e){this.message.$unknown=e}};function Gf(t,e){if(e.parent.typeName!==t.$typeName)throw new br(e,`cannot use ${e.toString()} with message ${t.$typeName}`,"ForeignFieldError")}var mA=class{field(){return this._field}get size(){return this._arr.length}constructor(e,r,n){this._field=e,this._arr=this[Ui]=r,this.check=n}get(e){let r=this._arr[e];return r===void 0?void 0:fA(this._field,r,this.check)}set(e,r){if(e<0||e>=this._arr.length)throw new br(this._field,`list item #${e+1}: out of range`);if(this.check){let n=uA(this._field,e,r);if(n)throw n}this._arr[e]=LK(this._field,r)}add(e){if(this.check){let r=uA(this._field,this._arr.length,e);if(r)throw r}this._arr.push(LK(this._field,e))}clear(){this._arr.splice(0,this._arr.length)}[Symbol.iterator](){return this.values()}keys(){return this._arr.keys()}*values(){for(let e of this._arr)yield fA(this._field,e,this.check)}*entries(){for(let e=0;e<this._arr.length;e++)yield[e,fA(this._field,this._arr[e],this.check)]}};var hA=class{constructor(e,r,n=!0){this.obj=this[Ui]=r??{},this.check=n,this._field=e}field(){return this._field}set(e,r){if(this.check){let n=OK(this._field,e,r);if(n)throw n}return this.obj[Zg(e)]=Mve(this._field,r),this}delete(e){let r=Zg(e),n=Object.prototype.hasOwnProperty.call(this.obj,r);return n&&delete this.obj[r],n}clear(){for(let e of Object.keys(this.obj))delete this.obj[e]}get(e){let r=this.obj[Zg(e)];return r!==void 0&&(r=pA(this._field,r,this.check)),r}has(e){return Object.prototype.hasOwnProperty.call(this.obj,Zg(e))}*keys(){for(let e of Object.keys(this.obj))yield PK(e,this._field.mapKey)}*entries(){for(let e of Object.entries(this.obj))yield[PK(e[0],this._field.mapKey),pA(this._field,e[1],this.check)]}[Symbol.iterator](){return this.entries()}get size(){return Object.keys(this.obj).length}*values(){for(let e of Object.values(this.obj))yield pA(this._field,e,this.check)}forEach(e,r){for(let n of this.entries())e.call(r,n[1],n[0],this)}};function _A(t,e){return Bf(e)?TK(e.message)&&!t.oneof&&t.fieldKind=="message"?e.message.value:e.desc.typeName=="google.protobuf.Struct"&&t.parent.typeName!="google.protobuf.Value"?FK(e.message):e.message:e}function gA(t,e,r){return e!==void 0&&(cs(t.message)&&!t.oneof&&t.fieldKind=="message"?e={$typeName:t.message.typeName,value:EA(t.message.fields[0],e)}:t.message.typeName=="google.protobuf.Struct"&&t.parent.typeName!="google.protobuf.Value"&&os(e)&&(e=MK(e))),new Jg(t.message,e,r)}function LK(t,e){return t.listKind=="message"?_A(t,e):SA(t,e)}function fA(t,e,r){return t.listKind=="message"?gA(t,e,r):EA(t,e)}function Mve(t,e){return t.mapKind=="message"?_A(t,e):SA(t,e)}function pA(t,e,r){return t.mapKind=="message"?gA(t,e,r):e}function Zg(t){return typeof t=="string"||typeof t=="number"?t:String(t)}function PK(t,e){switch(e){case z.STRING:return t;case z.INT32:case z.FIXED32:case z.UINT32:case z.SFIXED32:case z.SINT32:{let r=Number.parseInt(t);if(Number.isFinite(r))return r;break}case z.BOOL:switch(t){case"true":return!0;case"false":return!1}break;case z.UINT64:case z.FIXED64:try{return _t.uParse(t)}catch{}break;default:try{return _t.parse(t)}catch{}break}return t}function EA(t,e){switch(t.scalar){case z.INT64:case z.SFIXED64:case z.SINT64:"longAsString"in t&&t.longAsString&&typeof e=="string"&&(e=_t.parse(e));break;case z.FIXED64:case z.UINT64:"longAsString"in t&&t.longAsString&&typeof e=="string"&&(e=_t.uParse(e));break}return e}function SA(t,e){switch(t.scalar){case z.INT64:case z.SFIXED64:case z.SINT64:"longAsString"in t&&t.longAsString?e=String(e):(typeof e=="string"||typeof e=="number")&&(e=_t.parse(e));break;case z.FIXED64:case z.UINT64:"longAsString"in t&&t.longAsString?e=String(e):(typeof e=="string"||typeof e=="number")&&(e=_t.uParse(e));break}return e}function MK(t){let e={$typeName:"google.protobuf.Struct",fields:{}};if(os(t))for(let[r,n]of Object.entries(t))e.fields[r]=BK(n);return e}function FK(t){let e={};for(let[r,n]of Object.entries(t.fields))e[r]=kK(n);return e}function kK(t){switch(t.kind.case){case"structValue":return FK(t.kind.value);case"listValue":return t.kind.value.values.map(kK);case"nullValue":case void 0:return null;default:return t.kind.value}}function BK(t){let e={$typeName:"google.protobuf.Value",kind:{case:void 0}};switch(typeof t){case"number":e.kind={case:"numberValue",value:t};break;case"string":e.kind={case:"stringValue",value:t};break;case"boolean":e.kind={case:"boolValue",value:t};break;case"object":if(t===null)e.kind={case:"nullValue",value:0};else if(Array.isArray(t)){let r={$typeName:"google.protobuf.ListValue",values:[]};if(Array.isArray(t))for(let n of t)r.values.push(BK(n));e.kind={case:"listValue",value:r}}else e.kind={case:"structValue",value:MK(t)};break}return e}u();u();u();function Ql(t){let e=Fve(),r=t.length*3/4;t[t.length-2]=="="?r-=2:t[t.length-1]=="="&&(r-=1);let n=new Uint8Array(r),i=0,s=0,a,o=0;for(let c=0;c<t.length;c++){if(a=e[t.charCodeAt(c)],a===void 0)switch(t[c]){case"=":s=0;case`
@@ -254,7 +254,7 @@ attempted value: ${a}
254
254
  # import { Sandbox } from 'e2b'
255
255
  # const sandbox = await Sandbox.create('${t.template_name||t.template_id}')
256
256
 
257
- `}var vX=DO({template_id:Qa().required(),template_name:Qa().optional(),dockerfile:Qa().required(),start_cmd:Qa().optional(),ready_cmd:Qa().optional(),cpu_count:X0().integer().min(1).optional(),memory_mb:X0().integer().min(128).optional(),team_id:Qa().optional()}),j9e=[{from:"id",to:"template_id"},{from:"name",to:"template_name"}];function Q9e(t,e){for(let r of e){let n=r.from,i=r.to;t[n]&&(t[i]=t[n],delete t[n])}return t}async function fs(t){let e=await _u.readFile(t,"utf-8"),r=sE.parse(e),n=Q9e(r,j9e);return await vX.validate(n)}async function IX(t,e,r){try{if(!r&&NX.existsSync(t))throw new Error(`Config already exists on path ${At(t)}`);let n=await vX.validate(e,{stripUnknown:!0}),i=sE.stringify(n);await _u.writeFile(t,z9e(e)+i)}catch(n){throw new Error(`E2B sandbox template config ${rr({templateID:e.template_id},t)} cannot be saved: ${n.message}`)}}async function wX(t){await _u.unlink(t)}function ps(t,e){return e&&aE.isAbsolute(e)?e:aE.join(t,e||Xa)}u();async function Za(t){return new Promise(e=>setTimeout(e,t))}u();var kX=J(FX()),PO=class extends Error{constructor(e){super(e),this.name="E2BRequestError"}};function an(t,e){if(!t.error)return;let r,n=t.error?.code??0;switch(n){case 400:r="bad request";break;case 401:r="unauthorized";break;case 403:r="forbidden";break;case 404:r="not found";break;case 500:r="internal server error";break;default:r=(0,kX.default)(n)||"unknown error";break}throw new PO(`${e&&`${e}: `}[${n}] ${r&&`${r}: `}${t.error?.message??"no message"}`)}u();var MO=J(require("child_process")),BX=J(require("http")),UX=J(require("url")),GX=J(require("https"));u();async function gu(t,e=!1){return(await(await import("inquirer")).default.prompt([{name:"confirm",type:"confirm",default:e,message:t}])).confirm}var HX=J(require("fs")),oE=49984;async function qX(t,e,r,n,i){t?.dockerProxySet||(console.log("There was an issue during Docker authentication. Please follow the workaround steps from https://e2b.dev/docs/troubleshooting/templates/build-authentication-error and then continue."),await gu("Have you completed the steps from the https://e2b.dev/docs/troubleshooting/templates/build-authentication-error workaround guide?")||(console.log("Please follow the workaround steps from https://e2b.dev/docs/troubleshooting/templates/build-authentication-error and then try again."),process.exit(1)));let s,a=new Promise(d=>{s=d}),o=Buffer.from(`_e2b_access_token:${r}`).toString("base64"),c=await r5e(e,n,o,s);await a,await t5e(e,n,i)||(console.error("Docker push failed"),process.exit(1)),t&&!t.dockerProxySet&&(t.dockerProxySet=!0,HX.writeFileSync(In,JSON.stringify(t,null,2))),c.close()}async function t5e(t,e,r){let n=process.platform==="linux"?"localhost":"host.docker.internal",i=!1;MO.default.execSync(`docker tag docker.${t.domain}/e2b/custom-envs/${e.templateID}:${e.buildID} ${n}:${oE}/e2b/custom-envs/${e.templateID}:${e.buildID}`,{stdio:"inherit",cwd:r});let s,a=new Promise(c=>{s=c}),o=MO.default.spawn("docker",["push",`${n}:${oE}/e2b/custom-envs/${e.templateID}:${e.buildID}`],{detached:!0,stdio:"inherit",cwd:r});return o.on("exit",c=>{c!==0&&(console.error("Docker push failed"),process.exit(1)),i=!0,s(c)}),o.on("error",c=>{console.error("Error",c),process.exit(1)}),await a,i}async function r5e(t,e,r,n){let i=await fetch(`https://docker.${t.domain}/v2/token?account=_e2b_access_token&scope=repository%3Ae2b%2Fcustom-envs%2F${e.templateID}%3Apush%2Cpull`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Basic ${r}`}}),{token:s}=await i.json(),a=BX.createServer((o,c)=>{let l=new UX.URL(o.url||"/",`https://docker.${t.domain}`),d={protocol:"https:",hostname:l.hostname,method:o.method,path:l.pathname+l.search,headers:{...o.headers,host:l.hostname}},f=d.headers;f.Authorization||(l.pathname.startsWith("/v2/token")?f.Authorization=`Basic ${r}`:l.pathname=="/v2/"||l.pathname=="/v2"?f.Authorization=`Bearer ${r}`:l.pathname.startsWith("/artifacts-uploads/namespaces")||(f.Authorization=`Bearer ${s}`));let m=GX.request(d,p=>{c.writeHead(p.statusCode||500,p.headers),p.pipe(c,{end:!0})});m.on("error",p=>{console.error("Proxy Request Error:",p),c.statusCode=500,c.end(`Proxy Error: ${p.message}`)}),o.pipe(m,{end:!0})});return a.on("error",o=>{console.error("Server Error:",o)}),a.listen(oE,()=>{n(null),console.log(`Proxy server running on port ${oE}`)}),a}var n5e=500,FO=process.env.E2B_IMAGE_URI_MASK;async function i5e({templateID:t,buildID:e,logsOffset:r}){let n=wn.getSignal(),i=await Sn.api.GET("/templates/{templateID}/builds/{buildID}/status",{signal:n,params:{path:{templateID:t,buildID:e},query:{logsOffset:r}}});return an(i,"Error getting template build status"),i.data}async function s5e(t){return await Sn.api.POST("/templates",{body:t})}async function a5e(t,e){return await Sn.api.POST("/templates/{templateID}",{body:e,params:{path:{templateID:t}}})}async function o5e(t,e){let r;for(let i=0;i<3;i++)try{r=await Sn.api.POST("/templates/{templateID}/builds/{buildID}",{params:{path:{templateID:t,buildID:e}}});break}catch(s){s instanceof TypeError&&s.cause?.code!=="UND_ERR_SOCKET"&&(console.error(s),console.log("Retrying..."))}if(!r)throw new Error("Error triggering template build");return an(r,"Error triggering template build"),r.data}var YX=new $e("build").description(`build sandbox template defined by ${At(za)} or ${At(du)} in root directory. By default the root directory is the current working directory. This command also creates ${Dt(Xa)} config.`).argument("[template]",`specify ${Oe("[template]")} to rebuild it. If you dont's specify ${Oe("[template]")} and there is no ${Dt("e2b.toml")} a new sandbox template will be created.`).addOption(bn).option("-d, --dockerfile <file>",`specify path to Dockerfile. By default E2B tries to find ${Dt(za)} or ${Dt(du)} in root directory.`).option("-n, --name <template-name>","specify sandbox template name. You can use the template name to start the sandbox with SDK. The template name must be lowercase and contain only letters, numbers, dashes and underscores.").option("-c, --cmd <start-command>","specify command that will be executed when the sandbox is started.").option("--ready-cmd <ready-command>","specify command that will need to exit 0 for the template to be ready.").addOption(Xs).addOption(qi).option("--cpu-count <cpu-count>","specify the number of CPUs that will be used to run the sandbox. The default value is 2.",parseInt).option("--memory-mb <memory-mb>","specify the amount of memory in megabytes that will be used to run the sandbox. Must be an even number. The default value is 512.",parseInt).option("--build-arg <args...>","specify additional build arguments for the build command. The format should be <varname>=<value>.").option("--no-cache","skip cache when building the template.").alias("bd").action(async(t,e)=>{try{let r=`${Oe("DEPRECATION WARNING")}
257
+ `}var vX=DO({template_id:Qa().required(),template_name:Qa().optional(),dockerfile:Qa().required(),start_cmd:Qa().optional(),ready_cmd:Qa().optional(),cpu_count:X0().integer().min(1).optional(),memory_mb:X0().integer().min(128).optional(),team_id:Qa().optional()}),j9e=[{from:"id",to:"template_id"},{from:"name",to:"template_name"}];function Q9e(t,e){for(let r of e){let n=r.from,i=r.to;t[n]&&(t[i]=t[n],delete t[n])}return t}async function fs(t){let e=await _u.readFile(t,"utf-8"),r=sE.parse(e),n=Q9e(r,j9e);return await vX.validate(n)}async function IX(t,e,r){try{if(!r&&NX.existsSync(t))throw new Error(`Config already exists on path ${At(t)}`);let n=await vX.validate(e,{stripUnknown:!0}),i=sE.stringify(n);await _u.writeFile(t,z9e(e)+i)}catch(n){throw new Error(`E2B sandbox template config ${rr({templateID:e.template_id},t)} cannot be saved: ${n.message}`)}}async function wX(t){await _u.unlink(t)}function ps(t,e){return e&&aE.isAbsolute(e)?e:aE.join(t,e||Xa)}u();async function Za(t){return new Promise(e=>setTimeout(e,t))}u();var kX=J(FX()),PO=class extends Error{constructor(e){super(e),this.name="E2BRequestError"}};function an(t,e){if(!t.error)return;let r,n=t.error?.code??0;switch(n){case 400:r="bad request";break;case 401:r="unauthorized";break;case 403:r="forbidden";break;case 404:r="not found";break;case 500:r="internal server error";break;default:r=kX.default.message[n]||"unknown error";break}throw new PO(`${e&&`${e}: `}[${n}] ${r&&`${r}: `}${t.error?.message??"no message"}`)}u();var MO=J(require("child_process")),BX=J(require("http")),UX=J(require("url")),GX=J(require("https"));u();async function gu(t,e=!1){return(await(await import("inquirer")).default.prompt([{name:"confirm",type:"confirm",default:e,message:t}])).confirm}var HX=J(require("fs")),oE=49984;async function qX(t,e,r,n,i){t?.dockerProxySet||(console.log("There was an issue during Docker authentication. Please follow the workaround steps from https://e2b.dev/docs/troubleshooting/templates/build-authentication-error and then continue."),await gu("Have you completed the steps from the https://e2b.dev/docs/troubleshooting/templates/build-authentication-error workaround guide?")||(console.log("Please follow the workaround steps from https://e2b.dev/docs/troubleshooting/templates/build-authentication-error and then try again."),process.exit(1)));let s,a=new Promise(d=>{s=d}),o=Buffer.from(`_e2b_access_token:${r}`).toString("base64"),c=await r5e(e,n,o,s);await a,await t5e(e,n,i)||(console.error("Docker push failed"),process.exit(1)),t&&!t.dockerProxySet&&(t.dockerProxySet=!0,HX.writeFileSync(In,JSON.stringify(t,null,2))),c.close()}async function t5e(t,e,r){let n=process.platform==="linux"?"localhost":"host.docker.internal",i=!1;MO.default.execSync(`docker tag docker.${t.domain}/e2b/custom-envs/${e.templateID}:${e.buildID} ${n}:${oE}/e2b/custom-envs/${e.templateID}:${e.buildID}`,{stdio:"inherit",cwd:r});let s,a=new Promise(c=>{s=c}),o=MO.default.spawn("docker",["push",`${n}:${oE}/e2b/custom-envs/${e.templateID}:${e.buildID}`],{detached:!0,stdio:"inherit",cwd:r});return o.on("exit",c=>{c!==0&&(console.error("Docker push failed"),process.exit(1)),i=!0,s(c)}),o.on("error",c=>{console.error("Error",c),process.exit(1)}),await a,i}async function r5e(t,e,r,n){let i=await fetch(`https://docker.${t.domain}/v2/token?account=_e2b_access_token&scope=repository%3Ae2b%2Fcustom-envs%2F${e.templateID}%3Apush%2Cpull`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Basic ${r}`}}),{token:s}=await i.json(),a=BX.createServer((o,c)=>{let l=new UX.URL(o.url||"/",`https://docker.${t.domain}`),d={protocol:"https:",hostname:l.hostname,method:o.method,path:l.pathname+l.search,headers:{...o.headers,host:l.hostname}},f=d.headers;f.Authorization||(l.pathname.startsWith("/v2/token")?f.Authorization=`Basic ${r}`:l.pathname=="/v2/"||l.pathname=="/v2"?f.Authorization=`Bearer ${r}`:l.pathname.startsWith("/artifacts-uploads/namespaces")||(f.Authorization=`Bearer ${s}`));let m=GX.request(d,p=>{c.writeHead(p.statusCode||500,p.headers),p.pipe(c,{end:!0})});m.on("error",p=>{console.error("Proxy Request Error:",p),c.statusCode=500,c.end(`Proxy Error: ${p.message}`)}),o.pipe(m,{end:!0})});return a.on("error",o=>{console.error("Server Error:",o)}),a.listen(oE,()=>{n(null),console.log(`Proxy server running on port ${oE}`)}),a}var n5e=500,FO=process.env.E2B_IMAGE_URI_MASK;async function i5e({templateID:t,buildID:e,logsOffset:r}){let n=wn.getSignal(),i=await Sn.api.GET("/templates/{templateID}/builds/{buildID}/status",{signal:n,params:{path:{templateID:t,buildID:e},query:{logsOffset:r}}});return an(i,"Error getting template build status"),i.data}async function s5e(t){return await Sn.api.POST("/templates",{body:t})}async function a5e(t,e){return await Sn.api.POST("/templates/{templateID}",{body:e,params:{path:{templateID:t}}})}async function o5e(t,e){let r;for(let i=0;i<3;i++)try{r=await Sn.api.POST("/templates/{templateID}/builds/{buildID}",{params:{path:{templateID:t,buildID:e}}});break}catch(s){s instanceof TypeError&&s.cause?.code!=="UND_ERR_SOCKET"&&(console.error(s),console.log("Retrying..."))}if(!r)throw new Error("Error triggering template build");return an(r,"Error triggering template build"),r.data}var YX=new $e("build").description(`build sandbox template defined by ${At(za)} or ${At(du)} in root directory. By default the root directory is the current working directory. This command also creates ${Dt(Xa)} config.`).argument("[template]",`specify ${Oe("[template]")} to rebuild it. If you dont's specify ${Oe("[template]")} and there is no ${Dt("e2b.toml")} a new sandbox template will be created.`).addOption(bn).option("-d, --dockerfile <file>",`specify path to Dockerfile. By default E2B tries to find ${Dt(za)} or ${Dt(du)} in root directory.`).option("-n, --name <template-name>","specify sandbox template name. You can use the template name to start the sandbox with SDK. The template name must be lowercase and contain only letters, numbers, dashes and underscores.").option("-c, --cmd <start-command>","specify command that will be executed when the sandbox is started.").option("--ready-cmd <ready-command>","specify command that will need to exit 0 for the template to be ready.").addOption(Xs).addOption(qi).option("--cpu-count <cpu-count>","specify the number of CPUs that will be used to run the sandbox. The default value is 2.",parseInt).option("--memory-mb <memory-mb>","specify the amount of memory in megabytes that will be used to run the sandbox. Must be an even number. The default value is 512.",parseInt).option("--build-arg <args...>","specify additional build arguments for the build command. The format should be <varname>=<value>.").option("--no-cache","skip cache when building the template.").alias("bd").action(async(t,e)=>{try{let r=`${Oe("DEPRECATION WARNING")}
258
258
 
259
259
  This is the v1 build system which is now deprecated.
260
260
  Please migrate to the new build system v2.