mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-15 08:03:46 +00:00
fix(examples): pass API keys to E2B sandbox and improve session end handling
This commit is contained in:
parent
8af152f0b3
commit
fa89872d3b
2 changed files with 20 additions and 2 deletions
|
|
@ -6,7 +6,11 @@ if (!process.env.E2B_API_KEY || (!process.env.OPENAI_API_KEY && !process.env.ANT
|
|||
throw new Error("E2B_API_KEY and (OPENAI_API_KEY or ANTHROPIC_API_KEY) required");
|
||||
}
|
||||
|
||||
const sandbox = await Sandbox.create({ allowInternetAccess: true });
|
||||
const envs: Record<string, string> = {};
|
||||
if (process.env.ANTHROPIC_API_KEY) envs.ANTHROPIC_API_KEY = process.env.ANTHROPIC_API_KEY;
|
||||
if (process.env.OPENAI_API_KEY) envs.OPENAI_API_KEY = process.env.OPENAI_API_KEY;
|
||||
|
||||
const sandbox = await Sandbox.create({ allowInternetAccess: true, envs });
|
||||
|
||||
const run = (cmd: string) => sandbox.commands.run(cmd);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue