@midscene/visualizer 0.28.7-beta-20250912113807.0 → 0.28.7-beta-20250915094412.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/component/service-mode-control/index.mjs +2 -2
- package/dist/es/hooks/useSafeOverrideAIConfig.mjs +24 -0
- package/dist/es/index.mjs +2 -1
- package/dist/lib/component/service-mode-control/index.js +2 -2
- package/dist/lib/hooks/useSafeOverrideAIConfig.js +61 -0
- package/dist/lib/index.js +7 -0
- package/dist/types/hooks/useSafeOverrideAIConfig.d.ts +16 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +5 -5
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { PlaygroundSDK } from "@midscene/playground";
|
|
3
|
-
import { overrideAIConfig } from "@midscene/shared/env";
|
|
4
3
|
import { Button, Tooltip } from "antd";
|
|
5
4
|
import { useEffect } from "react";
|
|
5
|
+
import { safeOverrideAIConfig } from "../../hooks/useSafeOverrideAIConfig.mjs";
|
|
6
6
|
import { useServerValid } from "../../hooks/useServerValid.mjs";
|
|
7
7
|
import { useEnvConfig } from "../../store/store.mjs";
|
|
8
8
|
import { EnvConfig } from "../env-config/index.mjs";
|
|
@@ -57,7 +57,7 @@ const ServiceModeControl = (param)=>{
|
|
|
57
57
|
});
|
|
58
58
|
};
|
|
59
59
|
useEffect(()=>{
|
|
60
|
-
|
|
60
|
+
safeOverrideAIConfig(config, false, false);
|
|
61
61
|
if ('Server' === serviceMode) {
|
|
62
62
|
const playgroundSDK = new PlaygroundSDK({
|
|
63
63
|
type: 'remote-execution'
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { overrideAIConfig } from "@midscene/shared/env";
|
|
2
|
+
import { message } from "antd";
|
|
3
|
+
function safeOverrideAIConfig(newConfig) {
|
|
4
|
+
let extendMode = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : false, showErrorMessage = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : true;
|
|
5
|
+
try {
|
|
6
|
+
overrideAIConfig(newConfig, extendMode);
|
|
7
|
+
return true;
|
|
8
|
+
} catch (error) {
|
|
9
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
10
|
+
console.error('Failed to override AI config:', err);
|
|
11
|
+
if (showErrorMessage) message.error(`Failed to apply AI configuration: ${err.message}`);
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function useSafeOverrideAIConfig() {
|
|
16
|
+
const applyConfig = function(newConfig) {
|
|
17
|
+
let extendMode = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : false, showErrorMessage = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : true;
|
|
18
|
+
return safeOverrideAIConfig(newConfig, extendMode, showErrorMessage);
|
|
19
|
+
};
|
|
20
|
+
return {
|
|
21
|
+
applyConfig
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export { safeOverrideAIConfig, useSafeOverrideAIConfig };
|
package/dist/es/index.mjs
CHANGED
|
@@ -8,6 +8,7 @@ import { EnvConfigReminder } from "./component/env-config-reminder/index.mjs";
|
|
|
8
8
|
import { Logo } from "./component/logo/index.mjs";
|
|
9
9
|
import { iconForStatus, timeCostStrElement } from "./component/misc/index.mjs";
|
|
10
10
|
import { useServerValid } from "./hooks/useServerValid.mjs";
|
|
11
|
+
import { safeOverrideAIConfig, useSafeOverrideAIConfig } from "./hooks/useSafeOverrideAIConfig.mjs";
|
|
11
12
|
import { PlaygroundResultView } from "./component/playground-result/index.mjs";
|
|
12
13
|
import { ServiceModeControl } from "./component/service-mode-control/index.mjs";
|
|
13
14
|
import { ContextPreview } from "./component/context-preview/index.mjs";
|
|
@@ -21,4 +22,4 @@ import shiny_text from "./component/shiny-text/index.mjs";
|
|
|
21
22
|
import universal_playground, { UniversalPlayground } from "./component/universal-playground/index.mjs";
|
|
22
23
|
import { LocalStorageProvider, MemoryStorageProvider, NoOpStorageProvider } from "./component/universal-playground/providers/storage-provider.mjs";
|
|
23
24
|
import { AgentContextProvider, BaseContextProvider, NoOpContextProvider, StaticContextProvider } from "./component/universal-playground/providers/context-provider.mjs";
|
|
24
|
-
export { AgentContextProvider, BaseContextProvider, Blackboard, ContextPreview, EnvConfig, EnvConfigReminder, GithubStar, LocalStorageProvider, Logo, MemoryStorageProvider, NoOpContextProvider, NoOpStorageProvider, Player, PlaygroundResultView, PromptInput, ServiceModeControl, shiny_text as ShinyText, StaticContextProvider, UniversalPlayground, universal_playground as UniversalPlaygroundDefault, actionNameForType, allScriptsFromDump, colorForName, filterBase64Value, generateAnimationScripts, getPlaceholderForType, globalThemeConfig, highlightColorForType, iconForStatus, staticAgentFromContext, timeCostStrElement, timeStr, useEnvConfig, useServerValid };
|
|
25
|
+
export { AgentContextProvider, BaseContextProvider, Blackboard, ContextPreview, EnvConfig, EnvConfigReminder, GithubStar, LocalStorageProvider, Logo, MemoryStorageProvider, NoOpContextProvider, NoOpStorageProvider, Player, PlaygroundResultView, PromptInput, ServiceModeControl, shiny_text as ShinyText, StaticContextProvider, UniversalPlayground, universal_playground as UniversalPlaygroundDefault, actionNameForType, allScriptsFromDump, colorForName, filterBase64Value, generateAnimationScripts, getPlaceholderForType, globalThemeConfig, highlightColorForType, iconForStatus, safeOverrideAIConfig, staticAgentFromContext, timeCostStrElement, timeStr, useEnvConfig, useSafeOverrideAIConfig, useServerValid };
|
|
@@ -28,9 +28,9 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
28
28
|
});
|
|
29
29
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
30
|
const playground_namespaceObject = require("@midscene/playground");
|
|
31
|
-
const env_namespaceObject = require("@midscene/shared/env");
|
|
32
31
|
const external_antd_namespaceObject = require("antd");
|
|
33
32
|
const external_react_namespaceObject = require("react");
|
|
33
|
+
const useSafeOverrideAIConfig_js_namespaceObject = require("../../hooks/useSafeOverrideAIConfig.js");
|
|
34
34
|
const useServerValid_js_namespaceObject = require("../../hooks/useServerValid.js");
|
|
35
35
|
const store_js_namespaceObject = require("../../store/store.js");
|
|
36
36
|
const index_js_namespaceObject = require("../env-config/index.js");
|
|
@@ -85,7 +85,7 @@ const ServiceModeControl = (param)=>{
|
|
|
85
85
|
});
|
|
86
86
|
};
|
|
87
87
|
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
88
|
-
(0,
|
|
88
|
+
(0, useSafeOverrideAIConfig_js_namespaceObject.safeOverrideAIConfig)(config, false, false);
|
|
89
89
|
if ('Server' === serviceMode) {
|
|
90
90
|
const playgroundSDK = new playground_namespaceObject.PlaygroundSDK({
|
|
91
91
|
type: 'remote-execution'
|
|
@@ -0,0 +1,61 @@
|
|
|
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
|
+
safeOverrideAIConfig: ()=>safeOverrideAIConfig,
|
|
28
|
+
useSafeOverrideAIConfig: ()=>useSafeOverrideAIConfig
|
|
29
|
+
});
|
|
30
|
+
const env_namespaceObject = require("@midscene/shared/env");
|
|
31
|
+
const external_antd_namespaceObject = require("antd");
|
|
32
|
+
function safeOverrideAIConfig(newConfig) {
|
|
33
|
+
let extendMode = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : false, showErrorMessage = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : true;
|
|
34
|
+
try {
|
|
35
|
+
(0, env_namespaceObject.overrideAIConfig)(newConfig, extendMode);
|
|
36
|
+
return true;
|
|
37
|
+
} catch (error) {
|
|
38
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
39
|
+
console.error('Failed to override AI config:', err);
|
|
40
|
+
if (showErrorMessage) external_antd_namespaceObject.message.error(`Failed to apply AI configuration: ${err.message}`);
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function useSafeOverrideAIConfig() {
|
|
45
|
+
const applyConfig = function(newConfig) {
|
|
46
|
+
let extendMode = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : false, showErrorMessage = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : true;
|
|
47
|
+
return safeOverrideAIConfig(newConfig, extendMode, showErrorMessage);
|
|
48
|
+
};
|
|
49
|
+
return {
|
|
50
|
+
applyConfig
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
exports.safeOverrideAIConfig = __webpack_exports__.safeOverrideAIConfig;
|
|
54
|
+
exports.useSafeOverrideAIConfig = __webpack_exports__.useSafeOverrideAIConfig;
|
|
55
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
56
|
+
"safeOverrideAIConfig",
|
|
57
|
+
"useSafeOverrideAIConfig"
|
|
58
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
59
|
+
Object.defineProperty(exports, '__esModule', {
|
|
60
|
+
value: true
|
|
61
|
+
});
|
package/dist/lib/index.js
CHANGED
|
@@ -45,10 +45,12 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
45
45
|
ShinyText: ()=>shiny_text_index_js_default(),
|
|
46
46
|
getPlaceholderForType: ()=>playground_utils_js_namespaceObject.getPlaceholderForType,
|
|
47
47
|
staticAgentFromContext: ()=>playground_utils_js_namespaceObject.staticAgentFromContext,
|
|
48
|
+
useSafeOverrideAIConfig: ()=>useSafeOverrideAIConfig_js_namespaceObject.useSafeOverrideAIConfig,
|
|
48
49
|
useServerValid: ()=>useServerValid_js_namespaceObject.useServerValid,
|
|
49
50
|
ServiceModeControl: ()=>service_mode_control_index_js_namespaceObject.ServiceModeControl,
|
|
50
51
|
BaseContextProvider: ()=>context_provider_js_namespaceObject.BaseContextProvider,
|
|
51
52
|
colorForName: ()=>color_js_namespaceObject.colorForName,
|
|
53
|
+
safeOverrideAIConfig: ()=>useSafeOverrideAIConfig_js_namespaceObject.safeOverrideAIConfig,
|
|
52
54
|
GithubStar: ()=>github_star_index_js_namespaceObject.GithubStar,
|
|
53
55
|
Logo: ()=>logo_index_js_namespaceObject.Logo,
|
|
54
56
|
UniversalPlayground: ()=>universal_playground_index_js_namespaceObject.UniversalPlayground,
|
|
@@ -78,6 +80,7 @@ const env_config_reminder_index_js_namespaceObject = require("./component/env-co
|
|
|
78
80
|
const logo_index_js_namespaceObject = require("./component/logo/index.js");
|
|
79
81
|
const misc_index_js_namespaceObject = require("./component/misc/index.js");
|
|
80
82
|
const useServerValid_js_namespaceObject = require("./hooks/useServerValid.js");
|
|
83
|
+
const useSafeOverrideAIConfig_js_namespaceObject = require("./hooks/useSafeOverrideAIConfig.js");
|
|
81
84
|
const playground_result_index_js_namespaceObject = require("./component/playground-result/index.js");
|
|
82
85
|
const service_mode_control_index_js_namespaceObject = require("./component/service-mode-control/index.js");
|
|
83
86
|
const context_preview_index_js_namespaceObject = require("./component/context-preview/index.js");
|
|
@@ -122,10 +125,12 @@ exports.getPlaceholderForType = __webpack_exports__.getPlaceholderForType;
|
|
|
122
125
|
exports.globalThemeConfig = __webpack_exports__.globalThemeConfig;
|
|
123
126
|
exports.highlightColorForType = __webpack_exports__.highlightColorForType;
|
|
124
127
|
exports.iconForStatus = __webpack_exports__.iconForStatus;
|
|
128
|
+
exports.safeOverrideAIConfig = __webpack_exports__.safeOverrideAIConfig;
|
|
125
129
|
exports.staticAgentFromContext = __webpack_exports__.staticAgentFromContext;
|
|
126
130
|
exports.timeCostStrElement = __webpack_exports__.timeCostStrElement;
|
|
127
131
|
exports.timeStr = __webpack_exports__.timeStr;
|
|
128
132
|
exports.useEnvConfig = __webpack_exports__.useEnvConfig;
|
|
133
|
+
exports.useSafeOverrideAIConfig = __webpack_exports__.useSafeOverrideAIConfig;
|
|
129
134
|
exports.useServerValid = __webpack_exports__.useServerValid;
|
|
130
135
|
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
131
136
|
"AgentContextProvider",
|
|
@@ -157,10 +162,12 @@ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
|
157
162
|
"globalThemeConfig",
|
|
158
163
|
"highlightColorForType",
|
|
159
164
|
"iconForStatus",
|
|
165
|
+
"safeOverrideAIConfig",
|
|
160
166
|
"staticAgentFromContext",
|
|
161
167
|
"timeCostStrElement",
|
|
162
168
|
"timeStr",
|
|
163
169
|
"useEnvConfig",
|
|
170
|
+
"useSafeOverrideAIConfig",
|
|
164
171
|
"useServerValid"
|
|
165
172
|
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
166
173
|
Object.defineProperty(exports, '__esModule', {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { GLOBAL_ENV_KEYS, MODEL_ENV_KEYS } from '@midscene/shared/env';
|
|
2
|
+
/**
|
|
3
|
+
* Safely override AI configuration with built-in error handling
|
|
4
|
+
* @param newConfig - The configuration to override
|
|
5
|
+
* @param extendMode - Whether to extend or replace the config (default: false)
|
|
6
|
+
* @param showErrorMessage - Whether to show error message in UI (default: true)
|
|
7
|
+
* @returns boolean indicating success
|
|
8
|
+
*/
|
|
9
|
+
export declare function safeOverrideAIConfig(newConfig: Partial<Record<(typeof GLOBAL_ENV_KEYS)[number] | (typeof MODEL_ENV_KEYS)[number], string>>, extendMode?: boolean, showErrorMessage?: boolean): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* React Hook for safely overriding AI config with error handling
|
|
12
|
+
* Useful for components that need to handle config changes
|
|
13
|
+
*/
|
|
14
|
+
export declare function useSafeOverrideAIConfig(): {
|
|
15
|
+
applyConfig: (newConfig: Partial<Record<(typeof GLOBAL_ENV_KEYS)[number] | (typeof MODEL_ENV_KEYS)[number], string>>, extendMode?: boolean, showErrorMessage?: boolean) => boolean;
|
|
16
|
+
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export { EnvConfigReminder } from './component/env-config-reminder';
|
|
|
8
8
|
export { Logo } from './component/logo';
|
|
9
9
|
export { iconForStatus, timeCostStrElement } from './component/misc';
|
|
10
10
|
export { useServerValid } from './hooks/useServerValid';
|
|
11
|
+
export { useSafeOverrideAIConfig, safeOverrideAIConfig, } from './hooks/useSafeOverrideAIConfig';
|
|
11
12
|
export { PlaygroundResultView } from './component/playground-result';
|
|
12
13
|
export type { PlaygroundResult } from './types';
|
|
13
14
|
export { ServiceModeControl } from './component/service-mode-control';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midscene/visualizer",
|
|
3
|
-
"version": "0.28.7-beta-
|
|
3
|
+
"version": "0.28.7-beta-20250915094412.0",
|
|
4
4
|
"repository": "https://github.com/web-infra-dev/midscene",
|
|
5
5
|
"homepage": "https://midscenejs.com/",
|
|
6
6
|
"types": "./dist/types/index.d.ts",
|
|
@@ -70,10 +70,10 @@
|
|
|
70
70
|
"antd": "^5.21.6",
|
|
71
71
|
"buffer": "6.0.3",
|
|
72
72
|
"dayjs": "^1.11.11",
|
|
73
|
-
"@midscene/core": "0.28.7-beta-
|
|
74
|
-
"@midscene/
|
|
75
|
-
"@midscene/
|
|
76
|
-
"@midscene/
|
|
73
|
+
"@midscene/core": "0.28.7-beta-20250915094412.0",
|
|
74
|
+
"@midscene/playground": "0.28.7-beta-20250915094412.0",
|
|
75
|
+
"@midscene/shared": "0.28.7-beta-20250915094412.0",
|
|
76
|
+
"@midscene/web": "0.28.7-beta-20250915094412.0"
|
|
77
77
|
},
|
|
78
78
|
"license": "MIT",
|
|
79
79
|
"scripts": {
|