@midscene/visualizer 1.7.3 → 1.7.5-beta-20260418223706.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.
- package/dist/es/component/config-selector/index.mjs +2 -2
- package/dist/es/component/history-selector/index.css +83 -16
- package/dist/es/component/history-selector/index.mjs +2 -2
- package/dist/es/component/player/index.mjs +3 -0
- package/dist/es/component/playground/index.css +193 -1
- package/dist/es/component/playground-result/index.css +28 -0
- package/dist/es/component/playground-result/index.mjs +39 -54
- package/dist/es/component/prompt-input/index.css +165 -1
- package/dist/es/component/prompt-input/index.mjs +305 -130
- package/dist/es/component/universal-playground/index.css +47 -15
- package/dist/es/component/universal-playground/index.mjs +162 -102
- package/dist/es/utils/action-label.mjs +14 -0
- package/dist/es/utils/playground-utils.mjs +1 -9
- package/dist/es/utils/prompt-input-utils.mjs +45 -0
- package/dist/es/utils/replay-scripts.mjs +32 -19
- package/dist/lib/component/config-selector/index.js +2 -2
- package/dist/lib/component/history-selector/index.css +83 -16
- package/dist/lib/component/history-selector/index.js +2 -2
- package/dist/lib/component/player/index.js +3 -0
- package/dist/lib/component/playground/index.css +193 -1
- package/dist/lib/component/playground-result/index.css +28 -0
- package/dist/lib/component/playground-result/index.js +39 -54
- package/dist/lib/component/prompt-input/index.css +165 -1
- package/dist/lib/component/prompt-input/index.js +307 -130
- package/dist/lib/component/universal-playground/index.css +47 -15
- package/dist/lib/component/universal-playground/index.js +161 -101
- package/dist/lib/utils/action-label.js +51 -0
- package/dist/lib/utils/playground-utils.js +2 -10
- package/dist/lib/utils/prompt-input-utils.js +82 -0
- package/dist/lib/utils/replay-scripts.js +32 -19
- package/dist/types/component/config-selector/index.d.ts +2 -0
- package/dist/types/component/history-selector/index.d.ts +2 -0
- package/dist/types/component/prompt-input/index.d.ts +2 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/types.d.ts +50 -0
- package/dist/types/utils/action-label.d.ts +11 -0
- package/dist/types/utils/playground-utils.d.ts +6 -1
- package/dist/types/utils/prompt-input-utils.d.ts +24 -0
- package/package.json +5 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import icons, { ArrowDownOutlined, ClearOutlined, LoadingOutlined } from "@ant-design/icons";
|
|
2
|
+
import icons, { ArrowDownOutlined, ClearOutlined, LoadingOutlined, UpOutlined } from "@ant-design/icons";
|
|
3
3
|
import { Alert, Button, Form, List, Typography, message } from "antd";
|
|
4
4
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
5
5
|
import { usePlaygroundExecution } from "../../hooks/usePlaygroundExecution.mjs";
|
|
@@ -137,7 +137,8 @@ function UniversalPlayground({ playgroundSDK, storage, contextProvider, config:
|
|
|
137
137
|
]);
|
|
138
138
|
const configAlreadySet = Object.keys(config || {}).length >= 1;
|
|
139
139
|
const runButtonEnabled = componentConfig.serverMode || !dryMode && !actionSpaceLoading && configAlreadySet;
|
|
140
|
-
const
|
|
140
|
+
const watchedType = Form.useWatch('type', form);
|
|
141
|
+
const selectedType = watchedType || form.getFieldValue('type');
|
|
141
142
|
const serviceMode = useMemo(()=>{
|
|
142
143
|
if (!playgroundSDK || 'function' != typeof playgroundSDK.getServiceMode) return 'Server';
|
|
143
144
|
return playgroundSDK.getServiceMode();
|
|
@@ -148,6 +149,49 @@ function UniversalPlayground({ playgroundSDK, storage, contextProvider, config:
|
|
|
148
149
|
const layout = componentConfig.layout || 'vertical';
|
|
149
150
|
const showVersionInfo = false !== componentConfig.showVersionInfo;
|
|
150
151
|
const deviceType = componentConfig.deviceType;
|
|
152
|
+
const collapsibleProgressGroup = true === componentConfig.collapsibleProgressGroup;
|
|
153
|
+
var _componentConfig_progressGroupLabel;
|
|
154
|
+
const progressGroupLabel = null != (_componentConfig_progressGroupLabel = componentConfig.progressGroupLabel) ? _componentConfig_progressGroupLabel : 'Execution Flow';
|
|
155
|
+
const [collapsedProgressGroups, setCollapsedProgressGroups] = useState(()=>new Set());
|
|
156
|
+
const toggleProgressGroup = useCallback((groupId)=>{
|
|
157
|
+
setCollapsedProgressGroups((prev)=>{
|
|
158
|
+
const next = new Set(prev);
|
|
159
|
+
if (next.has(groupId)) next.delete(groupId);
|
|
160
|
+
else next.add(groupId);
|
|
161
|
+
return next;
|
|
162
|
+
});
|
|
163
|
+
}, []);
|
|
164
|
+
const { firstInProgressGroup, visibleInfoList } = useMemo(()=>{
|
|
165
|
+
const firstIds = new Set();
|
|
166
|
+
const visible = [];
|
|
167
|
+
let currentGroupFirstId = null;
|
|
168
|
+
for (const item of infoList)if ('progress' === item.type) {
|
|
169
|
+
if (null === currentGroupFirstId) {
|
|
170
|
+
currentGroupFirstId = item.id;
|
|
171
|
+
firstIds.add(item.id);
|
|
172
|
+
visible.push(item);
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
if (!collapsibleProgressGroup || !collapsedProgressGroups.has(currentGroupFirstId)) visible.push(item);
|
|
176
|
+
} else {
|
|
177
|
+
currentGroupFirstId = null;
|
|
178
|
+
visible.push(item);
|
|
179
|
+
}
|
|
180
|
+
return {
|
|
181
|
+
firstInProgressGroup: firstIds,
|
|
182
|
+
visibleInfoList: visible
|
|
183
|
+
};
|
|
184
|
+
}, [
|
|
185
|
+
collapsedProgressGroups,
|
|
186
|
+
collapsibleProgressGroup,
|
|
187
|
+
infoList
|
|
188
|
+
]);
|
|
189
|
+
const latestProgressId = useMemo(()=>{
|
|
190
|
+
for(let i = infoList.length - 1; i >= 0; i--)if ('progress' === infoList[i].type) return infoList[i].id;
|
|
191
|
+
return null;
|
|
192
|
+
}, [
|
|
193
|
+
infoList
|
|
194
|
+
]);
|
|
151
195
|
return /*#__PURE__*/ jsx("div", {
|
|
152
196
|
className: `playground-container ${layout}-mode ${className}`.trim(),
|
|
153
197
|
children: /*#__PURE__*/ jsxs(Form, {
|
|
@@ -166,7 +210,7 @@ function UniversalPlayground({ playgroundSDK, storage, contextProvider, config:
|
|
|
166
210
|
/*#__PURE__*/ jsxs("div", {
|
|
167
211
|
className: "middle-dialog-area",
|
|
168
212
|
children: [
|
|
169
|
-
infoList.length > 1 && /*#__PURE__*/ jsx("div", {
|
|
213
|
+
false !== componentConfig.showClearButton && infoList.length > 1 && /*#__PURE__*/ jsx("div", {
|
|
170
214
|
className: "clear-button-container",
|
|
171
215
|
children: /*#__PURE__*/ jsx(Button, {
|
|
172
216
|
size: "small",
|
|
@@ -181,115 +225,130 @@ function UniversalPlayground({ playgroundSDK, storage, contextProvider, config:
|
|
|
181
225
|
className: "info-list-container",
|
|
182
226
|
children: /*#__PURE__*/ jsx(List, {
|
|
183
227
|
itemLayout: "vertical",
|
|
184
|
-
dataSource:
|
|
185
|
-
renderItem: (item)=>/*#__PURE__*/
|
|
228
|
+
dataSource: visibleInfoList,
|
|
229
|
+
renderItem: (item)=>/*#__PURE__*/ jsxs(List.Item, {
|
|
186
230
|
className: "list-item",
|
|
187
|
-
children:
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
className:
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
231
|
+
children: [
|
|
232
|
+
collapsibleProgressGroup && firstInProgressGroup.has(item.id) ? /*#__PURE__*/ jsxs("button", {
|
|
233
|
+
type: "button",
|
|
234
|
+
className: `progress-group-toggle ${collapsedProgressGroups.has(item.id) ? 'is-collapsed' : 'is-expanded'}`,
|
|
235
|
+
"aria-expanded": !collapsedProgressGroups.has(item.id),
|
|
236
|
+
onClick: ()=>toggleProgressGroup(item.id),
|
|
237
|
+
children: [
|
|
238
|
+
/*#__PURE__*/ jsx("span", {
|
|
239
|
+
className: "progress-group-toggle-label",
|
|
240
|
+
children: progressGroupLabel
|
|
241
|
+
}),
|
|
242
|
+
/*#__PURE__*/ jsx(UpOutlined, {
|
|
243
|
+
className: "progress-group-toggle-chevron"
|
|
244
|
+
})
|
|
245
|
+
]
|
|
246
|
+
}) : null,
|
|
247
|
+
'user' === item.type ? /*#__PURE__*/ jsx("div", {
|
|
248
|
+
className: "user-message-container",
|
|
249
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
250
|
+
className: "user-message-bubble",
|
|
251
|
+
children: item.content
|
|
252
|
+
})
|
|
253
|
+
}) : 'progress' === item.type ? /*#__PURE__*/ jsx("div", {
|
|
254
|
+
children: (()=>{
|
|
255
|
+
var _parts_, _item_result, _item_result1, _item_result2;
|
|
256
|
+
const parts = item.content.split(' - ');
|
|
257
|
+
const action = null == (_parts_ = parts[0]) ? void 0 : _parts_.trim();
|
|
258
|
+
const description = parts.slice(1).join(' - ').trim();
|
|
259
|
+
const isLatestProgress = item.id === latestProgressId;
|
|
260
|
+
const shouldShowLoading = loading && isLatestProgress;
|
|
261
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
262
|
+
children: [
|
|
263
|
+
action && /*#__PURE__*/ jsxs("span", {
|
|
264
|
+
className: "progress-action-item",
|
|
265
|
+
children: [
|
|
266
|
+
action,
|
|
267
|
+
/*#__PURE__*/ jsx("span", {
|
|
268
|
+
className: `progress-status-icon ${shouldShowLoading ? 'loading' : (null == (_item_result = item.result) ? void 0 : _item_result.error) ? 'error' : 'completed'}`,
|
|
269
|
+
children: shouldShowLoading ? /*#__PURE__*/ jsx(LoadingOutlined, {
|
|
270
|
+
spin: true
|
|
271
|
+
}) : (null == (_item_result1 = item.result) ? void 0 : _item_result1.error) ? '✗' : '✓'
|
|
272
|
+
})
|
|
273
|
+
]
|
|
274
|
+
}),
|
|
275
|
+
description && /*#__PURE__*/ jsx("div", {
|
|
276
|
+
children: /*#__PURE__*/ jsx(shiny_text, {
|
|
277
|
+
text: description,
|
|
278
|
+
className: "progress-description",
|
|
279
|
+
disabled: !shouldShowLoading
|
|
214
280
|
})
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
children: /*#__PURE__*/ jsx(shiny_text, {
|
|
219
|
-
text: description,
|
|
220
|
-
className: "progress-description",
|
|
221
|
-
disabled: !shouldShowLoading
|
|
281
|
+
}),
|
|
282
|
+
(null == (_item_result2 = item.result) ? void 0 : _item_result2.error) && /*#__PURE__*/ jsx(ErrorMessage, {
|
|
283
|
+
error: item.result.error
|
|
222
284
|
})
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
285
|
+
]
|
|
286
|
+
});
|
|
287
|
+
})()
|
|
288
|
+
}) : 'separator' === item.type ? /*#__PURE__*/ jsxs("div", {
|
|
289
|
+
className: "new-conversation-separator",
|
|
290
|
+
children: [
|
|
291
|
+
/*#__PURE__*/ jsx("div", {
|
|
292
|
+
className: "separator-line"
|
|
293
|
+
}),
|
|
294
|
+
/*#__PURE__*/ jsx("div", {
|
|
295
|
+
className: "separator-text-container",
|
|
296
|
+
children: /*#__PURE__*/ jsx(Text, {
|
|
297
|
+
type: "secondary",
|
|
298
|
+
className: "separator-text",
|
|
299
|
+
children: item.content
|
|
226
300
|
})
|
|
227
|
-
]
|
|
228
|
-
});
|
|
229
|
-
})()
|
|
230
|
-
}) : 'separator' === item.type ? /*#__PURE__*/ jsxs("div", {
|
|
231
|
-
className: "new-conversation-separator",
|
|
232
|
-
children: [
|
|
233
|
-
/*#__PURE__*/ jsx("div", {
|
|
234
|
-
className: "separator-line"
|
|
235
|
-
}),
|
|
236
|
-
/*#__PURE__*/ jsx("div", {
|
|
237
|
-
className: "separator-text-container",
|
|
238
|
-
children: /*#__PURE__*/ jsx(Text, {
|
|
239
|
-
type: "secondary",
|
|
240
|
-
className: "separator-text",
|
|
241
|
-
children: item.content
|
|
242
301
|
})
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
className: "system-message-header",
|
|
250
|
-
children: [
|
|
251
|
-
/*#__PURE__*/ jsx(icons, {
|
|
252
|
-
component: branding.icon || avatar,
|
|
253
|
-
style: {
|
|
254
|
-
fontSize: 20
|
|
255
|
-
}
|
|
256
|
-
}),
|
|
257
|
-
/*#__PURE__*/ jsx("span", {
|
|
258
|
-
className: "system-message-title",
|
|
259
|
-
children: branding.title || 'Playground'
|
|
260
|
-
})
|
|
261
|
-
]
|
|
262
|
-
}),
|
|
263
|
-
(item.content || item.result) && /*#__PURE__*/ jsx("div", {
|
|
264
|
-
className: "system-message-content",
|
|
265
|
-
children: 'result' === item.type ? /*#__PURE__*/ jsx(PlaygroundResultView, {
|
|
266
|
-
result: item.result || null,
|
|
267
|
-
loading: item.loading || false,
|
|
268
|
-
serverValid: true,
|
|
269
|
-
serviceMode: serviceMode,
|
|
270
|
-
replayScriptsInfo: item.replayScriptsInfo || null,
|
|
271
|
-
replayCounter: item.replayCounter || 0,
|
|
272
|
-
loadingProgressText: item.loadingProgressText || '',
|
|
273
|
-
verticalMode: item.verticalMode || false,
|
|
274
|
-
fitMode: "width",
|
|
275
|
-
actionType: item.actionType
|
|
276
|
-
}) : /*#__PURE__*/ jsxs(Fragment, {
|
|
302
|
+
]
|
|
303
|
+
}) : /*#__PURE__*/ jsxs("div", {
|
|
304
|
+
className: "system-message-container",
|
|
305
|
+
children: [
|
|
306
|
+
false !== componentConfig.showSystemMessageHeader && /*#__PURE__*/ jsxs("div", {
|
|
307
|
+
className: "system-message-header",
|
|
277
308
|
children: [
|
|
278
|
-
/*#__PURE__*/ jsx(
|
|
279
|
-
|
|
280
|
-
|
|
309
|
+
/*#__PURE__*/ jsx(icons, {
|
|
310
|
+
component: branding.icon || avatar,
|
|
311
|
+
style: {
|
|
312
|
+
fontSize: 20
|
|
313
|
+
}
|
|
281
314
|
}),
|
|
282
|
-
|
|
283
|
-
className: "
|
|
284
|
-
children:
|
|
285
|
-
children: item.loadingProgressText
|
|
286
|
-
})
|
|
315
|
+
/*#__PURE__*/ jsx("span", {
|
|
316
|
+
className: "system-message-title",
|
|
317
|
+
children: branding.title || 'Playground'
|
|
287
318
|
})
|
|
288
319
|
]
|
|
320
|
+
}),
|
|
321
|
+
(item.content || item.result) && /*#__PURE__*/ jsx("div", {
|
|
322
|
+
className: "system-message-content",
|
|
323
|
+
children: 'result' === item.type ? /*#__PURE__*/ jsx(PlaygroundResultView, {
|
|
324
|
+
result: item.result || null,
|
|
325
|
+
loading: item.loading || false,
|
|
326
|
+
serverValid: true,
|
|
327
|
+
serviceMode: serviceMode,
|
|
328
|
+
replayScriptsInfo: item.replayScriptsInfo || null,
|
|
329
|
+
replayCounter: item.replayCounter || 0,
|
|
330
|
+
loadingProgressText: item.loadingProgressText || '',
|
|
331
|
+
verticalMode: item.verticalMode || false,
|
|
332
|
+
fitMode: "width",
|
|
333
|
+
actionType: item.actionType
|
|
334
|
+
}) : /*#__PURE__*/ jsxs(Fragment, {
|
|
335
|
+
children: [
|
|
336
|
+
/*#__PURE__*/ jsx("div", {
|
|
337
|
+
className: "system-message-text",
|
|
338
|
+
children: item.content
|
|
339
|
+
}),
|
|
340
|
+
item.loading && item.loadingProgressText && /*#__PURE__*/ jsx("div", {
|
|
341
|
+
className: "loading-progress-text",
|
|
342
|
+
children: /*#__PURE__*/ jsx("span", {
|
|
343
|
+
children: item.loadingProgressText
|
|
344
|
+
})
|
|
345
|
+
})
|
|
346
|
+
]
|
|
347
|
+
})
|
|
289
348
|
})
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
349
|
+
]
|
|
350
|
+
})
|
|
351
|
+
]
|
|
293
352
|
}, item.id)
|
|
294
353
|
})
|
|
295
354
|
}),
|
|
@@ -318,6 +377,7 @@ function UniversalPlayground({ playgroundSDK, storage, contextProvider, config:
|
|
|
318
377
|
onRun: handleFormRun,
|
|
319
378
|
onStop: handleStop,
|
|
320
379
|
actionSpace: actionSpace,
|
|
380
|
+
chrome: componentConfig.promptInputChrome,
|
|
321
381
|
deviceType: deviceType
|
|
322
382
|
})
|
|
323
383
|
]
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const actionNameForType = (type)=>{
|
|
2
|
+
if (!type) return '';
|
|
3
|
+
const typeWithoutAi = type.startsWith('ai') ? type.slice(2) : type;
|
|
4
|
+
if (typeWithoutAi.startsWith('IOS')) return typeWithoutAi.substring(3).replace(/([A-Z])/g, ' $1').replace(/^/, 'IOS').trim();
|
|
5
|
+
const fullName = typeWithoutAi.replace(/([A-Z])/g, ' $1').trim();
|
|
6
|
+
const words = fullName.split(' ');
|
|
7
|
+
const result = words.length > 3 ? words.slice(-3).join(' ') : fullName;
|
|
8
|
+
return result.replace(/\b\w/g, (c)=>c.toUpperCase());
|
|
9
|
+
};
|
|
10
|
+
const getPromptInputActionLabel = (type, overrideLabel)=>{
|
|
11
|
+
if (overrideLabel) return overrideLabel;
|
|
12
|
+
return actionNameForType(type) || 'Action';
|
|
13
|
+
};
|
|
14
|
+
export { actionNameForType, getPromptInputActionLabel };
|
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import { StaticPage, StaticPageAgent } from "@midscene/web/static";
|
|
2
2
|
import { isZodObjectSchema, unwrapZodType } from "../types.mjs";
|
|
3
|
-
|
|
4
|
-
if (!type) return '';
|
|
5
|
-
const typeWithoutAi = type.startsWith('ai') ? type.slice(2) : type;
|
|
6
|
-
if (typeWithoutAi.startsWith('IOS')) return typeWithoutAi.substring(3).replace(/([A-Z])/g, ' $1').replace(/^/, 'IOS').trim();
|
|
7
|
-
const fullName = typeWithoutAi.replace(/([A-Z])/g, ' $1').trim();
|
|
8
|
-
const words = fullName.split(' ');
|
|
9
|
-
const result = words.length > 3 ? words.slice(-3).join(' ') : fullName;
|
|
10
|
-
return result.replace(/\b\w/g, (c)=>c.toUpperCase());
|
|
11
|
-
};
|
|
3
|
+
import { actionNameForType } from "./action-label.mjs";
|
|
12
4
|
const staticAgentFromContext = (context)=>{
|
|
13
5
|
const page = new StaticPage(context);
|
|
14
6
|
return new StaticPageAgent(page);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { isLocateField, isZodObjectSchema, unwrapZodType } from "../types.mjs";
|
|
2
|
+
import { apiMetadata } from "./constants.mjs";
|
|
3
|
+
const getAvailablePromptActionTypes = (actionSpace)=>{
|
|
4
|
+
const metadataMethods = Object.keys(apiMetadata);
|
|
5
|
+
if (!(null == actionSpace ? void 0 : actionSpace.length)) return metadataMethods;
|
|
6
|
+
const availableMethods = actionSpace.map((action)=>action.interfaceAlias || action.name);
|
|
7
|
+
const supportsAiAct = availableMethods.includes('aiAct');
|
|
8
|
+
const finalMethods = new Set();
|
|
9
|
+
metadataMethods.forEach((method)=>{
|
|
10
|
+
const methodInfo = apiMetadata[method];
|
|
11
|
+
if ('aiAct' === method) {
|
|
12
|
+
if (supportsAiAct) finalMethods.add(method);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if ((null == methodInfo ? void 0 : methodInfo.group) === 'extraction' || (null == methodInfo ? void 0 : methodInfo.group) === 'validation') return void finalMethods.add(method);
|
|
16
|
+
if (availableMethods.includes(method)) finalMethods.add(method);
|
|
17
|
+
});
|
|
18
|
+
availableMethods.forEach((method)=>{
|
|
19
|
+
finalMethods.add(method);
|
|
20
|
+
});
|
|
21
|
+
return Array.from(finalMethods);
|
|
22
|
+
};
|
|
23
|
+
const getInlineStructuredFieldConfig = (actionSpace, selectedType)=>{
|
|
24
|
+
var _actualField__def, _actualField__def1;
|
|
25
|
+
if (!(null == actionSpace ? void 0 : actionSpace.length) || !selectedType) return null;
|
|
26
|
+
const action = actionSpace.find((item)=>item.interfaceAlias === selectedType || item.name === selectedType);
|
|
27
|
+
if (!(null == action ? void 0 : action.paramSchema) || !isZodObjectSchema(action.paramSchema)) return null;
|
|
28
|
+
const schema = action.paramSchema;
|
|
29
|
+
const shape = schema.shape || {};
|
|
30
|
+
const keys = Object.keys(shape);
|
|
31
|
+
if (1 !== keys.length) return null;
|
|
32
|
+
const [name] = keys;
|
|
33
|
+
const field = shape[name];
|
|
34
|
+
const { actualField } = unwrapZodType(field);
|
|
35
|
+
const isLocate = isLocateField(actualField);
|
|
36
|
+
const fieldType = null == (_actualField__def = actualField._def) ? void 0 : _actualField__def.typeName;
|
|
37
|
+
const isInlineField = 'ZodString' === fieldType || isLocate;
|
|
38
|
+
if (!isInlineField) return null;
|
|
39
|
+
const placeholder = (null == (_actualField__def1 = actualField._def) ? void 0 : _actualField__def1.description) || actualField.description || (isLocate ? 'Describe the element you want to interact with' : `Enter ${name}`);
|
|
40
|
+
return {
|
|
41
|
+
name,
|
|
42
|
+
placeholder
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
export { getAvailablePromptActionTypes, getInlineStructuredFieldConfig };
|
|
@@ -69,6 +69,19 @@ const cameraStateForRect = (rect, imageWidth, imageHeight)=>{
|
|
|
69
69
|
width: Math.round(cameraWidth)
|
|
70
70
|
};
|
|
71
71
|
};
|
|
72
|
+
const createFullPageCameraState = (imageWidth, imageHeight)=>cameraStateForRect({
|
|
73
|
+
left: 0,
|
|
74
|
+
top: 0,
|
|
75
|
+
width: imageWidth,
|
|
76
|
+
height: imageHeight
|
|
77
|
+
}, imageWidth, imageHeight);
|
|
78
|
+
const resolveTaskShotSize = (task, fallbackWidth, fallbackHeight)=>{
|
|
79
|
+
var _task_uiContext_shotSize, _task_uiContext, _task_uiContext_shotSize1, _task_uiContext1;
|
|
80
|
+
return {
|
|
81
|
+
width: (null == task ? void 0 : null == (_task_uiContext = task.uiContext) ? void 0 : null == (_task_uiContext_shotSize = _task_uiContext.shotSize) ? void 0 : _task_uiContext_shotSize.width) || fallbackWidth,
|
|
82
|
+
height: (null == task ? void 0 : null == (_task_uiContext1 = task.uiContext) ? void 0 : null == (_task_uiContext_shotSize1 = _task_uiContext1.shotSize) ? void 0 : _task_uiContext_shotSize1.height) || fallbackHeight
|
|
83
|
+
};
|
|
84
|
+
};
|
|
72
85
|
const mergeTwoCameraState = (cameraState1, cameraState2)=>{
|
|
73
86
|
const newLeft = Math.min(cameraState1.left, cameraState2.left);
|
|
74
87
|
const newTop = Math.min(cameraState1.top, cameraState2.top);
|
|
@@ -195,12 +208,6 @@ const generateAnimationScripts = (execution, task, imageWidth, imageHeight, exec
|
|
|
195
208
|
}
|
|
196
209
|
}
|
|
197
210
|
if (0 === tasksIncluded.length) return null;
|
|
198
|
-
const fullPageCameraState = cameraStateForRect({
|
|
199
|
-
left: 0,
|
|
200
|
-
top: 0,
|
|
201
|
-
width: imageWidth,
|
|
202
|
-
height: imageHeight
|
|
203
|
-
}, imageWidth, imageHeight);
|
|
204
211
|
const getTaskId = (taskIndex)=>{
|
|
205
212
|
var _tasksIncluded_taskIndex;
|
|
206
213
|
return null == (_tasksIncluded_taskIndex = tasksIncluded[taskIndex]) ? void 0 : _tasksIncluded_taskIndex.taskId;
|
|
@@ -323,7 +330,7 @@ const generateAnimationScripts = (execution, task, imageWidth, imageHeight, exec
|
|
|
323
330
|
}, asScreenshot(screenshot)));
|
|
324
331
|
}
|
|
325
332
|
} else if ('Action Space' === task.type) {
|
|
326
|
-
var _task_recorder_, _task_recorder
|
|
333
|
+
var _task_recorder_, _task_recorder;
|
|
327
334
|
const title = typeStr(task);
|
|
328
335
|
const subTitle = paramStr(task);
|
|
329
336
|
scripts.push({
|
|
@@ -345,14 +352,15 @@ const generateAnimationScripts = (execution, task, imageWidth, imageHeight, exec
|
|
|
345
352
|
}
|
|
346
353
|
scripts.push(setPointerScript(mousePointer, title, subTitle, currentTaskId));
|
|
347
354
|
const screenshot = null == (_task_recorder = task.recorder) ? void 0 : null == (_task_recorder_ = _task_recorder[0]) ? void 0 : _task_recorder_.screenshot;
|
|
355
|
+
const { width, height } = resolveTaskShotSize(task, imageWidth, imageHeight);
|
|
348
356
|
scripts.push(createScript({
|
|
349
357
|
type: 'img',
|
|
350
358
|
duration: actionDuration,
|
|
351
|
-
camera: 'Sleep' === task.subType ?
|
|
359
|
+
camera: 'Sleep' === task.subType ? createFullPageCameraState(width, height) : void 0,
|
|
352
360
|
title,
|
|
353
361
|
subTitle,
|
|
354
|
-
imageWidth:
|
|
355
|
-
imageHeight:
|
|
362
|
+
imageWidth: width,
|
|
363
|
+
imageHeight: height,
|
|
356
364
|
taskId: currentTaskId
|
|
357
365
|
}, asScreenshot(screenshot)));
|
|
358
366
|
} else {
|
|
@@ -361,33 +369,34 @@ const generateAnimationScripts = (execution, task, imageWidth, imageHeight, exec
|
|
|
361
369
|
const subTitle = paramStr(task);
|
|
362
370
|
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;
|
|
363
371
|
if (screenshot) {
|
|
364
|
-
|
|
372
|
+
const { width, height } = resolveTaskShotSize(task, imageWidth, imageHeight);
|
|
365
373
|
scripts.push(createScript({
|
|
366
374
|
type: 'img',
|
|
367
375
|
duration: stillDuration,
|
|
368
|
-
camera:
|
|
376
|
+
camera: createFullPageCameraState(width, height),
|
|
369
377
|
title,
|
|
370
378
|
subTitle,
|
|
371
|
-
imageWidth:
|
|
372
|
-
imageHeight:
|
|
379
|
+
imageWidth: width,
|
|
380
|
+
imageHeight: height,
|
|
373
381
|
taskId: currentTaskId
|
|
374
382
|
}, asScreenshot(screenshot)));
|
|
375
383
|
}
|
|
376
384
|
}
|
|
377
385
|
if ('finished' !== task.status) {
|
|
378
|
-
var _task_recorder_2, _task_recorder2
|
|
386
|
+
var _task_recorder_2, _task_recorder2;
|
|
379
387
|
const errorTitle = typeStr(task);
|
|
380
388
|
const errorMsg = task.errorMessage || 'unknown error';
|
|
381
389
|
const errorSubTitle = errorMsg.indexOf('NOT_IMPLEMENTED_AS_DESIGNED') > 0 ? 'Further actions cannot be performed in the current environment' : errorMsg;
|
|
382
390
|
const screenshot = null == (_task_recorder2 = task.recorder) ? void 0 : null == (_task_recorder_2 = _task_recorder2[task.recorder.length - 1]) ? void 0 : _task_recorder_2.screenshot;
|
|
391
|
+
const { width, height } = resolveTaskShotSize(task, imageWidth, imageHeight);
|
|
383
392
|
scripts.push(createScript({
|
|
384
393
|
type: 'img',
|
|
385
|
-
camera:
|
|
394
|
+
camera: createFullPageCameraState(width, height),
|
|
386
395
|
duration: stillDuration,
|
|
387
396
|
title: errorTitle,
|
|
388
397
|
subTitle: errorSubTitle,
|
|
389
|
-
imageWidth:
|
|
390
|
-
imageHeight:
|
|
398
|
+
imageWidth: width,
|
|
399
|
+
imageHeight: height,
|
|
391
400
|
taskId: currentTaskId
|
|
392
401
|
}, asScreenshot(screenshot)));
|
|
393
402
|
}
|
|
@@ -402,12 +411,16 @@ const generateAnimationScripts = (execution, task, imageWidth, imageHeight, exec
|
|
|
402
411
|
});
|
|
403
412
|
insightOnTop = false;
|
|
404
413
|
}
|
|
414
|
+
const lastTaskShotSize = tasksIncluded.length > 0 ? resolveTaskShotSize(tasksIncluded[tasksIncluded.length - 1], imageWidth, imageHeight) : {
|
|
415
|
+
width: imageWidth,
|
|
416
|
+
height: imageHeight
|
|
417
|
+
};
|
|
405
418
|
scripts.push({
|
|
406
419
|
title: 'End',
|
|
407
420
|
subTitle: initSubTitle,
|
|
408
421
|
type: 'img',
|
|
409
422
|
duration: lastFrameDuration,
|
|
410
|
-
camera:
|
|
423
|
+
camera: createFullPageCameraState(lastTaskShotSize.width, lastTaskShotSize.height),
|
|
411
424
|
taskId: void 0
|
|
412
425
|
});
|
|
413
426
|
return scripts;
|
|
@@ -42,7 +42,7 @@ var setting_js_default = /*#__PURE__*/ __webpack_require__.n(setting_js_namespac
|
|
|
42
42
|
const store_js_namespaceObject = require("../../store/store.js");
|
|
43
43
|
const constants_js_namespaceObject = require("../../utils/constants.js");
|
|
44
44
|
const device_capabilities_js_namespaceObject = require("../../utils/device-capabilities.js");
|
|
45
|
-
const ConfigSelector = ({ showDeepLocateOption = false, showDeepThinkOption = false, enableTracking = false, showDataExtractionOptions = false, hideDomAndScreenshotOptions = false, deviceType })=>{
|
|
45
|
+
const ConfigSelector = ({ showDeepLocateOption = false, showDeepThinkOption = false, enableTracking = false, showDataExtractionOptions = false, hideDomAndScreenshotOptions = false, deviceType, trigger })=>{
|
|
46
46
|
const forceSameTabNavigation = (0, store_js_namespaceObject.useEnvConfig)((state)=>state.forceSameTabNavigation);
|
|
47
47
|
const setForceSameTabNavigation = (0, store_js_namespaceObject.useEnvConfig)((state)=>state.setForceSameTabNavigation);
|
|
48
48
|
const deepLocate = (0, store_js_namespaceObject.useEnvConfig)((state)=>state.deepLocate);
|
|
@@ -74,7 +74,7 @@ const ConfigSelector = ({ showDeepLocateOption = false, showDeepThinkOption = fa
|
|
|
74
74
|
trigger: [
|
|
75
75
|
'click'
|
|
76
76
|
],
|
|
77
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(setting_js_default(), {
|
|
77
|
+
children: null != trigger ? trigger : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(setting_js_default(), {
|
|
78
78
|
width: 24,
|
|
79
79
|
height: 24
|
|
80
80
|
})
|