今天有两个有趣的新产品用于在沙箱中运行代码。
Cloudflare 推出了其容器产品的公开测试版,并为 Cloudflare Workers 添加了一个新的沙盒库,可以在“安全的基于容器的环境”中运行命令:
从“@cloudflare/sandbox”导入{ getSandbox } ; const sandbox = getSandbox ( env . Sandbox , "my-sandbox" ) ; const输出=沙盒. exec ( "ls" , [ "-la" ] ) ;
Vercel 发布了类似的功能,该功能在使用 Vercel Sandbox 运行不受信任的代码中引入,它支持如下所示的代码:
从“@vercel/sandbox”导入{ Sandbox } ; const sandbox = await Sandbox.create ( ) ; 等待沙盒.writeFiles ( [ {路径: “ script.js” ,流: Buffer.from (结果.文本) } , ] ) ; 等待沙盒.runCommand ( { cmd : “节点” , 参数: [ “script.js” ] , stdout :进程.stdout , stderr :进程.stderr , } ) ;
在这两种情况下,主要的预期用例是安全地执行由 LLM 创建的代码。
标签: vercel 、 cloudflare 、 generative-ai 、 ai 、 llms 、沙盒
原文: https://simonwillison.net/2025/Jun/26/sandboxes/#atom-everything