You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{Agent,E2BSandbox}from'@shareai-lab/kode-sdk';import{createRuntime}from'./shared/runtime';constsandbox=newE2BSandbox({template: 'base',timeoutMs: 600_000,});awaitsandbox.init();constdeps=createRuntime(({ templates, registerBuiltin })=>{registerBuiltin('fs','bash','todo');templates.register({id: 'coder',systemPrompt: 'You are a coding assistant.',tools: ['bash_run','fs_read','fs_write','todo_read','todo_write'],});});constagent=awaitAgent.create({templateId: 'coder', sandbox },deps);awaitagent.send('Write and run a Python fibonacci script');
Sandbox Lifecycle Binding
Agent Start: Call sandbox.init() before Agent.create()
Agent Pause: Sandbox persists (use sandboxId to reconnect)
Agent Resume: Pass sandboxId to reconnect to existing sandbox
Agent Destroy: Call sandbox.dispose() to terminate
Resume / Fork with Persistent sandboxId
// First run - createconstsandbox=newE2BSandbox({template: 'base'});awaitsandbox.init();constid=sandbox.getSandboxId();// persist this// Later - resumeconstrestored=newE2BSandbox({sandboxId: id});awaitrestored.init();// Same sandbox environment is available