conversation-session-browser-use-agent-tab-closed-residual-guest.json 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. {
  2. "version": 1,
  3. "caseName": "conversation-session-browser-use-agent-tab-closed-residual-guest",
  4. "spec": "./test/e2e/conversation-session/browser-use/conversation-session-browser-use-agent-tab-closed-residual-guest.test.ts",
  5. "fixtures": [
  6. {
  7. "id": "upstream-agent-tab-ws-switch-title",
  8. "description": "预热轮的异步标题响应。",
  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_TAB_WS_SWITCH_WARMUP"]
  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-tab-ws-switch-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-tab-ws-switch-warmup",
  32. "description": "预热轮:首轮发出时 session 的 MCP 可能还没连上;测试按请求里是否已暴露 Browser Use 工具决定是否再预热一轮(最多 5 轮)。",
  33. "metadata": {
  34. "kind": "main",
  35. "timingPolicy": "fast-text",
  36. "source": "synthetic",
  37. "syntheticReason": "首轮工具快照不等待 MCP 启动;预热不属于本用例语义。"
  38. },
  39. "maxMatches": 5,
  40. "match": {
  41. "method": "POST",
  42. "pathIncludes": "/messages",
  43. "lastUserMessageIncludes": ["E2E_AGENT_TAB_WS_SWITCH_WARMUP"],
  44. "bodyExcludes": ["Generate a concise title", "CRITICAL: Respond with TEXT ONLY"]
  45. },
  46. "response": {
  47. "statusCode": 200,
  48. "text": "E2E_AGENT_TAB_WS_SWITCH_WARMUP_DONE"
  49. }
  50. },
  51. {
  52. "id": "upstream-agent-tab-ws-switch-open",
  53. "description": "Agent 用 Browser Use 打开 fixture 页面并 handoff,tab 保持 Agent 归属。",
  54. "metadata": {
  55. "kind": "main",
  56. "timingPolicy": "fast-text",
  57. "source": "synthetic",
  58. "syntheticReason": "稳定打开一个真实的 Agent Browser Use tab,供切换 workspace 后在别的 workspace 留下残留壳,再验证 tab 关闭后残留壳不会留下出声 guest。"
  59. },
  60. "maxMatches": 1,
  61. "match": {
  62. "method": "POST",
  63. "pathIncludes": "/messages",
  64. "lastUserMessageIncludes": ["E2E_AGENT_TAB_WS_SWITCH_TURN", "E2E_BROWSER_FIXTURE_URL:"],
  65. "bodyIncludes": ["mcp__node_repl__js"],
  66. "bodyExcludes": ["Generate a concise title", "CRITICAL: Respond with TEXT ONLY"]
  67. },
  68. "response": {
  69. "statusCode": 200,
  70. "toolUse": {
  71. "id": "toolu_e2e_agent_tab_ws_switch_open",
  72. "name": "mcp__node_repl__js",
  73. "input": {
  74. "title": "打开 Agent 浏览器页面",
  75. "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 agentTab = await browser.tabs.new();\nawait agentTab.goto('{{browserFixtureUrl}}');\nawait browser.tabs.finalize({ keep: [{ tab: agentTab, status: 'handoff' }] });\n({ marker: 'E2E_AGENT_TAB_WS_SWITCH_OPEN_OK', id: agentTab.id });"
  76. }
  77. }
  78. }
  79. },
  80. {
  81. "id": "upstream-agent-tab-ws-switch-final",
  82. "description": "打开页面后正常结束本轮,tab 留在 Agent 名下。",
  83. "metadata": {
  84. "kind": "main",
  85. "timingPolicy": "fast-text",
  86. "source": "synthetic",
  87. "syntheticReason": "让 turn 回到 idle,再切换 workspace 与归档任务。"
  88. },
  89. "maxMatches": 1,
  90. "match": {
  91. "method": "POST",
  92. "pathIncludes": "/messages",
  93. "bodyIncludes": ["E2E_AGENT_TAB_WS_SWITCH_TURN", "toolu_e2e_agent_tab_ws_switch_open"],
  94. "lastUserMessageIncludes": ["E2E_AGENT_TAB_WS_SWITCH_OPEN_OK"],
  95. "bodyExcludes": ["Generate a concise title", "CRITICAL: Respond with TEXT ONLY"]
  96. },
  97. "response": {
  98. "statusCode": 200,
  99. "text": "E2E_AGENT_TAB_WS_SWITCH_DONE"
  100. }
  101. }
  102. ]
  103. }