更新时间:2026-11-04 GMT+08:00
分享

执行浏览器操作 - InvokeBrowser

功能介绍

该 API 用于在浏览器 Session 中执行结构化操作,包括导航、鼠标点击/拖拽、

键盘输入、滚动、截图、获取页面信息、Tab 管理等。

请求体采用 UNION 结构(对齐 AWS BrowserAction),action 对象中每次仅设置一个成员。

同一 Session 内的 invoke 请求串行执行(session 级锁)。

坐标系为浏览器视口坐标,与截图像素一一对应。

当 automation_stream.stream_status 为 disabled(人工接管中)时,invoke 请求返回 403(Stream is disabled for this session)。

调用方法

请参见如何调用API。

授权信息

当前API调用无需身份策略权限。

URI

POST https://agentarts.com/v1/browsers/{browser_name}/invoke

表1 路径参数

参数

是否必选

参数类型

描述

browser_name

是

String

参数解释:

与会话关联的浏览器工具的唯一标识符。

浏览器工具名称获取方式:

1.进入 AgentArts 平台,在左侧导航栏选择"托管与运行 > 浏览器"。

2.在浏览器工具列表中"浏览器工具名称/ID"处获取名称。

约束限制:

不涉及。

取值范围:

不涉及。

默认取值:

不涉及。

请求参数

表2 请求Header参数

参数

是否必选

参数类型

描述

Authorization

是

String

参数解释:

本次智能体工具调用对应的身份认证凭据。需要根据实际的智能体工具的入站身份认证方式获取对应的身份认证凭据。

API Key认证、IAM认证及OAuth 2.0认证具体请参见认证鉴权。

约束限制:

不涉及。

取值范围:

1-4096个字符,由字母、数字及特殊字符组成。

默认取值:

不涉及。

X-Hw-Agentarts-Browser-Session-Id

是

String

参数解释:

要使用的浏览器会话的唯一标识符。

约束限制:

必须是通过 StartBrowserSession 创建的活跃会话。如果会话已过期或已停止,请求将失败。

取值范围:

符合正则:^[a-zA-Z0-9_-]+$。

默认取值:

不涉及。

表3 请求Body参数

参数

是否必选

参数类型

描述

type

是

String

参数解释:

动作类型标识,决定 action 的具体结构。

mouse_click:鼠标点击;mouse_move:鼠标移动;mouse_drag:鼠标拖拽;mouse_scroll:鼠标滚动;

key_press:按键;key_shortcut:组合键;key_type:文本输入;screenshot:截图;

navigate:导航;go_back:后退;go_forward:前进;refresh:刷新;get_page_info:获取页面信息;

wait:等待;list_tabs:列出标签页;switch_tab:切换标签页;close_tab:关闭标签页;new_tab:新建标签页。

取值范围:

mouse_click、mouse_move、mouse_drag、mouse_scroll、key_press、key_shortcut、key_type、screenshot、navigate、go_back、go_forward、refresh、get_page_info、wait、list_tabs、switch_tab、close_tab、new_tab。

约束限制:

不涉及。

默认取值:

不涉及。

action

是

One of:

参数解释:

浏览器操作动作。

取值范围:

不涉及。

约束限制:

不涉及。

默认取值:

不涉及。

表4 MouseClickArguments

参数

是否必选

参数类型

描述

x

否

Integer

参数解释:

点击位置的视口 X 坐标(像素),与截图像素一一对应。

取值范围:

0到3840。

约束限制:

不涉及。

默认取值:

不涉及。

y

否

Integer

参数解释:

点击位置的视口 Y 坐标(像素),与截图像素一一对应。

取值范围:

0到2160。

约束限制:

不涉及。

默认取值:

不涉及。

button

否

String

参数解释:

鼠标按钮。

取值范围:

  • left:左键

  • right:右键

  • middle:中键

默认取值:

left

约束限制:

不涉及。

click_count

否

Integer

参数解释:

点击次数。设为 2 即双击。

取值范围:

1 至 10。

默认取值:

1

约束限制:

不涉及。

表5 MouseMoveArguments

参数

是否必选

参数类型

描述

x

否

Integer

参数解释:

目标视口 X 坐标(像素)。

取值范围:

0到3840。

约束限制:

不涉及。

默认取值:

不涉及。

y

否

Integer

参数解释:

目标视口 Y 坐标(像素)。

取值范围:

0到2160。

约束限制:

不涉及。

默认取值:

不涉及。

表6 MouseDragArguments

参数

是否必选

参数类型

描述

start_x

否

Integer

参数解释:

拖拽起始 X 坐标(像素)。

取值范围:

0到3840。

约束限制:

不涉及。

默认取值:

不涉及。

start_y

否

Integer

参数解释:

拖拽起始 Y 坐标(像素)。

取值范围:

0到2160。

约束限制:

不涉及。

默认取值:

不涉及。

end_x

否

Integer

参数解释:

拖拽结束 X 坐标(像素)。

取值范围:

0到3840。

约束限制:

不涉及。

默认取值:

不涉及。

end_y

否

Integer

参数解释:

拖拽结束 Y 坐标(像素)。

取值范围:

0到2160。

约束限制:

不涉及。

默认取值:

不涉及。

button

否

String

参数解释:

拖拽使用的鼠标按钮。

取值范围:

  • left:左键

  • right:右键

  • middle:中键

默认取值:

left

约束限制:

不涉及。

表7 MouseScrollArguments

参数

是否必选

参数类型

描述

x

否

Integer

参数解释:

滚动位置的视口 X 坐标(像素)。

取值范围:

0到3840。

约束限制:

不涉及。

默认取值:

不涉及。

y

否

Integer

参数解释:

滚动位置的视口 Y 坐标(像素)。

取值范围:

0到2160。

约束限制:

不涉及。

默认取值:

不涉及。

delta_x

否

Integer

参数解释:

水平滚动量(像素)。正值向右,负值向左。

取值范围:

-1000 至 1000。

默认取值:

0

约束限制:

不涉及。

delta_y

否

Integer

参数解释:

垂直滚动量(像素)。负值向下,正值向上。

取值范围:

-1000 至 1000。

默认取值:

0

约束限制:

不涉及。

表8 KeyPressArguments

参数

是否必选

参数类型

描述

key

否

String

参数解释:

按键名称。大小写不敏感,支持标准 DOM 键名(W3C KeyboardEvent.key)及常用别名。

约束限制:

不遵循任何固定枚举;未识别键名将返回错误。

取值范围:

  • 字母数字单字符:a-z, 0-9

  • 功能键:Enter, Tab, Escape, Backspace, Delete, Insert, Space

  • 方向键:ArrowUp, ArrowDown, ArrowLeft, ArrowRight

  • 编辑键:Home, End, PageUp, PageDown

  • 锁定键:CapsLock, NumLock, ScrollLock

  • F1-F12

  • 修饰键:Control, Alt, Shift, Meta

  • 其他:PrintScreen, Pause, ContextMenu

  • 常用别名(不区分大小写):esc/return/enter/del/ins/bs/space/spacebar、

up/down/left/right/arrowup/arrowdown/arrowleft/arrowright、

pgup/pgdn/pageup/pagedown/home/end、ctrl/control/alt/shift、

cmd/command/win/windows/meta、capslock/numlock/scrolllock、

prtsc/printscreen/pause/menu/contextmenu

默认取值:

不涉及。

presses

否

Integer

参数解释:

按键重复次数。

取值范围:

1 至 100。

默认取值:

1

约束限制:

不涉及。

表9 KeyShortcutArguments

参数

是否必选

参数类型

描述

keys

否

Array of strings

参数解释:

组合键列表(如 ["ctrl", "s"])。键名大小写不敏感,支持标准 DOM 键名及常用别名,详见 key_press 的 key 字段取值范围。

约束限制:

最多 5 个键;通常最后一个为非修饰键,前面的为修饰键。

取值范围:

同 key_press.key 字段。

表10 KeyTypeArguments

参数

是否必选

参数类型

描述

text

否

String

参数解释:

要输入的文本字符串。

取值范围:

长度0到10000个字符。

约束限制:

不涉及。

默认取值:

不涉及。

表11 ScreenshotArguments

参数

是否必选

参数类型

描述

format

否

String

参数解释:

截图图片格式。

取值范围:

  • png:无损

  • jpeg:有损(配合 quality 参数)

默认取值:

jpeg

约束限制:

不涉及。

quality

否

Integer

参数解释:

JPEG 压缩质量。仅在 format=jpeg 时生效。

取值范围:

1 至 100。

默认取值:

80

约束限制:

不涉及。

full_page

否

Boolean

参数解释:

是否截取整个页面(超出可视区域)。

取值范围:

  • true:全页面截图

  • false:仅可视区域

默认取值:

false

约束限制:

不涉及。

表12 NavigateArguments

参数

是否必选

参数类型

描述

url

否

String

参数解释:

目标 URL。

取值范围:

合法 URL。

约束限制:

不涉及。

默认取值:

不涉及。

表13 WaitArguments

参数

是否必选

参数类型

描述

duration

否

Float

参数解释:

等待时间(秒)。

取值范围:

最小 0.1,最大 30。

约束限制:

不涉及。

默认取值:

不涉及。

表14 SwitchTabArguments

参数

是否必选

参数类型

描述

tab_id

否

String

参数解释:

目标标签页 ID(由 listTabs 返回的 CDP Target ID)。

取值范围:

长度1到256个字符。

约束限制:

不涉及。

默认取值:

不涉及。

表15 CloseTabArguments

参数

是否必选

参数类型

描述

tab_id

否

String

参数解释:

要关闭的标签页 ID。不传则关闭当前标签页。

取值范围:

长度1到256个字符。

约束限制:

不涉及。

默认取值:

不涉及。

表16 NewTabArguments

参数

是否必选

参数类型

描述

url

否

String

参数解释:

新标签页要打开的 URL。不传则打开空白页。

取值范围:

合法 URL。

约束限制:

不涉及。

默认取值:

不涉及。

响应参数

状态码:200

表17 响应Body参数

参数

参数类型

描述

result

BrowserActionResult object

参数解释:

浏览器操作执行后的输出结果。

取值范围:

不涉及。

表18 BrowserActionResult

参数

参数类型

描述

content

Array of BrowserContentBlock objects

参数解释:

执行结果内容列表。截图操作返回 image 类型(base64),

get_page_info 返回 text 类型(JSON),其他操作返回 text 类型确认信息。

取值范围:

数组长度0到100个元素。

is_error

Boolean

参数解释:

指示结果是否代表错误。true 时 content 包含错误信息。

取值范围:

布尔值。

structured_content

BrowserResultStructuredContent object

参数解释:

操作结果的结构化附加信息。

取值范围:

不涉及。

表19 BrowserContentBlock

参数

参数类型

描述

type

String

参数解释:

内容块类型。

取值范围:

  • text:文本内容

  • image:图片内容(base64 编码)

text

String

参数解释:

文本内容。type=text 时使用。

取值范围:

长度0到10485760个字符。

data

String

参数解释:

Base64 编码的图片数据。type=image 时使用(截图结果)。

取值范围:

长度0到104857600个字符。

mime_type

String

参数解释:

内容 MIME 类型。type=image 时为 image/jpeg 或 image/png。

取值范围:

长度1到256个字符。

表20 BrowserResultStructuredContent

参数

参数类型

描述

action_id

String

参数解释:

操作唯一标识,用于录制事件流中关联追踪。

取值范围:

长度1到128个字符。

execution_time

Integer

参数解释:

操作执行耗时(毫秒)。

取值范围:

0到300000。

current_url

String

参数解释:

操作完成后的当前页面 URL。navigate 等导航操作时返回。

取值范围:

长度0到8192个字符。

page_title

String

参数解释:

操作完成后的当前页面标题。get_page_info 操作时返回。

取值范围:

长度0到1024个字符。

viewport

Viewport object

参数解释:

浏览器视口尺寸配置。

取值范围:

不涉及。

tabs

Array of TabInfo objects

参数解释:

标签页列表。list_tabs 操作时返回。

取值范围:

数组长度0到100个元素。

表21 Viewport

参数

参数类型

描述

width

Integer

参数解释:

视口宽度(像素)。

取值范围:

最小 800,最大 3840。

height

Integer

参数解释:

视口高度(像素)。

取值范围:

最小 600,最大 2160。

表22 TabInfo

参数

参数类型

描述

tab_id

String

参数解释:

标签页 ID(CDP Target ID)。

取值范围:

长度1到256个字符。

url

String

参数解释:

标签页当前 URL。

取值范围:

长度0到8192个字符。

title

String

参数解释:

标签页标题。

取值范围:

长度0到1024个字符。

active

Boolean

参数解释:

是否为当前活跃标签页。

取值范围:

布尔值。

状态码:400

表23 响应Body参数

参数

参数类型

描述

error_code

String

参数解释:

错误码。

取值范围:

满足正则规则 ^AgentArts.0402\d{4}$

error_msg

String

参数解释:

错误信息。

取值范围:

符合正则:^[a-zA-Z0-9\s一-鿿.,!?;:()'"-。,!?;:()]+$。

状态码:401

表24 响应Body参数

参数

参数类型

描述

error_code

String

参数解释:

错误码。

取值范围:

满足正则规则 ^AgentArts.0402\d{4}$

error_msg

String

参数解释:

错误信息。

取值范围:

符合正则:^[a-zA-Z0-9\s一-鿿.,!?;:()'"-。,!?;:()]+$。

状态码:403

表25 响应Body参数

参数

参数类型

描述

error_code

String

参数解释:

错误码。

取值范围:

满足正则规则 ^AgentArts.0402\d{4}$

error_msg

String

参数解释:

错误信息。

取值范围:

符合正则:^[a-zA-Z0-9\s一-鿿.,!?;:()'"-。,!?;:()]+$。

状态码:404

表26 响应Body参数

参数

参数类型

描述

error_code

String

参数解释:

错误码。

取值范围:

满足正则规则 ^AgentArts.0402\d{4}$

error_msg

String

参数解释:

错误信息。

取值范围:

符合正则:^[a-zA-Z0-9\s一-鿿.,!?;:()'"-。,!?;:()]+$。

状态码:408

表27 响应Body参数

参数

参数类型

描述

error_code

String

参数解释:

错误码。

取值范围:

满足正则规则 ^AgentArts.0402\d{4}$

error_msg

String

参数解释:

错误信息。

取值范围:

符合正则:^[a-zA-Z0-9\s一-鿿.,!?;:()'"-。,!?;:()]+$。

状态码:409

表28 响应Body参数

参数

参数类型

描述

error_code

String

参数解释:

错误码。

取值范围:

满足正则规则 ^AgentArts.0402\d{4}$

error_msg

String

参数解释:

错误信息。

取值范围:

符合正则:^[a-zA-Z0-9\s一-鿿.,!?;:()'"-。,!?;:()]+$。

状态码:413

表29 响应Body参数

参数

参数类型

描述

error_code

String

参数解释:

错误码。

取值范围:

满足正则规则 ^AgentArts.0402\d{4}$

error_msg

String

参数解释:

错误信息。

取值范围:

符合正则:^[a-zA-Z0-9\s一-鿿.,!?;:()'"-。,!?;:()]+$。

状态码:429

表30 响应Body参数

参数

参数类型

描述

error_code

String

参数解释:

错误码。

取值范围:

满足正则规则 ^AgentArts.0402\d{4}$

error_msg

String

参数解释:

错误信息。

取值范围:

符合正则:^[a-zA-Z0-9\s一-鿿.,!?;:()'"-。,!?;:()]+$。

状态码:500

表31 响应Body参数

参数

参数类型

描述

error_code

String

参数解释:

错误码。

取值范围:

满足正则规则 ^AgentArts.0402\d{4}$

error_msg

String

参数解释:

错误信息。

取值范围:

符合正则:^[a-zA-Z0-9\s一-鿿.,!?;:()'"-。,!?;:()]+$。

请求示例

  • {
      "type" : "key_shortcut",
      "action" : {
        "keys" : [ "ctrl", "s" ]
      }
    }
  • {
      "type" : "navigate",
      "action" : {
        "url" : "https://example.com"
      }
    }
  • {
      "type" : "screenshot",
      "action" : {
        "format" : "jpeg",
        "quality" : 80,
        "full_page" : false
      }
    }
  • {
      "type" : "go_back",
      "action" : { }
    }
  • {
      "type" : "key_type",
      "action" : {
        "text" : "Hello World"
      }
    }
  • {
      "type" : "mouse_drag",
      "action" : {
        "start_x" : 100,
        "start_y" : 200,
        "end_x" : 300,
        "end_y" : 400
      }
    }
  • {
      "type" : "switch_tab",
      "action" : {
        "tab_id" : "target-abc123"
      }
    }

响应示例

状态码:200

{
  "result" : {
    "content" : [ {
      "type" : "text",
      "text" : "Action completed: mouse_click at (312, 480)"
    } ],
    "is_error" : false,
    "structured_content" : {
      "action_id" : "act-20260429-001",
      "execution_time" : 120
    }
  }
}

状态码:400

{
  "error_code" : "AgentArts.04020001",
  "error_msg" : "Invalid parameter."
}

状态码:401

{
  "error_code" : "AgentArts.04020002",
  "error_msg" : "Authentication failed: invalid token"
}

状态码:404

{
  "error_code" : "AgentArts.04020004",
  "error_msg" : "Resource not found: session_id=sess-xxx"
}

状态码:408

{
  "error_code" : "AgentArts.04020007",
  "error_msg" : "Operation timeout: invoke action exceeded 30s limit"
}

状态码:409

{
  "error_code" : "AgentArts.04020005",
  "error_msg" : "Operation conflict: another invoke is in progress"
}

状态码:413

{
  "error_code" : "AgentArts.04020008",
  "error_msg" : "Request entity too large: body exceeds 10MB limit"
}

状态码: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

权限不足或 Automation 流已禁用(人工接管中,通过 UpdateBrowserStream 设为 disabled)

404

资源不存在

408

操作超时

409

操作冲突

413

请求体过大

429

请求频率超限

500

内部系统错误

错误码

请参见错误码。

相关文档