conversation-session-browser-use-agent-element-picker.json 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. {
  2. "version": 1,
  3. "caseName": "conversation-session-browser-use-agent-element-picker",
  4. "spec": "./test/e2e/conversation-session/browser-use/conversation-session-browser-use-agent-element-picker.test.ts",
  5. "fixtures": [
  6. {
  7. "id": "upstream-agent-element-picker-title",
  8. "description": "Agent tab 元素选择器用例的异步标题响应。",
  9. "metadata": {
  10. "kind": "common",
  11. "timingPolicy": "fast-text",
  12. "source": "synthetic",
  13. "syntheticReason": "标题不属于本用例语义,只需与 Browser tool continuation 隔离。"
  14. },
  15. "maxMatches": 1,
  16. "match": {
  17. "method": "POST",
  18. "pathIncludes": "/messages",
  19. "bodyIncludes": ["Generate a concise title", "E2E_AGENT_ELEMENT_PICKER_TURN"]
  20. },
  21. "response": {
  22. "statusCode": 200,
  23. "statusMessage": "OK",
  24. "headers": {
  25. "content-type": "application/json; charset=utf-8"
  26. },
  27. "body": "{\"id\":\"upstream-agent-element-picker-title\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"deepseek-v4-flash\",\"content\":[{\"type\":\"text\",\"text\":\"{\\\"title\\\":\\\"Agent 浏览器选元素\\\"}\"}],\"stop_reason\":\"end_turn\",\"stop_sequence\":null,\"usage\":{\"input_tokens\":64,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":8,\"service_tier\":\"standard\"}}"
  28. }
  29. },
  30. {
  31. "id": "upstream-agent-element-picker-open",
  32. "description": "Agent 用 Browser Use 打开一个 IAB tab 并标记 handoff,留给用户在 Agent tab 里点选元素。",
  33. "metadata": {
  34. "kind": "main",
  35. "timingPolicy": "fast-text",
  36. "source": "synthetic",
  37. "syntheticReason": "稳定打开一个真实的 Agent Browser Use tab,验证 Agent tab 仍走原来的元素 chip 选择器。"
  38. },
  39. "maxMatches": 1,
  40. "match": {
  41. "method": "POST",
  42. "pathIncludes": "/messages",
  43. "bodyIncludes": [
  44. "E2E_AGENT_ELEMENT_PICKER_TURN",
  45. "E2E_BROWSER_FIXTURE_URL:",
  46. "mcp__node_repl__js"
  47. ],
  48. "bodyExcludes": [
  49. "Generate a concise title",
  50. "CRITICAL: Respond with TEXT ONLY",
  51. "toolu_e2e_agent_element_picker_open"
  52. ]
  53. },
  54. "response": {
  55. "statusCode": 200,
  56. "toolUse": {
  57. "id": "toolu_e2e_agent_element_picker_open",
  58. "name": "mcp__node_repl__js",
  59. "input": {
  60. "title": "打开 Agent 浏览器页面",
  61. "code": "const browserPluginRoot = process.env.ZCODE_PLUGIN_ROOT ?? process.env.CLAUDE_PLUGIN_ROOT;\nif (!browserPluginRoot) throw new Error('Browser plugin root is unavailable in the node_repl host');\nconst { join } = await import('node:path');\nconst { pathToFileURL } = await import('node:url');\nconst browserClientUrl = pathToFileURL(join(browserPluginRoot, 'scripts', 'browser-client.mjs')).href;\nconst { setupBrowserRuntime } = await import(browserClientUrl);\nawait setupBrowserRuntime({ globals: globalThis });\nconst browser = await agent.browsers.get('iab');\nconst pickerUrl = new URL('/agent', '{{browserFixtureUrl}}').href;\nconst pickerTab = await browser.tabs.new();\nawait pickerTab.goto(pickerUrl);\nawait browser.tabs.finalize({ keep: [{ tab: pickerTab, status: 'handoff' }] });\n({ marker: 'E2E_AGENT_ELEMENT_PICKER_OPEN_OK', id: pickerTab.id });"
  62. }
  63. }
  64. }
  65. },
  66. {
  67. "id": "upstream-agent-element-picker-open-mcp-wait-1",
  68. "description": "Browser MCP 尚未就绪时执行第 1 次有界等待,工具出现后直接进入原业务动作。",
  69. "metadata": {
  70. "kind": "main",
  71. "source": "synthetic",
  72. "timingPolicy": "fast-text",
  73. "syntheticReason": "首请求不等 MCP;用真实等待工具推进普通 step,保留尚未就绪、就绪后调用两条回放路径。"
  74. },
  75. "maxMatches": 1,
  76. "match": {
  77. "method": "POST",
  78. "pathIncludes": "/messages",
  79. "bodyIncludes": [
  80. "E2E_AGENT_ELEMENT_PICKER_TURN",
  81. "E2E_BROWSER_FIXTURE_URL:",
  82. "WaitForMcpServers"
  83. ],
  84. "bodyExcludes": [
  85. "mcp__node_repl__js",
  86. "Generate a concise title",
  87. "CRITICAL: Respond with TEXT ONLY",
  88. "toolu_e2e_agent_element_picker_open"
  89. ]
  90. },
  91. "response": {
  92. "statusCode": 200,
  93. "toolUse": {
  94. "id": "toolu_upstream_agent_element_picker_open_mcp_wait_1",
  95. "name": "WaitForMcpServers",
  96. "input": {
  97. "servers": ["node_repl"]
  98. }
  99. }
  100. }
  101. },
  102. {
  103. "id": "upstream-agent-element-picker-open-mcp-wait-2",
  104. "description": "Browser MCP 尚未就绪时执行第 2 次有界等待,工具出现后直接进入原业务动作。",
  105. "metadata": {
  106. "kind": "main",
  107. "source": "synthetic",
  108. "timingPolicy": "fast-text",
  109. "syntheticReason": "首请求不等 MCP;用真实等待工具推进普通 step,保留尚未就绪、就绪后调用两条回放路径。"
  110. },
  111. "maxMatches": 1,
  112. "match": {
  113. "method": "POST",
  114. "pathIncludes": "/messages",
  115. "bodyIncludes": [
  116. "E2E_AGENT_ELEMENT_PICKER_TURN",
  117. "E2E_BROWSER_FIXTURE_URL:",
  118. "WaitForMcpServers",
  119. "toolu_upstream_agent_element_picker_open_mcp_wait_1"
  120. ],
  121. "bodyExcludes": [
  122. "mcp__node_repl__js",
  123. "Generate a concise title",
  124. "CRITICAL: Respond with TEXT ONLY",
  125. "toolu_e2e_agent_element_picker_open"
  126. ],
  127. "lastUserMessageIncludes": ["Still connecting"]
  128. },
  129. "response": {
  130. "statusCode": 200,
  131. "toolUse": {
  132. "id": "toolu_upstream_agent_element_picker_open_mcp_wait_2",
  133. "name": "WaitForMcpServers",
  134. "input": {
  135. "servers": ["node_repl"]
  136. }
  137. }
  138. }
  139. },
  140. {
  141. "id": "upstream-agent-element-picker-open-mcp-wait-3",
  142. "description": "Browser MCP 尚未就绪时执行第 3 次有界等待,工具出现后直接进入原业务动作。",
  143. "metadata": {
  144. "kind": "main",
  145. "source": "synthetic",
  146. "timingPolicy": "fast-text",
  147. "syntheticReason": "首请求不等 MCP;用真实等待工具推进普通 step,保留尚未就绪、就绪后调用两条回放路径。"
  148. },
  149. "maxMatches": 1,
  150. "match": {
  151. "method": "POST",
  152. "pathIncludes": "/messages",
  153. "bodyIncludes": [
  154. "E2E_AGENT_ELEMENT_PICKER_TURN",
  155. "E2E_BROWSER_FIXTURE_URL:",
  156. "WaitForMcpServers",
  157. "toolu_upstream_agent_element_picker_open_mcp_wait_2"
  158. ],
  159. "bodyExcludes": [
  160. "mcp__node_repl__js",
  161. "Generate a concise title",
  162. "CRITICAL: Respond with TEXT ONLY",
  163. "toolu_e2e_agent_element_picker_open"
  164. ],
  165. "lastUserMessageIncludes": ["Still connecting"]
  166. },
  167. "response": {
  168. "statusCode": 200,
  169. "toolUse": {
  170. "id": "toolu_upstream_agent_element_picker_open_mcp_wait_3",
  171. "name": "WaitForMcpServers",
  172. "input": {
  173. "servers": ["node_repl"]
  174. }
  175. }
  176. }
  177. },
  178. {
  179. "id": "upstream-agent-element-picker-final",
  180. "description": "打开页面后正常结束本轮,tab 留给用户。",
  181. "metadata": {
  182. "kind": "main",
  183. "timingPolicy": "fast-text",
  184. "source": "synthetic",
  185. "syntheticReason": "让 turn 回到 idle,再由用户操作 Agent tab。"
  186. },
  187. "maxMatches": 1,
  188. "match": {
  189. "method": "POST",
  190. "pathIncludes": "/messages",
  191. "bodyIncludes": ["E2E_AGENT_ELEMENT_PICKER_TURN", "toolu_e2e_agent_element_picker_open"],
  192. "lastUserMessageIncludes": ["E2E_AGENT_ELEMENT_PICKER_OPEN_OK"],
  193. "bodyExcludes": ["Generate a concise title", "CRITICAL: Respond with TEXT ONLY"]
  194. },
  195. "response": {
  196. "statusCode": 200,
  197. "text": "E2E_AGENT_ELEMENT_PICKER_DONE"
  198. }
  199. }
  200. ]
  201. }