@midscene/core 0.27.1-beta-20250822053848.0 → 0.27.1-beta-20250822094725.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/agent/agent.mjs +518 -0
- package/dist/es/agent/agent.mjs.map +1 -0
- package/dist/es/agent/index.mjs +6 -0
- package/dist/es/agent/task-cache.mjs +149 -0
- package/dist/es/agent/task-cache.mjs.map +1 -0
- package/dist/es/agent/tasks.mjs +767 -0
- package/dist/es/agent/tasks.mjs.map +1 -0
- package/dist/es/agent/ui-utils.mjs +89 -0
- package/dist/es/agent/ui-utils.mjs.map +1 -0
- package/dist/es/agent/utils.mjs +337 -0
- package/dist/es/agent/utils.mjs.map +1 -0
- package/dist/es/device/index.mjs +20 -0
- package/dist/es/device/index.mjs.map +1 -0
- package/dist/es/index.mjs +2 -1
- package/dist/es/index.mjs.map +1 -1
- package/dist/es/types.mjs.map +1 -1
- package/dist/es/utils.mjs +2 -2
- package/dist/es/yaml/builder.mjs +13 -0
- package/dist/es/yaml/builder.mjs.map +1 -0
- package/dist/es/yaml/index.mjs +3 -0
- package/dist/es/yaml/player.mjs +375 -0
- package/dist/es/yaml/player.mjs.map +1 -0
- package/dist/es/yaml/utils.mjs +39 -0
- package/dist/es/yaml/utils.mjs.map +1 -0
- package/dist/lib/agent/agent.js +562 -0
- package/dist/lib/agent/agent.js.map +1 -0
- package/dist/lib/agent/index.js +90 -0
- package/dist/lib/agent/index.js.map +1 -0
- package/dist/lib/agent/task-cache.js +201 -0
- package/dist/lib/agent/task-cache.js.map +1 -0
- package/dist/lib/agent/tasks.js +804 -0
- package/dist/lib/agent/tasks.js.map +1 -0
- package/dist/lib/agent/ui-utils.js +141 -0
- package/dist/lib/agent/ui-utils.js.map +1 -0
- package/dist/lib/agent/utils.js +417 -0
- package/dist/lib/agent/utils.js.map +1 -0
- package/dist/lib/device/index.js +54 -0
- package/dist/lib/device/index.js.map +1 -0
- package/dist/lib/index.js +5 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/types.js.map +1 -1
- package/dist/lib/utils.js +2 -2
- package/dist/lib/yaml/builder.js +57 -0
- package/dist/lib/yaml/builder.js.map +1 -0
- package/dist/lib/yaml/index.js +80 -0
- package/dist/lib/yaml/index.js.map +1 -0
- package/dist/lib/yaml/player.js +409 -0
- package/dist/lib/yaml/player.js.map +1 -0
- package/dist/lib/yaml/utils.js +86 -0
- package/dist/lib/yaml/utils.js.map +1 -0
- package/dist/types/agent/agent.d.ts +123 -0
- package/dist/types/agent/index.d.ts +9 -0
- package/dist/types/agent/task-cache.d.ts +38 -0
- package/dist/types/agent/tasks.d.ts +56 -0
- package/dist/types/agent/ui-utils.d.ts +11 -0
- package/dist/types/agent/utils.d.ts +54 -0
- package/dist/types/device/index.d.ts +55 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/types.d.ts +1 -0
- package/dist/types/yaml/builder.d.ts +2 -0
- package/dist/types/yaml/index.d.ts +3 -0
- package/dist/types/yaml/player.d.ts +34 -0
- package/dist/types/yaml/utils.d.ts +3 -0
- package/package.json +27 -3
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: definition[key]
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
})();
|
|
20
|
+
(()=>{
|
|
21
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
+
})();
|
|
23
|
+
(()=>{
|
|
24
|
+
__webpack_require__.r = (exports1)=>{
|
|
25
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
+
value: 'Module'
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
+
value: true
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
})();
|
|
33
|
+
var __webpack_exports__ = {};
|
|
34
|
+
__webpack_require__.r(__webpack_exports__);
|
|
35
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
+
interpolateEnvVars: ()=>interpolateEnvVars,
|
|
37
|
+
parseYamlScript: ()=>parseYamlScript
|
|
38
|
+
});
|
|
39
|
+
const utils_namespaceObject = require("@midscene/shared/utils");
|
|
40
|
+
const external_js_yaml_namespaceObject = require("js-yaml");
|
|
41
|
+
var external_js_yaml_default = /*#__PURE__*/ __webpack_require__.n(external_js_yaml_namespaceObject);
|
|
42
|
+
function interpolateEnvVars(content) {
|
|
43
|
+
return content.replace(/\$\{([^}]+)\}/g, (_, envVar)=>{
|
|
44
|
+
const value = process.env[envVar.trim()];
|
|
45
|
+
if (void 0 === value) throw new Error(`Environment variable "${envVar.trim()}" is not defined`);
|
|
46
|
+
return value;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function parseYamlScript(content, filePath, ignoreCheckingTarget) {
|
|
50
|
+
let processedContent = content;
|
|
51
|
+
if (-1 !== content.indexOf('android') && content.match(/deviceId:\s*(\d+)/)) {
|
|
52
|
+
let matchedDeviceId;
|
|
53
|
+
processedContent = content.replace(/deviceId:\s*(\d+)/g, (match, deviceId)=>{
|
|
54
|
+
matchedDeviceId = deviceId;
|
|
55
|
+
return `deviceId: '${deviceId}'`;
|
|
56
|
+
});
|
|
57
|
+
console.warn(`please use string-style deviceId in yaml script, for example: deviceId: "${matchedDeviceId}"`);
|
|
58
|
+
}
|
|
59
|
+
const interpolatedContent = interpolateEnvVars(processedContent);
|
|
60
|
+
const obj = external_js_yaml_default().load(interpolatedContent, {
|
|
61
|
+
schema: external_js_yaml_default().JSON_SCHEMA
|
|
62
|
+
});
|
|
63
|
+
const pathTip = filePath ? `, failed to load ${filePath}` : '';
|
|
64
|
+
const android = void 0 !== obj.android ? Object.assign({}, obj.android || {}) : void 0;
|
|
65
|
+
const webConfig = obj.web || obj.target;
|
|
66
|
+
const web = void 0 !== webConfig ? Object.assign({}, webConfig || {}) : void 0;
|
|
67
|
+
if (!ignoreCheckingTarget) {
|
|
68
|
+
(0, utils_namespaceObject.assert)(web || android, `at least one of "target", "web", or "android" properties is required in yaml script${pathTip}`);
|
|
69
|
+
(0, utils_namespaceObject.assert)(web && !android || !web && android, `only one of "target", "web", or "android" properties is allowed in yaml script${pathTip}`);
|
|
70
|
+
if (web || android) (0, utils_namespaceObject.assert)('object' == typeof web || 'object' == typeof android, `property "target/web/android" must be an object${pathTip}`);
|
|
71
|
+
}
|
|
72
|
+
(0, utils_namespaceObject.assert)(obj.tasks, `property "tasks" is required in yaml script ${pathTip}`);
|
|
73
|
+
(0, utils_namespaceObject.assert)(Array.isArray(obj.tasks), `property "tasks" must be an array in yaml script, but got ${obj.tasks}`);
|
|
74
|
+
return obj;
|
|
75
|
+
}
|
|
76
|
+
exports.interpolateEnvVars = __webpack_exports__.interpolateEnvVars;
|
|
77
|
+
exports.parseYamlScript = __webpack_exports__.parseYamlScript;
|
|
78
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
79
|
+
"interpolateEnvVars",
|
|
80
|
+
"parseYamlScript"
|
|
81
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
82
|
+
Object.defineProperty(exports, '__esModule', {
|
|
83
|
+
value: true
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yaml/utils.js","sources":["webpack://@midscene/core/webpack/runtime/compat_get_default_export","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/yaml/utils.ts"],"sourcesContent":["// getDefaultExport function for compatibility with non-ESM modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { assert } from '@midscene/shared/utils';\nimport yaml from 'js-yaml';\n\nimport type { MidsceneYamlScript } from '@/index';\n\nexport function interpolateEnvVars(content: string): string {\n return content.replace(/\\$\\{([^}]+)\\}/g, (_, envVar) => {\n const value = process.env[envVar.trim()];\n if (value === undefined) {\n throw new Error(`Environment variable \"${envVar.trim()}\" is not defined`);\n }\n return value;\n });\n}\n\nexport function parseYamlScript(\n content: string,\n filePath?: string,\n ignoreCheckingTarget?: boolean,\n): MidsceneYamlScript {\n let processedContent = content;\n if (content.indexOf('android') !== -1 && content.match(/deviceId:\\s*(\\d+)/)) {\n let matchedDeviceId;\n processedContent = content.replace(\n /deviceId:\\s*(\\d+)/g,\n (match, deviceId) => {\n matchedDeviceId = deviceId;\n return `deviceId: '${deviceId}'`;\n },\n );\n console.warn(\n `please use string-style deviceId in yaml script, for example: deviceId: \"${matchedDeviceId}\"`,\n );\n }\n const interpolatedContent = interpolateEnvVars(processedContent);\n const obj = yaml.load(interpolatedContent, {\n schema: yaml.JSON_SCHEMA,\n }) as MidsceneYamlScript;\n\n const pathTip = filePath ? `, failed to load ${filePath}` : '';\n const android =\n typeof obj.android !== 'undefined'\n ? Object.assign({}, obj.android || {})\n : undefined;\n const webConfig = obj.web || obj.target; // no need to handle null case, because web has required parameters url\n const web =\n typeof webConfig !== 'undefined'\n ? Object.assign({}, webConfig || {})\n : undefined;\n\n if (!ignoreCheckingTarget) {\n // make sure at least one of target/web/android is provided\n assert(\n web || android,\n `at least one of \"target\", \"web\", or \"android\" properties is required in yaml script${pathTip}`,\n );\n\n // make sure only one of target/web/android is provided\n assert(\n (web && !android) || (!web && android),\n `only one of \"target\", \"web\", or \"android\" properties is allowed in yaml script${pathTip}`,\n );\n\n // make sure the config is valid\n if (web || android) {\n assert(\n typeof web === 'object' || typeof android === 'object',\n `property \"target/web/android\" must be an object${pathTip}`,\n );\n }\n }\n\n assert(obj.tasks, `property \"tasks\" is required in yaml script ${pathTip}`);\n assert(\n Array.isArray(obj.tasks),\n `property \"tasks\" must be an array in yaml script, but got ${obj.tasks}`,\n );\n return obj;\n}\n"],"names":["__webpack_require__","module","getter","definition","key","Object","obj","prop","Symbol","interpolateEnvVars","content","_","envVar","value","process","undefined","Error","parseYamlScript","filePath","ignoreCheckingTarget","processedContent","matchedDeviceId","match","deviceId","console","interpolatedContent","yaml","pathTip","android","webConfig","web","assert","Array"],"mappings":"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"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { type AgentAssertOpt, type AgentDescribeElementAtPointResult, type AgentWaitForOpt, type DeviceAction, type ExecutionDump, type GroupedActionDump, Insight, type InsightAction, type InsightExtractOption, type InsightExtractParam, type LocateOption, type LocateResultElement, type LocateValidatorResult, type LocatorValidatorOption, type OnTaskStartTip, type ScrollParam, type TUserPrompt, type UIContext } from '../index';
|
|
2
|
+
import type { AbstractPage } from '../device';
|
|
3
|
+
import { type TModelConfigFn } from '@midscene/shared/env';
|
|
4
|
+
import { TaskCache } from './task-cache';
|
|
5
|
+
import { PageTaskExecutor } from './tasks';
|
|
6
|
+
export interface PageAgentOpt {
|
|
7
|
+
testId?: string;
|
|
8
|
+
cacheId?: string;
|
|
9
|
+
groupName?: string;
|
|
10
|
+
groupDescription?: string;
|
|
11
|
+
generateReport?: boolean;
|
|
12
|
+
autoPrintReportMsg?: boolean;
|
|
13
|
+
onTaskStartTip?: OnTaskStartTip;
|
|
14
|
+
aiActionContext?: string;
|
|
15
|
+
reportFileName?: string;
|
|
16
|
+
modelConfig?: TModelConfigFn;
|
|
17
|
+
}
|
|
18
|
+
export declare class Agent<PageType extends AbstractPage = AbstractPage> {
|
|
19
|
+
page: PageType;
|
|
20
|
+
insight: Insight;
|
|
21
|
+
dump: GroupedActionDump;
|
|
22
|
+
reportFile?: string | null;
|
|
23
|
+
reportFileName?: string;
|
|
24
|
+
taskExecutor: PageTaskExecutor;
|
|
25
|
+
opts: PageAgentOpt;
|
|
26
|
+
/**
|
|
27
|
+
* If true, the agent will not perform any actions
|
|
28
|
+
*/
|
|
29
|
+
dryMode: boolean;
|
|
30
|
+
onTaskStartTip?: OnTaskStartTip;
|
|
31
|
+
taskCache?: TaskCache;
|
|
32
|
+
onDumpUpdate?: (dump: string) => void;
|
|
33
|
+
destroyed: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Frozen page context for consistent AI operations
|
|
36
|
+
*/
|
|
37
|
+
private frozenPageContext?;
|
|
38
|
+
constructor(page: PageType, opts?: PageAgentOpt);
|
|
39
|
+
getActionSpace(): Promise<DeviceAction[]>;
|
|
40
|
+
getUIContext(action?: InsightAction): Promise<UIContext>;
|
|
41
|
+
_snapshotContext(): Promise<UIContext>;
|
|
42
|
+
setAIActionContext(prompt: string): Promise<void>;
|
|
43
|
+
resetDump(): GroupedActionDump;
|
|
44
|
+
appendExecutionDump(execution: ExecutionDump): void;
|
|
45
|
+
dumpDataString(): string;
|
|
46
|
+
reportHTMLString(): string;
|
|
47
|
+
writeOutActionDumps(): void;
|
|
48
|
+
private callbackOnTaskStartTip;
|
|
49
|
+
private afterTaskRunning;
|
|
50
|
+
callActionInActionSpace<T = any>(type: string, opt?: T): Promise<any>;
|
|
51
|
+
aiTap(locatePrompt: TUserPrompt, opt?: LocateOption): Promise<any>;
|
|
52
|
+
aiRightClick(locatePrompt: TUserPrompt, opt?: LocateOption): Promise<any>;
|
|
53
|
+
aiHover(locatePrompt: TUserPrompt, opt?: LocateOption): Promise<any>;
|
|
54
|
+
aiInput(locatePrompt: TUserPrompt, opt: LocateOption & {
|
|
55
|
+
value: string;
|
|
56
|
+
}): Promise<any>;
|
|
57
|
+
/**
|
|
58
|
+
* @deprecated Use aiInput(locatePrompt, opt) instead where opt contains the value
|
|
59
|
+
*/
|
|
60
|
+
aiInput(value: string, locatePrompt: TUserPrompt, opt?: LocateOption): Promise<any>;
|
|
61
|
+
aiKeyboardPress(locatePrompt: TUserPrompt, opt: LocateOption & {
|
|
62
|
+
keyName: string;
|
|
63
|
+
}): Promise<any>;
|
|
64
|
+
/**
|
|
65
|
+
* @deprecated Use aiKeyboardPress(locatePrompt, opt) instead where opt contains the keyName
|
|
66
|
+
*/
|
|
67
|
+
aiKeyboardPress(keyName: string, locatePrompt?: TUserPrompt, opt?: LocateOption): Promise<any>;
|
|
68
|
+
aiScroll(locatePrompt: TUserPrompt | undefined, opt: LocateOption & ScrollParam): Promise<any>;
|
|
69
|
+
/**
|
|
70
|
+
* @deprecated Use aiScroll(locatePrompt, opt) instead where opt contains the scroll parameters
|
|
71
|
+
*/
|
|
72
|
+
aiScroll(scrollParam: ScrollParam, locatePrompt?: TUserPrompt, opt?: LocateOption): Promise<any>;
|
|
73
|
+
aiAction(taskPrompt: string, opt?: {
|
|
74
|
+
cacheable?: boolean;
|
|
75
|
+
}): Promise<{
|
|
76
|
+
yamlFlow?: import("../yaml").MidsceneYamlFlowItem[];
|
|
77
|
+
} | {
|
|
78
|
+
result: Record<string, any>;
|
|
79
|
+
} | undefined>;
|
|
80
|
+
aiQuery<ReturnType = any>(demand: InsightExtractParam, opt?: InsightExtractOption): Promise<ReturnType>;
|
|
81
|
+
aiBoolean(prompt: TUserPrompt, opt?: InsightExtractOption): Promise<boolean>;
|
|
82
|
+
aiNumber(prompt: TUserPrompt, opt?: InsightExtractOption): Promise<number>;
|
|
83
|
+
aiString(prompt: TUserPrompt, opt?: InsightExtractOption): Promise<string>;
|
|
84
|
+
aiAsk(prompt: TUserPrompt, opt?: InsightExtractOption): Promise<string>;
|
|
85
|
+
describeElementAtPoint(center: [number, number], opt?: {
|
|
86
|
+
verifyPrompt?: boolean;
|
|
87
|
+
retryLimit?: number;
|
|
88
|
+
deepThink?: boolean;
|
|
89
|
+
} & LocatorValidatorOption): Promise<AgentDescribeElementAtPointResult>;
|
|
90
|
+
verifyLocator(prompt: string, locateOpt: LocateOption | undefined, expectCenter: [number, number], verifyLocateOption?: LocatorValidatorOption): Promise<LocateValidatorResult>;
|
|
91
|
+
aiLocate(prompt: TUserPrompt, opt?: LocateOption): Promise<Pick<LocateResultElement, "center" | "rect"> & {
|
|
92
|
+
scale: number;
|
|
93
|
+
}>;
|
|
94
|
+
aiAssert(assertion: TUserPrompt, msg?: string, opt?: AgentAssertOpt & InsightExtractOption): Promise<{
|
|
95
|
+
pass: boolean;
|
|
96
|
+
thought: string | undefined;
|
|
97
|
+
message: string | undefined;
|
|
98
|
+
} | undefined>;
|
|
99
|
+
aiWaitFor(assertion: TUserPrompt, opt?: AgentWaitForOpt): Promise<void>;
|
|
100
|
+
ai(taskPrompt: string, type?: string): Promise<any>;
|
|
101
|
+
runYaml(yamlScriptContent: string): Promise<{
|
|
102
|
+
result: Record<string, any>;
|
|
103
|
+
}>;
|
|
104
|
+
evaluateJavaScript(script: string): Promise<any>;
|
|
105
|
+
destroy(): Promise<void>;
|
|
106
|
+
logScreenshot(title?: string, opt?: {
|
|
107
|
+
content: string;
|
|
108
|
+
}): Promise<void>;
|
|
109
|
+
_unstableLogContent(): {
|
|
110
|
+
groupName: string;
|
|
111
|
+
groupDescription: string | undefined;
|
|
112
|
+
executions: any[];
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Freezes the current page context to be reused in subsequent AI operations
|
|
116
|
+
* This avoids recalculating page context for each operation
|
|
117
|
+
*/
|
|
118
|
+
freezePageContext(): Promise<void>;
|
|
119
|
+
/**
|
|
120
|
+
* Unfreezes the page context, allowing AI operations to calculate context dynamically
|
|
121
|
+
*/
|
|
122
|
+
unfreezePageContext(): Promise<void>;
|
|
123
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { Agent, type PageAgentOpt } from './agent';
|
|
2
|
+
export { commonWebActionsForWebPage, commonContextParser } from './utils';
|
|
3
|
+
export { getReportFileName, printReportMsg, } from './utils';
|
|
4
|
+
export { locateParamStr, paramStr, taskTitleStr, typeStr } from './ui-utils';
|
|
5
|
+
export { type LocateCache, type PlanningCache, TaskCache } from './task-cache';
|
|
6
|
+
export { cacheFileExt } from './task-cache';
|
|
7
|
+
export { PageTaskExecutor } from './tasks';
|
|
8
|
+
export { getKeyCommands } from './ui-utils';
|
|
9
|
+
export { buildDetailedLocateParam, buildDetailedLocateParamAndRestParams, getCurrentExecutionFile, trimContextByViewport, } from './utils';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { TUserPrompt } from '../index';
|
|
2
|
+
export declare const debug: import("@midscene/shared/logger").DebugFunction;
|
|
3
|
+
export interface PlanningCache {
|
|
4
|
+
type: 'plan';
|
|
5
|
+
prompt: string;
|
|
6
|
+
yamlWorkflow: string;
|
|
7
|
+
}
|
|
8
|
+
export interface LocateCache {
|
|
9
|
+
type: 'locate';
|
|
10
|
+
prompt: TUserPrompt;
|
|
11
|
+
xpaths: string[];
|
|
12
|
+
}
|
|
13
|
+
export interface MatchCacheResult<T extends PlanningCache | LocateCache> {
|
|
14
|
+
cacheContent: T;
|
|
15
|
+
updateFn: (cb: (cache: T) => void) => void;
|
|
16
|
+
}
|
|
17
|
+
export type CacheFileContent = {
|
|
18
|
+
midsceneVersion: string;
|
|
19
|
+
cacheId: string;
|
|
20
|
+
caches: Array<PlanningCache | LocateCache>;
|
|
21
|
+
};
|
|
22
|
+
export declare const cacheFileExt = ".cache.yaml";
|
|
23
|
+
export declare class TaskCache {
|
|
24
|
+
cacheId: string;
|
|
25
|
+
cacheFilePath?: string;
|
|
26
|
+
cache: CacheFileContent;
|
|
27
|
+
isCacheResultUsed: boolean;
|
|
28
|
+
cacheOriginalLength: number;
|
|
29
|
+
private matchedCacheIndices;
|
|
30
|
+
constructor(cacheId: string, isCacheResultUsed: boolean, cacheFilePath?: string);
|
|
31
|
+
matchCache(prompt: TUserPrompt, type: 'plan' | 'locate'): MatchCacheResult<PlanningCache | LocateCache> | undefined;
|
|
32
|
+
matchPlanCache(prompt: string): MatchCacheResult<PlanningCache> | undefined;
|
|
33
|
+
matchLocateCache(prompt: TUserPrompt): MatchCacheResult<LocateCache> | undefined;
|
|
34
|
+
appendCache(cache: PlanningCache | LocateCache): void;
|
|
35
|
+
loadCacheFromFile(): CacheFileContent | undefined;
|
|
36
|
+
flushCacheToFile(): void;
|
|
37
|
+
updateOrAppendCacheRecord(newRecord: PlanningCache | LocateCache, cachedRecord?: MatchCacheResult<PlanningCache | LocateCache>): void;
|
|
38
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { type ChatCompletionMessageParam } from '../ai-model';
|
|
2
|
+
import type { AbstractPage } from '../device';
|
|
3
|
+
import { type DetailedLocateParam, type ExecutionTaskApply, type ExecutionTaskProgressOptions, Executor, type Insight, type InsightExtractOption, type InsightExtractParam, type MidsceneYamlFlowItem, type PlanningAction, type PlanningActionParamWaitFor, type PlanningLocateParam, type TMultimodalPrompt, type TUserPrompt } from '../index';
|
|
4
|
+
import type { TaskCache } from './task-cache';
|
|
5
|
+
interface ExecutionResult<OutputType = any> {
|
|
6
|
+
output: OutputType;
|
|
7
|
+
thought?: string;
|
|
8
|
+
executor: Executor;
|
|
9
|
+
}
|
|
10
|
+
export declare function locatePlanForLocate(param: string | DetailedLocateParam): PlanningAction<PlanningLocateParam>;
|
|
11
|
+
export declare class PageTaskExecutor {
|
|
12
|
+
page: AbstractPage;
|
|
13
|
+
insight: Insight;
|
|
14
|
+
taskCache?: TaskCache;
|
|
15
|
+
conversationHistory: ChatCompletionMessageParam[];
|
|
16
|
+
onTaskStartCallback?: ExecutionTaskProgressOptions['onTaskStart'];
|
|
17
|
+
constructor(page: AbstractPage, insight: Insight, opts: {
|
|
18
|
+
taskCache?: TaskCache;
|
|
19
|
+
onTaskStart?: ExecutionTaskProgressOptions['onTaskStart'];
|
|
20
|
+
});
|
|
21
|
+
private recordScreenshot;
|
|
22
|
+
private getElementXpath;
|
|
23
|
+
private prependExecutorWithScreenshot;
|
|
24
|
+
convertPlanToExecutable(plans: PlanningAction[]): Promise<{
|
|
25
|
+
tasks: ExecutionTaskApply<any, any, any, any>[];
|
|
26
|
+
}>;
|
|
27
|
+
private setupPlanningContext;
|
|
28
|
+
loadYamlFlowAsPlanning(userInstruction: string, yamlString: string): Promise<{
|
|
29
|
+
executor: Executor;
|
|
30
|
+
}>;
|
|
31
|
+
private planningTaskFromPrompt;
|
|
32
|
+
private planningTaskToGoal;
|
|
33
|
+
runPlans(title: string, plans: PlanningAction[]): Promise<ExecutionResult>;
|
|
34
|
+
action(userPrompt: string, actionContext?: string): Promise<ExecutionResult<{
|
|
35
|
+
yamlFlow?: MidsceneYamlFlowItem[];
|
|
36
|
+
} | undefined>>;
|
|
37
|
+
actionToGoal(userPrompt: string): Promise<ExecutionResult<{
|
|
38
|
+
yamlFlow?: MidsceneYamlFlowItem[];
|
|
39
|
+
} | undefined>>;
|
|
40
|
+
private createTypeQueryTask;
|
|
41
|
+
createTypeQueryExecution<T>(type: 'Query' | 'Boolean' | 'Number' | 'String' | 'Assert', demand: InsightExtractParam, opt?: InsightExtractOption, multimodalPrompt?: TMultimodalPrompt): Promise<ExecutionResult<T>>;
|
|
42
|
+
assert(assertion: TUserPrompt, opt?: InsightExtractOption): Promise<ExecutionResult<boolean>>;
|
|
43
|
+
/**
|
|
44
|
+
* Append a message to the conversation history
|
|
45
|
+
* For user messages with images:
|
|
46
|
+
* - Keep max 4 user image messages in history
|
|
47
|
+
* - Remove oldest user image message when limit reached
|
|
48
|
+
* For assistant messages:
|
|
49
|
+
* - Simply append to history
|
|
50
|
+
* @param conversationHistory Message to append
|
|
51
|
+
*/
|
|
52
|
+
private appendConversationHistory;
|
|
53
|
+
private appendErrorPlan;
|
|
54
|
+
waitFor(assertion: TUserPrompt, opt: PlanningActionParamWaitFor): Promise<ExecutionResult<void>>;
|
|
55
|
+
}
|
|
56
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AndroidPullParam, DetailedLocateParam, ExecutionTask, ScrollParam } from '../index';
|
|
2
|
+
export declare function typeStr(task: ExecutionTask): any;
|
|
3
|
+
export declare function getKeyCommands(value: string | string[]): Array<{
|
|
4
|
+
key: string;
|
|
5
|
+
command?: string;
|
|
6
|
+
}>;
|
|
7
|
+
export declare function locateParamStr(locate?: DetailedLocateParam): string;
|
|
8
|
+
export declare function scrollParamStr(scrollParam?: ScrollParam): string;
|
|
9
|
+
export declare function pullParamStr(pullParam?: AndroidPullParam): string;
|
|
10
|
+
export declare function taskTitleStr(type: 'Tap' | 'Hover' | 'Input' | 'RightClick' | 'KeyboardPress' | 'Scroll' | 'Action' | 'Query' | 'Assert' | 'WaitFor' | 'Locate' | 'Boolean' | 'Number' | 'String', prompt: string): string;
|
|
11
|
+
export declare function paramStr(task: ExecutionTask): string;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { AbstractPage } from '../device';
|
|
2
|
+
import type { BaseElement, DetailedLocateParam, DeviceAction, ElementTreeNode, ExecutionDump, ExecutorContext, LocateOption, PlanningLocateParam, TMultimodalPrompt, TUserPrompt, UIContext } from '../index';
|
|
3
|
+
import type { PageTaskExecutor } from './tasks';
|
|
4
|
+
export declare function commonContextParser(page: AbstractPage): Promise<UIContext>;
|
|
5
|
+
export declare function getReportFileName(tag?: string): string;
|
|
6
|
+
export declare function printReportMsg(filepath: string): void;
|
|
7
|
+
/**
|
|
8
|
+
* Get the current execution file name
|
|
9
|
+
* @returns The name of the current execution file
|
|
10
|
+
*/
|
|
11
|
+
export declare function getCurrentExecutionFile(trace?: string): string | false;
|
|
12
|
+
export declare function generateCacheId(fileName?: string): string;
|
|
13
|
+
export declare function matchElementFromPlan(planLocateParam: PlanningLocateParam, tree: ElementTreeNode<BaseElement>): any;
|
|
14
|
+
export declare function matchElementFromCache(taskExecutor: PageTaskExecutor, xpaths: string[] | undefined, cachePrompt: TUserPrompt, cacheable: boolean | undefined): Promise<any>;
|
|
15
|
+
export declare function trimContextByViewport(execution: ExecutionDump): {
|
|
16
|
+
tasks: {
|
|
17
|
+
type: any;
|
|
18
|
+
subType?: string;
|
|
19
|
+
param?: any;
|
|
20
|
+
thought?: string;
|
|
21
|
+
locate?: PlanningLocateParam | null;
|
|
22
|
+
pageContext?: UIContext;
|
|
23
|
+
executor: (param: any, context: ExecutorContext) => void | Promise<void | import("../index").ExecutionTaskReturn<any, any> | undefined> | undefined;
|
|
24
|
+
output?: any;
|
|
25
|
+
log?: any;
|
|
26
|
+
recorder?: import("../index").ExecutionRecorderItem[];
|
|
27
|
+
hitBy?: import("../index").ExecutionTaskHitBy;
|
|
28
|
+
status: "pending" | "running" | "finished" | "failed" | "cancelled";
|
|
29
|
+
error?: Error;
|
|
30
|
+
errorMessage?: string;
|
|
31
|
+
errorStack?: string;
|
|
32
|
+
timing?: {
|
|
33
|
+
start: number;
|
|
34
|
+
end?: number;
|
|
35
|
+
cost?: number;
|
|
36
|
+
};
|
|
37
|
+
usage?: import("../index").AIUsageInfo;
|
|
38
|
+
}[];
|
|
39
|
+
name: string;
|
|
40
|
+
description?: string;
|
|
41
|
+
sdkVersion: string;
|
|
42
|
+
logTime: number;
|
|
43
|
+
};
|
|
44
|
+
export declare function buildDetailedLocateParam(locatePrompt: TUserPrompt, opt?: LocateOption): DetailedLocateParam | undefined;
|
|
45
|
+
export declare function buildDetailedLocateParamAndRestParams(locatePrompt: TUserPrompt, opt: LocateOption | undefined, excludeKeys?: string[]): {
|
|
46
|
+
locateParam: DetailedLocateParam | undefined;
|
|
47
|
+
restParams: Record<string, any>;
|
|
48
|
+
};
|
|
49
|
+
export declare const getMidsceneVersion: () => string;
|
|
50
|
+
export declare const parsePrompt: (prompt: TUserPrompt) => {
|
|
51
|
+
textPrompt: string;
|
|
52
|
+
multimodalPrompt?: TMultimodalPrompt;
|
|
53
|
+
};
|
|
54
|
+
export declare const commonWebActionsForWebPage: <T extends AbstractPage>(page: T) => DeviceAction<any>[];
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { ElementInfo, ElementNode } from '@midscene/shared/extractor';
|
|
2
|
+
import type { DeviceAction, Point, Size, UIContext } from '../types';
|
|
3
|
+
export declare type KeyInput = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | 'Power' | 'Eject' | 'Abort' | 'Help' | 'Backspace' | 'Tab' | 'Numpad5' | 'NumpadEnter' | 'Enter' | '\r' | '\n' | 'ShiftLeft' | 'ShiftRight' | 'ControlLeft' | 'ControlRight' | 'AltLeft' | 'AltRight' | 'Pause' | 'CapsLock' | 'Escape' | 'Convert' | 'NonConvert' | 'Space' | 'Numpad9' | 'PageUp' | 'Numpad3' | 'PageDown' | 'End' | 'Numpad1' | 'Home' | 'Numpad7' | 'ArrowLeft' | 'Numpad4' | 'Numpad8' | 'ArrowUp' | 'ArrowRight' | 'Numpad6' | 'Numpad2' | 'ArrowDown' | 'Select' | 'Open' | 'PrintScreen' | 'Insert' | 'Numpad0' | 'Delete' | 'NumpadDecimal' | 'Digit0' | 'Digit1' | 'Digit2' | 'Digit3' | 'Digit4' | 'Digit5' | 'Digit6' | 'Digit7' | 'Digit8' | 'Digit9' | 'KeyA' | 'KeyB' | 'KeyC' | 'KeyD' | 'KeyE' | 'KeyF' | 'KeyG' | 'KeyH' | 'KeyI' | 'KeyJ' | 'KeyK' | 'KeyL' | 'KeyM' | 'KeyN' | 'KeyO' | 'KeyP' | 'KeyQ' | 'KeyR' | 'KeyS' | 'KeyT' | 'KeyU' | 'KeyV' | 'KeyW' | 'KeyX' | 'KeyY' | 'KeyZ' | 'MetaLeft' | 'MetaRight' | 'ContextMenu' | 'NumpadMultiply' | 'NumpadAdd' | 'NumpadSubtract' | 'NumpadDivide' | 'F1' | 'F2' | 'F3' | 'F4' | 'F5' | 'F6' | 'F7' | 'F8' | 'F9' | 'F10' | 'F11' | 'F12' | 'F13' | 'F14' | 'F15' | 'F16' | 'F17' | 'F18' | 'F19' | 'F20' | 'F21' | 'F22' | 'F23' | 'F24' | 'NumLock' | 'ScrollLock' | 'AudioVolumeMute' | 'AudioVolumeDown' | 'AudioVolumeUp' | 'MediaTrackNext' | 'MediaTrackPrevious' | 'MediaStop' | 'MediaPlayPause' | 'Semicolon' | 'Equal' | 'NumpadEqual' | 'Comma' | 'Minus' | 'Period' | 'Slash' | 'Backquote' | 'BracketLeft' | 'Backslash' | 'BracketRight' | 'Quote' | 'AltGraph' | 'Props' | 'Cancel' | 'Clear' | 'Shift' | 'Control' | 'Alt' | 'Accept' | 'ModeChange' | ' ' | 'Print' | 'Execute' | '\u0000' | 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z' | 'Meta' | '*' | '+' | '-' | '/' | ';' | '=' | ',' | '.' | '`' | '[' | '\\' | ']' | "'" | 'Attn' | 'CrSel' | 'ExSel' | 'EraseEof' | 'Play' | 'ZoomOut' | ')' | '!' | '@' | '#' | '$' | '%' | '^' | '&' | '(' | 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z' | ':' | '<' | '_' | '>' | '?' | '~' | '{' | '|' | '}' | '"' | 'SoftLeft' | 'SoftRight' | 'Camera' | 'Call' | 'EndCall' | 'VolumeDown' | 'VolumeUp';
|
|
4
|
+
export type MouseButton = 'left' | 'right' | 'middle';
|
|
5
|
+
export interface MouseAction {
|
|
6
|
+
click: (x: number, y: number, options: {
|
|
7
|
+
button: MouseButton;
|
|
8
|
+
}) => Promise<void>;
|
|
9
|
+
wheel: (deltaX: number, deltaY: number) => Promise<void>;
|
|
10
|
+
move: (x: number, y: number) => Promise<void>;
|
|
11
|
+
drag: (from: {
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
}, to: {
|
|
15
|
+
x: number;
|
|
16
|
+
y: number;
|
|
17
|
+
}) => Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export interface KeyboardAction {
|
|
20
|
+
type: (text: string) => Promise<void>;
|
|
21
|
+
press: (action: {
|
|
22
|
+
key: KeyInput;
|
|
23
|
+
command?: string;
|
|
24
|
+
} | {
|
|
25
|
+
key: KeyInput;
|
|
26
|
+
command?: string;
|
|
27
|
+
}[]) => Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
export interface ChromePageDestroyOptions {
|
|
30
|
+
closeTab?: boolean;
|
|
31
|
+
}
|
|
32
|
+
export declare abstract class AbstractPage {
|
|
33
|
+
abstract pageType: string;
|
|
34
|
+
abstract getElementsInfo(): Promise<ElementInfo[]>;
|
|
35
|
+
abstract getElementsNodeTree(): Promise<ElementNode>;
|
|
36
|
+
abstract url(): string | Promise<string>;
|
|
37
|
+
abstract screenshotBase64(): Promise<string>;
|
|
38
|
+
abstract size(): Promise<Size>;
|
|
39
|
+
abstract actionSpace(): DeviceAction[] | Promise<DeviceAction[]>;
|
|
40
|
+
get mouse(): MouseAction;
|
|
41
|
+
get keyboard(): KeyboardAction;
|
|
42
|
+
clearInput(element: ElementInfo): Promise<void>;
|
|
43
|
+
abstract scrollUntilTop(startingPoint?: Point): Promise<void>;
|
|
44
|
+
abstract scrollUntilBottom(startingPoint?: Point): Promise<void>;
|
|
45
|
+
abstract scrollUntilLeft(startingPoint?: Point): Promise<void>;
|
|
46
|
+
abstract scrollUntilRight(startingPoint?: Point): Promise<void>;
|
|
47
|
+
abstract scrollUp(distance?: number, startingPoint?: Point): Promise<void>;
|
|
48
|
+
abstract scrollDown(distance?: number, startingPoint?: Point): Promise<void>;
|
|
49
|
+
abstract scrollLeft(distance?: number, startingPoint?: Point): Promise<void>;
|
|
50
|
+
abstract scrollRight(distance?: number, startingPoint?: Point): Promise<void>;
|
|
51
|
+
abstract beforeAction?(): Promise<void>;
|
|
52
|
+
abstract destroy(options?: ChromePageDestroyOptions): Promise<void>;
|
|
53
|
+
abstract evaluateJavaScript?<T = any>(script: string): Promise<T>;
|
|
54
|
+
abstract getContext?(): Promise<UIContext>;
|
|
55
|
+
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -9,3 +9,4 @@ export { z };
|
|
|
9
9
|
export default Insight;
|
|
10
10
|
export { Executor, Insight, getVersion };
|
|
11
11
|
export type { MidsceneYamlScript, MidsceneYamlTask, MidsceneYamlFlowItem, MidsceneYamlFlowItemAIRightClick, MidsceneYamlConfigResult, LocateOption, DetailedLocateParam, } from './yaml';
|
|
12
|
+
export { Agent, type PageAgentOpt } from './agent';
|
package/dist/types/types.d.ts
CHANGED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Agent } from '../agent/agent';
|
|
2
|
+
import type { FreeFn, MidsceneYamlScript, MidsceneYamlScriptEnv, ScriptPlayerStatusValue, ScriptPlayerTaskStatus } from '../index';
|
|
3
|
+
export declare class ScriptPlayer<T extends MidsceneYamlScriptEnv> {
|
|
4
|
+
private script;
|
|
5
|
+
private setupAgent;
|
|
6
|
+
onTaskStatusChange?: ((taskStatus: ScriptPlayerTaskStatus) => void) | undefined;
|
|
7
|
+
currentTaskIndex?: number;
|
|
8
|
+
taskStatusList: ScriptPlayerTaskStatus[];
|
|
9
|
+
status: ScriptPlayerStatusValue;
|
|
10
|
+
reportFile?: string | null;
|
|
11
|
+
result: Record<string, any>;
|
|
12
|
+
private unnamedResultIndex;
|
|
13
|
+
output?: string | null;
|
|
14
|
+
unstableLogContent?: string | null;
|
|
15
|
+
errorInSetup?: Error;
|
|
16
|
+
private pageAgent;
|
|
17
|
+
agentStatusTip?: string;
|
|
18
|
+
target?: MidsceneYamlScriptEnv;
|
|
19
|
+
private actionSpace;
|
|
20
|
+
private scriptPath?;
|
|
21
|
+
constructor(script: MidsceneYamlScript, setupAgent: (platform: T) => Promise<{
|
|
22
|
+
agent: Agent;
|
|
23
|
+
freeFn: FreeFn[];
|
|
24
|
+
}>, onTaskStatusChange?: ((taskStatus: ScriptPlayerTaskStatus) => void) | undefined, scriptPath?: string);
|
|
25
|
+
private setResult;
|
|
26
|
+
private setPlayerStatus;
|
|
27
|
+
private notifyCurrentTaskStatusChange;
|
|
28
|
+
private setTaskStatus;
|
|
29
|
+
private setTaskIndex;
|
|
30
|
+
private flushResult;
|
|
31
|
+
private flushUnstableLogContent;
|
|
32
|
+
playTask(taskStatus: ScriptPlayerTaskStatus, agent: Agent): Promise<void>;
|
|
33
|
+
run(): Promise<void>;
|
|
34
|
+
}
|
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.27.1-beta-
|
|
4
|
+
"version": "0.27.1-beta-20250822094725.0",
|
|
5
5
|
"repository": "https://github.com/web-infra-dev/midscene",
|
|
6
6
|
"homepage": "https://midscenejs.com/",
|
|
7
7
|
"main": "./dist/lib/index.js",
|
|
@@ -31,6 +31,21 @@
|
|
|
31
31
|
"types": "./dist/types/tree.d.ts",
|
|
32
32
|
"import": "./dist/es/tree.mjs",
|
|
33
33
|
"require": "./dist/lib/tree.js"
|
|
34
|
+
},
|
|
35
|
+
"./device": {
|
|
36
|
+
"types": "./dist/types/device/index.d.ts",
|
|
37
|
+
"import": "./dist/es/device/index.mjs",
|
|
38
|
+
"require": "./dist/lib/device/index.js"
|
|
39
|
+
},
|
|
40
|
+
"./agent": {
|
|
41
|
+
"types": "./dist/types/agent/index.d.ts",
|
|
42
|
+
"import": "./dist/es/agent/index.mjs",
|
|
43
|
+
"require": "./dist/lib/agent/index.js"
|
|
44
|
+
},
|
|
45
|
+
"./yaml": {
|
|
46
|
+
"types": "./dist/types/yaml/index.d.ts",
|
|
47
|
+
"import": "./dist/es/yaml/index.mjs",
|
|
48
|
+
"require": "./dist/lib/yaml/index.js"
|
|
34
49
|
}
|
|
35
50
|
},
|
|
36
51
|
"typesVersions": {
|
|
@@ -46,6 +61,15 @@
|
|
|
46
61
|
],
|
|
47
62
|
"tree": [
|
|
48
63
|
"./dist/types/tree.d.ts"
|
|
64
|
+
],
|
|
65
|
+
"device": [
|
|
66
|
+
"./dist/types/device.d.ts"
|
|
67
|
+
],
|
|
68
|
+
"agent": [
|
|
69
|
+
"./dist/types/agent.d.ts"
|
|
70
|
+
],
|
|
71
|
+
"yaml": [
|
|
72
|
+
"./dist/types/yaml.d.ts"
|
|
49
73
|
]
|
|
50
74
|
}
|
|
51
75
|
},
|
|
@@ -63,8 +87,8 @@
|
|
|
63
87
|
"zod": "3.24.3",
|
|
64
88
|
"semver": "7.5.2",
|
|
65
89
|
"js-yaml": "4.1.0",
|
|
66
|
-
"@midscene/recorder": "0.27.1-beta-
|
|
67
|
-
"@midscene/shared": "0.27.1-beta-
|
|
90
|
+
"@midscene/recorder": "0.27.1-beta-20250822094725.0",
|
|
91
|
+
"@midscene/shared": "0.27.1-beta-20250822094725.0"
|
|
68
92
|
},
|
|
69
93
|
"devDependencies": {
|
|
70
94
|
"@microsoft/api-extractor": "^7.52.10",
|