@blocklet/pages-kit 0.2.363 → 0.2.365
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/components/AgentErrorBoundary.js +2 -2
- package/lib/cjs/builtin/async/ai-runtime/contexts/ComponentPreferences.js +7 -2
- package/lib/cjs/builtin/async/ai-runtime/index.js +4 -1
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/AutoForm/index.js +19 -5
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/MessageView.js +3 -3
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/index.js +25 -2
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleOutput/index.js +12 -8
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimplePage/index.js +4 -2
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/types/index.js +1 -0
- package/lib/cjs/utils/inject-global-components.js +2 -0
- package/lib/esm/builtin/async/ai-runtime/components/AgentErrorBoundary.js +2 -2
- package/lib/esm/builtin/async/ai-runtime/contexts/ComponentPreferences.js +4 -2
- package/lib/esm/builtin/async/ai-runtime/index.js +2 -0
- package/lib/esm/builtin/async/ai-runtime/runtime-components/AutoForm/index.js +19 -5
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/MessageView.js +4 -4
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/index.js +1 -1
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleOutput/index.js +14 -10
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SimplePage/index.js +4 -2
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/types/index.js +1 -0
- package/lib/esm/utils/inject-global-components.js +2 -0
- package/lib/types/builtin/async/ai-runtime/components/AgentErrorBoundary.d.ts +4 -1
- package/lib/types/builtin/async/ai-runtime/contexts/ComponentPreferences.d.ts +9 -3
- package/lib/types/builtin/async/ai-runtime/index.d.ts +2 -0
- package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/index.d.ts +2 -2
- package/lib/types/builtin/async/ai-runtime/runtime-components/SimplePage/index.d.ts +5 -2
- package/lib/types/tsconfig.tsbuildinfo +1 -1
- package/lib/types/types/index.d.ts +1 -0
- package/package.json +14 -7
|
@@ -11,8 +11,8 @@ const locale_1 = require("../../../locale");
|
|
|
11
11
|
const use_agent_admin_1 = require("../hooks/use-agent-admin");
|
|
12
12
|
const runtime_1 = require("../state/runtime");
|
|
13
13
|
const AgentSettingsDialog_1 = require("./AgentSettings/AgentSettingsDialog");
|
|
14
|
-
function AgentErrorBoundary() {
|
|
15
|
-
return (0, jsx_runtime_1.jsx)(react_error_boundary_1.ErrorBoundary, { FallbackComponent: AgentErrorView });
|
|
14
|
+
function AgentErrorBoundary({ children }) {
|
|
15
|
+
return (0, jsx_runtime_1.jsx)(react_error_boundary_1.ErrorBoundary, { FallbackComponent: AgentErrorView, children: children });
|
|
16
16
|
}
|
|
17
17
|
function AgentErrorView({ error }) {
|
|
18
18
|
if (error.type === 'MissingSecretError') {
|
|
@@ -10,15 +10,20 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
}
|
|
11
11
|
return t;
|
|
12
12
|
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
13
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.
|
|
17
|
+
exports.default = ComponentPreferencesProvider;
|
|
15
18
|
exports.useComponentPreferences = useComponentPreferences;
|
|
16
19
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
20
|
+
const omitBy_1 = __importDefault(require("lodash/omitBy"));
|
|
17
21
|
const react_1 = require("react");
|
|
18
22
|
const componentPreferencesContext = (0, react_1.createContext)(undefined);
|
|
19
23
|
function ComponentPreferencesProvider(_a) {
|
|
20
24
|
var { children } = _a, preferences = __rest(_a, ["children"]);
|
|
21
|
-
const
|
|
25
|
+
const inherited = useComponentPreferences();
|
|
26
|
+
const value = (0, react_1.useMemo)(() => (Object.assign(Object.assign({}, inherited), (0, omitBy_1.default)(preferences, (i) => i === undefined || i === null))), [inherited, Object.values(preferences)]);
|
|
22
27
|
return (0, jsx_runtime_1.jsx)(componentPreferencesContext.Provider, { value: value, children: children });
|
|
23
28
|
}
|
|
24
29
|
function useComponentPreferences() {
|
|
@@ -17,7 +17,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.MarkdownView = exports.GoogleSearchSourcesView = exports.GoogleSearchRelatedQuestionsView = exports.ImagesView = exports.OpeningQuestionsView = exports.ShareView = exports.ReferencedLinksView = exports.SuggestedQuestionsView = exports.PhotoGalleryItem = exports.ChatOutput = exports.SimpleOutput = exports.AutoForm = exports.PhotoGallery = exports.SimpleChat = exports.SimplePage = exports.ChatBotButton = exports.Runtime = exports.CurrentMessageProvider = exports.CurrentAgentProvider = void 0;
|
|
20
|
+
exports.MarkdownView = exports.GoogleSearchSourcesView = exports.GoogleSearchRelatedQuestionsView = exports.ImagesView = exports.OpeningQuestionsView = exports.ShareView = exports.ReferencedLinksView = exports.SuggestedQuestionsView = exports.PhotoGalleryItem = exports.ChatOutput = exports.SimpleOutput = exports.AutoForm = exports.PhotoGallery = exports.SimpleChat = exports.SimplePage = exports.ChatBotButton = exports.Runtime = exports.CurrentMessageProvider = exports.CurrentAgentProvider = exports.ComponentPreferencesProvider = void 0;
|
|
21
|
+
__exportStar(require("./contexts/ComponentPreferences"), exports);
|
|
22
|
+
var ComponentPreferences_1 = require("./contexts/ComponentPreferences");
|
|
23
|
+
Object.defineProperty(exports, "ComponentPreferencesProvider", { enumerable: true, get: function () { return __importDefault(ComponentPreferences_1).default; } });
|
|
21
24
|
__exportStar(require("./contexts/CurrentAgent"), exports);
|
|
22
25
|
var CurrentAgent_1 = require("./contexts/CurrentAgent");
|
|
23
26
|
Object.defineProperty(exports, "CurrentAgentProvider", { enumerable: true, get: function () { return __importDefault(CurrentAgent_1).default; } });
|
|
@@ -23,11 +23,13 @@ const react_hook_form_1 = require("react-hook-form");
|
|
|
23
23
|
const locale_1 = require("../../../../locale");
|
|
24
24
|
const AgentInputField_1 = __importDefault(require("../../components/AgentInputField"));
|
|
25
25
|
const LoadingButton_1 = __importDefault(require("../../components/LoadingButton"));
|
|
26
|
+
const ComponentPreferences_1 = require("../../contexts/ComponentPreferences");
|
|
26
27
|
const CurrentAgent_1 = require("../../contexts/CurrentAgent");
|
|
27
28
|
const runtime_1 = require("../../state/runtime");
|
|
28
29
|
const session_1 = require("../../state/session");
|
|
29
30
|
const agent_inputs_1 = require("../../utils/agent-inputs");
|
|
30
31
|
function AutoForm({ submitText, inlineLabel, autoFillLastForm = true, submitInQuestionField, chatMode, }) {
|
|
32
|
+
const preferences = (0, ComponentPreferences_1.useComponentPreferences)();
|
|
31
33
|
const submitRef = (0, react_1.useRef)(null);
|
|
32
34
|
const { t } = (0, locale_1.useLocaleContext)();
|
|
33
35
|
const { aid, agent } = (0, CurrentAgent_1.useCurrentAgent)();
|
|
@@ -35,13 +37,20 @@ function AutoForm({ submitText, inlineLabel, autoFillLastForm = true, submitInQu
|
|
|
35
37
|
const running = (0, session_1.useCurrentSessionState)((s) => s === null || s === void 0 ? void 0 : s.running);
|
|
36
38
|
const parameters = (0, react_1.useMemo)(() => {
|
|
37
39
|
var _a;
|
|
38
|
-
return (_a = agent.parameters) === null || _a === void 0 ? void 0 : _a.filter(agent_inputs_1.isValidInput).map((i) => {
|
|
40
|
+
return (_a = agent.parameters) === null || _a === void 0 ? void 0 : _a.filter((i) => { var _a; return (0, agent_inputs_1.isValidInput)(i) && !((_a = preferences === null || preferences === void 0 ? void 0 : preferences.hideInputFields) === null || _a === void 0 ? void 0 : _a.includes(i.key)); }).map((i) => {
|
|
39
41
|
var _a;
|
|
40
42
|
return (Object.assign(Object.assign({}, i), { label: ((_a = i.label) === null || _a === void 0 ? void 0 : _a.trim()) || undefined }));
|
|
41
43
|
});
|
|
42
44
|
}, [agent.parameters]);
|
|
43
45
|
const defaultForm = useInitialFormValues();
|
|
44
46
|
const form = (0, react_hook_form_1.useForm)({ defaultValues: defaultForm });
|
|
47
|
+
const submitDisabled = !form.formState.isValid;
|
|
48
|
+
(0, react_1.useEffect)(() => {
|
|
49
|
+
var _a, _b;
|
|
50
|
+
if ((preferences === null || preferences === void 0 ? void 0 : preferences.autoGenerate) && !form.formState.submitCount) {
|
|
51
|
+
(_b = (_a = submitRef.current) === null || _a === void 0 ? void 0 : _a.form) === null || _b === void 0 ? void 0 : _b.requestSubmit();
|
|
52
|
+
}
|
|
53
|
+
}, [defaultForm, preferences === null || preferences === void 0 ? void 0 : preferences.autoGenerate]);
|
|
45
54
|
(0, react_1.useEffect)(() => {
|
|
46
55
|
if (autoFillLastForm && !form.formState.isSubmitted && !form.formState.isSubmitting) {
|
|
47
56
|
form.reset(chatMode ? (0, omit_1.default)(defaultForm, 'question') : defaultForm);
|
|
@@ -61,8 +70,10 @@ function AutoForm({ submitText, inlineLabel, autoFillLastForm = true, submitInQu
|
|
|
61
70
|
});
|
|
62
71
|
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
72
|
const { key, required } = parameter !== null && parameter !== void 0 ? parameter : {};
|
|
73
|
+
if (!key)
|
|
74
|
+
return null;
|
|
64
75
|
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,
|
|
76
|
+
required: required || key === 'question',
|
|
66
77
|
min: parameter.type === 'number' && typeof parameter.min === 'number'
|
|
67
78
|
? { value: parameter.min, message: '' }
|
|
68
79
|
: undefined,
|
|
@@ -79,13 +90,14 @@ function AutoForm({ submitText, inlineLabel, autoFillLastForm = true, submitInQu
|
|
|
79
90
|
var _a;
|
|
80
91
|
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
92
|
? {
|
|
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 }) })),
|
|
93
|
+
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
94
|
}
|
|
84
95
|
: undefined })] }));
|
|
85
96
|
} }) }, 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') }))] }));
|
|
97
|
+
}), !(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
98
|
}
|
|
88
99
|
function useInitialFormValues() {
|
|
100
|
+
const preferences = (0, ComponentPreferences_1.useComponentPreferences)();
|
|
89
101
|
const { agent } = (0, CurrentAgent_1.useCurrentAgent)();
|
|
90
102
|
const lastMessage = (0, session_1.useCurrentSessionState)((s) => { var _a; return (_a = s === null || s === void 0 ? void 0 : s.messages) === null || _a === void 0 ? void 0 : _a.at(-1); });
|
|
91
103
|
const [lastInputs, setLastInputs] = (0, react_1.useState)();
|
|
@@ -98,11 +110,13 @@ function useInitialFormValues() {
|
|
|
98
110
|
}, [lastMessage]);
|
|
99
111
|
return (0, react_1.useMemo)(() => {
|
|
100
112
|
var _a, _b;
|
|
113
|
+
if (preferences === null || preferences === void 0 ? void 0 : preferences.initialInputValues)
|
|
114
|
+
return preferences.initialInputValues;
|
|
101
115
|
if (lastInputs) {
|
|
102
116
|
return lastInputs;
|
|
103
117
|
}
|
|
104
118
|
return Object.fromEntries((_b = (_a = agent.parameters) === null || _a === void 0 ? void 0 : _a.map((parameter) => [parameter.key, parameter.defaultValue])) !== null && _b !== void 0 ? _b : []);
|
|
105
|
-
}, [lastInputs, agent]);
|
|
119
|
+
}, [lastInputs, agent, preferences === null || preferences === void 0 ? void 0 : preferences.initialInputValues]);
|
|
106
120
|
}
|
|
107
121
|
const Form = (0, material_1.styled)(material_1.Stack)(({ theme }) => theme.unstable_sx({
|
|
108
122
|
gap: 2,
|
|
@@ -44,7 +44,7 @@ const react_1 = require("react");
|
|
|
44
44
|
const CustomComponentRenderer_1 = __importDefault(require("../../../../../components/CustomComponentRenderer"));
|
|
45
45
|
const session_1 = require("../../../../session");
|
|
46
46
|
const asset_1 = require("../../api/asset");
|
|
47
|
-
const AgentErrorBoundary_1 = require("../../components/AgentErrorBoundary");
|
|
47
|
+
const AgentErrorBoundary_1 = __importStar(require("../../components/AgentErrorBoundary"));
|
|
48
48
|
const UserInfo_1 = __importDefault(require("../../components/UserInfo"));
|
|
49
49
|
const ComponentPreferences_1 = require("../../contexts/ComponentPreferences");
|
|
50
50
|
const CurrentAgent_1 = __importDefault(require("../../contexts/CurrentAgent"));
|
|
@@ -63,8 +63,8 @@ const MessageView = (0, react_1.memo)(({ message }) => {
|
|
|
63
63
|
const { hideAgentAvatar, hideUserInputs } = (_b = (0, ComponentPreferences_1.useComponentPreferences)()) !== null && _b !== void 0 ? _b : {};
|
|
64
64
|
if (!(appearanceOutput === null || appearanceOutput === void 0 ? void 0 : appearanceOutput.componentId))
|
|
65
65
|
return null;
|
|
66
|
-
const agentMessage = ((0, jsx_runtime_1.jsx)(MessageBodyContainer, { messageRole: "assistant", children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProperties, fallbackRender: AgentErrorBoundary_1.AgentErrorView }, message.id) }));
|
|
67
|
-
return ((0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: message.agentId, children: (0, jsx_runtime_1.jsx)(CurrentMessage_1.default, { message: message, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: 2, children: [!hideUserInputs && ((0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(UserInfo_1.default, { name: (_c = authSession.user) === null || _c === void 0 ? void 0 : _c.fullName, did: (_d = authSession.user) === null || _d === void 0 ? void 0 : _d.did, avatar: (0, asset_1.getAssetUrl)({ filename: (_e = authSession.user) === null || _e === void 0 ? void 0 : _e.avatar, preset: 'avatar' }), time: message.createdAt, reverse: true, alignItems: "flex-start", UserNameProps: { sx: { color: hasBg ? 'white' : undefined } }, children: (0, jsx_runtime_1.jsx)(material_1.Stack, { sx: { alignItems: 'flex-end' }, children: (0, jsx_runtime_1.jsx)(MessageBodyContainer, { messageRole: "user", children: (0, jsx_runtime_1.jsx)(UserMessageView_1.default, {}) }) }) }) })), (0, jsx_runtime_1.jsx)(material_1.Box, { children: !hideAgentAvatar ? ((0, jsx_runtime_1.jsx)(UserInfo_1.default, { name: profile.name, did: (_f = globalThis.blocklet) === null || _f === void 0 ? void 0 : _f.appId, avatar: (0, asset_1.getAssetUrl)({ blockletDid, aid, filename: profile.avatar, preset: 'avatar' }), time: message.createdAt, alignItems: "flex-start", UserNameProps: { sx: { color: hasBg ? 'white' : undefined } }, children: agentMessage })) : (agentMessage) })] }) }) }));
|
|
66
|
+
const agentMessage = ((0, jsx_runtime_1.jsx)(MessageBodyContainer, { messageRole: "assistant", children: (0, jsx_runtime_1.jsx)(react_1.Suspense, { children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProperties, fallbackRender: AgentErrorBoundary_1.AgentErrorView }, message.id) }) }));
|
|
67
|
+
return ((0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: message.agentId, children: (0, jsx_runtime_1.jsx)(CurrentMessage_1.default, { message: message, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: 2, children: [!hideUserInputs && ((0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(UserInfo_1.default, { name: (_c = authSession.user) === null || _c === void 0 ? void 0 : _c.fullName, did: (_d = authSession.user) === null || _d === void 0 ? void 0 : _d.did, avatar: (0, asset_1.getAssetUrl)({ filename: (_e = authSession.user) === null || _e === void 0 ? void 0 : _e.avatar, preset: 'avatar' }), time: message.createdAt, reverse: true, alignItems: "flex-start", UserNameProps: { sx: { color: hasBg ? 'white' : undefined } }, children: (0, jsx_runtime_1.jsx)(material_1.Stack, { sx: { alignItems: 'flex-end' }, children: (0, jsx_runtime_1.jsx)(MessageBodyContainer, { messageRole: "user", children: (0, jsx_runtime_1.jsx)(AgentErrorBoundary_1.default, { children: (0, jsx_runtime_1.jsx)(react_1.Suspense, { children: (0, jsx_runtime_1.jsx)(UserMessageView_1.default, {}) }) }) }) }) }) })), (0, jsx_runtime_1.jsx)(material_1.Box, { children: !hideAgentAvatar ? ((0, jsx_runtime_1.jsx)(UserInfo_1.default, { name: profile.name, did: (_f = globalThis.blocklet) === null || _f === void 0 ? void 0 : _f.appId, avatar: (0, asset_1.getAssetUrl)({ blockletDid, aid, filename: profile.avatar, preset: 'avatar' }), time: message.createdAt, alignItems: "flex-start", UserNameProps: { sx: { color: hasBg ? 'white' : undefined } }, children: agentMessage })) : (agentMessage) })] }) }) }));
|
|
68
68
|
});
|
|
69
69
|
exports.default = MessageView;
|
|
70
70
|
function MessageBodyContainer(_a) {
|
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
26
|
var t = {};
|
|
4
27
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -23,7 +46,7 @@ const SimpleHeader_1 = __importDefault(require("../../components/Header/SimpleHe
|
|
|
23
46
|
const SimpleLayout_1 = __importDefault(require("../../components/Layout/SimpleLayout"));
|
|
24
47
|
const ScrollView_1 = __importDefault(require("../../components/ScrollView"));
|
|
25
48
|
const ActiveAgent_1 = require("../../contexts/ActiveAgent");
|
|
26
|
-
const ComponentPreferences_1 = require("../../contexts/ComponentPreferences");
|
|
49
|
+
const ComponentPreferences_1 = __importStar(require("../../contexts/ComponentPreferences"));
|
|
27
50
|
const CurrentAgent_1 = __importDefault(require("../../contexts/CurrentAgent"));
|
|
28
51
|
const session_1 = require("../../state/session");
|
|
29
52
|
const BackgroundImage_1 = __importDefault(require("./BackgroundImage"));
|
|
@@ -32,7 +55,7 @@ const MessagesView_1 = __importDefault(require("./MessagesView"));
|
|
|
32
55
|
function SimpleChat(_a) {
|
|
33
56
|
var { scrollViewProps = { scroll: 'window', initialScrollBehavior: 'auto' } } = _a, preferences = __rest(_a, ["scrollViewProps"]);
|
|
34
57
|
(0, session_1.useAutoLoadSessionState)();
|
|
35
|
-
return ((0, jsx_runtime_1.jsx)(ComponentPreferences_1.
|
|
58
|
+
return ((0, jsx_runtime_1.jsx)(ComponentPreferences_1.default, Object.assign({}, preferences, { children: (0, jsx_runtime_1.jsxs)(ScrollView_1.default, Object.assign({}, scrollViewProps, { children: [(0, jsx_runtime_1.jsx)(BackgroundImage_1.default, {}), (0, jsx_runtime_1.jsx)(SimpleChatView, {})] })) })));
|
|
36
59
|
}
|
|
37
60
|
function SimpleChatView() {
|
|
38
61
|
var _a;
|
|
@@ -9,7 +9,9 @@ const types_1 = require("@blocklet/ai-runtime/types");
|
|
|
9
9
|
const material_1 = require("@mui/material");
|
|
10
10
|
const react_1 = require("react");
|
|
11
11
|
const CustomComponentRenderer_1 = __importDefault(require("../../../../../components/CustomComponentRenderer"));
|
|
12
|
+
const AgentErrorBoundary_1 = __importDefault(require("../../components/AgentErrorBoundary"));
|
|
12
13
|
const constants_1 = require("../../constants");
|
|
14
|
+
const ComponentPreferences_1 = require("../../contexts/ComponentPreferences");
|
|
13
15
|
const CurrentAgent_1 = require("../../contexts/CurrentAgent");
|
|
14
16
|
const CurrentMessage_1 = require("../../contexts/CurrentMessage");
|
|
15
17
|
const ignoredOutputs = new Set([
|
|
@@ -20,6 +22,8 @@ const ignoredOutputs = new Set([
|
|
|
20
22
|
types_1.RuntimeOutputVariable.openingMessage,
|
|
21
23
|
]);
|
|
22
24
|
function SimpleOutput() {
|
|
25
|
+
const preferences = (0, ComponentPreferences_1.useComponentPreferences)();
|
|
26
|
+
const CustomComponentActionsComponent = preferences === null || preferences === void 0 ? void 0 : preferences.customOutputActionsComponent;
|
|
23
27
|
const { message } = (0, CurrentMessage_1.useCurrentMessage)();
|
|
24
28
|
if (message.error)
|
|
25
29
|
throw message.error;
|
|
@@ -33,12 +37,12 @@ function SimpleOutput() {
|
|
|
33
37
|
}, [agent.outputVariables]);
|
|
34
38
|
if (!(outputs === null || outputs === void 0 ? void 0 : outputs.length))
|
|
35
39
|
return null;
|
|
36
|
-
return ((0, jsx_runtime_1.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: 2, children: [outputs.map((output) => {
|
|
41
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
42
|
+
const value = output.name === types_1.RuntimeOutputVariable.text
|
|
43
|
+
? ((_a = message.outputs) === null || _a === void 0 ? void 0 : _a.content) ||
|
|
44
|
+
((_d = (_c = (_b = message.outputs) === null || _b === void 0 ? void 0 : _b.objects) === null || _c === void 0 ? void 0 : _c.find((i) => i === null || i === void 0 ? void 0 : i[types_1.RuntimeOutputVariable.text])) === null || _d === void 0 ? void 0 : _d[types_1.RuntimeOutputVariable.text])
|
|
45
|
+
: (_g = (_f = (_e = message.outputs) === null || _e === void 0 ? void 0 : _e.objects) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g[output.name];
|
|
46
|
+
return ((0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { instanceId: output.id, componentId: output.appearance.componentId, properties: output.appearance.componentProperties, props: Object.assign({ output, outputValue: value, writing: output.name === types_1.RuntimeOutputVariable.text && message.loading }, (((_h = output === null || output === void 0 ? void 0 : output.appearance) === null || _h === void 0 ? void 0 : _h.componentProps) || {})) }, output.id));
|
|
47
|
+
}), CustomComponentActionsComponent && ((0, jsx_runtime_1.jsx)(AgentErrorBoundary_1.default, { children: (0, jsx_runtime_1.jsx)(react_1.Suspense, { children: (0, jsx_runtime_1.jsx)(CustomComponentActionsComponent, {}) }) }))] }));
|
|
44
48
|
}
|
|
@@ -24,14 +24,16 @@ const AgentErrorBoundary_1 = require("../../components/AgentErrorBoundary");
|
|
|
24
24
|
const SimpleHeader_1 = __importDefault(require("../../components/Header/SimpleHeader"));
|
|
25
25
|
const SimpleLayout_1 = __importDefault(require("../../components/Layout/SimpleLayout"));
|
|
26
26
|
const ActiveAgent_1 = require("../../contexts/ActiveAgent");
|
|
27
|
+
const ComponentPreferences_1 = __importDefault(require("../../contexts/ComponentPreferences"));
|
|
27
28
|
const CurrentAgent_1 = __importDefault(require("../../contexts/CurrentAgent"));
|
|
28
29
|
const CurrentMessage_1 = __importDefault(require("../../contexts/CurrentMessage"));
|
|
29
30
|
const use_appearances_1 = __importDefault(require("../../hooks/use-appearances"));
|
|
30
31
|
const session_1 = require("../../state/session");
|
|
31
|
-
function SimplePage(
|
|
32
|
+
function SimplePage(_a) {
|
|
33
|
+
var { resultTitle } = _a, preferences = __rest(_a, ["resultTitle"]);
|
|
32
34
|
const { activeAgentId } = (0, ActiveAgent_1.useActiveAgent)();
|
|
33
35
|
(0, session_1.useAutoLoadSessionState)();
|
|
34
|
-
return ((0, jsx_runtime_1.jsxs)(SimpleLayout_1.default, { pb: 4, children: [(0, jsx_runtime_1.jsx)(SimpleHeader_1.default, {}), (0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: activeAgentId, children: (0, jsx_runtime_1.jsx)(AgentInputRender, { className: "aigne-inputs aigne-simple-page-inputs" }) }), (0, jsx_runtime_1.jsx)(OutputView, { className: "aigne-outputs aigne-simple-page-outputs", resultTitle: resultTitle })] }));
|
|
36
|
+
return ((0, jsx_runtime_1.jsx)(ComponentPreferences_1.default, Object.assign({}, preferences, { children: (0, jsx_runtime_1.jsxs)(SimpleLayout_1.default, { pb: 4, children: [(0, jsx_runtime_1.jsx)(SimpleHeader_1.default, {}), (0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: activeAgentId, children: (0, jsx_runtime_1.jsx)(AgentInputRender, { className: "aigne-inputs aigne-simple-page-inputs" }) }), (0, jsx_runtime_1.jsx)(OutputView, { className: "aigne-outputs aigne-simple-page-outputs", resultTitle: resultTitle })] }) })));
|
|
35
37
|
}
|
|
36
38
|
function AgentInputRender(_a) {
|
|
37
39
|
var props = __rest(_a, []);
|