conversation-session-node-repl-stateless-browser-multisession.json 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. {
  2. "version": 1,
  3. "caseName": "conversation-session-node-repl-stateless-browser-multisession",
  4. "spec": "./test/e2e/conversation-session/browser-use/conversation-session-node-repl-stateless-browser-multisession.test.ts",
  5. "fixtures": [
  6. {
  7. "id": "node-repl-browser-stateless-title",
  8. "description": "固定两个 Browser Use session 的异步标题响应。",
  9. "metadata": {
  10. "kind": "common",
  11. "timingPolicy": "fast-text",
  12. "source": "synthetic",
  13. "syntheticReason": "标题不是本 case 的产品语义,只需避免误命中主请求。"
  14. },
  15. "maxMatches": 2,
  16. "match": {
  17. "method": "POST",
  18. "pathIncludes": "/messages",
  19. "bodyIncludes": ["Generate a concise title", "E2E_NODE_REPL_BROWSER_STATELESS_"]
  20. },
  21. "response": {
  22. "statusCode": 200,
  23. "statusMessage": "OK",
  24. "headers": { "content-type": "application/json; charset=utf-8" },
  25. "body": "{\"id\":\"upstream-node-repl-browser-stateless-title\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"deepseek-v4-flash\",\"content\":[{\"type\":\"text\",\"text\":\"{\\\"title\\\":\\\"Browser 无状态复用\\\"}\"}],\"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\"}}"
  26. }
  27. },
  28. {
  29. "id": "node-repl-browser-a-initial",
  30. "description": "Session A 首次调用 node_repl,创建真实 IAB tab 并写入 kernel marker。",
  31. "metadata": {
  32. "kind": "main",
  33. "timingPolicy": "fast-text",
  34. "source": "synthetic",
  35. "syntheticReason": "稳定构造 fresh kernel 与 BrowserControl 连续性的前置状态。"
  36. },
  37. "maxMatches": 1,
  38. "match": {
  39. "method": "POST",
  40. "pathIncludes": "/messages",
  41. "lastUserMessageIncludes": ["E2E_NODE_REPL_BROWSER_STATELESS_A"],
  42. "bodyIncludes": ["mcp__node_repl__js"],
  43. "bodyExcludes": [
  44. "toolu_e2e_node_repl_browser_a_initial",
  45. "Generate a concise title",
  46. "CRITICAL: Respond with TEXT ONLY"
  47. ]
  48. },
  49. "response": {
  50. "statusCode": 200,
  51. "toolUse": {
  52. "id": "toolu_e2e_node_repl_browser_a_initial",
  53. "name": "mcp__node_repl__js",
  54. "input": {
  55. "title": "创建 Session A Browser tab",
  56. "code": "const root = process.env.ZCODE_PLUGIN_ROOT ?? process.env.CLAUDE_PLUGIN_ROOT;\nif (!root) throw new Error('Browser plugin root is unavailable');\nconst { join } = await import('node:path');\nconst { pathToFileURL } = await import('node:url');\nconst { setupBrowserRuntime } = await import(pathToFileURL(join(root, 'scripts', 'browser-client.mjs')).href);\nawait setupBrowserRuntime({ globals: globalThis });\nconst controlledBrowser = await agent.browsers.get('iab');\nconst before = await controlledBrowser.tabs.list();\nglobalThis.__zcodeBrowserKernelMarker = 'SESSION_A';\nawait controlledBrowser.tabs.new();\nconst after = await controlledBrowser.tabs.list();\n({ marker: before.length === 0 && after.length === 1 ? 'E2E_NODE_REPL_BROWSER_A_INITIAL_OK' : 'E2E_NODE_REPL_BROWSER_A_INITIAL_FAILED', beforeCount: before.length, afterCount: after.length, tabId: after[0]?.id });"
  57. }
  58. }
  59. }
  60. },
  61. {
  62. "id": "node-repl-browser-a-verify",
  63. "description": "Session A 第二次调用证明 kernel fresh 且 BrowserControl tab 连续。",
  64. "metadata": {
  65. "kind": "main",
  66. "timingPolicy": "fast-text",
  67. "source": "synthetic",
  68. "syntheticReason": "直接覆盖 Browser Use 的调用级无状态合同。"
  69. },
  70. "maxMatches": 1,
  71. "match": {
  72. "method": "POST",
  73. "pathIncludes": "/messages",
  74. "bodyIncludes": [
  75. "E2E_NODE_REPL_BROWSER_STATELESS_A",
  76. "toolu_e2e_node_repl_browser_a_initial"
  77. ],
  78. "lastUserMessageIncludes": ["E2E_NODE_REPL_BROWSER_A_INITIAL_OK"],
  79. "bodyExcludes": [
  80. "toolu_e2e_node_repl_browser_a_verify",
  81. "Generate a concise title",
  82. "CRITICAL: Respond with TEXT ONLY"
  83. ]
  84. },
  85. "response": {
  86. "statusCode": 200,
  87. "toolUse": {
  88. "id": "toolu_e2e_node_repl_browser_a_verify",
  89. "name": "mcp__node_repl__js",
  90. "input": {
  91. "title": "验证 Session A fresh kernel 与 tab 连续",
  92. "code": "const kernelState = typeof globalThis.__zcodeBrowserKernelMarker;\nconst root = process.env.ZCODE_PLUGIN_ROOT ?? process.env.CLAUDE_PLUGIN_ROOT;\nif (!root) throw new Error('Browser plugin root is unavailable');\nconst { join } = await import('node:path');\nconst { pathToFileURL } = await import('node:url');\nconst { setupBrowserRuntime } = await import(pathToFileURL(join(root, 'scripts', 'browser-client.mjs')).href);\nawait setupBrowserRuntime({ globals: globalThis });\nconst controlledBrowser = await agent.browsers.get('iab');\nconst tabs = await controlledBrowser.tabs.list();\n({ marker: kernelState === 'undefined' && tabs.length === 1 ? 'E2E_NODE_REPL_BROWSER_A_STATELESS_OK' : 'E2E_NODE_REPL_BROWSER_A_STATELESS_FAILED', kernelState, count: tabs.length, tabId: tabs[0]?.id });"
  93. }
  94. }
  95. }
  96. },
  97. {
  98. "id": "node-repl-browser-a-final",
  99. "description": "Session A 只在 fresh kernel 与 tab 连续同时成立后完成。",
  100. "metadata": {
  101. "kind": "main",
  102. "timingPolicy": "fast-text",
  103. "source": "synthetic",
  104. "syntheticReason": "证明真实 tool result 已进入同一 session continuation。"
  105. },
  106. "maxMatches": 1,
  107. "match": {
  108. "method": "POST",
  109. "pathIncludes": "/messages",
  110. "bodyIncludes": [
  111. "E2E_NODE_REPL_BROWSER_STATELESS_A",
  112. "toolu_e2e_node_repl_browser_a_verify"
  113. ],
  114. "lastUserMessageIncludes": ["E2E_NODE_REPL_BROWSER_A_STATELESS_OK"],
  115. "bodyExcludes": ["Generate a concise title", "CRITICAL: Respond with TEXT ONLY"]
  116. },
  117. "response": { "statusCode": 200, "text": "E2E_NODE_REPL_BROWSER_STATELESS_A_DONE" }
  118. },
  119. {
  120. "id": "node-repl-browser-b-verify",
  121. "description": "Session B 证明没有继承 A 的 kernel 或 BrowserControl tab,再创建自己的 tab。",
  122. "metadata": {
  123. "kind": "main",
  124. "timingPolicy": "fast-text",
  125. "source": "synthetic",
  126. "syntheticReason": "覆盖共享 frontend 下的跨 session kernel、tab 与结果隔离。"
  127. },
  128. "maxMatches": 1,
  129. "match": {
  130. "method": "POST",
  131. "pathIncludes": "/messages",
  132. "lastUserMessageIncludes": ["E2E_NODE_REPL_BROWSER_STATELESS_B"],
  133. "bodyIncludes": ["mcp__node_repl__js"],
  134. "bodyExcludes": [
  135. "toolu_e2e_node_repl_browser_b_verify",
  136. "Generate a concise title",
  137. "CRITICAL: Respond with TEXT ONLY"
  138. ]
  139. },
  140. "response": {
  141. "statusCode": 200,
  142. "toolUse": {
  143. "id": "toolu_e2e_node_repl_browser_b_verify",
  144. "name": "mcp__node_repl__js",
  145. "input": {
  146. "title": "验证 Session B Browser 隔离",
  147. "code": "const kernelState = typeof globalThis.__zcodeBrowserKernelMarker;\nconst root = process.env.ZCODE_PLUGIN_ROOT ?? process.env.CLAUDE_PLUGIN_ROOT;\nif (!root) throw new Error('Browser plugin root is unavailable');\nconst { join } = await import('node:path');\nconst { pathToFileURL } = await import('node:url');\nconst { setupBrowserRuntime } = await import(pathToFileURL(join(root, 'scripts', 'browser-client.mjs')).href);\nawait setupBrowserRuntime({ globals: globalThis });\nconst controlledBrowser = await agent.browsers.get('iab');\nconst before = await controlledBrowser.tabs.list();\nawait controlledBrowser.tabs.new();\nconst after = await controlledBrowser.tabs.list();\n({ marker: kernelState === 'undefined' && before.length === 0 && after.length === 1 ? 'E2E_NODE_REPL_BROWSER_B_ISOLATED_OK' : 'E2E_NODE_REPL_BROWSER_B_ISOLATED_FAILED', kernelState, beforeCount: before.length, afterCount: after.length });"
  148. }
  149. }
  150. }
  151. },
  152. {
  153. "id": "node-repl-browser-b-final",
  154. "description": "Session B 只在跨 session 隔离成立后完成。",
  155. "metadata": {
  156. "kind": "main",
  157. "timingPolicy": "fast-text",
  158. "source": "synthetic",
  159. "syntheticReason": "证明 B 的结果只回到 B continuation。"
  160. },
  161. "maxMatches": 1,
  162. "match": {
  163. "method": "POST",
  164. "pathIncludes": "/messages",
  165. "bodyIncludes": [
  166. "E2E_NODE_REPL_BROWSER_STATELESS_B",
  167. "toolu_e2e_node_repl_browser_b_verify"
  168. ],
  169. "lastUserMessageIncludes": ["E2E_NODE_REPL_BROWSER_B_ISOLATED_OK"],
  170. "bodyExcludes": [
  171. "E2E_NODE_REPL_BROWSER_A_STATELESS_OK",
  172. "Generate a concise title",
  173. "CRITICAL: Respond with TEXT ONLY"
  174. ]
  175. },
  176. "response": { "statusCode": 200, "text": "E2E_NODE_REPL_BROWSER_STATELESS_B_DONE" }
  177. }
  178. ]
  179. }