@midscene/core 1.12.10-beta-20260920031616.0 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (319) hide show
  1. package/dist/es/agent/agent.mjs +103 -6
  2. package/dist/es/agent/agent.mjs.map +1 -1
  3. package/dist/es/agent/index.mjs +4 -3
  4. package/dist/es/agent/tasks.mjs +2 -2
  5. package/dist/es/agent/tasks.mjs.map +1 -1
  6. package/dist/es/agent/test-runner-nodes.mjs +291 -40
  7. package/dist/es/agent/test-runner-nodes.mjs.map +1 -1
  8. package/dist/es/agent/utils.mjs +1 -1
  9. package/dist/es/device/index.mjs +15 -2
  10. package/dist/es/device/index.mjs.map +1 -1
  11. package/dist/es/dump/html-utils.mjs +37 -4
  12. package/dist/es/dump/html-utils.mjs.map +1 -1
  13. package/dist/es/dump/screenshot-store.mjs +8 -1
  14. package/dist/es/dump/screenshot-store.mjs.map +1 -1
  15. package/dist/es/report-cli.mjs +9 -4
  16. package/dist/es/report-cli.mjs.map +1 -1
  17. package/dist/es/report-generator.mjs +117 -4
  18. package/dist/es/report-generator.mjs.map +1 -1
  19. package/dist/es/report-html-template.mjs +1 -1
  20. package/dist/es/report.mjs +190 -41
  21. package/dist/es/report.mjs.map +1 -1
  22. package/dist/es/test-run-report.mjs.map +1 -1
  23. package/dist/es/test-runner/engine/case-runner.mjs +52 -0
  24. package/dist/es/test-runner/engine/case-runner.mjs.map +1 -0
  25. package/dist/es/test-runner/engine/document-runtime.mjs +273 -0
  26. package/dist/es/test-runner/engine/document-runtime.mjs.map +1 -0
  27. package/dist/es/test-runner/engine/execute-step.mjs +177 -0
  28. package/dist/es/test-runner/engine/execute-step.mjs.map +1 -0
  29. package/dist/es/test-runner/engine/execution-failure.mjs +39 -0
  30. package/dist/es/test-runner/engine/execution-failure.mjs.map +1 -0
  31. package/dist/es/test-runner/engine/index.mjs +12 -0
  32. package/dist/es/test-runner/engine/project-runtime.mjs +142 -0
  33. package/dist/es/test-runner/engine/project-runtime.mjs.map +1 -0
  34. package/dist/es/test-runner/engine/registry.mjs +61 -0
  35. package/dist/es/test-runner/engine/registry.mjs.map +1 -0
  36. package/dist/es/test-runner/engine/resource-operations.mjs +211 -0
  37. package/dist/es/test-runner/engine/resource-operations.mjs.map +1 -0
  38. package/dist/es/test-runner/engine/run-collected-case.mjs +193 -0
  39. package/dist/es/test-runner/engine/run-collected-case.mjs.map +1 -0
  40. package/dist/es/test-runner/engine/run-workflow-document.mjs +155 -0
  41. package/dist/es/test-runner/engine/run-workflow-document.mjs.map +1 -0
  42. package/dist/es/test-runner/engine/scheduler.mjs +27 -0
  43. package/dist/es/test-runner/engine/scheduler.mjs.map +1 -0
  44. package/dist/es/test-runner/engine/scope-teardown.mjs +16 -0
  45. package/dist/es/test-runner/engine/scope-teardown.mjs.map +1 -0
  46. package/dist/es/test-runner/engine/types.mjs +0 -0
  47. package/dist/es/test-runner/errors.mjs +201 -0
  48. package/dist/es/test-runner/errors.mjs.map +1 -0
  49. package/dist/es/test-runner/execution-record.mjs +83 -0
  50. package/dist/es/test-runner/execution-record.mjs.map +1 -0
  51. package/dist/es/test-runner/index.mjs +12 -0
  52. package/dist/es/test-runner/node/define-node.mjs +44 -0
  53. package/dist/es/test-runner/node/define-node.mjs.map +1 -0
  54. package/dist/es/test-runner/node/index.mjs +2 -0
  55. package/dist/es/test-runner/node/types.mjs +0 -0
  56. package/dist/es/test-runner/parser/document-format.mjs +21 -0
  57. package/dist/es/test-runner/parser/document-format.mjs.map +1 -0
  58. package/dist/es/test-runner/parser/normalize.mjs +87 -0
  59. package/dist/es/test-runner/parser/normalize.mjs.map +1 -0
  60. package/dist/es/test-runner/parser/types.mjs +0 -0
  61. package/dist/es/test-runner/project.mjs +0 -0
  62. package/dist/es/test-runner/reporting/agent-report.mjs +23 -0
  63. package/dist/es/test-runner/reporting/agent-report.mjs.map +1 -0
  64. package/dist/es/test-runner/reporting/execution-record.mjs +73 -0
  65. package/dist/es/test-runner/reporting/execution-record.mjs.map +1 -0
  66. package/dist/es/test-runner/reporting/merge-report.mjs +231 -0
  67. package/dist/es/test-runner/reporting/merge-report.mjs.map +1 -0
  68. package/dist/es/test-runner/reporting/sanitize.mjs +162 -0
  69. package/dist/es/test-runner/reporting/sanitize.mjs.map +1 -0
  70. package/dist/es/test-runner/reporting/test-run-report.mjs +327 -0
  71. package/dist/es/test-runner/reporting/test-run-report.mjs.map +1 -0
  72. package/dist/es/test-runner/reporting/types.mjs +0 -0
  73. package/dist/es/utils.mjs +1 -1
  74. package/dist/es/yaml/execution-context.node.mjs +6 -0
  75. package/dist/es/yaml/execution-context.node.mjs.map +1 -0
  76. package/dist/es/yaml/execution-context.stub.mjs +8 -0
  77. package/dist/es/yaml/execution-context.stub.mjs.map +1 -0
  78. package/dist/es/yaml/execution-session.mjs +90 -0
  79. package/dist/es/yaml/execution-session.mjs.map +1 -0
  80. package/dist/es/yaml/index.mjs +2 -1
  81. package/dist/es/yaml/legacy-yaml-execution-record.mjs +47 -0
  82. package/dist/es/yaml/legacy-yaml-execution-record.mjs.map +1 -0
  83. package/dist/es/yaml/legacy-yaml-report.mjs +52 -0
  84. package/dist/es/yaml/legacy-yaml-report.mjs.map +1 -0
  85. package/dist/es/yaml/legacy-yaml-runtime.mjs +119 -0
  86. package/dist/es/yaml/legacy-yaml-runtime.mjs.map +1 -0
  87. package/dist/es/yaml/player-state.mjs +15 -0
  88. package/dist/es/yaml/player-state.mjs.map +1 -0
  89. package/dist/es/yaml/player.mjs +214 -348
  90. package/dist/es/yaml/player.mjs.map +1 -1
  91. package/dist/es/yaml/report-policy.mjs +7 -0
  92. package/dist/es/yaml/report-policy.mjs.map +1 -0
  93. package/dist/es/yaml/test-runner-compat.mjs +301 -0
  94. package/dist/es/yaml/test-runner-compat.mjs.map +1 -0
  95. package/dist/es/yaml/test-runner-nodes.mjs +147 -0
  96. package/dist/es/yaml/test-runner-nodes.mjs.map +1 -0
  97. package/dist/es/yaml/utils.mjs +12 -1
  98. package/dist/es/yaml/utils.mjs.map +1 -1
  99. package/dist/es/yaml-runtime.mjs +7 -0
  100. package/dist/es/yaml.mjs.map +1 -1
  101. package/dist/lib/agent/agent.js +103 -6
  102. package/dist/lib/agent/agent.js.map +1 -1
  103. package/dist/lib/agent/index.js +37 -3
  104. package/dist/lib/agent/tasks.js +2 -2
  105. package/dist/lib/agent/tasks.js.map +1 -1
  106. package/dist/lib/agent/test-runner-nodes.js +329 -45
  107. package/dist/lib/agent/test-runner-nodes.js.map +1 -1
  108. package/dist/lib/agent/utils.js +1 -1
  109. package/dist/lib/device/index.js +15 -2
  110. package/dist/lib/device/index.js.map +1 -1
  111. package/dist/lib/dump/html-utils.js +43 -4
  112. package/dist/lib/dump/html-utils.js.map +1 -1
  113. package/dist/lib/dump/screenshot-store.js +8 -1
  114. package/dist/lib/dump/screenshot-store.js.map +1 -1
  115. package/dist/lib/report-cli.js +8 -3
  116. package/dist/lib/report-cli.js.map +1 -1
  117. package/dist/lib/report-generator.js +114 -1
  118. package/dist/lib/report-generator.js.map +1 -1
  119. package/dist/lib/report-html-template.js +1 -1
  120. package/dist/lib/report.js +187 -38
  121. package/dist/lib/report.js.map +1 -1
  122. package/dist/lib/test-run-report.js.map +1 -1
  123. package/dist/lib/test-runner/engine/case-runner.js +89 -0
  124. package/dist/lib/test-runner/engine/case-runner.js.map +1 -0
  125. package/dist/lib/test-runner/engine/document-runtime.js +307 -0
  126. package/dist/lib/test-runner/engine/document-runtime.js.map +1 -0
  127. package/dist/lib/test-runner/engine/execute-step.js +211 -0
  128. package/dist/lib/test-runner/engine/execute-step.js.map +1 -0
  129. package/dist/lib/test-runner/engine/execution-failure.js +79 -0
  130. package/dist/lib/test-runner/engine/execution-failure.js.map +1 -0
  131. package/dist/lib/test-runner/engine/index.js +137 -0
  132. package/dist/lib/test-runner/engine/index.js.map +1 -0
  133. package/dist/lib/test-runner/engine/project-runtime.js +176 -0
  134. package/dist/lib/test-runner/engine/project-runtime.js.map +1 -0
  135. package/dist/lib/test-runner/engine/registry.js +95 -0
  136. package/dist/lib/test-runner/engine/registry.js.map +1 -0
  137. package/dist/lib/test-runner/engine/resource-operations.js +272 -0
  138. package/dist/lib/test-runner/engine/resource-operations.js.map +1 -0
  139. package/dist/lib/test-runner/engine/run-collected-case.js +227 -0
  140. package/dist/lib/test-runner/engine/run-collected-case.js.map +1 -0
  141. package/dist/lib/test-runner/engine/run-workflow-document.js +189 -0
  142. package/dist/lib/test-runner/engine/run-workflow-document.js.map +1 -0
  143. package/dist/lib/test-runner/engine/scheduler.js +64 -0
  144. package/dist/lib/test-runner/engine/scheduler.js.map +1 -0
  145. package/dist/lib/test-runner/engine/scope-teardown.js +50 -0
  146. package/dist/lib/test-runner/engine/scope-teardown.js.map +1 -0
  147. package/dist/lib/test-runner/engine/types.js +20 -0
  148. package/dist/lib/test-runner/engine/types.js.map +1 -0
  149. package/dist/lib/test-runner/errors.js +283 -0
  150. package/dist/lib/test-runner/errors.js.map +1 -0
  151. package/dist/lib/test-runner/execution-record.js +123 -0
  152. package/dist/lib/test-runner/execution-record.js.map +1 -0
  153. package/dist/lib/test-runner/index.js +137 -0
  154. package/dist/lib/test-runner/index.js.map +1 -0
  155. package/dist/lib/test-runner/node/define-node.js +78 -0
  156. package/dist/lib/test-runner/node/define-node.js.map +1 -0
  157. package/dist/lib/test-runner/node/index.js +67 -0
  158. package/dist/lib/test-runner/node/index.js.map +1 -0
  159. package/dist/lib/test-runner/node/types.js +20 -0
  160. package/dist/lib/test-runner/node/types.js.map +1 -0
  161. package/dist/lib/test-runner/parser/document-format.js +58 -0
  162. package/dist/lib/test-runner/parser/document-format.js.map +1 -0
  163. package/dist/lib/test-runner/parser/normalize.js +124 -0
  164. package/dist/lib/test-runner/parser/normalize.js.map +1 -0
  165. package/dist/lib/test-runner/parser/types.js +20 -0
  166. package/dist/lib/test-runner/parser/types.js.map +1 -0
  167. package/dist/lib/test-runner/project.js +20 -0
  168. package/dist/lib/test-runner/project.js.map +1 -0
  169. package/dist/lib/test-runner/reporting/agent-report.js +57 -0
  170. package/dist/lib/test-runner/reporting/agent-report.js.map +1 -0
  171. package/dist/lib/test-runner/reporting/execution-record.js +107 -0
  172. package/dist/lib/test-runner/reporting/execution-record.js.map +1 -0
  173. package/dist/lib/test-runner/reporting/merge-report.js +265 -0
  174. package/dist/lib/test-runner/reporting/merge-report.js.map +1 -0
  175. package/dist/lib/test-runner/reporting/sanitize.js +202 -0
  176. package/dist/lib/test-runner/reporting/sanitize.js.map +1 -0
  177. package/dist/lib/test-runner/reporting/test-run-report.js +364 -0
  178. package/dist/lib/test-runner/reporting/test-run-report.js.map +1 -0
  179. package/dist/lib/test-runner/reporting/types.js +20 -0
  180. package/dist/lib/test-runner/reporting/types.js.map +1 -0
  181. package/dist/lib/utils.js +1 -1
  182. package/dist/lib/yaml/execution-context.node.js +43 -0
  183. package/dist/lib/yaml/execution-context.node.js.map +1 -0
  184. package/dist/lib/yaml/execution-context.stub.js +45 -0
  185. package/dist/lib/yaml/execution-context.stub.js.map +1 -0
  186. package/dist/lib/yaml/execution-session.js +136 -0
  187. package/dist/lib/yaml/execution-session.js.map +1 -0
  188. package/dist/lib/yaml/index.js +49 -7
  189. package/dist/lib/yaml/legacy-yaml-execution-record.js +81 -0
  190. package/dist/lib/yaml/legacy-yaml-execution-record.js.map +1 -0
  191. package/dist/lib/yaml/legacy-yaml-report.js +86 -0
  192. package/dist/lib/yaml/legacy-yaml-report.js.map +1 -0
  193. package/dist/lib/yaml/legacy-yaml-runtime.js +156 -0
  194. package/dist/lib/yaml/legacy-yaml-runtime.js.map +1 -0
  195. package/dist/lib/yaml/player-state.js +52 -0
  196. package/dist/lib/yaml/player-state.js.map +1 -0
  197. package/dist/lib/yaml/player.js +213 -347
  198. package/dist/lib/yaml/player.js.map +1 -1
  199. package/dist/lib/yaml/report-policy.js +41 -0
  200. package/dist/lib/yaml/report-policy.js.map +1 -0
  201. package/dist/lib/yaml/test-runner-compat.js +344 -0
  202. package/dist/lib/yaml/test-runner-compat.js.map +1 -0
  203. package/dist/lib/yaml/test-runner-nodes.js +184 -0
  204. package/dist/lib/yaml/test-runner-nodes.js.map +1 -0
  205. package/dist/lib/yaml/utils.js +18 -1
  206. package/dist/lib/yaml/utils.js.map +1 -1
  207. package/dist/lib/yaml-runtime.js +67 -0
  208. package/dist/lib/yaml-runtime.js.map +1 -0
  209. package/dist/lib/yaml.js.map +1 -1
  210. package/dist/types/agent/agent.d.ts +14 -1
  211. package/dist/types/agent/agent.d.ts.map +1 -1
  212. package/dist/types/agent/index.d.ts +4 -3
  213. package/dist/types/agent/index.d.ts.map +1 -1
  214. package/dist/types/agent/tasks.d.ts +1 -1
  215. package/dist/types/agent/tasks.d.ts.map +1 -1
  216. package/dist/types/agent/test-runner-nodes.d.ts +226 -0
  217. package/dist/types/agent/test-runner-nodes.d.ts.map +1 -1
  218. package/dist/types/device/index.d.ts +1 -1
  219. package/dist/types/device/index.d.ts.map +1 -1
  220. package/dist/types/dump/html-utils.d.ts +4 -0
  221. package/dist/types/dump/html-utils.d.ts.map +1 -1
  222. package/dist/types/dump/screenshot-store.d.ts +2 -1
  223. package/dist/types/dump/screenshot-store.d.ts.map +1 -1
  224. package/dist/types/report-cli.d.ts.map +1 -1
  225. package/dist/types/report-generator.d.ts +10 -0
  226. package/dist/types/report-generator.d.ts.map +1 -1
  227. package/dist/types/report.d.ts +3 -1
  228. package/dist/types/report.d.ts.map +1 -1
  229. package/dist/types/test-run-report.d.ts +18 -2
  230. package/dist/types/test-run-report.d.ts.map +1 -1
  231. package/dist/types/test-runner/engine/case-runner.d.ts +13 -0
  232. package/dist/types/test-runner/engine/case-runner.d.ts.map +1 -0
  233. package/dist/types/test-runner/engine/document-runtime.d.ts +4 -0
  234. package/dist/types/test-runner/engine/document-runtime.d.ts.map +1 -0
  235. package/dist/types/test-runner/engine/execute-step.d.ts +17 -0
  236. package/dist/types/test-runner/engine/execute-step.d.ts.map +1 -0
  237. package/dist/types/test-runner/engine/execution-failure.d.ts +13 -0
  238. package/dist/types/test-runner/engine/execution-failure.d.ts.map +1 -0
  239. package/dist/types/test-runner/engine/index.d.ts +13 -0
  240. package/dist/types/test-runner/engine/index.d.ts.map +1 -0
  241. package/dist/types/test-runner/engine/project-runtime.d.ts +3 -0
  242. package/dist/types/test-runner/engine/project-runtime.d.ts.map +1 -0
  243. package/dist/types/test-runner/engine/registry.d.ts +12 -0
  244. package/dist/types/test-runner/engine/registry.d.ts.map +1 -0
  245. package/dist/types/test-runner/engine/resource-operations.d.ts +32 -0
  246. package/dist/types/test-runner/engine/resource-operations.d.ts.map +1 -0
  247. package/dist/types/test-runner/engine/run-collected-case.d.ts +4 -0
  248. package/dist/types/test-runner/engine/run-collected-case.d.ts.map +1 -0
  249. package/dist/types/test-runner/engine/run-workflow-document.d.ts +4 -0
  250. package/dist/types/test-runner/engine/run-workflow-document.d.ts.map +1 -0
  251. package/dist/types/test-runner/engine/scheduler.d.ts +12 -0
  252. package/dist/types/test-runner/engine/scheduler.d.ts.map +1 -0
  253. package/dist/types/test-runner/engine/scope-teardown.d.ts +3 -0
  254. package/dist/types/test-runner/engine/scope-teardown.d.ts.map +1 -0
  255. package/dist/types/test-runner/engine/types.d.ts +226 -0
  256. package/dist/types/test-runner/engine/types.d.ts.map +1 -0
  257. package/dist/types/test-runner/errors.d.ts +79 -0
  258. package/dist/types/test-runner/errors.d.ts.map +1 -0
  259. package/dist/types/test-runner/execution-record.d.ts +43 -0
  260. package/dist/types/test-runner/execution-record.d.ts.map +1 -0
  261. package/dist/types/test-runner/index.d.ts +20 -0
  262. package/dist/types/test-runner/index.d.ts.map +1 -0
  263. package/dist/types/test-runner/node/define-node.d.ts +4 -0
  264. package/dist/types/test-runner/node/define-node.d.ts.map +1 -0
  265. package/dist/types/test-runner/node/index.d.ts +3 -0
  266. package/dist/types/test-runner/node/index.d.ts.map +1 -0
  267. package/dist/types/test-runner/node/types.d.ts +66 -0
  268. package/dist/types/test-runner/node/types.d.ts.map +1 -0
  269. package/dist/types/test-runner/parser/document-format.d.ts +8 -0
  270. package/dist/types/test-runner/parser/document-format.d.ts.map +1 -0
  271. package/dist/types/test-runner/parser/normalize.d.ts +9 -0
  272. package/dist/types/test-runner/parser/normalize.d.ts.map +1 -0
  273. package/dist/types/test-runner/parser/types.d.ts +69 -0
  274. package/dist/types/test-runner/parser/types.d.ts.map +1 -0
  275. package/dist/types/test-runner/project.d.ts +75 -0
  276. package/dist/types/test-runner/project.d.ts.map +1 -0
  277. package/dist/types/test-runner/reporting/agent-report.d.ts +9 -0
  278. package/dist/types/test-runner/reporting/agent-report.d.ts.map +1 -0
  279. package/dist/types/test-runner/reporting/execution-record.d.ts +9 -0
  280. package/dist/types/test-runner/reporting/execution-record.d.ts.map +1 -0
  281. package/dist/types/test-runner/reporting/merge-report.d.ts +15 -0
  282. package/dist/types/test-runner/reporting/merge-report.d.ts.map +1 -0
  283. package/dist/types/test-runner/reporting/sanitize.d.ts +6 -0
  284. package/dist/types/test-runner/reporting/sanitize.d.ts.map +1 -0
  285. package/dist/types/test-runner/reporting/test-run-report.d.ts +5 -0
  286. package/dist/types/test-runner/reporting/test-run-report.d.ts.map +1 -0
  287. package/dist/types/test-runner/reporting/types.d.ts +34 -0
  288. package/dist/types/test-runner/reporting/types.d.ts.map +1 -0
  289. package/dist/types/yaml/execution-context.node.d.ts +4 -0
  290. package/dist/types/yaml/execution-context.node.d.ts.map +1 -0
  291. package/dist/types/yaml/execution-context.stub.d.ts +6 -0
  292. package/dist/types/yaml/execution-context.stub.d.ts.map +1 -0
  293. package/dist/types/yaml/execution-session.d.ts +17 -0
  294. package/dist/types/yaml/execution-session.d.ts.map +1 -0
  295. package/dist/types/yaml/index.d.ts +1 -1
  296. package/dist/types/yaml/index.d.ts.map +1 -1
  297. package/dist/types/yaml/legacy-yaml-execution-record.d.ts +24 -0
  298. package/dist/types/yaml/legacy-yaml-execution-record.d.ts.map +1 -0
  299. package/dist/types/yaml/legacy-yaml-report.d.ts +19 -0
  300. package/dist/types/yaml/legacy-yaml-report.d.ts.map +1 -0
  301. package/dist/types/yaml/legacy-yaml-runtime.d.ts +23 -0
  302. package/dist/types/yaml/legacy-yaml-runtime.d.ts.map +1 -0
  303. package/dist/types/yaml/player-state.d.ts +11 -0
  304. package/dist/types/yaml/player-state.d.ts.map +1 -0
  305. package/dist/types/yaml/player.d.ts +11 -3
  306. package/dist/types/yaml/player.d.ts.map +1 -1
  307. package/dist/types/yaml/report-policy.d.ts +4 -0
  308. package/dist/types/yaml/report-policy.d.ts.map +1 -0
  309. package/dist/types/yaml/test-runner-compat.d.ts +17 -0
  310. package/dist/types/yaml/test-runner-compat.d.ts.map +1 -0
  311. package/dist/types/yaml/test-runner-nodes.d.ts +6 -0
  312. package/dist/types/yaml/test-runner-nodes.d.ts.map +1 -0
  313. package/dist/types/yaml/utils.d.ts +9 -0
  314. package/dist/types/yaml/utils.d.ts.map +1 -1
  315. package/dist/types/yaml-runtime.d.ts +13 -0
  316. package/dist/types/yaml-runtime.d.ts.map +1 -0
  317. package/dist/types/yaml.d.ts +25 -7
  318. package/dist/types/yaml.d.ts.map +1 -1
  319. package/package.json +28 -2
@@ -2,9 +2,14 @@ import { getModelRuntime } from "../ai-model/models/index.mjs";
2
2
  import { INTERNAL_CALL_ID_FIELD } from "../ai-model/service-caller/index.mjs";
3
3
  import { IS_REPORT_BUILD } from "../constants.mjs";
4
4
  import js_yaml from "js-yaml";
5
+ import { generateTestRunReportScriptTag } from "../dump/html-utils.mjs";
5
6
  import { ScreenshotItem } from "../screenshot-item.mjs";
6
7
  import service from "../service/index.mjs";
8
+ import { waitForResourceIdle } from "../test-runner/engine/resource-operations.mjs";
9
+ import { buildAgentTestRunReportDump } from "../test-runner/reporting/agent-report.mjs";
10
+ import { executionRecordsToReportInput } from "../test-runner/reporting/execution-record.mjs";
7
11
  import { ExecutionDump, ReportActionDump } from "../types.mjs";
12
+ import { YamlExecutionOwnershipError, enterYamlAction, enterYamlExecution, runInYamlExecutionContext } from "../yaml/execution-session.mjs";
8
13
  import { ReportGenerator, assertReportGenerationOptions } from "../report-generator.mjs";
9
14
  import { getVersion, processCacheConfig, reportHTMLContent } from "../utils.mjs";
10
15
  import { ScriptPlayer, buildDetailedLocateParam, buildDetailedLocateParamAndRestParams, parseYamlScript } from "../yaml/index.mjs";
@@ -61,6 +66,60 @@ class Agent {
61
66
  static getTestRunnerNodeDefinitions() {
62
67
  return commonAgentTestRunnerNodeDefinitions;
63
68
  }
69
+ _prepareForTestRunner() {
70
+ this.reportGenerator.enableSourceSnapshots?.();
71
+ }
72
+ async _createReportSource(scopeId) {
73
+ return this.reportGenerator.createSourceSnapshot?.(scopeId);
74
+ }
75
+ async _writeYamlExecutionReport(record) {
76
+ const existingIndex = this.yamlExecutionRecords.findIndex((entry)=>entry.runId === record.runId);
77
+ const recordIndex = existingIndex < 0 ? this.yamlExecutionRecords.length : existingIndex;
78
+ this.yamlExecutionRecords[recordIndex] = record;
79
+ try {
80
+ const path = await this.reportGenerator.writeRunnerReport?.(this.buildYamlReportInput(), this.yamlReportScopeId, this.getReportMeta());
81
+ this.reportFile = path ?? this.reportFile;
82
+ return path;
83
+ } catch (error) {
84
+ this.yamlExecutionRecords[recordIndex] = Object.freeze({
85
+ ...record,
86
+ status: 'failed',
87
+ reportError: error
88
+ });
89
+ throw error;
90
+ }
91
+ }
92
+ buildYamlReportInput() {
93
+ const scopedRecords = this.yamlExecutionRecords.map((entry)=>({
94
+ ...entry,
95
+ ...entry.execution ? {
96
+ execution: {
97
+ document: {
98
+ ...entry.execution.document,
99
+ reportScopeId: this.yamlReportScopeId
100
+ },
101
+ cases: entry.execution.cases.map((outcome)=>({
102
+ ...outcome,
103
+ ...outcome.run ? {
104
+ run: {
105
+ ...outcome.run,
106
+ reportScopeId: this.yamlReportScopeId
107
+ }
108
+ } : {},
109
+ ...outcome.attempts ? {
110
+ attempts: outcome.attempts.map((attempt)=>({
111
+ ...attempt,
112
+ reportScopeId: this.yamlReportScopeId
113
+ }))
114
+ } : {}
115
+ }))
116
+ }
117
+ } : {}
118
+ }));
119
+ return executionRecordsToReportInput(scopedRecords, {
120
+ runId: this.yamlReportScopeId
121
+ });
122
+ }
64
123
  get onDumpUpdate() {
65
124
  return this.dumpUpdateListeners[0];
66
125
  }
@@ -247,7 +306,21 @@ class Agent {
247
306
  }
248
307
  reportHTMLString(opt) {
249
308
  if (IS_REPORT_BUILD) return '';
250
- return reportHTMLContent(this.dumpDataString(opt));
309
+ const dumpString = this.dumpDataString(opt);
310
+ if (!this.yamlExecutionRecords.length) return reportHTMLContent(dumpString);
311
+ const reportId = this.yamlReportScopeId;
312
+ const runnerDump = buildAgentTestRunReportDump(this.buildYamlReportInput(), this.dump, {
313
+ reportId,
314
+ scopeId: this.yamlReportScopeId,
315
+ sourcePath: this.reportFile ?? '<inline-agent-report>'
316
+ });
317
+ return `${reportHTMLContent({
318
+ dumpString,
319
+ attributes: {
320
+ 'data-group-id': reportId,
321
+ 'data-report-id': reportId
322
+ }
323
+ })}\n${generateTestRunReportScriptTag(runnerDump)}`;
251
324
  }
252
325
  writeOutActionDumps(executionDump) {
253
326
  const exec = executionDump || this.lastExecutionDump;
@@ -257,6 +330,11 @@ class Agent {
257
330
  }
258
331
  this.reportFile = this.reportGenerator.getReportPath();
259
332
  }
333
+ async flushReport() {
334
+ this.writeOutActionDumps();
335
+ await this.reportGenerator.flush();
336
+ return this.lastExecutionDump ? this.reportFile ?? void 0 : void 0;
337
+ }
260
338
  getReportMeta() {
261
339
  return {
262
340
  groupName: this.dump.groupName,
@@ -276,9 +354,12 @@ class Agent {
276
354
  }
277
355
  async callActionInActionSpace(type, opt) {
278
356
  debug('callActionInActionSpace', type, ',', opt);
357
+ const clonedActionParam = opt && 'object' == typeof opt && !Array.isArray(opt) ? {
358
+ ...opt
359
+ } : opt || {};
279
360
  const actionPlan = {
280
361
  type: type,
281
- param: opt || {},
362
+ param: clonedActionParam,
282
363
  thought: ''
283
364
  };
284
365
  debug('actionPlan', actionPlan);
@@ -442,7 +523,7 @@ class Agent {
442
523
  const cachePrompt = buildPromptWithContext(taskPrompt, aiActContext);
443
524
  const effort = (()=>{
444
525
  const resolvedEffort = opt?.effort ?? (opt?.deepThink === true ? 'deepThink' : 'balance');
445
- if (opt?.effort !== void 0) warn('The "effort" option is experimental and not yet open for public use. Do not use it. When both "effort" and "deepThink" are provided, "effort" takes precedence.');
526
+ if (opt?.effort !== void 0 && void 0 !== opt.deepThink) warn('When both "effort" and "deepThink" are provided, "effort" takes precedence.');
446
527
  if ('fast' === resolvedEffort && 'custom' === planningModel.adapter.planning.kind) throw new Error(`The "fast" aiAct effort is not supported with custom planning adapters (modelFamily: ${planningModel.config.modelFamily ?? 'unknown'}).`);
447
528
  if ('deepThink' === resolvedEffort && 'custom' === planningModel.adapter.planning.kind) {
448
529
  warn(`The "deepThink" aiAct effort is not supported with custom planning adapters (modelFamily: ${planningModel.config.modelFamily ?? 'unknown'}). It will be ignored.`);
@@ -465,9 +546,20 @@ class Agent {
465
546
  try {
466
547
  await this.taskExecutor.loadYamlFlowAsPlanning(taskPrompt, yaml, internalReportDisplay);
467
548
  debug('matched cache, will call .runYaml to run the action');
468
- await this.runYaml(yaml);
549
+ await runInYamlExecutionContext(async ()=>{
550
+ const replay = enterYamlExecution(this);
551
+ const leaveAction = abortSignal ? enterYamlAction(this, abortSignal) : void 0;
552
+ try {
553
+ await this.runYaml(yaml);
554
+ } finally{
555
+ leaveAction?.();
556
+ replay.finish();
557
+ }
558
+ });
469
559
  return;
470
560
  } catch (error) {
561
+ if (error instanceof YamlExecutionOwnershipError) throw error;
562
+ abortSignal?.throwIfAborted();
471
563
  cachedYamlFailed = true;
472
564
  warn(`cached aiAct plan failed, will replan and disable the stale cache: ${error instanceof Error ? error.message : String(error)}`);
473
565
  }
@@ -595,6 +687,7 @@ class Agent {
595
687
  return this.aiAct(...args);
596
688
  }
597
689
  async runYaml(yamlScriptContent) {
690
+ if (this.destroyed) throw new Error('Cannot run YAML using a destroyed Agent.');
598
691
  const script = parseYamlScript(yamlScriptContent, 'yaml');
599
692
  const player = new ScriptPlayer(script, async ()=>({
600
693
  agent: this,
@@ -646,6 +739,7 @@ class Agent {
646
739
  async destroy() {
647
740
  if (this.destroyed) return;
648
741
  this.destroyed = true;
742
+ await waitForResourceIdle(this);
649
743
  for (const observer of this.ownedObservers)try {
650
744
  await observer.dispose();
651
745
  } catch (error) {
@@ -665,8 +759,9 @@ class Agent {
665
759
  this.resetDump();
666
760
  if (interfaceDestroyError) throw interfaceDestroyError;
667
761
  }
668
- async sleep(ms) {
669
- await this.taskExecutor.sleep(ms);
762
+ async sleep(ms, options) {
763
+ options?.abortSignal?.throwIfAborted();
764
+ await this.taskExecutor.sleep(ms, options?.abortSignal);
670
765
  }
671
766
  async recordToReport(title, opt) {
672
767
  const now = Date.now();
@@ -830,6 +925,8 @@ class Agent {
830
925
  _define_property(this, "dump", void 0);
831
926
  _define_property(this, "reportFile", void 0);
832
927
  _define_property(this, "reportFileName", void 0);
928
+ _define_property(this, "yamlReportScopeId", uuid());
929
+ _define_property(this, "yamlExecutionRecords", []);
833
930
  _define_property(this, "taskExecutor", void 0);
834
931
  _define_property(this, "opts", void 0);
835
932
  _define_property(this, "dryMode", false);