@midscene/core 1.12.10-beta-20260920072249.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 (329) hide show
  1. package/dist/es/agent/agent.mjs +104 -8
  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 +9 -62
  5. package/dist/es/agent/tasks.mjs.map +1 -1
  6. package/dist/es/agent/test-runner-nodes.mjs +292 -42
  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/types.mjs.map +1 -1
  74. package/dist/es/utils.mjs +1 -1
  75. package/dist/es/yaml/execution-context.node.mjs +6 -0
  76. package/dist/es/yaml/execution-context.node.mjs.map +1 -0
  77. package/dist/es/yaml/execution-context.stub.mjs +8 -0
  78. package/dist/es/yaml/execution-context.stub.mjs.map +1 -0
  79. package/dist/es/yaml/execution-session.mjs +90 -0
  80. package/dist/es/yaml/execution-session.mjs.map +1 -0
  81. package/dist/es/yaml/index.mjs +2 -1
  82. package/dist/es/yaml/legacy-yaml-execution-record.mjs +47 -0
  83. package/dist/es/yaml/legacy-yaml-execution-record.mjs.map +1 -0
  84. package/dist/es/yaml/legacy-yaml-report.mjs +52 -0
  85. package/dist/es/yaml/legacy-yaml-report.mjs.map +1 -0
  86. package/dist/es/yaml/legacy-yaml-runtime.mjs +119 -0
  87. package/dist/es/yaml/legacy-yaml-runtime.mjs.map +1 -0
  88. package/dist/es/yaml/player-state.mjs +15 -0
  89. package/dist/es/yaml/player-state.mjs.map +1 -0
  90. package/dist/es/yaml/player.mjs +214 -348
  91. package/dist/es/yaml/player.mjs.map +1 -1
  92. package/dist/es/yaml/report-policy.mjs +7 -0
  93. package/dist/es/yaml/report-policy.mjs.map +1 -0
  94. package/dist/es/yaml/test-runner-compat.mjs +301 -0
  95. package/dist/es/yaml/test-runner-compat.mjs.map +1 -0
  96. package/dist/es/yaml/test-runner-nodes.mjs +147 -0
  97. package/dist/es/yaml/test-runner-nodes.mjs.map +1 -0
  98. package/dist/es/yaml/utils.mjs +12 -1
  99. package/dist/es/yaml/utils.mjs.map +1 -1
  100. package/dist/es/yaml-runtime.mjs +7 -0
  101. package/dist/es/yaml.mjs.map +1 -1
  102. package/dist/lib/agent/agent.js +104 -8
  103. package/dist/lib/agent/agent.js.map +1 -1
  104. package/dist/lib/agent/index.js +37 -3
  105. package/dist/lib/agent/tasks.js +9 -62
  106. package/dist/lib/agent/tasks.js.map +1 -1
  107. package/dist/lib/agent/test-runner-nodes.js +330 -47
  108. package/dist/lib/agent/test-runner-nodes.js.map +1 -1
  109. package/dist/lib/agent/utils.js +1 -1
  110. package/dist/lib/device/index.js +15 -2
  111. package/dist/lib/device/index.js.map +1 -1
  112. package/dist/lib/dump/html-utils.js +43 -4
  113. package/dist/lib/dump/html-utils.js.map +1 -1
  114. package/dist/lib/dump/screenshot-store.js +8 -1
  115. package/dist/lib/dump/screenshot-store.js.map +1 -1
  116. package/dist/lib/report-cli.js +8 -3
  117. package/dist/lib/report-cli.js.map +1 -1
  118. package/dist/lib/report-generator.js +114 -1
  119. package/dist/lib/report-generator.js.map +1 -1
  120. package/dist/lib/report-html-template.js +1 -1
  121. package/dist/lib/report.js +187 -38
  122. package/dist/lib/report.js.map +1 -1
  123. package/dist/lib/test-run-report.js.map +1 -1
  124. package/dist/lib/test-runner/engine/case-runner.js +89 -0
  125. package/dist/lib/test-runner/engine/case-runner.js.map +1 -0
  126. package/dist/lib/test-runner/engine/document-runtime.js +307 -0
  127. package/dist/lib/test-runner/engine/document-runtime.js.map +1 -0
  128. package/dist/lib/test-runner/engine/execute-step.js +211 -0
  129. package/dist/lib/test-runner/engine/execute-step.js.map +1 -0
  130. package/dist/lib/test-runner/engine/execution-failure.js +79 -0
  131. package/dist/lib/test-runner/engine/execution-failure.js.map +1 -0
  132. package/dist/lib/test-runner/engine/index.js +137 -0
  133. package/dist/lib/test-runner/engine/index.js.map +1 -0
  134. package/dist/lib/test-runner/engine/project-runtime.js +176 -0
  135. package/dist/lib/test-runner/engine/project-runtime.js.map +1 -0
  136. package/dist/lib/test-runner/engine/registry.js +95 -0
  137. package/dist/lib/test-runner/engine/registry.js.map +1 -0
  138. package/dist/lib/test-runner/engine/resource-operations.js +272 -0
  139. package/dist/lib/test-runner/engine/resource-operations.js.map +1 -0
  140. package/dist/lib/test-runner/engine/run-collected-case.js +227 -0
  141. package/dist/lib/test-runner/engine/run-collected-case.js.map +1 -0
  142. package/dist/lib/test-runner/engine/run-workflow-document.js +189 -0
  143. package/dist/lib/test-runner/engine/run-workflow-document.js.map +1 -0
  144. package/dist/lib/test-runner/engine/scheduler.js +64 -0
  145. package/dist/lib/test-runner/engine/scheduler.js.map +1 -0
  146. package/dist/lib/test-runner/engine/scope-teardown.js +50 -0
  147. package/dist/lib/test-runner/engine/scope-teardown.js.map +1 -0
  148. package/dist/lib/test-runner/engine/types.js +20 -0
  149. package/dist/lib/test-runner/engine/types.js.map +1 -0
  150. package/dist/lib/test-runner/errors.js +283 -0
  151. package/dist/lib/test-runner/errors.js.map +1 -0
  152. package/dist/lib/test-runner/execution-record.js +123 -0
  153. package/dist/lib/test-runner/execution-record.js.map +1 -0
  154. package/dist/lib/test-runner/index.js +137 -0
  155. package/dist/lib/test-runner/index.js.map +1 -0
  156. package/dist/lib/test-runner/node/define-node.js +78 -0
  157. package/dist/lib/test-runner/node/define-node.js.map +1 -0
  158. package/dist/lib/test-runner/node/index.js +67 -0
  159. package/dist/lib/test-runner/node/index.js.map +1 -0
  160. package/dist/lib/test-runner/node/types.js +20 -0
  161. package/dist/lib/test-runner/node/types.js.map +1 -0
  162. package/dist/lib/test-runner/parser/document-format.js +58 -0
  163. package/dist/lib/test-runner/parser/document-format.js.map +1 -0
  164. package/dist/lib/test-runner/parser/normalize.js +124 -0
  165. package/dist/lib/test-runner/parser/normalize.js.map +1 -0
  166. package/dist/lib/test-runner/parser/types.js +20 -0
  167. package/dist/lib/test-runner/parser/types.js.map +1 -0
  168. package/dist/lib/test-runner/project.js +20 -0
  169. package/dist/lib/test-runner/project.js.map +1 -0
  170. package/dist/lib/test-runner/reporting/agent-report.js +57 -0
  171. package/dist/lib/test-runner/reporting/agent-report.js.map +1 -0
  172. package/dist/lib/test-runner/reporting/execution-record.js +107 -0
  173. package/dist/lib/test-runner/reporting/execution-record.js.map +1 -0
  174. package/dist/lib/test-runner/reporting/merge-report.js +265 -0
  175. package/dist/lib/test-runner/reporting/merge-report.js.map +1 -0
  176. package/dist/lib/test-runner/reporting/sanitize.js +202 -0
  177. package/dist/lib/test-runner/reporting/sanitize.js.map +1 -0
  178. package/dist/lib/test-runner/reporting/test-run-report.js +364 -0
  179. package/dist/lib/test-runner/reporting/test-run-report.js.map +1 -0
  180. package/dist/lib/test-runner/reporting/types.js +20 -0
  181. package/dist/lib/test-runner/reporting/types.js.map +1 -0
  182. package/dist/lib/types.js.map +1 -1
  183. package/dist/lib/utils.js +1 -1
  184. package/dist/lib/yaml/execution-context.node.js +43 -0
  185. package/dist/lib/yaml/execution-context.node.js.map +1 -0
  186. package/dist/lib/yaml/execution-context.stub.js +45 -0
  187. package/dist/lib/yaml/execution-context.stub.js.map +1 -0
  188. package/dist/lib/yaml/execution-session.js +136 -0
  189. package/dist/lib/yaml/execution-session.js.map +1 -0
  190. package/dist/lib/yaml/index.js +49 -7
  191. package/dist/lib/yaml/legacy-yaml-execution-record.js +81 -0
  192. package/dist/lib/yaml/legacy-yaml-execution-record.js.map +1 -0
  193. package/dist/lib/yaml/legacy-yaml-report.js +86 -0
  194. package/dist/lib/yaml/legacy-yaml-report.js.map +1 -0
  195. package/dist/lib/yaml/legacy-yaml-runtime.js +156 -0
  196. package/dist/lib/yaml/legacy-yaml-runtime.js.map +1 -0
  197. package/dist/lib/yaml/player-state.js +52 -0
  198. package/dist/lib/yaml/player-state.js.map +1 -0
  199. package/dist/lib/yaml/player.js +213 -347
  200. package/dist/lib/yaml/player.js.map +1 -1
  201. package/dist/lib/yaml/report-policy.js +41 -0
  202. package/dist/lib/yaml/report-policy.js.map +1 -0
  203. package/dist/lib/yaml/test-runner-compat.js +344 -0
  204. package/dist/lib/yaml/test-runner-compat.js.map +1 -0
  205. package/dist/lib/yaml/test-runner-nodes.js +184 -0
  206. package/dist/lib/yaml/test-runner-nodes.js.map +1 -0
  207. package/dist/lib/yaml/utils.js +18 -1
  208. package/dist/lib/yaml/utils.js.map +1 -1
  209. package/dist/lib/yaml-runtime.js +67 -0
  210. package/dist/lib/yaml-runtime.js.map +1 -0
  211. package/dist/lib/yaml.js.map +1 -1
  212. package/dist/types/agent/agent.d.ts +14 -2
  213. package/dist/types/agent/agent.d.ts.map +1 -1
  214. package/dist/types/agent/index.d.ts +4 -3
  215. package/dist/types/agent/index.d.ts.map +1 -1
  216. package/dist/types/agent/tasks.d.ts +2 -2
  217. package/dist/types/agent/tasks.d.ts.map +1 -1
  218. package/dist/types/agent/test-runner-nodes.d.ts +228 -2
  219. package/dist/types/agent/test-runner-nodes.d.ts.map +1 -1
  220. package/dist/types/device/index.d.ts +1 -1
  221. package/dist/types/device/index.d.ts.map +1 -1
  222. package/dist/types/dump/html-utils.d.ts +4 -0
  223. package/dist/types/dump/html-utils.d.ts.map +1 -1
  224. package/dist/types/dump/screenshot-store.d.ts +2 -1
  225. package/dist/types/dump/screenshot-store.d.ts.map +1 -1
  226. package/dist/types/report-cli.d.ts.map +1 -1
  227. package/dist/types/report-generator.d.ts +10 -0
  228. package/dist/types/report-generator.d.ts.map +1 -1
  229. package/dist/types/report.d.ts +3 -1
  230. package/dist/types/report.d.ts.map +1 -1
  231. package/dist/types/test-run-report.d.ts +18 -2
  232. package/dist/types/test-run-report.d.ts.map +1 -1
  233. package/dist/types/test-runner/engine/case-runner.d.ts +13 -0
  234. package/dist/types/test-runner/engine/case-runner.d.ts.map +1 -0
  235. package/dist/types/test-runner/engine/document-runtime.d.ts +4 -0
  236. package/dist/types/test-runner/engine/document-runtime.d.ts.map +1 -0
  237. package/dist/types/test-runner/engine/execute-step.d.ts +17 -0
  238. package/dist/types/test-runner/engine/execute-step.d.ts.map +1 -0
  239. package/dist/types/test-runner/engine/execution-failure.d.ts +13 -0
  240. package/dist/types/test-runner/engine/execution-failure.d.ts.map +1 -0
  241. package/dist/types/test-runner/engine/index.d.ts +13 -0
  242. package/dist/types/test-runner/engine/index.d.ts.map +1 -0
  243. package/dist/types/test-runner/engine/project-runtime.d.ts +3 -0
  244. package/dist/types/test-runner/engine/project-runtime.d.ts.map +1 -0
  245. package/dist/types/test-runner/engine/registry.d.ts +12 -0
  246. package/dist/types/test-runner/engine/registry.d.ts.map +1 -0
  247. package/dist/types/test-runner/engine/resource-operations.d.ts +32 -0
  248. package/dist/types/test-runner/engine/resource-operations.d.ts.map +1 -0
  249. package/dist/types/test-runner/engine/run-collected-case.d.ts +4 -0
  250. package/dist/types/test-runner/engine/run-collected-case.d.ts.map +1 -0
  251. package/dist/types/test-runner/engine/run-workflow-document.d.ts +4 -0
  252. package/dist/types/test-runner/engine/run-workflow-document.d.ts.map +1 -0
  253. package/dist/types/test-runner/engine/scheduler.d.ts +12 -0
  254. package/dist/types/test-runner/engine/scheduler.d.ts.map +1 -0
  255. package/dist/types/test-runner/engine/scope-teardown.d.ts +3 -0
  256. package/dist/types/test-runner/engine/scope-teardown.d.ts.map +1 -0
  257. package/dist/types/test-runner/engine/types.d.ts +226 -0
  258. package/dist/types/test-runner/engine/types.d.ts.map +1 -0
  259. package/dist/types/test-runner/errors.d.ts +79 -0
  260. package/dist/types/test-runner/errors.d.ts.map +1 -0
  261. package/dist/types/test-runner/execution-record.d.ts +43 -0
  262. package/dist/types/test-runner/execution-record.d.ts.map +1 -0
  263. package/dist/types/test-runner/index.d.ts +20 -0
  264. package/dist/types/test-runner/index.d.ts.map +1 -0
  265. package/dist/types/test-runner/node/define-node.d.ts +4 -0
  266. package/dist/types/test-runner/node/define-node.d.ts.map +1 -0
  267. package/dist/types/test-runner/node/index.d.ts +3 -0
  268. package/dist/types/test-runner/node/index.d.ts.map +1 -0
  269. package/dist/types/test-runner/node/types.d.ts +66 -0
  270. package/dist/types/test-runner/node/types.d.ts.map +1 -0
  271. package/dist/types/test-runner/parser/document-format.d.ts +8 -0
  272. package/dist/types/test-runner/parser/document-format.d.ts.map +1 -0
  273. package/dist/types/test-runner/parser/normalize.d.ts +9 -0
  274. package/dist/types/test-runner/parser/normalize.d.ts.map +1 -0
  275. package/dist/types/test-runner/parser/types.d.ts +69 -0
  276. package/dist/types/test-runner/parser/types.d.ts.map +1 -0
  277. package/dist/types/test-runner/project.d.ts +75 -0
  278. package/dist/types/test-runner/project.d.ts.map +1 -0
  279. package/dist/types/test-runner/reporting/agent-report.d.ts +9 -0
  280. package/dist/types/test-runner/reporting/agent-report.d.ts.map +1 -0
  281. package/dist/types/test-runner/reporting/execution-record.d.ts +9 -0
  282. package/dist/types/test-runner/reporting/execution-record.d.ts.map +1 -0
  283. package/dist/types/test-runner/reporting/merge-report.d.ts +15 -0
  284. package/dist/types/test-runner/reporting/merge-report.d.ts.map +1 -0
  285. package/dist/types/test-runner/reporting/sanitize.d.ts +6 -0
  286. package/dist/types/test-runner/reporting/sanitize.d.ts.map +1 -0
  287. package/dist/types/test-runner/reporting/test-run-report.d.ts +5 -0
  288. package/dist/types/test-runner/reporting/test-run-report.d.ts.map +1 -0
  289. package/dist/types/test-runner/reporting/types.d.ts +34 -0
  290. package/dist/types/test-runner/reporting/types.d.ts.map +1 -0
  291. package/dist/types/types.d.ts +1 -1
  292. package/dist/types/types.d.ts.map +1 -1
  293. package/dist/types/yaml/execution-context.node.d.ts +4 -0
  294. package/dist/types/yaml/execution-context.node.d.ts.map +1 -0
  295. package/dist/types/yaml/execution-context.stub.d.ts +6 -0
  296. package/dist/types/yaml/execution-context.stub.d.ts.map +1 -0
  297. package/dist/types/yaml/execution-session.d.ts +17 -0
  298. package/dist/types/yaml/execution-session.d.ts.map +1 -0
  299. package/dist/types/yaml/index.d.ts +1 -1
  300. package/dist/types/yaml/index.d.ts.map +1 -1
  301. package/dist/types/yaml/legacy-yaml-execution-record.d.ts +24 -0
  302. package/dist/types/yaml/legacy-yaml-execution-record.d.ts.map +1 -0
  303. package/dist/types/yaml/legacy-yaml-report.d.ts +19 -0
  304. package/dist/types/yaml/legacy-yaml-report.d.ts.map +1 -0
  305. package/dist/types/yaml/legacy-yaml-runtime.d.ts +23 -0
  306. package/dist/types/yaml/legacy-yaml-runtime.d.ts.map +1 -0
  307. package/dist/types/yaml/player-state.d.ts +11 -0
  308. package/dist/types/yaml/player-state.d.ts.map +1 -0
  309. package/dist/types/yaml/player.d.ts +11 -3
  310. package/dist/types/yaml/player.d.ts.map +1 -1
  311. package/dist/types/yaml/report-policy.d.ts +4 -0
  312. package/dist/types/yaml/report-policy.d.ts.map +1 -0
  313. package/dist/types/yaml/test-runner-compat.d.ts +17 -0
  314. package/dist/types/yaml/test-runner-compat.d.ts.map +1 -0
  315. package/dist/types/yaml/test-runner-nodes.d.ts +6 -0
  316. package/dist/types/yaml/test-runner-nodes.d.ts.map +1 -0
  317. package/dist/types/yaml/utils.d.ts +9 -0
  318. package/dist/types/yaml/utils.d.ts.map +1 -1
  319. package/dist/types/yaml-runtime.d.ts +13 -0
  320. package/dist/types/yaml-runtime.d.ts.map +1 -0
  321. package/dist/types/yaml.d.ts +25 -7
  322. package/dist/types/yaml.d.ts.map +1 -1
  323. package/package.json +28 -2
  324. package/dist/es/ai-model/workflows/planning/auto-deep-think.mjs +0 -80
  325. package/dist/es/ai-model/workflows/planning/auto-deep-think.mjs.map +0 -1
  326. package/dist/lib/ai-model/workflows/planning/auto-deep-think.js +0 -114
  327. package/dist/lib/ai-model/workflows/planning/auto-deep-think.js.map +0 -1
  328. package/dist/types/ai-model/workflows/planning/auto-deep-think.d.ts +0 -20
  329. package/dist/types/ai-model/workflows/planning/auto-deep-think.d.ts.map +0 -1
@@ -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);
@@ -441,9 +522,8 @@ class Agent {
441
522
  const aiActContext = this.resolveUserContext('aiAct', opt?.context);
442
523
  const cachePrompt = buildPromptWithContext(taskPrompt, aiActContext);
443
524
  const effort = (()=>{
444
- const resolvedEffort = opt?.effort ?? (opt?.deepThink === 'auto' ? 'auto' : 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.');
446
- if ('auto' === resolvedEffort && 'custom' === planningModel.adapter.planning.kind) throw new Error('deepThink: "auto" requires a standard planning adapter.');
525
+ const resolvedEffort = opt?.effort ?? (opt?.deepThink === true ? 'deepThink' : 'balance');
526
+ if (opt?.effort !== void 0 && void 0 !== opt.deepThink) warn('When both "effort" and "deepThink" are provided, "effort" takes precedence.');
447
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'}).`);
448
528
  if ('deepThink' === resolvedEffort && 'custom' === planningModel.adapter.planning.kind) {
449
529
  warn(`The "deepThink" aiAct effort is not supported with custom planning adapters (modelFamily: ${planningModel.config.modelFamily ?? 'unknown'}). It will be ignored.`);
@@ -466,9 +546,20 @@ class Agent {
466
546
  try {
467
547
  await this.taskExecutor.loadYamlFlowAsPlanning(taskPrompt, yaml, internalReportDisplay);
468
548
  debug('matched cache, will call .runYaml to run the action');
469
- 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
+ });
470
559
  return;
471
560
  } catch (error) {
561
+ if (error instanceof YamlExecutionOwnershipError) throw error;
562
+ abortSignal?.throwIfAborted();
472
563
  cachedYamlFailed = true;
473
564
  warn(`cached aiAct plan failed, will replan and disable the stale cache: ${error instanceof Error ? error.message : String(error)}`);
474
565
  }
@@ -596,6 +687,7 @@ class Agent {
596
687
  return this.aiAct(...args);
597
688
  }
598
689
  async runYaml(yamlScriptContent) {
690
+ if (this.destroyed) throw new Error('Cannot run YAML using a destroyed Agent.');
599
691
  const script = parseYamlScript(yamlScriptContent, 'yaml');
600
692
  const player = new ScriptPlayer(script, async ()=>({
601
693
  agent: this,
@@ -647,6 +739,7 @@ class Agent {
647
739
  async destroy() {
648
740
  if (this.destroyed) return;
649
741
  this.destroyed = true;
742
+ await waitForResourceIdle(this);
650
743
  for (const observer of this.ownedObservers)try {
651
744
  await observer.dispose();
652
745
  } catch (error) {
@@ -666,8 +759,9 @@ class Agent {
666
759
  this.resetDump();
667
760
  if (interfaceDestroyError) throw interfaceDestroyError;
668
761
  }
669
- async sleep(ms) {
670
- await this.taskExecutor.sleep(ms);
762
+ async sleep(ms, options) {
763
+ options?.abortSignal?.throwIfAborted();
764
+ await this.taskExecutor.sleep(ms, options?.abortSignal);
671
765
  }
672
766
  async recordToReport(title, opt) {
673
767
  const now = Date.now();
@@ -831,6 +925,8 @@ class Agent {
831
925
  _define_property(this, "dump", void 0);
832
926
  _define_property(this, "reportFile", void 0);
833
927
  _define_property(this, "reportFileName", void 0);
928
+ _define_property(this, "yamlReportScopeId", uuid());
929
+ _define_property(this, "yamlExecutionRecords", []);
834
930
  _define_property(this, "taskExecutor", void 0);
835
931
  _define_property(this, "opts", void 0);
836
932
  _define_property(this, "dryMode", false);