plugin-extension-sessions-write.json 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. {
  2. "version": 1,
  3. "caseName": "plugin-extension-sessions-write",
  4. "spec": "./test/e2e/plugins/extensions/plugin-extension-sessions-write.test.ts",
  5. "fixtures": [
  6. {
  7. "id": "p3c-title",
  8. "description": "PLM-EXT-P3C p3c-title",
  9. "metadata": {
  10. "kind": "common",
  11. "timingPolicy": "fast-text",
  12. "source": "synthetic",
  13. "syntheticReason": "受控模型只给出回复文本;扩展经 ctx.sessions.* 发出的真实命令在 Electron/Host/Agent 里执行,会话身份与回执只从扩展日志读取;模型切换靠请求体里的 model 匹配,中断靠显式流闸门固定运行窗口。"
  14. },
  15. "match": {
  16. "method": "POST",
  17. "pathIncludes": "/messages",
  18. "bodyIncludes": ["Generate a concise title", "E2E_P3C"]
  19. },
  20. "response": {
  21. "statusCode": 200,
  22. "text": {
  23. "text": "{\"title\":\"E2E_P3C\"}"
  24. }
  25. }
  26. },
  27. {
  28. "id": "p3c-create",
  29. "description": "PLM-EXT-P3C p3c-create",
  30. "metadata": {
  31. "kind": "main",
  32. "timingPolicy": "fast-text",
  33. "source": "synthetic",
  34. "syntheticReason": "受控模型只给出回复文本;扩展经 ctx.sessions.* 发出的真实命令在 Electron/Host/Agent 里执行,会话身份与回执只从扩展日志读取;模型切换靠请求体里的 model 匹配,中断靠显式流闸门固定运行窗口。"
  35. },
  36. "match": {
  37. "method": "POST",
  38. "pathIncludes": "/messages",
  39. "lastUserMessageIncludes": ["E2E_P3C_CREATE"],
  40. "bodyExcludes": ["Generate a concise title", "CRITICAL: Respond with TEXT ONLY"]
  41. },
  42. "response": {
  43. "statusCode": 200,
  44. "text": {
  45. "text": "E2E_P3C_CREATE_DONE"
  46. }
  47. },
  48. "maxMatches": 1
  49. },
  50. {
  51. "id": "p3c-send",
  52. "description": "PLM-EXT-P3C p3c-send",
  53. "metadata": {
  54. "kind": "main",
  55. "timingPolicy": "fast-text",
  56. "source": "synthetic",
  57. "syntheticReason": "受控模型只给出回复文本;扩展经 ctx.sessions.* 发出的真实命令在 Electron/Host/Agent 里执行,会话身份与回执只从扩展日志读取;模型切换靠请求体里的 model 匹配,中断靠显式流闸门固定运行窗口。"
  58. },
  59. "match": {
  60. "method": "POST",
  61. "pathIncludes": "/messages",
  62. "lastUserMessageIncludes": ["E2E_P3C_SEND"],
  63. "bodyExcludes": ["Generate a concise title", "CRITICAL: Respond with TEXT ONLY"]
  64. },
  65. "response": {
  66. "statusCode": 200,
  67. "text": {
  68. "text": "E2E_P3C_SEND_DONE"
  69. }
  70. },
  71. "maxMatches": 1
  72. },
  73. {
  74. "id": "p3c-model",
  75. "description": "PLM-EXT-P3C p3c-model",
  76. "metadata": {
  77. "kind": "main",
  78. "timingPolicy": "fast-text",
  79. "source": "synthetic",
  80. "syntheticReason": "受控模型只给出回复文本;扩展经 ctx.sessions.* 发出的真实命令在 Electron/Host/Agent 里执行,会话身份与回执只从扩展日志读取;模型切换靠请求体里的 model 匹配,中断靠显式流闸门固定运行窗口。"
  81. },
  82. "match": {
  83. "method": "POST",
  84. "pathIncludes": "/messages",
  85. "lastUserMessageIncludes": ["E2E_P3C_MODEL"],
  86. "bodyExcludes": ["Generate a concise title", "CRITICAL: Respond with TEXT ONLY"],
  87. "bodyIncludes": ["\"model\":\"deepseek-v4-pro\""]
  88. },
  89. "response": {
  90. "statusCode": 200,
  91. "text": {
  92. "text": "E2E_P3C_MODEL_DONE"
  93. }
  94. },
  95. "maxMatches": 1
  96. },
  97. {
  98. "id": "p3c-interrupt-target",
  99. "description": "PLM-EXT-P3C p3c-interrupt-target",
  100. "metadata": {
  101. "kind": "main",
  102. "timingPolicy": "controlled-stream",
  103. "source": "synthetic",
  104. "syntheticReason": "受控模型只给出回复文本;扩展经 ctx.sessions.* 发出的真实命令在 Electron/Host/Agent 里执行,会话身份与回执只从扩展日志读取;模型切换靠请求体里的 model 匹配,中断靠显式流闸门固定运行窗口。"
  105. },
  106. "match": {
  107. "method": "POST",
  108. "pathIncludes": "/messages",
  109. "lastUserMessageIncludes": ["E2E_P3C_INTERRUPT"],
  110. "bodyExcludes": ["Generate a concise title", "CRITICAL: Respond with TEXT ONLY"]
  111. },
  112. "response": {
  113. "statusCode": 200,
  114. "headers": {
  115. "content-type": "text/event-stream; charset=utf-8"
  116. },
  117. "chunks": [
  118. {
  119. "offsetMs": 0,
  120. "text": "event: message_start\ndata: {\"type\":\"message_start\",\"message\":{\"id\":\"p3c-interrupt\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"deepseek-v4-pro\",\"content\":[],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":80,\"output_tokens\":0}}}\n\n"
  121. },
  122. {
  123. "offsetMs": 0,
  124. "text": "event: content_block_start\ndata: {\"type\":\"content_block_start\",\"index\":0,\"content_block\":{\"type\":\"text\",\"text\":\"\"}}\n\n"
  125. },
  126. {
  127. "offsetMs": 0,
  128. "text": "event: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"E2E_P3C_INTERRUPT_STREAMING \"}}\n\n"
  129. },
  130. {
  131. "offsetMs": 0,
  132. "text": "event: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"E2E_P3C_INTERRUPT_DONE\"}}\n\n"
  133. },
  134. {
  135. "offsetMs": 0,
  136. "text": "event: content_block_stop\ndata: {\"type\":\"content_block_stop\",\"index\":0}\n\n"
  137. },
  138. {
  139. "offsetMs": 0,
  140. "text": "event: message_delta\ndata: {\"type\":\"message_delta\",\"delta\":{\"stop_reason\":\"end_turn\",\"stop_sequence\":null},\"usage\":{\"input_tokens\":80,\"output_tokens\":16}}\n\n"
  141. },
  142. {
  143. "offsetMs": 0,
  144. "text": "event: message_stop\ndata: {\"type\":\"message_stop\"}\n\n"
  145. }
  146. ],
  147. "releaseAfterChunks": 3
  148. },
  149. "maxMatches": 1
  150. },
  151. {
  152. "id": "p3c-stream",
  153. "description": "PLM-EXT-P3C p3c-stream:回复分四段到达,扩展的行订阅逐段收到增量",
  154. "metadata": {
  155. "kind": "main",
  156. "timingPolicy": "recorded-stream",
  157. "source": "synthetic",
  158. "syntheticReason": "受控模型分几段推回复文字(固定间隔),证明扩展经行镜像逐段收到增量;会话由扩展经 ctx.sessions.createSession 真实创建。"
  159. },
  160. "match": {
  161. "method": "POST",
  162. "pathIncludes": "/messages",
  163. "lastUserMessageIncludes": ["E2E_P3C_STREAM"],
  164. "bodyExcludes": ["Generate a concise title", "CRITICAL: Respond with TEXT ONLY"]
  165. },
  166. "response": {
  167. "statusCode": 200,
  168. "headers": {
  169. "content-type": "text/event-stream; charset=utf-8"
  170. },
  171. "chunks": [
  172. {
  173. "offsetMs": 0,
  174. "text": "event: message_start\ndata: {\"type\":\"message_start\",\"message\":{\"id\":\"p3c-stream\",\"type\":\"message\",\"role\":\"assistant\",\"model\":\"deepseek-v4-flash\",\"content\":[],\"stop_reason\":null,\"stop_sequence\":null,\"usage\":{\"input_tokens\":80,\"output_tokens\":0}}}\n\n"
  175. },
  176. {
  177. "offsetMs": 0,
  178. "text": "event: content_block_start\ndata: {\"type\":\"content_block_start\",\"index\":0,\"content_block\":{\"type\":\"text\",\"text\":\"\"}}\n\n"
  179. },
  180. {
  181. "offsetMs": 1000,
  182. "text": "event: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"E2E_P3C_STREAM_PART_1 \"}}\n\n"
  183. },
  184. {
  185. "offsetMs": 2500,
  186. "text": "event: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"E2E_P3C_STREAM_PART_2 \"}}\n\n"
  187. },
  188. {
  189. "offsetMs": 4000,
  190. "text": "event: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"E2E_P3C_STREAM_PART_3 \"}}\n\n"
  191. },
  192. {
  193. "offsetMs": 5500,
  194. "text": "event: content_block_delta\ndata: {\"type\":\"content_block_delta\",\"index\":0,\"delta\":{\"type\":\"text_delta\",\"text\":\"E2E_P3C_STREAM_DONE\"}}\n\n"
  195. },
  196. {
  197. "offsetMs": 5500,
  198. "text": "event: content_block_stop\ndata: {\"type\":\"content_block_stop\",\"index\":0}\n\n"
  199. },
  200. {
  201. "offsetMs": 5500,
  202. "text": "event: message_delta\ndata: {\"type\":\"message_delta\",\"delta\":{\"stop_reason\":\"end_turn\",\"stop_sequence\":null},\"usage\":{\"input_tokens\":80,\"output_tokens\":24}}\n\n"
  203. },
  204. {
  205. "offsetMs": 5500,
  206. "text": "event: message_stop\ndata: {\"type\":\"message_stop\"}\n\n"
  207. }
  208. ]
  209. },
  210. "maxMatches": 1
  211. },
  212. {
  213. "id": "p3c-fail",
  214. "description": "PLM-EXT-P3C p3c-fail:这一轮以 400 失败,扩展经行镜像看到 turnHeader 的 failed",
  215. "metadata": {
  216. "kind": "main",
  217. "timingPolicy": "fast-text",
  218. "source": "synthetic",
  219. "syntheticReason": "受控模型对这一句直接返回 400,这一轮在 CLI 里真实失败;扩展只经行镜像观察本轮状态。"
  220. },
  221. "match": {
  222. "method": "POST",
  223. "pathIncludes": "/messages",
  224. "lastUserMessageIncludes": ["E2E_P3C_FAIL"],
  225. "bodyExcludes": ["Generate a concise title", "CRITICAL: Respond with TEXT ONLY"]
  226. },
  227. "response": {
  228. "statusCode": 400,
  229. "statusMessage": "Bad Request",
  230. "headers": {
  231. "content-type": "application/json; charset=utf-8"
  232. },
  233. "body": "{\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"E2E_P3C_FAIL_SYNTHETIC\"}}"
  234. },
  235. "maxMatches": 1
  236. }
  237. ]
  238. }