refactor(e2b): keep code runtime host-local
This commit is contained in:
@@ -2,5 +2,5 @@
|
||||
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
||||
# after editing either side, bring the other along and re-record with:
|
||||
# pnpm run verify-translation-pairing --write packages/e2b/subprocess-e2b/README.md
|
||||
README.md: 3ddfe5bc47309ba56d3f8af7720fcbe71ec8a302
|
||||
README.zh.md: c4db7bf8bb8a0f4b2f147dd22868978be5d1fcf4
|
||||
README.md: 3bb9802c3afa41f3949fceeb73e76ea5cebce744
|
||||
README.zh.md: 520f0ea1cde18ed523ba80015d3d4700730aba7a
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
English | [中文](README.zh.md)
|
||||
|
||||
E2B implementation of the [`@deepseek-ai/dsh-subprocess`](../../subprocess/subprocess/README.md) seam. It has no config: load [`@deepseek-ai/dsh-e2b`](../e2b/README.md) first, then this service in place of `dsh-subprocess-local`. Existing Bash, PTY, LSP, and subprocess Code Runtime consumers then execute in the shared remote sandbox without E2B-specific capability packages.
|
||||
E2B implementation of the [`@deepseek-ai/dsh-subprocess`](../../subprocess/subprocess/README.md) seam. It has no config: load [`@deepseek-ai/dsh-e2b`](../e2b/README.md) first, then this service in place of `dsh-subprocess-local`. Existing Bash, PTY, and LSP consumers then execute in the shared remote sandbox without E2B-specific capability packages.
|
||||
|
||||
## Behavior
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
[English](README.md) | 中文
|
||||
|
||||
[`@deepseek-ai/dsh-subprocess`](../../subprocess/subprocess/README.md) seam 的 E2B 实现。它没有配置:先加载 [`@deepseek-ai/dsh-e2b`](../e2b/README.md),再用本服务取代 `dsh-subprocess-local`。现有的 Bash、PTY、LSP 以及使用 subprocess 的 Code Runtime 消费方随后会在共享远程沙箱中执行,无需 E2B 专用的功能包(package)。
|
||||
[`@deepseek-ai/dsh-subprocess`](../../subprocess/subprocess/README.md) seam 的 E2B 实现。它没有配置:先加载 [`@deepseek-ai/dsh-e2b`](../e2b/README.md),再用本服务取代 `dsh-subprocess-local`。现有的 Bash、PTY 和 LSP 消费方随后会在共享远程沙箱中执行,无需 E2B 专用的功能包(package)。
|
||||
|
||||
## 行为
|
||||
|
||||
|
||||
@@ -31,17 +31,9 @@ export class E2BSubprocessService extends SubprocessService {
|
||||
private readonly terminalSetups = new Map<Promise<void>, AbortController>()
|
||||
private disposing = false
|
||||
|
||||
/** @inheritdoc */
|
||||
readonly cwd: string
|
||||
|
||||
/** @inheritdoc */
|
||||
readonly runtimeRoot: string
|
||||
|
||||
/** Create the E2B subprocess service and bind its disposal policy. */
|
||||
constructor(ctx: Context) {
|
||||
super(ctx)
|
||||
this.cwd = ctx.e2b.cwd
|
||||
this.runtimeRoot = ctx.e2b.runtimeRoot
|
||||
ctx.effect(() => async () => {
|
||||
this.disposing = true
|
||||
for (const controller of this.terminalSetups.values()) {
|
||||
@@ -89,14 +81,14 @@ export class E2BSubprocessService extends SubprocessService {
|
||||
const prefix = path === undefined ? '' : `PATH=${quoteE2BShellArg(path)} `
|
||||
const result = await sandbox.commands.run(
|
||||
`${prefix}command -v -- ${quoteE2BShellArg(command)}`,
|
||||
{ cwd: this.cwd, envs: e2bControlEnvs(), ...signalOpts(signal) },
|
||||
{ cwd: this.ctx.e2b.cwd, envs: e2bControlEnvs(), ...signalOpts(signal) },
|
||||
)
|
||||
signal?.throwIfAborted()
|
||||
const executable = result.stdout.trim()
|
||||
if (executable.includes('\n') || (!posix.isAbsolute(executable) && !executable.includes('/'))) {
|
||||
throw new Error(`subprocess-e2b: executable ${JSON.stringify(command)} did not resolve to one absolute path`)
|
||||
}
|
||||
return posix.resolve(this.cwd, executable)
|
||||
return posix.resolve(this.ctx.e2b.cwd, executable)
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
@@ -138,7 +130,7 @@ export class E2BSubprocessService extends SubprocessService {
|
||||
}
|
||||
}
|
||||
spec.signal?.throwIfAborted()
|
||||
const stateDir = posix.join(this.runtimeRoot, 'terminals', randomUUID())
|
||||
const stateDir = posix.join(this.ctx.e2b.runtimeRoot, 'terminals', randomUUID())
|
||||
const setup = Promise.withResolvers<void>()
|
||||
const setupController = new AbortController()
|
||||
const setupSignal = spec.signal === undefined
|
||||
|
||||
@@ -775,10 +775,8 @@ describe('E2B subprocess terminal service', () => {
|
||||
return { ctx, fiber, fake }
|
||||
}
|
||||
|
||||
it('publishes execution-world coordinates and resolves remote executables', async () => {
|
||||
it('resolves remote executables', async () => {
|
||||
const { ctx, fake } = await service()
|
||||
expect(ctx.subprocess.cwd).toBe('/workspace')
|
||||
expect(ctx.subprocess.runtimeRoot).toBe('/workspace/.dsh-e2b')
|
||||
await expect(ctx.subprocess.resolveExecutable('/bin/bash')).resolves.toBe('/bin/bash')
|
||||
await expect(ctx.subprocess.resolveExecutable('node', { PATH: '/custom/bin' }, new AbortController().signal))
|
||||
.resolves.toBe('/usr/bin/node')
|
||||
|
||||
Reference in New Issue
Block a user