@midscene/visualizer 0.30.10 → 0.30.11-beta-20251218071621.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/blackboard/index.css +8 -0
- package/dist/es/component/blackboard/index.mjs +137 -68
- package/dist/es/component/config-selector/index.mjs +102 -4
- package/dist/es/component/context-preview/index.mjs +1 -2
- package/dist/es/component/env-config/index.mjs +1 -2
- package/dist/es/component/env-config-reminder/index.css +8 -0
- package/dist/es/component/env-config-reminder/index.mjs +1 -2
- package/dist/es/component/form-field/index.mjs +5 -10
- package/dist/es/component/history-selector/index.css +38 -1
- package/dist/es/component/history-selector/index.mjs +1 -2
- package/dist/es/component/logo/index.mjs +7 -3
- package/dist/es/component/misc/index.mjs +1 -4
- package/dist/es/component/nav-actions/index.mjs +1 -2
- package/dist/es/component/nav-actions/style.css +1 -1
- package/dist/es/component/player/index.css +26 -0
- package/dist/es/component/player/index.mjs +376 -364
- package/dist/es/component/playground/index.css +291 -31
- package/dist/es/component/playground-result/index.css +10 -0
- package/dist/es/component/playground-result/index.mjs +129 -10
- package/dist/es/component/prompt-input/index.css +281 -31
- package/dist/es/component/prompt-input/index.mjs +83 -25
- package/dist/es/component/screenshot-viewer/index.css +214 -0
- package/dist/es/component/screenshot-viewer/index.mjs +282 -0
- package/dist/es/component/service-mode-control/index.mjs +1 -2
- package/dist/es/component/shiny-text/index.css +35 -3
- package/dist/es/component/shiny-text/index.mjs +3 -3
- package/dist/es/component/universal-playground/index.css +61 -1
- package/dist/es/component/universal-playground/index.mjs +106 -83
- package/dist/es/component/universal-playground/providers/context-provider.mjs +56 -18
- package/dist/es/component/universal-playground/providers/indexeddb-storage-provider.mjs +213 -139
- package/dist/es/component/universal-playground/providers/storage-provider.mjs +199 -121
- package/dist/es/hooks/usePlaygroundExecution.mjs +297 -146
- package/dist/es/hooks/usePlaygroundState.mjs +141 -75
- package/dist/es/hooks/useSafeOverrideAIConfig.mjs +2 -6
- package/dist/es/hooks/useServerValid.mjs +37 -12
- package/dist/es/hooks/useTheme.mjs +25 -0
- package/dist/es/icons/avatar.mjs +46 -4
- package/dist/es/icons/close.mjs +46 -4
- package/dist/es/icons/global-perspective.mjs +47 -5
- package/dist/es/icons/history.mjs +48 -6
- package/dist/es/icons/magnifying-glass.mjs +47 -5
- package/dist/es/icons/player-setting.mjs +48 -6
- package/dist/es/icons/setting.mjs +47 -5
- package/dist/es/icons/show-marker.mjs +47 -5
- package/dist/es/index.mjs +4 -4
- package/dist/es/store/history.mjs +46 -7
- package/dist/es/store/store.mjs +68 -2
- package/dist/es/types.mjs +1 -1
- package/dist/es/utils/constants.mjs +7 -3
- package/dist/es/utils/index.mjs +4 -1
- package/dist/es/utils/pixi-loader.mjs +37 -11
- package/dist/es/utils/replay-scripts.mjs +160 -111
- package/dist/lib/component/blackboard/index.css +8 -0
- package/dist/lib/component/blackboard/index.js +139 -70
- package/dist/lib/component/config-selector/index.js +103 -5
- package/dist/lib/component/context-preview/index.js +3 -4
- package/dist/lib/component/env-config/index.js +3 -4
- package/dist/lib/component/env-config-reminder/index.css +8 -0
- package/dist/lib/component/env-config-reminder/index.js +3 -4
- package/dist/lib/component/form-field/index.js +10 -15
- package/dist/lib/component/history-selector/index.css +38 -1
- package/dist/lib/component/history-selector/index.js +3 -4
- package/dist/lib/component/index.js +6 -8
- package/dist/lib/component/logo/index.js +9 -5
- package/dist/lib/component/misc/index.js +6 -9
- package/dist/lib/component/nav-actions/index.js +3 -4
- package/dist/lib/component/nav-actions/style.css +1 -1
- package/dist/lib/component/player/index.css +26 -0
- package/dist/lib/component/player/index.js +376 -365
- package/dist/lib/component/playground/index.css +291 -31
- package/dist/lib/component/playground/index.js +31 -33
- package/dist/lib/component/playground-result/index.css +10 -0
- package/dist/lib/component/playground-result/index.js +131 -12
- package/dist/lib/component/prompt-input/index.css +281 -31
- package/dist/lib/component/prompt-input/index.js +84 -26
- package/dist/lib/component/screenshot-viewer/index.css +214 -0
- package/dist/lib/component/screenshot-viewer/index.js +316 -0
- package/dist/lib/component/service-mode-control/index.js +3 -4
- package/dist/lib/component/shiny-text/index.css +35 -3
- package/dist/lib/component/shiny-text/index.js +5 -5
- package/dist/lib/component/universal-playground/index.css +61 -1
- package/dist/lib/component/universal-playground/index.js +108 -84
- package/dist/lib/component/universal-playground/providers/context-provider.js +58 -20
- package/dist/lib/component/universal-playground/providers/indexeddb-storage-provider.js +217 -143
- package/dist/lib/component/universal-playground/providers/storage-provider.js +207 -129
- package/dist/lib/hooks/usePlaygroundExecution.js +299 -148
- package/dist/lib/hooks/usePlaygroundState.js +143 -77
- package/dist/lib/hooks/useSafeOverrideAIConfig.js +4 -8
- package/dist/lib/hooks/useServerValid.js +39 -14
- package/dist/lib/hooks/useTheme.js +59 -0
- package/dist/lib/icons/avatar.js +48 -6
- package/dist/lib/icons/close.js +48 -6
- package/dist/lib/icons/global-perspective.js +49 -7
- package/dist/lib/icons/history.js +50 -8
- package/dist/lib/icons/magnifying-glass.js +49 -7
- package/dist/lib/icons/player-setting.js +50 -8
- package/dist/lib/icons/setting.js +49 -7
- package/dist/lib/icons/show-marker.js +49 -7
- package/dist/lib/index.js +44 -34
- package/dist/lib/store/history.js +48 -9
- package/dist/lib/store/store.js +74 -8
- package/dist/lib/types.js +3 -3
- package/dist/lib/utils/color.js +2 -2
- package/dist/lib/utils/constants.js +20 -4
- package/dist/lib/utils/index.js +10 -4
- package/dist/lib/utils/pixi-loader.js +41 -15
- package/dist/lib/utils/playground-utils.js +4 -4
- package/dist/lib/utils/replay-scripts.js +164 -115
- package/dist/types/component/config-selector/index.d.ts +2 -0
- package/dist/types/component/player/index.d.ts +0 -1
- package/dist/types/component/playground-result/index.d.ts +1 -0
- package/dist/types/component/prompt-input/index.d.ts +2 -1
- package/dist/types/component/screenshot-viewer/index.d.ts +15 -0
- package/dist/types/hooks/usePlaygroundExecution.d.ts +1 -1
- package/dist/types/hooks/usePlaygroundState.d.ts +3 -3
- package/dist/types/hooks/useTheme.d.ts +7 -0
- package/dist/types/index.d.ts +3 -3
- package/dist/types/store/store.d.ts +18 -1
- package/dist/types/types.d.ts +14 -4
- package/dist/types/utils/constants.d.ts +5 -1
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/replay-scripts.d.ts +1 -1
- package/package.json +12 -22
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import icons, { ArrowDownOutlined, ClearOutlined, LoadingOutlined } from "@ant-design/icons";
|
|
3
|
-
import { Button, Form, List,
|
|
3
|
+
import { Alert, Button, Form, List, Typography, message } from "antd";
|
|
4
4
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
5
5
|
import { usePlaygroundExecution } from "../../hooks/usePlaygroundExecution.mjs";
|
|
6
6
|
import { usePlaygroundState } from "../../hooks/usePlaygroundState.mjs";
|
|
@@ -10,49 +10,78 @@ import { EnvConfigReminder } from "../env-config-reminder/index.mjs";
|
|
|
10
10
|
import { PlaygroundResultView } from "../playground-result/index.mjs";
|
|
11
11
|
import "./index.css";
|
|
12
12
|
import avatar from "../../icons/avatar.mjs";
|
|
13
|
+
import { defaultMainButtons } from "../../utils/constants.mjs";
|
|
13
14
|
import { PromptInput } from "../prompt-input/index.mjs";
|
|
15
|
+
import shiny_text from "../shiny-text/index.mjs";
|
|
14
16
|
import { createStorageProvider, detectBestStorageType } from "./providers/storage-provider.mjs";
|
|
17
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
18
|
+
try {
|
|
19
|
+
var info = gen[key](arg);
|
|
20
|
+
var value = info.value;
|
|
21
|
+
} catch (error) {
|
|
22
|
+
reject(error);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (info.done) resolve(value);
|
|
26
|
+
else Promise.resolve(value).then(_next, _throw);
|
|
27
|
+
}
|
|
28
|
+
function _async_to_generator(fn) {
|
|
29
|
+
return function() {
|
|
30
|
+
var self = this, args = arguments;
|
|
31
|
+
return new Promise(function(resolve, reject) {
|
|
32
|
+
var gen = fn.apply(self, args);
|
|
33
|
+
function _next(value) {
|
|
34
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
35
|
+
}
|
|
36
|
+
function _throw(err) {
|
|
37
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
38
|
+
}
|
|
39
|
+
_next(void 0);
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
}
|
|
15
43
|
const { Text } = Typography;
|
|
16
44
|
function getSDKId(sdk) {
|
|
45
|
+
if (!sdk) return 'playground-default';
|
|
17
46
|
if (sdk.id && 'string' == typeof sdk.id) return `agent-${sdk.id}`;
|
|
18
47
|
return 'playground-default';
|
|
19
48
|
}
|
|
20
|
-
function ErrorMessage(
|
|
21
|
-
let { error } = param;
|
|
49
|
+
function ErrorMessage({ error }) {
|
|
22
50
|
if (!error) return null;
|
|
23
|
-
|
|
24
|
-
|
|
51
|
+
const cleanError = error.replace(/^(Error:\s*)+/, 'Error: ');
|
|
52
|
+
return /*#__PURE__*/ jsx(Alert, {
|
|
53
|
+
message: /*#__PURE__*/ jsx("span", {
|
|
25
54
|
style: {
|
|
26
|
-
|
|
27
|
-
wordBreak: 'break-all'
|
|
55
|
+
color: '#ff4d4f'
|
|
28
56
|
},
|
|
29
|
-
children:
|
|
57
|
+
children: cleanError
|
|
30
58
|
}),
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
},
|
|
34
|
-
children: [
|
|
35
|
-
"Error: ",
|
|
36
|
-
error.split('\n')[0]
|
|
37
|
-
]
|
|
59
|
+
type: "error",
|
|
60
|
+
showIcon: true
|
|
38
61
|
});
|
|
39
62
|
}
|
|
40
|
-
function UniversalPlayground(
|
|
41
|
-
let { playgroundSDK, storage, contextProvider, config: componentConfig = {}, branding = {}, className = '', dryMode = false, showContextPreview = true } = param;
|
|
63
|
+
function UniversalPlayground({ playgroundSDK, storage, contextProvider, config: componentConfig = {}, branding = {}, className = '', dryMode = false, showContextPreview = true }) {
|
|
42
64
|
const [form] = Form.useForm();
|
|
43
65
|
const { config } = useEnvConfig();
|
|
44
66
|
const [sdkReady, setSdkReady] = useState(false);
|
|
45
67
|
useEffect(()=>{
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
68
|
+
form.setFieldsValue({
|
|
69
|
+
type: defaultMainButtons["0"]
|
|
70
|
+
});
|
|
71
|
+
}, [
|
|
72
|
+
form
|
|
73
|
+
]);
|
|
74
|
+
useEffect(()=>{
|
|
75
|
+
const initializeSDK = ()=>_async_to_generator(function*() {
|
|
76
|
+
if (playgroundSDK && 'function' == typeof playgroundSDK.checkStatus) try {
|
|
77
|
+
yield playgroundSDK.checkStatus();
|
|
78
|
+
setSdkReady(true);
|
|
79
|
+
} catch (error) {
|
|
80
|
+
console.warn('Failed to initialize SDK, using default namespace:', error);
|
|
81
|
+
setSdkReady(true);
|
|
82
|
+
}
|
|
83
|
+
else setSdkReady(true);
|
|
84
|
+
})();
|
|
56
85
|
initializeSDK();
|
|
57
86
|
}, [
|
|
58
87
|
playgroundSDK
|
|
@@ -71,7 +100,7 @@ function UniversalPlayground(param) {
|
|
|
71
100
|
playgroundSDK
|
|
72
101
|
]);
|
|
73
102
|
const { loading, setLoading, infoList, setInfoList, actionSpace, actionSpaceLoading, uiContextPreview, setUiContextPreview, showScrollToBottomButton, verticalMode, replayCounter, setReplayCounter, infoListRef, currentRunningIdRef, interruptedFlagRef, clearInfoList, handleScrollToBottom } = usePlaygroundState(playgroundSDK, effectiveStorage, contextProvider);
|
|
74
|
-
const { handleRun: executeAction, handleStop, canStop } = usePlaygroundExecution(playgroundSDK, effectiveStorage, actionSpace, loading, setLoading,
|
|
103
|
+
const { handleRun: executeAction, handleStop, canStop } = usePlaygroundExecution(playgroundSDK, effectiveStorage, actionSpace, loading, setLoading, setInfoList, replayCounter, setReplayCounter, verticalMode, currentRunningIdRef, interruptedFlagRef);
|
|
75
104
|
useEffect(()=>{
|
|
76
105
|
if ((null == playgroundSDK ? void 0 : playgroundSDK.overrideConfig) && config) playgroundSDK.overrideConfig(config).catch((error)=>{
|
|
77
106
|
console.error('Failed to override SDK config:', error);
|
|
@@ -80,23 +109,30 @@ function UniversalPlayground(param) {
|
|
|
80
109
|
playgroundSDK,
|
|
81
110
|
config
|
|
82
111
|
]);
|
|
83
|
-
const handleFormRun = useCallback(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
112
|
+
const handleFormRun = useCallback(()=>_async_to_generator(function*() {
|
|
113
|
+
try {
|
|
114
|
+
const value = form.getFieldsValue();
|
|
115
|
+
yield executeAction(value);
|
|
116
|
+
} catch (error) {
|
|
117
|
+
message.error((null == error ? void 0 : error.message) || 'Execution failed');
|
|
118
|
+
}
|
|
119
|
+
})(), [
|
|
91
120
|
form,
|
|
92
121
|
executeAction
|
|
93
122
|
]);
|
|
94
123
|
const configAlreadySet = Object.keys(config || {}).length >= 1;
|
|
95
124
|
const runButtonEnabled = componentConfig.serverMode || !dryMode && !actionSpaceLoading && configAlreadySet;
|
|
96
125
|
const selectedType = Form.useWatch('type', form);
|
|
126
|
+
const serviceMode = useMemo(()=>{
|
|
127
|
+
if (!playgroundSDK || 'function' != typeof playgroundSDK.getServiceMode) return 'Server';
|
|
128
|
+
return playgroundSDK.getServiceMode();
|
|
129
|
+
}, [
|
|
130
|
+
playgroundSDK
|
|
131
|
+
]);
|
|
97
132
|
const finalShowContextPreview = showContextPreview && false !== componentConfig.showContextPreview;
|
|
98
133
|
const layout = componentConfig.layout || 'vertical';
|
|
99
134
|
const showVersionInfo = false !== componentConfig.showVersionInfo;
|
|
135
|
+
const deviceType = componentConfig.deviceType;
|
|
100
136
|
return /*#__PURE__*/ jsx("div", {
|
|
101
137
|
className: `playground-container ${layout}-mode ${className}`.trim(),
|
|
102
138
|
children: /*#__PURE__*/ jsxs(Form, {
|
|
@@ -131,9 +167,7 @@ function UniversalPlayground(param) {
|
|
|
131
167
|
children: /*#__PURE__*/ jsx(List, {
|
|
132
168
|
itemLayout: "vertical",
|
|
133
169
|
dataSource: infoList,
|
|
134
|
-
renderItem: (item)
|
|
135
|
-
var _item_result;
|
|
136
|
-
return /*#__PURE__*/ jsx(List.Item, {
|
|
170
|
+
renderItem: (item)=>/*#__PURE__*/ jsx(List.Item, {
|
|
137
171
|
className: "list-item",
|
|
138
172
|
children: 'user' === item.type ? /*#__PURE__*/ jsx("div", {
|
|
139
173
|
className: "user-message-container",
|
|
@@ -161,14 +195,15 @@ function UniversalPlayground(param) {
|
|
|
161
195
|
className: `progress-status-icon ${shouldShowLoading ? 'loading' : (null == (_item_result = item.result) ? void 0 : _item_result.error) ? 'error' : 'completed'}`,
|
|
162
196
|
children: shouldShowLoading ? /*#__PURE__*/ jsx(LoadingOutlined, {
|
|
163
197
|
spin: true
|
|
164
|
-
}) : (null == (_item_result1 = item.result) ? void 0 : _item_result1.error) ?
|
|
198
|
+
}) : (null == (_item_result1 = item.result) ? void 0 : _item_result1.error) ? '✗' : '✓'
|
|
165
199
|
})
|
|
166
200
|
]
|
|
167
201
|
}),
|
|
168
202
|
description && /*#__PURE__*/ jsx("div", {
|
|
169
|
-
children: /*#__PURE__*/ jsx(
|
|
203
|
+
children: /*#__PURE__*/ jsx(shiny_text, {
|
|
204
|
+
text: description,
|
|
170
205
|
className: "progress-description",
|
|
171
|
-
|
|
206
|
+
disabled: !shouldShowLoading
|
|
172
207
|
})
|
|
173
208
|
}),
|
|
174
209
|
(null == (_item_result2 = item.result) ? void 0 : _item_result2.error) && /*#__PURE__*/ jsx(ErrorMessage, {
|
|
@@ -210,50 +245,37 @@ function UniversalPlayground(param) {
|
|
|
210
245
|
})
|
|
211
246
|
]
|
|
212
247
|
}),
|
|
213
|
-
(item.content || item.result) && /*#__PURE__*/
|
|
248
|
+
(item.content || item.result) && /*#__PURE__*/ jsx("div", {
|
|
214
249
|
className: "system-message-content",
|
|
215
|
-
children:
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
fitMode: "width"
|
|
237
|
-
}) : /*#__PURE__*/ jsxs(Fragment, {
|
|
238
|
-
children: [
|
|
239
|
-
/*#__PURE__*/ jsx("div", {
|
|
240
|
-
className: "system-message-text",
|
|
241
|
-
children: item.content
|
|
242
|
-
}),
|
|
243
|
-
item.loading && item.loadingProgressText && /*#__PURE__*/ jsx("div", {
|
|
244
|
-
className: "loading-progress-text",
|
|
245
|
-
children: /*#__PURE__*/ jsx("span", {
|
|
246
|
-
children: item.loadingProgressText
|
|
247
|
-
})
|
|
250
|
+
children: 'result' === item.type ? /*#__PURE__*/ jsx(PlaygroundResultView, {
|
|
251
|
+
result: item.result || null,
|
|
252
|
+
loading: item.loading || false,
|
|
253
|
+
serverValid: true,
|
|
254
|
+
serviceMode: serviceMode,
|
|
255
|
+
replayScriptsInfo: item.replayScriptsInfo || null,
|
|
256
|
+
replayCounter: item.replayCounter || 0,
|
|
257
|
+
loadingProgressText: item.loadingProgressText || '',
|
|
258
|
+
verticalMode: item.verticalMode || false,
|
|
259
|
+
fitMode: "width",
|
|
260
|
+
actionType: item.actionType
|
|
261
|
+
}) : /*#__PURE__*/ jsxs(Fragment, {
|
|
262
|
+
children: [
|
|
263
|
+
/*#__PURE__*/ jsx("div", {
|
|
264
|
+
className: "system-message-text",
|
|
265
|
+
children: item.content
|
|
266
|
+
}),
|
|
267
|
+
item.loading && item.loadingProgressText && /*#__PURE__*/ jsx("div", {
|
|
268
|
+
className: "loading-progress-text",
|
|
269
|
+
children: /*#__PURE__*/ jsx("span", {
|
|
270
|
+
children: item.loadingProgressText
|
|
248
271
|
})
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
272
|
+
})
|
|
273
|
+
]
|
|
274
|
+
})
|
|
252
275
|
})
|
|
253
276
|
]
|
|
254
277
|
})
|
|
255
|
-
}, item.id)
|
|
256
|
-
}
|
|
278
|
+
}, item.id)
|
|
257
279
|
})
|
|
258
280
|
}),
|
|
259
281
|
showScrollToBottomButton && false !== componentConfig.enableScrollToBottom && /*#__PURE__*/ jsx(Button, {
|
|
@@ -273,14 +295,15 @@ function UniversalPlayground(param) {
|
|
|
273
295
|
/*#__PURE__*/ jsx(PromptInput, {
|
|
274
296
|
runButtonEnabled: runButtonEnabled,
|
|
275
297
|
form: form,
|
|
276
|
-
serviceMode:
|
|
298
|
+
serviceMode: serviceMode,
|
|
277
299
|
selectedType: selectedType,
|
|
278
300
|
dryMode: dryMode,
|
|
279
301
|
stoppable: canStop,
|
|
280
302
|
loading: loading,
|
|
281
303
|
onRun: handleFormRun,
|
|
282
304
|
onStop: handleStop,
|
|
283
|
-
actionSpace: actionSpace
|
|
305
|
+
actionSpace: actionSpace,
|
|
306
|
+
deviceType: deviceType
|
|
284
307
|
})
|
|
285
308
|
]
|
|
286
309
|
}),
|
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2
|
+
try {
|
|
3
|
+
var info = gen[key](arg);
|
|
4
|
+
var value = info.value;
|
|
5
|
+
} catch (error) {
|
|
6
|
+
reject(error);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (info.done) resolve(value);
|
|
10
|
+
else Promise.resolve(value).then(_next, _throw);
|
|
11
|
+
}
|
|
12
|
+
function _async_to_generator(fn) {
|
|
13
|
+
return function() {
|
|
14
|
+
var self = this, args = arguments;
|
|
15
|
+
return new Promise(function(resolve, reject) {
|
|
16
|
+
var gen = fn.apply(self, args);
|
|
17
|
+
function _next(value) {
|
|
18
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
19
|
+
}
|
|
20
|
+
function _throw(err) {
|
|
21
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
22
|
+
}
|
|
23
|
+
_next(void 0);
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
}
|
|
1
27
|
function _define_property(obj, key, value) {
|
|
2
28
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
3
29
|
value: value,
|
|
@@ -9,44 +35,56 @@ function _define_property(obj, key, value) {
|
|
|
9
35
|
return obj;
|
|
10
36
|
}
|
|
11
37
|
class BaseContextProvider {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
38
|
+
refreshContext() {
|
|
39
|
+
return _async_to_generator(function*() {
|
|
40
|
+
this.cachedContext = void 0;
|
|
41
|
+
return yield this.getUIContext();
|
|
42
|
+
}).call(this);
|
|
15
43
|
}
|
|
16
44
|
constructor(){
|
|
17
45
|
_define_property(this, "cachedContext", void 0);
|
|
18
46
|
}
|
|
19
47
|
}
|
|
20
48
|
class AgentContextProvider extends BaseContextProvider {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
49
|
+
getUIContext() {
|
|
50
|
+
return _async_to_generator(function*() {
|
|
51
|
+
if (this.cachedContext) return this.cachedContext;
|
|
52
|
+
const agent = this.getAgent();
|
|
53
|
+
if (!(null == agent ? void 0 : agent.getUIContext)) throw new Error('Agent does not support getUIContext');
|
|
54
|
+
const context = yield agent.getUIContext();
|
|
55
|
+
this.cachedContext = context;
|
|
56
|
+
return context;
|
|
57
|
+
}).call(this);
|
|
28
58
|
}
|
|
29
59
|
constructor(getAgent, options){
|
|
30
60
|
super(), _define_property(this, "getAgent", void 0), _define_property(this, "options", void 0), this.getAgent = getAgent, this.options = options;
|
|
31
61
|
}
|
|
32
62
|
}
|
|
33
63
|
class StaticContextProvider extends BaseContextProvider {
|
|
34
|
-
|
|
35
|
-
return
|
|
64
|
+
getUIContext() {
|
|
65
|
+
return _async_to_generator(function*() {
|
|
66
|
+
return this.context;
|
|
67
|
+
}).call(this);
|
|
36
68
|
}
|
|
37
|
-
|
|
38
|
-
return
|
|
69
|
+
refreshContext() {
|
|
70
|
+
return _async_to_generator(function*() {
|
|
71
|
+
return this.context;
|
|
72
|
+
}).call(this);
|
|
39
73
|
}
|
|
40
74
|
constructor(context){
|
|
41
75
|
super(), _define_property(this, "context", void 0), this.context = context;
|
|
42
76
|
}
|
|
43
77
|
}
|
|
44
78
|
class NoOpContextProvider {
|
|
45
|
-
|
|
46
|
-
|
|
79
|
+
getUIContext() {
|
|
80
|
+
return _async_to_generator(function*() {
|
|
81
|
+
throw new Error('Context preview is disabled');
|
|
82
|
+
})();
|
|
47
83
|
}
|
|
48
|
-
|
|
49
|
-
|
|
84
|
+
refreshContext() {
|
|
85
|
+
return _async_to_generator(function*() {
|
|
86
|
+
throw new Error('Context preview is disabled');
|
|
87
|
+
})();
|
|
50
88
|
}
|
|
51
89
|
}
|
|
52
90
|
export { AgentContextProvider, BaseContextProvider, NoOpContextProvider, StaticContextProvider };
|