refactor(e2b): compose portable runtime consumers

This commit is contained in:
Tianyi Cui
2026-08-08 22:19:11 +08:00
parent 97496c3d00
commit 2abc9823e7
64 changed files with 1426 additions and 4229 deletions
@@ -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/code-runtime/code-runtime-worker/README.md
README.md: 4b14c6fad5d1e491faeb54c9cb0e4403c8e2d8dd
README.zh.md: c522917835b562cf7648d8bc78f0315b7c52d2d2
README.md: 35196a0b4fba5cd0388246a70354308ece08b39f
README.zh.md: 49871c38c540addd06f5d24793ae00b45e2f8bb0
@@ -46,7 +46,7 @@ No direct invalidation; the named consumer owns any request-prefix changes.
## Known Limitations and Deferred Work
- **OS processes a program spawns survive this backend's termination** — `worker.terminate()` ends only the thread; deployments needing remote process-group cleanup can select the E2B backend, whose separate limitations still apply.
- **OS processes a program spawns survive termination** — `worker.terminate()` ends the thread only; deployments requiring process-tree cleanup select `dsh-code-runtime-subprocess`, whose mounted subprocess provider owns that cleanup.
- **Type-strip rides Node's experimental `stripTypeScriptTypes` API** — the relied-on behavior is pinned by unit tests, with amaro/sucrase as named drop-in replacements if it shifts.
- **`computeMs` expiry can overshoot by up to one poll interval** — busy time is sampled every 25 ms (an internal constant, deliberately not config).
- **Programs get a five-method `console` shim** (`log`/`info`/`warn`/`error`/`debug`) — deliberately not Node's full console surface.
@@ -46,7 +46,7 @@ SDK 接口是默认/具名 `WorkerCodeRuntime` 类与 `Config`。可操作的
## 已知限制与暂缓工作
- **程序 spawn 的 OS 进程在该后端终止后仍会存活**`worker.terminate()` 只结束线程;需要清理远程进程的部署可以选择 E2B 后端,但该后端自身的限制仍然适用
- **程序 spawn 的 OS 进程在终止后仍会存活**:`worker.terminate()` 只结束线程;需要清理进程的部署选择 `dsh-code-runtime-subprocess`,由其挂载的子进程提供方负责该清理
- **类型剥离依赖 Node 的实验性 `stripTypeScriptTypes` API**:依赖的行为由单元测试固定;如其发生变化,amaro/sucrase 是已经点名的直接替代品。
- **`computeMs` 到期最多可能超过一个轮询间隔**:系统每 25 ms 采样一次忙碌时间(内部常量,有意不做成配置)。
- **程序获得一个含 5 种方法的 `console` shim**`log``info``warn``error``debug`):有意不提供 Node 的完整 console 接口。