@midscene/visualizer 0.27.1-beta-20250822053848.0 → 0.27.1-beta-20250822094725.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 (27) hide show
  1. package/dist/es/component/playground/FormField.mjs +122 -0
  2. package/dist/es/component/playground/HistorySelector.mjs +2 -3
  3. package/dist/es/component/playground/PromptInput.mjs +339 -58
  4. package/dist/es/component/playground/index.css +160 -2
  5. package/dist/es/component/playground/playground-constants.mjs +69 -1
  6. package/dist/es/component/playground/playground-utils.mjs +43 -1
  7. package/dist/es/component/playground/types.mjs +50 -0
  8. package/dist/es/component/replay-scripts.mjs +18 -9
  9. package/dist/es/component/store/history.mjs +42 -8
  10. package/dist/lib/component/playground/FormField.js +165 -0
  11. package/dist/lib/component/playground/HistorySelector.js +2 -3
  12. package/dist/lib/component/playground/PromptInput.js +345 -54
  13. package/dist/lib/component/playground/index.css +160 -2
  14. package/dist/lib/component/playground/playground-constants.js +76 -2
  15. package/dist/lib/component/playground/playground-utils.js +45 -0
  16. package/dist/lib/component/playground/types.js +96 -0
  17. package/dist/lib/component/replay-scripts.js +28 -19
  18. package/dist/lib/component/store/history.js +42 -8
  19. package/dist/types/component/playground/FormField.d.ts +15 -0
  20. package/dist/types/component/playground/HistorySelector.d.ts +2 -0
  21. package/dist/types/component/playground/PromptInput.d.ts +3 -1
  22. package/dist/types/component/playground/playground-constants.d.ts +63 -0
  23. package/dist/types/component/playground/playground-types.d.ts +1 -1
  24. package/dist/types/component/playground/playground-utils.d.ts +1 -0
  25. package/dist/types/component/playground/types.d.ts +58 -0
  26. package/dist/types/component/store/history.d.ts +9 -4
  27. package/package.json +4 -4
@@ -50,8 +50,31 @@ body {
50
50
  color: #fff;
51
51
  }
52
52
 
53
- .prompt-input-wrapper .mode-radio-group-wrapper .mode-radio-group .ant-radio-button-wrapper:hover {
54
- color: #2b83ff;
53
+ .prompt-input-wrapper .mode-radio-group-wrapper .mode-radio-group .more-apis-button {
54
+ height: 24px;
55
+ box-shadow: none;
56
+ background-color: #f7f7f7;
57
+ border: none;
58
+ border-radius: 11px;
59
+ align-items: center;
60
+ gap: 2px;
61
+ padding: 0 8px;
62
+ font-size: 12px;
63
+ display: inline-flex;
64
+ }
65
+
66
+ .prompt-input-wrapper .mode-radio-group-wrapper .mode-radio-group .more-apis-button:hover {
67
+ background-color: #e6e6e6;
68
+ }
69
+
70
+ .prompt-input-wrapper .mode-radio-group-wrapper .mode-radio-group .more-apis-button.selected-from-dropdown {
71
+ color: #fff;
72
+ background-color: #2b83ff;
73
+ font-weight: 500;
74
+ }
75
+
76
+ .prompt-input-wrapper .mode-radio-group-wrapper .mode-radio-group .more-apis-button.selected-from-dropdown:hover {
77
+ background-color: #2b83ff;
55
78
  }
56
79
 
57
80
  .prompt-input-wrapper .mode-radio-group-wrapper .action-icons {
@@ -120,6 +143,10 @@ body {
120
143
  background-color: rgba(0, 0, 0, 0);
121
144
  }
122
145
 
146
+ .prompt-input-wrapper .ant-form-item-with-help + .form-controller-wrapper {
147
+ bottom: 22px;
148
+ }
149
+
123
150
  .prompt-input-wrapper .ant-input {
124
151
  padding-bottom: 40px;
125
152
  }
@@ -152,6 +179,137 @@ body {
152
179
  color: #3b3b3b;
153
180
  }
154
181
 
182
+ .prompt-input-wrapper .structured-params-container {
183
+ background: linear-gradient(#fff, #fff) padding-box padding-box, linear-gradient(135deg, #4285f4 0%, #06f 25%, #7b02c5 50%, #ea4335 75%, #ff7043 100%) border-box;
184
+ border: 1px solid rgba(0, 0, 0, 0);
185
+ border-radius: 12px;
186
+ padding: 16px 16px 56px;
187
+ }
188
+
189
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-form-item {
190
+ flex-direction: column;
191
+ display: flex;
192
+ }
193
+
194
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-form-item .ant-form-item-label {
195
+ text-align: left;
196
+ flex-basis: auto;
197
+ padding-bottom: 4px;
198
+ }
199
+
200
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-form-item .ant-form-item-label > label {
201
+ color: rgba(0, 0, 0, .85);
202
+ height: auto;
203
+ font-size: 12px;
204
+ font-weight: 500;
205
+ line-height: 1.5;
206
+ }
207
+
208
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-form-item .ant-form-item-label > label:after {
209
+ color: #ff4d4f;
210
+ font-family: SimSun, sans-serif;
211
+ font-size: 12px;
212
+ line-height: 1;
213
+ display: inline-block;
214
+ }
215
+
216
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-form-item .ant-form-item-label > label:not(:-webkit-any(:lang(ae), :lang(ar), :lang(arc), :lang(bcc), :lang(bqi), :lang(ckb), :lang(dv), :lang(fa), :lang(glk), :lang(he), :lang(ku), :lang(mzn), :lang(nqo), :lang(pnb), :lang(ps), :lang(sd), :lang(ug), :lang(ur), :lang(yi))):after {
217
+ margin-left: 4px;
218
+ }
219
+
220
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-form-item .ant-form-item-label > label:not(:-moz-any(:lang(ae), :lang(ar), :lang(arc), :lang(bcc), :lang(bqi), :lang(ckb), :lang(dv), :lang(fa), :lang(glk), :lang(he), :lang(ku), :lang(mzn), :lang(nqo), :lang(pnb), :lang(ps), :lang(sd), :lang(ug), :lang(ur), :lang(yi))):after {
221
+ margin-left: 4px;
222
+ }
223
+
224
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-form-item .ant-form-item-label > label:not(:is(:lang(ae), :lang(ar), :lang(arc), :lang(bcc), :lang(bqi), :lang(ckb), :lang(dv), :lang(fa), :lang(glk), :lang(he), :lang(ku), :lang(mzn), :lang(nqo), :lang(pnb), :lang(ps), :lang(sd), :lang(ug), :lang(ur), :lang(yi))):after {
225
+ margin-left: 4px;
226
+ }
227
+
228
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-form-item .ant-form-item-label > label:-webkit-any(:lang(ae), :lang(ar), :lang(arc), :lang(bcc), :lang(bqi), :lang(ckb), :lang(dv), :lang(fa), :lang(glk), :lang(he), :lang(ku), :lang(mzn), :lang(nqo), :lang(pnb), :lang(ps), :lang(sd), :lang(ug), :lang(ur), :lang(yi)):after {
229
+ margin-right: 4px;
230
+ }
231
+
232
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-form-item .ant-form-item-label > label:-moz-any(:lang(ae), :lang(ar), :lang(arc), :lang(bcc), :lang(bqi), :lang(ckb), :lang(dv), :lang(fa), :lang(glk), :lang(he), :lang(ku), :lang(mzn), :lang(nqo), :lang(pnb), :lang(ps), :lang(sd), :lang(ug), :lang(ur), :lang(yi)):after {
233
+ margin-right: 4px;
234
+ }
235
+
236
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-form-item .ant-form-item-label > label:is(:lang(ae), :lang(ar), :lang(arc), :lang(bcc), :lang(bqi), :lang(ckb), :lang(dv), :lang(fa), :lang(glk), :lang(he), :lang(ku), :lang(mzn), :lang(nqo), :lang(pnb), :lang(ps), :lang(sd), :lang(ug), :lang(ur), :lang(yi)):after {
237
+ margin-right: 4px;
238
+ }
239
+
240
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-form-item .ant-form-item-control {
241
+ flex: 1;
242
+ margin-top: 0;
243
+ }
244
+
245
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-form-item .ant-form-item-row {
246
+ flex-direction: column;
247
+ }
248
+
249
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-form-item .ant-form-item-control-input {
250
+ min-height: auto;
251
+ }
252
+
253
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-input, .prompt-input-wrapper .structured-params-container .structured-params .ant-input-number, .prompt-input-wrapper .structured-params-container .structured-params .ant-select {
254
+ border: 1px solid #e1e5e9;
255
+ border-radius: 6px;
256
+ width: 100%;
257
+ }
258
+
259
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-input:hover, .prompt-input-wrapper .structured-params-container .structured-params .ant-input-number:hover, .prompt-input-wrapper .structured-params-container .structured-params .ant-select:hover {
260
+ border-color: #40a9ff;
261
+ }
262
+
263
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-input:focus, .prompt-input-wrapper .structured-params-container .structured-params .ant-input-number:focus, .prompt-input-wrapper .structured-params-container .structured-params .ant-select:focus, .prompt-input-wrapper .structured-params-container .structured-params .ant-input:focus-within, .prompt-input-wrapper .structured-params-container .structured-params .ant-input-number:focus-within, .prompt-input-wrapper .structured-params-container .structured-params .ant-select:focus-within {
264
+ border-color: #40a9ff;
265
+ box-shadow: 0 0 0 2px rgba(24, 144, 255, .2);
266
+ }
267
+
268
+ .prompt-input-wrapper .structured-params-container .structured-params textarea.ant-input {
269
+ padding-bottom: 5px;
270
+ }
271
+
272
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-input-number .ant-input-number-input {
273
+ box-shadow: none;
274
+ border: none;
275
+ }
276
+
277
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-input-number:hover .ant-input-number-input {
278
+ box-shadow: none;
279
+ }
280
+
281
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-select {
282
+ min-width: 120px;
283
+ }
284
+
285
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-select .ant-select-selector {
286
+ box-shadow: none;
287
+ border: none;
288
+ }
289
+
290
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-select:hover .ant-select-selector, .prompt-input-wrapper .structured-params-container .structured-params .ant-select.ant-select-focused .ant-select-selector {
291
+ box-shadow: none;
292
+ }
293
+
294
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-radio-group {
295
+ width: 100%;
296
+ }
297
+
298
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-radio-group .ant-radio-button-wrapper {
299
+ border: 1px solid #e1e5e9;
300
+ border-radius: 6px;
301
+ height: 32px;
302
+ margin-right: 4px;
303
+ font-size: 12px;
304
+ line-height: 30px;
305
+ }
306
+
307
+ .prompt-input-wrapper .structured-params-container .structured-params .ant-radio-group .ant-radio-button-wrapper.ant-radio-button-wrapper-checked {
308
+ color: #fff;
309
+ background-color: #2b83ff;
310
+ border-color: #2b83ff;
311
+ }
312
+
155
313
  .selector-trigger {
156
314
  cursor: pointer;
157
315
  width: 24px;
@@ -33,10 +33,12 @@ var __webpack_require__ = {};
33
33
  var __webpack_exports__ = {};
34
34
  __webpack_require__.r(__webpack_exports__);
35
35
  __webpack_require__.d(__webpack_exports__, {
36
- serverLaunchTip: ()=>serverLaunchTip,
36
+ apiMetadata: ()=>apiMetadata,
37
37
  errorMessageServerNotReady: ()=>errorMessageServerNotReady,
38
- trackingTip: ()=>trackingTip,
38
+ serverLaunchTip: ()=>serverLaunchTip,
39
+ defaultMainButtons: ()=>defaultMainButtons,
39
40
  deepThinkTip: ()=>deepThinkTip,
41
+ trackingTip: ()=>trackingTip,
40
42
  emptyResultTip: ()=>emptyResultTip
41
43
  });
42
44
  const jsx_runtime_namespaceObject = require("react/jsx-runtime");
@@ -84,13 +86,85 @@ const emptyResultTip = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div",
84
86
  });
85
87
  const trackingTip = 'limit popup to current tab';
86
88
  const deepThinkTip = 'deep think';
89
+ const apiMetadata = {
90
+ aiAction: {
91
+ group: 'interaction',
92
+ title: 'Auto Planning: plan the steps and execute'
93
+ },
94
+ aiTap: {
95
+ group: 'interaction',
96
+ title: 'Click an element'
97
+ },
98
+ aiHover: {
99
+ group: 'interaction',
100
+ title: 'Hover over an element'
101
+ },
102
+ aiInput: {
103
+ group: 'interaction',
104
+ title: 'Input text into an element'
105
+ },
106
+ aiRightClick: {
107
+ group: 'interaction',
108
+ title: 'Right-click an element'
109
+ },
110
+ aiKeyboardPress: {
111
+ group: 'interaction',
112
+ title: 'Press keyboard keys'
113
+ },
114
+ aiScroll: {
115
+ group: 'interaction',
116
+ title: 'Scroll the page or element'
117
+ },
118
+ aiLocate: {
119
+ group: 'interaction',
120
+ title: 'Locate an element on the page'
121
+ },
122
+ aiQuery: {
123
+ group: 'extraction',
124
+ title: 'Extract data directly from the UI'
125
+ },
126
+ aiBoolean: {
127
+ group: 'extraction',
128
+ title: 'Get true/false answer'
129
+ },
130
+ aiNumber: {
131
+ group: 'extraction',
132
+ title: 'Extract numeric value'
133
+ },
134
+ aiString: {
135
+ group: 'extraction',
136
+ title: 'Extract text value'
137
+ },
138
+ aiAsk: {
139
+ group: 'extraction',
140
+ title: 'Ask a question about the UI'
141
+ },
142
+ aiAssert: {
143
+ group: 'validation',
144
+ title: 'Assert a condition is true'
145
+ },
146
+ aiWaitFor: {
147
+ group: 'validation',
148
+ title: 'Wait for a condition to be met'
149
+ }
150
+ };
151
+ const defaultMainButtons = [
152
+ 'aiAction',
153
+ 'aiTap',
154
+ 'aiQuery',
155
+ 'aiAssert'
156
+ ];
157
+ exports.apiMetadata = __webpack_exports__.apiMetadata;
87
158
  exports.deepThinkTip = __webpack_exports__.deepThinkTip;
159
+ exports.defaultMainButtons = __webpack_exports__.defaultMainButtons;
88
160
  exports.emptyResultTip = __webpack_exports__.emptyResultTip;
89
161
  exports.errorMessageServerNotReady = __webpack_exports__.errorMessageServerNotReady;
90
162
  exports.serverLaunchTip = __webpack_exports__.serverLaunchTip;
91
163
  exports.trackingTip = __webpack_exports__.trackingTip;
92
164
  for(var __webpack_i__ in __webpack_exports__)if (-1 === [
165
+ "apiMetadata",
93
166
  "deepThinkTip",
167
+ "defaultMainButtons",
94
168
  "emptyResultTip",
95
169
  "errorMessageServerNotReady",
96
170
  "serverLaunchTip",
@@ -28,6 +28,7 @@ __webpack_require__.d(__webpack_exports__, {
28
28
  formatErrorMessage: ()=>formatErrorMessage,
29
29
  serverBase: ()=>serverBase,
30
30
  actionNameForType: ()=>actionNameForType,
31
+ isRunButtonEnabled: ()=>isRunButtonEnabled,
31
32
  getPlaceholderForType: ()=>getPlaceholderForType,
32
33
  cancelTask: ()=>cancelTask,
33
34
  requestPlaygroundServer: ()=>requestPlaygroundServer,
@@ -38,6 +39,7 @@ __webpack_require__.d(__webpack_exports__, {
38
39
  });
39
40
  const constants_namespaceObject = require("@midscene/shared/constants");
40
41
  const playground_namespaceObject = require("@midscene/web/playground");
42
+ const external_types_js_namespaceObject = require("./types.js");
41
43
  const serverBase = `http://localhost:${constants_namespaceObject.PLAYGROUND_SERVER_PORT}`;
42
44
  const checkServerStatus = async ()=>{
43
45
  try {
@@ -101,6 +103,17 @@ const actionNameForType = (type)=>{
101
103
  if ('aiQuery' === type) return 'Query';
102
104
  if ('aiAssert' === type) return 'Assert';
103
105
  if ('aiTap' === type) return 'Tap';
106
+ if ('aiHover' === type) return 'Hover';
107
+ if ('aiInput' === type) return 'Input';
108
+ if ('aiRightClick' === type) return 'Right Click';
109
+ if ('aiKeyboardPress' === type) return 'Keyboard Press';
110
+ if ('aiScroll' === type) return 'Scroll';
111
+ if ('aiLocate' === type) return 'Locate';
112
+ if ('aiBoolean' === type) return 'Boolean';
113
+ if ('aiNumber' === type) return 'Number';
114
+ if ('aiString' === type) return 'String';
115
+ if ('aiAsk' === type) return 'Ask';
116
+ if ('aiWaitFor' === type) return 'Wait For';
104
117
  return type;
105
118
  };
106
119
  const staticAgentFromContext = (context)=>{
@@ -116,6 +129,18 @@ const formatErrorMessage = (e)=>{
116
129
  const getPlaceholderForType = (type)=>{
117
130
  if ('aiQuery' === type) return 'What do you want to query?';
118
131
  if ('aiAssert' === type) return 'What do you want to assert?';
132
+ if ('aiTap' === type) return 'What element do you want to tap?';
133
+ if ('aiHover' === type) return 'What element do you want to hover over?';
134
+ if ('aiInput' === type) return 'Format: <value> | <element>\nExample: hello world | search box';
135
+ if ('aiRightClick' === type) return 'What element do you want to right-click?';
136
+ if ('aiKeyboardPress' === type) return 'Format: <key> | <element (optional)>\nExample: Enter | text field';
137
+ if ('aiScroll' === type) return 'Format: <direction> <amount> | <element (optional)>\nExample: down 500 | main content';
138
+ if ('aiLocate' === type) return 'What element do you want to locate?';
139
+ if ('aiBoolean' === type) return 'What do you want to check (returns true/false)?';
140
+ if ('aiNumber' === type) return 'What number do you want to extract?';
141
+ if ('aiString' === type) return 'What text do you want to extract?';
142
+ if ('aiAsk' === type) return 'What do you want to ask?';
143
+ if ('aiWaitFor' === type) return 'What condition do you want to wait for?';
119
144
  return 'What do you want to do?';
120
145
  };
121
146
  const blankResult = {
@@ -124,6 +149,24 @@ const blankResult = {
124
149
  reportHTML: null,
125
150
  error: null
126
151
  };
152
+ const isRunButtonEnabled = (runButtonEnabled, needsStructuredParams, params, actionSpace, selectedType, promptValue)=>{
153
+ if (!runButtonEnabled) return false;
154
+ if (needsStructuredParams) {
155
+ const currentParams = params || {};
156
+ const action = null == actionSpace ? void 0 : actionSpace.find((a)=>a.interfaceAlias === selectedType || a.name === selectedType);
157
+ if ((null == action ? void 0 : action.paramSchema) && (0, external_types_js_namespaceObject.isZodObjectSchema)(action.paramSchema)) {
158
+ const schema = action.paramSchema;
159
+ return Object.keys(schema.shape).every((key)=>{
160
+ const field = schema.shape[key];
161
+ const { isOptional } = (0, external_types_js_namespaceObject.unwrapZodType)(field);
162
+ const value = currentParams[key];
163
+ return isOptional || void 0 !== value && '' !== value && null !== value;
164
+ });
165
+ }
166
+ return true;
167
+ }
168
+ return promptValue.trim().length > 0;
169
+ };
127
170
  exports.actionNameForType = __webpack_exports__.actionNameForType;
128
171
  exports.blankResult = __webpack_exports__.blankResult;
129
172
  exports.cancelTask = __webpack_exports__.cancelTask;
@@ -131,6 +174,7 @@ exports.checkServerStatus = __webpack_exports__.checkServerStatus;
131
174
  exports.formatErrorMessage = __webpack_exports__.formatErrorMessage;
132
175
  exports.getPlaceholderForType = __webpack_exports__.getPlaceholderForType;
133
176
  exports.getTaskProgress = __webpack_exports__.getTaskProgress;
177
+ exports.isRunButtonEnabled = __webpack_exports__.isRunButtonEnabled;
134
178
  exports.overrideServerConfig = __webpack_exports__.overrideServerConfig;
135
179
  exports.requestPlaygroundServer = __webpack_exports__.requestPlaygroundServer;
136
180
  exports.serverBase = __webpack_exports__.serverBase;
@@ -143,6 +187,7 @@ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
143
187
  "formatErrorMessage",
144
188
  "getPlaceholderForType",
145
189
  "getTaskProgress",
190
+ "isRunButtonEnabled",
146
191
  "overrideServerConfig",
147
192
  "requestPlaygroundServer",
148
193
  "serverBase",
@@ -0,0 +1,96 @@
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
+ VALIDATION_CONSTANTS: ()=>VALIDATION_CONSTANTS,
28
+ extractDefaultValue: ()=>extractDefaultValue,
29
+ isLocateField: ()=>isLocateField,
30
+ isZodObjectSchema: ()=>isZodObjectSchema,
31
+ unwrapZodType: ()=>unwrapZodType
32
+ });
33
+ const VALIDATION_CONSTANTS = {
34
+ ZOD_TYPES: {
35
+ OPTIONAL: 'ZodOptional',
36
+ DEFAULT: 'ZodDefault',
37
+ NULLABLE: 'ZodNullable',
38
+ OBJECT: 'ZodObject',
39
+ ENUM: 'ZodEnum',
40
+ NUMBER: 'ZodNumber',
41
+ STRING: 'ZodString'
42
+ },
43
+ FIELD_FLAGS: {
44
+ LOCATION: 'midscene_location_field_flag'
45
+ },
46
+ DEFAULT_VALUES: {
47
+ ACTION_TYPE: 'aiAction',
48
+ TIMEOUT_MS: 15000,
49
+ CHECK_INTERVAL_MS: 3000
50
+ }
51
+ };
52
+ const isZodObjectSchema = (schema)=>'object' == typeof schema && null !== schema && 'shape' in schema && 'parse' in schema && 'function' == typeof schema.parse;
53
+ const isLocateField = (field)=>{
54
+ var _field__def, _field__def_shape, _field__def1, _field__def_shape1, _field__def2;
55
+ return !!((null == (_field__def = field._def) ? void 0 : _field__def.typeName) === VALIDATION_CONSTANTS.ZOD_TYPES.OBJECT && (null == (_field__def_shape = (_field__def1 = field._def).shape) ? void 0 : _field__def_shape.call(_field__def1)) && VALIDATION_CONSTANTS.FIELD_FLAGS.LOCATION in ((null == (_field__def_shape1 = (_field__def2 = field._def).shape) ? void 0 : _field__def_shape1.call(_field__def2)) || {}));
56
+ };
57
+ const unwrapZodType = (field)=>{
58
+ var _actualField__def, _actualField__def1, _actualField__def2;
59
+ let actualField = field;
60
+ let isOptional = false;
61
+ let hasDefault = false;
62
+ while((null == (_actualField__def = actualField._def) ? void 0 : _actualField__def.typeName) === VALIDATION_CONSTANTS.ZOD_TYPES.OPTIONAL || (null == (_actualField__def1 = actualField._def) ? void 0 : _actualField__def1.typeName) === VALIDATION_CONSTANTS.ZOD_TYPES.DEFAULT || (null == (_actualField__def2 = actualField._def) ? void 0 : _actualField__def2.typeName) === VALIDATION_CONSTANTS.ZOD_TYPES.NULLABLE){
63
+ var _actualField__def3, _actualField__def4;
64
+ if ((null == (_actualField__def3 = actualField._def) ? void 0 : _actualField__def3.typeName) === VALIDATION_CONSTANTS.ZOD_TYPES.OPTIONAL) isOptional = true;
65
+ if ((null == (_actualField__def4 = actualField._def) ? void 0 : _actualField__def4.typeName) === VALIDATION_CONSTANTS.ZOD_TYPES.DEFAULT) hasDefault = true;
66
+ actualField = actualField._def.innerType || actualField;
67
+ }
68
+ return {
69
+ actualField,
70
+ isOptional,
71
+ hasDefault
72
+ };
73
+ };
74
+ const extractDefaultValue = (field)=>{
75
+ var _currentField__def;
76
+ let currentField = field;
77
+ while(null == (_currentField__def = currentField._def) ? void 0 : _currentField__def.innerType){
78
+ if (currentField._def.typeName === VALIDATION_CONSTANTS.ZOD_TYPES.DEFAULT && currentField._def.defaultValue) return currentField._def.defaultValue();
79
+ currentField = currentField._def.innerType;
80
+ }
81
+ };
82
+ exports.VALIDATION_CONSTANTS = __webpack_exports__.VALIDATION_CONSTANTS;
83
+ exports.extractDefaultValue = __webpack_exports__.extractDefaultValue;
84
+ exports.isLocateField = __webpack_exports__.isLocateField;
85
+ exports.isZodObjectSchema = __webpack_exports__.isZodObjectSchema;
86
+ exports.unwrapZodType = __webpack_exports__.unwrapZodType;
87
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
88
+ "VALIDATION_CONSTANTS",
89
+ "extractDefaultValue",
90
+ "isLocateField",
91
+ "isZodObjectSchema",
92
+ "unwrapZodType"
93
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
94
+ Object.defineProperty(exports, '__esModule', {
95
+ value: true
96
+ });
@@ -32,7 +32,7 @@ __webpack_require__.d(__webpack_exports__, {
32
32
  });
33
33
  require("./player.css");
34
34
  const external_utils_js_namespaceObject = require("../utils.js");
35
- const ui_utils_namespaceObject = require("@midscene/web/ui-utils");
35
+ const agent_namespaceObject = require("@midscene/core/agent");
36
36
  const extractor_namespaceObject = require("@midscene/shared/extractor");
37
37
  const stillDuration = 900;
38
38
  const actionSpinningPointerDuration = 300;
@@ -81,11 +81,10 @@ const allScriptsFromDump = (dump)=>{
81
81
  dump.executions.forEach((execution)=>{
82
82
  if (execution.sdkVersion) sdkVersion = execution.sdkVersion;
83
83
  execution.tasks.forEach((task)=>{
84
- var _insightTask_pageContext_size, _insightTask_pageContext;
85
- const insightTask = task;
86
- if (null == (_insightTask_pageContext = insightTask.pageContext) ? void 0 : null == (_insightTask_pageContext_size = _insightTask_pageContext.size) ? void 0 : _insightTask_pageContext_size.width) {
87
- width = insightTask.pageContext.size.width;
88
- height = insightTask.pageContext.size.height;
84
+ var _task_pageContext_size, _task_pageContext;
85
+ if (null == (_task_pageContext = task.pageContext) ? void 0 : null == (_task_pageContext_size = _task_pageContext.size) ? void 0 : _task_pageContext_size.width) {
86
+ width = task.pageContext.size.width;
87
+ height = task.pageContext.size.height;
89
88
  }
90
89
  });
91
90
  });
@@ -112,14 +111,24 @@ const allScriptsFromDump = (dump)=>{
112
111
  if (index !== allScripts.length - 1 && 'Done' === script.title) return false;
113
112
  return true;
114
113
  });
114
+ const modelBriefs = (()=>{
115
+ var _list_;
116
+ const list = [
117
+ ...modelBriefsSet
118
+ ];
119
+ if (!list.length) return list;
120
+ const firstOneInfo = null == (_list_ = list[0]) ? void 0 : _list_.split('/', 2)[1];
121
+ if (firstOneInfo && list.slice(1).every((item)=>(null == item ? void 0 : item.split('/', 2)[1]) === firstOneInfo)) return [
122
+ firstOneInfo
123
+ ];
124
+ return list;
125
+ })();
115
126
  return {
116
127
  scripts: allScriptsWithoutIntermediateDoneFrame,
117
128
  width,
118
129
  height,
119
130
  sdkVersion,
120
- modelBriefs: [
121
- ...modelBriefsSet
122
- ]
131
+ modelBriefs
123
132
  };
124
133
  };
125
134
  const generateAnimationScripts = (execution, task, imageWidth, imageHeight)=>{
@@ -162,7 +171,7 @@ const generateAnimationScripts = (execution, task, imageWidth, imageHeight)=>{
162
171
  let errorStateFlag = false;
163
172
  tasksIncluded.forEach((task, index)=>{
164
173
  if (errorStateFlag) return;
165
- if (0 === index) initSubTitle = (0, ui_utils_namespaceObject.paramStr)(task);
174
+ if (0 === index) initSubTitle = (0, agent_namespaceObject.paramStr)(task);
166
175
  if ('Planning' === task.type) {
167
176
  const planningTask = task;
168
177
  if (planningTask.recorder && planningTask.recorder.length > 0) {
@@ -172,16 +181,16 @@ const generateAnimationScripts = (execution, task, imageWidth, imageHeight)=>{
172
181
  img: null == (_planningTask_recorder = planningTask.recorder) ? void 0 : null == (_planningTask_recorder_ = _planningTask_recorder[0]) ? void 0 : _planningTask_recorder_.screenshot,
173
182
  camera: 0 === index ? fullPageCameraState : void 0,
174
183
  duration: stillDuration,
175
- title: (0, ui_utils_namespaceObject.typeStr)(task),
176
- subTitle: (0, ui_utils_namespaceObject.paramStr)(task)
184
+ title: (0, agent_namespaceObject.typeStr)(task),
185
+ subTitle: (0, agent_namespaceObject.paramStr)(task)
177
186
  });
178
187
  }
179
188
  } else if ('Insight' === task.type && 'Locate' === task.subType) {
180
189
  var _insightTask_output;
181
190
  const insightTask = task;
182
191
  const resultElement = null == (_insightTask_output = insightTask.output) ? void 0 : _insightTask_output.element;
183
- const title = (0, ui_utils_namespaceObject.typeStr)(task);
184
- const subTitle = (0, ui_utils_namespaceObject.paramStr)(task);
192
+ const title = (0, agent_namespaceObject.typeStr)(task);
193
+ const subTitle = (0, agent_namespaceObject.paramStr)(task);
185
194
  if (null == resultElement ? void 0 : resultElement.rect) insightCameraState = {
186
195
  ...cameraStateForRect(resultElement.rect, imageWidth, imageHeight),
187
196
  pointerLeft: resultElement.center[0],
@@ -223,8 +232,8 @@ const generateAnimationScripts = (execution, task, imageWidth, imageHeight)=>{
223
232
  }
224
233
  } else if ('Action' === task.type && 'FalsyConditionStatement' !== task.subType) {
225
234
  var _task_recorder_, _task_recorder, _task_recorder_1, _task_recorder1;
226
- const title = (0, ui_utils_namespaceObject.typeStr)(task);
227
- const subTitle = (0, ui_utils_namespaceObject.paramStr)(task);
235
+ const title = (0, agent_namespaceObject.typeStr)(task);
236
+ const subTitle = (0, agent_namespaceObject.paramStr)(task);
228
237
  scripts.push(pointerScript(external_utils_js_namespaceObject.mousePointer, title, subTitle));
229
238
  currentCameraState = null != insightCameraState ? insightCameraState : fullPageCameraState;
230
239
  scripts.push({
@@ -269,8 +278,8 @@ const generateAnimationScripts = (execution, task, imageWidth, imageHeight)=>{
269
278
  });
270
279
  } else {
271
280
  var _task_recorder_3, _task_recorder3;
272
- const title = (0, ui_utils_namespaceObject.typeStr)(task);
273
- const subTitle = (0, ui_utils_namespaceObject.paramStr)(task);
281
+ const title = (0, agent_namespaceObject.typeStr)(task);
282
+ const subTitle = (0, agent_namespaceObject.paramStr)(task);
274
283
  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;
275
284
  if (screenshot) scripts.push({
276
285
  type: 'img',
@@ -283,7 +292,7 @@ const generateAnimationScripts = (execution, task, imageWidth, imageHeight)=>{
283
292
  }
284
293
  if ('finished' !== task.status) {
285
294
  errorStateFlag = true;
286
- const errorTitle = (0, ui_utils_namespaceObject.typeStr)(task);
295
+ const errorTitle = (0, agent_namespaceObject.typeStr)(task);
287
296
  const errorMsg = task.errorMessage || 'unknown error';
288
297
  const errorSubTitle = errorMsg.indexOf('NOT_IMPLEMENTED_AS_DESIGNED') > 0 ? 'Further actions cannot be performed in the current environment' : errorMsg;
289
298
  scripts.push({
@@ -28,29 +28,63 @@ __webpack_require__.d(__webpack_exports__, {
28
28
  });
29
29
  const external_zustand_namespaceObject = require("zustand");
30
30
  const { create } = external_zustand_namespaceObject;
31
- const HISTORY_KEY = 'midscene-prompt-history';
31
+ const HISTORY_KEY = 'midscene-prompt-history-v2';
32
+ const LAST_SELECTED_TYPE_KEY = 'midscene-last-selected-type';
32
33
  const getHistoryFromLocalStorage = ()=>{
33
34
  const historyString = localStorage.getItem(HISTORY_KEY);
34
- return historyString ? JSON.parse(historyString) : [];
35
+ return historyString ? JSON.parse(historyString) : {};
36
+ };
37
+ const getLastSelectedType = ()=>localStorage.getItem(LAST_SELECTED_TYPE_KEY) || 'aiAction';
38
+ const setLastSelectedType = (type)=>{
39
+ localStorage.setItem(LAST_SELECTED_TYPE_KEY, type);
35
40
  };
36
41
  const useHistoryStore = create((set, get)=>({
37
42
  history: getHistoryFromLocalStorage(),
38
- clearHistory: ()=>{
43
+ lastSelectedType: getLastSelectedType(),
44
+ clearHistory: (type)=>{
45
+ const newHistory = {
46
+ ...get().history
47
+ };
48
+ delete newHistory[type];
39
49
  set({
40
- history: []
50
+ history: newHistory
41
51
  });
42
- localStorage.removeItem(HISTORY_KEY);
52
+ localStorage.setItem(HISTORY_KEY, JSON.stringify(newHistory));
43
53
  },
44
54
  addHistory: (historyItem)=>{
45
- const newHistory = [
55
+ const { type } = historyItem;
56
+ const currentHistory = get().history;
57
+ const typeHistory = currentHistory[type] || [];
58
+ const stringifiedNewItem = JSON.stringify({
59
+ prompt: historyItem.prompt,
60
+ params: historyItem.params
61
+ });
62
+ const newTypeHistory = [
46
63
  historyItem,
47
- ...get().history.filter((h)=>h.prompt !== historyItem.prompt)
64
+ ...typeHistory.filter((h)=>{
65
+ const stringifiedOldItem = JSON.stringify({
66
+ prompt: h.prompt,
67
+ params: h.params
68
+ });
69
+ return stringifiedOldItem !== stringifiedNewItem;
70
+ })
48
71
  ];
49
- while(newHistory.length > 10)newHistory.pop();
72
+ if (newTypeHistory.length > 10) newTypeHistory.length = 10;
73
+ const newHistory = {
74
+ ...currentHistory,
75
+ [type]: newTypeHistory
76
+ };
50
77
  set({
51
78
  history: newHistory
52
79
  });
53
80
  localStorage.setItem(HISTORY_KEY, JSON.stringify(newHistory));
81
+ },
82
+ getHistoryForType: (type)=>get().history[type] || [],
83
+ setLastSelectedType: (type)=>{
84
+ set({
85
+ lastSelectedType: type
86
+ });
87
+ setLastSelectedType(type);
54
88
  }
55
89
  }));
56
90
  exports.useHistoryStore = __webpack_exports__.useHistoryStore;
@@ -0,0 +1,15 @@
1
+ import type { z } from '@midscene/core';
2
+ import type React from 'react';
3
+ interface FormFieldProps {
4
+ name: string;
5
+ label: string;
6
+ fieldSchema: z.ZodTypeAny;
7
+ isRequired: boolean;
8
+ isLocateField: boolean;
9
+ marginBottom: number;
10
+ }
11
+ export declare const TextField: React.FC<Omit<FormFieldProps, 'isLocateField'>>;
12
+ export declare const LocateField: React.FC<Omit<FormFieldProps, 'isLocateField'>>;
13
+ export declare const EnumField: React.FC<Omit<FormFieldProps, 'isLocateField'>>;
14
+ export declare const NumberField: React.FC<Omit<FormFieldProps, 'isLocateField'>>;
15
+ export {};