@sqaitech/visualizer 0.5.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/LICENSE +21 -0
- package/README.md +9 -0
- package/dist/es/assets/sqai-logo.mjs +2 -0
- package/dist/es/component/blackboard/index.css +33 -0
- package/dist/es/component/blackboard/index.mjs +278 -0
- package/dist/es/component/config-selector/index.mjs +104 -0
- package/dist/es/component/context-preview/index.mjs +38 -0
- package/dist/es/component/env-config/index.mjs +112 -0
- package/dist/es/component/env-config-reminder/index.css +22 -0
- package/dist/es/component/env-config-reminder/index.mjs +28 -0
- package/dist/es/component/form-field/index.mjs +163 -0
- package/dist/es/component/history-selector/index.css +135 -0
- package/dist/es/component/history-selector/index.mjs +170 -0
- package/dist/es/component/index.mjs +1 -0
- package/dist/es/component/logo/index.css +13 -0
- package/dist/es/component/logo/index.mjs +21 -0
- package/dist/es/component/misc/index.mjs +94 -0
- package/dist/es/component/nav-actions/index.mjs +32 -0
- package/dist/es/component/nav-actions/style.css +35 -0
- package/dist/es/component/player/index.css +185 -0
- package/dist/es/component/player/index.mjs +856 -0
- package/dist/es/component/playground/index.css +431 -0
- package/dist/es/component/playground/index.mjs +8 -0
- package/dist/es/component/playground/playground-demo-ui-context.json +290 -0
- package/dist/es/component/playground-result/index.css +34 -0
- package/dist/es/component/playground-result/index.mjs +62 -0
- package/dist/es/component/prompt-input/index.css +391 -0
- package/dist/es/component/prompt-input/index.mjs +730 -0
- package/dist/es/component/service-mode-control/index.mjs +105 -0
- package/dist/es/component/shiny-text/index.css +75 -0
- package/dist/es/component/shiny-text/index.mjs +15 -0
- package/dist/es/component/universal-playground/index.css +341 -0
- package/dist/es/component/universal-playground/index.mjs +302 -0
- package/dist/es/component/universal-playground/providers/context-provider.mjs +52 -0
- package/dist/es/component/universal-playground/providers/indexeddb-storage-provider.mjs +207 -0
- package/dist/es/component/universal-playground/providers/storage-provider.mjs +210 -0
- package/dist/es/hooks/usePlaygroundExecution.mjs +180 -0
- package/dist/es/hooks/usePlaygroundState.mjs +203 -0
- package/dist/es/hooks/useSafeOverrideAIConfig.mjs +24 -0
- package/dist/es/hooks/useServerValid.mjs +30 -0
- package/dist/es/icons/avatar.mjs +28 -0
- package/dist/es/icons/close.mjs +19 -0
- package/dist/es/icons/global-perspective.mjs +16 -0
- package/dist/es/icons/history.mjs +30 -0
- package/dist/es/icons/magnifying-glass.mjs +39 -0
- package/dist/es/icons/player-setting.mjs +26 -0
- package/dist/es/icons/setting.mjs +20 -0
- package/dist/es/icons/show-marker.mjs +16 -0
- package/dist/es/index.mjs +25 -0
- package/dist/es/static/image/sqai-logo.png +0 -0
- package/dist/es/store/history.mjs +89 -0
- package/dist/es/store/store.mjs +186 -0
- package/dist/es/types.mjs +70 -0
- package/dist/es/utils/color.mjs +35 -0
- package/dist/es/utils/constants.mjs +99 -0
- package/dist/es/utils/index.mjs +10 -0
- package/dist/es/utils/pixi-loader.mjs +16 -0
- package/dist/es/utils/playground-utils.mjs +67 -0
- package/dist/es/utils/replay-scripts.mjs +312 -0
- package/dist/lib/assets/sqai-logo.js +24 -0
- package/dist/lib/component/blackboard/index.css +33 -0
- package/dist/lib/component/blackboard/index.js +321 -0
- package/dist/lib/component/config-selector/index.js +148 -0
- package/dist/lib/component/context-preview/index.js +83 -0
- package/dist/lib/component/env-config/index.js +146 -0
- package/dist/lib/component/env-config-reminder/index.css +22 -0
- package/dist/lib/component/env-config-reminder/index.js +62 -0
- package/dist/lib/component/form-field/index.js +209 -0
- package/dist/lib/component/history-selector/index.css +135 -0
- package/dist/lib/component/history-selector/index.js +216 -0
- package/dist/lib/component/index.js +60 -0
- package/dist/lib/component/logo/index.css +13 -0
- package/dist/lib/component/logo/index.js +68 -0
- package/dist/lib/component/misc/index.js +150 -0
- package/dist/lib/component/nav-actions/index.js +66 -0
- package/dist/lib/component/nav-actions/style.css +35 -0
- package/dist/lib/component/player/index.css +185 -0
- package/dist/lib/component/player/index.js +902 -0
- package/dist/lib/component/playground/index.css +431 -0
- package/dist/lib/component/playground/index.js +113 -0
- package/dist/lib/component/playground/playground-demo-ui-context.json +290 -0
- package/dist/lib/component/playground-result/index.css +34 -0
- package/dist/lib/component/playground-result/index.js +106 -0
- package/dist/lib/component/prompt-input/index.css +391 -0
- package/dist/lib/component/prompt-input/index.js +774 -0
- package/dist/lib/component/service-mode-control/index.js +139 -0
- package/dist/lib/component/shiny-text/index.css +75 -0
- package/dist/lib/component/shiny-text/index.js +49 -0
- package/dist/lib/component/universal-playground/index.css +341 -0
- package/dist/lib/component/universal-playground/index.js +350 -0
- package/dist/lib/component/universal-playground/providers/context-provider.js +95 -0
- package/dist/lib/component/universal-playground/providers/indexeddb-storage-provider.js +247 -0
- package/dist/lib/component/universal-playground/providers/storage-provider.js +268 -0
- package/dist/lib/hooks/usePlaygroundExecution.js +214 -0
- package/dist/lib/hooks/usePlaygroundState.js +237 -0
- package/dist/lib/hooks/useSafeOverrideAIConfig.js +61 -0
- package/dist/lib/hooks/useServerValid.js +64 -0
- package/dist/lib/icons/avatar.js +62 -0
- package/dist/lib/icons/close.js +53 -0
- package/dist/lib/icons/global-perspective.js +50 -0
- package/dist/lib/icons/history.js +64 -0
- package/dist/lib/icons/magnifying-glass.js +73 -0
- package/dist/lib/icons/player-setting.js +60 -0
- package/dist/lib/icons/setting.js +54 -0
- package/dist/lib/icons/show-marker.js +50 -0
- package/dist/lib/index.js +187 -0
- package/dist/lib/static/image/sqai-logo.png +0 -0
- package/dist/lib/store/history.js +96 -0
- package/dist/lib/store/store.js +196 -0
- package/dist/lib/types.js +116 -0
- package/dist/lib/utils/color.js +75 -0
- package/dist/lib/utils/constants.js +154 -0
- package/dist/lib/utils/index.js +63 -0
- package/dist/lib/utils/pixi-loader.js +56 -0
- package/dist/lib/utils/playground-utils.js +110 -0
- package/dist/lib/utils/replay-scripts.js +355 -0
- package/dist/types/component/blackboard/index.d.ts +15 -0
- package/dist/types/component/config-selector/index.d.ts +9 -0
- package/dist/types/component/context-preview/index.d.ts +9 -0
- package/dist/types/component/env-config/index.d.ts +6 -0
- package/dist/types/component/env-config-reminder/index.d.ts +6 -0
- package/dist/types/component/form-field/index.d.ts +17 -0
- package/dist/types/component/history-selector/index.d.ts +10 -0
- package/dist/types/component/index.d.ts +1 -0
- package/dist/types/component/logo/index.d.ts +5 -0
- package/dist/types/component/misc/index.d.ts +6 -0
- package/dist/types/component/nav-actions/index.d.ts +10 -0
- package/dist/types/component/player/index.d.ts +13 -0
- package/dist/types/component/playground/index.d.ts +7 -0
- package/dist/types/component/playground-result/index.d.ts +20 -0
- package/dist/types/component/prompt-input/index.d.ts +22 -0
- package/dist/types/component/service-mode-control/index.d.ts +6 -0
- package/dist/types/component/shiny-text/index.d.ts +12 -0
- package/dist/types/component/universal-playground/index.d.ts +4 -0
- package/dist/types/component/universal-playground/providers/context-provider.d.ts +37 -0
- package/dist/types/component/universal-playground/providers/indexeddb-storage-provider.d.ts +71 -0
- package/dist/types/component/universal-playground/providers/storage-provider.d.ts +58 -0
- package/dist/types/hooks/usePlaygroundExecution.d.ts +10 -0
- package/dist/types/hooks/usePlaygroundState.d.ts +26 -0
- package/dist/types/hooks/useSafeOverrideAIConfig.d.ts +16 -0
- package/dist/types/hooks/useServerValid.d.ts +1 -0
- package/dist/types/index.d.ts +27 -0
- package/dist/types/store/history.d.ts +16 -0
- package/dist/types/store/store.d.ts +36 -0
- package/dist/types/types.d.ts +161 -0
- package/dist/types/utils/color.d.ts +4 -0
- package/dist/types/utils/constants.d.ts +74 -0
- package/dist/types/utils/index.d.ts +4 -0
- package/dist/types/utils/pixi-loader.d.ts +5 -0
- package/dist/types/utils/playground-utils.d.ts +6 -0
- package/dist/types/utils/replay-scripts.d.ts +34 -0
- package/package.json +85 -0
|
@@ -0,0 +1,214 @@
|
|
|
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
|
+
usePlaygroundExecution: ()=>usePlaygroundExecution
|
|
28
|
+
});
|
|
29
|
+
const external_react_namespaceObject = require("react");
|
|
30
|
+
const store_js_namespaceObject = require("../store/store.js");
|
|
31
|
+
const playground_namespaceObject = require("@sqaitech/playground");
|
|
32
|
+
const constants_js_namespaceObject = require("../utils/constants.js");
|
|
33
|
+
const replay_scripts_js_namespaceObject = require("../utils/replay-scripts.js");
|
|
34
|
+
function usePlaygroundExecution(playgroundSDK, storage, actionSpace, loading, setLoading, infoList, setInfoList, replayCounter, setReplayCounter, verticalMode, currentRunningIdRef, interruptedFlagRef) {
|
|
35
|
+
const { deepThink, screenshotIncluded, domIncluded } = (0, store_js_namespaceObject.useEnvConfig)();
|
|
36
|
+
const handleRun = (0, external_react_namespaceObject.useCallback)(async (value)=>{
|
|
37
|
+
if (!playgroundSDK) return void console.warn('PlaygroundSDK is not available');
|
|
38
|
+
const thisRunningId = Date.now();
|
|
39
|
+
const actionType = value.type;
|
|
40
|
+
const displayContent = `${value.type}: ${value.prompt || JSON.stringify(value.params)}`;
|
|
41
|
+
const userItem = {
|
|
42
|
+
id: `user-${Date.now()}`,
|
|
43
|
+
type: 'user',
|
|
44
|
+
content: displayContent,
|
|
45
|
+
timestamp: new Date()
|
|
46
|
+
};
|
|
47
|
+
setInfoList((prev)=>[
|
|
48
|
+
...prev,
|
|
49
|
+
userItem
|
|
50
|
+
]);
|
|
51
|
+
setLoading(true);
|
|
52
|
+
const result = {
|
|
53
|
+
...constants_js_namespaceObject.BLANK_RESULT
|
|
54
|
+
};
|
|
55
|
+
const systemItem = {
|
|
56
|
+
id: `system-${thisRunningId}`,
|
|
57
|
+
type: 'system',
|
|
58
|
+
content: '',
|
|
59
|
+
timestamp: new Date(),
|
|
60
|
+
loading: true,
|
|
61
|
+
loadingProgressText: ''
|
|
62
|
+
};
|
|
63
|
+
setInfoList((prev)=>[
|
|
64
|
+
...prev,
|
|
65
|
+
systemItem
|
|
66
|
+
]);
|
|
67
|
+
try {
|
|
68
|
+
currentRunningIdRef.current = thisRunningId;
|
|
69
|
+
interruptedFlagRef.current[thisRunningId] = false;
|
|
70
|
+
if (playgroundSDK.onProgressUpdate) playgroundSDK.onProgressUpdate(()=>{});
|
|
71
|
+
if (playgroundSDK.onProgressUpdate) playgroundSDK.onProgressUpdate((tip)=>{
|
|
72
|
+
if (interruptedFlagRef.current[thisRunningId]) return;
|
|
73
|
+
setInfoList((prev)=>{
|
|
74
|
+
const lastItem = prev[prev.length - 1];
|
|
75
|
+
if (lastItem && 'progress' === lastItem.type && lastItem.content === tip) return prev;
|
|
76
|
+
const progressItem = {
|
|
77
|
+
id: `progress-${thisRunningId}-${Date.now()}`,
|
|
78
|
+
type: 'progress',
|
|
79
|
+
content: tip,
|
|
80
|
+
timestamp: new Date()
|
|
81
|
+
};
|
|
82
|
+
return [
|
|
83
|
+
...prev,
|
|
84
|
+
progressItem
|
|
85
|
+
];
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
result.result = await playgroundSDK.executeAction(actionType, value, {
|
|
89
|
+
requestId: thisRunningId.toString(),
|
|
90
|
+
deepThink,
|
|
91
|
+
screenshotIncluded,
|
|
92
|
+
domIncluded
|
|
93
|
+
});
|
|
94
|
+
if ('object' == typeof result.result && null !== result.result) {
|
|
95
|
+
const resultObj = result.result;
|
|
96
|
+
if (resultObj.dump) result.dump = resultObj.dump;
|
|
97
|
+
if (resultObj.reportHTML) result.reportHTML = resultObj.reportHTML;
|
|
98
|
+
if (resultObj.error) result.error = resultObj.error;
|
|
99
|
+
if (void 0 !== resultObj.result) result.result = resultObj.result;
|
|
100
|
+
}
|
|
101
|
+
} catch (e) {
|
|
102
|
+
result.error = (null == e ? void 0 : e.message) || String(e);
|
|
103
|
+
console.error('Playground execution error:', e);
|
|
104
|
+
}
|
|
105
|
+
if (interruptedFlagRef.current[thisRunningId]) return;
|
|
106
|
+
setLoading(false);
|
|
107
|
+
currentRunningIdRef.current = null;
|
|
108
|
+
let replayInfo = null;
|
|
109
|
+
let counter = replayCounter;
|
|
110
|
+
if ((null == result ? void 0 : result.dump) && !playground_namespaceObject.noReplayAPIs.includes(actionType)) {
|
|
111
|
+
const info = (0, replay_scripts_js_namespaceObject.allScriptsFromDump)(result.dump);
|
|
112
|
+
setReplayCounter((c)=>c + 1);
|
|
113
|
+
replayInfo = info;
|
|
114
|
+
counter = replayCounter + 1;
|
|
115
|
+
}
|
|
116
|
+
setInfoList((prev)=>prev.map((item)=>item.id === `system-${thisRunningId}` ? {
|
|
117
|
+
...item,
|
|
118
|
+
content: '',
|
|
119
|
+
loading: false,
|
|
120
|
+
loadingProgressText: ''
|
|
121
|
+
} : item));
|
|
122
|
+
const resultItem = {
|
|
123
|
+
id: `result-${thisRunningId}`,
|
|
124
|
+
type: 'result',
|
|
125
|
+
content: 'Execution result',
|
|
126
|
+
timestamp: new Date(),
|
|
127
|
+
result: result,
|
|
128
|
+
loading: false,
|
|
129
|
+
replayScriptsInfo: replayInfo,
|
|
130
|
+
replayCounter: counter,
|
|
131
|
+
loadingProgressText: '',
|
|
132
|
+
verticalMode: verticalMode
|
|
133
|
+
};
|
|
134
|
+
setInfoList((prev)=>[
|
|
135
|
+
...prev,
|
|
136
|
+
resultItem
|
|
137
|
+
]);
|
|
138
|
+
if (null == storage ? void 0 : storage.saveResult) try {
|
|
139
|
+
await storage.saveResult(resultItem.id, resultItem);
|
|
140
|
+
} catch (error) {
|
|
141
|
+
console.error('Failed to save result:', error);
|
|
142
|
+
}
|
|
143
|
+
const separatorItem = {
|
|
144
|
+
id: `separator-${thisRunningId}`,
|
|
145
|
+
type: 'separator',
|
|
146
|
+
content: 'New Session',
|
|
147
|
+
timestamp: new Date()
|
|
148
|
+
};
|
|
149
|
+
setInfoList((prev)=>[
|
|
150
|
+
...prev,
|
|
151
|
+
separatorItem
|
|
152
|
+
]);
|
|
153
|
+
}, [
|
|
154
|
+
playgroundSDK,
|
|
155
|
+
storage,
|
|
156
|
+
actionSpace,
|
|
157
|
+
setLoading,
|
|
158
|
+
setInfoList,
|
|
159
|
+
replayCounter,
|
|
160
|
+
setReplayCounter,
|
|
161
|
+
verticalMode,
|
|
162
|
+
currentRunningIdRef,
|
|
163
|
+
interruptedFlagRef,
|
|
164
|
+
deepThink,
|
|
165
|
+
screenshotIncluded,
|
|
166
|
+
domIncluded
|
|
167
|
+
]);
|
|
168
|
+
const handleStop = (0, external_react_namespaceObject.useCallback)(async ()=>{
|
|
169
|
+
const thisRunningId = currentRunningIdRef.current;
|
|
170
|
+
if (thisRunningId && playgroundSDK && playgroundSDK.cancelExecution) try {
|
|
171
|
+
await playgroundSDK.cancelExecution(thisRunningId.toString());
|
|
172
|
+
interruptedFlagRef.current[thisRunningId] = true;
|
|
173
|
+
setLoading(false);
|
|
174
|
+
if (playgroundSDK.onProgressUpdate) playgroundSDK.onProgressUpdate(()=>{});
|
|
175
|
+
setInfoList((prev)=>prev.map((item)=>item.id === `system-${thisRunningId}` && item.loading ? {
|
|
176
|
+
...item,
|
|
177
|
+
content: 'Operation stopped',
|
|
178
|
+
loading: false,
|
|
179
|
+
loadingProgressText: ''
|
|
180
|
+
} : item));
|
|
181
|
+
const separatorItem = {
|
|
182
|
+
id: `separator-${thisRunningId}`,
|
|
183
|
+
type: 'separator',
|
|
184
|
+
content: 'New Session',
|
|
185
|
+
timestamp: new Date()
|
|
186
|
+
};
|
|
187
|
+
setInfoList((prev)=>[
|
|
188
|
+
...prev,
|
|
189
|
+
separatorItem
|
|
190
|
+
]);
|
|
191
|
+
} catch (error) {
|
|
192
|
+
console.error('Failed to stop execution:', error);
|
|
193
|
+
}
|
|
194
|
+
}, [
|
|
195
|
+
playgroundSDK,
|
|
196
|
+
currentRunningIdRef,
|
|
197
|
+
interruptedFlagRef,
|
|
198
|
+
setLoading,
|
|
199
|
+
setInfoList
|
|
200
|
+
]);
|
|
201
|
+
const canStop = loading && !!currentRunningIdRef.current && !!playgroundSDK && !!playgroundSDK.cancelExecution;
|
|
202
|
+
return {
|
|
203
|
+
handleRun,
|
|
204
|
+
handleStop,
|
|
205
|
+
canStop
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
exports.usePlaygroundExecution = __webpack_exports__.usePlaygroundExecution;
|
|
209
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
210
|
+
"usePlaygroundExecution"
|
|
211
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
212
|
+
Object.defineProperty(exports, '__esModule', {
|
|
213
|
+
value: true
|
|
214
|
+
});
|
|
@@ -0,0 +1,237 @@
|
|
|
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
|
+
usePlaygroundState: ()=>usePlaygroundState
|
|
28
|
+
});
|
|
29
|
+
const external_react_namespaceObject = require("react");
|
|
30
|
+
const storage_provider_js_namespaceObject = require("../component/universal-playground/providers/storage-provider.js");
|
|
31
|
+
const constants_js_namespaceObject = require("../utils/constants.js");
|
|
32
|
+
function usePlaygroundState(playgroundSDK, storage, contextProvider) {
|
|
33
|
+
const [loading, setLoading] = (0, external_react_namespaceObject.useState)(false);
|
|
34
|
+
const [infoList, setInfoList] = (0, external_react_namespaceObject.useState)([]);
|
|
35
|
+
const [actionSpace, setActionSpace] = (0, external_react_namespaceObject.useState)([]);
|
|
36
|
+
const [actionSpaceLoading, setActionSpaceLoading] = (0, external_react_namespaceObject.useState)(true);
|
|
37
|
+
const [uiContextPreview, setUiContextPreview] = (0, external_react_namespaceObject.useState)();
|
|
38
|
+
const [showScrollToBottomButton, setShowScrollToBottomButton] = (0, external_react_namespaceObject.useState)(false);
|
|
39
|
+
const [verticalMode, setVerticalMode] = (0, external_react_namespaceObject.useState)(false);
|
|
40
|
+
const [replayCounter, setReplayCounter] = (0, external_react_namespaceObject.useState)(0);
|
|
41
|
+
const infoListRef = (0, external_react_namespaceObject.useRef)(null);
|
|
42
|
+
const currentRunningIdRef = (0, external_react_namespaceObject.useRef)(null);
|
|
43
|
+
const interruptedFlagRef = (0, external_react_namespaceObject.useRef)({});
|
|
44
|
+
const initializedRef = (0, external_react_namespaceObject.useRef)(false);
|
|
45
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
46
|
+
const migrateFromOldNamespace = async ()=>{
|
|
47
|
+
const oldStorage = (0, storage_provider_js_namespaceObject.createStorageProvider)((0, storage_provider_js_namespaceObject.detectBestStorageType)(), 'playground-default');
|
|
48
|
+
try {
|
|
49
|
+
if (null == oldStorage ? void 0 : oldStorage.loadMessages) {
|
|
50
|
+
const oldMessages = await oldStorage.loadMessages();
|
|
51
|
+
if (oldMessages.length > 1) {
|
|
52
|
+
console.log('Found data in old namespace, migrating...');
|
|
53
|
+
if (null == storage ? void 0 : storage.saveMessages) await storage.saveMessages(oldMessages);
|
|
54
|
+
if (oldStorage.clearMessages) await oldStorage.clearMessages();
|
|
55
|
+
return oldMessages;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
} catch (error) {
|
|
59
|
+
console.debug('No data found in old namespace:', error);
|
|
60
|
+
}
|
|
61
|
+
return [];
|
|
62
|
+
};
|
|
63
|
+
const initializeMessages = async ()=>{
|
|
64
|
+
const welcomeMessage = {
|
|
65
|
+
...constants_js_namespaceObject.WELCOME_MESSAGE_TEMPLATE,
|
|
66
|
+
id: 'welcome',
|
|
67
|
+
timestamp: new Date()
|
|
68
|
+
};
|
|
69
|
+
if (null == storage ? void 0 : storage.loadMessages) try {
|
|
70
|
+
let storedMessages = await storage.loadMessages();
|
|
71
|
+
if (0 === storedMessages.length) storedMessages = await migrateFromOldNamespace();
|
|
72
|
+
const hasWelcomeMessage = storedMessages.some((msg)=>'welcome' === msg.id);
|
|
73
|
+
hasWelcomeMessage ? setInfoList(storedMessages) : setInfoList([
|
|
74
|
+
welcomeMessage,
|
|
75
|
+
...storedMessages
|
|
76
|
+
]);
|
|
77
|
+
} catch (error) {
|
|
78
|
+
console.error('Failed to load messages:', error);
|
|
79
|
+
setInfoList([
|
|
80
|
+
welcomeMessage
|
|
81
|
+
]);
|
|
82
|
+
}
|
|
83
|
+
else setInfoList([
|
|
84
|
+
welcomeMessage
|
|
85
|
+
]);
|
|
86
|
+
};
|
|
87
|
+
if (storage && !initializedRef.current) {
|
|
88
|
+
initializedRef.current = true;
|
|
89
|
+
initializeMessages();
|
|
90
|
+
} else if (!storage && 0 === infoList.length) initializeMessages();
|
|
91
|
+
}, [
|
|
92
|
+
storage
|
|
93
|
+
]);
|
|
94
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
95
|
+
if ((null == storage ? void 0 : storage.saveMessages) && infoList.length > 1) storage.saveMessages(infoList).catch((error)=>{
|
|
96
|
+
if (error instanceof DOMException && 'QuotaExceededError' === error.name) console.warn('Storage quota exceeded - some messages may not be saved persistently');
|
|
97
|
+
else console.error('Failed to save messages:', error);
|
|
98
|
+
});
|
|
99
|
+
}, [
|
|
100
|
+
infoList,
|
|
101
|
+
storage
|
|
102
|
+
]);
|
|
103
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
104
|
+
if (!(null == contextProvider ? void 0 : contextProvider.getUIContext) || uiContextPreview) return;
|
|
105
|
+
contextProvider.getUIContext().then((context)=>setUiContextPreview(context)).catch((error)=>{
|
|
106
|
+
console.error('Failed to get UI context:', error);
|
|
107
|
+
});
|
|
108
|
+
}, [
|
|
109
|
+
contextProvider,
|
|
110
|
+
uiContextPreview
|
|
111
|
+
]);
|
|
112
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
113
|
+
const loadActionSpace = async ()=>{
|
|
114
|
+
setActionSpaceLoading(true);
|
|
115
|
+
try {
|
|
116
|
+
var _contextProvider_getUIContext;
|
|
117
|
+
if (!playgroundSDK) return void setActionSpace([]);
|
|
118
|
+
const context = uiContextPreview || await (null == contextProvider ? void 0 : null == (_contextProvider_getUIContext = contextProvider.getUIContext) ? void 0 : _contextProvider_getUIContext.call(contextProvider));
|
|
119
|
+
const space = await playgroundSDK.getActionSpace(context);
|
|
120
|
+
setActionSpace(space || []);
|
|
121
|
+
} catch (error) {
|
|
122
|
+
console.error('Failed to load action space:', error);
|
|
123
|
+
setActionSpace([]);
|
|
124
|
+
} finally{
|
|
125
|
+
setActionSpaceLoading(false);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
loadActionSpace();
|
|
129
|
+
}, [
|
|
130
|
+
playgroundSDK,
|
|
131
|
+
uiContextPreview,
|
|
132
|
+
contextProvider
|
|
133
|
+
]);
|
|
134
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
135
|
+
const sizeThreshold = 750;
|
|
136
|
+
setVerticalMode(window.innerWidth < sizeThreshold);
|
|
137
|
+
const handleResize = ()=>{
|
|
138
|
+
setVerticalMode(window.innerWidth < sizeThreshold);
|
|
139
|
+
};
|
|
140
|
+
window.addEventListener('resize', handleResize);
|
|
141
|
+
return ()=>window.removeEventListener('resize', handleResize);
|
|
142
|
+
}, []);
|
|
143
|
+
const scrollToBottom = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
144
|
+
setTimeout(()=>{
|
|
145
|
+
if (infoListRef.current) infoListRef.current.scrollTop = infoListRef.current.scrollHeight;
|
|
146
|
+
}, 100);
|
|
147
|
+
}, []);
|
|
148
|
+
const checkIfScrolledToBottom = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
149
|
+
if (infoListRef.current) {
|
|
150
|
+
const { scrollTop, scrollHeight, clientHeight } = infoListRef.current;
|
|
151
|
+
const isAtBottom = scrollTop + clientHeight >= scrollHeight - 10;
|
|
152
|
+
setShowScrollToBottomButton(!isAtBottom);
|
|
153
|
+
}
|
|
154
|
+
}, []);
|
|
155
|
+
const handleScrollToBottom = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
156
|
+
if (infoListRef.current) {
|
|
157
|
+
infoListRef.current.scrollTo({
|
|
158
|
+
top: infoListRef.current.scrollHeight,
|
|
159
|
+
behavior: 'smooth'
|
|
160
|
+
});
|
|
161
|
+
setShowScrollToBottomButton(false);
|
|
162
|
+
}
|
|
163
|
+
}, []);
|
|
164
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
165
|
+
if (infoList.length > 0) scrollToBottom();
|
|
166
|
+
}, [
|
|
167
|
+
infoList,
|
|
168
|
+
scrollToBottom
|
|
169
|
+
]);
|
|
170
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
171
|
+
const container = infoListRef.current;
|
|
172
|
+
if (container) {
|
|
173
|
+
container.addEventListener('scroll', checkIfScrolledToBottom);
|
|
174
|
+
checkIfScrolledToBottom();
|
|
175
|
+
return ()=>{
|
|
176
|
+
container.removeEventListener('scroll', checkIfScrolledToBottom);
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
}, [
|
|
180
|
+
checkIfScrolledToBottom
|
|
181
|
+
]);
|
|
182
|
+
const clearInfoList = (0, external_react_namespaceObject.useCallback)(async ()=>{
|
|
183
|
+
const welcomeMessage = {
|
|
184
|
+
...constants_js_namespaceObject.WELCOME_MESSAGE_TEMPLATE,
|
|
185
|
+
id: 'welcome',
|
|
186
|
+
timestamp: new Date()
|
|
187
|
+
};
|
|
188
|
+
setInfoList([
|
|
189
|
+
welcomeMessage
|
|
190
|
+
]);
|
|
191
|
+
if (null == storage ? void 0 : storage.clearMessages) try {
|
|
192
|
+
await storage.clearMessages();
|
|
193
|
+
} catch (error) {
|
|
194
|
+
console.error('Failed to clear stored messages:', error);
|
|
195
|
+
}
|
|
196
|
+
}, [
|
|
197
|
+
storage
|
|
198
|
+
]);
|
|
199
|
+
const refreshContext = (0, external_react_namespaceObject.useCallback)(async ()=>{
|
|
200
|
+
if (null == contextProvider ? void 0 : contextProvider.refreshContext) try {
|
|
201
|
+
const newContext = await contextProvider.refreshContext();
|
|
202
|
+
setUiContextPreview(newContext);
|
|
203
|
+
} catch (error) {
|
|
204
|
+
console.error('Failed to refresh context:', error);
|
|
205
|
+
}
|
|
206
|
+
}, [
|
|
207
|
+
contextProvider
|
|
208
|
+
]);
|
|
209
|
+
return {
|
|
210
|
+
loading,
|
|
211
|
+
setLoading,
|
|
212
|
+
infoList,
|
|
213
|
+
setInfoList,
|
|
214
|
+
actionSpace,
|
|
215
|
+
actionSpaceLoading,
|
|
216
|
+
uiContextPreview,
|
|
217
|
+
setUiContextPreview,
|
|
218
|
+
showScrollToBottomButton,
|
|
219
|
+
verticalMode,
|
|
220
|
+
replayCounter,
|
|
221
|
+
setReplayCounter,
|
|
222
|
+
infoListRef,
|
|
223
|
+
currentRunningIdRef,
|
|
224
|
+
interruptedFlagRef,
|
|
225
|
+
clearInfoList,
|
|
226
|
+
refreshContext,
|
|
227
|
+
handleScrollToBottom,
|
|
228
|
+
scrollToBottom
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
exports.usePlaygroundState = __webpack_exports__.usePlaygroundState;
|
|
232
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
233
|
+
"usePlaygroundState"
|
|
234
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
235
|
+
Object.defineProperty(exports, '__esModule', {
|
|
236
|
+
value: true
|
|
237
|
+
});
|
|
@@ -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("@sqaitech/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
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
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
|
+
useServerValid: ()=>useServerValid
|
|
28
|
+
});
|
|
29
|
+
const playground_namespaceObject = require("@sqaitech/playground");
|
|
30
|
+
const external_react_namespaceObject = require("react");
|
|
31
|
+
const store_js_namespaceObject = require("../store/store.js");
|
|
32
|
+
const useServerValid = function() {
|
|
33
|
+
let shouldRun = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : true;
|
|
34
|
+
const [serverValid, setServerValid] = (0, external_react_namespaceObject.useState)(true);
|
|
35
|
+
const { serviceMode } = (0, store_js_namespaceObject.useEnvConfig)();
|
|
36
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
37
|
+
let interruptFlag = false;
|
|
38
|
+
if (!shouldRun) return;
|
|
39
|
+
Promise.resolve((async ()=>{
|
|
40
|
+
while(!interruptFlag){
|
|
41
|
+
const playgroundSDK = new playground_namespaceObject.PlaygroundSDK({
|
|
42
|
+
type: 'remote-execution'
|
|
43
|
+
});
|
|
44
|
+
const status = await playgroundSDK.checkStatus();
|
|
45
|
+
status ? setServerValid(true) : setServerValid(false);
|
|
46
|
+
await new Promise((resolve)=>setTimeout(resolve, 1000));
|
|
47
|
+
}
|
|
48
|
+
})());
|
|
49
|
+
return ()=>{
|
|
50
|
+
interruptFlag = true;
|
|
51
|
+
};
|
|
52
|
+
}, [
|
|
53
|
+
serviceMode,
|
|
54
|
+
shouldRun
|
|
55
|
+
]);
|
|
56
|
+
return serverValid;
|
|
57
|
+
};
|
|
58
|
+
exports.useServerValid = __webpack_exports__.useServerValid;
|
|
59
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
60
|
+
"useServerValid"
|
|
61
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
62
|
+
Object.defineProperty(exports, '__esModule', {
|
|
63
|
+
value: true
|
|
64
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
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
|
+
default: ()=>avatar
|
|
28
|
+
});
|
|
29
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
|
+
require("react");
|
|
31
|
+
const SvgAvatar = (props)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("svg", {
|
|
32
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
33
|
+
width: 20,
|
|
34
|
+
height: 20,
|
|
35
|
+
fill: "none",
|
|
36
|
+
"aria-label": "Playground",
|
|
37
|
+
viewBox: "0 0 20 20",
|
|
38
|
+
...props,
|
|
39
|
+
children: [
|
|
40
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("rect", {
|
|
41
|
+
width: 20,
|
|
42
|
+
height: 20,
|
|
43
|
+
fill: "#2B83FF",
|
|
44
|
+
rx: 10
|
|
45
|
+
}),
|
|
46
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("path", {
|
|
47
|
+
fill: "#2B83FF",
|
|
48
|
+
stroke: "#fff",
|
|
49
|
+
strokeLinejoin: "round",
|
|
50
|
+
strokeWidth: 1.125,
|
|
51
|
+
d: "M6.866 5.882a.56.56 0 0 1 .667-.078l3.248 1.875 3.247 1.875a.563.563 0 0 1 0 .974l-3.247 1.875-3.248 1.875a.563.563 0 0 1-.784-.74l1.749-3.497-1.75-3.498a.56.56 0 0 1 .118-.661Z"
|
|
52
|
+
})
|
|
53
|
+
]
|
|
54
|
+
});
|
|
55
|
+
const avatar = SvgAvatar;
|
|
56
|
+
exports["default"] = __webpack_exports__["default"];
|
|
57
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
58
|
+
"default"
|
|
59
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
60
|
+
Object.defineProperty(exports, '__esModule', {
|
|
61
|
+
value: true
|
|
62
|
+
});
|