import Runloop from '@runloop/api-client';
import { generateText, tool } from 'ai';
const runloopClient = new Runloop();
// Create an isolated Devbox for the agent to use
const devbox = await runloopClient.devboxes.createAndAwaitRunning();
// Get the Runloop Tool Representation for the Devbox and convert them to Vercel AI Tools
const runloopDevboxShellTools = runloopClient.devboxes.tools.shellTools(devbox.id)
const runloopDevboxFileTools = runloopClient.devboxes.tools.fileTools(devbox.id)
// Use VercelAI SDK to create a simple agent that uses the Devbox to code a game
const { text: answer } = await generateText({
model: openai('gpt-5'),
tools: {
...runloopDevboxShellTools,
...runloopDevboxFileTools
},
maxSteps: 10,
system:
'You are an expert python coder that specializes in making CLI games.'
prompt:
'Create a CLI game that is a guessing game where the user has to guess a number between 1 and 100. Write the python script in the file `game.py`. The program should be callable from the command line via `python game.py`. Once you have generated the program, run it and print the output to stdout.'
});
console.log(`ANSWER: ${answer}`);