@midscene/core 0.26.5-beta-20250814095614.0 → 0.26.5-beta-20250814125155.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 (132) hide show
  1. package/dist/es/ai-model/action-executor.mjs +139 -0
  2. package/dist/es/ai-model/action-executor.mjs.map +1 -0
  3. package/dist/es/ai-model/common.mjs +219 -0
  4. package/dist/es/ai-model/common.mjs.map +1 -0
  5. package/dist/es/ai-model/index.mjs +10 -0
  6. package/dist/es/ai-model/inspect.mjs +317 -0
  7. package/dist/es/ai-model/inspect.mjs.map +1 -0
  8. package/dist/es/ai-model/llm-planning.mjs +85 -0
  9. package/dist/es/ai-model/llm-planning.mjs.map +1 -0
  10. package/dist/es/ai-model/prompt/assertion.mjs +55 -0
  11. package/dist/es/ai-model/prompt/assertion.mjs.map +1 -0
  12. package/dist/es/ai-model/prompt/common.mjs +7 -0
  13. package/dist/es/ai-model/prompt/common.mjs.map +1 -0
  14. package/dist/es/ai-model/prompt/describe.mjs +44 -0
  15. package/dist/es/ai-model/prompt/describe.mjs.map +1 -0
  16. package/dist/es/ai-model/prompt/extraction.mjs +137 -0
  17. package/dist/es/ai-model/prompt/extraction.mjs.map +1 -0
  18. package/dist/es/ai-model/prompt/llm-locator.mjs +275 -0
  19. package/dist/es/ai-model/prompt/llm-locator.mjs.map +1 -0
  20. package/dist/es/ai-model/prompt/llm-planning.mjs +359 -0
  21. package/dist/es/ai-model/prompt/llm-planning.mjs.map +1 -0
  22. package/dist/es/ai-model/prompt/llm-section-locator.mjs +47 -0
  23. package/dist/es/ai-model/prompt/llm-section-locator.mjs.map +1 -0
  24. package/dist/es/ai-model/prompt/playwright-generator.mjs +117 -0
  25. package/dist/es/ai-model/prompt/playwright-generator.mjs.map +1 -0
  26. package/dist/es/ai-model/prompt/ui-tars-locator.mjs +34 -0
  27. package/dist/es/ai-model/prompt/ui-tars-locator.mjs.map +1 -0
  28. package/dist/es/ai-model/prompt/ui-tars-planning.mjs +36 -0
  29. package/dist/es/ai-model/prompt/ui-tars-planning.mjs.map +1 -0
  30. package/dist/es/ai-model/prompt/util.mjs +123 -0
  31. package/dist/es/ai-model/prompt/util.mjs.map +1 -0
  32. package/dist/es/ai-model/prompt/yaml-generator.mjs +219 -0
  33. package/dist/es/ai-model/prompt/yaml-generator.mjs.map +1 -0
  34. package/dist/es/ai-model/service-caller/index.mjs +413 -0
  35. package/dist/es/ai-model/service-caller/index.mjs.map +1 -0
  36. package/dist/es/ai-model/ui-tars-planning.mjs +235 -0
  37. package/dist/es/ai-model/ui-tars-planning.mjs.map +1 -0
  38. package/dist/es/image/index.mjs +2 -0
  39. package/dist/es/index.mjs +7 -2360
  40. package/dist/es/index.mjs.map +1 -1
  41. package/dist/es/insight/index.mjs +261 -0
  42. package/dist/es/insight/index.mjs.map +1 -0
  43. package/dist/es/insight/utils.mjs +19 -0
  44. package/dist/es/insight/utils.mjs.map +1 -0
  45. package/dist/es/types.mjs +11 -0
  46. package/dist/es/types.mjs.map +1 -0
  47. package/dist/es/utils.mjs +2 -2
  48. package/dist/es/yaml.mjs +0 -0
  49. package/dist/lib/ai-model/action-executor.js +173 -0
  50. package/dist/lib/ai-model/action-executor.js.map +1 -0
  51. package/dist/lib/ai-model/common.js +289 -0
  52. package/dist/lib/ai-model/common.js.map +1 -0
  53. package/dist/lib/ai-model/index.js +103 -0
  54. package/dist/lib/ai-model/index.js.map +1 -0
  55. package/dist/lib/ai-model/inspect.js +360 -0
  56. package/dist/lib/ai-model/inspect.js.map +1 -0
  57. package/dist/lib/ai-model/llm-planning.js +119 -0
  58. package/dist/lib/ai-model/llm-planning.js.map +1 -0
  59. package/dist/lib/ai-model/prompt/assertion.js +92 -0
  60. package/dist/lib/ai-model/prompt/assertion.js.map +1 -0
  61. package/dist/lib/ai-model/prompt/common.js +41 -0
  62. package/dist/lib/ai-model/prompt/common.js.map +1 -0
  63. package/dist/lib/ai-model/prompt/describe.js +78 -0
  64. package/dist/lib/ai-model/prompt/describe.js.map +1 -0
  65. package/dist/lib/ai-model/prompt/extraction.js +177 -0
  66. package/dist/lib/ai-model/prompt/extraction.js.map +1 -0
  67. package/dist/lib/ai-model/prompt/llm-locator.js +315 -0
  68. package/dist/lib/ai-model/prompt/llm-locator.js.map +1 -0
  69. package/dist/lib/ai-model/prompt/llm-planning.js +415 -0
  70. package/dist/lib/ai-model/prompt/llm-planning.js.map +1 -0
  71. package/dist/lib/ai-model/prompt/llm-section-locator.js +84 -0
  72. package/dist/lib/ai-model/prompt/llm-section-locator.js.map +1 -0
  73. package/dist/lib/ai-model/prompt/playwright-generator.js +178 -0
  74. package/dist/lib/ai-model/prompt/playwright-generator.js.map +1 -0
  75. package/dist/lib/ai-model/prompt/ui-tars-locator.js +68 -0
  76. package/dist/lib/ai-model/prompt/ui-tars-locator.js.map +1 -0
  77. package/dist/lib/ai-model/prompt/ui-tars-planning.js +73 -0
  78. package/dist/lib/ai-model/prompt/ui-tars-planning.js.map +1 -0
  79. package/dist/lib/ai-model/prompt/util.js +175 -0
  80. package/dist/lib/ai-model/prompt/util.js.map +1 -0
  81. package/dist/lib/ai-model/prompt/yaml-generator.js +280 -0
  82. package/dist/lib/ai-model/prompt/yaml-generator.js.map +1 -0
  83. package/dist/lib/ai-model/service-caller/index.js +496 -0
  84. package/dist/lib/ai-model/service-caller/index.js.map +1 -0
  85. package/dist/lib/ai-model/ui-tars-planning.js +272 -0
  86. package/dist/lib/ai-model/ui-tars-planning.js.map +1 -0
  87. package/dist/lib/image/index.js +56 -0
  88. package/dist/lib/image/index.js.map +1 -0
  89. package/dist/lib/index.js +21 -2393
  90. package/dist/lib/index.js.map +1 -1
  91. package/dist/lib/insight/index.js +295 -0
  92. package/dist/lib/insight/index.js.map +1 -0
  93. package/dist/lib/insight/utils.js +53 -0
  94. package/dist/lib/insight/utils.js.map +1 -0
  95. package/dist/lib/types.js +82 -0
  96. package/dist/lib/types.js.map +1 -0
  97. package/dist/lib/utils.js +2 -2
  98. package/dist/lib/yaml.js +20 -0
  99. package/dist/lib/yaml.js.map +1 -0
  100. package/dist/types/ai-model/action-executor.d.ts +19 -0
  101. package/dist/types/ai-model/common.d.ts +34 -0
  102. package/dist/types/ai-model/index.d.ts +11 -0
  103. package/dist/types/ai-model/inspect.d.ts +49 -0
  104. package/dist/types/ai-model/llm-planning.d.ts +10 -0
  105. package/dist/types/ai-model/prompt/assertion.d.ts +5 -0
  106. package/dist/types/ai-model/prompt/common.d.ts +2 -0
  107. package/dist/types/ai-model/prompt/describe.d.ts +1 -0
  108. package/dist/types/ai-model/prompt/extraction.d.ts +4 -0
  109. package/dist/types/ai-model/prompt/llm-locator.d.ts +9 -0
  110. package/dist/types/ai-model/prompt/llm-planning.d.ts +15 -0
  111. package/dist/types/ai-model/prompt/llm-section-locator.d.ts +6 -0
  112. package/dist/types/ai-model/prompt/playwright-generator.d.ts +25 -0
  113. package/dist/types/ai-model/prompt/ui-tars-locator.d.ts +1 -0
  114. package/dist/types/ai-model/prompt/ui-tars-planning.d.ts +2 -0
  115. package/dist/types/ai-model/prompt/util.d.ts +45 -0
  116. package/dist/types/ai-model/prompt/yaml-generator.d.ts +99 -0
  117. package/dist/types/ai-model/service-caller/index.d.ts +26 -0
  118. package/dist/types/ai-model/ui-tars-planning.d.ts +76 -0
  119. package/dist/types/image/index.d.ts +1 -0
  120. package/dist/types/index.d.ts +9 -1289
  121. package/dist/types/insight/index.d.ts +26 -0
  122. package/dist/types/insight/utils.d.ts +2 -0
  123. package/dist/types/tree.d.ts +1 -11
  124. package/dist/types/types.d.ts +399 -0
  125. package/dist/types/utils.d.ts +27 -47
  126. package/dist/types/yaml.d.ts +172 -0
  127. package/package.json +6 -6
  128. package/dist/es/ai-model.mjs +0 -2502
  129. package/dist/es/ai-model.mjs.map +0 -1
  130. package/dist/lib/ai-model.js +0 -2622
  131. package/dist/lib/ai-model.js.map +0 -1
  132. package/dist/types/ai-model.d.ts +0 -596
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-model/prompt/assertion.js","sources":["webpack://@midscene/core/webpack/runtime/define_property_getters","webpack://@midscene/core/webpack/runtime/has_own_property","webpack://@midscene/core/webpack/runtime/make_namespace_object","webpack://@midscene/core/./src/ai-model/prompt/assertion.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { getPreferredLanguage } from '@midscene/shared/env';\nimport type { ResponseFormatJSONSchema } from 'openai/resources/index';\n\nconst defaultAssertionPrompt =\n 'You are a senior testing engineer. User will give an assertion and a screenshot of a page. By carefully viewing the screenshot, please tell whether the assertion is truthy.';\n\nconst defaultAssertionResponseJsonFormat = `Return in the following JSON format:\n{\n pass: boolean, // whether the assertion is truthy\n thought: string | null, // string, if the result is falsy, give the reason why it is falsy. Otherwise, put null.\n}`;\n\nconst getUiTarsAssertionResponseJsonFormat = () => `## Output Json String Format\n\\`\\`\\`\n\"{\n \"pass\": <<is a boolean value from the enum [true, false], true means the assertion is truthy>>, \n \"thought\": \"<<is a string, give the reason why the assertion is falsy or truthy. Otherwise.>>\"\n}\"\n\\`\\`\\`\n\n## Rules **MUST** follow\n- Make sure to return **only** the JSON, with **no additional** text or explanations.\n- Use ${getPreferredLanguage()} in \\`thought\\` part.\n- You **MUST** strictly follow up the **Output Json String Format**.`;\n\nexport function systemPromptToAssert(model: { isUITars: boolean }) {\n return `${defaultAssertionPrompt}\n\n${model.isUITars ? getUiTarsAssertionResponseJsonFormat() : defaultAssertionResponseJsonFormat}`;\n}\n\nexport const assertSchema: ResponseFormatJSONSchema = {\n type: 'json_schema',\n json_schema: {\n name: 'assert',\n strict: true,\n schema: {\n type: 'object',\n properties: {\n pass: {\n type: 'boolean',\n description: 'Whether the assertion passed or failed',\n },\n thought: {\n type: ['string', 'null'],\n description: 'The thought process behind the assertion',\n },\n },\n required: ['pass', 'thought'],\n additionalProperties: false,\n },\n },\n};\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","defaultAssertionPrompt","defaultAssertionResponseJsonFormat","getUiTarsAssertionResponseJsonFormat","getPreferredLanguage","systemPromptToAssert","model","assertSchema"],"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,yBACJ;AAEF,MAAMC,qCAAqC,CAAC;;;;CAI3C,CAAC;AAEF,MAAMC,uCAAuC,IAAM,CAAC;;;;;;;;;;MAU9C,EAAEC,AAAAA,IAAAA,oBAAAA,oBAAAA,AAAAA,IAAuB;oEACqC,CAAC;AAE9D,SAASC,qBAAqBC,KAA4B;IAC/D,OAAO,GAAGL,uBAAuB;;AAEnC,EAAEK,MAAM,QAAQ,GAAGH,yCAAyCD,oCAAoC;AAChG;AAEO,MAAMK,eAAyC;IACpD,MAAM;IACN,aAAa;QACX,MAAM;QACN,QAAQ;QACR,QAAQ;YACN,MAAM;YACN,YAAY;gBACV,MAAM;oBACJ,MAAM;oBACN,aAAa;gBACf;gBACA,SAAS;oBACP,MAAM;wBAAC;wBAAU;qBAAO;oBACxB,aAAa;gBACf;YACF;YACA,UAAU;gBAAC;gBAAQ;aAAU;YAC7B,sBAAsB;QACxB;IACF;AACF"}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ bboxDescription: ()=>bboxDescription
28
+ });
29
+ function bboxDescription(vlMode) {
30
+ if ('gemini' === vlMode) return '2d bounding box as [ymin, xmin, ymax, xmax]';
31
+ return '2d bounding box as [xmin, ymin, xmax, ymax]';
32
+ }
33
+ exports.bboxDescription = __webpack_exports__.bboxDescription;
34
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
35
+ "bboxDescription"
36
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
37
+ Object.defineProperty(exports, '__esModule', {
38
+ value: true
39
+ });
40
+
41
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-model/prompt/common.js","sources":["webpack://@midscene/core/webpack/runtime/define_property_getters","webpack://@midscene/core/webpack/runtime/has_own_property","webpack://@midscene/core/webpack/runtime/make_namespace_object","webpack://@midscene/core/./src/ai-model/prompt/common.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 { vlLocateMode } from '@midscene/shared/env';\nexport function bboxDescription(vlMode: ReturnType<typeof vlLocateMode>) {\n if (vlMode === 'gemini') {\n return '2d bounding box as [ymin, xmin, ymax, xmax]';\n }\n return '2d bounding box as [xmin, ymin, xmax, ymax]';\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","bboxDescription","vlMode"],"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;;;;;;;ACLO,SAASI,gBAAgBC,MAAuC;IACrE,IAAIA,AAAW,aAAXA,QACF,OAAO;IAET,OAAO;AACT"}
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ elementDescriberInstruction: ()=>elementDescriberInstruction
28
+ });
29
+ const env_namespaceObject = require("@midscene/shared/env");
30
+ const elementDescriberInstruction = ()=>`
31
+ Describe the element in the red rectangle for precise identification. Use ${(0, env_namespaceObject.getPreferredLanguage)()}.
32
+
33
+ CRITICAL REQUIREMENTS:
34
+ 1. UNIQUENESS: The description must uniquely identify this element on the current page
35
+ 2. UNIVERSALITY: Use generic, reusable selectors that work across different contexts
36
+ 3. PRECISION: Be specific enough to distinguish from similar elements
37
+
38
+ DESCRIPTION STRUCTURE:
39
+ 1. Element type (button, input, link, div, etc.)
40
+ 2. Primary identifier (in order of preference):
41
+ - Unique text content: "with text 'Login'"
42
+ - Unique attribute: "with aria-label 'Search'"
43
+ - Unique class/ID: "with class 'primary-button'"
44
+ - Unique position: "in header navigation"
45
+ 3. Secondary identifiers (if needed for uniqueness):
46
+ - Visual features: "blue background", "with icon"
47
+ - Relative position: "below search bar", "in sidebar"
48
+ - Parent context: "in login form", "in main menu"
49
+
50
+ GUIDELINES:
51
+ - Keep description under 25 words
52
+ - Prioritize semantic identifiers over visual ones
53
+ - Use consistent terminology across similar elements
54
+ - Avoid page-specific or temporary content
55
+ - Don't mention the red rectangle or selection box
56
+ - Focus on stable, reusable characteristics
57
+
58
+ EXAMPLES:
59
+ - "Login button with text 'Sign In'"
60
+ - "Search input with placeholder 'Enter keywords'"
61
+ - "Navigation link with text 'Home' in header"
62
+ - "Submit button in contact form"
63
+ - "Menu icon with aria-label 'Open menu'"
64
+
65
+ Return JSON:
66
+ {
67
+ "description": "unique element identifier",
68
+ "error"?: "error message if any"
69
+ }`;
70
+ exports.elementDescriberInstruction = __webpack_exports__.elementDescriberInstruction;
71
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
72
+ "elementDescriberInstruction"
73
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
74
+ Object.defineProperty(exports, '__esModule', {
75
+ value: true
76
+ });
77
+
78
+ //# sourceMappingURL=describe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-model/prompt/describe.js","sources":["webpack://@midscene/core/webpack/runtime/define_property_getters","webpack://@midscene/core/webpack/runtime/has_own_property","webpack://@midscene/core/webpack/runtime/make_namespace_object","webpack://@midscene/core/./src/ai-model/prompt/describe.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { getPreferredLanguage } from '@midscene/shared/env';\n\nexport const elementDescriberInstruction = () => {\n return `\nDescribe the element in the red rectangle for precise identification. Use ${getPreferredLanguage()}.\n\nCRITICAL REQUIREMENTS:\n1. UNIQUENESS: The description must uniquely identify this element on the current page\n2. UNIVERSALITY: Use generic, reusable selectors that work across different contexts\n3. PRECISION: Be specific enough to distinguish from similar elements\n\nDESCRIPTION STRUCTURE:\n1. Element type (button, input, link, div, etc.)\n2. Primary identifier (in order of preference):\n - Unique text content: \"with text 'Login'\"\n - Unique attribute: \"with aria-label 'Search'\"\n - Unique class/ID: \"with class 'primary-button'\"\n - Unique position: \"in header navigation\"\n3. Secondary identifiers (if needed for uniqueness):\n - Visual features: \"blue background\", \"with icon\"\n - Relative position: \"below search bar\", \"in sidebar\"\n - Parent context: \"in login form\", \"in main menu\"\n\nGUIDELINES:\n- Keep description under 25 words\n- Prioritize semantic identifiers over visual ones\n- Use consistent terminology across similar elements\n- Avoid page-specific or temporary content\n- Don't mention the red rectangle or selection box\n- Focus on stable, reusable characteristics\n\nEXAMPLES:\n- \"Login button with text 'Sign In'\"\n- \"Search input with placeholder 'Enter keywords'\"\n- \"Navigation link with text 'Home' in header\"\n- \"Submit button in contact form\"\n- \"Menu icon with aria-label 'Open menu'\"\n\nReturn JSON:\n{\n \"description\": \"unique element identifier\",\n \"error\"?: \"error message if any\"\n}`;\n};\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","elementDescriberInstruction","getPreferredLanguage"],"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,8BAA8B,IAClC,CAAC;0EACgE,EAAEC,AAAAA,IAAAA,oBAAAA,oBAAAA,AAAAA,IAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsClG,CAAC"}
@@ -0,0 +1,177 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ systemPromptToExtract: ()=>systemPromptToExtract,
28
+ extractDataSchema: ()=>extractDataSchema,
29
+ extractDataQueryPrompt: ()=>extractDataQueryPrompt
30
+ });
31
+ const prompts_namespaceObject = require("@langchain/core/prompts");
32
+ function systemPromptToExtract() {
33
+ return `
34
+ You are a versatile professional in software UI design and testing. Your outstanding contributions will impact the user experience of billions of users.
35
+
36
+ The user will give you a screenshot, the contents of it (optional), and some data requirements in <DATA_DEMAND>. You need to extract the data according to the <DATA_DEMAND>.
37
+
38
+ If a key specifies a JSON data type (such as Number, String, Boolean, Object, Array), ensure the returned value strictly matches that data type.
39
+
40
+ If the user provides multiple reference images, please carefully review the reference images with the screenshot and provide the correct answer for <DATA_DEMAND>.
41
+
42
+ If the user requests reasons to be provided, please provide the thought field in response, less then 100 words.
43
+
44
+ Return in the following JSON format:
45
+ {
46
+ thought: string, // the thought process of the extraction, less then 100 words, not required by default.
47
+ data: any, // the extracted data. Make sure both the value and scheme meet the DATA_DEMAND. If you want to write some description in this field, use the same language as the DATA_DEMAND.
48
+ errors: [], // string[], error message if any
49
+ }
50
+
51
+ # Example 1
52
+ For example, if the DATA_DEMAND is:
53
+
54
+ <DATA_DEMAND>
55
+ {
56
+ "name": "name shows on the left panel, string",
57
+ "age": "age shows on the right panel, number",
58
+ "isAdmin": "if the user is admin, boolean"
59
+ }
60
+ </DATA_DEMAND>
61
+
62
+ By viewing the screenshot and page contents, you can extract the following data:
63
+
64
+ {
65
+ data: {
66
+ name: "John",
67
+ age: 30,
68
+ isAdmin: true
69
+ },
70
+ }
71
+
72
+ # Example 2
73
+ If the DATA_DEMAND is:
74
+
75
+ <DATA_DEMAND>
76
+ the todo items list, string[]
77
+ </DATA_DEMAND>
78
+
79
+ By viewing the screenshot and page contents, you can extract the following data:
80
+
81
+ {
82
+ data: ["todo 1", "todo 2", "todo 3"],
83
+ }
84
+
85
+ # Example 3
86
+ If the DATA_DEMAND is:
87
+
88
+ <DATA_DEMAND>
89
+ the page title, string
90
+ </DATA_DEMAND>
91
+
92
+ By viewing the screenshot and page contents, you can extract the following data:
93
+
94
+ {
95
+ data: "todo list",
96
+ }
97
+
98
+ # Example 4
99
+ If the DATA_DEMAND is:
100
+
101
+ <DATA_DEMAND>
102
+ {
103
+ "result": "Boolean, is it currently the SMS page?"
104
+ }
105
+ </DATA_DEMAND>
106
+
107
+ By viewing the screenshot and page contents, you can extract the following data:
108
+
109
+ {
110
+ data: { result: true },
111
+ }
112
+ `;
113
+ }
114
+ const extractDataQueryPrompt = async (pageDescription, dataQuery)=>{
115
+ let dataQueryText = '';
116
+ dataQueryText = 'string' == typeof dataQuery ? dataQuery : JSON.stringify(dataQuery, null, 2);
117
+ const extractDataPrompt = new prompts_namespaceObject.PromptTemplate({
118
+ template: `
119
+ <PageDescription>
120
+ {pageDescription}
121
+ </PageDescription>
122
+
123
+ <DATA_DEMAND>
124
+ {dataQuery}
125
+ </DATA_DEMAND>
126
+ `,
127
+ inputVariables: [
128
+ "pageDescription",
129
+ 'dataQuery'
130
+ ]
131
+ });
132
+ return await extractDataPrompt.format({
133
+ pageDescription,
134
+ dataQuery: dataQueryText
135
+ });
136
+ };
137
+ const extractDataSchema = {
138
+ type: 'json_schema',
139
+ json_schema: {
140
+ name: 'extract_data',
141
+ strict: true,
142
+ schema: {
143
+ type: 'object',
144
+ properties: {
145
+ data: {
146
+ type: 'object',
147
+ description: 'The extracted data'
148
+ },
149
+ errors: {
150
+ type: 'array',
151
+ items: {
152
+ type: 'string'
153
+ },
154
+ description: 'Error messages, if any'
155
+ }
156
+ },
157
+ required: [
158
+ 'data',
159
+ 'errors'
160
+ ],
161
+ additionalProperties: false
162
+ }
163
+ }
164
+ };
165
+ exports.extractDataQueryPrompt = __webpack_exports__.extractDataQueryPrompt;
166
+ exports.extractDataSchema = __webpack_exports__.extractDataSchema;
167
+ exports.systemPromptToExtract = __webpack_exports__.systemPromptToExtract;
168
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
169
+ "extractDataQueryPrompt",
170
+ "extractDataSchema",
171
+ "systemPromptToExtract"
172
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
173
+ Object.defineProperty(exports, '__esModule', {
174
+ value: true
175
+ });
176
+
177
+ //# sourceMappingURL=extraction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-model/prompt/extraction.js","sources":["webpack://@midscene/core/webpack/runtime/define_property_getters","webpack://@midscene/core/webpack/runtime/has_own_property","webpack://@midscene/core/webpack/runtime/make_namespace_object","webpack://@midscene/core/./src/ai-model/prompt/extraction.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { PromptTemplate } from '@langchain/core/prompts';\nimport type { ResponseFormatJSONSchema } from 'openai/resources/index';\n\nexport function systemPromptToExtract() {\n return `\nYou are a versatile professional in software UI design and testing. Your outstanding contributions will impact the user experience of billions of users.\n\nThe user will give you a screenshot, the contents of it (optional), and some data requirements in <DATA_DEMAND>. You need to extract the data according to the <DATA_DEMAND>.\n\nIf a key specifies a JSON data type (such as Number, String, Boolean, Object, Array), ensure the returned value strictly matches that data type.\n\nIf the user provides multiple reference images, please carefully review the reference images with the screenshot and provide the correct answer for <DATA_DEMAND>.\n\nIf the user requests reasons to be provided, please provide the thought field in response, less then 100 words.\n\nReturn in the following JSON format:\n{\n thought: string, // the thought process of the extraction, less then 100 words, not required by default.\n data: any, // the extracted data. Make sure both the value and scheme meet the DATA_DEMAND. If you want to write some description in this field, use the same language as the DATA_DEMAND.\n errors: [], // string[], error message if any\n}\n\n# Example 1\nFor example, if the DATA_DEMAND is:\n\n<DATA_DEMAND>\n{\n \"name\": \"name shows on the left panel, string\",\n \"age\": \"age shows on the right panel, number\",\n \"isAdmin\": \"if the user is admin, boolean\"\n}\n</DATA_DEMAND>\n\nBy viewing the screenshot and page contents, you can extract the following data:\n\n{\n data: {\n name: \"John\",\n age: 30,\n isAdmin: true\n },\n}\n\n# Example 2\nIf the DATA_DEMAND is:\n\n<DATA_DEMAND>\nthe todo items list, string[]\n</DATA_DEMAND>\n\nBy viewing the screenshot and page contents, you can extract the following data:\n\n{\n data: [\"todo 1\", \"todo 2\", \"todo 3\"],\n}\n\n# Example 3\nIf the DATA_DEMAND is:\n\n<DATA_DEMAND>\nthe page title, string\n</DATA_DEMAND>\n\nBy viewing the screenshot and page contents, you can extract the following data:\n\n{\n data: \"todo list\",\n}\n\n# Example 4\nIf the DATA_DEMAND is:\n\n<DATA_DEMAND>\n{\n \"result\": \"Boolean, is it currently the SMS page?\"\n}\n</DATA_DEMAND>\n\nBy viewing the screenshot and page contents, you can extract the following data:\n\n{\n data: { result: true },\n}\n`;\n}\n\nexport const extractDataQueryPrompt = async (\n pageDescription: string,\n dataQuery: string | Record<string, string>,\n) => {\n let dataQueryText = '';\n if (typeof dataQuery === 'string') {\n dataQueryText = dataQuery;\n } else {\n dataQueryText = JSON.stringify(dataQuery, null, 2);\n }\n const extractDataPrompt = new PromptTemplate({\n template: `\n<PageDescription>\n{pageDescription}\n</PageDescription>\n\n<DATA_DEMAND>\n{dataQuery}\n</DATA_DEMAND>\n `,\n inputVariables: ['pageDescription', 'dataQuery'],\n });\n\n return await extractDataPrompt.format({\n pageDescription,\n dataQuery: dataQueryText,\n });\n};\n\nexport const extractDataSchema: ResponseFormatJSONSchema = {\n type: 'json_schema',\n json_schema: {\n name: 'extract_data',\n strict: true,\n schema: {\n type: 'object',\n properties: {\n data: {\n type: 'object',\n description: 'The extracted data',\n },\n errors: {\n type: 'array',\n items: {\n type: 'string',\n },\n description: 'Error messages, if any',\n },\n },\n required: ['data', 'errors'],\n additionalProperties: false,\n },\n },\n};\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","systemPromptToExtract","extractDataQueryPrompt","pageDescription","dataQuery","dataQueryText","JSON","extractDataPrompt","PromptTemplate","extractDataSchema"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;ACHO,SAASI;IACd,OAAO,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+EV,CAAC;AACD;AAEO,MAAMC,yBAAyB,OACpCC,iBACAC;IAEA,IAAIC,gBAAgB;IAElBA,gBADE,AAAqB,YAArB,OAAOD,YACOA,YAEAE,KAAK,SAAS,CAACF,WAAW,MAAM;IAElD,MAAMG,oBAAoB,IAAIC,wBAAAA,cAAcA,CAAC;QAC3C,UAAU,CAAC;;;;;;;;EAQb,CAAC;QACC,gBAAgB;YAAC;YAAmB;SAAY;IAClD;IAEA,OAAO,MAAMD,kBAAkB,MAAM,CAAC;QACpCJ;QACA,WAAWE;IACb;AACF;AAEO,MAAMI,oBAA8C;IACzD,MAAM;IACN,aAAa;QACX,MAAM;QACN,QAAQ;QACR,QAAQ;YACN,MAAM;YACN,YAAY;gBACV,MAAM;oBACJ,MAAM;oBACN,aAAa;gBACf;gBACA,QAAQ;oBACN,MAAM;oBACN,OAAO;wBACL,MAAM;oBACR;oBACA,aAAa;gBACf;YACF;YACA,UAAU;gBAAC;gBAAQ;aAAS;YAC5B,sBAAsB;QACxB;IACF;AACF"}
@@ -0,0 +1,315 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ findElementPrompt: ()=>findElementPrompt,
28
+ locatorSchema: ()=>locatorSchema,
29
+ systemPromptToLocateElement: ()=>systemPromptToLocateElement
30
+ });
31
+ const prompts_namespaceObject = require("@langchain/core/prompts");
32
+ const external_common_js_namespaceObject = require("./common.js");
33
+ function systemPromptToLocateElement(vlMode) {
34
+ if (vlMode) {
35
+ const bboxComment = (0, external_common_js_namespaceObject.bboxDescription)(vlMode);
36
+ return `
37
+ ## Role:
38
+ You are an expert in software testing.
39
+
40
+ ## Objective:
41
+ - Identify elements in screenshots and text that match the user's description.
42
+ - Give the coordinates of the element that matches the user's description best in the screenshot.
43
+ - Determine whether the user's description is order-sensitive (e.g., contains phrases like 'the third item in the list', 'the last button', etc.).
44
+
45
+ ## Output Format:
46
+ \`\`\`json
47
+ {
48
+ "bbox": [number, number, number, number], // ${bboxComment}
49
+ "errors"?: string[],
50
+ "isOrderSensitive": boolean // Whether the targetElementDescription is order-sensitive (true/false)
51
+ }
52
+ \`\`\`
53
+
54
+ Fields:
55
+ * \`bbox\` is the bounding box of the element that matches the user's description best in the screenshot
56
+ * \`isOrderSensitive\` is a boolean indicating whether the user's description is order-sensitive (true/false)
57
+ * \`errors\` is an optional array of error messages (if any)
58
+
59
+ Order-sensitive means the description contains phrases like:
60
+ - "the third item in the list"
61
+ - "the last button"
62
+ - "the first input box"
63
+ - "the second row"
64
+
65
+ Not order-sensitive means the description is like:
66
+ - "confirm button"
67
+ - "search box"
68
+ - "password input"
69
+
70
+ For example, when an element is found and the description is order-sensitive:
71
+ \`\`\`json
72
+ {
73
+ "bbox": [100, 100, 200, 200],
74
+ "isOrderSensitive": true,
75
+ "errors": []
76
+ }
77
+ \`\`\`
78
+
79
+ When no element is found and the description is not order-sensitive:
80
+ \`\`\`json
81
+ {
82
+ "bbox": [],
83
+ "isOrderSensitive": false,
84
+ "errors": ["I can see ..., but {some element} is not found"]
85
+ }
86
+ \`\`\`
87
+ `;
88
+ }
89
+ return `
90
+ ## Role:
91
+ You are an expert in software page image (2D) and page element text analysis.
92
+
93
+ ## Objective:
94
+ - Identify elements in screenshots and text that match the user's description.
95
+ - Return JSON data containing the selection reason and element ID.
96
+ - Determine whether the user's description is order-sensitive (e.g., contains phrases like 'the third item in the list', 'the last button', etc.).
97
+
98
+ ## Skills:
99
+ - Image analysis and recognition
100
+ - Multilingual text understanding
101
+ - Software UI design and testing
102
+
103
+ ## Workflow:
104
+ 1. Receive the user's element description, screenshot, and element description information. Note that the text may contain non-English characters (e.g., Chinese), indicating that the application may be non-English.
105
+ 2. Based on the user's description, locate the target element ID in the list of element descriptions and the screenshot.
106
+ 3. Found the required number of elements
107
+ 4. Return JSON data containing the selection reason and element ID.
108
+ 5. Judge whether the user's description is order-sensitive (see below for definition and examples).
109
+
110
+ ## Constraints:
111
+ - Strictly adhere to the specified location when describing the required element; do not select elements from other locations.
112
+ - Elements in the image with NodeType other than "TEXT Node" have been highlighted to identify the element among multiple non-text elements.
113
+ - Accurately identify element information based on the user's description and return the corresponding element ID from the element description information, not extracted from the image.
114
+ - If no elements are found, the "elements" array should be empty.
115
+ - The returned data must conform to the specified JSON format.
116
+ - The returned value id information must use the id from element info (important: **use id not indexId, id is hash content**)
117
+
118
+ ## Order-Sensitive Definition:
119
+ - If the description contains phrases like "the third item in the list", "the last button", "the first input box", "the second row", etc., it is order-sensitive (isOrderSensitive = true).
120
+ - If the description is like "confirm button", "search box", "password input", etc., it is not order-sensitive (isOrderSensitive = false).
121
+
122
+ ## Output Format:
123
+
124
+ Please return the result in JSON format as follows:
125
+
126
+ \`\`\`json
127
+ {
128
+ "elements": [
129
+ // If no matching elements are found, return an empty array []
130
+ {
131
+ "reason": "PLACEHOLDER", // The thought process for finding the element, replace PLACEHOLDER with your thought process
132
+ "text": "PLACEHOLDER", // Replace PLACEHOLDER with the text of elementInfo, if none, leave empty
133
+ "id": "PLACEHOLDER" // Replace PLACEHOLDER with the ID (important: **use id not indexId, id is hash content**) of elementInfo
134
+ }
135
+ // More elements...
136
+ ],
137
+ "isOrderSensitive": true, // or false, depending on the user's description
138
+ "errors": [] // Array of strings containing any error messages
139
+ }
140
+ \`\`\`
141
+
142
+ ## Example:
143
+ Example 1:
144
+ Input Example:
145
+ \`\`\`json
146
+ // Description: "Shopping cart icon in the upper right corner"
147
+ {
148
+ "description": "PLACEHOLDER", // Description of the target element
149
+ "screenshot": "path/screenshot.png",
150
+ "text": '{
151
+ "pageSize": {
152
+ "width": 400, // Width of the page
153
+ "height": 905 // Height of the page
154
+ },
155
+ "elementInfos": [
156
+ {
157
+ "id": "1231", // ID of the element
158
+ "indexId": "0", // Index of the element\u{FF0C}The image is labeled to the left of the element
159
+ "attributes": { // Attributes of the element
160
+ "nodeType": "IMG Node", // Type of element, types include: TEXT Node, IMG Node, BUTTON Node, INPUT Node
161
+ "src": "https://ap-southeast-3.m",
162
+ "class": ".img"
163
+ },
164
+ "content": "", // Text content of the element
165
+ "rect": {
166
+ "left": 280, // Distance from the left side of the page
167
+ "top": 8, // Distance from the top of the page
168
+ "width": 44, // Width of the element
169
+ "height": 44 // Height of the element
170
+ }
171
+ },
172
+ {
173
+ "id": "66551", // ID of the element
174
+ "indexId": "1", // Index of the element,The image is labeled to the left of the element
175
+ "attributes": { // Attributes of the element
176
+ "nodeType": "IMG Node", // Type of element, types include: TEXT Node, IMG Node, BUTTON Node, INPUT Node
177
+ "src": "data:image/png;base64,iVBORw0KGgoAAAANSU...",
178
+ "class": ".icon"
179
+ },
180
+ "content": "", // Text content of the element
181
+ "rect": {
182
+ "left": 350, // Distance from the left side of the page
183
+ "top": 16, // Distance from the top of the page
184
+ "width": 25, // Width of the element
185
+ "height": 25 // Height of the element
186
+ }
187
+ },
188
+ ...
189
+ {
190
+ "id": "12344",
191
+ "indexId": "2", // Index of the element\u{FF0C}The image is labeled to the left of the element
192
+ "attributes": {
193
+ "nodeType": "TEXT Node",
194
+ "class": ".product-name"
195
+ },
196
+ "center": [
197
+ 288,
198
+ 834
199
+ ],
200
+ "content": "Mango Drink",
201
+ "rect": {
202
+ "left": 188,
203
+ "top": 827,
204
+ "width": 199,
205
+ "height": 13
206
+ }
207
+ },
208
+ ...
209
+ ]
210
+ }
211
+ '
212
+ }
213
+ \`\`\`
214
+ Output Example:
215
+ \`\`\`json
216
+ {
217
+ "elements": [
218
+ {
219
+ // Describe the reason for finding this element, replace with actual value in practice
220
+ "reason": "Reason for finding element 4: It is located in the upper right corner, is an image type, and according to the screenshot, it is a shopping cart icon button",
221
+ "text": "",
222
+ // ID(**use id not indexId**) of this element, replace with actual value in practice, **use id not indexId**
223
+ "id": "1231"
224
+ }
225
+ ],
226
+ "isOrderSensitive": true,
227
+ "errors": []
228
+ }
229
+ \`\`\`
230
+
231
+ `;
232
+ }
233
+ const locatorSchema = {
234
+ type: 'json_schema',
235
+ json_schema: {
236
+ name: 'find_elements',
237
+ strict: true,
238
+ schema: {
239
+ type: 'object',
240
+ properties: {
241
+ elements: {
242
+ type: 'array',
243
+ items: {
244
+ type: 'object',
245
+ properties: {
246
+ reason: {
247
+ type: 'string',
248
+ description: 'Reason for finding this element'
249
+ },
250
+ text: {
251
+ type: 'string',
252
+ description: 'Text content of the element'
253
+ },
254
+ id: {
255
+ type: 'string',
256
+ description: 'ID of this element'
257
+ }
258
+ },
259
+ required: [
260
+ 'reason',
261
+ 'text',
262
+ 'id'
263
+ ],
264
+ additionalProperties: false
265
+ },
266
+ description: 'List of found elements'
267
+ },
268
+ isOrderSensitive: {
269
+ type: 'boolean',
270
+ description: "Whether the targetElementDescription is order-sensitive (true/false)"
271
+ },
272
+ errors: {
273
+ type: 'array',
274
+ items: {
275
+ type: 'string'
276
+ },
277
+ description: 'List of error messages, if any'
278
+ }
279
+ },
280
+ required: [
281
+ 'elements',
282
+ 'isOrderSensitive',
283
+ 'errors'
284
+ ],
285
+ additionalProperties: false
286
+ }
287
+ }
288
+ };
289
+ const findElementPrompt = new prompts_namespaceObject.PromptTemplate({
290
+ template: `
291
+ Here is the item user want to find:
292
+ =====================================
293
+ {targetElementDescription}
294
+ =====================================
295
+
296
+ {pageDescription}
297
+ `,
298
+ inputVariables: [
299
+ "pageDescription",
300
+ "targetElementDescription"
301
+ ]
302
+ });
303
+ exports.findElementPrompt = __webpack_exports__.findElementPrompt;
304
+ exports.locatorSchema = __webpack_exports__.locatorSchema;
305
+ exports.systemPromptToLocateElement = __webpack_exports__.systemPromptToLocateElement;
306
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
307
+ "findElementPrompt",
308
+ "locatorSchema",
309
+ "systemPromptToLocateElement"
310
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
311
+ Object.defineProperty(exports, '__esModule', {
312
+ value: true
313
+ });
314
+
315
+ //# sourceMappingURL=llm-locator.js.map