@midscene/core 0.24.2-beta-20250731010609.0 → 0.24.2-beta-20250731030716.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-YCHAOUOW.js → chunk-3LFZDNMQ.js} +46 -7
- package/dist/es/chunk-3LFZDNMQ.js.map +1 -0
- package/dist/es/{chunk-EJK3T22H.js → chunk-6AFIPCHE.js} +7 -12
- package/dist/es/chunk-6AFIPCHE.js.map +1 -0
- package/dist/es/index.d.ts +4 -4
- package/dist/es/index.js +2 -2
- package/dist/es/{llm-planning-3f26578e.d.ts → llm-planning-ae19dc49.d.ts} +1 -1
- package/dist/es/{types-c519555a.d.ts → types-d187efec.d.ts} +16 -2
- 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-YCHAOUOW.js → chunk-3LFZDNMQ.js} +46 -7
- package/dist/lib/chunk-3LFZDNMQ.js.map +1 -0
- package/dist/lib/{chunk-EJK3T22H.js → chunk-6AFIPCHE.js} +6 -11
- package/dist/lib/chunk-6AFIPCHE.js.map +1 -0
- package/dist/lib/index.d.ts +4 -4
- package/dist/lib/index.js +12 -12
- package/dist/lib/{llm-planning-3f26578e.d.ts → llm-planning-ae19dc49.d.ts} +1 -1
- package/dist/{types/types-c519555a.d.ts → lib/types-d187efec.d.ts} +16 -2
- 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-3f26578e.d.ts → llm-planning-ae19dc49.d.ts} +1 -1
- package/dist/{lib/types-c519555a.d.ts → types/types-d187efec.d.ts} +16 -2
- package/dist/types/utils.d.ts +1 -1
- package/package.json +3 -3
- package/dist/es/chunk-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AAa;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"]}
|
package/dist/es/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { E as ExecutionTask, a as ExecutionTaskProgressOptions, b as ExecutionTaskApply, c as ExecutionDump, U as UIContext, I as InsightAction, D as DumpSubscriber, d as InsightTaskInfo, e as InsightOptions, f as DetailedLocateParam, L as LocateResult, g as InsightExtractOption, h as InsightAssertionResponse, A as AIDescribeElementResponse } from './types-
|
|
2
|
-
export { w as AIAssertionResponse, u as AIDataExtractionResponse, s as AIElementCoordinatesResponse, r as AIElementLocatorResponse, t as AIElementResponse, n as AIResponseFormat, v as AISectionLocatorResponse, q as AISingleElementResponse, o as AISingleElementResponseById, p as AISingleElementResponseByPosition, m as AIUsageInfo, S as AgentAssertOpt, z as AgentDescribeElementAtPointResult, Q as AgentWaitForOpt,
|
|
3
|
-
import { c as callAiFn } from './llm-planning-
|
|
4
|
-
export { a as AiAssert, A as AiLocateElement, d as describeUserPage, p as plan } from './llm-planning-
|
|
1
|
+
import { E as ExecutionTask, a as ExecutionTaskProgressOptions, b as ExecutionTaskApply, c as ExecutionDump, U as UIContext, I as InsightAction, D as DumpSubscriber, d as InsightTaskInfo, e as InsightOptions, f as DetailedLocateParam, L as LocateResult, g as InsightExtractOption, h as InsightAssertionResponse, A as AIDescribeElementResponse } from './types-d187efec.js';
|
|
2
|
+
export { w as AIAssertionResponse, u as AIDataExtractionResponse, s as AIElementCoordinatesResponse, r as AIElementLocatorResponse, t as AIElementResponse, n as AIResponseFormat, v as AISectionLocatorResponse, q as AISingleElementResponse, o as AISingleElementResponseById, p as AISingleElementResponseByPosition, m as AIUsageInfo, S as AgentAssertOpt, z as AgentDescribeElementAtPointResult, Q as AgentWaitForOpt, a7 as BaseAgentParserOpt, C as CallAIFn, aB as CodeGenerationChunk, a6 as Color, H as DumpMeta, N as ElementById, B as EnsureObject, aa as ExecutionRecorderItem, as as ExecutionTaskAction, ar as ExecutionTaskActionApply, ad as ExecutionTaskHitBy, aq as ExecutionTaskInsightAssertion, ap as ExecutionTaskInsightAssertionApply, ao as ExecutionTaskInsightAssertionParam, ah as ExecutionTaskInsightDumpLog, aj as ExecutionTaskInsightLocate, ai as ExecutionTaskInsightLocateApply, ag as ExecutionTaskInsightLocateOutput, af as ExecutionTaskInsightLocateParam, an as ExecutionTaskInsightQuery, am as ExecutionTaskInsightQueryApply, al as ExecutionTaskInsightQueryOutput, ak as ExecutionTaskInsightQueryParam, au as ExecutionTaskLog, at as ExecutionTaskLogApply, aw as ExecutionTaskPlanning, av as ExecutionTaskPlanningApply, ae as ExecutionTaskReturn, ab as ExecutionTaskType, ac as ExecutorContext, a$ as FreeFn, ax as GroupedActionDump, J as InsightDump, F as InsightExtractParam, K as LiteUISection, aD as LocateOption, G as LocateResultElement, y as LocateValidatorResult, x as LocatorValidatorOption, b2 as MidsceneYamlConfig, b3 as MidsceneYamlConfigOutput, l as MidsceneYamlConfigResult, j as MidsceneYamlFlowItem, aK as MidsceneYamlFlowItemAIAction, aP as MidsceneYamlFlowItemAIAsk, aL as MidsceneYamlFlowItemAIAssert, aQ as MidsceneYamlFlowItemAIBoolean, aU as MidsceneYamlFlowItemAIHover, aV as MidsceneYamlFlowItemAIInput, aW as MidsceneYamlFlowItemAIKeyboardPress, aR as MidsceneYamlFlowItemAILocate, aN as MidsceneYamlFlowItemAINumber, aM as MidsceneYamlFlowItemAIQuery, k as MidsceneYamlFlowItemAIRightClick, aX as MidsceneYamlFlowItemAIScroll, aO as MidsceneYamlFlowItemAIString, aT as MidsceneYamlFlowItemAITap, aS as MidsceneYamlFlowItemAIWaitFor, aY as MidsceneYamlFlowItemEvaluateJavaScript, a_ as MidsceneYamlFlowItemLogScreenshot, aZ as MidsceneYamlFlowItemSleep, M as MidsceneYamlScript, aI as MidsceneYamlScriptAndroidEnv, aJ as MidsceneYamlScriptEnv, aG as MidsceneYamlScriptEnvBase, aH as MidsceneYamlScriptWebEnv, i as MidsceneYamlTask, O as OnTaskStartTip, ay as PageType, P as PartialInsightDumpFromSDK, W as PlanningAIResponse, V as PlanningAction, a4 as PlanningActionParamAndroidLongPress, a5 as PlanningActionParamAndroidPull, a0 as PlanningActionParamAssert, a2 as PlanningActionParamError, Y as PlanningActionParamHover, _ as PlanningActionParamInputOrKeyPress, Z as PlanningActionParamRightClick, $ as PlanningActionParamScroll, a1 as PlanningActionParamSleep, X as PlanningActionParamTap, a3 as PlanningActionParamWaitFor, T as PlanningLocateParam, a9 as PlaywrightParserOpt, a8 as PuppeteerParserOpt, aE as ReferenceImage, R as ReportDumpWithAttributes, b1 as ScriptPlayerStatusValue, b0 as ScriptPlayerTaskStatus, aC as StreamingAIResponse, aA as StreamingCallback, az as StreamingCodeGenerationOptions, aF as scrollParam } from './types-d187efec.js';
|
|
3
|
+
import { c as callAiFn } from './llm-planning-ae19dc49.js';
|
|
4
|
+
export { a as AiAssert, A as AiLocateElement, d as describeUserPage, p as plan } from './llm-planning-ae19dc49.js';
|
|
5
5
|
import { BaseElement, Rect } from '@midscene/shared/types';
|
|
6
6
|
export { BaseElement, ElementTreeNode, Point, Rect, Size } from '@midscene/shared/types';
|
|
7
7
|
export { getVersion } from './utils.js';
|
package/dist/es/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getVersion
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-6AFIPCHE.js";
|
|
4
4
|
import {
|
|
5
5
|
AiAssert,
|
|
6
6
|
AiExtractElementInfo,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
describeUserPage,
|
|
12
12
|
expandSearchArea,
|
|
13
13
|
plan
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-3LFZDNMQ.js";
|
|
15
15
|
|
|
16
16
|
// src/ai-model/action-executor.ts
|
|
17
17
|
import {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { m as AIUsageInfo, U as UIContext,
|
|
1
|
+
import { m as AIUsageInfo, U as UIContext, aE as ReferenceImage, r as AIElementLocatorResponse, N as ElementById, g as InsightExtractOption, u as AIDataExtractionResponse, w as AIAssertionResponse, ay as PageType, W as PlanningAIResponse } from './types-d187efec.js';
|
|
2
2
|
import { Rect, ElementTreeNode, BaseElement } from '@midscene/shared/types';
|
|
3
3
|
import { ChatCompletionSystemMessageParam, ChatCompletionUserMessageParam } from 'openai/resources';
|
|
4
4
|
|
|
@@ -357,7 +357,7 @@ interface PlanningLocateParam extends DetailedLocateParam {
|
|
|
357
357
|
}
|
|
358
358
|
interface PlanningAction<ParamType = any> {
|
|
359
359
|
thought?: string;
|
|
360
|
-
type: 'Locate' | 'Tap' | 'RightClick' | 'Hover' | 'Drag' | 'Input' | 'KeyboardPress' | 'Scroll' | 'Error' | 'ExpectedFalsyCondition' | 'Assert' | 'AssertWithoutThrow' | 'Sleep' | 'Finished' | 'AndroidBackButton' | 'AndroidHomeButton' | 'AndroidRecentAppsButton';
|
|
360
|
+
type: 'Locate' | 'Tap' | 'RightClick' | 'Hover' | 'Drag' | 'Input' | 'KeyboardPress' | 'Scroll' | 'Error' | 'ExpectedFalsyCondition' | 'Assert' | 'AssertWithoutThrow' | 'Sleep' | 'Finished' | 'AndroidBackButton' | 'AndroidHomeButton' | 'AndroidRecentAppsButton' | 'AndroidLongPress' | 'AndroidPull';
|
|
361
361
|
param: ParamType;
|
|
362
362
|
locate?: PlanningLocateParam | null;
|
|
363
363
|
}
|
|
@@ -393,6 +393,20 @@ interface PlanningActionParamError {
|
|
|
393
393
|
type PlanningActionParamWaitFor = AgentWaitForOpt & {
|
|
394
394
|
assertion: string;
|
|
395
395
|
};
|
|
396
|
+
interface PlanningActionParamAndroidLongPress {
|
|
397
|
+
x: number;
|
|
398
|
+
y: number;
|
|
399
|
+
duration?: number;
|
|
400
|
+
}
|
|
401
|
+
interface PlanningActionParamAndroidPull {
|
|
402
|
+
direction: 'up' | 'down';
|
|
403
|
+
startPoint?: {
|
|
404
|
+
x: number;
|
|
405
|
+
y: number;
|
|
406
|
+
};
|
|
407
|
+
distance?: number;
|
|
408
|
+
duration?: number;
|
|
409
|
+
}
|
|
396
410
|
/**
|
|
397
411
|
* misc
|
|
398
412
|
*/
|
|
@@ -528,4 +542,4 @@ interface StreamingAIResponse {
|
|
|
528
542
|
isStreamed: boolean;
|
|
529
543
|
}
|
|
530
544
|
|
|
531
|
-
export { type PlanningActionParamScroll as $, type AIDescribeElementResponse as A, type EnsureObject as B, type CallAIFn as C, type DumpSubscriber as D, type ExecutionTask as E, type InsightExtractParam as F, type LocateResultElement as G, type DumpMeta as H, type InsightAction as I, type InsightDump as J, type LiteUISection as K, type LocateResult as L, type MidsceneYamlScript as M, type ElementById as N, type OnTaskStartTip as O, type PartialInsightDumpFromSDK as P, type AgentWaitForOpt as Q, type ReportDumpWithAttributes as R, type AgentAssertOpt as S, type PlanningLocateParam as T, UIContext as U, type PlanningAction as V, type PlanningAIResponse as W, type PlanningActionParamTap as X, type PlanningActionParamHover as Y, type PlanningActionParamRightClick as Z, type PlanningActionParamInputOrKeyPress as _, type ExecutionTaskProgressOptions as a, type
|
|
545
|
+
export { type PlanningActionParamScroll as $, type AIDescribeElementResponse as A, type EnsureObject as B, type CallAIFn as C, type DumpSubscriber as D, type ExecutionTask as E, type InsightExtractParam as F, type LocateResultElement as G, type DumpMeta as H, type InsightAction as I, type InsightDump as J, type LiteUISection as K, type LocateResult as L, type MidsceneYamlScript as M, type ElementById as N, type OnTaskStartTip as O, type PartialInsightDumpFromSDK as P, type AgentWaitForOpt as Q, type ReportDumpWithAttributes as R, type AgentAssertOpt as S, type PlanningLocateParam as T, UIContext as U, type PlanningAction as V, type PlanningAIResponse as W, type PlanningActionParamTap as X, type PlanningActionParamHover as Y, type PlanningActionParamRightClick as Z, type PlanningActionParamInputOrKeyPress as _, type ExecutionTaskProgressOptions as a, type FreeFn as a$, type PlanningActionParamAssert as a0, type PlanningActionParamSleep as a1, type PlanningActionParamError as a2, type PlanningActionParamWaitFor as a3, type PlanningActionParamAndroidLongPress as a4, type PlanningActionParamAndroidPull as a5, type Color as a6, type BaseAgentParserOpt as a7, type PuppeteerParserOpt as a8, type PlaywrightParserOpt as a9, type StreamingCallback as aA, type CodeGenerationChunk as aB, type StreamingAIResponse as aC, type LocateOption as aD, type ReferenceImage as aE, type scrollParam as aF, type MidsceneYamlScriptEnvBase as aG, type MidsceneYamlScriptWebEnv as aH, type MidsceneYamlScriptAndroidEnv as aI, type MidsceneYamlScriptEnv as aJ, type MidsceneYamlFlowItemAIAction as aK, type MidsceneYamlFlowItemAIAssert as aL, type MidsceneYamlFlowItemAIQuery as aM, type MidsceneYamlFlowItemAINumber as aN, type MidsceneYamlFlowItemAIString as aO, type MidsceneYamlFlowItemAIAsk as aP, type MidsceneYamlFlowItemAIBoolean as aQ, type MidsceneYamlFlowItemAILocate as aR, type MidsceneYamlFlowItemAIWaitFor as aS, type MidsceneYamlFlowItemAITap as aT, type MidsceneYamlFlowItemAIHover as aU, type MidsceneYamlFlowItemAIInput as aV, type MidsceneYamlFlowItemAIKeyboardPress as aW, type MidsceneYamlFlowItemAIScroll as aX, type MidsceneYamlFlowItemEvaluateJavaScript as aY, type MidsceneYamlFlowItemSleep as aZ, type MidsceneYamlFlowItemLogScreenshot as a_, type ExecutionRecorderItem as aa, type ExecutionTaskType as ab, type ExecutorContext as ac, type ExecutionTaskHitBy as ad, type ExecutionTaskReturn as ae, type ExecutionTaskInsightLocateParam as af, type ExecutionTaskInsightLocateOutput as ag, type ExecutionTaskInsightDumpLog as ah, type ExecutionTaskInsightLocateApply as ai, type ExecutionTaskInsightLocate as aj, type ExecutionTaskInsightQueryParam as ak, type ExecutionTaskInsightQueryOutput as al, type ExecutionTaskInsightQueryApply as am, type ExecutionTaskInsightQuery as an, type ExecutionTaskInsightAssertionParam as ao, type ExecutionTaskInsightAssertionApply as ap, type ExecutionTaskInsightAssertion as aq, type ExecutionTaskActionApply as ar, type ExecutionTaskAction as as, type ExecutionTaskLogApply as at, type ExecutionTaskLog as au, type ExecutionTaskPlanningApply as av, type ExecutionTaskPlanning as aw, type GroupedActionDump as ax, type PageType as ay, type StreamingCodeGenerationOptions as az, type ExecutionTaskApply as b, type ScriptPlayerTaskStatus as b0, type ScriptPlayerStatusValue as b1, type MidsceneYamlConfig as b2, type MidsceneYamlConfigOutput as b3, type ExecutionDump as c, type InsightTaskInfo as d, type InsightOptions as e, type DetailedLocateParam as f, type InsightExtractOption as g, type InsightAssertionResponse as h, type MidsceneYamlTask as i, type MidsceneYamlFlowItem as j, type MidsceneYamlFlowItemAIRightClick as k, type MidsceneYamlConfigResult as l, type AIUsageInfo as m, AIResponseFormat as n, type AISingleElementResponseById as o, type AISingleElementResponseByPosition as p, type AISingleElementResponse as q, type AIElementLocatorResponse as r, type AIElementCoordinatesResponse as s, type AIElementResponse as t, type AIDataExtractionResponse as u, type AISectionLocatorResponse as v, type AIAssertionResponse as w, type LocatorValidatorOption as x, type LocateValidatorResult as y, type AgentDescribeElementAtPointResult as z };
|
package/dist/es/utils.d.ts
CHANGED
package/dist/es/utils.js
CHANGED
package/dist/lib/ai-model.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { aA as StreamingCallback, m as AIUsageInfo, az as StreamingCodeGenerationOptions, aC as StreamingAIResponse, V as PlanningAction, j as MidsceneYamlFlowItem } from './types-d187efec.js';
|
|
2
2
|
import OpenAI from 'openai';
|
|
3
3
|
import { ChatCompletionMessageParam } from 'openai/resources';
|
|
4
4
|
export { ChatCompletionMessageParam } from 'openai/resources';
|
|
5
|
-
import { b as AIActionType } from './llm-planning-
|
|
6
|
-
export { a as AiAssert, f as AiExtractElementInfo, A as AiLocateElement, g as AiLocateSection, h as adaptBboxToRect, c as callAiFn, d as describeUserPage, e as elementByPositionWithElementInfo, p as plan } from './llm-planning-
|
|
5
|
+
import { b as AIActionType } from './llm-planning-ae19dc49.js';
|
|
6
|
+
export { a as AiAssert, f as AiExtractElementInfo, A as AiLocateElement, g as AiLocateSection, h as adaptBboxToRect, c as callAiFn, d as describeUserPage, e as elementByPositionWithElementInfo, p as plan } from './llm-planning-ae19dc49.js';
|
|
7
7
|
import { vlLocateMode } from '@midscene/shared/env';
|
|
8
8
|
import { actionParser } from '@ui-tars/action-parser';
|
|
9
9
|
import { Size } from '@midscene/shared/types';
|
package/dist/lib/ai-model.js
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
var
|
|
21
|
+
var _chunk3LFZDNMQjs = require('./chunk-3LFZDNMQ.js');
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
|
|
@@ -39,4 +39,4 @@ var _chunkYCHAOUOWjs = require('./chunk-YCHAOUOW.js');
|
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
|
|
42
|
-
exports.AIActionType =
|
|
42
|
+
exports.AIActionType = _chunk3LFZDNMQjs.AIActionType; exports.AiAssert = _chunk3LFZDNMQjs.AiAssert; exports.AiExtractElementInfo = _chunk3LFZDNMQjs.AiExtractElementInfo; exports.AiLocateElement = _chunk3LFZDNMQjs.AiLocateElement; exports.AiLocateSection = _chunk3LFZDNMQjs.AiLocateSection; exports.adaptBboxToRect = _chunk3LFZDNMQjs.adaptBboxToRect; exports.callAi = _chunk3LFZDNMQjs.call; exports.callAiFn = _chunk3LFZDNMQjs.callAiFn; exports.callToGetJSONObject = _chunk3LFZDNMQjs.callToGetJSONObject; exports.describeUserPage = _chunk3LFZDNMQjs.describeUserPage; exports.elementByPositionWithElementInfo = _chunk3LFZDNMQjs.elementByPositionWithElementInfo; exports.generatePlaywrightTest = _chunk3LFZDNMQjs.generatePlaywrightTest; exports.generatePlaywrightTestStream = _chunk3LFZDNMQjs.generatePlaywrightTestStream; exports.generateYamlTest = _chunk3LFZDNMQjs.generateYamlTest; exports.generateYamlTestStream = _chunk3LFZDNMQjs.generateYamlTestStream; exports.plan = _chunk3LFZDNMQjs.plan; exports.resizeImageForUiTars = _chunk3LFZDNMQjs.resizeImageForUiTars; exports.systemPromptToLocateElement = _chunk3LFZDNMQjs.systemPromptToLocateElement; exports.vlmPlanning = _chunk3LFZDNMQjs.vlmPlanning;
|
|
@@ -300,7 +300,7 @@ function buildYamlFlowFromPlans(plans, sleep) {
|
|
|
300
300
|
flow.push({
|
|
301
301
|
sleep: param.timeMs
|
|
302
302
|
});
|
|
303
|
-
} else if (type === "AndroidBackButton" || type === "AndroidHomeButton" || type === "AndroidRecentAppsButton") {
|
|
303
|
+
} else if (type === "AndroidBackButton" || type === "AndroidHomeButton" || type === "AndroidRecentAppsButton" || type === "AndroidLongPress" || type === "AndroidPull") {
|
|
304
304
|
} else if (type === "Error" || type === "ExpectedFalsyCondition" || type === "Assert" || type === "AssertWithoutThrow" || type === "Finished") {
|
|
305
305
|
} else {
|
|
306
306
|
console.warn(
|
|
@@ -794,7 +794,7 @@ Target: User will give you a screenshot, an instruction and some previous logs i
|
|
|
794
794
|
|
|
795
795
|
Restriction:
|
|
796
796
|
- Don't give extra actions or plans beyond the instruction. ONLY plan for what the instruction requires. For example, don't try to submit the form if the instruction is only to fill something.
|
|
797
|
-
- Always give ONLY ONE action in \`log\` field (or null if no action should be done), instead of multiple actions. Supported actions are Tap, Hover, Input, KeyboardPress, Scroll${pageType === "android" ? ", AndroidBackButton, AndroidHomeButton, AndroidRecentAppsButton." : "."}
|
|
797
|
+
- Always give ONLY ONE action in \`log\` field (or null if no action should be done), instead of multiple actions. Supported actions are Tap, Hover, Input, KeyboardPress, Scroll${pageType === "android" ? ", AndroidBackButton, AndroidHomeButton, AndroidRecentAppsButton, AndroidLongPress, AndroidPull." : "."}
|
|
798
798
|
- Don't repeat actions in the previous logs.
|
|
799
799
|
- Bbox is the bounding box of the element to be located. It's an array of 4 numbers, representing ${bboxDescription(vlMode)}.
|
|
800
800
|
|
|
@@ -807,7 +807,9 @@ Supporting actions:
|
|
|
807
807
|
- Scroll: { type: "Scroll", ${vlLocateParam} | null, param: { direction: 'down'(default) | 'up' | 'right' | 'left', scrollType: 'once' (default) | 'untilBottom' | 'untilTop' | 'untilRight' | 'untilLeft', distance: null | number }} // locate is the element to scroll. If it's a page scroll, put \`null\` in the \`locate\` field.
|
|
808
808
|
${pageType === "android" ? `- AndroidBackButton: { type: "AndroidBackButton", param: {} }
|
|
809
809
|
- AndroidHomeButton: { type: "AndroidHomeButton", param: {} }
|
|
810
|
-
- AndroidRecentAppsButton: { type: "AndroidRecentAppsButton", param: {} }
|
|
810
|
+
- AndroidRecentAppsButton: { type: "AndroidRecentAppsButton", param: {} }
|
|
811
|
+
- AndroidLongPress: { type: "AndroidLongPress", param: { x: number, y: number, duration?: number } }
|
|
812
|
+
- AndroidPull: { type: "AndroidPull", param: { direction: 'up' | 'down', startPoint?: { x: number, y: number }, distance?: number, duration?: number } } // Pull down to refresh (direction: 'down') or pull up to load more (direction: 'up')` : ""}
|
|
811
813
|
|
|
812
814
|
Field description:
|
|
813
815
|
* The \`prompt\` field inside the \`locate\` field is a short description that could be used to locate the element.
|
|
@@ -857,7 +859,7 @@ You are a versatile professional in software UI automation. Your outstanding con
|
|
|
857
859
|
## Workflow
|
|
858
860
|
|
|
859
861
|
1. Receive the screenshot, element description of screenshot(if any), user's instruction and previous logs.
|
|
860
|
-
2. Decompose the user's task into a sequence of actions, and place it in the \`actions\` field. There are different types of actions (Tap / Hover / Input / KeyboardPress / Scroll / FalsyConditionStatement / Sleep ${pageType === "android" ? "/ AndroidBackButton / AndroidHomeButton / AndroidRecentAppsButton" : ""}). The "About the action" section below will give you more details.
|
|
862
|
+
2. Decompose the user's task into a sequence of actions, and place it in the \`actions\` field. There are different types of actions (Tap / Hover / Input / KeyboardPress / Scroll / FalsyConditionStatement / Sleep ${pageType === "android" ? "/ AndroidBackButton / AndroidHomeButton / AndroidRecentAppsButton / AndroidLongPress / AndroidPull" : ""}). The "About the action" section below will give you more details.
|
|
861
863
|
3. Precisely locate the target element if it's already shown in the screenshot, put the location info in the \`locate\` field of the action.
|
|
862
864
|
4. If some target elements is not shown in the screenshot, consider the user's instruction is not feasible on this page. Follow the next steps.
|
|
863
865
|
5. Consider whether the user's instruction will be accomplished after all the actions
|
|
@@ -916,7 +918,11 @@ ${pageType === "android" ? `- type: 'AndroidBackButton', trigger the system "bac
|
|
|
916
918
|
- type: 'AndroidHomeButton', trigger the system "home" operation on Android devices
|
|
917
919
|
* {{ param: {{}} }}
|
|
918
920
|
- type: 'AndroidRecentAppsButton', trigger the system "recent apps" operation on Android devices
|
|
919
|
-
* {{ param: {{}} }}
|
|
921
|
+
* {{ param: {{}} }}
|
|
922
|
+
- type: 'AndroidLongPress', trigger a long press on the screen at specified coordinates on Android devices
|
|
923
|
+
* {{ param: {{ x: number, y: number, duration?: number }} }}
|
|
924
|
+
- type: 'AndroidPull', trigger pull down to refresh or pull up actions on Android devices
|
|
925
|
+
* {{ param: {{ direction: 'up' | 'down', startPoint?: {{ x: number, y: number }}, distance?: number, duration?: number }} }}` : ""}
|
|
920
926
|
`;
|
|
921
927
|
var outputTemplate = `
|
|
922
928
|
## Output JSON Format:
|
|
@@ -1030,7 +1036,7 @@ var planSchema = {
|
|
|
1030
1036
|
},
|
|
1031
1037
|
type: {
|
|
1032
1038
|
type: "string",
|
|
1033
|
-
description: 'Type of action, one of "Tap", "RightClick", "Hover" , "Input", "KeyboardPress", "Scroll", "ExpectedFalsyCondition", "Sleep", "AndroidBackButton", "AndroidHomeButton", "AndroidRecentAppsButton"'
|
|
1039
|
+
description: 'Type of action, one of "Tap", "RightClick", "Hover" , "Input", "KeyboardPress", "Scroll", "ExpectedFalsyCondition", "Sleep", "AndroidBackButton", "AndroidHomeButton", "AndroidRecentAppsButton", "AndroidLongPress"'
|
|
1034
1040
|
},
|
|
1035
1041
|
param: {
|
|
1036
1042
|
anyOf: [
|
|
@@ -2710,6 +2716,39 @@ async function vlmPlanning(options) {
|
|
|
2710
2716
|
type: "AndroidRecentAppsButton",
|
|
2711
2717
|
param: {}
|
|
2712
2718
|
});
|
|
2719
|
+
} else if (action.action_type === "androidLongPress") {
|
|
2720
|
+
_utils.assert.call(void 0,
|
|
2721
|
+
action.action_inputs.start_coords,
|
|
2722
|
+
"start_coords is required for androidLongPress"
|
|
2723
|
+
);
|
|
2724
|
+
const point = action.action_inputs.start_coords;
|
|
2725
|
+
transformActions.push({
|
|
2726
|
+
type: "AndroidLongPress",
|
|
2727
|
+
param: {
|
|
2728
|
+
x: point[0],
|
|
2729
|
+
y: point[1],
|
|
2730
|
+
duration: 1e3
|
|
2731
|
+
},
|
|
2732
|
+
locate: null,
|
|
2733
|
+
thought: action.thought || ""
|
|
2734
|
+
});
|
|
2735
|
+
} else if (action.action_type === "androidPull") {
|
|
2736
|
+
const pullDirection = action.action_inputs.direction || "down";
|
|
2737
|
+
const startPoint = action.action_inputs.start_coords ? {
|
|
2738
|
+
x: action.action_inputs.start_coords[0],
|
|
2739
|
+
y: action.action_inputs.start_coords[1]
|
|
2740
|
+
} : void 0;
|
|
2741
|
+
transformActions.push({
|
|
2742
|
+
type: "AndroidPull",
|
|
2743
|
+
param: {
|
|
2744
|
+
direction: pullDirection,
|
|
2745
|
+
startPoint,
|
|
2746
|
+
distance: action.action_inputs.distance,
|
|
2747
|
+
duration: action.action_inputs.duration || 500
|
|
2748
|
+
},
|
|
2749
|
+
locate: null,
|
|
2750
|
+
thought: action.thought || ""
|
|
2751
|
+
});
|
|
2713
2752
|
}
|
|
2714
2753
|
});
|
|
2715
2754
|
if (transformActions.length === 0) {
|
|
@@ -2793,4 +2832,4 @@ async function resizeImageForUiTars(imageBase64, size) {
|
|
|
2793
2832
|
|
|
2794
2833
|
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;
|
|
2795
2834
|
|
|
2796
|
-
//# sourceMappingURL=chunk-
|
|
2835
|
+
//# sourceMappingURL=chunk-3LFZDNMQ.js.map
|