@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,245 @@
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("@rpascene/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, showHumanUse) {
35
+ const { deepThink, screenshotIncluded, domIncluded } = (0, store_js_namespaceObject.useEnvConfig)();
36
+ const handleRun = (0, external_react_namespaceObject.useCallback)(async (value)=>{
37
+ var _result_dump_executions_, _result_dump_executions;
38
+ if (!playgroundSDK) return void console.warn('PlaygroundSDK is not available');
39
+ const thisRunningId = Date.now();
40
+ const actionType = value.type;
41
+ const sub = value.prompt || value.params ? value.prompt || JSON.stringify(value.params) : '';
42
+ const displayContent = sub ? `${value.type}: ${sub}` : value.type;
43
+ const userItem = {
44
+ id: `user-${Date.now()}`,
45
+ type: 'user',
46
+ content: displayContent,
47
+ timestamp: new Date()
48
+ };
49
+ setInfoList((prev)=>[
50
+ ...prev,
51
+ userItem
52
+ ]);
53
+ setLoading(true);
54
+ const result = {
55
+ ...constants_js_namespaceObject.BLANK_RESULT
56
+ };
57
+ const systemItem = {
58
+ id: `system-${thisRunningId}`,
59
+ type: 'system',
60
+ content: '',
61
+ timestamp: new Date(),
62
+ loading: true,
63
+ loadingProgressText: ''
64
+ };
65
+ setInfoList((prev)=>[
66
+ ...prev,
67
+ systemItem
68
+ ]);
69
+ try {
70
+ currentRunningIdRef.current = thisRunningId;
71
+ interruptedFlagRef.current[thisRunningId] = false;
72
+ if (playgroundSDK.onProgressUpdate) playgroundSDK.onProgressUpdate(()=>{});
73
+ if (playgroundSDK.onProgressUpdate) playgroundSDK.onProgressUpdate((tip)=>{
74
+ if (interruptedFlagRef.current[thisRunningId]) return;
75
+ setInfoList((prev)=>{
76
+ const lastItem = prev[prev.length - 1];
77
+ if (lastItem && 'progress' === lastItem.type && lastItem.content === tip) return prev;
78
+ const progressItem = {
79
+ id: `progress-${thisRunningId}-${Date.now()}`,
80
+ type: 'progress',
81
+ content: tip,
82
+ timestamp: new Date()
83
+ };
84
+ return [
85
+ ...prev,
86
+ progressItem
87
+ ];
88
+ });
89
+ });
90
+ result.result = await playgroundSDK.executeAction(actionType, value, {
91
+ requestId: thisRunningId.toString(),
92
+ deepThink,
93
+ screenshotIncluded,
94
+ domIncluded
95
+ });
96
+ if ('object' == typeof result.result && null !== result.result) {
97
+ const resultObj = result.result;
98
+ if (resultObj.dump) result.dump = resultObj.dump;
99
+ if (resultObj.reportHTML) result.reportHTML = resultObj.reportHTML;
100
+ if (resultObj.error) result.error = resultObj.error;
101
+ if (void 0 !== resultObj.result) result.result = resultObj.result;
102
+ }
103
+ } catch (e) {
104
+ result.error = (null == e ? void 0 : e.message) || String(e);
105
+ console.error('Playground execution error:', result);
106
+ }
107
+ console.log('result----', result);
108
+ if (interruptedFlagRef.current[thisRunningId]) return;
109
+ setLoading(false);
110
+ currentRunningIdRef.current = null;
111
+ let replayInfo = null;
112
+ let counter = replayCounter;
113
+ if ((null == result ? void 0 : result.dump) && !playground_namespaceObject.noReplayAPIs.includes(actionType)) {
114
+ const info = (0, replay_scripts_js_namespaceObject.allScriptsFromDump)(result.dump);
115
+ setReplayCounter((c)=>c + 1);
116
+ replayInfo = info;
117
+ counter = replayCounter + 1;
118
+ }
119
+ setInfoList((prev)=>prev.map((item)=>item.id === `system-${thisRunningId}` ? {
120
+ ...item,
121
+ content: '',
122
+ loading: false,
123
+ loadingProgressText: ''
124
+ } : item));
125
+ const resultItem = {
126
+ id: `result-${thisRunningId}`,
127
+ type: 'result',
128
+ content: 'Execution result',
129
+ timestamp: new Date(),
130
+ result: result,
131
+ loading: false,
132
+ replayScriptsInfo: replayInfo,
133
+ replayCounter: counter,
134
+ loadingProgressText: '',
135
+ verticalMode: verticalMode
136
+ };
137
+ setInfoList((prev)=>[
138
+ ...prev,
139
+ resultItem
140
+ ]);
141
+ if (null == storage ? void 0 : storage.saveResult) try {
142
+ await storage.saveResult(resultItem.id, resultItem);
143
+ } catch (error) {
144
+ console.error('Failed to save result:', error);
145
+ }
146
+ if (showHumanUse && result && result.dump && (null == (_result_dump_executions = result.dump.executions) ? void 0 : null == (_result_dump_executions_ = _result_dump_executions[0]) ? void 0 : _result_dump_executions_.tasks)) {
147
+ var _result_dump_executions__tasks_filter, _result_dump_executions__tasks, _result_dump_executions_1, _result_dump_executions1, _result_dump;
148
+ const thisRunningId = Date.now();
149
+ const systemItem = {
150
+ id: `system-${thisRunningId}`,
151
+ type: 'system',
152
+ content: '',
153
+ timestamp: new Date(),
154
+ loading: false,
155
+ loadingProgressText: '',
156
+ actionTasks: null == result ? void 0 : null == (_result_dump = result.dump) ? void 0 : null == (_result_dump_executions1 = _result_dump.executions) ? void 0 : null == (_result_dump_executions_1 = _result_dump_executions1[0]) ? void 0 : null == (_result_dump_executions__tasks = _result_dump_executions_1.tasks) ? void 0 : null == (_result_dump_executions__tasks_filter = _result_dump_executions__tasks.filter((item)=>'Action' === item.type)) ? void 0 : _result_dump_executions__tasks_filter.map((item, index)=>{
157
+ var _result_result_yamlFlow_index, _result_result_yamlFlow, _result_result, _value_params, _value_params1;
158
+ return {
159
+ ...item,
160
+ locate: (null == result ? void 0 : null == (_result_result = result.result) ? void 0 : null == (_result_result_yamlFlow = _result_result.yamlFlow) ? void 0 : null == (_result_result_yamlFlow_index = _result_result_yamlFlow[index]) ? void 0 : _result_result_yamlFlow_index.locate) || (null == value ? void 0 : null == (_value_params = value.params) ? void 0 : _value_params.locate) || (null == value ? void 0 : null == (_value_params1 = value.params) ? void 0 : _value_params1.prompt) || ''
161
+ };
162
+ })
163
+ };
164
+ setInfoList((prev)=>[
165
+ ...prev,
166
+ systemItem
167
+ ]);
168
+ }
169
+ const separatorItem = {
170
+ id: `separator-${thisRunningId}`,
171
+ type: 'separator',
172
+ content: 'New Session',
173
+ timestamp: new Date()
174
+ };
175
+ setInfoList((prev)=>[
176
+ ...prev,
177
+ separatorItem
178
+ ]);
179
+ return {
180
+ ...result,
181
+ reportHTML: null
182
+ };
183
+ }, [
184
+ playgroundSDK,
185
+ storage,
186
+ actionSpace,
187
+ setLoading,
188
+ setInfoList,
189
+ replayCounter,
190
+ setReplayCounter,
191
+ verticalMode,
192
+ currentRunningIdRef,
193
+ interruptedFlagRef,
194
+ deepThink,
195
+ screenshotIncluded,
196
+ domIncluded,
197
+ showHumanUse
198
+ ]);
199
+ const handleStop = (0, external_react_namespaceObject.useCallback)(async ()=>{
200
+ const thisRunningId = currentRunningIdRef.current;
201
+ if (thisRunningId && playgroundSDK && playgroundSDK.cancelExecution) try {
202
+ await playgroundSDK.cancelExecution(thisRunningId.toString());
203
+ interruptedFlagRef.current[thisRunningId] = true;
204
+ setLoading(false);
205
+ if (playgroundSDK.onProgressUpdate) playgroundSDK.onProgressUpdate(()=>{});
206
+ setInfoList((prev)=>prev.map((item)=>item.id === `system-${thisRunningId}` && item.loading ? {
207
+ ...item,
208
+ content: 'Operation stopped',
209
+ loading: false,
210
+ loadingProgressText: ''
211
+ } : item));
212
+ const separatorItem = {
213
+ id: `separator-${thisRunningId}`,
214
+ type: 'separator',
215
+ content: 'New Session',
216
+ timestamp: new Date()
217
+ };
218
+ setInfoList((prev)=>[
219
+ ...prev,
220
+ separatorItem
221
+ ]);
222
+ } catch (error) {
223
+ console.error('Failed to stop execution:', error);
224
+ }
225
+ }, [
226
+ playgroundSDK,
227
+ currentRunningIdRef,
228
+ interruptedFlagRef,
229
+ setLoading,
230
+ setInfoList
231
+ ]);
232
+ const canStop = loading && !!currentRunningIdRef.current && !!playgroundSDK && !!playgroundSDK.cancelExecution;
233
+ return {
234
+ handleRun,
235
+ handleStop,
236
+ canStop
237
+ };
238
+ }
239
+ exports.usePlaygroundExecution = __webpack_exports__.usePlaygroundExecution;
240
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
241
+ "usePlaygroundExecution"
242
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
243
+ Object.defineProperty(exports, '__esModule', {
244
+ value: true
245
+ });
@@ -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("@rpascene/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("@rpascene/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
+ });