更新浏览器 Stream 状态 - UpdateBrowserStream
功能介绍
该 API 用于更新浏览器会话的 Stream 状态。主要用于人工接管场景:
-
设置 automation_stream.stream_status 为 disabled:断开所有已有 automation WebSocket 连接,拒绝新的 automation 连接和 invoke 请求(返回 403 "Stream is disabled for this session")。
-
设置 automation_stream.stream_status 为 enabled:恢复 automation 连接和 invoke 请求。
LiveView 是纯观看通道,不受此 API 影响。
调用方法
请参见如何调用API。
授权信息
当前API调用无需身份策略权限。
URI
PUT https://agentarts.com/v1/browsers/{browser_name}/streams-update
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| browser_name | 是 | String | 参数解释: 与会话关联的浏览器工具的唯一标识符。 浏览器工具名称获取方式: 1.进入 AgentArts 平台,在左侧导航栏选择"托管与运行 > 浏览器"。 2.在浏览器工具列表中"浏览器工具名称/ID"处获取名称。 约束限制: 不涉及。 取值范围: 不涉及。 默认取值: 不涉及。 |
请求参数
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| Authorization | 是 | String | 参数解释: 本次智能体工具调用对应的身份认证凭据。需要根据实际的智能体工具的入站身份认证方式获取对应的身份认证凭据。 API Key认证、IAM认证及OAuth 2.0认证具体请参见认证鉴权。 约束限制: 不涉及。 取值范围: 1-4096个字符,由字母、数字及特殊字符组成。 默认取值: 不涉及。 |
| X-Hw-Agentarts-Browser-Session-Id | 是 | String | 参数解释: 要使用的浏览器会话的唯一标识符。 约束限制: 必须是通过 StartBrowserSession 创建的活跃会话。如果会话已过期或已停止,请求将失败。 取值范围: 符合正则:^[a-zA-Z0-9_-]+$。 默认取值: 不涉及。 |
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| stream_update | 是 | StreamUpdate object | 参数解释: Stream 更新内容 UNION。每次请求仅设置其中一个成员。当前仅支持 automationStreamUpdate。 约束限制: 不涉及。 取值范围: 不涉及。 默认取值: 不涉及。 |
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| automation_stream_update | 否 | AutomationStreamUpdate object | 参数解释: Automation 流状态更新。 约束限制: 不涉及。 取值范围: 不涉及。 默认取值: 不涉及。 |
响应参数
状态码:200
| 参数 | 参数类型 | 描述 |
|---|---|---|
| browser_name | String | 参数解释: 浏览器工具的名称。 取值范围: 长度1到64个字符。 |
| session_id | String | 参数解释: 浏览器会话的唯一标识符。 取值范围: 符合正则:^[a-zA-Z0-9_-]+$。 |
| streams | BrowserSessionStream object | 参数解释: 浏览器会话关联的流信息集合,包含 automation 控制流和 liveView 观看流。 取值范围: 不涉及。 |
| updated_at | String | 参数解释: Stream 状态更新时间(ISO 8601 格式)。 取值范围: ISO 8601日期时间格式字符串。 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| automation_stream | AutomationStream object | 参数解释: Automation 控制流配置。提供 CDP 协议双向通信通道,用于 Agent 程序化控制浏览器。 通过 UpdateBrowserStream API 可将 stream_status 切换为 disabled(人工接管), 此时已有连接被断开,新连接和 invoke 请求被拒绝(HTTP 403)。 设回 enabled 后恢复正常。 取值范围: 不涉及。 |
| live_view_stream | LiveViewStream object | 参数解释: LiveView 观看流配置。提供 RFB-over-WebSocket 实时画面流, 人工可通过 VNC 客户端观看并操作浏览器。 LiveView 是纯观看通道,连接不影响 automation/invoke 运行。 如需人工接管(禁用 automation),需通过 UpdateBrowserStream API 显式切换。 取值范围: 不涉及。 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| stream_endpoint | String | 参数解释: Automation 流的 WebSocket 端点 URL,用于建立 CDP 透传连接。 取值范围: 合法的 WSS URL。 |
| stream_status | String | 参数解释: Automation 流的当前状态。通过 UpdateBrowserStream API 切换。 取值范围: 新连接和 invoke 请求返回 403 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| stream_endpoint | String | 参数解释: LiveView 流的 WebSocket 端点 URL,用于建立 RFB 实时画面连接。 取值范围: 合法的 WSS URL。 |
状态码:400
| 参数 | 参数类型 | 描述 |
|---|---|---|
| error_code | String | 参数解释: 错误码。 取值范围: 满足正则规则 ^AgentArts.0402\d{4}$ |
| error_msg | String | 参数解释: 错误信息。 取值范围: 符合正则:^[a-zA-Z0-9\s一-鿿.,!?;:()'"-。,!?;:()]+$。 |
状态码:401
| 参数 | 参数类型 | 描述 |
|---|---|---|
| error_code | String | 参数解释: 错误码。 取值范围: 满足正则规则 ^AgentArts.0402\d{4}$ |
| error_msg | String | 参数解释: 错误信息。 取值范围: 符合正则:^[a-zA-Z0-9\s一-鿿.,!?;:()'"-。,!?;:()]+$。 |
状态码:403
| 参数 | 参数类型 | 描述 |
|---|---|---|
| error_code | String | 参数解释: 错误码。 取值范围: 满足正则规则 ^AgentArts.0402\d{4}$ |
| error_msg | String | 参数解释: 错误信息。 取值范围: 符合正则:^[a-zA-Z0-9\s一-鿿.,!?;:()'"-。,!?;:()]+$。 |
状态码:404
| 参数 | 参数类型 | 描述 |
|---|---|---|
| error_code | String | 参数解释: 错误码。 取值范围: 满足正则规则 ^AgentArts.0402\d{4}$ |
| error_msg | String | 参数解释: 错误信息。 取值范围: 符合正则:^[a-zA-Z0-9\s一-鿿.,!?;:()'"-。,!?;:()]+$。 |
状态码:409
| 参数 | 参数类型 | 描述 |
|---|---|---|
| error_code | String | 参数解释: 错误码。 取值范围: 满足正则规则 ^AgentArts.0402\d{4}$ |
| error_msg | String | 参数解释: 错误信息。 取值范围: 符合正则:^[a-zA-Z0-9\s一-鿿.,!?;:()'"-。,!?;:()]+$。 |
状态码:429
| 参数 | 参数类型 | 描述 |
|---|---|---|
| error_code | String | 参数解释: 错误码。 取值范围: 满足正则规则 ^AgentArts.0402\d{4}$ |
| error_msg | String | 参数解释: 错误信息。 取值范围: 符合正则:^[a-zA-Z0-9\s一-鿿.,!?;:()'"-。,!?;:()]+$。 |
状态码:500
| 参数 | 参数类型 | 描述 |
|---|---|---|
| error_code | String | 参数解释: 错误码。 取值范围: 满足正则规则 ^AgentArts.0402\d{4}$ |
| error_msg | String | 参数解释: 错误信息。 取值范围: 符合正则:^[a-zA-Z0-9\s一-鿿.,!?;:()'"-。,!?;:()]+$。 |
请求示例
/v1/browsers/my-browser/streams-update
{
"stream_update" : {
"automation_stream_update" : {
"stream_status" : "disabled"
}
}
} 响应示例
状态码:200
{
"browser_name" : "my-browser",
"session_id" : "sess-abc123",
"streams" : {
"automation_stream" : {
"stream_endpoint" : "wss://gateway.example.com/v1/browsers/browser-abc123/automation",
"stream_status" : "disabled"
},
"live_view_stream" : {
"stream_endpoint" : "wss://gateway.example.com/v1/browsers/browser-abc123/livestream"
}
},
"updated_at" : "2022-11-09 16:37:24"
} 状态码:400
{
"error_code" : "AgentArts.04020001",
"error_msg" : "Invalid parameter."
} 状态码:401
{
"error_code" : "AgentArts.04020002",
"error_msg" : "Authentication failed: invalid token"
} 状态码:403
{
"error_code" : "AgentArts.04020003",
"error_msg" : "Authentication failed: you have no permission."
} 状态码:404
{
"error_code" : "AgentArts.04020004",
"error_msg" : "Resource not found: session_id=sess-xxx"
} 状态码:409
{
"error_code" : "AgentArts.04020005",
"error_msg" : "Operation conflict: another invoke is in progress"
} 状态码:429
{
"error_code" : "AgentArts.04020006",
"error_msg" : "Request throttled: too many requests"
} 状态码:500
{
"error_code" : "AgentArts.04020000",
"error_msg" : "System error. Please retry."
} 状态码
| 状态码 | 描述 |
|---|---|
| 200 | OK |
| 400 | 请求参数错误 |
| 401 | 认证失败 |
| 403 | 权限不足 |
| 404 | 资源不存在 |
| 409 | 操作冲突 |
| 429 | 请求频率超限 |
| 500 | 内部系统错误 |
错误码
请参见错误码。