@midscene/shared 0.30.10 → 1.0.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.
Files changed (129) hide show
  1. package/dist/es/build/rspack-config.mjs +4 -0
  2. package/dist/es/constants/example-code.mjs +4 -4
  3. package/dist/es/env/constants.mjs +27 -82
  4. package/dist/es/env/global-config-manager.mjs +2 -3
  5. package/dist/es/env/helper.mjs +12 -17
  6. package/dist/es/env/init-debug.mjs +6 -6
  7. package/dist/es/env/model-config-manager.mjs +45 -65
  8. package/dist/es/env/parse-model-config.mjs +112 -0
  9. package/dist/es/env/types.mjs +70 -162
  10. package/dist/es/extractor/dom-util.mjs +10 -18
  11. package/dist/es/extractor/index.mjs +2 -3
  12. package/dist/es/extractor/locator.mjs +8 -15
  13. package/dist/es/extractor/tree.mjs +2 -5
  14. package/dist/es/extractor/util.mjs +4 -28
  15. package/dist/es/extractor/web-extractor.mjs +7 -14
  16. package/dist/es/index.mjs +2 -1
  17. package/dist/es/mcp/base-server.mjs +250 -0
  18. package/dist/es/mcp/base-tools.mjs +84 -0
  19. package/dist/es/mcp/index.mjs +5 -0
  20. package/dist/es/mcp/inject-report-html-plugin.mjs +53 -0
  21. package/dist/es/mcp/tool-generator.mjs +207 -0
  22. package/dist/es/mcp/types.mjs +3 -0
  23. package/dist/es/node/fs.mjs +2 -2
  24. package/dist/es/utils.mjs +2 -3
  25. package/dist/es/zod-schema-utils.mjs +54 -0
  26. package/dist/lib/baseDB.js +2 -2
  27. package/dist/lib/build/copy-static.js +4 -4
  28. package/dist/lib/build/rspack-config.js +38 -0
  29. package/dist/lib/common.js +4 -4
  30. package/dist/lib/constants/example-code.js +6 -6
  31. package/dist/lib/constants/index.js +13 -13
  32. package/dist/lib/env/basic.js +2 -2
  33. package/dist/lib/env/constants.js +32 -90
  34. package/dist/lib/env/global-config-manager.js +4 -5
  35. package/dist/lib/env/helper.js +13 -22
  36. package/dist/lib/env/index.js +24 -28
  37. package/dist/lib/env/init-debug.js +7 -7
  38. package/dist/lib/env/model-config-manager.js +47 -67
  39. package/dist/lib/env/parse-model-config.js +155 -0
  40. package/dist/lib/env/types.js +146 -379
  41. package/dist/lib/env/utils.js +4 -4
  42. package/dist/lib/extractor/constants.js +4 -4
  43. package/dist/lib/extractor/debug.js +1 -1
  44. package/dist/lib/extractor/dom-util.js +18 -26
  45. package/dist/lib/extractor/index.js +11 -21
  46. package/dist/lib/extractor/locator.js +10 -20
  47. package/dist/lib/extractor/tree.js +4 -7
  48. package/dist/lib/extractor/util.js +17 -50
  49. package/dist/lib/extractor/web-extractor.js +12 -19
  50. package/dist/lib/img/box-select.js +4 -4
  51. package/dist/lib/img/draw-box.js +2 -2
  52. package/dist/lib/img/get-jimp.js +16 -34
  53. package/dist/lib/img/get-photon.js +24 -47
  54. package/dist/lib/img/get-sharp.js +16 -34
  55. package/dist/lib/img/index.js +18 -18
  56. package/dist/lib/img/info.js +4 -4
  57. package/dist/lib/img/transform.js +10 -10
  58. package/dist/lib/index.js +8 -4
  59. package/dist/lib/logger.js +4 -4
  60. package/dist/lib/mcp/base-server.js +300 -0
  61. package/dist/lib/mcp/base-tools.js +118 -0
  62. package/dist/lib/mcp/index.js +86 -0
  63. package/dist/lib/mcp/inject-report-html-plugin.js +98 -0
  64. package/dist/lib/mcp/tool-generator.js +244 -0
  65. package/dist/lib/mcp/types.js +40 -0
  66. package/dist/lib/node/fs.js +6 -6
  67. package/dist/lib/node/index.js +6 -8
  68. package/dist/lib/polyfills/async-hooks.js +2 -2
  69. package/dist/lib/polyfills/index.js +6 -8
  70. package/dist/lib/types/index.js +2 -2
  71. package/dist/lib/us-keyboard-layout.js +2 -2
  72. package/dist/lib/utils.js +13 -14
  73. package/dist/lib/zod-schema-utils.js +97 -0
  74. package/dist/types/build/rspack-config.d.ts +8 -0
  75. package/dist/types/constants/example-code.d.ts +1 -1
  76. package/dist/types/env/constants.d.ts +5 -18
  77. package/dist/types/env/global-config-manager.d.ts +1 -2
  78. package/dist/types/env/helper.d.ts +2 -4
  79. package/dist/types/env/model-config-manager.d.ts +8 -7
  80. package/dist/types/env/parse-model-config.d.ts +28 -0
  81. package/dist/types/env/types.d.ts +152 -191
  82. package/dist/types/extractor/dom-util.d.ts +2 -15
  83. package/dist/types/extractor/index.d.ts +1 -2
  84. package/dist/types/extractor/locator.d.ts +0 -1
  85. package/dist/types/extractor/tree.d.ts +1 -4
  86. package/dist/types/extractor/util.d.ts +0 -3
  87. package/dist/types/index.d.ts +1 -0
  88. package/dist/types/mcp/base-server.d.ts +77 -0
  89. package/dist/types/mcp/base-tools.d.ts +55 -0
  90. package/dist/types/mcp/index.d.ts +5 -0
  91. package/dist/types/mcp/inject-report-html-plugin.d.ts +18 -0
  92. package/dist/types/mcp/tool-generator.d.ts +11 -0
  93. package/dist/types/mcp/types.d.ts +100 -0
  94. package/dist/types/types/index.d.ts +5 -2
  95. package/dist/types/zod-schema-utils.d.ts +23 -0
  96. package/package.json +19 -4
  97. package/src/build/rspack-config.ts +12 -0
  98. package/src/constants/example-code.ts +4 -4
  99. package/src/env/constants.ts +58 -203
  100. package/src/env/global-config-manager.ts +7 -7
  101. package/src/env/helper.ts +10 -31
  102. package/src/env/init-debug.ts +11 -6
  103. package/src/env/model-config-manager.ts +91 -87
  104. package/src/env/parse-model-config.ts +265 -0
  105. package/src/env/types.ts +212 -344
  106. package/src/extractor/dom-util.ts +15 -12
  107. package/src/extractor/index.ts +0 -3
  108. package/src/extractor/locator.ts +3 -12
  109. package/src/extractor/tree.ts +4 -4
  110. package/src/extractor/util.ts +0 -32
  111. package/src/index.ts +2 -0
  112. package/src/mcp/base-server.ts +435 -0
  113. package/src/mcp/base-tools.ts +196 -0
  114. package/src/mcp/index.ts +5 -0
  115. package/src/mcp/inject-report-html-plugin.ts +119 -0
  116. package/src/mcp/tool-generator.ts +330 -0
  117. package/src/mcp/types.ts +108 -0
  118. package/src/node/fs.ts +1 -1
  119. package/src/types/index.ts +8 -2
  120. package/src/utils.ts +1 -1
  121. package/src/zod-schema-utils.ts +133 -0
  122. package/dist/es/env/decide-model-config.mjs +0 -172
  123. package/dist/es/env/parse.mjs +0 -69
  124. package/dist/lib/env/decide-model-config.js +0 -212
  125. package/dist/lib/env/parse.js +0 -106
  126. package/dist/types/env/decide-model-config.d.ts +0 -14
  127. package/dist/types/env/parse.d.ts +0 -12
  128. package/src/env/decide-model-config.ts +0 -319
  129. package/src/env/parse.ts +0 -131
@@ -24,21 +24,21 @@ var __webpack_require__ = {};
24
24
  var __webpack_exports__ = {};
25
25
  __webpack_require__.r(__webpack_exports__);
26
26
  __webpack_require__.d(__webpack_exports__, {
27
- PLAYGROUND_SERVER_PORT: ()=>PLAYGROUND_SERVER_PORT,
28
- DEFAULT_WAIT_FOR_NETWORK_IDLE_TIMEOUT: ()=>DEFAULT_WAIT_FOR_NETWORK_IDLE_TIMEOUT,
29
- SCRCPY_SERVER_PORT: ()=>SCRCPY_SERVER_PORT,
30
- TEXT_SIZE_THRESHOLD: ()=>TEXT_SIZE_THRESHOLD,
31
- YAML_EXAMPLE_CODE: ()=>external_example_code_js_namespaceObject.YAML_EXAMPLE_CODE,
32
- DEFAULT_WAIT_FOR_NETWORK_IDLE_CONCURRENCY: ()=>DEFAULT_WAIT_FOR_NETWORK_IDLE_CONCURRENCY,
33
27
  DEFAULT_WAIT_FOR_NAVIGATION_TIMEOUT: ()=>DEFAULT_WAIT_FOR_NAVIGATION_TIMEOUT,
28
+ YAML_EXAMPLE_CODE: ()=>external_example_code_js_namespaceObject.YAML_EXAMPLE_CODE,
29
+ WEBDRIVER_ELEMENT_ID_KEY: ()=>WEBDRIVER_ELEMENT_ID_KEY,
34
30
  CONTAINER_MINI_WIDTH: ()=>CONTAINER_MINI_WIDTH,
35
- CONTAINER_MINI_HEIGHT: ()=>CONTAINER_MINI_HEIGHT,
31
+ DEFAULT_WAIT_FOR_NETWORK_IDLE_CONCURRENCY: ()=>DEFAULT_WAIT_FOR_NETWORK_IDLE_CONCURRENCY,
32
+ DEFAULT_WAIT_FOR_NETWORK_IDLE_TIMEOUT: ()=>DEFAULT_WAIT_FOR_NETWORK_IDLE_TIMEOUT,
36
33
  TEXT_MAX_SIZE: ()=>TEXT_MAX_SIZE,
37
- NodeType: ()=>constants_NodeType,
38
- WEBDRIVER_ELEMENT_ID_KEY: ()=>WEBDRIVER_ELEMENT_ID_KEY,
39
- DEFAULT_WDA_PORT: ()=>DEFAULT_WDA_PORT,
34
+ CONTAINER_MINI_HEIGHT: ()=>CONTAINER_MINI_HEIGHT,
35
+ PLAYGROUND_SERVER_PORT: ()=>PLAYGROUND_SERVER_PORT,
40
36
  DEFAULT_WAIT_FOR_NETWORK_IDLE_TIME: ()=>DEFAULT_WAIT_FOR_NETWORK_IDLE_TIME,
41
- PLAYWRIGHT_EXAMPLE_CODE: ()=>external_example_code_js_namespaceObject.PLAYWRIGHT_EXAMPLE_CODE
37
+ DEFAULT_WDA_PORT: ()=>DEFAULT_WDA_PORT,
38
+ NodeType: ()=>constants_NodeType,
39
+ PLAYWRIGHT_EXAMPLE_CODE: ()=>external_example_code_js_namespaceObject.PLAYWRIGHT_EXAMPLE_CODE,
40
+ SCRCPY_SERVER_PORT: ()=>SCRCPY_SERVER_PORT,
41
+ TEXT_SIZE_THRESHOLD: ()=>TEXT_SIZE_THRESHOLD
42
42
  });
43
43
  const external_example_code_js_namespaceObject = require("./example-code.js");
44
44
  const TEXT_SIZE_THRESHOLD = 9;
@@ -78,7 +78,7 @@ exports.TEXT_MAX_SIZE = __webpack_exports__.TEXT_MAX_SIZE;
78
78
  exports.TEXT_SIZE_THRESHOLD = __webpack_exports__.TEXT_SIZE_THRESHOLD;
79
79
  exports.WEBDRIVER_ELEMENT_ID_KEY = __webpack_exports__.WEBDRIVER_ELEMENT_ID_KEY;
80
80
  exports.YAML_EXAMPLE_CODE = __webpack_exports__.YAML_EXAMPLE_CODE;
81
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
81
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
82
82
  "CONTAINER_MINI_HEIGHT",
83
83
  "CONTAINER_MINI_WIDTH",
84
84
  "DEFAULT_WAIT_FOR_NAVIGATION_TIMEOUT",
@@ -94,7 +94,7 @@ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
94
94
  "TEXT_SIZE_THRESHOLD",
95
95
  "WEBDRIVER_ELEMENT_ID_KEY",
96
96
  "YAML_EXAMPLE_CODE"
97
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
97
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
98
98
  Object.defineProperty(exports, '__esModule', {
99
99
  value: true
100
100
  });
@@ -32,9 +32,9 @@ const getBasicEnvValue = (key)=>{
32
32
  return process.env[key];
33
33
  };
34
34
  exports.getBasicEnvValue = __webpack_exports__.getBasicEnvValue;
35
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
35
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
36
36
  "getBasicEnvValue"
37
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
37
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
38
38
  Object.defineProperty(exports, '__esModule', {
39
39
  value: true
40
40
  });
@@ -24,88 +24,41 @@ var __webpack_require__ = {};
24
24
  var __webpack_exports__ = {};
25
25
  __webpack_require__.r(__webpack_exports__);
26
26
  __webpack_require__.d(__webpack_exports__, {
27
+ INSIGHT_MODEL_CONFIG_KEYS: ()=>INSIGHT_MODEL_CONFIG_KEYS,
27
28
  DEFAULT_MODEL_CONFIG_KEYS_LEGACY: ()=>DEFAULT_MODEL_CONFIG_KEYS_LEGACY,
28
- VQA_MODEL_CONFIG_KEYS: ()=>VQA_MODEL_CONFIG_KEYS,
29
29
  DEFAULT_MODEL_CONFIG_KEYS: ()=>DEFAULT_MODEL_CONFIG_KEYS,
30
- PLANNING_MODEL_CONFIG_KEYS: ()=>PLANNING_MODEL_CONFIG_KEYS,
31
- GROUNDING_MODEL_CONFIG_KEYS: ()=>GROUNDING_MODEL_CONFIG_KEYS
30
+ PLANNING_MODEL_CONFIG_KEYS: ()=>PLANNING_MODEL_CONFIG_KEYS
32
31
  });
33
32
  const external_types_js_namespaceObject = require("./types.js");
34
- const VQA_MODEL_CONFIG_KEYS = {
35
- modelName: external_types_js_namespaceObject.MIDSCENE_VQA_MODEL_NAME,
36
- socksProxy: external_types_js_namespaceObject.MIDSCENE_VQA_OPENAI_SOCKS_PROXY,
37
- httpProxy: external_types_js_namespaceObject.MIDSCENE_VQA_OPENAI_HTTP_PROXY,
38
- openaiBaseURL: external_types_js_namespaceObject.MIDSCENE_VQA_OPENAI_BASE_URL,
39
- openaiApiKey: external_types_js_namespaceObject.MIDSCENE_VQA_OPENAI_API_KEY,
40
- openaiExtraConfig: external_types_js_namespaceObject.MIDSCENE_VQA_OPENAI_INIT_CONFIG_JSON,
41
- openaiUseAzureDeprecated: external_types_js_namespaceObject.MIDSCENE_VQA_OPENAI_USE_AZURE,
42
- useAzureOpenai: external_types_js_namespaceObject.MIDSCENE_VQA_USE_AZURE_OPENAI,
43
- azureOpenaiScope: external_types_js_namespaceObject.MIDSCENE_VQA_AZURE_OPENAI_SCOPE,
44
- azureOpenaiKey: external_types_js_namespaceObject.MIDSCENE_VQA_AZURE_OPENAI_KEY,
45
- azureOpenaiEndpoint: external_types_js_namespaceObject.MIDSCENE_VQA_AZURE_OPENAI_ENDPOINT,
46
- azureOpenaiApiVersion: external_types_js_namespaceObject.MIDSCENE_VQA_AZURE_OPENAI_API_VERSION,
47
- azureOpenaiDeployment: external_types_js_namespaceObject.MIDSCENE_VQA_AZURE_OPENAI_DEPLOYMENT,
48
- azureExtraConfig: external_types_js_namespaceObject.MIDSCENE_VQA_AZURE_OPENAI_INIT_CONFIG_JSON,
49
- useAnthropicSdk: external_types_js_namespaceObject.MIDSCENE_VQA_USE_ANTHROPIC_SDK,
50
- anthropicApiKey: external_types_js_namespaceObject.MIDSCENE_VQA_ANTHROPIC_API_KEY,
51
- vlMode: external_types_js_namespaceObject.MIDSCENE_VQA_VL_MODE
52
- };
53
- const GROUNDING_MODEL_CONFIG_KEYS = {
54
- modelName: external_types_js_namespaceObject.MIDSCENE_GROUNDING_MODEL_NAME,
55
- socksProxy: external_types_js_namespaceObject.MIDSCENE_GROUNDING_OPENAI_SOCKS_PROXY,
56
- httpProxy: external_types_js_namespaceObject.MIDSCENE_GROUNDING_OPENAI_HTTP_PROXY,
57
- openaiBaseURL: external_types_js_namespaceObject.MIDSCENE_GROUNDING_OPENAI_BASE_URL,
58
- openaiApiKey: external_types_js_namespaceObject.MIDSCENE_GROUNDING_OPENAI_API_KEY,
59
- openaiExtraConfig: external_types_js_namespaceObject.MIDSCENE_GROUNDING_OPENAI_INIT_CONFIG_JSON,
60
- openaiUseAzureDeprecated: external_types_js_namespaceObject.MIDSCENE_GROUNDING_OPENAI_USE_AZURE,
61
- useAzureOpenai: external_types_js_namespaceObject.MIDSCENE_GROUNDING_USE_AZURE_OPENAI,
62
- azureOpenaiScope: external_types_js_namespaceObject.MIDSCENE_GROUNDING_AZURE_OPENAI_SCOPE,
63
- azureOpenaiKey: external_types_js_namespaceObject.MIDSCENE_GROUNDING_AZURE_OPENAI_KEY,
64
- azureOpenaiEndpoint: external_types_js_namespaceObject.MIDSCENE_GROUNDING_AZURE_OPENAI_ENDPOINT,
65
- azureOpenaiApiVersion: external_types_js_namespaceObject.MIDSCENE_GROUNDING_AZURE_OPENAI_API_VERSION,
66
- azureOpenaiDeployment: external_types_js_namespaceObject.MIDSCENE_GROUNDING_AZURE_OPENAI_DEPLOYMENT,
67
- azureExtraConfig: external_types_js_namespaceObject.MIDSCENE_GROUNDING_AZURE_OPENAI_INIT_CONFIG_JSON,
68
- useAnthropicSdk: external_types_js_namespaceObject.MIDSCENE_GROUNDING_USE_ANTHROPIC_SDK,
69
- anthropicApiKey: external_types_js_namespaceObject.MIDSCENE_GROUNDING_ANTHROPIC_API_KEY,
70
- vlMode: external_types_js_namespaceObject.MIDSCENE_GROUNDING_VL_MODE
33
+ const INSIGHT_MODEL_CONFIG_KEYS = {
34
+ modelName: external_types_js_namespaceObject.MIDSCENE_INSIGHT_MODEL_NAME,
35
+ socksProxy: external_types_js_namespaceObject.MIDSCENE_INSIGHT_MODEL_SOCKS_PROXY,
36
+ httpProxy: external_types_js_namespaceObject.MIDSCENE_INSIGHT_MODEL_HTTP_PROXY,
37
+ openaiBaseURL: external_types_js_namespaceObject.MIDSCENE_INSIGHT_MODEL_BASE_URL,
38
+ openaiApiKey: external_types_js_namespaceObject.MIDSCENE_INSIGHT_MODEL_API_KEY,
39
+ openaiExtraConfig: external_types_js_namespaceObject.MIDSCENE_INSIGHT_MODEL_INIT_CONFIG_JSON,
40
+ modelFamily: 'THERE_IS_NO_MODEL_FAMILY_FOR_INSIGHT',
41
+ timeout: external_types_js_namespaceObject.MIDSCENE_INSIGHT_MODEL_TIMEOUT
71
42
  };
72
43
  const PLANNING_MODEL_CONFIG_KEYS = {
73
44
  modelName: external_types_js_namespaceObject.MIDSCENE_PLANNING_MODEL_NAME,
74
- socksProxy: external_types_js_namespaceObject.MIDSCENE_PLANNING_OPENAI_SOCKS_PROXY,
75
- httpProxy: external_types_js_namespaceObject.MIDSCENE_PLANNING_OPENAI_HTTP_PROXY,
76
- openaiBaseURL: external_types_js_namespaceObject.MIDSCENE_PLANNING_OPENAI_BASE_URL,
77
- openaiApiKey: external_types_js_namespaceObject.MIDSCENE_PLANNING_OPENAI_API_KEY,
78
- openaiExtraConfig: external_types_js_namespaceObject.MIDSCENE_PLANNING_OPENAI_INIT_CONFIG_JSON,
79
- openaiUseAzureDeprecated: external_types_js_namespaceObject.MIDSCENE_PLANNING_OPENAI_USE_AZURE,
80
- useAzureOpenai: external_types_js_namespaceObject.MIDSCENE_PLANNING_USE_AZURE_OPENAI,
81
- azureOpenaiScope: external_types_js_namespaceObject.MIDSCENE_PLANNING_AZURE_OPENAI_SCOPE,
82
- azureOpenaiKey: external_types_js_namespaceObject.MIDSCENE_PLANNING_AZURE_OPENAI_KEY,
83
- azureOpenaiEndpoint: external_types_js_namespaceObject.MIDSCENE_PLANNING_AZURE_OPENAI_ENDPOINT,
84
- azureOpenaiApiVersion: external_types_js_namespaceObject.MIDSCENE_PLANNING_AZURE_OPENAI_API_VERSION,
85
- azureOpenaiDeployment: external_types_js_namespaceObject.MIDSCENE_PLANNING_AZURE_OPENAI_DEPLOYMENT,
86
- azureExtraConfig: external_types_js_namespaceObject.MIDSCENE_PLANNING_AZURE_OPENAI_INIT_CONFIG_JSON,
87
- useAnthropicSdk: external_types_js_namespaceObject.MIDSCENE_PLANNING_USE_ANTHROPIC_SDK,
88
- anthropicApiKey: external_types_js_namespaceObject.MIDSCENE_PLANNING_ANTHROPIC_API_KEY,
89
- vlMode: external_types_js_namespaceObject.MIDSCENE_PLANNING_VL_MODE
45
+ socksProxy: external_types_js_namespaceObject.MIDSCENE_PLANNING_MODEL_SOCKS_PROXY,
46
+ httpProxy: external_types_js_namespaceObject.MIDSCENE_PLANNING_MODEL_HTTP_PROXY,
47
+ openaiBaseURL: external_types_js_namespaceObject.MIDSCENE_PLANNING_MODEL_BASE_URL,
48
+ openaiApiKey: external_types_js_namespaceObject.MIDSCENE_PLANNING_MODEL_API_KEY,
49
+ openaiExtraConfig: external_types_js_namespaceObject.MIDSCENE_PLANNING_MODEL_INIT_CONFIG_JSON,
50
+ modelFamily: 'THERE_IS_NO_MODEL_FAMILY_FOR_PLANNING',
51
+ timeout: external_types_js_namespaceObject.MIDSCENE_PLANNING_MODEL_TIMEOUT
90
52
  };
91
53
  const DEFAULT_MODEL_CONFIG_KEYS = {
92
54
  modelName: external_types_js_namespaceObject.MIDSCENE_MODEL_NAME,
93
- socksProxy: external_types_js_namespaceObject.MIDSCENE_OPENAI_SOCKS_PROXY,
94
- httpProxy: external_types_js_namespaceObject.MIDSCENE_OPENAI_HTTP_PROXY,
95
- openaiBaseURL: external_types_js_namespaceObject.MIDSCENE_OPENAI_BASE_URL,
96
- openaiApiKey: external_types_js_namespaceObject.MIDSCENE_OPENAI_API_KEY,
97
- openaiExtraConfig: external_types_js_namespaceObject.MIDSCENE_OPENAI_INIT_CONFIG_JSON,
98
- openaiUseAzureDeprecated: external_types_js_namespaceObject.MIDSCENE_OPENAI_USE_AZURE,
99
- useAzureOpenai: external_types_js_namespaceObject.MIDSCENE_USE_AZURE_OPENAI,
100
- azureOpenaiScope: external_types_js_namespaceObject.MIDSCENE_AZURE_OPENAI_SCOPE,
101
- azureOpenaiKey: external_types_js_namespaceObject.MIDSCENE_AZURE_OPENAI_KEY,
102
- azureOpenaiEndpoint: external_types_js_namespaceObject.MIDSCENE_AZURE_OPENAI_ENDPOINT,
103
- azureOpenaiApiVersion: external_types_js_namespaceObject.MIDSCENE_AZURE_OPENAI_API_VERSION,
104
- azureOpenaiDeployment: external_types_js_namespaceObject.MIDSCENE_AZURE_OPENAI_DEPLOYMENT,
105
- azureExtraConfig: external_types_js_namespaceObject.MIDSCENE_AZURE_OPENAI_INIT_CONFIG_JSON,
106
- useAnthropicSdk: external_types_js_namespaceObject.MIDSCENE_USE_ANTHROPIC_SDK,
107
- anthropicApiKey: external_types_js_namespaceObject.MIDSCENE_ANTHROPIC_API_KEY,
108
- vlMode: external_types_js_namespaceObject.MIDSCENE_VL_MODE
55
+ socksProxy: external_types_js_namespaceObject.MIDSCENE_MODEL_SOCKS_PROXY,
56
+ httpProxy: external_types_js_namespaceObject.MIDSCENE_MODEL_HTTP_PROXY,
57
+ openaiBaseURL: external_types_js_namespaceObject.MIDSCENE_MODEL_BASE_URL,
58
+ openaiApiKey: external_types_js_namespaceObject.MIDSCENE_MODEL_API_KEY,
59
+ openaiExtraConfig: external_types_js_namespaceObject.MIDSCENE_MODEL_INIT_CONFIG_JSON,
60
+ modelFamily: external_types_js_namespaceObject.MIDSCENE_MODEL_FAMILY,
61
+ timeout: external_types_js_namespaceObject.MIDSCENE_MODEL_TIMEOUT
109
62
  };
110
63
  const DEFAULT_MODEL_CONFIG_KEYS_LEGACY = {
111
64
  modelName: external_types_js_namespaceObject.MIDSCENE_MODEL_NAME,
@@ -114,30 +67,19 @@ const DEFAULT_MODEL_CONFIG_KEYS_LEGACY = {
114
67
  openaiBaseURL: external_types_js_namespaceObject.OPENAI_BASE_URL,
115
68
  openaiApiKey: external_types_js_namespaceObject.OPENAI_API_KEY,
116
69
  openaiExtraConfig: external_types_js_namespaceObject.MIDSCENE_OPENAI_INIT_CONFIG_JSON,
117
- openaiUseAzureDeprecated: external_types_js_namespaceObject.OPENAI_USE_AZURE,
118
- useAzureOpenai: external_types_js_namespaceObject.MIDSCENE_USE_AZURE_OPENAI,
119
- azureOpenaiScope: external_types_js_namespaceObject.MIDSCENE_AZURE_OPENAI_SCOPE,
120
- azureOpenaiKey: external_types_js_namespaceObject.AZURE_OPENAI_KEY,
121
- azureOpenaiEndpoint: external_types_js_namespaceObject.AZURE_OPENAI_ENDPOINT,
122
- azureOpenaiApiVersion: external_types_js_namespaceObject.AZURE_OPENAI_API_VERSION,
123
- azureOpenaiDeployment: external_types_js_namespaceObject.AZURE_OPENAI_DEPLOYMENT,
124
- azureExtraConfig: external_types_js_namespaceObject.MIDSCENE_AZURE_OPENAI_INIT_CONFIG_JSON,
125
- useAnthropicSdk: external_types_js_namespaceObject.MIDSCENE_USE_ANTHROPIC_SDK,
126
- anthropicApiKey: external_types_js_namespaceObject.ANTHROPIC_API_KEY,
127
- vlMode: 'DEFAULT_MODEL_CONFIG_KEYS has no vlMode key'
70
+ modelFamily: 'DEFAULT_MODEL_CONFIG_KEYS has no modelFamily key',
71
+ timeout: external_types_js_namespaceObject.MIDSCENE_MODEL_TIMEOUT
128
72
  };
129
73
  exports.DEFAULT_MODEL_CONFIG_KEYS = __webpack_exports__.DEFAULT_MODEL_CONFIG_KEYS;
130
74
  exports.DEFAULT_MODEL_CONFIG_KEYS_LEGACY = __webpack_exports__.DEFAULT_MODEL_CONFIG_KEYS_LEGACY;
131
- exports.GROUNDING_MODEL_CONFIG_KEYS = __webpack_exports__.GROUNDING_MODEL_CONFIG_KEYS;
75
+ exports.INSIGHT_MODEL_CONFIG_KEYS = __webpack_exports__.INSIGHT_MODEL_CONFIG_KEYS;
132
76
  exports.PLANNING_MODEL_CONFIG_KEYS = __webpack_exports__.PLANNING_MODEL_CONFIG_KEYS;
133
- exports.VQA_MODEL_CONFIG_KEYS = __webpack_exports__.VQA_MODEL_CONFIG_KEYS;
134
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
77
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
135
78
  "DEFAULT_MODEL_CONFIG_KEYS",
136
79
  "DEFAULT_MODEL_CONFIG_KEYS_LEGACY",
137
- "GROUNDING_MODEL_CONFIG_KEYS",
138
- "PLANNING_MODEL_CONFIG_KEYS",
139
- "VQA_MODEL_CONFIG_KEYS"
140
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
80
+ "INSIGHT_MODEL_CONFIG_KEYS",
81
+ "PLANNING_MODEL_CONFIG_KEYS"
82
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
141
83
  Object.defineProperty(exports, '__esModule', {
142
84
  value: true
143
85
  });
@@ -58,8 +58,8 @@ class GlobalConfigManager {
58
58
  }
59
59
  getEnvConfigValue(key) {
60
60
  const allConfig = this.getAllEnvConfig();
61
+ if (key === external_types_js_namespaceObject.MATCH_BY_POSITION) throw new Error('MATCH_BY_POSITION is discarded, use MIDSCENE_MODEL_FAMILY instead');
61
62
  if (!external_types_js_namespaceObject.STRING_ENV_KEYS.includes(key)) throw new Error(`getEnvConfigValue with key ${key} is not supported.`);
62
- if (key === external_types_js_namespaceObject.MATCH_BY_POSITION) throw new Error('MATCH_BY_POSITION is deprecated, use MIDSCENE_USE_VL_MODEL instead');
63
63
  const value = allConfig[key];
64
64
  this.keysHaveBeenRead[key] = true;
65
65
  if ('string' == typeof value) return value.trim();
@@ -86,7 +86,6 @@ class GlobalConfigManager {
86
86
  this.globalModelConfigManager = globalModelConfigManager;
87
87
  }
88
88
  overrideAIConfig(newConfig, extendMode = false) {
89
- var _this_override;
90
89
  for(const key in newConfig){
91
90
  if (![
92
91
  ...external_types_js_namespaceObject.GLOBAL_ENV_KEYS,
@@ -97,7 +96,7 @@ class GlobalConfigManager {
97
96
  if (this.keysHaveBeenRead[key]) console.warn(`Warning: try to override AI config with key ${key} ,but it has been read.`);
98
97
  }
99
98
  const savedNewConfig = extendMode ? {
100
- ...null == (_this_override = this.override) ? void 0 : _this_override.newConfig,
99
+ ...this.override?.newConfig,
101
100
  ...newConfig
102
101
  } : newConfig;
103
102
  this.override = {
@@ -117,9 +116,9 @@ class GlobalConfigManager {
117
116
  }
118
117
  }
119
118
  exports.GlobalConfigManager = __webpack_exports__.GlobalConfigManager;
120
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
119
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
121
120
  "GlobalConfigManager"
122
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
121
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
123
122
  Object.defineProperty(exports, '__esModule', {
124
123
  value: true
125
124
  });
@@ -25,10 +25,8 @@ var __webpack_exports__ = {};
25
25
  __webpack_require__.r(__webpack_exports__);
26
26
  __webpack_require__.d(__webpack_exports__, {
27
27
  maskConfig: ()=>maskConfig,
28
- createAssert: ()=>createAssert,
29
28
  parseJson: ()=>parseJson
30
29
  });
31
- const external_utils_js_namespaceObject = require("../utils.js");
32
30
  const maskKey = (key, maskChar = '*')=>{
33
31
  if ('string' != typeof key || 0 === key.length) return key;
34
32
  const prefixLen = 3;
@@ -42,21 +40,21 @@ const maskKey = (key, maskChar = '*')=>{
42
40
  return `${prefix}${mask}${suffix}`;
43
41
  };
44
42
  const maskConfig = (config)=>Object.fromEntries(Object.entries(config).map(([key, value])=>{
45
- if ([
46
- 'openaiApiKey',
47
- 'azureOpenaiKey',
48
- 'anthropicApiKey'
49
- ].includes(key)) return [
43
+ if (!value) return [
50
44
  key,
51
- maskKey(value)
45
+ value
52
46
  ];
53
- if ([
54
- 'openaiExtraConfig',
55
- 'azureExtraConfig'
56
- ].includes(key)) return [
47
+ if ('string' == typeof value && /key/i.test(key)) return [
57
48
  key,
58
- maskKey(JSON.stringify(value))
49
+ maskKey(value)
59
50
  ];
51
+ if ('object' == typeof value) {
52
+ const valueStr = JSON.stringify(value);
53
+ if (/key/i.test(valueStr)) return [
54
+ key,
55
+ maskKey(valueStr)
56
+ ];
57
+ }
60
58
  return [
61
59
  key,
62
60
  value
@@ -71,19 +69,12 @@ const parseJson = (key, value)=>{
71
69
  });
72
70
  }
73
71
  };
74
- const createAssert = (modelNameKey, provider, modelName)=>(value, key, modelVendorFlag)=>{
75
- if (modelName) if (modelVendorFlag) (0, external_utils_js_namespaceObject.assert)(value, `The ${key} must be a non-empty string because of the ${modelNameKey} is declared as ${modelName} and ${modelVendorFlag} has also been specified in ${provider}, but got: ${value}. Please check your config.`);
76
- else (0, external_utils_js_namespaceObject.assert)(value, `The ${key} must be a non-empty string because of the ${modelNameKey} is declared as ${modelName} in ${provider}, but got: ${value}. Please check your config.`);
77
- else (0, external_utils_js_namespaceObject.assert)(value, `The ${key} must be a non-empty string, but got: ${value}. Please check your config.`);
78
- };
79
- exports.createAssert = __webpack_exports__.createAssert;
80
72
  exports.maskConfig = __webpack_exports__.maskConfig;
81
73
  exports.parseJson = __webpack_exports__.parseJson;
82
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
83
- "createAssert",
74
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
84
75
  "maskConfig",
85
76
  "parseJson"
86
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
77
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
87
78
  Object.defineProperty(exports, '__esModule', {
88
79
  value: true
89
80
  });
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  var __webpack_modules__ = {
3
- "./global-config-manager": function(module) {
3
+ "./global-config-manager" (module) {
4
4
  module.exports = require("./global-config-manager.js");
5
5
  },
6
- "./model-config-manager": function(module) {
6
+ "./model-config-manager" (module) {
7
7
  module.exports = require("./model-config-manager.js");
8
8
  },
9
- "./types": function(module) {
9
+ "./types" (module) {
10
10
  module.exports = require("./types.js");
11
11
  },
12
- "./utils": function(module) {
12
+ "./utils" (module) {
13
13
  module.exports = require("./utils.js");
14
14
  }
15
15
  };
@@ -57,38 +57,34 @@ var __webpack_exports__ = {};
57
57
  (()=>{
58
58
  __webpack_require__.r(__webpack_exports__);
59
59
  __webpack_require__.d(__webpack_exports__, {
60
- GlobalConfigManager: ()=>_global_config_manager__WEBPACK_IMPORTED_MODULE_3__.GlobalConfigManager,
61
- ModelConfigManager: ()=>_model_config_manager__WEBPACK_IMPORTED_MODULE_2__.ModelConfigManager
60
+ GlobalConfigManager: ()=>_global_config_manager__rspack_import_3.GlobalConfigManager,
61
+ ModelConfigManager: ()=>_model_config_manager__rspack_import_2.ModelConfigManager
62
62
  });
63
- var _utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./utils");
64
- var __WEBPACK_REEXPORT_OBJECT__ = {};
65
- for(var __WEBPACK_IMPORT_KEY__ in _utils__WEBPACK_IMPORTED_MODULE_0__)if ([
66
- "default",
63
+ var _utils__rspack_import_0 = __webpack_require__("./utils");
64
+ var __rspack_reexport = {};
65
+ for(const __rspack_import_key in _utils__rspack_import_0)if ([
66
+ "ModelConfigManager",
67
67
  "GlobalConfigManager",
68
- "ModelConfigManager"
69
- ].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
70
- return _utils__WEBPACK_IMPORTED_MODULE_0__[key];
71
- }).bind(0, __WEBPACK_IMPORT_KEY__);
72
- __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
73
- var _types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./types");
74
- var __WEBPACK_REEXPORT_OBJECT__ = {};
75
- for(var __WEBPACK_IMPORT_KEY__ in _types__WEBPACK_IMPORTED_MODULE_1__)if ([
76
- "default",
68
+ "default"
69
+ ].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_utils__rspack_import_0[__rspack_import_key];
70
+ __webpack_require__.d(__webpack_exports__, __rspack_reexport);
71
+ var _types__rspack_import_1 = __webpack_require__("./types");
72
+ var __rspack_reexport = {};
73
+ for(const __rspack_import_key in _types__rspack_import_1)if ([
74
+ "ModelConfigManager",
77
75
  "GlobalConfigManager",
78
- "ModelConfigManager"
79
- ].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
80
- return _types__WEBPACK_IMPORTED_MODULE_1__[key];
81
- }).bind(0, __WEBPACK_IMPORT_KEY__);
82
- __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
83
- var _model_config_manager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./model-config-manager");
84
- var _global_config_manager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./global-config-manager");
76
+ "default"
77
+ ].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_types__rspack_import_1[__rspack_import_key];
78
+ __webpack_require__.d(__webpack_exports__, __rspack_reexport);
79
+ var _model_config_manager__rspack_import_2 = __webpack_require__("./model-config-manager");
80
+ var _global_config_manager__rspack_import_3 = __webpack_require__("./global-config-manager");
85
81
  })();
86
82
  exports.GlobalConfigManager = __webpack_exports__.GlobalConfigManager;
87
83
  exports.ModelConfigManager = __webpack_exports__.ModelConfigManager;
88
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
84
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
89
85
  "GlobalConfigManager",
90
86
  "ModelConfigManager"
91
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
87
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
92
88
  Object.defineProperty(exports, '__esModule', {
93
89
  value: true
94
90
  });
@@ -30,23 +30,23 @@ const external_logger_js_namespaceObject = require("../logger.js");
30
30
  const external_basic_js_namespaceObject = require("./basic.js");
31
31
  const external_types_js_namespaceObject = require("./types.js");
32
32
  const initDebugConfig = ()=>{
33
- const shouldPrintTiming = (0, external_basic_js_namespaceObject.getBasicEnvValue)(external_types_js_namespaceObject.MIDSCENE_DEBUG_AI_PROFILE);
33
+ const shouldPrintTiming = (0, external_basic_js_namespaceObject.getBasicEnvValue)(external_types_js_namespaceObject.MIDSCENE_DEBUG_MODEL_PROFILE);
34
34
  let debugConfig = '';
35
35
  if (shouldPrintTiming) {
36
- console.warn('MIDSCENE_DEBUG_AI_PROFILE is deprecated, use DEBUG=midscene:ai:profile instead');
36
+ console.warn('MIDSCENE_DEBUG_MODEL_PROFILE is deprecated, use DEBUG=midscene:ai:profile instead');
37
37
  debugConfig = 'ai:profile';
38
38
  }
39
- const shouldPrintAIResponse = (0, external_basic_js_namespaceObject.getBasicEnvValue)(external_types_js_namespaceObject.MIDSCENE_DEBUG_AI_RESPONSE);
40
- if (shouldPrintAIResponse) {
41
- console.warn('MIDSCENE_DEBUG_AI_RESPONSE is deprecated, use DEBUG=midscene:ai:response instead');
39
+ const shouldPrintModelResponse = (0, external_basic_js_namespaceObject.getBasicEnvValue)(external_types_js_namespaceObject.MIDSCENE_DEBUG_MODEL_RESPONSE);
40
+ if (shouldPrintModelResponse) {
41
+ console.warn('MIDSCENE_DEBUG_MODEL_RESPONSE is deprecated, use DEBUG=midscene:ai:response instead');
42
42
  debugConfig = debugConfig ? 'ai:*' : 'ai:call';
43
43
  }
44
44
  if (debugConfig) (0, external_logger_js_namespaceObject.enableDebug)(debugConfig);
45
45
  };
46
46
  exports.initDebugConfig = __webpack_exports__.initDebugConfig;
47
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
47
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
48
48
  "initDebugConfig"
49
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
49
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
50
50
  Object.defineProperty(exports, '__esModule', {
51
51
  value: true
52
52
  });
@@ -26,7 +26,7 @@ __webpack_require__.r(__webpack_exports__);
26
26
  __webpack_require__.d(__webpack_exports__, {
27
27
  ModelConfigManager: ()=>ModelConfigManager
28
28
  });
29
- const external_decide_model_config_js_namespaceObject = require("./decide-model-config.js");
29
+ const external_parse_model_config_js_namespaceObject = require("./parse-model-config.js");
30
30
  function _define_property(obj, key, value) {
31
31
  if (key in obj) Object.defineProperty(obj, key, {
32
32
  value: value,
@@ -37,97 +37,77 @@ function _define_property(obj, key, value) {
37
37
  else obj[key] = value;
38
38
  return obj;
39
39
  }
40
- const ALL_INTENTS = [
41
- 'VQA',
42
- 'default',
43
- 'grounding',
44
- 'planning'
45
- ];
46
40
  class ModelConfigManager {
47
- calcIntentConfigMap(modelConfigFn) {
48
- const intentConfigMap = {
49
- VQA: void 0,
50
- default: void 0,
51
- grounding: void 0,
52
- planning: void 0
41
+ initialize() {
42
+ if (this.isInitialized) return;
43
+ let configMap;
44
+ if (this.modelConfig) {
45
+ this.isolatedMode = true;
46
+ configMap = this.normalizeModelConfig(this.modelConfig);
47
+ } else configMap = this.globalConfigManager?.getAllEnvConfig() || {};
48
+ const defaultConfig = (0, external_parse_model_config_js_namespaceObject.decideModelConfigFromIntentConfig)('default', configMap);
49
+ if (!defaultConfig) throw new Error('default model config is not found, which should not happen');
50
+ const insightConfig = (0, external_parse_model_config_js_namespaceObject.decideModelConfigFromIntentConfig)('insight', configMap);
51
+ const planningConfig = (0, external_parse_model_config_js_namespaceObject.decideModelConfigFromIntentConfig)('planning', configMap);
52
+ this.modelConfigMap = {
53
+ default: {
54
+ ...defaultConfig,
55
+ createOpenAIClient: this.createOpenAIClientFn
56
+ },
57
+ insight: {
58
+ ...insightConfig || defaultConfig,
59
+ createOpenAIClient: this.createOpenAIClientFn
60
+ },
61
+ planning: {
62
+ ...planningConfig || defaultConfig,
63
+ createOpenAIClient: this.createOpenAIClientFn
64
+ }
53
65
  };
54
- for (const i of ALL_INTENTS){
55
- const result = modelConfigFn({
56
- intent: i
57
- });
58
- 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.`);
59
- intentConfigMap[i] = result;
60
- }
61
- return intentConfigMap;
66
+ this.isInitialized = true;
62
67
  }
63
- calcModelConfigMapBaseOnIntent(intentConfigMap) {
64
- const modelConfigMap = {
65
- VQA: void 0,
66
- default: void 0,
67
- grounding: void 0,
68
- planning: void 0
69
- };
70
- for (const i of ALL_INTENTS){
71
- const result = (0, external_decide_model_config_js_namespaceObject.decideModelConfigFromIntentConfig)(i, intentConfigMap[i]);
72
- modelConfigMap[i] = result;
73
- }
74
- return modelConfigMap;
75
- }
76
- calcModelConfigMapBaseOnEnv(allEnvConfig) {
77
- const modelConfigMap = {
78
- VQA: void 0,
79
- default: void 0,
80
- grounding: void 0,
81
- planning: void 0
82
- };
83
- for (const i of ALL_INTENTS){
84
- const result = (0, external_decide_model_config_js_namespaceObject.decideModelConfigFromEnv)(i, allEnvConfig);
85
- modelConfigMap[i] = result;
86
- }
87
- return modelConfigMap;
68
+ normalizeModelConfig(config) {
69
+ return Object.entries(config).reduce((acc, [key, value])=>{
70
+ if (null == value) return acc;
71
+ acc[key] = String(value);
72
+ return acc;
73
+ }, Object.create(null));
88
74
  }
89
75
  clearModelConfigMap() {
90
76
  if (this.isolatedMode) throw new Error('ModelConfigManager work in isolated mode, so clearModelConfigMap should not be called');
91
- this.modelConfigMap = void 0;
77
+ this.isInitialized = false;
92
78
  }
93
79
  getModelConfig(intent) {
94
- if (this.isolatedMode) {
95
- if (!this.modelConfigMap) throw new Error('modelConfigMap is not initialized in isolated mode, which should not happen');
96
- return this.modelConfigMap[intent];
97
- }
98
- if (!this.modelConfigMap) {
99
- if (!this.globalConfigManager) throw new Error('globalConfigManager is not registered, which should not happen');
100
- this.modelConfigMap = this.calcModelConfigMapBaseOnEnv(this.globalConfigManager.getAllEnvConfig());
101
- }
80
+ if (!this.isInitialized) this.initialize();
81
+ if (!this.modelConfigMap) throw new Error('modelConfigMap is not initialized, which should not happen');
102
82
  return this.modelConfigMap[intent];
103
83
  }
104
84
  getUploadTestServerUrl() {
105
85
  const { openaiExtraConfig } = this.getModelConfig('default');
106
- const serverUrl = null == openaiExtraConfig ? void 0 : openaiExtraConfig.REPORT_SERVER_URL;
86
+ const serverUrl = openaiExtraConfig?.REPORT_SERVER_URL;
107
87
  return serverUrl;
108
88
  }
109
89
  registerGlobalConfigManager(globalConfigManager) {
110
90
  this.globalConfigManager = globalConfigManager;
111
91
  }
112
- throwErrorIfNonVLModel(intent = 'grounding') {
113
- const modelConfig = this.getModelConfig(intent);
114
- if (!modelConfig.vlMode) throw new Error('No visual language model (VL model) detected for the current scenario. Element localization may be inaccurate. Please verify your model configuration. Learn more: https://midscenejs.com/choose-a-model');
92
+ throwErrorIfNonVLModel() {
93
+ const modelConfig = this.getModelConfig('default');
94
+ if (!modelConfig.vlMode) throw new Error('MIDSCENE_MODEL_FAMILY is not set to a visual language model (VL model), the element localization can not be achieved. Check your model configuration. See https://midscenejs.com/model-strategy.html');
115
95
  }
116
- constructor(modelConfigFn){
96
+ constructor(modelConfig, createOpenAIClientFn){
117
97
  _define_property(this, "modelConfigMap", void 0);
98
+ _define_property(this, "isInitialized", false);
118
99
  _define_property(this, "isolatedMode", false);
119
100
  _define_property(this, "globalConfigManager", void 0);
120
- if (modelConfigFn) {
121
- this.isolatedMode = true;
122
- const intentConfigMap = this.calcIntentConfigMap(modelConfigFn);
123
- this.modelConfigMap = this.calcModelConfigMapBaseOnIntent(intentConfigMap);
124
- }
101
+ _define_property(this, "modelConfig", void 0);
102
+ _define_property(this, "createOpenAIClientFn", void 0);
103
+ this.modelConfig = modelConfig;
104
+ this.createOpenAIClientFn = createOpenAIClientFn;
125
105
  }
126
106
  }
127
107
  exports.ModelConfigManager = __webpack_exports__.ModelConfigManager;
128
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
108
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
129
109
  "ModelConfigManager"
130
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
110
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
131
111
  Object.defineProperty(exports, '__esModule', {
132
112
  value: true
133
113
  });