@midscene/shared 0.28.2 → 0.28.3

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.
Files changed (36) hide show
  1. package/dist/es/env/{model-config.mjs → decide-model-config.mjs} +52 -50
  2. package/dist/es/env/global-config-manager.mjs +91 -0
  3. package/dist/es/env/index.mjs +3 -2
  4. package/dist/es/env/model-config-manager.mjs +95 -0
  5. package/dist/es/env/parse.mjs +8 -23
  6. package/dist/es/env/types.mjs +16 -1
  7. package/dist/es/env/utils.mjs +7 -52
  8. package/dist/lib/env/{model-config.js → decide-model-config.js} +57 -52
  9. package/dist/lib/env/global-config-manager.js +125 -0
  10. package/dist/lib/env/index.js +17 -8
  11. package/dist/lib/env/model-config-manager.js +129 -0
  12. package/dist/lib/env/parse.js +9 -27
  13. package/dist/lib/env/types.js +23 -2
  14. package/dist/lib/env/utils.js +12 -69
  15. package/dist/types/env/decide-model-config.d.ts +14 -0
  16. package/dist/types/env/global-config-manager.d.ts +32 -0
  17. package/dist/types/env/helper.d.ts +1 -1
  18. package/dist/types/env/index.d.ts +2 -1
  19. package/dist/types/env/model-config-manager.d.ts +23 -0
  20. package/dist/types/env/parse.d.ts +2 -13
  21. package/dist/types/env/types.d.ts +52 -2
  22. package/dist/types/env/utils.d.ts +4 -8
  23. package/package.json +1 -1
  24. package/src/env/{model-config.ts → decide-model-config.ts} +91 -139
  25. package/src/env/global-config-manager.ts +174 -0
  26. package/src/env/helper.ts +1 -1
  27. package/src/env/index.ts +2 -1
  28. package/src/env/model-config-manager.ts +135 -0
  29. package/src/env/parse.ts +5 -24
  30. package/src/env/types.ts +61 -3
  31. package/src/env/utils.ts +7 -98
  32. package/dist/es/env/global-config.mjs +0 -192
  33. package/dist/lib/env/global-config.js +0 -229
  34. package/dist/types/env/global-config.d.ts +0 -52
  35. package/dist/types/env/model-config.d.ts +0 -70
  36. package/src/env/global-config.ts +0 -329
@@ -1,192 +0,0 @@
1
- import { getDebug } from "../logger.mjs";
2
- import { initDebugConfig } from "./init-debug.mjs";
3
- import { decideModelConfig } from "./model-config.mjs";
4
- 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";
5
- function _define_property(obj, key, value) {
6
- if (key in obj) Object.defineProperty(obj, key, {
7
- value: value,
8
- enumerable: true,
9
- configurable: true,
10
- writable: true
11
- });
12
- else obj[key] = value;
13
- return obj;
14
- }
15
- const allConfigFromEnv = ()=>ALL_ENV_KEYS.reduce((p, name)=>({
16
- ...p,
17
- [name]: process.env[name]
18
- }), Object.create(null));
19
- const GLOBAL_CONFIG_MANAGER_UNINITIALIZED_FLAG = 'GLOBAL_CONFIG_MANAGER_UNINITIALIZED_FLAG';
20
- const isInChromeExtension = ()=>'undefined' != typeof chrome && chrome.runtime.id;
21
- const ALL_INTENTS = [
22
- 'VQA',
23
- 'default',
24
- 'grounding',
25
- 'planning'
26
- ];
27
- class GlobalConfigManager {
28
- initAllEnvConfig() {
29
- const envConfig = allConfigFromEnv();
30
- this.allEnvConfig = (()=>{
31
- if (this.override) {
32
- this.debugLog('initAllConfig with override from overrideAIConfig');
33
- const { newConfig, extendMode } = this.override;
34
- if (extendMode) {
35
- this.debugLog('initAllConfig with extend mode from overrideAIConfig');
36
- return {
37
- ...envConfig,
38
- ...newConfig
39
- };
40
- }
41
- this.debugLog('initAllConfig without override mode from overrideAIConfig');
42
- return {
43
- ...newConfig
44
- };
45
- }
46
- this.debugLog('initAllConfig without override from overrideAIConfig');
47
- return envConfig;
48
- })();
49
- }
50
- initIntentConfigFromFn() {
51
- const intentConfigFromFn = {
52
- VQA: void 0,
53
- default: void 0,
54
- grounding: void 0,
55
- planning: void 0
56
- };
57
- if (this.latestModelConfigFn) for (const i of ALL_INTENTS){
58
- const result = this.latestModelConfigFn({
59
- intent: i
60
- });
61
- if (!result) throw new Error(`The agent has an option named modelConfig is a function, but it return ${result} when call with intent ${i}, which should be a object.`);
62
- intentConfigFromFn[i] = result;
63
- }
64
- return intentConfigFromFn;
65
- }
66
- createUninitializedError(message) {
67
- const error = new Error(message);
68
- error[GLOBAL_CONFIG_MANAGER_UNINITIALIZED_FLAG] = true;
69
- return error;
70
- }
71
- reset() {
72
- console.warn('globalConfigManager.reset should only be called in Midscene owner unit test');
73
- this.initialized = false;
74
- this.override = void 0;
75
- this.allEnvConfig = void 0;
76
- this.keysHaveBeenRead = {};
77
- this.modelConfigByIntent = {
78
- VQA: void 0,
79
- default: void 0,
80
- grounding: void 0,
81
- planning: void 0
82
- };
83
- }
84
- initModelConfigForIntent() {
85
- this.initAllEnvConfig();
86
- const intentConfigFromFn = this.initIntentConfigFromFn();
87
- for (const i of ALL_INTENTS){
88
- const result = decideModelConfig({
89
- intent: i,
90
- allConfig: this.allEnvConfig,
91
- modelConfigFromFn: intentConfigFromFn[i]
92
- });
93
- this.modelConfigByIntent[i] = result;
94
- }
95
- }
96
- initModelConfigForChromeExtension() {
97
- this.initAllEnvConfig();
98
- this.modelConfigForChromeExtension = decideModelConfig({
99
- intent: 'default',
100
- allConfig: this.allEnvConfig,
101
- modelConfigFromFn: void 0
102
- });
103
- }
104
- init(modelConfigFn) {
105
- this.latestModelConfigFn = modelConfigFn;
106
- this.initModelConfigForIntent();
107
- this.initialized = true;
108
- }
109
- getModelConfigByIntent(intent) {
110
- if (!this.initialized) {
111
- if (isInChromeExtension()) {
112
- console.warn('globalConfigManager is not initialized but was called in chrome Extension, will get model config from env');
113
- if (!this.modelConfigForChromeExtension) this.initModelConfigForChromeExtension();
114
- return this.modelConfigForChromeExtension;
115
- }
116
- throw this.createUninitializedError(`globalConfigManager is not initialized when call getModelConfigByIntent with intent ${intent}`);
117
- }
118
- return this.modelConfigByIntent[intent];
119
- }
120
- getEnvConfigValue(key) {
121
- const allConfig = this.allEnvConfig || process.env;
122
- if (!STRING_ENV_KEYS.includes(key)) throw new Error(`getEnvConfigValue with key ${key} is not supported.`);
123
- if (key === MATCH_BY_POSITION) throw new Error('MATCH_BY_POSITION is deprecated, use MIDSCENE_USE_VL_MODEL instead');
124
- const value = allConfig[key];
125
- this.keysHaveBeenRead[key] = true;
126
- if ('string' == typeof value) return value.trim();
127
- return value;
128
- }
129
- getEnvConfigInNumber(key) {
130
- const allConfig = this.allEnvConfig || process.env;
131
- if (!NUMBER_ENV_KEYS.includes(key)) throw new Error(`getEnvConfigInNumber with key ${key} is not supported`);
132
- const value = allConfig[key];
133
- this.keysHaveBeenRead[key] = true;
134
- return Number(value || '');
135
- }
136
- getEnvConfigInBoolean(key) {
137
- const allConfig = this.allEnvConfig || process.env;
138
- if (!BOOLEAN_ENV_KEYS.includes(key)) throw new Error(`getEnvConfigInBoolean with key ${key} is not supported`);
139
- const value = allConfig[key];
140
- this.keysHaveBeenRead[key] = true;
141
- if (!value) return false;
142
- if (/^(true|1)$/i.test(value)) return true;
143
- if (/^(false|0)$/i.test(value)) return false;
144
- return !!value.trim();
145
- }
146
- registerOverride(newConfig, extendMode = false) {
147
- var _this_override;
148
- for(const key in newConfig){
149
- if (![
150
- ...GLOBAL_ENV_KEYS,
151
- ...MODEL_ENV_KEYS
152
- ].includes(key)) throw new Error(`Failed to override AI config, invalid key: ${key}`);
153
- const value = newConfig[key];
154
- if ('string' != typeof value) throw new Error(`Failed to override AI config, value for key ${key} must be a string, but got with type ${typeof value}`);
155
- if (this.keysHaveBeenRead[key]) console.warn(`Warning: try to override AI config with key ${key} ,but it has been read.`);
156
- }
157
- const savedNewConfig = extendMode ? {
158
- ...null == (_this_override = this.override) ? void 0 : _this_override.newConfig,
159
- ...newConfig
160
- } : newConfig;
161
- this.override = {
162
- newConfig: {
163
- ...savedNewConfig
164
- },
165
- extendMode
166
- };
167
- if (this.initialized) this.initModelConfigForIntent();
168
- else {
169
- this.initAllEnvConfig();
170
- this.modelConfigForChromeExtension = void 0;
171
- }
172
- }
173
- constructor(){
174
- _define_property(this, "override", void 0);
175
- _define_property(this, "initialized", false);
176
- _define_property(this, "debugLog", void 0);
177
- _define_property(this, "modelConfigByIntent", {
178
- VQA: void 0,
179
- default: void 0,
180
- grounding: void 0,
181
- planning: void 0
182
- });
183
- _define_property(this, "allEnvConfig", void 0);
184
- _define_property(this, "keysHaveBeenRead", {});
185
- _define_property(this, "latestModelConfigFn", void 0);
186
- _define_property(this, "modelConfigForChromeExtension", void 0);
187
- initDebugConfig();
188
- const debugLog = getDebug('ai:global-config');
189
- this.debugLog = debugLog;
190
- }
191
- }
192
- export { GLOBAL_CONFIG_MANAGER_UNINITIALIZED_FLAG, GlobalConfigManager };
@@ -1,229 +0,0 @@
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
- GLOBAL_CONFIG_MANAGER_UNINITIALIZED_FLAG: ()=>GLOBAL_CONFIG_MANAGER_UNINITIALIZED_FLAG,
28
- GlobalConfigManager: ()=>GlobalConfigManager
29
- });
30
- const external_logger_js_namespaceObject = require("../logger.js");
31
- const external_init_debug_js_namespaceObject = require("./init-debug.js");
32
- const external_model_config_js_namespaceObject = require("./model-config.js");
33
- const external_types_js_namespaceObject = require("./types.js");
34
- function _define_property(obj, key, value) {
35
- if (key in obj) Object.defineProperty(obj, key, {
36
- value: value,
37
- enumerable: true,
38
- configurable: true,
39
- writable: true
40
- });
41
- else obj[key] = value;
42
- return obj;
43
- }
44
- const allConfigFromEnv = ()=>external_types_js_namespaceObject.ALL_ENV_KEYS.reduce((p, name)=>({
45
- ...p,
46
- [name]: process.env[name]
47
- }), Object.create(null));
48
- const GLOBAL_CONFIG_MANAGER_UNINITIALIZED_FLAG = 'GLOBAL_CONFIG_MANAGER_UNINITIALIZED_FLAG';
49
- const isInChromeExtension = ()=>'undefined' != typeof chrome && chrome.runtime.id;
50
- const ALL_INTENTS = [
51
- 'VQA',
52
- 'default',
53
- 'grounding',
54
- 'planning'
55
- ];
56
- class GlobalConfigManager {
57
- initAllEnvConfig() {
58
- const envConfig = allConfigFromEnv();
59
- this.allEnvConfig = (()=>{
60
- if (this.override) {
61
- this.debugLog('initAllConfig with override from overrideAIConfig');
62
- const { newConfig, extendMode } = this.override;
63
- if (extendMode) {
64
- this.debugLog('initAllConfig with extend mode from overrideAIConfig');
65
- return {
66
- ...envConfig,
67
- ...newConfig
68
- };
69
- }
70
- this.debugLog('initAllConfig without override mode from overrideAIConfig');
71
- return {
72
- ...newConfig
73
- };
74
- }
75
- this.debugLog('initAllConfig without override from overrideAIConfig');
76
- return envConfig;
77
- })();
78
- }
79
- initIntentConfigFromFn() {
80
- const intentConfigFromFn = {
81
- VQA: void 0,
82
- default: void 0,
83
- grounding: void 0,
84
- planning: void 0
85
- };
86
- if (this.latestModelConfigFn) for (const i of ALL_INTENTS){
87
- const result = this.latestModelConfigFn({
88
- intent: i
89
- });
90
- if (!result) throw new Error(`The agent has an option named modelConfig is a function, but it return ${result} when call with intent ${i}, which should be a object.`);
91
- intentConfigFromFn[i] = result;
92
- }
93
- return intentConfigFromFn;
94
- }
95
- createUninitializedError(message) {
96
- const error = new Error(message);
97
- error[GLOBAL_CONFIG_MANAGER_UNINITIALIZED_FLAG] = true;
98
- return error;
99
- }
100
- reset() {
101
- console.warn('globalConfigManager.reset should only be called in Midscene owner unit test');
102
- this.initialized = false;
103
- this.override = void 0;
104
- this.allEnvConfig = void 0;
105
- this.keysHaveBeenRead = {};
106
- this.modelConfigByIntent = {
107
- VQA: void 0,
108
- default: void 0,
109
- grounding: void 0,
110
- planning: void 0
111
- };
112
- }
113
- initModelConfigForIntent() {
114
- this.initAllEnvConfig();
115
- const intentConfigFromFn = this.initIntentConfigFromFn();
116
- for (const i of ALL_INTENTS){
117
- const result = (0, external_model_config_js_namespaceObject.decideModelConfig)({
118
- intent: i,
119
- allConfig: this.allEnvConfig,
120
- modelConfigFromFn: intentConfigFromFn[i]
121
- });
122
- this.modelConfigByIntent[i] = result;
123
- }
124
- }
125
- initModelConfigForChromeExtension() {
126
- this.initAllEnvConfig();
127
- this.modelConfigForChromeExtension = (0, external_model_config_js_namespaceObject.decideModelConfig)({
128
- intent: 'default',
129
- allConfig: this.allEnvConfig,
130
- modelConfigFromFn: void 0
131
- });
132
- }
133
- init(modelConfigFn) {
134
- this.latestModelConfigFn = modelConfigFn;
135
- this.initModelConfigForIntent();
136
- this.initialized = true;
137
- }
138
- getModelConfigByIntent(intent) {
139
- if (!this.initialized) {
140
- if (isInChromeExtension()) {
141
- console.warn('globalConfigManager is not initialized but was called in chrome Extension, will get model config from env');
142
- if (!this.modelConfigForChromeExtension) this.initModelConfigForChromeExtension();
143
- return this.modelConfigForChromeExtension;
144
- }
145
- throw this.createUninitializedError(`globalConfigManager is not initialized when call getModelConfigByIntent with intent ${intent}`);
146
- }
147
- return this.modelConfigByIntent[intent];
148
- }
149
- getEnvConfigValue(key) {
150
- const allConfig = this.allEnvConfig || process.env;
151
- if (!external_types_js_namespaceObject.STRING_ENV_KEYS.includes(key)) throw new Error(`getEnvConfigValue with key ${key} is not supported.`);
152
- if (key === external_types_js_namespaceObject.MATCH_BY_POSITION) throw new Error('MATCH_BY_POSITION is deprecated, use MIDSCENE_USE_VL_MODEL instead');
153
- const value = allConfig[key];
154
- this.keysHaveBeenRead[key] = true;
155
- if ('string' == typeof value) return value.trim();
156
- return value;
157
- }
158
- getEnvConfigInNumber(key) {
159
- const allConfig = this.allEnvConfig || process.env;
160
- if (!external_types_js_namespaceObject.NUMBER_ENV_KEYS.includes(key)) throw new Error(`getEnvConfigInNumber with key ${key} is not supported`);
161
- const value = allConfig[key];
162
- this.keysHaveBeenRead[key] = true;
163
- return Number(value || '');
164
- }
165
- getEnvConfigInBoolean(key) {
166
- const allConfig = this.allEnvConfig || process.env;
167
- if (!external_types_js_namespaceObject.BOOLEAN_ENV_KEYS.includes(key)) throw new Error(`getEnvConfigInBoolean with key ${key} is not supported`);
168
- const value = allConfig[key];
169
- this.keysHaveBeenRead[key] = true;
170
- if (!value) return false;
171
- if (/^(true|1)$/i.test(value)) return true;
172
- if (/^(false|0)$/i.test(value)) return false;
173
- return !!value.trim();
174
- }
175
- registerOverride(newConfig, extendMode = false) {
176
- var _this_override;
177
- for(const key in newConfig){
178
- if (![
179
- ...external_types_js_namespaceObject.GLOBAL_ENV_KEYS,
180
- ...external_types_js_namespaceObject.MODEL_ENV_KEYS
181
- ].includes(key)) throw new Error(`Failed to override AI config, invalid key: ${key}`);
182
- const value = newConfig[key];
183
- if ('string' != typeof value) throw new Error(`Failed to override AI config, value for key ${key} must be a string, but got with type ${typeof value}`);
184
- if (this.keysHaveBeenRead[key]) console.warn(`Warning: try to override AI config with key ${key} ,but it has been read.`);
185
- }
186
- const savedNewConfig = extendMode ? {
187
- ...null == (_this_override = this.override) ? void 0 : _this_override.newConfig,
188
- ...newConfig
189
- } : newConfig;
190
- this.override = {
191
- newConfig: {
192
- ...savedNewConfig
193
- },
194
- extendMode
195
- };
196
- if (this.initialized) this.initModelConfigForIntent();
197
- else {
198
- this.initAllEnvConfig();
199
- this.modelConfigForChromeExtension = void 0;
200
- }
201
- }
202
- constructor(){
203
- _define_property(this, "override", void 0);
204
- _define_property(this, "initialized", false);
205
- _define_property(this, "debugLog", void 0);
206
- _define_property(this, "modelConfigByIntent", {
207
- VQA: void 0,
208
- default: void 0,
209
- grounding: void 0,
210
- planning: void 0
211
- });
212
- _define_property(this, "allEnvConfig", void 0);
213
- _define_property(this, "keysHaveBeenRead", {});
214
- _define_property(this, "latestModelConfigFn", void 0);
215
- _define_property(this, "modelConfigForChromeExtension", void 0);
216
- (0, external_init_debug_js_namespaceObject.initDebugConfig)();
217
- const debugLog = (0, external_logger_js_namespaceObject.getDebug)('ai:global-config');
218
- this.debugLog = debugLog;
219
- }
220
- }
221
- exports.GLOBAL_CONFIG_MANAGER_UNINITIALIZED_FLAG = __webpack_exports__.GLOBAL_CONFIG_MANAGER_UNINITIALIZED_FLAG;
222
- exports.GlobalConfigManager = __webpack_exports__.GlobalConfigManager;
223
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
224
- "GLOBAL_CONFIG_MANAGER_UNINITIALIZED_FLAG",
225
- "GlobalConfigManager"
226
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
227
- Object.defineProperty(exports, '__esModule', {
228
- value: true
229
- });
@@ -1,52 +0,0 @@
1
- import { type IModelConfig } from './model-config';
2
- import { BOOLEAN_ENV_KEYS, GLOBAL_ENV_KEYS, NUMBER_ENV_KEYS, STRING_ENV_KEYS } from './types';
3
- import { MODEL_ENV_KEYS, type TIntent, type TModelConfigFn } from './types';
4
- export declare const GLOBAL_CONFIG_MANAGER_UNINITIALIZED_FLAG = "GLOBAL_CONFIG_MANAGER_UNINITIALIZED_FLAG";
5
- declare global {
6
- const chrome: {
7
- runtime: {
8
- id: string;
9
- };
10
- };
11
- }
12
- /**
13
- * Collect global configs from process.env, overrideAIConfig, modelConfig, etc.
14
- * And provider methods to get merged config value
15
- */
16
- export declare class GlobalConfigManager {
17
- private override;
18
- private initialized;
19
- private debugLog;
20
- private modelConfigByIntent;
21
- private allEnvConfig;
22
- private keysHaveBeenRead;
23
- private latestModelConfigFn?;
24
- private modelConfigForChromeExtension;
25
- constructor();
26
- private initAllEnvConfig;
27
- private initIntentConfigFromFn;
28
- private createUninitializedError;
29
- reset(): void;
30
- private initModelConfigForIntent;
31
- private initModelConfigForChromeExtension;
32
- /**
33
- * init and decide all global config value,
34
- * should be called at Agent.constructor
35
- */
36
- init(modelConfigFn?: TModelConfigFn): void;
37
- getModelConfigByIntent(intent: TIntent): IModelConfig;
38
- getEnvConfigValue(key: (typeof STRING_ENV_KEYS)[number]): string | undefined;
39
- /**
40
- * read number only from process.env
41
- */
42
- getEnvConfigInNumber(key: (typeof NUMBER_ENV_KEYS)[number]): number;
43
- /**
44
- * read boolean only from process.env
45
- */
46
- getEnvConfigInBoolean(key: (typeof BOOLEAN_ENV_KEYS)[number]): boolean;
47
- /**
48
- * for overrideAIConfig
49
- * can only override keys in MODEL_ENV_KEYS
50
- */
51
- registerOverride(newConfig: Partial<Record<(typeof GLOBAL_ENV_KEYS)[number] | (typeof MODEL_ENV_KEYS)[number], string>>, extendMode?: boolean): void;
52
- }
@@ -1,70 +0,0 @@
1
- import type { TIntent } from './types';
2
- import { DEFAULT_MODEL_CONFIG_KEYS, DEFAULT_MODEL_CONFIG_KEYS_LEGACY, GROUNDING_MODEL_CONFIG_KEYS, PLANNING_MODEL_CONFIG_KEYS, VQA_MODEL_CONFIG_KEYS } from './constants';
3
- import { type UITarsModelVersion } from './parse';
4
- export interface IModelConfig {
5
- /**
6
- * proxy
7
- */
8
- socksProxy?: string;
9
- httpProxy?: string;
10
- /**
11
- * model
12
- */
13
- modelName: string;
14
- /**
15
- * OpenAI
16
- */
17
- openaiBaseURL?: string;
18
- openaiApiKey?: string;
19
- openaiExtraConfig?: Record<string, unknown>;
20
- /**
21
- * Azure
22
- */
23
- openaiUseAzureDeprecated?: boolean;
24
- useAzureOpenai?: boolean;
25
- azureOpenaiScope?: string;
26
- azureOpenaiKey?: string;
27
- azureOpenaiEndpoint?: string;
28
- azureOpenaiApiVersion?: string;
29
- azureOpenaiDeployment?: string;
30
- azureExtraConfig?: Record<string, unknown>;
31
- /**
32
- * Anthropic
33
- */
34
- useAnthropicSdk?: boolean;
35
- anthropicApiKey?: string;
36
- /**
37
- * - vlModeRaw: exists only in non-legacy logic. value can be 'doubao-vision', 'gemini', 'qwen-vl', 'vlm-ui-tars', 'vlm-ui-tars-doubao', 'vlm-ui-tars-doubao-1.5'
38
- * - vlMode: based on the results of the vlModoRaw classification,value can be 'doubao-vision', 'gemini', 'qwen-vl', 'vlm-ui-tars'
39
- */
40
- vlModeRaw?: string;
41
- vlMode?: string;
42
- uiTarsVersion?: UITarsModelVersion;
43
- modelDescription: string;
44
- /**
45
- * for debug
46
- */
47
- from: 'modelConfig' | 'env' | 'legacy-env';
48
- }
49
- type TModelConfigKeys = typeof VQA_MODEL_CONFIG_KEYS | typeof GROUNDING_MODEL_CONFIG_KEYS | typeof PLANNING_MODEL_CONFIG_KEYS | typeof DEFAULT_MODEL_CONFIG_KEYS | typeof DEFAULT_MODEL_CONFIG_KEYS_LEGACY;
50
- /**
51
- * Choose OpenAI SDK config, such as OpenAI, AzureOpenAI, AnthropicSDK, etc.
52
- */
53
- export declare const decideOpenaiSdkConfig: ({ keys, provider, valueAssert, }: {
54
- keys: TModelConfigKeys;
55
- provider: Record<string, string | undefined>;
56
- valueAssert: (value: string | undefined, key: string, modelVendorFlag?: string) => void;
57
- }) => Omit<IModelConfig, "modelName" | "from" | "vlMode" | "uiTarsVersion" | "modelDescription">;
58
- /**
59
- * get and validate model config for model client
60
- * priority order:
61
- * - modelConfigFn result
62
- * - process.env.MIDSCENE_${intent}_MODEL_NAME
63
- * - PROCESS.ENV.MIDSCENE_MODEL_NAME
64
- */
65
- export declare const decideModelConfig: ({ intent, modelConfigFromFn, allConfig, }: {
66
- intent: TIntent;
67
- modelConfigFromFn: Record<string, string | undefined> | undefined;
68
- allConfig: Record<string, string | undefined>;
69
- }) => IModelConfig;
70
- export {};