@midscene/shared 1.0.1-beta-20251022061922.0 → 1.0.1-beta-20251024063839.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/env/constants.mjs +28 -28
- package/dist/es/env/decide-model-config.mjs +5 -2
- package/dist/es/env/init-debug.mjs +6 -6
- package/dist/es/env/model-config-manager.mjs +2 -1
- package/dist/es/env/types.mjs +57 -53
- package/dist/lib/env/constants.js +27 -27
- package/dist/lib/env/decide-model-config.js +5 -2
- package/dist/lib/env/init-debug.js +5 -5
- package/dist/lib/env/model-config-manager.js +2 -1
- package/dist/lib/env/types.js +140 -130
- package/dist/types/env/model-config-manager.d.ts +2 -2
- package/dist/types/env/types.d.ts +76 -59
- package/package.json +1 -1
- package/src/env/constants.ts +54 -52
- package/src/env/decide-model-config.ts +20 -2
- package/src/env/init-debug.ts +11 -6
- package/src/env/model-config-manager.ts +9 -3
- package/src/env/types.ts +122 -95
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const MIDSCENE_MODEL_INIT_CONFIG_JSON = "MIDSCENE_MODEL_INIT_CONFIG_JSON";
|
|
2
2
|
export declare const MIDSCENE_MODEL_NAME = "MIDSCENE_MODEL_NAME";
|
|
3
3
|
export declare const MIDSCENE_LANGSMITH_DEBUG = "MIDSCENE_LANGSMITH_DEBUG";
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const
|
|
4
|
+
export declare const MIDSCENE_DEBUG_MODEL_PROFILE = "MIDSCENE_DEBUG_MODEL_PROFILE";
|
|
5
|
+
export declare const MIDSCENE_DEBUG_MODEL_RESPONSE = "MIDSCENE_DEBUG_MODEL_RESPONSE";
|
|
6
6
|
export declare const MIDSCENE_DANGEROUSLY_PRINT_ALL_CONFIG = "MIDSCENE_DANGEROUSLY_PRINT_ALL_CONFIG";
|
|
7
7
|
export declare const MIDSCENE_DEBUG_MODE = "MIDSCENE_DEBUG_MODE";
|
|
8
8
|
export declare const MIDSCENE_MCP_USE_PUPPETEER_MODE = "MIDSCENE_MCP_USE_PUPPETEER_MODE";
|
|
@@ -10,9 +10,17 @@ export declare const MIDSCENE_MCP_CHROME_PATH = "MIDSCENE_MCP_CHROME_PATH";
|
|
|
10
10
|
export declare const MIDSCENE_MCP_ANDROID_MODE = "MIDSCENE_MCP_ANDROID_MODE";
|
|
11
11
|
export declare const DOCKER_CONTAINER = "DOCKER_CONTAINER";
|
|
12
12
|
export declare const MIDSCENE_FORCE_DEEP_THINK = "MIDSCENE_FORCE_DEEP_THINK";
|
|
13
|
-
export declare const
|
|
14
|
-
export declare const
|
|
13
|
+
export declare const MIDSCENE_MODEL_SOCKS_PROXY = "MIDSCENE_MODEL_SOCKS_PROXY";
|
|
14
|
+
export declare const MIDSCENE_MODEL_HTTP_PROXY = "MIDSCENE_MODEL_HTTP_PROXY";
|
|
15
|
+
export declare const MODEL_API_KEY = "MODEL_API_KEY";
|
|
16
|
+
export declare const MODEL_BASE_URL = "MODEL_BASE_URL";
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated Use MODEL_API_KEY instead. This is kept for backward compatibility.
|
|
19
|
+
*/
|
|
15
20
|
export declare const OPENAI_API_KEY = "OPENAI_API_KEY";
|
|
21
|
+
/**
|
|
22
|
+
* @deprecated Use MODEL_BASE_URL instead. This is kept for backward compatibility.
|
|
23
|
+
*/
|
|
16
24
|
export declare const OPENAI_BASE_URL = "OPENAI_BASE_URL";
|
|
17
25
|
export declare const OPENAI_MAX_TOKENS = "OPENAI_MAX_TOKENS";
|
|
18
26
|
export declare const MIDSCENE_ADB_PATH = "MIDSCENE_ADB_PATH";
|
|
@@ -34,30 +42,30 @@ export declare const MIDSCENE_REPLANNING_CYCLE_LIMIT = "MIDSCENE_REPLANNING_CYCL
|
|
|
34
42
|
export declare const MIDSCENE_PREFERRED_LANGUAGE = "MIDSCENE_PREFERRED_LANGUAGE";
|
|
35
43
|
export declare const MIDSCENE_CACHE_MAX_FILENAME_LENGTH = "MIDSCENE_CACHE_MAX_FILENAME_LENGTH";
|
|
36
44
|
export declare const MIDSCENE_RUN_DIR = "MIDSCENE_RUN_DIR";
|
|
37
|
-
export declare const
|
|
38
|
-
export declare const
|
|
39
|
-
export declare const
|
|
45
|
+
export declare const MIDSCENE_MODEL_BASE_URL = "MIDSCENE_MODEL_BASE_URL";
|
|
46
|
+
export declare const MIDSCENE_MODEL_API_KEY = "MIDSCENE_MODEL_API_KEY";
|
|
47
|
+
export declare const MIDSCENE_LOCATOR_MODE = "MIDSCENE_LOCATOR_MODE";
|
|
40
48
|
export declare const MIDSCENE_VQA_MODEL_NAME = "MIDSCENE_VQA_MODEL_NAME";
|
|
41
|
-
export declare const
|
|
42
|
-
export declare const
|
|
43
|
-
export declare const
|
|
44
|
-
export declare const
|
|
45
|
-
export declare const
|
|
46
|
-
export declare const
|
|
49
|
+
export declare const MIDSCENE_VQA_MODEL_SOCKS_PROXY = "MIDSCENE_VQA_MODEL_SOCKS_PROXY";
|
|
50
|
+
export declare const MIDSCENE_VQA_MODEL_HTTP_PROXY = "MIDSCENE_VQA_MODEL_HTTP_PROXY";
|
|
51
|
+
export declare const MIDSCENE_VQA_MODEL_BASE_URL = "MIDSCENE_VQA_MODEL_BASE_URL";
|
|
52
|
+
export declare const MIDSCENE_VQA_MODEL_API_KEY = "MIDSCENE_VQA_MODEL_API_KEY";
|
|
53
|
+
export declare const MIDSCENE_VQA_MODEL_INIT_CONFIG_JSON = "MIDSCENE_VQA_MODEL_INIT_CONFIG_JSON";
|
|
54
|
+
export declare const MIDSCENE_VQA_LOCATOR_MODE = "MIDSCENE_VQA_LOCATOR_MODE";
|
|
47
55
|
export declare const MIDSCENE_PLANNING_MODEL_NAME = "MIDSCENE_PLANNING_MODEL_NAME";
|
|
48
|
-
export declare const
|
|
49
|
-
export declare const
|
|
50
|
-
export declare const
|
|
51
|
-
export declare const
|
|
52
|
-
export declare const
|
|
53
|
-
export declare const
|
|
56
|
+
export declare const MIDSCENE_PLANNING_MODEL_SOCKS_PROXY = "MIDSCENE_PLANNING_MODEL_SOCKS_PROXY";
|
|
57
|
+
export declare const MIDSCENE_PLANNING_MODEL_HTTP_PROXY = "MIDSCENE_PLANNING_MODEL_HTTP_PROXY";
|
|
58
|
+
export declare const MIDSCENE_PLANNING_MODEL_BASE_URL = "MIDSCENE_PLANNING_MODEL_BASE_URL";
|
|
59
|
+
export declare const MIDSCENE_PLANNING_MODEL_API_KEY = "MIDSCENE_PLANNING_MODEL_API_KEY";
|
|
60
|
+
export declare const MIDSCENE_PLANNING_MODEL_INIT_CONFIG_JSON = "MIDSCENE_PLANNING_MODEL_INIT_CONFIG_JSON";
|
|
61
|
+
export declare const MIDSCENE_PLANNING_LOCATOR_MODE = "MIDSCENE_PLANNING_LOCATOR_MODE";
|
|
54
62
|
export declare const MIDSCENE_GROUNDING_MODEL_NAME = "MIDSCENE_GROUNDING_MODEL_NAME";
|
|
55
|
-
export declare const
|
|
56
|
-
export declare const
|
|
57
|
-
export declare const
|
|
58
|
-
export declare const
|
|
59
|
-
export declare const
|
|
60
|
-
export declare const
|
|
63
|
+
export declare const MIDSCENE_GROUNDING_MODEL_SOCKS_PROXY = "MIDSCENE_GROUNDING_MODEL_SOCKS_PROXY";
|
|
64
|
+
export declare const MIDSCENE_GROUNDING_MODEL_HTTP_PROXY = "MIDSCENE_GROUNDING_MODEL_HTTP_PROXY";
|
|
65
|
+
export declare const MIDSCENE_GROUNDING_MODEL_BASE_URL = "MIDSCENE_GROUNDING_MODEL_BASE_URL";
|
|
66
|
+
export declare const MIDSCENE_GROUNDING_MODEL_API_KEY = "MIDSCENE_GROUNDING_MODEL_API_KEY";
|
|
67
|
+
export declare const MIDSCENE_GROUNDING_MODEL_INIT_CONFIG_JSON = "MIDSCENE_GROUNDING_MODEL_INIT_CONFIG_JSON";
|
|
68
|
+
export declare const MIDSCENE_GROUNDING_LOCATOR_MODE = "MIDSCENE_GROUNDING_LOCATOR_MODE";
|
|
61
69
|
/**
|
|
62
70
|
* env keys declared but unused
|
|
63
71
|
*/
|
|
@@ -66,7 +74,7 @@ export declare const UNUSED_ENV_KEYS: string[];
|
|
|
66
74
|
* env keys for debug or basic run
|
|
67
75
|
* can not be override by overrideAIConfig
|
|
68
76
|
*/
|
|
69
|
-
export declare const BASIC_ENV_KEYS: readonly ["MIDSCENE_DEBUG_MODE", "
|
|
77
|
+
export declare const BASIC_ENV_KEYS: readonly ["MIDSCENE_DEBUG_MODE", "MIDSCENE_DEBUG_MODEL_PROFILE", "MIDSCENE_DEBUG_MODEL_RESPONSE", "MIDSCENE_RUN_DIR"];
|
|
70
78
|
export declare const BOOLEAN_ENV_KEYS: readonly ["MIDSCENE_CACHE", "MIDSCENE_LANGSMITH_DEBUG", "MIDSCENE_FORCE_DEEP_THINK", "MIDSCENE_MCP_USE_PUPPETEER_MODE", "MIDSCENE_MCP_ANDROID_MODE"];
|
|
71
79
|
export declare const NUMBER_ENV_KEYS: readonly ["MIDSCENE_CACHE_MAX_FILENAME_LENGTH", "MIDSCENE_REPLANNING_CYCLE_LIMIT"];
|
|
72
80
|
export declare const STRING_ENV_KEYS: readonly ["OPENAI_MAX_TOKENS", "MIDSCENE_ADB_PATH", "MIDSCENE_ADB_REMOTE_HOST", "MIDSCENE_ADB_REMOTE_PORT", "MIDSCENE_ANDROID_IME_STRATEGY", "MIDSCENE_IOS_DEVICE_UDID", "MIDSCENE_IOS_SIMULATOR_UDID", "MIDSCENE_REPORT_TAG_NAME", "MIDSCENE_PREFERRED_LANGUAGE", "MATCH_BY_POSITION", "MIDSCENE_MCP_CHROME_PATH", "DOCKER_CONTAINER"];
|
|
@@ -81,20 +89,20 @@ export declare const GLOBAL_ENV_KEYS: readonly ["MIDSCENE_CACHE", "MIDSCENE_LANG
|
|
|
81
89
|
* Can be override by both agent.modelConfig and overrideAIConfig
|
|
82
90
|
* Can only be access after agent.constructor
|
|
83
91
|
*/
|
|
84
|
-
export declare const MODEL_ENV_KEYS: readonly ["MIDSCENE_MODEL_NAME", "
|
|
85
|
-
export declare const ALL_ENV_KEYS: readonly [...string[], "MIDSCENE_DEBUG_MODE", "
|
|
92
|
+
export declare const MODEL_ENV_KEYS: readonly ["MIDSCENE_MODEL_NAME", "MIDSCENE_MODEL_INIT_CONFIG_JSON", "MIDSCENE_MODEL_API_KEY", "MIDSCENE_MODEL_BASE_URL", "MIDSCENE_MODEL_SOCKS_PROXY", "MIDSCENE_MODEL_HTTP_PROXY", "MIDSCENE_USE_VLM_UI_TARS", "MIDSCENE_USE_QWEN_VL", "MIDSCENE_USE_QWEN3_VL", "MIDSCENE_USE_DOUBAO_VISION", "MIDSCENE_USE_GEMINI", "MIDSCENE_USE_VL_MODEL", "MIDSCENE_LOCATOR_MODE", "OPENAI_API_KEY", "OPENAI_BASE_URL", "MODEL_API_KEY", "MODEL_BASE_URL", "MIDSCENE_VQA_MODEL_NAME", "MIDSCENE_VQA_MODEL_SOCKS_PROXY", "MIDSCENE_VQA_MODEL_HTTP_PROXY", "MIDSCENE_VQA_MODEL_BASE_URL", "MIDSCENE_VQA_MODEL_API_KEY", "MIDSCENE_VQA_MODEL_INIT_CONFIG_JSON", "MIDSCENE_VQA_LOCATOR_MODE", "MIDSCENE_PLANNING_MODEL_NAME", "MIDSCENE_PLANNING_MODEL_SOCKS_PROXY", "MIDSCENE_PLANNING_MODEL_HTTP_PROXY", "MIDSCENE_PLANNING_MODEL_BASE_URL", "MIDSCENE_PLANNING_MODEL_API_KEY", "MIDSCENE_PLANNING_MODEL_INIT_CONFIG_JSON", "MIDSCENE_PLANNING_LOCATOR_MODE", "MIDSCENE_GROUNDING_MODEL_NAME", "MIDSCENE_GROUNDING_MODEL_SOCKS_PROXY", "MIDSCENE_GROUNDING_MODEL_HTTP_PROXY", "MIDSCENE_GROUNDING_MODEL_BASE_URL", "MIDSCENE_GROUNDING_MODEL_API_KEY", "MIDSCENE_GROUNDING_MODEL_INIT_CONFIG_JSON", "MIDSCENE_GROUNDING_LOCATOR_MODE"];
|
|
93
|
+
export declare const ALL_ENV_KEYS: readonly [...string[], "MIDSCENE_DEBUG_MODE", "MIDSCENE_DEBUG_MODEL_PROFILE", "MIDSCENE_DEBUG_MODEL_RESPONSE", "MIDSCENE_RUN_DIR", "MIDSCENE_CACHE", "MIDSCENE_LANGSMITH_DEBUG", "MIDSCENE_FORCE_DEEP_THINK", "MIDSCENE_MCP_USE_PUPPETEER_MODE", "MIDSCENE_MCP_ANDROID_MODE", "MIDSCENE_CACHE_MAX_FILENAME_LENGTH", "MIDSCENE_REPLANNING_CYCLE_LIMIT", "OPENAI_MAX_TOKENS", "MIDSCENE_ADB_PATH", "MIDSCENE_ADB_REMOTE_HOST", "MIDSCENE_ADB_REMOTE_PORT", "MIDSCENE_ANDROID_IME_STRATEGY", "MIDSCENE_IOS_DEVICE_UDID", "MIDSCENE_IOS_SIMULATOR_UDID", "MIDSCENE_REPORT_TAG_NAME", "MIDSCENE_PREFERRED_LANGUAGE", "MATCH_BY_POSITION", "MIDSCENE_MCP_CHROME_PATH", "DOCKER_CONTAINER", "MIDSCENE_MODEL_NAME", "MIDSCENE_MODEL_INIT_CONFIG_JSON", "MIDSCENE_MODEL_API_KEY", "MIDSCENE_MODEL_BASE_URL", "MIDSCENE_MODEL_SOCKS_PROXY", "MIDSCENE_MODEL_HTTP_PROXY", "MIDSCENE_USE_VLM_UI_TARS", "MIDSCENE_USE_QWEN_VL", "MIDSCENE_USE_QWEN3_VL", "MIDSCENE_USE_DOUBAO_VISION", "MIDSCENE_USE_GEMINI", "MIDSCENE_USE_VL_MODEL", "MIDSCENE_LOCATOR_MODE", "OPENAI_API_KEY", "OPENAI_BASE_URL", "MODEL_API_KEY", "MODEL_BASE_URL", "MIDSCENE_VQA_MODEL_NAME", "MIDSCENE_VQA_MODEL_SOCKS_PROXY", "MIDSCENE_VQA_MODEL_HTTP_PROXY", "MIDSCENE_VQA_MODEL_BASE_URL", "MIDSCENE_VQA_MODEL_API_KEY", "MIDSCENE_VQA_MODEL_INIT_CONFIG_JSON", "MIDSCENE_VQA_LOCATOR_MODE", "MIDSCENE_PLANNING_MODEL_NAME", "MIDSCENE_PLANNING_MODEL_SOCKS_PROXY", "MIDSCENE_PLANNING_MODEL_HTTP_PROXY", "MIDSCENE_PLANNING_MODEL_BASE_URL", "MIDSCENE_PLANNING_MODEL_API_KEY", "MIDSCENE_PLANNING_MODEL_INIT_CONFIG_JSON", "MIDSCENE_PLANNING_LOCATOR_MODE", "MIDSCENE_GROUNDING_MODEL_NAME", "MIDSCENE_GROUNDING_MODEL_SOCKS_PROXY", "MIDSCENE_GROUNDING_MODEL_HTTP_PROXY", "MIDSCENE_GROUNDING_MODEL_BASE_URL", "MIDSCENE_GROUNDING_MODEL_API_KEY", "MIDSCENE_GROUNDING_MODEL_INIT_CONFIG_JSON", "MIDSCENE_GROUNDING_LOCATOR_MODE"];
|
|
86
94
|
export type TEnvKeys = (typeof ALL_ENV_KEYS)[number];
|
|
87
95
|
export type TGlobalConfig = Record<TEnvKeys, string | undefined>;
|
|
88
96
|
export type TVlModeValues = 'qwen-vl' | 'qwen3-vl' | 'doubao-vision' | 'gemini' | 'vlm-ui-tars' | 'vlm-ui-tars-doubao' | 'vlm-ui-tars-doubao-1.5';
|
|
89
97
|
export type TVlModeTypes = 'qwen-vl' | 'qwen3-vl' | 'doubao-vision' | 'gemini' | 'vlm-ui-tars';
|
|
90
98
|
export interface IModelConfigForVQA {
|
|
91
99
|
[MIDSCENE_VQA_MODEL_NAME]: string;
|
|
92
|
-
[
|
|
93
|
-
[
|
|
94
|
-
[
|
|
95
|
-
[
|
|
96
|
-
[
|
|
97
|
-
[
|
|
100
|
+
[MIDSCENE_VQA_MODEL_SOCKS_PROXY]?: string;
|
|
101
|
+
[MIDSCENE_VQA_MODEL_HTTP_PROXY]?: string;
|
|
102
|
+
[MIDSCENE_VQA_MODEL_BASE_URL]?: string;
|
|
103
|
+
[MIDSCENE_VQA_MODEL_API_KEY]?: string;
|
|
104
|
+
[MIDSCENE_VQA_MODEL_INIT_CONFIG_JSON]?: string;
|
|
105
|
+
[MIDSCENE_VQA_LOCATOR_MODE]?: TVlModeValues;
|
|
98
106
|
}
|
|
99
107
|
/**
|
|
100
108
|
* Model configuration for Planning intent.
|
|
@@ -102,7 +110,7 @@ export interface IModelConfigForVQA {
|
|
|
102
110
|
* IMPORTANT: Planning MUST use a vision language model (VL mode).
|
|
103
111
|
* DOM-based planning is not supported.
|
|
104
112
|
*
|
|
105
|
-
* Required:
|
|
113
|
+
* Required: MIDSCENE_PLANNING_LOCATOR_MODE must be set to one of:
|
|
106
114
|
* - 'qwen-vl'
|
|
107
115
|
* - 'qwen3-vl'
|
|
108
116
|
* - 'gemini'
|
|
@@ -113,39 +121,39 @@ export interface IModelConfigForVQA {
|
|
|
113
121
|
*/
|
|
114
122
|
export interface IModelConfigForPlanning {
|
|
115
123
|
[MIDSCENE_PLANNING_MODEL_NAME]: string;
|
|
116
|
-
[
|
|
117
|
-
[
|
|
118
|
-
[
|
|
119
|
-
[
|
|
120
|
-
[
|
|
121
|
-
[
|
|
124
|
+
[MIDSCENE_PLANNING_MODEL_SOCKS_PROXY]?: string;
|
|
125
|
+
[MIDSCENE_PLANNING_MODEL_HTTP_PROXY]?: string;
|
|
126
|
+
[MIDSCENE_PLANNING_MODEL_BASE_URL]?: string;
|
|
127
|
+
[MIDSCENE_PLANNING_MODEL_API_KEY]?: string;
|
|
128
|
+
[MIDSCENE_PLANNING_MODEL_INIT_CONFIG_JSON]?: string;
|
|
129
|
+
[MIDSCENE_PLANNING_LOCATOR_MODE]?: TVlModeValues;
|
|
122
130
|
}
|
|
123
131
|
export interface IModeConfigForGrounding {
|
|
124
132
|
[MIDSCENE_GROUNDING_MODEL_NAME]: string;
|
|
125
|
-
[
|
|
126
|
-
[
|
|
127
|
-
[
|
|
128
|
-
[
|
|
129
|
-
[
|
|
130
|
-
[
|
|
133
|
+
[MIDSCENE_GROUNDING_MODEL_SOCKS_PROXY]?: string;
|
|
134
|
+
[MIDSCENE_GROUNDING_MODEL_HTTP_PROXY]?: string;
|
|
135
|
+
[MIDSCENE_GROUNDING_MODEL_BASE_URL]?: string;
|
|
136
|
+
[MIDSCENE_GROUNDING_MODEL_API_KEY]?: string;
|
|
137
|
+
[MIDSCENE_GROUNDING_MODEL_INIT_CONFIG_JSON]?: string;
|
|
138
|
+
[MIDSCENE_GROUNDING_LOCATOR_MODE]?: TVlModeValues;
|
|
131
139
|
}
|
|
132
140
|
export interface IModelConfigForDefault {
|
|
133
141
|
[MIDSCENE_MODEL_NAME]: string;
|
|
134
|
-
[
|
|
135
|
-
[
|
|
136
|
-
[
|
|
137
|
-
[
|
|
138
|
-
[
|
|
139
|
-
[
|
|
142
|
+
[MIDSCENE_MODEL_SOCKS_PROXY]?: string;
|
|
143
|
+
[MIDSCENE_MODEL_HTTP_PROXY]?: string;
|
|
144
|
+
[MIDSCENE_MODEL_BASE_URL]?: string;
|
|
145
|
+
[MIDSCENE_MODEL_API_KEY]?: string;
|
|
146
|
+
[MIDSCENE_MODEL_INIT_CONFIG_JSON]?: string;
|
|
147
|
+
[MIDSCENE_LOCATOR_MODE]?: TVlModeValues;
|
|
140
148
|
}
|
|
141
149
|
export interface IModelConfigForDefaultLegacy {
|
|
142
150
|
[MIDSCENE_MODEL_NAME]: string;
|
|
143
|
-
[
|
|
144
|
-
[
|
|
151
|
+
[MIDSCENE_MODEL_SOCKS_PROXY]?: string;
|
|
152
|
+
[MIDSCENE_MODEL_HTTP_PROXY]?: string;
|
|
145
153
|
[OPENAI_BASE_URL]?: string;
|
|
146
154
|
[OPENAI_API_KEY]?: string;
|
|
147
|
-
[
|
|
148
|
-
[
|
|
155
|
+
[MIDSCENE_MODEL_INIT_CONFIG_JSON]?: string;
|
|
156
|
+
[MIDSCENE_LOCATOR_MODE]?: TVlModeValues;
|
|
149
157
|
}
|
|
150
158
|
/**
|
|
151
159
|
* - VQA: Visual Question Answering
|
|
@@ -154,9 +162,18 @@ export interface IModelConfigForDefaultLegacy {
|
|
|
154
162
|
* - default: all except VQA、grounding、planning
|
|
155
163
|
*/
|
|
156
164
|
export type TIntent = 'VQA' | 'planning' | 'grounding' | 'default';
|
|
157
|
-
|
|
165
|
+
/**
|
|
166
|
+
* Internal type with intent parameter for ModelConfigManager
|
|
167
|
+
* @internal
|
|
168
|
+
*/
|
|
169
|
+
export type TModelConfigFnInternal = (options: {
|
|
158
170
|
intent: TIntent;
|
|
159
171
|
}) => IModelConfigForVQA | IModelConfigForPlanning | IModeConfigForGrounding | IModelConfigForDefault;
|
|
172
|
+
/**
|
|
173
|
+
* User-facing model config function type
|
|
174
|
+
* Users return config objects without needing to know about intent parameter
|
|
175
|
+
*/
|
|
176
|
+
export type TModelConfigFn = () => IModelConfigForVQA | IModelConfigForPlanning | IModeConfigForGrounding | IModelConfigForDefault;
|
|
160
177
|
export declare enum UITarsModelVersion {
|
|
161
178
|
V1_0 = "1.0",
|
|
162
179
|
V1_5 = "1.5",
|
package/package.json
CHANGED
package/src/env/constants.ts
CHANGED
|
@@ -1,33 +1,35 @@
|
|
|
1
1
|
import {
|
|
2
|
+
MIDSCENE_GROUNDING_LOCATOR_MODE,
|
|
3
|
+
MIDSCENE_GROUNDING_MODEL_API_KEY,
|
|
4
|
+
MIDSCENE_GROUNDING_MODEL_BASE_URL,
|
|
5
|
+
MIDSCENE_GROUNDING_MODEL_HTTP_PROXY,
|
|
6
|
+
MIDSCENE_GROUNDING_MODEL_INIT_CONFIG_JSON,
|
|
2
7
|
MIDSCENE_GROUNDING_MODEL_NAME,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
MIDSCENE_GROUNDING_MODEL_SOCKS_PROXY,
|
|
9
|
+
MIDSCENE_LOCATOR_MODE,
|
|
10
|
+
MIDSCENE_MODEL_API_KEY,
|
|
11
|
+
MIDSCENE_MODEL_BASE_URL,
|
|
12
|
+
MIDSCENE_MODEL_HTTP_PROXY,
|
|
13
|
+
MIDSCENE_MODEL_INIT_CONFIG_JSON,
|
|
9
14
|
MIDSCENE_MODEL_NAME,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
MIDSCENE_MODEL_SOCKS_PROXY,
|
|
16
|
+
MIDSCENE_PLANNING_LOCATOR_MODE,
|
|
17
|
+
MIDSCENE_PLANNING_MODEL_API_KEY,
|
|
18
|
+
MIDSCENE_PLANNING_MODEL_BASE_URL,
|
|
19
|
+
MIDSCENE_PLANNING_MODEL_HTTP_PROXY,
|
|
20
|
+
MIDSCENE_PLANNING_MODEL_INIT_CONFIG_JSON,
|
|
15
21
|
MIDSCENE_PLANNING_MODEL_NAME,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
MIDSCENE_VL_MODE,
|
|
22
|
+
MIDSCENE_PLANNING_MODEL_SOCKS_PROXY,
|
|
23
|
+
MIDSCENE_VQA_LOCATOR_MODE,
|
|
24
|
+
MIDSCENE_VQA_MODEL_API_KEY,
|
|
25
|
+
MIDSCENE_VQA_MODEL_BASE_URL,
|
|
26
|
+
MIDSCENE_VQA_MODEL_HTTP_PROXY,
|
|
27
|
+
MIDSCENE_VQA_MODEL_INIT_CONFIG_JSON,
|
|
23
28
|
// VQA
|
|
24
29
|
MIDSCENE_VQA_MODEL_NAME,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
MIDSCENE_VQA_OPENAI_INIT_CONFIG_JSON,
|
|
29
|
-
MIDSCENE_VQA_OPENAI_SOCKS_PROXY,
|
|
30
|
-
MIDSCENE_VQA_VL_MODE,
|
|
30
|
+
MIDSCENE_VQA_MODEL_SOCKS_PROXY,
|
|
31
|
+
MODEL_API_KEY,
|
|
32
|
+
MODEL_BASE_URL,
|
|
31
33
|
OPENAI_API_KEY,
|
|
32
34
|
OPENAI_BASE_URL,
|
|
33
35
|
} from './types';
|
|
@@ -56,18 +58,18 @@ export const VQA_MODEL_CONFIG_KEYS: IModelConfigKeys = {
|
|
|
56
58
|
/**
|
|
57
59
|
* proxy
|
|
58
60
|
*/
|
|
59
|
-
socksProxy:
|
|
60
|
-
httpProxy:
|
|
61
|
+
socksProxy: MIDSCENE_VQA_MODEL_SOCKS_PROXY,
|
|
62
|
+
httpProxy: MIDSCENE_VQA_MODEL_HTTP_PROXY,
|
|
61
63
|
/**
|
|
62
64
|
* OpenAI
|
|
63
65
|
*/
|
|
64
|
-
openaiBaseURL:
|
|
65
|
-
openaiApiKey:
|
|
66
|
-
openaiExtraConfig:
|
|
66
|
+
openaiBaseURL: MIDSCENE_VQA_MODEL_BASE_URL,
|
|
67
|
+
openaiApiKey: MIDSCENE_VQA_MODEL_API_KEY,
|
|
68
|
+
openaiExtraConfig: MIDSCENE_VQA_MODEL_INIT_CONFIG_JSON,
|
|
67
69
|
/**
|
|
68
70
|
* Extra
|
|
69
71
|
*/
|
|
70
|
-
vlMode:
|
|
72
|
+
vlMode: MIDSCENE_VQA_LOCATOR_MODE,
|
|
71
73
|
} as const;
|
|
72
74
|
|
|
73
75
|
export const GROUNDING_MODEL_CONFIG_KEYS: IModelConfigKeys = {
|
|
@@ -75,18 +77,18 @@ export const GROUNDING_MODEL_CONFIG_KEYS: IModelConfigKeys = {
|
|
|
75
77
|
/**
|
|
76
78
|
* proxy
|
|
77
79
|
*/
|
|
78
|
-
socksProxy:
|
|
79
|
-
httpProxy:
|
|
80
|
+
socksProxy: MIDSCENE_GROUNDING_MODEL_SOCKS_PROXY,
|
|
81
|
+
httpProxy: MIDSCENE_GROUNDING_MODEL_HTTP_PROXY,
|
|
80
82
|
/**
|
|
81
83
|
* OpenAI
|
|
82
84
|
*/
|
|
83
|
-
openaiBaseURL:
|
|
84
|
-
openaiApiKey:
|
|
85
|
-
openaiExtraConfig:
|
|
85
|
+
openaiBaseURL: MIDSCENE_GROUNDING_MODEL_BASE_URL,
|
|
86
|
+
openaiApiKey: MIDSCENE_GROUNDING_MODEL_API_KEY,
|
|
87
|
+
openaiExtraConfig: MIDSCENE_GROUNDING_MODEL_INIT_CONFIG_JSON,
|
|
86
88
|
/**
|
|
87
89
|
* Extra
|
|
88
90
|
*/
|
|
89
|
-
vlMode:
|
|
91
|
+
vlMode: MIDSCENE_GROUNDING_LOCATOR_MODE,
|
|
90
92
|
} as const;
|
|
91
93
|
|
|
92
94
|
export const PLANNING_MODEL_CONFIG_KEYS: IModelConfigKeys = {
|
|
@@ -94,18 +96,18 @@ export const PLANNING_MODEL_CONFIG_KEYS: IModelConfigKeys = {
|
|
|
94
96
|
/**
|
|
95
97
|
* proxy
|
|
96
98
|
*/
|
|
97
|
-
socksProxy:
|
|
98
|
-
httpProxy:
|
|
99
|
+
socksProxy: MIDSCENE_PLANNING_MODEL_SOCKS_PROXY,
|
|
100
|
+
httpProxy: MIDSCENE_PLANNING_MODEL_HTTP_PROXY,
|
|
99
101
|
/**
|
|
100
102
|
* OpenAI
|
|
101
103
|
*/
|
|
102
|
-
openaiBaseURL:
|
|
103
|
-
openaiApiKey:
|
|
104
|
-
openaiExtraConfig:
|
|
104
|
+
openaiBaseURL: MIDSCENE_PLANNING_MODEL_BASE_URL,
|
|
105
|
+
openaiApiKey: MIDSCENE_PLANNING_MODEL_API_KEY,
|
|
106
|
+
openaiExtraConfig: MIDSCENE_PLANNING_MODEL_INIT_CONFIG_JSON,
|
|
105
107
|
/**
|
|
106
108
|
* Extra
|
|
107
109
|
*/
|
|
108
|
-
vlMode:
|
|
110
|
+
vlMode: MIDSCENE_PLANNING_LOCATOR_MODE,
|
|
109
111
|
} as const;
|
|
110
112
|
|
|
111
113
|
// modelConfig return default
|
|
@@ -114,18 +116,18 @@ export const DEFAULT_MODEL_CONFIG_KEYS: IModelConfigKeys = {
|
|
|
114
116
|
/**
|
|
115
117
|
* proxy
|
|
116
118
|
*/
|
|
117
|
-
socksProxy:
|
|
118
|
-
httpProxy:
|
|
119
|
+
socksProxy: MIDSCENE_MODEL_SOCKS_PROXY,
|
|
120
|
+
httpProxy: MIDSCENE_MODEL_HTTP_PROXY,
|
|
119
121
|
/**
|
|
120
122
|
* OpenAI
|
|
121
123
|
*/
|
|
122
|
-
openaiBaseURL:
|
|
123
|
-
openaiApiKey:
|
|
124
|
-
openaiExtraConfig:
|
|
124
|
+
openaiBaseURL: MIDSCENE_MODEL_BASE_URL,
|
|
125
|
+
openaiApiKey: MIDSCENE_MODEL_API_KEY,
|
|
126
|
+
openaiExtraConfig: MIDSCENE_MODEL_INIT_CONFIG_JSON,
|
|
125
127
|
/**
|
|
126
128
|
* Extra
|
|
127
129
|
*/
|
|
128
|
-
vlMode:
|
|
130
|
+
vlMode: MIDSCENE_LOCATOR_MODE,
|
|
129
131
|
} as const;
|
|
130
132
|
|
|
131
133
|
// read from process.env
|
|
@@ -134,14 +136,14 @@ export const DEFAULT_MODEL_CONFIG_KEYS_LEGACY: IModelConfigKeys = {
|
|
|
134
136
|
/**
|
|
135
137
|
* proxy
|
|
136
138
|
*/
|
|
137
|
-
socksProxy:
|
|
138
|
-
httpProxy:
|
|
139
|
+
socksProxy: MIDSCENE_MODEL_SOCKS_PROXY,
|
|
140
|
+
httpProxy: MIDSCENE_MODEL_HTTP_PROXY,
|
|
139
141
|
/**
|
|
140
|
-
*
|
|
142
|
+
* Model API - Uses legacy OPENAI_* variables for backward compatibility
|
|
141
143
|
*/
|
|
142
144
|
openaiBaseURL: OPENAI_BASE_URL,
|
|
143
145
|
openaiApiKey: OPENAI_API_KEY,
|
|
144
|
-
openaiExtraConfig:
|
|
146
|
+
openaiExtraConfig: MIDSCENE_MODEL_INIT_CONFIG_JSON,
|
|
145
147
|
/**
|
|
146
148
|
* Extra
|
|
147
149
|
*/
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
PLANNING_MODEL_CONFIG_KEYS,
|
|
13
13
|
VQA_MODEL_CONFIG_KEYS,
|
|
14
14
|
} from './constants';
|
|
15
|
+
import { MODEL_API_KEY, MODEL_BASE_URL } from './types';
|
|
15
16
|
|
|
16
17
|
import { getDebug } from '../logger';
|
|
17
18
|
import { assert } from '../utils';
|
|
@@ -69,8 +70,25 @@ export const decideOpenaiSdkConfig = ({
|
|
|
69
70
|
|
|
70
71
|
debugLog('enter decideOpenaiSdkConfig with keys:', keys);
|
|
71
72
|
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
// Implement compatibility logic: prefer new variable names (MODEL_*), fallback to old ones (OPENAI_*)
|
|
74
|
+
let openaiBaseURL: string | undefined;
|
|
75
|
+
let openaiApiKey: string | undefined;
|
|
76
|
+
|
|
77
|
+
// When using legacy keys (OPENAI_BASE_URL, OPENAI_API_KEY), check for new names first
|
|
78
|
+
if (keys.openaiBaseURL === 'OPENAI_BASE_URL') {
|
|
79
|
+
// Priority: MODEL_BASE_URL > OPENAI_BASE_URL
|
|
80
|
+
openaiBaseURL = provider[MODEL_BASE_URL] || provider[keys.openaiBaseURL];
|
|
81
|
+
} else {
|
|
82
|
+
openaiBaseURL = provider[keys.openaiBaseURL];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (keys.openaiApiKey === 'OPENAI_API_KEY') {
|
|
86
|
+
// Priority: MODEL_API_KEY > OPENAI_API_KEY
|
|
87
|
+
openaiApiKey = provider[MODEL_API_KEY] || provider[keys.openaiApiKey];
|
|
88
|
+
} else {
|
|
89
|
+
openaiApiKey = provider[keys.openaiApiKey];
|
|
90
|
+
}
|
|
91
|
+
|
|
74
92
|
const openaiExtraConfig = parseJson(
|
|
75
93
|
keys.openaiExtraConfig,
|
|
76
94
|
provider[keys.openaiExtraConfig],
|
package/src/env/init-debug.ts
CHANGED
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
import { enableDebug } from '../logger';
|
|
2
2
|
import { getBasicEnvValue } from './basic';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
MIDSCENE_DEBUG_MODEL_PROFILE,
|
|
5
|
+
MIDSCENE_DEBUG_MODEL_RESPONSE,
|
|
6
|
+
} from './types';
|
|
4
7
|
|
|
5
8
|
export const initDebugConfig = () => {
|
|
6
|
-
const shouldPrintTiming = getBasicEnvValue(
|
|
9
|
+
const shouldPrintTiming = getBasicEnvValue(MIDSCENE_DEBUG_MODEL_PROFILE);
|
|
7
10
|
let debugConfig = '';
|
|
8
11
|
if (shouldPrintTiming) {
|
|
9
12
|
console.warn(
|
|
10
|
-
'
|
|
13
|
+
'MIDSCENE_DEBUG_MODEL_PROFILE is deprecated, use DEBUG=midscene:ai:profile instead',
|
|
11
14
|
);
|
|
12
15
|
debugConfig = 'ai:profile';
|
|
13
16
|
}
|
|
14
|
-
const
|
|
17
|
+
const shouldPrintModelResponse = getBasicEnvValue(
|
|
18
|
+
MIDSCENE_DEBUG_MODEL_RESPONSE,
|
|
19
|
+
);
|
|
15
20
|
|
|
16
|
-
if (
|
|
21
|
+
if (shouldPrintModelResponse) {
|
|
17
22
|
console.warn(
|
|
18
|
-
'
|
|
23
|
+
'MIDSCENE_DEBUG_MODEL_RESPONSE is deprecated, use DEBUG=midscene:ai:response instead',
|
|
19
24
|
);
|
|
20
25
|
if (debugConfig) {
|
|
21
26
|
debugConfig = 'ai:*';
|
|
@@ -9,6 +9,7 @@ import type {
|
|
|
9
9
|
IModelConfig,
|
|
10
10
|
TIntent,
|
|
11
11
|
TModelConfigFn,
|
|
12
|
+
TModelConfigFnInternal,
|
|
12
13
|
} from './types';
|
|
13
14
|
import { VL_MODE_RAW_VALID_VALUES as VL_MODES } from './types';
|
|
14
15
|
|
|
@@ -16,7 +17,7 @@ const ALL_INTENTS: TIntent[] = ['VQA', 'default', 'grounding', 'planning'];
|
|
|
16
17
|
|
|
17
18
|
export type TIntentConfigMap = Record<
|
|
18
19
|
TIntent,
|
|
19
|
-
ReturnType<
|
|
20
|
+
ReturnType<TModelConfigFnInternal> | undefined
|
|
20
21
|
>;
|
|
21
22
|
|
|
22
23
|
export class ModelConfigManager {
|
|
@@ -37,13 +38,18 @@ export class ModelConfigManager {
|
|
|
37
38
|
this.createOpenAIClientFn = createOpenAIClientFn;
|
|
38
39
|
if (modelConfigFn) {
|
|
39
40
|
this.isolatedMode = true;
|
|
40
|
-
|
|
41
|
+
// Cast to internal type - user function can optionally use intent parameter
|
|
42
|
+
// even though it's not shown in the type definition
|
|
43
|
+
const internalFn = modelConfigFn as unknown as TModelConfigFnInternal;
|
|
44
|
+
const intentConfigMap = this.calcIntentConfigMap(internalFn);
|
|
41
45
|
this.modelConfigMap =
|
|
42
46
|
this.calcModelConfigMapBaseOnIntent(intentConfigMap);
|
|
43
47
|
}
|
|
44
48
|
}
|
|
45
49
|
|
|
46
|
-
private calcIntentConfigMap(
|
|
50
|
+
private calcIntentConfigMap(
|
|
51
|
+
modelConfigFn: TModelConfigFnInternal,
|
|
52
|
+
): TIntentConfigMap {
|
|
47
53
|
const intentConfigMap: TIntentConfigMap = {
|
|
48
54
|
VQA: undefined,
|
|
49
55
|
default: undefined,
|