@midscene/shared 1.15.5 → 1.15.6
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 +26 -2
- package/dist/es/env/global-config-manager.mjs +1 -6
- package/dist/es/env/model-config-manager.mjs +10 -2
- package/dist/es/env/parse-model-config.mjs +8 -2
- package/dist/es/env/types.mjs +43 -2
- package/dist/es/img/index.mjs +2 -2
- package/dist/es/img/transform.mjs +52 -1
- package/dist/lib/env/constants.js +27 -0
- package/dist/lib/env/global-config-manager.js +0 -5
- package/dist/lib/env/model-config-manager.js +10 -2
- package/dist/lib/env/parse-model-config.js +7 -1
- package/dist/lib/env/types.js +102 -1
- package/dist/lib/img/index.js +3 -0
- package/dist/lib/img/transform.js +54 -0
- package/dist/types/env/constants.d.ts +2 -0
- package/dist/types/env/constants.d.ts.map +1 -1
- package/dist/types/env/global-config-manager.d.ts.map +1 -1
- package/dist/types/env/model-config-manager.d.ts.map +1 -1
- package/dist/types/env/parse-model-config.d.ts +2 -2
- package/dist/types/env/parse-model-config.d.ts.map +1 -1
- package/dist/types/env/types.d.ts +48 -8
- package/dist/types/env/types.d.ts.map +1 -1
- package/dist/types/img/index.d.ts +1 -1
- package/dist/types/img/index.d.ts.map +1 -1
- package/dist/types/img/transform.d.ts +6 -0
- package/dist/types/img/transform.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/env/constants.ts +65 -0
- package/src/env/global-config-manager.ts +0 -10
- package/src/env/model-config-manager.ts +17 -3
- package/src/env/parse-model-config.ts +12 -0
- package/src/env/types.ts +93 -6
- package/src/img/index.ts +1 -0
- package/src/img/transform.ts +67 -0
|
@@ -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_TEMPERATURE, MIDSCENE_INSIGHT_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_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_TEMPERATURE, MIDSCENE_PLANNING_MODEL_TIMEOUT, OPENAI_API_KEY, OPENAI_BASE_URL } from "./types.mjs";
|
|
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";
|
|
2
2
|
const INSIGHT_MODEL_CONFIG_KEYS = {
|
|
3
3
|
modelName: MIDSCENE_INSIGHT_MODEL_NAME,
|
|
4
4
|
socksProxy: MIDSCENE_INSIGHT_MODEL_SOCKS_PROXY,
|
|
@@ -8,6 +8,7 @@ const INSIGHT_MODEL_CONFIG_KEYS = {
|
|
|
8
8
|
openaiExtraConfig: MIDSCENE_INSIGHT_MODEL_INIT_CONFIG_JSON,
|
|
9
9
|
extraBody: MIDSCENE_INSIGHT_MODEL_EXTRA_BODY_JSON,
|
|
10
10
|
protocol: MIDSCENE_INSIGHT_MODEL_PROTOCOL,
|
|
11
|
+
streamMode: MIDSCENE_INSIGHT_MODEL_STREAM_MODE,
|
|
11
12
|
modelFamily: MIDSCENE_INSIGHT_MODEL_FAMILY,
|
|
12
13
|
timeout: MIDSCENE_INSIGHT_MODEL_TIMEOUT,
|
|
13
14
|
temperature: MIDSCENE_INSIGHT_MODEL_TEMPERATURE,
|
|
@@ -18,6 +19,26 @@ const INSIGHT_MODEL_CONFIG_KEYS = {
|
|
|
18
19
|
reasoningBudget: MIDSCENE_INSIGHT_MODEL_REASONING_BUDGET,
|
|
19
20
|
responseFormat: MIDSCENE_INSIGHT_MODEL_RESPONSE_FORMAT
|
|
20
21
|
};
|
|
22
|
+
const LOCATE_MODEL_CONFIG_KEYS = {
|
|
23
|
+
modelName: MIDSCENE_LOCATE_MODEL_NAME,
|
|
24
|
+
socksProxy: MIDSCENE_LOCATE_MODEL_SOCKS_PROXY,
|
|
25
|
+
httpProxy: MIDSCENE_LOCATE_MODEL_HTTP_PROXY,
|
|
26
|
+
openaiBaseURL: MIDSCENE_LOCATE_MODEL_BASE_URL,
|
|
27
|
+
openaiApiKey: MIDSCENE_LOCATE_MODEL_API_KEY,
|
|
28
|
+
openaiExtraConfig: MIDSCENE_LOCATE_MODEL_INIT_CONFIG_JSON,
|
|
29
|
+
extraBody: MIDSCENE_LOCATE_MODEL_EXTRA_BODY_JSON,
|
|
30
|
+
protocol: MIDSCENE_LOCATE_MODEL_PROTOCOL,
|
|
31
|
+
streamMode: MIDSCENE_LOCATE_MODEL_STREAM_MODE,
|
|
32
|
+
modelFamily: MIDSCENE_LOCATE_MODEL_FAMILY,
|
|
33
|
+
timeout: MIDSCENE_LOCATE_MODEL_TIMEOUT,
|
|
34
|
+
temperature: MIDSCENE_LOCATE_MODEL_TEMPERATURE,
|
|
35
|
+
retryCount: MIDSCENE_LOCATE_MODEL_RETRY_COUNT,
|
|
36
|
+
retryInterval: MIDSCENE_LOCATE_MODEL_RETRY_INTERVAL,
|
|
37
|
+
reasoningEffort: MIDSCENE_LOCATE_MODEL_REASONING_EFFORT,
|
|
38
|
+
reasoningEnabled: MIDSCENE_LOCATE_MODEL_REASONING_ENABLED,
|
|
39
|
+
reasoningBudget: MIDSCENE_LOCATE_MODEL_REASONING_BUDGET,
|
|
40
|
+
responseFormat: MIDSCENE_LOCATE_MODEL_RESPONSE_FORMAT
|
|
41
|
+
};
|
|
21
42
|
const PLANNING_MODEL_CONFIG_KEYS = {
|
|
22
43
|
modelName: MIDSCENE_PLANNING_MODEL_NAME,
|
|
23
44
|
socksProxy: MIDSCENE_PLANNING_MODEL_SOCKS_PROXY,
|
|
@@ -27,6 +48,7 @@ const PLANNING_MODEL_CONFIG_KEYS = {
|
|
|
27
48
|
openaiExtraConfig: MIDSCENE_PLANNING_MODEL_INIT_CONFIG_JSON,
|
|
28
49
|
extraBody: MIDSCENE_PLANNING_MODEL_EXTRA_BODY_JSON,
|
|
29
50
|
protocol: MIDSCENE_PLANNING_MODEL_PROTOCOL,
|
|
51
|
+
streamMode: MIDSCENE_PLANNING_MODEL_STREAM_MODE,
|
|
30
52
|
modelFamily: MIDSCENE_PLANNING_MODEL_FAMILY,
|
|
31
53
|
timeout: MIDSCENE_PLANNING_MODEL_TIMEOUT,
|
|
32
54
|
temperature: MIDSCENE_PLANNING_MODEL_TEMPERATURE,
|
|
@@ -46,6 +68,7 @@ const DEFAULT_MODEL_CONFIG_KEYS = {
|
|
|
46
68
|
openaiExtraConfig: MIDSCENE_MODEL_INIT_CONFIG_JSON,
|
|
47
69
|
extraBody: MIDSCENE_MODEL_EXTRA_BODY_JSON,
|
|
48
70
|
protocol: MIDSCENE_MODEL_PROTOCOL,
|
|
71
|
+
streamMode: MIDSCENE_MODEL_STREAM_MODE,
|
|
49
72
|
modelFamily: MIDSCENE_MODEL_FAMILY,
|
|
50
73
|
timeout: MIDSCENE_MODEL_TIMEOUT,
|
|
51
74
|
temperature: MIDSCENE_MODEL_TEMPERATURE,
|
|
@@ -65,6 +88,7 @@ const DEFAULT_MODEL_CONFIG_KEYS_LEGACY = {
|
|
|
65
88
|
openaiExtraConfig: MIDSCENE_OPENAI_INIT_CONFIG_JSON,
|
|
66
89
|
extraBody: MIDSCENE_MODEL_EXTRA_BODY_JSON,
|
|
67
90
|
protocol: MIDSCENE_MODEL_PROTOCOL,
|
|
91
|
+
streamMode: MIDSCENE_MODEL_STREAM_MODE,
|
|
68
92
|
modelFamily: 'DEFAULT_MODEL_CONFIG_KEYS has no modelFamily key',
|
|
69
93
|
timeout: MIDSCENE_MODEL_TIMEOUT,
|
|
70
94
|
temperature: MIDSCENE_MODEL_TEMPERATURE,
|
|
@@ -75,4 +99,4 @@ const DEFAULT_MODEL_CONFIG_KEYS_LEGACY = {
|
|
|
75
99
|
reasoningBudget: MIDSCENE_MODEL_REASONING_BUDGET,
|
|
76
100
|
responseFormat: MIDSCENE_MODEL_RESPONSE_FORMAT
|
|
77
101
|
};
|
|
78
|
-
export { DEFAULT_MODEL_CONFIG_KEYS, DEFAULT_MODEL_CONFIG_KEYS_LEGACY, INSIGHT_MODEL_CONFIG_KEYS, PLANNING_MODEL_CONFIG_KEYS };
|
|
102
|
+
export { DEFAULT_MODEL_CONFIG_KEYS, DEFAULT_MODEL_CONFIG_KEYS_LEGACY, INSIGHT_MODEL_CONFIG_KEYS, LOCATE_MODEL_CONFIG_KEYS, PLANNING_MODEL_CONFIG_KEYS };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { initDebugConfig } from "./init-debug.mjs";
|
|
2
|
-
import { ALL_ENV_KEYS, BOOLEAN_ENV_KEYS, GLOBAL_ENV_KEYS, MATCH_BY_POSITION,
|
|
2
|
+
import { ALL_ENV_KEYS, BOOLEAN_ENV_KEYS, GLOBAL_ENV_KEYS, MATCH_BY_POSITION, MODEL_ENV_KEYS, NUMBER_ENV_KEYS, STRING_ENV_KEYS } from "./types.mjs";
|
|
3
3
|
function _define_property(obj, key, value) {
|
|
4
4
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
5
5
|
value: value,
|
|
@@ -34,11 +34,6 @@ class GlobalConfigManager {
|
|
|
34
34
|
if (!STRING_ENV_KEYS.includes(key)) throw new Error(`getEnvConfigValue with key ${key} is not supported.`);
|
|
35
35
|
const value = allConfig[key];
|
|
36
36
|
this.keysHaveBeenRead[key] = true;
|
|
37
|
-
if (key === MIDSCENE_MODEL_STREAM_MODE) {
|
|
38
|
-
const mode = value?.trim() ?? 'non-stream';
|
|
39
|
-
if ('stream' !== mode && 'non-stream' !== mode) throw new Error(`Invalid MIDSCENE_MODEL_STREAM_MODE: "${mode}". Expected "stream" or "non-stream".`);
|
|
40
|
-
return mode;
|
|
41
|
-
}
|
|
42
37
|
if ('string' == typeof value) return value.trim();
|
|
43
38
|
return value;
|
|
44
39
|
}
|
|
@@ -19,8 +19,10 @@ class ModelConfigManager {
|
|
|
19
19
|
} else configMap = this.globalConfigManager?.getAllEnvConfig() || {};
|
|
20
20
|
const defaultConfig = decideModelConfigFromIntentConfig('default', configMap);
|
|
21
21
|
if (!defaultConfig) throw new Error('Model configuration is incomplete: model name (MIDSCENE_MODEL_NAME) is required. See https://midscenejs.com/model-strategy.html');
|
|
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.');
|
|
22
23
|
const insightConfig = decideModelConfigFromIntentConfig('insight', configMap);
|
|
23
24
|
const planningConfig = decideModelConfigFromIntentConfig('planning', configMap);
|
|
25
|
+
const locateConfig = decideModelConfigFromIntentConfig('locate', configMap);
|
|
24
26
|
this.modelConfigMap = {
|
|
25
27
|
default: {
|
|
26
28
|
...defaultConfig,
|
|
@@ -28,6 +30,12 @@ class ModelConfigManager {
|
|
|
28
30
|
slot: 'default',
|
|
29
31
|
createOpenAIClient: this.createOpenAIClientFn
|
|
30
32
|
},
|
|
33
|
+
locate: {
|
|
34
|
+
...locateConfig || defaultConfig,
|
|
35
|
+
intent: 'locate',
|
|
36
|
+
slot: locateConfig ? 'locate' : 'default',
|
|
37
|
+
createOpenAIClient: this.createOpenAIClientFn
|
|
38
|
+
},
|
|
31
39
|
insight: {
|
|
32
40
|
...insightConfig || defaultConfig,
|
|
33
41
|
intent: 'insight',
|
|
@@ -68,8 +76,8 @@ class ModelConfigManager {
|
|
|
68
76
|
this.globalConfigManager = globalConfigManager;
|
|
69
77
|
}
|
|
70
78
|
throwErrorIfNonVLModel() {
|
|
71
|
-
const modelConfig = this.getModelConfig('
|
|
72
|
-
if (!modelConfig.modelFamily) throw new Error('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-strategy.html
|
|
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-strategy.html`);
|
|
73
81
|
}
|
|
74
82
|
constructor(modelConfig, createOpenAIClientFn){
|
|
75
83
|
_define_property(this, "modelConfigMap", void 0);
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { DEFAULT_MODEL_CONFIG_KEYS, INSIGHT_MODEL_CONFIG_KEYS, PLANNING_MODEL_CONFIG_KEYS } from "./constants.mjs";
|
|
1
|
+
import { DEFAULT_MODEL_CONFIG_KEYS, INSIGHT_MODEL_CONFIG_KEYS, LOCATE_MODEL_CONFIG_KEYS, PLANNING_MODEL_CONFIG_KEYS } from "./constants.mjs";
|
|
2
2
|
import { MIDSCENE_OPENAI_HTTP_PROXY, MIDSCENE_OPENAI_INIT_CONFIG_JSON, MIDSCENE_OPENAI_SOCKS_PROXY, MIDSCENE_USE_DOUBAO_VISION, MIDSCENE_USE_GEMINI, MIDSCENE_USE_QWEN3_VL, MIDSCENE_USE_QWEN_VL, MIDSCENE_USE_VLM_UI_TARS, MODEL_FAMILY_VALUES, OPENAI_API_KEY, OPENAI_BASE_URL, UITarsModelVersion } from "./types.mjs";
|
|
3
3
|
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
7
|
const MODEL_CONFIG_DOC_URL = 'https://midscenejs.com/model-common-config.html';
|
|
8
|
-
const getCurrentVersion = ()=>"1.15.
|
|
8
|
+
const getCurrentVersion = ()=>"1.15.6";
|
|
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
|
+
locate: LOCATE_MODEL_CONFIG_KEYS,
|
|
11
12
|
insight: INSIGHT_MODEL_CONFIG_KEYS,
|
|
12
13
|
planning: PLANNING_MODEL_CONFIG_KEYS,
|
|
13
14
|
default: DEFAULT_MODEL_CONFIG_KEYS
|
|
@@ -113,6 +114,11 @@ const parseOpenaiSdkConfig = ({ keys, provider, useLegacyLogic = false })=>{
|
|
|
113
114
|
return timeout;
|
|
114
115
|
})(),
|
|
115
116
|
temperature,
|
|
117
|
+
streamMode: (()=>{
|
|
118
|
+
const mode = provider[keys.streamMode]?.trim() ?? 'non-stream';
|
|
119
|
+
if ('stream' === mode || 'non-stream' === mode) return mode;
|
|
120
|
+
throw new Error(`Invalid ${keys.streamMode}: "${mode}". Expected "stream" or "non-stream".`);
|
|
121
|
+
})(),
|
|
116
122
|
retryCount: (()=>{
|
|
117
123
|
if (!provider[keys.retryCount]) return 1;
|
|
118
124
|
const val = Number(provider[keys.retryCount]);
|
package/dist/es/env/types.mjs
CHANGED
|
@@ -22,6 +22,9 @@ const MIDSCENE_MODEL_REASONING_EFFORT = 'MIDSCENE_MODEL_REASONING_EFFORT';
|
|
|
22
22
|
const MIDSCENE_MODEL_REASONING_ENABLED = 'MIDSCENE_MODEL_REASONING_ENABLED';
|
|
23
23
|
const MIDSCENE_MODEL_REASONING_BUDGET = 'MIDSCENE_MODEL_REASONING_BUDGET';
|
|
24
24
|
const MIDSCENE_MODEL_PROTOCOL = 'MIDSCENE_MODEL_PROTOCOL';
|
|
25
|
+
const MIDSCENE_LOCATE_MODEL_STREAM_MODE = 'MIDSCENE_LOCATE_MODEL_STREAM_MODE';
|
|
26
|
+
const MIDSCENE_PLANNING_MODEL_STREAM_MODE = 'MIDSCENE_PLANNING_MODEL_STREAM_MODE';
|
|
27
|
+
const MIDSCENE_INSIGHT_MODEL_STREAM_MODE = 'MIDSCENE_INSIGHT_MODEL_STREAM_MODE';
|
|
25
28
|
const MIDSCENE_MODEL_STREAM_MODE = 'MIDSCENE_MODEL_STREAM_MODE';
|
|
26
29
|
const MIDSCENE_MODEL_RESPONSE_FORMAT = 'MIDSCENE_MODEL_RESPONSE_FORMAT';
|
|
27
30
|
const OPENAI_API_KEY = 'OPENAI_API_KEY';
|
|
@@ -69,6 +72,23 @@ const MIDSCENE_INSIGHT_MODEL_REASONING_ENABLED = 'MIDSCENE_INSIGHT_MODEL_REASONI
|
|
|
69
72
|
const MIDSCENE_INSIGHT_MODEL_REASONING_BUDGET = 'MIDSCENE_INSIGHT_MODEL_REASONING_BUDGET';
|
|
70
73
|
const MIDSCENE_INSIGHT_MODEL_PROTOCOL = 'MIDSCENE_INSIGHT_MODEL_PROTOCOL';
|
|
71
74
|
const MIDSCENE_INSIGHT_MODEL_RESPONSE_FORMAT = 'MIDSCENE_INSIGHT_MODEL_RESPONSE_FORMAT';
|
|
75
|
+
const MIDSCENE_LOCATE_MODEL_NAME = 'MIDSCENE_LOCATE_MODEL_NAME';
|
|
76
|
+
const MIDSCENE_LOCATE_MODEL_SOCKS_PROXY = 'MIDSCENE_LOCATE_MODEL_SOCKS_PROXY';
|
|
77
|
+
const MIDSCENE_LOCATE_MODEL_HTTP_PROXY = 'MIDSCENE_LOCATE_MODEL_HTTP_PROXY';
|
|
78
|
+
const MIDSCENE_LOCATE_MODEL_BASE_URL = 'MIDSCENE_LOCATE_MODEL_BASE_URL';
|
|
79
|
+
const MIDSCENE_LOCATE_MODEL_API_KEY = 'MIDSCENE_LOCATE_MODEL_API_KEY';
|
|
80
|
+
const MIDSCENE_LOCATE_MODEL_INIT_CONFIG_JSON = 'MIDSCENE_LOCATE_MODEL_INIT_CONFIG_JSON';
|
|
81
|
+
const MIDSCENE_LOCATE_MODEL_EXTRA_BODY_JSON = 'MIDSCENE_LOCATE_MODEL_EXTRA_BODY_JSON';
|
|
82
|
+
const MIDSCENE_LOCATE_MODEL_TIMEOUT = 'MIDSCENE_LOCATE_MODEL_TIMEOUT';
|
|
83
|
+
const MIDSCENE_LOCATE_MODEL_TEMPERATURE = 'MIDSCENE_LOCATE_MODEL_TEMPERATURE';
|
|
84
|
+
const MIDSCENE_LOCATE_MODEL_RETRY_COUNT = 'MIDSCENE_LOCATE_MODEL_RETRY_COUNT';
|
|
85
|
+
const MIDSCENE_LOCATE_MODEL_RETRY_INTERVAL = 'MIDSCENE_LOCATE_MODEL_RETRY_INTERVAL';
|
|
86
|
+
const MIDSCENE_LOCATE_MODEL_FAMILY = 'MIDSCENE_LOCATE_MODEL_FAMILY';
|
|
87
|
+
const MIDSCENE_LOCATE_MODEL_REASONING_EFFORT = 'MIDSCENE_LOCATE_MODEL_REASONING_EFFORT';
|
|
88
|
+
const MIDSCENE_LOCATE_MODEL_REASONING_ENABLED = 'MIDSCENE_LOCATE_MODEL_REASONING_ENABLED';
|
|
89
|
+
const MIDSCENE_LOCATE_MODEL_REASONING_BUDGET = 'MIDSCENE_LOCATE_MODEL_REASONING_BUDGET';
|
|
90
|
+
const MIDSCENE_LOCATE_MODEL_PROTOCOL = 'MIDSCENE_LOCATE_MODEL_PROTOCOL';
|
|
91
|
+
const MIDSCENE_LOCATE_MODEL_RESPONSE_FORMAT = 'MIDSCENE_LOCATE_MODEL_RESPONSE_FORMAT';
|
|
72
92
|
const MIDSCENE_PLANNING_MODEL_NAME = 'MIDSCENE_PLANNING_MODEL_NAME';
|
|
73
93
|
const MIDSCENE_PLANNING_MODEL_SOCKS_PROXY = 'MIDSCENE_PLANNING_MODEL_SOCKS_PROXY';
|
|
74
94
|
const MIDSCENE_PLANNING_MODEL_HTTP_PROXY = 'MIDSCENE_PLANNING_MODEL_HTTP_PROXY';
|
|
@@ -108,7 +128,6 @@ const NUMBER_ENV_KEYS = [
|
|
|
108
128
|
MIDSCENE_REPLANNING_CYCLE_LIMIT
|
|
109
129
|
];
|
|
110
130
|
const STRING_ENV_KEYS = [
|
|
111
|
-
MIDSCENE_MODEL_STREAM_MODE,
|
|
112
131
|
MIDSCENE_ADB_PATH,
|
|
113
132
|
MIDSCENE_ADB_REMOTE_HOST,
|
|
114
133
|
MIDSCENE_ADB_REMOTE_PORT,
|
|
@@ -129,6 +148,10 @@ const GLOBAL_ENV_KEYS = [
|
|
|
129
148
|
...STRING_ENV_KEYS
|
|
130
149
|
];
|
|
131
150
|
const MODEL_ENV_KEYS = [
|
|
151
|
+
MIDSCENE_INSIGHT_MODEL_STREAM_MODE,
|
|
152
|
+
MIDSCENE_PLANNING_MODEL_STREAM_MODE,
|
|
153
|
+
MIDSCENE_LOCATE_MODEL_STREAM_MODE,
|
|
154
|
+
MIDSCENE_MODEL_STREAM_MODE,
|
|
132
155
|
MIDSCENE_MODEL_NAME,
|
|
133
156
|
MIDSCENE_MODEL_INIT_CONFIG_JSON,
|
|
134
157
|
MIDSCENE_MODEL_EXTRA_BODY_JSON,
|
|
@@ -173,6 +196,23 @@ const MODEL_ENV_KEYS = [
|
|
|
173
196
|
MIDSCENE_INSIGHT_MODEL_REASONING_BUDGET,
|
|
174
197
|
MIDSCENE_INSIGHT_MODEL_PROTOCOL,
|
|
175
198
|
MIDSCENE_INSIGHT_MODEL_RESPONSE_FORMAT,
|
|
199
|
+
MIDSCENE_LOCATE_MODEL_NAME,
|
|
200
|
+
MIDSCENE_LOCATE_MODEL_SOCKS_PROXY,
|
|
201
|
+
MIDSCENE_LOCATE_MODEL_HTTP_PROXY,
|
|
202
|
+
MIDSCENE_LOCATE_MODEL_BASE_URL,
|
|
203
|
+
MIDSCENE_LOCATE_MODEL_API_KEY,
|
|
204
|
+
MIDSCENE_LOCATE_MODEL_INIT_CONFIG_JSON,
|
|
205
|
+
MIDSCENE_LOCATE_MODEL_EXTRA_BODY_JSON,
|
|
206
|
+
MIDSCENE_LOCATE_MODEL_TIMEOUT,
|
|
207
|
+
MIDSCENE_LOCATE_MODEL_TEMPERATURE,
|
|
208
|
+
MIDSCENE_LOCATE_MODEL_RETRY_COUNT,
|
|
209
|
+
MIDSCENE_LOCATE_MODEL_RETRY_INTERVAL,
|
|
210
|
+
MIDSCENE_LOCATE_MODEL_FAMILY,
|
|
211
|
+
MIDSCENE_LOCATE_MODEL_REASONING_EFFORT,
|
|
212
|
+
MIDSCENE_LOCATE_MODEL_REASONING_ENABLED,
|
|
213
|
+
MIDSCENE_LOCATE_MODEL_REASONING_BUDGET,
|
|
214
|
+
MIDSCENE_LOCATE_MODEL_PROTOCOL,
|
|
215
|
+
MIDSCENE_LOCATE_MODEL_RESPONSE_FORMAT,
|
|
176
216
|
MIDSCENE_PLANNING_MODEL_NAME,
|
|
177
217
|
MIDSCENE_PLANNING_MODEL_SOCKS_PROXY,
|
|
178
218
|
MIDSCENE_PLANNING_MODEL_HTTP_PROXY,
|
|
@@ -199,6 +239,7 @@ const ALL_ENV_KEYS = [
|
|
|
199
239
|
...MODEL_ENV_KEYS
|
|
200
240
|
];
|
|
201
241
|
const MODEL_FAMILY_VALUES = [
|
|
242
|
+
'jev',
|
|
202
243
|
'doubao-vision',
|
|
203
244
|
'doubao-seed',
|
|
204
245
|
'gemini',
|
|
@@ -227,4 +268,4 @@ var types_UITarsModelVersion = /*#__PURE__*/ function(UITarsModelVersion) {
|
|
|
227
268
|
UITarsModelVersion["DOUBAO_1_5_20B"] = "doubao-1.5-20B";
|
|
228
269
|
return UITarsModelVersion;
|
|
229
270
|
}({});
|
|
230
|
-
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_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_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_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 };
|
|
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 };
|
package/dist/es/img/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { encodedImageInfoOfBuffer, imageInfoOfBase64, isValidImageBuffer, isValidJPEGImageBuffer, isValidPNGImageBuffer, validateScreenshotBuffer } from "./info.mjs";
|
|
2
|
-
import { constrainBase64ImageToMaxSize, convertBase64ImageToJpeg, convertImgBufferToJpeg, createImgBase64ByFormat, cropByRect, httpImg2Base64, inferBase64ImageFormat, localImg2Base64, normalizeBase64Image, normalizeScreenshotBase64, paddingToMatchBlockByBase64, parseBase64, preProcessImageUrl, resizeAndConvertImgBuffer, resizeBase64ImageToJpeg, resizeImgBase64, saveBase64Image, scaleImage, zoomForGPT4o } from "./transform.mjs";
|
|
2
|
+
import { constrainBase64ImageToMaxSize, convertBase64ImageToJpeg, convertImgBufferToJpeg, createImgBase64ByFormat, cropByRect, httpImg2Base64, inferBase64ImageFormat, localImg2Base64, normalizeBase64Image, normalizeScreenshotBase64, padBase64ImageToMinimumSize, paddingToMatchBlockByBase64, parseBase64, preProcessImageUrl, resizeAndConvertImgBuffer, resizeBase64ImageToJpeg, resizeImgBase64, saveBase64Image, scaleImage, zoomForGPT4o } from "./transform.mjs";
|
|
3
3
|
import { annotateRects, compositeElementInfoImg, compositePointMarkerImg, processImageElementInfo } from "./box-select.mjs";
|
|
4
|
-
export { annotateRects, compositeElementInfoImg, compositePointMarkerImg, constrainBase64ImageToMaxSize, convertBase64ImageToJpeg, convertImgBufferToJpeg, createImgBase64ByFormat, cropByRect, encodedImageInfoOfBuffer, httpImg2Base64, imageInfoOfBase64, inferBase64ImageFormat, isValidImageBuffer, isValidJPEGImageBuffer, isValidPNGImageBuffer, localImg2Base64, normalizeBase64Image, normalizeScreenshotBase64, paddingToMatchBlockByBase64, parseBase64, preProcessImageUrl, processImageElementInfo, resizeAndConvertImgBuffer, resizeBase64ImageToJpeg, resizeImgBase64, saveBase64Image, scaleImage, validateScreenshotBuffer, zoomForGPT4o };
|
|
4
|
+
export { annotateRects, compositeElementInfoImg, compositePointMarkerImg, constrainBase64ImageToMaxSize, convertBase64ImageToJpeg, convertImgBufferToJpeg, createImgBase64ByFormat, cropByRect, encodedImageInfoOfBuffer, httpImg2Base64, imageInfoOfBase64, inferBase64ImageFormat, isValidImageBuffer, isValidJPEGImageBuffer, isValidPNGImageBuffer, localImg2Base64, normalizeBase64Image, normalizeScreenshotBase64, padBase64ImageToMinimumSize, paddingToMatchBlockByBase64, parseBase64, preProcessImageUrl, processImageElementInfo, resizeAndConvertImgBuffer, resizeBase64ImageToJpeg, resizeImgBase64, saveBase64Image, scaleImage, validateScreenshotBuffer, zoomForGPT4o };
|
|
@@ -456,4 +456,55 @@ async function scaleImage(imageBase64, scale) {
|
|
|
456
456
|
imageBase64: base64
|
|
457
457
|
};
|
|
458
458
|
}
|
|
459
|
-
|
|
459
|
+
async function padBase64ImageToMinimumSize(imageBase64, minimum) {
|
|
460
|
+
node_assert(Number.isInteger(minimum) && minimum > 0, 'minimum must be a positive integer');
|
|
461
|
+
const { body } = parseBase64(imageBase64);
|
|
462
|
+
const buffer = Buffer.from(body, 'base64');
|
|
463
|
+
const size = encodedImageInfoOfBuffer(buffer);
|
|
464
|
+
const width = Math.max(minimum, size.width);
|
|
465
|
+
const height = Math.max(minimum, size.height);
|
|
466
|
+
if (width === size.width && height === size.height) return {
|
|
467
|
+
imageBase64,
|
|
468
|
+
width,
|
|
469
|
+
height
|
|
470
|
+
};
|
|
471
|
+
if (ifInNode) {
|
|
472
|
+
const Sharp = await get_sharp();
|
|
473
|
+
const padded = await Sharp(buffer).extend({
|
|
474
|
+
right: width - size.width,
|
|
475
|
+
bottom: height - size.height,
|
|
476
|
+
background: {
|
|
477
|
+
r: 255,
|
|
478
|
+
g: 255,
|
|
479
|
+
b: 255,
|
|
480
|
+
alpha: 1
|
|
481
|
+
}
|
|
482
|
+
}).jpeg({
|
|
483
|
+
quality: 90
|
|
484
|
+
}).toBuffer();
|
|
485
|
+
return {
|
|
486
|
+
imageBase64: createImgBase64ByFormat('jpeg', padded.toString('base64')),
|
|
487
|
+
width,
|
|
488
|
+
height
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
const { padding_right, padding_bottom, Rgba } = await get_photon();
|
|
492
|
+
const original = await photonFromBase64(imageBase64);
|
|
493
|
+
const right = width > size.width ? padding_right(original, width - size.width, new Rgba(255, 255, 255, 255)) : original;
|
|
494
|
+
try {
|
|
495
|
+
const bottom = height > size.height ? padding_bottom(right, height - size.height, new Rgba(255, 255, 255, 255)) : right;
|
|
496
|
+
try {
|
|
497
|
+
return {
|
|
498
|
+
imageBase64: await photonToBase64(bottom),
|
|
499
|
+
width,
|
|
500
|
+
height
|
|
501
|
+
};
|
|
502
|
+
} finally{
|
|
503
|
+
if (bottom !== right) bottom.free();
|
|
504
|
+
}
|
|
505
|
+
} finally{
|
|
506
|
+
if (right !== original) right.free();
|
|
507
|
+
original.free();
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
export { constrainBase64ImageToMaxSize, convertBase64ImageToJpeg, convertImgBufferToJpeg, createImgBase64ByFormat, cropByRect, httpImg2Base64, inferBase64ImageFormat, localImg2Base64, normalizeBase64Body, normalizeBase64Image, normalizeScreenshotBase64, padBase64ImageToMinimumSize, paddingToMatchBlock, paddingToMatchBlockByBase64, parseBase64, photonFromBase64, photonToBase64, preProcessImageUrl, resizeAndConvertImgBuffer, resizeBase64ImageToJpeg, resizeImgBase64, saveBase64Image, scaleImage, zoomForGPT4o };
|
|
@@ -24,6 +24,7 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
LOCATE_MODEL_CONFIG_KEYS: ()=>LOCATE_MODEL_CONFIG_KEYS,
|
|
27
28
|
INSIGHT_MODEL_CONFIG_KEYS: ()=>INSIGHT_MODEL_CONFIG_KEYS,
|
|
28
29
|
DEFAULT_MODEL_CONFIG_KEYS_LEGACY: ()=>DEFAULT_MODEL_CONFIG_KEYS_LEGACY,
|
|
29
30
|
DEFAULT_MODEL_CONFIG_KEYS: ()=>DEFAULT_MODEL_CONFIG_KEYS,
|
|
@@ -39,6 +40,7 @@ const INSIGHT_MODEL_CONFIG_KEYS = {
|
|
|
39
40
|
openaiExtraConfig: external_types_js_namespaceObject.MIDSCENE_INSIGHT_MODEL_INIT_CONFIG_JSON,
|
|
40
41
|
extraBody: external_types_js_namespaceObject.MIDSCENE_INSIGHT_MODEL_EXTRA_BODY_JSON,
|
|
41
42
|
protocol: external_types_js_namespaceObject.MIDSCENE_INSIGHT_MODEL_PROTOCOL,
|
|
43
|
+
streamMode: external_types_js_namespaceObject.MIDSCENE_INSIGHT_MODEL_STREAM_MODE,
|
|
42
44
|
modelFamily: external_types_js_namespaceObject.MIDSCENE_INSIGHT_MODEL_FAMILY,
|
|
43
45
|
timeout: external_types_js_namespaceObject.MIDSCENE_INSIGHT_MODEL_TIMEOUT,
|
|
44
46
|
temperature: external_types_js_namespaceObject.MIDSCENE_INSIGHT_MODEL_TEMPERATURE,
|
|
@@ -49,6 +51,26 @@ const INSIGHT_MODEL_CONFIG_KEYS = {
|
|
|
49
51
|
reasoningBudget: external_types_js_namespaceObject.MIDSCENE_INSIGHT_MODEL_REASONING_BUDGET,
|
|
50
52
|
responseFormat: external_types_js_namespaceObject.MIDSCENE_INSIGHT_MODEL_RESPONSE_FORMAT
|
|
51
53
|
};
|
|
54
|
+
const LOCATE_MODEL_CONFIG_KEYS = {
|
|
55
|
+
modelName: external_types_js_namespaceObject.MIDSCENE_LOCATE_MODEL_NAME,
|
|
56
|
+
socksProxy: external_types_js_namespaceObject.MIDSCENE_LOCATE_MODEL_SOCKS_PROXY,
|
|
57
|
+
httpProxy: external_types_js_namespaceObject.MIDSCENE_LOCATE_MODEL_HTTP_PROXY,
|
|
58
|
+
openaiBaseURL: external_types_js_namespaceObject.MIDSCENE_LOCATE_MODEL_BASE_URL,
|
|
59
|
+
openaiApiKey: external_types_js_namespaceObject.MIDSCENE_LOCATE_MODEL_API_KEY,
|
|
60
|
+
openaiExtraConfig: external_types_js_namespaceObject.MIDSCENE_LOCATE_MODEL_INIT_CONFIG_JSON,
|
|
61
|
+
extraBody: external_types_js_namespaceObject.MIDSCENE_LOCATE_MODEL_EXTRA_BODY_JSON,
|
|
62
|
+
protocol: external_types_js_namespaceObject.MIDSCENE_LOCATE_MODEL_PROTOCOL,
|
|
63
|
+
streamMode: external_types_js_namespaceObject.MIDSCENE_LOCATE_MODEL_STREAM_MODE,
|
|
64
|
+
modelFamily: external_types_js_namespaceObject.MIDSCENE_LOCATE_MODEL_FAMILY,
|
|
65
|
+
timeout: external_types_js_namespaceObject.MIDSCENE_LOCATE_MODEL_TIMEOUT,
|
|
66
|
+
temperature: external_types_js_namespaceObject.MIDSCENE_LOCATE_MODEL_TEMPERATURE,
|
|
67
|
+
retryCount: external_types_js_namespaceObject.MIDSCENE_LOCATE_MODEL_RETRY_COUNT,
|
|
68
|
+
retryInterval: external_types_js_namespaceObject.MIDSCENE_LOCATE_MODEL_RETRY_INTERVAL,
|
|
69
|
+
reasoningEffort: external_types_js_namespaceObject.MIDSCENE_LOCATE_MODEL_REASONING_EFFORT,
|
|
70
|
+
reasoningEnabled: external_types_js_namespaceObject.MIDSCENE_LOCATE_MODEL_REASONING_ENABLED,
|
|
71
|
+
reasoningBudget: external_types_js_namespaceObject.MIDSCENE_LOCATE_MODEL_REASONING_BUDGET,
|
|
72
|
+
responseFormat: external_types_js_namespaceObject.MIDSCENE_LOCATE_MODEL_RESPONSE_FORMAT
|
|
73
|
+
};
|
|
52
74
|
const PLANNING_MODEL_CONFIG_KEYS = {
|
|
53
75
|
modelName: external_types_js_namespaceObject.MIDSCENE_PLANNING_MODEL_NAME,
|
|
54
76
|
socksProxy: external_types_js_namespaceObject.MIDSCENE_PLANNING_MODEL_SOCKS_PROXY,
|
|
@@ -58,6 +80,7 @@ const PLANNING_MODEL_CONFIG_KEYS = {
|
|
|
58
80
|
openaiExtraConfig: external_types_js_namespaceObject.MIDSCENE_PLANNING_MODEL_INIT_CONFIG_JSON,
|
|
59
81
|
extraBody: external_types_js_namespaceObject.MIDSCENE_PLANNING_MODEL_EXTRA_BODY_JSON,
|
|
60
82
|
protocol: external_types_js_namespaceObject.MIDSCENE_PLANNING_MODEL_PROTOCOL,
|
|
83
|
+
streamMode: external_types_js_namespaceObject.MIDSCENE_PLANNING_MODEL_STREAM_MODE,
|
|
61
84
|
modelFamily: external_types_js_namespaceObject.MIDSCENE_PLANNING_MODEL_FAMILY,
|
|
62
85
|
timeout: external_types_js_namespaceObject.MIDSCENE_PLANNING_MODEL_TIMEOUT,
|
|
63
86
|
temperature: external_types_js_namespaceObject.MIDSCENE_PLANNING_MODEL_TEMPERATURE,
|
|
@@ -77,6 +100,7 @@ const DEFAULT_MODEL_CONFIG_KEYS = {
|
|
|
77
100
|
openaiExtraConfig: external_types_js_namespaceObject.MIDSCENE_MODEL_INIT_CONFIG_JSON,
|
|
78
101
|
extraBody: external_types_js_namespaceObject.MIDSCENE_MODEL_EXTRA_BODY_JSON,
|
|
79
102
|
protocol: external_types_js_namespaceObject.MIDSCENE_MODEL_PROTOCOL,
|
|
103
|
+
streamMode: external_types_js_namespaceObject.MIDSCENE_MODEL_STREAM_MODE,
|
|
80
104
|
modelFamily: external_types_js_namespaceObject.MIDSCENE_MODEL_FAMILY,
|
|
81
105
|
timeout: external_types_js_namespaceObject.MIDSCENE_MODEL_TIMEOUT,
|
|
82
106
|
temperature: external_types_js_namespaceObject.MIDSCENE_MODEL_TEMPERATURE,
|
|
@@ -96,6 +120,7 @@ const DEFAULT_MODEL_CONFIG_KEYS_LEGACY = {
|
|
|
96
120
|
openaiExtraConfig: external_types_js_namespaceObject.MIDSCENE_OPENAI_INIT_CONFIG_JSON,
|
|
97
121
|
extraBody: external_types_js_namespaceObject.MIDSCENE_MODEL_EXTRA_BODY_JSON,
|
|
98
122
|
protocol: external_types_js_namespaceObject.MIDSCENE_MODEL_PROTOCOL,
|
|
123
|
+
streamMode: external_types_js_namespaceObject.MIDSCENE_MODEL_STREAM_MODE,
|
|
99
124
|
modelFamily: 'DEFAULT_MODEL_CONFIG_KEYS has no modelFamily key',
|
|
100
125
|
timeout: external_types_js_namespaceObject.MIDSCENE_MODEL_TIMEOUT,
|
|
101
126
|
temperature: external_types_js_namespaceObject.MIDSCENE_MODEL_TEMPERATURE,
|
|
@@ -109,11 +134,13 @@ const DEFAULT_MODEL_CONFIG_KEYS_LEGACY = {
|
|
|
109
134
|
exports.DEFAULT_MODEL_CONFIG_KEYS = __webpack_exports__.DEFAULT_MODEL_CONFIG_KEYS;
|
|
110
135
|
exports.DEFAULT_MODEL_CONFIG_KEYS_LEGACY = __webpack_exports__.DEFAULT_MODEL_CONFIG_KEYS_LEGACY;
|
|
111
136
|
exports.INSIGHT_MODEL_CONFIG_KEYS = __webpack_exports__.INSIGHT_MODEL_CONFIG_KEYS;
|
|
137
|
+
exports.LOCATE_MODEL_CONFIG_KEYS = __webpack_exports__.LOCATE_MODEL_CONFIG_KEYS;
|
|
112
138
|
exports.PLANNING_MODEL_CONFIG_KEYS = __webpack_exports__.PLANNING_MODEL_CONFIG_KEYS;
|
|
113
139
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
114
140
|
"DEFAULT_MODEL_CONFIG_KEYS",
|
|
115
141
|
"DEFAULT_MODEL_CONFIG_KEYS_LEGACY",
|
|
116
142
|
"INSIGHT_MODEL_CONFIG_KEYS",
|
|
143
|
+
"LOCATE_MODEL_CONFIG_KEYS",
|
|
117
144
|
"PLANNING_MODEL_CONFIG_KEYS"
|
|
118
145
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
119
146
|
Object.defineProperty(exports, '__esModule', {
|
|
@@ -62,11 +62,6 @@ class GlobalConfigManager {
|
|
|
62
62
|
if (!external_types_js_namespaceObject.STRING_ENV_KEYS.includes(key)) throw new Error(`getEnvConfigValue with key ${key} is not supported.`);
|
|
63
63
|
const value = allConfig[key];
|
|
64
64
|
this.keysHaveBeenRead[key] = true;
|
|
65
|
-
if (key === external_types_js_namespaceObject.MIDSCENE_MODEL_STREAM_MODE) {
|
|
66
|
-
const mode = value?.trim() ?? 'non-stream';
|
|
67
|
-
if ('stream' !== mode && 'non-stream' !== mode) throw new Error(`Invalid MIDSCENE_MODEL_STREAM_MODE: "${mode}". Expected "stream" or "non-stream".`);
|
|
68
|
-
return mode;
|
|
69
|
-
}
|
|
70
65
|
if ('string' == typeof value) return value.trim();
|
|
71
66
|
return value;
|
|
72
67
|
}
|
|
@@ -47,8 +47,10 @@ class ModelConfigManager {
|
|
|
47
47
|
} else configMap = this.globalConfigManager?.getAllEnvConfig() || {};
|
|
48
48
|
const defaultConfig = (0, external_parse_model_config_js_namespaceObject.decideModelConfigFromIntentConfig)('default', configMap);
|
|
49
49
|
if (!defaultConfig) throw new Error('Model configuration is incomplete: model name (MIDSCENE_MODEL_NAME) is required. See https://midscenejs.com/model-strategy.html');
|
|
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.');
|
|
50
51
|
const insightConfig = (0, external_parse_model_config_js_namespaceObject.decideModelConfigFromIntentConfig)('insight', configMap);
|
|
51
52
|
const planningConfig = (0, external_parse_model_config_js_namespaceObject.decideModelConfigFromIntentConfig)('planning', configMap);
|
|
53
|
+
const locateConfig = (0, external_parse_model_config_js_namespaceObject.decideModelConfigFromIntentConfig)('locate', configMap);
|
|
52
54
|
this.modelConfigMap = {
|
|
53
55
|
default: {
|
|
54
56
|
...defaultConfig,
|
|
@@ -56,6 +58,12 @@ class ModelConfigManager {
|
|
|
56
58
|
slot: 'default',
|
|
57
59
|
createOpenAIClient: this.createOpenAIClientFn
|
|
58
60
|
},
|
|
61
|
+
locate: {
|
|
62
|
+
...locateConfig || defaultConfig,
|
|
63
|
+
intent: 'locate',
|
|
64
|
+
slot: locateConfig ? 'locate' : 'default',
|
|
65
|
+
createOpenAIClient: this.createOpenAIClientFn
|
|
66
|
+
},
|
|
59
67
|
insight: {
|
|
60
68
|
...insightConfig || defaultConfig,
|
|
61
69
|
intent: 'insight',
|
|
@@ -96,8 +104,8 @@ class ModelConfigManager {
|
|
|
96
104
|
this.globalConfigManager = globalConfigManager;
|
|
97
105
|
}
|
|
98
106
|
throwErrorIfNonVLModel() {
|
|
99
|
-
const modelConfig = this.getModelConfig('
|
|
100
|
-
if (!modelConfig.modelFamily) throw new Error('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-strategy.html
|
|
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-strategy.html`);
|
|
101
109
|
}
|
|
102
110
|
constructor(modelConfig, createOpenAIClientFn){
|
|
103
111
|
_define_property(this, "modelConfigMap", void 0);
|
|
@@ -37,9 +37,10 @@ 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
39
|
const MODEL_CONFIG_DOC_URL = 'https://midscenejs.com/model-common-config.html';
|
|
40
|
-
const getCurrentVersion = ()=>"1.15.
|
|
40
|
+
const getCurrentVersion = ()=>"1.15.6";
|
|
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
|
+
locate: external_constants_js_namespaceObject.LOCATE_MODEL_CONFIG_KEYS,
|
|
43
44
|
insight: external_constants_js_namespaceObject.INSIGHT_MODEL_CONFIG_KEYS,
|
|
44
45
|
planning: external_constants_js_namespaceObject.PLANNING_MODEL_CONFIG_KEYS,
|
|
45
46
|
default: external_constants_js_namespaceObject.DEFAULT_MODEL_CONFIG_KEYS
|
|
@@ -145,6 +146,11 @@ const parseOpenaiSdkConfig = ({ keys, provider, useLegacyLogic = false })=>{
|
|
|
145
146
|
return timeout;
|
|
146
147
|
})(),
|
|
147
148
|
temperature,
|
|
149
|
+
streamMode: (()=>{
|
|
150
|
+
const mode = provider[keys.streamMode]?.trim() ?? 'non-stream';
|
|
151
|
+
if ('stream' === mode || 'non-stream' === mode) return mode;
|
|
152
|
+
throw new Error(`Invalid ${keys.streamMode}: "${mode}". Expected "stream" or "non-stream".`);
|
|
153
|
+
})(),
|
|
148
154
|
retryCount: (()=>{
|
|
149
155
|
if (!provider[keys.retryCount]) return 1;
|
|
150
156
|
const val = Number(provider[keys.retryCount]);
|