Use case
Verify that an agent can author and run TypeScript code end to end: write sources, install deps, compile, start a long-running server, smoke-test it with curl — all inside a Node 20 sandbox.Template
node — Node 20, npm, TypeScript, tsc on PATH. No pip, no Python.
Run it
Security policy
127.0.0.1 inside the VM and
is only reachable with curl from within the same sandbox —
outbound network policy doesn’t need to allow it because nothing
outside the VM is trying to reach it.
Env isolation
server.ts reads both from process.env, so
rotating the port or service name is a client-side config change,
not a prompt rewrite.
What the agent does
mkdir -p /workspace/api && cd /workspace/api.- Write
server.tsreadingprocess.env.API_PORTandprocess.env.SERVICE_NAME. npm init -y && npm i express && npm i -D typescript @types/node @types/express.npx tscto compile.- Start the server in background:
node server.js >server.log 2>&1 &. sleep 1 && curl http://127.0.0.1:$API_PORT/health.- Return the JSON plus
tail -n 10 server.log.
Why background processes matter
session._inner._sbx.run_command("... &") returns when the shell
forks — the server keeps running in the sandbox. The same session
can then hit it with a second run_command("curl ..."). This is
the same pattern you’d use for testing any long-running service
(databases, workers, APIs) against an agent-driven client.
Full source
Seecookbook/openai_agents_typescript_api.py in the repo.