refactor(core): migrate to Bun and converge acquisition policies and Agent boundaries

This commit is contained in:
root committed 2026-10-13 14:37:03 +08:00
1 parent 3f1c6d02f6
commit 27c0f27434
268 files changed
+7468 -7852

No files matched your search

+23 -1
View File
@@ -16,13 +16,34 @@ describe("沙箱子进程", () => {
it("正常返回;子进程里读文件被拒绝", async () => {
expect(await runSandbox("self.test", { mode: "ok" })).toEqual({ ok: true });
await expect(runSandbox("self.test", { mode: "io" })).rejects.toMatchObject({ kind: "job", message: /NotCapable/ });
await expect(runSandbox("self.test", { mode: "io" })).rejects.toMatchObject({
kind: "job",
message: /EPERM|operation not permitted/i,
});
});
it("不继承父进程密钥,也不自动读取 dotenv", async () => {
process.env.UMT_SANDBOX_TEST_SECRET = "private";
try {
const result = await runSandbox("self.test", { mode: "env" });
expect(result).toEqual({ keys: ["PATH"] });
} finally {
delete process.env.UMT_SANDBOX_TEST_SECRET;
}
});
it.each(["async-io", "write", "net", "exec"] as const)("内核拒绝 %s,包括运行时工作线程", async (mode) => {
await expect(runSandbox("self.test", { mode })).rejects.toMatchObject({
kind: "job",
message: /EPERM|operation not permitted/i,
});
});
it("卡死:超时后强杀,不拖住调用方", async () => {
const t0 = Date.now();
const e = await runSandbox("self.test", { mode: "hang" }, { timeoutMs: 800 }).catch((x) => x);
expect(e).toBeInstanceOf(SandboxError);
if (!(e instanceof SandboxError)) throw e;
expect(e.kind).toBe("timeout");
expect(Date.now() - t0).toBeLessThan(5000);
});
@@ -30,6 +51,7 @@ describe("沙箱子进程", () => {
it("吃内存:超过上限强杀", async () => {
const e = await runSandbox("self.test", { mode: "memory" }, { memoryMb: 128, timeoutMs: 20_000 }).catch((x) => x);
expect(e).toBeInstanceOf(SandboxError);
if (!(e instanceof SandboxError)) throw e;
expect(e.kind).toBe("memory");
});