@midscene/core 1.9.8 → 1.10.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 (256) hide show
  1. package/dist/es/agent/agent.mjs +26 -94
  2. package/dist/es/agent/agent.mjs.map +1 -1
  3. package/dist/es/agent/prompt-context.mjs +14 -0
  4. package/dist/es/agent/prompt-context.mjs.map +1 -0
  5. package/dist/es/agent/run-gherkin-scenario.mjs +114 -0
  6. package/dist/es/agent/run-gherkin-scenario.mjs.map +1 -0
  7. package/dist/es/agent/task-builder.mjs +4 -4
  8. package/dist/es/agent/task-builder.mjs.map +1 -1
  9. package/dist/es/agent/tasks.mjs +4 -8
  10. package/dist/es/agent/tasks.mjs.map +1 -1
  11. package/dist/es/agent/utils.mjs +15 -3
  12. package/dist/es/agent/utils.mjs.map +1 -1
  13. package/dist/es/ai-model/index.mjs +1 -2
  14. package/dist/es/ai-model/inspect.mjs +77 -50
  15. package/dist/es/ai-model/inspect.mjs.map +1 -1
  16. package/dist/es/ai-model/llm-planning.mjs +10 -26
  17. package/dist/es/ai-model/llm-planning.mjs.map +1 -1
  18. package/dist/es/ai-model/model-adapter/chat-completion.mjs +46 -0
  19. package/dist/es/ai-model/model-adapter/chat-completion.mjs.map +1 -0
  20. package/dist/es/ai-model/model-adapter/index.mjs +2 -0
  21. package/dist/es/ai-model/model-adapter/locate.mjs +33 -0
  22. package/dist/es/ai-model/model-adapter/locate.mjs.map +1 -0
  23. package/dist/es/ai-model/model-adapter/planning.mjs +44 -0
  24. package/dist/es/ai-model/model-adapter/planning.mjs.map +1 -0
  25. package/dist/es/ai-model/model-adapter/resolve.mjs +43 -0
  26. package/dist/es/ai-model/model-adapter/resolve.mjs.map +1 -0
  27. package/dist/es/ai-model/model-adapter/types.mjs +0 -0
  28. package/dist/es/ai-model/models/auto-glm/actions.mjs +19 -31
  29. package/dist/es/ai-model/models/auto-glm/actions.mjs.map +1 -1
  30. package/dist/es/ai-model/models/auto-glm/adapter.mjs +8 -16
  31. package/dist/es/ai-model/models/auto-glm/adapter.mjs.map +1 -1
  32. package/dist/es/ai-model/models/auto-glm/locate.mjs +6 -108
  33. package/dist/es/ai-model/models/auto-glm/locate.mjs.map +1 -1
  34. package/dist/es/ai-model/models/auto-glm/parser.mjs +19 -41
  35. package/dist/es/ai-model/models/auto-glm/parser.mjs.map +1 -1
  36. package/dist/es/ai-model/models/auto-glm/planning.mjs +27 -70
  37. package/dist/es/ai-model/models/auto-glm/planning.mjs.map +1 -1
  38. package/dist/es/ai-model/models/default.mjs.map +1 -1
  39. package/dist/es/ai-model/models/doubao.mjs.map +1 -1
  40. package/dist/es/ai-model/models/gemini.mjs +1 -1
  41. package/dist/es/ai-model/models/gemini.mjs.map +1 -1
  42. package/dist/es/ai-model/models/glm.mjs.map +1 -1
  43. package/dist/es/ai-model/models/gpt.mjs.map +1 -1
  44. package/dist/es/ai-model/models/kimi.mjs.map +1 -1
  45. package/dist/es/ai-model/models/mimo.mjs.map +1 -1
  46. package/dist/es/ai-model/models/qwen.mjs.map +1 -1
  47. package/dist/es/ai-model/models/registry.mjs +1 -1
  48. package/dist/es/ai-model/models/registry.mjs.map +1 -1
  49. package/dist/es/ai-model/models/ui-tars/actions.mjs +147 -0
  50. package/dist/es/ai-model/models/ui-tars/actions.mjs.map +1 -0
  51. package/dist/es/ai-model/models/ui-tars/adapter.mjs +2 -2
  52. package/dist/es/ai-model/models/ui-tars/adapter.mjs.map +1 -1
  53. package/dist/es/ai-model/models/ui-tars/parser.mjs +40 -0
  54. package/dist/es/ai-model/models/ui-tars/parser.mjs.map +1 -0
  55. package/dist/es/ai-model/models/ui-tars/planning.mjs +19 -230
  56. package/dist/es/ai-model/models/ui-tars/planning.mjs.map +1 -1
  57. package/dist/es/ai-model/{prompt/ui-tars-planning.mjs → models/ui-tars/prompt.mjs} +1 -1
  58. package/dist/es/ai-model/models/ui-tars/prompt.mjs.map +1 -0
  59. package/dist/es/ai-model/service-caller/index.mjs +1 -3
  60. package/dist/es/ai-model/service-caller/index.mjs.map +1 -1
  61. package/dist/es/ai-model/shared/model-locate-result/coordinate-distance.mjs +10 -0
  62. package/dist/es/ai-model/shared/model-locate-result/coordinate-distance.mjs.map +1 -0
  63. package/dist/es/ai-model/shared/model-locate-result/factory.mjs +1 -3
  64. package/dist/es/ai-model/shared/model-locate-result/factory.mjs.map +1 -1
  65. package/dist/es/ai-model/shared/model-locate-result/index.mjs +3 -2
  66. package/dist/es/ai-model/shared/planning-action.mjs +6 -0
  67. package/dist/es/ai-model/shared/planning-action.mjs.map +1 -0
  68. package/dist/es/ai-model/workflows/inspect/planning-action-locate.mjs +95 -0
  69. package/dist/es/ai-model/workflows/inspect/planning-action-locate.mjs.map +1 -0
  70. package/dist/es/ai-model/workflows/planning/custom-planning.mjs +126 -0
  71. package/dist/es/ai-model/workflows/planning/custom-planning.mjs.map +1 -0
  72. package/dist/es/ai-model/workflows/planning/locate-normalization.mjs +31 -0
  73. package/dist/es/ai-model/workflows/planning/locate-normalization.mjs.map +1 -0
  74. package/dist/es/common.mjs +10 -6
  75. package/dist/es/common.mjs.map +1 -1
  76. package/dist/es/element-describer.mjs +180 -0
  77. package/dist/es/element-describer.mjs.map +1 -0
  78. package/dist/es/index.mjs +2 -1
  79. package/dist/es/index.mjs.map +1 -1
  80. package/dist/es/report-generator.mjs +3 -5
  81. package/dist/es/report-generator.mjs.map +1 -1
  82. package/dist/es/service/index.mjs +3 -2
  83. package/dist/es/service/index.mjs.map +1 -1
  84. package/dist/es/skill/index.mjs +1 -1
  85. package/dist/es/skill/index.mjs.map +1 -1
  86. package/dist/es/types.mjs.map +1 -1
  87. package/dist/es/utils.mjs +2 -2
  88. package/dist/es/yaml/player.mjs +7 -0
  89. package/dist/es/yaml/player.mjs.map +1 -1
  90. package/dist/lib/agent/agent.js +25 -93
  91. package/dist/lib/agent/agent.js.map +1 -1
  92. package/dist/lib/{ai-model/models/chat-content.js → agent/prompt-context.js} +13 -13
  93. package/dist/lib/agent/prompt-context.js.map +1 -0
  94. package/dist/lib/agent/run-gherkin-scenario.js +151 -0
  95. package/dist/lib/agent/run-gherkin-scenario.js.map +1 -0
  96. package/dist/lib/agent/task-builder.js +4 -4
  97. package/dist/lib/agent/task-builder.js.map +1 -1
  98. package/dist/lib/agent/tasks.js +4 -8
  99. package/dist/lib/agent/tasks.js.map +1 -1
  100. package/dist/lib/agent/utils.js +14 -2
  101. package/dist/lib/agent/utils.js.map +1 -1
  102. package/dist/lib/ai-model/index.js +0 -10
  103. package/dist/lib/ai-model/inspect.js +77 -50
  104. package/dist/lib/ai-model/inspect.js.map +1 -1
  105. package/dist/lib/ai-model/llm-planning.js +9 -25
  106. package/dist/lib/ai-model/llm-planning.js.map +1 -1
  107. package/dist/lib/ai-model/model-adapter/chat-completion.js +83 -0
  108. package/dist/lib/ai-model/model-adapter/chat-completion.js.map +1 -0
  109. package/dist/lib/ai-model/model-adapter/custom-planning-types.js +20 -0
  110. package/dist/lib/ai-model/model-adapter/custom-planning-types.js.map +1 -0
  111. package/dist/lib/ai-model/model-adapter/index.js +38 -0
  112. package/dist/lib/ai-model/model-adapter/index.js.map +1 -0
  113. package/dist/lib/ai-model/model-adapter/locate.js +67 -0
  114. package/dist/lib/ai-model/model-adapter/locate.js.map +1 -0
  115. package/dist/lib/ai-model/model-adapter/planning.js +81 -0
  116. package/dist/lib/ai-model/model-adapter/planning.js.map +1 -0
  117. package/dist/lib/ai-model/model-adapter/resolve.js +77 -0
  118. package/dist/lib/ai-model/model-adapter/resolve.js.map +1 -0
  119. package/dist/lib/ai-model/model-adapter/types.js.map +1 -0
  120. package/dist/lib/ai-model/models/auto-glm/actions.js +19 -31
  121. package/dist/lib/ai-model/models/auto-glm/actions.js.map +1 -1
  122. package/dist/lib/ai-model/models/auto-glm/adapter.js +6 -14
  123. package/dist/lib/ai-model/models/auto-glm/adapter.js.map +1 -1
  124. package/dist/lib/ai-model/models/auto-glm/locate.js +8 -110
  125. package/dist/lib/ai-model/models/auto-glm/locate.js.map +1 -1
  126. package/dist/lib/ai-model/models/auto-glm/parser.js +24 -46
  127. package/dist/lib/ai-model/models/auto-glm/parser.js.map +1 -1
  128. package/dist/lib/ai-model/models/auto-glm/planning.js +28 -71
  129. package/dist/lib/ai-model/models/auto-glm/planning.js.map +1 -1
  130. package/dist/lib/ai-model/models/default.js.map +1 -1
  131. package/dist/lib/ai-model/models/doubao.js.map +1 -1
  132. package/dist/lib/ai-model/models/gemini.js +2 -2
  133. package/dist/lib/ai-model/models/gemini.js.map +1 -1
  134. package/dist/lib/ai-model/models/glm.js.map +1 -1
  135. package/dist/lib/ai-model/models/gpt.js.map +1 -1
  136. package/dist/lib/ai-model/models/kimi.js.map +1 -1
  137. package/dist/lib/ai-model/models/mimo.js.map +1 -1
  138. package/dist/lib/ai-model/models/qwen.js.map +1 -1
  139. package/dist/lib/ai-model/models/registry.js +2 -2
  140. package/dist/lib/ai-model/models/registry.js.map +1 -1
  141. package/dist/lib/ai-model/models/ui-tars/actions.js +181 -0
  142. package/dist/lib/ai-model/models/ui-tars/actions.js.map +1 -0
  143. package/dist/lib/ai-model/models/ui-tars/adapter.js +1 -1
  144. package/dist/lib/ai-model/models/ui-tars/adapter.js.map +1 -1
  145. package/dist/lib/ai-model/models/ui-tars/parser.js +74 -0
  146. package/dist/lib/ai-model/models/ui-tars/parser.js.map +1 -0
  147. package/dist/lib/ai-model/models/ui-tars/planning.js +21 -232
  148. package/dist/lib/ai-model/models/ui-tars/planning.js.map +1 -1
  149. package/dist/lib/ai-model/{prompt/ui-tars-planning.js → models/ui-tars/prompt.js} +1 -1
  150. package/dist/lib/ai-model/models/ui-tars/prompt.js.map +1 -0
  151. package/dist/lib/ai-model/service-caller/index.js +1 -3
  152. package/dist/lib/ai-model/service-caller/index.js.map +1 -1
  153. package/dist/lib/ai-model/shared/model-locate-result/coordinate-distance.js +44 -0
  154. package/dist/lib/ai-model/shared/model-locate-result/coordinate-distance.js.map +1 -0
  155. package/dist/lib/ai-model/shared/model-locate-result/factory.js +5 -4
  156. package/dist/lib/ai-model/shared/model-locate-result/factory.js.map +1 -1
  157. package/dist/lib/ai-model/shared/model-locate-result/index.js +7 -0
  158. package/dist/lib/ai-model/shared/planning-action.js +40 -0
  159. package/dist/lib/ai-model/shared/planning-action.js.map +1 -0
  160. package/dist/lib/ai-model/workflows/inspect/planning-action-locate.js +129 -0
  161. package/dist/lib/ai-model/workflows/inspect/planning-action-locate.js.map +1 -0
  162. package/dist/lib/ai-model/workflows/planning/custom-planning.js +163 -0
  163. package/dist/lib/ai-model/workflows/planning/custom-planning.js.map +1 -0
  164. package/dist/lib/ai-model/workflows/planning/locate-normalization.js +65 -0
  165. package/dist/lib/ai-model/workflows/planning/locate-normalization.js.map +1 -0
  166. package/dist/lib/common.js +13 -6
  167. package/dist/lib/common.js.map +1 -1
  168. package/dist/lib/element-describer.js +223 -0
  169. package/dist/lib/element-describer.js.map +1 -0
  170. package/dist/lib/index.js +14 -1
  171. package/dist/lib/index.js.map +1 -1
  172. package/dist/lib/report-generator.js +4 -6
  173. package/dist/lib/report-generator.js.map +1 -1
  174. package/dist/lib/service/index.js +3 -2
  175. package/dist/lib/service/index.js.map +1 -1
  176. package/dist/lib/skill/index.js +1 -1
  177. package/dist/lib/skill/index.js.map +1 -1
  178. package/dist/lib/types.js.map +1 -1
  179. package/dist/lib/utils.js +2 -2
  180. package/dist/lib/yaml/player.js +7 -0
  181. package/dist/lib/yaml/player.js.map +1 -1
  182. package/dist/types/agent/agent.d.ts +4 -18
  183. package/dist/types/agent/index.d.ts +3 -2
  184. package/dist/types/agent/prompt-context.d.ts +2 -0
  185. package/dist/types/agent/run-gherkin-scenario.d.ts +26 -0
  186. package/dist/types/agent/tasks.d.ts +3 -1
  187. package/dist/types/ai-model/index.d.ts +0 -2
  188. package/dist/types/ai-model/inspect.d.ts +3 -2
  189. package/dist/types/ai-model/model-adapter/chat-completion.d.ts +3 -0
  190. package/dist/types/ai-model/model-adapter/custom-planning-types.d.ts +32 -0
  191. package/dist/types/ai-model/model-adapter/index.d.ts +2 -0
  192. package/dist/types/ai-model/model-adapter/locate.d.ts +3 -0
  193. package/dist/types/ai-model/model-adapter/planning.d.ts +4 -0
  194. package/dist/types/ai-model/{models → model-adapter}/types.d.ts +39 -4
  195. package/dist/types/ai-model/models/auto-glm/actions.d.ts +8 -5
  196. package/dist/types/ai-model/models/auto-glm/adapter.d.ts +1 -1
  197. package/dist/types/ai-model/models/auto-glm/locate.d.ts +2 -3
  198. package/dist/types/ai-model/models/auto-glm/parser.d.ts +6 -10
  199. package/dist/types/ai-model/models/auto-glm/planning.d.ts +5 -4
  200. package/dist/types/ai-model/models/default.d.ts +1 -1
  201. package/dist/types/ai-model/models/doubao.d.ts +1 -1
  202. package/dist/types/ai-model/models/gemini.d.ts +1 -1
  203. package/dist/types/ai-model/models/glm.d.ts +1 -1
  204. package/dist/types/ai-model/models/gpt.d.ts +1 -1
  205. package/dist/types/ai-model/models/index.d.ts +1 -1
  206. package/dist/types/ai-model/models/kimi.d.ts +1 -1
  207. package/dist/types/ai-model/models/mimo.d.ts +1 -1
  208. package/dist/types/ai-model/models/qwen.d.ts +1 -1
  209. package/dist/types/ai-model/models/registry.d.ts +10 -10
  210. package/dist/types/ai-model/models/ui-tars/actions.d.ts +3 -0
  211. package/dist/types/ai-model/models/ui-tars/adapter.d.ts +1 -1
  212. package/dist/types/ai-model/models/ui-tars/parser.d.ts +72 -0
  213. package/dist/types/ai-model/models/ui-tars/planning.d.ts +3 -68
  214. package/dist/types/ai-model/service-caller/index.d.ts +4 -5
  215. package/dist/types/ai-model/shared/model-locate-result/coordinate-distance.d.ts +4 -0
  216. package/dist/types/ai-model/shared/model-locate-result/factory.d.ts +2 -1
  217. package/dist/types/ai-model/shared/model-locate-result/index.d.ts +4 -2
  218. package/dist/types/ai-model/shared/model-locate-result/types.d.ts +0 -1
  219. package/dist/types/ai-model/shared/planning-action.d.ts +20 -0
  220. package/dist/types/ai-model/workflows/inspect/planning-action-locate.d.ts +4 -0
  221. package/dist/types/ai-model/workflows/inspect/types.d.ts +21 -2
  222. package/dist/types/ai-model/workflows/planning/custom-planning.d.ts +7 -0
  223. package/dist/types/ai-model/workflows/planning/locate-normalization.d.ts +9 -0
  224. package/dist/types/common.d.ts +1 -0
  225. package/dist/types/device/index.d.ts +17 -17
  226. package/dist/types/element-describer.d.ts +46 -0
  227. package/dist/types/index.d.ts +2 -1
  228. package/dist/types/service/index.d.ts +3 -1
  229. package/dist/types/types.d.ts +5 -0
  230. package/dist/types/yaml.d.ts +4 -1
  231. package/package.json +3 -3
  232. package/dist/es/ai-model/models/chat-content.mjs +0 -14
  233. package/dist/es/ai-model/models/chat-content.mjs.map +0 -1
  234. package/dist/es/ai-model/models/resolved.mjs +0 -107
  235. package/dist/es/ai-model/models/resolved.mjs.map +0 -1
  236. package/dist/es/ai-model/prompt/recorder-ui-describer.mjs +0 -56
  237. package/dist/es/ai-model/prompt/recorder-ui-describer.mjs.map +0 -1
  238. package/dist/es/ai-model/prompt/ui-tars-planning.mjs.map +0 -1
  239. package/dist/es/recorder-ui-describer.mjs +0 -379
  240. package/dist/es/recorder-ui-describer.mjs.map +0 -1
  241. package/dist/lib/ai-model/models/chat-content.js.map +0 -1
  242. package/dist/lib/ai-model/models/resolved.js +0 -141
  243. package/dist/lib/ai-model/models/resolved.js.map +0 -1
  244. package/dist/lib/ai-model/models/types.js.map +0 -1
  245. package/dist/lib/ai-model/prompt/recorder-ui-describer.js +0 -90
  246. package/dist/lib/ai-model/prompt/recorder-ui-describer.js.map +0 -1
  247. package/dist/lib/ai-model/prompt/ui-tars-planning.js.map +0 -1
  248. package/dist/lib/recorder-ui-describer.js +0 -419
  249. package/dist/lib/recorder-ui-describer.js.map +0 -1
  250. package/dist/types/ai-model/models/chat-content.d.ts +0 -2
  251. package/dist/types/ai-model/prompt/recorder-ui-describer.d.ts +0 -1
  252. package/dist/types/recorder-ui-describer.d.ts +0 -20
  253. /package/dist/es/ai-model/{models/types.mjs → model-adapter/custom-planning-types.mjs} +0 -0
  254. /package/dist/lib/ai-model/{models → model-adapter}/types.js +0 -0
  255. /package/dist/types/ai-model/{models/resolved.d.ts → model-adapter/resolve.d.ts} +0 -0
  256. /package/dist/types/ai-model/{prompt/ui-tars-planning.d.ts → models/ui-tars/prompt.d.ts} +0 -0
@@ -1,90 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.d = (exports1, definition)=>{
5
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
- enumerable: true,
7
- get: definition[key]
8
- });
9
- };
10
- })();
11
- (()=>{
12
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
- })();
14
- (()=>{
15
- __webpack_require__.r = (exports1)=>{
16
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
- value: 'Module'
18
- });
19
- Object.defineProperty(exports1, '__esModule', {
20
- value: true
21
- });
22
- };
23
- })();
24
- var __webpack_exports__ = {};
25
- __webpack_require__.r(__webpack_exports__);
26
- __webpack_require__.d(__webpack_exports__, {
27
- RECORDER_UI_DESCRIBER_SYSTEM_PROMPT: ()=>RECORDER_UI_DESCRIBER_SYSTEM_PROMPT
28
- });
29
- const RECORDER_UI_DESCRIBER_SYSTEM_PROMPT = `You convert Studio preview recorder UI events into semantic replay instructions.
30
-
31
- The recorder works from screenshots and mapped real-device coordinates only. Infer stable UI intent from the highlighted BEFORE screenshot. The AFTER screenshot is contextual evidence for state changes and scroll destinations.
32
-
33
- Output JSON only:
34
- {
35
- "elementDescription": "short stable target/region description",
36
- "replayInstruction": "one executable natural-language replay step",
37
- "actionSummary": "short timeline summary",
38
- "scrollDestinationDescription": "for scroll only: concrete newly visible destination content or goal",
39
- "confidence": "high" | "medium" | "low",
40
- "error"?: "only if no useful visual description can be inferred"
41
- }
42
-
43
- Rules:
44
- - Do NOT output coordinates as the main description.
45
- - Do NOT mention "near coordinates", "nearby element", "near point", "red marker", highlighted box, highlighted element, or screenshot.
46
- - Prefer stable target descriptions in this order: exact stable control text > stable label > role + stable section/context > icon purpose > visual position.
47
- - Treat placeholder or hint text that can change by user, time, data, or context as dynamic. Do not use dynamic hint values as the primary target description; prefer role + stable region + intent.
48
- - For repeated collections, treat item identity text as dynamic unless the user is clearly verifying that exact item. This includes any list/grid/table/feed/menu or repeated record surface. Do not output descriptions like "<role> titled/named '<content>'"; prefer stable role + region + selection intent.
49
- - Keep quoted UI text in the original UI language when it is a stable control label.
50
- - Apply the platform guidance from the user event:
51
- - Web: button, input, link, menu item, tab, dialog, aria-label, placeholder, form section.
52
- - Mobile: tab, list item, text field, icon button, navigation bar, bottom bar, sheet, card, screen section.
53
- - Desktop/computer: menu item, toolbar button, dialog field, sidebar item, window control, file row, application region.
54
- - Pointer action rules:
55
- - Preserve event.actionType semantics. Tap, DoubleClick, LongPress, and RightClick must not all become Click.
56
- - Tap replayInstruction format: Tap on the element described as "<elementDescription>".
57
- - DoubleClick replayInstruction format: Double click on the element described as "<elementDescription>".
58
- - LongPress replayInstruction format: Long press the element described as "<elementDescription>".
59
- - RightClick replayInstruction format: Right click on the element described as "<elementDescription>".
60
- - Click replayInstruction format: Click on the element described as "<elementDescription>".
61
- - Input-specific rules:
62
- - The highlighted BEFORE screenshot marks the field that receives the text.
63
- - The screenshot after the action may show the typed value; use it only to confirm the field, never as the field description.
64
- - elementDescription must identify the field itself by stable field role, nearby label, region, section, or sequence intent.
65
- - Never use "AI is analyzing element", the typed value, the page title alone, or a generic "input field" as elementDescription.
66
- - For consecutive input events, distinguish fields by stable role, section, order, current focus, filled/empty state, and neighboring actions instead of reusing the same generic field description.
67
- - Input replayInstruction format: Input "<value>" into the element described as "<elementDescription>".
68
- - Scroll target quality bar:
69
- - elementDescription describes the scrollable page, panel, list, table, or section at the highlighted scroll point.
70
- - When multiple scrollable regions are visible, preserve the specific region where the scroll happened, such as left/right/top/bottom panel, navigation area, content pane, dialog body, table, list, or menu. Do not generalize a panel/list scroll into the whole page.
71
- - scrollDestinationDescription is required and describes what the scroll is trying to reveal or reach, using newly visible headings, section titles, list items, or stable content from the AFTER screenshot.
72
- - Prefer descriptions like "Playwright integration documentation page, scrolling toward the API reference section" or "Android API documentation page, scrolling to the installation steps section".
73
- - Do NOT write generic phrases like "more content", "the page", "current screen", or "main scrollable area".
74
- - Scroll replayInstruction format: Scroll the page/region with description "<elementDescription>" by value "<recorded value>" until "<scrollDestinationDescription>" is visible.
75
- - Scroll actionSummary format: Scroll <elementDescription> toward <scrollDestinationDescription>.
76
- - Drag/Swipe rules:
77
- - Drag replayInstruction format: Drag through the area described as "<elementDescription>".
78
- - Swipe replayInstruction format: Swipe through the area described as "<elementDescription>".
79
- - Describe start/end regions or the dragged UI control; do not describe only the gesture path.
80
- - KeyboardPress replayInstruction format: Press "<value>" on the element described as "<elementDescription>".
81
- - If uncertain, provide the best concrete visible text/role/context description. Set confidence to "low"; do not fall back to coordinates.`;
82
- exports.RECORDER_UI_DESCRIBER_SYSTEM_PROMPT = __webpack_exports__.RECORDER_UI_DESCRIBER_SYSTEM_PROMPT;
83
- for(var __rspack_i in __webpack_exports__)if (-1 === [
84
- "RECORDER_UI_DESCRIBER_SYSTEM_PROMPT"
85
- ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
86
- Object.defineProperty(exports, '__esModule', {
87
- value: true
88
- });
89
-
90
- //# sourceMappingURL=recorder-ui-describer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ai-model/prompt/recorder-ui-describer.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/ai-model/prompt/recorder-ui-describer.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","export const RECORDER_UI_DESCRIBER_SYSTEM_PROMPT = `You convert Studio preview recorder UI events into semantic replay instructions.\n\nThe recorder works from screenshots and mapped real-device coordinates only. Infer stable UI intent from the highlighted BEFORE screenshot. The AFTER screenshot is contextual evidence for state changes and scroll destinations.\n\nOutput JSON only:\n{\n \"elementDescription\": \"short stable target/region description\",\n \"replayInstruction\": \"one executable natural-language replay step\",\n \"actionSummary\": \"short timeline summary\",\n \"scrollDestinationDescription\": \"for scroll only: concrete newly visible destination content or goal\",\n \"confidence\": \"high\" | \"medium\" | \"low\",\n \"error\"?: \"only if no useful visual description can be inferred\"\n}\n\nRules:\n- Do NOT output coordinates as the main description.\n- Do NOT mention \"near coordinates\", \"nearby element\", \"near point\", \"red marker\", highlighted box, highlighted element, or screenshot.\n- Prefer stable target descriptions in this order: exact stable control text > stable label > role + stable section/context > icon purpose > visual position.\n- Treat placeholder or hint text that can change by user, time, data, or context as dynamic. Do not use dynamic hint values as the primary target description; prefer role + stable region + intent.\n- For repeated collections, treat item identity text as dynamic unless the user is clearly verifying that exact item. This includes any list/grid/table/feed/menu or repeated record surface. Do not output descriptions like \"<role> titled/named '<content>'\"; prefer stable role + region + selection intent.\n- Keep quoted UI text in the original UI language when it is a stable control label.\n- Apply the platform guidance from the user event:\n - Web: button, input, link, menu item, tab, dialog, aria-label, placeholder, form section.\n - Mobile: tab, list item, text field, icon button, navigation bar, bottom bar, sheet, card, screen section.\n - Desktop/computer: menu item, toolbar button, dialog field, sidebar item, window control, file row, application region.\n- Pointer action rules:\n - Preserve event.actionType semantics. Tap, DoubleClick, LongPress, and RightClick must not all become Click.\n - Tap replayInstruction format: Tap on the element described as \"<elementDescription>\".\n - DoubleClick replayInstruction format: Double click on the element described as \"<elementDescription>\".\n - LongPress replayInstruction format: Long press the element described as \"<elementDescription>\".\n - RightClick replayInstruction format: Right click on the element described as \"<elementDescription>\".\n - Click replayInstruction format: Click on the element described as \"<elementDescription>\".\n- Input-specific rules:\n - The highlighted BEFORE screenshot marks the field that receives the text.\n - The screenshot after the action may show the typed value; use it only to confirm the field, never as the field description.\n - elementDescription must identify the field itself by stable field role, nearby label, region, section, or sequence intent.\n - Never use \"AI is analyzing element\", the typed value, the page title alone, or a generic \"input field\" as elementDescription.\n - For consecutive input events, distinguish fields by stable role, section, order, current focus, filled/empty state, and neighboring actions instead of reusing the same generic field description.\n - Input replayInstruction format: Input \"<value>\" into the element described as \"<elementDescription>\".\n- Scroll target quality bar:\n - elementDescription describes the scrollable page, panel, list, table, or section at the highlighted scroll point.\n - When multiple scrollable regions are visible, preserve the specific region where the scroll happened, such as left/right/top/bottom panel, navigation area, content pane, dialog body, table, list, or menu. Do not generalize a panel/list scroll into the whole page.\n - scrollDestinationDescription is required and describes what the scroll is trying to reveal or reach, using newly visible headings, section titles, list items, or stable content from the AFTER screenshot.\n - Prefer descriptions like \"Playwright integration documentation page, scrolling toward the API reference section\" or \"Android API documentation page, scrolling to the installation steps section\".\n - Do NOT write generic phrases like \"more content\", \"the page\", \"current screen\", or \"main scrollable area\".\n- Scroll replayInstruction format: Scroll the page/region with description \"<elementDescription>\" by value \"<recorded value>\" until \"<scrollDestinationDescription>\" is visible.\n- Scroll actionSummary format: Scroll <elementDescription> toward <scrollDestinationDescription>.\n- Drag/Swipe rules:\n - Drag replayInstruction format: Drag through the area described as \"<elementDescription>\".\n - Swipe replayInstruction format: Swipe through the area described as \"<elementDescription>\".\n - Describe start/end regions or the dragged UI control; do not describe only the gesture path.\n- KeyboardPress replayInstruction format: Press \"<value>\" on the element described as \"<elementDescription>\".\n- If uncertain, provide the best concrete visible text/role/context description. Set confidence to \"low\"; do not fall back to coordinates.`;\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","RECORDER_UI_DESCRIBER_SYSTEM_PROMPT"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;ACNO,MAAMI,sCAAsC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0IAoDsF,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ai-model/prompt/ui-tars-planning.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/ai-model/prompt/ui-tars-planning.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { getPreferredLanguage } from '@midscene/shared/env';\n\nexport function getUiTarsPlanningPrompt(): string {\n const preferredLanguage = getPreferredLanguage();\n\n return `\nYou are a GUI agent. You are given a task and your action history, with screenshots. You need to perform the next action to complete the task. \n\n## Output Format\n\\`\\`\\`\nThought: ...\nAction: ...\n\\`\\`\\`\n\n## Action Space\n\nclick(start_box='[x1, y1, x2, y2]')\nleft_double(start_box='[x1, y1, x2, y2]')\nright_single(start_box='[x1, y1, x2, y2]')\ndrag(start_box='[x1, y1, x2, y2]', end_box='[x3, y3, x4, y4]')\nhotkey(key='')\ntype(content='xxx') # Use escape characters \\\\', \\\\\\\", and \\\\n in content part to ensure we can parse the content in normal python string format. If you want to submit your input, use \\\\n at the end of content. \nscroll(start_box='[x1, y1, x2, y2]', direction='down or up or right or left')\nwait() #Sleep for 5s and take a screenshot to check for any changes.\nfinished(content='xxx') # Use escape characters \\\\', \\\\\", and \\\\n in content part to ensure we can parse the content in normal python string format.\n\n\n## Note\n- Use ${preferredLanguage} in \\`Thought\\` part.\n- Write a small plan and finally summarize your next action (with its target element) in one sentence in \\`Thought\\` part.\n\n## User Instruction\n`;\n}\n\nexport const getSummary = (prediction: string) =>\n prediction\n .replace(/Reflection:[\\s\\S]*?(?=Action_Summary:|Action:|$)/g, '')\n .trim();\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","getUiTarsPlanningPrompt","preferredLanguage","getPreferredLanguage","getSummary","prediction"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;ACJO,SAASI;IACd,MAAMC,oBAAoBC,AAAAA,IAAAA,oBAAAA,oBAAAA,AAAAA;IAE1B,OAAO,CAAC;;;;;;;;;;;;;;;;;;;;;;;MAuBJ,EAAED,kBAAkB;;;;AAI1B,CAAC;AACD;AAEO,MAAME,aAAa,CAACC,aACzBA,WACG,OAAO,CAAC,qDAAqD,IAC7D,IAAI"}
@@ -1,419 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.d = (exports1, definition)=>{
5
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
- enumerable: true,
7
- get: definition[key]
8
- });
9
- };
10
- })();
11
- (()=>{
12
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
- })();
14
- (()=>{
15
- __webpack_require__.r = (exports1)=>{
16
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
- value: 'Module'
18
- });
19
- Object.defineProperty(exports1, '__esModule', {
20
- value: true
21
- });
22
- };
23
- })();
24
- var __webpack_exports__ = {};
25
- __webpack_require__.r(__webpack_exports__);
26
- __webpack_require__.d(__webpack_exports__, {
27
- getRecorderUIEventTargetRect: ()=>getRecorderUIEventTargetRect,
28
- describeRecorderUIEvent: ()=>describeRecorderUIEvent,
29
- describeRecorderUIEvents: ()=>describeRecorderUIEvents
30
- });
31
- const img_namespaceObject = require("@midscene/shared/img");
32
- const recorder_namespaceObject = require("@midscene/shared/recorder");
33
- const recorder_ui_describer_js_namespaceObject = require("./ai-model/prompt/recorder-ui-describer.js");
34
- const index_js_namespaceObject = require("./ai-model/service-caller/index.js");
35
- const RECORDER_UI_DESCRIBER_DEFAULT_RETRIES = 2;
36
- const RECORDER_UI_DESCRIBER_DEFAULT_RETRY_DELAY_MS = 200;
37
- const RECORDER_UI_DESCRIBER_DEFAULT_CONCURRENCY = 2;
38
- function delay(ms) {
39
- return new Promise((resolve)=>setTimeout(resolve, ms));
40
- }
41
- function clamp(value, min, max) {
42
- return Math.min(Math.max(value, min), max);
43
- }
44
- function isFiniteNumber(value) {
45
- return 'number' == typeof value && Number.isFinite(value);
46
- }
47
- function isPendingDescription(value) {
48
- return value?.trim() === 'AI is analyzing element...';
49
- }
50
- function getRecorderEventScreenshot(event) {
51
- return event.screenshotWithBox || event.screenshotBefore || event.screenshotAfter;
52
- }
53
- function getRecorderEventAfterScreenshot(event) {
54
- return event.screenshotAfter || event.screenshotWithBox;
55
- }
56
- function normalizeActionType(event) {
57
- return event.actionType?.trim();
58
- }
59
- function getPlatformId(target) {
60
- return target?.platformId?.toLowerCase();
61
- }
62
- function getPlatformSurface(target) {
63
- switch(getPlatformId(target)){
64
- case 'web':
65
- return 'current web page';
66
- case 'android':
67
- case 'ios':
68
- case 'harmony':
69
- return 'current mobile screen';
70
- case 'computer':
71
- return 'current desktop screen';
72
- default:
73
- return 'current UI';
74
- }
75
- }
76
- function getPlatformGuidance(target) {
77
- switch(getPlatformId(target)){
78
- case 'web':
79
- return 'For web targets, use web UI terms such as button, input, link, menu item, tab, dialog, aria-label, placeholder, and form section when visible or inferable.';
80
- case 'android':
81
- case 'ios':
82
- case 'harmony':
83
- return 'For mobile targets, use mobile UI terms such as tab, list item, text field, icon button, navigation bar, bottom bar, sheet, card, and screen section.';
84
- case 'computer':
85
- return 'For desktop/computer targets, use desktop UI terms such as menu item, toolbar button, dialog field, sidebar item, window control, file row, and application region.';
86
- default:
87
- return 'Use platform-neutral UI terms such as control, field, item, icon button, list item, region, panel, and page section.';
88
- }
89
- }
90
- function getPointerActionVerb(event) {
91
- switch(normalizeActionType(event)){
92
- case 'Tap':
93
- return 'Tap';
94
- case 'DoubleClick':
95
- return 'Double click';
96
- case 'LongPress':
97
- return 'Long press';
98
- case 'RightClick':
99
- return 'Right click';
100
- default:
101
- return 'Click';
102
- }
103
- }
104
- function getDragActionVerb(event) {
105
- switch(normalizeActionType(event)){
106
- case 'Swipe':
107
- return 'Swipe';
108
- case 'DragAndDrop':
109
- return 'Drag';
110
- default:
111
- return 'Drag';
112
- }
113
- }
114
- function pointToRect(x, y, size, pageInfo) {
115
- const width = pageInfo.width || size;
116
- const height = pageInfo.height || size;
117
- const left = clamp(Math.floor(x - size / 2), 0, Math.max(width - 1, 0));
118
- const top = clamp(Math.floor(y - size / 2), 0, Math.max(height - 1, 0));
119
- return {
120
- left,
121
- top,
122
- width: Math.min(size, Math.max(width - left, 1)),
123
- height: Math.min(size, Math.max(height - top, 1))
124
- };
125
- }
126
- function getPointRectSize(event) {
127
- switch(event.type){
128
- case 'scroll':
129
- return 96;
130
- case 'drag':
131
- return 64;
132
- default:
133
- return 36;
134
- }
135
- }
136
- function getRecorderUIEventTargetRect(event) {
137
- const rect = event.elementRect;
138
- if (!rect) return null;
139
- if (isFiniteNumber(rect.width) && rect.width > 0 && isFiniteNumber(rect.height) && rect.height > 0 && (isFiniteNumber(rect.left) || isFiniteNumber(rect.top))) return {
140
- left: rect.left || 0,
141
- top: rect.top || 0,
142
- width: rect.width,
143
- height: rect.height
144
- };
145
- if (isFiniteNumber(rect.x) && isFiniteNumber(rect.y)) return pointToRect(rect.x, rect.y, getPointRectSize(event), event.pageInfo);
146
- return null;
147
- }
148
- function getFallbackDescription(event, target) {
149
- const pageContext = getPageSemanticContext(event);
150
- const surface = getPlatformSurface(target);
151
- switch(event.type){
152
- case 'navigation':
153
- return event.url || event.value || event.actionType || 'navigation';
154
- case 'scroll':
155
- return pageContext ? `${pageContext} scrollable content` : `scrollable content on the ${surface}`;
156
- case 'drag':
157
- return pageContext ? `gesture area in ${pageContext}` : `gesture area on the ${surface}`;
158
- case 'input':
159
- return `unresolved input field on the ${surface}`;
160
- case 'keydown':
161
- return pageContext ? `focused control in ${pageContext}` : `focused control on the ${surface}`;
162
- default:
163
- return pageContext ? `control in ${pageContext}` : `control on the ${surface}`;
164
- }
165
- }
166
- function buildSemanticAction(event, scrollDestinationDescription) {
167
- return {
168
- type: event.type,
169
- actionType: event.actionType,
170
- value: event.value,
171
- url: event.url,
172
- scrollDestinationDescription
173
- };
174
- }
175
- function getFallbackReplayInstruction(event, elementDescription) {
176
- return (0, recorder_namespaceObject.buildMidsceneRecorderReplayInstruction)(buildSemanticAction(event), elementDescription);
177
- }
178
- function getFallbackActionSummary(event, elementDescription) {
179
- return (0, recorder_namespaceObject.buildMidsceneRecorderActionSummary)(buildSemanticAction(event), elementDescription);
180
- }
181
- function getActionGuidance(event, target) {
182
- const platformGuidance = getPlatformGuidance(target);
183
- switch(event.type){
184
- case 'click':
185
- return `${platformGuidance} Identify the ${getPointerActionVerb(event).toLowerCase()} target by exact visible text first, then label/placeholder, then role plus stable surrounding context, then icon purpose, then visual position. Never describe it by coordinates, marker location, or as a nearby element.`;
186
- case 'input':
187
- return `${platformGuidance} Identify the exact input field at the marker before text entry. Use stable visible label, field role, field name, surrounding section, or sequence intent. Treat hint text that can change by user, time, data, or context as secondary evidence. Preserve the recorded input value only in replayInstruction; never describe the typed value or page title alone as the field.`;
188
- case 'scroll':
189
- return `${platformGuidance} Identify the scrollable page/region at the highlighted scroll point and concrete destination content revealed after scrolling. If multiple scrollable regions are visible, preserve the specific region where the scroll happened, such as left/right/top/bottom panel, navigation area, content pane, dialog body, table, list, or menu; do not generalize a panel/list scroll into the whole page. Use newly visible headings, section titles, list/table names, list items, or stable region labels; never say only "more content" or "current page".`;
190
- case 'drag':
191
- return `${platformGuidance} Identify the ${getDragActionVerb(event).toLowerCase()} start/end regions or the dragged UI control. Do not describe only the gesture path or coordinates.`;
192
- case 'keydown':
193
- return `${platformGuidance} Identify the focused element or keyboard target if visible, and preserve the recorded key in the replay instruction.`;
194
- default:
195
- return `${platformGuidance} Identify the UI target involved in this event using the most stable visible text or surrounding context.`;
196
- }
197
- }
198
- function getEventRawCoordinates(event) {
199
- const x = event.elementRect?.x;
200
- const y = event.elementRect?.y;
201
- if (isFiniteNumber(x) && isFiniteNumber(y)) return {
202
- x,
203
- y
204
- };
205
- }
206
- function getPageSemanticContext(event) {
207
- const candidates = [
208
- event.title,
209
- event.url
210
- ].map((item)=>item?.trim()).filter(Boolean);
211
- return candidates[0];
212
- }
213
- function isWeakDescription(value) {
214
- if (!value) return true;
215
- if (isPendingDescription(value)) return true;
216
- const normalized = value.trim().toLowerCase();
217
- const compact = normalized.replace(/\s+/g, '');
218
- return 0 === normalized.length || /^\(?\d+(?:\.\d+)?,\s*\d+(?:\.\d+)?\)?$/.test(normalized) || 'target' === normalized || 'element' === normalized || 'target element' === normalized || 'the element' === normalized || 'page element' === normalized || 'input field' === normalized || 'text input' === normalized || 'text field' === normalized || 'search box' === normalized || 'more content' === normalized || 'the page' === normalized || 'current page' === normalized || 'current screen' === normalized || 'the screen' === normalized || 'current ui' === normalized || 'current visible ui' === normalized || 'current visible page' === normalized || 'current visible screen' === normalized || 'main area' === normalized || 'main scrollable area' === normalized || 'scrollable area' === normalized || 'highlighted element' === normalized || 'highlighted item' === normalized || 'marked element' === normalized || 'marked item' === normalized || normalized.includes('ai is analyzing element') || compact.includes('坐标') || compact.includes('附近') || compact.includes('附近的元素') || normalized.includes('coordinate') || normalized.includes('near the coordinate') || normalized.includes('near coordinates') || normalized.includes('nearby element') || normalized.includes('nearby item') || normalized.includes('near the marker') || normalized.includes('near marker') || normalized.includes('near the point') || normalized.includes('near point') || normalized.includes('at the point') || normalized.includes('button near point') || normalized.includes('shown in the screenshot') || normalized.includes('red rectangle') || normalized.includes('red marker') || normalized.includes('red box') || normalized.includes('highlighted element') || normalized.includes('highlighted item') || normalized.includes('highlighted screenshot');
219
- }
220
- function isWeakReplayInstruction(value) {
221
- if (!value) return true;
222
- if (isPendingDescription(value)) return true;
223
- const normalized = value.trim().toLowerCase();
224
- const compact = normalized.replace(/\s+/g, '');
225
- return compact.includes('坐标') || compact.includes('附近') || normalized.includes('coordinate') || normalized.includes('near the coordinate') || normalized.includes('nearby element') || normalized.includes('nearby item') || normalized.includes('near the marker') || normalized.includes('near marker') || normalized.includes('near the point') || normalized.includes('near point') || normalized.includes('at the point') || normalized.includes('ai is analyzing element') || normalized.includes('more content') || normalized.includes('current page') || normalized.includes('current screen') || normalized.includes('highlighted element') || normalized.includes('highlighted item') || normalized.includes('red marker') || normalized.includes('red box') || normalized.includes('shown in the screenshot') || normalized.includes('highlighted screenshot');
226
- }
227
- function normalizeForComparison(value) {
228
- return value.trim().toLowerCase().replace(/["'`]/g, '').replace(/\s+/g, ' ');
229
- }
230
- function isInputValueUsedAsFieldDescription(event, elementDescription) {
231
- if ('input' !== event.type || !event.value || !elementDescription) return false;
232
- const typedValue = normalizeForComparison(event.value);
233
- if (!typedValue) return false;
234
- const description = normalizeForComparison(elementDescription);
235
- return description === typedValue || description === `${typedValue} input` || description === `${typedValue} field` || description === `${typedValue} text field` || description === `input ${typedValue}` || description === `field ${typedValue}` || description.includes(`typed value ${typedValue}`) || description.includes(`value ${typedValue}`);
236
- }
237
- function hasScrollDestination(replayInstruction, scrollDestinationDescription) {
238
- if (scrollDestinationDescription && !isWeakDescription(scrollDestinationDescription)) return true;
239
- const normalized = replayInstruction.toLowerCase();
240
- return normalized.includes(' until ') || normalized.includes(' visible') || normalized.includes(' reveal') || normalized.includes(' to the ') || normalized.includes(' toward ');
241
- }
242
- async function describeWithRetry(event, target, highlightedScreenshot, modelConfig, options) {
243
- let lastError;
244
- for(let attempt = 1; attempt <= options.maxRetries; attempt += 1)try {
245
- const afterScreenshot = getRecorderEventAfterScreenshot(event);
246
- const pageContext = getPageSemanticContext(event);
247
- const platformGuidance = getPlatformGuidance(target);
248
- const userContent = [
249
- {
250
- type: 'text',
251
- text: `Recorder event:
252
- ${JSON.stringify({
253
- type: event.type,
254
- actionType: event.actionType,
255
- value: event.value,
256
- rawCoordinates: getEventRawCoordinates(event),
257
- url: event.url,
258
- title: event.title,
259
- pageContext,
260
- pageInfo: event.pageInfo,
261
- target,
262
- platformGuidance,
263
- guidance: getActionGuidance(event, target)
264
- }, null, 2)}
265
-
266
- The target or region is highlighted in the screenshot below. Convert this event into semantic replay fields.`
267
- },
268
- {
269
- type: 'image_url',
270
- image_url: {
271
- url: highlightedScreenshot,
272
- detail: 'high'
273
- }
274
- }
275
- ];
276
- if (afterScreenshot) userContent.push({
277
- type: 'text',
278
- text: 'Screenshot after the recorded action, for context only:'
279
- }, {
280
- type: 'image_url',
281
- image_url: {
282
- url: afterScreenshot,
283
- detail: 'high'
284
- }
285
- });
286
- const response = await (0, index_js_namespaceObject.callAIWithObjectResponse)([
287
- {
288
- role: 'system',
289
- content: recorder_ui_describer_js_namespaceObject.RECORDER_UI_DESCRIBER_SYSTEM_PROMPT
290
- },
291
- {
292
- role: 'user',
293
- content: userContent
294
- }
295
- ], modelConfig);
296
- const content = response.content;
297
- if (content.error) throw new Error(content.error);
298
- if (isWeakDescription(content.elementDescription)) throw new Error("AI returned a weak recorder event description.");
299
- if (isInputValueUsedAsFieldDescription(event, content.elementDescription)) throw new Error("AI used the recorded input value as the field description.");
300
- const elementDescription = content.elementDescription.trim();
301
- const scrollDestinationDescription = 'scroll' === event.type ? content.scrollDestinationDescription?.trim() : void 0;
302
- if ('scroll' === event.type && !hasScrollDestination('', scrollDestinationDescription)) throw new Error("AI returned a scroll description without a destination.");
303
- const aiReplayInstruction = content.replayInstruction?.trim();
304
- if (aiReplayInstruction && isWeakReplayInstruction(aiReplayInstruction)) throw new Error('AI returned a weak recorder replay instruction.');
305
- const semanticAction = buildSemanticAction(event, scrollDestinationDescription);
306
- const replayInstruction = (0, recorder_namespaceObject.buildMidsceneRecorderReplayInstruction)(semanticAction, elementDescription);
307
- if (isWeakReplayInstruction(replayInstruction)) throw new Error('AI returned a weak recorder replay instruction.');
308
- const actionSummary = (0, recorder_namespaceObject.buildMidsceneRecorderActionSummary)(semanticAction, elementDescription);
309
- return {
310
- source: 'recorderAI',
311
- status: 'ready',
312
- elementDescription,
313
- replayInstruction,
314
- actionSummary,
315
- confidence: content.confidence || 'medium'
316
- };
317
- } catch (error) {
318
- lastError = error;
319
- if (attempt < options.maxRetries) await delay(options.retryDelayMs);
320
- }
321
- throw lastError;
322
- }
323
- async function createScreenshotWithBox(event, rect) {
324
- if (event.screenshotWithBox) return event.screenshotWithBox;
325
- const screenshot = getRecorderEventScreenshot(event);
326
- if (!screenshot) return;
327
- return (0, img_namespaceObject.compositeElementInfoImg)({
328
- inputImgBase64: screenshot,
329
- size: event.pageInfo,
330
- elementsPositionInfo: [
331
- {
332
- rect
333
- }
334
- ],
335
- borderThickness: 3,
336
- annotationPadding: 2
337
- });
338
- }
339
- function createFallbackEvent(event, error, screenshotWithBox, target) {
340
- const semantic = (0, recorder_namespaceObject.getMidsceneRecorderSemantic)(event);
341
- const elementDescription = semantic?.elementDescription && !isWeakDescription(semantic.elementDescription) ? semantic.elementDescription : getFallbackDescription(event, target);
342
- return {
343
- ...event,
344
- semantic: {
345
- source: 'heuristic',
346
- status: 'ready',
347
- elementDescription,
348
- replayInstruction: getFallbackReplayInstruction(event, elementDescription),
349
- actionSummary: getFallbackActionSummary(event, elementDescription),
350
- confidence: 'low',
351
- error
352
- },
353
- screenshotWithBox: screenshotWithBox || event.screenshotWithBox
354
- };
355
- }
356
- async function describeRecorderUIEvent(input, modelConfig, options = {}) {
357
- const event = input.event;
358
- const rect = getRecorderUIEventTargetRect(event);
359
- const screenshot = getRecorderEventScreenshot(event);
360
- if (!rect || !screenshot) {
361
- const error = rect ? 'Recorder event has no screenshot.' : 'Recorder event has no target rectangle.';
362
- return {
363
- usedFallback: true,
364
- event: createFallbackEvent(event, error, void 0, input.target)
365
- };
366
- }
367
- let screenshotWithBox;
368
- try {
369
- screenshotWithBox = await createScreenshotWithBox(event, rect);
370
- const semanticFields = await describeWithRetry(event, input.target, screenshotWithBox || screenshot, modelConfig, {
371
- maxRetries: options.maxRetries ?? RECORDER_UI_DESCRIBER_DEFAULT_RETRIES,
372
- retryDelayMs: options.retryDelayMs ?? RECORDER_UI_DESCRIBER_DEFAULT_RETRY_DELAY_MS
373
- });
374
- return {
375
- usedFallback: false,
376
- event: {
377
- ...event,
378
- semantic: semanticFields,
379
- screenshotWithBox: screenshotWithBox || event.screenshotWithBox
380
- }
381
- };
382
- } catch (error) {
383
- const message = error instanceof Error ? error.message : String(error);
384
- return {
385
- usedFallback: true,
386
- error: message,
387
- event: createFallbackEvent(event, message, screenshotWithBox, input.target)
388
- };
389
- }
390
- }
391
- async function describeRecorderUIEvents(inputs, modelConfig, options = {}) {
392
- const concurrency = Math.max(1, options.concurrency ?? RECORDER_UI_DESCRIBER_DEFAULT_CONCURRENCY);
393
- const results = new Array(inputs.length);
394
- let cursor = 0;
395
- async function worker() {
396
- while(cursor < inputs.length){
397
- const index = cursor;
398
- cursor += 1;
399
- results[index] = await describeRecorderUIEvent(inputs[index], modelConfig, options);
400
- }
401
- }
402
- await Promise.all(Array.from({
403
- length: Math.min(concurrency, inputs.length)
404
- }, ()=>worker()));
405
- return results;
406
- }
407
- exports.describeRecorderUIEvent = __webpack_exports__.describeRecorderUIEvent;
408
- exports.describeRecorderUIEvents = __webpack_exports__.describeRecorderUIEvents;
409
- exports.getRecorderUIEventTargetRect = __webpack_exports__.getRecorderUIEventTargetRect;
410
- for(var __rspack_i in __webpack_exports__)if (-1 === [
411
- "describeRecorderUIEvent",
412
- "describeRecorderUIEvents",
413
- "getRecorderUIEventTargetRect"
414
- ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
415
- Object.defineProperty(exports, '__esModule', {
416
- value: true
417
- });
418
-
419
- //# sourceMappingURL=recorder-ui-describer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"recorder-ui-describer.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../src/recorder-ui-describer.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import type { IModelConfig } from '@midscene/shared/env';\nimport { compositeElementInfoImg } from '@midscene/shared/img';\nimport type {\n MidsceneRecorderEvent,\n MidsceneRecorderPageInfo,\n MidsceneRecorderSemanticAction,\n MidsceneRecorderTarget,\n} from '@midscene/shared/recorder';\nimport {\n buildMidsceneRecorderActionSummary,\n buildMidsceneRecorderReplayInstruction,\n getMidsceneRecorderSemantic,\n} from '@midscene/shared/recorder';\nimport { RECORDER_UI_DESCRIBER_SYSTEM_PROMPT } from './ai-model/prompt/recorder-ui-describer';\nimport { callAIWithObjectResponse } from './ai-model/service-caller';\nimport type { Rect } from './types';\n\nexport interface DescribeRecorderUIEventInput {\n event: MidsceneRecorderEvent;\n target?: MidsceneRecorderTarget;\n}\n\nexport interface DescribeRecorderUIEventOptions {\n maxRetries?: number;\n retryDelayMs?: number;\n concurrency?: number;\n}\n\nexport interface DescribeRecorderUIEventResult {\n event: MidsceneRecorderEvent;\n usedFallback: boolean;\n error?: string;\n}\n\ninterface RecorderUIEventAIResponse {\n elementDescription?: string;\n replayInstruction?: string;\n actionSummary?: string;\n scrollDestinationDescription?: string;\n confidence?: 'high' | 'medium' | 'low';\n error?: string;\n}\n\nconst RECORDER_UI_DESCRIBER_DEFAULT_RETRIES = 2;\nconst RECORDER_UI_DESCRIBER_DEFAULT_RETRY_DELAY_MS = 200;\nconst RECORDER_UI_DESCRIBER_DEFAULT_CONCURRENCY = 2;\n\nfunction delay(ms: number) {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nfunction clamp(value: number, min: number, max: number) {\n return Math.min(Math.max(value, min), max);\n}\n\nfunction isFiniteNumber(value: unknown): value is number {\n return typeof value === 'number' && Number.isFinite(value);\n}\n\nfunction isPendingDescription(value?: string) {\n return value?.trim() === 'AI is analyzing element...';\n}\n\nfunction getRecorderEventScreenshot(event: MidsceneRecorderEvent) {\n return (\n event.screenshotWithBox || event.screenshotBefore || event.screenshotAfter\n );\n}\n\nfunction getRecorderEventAfterScreenshot(event: MidsceneRecorderEvent) {\n return event.screenshotAfter || event.screenshotWithBox;\n}\n\nfunction normalizeActionType(event: MidsceneRecorderEvent) {\n return event.actionType?.trim();\n}\n\nfunction getPlatformId(target?: MidsceneRecorderTarget) {\n return target?.platformId?.toLowerCase();\n}\n\nfunction getPlatformSurface(target?: MidsceneRecorderTarget) {\n switch (getPlatformId(target)) {\n case 'web':\n return 'current web page';\n case 'android':\n case 'ios':\n case 'harmony':\n return 'current mobile screen';\n case 'computer':\n return 'current desktop screen';\n default:\n return 'current UI';\n }\n}\n\nfunction getPlatformGuidance(target?: MidsceneRecorderTarget) {\n switch (getPlatformId(target)) {\n case 'web':\n return 'For web targets, use web UI terms such as button, input, link, menu item, tab, dialog, aria-label, placeholder, and form section when visible or inferable.';\n case 'android':\n case 'ios':\n case 'harmony':\n return 'For mobile targets, use mobile UI terms such as tab, list item, text field, icon button, navigation bar, bottom bar, sheet, card, and screen section.';\n case 'computer':\n return 'For desktop/computer targets, use desktop UI terms such as menu item, toolbar button, dialog field, sidebar item, window control, file row, and application region.';\n default:\n return 'Use platform-neutral UI terms such as control, field, item, icon button, list item, region, panel, and page section.';\n }\n}\n\nfunction getPointerActionVerb(event: MidsceneRecorderEvent) {\n switch (normalizeActionType(event)) {\n case 'Tap':\n return 'Tap';\n case 'DoubleClick':\n return 'Double click';\n case 'LongPress':\n return 'Long press';\n case 'RightClick':\n return 'Right click';\n default:\n return 'Click';\n }\n}\n\nfunction getDragActionVerb(event: MidsceneRecorderEvent) {\n switch (normalizeActionType(event)) {\n case 'Swipe':\n return 'Swipe';\n case 'DragAndDrop':\n return 'Drag';\n default:\n return 'Drag';\n }\n}\n\nfunction pointToRect(\n x: number,\n y: number,\n size: number,\n pageInfo: MidsceneRecorderPageInfo,\n): Rect {\n const width = pageInfo.width || size;\n const height = pageInfo.height || size;\n const left = clamp(Math.floor(x - size / 2), 0, Math.max(width - 1, 0));\n const top = clamp(Math.floor(y - size / 2), 0, Math.max(height - 1, 0));\n return {\n left,\n top,\n width: Math.min(size, Math.max(width - left, 1)),\n height: Math.min(size, Math.max(height - top, 1)),\n };\n}\n\nfunction getPointRectSize(event: MidsceneRecorderEvent) {\n switch (event.type) {\n case 'scroll':\n return 96;\n case 'drag':\n return 64;\n default:\n return 36;\n }\n}\n\nexport function getRecorderUIEventTargetRect(\n event: MidsceneRecorderEvent,\n): Rect | null {\n const rect = event.elementRect;\n if (!rect) {\n return null;\n }\n\n if (\n isFiniteNumber(rect.width) &&\n rect.width > 0 &&\n isFiniteNumber(rect.height) &&\n rect.height > 0 &&\n (isFiniteNumber(rect.left) || isFiniteNumber(rect.top))\n ) {\n return {\n left: rect.left || 0,\n top: rect.top || 0,\n width: rect.width,\n height: rect.height,\n };\n }\n\n if (isFiniteNumber(rect.x) && isFiniteNumber(rect.y)) {\n return pointToRect(rect.x, rect.y, getPointRectSize(event), event.pageInfo);\n }\n\n return null;\n}\n\nfunction getFallbackDescription(\n event: MidsceneRecorderEvent,\n target?: MidsceneRecorderTarget,\n) {\n const pageContext = getPageSemanticContext(event);\n const surface = getPlatformSurface(target);\n\n switch (event.type) {\n case 'navigation':\n return event.url || event.value || event.actionType || 'navigation';\n case 'scroll':\n return pageContext\n ? `${pageContext} scrollable content`\n : `scrollable content on the ${surface}`;\n case 'drag':\n return pageContext\n ? `gesture area in ${pageContext}`\n : `gesture area on the ${surface}`;\n case 'input':\n return `unresolved input field on the ${surface}`;\n case 'keydown':\n return pageContext\n ? `focused control in ${pageContext}`\n : `focused control on the ${surface}`;\n default:\n return pageContext\n ? `control in ${pageContext}`\n : `control on the ${surface}`;\n }\n}\n\nfunction buildSemanticAction(\n event: MidsceneRecorderEvent,\n scrollDestinationDescription?: string,\n): MidsceneRecorderSemanticAction {\n return {\n type: event.type,\n actionType: event.actionType,\n value: event.value,\n url: event.url,\n scrollDestinationDescription,\n };\n}\n\nfunction getFallbackReplayInstruction(\n event: MidsceneRecorderEvent,\n elementDescription: string,\n) {\n return buildMidsceneRecorderReplayInstruction(\n buildSemanticAction(event),\n elementDescription,\n );\n}\n\nfunction getFallbackActionSummary(\n event: MidsceneRecorderEvent,\n elementDescription: string,\n) {\n return buildMidsceneRecorderActionSummary(\n buildSemanticAction(event),\n elementDescription,\n );\n}\n\nfunction getActionGuidance(\n event: MidsceneRecorderEvent,\n target?: MidsceneRecorderTarget,\n) {\n const platformGuidance = getPlatformGuidance(target);\n\n switch (event.type) {\n case 'click':\n return `${platformGuidance} Identify the ${getPointerActionVerb(event).toLowerCase()} target by exact visible text first, then label/placeholder, then role plus stable surrounding context, then icon purpose, then visual position. Never describe it by coordinates, marker location, or as a nearby element.`;\n case 'input':\n return `${platformGuidance} Identify the exact input field at the marker before text entry. Use stable visible label, field role, field name, surrounding section, or sequence intent. Treat hint text that can change by user, time, data, or context as secondary evidence. Preserve the recorded input value only in replayInstruction; never describe the typed value or page title alone as the field.`;\n case 'scroll':\n return `${platformGuidance} Identify the scrollable page/region at the highlighted scroll point and concrete destination content revealed after scrolling. If multiple scrollable regions are visible, preserve the specific region where the scroll happened, such as left/right/top/bottom panel, navigation area, content pane, dialog body, table, list, or menu; do not generalize a panel/list scroll into the whole page. Use newly visible headings, section titles, list/table names, list items, or stable region labels; never say only \"more content\" or \"current page\".`;\n case 'drag':\n return `${platformGuidance} Identify the ${getDragActionVerb(event).toLowerCase()} start/end regions or the dragged UI control. Do not describe only the gesture path or coordinates.`;\n case 'keydown':\n return `${platformGuidance} Identify the focused element or keyboard target if visible, and preserve the recorded key in the replay instruction.`;\n default:\n return `${platformGuidance} Identify the UI target involved in this event using the most stable visible text or surrounding context.`;\n }\n}\n\nfunction getEventRawCoordinates(event: MidsceneRecorderEvent) {\n const x = event.elementRect?.x;\n const y = event.elementRect?.y;\n if (isFiniteNumber(x) && isFiniteNumber(y)) {\n return { x, y };\n }\n return undefined;\n}\n\nfunction getPageSemanticContext(event: MidsceneRecorderEvent) {\n const candidates = [event.title, event.url]\n .map((item) => item?.trim())\n .filter(Boolean) as string[];\n return candidates[0];\n}\n\nfunction isWeakDescription(value?: string) {\n if (!value) {\n return true;\n }\n if (isPendingDescription(value)) {\n return true;\n }\n const normalized = value.trim().toLowerCase();\n const compact = normalized.replace(/\\s+/g, '');\n return (\n normalized.length === 0 ||\n /^\\(?\\d+(?:\\.\\d+)?,\\s*\\d+(?:\\.\\d+)?\\)?$/.test(normalized) ||\n normalized === 'target' ||\n normalized === 'element' ||\n normalized === 'target element' ||\n normalized === 'the element' ||\n normalized === 'page element' ||\n normalized === 'input field' ||\n normalized === 'text input' ||\n normalized === 'text field' ||\n normalized === 'search box' ||\n normalized === 'more content' ||\n normalized === 'the page' ||\n normalized === 'current page' ||\n normalized === 'current screen' ||\n normalized === 'the screen' ||\n normalized === 'current ui' ||\n normalized === 'current visible ui' ||\n normalized === 'current visible page' ||\n normalized === 'current visible screen' ||\n normalized === 'main area' ||\n normalized === 'main scrollable area' ||\n normalized === 'scrollable area' ||\n normalized === 'highlighted element' ||\n normalized === 'highlighted item' ||\n normalized === 'marked element' ||\n normalized === 'marked item' ||\n normalized.includes('ai is analyzing element') ||\n compact.includes('坐标') ||\n compact.includes('附近') ||\n compact.includes('附近的元素') ||\n normalized.includes('coordinate') ||\n normalized.includes('near the coordinate') ||\n normalized.includes('near coordinates') ||\n normalized.includes('nearby element') ||\n normalized.includes('nearby item') ||\n normalized.includes('near the marker') ||\n normalized.includes('near marker') ||\n normalized.includes('near the point') ||\n normalized.includes('near point') ||\n normalized.includes('at the point') ||\n normalized.includes('button near point') ||\n normalized.includes('shown in the screenshot') ||\n normalized.includes('red rectangle') ||\n normalized.includes('red marker') ||\n normalized.includes('red box') ||\n normalized.includes('highlighted element') ||\n normalized.includes('highlighted item') ||\n normalized.includes('highlighted screenshot')\n );\n}\n\nfunction isWeakReplayInstruction(value?: string) {\n if (!value) {\n return true;\n }\n if (isPendingDescription(value)) {\n return true;\n }\n const normalized = value.trim().toLowerCase();\n const compact = normalized.replace(/\\s+/g, '');\n return (\n compact.includes('坐标') ||\n compact.includes('附近') ||\n normalized.includes('coordinate') ||\n normalized.includes('near the coordinate') ||\n normalized.includes('nearby element') ||\n normalized.includes('nearby item') ||\n normalized.includes('near the marker') ||\n normalized.includes('near marker') ||\n normalized.includes('near the point') ||\n normalized.includes('near point') ||\n normalized.includes('at the point') ||\n normalized.includes('ai is analyzing element') ||\n normalized.includes('more content') ||\n normalized.includes('current page') ||\n normalized.includes('current screen') ||\n normalized.includes('highlighted element') ||\n normalized.includes('highlighted item') ||\n normalized.includes('red marker') ||\n normalized.includes('red box') ||\n normalized.includes('shown in the screenshot') ||\n normalized.includes('highlighted screenshot')\n );\n}\n\nfunction normalizeForComparison(value: string) {\n return value.trim().toLowerCase().replace(/[\"'`]/g, '').replace(/\\s+/g, ' ');\n}\n\nfunction isInputValueUsedAsFieldDescription(\n event: MidsceneRecorderEvent,\n elementDescription?: string,\n) {\n if (event.type !== 'input' || !event.value || !elementDescription) {\n return false;\n }\n\n const typedValue = normalizeForComparison(event.value);\n if (!typedValue) {\n return false;\n }\n const description = normalizeForComparison(elementDescription);\n\n return (\n description === typedValue ||\n description === `${typedValue} input` ||\n description === `${typedValue} field` ||\n description === `${typedValue} text field` ||\n description === `input ${typedValue}` ||\n description === `field ${typedValue}` ||\n description.includes(`typed value ${typedValue}`) ||\n description.includes(`value ${typedValue}`)\n );\n}\n\nfunction hasScrollDestination(\n replayInstruction: string,\n scrollDestinationDescription?: string,\n) {\n if (\n scrollDestinationDescription &&\n !isWeakDescription(scrollDestinationDescription)\n ) {\n return true;\n }\n const normalized = replayInstruction.toLowerCase();\n return (\n normalized.includes(' until ') ||\n normalized.includes(' visible') ||\n normalized.includes(' reveal') ||\n normalized.includes(' to the ') ||\n normalized.includes(' toward ')\n );\n}\n\nasync function describeWithRetry(\n event: MidsceneRecorderEvent,\n target: MidsceneRecorderTarget | undefined,\n highlightedScreenshot: string,\n modelConfig: IModelConfig,\n options: Required<\n Pick<DescribeRecorderUIEventOptions, 'maxRetries' | 'retryDelayMs'>\n >,\n) {\n let lastError: unknown;\n for (let attempt = 1; attempt <= options.maxRetries; attempt += 1) {\n try {\n const afterScreenshot = getRecorderEventAfterScreenshot(event);\n const pageContext = getPageSemanticContext(event);\n const platformGuidance = getPlatformGuidance(target);\n const userContent: any[] = [\n {\n type: 'text',\n text: `Recorder event:\n${JSON.stringify(\n {\n type: event.type,\n actionType: event.actionType,\n value: event.value,\n rawCoordinates: getEventRawCoordinates(event),\n url: event.url,\n title: event.title,\n pageContext,\n pageInfo: event.pageInfo,\n target,\n platformGuidance,\n guidance: getActionGuidance(event, target),\n },\n null,\n 2,\n)}\n\nThe target or region is highlighted in the screenshot below. Convert this event into semantic replay fields.`,\n },\n {\n type: 'image_url',\n image_url: {\n url: highlightedScreenshot,\n detail: 'high',\n },\n },\n ];\n if (afterScreenshot) {\n userContent.push(\n {\n type: 'text',\n text: 'Screenshot after the recorded action, for context only:',\n },\n {\n type: 'image_url',\n image_url: {\n url: afterScreenshot,\n detail: 'high',\n },\n },\n );\n }\n const response =\n await callAIWithObjectResponse<RecorderUIEventAIResponse>(\n [\n {\n role: 'system',\n content: RECORDER_UI_DESCRIBER_SYSTEM_PROMPT,\n },\n {\n role: 'user',\n content: userContent,\n },\n ],\n modelConfig,\n );\n\n const content = response.content;\n if (content.error) {\n throw new Error(content.error);\n }\n if (isWeakDescription(content.elementDescription)) {\n throw new Error('AI returned a weak recorder event description.');\n }\n if (\n isInputValueUsedAsFieldDescription(event, content.elementDescription)\n ) {\n throw new Error(\n 'AI used the recorded input value as the field description.',\n );\n }\n const elementDescription = content.elementDescription!.trim();\n const scrollDestinationDescription =\n event.type === 'scroll'\n ? content.scrollDestinationDescription?.trim()\n : undefined;\n if (\n event.type === 'scroll' &&\n !hasScrollDestination('', scrollDestinationDescription)\n ) {\n throw new Error(\n 'AI returned a scroll description without a destination.',\n );\n }\n const aiReplayInstruction = content.replayInstruction?.trim();\n if (aiReplayInstruction && isWeakReplayInstruction(aiReplayInstruction)) {\n throw new Error('AI returned a weak recorder replay instruction.');\n }\n const semanticAction = buildSemanticAction(\n event,\n scrollDestinationDescription,\n );\n const replayInstruction = buildMidsceneRecorderReplayInstruction(\n semanticAction,\n elementDescription,\n );\n if (isWeakReplayInstruction(replayInstruction)) {\n throw new Error('AI returned a weak recorder replay instruction.');\n }\n const actionSummary = buildMidsceneRecorderActionSummary(\n semanticAction,\n elementDescription,\n );\n\n return {\n source: 'recorderAI' as const,\n status: 'ready' as const,\n elementDescription,\n replayInstruction,\n actionSummary,\n confidence: content.confidence || 'medium',\n };\n } catch (error) {\n lastError = error;\n if (attempt < options.maxRetries) {\n await delay(options.retryDelayMs);\n }\n }\n }\n throw lastError;\n}\n\nasync function createScreenshotWithBox(\n event: MidsceneRecorderEvent,\n rect: Rect,\n) {\n if (event.screenshotWithBox) {\n return event.screenshotWithBox;\n }\n const screenshot = getRecorderEventScreenshot(event);\n if (!screenshot) {\n return undefined;\n }\n return compositeElementInfoImg({\n inputImgBase64: screenshot,\n size: event.pageInfo,\n elementsPositionInfo: [{ rect }],\n borderThickness: 3,\n annotationPadding: 2,\n });\n}\n\nfunction createFallbackEvent(\n event: MidsceneRecorderEvent,\n error: string,\n screenshotWithBox?: string,\n target?: MidsceneRecorderTarget,\n): MidsceneRecorderEvent {\n const semantic = getMidsceneRecorderSemantic(event);\n const elementDescription =\n semantic?.elementDescription &&\n !isWeakDescription(semantic.elementDescription)\n ? semantic.elementDescription\n : getFallbackDescription(event, target);\n return {\n ...event,\n semantic: {\n source: 'heuristic',\n status: 'ready',\n elementDescription,\n replayInstruction: getFallbackReplayInstruction(\n event,\n elementDescription,\n ),\n actionSummary: getFallbackActionSummary(event, elementDescription),\n confidence: 'low',\n error,\n },\n screenshotWithBox: screenshotWithBox || event.screenshotWithBox,\n };\n}\n\nexport async function describeRecorderUIEvent(\n input: DescribeRecorderUIEventInput,\n modelConfig: IModelConfig,\n options: DescribeRecorderUIEventOptions = {},\n): Promise<DescribeRecorderUIEventResult> {\n const event = input.event;\n const rect = getRecorderUIEventTargetRect(event);\n const screenshot = getRecorderEventScreenshot(event);\n\n if (!rect || !screenshot) {\n const error = !rect\n ? 'Recorder event has no target rectangle.'\n : 'Recorder event has no screenshot.';\n return {\n usedFallback: true,\n event: createFallbackEvent(event, error, undefined, input.target),\n };\n }\n\n let screenshotWithBox: string | undefined;\n try {\n screenshotWithBox = await createScreenshotWithBox(event, rect);\n const semanticFields = await describeWithRetry(\n event,\n input.target,\n screenshotWithBox || screenshot,\n modelConfig,\n {\n maxRetries: options.maxRetries ?? RECORDER_UI_DESCRIBER_DEFAULT_RETRIES,\n retryDelayMs:\n options.retryDelayMs ?? RECORDER_UI_DESCRIBER_DEFAULT_RETRY_DELAY_MS,\n },\n );\n return {\n usedFallback: false,\n event: {\n ...event,\n semantic: semanticFields,\n screenshotWithBox: screenshotWithBox || event.screenshotWithBox,\n },\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n usedFallback: true,\n error: message,\n event: createFallbackEvent(\n event,\n message,\n screenshotWithBox,\n input.target,\n ),\n };\n }\n}\n\nexport async function describeRecorderUIEvents(\n inputs: DescribeRecorderUIEventInput[],\n modelConfig: IModelConfig,\n options: DescribeRecorderUIEventOptions = {},\n): Promise<DescribeRecorderUIEventResult[]> {\n const concurrency = Math.max(\n 1,\n options.concurrency ?? RECORDER_UI_DESCRIBER_DEFAULT_CONCURRENCY,\n );\n const results: DescribeRecorderUIEventResult[] = new Array(inputs.length);\n let cursor = 0;\n\n async function worker() {\n while (cursor < inputs.length) {\n const index = cursor;\n cursor += 1;\n results[index] = await describeRecorderUIEvent(\n inputs[index],\n modelConfig,\n options,\n );\n }\n }\n\n await Promise.all(\n Array.from({ length: Math.min(concurrency, inputs.length) }, () =>\n worker(),\n ),\n );\n return results;\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","RECORDER_UI_DESCRIBER_DEFAULT_RETRIES","RECORDER_UI_DESCRIBER_DEFAULT_RETRY_DELAY_MS","RECORDER_UI_DESCRIBER_DEFAULT_CONCURRENCY","delay","ms","Promise","resolve","setTimeout","clamp","value","min","max","Math","isFiniteNumber","Number","isPendingDescription","getRecorderEventScreenshot","event","getRecorderEventAfterScreenshot","normalizeActionType","getPlatformId","target","getPlatformSurface","getPlatformGuidance","getPointerActionVerb","getDragActionVerb","pointToRect","x","y","size","pageInfo","width","height","left","top","getPointRectSize","getRecorderUIEventTargetRect","rect","getFallbackDescription","pageContext","getPageSemanticContext","surface","buildSemanticAction","scrollDestinationDescription","getFallbackReplayInstruction","elementDescription","buildMidsceneRecorderReplayInstruction","getFallbackActionSummary","buildMidsceneRecorderActionSummary","getActionGuidance","platformGuidance","getEventRawCoordinates","candidates","item","Boolean","isWeakDescription","normalized","compact","isWeakReplayInstruction","normalizeForComparison","isInputValueUsedAsFieldDescription","typedValue","description","hasScrollDestination","replayInstruction","describeWithRetry","highlightedScreenshot","modelConfig","options","lastError","attempt","afterScreenshot","userContent","JSON","response","callAIWithObjectResponse","RECORDER_UI_DESCRIBER_SYSTEM_PROMPT","content","Error","undefined","aiReplayInstruction","semanticAction","actionSummary","error","createScreenshotWithBox","screenshot","compositeElementInfoImg","createFallbackEvent","screenshotWithBox","semantic","getMidsceneRecorderSemantic","describeRecorderUIEvent","input","semanticFields","message","String","describeRecorderUIEvents","inputs","concurrency","results","Array","cursor","worker","index"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;;;;ACqCA,MAAMI,wCAAwC;AAC9C,MAAMC,+CAA+C;AACrD,MAAMC,4CAA4C;AAElD,SAASC,MAAMC,EAAU;IACvB,OAAO,IAAIC,QAAQ,CAACC,UAAYC,WAAWD,SAASF;AACtD;AAEA,SAASI,MAAMC,KAAa,EAAEC,GAAW,EAAEC,GAAW;IACpD,OAAOC,KAAK,GAAG,CAACA,KAAK,GAAG,CAACH,OAAOC,MAAMC;AACxC;AAEA,SAASE,eAAeJ,KAAc;IACpC,OAAO,AAAiB,YAAjB,OAAOA,SAAsBK,OAAO,QAAQ,CAACL;AACtD;AAEA,SAASM,qBAAqBN,KAAc;IAC1C,OAAOA,OAAO,WAAW;AAC3B;AAEA,SAASO,2BAA2BC,KAA4B;IAC9D,OACEA,MAAM,iBAAiB,IAAIA,MAAM,gBAAgB,IAAIA,MAAM,eAAe;AAE9E;AAEA,SAASC,gCAAgCD,KAA4B;IACn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2C,IAAIC,MAAMH,OAAO,MAAM;IACxE,IAAII,SAAS;IAEb,eAAeC;QACb,MAAOD,SAASJ,OAAO,MAAM,CAAE;YAC7B,MAAMM,QAAQF;YACdA,UAAU;YACVF,OAAO,CAACI,MAAM,GAAG,MAAMZ,wBACrBM,MAAM,CAACM,MAAM,EACbpC,aACAC;QAEJ;IACF;IAEA,MAAM/D,QAAQ,GAAG,CACf+F,MAAM,IAAI,CAAC;QAAE,QAAQxF,KAAK,GAAG,CAACsF,aAAaD,OAAO,MAAM;IAAE,GAAG,IAC3DK;IAGJ,OAAOH;AACT"}
@@ -1,2 +0,0 @@
1
- import type { ChatCompletionContentSource, ContentAndReasoning } from './types';
2
- export declare function defaultExtractContentAndReasoning(message: ChatCompletionContentSource | undefined): ContentAndReasoning;