@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
@@ -1,4 +1,7 @@
1
1
  import { z } from "zod/v4";
2
+ import { inputStrategies } from "../device/input-strategy.mjs";
3
+ import { NodeExecutionError } from "../test-runner/errors.mjs";
4
+ import { buildDetailedLocateParam } from "../yaml/utils.mjs";
2
5
  const createAgentTestRunnerNodeDefinition = (agentLabel = 'an Agent')=>(definition)=>({
3
6
  name: definition.name ?? definition.method,
4
7
  ...void 0 === definition.title ? {} : {
@@ -35,6 +38,11 @@ const userPromptInputSchema = z.union([
35
38
  structuredUserPromptInputSchema
36
39
  ]);
37
40
  const aiActOptionsInputSchema = z.strictObject({
41
+ effort: z["enum"]([
42
+ 'fast',
43
+ 'balance',
44
+ 'deepThink'
45
+ ]).optional().describe('Action planning effort: fast, balanced, or deeper reasoning.'),
38
46
  cacheable: z.boolean().optional().describe('Whether this action may use the Midscene cache.'),
39
47
  fileChooserAccept: z.union([
40
48
  z.string(),
@@ -83,6 +91,100 @@ const aiTapInputSchema = z.strictObject({
83
91
  prompt: userPromptInputSchema,
84
92
  options: locateOptionsInputSchema.optional()
85
93
  });
94
+ const aiInputInputSchema = z.strictObject({
95
+ prompt: userPromptInputSchema,
96
+ value: z.union([
97
+ z.string(),
98
+ z.number()
99
+ ]),
100
+ options: locateOptionsInputSchema.extend({
101
+ mode: z["enum"]([
102
+ 'replace',
103
+ 'clear',
104
+ 'typeOnly',
105
+ 'append'
106
+ ]).optional(),
107
+ autoDismissKeyboard: z.boolean().optional(),
108
+ keyboardTypeDelay: z.number().nonnegative().optional(),
109
+ inputStrategy: z["enum"](inputStrategies).optional()
110
+ }).optional()
111
+ });
112
+ const aiKeyboardPressInputSchema = z.strictObject({
113
+ prompt: userPromptInputSchema.optional(),
114
+ keyName: nonBlankText('The key or key combination to press.'),
115
+ options: locateOptionsInputSchema.optional()
116
+ });
117
+ const aiScrollInputSchema = z.strictObject({
118
+ prompt: userPromptInputSchema.optional(),
119
+ options: locateOptionsInputSchema.extend({
120
+ direction: z["enum"]([
121
+ 'down',
122
+ 'up',
123
+ 'right',
124
+ 'left'
125
+ ]).optional(),
126
+ scrollType: z["enum"]([
127
+ 'singleAction',
128
+ 'scrollToBottom',
129
+ 'scrollToTop',
130
+ 'scrollToRight',
131
+ 'scrollToLeft',
132
+ 'once',
133
+ 'untilBottom',
134
+ 'untilTop',
135
+ 'untilRight',
136
+ 'untilLeft'
137
+ ]).optional(),
138
+ distance: z.number().nullable().optional()
139
+ }).optional()
140
+ });
141
+ const aiPinchInputSchema = z.strictObject({
142
+ prompt: userPromptInputSchema.optional(),
143
+ direction: z["enum"]([
144
+ 'in',
145
+ 'out'
146
+ ]),
147
+ options: locateOptionsInputSchema.extend({
148
+ distance: z.number().optional(),
149
+ duration: z.number().nonnegative().optional()
150
+ }).optional()
151
+ });
152
+ const aiLongPressInputSchema = z.strictObject({
153
+ prompt: userPromptInputSchema,
154
+ options: locateOptionsInputSchema.extend({
155
+ duration: z.number().nonnegative().optional()
156
+ }).optional()
157
+ });
158
+ const aiDragAndDropInputSchema = z.strictObject({
159
+ from: userPromptInputSchema,
160
+ to: userPromptInputSchema,
161
+ options: locateOptionsInputSchema.optional()
162
+ });
163
+ const aiQueryInputSchema = z.strictObject({
164
+ prompt: z.union([
165
+ nonBlankText('The extraction request.'),
166
+ z.record(z.string(), z.string())
167
+ ]),
168
+ options: insightOptionsInputSchema.optional()
169
+ });
170
+ const aiWaitForInputSchema = z.strictObject({
171
+ prompt: userPromptInputSchema,
172
+ options: insightOptionsInputSchema.extend({
173
+ timeoutMs: z.number().positive().optional(),
174
+ checkIntervalMs: z.number().positive().optional()
175
+ }).optional()
176
+ });
177
+ const javascriptInputSchema = z.strictObject({
178
+ script: nonBlankText('JavaScript to evaluate through the current interface.')
179
+ });
180
+ const runGherkinScenarioInputSchema = z.strictObject({
181
+ scenario: nonBlankText('The Gherkin scenario to execute.'),
182
+ options: aiActOptionsInputSchema.optional()
183
+ });
184
+ const actionInputSchema = z.strictObject({
185
+ name: nonBlankText('The ActionSpace action name, for example DragAndDrop.'),
186
+ params: z.unknown().optional()
187
+ });
86
188
  const insightInputSchema = z.strictObject({
87
189
  prompt: userPromptInputSchema,
88
190
  options: insightOptionsInputSchema.optional()
@@ -106,7 +208,11 @@ const recordToReportInputSchema = z.strictObject({
106
208
  options: recordToReportOptionsInputSchema.optional()
107
209
  });
108
210
  const defineCommonAgentNode = createAgentTestRunnerNodeDefinition('an Agent');
211
+ const defineAgentActionNode = createAgentTestRunnerNodeDefinition('an Agent');
109
212
  const promptText = (prompt)=>'string' == typeof prompt ? prompt : prompt.prompt;
213
+ const valueResult = (value)=>({
214
+ data: value
215
+ });
110
216
  const aiActNode = defineCommonAgentNode({
111
217
  method: 'aiAct',
112
218
  description: 'Perform a natural-language task with a Midscene UI Agent.',
@@ -154,14 +260,15 @@ const aiAssertNode = defineCommonAgentNode({
154
260
  input.prompt,
155
261
  input.message,
156
262
  {
263
+ keepRawResponse: true,
157
264
  ...input.options,
158
265
  abortSignal: context.signal
159
266
  }
160
267
  ];
161
268
  },
162
269
  toResult (output, input) {
163
- return {
164
- summary: `Assertion passed: ${promptText(input.prompt)}`,
270
+ const result = {
271
+ summary: `Assertion ${output?.pass === false ? 'failed' : 'passed'}: ${promptText(input.prompt)}`,
165
272
  ...void 0 === output ? {} : {
166
273
  data: {
167
274
  pass: output.pass,
@@ -174,74 +281,201 @@ const aiAssertNode = defineCommonAgentNode({
174
281
  }
175
282
  }
176
283
  };
284
+ if (output?.pass === false) throw new NodeExecutionError('aiAssert', new Error(output.message || input.message || output.thought || `Assertion failed: ${promptText(input.prompt)}`), result);
285
+ return result;
177
286
  }
178
287
  });
179
- const insightNode = (method)=>{
180
- if ('aiBoolean' === method) return defineCommonAgentNode({
288
+ const locateActionNode = (method)=>defineAgentActionNode({
181
289
  method,
182
- description: `Run ${method} with a Midscene UI Agent and store its value.`,
290
+ description: {
291
+ aiHover: 'Locate and hover over an element with a Midscene UI Agent.',
292
+ aiDoubleClick: 'Locate and double-click an element with a Midscene UI Agent.',
293
+ aiRightClick: 'Locate and right-click an element with a Midscene UI Agent.',
294
+ aiClearInput: 'Locate an input element and clear its value with a Midscene UI Agent.'
295
+ }[method],
183
296
  stringInputKey: 'prompt',
184
- inputSchema: insightInputSchema,
297
+ inputSchema: aiTapInputSchema,
185
298
  toArgs: (input)=>[
186
299
  input.prompt,
187
300
  input.options
188
301
  ],
189
- toResult: (value)=>({
190
- summary: `${method} returned ${value}`,
191
- data: {
192
- value
193
- }
302
+ toResult: (_output, input)=>({
303
+ summary: `${method}: ${promptText(input.prompt)}`
194
304
  })
195
305
  });
196
- if ('aiNumber' === method) return defineCommonAgentNode({
197
- method,
198
- description: `Run ${method} with a Midscene UI Agent and store its value.`,
306
+ const additionalAgentNodes = [
307
+ locateActionNode('aiHover'),
308
+ locateActionNode('aiDoubleClick'),
309
+ locateActionNode('aiRightClick'),
310
+ locateActionNode('aiClearInput'),
311
+ defineAgentActionNode({
312
+ method: 'aiInput',
313
+ description: 'Locate an input element and enter a value with a Midscene UI Agent.',
314
+ inputSchema: aiInputInputSchema,
315
+ toArgs: (input)=>[
316
+ input.prompt,
317
+ {
318
+ ...input.options,
319
+ value: input.value
320
+ }
321
+ ]
322
+ }),
323
+ defineAgentActionNode({
324
+ method: 'aiKeyboardPress',
325
+ description: 'Press a key or key combination, optionally targeting a located element.',
326
+ stringInputKey: 'keyName',
327
+ inputSchema: aiKeyboardPressInputSchema,
328
+ toArgs: (input)=>[
329
+ input.prompt,
330
+ {
331
+ ...input.options,
332
+ keyName: input.keyName
333
+ }
334
+ ]
335
+ }),
336
+ defineAgentActionNode({
337
+ method: 'aiScroll',
338
+ description: 'Scroll the page or a located region with a Midscene UI Agent.',
199
339
  stringInputKey: 'prompt',
200
- inputSchema: insightInputSchema,
340
+ inputSchema: aiScrollInputSchema,
201
341
  toArgs: (input)=>[
202
342
  input.prompt,
203
- input.options
204
- ],
205
- toResult: (value)=>({
206
- summary: `${method} returned ${value}`,
207
- data: {
208
- value
343
+ {
344
+ ...input.options
209
345
  }
210
- })
211
- });
212
- if ('aiString' === method) return defineCommonAgentNode({
213
- method,
214
- description: `Run ${method} with a Midscene UI Agent and store its value.`,
346
+ ]
347
+ }),
348
+ defineAgentActionNode({
349
+ method: 'aiPinch',
350
+ description: 'Perform a pinch-in or pinch-out gesture with a Midscene UI Agent.',
351
+ inputSchema: aiPinchInputSchema,
352
+ toArgs: (input)=>[
353
+ input.prompt,
354
+ {
355
+ ...input.options,
356
+ direction: input.direction
357
+ }
358
+ ]
359
+ }),
360
+ defineAgentActionNode({
361
+ method: 'aiLongPress',
362
+ description: 'Locate and long-press an element with a Midscene UI Agent.',
215
363
  stringInputKey: 'prompt',
216
- inputSchema: insightInputSchema,
364
+ inputSchema: aiLongPressInputSchema,
217
365
  toArgs: (input)=>[
218
366
  input.prompt,
219
367
  input.options
368
+ ]
369
+ }),
370
+ defineAgentActionNode({
371
+ method: 'callActionInActionSpace',
372
+ name: 'aiDragAndDrop',
373
+ description: 'Locate source and destination elements, then drag the source to the destination.',
374
+ inputSchema: aiDragAndDropInputSchema,
375
+ toArgs: (input)=>[
376
+ 'DragAndDrop',
377
+ {
378
+ from: buildDetailedLocateParam(input.from, input.options),
379
+ to: buildDetailedLocateParam(input.to, input.options)
380
+ }
381
+ ]
382
+ }),
383
+ defineAgentActionNode({
384
+ method: 'aiLocate',
385
+ description: "Locate an element from a natural-language description and store the result.",
386
+ stringInputKey: 'prompt',
387
+ inputSchema: aiTapInputSchema,
388
+ toArgs: (input, context)=>[
389
+ input.prompt,
390
+ {
391
+ ...input.options,
392
+ abortSignal: context.signal
393
+ }
220
394
  ],
221
- toResult: (value)=>({
222
- summary: `${method} returned ${JSON.stringify(value)}`,
223
- data: {
224
- value
395
+ toResult: valueResult
396
+ }),
397
+ defineAgentActionNode({
398
+ method: 'aiQuery',
399
+ description: 'Extract structured data from the current interface and store the result.',
400
+ stringInputKey: 'prompt',
401
+ inputSchema: aiQueryInputSchema,
402
+ toArgs: (input, context)=>[
403
+ input.prompt,
404
+ {
405
+ ...input.options,
406
+ abortSignal: context.signal
225
407
  }
226
- })
227
- });
228
- return defineCommonAgentNode({
408
+ ],
409
+ toResult: valueResult
410
+ }),
411
+ defineAgentActionNode({
412
+ method: 'aiWaitFor',
413
+ description: 'Wait until a natural-language condition is satisfied.',
414
+ stringInputKey: 'prompt',
415
+ inputSchema: aiWaitForInputSchema,
416
+ toArgs: (input, context)=>[
417
+ input.prompt,
418
+ {
419
+ ...input.options,
420
+ abortSignal: context.signal
421
+ }
422
+ ]
423
+ }),
424
+ defineAgentActionNode({
425
+ method: 'evaluateJavaScript',
426
+ name: "javascript",
427
+ description: 'Evaluate JavaScript in the current interface and store the result.',
428
+ stringInputKey: "script",
429
+ inputSchema: javascriptInputSchema,
430
+ toArgs: (input)=>[
431
+ input.script
432
+ ],
433
+ toResult: valueResult
434
+ }),
435
+ defineAgentActionNode({
436
+ method: 'runGherkinScenario',
437
+ description: 'Execute a Gherkin scenario with the current Midscene UI Agent.',
438
+ stringInputKey: 'scenario',
439
+ inputSchema: runGherkinScenarioInputSchema,
440
+ toArgs: (input, context)=>[
441
+ input.scenario,
442
+ {
443
+ ...input.options,
444
+ abortSignal: context.signal
445
+ }
446
+ ]
447
+ }),
448
+ defineAgentActionNode({
449
+ method: 'callActionInActionSpace',
450
+ name: 'action',
451
+ description: 'Call a platform or custom action. Its ActionSpace schema validates params when the action executes.',
452
+ inputSchema: actionInputSchema,
453
+ toArgs: (input)=>[
454
+ input.name,
455
+ input.params
456
+ ],
457
+ toResult: (value)=>void 0 === value ? void 0 : valueResult(value)
458
+ })
459
+ ];
460
+ const insightNode = (method)=>defineCommonAgentNode({
229
461
  method,
230
462
  description: `Run ${method} with a Midscene UI Agent and store its value.`,
231
463
  stringInputKey: 'prompt',
232
464
  inputSchema: insightInputSchema,
233
- toArgs: (input)=>[
465
+ toArgs: (input, context)=>[
234
466
  input.prompt,
235
- input.options
467
+ {
468
+ ...input.options,
469
+ abortSignal: context.signal
470
+ }
236
471
  ],
237
472
  toResult: (value)=>({
238
- summary: `${method} returned ${JSON.stringify(value)}`,
473
+ summary: `${method} returned ${'aiString' === method || 'aiAsk' === method ? JSON.stringify(value) : value}`,
239
474
  data: {
240
475
  value
241
476
  }
242
477
  })
243
478
  });
244
- };
245
479
  const recordToReportNode = defineCommonAgentNode({
246
480
  method: 'recordToReport',
247
481
  description: 'Add text or screenshots to the current Midscene report.',
@@ -260,6 +494,22 @@ const recordToReportNode = defineCommonAgentNode({
260
494
  }
261
495
  });
262
496
  const commonAgentTestRunnerNodeDefinitions = [
497
+ defineAgentActionNode({
498
+ method: 'sleep',
499
+ description: 'Wait for a fixed number of milliseconds, recording standard UI snapshots and honoring cancellation.',
500
+ inputSchema: z.strictObject({
501
+ ms: z.number().positive()
502
+ }),
503
+ toArgs (input, { signal }) {
504
+ signal.throwIfAborted();
505
+ return [
506
+ input.ms,
507
+ {
508
+ abortSignal: signal
509
+ }
510
+ ];
511
+ }
512
+ }),
263
513
  aiActNode,
264
514
  aiTapNode,
265
515
  aiAssertNode,
@@ -267,8 +517,9 @@ const commonAgentTestRunnerNodeDefinitions = [
267
517
  insightNode('aiNumber'),
268
518
  insightNode('aiString'),
269
519
  insightNode('aiAsk'),
270
- recordToReportNode
520
+ recordToReportNode,
521
+ ...additionalAgentNodes
271
522
  ];
272
- export { aiActInputSchema, aiActOptionsInputSchema, aiAssertInputSchema, aiAssertOptionsInputSchema, aiTapInputSchema, commonAgentTestRunnerNodeDefinitions, createAgentTestRunnerNodeDefinition, insightInputSchema, insightOptionsInputSchema, locateOptionsInputSchema, promptImageInputSchema, recordToReportInputSchema, recordToReportOptionsInputSchema, reportScreenshotInputSchema, structuredUserPromptInputSchema, userPromptInputSchema };
523
+ export { actionInputSchema, aiActInputSchema, aiActOptionsInputSchema, aiAssertInputSchema, aiAssertOptionsInputSchema, aiDragAndDropInputSchema, aiInputInputSchema, aiKeyboardPressInputSchema, aiLongPressInputSchema, aiPinchInputSchema, aiQueryInputSchema, aiScrollInputSchema, aiTapInputSchema, aiWaitForInputSchema, commonAgentTestRunnerNodeDefinitions, createAgentTestRunnerNodeDefinition, insightInputSchema, insightOptionsInputSchema, javascriptInputSchema, locateOptionsInputSchema, promptImageInputSchema, recordToReportInputSchema, recordToReportOptionsInputSchema, reportScreenshotInputSchema, runGherkinScenarioInputSchema, structuredUserPromptInputSchema, userPromptInputSchema };
273
524
 
274
525
  //# sourceMappingURL=test-runner-nodes.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"agent/test-runner-nodes.mjs","sources":["../../../src/agent/test-runner-nodes.ts"],"sourcesContent":["import { z } from 'zod/v4';\nimport type { Agent } from './agent';\n\nexport interface AgentTestRunnerNodeResult<TData = unknown> {\n summary?: string;\n data?: TData;\n}\n\nexport interface AgentTestRunnerNodeExecutionContext {\n signal: AbortSignal;\n}\n\n/** Agent-owned Node description consumed by Test Runner adapters. */\nexport interface AgentTestRunnerNodeDefinition<\n TInput extends Record<string, unknown> = Record<string, unknown>,\n TData = unknown,\n> {\n name: string;\n title?: string;\n description?: string;\n /** Node input field populated by YAML string shorthand; omit to disable. */\n stringInputKey?: string | false;\n inputSchema: z.ZodObject;\n execute(\n agent: unknown,\n input: TInput,\n context: AgentTestRunnerNodeExecutionContext,\n ):\n | Promise<AgentTestRunnerNodeResult<TData> | undefined>\n | AgentTestRunnerNodeResult<TData>\n | undefined;\n}\n\n/** Static capability implemented by Agent classes that expose Runner Nodes. */\nexport interface AgentTestRunnerNodeProvider {\n getTestRunnerNodeDefinitions(): readonly AgentTestRunnerNodeDefinition[];\n}\n\ntype AnyAgentMethod = (...args: any[]) => unknown;\ntype AgentMethodName<TAgent extends object> = {\n [TKey in keyof TAgent]-?: TAgent[TKey] extends AnyAgentMethod ? TKey : never;\n}[keyof TAgent] &\n string;\ntype AgentMethod<\n TAgent extends object,\n TMethod extends AgentMethodName<TAgent>,\n> = Extract<TAgent[TMethod], AnyAgentMethod>;\n\nexport interface DefineAgentTestRunnerNodeOptions<\n TAgent extends object,\n TMethod extends AgentMethodName<TAgent>,\n TSchema extends z.ZodObject,\n TData = unknown,\n> {\n method: TMethod;\n name?: string;\n title?: string;\n description?: string;\n stringInputKey?: (keyof z.output<TSchema> & string) | false;\n inputSchema: TSchema;\n toArgs(\n input: z.output<TSchema>,\n context: AgentTestRunnerNodeExecutionContext,\n ): Parameters<AgentMethod<TAgent, TMethod>>;\n toResult?(\n result: Awaited<ReturnType<AgentMethod<TAgent, TMethod>>>,\n input: z.output<TSchema>,\n ): AgentTestRunnerNodeResult<TData> | undefined;\n}\n\n/** Create a Node factory whose adapters are checked against an Agent API. */\nexport const createAgentTestRunnerNodeDefinition =\n <TAgent extends object>(agentLabel = 'an Agent') =>\n <\n TMethod extends AgentMethodName<TAgent>,\n TSchema extends z.ZodObject,\n TData = unknown,\n >(\n definition: DefineAgentTestRunnerNodeOptions<\n TAgent,\n TMethod,\n TSchema,\n TData\n >,\n ): AgentTestRunnerNodeDefinition => ({\n name: definition.name ?? definition.method,\n ...(definition.title === undefined ? {} : { title: definition.title }),\n ...(definition.description === undefined\n ? {}\n : { description: definition.description }),\n ...(definition.stringInputKey === undefined\n ? {}\n : { stringInputKey: definition.stringInputKey }),\n inputSchema: definition.inputSchema,\n async execute(agent, input, context) {\n if (\n typeof agent !== 'object' ||\n agent === null ||\n typeof (agent as Record<string, unknown>)[definition.method] !==\n 'function'\n ) {\n throw new TypeError(\n `getAgent() must return ${agentLabel} with ${definition.method}().`,\n );\n }\n\n const typedAgent = agent as TAgent;\n const method = typedAgent[definition.method] as AgentMethod<\n TAgent,\n TMethod\n >;\n const typedInput = input as z.output<TSchema>;\n const result = (await method.apply(\n typedAgent,\n definition.toArgs(typedInput, context),\n )) as Awaited<ReturnType<AgentMethod<TAgent, TMethod>>>;\n return definition.toResult?.(result, typedInput);\n },\n });\n\nconst nonBlankText = (description: string) =>\n z\n .string()\n .regex(/\\S/, 'value must contain a non-whitespace character')\n .describe(description);\n\nexport const promptImageInputSchema = z.strictObject({\n name: nonBlankText('The name used to identify this reference image.'),\n url: nonBlankText('The URL, data URL, or file path of this reference image.'),\n});\n\nexport const structuredUserPromptInputSchema = z.strictObject({\n prompt: nonBlankText('The natural-language prompt.'),\n images: z.array(promptImageInputSchema).min(1).optional(),\n convertHttpImage2Base64: z\n .boolean()\n .optional()\n .describe('Whether HTTP reference images are converted to base64 first.'),\n});\n\nexport const userPromptInputSchema = z.union([\n nonBlankText('The natural-language prompt.'),\n structuredUserPromptInputSchema,\n]);\n\nexport const aiActOptionsInputSchema = z.strictObject({\n cacheable: z\n .boolean()\n .optional()\n .describe('Whether this action may use the Midscene cache.'),\n fileChooserAccept: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('Accepted file types for a file chooser.'),\n fileChooserAllowedDir: z\n .string()\n .optional()\n .describe('Directory allowed for prompt-driven file uploads.'),\n deepThink: z\n .union([z.literal('unset'), z.boolean()])\n .optional()\n .describe('Whether to enable deep thinking for this action.'),\n deepLocate: z\n .boolean()\n .optional()\n .describe('Whether to use deep element location.'),\n context: z\n .string()\n .optional()\n .describe(\n 'Additional facts, rules, constraints, or output requirements for this AI call. Overrides inherited aiContexts; an empty string disables inherited user context.',\n ),\n});\n\nexport const aiActInputSchema = z.strictObject({\n prompt: userPromptInputSchema,\n options: aiActOptionsInputSchema.optional(),\n});\n\nexport const insightOptionsInputSchema = z.strictObject({\n domIncluded: z\n .union([z.boolean(), z.literal('visible-only')])\n .optional()\n .describe('How DOM information is included.'),\n screenshotIncluded: z\n .boolean()\n .optional()\n .describe('Whether the request includes a screenshot.'),\n context: z\n .string()\n .optional()\n .describe(\n 'Additional facts, rules, constraints, or output requirements for this AI call. Overrides inherited aiContexts; an empty string disables inherited user context.',\n ),\n});\n\nexport const aiAssertOptionsInputSchema = insightOptionsInputSchema.extend({\n keepRawResponse: z\n .boolean()\n .optional()\n .describe('Whether the Agent returns the structured assertion result.'),\n});\n\nexport const aiAssertInputSchema = z.strictObject({\n prompt: userPromptInputSchema,\n message: z.string().optional().describe('The assertion failure message.'),\n options: aiAssertOptionsInputSchema.optional(),\n});\n\nexport const locateOptionsInputSchema = z.strictObject({\n context: z\n .string()\n .optional()\n .describe(\n 'Additional facts, rules, constraints, or output requirements for this AI call. Overrides inherited aiContexts; an empty string disables inherited user context.',\n ),\n deepLocate: z\n .boolean()\n .optional()\n .describe('Whether to use deep element location.'),\n deepThink: z\n .boolean()\n .optional()\n .describe('Deprecated alias for deepLocate.'),\n cacheable: z\n .boolean()\n .optional()\n .describe('Whether this location may use the Midscene cache.'),\n xpath: z.string().optional().describe('A web XPath location hint.'),\n fileChooserAccept: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('Files accepted when tapping opens a file chooser.'),\n});\n\nexport const aiTapInputSchema = z.strictObject({\n prompt: userPromptInputSchema,\n options: locateOptionsInputSchema.optional(),\n});\n\nexport const insightInputSchema = z.strictObject({\n prompt: userPromptInputSchema,\n options: insightOptionsInputSchema.optional(),\n});\n\nexport const reportScreenshotInputSchema = z.strictObject({\n base64: z.string().min(1).describe('A base64-encoded screenshot.'),\n description: z.string().optional().describe('What the screenshot shows.'),\n});\n\nexport const recordToReportOptionsInputSchema = z\n .strictObject({\n content: z.string().optional().describe('The report text content.'),\n screenshotBase64: z\n .string()\n .optional()\n .describe('One base64-encoded screenshot.'),\n screenshots: z\n .array(reportScreenshotInputSchema)\n .min(1)\n .optional()\n .describe('Screenshots attached to the report section.'),\n })\n .superRefine((input, context) => {\n if (\n input.screenshotBase64 !== undefined &&\n input.screenshots !== undefined\n ) {\n context.addIssue({\n code: 'custom',\n message: 'screenshotBase64 and screenshots are mutually exclusive',\n });\n }\n });\n\nexport const recordToReportInputSchema = z.strictObject({\n title: z.string().optional().describe('The report section title.'),\n options: recordToReportOptionsInputSchema.optional(),\n});\n\nexport type UserPromptNodeInput = z.infer<typeof userPromptInputSchema>;\nexport type AiActNodeOptions = z.infer<typeof aiActOptionsInputSchema>;\nexport type AiActNodeInput = z.infer<typeof aiActInputSchema>;\nexport type AiAssertNodeOptions = z.infer<typeof aiAssertOptionsInputSchema>;\nexport type AiAssertNodeInput = z.infer<typeof aiAssertInputSchema>;\nexport type AiTapNodeOptions = z.infer<typeof locateOptionsInputSchema>;\nexport type AiTapNodeInput = z.infer<typeof aiTapInputSchema>;\nexport type InsightNodeOptions = z.infer<typeof insightOptionsInputSchema>;\nexport type InsightNodeInput = z.infer<typeof insightInputSchema>;\nexport type RecordToReportNodeOptions = z.infer<\n typeof recordToReportOptionsInputSchema\n>;\nexport type RecordToReportNodeInput = z.infer<typeof recordToReportInputSchema>;\n\nexport type CommonAgentTestRunnerApi = Pick<\n Agent,\n | 'aiAct'\n | 'aiTap'\n | 'aiAssert'\n | 'aiBoolean'\n | 'aiNumber'\n | 'aiString'\n | 'aiAsk'\n | 'recordToReport'\n>;\n\nconst defineCommonAgentNode =\n createAgentTestRunnerNodeDefinition<CommonAgentTestRunnerApi>('an Agent');\n\nconst promptText = (prompt: UserPromptNodeInput): string =>\n typeof prompt === 'string' ? prompt : prompt.prompt;\n\nconst aiActNode = defineCommonAgentNode({\n method: 'aiAct',\n description: 'Perform a natural-language task with a Midscene UI Agent.',\n stringInputKey: 'prompt',\n inputSchema: aiActInputSchema,\n toArgs(input, context) {\n return [\n input.prompt,\n {\n ...input.options,\n abortSignal: context.signal,\n },\n ];\n },\n toResult(output) {\n return output === undefined ? undefined : { summary: output };\n },\n});\n\nconst aiTapNode = defineCommonAgentNode({\n method: 'aiTap',\n description: 'Locate and tap an element with a Midscene UI Agent.',\n stringInputKey: 'prompt',\n inputSchema: aiTapInputSchema,\n toArgs(input) {\n return [input.prompt, input.options];\n },\n toResult(_output, input) {\n return { summary: `Tapped: ${promptText(input.prompt)}` };\n },\n});\n\nconst aiAssertNode = defineCommonAgentNode({\n method: 'aiAssert',\n description: 'Assert a natural-language condition with a Midscene UI Agent.',\n stringInputKey: 'prompt',\n inputSchema: aiAssertInputSchema,\n toArgs(input, context) {\n return [\n input.prompt,\n input.message,\n {\n ...input.options,\n abortSignal: context.signal,\n },\n ];\n },\n toResult(output, input) {\n return {\n summary: `Assertion passed: ${promptText(input.prompt)}`,\n ...(output === undefined\n ? {}\n : {\n data: {\n pass: output.pass,\n ...(output.thought === undefined\n ? {}\n : { thought: output.thought }),\n ...(output.message === undefined\n ? {}\n : { message: output.message }),\n },\n }),\n };\n },\n});\n\nconst insightNode = (\n method: 'aiBoolean' | 'aiNumber' | 'aiString' | 'aiAsk',\n) => {\n if (method === 'aiBoolean') {\n return defineCommonAgentNode({\n method,\n description: `Run ${method} with a Midscene UI Agent and store its value.`,\n stringInputKey: 'prompt',\n inputSchema: insightInputSchema,\n toArgs: (input) => [input.prompt, input.options],\n toResult: (value) => ({\n summary: `${method} returned ${value}`,\n data: { value },\n }),\n });\n }\n if (method === 'aiNumber') {\n return defineCommonAgentNode({\n method,\n description: `Run ${method} with a Midscene UI Agent and store its value.`,\n stringInputKey: 'prompt',\n inputSchema: insightInputSchema,\n toArgs: (input) => [input.prompt, input.options],\n toResult: (value) => ({\n summary: `${method} returned ${value}`,\n data: { value },\n }),\n });\n }\n if (method === 'aiString') {\n return defineCommonAgentNode({\n method,\n description: `Run ${method} with a Midscene UI Agent and store its value.`,\n stringInputKey: 'prompt',\n inputSchema: insightInputSchema,\n toArgs: (input) => [input.prompt, input.options],\n toResult: (value) => ({\n summary: `${method} returned ${JSON.stringify(value)}`,\n data: { value },\n }),\n });\n }\n return defineCommonAgentNode({\n method,\n description: `Run ${method} with a Midscene UI Agent and store its value.`,\n stringInputKey: 'prompt',\n inputSchema: insightInputSchema,\n toArgs: (input) => [input.prompt, input.options],\n toResult: (value) => ({\n summary: `${method} returned ${JSON.stringify(value)}`,\n data: { value },\n }),\n });\n};\n\nconst recordToReportNode = defineCommonAgentNode({\n method: 'recordToReport',\n description: 'Add text or screenshots to the current Midscene report.',\n stringInputKey: 'title',\n inputSchema: recordToReportInputSchema,\n toArgs(input) {\n return [input.title, input.options];\n },\n toResult(_output, input) {\n return { summary: `Recorded to report: ${input.title ?? 'untitled'}` };\n },\n});\n\nexport const commonAgentTestRunnerNodeDefinitions: readonly AgentTestRunnerNodeDefinition[] =\n [\n aiActNode,\n aiTapNode,\n aiAssertNode,\n insightNode('aiBoolean'),\n insightNode('aiNumber'),\n insightNode('aiString'),\n insightNode('aiAsk'),\n recordToReportNode,\n ];\n"],"names":["createAgentTestRunnerNodeDefinition","agentLabel","definition","undefined","agent","input","context","TypeError","typedAgent","method","typedInput","result","nonBlankText","description","z","promptImageInputSchema","structuredUserPromptInputSchema","userPromptInputSchema","aiActOptionsInputSchema","aiActInputSchema","insightOptionsInputSchema","aiAssertOptionsInputSchema","aiAssertInputSchema","locateOptionsInputSchema","aiTapInputSchema","insightInputSchema","reportScreenshotInputSchema","recordToReportOptionsInputSchema","recordToReportInputSchema","defineCommonAgentNode","promptText","prompt","aiActNode","output","aiTapNode","_output","aiAssertNode","ins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AAO,UAAU,EAAE8B,KAAK,SAAS,CAACD,QAAQ;gBACtD,MAAM;oBAAEA;gBAAM;YAChB;IACF;IAEF,OAAOT,sBAAsB;QAC3BpB;QACA,aAAa,CAAC,IAAI,EAAEA,OAAO,8CAA8C,CAAC;QAC1E,gBAAgB;QAChB,aAAagB;QACb,QAAQ,CAACpB,QAAU;gBAACA,MAAM,MAAM;gBAAEA,MAAM,OAAO;aAAC;QAChD,UAAU,CAACiC,QAAW;gBACpB,SAAS,GAAG7B,OAAO,UAAU,EAAE8B,KAAK,SAAS,CAACD,QAAQ;gBACtD,MAAM;oBAAEA;gBAAM;YAChB;IACF;AACF;AAEA,MAAME,qBAAqBX,sBAAsB;IAC/C,QAAQ;IACR,aAAa;IACb,gBAAgB;IAChB,aAAaD;IACb,QAAOvB,KAAK;QACV,OAAO;YAACA,MAAM,KAAK;YAAEA,MAAM,OAAO;SAAC;IACrC;IACA,UAAS8B,OAAO,EAAE9B,KAAK;QACrB,OAAO;YAAE,SAAS,CAAC,oBAAoB,EAAEA,MAAM,KAAK,IAAI,YAAY;QAAC;IACvE;AACF;AAEO,MAAMoC,uCACX;IACET;IACAE;IACAE;IACAC,YAAY;IACZA,YAAY;IACZA,YAAY;IACZA,YAAY;IACZG;CACD"}
1
+ {"version":3,"file":"agent/test-runner-nodes.mjs","sources":["../../../src/agent/test-runner-nodes.ts"],"sourcesContent":["import { z } from 'zod/v4';\nimport type { TUserPrompt } from '../common';\nimport { inputStrategies } from '../device/input-strategy';\nimport { NodeExecutionError } from '../test-runner/errors';\nimport type { LocateOption, ScrollParam } from '../yaml';\nimport { buildDetailedLocateParam } from '../yaml/utils';\nimport type { Agent } from './agent';\n\nexport interface AgentTestRunnerNodeResult<TData = unknown> {\n summary?: string;\n data?: TData;\n}\n\nexport interface AgentTestRunnerNodeExecutionContext {\n signal: AbortSignal;\n}\n\n/** Agent-owned Node description consumed by Test Runner adapters. */\nexport interface AgentTestRunnerNodeDefinition<\n TInput extends Record<string, unknown> = Record<string, unknown>,\n TData = unknown,\n> {\n name: string;\n title?: string;\n description?: string;\n /** Node input field populated by YAML string shorthand; omit to disable. */\n stringInputKey?: string | false;\n inputSchema: z.ZodObject;\n execute(\n agent: unknown,\n input: TInput,\n context: AgentTestRunnerNodeExecutionContext,\n ):\n | Promise<AgentTestRunnerNodeResult<TData> | undefined>\n | AgentTestRunnerNodeResult<TData>\n | undefined;\n}\n\n/** Static capability implemented by Agent classes that expose Runner Nodes. */\nexport interface AgentTestRunnerNodeProvider {\n getTestRunnerNodeDefinitions(): readonly AgentTestRunnerNodeDefinition[];\n}\n\ntype AnyAgentMethod = (...args: any[]) => unknown;\ntype AgentMethodName<TAgent extends object> = {\n [TKey in keyof TAgent]-?: TAgent[TKey] extends AnyAgentMethod ? TKey : never;\n}[keyof TAgent] &\n string;\ntype AgentMethod<\n TAgent extends object,\n TMethod extends AgentMethodName<TAgent>,\n> = Extract<TAgent[TMethod], AnyAgentMethod>;\n\nexport interface DefineAgentTestRunnerNodeOptions<\n TAgent extends object,\n TMethod extends AgentMethodName<TAgent>,\n TSchema extends z.ZodObject,\n TData = unknown,\n> {\n method: TMethod;\n name?: string;\n title?: string;\n description?: string;\n stringInputKey?: (keyof z.output<TSchema> & string) | false;\n inputSchema: TSchema;\n toArgs(\n input: z.output<TSchema>,\n context: AgentTestRunnerNodeExecutionContext,\n ): Parameters<AgentMethod<TAgent, TMethod>>;\n toResult?(\n result: Awaited<ReturnType<AgentMethod<TAgent, TMethod>>>,\n input: z.output<TSchema>,\n ): AgentTestRunnerNodeResult<TData> | undefined;\n}\n\n/** Create a Node factory whose adapters are checked against an Agent API. */\nexport const createAgentTestRunnerNodeDefinition =\n <TAgent extends object>(agentLabel = 'an Agent') =>\n <\n TMethod extends AgentMethodName<TAgent>,\n TSchema extends z.ZodObject,\n TData = unknown,\n >(\n definition: DefineAgentTestRunnerNodeOptions<\n TAgent,\n TMethod,\n TSchema,\n TData\n >,\n ): AgentTestRunnerNodeDefinition => ({\n name: definition.name ?? definition.method,\n ...(definition.title === undefined ? {} : { title: definition.title }),\n ...(definition.description === undefined\n ? {}\n : { description: definition.description }),\n ...(definition.stringInputKey === undefined\n ? {}\n : { stringInputKey: definition.stringInputKey }),\n inputSchema: definition.inputSchema,\n async execute(agent, input, context) {\n if (\n typeof agent !== 'object' ||\n agent === null ||\n typeof (agent as Record<string, unknown>)[definition.method] !==\n 'function'\n ) {\n throw new TypeError(\n `getAgent() must return ${agentLabel} with ${definition.method}().`,\n );\n }\n\n const typedAgent = agent as TAgent;\n const method = typedAgent[definition.method] as AgentMethod<\n TAgent,\n TMethod\n >;\n const typedInput = input as z.output<TSchema>;\n const result = (await method.apply(\n typedAgent,\n definition.toArgs(typedInput, context),\n )) as Awaited<ReturnType<AgentMethod<TAgent, TMethod>>>;\n return definition.toResult?.(result, typedInput);\n },\n });\n\nconst nonBlankText = (description: string) =>\n z\n .string()\n .regex(/\\S/, 'value must contain a non-whitespace character')\n .describe(description);\n\nexport const promptImageInputSchema = z.strictObject({\n name: nonBlankText('The name used to identify this reference image.'),\n url: nonBlankText('The URL, data URL, or file path of this reference image.'),\n});\n\nexport const structuredUserPromptInputSchema = z.strictObject({\n prompt: nonBlankText('The natural-language prompt.'),\n images: z.array(promptImageInputSchema).min(1).optional(),\n convertHttpImage2Base64: z\n .boolean()\n .optional()\n .describe('Whether HTTP reference images are converted to base64 first.'),\n});\n\nexport const userPromptInputSchema = z.union([\n nonBlankText('The natural-language prompt.'),\n structuredUserPromptInputSchema,\n]);\n\nexport const aiActOptionsInputSchema = z.strictObject({\n effort: z\n .enum(['fast', 'balance', 'deepThink'])\n .optional()\n .describe('Action planning effort: fast, balanced, or deeper reasoning.'),\n cacheable: z\n .boolean()\n .optional()\n .describe('Whether this action may use the Midscene cache.'),\n fileChooserAccept: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('Accepted file types for a file chooser.'),\n fileChooserAllowedDir: z\n .string()\n .optional()\n .describe('Directory allowed for prompt-driven file uploads.'),\n deepThink: z\n .union([z.literal('unset'), z.boolean()])\n .optional()\n .describe('Whether to enable deep thinking for this action.'),\n deepLocate: z\n .boolean()\n .optional()\n .describe('Whether to use deep element location.'),\n context: z\n .string()\n .optional()\n .describe(\n 'Additional facts, rules, constraints, or output requirements for this AI call. Overrides inherited aiContexts; an empty string disables inherited user context.',\n ),\n});\n\nexport const aiActInputSchema = z.strictObject({\n prompt: userPromptInputSchema,\n options: aiActOptionsInputSchema.optional(),\n});\n\nexport const insightOptionsInputSchema = z.strictObject({\n domIncluded: z\n .union([z.boolean(), z.literal('visible-only')])\n .optional()\n .describe('How DOM information is included.'),\n screenshotIncluded: z\n .boolean()\n .optional()\n .describe('Whether the request includes a screenshot.'),\n context: z\n .string()\n .optional()\n .describe(\n 'Additional facts, rules, constraints, or output requirements for this AI call. Overrides inherited aiContexts; an empty string disables inherited user context.',\n ),\n});\n\nexport const aiAssertOptionsInputSchema = insightOptionsInputSchema.extend({\n keepRawResponse: z\n .boolean()\n .optional()\n .describe('Whether the Agent returns the structured assertion result.'),\n});\n\nexport const aiAssertInputSchema = z.strictObject({\n prompt: userPromptInputSchema,\n message: z.string().optional().describe('The assertion failure message.'),\n options: aiAssertOptionsInputSchema.optional(),\n});\n\nexport const locateOptionsInputSchema = z.strictObject({\n context: z\n .string()\n .optional()\n .describe(\n 'Additional facts, rules, constraints, or output requirements for this AI call. Overrides inherited aiContexts; an empty string disables inherited user context.',\n ),\n deepLocate: z\n .boolean()\n .optional()\n .describe('Whether to use deep element location.'),\n deepThink: z\n .boolean()\n .optional()\n .describe('Deprecated alias for deepLocate.'),\n cacheable: z\n .boolean()\n .optional()\n .describe('Whether this location may use the Midscene cache.'),\n xpath: z.string().optional().describe('A web XPath location hint.'),\n fileChooserAccept: z\n .union([z.string(), z.array(z.string())])\n .optional()\n .describe('Files accepted when tapping opens a file chooser.'),\n});\n\nexport const aiTapInputSchema = z.strictObject({\n prompt: userPromptInputSchema,\n options: locateOptionsInputSchema.optional(),\n});\n\nexport const aiInputInputSchema = z.strictObject({\n prompt: userPromptInputSchema,\n value: z.union([z.string(), z.number()]),\n options: locateOptionsInputSchema\n .extend({\n mode: z.enum(['replace', 'clear', 'typeOnly', 'append']).optional(),\n autoDismissKeyboard: z.boolean().optional(),\n keyboardTypeDelay: z.number().nonnegative().optional(),\n inputStrategy: z.enum(inputStrategies).optional(),\n })\n .optional(),\n});\n\nexport const aiKeyboardPressInputSchema = z.strictObject({\n prompt: userPromptInputSchema.optional(),\n keyName: nonBlankText('The key or key combination to press.'),\n options: locateOptionsInputSchema.optional(),\n});\n\nexport const aiScrollInputSchema = z.strictObject({\n prompt: userPromptInputSchema.optional(),\n options: locateOptionsInputSchema\n .extend({\n direction: z.enum(['down', 'up', 'right', 'left']).optional(),\n scrollType: z\n .enum([\n 'singleAction',\n 'scrollToBottom',\n 'scrollToTop',\n 'scrollToRight',\n 'scrollToLeft',\n 'once',\n 'untilBottom',\n 'untilTop',\n 'untilRight',\n 'untilLeft',\n ])\n .optional(),\n distance: z.number().nullable().optional(),\n })\n .optional(),\n});\n\nexport const aiPinchInputSchema = z.strictObject({\n prompt: userPromptInputSchema.optional(),\n direction: z.enum(['in', 'out']),\n options: locateOptionsInputSchema\n .extend({\n distance: z.number().optional(),\n duration: z.number().nonnegative().optional(),\n })\n .optional(),\n});\n\nexport const aiLongPressInputSchema = z.strictObject({\n prompt: userPromptInputSchema,\n options: locateOptionsInputSchema\n .extend({ duration: z.number().nonnegative().optional() })\n .optional(),\n});\n\nexport const aiDragAndDropInputSchema = z.strictObject({\n from: userPromptInputSchema,\n to: userPromptInputSchema,\n options: locateOptionsInputSchema.optional(),\n});\n\nexport const aiQueryInputSchema = z.strictObject({\n prompt: z.union([\n nonBlankText('The extraction request.'),\n z.record(z.string(), z.string()),\n ]),\n options: insightOptionsInputSchema.optional(),\n});\n\nexport const aiWaitForInputSchema = z.strictObject({\n prompt: userPromptInputSchema,\n options: insightOptionsInputSchema\n .extend({\n timeoutMs: z.number().positive().optional(),\n checkIntervalMs: z.number().positive().optional(),\n })\n .optional(),\n});\n\nexport const javascriptInputSchema = z.strictObject({\n script: nonBlankText('JavaScript to evaluate through the current interface.'),\n});\n\nexport const runGherkinScenarioInputSchema = z.strictObject({\n scenario: nonBlankText('The Gherkin scenario to execute.'),\n options: aiActOptionsInputSchema.optional(),\n});\n\nexport const actionInputSchema = z.strictObject({\n name: nonBlankText('The ActionSpace action name, for example DragAndDrop.'),\n params: z.unknown().optional(),\n});\n\nexport const insightInputSchema = z.strictObject({\n prompt: userPromptInputSchema,\n options: insightOptionsInputSchema.optional(),\n});\n\nexport const reportScreenshotInputSchema = z.strictObject({\n base64: z.string().min(1).describe('A base64-encoded screenshot.'),\n description: z.string().optional().describe('What the screenshot shows.'),\n});\n\nexport const recordToReportOptionsInputSchema = z\n .strictObject({\n content: z.string().optional().describe('The report text content.'),\n screenshotBase64: z\n .string()\n .optional()\n .describe('One base64-encoded screenshot.'),\n screenshots: z\n .array(reportScreenshotInputSchema)\n .min(1)\n .optional()\n .describe('Screenshots attached to the report section.'),\n })\n .superRefine((input, context) => {\n if (\n input.screenshotBase64 !== undefined &&\n input.screenshots !== undefined\n ) {\n context.addIssue({\n code: 'custom',\n message: 'screenshotBase64 and screenshots are mutually exclusive',\n });\n }\n });\n\nexport const recordToReportInputSchema = z.strictObject({\n title: z.string().optional().describe('The report section title.'),\n options: recordToReportOptionsInputSchema.optional(),\n});\n\nexport type UserPromptNodeInput = z.infer<typeof userPromptInputSchema>;\nexport type AiActNodeOptions = z.infer<typeof aiActOptionsInputSchema>;\nexport type AiActNodeInput = z.infer<typeof aiActInputSchema>;\nexport type AiAssertNodeOptions = z.infer<typeof aiAssertOptionsInputSchema>;\nexport type AiAssertNodeInput = z.infer<typeof aiAssertInputSchema>;\nexport type AiTapNodeOptions = z.infer<typeof locateOptionsInputSchema>;\nexport type AiTapNodeInput = z.infer<typeof aiTapInputSchema>;\nexport type AiInputNodeInput = z.infer<typeof aiInputInputSchema>;\nexport type AiKeyboardPressNodeInput = z.infer<\n typeof aiKeyboardPressInputSchema\n>;\nexport type AiScrollNodeInput = z.infer<typeof aiScrollInputSchema>;\nexport type AiPinchNodeInput = z.infer<typeof aiPinchInputSchema>;\nexport type AiLongPressNodeInput = z.infer<typeof aiLongPressInputSchema>;\nexport type AiDragAndDropNodeInput = z.infer<typeof aiDragAndDropInputSchema>;\nexport type AiQueryNodeInput = z.infer<typeof aiQueryInputSchema>;\nexport type AiWaitForNodeInput = z.infer<typeof aiWaitForInputSchema>;\nexport type JavascriptNodeInput = z.infer<typeof javascriptInputSchema>;\nexport type RunGherkinScenarioNodeInput = z.infer<\n typeof runGherkinScenarioInputSchema\n>;\nexport type ActionNodeInput = z.infer<typeof actionInputSchema>;\nexport type InsightNodeOptions = z.infer<typeof insightOptionsInputSchema>;\nexport type InsightNodeInput = z.infer<typeof insightInputSchema>;\nexport type RecordToReportNodeOptions = z.infer<\n typeof recordToReportOptionsInputSchema\n>;\nexport type RecordToReportNodeInput = z.infer<typeof recordToReportInputSchema>;\n\nexport type CommonAgentTestRunnerApi = Pick<\n Agent,\n | 'aiAct'\n | 'aiTap'\n | 'aiAssert'\n | 'aiBoolean'\n | 'aiNumber'\n | 'aiString'\n | 'aiAsk'\n | 'recordToReport'\n>;\n\nconst defineCommonAgentNode =\n createAgentTestRunnerNodeDefinition<CommonAgentTestRunnerApi>('an Agent');\n\n// Select the current overloads without expanding the minimum API required by\n// existing getAgent() providers. Each Node checks its own method at execution.\ntype AgentActionNodeApi = Pick<\n Agent,\n | 'sleep'\n | 'aiHover'\n | 'aiDoubleClick'\n | 'aiRightClick'\n | 'aiLongPress'\n | 'aiClearInput'\n | 'aiPinch'\n | 'aiLocate'\n | 'aiQuery'\n | 'aiWaitFor'\n | 'evaluateJavaScript'\n | 'runGherkinScenario'\n | 'callActionInActionSpace'\n> & {\n aiInput(\n prompt: TUserPrompt,\n options: NonNullable<Parameters<Agent['aiInput']>[2]> & {\n value: string | number;\n },\n ): Promise<void>;\n aiKeyboardPress(\n prompt: TUserPrompt | undefined,\n options: LocateOption & { keyName: string },\n ): Promise<void>;\n aiScroll(\n prompt: TUserPrompt | undefined,\n options: LocateOption & ScrollParam,\n ): Promise<void>;\n};\n\nconst defineAgentActionNode =\n createAgentTestRunnerNodeDefinition<AgentActionNodeApi>('an Agent');\n\nconst promptText = (prompt: UserPromptNodeInput): string =>\n typeof prompt === 'string' ? prompt : prompt.prompt;\n\nconst valueResult = (\n value: unknown,\n): AgentTestRunnerNodeResult | undefined => ({ data: value });\n\nconst aiActNode = defineCommonAgentNode({\n method: 'aiAct',\n description: 'Perform a natural-language task with a Midscene UI Agent.',\n stringInputKey: 'prompt',\n inputSchema: aiActInputSchema,\n toArgs(input, context) {\n return [\n input.prompt,\n {\n ...input.options,\n abortSignal: context.signal,\n },\n ];\n },\n toResult(output) {\n return output === undefined ? undefined : { summary: output };\n },\n});\n\nconst aiTapNode = defineCommonAgentNode({\n method: 'aiTap',\n description: 'Locate and tap an element with a Midscene UI Agent.',\n stringInputKey: 'prompt',\n inputSchema: aiTapInputSchema,\n toArgs(input) {\n return [input.prompt, input.options];\n },\n toResult(_output, input) {\n return { summary: `Tapped: ${promptText(input.prompt)}` };\n },\n});\n\nconst aiAssertNode = defineCommonAgentNode({\n method: 'aiAssert',\n description: 'Assert a natural-language condition with a Midscene UI Agent.',\n stringInputKey: 'prompt',\n inputSchema: aiAssertInputSchema,\n toArgs(input, context) {\n return [\n input.prompt,\n input.message,\n {\n keepRawResponse: true,\n ...input.options,\n abortSignal: context.signal,\n },\n ];\n },\n toResult(output, input) {\n const result = {\n summary: `Assertion ${output?.pass === false ? 'failed' : 'passed'}: ${promptText(input.prompt)}`,\n ...(output === undefined\n ? {}\n : {\n data: {\n pass: output.pass,\n ...(output.thought === undefined\n ? {}\n : { thought: output.thought }),\n ...(output.message === undefined\n ? {}\n : { message: output.message }),\n },\n }),\n };\n if (output?.pass === false)\n throw new NodeExecutionError(\n 'aiAssert',\n new Error(\n output.message ||\n input.message ||\n output.thought ||\n `Assertion failed: ${promptText(input.prompt)}`,\n ),\n result,\n );\n return result;\n },\n});\n\nconst locateActionNode = (\n method: 'aiHover' | 'aiDoubleClick' | 'aiRightClick' | 'aiClearInput',\n) =>\n defineAgentActionNode({\n method,\n description: {\n aiHover: 'Locate and hover over an element with a Midscene UI Agent.',\n aiDoubleClick:\n 'Locate and double-click an element with a Midscene UI Agent.',\n aiRightClick:\n 'Locate and right-click an element with a Midscene UI Agent.',\n aiClearInput:\n 'Locate an input element and clear its value with a Midscene UI Agent.',\n }[method],\n stringInputKey: 'prompt',\n inputSchema: aiTapInputSchema,\n toArgs: (input) => [input.prompt, input.options],\n toResult: (_output, input) => ({\n summary: `${method}: ${promptText(input.prompt)}`,\n }),\n });\n\nconst additionalAgentNodes: readonly AgentTestRunnerNodeDefinition[] = [\n locateActionNode('aiHover'),\n locateActionNode('aiDoubleClick'),\n locateActionNode('aiRightClick'),\n locateActionNode('aiClearInput'),\n defineAgentActionNode({\n method: 'aiInput',\n description:\n 'Locate an input element and enter a value with a Midscene UI Agent.',\n inputSchema: aiInputInputSchema,\n toArgs: (input) => [input.prompt, { ...input.options, value: input.value }],\n }),\n defineAgentActionNode({\n method: 'aiKeyboardPress',\n description:\n 'Press a key or key combination, optionally targeting a located element.',\n stringInputKey: 'keyName',\n inputSchema: aiKeyboardPressInputSchema,\n toArgs: (input) => [\n input.prompt,\n { ...input.options, keyName: input.keyName },\n ],\n }),\n defineAgentActionNode({\n method: 'aiScroll',\n description:\n 'Scroll the page or a located region with a Midscene UI Agent.',\n stringInputKey: 'prompt',\n inputSchema: aiScrollInputSchema,\n toArgs: (input) => [input.prompt, { ...input.options }],\n }),\n defineAgentActionNode({\n method: 'aiPinch',\n description:\n 'Perform a pinch-in or pinch-out gesture with a Midscene UI Agent.',\n inputSchema: aiPinchInputSchema,\n toArgs: (input) => [\n input.prompt,\n { ...input.options, direction: input.direction },\n ],\n }),\n defineAgentActionNode({\n method: 'aiLongPress',\n description: 'Locate and long-press an element with a Midscene UI Agent.',\n stringInputKey: 'prompt',\n inputSchema: aiLongPressInputSchema,\n toArgs: (input) => [input.prompt, input.options],\n }),\n defineAgentActionNode({\n method: 'callActionInActionSpace',\n name: 'aiDragAndDrop',\n description:\n 'Locate source and destination elements, then drag the source to the destination.',\n inputSchema: aiDragAndDropInputSchema,\n toArgs: (input) => [\n 'DragAndDrop',\n {\n from: buildDetailedLocateParam(input.from, input.options),\n to: buildDetailedLocateParam(input.to, input.options),\n },\n ],\n }),\n defineAgentActionNode({\n method: 'aiLocate',\n description:\n 'Locate an element from a natural-language description and store the result.',\n stringInputKey: 'prompt',\n inputSchema: aiTapInputSchema,\n toArgs: (input, context) => [\n input.prompt,\n { ...input.options, abortSignal: context.signal },\n ],\n toResult: valueResult,\n }),\n defineAgentActionNode({\n method: 'aiQuery',\n description:\n 'Extract structured data from the current interface and store the result.',\n stringInputKey: 'prompt',\n inputSchema: aiQueryInputSchema,\n toArgs: (input, context) => [\n input.prompt,\n { ...input.options, abortSignal: context.signal },\n ],\n toResult: valueResult,\n }),\n defineAgentActionNode({\n method: 'aiWaitFor',\n description: 'Wait until a natural-language condition is satisfied.',\n stringInputKey: 'prompt',\n inputSchema: aiWaitForInputSchema,\n toArgs: (input, context) => [\n input.prompt,\n { ...input.options, abortSignal: context.signal },\n ],\n }),\n defineAgentActionNode({\n method: 'evaluateJavaScript',\n name: 'javascript',\n description:\n 'Evaluate JavaScript in the current interface and store the result.',\n stringInputKey: 'script',\n inputSchema: javascriptInputSchema,\n toArgs: (input) => [input.script],\n toResult: valueResult,\n }),\n defineAgentActionNode({\n method: 'runGherkinScenario',\n description:\n 'Execute a Gherkin scenario with the current Midscene UI Agent.',\n stringInputKey: 'scenario',\n inputSchema: runGherkinScenarioInputSchema,\n toArgs: (input, context) => [\n input.scenario,\n { ...input.options, abortSignal: context.signal },\n ],\n }),\n defineAgentActionNode({\n method: 'callActionInActionSpace',\n name: 'action',\n description:\n 'Call a platform or custom action. Its ActionSpace schema validates params when the action executes.',\n inputSchema: actionInputSchema,\n toArgs: (input) => [input.name, input.params],\n toResult: (value) => (value === undefined ? undefined : valueResult(value)),\n }),\n];\n\nconst insightNode = (method: 'aiBoolean' | 'aiNumber' | 'aiString' | 'aiAsk') =>\n defineCommonAgentNode({\n method,\n description: `Run ${method} with a Midscene UI Agent and store its value.`,\n stringInputKey: 'prompt',\n inputSchema: insightInputSchema,\n toArgs: (input, context) => [\n input.prompt,\n { ...input.options, abortSignal: context.signal },\n ],\n toResult: (value) => ({\n summary: `${method} returned ${\n method === 'aiString' || method === 'aiAsk'\n ? JSON.stringify(value)\n : value\n }`,\n data: { value },\n }),\n });\n\nconst recordToReportNode = defineCommonAgentNode({\n method: 'recordToReport',\n description: 'Add text or screenshots to the current Midscene report.',\n stringInputKey: 'title',\n inputSchema: recordToReportInputSchema,\n toArgs(input) {\n return [input.title, input.options];\n },\n toResult(_output, input) {\n return { summary: `Recorded to report: ${input.title ?? 'untitled'}` };\n },\n});\n\nexport const commonAgentTestRunnerNodeDefinitions: readonly AgentTestRunnerNodeDefinition[] =\n [\n defineAgentActionNode({\n method: 'sleep',\n description:\n 'Wait for a fixed number of milliseconds, recording standard UI snapshots and honoring cancellation.',\n inputSchema: z.strictObject({ ms: z.number().positive() }),\n toArgs(input, { signal }) {\n signal.throwIfAborted();\n return [input.ms, { abortSignal: signal }];\n },\n }),\n aiActNode,\n aiTapNode,\n aiAssertNode,\n insightNode('aiBoolean'),\n insightNode('aiNumber'),\n insightNode('aiString'),\n insightNode('aiAsk'),\n recordToReportNode,\n ...additionalAgentNodes,\n ];\n"],"names":["createAgentTestRunnerNodeDefinition","agentLabel","definition","undefined","agent","input","context","TypeError","typedAgent","method","typedInput","result","nonBlankText","description","z","promptImageInputSchema","structuredUserPromptInputSchema","userPromptInputSchema","aiActOptionsInputSchema","aiActInputSchema","insightOptionsInputSchema","aiAssertOptionsInputSchema","aiAssertInputSchema","locateOptionsInputSchema","aiTapInputSchema","aiInputInputSchema","inputStrategies","aiKeyboardPressInputSchema","aiScrollInputSchema","aiPinchInputSchema","aiLongPressInputSchema","aiDragAndDropInputSchema","aiQueryInputSchema","aiWaitForInputSchema","javascriptInputSchema","runGherkinScenarioInputSchema","actionInputSchema","insightInputSchema","reportScreenshotInputSchema","recordToReportOptionsInputSchema","recordToReportInputSchema","defineCommonAgentNode","defineAgentActionNode","promptText","prompt","valueResult","value","aiActNode","output","aiTapNode","_output","aiAssertNode","NodeExecutionError","Error","locateActionNode","additionalAgentNodes","buildDetailedLocateParam","insightNode","JSON","recordToReportNode","commonAgentTestRunnerNodeDefinitions","signal"],"mappings":";;;;AA4EO,MAAMA,sCACX,CAAwBC,aAAa,UAAU,GAC/C,CAKEC,aAMmC;YACnC,MAAMA,WAAW,IAAI,IAAIA,WAAW,MAAM;YAC1C,GAAIA,AAAqBC,WAArBD,WAAW,KAAK,GAAiB,CAAC,IAAI;gBAAE,OAAOA,WAAW,KAAK;YAAC,CAAC;YACrE,GAAIA,AAA2BC,WAA3BD,WAAW,WAAW,GACtB,CAAC,IACD;gBAAE,aAAaA,WAAW,WAAW;YAAC,CAAC;YAC3C,GAAIA,AAA8BC,WAA9BD,WAAW,cAAc,GACzB,CAAC,IACD;gBAAE,gBAAgBA,WAAW,cAAc;YAAC,CAAC;YACjD,aAAaA,WAAW,WAAW;YACnC,MAAM,SAAQE,KAAK,EAAEC,KAAK,EAAEC,OAAO;gBACjC,IACE,AAAiB,YAAjB,OAAOF,SACPA,AAAU,SAAVA,SACA,AACE,cADF,OAAQA,KAAiC,CAACF,WAAW,MAAM,CAAC,EAG5D,MAAM,IAAIK,UACR,CAAC,uBAAuB,EAAEN,WAAW,MAAM,EAAEC,WAAW,MAAM,CAAC,GAAG,CAAC;gBAIvE,MAAMM,aAAaJ;gBACnB,MAAMK,SAASD,UAAU,CAACN,WAAW,MAAM,CAAC;gBAI5C,MAAMQ,aAAaL;gBACnB,MAAMM,SAAU,MAAMF,OAAO,KAAK,CAChCD,YACAN,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gBACpB,SAAS,GAAGrC,OAAO,UAAU,EAC3BA,AAAW,eAAXA,UAAyBA,AAAW,YAAXA,SACrBiD,KAAK,SAAS,CAACZ,SACfA,OACJ;gBACF,MAAM;oBAAEA;gBAAM;YAChB;IACF;AAEF,MAAMa,qBAAqBlB,sBAAsB;IAC/C,QAAQ;IACR,aAAa;IACb,gBAAgB;IAChB,aAAaD;IACb,QAAOnC,KAAK;QACV,OAAO;YAACA,MAAM,KAAK;YAAEA,MAAM,OAAO;SAAC;IACrC;IACA,UAAS6C,OAAO,EAAE7C,KAAK;QACrB,OAAO;YAAE,SAAS,CAAC,oBAAoB,EAAEA,MAAM,KAAK,IAAI,YAAY;QAAC;IACvE;AACF;AAEO,MAAMuD,uCACX;IACElB,sBAAsB;QACpB,QAAQ;QACR,aACE;QACF,aAAa5B,EAAE,YAAY,CAAC;YAAE,IAAIA,EAAE,MAAM,GAAG,QAAQ;QAAG;QACxD,QAAOT,KAAK,EAAE,EAAEwD,MAAM,EAAE;YACtBA,OAAO,cAAc;YACrB,OAAO;gBAACxD,MAAM,EAAE;gBAAE;oBAAE,aAAawD;gBAAO;aAAE;QAC5C;IACF;IACAd;IACAE;IACAE;IACAM,YAAY;IACZA,YAAY;IACZA,YAAY;IACZA,YAAY;IACZE;OACGJ;CACJ"}
@@ -153,7 +153,7 @@ async function matchElementFromCache(context, cacheEntry, cachePrompt, cacheable
153
153
  return;
154
154
  }
155
155
  }
156
- const getMidsceneVersion = ()=>"1.12.10-beta-20260920031616.0";
156
+ const getMidsceneVersion = ()=>"1.13.0";
157
157
  const parsePrompt = (prompt)=>{
158
158
  if ('string' == typeof prompt) return {
159
159
  textPrompt: prompt,
@@ -514,7 +514,7 @@ function createDefaultMobileActions(context) {
514
514
  const ActionSleepParamSchema = z.object({
515
515
  timeMs: z.number().default(1000).optional().describe('Sleep duration in milliseconds, defaults to 1000ms (1 second)')
516
516
  });
517
- const defineActionSleep = ()=>defineAction({
517
+ const defineActionSleep = (abortSignal)=>defineAction({
518
518
  name: 'Sleep',
519
519
  description: 'Wait for a specified duration before continuing. Defaults to 1 second (1000ms) if not specified.',
520
520
  paramSchema: ActionSleepParamSchema,
@@ -524,7 +524,20 @@ const defineActionSleep = ()=>defineAction({
524
524
  call: async (param)=>{
525
525
  const duration = param?.timeMs ?? 1000;
526
526
  getDebug('device:common-action')(`Sleeping for ${duration}ms`);
527
- await new Promise((resolve)=>setTimeout(resolve, duration));
527
+ abortSignal?.throwIfAborted();
528
+ await new Promise((resolve, reject)=>{
529
+ const abort = ()=>{
530
+ clearTimeout(timer);
531
+ reject(abortSignal?.reason);
532
+ };
533
+ const timer = setTimeout(()=>{
534
+ abortSignal?.removeEventListener('abort', abort);
535
+ resolve();
536
+ }, duration);
537
+ abortSignal?.addEventListener('abort', abort, {
538
+ once: true
539
+ });
540
+ });
528
541
  }
529
542
  });
530
543
  export { AbstractInterface, ActionLongPressParamSchema, ActionPinchParamSchema, ActionSleepParamSchema, ActionSwipeParamSchema, actionClearInputParamSchema, actionCursorMoveParamSchema, actionDoubleClickParamSchema, actionDragAndDropParamSchema, actionHoverParamSchema, actionInputParamSchema, actionKeyboardPressParamSchema, actionRightClickParamSchema, actionScrollParamSchema, actionTapParamSchema, createDefaultMobileActions, defineAction, defineActionClearInput, defineActionCursorMove, defineActionDoubleClick, defineActionDragAndDrop, defineActionHover, defineActionInput, defineActionKeyboardPress, defineActionLongPress, defineActionPinch, defineActionRegisterFileChooserAccept, defineActionRightClick, defineActionScroll, defineActionSleep, defineActionSwipe, defineActionTap, defineActionsFromInputPrimitives, getMidsceneLocationSchema, inputStrategies, normalizeMobileSwipeParam, normalizePinchParam, normalizeSwipeParam, registerFileChooserAcceptParamSchema, resolveInputStrategy, resolveSwipeInputPrimitive, resolveTextInputOptions, sendTextSequentially, shouldInputSequentially, z };