Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion packages/core/tests/execution-api-redesign.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe("execution API redesign", () => {
let vm: AgentOs;

beforeAll(async () => {
vm = await AgentOs.create();
vm = await AgentOs.create({ defaultSoftware: false });
}, 30_000);

afterAll(async () => {
Expand Down Expand Up @@ -51,6 +51,39 @@ describe("execution API redesign", () => {
});
}, 30_000);

test("runs every Secure Exec resident-runner source unchanged", async () => {
const contextId = "secure-exec-resident-cases";
await vm.createContext(contextId);
try {
const cases = [
["1 + 1", ""],
["globalThis.x = 1", ""],
['console.log("A")', "A\n"],
['process.stdout.write("B")', "B"],
["export const y = 1;", ""],
] as const;

for (const [source, expectedStdout] of cases) {
const result = await vm.javascript.execute(source, {
contextId,
timeoutMs: 10_000,
output: { capture: "all" },
});
expect(result, source).toMatchObject({
outcome: "succeeded",
exitCode: 0,
stdout: expectedStdout,
});
}

expect(
await vm.javascript.evaluate("globalThis.x", { contextId }),
).toMatchObject({ outcome: "succeeded", value: 1 });
} finally {
await vm.contexts.delete(contextId);
}
}, 30_000);

test("returns a PID for spawned language work and controls it through process", async () => {
const process = await vm.javascript.spawn("console.log('spawned')", {
output: { retainEvents: true },
Expand Down