@donggui/core 1.5.4-donggui.3

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 (269) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +9 -0
  3. package/dist/es/agent/agent.mjs +709 -0
  4. package/dist/es/agent/agent.mjs.map +1 -0
  5. package/dist/es/agent/common.mjs +0 -0
  6. package/dist/es/agent/execution-session.mjs +41 -0
  7. package/dist/es/agent/execution-session.mjs.map +1 -0
  8. package/dist/es/agent/index.mjs +6 -0
  9. package/dist/es/agent/task-builder.mjs +330 -0
  10. package/dist/es/agent/task-builder.mjs.map +1 -0
  11. package/dist/es/agent/task-cache.mjs +186 -0
  12. package/dist/es/agent/task-cache.mjs.map +1 -0
  13. package/dist/es/agent/tasks.mjs +422 -0
  14. package/dist/es/agent/tasks.mjs.map +1 -0
  15. package/dist/es/agent/ui-utils.mjs +91 -0
  16. package/dist/es/agent/ui-utils.mjs.map +1 -0
  17. package/dist/es/agent/utils.mjs +198 -0
  18. package/dist/es/agent/utils.mjs.map +1 -0
  19. package/dist/es/ai-model/auto-glm/actions.mjs +224 -0
  20. package/dist/es/ai-model/auto-glm/actions.mjs.map +1 -0
  21. package/dist/es/ai-model/auto-glm/index.mjs +6 -0
  22. package/dist/es/ai-model/auto-glm/parser.mjs +239 -0
  23. package/dist/es/ai-model/auto-glm/parser.mjs.map +1 -0
  24. package/dist/es/ai-model/auto-glm/planning.mjs +71 -0
  25. package/dist/es/ai-model/auto-glm/planning.mjs.map +1 -0
  26. package/dist/es/ai-model/auto-glm/prompt.mjs +222 -0
  27. package/dist/es/ai-model/auto-glm/prompt.mjs.map +1 -0
  28. package/dist/es/ai-model/auto-glm/util.mjs +9 -0
  29. package/dist/es/ai-model/auto-glm/util.mjs.map +1 -0
  30. package/dist/es/ai-model/conversation-history.mjs +195 -0
  31. package/dist/es/ai-model/conversation-history.mjs.map +1 -0
  32. package/dist/es/ai-model/index.mjs +11 -0
  33. package/dist/es/ai-model/inspect.mjs +386 -0
  34. package/dist/es/ai-model/inspect.mjs.map +1 -0
  35. package/dist/es/ai-model/llm-planning.mjs +233 -0
  36. package/dist/es/ai-model/llm-planning.mjs.map +1 -0
  37. package/dist/es/ai-model/prompt/common.mjs +7 -0
  38. package/dist/es/ai-model/prompt/common.mjs.map +1 -0
  39. package/dist/es/ai-model/prompt/describe.mjs +66 -0
  40. package/dist/es/ai-model/prompt/describe.mjs.map +1 -0
  41. package/dist/es/ai-model/prompt/extraction.mjs +129 -0
  42. package/dist/es/ai-model/prompt/extraction.mjs.map +1 -0
  43. package/dist/es/ai-model/prompt/llm-locator.mjs +51 -0
  44. package/dist/es/ai-model/prompt/llm-locator.mjs.map +1 -0
  45. package/dist/es/ai-model/prompt/llm-planning.mjs +364 -0
  46. package/dist/es/ai-model/prompt/llm-planning.mjs.map +1 -0
  47. package/dist/es/ai-model/prompt/llm-section-locator.mjs +44 -0
  48. package/dist/es/ai-model/prompt/llm-section-locator.mjs.map +1 -0
  49. package/dist/es/ai-model/prompt/order-sensitive-judge.mjs +35 -0
  50. package/dist/es/ai-model/prompt/order-sensitive-judge.mjs.map +1 -0
  51. package/dist/es/ai-model/prompt/playwright-generator.mjs +117 -0
  52. package/dist/es/ai-model/prompt/playwright-generator.mjs.map +1 -0
  53. package/dist/es/ai-model/prompt/ui-tars-planning.mjs +36 -0
  54. package/dist/es/ai-model/prompt/ui-tars-planning.mjs.map +1 -0
  55. package/dist/es/ai-model/prompt/util.mjs +59 -0
  56. package/dist/es/ai-model/prompt/util.mjs.map +1 -0
  57. package/dist/es/ai-model/prompt/yaml-generator.mjs +219 -0
  58. package/dist/es/ai-model/prompt/yaml-generator.mjs.map +1 -0
  59. package/dist/es/ai-model/service-caller/index.mjs +466 -0
  60. package/dist/es/ai-model/service-caller/index.mjs.map +1 -0
  61. package/dist/es/ai-model/ui-tars-planning.mjs +249 -0
  62. package/dist/es/ai-model/ui-tars-planning.mjs.map +1 -0
  63. package/dist/es/common.mjs +371 -0
  64. package/dist/es/common.mjs.map +1 -0
  65. package/dist/es/device/device-options.mjs +0 -0
  66. package/dist/es/device/index.mjs +300 -0
  67. package/dist/es/device/index.mjs.map +1 -0
  68. package/dist/es/dump/html-utils.mjs +211 -0
  69. package/dist/es/dump/html-utils.mjs.map +1 -0
  70. package/dist/es/dump/image-restoration.mjs +43 -0
  71. package/dist/es/dump/image-restoration.mjs.map +1 -0
  72. package/dist/es/dump/index.mjs +3 -0
  73. package/dist/es/index.mjs +15 -0
  74. package/dist/es/index.mjs.map +1 -0
  75. package/dist/es/report-generator.mjs +134 -0
  76. package/dist/es/report-generator.mjs.map +1 -0
  77. package/dist/es/report.mjs +111 -0
  78. package/dist/es/report.mjs.map +1 -0
  79. package/dist/es/screenshot-item.mjs +105 -0
  80. package/dist/es/screenshot-item.mjs.map +1 -0
  81. package/dist/es/service/index.mjs +256 -0
  82. package/dist/es/service/index.mjs.map +1 -0
  83. package/dist/es/service/utils.mjs +15 -0
  84. package/dist/es/service/utils.mjs.map +1 -0
  85. package/dist/es/skill/index.mjs +38 -0
  86. package/dist/es/skill/index.mjs.map +1 -0
  87. package/dist/es/task-runner.mjs +258 -0
  88. package/dist/es/task-runner.mjs.map +1 -0
  89. package/dist/es/task-timing.mjs +12 -0
  90. package/dist/es/task-timing.mjs.map +1 -0
  91. package/dist/es/tree.mjs +13 -0
  92. package/dist/es/tree.mjs.map +1 -0
  93. package/dist/es/types.mjs +196 -0
  94. package/dist/es/types.mjs.map +1 -0
  95. package/dist/es/utils.mjs +218 -0
  96. package/dist/es/utils.mjs.map +1 -0
  97. package/dist/es/yaml/builder.mjs +13 -0
  98. package/dist/es/yaml/builder.mjs.map +1 -0
  99. package/dist/es/yaml/index.mjs +4 -0
  100. package/dist/es/yaml/player.mjs +418 -0
  101. package/dist/es/yaml/player.mjs.map +1 -0
  102. package/dist/es/yaml/utils.mjs +73 -0
  103. package/dist/es/yaml/utils.mjs.map +1 -0
  104. package/dist/es/yaml.mjs +0 -0
  105. package/dist/lib/agent/agent.js +757 -0
  106. package/dist/lib/agent/agent.js.map +1 -0
  107. package/dist/lib/agent/common.js +5 -0
  108. package/dist/lib/agent/execution-session.js +75 -0
  109. package/dist/lib/agent/execution-session.js.map +1 -0
  110. package/dist/lib/agent/index.js +81 -0
  111. package/dist/lib/agent/index.js.map +1 -0
  112. package/dist/lib/agent/task-builder.js +367 -0
  113. package/dist/lib/agent/task-builder.js.map +1 -0
  114. package/dist/lib/agent/task-cache.js +238 -0
  115. package/dist/lib/agent/task-cache.js.map +1 -0
  116. package/dist/lib/agent/tasks.js +465 -0
  117. package/dist/lib/agent/tasks.js.map +1 -0
  118. package/dist/lib/agent/ui-utils.js +143 -0
  119. package/dist/lib/agent/ui-utils.js.map +1 -0
  120. package/dist/lib/agent/utils.js +275 -0
  121. package/dist/lib/agent/utils.js.map +1 -0
  122. package/dist/lib/ai-model/auto-glm/actions.js +258 -0
  123. package/dist/lib/ai-model/auto-glm/actions.js.map +1 -0
  124. package/dist/lib/ai-model/auto-glm/index.js +66 -0
  125. package/dist/lib/ai-model/auto-glm/index.js.map +1 -0
  126. package/dist/lib/ai-model/auto-glm/parser.js +282 -0
  127. package/dist/lib/ai-model/auto-glm/parser.js.map +1 -0
  128. package/dist/lib/ai-model/auto-glm/planning.js +105 -0
  129. package/dist/lib/ai-model/auto-glm/planning.js.map +1 -0
  130. package/dist/lib/ai-model/auto-glm/prompt.js +259 -0
  131. package/dist/lib/ai-model/auto-glm/prompt.js.map +1 -0
  132. package/dist/lib/ai-model/auto-glm/util.js +46 -0
  133. package/dist/lib/ai-model/auto-glm/util.js.map +1 -0
  134. package/dist/lib/ai-model/conversation-history.js +229 -0
  135. package/dist/lib/ai-model/conversation-history.js.map +1 -0
  136. package/dist/lib/ai-model/index.js +125 -0
  137. package/dist/lib/ai-model/index.js.map +1 -0
  138. package/dist/lib/ai-model/inspect.js +429 -0
  139. package/dist/lib/ai-model/inspect.js.map +1 -0
  140. package/dist/lib/ai-model/llm-planning.js +270 -0
  141. package/dist/lib/ai-model/llm-planning.js.map +1 -0
  142. package/dist/lib/ai-model/prompt/common.js +41 -0
  143. package/dist/lib/ai-model/prompt/common.js.map +1 -0
  144. package/dist/lib/ai-model/prompt/describe.js +100 -0
  145. package/dist/lib/ai-model/prompt/describe.js.map +1 -0
  146. package/dist/lib/ai-model/prompt/extraction.js +169 -0
  147. package/dist/lib/ai-model/prompt/extraction.js.map +1 -0
  148. package/dist/lib/ai-model/prompt/llm-locator.js +88 -0
  149. package/dist/lib/ai-model/prompt/llm-locator.js.map +1 -0
  150. package/dist/lib/ai-model/prompt/llm-planning.js +401 -0
  151. package/dist/lib/ai-model/prompt/llm-planning.js.map +1 -0
  152. package/dist/lib/ai-model/prompt/llm-section-locator.js +81 -0
  153. package/dist/lib/ai-model/prompt/llm-section-locator.js.map +1 -0
  154. package/dist/lib/ai-model/prompt/order-sensitive-judge.js +72 -0
  155. package/dist/lib/ai-model/prompt/order-sensitive-judge.js.map +1 -0
  156. package/dist/lib/ai-model/prompt/playwright-generator.js +178 -0
  157. package/dist/lib/ai-model/prompt/playwright-generator.js.map +1 -0
  158. package/dist/lib/ai-model/prompt/ui-tars-planning.js +73 -0
  159. package/dist/lib/ai-model/prompt/ui-tars-planning.js.map +1 -0
  160. package/dist/lib/ai-model/prompt/util.js +105 -0
  161. package/dist/lib/ai-model/prompt/util.js.map +1 -0
  162. package/dist/lib/ai-model/prompt/yaml-generator.js +280 -0
  163. package/dist/lib/ai-model/prompt/yaml-generator.js.map +1 -0
  164. package/dist/lib/ai-model/service-caller/index.js +531 -0
  165. package/dist/lib/ai-model/service-caller/index.js.map +1 -0
  166. package/dist/lib/ai-model/ui-tars-planning.js +283 -0
  167. package/dist/lib/ai-model/ui-tars-planning.js.map +1 -0
  168. package/dist/lib/common.js +480 -0
  169. package/dist/lib/common.js.map +1 -0
  170. package/dist/lib/device/device-options.js +20 -0
  171. package/dist/lib/device/device-options.js.map +1 -0
  172. package/dist/lib/device/index.js +418 -0
  173. package/dist/lib/device/index.js.map +1 -0
  174. package/dist/lib/dump/html-utils.js +281 -0
  175. package/dist/lib/dump/html-utils.js.map +1 -0
  176. package/dist/lib/dump/image-restoration.js +77 -0
  177. package/dist/lib/dump/image-restoration.js.map +1 -0
  178. package/dist/lib/dump/index.js +60 -0
  179. package/dist/lib/dump/index.js.map +1 -0
  180. package/dist/lib/index.js +146 -0
  181. package/dist/lib/index.js.map +1 -0
  182. package/dist/lib/report-generator.js +172 -0
  183. package/dist/lib/report-generator.js.map +1 -0
  184. package/dist/lib/report.js +145 -0
  185. package/dist/lib/report.js.map +1 -0
  186. package/dist/lib/screenshot-item.js +139 -0
  187. package/dist/lib/screenshot-item.js.map +1 -0
  188. package/dist/lib/service/index.js +290 -0
  189. package/dist/lib/service/index.js.map +1 -0
  190. package/dist/lib/service/utils.js +49 -0
  191. package/dist/lib/service/utils.js.map +1 -0
  192. package/dist/lib/skill/index.js +72 -0
  193. package/dist/lib/skill/index.js.map +1 -0
  194. package/dist/lib/task-runner.js +295 -0
  195. package/dist/lib/task-runner.js.map +1 -0
  196. package/dist/lib/task-timing.js +46 -0
  197. package/dist/lib/task-timing.js.map +1 -0
  198. package/dist/lib/tree.js +53 -0
  199. package/dist/lib/tree.js.map +1 -0
  200. package/dist/lib/types.js +285 -0
  201. package/dist/lib/types.js.map +1 -0
  202. package/dist/lib/utils.js +297 -0
  203. package/dist/lib/utils.js.map +1 -0
  204. package/dist/lib/yaml/builder.js +57 -0
  205. package/dist/lib/yaml/builder.js.map +1 -0
  206. package/dist/lib/yaml/index.js +81 -0
  207. package/dist/lib/yaml/index.js.map +1 -0
  208. package/dist/lib/yaml/player.js +452 -0
  209. package/dist/lib/yaml/player.js.map +1 -0
  210. package/dist/lib/yaml/utils.js +126 -0
  211. package/dist/lib/yaml/utils.js.map +1 -0
  212. package/dist/lib/yaml.js +20 -0
  213. package/dist/lib/yaml.js.map +1 -0
  214. package/dist/types/agent/agent.d.ts +190 -0
  215. package/dist/types/agent/common.d.ts +0 -0
  216. package/dist/types/agent/execution-session.d.ts +36 -0
  217. package/dist/types/agent/index.d.ts +10 -0
  218. package/dist/types/agent/task-builder.d.ts +34 -0
  219. package/dist/types/agent/task-cache.d.ts +48 -0
  220. package/dist/types/agent/tasks.d.ts +70 -0
  221. package/dist/types/agent/ui-utils.d.ts +14 -0
  222. package/dist/types/agent/utils.d.ts +29 -0
  223. package/dist/types/ai-model/auto-glm/actions.d.ts +77 -0
  224. package/dist/types/ai-model/auto-glm/index.d.ts +6 -0
  225. package/dist/types/ai-model/auto-glm/parser.d.ts +18 -0
  226. package/dist/types/ai-model/auto-glm/planning.d.ts +10 -0
  227. package/dist/types/ai-model/auto-glm/prompt.d.ts +27 -0
  228. package/dist/types/ai-model/auto-glm/util.d.ts +13 -0
  229. package/dist/types/ai-model/conversation-history.d.ts +105 -0
  230. package/dist/types/ai-model/index.d.ts +14 -0
  231. package/dist/types/ai-model/inspect.d.ts +58 -0
  232. package/dist/types/ai-model/llm-planning.d.ts +19 -0
  233. package/dist/types/ai-model/prompt/common.d.ts +2 -0
  234. package/dist/types/ai-model/prompt/describe.d.ts +1 -0
  235. package/dist/types/ai-model/prompt/extraction.d.ts +7 -0
  236. package/dist/types/ai-model/prompt/llm-locator.d.ts +3 -0
  237. package/dist/types/ai-model/prompt/llm-planning.d.ts +10 -0
  238. package/dist/types/ai-model/prompt/llm-section-locator.d.ts +3 -0
  239. package/dist/types/ai-model/prompt/order-sensitive-judge.d.ts +2 -0
  240. package/dist/types/ai-model/prompt/playwright-generator.d.ts +26 -0
  241. package/dist/types/ai-model/prompt/ui-tars-planning.d.ts +2 -0
  242. package/dist/types/ai-model/prompt/util.d.ts +33 -0
  243. package/dist/types/ai-model/prompt/yaml-generator.d.ts +100 -0
  244. package/dist/types/ai-model/service-caller/index.d.ts +49 -0
  245. package/dist/types/ai-model/ui-tars-planning.d.ts +72 -0
  246. package/dist/types/common.d.ts +288 -0
  247. package/dist/types/device/device-options.d.ts +142 -0
  248. package/dist/types/device/index.d.ts +2315 -0
  249. package/dist/types/dump/html-utils.d.ts +52 -0
  250. package/dist/types/dump/image-restoration.d.ts +6 -0
  251. package/dist/types/dump/index.d.ts +5 -0
  252. package/dist/types/index.d.ts +17 -0
  253. package/dist/types/report-generator.d.ts +48 -0
  254. package/dist/types/report.d.ts +15 -0
  255. package/dist/types/screenshot-item.d.ts +66 -0
  256. package/dist/types/service/index.d.ts +23 -0
  257. package/dist/types/service/utils.d.ts +2 -0
  258. package/dist/types/skill/index.d.ts +25 -0
  259. package/dist/types/task-runner.d.ts +48 -0
  260. package/dist/types/task-timing.d.ts +8 -0
  261. package/dist/types/tree.d.ts +4 -0
  262. package/dist/types/types.d.ts +645 -0
  263. package/dist/types/utils.d.ts +40 -0
  264. package/dist/types/yaml/builder.d.ts +2 -0
  265. package/dist/types/yaml/index.d.ts +4 -0
  266. package/dist/types/yaml/player.d.ts +34 -0
  267. package/dist/types/yaml/utils.d.ts +9 -0
  268. package/dist/types/yaml.d.ts +203 -0
  269. package/package.json +111 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-model/prompt/extraction.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/ai-model/prompt/extraction.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 { AIDataExtractionResponse } from '@/types';\nimport { getPreferredLanguage } from '@midscene/shared/env';\nimport type { ResponseFormatJSONSchema } from 'openai/resources/index';\nimport { safeParseJson } from '../service-caller/index';\nimport { extractXMLTag } from './util';\n\n/**\n * Parse XML response from LLM and convert to AIDataExtractionResponse\n */\nexport function parseXMLExtractionResponse<T>(\n xmlString: string,\n): AIDataExtractionResponse<T> {\n const thought = extractXMLTag(xmlString, 'thought');\n const dataJsonStr = extractXMLTag(xmlString, 'data-json');\n const errorsStr = extractXMLTag(xmlString, 'errors');\n\n // Parse data-json (required)\n if (!dataJsonStr) {\n throw new Error('Missing required field: data-json');\n }\n\n let data: T;\n try {\n data = safeParseJson(dataJsonStr, undefined) as T;\n } catch (e) {\n throw new Error(`Failed to parse data-json: ${e}`);\n }\n\n // Parse errors (optional)\n let errors: string[] | undefined;\n if (errorsStr) {\n try {\n const parsedErrors = safeParseJson(errorsStr, undefined);\n if (Array.isArray(parsedErrors)) {\n errors = parsedErrors;\n }\n } catch (e) {\n // If errors parsing fails, just ignore it\n }\n }\n\n return {\n ...(thought ? { thought } : {}),\n data,\n ...(errors && errors.length > 0 ? { errors } : {}),\n };\n}\n\nexport function systemPromptToExtract() {\n const preferredLanguage = getPreferredLanguage();\n\n return `\nYou are a versatile professional in software UI design and testing. Your outstanding contributions will impact the user experience of billions of users.\n\nThe user will give you a screenshot, the contents of it (optional), and some data requirements in <DATA_DEMAND>. You need to understand the user's requirements and extract the data satisfying the <DATA_DEMAND>.\n\nIf a key specifies a JSON data type (such as Number, String, Boolean, Object, Array), ensure the returned value strictly matches that data type.\n\nIf the user provides multiple reference images, please carefully review the reference images with the screenshot and provide the correct answer for <DATA_DEMAND>.\n\n\nReturn in the following XML format:\n<thought>the thinking process of the extraction, less than 300 words. Use ${preferredLanguage} in this field.</thought>\n<data-json>the extracted data as JSON. Make sure both the value and scheme meet the DATA_DEMAND. If you want to write some description in this field, use the same language as the DATA_DEMAND.</data-json>\n<errors>optional error messages as JSON array, e.g., [\"error1\", \"error2\"]</errors>\n\n# Example 1\nFor example, if the DATA_DEMAND is:\n\n<DATA_DEMAND>\n{\n \"name\": \"name shows on the left panel, string\",\n \"age\": \"age shows on the right panel, number\",\n \"isAdmin\": \"if the user is admin, boolean\"\n}\n</DATA_DEMAND>\n\nBy viewing the screenshot and page contents, you can extract the following data:\n\n<thought>According to the screenshot, i can see ...</thought>\n<data-json>\n{\n \"name\": \"John\",\n \"age\": 30,\n \"isAdmin\": true\n}\n</data-json>\n\n# Example 2\nIf the DATA_DEMAND is:\n\n<DATA_DEMAND>\nthe todo items list, string[]\n</DATA_DEMAND>\n\nBy viewing the screenshot and page contents, you can extract the following data:\n\n<thought>According to the screenshot, i can see ...</thought>\n<data-json>\n[\"todo 1\", \"todo 2\", \"todo 3\"]\n</data-json>\n\n# Example 3\nIf the DATA_DEMAND is:\n\n<DATA_DEMAND>\nthe page title, string\n</DATA_DEMAND>\n\nBy viewing the screenshot and page contents, you can extract the following data:\n\n<thought>According to the screenshot, i can see ...</thought>\n<data-json>\n\"todo list\"\n</data-json>\n\n# Example 4\nIf the DATA_DEMAND is:\n\n<DATA_DEMAND>\n{\n \"result\": \"Boolean, is it currently the SMS page?\"\n}\n</DATA_DEMAND>\n\nBy viewing the screenshot and page contents, you can extract the following data:\n\n<thought>According to the screenshot, i can see ...</thought>\n<data-json>\n{ \"result\": true }\n</data-json>\n`;\n}\n\nexport const extractDataQueryPrompt = (\n pageDescription: string,\n dataQuery: string | Record<string, string>,\n) => {\n let dataQueryText = '';\n if (typeof dataQuery === 'string') {\n dataQueryText = dataQuery;\n } else {\n dataQueryText = JSON.stringify(dataQuery, null, 2);\n }\n\n return `\n<PageDescription>\n${pageDescription}\n</PageDescription>\n\n<DATA_DEMAND>\n${dataQueryText}\n</DATA_DEMAND>\n `;\n};\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","parseXMLExtractionResponse","xmlString","thought","extractXMLTag","dataJsonStr","errorsStr","Error","data","safeParseJson","undefined","e","errors","parsedErrors","Array","systemPromptToExtract","preferredLanguage","getPreferredLanguage","extractDataQueryPrompt","pageDescription","data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AAOF,GAAG,CAEZ;IAGF,OAAO;QACL,GAAIR,UAAU;YAAEA;QAAQ,IAAI,CAAC,CAAC;QAC9BK;QACA,GAAII,UAAUA,OAAO,MAAM,GAAG,IAAI;YAAEA;QAAO,IAAI,CAAC,CAAC;IACnD;AACF;AAEO,SAASG;IACd,MAAMC,oBAAoBC,AAAAA,IAAAA,oBAAAA,oBAAAA,AAAAA;IAE1B,OAAO,CAAC;;;;;;;;;;;0EAWgE,EAAED,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqE9F,CAAC;AACD;AAEO,MAAME,yBAAyB,CACpCC,iBACAC;IAEA,IAAIC,gBAAgB;IAElBA,gBADE,AAAqB,YAArB,OAAOD,YACOA,YAEAE,KAAK,SAAS,CAACF,WAAW,MAAM;IAGlD,OAAO,CAAC;;AAEV,EAAED,gBAAgB;;;;AAIlB,EAAEE,cAAc;;EAEd,CAAC;AACH"}
@@ -0,0 +1,88 @@
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
+ systemPromptToLocateElement: ()=>systemPromptToLocateElement,
28
+ findElementPrompt: ()=>findElementPrompt
29
+ });
30
+ const env_namespaceObject = require("@midscene/shared/env");
31
+ const external_common_js_namespaceObject = require("./common.js");
32
+ function systemPromptToLocateElement(modelFamily) {
33
+ const preferredLanguage = (0, env_namespaceObject.getPreferredLanguage)();
34
+ const bboxComment = (0, external_common_js_namespaceObject.bboxDescription)(modelFamily);
35
+ return `
36
+ ## Role:
37
+ You are an AI assistant that helps identify UI elements.
38
+
39
+ ## Objective:
40
+ - Identify elements in screenshots that match the user's description.
41
+ - Provide the coordinates of the element that matches the user's description.
42
+
43
+ ## Important Notes for Locating Elements:
44
+ - When the user describes an element that contains text (such as buttons, input fields, dropdown options, radio buttons, etc.), you should locate ONLY the text region of that element, not the entire element boundary.
45
+ - For example: If an input field is large (both wide and tall) with a placeholder text "Please enter your comment", you should locate only the area where the placeholder text appears, not the entire input field.
46
+ - This principle applies to all text-containing elements: focus on the visible text region rather than the full element container.
47
+
48
+ ## Output Format:
49
+ \`\`\`json
50
+ {
51
+ "bbox": [number, number, number, number], // ${bboxComment}
52
+ "errors"?: string[]
53
+ }
54
+ \`\`\`
55
+
56
+ Fields:
57
+ * \`bbox\` is the bounding box of the element that matches the user's description
58
+ * \`errors\` is an optional array of error messages (if any)
59
+
60
+ For example, when an element is found:
61
+ \`\`\`json
62
+ {
63
+ "bbox": [100, 100, 200, 200],
64
+ "errors": []
65
+ }
66
+ \`\`\`
67
+
68
+ When no element is found:
69
+ \`\`\`json
70
+ {
71
+ "bbox": [],
72
+ "errors": ["I can see ..., but {some element} is not found. Use ${preferredLanguage}."]
73
+ }
74
+ \`\`\`
75
+ `;
76
+ }
77
+ const findElementPrompt = (targetElementDescription)=>`Find: ${targetElementDescription}`;
78
+ exports.findElementPrompt = __webpack_exports__.findElementPrompt;
79
+ exports.systemPromptToLocateElement = __webpack_exports__.systemPromptToLocateElement;
80
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
81
+ "findElementPrompt",
82
+ "systemPromptToLocateElement"
83
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
84
+ Object.defineProperty(exports, '__esModule', {
85
+ value: true
86
+ });
87
+
88
+ //# sourceMappingURL=llm-locator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-model/prompt/llm-locator.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/ai-model/prompt/llm-locator.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 { TModelFamily } from '@midscene/shared/env';\nimport { getPreferredLanguage } from '@midscene/shared/env';\nimport { bboxDescription } from './common';\nexport function systemPromptToLocateElement(\n modelFamily: TModelFamily | undefined,\n) {\n const preferredLanguage = getPreferredLanguage();\n const bboxComment = bboxDescription(modelFamily);\n return `\n## Role:\nYou are an AI assistant that helps identify UI elements.\n\n## Objective:\n- Identify elements in screenshots that match the user's description.\n- Provide the coordinates of the element that matches the user's description.\n\n## Important Notes for Locating Elements:\n- When the user describes an element that contains text (such as buttons, input fields, dropdown options, radio buttons, etc.), you should locate ONLY the text region of that element, not the entire element boundary.\n- For example: If an input field is large (both wide and tall) with a placeholder text \"Please enter your comment\", you should locate only the area where the placeholder text appears, not the entire input field.\n- This principle applies to all text-containing elements: focus on the visible text region rather than the full element container.\n\n## Output Format:\n\\`\\`\\`json\n{\n \"bbox\": [number, number, number, number], // ${bboxComment}\n \"errors\"?: string[]\n}\n\\`\\`\\`\n\nFields:\n* \\`bbox\\` is the bounding box of the element that matches the user's description\n* \\`errors\\` is an optional array of error messages (if any)\n\nFor example, when an element is found:\n\\`\\`\\`json\n{\n \"bbox\": [100, 100, 200, 200],\n \"errors\": []\n}\n\\`\\`\\`\n\nWhen no element is found:\n\\`\\`\\`json\n{\n \"bbox\": [],\n \"errors\": [\"I can see ..., but {some element} is not found. Use ${preferredLanguage}.\"]\n}\n\\`\\`\\`\n`;\n}\n\nexport const findElementPrompt = (targetElementDescription: string) =>\n `Find: ${targetElementDescription}`;\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","systemPromptToLocateElement","modelFamily","preferredLanguage","getPreferredLanguage","bboxComment","bboxDescription","findElementPrompt","targetElementDescription"],"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;;;;;;;;;;ACHO,SAASI,4BACdC,WAAqC;IAErC,MAAMC,oBAAoBC,AAAAA,IAAAA,oBAAAA,oBAAAA,AAAAA;IAC1B,MAAMC,cAAcC,AAAAA,IAAAA,mCAAAA,eAAAA,AAAAA,EAAgBJ;IACpC,OAAO,CAAC;;;;;;;;;;;;;;;;gDAgBsC,EAAEG,YAAY;;;;;;;;;;;;;;;;;;;;;kEAqBI,EAAEF,kBAAkB;;;AAGtF,CAAC;AACD;AAEO,MAAMI,oBAAoB,CAACC,2BAChC,CAAC,MAAM,EAAEA,0BAA0B"}
@@ -0,0 +1,401 @@
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
+ descriptionForAction: ()=>descriptionForAction,
28
+ systemPromptToTaskPlanning: ()=>systemPromptToTaskPlanning
29
+ });
30
+ const external_common_js_namespaceObject = require("../../common.js");
31
+ const env_namespaceObject = require("@midscene/shared/env");
32
+ const zod_schema_utils_namespaceObject = require("@midscene/shared/zod-schema-utils");
33
+ const external_common_js_namespaceObject_1 = require("./common.js");
34
+ const vlLocateParam = (modelFamily)=>{
35
+ if (modelFamily) return `{bbox: [number, number, number, number], prompt: string } // ${(0, external_common_js_namespaceObject_1.bboxDescription)(modelFamily)}`;
36
+ return "{ prompt: string /* description of the target element */ }";
37
+ };
38
+ const findDefaultValue = (field)=>{
39
+ let current = field;
40
+ const visited = new Set();
41
+ while(current && !visited.has(current)){
42
+ visited.add(current);
43
+ const currentWithDef = current;
44
+ if (!currentWithDef._def?.typeName) break;
45
+ if ('ZodDefault' === currentWithDef._def.typeName) return currentWithDef._def.defaultValue?.();
46
+ if ('ZodOptional' === currentWithDef._def.typeName || 'ZodNullable' === currentWithDef._def.typeName) current = currentWithDef._def.innerType;
47
+ else break;
48
+ }
49
+ };
50
+ const SAMPLE_BBOXES = [
51
+ [
52
+ 50,
53
+ 100,
54
+ 200,
55
+ 200
56
+ ],
57
+ [
58
+ 300,
59
+ 400,
60
+ 500,
61
+ 500
62
+ ],
63
+ [
64
+ 600,
65
+ 100,
66
+ 800,
67
+ 250
68
+ ],
69
+ [
70
+ 50,
71
+ 600,
72
+ 250,
73
+ 750
74
+ ]
75
+ ];
76
+ const injectBboxIntoSample = (sample, locateFields, includeBbox)=>{
77
+ if (!includeBbox) return sample;
78
+ const result = {
79
+ ...sample
80
+ };
81
+ let bboxIndex = 0;
82
+ for (const field of locateFields)if (result[field] && 'object' == typeof result[field] && result[field].prompt) {
83
+ result[field] = {
84
+ ...result[field],
85
+ bbox: SAMPLE_BBOXES[bboxIndex % SAMPLE_BBOXES.length]
86
+ };
87
+ bboxIndex++;
88
+ }
89
+ return result;
90
+ };
91
+ const descriptionForAction = (action, locatorSchemaTypeDescription, includeBbox = false)=>{
92
+ const tab = ' ';
93
+ const fields = [];
94
+ fields.push(`- type: "${action.name}"`);
95
+ if (action.paramSchema) {
96
+ const paramLines = [];
97
+ const schema = action.paramSchema;
98
+ const isZodObject = schema._def?.typeName === 'ZodObject';
99
+ if (isZodObject && schema.shape) {
100
+ const shape = schema.shape;
101
+ for (const [key, field] of Object.entries(shape))if (field && 'object' == typeof field) {
102
+ const isOptional = 'function' == typeof field.isOptional && field.isOptional();
103
+ const keyWithOptional = isOptional ? `${key}?` : key;
104
+ const typeName = (0, zod_schema_utils_namespaceObject.getZodTypeName)(field, locatorSchemaTypeDescription);
105
+ const description = (0, zod_schema_utils_namespaceObject.getZodDescription)(field);
106
+ const defaultValue = findDefaultValue(field);
107
+ const hasDefault = void 0 !== defaultValue;
108
+ let paramLine = `${keyWithOptional}: ${typeName}`;
109
+ const comments = [];
110
+ if (description) comments.push(description);
111
+ if (hasDefault) {
112
+ const defaultStr = 'string' == typeof defaultValue ? `"${defaultValue}"` : JSON.stringify(defaultValue);
113
+ comments.push(`default: ${defaultStr}`);
114
+ }
115
+ if (comments.length > 0) paramLine += ` // ${comments.join(', ')}`;
116
+ paramLines.push(paramLine);
117
+ }
118
+ if (paramLines.length > 0) {
119
+ fields.push('- param:');
120
+ paramLines.forEach((line)=>{
121
+ fields.push(` - ${line}`);
122
+ });
123
+ }
124
+ } else {
125
+ const typeName = (0, zod_schema_utils_namespaceObject.getZodTypeName)(schema);
126
+ const description = (0, zod_schema_utils_namespaceObject.getZodDescription)(schema);
127
+ let paramDescription = `- param: ${typeName}`;
128
+ if (description) paramDescription += ` // ${description}`;
129
+ paramDescription += ' (pass the value directly, not as an object)';
130
+ fields.push(paramDescription);
131
+ }
132
+ }
133
+ if (action.sample && 'object' == typeof action.sample) {
134
+ const locateFields = (0, external_common_js_namespaceObject.findAllMidsceneLocatorField)(action.paramSchema);
135
+ const sampleWithBbox = injectBboxIntoSample(action.sample, locateFields, includeBbox);
136
+ const sampleStr = `- sample:\n${tab}${tab}<action-type>${action.name}</action-type>\n${tab}${tab}<action-param-json>\n${tab}${tab}${JSON.stringify(sampleWithBbox, null, 2).replace(/\n/g, `\n${tab}${tab}`)}\n${tab}${tab}</action-param-json>`;
137
+ fields.push(sampleStr);
138
+ }
139
+ return `- ${action.name}, ${action.description || "No description provided"}
140
+ ${tab}${fields.join(`\n${tab}`)}
141
+ `.trim();
142
+ };
143
+ const EXPLICIT_INSTRUCTION_RULES = `
144
+ **Explicit instructions vs. High-level goals:**
145
+ - **Explicit steps** (e.g., "click X", "type Y", "fill form"): Execute EXACTLY those steps - nothing more
146
+ - **High-level goals** (e.g., "log in", "complete purchase"): Determine necessary steps
147
+
148
+ **Examples:**
149
+ - "fill out the form" → Fill fields only, do NOT submit
150
+ - "click the button" → Click only, do NOT wait for page load
151
+ - "type 'hello'" → Type only, do NOT press Enter
152
+ - "select the first item" → Select only, do NOT proceed to checkout`;
153
+ const ASSERTION_RULES = `
154
+ **Assertion instructions:**
155
+ - If assertion condition is NOT satisfied and cannot be satisfied, mark as failed (success="false")
156
+ - If page is loading (spinner, skeleton, progress bar), wait before asserting`;
157
+ const PAGE_NAVIGATION_RULES = `
158
+ **Page navigation restriction:**
159
+ - Complete task on current page unless explicitly instructed to navigate
160
+ - Do NOT click links, use browser navigation, or open new URLs
161
+ - If task cannot be accomplished, report failure instead of navigating`;
162
+ const generateSubGoalSection = ()=>`
163
+ * <update-plan-content> tag
164
+
165
+ <update-plan-content>
166
+ <sub-goal index="1" status="finished|pending">description</sub-goal>
167
+ <sub-goal index="2" status="finished|pending">description</sub-goal>
168
+ </update-plan-content>
169
+
170
+ * <mark-sub-goal-done> tag
171
+
172
+ <mark-sub-goal-done>
173
+ <sub-goal index="1" status="finished" />
174
+ </mark-sub-goal-done>
175
+
176
+ IMPORTANT: Mark sub-goal as "finished" ONLY AFTER confirming completion in screenshot.`;
177
+ const generateSimplifiedExample = (includeSubGoals, locateNameField, locateEmailField)=>{
178
+ if (includeSubGoals) return `
179
+ ## Example: Fill registration form
180
+
181
+ **User:** "fill out the form with name 'John' and email 'xxxx(真实的email地址)', then return the email"
182
+
183
+ **Response:**
184
+ <thought>Form has Name and Email fields. Both empty. Break into sub-goals.</thought>
185
+ <update-plan-content>
186
+ <sub-goal index="1" status="pending">Fill Name with 'John'</sub-goal>
187
+ <sub-goal index="2" status="pending">Fill Email with 'xxxx(真实的email地址)'</sub-goal>
188
+ <sub-goal index="3" status="pending">Return email address</sub-goal>
189
+ </update-plan-content>
190
+ <log>Click Name field</log>
191
+ <action-type>Tap</action-type>
192
+ <action-param-json>{"locate": ${locateNameField}}</action-param-json>
193
+
194
+ (After typing name)
195
+ <thought>Name='John'. Sub-goal 1 complete. Fill Email next.</thought>
196
+ <mark-sub-goal-done><sub-goal index="1" status="finished" /></mark-sub-goal-done>
197
+ <log>Click Email field</log>
198
+ <action-type>Tap</action-type>
199
+ <action-param-json>{"locate": ${locateEmailField}}</action-param-json>
200
+
201
+ (After typing email)
202
+ <thought>Both fields filled. All sub-goals complete.</thought>
203
+ <mark-sub-goal-done>
204
+ <sub-goal index="2" status="finished" />
205
+ <sub-goal index="3" status="finished" />
206
+ </mark-sub-goal-done>
207
+ <complete success="true">xxxx(真实的email地址)</complete>`;
208
+ return `
209
+ ## Example: Fill registration form
210
+
211
+ **User:** "fill out the form with name 'John' and email 'xxxx(真实的email地址)', then return the email"
212
+
213
+ **Response:**
214
+ <thought>Form has Name and Email fields. Both empty. Start with Name.</thought>
215
+ <log>Click Name field</log>
216
+ <action-type>Tap</action-type>
217
+ <action-param-json>{"locate": ${locateNameField}}</action-param-json>
218
+
219
+ (After typing name)
220
+ <thought>Name='John'. Fill Email next.</thought>
221
+ <log>Click Email field</log>
222
+ <action-type>Tap</action-type>
223
+ <action-param-json>{"locate": ${locateEmailField}}</action-param-json>
224
+
225
+ (After typing email)
226
+ <thought>Both fields filled. Task complete.</thought>
227
+ <complete success="true">xxxx(真实的email地址)</complete>`;
228
+ };
229
+ async function systemPromptToTaskPlanning({ actionSpace, modelFamily, includeBbox, includeThought, includeSubGoals }) {
230
+ const preferredLanguage = (0, env_namespaceObject.getPreferredLanguage)();
231
+ if (includeBbox && !modelFamily) throw new Error('modelFamily cannot be undefined when includeBbox is true. A valid modelFamily is required for bbox-based location.');
232
+ const actionDescriptionList = actionSpace.map((action)=>descriptionForAction(action, vlLocateParam(includeBbox ? modelFamily : void 0), includeBbox));
233
+ const actionList = actionDescriptionList.join('\n');
234
+ const shouldIncludeSubGoals = includeSubGoals ?? false;
235
+ const locateExample1 = includeBbox ? `{
236
+ "prompt": "Add to cart button for Sauce Labs Backpack",
237
+ "bbox": [345, 442, 458, 483]
238
+ }` : `{
239
+ "prompt": "Add to cart button for Sauce Labs Backpack"
240
+ }`;
241
+ const locateNameField = includeBbox ? `{
242
+ "prompt": "Name input field in the registration form",
243
+ "bbox": [120, 180, 380, 210]
244
+ }` : `{
245
+ "prompt": "Name input field in the registration form"
246
+ }`;
247
+ const locateEmailField = includeBbox ? `{
248
+ "prompt": "Email input field in the registration form",
249
+ "bbox": [120, 240, 380, 270]
250
+ }` : `{
251
+ "prompt": "Email input field in the registration form"
252
+ }`;
253
+ const step1Title = shouldIncludeSubGoals ? '## Step 1: Observe and Plan' : '## Step 1: Observe';
254
+ const step1Description = shouldIncludeSubGoals ? "Observe screenshot and logs, then break down instruction into sub-goals." : 'Observe screenshot and logs to understand current state.';
255
+ const thoughtTagDescription = `REQUIRED: Always output the <thought> tag.
256
+
257
+ Answer these questions:
258
+ - What is the user's requirement?
259
+ - What is the current state?
260
+ ${shouldIncludeSubGoals ? '- Are all sub-goals completed?' : ''}
261
+ - What should be the next action?
262
+
263
+ ${EXPLICIT_INSTRUCTION_RULES}`;
264
+ const subGoalSection = shouldIncludeSubGoals ? generateSubGoalSection() : '';
265
+ const memoryStepNumber = 2;
266
+ const checkGoalStepNumber = shouldIncludeSubGoals ? 3 : 2;
267
+ const actionStepNumber = shouldIncludeSubGoals ? 4 : 3;
268
+ const goalAccomplished = shouldIncludeSubGoals ? 'goal is accomplished' : 'instruction is fulfilled';
269
+ return `
270
+ # Role
271
+ You are an expert UI automation agent. Accomplish user instructions by observing screenshots and executing actions.
272
+
273
+ # Steps
274
+
275
+ ${step1Title}
276
+
277
+ ${step1Description}
278
+
279
+ * <thought> tag (REQUIRED)
280
+
281
+ ${thoughtTagDescription}
282
+ ${subGoalSection}
283
+ ${shouldIncludeSubGoals ? `
284
+ ## Step ${memoryStepNumber}: Memory Data
285
+
286
+ Record information needed in follow-up actions. Current screenshot will NOT be available later.
287
+
288
+ Examples: extracted data, element states, content to reference.
289
+ ` : ''}
290
+ ## Step ${checkGoalStepNumber}: Check if ${shouldIncludeSubGoals ? 'Goal is Accomplished' : 'Instruction is Fulfilled'}
291
+
292
+ ${shouldIncludeSubGoals ? 'Based on screenshot and sub-goals status, determine' : 'Determine'} if task is completed.
293
+
294
+ ### CRITICAL: User's Instruction is Supreme
295
+
296
+ The user's instruction defines EXACT scope. Follow it precisely - nothing more, nothing less.
297
+
298
+ ${EXPLICIT_INSTRUCTION_RULES}
299
+
300
+ **What "${goalAccomplished}" means:**
301
+ - Done EXACTLY what user asked - no extra steps, no assumptions
302
+ - Do NOT perform actions beyond explicit instruction
303
+
304
+ ${ASSERTION_RULES}
305
+ ${!shouldIncludeSubGoals ? `
306
+ ${PAGE_NAVIGATION_RULES}
307
+ ` : ''}
308
+ ### Output Rules
309
+
310
+ - If NOT complete, continue to Step ${actionStepNumber}
311
+ - Use <complete success="true|false">message</complete> to output result
312
+ - success="true" if ${goalAccomplished}
313
+ - success="false" if ${goalAccomplished.replace('is', 'is not').replace('fulfilled', 'fulfilled and cannot be fulfilled')}
314
+ - message: information for user (follow requested format)
315
+ - If outputting <complete>, do NOT output <action-type> or <action-param-json>
316
+
317
+ ## Step ${actionStepNumber}: Determine Next Action
318
+
319
+ ONLY if task is not complete: Determine next action based on current screenshot${shouldIncludeSubGoals ? ' and plan' : ''}.
320
+
321
+ - Don't give extra actions beyond instruction${shouldIncludeSubGoals ? ' or plan' : ''}
322
+ - Consider current screenshot - if element not visible, find it first
323
+ - Ensure previous actions completed successfully
324
+ - Give just the next ONE action
325
+ - If errors persist >3 times, use <error> tag
326
+
327
+ ### Supporting actions list
328
+
329
+ ${actionList}
330
+
331
+ ### Log tag (preamble message)
332
+
333
+ Brief message to user explaining next action:
334
+ - **Use ${preferredLanguage}**
335
+ - **Keep concise**: 1-2 sentences, 8-12 words
336
+ - **Build on context**: connect with previous actions
337
+ - **Friendly tone**: collaborative and engaging
338
+
339
+ **Examples:**
340
+ - <log>Click the login button</log>
341
+ - <log>Scroll to find the 'Yes' button</log>
342
+
343
+ ### Action output
344
+
345
+ Use <action-type> and <action-param-json> tags:
346
+ - <action-type> MUST be from supporting actions list
347
+ - Use EXACT field names from action description
348
+ - 'complete' is NOT a valid action-type
349
+
350
+ Example:
351
+ <action-type>Tap</action-type>
352
+ <action-param-json>
353
+ {
354
+ "locate": ${locateExample1}
355
+ }
356
+ </action-param-json>
357
+
358
+ ### Error output
359
+
360
+ Use <error> tag for error messages:
361
+ <error>Unable to find the required element on the page</error>
362
+
363
+ # Return Format
364
+
365
+ **Always include (REQUIRED):**
366
+ <thought>Your thought process here. NEVER skip this tag.</thought>
367
+ ${shouldIncludeSubGoals ? `
368
+ <update-plan-content>...</update-plan-content>
369
+ <mark-sub-goal-done>
370
+ <sub-goal index="1" status="finished" />
371
+ </mark-sub-goal-done>
372
+ ` : ''}${shouldIncludeSubGoals ? `
373
+ <memory>...</memory>
374
+ ` : ''}
375
+ **Then choose ONE path:**
376
+
377
+ **Path A: If ${goalAccomplished} or failed**
378
+ <complete success="true|false">...</complete>
379
+
380
+ **Path B: If ${goalAccomplished.replace('is', 'is not yet')}**
381
+ <log>...</log>
382
+ <action-type>...</action-type>
383
+ <action-param-json>...</action-param-json>
384
+
385
+ <!-- OR if there's an error -->
386
+ <error>...</error>
387
+
388
+ ${generateSimplifiedExample(shouldIncludeSubGoals, locateNameField, locateEmailField)}
389
+ `;
390
+ }
391
+ exports.descriptionForAction = __webpack_exports__.descriptionForAction;
392
+ exports.systemPromptToTaskPlanning = __webpack_exports__.systemPromptToTaskPlanning;
393
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
394
+ "descriptionForAction",
395
+ "systemPromptToTaskPlanning"
396
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
397
+ Object.defineProperty(exports, '__esModule', {
398
+ value: true
399
+ });
400
+
401
+ //# sourceMappingURL=llm-planning.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-model/prompt/llm-planning.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/ai-model/prompt/llm-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 { findAllMidsceneLocatorField } from '@/common';\nimport type { DeviceAction } from '@/types';\nimport type { TModelFamily } from '@midscene/shared/env';\nimport { getPreferredLanguage } from '@midscene/shared/env';\nimport {\n getZodDescription,\n getZodTypeName,\n} from '@midscene/shared/zod-schema-utils';\nimport type { z } from 'zod';\nimport { bboxDescription } from './common';\n\nconst vlLocateParam = (modelFamily: TModelFamily | undefined) => {\n if (modelFamily) {\n return `{bbox: [number, number, number, number], prompt: string } // ${bboxDescription(modelFamily)}`;\n }\n return '{ prompt: string /* description of the target element */ }';\n};\n\nconst findDefaultValue = (field: unknown): any | undefined => {\n let current = field;\n const visited = new Set<unknown>();\n\n while (current && !visited.has(current)) {\n visited.add(current);\n const currentWithDef = current as {\n _def?: {\n typeName?: string;\n defaultValue?: () => any;\n innerType?: unknown;\n };\n };\n\n if (!currentWithDef._def?.typeName) break;\n\n if (currentWithDef._def.typeName === 'ZodDefault') {\n return currentWithDef._def.defaultValue?.();\n }\n\n if (\n currentWithDef._def.typeName === 'ZodOptional' ||\n currentWithDef._def.typeName === 'ZodNullable'\n ) {\n current = currentWithDef._def.innerType;\n } else {\n break;\n }\n }\n\n return undefined;\n};\n\nconst SAMPLE_BBOXES: [number, number, number, number][] = [\n [50, 100, 200, 200],\n [300, 400, 500, 500],\n [600, 100, 800, 250],\n [50, 600, 250, 750],\n];\n\nconst injectBboxIntoSample = (\n sample: Record<string, any>,\n locateFields: string[],\n includeBbox: boolean,\n): Record<string, any> => {\n if (!includeBbox) return sample;\n const result = { ...sample };\n let bboxIndex = 0;\n for (const field of locateFields) {\n if (\n result[field] &&\n typeof result[field] === 'object' &&\n result[field].prompt\n ) {\n result[field] = {\n ...result[field],\n bbox: SAMPLE_BBOXES[bboxIndex % SAMPLE_BBOXES.length],\n };\n bboxIndex++;\n }\n }\n return result;\n};\n\nexport const descriptionForAction = (\n action: DeviceAction<any>,\n locatorSchemaTypeDescription: string,\n includeBbox = false,\n) => {\n const tab = ' ';\n const fields: string[] = [];\n\n fields.push(`- type: \"${action.name}\"`);\n\n if (action.paramSchema) {\n const paramLines: string[] = [];\n\n const schema = action.paramSchema as {\n _def?: { typeName?: string };\n shape?: Record<string, unknown>;\n };\n const isZodObject = schema._def?.typeName === 'ZodObject';\n\n if (isZodObject && schema.shape) {\n const shape = schema.shape;\n\n for (const [key, field] of Object.entries(shape)) {\n if (field && typeof field === 'object') {\n const isOptional =\n typeof (field as { isOptional?: () => boolean }).isOptional ===\n 'function' &&\n (field as { isOptional: () => boolean }).isOptional();\n const keyWithOptional = isOptional ? `${key}?` : key;\n\n const typeName = getZodTypeName(field, locatorSchemaTypeDescription);\n\n const description = getZodDescription(field as z.ZodTypeAny);\n\n const defaultValue = findDefaultValue(field);\n const hasDefault = defaultValue !== undefined;\n\n let paramLine = `${keyWithOptional}: ${typeName}`;\n const comments: string[] = [];\n if (description) {\n comments.push(description);\n }\n if (hasDefault) {\n const defaultStr =\n typeof defaultValue === 'string'\n ? `\"${defaultValue}\"`\n : JSON.stringify(defaultValue);\n comments.push(`default: ${defaultStr}`);\n }\n if (comments.length > 0) {\n paramLine += ` // ${comments.join(', ')}`;\n }\n\n paramLines.push(paramLine);\n }\n }\n\n if (paramLines.length > 0) {\n fields.push('- param:');\n paramLines.forEach((line) => {\n fields.push(` - ${line}`);\n });\n }\n } else {\n const typeName = getZodTypeName(schema);\n const description = getZodDescription(schema as z.ZodTypeAny);\n\n let paramDescription = `- param: ${typeName}`;\n if (description) {\n paramDescription += ` // ${description}`;\n }\n paramDescription += ' (pass the value directly, not as an object)';\n\n fields.push(paramDescription);\n }\n }\n\n if (action.sample && typeof action.sample === 'object') {\n const locateFields = findAllMidsceneLocatorField(action.paramSchema);\n const sampleWithBbox = injectBboxIntoSample(\n action.sample,\n locateFields,\n includeBbox,\n );\n const sampleStr = `- sample:\\n${tab}${tab}<action-type>${action.name}</action-type>\\n${tab}${tab}<action-param-json>\\n${tab}${tab}${JSON.stringify(sampleWithBbox, null, 2).replace(/\\n/g, `\\n${tab}${tab}`)}\\n${tab}${tab}</action-param-json>`;\n fields.push(sampleStr);\n }\n\n return `- ${action.name}, ${action.description || 'No description provided'}\n${tab}${fields.join(`\\n${tab}`)}\n`.trim();\n};\n\nconst EXPLICIT_INSTRUCTION_RULES = `\n**Explicit instructions vs. High-level goals:**\n- **Explicit steps** (e.g., \"click X\", \"type Y\", \"fill form\"): Execute EXACTLY those steps - nothing more\n- **High-level goals** (e.g., \"log in\", \"complete purchase\"): Determine necessary steps\n\n**Examples:**\n- \"fill out the form\" → Fill fields only, do NOT submit\n- \"click the button\" → Click only, do NOT wait for page load\n- \"type 'hello'\" → Type only, do NOT press Enter\n- \"select the first item\" → Select only, do NOT proceed to checkout`;\n\nconst ASSERTION_RULES = `\n**Assertion instructions:**\n- If assertion condition is NOT satisfied and cannot be satisfied, mark as failed (success=\"false\")\n- If page is loading (spinner, skeleton, progress bar), wait before asserting`;\n\nconst PAGE_NAVIGATION_RULES = `\n**Page navigation restriction:**\n- Complete task on current page unless explicitly instructed to navigate\n- Do NOT click links, use browser navigation, or open new URLs\n- If task cannot be accomplished, report failure instead of navigating`;\n\nconst generateSubGoalSection = () => `\n* <update-plan-content> tag\n\n<update-plan-content>\n <sub-goal index=\"1\" status=\"finished|pending\">description</sub-goal>\n <sub-goal index=\"2\" status=\"finished|pending\">description</sub-goal>\n</update-plan-content>\n\n* <mark-sub-goal-done> tag\n\n<mark-sub-goal-done>\n <sub-goal index=\"1\" status=\"finished\" />\n</mark-sub-goal-done>\n\nIMPORTANT: Mark sub-goal as \"finished\" ONLY AFTER confirming completion in screenshot.`;\n\nconst generateSimplifiedExample = (\n includeSubGoals: boolean,\n locateNameField: string,\n locateEmailField: string,\n) => {\n if (includeSubGoals) {\n return `\n## Example: Fill registration form\n\n**User:** \"fill out the form with name 'John' and email 'xxxx(真实的email地址)', then return the email\"\n\n**Response:**\n<thought>Form has Name and Email fields. Both empty. Break into sub-goals.</thought>\n<update-plan-content>\n <sub-goal index=\"1\" status=\"pending\">Fill Name with 'John'</sub-goal>\n <sub-goal index=\"2\" status=\"pending\">Fill Email with 'xxxx(真实的email地址)'</sub-goal>\n <sub-goal index=\"3\" status=\"pending\">Return email address</sub-goal>\n</update-plan-content>\n<log>Click Name field</log>\n<action-type>Tap</action-type>\n<action-param-json>{\"locate\": ${locateNameField}}</action-param-json>\n\n(After typing name)\n<thought>Name='John'. Sub-goal 1 complete. Fill Email next.</thought>\n<mark-sub-goal-done><sub-goal index=\"1\" status=\"finished\" /></mark-sub-goal-done>\n<log>Click Email field</log>\n<action-type>Tap</action-type>\n<action-param-json>{\"locate\": ${locateEmailField}}</action-param-json>\n\n(After typing email)\n<thought>Both fields filled. All sub-goals complete.</thought>\n<mark-sub-goal-done>\n <sub-goal index=\"2\" status=\"finished\" />\n <sub-goal index=\"3\" status=\"finished\" />\n</mark-sub-goal-done>\n<complete success=\"true\">xxxx(真实的email地址)</complete>`;\n }\n\n return `\n## Example: Fill registration form\n\n**User:** \"fill out the form with name 'John' and email 'xxxx(真实的email地址)', then return the email\"\n\n**Response:**\n<thought>Form has Name and Email fields. Both empty. Start with Name.</thought>\n<log>Click Name field</log>\n<action-type>Tap</action-type>\n<action-param-json>{\"locate\": ${locateNameField}}</action-param-json>\n\n(After typing name)\n<thought>Name='John'. Fill Email next.</thought>\n<log>Click Email field</log>\n<action-type>Tap</action-type>\n<action-param-json>{\"locate\": ${locateEmailField}}</action-param-json>\n\n(After typing email)\n<thought>Both fields filled. Task complete.</thought>\n<complete success=\"true\">xxxx(真实的email地址)</complete>`;\n};\n\nexport async function systemPromptToTaskPlanning({\n actionSpace,\n modelFamily,\n includeBbox,\n includeThought,\n includeSubGoals,\n}: {\n actionSpace: DeviceAction<any>[];\n modelFamily: TModelFamily | undefined;\n includeBbox: boolean;\n includeThought?: boolean;\n includeSubGoals?: boolean;\n}) {\n const preferredLanguage = getPreferredLanguage();\n\n if (includeBbox && !modelFamily) {\n throw new Error(\n 'modelFamily cannot be undefined when includeBbox is true. A valid modelFamily is required for bbox-based location.',\n );\n }\n\n const actionDescriptionList = actionSpace.map((action) => {\n return descriptionForAction(\n action,\n vlLocateParam(includeBbox ? modelFamily : undefined),\n includeBbox,\n );\n });\n const actionList = actionDescriptionList.join('\\n');\n\n const shouldIncludeThought = includeThought ?? true;\n const shouldIncludeSubGoals = includeSubGoals ?? false;\n\n const locateExample1 = includeBbox\n ? `{\n \"prompt\": \"Add to cart button for Sauce Labs Backpack\",\n \"bbox\": [345, 442, 458, 483]\n }`\n : `{\n \"prompt\": \"Add to cart button for Sauce Labs Backpack\"\n }`;\n\n const locateNameField = includeBbox\n ? `{\n \"prompt\": \"Name input field in the registration form\",\n \"bbox\": [120, 180, 380, 210]\n }`\n : `{\n \"prompt\": \"Name input field in the registration form\"\n }`;\n\n const locateEmailField = includeBbox\n ? `{\n \"prompt\": \"Email input field in the registration form\",\n \"bbox\": [120, 240, 380, 270]\n }`\n : `{\n \"prompt\": \"Email input field in the registration form\"\n }`;\n\n const step1Title = shouldIncludeSubGoals\n ? '## Step 1: Observe and Plan'\n : '## Step 1: Observe';\n\n const step1Description = shouldIncludeSubGoals\n ? \"Observe screenshot and logs, then break down instruction into sub-goals.\"\n : 'Observe screenshot and logs to understand current state.';\n\n const thoughtTagDescription = `REQUIRED: Always output the <thought> tag.\n\nAnswer these questions:\n- What is the user's requirement?\n- What is the current state?\n${shouldIncludeSubGoals ? '- Are all sub-goals completed?' : ''}\n- What should be the next action?\n\n${EXPLICIT_INSTRUCTION_RULES}`;\n\n const subGoalSection = shouldIncludeSubGoals ? generateSubGoalSection() : '';\n\n const memoryStepNumber = 2;\n const checkGoalStepNumber = shouldIncludeSubGoals ? 3 : 2;\n const actionStepNumber = shouldIncludeSubGoals ? 4 : 3;\n\n const goalTerm = shouldIncludeSubGoals ? 'goal' : 'instruction';\n const goalAccomplished = shouldIncludeSubGoals ? 'goal is accomplished' : 'instruction is fulfilled';\n\n return `\n# Role\nYou are an expert UI automation agent. Accomplish user instructions by observing screenshots and executing actions.\n\n# Steps\n\n${step1Title}\n\n${step1Description}\n\n* <thought> tag (REQUIRED)\n\n${thoughtTagDescription}\n${subGoalSection}\n${\n shouldIncludeSubGoals\n ? `\n## Step ${memoryStepNumber}: Memory Data\n\nRecord information needed in follow-up actions. Current screenshot will NOT be available later.\n\nExamples: extracted data, element states, content to reference.\n`\n : ''\n}\n## Step ${checkGoalStepNumber}: Check if ${shouldIncludeSubGoals ? 'Goal is Accomplished' : 'Instruction is Fulfilled'}\n\n${shouldIncludeSubGoals ? 'Based on screenshot and sub-goals status, determine' : 'Determine'} if task is completed.\n\n### CRITICAL: User's Instruction is Supreme\n\nThe user's instruction defines EXACT scope. Follow it precisely - nothing more, nothing less.\n\n${EXPLICIT_INSTRUCTION_RULES}\n\n**What \"${goalAccomplished}\" means:**\n- Done EXACTLY what user asked - no extra steps, no assumptions\n- Do NOT perform actions beyond explicit instruction\n\n${ASSERTION_RULES}\n${\n !shouldIncludeSubGoals\n ? `\n${PAGE_NAVIGATION_RULES}\n`\n : ''\n}\n### Output Rules\n\n- If NOT complete, continue to Step ${actionStepNumber}\n- Use <complete success=\"true|false\">message</complete> to output result\n - success=\"true\" if ${goalAccomplished}\n - success=\"false\" if ${goalAccomplished.replace('is', 'is not').replace('fulfilled', 'fulfilled and cannot be fulfilled')}\n - message: information for user (follow requested format)\n- If outputting <complete>, do NOT output <action-type> or <action-param-json>\n\n## Step ${actionStepNumber}: Determine Next Action\n\nONLY if task is not complete: Determine next action based on current screenshot${shouldIncludeSubGoals ? ' and plan' : ''}.\n\n- Don't give extra actions beyond instruction${shouldIncludeSubGoals ? ' or plan' : ''}\n- Consider current screenshot - if element not visible, find it first\n- Ensure previous actions completed successfully\n- Give just the next ONE action\n- If errors persist >3 times, use <error> tag\n\n### Supporting actions list\n\n${actionList}\n\n### Log tag (preamble message)\n\nBrief message to user explaining next action:\n- **Use ${preferredLanguage}**\n- **Keep concise**: 1-2 sentences, 8-12 words\n- **Build on context**: connect with previous actions\n- **Friendly tone**: collaborative and engaging\n\n**Examples:**\n- <log>Click the login button</log>\n- <log>Scroll to find the 'Yes' button</log>\n\n### Action output\n\nUse <action-type> and <action-param-json> tags:\n- <action-type> MUST be from supporting actions list\n- Use EXACT field names from action description\n- 'complete' is NOT a valid action-type\n\nExample:\n<action-type>Tap</action-type>\n<action-param-json>\n{\n \"locate\": ${locateExample1}\n}\n</action-param-json>\n\n### Error output\n\nUse <error> tag for error messages:\n<error>Unable to find the required element on the page</error>\n\n# Return Format\n\n**Always include (REQUIRED):**\n<thought>Your thought process here. NEVER skip this tag.</thought>\n${\n shouldIncludeSubGoals\n ? `\n<update-plan-content>...</update-plan-content>\n<mark-sub-goal-done>\n <sub-goal index=\"1\" status=\"finished\" />\n</mark-sub-goal-done>\n`\n : ''\n}${\n shouldIncludeSubGoals\n ? `\n<memory>...</memory>\n`\n : ''\n}\n**Then choose ONE path:**\n\n**Path A: If ${goalAccomplished} or failed**\n<complete success=\"true|false\">...</complete>\n\n**Path B: If ${goalAccomplished.replace('is', 'is not yet')}**\n<log>...</log>\n<action-type>...</action-type>\n<action-param-json>...</action-param-json>\n\n<!-- OR if there's an error -->\n<error>...</error>\n\n${generateSimplifiedExample(shouldIncludeSubGoals, locateNameField, locateEmailField)}\n`;\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","vlLocateParam","modelFamily","bboxDescription","findDefaultValue","field","current","visited","Set","currentWithDef","SAMPLE_BBOXES","injectBboxIntoSample","sample","locateFields","includeBbox","result","bboxIndex","descriptionForAction","action","locatorSchemaTypeDescription","tab","fields","paramLines","schema","isZodObject","shape","isOptional","keyWithOptional","typeName","getZodTypeName","description","getZodDescription","defaultValue","hasDefault","undefined","paramLine","comments","defaultStr","JSON","line","paramDescription","findAllMidsceneLocatorField","sampleWithBbox","sampleStr","EXPLICIT_INSTRUCTION_RULES","ASSERTION_RULES","PAGE_NAVIGATION_RULES","generateSubGoalSection","generateSimplifiedExample","includeSubGoals","locateNameField","locateEmailField","systemPromptToTaskPlanning","actionSpace","includeThought","preferredLanguage","getPreferredLanguage","Error","actionDescriptionList","actionList","shouldIncludeSubGoals","locateExample1","step1Title","step1Description","thoughtTagDescription","subGoalSection","memoryStepNumber","checkGoalStepNumber","actionStepNumber","goalAccomplished"],"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;;;;;;;;;;;;ACKA,MAAMI,gBAAgB,CAACC;IACrB,IAAIA,aACF,OAAO,CAAC,6DAA6D,EAAEC,AAAAA,IAAAA,qCAAAA,eAAAA,AAAAA,EAAgBD,cAAc;IAEvG,OAAO;AACT;AAEA,MAA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MQ,mBAAmBR,wBAAwB,IAAI;IAGrD,MAAMS,mBAAmBT,wBAAwB,yBAAyB;IAE1E,OAAO,CAAC;;;;;;AAMV,EAAEE,WAAW;;AAEb,EAAEC,iBAAiB;;;;AAInB,EAAEC,sBAAsB;AACxB,EAAEC,eAAe;AACjB,EACEL,wBACI,CAAC;QACC,EAAEM,iBAAiB;;;;;AAK3B,CAAC,GACK,GACL;QACO,EAAEC,oBAAoB,WAAW,EAAEP,wBAAwB,yBAAyB,2BAA2B;;AAEvH,EAAEA,wBAAwB,wDAAwD,YAAY;;;;;;AAM9F,EAAEhB,2BAA2B;;QAErB,EAAEyB,iBAAiB;;;;AAI3B,EAAExB,gBAAgB;AAClB,EACE,CAACe,wBACG,CAAC;AACP,EAAEd,sBAAsB;AACxB,CAAC,GACK,GACL;;;oCAGmC,EAAEsB,iBAAiB;;sBAEjC,EAAEC,iBAAiB;uBAClB,EAAEA,iBAAiB,OAAO,CAAC,MAAM,UAAU,OAAO,CAAC,aAAa,qCAAqC;;;;QAIpH,EAAED,iBAAiB;;+EAEoD,EAAER,wBAAwB,cAAc,GAAG;;6CAE7E,EAAEA,wBAAwB,aAAa,GAAG;;;;;;;;AAQvF,EAAED,WAAW;;;;;QAKL,EAAEJ,kBAAkB;;;;;;;;;;;;;;;;;;;;YAoBhB,EAAEM,eAAe;;;;;;;;;;;;;AAa7B,EACED,wBACI,CAAC;;;;;AAKP,CAAC,GACK,KAEJA,wBACI,CAAC;;AAEP,CAAC,GACK,GACL;;;aAGY,EAAES,iBAAiB;;;aAGnB,EAAEA,iBAAiB,OAAO,CAAC,MAAM,cAAc;;;;;;;;AAQ5D,EAAErB,0BAA0BY,uBAAuBV,iBAAiBC,kBAAkB;AACtF,CAAC;AACD"}
@@ -0,0 +1,81 @@
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
+ sectionLocatorInstruction: ()=>sectionLocatorInstruction,
28
+ systemPromptToLocateSection: ()=>systemPromptToLocateSection
29
+ });
30
+ const env_namespaceObject = require("@midscene/shared/env");
31
+ const external_common_js_namespaceObject = require("./common.js");
32
+ function systemPromptToLocateSection(modelFamily) {
33
+ const preferredLanguage = (0, env_namespaceObject.getPreferredLanguage)();
34
+ const bboxFormat = (0, external_common_js_namespaceObject.bboxDescription)(modelFamily);
35
+ return `
36
+ ## Role:
37
+ You are an AI assistant that helps identify UI elements.
38
+
39
+ ## Objective:
40
+ - Find a section containing the target element
41
+ - If the description mentions reference elements, also locate sections containing those references
42
+
43
+ ## Output Format:
44
+ \`\`\`json
45
+ {
46
+ "bbox": [number, number, number, number], // ${bboxFormat}
47
+ "references_bbox"?: [
48
+ [number, number, number, number],
49
+ ...
50
+ ],
51
+ "error"?: string
52
+ }
53
+ \`\`\`
54
+
55
+ Fields:
56
+ * \`bbox\` - Bounding box of the section containing the target element
57
+ * \`references_bbox\` - Optional array of bounding boxes for reference elements
58
+ * \`error\` - Optional error message if the section cannot be found. Use ${preferredLanguage}.
59
+
60
+ Example:
61
+ If the description is "delete button on the second row with title 'Peter'", return:
62
+ \`\`\`json
63
+ {
64
+ "bbox": [100, 100, 200, 200],
65
+ "references_bbox": [[100, 100, 200, 200]]
66
+ }
67
+ \`\`\`
68
+ `;
69
+ }
70
+ const sectionLocatorInstruction = (sectionDescription)=>`Find section containing: ${sectionDescription}`;
71
+ exports.sectionLocatorInstruction = __webpack_exports__.sectionLocatorInstruction;
72
+ exports.systemPromptToLocateSection = __webpack_exports__.systemPromptToLocateSection;
73
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
74
+ "sectionLocatorInstruction",
75
+ "systemPromptToLocateSection"
76
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
77
+ Object.defineProperty(exports, '__esModule', {
78
+ value: true
79
+ });
80
+
81
+ //# sourceMappingURL=llm-section-locator.js.map