@midscene/core 0.26.7-beta-20250820160625.0 → 0.26.7-beta-20250821033353.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 (36) hide show
  1. package/dist/es/ai-model/common.mjs +13 -79
  2. package/dist/es/ai-model/common.mjs.map +1 -1
  3. package/dist/es/ai-model/index.mjs +2 -2
  4. package/dist/es/ai-model/inspect.mjs.map +1 -1
  5. package/dist/es/ai-model/llm-planning.mjs +1 -0
  6. package/dist/es/ai-model/llm-planning.mjs.map +1 -1
  7. package/dist/es/ai-model/prompt/llm-planning.mjs +21 -43
  8. package/dist/es/ai-model/prompt/llm-planning.mjs.map +1 -1
  9. package/dist/es/index.mjs +2 -2
  10. package/dist/es/index.mjs.map +1 -1
  11. package/dist/es/insight/index.mjs.map +1 -1
  12. package/dist/es/types.mjs.map +1 -1
  13. package/dist/es/utils.mjs +2 -2
  14. package/dist/es/utils.mjs.map +1 -1
  15. package/dist/lib/ai-model/common.js +19 -97
  16. package/dist/lib/ai-model/common.js.map +1 -1
  17. package/dist/lib/ai-model/index.js +10 -22
  18. package/dist/lib/ai-model/inspect.js.map +1 -1
  19. package/dist/lib/ai-model/llm-planning.js +1 -0
  20. package/dist/lib/ai-model/llm-planning.js.map +1 -1
  21. package/dist/lib/ai-model/prompt/llm-planning.js +21 -43
  22. package/dist/lib/ai-model/prompt/llm-planning.js.map +1 -1
  23. package/dist/lib/index.js +8 -14
  24. package/dist/lib/index.js.map +1 -1
  25. package/dist/lib/insight/index.js.map +1 -1
  26. package/dist/lib/types.js.map +1 -1
  27. package/dist/lib/utils.js +2 -2
  28. package/dist/lib/utils.js.map +1 -1
  29. package/dist/types/ai-model/common.d.ts +7 -363
  30. package/dist/types/ai-model/index.d.ts +1 -1
  31. package/dist/types/ai-model/inspect.d.ts +1 -2
  32. package/dist/types/index.d.ts +1 -1
  33. package/dist/types/insight/index.d.ts +1 -2
  34. package/dist/types/types.d.ts +20 -1
  35. package/dist/types/yaml.d.ts +2 -4
  36. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"utils.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/utils.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 { 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 {\n defaultRunDirName,\n getMidsceneRunSubDir,\n} from '@midscene/shared/common';\nimport {\n MIDSCENE_DEBUG_MODE,\n getUploadTestServerUrl,\n} from '@midscene/shared/env';\nimport { getRunningPkgInfo } from '@midscene/shared/node';\nimport { assert, logMsg } from '@midscene/shared/utils';\nimport {\n escapeScriptTag,\n ifInBrowser,\n ifInWorker,\n uuid,\n} 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 (typeof __DEV_REPORT_PATH__ === 'string' && __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 || ifInWorker) {\n console.log('will not write report in browser');\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 || ifInWorker) {\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 || ifInWorker) {\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 // always read from process.env, and cannot be override by modelConfig, overrideAIConfig, etc.\n const debugMode = process.env[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 serverUrl = getUploadTestServerUrl();\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"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","logEnvReady","groupedActionDumpFileExt","reportInitializedMap","Map","getReportTpl","reportTpl","insertScriptBeforeClosingHtml","filePath","scriptContent","htmlEndTag","stat","fs","readSize","Math","start","buffer","Buffer","fd","tailStr","htmlEndIdx","Error","beforeHtmlInTail","htmlEndPos","reportHTMLContent","dumpData","reportPath","appendReport","tpl","console","writeToFile","ifInBrowser","dumpContent","escapeScriptTag","dumpString","attributes","attributesArr","encodeURIComponent","writeFileSync","writeDumpReport","fileName","ifInWorker","path","getMidsceneRunSubDir","process","jsonPath","data","JSON","logMsg","writeLogFile","opts","fileExt","fileContent","type","targetDir","assert","gitIgnorePath","gitPath","gitIgnoreContent","existsSync","readFileSync","defaultRunDirName","getTmpDir","runningPkgInfo","getRunningPkgInfo","name","tmpPath","tmpdir","mkdirSync","e","getTmpFile","fileExtWithoutDot","tmpDir","filename","uuid","overlapped","container","target","sleep","ms","Promise","resolve","setTimeout","replacerForPageObject","value","_value_constructor","_value_constructor1","stringifyDumpData","indents","getVersion","__VERSION__","debugLog","message","debugMode","MIDSCENE_DEBUG_MODE","lastReportedRepoUrl","uploadTestInfoToServer","testUrl","repoUrl","userEmail","serverUrl","getUploadTestServerUrl","execSync","error","fetch","response"],"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;;;;;;;;;;;;;;;;;;;;;;;;;;;ACiBA,IAAII,cAAc;AAEX,MAAMC,2BAA2B;AAExC,MAAMC,uBAAuB,IAAIC;AAIjC,SAASC;IAIP,MAAMC,YAAY;IAElB,OAAOA;AACT;AAMO,SAASC,8BACdC,QAAgB,EAChBC,aAAqB;IAErB,MAAMC,aA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AAK,CAAC,CAACyD,QACNZ,SAAS,yCAAyCY;QAEtDR,sBAAsBG;IACxB;AACF"}
1
+ {"version":3,"file":"utils.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/utils.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 { 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 {\n defaultRunDirName,\n getMidsceneRunSubDir,\n} from '@midscene/shared/common';\nimport {\n MIDSCENE_DEBUG_MODE,\n getUploadTestServerUrl,\n} from '@midscene/shared/env';\nimport { getRunningPkgInfo } from '@midscene/shared/node';\nimport { assert, logMsg } from '@midscene/shared/utils';\nimport {\n escapeScriptTag,\n ifInBrowser,\n ifInWorker,\n uuid,\n} 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 || ifInWorker) {\n console.log('will not write report in browser');\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 || ifInWorker) {\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 || ifInWorker) {\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 // always read from process.env, and cannot be override by modelConfig, overrideAIConfig, etc.\n const debugMode = process.env[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 serverUrl = getUploadTestServerUrl();\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"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","logEnvReady","groupedActionDumpFileExt","reportInitializedMap","Map","getReportTpl","reportTpl","insertScriptBeforeClosingHtml","filePath","scriptContent","htmlEndTag","stat","fs","readSize","Math","start","buffer","Buffer","fd","tailStr","htmlEndIdx","Error","beforeHtmlInTail","htmlEndPos","reportHTMLContent","dumpData","reportPath","appendReport","tpl","console","writeToFile","ifInBrowser","dumpContent","escapeScriptTag","dumpString","attributes","attributesArr","encodeURIComponent","writeFileSync","writeDumpReport","fileName","ifInWorker","path","getMidsceneRunSubDir","process","jsonPath","data","JSON","logMsg","writeLogFile","opts","fileExt","fileContent","type","targetDir","assert","gitIgnorePath","gitPath","gitIgnoreContent","existsSync","readFileSync","defaultRunDirName","getTmpDir","runningPkgInfo","getRunningPkgInfo","name","tmpPath","tmpdir","mkdirSync","e","getTmpFile","fileExtWithoutDot","tmpDir","filename","uuid","overlapped","container","target","sleep","ms","Promise","resolve","setTimeout","replacerForPageObject","value","_value_constructor","_value_constructor1","stringifyDumpData","indents","getVersion","__VERSION__","debugLog","message","debugMode","MIDSCENE_DEBUG_MODE","lastReportedRepoUrl","uploadTestInfoToServer","testUrl","repoUrl","userEmail","serverUrl","getUploadTestServerUrl","execSync","error","fetch","response"],"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;;;;;;;;;;;;;;;;;;;;;;;;;;;ACiBA,IAAII,cAAc;AAEX,MAAMC,2BAA2B;AAExC,MAAMC,uBAAuB,IAAIC;AAIjC,SAASC;IAIP,MAAMC,YAAY;IAElB,OAAOA;AACT;AAMO,SAASC,8BACdC,QAAgB,EAChBC,aAAqB;IAErB,MAAMC,aAAa;IACnB,MAAM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yD,QACNZ,SAAS,yCAAyCY;QAEtDR,sBAAsBG;IACxB;AACF"}
@@ -14,6 +14,7 @@ export declare enum AIActionType {
14
14
  PLAN = 3,
15
15
  DESCRIBE_ELEMENT = 4
16
16
  }
17
+ export declare const actionSpaceTypePrefix = "action_space_";
17
18
  export declare function callAiFn<T>(msgs: AIArgs, AIActionTypeValue: AIActionType, modelPreferences: IModelPreferences): Promise<{
18
19
  content: T;
19
20
  usage?: AIUsageInfo;
@@ -85,297 +86,9 @@ export declare const RectSchema: z.ZodIntersection<z.ZodIntersection<z.ZodObject
85
86
  }, {
86
87
  zoom?: number | undefined;
87
88
  }>>;
88
- export declare const TMultimodalPromptSchema: z.ZodObject<{
89
- images: z.ZodOptional<z.ZodArray<z.ZodObject<{
90
- name: z.ZodString;
91
- url: z.ZodString;
92
- }, "strip", z.ZodTypeAny, {
93
- name: string;
94
- url: string;
95
- }, {
96
- name: string;
97
- url: string;
98
- }>, "many">>;
99
- convertHttpImage2Base64: z.ZodOptional<z.ZodBoolean>;
100
- }, "strip", z.ZodTypeAny, {
101
- images?: {
102
- name: string;
103
- url: string;
104
- }[] | undefined;
105
- convertHttpImage2Base64?: boolean | undefined;
106
- }, {
107
- images?: {
108
- name: string;
109
- url: string;
110
- }[] | undefined;
111
- convertHttpImage2Base64?: boolean | undefined;
112
- }>;
113
- export declare const TUserPromptSchema: z.ZodUnion<[z.ZodString, z.ZodIntersection<z.ZodObject<{
114
- prompt: z.ZodString;
115
- }, "strip", z.ZodTypeAny, {
116
- prompt: string;
117
- }, {
118
- prompt: string;
119
- }>, z.ZodObject<{
120
- images: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodObject<{
121
- name: z.ZodString;
122
- url: z.ZodString;
123
- }, "strip", z.ZodTypeAny, {
124
- name: string;
125
- url: string;
126
- }, {
127
- name: string;
128
- url: string;
129
- }>, "many">>>;
130
- convertHttpImage2Base64: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
131
- }, "strip", z.ZodTypeAny, {
132
- images?: {
133
- name: string;
134
- url: string;
135
- }[] | undefined;
136
- convertHttpImage2Base64?: boolean | undefined;
137
- }, {
138
- images?: {
139
- name: string;
140
- url: string;
141
- }[] | undefined;
142
- convertHttpImage2Base64?: boolean | undefined;
143
- }>>]>;
144
- export type TMultimodalPrompt = z.infer<typeof TMultimodalPromptSchema>;
145
- export type TUserPrompt = z.infer<typeof TUserPromptSchema>;
146
- declare const MidsceneLocationResult: z.ZodObject<{
147
- midscene_location_field_flag: z.ZodLiteral<true>;
148
- prompt: z.ZodUnion<[z.ZodString, z.ZodIntersection<z.ZodObject<{
149
- prompt: z.ZodString;
150
- }, "strip", z.ZodTypeAny, {
151
- prompt: string;
152
- }, {
153
- prompt: string;
154
- }>, z.ZodObject<{
155
- images: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodObject<{
156
- name: z.ZodString;
157
- url: z.ZodString;
158
- }, "strip", z.ZodTypeAny, {
159
- name: string;
160
- url: string;
161
- }, {
162
- name: string;
163
- url: string;
164
- }>, "many">>>;
165
- convertHttpImage2Base64: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
166
- }, "strip", z.ZodTypeAny, {
167
- images?: {
168
- name: string;
169
- url: string;
170
- }[] | undefined;
171
- convertHttpImage2Base64?: boolean | undefined;
172
- }, {
173
- images?: {
174
- name: string;
175
- url: string;
176
- }[] | undefined;
177
- convertHttpImage2Base64?: boolean | undefined;
178
- }>>]>;
179
- deepThink: z.ZodOptional<z.ZodBoolean>;
180
- cacheable: z.ZodOptional<z.ZodBoolean>;
181
- xpath: z.ZodOptional<z.ZodBoolean>;
182
- center: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
183
- rect: z.ZodIntersection<z.ZodIntersection<z.ZodObject<{
184
- left: z.ZodNumber;
185
- top: z.ZodNumber;
186
- }, "strip", z.ZodTypeAny, {
187
- left: number;
188
- top: number;
189
- }, {
190
- left: number;
191
- top: number;
192
- }>, z.ZodObject<{
193
- width: z.ZodNumber;
194
- height: z.ZodNumber;
195
- dpr: z.ZodOptional<z.ZodNumber>;
196
- }, "strip", z.ZodTypeAny, {
197
- width: number;
198
- height: number;
199
- dpr?: number | undefined;
200
- }, {
201
- width: number;
202
- height: number;
203
- dpr?: number | undefined;
204
- }>>, z.ZodObject<{
205
- zoom: z.ZodOptional<z.ZodNumber>;
206
- }, "strip", z.ZodTypeAny, {
207
- zoom?: number | undefined;
208
- }, {
209
- zoom?: number | undefined;
210
- }>>;
211
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
89
+ export declare const MidsceneLocation: z.ZodObject<{
212
90
  midscene_location_field_flag: z.ZodLiteral<true>;
213
- prompt: z.ZodUnion<[z.ZodString, z.ZodIntersection<z.ZodObject<{
214
- prompt: z.ZodString;
215
- }, "strip", z.ZodTypeAny, {
216
- prompt: string;
217
- }, {
218
- prompt: string;
219
- }>, z.ZodObject<{
220
- images: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodObject<{
221
- name: z.ZodString;
222
- url: z.ZodString;
223
- }, "strip", z.ZodTypeAny, {
224
- name: string;
225
- url: string;
226
- }, {
227
- name: string;
228
- url: string;
229
- }>, "many">>>;
230
- convertHttpImage2Base64: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
231
- }, "strip", z.ZodTypeAny, {
232
- images?: {
233
- name: string;
234
- url: string;
235
- }[] | undefined;
236
- convertHttpImage2Base64?: boolean | undefined;
237
- }, {
238
- images?: {
239
- name: string;
240
- url: string;
241
- }[] | undefined;
242
- convertHttpImage2Base64?: boolean | undefined;
243
- }>>]>;
244
- deepThink: z.ZodOptional<z.ZodBoolean>;
245
- cacheable: z.ZodOptional<z.ZodBoolean>;
246
- xpath: z.ZodOptional<z.ZodBoolean>;
247
- center: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
248
- rect: z.ZodIntersection<z.ZodIntersection<z.ZodObject<{
249
- left: z.ZodNumber;
250
- top: z.ZodNumber;
251
- }, "strip", z.ZodTypeAny, {
252
- left: number;
253
- top: number;
254
- }, {
255
- left: number;
256
- top: number;
257
- }>, z.ZodObject<{
258
- width: z.ZodNumber;
259
- height: z.ZodNumber;
260
- dpr: z.ZodOptional<z.ZodNumber>;
261
- }, "strip", z.ZodTypeAny, {
262
- width: number;
263
- height: number;
264
- dpr?: number | undefined;
265
- }, {
266
- width: number;
267
- height: number;
268
- dpr?: number | undefined;
269
- }>>, z.ZodObject<{
270
- zoom: z.ZodOptional<z.ZodNumber>;
271
- }, "strip", z.ZodTypeAny, {
272
- zoom?: number | undefined;
273
- }, {
274
- zoom?: number | undefined;
275
- }>>;
276
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
277
- midscene_location_field_flag: z.ZodLiteral<true>;
278
- prompt: z.ZodUnion<[z.ZodString, z.ZodIntersection<z.ZodObject<{
279
- prompt: z.ZodString;
280
- }, "strip", z.ZodTypeAny, {
281
- prompt: string;
282
- }, {
283
- prompt: string;
284
- }>, z.ZodObject<{
285
- images: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodObject<{
286
- name: z.ZodString;
287
- url: z.ZodString;
288
- }, "strip", z.ZodTypeAny, {
289
- name: string;
290
- url: string;
291
- }, {
292
- name: string;
293
- url: string;
294
- }>, "many">>>;
295
- convertHttpImage2Base64: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
296
- }, "strip", z.ZodTypeAny, {
297
- images?: {
298
- name: string;
299
- url: string;
300
- }[] | undefined;
301
- convertHttpImage2Base64?: boolean | undefined;
302
- }, {
303
- images?: {
304
- name: string;
305
- url: string;
306
- }[] | undefined;
307
- convertHttpImage2Base64?: boolean | undefined;
308
- }>>]>;
309
- deepThink: z.ZodOptional<z.ZodBoolean>;
310
- cacheable: z.ZodOptional<z.ZodBoolean>;
311
- xpath: z.ZodOptional<z.ZodBoolean>;
312
- center: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
313
- rect: z.ZodIntersection<z.ZodIntersection<z.ZodObject<{
314
- left: z.ZodNumber;
315
- top: z.ZodNumber;
316
- }, "strip", z.ZodTypeAny, {
317
- left: number;
318
- top: number;
319
- }, {
320
- left: number;
321
- top: number;
322
- }>, z.ZodObject<{
323
- width: z.ZodNumber;
324
- height: z.ZodNumber;
325
- dpr: z.ZodOptional<z.ZodNumber>;
326
- }, "strip", z.ZodTypeAny, {
327
- width: number;
328
- height: number;
329
- dpr?: number | undefined;
330
- }, {
331
- width: number;
332
- height: number;
333
- dpr?: number | undefined;
334
- }>>, z.ZodObject<{
335
- zoom: z.ZodOptional<z.ZodNumber>;
336
- }, "strip", z.ZodTypeAny, {
337
- zoom?: number | undefined;
338
- }, {
339
- zoom?: number | undefined;
340
- }>>;
341
- }, z.ZodTypeAny, "passthrough">>;
342
- export type MidsceneLocationResultType = z.infer<typeof MidsceneLocationResult>;
343
- export declare const getMidsceneLocationSchema: () => z.ZodObject<{
344
- midscene_location_field_flag: z.ZodLiteral<true>;
345
- prompt: z.ZodUnion<[z.ZodString, z.ZodIntersection<z.ZodObject<{
346
- prompt: z.ZodString;
347
- }, "strip", z.ZodTypeAny, {
348
- prompt: string;
349
- }, {
350
- prompt: string;
351
- }>, z.ZodObject<{
352
- images: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodObject<{
353
- name: z.ZodString;
354
- url: z.ZodString;
355
- }, "strip", z.ZodTypeAny, {
356
- name: string;
357
- url: string;
358
- }, {
359
- name: string;
360
- url: string;
361
- }>, "many">>>;
362
- convertHttpImage2Base64: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
363
- }, "strip", z.ZodTypeAny, {
364
- images?: {
365
- name: string;
366
- url: string;
367
- }[] | undefined;
368
- convertHttpImage2Base64?: boolean | undefined;
369
- }, {
370
- images?: {
371
- name: string;
372
- url: string;
373
- }[] | undefined;
374
- convertHttpImage2Base64?: boolean | undefined;
375
- }>>]>;
376
- deepThink: z.ZodOptional<z.ZodBoolean>;
377
- cacheable: z.ZodOptional<z.ZodBoolean>;
378
- xpath: z.ZodOptional<z.ZodBoolean>;
91
+ prompt: z.ZodString;
379
92
  center: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
380
93
  rect: z.ZodIntersection<z.ZodIntersection<z.ZodObject<{
381
94
  left: z.ZodNumber;
@@ -407,40 +120,7 @@ export declare const getMidsceneLocationSchema: () => z.ZodObject<{
407
120
  }>>;
408
121
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
409
122
  midscene_location_field_flag: z.ZodLiteral<true>;
410
- prompt: z.ZodUnion<[z.ZodString, z.ZodIntersection<z.ZodObject<{
411
- prompt: z.ZodString;
412
- }, "strip", z.ZodTypeAny, {
413
- prompt: string;
414
- }, {
415
- prompt: string;
416
- }>, z.ZodObject<{
417
- images: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodObject<{
418
- name: z.ZodString;
419
- url: z.ZodString;
420
- }, "strip", z.ZodTypeAny, {
421
- name: string;
422
- url: string;
423
- }, {
424
- name: string;
425
- url: string;
426
- }>, "many">>>;
427
- convertHttpImage2Base64: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
428
- }, "strip", z.ZodTypeAny, {
429
- images?: {
430
- name: string;
431
- url: string;
432
- }[] | undefined;
433
- convertHttpImage2Base64?: boolean | undefined;
434
- }, {
435
- images?: {
436
- name: string;
437
- url: string;
438
- }[] | undefined;
439
- convertHttpImage2Base64?: boolean | undefined;
440
- }>>]>;
441
- deepThink: z.ZodOptional<z.ZodBoolean>;
442
- cacheable: z.ZodOptional<z.ZodBoolean>;
443
- xpath: z.ZodOptional<z.ZodBoolean>;
123
+ prompt: z.ZodString;
444
124
  center: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
445
125
  rect: z.ZodIntersection<z.ZodIntersection<z.ZodObject<{
446
126
  left: z.ZodNumber;
@@ -472,40 +152,7 @@ export declare const getMidsceneLocationSchema: () => z.ZodObject<{
472
152
  }>>;
473
153
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
474
154
  midscene_location_field_flag: z.ZodLiteral<true>;
475
- prompt: z.ZodUnion<[z.ZodString, z.ZodIntersection<z.ZodObject<{
476
- prompt: z.ZodString;
477
- }, "strip", z.ZodTypeAny, {
478
- prompt: string;
479
- }, {
480
- prompt: string;
481
- }>, z.ZodObject<{
482
- images: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodObject<{
483
- name: z.ZodString;
484
- url: z.ZodString;
485
- }, "strip", z.ZodTypeAny, {
486
- name: string;
487
- url: string;
488
- }, {
489
- name: string;
490
- url: string;
491
- }>, "many">>>;
492
- convertHttpImage2Base64: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
493
- }, "strip", z.ZodTypeAny, {
494
- images?: {
495
- name: string;
496
- url: string;
497
- }[] | undefined;
498
- convertHttpImage2Base64?: boolean | undefined;
499
- }, {
500
- images?: {
501
- name: string;
502
- url: string;
503
- }[] | undefined;
504
- convertHttpImage2Base64?: boolean | undefined;
505
- }>>]>;
506
- deepThink: z.ZodOptional<z.ZodBoolean>;
507
- cacheable: z.ZodOptional<z.ZodBoolean>;
508
- xpath: z.ZodOptional<z.ZodBoolean>;
155
+ prompt: z.ZodString;
509
156
  center: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
510
157
  rect: z.ZodIntersection<z.ZodIntersection<z.ZodObject<{
511
158
  left: z.ZodNumber;
@@ -536,9 +183,6 @@ export declare const getMidsceneLocationSchema: () => z.ZodObject<{
536
183
  zoom?: number | undefined;
537
184
  }>>;
538
185
  }, z.ZodTypeAny, "passthrough">>;
186
+ export type MidsceneLocationType = z.infer<typeof MidsceneLocation>;
539
187
  export declare const ifMidsceneLocatorField: (field: any) => boolean;
540
- export declare const dumpMidsceneLocatorField: (field: any) => string;
541
- export declare const findAllMidsceneLocatorField: (zodType?: z.ZodType<any>, requiredOnly?: boolean) => string[];
542
- export declare const dumpActionParam: (jsonObject: Record<string, any>, zodSchema: z.ZodType<any>) => Record<string, any>;
543
- export declare const loadActionParam: (jsonObject: Record<string, any>, zodSchema: z.ZodType<any>) => Record<string, any>;
544
- export {};
188
+ export declare const findAllMidsceneLocatorField: (zodType?: z.ZodType<any>) => string[];
@@ -9,4 +9,4 @@ export { plan } from './llm-planning';
9
9
  export { callAiFn, adaptBboxToRect, } from './common';
10
10
  export { vlmPlanning, resizeImageForUiTars } from './ui-tars-planning';
11
11
  export { AIActionType, type AIArgs } from './common';
12
- export { getMidsceneLocationSchema, type MidsceneLocationResultType, PointSchema, SizeSchema, RectSchema, TMultimodalPromptSchema, TUserPromptSchema, type TMultimodalPrompt, type TUserPrompt, findAllMidsceneLocatorField, dumpActionParam, loadActionParam, } from './common';
12
+ export { actionSpaceTypePrefix, MidsceneLocation, type MidsceneLocationType, PointSchema, SizeSchema, RectSchema, } from './common';
@@ -1,7 +1,6 @@
1
- import type { AIDataExtractionResponse, AIElementLocatorResponse, AIElementResponse, AISectionLocatorResponse, AIUsageInfo, BaseElement, ElementById, InsightExtractOption, Rect, ReferenceImage, UIContext } from '../types';
1
+ import type { AIDataExtractionResponse, AIElementLocatorResponse, AIElementResponse, AISectionLocatorResponse, AIUsageInfo, BaseElement, ElementById, InsightExtractOption, Rect, ReferenceImage, TMultimodalPrompt, TUserPrompt, UIContext } from '../types';
2
2
  import { type IModelPreferences } from '@midscene/shared/env';
3
3
  import type { ChatCompletionSystemMessageParam, ChatCompletionUserMessageParam } from 'openai/resources/index';
4
- import type { TMultimodalPrompt, TUserPrompt } from './common';
5
4
  import { callAiFn } from './common';
6
5
  export type AIArgs = [
7
6
  ChatCompletionSystemMessageParam,
@@ -2,7 +2,7 @@ import { z } from 'zod';
2
2
  import { Executor } from './ai-model/action-executor';
3
3
  import Insight from './insight/index';
4
4
  import { getVersion } from './utils';
5
- export { plan, describeUserPage, AiLocateElement, getMidsceneLocationSchema, type MidsceneLocationResultType, PointSchema, SizeSchema, RectSchema, TMultimodalPromptSchema, TUserPromptSchema, type TMultimodalPrompt, type TUserPrompt, } from './ai-model/index';
5
+ export { plan, describeUserPage, AiLocateElement, MidsceneLocation, type MidsceneLocationType, PointSchema, SizeSchema, RectSchema, } from './ai-model/index';
6
6
  export { getAIConfig, MIDSCENE_MODEL_NAME } from '@midscene/shared/env';
7
7
  export type * from './types';
8
8
  export { z };
@@ -1,6 +1,5 @@
1
1
  import { callAiFn } from '../ai-model/common';
2
- import type { AIElementResponse, AIUsageInfo, BaseElement, DetailedLocateParam, DumpSubscriber, InsightAction, InsightExtractOption, InsightExtractParam, InsightOptions, InsightTaskInfo, LocateResult, UIContext } from '../types';
3
- import type { TMultimodalPrompt } from '../ai-model/common';
2
+ import type { AIElementResponse, AIUsageInfo, BaseElement, DetailedLocateParam, DumpSubscriber, InsightAction, InsightExtractOption, InsightExtractParam, InsightOptions, InsightTaskInfo, LocateResult, TMultimodalPrompt, UIContext } from '../types';
4
3
  export interface LocateOpts {
5
4
  context?: UIContext<BaseElement>;
6
5
  callAI?: typeof callAiFn<AIElementResponse>;
@@ -2,7 +2,6 @@ import type { NodeType } from '@midscene/shared/constants';
2
2
  import type { BaseElement, ElementTreeNode, Rect, Size } from '@midscene/shared/types';
3
3
  import type { ChatCompletionMessageParam } from 'openai/resources/index';
4
4
  import type { z } from 'zod';
5
- import type { TUserPrompt } from './ai-model/common';
6
5
  import type { DetailedLocateParam, MidsceneYamlFlowItem } from './yaml';
7
6
  export type { ElementTreeNode, BaseElement, Rect, Size, Point, } from '@midscene/shared/types';
8
7
  export * from './yaml';
@@ -370,6 +369,26 @@ export interface StreamingAIResponse {
370
369
  /** Whether the response was streamed */
371
370
  isStreamed: boolean;
372
371
  }
372
+ export type TMultimodalPrompt = {
373
+ /**
374
+ * Support use image to inspect elements.
375
+ * The "images" field is an object that uses image name as key and image url as value.
376
+ * The image url can be a local path, a http link , or a base64 string.
377
+ */
378
+ images?: {
379
+ name: string;
380
+ url: string;
381
+ }[];
382
+ /**
383
+ * By default, the image url in the "images" filed starts with `https://` or `http://` will be directly sent to the LLM.
384
+ * In case the images are not accessible to the LLM (One common case is that image url is internal network only.), you can enable this option.
385
+ * Then image will be download and convert to base64 format.
386
+ */
387
+ convertHttpImage2Base64?: boolean;
388
+ };
389
+ export type TUserPrompt = string | ({
390
+ prompt: string;
391
+ } & Partial<TMultimodalPrompt>);
373
392
  export interface DeviceAction<T = {}> {
374
393
  name: string;
375
394
  description?: string;
@@ -1,8 +1,6 @@
1
- import type { TUserPrompt } from './ai-model/common';
2
- import type { Rect } from './types';
1
+ import type { Rect, TUserPrompt } from './types';
3
2
  import type { BaseElement, UIContext } from './types';
4
3
  export interface LocateOption {
5
- prompt?: TUserPrompt;
6
4
  deepThink?: boolean;
7
5
  cacheable?: boolean;
8
6
  xpath?: string;
@@ -120,7 +118,7 @@ export interface MidsceneYamlFlowItemAIInput extends LocateOption {
120
118
  }
121
119
  export interface MidsceneYamlFlowItemAIKeyboardPress extends LocateOption {
122
120
  aiKeyboardPress: TUserPrompt | undefined;
123
- keyName: string;
121
+ key: string;
124
122
  }
125
123
  export interface MidsceneYamlFlowItemAIScroll extends LocateOption, ScrollParam {
126
124
  aiScroll: TUserPrompt | undefined;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@midscene/core",
3
3
  "description": "Automate browser actions, extract data, and perform assertions using AI. It offers JavaScript SDK, Chrome extension, and support for scripting in YAML. See https://midscenejs.com/ for details.",
4
- "version": "0.26.7-beta-20250820160625.0",
4
+ "version": "0.26.7-beta-20250821033353.0",
5
5
  "repository": "https://github.com/web-infra-dev/midscene",
6
6
  "homepage": "https://midscenejs.com/",
7
7
  "main": "./dist/lib/index.js",
@@ -61,8 +61,8 @@
61
61
  "openai": "4.81.0",
62
62
  "socks-proxy-agent": "8.0.4",
63
63
  "zod": "3.24.3",
64
- "@midscene/recorder": "0.26.7-beta-20250820160625.0",
65
- "@midscene/shared": "0.26.7-beta-20250820160625.0"
64
+ "@midscene/recorder": "0.26.7-beta-20250821033353.0",
65
+ "@midscene/shared": "0.26.7-beta-20250821033353.0"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@microsoft/api-extractor": "^7.52.10",