Hacker News 中文摘要

RSS订阅

Just-bash:代理专用Bash -- Just-bash: Bash for Agents

文章摘要

just-bash是一个用TypeScript编写的模拟bash环境,提供内存虚拟文件系统,专为AI代理设计,提供安全沙盒环境。支持通过curl进行可选网络访问并默认启用URL过滤。目前处于测试阶段,使用需谨慎。

文章总结

项目名称:just-bash —— 专为AI代理设计的Bash沙箱环境

核心功能: 1. 安全沙箱 - 基于TypeScript构建的内存虚拟文件系统 - 默认禁用网络访问(可配置URL前缀白名单) - 提供执行保护机制(防止无限循环/递归)

  1. 多场景适配
  • 支持四种文件系统:
    • InMemoryFs(纯内存)
    • OverlayFs(磁盘只读+内存写入)
    • ReadWriteFs(真实磁盘读写)
    • MountableFs(多文件系统挂载)
  • 兼容Vercel Sandbox API
  • 提供CLI工具和交互式Shell
  1. 扩展能力
  • 支持自定义TypeScript命令
  • 可选Python(Pyodide)和SQLite支持
  • AST转换插件系统(支持脚本分析与改造)

安全特性: - 网络访问需显式启用,默认仅允许GET/HEAD方法 - 执行限制:递归深度≤100,命令总数≤10,000等 - 不支持二进制/WASM执行

典型应用: 1. AI代理开发 - 通过bash-tool工具集成AI SDK - 示例:处理JSON数据、执行Python脚本

  1. 安全脚本测试
  • CLI模式:just-bash -c 'grep -r "TODO" src/'
  • 支持JSON输出格式

开发状态: - Beta版软件(Apache-2.0协议) - 提供完整测试套件和类型检查

注意:浏览器环境下Python/SQLite功能不可用,网络访问需谨慎配置白名单。

评论总结

以下是评论内容的总结:

  1. 对Bash兼容性的担忧

    • gaigalas指出Bash的稳定性是其优势,但重实现Bash是巨大挑战:"Re-implementing bash is a herculean effort"
    • pdp认为工具兼容性很重要,否则会出现奇怪行为:"make the tools compatible with the official tools otherwise you will get odd behaviour"
  2. 替代方案建议

    • IceWreck提议使用Python/TypeScript等受限子集:"why not make the agents use a restricted subset of python, typescript or lua"
    • agartner推荐Go语言实现方案:"If anyone is looking to make a similar thing in go I suggest..."
  3. 性能与实现质疑

    • RobertLong质疑JS实现的性能:"isn't this incredibly slow compared to native cli tools?"
    • throwaway13337认为这可能是"far too leaky abstraction"
  4. 扩展与创新应用

    • huntaub介绍了与S3集成的方案:"allows users to attach a full Archil file system, synced to S3"
    • jeffchuber展示了多后端支持项目:"puts a bash interface in front of s3, filesystem...postgres, and chroma"
  5. 命名与设计批评

    • dostick批评命名方式:"Why couldn't they name it agent-bash then?"
    • Lerc分享了自己的非兼容性设计:"Deliberately not having /lib /share and /etc"
  6. 安全与隔离建议

    • CuriouslyC建议关注沙箱隔离:"easier to focus on isolating the sandbox"
    • jpitz提出使用jail的疑问:"why wouldn't you attack this with a jail?"
  7. 相关项目展示

    • rbbydotdev分享虚拟化经验:"Virtualizing os primitives like bash and even file systems"
    • rob提供了Web UI链接:"Web UI for it: https://justbash.dev"