@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
@@ -0,0 +1,52 @@
1
+ import { basename } from "node:path";
2
+ import { ifInBrowser, ifInWorker } from "@midscene/shared/utils";
3
+ import { ReportGenerator } from "../report-generator.mjs";
4
+ import { executionRecordsToReportInput } from "../test-runner/reporting/execution-record.mjs";
5
+ import { getVersion } from "../utils.mjs";
6
+ import { isYamlReportEnabled } from "./report-policy.mjs";
7
+ async function publishLegacyYamlReport(options) {
8
+ const { agent, runId } = options;
9
+ let record = options.record;
10
+ if (agent) {
11
+ const reportFile = await agent._writeYamlExecutionReport?.(record) ?? agent.reportFile;
12
+ const source = await agent._createReportSource?.(runId);
13
+ if (source) record = Object.freeze({
14
+ ...record,
15
+ reportSources: [
16
+ source
17
+ ]
18
+ });
19
+ return {
20
+ record,
21
+ reportFile
22
+ };
23
+ }
24
+ if (ifInBrowser || ifInWorker || !isYamlReportEnabled(options.script)) return {
25
+ record
26
+ };
27
+ const generator = ReportGenerator.create(options.fallbackReportFileName ?? options.script.agent?.reportFileName ?? options.script.agent?.testId ?? (options.scriptPath ? basename(options.scriptPath).replace(/\.ya?ml$/i, '') : `script-${runId}`), options.script.agent ?? {});
28
+ const reportFile = await generator.writeRunnerReport?.(executionRecordsToReportInput([
29
+ record
30
+ ], {
31
+ runId
32
+ }), runId, {
33
+ groupName: 'YAML execution',
34
+ sdkVersion: getVersion(),
35
+ modelBriefs: []
36
+ });
37
+ await generator.finalize();
38
+ const source = await generator.createSourceSnapshot?.(runId);
39
+ if (source) record = Object.freeze({
40
+ ...record,
41
+ reportSources: [
42
+ source
43
+ ]
44
+ });
45
+ return {
46
+ record,
47
+ reportFile
48
+ };
49
+ }
50
+ export { publishLegacyYamlReport };
51
+
52
+ //# sourceMappingURL=legacy-yaml-report.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"yaml/legacy-yaml-report.mjs","sources":["../../../src/yaml/legacy-yaml-report.ts"],"sourcesContent":["import { basename } from 'node:path';\nimport type { Agent } from '@/agent/agent';\nimport type { MidsceneYamlScript } from '@/types';\nimport { ifInBrowser, ifInWorker } from '@midscene/shared/utils';\nimport { ReportGenerator } from '../report-generator';\nimport type { WorkflowExecutionRecord } from '../test-runner';\nimport { executionRecordsToReportInput } from '../test-runner/reporting/execution-record';\nimport { getVersion } from '../utils';\nimport { isYamlReportEnabled } from './report-policy';\n\ninterface PublishLegacyYamlReportOptions {\n agent: Agent | null;\n record: WorkflowExecutionRecord;\n runId: string;\n script: MidsceneYamlScript;\n scriptPath?: string;\n fallbackReportFileName?: string;\n}\n\nexport interface PublishedLegacyYamlReport {\n record: WorkflowExecutionRecord;\n reportFile?: string | null;\n}\n\n/** Report publication is a host projection, not a ScriptPlayer state concern. */\nexport async function publishLegacyYamlReport(\n options: PublishLegacyYamlReportOptions,\n): Promise<PublishedLegacyYamlReport> {\n const { agent, runId } = options;\n let record = options.record;\n if (agent) {\n const reportFile =\n (await agent._writeYamlExecutionReport?.(record)) ?? agent.reportFile;\n const source = await agent._createReportSource?.(runId);\n if (source) record = Object.freeze({ ...record, reportSources: [source] });\n return { record, reportFile };\n }\n if (ifInBrowser || ifInWorker || !isYamlReportEnabled(options.script))\n return { record };\n\n const generator = ReportGenerator.create(\n options.fallbackReportFileName ??\n options.script.agent?.reportFileName ??\n options.script.agent?.testId ??\n (options.scriptPath\n ? basename(options.scriptPath).replace(/\\.ya?ml$/i, '')\n : `script-${runId}`),\n options.script.agent ?? {},\n );\n const reportFile = await generator.writeRunnerReport?.(\n executionRecordsToReportInput([record], { runId }),\n runId,\n {\n groupName: 'YAML execution',\n sdkVersion: getVersion(),\n modelBriefs: [],\n },\n );\n await generator.finalize();\n const source = await generator.createSourceSnapshot?.(runId);\n if (source) record = Object.freeze({ ...record, reportSources: [source] });\n return { record, reportFile };\n}\n"],"names":["publishLegacyYamlReport","options","agent","runId","record","reportFile","source","Object","ifInBrowser","ifInWorker","isYamlReportEnabled","generator","ReportGenerator","basename","executionRecordsToReportInput","getVersion"],"mappings":";;;;;;AAyBO,eAAeA,wBACpBC,OAAuC;IAEvC,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAGF;IACzB,IAAIG,SAASH,QAAQ,MAAM;IAC3B,IAAIC,OAAO;QACT,MAAMG,aACH,MAAMH,MAAM,yBAAyB,GAAGE,WAAYF,MAAM,UAAU;QACvE,MAAMI,SAAS,MAAMJ,MAAM,mBAAmB,GAAGC;QACjD,IAAIG,QAAQF,SAASG,OAAO,MAAM,CAAC;YAAE,GAAGH,MAAM;YAAE,eAAe;gBAACE;aAAO;QAAC;QACxE,OAAO;YAAEF;YAAQC;QAAW;IAC9B;IACA,IAAIG,eAAeC,cAAc,CAACC,oBAAoBT,QAAQ,MAAM,GAClE,OAAO;QAAEG;IAAO;IAElB,MAAMO,YAAYC,gBAAgB,MAAM,CACtCX,QAAQ,sBAAsB,IAC5BA,QAAQ,MAAM,CAAC,KAAK,EAAE,kBACtBA,QAAQ,MAAM,CAAC,KAAK,EAAE,UACrBA,CAAAA,QAAQ,UAAU,GACfY,SAASZ,QAAQ,UAAU,EAAE,OAAO,CAAC,aAAa,MAClD,CAAC,OAAO,EAAEE,OAAM,GACtBF,QAAQ,MAAM,CAAC,KAAK,IAAI,CAAC;IAE3B,MAAMI,aAAa,MAAMM,UAAU,iBAAiB,GAClDG,8BAA8B;QAACV;KAAO,EAAE;QAAED;IAAM,IAChDA,OACA;QACE,WAAW;QACX,YAAYY;QACZ,aAAa,EAAE;IACjB;IAEF,MAAMJ,UAAU,QAAQ;IACxB,MAAML,SAAS,MAAMK,UAAU,oBAAoB,GAAGR;IACtD,IAAIG,QAAQF,SAASG,OAAO,MAAM,CAAC;QAAE,GAAGH,MAAM;QAAE,eAAe;YAACE;SAAO;IAAC;IACxE,OAAO;QAAEF;QAAQC;IAAW;AAC9B"}
@@ -0,0 +1,119 @@
1
+ import { deriveCaseStatus } from "../dump/task-status.mjs";
2
+ import { getDebug } from "@midscene/shared/logger";
3
+ import { assert } from "@midscene/shared/utils";
4
+ import { assertResourceAvailable, defineNode, runWorkflowDocument, trackResourceOperation, waitForResourceIdle } from "../test-runner/index.mjs";
5
+ import { enterYamlAction, runInYamlExecutionContext } from "./execution-session.mjs";
6
+ import { collectLegacyYamlDocument, collectLegacyYamlTaskDocument } from "./test-runner-compat.mjs";
7
+ import { getLegacyYamlResultData, legacyAgentTestRunnerNodeDefinitions } from "./test-runner-nodes.mjs";
8
+ const debug = getDebug('yaml-player');
9
+ const hasFailedReportExecutionSince = (agent, executionCountBefore)=>'failed' === deriveCaseStatus((agent.dump?.executions ?? []).slice(executionCountBefore));
10
+ const recordYamlTaskError = async (agent, task, flowItemIndex, error)=>{
11
+ const recordErrorToReport = agent.recordErrorToReport;
12
+ if ('function' != typeof recordErrorToReport) return;
13
+ try {
14
+ await recordErrorToReport.call(agent, `YAML task failed - ${task.name}`, {
15
+ error,
16
+ content: `Step ${flowItemIndex} failed while running YAML task "${task.name}".`
17
+ });
18
+ } catch (reportError) {
19
+ debug('failed to record yaml error to report', reportError);
20
+ }
21
+ };
22
+ const createLegacyYamlNodeResolver = (options, resolveTask, recordTaskErrors, captureReportTraces)=>{
23
+ const definitions = new Map(legacyAgentTestRunnerNodeDefinitions.map((definition)=>[
24
+ definition.name,
25
+ definition
26
+ ]));
27
+ const nodes = new Map();
28
+ return (name)=>{
29
+ const existing = nodes.get(name);
30
+ if (existing) return existing;
31
+ const definition = definitions.get(name);
32
+ assert(definition, `Unknown Agent Node: ${name}`);
33
+ const node = defineNode({
34
+ name,
35
+ inputSchema: definition.inputSchema,
36
+ execute: (ctx)=>runInYamlExecutionContext(async ()=>{
37
+ ctx.signal.throwIfAborted();
38
+ assertResourceAvailable(options.agent, false, ctx.signal);
39
+ assert('case' === ctx.scope, 'YAML task requires a Case scope');
40
+ const taskIndex = ctx.case.caseIndex;
41
+ const flowItemIndex = ctx.case.stepIndex;
42
+ const task = resolveTask(taskIndex);
43
+ assert(task, `missing YAML task at index ${taskIndex}`);
44
+ assert(task.flow, 'missing flow in task');
45
+ const executionCountBeforeStep = options.agent.dump?.executions?.length ?? 0;
46
+ const addDumpUpdateListener = captureReportTraces ? options.agent.addDumpUpdateListener : void 0;
47
+ const removeDumpListener = 'function' == typeof addDumpUpdateListener ? addDumpUpdateListener.call(options.agent, (_dump, execution)=>{
48
+ if (!ctx.signal.aborted && execution?.id) ctx.report.addTrace({
49
+ type: 'midscene-execution',
50
+ executionId: execution.id
51
+ });
52
+ }) : void 0;
53
+ let listening = true;
54
+ const removeListener = ()=>{
55
+ if (!listening) return;
56
+ listening = false;
57
+ removeDumpListener?.();
58
+ };
59
+ const operation = trackResourceOperation(options.agent, Promise.resolve().then(()=>{
60
+ ctx.signal.throwIfAborted();
61
+ return definition.execute(options.agent, ctx.input, {
62
+ signal: ctx.signal
63
+ });
64
+ }), ctx.signal);
65
+ const leaveAction = enterYamlAction(options.agent, ctx.signal);
66
+ const onAbort = ()=>{
67
+ removeListener();
68
+ };
69
+ ctx.signal.addEventListener('abort', onAbort, {
70
+ once: true
71
+ });
72
+ try {
73
+ return await operation;
74
+ } catch (error) {
75
+ const reportAlreadyContainsFailure = hasFailedReportExecutionSince(options.agent, executionCountBeforeStep);
76
+ if (!ctx.signal.aborted && recordTaskErrors && !reportAlreadyContainsFailure) await recordYamlTaskError(options.agent, task, flowItemIndex, error);
77
+ throw error;
78
+ } finally{
79
+ ctx.signal.removeEventListener('abort', onAbort);
80
+ removeListener();
81
+ leaveAction();
82
+ }
83
+ })
84
+ });
85
+ nodes.set(name, node);
86
+ return node;
87
+ };
88
+ };
89
+ const runLegacyYamlDocument = (document, options, resolveTask, recordTaskErrors, captureReportTraces, runOptions)=>runWorkflowDocument(document, {
90
+ ...runOptions ?? {},
91
+ onStepResult: async (info, result)=>{
92
+ if (result.meta.captureResult && result.output && Object.hasOwn(result.output, 'data')) await options.setResult(result.meta.resultName, getLegacyYamlResultData(result.node, result.output));
93
+ await runOptions?.onStepResult?.(info, result);
94
+ },
95
+ resolveNode: createLegacyYamlNodeResolver(options, resolveTask, recordTaskErrors, captureReportTraces),
96
+ projectContext: options.agent,
97
+ retry: 0,
98
+ resolveCaseReportScopeId: (_collectedCase, _attemptIndex, documentRunId)=>documentRunId
99
+ });
100
+ const createLegacyYamlRuntime = (options)=>{
101
+ const sourcePath = options.sourcePath ?? '<inline-yaml>';
102
+ return {
103
+ waitForIdle: ()=>waitForResourceIdle(options.agent),
104
+ runScript: (script, runOptions)=>runLegacyYamlDocument(runOptions?.document ?? collectLegacyYamlDocument(script, sourcePath, options.actionSpace), options, (taskIndex)=>script.tasks?.[taskIndex], true, true, runOptions),
105
+ runTask: (task, taskIndex, runOptions)=>runLegacyYamlDocument(collectLegacyYamlTaskDocument(task, taskIndex, sourcePath, options.actionSpace), options, ()=>task, false, false, runOptions)
106
+ };
107
+ };
108
+ const legacyYamlOutcomeError = (outcome)=>{
109
+ const failedStep = [
110
+ ...outcome.run?.beforeEach ?? [],
111
+ ...outcome.run?.steps ?? [],
112
+ ...outcome.run?.afterEach ?? []
113
+ ].find((step)=>'failed' === step.status);
114
+ const error = failedStep?.error;
115
+ return error?.code === 'NODE_EXECUTION_ERROR' && error.cause instanceof Error ? error.cause : error ?? new Error(`Task "${outcome.name}" failed`);
116
+ };
117
+ export { createLegacyYamlRuntime, legacyYamlOutcomeError };
118
+
119
+ //# sourceMappingURL=legacy-yaml-runtime.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"yaml/legacy-yaml-runtime.mjs","sources":["../../../src/yaml/legacy-yaml-runtime.ts"],"sourcesContent":["import type { Agent } from '@/agent/agent';\nimport { deriveCaseStatus } from '@/dump/task-status';\nimport type {\n DeviceAction,\n MidsceneYamlScript,\n MidsceneYamlTask,\n} from '@/types';\nimport { getDebug } from '@midscene/shared/logger';\nimport { assert } from '@midscene/shared/utils';\nimport {\n type CaseRunOutcome,\n type CollectedWorkflowDocument,\n type NodeDefinition,\n type RunWorkflowDocumentOptions,\n type WorkflowDocumentExecutionResult,\n assertResourceAvailable,\n defineNode,\n runWorkflowDocument,\n trackResourceOperation,\n waitForResourceIdle,\n} from '../test-runner';\nimport {\n enterYamlAction,\n runInYamlExecutionContext,\n} from './execution-session';\nimport {\n collectLegacyYamlDocument,\n collectLegacyYamlTaskDocument,\n} from './test-runner-compat';\nimport {\n getLegacyYamlResultData,\n legacyAgentTestRunnerNodeDefinitions,\n} from './test-runner-nodes';\nconst debug = getDebug('yaml-player');\n\ntype SetLegacyYamlResult = (\n key: string | undefined,\n value: any,\n) => void | Promise<void>;\n\nexport type LegacyYamlRuntimeRunOptions = Omit<\n RunWorkflowDocumentOptions<Agent>,\n 'projectContext' | 'resolveCaseReportScopeId' | 'resolveNode' | 'retry'\n> & { document?: CollectedWorkflowDocument };\n\nexport interface LegacyYamlRuntimeOptions {\n agent: Agent;\n actionSpace: readonly DeviceAction[];\n sourcePath?: string;\n setResult: SetLegacyYamlResult;\n}\n\nexport interface LegacyYamlRuntime {\n /** Wait before releasing an Agent whose non-cooperative action was aborted. */\n waitForIdle(): Promise<void>;\n runScript(\n script: MidsceneYamlScript,\n options?: LegacyYamlRuntimeRunOptions,\n ): Promise<WorkflowDocumentExecutionResult>;\n runTask(\n task: MidsceneYamlTask,\n taskIndex: number,\n options?: LegacyYamlRuntimeRunOptions,\n ): Promise<WorkflowDocumentExecutionResult>;\n}\n\nconst hasFailedReportExecutionSince = (\n agent: Agent,\n executionCountBefore: number,\n): boolean =>\n deriveCaseStatus(\n (agent.dump?.executions ?? []).slice(executionCountBefore),\n ) === 'failed';\n\nconst recordYamlTaskError = async (\n agent: Agent,\n task: MidsceneYamlTask,\n flowItemIndex: number,\n error: Error,\n): Promise<void> => {\n const recordErrorToReport = (agent as any).recordErrorToReport;\n if (typeof recordErrorToReport !== 'function') return;\n\n try {\n await recordErrorToReport.call(agent, `YAML task failed - ${task.name}`, {\n error,\n content: `Step ${flowItemIndex} failed while running YAML task \"${task.name}\".`,\n });\n } catch (reportError) {\n debug('failed to record yaml error to report', reportError);\n }\n};\n\nconst createLegacyYamlNodeResolver = (\n options: LegacyYamlRuntimeOptions,\n resolveTask: (taskIndex: number) => MidsceneYamlTask | undefined,\n recordTaskErrors: boolean,\n captureReportTraces: boolean,\n): ((\n name: string,\n) => NodeDefinition<Record<string, unknown>, unknown, Agent>) => {\n const definitions = new Map(\n legacyAgentTestRunnerNodeDefinitions.map((definition) => [\n definition.name,\n definition,\n ]),\n );\n const nodes = new Map<\n string,\n NodeDefinition<Record<string, unknown>, unknown, Agent>\n >();\n\n return (name) => {\n const existing = nodes.get(name);\n if (existing) return existing;\n\n const definition = definitions.get(name);\n assert(definition, `Unknown Agent Node: ${name}`);\n const node = defineNode<Record<string, unknown>, unknown, Agent>({\n name,\n inputSchema: definition.inputSchema,\n execute: (ctx) =>\n runInYamlExecutionContext(async () => {\n ctx.signal.throwIfAborted();\n assertResourceAvailable(options.agent, false, ctx.signal);\n assert(ctx.scope === 'case', 'YAML task requires a Case scope');\n const taskIndex = ctx.case.caseIndex;\n const flowItemIndex = ctx.case.stepIndex;\n const task = resolveTask(taskIndex);\n assert(task, `missing YAML task at index ${taskIndex}`);\n assert(task.flow, 'missing flow in task');\n\n const executionCountBeforeStep =\n options.agent.dump?.executions?.length ?? 0;\n const addDumpUpdateListener = captureReportTraces\n ? (options.agent as any).addDumpUpdateListener\n : undefined;\n const removeDumpListener =\n typeof addDumpUpdateListener === 'function'\n ? addDumpUpdateListener.call(\n options.agent,\n (_dump: string, execution?: { id?: string }) => {\n if (!ctx.signal.aborted && execution?.id) {\n ctx.report.addTrace({\n type: 'midscene-execution',\n executionId: execution.id,\n });\n }\n },\n )\n : undefined;\n\n let listening = true;\n const removeListener = () => {\n if (!listening) return;\n listening = false;\n removeDumpListener?.();\n };\n const operation = trackResourceOperation(\n options.agent,\n Promise.resolve().then(() => {\n ctx.signal.throwIfAborted();\n return definition.execute(options.agent, ctx.input, {\n signal: ctx.signal,\n });\n }),\n ctx.signal,\n );\n const leaveAction = enterYamlAction(options.agent, ctx.signal);\n const onAbort = () => {\n removeListener();\n };\n ctx.signal.addEventListener('abort', onAbort, { once: true });\n\n try {\n return await operation;\n } catch (error) {\n const reportAlreadyContainsFailure = hasFailedReportExecutionSince(\n options.agent,\n executionCountBeforeStep,\n );\n if (\n !ctx.signal.aborted &&\n recordTaskErrors &&\n !reportAlreadyContainsFailure\n ) {\n await recordYamlTaskError(\n options.agent,\n task,\n flowItemIndex,\n error as Error,\n );\n }\n throw error;\n } finally {\n ctx.signal.removeEventListener('abort', onAbort);\n removeListener();\n leaveAction();\n }\n }),\n });\n nodes.set(name, node);\n return node;\n };\n};\n\nconst runLegacyYamlDocument = (\n document: CollectedWorkflowDocument,\n options: LegacyYamlRuntimeOptions,\n resolveTask: (taskIndex: number) => MidsceneYamlTask | undefined,\n recordTaskErrors: boolean,\n captureReportTraces: boolean,\n runOptions?: LegacyYamlRuntimeRunOptions,\n): Promise<WorkflowDocumentExecutionResult> => {\n return runWorkflowDocument(document, {\n ...(runOptions ?? {}),\n onStepResult: async (info, result) => {\n if (\n result.meta.captureResult &&\n result.output &&\n Object.hasOwn(result.output, 'data')\n ) {\n // Publication follows the recorded action. The Node result is never mutated.\n await options.setResult(\n result.meta.resultName,\n getLegacyYamlResultData(result.node, result.output),\n );\n }\n await runOptions?.onStepResult?.(info, result);\n },\n resolveNode: createLegacyYamlNodeResolver(\n options,\n resolveTask,\n recordTaskErrors,\n captureReportTraces,\n ),\n projectContext: options.agent,\n // Legacy CLI retry recreates the whole player and Agent outside this\n // runtime, so the shared kernel must not retry a Case here.\n retry: 0,\n // One legacy YAML file owns one Agent report shared by all of its tasks.\n resolveCaseReportScopeId: (_collectedCase, _attemptIndex, documentRunId) =>\n documentRunId,\n });\n};\n\nexport const createLegacyYamlRuntime = (\n options: LegacyYamlRuntimeOptions,\n): LegacyYamlRuntime => {\n const sourcePath = options.sourcePath ?? '<inline-yaml>';\n return {\n waitForIdle: () => waitForResourceIdle(options.agent),\n runScript: (script, runOptions) =>\n runLegacyYamlDocument(\n runOptions?.document ??\n collectLegacyYamlDocument(script, sourcePath, options.actionSpace),\n options,\n (taskIndex) => script.tasks?.[taskIndex],\n true,\n true,\n runOptions,\n ),\n runTask: (task, taskIndex, runOptions) =>\n runLegacyYamlDocument(\n collectLegacyYamlTaskDocument(\n task,\n taskIndex,\n sourcePath,\n options.actionSpace,\n ),\n options,\n () => task,\n false,\n false,\n runOptions,\n ),\n };\n};\n\nexport const legacyYamlOutcomeError = (outcome: CaseRunOutcome): Error => {\n const failedStep = [\n ...(outcome.run?.beforeEach ?? []),\n ...(outcome.run?.steps ?? []),\n ...(outcome.run?.afterEach ?? []),\n ].find((step) => step.status === 'failed');\n const error = failedStep?.error;\n return error?.code === 'NODE_EXECUTION_ERROR' && error.cause instanceof Error\n ? error.cause\n : (error ?? new Error(`Task \"${outcome.name}\" failed`));\n};\n"],"names":["debug","getDebug","hasFailedReportExecutionSince","agent","executionCountBefore","deriveCaseStatus","recordYamlTaskError","task","flowItemIndex","error","recordErrorToReport","reportError","createLegacyYamlNodeResolver","options","resolveTask","recordTaskErrors","captureReportTraces","definitions","Map","legacyAgentTestRunnerNodeDefinitions","definition","nodes","name","existing","assert","node","defineNode","ctx","runInYamlExecutionContext","assertResourceAvailable","taskIndex","executionCountBeforeStep","addDumpUpdateListener","undefined","removeDumpListener","_dump","execution","listening","removeListener","operation","trackResourceOperation","Promise","leaveAction","enterYamlAction","onAbort","reportAlreadyContainsFailure","runLegacyYamlDocument","document","runOptions","runWorkflowDocument","info","result","Object","getLegacyYamlResultData","_collectedCase","_attemptIndex","documentRunId","createLegacyYamlRuntime","sourcePath","waitForResourceIdle","script","collectLegacyYamlDocument","collectLegacyYamlTaskDocument","legacyYamlOutcomeError","outcome","failedStep","step","Error"],"mappings":"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"}
@@ -0,0 +1,15 @@
1
+ const stateKey = Symbol.for('@midscene/core/yaml-player-state/v1');
2
+ const host = globalThis;
3
+ host[stateKey] ??= new WeakMap();
4
+ const states = host[stateKey];
5
+ function initializeLegacyYamlPlayerState(player) {
6
+ states.set(player, {});
7
+ }
8
+ function getLegacyYamlPlayerState(player) {
9
+ const state = states.get(player);
10
+ if (!state) throw new Error('Expected an initialized YAML ScriptPlayer.');
11
+ return state;
12
+ }
13
+ export { getLegacyYamlPlayerState, initializeLegacyYamlPlayerState };
14
+
15
+ //# sourceMappingURL=player-state.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"yaml/player-state.mjs","sources":["../../../src/yaml/player-state.ts"],"sourcesContent":["import type {\n WorkflowDocumentExecutionResult,\n WorkflowExecutionRecord,\n} from '../test-runner';\n\ninterface LegacyYamlPlayerState {\n executionResult?: WorkflowDocumentExecutionResult;\n executionRecord?: WorkflowExecutionRecord;\n fallbackReportFileName?: string;\n}\n\n// Hosts can load the public player through CJS and internal integration through ESM.\nconst stateKey = Symbol.for('@midscene/core/yaml-player-state/v1');\nconst host = globalThis as typeof globalThis & {\n [stateKey]?: WeakMap<object, LegacyYamlPlayerState>;\n};\nhost[stateKey] ??= new WeakMap();\nconst states = host[stateKey];\n\nexport function initializeLegacyYamlPlayerState(player: object): void {\n states.set(player, {});\n}\n\n/** Package integration only; do not expose host controls on ScriptPlayer. */\nexport function getLegacyYamlPlayerState(\n player: object,\n): LegacyYamlPlayerState {\n const state = states.get(player);\n if (!state) throw new Error('Expected an initialized YAML ScriptPlayer.');\n return state;\n}\n"],"names":["stateKey","Symbol","host","globalThis","WeakMap","states","initializeLegacyYamlPlayerState","player","getLegacyYamlPlayerState","state","Error"],"mappings":"AAYA,MAAMA,WAAWC,OAAO,GAAG,CAAC;AAC5B,MAAMC,OAAOC;AAGbD,IAAI,CAACF,SAAS,KAAK,IAAII;AACvB,MAAMC,SAASH,IAAI,CAACF,SAAS;AAEtB,SAASM,gCAAgCC,MAAc;IAC5DF,OAAO,GAAG,CAACE,QAAQ,CAAC;AACtB;AAGO,SAASC,yBACdD,MAAc;IAEd,MAAME,QAAQJ,OAAO,GAAG,CAACE;IACzB,IAAI,CAACE,OAAO,MAAM,IAAIC,MAAM;IAC5B,OAAOD;AACT"}