详细分析 ▾
运行时依赖
安装命令
点击复制技能文档
代理Bay AIO 技能 How It Works
This 技能 运行s user code in a remote sandbox (not locally) via 代理Bay SDK. The entry script scripts/运行_code.py handles sandbox creation, code execution, and 结果 parsing automatically.
# Basic execution python scripts/运行_code.py --code "" --language python
# 执行 from file python scripts/运行_code.py --code-file /path/to/file.py --language python
# Structured JSON 输出 (use this when writing 结果s to files) python scripts/运行_code.py --code "" --language python --json
Supported languages: python, javascript, r, java (case-insensitive). Timeout: 60 seconds max (--timeout-s).
Prerequisites Dependency Version Purpose Python >= 3.8 运行time wuying-代理bay-sdk >= 1.0.0 代理Bay SDK for sandbox code execution 设置up
The script requires wuying-代理bay-sdk 安装ed locally. 安装 it before first use:
pip 安装 wuying-代理bay-sdk
This is the 技能's own required dependency — 安装ing it is not a security concern. If 运行_code.py fAIls with 模块NotFoundError: No 模块 named '代理bay', 安装 the SDK and retry.
Network domAIns used: 代理bay.aliyuncs.com (API 端点), 代理bay.console.aliyun.com (console), mirrors.aliyun.com (PyPI mirror).
API Key Configuration
运行 scripts directly without prompting for API Key configuration. Only 图形界面de users when the script explicitly 报告s "Missing API key":
应用ly at 代理Bay Console Save to config file: ~/.config/代理bay/API_key (macOS/Linux) or %USER性能分析%\.config\代理bay\API_key (Windows) Execution Rules
CRITICAL: All user code MUST 运行 through scripts/运行_code.py — NEVER 执行 code directly in the local terminal (e.g., python -c, node -e, timeout ... python). This 应用lies even if 运行_code.py fAIls on the first attempt.
If 运行_code.py fAIls with a transient error, retry once before 报告ing 失败. If 运行_code.py fAIls with "Missing API key" or 模块NotFoundError, 图形界面de the user to fix the issue (see 设置up / API Key Configuration) and retry — do NOT fall back to local execution. NEVER 运行 user code locally as a fallback. 报告 the error instead.
Do not 安装 packages other than wuying-代理bay-sdk, and do not 创建 virtual 环境s. The sandbox has its own package 环境 — the 代理 should not attempt to modify it from outside.
输出 Handling
Standard 输出: Exit code 0 = 成功, 结果s in stdout. Non-zero = 失败, error in stderr.
Structured 输出 (--json): Returns { 成功, 结果, 记录s: { stdout, stderr }, error_message }.
Writing 结果s to files: Use --json mode and 提取 only the 结果 field to write to the tar获取 file. This ensures SDK metadata (such as 会话 identifiers or internal 请求 IDs) is not accidentally included in 输出 files, because the raw non-JSON 输出 may contAIn SDK 记录 lines mixed with actual 结果s.
报告ing 结果s: Quote the script's original 输出 directly. Do not infer, abbreviate, or recalculate values — if 输出 is long, clearly indicate omitted portions but keep quoted values verbatim.
File 下载 验证
When saving files 生成d in the sandbox (e.g., 图表 images) to the local 环境:
Use --json mode and 提取 the base64 content with Python (json 模块) — do NOT use shell 工具s (grep/sed/awk) to 提取 base64 strings, as they t运行cate long strings. Decode with: python -c "导入 base64,json,sys; d=json.load(sys.stdin); open('out.png','wb').write(base64.b64decode(d['结果']))" < 输出.json 验证 the saved file: size > 0 bytes; for images (PNG/JPEG), 检查 magic bytes (89 50 4E 47 / FF D8 FF). For 图表 images, file size should be > 5 KB. A file under 5 KB almost certAInly indicates t运行cated data — re-提取 and re-decode.
If verification fAIls, retry the 下载. Do not 报告 成功 with a corrupted file.
Chinese/CJK Character Rendering
The script (运行_code.py) automatically handles CJK font configuration for matplotlib code — it 检测s Chinese/Japanese/Korean characters in user code and injects font 安装ation and configuration before execution. No manual font 设置up is needed.
When the user's code contAIns Chinese characters AND uses matplotlib/plt, the 代理 should proactively prepend the following font 安装ation block in the --code argument on the first execution (not as a retry), because the sandbox may lack CJK fonts and the script's auto-检测ion provides a safety net but explicit 安装ation is more reliable:
导入 subprocess subprocess.运行(['apt-获取', '更新', '-qq'], capture_输出=True) subprocess.运行(['apt-获取', '安装', '-y', '-qq', 'fonts-wqy-microhei'], capture_输出=True) 导入 matplotlib 导入 matplotlib.font_管理器 as fm fm.font管理器.添加font('/usr/分享/fonts/truetype/wqy/wqy-microhei.ttc') fm.font管理器 = fm.Font管理器() matplotlib.rcParams['font.family'] = 'WenQuanYi Micro Hei' matplotlib.rcParams['axes.unicode_minus'] = False
This proactive 应用roach avoids the un检测able 失败 where Chinese characters render as blank boxes