@xiuchang-midscene/shared 2.0.2 → 2.0.3

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 (166) hide show
  1. package/dist/es/oss/index.mjs +1 -1
  2. package/dist/lib/oss/index.js +1 -1
  3. package/package.json +1 -1
  4. package/src/oss/index.ts +1 -1
  5. package/dist/es/baseDB.mjs.bak +0 -109
  6. package/dist/es/build/copy-static.mjs.bak +0 -31
  7. package/dist/es/build/rspack-config.mjs.bak +0 -4
  8. package/dist/es/cli/cli-runner.mjs.bak +0 -140
  9. package/dist/es/cli/index.mjs.bak +0 -2
  10. package/dist/es/common.mjs.bak +0 -37
  11. package/dist/es/constants/example-code.mjs.bak +0 -223
  12. package/dist/es/constants/index.mjs.bak +0 -23
  13. package/dist/es/env/basic.mjs.bak +0 -6
  14. package/dist/es/env/constants.mjs.bak +0 -70
  15. package/dist/es/env/global-config-manager.mjs.bak +0 -94
  16. package/dist/es/env/helper.mjs.bak +0 -43
  17. package/dist/es/env/index.mjs.bak +0 -5
  18. package/dist/es/env/init-debug.mjs.bak +0 -18
  19. package/dist/es/env/model-config-manager.mjs.bak +0 -79
  20. package/dist/es/env/parse-model-config.mjs.bak +0 -132
  21. package/dist/es/env/types.mjs.bak +0 -220
  22. package/dist/es/env/utils.mjs.bak +0 -26
  23. package/dist/es/extractor/constants.mjs.bak +0 -2
  24. package/dist/es/extractor/debug.mjs.bak +0 -6
  25. package/dist/es/extractor/dom-util.mjs.bak +0 -92
  26. package/dist/es/extractor/index.mjs.bak +0 -5
  27. package/dist/es/extractor/locator.mjs.bak +0 -250
  28. package/dist/es/extractor/tree.mjs.bak +0 -78
  29. package/dist/es/extractor/util.mjs.bak +0 -245
  30. package/dist/es/extractor/web-extractor.mjs.bak +0 -303
  31. package/dist/es/img/box-select.mjs.bak +0 -824
  32. package/dist/es/img/canvas-fallback.mjs.bak +0 -238
  33. package/dist/es/img/get-photon.mjs.bak +0 -45
  34. package/dist/es/img/get-sharp.mjs.bak +0 -11
  35. package/dist/es/img/index.mjs.bak +0 -4
  36. package/dist/es/img/info.mjs.bak +0 -29
  37. package/dist/es/img/transform.mjs.bak +0 -295
  38. package/dist/es/index.mjs.bak +0 -4
  39. package/dist/es/logger.mjs.bak +0 -64
  40. package/dist/es/mcp/base-server.mjs.bak +0 -281
  41. package/dist/es/mcp/base-tools.mjs.bak +0 -91
  42. package/dist/es/mcp/chrome-path.mjs.bak +0 -35
  43. package/dist/es/mcp/index.mjs.bak +0 -7
  44. package/dist/es/mcp/inject-report-html-plugin.mjs.bak +0 -53
  45. package/dist/es/mcp/launcher-helper.mjs.bak +0 -52
  46. package/dist/es/mcp/tool-generator.mjs.bak +0 -297
  47. package/dist/es/mcp/types.mjs.bak +0 -3
  48. package/dist/es/node/fs.mjs.bak +0 -44
  49. package/dist/es/node/index.mjs.bak +0 -2
  50. package/dist/es/node/port.mjs.bak +0 -24
  51. package/dist/es/oss/demo.mjs.bak +0 -30
  52. package/dist/es/oss/index.mjs.bak +0 -90
  53. package/dist/es/polyfills/async-hooks.mjs.bak +0 -2
  54. package/dist/es/polyfills/index.mjs.bak +0 -1
  55. package/dist/es/types/index.mjs.bak +0 -3
  56. package/dist/es/us-keyboard-layout.mjs.bak +0 -1414
  57. package/dist/es/utils.mjs.bak +0 -72
  58. package/dist/es/zod-schema-utils.mjs.bak +0 -54
  59. package/dist/lib/baseDB.js.bak +0 -149
  60. package/dist/lib/build/copy-static.js.bak +0 -79
  61. package/dist/lib/build/rspack-config.js.bak +0 -38
  62. package/dist/lib/cli/cli-runner.js.bak +0 -196
  63. package/dist/lib/cli/index.js.bak +0 -48
  64. package/dist/lib/common.js.bak +0 -93
  65. package/dist/lib/constants/example-code.js.bak +0 -260
  66. package/dist/lib/constants/index.js.bak +0 -96
  67. package/dist/lib/env/basic.js.bak +0 -40
  68. package/dist/lib/env/constants.js.bak +0 -113
  69. package/dist/lib/env/global-config-manager.js.bak +0 -128
  70. package/dist/lib/env/helper.js.bak +0 -80
  71. package/dist/lib/env/index.js.bak +0 -90
  72. package/dist/lib/env/init-debug.js.bak +0 -52
  73. package/dist/lib/env/model-config-manager.js.bak +0 -113
  74. package/dist/lib/env/parse-model-config.js.bak +0 -178
  75. package/dist/lib/env/types.js.bak +0 -554
  76. package/dist/lib/env/utils.js.bak +0 -72
  77. package/dist/lib/extractor/constants.js.bak +0 -42
  78. package/dist/lib/extractor/debug.js.bak +0 -12
  79. package/dist/lib/extractor/dom-util.js.bak +0 -153
  80. package/dist/lib/extractor/index.js.bak +0 -81
  81. package/dist/lib/extractor/locator.js.bak +0 -296
  82. package/dist/lib/extractor/tree.js.bak +0 -124
  83. package/dist/lib/extractor/util.js.bak +0 -336
  84. package/dist/lib/extractor/web-extractor.js.bak +0 -349
  85. package/dist/lib/img/box-select.js.bak +0 -875
  86. package/dist/lib/img/canvas-fallback.js.bak +0 -305
  87. package/dist/lib/img/get-photon.js.bak +0 -82
  88. package/dist/lib/img/get-sharp.js.bak +0 -45
  89. package/dist/lib/img/index.js.bak +0 -95
  90. package/dist/lib/img/info.js.bak +0 -83
  91. package/dist/lib/img/transform.js.bak +0 -387
  92. package/dist/lib/index.js.bak +0 -47
  93. package/dist/lib/logger.js.bak +0 -114
  94. package/dist/lib/mcp/base-server.js.bak +0 -331
  95. package/dist/lib/mcp/base-tools.js.bak +0 -125
  96. package/dist/lib/mcp/chrome-path.js.bak +0 -72
  97. package/dist/lib/mcp/index.js.bak +0 -100
  98. package/dist/lib/mcp/inject-report-html-plugin.js.bak +0 -98
  99. package/dist/lib/mcp/launcher-helper.js.bak +0 -86
  100. package/dist/lib/mcp/tool-generator.js.bak +0 -334
  101. package/dist/lib/mcp/types.js.bak +0 -40
  102. package/dist/lib/node/fs.js.bak +0 -97
  103. package/dist/lib/node/index.js.bak +0 -65
  104. package/dist/lib/node/port.js.bak +0 -61
  105. package/dist/lib/oss/demo.js.bak +0 -36
  106. package/dist/lib/oss/index.js.bak +0 -138
  107. package/dist/lib/polyfills/async-hooks.js.bak +0 -36
  108. package/dist/lib/polyfills/index.js.bak +0 -58
  109. package/dist/lib/types/index.js.bak +0 -37
  110. package/dist/lib/us-keyboard-layout.js.bak +0 -1457
  111. package/dist/lib/utils.js.bak +0 -148
  112. package/dist/lib/zod-schema-utils.js.bak +0 -97
  113. package/dist/types/baseDB.d.ts.bak +0 -25
  114. package/dist/types/build/copy-static.d.ts.bak +0 -31
  115. package/dist/types/build/rspack-config.d.ts.bak +0 -8
  116. package/dist/types/cli/cli-runner.d.ts.bak +0 -14
  117. package/dist/types/cli/index.d.ts.bak +0 -2
  118. package/dist/types/common.d.ts.bak +0 -12
  119. package/dist/types/constants/example-code.d.ts.bak +0 -2
  120. package/dist/types/constants/index.d.ts.bak +0 -21
  121. package/dist/types/env/basic.d.ts.bak +0 -6
  122. package/dist/types/env/constants.d.ts.bak +0 -40
  123. package/dist/types/env/global-config-manager.d.ts.bak +0 -32
  124. package/dist/types/env/helper.d.ts.bak +0 -4
  125. package/dist/types/env/index.d.ts.bak +0 -4
  126. package/dist/types/env/init-debug.d.ts.bak +0 -1
  127. package/dist/types/env/model-config-manager.d.ts.bak +0 -25
  128. package/dist/types/env/parse-model-config.d.ts.bak +0 -31
  129. package/dist/types/env/types.d.ts.bak +0 -318
  130. package/dist/types/env/utils.d.ts.bak +0 -38
  131. package/dist/types/extractor/constants.d.ts.bak +0 -1
  132. package/dist/types/extractor/debug.d.ts.bak +0 -1
  133. package/dist/types/extractor/dom-util.d.ts.bak +0 -56
  134. package/dist/types/extractor/index.d.ts.bak +0 -32
  135. package/dist/types/extractor/locator.d.ts.bak +0 -9
  136. package/dist/types/extractor/tree.d.ts.bak +0 -6
  137. package/dist/types/extractor/util.d.ts.bak +0 -47
  138. package/dist/types/extractor/web-extractor.d.ts.bak +0 -19
  139. package/dist/types/img/box-select.d.ts.bak +0 -26
  140. package/dist/types/img/canvas-fallback.d.ts.bak +0 -105
  141. package/dist/types/img/get-photon.d.ts.bak +0 -19
  142. package/dist/types/img/get-sharp.d.ts.bak +0 -3
  143. package/dist/types/img/index.d.ts.bak +0 -3
  144. package/dist/types/img/info.d.ts.bak +0 -29
  145. package/dist/types/img/transform.d.ts.bak +0 -107
  146. package/dist/types/index.d.ts.bak +0 -4
  147. package/dist/types/logger.d.ts.bak +0 -5
  148. package/dist/types/mcp/base-server.d.ts.bak +0 -93
  149. package/dist/types/mcp/base-tools.d.ts.bak +0 -79
  150. package/dist/types/mcp/chrome-path.d.ts.bak +0 -2
  151. package/dist/types/mcp/index.d.ts.bak +0 -7
  152. package/dist/types/mcp/inject-report-html-plugin.d.ts.bak +0 -18
  153. package/dist/types/mcp/launcher-helper.d.ts.bak +0 -94
  154. package/dist/types/mcp/tool-generator.d.ts.bak +0 -10
  155. package/dist/types/mcp/types.d.ts.bak +0 -103
  156. package/dist/types/node/fs.d.ts.bak +0 -15
  157. package/dist/types/node/index.d.ts.bak +0 -2
  158. package/dist/types/node/port.d.ts.bak +0 -8
  159. package/dist/types/oss/demo.d.ts.bak +0 -1
  160. package/dist/types/oss/index.d.ts.bak +0 -34
  161. package/dist/types/polyfills/async-hooks.d.ts.bak +0 -6
  162. package/dist/types/polyfills/index.d.ts.bak +0 -4
  163. package/dist/types/types/index.d.ts.bak +0 -34
  164. package/dist/types/us-keyboard-layout.d.ts.bak +0 -32
  165. package/dist/types/utils.d.ts.bak +0 -34
  166. package/dist/types/zod-schema-utils.d.ts.bak +0 -23
@@ -1,148 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.d = (exports1, definition)=>{
5
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
- enumerable: true,
7
- get: definition[key]
8
- });
9
- };
10
- })();
11
- (()=>{
12
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
- })();
14
- (()=>{
15
- __webpack_require__.r = (exports1)=>{
16
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
- value: 'Module'
18
- });
19
- Object.defineProperty(exports1, '__esModule', {
20
- value: true
21
- });
22
- };
23
- })();
24
- var __webpack_exports__ = {};
25
- __webpack_require__.r(__webpack_exports__);
26
- __webpack_require__.d(__webpack_exports__, {
27
- uuid: ()=>uuid,
28
- isPlainObject: ()=>isPlainObject,
29
- ifInBrowser: ()=>ifInBrowser,
30
- repeat: ()=>repeat,
31
- mergeAndNormalizeAppNameMapping: ()=>mergeAndNormalizeAppNameMapping,
32
- ifInNode: ()=>ifInNode,
33
- assert: ()=>assert,
34
- escapeScriptTag: ()=>escapeScriptTag,
35
- logMsg: ()=>logMsg,
36
- replaceIllegalPathCharsAndSpace: ()=>replaceIllegalPathCharsAndSpace,
37
- generateHashId: ()=>generateHashId,
38
- normalizeForComparison: ()=>normalizeForComparison,
39
- ifInWorker: ()=>ifInWorker,
40
- setIsMcp: ()=>setIsMcp,
41
- antiEscapeScriptTag: ()=>antiEscapeScriptTag
42
- });
43
- const external_js_sha256_namespaceObject = require("js-sha256");
44
- const external_uuid_namespaceObject = require("uuid");
45
- const ifInBrowser = 'undefined' != typeof window;
46
- const ifInWorker = 'undefined' != typeof WorkerGlobalScope;
47
- const ifInNode = 'undefined' != typeof process && process.versions?.node;
48
- function uuid() {
49
- return (0, external_uuid_namespaceObject.v4)();
50
- }
51
- const hashMap = {};
52
- function generateHashId(rect, content = '') {
53
- const combined = JSON.stringify({
54
- content,
55
- rect
56
- });
57
- let sliceLength = 5;
58
- let slicedHash = '';
59
- const hashHex = external_js_sha256_namespaceObject.sha256.create().update(combined).hex();
60
- const toLetters = (hex)=>hex.split('').map((char)=>{
61
- const code = Number.parseInt(char, 16);
62
- return String.fromCharCode(97 + code % 26);
63
- }).join('');
64
- const hashLetters = toLetters(hashHex);
65
- while(sliceLength < hashLetters.length - 1){
66
- slicedHash = hashLetters.slice(0, sliceLength);
67
- if (hashMap[slicedHash] && hashMap[slicedHash] !== combined) {
68
- sliceLength++;
69
- continue;
70
- }
71
- hashMap[slicedHash] = combined;
72
- break;
73
- }
74
- return slicedHash;
75
- }
76
- function assert(condition, message) {
77
- if (!condition) throw new Error(message || 'Assertion failed');
78
- }
79
- let isMcp = false;
80
- function setIsMcp(value) {
81
- isMcp = value;
82
- }
83
- function logMsg(...message) {
84
- if (!isMcp) console.log(...message);
85
- }
86
- async function repeat(times, fn) {
87
- for(let i = 0; i < times; i++)await fn(i);
88
- }
89
- const utils_REGEXP_LT = /</g;
90
- const utils_REGEXP_GT = />/g;
91
- const REGEXP_LT_ESCAPE = '__midscene_lt__';
92
- const REGEXP_GT_ESCAPE = '__midscene_gt__';
93
- const escapeScriptTag = (html)=>html.replace(utils_REGEXP_LT, REGEXP_LT_ESCAPE).replace(utils_REGEXP_GT, REGEXP_GT_ESCAPE);
94
- const antiEscapeScriptTag = (html)=>{
95
- const REGEXP_LT = new RegExp(REGEXP_LT_ESCAPE, 'g');
96
- const REGEXP_GT = new RegExp(REGEXP_GT_ESCAPE, 'g');
97
- return html.replace(REGEXP_LT, '<').replace(REGEXP_GT, '>');
98
- };
99
- function replaceIllegalPathCharsAndSpace(str) {
100
- return str.replace(/[:*?"<>|# ]/g, '-');
101
- }
102
- function isPlainObject(value) {
103
- return 'object' == typeof value && null !== value && !Array.isArray(value);
104
- }
105
- function normalizeForComparison(str) {
106
- return str.toLowerCase().replace(/[\s\-_]+/g, '');
107
- }
108
- function mergeAndNormalizeAppNameMapping(defaultMapping, userMapping) {
109
- const result = {};
110
- for (const [key, value] of Object.entries(defaultMapping))result[normalizeForComparison(key)] = value;
111
- if (userMapping) for (const [key, value] of Object.entries(userMapping))result[normalizeForComparison(key)] = value;
112
- return result;
113
- }
114
- exports.antiEscapeScriptTag = __webpack_exports__.antiEscapeScriptTag;
115
- exports.assert = __webpack_exports__.assert;
116
- exports.escapeScriptTag = __webpack_exports__.escapeScriptTag;
117
- exports.generateHashId = __webpack_exports__.generateHashId;
118
- exports.ifInBrowser = __webpack_exports__.ifInBrowser;
119
- exports.ifInNode = __webpack_exports__.ifInNode;
120
- exports.ifInWorker = __webpack_exports__.ifInWorker;
121
- exports.isPlainObject = __webpack_exports__.isPlainObject;
122
- exports.logMsg = __webpack_exports__.logMsg;
123
- exports.mergeAndNormalizeAppNameMapping = __webpack_exports__.mergeAndNormalizeAppNameMapping;
124
- exports.normalizeForComparison = __webpack_exports__.normalizeForComparison;
125
- exports.repeat = __webpack_exports__.repeat;
126
- exports.replaceIllegalPathCharsAndSpace = __webpack_exports__.replaceIllegalPathCharsAndSpace;
127
- exports.setIsMcp = __webpack_exports__.setIsMcp;
128
- exports.uuid = __webpack_exports__.uuid;
129
- for(var __rspack_i in __webpack_exports__)if (-1 === [
130
- "antiEscapeScriptTag",
131
- "assert",
132
- "escapeScriptTag",
133
- "generateHashId",
134
- "ifInBrowser",
135
- "ifInNode",
136
- "ifInWorker",
137
- "isPlainObject",
138
- "logMsg",
139
- "mergeAndNormalizeAppNameMapping",
140
- "normalizeForComparison",
141
- "repeat",
142
- "replaceIllegalPathCharsAndSpace",
143
- "setIsMcp",
144
- "uuid"
145
- ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
146
- Object.defineProperty(exports, '__esModule', {
147
- value: true
148
- });
@@ -1,97 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.d = (exports1, definition)=>{
5
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
- enumerable: true,
7
- get: definition[key]
8
- });
9
- };
10
- })();
11
- (()=>{
12
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
- })();
14
- (()=>{
15
- __webpack_require__.r = (exports1)=>{
16
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
- value: 'Module'
18
- });
19
- Object.defineProperty(exports1, '__esModule', {
20
- value: true
21
- });
22
- };
23
- })();
24
- var __webpack_exports__ = {};
25
- __webpack_require__.r(__webpack_exports__);
26
- __webpack_require__.d(__webpack_exports__, {
27
- getZodDescription: ()=>getZodDescription,
28
- getZodTypeName: ()=>getZodTypeName,
29
- isMidsceneLocatorField: ()=>isMidsceneLocatorField,
30
- unwrapZodField: ()=>unwrapZodField
31
- });
32
- function unwrapZodField(field) {
33
- const f = field;
34
- if (!f._def) return f;
35
- const typeName = f._def.typeName;
36
- if ('ZodOptional' === typeName || 'ZodNullable' === typeName || 'ZodDefault' === typeName) return unwrapZodField(f._def.innerType);
37
- if ('ZodEffects' === typeName) {
38
- if (f._def.schema) return unwrapZodField(f._def.schema);
39
- }
40
- return f;
41
- }
42
- function isMidsceneLocatorField(field) {
43
- const actualField = unwrapZodField(field);
44
- if (actualField._def?.typeName === 'ZodObject') {
45
- const shape = actualField._def.shape?.();
46
- if (shape) {
47
- if ('midscene_location_field_flag' in shape) return true;
48
- if ('prompt' in shape && shape.prompt) return true;
49
- }
50
- }
51
- return false;
52
- }
53
- function getZodTypeName(field, locatorTypeDescription) {
54
- const actualField = unwrapZodField(field);
55
- const fieldTypeName = actualField._def?.typeName;
56
- if ('ZodString' === fieldTypeName) return 'string';
57
- if ('ZodNumber' === fieldTypeName) return 'number';
58
- if ('ZodBoolean' === fieldTypeName) return 'boolean';
59
- if ('ZodArray' === fieldTypeName) return 'array';
60
- if ('ZodObject' === fieldTypeName) {
61
- if (isMidsceneLocatorField(actualField)) return locatorTypeDescription || 'object';
62
- return 'object';
63
- }
64
- if ('ZodEnum' === fieldTypeName) {
65
- const values = actualField._def?.values?.map((option)=>String(`'${option}'`)).join(', ') ?? 'enum';
66
- return `enum(${values})`;
67
- }
68
- if ('ZodUnion' === fieldTypeName) {
69
- const options = actualField._def?.options;
70
- if (options && options.length > 0) {
71
- const types = options.map((opt)=>getZodTypeName(opt, locatorTypeDescription));
72
- return types.join(' | ');
73
- }
74
- return 'union';
75
- }
76
- return 'unknown';
77
- }
78
- function getZodDescription(field) {
79
- if ("description" in field) return field.description || null;
80
- const actualField = unwrapZodField(field);
81
- if ("description" in actualField) return actualField.description || null;
82
- if (isMidsceneLocatorField(actualField)) return 'Location information for the target element';
83
- return null;
84
- }
85
- exports.getZodDescription = __webpack_exports__.getZodDescription;
86
- exports.getZodTypeName = __webpack_exports__.getZodTypeName;
87
- exports.isMidsceneLocatorField = __webpack_exports__.isMidsceneLocatorField;
88
- exports.unwrapZodField = __webpack_exports__.unwrapZodField;
89
- for(var __rspack_i in __webpack_exports__)if (-1 === [
90
- "getZodDescription",
91
- "getZodTypeName",
92
- "isMidsceneLocatorField",
93
- "unwrapZodField"
94
- ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
95
- Object.defineProperty(exports, '__esModule', {
96
- value: true
97
- });
@@ -1,25 +0,0 @@
1
- export declare class IndexedDBManager {
2
- private dbPromise;
3
- private dbName;
4
- private version;
5
- private storeConfigs;
6
- constructor(dbName: string, version: number, storeConfigs: Array<{
7
- name: string;
8
- keyPath: string;
9
- }>);
10
- private initDB;
11
- private withTransaction;
12
- private promisifyRequest;
13
- put<T>(storeName: string, data: T): Promise<void>;
14
- get<T>(storeName: string, key: string): Promise<T | undefined>;
15
- getAll<T>(storeName: string, sortByTimestamp?: boolean): Promise<T[]>;
16
- clear(storeName: string): Promise<void>;
17
- delete(storeName: string, key: string): Promise<void>;
18
- count(storeName: string): Promise<number>;
19
- getDBPromise(): Promise<IDBDatabase>;
20
- }
21
- export declare const withErrorHandling: <T>(operation: () => Promise<T>, errorMessage: string, defaultValue?: T, onQuotaExceeded?: () => Promise<void>) => Promise<T | undefined>;
22
- export declare const createCleanupFunction: <T extends {
23
- id: string;
24
- timestamp: number;
25
- }>(dbManager: IndexedDBManager, storeName: string, maxItems: number) => () => Promise<void>;
@@ -1,31 +0,0 @@
1
- export interface CopyStaticOptions {
2
- /** Source directory to copy from */
3
- srcDir: string;
4
- /** Destination directory to copy to */
5
- destDir: string;
6
- /** Optional favicon source path (relative to directory containing srcDir) */
7
- faviconPath?: string;
8
- /** Name for the rsbuild plugin */
9
- pluginName?: string;
10
- }
11
- /**
12
- * Creates an rsbuild plugin that copies static files after build
13
- * @param options Configuration options for copying static files
14
- * @returns Rsbuild plugin object
15
- */
16
- export declare const createCopyStaticPlugin: (options: CopyStaticOptions) => {
17
- name: string;
18
- setup(api: any): void;
19
- };
20
- /**
21
- * Helper function to create a copy static plugin for playground builds
22
- * @param srcDir Source directory (usually dist directory)
23
- * @param destDir Destination directory
24
- * @param pluginName Optional plugin name
25
- * @param faviconSrc Optional favicon source path
26
- * @returns Rsbuild plugin
27
- */
28
- export declare const createPlaygroundCopyPlugin: (srcDir: string, destDir: string, pluginName?: string, faviconSrc?: string) => {
29
- name: string;
30
- setup(api: any): void;
31
- };
@@ -1,8 +0,0 @@
1
- /**
2
- * Common Rspack configuration helpers for rsbuild projects
3
- */
4
- /**
5
- * Common warning patterns to ignore in Rspack builds.
6
- * These warnings are typically from optional dependencies or known non-critical issues.
7
- */
8
- export declare const commonIgnoreWarnings: RegExp[];
@@ -1,14 +0,0 @@
1
- import type { BaseMidsceneTools } from '../mcp/base-tools';
2
- export interface CLIRunnerOptions {
3
- stripPrefix?: string;
4
- argv?: string[];
5
- version?: string;
6
- }
7
- export declare class CLIError extends Error {
8
- exitCode: number;
9
- constructor(message: string, exitCode?: number);
10
- }
11
- export declare function parseValue(raw: string): unknown;
12
- export declare function parseCliArgs(args: string[]): Record<string, unknown>;
13
- export declare function removePrefix(name: string, prefix?: string): string;
14
- export declare function runToolsCLI(tools: BaseMidsceneTools, scriptName: string, options?: CLIRunnerOptions): Promise<void>;
@@ -1,2 +0,0 @@
1
- export { runToolsCLI, CLIError, parseValue, parseCliArgs, removePrefix, } from './cli-runner';
2
- export type { CLIRunnerOptions } from './cli-runner';
@@ -1,12 +0,0 @@
1
- export declare const defaultRunDirName = "midscene_run";
2
- export declare const getMidsceneRunDir: () => string;
3
- export declare const getMidsceneRunBaseDir: () => string;
4
- /**
5
- * Get the path to the midscene_run directory or a subdirectory within it.
6
- * Creates the directory if it doesn't exist.
7
- *
8
- * @param subdir - Optional subdirectory name (e.g., 'log', 'report')
9
- * @returns The absolute path to the requested directory
10
- */
11
- export declare const getMidsceneRunSubDir: (subdir: "dump" | "cache" | "report" | "tmp" | "log" | "output") => string;
12
- export declare const ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED = "NOT_IMPLEMENTED_AS_DESIGNED";
@@ -1,2 +0,0 @@
1
- export declare const PLAYWRIGHT_EXAMPLE_CODE = "\n// Reference the following code to generate Midscene test cases\n// The following is test code for Midscene AI, for reference\n// The following is Playwright syntax, you can use Playwright to assist in test generation\nIMPORTANT: Follow these exact type signatures for AI functions:\n\n// Type signatures for AI functions:\naiAct(prompt: string, options?: { cacheable?: boolean, deepThink?: 'unset' | true | false }): Promise<void>\naiInput(text: string, locate: string, options?: { deepLocate?: boolean, xpath?: string, cacheable?: boolean }): Promise<void>\naiTap(locate: string, options?: { deepLocate?: boolean, xpath?: string, cacheable?: boolean }): Promise<void>\naiHover(locate: string, options?: { deepLocate?: boolean, xpath?: string, cacheable?: boolean }): Promise<void>\naiDoubleClick(locate: string, options?: { deepLocate?: boolean, xpath?: string, cacheable?: boolean }): Promise<void>\naiKeyboardPress(key: string, locate?: string, options?: { deepLocate?: boolean, xpath?: string, cacheable?: boolean }): Promise<void>\naiScroll(locate: string | undefined, options: {\n direction?: 'up' | 'down' | 'left' | 'right',\n scrollType?: 'singleAction' | 'scrollToBottom' | 'scrollToTop' | 'scrollToRight' | 'scrollToLeft',\n distance?: number | null,\n deepLocate?: boolean,\n xpath?: string,\n cacheable?: boolean\n}): Promise<void>\naiAssert(assertion: string, options?: { errorMessage?: string }): Promise<void>\naiWaitFor(prompt: string, options?: { timeout?: number }): Promise<void>\naiQuery<T>(queryObject: Record<string, string>): Promise<T> // Extracts data from page based on descriptions\n\n// examples:\n// Reference the following code to generate Midscene test cases\n// The following is test code for Midscene AI, for reference\n// The following is Playwright syntax, you can use Playwright to assist in test generation\nimport { test as base } from '@playwright/test';\nimport type { PlayWrightAiFixtureType } from '@midscene/web/playwright';\nimport { PlaywrightAiFixture } from '@midscene/web/playwright';\n\nconst test = base.extend<PlayWrightAiFixtureType>(PlaywrightAiFixture({\n waitForNetworkIdleTimeout: 2000, // optional, the timeout for waiting for network idle between each action, default is 2000ms\n}));\n\n\ntest.beforeEach(async ({ page }) => {\n await page.goto('https://www.xxx.com/');\n await page.setViewportSize({ width: 1920, height: 1080 });\n});\n\ntest('ai shop', async ({\n aiAct,\n aiInput,\n aiAssert,\n aiQuery,\n aiKeyboardPress,\n aiHover,\n aiTap,\n aiWaitFor,\n agentForPage,\n page,\n}) => {\n // login\n await aiAssert('The page shows the login interface');\n await aiInput('user_name', 'in user name input');\n await aiInput('password', 'in password input');\n await aiKeyboardPress('Enter', 'Login Button');\n\n // check the login success\n await aiWaitFor('The page shows that the loading is complete');\n await aiAssert('The current page shows the product detail page');\n\n // check the product info\n const dataA = await aiQuery({\n userInfo: 'User information in the format {name: string}',\n theFirstProductInfo: 'The first product info in the format {name: string, price: number}',\n });\n expect(dataA.theFirstProductInfo.name).toBe('xxx');\n expect(dataA.theFirstProductInfo.price).toBe(100);\n\n\n // add to cart\n await aiTap('click add to cart button');\n \n await aiTap('click right top cart icon');\n await aiAssert('The cart icon shows the number 1');\n});\n";
2
- export declare const YAML_EXAMPLE_CODE = "\n1. Format:\n\nweb:\n url: \"starting_url\"\n viewportWidth: 1280\n viewportHeight: 960\n\ntasks:\n - name: \"descriptive task name\"\n flow:\n - aiTap: \"element description\"\n - aiInput: 'text value'\n locate: 'input field description'\n - aiScroll:\n direction: down/up\n scrollType: scrollToBottom/scrollToTop/singleAction\n - aiAssert: \"expected state\"\n - sleep: milliseconds\n\n2. Action Types:\n- aiTap: for clicks (natural language targeting)\n- aiInput: for text input with 'locate' field\n- aiScroll: with direction and scrollType\n- aiAssert: for validations\n- sleep: for delays (milliseconds)\n\n3. Best Practices:\n- Group related actions into logical tasks\n- Use natural language descriptions\n- Add deepLocate: true for complex interactions\n- Keep task names concise but descriptive\n\n4. CRITICAL - YAML Indentation Rules:\n- For actions with additional parameters (aiScroll, aiInput, aiKeyboardPress), the parameters must be SIBLING keys, NOT nested children\n- Parameters like direction, scrollType, locate must align with the action key, not indented further\n- CORRECT indentation example:\n - aiScroll:\n direction: down\n scrollType: singleAction\n- WRONG indentation (DO NOT do this):\n - aiScroll:\n direction: down\n scrollType: singleAction\n\n\n\nYAML type\ntasks:\n - name: <name>\n continueOnError: <boolean> # Optional, whether to continue to the next task on error, defaults to false.\n flow:\n # Auto Planning (.ai)\n # ----------------\n\n # Perform an interaction. `ai` is a shorthand for `aiAct`.\n - ai: <prompt>\n cacheable: <boolean> # Optional, whether to cache the result of this API call when the [caching feature](./caching.mdx) is enabled. Defaults to True.\n\n # This usage is the same as `ai`.\n - aiAct: <prompt>\n cacheable: <boolean> # Optional, whether to cache the result of this API call when the [caching feature](./caching.mdx) is enabled. Defaults to True.\n\n # Instant Action (.aiTap, .aiDoubleClick, .aiHover, .aiInput, .aiKeyboardPress, .aiScroll)\n # ----------------\n\n # Tap an element described by a prompt.\n - aiTap: <prompt>\n deepLocate: <boolean> # Optional, whether to use deepLocate to precisely locate the element. Defaults to False.\n xpath: <xpath> # Optional, the xpath of the target element for the operation. If provided, Midscene will prioritize this xpath to find the element before using the cache and the AI model. Defaults to empty.\n cacheable: <boolean> # Optional, whether to cache the result of this API call when the [caching feature](./caching.mdx) is enabled. Defaults to True.\n\n # Double click an element described by a prompt.\n - aiDoubleClick: <prompt>\n deepLocate: <boolean> # Optional, whether to use deepLocate to precisely locate the element. Defaults to False.\n xpath: <xpath> # Optional, the xpath of the target element for the operation. If provided, Midscene will prioritize this xpath to find the element before using the cache and the AI model. Defaults to empty.\n cacheable: <boolean> # Optional, whether to cache the result of this API call when the [caching feature](./caching.mdx) is enabled. Defaults to True.\n\n # Hover over an element described by a prompt.\n - aiHover: <prompt>\n deepLocate: <boolean> # Optional, whether to use deepLocate to precisely locate the element. Defaults to False.\n xpath: <xpath> # Optional, the xpath of the target element for the operation. If provided, Midscene will prioritize this xpath to find the element before using the cache and the AI model. Defaults to empty.\n cacheable: <boolean> # Optional, whether to cache the result of this API call when the [caching feature](./caching.mdx) is enabled. Defaults to True.\n\n # Input text into an element described by a prompt.\n - aiInput: <final text content of the input>\n locate: <prompt>\n deepLocate: <boolean> # Optional, whether to use deepLocate to precisely locate the element. Defaults to False.\n xpath: <xpath> # Optional, the xpath of the target element for the operation. If provided, Midscene will prioritize this xpath to find the element before using the cache and the AI model. Defaults to empty.\n cacheable: <boolean> # Optional, whether to cache the result of this API call when the [caching feature](./caching.mdx) is enabled. Defaults to True.\n\n # Press a key (e.g., Enter, Tab, Escape) on an element described by a prompt.\n - aiKeyboardPress: <key>\n locate: <prompt>\n deepLocate: <boolean> # Optional, whether to use deepLocate to precisely locate the element. Defaults to False.\n xpath: <xpath> # Optional, the xpath of the target element for the operation. If provided, Midscene will prioritize this xpath to find the element before using the cache and the AI model. Defaults to empty.\n cacheable: <boolean> # Optional, whether to cache the result of this API call when the [caching feature](./caching.mdx) is enabled. Defaults to True.\n\n # Scroll globally or on an element described by a prompt.\n - aiScroll:\n direction: 'up' # or 'down' | 'left' | 'right'\n scrollType: 'singleAction' # or 'scrollToTop' | 'scrollToBottom' | 'scrollToLeft' | 'scrollToRight'\n distance: <number> # Optional, the scroll distance in pixels.\n locate: <prompt> # Optional, the element to scroll on.\n deepLocate: <boolean> # Optional, whether to use deepLocate to precisely locate the element. Defaults to False.\n xpath: <xpath> # Optional, the xpath of the target element for the operation. If provided, Midscene will prioritize this xpath to find the element before using the cache and the AI model. Defaults to empty.\n cacheable: <boolean> # Optional, whether to cache the result of this API call when the [caching feature](./caching.mdx) is enabled. Defaults to True.\n\n # Record the current screenshot with a description in the report file.\n - recordToReport: <title> # Optional, the title of the screenshot. If not provided, the title will be 'untitled'.\n content: <content> # Optional, the description of the screenshot.\n\n # Data Extraction\n # ----------------\n\n # Perform a query that returns a JSON object.\n - aiQuery: <prompt> # Remember to describe the format of the result in the prompt.\n name: <name> # The key for the query result in the JSON output.\n\n # More APIs\n # ----------------\n\n # Wait for a condition to be met, with a timeout (in ms, optional, defaults to 30000).\n - aiWaitFor: <prompt>\n timeout: <ms>\n\n # Perform an assertion.\n - aiAssert: <prompt>\n errorMessage: <error-message> # Optional, the error message to print if the assertion fails.\n\n # Wait for a specified amount of time.\n - sleep: <ms>\n\n # Execute a piece of JavaScript code in the web page context.\n - javascript: <javascript>\n name: <name> # Optional, assign a name to the return value, which will be used as a key in the JSON output.\n\n - name: <name>\n flow:\n # ...\n";
@@ -1,21 +0,0 @@
1
- export declare const TEXT_SIZE_THRESHOLD = 9;
2
- export declare const TEXT_MAX_SIZE = 40;
3
- export declare const CONTAINER_MINI_HEIGHT = 3;
4
- export declare const CONTAINER_MINI_WIDTH = 3;
5
- export declare enum NodeType {
6
- CONTAINER = "CONTAINER Node",
7
- FORM_ITEM = "FORM_ITEM Node",
8
- BUTTON = "BUTTON Node",
9
- A = "Anchor Node",
10
- IMG = "IMG Node",
11
- TEXT = "TEXT Node",
12
- POSITION = "POSITION Node"
13
- }
14
- export declare const PLAYGROUND_SERVER_PORT = 5800;
15
- export declare const SCRCPY_SERVER_PORT = 5700;
16
- export declare const WEBDRIVER_ELEMENT_ID_KEY = "element-6066-11e4-a52e-4f735466cecf";
17
- export declare const DEFAULT_WDA_PORT = 8100;
18
- export declare const DEFAULT_WAIT_FOR_NAVIGATION_TIMEOUT = 5000;
19
- export declare const DEFAULT_WAIT_FOR_NETWORK_IDLE_TIMEOUT = 2000;
20
- export declare const DEFAULT_WAIT_FOR_NETWORK_IDLE_CONCURRENCY = 2;
21
- export { PLAYWRIGHT_EXAMPLE_CODE, YAML_EXAMPLE_CODE } from './example-code';
@@ -1,6 +0,0 @@
1
- import { BASIC_ENV_KEYS } from './types';
2
- /**
3
- * get basic env value from process.env
4
- * use a single file to avoid circular dependency
5
- */
6
- export declare const getBasicEnvValue: (key: (typeof BASIC_ENV_KEYS)[number]) => string | undefined;
@@ -1,40 +0,0 @@
1
- interface IModelConfigKeys {
2
- modelName: string;
3
- /**
4
- * proxy
5
- */
6
- socksProxy: string;
7
- httpProxy: string;
8
- /**
9
- * OpenAI
10
- */
11
- openaiBaseURL: string;
12
- openaiApiKey: string;
13
- openaiExtraConfig: string;
14
- extraBody: string;
15
- /**
16
- * Extra
17
- */
18
- modelFamily: string;
19
- /**
20
- * Timeout
21
- */
22
- timeout: string;
23
- /**
24
- * Temperature
25
- */
26
- temperature: string;
27
- /**
28
- * Retry
29
- */
30
- retryCount: string;
31
- retryInterval: string;
32
- reasoningEffort: string;
33
- reasoningEnabled: string;
34
- reasoningBudget: string;
35
- }
36
- export declare const INSIGHT_MODEL_CONFIG_KEYS: IModelConfigKeys;
37
- export declare const PLANNING_MODEL_CONFIG_KEYS: IModelConfigKeys;
38
- export declare const DEFAULT_MODEL_CONFIG_KEYS: IModelConfigKeys;
39
- export declare const DEFAULT_MODEL_CONFIG_KEYS_LEGACY: IModelConfigKeys;
40
- export {};
@@ -1,32 +0,0 @@
1
- import type { ModelConfigManager } from './model-config-manager';
2
- import { BOOLEAN_ENV_KEYS, GLOBAL_ENV_KEYS, NUMBER_ENV_KEYS, STRING_ENV_KEYS } from './types';
3
- import { MODEL_ENV_KEYS } from './types';
4
- /**
5
- * Collect global configs from process.env, overrideAIConfig, etc.
6
- * And provider methods to get merged config value
7
- */
8
- export declare class GlobalConfigManager {
9
- private override;
10
- private keysHaveBeenRead;
11
- private globalModelConfigManager;
12
- constructor();
13
- /**
14
- * recalculate allEnvConfig every time because process.env can be updated any time
15
- */
16
- getAllEnvConfig(): Record<string, string | undefined>;
17
- getEnvConfigValue(key: (typeof STRING_ENV_KEYS)[number]): string | undefined;
18
- /**
19
- * read boolean only from process.env
20
- */
21
- getEnvConfigInBoolean(key: (typeof BOOLEAN_ENV_KEYS)[number]): boolean;
22
- /**
23
- * Read environment variable value and convert it to number.
24
- * Returns undefined if the value is not set or cannot be converted to a valid number.
25
- */
26
- getEnvConfigValueAsNumber(key: (typeof STRING_ENV_KEYS)[number] | (typeof NUMBER_ENV_KEYS)[number]): number | undefined;
27
- registerModelConfigManager(globalModelConfigManager: ModelConfigManager): void;
28
- /**
29
- * @deprecated use the modelConfig param in Agent constructor instead
30
- */
31
- overrideAIConfig(newConfig: Partial<Record<(typeof GLOBAL_ENV_KEYS)[number] | (typeof MODEL_ENV_KEYS)[number], string>>, extendMode?: boolean): void;
32
- }
@@ -1,4 +0,0 @@
1
- export declare const maskConfig: (config: Record<string, unknown>) => {
2
- [k: string]: unknown;
3
- };
4
- export declare const parseJson: (key: string, value: string | undefined) => any;
@@ -1,4 +0,0 @@
1
- export * from './utils';
2
- export * from './types';
3
- export { ModelConfigManager } from './model-config-manager';
4
- export { GlobalConfigManager } from './global-config-manager';
@@ -1 +0,0 @@
1
- export declare const initDebugConfig: () => void;
@@ -1,25 +0,0 @@
1
- import type { GlobalConfigManager } from './global-config-manager';
2
- import type { CreateOpenAIClientFn, IModelConfig, TIntent, TModelConfig } from './types';
3
- export declare class ModelConfigManager {
4
- private modelConfigMap;
5
- private isInitialized;
6
- private isolatedMode;
7
- private globalConfigManager;
8
- private modelConfig?;
9
- private createOpenAIClientFn?;
10
- constructor(modelConfig?: TModelConfig, createOpenAIClientFn?: CreateOpenAIClientFn);
11
- private initialize;
12
- private normalizeModelConfig;
13
- /**
14
- * should only be called by GlobalConfigManager
15
- */
16
- clearModelConfigMap(): void;
17
- /**
18
- * if isolatedMode is true, modelConfigMap was initialized in constructor and can't be changed
19
- * if isolatedMode is false, modelConfigMap can be changed by process.env so we need to recalculate it when it's undefined
20
- */
21
- getModelConfig(intent: TIntent): IModelConfig;
22
- getUploadTestServerUrl(): string | undefined;
23
- registerGlobalConfigManager(globalConfigManager: GlobalConfigManager): void;
24
- throwErrorIfNonVLModel(): void;
25
- }
@@ -1,31 +0,0 @@
1
- import { DEFAULT_MODEL_CONFIG_KEYS, type DEFAULT_MODEL_CONFIG_KEYS_LEGACY, INSIGHT_MODEL_CONFIG_KEYS, PLANNING_MODEL_CONFIG_KEYS } from './constants';
2
- import { type IModelConfig, type TIntent, type TModelFamily, UITarsModelVersion } from './types';
3
- type TModelConfigKeys = typeof INSIGHT_MODEL_CONFIG_KEYS | typeof PLANNING_MODEL_CONFIG_KEYS | typeof DEFAULT_MODEL_CONFIG_KEYS | typeof DEFAULT_MODEL_CONFIG_KEYS_LEGACY;
4
- /**
5
- * Get UI-TARS model version from model family
6
- * @param modelFamily - The model family value
7
- * @returns UITarsModelVersion if the model family is a UI-TARS variant, undefined otherwise
8
- */
9
- export declare const getUITarsModelVersion: (modelFamily?: TModelFamily) => UITarsModelVersion | undefined;
10
- /**
11
- * Validate model family value
12
- * @param modelFamily - The model family value to validate
13
- * @throws Error if the model family is invalid
14
- */
15
- export declare const validateModelFamily: (modelFamily?: TModelFamily) => void;
16
- /**
17
- * Convert legacy environment variables to model family
18
- * @param provider - Environment variable provider (e.g., process.env)
19
- * @returns The corresponding model family value, or undefined if no legacy config is found
20
- */
21
- export declare const legacyConfigToModelFamily: (provider: Record<string, string | undefined>) => TModelFamily | undefined;
22
- /**
23
- * Parse OpenAI SDK config
24
- */
25
- export declare const parseOpenaiSdkConfig: ({ keys, provider, useLegacyLogic, }: {
26
- keys: TModelConfigKeys;
27
- provider: Record<string, string | undefined>;
28
- useLegacyLogic?: boolean;
29
- }) => IModelConfig;
30
- export declare const decideModelConfigFromIntentConfig: (intent: TIntent, configMap: Record<string, string | undefined>) => IModelConfig | undefined;
31
- export {};