Skip to content

Commit c69f08b

Browse files
committed
starter deno agent
1 parent 2d5727d commit c69f08b

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed

packages/deno-agent/deno.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"dev": "deno run --watch main.ts"
44
},
55
"imports": {
6-
"@std/assert": "jsr:@std/assert@1"
6+
"@std/assert": "jsr:@std/assert@1",
7+
"@std/dotenv": "jsr:@std/[email protected]",
8+
"@deno/sandbox": "jsr:@deno/[email protected]"
79
}
810
}

packages/deno-agent/main.ts

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,23 @@
1-
export function add(a: number, b: number): number {
2-
return a + b;
3-
}
4-
5-
// Learn more at https://docs.deno.com/runtime/manual/examples/module_metadata#concepts
6-
if (import.meta.main) {
7-
console.log("Add 2 + 3 =", add(2, 3));
8-
}
1+
// %%
2+
import { Sandbox } from "@deno/sandbox";
3+
import "@std/dotenv/load";
4+
5+
// %%
6+
await using sandbox = await Sandbox.create();
7+
8+
// %%
9+
const result = await sandbox.eval(`1 + 2`);
10+
console.log("result:", result);
11+
12+
// %%
13+
let repl = await sandbox.repl();
14+
15+
// %%
16+
await repl.eval(`5`);
17+
18+
// %%
19+
const result2 = await sandbox.eval(`5`);
20+
console.log("result:", result2);
21+
22+
// %%
23+
await sandbox.close();

0 commit comments

Comments
 (0)