=======================================================
Mastra + Declaw Sandbox Example
=======================================================
No OPENAI_API_KEY found -- running demo mode.
--- Tool Definition ---
const executePython = createTool({
id: 'execute-python',
description: 'Execute Python code in a secure Declaw sandbox',
inputSchema: z.object({ code: z.string() }),
execute: async ({ context }) => {
const sbx = await Sandbox.create({ template: 'python', timeout: 300 });
...
},
});
--- Running Code Directly in Declaw Sandbox ---
Code:
a, b = 0, 1
fibs = []
for _ in range(15):
fibs.append(a)
a, b = b, a + b
print("Fibonacci:", fibs)
stdout: Fibonacci: [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377]
stderr:
exitCode: 0
Sandbox cleaned up.
=======================================================
Done!
=======================================================