沙箱观测 (0.1.3)

Download OpenAPI specification:

沙箱运行时的只读观测面:健康、会话池、会话列表与详情。Studio 的沙箱运行时页 就是靠这四个接口渲染的。

只读——这里没有创建、终止、清理会话的接口。会话由函数执行按需申请与释放, 见 function.yaml

仅超管可见。这四条接口原本只在内部面 internal-v1 上,而内部面不校验令牌、 身份取自调用方自填的 X-Account-ID 头;为了让 Studio 能访问才开到公开面, 公开面走令牌校验拿到真实身份后,再叠一道超管判定收口(见 #326)。非超管调用 返回 403。

认证Authorization: Bearer <token>(OAuth access token 或 bak_ 前缀的 AppKey)。

Sandbox

沙箱健康状态

一眼看清沙箱能不能用:控制面是否可达、会话上限与当前占用、失败会话数。

status 不健康时 message 会带原因;控制面不可达(control_plane_reachablefalse)意味着所有函数执行都会失败,先查沙箱控制面而不是查调用方代码。

Authorizations:
OAuth2AppKey

Responses

Response samples

Content type
application/json
{
  • "status": "healthy",
  • "control_plane_reachable": true,
  • "checked_at": "2026-07-31T08:56:33Z",
  • "max_sessions": 3,
  • "current_active_sessions": 1,
  • "current_running_tasks": 0,
  • "failed_sessions": 0
}

会话池状态

会话池的容量、当前占用、所用模板与单会话资源规格,以及池内每个会话的简况。

max_concurrent_tasks 是全池并发任务上限,max_sessions 是会话数上限, 两者不是一回事:一个会话可以同时跑多个任务。

Authorizations:
OAuth2AppKey

Responses

Response samples

Content type
application/json
{
  • "max_sessions": 3,
  • "active_sessions": 1,
  • "max_concurrent_tasks": 100,
  • "current_active_sessions": 1,
  • "current_running_tasks": 0,
  • "template_id": "python-basic",
  • "session_resources": {
    },
  • "sessions": [
    ]
}

会话列表

列出沙箱会话,支持按状态、来源、运行时过滤。排障时先用 abnormal_only=true 收敛到异常会话,再用 GET /sandbox/sessions/{id} 看详情。

Authorizations:
OAuth2AppKey
query Parameters
limit
integer

分页大小。

offset
integer

分页偏移。

status
string (SessionStatus)
Enum: "creating" "running" "terminated" "failed"

按会话状态过滤。

source
string

按来源过滤。来源即执行时写进沙箱环境的 source,如 function_debug (调试执行)、function_proxy(按版本执行);取不到时记为 unknown

runtime
string

按语言运行时过滤,如 python3.11

abnormal_only
boolean

只看异常会话。

Responses

Response samples

Content type
application/json
{
  • "items": [
    ],
  • "total": 0,
  • "limit": 0,
  • "offset": 0,
  • "has_more": true
}

会话详情

单个会话的完整诊断信息:列表里的全部字段,外加工作空间路径、运行节点、 Pod 名、依赖安装的请求与实际结果及其起止时间。

三个 *_available / *_redacted 布尔位说明这套接口的能力边界: 完整 stdout/stderr 与治理动作(终止 / 清理会话)当前不由本接口提供, 敏感诊断信息是否已脱敏也在这里标明。

Authorizations:
OAuth2AppKey
path Parameters
id
required
string

会话 ID。

Responses

Response samples

Content type
application/json
{
  • "id": "string",
  • "status": "creating",
  • "source": "string",
  • "task_id": "string",
  • "capability_id": "string",
  • "capability_name": "string",
  • "user_id": "string",
  • "user_name": "string",
  • "template_id": "string",
  • "runtime_type": "string",
  • "language_runtime": "string",
  • "resource_limit": { },
  • "dependency_install_status": "string",
  • "recent_error_summary": "string",
  • "created_at": "string",
  • "updated_at": "string",
  • "last_activity_at": "string",
  • "workspace_path": "string",
  • "runtime_node": "string",
  • "pod_name": "string",
  • "timeout": 0,
  • "python_package_index_url": "string",
  • "requested_dependencies": [
    ],
  • "installed_dependencies": [
    ],
  • "dependency_install_started_at": "string",
  • "dependency_install_completed_at": "string",
  • "full_stdout_stderr_available": true,
  • "governance_actions_available": true,
  • "sensitive_diagnostics_redacted": true
}