SuperAPI AI 工具集

agentbay-aio-skills

编程与开发

查看项目

更新于 10-15 19:51

技能介绍

用途:当用户要求运行、执行或评估代码(如 run this code、执行脚本、用 Python 画图、查看代码输出)时使用本技能,即使用户未提“沙箱”。

主要能力:通过 AgentBay SDK 以 code_latest 镜像创建会话,在沙箱中调用 run_code 执行代码,解析 EnhancedCodeExecutionResult 并销毁会话。支持语言为 python、javascript、r、java(不区分大小写)。

使用方式:依赖 wuying-agentbay-sdk 包。建议在技能目录下使用独立虚拟环境,避免污染用户项目环境: if [ ! -d ".venv" ]; then python3 -m venv .venv; fi source .venv/bin/activate pip show wuying-agentbay-sdk >/dev/null 2>&1 || pip install wuying-agentbay-sdk -i https://mirrors.aliyun.com/pypi/simple/ 执行代码: python scripts/run_code.py --code "..." --language python 从文件执行: python scripts/run_code.py --code-file /path/to/file.py --language python 需要结构化输出时加 --json。脚本从配置文件或环境变量读取 API Key。

API Key:默认直接执行,不要每次提醒配置。仅当报错“Missing API key”或类似信息时,引导用户到 AgentBay 控制台申请,并写入配置文件:macOS/Linux 为 ~/.config/agentbay/api_key(或 $XDG_CONFIG_HOME/agentbay/api_key),Windows 为 %USERPROFILE%.config\agentbay\api_key(无扩展名文件),完成后重试。

输出:成功时 exit code 0,结果在 stdout;加 --json 输出 success、result、logs、error_message。失败时 exit code 非 0,错误在 stderr。

限制:单次执行超时 60 秒,可用 --timeout-s 指定且不超过 60。本技能可用时不要在本地终端执行用户代码,应使用沙箱以保证隔离与行为一致。