@midscene/visualizer 0.30.10 → 1.0.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 (123) hide show
  1. package/dist/es/component/blackboard/index.css +8 -0
  2. package/dist/es/component/blackboard/index.mjs +137 -68
  3. package/dist/es/component/config-selector/index.mjs +102 -4
  4. package/dist/es/component/context-preview/index.mjs +1 -2
  5. package/dist/es/component/env-config/index.mjs +1 -2
  6. package/dist/es/component/env-config-reminder/index.css +8 -0
  7. package/dist/es/component/env-config-reminder/index.mjs +1 -2
  8. package/dist/es/component/form-field/index.mjs +5 -10
  9. package/dist/es/component/history-selector/index.css +38 -1
  10. package/dist/es/component/history-selector/index.mjs +1 -2
  11. package/dist/es/component/logo/index.mjs +7 -3
  12. package/dist/es/component/misc/index.mjs +1 -4
  13. package/dist/es/component/nav-actions/index.mjs +1 -2
  14. package/dist/es/component/nav-actions/style.css +1 -1
  15. package/dist/es/component/player/index.css +26 -0
  16. package/dist/es/component/player/index.mjs +376 -364
  17. package/dist/es/component/playground/index.css +291 -31
  18. package/dist/es/component/playground-result/index.css +10 -0
  19. package/dist/es/component/playground-result/index.mjs +129 -10
  20. package/dist/es/component/prompt-input/index.css +281 -31
  21. package/dist/es/component/prompt-input/index.mjs +83 -25
  22. package/dist/es/component/screenshot-viewer/index.css +214 -0
  23. package/dist/es/component/screenshot-viewer/index.mjs +282 -0
  24. package/dist/es/component/service-mode-control/index.mjs +1 -2
  25. package/dist/es/component/shiny-text/index.css +35 -3
  26. package/dist/es/component/shiny-text/index.mjs +3 -3
  27. package/dist/es/component/universal-playground/index.css +61 -1
  28. package/dist/es/component/universal-playground/index.mjs +106 -83
  29. package/dist/es/component/universal-playground/providers/context-provider.mjs +56 -18
  30. package/dist/es/component/universal-playground/providers/indexeddb-storage-provider.mjs +213 -139
  31. package/dist/es/component/universal-playground/providers/storage-provider.mjs +199 -121
  32. package/dist/es/hooks/usePlaygroundExecution.mjs +297 -146
  33. package/dist/es/hooks/usePlaygroundState.mjs +141 -75
  34. package/dist/es/hooks/useSafeOverrideAIConfig.mjs +2 -6
  35. package/dist/es/hooks/useServerValid.mjs +37 -12
  36. package/dist/es/hooks/useTheme.mjs +25 -0
  37. package/dist/es/icons/avatar.mjs +46 -4
  38. package/dist/es/icons/close.mjs +46 -4
  39. package/dist/es/icons/global-perspective.mjs +47 -5
  40. package/dist/es/icons/history.mjs +48 -6
  41. package/dist/es/icons/magnifying-glass.mjs +47 -5
  42. package/dist/es/icons/player-setting.mjs +48 -6
  43. package/dist/es/icons/setting.mjs +47 -5
  44. package/dist/es/icons/show-marker.mjs +47 -5
  45. package/dist/es/index.mjs +4 -4
  46. package/dist/es/store/history.mjs +46 -7
  47. package/dist/es/store/store.mjs +68 -2
  48. package/dist/es/types.mjs +1 -1
  49. package/dist/es/utils/constants.mjs +7 -3
  50. package/dist/es/utils/index.mjs +4 -1
  51. package/dist/es/utils/pixi-loader.mjs +37 -11
  52. package/dist/es/utils/replay-scripts.mjs +160 -111
  53. package/dist/lib/component/blackboard/index.css +8 -0
  54. package/dist/lib/component/blackboard/index.js +139 -70
  55. package/dist/lib/component/config-selector/index.js +103 -5
  56. package/dist/lib/component/context-preview/index.js +3 -4
  57. package/dist/lib/component/env-config/index.js +3 -4
  58. package/dist/lib/component/env-config-reminder/index.css +8 -0
  59. package/dist/lib/component/env-config-reminder/index.js +3 -4
  60. package/dist/lib/component/form-field/index.js +10 -15
  61. package/dist/lib/component/history-selector/index.css +38 -1
  62. package/dist/lib/component/history-selector/index.js +3 -4
  63. package/dist/lib/component/index.js +6 -8
  64. package/dist/lib/component/logo/index.js +9 -5
  65. package/dist/lib/component/misc/index.js +6 -9
  66. package/dist/lib/component/nav-actions/index.js +3 -4
  67. package/dist/lib/component/nav-actions/style.css +1 -1
  68. package/dist/lib/component/player/index.css +26 -0
  69. package/dist/lib/component/player/index.js +376 -365
  70. package/dist/lib/component/playground/index.css +291 -31
  71. package/dist/lib/component/playground/index.js +31 -33
  72. package/dist/lib/component/playground-result/index.css +10 -0
  73. package/dist/lib/component/playground-result/index.js +131 -12
  74. package/dist/lib/component/prompt-input/index.css +281 -31
  75. package/dist/lib/component/prompt-input/index.js +84 -26
  76. package/dist/lib/component/screenshot-viewer/index.css +214 -0
  77. package/dist/lib/component/screenshot-viewer/index.js +316 -0
  78. package/dist/lib/component/service-mode-control/index.js +3 -4
  79. package/dist/lib/component/shiny-text/index.css +35 -3
  80. package/dist/lib/component/shiny-text/index.js +5 -5
  81. package/dist/lib/component/universal-playground/index.css +61 -1
  82. package/dist/lib/component/universal-playground/index.js +108 -84
  83. package/dist/lib/component/universal-playground/providers/context-provider.js +58 -20
  84. package/dist/lib/component/universal-playground/providers/indexeddb-storage-provider.js +217 -143
  85. package/dist/lib/component/universal-playground/providers/storage-provider.js +207 -129
  86. package/dist/lib/hooks/usePlaygroundExecution.js +299 -148
  87. package/dist/lib/hooks/usePlaygroundState.js +143 -77
  88. package/dist/lib/hooks/useSafeOverrideAIConfig.js +4 -8
  89. package/dist/lib/hooks/useServerValid.js +39 -14
  90. package/dist/lib/hooks/useTheme.js +59 -0
  91. package/dist/lib/icons/avatar.js +48 -6
  92. package/dist/lib/icons/close.js +48 -6
  93. package/dist/lib/icons/global-perspective.js +49 -7
  94. package/dist/lib/icons/history.js +50 -8
  95. package/dist/lib/icons/magnifying-glass.js +49 -7
  96. package/dist/lib/icons/player-setting.js +50 -8
  97. package/dist/lib/icons/setting.js +49 -7
  98. package/dist/lib/icons/show-marker.js +49 -7
  99. package/dist/lib/index.js +44 -34
  100. package/dist/lib/store/history.js +48 -9
  101. package/dist/lib/store/store.js +74 -8
  102. package/dist/lib/types.js +3 -3
  103. package/dist/lib/utils/color.js +2 -2
  104. package/dist/lib/utils/constants.js +20 -4
  105. package/dist/lib/utils/index.js +10 -4
  106. package/dist/lib/utils/pixi-loader.js +41 -15
  107. package/dist/lib/utils/playground-utils.js +4 -4
  108. package/dist/lib/utils/replay-scripts.js +164 -115
  109. package/dist/types/component/config-selector/index.d.ts +2 -0
  110. package/dist/types/component/player/index.d.ts +0 -1
  111. package/dist/types/component/playground-result/index.d.ts +1 -0
  112. package/dist/types/component/prompt-input/index.d.ts +2 -1
  113. package/dist/types/component/screenshot-viewer/index.d.ts +15 -0
  114. package/dist/types/hooks/usePlaygroundExecution.d.ts +1 -1
  115. package/dist/types/hooks/usePlaygroundState.d.ts +3 -3
  116. package/dist/types/hooks/useTheme.d.ts +7 -0
  117. package/dist/types/index.d.ts +3 -3
  118. package/dist/types/store/store.d.ts +18 -1
  119. package/dist/types/types.d.ts +14 -4
  120. package/dist/types/utils/constants.d.ts +5 -1
  121. package/dist/types/utils/index.d.ts +1 -0
  122. package/dist/types/utils/replay-scripts.d.ts +1 -1
  123. package/package.json +12 -22
@@ -1,5 +1,5 @@
1
- 'use client';
2
1
  "use strict";
2
+ "use client";
3
3
  var __webpack_require__ = {};
4
4
  (()=>{
5
5
  __webpack_require__.d = (exports1, definition)=>{
@@ -25,20 +25,62 @@ var __webpack_require__ = {};
25
25
  var __webpack_exports__ = {};
26
26
  __webpack_require__.r(__webpack_exports__);
27
27
  __webpack_require__.d(__webpack_exports__, {
28
- cameraStateForRect: ()=>cameraStateForRect,
29
- mergeTwoCameraState: ()=>mergeTwoCameraState,
30
28
  generateAnimationScripts: ()=>generateAnimationScripts,
29
+ mergeTwoCameraState: ()=>mergeTwoCameraState,
30
+ cameraStateForRect: ()=>cameraStateForRect,
31
31
  allScriptsFromDump: ()=>allScriptsFromDump
32
32
  });
33
33
  const external_index_js_namespaceObject = require("./index.js");
34
34
  const agent_namespaceObject = require("@midscene/core/agent");
35
- const extractor_namespaceObject = require("@midscene/shared/extractor");
35
+ function _define_property(obj, key, value) {
36
+ if (key in obj) Object.defineProperty(obj, key, {
37
+ value: value,
38
+ enumerable: true,
39
+ configurable: true,
40
+ writable: true
41
+ });
42
+ else obj[key] = value;
43
+ return obj;
44
+ }
45
+ function _object_spread(target) {
46
+ for(var i = 1; i < arguments.length; i++){
47
+ var source = null != arguments[i] ? arguments[i] : {};
48
+ var ownKeys = Object.keys(source);
49
+ if ("function" == typeof Object.getOwnPropertySymbols) ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
50
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
51
+ }));
52
+ ownKeys.forEach(function(key) {
53
+ _define_property(target, key, source[key]);
54
+ });
55
+ }
56
+ return target;
57
+ }
58
+ function replay_scripts_ownKeys(object, enumerableOnly) {
59
+ var keys = Object.keys(object);
60
+ if (Object.getOwnPropertySymbols) {
61
+ var symbols = Object.getOwnPropertySymbols(object);
62
+ if (enumerableOnly) symbols = symbols.filter(function(sym) {
63
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
64
+ });
65
+ keys.push.apply(keys, symbols);
66
+ }
67
+ return keys;
68
+ }
69
+ function _object_spread_props(target, source) {
70
+ source = null != source ? source : {};
71
+ if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
72
+ else replay_scripts_ownKeys(Object(source)).forEach(function(key) {
73
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
74
+ });
75
+ return target;
76
+ }
36
77
  const stillDuration = 900;
37
78
  const actionSpinningPointerDuration = 300;
38
79
  const stillAfterInsightDuration = 300;
39
80
  const locateDuration = 800;
40
- const actionDuration = 1000;
81
+ const actionDuration = 500;
41
82
  const clearInsightDuration = 200;
83
+ const lastFrameDuration = 200;
42
84
  const cameraStateForRect = (rect, imageWidth, imageHeight)=>{
43
85
  const canvasRatio = imageWidth / imageHeight;
44
86
  const rectRatio = rect.width / rect.height;
@@ -68,17 +110,29 @@ const mergeTwoCameraState = (cameraState1, cameraState2)=>{
68
110
  width: newWidth
69
111
  };
70
112
  };
71
- const capitalizeFirstLetter = (str)=>{
72
- if ('string' != typeof str || 0 === str.length) return str;
73
- return str.charAt(0).toUpperCase() + str.slice(1);
74
- };
75
113
  const allScriptsFromDump = (dump)=>{
114
+ var _normalizedDump_executions, _normalizedDump_executions1, _normalizedDump_modelBriefs;
115
+ if (!dump) {
116
+ console.warn('[allScriptsFromDump] dump is empty');
117
+ return {
118
+ scripts: [],
119
+ modelBriefs: []
120
+ };
121
+ }
122
+ const normalizedDump = Array.isArray(dump.executions) ? dump : {
123
+ sdkVersion: '',
124
+ groupName: 'Execution',
125
+ modelBriefs: [],
126
+ executions: [
127
+ dump
128
+ ]
129
+ };
76
130
  const dimensionsSet = new Set();
77
131
  let firstWidth;
78
132
  let firstHeight;
79
- const sdkVersion = dump.sdkVersion;
133
+ const sdkVersion = normalizedDump.sdkVersion;
80
134
  const modelBriefsSet = new Set();
81
- dump.executions.forEach((execution)=>{
135
+ null == (_normalizedDump_executions = normalizedDump.executions) || _normalizedDump_executions.filter(Boolean).forEach((execution)=>{
82
136
  execution.tasks.forEach((task)=>{
83
137
  var _task_uiContext_size, _task_uiContext;
84
138
  if (null == (_task_uiContext = task.uiContext) ? void 0 : null == (_task_uiContext_size = _task_uiContext.size) ? void 0 : _task_uiContext_size.width) {
@@ -101,13 +155,13 @@ const allScriptsFromDump = (dump)=>{
101
155
  };
102
156
  }
103
157
  const allScripts = [];
104
- dump.executions.forEach((execution)=>{
158
+ null == (_normalizedDump_executions1 = normalizedDump.executions) || _normalizedDump_executions1.filter(Boolean).forEach((execution)=>{
105
159
  const scripts = generateAnimationScripts(execution, -1, firstWidth, firstHeight);
106
160
  if (scripts) allScripts.push(...scripts);
107
161
  execution.tasks.forEach((task)=>{
108
162
  if (task.usage) {
109
163
  const { model_name, model_description, intent } = task.usage;
110
- if (intent && model_name) modelBriefsSet.add(model_description ? `${capitalizeFirstLetter(intent)}/${model_name}(${model_description})` : model_name);
164
+ if (intent && model_name) modelBriefsSet.add(model_description ? `${intent}/${model_name}(${model_description})` : `${intent}/${model_name}`);
111
165
  }
112
166
  });
113
167
  });
@@ -115,9 +169,10 @@ const allScriptsFromDump = (dump)=>{
115
169
  if (index !== allScripts.length - 1 && 'Done' === script.title) return false;
116
170
  return true;
117
171
  });
172
+ const normalizedModelBriefs = (null == (_normalizedDump_modelBriefs = normalizedDump.modelBriefs) ? void 0 : _normalizedDump_modelBriefs.length) ? normalizedDump.modelBriefs : [];
118
173
  const modelBriefs = (()=>{
119
174
  var _list_;
120
- const list = [
175
+ const list = normalizedModelBriefs.length ? normalizedModelBriefs : [
121
176
  ...modelBriefsSet
122
177
  ];
123
178
  if (!list.length) return list;
@@ -159,7 +214,7 @@ const generateAnimationScripts = (execution, task, imageWidth, imageHeight)=>{
159
214
  width: imageWidth,
160
215
  height: imageHeight
161
216
  }, imageWidth, imageHeight);
162
- const pointerScript = (img, title, subTitle)=>({
217
+ const setPointerScript = (img, title, subTitle)=>({
163
218
  type: 'pointer',
164
219
  img,
165
220
  duration: 0,
@@ -168,22 +223,88 @@ const generateAnimationScripts = (execution, task, imageWidth, imageHeight)=>{
168
223
  });
169
224
  const scripts = [];
170
225
  let insightCameraState;
171
- let currentCameraState = fullPageCameraState;
172
226
  let insightOnTop = false;
173
- const taskCount = tasksIncluded.length;
227
+ tasksIncluded.length;
174
228
  let initSubTitle = '';
175
229
  let errorStateFlag = false;
176
230
  tasksIncluded.forEach((task, index)=>{
177
231
  if (errorStateFlag) return;
178
232
  if (0 === index) initSubTitle = (0, agent_namespaceObject.paramStr)(task);
179
233
  if ('Planning' === task.type) {
234
+ var _task_output;
235
+ let locateElements = [];
236
+ if ('Plan' === task.subType) {
237
+ var _planTask_output;
238
+ const planTask = task;
239
+ const actions = (null == (_planTask_output = planTask.output) ? void 0 : _planTask_output.actions) || [];
240
+ if (actions.length > 0) {
241
+ const action = actions[0];
242
+ const knownFields = [
243
+ 'locate',
244
+ 'start',
245
+ 'end'
246
+ ];
247
+ if (action.param) {
248
+ knownFields.forEach((field)=>{
249
+ if (action.param[field] && 'object' == typeof action.param[field] && 'center' in (action.param[field] || {})) locateElements.push(action.param[field]);
250
+ });
251
+ for(const key in action.param)if (!knownFields.includes(key)) {
252
+ if ('object' == typeof action.param[key] && 'center' in (action.param[key] || {})) locateElements.push(action.param[key]);
253
+ }
254
+ }
255
+ }
256
+ } else if ('Locate' === task.subType && (null == (_task_output = task.output) ? void 0 : _task_output.element)) {
257
+ const locateTask = task;
258
+ locateElements = [
259
+ locateTask.output.element
260
+ ];
261
+ }
262
+ const title = (0, agent_namespaceObject.typeStr)(task);
263
+ const subTitle = (0, agent_namespaceObject.paramStr)(task);
264
+ const context = task.uiContext;
265
+ if (null == context ? void 0 : context.screenshotBase64) {
266
+ var _context_size, _context_size1;
267
+ const width = (null == (_context_size = context.size) ? void 0 : _context_size.width) || imageWidth;
268
+ const height = (null == (_context_size1 = context.size) ? void 0 : _context_size1.height) || imageHeight;
269
+ scripts.push({
270
+ type: 'img',
271
+ img: context.screenshotBase64,
272
+ duration: stillAfterInsightDuration,
273
+ title,
274
+ subTitle,
275
+ imageWidth: width,
276
+ imageHeight: height
277
+ });
278
+ locateElements.forEach((element)=>{
279
+ var _task_log_taskInfo, _task_log, _context_size, _context_size1;
280
+ insightCameraState = _object_spread_props(_object_spread({}, cameraStateForRect(element.rect, width, height)), {
281
+ pointerLeft: element.center[0],
282
+ pointerTop: element.center[1]
283
+ });
284
+ const newCameraState = insightCameraState;
285
+ scripts.push({
286
+ type: 'insight',
287
+ img: context.screenshotBase64,
288
+ context: context,
289
+ camera: newCameraState,
290
+ highlightElement: element,
291
+ searchArea: null == (_task_log = task.log) ? void 0 : null == (_task_log_taskInfo = _task_log.taskInfo) ? void 0 : _task_log_taskInfo.searchArea,
292
+ duration: 0.5 * locateDuration,
293
+ insightCameraDuration: locateDuration,
294
+ title,
295
+ subTitle: element.description || subTitle,
296
+ imageWidth: (null == (_context_size = context.size) ? void 0 : _context_size.width) || imageWidth,
297
+ imageHeight: (null == (_context_size1 = context.size) ? void 0 : _context_size1.height) || imageHeight
298
+ });
299
+ insightOnTop = true;
300
+ });
301
+ }
180
302
  const planningTask = task;
181
303
  if (planningTask.recorder && planningTask.recorder.length > 0) {
182
304
  var _planningTask_recorder_, _planningTask_recorder, _task_uiContext_size, _task_uiContext, _task_uiContext_size1, _task_uiContext1;
183
305
  scripts.push({
184
306
  type: 'img',
185
307
  img: null == (_planningTask_recorder = planningTask.recorder) ? void 0 : null == (_planningTask_recorder_ = _planningTask_recorder[0]) ? void 0 : _planningTask_recorder_.screenshot,
186
- camera: 0 === index ? fullPageCameraState : void 0,
187
308
  duration: stillDuration,
188
309
  title: (0, agent_namespaceObject.typeStr)(task),
189
310
  subTitle: (0, agent_namespaceObject.paramStr)(task),
@@ -191,73 +312,15 @@ const generateAnimationScripts = (execution, task, imageWidth, imageHeight)=>{
191
312
  imageHeight: (null == (_task_uiContext1 = task.uiContext) ? void 0 : null == (_task_uiContext_size1 = _task_uiContext1.size) ? void 0 : _task_uiContext_size1.height) || imageHeight
192
313
  });
193
314
  }
194
- } else if ('Insight' === task.type && 'Locate' === task.subType) {
195
- var _insightTask_output;
196
- const insightTask = task;
197
- const resultElement = null == (_insightTask_output = insightTask.output) ? void 0 : _insightTask_output.element;
315
+ } else if ('Action Space' === task.type) {
316
+ var _task_recorder_, _task_recorder, _task_uiContext_size2, _task_uiContext2, _task_uiContext_size3, _task_uiContext3;
198
317
  const title = (0, agent_namespaceObject.typeStr)(task);
199
318
  const subTitle = (0, agent_namespaceObject.paramStr)(task);
200
- if (null == resultElement ? void 0 : resultElement.rect) insightCameraState = {
201
- ...cameraStateForRect(resultElement.rect, imageWidth, imageHeight),
202
- pointerLeft: resultElement.center[0],
203
- pointerTop: resultElement.center[1]
204
- };
205
- const context = insightTask.uiContext;
206
- if (null == context ? void 0 : context.screenshotBase64) {
207
- var _insightTask_output1, _insightDump_taskInfo, _context_size, _context_size1;
208
- const insightDump = insightTask.log;
209
- const insightContentLength = context.tree ? (0, extractor_namespaceObject.treeToList)(context.tree).length : 0;
210
- if (context.screenshotBase64) {
211
- var _context_size2, _context_size3;
212
- scripts.push({
213
- type: 'img',
214
- img: context.screenshotBase64,
215
- duration: stillAfterInsightDuration,
216
- title,
217
- subTitle,
218
- imageWidth: (null == (_context_size2 = context.size) ? void 0 : _context_size2.width) || imageWidth,
219
- imageHeight: (null == (_context_size3 = context.size) ? void 0 : _context_size3.height) || imageHeight
220
- });
221
- }
222
- let cameraState;
223
- cameraState = currentCameraState === fullPageCameraState ? void 0 : insightCameraState ? mergeTwoCameraState(currentCameraState, insightCameraState) : void 0;
224
- scripts.push({
225
- type: 'insight',
226
- img: context.screenshotBase64,
227
- context: context,
228
- camera: cameraState,
229
- highlightElement: (null == (_insightTask_output1 = insightTask.output) ? void 0 : _insightTask_output1.element) || void 0,
230
- searchArea: null == insightDump ? void 0 : null == (_insightDump_taskInfo = insightDump.taskInfo) ? void 0 : _insightDump_taskInfo.searchArea,
231
- duration: insightContentLength > 20 ? locateDuration : 0.5 * locateDuration,
232
- insightCameraDuration: locateDuration,
233
- title,
234
- subTitle,
235
- imageWidth: (null == (_context_size = context.size) ? void 0 : _context_size.width) || imageWidth,
236
- imageHeight: (null == (_context_size1 = context.size) ? void 0 : _context_size1.height) || imageHeight
237
- });
238
- scripts.push({
239
- type: 'sleep',
240
- duration: stillAfterInsightDuration,
241
- title,
242
- subTitle
243
- });
244
- insightOnTop = true;
245
- }
246
- } else if ('Action' === task.type && 'FalsyConditionStatement' !== task.subType) {
247
- var _task_recorder_, _task_recorder, _task_uiContext_size2, _task_uiContext2, _task_uiContext_size3, _task_uiContext3, _task_recorder_1, _task_recorder1;
248
- const title = (0, agent_namespaceObject.typeStr)(task);
249
- const subTitle = (0, agent_namespaceObject.paramStr)(task);
250
- scripts.push(pointerScript(external_index_js_namespaceObject.mousePointer, title, subTitle));
251
- currentCameraState = null != insightCameraState ? insightCameraState : fullPageCameraState;
252
319
  scripts.push({
253
- type: 'img',
254
- img: null == (_task_recorder = task.recorder) ? void 0 : null == (_task_recorder_ = _task_recorder[0]) ? void 0 : _task_recorder_.screenshot,
255
- duration: actionDuration,
256
- camera: 'Sleep' === task.subType ? fullPageCameraState : insightCameraState,
320
+ type: 'spinning-pointer',
321
+ duration: actionSpinningPointerDuration,
257
322
  title,
258
- subTitle,
259
- imageWidth: (null == (_task_uiContext2 = task.uiContext) ? void 0 : null == (_task_uiContext_size2 = _task_uiContext2.size) ? void 0 : _task_uiContext_size2.width) || imageWidth,
260
- imageHeight: (null == (_task_uiContext3 = task.uiContext) ? void 0 : null == (_task_uiContext_size3 = _task_uiContext3.size) ? void 0 : _task_uiContext_size3.height) || imageHeight
323
+ subTitle
261
324
  });
262
325
  if (insightOnTop) {
263
326
  scripts.push({
@@ -268,38 +331,24 @@ const generateAnimationScripts = (execution, task, imageWidth, imageHeight)=>{
268
331
  });
269
332
  insightOnTop = false;
270
333
  }
271
- const imgStillDuration = index < taskCount - 1 ? stillDuration : 0;
272
- if (null == (_task_recorder1 = task.recorder) ? void 0 : null == (_task_recorder_1 = _task_recorder1[1]) ? void 0 : _task_recorder_1.screenshot) {
273
- var _task_recorder_2, _task_recorder2, _task_uiContext_size4, _task_uiContext4, _task_uiContext_size5, _task_uiContext5;
274
- scripts.push({
275
- type: 'spinning-pointer',
276
- duration: actionSpinningPointerDuration,
277
- title,
278
- subTitle
279
- });
280
- scripts.push(pointerScript(external_index_js_namespaceObject.mousePointer, title, subTitle));
281
- scripts.push({
282
- type: 'img',
283
- img: null == (_task_recorder2 = task.recorder) ? void 0 : null == (_task_recorder_2 = _task_recorder2[1]) ? void 0 : _task_recorder_2.screenshot,
284
- duration: imgStillDuration,
285
- title,
286
- subTitle,
287
- imageWidth: (null == (_task_uiContext4 = task.uiContext) ? void 0 : null == (_task_uiContext_size4 = _task_uiContext4.size) ? void 0 : _task_uiContext_size4.width) || imageWidth,
288
- imageHeight: (null == (_task_uiContext5 = task.uiContext) ? void 0 : null == (_task_uiContext_size5 = _task_uiContext5.size) ? void 0 : _task_uiContext_size5.height) || imageHeight
289
- });
290
- } else scripts.push({
291
- type: 'sleep',
292
- duration: imgStillDuration,
334
+ scripts.push(setPointerScript(external_index_js_namespaceObject.mousePointer, title, subTitle));
335
+ scripts.push({
336
+ type: 'img',
337
+ img: null == (_task_recorder = task.recorder) ? void 0 : null == (_task_recorder_ = _task_recorder[0]) ? void 0 : _task_recorder_.screenshot,
338
+ duration: actionDuration,
339
+ camera: 'Sleep' === task.subType ? fullPageCameraState : void 0,
293
340
  title,
294
- subTitle
341
+ subTitle,
342
+ imageWidth: (null == (_task_uiContext2 = task.uiContext) ? void 0 : null == (_task_uiContext_size2 = _task_uiContext2.size) ? void 0 : _task_uiContext_size2.width) || imageWidth,
343
+ imageHeight: (null == (_task_uiContext3 = task.uiContext) ? void 0 : null == (_task_uiContext_size3 = _task_uiContext3.size) ? void 0 : _task_uiContext_size3.height) || imageHeight
295
344
  });
296
345
  } else {
297
- var _task_recorder_3, _task_recorder3;
346
+ var _task_recorder_1, _task_recorder1;
298
347
  const title = (0, agent_namespaceObject.typeStr)(task);
299
348
  const subTitle = (0, agent_namespaceObject.paramStr)(task);
300
- const screenshot = null == (_task_recorder3 = task.recorder) ? void 0 : null == (_task_recorder_3 = _task_recorder3[task.recorder.length - 1]) ? void 0 : _task_recorder_3.screenshot;
349
+ const screenshot = null == (_task_recorder1 = task.recorder) ? void 0 : null == (_task_recorder_1 = _task_recorder1[task.recorder.length - 1]) ? void 0 : _task_recorder_1.screenshot;
301
350
  if (screenshot) {
302
- var _task_uiContext_size6, _task_uiContext6, _task_uiContext_size7, _task_uiContext7;
351
+ var _task_uiContext_size4, _task_uiContext4, _task_uiContext_size5, _task_uiContext5;
303
352
  scripts.push({
304
353
  type: 'img',
305
354
  img: screenshot,
@@ -307,13 +356,13 @@ const generateAnimationScripts = (execution, task, imageWidth, imageHeight)=>{
307
356
  camera: fullPageCameraState,
308
357
  title,
309
358
  subTitle,
310
- imageWidth: (null == (_task_uiContext6 = task.uiContext) ? void 0 : null == (_task_uiContext_size6 = _task_uiContext6.size) ? void 0 : _task_uiContext_size6.width) || imageWidth,
311
- imageHeight: (null == (_task_uiContext7 = task.uiContext) ? void 0 : null == (_task_uiContext_size7 = _task_uiContext7.size) ? void 0 : _task_uiContext_size7.height) || imageHeight
359
+ imageWidth: (null == (_task_uiContext4 = task.uiContext) ? void 0 : null == (_task_uiContext_size4 = _task_uiContext4.size) ? void 0 : _task_uiContext_size4.width) || imageWidth,
360
+ imageHeight: (null == (_task_uiContext5 = task.uiContext) ? void 0 : null == (_task_uiContext_size5 = _task_uiContext5.size) ? void 0 : _task_uiContext_size5.height) || imageHeight
312
361
  });
313
362
  }
314
363
  }
315
364
  if ('finished' !== task.status) {
316
- var _task_uiContext_size8, _task_uiContext8, _task_uiContext_size9, _task_uiContext9;
365
+ var _task_uiContext_size6, _task_uiContext6, _task_uiContext_size7, _task_uiContext7;
317
366
  errorStateFlag = true;
318
367
  const errorTitle = (0, agent_namespaceObject.typeStr)(task);
319
368
  const errorMsg = task.errorMessage || 'unknown error';
@@ -325,8 +374,8 @@ const generateAnimationScripts = (execution, task, imageWidth, imageHeight)=>{
325
374
  duration: stillDuration,
326
375
  title: errorTitle,
327
376
  subTitle: errorSubTitle,
328
- imageWidth: (null == (_task_uiContext8 = task.uiContext) ? void 0 : null == (_task_uiContext_size8 = _task_uiContext8.size) ? void 0 : _task_uiContext_size8.width) || imageWidth,
329
- imageHeight: (null == (_task_uiContext9 = task.uiContext) ? void 0 : null == (_task_uiContext_size9 = _task_uiContext9.size) ? void 0 : _task_uiContext_size9.height) || imageHeight
377
+ imageWidth: (null == (_task_uiContext6 = task.uiContext) ? void 0 : null == (_task_uiContext_size6 = _task_uiContext6.size) ? void 0 : _task_uiContext_size6.width) || imageWidth,
378
+ imageHeight: (null == (_task_uiContext7 = task.uiContext) ? void 0 : null == (_task_uiContext_size7 = _task_uiContext7.size) ? void 0 : _task_uiContext_size7.height) || imageHeight
330
379
  });
331
380
  return;
332
381
  }
@@ -335,7 +384,7 @@ const generateAnimationScripts = (execution, task, imageWidth, imageHeight)=>{
335
384
  title: 'Done',
336
385
  subTitle: initSubTitle,
337
386
  type: 'img',
338
- duration: stillDuration,
387
+ duration: lastFrameDuration,
339
388
  camera: fullPageCameraState
340
389
  });
341
390
  return scripts;
@@ -344,12 +393,12 @@ exports.allScriptsFromDump = __webpack_exports__.allScriptsFromDump;
344
393
  exports.cameraStateForRect = __webpack_exports__.cameraStateForRect;
345
394
  exports.generateAnimationScripts = __webpack_exports__.generateAnimationScripts;
346
395
  exports.mergeTwoCameraState = __webpack_exports__.mergeTwoCameraState;
347
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
396
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
348
397
  "allScriptsFromDump",
349
398
  "cameraStateForRect",
350
399
  "generateAnimationScripts",
351
400
  "mergeTwoCameraState"
352
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
401
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
353
402
  Object.defineProperty(exports, '__esModule', {
354
403
  value: true
355
404
  });
@@ -1,9 +1,11 @@
1
1
  import type React from 'react';
2
+ import type { DeviceType } from '../../types';
2
3
  interface ConfigSelectorProps {
3
4
  showDeepThinkOption: boolean;
4
5
  enableTracking: boolean;
5
6
  showDataExtractionOptions: boolean;
6
7
  hideDomAndScreenshotOptions?: boolean;
8
+ deviceType?: DeviceType;
7
9
  }
8
10
  export declare const ConfigSelector: React.FC<ConfigSelectorProps>;
9
11
  export {};
@@ -9,5 +9,4 @@ export declare function Player(props?: {
9
9
  key?: string | number;
10
10
  fitMode?: 'width' | 'height';
11
11
  autoZoom?: boolean;
12
- elementsVisible?: boolean;
13
12
  }): import("react").JSX.Element;
@@ -15,6 +15,7 @@ interface PlaygroundResultProps {
15
15
  notReadyMessage?: React.ReactNode | string;
16
16
  fitMode?: 'width' | 'height';
17
17
  autoZoom?: boolean;
18
+ actionType?: string;
18
19
  }
19
20
  export declare const PlaygroundResultView: React.FC<PlaygroundResultProps>;
20
21
  export {};
@@ -1,6 +1,6 @@
1
1
  import './index.less';
2
2
  import React from 'react';
3
- import type { RunType } from '../../types';
3
+ import type { DeviceType, RunType } from '../../types';
4
4
  import type { ServiceModeType } from '../../types';
5
5
  import './index.less';
6
6
  import type { DeviceAction } from '@midscene/core';
@@ -17,6 +17,7 @@ interface PromptInputProps {
17
17
  clearPromptAfterRun?: boolean;
18
18
  hideDomAndScreenshotOptions?: boolean;
19
19
  actionSpace: DeviceAction<any>[];
20
+ deviceType?: DeviceType;
20
21
  }
21
22
  export declare const PromptInput: React.FC<PromptInputProps>;
22
23
  export {};
@@ -0,0 +1,15 @@
1
+ import './index.less';
2
+ interface ScreenshotViewerProps {
3
+ getScreenshot: () => Promise<{
4
+ screenshot: string;
5
+ timestamp: number;
6
+ } | null>;
7
+ getInterfaceInfo?: () => Promise<{
8
+ type: string;
9
+ description?: string;
10
+ } | null>;
11
+ serverOnline: boolean;
12
+ isUserOperating?: boolean;
13
+ }
14
+ export default function ScreenshotViewer({ getScreenshot, getInterfaceInfo, serverOnline, isUserOperating, }: ScreenshotViewerProps): import("react").JSX.Element;
15
+ export {};
@@ -3,7 +3,7 @@ import type { FormValue, InfoListItem, PlaygroundSDKLike, StorageProvider } from
3
3
  /**
4
4
  * Hook for handling playground execution logic
5
5
  */
6
- export declare function usePlaygroundExecution(playgroundSDK: PlaygroundSDKLike | null, storage: StorageProvider | undefined | null, actionSpace: DeviceAction<unknown>[], loading: boolean, setLoading: (loading: boolean) => void, infoList: InfoListItem[], setInfoList: React.Dispatch<React.SetStateAction<InfoListItem[]>>, replayCounter: number, setReplayCounter: React.Dispatch<React.SetStateAction<number>>, verticalMode: boolean, currentRunningIdRef: React.MutableRefObject<number | null>, interruptedFlagRef: React.MutableRefObject<Record<number, boolean>>): {
6
+ export declare function usePlaygroundExecution(playgroundSDK: PlaygroundSDKLike | null, storage: StorageProvider | undefined | null, actionSpace: DeviceAction<unknown>[], loading: boolean, setLoading: (loading: boolean) => void, setInfoList: React.Dispatch<React.SetStateAction<InfoListItem[]>>, replayCounter: number, setReplayCounter: React.Dispatch<React.SetStateAction<number>>, verticalMode: boolean, currentRunningIdRef: React.MutableRefObject<number | null>, interruptedFlagRef: React.MutableRefObject<Record<number, boolean>>): {
7
7
  handleRun: (value: FormValue) => Promise<void>;
8
8
  handleStop: () => Promise<void>;
9
9
  canStop: boolean;
@@ -8,10 +8,10 @@ export declare function usePlaygroundState(playgroundSDK: PlaygroundSDKLike | nu
8
8
  setLoading: import("react").Dispatch<import("react").SetStateAction<boolean>>;
9
9
  infoList: InfoListItem[];
10
10
  setInfoList: import("react").Dispatch<import("react").SetStateAction<InfoListItem[]>>;
11
- actionSpace: DeviceAction<unknown>[];
11
+ actionSpace: DeviceAction<unknown, any>[];
12
12
  actionSpaceLoading: boolean;
13
- uiContextPreview: UIContext<import("@midscene/core").BaseElement> | undefined;
14
- setUiContextPreview: import("react").Dispatch<import("react").SetStateAction<UIContext<import("@midscene/core").BaseElement> | undefined>>;
13
+ uiContextPreview: UIContext | undefined;
14
+ setUiContextPreview: import("react").Dispatch<import("react").SetStateAction<UIContext | undefined>>;
15
15
  showScrollToBottomButton: boolean;
16
16
  verticalMode: boolean;
17
17
  replayCounter: number;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Hook to detect and observe the current theme (light/dark mode)
3
+ * @returns Object containing isDarkMode boolean
4
+ */
5
+ export declare function useTheme(): {
6
+ isDarkMode: boolean;
7
+ };
@@ -1,7 +1,5 @@
1
- import './component/playground/index.less';
2
- import './component/universal-playground/index.less';
3
1
  export { type AnimationScript, type ReplayScriptsInfo, allScriptsFromDump, generateAnimationScripts, } from './utils/replay-scripts';
4
- export { useEnvConfig } from './store/store';
2
+ export { useEnvConfig, useGlobalPreference } from './store/store';
5
3
  export { colorForName, highlightColorForType, globalThemeConfig, } from './utils/color';
6
4
  export { EnvConfig } from './component/env-config';
7
5
  export { EnvConfigReminder } from './component/env-config-reminder';
@@ -9,6 +7,7 @@ export { NavActions } from './component/nav-actions';
9
7
  export type { NavActionsProps } from './component/nav-actions';
10
8
  export { Logo } from './component/logo';
11
9
  export { iconForStatus, timeCostStrElement } from './component/misc';
10
+ export { useTheme } from './hooks/useTheme';
12
11
  export { useServerValid } from './hooks/useServerValid';
13
12
  export { useSafeOverrideAIConfig, safeOverrideAIConfig, } from './hooks/useSafeOverrideAIConfig';
14
13
  export { PlaygroundResultView } from './component/playground-result';
@@ -18,6 +17,7 @@ export { ContextPreview } from './component/context-preview';
18
17
  export { PromptInput } from './component/prompt-input';
19
18
  export { Player } from './component/player';
20
19
  export { Blackboard } from './component/blackboard';
20
+ export { default as ScreenshotViewer } from './component/screenshot-viewer';
21
21
  export { actionNameForType, staticAgentFromContext, getPlaceholderForType, } from './utils/playground-utils';
22
22
  export { timeStr, filterBase64Value } from './utils';
23
23
  export { default as ShinyText } from './component/shiny-text';
@@ -1,11 +1,16 @@
1
1
  import * as Z from 'zustand';
2
- export declare const useBlackboardPreference: Z.UseBoundStore<Z.StoreApi<{
2
+ import type { PlanningStrategyType } from '../types';
3
+ export declare const useGlobalPreference: Z.UseBoundStore<Z.StoreApi<{
3
4
  backgroundVisible: boolean;
4
5
  elementsVisible: boolean;
5
6
  autoZoom: boolean;
7
+ modelCallDetailsEnabled: boolean;
8
+ darkModeEnabled: boolean;
6
9
  setBackgroundVisible: (visible: boolean) => void;
7
10
  setElementsVisible: (visible: boolean) => void;
8
11
  setAutoZoom: (enabled: boolean) => void;
12
+ setModelCallDetailsEnabled: (enabled: boolean) => void;
13
+ setDarkModeEnabled: (enabled: boolean) => void;
9
14
  }>>;
10
15
  /**
11
16
  * Service Mode
@@ -15,6 +20,8 @@ export declare const useBlackboardPreference: Z.UseBoundStore<Z.StoreApi<{
15
20
  * - In-Browser-Extension: use browser's fetch API to run the code, but the page is running in the extension context
16
21
  */
17
22
  export type ServiceModeType = 'Server' | 'In-Browser' | 'In-Browser-Extension';
23
+ export type ImeStrategyType = 'always-yadb' | 'yadb-for-non-ascii';
24
+ export type KeyboardDismissStrategyType = 'esc-first' | 'back-first';
18
25
  export declare const useEnvConfig: Z.UseBoundStore<Z.StoreApi<{
19
26
  serviceMode: ServiceModeType;
20
27
  setServiceMode: (serviceMode: ServiceModeType) => void;
@@ -31,6 +38,16 @@ export declare const useEnvConfig: Z.UseBoundStore<Z.StoreApi<{
31
38
  setScreenshotIncluded: (screenshotIncluded: boolean) => void;
32
39
  domIncluded: boolean | "visible-only";
33
40
  setDomIncluded: (domIncluded: boolean | "visible-only") => void;
41
+ planningStrategy: PlanningStrategyType;
42
+ setPlanningStrategy: (planningStrategy: PlanningStrategyType) => void;
34
43
  popupTab: "playground" | "bridge" | "recorder";
35
44
  setPopupTab: (tab: "playground" | "bridge" | "recorder") => void;
45
+ imeStrategy: ImeStrategyType;
46
+ setImeStrategy: (imeStrategy: ImeStrategyType) => void;
47
+ autoDismissKeyboard: boolean;
48
+ setAutoDismissKeyboard: (autoDismissKeyboard: boolean) => void;
49
+ keyboardDismissStrategy: KeyboardDismissStrategyType;
50
+ setKeyboardDismissStrategy: (keyboardDismissStrategy: KeyboardDismissStrategyType) => void;
51
+ alwaysRefreshScreenInfo: boolean;
52
+ setAlwaysRefreshScreenInfo: (alwaysRefreshScreenInfo: boolean) => void;
36
53
  }>>;
@@ -58,7 +58,7 @@ export declare const VALIDATION_CONSTANTS: {
58
58
  readonly LOCATION: "midscene_location_field_flag";
59
59
  };
60
60
  readonly DEFAULT_VALUES: {
61
- readonly ACTION_TYPE: "aiAction";
61
+ readonly ACTION_TYPE: "aiAct";
62
62
  readonly TIMEOUT_MS: 15000;
63
63
  readonly CHECK_INTERVAL_MS: 3000;
64
64
  };
@@ -71,11 +71,11 @@ export declare const unwrapZodType: (field: ZodType) => {
71
71
  hasDefault: boolean;
72
72
  };
73
73
  export declare const extractDefaultValue: (field: ZodType) => unknown;
74
- import type { GroupedActionDump, WebUIContext } from '@midscene/core';
74
+ import type { ExecutionDump, WebUIContext } from '@midscene/core';
75
75
  import type { ExecutionOptions, PlaygroundAgent } from '@midscene/playground';
76
76
  export interface PlaygroundResult {
77
77
  result: any;
78
- dump?: GroupedActionDump | null;
78
+ dump?: ExecutionDump | null;
79
79
  reportHTML?: string | null;
80
80
  error: string | null;
81
81
  }
@@ -89,7 +89,9 @@ export interface StaticPlaygroundProps {
89
89
  context: WebUIContext | null;
90
90
  }
91
91
  export type ServiceModeType = 'Server' | 'In-Browser' | 'In-Browser-Extension';
92
- export type RunType = 'aiAction' | 'aiQuery' | 'aiAssert' | 'aiTap' | 'aiDoubleClick' | 'aiHover' | 'aiInput' | 'aiRightClick' | 'aiKeyboardPress' | 'aiScroll' | 'aiLocate' | 'aiBoolean' | 'aiNumber' | 'aiString' | 'aiAsk' | 'aiWaitFor';
92
+ export type DeviceType = 'web' | 'android' | 'ios';
93
+ export type PlanningStrategyType = 'fast' | 'standard';
94
+ export type RunType = 'aiAct' | 'aiQuery' | 'aiAssert' | 'aiTap' | 'aiDoubleClick' | 'aiHover' | 'aiInput' | 'aiRightClick' | 'aiKeyboardPress' | 'aiScroll' | 'aiLocate' | 'aiBoolean' | 'aiNumber' | 'aiString' | 'aiAsk' | 'aiWaitFor';
93
95
  export interface ReplayScriptsInfo {
94
96
  scripts: any[];
95
97
  width?: number;
@@ -108,9 +110,15 @@ export interface PlaygroundSDKLike {
108
110
  executeAction(actionType: string, value: FormValue, options: ExecutionOptions): Promise<unknown>;
109
111
  getActionSpace(context?: any): Promise<DeviceAction<unknown>[]>;
110
112
  onProgressUpdate?: (callback: ProgressCallback) => void;
113
+ onDumpUpdate?: (callback: (dump: string, executionDump?: ExecutionDump) => void) => void;
111
114
  cancelExecution?(requestId: string): Promise<void>;
115
+ getCurrentExecutionData?(): Promise<{
116
+ dump: ExecutionDump | null;
117
+ reportHTML: string | null;
118
+ }>;
112
119
  overrideConfig?(config: any): Promise<void>;
113
120
  checkStatus?(): Promise<boolean>;
121
+ getServiceMode?(): 'In-Browser-Extension' | 'Server';
114
122
  id?: string;
115
123
  }
116
124
  export interface StorageProvider {
@@ -134,6 +142,7 @@ export interface InfoListItem {
134
142
  replayCounter?: number;
135
143
  loadingProgressText?: string;
136
144
  verticalMode?: boolean;
145
+ actionType?: string;
137
146
  }
138
147
  export interface UniversalPlaygroundConfig {
139
148
  showContextPreview?: boolean;
@@ -143,6 +152,7 @@ export interface UniversalPlaygroundConfig {
143
152
  enableScrollToBottom?: boolean;
144
153
  serverMode?: boolean;
145
154
  showEnvConfigReminder?: boolean;
155
+ deviceType?: DeviceType;
146
156
  }
147
157
  export interface PlaygroundBranding {
148
158
  title?: string;