@rpascene/shared 0.30.8 → 0.30.9
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/README.md +2 -2
- package/dist/es/common.mjs +9 -9
- package/dist/es/constants/example-code.mjs +10 -10
- package/dist/es/constants/index.mjs +1 -1
- package/dist/es/env/constants.mjs +77 -77
- package/dist/es/env/global-config-manager.mjs +1 -1
- package/dist/es/env/init-debug.mjs +5 -5
- package/dist/es/env/model-config-manager.mjs +1 -1
- package/dist/es/env/parse.mjs +11 -11
- package/dist/es/env/types.mjs +191 -191
- package/dist/es/env/utils.mjs +2 -2
- package/dist/es/extractor/debug.mjs +2 -2
- package/dist/es/extractor/util.mjs +11 -11
- package/dist/es/extractor/web-extractor.mjs +7 -7
- package/dist/es/logger.mjs +3 -3
- package/dist/es/node/fs.mjs +6 -6
- package/dist/es/utils.mjs +2 -2
- package/dist/lib/common.js +16 -16
- package/dist/lib/constants/example-code.js +10 -10
- package/dist/lib/constants/index.js +1 -1
- package/dist/lib/env/constants.js +76 -76
- package/dist/lib/env/global-config-manager.js +1 -1
- package/dist/lib/env/init-debug.js +4 -4
- package/dist/lib/env/model-config-manager.js +1 -1
- package/dist/lib/env/parse.js +10 -10
- package/dist/lib/env/types.js +478 -478
- package/dist/lib/env/utils.js +1 -1
- package/dist/lib/extractor/debug.js +1 -1
- package/dist/lib/extractor/util.js +16 -16
- package/dist/lib/extractor/web-extractor.js +6 -6
- package/dist/lib/logger.js +2 -2
- package/dist/lib/node/fs.js +6 -6
- package/dist/lib/utils.js +2 -2
- package/dist/types/common.d.ts +5 -5
- package/dist/types/constants/example-code.d.ts +2 -2
- package/dist/types/env/types.d.ts +180 -180
- package/dist/types/extractor/util.d.ts +2 -2
- package/dist/types/node/fs.d.ts +1 -1
- package/package.json +8 -3
- package/src/common.ts +10 -10
- package/src/constants/example-code.ts +10 -10
- package/src/constants/index.ts +1 -1
- package/src/env/constants.ts +144 -144
- package/src/env/decide-model-config.ts +1 -1
- package/src/env/global-config-manager.ts +1 -1
- package/src/env/init-debug.ts +5 -5
- package/src/env/model-config-manager.ts +1 -1
- package/src/env/parse.ts +15 -15
- package/src/env/types.ts +315 -315
- package/src/env/utils.ts +2 -2
- package/src/extractor/debug.ts +2 -2
- package/src/extractor/util.ts +15 -15
- package/src/extractor/web-extractor.ts +7 -7
- package/src/logger.ts +3 -3
- package/src/node/fs.ts +5 -5
- package/src/utils.ts +2 -2
package/dist/lib/common.js
CHANGED
|
@@ -35,9 +35,9 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
35
35
|
__webpack_require__.d(__webpack_exports__, {
|
|
36
36
|
defaultRunDirName: ()=>defaultRunDirName,
|
|
37
37
|
ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED: ()=>ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
getMidsceneRunDir: ()=>getMidsceneRunDir,
|
|
39
|
+
getMidsceneRunSubDir: ()=>getMidsceneRunSubDir,
|
|
40
|
+
getMidsceneRunBaseDir: ()=>getMidsceneRunBaseDir
|
|
41
41
|
});
|
|
42
42
|
const external_node_fs_namespaceObject = require("node:fs");
|
|
43
43
|
const external_node_os_namespaceObject = require("node:os");
|
|
@@ -46,14 +46,14 @@ var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_no
|
|
|
46
46
|
const basic_js_namespaceObject = require("./env/basic.js");
|
|
47
47
|
const types_js_namespaceObject = require("./env/types.js");
|
|
48
48
|
const external_utils_js_namespaceObject = require("./utils.js");
|
|
49
|
-
const defaultRunDirName = '
|
|
50
|
-
const
|
|
49
|
+
const defaultRunDirName = 'midscene_run';
|
|
50
|
+
const getMidsceneRunDir = ()=>{
|
|
51
51
|
if (!external_utils_js_namespaceObject.ifInNode) return '';
|
|
52
|
-
return (0, basic_js_namespaceObject.getBasicEnvValue)(types_js_namespaceObject.
|
|
52
|
+
return (0, basic_js_namespaceObject.getBasicEnvValue)(types_js_namespaceObject.MIDSCENE_RUN_DIR) || defaultRunDirName;
|
|
53
53
|
};
|
|
54
|
-
const
|
|
54
|
+
const getMidsceneRunBaseDir = ()=>{
|
|
55
55
|
if (!external_utils_js_namespaceObject.ifInNode) return '';
|
|
56
|
-
let basePath = external_node_path_default().resolve(process.cwd(),
|
|
56
|
+
let basePath = external_node_path_default().resolve(process.cwd(), getMidsceneRunDir());
|
|
57
57
|
if (!(0, external_node_fs_namespaceObject.existsSync)(basePath)) try {
|
|
58
58
|
(0, external_node_fs_namespaceObject.mkdirSync)(basePath, {
|
|
59
59
|
recursive: true
|
|
@@ -66,9 +66,9 @@ const getRpasceneRunBaseDir = ()=>{
|
|
|
66
66
|
}
|
|
67
67
|
return basePath;
|
|
68
68
|
};
|
|
69
|
-
const
|
|
69
|
+
const getMidsceneRunSubDir = (subdir)=>{
|
|
70
70
|
if (!external_utils_js_namespaceObject.ifInNode) return '';
|
|
71
|
-
const basePath =
|
|
71
|
+
const basePath = getMidsceneRunBaseDir();
|
|
72
72
|
const logPath = external_node_path_default().join(basePath, subdir);
|
|
73
73
|
if (!(0, external_node_fs_namespaceObject.existsSync)(logPath)) (0, external_node_fs_namespaceObject.mkdirSync)(logPath, {
|
|
74
74
|
recursive: true
|
|
@@ -78,15 +78,15 @@ const getRpasceneRunSubDir = (subdir)=>{
|
|
|
78
78
|
const ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED = 'NOT_IMPLEMENTED_AS_DESIGNED';
|
|
79
79
|
exports.ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED = __webpack_exports__.ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED;
|
|
80
80
|
exports.defaultRunDirName = __webpack_exports__.defaultRunDirName;
|
|
81
|
-
exports.
|
|
82
|
-
exports.
|
|
83
|
-
exports.
|
|
81
|
+
exports.getMidsceneRunBaseDir = __webpack_exports__.getMidsceneRunBaseDir;
|
|
82
|
+
exports.getMidsceneRunDir = __webpack_exports__.getMidsceneRunDir;
|
|
83
|
+
exports.getMidsceneRunSubDir = __webpack_exports__.getMidsceneRunSubDir;
|
|
84
84
|
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
85
85
|
"ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED",
|
|
86
86
|
"defaultRunDirName",
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
87
|
+
"getMidsceneRunBaseDir",
|
|
88
|
+
"getMidsceneRunDir",
|
|
89
|
+
"getMidsceneRunSubDir"
|
|
90
90
|
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
91
91
|
Object.defineProperty(exports, '__esModule', {
|
|
92
92
|
value: true
|
|
@@ -28,8 +28,8 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
28
28
|
YAML_EXAMPLE_CODE: ()=>YAML_EXAMPLE_CODE
|
|
29
29
|
});
|
|
30
30
|
const PLAYWRIGHT_EXAMPLE_CODE = `
|
|
31
|
-
// Reference the following code to generate
|
|
32
|
-
// The following is test code for
|
|
31
|
+
// Reference the following code to generate Midscene test cases
|
|
32
|
+
// The following is test code for Midscene AI, for reference
|
|
33
33
|
// The following is Playwright syntax, you can use Playwright to assist in test generation
|
|
34
34
|
IMPORTANT: Follow these exact type signatures for AI functions:
|
|
35
35
|
|
|
@@ -46,8 +46,8 @@ aiAssert(assertion: string): Promise<void>
|
|
|
46
46
|
aiQuery<T>(queryObject: Record<string, string>): Promise<T> // Extracts data from page based on descriptions
|
|
47
47
|
|
|
48
48
|
// examples:
|
|
49
|
-
// Reference the following code to generate
|
|
50
|
-
// The following is test code for
|
|
49
|
+
// Reference the following code to generate Midscene test cases
|
|
50
|
+
// The following is test code for Midscene AI, for reference
|
|
51
51
|
// The following is Playwright syntax, you can use Playwright to assist in test generation
|
|
52
52
|
import { test as base } from '@playwright/test';
|
|
53
53
|
import type { PlayWrightAiFixtureType } from '@rpascene/web/playwright';
|
|
@@ -156,33 +156,33 @@ tasks:
|
|
|
156
156
|
# Tap an element described by a prompt.
|
|
157
157
|
- aiTap: <prompt>
|
|
158
158
|
deepThink: <boolean> # Optional, whether to use deepThink to precisely locate the element. Defaults to False.
|
|
159
|
-
xpath: <xpath> # Optional, the xpath of the target element for the operation. If provided,
|
|
159
|
+
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.
|
|
160
160
|
cacheable: <boolean> # Optional, whether to cache the result of this API call when the [caching feature](./caching.mdx) is enabled. Defaults to True.
|
|
161
161
|
|
|
162
162
|
# Double click an element described by a prompt.
|
|
163
163
|
- aiDoubleClick: <prompt>
|
|
164
164
|
deepThink: <boolean> # Optional, whether to use deepThink to precisely locate the element. Defaults to False.
|
|
165
|
-
xpath: <xpath> # Optional, the xpath of the target element for the operation. If provided,
|
|
165
|
+
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.
|
|
166
166
|
cacheable: <boolean> # Optional, whether to cache the result of this API call when the [caching feature](./caching.mdx) is enabled. Defaults to True.
|
|
167
167
|
|
|
168
168
|
# Hover over an element described by a prompt.
|
|
169
169
|
- aiHover: <prompt>
|
|
170
170
|
deepThink: <boolean> # Optional, whether to use deepThink to precisely locate the element. Defaults to False.
|
|
171
|
-
xpath: <xpath> # Optional, the xpath of the target element for the operation. If provided,
|
|
171
|
+
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.
|
|
172
172
|
cacheable: <boolean> # Optional, whether to cache the result of this API call when the [caching feature](./caching.mdx) is enabled. Defaults to True.
|
|
173
173
|
|
|
174
174
|
# Input text into an element described by a prompt.
|
|
175
175
|
- aiInput: <final text content of the input>
|
|
176
176
|
locate: <prompt>
|
|
177
177
|
deepThink: <boolean> # Optional, whether to use deepThink to precisely locate the element. Defaults to False.
|
|
178
|
-
xpath: <xpath> # Optional, the xpath of the target element for the operation. If provided,
|
|
178
|
+
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.
|
|
179
179
|
cacheable: <boolean> # Optional, whether to cache the result of this API call when the [caching feature](./caching.mdx) is enabled. Defaults to True.
|
|
180
180
|
|
|
181
181
|
# Press a key (e.g., Enter, Tab, Escape) on an element described by a prompt.
|
|
182
182
|
- aiKeyboardPress: <key>
|
|
183
183
|
locate: <prompt>
|
|
184
184
|
deepThink: <boolean> # Optional, whether to use deepThink to precisely locate the element. Defaults to False.
|
|
185
|
-
xpath: <xpath> # Optional, the xpath of the target element for the operation. If provided,
|
|
185
|
+
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.
|
|
186
186
|
cacheable: <boolean> # Optional, whether to cache the result of this API call when the [caching feature](./caching.mdx) is enabled. Defaults to True.
|
|
187
187
|
|
|
188
188
|
# Scroll globally or on an element described by a prompt.
|
|
@@ -192,7 +192,7 @@ tasks:
|
|
|
192
192
|
distance: <number> # Optional, the scroll distance in pixels.
|
|
193
193
|
locate: <prompt> # Optional, the element to scroll on.
|
|
194
194
|
deepThink: <boolean> # Optional, whether to use deepThink to precisely locate the element. Defaults to False.
|
|
195
|
-
xpath: <xpath> # Optional, the xpath of the target element for the operation. If provided,
|
|
195
|
+
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.
|
|
196
196
|
cacheable: <boolean> # Optional, whether to cache the result of this API call when the [caching feature](./caching.mdx) is enabled. Defaults to True.
|
|
197
197
|
|
|
198
198
|
# Log the current screenshot with a description in the report file.
|
|
@@ -32,97 +32,97 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
32
32
|
});
|
|
33
33
|
const external_types_js_namespaceObject = require("./types.js");
|
|
34
34
|
const VQA_MODEL_CONFIG_KEYS = {
|
|
35
|
-
modelName: external_types_js_namespaceObject.
|
|
36
|
-
socksProxy: external_types_js_namespaceObject.
|
|
37
|
-
httpProxy: external_types_js_namespaceObject.
|
|
38
|
-
openaiBaseURL: external_types_js_namespaceObject.
|
|
39
|
-
openaiApiKey: external_types_js_namespaceObject.
|
|
40
|
-
openaiExtraConfig: external_types_js_namespaceObject.
|
|
41
|
-
openaiUseAzureDeprecated: external_types_js_namespaceObject.
|
|
42
|
-
useAzureOpenai: external_types_js_namespaceObject.
|
|
43
|
-
azureOpenaiScope: external_types_js_namespaceObject.
|
|
44
|
-
azureOpenaiKey: external_types_js_namespaceObject.
|
|
45
|
-
azureOpenaiEndpoint: external_types_js_namespaceObject.
|
|
46
|
-
azureOpenaiApiVersion: external_types_js_namespaceObject.
|
|
47
|
-
azureOpenaiDeployment: external_types_js_namespaceObject.
|
|
48
|
-
azureExtraConfig: external_types_js_namespaceObject.
|
|
49
|
-
useAnthropicSdk: external_types_js_namespaceObject.
|
|
50
|
-
anthropicApiKey: external_types_js_namespaceObject.
|
|
51
|
-
vlMode: external_types_js_namespaceObject.
|
|
35
|
+
modelName: external_types_js_namespaceObject.MIDSCENE_VQA_MODEL_NAME,
|
|
36
|
+
socksProxy: external_types_js_namespaceObject.MIDSCENE_VQA_OPENAI_SOCKS_PROXY,
|
|
37
|
+
httpProxy: external_types_js_namespaceObject.MIDSCENE_VQA_OPENAI_HTTP_PROXY,
|
|
38
|
+
openaiBaseURL: external_types_js_namespaceObject.MIDSCENE_VQA_OPENAI_BASE_URL,
|
|
39
|
+
openaiApiKey: external_types_js_namespaceObject.MIDSCENE_VQA_OPENAI_API_KEY,
|
|
40
|
+
openaiExtraConfig: external_types_js_namespaceObject.MIDSCENE_VQA_OPENAI_INIT_CONFIG_JSON,
|
|
41
|
+
openaiUseAzureDeprecated: external_types_js_namespaceObject.MIDSCENE_VQA_OPENAI_USE_AZURE,
|
|
42
|
+
useAzureOpenai: external_types_js_namespaceObject.MIDSCENE_VQA_USE_AZURE_OPENAI,
|
|
43
|
+
azureOpenaiScope: external_types_js_namespaceObject.MIDSCENE_VQA_AZURE_OPENAI_SCOPE,
|
|
44
|
+
azureOpenaiKey: external_types_js_namespaceObject.MIDSCENE_VQA_AZURE_OPENAI_KEY,
|
|
45
|
+
azureOpenaiEndpoint: external_types_js_namespaceObject.MIDSCENE_VQA_AZURE_OPENAI_ENDPOINT,
|
|
46
|
+
azureOpenaiApiVersion: external_types_js_namespaceObject.MIDSCENE_VQA_AZURE_OPENAI_API_VERSION,
|
|
47
|
+
azureOpenaiDeployment: external_types_js_namespaceObject.MIDSCENE_VQA_AZURE_OPENAI_DEPLOYMENT,
|
|
48
|
+
azureExtraConfig: external_types_js_namespaceObject.MIDSCENE_VQA_AZURE_OPENAI_INIT_CONFIG_JSON,
|
|
49
|
+
useAnthropicSdk: external_types_js_namespaceObject.MIDSCENE_VQA_USE_ANTHROPIC_SDK,
|
|
50
|
+
anthropicApiKey: external_types_js_namespaceObject.MIDSCENE_VQA_ANTHROPIC_API_KEY,
|
|
51
|
+
vlMode: external_types_js_namespaceObject.MIDSCENE_VQA_VL_MODE
|
|
52
52
|
};
|
|
53
53
|
const GROUNDING_MODEL_CONFIG_KEYS = {
|
|
54
|
-
modelName: external_types_js_namespaceObject.
|
|
55
|
-
socksProxy: external_types_js_namespaceObject.
|
|
56
|
-
httpProxy: external_types_js_namespaceObject.
|
|
57
|
-
openaiBaseURL: external_types_js_namespaceObject.
|
|
58
|
-
openaiApiKey: external_types_js_namespaceObject.
|
|
59
|
-
openaiExtraConfig: external_types_js_namespaceObject.
|
|
60
|
-
openaiUseAzureDeprecated: external_types_js_namespaceObject.
|
|
61
|
-
useAzureOpenai: external_types_js_namespaceObject.
|
|
62
|
-
azureOpenaiScope: external_types_js_namespaceObject.
|
|
63
|
-
azureOpenaiKey: external_types_js_namespaceObject.
|
|
64
|
-
azureOpenaiEndpoint: external_types_js_namespaceObject.
|
|
65
|
-
azureOpenaiApiVersion: external_types_js_namespaceObject.
|
|
66
|
-
azureOpenaiDeployment: external_types_js_namespaceObject.
|
|
67
|
-
azureExtraConfig: external_types_js_namespaceObject.
|
|
68
|
-
useAnthropicSdk: external_types_js_namespaceObject.
|
|
69
|
-
anthropicApiKey: external_types_js_namespaceObject.
|
|
70
|
-
vlMode: external_types_js_namespaceObject.
|
|
54
|
+
modelName: external_types_js_namespaceObject.MIDSCENE_GROUNDING_MODEL_NAME,
|
|
55
|
+
socksProxy: external_types_js_namespaceObject.MIDSCENE_GROUNDING_OPENAI_SOCKS_PROXY,
|
|
56
|
+
httpProxy: external_types_js_namespaceObject.MIDSCENE_GROUNDING_OPENAI_HTTP_PROXY,
|
|
57
|
+
openaiBaseURL: external_types_js_namespaceObject.MIDSCENE_GROUNDING_OPENAI_BASE_URL,
|
|
58
|
+
openaiApiKey: external_types_js_namespaceObject.MIDSCENE_GROUNDING_OPENAI_API_KEY,
|
|
59
|
+
openaiExtraConfig: external_types_js_namespaceObject.MIDSCENE_GROUNDING_OPENAI_INIT_CONFIG_JSON,
|
|
60
|
+
openaiUseAzureDeprecated: external_types_js_namespaceObject.MIDSCENE_GROUNDING_OPENAI_USE_AZURE,
|
|
61
|
+
useAzureOpenai: external_types_js_namespaceObject.MIDSCENE_GROUNDING_USE_AZURE_OPENAI,
|
|
62
|
+
azureOpenaiScope: external_types_js_namespaceObject.MIDSCENE_GROUNDING_AZURE_OPENAI_SCOPE,
|
|
63
|
+
azureOpenaiKey: external_types_js_namespaceObject.MIDSCENE_GROUNDING_AZURE_OPENAI_KEY,
|
|
64
|
+
azureOpenaiEndpoint: external_types_js_namespaceObject.MIDSCENE_GROUNDING_AZURE_OPENAI_ENDPOINT,
|
|
65
|
+
azureOpenaiApiVersion: external_types_js_namespaceObject.MIDSCENE_GROUNDING_AZURE_OPENAI_API_VERSION,
|
|
66
|
+
azureOpenaiDeployment: external_types_js_namespaceObject.MIDSCENE_GROUNDING_AZURE_OPENAI_DEPLOYMENT,
|
|
67
|
+
azureExtraConfig: external_types_js_namespaceObject.MIDSCENE_GROUNDING_AZURE_OPENAI_INIT_CONFIG_JSON,
|
|
68
|
+
useAnthropicSdk: external_types_js_namespaceObject.MIDSCENE_GROUNDING_USE_ANTHROPIC_SDK,
|
|
69
|
+
anthropicApiKey: external_types_js_namespaceObject.MIDSCENE_GROUNDING_ANTHROPIC_API_KEY,
|
|
70
|
+
vlMode: external_types_js_namespaceObject.MIDSCENE_GROUNDING_VL_MODE
|
|
71
71
|
};
|
|
72
72
|
const PLANNING_MODEL_CONFIG_KEYS = {
|
|
73
|
-
modelName: external_types_js_namespaceObject.
|
|
74
|
-
socksProxy: external_types_js_namespaceObject.
|
|
75
|
-
httpProxy: external_types_js_namespaceObject.
|
|
76
|
-
openaiBaseURL: external_types_js_namespaceObject.
|
|
77
|
-
openaiApiKey: external_types_js_namespaceObject.
|
|
78
|
-
openaiExtraConfig: external_types_js_namespaceObject.
|
|
79
|
-
openaiUseAzureDeprecated: external_types_js_namespaceObject.
|
|
80
|
-
useAzureOpenai: external_types_js_namespaceObject.
|
|
81
|
-
azureOpenaiScope: external_types_js_namespaceObject.
|
|
82
|
-
azureOpenaiKey: external_types_js_namespaceObject.
|
|
83
|
-
azureOpenaiEndpoint: external_types_js_namespaceObject.
|
|
84
|
-
azureOpenaiApiVersion: external_types_js_namespaceObject.
|
|
85
|
-
azureOpenaiDeployment: external_types_js_namespaceObject.
|
|
86
|
-
azureExtraConfig: external_types_js_namespaceObject.
|
|
87
|
-
useAnthropicSdk: external_types_js_namespaceObject.
|
|
88
|
-
anthropicApiKey: external_types_js_namespaceObject.
|
|
89
|
-
vlMode: external_types_js_namespaceObject.
|
|
73
|
+
modelName: external_types_js_namespaceObject.MIDSCENE_PLANNING_MODEL_NAME,
|
|
74
|
+
socksProxy: external_types_js_namespaceObject.MIDSCENE_PLANNING_OPENAI_SOCKS_PROXY,
|
|
75
|
+
httpProxy: external_types_js_namespaceObject.MIDSCENE_PLANNING_OPENAI_HTTP_PROXY,
|
|
76
|
+
openaiBaseURL: external_types_js_namespaceObject.MIDSCENE_PLANNING_OPENAI_BASE_URL,
|
|
77
|
+
openaiApiKey: external_types_js_namespaceObject.MIDSCENE_PLANNING_OPENAI_API_KEY,
|
|
78
|
+
openaiExtraConfig: external_types_js_namespaceObject.MIDSCENE_PLANNING_OPENAI_INIT_CONFIG_JSON,
|
|
79
|
+
openaiUseAzureDeprecated: external_types_js_namespaceObject.MIDSCENE_PLANNING_OPENAI_USE_AZURE,
|
|
80
|
+
useAzureOpenai: external_types_js_namespaceObject.MIDSCENE_PLANNING_USE_AZURE_OPENAI,
|
|
81
|
+
azureOpenaiScope: external_types_js_namespaceObject.MIDSCENE_PLANNING_AZURE_OPENAI_SCOPE,
|
|
82
|
+
azureOpenaiKey: external_types_js_namespaceObject.MIDSCENE_PLANNING_AZURE_OPENAI_KEY,
|
|
83
|
+
azureOpenaiEndpoint: external_types_js_namespaceObject.MIDSCENE_PLANNING_AZURE_OPENAI_ENDPOINT,
|
|
84
|
+
azureOpenaiApiVersion: external_types_js_namespaceObject.MIDSCENE_PLANNING_AZURE_OPENAI_API_VERSION,
|
|
85
|
+
azureOpenaiDeployment: external_types_js_namespaceObject.MIDSCENE_PLANNING_AZURE_OPENAI_DEPLOYMENT,
|
|
86
|
+
azureExtraConfig: external_types_js_namespaceObject.MIDSCENE_PLANNING_AZURE_OPENAI_INIT_CONFIG_JSON,
|
|
87
|
+
useAnthropicSdk: external_types_js_namespaceObject.MIDSCENE_PLANNING_USE_ANTHROPIC_SDK,
|
|
88
|
+
anthropicApiKey: external_types_js_namespaceObject.MIDSCENE_PLANNING_ANTHROPIC_API_KEY,
|
|
89
|
+
vlMode: external_types_js_namespaceObject.MIDSCENE_PLANNING_VL_MODE
|
|
90
90
|
};
|
|
91
91
|
const DEFAULT_MODEL_CONFIG_KEYS = {
|
|
92
|
-
modelName: external_types_js_namespaceObject.
|
|
93
|
-
socksProxy: external_types_js_namespaceObject.
|
|
94
|
-
httpProxy: external_types_js_namespaceObject.
|
|
95
|
-
openaiBaseURL: external_types_js_namespaceObject.
|
|
96
|
-
openaiApiKey: external_types_js_namespaceObject.
|
|
97
|
-
openaiExtraConfig: external_types_js_namespaceObject.
|
|
98
|
-
openaiUseAzureDeprecated: external_types_js_namespaceObject.
|
|
99
|
-
useAzureOpenai: external_types_js_namespaceObject.
|
|
100
|
-
azureOpenaiScope: external_types_js_namespaceObject.
|
|
101
|
-
azureOpenaiKey: external_types_js_namespaceObject.
|
|
102
|
-
azureOpenaiEndpoint: external_types_js_namespaceObject.
|
|
103
|
-
azureOpenaiApiVersion: external_types_js_namespaceObject.
|
|
104
|
-
azureOpenaiDeployment: external_types_js_namespaceObject.
|
|
105
|
-
azureExtraConfig: external_types_js_namespaceObject.
|
|
106
|
-
useAnthropicSdk: external_types_js_namespaceObject.
|
|
107
|
-
anthropicApiKey: external_types_js_namespaceObject.
|
|
108
|
-
vlMode: external_types_js_namespaceObject.
|
|
92
|
+
modelName: external_types_js_namespaceObject.MIDSCENE_MODEL_NAME,
|
|
93
|
+
socksProxy: external_types_js_namespaceObject.MIDSCENE_OPENAI_SOCKS_PROXY,
|
|
94
|
+
httpProxy: external_types_js_namespaceObject.MIDSCENE_OPENAI_HTTP_PROXY,
|
|
95
|
+
openaiBaseURL: external_types_js_namespaceObject.MIDSCENE_OPENAI_BASE_URL,
|
|
96
|
+
openaiApiKey: external_types_js_namespaceObject.MIDSCENE_OPENAI_API_KEY,
|
|
97
|
+
openaiExtraConfig: external_types_js_namespaceObject.MIDSCENE_OPENAI_INIT_CONFIG_JSON,
|
|
98
|
+
openaiUseAzureDeprecated: external_types_js_namespaceObject.MIDSCENE_OPENAI_USE_AZURE,
|
|
99
|
+
useAzureOpenai: external_types_js_namespaceObject.MIDSCENE_USE_AZURE_OPENAI,
|
|
100
|
+
azureOpenaiScope: external_types_js_namespaceObject.MIDSCENE_AZURE_OPENAI_SCOPE,
|
|
101
|
+
azureOpenaiKey: external_types_js_namespaceObject.MIDSCENE_AZURE_OPENAI_KEY,
|
|
102
|
+
azureOpenaiEndpoint: external_types_js_namespaceObject.MIDSCENE_AZURE_OPENAI_ENDPOINT,
|
|
103
|
+
azureOpenaiApiVersion: external_types_js_namespaceObject.MIDSCENE_AZURE_OPENAI_API_VERSION,
|
|
104
|
+
azureOpenaiDeployment: external_types_js_namespaceObject.MIDSCENE_AZURE_OPENAI_DEPLOYMENT,
|
|
105
|
+
azureExtraConfig: external_types_js_namespaceObject.MIDSCENE_AZURE_OPENAI_INIT_CONFIG_JSON,
|
|
106
|
+
useAnthropicSdk: external_types_js_namespaceObject.MIDSCENE_USE_ANTHROPIC_SDK,
|
|
107
|
+
anthropicApiKey: external_types_js_namespaceObject.MIDSCENE_ANTHROPIC_API_KEY,
|
|
108
|
+
vlMode: external_types_js_namespaceObject.MIDSCENE_VL_MODE
|
|
109
109
|
};
|
|
110
110
|
const DEFAULT_MODEL_CONFIG_KEYS_LEGACY = {
|
|
111
|
-
modelName: external_types_js_namespaceObject.
|
|
112
|
-
socksProxy: external_types_js_namespaceObject.
|
|
113
|
-
httpProxy: external_types_js_namespaceObject.
|
|
111
|
+
modelName: external_types_js_namespaceObject.MIDSCENE_MODEL_NAME,
|
|
112
|
+
socksProxy: external_types_js_namespaceObject.MIDSCENE_OPENAI_SOCKS_PROXY,
|
|
113
|
+
httpProxy: external_types_js_namespaceObject.MIDSCENE_OPENAI_HTTP_PROXY,
|
|
114
114
|
openaiBaseURL: external_types_js_namespaceObject.OPENAI_BASE_URL,
|
|
115
115
|
openaiApiKey: external_types_js_namespaceObject.OPENAI_API_KEY,
|
|
116
|
-
openaiExtraConfig: external_types_js_namespaceObject.
|
|
116
|
+
openaiExtraConfig: external_types_js_namespaceObject.MIDSCENE_OPENAI_INIT_CONFIG_JSON,
|
|
117
117
|
openaiUseAzureDeprecated: external_types_js_namespaceObject.OPENAI_USE_AZURE,
|
|
118
|
-
useAzureOpenai: external_types_js_namespaceObject.
|
|
119
|
-
azureOpenaiScope: external_types_js_namespaceObject.
|
|
118
|
+
useAzureOpenai: external_types_js_namespaceObject.MIDSCENE_USE_AZURE_OPENAI,
|
|
119
|
+
azureOpenaiScope: external_types_js_namespaceObject.MIDSCENE_AZURE_OPENAI_SCOPE,
|
|
120
120
|
azureOpenaiKey: external_types_js_namespaceObject.AZURE_OPENAI_KEY,
|
|
121
121
|
azureOpenaiEndpoint: external_types_js_namespaceObject.AZURE_OPENAI_ENDPOINT,
|
|
122
122
|
azureOpenaiApiVersion: external_types_js_namespaceObject.AZURE_OPENAI_API_VERSION,
|
|
123
123
|
azureOpenaiDeployment: external_types_js_namespaceObject.AZURE_OPENAI_DEPLOYMENT,
|
|
124
|
-
azureExtraConfig: external_types_js_namespaceObject.
|
|
125
|
-
useAnthropicSdk: external_types_js_namespaceObject.
|
|
124
|
+
azureExtraConfig: external_types_js_namespaceObject.MIDSCENE_AZURE_OPENAI_INIT_CONFIG_JSON,
|
|
125
|
+
useAnthropicSdk: external_types_js_namespaceObject.MIDSCENE_USE_ANTHROPIC_SDK,
|
|
126
126
|
anthropicApiKey: external_types_js_namespaceObject.ANTHROPIC_API_KEY,
|
|
127
127
|
vlMode: 'DEFAULT_MODEL_CONFIG_KEYS has no vlMode key'
|
|
128
128
|
};
|
|
@@ -59,7 +59,7 @@ class GlobalConfigManager {
|
|
|
59
59
|
getEnvConfigValue(key) {
|
|
60
60
|
const allConfig = this.getAllEnvConfig();
|
|
61
61
|
if (!external_types_js_namespaceObject.STRING_ENV_KEYS.includes(key)) throw new Error(`getEnvConfigValue with key ${key} is not supported.`);
|
|
62
|
-
if (key === external_types_js_namespaceObject.MATCH_BY_POSITION) throw new Error('MATCH_BY_POSITION is deprecated, use
|
|
62
|
+
if (key === external_types_js_namespaceObject.MATCH_BY_POSITION) throw new Error('MATCH_BY_POSITION is deprecated, use MIDSCENE_USE_VL_MODEL instead');
|
|
63
63
|
const value = allConfig[key];
|
|
64
64
|
this.keysHaveBeenRead[key] = true;
|
|
65
65
|
if ('string' == typeof value) return value.trim();
|
|
@@ -30,15 +30,15 @@ const external_logger_js_namespaceObject = require("../logger.js");
|
|
|
30
30
|
const external_basic_js_namespaceObject = require("./basic.js");
|
|
31
31
|
const external_types_js_namespaceObject = require("./types.js");
|
|
32
32
|
const initDebugConfig = ()=>{
|
|
33
|
-
const shouldPrintTiming = (0, external_basic_js_namespaceObject.getBasicEnvValue)(external_types_js_namespaceObject.
|
|
33
|
+
const shouldPrintTiming = (0, external_basic_js_namespaceObject.getBasicEnvValue)(external_types_js_namespaceObject.MIDSCENE_DEBUG_AI_PROFILE);
|
|
34
34
|
let debugConfig = '';
|
|
35
35
|
if (shouldPrintTiming) {
|
|
36
|
-
console.warn('
|
|
36
|
+
console.warn('MIDSCENE_DEBUG_AI_PROFILE is deprecated, use DEBUG=midscene:ai:profile instead');
|
|
37
37
|
debugConfig = 'ai:profile';
|
|
38
38
|
}
|
|
39
|
-
const shouldPrintAIResponse = (0, external_basic_js_namespaceObject.getBasicEnvValue)(external_types_js_namespaceObject.
|
|
39
|
+
const shouldPrintAIResponse = (0, external_basic_js_namespaceObject.getBasicEnvValue)(external_types_js_namespaceObject.MIDSCENE_DEBUG_AI_RESPONSE);
|
|
40
40
|
if (shouldPrintAIResponse) {
|
|
41
|
-
console.warn('
|
|
41
|
+
console.warn('MIDSCENE_DEBUG_AI_RESPONSE is deprecated, use DEBUG=midscene:ai:response instead');
|
|
42
42
|
debugConfig = debugConfig ? 'ai:*' : 'ai:call';
|
|
43
43
|
}
|
|
44
44
|
if (debugConfig) (0, external_logger_js_namespaceObject.enableDebug)(debugConfig);
|
|
@@ -111,7 +111,7 @@ class ModelConfigManager {
|
|
|
111
111
|
}
|
|
112
112
|
throwErrorIfNonVLModel(intent = 'grounding') {
|
|
113
113
|
const modelConfig = this.getModelConfig(intent);
|
|
114
|
-
if (!modelConfig.vlMode) throw new Error('No visual language model (VL model) detected for the current scenario. Element localization may be inaccurate. Please verify your model configuration. Learn more: https://
|
|
114
|
+
if (!modelConfig.vlMode) throw new Error('No visual language model (VL model) detected for the current scenario. Element localization may be inaccurate. Please verify your model configuration. Learn more: https://midscenejs.com/choose-a-model');
|
|
115
115
|
}
|
|
116
116
|
constructor(modelConfigFn){
|
|
117
117
|
_define_property(this, "modelConfigMap", void 0);
|
package/dist/lib/env/parse.js
CHANGED
|
@@ -49,17 +49,17 @@ const parseVlModeAndUiTarsModelVersionFromRawValue = (vlModeRaw)=>{
|
|
|
49
49
|
};
|
|
50
50
|
};
|
|
51
51
|
const parseVlModeAndUiTarsFromGlobalConfig = (provider)=>{
|
|
52
|
-
const isDoubao = provider[external_types_js_namespaceObject.
|
|
53
|
-
const isQwen = provider[external_types_js_namespaceObject.
|
|
54
|
-
const isQwen3 = provider[external_types_js_namespaceObject.
|
|
55
|
-
const isUiTars = provider[external_types_js_namespaceObject.
|
|
56
|
-
const isGemini = provider[external_types_js_namespaceObject.
|
|
52
|
+
const isDoubao = provider[external_types_js_namespaceObject.MIDSCENE_USE_DOUBAO_VISION];
|
|
53
|
+
const isQwen = provider[external_types_js_namespaceObject.MIDSCENE_USE_QWEN_VL];
|
|
54
|
+
const isQwen3 = provider[external_types_js_namespaceObject.MIDSCENE_USE_QWEN3_VL];
|
|
55
|
+
const isUiTars = provider[external_types_js_namespaceObject.MIDSCENE_USE_VLM_UI_TARS];
|
|
56
|
+
const isGemini = provider[external_types_js_namespaceObject.MIDSCENE_USE_GEMINI];
|
|
57
57
|
const enabledModes = [
|
|
58
|
-
isDoubao && external_types_js_namespaceObject.
|
|
59
|
-
isQwen && external_types_js_namespaceObject.
|
|
60
|
-
isQwen3 && external_types_js_namespaceObject.
|
|
61
|
-
isUiTars && external_types_js_namespaceObject.
|
|
62
|
-
isGemini && external_types_js_namespaceObject.
|
|
58
|
+
isDoubao && external_types_js_namespaceObject.MIDSCENE_USE_DOUBAO_VISION,
|
|
59
|
+
isQwen && external_types_js_namespaceObject.MIDSCENE_USE_QWEN_VL,
|
|
60
|
+
isQwen3 && external_types_js_namespaceObject.MIDSCENE_USE_QWEN3_VL,
|
|
61
|
+
isUiTars && external_types_js_namespaceObject.MIDSCENE_USE_VLM_UI_TARS,
|
|
62
|
+
isGemini && external_types_js_namespaceObject.MIDSCENE_USE_GEMINI
|
|
63
63
|
].filter(Boolean);
|
|
64
64
|
if (enabledModes.length > 1) throw new Error(`Only one vision mode can be enabled at a time. Currently enabled modes: ${enabledModes.join(', ')}. Please disable all but one mode.`);
|
|
65
65
|
if (isQwen3) return {
|