@midscene/shared 1.7.9 → 1.7.10-beta-20260507030203.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/env/parse-model-config.mjs +4 -1
- package/dist/es/env/utils.mjs +1 -9
- package/dist/lib/env/parse-model-config.js +4 -1
- package/dist/lib/env/utils.js +0 -11
- package/dist/types/env/utils.d.ts +0 -31
- package/package.json +1 -1
- package/src/env/parse-model-config.ts +17 -1
- package/src/env/utils.ts +0 -50
|
@@ -4,6 +4,9 @@ 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-common-config.html';
|
|
8
|
+
const getCurrentVersion = ()=>"1.7.10-beta-20260507030203.0";
|
|
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.`;
|
|
7
10
|
const KEYS_MAP = {
|
|
8
11
|
insight: INSIGHT_MODEL_CONFIG_KEYS,
|
|
9
12
|
planning: PLANNING_MODEL_CONFIG_KEYS,
|
|
@@ -14,7 +17,7 @@ const getUITarsModelVersion = (modelFamily)=>{
|
|
|
14
17
|
if ('vlm-ui-tars-doubao' === modelFamily || 'vlm-ui-tars-doubao-1.5' === modelFamily) return UITarsModelVersion.DOUBAO_1_5_20B;
|
|
15
18
|
};
|
|
16
19
|
const validateModelFamily = (modelFamily)=>{
|
|
17
|
-
if (modelFamily && !MODEL_FAMILY_VALUES.includes(modelFamily)) throw new Error(
|
|
20
|
+
if (modelFamily && !MODEL_FAMILY_VALUES.includes(modelFamily)) throw new Error(getInvalidModelFamilyMessage(modelFamily));
|
|
18
21
|
};
|
|
19
22
|
const legacyConfigToModelFamily = (provider)=>{
|
|
20
23
|
const isDoubao = provider[MIDSCENE_USE_DOUBAO_VISION];
|
package/dist/es/env/utils.mjs
CHANGED
|
@@ -5,14 +5,6 @@ const globalModelConfigManager = new ModelConfigManager();
|
|
|
5
5
|
const globalConfigManager = new GlobalConfigManager();
|
|
6
6
|
globalConfigManager.registerModelConfigManager(globalModelConfigManager);
|
|
7
7
|
globalModelConfigManager.registerGlobalConfigManager(globalConfigManager);
|
|
8
|
-
async function getCurrentTime(device, useDeviceTimestamp) {
|
|
9
|
-
if (useDeviceTimestamp && device?.getTimestamp) try {
|
|
10
|
-
return await device.getTimestamp();
|
|
11
|
-
} catch (error) {
|
|
12
|
-
console.warn(`Failed to get device time, falling back to system time: ${error}`);
|
|
13
|
-
}
|
|
14
|
-
return Date.now();
|
|
15
|
-
}
|
|
16
8
|
const getPreferredLanguage = ()=>{
|
|
17
9
|
const prefer = globalConfigManager.getEnvConfigValue(MIDSCENE_PREFERRED_LANGUAGE);
|
|
18
10
|
if (prefer) return prefer;
|
|
@@ -23,4 +15,4 @@ const getPreferredLanguage = ()=>{
|
|
|
23
15
|
const overrideAIConfig = (newConfig, extendMode = false)=>{
|
|
24
16
|
globalConfigManager.overrideAIConfig(newConfig, extendMode);
|
|
25
17
|
};
|
|
26
|
-
export {
|
|
18
|
+
export { getPreferredLanguage, globalConfigManager, globalModelConfigManager, overrideAIConfig };
|
|
@@ -36,6 +36,9 @@ 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-common-config.html';
|
|
40
|
+
const getCurrentVersion = ()=>"1.7.10-beta-20260507030203.0";
|
|
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.`;
|
|
39
42
|
const KEYS_MAP = {
|
|
40
43
|
insight: external_constants_js_namespaceObject.INSIGHT_MODEL_CONFIG_KEYS,
|
|
41
44
|
planning: external_constants_js_namespaceObject.PLANNING_MODEL_CONFIG_KEYS,
|
|
@@ -46,7 +49,7 @@ const getUITarsModelVersion = (modelFamily)=>{
|
|
|
46
49
|
if ('vlm-ui-tars-doubao' === modelFamily || 'vlm-ui-tars-doubao-1.5' === modelFamily) return external_types_js_namespaceObject.UITarsModelVersion.DOUBAO_1_5_20B;
|
|
47
50
|
};
|
|
48
51
|
const validateModelFamily = (modelFamily)=>{
|
|
49
|
-
if (modelFamily && !external_types_js_namespaceObject.MODEL_FAMILY_VALUES.includes(modelFamily)) throw new Error(
|
|
52
|
+
if (modelFamily && !external_types_js_namespaceObject.MODEL_FAMILY_VALUES.includes(modelFamily)) throw new Error(getInvalidModelFamilyMessage(modelFamily));
|
|
50
53
|
};
|
|
51
54
|
const legacyConfigToModelFamily = (provider)=>{
|
|
52
55
|
const isDoubao = provider[external_types_js_namespaceObject.MIDSCENE_USE_DOUBAO_VISION];
|
package/dist/lib/env/utils.js
CHANGED
|
@@ -27,7 +27,6 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
27
27
|
overrideAIConfig: ()=>overrideAIConfig,
|
|
28
28
|
globalModelConfigManager: ()=>globalModelConfigManager,
|
|
29
29
|
getPreferredLanguage: ()=>getPreferredLanguage,
|
|
30
|
-
getCurrentTime: ()=>getCurrentTime,
|
|
31
30
|
globalConfigManager: ()=>globalConfigManager
|
|
32
31
|
});
|
|
33
32
|
const external_global_config_manager_js_namespaceObject = require("./global-config-manager.js");
|
|
@@ -37,14 +36,6 @@ const globalModelConfigManager = new external_model_config_manager_js_namespaceO
|
|
|
37
36
|
const globalConfigManager = new external_global_config_manager_js_namespaceObject.GlobalConfigManager();
|
|
38
37
|
globalConfigManager.registerModelConfigManager(globalModelConfigManager);
|
|
39
38
|
globalModelConfigManager.registerGlobalConfigManager(globalConfigManager);
|
|
40
|
-
async function getCurrentTime(device, useDeviceTimestamp) {
|
|
41
|
-
if (useDeviceTimestamp && device?.getTimestamp) try {
|
|
42
|
-
return await device.getTimestamp();
|
|
43
|
-
} catch (error) {
|
|
44
|
-
console.warn(`Failed to get device time, falling back to system time: ${error}`);
|
|
45
|
-
}
|
|
46
|
-
return Date.now();
|
|
47
|
-
}
|
|
48
39
|
const getPreferredLanguage = ()=>{
|
|
49
40
|
const prefer = globalConfigManager.getEnvConfigValue(external_types_js_namespaceObject.MIDSCENE_PREFERRED_LANGUAGE);
|
|
50
41
|
if (prefer) return prefer;
|
|
@@ -55,13 +46,11 @@ const getPreferredLanguage = ()=>{
|
|
|
55
46
|
const overrideAIConfig = (newConfig, extendMode = false)=>{
|
|
56
47
|
globalConfigManager.overrideAIConfig(newConfig, extendMode);
|
|
57
48
|
};
|
|
58
|
-
exports.getCurrentTime = __webpack_exports__.getCurrentTime;
|
|
59
49
|
exports.getPreferredLanguage = __webpack_exports__.getPreferredLanguage;
|
|
60
50
|
exports.globalConfigManager = __webpack_exports__.globalConfigManager;
|
|
61
51
|
exports.globalModelConfigManager = __webpack_exports__.globalModelConfigManager;
|
|
62
52
|
exports.overrideAIConfig = __webpack_exports__.overrideAIConfig;
|
|
63
53
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
64
|
-
"getCurrentTime",
|
|
65
54
|
"getPreferredLanguage",
|
|
66
55
|
"globalConfigManager",
|
|
67
56
|
"globalModelConfigManager",
|
|
@@ -3,36 +3,5 @@ import { ModelConfigManager } from './model-config-manager';
|
|
|
3
3
|
import { type GLOBAL_ENV_KEYS, type MODEL_ENV_KEYS } from './types';
|
|
4
4
|
export declare const globalModelConfigManager: ModelConfigManager;
|
|
5
5
|
export declare const globalConfigManager: GlobalConfigManager;
|
|
6
|
-
/**
|
|
7
|
-
* Interface for devices that support getTimestamp method.
|
|
8
|
-
* This is a minimal interface to avoid circular dependencies with @midscene/core.
|
|
9
|
-
*/
|
|
10
|
-
export interface DeviceWithTimestamp {
|
|
11
|
-
getTimestamp?: () => Promise<number>;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Get the current timestamp, optionally from the target device.
|
|
15
|
-
*
|
|
16
|
-
* When useDeviceTimestamp is enabled and a device with getTimestamp is provided,
|
|
17
|
-
* this function will return the device's time. Otherwise, it returns the system time.
|
|
18
|
-
*
|
|
19
|
-
* This is useful when:
|
|
20
|
-
* - Testing on devices with different time zones
|
|
21
|
-
* - Debugging time-sensitive features
|
|
22
|
-
* - The system clock and device clock are not synchronized
|
|
23
|
-
*
|
|
24
|
-
* @param device Optional device interface that supports getTimestamp
|
|
25
|
-
* @param useDeviceTimestamp Whether to use device timestamp (from agent config)
|
|
26
|
-
* @returns Timestamp in milliseconds
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* // Without device - always returns system time
|
|
30
|
-
* const systemTime = await getCurrentTime();
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* // With device and config enabled - returns device time
|
|
34
|
-
* const deviceTime = await getCurrentTime(androidDevice, true);
|
|
35
|
-
*/
|
|
36
|
-
export declare function getCurrentTime(device?: DeviceWithTimestamp, useDeviceTimestamp?: boolean): Promise<number>;
|
|
37
6
|
export declare const getPreferredLanguage: () => string;
|
|
38
7
|
export declare const overrideAIConfig: (newConfig: Partial<Record<(typeof GLOBAL_ENV_KEYS)[number] | (typeof MODEL_ENV_KEYS)[number], string>>, extendMode?: boolean) => void;
|
package/package.json
CHANGED
|
@@ -24,10 +24,26 @@ import {
|
|
|
24
24
|
} from './types';
|
|
25
25
|
|
|
26
26
|
import { getDebug } from '../logger';
|
|
27
|
+
|
|
27
28
|
import { assert } from '../utils';
|
|
28
29
|
import { maskConfig, parseJson } from './helper';
|
|
29
30
|
import { initDebugConfig } from './init-debug';
|
|
30
31
|
|
|
32
|
+
declare const __VERSION__: string | undefined;
|
|
33
|
+
|
|
34
|
+
const MODEL_CONFIG_DOC_URL = 'https://midscenejs.com/model-common-config.html';
|
|
35
|
+
|
|
36
|
+
const getCurrentVersion = (): string => {
|
|
37
|
+
if (typeof __VERSION__ !== 'undefined' && __VERSION__) {
|
|
38
|
+
return __VERSION__;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return 'unknown';
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const getInvalidModelFamilyMessage = (modelFamily: TModelFamily): string =>
|
|
45
|
+
`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.`;
|
|
46
|
+
|
|
31
47
|
type TModelConfigKeys =
|
|
32
48
|
| typeof INSIGHT_MODEL_CONFIG_KEYS
|
|
33
49
|
| typeof PLANNING_MODEL_CONFIG_KEYS
|
|
@@ -70,7 +86,7 @@ export const getUITarsModelVersion = (
|
|
|
70
86
|
*/
|
|
71
87
|
export const validateModelFamily = (modelFamily?: TModelFamily): void => {
|
|
72
88
|
if (modelFamily && !MODEL_FAMILY_VALUES.includes(modelFamily as any)) {
|
|
73
|
-
throw new Error(
|
|
89
|
+
throw new Error(getInvalidModelFamilyMessage(modelFamily));
|
|
74
90
|
}
|
|
75
91
|
};
|
|
76
92
|
|
package/src/env/utils.ts
CHANGED
|
@@ -13,56 +13,6 @@ export const globalConfigManager = new GlobalConfigManager();
|
|
|
13
13
|
globalConfigManager.registerModelConfigManager(globalModelConfigManager);
|
|
14
14
|
globalModelConfigManager.registerGlobalConfigManager(globalConfigManager);
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* Interface for devices that support getTimestamp method.
|
|
18
|
-
* This is a minimal interface to avoid circular dependencies with @midscene/core.
|
|
19
|
-
*/
|
|
20
|
-
export interface DeviceWithTimestamp {
|
|
21
|
-
getTimestamp?: () => Promise<number>;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Get the current timestamp, optionally from the target device.
|
|
26
|
-
*
|
|
27
|
-
* When useDeviceTimestamp is enabled and a device with getTimestamp is provided,
|
|
28
|
-
* this function will return the device's time. Otherwise, it returns the system time.
|
|
29
|
-
*
|
|
30
|
-
* This is useful when:
|
|
31
|
-
* - Testing on devices with different time zones
|
|
32
|
-
* - Debugging time-sensitive features
|
|
33
|
-
* - The system clock and device clock are not synchronized
|
|
34
|
-
*
|
|
35
|
-
* @param device Optional device interface that supports getTimestamp
|
|
36
|
-
* @param useDeviceTimestamp Whether to use device timestamp (from agent config)
|
|
37
|
-
* @returns Timestamp in milliseconds
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* // Without device - always returns system time
|
|
41
|
-
* const systemTime = await getCurrentTime();
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* // With device and config enabled - returns device time
|
|
45
|
-
* const deviceTime = await getCurrentTime(androidDevice, true);
|
|
46
|
-
*/
|
|
47
|
-
export async function getCurrentTime(
|
|
48
|
-
device?: DeviceWithTimestamp,
|
|
49
|
-
useDeviceTimestamp?: boolean,
|
|
50
|
-
): Promise<number> {
|
|
51
|
-
if (useDeviceTimestamp && device?.getTimestamp) {
|
|
52
|
-
try {
|
|
53
|
-
return await device.getTimestamp();
|
|
54
|
-
} catch (error) {
|
|
55
|
-
// Fall back to system time if device time retrieval fails
|
|
56
|
-
console.warn(
|
|
57
|
-
`Failed to get device time, falling back to system time: ${error}`,
|
|
58
|
-
);
|
|
59
|
-
return Date.now();
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return Date.now();
|
|
64
|
-
}
|
|
65
|
-
|
|
66
16
|
export const getPreferredLanguage = () => {
|
|
67
17
|
const prefer = globalConfigManager.getEnvConfigValue(
|
|
68
18
|
MIDSCENE_PREFERRED_LANGUAGE,
|