Environment 结构

更新时间:
复制 MD 格式

Environment 对象和配置字段结构。

Environment 对象

创建、获取、列表、更新和归档接口都会返回 Environment 对象。

字段

类型

说明

id

string

Environment 唯一标识,前缀为 env_

type

string

固定值 "environment"

name

string

Environment 显示名称

description

string | null

自然语言描述

config

object

Environment 配置。见 Environment config

metadata

object

自定义键值对。最多 16 对,key ≤ 64 字符,value ≤ 512 字符

archived_at

string | null

归档时间(ISO 8601);未归档时为 null

created_at

string

创建时间(ISO 8601)

updated_at

string

最后更新时间(ISO 8601)

Environment config

字段

类型

必填

说明

type

string

配置类型。可选值:managed(托管)、self_hosted(自托管)

networking

object | null

网络访问策略。仅 managed 类型可用。见 Environment networking

packages

object | null

预装包配置。仅 managed 类型可用。见 Environment packages

setup_script

string | null

初始化脚本。仅 managed 类型可用。见 Environment setup script

自托管类型的 config 必须为 {"type":"self_hosted"},不支持 networking、packages 和 setup_script 字段。

{
  "type": "self_hosted"
}

Environment packages

key

类型

说明

示例

type

string

固定值 "packages"

"packages"

apt

array | null

APT 系统包名称列表

["ffmpeg", "imagemagick"]

npm

array | null

全局安装的 npm 包列表

["typescript", "prettier"]

pip

array | null

全局安装的 pip 包列表

["pandas", "numpy"]

Environment setup script

setup_script 是在 Environment 初始化阶段执行的 shell 脚本。

约束

类型

string

最大长度

10,000 字符

解释器

bash

超时

10 分钟

执行时机

容器启动后、Agent 执行前

脚本在容器内以 root 身份执行。若脚本以非零退出码结束,Session 将进入 failed 状态。

脚本的 stdout/stderr 不会暴露给 Agent,只记录在平台日志中,用于调试。

#!/bin/bash
set -e
apt-get update && apt-get install -y jq
pip install requests
echo "Setup complete"

Environment networking

字段

类型

必填

说明

type

string

固定值 "networking"

allowed_hosts

array | null

允许访问的域名白名单。为 null 时允许所有出站连接

allow_package_managers

boolean

是否允许 Agent 运行时动态安装包。默认 true

allow_mcp_servers

boolean

是否允许 Agent 连接 MCP servers。默认 true