@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 +1 @@
1
- {"version":3,"file":"ai-model/models/auto-glm/parser.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../src/ai-model/models/auto-glm/parser.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 { getDebug } from '@midscene/shared/logger';\nimport type { ParsedAction } from './actions';\n\nconst debug = getDebug('auto-glm-parser');\n\n// Do not rely on regex extraction here; regex can fail on malformed input.\n// Bad Case: finish(message=\"Finished! Now There is a contact whose name is \\\"Tom\\\" in the list.\")\nexport const extractValueAfter = (src: string, key: string): string => {\n const idx = src.indexOf(key);\n if (idx === -1) {\n throw new Error(`Missing key ${key} in action payload ${src}`);\n }\n let rest = src.slice(idx + key.length).trim();\n if (rest.endsWith('\")')) {\n rest = rest.slice(0, -2);\n }\n return rest;\n};\n\nexport function parseAction(response: {\n think: string;\n content: string;\n}): ParsedAction {\n debug('Parsing action:', response);\n let trimmedResponse = '';\n try {\n trimmedResponse = response.content.trim();\n\n if (\n trimmedResponse.startsWith('do(action=\"Type\"') ||\n trimmedResponse.startsWith('do(action=\"Type_Name\"')\n ) {\n const text = extractValueAfter(trimmedResponse, 'text=\"');\n return {\n _metadata: 'do',\n action: 'Type',\n text,\n think: response.think,\n } as ParsedAction;\n }\n\n if (trimmedResponse.startsWith('finish(message=')) {\n let message = extractValueAfter(trimmedResponse, 'finish(message=\"');\n if (message.endsWith(')')) message = message.slice(0, -1);\n return {\n _metadata: 'finish',\n message,\n think: response.think,\n } as ParsedAction;\n }\n\n if (trimmedResponse.startsWith('do(')) {\n const actionMatch = trimmedResponse.match(/do\\(action=\"([^\"]+)\"/);\n if (!actionMatch)\n throw new Error(\n `Failed to extract action type from do() call; raw=\"${trimmedResponse}\"`,\n );\n const actionType = actionMatch[1];\n\n const baseAction = { _metadata: 'do' as const, think: response.think };\n switch (actionType) {\n case 'Tap': {\n const elementMatch = trimmedResponse.match(/element=\\[(\\d+),(\\d+)\\]/);\n if (!elementMatch)\n throw new Error(\n `Failed to extract element coordinates for Tap; raw=\"${trimmedResponse}\"`,\n );\n return {\n ...baseAction,\n action: 'Tap',\n element: [Number(elementMatch[1]), Number(elementMatch[2])],\n } as ParsedAction;\n }\n case 'Double Tap': {\n const elementMatch = trimmedResponse.match(/element=\\[(\\d+),(\\d+)\\]/);\n if (!elementMatch)\n throw new Error(\n `Failed to extract element coordinates for Double Tap; raw=\"${trimmedResponse}\"`,\n );\n return {\n ...baseAction,\n action: 'Double Tap',\n element: [Number(elementMatch[1]), Number(elementMatch[2])],\n } as ParsedAction;\n }\n case 'Swipe': {\n const startMatch = trimmedResponse.match(/start=\\[(\\d+),(\\d+)\\]/);\n const endMatch = trimmedResponse.match(/end=\\[(\\d+),(\\d+)\\]/);\n if (!startMatch || !endMatch)\n throw new Error(\n `Failed to extract start/end coordinates for Swipe; raw=\"${trimmedResponse}\"`,\n );\n return {\n ...baseAction,\n action: 'Swipe',\n start: [Number(startMatch[1]), Number(startMatch[2])],\n end: [Number(endMatch[1]), Number(endMatch[2])],\n } as ParsedAction;\n }\n case 'Long Press': {\n const elementMatch = trimmedResponse.match(/element=\\[(\\d+),(\\d+)\\]/);\n if (!elementMatch)\n throw new Error(\n `Failed to extract element coordinates for Long Press; raw=\"${trimmedResponse}\"`,\n );\n return {\n ...baseAction,\n action: 'Long Press',\n element: [Number(elementMatch[1]), Number(elementMatch[2])],\n } as ParsedAction;\n }\n case 'Launch': {\n const app = extractValueAfter(trimmedResponse, 'app=\"');\n return { ...baseAction, action: 'Launch', app } as ParsedAction;\n }\n case 'Back': {\n return { ...baseAction, action: 'Back' } as ParsedAction;\n }\n case 'Home': {\n return { ...baseAction, action: 'Home' } as ParsedAction;\n }\n case 'Wait': {\n const durationMatch = trimmedResponse.match(\n /duration=(?:[\"\\[])?(\\d+)/,\n );\n if (!durationMatch) {\n throw new Error(\n `Failed to extract duration for Wait; raw=\"${trimmedResponse}\"`,\n );\n }\n const seconds = Number.parseInt(durationMatch[1], 10);\n const durationMs = seconds * 1000;\n return {\n ...baseAction,\n action: 'Wait',\n durationMs,\n } as ParsedAction;\n }\n case 'Interact': {\n return { ...baseAction, action: 'Interact' } as ParsedAction;\n }\n case 'Call_API': {\n const instruction = extractValueAfter(\n trimmedResponse,\n 'instruction=\"',\n );\n return {\n ...baseAction,\n action: 'Call_API',\n instruction,\n } as ParsedAction;\n }\n case 'Take_over': {\n const message = extractValueAfter(trimmedResponse, 'message=\"');\n return {\n ...baseAction,\n action: 'Take_over',\n message,\n } as ParsedAction;\n }\n case 'Note': {\n const message = extractValueAfter(trimmedResponse, 'message=\"');\n return {\n ...baseAction,\n action: 'Note',\n message,\n } as ParsedAction;\n }\n default:\n throw new Error(\n `Unknown action type: ${actionType}; raw=\"${trimmedResponse}\"`,\n );\n }\n }\n throw new Error(`Failed to parse action: ${trimmedResponse}`);\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n throw new Error(\n `Failed to parse action: ${errorMessage}; raw=\"${trimmedResponse}\"`,\n );\n }\n}\n\nexport function parseAutoGLMResponse(content: string): {\n think: string;\n content: string;\n} {\n if (content.includes('finish(message=')) {\n const parts = content.split('finish(message=');\n const think = parts[0].trim();\n const actionContent = `finish(message=${parts[1]}`;\n return { think, content: actionContent };\n }\n if (content.includes('do(action=')) {\n const parts = content.split('do(action=');\n const think = parts[0].trim();\n const actionContent = `do(action=${parts[1]}`;\n return { think, content: actionContent };\n }\n if (content.includes('<answer>')) {\n const parts = content.split('<answer>');\n const think = parts[0]\n .replace(/<think>/g, '')\n .replace(/<\\/think>/g, '')\n .trim();\n const actionContent = parts[1].replace(/<\\/answer>/g, '').trim();\n return { think, content: actionContent };\n }\n return { think: '', content };\n}\n\nexport function parseAutoGLMLocateResponse(rawResponse: string): {\n think: string;\n coordinates: { x: number; y: number } | null;\n error?: string;\n} {\n const { think, content: actionContent } = parseAutoGLMResponse(rawResponse);\n if (!actionContent.startsWith('do(action=\"Tap\"')) {\n return {\n think,\n coordinates: null,\n error: `Unexpected action type in auto-glm locate response: ${actionContent}`,\n };\n }\n try {\n const elementMatch = actionContent.match(/element=\\[(\\d+),(\\d+)\\]/);\n if (!elementMatch) {\n return {\n think,\n coordinates: null,\n error: `Failed to extract element coordinates from auto-glm response: ${actionContent}`,\n };\n }\n const x = Number(elementMatch[1]);\n const y = Number(elementMatch[2]);\n return { think, coordinates: { x, y } };\n } catch (e) {\n const errorMessage = e instanceof Error ? e.message : String(e);\n return {\n think,\n coordinates: null,\n error: `Failed to parse coordinates \"${actionContent}\" with errorMessage: ${errorMessage}`,\n };\n }\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","debug","getDebug","extractValueAfter","src","idx","Error","rest","parseAction","response","trimmedResponse","text","message","actionMatch","actionType","baseAction","elementMatch","Number","startMatch","endMatch","app","durationMatch","seconds","durationMs","instruction","error","errorMessage","String","parseAutoGLMResponse","content","parts","think","actionContent","parseAutoGLMLocateResponse","rawResponse","x","y","e"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ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AQD,QAAQ,KAAK,CAAC;QAC5B,MAAME,QAAQD,KAAK,CAAC,EAAE,CACnB,OAAO,CAAC,YAAY,IACpB,OAAO,CAAC,cAAc,IACtB,IAAI;QACP,MAAME,gBAAgBF,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,eAAe,IAAI,IAAI;QAC9D,OAAO;YAAEC;YAAO,SAASC;QAAc;IACzC;IACA,OAAO;QAAE,OAAO;QAAIH;IAAQ;AAC9B;AAEO,SAASI,2BAA2BC,WAAmB;IAK5D,MAAM,EAAEH,KAAK,EAAE,SAASC,aAAa,EAAE,GAAGJ,qBAAqBM;IAC/D,IAAI,CAACF,cAAc,UAAU,CAAC,oBAC5B,OAAO;QACLD;QACA,aAAa;QACb,OAAO,CAAC,oDAAoD,EAAEC,eAAe;IAC/E;IAEF,IAAI;QACF,MAAMhB,eAAegB,cAAc,KAAK,CAAC;QACzC,IAAI,CAAChB,cACH,OAAO;YACLe;YACA,aAAa;YACb,OAAO,CAAC,8DAA8D,EAAEC,eAAe;QACzF;QAEF,MAAMG,IAAIlB,OAAOD,YAAY,CAAC,EAAE;QAChC,MAAMoB,IAAInB,OAAOD,YAAY,CAAC,EAAE;QAChC,OAAO;YAAEe;YAAO,aAAa;gBAAEI;gBAAGC;YAAE;QAAE;IACxC,EAAE,OAAOC,GAAG;QACV,MAAMX,eAAeW,aAAa/B,QAAQ+B,EAAE,OAAO,GAAGV,OAAOU;QAC7D,OAAO;YACLN;YACA,aAAa;YACb,OAAO,CAAC,6BAA6B,EAAEC,cAAc,qBAAqB,EAAEN,cAAc;QAC5F;IACF;AACF"}
1
+ {"version":3,"file":"ai-model/models/auto-glm/parser.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../src/ai-model/models/auto-glm/parser.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 { getDebug } from '@midscene/shared/logger';\nimport type { AutoGLMParsedAction } from './actions';\n\nconst debug = getDebug('auto-glm-parser');\n\n// Do not rely on regex extraction here; regex can fail on malformed input.\n// Bad Case: finish(message=\"Finished! Now There is a contact whose name is \\\"Tom\\\" in the list.\")\nexport const extractValueAfter = (src: string, key: string): string => {\n const idx = src.indexOf(key);\n if (idx === -1) {\n throw new Error(`Missing key ${key} in action payload ${src}`);\n }\n let rest = src.slice(idx + key.length).trim();\n if (rest.endsWith('\")')) {\n rest = rest.slice(0, -2);\n }\n return rest;\n};\n\nexport function parseAutoGLMPlanningAction(response: {\n think: string;\n content: string;\n}): AutoGLMParsedAction {\n debug('Parsing action:', response);\n let trimmedResponse = '';\n try {\n trimmedResponse = response.content.trim();\n\n if (\n trimmedResponse.startsWith('do(action=\"Type\"') ||\n trimmedResponse.startsWith('do(action=\"Type_Name\"')\n ) {\n const text = extractValueAfter(trimmedResponse, 'text=\"');\n return {\n _metadata: 'do',\n action: 'Type',\n text,\n think: response.think,\n } as AutoGLMParsedAction;\n }\n\n if (trimmedResponse.startsWith('finish(message=')) {\n let message = extractValueAfter(trimmedResponse, 'finish(message=\"');\n if (message.endsWith(')')) message = message.slice(0, -1);\n return {\n _metadata: 'finish',\n message,\n think: response.think,\n } as AutoGLMParsedAction;\n }\n\n if (trimmedResponse.startsWith('do(')) {\n const actionMatch = trimmedResponse.match(/do\\(action=\"([^\"]+)\"/);\n if (!actionMatch)\n throw new Error(\n `Failed to extract action type from do() call; raw=\"${trimmedResponse}\"`,\n );\n const actionType = actionMatch[1];\n\n const baseAction = { _metadata: 'do' as const, think: response.think };\n switch (actionType) {\n case 'Tap': {\n const elementMatch = trimmedResponse.match(/element=\\[(\\d+),(\\d+)\\]/);\n if (!elementMatch)\n throw new Error(\n `Failed to extract element coordinates for Tap; raw=\"${trimmedResponse}\"`,\n );\n return {\n ...baseAction,\n action: 'Tap',\n element: [Number(elementMatch[1]), Number(elementMatch[2])],\n } as AutoGLMParsedAction;\n }\n case 'Double Tap': {\n const elementMatch = trimmedResponse.match(/element=\\[(\\d+),(\\d+)\\]/);\n if (!elementMatch)\n throw new Error(\n `Failed to extract element coordinates for Double Tap; raw=\"${trimmedResponse}\"`,\n );\n return {\n ...baseAction,\n action: 'Double Tap',\n element: [Number(elementMatch[1]), Number(elementMatch[2])],\n } as AutoGLMParsedAction;\n }\n case 'Swipe': {\n const startMatch = trimmedResponse.match(/start=\\[(\\d+),(\\d+)\\]/);\n const endMatch = trimmedResponse.match(/end=\\[(\\d+),(\\d+)\\]/);\n if (!startMatch || !endMatch)\n throw new Error(\n `Failed to extract start/end coordinates for Swipe; raw=\"${trimmedResponse}\"`,\n );\n return {\n ...baseAction,\n action: 'Swipe',\n start: [Number(startMatch[1]), Number(startMatch[2])],\n end: [Number(endMatch[1]), Number(endMatch[2])],\n } as AutoGLMParsedAction;\n }\n case 'Long Press': {\n const elementMatch = trimmedResponse.match(/element=\\[(\\d+),(\\d+)\\]/);\n if (!elementMatch)\n throw new Error(\n `Failed to extract element coordinates for Long Press; raw=\"${trimmedResponse}\"`,\n );\n return {\n ...baseAction,\n action: 'Long Press',\n element: [Number(elementMatch[1]), Number(elementMatch[2])],\n } as AutoGLMParsedAction;\n }\n case 'Launch': {\n const app = extractValueAfter(trimmedResponse, 'app=\"');\n return {\n ...baseAction,\n action: 'Launch',\n app,\n } as AutoGLMParsedAction;\n }\n case 'Back': {\n return { ...baseAction, action: 'Back' } as AutoGLMParsedAction;\n }\n case 'Home': {\n return { ...baseAction, action: 'Home' } as AutoGLMParsedAction;\n }\n case 'Wait': {\n const durationMatch = trimmedResponse.match(\n /duration=(?:[\"\\[])?(\\d+)/,\n );\n if (!durationMatch) {\n throw new Error(\n `Failed to extract duration for Wait; raw=\"${trimmedResponse}\"`,\n );\n }\n const seconds = Number.parseInt(durationMatch[1], 10);\n const durationMs = seconds * 1000;\n return {\n ...baseAction,\n action: 'Wait',\n durationMs,\n } as AutoGLMParsedAction;\n }\n case 'Interact': {\n return { ...baseAction, action: 'Interact' } as AutoGLMParsedAction;\n }\n case 'Call_API': {\n const instruction = extractValueAfter(\n trimmedResponse,\n 'instruction=\"',\n );\n return {\n ...baseAction,\n action: 'Call_API',\n instruction,\n } as AutoGLMParsedAction;\n }\n case 'Take_over': {\n const message = extractValueAfter(trimmedResponse, 'message=\"');\n return {\n ...baseAction,\n action: 'Take_over',\n message,\n } as AutoGLMParsedAction;\n }\n case 'Note': {\n const message = extractValueAfter(trimmedResponse, 'message=\"');\n return {\n ...baseAction,\n action: 'Note',\n message,\n } as AutoGLMParsedAction;\n }\n default:\n throw new Error(\n `Unknown action type: ${actionType}; raw=\"${trimmedResponse}\"`,\n );\n }\n }\n throw new Error(`Failed to parse action: ${trimmedResponse}`);\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n throw new Error(\n `Failed to parse action: ${errorMessage}; raw=\"${trimmedResponse}\"`,\n );\n }\n}\n\nexport function parseAutoGLMResponse(content: string): {\n think: string;\n content: string;\n} {\n let parsedResponse: { think: string; content: string };\n\n if (content.includes('finish(message=')) {\n const parts = content.split('finish(message=');\n const think = parts[0].trim();\n const actionContent = `finish(message=${parts[1]}`;\n parsedResponse = { think, content: actionContent };\n } else if (content.includes('do(action=')) {\n const parts = content.split('do(action=');\n const think = parts[0].trim();\n const actionContent = `do(action=${parts[1]}`;\n parsedResponse = { think, content: actionContent };\n } else if (content.includes('<answer>')) {\n const parts = content.split('<answer>');\n const think = parts[0]\n .replace(/<think>/g, '')\n .replace(/<\\/think>/g, '')\n .trim();\n const actionContent = parts[1].replace(/<\\/answer>/g, '').trim();\n parsedResponse = { think, content: actionContent };\n } else {\n parsedResponse = { think: '', content };\n }\n\n debug('autoGLM rawResponse:', content);\n debug('thinking in response:', parsedResponse.think);\n debug('action in response:', parsedResponse.content);\n return parsedResponse;\n}\n\nexport function parseAutoGLMPlanningResponse(content: string): {\n response: ReturnType<typeof parseAutoGLMResponse>;\n action: AutoGLMParsedAction;\n} {\n const response = parseAutoGLMResponse(content);\n const action = parseAutoGLMPlanningAction(response);\n return { response, action };\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","debug","getDebug","extractValueAfter","src","idx","Error","rest","parseAutoGLMPlanningAction","response","trimmedResponse","text","message","actionMatch","actionType","baseAction","elementMatch","Number","startMatch","endMatch","app","durationMatch","seconds","durationMs","instruction","error","errorMessage","String","parseAutoGLMResponse","content","parsedResponse","parts","think","actionContent","parseAutoGLMPlanningResponse","action"],"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;;;;;;;;;;;ACHA,MAAMI,QAAQC,AAAAA,IAAAA,uBAAAA,QAAAA,AAAAA,EAAS;AAIhB,MAAMC,oBAAoB,CAACC,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;AAC5B"}
@@ -24,84 +24,41 @@ var __webpack_require__ = {};
24
24
  var __webpack_exports__ = {};
25
25
  __webpack_require__.r(__webpack_exports__);
26
26
  __webpack_require__.d(__webpack_exports__, {
27
- autoGlmPlanning: ()=>autoGlmPlanning
27
+ createAutoGlmPlanner: ()=>createAutoGlmPlanner
28
28
  });
29
- const external_common_js_namespaceObject = require("../../../common.js");
30
- const logger_namespaceObject = require("@midscene/shared/logger");
31
- const index_js_namespaceObject = require("../../service-caller/index.js");
29
+ const utils_namespaceObject = require("@midscene/shared/utils");
30
+ const index_js_namespaceObject = require("../../shared/model-locate-result/index.js");
32
31
  const external_actions_js_namespaceObject = require("./actions.js");
33
32
  const external_parser_js_namespaceObject = require("./parser.js");
34
- const debug = (0, logger_namespaceObject.getDebug)('auto-glm-planning');
35
- async function autoGlmPlanning(userInstruction, options, getSystemPrompt) {
36
- const { conversationHistory, context, actionContext } = options;
37
- const systemPrompt = getSystemPrompt() + (actionContext ? `<high_priority_knowledge>${actionContext}</high_priority_knowledge>` : '');
38
- const imagePayloadBase64 = context.screenshot.base64;
39
- const userInstructionText = (0, external_common_js_namespaceObject.userPromptToString)(userInstruction);
40
- const referenceImageMessages = options.referenceImageMessages ?? [];
41
- const userInstructionMessage = {
42
- role: 'user',
43
- content: [
44
- {
45
- type: 'text',
46
- text: userInstructionText
47
- }
48
- ]
49
- };
50
- conversationHistory.append({
51
- role: 'user',
52
- content: [
53
- {
54
- type: 'image_url',
55
- image_url: {
56
- url: imagePayloadBase64
57
- }
58
- }
59
- ]
60
- });
61
- const msgs = [
62
- {
63
- role: 'system',
64
- content: systemPrompt
65
- },
66
- userInstructionMessage,
67
- ...referenceImageMessages,
68
- ...conversationHistory.snapshot(1)
69
- ];
70
- const { content: rawResponse, usage, rawChoiceMessage } = await (0, index_js_namespaceObject.callAIWithStringResponse)(msgs, options.modelRuntime, {
71
- abortSignal: options.abortSignal
72
- });
73
- debug('autoGLMPlanning rawResponse:', rawResponse);
74
- let parsedResponse;
75
- let transformedActions;
76
- try {
77
- parsedResponse = (0, external_parser_js_namespaceObject.parseAutoGLMResponse)(rawResponse);
78
- debug('thinking in response:', parsedResponse.think);
79
- debug('action in response:', parsedResponse.content);
80
- const parsedAction = (0, external_parser_js_namespaceObject.parseAction)(parsedResponse);
81
- debug('Parsed action object:', parsedAction);
82
- transformedActions = (0, external_actions_js_namespaceObject.transformAutoGLMAction)(parsedAction, context.shotSize, options.actionSpace);
83
- debug('Transformed actions:', transformedActions);
84
- } catch (parseError) {
85
- const errorMessage = parseError instanceof Error ? parseError.message : String(parseError);
86
- throw new index_js_namespaceObject.AIResponseParseError(`Parse error: ${errorMessage}`, JSON.stringify(rawResponse, void 0, 2), usage, rawChoiceMessage);
87
- }
88
- conversationHistory.append({
89
- role: 'assistant',
90
- content: `<think>${parsedResponse.think}</think><answer>${parsedResponse.content}</answer>`
91
- });
92
- const shouldContinuePlanning = !parsedResponse.content.startsWith('finish(');
33
+ const external_prompt_js_namespaceObject = require("./prompt.js");
34
+ function createAutoGlmPlanner(isMultilingual) {
93
35
  return {
94
- actions: transformedActions,
95
- log: rawResponse,
96
- usage,
97
- shouldContinuePlanning,
98
- rawResponse: JSON.stringify(rawResponse, void 0, 2),
99
- rawChoiceMessage
36
+ messages: {
37
+ systemPromptPlacement: 'system-message',
38
+ buildSystemPrompt: ()=>isMultilingual ? (0, external_prompt_js_namespaceObject.getAutoGLMMultilingualPlanPrompt)() : (0, external_prompt_js_namespaceObject.getAutoGLMChinesePlanPrompt)(),
39
+ historyImageLimit: 1,
40
+ buildAssistantContent: (parsedResponse)=>`<think>${parsedResponse.response.think}</think><answer>${parsedResponse.response.content}</answer>`
41
+ },
42
+ coordinates: {
43
+ shape: 'point',
44
+ order: 'xy',
45
+ normalizedBy: 1000
46
+ },
47
+ parseResponse: (rawResponse)=>(0, external_parser_js_namespaceObject.parseAutoGLMPlanningResponse)(rawResponse),
48
+ transformActions: (parsedResponse, { options, coordinateSystem })=>{
49
+ (0, utils_namespaceObject.assert)(coordinateSystem, 'Auto-GLM planning requires coordinate system');
50
+ return (0, external_actions_js_namespaceObject.transformAutoGLMAction)(parsedResponse.action, {
51
+ actionSpace: options.actionSpace,
52
+ coordinateDistanceToPixels: (0, index_js_namespaceObject.createCoordinateDistanceToPixels)(options.context.shotSize, coordinateSystem)
53
+ });
54
+ },
55
+ shouldContinuePlanning: (parsedResponse)=>'finish' !== parsedResponse.action._metadata,
56
+ buildResponseLog: (_parsedResponse, rawResponse)=>rawResponse
100
57
  };
101
58
  }
102
- exports.autoGlmPlanning = __webpack_exports__.autoGlmPlanning;
59
+ exports.createAutoGlmPlanner = __webpack_exports__.createAutoGlmPlanner;
103
60
  for(var __rspack_i in __webpack_exports__)if (-1 === [
104
- "autoGlmPlanning"
61
+ "createAutoGlmPlanner"
105
62
  ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
106
63
  Object.defineProperty(exports, '__esModule', {
107
64
  value: true
@@ -1 +1 @@
1
- {"version":3,"file":"ai-model/models/auto-glm/planning.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../src/ai-model/models/auto-glm/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 { type TUserPrompt, userPromptToString } from '@/common';\nimport type { PlanningAIResponse } from '@/types';\nimport { getDebug } from '@midscene/shared/logger';\nimport type { ChatCompletionMessageParam } from 'openai/resources/index';\nimport {\n AIResponseParseError,\n callAIWithStringResponse,\n} from '../../service-caller/index';\nimport type { PlanOptions } from '../../workflows/planning/types';\nimport { transformAutoGLMAction } from './actions';\nimport { parseAction, parseAutoGLMResponse } from './parser';\n\nconst debug = getDebug('auto-glm-planning');\n\nexport async function autoGlmPlanning(\n userInstruction: TUserPrompt,\n options: PlanOptions,\n getSystemPrompt: () => string,\n): Promise<PlanningAIResponse> {\n const { conversationHistory, context, actionContext } = options;\n\n const systemPrompt =\n getSystemPrompt() +\n (actionContext\n ? `<high_priority_knowledge>${actionContext}</high_priority_knowledge>`\n : '');\n\n const imagePayloadBase64 = context.screenshot.base64;\n const userInstructionText = userPromptToString(userInstruction);\n const referenceImageMessages = options.referenceImageMessages ?? [];\n\n const userInstructionMessage: ChatCompletionMessageParam = {\n role: 'user',\n content: [{ type: 'text', text: userInstructionText }],\n };\n conversationHistory.append({\n role: 'user',\n content: [{ type: 'image_url', image_url: { url: imagePayloadBase64 } }],\n });\n\n const msgs: ChatCompletionMessageParam[] = [\n { role: 'system', content: systemPrompt },\n userInstructionMessage,\n ...referenceImageMessages,\n ...conversationHistory.snapshot(1),\n ];\n\n const {\n content: rawResponse,\n usage,\n rawChoiceMessage,\n } = await callAIWithStringResponse(msgs, options.modelRuntime, {\n abortSignal: options.abortSignal,\n });\n\n debug('autoGLMPlanning rawResponse:', rawResponse);\n\n let parsedResponse: ReturnType<typeof parseAutoGLMResponse>;\n let transformedActions: ReturnType<typeof transformAutoGLMAction>;\n\n try {\n parsedResponse = parseAutoGLMResponse(rawResponse);\n debug('thinking in response:', parsedResponse.think);\n debug('action in response:', parsedResponse.content);\n\n const parsedAction = parseAction(parsedResponse);\n debug('Parsed action object:', parsedAction);\n transformedActions = transformAutoGLMAction(\n parsedAction,\n context.shotSize,\n options.actionSpace,\n );\n debug('Transformed actions:', transformedActions);\n } catch (parseError) {\n // Throw AIResponseParseError with usage and rawResponse preserved\n const errorMessage =\n parseError instanceof Error ? parseError.message : String(parseError);\n throw new AIResponseParseError(\n `Parse error: ${errorMessage}`,\n JSON.stringify(rawResponse, undefined, 2),\n usage,\n rawChoiceMessage,\n );\n }\n\n conversationHistory.append({\n role: 'assistant',\n content: `<think>${parsedResponse.think}</think><answer>${parsedResponse.content}</answer>`,\n });\n\n const shouldContinuePlanning = !parsedResponse.content.startsWith('finish(');\n\n return {\n actions: transformedActions,\n log: rawResponse,\n usage,\n shouldContinuePlanning,\n rawResponse: JSON.stringify(rawResponse, undefined, 2),\n rawChoiceMessage,\n };\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","debug","getDebug","autoGlmPlanning","userInstruction","options","getSystemPrompt","conversationHistory","context","actionContext","systemPrompt","imagePayloadBase64","userInstructionText","userPromptToString","referenceImageMessages","userInstructionMessage","msgs","rawResponse","usage","rawChoiceMessage","callAIWithStringResponse","parsedResponse","transformedActions","parseAutoGLMResponse","parsedAction","parseAction","transformAutoGLMAction","parseError","errorMessage","Error","String","AIResponseParseError","JSON","undefined","shouldContinuePlanning"],"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;;;;;;;;;;;;ACMA,MAAMI,QAAQC,AAAA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BuB;QAC/BF,qBAAqBI,AAAAA,IAAAA,oCAAAA,sBAAAA,AAAAA,EACnBF,cACAhB,QAAQ,QAAQ,EAChBH,QAAQ,WAAW;QAErBJ,MAAM,wBAAwBqB;IAChC,EAAE,OAAOK,YAAY;QAEnB,MAAMC,eACJD,sBAAsBE,QAAQF,WAAW,OAAO,GAAGG,OAAOH;QAC5D,MAAM,IAAII,yBAAAA,oBAAoBA,CAC5B,CAAC,aAAa,EAAEH,cAAc,EAC9BI,KAAK,SAAS,CAACf,aAAagB,QAAW,IACvCf,OACAC;IAEJ;IAEAZ,oBAAoB,MAAM,CAAC;QACzB,MAAM;QACN,SAAS,CAAC,OAAO,EAAEc,eAAe,KAAK,CAAC,gBAAgB,EAAEA,eAAe,OAAO,CAAC,SAAS,CAAC;IAC7F;IAEA,MAAMa,yBAAyB,CAACb,eAAe,OAAO,CAAC,UAAU,CAAC;IAElE,OAAO;QACL,SAASC;QACT,KAAKL;QACLC;QACAgB;QACA,aAAaF,KAAK,SAAS,CAACf,aAAagB,QAAW;QACpDd;IACF;AACF"}
1
+ {"version":3,"file":"ai-model/models/auto-glm/planning.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../../src/ai-model/models/auto-glm/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 { assert } from '@midscene/shared/utils';\nimport type { CustomPlanningDefinition } from '../../model-adapter/custom-planning-types';\nimport { createCoordinateDistanceToPixels } from '../../shared/model-locate-result';\nimport { transformAutoGLMAction } from './actions';\nimport { parseAutoGLMPlanningResponse } from './parser';\nimport {\n getAutoGLMChinesePlanPrompt,\n getAutoGLMMultilingualPlanPrompt,\n} from './prompt';\n\ntype AutoGLMParsedResponse = ReturnType<typeof parseAutoGLMPlanningResponse>;\n\nexport function createAutoGlmPlanner(\n isMultilingual: boolean,\n): CustomPlanningDefinition<AutoGLMParsedResponse> {\n return {\n messages: {\n systemPromptPlacement: 'system-message',\n buildSystemPrompt: () =>\n isMultilingual\n ? getAutoGLMMultilingualPlanPrompt()\n : getAutoGLMChinesePlanPrompt(),\n historyImageLimit: 1,\n buildAssistantContent: (parsedResponse) =>\n `<think>${parsedResponse.response.think}</think><answer>${parsedResponse.response.content}</answer>`,\n },\n coordinates: {\n shape: 'point',\n order: 'xy',\n normalizedBy: 1000,\n },\n parseResponse: (rawResponse) => {\n return parseAutoGLMPlanningResponse(rawResponse);\n },\n transformActions: (parsedResponse, { options, coordinateSystem }) => {\n assert(coordinateSystem, 'Auto-GLM planning requires coordinate system');\n return transformAutoGLMAction(parsedResponse.action, {\n actionSpace: options.actionSpace,\n coordinateDistanceToPixels: createCoordinateDistanceToPixels(\n options.context.shotSize,\n coordinateSystem,\n ),\n });\n },\n shouldContinuePlanning: (parsedResponse) =>\n parsedResponse.action._metadata !== 'finish',\n buildResponseLog: (_parsedResponse, rawResponse) => rawResponse,\n };\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","createAutoGlmPlanner","isMultilingual","getAutoGLMMultilingualPlanPrompt","getAutoGLMChinesePlanPrompt","parsedResponse","rawResponse","parseAutoGLMPlanningResponse","options","coordinateSystem","assert","transformAutoGLMAction","createCoordinateDistanceToPixels","_parsedResponse"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB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F;QACA,wBAAwB,CAACJ,iBACvBA,AAAoC,aAApCA,eAAe,MAAM,CAAC,SAAS;QACjC,kBAAkB,CAACQ,iBAAiBP,cAAgBA;IACtD;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"ai-model/models/default.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/ai-model/models/default.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 { ModelAdapterDefinition } from './types';\n\nexport const defaultOpenAICompatibleAdapterConfig: ModelAdapterDefinition = {\n chatCompletion: {\n unsupportedUserConfig: [\n 'reasoningEnabled',\n 'reasoningEffort',\n 'reasoningBudget',\n ],\n },\n};\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","defaultOpenAICompatibleAdapterConfig"],"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,MAAMI,uCAA+D;IAC1E,gBAAgB;QACd,uBAAuB;YACrB;YACA;YACA;SACD;IACH;AACF"}
1
+ {"version":3,"file":"ai-model/models/default.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/ai-model/models/default.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 { ModelAdapterDefinition } from '../model-adapter/types';\n\nexport const defaultOpenAICompatibleAdapterConfig: ModelAdapterDefinition = {\n chatCompletion: {\n unsupportedUserConfig: [\n 'reasoningEnabled',\n 'reasoningEffort',\n 'reasoningBudget',\n ],\n },\n};\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","defaultOpenAICompatibleAdapterConfig"],"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,MAAMI,uCAA+D;IAC1E,gBAAgB;QACd,uBAAuB;YACrB;YACA;YACA;SACD;IACH;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"ai-model/models/doubao.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/ai-model/models/doubao.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 { assert } from '@midscene/shared/utils';\nimport { jsonrepair } from 'jsonrepair';\nimport {\n extractJSONFromCodeBlock,\n safeParseJson,\n} from '../service-caller/json';\nimport {\n type LocateResultValue,\n unwrapCoordinateListLikeInput,\n} from '../shared/model-locate-result';\nimport type {\n ChatCompletionCallContext,\n ChatCompletionParamsResult,\n JsonParserContext,\n JsonParserSource,\n ModelAdapterDefinition,\n} from './types';\n\nexport function normalizeDoubaoJsonObject(\n obj: any,\n context: Pick<JsonParserContext, 'preserveStringValueKeys'> = {},\n): any {\n if (obj === null || obj === undefined) {\n return obj;\n }\n\n if (Array.isArray(obj)) {\n return obj.map((item) => normalizeDoubaoJsonObject(item, context));\n }\n\n if (typeof obj === 'object') {\n const normalized: any = {};\n for (const [key, value] of Object.entries(obj)) {\n const trimmedKey = key.trim();\n const preserveStringValue =\n context.preserveStringValueKeys?.includes(trimmedKey) ?? false;\n const normalizedValue =\n typeof value === 'string'\n ? preserveStringValue\n ? value\n : value.trim()\n : normalizeDoubaoJsonObject(value, context);\n normalized[trimmedKey] = normalizedValue;\n }\n return normalized;\n }\n\n return typeof obj === 'string' ? obj.trim() : obj;\n}\n\nexport function shouldRepairDoubaoLocateJson(source: JsonParserSource) {\n return (\n source === 'locate' ||\n source === 'section-locator' ||\n source === 'planning-action-param'\n );\n}\n\nexport function preprocessDoubaoLocateJson(input: string) {\n if (input.includes('bbox')) {\n while (/\\d+\\s+\\d+/.test(input)) {\n input = input.replace(/(\\d+)\\s+(\\d+)/g, '$1,$2');\n }\n }\n return input;\n}\n\nconst doubaoJsonParser: ModelAdapterDefinition['jsonParser'] = (\n raw,\n context = { source: 'generic-object' },\n) => {\n const { source } = context;\n try {\n return safeParseJson(raw, context);\n } catch (firstError) {\n if (!shouldRepairDoubaoLocateJson(source)) {\n throw firstError;\n }\n\n const jsonString = preprocessDoubaoLocateJson(\n extractJSONFromCodeBlock(raw),\n );\n try {\n return normalizeDoubaoJsonObject(\n JSON.parse(jsonrepair(jsonString)),\n context,\n );\n } catch (error) {\n throw Error(\n `failed to parse LLM response into JSON. Error - ${String(\n error ?? firstError ?? 'unknown error',\n )}. Response - \\n ${raw}`,\n );\n }\n }\n};\n\nexport function parseDoubaoRawLocateValue(input: unknown): LocateResultValue {\n const bbox = unwrapCoordinateListLikeInput(input as any);\n if (typeof bbox === 'string') {\n assert(\n /^(\\d+)\\s(\\d+)\\s(\\d+)\\s(\\d+)$/.test(bbox.trim()),\n `invalid bbox data string for doubao-vision mode: ${bbox}`,\n );\n const splitted = bbox.split(' ');\n if (splitted.length === 4) {\n return {\n type: 'bbox',\n coordinates: [\n Number(splitted[0]),\n Number(splitted[1]),\n Number(splitted[2]),\n Number(splitted[3]),\n ],\n };\n }\n throw new Error(`invalid bbox data string for doubao-vision mode: ${bbox}`);\n }\n\n let bboxList: number[] = [];\n if (Array.isArray(bbox) && typeof bbox[0] === 'string') {\n bbox.forEach((item) => {\n if (typeof item === 'string' && item.includes(',')) {\n const [x, y] = item.split(',');\n bboxList.push(Number(x.trim()), Number(y.trim()));\n } else if (typeof item === 'string' && item.includes(' ')) {\n const [x, y] = item.split(' ');\n bboxList.push(Number(x.trim()), Number(y.trim()));\n } else {\n bboxList.push(Number(item));\n }\n });\n } else {\n bboxList = bbox as number[];\n }\n\n if (bboxList.length === 4 || bboxList.length === 5) {\n return {\n type: 'bbox',\n coordinates: [bboxList[0], bboxList[1], bboxList[2], bboxList[3]],\n };\n }\n\n if (\n bboxList.length === 6 ||\n bboxList.length === 2 ||\n bboxList.length === 3 ||\n bboxList.length === 7\n ) {\n return { type: 'point', coordinates: [bboxList[0], bboxList[1]] };\n }\n\n if (bbox.length === 8) {\n return {\n type: 'bbox',\n coordinates: [bboxList[0], bboxList[1], bboxList[4], bboxList[5]],\n };\n }\n\n const msg = `invalid bbox data for doubao-vision mode: ${JSON.stringify(bbox)} `;\n throw new Error(msg);\n}\n\nconst buildDoubaoChatCompletionParams = (\n input: ChatCompletionCallContext,\n): ChatCompletionParamsResult => {\n const { midsceneDefaults, userConfig } = input;\n const { reasoningEnabled, reasoningEffort } = userConfig;\n const commonOverrideConfig: Record<string, unknown> = {};\n\n if (userConfig.temperature !== undefined) {\n commonOverrideConfig.temperature = userConfig.temperature;\n }\n\n const modelSpecificConfig: Record<string, unknown> = {};\n\n if (reasoningEnabled !== 'default') {\n modelSpecificConfig.thinking = {\n type: (reasoningEnabled ?? false) ? 'enabled' : 'disabled',\n };\n if (reasoningEffort) {\n modelSpecificConfig.reasoning_effort = reasoningEffort;\n }\n }\n\n return {\n config: {\n ...midsceneDefaults,\n ...commonOverrideConfig,\n ...modelSpecificConfig,\n },\n };\n};\n\nconst doubaoVisionAdapter: ModelAdapterDefinition = {\n jsonParser: doubaoJsonParser,\n chatCompletion: {\n unsupportedUserConfig: ['reasoningBudget'],\n buildChatCompletionParams: buildDoubaoChatCompletionParams,\n },\n locate: {\n resultAdapter: {\n coordinates: { shape: 'bbox', order: 'xy', normalizedBy: 1000 },\n parseRawLocateValue: parseDoubaoRawLocateValue,\n },\n },\n};\n\nexport const doubaoAdapters = {\n 'doubao-vision': doubaoVisionAdapter,\n 'doubao-seed': doubaoVisionAdapter,\n} satisfies Pick<\n Record<TModelFamily, ModelAdapterDefinition>,\n 'doubao-vision' | 'doubao-seed'\n>;\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","normalizeDoubaoJsonObject","context","Array","item","normalized","value","trimmedKey","preserveStringValue","normalizedValue","shouldRepairDoubaoLocateJson","source","preprocessDoubaoLocateJson","input","doubaoJsonParser","raw","safeParseJson","firstError","jsonString","extractJSONFromCodeBlock","JSON","jsonrepair","error","Error","String","parseDoubaoRawLocateValue","bbox","unwrapCoordinateListLikeInput","assert","splitted","Number","bboxList","x","y","msg","buildDoubaoChatCompletionParams","midsceneDefaults","userConfig","reasoningEnabled","reasoningEffort","commonOverrideConfig","undefined","modelSpecificConfig","doubaoVisionAdapter","doubaoAdapters"],"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,oBA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GxB;IACzC,MAAM,EAAEyB,gBAAgB,EAAEC,eAAe,EAAE,GAAGF;IAC9C,MAAMG,uBAAgD,CAAC;IAEvD,IAAIH,AAA2BI,WAA3BJ,WAAW,WAAW,EACxBG,qBAAqB,WAAW,GAAGH,WAAW,WAAW;IAG3D,MAAMK,sBAA+C,CAAC;IAEtD,IAAIJ,AAAqB,cAArBA,kBAAgC;QAClCI,oBAAoB,QAAQ,GAAG;YAC7B,MAAOJ,oBAAoB,QAAS,YAAY;QAClD;QACA,IAAIC,iBACFG,oBAAoB,gBAAgB,GAAGH;IAE3C;IAEA,OAAO;QACL,QAAQ;YACN,GAAGH,gBAAgB;YACnB,GAAGI,oBAAoB;YACvB,GAAGE,mBAAmB;QACxB;IACF;AACF;AAEA,MAAMC,sBAA8C;IAClD,YAAY7B;IACZ,gBAAgB;QACd,uBAAuB;YAAC;SAAkB;QAC1C,2BAA2BqB;IAC7B;IACA,QAAQ;QACN,eAAe;YACb,aAAa;gBAAE,OAAO;gBAAQ,OAAO;gBAAM,cAAc;YAAK;YAC9D,qBAAqBV;QACvB;IACF;AACF;AAEO,MAAMmB,iBAAiB;IAC5B,iBAAiBD;IACjB,eAAeA;AACjB"}
1
+ {"version":3,"file":"ai-model/models/doubao.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/ai-model/models/doubao.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 { assert } from '@midscene/shared/utils';\nimport { jsonrepair } from 'jsonrepair';\nimport type {\n ChatCompletionCallContext,\n ChatCompletionParamsResult,\n JsonParserContext,\n JsonParserSource,\n ModelAdapterDefinition,\n} from '../model-adapter/types';\nimport {\n extractJSONFromCodeBlock,\n safeParseJson,\n} from '../service-caller/json';\nimport {\n type LocateResultValue,\n unwrapCoordinateListLikeInput,\n} from '../shared/model-locate-result';\n\nexport function normalizeDoubaoJsonObject(\n obj: any,\n context: Pick<JsonParserContext, 'preserveStringValueKeys'> = {},\n): any {\n if (obj === null || obj === undefined) {\n return obj;\n }\n\n if (Array.isArray(obj)) {\n return obj.map((item) => normalizeDoubaoJsonObject(item, context));\n }\n\n if (typeof obj === 'object') {\n const normalized: any = {};\n for (const [key, value] of Object.entries(obj)) {\n const trimmedKey = key.trim();\n const preserveStringValue =\n context.preserveStringValueKeys?.includes(trimmedKey) ?? false;\n const normalizedValue =\n typeof value === 'string'\n ? preserveStringValue\n ? value\n : value.trim()\n : normalizeDoubaoJsonObject(value, context);\n normalized[trimmedKey] = normalizedValue;\n }\n return normalized;\n }\n\n return typeof obj === 'string' ? obj.trim() : obj;\n}\n\nexport function shouldRepairDoubaoLocateJson(source: JsonParserSource) {\n return (\n source === 'locate' ||\n source === 'section-locator' ||\n source === 'planning-action-param'\n );\n}\n\nexport function preprocessDoubaoLocateJson(input: string) {\n if (input.includes('bbox')) {\n while (/\\d+\\s+\\d+/.test(input)) {\n input = input.replace(/(\\d+)\\s+(\\d+)/g, '$1,$2');\n }\n }\n return input;\n}\n\nconst doubaoJsonParser: ModelAdapterDefinition['jsonParser'] = (\n raw,\n context = { source: 'generic-object' },\n) => {\n const { source } = context;\n try {\n return safeParseJson(raw, context);\n } catch (firstError) {\n if (!shouldRepairDoubaoLocateJson(source)) {\n throw firstError;\n }\n\n const jsonString = preprocessDoubaoLocateJson(\n extractJSONFromCodeBlock(raw),\n );\n try {\n return normalizeDoubaoJsonObject(\n JSON.parse(jsonrepair(jsonString)),\n context,\n );\n } catch (error) {\n throw Error(\n `failed to parse LLM response into JSON. Error - ${String(\n error ?? firstError ?? 'unknown error',\n )}. Response - \\n ${raw}`,\n );\n }\n }\n};\n\nexport function parseDoubaoRawLocateValue(input: unknown): LocateResultValue {\n const bbox = unwrapCoordinateListLikeInput(input as any);\n if (typeof bbox === 'string') {\n assert(\n /^(\\d+)\\s(\\d+)\\s(\\d+)\\s(\\d+)$/.test(bbox.trim()),\n `invalid bbox data string for doubao-vision mode: ${bbox}`,\n );\n const splitted = bbox.split(' ');\n if (splitted.length === 4) {\n return {\n type: 'bbox',\n coordinates: [\n Number(splitted[0]),\n Number(splitted[1]),\n Number(splitted[2]),\n Number(splitted[3]),\n ],\n };\n }\n throw new Error(`invalid bbox data string for doubao-vision mode: ${bbox}`);\n }\n\n let bboxList: number[] = [];\n if (Array.isArray(bbox) && typeof bbox[0] === 'string') {\n bbox.forEach((item) => {\n if (typeof item === 'string' && item.includes(',')) {\n const [x, y] = item.split(',');\n bboxList.push(Number(x.trim()), Number(y.trim()));\n } else if (typeof item === 'string' && item.includes(' ')) {\n const [x, y] = item.split(' ');\n bboxList.push(Number(x.trim()), Number(y.trim()));\n } else {\n bboxList.push(Number(item));\n }\n });\n } else {\n bboxList = bbox as number[];\n }\n\n if (bboxList.length === 4 || bboxList.length === 5) {\n return {\n type: 'bbox',\n coordinates: [bboxList[0], bboxList[1], bboxList[2], bboxList[3]],\n };\n }\n\n if (\n bboxList.length === 6 ||\n bboxList.length === 2 ||\n bboxList.length === 3 ||\n bboxList.length === 7\n ) {\n return { type: 'point', coordinates: [bboxList[0], bboxList[1]] };\n }\n\n if (bbox.length === 8) {\n return {\n type: 'bbox',\n coordinates: [bboxList[0], bboxList[1], bboxList[4], bboxList[5]],\n };\n }\n\n const msg = `invalid bbox data for doubao-vision mode: ${JSON.stringify(bbox)} `;\n throw new Error(msg);\n}\n\nconst buildDoubaoChatCompletionParams = (\n input: ChatCompletionCallContext,\n): ChatCompletionParamsResult => {\n const { midsceneDefaults, userConfig } = input;\n const { reasoningEnabled, reasoningEffort } = userConfig;\n const commonOverrideConfig: Record<string, unknown> = {};\n\n if (userConfig.temperature !== undefined) {\n commonOverrideConfig.temperature = userConfig.temperature;\n }\n\n const modelSpecificConfig: Record<string, unknown> = {};\n\n if (reasoningEnabled !== 'default') {\n modelSpecificConfig.thinking = {\n type: (reasoningEnabled ?? false) ? 'enabled' : 'disabled',\n };\n if (reasoningEffort) {\n modelSpecificConfig.reasoning_effort = reasoningEffort;\n }\n }\n\n return {\n config: {\n ...midsceneDefaults,\n ...commonOverrideConfig,\n ...modelSpecificConfig,\n },\n };\n};\n\nconst doubaoVisionAdapter: ModelAdapterDefinition = {\n jsonParser: doubaoJsonParser,\n chatCompletion: {\n unsupportedUserConfig: ['reasoningBudget'],\n buildChatCompletionParams: buildDoubaoChatCompletionParams,\n },\n locate: {\n resultAdapter: {\n coordinates: { shape: 'bbox', order: 'xy', normalizedBy: 1000 },\n parseRawLocateValue: parseDoubaoRawLocateValue,\n },\n },\n};\n\nexport const doubaoAdapters = {\n 'doubao-vision': doubaoVisionAdapter,\n 'doubao-seed': doubaoVisionAdapter,\n} satisfies Pick<\n Record<TModelFamily, ModelAdapterDefinition>,\n 'doubao-vision' | 'doubao-seed'\n>;\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","normalizeDoubaoJsonObject","context","Array","item","normalized","value","trimmedKey","preserveStringValue","normalizedValue","shouldRepairDoubaoLocateJson","source","preprocessDoubaoLocateJson","input","doubaoJsonParser","raw","safeParseJson","firstError","jsonString","extractJSONFromCodeBlock","JSON","jsonrepair","error","Error","String","parseDoubaoRawLocateValue","bbox","unwrapCoordinateListLikeInput","assert","splitted","Number","bboxList","x","y","msg","buildDoubaoChatCompletionParams","midsceneDefaults","userConfig","reasoningEnabled","reasoningEffort","commonOverrideConfig","undefined","modelSpecificConfig","doubaoVisionAdapter","doubaoAdapters"],"mappings":";;;IAAAA,oBA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,EACb,OAAO;QACL,MAAM;QACN,aAAa;YAACK,QAAQ,CAAC,EAAE;YAAEA,QAAQ,CAAC,EAAE;YAAEA,QAAQ,CAAC,EAAE;YAAEA,QAAQ,CAAC,EAAE;SAAC;IACnE;IAGF,MAAMG,MAAM,CAAC,0CAA0C,EAAEd,KAAK,SAAS,CAACM,MAAM,CAAC,CAAC;IAChF,MAAM,IAAIH,MAAMW;AAClB;AAEA,MAAMC,kCAAkC,CACtCtB;IAEA,MAAM,EAAEuB,gBAAgB,EAAEC,UAAU,EAAE,GAAGxB;IACzC,MAAM,EAAEyB,gBAAgB,EAAEC,eAAe,EAAE,GAAGF;IAC9C,MAAMG,uBAAgD,CAAC;IAEvD,IAAIH,AAA2BI,WAA3BJ,WAAW,WAAW,EACxBG,qBAAqB,WAAW,GAAGH,WAAW,WAAW;IAG3D,MAAMK,sBAA+C,CAAC;IAEtD,IAAIJ,AAAqB,cAArBA,kBAAgC;QAClCI,oBAAoB,QAAQ,GAAG;YAC7B,MAAOJ,oBAAoB,QAAS,YAAY;QAClD;QACA,IAAIC,iBACFG,oBAAoB,gBAAgB,GAAGH;IAE3C;IAEA,OAAO;QACL,QAAQ;YACN,GAAGH,gBAAgB;YACnB,GAAGI,oBAAoB;YACvB,GAAGE,mBAAmB;QACxB;IACF;AACF;AAEA,MAAMC,sBAA8C;IAClD,YAAY7B;IACZ,gBAAgB;QACd,uBAAuB;YAAC;SAAkB;QAC1C,2BAA2BqB;IAC7B;IACA,QAAQ;QACN,eAAe;YACb,aAAa;gBAAE,OAAO;gBAAQ,OAAO;gBAAM,cAAc;YAAK;YAC9D,qBAAqBV;QACvB;IACF;AACF;AAEO,MAAMmB,iBAAiB;IAC5B,iBAAiBD;IACjB,eAAeA;AACjB"}
@@ -27,7 +27,7 @@ __webpack_require__.d(__webpack_exports__, {
27
27
  extractGeminiContentAndReasoning: ()=>extractGeminiContentAndReasoning,
28
28
  geminiAdapters: ()=>geminiAdapters
29
29
  });
30
- const external_chat_content_js_namespaceObject = require("./chat-content.js");
30
+ const chat_completion_js_namespaceObject = require("../model-adapter/chat-completion.js");
31
31
  const buildGeminiChatCompletionParams = (input)=>{
32
32
  const { midsceneDefaults, userConfig, intent } = input;
33
33
  const { reasoningEnabled, reasoningEffort } = userConfig;
@@ -100,7 +100,7 @@ const extractGeminiContentAndReasoning = (message)=>{
100
100
  })
101
101
  };
102
102
  }
103
- const result = (0, external_chat_content_js_namespaceObject.defaultExtractContentAndReasoning)(message);
103
+ const result = (0, chat_completion_js_namespaceObject.defaultExtractContentAndReasoning)(message);
104
104
  const geminiReasoningContent = extractInlineThought(result.content) || '';
105
105
  return {
106
106
  content: result.content,
@@ -1 +1 @@
1
- {"version":3,"file":"ai-model/models/gemini.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/ai-model/models/gemini.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 type OpenAI from 'openai';\nimport { defaultExtractContentAndReasoning } from './chat-content';\nimport type {\n ChatCompletionCallContext,\n ChatCompletionContentSource,\n ChatCompletionParamsResult,\n ContentAndReasoning,\n ModelAdapterDefinition,\n} from './types';\n\ntype GeminiContentPart = Record<string, unknown> & {\n text?: string;\n thought?: boolean;\n};\n\ntype GeminiContentExtension = {\n content: string | null | GeminiContentPart[];\n reasoning_content?: string;\n extra_content?: unknown;\n};\n\ntype GeminiContentSource =\n | ChatCompletionContentSource\n | (Omit<OpenAI.Chat.Completions.ChatCompletionMessage, 'content'> &\n GeminiContentExtension)\n | (Omit<OpenAI.Chat.Completions.ChatCompletionChunk.Choice.Delta, 'content'> &\n GeminiContentExtension);\n\nconst buildGeminiChatCompletionParams = (\n input: ChatCompletionCallContext,\n): ChatCompletionParamsResult => {\n const { midsceneDefaults, userConfig, intent } = input;\n const { reasoningEnabled, reasoningEffort } = userConfig;\n const commonOverrideConfig: Record<string, unknown> = {};\n\n if (userConfig.temperature !== undefined) {\n commonOverrideConfig.temperature = userConfig.temperature;\n }\n\n const modelSpecificConfig: {\n extra_body?: {\n google?: {\n thinking_config: Record<string, unknown>;\n };\n };\n reasoning_effort?: unknown;\n } = {};\n\n if (reasoningEnabled !== 'default') {\n if (reasoningEffort) {\n modelSpecificConfig.extra_body = {\n google: {\n thinking_config: {\n thinking_level: reasoningEffort,\n include_thoughts: true,\n },\n },\n };\n } else {\n if (intent === 'insight') {\n modelSpecificConfig.extra_body = {\n google: {\n thinking_config: {\n // In real Gemini tests, insight calls need `include_thoughts` to get\n // the model's thinking, and Gemini puts that thinking into `content`.\n include_thoughts: true,\n },\n },\n };\n }\n\n // Gemini 3.x cannot fully disable native thinking, so use the lowest\n // supported effort unless the user explicitly requests another level.\n modelSpecificConfig.reasoning_effort = 'minimal';\n }\n }\n\n return {\n config: {\n ...midsceneDefaults,\n ...commonOverrideConfig,\n ...modelSpecificConfig,\n },\n };\n};\n\nconst extractInlineThought = (content: string): string | undefined => {\n const match = content.match(/<thought>([\\s\\S]*?)<\\/thought>/i);\n return match?.[1]?.trim() || undefined;\n};\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return !!value && typeof value === 'object' && !Array.isArray(value);\n}\n\ntype GeminiExtractedContent = {\n content: string;\n geminiReasoningContent: string;\n};\n\nconst formatReasoningContent = ({\n geminiReasoningContent,\n providerReasoningContent,\n}: {\n geminiReasoningContent: string;\n providerReasoningContent: string;\n}): string => {\n if (geminiReasoningContent && providerReasoningContent) {\n return `thoughtParts:${geminiReasoningContent}; reasoning_content:${providerReasoningContent}`;\n }\n\n return geminiReasoningContent || providerReasoningContent || '';\n};\n\nconst extractGeminiThoughtParts = (\n content: GeminiContentPart[],\n): GeminiExtractedContent => {\n const contentParts: string[] = [];\n const reasoningParts: string[] = [];\n\n for (const part of content) {\n if (!isRecord(part)) {\n continue;\n }\n\n const text = typeof part.text === 'string' ? part.text : undefined;\n if (!text) {\n continue;\n }\n\n if (part.thought === true) {\n reasoningParts.push(text);\n } else {\n contentParts.push(text);\n }\n }\n\n return {\n content: contentParts.join(''),\n geminiReasoningContent: reasoningParts.join(''),\n };\n};\n\nexport const extractGeminiContentAndReasoning = (\n message: GeminiContentSource | undefined,\n): ContentAndReasoning => {\n // Gemini native API exposes thought summaries in\n // `response.candidates[0].content.parts`, where each text part can carry\n // `thought: true`. Some OpenAI-compatible adapters may pass through a\n // native-like content-parts shape, even though the Gemini OpenAI\n // compatibility docs do not guarantee it.\n // Docs: https://ai.google.dev/gemini-api/docs/thinking#thought-summaries\n\n if (!message) {\n return {\n content: '',\n reasoning_content: '',\n };\n }\n\n if (Array.isArray(message.content)) {\n const extracted = extractGeminiThoughtParts(message.content);\n\n return {\n content: extracted.content,\n reasoning_content: formatReasoningContent({\n geminiReasoningContent: extracted.geminiReasoningContent,\n providerReasoningContent:\n typeof message.reasoning_content === 'string'\n ? message.reasoning_content\n : '',\n }),\n };\n }\n\n const result = defaultExtractContentAndReasoning(\n message as ChatCompletionContentSource,\n );\n // In real Gemini OpenAI-compatible responses we observed that\n // `include_thoughts` can still return a plain string `message.content`,\n // with the thought summary prepended as `<thought>...</thought>` before the\n // visible answer. Keep content unchanged, but extract that leading thought\n // text for report display.\n const geminiReasoningContent = extractInlineThought(result.content) || '';\n\n return {\n content: result.content,\n reasoning_content: formatReasoningContent({\n geminiReasoningContent,\n providerReasoningContent: result.reasoning_content,\n }),\n };\n};\n\nexport const geminiAdapters = {\n gemini: {\n chatCompletion: {\n unsupportedUserConfig: ['reasoningEnabled', 'reasoningBudget'],\n buildChatCompletionParams: buildGeminiChatCompletionParams,\n extractContentAndReasoning: extractGeminiContentAndReasoning,\n },\n locate: {\n resultAdapter: {\n coordinates: { shape: 'bbox', order: 'yx', normalizedBy: 1000 },\n },\n },\n },\n} satisfies Pick<Record<TModelFamily, ModelAdapterDefinition>, 'gemini'>;\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","buildGeminiChatCompletionParams","input","midsceneDefaults","userConfig","intent","reasoningEnabled","reasoningEffort","commonOverrideConfig","undefined","modelSpecificConfig","extractInlineThought","content","match","isRecord","value","Array","formatReasoningContent","geminiReasoningContent","providerReasoningContent","extractGeminiThoughtParts","contentParts","reasoningParts","part","text","extractGeminiContentAndReasoning","message","extracted","result","defaultExtractContentAndReasoning","geminiAdapters"],"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;;;;;;;;;ACuBA,MAAMI,kCAAkC,CACtCC;IAEA,MAAM,EAAEC,gBAAgB,EAAEC,UAAU,EAAEC,MAAM,EAAE,GAAGH;IACjD,MAAM,EAAEI,gBAAgB,EAAEC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e,MAIL,IAAID,AAAiB,SAAjBA,KAAK,OAAO,EACdD,eAAe,IAAI,CAACE;aAEpBH,aAAa,IAAI,CAACG;IAEtB;IAEA,OAAO;QACL,SAASH,aAAa,IAAI,CAAC;QAC3B,wBAAwBC,eAAe,IAAI,CAAC;IAC9C;AACF;AAEO,MAAMG,mCAAmC,CAC9CC;IASA,IAAI,CAACA,SACH,OAAO;QACL,SAAS;QACT,mBAAmB;IACrB;IAGF,IAAIV,MAAM,OAAO,CAACU,QAAQ,OAAO,GAAG;QAClC,MAAMC,YAAYP,0BAA0BM,QAAQ,OAAO;QAE3D,OAAO;YACL,SAASC,UAAU,OAAO;YAC1B,mBAAmBV,uBAAuB;gBACxC,wBAAwBU,UAAU,sBAAsB;gBACxD,0BACE,AAAqC,YAArC,OAAOD,QAAQ,iBAAiB,GAC5BA,QAAQ,iBAAiB,GACzB;YACR;QACF;IACF;IAEA,MAAME,SAASC,AAAAA,IAAAA,yCAAAA,iCAAAA,AAAAA,EACbH;IAOF,MAAMR,yBAAyBP,qBAAqBiB,OAAO,OAAO,KAAK;IAEvE,OAAO;QACL,SAASA,OAAO,OAAO;QACvB,mBAAmBX,uBAAuB;YACxCC;YACA,0BAA0BU,OAAO,iBAAiB;QACpD;IACF;AACF;AAEO,MAAME,iBAAiB;IAC5B,QAAQ;QACN,gBAAgB;YACd,uBAAuB;gBAAC;gBAAoB;aAAkB;YAC9D,2BAA2B7B;YAC3B,4BAA4BwB;QAC9B;QACA,QAAQ;YACN,eAAe;gBACb,aAAa;oBAAE,OAAO;oBAAQ,OAAO;oBAAM,cAAc;gBAAK;YAChE;QACF;IACF;AACF"}
1
+ {"version":3,"file":"ai-model/models/gemini.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/ai-model/models/gemini.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 type OpenAI from 'openai';\nimport { defaultExtractContentAndReasoning } from '../model-adapter/chat-completion';\nimport type {\n ChatCompletionCallContext,\n ChatCompletionContentSource,\n ChatCompletionParamsResult,\n ContentAndReasoning,\n ModelAdapterDefinition,\n} from '../model-adapter/types';\n\ntype GeminiContentPart = Record<string, unknown> & {\n text?: string;\n thought?: boolean;\n};\n\ntype GeminiContentExtension = {\n content: string | null | GeminiContentPart[];\n reasoning_content?: string;\n extra_content?: unknown;\n};\n\ntype GeminiContentSource =\n | ChatCompletionContentSource\n | (Omit<OpenAI.Chat.Completions.ChatCompletionMessage, 'content'> &\n GeminiContentExtension)\n | (Omit<OpenAI.Chat.Completions.ChatCompletionChunk.Choice.Delta, 'content'> &\n GeminiContentExtension);\n\nconst buildGeminiChatCompletionParams = (\n input: ChatCompletionCallContext,\n): ChatCompletionParamsResult => {\n const { midsceneDefaults, userConfig, intent } = input;\n const { reasoningEnabled, reasoningEffort } = userConfig;\n const commonOverrideConfig: Record<string, unknown> = {};\n\n if (userConfig.temperature !== undefined) {\n commonOverrideConfig.temperature = userConfig.temperature;\n }\n\n const modelSpecificConfig: {\n extra_body?: {\n google?: {\n thinking_config: Record<string, unknown>;\n };\n };\n reasoning_effort?: unknown;\n } = {};\n\n if (reasoningEnabled !== 'default') {\n if (reasoningEffort) {\n modelSpecificConfig.extra_body = {\n google: {\n thinking_config: {\n thinking_level: reasoningEffort,\n include_thoughts: true,\n },\n },\n };\n } else {\n if (intent === 'insight') {\n modelSpecificConfig.extra_body = {\n google: {\n thinking_config: {\n // In real Gemini tests, insight calls need `include_thoughts` to get\n // the model's thinking, and Gemini puts that thinking into `content`.\n include_thoughts: true,\n },\n },\n };\n }\n\n // Gemini 3.x cannot fully disable native thinking, so use the lowest\n // supported effort unless the user explicitly requests another level.\n modelSpecificConfig.reasoning_effort = 'minimal';\n }\n }\n\n return {\n config: {\n ...midsceneDefaults,\n ...commonOverrideConfig,\n ...modelSpecificConfig,\n },\n };\n};\n\nconst extractInlineThought = (content: string): string | undefined => {\n const match = content.match(/<thought>([\\s\\S]*?)<\\/thought>/i);\n return match?.[1]?.trim() || undefined;\n};\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return !!value && typeof value === 'object' && !Array.isArray(value);\n}\n\ntype GeminiExtractedContent = {\n content: string;\n geminiReasoningContent: string;\n};\n\nconst formatReasoningContent = ({\n geminiReasoningContent,\n providerReasoningContent,\n}: {\n geminiReasoningContent: string;\n providerReasoningContent: string;\n}): string => {\n if (geminiReasoningContent && providerReasoningContent) {\n return `thoughtParts:${geminiReasoningContent}; reasoning_content:${providerReasoningContent}`;\n }\n\n return geminiReasoningContent || providerReasoningContent || '';\n};\n\nconst extractGeminiThoughtParts = (\n content: GeminiContentPart[],\n): GeminiExtractedContent => {\n const contentParts: string[] = [];\n const reasoningParts: string[] = [];\n\n for (const part of content) {\n if (!isRecord(part)) {\n continue;\n }\n\n const text = typeof part.text === 'string' ? part.text : undefined;\n if (!text) {\n continue;\n }\n\n if (part.thought === true) {\n reasoningParts.push(text);\n } else {\n contentParts.push(text);\n }\n }\n\n return {\n content: contentParts.join(''),\n geminiReasoningContent: reasoningParts.join(''),\n };\n};\n\nexport const extractGeminiContentAndReasoning = (\n message: GeminiContentSource | undefined,\n): ContentAndReasoning => {\n // Gemini native API exposes thought summaries in\n // `response.candidates[0].content.parts`, where each text part can carry\n // `thought: true`. Some OpenAI-compatible adapters may pass through a\n // native-like content-parts shape, even though the Gemini OpenAI\n // compatibility docs do not guarantee it.\n // Docs: https://ai.google.dev/gemini-api/docs/thinking#thought-summaries\n\n if (!message) {\n return {\n content: '',\n reasoning_content: '',\n };\n }\n\n if (Array.isArray(message.content)) {\n const extracted = extractGeminiThoughtParts(message.content);\n\n return {\n content: extracted.content,\n reasoning_content: formatReasoningContent({\n geminiReasoningContent: extracted.geminiReasoningContent,\n providerReasoningContent:\n typeof message.reasoning_content === 'string'\n ? message.reasoning_content\n : '',\n }),\n };\n }\n\n const result = defaultExtractContentAndReasoning(\n message as ChatCompletionContentSource,\n );\n // In real Gemini OpenAI-compatible responses we observed that\n // `include_thoughts` can still return a plain string `message.content`,\n // with the thought summary prepended as `<thought>...</thought>` before the\n // visible answer. Keep content unchanged, but extract that leading thought\n // text for report display.\n const geminiReasoningContent = extractInlineThought(result.content) || '';\n\n return {\n content: result.content,\n reasoning_content: formatReasoningContent({\n geminiReasoningContent,\n providerReasoningContent: result.reasoning_content,\n }),\n };\n};\n\nexport const geminiAdapters = {\n gemini: {\n chatCompletion: {\n unsupportedUserConfig: ['reasoningEnabled', 'reasoningBudget'],\n buildChatCompletionParams: buildGeminiChatCompletionParams,\n extractContentAndReasoning: extractGeminiContentAndReasoning,\n },\n locate: {\n resultAdapter: {\n coordinates: { shape: 'bbox', order: 'yx', normalizedBy: 1000 },\n },\n },\n },\n} satisfies Pick<Record<TModelFamily, ModelAdapterDefinition>, 'gemini'>;\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","buildGeminiChatCompletionParams","input","midsceneDefaults","userConfig","intent","reasoningEnabled","reasoningEffort","commonOverrideConfig","undefined","modelSpecificConfig","extractInlineThought","content","match","isRecord","value","Array","formatReasoningContent","geminiReasoningContent","providerReasoningContent","extractGeminiThoughtParts","contentParts","reasoningParts","part","text","extractGeminiContentAndReasoning","message","extracted","result","defaultExtractContentAndReasoning","geminiAdapters"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,C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MAAMR,yBAAyBP,qBAAqBiB,OAAO,OAAO,KAAK;IAEvE,OAAO;QACL,SAASA,OAAO,OAAO;QACvB,mBAAmBX,uBAAuB;YACxCC;YACA,0BAA0BU,OAAO,iBAAiB;QACpD;IACF;AACF;AAEO,MAAME,iBAAiB;IAC5B,QAAQ;QACN,gBAAgB;YACd,uBAAuB;gBAAC;gBAAoB;aAAkB;YAC9D,2BAA2B7B;YAC3B,4BAA4BwB;QAC9B;QACA,QAAQ;YACN,eAAe;gBACb,aAAa;oBAAE,OAAO;oBAAQ,OAAO;oBAAM,cAAc;gBAAK;YAChE;QACF;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"ai-model/models/glm.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/ai-model/models/glm.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 type {\n ChatCompletionCallContext,\n ChatCompletionParamsResult,\n ModelAdapterDefinition,\n} from './types';\n\nconst buildGlmChatCompletionParams = (\n input: ChatCompletionCallContext,\n): ChatCompletionParamsResult => {\n const { midsceneDefaults, userConfig } = input;\n const { reasoningEnabled } = userConfig;\n const commonOverrideConfig: Record<string, unknown> = {};\n\n if (userConfig.temperature !== undefined) {\n commonOverrideConfig.temperature = userConfig.temperature;\n }\n\n const modelSpecificConfig: Record<string, unknown> = {};\n\n if (reasoningEnabled !== 'default') {\n modelSpecificConfig.thinking = {\n type: (reasoningEnabled ?? false) ? 'enabled' : 'disabled',\n };\n }\n\n return {\n config: {\n ...midsceneDefaults,\n ...commonOverrideConfig,\n ...modelSpecificConfig,\n },\n };\n};\n\nexport const glmAdapters = {\n 'glm-v': {\n chatCompletion: {\n unsupportedUserConfig: ['reasoningEffort', 'reasoningBudget'],\n buildChatCompletionParams: buildGlmChatCompletionParams,\n },\n locate: {\n resultAdapter: {\n coordinates: { shape: 'bbox', order: 'xy', normalizedBy: 1000 },\n },\n },\n },\n} satisfies Pick<Record<TModelFamily, ModelAdapterDefinition>, 'glm-v'>;\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","buildGlmChatCompletionParams","input","midsceneDefaults","userConfig","reasoningEnabled","commonOverrideConfig","undefined","modelSpecificConfig","glmAdapters"],"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;;;;;;;ACCA,MAAMI,+BAA+B,CACnCC;IAEA,MAAM,EAAEC,gBAAgB,EAAEC,UAAU,EAAE,GAAGF;IACzC,MAAM,EAAEG,gBAAgB,EAAE,GAAGD;IAC7B,MAAME,uBAAgD,CAAC;IAEvD,IAAIF,AAA2BG,WAA3BH,WAAW,WAAW,EACxBE,qBAAqB,WAAW,GAAGF,WAAW,WAAW;IAG3D,MAAMI,sBAA+C,CAAC;IAEtD,IAAIH,AAAqB,cAArBA,kBACFG,oBAAoB,QAAQ,GAAG;QAC7B,MAAOH,oBAAoB,QAAS,YAAY;IAClD;IAGF,OAAO;QACL,QAAQ;YACN,GAAGF,gBAAgB;YACnB,GAAGG,oBAAoB;YACvB,GAAGE,mBAAmB;QACxB;IACF;AACF;AAEO,MAAMC,cAAc;IACzB,SAAS;QACP,gBAAgB;YACd,uBAAuB;gBAAC;gBAAmB;aAAkB;YAC7D,2BAA2BR;QAC7B;QACA,QAAQ;YACN,eAAe;gBACb,aAAa;oBAAE,OAAO;oBAAQ,OAAO;oBAAM,cAAc;gBAAK;YAChE;QACF;IACF;AACF"}
1
+ {"version":3,"file":"ai-model/models/glm.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/ai-model/models/glm.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 type {\n ChatCompletionCallContext,\n ChatCompletionParamsResult,\n ModelAdapterDefinition,\n} from '../model-adapter/types';\n\nconst buildGlmChatCompletionParams = (\n input: ChatCompletionCallContext,\n): ChatCompletionParamsResult => {\n const { midsceneDefaults, userConfig } = input;\n const { reasoningEnabled } = userConfig;\n const commonOverrideConfig: Record<string, unknown> = {};\n\n if (userConfig.temperature !== undefined) {\n commonOverrideConfig.temperature = userConfig.temperature;\n }\n\n const modelSpecificConfig: Record<string, unknown> = {};\n\n if (reasoningEnabled !== 'default') {\n modelSpecificConfig.thinking = {\n type: (reasoningEnabled ?? false) ? 'enabled' : 'disabled',\n };\n }\n\n return {\n config: {\n ...midsceneDefaults,\n ...commonOverrideConfig,\n ...modelSpecificConfig,\n },\n };\n};\n\nexport const glmAdapters = {\n 'glm-v': {\n chatCompletion: {\n unsupportedUserConfig: ['reasoningEffort', 'reasoningBudget'],\n buildChatCompletionParams: buildGlmChatCompletionParams,\n },\n locate: {\n resultAdapter: {\n coordinates: { shape: 'bbox', order: 'xy', normalizedBy: 1000 },\n },\n },\n },\n} satisfies Pick<Record<TModelFamily, ModelAdapterDefinition>, 'glm-v'>;\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","buildGlmChatCompletionParams","input","midsceneDefaults","userConfig","reasoningEnabled","commonOverrideConfig","undefined","modelSpecificConfig","glmAdapters"],"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;;;;;;;ACCA,MAAMI,+BAA+B,CACnCC;IAEA,MAAM,EAAEC,gBAAgB,EAAEC,UAAU,EAAE,GAAGF;IACzC,MAAM,EAAEG,gBAAgB,EAAE,GAAGD;IAC7B,MAAME,uBAAgD,CAAC;IAEvD,IAAIF,AAA2BG,WAA3BH,WAAW,WAAW,EACxBE,qBAAqB,WAAW,GAAGF,WAAW,WAAW;IAG3D,MAAMI,sBAA+C,CAAC;IAEtD,IAAIH,AAAqB,cAArBA,kBACFG,oBAAoB,QAAQ,GAAG;QAC7B,MAAOH,oBAAoB,QAAS,YAAY;IAClD;IAGF,OAAO;QACL,QAAQ;YACN,GAAGF,gBAAgB;YACnB,GAAGG,oBAAoB;YACvB,GAAGE,mBAAmB;QACxB;IACF;AACF;AAEO,MAAMC,cAAc;IACzB,SAAS;QACP,gBAAgB;YACd,uBAAuB;gBAAC;gBAAmB;aAAkB;YAC7D,2BAA2BR;QAC7B;QACA,QAAQ;YACN,eAAe;gBACb,aAAa;oBAAE,OAAO;oBAAQ,OAAO;oBAAM,cAAc;gBAAK;YAChE;QACF;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"ai-model/models/gpt.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/ai-model/models/gpt.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 type {\n ChatCompletionCallContext,\n ChatCompletionParamsResult,\n ImageDetail,\n ModelAdapterDefinition,\n} from './types';\n\nconst originalImageDetailForDefaultIntent = (\n input: ChatCompletionCallContext,\n): ImageDetail | undefined =>\n input.intent === 'default' || input.requiresOriginalImageDetail\n ? 'original'\n : undefined;\n\nconst buildGpt5ChatCompletionParams = (\n input: ChatCompletionCallContext,\n): ChatCompletionParamsResult => {\n const { midsceneDefaults, userConfig } = input;\n const { reasoningEnabled, reasoningEffort } = userConfig;\n const commonOverrideConfig: Record<string, unknown> = {};\n\n if (userConfig.temperature !== undefined) {\n commonOverrideConfig.temperature = userConfig.temperature;\n }\n\n const effectiveReasoningEffort =\n reasoningEnabled === true ? (reasoningEffort ?? 'medium') : 'none';\n\n return {\n config: {\n ...midsceneDefaults,\n ...commonOverrideConfig,\n reasoning_effort: effectiveReasoningEffort,\n },\n };\n};\n\nexport const gptAdapters = {\n 'gpt-5': {\n chatCompletion: {\n unsupportedUserConfig: ['reasoningBudget'],\n buildChatCompletionParams: buildGpt5ChatCompletionParams,\n resolveImageDetail: originalImageDetailForDefaultIntent,\n },\n locate: {\n resultAdapter: {\n coordinates: { shape: 'bbox', order: 'xy' },\n },\n },\n },\n} satisfies Pick<Record<TModelFamily, ModelAdapterDefinition>, 'gpt-5'>;\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","originalImageDetailForDefaultIntent","input","undefined","buildGpt5ChatCompletionParams","midsceneDefaults","userConfig","reasoningEnabled","reasoningEffort","commonOverrideConfig","effectiveReasoningEffort","gptAdapters"],"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;;;;;;;ACEA,MAAMI,sCAAsC,CAC1CC,QAEAA,AAAiB,cAAjBA,MAAM,MAAM,IAAkBA,MAAM,2BAA2B,GAC3D,aACAC;AAEN,MAAMC,gCAAgC,CACpCF;IAEA,MAAM,EAAEG,gBAAgB,EAAEC,UAAU,EAAE,GAAGJ;IACzC,MAAM,EAAEK,gBAAgB,EAAEC,eAAe,EAAE,GAAGF;IAC9C,MAAMG,uBAAgD,CAAC;IAEvD,IAAIH,AAA2BH,WAA3BG,WAAW,WAAW,EACxBG,qBAAqB,WAAW,GAAGH,WAAW,WAAW;IAG3D,MAAMI,2BACJH,AAAqB,SAArBA,mBAA6BC,mBAAmB,WAAY;IAE9D,OAAO;QACL,QAAQ;YACN,GAAGH,gBAAgB;YACnB,GAAGI,oBAAoB;YACvB,kBAAkBC;QACpB;IACF;AACF;AAEO,MAAMC,cAAc;IACzB,SAAS;QACP,gBAAgB;YACd,uBAAuB;gBAAC;aAAkB;YAC1C,2BAA2BP;YAC3B,oBAAoBH;QACtB;QACA,QAAQ;YACN,eAAe;gBACb,aAAa;oBAAE,OAAO;oBAAQ,OAAO;gBAAK;YAC5C;QACF;IACF;AACF"}
1
+ {"version":3,"file":"ai-model/models/gpt.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/ai-model/models/gpt.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 type {\n ChatCompletionCallContext,\n ChatCompletionParamsResult,\n ImageDetail,\n ModelAdapterDefinition,\n} from '../model-adapter/types';\n\nconst originalImageDetailForDefaultIntent = (\n input: ChatCompletionCallContext,\n): ImageDetail | undefined =>\n input.intent === 'default' || input.requiresOriginalImageDetail\n ? 'original'\n : undefined;\n\nconst buildGpt5ChatCompletionParams = (\n input: ChatCompletionCallContext,\n): ChatCompletionParamsResult => {\n const { midsceneDefaults, userConfig } = input;\n const { reasoningEnabled, reasoningEffort } = userConfig;\n const commonOverrideConfig: Record<string, unknown> = {};\n\n if (userConfig.temperature !== undefined) {\n commonOverrideConfig.temperature = userConfig.temperature;\n }\n\n const effectiveReasoningEffort =\n reasoningEnabled === true ? (reasoningEffort ?? 'medium') : 'none';\n\n return {\n config: {\n ...midsceneDefaults,\n ...commonOverrideConfig,\n reasoning_effort: effectiveReasoningEffort,\n },\n };\n};\n\nexport const gptAdapters = {\n 'gpt-5': {\n chatCompletion: {\n unsupportedUserConfig: ['reasoningBudget'],\n buildChatCompletionParams: buildGpt5ChatCompletionParams,\n resolveImageDetail: originalImageDetailForDefaultIntent,\n },\n locate: {\n resultAdapter: {\n coordinates: { shape: 'bbox', order: 'xy' },\n },\n },\n },\n} satisfies Pick<Record<TModelFamily, ModelAdapterDefinition>, 'gpt-5'>;\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","originalImageDetailForDefaultIntent","input","undefined","buildGpt5ChatCompletionParams","midsceneDefaults","userConfig","reasoningEnabled","reasoningEffort","commonOverrideConfig","effectiveRe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ACN,eAAe;gBACb,aAAa;oBAAE,OAAO;oBAAQ,OAAO;gBAAK;YAC5C;QACF;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"ai-model/models/kimi.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/ai-model/models/kimi.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 type {\n ChatCompletionCallContext,\n ChatCompletionParamsResult,\n ModelAdapterDefinition,\n} from './types';\n\nconst buildKimiChatCompletionParams = (\n input: ChatCompletionCallContext,\n): ChatCompletionParamsResult => {\n const { midsceneDefaults, userConfig } = input;\n const { reasoningEnabled } = userConfig;\n const effectiveReasoningEnabled = reasoningEnabled ?? false;\n const commonOverrideConfig: Record<string, unknown> = {};\n\n // kimi disallow custom temperature\n commonOverrideConfig.temperature = undefined;\n\n const modelSpecificConfig: Record<string, unknown> = {\n thinking: {\n type: effectiveReasoningEnabled ? 'enabled' : 'disabled',\n },\n };\n\n return {\n config: {\n ...midsceneDefaults,\n ...commonOverrideConfig,\n ...modelSpecificConfig,\n },\n };\n};\n\nexport const kimiAdapters = {\n kimi: {\n chatCompletion: {\n unsupportedUserConfig: ['reasoningEffort', 'reasoningBudget'],\n buildChatCompletionParams: buildKimiChatCompletionParams,\n },\n locate: {\n resultAdapter: {\n coordinates: { shape: 'point', order: 'xy', normalizedBy: 1 },\n },\n },\n },\n} satisfies Pick<Record<TModelFamily, ModelAdapterDefinition>, 'kimi'>;\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","buildKimiChatCompletionParams","input","midsceneDefaults","userConfig","reasoningEnabled","effectiveReasoningEnabled","commonOverrideConfig","undefined","modelSpecificConfig","kimiAdapters"],"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;;;;;;;ACCA,MAAMI,gCAAgC,CACpCC;IAEA,MAAM,EAAEC,gBAAgB,EAAEC,UAAU,EAAE,GAAGF;IACzC,MAAM,EAAEG,gBAAgB,EAAE,GAAGD;IAC7B,MAAME,4BAA4BD,oBAAoB;IACtD,MAAME,uBAAgD,CAAC;IAGvDA,qBAAqB,WAAW,GAAGC;IAEnC,MAAMC,sBAA+C;QACnD,UAAU;YACR,MAAMH,4BAA4B,YAAY;QAChD;IACF;IAEA,OAAO;QACL,QAAQ;YACN,GAAGH,gBAAgB;YACnB,GAAGI,oBAAoB;YACvB,GAAGE,mBAAmB;QACxB;IACF;AACF;AAEO,MAAMC,eAAe;IAC1B,MAAM;QACJ,gBAAgB;YACd,uBAAuB;gBAAC;gBAAmB;aAAkB;YAC7D,2BAA2BT;QAC7B;QACA,QAAQ;YACN,eAAe;gBACb,aAAa;oBAAE,OAAO;oBAAS,OAAO;oBAAM,cAAc;gBAAE;YAC9D;QACF;IACF;AACF"}
1
+ {"version":3,"file":"ai-model/models/kimi.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/ai-model/models/kimi.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 type {\n ChatCompletionCallContext,\n ChatCompletionParamsResult,\n ModelAdapterDefinition,\n} from '../model-adapter/types';\n\nconst buildKimiChatCompletionParams = (\n input: ChatCompletionCallContext,\n): ChatCompletionParamsResult => {\n const { midsceneDefaults, userConfig } = input;\n const { reasoningEnabled } = userConfig;\n const effectiveReasoningEnabled = reasoningEnabled ?? false;\n const commonOverrideConfig: Record<string, unknown> = {};\n\n // kimi disallow custom temperature\n commonOverrideConfig.temperature = undefined;\n\n const modelSpecificConfig: Record<string, unknown> = {\n thinking: {\n type: effectiveReasoningEnabled ? 'enabled' : 'disabled',\n },\n };\n\n return {\n config: {\n ...midsceneDefaults,\n ...commonOverrideConfig,\n ...modelSpecificConfig,\n },\n };\n};\n\nexport const kimiAdapters = {\n kimi: {\n chatCompletion: {\n unsupportedUserConfig: ['reasoningEffort', 'reasoningBudget'],\n buildChatCompletionParams: buildKimiChatCompletionParams,\n },\n locate: {\n resultAdapter: {\n coordinates: { shape: 'point', order: 'xy', normalizedBy: 1 },\n },\n },\n },\n} satisfies Pick<Record<TModelFamily, ModelAdapterDefinition>, 'kimi'>;\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","buildKimiChatCompletionParams","input","midsceneDefaults","userConfig","reasoningEnabled","effectiveReasoningEnabled","commonOverrideConfig","undefined","modelSpecificConfig","kimiAdapters"],"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;;;;;;;ACCA,MAAMI,gCAAgC,CACpCC;IAEA,MAAM,EAAEC,gBAAgB,EAAEC,UAAU,EAAE,GAAGF;IACzC,MAAM,EAAEG,gBAAgB,EAAE,GAAGD;IAC7B,MAAME,4BAA4BD,oBAAoB;IACtD,MAAME,uBAAgD,CAAC;IAGvDA,qBAAqB,WAAW,GAAGC;IAEnC,MAAMC,sBAA+C;QACnD,UAAU;YACR,MAAMH,4BAA4B,YAAY;QAChD;IACF;IAEA,OAAO;QACL,QAAQ;YACN,GAAGH,gBAAgB;YACnB,GAAGI,oBAAoB;YACvB,GAAGE,mBAAmB;QACxB;IACF;AACF;AAEO,MAAMC,eAAe;IAC1B,MAAM;QACJ,gBAAgB;YACd,uBAAuB;gBAAC;gBAAmB;aAAkB;YAC7D,2BAA2BT;QAC7B;QACA,QAAQ;YACN,eAAe;gBACb,aAAa;oBAAE,OAAO;oBAAS,OAAO;oBAAM,cAAc;gBAAE;YAC9D;QACF;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"ai-model/models/mimo.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/ai-model/models/mimo.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 type {\n ChatCompletionCallContext,\n ChatCompletionParamsResult,\n ModelAdapterDefinition,\n} from './types';\n\nconst buildMimoChatCompletionParams = (\n input: ChatCompletionCallContext,\n): ChatCompletionParamsResult => {\n const { intent, midsceneDefaults, userConfig } = input;\n const { reasoningEnabled } = userConfig;\n const commonOverrideConfig: Record<string, unknown> = {};\n\n // https://platform.xiaomimimo.com/docs/zh-CN/api/chat/openai-api\n // Observed with thinking disabled: Mimo needs json_object to return JSON.\n commonOverrideConfig.response_format = {\n type: intent === 'default' ? 'json_object' : 'text',\n };\n\n if (userConfig.temperature !== undefined) {\n commonOverrideConfig.temperature = userConfig.temperature;\n }\n\n const modelSpecificConfig: Record<string, unknown> = {\n thinking: {\n type: (reasoningEnabled ?? false) ? 'enabled' : 'disabled',\n },\n };\n\n return {\n config: {\n ...midsceneDefaults,\n ...commonOverrideConfig,\n ...modelSpecificConfig,\n },\n };\n};\n\nexport const mimoAdapters = {\n 'xiaomi-mimo': {\n chatCompletion: {\n unsupportedUserConfig: ['reasoningEffort', 'reasoningBudget'],\n buildChatCompletionParams: buildMimoChatCompletionParams,\n },\n },\n} satisfies Pick<Record<TModelFamily, ModelAdapterDefinition>, 'xiaomi-mimo'>;\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","buildMimoChatCompletionParams","input","intent","midsceneDefaults","userConfig","reasoningEnabled","commonOverrideConfig","undefined","modelSpecificConfig","mimoAdapters"],"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;;;;;;;ACCA,MAAMI,gCAAgC,CACpCC;IAEA,MAAM,EAAEC,MAAM,EAAEC,gBAAgB,EAAEC,UAAU,EAAE,GAAGH;IACjD,MAAM,EAAEI,gBAAgB,EAAE,GAAGD;IAC7B,MAAME,uBAAgD,CAAC;IAIvDA,qBAAqB,eAAe,GAAG;QACrC,MAAMJ,AAAW,cAAXA,SAAuB,gBAAgB;IAC/C;IAEA,IAAIE,AAA2BG,WAA3BH,WAAW,WAAW,EACxBE,qBAAqB,WAAW,GAAGF,WAAW,WAAW;IAG3D,MAAMI,sBAA+C;QACnD,UAAU;YACR,MAAOH,oBAAoB,QAAS,YAAY;QAClD;IACF;IAEA,OAAO;QACL,QAAQ;YACN,GAAGF,gBAAgB;YACnB,GAAGG,oBAAoB;YACvB,GAAGE,mBAAmB;QACxB;IACF;AACF;AAEO,MAAMC,eAAe;IAC1B,eAAe;QACb,gBAAgB;YACd,uBAAuB;gBAAC;gBAAmB;aAAkB;YAC7D,2BAA2BT;QAC7B;IACF;AACF"}
1
+ {"version":3,"file":"ai-model/models/mimo.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/ai-model/models/mimo.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 type {\n ChatCompletionCallContext,\n ChatCompletionParamsResult,\n ModelAdapterDefinition,\n} from '../model-adapter/types';\n\nconst buildMimoChatCompletionParams = (\n input: ChatCompletionCallContext,\n): ChatCompletionParamsResult => {\n const { intent, midsceneDefaults, userConfig } = input;\n const { reasoningEnabled } = userConfig;\n const commonOverrideConfig: Record<string, unknown> = {};\n\n // https://platform.xiaomimimo.com/docs/zh-CN/api/chat/openai-api\n // Observed with thinking disabled: Mimo needs json_object to return JSON.\n commonOverrideConfig.response_format = {\n type: intent === 'default' ? 'json_object' : 'text',\n };\n\n if (userConfig.temperature !== undefined) {\n commonOverrideConfig.temperature = userConfig.temperature;\n }\n\n const modelSpecificConfig: Record<string, unknown> = {\n thinking: {\n type: (reasoningEnabled ?? false) ? 'enabled' : 'disabled',\n },\n };\n\n return {\n config: {\n ...midsceneDefaults,\n ...commonOverrideConfig,\n ...modelSpecificConfig,\n },\n };\n};\n\nexport const mimoAdapters = {\n 'xiaomi-mimo': {\n chatCompletion: {\n unsupportedUserConfig: ['reasoningEffort', 'reasoningBudget'],\n buildChatCompletionParams: buildMimoChatCompletionParams,\n },\n },\n} satisfies Pick<Record<TModelFamily, ModelAdapterDefinition>, 'xiaomi-mimo'>;\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","buildMimoChatCompletionParams","input","intent","midsceneDefaults","userConfig","reasoningEnabled","commonOverrideConfig","undefined","modelSpecificConfig","mimoAdapters"],"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;;;;;;;ACCA,MAAMI,gCAAgC,CACpCC;IAEA,MAAM,EAAEC,MAAM,EAAEC,gBAAgB,EAAEC,UAAU,EAAE,GAAGH;IACjD,MAAM,EAAEI,gBAAgB,EAAE,GAAGD;IAC7B,MAAME,uBAAgD,CAAC;IAIvDA,qBAAqB,eAAe,GAAG;QACrC,MAAMJ,AAAW,cAAXA,SAAuB,gBAAgB;IAC/C;IAEA,IAAIE,AAA2BG,WAA3BH,WAAW,WAAW,EACxBE,qBAAqB,WAAW,GAAGF,WAAW,WAAW;IAG3D,MAAMI,sBAA+C;QACnD,UAAU;YACR,MAAOH,oBAAoB,QAAS,YAAY;QAClD;IACF;IAEA,OAAO;QACL,QAAQ;YACN,GAAGF,gBAAgB;YACnB,GAAGG,oBAAoB;YACvB,GAAGE,mBAAmB;QACxB;IACF;AACF;AAEO,MAAMC,eAAe;IAC1B,eAAe;QACb,gBAAgB;YACd,uBAAuB;gBAAC;gBAAmB;aAAkB;YAC7D,2BAA2BT;QAC7B;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"ai-model/models/qwen.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/ai-model/models/qwen.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 {\n type LocateResultValue,\n type PixelBbox,\n unwrapCoordinateListLikeInput,\n} from '../shared/model-locate-result';\nimport type {\n ChatCompletionCallContext,\n ChatCompletionParamsResult,\n ModelAdapterDefinition,\n} from './types';\n\nconst defaultBboxSize = 20;\n\nfunction topLeftPointToPixelBbox(x: number, y: number): PixelBbox {\n return [\n Math.round(x),\n Math.round(y),\n Math.round(x + defaultBboxSize),\n Math.round(y + defaultBboxSize),\n ];\n}\n\nfunction parseQwen25RawLocateValue(input: unknown): LocateResultValue {\n const bbox = unwrapCoordinateListLikeInput(input as any) as number[];\n if (bbox.length < 2) {\n const msg = `invalid bbox data for qwen-vl mode: ${JSON.stringify(bbox)} `;\n throw new Error(msg);\n }\n\n if (typeof bbox[2] === 'number' && typeof bbox[3] === 'number') {\n return {\n type: 'bbox',\n coordinates: [bbox[0], bbox[1], bbox[2], bbox[3]],\n };\n }\n\n return { type: 'point', coordinates: [bbox[0], bbox[1]] };\n}\n\nfunction normalizeQwen25ResultToPixelBbox(\n result: LocateResultValue,\n): PixelBbox {\n if (result.type === 'bbox') {\n return [\n Math.round(result.coordinates[0]),\n Math.round(result.coordinates[1]),\n Math.round(result.coordinates[2]),\n Math.round(result.coordinates[3]),\n ];\n }\n\n return topLeftPointToPixelBbox(result.coordinates[0], result.coordinates[1]);\n}\n\nconst buildQwenChatCompletionParams = (\n input: ChatCompletionCallContext,\n): ChatCompletionParamsResult => {\n const { midsceneDefaults, userConfig } = input;\n const { reasoningEnabled, reasoningBudget } = userConfig;\n\n const commonOverrideConfig: Record<string, unknown> = {};\n\n if (userConfig.temperature !== undefined) {\n commonOverrideConfig.temperature = userConfig.temperature;\n }\n\n const modelSpecificConfig: Record<string, unknown> = {};\n\n if (reasoningEnabled !== 'default') {\n modelSpecificConfig.enable_thinking = reasoningEnabled ?? false;\n if (reasoningBudget !== undefined) {\n modelSpecificConfig.thinking_budget = reasoningBudget;\n }\n }\n\n return {\n config: {\n ...midsceneDefaults,\n ...commonOverrideConfig,\n ...modelSpecificConfig,\n },\n };\n};\n\nconst buildQwen25ChatCompletionParams = (\n input: ChatCompletionCallContext,\n): ChatCompletionParamsResult => {\n const { midsceneDefaults, userConfig } = input;\n const commonOverrideConfig: Record<string, unknown> = {};\n\n if (userConfig.temperature !== undefined) {\n commonOverrideConfig.temperature = userConfig.temperature;\n }\n\n return {\n config: {\n ...midsceneDefaults,\n ...commonOverrideConfig,\n vl_high_resolution_images: true,\n },\n };\n};\n\nconst qwen3Adapter: ModelAdapterDefinition = {\n chatCompletion: {\n unsupportedUserConfig: ['reasoningEffort'],\n buildChatCompletionParams: buildQwenChatCompletionParams,\n },\n locate: {\n resultAdapter: {\n coordinates: { shape: 'bbox', order: 'xy', normalizedBy: 1000 },\n },\n },\n};\n\nexport const qwenAdapters = {\n 'qwen2.5-vl': {\n chatCompletion: {\n unsupportedUserConfig: [\n 'reasoningEnabled',\n 'reasoningEffort',\n 'reasoningBudget',\n ],\n buildChatCompletionParams: buildQwen25ChatCompletionParams,\n },\n imagePreprocess: {\n padBlockSize: 28,\n },\n locate: {\n resultAdapter: {\n coordinates: { shape: 'bbox', order: 'xy' },\n parseRawLocateValue: parseQwen25RawLocateValue,\n mapLocateResultToPixelBbox: normalizeQwen25ResultToPixelBbox,\n },\n },\n },\n 'qwen3-vl': qwen3Adapter,\n qwen3: qwen3Adapter,\n 'qwen3.5': qwen3Adapter,\n 'qwen3.6': qwen3Adapter,\n} satisfies Pick<\n Record<TModelFamily, ModelAdapterDefinition>,\n 'qwen2.5-vl' | 'qwen3-vl' | 'qwen3' | 'qwen3.5' | 'qwen3.6'\n>;\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","defaultBboxSize","topLeftPointToPixelBbox","x","y","Math","parseQwen25RawLocateValue","input","bbox","unwrapCoordinateListLikeInput","msg","JSON","Error","normalizeQwen25ResultToPixelBbox","result","buildQwenChatCompletionParams","midsceneDefaults","userConfig","reasoningEnabled","reasoningBudget","commonOverrideConfig","undefined","modelSpecificConfig","buildQwen25ChatCompletionParams","qwen3Adapter","qwenAdapters"],"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,K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;QACN,eAAe;YACb,aAAa;gBAAE,OAAO;gBAAQ,OAAO;gBAAM,cAAc;YAAK;QAChE;IACF;AACF;AAEO,MAAMU,eAAe;IAC1B,cAAc;QACZ,gBAAgB;YACd,uBAAuB;gBACrB;gBACA;gBACA;aACD;YACD,2BAA2BF;QAC7B;QACA,iBAAiB;YACf,cAAc;QAChB;QACA,QAAQ;YACN,eAAe;gBACb,aAAa;oBAAE,OAAO;oBAAQ,OAAO;gBAAK;gBAC1C,qBAAqBjB;gBACrB,4BAA4BO;YAC9B;QACF;IACF;IACA,YAAYW;IACZ,OAAOA;IACP,WAAWA;IACX,WAAWA;AACb"}
1
+ {"version":3,"file":"ai-model/models/qwen.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/ai-model/models/qwen.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 type {\n ChatCompletionCallContext,\n ChatCompletionParamsResult,\n ModelAdapterDefinition,\n} from '../model-adapter/types';\nimport {\n type LocateResultValue,\n type PixelBbox,\n unwrapCoordinateListLikeInput,\n} from '../shared/model-locate-result';\n\nconst defaultBboxSize = 20;\n\nfunction topLeftPointToPixelBbox(x: number, y: number): PixelBbox {\n return [\n Math.round(x),\n Math.round(y),\n Math.round(x + defaultBboxSize),\n Math.round(y + defaultBboxSize),\n ];\n}\n\nfunction parseQwen25RawLocateValue(input: unknown): LocateResultValue {\n const bbox = unwrapCoordinateListLikeInput(input as any) as number[];\n if (bbox.length < 2) {\n const msg = `invalid bbox data for qwen-vl mode: ${JSON.stringify(bbox)} `;\n throw new Error(msg);\n }\n\n if (typeof bbox[2] === 'number' && typeof bbox[3] === 'number') {\n return {\n type: 'bbox',\n coordinates: [bbox[0], bbox[1], bbox[2], bbox[3]],\n };\n }\n\n return { type: 'point', coordinates: [bbox[0], bbox[1]] };\n}\n\nfunction normalizeQwen25ResultToPixelBbox(\n result: LocateResultValue,\n): PixelBbox {\n if (result.type === 'bbox') {\n return [\n Math.round(result.coordinates[0]),\n Math.round(result.coordinates[1]),\n Math.round(result.coordinates[2]),\n Math.round(result.coordinates[3]),\n ];\n }\n\n return topLeftPointToPixelBbox(result.coordinates[0], result.coordinates[1]);\n}\n\nconst buildQwenChatCompletionParams = (\n input: ChatCompletionCallContext,\n): ChatCompletionParamsResult => {\n const { midsceneDefaults, userConfig } = input;\n const { reasoningEnabled, reasoningBudget } = userConfig;\n\n const commonOverrideConfig: Record<string, unknown> = {};\n\n if (userConfig.temperature !== undefined) {\n commonOverrideConfig.temperature = userConfig.temperature;\n }\n\n const modelSpecificConfig: Record<string, unknown> = {};\n\n if (reasoningEnabled !== 'default') {\n modelSpecificConfig.enable_thinking = reasoningEnabled ?? false;\n if (reasoningBudget !== undefined) {\n modelSpecificConfig.thinking_budget = reasoningBudget;\n }\n }\n\n return {\n config: {\n ...midsceneDefaults,\n ...commonOverrideConfig,\n ...modelSpecificConfig,\n },\n };\n};\n\nconst buildQwen25ChatCompletionParams = (\n input: ChatCompletionCallContext,\n): ChatCompletionParamsResult => {\n const { midsceneDefaults, userConfig } = input;\n const commonOverrideConfig: Record<string, unknown> = {};\n\n if (userConfig.temperature !== undefined) {\n commonOverrideConfig.temperature = userConfig.temperature;\n }\n\n return {\n config: {\n ...midsceneDefaults,\n ...commonOverrideConfig,\n vl_high_resolution_images: true,\n },\n };\n};\n\nconst qwen3Adapter: ModelAdapterDefinition = {\n chatCompletion: {\n unsupportedUserConfig: ['reasoningEffort'],\n buildChatCompletionParams: buildQwenChatCompletionParams,\n },\n locate: {\n resultAdapter: {\n coordinates: { shape: 'bbox', order: 'xy', normalizedBy: 1000 },\n },\n },\n};\n\nexport const qwenAdapters = {\n 'qwen2.5-vl': {\n chatCompletion: {\n unsupportedUserConfig: [\n 'reasoningEnabled',\n 'reasoningEffort',\n 'reasoningBudget',\n ],\n buildChatCompletionParams: buildQwen25ChatCompletionParams,\n },\n imagePreprocess: {\n padBlockSize: 28,\n },\n locate: {\n resultAdapter: {\n coordinates: { shape: 'bbox', order: 'xy' },\n parseRawLocateValue: parseQwen25RawLocateValue,\n mapLocateResultToPixelBbox: normalizeQwen25ResultToPixelBbox,\n },\n },\n },\n 'qwen3-vl': qwen3Adapter,\n qwen3: qwen3Adapter,\n 'qwen3.5': qwen3Adapter,\n 'qwen3.6': qwen3Adapter,\n} satisfies Pick<\n Record<TModelFamily, ModelAdapterDefinition>,\n 'qwen2.5-vl' | 'qwen3-vl' | 'qwen3' | 'qwen3.5' | 'qwen3.6'\n>;\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","defaultBboxSize","topLeftPointToPixelBbox","x","y","Math","parseQwen25RawLocateValue","input","bbox","unwrapCoordinateListLikeInput","msg","JSON","Error","normalizeQwen25ResultToPixelBbox","result","buildQwenChatCompletionParams","midsceneDefaults","userConfig","reasoningEnabled","reasoningBudget","commonOverrideConfig","undefined","modelSpecificConfig","buildQwen25ChatCompletionParams","qwen3Adapter","qwenAdapters"],"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,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;AAEO,MAAMU,eAAe;IAC1B,cAAc;QACZ,gBAAgB;YACd,uBAAuB;gBACrB;gBACA;gBACA;aACD;YACD,2BAA2BF;QAC7B;QACA,iBAAiB;YACf,cAAc;QAChB;QACA,QAAQ;YACN,eAAe;gBACb,aAAa;oBAAE,OAAO;oBAAQ,OAAO;gBAAK;gBAC1C,qBAAqBjB;gBACrB,4BAA4BO;YAC9B;QACF;IACF;IACA,YAAYW;IACZ,OAAOA;IACP,WAAWA;IACX,WAAWA;AACb"}
@@ -29,6 +29,7 @@ __webpack_require__.d(__webpack_exports__, {
29
29
  getModelRuntime: ()=>getModelRuntime
30
30
  });
31
31
  const logger_namespaceObject = require("@midscene/shared/logger");
32
+ const resolve_js_namespaceObject = require("../model-adapter/resolve.js");
32
33
  const adapter_js_namespaceObject = require("./auto-glm/adapter.js");
33
34
  const external_default_js_namespaceObject = require("./default.js");
34
35
  const external_doubao_js_namespaceObject = require("./doubao.js");
@@ -38,7 +39,6 @@ const external_gpt_js_namespaceObject = require("./gpt.js");
38
39
  const external_kimi_js_namespaceObject = require("./kimi.js");
39
40
  const external_mimo_js_namespaceObject = require("./mimo.js");
40
41
  const external_qwen_js_namespaceObject = require("./qwen.js");
41
- const external_resolved_js_namespaceObject = require("./resolved.js");
42
42
  const external_ui_tars_adapter_js_namespaceObject = require("./ui-tars/adapter.js");
43
43
  const MODEL_ADAPTER_CONFIGS = {
44
44
  ...external_qwen_js_namespaceObject.qwenAdapters,
@@ -63,7 +63,7 @@ function getModelAdapter(modelFamily) {
63
63
  if (adapter) return adapter;
64
64
  const config = modelFamily ? MODEL_ADAPTER_CONFIGS[modelFamily] : external_default_js_namespaceObject.defaultOpenAICompatibleAdapterConfig;
65
65
  if (!config) throw new Error(`No model adapter registered for modelFamily: ${modelFamily}`);
66
- adapter = new external_resolved_js_namespaceObject.ResolvedModelAdapter(config, cacheKey);
66
+ adapter = new resolve_js_namespaceObject.ResolvedModelAdapter(config, cacheKey);
67
67
  modelAdapterCache.set(cacheKey, adapter);
68
68
  debugAdapterUnsupportedUserConfig(cacheKey, adapter);
69
69
  return adapter;
@@ -1 +1 @@
1
- {"version":3,"file":"ai-model/models/registry.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/ai-model/models/registry.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, TModelFamily } from '@midscene/shared/env';\nimport { getDebug } from '@midscene/shared/logger';\nimport { autoGlmAdapters } from './auto-glm/adapter';\nimport { defaultOpenAICompatibleAdapterConfig } from './default';\nimport { doubaoAdapters } from './doubao';\nimport { geminiAdapters } from './gemini';\nimport { glmAdapters } from './glm';\nimport { gptAdapters } from './gpt';\nimport { kimiAdapters } from './kimi';\nimport { mimoAdapters } from './mimo';\nimport { qwenAdapters } from './qwen';\nimport { ResolvedModelAdapter } from './resolved';\nimport type {\n ModelAdapter,\n ModelAdapterDefinition,\n ModelRuntime,\n} from './types';\nimport { uiTarsAdapters } from './ui-tars/adapter';\n\nexport const MODEL_ADAPTER_CONFIGS = {\n ...qwenAdapters,\n ...doubaoAdapters,\n ...geminiAdapters,\n ...uiTarsAdapters,\n ...glmAdapters,\n ...autoGlmAdapters,\n ...gptAdapters,\n ...kimiAdapters,\n ...mimoAdapters,\n} satisfies Record<TModelFamily, ModelAdapterDefinition>;\n\ntype ModelAdapterCacheKey = TModelFamily | 'default';\n\nconst modelAdapterCache = new Map<ModelAdapterCacheKey, ModelAdapter>();\nconst debugModelAdapter = getDebug('ai:model-adapter');\n\nfunction debugAdapterUnsupportedUserConfig(\n modelFamily: ModelAdapterCacheKey,\n adapter: ModelAdapter,\n): void {\n if (adapter.chatCompletion.unsupportedUserConfig.length === 0) {\n return;\n }\n\n debugModelAdapter(\n `model adapter \"${modelFamily}\" unsupportedUserConfig: ${JSON.stringify(\n adapter.chatCompletion.unsupportedUserConfig,\n )}`,\n );\n}\n\nexport function getModelAdapter(modelFamily?: TModelFamily): ModelAdapter {\n const cacheKey: ModelAdapterCacheKey = modelFamily ?? 'default';\n let adapter = modelAdapterCache.get(cacheKey);\n if (adapter) {\n return adapter;\n }\n\n const config = modelFamily\n ? MODEL_ADAPTER_CONFIGS[modelFamily]\n : defaultOpenAICompatibleAdapterConfig;\n if (!config) {\n throw new Error(\n `No model adapter registered for modelFamily: ${modelFamily}`,\n );\n }\n\n adapter = new ResolvedModelAdapter(config, cacheKey);\n modelAdapterCache.set(cacheKey, adapter);\n debugAdapterUnsupportedUserConfig(cacheKey, adapter);\n\n return adapter;\n}\n\nexport function getModelRuntime(config: IModelConfig): ModelRuntime {\n return {\n config,\n adapter: getModelAdapter(config.modelFamily),\n };\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","MODEL_ADAPTER_CONFIGS","qwenAdapters","doubaoAdapters","geminiAdapters","uiTarsAdapters","glmAdapters","autoGlmAdapters","gptAdapters","kimiAdapters","mimoAdapters","modelAdapterCache","Map","debugModelAdapter","getDebug","debugAdapterUnsupportedUserConfig","modelFamily","adapter","JSON","getModelAdapter","cacheKey","config","defaultOpenAICompatibleAdapterConfig","Error","ResolvedModelAdapter","getModelRuntime"],"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,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AAIE,MACR,CAAC,6CAA6C,EAAEP,aAAa;IAIjEC,UAAU,IAAIO,qCAAAA,oBAAoBA,CAACH,QAAQD;IAC3CT,kBAAkB,GAAG,CAACS,UAAUH;IAChCF,kCAAkCK,UAAUH;IAE5C,OAAOA;AACT;AAEO,SAASQ,gBAAgBJ,MAAoB;IAClD,OAAO;QACLA;QACA,SAASF,gBAAgBE,OAAO,WAAW;IAC7C;AACF"}
1
+ {"version":3,"file":"ai-model/models/registry.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../../src/ai-model/models/registry.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, TModelFamily } from '@midscene/shared/env';\nimport { getDebug } from '@midscene/shared/logger';\nimport { ResolvedModelAdapter } from '../model-adapter/resolve';\nimport type {\n ModelAdapter,\n ModelAdapterDefinition,\n ModelRuntime,\n} from '../model-adapter/types';\nimport { autoGlmAdapters } from './auto-glm/adapter';\nimport { defaultOpenAICompatibleAdapterConfig } from './default';\nimport { doubaoAdapters } from './doubao';\nimport { geminiAdapters } from './gemini';\nimport { glmAdapters } from './glm';\nimport { gptAdapters } from './gpt';\nimport { kimiAdapters } from './kimi';\nimport { mimoAdapters } from './mimo';\nimport { qwenAdapters } from './qwen';\nimport { uiTarsAdapters } from './ui-tars/adapter';\n\nexport const MODEL_ADAPTER_CONFIGS = {\n ...qwenAdapters,\n ...doubaoAdapters,\n ...geminiAdapters,\n ...uiTarsAdapters,\n ...glmAdapters,\n ...autoGlmAdapters,\n ...gptAdapters,\n ...kimiAdapters,\n ...mimoAdapters,\n} satisfies Record<TModelFamily, ModelAdapterDefinition>;\n\ntype ModelAdapterCacheKey = TModelFamily | 'default';\n\nconst modelAdapterCache = new Map<ModelAdapterCacheKey, ModelAdapter>();\nconst debugModelAdapter = getDebug('ai:model-adapter');\n\nfunction debugAdapterUnsupportedUserConfig(\n modelFamily: ModelAdapterCacheKey,\n adapter: ModelAdapter,\n): void {\n if (adapter.chatCompletion.unsupportedUserConfig.length === 0) {\n return;\n }\n\n debugModelAdapter(\n `model adapter \"${modelFamily}\" unsupportedUserConfig: ${JSON.stringify(\n adapter.chatCompletion.unsupportedUserConfig,\n )}`,\n );\n}\n\nexport function getModelAdapter(modelFamily?: TModelFamily): ModelAdapter {\n const cacheKey: ModelAdapterCacheKey = modelFamily ?? 'default';\n let adapter = modelAdapterCache.get(cacheKey);\n if (adapter) {\n return adapter;\n }\n\n const config = modelFamily\n ? MODEL_ADAPTER_CONFIGS[modelFamily]\n : defaultOpenAICompatibleAdapterConfig;\n if (!config) {\n throw new Error(\n `No model adapter registered for modelFamily: ${modelFamily}`,\n );\n }\n\n adapter = new ResolvedModelAdapter(config, cacheKey);\n modelAdapterCache.set(cacheKey, adapter);\n debugAdapterUnsupportedUserConfig(cacheKey, adapter);\n\n return adapter;\n}\n\nexport function getModelRuntime(config: IModelConfig): ModelRuntime {\n return {\n config,\n adapter: getModelAdapter(config.modelFamily),\n };\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","MODEL_ADAPTER_CONFIGS","qwenAdapters","doubaoAdapters","geminiAdapters","uiTarsAdapters","glmAdapters","autoGlmAdapters","gptAdapters","kimiAdapters","mimoAdapters","modelAdapterCache","Map","debugModelAdapter","getDebug","debugAdapterUnsupportedUserConfig","modelFamily","adapter","JSON","getModelAdapter","cacheKey","config","defaultOpenAICompatibleAdapterConfig","Error","ResolvedModel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