@midscene/shared 1.16.1 → 1.16.5
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/console-context.node.mjs +3 -0
- package/dist/es/console-context.stub.mjs +5 -0
- package/dist/es/env/constants.mjs +6 -1
- package/dist/es/env/model-config-manager.mjs +2 -2
- package/dist/es/env/parse-model-config.mjs +9 -4
- package/dist/es/env/types.mjs +9 -1
- package/dist/es/logger.mjs +51 -4
- package/dist/lib/console-context.node.js +37 -0
- package/dist/lib/console-context.stub.js +39 -0
- package/dist/lib/env/constants.js +5 -0
- package/dist/lib/env/model-config-manager.js +2 -2
- package/dist/lib/env/parse-model-config.js +9 -4
- package/dist/lib/env/types.js +20 -0
- package/dist/lib/logger.js +59 -3
- package/dist/types/console-context.node.d.ts +3 -0
- package/dist/types/console-context.node.d.ts.map +1 -0
- package/dist/types/console-context.stub.d.ts +5 -0
- package/dist/types/console-context.stub.d.ts.map +1 -0
- package/dist/types/env/constants.d.ts +1 -0
- package/dist/types/env/constants.d.ts.map +1 -1
- package/dist/types/env/parse-model-config.d.ts.map +1 -1
- package/dist/types/env/types.d.ts +12 -2
- package/dist/types/env/types.d.ts.map +1 -1
- package/dist/types/logger.d.ts +37 -0
- package/dist/types/logger.d.ts.map +1 -1
- package/package.json +14 -1
- package/src/console-context.d.ts +4 -0
- package/src/console-context.node.ts +3 -0
- package/src/console-context.stub.ts +5 -0
- package/src/env/constants.ts +10 -0
- package/src/env/model-config-manager.ts +2 -2
- package/src/env/parse-model-config.ts +13 -4
- package/src/env/types.ts +18 -0
- package/src/logger.ts +105 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MIDSCENE_INSIGHT_MODEL_API_KEY, MIDSCENE_INSIGHT_MODEL_BASE_URL, MIDSCENE_INSIGHT_MODEL_EXTRA_BODY_JSON, MIDSCENE_INSIGHT_MODEL_FAMILY, MIDSCENE_INSIGHT_MODEL_HTTP_PROXY, MIDSCENE_INSIGHT_MODEL_INIT_CONFIG_JSON, MIDSCENE_INSIGHT_MODEL_NAME, MIDSCENE_INSIGHT_MODEL_PROTOCOL, MIDSCENE_INSIGHT_MODEL_REASONING_BUDGET, MIDSCENE_INSIGHT_MODEL_REASONING_EFFORT, MIDSCENE_INSIGHT_MODEL_REASONING_ENABLED, MIDSCENE_INSIGHT_MODEL_RESPONSE_FORMAT, MIDSCENE_INSIGHT_MODEL_RETRY_COUNT, MIDSCENE_INSIGHT_MODEL_RETRY_INTERVAL, MIDSCENE_INSIGHT_MODEL_SOCKS_PROXY, MIDSCENE_INSIGHT_MODEL_STREAM_MODE, MIDSCENE_INSIGHT_MODEL_TEMPERATURE, MIDSCENE_INSIGHT_MODEL_TIMEOUT, MIDSCENE_LOCATE_MODEL_API_KEY, MIDSCENE_LOCATE_MODEL_BASE_URL, MIDSCENE_LOCATE_MODEL_EXTRA_BODY_JSON, MIDSCENE_LOCATE_MODEL_FAMILY, MIDSCENE_LOCATE_MODEL_HTTP_PROXY, MIDSCENE_LOCATE_MODEL_INIT_CONFIG_JSON, MIDSCENE_LOCATE_MODEL_NAME, MIDSCENE_LOCATE_MODEL_PROTOCOL, MIDSCENE_LOCATE_MODEL_REASONING_BUDGET, MIDSCENE_LOCATE_MODEL_REASONING_EFFORT, MIDSCENE_LOCATE_MODEL_REASONING_ENABLED, MIDSCENE_LOCATE_MODEL_RESPONSE_FORMAT, MIDSCENE_LOCATE_MODEL_RETRY_COUNT, MIDSCENE_LOCATE_MODEL_RETRY_INTERVAL, MIDSCENE_LOCATE_MODEL_SOCKS_PROXY, MIDSCENE_LOCATE_MODEL_STREAM_MODE, MIDSCENE_LOCATE_MODEL_TEMPERATURE, MIDSCENE_LOCATE_MODEL_TIMEOUT, MIDSCENE_MODEL_API_KEY, MIDSCENE_MODEL_BASE_URL, MIDSCENE_MODEL_EXTRA_BODY_JSON, MIDSCENE_MODEL_FAMILY, MIDSCENE_MODEL_HTTP_PROXY, MIDSCENE_MODEL_INIT_CONFIG_JSON, MIDSCENE_MODEL_NAME, MIDSCENE_MODEL_PROTOCOL, MIDSCENE_MODEL_REASONING_BUDGET, MIDSCENE_MODEL_REASONING_EFFORT, MIDSCENE_MODEL_REASONING_ENABLED, MIDSCENE_MODEL_RESPONSE_FORMAT, MIDSCENE_MODEL_RETRY_COUNT, MIDSCENE_MODEL_RETRY_INTERVAL, MIDSCENE_MODEL_SOCKS_PROXY, MIDSCENE_MODEL_STREAM_MODE, MIDSCENE_MODEL_TEMPERATURE, MIDSCENE_MODEL_TIMEOUT, MIDSCENE_OPENAI_HTTP_PROXY, MIDSCENE_OPENAI_INIT_CONFIG_JSON, MIDSCENE_OPENAI_SOCKS_PROXY, MIDSCENE_PLANNING_MODEL_API_KEY, MIDSCENE_PLANNING_MODEL_BASE_URL, MIDSCENE_PLANNING_MODEL_EXTRA_BODY_JSON, MIDSCENE_PLANNING_MODEL_FAMILY, MIDSCENE_PLANNING_MODEL_HTTP_PROXY, MIDSCENE_PLANNING_MODEL_INIT_CONFIG_JSON, MIDSCENE_PLANNING_MODEL_NAME, MIDSCENE_PLANNING_MODEL_PROTOCOL, MIDSCENE_PLANNING_MODEL_REASONING_BUDGET, MIDSCENE_PLANNING_MODEL_REASONING_EFFORT, MIDSCENE_PLANNING_MODEL_REASONING_ENABLED, MIDSCENE_PLANNING_MODEL_RESPONSE_FORMAT, MIDSCENE_PLANNING_MODEL_RETRY_COUNT, MIDSCENE_PLANNING_MODEL_RETRY_INTERVAL, MIDSCENE_PLANNING_MODEL_SOCKS_PROXY, MIDSCENE_PLANNING_MODEL_STREAM_MODE, MIDSCENE_PLANNING_MODEL_TEMPERATURE, MIDSCENE_PLANNING_MODEL_TIMEOUT, OPENAI_API_KEY, OPENAI_BASE_URL } from "./types.mjs";
|
|
1
|
+
import { MIDSCENE_INSIGHT_MODEL_API_KEY, MIDSCENE_INSIGHT_MODEL_AUTH_MODE, MIDSCENE_INSIGHT_MODEL_BASE_URL, MIDSCENE_INSIGHT_MODEL_EXTRA_BODY_JSON, MIDSCENE_INSIGHT_MODEL_FAMILY, MIDSCENE_INSIGHT_MODEL_HTTP_PROXY, MIDSCENE_INSIGHT_MODEL_INIT_CONFIG_JSON, MIDSCENE_INSIGHT_MODEL_NAME, MIDSCENE_INSIGHT_MODEL_PROTOCOL, MIDSCENE_INSIGHT_MODEL_REASONING_BUDGET, MIDSCENE_INSIGHT_MODEL_REASONING_EFFORT, MIDSCENE_INSIGHT_MODEL_REASONING_ENABLED, MIDSCENE_INSIGHT_MODEL_RESPONSE_FORMAT, MIDSCENE_INSIGHT_MODEL_RETRY_COUNT, MIDSCENE_INSIGHT_MODEL_RETRY_INTERVAL, MIDSCENE_INSIGHT_MODEL_SOCKS_PROXY, MIDSCENE_INSIGHT_MODEL_STREAM_MODE, MIDSCENE_INSIGHT_MODEL_TEMPERATURE, MIDSCENE_INSIGHT_MODEL_TIMEOUT, MIDSCENE_LOCATE_MODEL_API_KEY, MIDSCENE_LOCATE_MODEL_AUTH_MODE, MIDSCENE_LOCATE_MODEL_BASE_URL, MIDSCENE_LOCATE_MODEL_EXTRA_BODY_JSON, MIDSCENE_LOCATE_MODEL_FAMILY, MIDSCENE_LOCATE_MODEL_HTTP_PROXY, MIDSCENE_LOCATE_MODEL_INIT_CONFIG_JSON, MIDSCENE_LOCATE_MODEL_NAME, MIDSCENE_LOCATE_MODEL_PROTOCOL, MIDSCENE_LOCATE_MODEL_REASONING_BUDGET, MIDSCENE_LOCATE_MODEL_REASONING_EFFORT, MIDSCENE_LOCATE_MODEL_REASONING_ENABLED, MIDSCENE_LOCATE_MODEL_RESPONSE_FORMAT, MIDSCENE_LOCATE_MODEL_RETRY_COUNT, MIDSCENE_LOCATE_MODEL_RETRY_INTERVAL, MIDSCENE_LOCATE_MODEL_SOCKS_PROXY, MIDSCENE_LOCATE_MODEL_STREAM_MODE, MIDSCENE_LOCATE_MODEL_TEMPERATURE, MIDSCENE_LOCATE_MODEL_TIMEOUT, MIDSCENE_MODEL_API_KEY, MIDSCENE_MODEL_AUTH_MODE, MIDSCENE_MODEL_BASE_URL, MIDSCENE_MODEL_EXTRA_BODY_JSON, MIDSCENE_MODEL_FAMILY, MIDSCENE_MODEL_HTTP_PROXY, MIDSCENE_MODEL_INIT_CONFIG_JSON, MIDSCENE_MODEL_NAME, MIDSCENE_MODEL_PROTOCOL, MIDSCENE_MODEL_REASONING_BUDGET, MIDSCENE_MODEL_REASONING_EFFORT, MIDSCENE_MODEL_REASONING_ENABLED, MIDSCENE_MODEL_RESPONSE_FORMAT, MIDSCENE_MODEL_RETRY_COUNT, MIDSCENE_MODEL_RETRY_INTERVAL, MIDSCENE_MODEL_SOCKS_PROXY, MIDSCENE_MODEL_STREAM_MODE, MIDSCENE_MODEL_TEMPERATURE, MIDSCENE_MODEL_TIMEOUT, MIDSCENE_OPENAI_HTTP_PROXY, MIDSCENE_OPENAI_INIT_CONFIG_JSON, MIDSCENE_OPENAI_SOCKS_PROXY, MIDSCENE_PLANNING_MODEL_API_KEY, MIDSCENE_PLANNING_MODEL_AUTH_MODE, MIDSCENE_PLANNING_MODEL_BASE_URL, MIDSCENE_PLANNING_MODEL_EXTRA_BODY_JSON, MIDSCENE_PLANNING_MODEL_FAMILY, MIDSCENE_PLANNING_MODEL_HTTP_PROXY, MIDSCENE_PLANNING_MODEL_INIT_CONFIG_JSON, MIDSCENE_PLANNING_MODEL_NAME, MIDSCENE_PLANNING_MODEL_PROTOCOL, MIDSCENE_PLANNING_MODEL_REASONING_BUDGET, MIDSCENE_PLANNING_MODEL_REASONING_EFFORT, MIDSCENE_PLANNING_MODEL_REASONING_ENABLED, MIDSCENE_PLANNING_MODEL_RESPONSE_FORMAT, MIDSCENE_PLANNING_MODEL_RETRY_COUNT, MIDSCENE_PLANNING_MODEL_RETRY_INTERVAL, MIDSCENE_PLANNING_MODEL_SOCKS_PROXY, MIDSCENE_PLANNING_MODEL_STREAM_MODE, MIDSCENE_PLANNING_MODEL_TEMPERATURE, MIDSCENE_PLANNING_MODEL_TIMEOUT, OPENAI_API_KEY, OPENAI_BASE_URL } from "./types.mjs";
|
|
2
2
|
const INSIGHT_MODEL_CONFIG_KEYS = {
|
|
3
3
|
modelName: MIDSCENE_INSIGHT_MODEL_NAME,
|
|
4
4
|
socksProxy: MIDSCENE_INSIGHT_MODEL_SOCKS_PROXY,
|
|
@@ -9,6 +9,7 @@ const INSIGHT_MODEL_CONFIG_KEYS = {
|
|
|
9
9
|
extraBody: MIDSCENE_INSIGHT_MODEL_EXTRA_BODY_JSON,
|
|
10
10
|
protocol: MIDSCENE_INSIGHT_MODEL_PROTOCOL,
|
|
11
11
|
streamMode: MIDSCENE_INSIGHT_MODEL_STREAM_MODE,
|
|
12
|
+
authMode: MIDSCENE_INSIGHT_MODEL_AUTH_MODE,
|
|
12
13
|
modelFamily: MIDSCENE_INSIGHT_MODEL_FAMILY,
|
|
13
14
|
timeout: MIDSCENE_INSIGHT_MODEL_TIMEOUT,
|
|
14
15
|
temperature: MIDSCENE_INSIGHT_MODEL_TEMPERATURE,
|
|
@@ -29,6 +30,7 @@ const LOCATE_MODEL_CONFIG_KEYS = {
|
|
|
29
30
|
extraBody: MIDSCENE_LOCATE_MODEL_EXTRA_BODY_JSON,
|
|
30
31
|
protocol: MIDSCENE_LOCATE_MODEL_PROTOCOL,
|
|
31
32
|
streamMode: MIDSCENE_LOCATE_MODEL_STREAM_MODE,
|
|
33
|
+
authMode: MIDSCENE_LOCATE_MODEL_AUTH_MODE,
|
|
32
34
|
modelFamily: MIDSCENE_LOCATE_MODEL_FAMILY,
|
|
33
35
|
timeout: MIDSCENE_LOCATE_MODEL_TIMEOUT,
|
|
34
36
|
temperature: MIDSCENE_LOCATE_MODEL_TEMPERATURE,
|
|
@@ -49,6 +51,7 @@ const PLANNING_MODEL_CONFIG_KEYS = {
|
|
|
49
51
|
extraBody: MIDSCENE_PLANNING_MODEL_EXTRA_BODY_JSON,
|
|
50
52
|
protocol: MIDSCENE_PLANNING_MODEL_PROTOCOL,
|
|
51
53
|
streamMode: MIDSCENE_PLANNING_MODEL_STREAM_MODE,
|
|
54
|
+
authMode: MIDSCENE_PLANNING_MODEL_AUTH_MODE,
|
|
52
55
|
modelFamily: MIDSCENE_PLANNING_MODEL_FAMILY,
|
|
53
56
|
timeout: MIDSCENE_PLANNING_MODEL_TIMEOUT,
|
|
54
57
|
temperature: MIDSCENE_PLANNING_MODEL_TEMPERATURE,
|
|
@@ -69,6 +72,7 @@ const DEFAULT_MODEL_CONFIG_KEYS = {
|
|
|
69
72
|
extraBody: MIDSCENE_MODEL_EXTRA_BODY_JSON,
|
|
70
73
|
protocol: MIDSCENE_MODEL_PROTOCOL,
|
|
71
74
|
streamMode: MIDSCENE_MODEL_STREAM_MODE,
|
|
75
|
+
authMode: MIDSCENE_MODEL_AUTH_MODE,
|
|
72
76
|
modelFamily: MIDSCENE_MODEL_FAMILY,
|
|
73
77
|
timeout: MIDSCENE_MODEL_TIMEOUT,
|
|
74
78
|
temperature: MIDSCENE_MODEL_TEMPERATURE,
|
|
@@ -89,6 +93,7 @@ const DEFAULT_MODEL_CONFIG_KEYS_LEGACY = {
|
|
|
89
93
|
extraBody: MIDSCENE_MODEL_EXTRA_BODY_JSON,
|
|
90
94
|
protocol: MIDSCENE_MODEL_PROTOCOL,
|
|
91
95
|
streamMode: MIDSCENE_MODEL_STREAM_MODE,
|
|
96
|
+
authMode: MIDSCENE_MODEL_AUTH_MODE,
|
|
92
97
|
modelFamily: 'DEFAULT_MODEL_CONFIG_KEYS has no modelFamily key',
|
|
93
98
|
timeout: MIDSCENE_MODEL_TIMEOUT,
|
|
94
99
|
temperature: MIDSCENE_MODEL_TEMPERATURE,
|
|
@@ -18,7 +18,7 @@ class ModelConfigManager {
|
|
|
18
18
|
configMap = this.normalizeModelConfig(this.modelConfig);
|
|
19
19
|
} else configMap = this.globalConfigManager?.getAllEnvConfig() || {};
|
|
20
20
|
const defaultConfig = decideModelConfigFromIntentConfig('default', configMap);
|
|
21
|
-
if (!defaultConfig) throw new Error('Model configuration is incomplete: model name (MIDSCENE_MODEL_NAME) is required. See https://midscenejs.com/model-
|
|
21
|
+
if (!defaultConfig) throw new Error('Model configuration is incomplete: model name (MIDSCENE_MODEL_NAME) is required. See https://midscenejs.com/model-api-setup');
|
|
22
22
|
if ('jev' === defaultConfig.modelFamily) throw new Error('Jev cannot be the default model. Configure a general-purpose MIDSCENE_MODEL_FAMILY and use Jev in Locate, Planning, or Insight.');
|
|
23
23
|
const insightConfig = decideModelConfigFromIntentConfig('insight', configMap);
|
|
24
24
|
const planningConfig = decideModelConfigFromIntentConfig('planning', configMap);
|
|
@@ -77,7 +77,7 @@ class ModelConfigManager {
|
|
|
77
77
|
}
|
|
78
78
|
throwErrorIfNonVLModel() {
|
|
79
79
|
const modelConfig = this.getModelConfig('locate');
|
|
80
|
-
if (!modelConfig.modelFamily) throw new Error(`${'locate' === modelConfig.slot ? 'MIDSCENE_LOCATE_MODEL_FAMILY' : 'MIDSCENE_MODEL_FAMILY'} is not set to a multimodal model with UI localization, so element localization cannot be achieved. Check your model configuration. See https://midscenejs.com/model-
|
|
80
|
+
if (!modelConfig.modelFamily) throw new Error(`${'locate' === modelConfig.slot ? 'MIDSCENE_LOCATE_MODEL_FAMILY' : 'MIDSCENE_MODEL_FAMILY'} is not set to a multimodal model with UI localization, so element localization cannot be achieved. Check your model configuration. See https://midscenejs.com/model-api-setup`);
|
|
81
81
|
}
|
|
82
82
|
constructor(modelConfig, createOpenAIClientFn){
|
|
83
83
|
_define_property(this, "modelConfigMap", void 0);
|
|
@@ -4,8 +4,8 @@ import { getDebug } from "../logger.mjs";
|
|
|
4
4
|
import { assert } from "../utils.mjs";
|
|
5
5
|
import { maskConfig, parseJson } from "./helper.mjs";
|
|
6
6
|
import { initDebugConfig } from "./init-debug.mjs";
|
|
7
|
-
const MODEL_CONFIG_DOC_URL = 'https://midscenejs.com/model-
|
|
8
|
-
const getCurrentVersion = ()=>"1.16.
|
|
7
|
+
const MODEL_CONFIG_DOC_URL = 'https://midscenejs.com/model-api-setup.html';
|
|
8
|
+
const getCurrentVersion = ()=>"1.16.5";
|
|
9
9
|
const getInvalidModelFamilyMessage = (modelFamily)=>`Invalid MIDSCENE_MODEL_FAMILY value: ${modelFamily}. Current version v${getCurrentVersion()} accepts the following model families: ${MODEL_FAMILY_VALUES.join(', ')}. You can also visit ${MODEL_CONFIG_DOC_URL} for the latest configuration information.`;
|
|
10
10
|
const KEYS_MAP = {
|
|
11
11
|
locate: LOCATE_MODEL_CONFIG_KEYS,
|
|
@@ -90,6 +90,11 @@ const parseOpenaiSdkConfig = ({ keys, provider, useLegacyLogic = false })=>{
|
|
|
90
90
|
return {
|
|
91
91
|
socksProxy,
|
|
92
92
|
httpProxy,
|
|
93
|
+
authMode: (()=>{
|
|
94
|
+
const value = provider[keys.authMode]?.trim() ?? 'api-key';
|
|
95
|
+
if ('api-key' === value || 'siwc' === value) return value;
|
|
96
|
+
throw new Error(`Invalid ${keys.authMode}: "${value}". Expected "api-key" or "siwc".`);
|
|
97
|
+
})(),
|
|
93
98
|
openaiBaseURL,
|
|
94
99
|
openaiApiKey,
|
|
95
100
|
openaiExtraConfig: normalizeOpenaiExtraConfig(openaiExtraConfig),
|
|
@@ -170,8 +175,8 @@ const decideModelConfigFromIntentConfig = (intent, configMap)=>{
|
|
|
170
175
|
debugLog('decideModelConfig result by agent.modelConfig() with intent', intent, maskConfig({
|
|
171
176
|
...finalResult
|
|
172
177
|
}));
|
|
173
|
-
assert(finalResult.openaiBaseURL, `failed to get base URL of model (intent=${intent}). See https://midscenejs.com/model-
|
|
174
|
-
if (!finalResult.modelName) console.warn(`modelName is not set for intent ${intent}, this may cause unexpected behavior. See https://midscenejs.com/model-
|
|
178
|
+
assert('siwc' === finalResult.authMode || finalResult.openaiBaseURL, `failed to get base URL of model (intent=${intent}). See https://midscenejs.com/model-api-setup`);
|
|
179
|
+
if (!finalResult.modelName) console.warn(`modelName is not set for intent ${intent}, this may cause unexpected behavior. See https://midscenejs.com/model-api-setup`);
|
|
175
180
|
return finalResult;
|
|
176
181
|
};
|
|
177
182
|
export { decideModelConfigFromIntentConfig, getUITarsModelVersion, legacyConfigToModelFamily, parseOpenaiSdkConfig, validateModelFamily };
|
package/dist/es/env/types.mjs
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
const MIDSCENE_MODEL_AUTH_MODE = 'MIDSCENE_MODEL_AUTH_MODE';
|
|
2
|
+
const MIDSCENE_PLANNING_MODEL_AUTH_MODE = 'MIDSCENE_PLANNING_MODEL_AUTH_MODE';
|
|
3
|
+
const MIDSCENE_LOCATE_MODEL_AUTH_MODE = 'MIDSCENE_LOCATE_MODEL_AUTH_MODE';
|
|
4
|
+
const MIDSCENE_INSIGHT_MODEL_AUTH_MODE = 'MIDSCENE_INSIGHT_MODEL_AUTH_MODE';
|
|
1
5
|
const MIDSCENE_MODEL_INIT_CONFIG_JSON = 'MIDSCENE_MODEL_INIT_CONFIG_JSON';
|
|
2
6
|
const MIDSCENE_MODEL_EXTRA_BODY_JSON = 'MIDSCENE_MODEL_EXTRA_BODY_JSON';
|
|
3
7
|
const MIDSCENE_MODEL_NAME = 'MIDSCENE_MODEL_NAME';
|
|
@@ -148,6 +152,10 @@ const GLOBAL_ENV_KEYS = [
|
|
|
148
152
|
...STRING_ENV_KEYS
|
|
149
153
|
];
|
|
150
154
|
const MODEL_ENV_KEYS = [
|
|
155
|
+
MIDSCENE_MODEL_AUTH_MODE,
|
|
156
|
+
MIDSCENE_PLANNING_MODEL_AUTH_MODE,
|
|
157
|
+
MIDSCENE_LOCATE_MODEL_AUTH_MODE,
|
|
158
|
+
MIDSCENE_INSIGHT_MODEL_AUTH_MODE,
|
|
151
159
|
MIDSCENE_INSIGHT_MODEL_STREAM_MODE,
|
|
152
160
|
MIDSCENE_PLANNING_MODEL_STREAM_MODE,
|
|
153
161
|
MIDSCENE_LOCATE_MODEL_STREAM_MODE,
|
|
@@ -268,4 +276,4 @@ var types_UITarsModelVersion = /*#__PURE__*/ function(UITarsModelVersion) {
|
|
|
268
276
|
UITarsModelVersion["DOUBAO_1_5_20B"] = "doubao-1.5-20B";
|
|
269
277
|
return UITarsModelVersion;
|
|
270
278
|
}({});
|
|
271
|
-
export { ALL_ENV_KEYS, BASIC_ENV_KEYS, BOOLEAN_ENV_KEYS, DOCKER_CONTAINER, GLOBAL_ENV_KEYS, MATCH_BY_POSITION, MIDSCENE_ADB_PATH, MIDSCENE_ADB_REMOTE_HOST, MIDSCENE_ADB_REMOTE_PORT, MIDSCENE_ANDROID_IME_STRATEGY, MIDSCENE_ANDROID_SCREENSHOT_STRATEGY, MIDSCENE_CACHE, MIDSCENE_CACHE_MAX_FILENAME_LENGTH, MIDSCENE_CHROME_PATH, MIDSCENE_DANGEROUSLY_PRINT_ALL_CONFIG, MIDSCENE_DEBUG_MODE, MIDSCENE_DEBUG_MODEL_PROFILE, MIDSCENE_DEBUG_MODEL_RESPONSE, MIDSCENE_INSIGHT_MODEL_API_KEY, MIDSCENE_INSIGHT_MODEL_BASE_URL, MIDSCENE_INSIGHT_MODEL_EXTRA_BODY_JSON, MIDSCENE_INSIGHT_MODEL_FAMILY, MIDSCENE_INSIGHT_MODEL_HTTP_PROXY, MIDSCENE_INSIGHT_MODEL_INIT_CONFIG_JSON, MIDSCENE_INSIGHT_MODEL_NAME, MIDSCENE_INSIGHT_MODEL_PROTOCOL, MIDSCENE_INSIGHT_MODEL_REASONING_BUDGET, MIDSCENE_INSIGHT_MODEL_REASONING_EFFORT, MIDSCENE_INSIGHT_MODEL_REASONING_ENABLED, MIDSCENE_INSIGHT_MODEL_RESPONSE_FORMAT, MIDSCENE_INSIGHT_MODEL_RETRY_COUNT, MIDSCENE_INSIGHT_MODEL_RETRY_INTERVAL, MIDSCENE_INSIGHT_MODEL_SOCKS_PROXY, MIDSCENE_INSIGHT_MODEL_STREAM_MODE, MIDSCENE_INSIGHT_MODEL_TEMPERATURE, MIDSCENE_INSIGHT_MODEL_TIMEOUT, MIDSCENE_IOS_DEVICE_CLASS_OVERRIDE, MIDSCENE_IOS_DEVICE_UDID, MIDSCENE_IOS_SIMULATOR_UDID, MIDSCENE_LANGFUSE_DEBUG, MIDSCENE_LANGSMITH_DEBUG, MIDSCENE_LOCATE_MODEL_API_KEY, MIDSCENE_LOCATE_MODEL_BASE_URL, MIDSCENE_LOCATE_MODEL_EXTRA_BODY_JSON, MIDSCENE_LOCATE_MODEL_FAMILY, MIDSCENE_LOCATE_MODEL_HTTP_PROXY, MIDSCENE_LOCATE_MODEL_INIT_CONFIG_JSON, MIDSCENE_LOCATE_MODEL_NAME, MIDSCENE_LOCATE_MODEL_PROTOCOL, MIDSCENE_LOCATE_MODEL_REASONING_BUDGET, MIDSCENE_LOCATE_MODEL_REASONING_EFFORT, MIDSCENE_LOCATE_MODEL_REASONING_ENABLED, MIDSCENE_LOCATE_MODEL_RESPONSE_FORMAT, MIDSCENE_LOCATE_MODEL_RETRY_COUNT, MIDSCENE_LOCATE_MODEL_RETRY_INTERVAL, MIDSCENE_LOCATE_MODEL_SOCKS_PROXY, MIDSCENE_LOCATE_MODEL_STREAM_MODE, MIDSCENE_LOCATE_MODEL_TEMPERATURE, MIDSCENE_LOCATE_MODEL_TIMEOUT, MIDSCENE_MCP_CHROME_PATH, MIDSCENE_MODEL_API_KEY, MIDSCENE_MODEL_BASE_URL, MIDSCENE_MODEL_EXTRA_BODY_JSON, MIDSCENE_MODEL_FAMILY, MIDSCENE_MODEL_HTTP_PROXY, MIDSCENE_MODEL_INIT_CONFIG_JSON, MIDSCENE_MODEL_NAME, MIDSCENE_MODEL_PROTOCOL, MIDSCENE_MODEL_REASONING_BUDGET, MIDSCENE_MODEL_REASONING_EFFORT, MIDSCENE_MODEL_REASONING_ENABLED, MIDSCENE_MODEL_RESPONSE_FORMAT, MIDSCENE_MODEL_RETRY_COUNT, MIDSCENE_MODEL_RETRY_INTERVAL, MIDSCENE_MODEL_SOCKS_PROXY, MIDSCENE_MODEL_STREAM_MODE, MIDSCENE_MODEL_TEMPERATURE, MIDSCENE_MODEL_TIMEOUT, MIDSCENE_OPENAI_HTTP_PROXY, MIDSCENE_OPENAI_INIT_CONFIG_JSON, MIDSCENE_OPENAI_SOCKS_PROXY, MIDSCENE_PLANNING_MODEL_API_KEY, MIDSCENE_PLANNING_MODEL_BASE_URL, MIDSCENE_PLANNING_MODEL_EXTRA_BODY_JSON, MIDSCENE_PLANNING_MODEL_FAMILY, MIDSCENE_PLANNING_MODEL_HTTP_PROXY, MIDSCENE_PLANNING_MODEL_INIT_CONFIG_JSON, MIDSCENE_PLANNING_MODEL_NAME, MIDSCENE_PLANNING_MODEL_PROTOCOL, MIDSCENE_PLANNING_MODEL_REASONING_BUDGET, MIDSCENE_PLANNING_MODEL_REASONING_EFFORT, MIDSCENE_PLANNING_MODEL_REASONING_ENABLED, MIDSCENE_PLANNING_MODEL_RESPONSE_FORMAT, MIDSCENE_PLANNING_MODEL_RETRY_COUNT, MIDSCENE_PLANNING_MODEL_RETRY_INTERVAL, MIDSCENE_PLANNING_MODEL_SOCKS_PROXY, MIDSCENE_PLANNING_MODEL_STREAM_MODE, MIDSCENE_PLANNING_MODEL_TEMPERATURE, MIDSCENE_PLANNING_MODEL_TIMEOUT, MIDSCENE_PREFERRED_LANGUAGE, MIDSCENE_RECORD_MODEL_CALL, MIDSCENE_REPLANNING_CYCLE_LIMIT, MIDSCENE_REPORT_QUIET, MIDSCENE_REPORT_TAG_NAME, MIDSCENE_RUN_DIR, MIDSCENE_USE_DOUBAO_VISION, MIDSCENE_USE_GEMINI, MIDSCENE_USE_QWEN3_VL, MIDSCENE_USE_QWEN_VL, MIDSCENE_USE_VLM_UI_TARS, MIDSCENE_USE_VL_MODEL, MODEL_ENV_KEYS, MODEL_FAMILY_VALUES, NUMBER_ENV_KEYS, OPENAI_API_KEY, OPENAI_BASE_URL, STRING_ENV_KEYS, types_UITarsModelVersion as UITarsModelVersion, UNUSED_ENV_KEYS };
|
|
279
|
+
export { ALL_ENV_KEYS, BASIC_ENV_KEYS, BOOLEAN_ENV_KEYS, DOCKER_CONTAINER, GLOBAL_ENV_KEYS, MATCH_BY_POSITION, MIDSCENE_ADB_PATH, MIDSCENE_ADB_REMOTE_HOST, MIDSCENE_ADB_REMOTE_PORT, MIDSCENE_ANDROID_IME_STRATEGY, MIDSCENE_ANDROID_SCREENSHOT_STRATEGY, MIDSCENE_CACHE, MIDSCENE_CACHE_MAX_FILENAME_LENGTH, MIDSCENE_CHROME_PATH, MIDSCENE_DANGEROUSLY_PRINT_ALL_CONFIG, MIDSCENE_DEBUG_MODE, MIDSCENE_DEBUG_MODEL_PROFILE, MIDSCENE_DEBUG_MODEL_RESPONSE, MIDSCENE_INSIGHT_MODEL_API_KEY, MIDSCENE_INSIGHT_MODEL_AUTH_MODE, MIDSCENE_INSIGHT_MODEL_BASE_URL, MIDSCENE_INSIGHT_MODEL_EXTRA_BODY_JSON, MIDSCENE_INSIGHT_MODEL_FAMILY, MIDSCENE_INSIGHT_MODEL_HTTP_PROXY, MIDSCENE_INSIGHT_MODEL_INIT_CONFIG_JSON, MIDSCENE_INSIGHT_MODEL_NAME, MIDSCENE_INSIGHT_MODEL_PROTOCOL, MIDSCENE_INSIGHT_MODEL_REASONING_BUDGET, MIDSCENE_INSIGHT_MODEL_REASONING_EFFORT, MIDSCENE_INSIGHT_MODEL_REASONING_ENABLED, MIDSCENE_INSIGHT_MODEL_RESPONSE_FORMAT, MIDSCENE_INSIGHT_MODEL_RETRY_COUNT, MIDSCENE_INSIGHT_MODEL_RETRY_INTERVAL, MIDSCENE_INSIGHT_MODEL_SOCKS_PROXY, MIDSCENE_INSIGHT_MODEL_STREAM_MODE, MIDSCENE_INSIGHT_MODEL_TEMPERATURE, MIDSCENE_INSIGHT_MODEL_TIMEOUT, MIDSCENE_IOS_DEVICE_CLASS_OVERRIDE, MIDSCENE_IOS_DEVICE_UDID, MIDSCENE_IOS_SIMULATOR_UDID, MIDSCENE_LANGFUSE_DEBUG, MIDSCENE_LANGSMITH_DEBUG, MIDSCENE_LOCATE_MODEL_API_KEY, MIDSCENE_LOCATE_MODEL_AUTH_MODE, MIDSCENE_LOCATE_MODEL_BASE_URL, MIDSCENE_LOCATE_MODEL_EXTRA_BODY_JSON, MIDSCENE_LOCATE_MODEL_FAMILY, MIDSCENE_LOCATE_MODEL_HTTP_PROXY, MIDSCENE_LOCATE_MODEL_INIT_CONFIG_JSON, MIDSCENE_LOCATE_MODEL_NAME, MIDSCENE_LOCATE_MODEL_PROTOCOL, MIDSCENE_LOCATE_MODEL_REASONING_BUDGET, MIDSCENE_LOCATE_MODEL_REASONING_EFFORT, MIDSCENE_LOCATE_MODEL_REASONING_ENABLED, MIDSCENE_LOCATE_MODEL_RESPONSE_FORMAT, MIDSCENE_LOCATE_MODEL_RETRY_COUNT, MIDSCENE_LOCATE_MODEL_RETRY_INTERVAL, MIDSCENE_LOCATE_MODEL_SOCKS_PROXY, MIDSCENE_LOCATE_MODEL_STREAM_MODE, MIDSCENE_LOCATE_MODEL_TEMPERATURE, MIDSCENE_LOCATE_MODEL_TIMEOUT, MIDSCENE_MCP_CHROME_PATH, MIDSCENE_MODEL_API_KEY, MIDSCENE_MODEL_AUTH_MODE, MIDSCENE_MODEL_BASE_URL, MIDSCENE_MODEL_EXTRA_BODY_JSON, MIDSCENE_MODEL_FAMILY, MIDSCENE_MODEL_HTTP_PROXY, MIDSCENE_MODEL_INIT_CONFIG_JSON, MIDSCENE_MODEL_NAME, MIDSCENE_MODEL_PROTOCOL, MIDSCENE_MODEL_REASONING_BUDGET, MIDSCENE_MODEL_REASONING_EFFORT, MIDSCENE_MODEL_REASONING_ENABLED, MIDSCENE_MODEL_RESPONSE_FORMAT, MIDSCENE_MODEL_RETRY_COUNT, MIDSCENE_MODEL_RETRY_INTERVAL, MIDSCENE_MODEL_SOCKS_PROXY, MIDSCENE_MODEL_STREAM_MODE, MIDSCENE_MODEL_TEMPERATURE, MIDSCENE_MODEL_TIMEOUT, MIDSCENE_OPENAI_HTTP_PROXY, MIDSCENE_OPENAI_INIT_CONFIG_JSON, MIDSCENE_OPENAI_SOCKS_PROXY, MIDSCENE_PLANNING_MODEL_API_KEY, MIDSCENE_PLANNING_MODEL_AUTH_MODE, MIDSCENE_PLANNING_MODEL_BASE_URL, MIDSCENE_PLANNING_MODEL_EXTRA_BODY_JSON, MIDSCENE_PLANNING_MODEL_FAMILY, MIDSCENE_PLANNING_MODEL_HTTP_PROXY, MIDSCENE_PLANNING_MODEL_INIT_CONFIG_JSON, MIDSCENE_PLANNING_MODEL_NAME, MIDSCENE_PLANNING_MODEL_PROTOCOL, MIDSCENE_PLANNING_MODEL_REASONING_BUDGET, MIDSCENE_PLANNING_MODEL_REASONING_EFFORT, MIDSCENE_PLANNING_MODEL_REASONING_ENABLED, MIDSCENE_PLANNING_MODEL_RESPONSE_FORMAT, MIDSCENE_PLANNING_MODEL_RETRY_COUNT, MIDSCENE_PLANNING_MODEL_RETRY_INTERVAL, MIDSCENE_PLANNING_MODEL_SOCKS_PROXY, MIDSCENE_PLANNING_MODEL_STREAM_MODE, MIDSCENE_PLANNING_MODEL_TEMPERATURE, MIDSCENE_PLANNING_MODEL_TIMEOUT, MIDSCENE_PREFERRED_LANGUAGE, MIDSCENE_RECORD_MODEL_CALL, MIDSCENE_REPLANNING_CYCLE_LIMIT, MIDSCENE_REPORT_QUIET, MIDSCENE_REPORT_TAG_NAME, MIDSCENE_RUN_DIR, MIDSCENE_USE_DOUBAO_VISION, MIDSCENE_USE_GEMINI, MIDSCENE_USE_QWEN3_VL, MIDSCENE_USE_QWEN_VL, MIDSCENE_USE_VLM_UI_TARS, MIDSCENE_USE_VL_MODEL, MODEL_ENV_KEYS, MODEL_FAMILY_VALUES, NUMBER_ENV_KEYS, OPENAI_API_KEY, OPENAI_BASE_URL, STRING_ENV_KEYS, types_UITarsModelVersion as UITarsModelVersion, UNUSED_ENV_KEYS };
|
package/dist/es/logger.mjs
CHANGED
|
@@ -2,9 +2,35 @@ import node_fs from "node:fs";
|
|
|
2
2
|
import node_path from "node:path";
|
|
3
3
|
import node_util from "node:util";
|
|
4
4
|
import debug from "debug";
|
|
5
|
+
import { createConsoleContext } from "#console-context";
|
|
5
6
|
import { getMidsceneRunSubDir } from "./common.mjs";
|
|
6
7
|
import { ifInNode } from "./utils.mjs";
|
|
7
8
|
const topicPrefix = 'midscene';
|
|
9
|
+
const consoleContextKey = Symbol.for('@midscene/shared/console-context');
|
|
10
|
+
const consoleHost = globalThis;
|
|
11
|
+
consoleHost[consoleContextKey] ??= createConsoleContext();
|
|
12
|
+
const consoleContext = consoleHost[consoleContextKey];
|
|
13
|
+
const runWithConsoleLogHandler = (handler, run)=>consoleContext.run(handler, run);
|
|
14
|
+
const runWithConsoleLogScope = (scope, run)=>{
|
|
15
|
+
const handler = consoleContext.getStore();
|
|
16
|
+
if (!handler) return run();
|
|
17
|
+
return consoleContext.run((entry)=>handler({
|
|
18
|
+
...entry,
|
|
19
|
+
scope: {
|
|
20
|
+
...scope,
|
|
21
|
+
...entry.scope
|
|
22
|
+
}
|
|
23
|
+
}), run);
|
|
24
|
+
};
|
|
25
|
+
function logReport(message) {
|
|
26
|
+
const handler = consoleContext.getStore();
|
|
27
|
+
if (handler) handler({
|
|
28
|
+
type: 'report',
|
|
29
|
+
topic: 'midscene:report',
|
|
30
|
+
message
|
|
31
|
+
});
|
|
32
|
+
else console.log(message);
|
|
33
|
+
}
|
|
8
34
|
const logStreams = new Map();
|
|
9
35
|
const logStreamPaths = new Map();
|
|
10
36
|
let logDirectoryResolver;
|
|
@@ -78,17 +104,38 @@ function writeLogToFile(topic, message) {
|
|
|
78
104
|
backpressuredLogStreams.delete(topicFileName);
|
|
79
105
|
}
|
|
80
106
|
}
|
|
107
|
+
function printConsoleWarning(topic, args, warning) {
|
|
108
|
+
const handler = consoleContext.getStore();
|
|
109
|
+
if (handler) return void handler({
|
|
110
|
+
type: 'warning',
|
|
111
|
+
topic,
|
|
112
|
+
message: node_util.format(...args),
|
|
113
|
+
args,
|
|
114
|
+
...warning ? {
|
|
115
|
+
warning
|
|
116
|
+
} : {}
|
|
117
|
+
});
|
|
118
|
+
try {
|
|
119
|
+
console.warn('[Midscene]', ...args);
|
|
120
|
+
} catch {}
|
|
121
|
+
}
|
|
81
122
|
function getDebug(topic, options) {
|
|
82
123
|
const fullTopic = `${topicPrefix}:${topic}`;
|
|
83
124
|
const withConsole = options?.console ?? false;
|
|
84
125
|
const cacheKey = withConsole ? `${fullTopic}:withConsole` : fullTopic;
|
|
126
|
+
if (withConsole && options?.warning) {
|
|
127
|
+
const baseFn = getDebug(topic);
|
|
128
|
+
const warning = options.warning;
|
|
129
|
+
return (...args)=>{
|
|
130
|
+
baseFn(...args);
|
|
131
|
+
printConsoleWarning(fullTopic, args, warning);
|
|
132
|
+
};
|
|
133
|
+
}
|
|
85
134
|
if (!debugInstances.has(cacheKey)) if (withConsole) {
|
|
86
135
|
const baseFn = getDebug(topic);
|
|
87
136
|
const wrapper = (...args)=>{
|
|
88
137
|
baseFn(...args);
|
|
89
|
-
|
|
90
|
-
console.warn('[Midscene]', ...args);
|
|
91
|
-
} catch {}
|
|
138
|
+
printConsoleWarning(fullTopic, args);
|
|
92
139
|
};
|
|
93
140
|
debugInstances.set(cacheKey, wrapper);
|
|
94
141
|
} else {
|
|
@@ -108,4 +155,4 @@ function enableDebug(topic) {
|
|
|
108
155
|
if (ifInNode) return;
|
|
109
156
|
debug.enable(`${topicPrefix}:${topic}`);
|
|
110
157
|
}
|
|
111
|
-
export { enableDebug, getDebug, setLogDirectoryResolver };
|
|
158
|
+
export { enableDebug, getDebug, logReport, runWithConsoleLogHandler, runWithConsoleLogScope, setLogDirectoryResolver };
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
createConsoleContext: ()=>createConsoleContext
|
|
28
|
+
});
|
|
29
|
+
const external_node_async_hooks_namespaceObject = require("node:async_hooks");
|
|
30
|
+
const createConsoleContext = ()=>new external_node_async_hooks_namespaceObject.AsyncLocalStorage();
|
|
31
|
+
exports.createConsoleContext = __webpack_exports__.createConsoleContext;
|
|
32
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
33
|
+
"createConsoleContext"
|
|
34
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
35
|
+
Object.defineProperty(exports, '__esModule', {
|
|
36
|
+
value: true
|
|
37
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
createConsoleContext: ()=>createConsoleContext
|
|
28
|
+
});
|
|
29
|
+
const createConsoleContext = ()=>({
|
|
30
|
+
getStore: ()=>void 0,
|
|
31
|
+
run: (_store, callback)=>callback()
|
|
32
|
+
});
|
|
33
|
+
exports.createConsoleContext = __webpack_exports__.createConsoleContext;
|
|
34
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
35
|
+
"createConsoleContext"
|
|
36
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
37
|
+
Object.defineProperty(exports, '__esModule', {
|
|
38
|
+
value: true
|
|
39
|
+
});
|
|
@@ -41,6 +41,7 @@ const INSIGHT_MODEL_CONFIG_KEYS = {
|
|
|
41
41
|
extraBody: external_types_js_namespaceObject.MIDSCENE_INSIGHT_MODEL_EXTRA_BODY_JSON,
|
|
42
42
|
protocol: external_types_js_namespaceObject.MIDSCENE_INSIGHT_MODEL_PROTOCOL,
|
|
43
43
|
streamMode: external_types_js_namespaceObject.MIDSCENE_INSIGHT_MODEL_STREAM_MODE,
|
|
44
|
+
authMode: external_types_js_namespaceObject.MIDSCENE_INSIGHT_MODEL_AUTH_MODE,
|
|
44
45
|
modelFamily: external_types_js_namespaceObject.MIDSCENE_INSIGHT_MODEL_FAMILY,
|
|
45
46
|
timeout: external_types_js_namespaceObject.MIDSCENE_INSIGHT_MODEL_TIMEOUT,
|
|
46
47
|
temperature: external_types_js_namespaceObject.MIDSCENE_INSIGHT_MODEL_TEMPERATURE,
|
|
@@ -61,6 +62,7 @@ const LOCATE_MODEL_CONFIG_KEYS = {
|
|
|
61
62
|
extraBody: external_types_js_namespaceObject.MIDSCENE_LOCATE_MODEL_EXTRA_BODY_JSON,
|
|
62
63
|
protocol: external_types_js_namespaceObject.MIDSCENE_LOCATE_MODEL_PROTOCOL,
|
|
63
64
|
streamMode: external_types_js_namespaceObject.MIDSCENE_LOCATE_MODEL_STREAM_MODE,
|
|
65
|
+
authMode: external_types_js_namespaceObject.MIDSCENE_LOCATE_MODEL_AUTH_MODE,
|
|
64
66
|
modelFamily: external_types_js_namespaceObject.MIDSCENE_LOCATE_MODEL_FAMILY,
|
|
65
67
|
timeout: external_types_js_namespaceObject.MIDSCENE_LOCATE_MODEL_TIMEOUT,
|
|
66
68
|
temperature: external_types_js_namespaceObject.MIDSCENE_LOCATE_MODEL_TEMPERATURE,
|
|
@@ -81,6 +83,7 @@ const PLANNING_MODEL_CONFIG_KEYS = {
|
|
|
81
83
|
extraBody: external_types_js_namespaceObject.MIDSCENE_PLANNING_MODEL_EXTRA_BODY_JSON,
|
|
82
84
|
protocol: external_types_js_namespaceObject.MIDSCENE_PLANNING_MODEL_PROTOCOL,
|
|
83
85
|
streamMode: external_types_js_namespaceObject.MIDSCENE_PLANNING_MODEL_STREAM_MODE,
|
|
86
|
+
authMode: external_types_js_namespaceObject.MIDSCENE_PLANNING_MODEL_AUTH_MODE,
|
|
84
87
|
modelFamily: external_types_js_namespaceObject.MIDSCENE_PLANNING_MODEL_FAMILY,
|
|
85
88
|
timeout: external_types_js_namespaceObject.MIDSCENE_PLANNING_MODEL_TIMEOUT,
|
|
86
89
|
temperature: external_types_js_namespaceObject.MIDSCENE_PLANNING_MODEL_TEMPERATURE,
|
|
@@ -101,6 +104,7 @@ const DEFAULT_MODEL_CONFIG_KEYS = {
|
|
|
101
104
|
extraBody: external_types_js_namespaceObject.MIDSCENE_MODEL_EXTRA_BODY_JSON,
|
|
102
105
|
protocol: external_types_js_namespaceObject.MIDSCENE_MODEL_PROTOCOL,
|
|
103
106
|
streamMode: external_types_js_namespaceObject.MIDSCENE_MODEL_STREAM_MODE,
|
|
107
|
+
authMode: external_types_js_namespaceObject.MIDSCENE_MODEL_AUTH_MODE,
|
|
104
108
|
modelFamily: external_types_js_namespaceObject.MIDSCENE_MODEL_FAMILY,
|
|
105
109
|
timeout: external_types_js_namespaceObject.MIDSCENE_MODEL_TIMEOUT,
|
|
106
110
|
temperature: external_types_js_namespaceObject.MIDSCENE_MODEL_TEMPERATURE,
|
|
@@ -121,6 +125,7 @@ const DEFAULT_MODEL_CONFIG_KEYS_LEGACY = {
|
|
|
121
125
|
extraBody: external_types_js_namespaceObject.MIDSCENE_MODEL_EXTRA_BODY_JSON,
|
|
122
126
|
protocol: external_types_js_namespaceObject.MIDSCENE_MODEL_PROTOCOL,
|
|
123
127
|
streamMode: external_types_js_namespaceObject.MIDSCENE_MODEL_STREAM_MODE,
|
|
128
|
+
authMode: external_types_js_namespaceObject.MIDSCENE_MODEL_AUTH_MODE,
|
|
124
129
|
modelFamily: 'DEFAULT_MODEL_CONFIG_KEYS has no modelFamily key',
|
|
125
130
|
timeout: external_types_js_namespaceObject.MIDSCENE_MODEL_TIMEOUT,
|
|
126
131
|
temperature: external_types_js_namespaceObject.MIDSCENE_MODEL_TEMPERATURE,
|
|
@@ -46,7 +46,7 @@ class ModelConfigManager {
|
|
|
46
46
|
configMap = this.normalizeModelConfig(this.modelConfig);
|
|
47
47
|
} else configMap = this.globalConfigManager?.getAllEnvConfig() || {};
|
|
48
48
|
const defaultConfig = (0, external_parse_model_config_js_namespaceObject.decideModelConfigFromIntentConfig)('default', configMap);
|
|
49
|
-
if (!defaultConfig) throw new Error('Model configuration is incomplete: model name (MIDSCENE_MODEL_NAME) is required. See https://midscenejs.com/model-
|
|
49
|
+
if (!defaultConfig) throw new Error('Model configuration is incomplete: model name (MIDSCENE_MODEL_NAME) is required. See https://midscenejs.com/model-api-setup');
|
|
50
50
|
if ('jev' === defaultConfig.modelFamily) throw new Error('Jev cannot be the default model. Configure a general-purpose MIDSCENE_MODEL_FAMILY and use Jev in Locate, Planning, or Insight.');
|
|
51
51
|
const insightConfig = (0, external_parse_model_config_js_namespaceObject.decideModelConfigFromIntentConfig)('insight', configMap);
|
|
52
52
|
const planningConfig = (0, external_parse_model_config_js_namespaceObject.decideModelConfigFromIntentConfig)('planning', configMap);
|
|
@@ -105,7 +105,7 @@ class ModelConfigManager {
|
|
|
105
105
|
}
|
|
106
106
|
throwErrorIfNonVLModel() {
|
|
107
107
|
const modelConfig = this.getModelConfig('locate');
|
|
108
|
-
if (!modelConfig.modelFamily) throw new Error(`${'locate' === modelConfig.slot ? 'MIDSCENE_LOCATE_MODEL_FAMILY' : 'MIDSCENE_MODEL_FAMILY'} is not set to a multimodal model with UI localization, so element localization cannot be achieved. Check your model configuration. See https://midscenejs.com/model-
|
|
108
|
+
if (!modelConfig.modelFamily) throw new Error(`${'locate' === modelConfig.slot ? 'MIDSCENE_LOCATE_MODEL_FAMILY' : 'MIDSCENE_MODEL_FAMILY'} is not set to a multimodal model with UI localization, so element localization cannot be achieved. Check your model configuration. See https://midscenejs.com/model-api-setup`);
|
|
109
109
|
}
|
|
110
110
|
constructor(modelConfig, createOpenAIClientFn){
|
|
111
111
|
_define_property(this, "modelConfigMap", void 0);
|
|
@@ -36,8 +36,8 @@ const external_logger_js_namespaceObject = require("../logger.js");
|
|
|
36
36
|
const external_utils_js_namespaceObject = require("../utils.js");
|
|
37
37
|
const external_helper_js_namespaceObject = require("./helper.js");
|
|
38
38
|
const external_init_debug_js_namespaceObject = require("./init-debug.js");
|
|
39
|
-
const MODEL_CONFIG_DOC_URL = 'https://midscenejs.com/model-
|
|
40
|
-
const getCurrentVersion = ()=>"1.16.
|
|
39
|
+
const MODEL_CONFIG_DOC_URL = 'https://midscenejs.com/model-api-setup.html';
|
|
40
|
+
const getCurrentVersion = ()=>"1.16.5";
|
|
41
41
|
const getInvalidModelFamilyMessage = (modelFamily)=>`Invalid MIDSCENE_MODEL_FAMILY value: ${modelFamily}. Current version v${getCurrentVersion()} accepts the following model families: ${external_types_js_namespaceObject.MODEL_FAMILY_VALUES.join(', ')}. You can also visit ${MODEL_CONFIG_DOC_URL} for the latest configuration information.`;
|
|
42
42
|
const KEYS_MAP = {
|
|
43
43
|
locate: external_constants_js_namespaceObject.LOCATE_MODEL_CONFIG_KEYS,
|
|
@@ -122,6 +122,11 @@ const parseOpenaiSdkConfig = ({ keys, provider, useLegacyLogic = false })=>{
|
|
|
122
122
|
return {
|
|
123
123
|
socksProxy,
|
|
124
124
|
httpProxy,
|
|
125
|
+
authMode: (()=>{
|
|
126
|
+
const value = provider[keys.authMode]?.trim() ?? 'api-key';
|
|
127
|
+
if ('api-key' === value || 'siwc' === value) return value;
|
|
128
|
+
throw new Error(`Invalid ${keys.authMode}: "${value}". Expected "api-key" or "siwc".`);
|
|
129
|
+
})(),
|
|
125
130
|
openaiBaseURL,
|
|
126
131
|
openaiApiKey,
|
|
127
132
|
openaiExtraConfig: normalizeOpenaiExtraConfig(openaiExtraConfig),
|
|
@@ -202,8 +207,8 @@ const decideModelConfigFromIntentConfig = (intent, configMap)=>{
|
|
|
202
207
|
debugLog('decideModelConfig result by agent.modelConfig() with intent', intent, (0, external_helper_js_namespaceObject.maskConfig)({
|
|
203
208
|
...finalResult
|
|
204
209
|
}));
|
|
205
|
-
(0, external_utils_js_namespaceObject.assert)(finalResult.openaiBaseURL, `failed to get base URL of model (intent=${intent}). See https://midscenejs.com/model-
|
|
206
|
-
if (!finalResult.modelName) console.warn(`modelName is not set for intent ${intent}, this may cause unexpected behavior. See https://midscenejs.com/model-
|
|
210
|
+
(0, external_utils_js_namespaceObject.assert)('siwc' === finalResult.authMode || finalResult.openaiBaseURL, `failed to get base URL of model (intent=${intent}). See https://midscenejs.com/model-api-setup`);
|
|
211
|
+
if (!finalResult.modelName) console.warn(`modelName is not set for intent ${intent}, this may cause unexpected behavior. See https://midscenejs.com/model-api-setup`);
|
|
207
212
|
return finalResult;
|
|
208
213
|
};
|
|
209
214
|
exports.decideModelConfigFromIntentConfig = __webpack_exports__.decideModelConfigFromIntentConfig;
|
package/dist/lib/env/types.js
CHANGED
|
@@ -43,6 +43,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
43
43
|
MIDSCENE_DEBUG_MODEL_PROFILE: ()=>MIDSCENE_DEBUG_MODEL_PROFILE,
|
|
44
44
|
MIDSCENE_DEBUG_MODEL_RESPONSE: ()=>MIDSCENE_DEBUG_MODEL_RESPONSE,
|
|
45
45
|
MIDSCENE_INSIGHT_MODEL_API_KEY: ()=>MIDSCENE_INSIGHT_MODEL_API_KEY,
|
|
46
|
+
MIDSCENE_INSIGHT_MODEL_AUTH_MODE: ()=>MIDSCENE_INSIGHT_MODEL_AUTH_MODE,
|
|
46
47
|
MIDSCENE_INSIGHT_MODEL_BASE_URL: ()=>MIDSCENE_INSIGHT_MODEL_BASE_URL,
|
|
47
48
|
MIDSCENE_INSIGHT_MODEL_EXTRA_BODY_JSON: ()=>MIDSCENE_INSIGHT_MODEL_EXTRA_BODY_JSON,
|
|
48
49
|
MIDSCENE_INSIGHT_MODEL_FAMILY: ()=>MIDSCENE_INSIGHT_MODEL_FAMILY,
|
|
@@ -66,6 +67,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
66
67
|
MIDSCENE_LANGFUSE_DEBUG: ()=>MIDSCENE_LANGFUSE_DEBUG,
|
|
67
68
|
MIDSCENE_LANGSMITH_DEBUG: ()=>MIDSCENE_LANGSMITH_DEBUG,
|
|
68
69
|
MIDSCENE_LOCATE_MODEL_API_KEY: ()=>MIDSCENE_LOCATE_MODEL_API_KEY,
|
|
70
|
+
MIDSCENE_LOCATE_MODEL_AUTH_MODE: ()=>MIDSCENE_LOCATE_MODEL_AUTH_MODE,
|
|
69
71
|
MIDSCENE_LOCATE_MODEL_BASE_URL: ()=>MIDSCENE_LOCATE_MODEL_BASE_URL,
|
|
70
72
|
MIDSCENE_LOCATE_MODEL_EXTRA_BODY_JSON: ()=>MIDSCENE_LOCATE_MODEL_EXTRA_BODY_JSON,
|
|
71
73
|
MIDSCENE_LOCATE_MODEL_FAMILY: ()=>MIDSCENE_LOCATE_MODEL_FAMILY,
|
|
@@ -85,6 +87,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
85
87
|
MIDSCENE_LOCATE_MODEL_TIMEOUT: ()=>MIDSCENE_LOCATE_MODEL_TIMEOUT,
|
|
86
88
|
MIDSCENE_MCP_CHROME_PATH: ()=>MIDSCENE_MCP_CHROME_PATH,
|
|
87
89
|
MIDSCENE_MODEL_API_KEY: ()=>MIDSCENE_MODEL_API_KEY,
|
|
90
|
+
MIDSCENE_MODEL_AUTH_MODE: ()=>MIDSCENE_MODEL_AUTH_MODE,
|
|
88
91
|
MIDSCENE_MODEL_BASE_URL: ()=>MIDSCENE_MODEL_BASE_URL,
|
|
89
92
|
MIDSCENE_MODEL_EXTRA_BODY_JSON: ()=>MIDSCENE_MODEL_EXTRA_BODY_JSON,
|
|
90
93
|
MIDSCENE_MODEL_FAMILY: ()=>MIDSCENE_MODEL_FAMILY,
|
|
@@ -106,6 +109,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
106
109
|
MIDSCENE_OPENAI_INIT_CONFIG_JSON: ()=>MIDSCENE_OPENAI_INIT_CONFIG_JSON,
|
|
107
110
|
MIDSCENE_OPENAI_SOCKS_PROXY: ()=>MIDSCENE_OPENAI_SOCKS_PROXY,
|
|
108
111
|
MIDSCENE_PLANNING_MODEL_API_KEY: ()=>MIDSCENE_PLANNING_MODEL_API_KEY,
|
|
112
|
+
MIDSCENE_PLANNING_MODEL_AUTH_MODE: ()=>MIDSCENE_PLANNING_MODEL_AUTH_MODE,
|
|
109
113
|
MIDSCENE_PLANNING_MODEL_BASE_URL: ()=>MIDSCENE_PLANNING_MODEL_BASE_URL,
|
|
110
114
|
MIDSCENE_PLANNING_MODEL_EXTRA_BODY_JSON: ()=>MIDSCENE_PLANNING_MODEL_EXTRA_BODY_JSON,
|
|
111
115
|
MIDSCENE_PLANNING_MODEL_FAMILY: ()=>MIDSCENE_PLANNING_MODEL_FAMILY,
|
|
@@ -144,6 +148,10 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
144
148
|
UITarsModelVersion: ()=>UITarsModelVersion,
|
|
145
149
|
UNUSED_ENV_KEYS: ()=>UNUSED_ENV_KEYS
|
|
146
150
|
});
|
|
151
|
+
const MIDSCENE_MODEL_AUTH_MODE = 'MIDSCENE_MODEL_AUTH_MODE';
|
|
152
|
+
const MIDSCENE_PLANNING_MODEL_AUTH_MODE = 'MIDSCENE_PLANNING_MODEL_AUTH_MODE';
|
|
153
|
+
const MIDSCENE_LOCATE_MODEL_AUTH_MODE = 'MIDSCENE_LOCATE_MODEL_AUTH_MODE';
|
|
154
|
+
const MIDSCENE_INSIGHT_MODEL_AUTH_MODE = 'MIDSCENE_INSIGHT_MODEL_AUTH_MODE';
|
|
147
155
|
const MIDSCENE_MODEL_INIT_CONFIG_JSON = 'MIDSCENE_MODEL_INIT_CONFIG_JSON';
|
|
148
156
|
const MIDSCENE_MODEL_EXTRA_BODY_JSON = 'MIDSCENE_MODEL_EXTRA_BODY_JSON';
|
|
149
157
|
const MIDSCENE_MODEL_NAME = 'MIDSCENE_MODEL_NAME';
|
|
@@ -294,6 +302,10 @@ const GLOBAL_ENV_KEYS = [
|
|
|
294
302
|
...STRING_ENV_KEYS
|
|
295
303
|
];
|
|
296
304
|
const MODEL_ENV_KEYS = [
|
|
305
|
+
MIDSCENE_MODEL_AUTH_MODE,
|
|
306
|
+
MIDSCENE_PLANNING_MODEL_AUTH_MODE,
|
|
307
|
+
MIDSCENE_LOCATE_MODEL_AUTH_MODE,
|
|
308
|
+
MIDSCENE_INSIGHT_MODEL_AUTH_MODE,
|
|
297
309
|
MIDSCENE_INSIGHT_MODEL_STREAM_MODE,
|
|
298
310
|
MIDSCENE_PLANNING_MODEL_STREAM_MODE,
|
|
299
311
|
MIDSCENE_LOCATE_MODEL_STREAM_MODE,
|
|
@@ -433,6 +445,7 @@ exports.MIDSCENE_DEBUG_MODE = __webpack_exports__.MIDSCENE_DEBUG_MODE;
|
|
|
433
445
|
exports.MIDSCENE_DEBUG_MODEL_PROFILE = __webpack_exports__.MIDSCENE_DEBUG_MODEL_PROFILE;
|
|
434
446
|
exports.MIDSCENE_DEBUG_MODEL_RESPONSE = __webpack_exports__.MIDSCENE_DEBUG_MODEL_RESPONSE;
|
|
435
447
|
exports.MIDSCENE_INSIGHT_MODEL_API_KEY = __webpack_exports__.MIDSCENE_INSIGHT_MODEL_API_KEY;
|
|
448
|
+
exports.MIDSCENE_INSIGHT_MODEL_AUTH_MODE = __webpack_exports__.MIDSCENE_INSIGHT_MODEL_AUTH_MODE;
|
|
436
449
|
exports.MIDSCENE_INSIGHT_MODEL_BASE_URL = __webpack_exports__.MIDSCENE_INSIGHT_MODEL_BASE_URL;
|
|
437
450
|
exports.MIDSCENE_INSIGHT_MODEL_EXTRA_BODY_JSON = __webpack_exports__.MIDSCENE_INSIGHT_MODEL_EXTRA_BODY_JSON;
|
|
438
451
|
exports.MIDSCENE_INSIGHT_MODEL_FAMILY = __webpack_exports__.MIDSCENE_INSIGHT_MODEL_FAMILY;
|
|
@@ -456,6 +469,7 @@ exports.MIDSCENE_IOS_SIMULATOR_UDID = __webpack_exports__.MIDSCENE_IOS_SIMULATOR
|
|
|
456
469
|
exports.MIDSCENE_LANGFUSE_DEBUG = __webpack_exports__.MIDSCENE_LANGFUSE_DEBUG;
|
|
457
470
|
exports.MIDSCENE_LANGSMITH_DEBUG = __webpack_exports__.MIDSCENE_LANGSMITH_DEBUG;
|
|
458
471
|
exports.MIDSCENE_LOCATE_MODEL_API_KEY = __webpack_exports__.MIDSCENE_LOCATE_MODEL_API_KEY;
|
|
472
|
+
exports.MIDSCENE_LOCATE_MODEL_AUTH_MODE = __webpack_exports__.MIDSCENE_LOCATE_MODEL_AUTH_MODE;
|
|
459
473
|
exports.MIDSCENE_LOCATE_MODEL_BASE_URL = __webpack_exports__.MIDSCENE_LOCATE_MODEL_BASE_URL;
|
|
460
474
|
exports.MIDSCENE_LOCATE_MODEL_EXTRA_BODY_JSON = __webpack_exports__.MIDSCENE_LOCATE_MODEL_EXTRA_BODY_JSON;
|
|
461
475
|
exports.MIDSCENE_LOCATE_MODEL_FAMILY = __webpack_exports__.MIDSCENE_LOCATE_MODEL_FAMILY;
|
|
@@ -475,6 +489,7 @@ exports.MIDSCENE_LOCATE_MODEL_TEMPERATURE = __webpack_exports__.MIDSCENE_LOCATE_
|
|
|
475
489
|
exports.MIDSCENE_LOCATE_MODEL_TIMEOUT = __webpack_exports__.MIDSCENE_LOCATE_MODEL_TIMEOUT;
|
|
476
490
|
exports.MIDSCENE_MCP_CHROME_PATH = __webpack_exports__.MIDSCENE_MCP_CHROME_PATH;
|
|
477
491
|
exports.MIDSCENE_MODEL_API_KEY = __webpack_exports__.MIDSCENE_MODEL_API_KEY;
|
|
492
|
+
exports.MIDSCENE_MODEL_AUTH_MODE = __webpack_exports__.MIDSCENE_MODEL_AUTH_MODE;
|
|
478
493
|
exports.MIDSCENE_MODEL_BASE_URL = __webpack_exports__.MIDSCENE_MODEL_BASE_URL;
|
|
479
494
|
exports.MIDSCENE_MODEL_EXTRA_BODY_JSON = __webpack_exports__.MIDSCENE_MODEL_EXTRA_BODY_JSON;
|
|
480
495
|
exports.MIDSCENE_MODEL_FAMILY = __webpack_exports__.MIDSCENE_MODEL_FAMILY;
|
|
@@ -496,6 +511,7 @@ exports.MIDSCENE_OPENAI_HTTP_PROXY = __webpack_exports__.MIDSCENE_OPENAI_HTTP_PR
|
|
|
496
511
|
exports.MIDSCENE_OPENAI_INIT_CONFIG_JSON = __webpack_exports__.MIDSCENE_OPENAI_INIT_CONFIG_JSON;
|
|
497
512
|
exports.MIDSCENE_OPENAI_SOCKS_PROXY = __webpack_exports__.MIDSCENE_OPENAI_SOCKS_PROXY;
|
|
498
513
|
exports.MIDSCENE_PLANNING_MODEL_API_KEY = __webpack_exports__.MIDSCENE_PLANNING_MODEL_API_KEY;
|
|
514
|
+
exports.MIDSCENE_PLANNING_MODEL_AUTH_MODE = __webpack_exports__.MIDSCENE_PLANNING_MODEL_AUTH_MODE;
|
|
499
515
|
exports.MIDSCENE_PLANNING_MODEL_BASE_URL = __webpack_exports__.MIDSCENE_PLANNING_MODEL_BASE_URL;
|
|
500
516
|
exports.MIDSCENE_PLANNING_MODEL_EXTRA_BODY_JSON = __webpack_exports__.MIDSCENE_PLANNING_MODEL_EXTRA_BODY_JSON;
|
|
501
517
|
exports.MIDSCENE_PLANNING_MODEL_FAMILY = __webpack_exports__.MIDSCENE_PLANNING_MODEL_FAMILY;
|
|
@@ -553,6 +569,7 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
|
553
569
|
"MIDSCENE_DEBUG_MODEL_PROFILE",
|
|
554
570
|
"MIDSCENE_DEBUG_MODEL_RESPONSE",
|
|
555
571
|
"MIDSCENE_INSIGHT_MODEL_API_KEY",
|
|
572
|
+
"MIDSCENE_INSIGHT_MODEL_AUTH_MODE",
|
|
556
573
|
"MIDSCENE_INSIGHT_MODEL_BASE_URL",
|
|
557
574
|
"MIDSCENE_INSIGHT_MODEL_EXTRA_BODY_JSON",
|
|
558
575
|
"MIDSCENE_INSIGHT_MODEL_FAMILY",
|
|
@@ -576,6 +593,7 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
|
576
593
|
"MIDSCENE_LANGFUSE_DEBUG",
|
|
577
594
|
"MIDSCENE_LANGSMITH_DEBUG",
|
|
578
595
|
"MIDSCENE_LOCATE_MODEL_API_KEY",
|
|
596
|
+
"MIDSCENE_LOCATE_MODEL_AUTH_MODE",
|
|
579
597
|
"MIDSCENE_LOCATE_MODEL_BASE_URL",
|
|
580
598
|
"MIDSCENE_LOCATE_MODEL_EXTRA_BODY_JSON",
|
|
581
599
|
"MIDSCENE_LOCATE_MODEL_FAMILY",
|
|
@@ -595,6 +613,7 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
|
595
613
|
"MIDSCENE_LOCATE_MODEL_TIMEOUT",
|
|
596
614
|
"MIDSCENE_MCP_CHROME_PATH",
|
|
597
615
|
"MIDSCENE_MODEL_API_KEY",
|
|
616
|
+
"MIDSCENE_MODEL_AUTH_MODE",
|
|
598
617
|
"MIDSCENE_MODEL_BASE_URL",
|
|
599
618
|
"MIDSCENE_MODEL_EXTRA_BODY_JSON",
|
|
600
619
|
"MIDSCENE_MODEL_FAMILY",
|
|
@@ -616,6 +635,7 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
|
616
635
|
"MIDSCENE_OPENAI_INIT_CONFIG_JSON",
|
|
617
636
|
"MIDSCENE_OPENAI_SOCKS_PROXY",
|
|
618
637
|
"MIDSCENE_PLANNING_MODEL_API_KEY",
|
|
638
|
+
"MIDSCENE_PLANNING_MODEL_AUTH_MODE",
|
|
619
639
|
"MIDSCENE_PLANNING_MODEL_BASE_URL",
|
|
620
640
|
"MIDSCENE_PLANNING_MODEL_EXTRA_BODY_JSON",
|
|
621
641
|
"MIDSCENE_PLANNING_MODEL_FAMILY",
|
package/dist/lib/logger.js
CHANGED
|
@@ -33,7 +33,10 @@ var __webpack_require__ = {};
|
|
|
33
33
|
var __webpack_exports__ = {};
|
|
34
34
|
__webpack_require__.r(__webpack_exports__);
|
|
35
35
|
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
+
logReport: ()=>logReport,
|
|
36
37
|
enableDebug: ()=>enableDebug,
|
|
38
|
+
runWithConsoleLogHandler: ()=>runWithConsoleLogHandler,
|
|
39
|
+
runWithConsoleLogScope: ()=>runWithConsoleLogScope,
|
|
37
40
|
setLogDirectoryResolver: ()=>setLogDirectoryResolver,
|
|
38
41
|
getDebug: ()=>getDebug
|
|
39
42
|
});
|
|
@@ -45,9 +48,35 @@ const external_node_util_namespaceObject = require("node:util");
|
|
|
45
48
|
var external_node_util_default = /*#__PURE__*/ __webpack_require__.n(external_node_util_namespaceObject);
|
|
46
49
|
const external_debug_namespaceObject = require("debug");
|
|
47
50
|
var external_debug_default = /*#__PURE__*/ __webpack_require__.n(external_debug_namespaceObject);
|
|
51
|
+
const external_console_context_namespaceObject = require("#console-context");
|
|
48
52
|
const external_common_js_namespaceObject = require("./common.js");
|
|
49
53
|
const external_utils_js_namespaceObject = require("./utils.js");
|
|
50
54
|
const topicPrefix = 'midscene';
|
|
55
|
+
const consoleContextKey = Symbol.for('@midscene/shared/console-context');
|
|
56
|
+
const consoleHost = globalThis;
|
|
57
|
+
consoleHost[consoleContextKey] ??= (0, external_console_context_namespaceObject.createConsoleContext)();
|
|
58
|
+
const consoleContext = consoleHost[consoleContextKey];
|
|
59
|
+
const runWithConsoleLogHandler = (handler, run)=>consoleContext.run(handler, run);
|
|
60
|
+
const runWithConsoleLogScope = (scope, run)=>{
|
|
61
|
+
const handler = consoleContext.getStore();
|
|
62
|
+
if (!handler) return run();
|
|
63
|
+
return consoleContext.run((entry)=>handler({
|
|
64
|
+
...entry,
|
|
65
|
+
scope: {
|
|
66
|
+
...scope,
|
|
67
|
+
...entry.scope
|
|
68
|
+
}
|
|
69
|
+
}), run);
|
|
70
|
+
};
|
|
71
|
+
function logReport(message) {
|
|
72
|
+
const handler = consoleContext.getStore();
|
|
73
|
+
if (handler) handler({
|
|
74
|
+
type: 'report',
|
|
75
|
+
topic: 'midscene:report',
|
|
76
|
+
message
|
|
77
|
+
});
|
|
78
|
+
else console.log(message);
|
|
79
|
+
}
|
|
51
80
|
const logStreams = new Map();
|
|
52
81
|
const logStreamPaths = new Map();
|
|
53
82
|
let logDirectoryResolver;
|
|
@@ -121,17 +150,38 @@ function writeLogToFile(topic, message) {
|
|
|
121
150
|
backpressuredLogStreams.delete(topicFileName);
|
|
122
151
|
}
|
|
123
152
|
}
|
|
153
|
+
function printConsoleWarning(topic, args, warning) {
|
|
154
|
+
const handler = consoleContext.getStore();
|
|
155
|
+
if (handler) return void handler({
|
|
156
|
+
type: 'warning',
|
|
157
|
+
topic,
|
|
158
|
+
message: external_node_util_default().format(...args),
|
|
159
|
+
args,
|
|
160
|
+
...warning ? {
|
|
161
|
+
warning
|
|
162
|
+
} : {}
|
|
163
|
+
});
|
|
164
|
+
try {
|
|
165
|
+
console.warn('[Midscene]', ...args);
|
|
166
|
+
} catch {}
|
|
167
|
+
}
|
|
124
168
|
function getDebug(topic, options) {
|
|
125
169
|
const fullTopic = `${topicPrefix}:${topic}`;
|
|
126
170
|
const withConsole = options?.console ?? false;
|
|
127
171
|
const cacheKey = withConsole ? `${fullTopic}:withConsole` : fullTopic;
|
|
172
|
+
if (withConsole && options?.warning) {
|
|
173
|
+
const baseFn = getDebug(topic);
|
|
174
|
+
const warning = options.warning;
|
|
175
|
+
return (...args)=>{
|
|
176
|
+
baseFn(...args);
|
|
177
|
+
printConsoleWarning(fullTopic, args, warning);
|
|
178
|
+
};
|
|
179
|
+
}
|
|
128
180
|
if (!debugInstances.has(cacheKey)) if (withConsole) {
|
|
129
181
|
const baseFn = getDebug(topic);
|
|
130
182
|
const wrapper = (...args)=>{
|
|
131
183
|
baseFn(...args);
|
|
132
|
-
|
|
133
|
-
console.warn('[Midscene]', ...args);
|
|
134
|
-
} catch {}
|
|
184
|
+
printConsoleWarning(fullTopic, args);
|
|
135
185
|
};
|
|
136
186
|
debugInstances.set(cacheKey, wrapper);
|
|
137
187
|
} else {
|
|
@@ -153,10 +203,16 @@ function enableDebug(topic) {
|
|
|
153
203
|
}
|
|
154
204
|
exports.enableDebug = __webpack_exports__.enableDebug;
|
|
155
205
|
exports.getDebug = __webpack_exports__.getDebug;
|
|
206
|
+
exports.logReport = __webpack_exports__.logReport;
|
|
207
|
+
exports.runWithConsoleLogHandler = __webpack_exports__.runWithConsoleLogHandler;
|
|
208
|
+
exports.runWithConsoleLogScope = __webpack_exports__.runWithConsoleLogScope;
|
|
156
209
|
exports.setLogDirectoryResolver = __webpack_exports__.setLogDirectoryResolver;
|
|
157
210
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
158
211
|
"enableDebug",
|
|
159
212
|
"getDebug",
|
|
213
|
+
"logReport",
|
|
214
|
+
"runWithConsoleLogHandler",
|
|
215
|
+
"runWithConsoleLogScope",
|
|
160
216
|
"setLogDirectoryResolver"
|
|
161
217
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
162
218
|
Object.defineProperty(exports, '__esModule', {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"console-context.node.d.ts","sourceRoot":"","sources":["../../src/console-context.node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,eAAO,MAAM,oBAAoB,GAAI,CAAC,2BAAiC,CAAC"}
|