@evolvingmachines/e2b 0.0.35 → 0.0.38
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.cjs +2 -2
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var codeInterpreter=require('@e2b/code-interpreter');var
|
|
2
|
-
exports.E2BProvider=u;exports.createE2BProvider=
|
|
1
|
+
'use strict';var codeInterpreter=require('@e2b/code-interpreter');var p=new Set([".xlsx",".xls",".docx",".doc",".pptx",".ppt",".pdf",".zip",".tar",".gz",".7z",".rar",".png",".jpg",".jpeg",".gif",".webp",".ico",".bmp",".mp3",".wav",".ogg",".flac",".aac",".mp4",".avi",".mov",".mkv",".webm",".woff",".woff2",".ttf",".otf",".eot",".exe",".dll",".so",".dylib",".sqlite",".db",".pickle",".pkl",".parquet"]);function a(i){return i instanceof Date?i.toISOString():String(i)}function l(i){if(typeof i=="string"||i instanceof ArrayBuffer)return i;if(i instanceof Buffer)return new Uint8Array(i).buffer;if(i instanceof Uint8Array)return new Uint8Array(i).buffer;throw new Error(`Unsupported data type for file upload: ${typeof i}. Expected string, Buffer, ArrayBuffer, or Uint8Array.`)}function g(i){let t=i.substring(i.lastIndexOf(".")).toLowerCase();return p.has(t)}var m=class{constructor(t){this.sandbox=t;}async run(t,e){try{let n=await this.sandbox.commands.run(t,{timeoutMs:e?.timeoutMs,envs:e?.envs,cwd:e?.cwd,onStdout:e?.onStdout,onStderr:e?.onStderr});return {exitCode:n.exitCode,stdout:n.stdout,stderr:n.stderr}}catch(n){if(n&&typeof n=="object"&&"exitCode"in n){let r=n;return {exitCode:r.exitCode,stdout:r.stdout??"",stderr:r.stderr??""}}throw n}}async spawn(t,e){let n=await this.sandbox.commands.run(t,{background:true,stdin:e?.stdin??true,timeoutMs:e?.timeoutMs,envs:e?.envs,cwd:e?.cwd,onStdout:e?.onStdout,onStderr:e?.onStderr});return {processId:String(n.pid),wait:async()=>{try{let r=await n.wait();return {exitCode:r.exitCode,stdout:r.stdout,stderr:r.stderr}}catch(r){if(r&&typeof r=="object"&&"exitCode"in r){let s=r;return {exitCode:s.exitCode,stdout:s.stdout??"",stderr:s.stderr??""}}throw r}},kill:()=>this.sandbox.commands.kill(n.pid)}}async list(){return (await this.sandbox.commands.list()).map(e=>({...e,processId:String(e.pid)}))}async connect(t,e){let n=await this.sandbox.commands.connect(Number(t),{onStdout:e?.onStdout,onStderr:e?.onStderr,timeoutMs:e?.timeoutMs});return {processId:String(n.pid),wait:async()=>{try{let r=await n.wait();return {exitCode:r.exitCode,stdout:r.stdout,stderr:r.stderr}}catch(r){if(r&&typeof r=="object"&&"exitCode"in r){let s=r;return {exitCode:s.exitCode,stdout:s.stdout??"",stderr:s.stderr??""}}throw r}},kill:()=>this.sandbox.commands.kill(n.pid)}}async sendStdin(t,e){await this.sandbox.commands.sendStdin(Number(t),e);}async kill(t){return this.sandbox.commands.kill(Number(t))}},c=class{constructor(t){this.sandbox=t;}async read(t){return g(t)?this.sandbox.files.read(t,{format:"bytes",requestTimeoutMs:3e5}):this.sandbox.files.read(t,{format:"text",requestTimeoutMs:3e5})}async write(t,e){await this.sandbox.files.write(t,l(e),{requestTimeoutMs:3e5});}async writeBatch(t){let e=t.map(n=>({path:n.path,data:l(n.data)}));await this.sandbox.files.write(e,{requestTimeoutMs:3e5});}async makeDir(t){await this.sandbox.files.makeDir(t);}async uploadUrl(t,e){return this.sandbox.uploadUrl(t,e?{useSignatureExpiration:e}:void 0)}async downloadUrl(t,e){return this.sandbox.downloadUrl(t,e?{useSignatureExpiration:e}:void 0)}async exists(t){return this.sandbox.files.exists(t)}async list(t){return (await this.sandbox.files.list(t)).map(n=>({name:n.name,path:n.path,type:n.type==="dir"?"dir":"file"}))}async remove(t){await this.sandbox.files.remove(t);}async rename(t,e){await this.sandbox.files.rename(t,e);}async readStream(t){return this.sandbox.files.read(t,{format:"stream"})}async writeStream(t,e){await this.sandbox.files.write(t,e);}async watchDir(t,e,n){let r=await this.sandbox.files.watchDir(t,e,{recursive:n?.recursive,timeoutMs:n?.timeoutMs,onExit:n?.onExit});return {stop:()=>r.stop()}}},o=class{constructor(t,e,n){this.sandbox=t;this.apiKey=e;this.apiUrl=n;this.commands=new m(t),this.files=new c(t);}commands;files;get sandboxId(){return this.sandbox.sandboxId}getHost(t){return Promise.resolve(this.sandbox.getHost(t))}async isRunning(){return this.sandbox.isRunning()}async getInfo(){let t=await this.sandbox.getInfo();return {sandboxId:t.sandboxId,image:t.templateId,name:t.name,metadata:t.metadata??{},startedAt:a(t.startedAt),endAt:t.endAt?a(t.endAt):void 0}}async kill(){try{await this.sandbox.kill();}catch{await new Promise(t=>setTimeout(t,500)),await this.sandbox.kill();}}async pause(){await this.sandbox.betaPause({apiKey:this.apiKey,apiUrl:this.apiUrl});}},u=class{providerType="e2b";apiKey;apiUrl;defaultTimeoutMs;templateId;constructor(t){this.apiKey=t.apiKey,this.apiUrl=t.apiUrl,this.defaultTimeoutMs=t.defaultTimeoutMs??36e5,this.templateId=t.templateId;}async create(t){let e=t.timeoutMs??this.defaultTimeoutMs,n=t.image??this.templateId??"evolve-all",r=await codeInterpreter.Sandbox.create(n,{apiKey:this.apiKey,apiUrl:this.apiUrl,envs:t.envs,metadata:t.metadata,timeoutMs:e});return t.workingDirectory&&await r.files.makeDir(t.workingDirectory),new o(r,this.apiKey,this.apiUrl)}async connect(t,e){let n=await codeInterpreter.Sandbox.connect(t,{apiKey:this.apiKey,apiUrl:this.apiUrl,timeoutMs:e??this.defaultTimeoutMs});return new o(n,this.apiKey,this.apiUrl)}async list(t){return (await codeInterpreter.Sandbox.list({apiKey:this.apiKey,apiUrl:this.apiUrl,query:{state:t?.state,metadata:t?.metadata},limit:t?.limit??100}).nextItems()).map(r=>({sandboxId:r.sandboxId,image:r.templateId,name:r.name,metadata:r.metadata??{},startedAt:a(r.startedAt),endAt:r.endAt?a(r.endAt):void 0}))}};function b(i={}){let t=i.apiKey??process.env.E2B_API_KEY;if(!t)throw new Error("E2B API key required. Set E2B_API_KEY environment variable or pass apiKey in config. Get your key at https://e2b.dev/sign-in");return new u({...i,apiKey:t})}
|
|
2
|
+
exports.E2BProvider=u;exports.createE2BProvider=b;
|
package/dist/index.d.cts
CHANGED
|
@@ -174,6 +174,8 @@ interface SandboxProvider {
|
|
|
174
174
|
interface E2BConfig {
|
|
175
175
|
/** E2B API key. Default: reads from E2B_API_KEY env var */
|
|
176
176
|
apiKey?: string;
|
|
177
|
+
/** @internal E2B API base URL override, used for managed gateway routing */
|
|
178
|
+
apiUrl?: string;
|
|
177
179
|
defaultTimeoutMs?: number;
|
|
178
180
|
/** E2B template ID (default: 'evolve-all'). Create custom templates at https://e2b.dev/docs/sandbox-template */
|
|
179
181
|
templateId?: string;
|
|
@@ -181,12 +183,14 @@ interface E2BConfig {
|
|
|
181
183
|
/** Internal resolved config with required apiKey */
|
|
182
184
|
interface ResolvedE2BConfig {
|
|
183
185
|
apiKey: string;
|
|
186
|
+
apiUrl?: string;
|
|
184
187
|
defaultTimeoutMs?: number;
|
|
185
188
|
templateId?: string;
|
|
186
189
|
}
|
|
187
190
|
declare class E2BProvider implements SandboxProvider {
|
|
188
191
|
readonly providerType: "e2b";
|
|
189
192
|
private readonly apiKey;
|
|
193
|
+
private readonly apiUrl?;
|
|
190
194
|
private readonly defaultTimeoutMs;
|
|
191
195
|
private readonly templateId?;
|
|
192
196
|
constructor(config: ResolvedE2BConfig);
|
package/dist/index.d.ts
CHANGED
|
@@ -174,6 +174,8 @@ interface SandboxProvider {
|
|
|
174
174
|
interface E2BConfig {
|
|
175
175
|
/** E2B API key. Default: reads from E2B_API_KEY env var */
|
|
176
176
|
apiKey?: string;
|
|
177
|
+
/** @internal E2B API base URL override, used for managed gateway routing */
|
|
178
|
+
apiUrl?: string;
|
|
177
179
|
defaultTimeoutMs?: number;
|
|
178
180
|
/** E2B template ID (default: 'evolve-all'). Create custom templates at https://e2b.dev/docs/sandbox-template */
|
|
179
181
|
templateId?: string;
|
|
@@ -181,12 +183,14 @@ interface E2BConfig {
|
|
|
181
183
|
/** Internal resolved config with required apiKey */
|
|
182
184
|
interface ResolvedE2BConfig {
|
|
183
185
|
apiKey: string;
|
|
186
|
+
apiUrl?: string;
|
|
184
187
|
defaultTimeoutMs?: number;
|
|
185
188
|
templateId?: string;
|
|
186
189
|
}
|
|
187
190
|
declare class E2BProvider implements SandboxProvider {
|
|
188
191
|
readonly providerType: "e2b";
|
|
189
192
|
private readonly apiKey;
|
|
193
|
+
private readonly apiUrl?;
|
|
190
194
|
private readonly defaultTimeoutMs;
|
|
191
195
|
private readonly templateId?;
|
|
192
196
|
constructor(config: ResolvedE2BConfig);
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {Sandbox}from'@e2b/code-interpreter';var
|
|
2
|
-
export{u as E2BProvider,
|
|
1
|
+
import {Sandbox}from'@e2b/code-interpreter';var p=new Set([".xlsx",".xls",".docx",".doc",".pptx",".ppt",".pdf",".zip",".tar",".gz",".7z",".rar",".png",".jpg",".jpeg",".gif",".webp",".ico",".bmp",".mp3",".wav",".ogg",".flac",".aac",".mp4",".avi",".mov",".mkv",".webm",".woff",".woff2",".ttf",".otf",".eot",".exe",".dll",".so",".dylib",".sqlite",".db",".pickle",".pkl",".parquet"]);function a(i){return i instanceof Date?i.toISOString():String(i)}function l(i){if(typeof i=="string"||i instanceof ArrayBuffer)return i;if(i instanceof Buffer)return new Uint8Array(i).buffer;if(i instanceof Uint8Array)return new Uint8Array(i).buffer;throw new Error(`Unsupported data type for file upload: ${typeof i}. Expected string, Buffer, ArrayBuffer, or Uint8Array.`)}function g(i){let t=i.substring(i.lastIndexOf(".")).toLowerCase();return p.has(t)}var m=class{constructor(t){this.sandbox=t;}async run(t,e){try{let n=await this.sandbox.commands.run(t,{timeoutMs:e?.timeoutMs,envs:e?.envs,cwd:e?.cwd,onStdout:e?.onStdout,onStderr:e?.onStderr});return {exitCode:n.exitCode,stdout:n.stdout,stderr:n.stderr}}catch(n){if(n&&typeof n=="object"&&"exitCode"in n){let r=n;return {exitCode:r.exitCode,stdout:r.stdout??"",stderr:r.stderr??""}}throw n}}async spawn(t,e){let n=await this.sandbox.commands.run(t,{background:true,stdin:e?.stdin??true,timeoutMs:e?.timeoutMs,envs:e?.envs,cwd:e?.cwd,onStdout:e?.onStdout,onStderr:e?.onStderr});return {processId:String(n.pid),wait:async()=>{try{let r=await n.wait();return {exitCode:r.exitCode,stdout:r.stdout,stderr:r.stderr}}catch(r){if(r&&typeof r=="object"&&"exitCode"in r){let s=r;return {exitCode:s.exitCode,stdout:s.stdout??"",stderr:s.stderr??""}}throw r}},kill:()=>this.sandbox.commands.kill(n.pid)}}async list(){return (await this.sandbox.commands.list()).map(e=>({...e,processId:String(e.pid)}))}async connect(t,e){let n=await this.sandbox.commands.connect(Number(t),{onStdout:e?.onStdout,onStderr:e?.onStderr,timeoutMs:e?.timeoutMs});return {processId:String(n.pid),wait:async()=>{try{let r=await n.wait();return {exitCode:r.exitCode,stdout:r.stdout,stderr:r.stderr}}catch(r){if(r&&typeof r=="object"&&"exitCode"in r){let s=r;return {exitCode:s.exitCode,stdout:s.stdout??"",stderr:s.stderr??""}}throw r}},kill:()=>this.sandbox.commands.kill(n.pid)}}async sendStdin(t,e){await this.sandbox.commands.sendStdin(Number(t),e);}async kill(t){return this.sandbox.commands.kill(Number(t))}},c=class{constructor(t){this.sandbox=t;}async read(t){return g(t)?this.sandbox.files.read(t,{format:"bytes",requestTimeoutMs:3e5}):this.sandbox.files.read(t,{format:"text",requestTimeoutMs:3e5})}async write(t,e){await this.sandbox.files.write(t,l(e),{requestTimeoutMs:3e5});}async writeBatch(t){let e=t.map(n=>({path:n.path,data:l(n.data)}));await this.sandbox.files.write(e,{requestTimeoutMs:3e5});}async makeDir(t){await this.sandbox.files.makeDir(t);}async uploadUrl(t,e){return this.sandbox.uploadUrl(t,e?{useSignatureExpiration:e}:void 0)}async downloadUrl(t,e){return this.sandbox.downloadUrl(t,e?{useSignatureExpiration:e}:void 0)}async exists(t){return this.sandbox.files.exists(t)}async list(t){return (await this.sandbox.files.list(t)).map(n=>({name:n.name,path:n.path,type:n.type==="dir"?"dir":"file"}))}async remove(t){await this.sandbox.files.remove(t);}async rename(t,e){await this.sandbox.files.rename(t,e);}async readStream(t){return this.sandbox.files.read(t,{format:"stream"})}async writeStream(t,e){await this.sandbox.files.write(t,e);}async watchDir(t,e,n){let r=await this.sandbox.files.watchDir(t,e,{recursive:n?.recursive,timeoutMs:n?.timeoutMs,onExit:n?.onExit});return {stop:()=>r.stop()}}},o=class{constructor(t,e,n){this.sandbox=t;this.apiKey=e;this.apiUrl=n;this.commands=new m(t),this.files=new c(t);}commands;files;get sandboxId(){return this.sandbox.sandboxId}getHost(t){return Promise.resolve(this.sandbox.getHost(t))}async isRunning(){return this.sandbox.isRunning()}async getInfo(){let t=await this.sandbox.getInfo();return {sandboxId:t.sandboxId,image:t.templateId,name:t.name,metadata:t.metadata??{},startedAt:a(t.startedAt),endAt:t.endAt?a(t.endAt):void 0}}async kill(){try{await this.sandbox.kill();}catch{await new Promise(t=>setTimeout(t,500)),await this.sandbox.kill();}}async pause(){await this.sandbox.betaPause({apiKey:this.apiKey,apiUrl:this.apiUrl});}},u=class{providerType="e2b";apiKey;apiUrl;defaultTimeoutMs;templateId;constructor(t){this.apiKey=t.apiKey,this.apiUrl=t.apiUrl,this.defaultTimeoutMs=t.defaultTimeoutMs??36e5,this.templateId=t.templateId;}async create(t){let e=t.timeoutMs??this.defaultTimeoutMs,n=t.image??this.templateId??"evolve-all",r=await Sandbox.create(n,{apiKey:this.apiKey,apiUrl:this.apiUrl,envs:t.envs,metadata:t.metadata,timeoutMs:e});return t.workingDirectory&&await r.files.makeDir(t.workingDirectory),new o(r,this.apiKey,this.apiUrl)}async connect(t,e){let n=await Sandbox.connect(t,{apiKey:this.apiKey,apiUrl:this.apiUrl,timeoutMs:e??this.defaultTimeoutMs});return new o(n,this.apiKey,this.apiUrl)}async list(t){return (await Sandbox.list({apiKey:this.apiKey,apiUrl:this.apiUrl,query:{state:t?.state,metadata:t?.metadata},limit:t?.limit??100}).nextItems()).map(r=>({sandboxId:r.sandboxId,image:r.templateId,name:r.name,metadata:r.metadata??{},startedAt:a(r.startedAt),endAt:r.endAt?a(r.endAt):void 0}))}};function b(i={}){let t=i.apiKey??process.env.E2B_API_KEY;if(!t)throw new Error("E2B API key required. Set E2B_API_KEY environment variable or pass apiKey in config. Get your key at https://e2b.dev/sign-in");return new u({...i,apiKey:t})}
|
|
2
|
+
export{u as E2BProvider,b as createE2BProvider};
|