@midscene/core 0.24.1-beta-20250729081015.0 → 0.24.1-beta-20250730043959.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.
- package/dist/es/ai-model.d.ts +3 -3
- package/dist/es/ai-model.js +1 -1
- package/dist/es/{chunk-SI7ZG3EP.js → chunk-NHTJEDSA.js} +9 -6
- package/dist/es/chunk-NHTJEDSA.js.map +1 -0
- package/dist/es/{chunk-GPQNKTL4.js → chunk-TV47VKQ7.js} +8 -61
- package/dist/es/chunk-TV47VKQ7.js.map +1 -0
- package/dist/es/index.d.ts +4 -4
- package/dist/es/index.js +4 -12
- package/dist/es/index.js.map +1 -1
- package/dist/es/{llm-planning-7d13d5ff.d.ts → llm-planning-3407bd42.d.ts} +1 -2
- package/dist/es/{types-8d202846.d.ts → types-4d9c9a85.d.ts} +0 -4
- package/dist/es/utils.d.ts +1 -1
- package/dist/es/utils.js +1 -1
- package/dist/lib/ai-model.d.ts +3 -3
- package/dist/lib/ai-model.js +2 -2
- package/dist/lib/{chunk-SI7ZG3EP.js → chunk-NHTJEDSA.js} +7 -4
- package/dist/lib/chunk-NHTJEDSA.js.map +1 -0
- package/dist/lib/{chunk-GPQNKTL4.js → chunk-TV47VKQ7.js} +8 -61
- package/dist/lib/chunk-TV47VKQ7.js.map +1 -0
- package/dist/lib/index.d.ts +4 -4
- package/dist/lib/index.js +13 -21
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/{llm-planning-7d13d5ff.d.ts → llm-planning-3407bd42.d.ts} +1 -2
- package/dist/{types/types-8d202846.d.ts → lib/types-4d9c9a85.d.ts} +0 -4
- package/dist/lib/utils.d.ts +1 -1
- package/dist/lib/utils.js +2 -2
- package/dist/types/ai-model.d.ts +3 -3
- package/dist/types/index.d.ts +4 -4
- package/dist/types/{llm-planning-7d13d5ff.d.ts → llm-planning-3407bd42.d.ts} +1 -2
- package/dist/{lib/types-8d202846.d.ts → types/types-4d9c9a85.d.ts} +0 -4
- package/dist/types/utils.d.ts +1 -1
- package/package.json +4 -4
- package/dist/es/chunk-GPQNKTL4.js.map +0 -1
- package/dist/es/chunk-SI7ZG3EP.js.map +0 -1
- package/dist/lib/chunk-GPQNKTL4.js.map +0 -1
- package/dist/lib/chunk-SI7ZG3EP.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"mappings":";AAAA,SAAS,gBAAgB;AACzB,YAAY,QAAQ;AACpB,SAAS,YAAY,WAAW,gBAAAA,eAAc,qBAAqB;AACnE,SAAS,cAAc;AACvB,YAAY,UAAU;AACtB,SAAS,eAAe;AACxB;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,yBAAyB;AAClC,SAAS,QAAQ,cAAc;AAC/B,SAAS,iBAAiB,aAAa,YAAY;AAGnD,IAAI,cAAc;AAEX,IAAM,2BAA2B;AAExC,IAAM,uBAAuB,oBAAI,IAAqB;AAItD,SAAS,eAAe;AACtB,MAAI,IAAqB;AACvB,WAAU,gBAAa,IAAqB,OAAO;AAAA,EACrD;AACA,QAAM,YAAY;AAElB,SAAO;AACT;AAMO,SAAS,8BACd,UACA,eACM;AACN,QAAM,aAAa;AACnB,QAAM,OAAU,YAAS,QAAQ;AAEjC,QAAM,WAAW,KAAK,IAAI,KAAK,MAAM,IAAI;AACzC,QAAM,QAAQ,KAAK,IAAI,GAAG,KAAK,OAAO,QAAQ;AAC9C,QAAM,SAAS,OAAO,MAAM,KAAK,OAAO,KAAK;AAC7C,QAAM,KAAQ,YAAS,UAAU,GAAG;AACpC,EAAG,YAAS,IAAI,QAAQ,GAAG,OAAO,QAAQ,KAAK;AAC/C,EAAG,aAAU,EAAE;AAEf,QAAM,UAAU,OAAO,SAAS,MAAM;AACtC,QAAM,aAAa,QAAQ,YAAY,UAAU;AACjD,MAAI,eAAe,IAAI;AACrB,UAAM,IAAI,MAAM,4BAA4B,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AAC7D,SAAO,KAAK,UAAU,MAAM,uBAAuB,OAAO;AAC5D;AAIO,SAAS,aAAa;AAC3B,SAAO;AACT;AAEA,SAAS,YAAY,SAAgB;AACnC,QAAM,YAAY,YAAY,mBAAmB;AACjD,MAAI,WAAW;AACb,YAAQ,IAAI,cAAc,GAAG,OAAO;AAAA,EACtC;AACF;AAEA,IAAI,sBAAsB;AACnB,SAAS,uBAAuB,EAAE,QAAQ,GAAwB;AACvE,MAAI,UAAU;AACd,MAAI,YAAY;AAEhB,QAAM,cAAc,kBAAkB,gCAAgC;AACtE,QAAM,YAAY,aAAa;AAE/B,MAAI;AACF,cAAU,SAAS,oCAAoC,EAAE,SAAS,EAAE,KAAK;AACzE,gBAAY,SAAS,6BAA6B,EAAE,SAAS,EAAE,KAAK;AAAA,EACtE,SAAS,OAAO;AACd,aAAS,2BAA2B,KAAK;AAAA,EAC3C;AAOA,MACE,cACE,WAAW,YAAY,uBAAyB,CAAC,WAAW,UAC9D;AACA,aAAS,iCAAiC;AAAA,MACxC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,UAAM,WAAW;AAAA,MACf,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,gBAAgB;AAAA,MAClB;AAAA,MACA,MAAM,KAAK,UAAU;AAAA,QACnB,UAAU;AAAA,QACV,UAAU;AAAA,QACV,YAAY;AAAA,MACd,CAAC;AAAA,IACH,CAAC,EACE,KAAK,CAAC,aAAa,SAAS,KAAK,CAAC,EAClC,KAAK,CAAC,SAAS;AACd,eAAS,8CAA8C,IAAI;AAAA,IAC7D,CAAC,EACA;AAAA,MAAM,CAAC,UACN,SAAS,yCAAyC,KAAK;AAAA,IACzD;AACF,0BAAsB;AAAA,EACxB;AACF","names":["readFileSync"],"ignoreList":[],"sources":["../../src/utils.ts"],"sourcesContent":["import { execSync } from 'node:child_process';\nimport * as fs from 'node:fs';\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { tmpdir } from 'node:os';\nimport * as path from 'node:path';\nimport { dirname } from 'node:path';\nimport {\n defaultRunDirName,\n getMidsceneRunSubDir,\n} from '@midscene/shared/common';\nimport {\n MIDSCENE_DEBUG_MODE,\n MIDSCENE_OPENAI_INIT_CONFIG_JSON,\n getAIConfig,\n getAIConfigInJson,\n} from '@midscene/shared/env';\nimport { getRunningPkgInfo } from '@midscene/shared/fs';\nimport { assert, logMsg } from '@midscene/shared/utils';\nimport { escapeScriptTag, ifInBrowser, uuid } from '@midscene/shared/utils';\nimport type { Rect, ReportDumpWithAttributes } from './types';\n\nlet logEnvReady = false;\n\nexport const groupedActionDumpFileExt = 'web-dump.json';\n\nconst reportInitializedMap = new Map<string, boolean>();\n\ndeclare const __DEV_REPORT_PATH__: string;\n\nfunction getReportTpl() {\n if (__DEV_REPORT_PATH__) {\n return fs.readFileSync(__DEV_REPORT_PATH__, 'utf-8');\n }\n const reportTpl = 'REPLACE_ME_WITH_REPORT_HTML';\n\n return reportTpl;\n}\n\n/**\n * high performance, insert script before </html> in HTML file\n * only truncate and append, no temporary file\n */\nexport function insertScriptBeforeClosingHtml(\n filePath: string,\n scriptContent: string,\n): void {\n const htmlEndTag = '</html>';\n const stat = fs.statSync(filePath);\n\n const readSize = Math.min(stat.size, 4096);\n const start = Math.max(0, stat.size - readSize);\n const buffer = Buffer.alloc(stat.size - start);\n const fd = fs.openSync(filePath, 'r');\n fs.readSync(fd, buffer, 0, buffer.length, start);\n fs.closeSync(fd);\n\n const tailStr = buffer.toString('utf8');\n const htmlEndIdx = tailStr.lastIndexOf(htmlEndTag);\n if (htmlEndIdx === -1) {\n throw new Error(`No </html> found in file:${filePath}`);\n }\n\n // calculate the correct byte position: char position to byte position\n const beforeHtmlInTail = tailStr.slice(0, htmlEndIdx);\n const htmlEndPos = start + Buffer.byteLength(beforeHtmlInTail, 'utf8');\n\n // truncate to </html> before\n fs.truncateSync(filePath, htmlEndPos);\n // append script and </html>\n fs.appendFileSync(filePath, `${scriptContent}\\n${htmlEndTag}\\n`);\n}\n\nexport function reportHTMLContent(\n dumpData: string | ReportDumpWithAttributes,\n reportPath?: string,\n appendReport?: boolean,\n): string {\n const tpl = getReportTpl();\n\n if (!tpl) {\n console.warn('reportTpl is not set, will not write report');\n return '';\n }\n\n // if reportPath is set, it means we are in write to file mode\n const writeToFile = reportPath && !ifInBrowser;\n let dumpContent = '';\n\n if (typeof dumpData === 'string') {\n // do not use template string here, will cause bundle error\n dumpContent =\n // biome-ignore lint/style/useTemplate: <explanation>\n '<script type=\"midscene_web_dump\" type=\"application/json\">\\n' +\n escapeScriptTag(dumpData) +\n '\\n</script>';\n } else {\n const { dumpString, attributes } = dumpData;\n const attributesArr = Object.keys(attributes || {}).map((key) => {\n return `${key}=\"${encodeURIComponent(attributes![key])}\"`;\n });\n\n dumpContent =\n // do not use template string here, will cause bundle error\n // biome-ignore lint/style/useTemplate: <explanation>\n '<script type=\"midscene_web_dump\" type=\"application/json\" ' +\n attributesArr.join(' ') +\n '>\\n' +\n escapeScriptTag(dumpString) +\n '\\n</script>';\n }\n\n if (writeToFile) {\n if (!appendReport) {\n writeFileSync(reportPath!, tpl + dumpContent, { flag: 'w' });\n return reportPath!;\n }\n\n if (!reportInitializedMap.get(reportPath!)) {\n writeFileSync(reportPath!, tpl, { flag: 'w' });\n reportInitializedMap.set(reportPath!, true);\n }\n\n insertScriptBeforeClosingHtml(reportPath!, dumpContent);\n return reportPath!;\n }\n\n return tpl + dumpContent;\n}\n\nexport function writeDumpReport(\n fileName: string,\n dumpData: string | ReportDumpWithAttributes,\n appendReport?: boolean,\n): string | null {\n if (ifInBrowser) {\n console.log('will not write report in browser');\n return null;\n }\n\n const __dirname = dirname(__filename);\n const midscenePkgInfo = getRunningPkgInfo(__dirname);\n if (!midscenePkgInfo) {\n console.warn('midscenePkgInfo not found, will not write report');\n return null;\n }\n\n const reportPath = path.join(\n getMidsceneRunSubDir('report'),\n `${fileName}.html`,\n );\n\n reportHTMLContent(dumpData, reportPath, appendReport);\n\n if (process.env.MIDSCENE_DEBUG_LOG_JSON) {\n const jsonPath = `${reportPath}.json`;\n let data;\n\n if (typeof dumpData === 'string') {\n data = JSON.parse(dumpData) as ReportDumpWithAttributes;\n } else {\n data = dumpData;\n }\n\n writeFileSync(jsonPath, JSON.stringify(data, null, 2), {\n flag: appendReport ? 'a' : 'w',\n });\n\n logMsg(`Midscene - dump file written: ${jsonPath}`);\n }\n\n return reportPath;\n}\n\nexport function writeLogFile(opts: {\n fileName: string;\n fileExt: string;\n fileContent: string;\n type: 'dump' | 'cache' | 'report' | 'tmp';\n generateReport?: boolean;\n appendReport?: boolean;\n}) {\n if (ifInBrowser) {\n return '/mock/report.html';\n }\n const { fileName, fileExt, fileContent, type = 'dump' } = opts;\n const targetDir = getMidsceneRunSubDir(type);\n // Ensure directory exists\n if (!logEnvReady) {\n assert(targetDir, 'logDir should be set before writing dump file');\n\n // gitIgnore in the parent directory\n const gitIgnorePath = path.join(targetDir, '../../.gitignore');\n const gitPath = path.join(targetDir, '../../.git');\n let gitIgnoreContent = '';\n\n if (existsSync(gitPath)) {\n // if the git path exists, we need to add the log folder to the git ignore file\n if (existsSync(gitIgnorePath)) {\n gitIgnoreContent = readFileSync(gitIgnorePath, 'utf-8');\n }\n\n // ignore the log folder\n if (!gitIgnoreContent.includes(`${defaultRunDirName}/`)) {\n writeFileSync(\n gitIgnorePath,\n `${gitIgnoreContent}\\n# Midscene.js dump files\\n${defaultRunDirName}/dump\\n${defaultRunDirName}/report\\n${defaultRunDirName}/tmp\\n${defaultRunDirName}/log\\n`,\n 'utf-8',\n );\n }\n }\n\n logEnvReady = true;\n }\n\n const filePath = path.join(targetDir, `${fileName}.${fileExt}`);\n\n if (type !== 'dump') {\n // do not write dump file any more\n writeFileSync(filePath, fileContent);\n }\n\n if (opts?.generateReport) {\n return writeDumpReport(fileName, fileContent, opts.appendReport);\n }\n\n return filePath;\n}\n\nexport function getTmpDir(): string | null {\n try {\n const runningPkgInfo = getRunningPkgInfo();\n if (!runningPkgInfo) {\n return null;\n }\n const { name } = runningPkgInfo;\n const tmpPath = path.join(tmpdir(), name);\n mkdirSync(tmpPath, { recursive: true });\n return tmpPath;\n } catch (e) {\n return null;\n }\n}\n\nexport function getTmpFile(fileExtWithoutDot: string): string | null {\n if (ifInBrowser) {\n return null;\n }\n const tmpDir = getTmpDir();\n const filename = `${uuid()}.${fileExtWithoutDot}`;\n return path.join(tmpDir!, filename);\n}\n\nexport function overlapped(container: Rect, target: Rect) {\n // container and the target have some part overlapped\n return (\n container.left < target.left + target.width &&\n container.left + container.width > target.left &&\n container.top < target.top + target.height &&\n container.top + container.height > target.top\n );\n}\n\nexport async function sleep(ms: number) {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nexport function replacerForPageObject(key: string, value: any) {\n if (value && value.constructor?.name === 'Page') {\n return '[Page object]';\n }\n if (value && value.constructor?.name === 'Browser') {\n return '[Browser object]';\n }\n return value;\n}\n\nexport function stringifyDumpData(data: any, indents?: number) {\n return JSON.stringify(data, replacerForPageObject, indents);\n}\n\ndeclare const __VERSION__: string;\n\nexport function getVersion() {\n return __VERSION__;\n}\n\nfunction debugLog(...message: any[]) {\n const debugMode = getAIConfig(MIDSCENE_DEBUG_MODE);\n if (debugMode) {\n console.log('[Midscene]', ...message);\n }\n}\n\nlet lastReportedRepoUrl = '';\nexport function uploadTestInfoToServer({ testUrl }: { testUrl: string }) {\n let repoUrl = '';\n let userEmail = '';\n\n const extraConfig = getAIConfigInJson(MIDSCENE_OPENAI_INIT_CONFIG_JSON);\n const serverUrl = extraConfig?.REPORT_SERVER_URL;\n\n try {\n repoUrl = execSync('git config --get remote.origin.url').toString().trim();\n userEmail = execSync('git config --get user.email').toString().trim();\n } catch (error) {\n debugLog('Failed to get git info:', error);\n }\n\n // Only upload test info if:\n // 1. Server URL is configured AND\n // 2. Either:\n // - We have a repo URL that's different from last reported one (to avoid duplicate reports)\n // - OR we don't have a repo URL but have a test URL (for non-git environments)\n if (\n serverUrl &&\n ((repoUrl && repoUrl !== lastReportedRepoUrl) || (!repoUrl && testUrl))\n ) {\n debugLog('Uploading test info to server', {\n serverUrl,\n repoUrl,\n testUrl,\n userEmail,\n });\n\n fetch(serverUrl, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n repo_url: repoUrl,\n test_url: testUrl,\n user_email: userEmail,\n }),\n })\n .then((response) => response.json())\n .then((data) => {\n debugLog('Successfully uploaded test info to server:', data);\n })\n .catch((error) =>\n debugLog('Failed to upload test info to server:', error),\n );\n lastReportedRepoUrl = repoUrl;\n }\n}\n"]}
|
|
@@ -386,47 +386,31 @@ You are an expert in software testing.
|
|
|
386
386
|
## Objective:
|
|
387
387
|
- Identify elements in screenshots and text that match the user's description.
|
|
388
388
|
- Give the coordinates of the element that matches the user's description best in the screenshot.
|
|
389
|
-
- Determine whether the user's description is order-sensitive (e.g., contains phrases like 'the third item in the list', 'the last button', etc.).
|
|
390
389
|
|
|
391
390
|
## Output Format:
|
|
392
391
|
\`\`\`json
|
|
393
392
|
{
|
|
394
393
|
"bbox": [number, number, number, number], // ${bboxComment}
|
|
395
|
-
"errors"?: string[]
|
|
396
|
-
"isOrderSensitive": boolean // Whether the targetElementDescription is order-sensitive (true/false)
|
|
394
|
+
"errors"?: string[]
|
|
397
395
|
}
|
|
398
396
|
\`\`\`
|
|
399
397
|
|
|
400
398
|
Fields:
|
|
401
399
|
* \`bbox\` is the bounding box of the element that matches the user's description best in the screenshot
|
|
402
|
-
* \`isOrderSensitive\` is a boolean indicating whether the user's description is order-sensitive (true/false)
|
|
403
400
|
* \`errors\` is an optional array of error messages (if any)
|
|
404
401
|
|
|
405
|
-
|
|
406
|
-
- "the third item in the list"
|
|
407
|
-
- "the last button"
|
|
408
|
-
- "the first input box"
|
|
409
|
-
- "the second row"
|
|
410
|
-
|
|
411
|
-
Not order-sensitive means the description is like:
|
|
412
|
-
- "confirm button"
|
|
413
|
-
- "search box"
|
|
414
|
-
- "password input"
|
|
415
|
-
|
|
416
|
-
For example, when an element is found and the description is order-sensitive:
|
|
402
|
+
For example, when an element is found:
|
|
417
403
|
\`\`\`json
|
|
418
404
|
{
|
|
419
405
|
"bbox": [100, 100, 200, 200],
|
|
420
|
-
"isOrderSensitive": true,
|
|
421
406
|
"errors": []
|
|
422
407
|
}
|
|
423
408
|
\`\`\`
|
|
424
409
|
|
|
425
|
-
When no element is found
|
|
410
|
+
When no element is found:
|
|
426
411
|
\`\`\`json
|
|
427
412
|
{
|
|
428
413
|
"bbox": [],
|
|
429
|
-
"isOrderSensitive": false,
|
|
430
414
|
"errors": ["I can see ..., but {some element} is not found"]
|
|
431
415
|
}
|
|
432
416
|
\`\`\`
|
|
@@ -439,7 +423,6 @@ You are an expert in software page image (2D) and page element text analysis.
|
|
|
439
423
|
## Objective:
|
|
440
424
|
- Identify elements in screenshots and text that match the user's description.
|
|
441
425
|
- Return JSON data containing the selection reason and element ID.
|
|
442
|
-
- Determine whether the user's description is order-sensitive (e.g., contains phrases like 'the third item in the list', 'the last button', etc.).
|
|
443
426
|
|
|
444
427
|
## Skills:
|
|
445
428
|
- Image analysis and recognition
|
|
@@ -451,7 +434,6 @@ You are an expert in software page image (2D) and page element text analysis.
|
|
|
451
434
|
2. Based on the user's description, locate the target element ID in the list of element descriptions and the screenshot.
|
|
452
435
|
3. Found the required number of elements
|
|
453
436
|
4. Return JSON data containing the selection reason and element ID.
|
|
454
|
-
5. Judge whether the user's description is order-sensitive (see below for definition and examples).
|
|
455
437
|
|
|
456
438
|
## Constraints:
|
|
457
439
|
- Strictly adhere to the specified location when describing the required element; do not select elements from other locations.
|
|
@@ -461,10 +443,6 @@ You are an expert in software page image (2D) and page element text analysis.
|
|
|
461
443
|
- The returned data must conform to the specified JSON format.
|
|
462
444
|
- The returned value id information must use the id from element info (important: **use id not indexId, id is hash content**)
|
|
463
445
|
|
|
464
|
-
## Order-Sensitive Definition:
|
|
465
|
-
- 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).
|
|
466
|
-
- If the description is like "confirm button", "search box", "password input", etc., it is not order-sensitive (isOrderSensitive = false).
|
|
467
|
-
|
|
468
446
|
## Output Format:
|
|
469
447
|
|
|
470
448
|
Please return the result in JSON format as follows:
|
|
@@ -480,7 +458,6 @@ Please return the result in JSON format as follows:
|
|
|
480
458
|
}
|
|
481
459
|
// More elements...
|
|
482
460
|
],
|
|
483
|
-
"isOrderSensitive": true, // or false, depending on the user's description
|
|
484
461
|
"errors": [] // Array of strings containing any error messages
|
|
485
462
|
}
|
|
486
463
|
\`\`\`
|
|
@@ -569,7 +546,6 @@ Output Example:
|
|
|
569
546
|
"id": "1231"
|
|
570
547
|
}
|
|
571
548
|
],
|
|
572
|
-
"isOrderSensitive": true,
|
|
573
549
|
"errors": []
|
|
574
550
|
}
|
|
575
551
|
\`\`\`
|
|
@@ -607,10 +583,6 @@ var locatorSchema = {
|
|
|
607
583
|
},
|
|
608
584
|
description: "List of found elements"
|
|
609
585
|
},
|
|
610
|
-
isOrderSensitive: {
|
|
611
|
-
type: "boolean",
|
|
612
|
-
description: "Whether the targetElementDescription is order-sensitive (true/false)"
|
|
613
|
-
},
|
|
614
586
|
errors: {
|
|
615
587
|
type: "array",
|
|
616
588
|
items: {
|
|
@@ -619,7 +591,7 @@ var locatorSchema = {
|
|
|
619
591
|
description: "List of error messages, if any"
|
|
620
592
|
}
|
|
621
593
|
},
|
|
622
|
-
required: ["elements", "
|
|
594
|
+
required: ["elements", "errors"],
|
|
623
595
|
additionalProperties: false
|
|
624
596
|
}
|
|
625
597
|
}
|
|
@@ -817,7 +789,6 @@ Return in JSON format:
|
|
|
817
789
|
${vlCoTLog}
|
|
818
790
|
${vlCurrentLog}
|
|
819
791
|
${commonOutputFields}
|
|
820
|
-
"isOrderSensitive": boolean, // Whether the user's instruction is order-sensitive (true/false)
|
|
821
792
|
"action":
|
|
822
793
|
{
|
|
823
794
|
// one of the supporting actions
|
|
@@ -930,7 +901,6 @@ The JSON format is as follows:
|
|
|
930
901
|
],
|
|
931
902
|
${llmCurrentLog}
|
|
932
903
|
${commonOutputFields}
|
|
933
|
-
"isOrderSensitive": boolean, // Whether the user's instruction is order-sensitive (true/false)
|
|
934
904
|
}}
|
|
935
905
|
|
|
936
906
|
## Examples
|
|
@@ -1090,10 +1060,6 @@ var planSchema = {
|
|
|
1090
1060
|
},
|
|
1091
1061
|
description: "List of actions to be performed"
|
|
1092
1062
|
},
|
|
1093
|
-
isOrderSensitive: {
|
|
1094
|
-
type: "boolean",
|
|
1095
|
-
description: "Whether the user's instruction is order-sensitive (true/false)"
|
|
1096
|
-
},
|
|
1097
1063
|
more_actions_needed_by_instruction: {
|
|
1098
1064
|
type: "boolean",
|
|
1099
1065
|
description: "If all the actions described in the instruction have been covered by this action and logs, set this field to false."
|
|
@@ -2117,7 +2083,6 @@ var extractDataQueryPrompt = async (pageDescription, dataQuery) => {
|
|
|
2117
2083
|
function systemPromptToLocateSection(vlMode) {
|
|
2118
2084
|
return `
|
|
2119
2085
|
You goal is to find out one section containing the target element in the screenshot, put it in the \`bbox\` field. If the user describe the target element with some reference elements, you should also find the section containing the reference elements, put it in the \`references_bbox\` field.
|
|
2120
|
-
- Determine whether the user's description is order-sensitive (e.g., contains phrases like 'the third item in the list', 'the last button', etc.).
|
|
2121
2086
|
|
|
2122
2087
|
Usually, it should be approximately an area not more than 300x300px. Changes of the size are allowed if there are many elements to cover.
|
|
2123
2088
|
|
|
@@ -2130,27 +2095,11 @@ return in this JSON format:
|
|
|
2130
2095
|
[number, number, number, number],
|
|
2131
2096
|
...
|
|
2132
2097
|
],
|
|
2133
|
-
"isOrderSensitive": boolean, // Whether the targetElementDescription is order-sensitive (true/false)
|
|
2134
2098
|
"error"?: string
|
|
2135
2099
|
}
|
|
2136
2100
|
\`\`\`
|
|
2137
2101
|
|
|
2138
|
-
In which, all the numbers in the \`bbox\` and \`references_bbox\` represent ${bboxDescription(
|
|
2139
|
-
vlMode
|
|
2140
|
-
)}.
|
|
2141
|
-
|
|
2142
|
-
* \`isOrderSensitive\` is a boolean indicating whether the user's description is order-sensitive (true/false)
|
|
2143
|
-
|
|
2144
|
-
Order-sensitive means the description contains phrases like:
|
|
2145
|
-
- "the third item in the list"
|
|
2146
|
-
- "the last button"
|
|
2147
|
-
- "the first input box"
|
|
2148
|
-
- "the second row"
|
|
2149
|
-
|
|
2150
|
-
Not order-sensitive means the description is like:
|
|
2151
|
-
- "confirm button"
|
|
2152
|
-
- "search box"
|
|
2153
|
-
- "password input"
|
|
2102
|
+
In which, all the numbers in the \`bbox\` and \`references_bbox\` represent ${bboxDescription(vlMode)}.
|
|
2154
2103
|
|
|
2155
2104
|
For example, if the user describe the target element as "the delete button on the second row with title 'Peter'", you should put the bounding box of the delete button in the \`bbox\` field, and the bounding box of the second row in the \`references_bbox\` field.
|
|
2156
2105
|
|
|
@@ -2158,8 +2107,7 @@ the return value should be like this:
|
|
|
2158
2107
|
\`\`\`json
|
|
2159
2108
|
{
|
|
2160
2109
|
"bbox": [100, 100, 200, 200],
|
|
2161
|
-
"references_bbox": [[100, 100, 200, 200]]
|
|
2162
|
-
"isOrderSensitive": true
|
|
2110
|
+
"references_bbox": [[100, 100, 200, 200]]
|
|
2163
2111
|
}
|
|
2164
2112
|
\`\`\`
|
|
2165
2113
|
`;
|
|
@@ -2282,8 +2230,7 @@ async function AiLocateElement(options) {
|
|
|
2282
2230
|
},
|
|
2283
2231
|
rawResponse,
|
|
2284
2232
|
elementById,
|
|
2285
|
-
usage: res.usage
|
|
2286
|
-
isOrderSensitive: typeof res.content === "object" && res.content !== null && "isOrderSensitive" in res.content ? res.content.isOrderSensitive : void 0
|
|
2233
|
+
usage: res.usage
|
|
2287
2234
|
};
|
|
2288
2235
|
}
|
|
2289
2236
|
async function AiLocateSection(options) {
|
|
@@ -2817,4 +2764,4 @@ async function resizeImageForUiTars(imageBase64, size) {
|
|
|
2817
2764
|
|
|
2818
2765
|
exports.systemPromptToLocateElement = systemPromptToLocateElement; exports.elementByPositionWithElementInfo = elementByPositionWithElementInfo; exports.describeUserPage = describeUserPage; exports.call = call; exports.callToGetJSONObject = callToGetJSONObject; exports.AIActionType = AIActionType; exports.callAiFn = callAiFn; exports.adaptBboxToRect = adaptBboxToRect; exports.expandSearchArea = expandSearchArea; exports.generateYamlTest = generateYamlTest; exports.generateYamlTestStream = generateYamlTestStream; exports.generatePlaywrightTest = generatePlaywrightTest; exports.generatePlaywrightTestStream = generatePlaywrightTestStream; exports.AiLocateElement = AiLocateElement; exports.AiLocateSection = AiLocateSection; exports.AiExtractElementInfo = AiExtractElementInfo; exports.AiAssert = AiAssert; exports.plan = plan; exports.vlmPlanning = vlmPlanning; exports.resizeImageForUiTars = resizeImageForUiTars;
|
|
2819
2766
|
|
|
2820
|
-
//# sourceMappingURL=chunk-
|
|
2767
|
+
//# sourceMappingURL=chunk-TV47VKQ7.js.map
|