@sqaitech/visualizer 0.30.10
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/LICENSE +21 -0
- package/README.md +9 -0
- package/dist/es/component/blackboard/index.css +33 -0
- package/dist/es/component/blackboard/index.mjs +278 -0
- package/dist/es/component/config-selector/index.mjs +104 -0
- package/dist/es/component/context-preview/index.mjs +38 -0
- package/dist/es/component/env-config/index.mjs +112 -0
- package/dist/es/component/env-config-reminder/index.css +22 -0
- package/dist/es/component/env-config-reminder/index.mjs +28 -0
- package/dist/es/component/form-field/index.mjs +163 -0
- package/dist/es/component/history-selector/index.css +135 -0
- package/dist/es/component/history-selector/index.mjs +170 -0
- package/dist/es/component/index.mjs +1 -0
- package/dist/es/component/logo/index.css +13 -0
- package/dist/es/component/logo/index.mjs +20 -0
- package/dist/es/component/misc/index.mjs +94 -0
- package/dist/es/component/nav-actions/index.mjs +32 -0
- package/dist/es/component/nav-actions/style.css +35 -0
- package/dist/es/component/player/index.css +185 -0
- package/dist/es/component/player/index.mjs +856 -0
- package/dist/es/component/playground/index.css +431 -0
- package/dist/es/component/playground/index.mjs +8 -0
- package/dist/es/component/playground/playground-demo-ui-context.json +290 -0
- package/dist/es/component/playground-result/index.css +34 -0
- package/dist/es/component/playground-result/index.mjs +62 -0
- package/dist/es/component/prompt-input/index.css +391 -0
- package/dist/es/component/prompt-input/index.mjs +730 -0
- package/dist/es/component/service-mode-control/index.mjs +105 -0
- package/dist/es/component/shiny-text/index.css +75 -0
- package/dist/es/component/shiny-text/index.mjs +15 -0
- package/dist/es/component/universal-playground/index.css +341 -0
- package/dist/es/component/universal-playground/index.mjs +302 -0
- package/dist/es/component/universal-playground/providers/context-provider.mjs +52 -0
- package/dist/es/component/universal-playground/providers/indexeddb-storage-provider.mjs +207 -0
- package/dist/es/component/universal-playground/providers/storage-provider.mjs +210 -0
- package/dist/es/hooks/usePlaygroundExecution.mjs +180 -0
- package/dist/es/hooks/usePlaygroundState.mjs +203 -0
- package/dist/es/hooks/useSafeOverrideAIConfig.mjs +24 -0
- package/dist/es/hooks/useServerValid.mjs +30 -0
- package/dist/es/icons/avatar.mjs +28 -0
- package/dist/es/icons/close.mjs +19 -0
- package/dist/es/icons/global-perspective.mjs +16 -0
- package/dist/es/icons/history.mjs +30 -0
- package/dist/es/icons/magnifying-glass.mjs +39 -0
- package/dist/es/icons/player-setting.mjs +26 -0
- package/dist/es/icons/setting.mjs +20 -0
- package/dist/es/icons/show-marker.mjs +16 -0
- package/dist/es/index.mjs +25 -0
- package/dist/es/store/history.mjs +89 -0
- package/dist/es/store/store.mjs +186 -0
- package/dist/es/types.mjs +70 -0
- package/dist/es/utils/color.mjs +35 -0
- package/dist/es/utils/constants.mjs +99 -0
- package/dist/es/utils/index.mjs +10 -0
- package/dist/es/utils/pixi-loader.mjs +16 -0
- package/dist/es/utils/playground-utils.mjs +67 -0
- package/dist/es/utils/replay-scripts.mjs +312 -0
- package/dist/lib/component/blackboard/index.css +33 -0
- package/dist/lib/component/blackboard/index.js +321 -0
- package/dist/lib/component/config-selector/index.js +148 -0
- package/dist/lib/component/context-preview/index.js +83 -0
- package/dist/lib/component/env-config/index.js +146 -0
- package/dist/lib/component/env-config-reminder/index.css +22 -0
- package/dist/lib/component/env-config-reminder/index.js +62 -0
- package/dist/lib/component/form-field/index.js +209 -0
- package/dist/lib/component/history-selector/index.css +135 -0
- package/dist/lib/component/history-selector/index.js +216 -0
- package/dist/lib/component/index.js +60 -0
- package/dist/lib/component/logo/index.css +13 -0
- package/dist/lib/component/logo/index.js +57 -0
- package/dist/lib/component/misc/index.js +150 -0
- package/dist/lib/component/nav-actions/index.js +66 -0
- package/dist/lib/component/nav-actions/style.css +35 -0
- package/dist/lib/component/player/index.css +185 -0
- package/dist/lib/component/player/index.js +902 -0
- package/dist/lib/component/playground/index.css +431 -0
- package/dist/lib/component/playground/index.js +113 -0
- package/dist/lib/component/playground/playground-demo-ui-context.json +290 -0
- package/dist/lib/component/playground-result/index.css +34 -0
- package/dist/lib/component/playground-result/index.js +106 -0
- package/dist/lib/component/prompt-input/index.css +391 -0
- package/dist/lib/component/prompt-input/index.js +774 -0
- package/dist/lib/component/service-mode-control/index.js +139 -0
- package/dist/lib/component/shiny-text/index.css +75 -0
- package/dist/lib/component/shiny-text/index.js +49 -0
- package/dist/lib/component/universal-playground/index.css +341 -0
- package/dist/lib/component/universal-playground/index.js +350 -0
- package/dist/lib/component/universal-playground/providers/context-provider.js +95 -0
- package/dist/lib/component/universal-playground/providers/indexeddb-storage-provider.js +247 -0
- package/dist/lib/component/universal-playground/providers/storage-provider.js +268 -0
- package/dist/lib/hooks/usePlaygroundExecution.js +214 -0
- package/dist/lib/hooks/usePlaygroundState.js +237 -0
- package/dist/lib/hooks/useSafeOverrideAIConfig.js +61 -0
- package/dist/lib/hooks/useServerValid.js +64 -0
- package/dist/lib/icons/avatar.js +62 -0
- package/dist/lib/icons/close.js +53 -0
- package/dist/lib/icons/global-perspective.js +50 -0
- package/dist/lib/icons/history.js +64 -0
- package/dist/lib/icons/magnifying-glass.js +73 -0
- package/dist/lib/icons/player-setting.js +60 -0
- package/dist/lib/icons/setting.js +54 -0
- package/dist/lib/icons/show-marker.js +50 -0
- package/dist/lib/index.js +187 -0
- package/dist/lib/store/history.js +96 -0
- package/dist/lib/store/store.js +196 -0
- package/dist/lib/types.js +116 -0
- package/dist/lib/utils/color.js +75 -0
- package/dist/lib/utils/constants.js +154 -0
- package/dist/lib/utils/index.js +63 -0
- package/dist/lib/utils/pixi-loader.js +56 -0
- package/dist/lib/utils/playground-utils.js +110 -0
- package/dist/lib/utils/replay-scripts.js +355 -0
- package/dist/types/component/blackboard/index.d.ts +15 -0
- package/dist/types/component/config-selector/index.d.ts +9 -0
- package/dist/types/component/context-preview/index.d.ts +9 -0
- package/dist/types/component/env-config/index.d.ts +6 -0
- package/dist/types/component/env-config-reminder/index.d.ts +6 -0
- package/dist/types/component/form-field/index.d.ts +17 -0
- package/dist/types/component/history-selector/index.d.ts +10 -0
- package/dist/types/component/index.d.ts +1 -0
- package/dist/types/component/logo/index.d.ts +5 -0
- package/dist/types/component/misc/index.d.ts +6 -0
- package/dist/types/component/nav-actions/index.d.ts +10 -0
- package/dist/types/component/player/index.d.ts +13 -0
- package/dist/types/component/playground/index.d.ts +7 -0
- package/dist/types/component/playground-result/index.d.ts +20 -0
- package/dist/types/component/prompt-input/index.d.ts +22 -0
- package/dist/types/component/service-mode-control/index.d.ts +6 -0
- package/dist/types/component/shiny-text/index.d.ts +12 -0
- package/dist/types/component/universal-playground/index.d.ts +4 -0
- package/dist/types/component/universal-playground/providers/context-provider.d.ts +37 -0
- package/dist/types/component/universal-playground/providers/indexeddb-storage-provider.d.ts +71 -0
- package/dist/types/component/universal-playground/providers/storage-provider.d.ts +58 -0
- package/dist/types/hooks/usePlaygroundExecution.d.ts +10 -0
- package/dist/types/hooks/usePlaygroundState.d.ts +26 -0
- package/dist/types/hooks/useSafeOverrideAIConfig.d.ts +16 -0
- package/dist/types/hooks/useServerValid.d.ts +1 -0
- package/dist/types/index.d.ts +27 -0
- package/dist/types/store/history.d.ts +16 -0
- package/dist/types/store/store.d.ts +36 -0
- package/dist/types/types.d.ts +161 -0
- package/dist/types/utils/color.d.ts +4 -0
- package/dist/types/utils/constants.d.ts +74 -0
- package/dist/types/utils/index.d.ts +4 -0
- package/dist/types/utils/pixi-loader.d.ts +5 -0
- package/dist/types/utils/playground-utils.d.ts +6 -0
- package/dist/types/utils/replay-scripts.d.ts +34 -0
- package/package.json +85 -0
|
@@ -0,0 +1,774 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: definition[key]
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
})();
|
|
20
|
+
(()=>{
|
|
21
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
+
})();
|
|
23
|
+
(()=>{
|
|
24
|
+
__webpack_require__.r = (exports1)=>{
|
|
25
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
+
value: 'Module'
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
+
value: true
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
})();
|
|
33
|
+
var __webpack_exports__ = {};
|
|
34
|
+
__webpack_require__.r(__webpack_exports__);
|
|
35
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
+
PromptInput: ()=>PromptInput
|
|
37
|
+
});
|
|
38
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
39
|
+
const icons_namespaceObject = require("@ant-design/icons");
|
|
40
|
+
require("./index.css");
|
|
41
|
+
const external_antd_namespaceObject = require("antd");
|
|
42
|
+
const external_react_namespaceObject = require("react");
|
|
43
|
+
var external_react_default = /*#__PURE__*/ __webpack_require__.n(external_react_namespaceObject);
|
|
44
|
+
const history_js_namespaceObject = require("../../store/history.js");
|
|
45
|
+
const external_types_js_namespaceObject = require("../../types.js");
|
|
46
|
+
const constants_js_namespaceObject = require("../../utils/constants.js");
|
|
47
|
+
const playground_utils_js_namespaceObject = require("../../utils/playground-utils.js");
|
|
48
|
+
const index_js_namespaceObject = require("../config-selector/index.js");
|
|
49
|
+
const external_form_field_index_js_namespaceObject = require("../form-field/index.js");
|
|
50
|
+
const external_history_selector_index_js_namespaceObject = require("../history-selector/index.js");
|
|
51
|
+
const { TextArea } = external_antd_namespaceObject.Input;
|
|
52
|
+
const PromptInput = (param)=>{
|
|
53
|
+
let { runButtonEnabled, form, serviceMode, selectedType, dryMode, stoppable, loading, onRun, onStop, clearPromptAfterRun = true, actionSpace, hideDomAndScreenshotOptions = false } = param;
|
|
54
|
+
const [hoveringSettings, setHoveringSettings] = (0, external_react_namespaceObject.useState)(false);
|
|
55
|
+
const [promptValue, setPromptValue] = (0, external_react_namespaceObject.useState)('');
|
|
56
|
+
const placeholder = (0, playground_utils_js_namespaceObject.getPlaceholderForType)(selectedType);
|
|
57
|
+
const textAreaRef = (0, external_react_namespaceObject.useRef)(null);
|
|
58
|
+
const modeRadioGroupRef = (0, external_react_namespaceObject.useRef)(null);
|
|
59
|
+
const params = external_antd_namespaceObject.Form.useWatch('params', form);
|
|
60
|
+
const lastHistoryRef = (0, external_react_namespaceObject.useRef)(null);
|
|
61
|
+
const history = (0, history_js_namespaceObject.useHistoryStore)((state)=>state.history);
|
|
62
|
+
const lastSelectedType = (0, history_js_namespaceObject.useHistoryStore)((state)=>state.lastSelectedType);
|
|
63
|
+
const addHistory = (0, history_js_namespaceObject.useHistoryStore)((state)=>state.addHistory);
|
|
64
|
+
const setLastSelectedType = (0, history_js_namespaceObject.useHistoryStore)((state)=>state.setLastSelectedType);
|
|
65
|
+
const historyForSelectedType = (0, external_react_namespaceObject.useMemo)(()=>history[selectedType] || [], [
|
|
66
|
+
history,
|
|
67
|
+
selectedType
|
|
68
|
+
]);
|
|
69
|
+
const needsStructuredParams = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
70
|
+
if (actionSpace) {
|
|
71
|
+
const action = actionSpace.find((a)=>a.interfaceAlias === selectedType || a.name === selectedType);
|
|
72
|
+
if (!(null == action ? void 0 : action.paramSchema)) return false;
|
|
73
|
+
if ((0, external_types_js_namespaceObject.isZodObjectSchema)(action.paramSchema)) {
|
|
74
|
+
const schema = action.paramSchema;
|
|
75
|
+
const shape = schema.shape || {};
|
|
76
|
+
const shapeKeys = Object.keys(shape);
|
|
77
|
+
return shapeKeys.length > 0;
|
|
78
|
+
}
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
return false;
|
|
82
|
+
}, [
|
|
83
|
+
selectedType,
|
|
84
|
+
actionSpace
|
|
85
|
+
]);
|
|
86
|
+
const needsAnyInput = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
87
|
+
if (actionSpace && actionSpace.length > 0) {
|
|
88
|
+
const action = actionSpace.find((a)=>a.interfaceAlias === selectedType || a.name === selectedType);
|
|
89
|
+
if (action) {
|
|
90
|
+
if (action.paramSchema && (0, external_types_js_namespaceObject.isZodObjectSchema)(action.paramSchema)) {
|
|
91
|
+
const schema = action.paramSchema;
|
|
92
|
+
const shape = schema.shape || {};
|
|
93
|
+
const hasRequiredFields = Object.keys(shape).some((key)=>{
|
|
94
|
+
const field = shape[key];
|
|
95
|
+
const { isOptional } = (0, external_types_js_namespaceObject.unwrapZodType)(field);
|
|
96
|
+
return !isOptional;
|
|
97
|
+
});
|
|
98
|
+
return hasRequiredFields;
|
|
99
|
+
}
|
|
100
|
+
return !!action.paramSchema;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return true;
|
|
104
|
+
}, [
|
|
105
|
+
selectedType,
|
|
106
|
+
actionSpace
|
|
107
|
+
]);
|
|
108
|
+
const showDataExtractionOptions = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
109
|
+
const dataExtractionMethods = [
|
|
110
|
+
'aiQuery',
|
|
111
|
+
'aiBoolean',
|
|
112
|
+
'aiNumber',
|
|
113
|
+
'aiString',
|
|
114
|
+
'aiAsk',
|
|
115
|
+
'aiAssert'
|
|
116
|
+
];
|
|
117
|
+
return dataExtractionMethods.includes(selectedType);
|
|
118
|
+
}, [
|
|
119
|
+
selectedType
|
|
120
|
+
]);
|
|
121
|
+
const showDeepThinkOption = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
122
|
+
if ('aiLocate' === selectedType) return true;
|
|
123
|
+
if (actionSpace) {
|
|
124
|
+
const action = actionSpace.find((a)=>a.interfaceAlias === selectedType || a.name === selectedType);
|
|
125
|
+
if ((null == action ? void 0 : action.paramSchema) && (0, external_types_js_namespaceObject.isZodObjectSchema)(action.paramSchema)) {
|
|
126
|
+
const schema = action.paramSchema;
|
|
127
|
+
const shape = schema.shape || {};
|
|
128
|
+
const hasLocateField = Object.keys(shape).some((key)=>{
|
|
129
|
+
const field = shape[key];
|
|
130
|
+
const { actualField } = (0, external_types_js_namespaceObject.unwrapZodType)(field);
|
|
131
|
+
return (0, external_types_js_namespaceObject.isLocateField)(actualField);
|
|
132
|
+
});
|
|
133
|
+
return hasLocateField;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return false;
|
|
137
|
+
}, [
|
|
138
|
+
selectedType,
|
|
139
|
+
actionSpace
|
|
140
|
+
]);
|
|
141
|
+
const hasConfigOptions = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
142
|
+
const hasTracking = 'In-Browser-Extension' === serviceMode;
|
|
143
|
+
const hasDeepThink = showDeepThinkOption;
|
|
144
|
+
const hasDataExtraction = showDataExtractionOptions && !hideDomAndScreenshotOptions;
|
|
145
|
+
return hasTracking || hasDeepThink || hasDataExtraction;
|
|
146
|
+
}, [
|
|
147
|
+
serviceMode,
|
|
148
|
+
showDeepThinkOption,
|
|
149
|
+
showDataExtractionOptions,
|
|
150
|
+
hideDomAndScreenshotOptions
|
|
151
|
+
]);
|
|
152
|
+
const availableDropdownMethods = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
153
|
+
const metadataMethods = Object.keys(constants_js_namespaceObject.apiMetadata);
|
|
154
|
+
if (!actionSpace || 0 === actionSpace.length) return metadataMethods;
|
|
155
|
+
const availableMethods = actionSpace.map((action)=>action.interfaceAlias || action.name);
|
|
156
|
+
const finalMethods = new Set();
|
|
157
|
+
metadataMethods.forEach((method)=>{
|
|
158
|
+
const methodInfo = constants_js_namespaceObject.apiMetadata[method];
|
|
159
|
+
if ((null == methodInfo ? void 0 : methodInfo.group) === 'extraction' || (null == methodInfo ? void 0 : methodInfo.group) === 'validation') finalMethods.add(method);
|
|
160
|
+
else if (availableMethods.includes(method)) finalMethods.add(method);
|
|
161
|
+
});
|
|
162
|
+
availableMethods.forEach((method)=>{
|
|
163
|
+
finalMethods.add(method);
|
|
164
|
+
});
|
|
165
|
+
return Array.from(finalMethods);
|
|
166
|
+
}, [
|
|
167
|
+
actionSpace
|
|
168
|
+
]);
|
|
169
|
+
const getDefaultParams = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
170
|
+
if (!needsStructuredParams || !actionSpace) return {};
|
|
171
|
+
const action = actionSpace.find((a)=>a.interfaceAlias === selectedType || a.name === selectedType);
|
|
172
|
+
if ((null == action ? void 0 : action.paramSchema) && (0, external_types_js_namespaceObject.isZodObjectSchema)(action.paramSchema)) {
|
|
173
|
+
const defaultParams = {};
|
|
174
|
+
const schema = action.paramSchema;
|
|
175
|
+
const shape = schema.shape || {};
|
|
176
|
+
Object.keys(shape).forEach((key)=>{
|
|
177
|
+
const field = shape[key];
|
|
178
|
+
const defaultValue = (0, external_types_js_namespaceObject.extractDefaultValue)(field);
|
|
179
|
+
if (void 0 !== defaultValue) defaultParams[key] = defaultValue;
|
|
180
|
+
});
|
|
181
|
+
return defaultParams;
|
|
182
|
+
}
|
|
183
|
+
return {};
|
|
184
|
+
}, [
|
|
185
|
+
selectedType,
|
|
186
|
+
needsStructuredParams,
|
|
187
|
+
actionSpace
|
|
188
|
+
]);
|
|
189
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
190
|
+
if (!form.getFieldValue('type') && lastSelectedType) form.setFieldValue('type', lastSelectedType);
|
|
191
|
+
}, [
|
|
192
|
+
form,
|
|
193
|
+
lastSelectedType
|
|
194
|
+
]);
|
|
195
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
196
|
+
if (selectedType && selectedType !== lastSelectedType) setLastSelectedType(selectedType);
|
|
197
|
+
}, [
|
|
198
|
+
selectedType,
|
|
199
|
+
lastSelectedType,
|
|
200
|
+
setLastSelectedType
|
|
201
|
+
]);
|
|
202
|
+
const scrollToSelectedItem = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
203
|
+
const container = modeRadioGroupRef.current;
|
|
204
|
+
if (!container) return;
|
|
205
|
+
let targetElement = null;
|
|
206
|
+
const selectedRadioButton = container.querySelector('.ant-radio-button-wrapper-checked');
|
|
207
|
+
const dropdownButton = container.querySelector('.more-apis-button.selected-from-dropdown');
|
|
208
|
+
if (selectedRadioButton) targetElement = selectedRadioButton;
|
|
209
|
+
else if (dropdownButton) targetElement = dropdownButton;
|
|
210
|
+
if (targetElement) {
|
|
211
|
+
const containerRect = container.getBoundingClientRect();
|
|
212
|
+
const targetRect = targetElement.getBoundingClientRect();
|
|
213
|
+
const targetLeft = targetRect.left - containerRect.left + container.scrollLeft;
|
|
214
|
+
const targetWidth = targetRect.width;
|
|
215
|
+
const containerWidth = containerRect.width;
|
|
216
|
+
const optimalScrollLeft = targetLeft - (containerWidth - targetWidth) / 2;
|
|
217
|
+
container.scrollTo({
|
|
218
|
+
left: Math.max(0, optimalScrollLeft),
|
|
219
|
+
behavior: 'smooth'
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}, []);
|
|
223
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
224
|
+
const lastHistory = historyForSelectedType[0];
|
|
225
|
+
if (lastHistory && lastHistoryRef.current && lastHistory.timestamp === lastHistoryRef.current.timestamp) return;
|
|
226
|
+
if (lastHistory) {
|
|
227
|
+
form.setFieldsValue({
|
|
228
|
+
type: lastHistory.type,
|
|
229
|
+
prompt: lastHistory.prompt || '',
|
|
230
|
+
params: lastHistory.params
|
|
231
|
+
});
|
|
232
|
+
setPromptValue(lastHistory.prompt || '');
|
|
233
|
+
lastHistoryRef.current = lastHistory;
|
|
234
|
+
} else {
|
|
235
|
+
const defaultParams = getDefaultParams();
|
|
236
|
+
form.setFieldsValue({
|
|
237
|
+
prompt: '',
|
|
238
|
+
params: defaultParams
|
|
239
|
+
});
|
|
240
|
+
setPromptValue('');
|
|
241
|
+
lastHistoryRef.current = null;
|
|
242
|
+
}
|
|
243
|
+
}, [
|
|
244
|
+
selectedType,
|
|
245
|
+
historyForSelectedType,
|
|
246
|
+
form,
|
|
247
|
+
getDefaultParams
|
|
248
|
+
]);
|
|
249
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
250
|
+
const timeoutId = setTimeout(()=>{
|
|
251
|
+
scrollToSelectedItem();
|
|
252
|
+
}, 100);
|
|
253
|
+
return ()=>clearTimeout(timeoutId);
|
|
254
|
+
}, [
|
|
255
|
+
selectedType,
|
|
256
|
+
scrollToSelectedItem
|
|
257
|
+
]);
|
|
258
|
+
const formPromptValue = external_antd_namespaceObject.Form.useWatch('prompt', form);
|
|
259
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
260
|
+
if (formPromptValue !== promptValue) setPromptValue(formPromptValue || '');
|
|
261
|
+
}, [
|
|
262
|
+
formPromptValue,
|
|
263
|
+
promptValue
|
|
264
|
+
]);
|
|
265
|
+
const handleSelectHistory = (0, external_react_namespaceObject.useCallback)((historyItem)=>{
|
|
266
|
+
form.setFieldsValue({
|
|
267
|
+
prompt: historyItem.prompt,
|
|
268
|
+
type: historyItem.type,
|
|
269
|
+
params: historyItem.params
|
|
270
|
+
});
|
|
271
|
+
setPromptValue(historyItem.prompt);
|
|
272
|
+
}, [
|
|
273
|
+
form
|
|
274
|
+
]);
|
|
275
|
+
const handlePromptChange = (0, external_react_namespaceObject.useCallback)((e)=>{
|
|
276
|
+
const value = e.target.value;
|
|
277
|
+
setPromptValue(value);
|
|
278
|
+
}, []);
|
|
279
|
+
const hasSingleStructuredParam = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
280
|
+
if (!needsStructuredParams || !actionSpace) return false;
|
|
281
|
+
const action = actionSpace.find((a)=>a.interfaceAlias === selectedType || a.name === selectedType);
|
|
282
|
+
if ((null == action ? void 0 : action.paramSchema) && (0, external_types_js_namespaceObject.isZodObjectSchema)(action.paramSchema)) {
|
|
283
|
+
const schema = action.paramSchema;
|
|
284
|
+
const shape = schema.shape || {};
|
|
285
|
+
return 1 === Object.keys(shape).length;
|
|
286
|
+
}
|
|
287
|
+
return false;
|
|
288
|
+
}, [
|
|
289
|
+
selectedType,
|
|
290
|
+
needsStructuredParams,
|
|
291
|
+
actionSpace
|
|
292
|
+
]);
|
|
293
|
+
const isRunButtonEnabled = (0, external_react_namespaceObject.useMemo)(()=>(0, playground_utils_js_namespaceObject.isRunButtonEnabled)(runButtonEnabled, !!needsStructuredParams, params, actionSpace, selectedType, promptValue), [
|
|
294
|
+
runButtonEnabled,
|
|
295
|
+
needsStructuredParams,
|
|
296
|
+
selectedType,
|
|
297
|
+
actionSpace,
|
|
298
|
+
promptValue,
|
|
299
|
+
params
|
|
300
|
+
]);
|
|
301
|
+
const handleRunWithHistory = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
302
|
+
const values = form.getFieldsValue();
|
|
303
|
+
let historyPrompt = '';
|
|
304
|
+
if (needsStructuredParams && values.params && actionSpace) {
|
|
305
|
+
const action = actionSpace.find((a)=>a.interfaceAlias === selectedType || a.name === selectedType);
|
|
306
|
+
if ((null == action ? void 0 : action.paramSchema) && (0, external_types_js_namespaceObject.isZodObjectSchema)(action.paramSchema)) {
|
|
307
|
+
let locateValue = '';
|
|
308
|
+
const otherValues = [];
|
|
309
|
+
const schema = action.paramSchema;
|
|
310
|
+
const shape = schema.shape || {};
|
|
311
|
+
Object.keys(shape).forEach((key)=>{
|
|
312
|
+
var _values_params;
|
|
313
|
+
const paramValue = null == (_values_params = values.params) ? void 0 : _values_params[key];
|
|
314
|
+
if (null != paramValue && '' !== paramValue) {
|
|
315
|
+
const field = shape[key];
|
|
316
|
+
const { actualField } = (0, external_types_js_namespaceObject.unwrapZodType)(field);
|
|
317
|
+
if ((0, external_types_js_namespaceObject.isLocateField)(actualField)) locateValue = String(paramValue);
|
|
318
|
+
else if ('distance' === key) otherValues.push(`${paramValue}`);
|
|
319
|
+
else otherValues.push(String(paramValue));
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
const mainPart = otherValues.join(' ');
|
|
323
|
+
historyPrompt = locateValue ? `${locateValue} - ${mainPart}` : mainPart;
|
|
324
|
+
} else historyPrompt = values.prompt || '';
|
|
325
|
+
} else historyPrompt = values.prompt || '';
|
|
326
|
+
const newHistoryItem = {
|
|
327
|
+
type: values.type,
|
|
328
|
+
prompt: historyPrompt,
|
|
329
|
+
params: values.params,
|
|
330
|
+
timestamp: Date.now()
|
|
331
|
+
};
|
|
332
|
+
addHistory(newHistoryItem);
|
|
333
|
+
onRun();
|
|
334
|
+
if (clearPromptAfterRun) {
|
|
335
|
+
lastHistoryRef.current = newHistoryItem;
|
|
336
|
+
setPromptValue('');
|
|
337
|
+
if (needsStructuredParams) {
|
|
338
|
+
const defaultParams = getDefaultParams();
|
|
339
|
+
form.setFieldValue('params', defaultParams);
|
|
340
|
+
} else form.setFieldValue('prompt', '');
|
|
341
|
+
}
|
|
342
|
+
}, [
|
|
343
|
+
form,
|
|
344
|
+
addHistory,
|
|
345
|
+
onRun,
|
|
346
|
+
needsStructuredParams,
|
|
347
|
+
selectedType,
|
|
348
|
+
clearPromptAfterRun,
|
|
349
|
+
actionSpace,
|
|
350
|
+
getDefaultParams
|
|
351
|
+
]);
|
|
352
|
+
const handleKeyDown = (0, external_react_namespaceObject.useCallback)((e)=>{
|
|
353
|
+
if ('Enter' === e.key && e.metaKey && isRunButtonEnabled) {
|
|
354
|
+
handleRunWithHistory();
|
|
355
|
+
e.preventDefault();
|
|
356
|
+
e.stopPropagation();
|
|
357
|
+
} else if ('Enter' === e.key) setTimeout(()=>{
|
|
358
|
+
if (textAreaRef.current) {
|
|
359
|
+
var _textAreaRef_current_resizableTextArea;
|
|
360
|
+
const textarea = null == (_textAreaRef_current_resizableTextArea = textAreaRef.current.resizableTextArea) ? void 0 : _textAreaRef_current_resizableTextArea.textArea;
|
|
361
|
+
if (textarea) {
|
|
362
|
+
const selectionStart = textarea.selectionStart;
|
|
363
|
+
const value = textarea.value;
|
|
364
|
+
const lastNewlineIndex = value.lastIndexOf('\n');
|
|
365
|
+
const isAtLastLine = -1 === lastNewlineIndex || selectionStart > lastNewlineIndex;
|
|
366
|
+
if (isAtLastLine) textarea.scrollTop = textarea.scrollHeight;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}, 0);
|
|
370
|
+
}, [
|
|
371
|
+
handleRunWithHistory,
|
|
372
|
+
isRunButtonEnabled
|
|
373
|
+
]);
|
|
374
|
+
const handleStructuredKeyDown = (0, external_react_namespaceObject.useCallback)((e)=>{
|
|
375
|
+
if ('Enter' === e.key && e.metaKey && isRunButtonEnabled) {
|
|
376
|
+
handleRunWithHistory();
|
|
377
|
+
e.preventDefault();
|
|
378
|
+
e.stopPropagation();
|
|
379
|
+
}
|
|
380
|
+
}, [
|
|
381
|
+
handleRunWithHistory,
|
|
382
|
+
isRunButtonEnabled
|
|
383
|
+
]);
|
|
384
|
+
const renderStructuredParams = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
385
|
+
if (!needsStructuredParams) return null;
|
|
386
|
+
if (actionSpace) {
|
|
387
|
+
const action = actionSpace.find((a)=>a.interfaceAlias === selectedType || a.name === selectedType);
|
|
388
|
+
if ((null == action ? void 0 : action.paramSchema) && (0, external_types_js_namespaceObject.isZodObjectSchema)(action.paramSchema)) {
|
|
389
|
+
const schema = action.paramSchema;
|
|
390
|
+
const shape = schema.shape || {};
|
|
391
|
+
const schemaKeys = Object.keys(shape);
|
|
392
|
+
if (1 === schemaKeys.length) {
|
|
393
|
+
const key = schemaKeys[0];
|
|
394
|
+
const field = shape[key];
|
|
395
|
+
const { actualField } = (0, external_types_js_namespaceObject.unwrapZodType)(field);
|
|
396
|
+
const isLocateFieldFlag = (0, external_types_js_namespaceObject.isLocateField)(actualField);
|
|
397
|
+
const placeholderText = (()=>{
|
|
398
|
+
var _fieldWithRuntime__def;
|
|
399
|
+
const fieldWithRuntime = actualField;
|
|
400
|
+
if (null == (_fieldWithRuntime__def = fieldWithRuntime._def) ? void 0 : _fieldWithRuntime__def.description) return fieldWithRuntime._def.description;
|
|
401
|
+
if (fieldWithRuntime.description) return fieldWithRuntime.description;
|
|
402
|
+
if (actionSpace) {
|
|
403
|
+
const action = actionSpace.find((a)=>a.interfaceAlias === selectedType || a.name === selectedType);
|
|
404
|
+
if ((null == action ? void 0 : action.paramSchema) && 'object' == typeof action.paramSchema && 'shape' in action.paramSchema) {
|
|
405
|
+
var _fieldDef__def;
|
|
406
|
+
const shape = action.paramSchema.shape || {};
|
|
407
|
+
const fieldDef = shape[key];
|
|
408
|
+
if (null == fieldDef ? void 0 : null == (_fieldDef__def = fieldDef._def) ? void 0 : _fieldDef__def.description) return fieldDef._def.description;
|
|
409
|
+
if (null == fieldDef ? void 0 : fieldDef.description) return fieldDef.description;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
if (isLocateFieldFlag) return 'Describe the element you want to interact with';
|
|
413
|
+
if ('keyName' === key) return 'Enter key name or text to type';
|
|
414
|
+
if ('value' === key) return 'Enter text to input';
|
|
415
|
+
return `Enter ${key}`;
|
|
416
|
+
})();
|
|
417
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Form.Item, {
|
|
418
|
+
name: [
|
|
419
|
+
'params',
|
|
420
|
+
key
|
|
421
|
+
],
|
|
422
|
+
style: {
|
|
423
|
+
margin: 0
|
|
424
|
+
},
|
|
425
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Input.TextArea, {
|
|
426
|
+
className: "main-side-console-input-textarea",
|
|
427
|
+
rows: 4,
|
|
428
|
+
placeholder: placeholderText,
|
|
429
|
+
autoFocus: true,
|
|
430
|
+
onKeyDown: handleStructuredKeyDown
|
|
431
|
+
})
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
const fields = [];
|
|
435
|
+
const sortedKeys = schemaKeys.sort((keyA, keyB)=>{
|
|
436
|
+
const fieldSchemaA = shape[keyA];
|
|
437
|
+
const fieldSchemaB = shape[keyB];
|
|
438
|
+
const { isOptional: isOptionalA } = (0, external_types_js_namespaceObject.unwrapZodType)(fieldSchemaA);
|
|
439
|
+
const { isOptional: isOptionalB } = (0, external_types_js_namespaceObject.unwrapZodType)(fieldSchemaB);
|
|
440
|
+
if (!isOptionalA && isOptionalB) return -1;
|
|
441
|
+
if (isOptionalA && !isOptionalB) return 1;
|
|
442
|
+
return 0;
|
|
443
|
+
});
|
|
444
|
+
sortedKeys.forEach((key, index)=>{
|
|
445
|
+
var _actualField__def, _actualField__def1, _actualField__def2;
|
|
446
|
+
const fieldSchema = shape[key];
|
|
447
|
+
const { actualField, isOptional } = (0, external_types_js_namespaceObject.unwrapZodType)(fieldSchema);
|
|
448
|
+
const isLocateFieldFlag = (0, external_types_js_namespaceObject.isLocateField)(actualField);
|
|
449
|
+
const label = key.charAt(0).toUpperCase() + key.slice(1);
|
|
450
|
+
const isRequired = !isOptional;
|
|
451
|
+
const marginBottom = index === sortedKeys.length - 1 ? 0 : 12;
|
|
452
|
+
const placeholder = (()=>{
|
|
453
|
+
var _fieldWithRuntime__def;
|
|
454
|
+
const fieldWithRuntime = actualField;
|
|
455
|
+
if (null == (_fieldWithRuntime__def = fieldWithRuntime._def) ? void 0 : _fieldWithRuntime__def.description) return fieldWithRuntime._def.description;
|
|
456
|
+
if (fieldWithRuntime.description) return fieldWithRuntime.description;
|
|
457
|
+
if (actionSpace) {
|
|
458
|
+
const action = actionSpace.find((a)=>a.interfaceAlias === selectedType || a.name === selectedType);
|
|
459
|
+
if ((null == action ? void 0 : action.paramSchema) && 'object' == typeof action.paramSchema && 'shape' in action.paramSchema) {
|
|
460
|
+
var _fieldDef__def;
|
|
461
|
+
const shape = action.paramSchema.shape || {};
|
|
462
|
+
const fieldDef = shape[key];
|
|
463
|
+
if (null == fieldDef ? void 0 : null == (_fieldDef__def = fieldDef._def) ? void 0 : _fieldDef__def.description) return fieldDef._def.description;
|
|
464
|
+
if (null == fieldDef ? void 0 : fieldDef.description) return fieldDef.description;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
if (isLocateFieldFlag) return 'Describe the element you want to interact with';
|
|
468
|
+
})();
|
|
469
|
+
const fieldProps = {
|
|
470
|
+
name: key,
|
|
471
|
+
label,
|
|
472
|
+
fieldSchema: actualField,
|
|
473
|
+
isRequired,
|
|
474
|
+
marginBottom,
|
|
475
|
+
placeholder
|
|
476
|
+
};
|
|
477
|
+
if (isLocateFieldFlag) fields.push(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_form_field_index_js_namespaceObject.LocateField, {
|
|
478
|
+
...fieldProps
|
|
479
|
+
}, key));
|
|
480
|
+
else if ((null == (_actualField__def = actualField._def) ? void 0 : _actualField__def.typeName) === 'ZodEnum') fields.push(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_form_field_index_js_namespaceObject.EnumField, {
|
|
481
|
+
...fieldProps
|
|
482
|
+
}, key));
|
|
483
|
+
else if ((null == (_actualField__def1 = actualField._def) ? void 0 : _actualField__def1.typeName) === 'ZodNumber') fields.push(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_form_field_index_js_namespaceObject.NumberField, {
|
|
484
|
+
...fieldProps
|
|
485
|
+
}, key));
|
|
486
|
+
else if ((null == (_actualField__def2 = actualField._def) ? void 0 : _actualField__def2.typeName) === 'ZodBoolean') fields.push(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_form_field_index_js_namespaceObject.BooleanField, {
|
|
487
|
+
...fieldProps
|
|
488
|
+
}, key));
|
|
489
|
+
else fields.push(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_form_field_index_js_namespaceObject.TextField, {
|
|
490
|
+
...fieldProps
|
|
491
|
+
}, key));
|
|
492
|
+
});
|
|
493
|
+
if ('aiScroll' === selectedType) {
|
|
494
|
+
const directionField = fields.find((field)=>/*#__PURE__*/ external_react_default().isValidElement(field) && 'direction' === field.props.name);
|
|
495
|
+
const distanceField = fields.find((field)=>/*#__PURE__*/ external_react_default().isValidElement(field) && 'distance' === field.props.name);
|
|
496
|
+
const otherFields = fields.filter((field)=>/*#__PURE__*/ external_react_default().isValidElement(field) && 'direction' !== field.props.name && 'distance' !== field.props.name);
|
|
497
|
+
if (directionField && distanceField) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
498
|
+
className: "structured-params",
|
|
499
|
+
children: [
|
|
500
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
501
|
+
style: {
|
|
502
|
+
display: 'flex',
|
|
503
|
+
gap: 12,
|
|
504
|
+
marginBottom: 12
|
|
505
|
+
},
|
|
506
|
+
children: [
|
|
507
|
+
directionField,
|
|
508
|
+
distanceField
|
|
509
|
+
]
|
|
510
|
+
}),
|
|
511
|
+
otherFields
|
|
512
|
+
]
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
516
|
+
className: "structured-params",
|
|
517
|
+
children: fields
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
return null;
|
|
522
|
+
}, [
|
|
523
|
+
selectedType,
|
|
524
|
+
needsStructuredParams,
|
|
525
|
+
actionSpace,
|
|
526
|
+
handleStructuredKeyDown
|
|
527
|
+
]);
|
|
528
|
+
const handleMouseEnter = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
529
|
+
setHoveringSettings(true);
|
|
530
|
+
}, []);
|
|
531
|
+
const handleMouseLeave = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
532
|
+
setHoveringSettings(false);
|
|
533
|
+
}, []);
|
|
534
|
+
const renderActionButton = (0, external_react_namespaceObject.useCallback)(()=>{
|
|
535
|
+
const runButton = (text)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Button, {
|
|
536
|
+
type: "primary",
|
|
537
|
+
icon: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icons_namespaceObject.SendOutlined, {}),
|
|
538
|
+
style: {
|
|
539
|
+
borderRadius: 20,
|
|
540
|
+
zIndex: 999
|
|
541
|
+
},
|
|
542
|
+
onClick: handleRunWithHistory,
|
|
543
|
+
disabled: !isRunButtonEnabled,
|
|
544
|
+
loading: loading,
|
|
545
|
+
children: text
|
|
546
|
+
});
|
|
547
|
+
if (dryMode) return 'aiAction' === selectedType ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Tooltip, {
|
|
548
|
+
title: "Start executing until some interaction actions need to be performed. You can see the process of planning and locating.",
|
|
549
|
+
children: runButton('Dry Run')
|
|
550
|
+
}) : runButton('Run');
|
|
551
|
+
if (stoppable) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Button, {
|
|
552
|
+
icon: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icons_namespaceObject.BorderOutlined, {}),
|
|
553
|
+
onClick: onStop,
|
|
554
|
+
style: {
|
|
555
|
+
borderRadius: 20,
|
|
556
|
+
zIndex: 999
|
|
557
|
+
},
|
|
558
|
+
children: "Stop"
|
|
559
|
+
});
|
|
560
|
+
return runButton('Run');
|
|
561
|
+
}, [
|
|
562
|
+
dryMode,
|
|
563
|
+
loading,
|
|
564
|
+
handleRunWithHistory,
|
|
565
|
+
onStop,
|
|
566
|
+
isRunButtonEnabled,
|
|
567
|
+
selectedType,
|
|
568
|
+
stoppable
|
|
569
|
+
]);
|
|
570
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
571
|
+
className: "prompt-input-wrapper",
|
|
572
|
+
children: [
|
|
573
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
574
|
+
className: "mode-radio-group-wrapper",
|
|
575
|
+
children: [
|
|
576
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
577
|
+
className: "mode-radio-group",
|
|
578
|
+
ref: modeRadioGroupRef,
|
|
579
|
+
children: [
|
|
580
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Form.Item, {
|
|
581
|
+
name: "type",
|
|
582
|
+
style: {
|
|
583
|
+
margin: 0
|
|
584
|
+
},
|
|
585
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Radio.Group, {
|
|
586
|
+
buttonStyle: "solid",
|
|
587
|
+
disabled: !runButtonEnabled,
|
|
588
|
+
children: constants_js_namespaceObject.defaultMainButtons.map((apiType)=>{
|
|
589
|
+
var _apiMetadata_apiType;
|
|
590
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Tooltip, {
|
|
591
|
+
title: (null == (_apiMetadata_apiType = constants_js_namespaceObject.apiMetadata[apiType]) ? void 0 : _apiMetadata_apiType.title) || '',
|
|
592
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Radio.Button, {
|
|
593
|
+
value: apiType,
|
|
594
|
+
children: (0, playground_utils_js_namespaceObject.actionNameForType)(apiType)
|
|
595
|
+
})
|
|
596
|
+
}, apiType);
|
|
597
|
+
})
|
|
598
|
+
})
|
|
599
|
+
}),
|
|
600
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Dropdown, {
|
|
601
|
+
menu: (()=>{
|
|
602
|
+
const hiddenAPIs = availableDropdownMethods.filter((api)=>!constants_js_namespaceObject.defaultMainButtons.includes(api));
|
|
603
|
+
const groupedItems = [];
|
|
604
|
+
const interactionAPIs = hiddenAPIs.filter((api)=>{
|
|
605
|
+
var _apiMetadata_api;
|
|
606
|
+
return (null == (_apiMetadata_api = constants_js_namespaceObject.apiMetadata[api]) ? void 0 : _apiMetadata_api.group) === 'interaction';
|
|
607
|
+
});
|
|
608
|
+
if (interactionAPIs.length > 0) groupedItems.push({
|
|
609
|
+
key: 'interaction-group',
|
|
610
|
+
type: 'group',
|
|
611
|
+
label: 'Interaction APIs',
|
|
612
|
+
children: interactionAPIs.map((api)=>{
|
|
613
|
+
var _apiMetadata_api;
|
|
614
|
+
return {
|
|
615
|
+
key: api,
|
|
616
|
+
label: (0, playground_utils_js_namespaceObject.actionNameForType)(api),
|
|
617
|
+
title: (null == (_apiMetadata_api = constants_js_namespaceObject.apiMetadata[api]) ? void 0 : _apiMetadata_api.title) || '',
|
|
618
|
+
onClick: ()=>{
|
|
619
|
+
form.setFieldValue('type', api);
|
|
620
|
+
}
|
|
621
|
+
};
|
|
622
|
+
})
|
|
623
|
+
});
|
|
624
|
+
const extractionAPIs = hiddenAPIs.filter((api)=>{
|
|
625
|
+
var _apiMetadata_api;
|
|
626
|
+
return (null == (_apiMetadata_api = constants_js_namespaceObject.apiMetadata[api]) ? void 0 : _apiMetadata_api.group) === 'extraction';
|
|
627
|
+
});
|
|
628
|
+
if (extractionAPIs.length > 0) groupedItems.push({
|
|
629
|
+
key: 'extraction-group',
|
|
630
|
+
type: 'group',
|
|
631
|
+
label: 'Data Extraction APIs',
|
|
632
|
+
children: extractionAPIs.map((api)=>{
|
|
633
|
+
var _apiMetadata_api;
|
|
634
|
+
return {
|
|
635
|
+
key: api,
|
|
636
|
+
label: (0, playground_utils_js_namespaceObject.actionNameForType)(api),
|
|
637
|
+
title: (null == (_apiMetadata_api = constants_js_namespaceObject.apiMetadata[api]) ? void 0 : _apiMetadata_api.title) || '',
|
|
638
|
+
onClick: ()=>{
|
|
639
|
+
form.setFieldValue('type', api);
|
|
640
|
+
}
|
|
641
|
+
};
|
|
642
|
+
})
|
|
643
|
+
});
|
|
644
|
+
const validationAPIs = hiddenAPIs.filter((api)=>{
|
|
645
|
+
var _apiMetadata_api;
|
|
646
|
+
return (null == (_apiMetadata_api = constants_js_namespaceObject.apiMetadata[api]) ? void 0 : _apiMetadata_api.group) === 'validation';
|
|
647
|
+
});
|
|
648
|
+
if (validationAPIs.length > 0) groupedItems.push({
|
|
649
|
+
key: 'validation-group',
|
|
650
|
+
type: 'group',
|
|
651
|
+
label: 'Validation APIs',
|
|
652
|
+
children: validationAPIs.map((api)=>{
|
|
653
|
+
var _apiMetadata_api;
|
|
654
|
+
return {
|
|
655
|
+
key: api,
|
|
656
|
+
label: (0, playground_utils_js_namespaceObject.actionNameForType)(api),
|
|
657
|
+
title: (null == (_apiMetadata_api = constants_js_namespaceObject.apiMetadata[api]) ? void 0 : _apiMetadata_api.title) || '',
|
|
658
|
+
onClick: ()=>{
|
|
659
|
+
form.setFieldValue('type', api);
|
|
660
|
+
}
|
|
661
|
+
};
|
|
662
|
+
})
|
|
663
|
+
});
|
|
664
|
+
const deviceSpecificAPIs = hiddenAPIs.filter((api)=>!constants_js_namespaceObject.apiMetadata[api]);
|
|
665
|
+
if (deviceSpecificAPIs.length > 0) groupedItems.push({
|
|
666
|
+
key: 'device-specific-group',
|
|
667
|
+
type: 'group',
|
|
668
|
+
label: 'Device-Specific APIs',
|
|
669
|
+
children: deviceSpecificAPIs.map((api)=>({
|
|
670
|
+
key: api,
|
|
671
|
+
label: (0, playground_utils_js_namespaceObject.actionNameForType)(api),
|
|
672
|
+
title: '',
|
|
673
|
+
onClick: ()=>{
|
|
674
|
+
form.setFieldValue('type', api);
|
|
675
|
+
}
|
|
676
|
+
}))
|
|
677
|
+
});
|
|
678
|
+
return {
|
|
679
|
+
items: groupedItems
|
|
680
|
+
};
|
|
681
|
+
})(),
|
|
682
|
+
placement: "bottomLeft",
|
|
683
|
+
trigger: [
|
|
684
|
+
'click'
|
|
685
|
+
],
|
|
686
|
+
disabled: !runButtonEnabled,
|
|
687
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_antd_namespaceObject.Button, {
|
|
688
|
+
className: `more-apis-button ${!constants_js_namespaceObject.defaultMainButtons.includes(selectedType) ? 'selected-from-dropdown' : ''}`,
|
|
689
|
+
children: [
|
|
690
|
+
selectedType && !constants_js_namespaceObject.defaultMainButtons.includes(selectedType) ? (0, playground_utils_js_namespaceObject.actionNameForType)(selectedType) : 'more',
|
|
691
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icons_namespaceObject.DownOutlined, {
|
|
692
|
+
style: {
|
|
693
|
+
fontSize: '10px',
|
|
694
|
+
marginLeft: '2px'
|
|
695
|
+
}
|
|
696
|
+
})
|
|
697
|
+
]
|
|
698
|
+
})
|
|
699
|
+
})
|
|
700
|
+
]
|
|
701
|
+
}),
|
|
702
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
703
|
+
className: "action-icons",
|
|
704
|
+
children: [
|
|
705
|
+
hasConfigOptions && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
706
|
+
className: hoveringSettings ? 'settings-wrapper settings-wrapper-hover' : 'settings-wrapper',
|
|
707
|
+
onMouseEnter: handleMouseEnter,
|
|
708
|
+
onMouseLeave: handleMouseLeave,
|
|
709
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_js_namespaceObject.ConfigSelector, {
|
|
710
|
+
enableTracking: 'In-Browser-Extension' === serviceMode,
|
|
711
|
+
showDeepThinkOption: showDeepThinkOption,
|
|
712
|
+
showDataExtractionOptions: showDataExtractionOptions,
|
|
713
|
+
hideDomAndScreenshotOptions: hideDomAndScreenshotOptions
|
|
714
|
+
})
|
|
715
|
+
}),
|
|
716
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_history_selector_index_js_namespaceObject.HistorySelector, {
|
|
717
|
+
onSelect: handleSelectHistory,
|
|
718
|
+
history: historyForSelectedType,
|
|
719
|
+
currentType: selectedType
|
|
720
|
+
})
|
|
721
|
+
]
|
|
722
|
+
})
|
|
723
|
+
]
|
|
724
|
+
}),
|
|
725
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
726
|
+
className: `main-side-console-input ${!runButtonEnabled ? 'disabled' : ''} ${loading ? 'loading' : ''}`,
|
|
727
|
+
children: [
|
|
728
|
+
needsAnyInput ? needsStructuredParams ? hasSingleStructuredParam ? renderStructuredParams() : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
729
|
+
className: "structured-params-container",
|
|
730
|
+
children: renderStructuredParams()
|
|
731
|
+
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Form.Item, {
|
|
732
|
+
name: "prompt",
|
|
733
|
+
style: {
|
|
734
|
+
margin: 0
|
|
735
|
+
},
|
|
736
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(TextArea, {
|
|
737
|
+
className: "main-side-console-input-textarea",
|
|
738
|
+
disabled: !runButtonEnabled,
|
|
739
|
+
rows: 4,
|
|
740
|
+
placeholder: placeholder,
|
|
741
|
+
autoFocus: true,
|
|
742
|
+
onKeyDown: handleKeyDown,
|
|
743
|
+
onChange: handlePromptChange,
|
|
744
|
+
ref: textAreaRef
|
|
745
|
+
})
|
|
746
|
+
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
747
|
+
className: "no-input-method",
|
|
748
|
+
style: {
|
|
749
|
+
padding: '20px',
|
|
750
|
+
textAlign: 'center',
|
|
751
|
+
color: '#666',
|
|
752
|
+
fontSize: '14px'
|
|
753
|
+
},
|
|
754
|
+
children: [
|
|
755
|
+
'Click "Run" to execute ',
|
|
756
|
+
(0, playground_utils_js_namespaceObject.actionNameForType)(selectedType)
|
|
757
|
+
]
|
|
758
|
+
}),
|
|
759
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
760
|
+
className: "form-controller-wrapper",
|
|
761
|
+
children: renderActionButton()
|
|
762
|
+
})
|
|
763
|
+
]
|
|
764
|
+
})
|
|
765
|
+
]
|
|
766
|
+
});
|
|
767
|
+
};
|
|
768
|
+
exports.PromptInput = __webpack_exports__.PromptInput;
|
|
769
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
770
|
+
"PromptInput"
|
|
771
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
772
|
+
Object.defineProperty(exports, '__esModule', {
|
|
773
|
+
value: true
|
|
774
|
+
});
|