@midscene/visualizer 0.28.1-beta-20250909063633.0 → 0.28.2-beta-20250909133629.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.
Files changed (133) hide show
  1. package/dist/es/browser.mjs +18 -0
  2. package/dist/es/component/{blackboard.mjs → blackboard/index.mjs} +3 -3
  3. package/dist/es/component/{playground/ConfigSelector.mjs → config-selector/index.mjs} +2 -3
  4. package/dist/es/component/{playground/ContextPreview.mjs → context-preview/index.mjs} +3 -4
  5. package/dist/es/component/{env-config.mjs → env-config/index.mjs} +1 -1
  6. package/dist/es/component/{github-star.mjs → github-star/index.mjs} +1 -1
  7. package/dist/es/component/history-selector/index.css +132 -0
  8. package/dist/es/component/{playground/HistorySelector.mjs → history-selector/index.mjs} +1 -1
  9. package/dist/es/component/index.mjs +1 -0
  10. package/dist/es/component/{logo.mjs → logo/index.mjs} +1 -1
  11. package/dist/es/component/{misc.mjs → misc/index.mjs} +42 -2
  12. package/dist/es/component/{player.mjs → player/index.mjs} +8 -8
  13. package/dist/es/component/playground/index.css +29 -161
  14. package/dist/es/component/playground/index.mjs +8 -0
  15. package/dist/es/component/playground-result/index.css +29 -0
  16. package/dist/es/component/{playground/PlaygroundResult.mjs → playground-result/index.mjs} +3 -4
  17. package/dist/es/component/prompt-input/index.css +330 -0
  18. package/dist/es/component/{playground/PromptInput.mjs → prompt-input/index.mjs} +9 -9
  19. package/dist/es/component/{playground/ServiceModeControl.mjs → service-mode-control/index.mjs} +4 -5
  20. package/dist/es/component/{shiny-text.mjs → shiny-text/index.mjs} +1 -1
  21. package/dist/es/component/universal-playground/index.css +341 -0
  22. package/dist/es/component/universal-playground/index.mjs +273 -0
  23. package/dist/es/component/universal-playground/providers/context-provider.mjs +52 -0
  24. package/dist/es/component/universal-playground/providers/storage-provider.mjs +107 -0
  25. package/dist/es/hooks/usePlaygroundExecution.mjs +170 -0
  26. package/dist/es/hooks/usePlaygroundState.mjs +173 -0
  27. package/dist/es/icons/avatar.mjs +14 -0
  28. package/dist/es/index.mjs +22 -18
  29. package/dist/es/{component/playground/types.mjs → types.mjs} +23 -1
  30. package/dist/es/{component/playground/playground-constants.mjs → utils/constants.mjs} +1 -2
  31. package/dist/es/{component/playground → utils}/playground-utils.mjs +1 -1
  32. package/dist/es/{component → utils}/replay-scripts.mjs +1 -2
  33. package/dist/lib/browser.js +132 -0
  34. package/dist/lib/component/{blackboard.js → blackboard/index.js} +5 -5
  35. package/dist/lib/component/{playground/ConfigSelector.js → config-selector/index.js} +6 -7
  36. package/dist/lib/component/{playground/ContextPreview.js → context-preview/index.js} +8 -9
  37. package/dist/lib/component/{env-config.js → env-config/index.js} +1 -1
  38. package/dist/lib/component/{github-star.js → github-star/index.js} +1 -1
  39. package/dist/lib/component/history-selector/index.css +132 -0
  40. package/dist/lib/component/{playground/HistorySelector.js → history-selector/index.js} +1 -1
  41. package/dist/lib/component/index.js +60 -0
  42. package/dist/lib/component/{logo.js → logo/index.js} +1 -1
  43. package/dist/lib/component/{misc.js → misc/index.js} +60 -1
  44. package/dist/lib/component/{player.js → player/index.js} +23 -23
  45. package/dist/lib/component/playground/index.css +29 -161
  46. package/dist/lib/component/playground/index.js +113 -0
  47. package/dist/lib/component/playground-result/index.css +29 -0
  48. package/dist/lib/component/{playground/PlaygroundResult.js → playground-result/index.js} +8 -9
  49. package/dist/lib/component/prompt-input/index.css +330 -0
  50. package/dist/lib/component/{playground/PromptInput.js → prompt-input/index.js} +37 -37
  51. package/dist/lib/component/{playground/ServiceModeControl.js → service-mode-control/index.js} +8 -9
  52. package/dist/lib/component/{shiny-text.js → shiny-text/index.js} +1 -1
  53. package/dist/lib/component/universal-playground/index.css +341 -0
  54. package/dist/lib/component/universal-playground/index.js +321 -0
  55. package/dist/lib/component/universal-playground/providers/context-provider.js +95 -0
  56. package/dist/lib/component/universal-playground/providers/storage-provider.js +147 -0
  57. package/dist/lib/hooks/usePlaygroundExecution.js +204 -0
  58. package/dist/lib/hooks/usePlaygroundState.js +207 -0
  59. package/dist/lib/{init.js → icons/avatar.js} +16 -12
  60. package/dist/lib/index.js +66 -34
  61. package/dist/lib/{component/playground/types.js → types.js} +28 -0
  62. package/dist/lib/{component/playground/playground-constants.js → utils/constants.js} +3 -4
  63. package/dist/lib/{component/playground → utils}/playground-utils.js +1 -1
  64. package/dist/lib/{component → utils}/replay-scripts.js +3 -4
  65. package/dist/types/browser.d.ts +19 -0
  66. package/dist/types/component/{blackboard.d.ts → blackboard/index.d.ts} +2 -2
  67. package/dist/types/component/{playground/ConfigSelector.d.ts → config-selector/index.d.ts} +0 -1
  68. package/dist/types/component/{playground/ContextPreview.d.ts → context-preview/index.d.ts} +0 -1
  69. package/dist/types/component/{github-star.d.ts → github-star/index.d.ts} +1 -1
  70. package/dist/types/component/{playground/HistorySelector.d.ts → history-selector/index.d.ts} +1 -1
  71. package/dist/types/component/index.d.ts +1 -0
  72. package/dist/types/component/{logo.d.ts → logo/index.d.ts} +1 -1
  73. package/dist/types/component/misc/index.d.ts +6 -0
  74. package/dist/types/component/{player.d.ts → player/index.d.ts} +2 -2
  75. package/dist/types/component/playground/index.d.ts +7 -0
  76. package/dist/types/component/{playground/PlaygroundResult.d.ts → playground-result/index.d.ts} +3 -4
  77. package/dist/types/component/{playground/PromptInput.d.ts → prompt-input/index.d.ts} +3 -2
  78. package/dist/types/component/{playground/ServiceModeControl.d.ts → service-mode-control/index.d.ts} +0 -1
  79. package/dist/types/component/{shiny-text.d.ts → shiny-text/index.d.ts} +1 -1
  80. package/dist/types/component/universal-playground/index.d.ts +4 -0
  81. package/dist/types/component/universal-playground/providers/context-provider.d.ts +37 -0
  82. package/dist/types/component/universal-playground/providers/storage-provider.d.ts +33 -0
  83. package/dist/types/hooks/usePlaygroundExecution.d.ts +10 -0
  84. package/dist/types/hooks/usePlaygroundState.d.ts +26 -0
  85. package/dist/types/index.d.ts +15 -10
  86. package/dist/types/types.d.ts +166 -0
  87. package/dist/types/{component/playground/playground-constants.d.ts → utils/constants.d.ts} +0 -1
  88. package/dist/types/{component → utils}/replay-scripts.d.ts +0 -1
  89. package/package.json +10 -5
  90. package/dist/es/component/describer.css +0 -25
  91. package/dist/es/component/playground/playground-types.mjs +0 -0
  92. package/dist/es/init.mjs +0 -10
  93. package/dist/lib/component/describer.css +0 -25
  94. package/dist/lib/component/playground/playground-types.js +0 -18
  95. package/dist/types/component/misc.d.ts +0 -2
  96. package/dist/types/component/playground/playground-types.d.ts +0 -19
  97. package/dist/types/component/playground/types.d.ts +0 -72
  98. package/dist/types/init.d.ts +0 -1
  99. /package/dist/es/component/{blackboard.css → blackboard/index.css} +0 -0
  100. /package/dist/es/component/{playground/FormField.mjs → form-field/index.mjs} +0 -0
  101. /package/dist/es/component/{github-star.css → github-star/index.css} +0 -0
  102. /package/dist/es/component/{logo.css → logo/index.css} +0 -0
  103. /package/dist/es/component/{player.css → player/index.css} +0 -0
  104. /package/dist/es/component/{playground-demo-ui-context.json → playground/playground-demo-ui-context.json} +0 -0
  105. /package/dist/es/component/{shiny-text.css → shiny-text/index.css} +0 -0
  106. /package/dist/es/{component/playground → hooks}/useServerValid.mjs +0 -0
  107. /package/dist/es/{component/store → store}/history.mjs +0 -0
  108. /package/dist/es/{component/store → store}/store.mjs +0 -0
  109. /package/dist/es/{component → utils}/color.mjs +0 -0
  110. /package/dist/es/{utils.mjs → utils/index.mjs} +0 -0
  111. /package/dist/es/{component → utils}/pixi-loader.mjs +0 -0
  112. /package/dist/lib/component/{blackboard.css → blackboard/index.css} +0 -0
  113. /package/dist/lib/component/{playground/FormField.js → form-field/index.js} +0 -0
  114. /package/dist/lib/component/{github-star.css → github-star/index.css} +0 -0
  115. /package/dist/lib/component/{logo.css → logo/index.css} +0 -0
  116. /package/dist/lib/component/{player.css → player/index.css} +0 -0
  117. /package/dist/lib/component/{playground-demo-ui-context.json → playground/playground-demo-ui-context.json} +0 -0
  118. /package/dist/lib/component/{shiny-text.css → shiny-text/index.css} +0 -0
  119. /package/dist/lib/{component/playground → hooks}/useServerValid.js +0 -0
  120. /package/dist/lib/{component/store → store}/history.js +0 -0
  121. /package/dist/lib/{component/store → store}/store.js +0 -0
  122. /package/dist/lib/{component → utils}/color.js +0 -0
  123. /package/dist/lib/{utils.js → utils/index.js} +0 -0
  124. /package/dist/lib/{component → utils}/pixi-loader.js +0 -0
  125. /package/dist/types/component/{env-config.d.ts → env-config/index.d.ts} +0 -0
  126. /package/dist/types/component/{playground/FormField.d.ts → form-field/index.d.ts} +0 -0
  127. /package/dist/types/{component/playground → hooks}/useServerValid.d.ts +0 -0
  128. /package/dist/types/{component/store → store}/history.d.ts +0 -0
  129. /package/dist/types/{component/store → store}/store.d.ts +0 -0
  130. /package/dist/types/{component → utils}/color.d.ts +0 -0
  131. /package/dist/types/{utils.d.ts → utils/index.d.ts} +0 -0
  132. /package/dist/types/{component → utils}/pixi-loader.d.ts +0 -0
  133. /package/dist/types/{component/playground → utils}/playground-utils.d.ts +0 -0
@@ -0,0 +1,341 @@
1
+ .playground-container {
2
+ background: #fff;
3
+ flex-direction: column;
4
+ width: 100%;
5
+ height: 100vh;
6
+ padding: 0 12px;
7
+ display: flex;
8
+ }
9
+
10
+ .playground-container .command-form {
11
+ flex-direction: column;
12
+ width: 100%;
13
+ height: 100%;
14
+ display: flex;
15
+ }
16
+
17
+ .playground-container .context-preview-section {
18
+ border-bottom: 1px solid #f0f0f0;
19
+ flex-shrink: 0;
20
+ padding: 16px;
21
+ }
22
+
23
+ .playground-container .middle-dialog-area {
24
+ flex-direction: column;
25
+ flex: 1;
26
+ min-height: 0;
27
+ display: flex;
28
+ position: relative;
29
+ overflow: hidden;
30
+ }
31
+
32
+ .playground-container .middle-dialog-area .clear-button-container {
33
+ z-index: 10;
34
+ position: absolute;
35
+ top: 8px;
36
+ right: 12px;
37
+ }
38
+
39
+ .playground-container .middle-dialog-area .clear-button-container .clear-button {
40
+ opacity: .7;
41
+ transition: opacity .2s;
42
+ }
43
+
44
+ .playground-container .middle-dialog-area .clear-button-container .clear-button:hover {
45
+ opacity: 1;
46
+ }
47
+
48
+ .playground-container .middle-dialog-area .info-list-container {
49
+ scrollbar-width: none;
50
+ flex: 1;
51
+ padding-top: 16px;
52
+ padding-bottom: 16px;
53
+ overflow-x: hidden;
54
+ overflow-y: auto;
55
+ }
56
+
57
+ .playground-container .middle-dialog-area .info-list-container .ant-list .ant-list-item {
58
+ border-bottom: none;
59
+ padding: 0;
60
+ }
61
+
62
+ .playground-container .middle-dialog-area .info-list-container .ant-list .ant-list-item .ant-card {
63
+ border: 1px solid #f0f0f0;
64
+ border-radius: 8px;
65
+ box-shadow: 0 1px 3px rgba(0, 0, 0, .1);
66
+ }
67
+
68
+ .playground-container .middle-dialog-area .info-list-container .ant-list .ant-list-item .ant-card:hover {
69
+ box-shadow: 0 2px 6px rgba(0, 0, 0, .15);
70
+ }
71
+
72
+ .playground-container .middle-dialog-area .info-list-container .ant-list .ant-list-item .ant-card .ant-card-body {
73
+ padding: 12px;
74
+ }
75
+
76
+ .playground-container .middle-dialog-area .info-list-container .ant-list .ant-list-empty-text {
77
+ color: #999;
78
+ font-style: italic;
79
+ }
80
+
81
+ .playground-container .middle-dialog-area .info-list-container::-webkit-scrollbar {
82
+ display: none;
83
+ }
84
+
85
+ .playground-container .middle-dialog-area .info-list-container .list-item {
86
+ background: none;
87
+ border: none;
88
+ padding: 0;
89
+ }
90
+
91
+ .playground-container .middle-dialog-area .scroll-to-bottom-button {
92
+ z-index: 10;
93
+ background: #fff;
94
+ position: absolute;
95
+ bottom: 10px;
96
+ right: 0;
97
+ box-shadow: 0 4px 8px rgba(0, 0, 0, .04);
98
+ }
99
+
100
+ .playground-container .middle-dialog-area .scroll-to-bottom-button:hover {
101
+ background: #1890ff;
102
+ }
103
+
104
+ .playground-container .middle-dialog-area .scroll-to-bottom-button:hover .anticon {
105
+ color: #fff;
106
+ }
107
+
108
+ .playground-container .middle-dialog-area .scroll-to-bottom-button .anticon {
109
+ color: #333;
110
+ font-size: 16px;
111
+ }
112
+
113
+ .playground-container .user-message-container {
114
+ justify-content: flex-end;
115
+ width: 100%;
116
+ margin: 20px 0 30px;
117
+ display: flex;
118
+ }
119
+
120
+ .playground-container .user-message-container .user-message-bubble {
121
+ color: rgba(0, 0, 0, .85);
122
+ text-align: center;
123
+ background: #f2f4f7;
124
+ border-radius: 12px;
125
+ max-width: 80%;
126
+ padding: 12px 16px;
127
+ font-size: 14px;
128
+ font-weight: 400;
129
+ display: inline-block;
130
+ }
131
+
132
+ .playground-container .progress-action-item {
133
+ color: #000;
134
+ background: #f2f4f7;
135
+ border-radius: 8px;
136
+ justify-content: space-between;
137
+ height: 36px;
138
+ margin: 4px 0;
139
+ padding: 0 12px;
140
+ font-size: 14px;
141
+ line-height: 36px;
142
+ display: flex;
143
+ }
144
+
145
+ .playground-container .progress-action-item .progress-status-icon {
146
+ margin-left: 4px;
147
+ }
148
+
149
+ .playground-container .progress-action-item .progress-status-icon.loading {
150
+ color: #1890ff;
151
+ }
152
+
153
+ .playground-container .progress-action-item .progress-status-icon.completed {
154
+ color: #52c41a;
155
+ }
156
+
157
+ .playground-container .progress-action-item .progress-status-icon.error {
158
+ color: #ff4d4f;
159
+ font-weight: bold;
160
+ }
161
+
162
+ .playground-container .progress-description {
163
+ color: #000;
164
+ padding: 8px 0;
165
+ font-size: 14px;
166
+ line-height: 22px;
167
+ display: inline-block;
168
+ }
169
+
170
+ .playground-container .system-message-container {
171
+ flex-direction: column;
172
+ display: flex;
173
+ }
174
+
175
+ .playground-container .system-message-container .system-message-header {
176
+ align-items: center;
177
+ gap: 8px;
178
+ margin: 12px 0;
179
+ display: flex;
180
+ }
181
+
182
+ .playground-container .system-message-container .system-message-header .system-message-title {
183
+ font-size: 12px;
184
+ font-weight: 400;
185
+ line-height: 100%;
186
+ }
187
+
188
+ .playground-container .system-message-container .system-message-content {
189
+ color: rgba(0, 0, 0, .85);
190
+ font-size: 14px;
191
+ }
192
+
193
+ .playground-container .system-message-container .system-message-content .system-message-text {
194
+ color: rgba(0, 0, 0, .85);
195
+ font-size: 14px;
196
+ line-height: 25px;
197
+ }
198
+
199
+ .playground-container .system-message-container .system-message-content .error-message {
200
+ color: #e51723;
201
+ word-break: break-word;
202
+ background-color: #fff;
203
+ border: none;
204
+ border-radius: 0;
205
+ align-items: flex-start;
206
+ margin-bottom: 16px;
207
+ padding: 0;
208
+ font-size: 14px;
209
+ display: flex;
210
+ }
211
+
212
+ .playground-container .system-message-container .system-message-content .error-message .divider {
213
+ background-color: #e6e8eb;
214
+ flex-shrink: 0;
215
+ align-self: stretch;
216
+ width: 1px;
217
+ min-height: 20px;
218
+ margin: 0 8px 0 0;
219
+ }
220
+
221
+ .playground-container .system-message-container .system-message-content .loading-progress-text {
222
+ color: #666;
223
+ background: #f6f8fa;
224
+ border-left: 3px solid #1890ff;
225
+ border-radius: 4px;
226
+ margin-top: 8px;
227
+ padding: 8px 12px;
228
+ font-size: 13px;
229
+ }
230
+
231
+ .playground-container .new-conversation-separator {
232
+ flex-shrink: 0;
233
+ justify-content: center;
234
+ align-items: center;
235
+ padding: 20px 0;
236
+ display: flex;
237
+ position: relative;
238
+ }
239
+
240
+ .playground-container .new-conversation-separator .separator-line {
241
+ background-color: #e8e8e8;
242
+ height: 1px;
243
+ position: absolute;
244
+ top: 50%;
245
+ left: 0;
246
+ right: 0;
247
+ }
248
+
249
+ .playground-container .new-conversation-separator .separator-text-container {
250
+ z-index: 1;
251
+ background-color: #fff;
252
+ padding: 0 16px;
253
+ position: relative;
254
+ }
255
+
256
+ .playground-container .new-conversation-separator .separator-text-container .separator-text {
257
+ color: #999;
258
+ background-color: #fff;
259
+ font-size: 12px;
260
+ }
261
+
262
+ .playground-container .bottom-input-section {
263
+ background-color: #fff;
264
+ flex-shrink: 0;
265
+ padding: 16px 0 0;
266
+ }
267
+
268
+ .playground-container .version-info-section {
269
+ flex-shrink: 0;
270
+ justify-content: center;
271
+ align-items: center;
272
+ height: 38px;
273
+ display: flex;
274
+ }
275
+
276
+ .playground-container .version-text {
277
+ color: #999;
278
+ text-align: center;
279
+ font-size: 12px;
280
+ }
281
+
282
+ .playground-container .hidden-result-ref {
283
+ display: none;
284
+ }
285
+
286
+ .playground-container .playground-description {
287
+ margin-bottom: 32px;
288
+ }
289
+
290
+ .playground-container .playground-description .description-zh {
291
+ color: #333;
292
+ margin: 0 0 8px;
293
+ font-size: 16px;
294
+ line-height: 1.5;
295
+ }
296
+
297
+ .playground-container .playground-description .description-en {
298
+ color: #666;
299
+ margin: 0;
300
+ font-size: 14px;
301
+ line-height: 1.5;
302
+ }
303
+
304
+ .playground-container .config-section {
305
+ margin-bottom: 24px;
306
+ }
307
+
308
+ .playground-container .config-section .config-title {
309
+ color: #333;
310
+ margin: 0 0 16px;
311
+ font-size: 18px;
312
+ font-weight: 600;
313
+ }
314
+
315
+ .playground-container .config-section .config-item {
316
+ align-items: center;
317
+ gap: 8px;
318
+ margin-bottom: 12px;
319
+ display: flex;
320
+ }
321
+
322
+ .playground-container .config-section .config-item .config-check {
323
+ color: #52c41a;
324
+ font-size: 16px;
325
+ }
326
+
327
+ .playground-container .config-section .config-item .config-label {
328
+ color: #333;
329
+ font-size: 14px;
330
+ }
331
+
332
+ .playground-container .config-section .config-link {
333
+ color: #1890ff;
334
+ font-size: 14px;
335
+ text-decoration: none;
336
+ }
337
+
338
+ .playground-container .config-section .config-link:hover {
339
+ text-decoration: underline;
340
+ }
341
+
@@ -0,0 +1,273 @@
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 } 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 "./index.css";
11
+ import avatar from "../../icons/avatar.mjs";
12
+ import { PromptInput } from "../prompt-input/index.mjs";
13
+ const { Text } = Typography;
14
+ function ErrorMessage(param) {
15
+ let { error } = param;
16
+ if (!error) return null;
17
+ return /*#__PURE__*/ jsxs(Tooltip, {
18
+ title: /*#__PURE__*/ jsx("span", {
19
+ style: {
20
+ whiteSpace: 'pre-wrap',
21
+ wordBreak: 'break-all'
22
+ },
23
+ children: error
24
+ }),
25
+ overlayStyle: {
26
+ maxWidth: '100vw'
27
+ },
28
+ children: [
29
+ "Error: ",
30
+ error.split('\n')[0]
31
+ ]
32
+ });
33
+ }
34
+ function UniversalPlayground(param) {
35
+ let { playgroundSDK, storage, contextProvider, config: componentConfig = {}, branding = {}, className = '', dryMode = false, showContextPreview = true } = param;
36
+ const [form] = Form.useForm();
37
+ const { deepThink, screenshotIncluded, domIncluded, config } = useEnvConfig();
38
+ const { loading, setLoading, infoList, setInfoList, actionSpace, actionSpaceLoading, uiContextPreview, setUiContextPreview, showScrollToBottomButton, verticalMode, replayCounter, setReplayCounter, infoListRef, currentRunningIdRef, interruptedFlagRef, clearInfoList, refreshContext, handleScrollToBottom } = usePlaygroundState(playgroundSDK, storage, contextProvider);
39
+ const { handleRun: executeAction, handleStop, canStop } = usePlaygroundExecution(playgroundSDK, storage, actionSpace, loading, setLoading, infoList, setInfoList, replayCounter, setReplayCounter, verticalMode, currentRunningIdRef, interruptedFlagRef);
40
+ useEffect(()=>{
41
+ const completeConfig = {
42
+ ...config,
43
+ deepThink,
44
+ screenshotIncluded,
45
+ domIncluded
46
+ };
47
+ if (playgroundSDK.overrideConfig) playgroundSDK.overrideConfig(completeConfig).catch((error)=>{
48
+ console.error('Failed to override SDK config:', error);
49
+ });
50
+ }, [
51
+ playgroundSDK,
52
+ config,
53
+ deepThink,
54
+ screenshotIncluded,
55
+ domIncluded
56
+ ]);
57
+ const handleFormRun = useCallback(async ()=>{
58
+ try {
59
+ const value = form.getFieldsValue();
60
+ await executeAction(value);
61
+ } catch (error) {
62
+ message.error((null == error ? void 0 : error.message) || 'Execution failed');
63
+ }
64
+ }, [
65
+ form,
66
+ executeAction
67
+ ]);
68
+ const runButtonEnabled = !dryMode && !actionSpaceLoading;
69
+ const selectedType = Form.useWatch('type', form);
70
+ const finalShowContextPreview = showContextPreview && false !== componentConfig.showContextPreview;
71
+ const enablePersistence = false !== componentConfig.enablePersistence;
72
+ const layout = componentConfig.layout || 'vertical';
73
+ const showVersionInfo = false !== componentConfig.showVersionInfo;
74
+ return /*#__PURE__*/ jsx("div", {
75
+ className: `playground-container ${layout}-mode ${className}`.trim(),
76
+ children: /*#__PURE__*/ jsxs(Form, {
77
+ form: form,
78
+ onFinish: handleFormRun,
79
+ className: "command-form",
80
+ children: [
81
+ finalShowContextPreview && /*#__PURE__*/ jsx("div", {
82
+ className: "context-preview-section",
83
+ children: /*#__PURE__*/ jsx(ContextPreview, {
84
+ uiContextPreview: uiContextPreview,
85
+ setUiContextPreview: setUiContextPreview,
86
+ showContextPreview: finalShowContextPreview
87
+ })
88
+ }),
89
+ /*#__PURE__*/ jsxs("div", {
90
+ className: "middle-dialog-area",
91
+ children: [
92
+ infoList.length > 1 && enablePersistence && /*#__PURE__*/ jsx("div", {
93
+ className: "clear-button-container",
94
+ children: /*#__PURE__*/ jsx(Button, {
95
+ size: "small",
96
+ icon: /*#__PURE__*/ jsx(ClearOutlined, {}),
97
+ onClick: clearInfoList,
98
+ type: "text",
99
+ className: "clear-button"
100
+ })
101
+ }),
102
+ /*#__PURE__*/ jsx("div", {
103
+ ref: infoListRef,
104
+ className: "info-list-container",
105
+ children: /*#__PURE__*/ jsx(List, {
106
+ itemLayout: "vertical",
107
+ dataSource: infoList,
108
+ renderItem: (item)=>{
109
+ var _item_result;
110
+ return /*#__PURE__*/ jsx(List.Item, {
111
+ className: "list-item",
112
+ children: 'user' === item.type ? /*#__PURE__*/ jsx("div", {
113
+ className: "user-message-container",
114
+ children: /*#__PURE__*/ jsx("div", {
115
+ className: "user-message-bubble",
116
+ children: item.content
117
+ })
118
+ }) : 'progress' === item.type ? /*#__PURE__*/ jsx("div", {
119
+ children: (()=>{
120
+ var _parts_, _item_result, _item_result1, _item_result2;
121
+ const parts = item.content.split(' - ');
122
+ const action = null == (_parts_ = parts[0]) ? void 0 : _parts_.trim();
123
+ const description = parts.slice(1).join(' - ').trim();
124
+ const currentIndex = infoList.findIndex((listItem)=>listItem.id === item.id);
125
+ const laterProgressExists = infoList.slice(currentIndex + 1).some((listItem)=>'progress' === listItem.type);
126
+ const isLatestProgress = !laterProgressExists;
127
+ const shouldShowLoading = loading && isLatestProgress;
128
+ return /*#__PURE__*/ jsxs(Fragment, {
129
+ children: [
130
+ action && /*#__PURE__*/ jsxs("span", {
131
+ className: "progress-action-item",
132
+ children: [
133
+ action,
134
+ /*#__PURE__*/ jsx("span", {
135
+ className: `progress-status-icon ${shouldShowLoading ? 'loading' : (null == (_item_result = item.result) ? void 0 : _item_result.error) ? 'error' : 'completed'}`,
136
+ children: shouldShowLoading ? /*#__PURE__*/ jsx(LoadingOutlined, {
137
+ spin: true
138
+ }) : (null == (_item_result1 = item.result) ? void 0 : _item_result1.error) ? "\u2717" : "\u2713"
139
+ })
140
+ ]
141
+ }),
142
+ description && /*#__PURE__*/ jsx("div", {
143
+ children: /*#__PURE__*/ jsx("span", {
144
+ className: "progress-description",
145
+ children: description
146
+ })
147
+ }),
148
+ (null == (_item_result2 = item.result) ? void 0 : _item_result2.error) && /*#__PURE__*/ jsx(ErrorMessage, {
149
+ error: item.result.error
150
+ })
151
+ ]
152
+ });
153
+ })()
154
+ }) : 'separator' === item.type ? /*#__PURE__*/ jsxs("div", {
155
+ className: "new-conversation-separator",
156
+ children: [
157
+ /*#__PURE__*/ jsx("div", {
158
+ className: "separator-line"
159
+ }),
160
+ /*#__PURE__*/ jsx("div", {
161
+ className: "separator-text-container",
162
+ children: /*#__PURE__*/ jsx(Text, {
163
+ type: "secondary",
164
+ className: "separator-text",
165
+ children: item.content
166
+ })
167
+ })
168
+ ]
169
+ }) : /*#__PURE__*/ jsxs("div", {
170
+ className: "system-message-container",
171
+ children: [
172
+ /*#__PURE__*/ jsxs("div", {
173
+ className: "system-message-header",
174
+ children: [
175
+ /*#__PURE__*/ jsx(icons, {
176
+ component: branding.icon || avatar,
177
+ style: {
178
+ fontSize: 20
179
+ }
180
+ }),
181
+ /*#__PURE__*/ jsx("span", {
182
+ className: "system-message-title",
183
+ children: branding.title || 'Playground'
184
+ })
185
+ ]
186
+ }),
187
+ (item.content || item.result) && /*#__PURE__*/ jsxs("div", {
188
+ className: "system-message-content",
189
+ children: [
190
+ 'result' === item.type && (null == (_item_result = item.result) ? void 0 : _item_result.error) && /*#__PURE__*/ jsxs("div", {
191
+ className: "error-message",
192
+ children: [
193
+ /*#__PURE__*/ jsx("div", {
194
+ className: "divider"
195
+ }),
196
+ /*#__PURE__*/ jsx(ErrorMessage, {
197
+ error: item.result.error
198
+ })
199
+ ]
200
+ }),
201
+ 'result' === item.type ? /*#__PURE__*/ jsx(PlaygroundResultView, {
202
+ result: item.result || null,
203
+ loading: item.loading || false,
204
+ serverValid: true,
205
+ serviceMode: 'Server',
206
+ replayScriptsInfo: item.replayScriptsInfo || null,
207
+ replayCounter: item.replayCounter || 0,
208
+ loadingProgressText: item.loadingProgressText || '',
209
+ verticalMode: item.verticalMode || false,
210
+ fitMode: "width"
211
+ }) : /*#__PURE__*/ jsxs(Fragment, {
212
+ children: [
213
+ /*#__PURE__*/ jsx("div", {
214
+ className: "system-message-text",
215
+ children: item.content
216
+ }),
217
+ item.loading && item.loadingProgressText && /*#__PURE__*/ jsx("div", {
218
+ className: "loading-progress-text",
219
+ children: /*#__PURE__*/ jsx("span", {
220
+ children: item.loadingProgressText
221
+ })
222
+ })
223
+ ]
224
+ })
225
+ ]
226
+ })
227
+ ]
228
+ })
229
+ }, item.id);
230
+ }
231
+ })
232
+ }),
233
+ showScrollToBottomButton && false !== componentConfig.enableScrollToBottom && /*#__PURE__*/ jsx(Button, {
234
+ className: "scroll-to-bottom-button",
235
+ type: "primary",
236
+ shape: "circle",
237
+ icon: /*#__PURE__*/ jsx(ArrowDownOutlined, {}),
238
+ onClick: handleScrollToBottom,
239
+ size: "large"
240
+ })
241
+ ]
242
+ }),
243
+ /*#__PURE__*/ jsx("div", {
244
+ className: "bottom-input-section",
245
+ children: /*#__PURE__*/ jsx(PromptInput, {
246
+ runButtonEnabled: runButtonEnabled,
247
+ form: form,
248
+ serviceMode: 'Server',
249
+ selectedType: selectedType,
250
+ dryMode: dryMode,
251
+ stoppable: canStop,
252
+ loading: loading,
253
+ onRun: handleFormRun,
254
+ onStop: handleStop,
255
+ actionSpace: actionSpace
256
+ })
257
+ }),
258
+ showVersionInfo && branding.version && /*#__PURE__*/ jsx("div", {
259
+ className: "version-info-section",
260
+ children: /*#__PURE__*/ jsxs("span", {
261
+ className: "version-text",
262
+ children: [
263
+ "Midscene.js version: ",
264
+ branding.version
265
+ ]
266
+ })
267
+ })
268
+ ]
269
+ })
270
+ });
271
+ }
272
+ const universal_playground = UniversalPlayground;
273
+ 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 };