--- name: l1-shell-exec description: "L1 原子技能:安全沙盒执行 Python/Node.js/Shell 脚本片段,返回 stdout/stderr。" layer: 1 domain: tooling keywords: - shell - exec - python - node - script - run - code input_schema: "{ code: string, language: string }" output_schema: "{ stdout: string, stderr: string, exit_code: number }" --- # L1: Shell Exec(脚本执行原子技能) ## 能力 在本地环境中执行 Python、Node.js 或 Shell 脚本片段,返回标准输出和错误输出。 ## 使用方法 ### Python 脚本 ```bash python3 -c " # 用户的 Python 代码 print('hello') " ``` ### Node.js 脚本 ```bash node -e " // 用户的 JS 代码 console.log('hello'); " ``` ### Shell / Bash ```bash bash -c " # 用户的 Shell 命令 echo hello " ``` ### 带超时保护的执行 ```bash timeout 30 python3 -c "用户代码" ``` ## 输入 | 参数 | 类型 | 必填 | 说明 | |------|------|------|------| | code | string | ✅ | 要执行的代码片段 | | language | string | ✅ | `python` / `node` / `bash` | ## 输出 | 字段 | 说明 | |------|------| | stdout | 标准输出内容 | | stderr | 错误输出内容 | | exit_code | 退出码 (0=成功) | ## 安全约束 - 执行超时:30 秒 - 禁止执行以下操作: - `rm -rf /` 或类似的破坏性命令 - 访问 `/etc/passwd`、`/etc/shadow` 等敏感文件 - 向外发送用户凭据或 API Key - 建议使用 `timeout` 包装长时间运行的脚本 - 输出截取前 5000 字符