@midscene/shared 1.8.0 → 1.8.1-beta-20260513084557.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/model-config-manager.mjs +3 -0
- package/dist/es/env/parse-model-config.mjs +3 -1
- package/dist/lib/env/model-config-manager.js +3 -0
- package/dist/lib/env/parse-model-config.js +3 -1
- package/dist/types/env/types.d.ts +9 -2
- package/package.json +1 -1
- package/src/env/model-config-manager.ts +3 -0
- package/src/env/parse-model-config.ts +2 -0
- package/src/env/types.ts +9 -2
|
@@ -24,14 +24,17 @@ class ModelConfigManager {
|
|
|
24
24
|
this.modelConfigMap = {
|
|
25
25
|
default: {
|
|
26
26
|
...defaultConfig,
|
|
27
|
+
intent: 'default',
|
|
27
28
|
createOpenAIClient: this.createOpenAIClientFn
|
|
28
29
|
},
|
|
29
30
|
insight: {
|
|
30
31
|
...insightConfig || defaultConfig,
|
|
32
|
+
intent: 'insight',
|
|
31
33
|
createOpenAIClient: this.createOpenAIClientFn
|
|
32
34
|
},
|
|
33
35
|
planning: {
|
|
34
36
|
...planningConfig || defaultConfig,
|
|
37
|
+
intent: 'planning',
|
|
35
38
|
createOpenAIClient: this.createOpenAIClientFn
|
|
36
39
|
}
|
|
37
40
|
};
|
|
@@ -5,7 +5,7 @@ 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.8.0";
|
|
8
|
+
const getCurrentVersion = ()=>"1.8.1-beta-20260513084557.0";
|
|
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
|
insight: INSIGHT_MODEL_CONFIG_KEYS,
|
|
@@ -93,6 +93,7 @@ const parseOpenaiSdkConfig = ({ keys, provider, useLegacyLogic = false })=>{
|
|
|
93
93
|
modelName: modelName,
|
|
94
94
|
modelDescription,
|
|
95
95
|
intent: '-',
|
|
96
|
+
slot: '-',
|
|
96
97
|
timeout: provider[keys.timeout] ? Number(provider[keys.timeout]) : void 0,
|
|
97
98
|
temperature,
|
|
98
99
|
retryCount: (()=>{
|
|
@@ -135,6 +136,7 @@ const decideModelConfigFromIntentConfig = (intent, configMap)=>{
|
|
|
135
136
|
useLegacyLogic: 'default' === intent
|
|
136
137
|
});
|
|
137
138
|
finalResult.intent = intent;
|
|
139
|
+
finalResult.slot = intent;
|
|
138
140
|
debugLog('decideModelConfig result by agent.modelConfig() with intent', intent, maskConfig({
|
|
139
141
|
...finalResult
|
|
140
142
|
}));
|
|
@@ -52,14 +52,17 @@ class ModelConfigManager {
|
|
|
52
52
|
this.modelConfigMap = {
|
|
53
53
|
default: {
|
|
54
54
|
...defaultConfig,
|
|
55
|
+
intent: 'default',
|
|
55
56
|
createOpenAIClient: this.createOpenAIClientFn
|
|
56
57
|
},
|
|
57
58
|
insight: {
|
|
58
59
|
...insightConfig || defaultConfig,
|
|
60
|
+
intent: 'insight',
|
|
59
61
|
createOpenAIClient: this.createOpenAIClientFn
|
|
60
62
|
},
|
|
61
63
|
planning: {
|
|
62
64
|
...planningConfig || defaultConfig,
|
|
65
|
+
intent: 'planning',
|
|
63
66
|
createOpenAIClient: this.createOpenAIClientFn
|
|
64
67
|
}
|
|
65
68
|
};
|
|
@@ -37,7 +37,7 @@ 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.8.0";
|
|
40
|
+
const getCurrentVersion = ()=>"1.8.1-beta-20260513084557.0";
|
|
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
|
insight: external_constants_js_namespaceObject.INSIGHT_MODEL_CONFIG_KEYS,
|
|
@@ -125,6 +125,7 @@ const parseOpenaiSdkConfig = ({ keys, provider, useLegacyLogic = false })=>{
|
|
|
125
125
|
modelName: modelName,
|
|
126
126
|
modelDescription,
|
|
127
127
|
intent: '-',
|
|
128
|
+
slot: '-',
|
|
128
129
|
timeout: provider[keys.timeout] ? Number(provider[keys.timeout]) : void 0,
|
|
129
130
|
temperature,
|
|
130
131
|
retryCount: (()=>{
|
|
@@ -167,6 +168,7 @@ const decideModelConfigFromIntentConfig = (intent, configMap)=>{
|
|
|
167
168
|
useLegacyLogic: 'default' === intent
|
|
168
169
|
});
|
|
169
170
|
finalResult.intent = intent;
|
|
171
|
+
finalResult.slot = intent;
|
|
170
172
|
debugLog('decideModelConfig result by agent.modelConfig() with intent', intent, (0, external_helper_js_namespaceObject.maskConfig)({
|
|
171
173
|
...finalResult
|
|
172
174
|
}));
|
|
@@ -204,7 +204,7 @@ export declare enum UITarsModelVersion {
|
|
|
204
204
|
}
|
|
205
205
|
/**
|
|
206
206
|
* Callback to create custom OpenAI client instance
|
|
207
|
-
* @param config - Resolved model configuration including apiKey, baseURL, modelName, intent, etc.
|
|
207
|
+
* @param config - Resolved model configuration including apiKey, baseURL, modelName, intent, slot, etc.
|
|
208
208
|
* @returns OpenAI client instance (can be wrapped with langsmith, langfuse, etc.)
|
|
209
209
|
*
|
|
210
210
|
* Note: Wrapper functions like langsmith's wrapOpenAI() return the same OpenAI instance
|
|
@@ -294,9 +294,16 @@ export interface IModelConfig {
|
|
|
294
294
|
uiTarsModelVersion?: UITarsModelVersion;
|
|
295
295
|
modelDescription: string;
|
|
296
296
|
/**
|
|
297
|
-
*
|
|
297
|
+
* The semantic intent this config is requested for.
|
|
298
|
+
* For example, getModelConfig('planning') always returns intent === 'planning'.
|
|
298
299
|
*/
|
|
299
300
|
intent: TIntent;
|
|
301
|
+
/**
|
|
302
|
+
* The model-config slot this config was resolved from.
|
|
303
|
+
* For example, getModelConfig('planning') may resolve from slot === 'default'
|
|
304
|
+
* when MIDSCENE_PLANNING_MODEL_NAME is not configured.
|
|
305
|
+
*/
|
|
306
|
+
slot: TIntent;
|
|
300
307
|
/**
|
|
301
308
|
* Custom OpenAI client factory function
|
|
302
309
|
*
|
package/package.json
CHANGED
|
@@ -68,14 +68,17 @@ export class ModelConfigManager {
|
|
|
68
68
|
this.modelConfigMap = {
|
|
69
69
|
default: {
|
|
70
70
|
...defaultConfig,
|
|
71
|
+
intent: 'default',
|
|
71
72
|
createOpenAIClient: this.createOpenAIClientFn,
|
|
72
73
|
},
|
|
73
74
|
insight: {
|
|
74
75
|
...(insightConfig || defaultConfig),
|
|
76
|
+
intent: 'insight',
|
|
75
77
|
createOpenAIClient: this.createOpenAIClientFn,
|
|
76
78
|
},
|
|
77
79
|
planning: {
|
|
78
80
|
...(planningConfig || defaultConfig),
|
|
81
|
+
intent: 'planning',
|
|
79
82
|
createOpenAIClient: this.createOpenAIClientFn,
|
|
80
83
|
},
|
|
81
84
|
};
|
|
@@ -244,6 +244,7 @@ export const parseOpenaiSdkConfig = ({
|
|
|
244
244
|
modelName: modelName!,
|
|
245
245
|
modelDescription,
|
|
246
246
|
intent: '-' as any,
|
|
247
|
+
slot: '-' as any,
|
|
247
248
|
timeout: provider[keys.timeout]
|
|
248
249
|
? Number(provider[keys.timeout])
|
|
249
250
|
: undefined,
|
|
@@ -308,6 +309,7 @@ export const decideModelConfigFromIntentConfig = (
|
|
|
308
309
|
useLegacyLogic: intent === 'default',
|
|
309
310
|
});
|
|
310
311
|
finalResult.intent = intent;
|
|
312
|
+
finalResult.slot = intent;
|
|
311
313
|
|
|
312
314
|
debugLog(
|
|
313
315
|
'decideModelConfig result by agent.modelConfig() with intent',
|
package/src/env/types.ts
CHANGED
|
@@ -427,7 +427,7 @@ export enum UITarsModelVersion {
|
|
|
427
427
|
|
|
428
428
|
/**
|
|
429
429
|
* Callback to create custom OpenAI client instance
|
|
430
|
-
* @param config - Resolved model configuration including apiKey, baseURL, modelName, intent, etc.
|
|
430
|
+
* @param config - Resolved model configuration including apiKey, baseURL, modelName, intent, slot, etc.
|
|
431
431
|
* @returns OpenAI client instance (can be wrapped with langsmith, langfuse, etc.)
|
|
432
432
|
*
|
|
433
433
|
* Note: Wrapper functions like langsmith's wrapOpenAI() return the same OpenAI instance
|
|
@@ -521,9 +521,16 @@ export interface IModelConfig {
|
|
|
521
521
|
uiTarsModelVersion?: UITarsModelVersion;
|
|
522
522
|
modelDescription: string;
|
|
523
523
|
/**
|
|
524
|
-
*
|
|
524
|
+
* The semantic intent this config is requested for.
|
|
525
|
+
* For example, getModelConfig('planning') always returns intent === 'planning'.
|
|
525
526
|
*/
|
|
526
527
|
intent: TIntent;
|
|
528
|
+
/**
|
|
529
|
+
* The model-config slot this config was resolved from.
|
|
530
|
+
* For example, getModelConfig('planning') may resolve from slot === 'default'
|
|
531
|
+
* when MIDSCENE_PLANNING_MODEL_NAME is not configured.
|
|
532
|
+
*/
|
|
533
|
+
slot: TIntent;
|
|
527
534
|
/**
|
|
528
535
|
* Custom OpenAI client factory function
|
|
529
536
|
*
|