@blocklet/pages-kit 0.2.296 → 0.2.297

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.
Files changed (40) hide show
  1. package/lib/cjs/builtin/async/ai-runtime/components/RuntimeProvider.js +7 -2
  2. package/lib/cjs/builtin/async/ai-runtime/components/common/UserInfo.js +56 -0
  3. package/lib/cjs/builtin/async/ai-runtime/components/runtime/components/ChatOutput/MessageItemView.js +16 -12
  4. package/lib/cjs/builtin/async/ai-runtime/components/runtime/components/ChatOutput/index.js +13 -2
  5. package/lib/cjs/builtin/async/ai-runtime/components/runtime/components/PhotoGallery/index.js +10 -18
  6. package/lib/cjs/builtin/async/ai-runtime/components/runtime/components/PhotoGalleryItem/index.js +40 -26
  7. package/lib/cjs/builtin/async/ai-runtime/components/runtime/components/SimpleChat/index.js +21 -17
  8. package/lib/cjs/builtin/async/ai-runtime/components/runtime/components/SimpleOutput/index.js +2 -2
  9. package/lib/cjs/builtin/async/ai-runtime/components/runtime/components/SimplePage/index.js +10 -18
  10. package/lib/cjs/builtin/async/ai-runtime/components/runtime/constants.js +6 -0
  11. package/lib/cjs/builtin/async/ai-runtime/components/runtime/contexts/CurrentAgent.js +11 -1
  12. package/lib/cjs/builtin/async/ai-runtime/components/runtime/index.js +64 -11
  13. package/lib/cjs/builtin/async/ai-runtime/components/runtime/state/runtime.js +5 -1
  14. package/lib/cjs/builtin/async/ai-runtime/index.js +2 -2
  15. package/lib/cjs/builtin/async/ai-runtime/locales/index.js +7 -1
  16. package/lib/esm/builtin/async/ai-runtime/components/RuntimeProvider.js +5 -2
  17. package/lib/esm/builtin/async/ai-runtime/components/common/UserInfo.js +47 -0
  18. package/lib/esm/builtin/async/ai-runtime/components/runtime/components/ChatOutput/MessageItemView.js +16 -12
  19. package/lib/esm/builtin/async/ai-runtime/components/runtime/components/ChatOutput/index.js +13 -2
  20. package/lib/esm/builtin/async/ai-runtime/components/runtime/components/PhotoGallery/index.js +10 -18
  21. package/lib/esm/builtin/async/ai-runtime/components/runtime/components/PhotoGalleryItem/index.js +38 -27
  22. package/lib/esm/builtin/async/ai-runtime/components/runtime/components/SimpleChat/index.js +21 -17
  23. package/lib/esm/builtin/async/ai-runtime/components/runtime/components/SimpleOutput/index.js +1 -1
  24. package/lib/esm/builtin/async/ai-runtime/components/runtime/components/SimplePage/index.js +10 -18
  25. package/lib/esm/builtin/async/ai-runtime/components/runtime/constants.js +3 -0
  26. package/lib/esm/builtin/async/ai-runtime/components/runtime/contexts/CurrentAgent.js +11 -1
  27. package/lib/esm/builtin/async/ai-runtime/components/runtime/index.js +44 -14
  28. package/lib/esm/builtin/async/ai-runtime/components/runtime/state/runtime.js +5 -1
  29. package/lib/esm/builtin/async/ai-runtime/index.js +1 -1
  30. package/lib/esm/builtin/async/ai-runtime/locales/index.js +7 -1
  31. package/lib/types/builtin/async/ai-runtime/components/RuntimeProvider.d.ts +3 -0
  32. package/lib/types/builtin/async/ai-runtime/components/common/UserInfo.d.ts +17 -0
  33. package/lib/types/builtin/async/ai-runtime/components/runtime/components/ChatOutput/index.d.ts +4 -1
  34. package/lib/types/builtin/async/ai-runtime/components/runtime/components/SimpleOutput/index.d.ts +1 -1
  35. package/lib/types/builtin/async/ai-runtime/components/runtime/constants.d.ts +3 -0
  36. package/lib/types/builtin/async/ai-runtime/components/runtime/contexts/CurrentAgent.d.ts +3 -0
  37. package/lib/types/builtin/async/ai-runtime/components/runtime/state/runtime.d.ts +1 -0
  38. package/lib/types/builtin/async/ai-runtime/index.d.ts +1 -1
  39. package/lib/types/builtin/async/ai-runtime/locales/index.d.ts +6 -0
  40. package/package.json +1 -1
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.RuntimeLocaleProvider = void 0;
6
7
  const jsx_runtime_1 = require("react/jsx-runtime");
7
8
  const material_1 = require("@mui/material");
8
9
  const react_1 = __importDefault(require("react"));
@@ -13,10 +14,14 @@ const locales_1 = require("../locales");
13
14
  const GlobalLoading_1 = __importDefault(require("./GlobalLoading"));
14
15
  const ThemeProvider_1 = __importDefault(require("./ThemeProvider"));
15
16
  function RuntimeProvider({ children }) {
16
- const { locale } = (0, locale_1.useLocaleContext)();
17
- return ((0, jsx_runtime_1.jsx)(locale_1.LocaleProvider, { translations: locales_1.translations, locale: locale, fallbackLocale: "en", children: (0, jsx_runtime_1.jsx)(ThemeProvider_1.default, { children: (0, jsx_runtime_1.jsxs)(react_error_boundary_1.ErrorBoundary, { FallbackComponent: ErrorRender, children: [(0, jsx_runtime_1.jsx)(GlobalLoading_1.default, { sx: { position: 'fixed', left: 0, top: 0, width: '100%', zIndex: 'snackbar' } }), (0, jsx_runtime_1.jsx)(react_1.default.Suspense, { fallback: (0, jsx_runtime_1.jsx)(material_1.Stack, { flexGrow: 1, alignItems: "center", justifyContent: "center", children: (0, jsx_runtime_1.jsx)(material_1.CircularProgress, { size: 24 }) }), children: children })] }) }) }));
17
+ return ((0, jsx_runtime_1.jsx)(RuntimeLocaleProvider, { children: (0, jsx_runtime_1.jsx)(ThemeProvider_1.default, { children: (0, jsx_runtime_1.jsxs)(react_error_boundary_1.ErrorBoundary, { FallbackComponent: ErrorRender, children: [(0, jsx_runtime_1.jsx)(GlobalLoading_1.default, { sx: { position: 'fixed', left: 0, top: 0, width: '100%', zIndex: 'snackbar' } }), (0, jsx_runtime_1.jsx)(react_1.default.Suspense, { fallback: (0, jsx_runtime_1.jsx)(material_1.Stack, { flexGrow: 1, alignItems: "center", justifyContent: "center", children: (0, jsx_runtime_1.jsx)(material_1.CircularProgress, { size: 24 }) }), children: children })] }) }) }));
18
18
  }
19
19
  exports.default = RuntimeProvider;
20
20
  function ErrorRender({ error }) {
21
21
  return ((0, jsx_runtime_1.jsx)(ux_1.Result, { status: error.status || 'error', description: error.message, sx: { bgcolor: 'transparent', mt: '20%' } }));
22
22
  }
23
+ function RuntimeLocaleProvider({ children }) {
24
+ const { locale } = (0, locale_1.useLocaleContext)();
25
+ return ((0, jsx_runtime_1.jsx)(locale_1.LocaleProvider, { translations: locales_1.translations, locale: locale, fallbackLocale: "en", children: children }));
26
+ }
27
+ exports.RuntimeLocaleProvider = RuntimeLocaleProvider;
@@ -0,0 +1,56 @@
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
+ exports.UserTime = exports.UserName = void 0;
18
+ const jsx_runtime_1 = require("react/jsx-runtime");
19
+ const DID_1 = __importDefault(require("@arcblock/ux/lib/DID"));
20
+ const material_1 = require("@mui/material");
21
+ const dayjs_1 = __importDefault(require("dayjs"));
22
+ const react_1 = require("react");
23
+ const ux_1 = require("../../../../arcblock/ux");
24
+ function UserInfo(_a) {
25
+ var { avatar, showDID, did, name, time, children, reverse } = _a, restProps = __rest(_a, ["avatar", "showDID", "did", "name", "time", "children", "reverse"]);
26
+ return ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: "user-info", alignItems: "center", direction: reverse ? 'row-reverse' : 'row', gap: 1.5 }, restProps, { children: [(avatar || did) && ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
27
+ display: 'flex',
28
+ alignItems: 'center',
29
+ maxHeight: 44,
30
+ }, children: (0, jsx_runtime_1.jsx)(ux_1.Avatar, { size: 40, did: did, variant: "circle", shape: "circle", src: avatar }) })), (0, jsx_runtime_1.jsxs)(material_1.Box, { flex: 1, width: 0, children: [(0, jsx_runtime_1.jsxs)(UserName, { sx: {
31
+ justifyContent: reverse ? 'flex-end' : 'flex-start',
32
+ }, children: [name || '', time && ((0, jsx_runtime_1.jsx)(UserTime, { time: time, sx: {
33
+ fontSize: 12,
34
+ lineHeight: '24px',
35
+ color: 'text.secondary',
36
+ } }))] }), showDID && did && (0, jsx_runtime_1.jsx)(material_1.Box, { component: DID_1.default, did: did, copyable: false, size: 14, responsive: true, sx: { mt: -0.25 } }), (0, jsx_runtime_1.jsx)(material_1.Box, { flex: 1, children: children })] })] })));
37
+ }
38
+ exports.default = UserInfo;
39
+ function UserName(_a) {
40
+ var { children, sx } = _a, restProps = __rest(_a, ["children", "sx"]);
41
+ return ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ component: "div", noWrap: true, sx: Object.assign({ fontSize: 14, lineHeight: '24px', fontWeight: 500, display: 'flex', alignItems: 'center', gap: 1 }, sx) }, restProps, { children: children })));
42
+ }
43
+ exports.UserName = UserName;
44
+ function UserTime(_a) {
45
+ var { time } = _a, restProps = __rest(_a, ["time"]);
46
+ const formattedTime = (0, react_1.useMemo)(() => {
47
+ const date = (0, dayjs_1.default)(time);
48
+ if (!date.isValid())
49
+ return undefined;
50
+ return date.isSame((0, dayjs_1.default)(), 'date') ? date.format('HH:mm') : date.format('YYYY-MM-DD HH:mm');
51
+ }, [time]);
52
+ if (!formattedTime)
53
+ return null;
54
+ return ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({}, restProps, { children: formattedTime }), "user-time"));
55
+ }
56
+ exports.UserTime = UserTime;
@@ -43,6 +43,7 @@ const image_preview_1 = __importDefault(require("@blocklet/ai-kit/components/ima
43
43
  const css_1 = require("@emotion/css");
44
44
  const material_1 = require("@mui/material");
45
45
  const dayjs_1 = __importDefault(require("dayjs"));
46
+ const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
46
47
  const react_1 = __importStar(require("react"));
47
48
  const ux_1 = require("../../../../../../arcblock/ux");
48
49
  const session_1 = require("../../../../../../session");
@@ -55,13 +56,23 @@ const MessageItemView = (0, react_1.memo)((_a) => {
55
56
  var _b;
56
57
  var { message, hideAvatar } = _a, props = __rest(_a, ["message", "hideAvatar"]);
57
58
  const showUserMessage = !!((_b = message.parameters) === null || _b === void 0 ? void 0 : _b.question);
58
- return ((0, jsx_runtime_1.jsxs)(MessageItemContainer, Object.assign({}, props, { className: (0, css_1.cx)('ai-chat-message-item', hideAvatar && 'hide-avatar', props.className), children: [showUserMessage && (0, jsx_runtime_1.jsx)(UserMessage, { message: message }), (0, jsx_runtime_1.jsx)(AgentMessage, { message: message, hideAvatar: hideAvatar })] })));
59
+ return ((0, jsx_runtime_1.jsxs)(MessageItemContainer, Object.assign({}, props, { className: (0, css_1.cx)('ai-chat-message-item', hideAvatar && 'hide-avatar', props.className), children: [showUserMessage && !(0, isEmpty_1.default)(message.parameters) && (0, jsx_runtime_1.jsx)(UserMessage, { message: message, hideAvatar: hideAvatar }), !(0, isEmpty_1.default)(message.result) && (0, jsx_runtime_1.jsx)(AgentMessage, { message: message, hideAvatar: hideAvatar })] })));
59
60
  });
60
61
  exports.default = MessageItemView;
61
62
  const MessageItemContainer = (0, material_1.styled)(material_1.Stack) `
62
63
  gap: ${({ theme }) => theme.spacing(2.5)};
63
64
  overflow: hidden;
64
65
 
66
+ &.hide-avatar {
67
+ .message-question {
68
+ border-top-right-radius: ${({ theme }) => theme.shape.borderRadius}px;
69
+ }
70
+
71
+ .message-response {
72
+ border-top-left-radius: ${({ theme }) => theme.shape.borderRadius}px;
73
+ }
74
+ }
75
+
65
76
  .message-question {
66
77
  position: relative;
67
78
  border-radius: ${({ theme }) => theme.shape.borderRadius}px;
@@ -71,10 +82,6 @@ const MessageItemContainer = (0, material_1.styled)(material_1.Stack) `
71
82
  // without logo width
72
83
  max-width: calc(100% - 40px);
73
84
  background-color: rgba(239, 246, 255, 1);
74
-
75
- &.hide-avatar {
76
- border-top-right-radius: ${({ theme }) => theme.shape.borderRadius}px;
77
- }
78
85
  }
79
86
 
80
87
  .message-response {
@@ -85,14 +92,11 @@ const MessageItemContainer = (0, material_1.styled)(material_1.Stack) `
85
92
  margin-top: ${({ theme }) => theme.spacing(0.5)};
86
93
  // without logo width
87
94
  max-width: calc(100% - 40px);
95
+ display: inline-flex;
88
96
  background-color: rgba(229, 231, 235, 1);
89
-
90
- &.hide-avatar {
91
- border-top-left-radius: ${({ theme }) => theme.shape.borderRadius}px;
92
- }
93
97
  }
94
98
  `;
95
- function UserMessage({ message }) {
99
+ function UserMessage({ message, hideAvatar }) {
96
100
  var _a, _b, _c, _d;
97
101
  const { session: authSession } = (0, session_1.useSessionContext)();
98
102
  return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { className: "ai-chat-message-user", direction: "row", gap: 1.5, sx: {
@@ -100,11 +104,11 @@ function UserMessage({ message }) {
100
104
  flexDirection: 'row-reverse',
101
105
  textAlign: 'right',
102
106
  justifyContent: 'flex-end',
103
- }, children: [(0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(ux_1.Avatar, { size: 40, src: (_a = authSession.user) === null || _a === void 0 ? void 0 : _a.avatar, did: (_b = authSession.user) === null || _b === void 0 ? void 0 : _b.did, variant: "circle", shape: "circle" }) }), (0, jsx_runtime_1.jsxs)(material_1.Stack, { flex: 1, overflow: "hidden", sx: {
107
+ }, children: [!hideAvatar && ((0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(ux_1.Avatar, { size: 40, src: (_a = authSession.user) === null || _a === void 0 ? void 0 : _a.avatar, did: (_b = authSession.user) === null || _b === void 0 ? void 0 : _b.did, variant: "circle", shape: "circle" }) })), (0, jsx_runtime_1.jsxs)(material_1.Stack, { flex: 1, overflow: "hidden", sx: {
104
108
  display: 'flex',
105
109
  flexDirection: 'column',
106
110
  alignItems: 'flex-end',
107
- }, children: [(0, jsx_runtime_1.jsxs)(MessageUserName, { children: [(_c = authSession.user) === null || _c === void 0 ? void 0 : _c.fullName, (0, jsx_runtime_1.jsx)(MessageTime, { time: message.createdAt })] }), (0, jsx_runtime_1.jsx)(material_1.Box, { className: "message-question", sx: { whiteSpace: 'pre-wrap', wordBreak: 'break-word', textAlign: 'left' }, children: (_d = message.parameters) === null || _d === void 0 ? void 0 : _d.question })] })] }));
111
+ }, children: [!hideAvatar && ((0, jsx_runtime_1.jsxs)(MessageUserName, { children: [(_c = authSession.user) === null || _c === void 0 ? void 0 : _c.fullName, (0, jsx_runtime_1.jsx)(MessageTime, { time: message.createdAt })] })), (0, jsx_runtime_1.jsx)(material_1.Box, { className: "message-question", sx: { whiteSpace: 'pre-wrap', wordBreak: 'break-word', textAlign: 'left' }, children: (_d = message.parameters) === null || _d === void 0 ? void 0 : _d.question })] })] }));
108
112
  }
109
113
  function AgentMessage({ message, hideAvatar }) {
110
114
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
@@ -4,10 +4,21 @@ 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 react_1 = require("react");
7
8
  const CurrentMessage_1 = require("../../contexts/CurrentMessage");
8
9
  const MessageItemView_1 = __importDefault(require("./MessageItemView"));
9
- function ChatOutput() {
10
+ // default hideAvatar to true, only show message when polish agent layout
11
+ function ChatOutput({ hideAvatar = true, renderType, }) {
10
12
  const { message } = (0, CurrentMessage_1.useCurrentMessage)();
11
- return (0, jsx_runtime_1.jsx)(MessageItemView_1.default, { message: message });
13
+ const formattedMessage = (0, react_1.useMemo)(() => {
14
+ if (renderType) {
15
+ return Object.assign({}, message, {
16
+ result: renderType === 'parameters' ? {} : message.result,
17
+ parameters: renderType === 'result' ? {} : message.parameters,
18
+ });
19
+ }
20
+ return message;
21
+ }, [message, renderType]);
22
+ return (0, jsx_runtime_1.jsx)(MessageItemView_1.default, { message: formattedMessage, hideAvatar: hideAvatar });
12
23
  }
13
24
  exports.default = ChatOutput;
@@ -27,7 +27,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  const jsx_runtime_1 = require("react/jsx-runtime");
30
- const types_1 = require("@blocklet/ai-runtime/types");
31
30
  const lab_1 = require("@mui/lab");
32
31
  const material_1 = require("@mui/material");
33
32
  const react_1 = require("react");
@@ -40,12 +39,7 @@ const CurrentMessage_1 = __importDefault(require("../../contexts/CurrentMessage"
40
39
  const runtime_1 = require("../../state/runtime");
41
40
  const map_right_1 = __importDefault(require("../../utils/map-right"));
42
41
  function PhotoGallery({ resultTitle, background, primaryColor, }) {
43
- var _a;
44
- const { appearancePage, agent } = (0, runtime_1.useRuntimeState)();
45
- const children = (0, react_1.useMemo)(() => {
46
- var _a, _b;
47
- return (_b = (_a = agent.outputVariables) === null || _a === void 0 ? void 0 : _a.find((i) => i.name === types_1.RuntimeOutputVariable.children)) === null || _b === void 0 ? void 0 : _b.initialValue;
48
- }, [agent]);
42
+ const { agent, appearancePage, childAgentId } = (0, runtime_1.useRuntimeState)();
49
43
  const inheritedTheme = (0, material_1.useTheme)();
50
44
  const theme = (0, react_1.useMemo)(() => {
51
45
  let { primary } = inheritedTheme.palette;
@@ -64,7 +58,9 @@ function PhotoGallery({ resultTitle, background, primaryColor, }) {
64
58
  },
65
59
  });
66
60
  }, [inheritedTheme, primaryColor]);
67
- return ((0, jsx_runtime_1.jsx)(material_1.ThemeProvider, { theme: theme, children: (0, jsx_runtime_1.jsxs)(Root, { className: "photo-wall-root", sx: { backgroundImage: `url(${background})` }, children: [(0, jsx_runtime_1.jsx)(material_1.Stack, { className: "photo-wall-header", children: (0, jsx_runtime_1.jsxs)(react_wrap_balancer_1.Provider, { children: [(appearancePage === null || appearancePage === void 0 ? void 0 : appearancePage.name) && ((0, jsx_runtime_1.jsx)(material_1.Typography, { component: "h2", fontSize: 48, fontWeight: 700, textAlign: "center", children: (0, jsx_runtime_1.jsx)(react_wrap_balancer_1.default, { children: appearancePage.name }) })), (appearancePage === null || appearancePage === void 0 ? void 0 : appearancePage.description) && ((0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 20, textAlign: "center", children: (0, jsx_runtime_1.jsx)(react_wrap_balancer_1.default, { children: appearancePage.description }) }))] }) }), (0, jsx_runtime_1.jsx)(material_1.Stack, { className: "photo-wall-input", children: (_a = children === null || children === void 0 ? void 0 : children.agents) === null || _a === void 0 ? void 0 : _a.map((i) => ((0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: i.id, children: (0, jsx_runtime_1.jsx)(AgentInputRender, {}) }, i.id))) }), (0, jsx_runtime_1.jsxs)(material_1.Stack, { className: "photo-wall-output", gap: 2, children: [resultTitle && ((0, jsx_runtime_1.jsx)(material_1.Typography, { component: "h2", fontSize: 48, fontWeight: 700, textAlign: "center", children: (0, jsx_runtime_1.jsx)(react_wrap_balancer_1.default, { children: resultTitle }) })), (0, jsx_runtime_1.jsx)(OutputView, {})] })] }) }));
61
+ const title = (appearancePage === null || appearancePage === void 0 ? void 0 : appearancePage.name) || agent.name;
62
+ const description = (appearancePage === null || appearancePage === void 0 ? void 0 : appearancePage.description) || agent.description;
63
+ return ((0, jsx_runtime_1.jsx)(material_1.ThemeProvider, { theme: theme, children: (0, jsx_runtime_1.jsxs)(Root, { className: "photo-wall-root", sx: { backgroundImage: `url(${background})` }, children: [(0, jsx_runtime_1.jsx)(material_1.Stack, { className: "photo-wall-header", children: (0, jsx_runtime_1.jsxs)(react_wrap_balancer_1.Provider, { children: [title && ((0, jsx_runtime_1.jsx)(material_1.Typography, { component: "h2", fontSize: 48, fontWeight: 700, textAlign: "center", children: (0, jsx_runtime_1.jsx)(react_wrap_balancer_1.default, { children: title }) })), description && ((0, jsx_runtime_1.jsx)(material_1.Typography, { fontSize: 20, textAlign: "center", children: (0, jsx_runtime_1.jsx)(react_wrap_balancer_1.default, { children: description }) }))] }) }), (0, jsx_runtime_1.jsx)(material_1.Stack, { className: "photo-wall-input", children: (0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: childAgentId, children: (0, jsx_runtime_1.jsx)(AgentInputRender, {}) }) }), (0, jsx_runtime_1.jsxs)(material_1.Stack, { className: "photo-wall-output", gap: 2, children: [resultTitle && ((0, jsx_runtime_1.jsx)(material_1.Typography, { component: "h2", fontSize: 48, fontWeight: 700, textAlign: "center", children: (0, jsx_runtime_1.jsx)(react_wrap_balancer_1.default, { children: resultTitle }) })), (0, jsx_runtime_1.jsx)(OutputView, {})] })] }) }));
68
64
  }
69
65
  exports.default = PhotoGallery;
70
66
  const Root = (0, material_1.styled)(material_1.Stack)(({ theme }) => theme.unstable_sx({
@@ -100,12 +96,10 @@ const Root = (0, material_1.styled)(material_1.Stack)(({ theme }) => theme.unsta
100
96
  },
101
97
  }));
102
98
  function AgentInputRender() {
103
- var _a, _b;
104
- const { agent } = (0, CurrentAgent_1.useCurrentAgent)();
105
- const input = (_b = (_a = agent.outputVariables) === null || _a === void 0 ? void 0 : _a.find((i) => i.name === types_1.RuntimeOutputVariable.appearanceInput)) === null || _b === void 0 ? void 0 : _b.initialValue;
106
- if (!(input === null || input === void 0 ? void 0 : input.componentId))
99
+ const { appearanceInput } = (0, CurrentAgent_1.useCurrentAgent)();
100
+ if (!(appearanceInput === null || appearanceInput === void 0 ? void 0 : appearanceInput.componentId))
107
101
  return null;
108
- return ((0, jsx_runtime_1.jsx)(material_1.Stack, { children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: input.componentId, properties: input.componentProps }) }));
102
+ return ((0, jsx_runtime_1.jsx)(material_1.Stack, { children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: appearanceInput.componentId, properties: appearanceInput.componentProps }) }));
109
103
  }
110
104
  function NoOutputs() {
111
105
  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." }) }));
@@ -120,10 +114,8 @@ function OutputView() {
120
114
  } })), (0, map_right_1.default)((_d = sessionState.messages) !== null && _d !== void 0 ? _d : [], (message) => ((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)(OutputItemView, {}) }) }) }, message.taskId)))] }), (0, jsx_runtime_1.jsx)(material_1.Box, { my: 4, children: !!((_e = sessionState.messages) === null || _e === void 0 ? void 0 : _e.length) && !sessionState.noMoreMessage && ((0, jsx_runtime_1.jsx)(LoadingButton_1.default, { variant: "outlined", onClick: sessionState.loadMoreMessages, children: t('loadMore') })) })] }));
121
115
  }
122
116
  function OutputItemView() {
123
- var _a, _b;
124
- const { agent } = (0, CurrentAgent_1.useCurrentAgent)();
125
- const input = (_b = (_a = agent.outputVariables) === null || _a === void 0 ? void 0 : _a.find((i) => i.name === types_1.RuntimeOutputVariable.appearanceOutput)) === null || _b === void 0 ? void 0 : _b.initialValue;
126
- if (!(input === null || input === void 0 ? void 0 : input.componentId))
117
+ const { appearanceOutput } = (0, CurrentAgent_1.useCurrentAgent)();
118
+ if (!(appearanceOutput === null || appearanceOutput === void 0 ? void 0 : appearanceOutput.componentId))
127
119
  return null;
128
- return (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: input.componentId, properties: input.componentProps });
120
+ return ((0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProps }));
129
121
  }
@@ -10,14 +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
17
  const jsx_runtime_1 = require("react/jsx-runtime");
15
18
  const types_1 = require("@blocklet/ai-runtime/types");
16
19
  const react_1 = require("@iconify/react");
17
20
  const material_1 = require("@mui/material");
18
21
  const react_2 = require("react");
22
+ const ux_1 = require("../../../../../../arcblock/ux");
19
23
  const locale_1 = require("../../../../../../locale");
24
+ const session_1 = require("../../../../../../session");
20
25
  const ActionButton_1 = require("../../../ActionButton");
26
+ const UserInfo_1 = __importDefault(require("../../../common/UserInfo"));
21
27
  const CurrentMessage_1 = require("../../contexts/CurrentMessage");
22
28
  const getLineClamp = (line) => ({
23
29
  display: '-webkit-box',
@@ -73,12 +79,17 @@ function PhotoGalleryItem() {
73
79
  });
74
80
  }
75
81
  exports.default = PhotoGalleryItem;
82
+ function RenderSubTitle({ children }) {
83
+ return ((0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "caption", sx: { fontSize: 14 }, children: children }));
84
+ }
76
85
  function PromptDialog(_a) {
86
+ var _b, _c, _d;
77
87
  var { url } = _a, props = __rest(_a, ["url"]);
78
88
  const { message } = (0, CurrentMessage_1.useCurrentMessage)();
79
89
  const { parameters } = message;
80
- const theme = (0, material_1.useTheme)();
81
90
  const { t } = (0, locale_1.useLocaleContext)();
91
+ const { session: authSession } = (0, session_1.useSessionContext)();
92
+ const borderRadius = 1;
82
93
  return ((0, jsx_runtime_1.jsxs)(material_1.Dialog, Object.assign({ fullWidth: true, maxWidth: false, scroll: "paper", slotProps: {
83
94
  backdrop: {
84
95
  sx: {
@@ -86,32 +97,35 @@ function PromptDialog(_a) {
86
97
  backdropFilter: 'blur(12px)',
87
98
  },
88
99
  },
89
- } }, props, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, { sx: { position: 'absolute', right: 0, top: 0, p: 0.5 }, children: (0, jsx_runtime_1.jsx)(material_1.Button, { onClick: (e) => { var _a; return (_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props, e, 'backdropClick'); }, variant: "contained", disableElevation: true, sx: {
90
- bgcolor: (theme) => (0, material_1.alpha)(theme.palette.primary.light, 0.2),
91
- minWidth: 32,
92
- minHeight: 32,
93
- p: 0,
94
- fontSize: 22,
95
- color: 'primary.main',
96
- ':hover': {
97
- bgcolor: (theme) => (0, material_1.alpha)(theme.palette.primary.light, 0.3),
98
- },
99
- }, children: (0, jsx_runtime_1.jsx)(react_1.Icon, { icon: "tabler:x" }) }) }), (0, jsx_runtime_1.jsx)(material_1.DialogContent, { children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: 4, sx: { flexDirection: { md: 'row' } }, children: [(0, jsx_runtime_1.jsxs)(material_1.Stack, { sx: { flex: 3, width: { xs: '100%', md: 0 }, gap: 1 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { component: "h5", sx: { fontSize: 24, fontWeight: 700, color: 'primary.main' }, children: t('photoWall.dialog.title') }), (0, jsx_runtime_1.jsx)(material_1.Box, { component: "img", src: url, alt: "", loading: "lazy", sx: {
100
- display: 'block',
101
- width: '100%',
102
- borderRadius: 1,
103
- } })] }), (0, jsx_runtime_1.jsxs)(material_1.Stack, { sx: { flex: 2, width: { xs: '100%', md: 0 }, gap: 1 }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { component: "h5", sx: { fontSize: 24, fontWeight: 700, color: 'primary.main' }, children: t('photoWall.dialog.prompt') }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
104
- p: 2,
105
- borderRadius: 1,
106
- background: (theme) => `linear-gradient(to top, ${(0, material_1.alpha)(theme.palette.primary.light, 0.5)}, ${(0, material_1.alpha)(theme.palette.primary.light, 0.1)})`,
107
- }, children: (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
108
- backgroundColor: 'rgba(255,255,255,0.2)',
109
- borderRadius: 1,
110
- p: 1,
111
- fontSize: 16,
112
- }, children: parameters === null || parameters === void 0 ? void 0 : parameters.question }) }), (0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(ActionButton_1.ActionButton, { autoReset: true, size: "small", variant: "contained", placement: "right", tip: t('copyToClipboard'), title: t('copy'), titleSucceed: t('copied'), icon: "tabler:copy", iconSucceed: "tabler:copy-check-filled", onClick: () => {
100
+ } }, props, { children: [(0, jsx_runtime_1.jsxs)(material_1.DialogTitle, { sx: {
101
+ display: 'flex',
102
+ justifyContent: 'space-between',
103
+ }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { component: "h5", sx: { fontSize: 24, fontWeight: 700, color: 'primary.main' }, children: t('photoWall.dialog.title') }), (0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(material_1.Button, { onClick: (e) => { var _a; return (_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props, e, 'backdropClick'); }, variant: "contained", disableElevation: true, sx: {
104
+ bgcolor: (theme) => (0, material_1.alpha)(theme.palette.primary.light, 0.2),
105
+ minWidth: 32,
106
+ minHeight: 32,
107
+ p: 0,
108
+ fontSize: 22,
109
+ color: 'primary.main',
110
+ ':hover': {
111
+ bgcolor: (theme) => (0, material_1.alpha)(theme.palette.primary.light, 0.3),
112
+ },
113
+ }, children: (0, jsx_runtime_1.jsx)(react_1.Icon, { icon: "tabler:x" }) }) })] }), (0, jsx_runtime_1.jsx)(material_1.DialogContent, { children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: 2.5, sx: { flexDirection: { md: 'row' } }, children: [(0, jsx_runtime_1.jsx)(material_1.Stack, { sx: { flex: 3, width: { xs: '100%', md: 0 }, gap: 1 }, children: (0, jsx_runtime_1.jsx)(material_1.Box, { component: "img", src: url, alt: "", loading: "lazy", sx: {
114
+ display: 'block',
115
+ width: '100%',
116
+ borderRadius,
117
+ } }) }), (0, jsx_runtime_1.jsxs)(material_1.Stack, { sx: { flex: 2, width: { xs: '100%', md: 0 }, gap: 1 }, children: [(0, jsx_runtime_1.jsx)(RenderSubTitle, { children: t('photoWall.dialog.author') }), (0, jsx_runtime_1.jsx)(UserInfo_1.default, { showDID: true, 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 }), (0, jsx_runtime_1.jsx)(material_1.Box, {}), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { fontSize: 14, color: 'text.secondary' }, children: (0, jsx_runtime_1.jsx)(ux_1.RelativeTime, { value: message.createdAt }) }), (0, jsx_runtime_1.jsx)(material_1.Box, {}), (0, jsx_runtime_1.jsx)(RenderSubTitle, { children: t('photoWall.dialog.prompt') }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
118
+ backgroundColor: 'background.paper',
119
+ borderRadius,
120
+ p: 1,
121
+ fontSize: 16,
122
+ border: 1,
123
+ borderColor: 'divider',
124
+ overflow: 'auto',
125
+ maxHeight: { xs: 'unset', md: '40vh' },
126
+ }, children: parameters === null || parameters === void 0 ? void 0 : parameters.question }), (0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(ActionButton_1.ActionButton, { autoReset: true, size: "small", variant: "contained", placement: "right", tip: t('copyToClipboard'), title: t('copy'), titleSucceed: t('copied'), icon: "tabler:copy", iconSucceed: "tabler:copy-check-filled", onClick: () => {
113
127
  window.navigator.clipboard.writeText(parameters === null || parameters === void 0 ? void 0 : parameters.question);
114
128
  }, sx: {
115
- borderRadius: theme.shape.borderRadius,
129
+ borderRadius,
116
130
  } }) })] })] }) })] })));
117
131
  }
@@ -32,7 +32,9 @@ const material_1 = require("@mui/material");
32
32
  const react_1 = require("react");
33
33
  const react_wrap_balancer_1 = __importStar(require("react-wrap-balancer"));
34
34
  const CustomComponentRenderer_1 = __importDefault(require("../../../../../../../components/CustomComponentRenderer"));
35
+ const session_1 = require("../../../../../../session");
35
36
  const common_1 = require("../../../common");
37
+ const UserInfo_1 = __importDefault(require("../../../common/UserInfo"));
36
38
  const ScrollView_1 = __importStar(require("../../../ScrollView"));
37
39
  const CurrentAgent_1 = __importStar(require("../../contexts/CurrentAgent"));
38
40
  const CurrentMessage_1 = __importStar(require("../../contexts/CurrentMessage"));
@@ -60,26 +62,21 @@ function SimpleChat({ primaryColor }) {
60
62
  }
61
63
  exports.default = SimpleChat;
62
64
  function SimpleChatView() {
63
- var _a;
64
- const { agent, appearancePage, sessionState } = (0, runtime_1.useRuntimeState)();
65
+ const { agent, childAgentId, appearancePage, sessionState } = (0, runtime_1.useRuntimeState)();
65
66
  const scrollToBottom = (0, ScrollView_1.useScrollToBottomModule)().useScrollToBottom();
66
67
  (0, react_1.useEffect)(() => {
67
68
  if (sessionState.running)
68
69
  scrollToBottom();
69
70
  }, [scrollToBottom, sessionState.running]);
70
- const children = (0, react_1.useMemo)(() => {
71
- var _a, _b;
72
- return (_b = (_a = agent.outputVariables) === null || _a === void 0 ? void 0 : _a.find((i) => i.name === types_1.RuntimeOutputVariable.children)) === null || _b === void 0 ? void 0 : _b.initialValue;
73
- }, [agent]);
74
- return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { flexGrow: 1, maxWidth: "md", width: "100%", mx: "auto", px: { xs: 2, sm: 3 }, children: [(0, jsx_runtime_1.jsx)(material_1.Stack, { gap: 2, mt: 8, mb: 4, children: (0, jsx_runtime_1.jsxs)(react_wrap_balancer_1.Provider, { children: [(appearancePage === null || appearancePage === void 0 ? void 0 : appearancePage.name) && ((0, jsx_runtime_1.jsx)(material_1.Typography, { component: "h5", fontSize: 30, fontWeight: 700, textAlign: "center", children: (0, jsx_runtime_1.jsx)(react_wrap_balancer_1.default, { children: appearancePage.name }) })), (appearancePage === null || appearancePage === void 0 ? void 0 : appearancePage.description) && ((0, jsx_runtime_1.jsx)(material_1.Typography, { textAlign: "center", children: (0, jsx_runtime_1.jsx)(react_wrap_balancer_1.default, { children: appearancePage.description }) }))] }) }), (0, jsx_runtime_1.jsx)(material_1.Stack, { children: (0, jsx_runtime_1.jsx)(OutputView, {}) }), (0, jsx_runtime_1.jsx)(material_1.Box, { flexGrow: 1, minHeight: 200 }), (0, jsx_runtime_1.jsx)(material_1.Stack, { sx: { position: 'sticky', bottom: 0, py: 1, bgcolor: 'background.paper', zIndex: 10 }, children: (_a = children === null || children === void 0 ? void 0 : children.agents) === null || _a === void 0 ? void 0 : _a.map((i) => ((0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: i.id, children: (0, jsx_runtime_1.jsx)(AgentInputRender, {}) }, i.id))) })] }));
71
+ const title = (appearancePage === null || appearancePage === void 0 ? void 0 : appearancePage.name) || agent.name;
72
+ const description = (appearancePage === null || appearancePage === void 0 ? void 0 : appearancePage.description) || agent.description;
73
+ return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { flexGrow: 1, maxWidth: "md", width: "100%", mx: "auto", px: { xs: 2, sm: 3 }, children: [(0, jsx_runtime_1.jsx)(material_1.Stack, { gap: 2, mt: 8, mb: 4, children: (0, jsx_runtime_1.jsxs)(react_wrap_balancer_1.Provider, { children: [title && ((0, jsx_runtime_1.jsx)(material_1.Typography, { component: "h5", fontSize: 30, fontWeight: 700, textAlign: "center", children: (0, jsx_runtime_1.jsx)(react_wrap_balancer_1.default, { children: title }) })), description && ((0, jsx_runtime_1.jsx)(material_1.Typography, { textAlign: "center", children: (0, jsx_runtime_1.jsx)(react_wrap_balancer_1.default, { children: description }) }))] }) }), (0, jsx_runtime_1.jsx)(material_1.Stack, { children: (0, jsx_runtime_1.jsx)(OutputView, {}) }), (0, jsx_runtime_1.jsx)(material_1.Box, { flexGrow: 1, minHeight: 200 }), (0, jsx_runtime_1.jsx)(material_1.Stack, { sx: { position: 'sticky', bottom: 0, py: 1, bgcolor: 'background.paper', zIndex: 10 }, children: (0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: childAgentId, children: (0, jsx_runtime_1.jsx)(AgentInputRender, {}) }) })] }));
75
74
  }
76
75
  function AgentInputRender() {
77
- var _a, _b;
78
- const { agent } = (0, CurrentAgent_1.useCurrentAgent)();
79
- const input = (_b = (_a = agent.outputVariables) === null || _a === void 0 ? void 0 : _a.find((i) => i.name === types_1.RuntimeOutputVariable.appearanceInput)) === null || _b === void 0 ? void 0 : _b.initialValue;
80
- if (!(input === null || input === void 0 ? void 0 : input.componentId))
76
+ const { appearanceInput } = (0, CurrentAgent_1.useCurrentAgent)();
77
+ if (!(appearanceInput === null || appearanceInput === void 0 ? void 0 : appearanceInput.componentId))
81
78
  return null;
82
- return ((0, jsx_runtime_1.jsx)(material_1.Stack, { children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: input.componentId, properties: input.componentProps }) }));
79
+ return ((0, jsx_runtime_1.jsx)(material_1.Stack, { children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: appearanceInput.componentId, properties: appearanceInput.componentProps }) }));
83
80
  }
84
81
  function OutputView() {
85
82
  var _a, _b;
@@ -88,12 +85,19 @@ function OutputView() {
88
85
  return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: 2, children: [(_b = sessionState.messages) === null || _b === void 0 ? void 0 : _b.map((message) => ((0, jsx_runtime_1.jsx)(material_1.Stack, { children: (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)(OutputItemView, {}) }) }) }) }))), lastMessage && ((0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: lastMessage.assistantId, children: (0, jsx_runtime_1.jsx)(CurrentMessage_1.default, { message: lastMessage, children: (0, jsx_runtime_1.jsx)(SuggestedQuestionsView, {}) }) }))] }));
89
86
  }
90
87
  function OutputItemView() {
91
- var _a, _b;
92
- const { agent } = (0, CurrentAgent_1.useCurrentAgent)();
93
- const input = (_b = (_a = agent.outputVariables) === null || _a === void 0 ? void 0 : _a.find((i) => i.name === types_1.RuntimeOutputVariable.appearanceOutput)) === null || _b === void 0 ? void 0 : _b.initialValue;
94
- if (!(input === null || input === void 0 ? void 0 : input.componentId))
88
+ var _a, _b, _c, _d, _e;
89
+ const { appearancePage } = (0, runtime_1.useRuntimeState)();
90
+ const { appearanceOutput } = (0, CurrentAgent_1.useCurrentAgent)();
91
+ const { message } = (0, CurrentMessage_1.useCurrentMessage)();
92
+ const { session: authSession } = (0, session_1.useSessionContext)();
93
+ if (!(appearanceOutput === null || appearanceOutput === void 0 ? void 0 : appearanceOutput.componentId))
95
94
  return null;
96
- return (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: input.componentId, properties: input.componentProps });
95
+ // return <CustomComponentRenderer componentId={input.componentId} properties={input.componentProps} props={{hideAvatar: false}} />;
96
+ return ((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: {
97
+ renderType: 'parameters',
98
+ } }) }) }), (0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(UserInfo_1.default, { name: appearancePage === null || appearancePage === void 0 ? void 0 : appearancePage.name, did: (_d = globalThis.blocklet) === null || _d === void 0 ? void 0 : _d.appId, avatar: (_e = appearancePage === null || appearancePage === void 0 ? void 0 : appearancePage.logo) === null || _e === void 0 ? void 0 : _e.url, time: message.createdAt, alignItems: "flex-start", children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProps, props: {
99
+ renderType: 'result',
100
+ } }) }) })] }));
97
101
  }
98
102
  function SuggestedQuestionsView() {
99
103
  const { execute } = (0, runtime_1.useRuntimeState)();
@@ -8,10 +8,10 @@ const material_1 = require("@mui/material");
8
8
  const common_1 = require("../../../common");
9
9
  const MarkdownRenderer_1 = __importDefault(require("../../../MarkdownRenderer"));
10
10
  const CurrentMessage_1 = require("../../contexts/CurrentMessage");
11
- function BaseOutputs() {
11
+ function SimpleOutput() {
12
12
  var _a, _b;
13
13
  const { message } = (0, CurrentMessage_1.useCurrentMessage)();
14
14
  const objects = (_a = message.result) === null || _a === void 0 ? void 0 : _a.objects;
15
15
  return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: 2, boxShadow: 1, borderRadius: 1, p: 2, children: [(0, jsx_runtime_1.jsx)(MarkdownRenderer_1.default, { children: (_b = message.result) === null || _b === void 0 ? void 0 : _b.content }), objects === null || objects === void 0 ? void 0 : objects.map((item) => (0, jsx_runtime_1.jsx)(common_1.MessageMetadataRenderer, { object: item.data }))] }));
16
16
  }
17
- exports.default = BaseOutputs;
17
+ exports.default = SimpleOutput;
@@ -27,7 +27,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  const jsx_runtime_1 = require("react/jsx-runtime");
30
- const types_1 = require("@blocklet/ai-runtime/types");
31
30
  const material_1 = require("@mui/material");
32
31
  const react_1 = require("react");
33
32
  const react_wrap_balancer_1 = __importStar(require("react-wrap-balancer"));
@@ -36,12 +35,7 @@ const CurrentAgent_1 = __importStar(require("../../contexts/CurrentAgent"));
36
35
  const CurrentMessage_1 = __importDefault(require("../../contexts/CurrentMessage"));
37
36
  const runtime_1 = require("../../state/runtime");
38
37
  function SimplePage({ resultTitle, primaryColor }) {
39
- var _a;
40
- const { agent, appearancePage } = (0, runtime_1.useRuntimeState)();
41
- const children = (0, react_1.useMemo)(() => {
42
- var _a, _b;
43
- return (_b = (_a = agent.outputVariables) === null || _a === void 0 ? void 0 : _a.find((i) => i.name === types_1.RuntimeOutputVariable.children)) === null || _b === void 0 ? void 0 : _b.initialValue;
44
- }, [agent]);
38
+ const { agent, appearancePage, childAgentId } = (0, runtime_1.useRuntimeState)();
45
39
  const inheritedTheme = (0, material_1.useTheme)();
46
40
  const theme = (0, react_1.useMemo)(() => {
47
41
  let { primary } = inheritedTheme.palette;
@@ -60,16 +54,16 @@ function SimplePage({ resultTitle, primaryColor }) {
60
54
  },
61
55
  });
62
56
  }, [inheritedTheme, primaryColor]);
63
- return ((0, jsx_runtime_1.jsx)(material_1.ThemeProvider, { theme: theme, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: 2, maxWidth: "md", width: "100%", mx: "auto", px: { xs: 2, sm: 3 }, children: [(0, jsx_runtime_1.jsx)(material_1.Stack, { gap: 2, mt: 8, mb: 4, children: (0, jsx_runtime_1.jsxs)(react_wrap_balancer_1.Provider, { children: [(appearancePage === null || appearancePage === void 0 ? void 0 : appearancePage.name) && ((0, jsx_runtime_1.jsx)(material_1.Typography, { component: "h5", fontSize: 30, fontWeight: 700, textAlign: "center", children: (0, jsx_runtime_1.jsx)(react_wrap_balancer_1.default, { children: appearancePage.name }) })), (appearancePage === null || appearancePage === void 0 ? void 0 : appearancePage.description) && ((0, jsx_runtime_1.jsx)(material_1.Typography, { textAlign: "center", children: (0, jsx_runtime_1.jsx)(react_wrap_balancer_1.default, { children: appearancePage.description }) }))] }) }), (0, jsx_runtime_1.jsx)(material_1.Stack, { children: (_a = children === null || children === void 0 ? void 0 : children.agents) === null || _a === void 0 ? void 0 : _a.map((i) => ((0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: i.id, children: (0, jsx_runtime_1.jsx)(AgentInputRender, {}) }, i.id))) }), (0, jsx_runtime_1.jsx)(material_1.Stack, { children: (0, jsx_runtime_1.jsx)(OutputView, { resultTitle: resultTitle }) })] }) }));
57
+ const title = (appearancePage === null || appearancePage === void 0 ? void 0 : appearancePage.name) || agent.name;
58
+ const description = (appearancePage === null || appearancePage === void 0 ? void 0 : appearancePage.description) || agent.description;
59
+ return ((0, jsx_runtime_1.jsx)(material_1.ThemeProvider, { theme: theme, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: 2, maxWidth: "md", width: "100%", mx: "auto", px: { xs: 2, sm: 3 }, children: [(0, jsx_runtime_1.jsx)(material_1.Stack, { gap: 2, mt: 8, mb: 4, children: (0, jsx_runtime_1.jsxs)(react_wrap_balancer_1.Provider, { children: [title && ((0, jsx_runtime_1.jsx)(material_1.Typography, { component: "h5", fontSize: 30, fontWeight: 700, textAlign: "center", children: (0, jsx_runtime_1.jsx)(react_wrap_balancer_1.default, { children: title }) })), description && ((0, jsx_runtime_1.jsx)(material_1.Typography, { textAlign: "center", children: (0, jsx_runtime_1.jsx)(react_wrap_balancer_1.default, { children: description }) }))] }) }), (0, jsx_runtime_1.jsx)(material_1.Stack, { children: (0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: childAgentId, children: (0, jsx_runtime_1.jsx)(AgentInputRender, {}) }) }), (0, jsx_runtime_1.jsx)(material_1.Stack, { children: (0, jsx_runtime_1.jsx)(OutputView, { resultTitle: resultTitle }) })] }) }));
64
60
  }
65
61
  exports.default = SimplePage;
66
62
  function AgentInputRender() {
67
- var _a, _b;
68
- const { agent } = (0, CurrentAgent_1.useCurrentAgent)();
69
- const input = (_b = (_a = agent.outputVariables) === null || _a === void 0 ? void 0 : _a.find((i) => i.name === types_1.RuntimeOutputVariable.appearanceInput)) === null || _b === void 0 ? void 0 : _b.initialValue;
70
- if (!(input === null || input === void 0 ? void 0 : input.componentId))
63
+ const { appearanceInput } = (0, CurrentAgent_1.useCurrentAgent)();
64
+ if (!(appearanceInput === null || appearanceInput === void 0 ? void 0 : appearanceInput.componentId))
71
65
  return null;
72
- return ((0, jsx_runtime_1.jsx)(material_1.Stack, { children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: input.componentId, properties: input.componentProps }) }));
66
+ return ((0, jsx_runtime_1.jsx)(material_1.Stack, { children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: appearanceInput.componentId, properties: appearanceInput.componentProps }) }));
73
67
  }
74
68
  function OutputView({ resultTitle }) {
75
69
  var _a;
@@ -78,10 +72,8 @@ function OutputView({ resultTitle }) {
78
72
  return ((0, jsx_runtime_1.jsx)(material_1.Stack, { gap: 2, children: lastMessage && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Stack, { children: resultTitle && ((0, jsx_runtime_1.jsx)(material_1.Typography, { component: "h5", fontSize: 36, fontWeight: 700, textAlign: "center", children: (0, jsx_runtime_1.jsx)(react_wrap_balancer_1.default, { children: resultTitle }) })) }), (0, jsx_runtime_1.jsx)(material_1.Stack, { children: (0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: lastMessage.assistantId, children: (0, jsx_runtime_1.jsx)(CurrentMessage_1.default, { message: lastMessage, children: (0, jsx_runtime_1.jsx)(react_1.Suspense, { children: (0, jsx_runtime_1.jsx)(OutputItemView, {}) }) }) }) })] })) }));
79
73
  }
80
74
  function OutputItemView() {
81
- var _a, _b;
82
- const { agent } = (0, CurrentAgent_1.useCurrentAgent)();
83
- const input = (_b = (_a = agent.outputVariables) === null || _a === void 0 ? void 0 : _a.find((i) => i.name === types_1.RuntimeOutputVariable.appearanceOutput)) === null || _b === void 0 ? void 0 : _b.initialValue;
84
- if (!(input === null || input === void 0 ? void 0 : input.componentId))
75
+ const { appearanceOutput } = (0, CurrentAgent_1.useCurrentAgent)();
76
+ if (!(appearanceOutput === null || appearanceOutput === void 0 ? void 0 : appearanceOutput.componentId))
85
77
  return null;
86
- return (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: input.componentId, properties: input.componentProps });
78
+ return ((0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProps }));
87
79
  }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_OUTPUT_COMPONENT_ID = exports.DEFAULT_INPUT_COMPONENT_ID = exports.DEFAULT_PAGE_COMPONENT_ID = void 0;
4
+ exports.DEFAULT_PAGE_COMPONENT_ID = 'ctnxha29uu8cx4xv';
5
+ exports.DEFAULT_INPUT_COMPONENT_ID = '1wwtemqcdio6nqf0';
6
+ exports.DEFAULT_OUTPUT_COMPONENT_ID = 'q0ckknkxph4hfwas';
@@ -2,8 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useCurrentAgent = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const types_1 = require("@blocklet/ai-runtime/types");
5
6
  const react_1 = require("react");
6
7
  const utils_1 = require("../../../utils");
8
+ const constants_1 = require("../constants");
7
9
  const assistant_1 = require("../state/assistant");
8
10
  const runtime_1 = require("../state/runtime");
9
11
  const context = (0, react_1.createContext)(undefined);
@@ -22,6 +24,14 @@ function useCurrentAgent() {
22
24
  throw new Error('No such current agent state. You should use `useCurrentAgent` within the `CurrentAgentProvider`');
23
25
  }
24
26
  const [agent] = (0, assistant_1.useAssistantState)({ aid: current.aid, working });
25
- return Object.assign(Object.assign({}, current), { agent });
27
+ const appearanceInput = (0, react_1.useMemo)(() => {
28
+ var _a, _b, _c;
29
+ return (_c = (_b = (_a = agent.outputVariables) === null || _a === void 0 ? void 0 : _a.find((i) => i.name === types_1.RuntimeOutputVariable.appearanceInput)) === null || _b === void 0 ? void 0 : _b.initialValue) !== null && _c !== void 0 ? _c : { componentId: constants_1.DEFAULT_INPUT_COMPONENT_ID };
30
+ }, [agent]);
31
+ const appearanceOutput = (0, react_1.useMemo)(() => {
32
+ var _a, _b, _c;
33
+ return (_c = (_b = (_a = agent.outputVariables) === null || _a === void 0 ? void 0 : _a.find((i) => i.name === types_1.RuntimeOutputVariable.appearanceOutput)) === null || _b === void 0 ? void 0 : _b.initialValue) !== null && _c !== void 0 ? _c : { componentId: constants_1.DEFAULT_OUTPUT_COMPONENT_ID };
34
+ }, [agent]);
35
+ return Object.assign(Object.assign({}, current), { agent, appearanceInput, appearanceOutput });
26
36
  }
27
37
  exports.useCurrentAgent = useCurrentAgent;