@blocklet/pages-kit 0.2.362 → 0.2.364
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/lib/cjs/builtin/async/ai-runtime/hooks/use-appearances.js +4 -4
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/AutoForm/index.js +4 -3
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/builtin/async/ai-runtime/hooks/use-appearances.js +6 -6
- package/lib/esm/builtin/async/ai-runtime/runtime-components/AutoForm/index.js +4 -3
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/lib/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
|
@@ -53,17 +53,17 @@ function useAppearances(args) {
|
|
|
53
53
|
}, [agent, runtimeAgent]);
|
|
54
54
|
return { appearancePage, appearanceInput, appearanceOutput };
|
|
55
55
|
}
|
|
56
|
-
function getProjectIconUrl(
|
|
57
|
-
return (0, ufo_1.joinURL)(window.location.origin, (0, utils_1.getComponentMountPoint)(constants_1.
|
|
56
|
+
function getProjectIconUrl({ blockletDid, aid }) {
|
|
57
|
+
return (0, ufo_1.withQuery)((0, ufo_1.joinURL)(window.location.origin, (0, utils_1.getComponentMountPoint)(constants_1.AI_RUNTIME_DID), '/api/agents', aid, '/logo'), { blockletDid });
|
|
58
58
|
}
|
|
59
59
|
function useProfile(args) {
|
|
60
|
-
const { agent: runtimeAgent } = (0, runtime_1.useRuntimeState)();
|
|
60
|
+
const { blockletDid, aid, agent: runtimeAgent } = (0, runtime_1.useRuntimeState)();
|
|
61
61
|
const { agent } = (0, CurrentAgent_1.useCurrentAgent)(args);
|
|
62
62
|
return (0, react_1.useMemo)(() => {
|
|
63
63
|
const profile = (0, runtime_output_schema_1.getOutputVariableInitialValue)(agent, types_1.RuntimeOutputVariable.profile);
|
|
64
64
|
const runtimeProfile = (0, runtime_output_schema_1.getOutputVariableInitialValue)(runtimeAgent, types_1.RuntimeOutputVariable.profile);
|
|
65
65
|
return {
|
|
66
|
-
avatar: (profile === null || profile === void 0 ? void 0 : profile.avatar) || (runtimeProfile === null || runtimeProfile === void 0 ? void 0 : runtimeProfile.avatar) || getProjectIconUrl(
|
|
66
|
+
avatar: (profile === null || profile === void 0 ? void 0 : profile.avatar) || (runtimeProfile === null || runtimeProfile === void 0 ? void 0 : runtimeProfile.avatar) || getProjectIconUrl({ blockletDid, aid }),
|
|
67
67
|
name: (profile === null || profile === void 0 ? void 0 : profile.name) || (runtimeProfile === null || runtimeProfile === void 0 ? void 0 : runtimeProfile.name) || agent.name,
|
|
68
68
|
};
|
|
69
69
|
}, [agent, runtimeAgent]);
|
|
@@ -42,6 +42,7 @@ function AutoForm({ submitText, inlineLabel, autoFillLastForm = true, submitInQu
|
|
|
42
42
|
}, [agent.parameters]);
|
|
43
43
|
const defaultForm = useInitialFormValues();
|
|
44
44
|
const form = (0, react_hook_form_1.useForm)({ defaultValues: defaultForm });
|
|
45
|
+
const submitDisabled = !form.formState.isValid;
|
|
45
46
|
(0, react_1.useEffect)(() => {
|
|
46
47
|
if (autoFillLastForm && !form.formState.isSubmitted && !form.formState.isSubmitting) {
|
|
47
48
|
form.reset(chatMode ? (0, omit_1.default)(defaultForm, 'question') : defaultForm);
|
|
@@ -62,7 +63,7 @@ function AutoForm({ submitText, inlineLabel, autoFillLastForm = true, submitInQu
|
|
|
62
63
|
return ((0, jsx_runtime_1.jsxs)(Form, { component: "form", className: (0, css_1.cx)('form', `label-position-${inlineLabel ? 'start' : 'top'}`), onSubmit: form.handleSubmit(onSubmit), children: [parameters === null || parameters === void 0 ? void 0 : parameters.map((parameter, index) => {
|
|
63
64
|
const { key, required } = parameter !== null && parameter !== void 0 ? parameter : {};
|
|
64
65
|
return ((0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(react_hook_form_1.Controller, { control: form.control, name: key, rules: {
|
|
65
|
-
required,
|
|
66
|
+
required: required || key === 'question',
|
|
66
67
|
min: parameter.type === 'number' && typeof parameter.min === 'number'
|
|
67
68
|
? { value: parameter.min, message: '' }
|
|
68
69
|
: undefined,
|
|
@@ -79,11 +80,11 @@ function AutoForm({ submitText, inlineLabel, autoFillLastForm = true, submitInQu
|
|
|
79
80
|
var _a;
|
|
80
81
|
return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { className: "form-item", children: [parameter.label && (0, jsx_runtime_1.jsx)(material_1.FormLabel, { children: parameter.label }), (0, jsx_runtime_1.jsx)(AgentInputField_1.default, { inputRef: field.ref, autoFocus: index === 0, size: "small", hiddenLabel: true, fullWidth: true, label: undefined, parameter: parameter, maxRows: !(parameter === null || parameter === void 0 ? void 0 : parameter.type) || (parameter === null || parameter === void 0 ? void 0 : parameter.type) === 'string' ? 5 : undefined, value: field.value || '', onChange: (value) => field.onChange({ target: { value } }), error: Boolean(fieldState.error), helperText: ((_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message) || (parameter === null || parameter === void 0 ? void 0 : parameter.helper), InputProps: parameter.key === 'question' && submitInQuestionField
|
|
81
82
|
? {
|
|
82
|
-
endAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, { position: "end", sx: { py: 3, mr: -0.75, alignSelf: 'flex-end' }, children: (0, jsx_runtime_1.jsx)(LoadingButton_1.default, { ref: submitRef, type: "submit", variant: "contained", loading: running, sx: { borderRadius: 1.5 }, children: submitText }) })),
|
|
83
|
+
endAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, { position: "end", sx: { py: 3, mr: -0.75, alignSelf: 'flex-end' }, children: (0, jsx_runtime_1.jsx)(LoadingButton_1.default, { ref: submitRef, type: "submit", variant: "contained", loading: running, disabled: submitDisabled, sx: { borderRadius: 1.5 }, children: submitText }) })),
|
|
83
84
|
}
|
|
84
85
|
: undefined })] }));
|
|
85
86
|
} }) }, parameter.id));
|
|
86
|
-
}), !(submitInQuestionField && (parameters === null || parameters === void 0 ? void 0 : parameters.some((i) => i.key === 'question'))) && ((0, jsx_runtime_1.jsx)(LoadingButton_1.default, { ref: submitRef, type: "submit", variant: "contained", loading: running, sx: { height: 40 }, children: submitText || t('generate') }))] }));
|
|
87
|
+
}), !(submitInQuestionField && (parameters === null || parameters === void 0 ? void 0 : parameters.some((i) => i.key === 'question'))) && ((0, jsx_runtime_1.jsx)(LoadingButton_1.default, { ref: submitRef, type: "submit", variant: "contained", loading: running, disabled: submitDisabled, sx: { height: 40 }, children: submitText || t('generate') }))] }));
|
|
87
88
|
}
|
|
88
89
|
function useInitialFormValues() {
|
|
89
90
|
const { agent } = (0, CurrentAgent_1.useCurrentAgent)();
|