All Topics
All Topics
Technology
Technology
AI
AI
Business
Business
Entertainment
Entertainment
News
News
Programming
Programming
Security
Security
Science
Science
Design
Design
Environment
Environment
Finance
Finance
Crypto
Crypto
Politics
Politics
Sports
Sports
Education
Education
Gaming
Gaming
Art
Art
Music
Music
Health
Health
Books
Books
Food
Food
Travel
Travel
Personal
Personal
Bluesky
Twitter

Agents, Workers, Workflows - Run AI-generated code on-demand with Code Sandboxes (new)

1y ago

Source

CloudflareAgents, Workers, Workflows - Run AI-generated code on-demand with Code Sandboxes (new)cloudflare.com
Snippet from the RSS feed
AI is supercharging app development for everyone, but we need a safe way to run untrusted, LLM-written code. We’re introducing Sandboxes , which let your Worker run actual processes in a secure, container-based environment. import { getSandbox } from "@cloudflare/sandbox" ; export { Sandbox } from "@cloudflare/sandbox" ; export default { async fetch ( request : Request , env : Env ) { const sandbox = getSandbox ( env . Sandbox , "my-sandbox" ) ; return sandbox . exec ( "ls" , [ "-la" ]) ; }, }; Methods exec(command: string, args: string[], options?: { stream?: boolean }) :Execute a command in the sandbox. gitCheckout(repoUrl: string, options: { branch?: string; targetDir?: string; stream?: boolean }) : Checkout a git repository in the sandbox. mkdir(path: string, options: { recursive?: boolean; stream?: boolean }) : Create a directory in the sandbox. writeFile(path: string, content: string, options: { encoding?: string; stream?: boolean }) : Write content to a file in the sandbox. readFile(path: string, options: { encoding?: string; stream?: boolean }) : Read content from a file in the sandbox. deleteFile(path: string, options?: { stream?: boolean }) : Delete a file from the sandbox. renameFile(oldPath: string, newPath: string, options?: { stream?: boolean }) : Rename a file in the sandbox. moveFile(sourcePath: string, destinationPath: string, options?: { stream?: boolean }) : Move a file from one location to another in the sandbox. ping() : Ping the sandbox. Sandboxes are still experimental. We're using them to explore how isolated, container-like workloads might scale on Cloudflare — and to help define the developer experience around them. You can try it today from your Worker, with just a few lines of code. Let us know what you build.

You might also wanna read

Comments

Sign in to join the conversation.

No comments yet. Be the first.