@blocklet/pages-kit 0.2.316 → 0.2.317
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/MarkdownRenderer.js +26 -2
- package/lib/cjs/builtin/async/ai-runtime/components/OutputFieldContainer/index.js +22 -0
- package/lib/cjs/builtin/async/ai-runtime/components/ShareActions/index.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/constants.js +34 -4
- package/lib/cjs/builtin/async/ai-runtime/contexts/ActiveAgent.js +28 -0
- package/lib/cjs/builtin/async/ai-runtime/contexts/ComponentPreferences.js +27 -0
- package/lib/cjs/builtin/async/ai-runtime/contexts/CurrentMessage.js +2 -2
- package/lib/cjs/builtin/async/ai-runtime/hooks/use-appearances.js +10 -5
- package/lib/cjs/builtin/async/ai-runtime/hooks/use-header-menu.js +39 -0
- package/lib/cjs/builtin/async/ai-runtime/index.js +17 -3
- package/lib/cjs/builtin/async/ai-runtime/runtime/ChatBotButton/index.js +3 -2
- package/lib/cjs/builtin/async/ai-runtime/runtime/Runtime/index.js +4 -6
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/GoogleSearch/GoogleSearchRelatedQuestionsView.js +60 -0
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/GoogleSearch/GoogleSearchSourcesView.js +50 -0
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/ImagesView/index.js +30 -0
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/MarkdownView/index.js +13 -0
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/OpeningQuestionsView/index.js +46 -0
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/OutputFieldView/type.js +2 -0
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/PhotoGallery/index.js +5 -5
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/ReferencedLinksView/index.js +26 -0
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/ShareView/index.js +16 -0
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/BackgroundImage.js +25 -0
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/InputsView.js +73 -0
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/MessageView.js +58 -0
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/MessagesView.js +33 -0
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/OpeningMessageView.js +23 -0
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/OpeningQuestionsView.js +20 -0
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/UserMessageView.js +26 -0
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/index.js +28 -134
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleOutput/index.js +35 -9
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimplePage/index.js +5 -5
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SuggestedQuestionsView/index.js +54 -0
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/Page.js +5 -5
- package/lib/cjs/builtin/async/ai-runtime/state/runtime.js +1 -6
- package/lib/cjs/builtin/mui/material.js +4 -2
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/utils/inject-global-components.js +2 -0
- package/lib/esm/builtin/async/ai-runtime/components/MarkdownRenderer.js +3 -2
- package/lib/esm/builtin/async/ai-runtime/components/OutputFieldContainer/index.js +19 -0
- package/lib/esm/builtin/async/ai-runtime/components/ShareActions/index.js +2 -2
- package/lib/esm/builtin/async/ai-runtime/constants.js +32 -3
- package/lib/esm/builtin/async/ai-runtime/contexts/ActiveAgent.js +23 -0
- package/lib/esm/builtin/async/ai-runtime/contexts/ComponentPreferences.js +22 -0
- package/lib/esm/builtin/async/ai-runtime/contexts/CurrentMessage.js +2 -2
- package/lib/esm/builtin/async/ai-runtime/hooks/use-appearances.js +10 -5
- package/lib/esm/builtin/async/ai-runtime/hooks/use-header-menu.js +32 -0
- package/lib/esm/builtin/async/ai-runtime/index.js +8 -1
- package/lib/esm/builtin/async/ai-runtime/runtime/ChatBotButton/index.js +3 -2
- package/lib/esm/builtin/async/ai-runtime/runtime/Runtime/index.js +4 -6
- package/lib/esm/builtin/async/ai-runtime/runtime-components/GoogleSearch/GoogleSearchRelatedQuestionsView.js +54 -0
- package/lib/esm/builtin/async/ai-runtime/runtime-components/GoogleSearch/GoogleSearchSourcesView.js +44 -0
- package/lib/esm/builtin/async/ai-runtime/runtime-components/ImagesView/index.js +24 -0
- package/lib/esm/builtin/async/ai-runtime/runtime-components/MarkdownView/index.js +7 -0
- package/lib/esm/builtin/async/ai-runtime/runtime-components/OpeningQuestionsView/index.js +40 -0
- package/lib/esm/builtin/async/ai-runtime/runtime-components/OutputFieldView/type.js +1 -0
- package/lib/esm/builtin/async/ai-runtime/runtime-components/PhotoGallery/index.js +5 -5
- package/lib/esm/builtin/async/ai-runtime/runtime-components/ReferencedLinksView/index.js +20 -0
- package/lib/esm/builtin/async/ai-runtime/runtime-components/ShareView/index.js +10 -0
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/BackgroundImage.js +22 -0
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/InputsView.js +44 -0
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/MessageView.js +30 -0
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/MessagesView.js +27 -0
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/OpeningMessageView.js +18 -0
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/OpeningQuestionsView.js +14 -0
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/UserMessageView.js +20 -0
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/index.js +25 -108
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleOutput/index.js +36 -10
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SimplePage/index.js +5 -5
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SuggestedQuestionsView/index.js +48 -0
- package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/Page.js +5 -5
- package/lib/esm/builtin/async/ai-runtime/state/runtime.js +1 -6
- package/lib/esm/builtin/mui/material.js +1 -1
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/utils/inject-global-components.js +2 -0
- package/lib/types/builtin/async/ai-runtime/components/OutputFieldContainer/index.d.ts +5 -0
- package/lib/types/builtin/async/ai-runtime/constants.d.ts +14 -0
- package/lib/types/builtin/async/ai-runtime/contexts/ActiveAgent.d.ts +9 -0
- package/lib/types/builtin/async/ai-runtime/contexts/ComponentPreferences.d.ts +5 -0
- package/lib/types/builtin/async/ai-runtime/contexts/CurrentMessage.d.ts +6 -1
- package/lib/types/builtin/async/ai-runtime/hooks/use-appearances.d.ts +4 -1
- package/lib/types/builtin/async/ai-runtime/hooks/use-header-menu.d.ts +1 -0
- package/lib/types/builtin/async/ai-runtime/index.d.ts +8 -1
- package/lib/types/builtin/async/ai-runtime/runtime-components/GoogleSearch/GoogleSearchRelatedQuestionsView.d.ts +4 -0
- package/lib/types/builtin/async/ai-runtime/runtime-components/GoogleSearch/GoogleSearchSourcesView.d.ts +2 -0
- package/lib/types/builtin/async/ai-runtime/runtime-components/ImagesView/index.d.ts +2 -0
- package/lib/types/builtin/async/ai-runtime/runtime-components/MarkdownView/index.d.ts +5 -0
- package/lib/types/builtin/async/ai-runtime/runtime-components/OpeningQuestionsView/index.d.ts +2 -0
- package/lib/types/builtin/async/ai-runtime/runtime-components/OutputFieldView/type.d.ts +5 -0
- package/lib/types/builtin/async/ai-runtime/runtime-components/ReferencedLinksView/index.d.ts +2 -0
- package/lib/types/builtin/async/ai-runtime/runtime-components/ShareView/index.d.ts +2 -0
- package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/BackgroundImage.d.ts +1 -0
- package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/InputsView.d.ts +2 -0
- package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/MessageView.d.ts +6 -0
- package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/MessagesView.d.ts +2 -0
- package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/OpeningMessageView.d.ts +3 -0
- package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/OpeningQuestionsView.d.ts +1 -0
- package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/UserMessageView.d.ts +1 -0
- package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/index.d.ts +13 -3
- package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleOutput/index.d.ts +1 -1
- package/lib/types/builtin/async/ai-runtime/runtime-components/SuggestedQuestionsView/index.d.ts +4 -0
- package/lib/types/builtin/async/ai-runtime/state/runtime.d.ts +0 -1
- package/lib/types/builtin/mui/material.d.ts +1 -1
- package/lib/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -8
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/MultiAgentsChat/index.js +0 -193
- package/lib/esm/builtin/async/ai-runtime/runtime-components/MultiAgentsChat/index.js +0 -164
- package/lib/types/builtin/async/ai-runtime/runtime-components/MultiAgentsChat/index.d.ts +0 -11
|
@@ -23,14 +23,14 @@ const CustomComponentRenderer_1 = __importDefault(require("../../../../../compon
|
|
|
23
23
|
const locale_1 = require("../../../../locale");
|
|
24
24
|
const SimpleHeader_1 = __importDefault(require("../../components/Header/SimpleHeader"));
|
|
25
25
|
const LoadingButton_1 = __importDefault(require("../../components/LoadingButton"));
|
|
26
|
+
const ActiveAgent_1 = require("../../contexts/ActiveAgent");
|
|
26
27
|
const CurrentAgent_1 = __importDefault(require("../../contexts/CurrentAgent"));
|
|
27
28
|
const CurrentMessage_1 = __importDefault(require("../../contexts/CurrentMessage"));
|
|
28
29
|
const use_appearances_1 = __importDefault(require("../../hooks/use-appearances"));
|
|
29
|
-
const runtime_1 = require("../../state/runtime");
|
|
30
30
|
const session_1 = require("../../state/session");
|
|
31
31
|
const map_right_1 = __importDefault(require("../../utils/map-right"));
|
|
32
32
|
function PhotoGallery({ resultTitle, primaryColor }) {
|
|
33
|
-
const {
|
|
33
|
+
const { activeAgentId } = (0, ActiveAgent_1.useActiveAgent)();
|
|
34
34
|
(0, session_1.useAutoLoadSessionState)();
|
|
35
35
|
const inheritedTheme = (0, material_1.useTheme)();
|
|
36
36
|
const theme = (0, react_1.useMemo)(() => {
|
|
@@ -50,7 +50,7 @@ function PhotoGallery({ resultTitle, primaryColor }) {
|
|
|
50
50
|
},
|
|
51
51
|
});
|
|
52
52
|
}, [inheritedTheme, primaryColor]);
|
|
53
|
-
return ((0, jsx_runtime_1.jsx)(material_1.ThemeProvider, { theme: theme, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { className: "aigne-layout aigne-photo-wall-layout", children: [(0, jsx_runtime_1.jsx)(SimpleHeader_1.default, { TitleProps: { fontSize: 48 }, DescriptionProps: { fontSize: 20 }, maxWidth: "md", mx: "auto", width: "100%", px: { xs: 2, sm: 3 } }), (0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId:
|
|
53
|
+
return ((0, jsx_runtime_1.jsx)(material_1.ThemeProvider, { theme: theme, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { className: "aigne-layout aigne-photo-wall-layout", children: [(0, jsx_runtime_1.jsx)(SimpleHeader_1.default, { TitleProps: { fontSize: 48 }, DescriptionProps: { fontSize: 20 }, maxWidth: "md", mx: "auto", width: "100%", px: { xs: 2, sm: 3 } }), (0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: activeAgentId, children: (0, jsx_runtime_1.jsx)(AgentInputRender, { className: "aigne-inputs aigne-photo-wall-inputs", maxWidth: "md", mx: "auto", width: "100%", px: { xs: 2, sm: 3 } }) }), (0, jsx_runtime_1.jsx)(OutputView, { resultTitle: resultTitle, className: "aigne-outputs aigne-photo-wall-outputs", gap: 2 })] }) }));
|
|
54
54
|
}
|
|
55
55
|
exports.default = PhotoGallery;
|
|
56
56
|
function AgentInputRender(_a) {
|
|
@@ -58,7 +58,7 @@ function AgentInputRender(_a) {
|
|
|
58
58
|
const { appearanceInput } = (0, use_appearances_1.default)();
|
|
59
59
|
if (!(appearanceInput === null || appearanceInput === void 0 ? void 0 : appearanceInput.componentId))
|
|
60
60
|
return null;
|
|
61
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Stack, Object.assign({}, props, { children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: appearanceInput.componentId, properties: appearanceInput.
|
|
61
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Stack, Object.assign({}, props, { children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: appearanceInput.componentId, properties: appearanceInput.componentProperties }) })));
|
|
62
62
|
}
|
|
63
63
|
function NoOutputs() {
|
|
64
64
|
return ((0, jsx_runtime_1.jsx)(material_1.Stack, { mt: 10, children: (0, jsx_runtime_1.jsx)(material_1.Typography, { color: "text.disabled", children: "You haven't generated any pictures yet." }) }));
|
|
@@ -79,5 +79,5 @@ const OutputItemView = (0, react_1.memo)(({ message }) => {
|
|
|
79
79
|
const { appearanceOutput } = (0, use_appearances_1.default)({ agentId: message.assistantId });
|
|
80
80
|
if (!(appearanceOutput === null || appearanceOutput === void 0 ? void 0 : appearanceOutput.componentId))
|
|
81
81
|
return null;
|
|
82
|
-
return ((0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: message.assistantId, children: (0, jsx_runtime_1.jsx)(CurrentMessage_1.default, { message: message, children: (0, jsx_runtime_1.jsx)(react_1.Suspense, { children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: appearanceOutput.componentId, properties: appearanceOutput.
|
|
82
|
+
return ((0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: message.assistantId, children: (0, jsx_runtime_1.jsx)(CurrentMessage_1.default, { message: message, children: (0, jsx_runtime_1.jsx)(react_1.Suspense, { children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProperties }) }) }) }, message.taskId));
|
|
83
83
|
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
const material_1 = require("@mui/material");
|
|
8
|
+
const joi_1 = __importDefault(require("joi"));
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
const OutputFieldContainer_1 = __importDefault(require("../../components/OutputFieldContainer"));
|
|
11
|
+
const referencedLinksSchema = joi_1.default.array().items(joi_1.default.object({
|
|
12
|
+
title: joi_1.default.string().required(),
|
|
13
|
+
url: joi_1.default.string().required(),
|
|
14
|
+
}));
|
|
15
|
+
function SuggestedQuestionsView({ output, outputValue }) {
|
|
16
|
+
const links = (0, react_1.useMemo)(() => {
|
|
17
|
+
const result = referencedLinksSchema.validate(outputValue, { allowUnknown: true });
|
|
18
|
+
if (result.error)
|
|
19
|
+
return undefined;
|
|
20
|
+
return result.value;
|
|
21
|
+
}, [outputValue]);
|
|
22
|
+
if (!(links === null || links === void 0 ? void 0 : links.length))
|
|
23
|
+
return null;
|
|
24
|
+
return ((0, jsx_runtime_1.jsx)(OutputFieldContainer_1.default, { output: output, children: (0, jsx_runtime_1.jsx)(material_1.Stack, { gap: 1, children: links.map((item) => ((0, jsx_runtime_1.jsx)(material_1.Link, { href: item.url, children: item.title }))) }) }));
|
|
25
|
+
}
|
|
26
|
+
exports.default = SuggestedQuestionsView;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
const OutputFieldContainer_1 = __importDefault(require("../../components/OutputFieldContainer"));
|
|
8
|
+
const ShareActions_1 = __importDefault(require("../../components/ShareActions"));
|
|
9
|
+
const CurrentMessage_1 = require("../../contexts/CurrentMessage");
|
|
10
|
+
function ShareView({ output }) {
|
|
11
|
+
const message = (0, CurrentMessage_1.useCurrentMessage)({ optional: true });
|
|
12
|
+
if (message === null || message === void 0 ? void 0 : message.message.loading)
|
|
13
|
+
return null;
|
|
14
|
+
return ((0, jsx_runtime_1.jsx)(OutputFieldContainer_1.default, { output: output, children: (0, jsx_runtime_1.jsx)(ShareActions_1.default, { flexDirection: "row", justifyContent: "flex-end" }) }));
|
|
15
|
+
}
|
|
16
|
+
exports.default = ShareView;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
const material_1 = require("@mui/material");
|
|
5
|
+
const ComponentPreferences_1 = require("../../contexts/ComponentPreferences");
|
|
6
|
+
function BackgroundImage() {
|
|
7
|
+
var _a, _b;
|
|
8
|
+
const preferences = (0, ComponentPreferences_1.useComponentPreferences)();
|
|
9
|
+
if (!((_a = preferences === null || preferences === void 0 ? void 0 : preferences.backgroundImage) === null || _a === void 0 ? void 0 : _a.url))
|
|
10
|
+
return null;
|
|
11
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
|
|
12
|
+
position: 'fixed',
|
|
13
|
+
left: 0,
|
|
14
|
+
top: 0,
|
|
15
|
+
right: 0,
|
|
16
|
+
bottom: 0,
|
|
17
|
+
backgroundImage: `url(${(_b = preferences.backgroundImage) === null || _b === void 0 ? void 0 : _b.url}) !important`,
|
|
18
|
+
backgroundRepeat: 'no-repeat',
|
|
19
|
+
backgroundSize: 'cover',
|
|
20
|
+
backgroundPosition: 'center',
|
|
21
|
+
pointerEvents: 'none',
|
|
22
|
+
zIndex: -1,
|
|
23
|
+
} }));
|
|
24
|
+
}
|
|
25
|
+
exports.default = BackgroundImage;
|
|
@@ -0,0 +1,73 @@
|
|
|
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
|
+
};
|
|
25
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
26
|
+
var t = {};
|
|
27
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
28
|
+
t[p] = s[p];
|
|
29
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
30
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
31
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
32
|
+
t[p[i]] = s[p[i]];
|
|
33
|
+
}
|
|
34
|
+
return t;
|
|
35
|
+
};
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
41
|
+
const types_1 = require("@blocklet/ai-runtime/types");
|
|
42
|
+
const material_1 = require("@mui/material");
|
|
43
|
+
const react_1 = require("react");
|
|
44
|
+
const CustomComponentRenderer_1 = __importDefault(require("../../../../../components/CustomComponentRenderer"));
|
|
45
|
+
const ActiveAgent_1 = require("../../contexts/ActiveAgent");
|
|
46
|
+
const CurrentAgent_1 = __importStar(require("../../contexts/CurrentAgent"));
|
|
47
|
+
const use_appearances_1 = __importStar(require("../../hooks/use-appearances"));
|
|
48
|
+
const runtime_1 = require("../../state/runtime");
|
|
49
|
+
const runtime_output_schema_1 = require("../../utils/runtime-output-schema");
|
|
50
|
+
function InputsView(_a) {
|
|
51
|
+
var props = __rest(_a, []);
|
|
52
|
+
const { activeAgentId, setActiveAgentId } = (0, ActiveAgent_1.useActiveAgent)();
|
|
53
|
+
const { agent } = (0, runtime_1.useRuntimeState)();
|
|
54
|
+
const children = (0, react_1.useMemo)(() => { var _a, _b; return (_b = (_a = (0, runtime_output_schema_1.getOutputVariableInitialValue)(agent, types_1.RuntimeOutputVariable.children)) === null || _a === void 0 ? void 0 : _a.agents) === null || _b === void 0 ? void 0 : _b.filter((i) => !!i.id); }, [agent]);
|
|
55
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ gap: 2 }, props, { children: [children && children.length > 1 && ((0, jsx_runtime_1.jsx)(material_1.Stack, { direction: "row", gap: 2, children: children === null || children === void 0 ? void 0 : children.map((child) => ((0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: child.id, children: (0, jsx_runtime_1.jsx)(AgentAvatar, { selected: activeAgentId === child.id, onClick: () => setActiveAgentId(child.id) }) }))) })), (0, jsx_runtime_1.jsx)(material_1.Stack, { children: (0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: activeAgentId, children: (0, jsx_runtime_1.jsx)(AgentInput, {}) }) })] })));
|
|
56
|
+
}
|
|
57
|
+
exports.default = InputsView;
|
|
58
|
+
function AgentAvatar(_a) {
|
|
59
|
+
var _b;
|
|
60
|
+
var { selected } = _a, props = __rest(_a, ["selected"]);
|
|
61
|
+
const { appearanceInput } = (0, use_appearances_1.default)();
|
|
62
|
+
const profile = (0, use_appearances_1.useProfile)();
|
|
63
|
+
if (!(appearanceInput === null || appearanceInput === void 0 ? void 0 : appearanceInput.componentId))
|
|
64
|
+
return null;
|
|
65
|
+
return ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({}, props, { sx: Object.assign({ p: 0, outline: selected ? 3 : 0, outlineColor: 'primary.light' }, props.sx), children: (0, jsx_runtime_1.jsx)(material_1.Avatar, { src: profile === null || profile === void 0 ? void 0 : profile.avatar, children: (_b = profile.name) === null || _b === void 0 ? void 0 : _b.slice(0, 1) }) })));
|
|
66
|
+
}
|
|
67
|
+
function AgentInput() {
|
|
68
|
+
const { aid } = (0, CurrentAgent_1.useCurrentAgent)();
|
|
69
|
+
const { appearanceInput } = (0, use_appearances_1.default)({ aid });
|
|
70
|
+
if (!(appearanceInput === null || appearanceInput === void 0 ? void 0 : appearanceInput.componentId))
|
|
71
|
+
return null;
|
|
72
|
+
return ((0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: appearanceInput.componentId, properties: appearanceInput.componentProperties }));
|
|
73
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
30
|
+
const material_1 = require("@mui/material");
|
|
31
|
+
const react_1 = require("react");
|
|
32
|
+
const CustomComponentRenderer_1 = __importDefault(require("../../../../../components/CustomComponentRenderer"));
|
|
33
|
+
const session_1 = require("../../../../session");
|
|
34
|
+
const UserInfo_1 = __importDefault(require("../../components/UserInfo"));
|
|
35
|
+
const ComponentPreferences_1 = require("../../contexts/ComponentPreferences");
|
|
36
|
+
const CurrentAgent_1 = __importDefault(require("../../contexts/CurrentAgent"));
|
|
37
|
+
const CurrentMessage_1 = __importDefault(require("../../contexts/CurrentMessage"));
|
|
38
|
+
const use_appearances_1 = __importStar(require("../../hooks/use-appearances"));
|
|
39
|
+
const UserMessageView_1 = __importDefault(require("./UserMessageView"));
|
|
40
|
+
const MessageView = (0, react_1.memo)(({ message }) => {
|
|
41
|
+
var _a, _b, _c, _d, _e;
|
|
42
|
+
const { session: authSession } = (0, session_1.useSessionContext)();
|
|
43
|
+
const { appearanceOutput } = (0, use_appearances_1.default)({ agentId: message.assistantId });
|
|
44
|
+
const profile = (0, use_appearances_1.useProfile)({ agentId: message.assistantId });
|
|
45
|
+
const { hideAgentAvatar, hideUserInputs } = (_a = (0, ComponentPreferences_1.useComponentPreferences)()) !== null && _a !== void 0 ? _a : {};
|
|
46
|
+
if (!(appearanceOutput === null || appearanceOutput === void 0 ? void 0 : appearanceOutput.componentId))
|
|
47
|
+
return null;
|
|
48
|
+
return ((0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: message.assistantId, 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: (_b = authSession.user) === null || _b === void 0 ? void 0 : _b.fullName, did: (_c = authSession.user) === null || _c === void 0 ? void 0 : _c.did, avatar: (_d = authSession.user) === null || _d === void 0 ? void 0 : _d.avatar, time: message.createdAt, reverse: true, alignItems: "flex-start", children: (0, jsx_runtime_1.jsx)(material_1.Stack, { sx: { alignItems: 'flex-end' }, children: (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
|
|
49
|
+
borderRadius: 1,
|
|
50
|
+
borderTopRightRadius: '2px',
|
|
51
|
+
px: 2,
|
|
52
|
+
py: 1,
|
|
53
|
+
marginTop: 0.5,
|
|
54
|
+
maxWidth: 'calc(100% - 40px)',
|
|
55
|
+
bgcolor: 'rgba(239, 246, 255, 1)',
|
|
56
|
+
}, 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: (_e = globalThis.blocklet) === null || _e === void 0 ? void 0 : _e.appId, avatar: profile.avatar, time: message.createdAt, alignItems: "flex-start", children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProperties }) })) : ((0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProperties })) })] }) }) }));
|
|
57
|
+
});
|
|
58
|
+
exports.default = MessageView;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
18
|
+
const material_1 = require("@mui/material");
|
|
19
|
+
const ComponentPreferences_1 = require("../../contexts/ComponentPreferences");
|
|
20
|
+
const session_1 = require("../../state/session");
|
|
21
|
+
const MessageView_1 = __importDefault(require("./MessageView"));
|
|
22
|
+
const OpeningMessageView_1 = __importDefault(require("./OpeningMessageView"));
|
|
23
|
+
const OpeningQuestionsView_1 = __importDefault(require("./OpeningQuestionsView"));
|
|
24
|
+
function MessagesView(_a) {
|
|
25
|
+
var _b;
|
|
26
|
+
var props = __rest(_a, []);
|
|
27
|
+
const messages = (0, session_1.useCurrentSessionState)((s) => s === null || s === void 0 ? void 0 : s.messages);
|
|
28
|
+
const loaded = (0, session_1.useSessionState)((s) => s.loaded);
|
|
29
|
+
const showOpening = (0, session_1.useCurrentSessionState)((s) => !s || (s === null || s === void 0 ? void 0 : s.loaded)) && loaded;
|
|
30
|
+
const divider = (_b = (0, ComponentPreferences_1.useComponentPreferences)()) === null || _b === void 0 ? void 0 : _b.divider;
|
|
31
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ gap: 2 }, props, { children: [showOpening && (0, jsx_runtime_1.jsx)(OpeningMessageView_1.default, {}), messages === null || messages === void 0 ? void 0 : messages.map((message, index) => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(MessageView_1.default, { message: message }, message.taskId), divider && index !== messages.length - 1 ? (0, jsx_runtime_1.jsx)(material_1.Divider, { sx: { my: 2 } }) : undefined] }))), showOpening && !(messages === null || messages === void 0 ? void 0 : messages.length) && (0, jsx_runtime_1.jsx)(OpeningQuestionsView_1.default, {})] })));
|
|
32
|
+
}
|
|
33
|
+
exports.default = MessagesView;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
const types_1 = require("@blocklet/ai-runtime/types");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const CustomComponentRenderer_1 = __importDefault(require("../../../../../components/CustomComponentRenderer"));
|
|
10
|
+
const UserInfo_1 = __importDefault(require("../../components/UserInfo"));
|
|
11
|
+
const ComponentPreferences_1 = require("../../contexts/ComponentPreferences");
|
|
12
|
+
const use_appearances_1 = require("../../hooks/use-appearances");
|
|
13
|
+
const OpeningMessageView = (0, react_1.memo)(() => {
|
|
14
|
+
var _a, _b, _c, _d, _e;
|
|
15
|
+
const { hideAgentAvatar } = (_a = (0, ComponentPreferences_1.useComponentPreferences)()) !== null && _a !== void 0 ? _a : {};
|
|
16
|
+
const opening = (0, use_appearances_1.useOpeningMessage)();
|
|
17
|
+
const output = (0, react_1.useMemo)(() => { var _a; return (_a = opening === null || opening === void 0 ? void 0 : opening.agent.outputVariables) === null || _a === void 0 ? void 0 : _a.find((i) => i.name === types_1.RuntimeOutputVariable.openingMessage); }, [opening === null || opening === void 0 ? void 0 : opening.agent]);
|
|
18
|
+
const componentId = (_b = output === null || output === void 0 ? void 0 : output.appearance) === null || _b === void 0 ? void 0 : _b.componentId;
|
|
19
|
+
if (!output || !(opening === null || opening === void 0 ? void 0 : opening.message) || !componentId)
|
|
20
|
+
return null;
|
|
21
|
+
return hideAgentAvatar ? ((0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { instanceId: output.id, componentId: componentId, properties: (_c = output.appearance) === null || _c === void 0 ? void 0 : _c.componentProperties, props: { output, outputValue: opening.message } })) : ((0, jsx_runtime_1.jsx)(UserInfo_1.default, { name: opening.profile.name, did: (_d = globalThis.blocklet) === null || _d === void 0 ? void 0 : _d.appId, avatar: opening.profile.avatar, alignItems: "flex-start", children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { instanceId: output.id, componentId: componentId, properties: (_e = output.appearance) === null || _e === void 0 ? void 0 : _e.componentProperties, props: { output, outputValue: opening.message } }) }));
|
|
22
|
+
});
|
|
23
|
+
exports.default = OpeningMessageView;
|
package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/OpeningQuestionsView.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
const types_1 = require("@blocklet/ai-runtime/types");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const CustomComponentRenderer_1 = __importDefault(require("../../../../../components/CustomComponentRenderer"));
|
|
10
|
+
const CurrentAgent_1 = require("../../contexts/CurrentAgent");
|
|
11
|
+
function OpeningQuestionsView() {
|
|
12
|
+
var _a, _b;
|
|
13
|
+
const { agent } = (0, CurrentAgent_1.useCurrentAgent)();
|
|
14
|
+
const output = (0, react_1.useMemo)(() => { var _a; return (_a = agent.outputVariables) === null || _a === void 0 ? void 0 : _a.find((i) => i.name === types_1.RuntimeOutputVariable.openingQuestions); }, [agent.outputVariables]);
|
|
15
|
+
const componentId = (_a = output === null || output === void 0 ? void 0 : output.appearance) === null || _a === void 0 ? void 0 : _a.componentId;
|
|
16
|
+
if (!componentId)
|
|
17
|
+
return null;
|
|
18
|
+
return ((0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { instanceId: output.id, componentId: componentId, properties: (_b = output.appearance) === null || _b === void 0 ? void 0 : _b.componentProperties, props: { output } }));
|
|
19
|
+
}
|
|
20
|
+
exports.default = OpeningQuestionsView;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
const material_1 = require("@mui/material");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const MarkdownRenderer_1 = __importDefault(require("../../components/MarkdownRenderer"));
|
|
10
|
+
const CurrentAgent_1 = require("../../contexts/CurrentAgent");
|
|
11
|
+
const CurrentMessage_1 = require("../../contexts/CurrentMessage");
|
|
12
|
+
const agent_inputs_1 = require("../../utils/agent-inputs");
|
|
13
|
+
function UserMessageView() {
|
|
14
|
+
var _a;
|
|
15
|
+
const { message } = (0, CurrentMessage_1.useCurrentMessage)();
|
|
16
|
+
const { agent } = (0, CurrentAgent_1.useCurrentAgent)();
|
|
17
|
+
const params = (0, react_1.useMemo)(() => {
|
|
18
|
+
var _a;
|
|
19
|
+
return (_a = agent.parameters) === null || _a === void 0 ? void 0 : _a.filter(agent_inputs_1.isValidInput).map((i) => { var _a, _b; return [((_a = i.label) === null || _a === void 0 ? void 0 : _a.trim()) || i.key, (_b = message.parameters) === null || _b === void 0 ? void 0 : _b[i.key]]; }).filter((i) => i[1]);
|
|
20
|
+
}, [agent.parameters, message.parameters]);
|
|
21
|
+
if ((params === null || params === void 0 ? void 0 : params.length) === 1) {
|
|
22
|
+
return (0, jsx_runtime_1.jsx)(MarkdownRenderer_1.default, { children: (_a = params[0]) === null || _a === void 0 ? void 0 : _a[1] });
|
|
23
|
+
}
|
|
24
|
+
return params === null || params === void 0 ? void 0 : params.map(([key, value]) => ((0, jsx_runtime_1.jsxs)(material_1.Typography, { sx: { wordWrap: 'break-word' }, children: [(0, jsx_runtime_1.jsx)(material_1.Box, { component: "span", sx: { color: 'text.secondary' }, children: key }), "\u00A0\u00A0", (0, jsx_runtime_1.jsx)("span", { children: value })] }, key)));
|
|
25
|
+
}
|
|
26
|
+
exports.default = UserMessageView;
|
|
@@ -1,36 +1,4 @@
|
|
|
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
|
-
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
2
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
35
3
|
var t = {};
|
|
36
4
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -47,32 +15,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
47
15
|
};
|
|
48
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
17
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
50
|
-
const types_1 = require("@blocklet/ai-runtime/types");
|
|
51
|
-
const react_1 = require("@iconify/react");
|
|
52
18
|
const material_1 = require("@mui/material");
|
|
53
|
-
const
|
|
19
|
+
const react_1 = require("react");
|
|
54
20
|
const react_scroll_to_bottom_1 = require("react-scroll-to-bottom");
|
|
55
|
-
const CustomComponentRenderer_1 = __importDefault(require("../../../../../components/CustomComponentRenderer"));
|
|
56
|
-
const locale_1 = require("../../../../locale");
|
|
57
|
-
const header_1 = require("../../../../page/header");
|
|
58
|
-
const session_1 = require("../../../../session");
|
|
59
21
|
const SimpleHeader_1 = __importDefault(require("../../components/Header/SimpleHeader"));
|
|
60
22
|
const SimpleLayout_1 = __importDefault(require("../../components/Layout/SimpleLayout"));
|
|
61
|
-
const MarkdownRenderer_1 = __importDefault(require("../../components/MarkdownRenderer"));
|
|
62
|
-
const PopperMenuButton_1 = __importDefault(require("../../components/PopperMenuButton"));
|
|
63
|
-
const LoadingMenuItem_1 = __importDefault(require("../../components/PopperMenuButton/LoadingMenuItem"));
|
|
64
23
|
const ScrollView_1 = __importDefault(require("../../components/ScrollView"));
|
|
65
|
-
const
|
|
66
|
-
const
|
|
67
|
-
const
|
|
68
|
-
const
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
24
|
+
const ActiveAgent_1 = require("../../contexts/ActiveAgent");
|
|
25
|
+
const ComponentPreferences_1 = require("../../contexts/ComponentPreferences");
|
|
26
|
+
const CurrentAgent_1 = __importDefault(require("../../contexts/CurrentAgent"));
|
|
27
|
+
const use_header_menu_1 = require("../../hooks/use-header-menu");
|
|
28
|
+
const session_1 = require("../../state/session");
|
|
29
|
+
const BackgroundImage_1 = __importDefault(require("./BackgroundImage"));
|
|
30
|
+
const InputsView_1 = __importDefault(require("./InputsView"));
|
|
31
|
+
const MessagesView_1 = __importDefault(require("./MessagesView"));
|
|
32
|
+
function SimpleChat(_a) {
|
|
33
|
+
var { primaryColor, scrollViewProps = { scroll: 'window', initialScrollBehavior: 'auto' } } = _a, preferences = __rest(_a, ["primaryColor", "scrollViewProps"]);
|
|
34
|
+
(0, session_1.useAutoLoadSessionState)();
|
|
74
35
|
const inheritedTheme = (0, material_1.useTheme)();
|
|
75
|
-
const theme = (0,
|
|
36
|
+
const theme = (0, react_1.useMemo)(() => {
|
|
76
37
|
let { primary } = inheritedTheme.palette;
|
|
77
38
|
try {
|
|
78
39
|
if (primaryColor) {
|
|
@@ -89,93 +50,26 @@ function SimpleChat({ primaryColor, scrollViewProps = { scroll: 'window', initia
|
|
|
89
50
|
},
|
|
90
51
|
});
|
|
91
52
|
}, [inheritedTheme, primaryColor]);
|
|
92
|
-
return ((0, jsx_runtime_1.jsx)(ScrollView_1.default, Object.assign({}, scrollViewProps, { children: (0, jsx_runtime_1.
|
|
53
|
+
return ((0, jsx_runtime_1.jsx)(ComponentPreferences_1.ComponentPreferencesProvider, Object.assign({}, preferences, { children: (0, jsx_runtime_1.jsx)(ScrollView_1.default, Object.assign({}, scrollViewProps, { children: (0, jsx_runtime_1.jsxs)(material_1.ThemeProvider, { theme: theme, children: [(0, jsx_runtime_1.jsx)(BackgroundImage_1.default, {}), (0, jsx_runtime_1.jsx)(SimpleChatView, {})] }) })) })));
|
|
93
54
|
}
|
|
94
55
|
exports.default = SimpleChat;
|
|
95
|
-
function SimpleChatView(
|
|
96
|
-
const {
|
|
97
|
-
const { childAgentId } = (0, runtime_1.useRuntimeState)();
|
|
56
|
+
function SimpleChatView() {
|
|
57
|
+
const { activeAgentId } = (0, ActiveAgent_1.useActiveAgent)();
|
|
98
58
|
// auto scroll to bottom when new message is sent
|
|
99
|
-
const running = (0,
|
|
59
|
+
const running = (0, session_1.useCurrentSessionState)((s) => s === null || s === void 0 ? void 0 : s.running);
|
|
100
60
|
const scrollToBottom = (0, react_scroll_to_bottom_1.useScrollToBottom)();
|
|
101
|
-
(0,
|
|
61
|
+
(0, react_1.useEffect)(() => {
|
|
102
62
|
if (running)
|
|
103
63
|
scrollToBottom({ behavior: 'smooth' });
|
|
104
64
|
}, [scrollToBottom, running]);
|
|
105
|
-
|
|
106
|
-
(0,
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
function AgentInputRender(_a) {
|
|
117
|
-
var props = __rest(_a, []);
|
|
118
|
-
const { appearanceInput } = (0, use_appearances_1.default)();
|
|
119
|
-
if (!appearanceInput.componentId)
|
|
120
|
-
return null;
|
|
121
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Stack, Object.assign({}, props, { children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: appearanceInput.componentId, properties: appearanceInput.componentProps }) })));
|
|
122
|
-
}
|
|
123
|
-
function OutputView(_a) {
|
|
124
|
-
var props = __rest(_a, []);
|
|
125
|
-
const messages = (0, session_2.useCurrentSessionState)((s) => s === null || s === void 0 ? void 0 : s.messages);
|
|
126
|
-
const loaded = (0, session_2.useSessionState)((s) => s.loaded);
|
|
127
|
-
const showOpening = (0, session_2.useCurrentSessionState)((s) => !s || (s === null || s === void 0 ? void 0 : s.loaded)) && loaded;
|
|
128
|
-
const lastMessage = messages === null || messages === void 0 ? void 0 : messages.at(-1);
|
|
129
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ gap: 2 }, props, { children: [showOpening && (0, jsx_runtime_1.jsx)(OpeningMessageView, {}), messages === null || messages === void 0 ? void 0 : messages.map((message) => (0, jsx_runtime_1.jsx)(OutputItemView, { message: message }, message.taskId)), lastMessage && (0, jsx_runtime_1.jsx)(SuggestedQuestionsView, { message: lastMessage }), showOpening && !(messages === null || messages === void 0 ? void 0 : messages.length) && (0, jsx_runtime_1.jsx)(OpeningQuestionsView, {})] })));
|
|
130
|
-
}
|
|
131
|
-
const OutputItemView = (0, react_2.memo)(({ message }) => {
|
|
132
|
-
var _a, _b, _c, _d;
|
|
133
|
-
const { session: authSession } = (0, session_1.useSessionContext)();
|
|
134
|
-
const { appearanceOutput } = (0, use_appearances_1.default)({ agentId: message.assistantId });
|
|
135
|
-
const profile = (0, use_appearances_1.useProfile)({ agentId: message.assistantId });
|
|
136
|
-
if (!(appearanceOutput === null || appearanceOutput === void 0 ? void 0 : appearanceOutput.componentId))
|
|
137
|
-
return null;
|
|
138
|
-
return ((0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: message.assistantId, children: (0, jsx_runtime_1.jsx)(CurrentMessage_1.default, { message: message, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: 2, children: [(0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(UserInfo_1.default, { name: (_a = authSession.user) === null || _a === void 0 ? void 0 : _a.fullName, did: (_b = authSession.user) === null || _b === void 0 ? void 0 : _b.did, avatar: (_c = authSession.user) === null || _c === void 0 ? void 0 : _c.avatar, time: message.createdAt, reverse: true, alignItems: "flex-start", children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProps, props: {
|
|
139
|
-
renderType: 'parameters',
|
|
140
|
-
} }) }) }), (0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(UserInfo_1.default, { name: profile.name, did: (_d = globalThis.blocklet) === null || _d === void 0 ? void 0 : _d.appId, avatar: profile.avatar, time: message.createdAt, alignItems: "flex-start", children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProps, props: {
|
|
141
|
-
renderType: 'result',
|
|
142
|
-
} }) }) })] }) }) }));
|
|
143
|
-
});
|
|
144
|
-
function SuggestedQuestionsView({ message }) {
|
|
145
|
-
const { aid } = (0, CurrentAgent_1.useCurrentAgent)({ agentId: message.assistantId });
|
|
146
|
-
const { execute } = (0, runtime_1.useRuntimeState)();
|
|
147
|
-
const suggestedQuestions = (0, react_2.useMemo)(() => {
|
|
148
|
-
var _a, _b, _c;
|
|
149
|
-
return (_c = (_b = (_a = message === null || message === void 0 ? void 0 : message.result) === null || _a === void 0 ? void 0 : _a.objects) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.data[types_1.RuntimeOutputVariable.suggestedQuestions];
|
|
150
|
-
}, [message]);
|
|
151
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Box, { ml: 6.5, mr: 2.5, children: (suggestedQuestions === null || suggestedQuestions === void 0 ? void 0 : suggestedQuestions.length) ? ((0, jsx_runtime_1.jsx)(MessageSuggestedQuestions_1.default, { dataSource: suggestedQuestions, onClick: (item) => {
|
|
152
|
-
execute({ aid, parameters: Object.assign(Object.assign({}, message.parameters), { question: item.question }) });
|
|
153
|
-
} })) : null }));
|
|
154
|
-
}
|
|
155
|
-
const OpeningMessageView = (0, react_2.memo)(() => {
|
|
156
|
-
var _a;
|
|
157
|
-
const { childAgentId } = (0, runtime_1.useRuntimeState)();
|
|
158
|
-
const opening = (0, use_appearances_1.useOpeningMessage)({ agentId: childAgentId });
|
|
159
|
-
if (!(opening === null || opening === void 0 ? void 0 : opening.message))
|
|
160
|
-
return null;
|
|
161
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(UserInfo_1.default, { name: opening.profile.name, did: (_a = globalThis.blocklet) === null || _a === void 0 ? void 0 : _a.appId, avatar: opening.profile.avatar, alignItems: "flex-start", children: (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
|
|
162
|
-
bgcolor: 'rgba(229, 231, 235, 1)',
|
|
163
|
-
borderRadius: 1,
|
|
164
|
-
borderTopLeftRadius: 2,
|
|
165
|
-
px: 2,
|
|
166
|
-
py: 1,
|
|
167
|
-
mt: 0.5,
|
|
168
|
-
mr: 5,
|
|
169
|
-
}, children: (0, jsx_runtime_1.jsx)(MarkdownRenderer_1.default, { children: opening.message }) }) }) }));
|
|
170
|
-
});
|
|
171
|
-
function OpeningQuestionsView() {
|
|
172
|
-
const { execute } = (0, runtime_1.useRuntimeState)();
|
|
173
|
-
const { childAgentId } = (0, runtime_1.useRuntimeState)();
|
|
174
|
-
const { aid } = (0, CurrentAgent_1.useCurrentAgent)({ agentId: childAgentId });
|
|
175
|
-
const opening = (0, use_appearances_1.useOpeningQuestions)({ aid });
|
|
176
|
-
if (!(opening === null || opening === void 0 ? void 0 : opening.questions.length))
|
|
177
|
-
return null;
|
|
178
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Box, { ml: 6.5, mr: 2.5, children: (0, jsx_runtime_1.jsx)(material_1.Stack, { gap: 1, children: opening.questions.map((item) => {
|
|
179
|
-
return ((0, jsx_runtime_1.jsx)(MessageSuggestedQuestions_1.MessageSuggestedQuestion, { onClick: () => execute({ aid, parameters: Object.assign(Object.assign({}, item.parameters), { question: item.parameters.question || item.title }) }), children: item.title }, item.id));
|
|
180
|
-
}) }) }));
|
|
65
|
+
(0, use_header_menu_1.useHeaderMenu)();
|
|
66
|
+
return ((0, jsx_runtime_1.jsxs)(SimpleLayout_1.default, { children: [(0, jsx_runtime_1.jsx)(SimpleHeader_1.default, { px: 2 }), (0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: activeAgentId, children: (0, jsx_runtime_1.jsx)(MessagesView_1.default, { className: "aigne-outputs aigne-simple-chat-outputs", flexGrow: 1, pb: 10 }) }), (0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: activeAgentId, children: (0, jsx_runtime_1.jsx)(InputsView_1.default, { className: "aigne-inputs aigne-simple-chat-inputs", sx: {
|
|
67
|
+
position: 'sticky',
|
|
68
|
+
bottom: 0,
|
|
69
|
+
p: 2,
|
|
70
|
+
zIndex: 10,
|
|
71
|
+
borderRadius: 1,
|
|
72
|
+
bgcolor: (theme) => (0, material_1.alpha)(theme.palette.background.paper, 0.7),
|
|
73
|
+
backdropFilter: 'blur(10px)',
|
|
74
|
+
} }) })] }));
|
|
181
75
|
}
|
|
@@ -4,18 +4,44 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
const types_1 = require("@blocklet/ai-runtime/types");
|
|
7
8
|
const material_1 = require("@mui/material");
|
|
8
|
-
const
|
|
9
|
-
const
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
const CustomComponentRenderer_1 = __importDefault(require("../../../../../components/CustomComponentRenderer"));
|
|
11
|
+
const constants_1 = require("../../constants");
|
|
12
|
+
const CurrentAgent_1 = require("../../contexts/CurrentAgent");
|
|
10
13
|
const CurrentMessage_1 = require("../../contexts/CurrentMessage");
|
|
11
|
-
const
|
|
12
|
-
|
|
14
|
+
const ignoredOutputs = new Set([
|
|
15
|
+
types_1.RuntimeOutputVariable.appearancePage,
|
|
16
|
+
types_1.RuntimeOutputVariable.appearanceInput,
|
|
17
|
+
types_1.RuntimeOutputVariable.appearanceOutput,
|
|
18
|
+
types_1.RuntimeOutputVariable.openingQuestions,
|
|
19
|
+
types_1.RuntimeOutputVariable.openingMessage,
|
|
20
|
+
]);
|
|
13
21
|
function SimpleOutput() {
|
|
14
|
-
var _a, _b, _c;
|
|
15
22
|
const { message } = (0, CurrentMessage_1.useCurrentMessage)();
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
|
|
23
|
+
if (message.error)
|
|
24
|
+
throw message.error;
|
|
25
|
+
const { agent } = (0, CurrentAgent_1.useCurrentAgent)();
|
|
26
|
+
const outputs = (0, react_1.useMemo)(() => {
|
|
27
|
+
var _a;
|
|
28
|
+
return (_a = agent.outputVariables) === null || _a === void 0 ? void 0 : _a.map((i) => {
|
|
29
|
+
var _a, _b;
|
|
30
|
+
return (Object.assign(Object.assign({}, i), { appearance: Object.assign(Object.assign({}, i.appearance), { componentId: ((_a = i.appearance) === null || _a === void 0 ? void 0 : _a.componentId) || ((_b = (0, constants_1.getDefaultOutputComponent)(i)) === null || _b === void 0 ? void 0 : _b.componentId) }) }));
|
|
31
|
+
}).filter((i) => { var _a; return !!((_a = i.appearance) === null || _a === void 0 ? void 0 : _a.componentId) && !ignoredOutputs.has(i.name); });
|
|
32
|
+
}, [agent.outputVariables]);
|
|
33
|
+
if (!(outputs === null || outputs === void 0 ? void 0 : outputs.length))
|
|
34
|
+
return null;
|
|
35
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Stack, { gap: 2, children: outputs.map((output) => {
|
|
36
|
+
var _a, _b, _c, _d, _e;
|
|
37
|
+
const value = output.name === types_1.RuntimeOutputVariable.text
|
|
38
|
+
? (_a = message.result) === null || _a === void 0 ? void 0 : _a.content
|
|
39
|
+
: (_e = (_d = (_c = (_b = message.result) === null || _b === void 0 ? void 0 : _b.objects) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e[output.name];
|
|
40
|
+
return ((0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { instanceId: output.id, componentId: output.appearance.componentId, properties: output.appearance.componentProperties, props: {
|
|
41
|
+
output,
|
|
42
|
+
outputValue: value,
|
|
43
|
+
writing: output.name === types_1.RuntimeOutputVariable.text && message.loading,
|
|
44
|
+
} }, output.id));
|
|
45
|
+
}) }));
|
|
20
46
|
}
|
|
21
47
|
exports.default = SimpleOutput;
|