Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Fix testing config; [WIP] Add tests; Fix python debug opt; Fix enum mapping

Tomas Valenta206d6744f090
diff --git a/packages/js-sdk/example.mts b/packages/js-sdk/example.mts
index 9d40e3e16..be9178a26 100644
--- a/packages/js-sdk/example.mts
+++ b/packages/js-sdk/example.mts
@@ -1,28 +1,151 @@
import { Sandbox } from './dist'
-const sbx = await Sandbox.create('', {
+const start = Date.now()
+
+const sbx = await Sandbox.create('3pcmtxu6u8it5f6flpkk', {
debug: true,
+ domain: 'e2b-staging.com',
+ timeoutMs: 5_000,
+ logger: console,
})
+console.log(sbx.sandboxID)
-const watcher = await sbx.files.watch('./', (e) => {
- e.path
-}, {
- user: 'user',
- timeout: 2,
+const res = await sbx.commands.run('sleep 20', {
+ // requestTimeoutMs: 1,
+ // user: 'asdfasdf',
+ timeoutMs: 200000,
+ background: true,
+ onStdout: (data) => {
+ // TODO: print also the time elapsed
+ console.log(`${(Date.now() - start) / 1000}s: ${data}`)
+ },
})
+// const l = await sbx.commands.list()
+
+// console.log(l)
+
+// // console.log('time', Date.now() - start)
+
+// async function wait(ms: number) {
+// return new Promise((resolve) => setTimeout(resolve, ms))
+// }
+
+// for (let i = 0; i < 10; i++) {
+// const lStart = Date.now()
+// await wait(10000)
+
+// const res = await sbx.files.list('/')
+
+// console.log('time', Date.now() - lStart)
+// }
+
+
+// // const watcher = await sbx.files.watch('./', (e) => {
+// // console.log(e)
+// // }, {
+// // // onExit: (err) => {
+// // // console.log('watcher exited', err)
+// // // },
+// // // timeout: 1000,
+// // // requestTimeoutMs: 1,
+// // })
+
+// // await sbx.files.write('test', 'hello world')
+// // const contents = await sbx.files.read('test')
+// // console.log(contents)
+
+// // await watcher.stop()
+
+
+// // const pStart = Date.now()
+
+// // await sbx.commands.run('python3 -m http.server -b 127.0.0.1 8090', {
+// // await sbx.commands.run('echo "c"', {
+// // background: false,
+// // // user: 'root',
+// // onStdout: (data) => {
+// // console.log('event0', data)
+// // },
+// // })
+
+// // console.log('time', Date.now() - pStart)
+
+// // await wait(3000)
+
+// // const res = await fetch(`https://${sbx.getHost(8090)}`)
+
+// // console.log(await res.text())
+
+
+// // const lStart = Date.now()
+
+// // await sbx.files.makeDir('test')
+
+// // console.log('time', Date.now() - lStart)
+
+// // const rStart = Date.now()
+
+// // await sbx.files.makeDir('test')
+// // // await sbx.files.read('test')
+
+// // console.log('time', Date.now() - rStart)
+// // const xStart = Date.now()
+
+// // await sbx.files.makeDir('test')
+// // // await sbx.files.read('test')
+
+// // console.log('time', Date.now() - xStart)
+// // const yStart = Date.now()
+
+// // await sbx.files.makeDir('test')
+// // // await sbx.files.read('test')
+
+// // console.log('time', Date.now() - yStart)
+
+// // // await sbx.commands.sendStdin(c.pid, 'hello world\n')
+
+// // // console.log(res)
+
+// // // await sbx.files.makeDir('test')
+
+// // // const contents2 = await sbx.files.exists('%%\\test')
+// // // console.log(contents2)
+
+// // // watcher.stop()
+
+
+// // // const start = Date.now()
+
+// // // const res = await sbx.commands.list()
+// // // console.log(res)
+
+// // // const res = await fetch('http://localhost:49982/sync', {
+// // // method: 'POST',
+// // // })
-// await sbx.files.write('test', 'hello world')
-// const contents = await sbx.files.read('test')
-// console.log(contents)
+// // // const q = await res.text()
+// // // console.log(q)
-// await sbx.files.makeDir('new-lore')
+// // // const res = await sbx.commands.run('sleep 5 && echo hello', {
+// // // background: true,
+// // // onStdout: (data) => {
+// // // console.log('event0', data)
+// // // },
+// // // })
-// const contents2 = await sbx.files.exists('%%\\test')
-// console.log(contents2)
+// // // async function wait(ms: number) {
+// // // return new Promise((resolve) => setTimeout(resolve, ms))
+// // // }
-// watcher.stop()
+// // // // const r2 = await sbx.commands.connect(res.pid, {
+// // // // onStdout: (data) => {
+// // // // console.log('event1', data)
+// // // // },
+// // // // })
+// // // await wait(2000)
+// // // await res.kill()
-const res = await sbx.commands.run('ls -a', {})
+// // // console.log('time', Date.now() - start)
diff --git a/packages/js-sdk/package.json b/packages/js-sdk/package.json
index 26e771901..9dd0dc713 100644
--- a/packages/js-sdk/package.json
+++ b/packages/js-sdk/package.json
@@ -26,10 +26,8 @@
"prepublishOnly": "pnpm build",
"build": "tsc --noEmit && tsup",
"dev": "tsup --watch",
- "measure": "node test/performance.mjs",
"example": "tsx example.mts",
"test": "vitest run",
- "test:coverage": "vitest run --coverage",
"generate": "openapi-typescript ../../spec/openapi.yml -x api_key --support-array-length --alphabetize --output src/api/schema.gen.ts",
"generate-envd-api": "openapi-typescript ../../spec/envd/envd.yaml -x api_key --support-array-length --alphabetize --output src/envd/schema.gen.ts",
"check-deps": "knip",
diff --git a/packages/js-sdk/src/envd/api.ts b/packages/js-sdk/src/envd/api.ts
index fa7675490..970c1c6a8 100644
--- a/packages/js-sdk/src/envd/api.ts
+++ b/packages/js-sdk/src/envd/api.ts
@@ -29,10 +29,10 @@ export function handleEnvdApiError(err: {
}
}
-
class EnvdApiClient {
private readonly client: ReturnType<typeof createClient<paths>>
+ // TODO: Fix apiUrl vs domain
constructor(config: Pick<ConnectionConfig, 'apiUrl' | 'logger'>) {
this.client = createClient<paths>({
baseUrl: config.apiUrl,
diff --git a/packages/js-sdk/src/envd/rpc.ts b/packages/js-sdk/src/envd/rpc.ts
index 322c03e7d..34c962e3e 100644
--- a/packages/js-sdk/src/envd/rpc.ts
+++ b/packages/js-sdk/src/envd/rpc.ts
@@ -18,7 +18,7 @@ export function handleRpcError(err: unknown) {
)
case Code.DeadlineExceeded:
return new TimeoutError(
- `${err.message}: This error is likely due to exceeding 'timeoutMs' — the total time a long running request can be active. It can be modified by passing 'timeoutMs' when making the request. Use '0' to disable the timeout.`
+ `${err.message}: This error is likely due to exceeding 'timeoutMs' — the total time a long running request (like process or directory watch) can be active. It can be modified by passing 'timeoutMs' when making the request. Use '0' to disable the timeout.`
)
default:
return new SandboxError(`${err.code}: ${err.message}`)
diff --git a/packages/js-sdk/src/envd/schema.gen.ts b/packages/js-sdk/src/envd/schema.gen.ts
index 0fb459617..123898de4 100644
--- a/packages/js-sdk/src/envd/schema.gen.ts
+++ b/packages/js-sdk/src/envd/schema.gen.ts
@@ -16,7 +16,7 @@ export interface paths {
};
responses: {
200: components["responses"]["DownloadSuccess"];
- 400: components["responses"]["BadRequest"];
+ 400: components["responses"]["InvalidUser"];
403: components["responses"]["DirectoryPathError"];
404: components["responses"]["FileNotFound"];
500: components["responses"]["InternalServerError"];
@@ -33,13 +33,24 @@ export interface paths {
requestBody: components["requestBodies"]["File"];
responses: {
204: components["responses"]["UploadSuccess"];
- 400: components["responses"]["BadRequest"];
+ 400: components["responses"]["InvalidUser"];
403: components["responses"]["DirectoryPathError"];
500: components["responses"]["InternalServerError"];
507: components["responses"]["NotEnoughDiskSpace"];
};
};
};
+ "/health": {
+ /** Check the health of the service */
+ get: {
+ responses: {
+ /** @description The service is healthy */
+ 204: {
+ content: never;
+ };
+ };
+ };
+ };
"/sync": {
/** Ensure the time and metadata is synced with the host */
post: {
@@ -65,12 +76,6 @@ export interface components {
};
};
responses: {
- /** @description Bad request */
- BadRequest: {
- content: {
- "application/json": components["schemas"]["Error"];
- };
- };
/** @description Directory path error */
DirectoryPathError: {
content: {
@@ -95,6 +100,12 @@ export interface components {
"application/json": components["schemas"]["Error"];
};
};
+ /** @description Invalid user */
+ InvalidUser: {
+ content: {
+ "application/json": components["schemas"]["Error"];
+ };
+ };
/** @description Not enough disk space */
NotEnoughDiskSpace: {
content: {
diff --git a/packages/js-sdk/src/sandbox/filesystem/index.ts b/packages/js-sdk/src/sandbox/filesystem/index.ts
index 0e3d497bc..79428a3f0 100644
--- a/packages/js-sdk/src/sandbox/filesystem/index.ts
+++ b/packages/js-sdk/src/sandbox/filesystem/index.ts
@@ -21,7 +21,6 @@ import { handleRpcError } from '../../envd/rpc'
import { EnvdApiClient } from '../../envd/api'
import { Filesystem as FilesystemService } from '../../envd/filesystem/filesystem_connect'
import { FileType as FsFileType, WatchDirResponse } from '../../envd/filesystem/filesystem_pb'
-import { Logger } from '../../logs'
import { WatchHandle, FilesystemEvent } from './watchHandle'
@@ -35,6 +34,15 @@ export const enum FileType {
DIR = 'dir',
}
+function mapFileType(fileType: FsFileType) {
+ switch (fileType) {
+ case FsFileType.DIRECTORY:
+ return FileType.DIR
+ case FsFileType.FILE:
+ return FileType.FILE
+ }
+}
+
export interface FilesystemRequestOpts extends Partial<Pick<ConnectionOpts, 'requestTimeoutMs'>> {
user?: Username
}
@@ -46,15 +54,14 @@ export interface WatchOpts extends FilesystemRequestOpts {
export class Filesystem {
private readonly rpc: PromiseClient<typeof FilesystemService>
- private readonly envdApi: EnvdApiClient
+
+ private readonly defaultWatchTimeout = 60_000 // 60 seconds
constructor(
transport: Transport,
- envdApiUrl: string,
+ private readonly envdApi: EnvdApiClient,
private readonly connectionConfig: ConnectionConfig,
- logger?: Logger,
) {
- this.envdApi = new EnvdApiClient({ apiUrl: envdApiUrl, logger })
this.rpc = createPromiseClient(FilesystemService, transport)
}
@@ -129,10 +136,20 @@ export class Filesystem {
signal: this.connectionConfig.getSignal(opts?.requestTimeoutMs),
})
- return res.entries.map(e => ({
- name: e.name,
- type: e.type === FsFileType.FILE ? FileType.FILE : FileType.DIR,
- }))
+ const entries: EntryInfo[] = []
+
+ for (const e of res.entries) {
+ const type = mapFileType(e.type)
+
+ if (type) {
+ entries.push({
+ name: e.name,
+ type,
+ })
+ }
+ }
+
+ return entries
} catch (err) {
throw handleRpcError(err)
}
@@ -254,7 +271,7 @@ export class Filesystem {
},
}, {
signal: controller.signal,
- timeoutMs: opts?.timeout ?? 60_000,
+ timeoutMs: opts?.timeout ?? this.defaultWatchTimeout,
})
try {
diff --git a/packages/js-sdk/src/sandbox/index.ts b/packages/js-sdk/src/sandbox/index.ts
index af0f34b4c..700a17e8e 100644
--- a/packages/js-sdk/src/sandbox/index.ts
+++ b/packages/js-sdk/src/sandbox/index.ts
@@ -6,6 +6,7 @@ import { Filesystem } from './filesystem'
import { Process } from './process'
import { Pty } from './pty'
import { SandboxApi } from './sandboxApi'
+import { EnvdApiClient, handleEnvdApiError } from '../envd/api'
// @ts-ignore
Symbol.asyncDispose ??= Symbol('Symbol.asyncDispose')
@@ -24,7 +25,7 @@ export interface SandboxOpts extends ConnectionOpts {
}
export class Sandbox extends SandboxApi {
- protected static readonly defaultTemplate = 'base-v1'
+ protected static readonly defaultTemplate = 'base'
protected static readonly defaultSandboxTimeoutMs = 300_000
readonly files: Filesystem
@@ -35,6 +36,7 @@ export class Sandbox extends SandboxApi {
private readonly connectionConfig: ConnectionConfig
private readonly envdApiUrl: string
+ private readonly envdApi: EnvdApiClient
constructor(readonly sandboxID: string, opts?: Omit<SandboxOpts, 'timeoutMs' | 'metadata'>) {
super()
@@ -48,7 +50,8 @@ export class Sandbox extends SandboxApi {
interceptors: opts?.logger ? [createRpcLogger(opts.logger)] : undefined,
})
- this.files = new Filesystem(rpcTransport, this.envdApiUrl, this.connectionConfig, opts?.logger)
+ this.envdApi = new EnvdApiClient({ apiUrl: this.envdApiUrl, logger: opts?.logger })
+ this.files = new Filesystem(rpcTransport, this.envdApi, this.connectionConfig)
this.commands = new Process(rpcTransport, this.connectionConfig)
this.pty = new Pty(rpcTransport, this.connectionConfig)
}
@@ -88,6 +91,19 @@ export class Sandbox extends SandboxApi {
return `${port}-${this.sandboxID}.${this.connectionConfig.domain}`
}
+ async isRunning(opts?: Pick<ConnectionOpts, 'requestTimeoutMs'>): Promise<true> {
+ const { error } = await this.envdApi.api.GET('/health', {
+ signal: this.connectionConfig.getSignal(opts?.requestTimeoutMs),
+ })
+
+ const err = handleEnvdApiError(error)
+ if (err) {
+ throw err
+ }
+
+ return true
+ }
+
async setTimeout(timeoutMs: number, opts?: Pick<SandboxOpts, 'requestTimeoutMs'>) {
await Sandbox.setTimeout(this.sandboxID, timeoutMs, { ...this.connectionConfig, ...opts })
}
@@ -96,7 +112,7 @@ export class Sandbox extends SandboxApi {
await Sandbox.kill(this.sandboxID, { ...this.connectionConfig, ...opts })
}
- async [Symbol.asyncDispose]() {
+ async[Symbol.asyncDispose]() {
await this.kill()
}
}
diff --git a/packages/js-sdk/src/sandbox/process/index.ts b/packages/js-sdk/src/sandbox/process/index.ts
index 989000824..15539f7fa 100644
--- a/packages/js-sdk/src/sandbox/process/index.ts
+++ b/packages/js-sdk/src/sandbox/process/index.ts
@@ -38,6 +38,8 @@ export interface ProcessInfo extends PlainMessage<ProcessConfig> {
export class Process {
protected readonly rpc: PromiseClient<typeof ProcessService>
+ private readonly defaultProcessConnectionTimeout = 60_000 // 60 seconds
+
constructor(
transport: Transport,
private readonly connectionConfig: ConnectionConfig,
@@ -125,7 +127,7 @@ export class Process {
},
}, {
signal: controller.signal,
- timeoutMs: opts?.timeoutMs ?? 60_000,
+ timeoutMs: opts?.timeoutMs ?? this.defaultProcessConnectionTimeout,
})
try {
@@ -187,7 +189,7 @@ export class Process {
},
}, {
signal: controller.signal,
- timeoutMs: opts?.timeoutMs ?? 60_000,
+ timeoutMs: opts?.timeoutMs ?? this.defaultProcessConnectionTimeout,
})
try {
diff --git a/packages/js-sdk/src/sandbox/process/processHandle.ts b/packages/js-sdk/src/sandbox/process/processHandle.ts
index aa29735a5..55c53f69b 100644
--- a/packages/js-sdk/src/sandbox/process/processHandle.ts
+++ b/packages/js-sdk/src/sandbox/process/processHandle.ts
@@ -92,7 +92,7 @@ export class ProcessHandle implements Omit<ProcessResult, 'exitCode' | 'error'>,
await this.handleKill()
}
- private async* iterateEvents(): AsyncGenerator<[Stdout, undefined, undefined] | [undefined, Stderr, undefined] | [undefined, undefined, Pty]> {
+ private async* iterateEvents(): AsyncGenerator<[Stdout] | [null, Stderr] | [null, null, Pty]> {
try {
for await (const event of this.events) {
const e = event?.event?.event
@@ -104,15 +104,15 @@ export class ProcessHandle implements Omit<ProcessResult, 'exitCode' | 'error'>,
case 'stdout':
out = new TextDecoder().decode(e.value.output.value)
this._stdout += out
- yield [out as Stdout, undefined, undefined]
+ yield [out as Stdout]
break
case 'stderr':
out = new TextDecoder().decode(e.value.output.value)
this._stderr += out
- yield [undefined, out as Stderr, undefined]
+ yield [null, out as Stderr]
break
case 'pty':
- yield [undefined, undefined, e.value.output.value as Pty]
+ yield [null, null, e.value.output.value as Pty]
break
}
break
@@ -136,9 +136,9 @@ export class ProcessHandle implements Omit<ProcessResult, 'exitCode' | 'error'>,
private async handleEvents(): Promise<ProcessResult> {
for await (const [stdout, stderr, pty] of this.iterateEvents()) {
- if (stdout !== undefined) {
+ if (stdout !== null) {
this.onStdout?.(stdout)
- } else if (stderr !== undefined) {
+ } else if (stderr !== null) {
this.onStderr?.(stderr)
} else if (pty) {
this.onPty?.(pty)
diff --git a/packages/js-sdk/test/sandbox/files/write.test.mjs b/packages/js-sdk/test/sandbox/files/write.test.mjs
deleted file mode 100644
index e69de29bb..000000000
diff --git a/packages/js-sdk/test/sandbox/pty/create.test.mjs b/packages/js-sdk/test/sandbox/pty/create.test.mjs
deleted file mode 100644
index e69de29bb..000000000
diff --git a/packages/js-sdk/test/sandbox/pty/resize.test.mjs b/packages/js-sdk/test/sandbox/pty/resize.test.mjs
deleted file mode 100644
index e69de29bb..000000000
diff --git a/packages/js-sdk/test/sandbox/pty/streamInput.test.mjs b/packages/js-sdk/test/sandbox/pty/streamInput.test.mjs
deleted file mode 100644
index e69de29bb..000000000
diff --git a/packages/js-sdk/test/sandbox/timeout.test.mjs b/packages/js-sdk/test/sandbox/timeout.test.mjs
deleted file mode 100644
index e69de29bb..000000000
diff --git a/packages/js-sdk/test/setup.mjs b/packages/js-sdk/test/setup.mjs
deleted file mode 100644
index c35cc06d8..000000000
--- a/packages/js-sdk/test/setup.mjs
+++ /dev/null
@@ -1 +0,0 @@
-export const id = 'base'
diff --git a/packages/js-sdk/test/api/kill.test.mjs b/packages/js-sdk/tests/api/kill.test.mts
similarity index 100%
rename from packages/js-sdk/test/api/kill.test.mjs
rename to packages/js-sdk/tests/api/kill.test.mts
diff --git a/packages/js-sdk/test/api/list.test.mjs b/packages/js-sdk/tests/api/list.test.mts
similarity index 100%
rename from packages/js-sdk/test/api/list.test.mjs
rename to packages/js-sdk/tests/api/list.test.mts
diff --git a/packages/js-sdk/test/runtime/browser.mjs b/packages/js-sdk/tests/sandbox/commands/connect.test.mts
similarity index 100%
rename from packages/js-sdk/test/runtime/browser.mjs
rename to packages/js-sdk/tests/sandbox/commands/connect.test.mts
diff --git a/packages/js-sdk/test/runtime/bun.mjs b/packages/js-sdk/tests/sandbox/commands/kill.test.mts
similarity index 100%
rename from packages/js-sdk/test/runtime/bun.mjs
rename to packages/js-sdk/tests/sandbox/commands/kill.test.mts
diff --git a/packages/js-sdk/test/runtime/deno.mjs b/packages/js-sdk/tests/sandbox/commands/list.test.mts
similarity index 100%
rename from packages/js-sdk/test/runtime/deno.mjs
rename to packages/js-sdk/tests/sandbox/commands/list.test.mts
diff --git a/packages/js-sdk/tests/sandbox/commands/run.test.mts b/packages/js-sdk/tests/sandbox/commands/run.test.mts
new file mode 100644
index 000000000..7ef826df3
--- /dev/null
+++ b/packages/js-sdk/tests/sandbox/commands/run.test.mts
@@ -0,0 +1,11 @@
+import { assert } from 'vitest'
+import { sandboxTest } from '../../setup.mjs'
+
+sandboxTest('run', async ({ sandbox }) => {
+ const text = 'Hello, World!'
+
+ const cmd = await sandbox.commands.run(`echo "${text}"`)
+
+ assert.equal(cmd.exitCode, 0)
+ assert.equal(cmd.stdout, `${text}\n`)
+})
diff --git a/packages/js-sdk/test/runtime/edge.mjs b/packages/js-sdk/tests/sandbox/commands/sendStdin.test.mts
similarity index 100%
rename from packages/js-sdk/test/runtime/edge.mjs
rename to packages/js-sdk/tests/sandbox/commands/sendStdin.test.mts
diff --git a/packages/js-sdk/tests/sandbox/connect.test.mts b/packages/js-sdk/tests/sandbox/connect.test.mts
new file mode 100644
index 000000000..ab028ff0a
--- /dev/null
+++ b/packages/js-sdk/tests/sandbox/connect.test.mts
@@ -0,0 +1,14 @@
+import { test, assert } from 'vitest'
+
+import { Sandbox } from '../../src'
+import { template } from '../setup.mts'
+
+test('connect', async () => {
+ const sbx = await Sandbox.create(template, { timeoutMs: 10_000 })
+ const isRunning = await sbx.isRunning()
+ assert.isTrue(isRunning)
+
+ const sbxConnection = await Sandbox.connect(sbx.sandboxID)
+ const isRunning2 = await sbxConnection.isRunning()
+ assert.isTrue(isRunning2)
+})
diff --git a/packages/js-sdk/tests/sandbox/create.test.mts b/packages/js-sdk/tests/sandbox/create.test.mts
new file mode 100644
index 000000000..23e1462a1
--- /dev/null
+++ b/packages/js-sdk/tests/sandbox/create.test.mts
@@ -0,0 +1,10 @@
+import { test, assert } from 'vitest'
+
+import { Sandbox } from '../../src'
+import { template } from '../setup.mjs'
+
+test('create', async () => {
+ const sbx = await Sandbox.create(template, { timeoutMs: 5_000 })
+ const isRunning = await sbx.isRunning()
+ assert.isTrue(isRunning)
+})
diff --git a/packages/js-sdk/tests/sandbox/files/exists.test.mts b/packages/js-sdk/tests/sandbox/files/exists.test.mts
new file mode 100644
index 000000000..f851f3965
--- /dev/null
+++ b/packages/js-sdk/tests/sandbox/files/exists.test.mts
@@ -0,0 +1,18 @@
+import { assert } from 'vitest'
+
+import { sandboxTest } from '../../setup.mjs'
+
+sandboxTest('file exists', async ({ sandbox }) => {
+ const filename = 'test_exists.txt'
+
+ await sandbox.files.write(filename, 'test')
+ const exists = await sandbox.files.exists(filename)
+ assert.isTrue(exists)
+})
+
+sandboxTest('file does not exist', async ({ sandbox }) => {
+ const filename = 'test_does_not_exist.txt'
+
+ const exists = await sandbox.files.exists(filename)
+ assert.isFalse(exists)
+})
diff --git a/packages/js-sdk/test/runtime/node.mjs b/packages/js-sdk/tests/sandbox/files/list.test.mts
similarity index 100%
rename from packages/js-sdk/test/runtime/node.mjs
rename to packages/js-sdk/tests/sandbox/files/list.test.mts
diff --git a/packages/js-sdk/test/sandbox/commands/connect.test.mjs b/packages/js-sdk/tests/sandbox/files/makeDir.test.mts
similarity index 100%
rename from packages/js-sdk/test/sandbox/commands/connect.test.mjs
rename to packages/js-sdk/tests/sandbox/files/makeDir.test.mts
diff --git a/packages/js-sdk/test/sandbox/commands/kill.test.mjs b/packages/js-sdk/tests/sandbox/files/read.test.mts
similarity index 100%
rename from packages/js-sdk/test/sandbox/commands/kill.test.mjs
rename to packages/js-sdk/tests/sandbox/files/read.test.mts
diff --git a/packages/js-sdk/test/sandbox/commands/list.test.mjs b/packages/js-sdk/tests/sandbox/files/remove.test.mts
similarity index 100%
rename from packages/js-sdk/test/sandbox/commands/list.test.mjs
rename to packages/js-sdk/tests/sandbox/files/remove.test.mts
diff --git a/packages/js-sdk/test/sandbox/commands/run.test.mjs b/packages/js-sdk/tests/sandbox/files/rename.test.mts
similarity index 100%
rename from packages/js-sdk/test/sandbox/commands/run.test.mjs
rename to packages/js-sdk/tests/sandbox/files/rename.test.mts
diff --git a/packages/js-sdk/test/sandbox/commands/sendStdin.test.mjs b/packages/js-sdk/tests/sandbox/files/watch.test.mts
similarity index 100%
rename from packages/js-sdk/test/sandbox/commands/sendStdin.test.mjs
rename to packages/js-sdk/tests/sandbox/files/watch.test.mts
diff --git a/packages/js-sdk/test/sandbox/connect.test.mjs b/packages/js-sdk/tests/sandbox/files/write.test.mts
similarity index 100%
rename from packages/js-sdk/test/sandbox/connect.test.mjs
rename to packages/js-sdk/tests/sandbox/files/write.test.mts
diff --git a/packages/js-sdk/test/sandbox/create.test.mjs b/packages/js-sdk/tests/sandbox/host.test.mts
similarity index 100%
rename from packages/js-sdk/test/sandbox/create.test.mjs
rename to packages/js-sdk/tests/sandbox/host.test.mts
diff --git a/packages/js-sdk/test/sandbox/files/exists.test.mjs b/packages/js-sdk/tests/sandbox/pty/create.test.mts
similarity index 100%
rename from packages/js-sdk/test/sandbox/files/exists.test.mjs
rename to packages/js-sdk/tests/sandbox/pty/create.test.mts
diff --git a/packages/js-sdk/test/sandbox/files/list.test.mjs b/packages/js-sdk/tests/sandbox/pty/resize.test.mts
similarity index 100%
rename from packages/js-sdk/test/sandbox/files/list.test.mjs
rename to packages/js-sdk/tests/sandbox/pty/resize.test.mts
diff --git a/packages/js-sdk/test/sandbox/files/makeDir.test.mjs b/packages/js-sdk/tests/sandbox/pty/streamInput.test.mts
similarity index 100%
rename from packages/js-sdk/test/sandbox/files/makeDir.test.mjs
rename to packages/js-sdk/tests/sandbox/pty/streamInput.test.mts
diff --git a/packages/js-sdk/test/sandbox/files/read.test.mjs b/packages/js-sdk/tests/sandbox/timeout.test.mts
similarity index 100%
rename from packages/js-sdk/test/sandbox/files/read.test.mjs
rename to packages/js-sdk/tests/sandbox/timeout.test.mts
diff --git a/packages/js-sdk/test/sandbox/files/remove.test.mjs b/packages/js-sdk/tests/sandbox/uploadUrl.test.mts
similarity index 100%
rename from packages/js-sdk/test/sandbox/files/remove.test.mjs
rename to packages/js-sdk/tests/sandbox/uploadUrl.test.mts
diff --git a/packages/js-sdk/tests/setup.mts b/packages/js-sdk/tests/setup.mts
new file mode 100644
index 000000000..3c2a49685
--- /dev/null
+++ b/packages/js-sdk/tests/setup.mts
@@ -0,0 +1,27 @@
+import { Sandbox } from '../src'
+import { test as base } from 'vitest'
+
+export const template = 'base'
+
+interface SandboxFixture {
+ sandbox: Sandbox
+}
+
+export const sandboxTest = base.extend<SandboxFixture>({
+ sandbox: [
+ async ({ }, use) => {
+ const sandbox = await Sandbox.create(template)
+ try {
+ await use(sandbox)
+
+ } finally {
+ try {
+ await sandbox.kill()
+ } catch (err) {
+ console.warn('Failed to kill sandbox — this is expected if the test runs with local envd.')
+ }
+ }
+ },
+ { auto: true },
+ ],
+})
diff --git a/packages/js-sdk/vitest.config.ts b/packages/js-sdk/vitest.config.mts
similarity index 80%
rename from packages/js-sdk/vitest.config.ts
rename to packages/js-sdk/vitest.config.mts
index 92bb05ccc..084b9bbe6 100644
--- a/packages/js-sdk/vitest.config.ts
+++ b/packages/js-sdk/vitest.config.mts
@@ -5,6 +5,12 @@ const env = config()
export default defineConfig({
test: {
+ poolOptions: {
+ threads: {
+ minThreads: 1,
+ maxThreads: 5,
+ },
+ },
maxWorkers: 5,
globals: false,
testTimeout: 20000,
diff --git a/packages/python-sdk/connect/client.py b/packages/python-sdk/connect/client.py
index c7d87c796..13ac712e8 100644
--- a/packages/python-sdk/connect/client.py
+++ b/packages/python-sdk/connect/client.py
@@ -137,7 +137,7 @@ class Client:
if self._compressor is not None:
data = self._compressor.compress(data)
- extensions = {}
+ extensions = None
if request_timeout is not None:
extensions = {"timeout": request_timeout}
@@ -146,7 +146,7 @@ class Client:
"POST",
self.url,
content=data,
- extensions=extensions,
+ # extensions=extensions,
headers={
**self._headers,
**opts.get("headers", {}),
@@ -183,9 +183,7 @@ class Client:
extensions = {}
if request_timeout is not None:
- extensions = {
- "timeout": {"connect": request_timeout, "pool": request_timeout}
- }
+ extensions = {"timeout": {"connect": request_timeout}}
if self._compressor is not None:
data = self._compressor.compress(data)
diff --git a/packages/python-sdk/e2b/connection_config.py b/packages/python-sdk/e2b/connection_config.py
index 1a65c069f..e10785c37 100644
--- a/packages/python-sdk/e2b/connection_config.py
+++ b/packages/python-sdk/e2b/connection_config.py
@@ -7,7 +7,7 @@ DEBUG = os.getenv("E2B_DEBUG", "false") == "true"
API_KEY = os.getenv("E2B_API_KEY")
ACCESS_TOKEN = os.getenv("E2B_ACCESS_TOKEN")
-REQUEST_TIMEOUT: float = 30 # 30s
+REQUEST_TIMEOUT: float = 30.0 # 30s
class ConnectionConfig:
@@ -37,7 +37,7 @@ class ConnectionConfig:
self.request_timeout = REQUEST_TIMEOUT
self.api_url = (
- "http://localhost:3000" if debug else f"https://api.{self.domain}"
+ "http://localhost:3000" if self.debug else f"https://api.{self.domain}"
)
@staticmethod
diff --git a/packages/python-sdk/e2b/envd/api.py b/packages/python-sdk/e2b/envd/api.py
index 5f6eda189..ea0f520ac 100644
--- a/packages/python-sdk/e2b/envd/api.py
+++ b/packages/python-sdk/e2b/envd/api.py
@@ -1,4 +1,5 @@
-import requests
+import httpx
+import json
from e2b.exceptions import (
SandboxException,
@@ -11,9 +12,10 @@ from e2b.exceptions import (
ENVD_API_FILES_ROUTE = "/files"
+ENVD_API_HEALTH_ROUTE = "/health"
-def handle_envd_api_exception(res: requests.Response):
+def handle_envd_api_exception(res: httpx.Response):
if res.status_code == 400:
return InvalidUserException(res.json().get("message"))
elif res.status_code == 403:
diff --git a/packages/python-sdk/e2b/envd/rpc.py b/packages/python-sdk/e2b/envd/rpc.py
index 2710c9572..05fa2d2a2 100644
--- a/packages/python-sdk/e2b/envd/rpc.py
+++ b/packages/python-sdk/e2b/envd/rpc.py
@@ -23,7 +23,7 @@ def handle_rpc_exception(e: Exception):
)
elif e.status == Code.deadline_exceeded:
return TimeoutException(
- f"{e.message}: This error is likely due to exceeding 'timeoutMs' — the total time a long running request can be active. It can be modified by passing 'timeoutMs' when making the request. Use '0' to disable the timeout."
+ f"{e.message}: This error is likely due to exceeding 'timeoutMs' — the total time a long running request (like process or directory watch) can be active. It can be modified by passing 'timeoutMs' when making the request. Use '0' to disable the timeout."
)
else:
return SandboxException(f"{e.status}: {e.message}")
diff --git a/packages/python-sdk/e2b/sandbox/filesystem/filesystem.py b/packages/python-sdk/e2b/sandbox/filesystem/filesystem.py
index 3aaeb952a..9d3a75c37 100644
--- a/packages/python-sdk/e2b/sandbox/filesystem/filesystem.py
+++ b/packages/python-sdk/e2b/sandbox/filesystem/filesystem.py
@@ -1,11 +1,9 @@
import connect
-import requests
-import urllib.parse
+import httpx
import httpcore
from enum import Enum
from dataclasses import dataclass
-from io import IOBase
from typing import (
Iterator,
List,
@@ -36,6 +34,13 @@ class FileType(Enum):
DIR = "dir"
+def map_file_type(ft: filesystem_pb2.FileType):
+ if ft == filesystem_pb2.FileType.FILE_TYPE_FILE:
+ return FileType.FILE
+ elif ft == filesystem_pb2.FileType.FILE_TYPE_DIRECTORY:
+ return FileType.DIR
+
+
@dataclass
class EntryInfo:
name: str
@@ -48,9 +53,12 @@ class Filesystem:
envd_api_url: str,
connection_config: ConnectionConfig,
pool: httpcore.ConnectionPool,
+ envd_api: httpx.Client,
) -> None:
self._envd_api_url = envd_api_url
self._connection_config = connection_config
+ self._pool = pool
+ self._envd_api = envd_api
self._rpc = filesystem_connect.FilesystemClient(
envd_api_url,
@@ -92,10 +100,8 @@ class Filesystem:
user: Username = "user",
request_timeout: Optional[float] = None,
):
- url = urllib.parse.urljoin(self._envd_api_url, f"{ENVD_API_FILES_ROUTE}")
- r = requests.get(
- url,
- stream=True if format == "stream" else False,
+ r = self._envd_api.get(
+ ENVD_API_FILES_ROUTE,
params={"path": path, "username": user},
timeout=self._connection_config.get_request_timeout(request_timeout),
)
@@ -109,22 +115,18 @@ class Filesystem:
elif format == "bytes":
return bytearray(r.content)
elif format == "stream":
- iter: Iterator[bytes] = r.iter_content()
- return iter
+ return r.iter_bytes()
def write(
self,
path: str,
- data: Union[str, bytes, IOBase, IO],
+ data: Union[str, bytes, IO],
user: Username = "user",
request_timeout: Optional[float] = None,
) -> None:
- url = urllib.parse.urljoin(self._envd_api_url, f"{ENVD_API_FILES_ROUTE}")
-
- files = {"file": data}
- r = requests.post(
- url,
- files=files,
+ r = self._envd_api.post(
+ ENVD_API_FILES_ROUTE,
+ files={"file": data},
params={"path": path, "username": user},
timeout=self._connection_config.get_request_timeout(request_timeout),
)
@@ -145,13 +147,19 @@ class Filesystem:
path=path,
user=User(username=user),
),
- request_timeout=self._connection_config.get_request_timeout(request_timeout),
+ request_timeout=self._connection_config.get_request_timeout(
+ request_timeout
+ ),
)
- return [
- EntryInfo(name=entry.name, type=FileType(entry.name))
- for entry in res.entries
- ]
+ entries: List[EntryInfo] = []
+ for entry in res.entries:
+ event_type = map_file_type(entry.type)
+
+ if event_type:
+ entries.append(EntryInfo(name=entry.name, type=event_type))
+
+ return entries
except Exception as e:
raise handle_rpc_exception(e)
@@ -167,7 +175,9 @@ class Filesystem:
path=path,
user=User(username=user),
),
- request_timeout=self._connection_config.get_request_timeout(request_timeout),
+ request_timeout=self._connection_config.get_request_timeout(
+ request_timeout
+ ),
)
return True
@@ -189,7 +199,9 @@ class Filesystem:
path=path,
user=User(username=user),
),
- request_timeout=self._connection_config.get_request_timeout(request_timeout),
+ request_timeout=self._connection_config.get_request_timeout(
+ request_timeout
+ ),
)
except Exception as e:
raise handle_rpc_exception(e)
@@ -208,7 +220,9 @@ class Filesystem:
destination=new_path,
user=User(username=user),
),
- request_timeout=self._connection_config.get_request_timeout(request_timeout),
+ request_timeout=self._connection_config.get_request_timeout(
+ request_timeout
+ ),
)
except Exception as e:
raise handle_rpc_exception(e)
@@ -225,7 +239,9 @@ class Filesystem:
path=path,
user=User(username=user),
),
- request_timeout=self._connection_config.get_request_timeout(request_timeout),
+ request_timeout=self._connection_config.get_request_timeout(
+ request_timeout
+ ),
)
return True
@@ -247,7 +263,9 @@ class Filesystem:
path=path,
user=User(username=user),
),
- request_timeout=self._connection_config.get_request_timeout(request_timeout),
+ request_timeout=self._connection_config.get_request_timeout(
+ request_timeout
+ ),
timeout=timeout,
)
diff --git a/packages/python-sdk/e2b/sandbox/filesystem/watch_handle.py b/packages/python-sdk/e2b/sandbox/filesystem/watch_handle.py
index e4545bf3b..372e17a69 100644
--- a/packages/python-sdk/e2b/sandbox/filesystem/watch_handle.py
+++ b/packages/python-sdk/e2b/sandbox/filesystem/watch_handle.py
@@ -3,7 +3,7 @@ from dataclasses import dataclass
from enum import Enum
from e2b.envd.rpc import handle_rpc_exception
-from e2b.envd.filesystem.filesystem_pb2 import WatchDirResponse
+from e2b.envd.filesystem.filesystem_pb2 import EventType, WatchDirResponse
class FilesystemEventType(Enum):
@@ -14,6 +14,19 @@ class FilesystemEventType(Enum):
WRITE = "write"
+def map_event_type(event: EventType):
+ if event == EventType.EVENT_TYPE_CHMOD:
+ return FilesystemEventType.CHMOD
+ elif event == EventType.EVENT_TYPE_CREATE:
+ return FilesystemEventType.CREATE
+ elif event == EventType.EVENT_TYPE_REMOVE:
+ return FilesystemEventType.REMOVE
+ elif event == EventType.EVENT_TYPE_RENAME:
+ return FilesystemEventType.RENAME
+ elif event == EventType.EVENT_TYPE_WRITE:
+ return FilesystemEventType.WRITE
+
+
@dataclass
class FilesystemEvent:
name: str
@@ -37,10 +50,12 @@ class WatchHandle(Generator):
try:
for event in self._events:
if event.HasField("filesystem"):
- yield FilesystemEvent(
- name=event.filesystem.name,
- type=FilesystemEventType(event.filesystem.type),
- )
+ event_type = map_event_type(event.filesystem.type)
+ if event_type:
+ yield FilesystemEvent(
+ name=event.filesystem.name,
+ type=event_type,
+ )
except Exception as e:
raise handle_rpc_exception(e)
finally:
diff --git a/packages/python-sdk/e2b/sandbox/main.py b/packages/python-sdk/e2b/sandbox/main.py
index 2d28e42c7..21c7ed6dd 100644
--- a/packages/python-sdk/e2b/sandbox/main.py
+++ b/packages/python-sdk/e2b/sandbox/main.py
@@ -1,13 +1,19 @@
import urllib.parse
import httpcore
+import httpx
+import requests
-from typing import Optional, Dict
+from typing import Optional, Dict, Literal
from e2b.sandbox.filesystem.filesystem import Filesystem
from e2b.sandbox.process.main import Process
from e2b.sandbox.sandbox_api import SandboxApi
from e2b.connection_config import ConnectionConfig
-from e2b.envd.api import ENVD_API_FILES_ROUTE
+from e2b.envd.api import (
+ ENVD_API_FILES_ROUTE,
+ handle_envd_api_exception,
+ ENVD_API_HEALTH_ROUTE,
+)
from e2b.exceptions import SandboxException
# TODO: Add logs
@@ -26,7 +32,7 @@ class Sandbox(SandboxApi):
def __init__(
self,
- template: str = "base-v1",
+ template: str = "base",
timeout: int = 300,
metadata: Optional[Dict[str, str]] = None,
api_key: Optional[str] = None,
@@ -67,14 +73,20 @@ class Sandbox(SandboxApi):
request_timeout=request_timeout,
)
- self._envd_api_url = (
- f"{'http' if debug else 'https'}://{self.get_host(self._envd_port)}"
- )
+ self._envd_api_url = f"{'http' if self._connection_config.debug else 'https'}://{self.get_host(self._envd_port)}"
- pool = httpcore.ConnectionPool(max_connections=25)
+ self._envd_rpc_pool = httpcore.ConnectionPool(max_connections=25)
+ self._envd_api = httpx.Client(base_url=self._envd_api_url)
- self._filesystem = Filesystem(self._envd_api_url, self._connection_config, pool)
- self._process = Process(self._envd_api_url, self._connection_config, pool)
+ self._filesystem = Filesystem(
+ self._envd_api_url,
+ self._connection_config,
+ self._envd_rpc_pool,
+ self._envd_api,
+ )
+ self._process = Process(
+ self._envd_api_url, self._connection_config, self._envd_rpc_pool
+ )
def get_host(self, port: int) -> str:
if self._connection_config.debug:
@@ -82,6 +94,18 @@ class Sandbox(SandboxApi):
return f"{port}-{self.sandbox_id}.{self._connection_config.domain}"
+ def is_running(self, request_timeout: Optional[float] = None) -> Literal[True]:
+ r = requests.get(
+ self._envd_api_url + ENVD_API_HEALTH_ROUTE,
+ timeout=self._connection_config.get_request_timeout(request_timeout),
+ )
+
+ err = handle_envd_api_exception(r)
+ if err:
+ raise err
+
+ return True
+
@classmethod
def connect(
cls,
diff --git a/packages/python-sdk/example.py b/packages/python-sdk/example.py
index 4dbf5f9bc..64fe3e594 100644
--- a/packages/python-sdk/example.py
+++ b/packages/python-sdk/example.py
@@ -1,30 +1,11 @@
-import io
-import asyncio
-
from e2b import Sandbox
sbx = Sandbox(debug=True)
-print(sbx.sandbox_id)
-
-f = sbx.files.list("/")
-print(f)
-
-# const res = await sbx.commands.run('while true; do echo -n "Hello World"; sleep 1; done', {
-# // requestTimeoutMs: 1,
-# onStdout: (data) => {
-# // TODO: print also the time elapsed
-# console.log(`${(Date.now() - start) / 1000}s: ${data}`)
-# },
-# })
-
-
-# input = io.StringIO("This goes into the read buffer.")
-
-# s.files.write("/tmp/test.txt", input)
+print(sbx.is_running())
+res = sbx.files.list("/")
+print(res)
-sbx.commands.run(
- cmd='while true; do echo -n "Hello World"; sleep 1; done',
- on_stdout=lambda x: print(x),
-)
+# sbx.files.write("/tmp/test.txt", "Hello World")
+# print(sbx.files.read("/tmp/test.txt"))
diff --git a/packages/python-sdk/poetry.lock b/packages/python-sdk/poetry.lock
index 62327b551..50b51c4e1 100644
--- a/packages/python-sdk/poetry.lock
+++ b/packages/python-sdk/poetry.lock
@@ -26,6 +26,28 @@ files = [
[package.dependencies]
typing-extensions = {version = ">=4.0.0", markers = "python_version < \"3.9\""}
+[[package]]
+name = "anyio"
+version = "4.4.0"
+description = "High level compatibility layer for multiple asynchronous event loop implementations"
+optional = false
+python-versions = ">=3.8"
+files = [
+ {file = "anyio-4.4.0-py3-none-any.whl", hash = "sha256:c1b2d8f46a8a812513012e1107cb0e68c17159a7a594208005a57dc776e1bdc7"},
+ {file = "anyio-4.4.0.tar.gz", hash = "sha256:5aadc6a1bbb7cdb0bede386cac5e2940f5e2ff3aa20277e991cf028e0585ce94"},
+]
+
+[package.dependencies]
+exceptiongroup = {version = ">=1.0.2", markers = "python_version < \"3.11\""}
+idna = ">=2.8"
+sniffio = ">=1.1"
+typing-extensions = {version = ">=4.1", markers = "python_version < \"3.11\""}
+
+[package.extras]
+doc = ["Sphinx (>=7)", "packaging", "sphinx-autodoc-typehints (>=1.2.0)", "sphinx-rtd-theme"]
+test = ["anyio[trio]", "coverage[toml] (>=7)", "exceptiongroup (>=1.2.0)", "hypothesis (>=4.0)", "psutil (>=5.9)", "pytest (>=7.0)", "pytest-mock (>=3.6.1)", "trustme", "uvloop (>=0.17)"]
+trio = ["trio (>=0.23)"]
+
[[package]]
name = "black"
version = "23.12.1"
@@ -83,105 +105,6 @@ files = [
{file = "certifi-2024.6.2.tar.gz", hash = "sha256:3cd43f1c6fa7dedc5899d69d3ad0398fd018ad1a17fba83ddaf78aa46c747516"},
]
-[[package]]
-name = "charset-normalizer"
-version = "3.3.2"
-description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet."
-optional = false
-python-versions = ">=3.7.0"
-files = [
- {file = "charset-normalizer-3.3.2.tar.gz", hash = "sha256:f30c3cb33b24454a82faecaf01b19c18562b1e89558fb6c56de4d9118a032fd5"},
- {file = "charset_normalizer-3.3.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:25baf083bf6f6b341f4121c2f3c548875ee6f5339300e08be3f2b2ba1721cdd3"},
- {file = "charset_normalizer-3.3.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:06435b539f889b1f6f4ac1758871aae42dc3a8c0e24ac9e60c2384973ad73027"},
- {file = "charset_normalizer-3.3.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9063e24fdb1e498ab71cb7419e24622516c4a04476b17a2dab57e8baa30d6e03"},
- {file = "charset_normalizer-3.3.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6897af51655e3691ff853668779c7bad41579facacf5fd7253b0133308cf000d"},
- {file = "charset_normalizer-3.3.2-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1d3193f4a680c64b4b6a9115943538edb896edc190f0b222e73761716519268e"},
- {file = "charset_normalizer-3.3.2-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:cd70574b12bb8a4d2aaa0094515df2463cb429d8536cfb6c7ce983246983e5a6"},
- {file = "charset_normalizer-3.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8465322196c8b4d7ab6d1e049e4c5cb460d0394da4a27d23cc242fbf0034b6b5"},
- {file = "charset_normalizer-3.3.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a9a8e9031d613fd2009c182b69c7b2c1ef8239a0efb1df3f7c8da66d5dd3d537"},
- {file = "charset_normalizer-3.3.2-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:beb58fe5cdb101e3a055192ac291b7a21e3b7ef4f67fa1d74e331a7f2124341c"},
- {file = "charset_normalizer-3.3.2-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:e06ed3eb3218bc64786f7db41917d4e686cc4856944f53d5bdf83a6884432e12"},
- {file = "charset_normalizer-3.3.2-cp310-cp310-musllinux_1_1_ppc64le.whl", hash = "sha256:2e81c7b9c8979ce92ed306c249d46894776a909505d8f5a4ba55b14206e3222f"},
- {file = "charset_normalizer-3.3.2-cp310-cp310-musllinux_1_1_s390x.whl", hash = "sha256:572c3763a264ba47b3cf708a44ce965d98555f618ca42c926a9c1616d8f34269"},
- {file = "charset_normalizer-3.3.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:fd1abc0d89e30cc4e02e4064dc67fcc51bd941eb395c502aac3ec19fab46b519"},
- {file = "charset_normalizer-3.3.2-cp310-cp310-win32.whl", hash = "sha256:3d47fa203a7bd9c5b6cee4736ee84ca03b8ef23193c0d1ca99b5089f72645c73"},
- {file = "charset_normalizer-3.3.2-cp310-cp310-win_amd64.whl", hash = "sha256:10955842570876604d404661fbccbc9c7e684caf432c09c715ec38fbae45ae09"},
- {file = "charset_normalizer-3.3.2-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:802fe99cca7457642125a8a88a084cef28ff0cf9407060f7b93dca5aa25480db"},
- {file = "charset_normalizer-3.3.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:573f6eac48f4769d667c4442081b1794f52919e7edada77495aaed9236d13a96"},
- {file = "charset_normalizer-3.3.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:549a3a73da901d5bc3ce8d24e0600d1fa85524c10287f6004fbab87672bf3e1e"},
- {file = "charset_normalizer-3.3.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f27273b60488abe721a075bcca6d7f3964f9f6f067c8c4c605743023d7d3944f"},
- {file = "charset_normalizer-3.3.2-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1ceae2f17a9c33cb48e3263960dc5fc8005351ee19db217e9b1bb15d28c02574"},
- {file = "charset_normalizer-3.3.2-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:65f6f63034100ead094b8744b3b97965785388f308a64cf8d7c34f2f2e5be0c4"},
- {file = "charset_normalizer-3.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:753f10e867343b4511128c6ed8c82f7bec3bd026875576dfd88483c5c73b2fd8"},
- {file = "charset_normalizer-3.3.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4a78b2b446bd7c934f5dcedc588903fb2f5eec172f3d29e52a9096a43722adfc"},
- {file = "charset_normalizer-3.3.2-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:e537484df0d8f426ce2afb2d0f8e1c3d0b114b83f8850e5f2fbea0e797bd82ae"},
- {file = "charset_normalizer-3.3.2-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:eb6904c354526e758fda7167b33005998fb68c46fbc10e013ca97f21ca5c8887"},
- {file = "charset_normalizer-3.3.2-cp311-cp311-musllinux_1_1_ppc64le.whl", hash = "sha256:deb6be0ac38ece9ba87dea880e438f25ca3eddfac8b002a2ec3d9183a454e8ae"},
- {file = "charset_normalizer-3.3.2-cp311-cp311-musllinux_1_1_s390x.whl", hash = "sha256:4ab2fe47fae9e0f9dee8c04187ce5d09f48eabe611be8259444906793ab7cbce"},
- {file = "charset_normalizer-3.3.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:80402cd6ee291dcb72644d6eac93785fe2c8b9cb30893c1af5b8fdd753b9d40f"},
- {file = "charset_normalizer-3.3.2-cp311-cp311-win32.whl", hash = "sha256:7cd13a2e3ddeed6913a65e66e94b51d80a041145a026c27e6bb76c31a853c6ab"},
- {file = "charset_normalizer-3.3.2-cp311-cp311-win_amd64.whl", hash = "sha256:663946639d296df6a2bb2aa51b60a2454ca1cb29835324c640dafb5ff2131a77"},
- {file = "charset_normalizer-3.3.2-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:0b2b64d2bb6d3fb9112bafa732def486049e63de9618b5843bcdd081d8144cd8"},
- {file = "charset_normalizer-3.3.2-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:ddbb2551d7e0102e7252db79ba445cdab71b26640817ab1e3e3648dad515003b"},
- {file = "charset_normalizer-3.3.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:55086ee1064215781fff39a1af09518bc9255b50d6333f2e4c74ca09fac6a8f6"},
- {file = "charset_normalizer-3.3.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8f4a014bc36d3c57402e2977dada34f9c12300af536839dc38c0beab8878f38a"},
- {file = "charset_normalizer-3.3.2-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a10af20b82360ab00827f916a6058451b723b4e65030c5a18577c8b2de5b3389"},
- {file = "charset_normalizer-3.3.2-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:8d756e44e94489e49571086ef83b2bb8ce311e730092d2c34ca8f7d925cb20aa"},
- {file = "charset_normalizer-3.3.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:90d558489962fd4918143277a773316e56c72da56ec7aa3dc3dbbe20fdfed15b"},
- {file = "charset_normalizer-3.3.2-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6ac7ffc7ad6d040517be39eb591cac5ff87416c2537df6ba3cba3bae290c0fed"},
- {file = "charset_normalizer-3.3.2-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:7ed9e526742851e8d5cc9e6cf41427dfc6068d4f5a3bb03659444b4cabf6bc26"},
- {file = "charset_normalizer-3.3.2-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:8bdb58ff7ba23002a4c5808d608e4e6c687175724f54a5dade5fa8c67b604e4d"},
- {file = "charset_normalizer-3.3.2-cp312-cp312-musllinux_1_1_ppc64le.whl", hash = "sha256:6b3251890fff30ee142c44144871185dbe13b11bab478a88887a639655be1068"},
- {file = "charset_normalizer-3.3.2-cp312-cp312-musllinux_1_1_s390x.whl", hash = "sha256:b4a23f61ce87adf89be746c8a8974fe1c823c891d8f86eb218bb957c924bb143"},
- {file = "charset_normalizer-3.3.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:efcb3f6676480691518c177e3b465bcddf57cea040302f9f4e6e191af91174d4"},
- {file = "charset_normalizer-3.3.2-cp312-cp312-win32.whl", hash = "sha256:d965bba47ddeec8cd560687584e88cf699fd28f192ceb452d1d7ee807c5597b7"},
- {file = "charset_normalizer-3.3.2-cp312-cp312-win_amd64.whl", hash = "sha256:96b02a3dc4381e5494fad39be677abcb5e6634bf7b4fa83a6dd3112607547001"},
- {file = "charset_normalizer-3.3.2-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:95f2a5796329323b8f0512e09dbb7a1860c46a39da62ecb2324f116fa8fdc85c"},
- {file = "charset_normalizer-3.3.2-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c002b4ffc0be611f0d9da932eb0f704fe2602a9a949d1f738e4c34c75b0863d5"},
- {file = "charset_normalizer-3.3.2-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a981a536974bbc7a512cf44ed14938cf01030a99e9b3a06dd59578882f06f985"},
- {file = "charset_normalizer-3.3.2-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:3287761bc4ee9e33561a7e058c72ac0938c4f57fe49a09eae428fd88aafe7bb6"},
- {file = "charset_normalizer-3.3.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:42cb296636fcc8b0644486d15c12376cb9fa75443e00fb25de0b8602e64c1714"},
- {file = "charset_normalizer-3.3.2-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0a55554a2fa0d408816b3b5cedf0045f4b8e1a6065aec45849de2d6f3f8e9786"},
- {file = "charset_normalizer-3.3.2-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:c083af607d2515612056a31f0a8d9e0fcb5876b7bfc0abad3ecd275bc4ebc2d5"},
- {file = "charset_normalizer-3.3.2-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:87d1351268731db79e0f8e745d92493ee2841c974128ef629dc518b937d9194c"},
- {file = "charset_normalizer-3.3.2-cp37-cp37m-musllinux_1_1_ppc64le.whl", hash = "sha256:bd8f7df7d12c2db9fab40bdd87a7c09b1530128315d047a086fa3ae3435cb3a8"},
- {file = "charset_normalizer-3.3.2-cp37-cp37m-musllinux_1_1_s390x.whl", hash = "sha256:c180f51afb394e165eafe4ac2936a14bee3eb10debc9d9e4db8958fe36afe711"},
- {file = "charset_normalizer-3.3.2-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:8c622a5fe39a48f78944a87d4fb8a53ee07344641b0562c540d840748571b811"},
- {file = "charset_normalizer-3.3.2-cp37-cp37m-win32.whl", hash = "sha256:db364eca23f876da6f9e16c9da0df51aa4f104a972735574842618b8c6d999d4"},
- {file = "charset_normalizer-3.3.2-cp37-cp37m-win_amd64.whl", hash = "sha256:86216b5cee4b06df986d214f664305142d9c76df9b6512be2738aa72a2048f99"},
- {file = "charset_normalizer-3.3.2-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:6463effa3186ea09411d50efc7d85360b38d5f09b870c48e4600f63af490e56a"},
- {file = "charset_normalizer-3.3.2-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:6c4caeef8fa63d06bd437cd4bdcf3ffefe6738fb1b25951440d80dc7df8c03ac"},
- {file = "charset_normalizer-3.3.2-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:37e55c8e51c236f95b033f6fb391d7d7970ba5fe7ff453dad675e88cf303377a"},
- {file = "charset_normalizer-3.3.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:fb69256e180cb6c8a894fee62b3afebae785babc1ee98b81cdf68bbca1987f33"},
- {file = "charset_normalizer-3.3.2-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:ae5f4161f18c61806f411a13b0310bea87f987c7d2ecdbdaad0e94eb2e404238"},
- {file = "charset_normalizer-3.3.2-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b2b0a0c0517616b6869869f8c581d4eb2dd83a4d79e0ebcb7d373ef9956aeb0a"},
- {file = "charset_normalizer-3.3.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:45485e01ff4d3630ec0d9617310448a8702f70e9c01906b0d0118bdf9d124cf2"},
- {file = "charset_normalizer-3.3.2-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:eb00ed941194665c332bf8e078baf037d6c35d7c4f3102ea2d4f16ca94a26dc8"},
- {file = "charset_normalizer-3.3.2-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:2127566c664442652f024c837091890cb1942c30937add288223dc895793f898"},
- {file = "charset_normalizer-3.3.2-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:a50aebfa173e157099939b17f18600f72f84eed3049e743b68ad15bd69b6bf99"},
- {file = "charset_normalizer-3.3.2-cp38-cp38-musllinux_1_1_ppc64le.whl", hash = "sha256:4d0d1650369165a14e14e1e47b372cfcb31d6ab44e6e33cb2d4e57265290044d"},
- {file = "charset_normalizer-3.3.2-cp38-cp38-musllinux_1_1_s390x.whl", hash = "sha256:923c0c831b7cfcb071580d3f46c4baf50f174be571576556269530f4bbd79d04"},
- {file = "charset_normalizer-3.3.2-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:06a81e93cd441c56a9b65d8e1d043daeb97a3d0856d177d5c90ba85acb3db087"},
- {file = "charset_normalizer-3.3.2-cp38-cp38-win32.whl", hash = "sha256:6ef1d82a3af9d3eecdba2321dc1b3c238245d890843e040e41e470ffa64c3e25"},
- {file = "charset_normalizer-3.3.2-cp38-cp38-win_amd64.whl", hash = "sha256:eb8821e09e916165e160797a6c17edda0679379a4be5c716c260e836e122f54b"},
- {file = "charset_normalizer-3.3.2-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:c235ebd9baae02f1b77bcea61bce332cb4331dc3617d254df3323aa01ab47bd4"},
- {file = "charset_normalizer-3.3.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:5b4c145409bef602a690e7cfad0a15a55c13320ff7a3ad7ca59c13bb8ba4d45d"},
- {file = "charset_normalizer-3.3.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:68d1f8a9e9e37c1223b656399be5d6b448dea850bed7d0f87a8311f1ff3dabb0"},
- {file = "charset_normalizer-3.3.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:22afcb9f253dac0696b5a4be4a1c0f8762f8239e21b99680099abd9b2b1b2269"},
- {file = "charset_normalizer-3.3.2-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e27ad930a842b4c5eb8ac0016b0a54f5aebbe679340c26101df33424142c143c"},
- {file = "charset_normalizer-3.3.2-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:1f79682fbe303db92bc2b1136016a38a42e835d932bab5b3b1bfcfbf0640e519"},
- {file = "charset_normalizer-3.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b261ccdec7821281dade748d088bb6e9b69e6d15b30652b74cbbac25e280b796"},
- {file = "charset_normalizer-3.3.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:122c7fa62b130ed55f8f285bfd56d5f4b4a5b503609d181f9ad85e55c89f4185"},
- {file = "charset_normalizer-3.3.2-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:d0eccceffcb53201b5bfebb52600a5fb483a20b61da9dbc885f8b103cbe7598c"},
- {file = "charset_normalizer-3.3.2-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:9f96df6923e21816da7e0ad3fd47dd8f94b2a5ce594e00677c0013018b813458"},
- {file = "charset_normalizer-3.3.2-cp39-cp39-musllinux_1_1_ppc64le.whl", hash = "sha256:7f04c839ed0b6b98b1a7501a002144b76c18fb1c1850c8b98d458ac269e26ed2"},
- {file = "charset_normalizer-3.3.2-cp39-cp39-musllinux_1_1_s390x.whl", hash = "sha256:34d1c8da1e78d2e001f363791c98a272bb734000fcef47a491c1e3b0505657a8"},
- {file = "charset_normalizer-3.3.2-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:ff8fa367d09b717b2a17a052544193ad76cd49979c805768879cb63d9ca50561"},
- {file = "charset_normalizer-3.3.2-cp39-cp39-win32.whl", hash = "sha256:aed38f6e4fb3f5d6bf81bfa990a07806be9d83cf7bacef998ab1a9bd660a581f"},
- {file = "charset_normalizer-3.3.2-cp39-cp39-win_amd64.whl", hash = "sha256:b01b88d45a6fcb69667cd6d2f7a9aeb4bf53760d7fc536bf679ec94fe9f3ff3d"},
- {file = "charset_normalizer-3.3.2-py3-none-any.whl", hash = "sha256:3e4d1f6587322d2788836a99c69062fbb091331ec940e02d12d179c1d53e25fc"},
-]
-
[[package]]
name = "click"
version = "8.1.7"
@@ -267,6 +190,30 @@ http2 = ["h2 (>=3,<5)"]
socks = ["socksio (==1.*)"]
trio = ["trio (>=0.22.0,<0.26.0)"]
+[[package]]
+name = "httpx"
+version = "0.27.0"
+description = "The next generation HTTP client."
+optional = false
+python-versions = ">=3.8"
+files = [
+ {file = "httpx-0.27.0-py3-none-any.whl", hash = "sha256:71d5465162c13681bff01ad59b2cc68dd838ea1f10e51574bac27103f00c91a5"},
+ {file = "httpx-0.27.0.tar.gz", hash = "sha256:a0cb88a46f32dc874e04ee956e4c2764aba2aa228f650b06788ba6bda2962ab5"},
+]
+
+[package.dependencies]
+anyio = "*"
+certifi = "*"
+httpcore = "==1.*"
+idna = "*"
+sniffio = "*"
+
+[package.extras]
+brotli = ["brotli", "brotlicffi"]
+cli = ["click (==8.*)", "pygments (==2.*)", "rich (>=10,<14)"]
+http2 = ["h2 (>=3,<5)"]
+socks = ["socksio (==1.*)"]
+
[[package]]
name = "idna"
version = "3.7"
@@ -568,27 +515,6 @@ files = [
[package.extras]
cli = ["click (>=5.0)"]
-[[package]]
-name = "requests"
-version = "2.32.3"
-description = "Python HTTP for Humans."
-optional = false
-python-versions = ">=3.8"
-files = [
- {file = "requests-2.32.3-py3-none-any.whl", hash = "sha256:70761cfe03c773ceb22aa2f671b4757976145175cdfca038c02654d061d6dcc6"},
- {file = "requests-2.32.3.tar.gz", hash = "sha256:55365417734eb18255590a9ff9eb97e9e1da868d4ccd6402399eaf68af20a760"},
-]
-
-[package.dependencies]
-certifi = ">=2017.4.17"
-charset-normalizer = ">=2,<4"
-idna = ">=2.5,<4"
-urllib3 = ">=1.21.1,<3"
-
-[package.extras]
-socks = ["PySocks (>=1.5.6,!=1.5.7)"]
-use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"]
-
[[package]]
name = "six"
version = "1.16.0"
@@ -600,6 +526,17 @@ files = [
{file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"},
]
+[[package]]
+name = "sniffio"
+version = "1.3.1"
+description = "Sniff out which async library your code is running under"
+optional = false
+python-versions = ">=3.7"
+files = [
+ {file = "sniffio-1.3.1-py3-none-any.whl", hash = "sha256:2f6da418d1f1e0fddd844478f41680e794e6051915791a034ff65e5f100525a2"},
+ {file = "sniffio-1.3.1.tar.gz", hash = "sha256:f4324edc670a0f49750a81b895f35c3adb843cca46f0530f79fc1babb23789dc"},
+]
+
[[package]]
name = "tomli"
version = "2.0.1"
@@ -642,4 +579,4 @@ zstd = ["zstandard (>=0.18.0)"]
[metadata]
lock-version = "2.0"
python-versions = "^3.8"
-content-hash = "99f593fce946c991cdbc37f202dd18c672f260d40f0a02870b9699fb3690269e"
+content-hash = "011f5a00fd1d5cb161867bf2f22d1fd90bb070bd9c11851afcb5b159f251e930"
diff --git a/packages/python-sdk/pyproject.toml b/packages/python-sdk/pyproject.toml
index 27bf373ba..fc7495987 100644
--- a/packages/python-sdk/pyproject.toml
+++ b/packages/python-sdk/pyproject.toml
@@ -18,8 +18,8 @@ pydantic = "*"
aenum = ">=3.1.11"
typing-extensions = ">=4.8.0"
protobuf = "^5.26.1"
-requests = "^2.32.3"
httpcore = "^1.0.5"
+httpx = "^0.27.0"
[tool.poetry.group.dev.dependencies]
black = "^23.7.0"
diff --git a/packages/python-sdk/tests/conftest.py b/packages/python-sdk/tests/conftest.py
new file mode 100644
index 000000000..7da44913a
--- /dev/null
+++ b/packages/python-sdk/tests/conftest.py
@@ -0,0 +1,25 @@
+import pytest
+
+from logging import warning
+
+from e2b import Sandbox
+
+
+def template():
+ return "base"
+
+
+def sandbox(template):
+ sandbox = Sandbox(template)
+
+ try:
+ yield sandbox
+ finally:
+ try:
+ sandbox.kill()
+ except:
+ warning(
+ "Failed to kill sandbox — this is expected if the test runs with local envd."
+ )
diff --git a/packages/python-sdk/tests/sandbox/files/test_exists.py b/packages/python-sdk/tests/sandbox/files/test_exists.py
index e69de29bb..2a04aec5d 100644
--- a/packages/python-sdk/tests/sandbox/files/test_exists.py
+++ b/packages/python-sdk/tests/sandbox/files/test_exists.py
@@ -0,0 +1,8 @@
+from e2b import Sandbox
+
+
+def test_exists(sandbox: Sandbox):
+ filename = "test_exists.txt"
+
+ sandbox.files.write(filename, "test")
+ assert sandbox.files.exists(filename)
diff --git a/packages/python-sdk/tests/sandbox/test_create.py b/packages/python-sdk/tests/sandbox/test_create.py
index e69de29bb..1e03818b4 100644
--- a/packages/python-sdk/tests/sandbox/test_create.py
+++ b/packages/python-sdk/tests/sandbox/test_create.py
@@ -0,0 +1,6 @@
+from e2b.sandbox.main import Sandbox
+
+
+def test_start(template):
+ sbx = Sandbox(template, timeout=5)
+ assert sbx.is_running()
diff --git a/packages/js-sdk/test/sandbox/files/rename.test.mjs b/packages/python-sdk/tests/sandbox/test_host.py
similarity index 100%
rename from packages/js-sdk/test/sandbox/files/rename.test.mjs
rename to packages/python-sdk/tests/sandbox/test_host.py
diff --git a/packages/js-sdk/test/sandbox/files/watch.test.mjs b/packages/python-sdk/tests/sandbox/test_upload_url.py
similarity index 100%
rename from packages/js-sdk/test/sandbox/files/watch.test.mjs
rename to packages/python-sdk/tests/sandbox/test_upload_url.py
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 91c3b2461..b9302c0b9 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -17,10 +17,10 @@ importers:
devDependencies:
'@typescript-eslint/eslint-plugin':
specifier: ^6.7.2
- version: 6.7.2(@typescript-eslint/[email protected])([email protected])([email protected])
+ version: 6.7.2(@typescript-eslint/[email protected])([email protected])([email protected])
'@typescript-eslint/parser':
specifier: ^6.7.2
changeset:
specifier: ^0.2.6
version: 0.2.6
@@ -1532,6 +1532,7 @@ packages:
/@humanwhocodes/[email protected]:
resolution: {integrity: sha512-3T8LkOmg45BV5FICb15QQMsyUSWrQ8AygVfC7ZG32zOalnqrilm018ZVCw0eapXux8FtA33q8PSRSstjee3jSg==}
engines: {node: '>=10.10.0'}
+ deprecated: Use @eslint/config-array instead
dependencies:
'@humanwhocodes/object-schema': 2.0.3
debug: 4.3.4
@@ -1551,6 +1552,7 @@ packages:
/@humanwhocodes/[email protected]:
resolution: {integrity: sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==}
+ deprecated: Use @eslint/object-schema instead
dev: true
@@ -1963,7 +1965,7 @@ packages:
resolution: {integrity: sha512-7kZUAaLscfgbwBQRbvdMYaZOWyMEcPTH/tJjnyAWJ/dvvs9Ef+CERx/qJb9GExJpl1qipaDGn7KqHnFGGixd0w==}
engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0}
dependencies:
- semver: 7.5.4
+ semver: 7.6.2
dev: true
@@ -1976,7 +1978,7 @@ packages:
proc-log: 3.0.0
promise-inflight: 1.0.1
promise-retry: 2.0.1
- semver: 7.5.4
+ semver: 7.6.2
which: 3.0.1
transitivePeerDependencies:
- bluebird
@@ -2110,7 +2112,7 @@ packages:
engines: {node: '>=14.6'}
dependencies:
hosted-git-info: 4.1.0
- semver: 7.5.4
+ semver: 7.6.2
validate-npm-package-name: 4.0.0
dev: true
@@ -2139,7 +2141,7 @@ packages:
path-temp: 2.1.0
ramda: /@pnpm/[email protected]
rename-overwrite: 4.0.3
- semver: 7.5.4
+ semver: 7.6.2
ssri: 10.0.4
version-selector-type: 3.0.0
transitivePeerDependencies:
@@ -2154,7 +2156,7 @@ packages:
resolution: {integrity: sha512-yQ0pMthlw8rTgS/C9hrjne+NEnnSNevCjtdodd7i15I59jMBYciHifZ/vjg0NY+Jl+USTc3dBE+0h/4tdYjMKg==}
engines: {node: '>=16.14'}
dependencies:
- semver: 7.5.4
+ semver: 7.6.2
dev: true
@@ -3202,7 +3204,7 @@ packages:
engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0}
dependencies:
'@tufjs/canonical-json': 1.0.0
- minimatch: 9.0.3
+ minimatch: 9.0.4
dev: true
@@ -3408,7 +3410,7 @@ packages:
'@types/node': 18.18.6
dev: false
- /@typescript-eslint/[email protected](@typescript-eslint/[email protected])([email protected])([email protected]):
+ /@typescript-eslint/[email protected](@typescript-eslint/[email protected])([email protected])([email protected]):
resolution: {integrity: sha512-ooaHxlmSgZTM6CHYAFRlifqh1OAr3PAQEwi7lhYhaegbnXrnh7CDcHmc3+ihhbQC7H0i4JF0psI5ehzkF6Yl6Q==}
engines: {node: ^16.0.0 || >=18.0.0}
peerDependencies:
@@ -3420,10 +3422,10 @@ packages:
optional: true
dependencies:
'@eslint-community/regexpp': 4.8.1
- '@typescript-eslint/parser': 6.7.2([email protected])([email protected])
+ '@typescript-eslint/parser': 6.7.2([email protected])([email protected])
'@typescript-eslint/scope-manager': 6.7.2
- '@typescript-eslint/type-utils': 6.7.2([email protected])([email protected])
- '@typescript-eslint/utils': 6.7.2([email protected])([email protected])
+ '@typescript-eslint/type-utils': 6.7.2([email protected])([email protected])
+ '@typescript-eslint/utils': 6.7.2([email protected])([email protected])
'@typescript-eslint/visitor-keys': 6.7.2
debug: 4.3.4
eslint: 8.49.0
@@ -3431,8 +3433,8 @@ packages:
ignore: 5.2.4
natural-compare: 1.4.0
semver: 7.5.4
- ts-api-utils: 1.0.3([email protected])
- typescript: 5.4.5
+ ts-api-utils: 1.0.3([email protected])
+ typescript: 5.5.2
transitivePeerDependencies:
- supports-color
dev: true
@@ -3464,7 +3466,7 @@ packages:
- supports-color
dev: true
resolution: {integrity: sha512-KA3E4ox0ws+SPyxQf9iSI25R6b4Ne78ORhNHeVKrPQnoYsb9UhieoiRoJgrzgEeKGOXhcY1i8YtOeCHHTDa6Fw==}
engines: {node: ^16.0.0 || >=18.0.0}
peerDependencies:
@@ -3476,11 +3478,11 @@ packages:
dependencies:
'@typescript-eslint/scope-manager': 6.7.2
'@typescript-eslint/types': 6.7.2
- '@typescript-eslint/typescript-estree': 6.7.2([email protected])
+ '@typescript-eslint/typescript-estree': 6.7.2([email protected])
'@typescript-eslint/visitor-keys': 6.7.2
debug: 4.3.4
eslint: 8.49.0
- typescript: 5.4.5
+ typescript: 5.5.2
transitivePeerDependencies:
- supports-color
dev: true
@@ -3551,7 +3553,7 @@ packages:
'@typescript-eslint/visitor-keys': 7.11.0
dev: true
resolution: {integrity: sha512-36F4fOYIROYRl0qj95dYKx6kybddLtsbmPIYNK0OBeXv2j9L5nZ17j9jmfy+bIDHKQgn2EZX+cofsqi8NPATBQ==}
engines: {node: ^16.0.0 || >=18.0.0}
peerDependencies:
@@ -3561,12 +3563,12 @@ packages:
typescript:
optional: true
dependencies:
- '@typescript-eslint/typescript-estree': 6.7.2([email protected])
- '@typescript-eslint/utils': 6.7.2([email protected])([email protected])
+ '@typescript-eslint/typescript-estree': 6.7.2([email protected])
+ '@typescript-eslint/utils': 6.7.2([email protected])([email protected])
debug: 4.3.4
eslint: 8.49.0
- ts-api-utils: 1.0.3([email protected])
- typescript: 5.4.5
+ ts-api-utils: 1.0.3([email protected])
+ typescript: 5.5.2
transitivePeerDependencies:
- supports-color
dev: true
@@ -3621,7 +3623,7 @@ packages:
globby: 11.1.0
is-glob: 4.0.3
minimatch: 9.0.3
- semver: 7.5.4
+ semver: 7.6.2
ts-api-utils: 1.0.3([email protected])
typescript: 5.1.6
transitivePeerDependencies:
@@ -3649,7 +3651,7 @@ packages:
- supports-color
dev: true
- /@typescript-eslint/[email protected]([email protected]):
+ /@typescript-eslint/[email protected]([email protected]):
resolution: {integrity: sha512-kiJKVMLkoSciGyFU0TOY0fRxnp9qq1AzVOHNeN1+B9erKFCJ4Z8WdjAkKQPP+b1pWStGFqezMLltxO+308dJTQ==}
engines: {node: ^16.0.0 || >=18.0.0}
peerDependencies:
@@ -3664,8 +3666,8 @@ packages:
globby: 11.1.0
is-glob: 4.0.3
semver: 7.5.4
- ts-api-utils: 1.0.3([email protected])
- typescript: 5.4.5
+ ts-api-utils: 1.0.3([email protected])
+ typescript: 5.5.2
transitivePeerDependencies:
- supports-color
dev: true
@@ -3711,7 +3713,7 @@ packages:
- typescript
dev: true
resolution: {integrity: sha512-ZCcBJug/TS6fXRTsoTkgnsvyWSiXwMNiPzBUani7hDidBdj1779qwM1FIAmpH4lvlOZNF3EScsxxuGifjpLSWQ==}
engines: {node: ^16.0.0 || >=18.0.0}
peerDependencies:
@@ -3722,7 +3724,7 @@ packages:
'@types/semver': 7.5.2
'@typescript-eslint/scope-manager': 6.7.2
'@typescript-eslint/types': 6.7.2
- '@typescript-eslint/typescript-estree': 6.7.2([email protected])
+ '@typescript-eslint/typescript-estree': 6.7.2([email protected])
eslint: 8.49.0
semver: 7.5.4
transitivePeerDependencies:
@@ -4423,7 +4425,7 @@ packages:
resolution: {integrity: sha512-qwVpFEHNfhYJIzNRBvd2C1kyo6jz3ZSMPyyuR47OPdiKWlbYnZNyDWuyR175qDnAJLiCo5fBBqPb3RiXgWlkOQ==}
dependencies:
- semver: 7.5.4
+ semver: 7.6.2
dev: true
@@ -5652,7 +5654,7 @@ packages:
eslint-import-resolver-webpack:
optional: true
dependencies:
- '@typescript-eslint/parser': 6.7.2([email protected])([email protected])
+ '@typescript-eslint/parser': 6.7.2([email protected])([email protected])
debug: 3.2.7
eslint: 8.57.0
eslint-import-resolver-node: 0.3.9
@@ -5670,7 +5672,7 @@ packages:
'@typescript-eslint/parser':
optional: true
dependencies:
- '@typescript-eslint/parser': 6.7.2([email protected])([email protected])
+ '@typescript-eslint/parser': 6.7.2([email protected])([email protected])
array-includes: 3.1.7
array.prototype.findlastindex: 1.2.3
array.prototype.flat: 1.3.2
@@ -5764,7 +5766,7 @@ packages:
'@typescript-eslint/eslint-plugin':
optional: true
dependencies:
- '@typescript-eslint/eslint-plugin': 6.7.2(@typescript-eslint/[email protected])([email protected])([email protected])
+ '@typescript-eslint/eslint-plugin': 6.7.2(@typescript-eslint/[email protected])([email protected])([email protected])
eslint: 8.49.0
eslint-rule-composer: 0.3.0
dev: true
@@ -6422,7 +6424,7 @@ packages:
dependencies:
foreground-child: 3.1.1
jackspeak: 2.3.6
- minimatch: 9.0.3
+ minimatch: 9.0.4
minipass: 7.0.3
path-scurry: 1.10.1
dev: true
@@ -6434,13 +6436,14 @@ packages:
dependencies:
foreground-child: 3.1.1
jackspeak: 2.3.3
- minimatch: 9.0.3
+ minimatch: 9.0.4
minipass: 7.0.3
path-scurry: 1.10.1
dev: true
resolution: {integrity: sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==}
+ deprecated: Glob versions prior to v9 are no longer supported
dependencies:
fs.realpath: 1.0.0
inflight: 1.0.6
@@ -6462,6 +6465,7 @@ packages:
resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==}
+ deprecated: Glob versions prior to v9 are no longer supported
dependencies:
fs.realpath: 1.0.0
inflight: 1.0.6
@@ -6789,7 +6793,7 @@ packages:
resolution: {integrity: sha512-C7FfFoTA+bI10qfeydT8aZbvr91vAEU+2W5BZUlzPec47oNb07SsOfwYrtxuvOYdUApPP/Qlh4DtAO51Ekk2QA==}
engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0}
dependencies:
- minimatch: 9.0.3
+ minimatch: 9.0.4
dev: true
@@ -6837,6 +6841,7 @@ packages:
resolution: {integrity: sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==}
+ deprecated: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
dependencies:
once: 1.4.0
wrappy: 1.0.2
@@ -8748,7 +8753,7 @@ packages:
resolution: {integrity: sha512-2s6B2CWZM//kPgwnuI0KrYwNjfdByE25zvAaEpq9IH4zcNsarH8Ihu/UuX6XMPEogDAxkuUFeZn60pXNHAqn3A==}
engines: {node: '>=10'}
dependencies:
- semver: 7.5.4
+ semver: 7.6.2
dev: true
@@ -8796,7 +8801,7 @@ packages:
nopt: 6.0.0
npmlog: 6.0.2
rimraf: 3.0.2
- semver: 7.5.4
+ semver: 7.6.2
tar: 6.2.0
which: 2.0.2
transitivePeerDependencies:
@@ -8830,7 +8835,7 @@ packages:
dependencies:
hosted-git-info: 6.1.1
is-core-module: 2.13.0
- semver: 7.5.4
+ semver: 7.6.2
validate-npm-package-license: 3.0.4
dev: true
@@ -8949,7 +8954,7 @@ packages:
resolution: {integrity: sha512-W29RiK/xtpCGqn6f3ixfRYGk+zRyr+Ew9F2E20BfXxT5/euLdA/Nm7fO7OeTGuAmTs30cpgInyJ0cYe708YTZw==}
engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0}
dependencies:
- semver: 7.5.4
+ semver: 7.6.2
dev: true
@@ -8963,7 +8968,7 @@ packages:
dependencies:
hosted-git-info: 6.1.1
proc-log: 3.0.0
- semver: 7.5.4
+ semver: 7.6.2
validate-npm-package-name: 5.0.0
dev: true
@@ -8981,7 +8986,7 @@ packages:
npm-install-checks: 6.3.0
npm-normalize-package-bin: 3.0.1
npm-package-arg: 10.1.0
- semver: 7.5.4
+ semver: 7.6.2
dev: true
@@ -9284,7 +9289,7 @@ packages:
got: 12.6.1
registry-auth-token: 5.0.2
registry-url: 6.0.1
- semver: 7.5.4
+ semver: 7.6.2
dev: true
@@ -9568,7 +9573,7 @@ packages:
dependencies:
nanoid: 3.3.6
picocolors: 1.0.0
- source-map-js: 1.0.2
+ source-map-js: 1.2.0
dev: false
@@ -9585,7 +9590,7 @@ packages:
dependencies:
nanoid: 3.3.6
picocolors: 1.0.0
- source-map-js: 1.0.2
+ source-map-js: 1.2.0
dev: false
@@ -10334,7 +10339,7 @@ packages:
resolution: {integrity: sha512-0Ju4+6A8iOnpL/Thra7dZsSlOHYAHIeMxfhWQRI1/VLcT3WDBZKKtQt/QkBOsiIN9ZpuvHE6cGZ0x4glCMmfiA==}
engines: {node: '>=12'}
dependencies:
- semver: 7.5.4
+ semver: 7.6.2
dev: true
@@ -11158,13 +11163,13 @@ packages:
typescript: 5.1.6
dev: true
resolution: {integrity: sha512-wNMeqtMz5NtwpT/UZGY5alT+VoKdSsOOP/kqHFcUW1P/VRhH2wJ48+DN2WwUliNbQ976ETwDL0Ifd2VVvgonvg==}
engines: {node: '>=16.13.0'}
peerDependencies:
typescript: '>=4.2.0'
dependencies:
- typescript: 5.4.5
+ typescript: 5.5.2
dev: true
@@ -11420,6 +11425,12 @@ packages:
hasBin: true
dev: true
+ resolution: {integrity: sha512-NcRtPEOsPFFWjobJEtfihkLCZCXZt/os3zf8nTxjVH3RvTSxjrCamJpbExGvYOF+tFHc3pA65qpdwPbzjohhew==}
+ engines: {node: '>=14.17'}
+ hasBin: true
+ dev: true
+
resolution: {integrity: sha512-jv+D9de1flsum5QkFtBdjyppCQAdz9kTck/0xST5Vx48T9LL2BYnw0Iw77dSKDQ9KZ/PS3qPO1vfXHDpLZlxcQ==}
dev: true
@@ -11735,7 +11746,7 @@ packages:
resolution: {integrity: sha512-PSvMIZS7C1MuVNBXl/CDG2pZq8EXy/NW2dHIdm3bVP5N0PC8utDK8ttXLXj44Gn3J0lQE3U7Mpm1estAOd+eiA==}
engines: {node: '>=10.13'}
dependencies:
- semver: 7.5.4
+ semver: 7.6.2
dev: true
diff --git a/spec/envd/envd.yaml b/spec/envd/envd.yaml
index db8de8714..4c6319121 100644
--- a/spec/envd/envd.yaml
+++ b/spec/envd/envd.yaml
@@ -8,6 +8,13 @@ tags:
- name: files
paths:
+ /health:
+ get:
+ summary: Check the health of the service
+ responses:
+ 204:
+ description: The service is healthy
+
/sync:
post:
summary: Ensure the time and metadata is synced with the host
@@ -26,7 +33,7 @@ paths:
200:
$ref: "#/components/responses/DownloadSuccess"
400:
- $ref: "#/components/responses/BadRequest"
+ $ref: "#/components/responses/InvalidUser"
403:
$ref: "#/components/responses/DirectoryPathError"
404:
@@ -45,7 +52,7 @@ paths:
204:
$ref: "#/components/responses/UploadSuccess"
400:
- $ref: "#/components/responses/BadRequest"
+ $ref: "#/components/responses/InvalidUser"
403:
$ref: "#/components/responses/DirectoryPathError"
500:
@@ -112,8 +119,8 @@ components:
application/json:
schema:
$ref: "#/components/schemas/Error"
- BadRequest:
- description: Bad request
+ InvalidUser:
+ description: Invalid user
content:
application/json:
schema: