@rpascene/shared 0.30.8

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 (177) hide show
  1. package/README.md +9 -0
  2. package/dist/es/baseDB.mjs +109 -0
  3. package/dist/es/build/copy-static.mjs +29 -0
  4. package/dist/es/common.mjs +37 -0
  5. package/dist/es/constants/example-code.mjs +202 -0
  6. package/dist/es/constants/index.mjs +74 -0
  7. package/dist/es/env/basic.mjs +6 -0
  8. package/dist/es/env/constants.mjs +97 -0
  9. package/dist/es/env/decide-model-config.mjs +172 -0
  10. package/dist/es/env/global-config-manager.mjs +82 -0
  11. package/dist/es/env/helper.mjs +45 -0
  12. package/dist/es/env/index.mjs +5 -0
  13. package/dist/es/env/init-debug.mjs +18 -0
  14. package/dist/es/env/model-config-manager.mjs +99 -0
  15. package/dist/es/env/parse.mjs +69 -0
  16. package/dist/es/env/types.mjs +265 -0
  17. package/dist/es/env/utils.mjs +18 -0
  18. package/dist/es/extractor/constants.mjs +2 -0
  19. package/dist/es/extractor/cs_postmessage.mjs +61 -0
  20. package/dist/es/extractor/customLocator.mjs +646 -0
  21. package/dist/es/extractor/debug.mjs +6 -0
  22. package/dist/es/extractor/dom-util.mjs +92 -0
  23. package/dist/es/extractor/index.mjs +7 -0
  24. package/dist/es/extractor/locator.mjs +95 -0
  25. package/dist/es/extractor/tree.mjs +81 -0
  26. package/dist/es/extractor/util.mjs +244 -0
  27. package/dist/es/extractor/web-extractor.mjs +361 -0
  28. package/dist/es/img/box-select.mjs +184 -0
  29. package/dist/es/img/draw-box.mjs +42 -0
  30. package/dist/es/img/get-jimp.mjs +10 -0
  31. package/dist/es/img/get-photon.mjs +19 -0
  32. package/dist/es/img/get-sharp.mjs +11 -0
  33. package/dist/es/img/index.mjs +5 -0
  34. package/dist/es/img/info.mjs +32 -0
  35. package/dist/es/img/transform.mjs +192 -0
  36. package/dist/es/index.mjs +3 -0
  37. package/dist/es/logger.mjs +61 -0
  38. package/dist/es/node/fs.mjs +44 -0
  39. package/dist/es/node/index.mjs +1 -0
  40. package/dist/es/polyfills/async-hooks.mjs +2 -0
  41. package/dist/es/polyfills/index.mjs +1 -0
  42. package/dist/es/types/index.mjs +3 -0
  43. package/dist/es/us-keyboard-layout.mjs +1414 -0
  44. package/dist/es/us-keyboard-layout.mjs.LICENSE.txt +5 -0
  45. package/dist/es/utils.mjs +66 -0
  46. package/dist/lib/baseDB.js +149 -0
  47. package/dist/lib/build/copy-static.js +77 -0
  48. package/dist/lib/common.js +93 -0
  49. package/dist/lib/constants/example-code.js +239 -0
  50. package/dist/lib/constants/index.js +153 -0
  51. package/dist/lib/env/basic.js +40 -0
  52. package/dist/lib/env/constants.js +143 -0
  53. package/dist/lib/env/decide-model-config.js +212 -0
  54. package/dist/lib/env/global-config-manager.js +116 -0
  55. package/dist/lib/env/helper.js +85 -0
  56. package/dist/lib/env/index.js +94 -0
  57. package/dist/lib/env/init-debug.js +52 -0
  58. package/dist/lib/env/model-config-manager.js +133 -0
  59. package/dist/lib/env/parse.js +106 -0
  60. package/dist/lib/env/types.js +650 -0
  61. package/dist/lib/env/utils.js +61 -0
  62. package/dist/lib/extractor/constants.js +42 -0
  63. package/dist/lib/extractor/cs_postmessage.js +98 -0
  64. package/dist/lib/extractor/customLocator.js +698 -0
  65. package/dist/lib/extractor/debug.js +12 -0
  66. package/dist/lib/extractor/dom-util.js +150 -0
  67. package/dist/lib/extractor/index.js +153 -0
  68. package/dist/lib/extractor/locator.js +141 -0
  69. package/dist/lib/extractor/tree.js +127 -0
  70. package/dist/lib/extractor/util.js +335 -0
  71. package/dist/lib/extractor/web-extractor.js +407 -0
  72. package/dist/lib/img/box-select.js +232 -0
  73. package/dist/lib/img/draw-box.js +89 -0
  74. package/dist/lib/img/get-jimp.js +72 -0
  75. package/dist/lib/img/get-photon.js +76 -0
  76. package/dist/lib/img/get-sharp.js +63 -0
  77. package/dist/lib/img/index.js +102 -0
  78. package/dist/lib/img/info.js +86 -0
  79. package/dist/lib/img/transform.js +279 -0
  80. package/dist/lib/index.js +43 -0
  81. package/dist/lib/logger.js +114 -0
  82. package/dist/lib/node/fs.js +97 -0
  83. package/dist/lib/node/index.js +60 -0
  84. package/dist/lib/polyfills/async-hooks.js +36 -0
  85. package/dist/lib/polyfills/index.js +60 -0
  86. package/dist/lib/types/index.js +37 -0
  87. package/dist/lib/us-keyboard-layout.js +1457 -0
  88. package/dist/lib/us-keyboard-layout.js.LICENSE.txt +5 -0
  89. package/dist/lib/utils.js +136 -0
  90. package/dist/types/baseDB.d.ts +25 -0
  91. package/dist/types/build/copy-static.d.ts +31 -0
  92. package/dist/types/common.d.ts +12 -0
  93. package/dist/types/constants/example-code.d.ts +2 -0
  94. package/dist/types/constants/index.d.ts +23 -0
  95. package/dist/types/env/basic.d.ts +6 -0
  96. package/dist/types/env/constants.d.ts +40 -0
  97. package/dist/types/env/decide-model-config.d.ts +14 -0
  98. package/dist/types/env/global-config-manager.d.ts +32 -0
  99. package/dist/types/env/helper.d.ts +6 -0
  100. package/dist/types/env/index.d.ts +4 -0
  101. package/dist/types/env/init-debug.d.ts +1 -0
  102. package/dist/types/env/model-config-manager.d.ts +24 -0
  103. package/dist/types/env/parse.d.ts +12 -0
  104. package/dist/types/env/types.d.ts +295 -0
  105. package/dist/types/env/utils.d.ts +7 -0
  106. package/dist/types/extractor/constants.d.ts +1 -0
  107. package/dist/types/extractor/cs_postmessage.d.ts +2 -0
  108. package/dist/types/extractor/customLocator.d.ts +69 -0
  109. package/dist/types/extractor/debug.d.ts +1 -0
  110. package/dist/types/extractor/dom-util.d.ts +26 -0
  111. package/dist/types/extractor/index.d.ts +36 -0
  112. package/dist/types/extractor/locator.d.ts +7 -0
  113. package/dist/types/extractor/tree.d.ts +9 -0
  114. package/dist/types/extractor/util.d.ts +43 -0
  115. package/dist/types/extractor/web-extractor.d.ts +19 -0
  116. package/dist/types/img/box-select.d.ts +25 -0
  117. package/dist/types/img/draw-box.d.ts +15 -0
  118. package/dist/types/img/get-jimp.d.ts +2 -0
  119. package/dist/types/img/get-photon.d.ts +8 -0
  120. package/dist/types/img/get-sharp.d.ts +3 -0
  121. package/dist/types/img/index.d.ts +4 -0
  122. package/dist/types/img/info.d.ts +29 -0
  123. package/dist/types/img/transform.d.ts +88 -0
  124. package/dist/types/index.d.ts +3 -0
  125. package/dist/types/logger.d.ts +4 -0
  126. package/dist/types/node/fs.d.ts +15 -0
  127. package/dist/types/node/index.d.ts +1 -0
  128. package/dist/types/polyfills/async-hooks.d.ts +6 -0
  129. package/dist/types/polyfills/index.d.ts +4 -0
  130. package/dist/types/types/index.d.ts +37 -0
  131. package/dist/types/us-keyboard-layout.d.ts +32 -0
  132. package/dist/types/utils.d.ts +22 -0
  133. package/package.json +102 -0
  134. package/src/baseDB.ts +158 -0
  135. package/src/build/copy-static.ts +62 -0
  136. package/src/common.ts +67 -0
  137. package/src/constants/example-code.ts +202 -0
  138. package/src/constants/index.ts +81 -0
  139. package/src/env/basic.ts +12 -0
  140. package/src/env/constants.ts +291 -0
  141. package/src/env/decide-model-config.ts +319 -0
  142. package/src/env/global-config-manager.ts +174 -0
  143. package/src/env/helper.ts +80 -0
  144. package/src/env/index.ts +4 -0
  145. package/src/env/init-debug.ts +29 -0
  146. package/src/env/model-config-manager.ts +145 -0
  147. package/src/env/parse.ts +131 -0
  148. package/src/env/types.ts +573 -0
  149. package/src/env/utils.ts +39 -0
  150. package/src/extractor/constants.ts +5 -0
  151. package/src/extractor/cs_postmessage.ts +101 -0
  152. package/src/extractor/customLocator.ts +1138 -0
  153. package/src/extractor/debug.ts +10 -0
  154. package/src/extractor/dom-util.ts +141 -0
  155. package/src/extractor/index.ts +54 -0
  156. package/src/extractor/locator.ts +179 -0
  157. package/src/extractor/tree.ts +179 -0
  158. package/src/extractor/util.ts +468 -0
  159. package/src/extractor/web-extractor.ts +559 -0
  160. package/src/img/box-select.ts +346 -0
  161. package/src/img/draw-box.ts +60 -0
  162. package/src/img/get-jimp.ts +12 -0
  163. package/src/img/get-photon.ts +48 -0
  164. package/src/img/get-sharp.ts +18 -0
  165. package/src/img/index.ts +24 -0
  166. package/src/img/info.ts +79 -0
  167. package/src/img/jimp.d.ts +4 -0
  168. package/src/img/transform.ts +396 -0
  169. package/src/index.ts +6 -0
  170. package/src/logger.ts +93 -0
  171. package/src/node/fs.ts +84 -0
  172. package/src/node/index.ts +1 -0
  173. package/src/polyfills/async-hooks.ts +6 -0
  174. package/src/polyfills/index.ts +4 -0
  175. package/src/types/index.ts +53 -0
  176. package/src/us-keyboard-layout.ts +723 -0
  177. package/src/utils.ts +127 -0
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2017 Google Inc.
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
@@ -0,0 +1,136 @@
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
+ generateHashId: ()=>generateHashId,
28
+ logMsg: ()=>logMsg,
29
+ uuid: ()=>uuid,
30
+ ifInWorker: ()=>ifInWorker,
31
+ ifInNode: ()=>ifInNode,
32
+ escapeScriptTag: ()=>escapeScriptTag,
33
+ antiEscapeScriptTag: ()=>antiEscapeScriptTag,
34
+ repeat: ()=>repeat,
35
+ setIsMcp: ()=>setIsMcp,
36
+ ifInBrowser: ()=>ifInBrowser,
37
+ replaceIllegalPathCharsAndSpace: ()=>replaceIllegalPathCharsAndSpace,
38
+ assert: ()=>assert,
39
+ getGlobalScope: ()=>getGlobalScope
40
+ });
41
+ const external_js_sha256_namespaceObject = require("js-sha256");
42
+ const external_uuid_namespaceObject = require("uuid");
43
+ var _process_versions;
44
+ const ifInBrowser = 'undefined' != typeof window;
45
+ const ifInWorker = 'undefined' != typeof WorkerGlobalScope;
46
+ const ifInNode = 'undefined' != typeof process && (null == (_process_versions = process.versions) ? void 0 : _process_versions.node);
47
+ function uuid() {
48
+ return (0, external_uuid_namespaceObject.v4)();
49
+ }
50
+ const hashMap = {};
51
+ function generateHashId(rect, content = '') {
52
+ const combined = JSON.stringify({
53
+ content,
54
+ rect
55
+ });
56
+ let sliceLength = 5;
57
+ let slicedHash = '';
58
+ const hashHex = external_js_sha256_namespaceObject.sha256.create().update(combined).hex();
59
+ const toLetters = (hex)=>hex.split('').map((char)=>{
60
+ const code = Number.parseInt(char, 16);
61
+ return String.fromCharCode(97 + code % 26);
62
+ }).join('');
63
+ const hashLetters = toLetters(hashHex);
64
+ while(sliceLength < hashLetters.length - 1){
65
+ slicedHash = hashLetters.slice(0, sliceLength);
66
+ if (hashMap[slicedHash] && hashMap[slicedHash] !== combined) {
67
+ sliceLength++;
68
+ continue;
69
+ }
70
+ hashMap[slicedHash] = combined;
71
+ break;
72
+ }
73
+ return slicedHash;
74
+ }
75
+ function assert(condition, message) {
76
+ if (!condition) throw new Error(message || 'Assertion failed');
77
+ }
78
+ function getGlobalScope() {
79
+ if ('undefined' != typeof window) return window;
80
+ if ('undefined' != typeof globalThis) return globalThis;
81
+ if ('undefined' != typeof self) return self;
82
+ }
83
+ let isMcp = false;
84
+ function setIsMcp(value) {
85
+ isMcp = value;
86
+ }
87
+ function logMsg(...message) {
88
+ if (!isMcp) console.log(...message);
89
+ }
90
+ async function repeat(times, fn) {
91
+ for(let i = 0; i < times; i++)await fn(i);
92
+ }
93
+ const utils_REGEXP_LT = /</g;
94
+ const utils_REGEXP_GT = />/g;
95
+ const REGEXP_LT_ESCAPE = '__rpascene_lt__';
96
+ const REGEXP_GT_ESCAPE = '__rpascene_gt__';
97
+ const escapeScriptTag = (html)=>html.replace(utils_REGEXP_LT, REGEXP_LT_ESCAPE).replace(utils_REGEXP_GT, REGEXP_GT_ESCAPE);
98
+ const antiEscapeScriptTag = (html)=>{
99
+ const REGEXP_LT = new RegExp(REGEXP_LT_ESCAPE, 'g');
100
+ const REGEXP_GT = new RegExp(REGEXP_GT_ESCAPE, 'g');
101
+ return html.replace(REGEXP_LT, '<').replace(REGEXP_GT, '>');
102
+ };
103
+ function replaceIllegalPathCharsAndSpace(str) {
104
+ return str.replace(/[:*?"<>| ]/g, '-');
105
+ }
106
+ exports.antiEscapeScriptTag = __webpack_exports__.antiEscapeScriptTag;
107
+ exports.assert = __webpack_exports__.assert;
108
+ exports.escapeScriptTag = __webpack_exports__.escapeScriptTag;
109
+ exports.generateHashId = __webpack_exports__.generateHashId;
110
+ exports.getGlobalScope = __webpack_exports__.getGlobalScope;
111
+ exports.ifInBrowser = __webpack_exports__.ifInBrowser;
112
+ exports.ifInNode = __webpack_exports__.ifInNode;
113
+ exports.ifInWorker = __webpack_exports__.ifInWorker;
114
+ exports.logMsg = __webpack_exports__.logMsg;
115
+ exports.repeat = __webpack_exports__.repeat;
116
+ exports.replaceIllegalPathCharsAndSpace = __webpack_exports__.replaceIllegalPathCharsAndSpace;
117
+ exports.setIsMcp = __webpack_exports__.setIsMcp;
118
+ exports.uuid = __webpack_exports__.uuid;
119
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
120
+ "antiEscapeScriptTag",
121
+ "assert",
122
+ "escapeScriptTag",
123
+ "generateHashId",
124
+ "getGlobalScope",
125
+ "ifInBrowser",
126
+ "ifInNode",
127
+ "ifInWorker",
128
+ "logMsg",
129
+ "repeat",
130
+ "replaceIllegalPathCharsAndSpace",
131
+ "setIsMcp",
132
+ "uuid"
133
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
134
+ Object.defineProperty(exports, '__esModule', {
135
+ value: true
136
+ });
@@ -0,0 +1,25 @@
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>;
@@ -0,0 +1,31 @@
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
+ };
@@ -0,0 +1,12 @@
1
+ export declare const defaultRunDirName = "rpascene_run";
2
+ export declare const getRpasceneRunDir: () => string;
3
+ export declare const getRpasceneRunBaseDir: () => string;
4
+ /**
5
+ * Get the path to the rpascene_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 getRpasceneRunSubDir: (subdir: "dump" | "cache" | "report" | "tmp" | "log" | "output") => string;
12
+ export declare const ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED = "NOT_IMPLEMENTED_AS_DESIGNED";
@@ -0,0 +1,2 @@
1
+ export declare const PLAYWRIGHT_EXAMPLE_CODE = "\n// Reference the following code to generate Rpascene test cases\n// The following is test code for Rpascene 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:\naiInput(value: string, locator: string): Promise<void>\naiTap(locator: string): Promise<void>\naiDoubleClick(locator: string): Promise<void>\naiScroll(scrollParam: {\n direction: 'up' | 'down' | 'left' | 'right',\n scrollType: 'once' | 'untilBottom' | 'untilTop' | 'untilRight' | 'untilLeft',\n distance: number - scroll distance, px is the unit\n}): Promise<void>\naiAssert(assertion: string): 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 Rpascene test cases\n// The following is test code for Rpascene 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 '@rpascene/web/playwright';\nimport { PlaywrightAiFixture } from '@rpascene/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 aiInput,\n aiAssert,\n aiQuery,\n aiKeyboardPress,\n aiHover,\n aiTap,\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: untilBottom/untilTop/page\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 deepThink: true for complex interactions\n- Keep task names concise but descriptive\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 `aiAction`.\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 - aiAction: <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 deepThink: <boolean> # Optional, whether to use deepThink to precisely locate the element. Defaults to False.\n xpath: <xpath> # Optional, the xpath of the target element for the operation. If provided, Rpascene 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 deepThink: <boolean> # Optional, whether to use deepThink to precisely locate the element. Defaults to False.\n xpath: <xpath> # Optional, the xpath of the target element for the operation. If provided, Rpascene 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 deepThink: <boolean> # Optional, whether to use deepThink to precisely locate the element. Defaults to False.\n xpath: <xpath> # Optional, the xpath of the target element for the operation. If provided, Rpascene 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 deepThink: <boolean> # Optional, whether to use deepThink to precisely locate the element. Defaults to False.\n xpath: <xpath> # Optional, the xpath of the target element for the operation. If provided, Rpascene 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 deepThink: <boolean> # Optional, whether to use deepThink to precisely locate the element. Defaults to False.\n xpath: <xpath> # Optional, the xpath of the target element for the operation. If provided, Rpascene 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: 'once' # or 'untilTop' | 'untilBottom' | 'untilLeft' | 'untilRight'\n distance: <number> # Optional, the scroll distance in pixels.\n locate: <prompt> # Optional, the element to scroll on.\n deepThink: <boolean> # Optional, whether to use deepThink to precisely locate the element. Defaults to False.\n xpath: <xpath> # Optional, the xpath of the target element for the operation. If provided, Rpascene 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 # Log the current screenshot with a description in the report file.\n - logScreenshot: <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";
@@ -0,0 +1,23 @@
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_TIME = 300;
21
+ export declare const DEFAULT_WAIT_FOR_NETWORK_IDLE_CONCURRENCY = 2;
22
+ export { PLAYWRIGHT_EXAMPLE_CODE, YAML_EXAMPLE_CODE } from './example-code';
23
+ export declare const commandMap: any;
@@ -0,0 +1,6 @@
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;
@@ -0,0 +1,40 @@
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
+ /**
15
+ * Azure
16
+ */
17
+ openaiUseAzureDeprecated: string;
18
+ useAzureOpenai: string;
19
+ azureOpenaiScope: string;
20
+ azureOpenaiKey: string;
21
+ azureOpenaiEndpoint: string;
22
+ azureOpenaiApiVersion: string;
23
+ azureOpenaiDeployment: string;
24
+ azureExtraConfig: string;
25
+ /**
26
+ * Anthropic
27
+ */
28
+ useAnthropicSdk: string;
29
+ anthropicApiKey: string;
30
+ /**
31
+ * Extra
32
+ */
33
+ vlMode: string;
34
+ }
35
+ export declare const VQA_MODEL_CONFIG_KEYS: IModelConfigKeys;
36
+ export declare const GROUNDING_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 {};
@@ -0,0 +1,14 @@
1
+ import type { IModelConfig, TIntent } from './types';
2
+ import { DEFAULT_MODEL_CONFIG_KEYS, DEFAULT_MODEL_CONFIG_KEYS_LEGACY, GROUNDING_MODEL_CONFIG_KEYS, PLANNING_MODEL_CONFIG_KEYS, VQA_MODEL_CONFIG_KEYS } from './constants';
3
+ type TModelConfigKeys = typeof VQA_MODEL_CONFIG_KEYS | typeof GROUNDING_MODEL_CONFIG_KEYS | typeof PLANNING_MODEL_CONFIG_KEYS | typeof DEFAULT_MODEL_CONFIG_KEYS | typeof DEFAULT_MODEL_CONFIG_KEYS_LEGACY;
4
+ /**
5
+ * Choose OpenAI SDK config, such as OpenAI, AzureOpenAI, AnthropicSDK, etc.
6
+ */
7
+ export declare const decideOpenaiSdkConfig: ({ keys, provider, valueAssert, }: {
8
+ keys: TModelConfigKeys;
9
+ provider: Record<string, string | undefined>;
10
+ valueAssert: (value: string | undefined, key: string, modelVendorFlag?: string) => void;
11
+ }) => Omit<IModelConfig, "modelName" | "from" | "vlMode" | "uiTarsVersion" | "modelDescription" | "intent">;
12
+ export declare const decideModelConfigFromIntentConfig: (intent: TIntent, intentConfig: Record<string, string | undefined>) => IModelConfig;
13
+ export declare const decideModelConfigFromEnv: (intent: TIntent, allEnvConfig: Record<string, string | undefined>) => IModelConfig;
14
+ export {};
@@ -0,0 +1,32 @@
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 number only from process.env
20
+ */
21
+ getEnvConfigInNumber(key: (typeof NUMBER_ENV_KEYS)[number]): number;
22
+ /**
23
+ * read boolean only from process.env
24
+ */
25
+ getEnvConfigInBoolean(key: (typeof BOOLEAN_ENV_KEYS)[number]): boolean;
26
+ registerModelConfigManager(globalModelConfigManager: ModelConfigManager): void;
27
+ /**
28
+ * for overrideAIConfig
29
+ * can only override keys in MODEL_ENV_KEYS
30
+ */
31
+ overrideAIConfig(newConfig: Partial<Record<(typeof GLOBAL_ENV_KEYS)[number] | (typeof MODEL_ENV_KEYS)[number], string>>, extendMode?: boolean): void;
32
+ }
@@ -0,0 +1,6 @@
1
+ import type { IModelConfig } from './types';
2
+ export declare const maskConfig: (config: IModelConfig) => {
3
+ [k: string]: any;
4
+ };
5
+ export declare const parseJson: (key: string, value: string | undefined) => any;
6
+ export declare const createAssert: (modelNameKey: string, provider: "process.env" | "modelConfig", modelName?: string) => (value: string | undefined, key: string, modelVendorFlag?: string) => void;
@@ -0,0 +1,4 @@
1
+ export * from './utils';
2
+ export * from './types';
3
+ export { ModelConfigManager } from './model-config-manager';
4
+ export { GlobalConfigManager } from './global-config-manager';
@@ -0,0 +1 @@
1
+ export declare const initDebugConfig: () => void;
@@ -0,0 +1,24 @@
1
+ import type { GlobalConfigManager } from './global-config-manager';
2
+ import type { IModelConfig, TIntent, TModelConfigFn } from './types';
3
+ export type TIntentConfigMap = Record<TIntent, ReturnType<TModelConfigFn> | undefined>;
4
+ export declare class ModelConfigManager {
5
+ private modelConfigMap;
6
+ private isolatedMode;
7
+ private globalConfigManager;
8
+ constructor(modelConfigFn?: TModelConfigFn);
9
+ private calcIntentConfigMap;
10
+ private calcModelConfigMapBaseOnIntent;
11
+ private calcModelConfigMapBaseOnEnv;
12
+ /**
13
+ * should only be called by GlobalConfigManager
14
+ */
15
+ clearModelConfigMap(): void;
16
+ /**
17
+ * if isolatedMode is true, modelConfigMap was initialized in constructor and can't be changed
18
+ * if isolatedMode is false, modelConfigMap can be changed by process.env so we need to recalculate it when it's undefined
19
+ */
20
+ getModelConfig(intent: TIntent): IModelConfig;
21
+ getUploadTestServerUrl(): string | undefined;
22
+ registerGlobalConfigManager(globalConfigManager: GlobalConfigManager): void;
23
+ throwErrorIfNonVLModel(intent?: TIntent): void;
24
+ }
@@ -0,0 +1,12 @@
1
+ import { type TVlModeTypes, UITarsModelVersion } from './types';
2
+ export declare const parseVlModeAndUiTarsModelVersionFromRawValue: (vlModeRaw?: string) => {
3
+ vlMode?: TVlModeTypes;
4
+ uiTarsVersion?: UITarsModelVersion;
5
+ };
6
+ /**
7
+ * legacy logic of how to detect vlMode from process.env without intent
8
+ */
9
+ export declare const parseVlModeAndUiTarsFromGlobalConfig: (provider: Record<string, string | undefined>) => {
10
+ vlMode?: TVlModeTypes;
11
+ uiTarsVersion?: UITarsModelVersion;
12
+ };