@rpascene/visualizer 0.30.11

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 (152) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +8 -0
  3. package/dist/es/component/blackboard/index.css +33 -0
  4. package/dist/es/component/blackboard/index.mjs +278 -0
  5. package/dist/es/component/config-selector/index.mjs +104 -0
  6. package/dist/es/component/context-preview/index.mjs +38 -0
  7. package/dist/es/component/env-config/index.mjs +112 -0
  8. package/dist/es/component/env-config-reminder/index.css +22 -0
  9. package/dist/es/component/env-config-reminder/index.mjs +28 -0
  10. package/dist/es/component/form-field/index.mjs +163 -0
  11. package/dist/es/component/history-selector/index.css +135 -0
  12. package/dist/es/component/history-selector/index.mjs +170 -0
  13. package/dist/es/component/index.mjs +1 -0
  14. package/dist/es/component/logo/index.css +19 -0
  15. package/dist/es/component/logo/index.mjs +21 -0
  16. package/dist/es/component/logo/logo.mjs +2 -0
  17. package/dist/es/component/misc/index.mjs +94 -0
  18. package/dist/es/component/nav-actions/index.mjs +32 -0
  19. package/dist/es/component/nav-actions/style.css +35 -0
  20. package/dist/es/component/player/index.css +185 -0
  21. package/dist/es/component/player/index.mjs +761 -0
  22. package/dist/es/component/playground/index.css +431 -0
  23. package/dist/es/component/playground/index.mjs +8 -0
  24. package/dist/es/component/playground/playground-demo-ui-context.json +290 -0
  25. package/dist/es/component/playground-result/index.css +34 -0
  26. package/dist/es/component/playground-result/index.mjs +62 -0
  27. package/dist/es/component/prompt-input/index.css +391 -0
  28. package/dist/es/component/prompt-input/index.mjs +730 -0
  29. package/dist/es/component/service-mode-control/index.mjs +105 -0
  30. package/dist/es/component/shiny-text/index.css +75 -0
  31. package/dist/es/component/shiny-text/index.mjs +15 -0
  32. package/dist/es/component/universal-playground/index.css +387 -0
  33. package/dist/es/component/universal-playground/index.mjs +403 -0
  34. package/dist/es/component/universal-playground/providers/context-provider.mjs +52 -0
  35. package/dist/es/component/universal-playground/providers/indexeddb-storage-provider.mjs +207 -0
  36. package/dist/es/component/universal-playground/providers/storage-provider.mjs +210 -0
  37. package/dist/es/hooks/usePlaygroundExecution.mjs +211 -0
  38. package/dist/es/hooks/usePlaygroundState.mjs +203 -0
  39. package/dist/es/hooks/useSafeOverrideAIConfig.mjs +24 -0
  40. package/dist/es/hooks/useServerValid.mjs +30 -0
  41. package/dist/es/icons/avatar.mjs +28 -0
  42. package/dist/es/icons/close.mjs +19 -0
  43. package/dist/es/icons/global-perspective.mjs +16 -0
  44. package/dist/es/icons/history.mjs +30 -0
  45. package/dist/es/icons/magnifying-glass.mjs +39 -0
  46. package/dist/es/icons/player-setting.mjs +26 -0
  47. package/dist/es/icons/setting.mjs +20 -0
  48. package/dist/es/icons/show-marker.mjs +16 -0
  49. package/dist/es/index.mjs +25 -0
  50. package/dist/es/static/image/logo.png +0 -0
  51. package/dist/es/store/history.mjs +89 -0
  52. package/dist/es/store/store.mjs +186 -0
  53. package/dist/es/types.mjs +70 -0
  54. package/dist/es/utils/color.mjs +35 -0
  55. package/dist/es/utils/constants.mjs +95 -0
  56. package/dist/es/utils/index.mjs +10 -0
  57. package/dist/es/utils/pixi-loader.mjs +16 -0
  58. package/dist/es/utils/playground-utils.mjs +67 -0
  59. package/dist/es/utils/replay-scripts.mjs +312 -0
  60. package/dist/lib/component/blackboard/index.css +33 -0
  61. package/dist/lib/component/blackboard/index.js +321 -0
  62. package/dist/lib/component/config-selector/index.js +148 -0
  63. package/dist/lib/component/context-preview/index.js +83 -0
  64. package/dist/lib/component/env-config/index.js +146 -0
  65. package/dist/lib/component/env-config-reminder/index.css +22 -0
  66. package/dist/lib/component/env-config-reminder/index.js +62 -0
  67. package/dist/lib/component/form-field/index.js +209 -0
  68. package/dist/lib/component/history-selector/index.css +135 -0
  69. package/dist/lib/component/history-selector/index.js +216 -0
  70. package/dist/lib/component/index.js +60 -0
  71. package/dist/lib/component/logo/index.css +19 -0
  72. package/dist/lib/component/logo/index.js +68 -0
  73. package/dist/lib/component/logo/logo.js +24 -0
  74. package/dist/lib/component/misc/index.js +150 -0
  75. package/dist/lib/component/nav-actions/index.js +66 -0
  76. package/dist/lib/component/nav-actions/style.css +35 -0
  77. package/dist/lib/component/player/index.css +185 -0
  78. package/dist/lib/component/player/index.js +807 -0
  79. package/dist/lib/component/playground/index.css +431 -0
  80. package/dist/lib/component/playground/index.js +113 -0
  81. package/dist/lib/component/playground/playground-demo-ui-context.json +290 -0
  82. package/dist/lib/component/playground-result/index.css +34 -0
  83. package/dist/lib/component/playground-result/index.js +106 -0
  84. package/dist/lib/component/prompt-input/index.css +391 -0
  85. package/dist/lib/component/prompt-input/index.js +774 -0
  86. package/dist/lib/component/service-mode-control/index.js +139 -0
  87. package/dist/lib/component/shiny-text/index.css +75 -0
  88. package/dist/lib/component/shiny-text/index.js +49 -0
  89. package/dist/lib/component/universal-playground/index.css +387 -0
  90. package/dist/lib/component/universal-playground/index.js +451 -0
  91. package/dist/lib/component/universal-playground/providers/context-provider.js +95 -0
  92. package/dist/lib/component/universal-playground/providers/indexeddb-storage-provider.js +247 -0
  93. package/dist/lib/component/universal-playground/providers/storage-provider.js +268 -0
  94. package/dist/lib/hooks/usePlaygroundExecution.js +245 -0
  95. package/dist/lib/hooks/usePlaygroundState.js +237 -0
  96. package/dist/lib/hooks/useSafeOverrideAIConfig.js +61 -0
  97. package/dist/lib/hooks/useServerValid.js +64 -0
  98. package/dist/lib/icons/avatar.js +62 -0
  99. package/dist/lib/icons/close.js +53 -0
  100. package/dist/lib/icons/global-perspective.js +50 -0
  101. package/dist/lib/icons/history.js +64 -0
  102. package/dist/lib/icons/magnifying-glass.js +73 -0
  103. package/dist/lib/icons/player-setting.js +60 -0
  104. package/dist/lib/icons/setting.js +54 -0
  105. package/dist/lib/icons/show-marker.js +50 -0
  106. package/dist/lib/index.js +187 -0
  107. package/dist/lib/static/image/logo.png +0 -0
  108. package/dist/lib/store/history.js +96 -0
  109. package/dist/lib/store/store.js +196 -0
  110. package/dist/lib/types.js +116 -0
  111. package/dist/lib/utils/color.js +75 -0
  112. package/dist/lib/utils/constants.js +150 -0
  113. package/dist/lib/utils/index.js +63 -0
  114. package/dist/lib/utils/pixi-loader.js +56 -0
  115. package/dist/lib/utils/playground-utils.js +110 -0
  116. package/dist/lib/utils/replay-scripts.js +355 -0
  117. package/dist/types/component/blackboard/index.d.ts +15 -0
  118. package/dist/types/component/config-selector/index.d.ts +9 -0
  119. package/dist/types/component/context-preview/index.d.ts +9 -0
  120. package/dist/types/component/env-config/index.d.ts +6 -0
  121. package/dist/types/component/env-config-reminder/index.d.ts +6 -0
  122. package/dist/types/component/form-field/index.d.ts +17 -0
  123. package/dist/types/component/history-selector/index.d.ts +10 -0
  124. package/dist/types/component/index.d.ts +1 -0
  125. package/dist/types/component/logo/index.d.ts +5 -0
  126. package/dist/types/component/misc/index.d.ts +6 -0
  127. package/dist/types/component/nav-actions/index.d.ts +10 -0
  128. package/dist/types/component/player/index.d.ts +13 -0
  129. package/dist/types/component/playground/index.d.ts +7 -0
  130. package/dist/types/component/playground-result/index.d.ts +20 -0
  131. package/dist/types/component/prompt-input/index.d.ts +22 -0
  132. package/dist/types/component/service-mode-control/index.d.ts +6 -0
  133. package/dist/types/component/shiny-text/index.d.ts +12 -0
  134. package/dist/types/component/universal-playground/index.d.ts +4 -0
  135. package/dist/types/component/universal-playground/providers/context-provider.d.ts +37 -0
  136. package/dist/types/component/universal-playground/providers/indexeddb-storage-provider.d.ts +71 -0
  137. package/dist/types/component/universal-playground/providers/storage-provider.d.ts +58 -0
  138. package/dist/types/hooks/usePlaygroundExecution.d.ts +15 -0
  139. package/dist/types/hooks/usePlaygroundState.d.ts +26 -0
  140. package/dist/types/hooks/useSafeOverrideAIConfig.d.ts +16 -0
  141. package/dist/types/hooks/useServerValid.d.ts +1 -0
  142. package/dist/types/index.d.ts +27 -0
  143. package/dist/types/store/history.d.ts +16 -0
  144. package/dist/types/store/store.d.ts +36 -0
  145. package/dist/types/types.d.ts +165 -0
  146. package/dist/types/utils/color.d.ts +4 -0
  147. package/dist/types/utils/constants.d.ts +74 -0
  148. package/dist/types/utils/index.d.ts +4 -0
  149. package/dist/types/utils/pixi-loader.d.ts +5 -0
  150. package/dist/types/utils/playground-utils.d.ts +6 -0
  151. package/dist/types/utils/replay-scripts.d.ts +34 -0
  152. package/package.json +87 -0
@@ -0,0 +1,403 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import icons, { ArrowDownOutlined, ClearOutlined, LoadingOutlined } from "@ant-design/icons";
3
+ import { Button, Form, List, Tooltip, Typography, message } from "antd";
4
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
5
+ import { usePlaygroundExecution } from "../../hooks/usePlaygroundExecution.mjs";
6
+ import { usePlaygroundState } from "../../hooks/usePlaygroundState.mjs";
7
+ import { useEnvConfig } from "../../store/store.mjs";
8
+ import { ContextPreview } from "../context-preview/index.mjs";
9
+ import { PlaygroundResultView } from "../playground-result/index.mjs";
10
+ import avatar from "../../icons/avatar.mjs";
11
+ import { PromptInput } from "../prompt-input/index.mjs";
12
+ import { createStorageProvider, detectBestStorageType } from "./providers/storage-provider.mjs";
13
+ import { overrideAIConfig } from "@rpascene/shared/env";
14
+ import { commandMap } from "@rpascene/shared/constants";
15
+ import "./index.css";
16
+ const { Text } = Typography;
17
+ function getSDKId(sdk) {
18
+ if (sdk.id && 'string' == typeof sdk.id) return `agent-${sdk.id}`;
19
+ return 'playground-default';
20
+ }
21
+ function ErrorMessage(param) {
22
+ let { error } = param;
23
+ if (!error) return null;
24
+ return /*#__PURE__*/ jsxs(Tooltip, {
25
+ title: /*#__PURE__*/ jsx("span", {
26
+ style: {
27
+ whiteSpace: 'pre-wrap',
28
+ wordBreak: 'break-all'
29
+ },
30
+ children: error
31
+ }),
32
+ overlayStyle: {
33
+ maxWidth: '100vw'
34
+ },
35
+ children: [
36
+ "Error: ",
37
+ error.split('\n')[0]
38
+ ]
39
+ });
40
+ }
41
+ function UniversalPlayground(param) {
42
+ let { playgroundSDK, storage, contextProvider, config: componentConfig = {}, branding = {}, className = '', dryMode = false, showContextPreview = true, showPromptInput = true, onHumanUse = ()=>{}, showHumanUse = false } = param;
43
+ const [form] = Form.useForm();
44
+ const { config } = useEnvConfig();
45
+ const [sdkReady, setSdkReady] = useState(false);
46
+ const ref = useRef(null);
47
+ useEffect(()=>{
48
+ const initializeSDK = async ()=>{
49
+ if (playgroundSDK && 'function' == typeof playgroundSDK.checkStatus) try {
50
+ await playgroundSDK.checkStatus();
51
+ setSdkReady(true);
52
+ } catch (error) {
53
+ console.warn('Failed to initialize SDK, using default namespace:', error);
54
+ setSdkReady(true);
55
+ }
56
+ else setSdkReady(true);
57
+ };
58
+ initializeSDK();
59
+ }, [
60
+ playgroundSDK
61
+ ]);
62
+ const effectiveStorage = useMemo(()=>{
63
+ if (storage) return storage;
64
+ if (!sdkReady) return null;
65
+ const namespace = componentConfig.storageNamespace || getSDKId(playgroundSDK);
66
+ const bestStorageType = detectBestStorageType();
67
+ console.log(`Using ${bestStorageType} storage for namespace: ${namespace}`);
68
+ return createStorageProvider(bestStorageType, namespace);
69
+ }, [
70
+ storage,
71
+ sdkReady,
72
+ componentConfig.storageNamespace,
73
+ playgroundSDK
74
+ ]);
75
+ const { loading, setLoading, infoList, setInfoList, actionSpace, actionSpaceLoading, uiContextPreview, setUiContextPreview, showScrollToBottomButton, verticalMode, replayCounter, setReplayCounter, infoListRef, currentRunningIdRef, interruptedFlagRef, clearInfoList, handleScrollToBottom } = usePlaygroundState(playgroundSDK, effectiveStorage, contextProvider);
76
+ const { handleRun: executeAction, handleStop, canStop } = usePlaygroundExecution(playgroundSDK, effectiveStorage, actionSpace, loading, setLoading, infoList, setInfoList, replayCounter, setReplayCounter, verticalMode, currentRunningIdRef, interruptedFlagRef, showHumanUse);
77
+ useEffect(()=>{
78
+ if ((null == playgroundSDK ? void 0 : playgroundSDK.overrideConfig) && config) playgroundSDK.overrideConfig(config).catch((error)=>{
79
+ console.error('Failed to override SDK config:', error);
80
+ });
81
+ }, [
82
+ playgroundSDK,
83
+ config
84
+ ]);
85
+ useEffect(()=>{
86
+ form.setFieldValue('type', 'aiTap');
87
+ }, [
88
+ form
89
+ ]);
90
+ const handleFormRun = useCallback(async ()=>{
91
+ try {
92
+ const value = form.getFieldsValue();
93
+ console.log(value, "\u8868\u5355\u7684\u503C");
94
+ await executeAction(value);
95
+ } catch (error) {
96
+ message.error((null == error ? void 0 : error.message) || 'Execution failed');
97
+ }
98
+ }, [
99
+ form,
100
+ executeAction,
101
+ ref
102
+ ]);
103
+ const configAlreadySet = Object.keys(config || {}).length >= 1;
104
+ const runButtonEnabled = componentConfig.serverMode || !dryMode && !actionSpaceLoading && configAlreadySet;
105
+ const selectedType = Form.useWatch('type', form);
106
+ const finalShowContextPreview = showContextPreview && false !== componentConfig.showContextPreview;
107
+ const layout = componentConfig.layout || 'vertical';
108
+ const showVersionInfo = false !== componentConfig.showVersionInfo;
109
+ useEffect(()=>{
110
+ try {
111
+ const handleMessage = (request, sender, sendResponse)=>{
112
+ if ('zhiyou_rpa_aitap' === request.action) (async ()=>{
113
+ if (canStop) await handleStop();
114
+ clearInfoList();
115
+ overrideAIConfig(request.data.aiConfig);
116
+ try {
117
+ const result = await executeAction({
118
+ type: 'aiTap',
119
+ prompt: request.data.prompt,
120
+ params: {
121
+ locate: request.data.prompt
122
+ }
123
+ });
124
+ sendResponse(result);
125
+ } catch (error) {
126
+ sendResponse({
127
+ error
128
+ });
129
+ }
130
+ })();
131
+ return true;
132
+ };
133
+ chrome.runtime.onMessage.addListener(handleMessage);
134
+ return ()=>{
135
+ chrome.runtime.onMessage.removeListener(handleMessage);
136
+ };
137
+ } catch (error) {}
138
+ }, [
139
+ executeAction,
140
+ clearInfoList,
141
+ canStop,
142
+ handleStop
143
+ ]);
144
+ return /*#__PURE__*/ jsx("div", {
145
+ className: `playground-container ${layout}-mode ${className}`.trim(),
146
+ ref: ref,
147
+ children: /*#__PURE__*/ jsxs(Form, {
148
+ form: form,
149
+ onFinish: handleFormRun,
150
+ className: "command-form",
151
+ initialValues: {
152
+ type: 'aiTap'
153
+ },
154
+ children: [
155
+ finalShowContextPreview && /*#__PURE__*/ jsx("div", {
156
+ className: "context-preview-section",
157
+ children: /*#__PURE__*/ jsx(ContextPreview, {
158
+ uiContextPreview: uiContextPreview,
159
+ setUiContextPreview: setUiContextPreview,
160
+ showContextPreview: finalShowContextPreview
161
+ })
162
+ }),
163
+ /*#__PURE__*/ jsxs("div", {
164
+ className: "middle-dialog-area",
165
+ children: [
166
+ infoList.length > 1 && /*#__PURE__*/ jsx("div", {
167
+ className: "clear-button-container",
168
+ children: /*#__PURE__*/ jsx(Button, {
169
+ size: "small",
170
+ icon: /*#__PURE__*/ jsx(ClearOutlined, {}),
171
+ onClick: clearInfoList,
172
+ type: "text",
173
+ className: "clear-button"
174
+ })
175
+ }),
176
+ /*#__PURE__*/ jsx("div", {
177
+ ref: infoListRef,
178
+ className: "info-list-container",
179
+ children: /*#__PURE__*/ jsx(List, {
180
+ itemLayout: "vertical",
181
+ dataSource: infoList,
182
+ renderItem: (item)=>{
183
+ var _item_result;
184
+ return /*#__PURE__*/ jsx(List.Item, {
185
+ className: "list-item",
186
+ children: 'user' === item.type ? /*#__PURE__*/ jsx("div", {
187
+ className: "user-message-container",
188
+ children: /*#__PURE__*/ jsx("div", {
189
+ className: "user-message-bubble",
190
+ children: item.content
191
+ })
192
+ }) : 'progress' === item.type ? /*#__PURE__*/ jsx("div", {
193
+ children: (()=>{
194
+ var _parts_, _item_result, _item_result1, _item_result2;
195
+ const parts = item.content.split(' - ');
196
+ const action = null == (_parts_ = parts[0]) ? void 0 : _parts_.trim();
197
+ const description = parts.slice(1).join(' - ').trim();
198
+ const currentIndex = infoList.findIndex((listItem)=>listItem.id === item.id);
199
+ const laterProgressExists = infoList.slice(currentIndex + 1).some((listItem)=>'progress' === listItem.type);
200
+ const isLatestProgress = !laterProgressExists;
201
+ const shouldShowLoading = loading && isLatestProgress;
202
+ return /*#__PURE__*/ jsxs(Fragment, {
203
+ children: [
204
+ action && /*#__PURE__*/ jsxs("span", {
205
+ className: "progress-action-item",
206
+ children: [
207
+ action,
208
+ /*#__PURE__*/ jsx("span", {
209
+ className: `progress-status-icon ${shouldShowLoading ? 'loading' : (null == (_item_result = item.result) ? void 0 : _item_result.error) ? 'error' : 'completed'}`,
210
+ children: shouldShowLoading ? /*#__PURE__*/ jsx(LoadingOutlined, {
211
+ spin: true
212
+ }) : (null == (_item_result1 = item.result) ? void 0 : _item_result1.error) ? "\u2717" : "\u2713"
213
+ })
214
+ ]
215
+ }),
216
+ description && /*#__PURE__*/ jsx("div", {
217
+ children: /*#__PURE__*/ jsx("span", {
218
+ className: "progress-description",
219
+ children: description
220
+ })
221
+ }),
222
+ (null == (_item_result2 = item.result) ? void 0 : _item_result2.error) && /*#__PURE__*/ jsx(ErrorMessage, {
223
+ error: item.result.error
224
+ })
225
+ ]
226
+ });
227
+ })()
228
+ }) : 'separator' === item.type ? /*#__PURE__*/ jsxs("div", {
229
+ className: "new-conversation-separator",
230
+ children: [
231
+ /*#__PURE__*/ jsx("div", {
232
+ className: "separator-line"
233
+ }),
234
+ /*#__PURE__*/ jsx("div", {
235
+ className: "separator-text-container",
236
+ children: /*#__PURE__*/ jsx(Text, {
237
+ type: "secondary",
238
+ className: "separator-text",
239
+ children: item.content
240
+ })
241
+ })
242
+ ]
243
+ }) : /*#__PURE__*/ jsxs("div", {
244
+ className: "system-message-container",
245
+ children: [
246
+ /*#__PURE__*/ jsxs("div", {
247
+ className: "system-message-header",
248
+ children: [
249
+ /*#__PURE__*/ jsx(icons, {
250
+ component: branding.icon || avatar,
251
+ style: {
252
+ fontSize: 20
253
+ }
254
+ }),
255
+ /*#__PURE__*/ jsx("span", {
256
+ className: "system-message-title",
257
+ children: branding.title || "RPA\u667A\u80FD\u52A9\u624B"
258
+ })
259
+ ]
260
+ }),
261
+ (item.content || item.result) && /*#__PURE__*/ jsxs("div", {
262
+ className: "system-message-content",
263
+ children: [
264
+ 'result' === item.type && (null == (_item_result = item.result) ? void 0 : _item_result.error) && /*#__PURE__*/ jsxs("div", {
265
+ className: "error-message",
266
+ children: [
267
+ /*#__PURE__*/ jsx("div", {
268
+ className: "divider"
269
+ }),
270
+ /*#__PURE__*/ jsx(ErrorMessage, {
271
+ error: item.result.error
272
+ })
273
+ ]
274
+ }),
275
+ 'result' === item.type ? /*#__PURE__*/ jsx(PlaygroundResultView, {
276
+ result: item.result || null,
277
+ loading: item.loading || false,
278
+ serverValid: true,
279
+ serviceMode: 'Server',
280
+ replayScriptsInfo: item.replayScriptsInfo || null,
281
+ replayCounter: item.replayCounter || 0,
282
+ loadingProgressText: item.loadingProgressText || '',
283
+ verticalMode: item.verticalMode || false,
284
+ fitMode: "width"
285
+ }) : /*#__PURE__*/ jsxs(Fragment, {
286
+ children: [
287
+ /*#__PURE__*/ jsx("div", {
288
+ className: "system-message-text",
289
+ children: item.content
290
+ }),
291
+ item.loading && item.loadingProgressText && /*#__PURE__*/ jsx("div", {
292
+ className: "loading-progress-text",
293
+ children: /*#__PURE__*/ jsx("span", {
294
+ children: item.loadingProgressText
295
+ })
296
+ })
297
+ ]
298
+ })
299
+ ]
300
+ }),
301
+ showHumanUse && (null == item ? void 0 : item.actionTasks) && (null == item ? void 0 : item.actionTasks.length) > 0 && /*#__PURE__*/ jsx("div", {
302
+ className: "system-message-content",
303
+ children: /*#__PURE__*/ jsxs(Fragment, {
304
+ children: [
305
+ /*#__PURE__*/ jsxs("div", {
306
+ className: "system-message-text",
307
+ children: [
308
+ /*#__PURE__*/ jsx("div", {
309
+ className: "action-result-title",
310
+ children: "\u6B64\u6B21\u751F\u6210\u5982\u4E0B\u547D\u4EE4\uFF0C\u70B9\u51FB\u91C7\u7528\u53EF\u63D2\u5165\u5230\u8BBE\u8BA1\u5668"
311
+ }),
312
+ /*#__PURE__*/ jsx("ul", {
313
+ className: "action-result-list",
314
+ children: item.actionTasks.map((data, index)=>{
315
+ var _commandMap_data_subType, _data_param, _data_param1;
316
+ return /*#__PURE__*/ jsxs("li", {
317
+ title: data.locate,
318
+ children: [
319
+ /*#__PURE__*/ jsxs("div", {
320
+ className: "action-result-command",
321
+ children: [
322
+ "\u547D\u4EE4\uFF1A",
323
+ (null == (_commandMap_data_subType = commandMap[data.subType]) ? void 0 : _commandMap_data_subType.DisplayName) || data.subType
324
+ ]
325
+ }),
326
+ (null == data ? void 0 : null == (_data_param = data.param) ? void 0 : _data_param.value) && /*#__PURE__*/ jsxs("div", {
327
+ className: "action-result-command",
328
+ children: [
329
+ "\u503C\uFF1A",
330
+ (null == data ? void 0 : null == (_data_param1 = data.param) ? void 0 : _data_param1.value) || (null == data ? void 0 : data.param.keyName)
331
+ ]
332
+ }),
333
+ /*#__PURE__*/ jsxs("div", {
334
+ className: "action-result-locate",
335
+ children: [
336
+ "\u5143\u7D20\uFF1A",
337
+ data.locate
338
+ ]
339
+ })
340
+ ]
341
+ }, index);
342
+ })
343
+ })
344
+ ]
345
+ }),
346
+ /*#__PURE__*/ jsx("div", {
347
+ className: "action-result-btns",
348
+ children: /*#__PURE__*/ jsx(Button, {
349
+ type: "primary",
350
+ onClick: ()=>onHumanUse(item.actionTasks),
351
+ children: "\u91C7\u7528"
352
+ })
353
+ })
354
+ ]
355
+ })
356
+ })
357
+ ]
358
+ })
359
+ }, item.id);
360
+ }
361
+ })
362
+ }),
363
+ showScrollToBottomButton && false !== componentConfig.enableScrollToBottom && /*#__PURE__*/ jsx(Button, {
364
+ className: "scroll-to-bottom-button",
365
+ type: "primary",
366
+ shape: "circle",
367
+ icon: /*#__PURE__*/ jsx(ArrowDownOutlined, {}),
368
+ onClick: handleScrollToBottom,
369
+ size: "large"
370
+ })
371
+ ]
372
+ }),
373
+ /*#__PURE__*/ jsx("div", {
374
+ className: "bottom-input-section aaa",
375
+ children: showPromptInput && /*#__PURE__*/ jsx(PromptInput, {
376
+ runButtonEnabled: runButtonEnabled,
377
+ form: form,
378
+ serviceMode: 'Server',
379
+ selectedType: selectedType,
380
+ dryMode: dryMode,
381
+ stoppable: canStop,
382
+ loading: loading,
383
+ onRun: handleFormRun,
384
+ onStop: handleStop,
385
+ actionSpace: actionSpace
386
+ })
387
+ }),
388
+ showVersionInfo && branding.version && /*#__PURE__*/ jsx("div", {
389
+ className: "version-info-section",
390
+ children: /*#__PURE__*/ jsxs("span", {
391
+ className: "version-text",
392
+ children: [
393
+ "RPA\u667A\u80FD\u52A9\u624B version: ",
394
+ branding.version
395
+ ]
396
+ })
397
+ })
398
+ ]
399
+ })
400
+ });
401
+ }
402
+ const universal_playground = UniversalPlayground;
403
+ export { UniversalPlayground, universal_playground as default };
@@ -0,0 +1,52 @@
1
+ function _define_property(obj, key, value) {
2
+ if (key in obj) Object.defineProperty(obj, key, {
3
+ value: value,
4
+ enumerable: true,
5
+ configurable: true,
6
+ writable: true
7
+ });
8
+ else obj[key] = value;
9
+ return obj;
10
+ }
11
+ class BaseContextProvider {
12
+ async refreshContext() {
13
+ this.cachedContext = void 0;
14
+ return await this.getUIContext();
15
+ }
16
+ constructor(){
17
+ _define_property(this, "cachedContext", void 0);
18
+ }
19
+ }
20
+ class AgentContextProvider extends BaseContextProvider {
21
+ async getUIContext() {
22
+ if (this.cachedContext) return this.cachedContext;
23
+ const agent = this.getAgent();
24
+ if (!(null == agent ? void 0 : agent.getUIContext)) throw new Error('Agent does not support getUIContext');
25
+ const context = await agent.getUIContext();
26
+ this.cachedContext = context;
27
+ return context;
28
+ }
29
+ constructor(getAgent, options){
30
+ super(), _define_property(this, "getAgent", void 0), _define_property(this, "options", void 0), this.getAgent = getAgent, this.options = options;
31
+ }
32
+ }
33
+ class StaticContextProvider extends BaseContextProvider {
34
+ async getUIContext() {
35
+ return this.context;
36
+ }
37
+ async refreshContext() {
38
+ return this.context;
39
+ }
40
+ constructor(context){
41
+ super(), _define_property(this, "context", void 0), this.context = context;
42
+ }
43
+ }
44
+ class NoOpContextProvider {
45
+ async getUIContext() {
46
+ throw new Error('Context preview is disabled');
47
+ }
48
+ async refreshContext() {
49
+ throw new Error('Context preview is disabled');
50
+ }
51
+ }
52
+ export { AgentContextProvider, BaseContextProvider, NoOpContextProvider, StaticContextProvider };
@@ -0,0 +1,207 @@
1
+ import { IndexedDBManager, createCleanupFunction, withErrorHandling } from "@rpascene/shared/baseDB";
2
+ function _define_property(obj, key, value) {
3
+ if (key in obj) Object.defineProperty(obj, key, {
4
+ value: value,
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true
8
+ });
9
+ else obj[key] = value;
10
+ return obj;
11
+ }
12
+ const DB_NAME = 'rpascene_playground';
13
+ const DB_VERSION = 1;
14
+ const MESSAGES_STORE = 'playground_messages';
15
+ const RESULTS_STORE = 'playground_results';
16
+ const MAX_STORED_MESSAGES = 100;
17
+ const MAX_STORED_RESULTS = 50;
18
+ class IndexedDBStorageProvider {
19
+ async saveMessages(messages) {
20
+ await withErrorHandling(async ()=>{
21
+ await this.dbManager.clear(MESSAGES_STORE);
22
+ const messagesToSave = messages.slice(-MAX_STORED_MESSAGES);
23
+ await Promise.all(messagesToSave.map((msg, index)=>{
24
+ const lightMessage = {
25
+ ...msg,
26
+ result: void 0
27
+ };
28
+ const data = {
29
+ id: msg.id || `msg-${index}`,
30
+ data: lightMessage,
31
+ timestamp: msg.timestamp ? msg.timestamp.getTime() : Date.now() + index
32
+ };
33
+ return this.dbManager.put(MESSAGES_STORE, data);
34
+ }));
35
+ }, 'Failed to save messages to IndexedDB', void 0, this.messagesCleanup);
36
+ }
37
+ async loadMessages() {
38
+ const result = await withErrorHandling(async ()=>{
39
+ const messages = await this.dbManager.getAll(MESSAGES_STORE, true);
40
+ if (0 === messages.length) return [];
41
+ return Promise.all(messages.map(async (msg)=>{
42
+ const item = msg.data;
43
+ const restoredItem = {
44
+ ...item,
45
+ timestamp: new Date(item.timestamp)
46
+ };
47
+ if ('result' === item.type && item.id) {
48
+ const fullResult = await this.loadResult(item.id);
49
+ if (fullResult) {
50
+ restoredItem.result = fullResult.result;
51
+ restoredItem.replayScriptsInfo = fullResult.replayScriptsInfo;
52
+ restoredItem.replayCounter = fullResult.replayCounter;
53
+ restoredItem.verticalMode = fullResult.verticalMode;
54
+ }
55
+ }
56
+ return restoredItem;
57
+ }));
58
+ }, 'Failed to load messages from IndexedDB', [], this.messagesCleanup);
59
+ return result || [];
60
+ }
61
+ async clearMessages() {
62
+ await withErrorHandling(async ()=>{
63
+ await Promise.all([
64
+ this.dbManager.clear(MESSAGES_STORE),
65
+ this.dbManager.clear(RESULTS_STORE)
66
+ ]);
67
+ }, 'Failed to clear messages from IndexedDB');
68
+ }
69
+ async saveResult(id, result) {
70
+ await withErrorHandling(async ()=>{
71
+ const compressedResult = this.compressResultForStorage(result);
72
+ const data = {
73
+ id,
74
+ data: compressedResult,
75
+ timestamp: Date.now(),
76
+ size: JSON.stringify(compressedResult).length
77
+ };
78
+ await this.dbManager.put(RESULTS_STORE, data);
79
+ }, 'Failed to save result to IndexedDB', void 0, this.resultsCleanup);
80
+ }
81
+ async loadResult(id) {
82
+ const result = await withErrorHandling(async ()=>{
83
+ const data = await this.dbManager.get(RESULTS_STORE, id);
84
+ return (null == data ? void 0 : data.data) || null;
85
+ }, 'Failed to load result from IndexedDB', null);
86
+ return result || null;
87
+ }
88
+ compressResultForStorage(result) {
89
+ var _result_result_dump, _result_result;
90
+ if (!(null == (_result_result = result.result) ? void 0 : null == (_result_result_dump = _result_result.dump) ? void 0 : _result_result_dump.executions)) return result;
91
+ const compressedExecutions = result.result.dump.executions.map((execution)=>{
92
+ var _execution_tasks;
93
+ return {
94
+ ...execution,
95
+ tasks: (null == (_execution_tasks = execution.tasks) ? void 0 : _execution_tasks.map((task)=>{
96
+ var _task_recorder;
97
+ var _this_compressScreenshotIfNeeded;
98
+ return {
99
+ ...task,
100
+ uiContext: task.uiContext ? {
101
+ ...task.uiContext,
102
+ screenshotBase64: null != (_this_compressScreenshotIfNeeded = this.compressScreenshotIfNeeded(task.uiContext.screenshotBase64)) ? _this_compressScreenshotIfNeeded : task.uiContext.screenshotBase64
103
+ } : task.uiContext,
104
+ recorder: null == (_task_recorder = task.recorder) ? void 0 : _task_recorder.map((record)=>({
105
+ ...record,
106
+ screenshot: this.compressScreenshotIfNeeded(record.screenshot)
107
+ }))
108
+ };
109
+ })) || []
110
+ };
111
+ });
112
+ return {
113
+ ...result,
114
+ result: {
115
+ ...result.result,
116
+ dump: {
117
+ ...result.result.dump,
118
+ executions: compressedExecutions
119
+ }
120
+ }
121
+ };
122
+ }
123
+ compressScreenshotIfNeeded(screenshot) {
124
+ if (!screenshot) return screenshot;
125
+ if (screenshot.length > 1048576) {
126
+ const sizeKB = Math.round(screenshot.length / 1024);
127
+ return `[COMPRESSED: ${sizeKB}KB screenshot removed for storage]`;
128
+ }
129
+ return screenshot;
130
+ }
131
+ async getStorageStats() {
132
+ const result = await withErrorHandling(async ()=>{
133
+ const [messageCount, resultCount] = await Promise.all([
134
+ this.dbManager.count(MESSAGES_STORE),
135
+ this.dbManager.count(RESULTS_STORE)
136
+ ]);
137
+ return {
138
+ messageCount,
139
+ resultCount
140
+ };
141
+ }, 'Failed to get storage statistics', {
142
+ messageCount: 0,
143
+ resultCount: 0
144
+ });
145
+ return result || {
146
+ messageCount: 0,
147
+ resultCount: 0
148
+ };
149
+ }
150
+ async cleanup() {
151
+ await Promise.all([
152
+ this.messagesCleanup(),
153
+ this.resultsCleanup()
154
+ ]);
155
+ }
156
+ constructor(namespace = 'playground'){
157
+ _define_property(this, "dbManager", void 0);
158
+ _define_property(this, "namespace", void 0);
159
+ _define_property(this, "messagesCleanup", void 0);
160
+ _define_property(this, "resultsCleanup", void 0);
161
+ this.namespace = namespace;
162
+ this.dbManager = new IndexedDBManager(`${DB_NAME}_${namespace}`, DB_VERSION, [
163
+ {
164
+ name: MESSAGES_STORE,
165
+ keyPath: 'id'
166
+ },
167
+ {
168
+ name: RESULTS_STORE,
169
+ keyPath: 'id'
170
+ }
171
+ ]);
172
+ this.messagesCleanup = createCleanupFunction(this.dbManager, MESSAGES_STORE, MAX_STORED_MESSAGES);
173
+ this.resultsCleanup = createCleanupFunction(this.dbManager, RESULTS_STORE, MAX_STORED_RESULTS);
174
+ }
175
+ }
176
+ class MemoryStorageProvider {
177
+ async saveMessages(messages) {
178
+ this.messages = [
179
+ ...messages
180
+ ];
181
+ }
182
+ async loadMessages() {
183
+ return [
184
+ ...this.messages
185
+ ];
186
+ }
187
+ async clearMessages() {
188
+ this.messages = [];
189
+ this.results.clear();
190
+ }
191
+ async saveResult(id, result) {
192
+ this.results.set(id, result);
193
+ }
194
+ constructor(){
195
+ _define_property(this, "messages", []);
196
+ _define_property(this, "results", new Map());
197
+ }
198
+ }
199
+ class NoOpStorageProvider {
200
+ async saveMessages(_messages) {}
201
+ async loadMessages() {
202
+ return [];
203
+ }
204
+ async clearMessages() {}
205
+ async saveResult(_id, _result) {}
206
+ }
207
+ export { IndexedDBStorageProvider, MemoryStorageProvider, NoOpStorageProvider };