@blocklet/pages-kit 0.2.311 → 0.2.313

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 (41) hide show
  1. package/lib/cjs/builtin/async/ai-runtime/api/session.js +10 -1
  2. package/lib/cjs/builtin/async/ai-runtime/components/PopperMenuButton/LoadingMenuItem.js +49 -0
  3. package/lib/cjs/builtin/async/ai-runtime/components/PopperMenuButton/index.js +68 -0
  4. package/lib/cjs/builtin/async/ai-runtime/locales/index.js +1 -1
  5. package/lib/cjs/builtin/async/ai-runtime/runtime/ChatBotButton/index.js +29 -12
  6. package/lib/cjs/builtin/async/ai-runtime/runtime/Runtime/index.js +22 -33
  7. package/lib/cjs/builtin/async/ai-runtime/runtime-components/AutoForm/index.js +2 -2
  8. package/lib/cjs/builtin/async/ai-runtime/runtime-components/MultiAgentsChat/index.js +6 -5
  9. package/lib/cjs/builtin/async/ai-runtime/runtime-components/PhotoGallery/index.js +6 -5
  10. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/index.js +39 -14
  11. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimplePage/index.js +2 -2
  12. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/Input.js +2 -2
  13. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/Page.js +2 -3
  14. package/lib/cjs/builtin/async/ai-runtime/state/session.js +217 -79
  15. package/lib/cjs/builtin/page/header.js +45 -3
  16. package/lib/cjs/tsconfig.tsbuildinfo +1 -1
  17. package/lib/esm/builtin/async/ai-runtime/api/session.js +8 -0
  18. package/lib/esm/builtin/async/ai-runtime/components/PopperMenuButton/LoadingMenuItem.js +46 -0
  19. package/lib/esm/builtin/async/ai-runtime/components/PopperMenuButton/index.js +42 -0
  20. package/lib/esm/builtin/async/ai-runtime/locales/index.js +1 -1
  21. package/lib/esm/builtin/async/ai-runtime/runtime/ChatBotButton/index.js +31 -14
  22. package/lib/esm/builtin/async/ai-runtime/runtime/Runtime/index.js +23 -34
  23. package/lib/esm/builtin/async/ai-runtime/runtime-components/AutoForm/index.js +3 -3
  24. package/lib/esm/builtin/async/ai-runtime/runtime-components/MultiAgentsChat/index.js +7 -6
  25. package/lib/esm/builtin/async/ai-runtime/runtime-components/PhotoGallery/index.js +7 -6
  26. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/index.js +35 -10
  27. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimplePage/index.js +3 -3
  28. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/Input.js +3 -3
  29. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/Page.js +3 -4
  30. package/lib/esm/builtin/async/ai-runtime/state/session.js +215 -79
  31. package/lib/esm/builtin/page/header.js +42 -1
  32. package/lib/esm/tsconfig.tsbuildinfo +1 -1
  33. package/lib/types/builtin/async/ai-runtime/api/session.d.ts +3 -0
  34. package/lib/types/builtin/async/ai-runtime/components/PopperMenuButton/LoadingMenuItem.d.ts +5 -0
  35. package/lib/types/builtin/async/ai-runtime/components/PopperMenuButton/index.d.ts +6 -0
  36. package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/index.d.ts +2 -1
  37. package/lib/types/builtin/async/ai-runtime/state/runtime.d.ts +1 -0
  38. package/lib/types/builtin/async/ai-runtime/state/session.d.ts +27 -6
  39. package/lib/types/builtin/page/header.d.ts +13 -0
  40. package/lib/types/tsconfig.tsbuildinfo +1 -1
  41. package/package.json +7 -6
@@ -22,7 +22,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar
22
22
  function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
23
23
  };
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.runAgent = exports.deleteSession = exports.updateSession = exports.createSession = exports.getSession = exports.getSessions = void 0;
25
+ exports.runAgent = exports.deleteSession = exports.updateSession = exports.clearSession = exports.createSession = exports.getSession = exports.getSessions = void 0;
26
26
  const ufo_1 = require("ufo");
27
27
  const stream_1 = require("../../../stream");
28
28
  const utils_1 = require("../../../utils");
@@ -58,6 +58,15 @@ function createSession(_a) {
58
58
  });
59
59
  }
60
60
  exports.createSession = createSession;
61
+ function clearSession(_a) {
62
+ return __awaiter(this, arguments, void 0, function* ({ sessionId }) {
63
+ return (0, request_1.request)({
64
+ method: 'POST',
65
+ url: (0, ufo_1.joinURL)((0, utils_1.getComponentMountPoint)(constants_1.AI_STUDIO_DID), '/api/sessions', sessionId, '/clear'),
66
+ });
67
+ });
68
+ }
69
+ exports.clearSession = clearSession;
61
70
  function updateSession(_a) {
62
71
  return __awaiter(this, arguments, void 0, function* ({ sessionId, name, }) {
63
72
  return (0, request_1.request)({
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __rest = (this && this.__rest) || function (s, e) {
12
+ var t = {};
13
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
+ t[p] = s[p];
15
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
+ t[p[i]] = s[p[i]];
19
+ }
20
+ return t;
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ const jsx_runtime_1 = require("react/jsx-runtime");
24
+ const material_1 = require("@mui/material");
25
+ const react_1 = require("react");
26
+ function LoadingMenuItem(_a) {
27
+ var { children, confirmation } = _a, props = __rest(_a, ["children", "confirmation"]);
28
+ const [clicked, setClicked] = (0, react_1.useState)(false);
29
+ const [loading, setLoading] = (0, react_1.useState)(false);
30
+ const handleClick = (e) => __awaiter(this, void 0, void 0, function* () {
31
+ var _b;
32
+ if (loading)
33
+ return;
34
+ if (!clicked && confirmation) {
35
+ setClicked(true);
36
+ return;
37
+ }
38
+ try {
39
+ setLoading(true);
40
+ yield ((_b = props.onClick) === null || _b === void 0 ? void 0 : _b.call(props, e));
41
+ }
42
+ finally {
43
+ setClicked(false);
44
+ setLoading(false);
45
+ }
46
+ });
47
+ return ((0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({}, props, { onClick: handleClick, sx: Object.assign(Object.assign({}, props.sx), { display: 'flex', alignItems: 'center', gap: 1 }), children: [(clicked && confirmation) || children, (0, jsx_runtime_1.jsx)(material_1.Stack, { direction: "row", alignItems: "center", justifyContent: "flex-end", sx: { width: 18 }, children: loading && (0, jsx_runtime_1.jsx)(material_1.CircularProgress, { size: 14 }) })] })));
48
+ }
49
+ exports.default = LoadingMenuItem;
@@ -0,0 +1,68 @@
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
+ var __rest = (this && this.__rest) || function (s, e) {
35
+ var t = {};
36
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
37
+ t[p] = s[p];
38
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
39
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
40
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
41
+ t[p[i]] = s[p[i]];
42
+ }
43
+ return t;
44
+ };
45
+ Object.defineProperty(exports, "__esModule", { value: true });
46
+ const jsx_runtime_1 = require("react/jsx-runtime");
47
+ const material_1 = require("@mui/material");
48
+ const hooks_1 = require("material-ui-popup-state/hooks");
49
+ const react_1 = __importStar(require("react"));
50
+ function PopperMenuButton(_a) {
51
+ var { PopperProps, menus } = _a, props = __rest(_a, ["PopperProps", "menus"]);
52
+ const state = (0, hooks_1.usePopupState)({ variant: 'popper' });
53
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ component: material_1.Button }, (0, hooks_1.bindTrigger)(state), props)), (0, jsx_runtime_1.jsx)(material_1.Popper, Object.assign({ transition: true }, PopperProps, (0, hooks_1.bindPopper)(state), { children: ({ TransitionProps }) => ((0, jsx_runtime_1.jsx)(material_1.ClickAwayListener, { onClickAway: state.close, children: (0, jsx_runtime_1.jsx)(material_1.Grow, Object.assign({}, TransitionProps, { children: (0, jsx_runtime_1.jsx)(material_1.Paper, { children: (0, jsx_runtime_1.jsx)(material_1.List, { dense: true, sx: {
54
+ [`.${material_1.listItemIconClasses.root}`]: {
55
+ minWidth: 24,
56
+ },
57
+ }, children: react_1.default.Children.map(menus, (menu) => !(0, react_1.isValidElement)(menu)
58
+ ? menu
59
+ : react_1.default.cloneElement(menu, {
60
+ // Close popper after the menu item click handler has been resolved
61
+ onClick: (...args) => __awaiter(this, void 0, void 0, function* () {
62
+ var _b, _c;
63
+ yield ((_c = (_b = menu.props).onClick) === null || _c === void 0 ? void 0 : _c.call(_b, ...args));
64
+ state.close();
65
+ }),
66
+ })) }) }) })) })) }))] }));
67
+ }
68
+ exports.default = PopperMenuButton;
@@ -121,7 +121,7 @@ exports.translations = {
121
121
  parameters: '参数',
122
122
  parametersTitle: '告诉我你想要什么?',
123
123
  parametersSetting: '设置',
124
- clearSession: '清空对话',
124
+ clearSession: '清空会话',
125
125
  generate: '生成',
126
126
  startChat: '开始对话',
127
127
  collections: '知识库',
@@ -22,6 +22,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
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
+ };
25
34
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
35
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
36
  };
@@ -33,6 +42,9 @@ const material_1 = require("@mui/material");
33
42
  const react_2 = require("react");
34
43
  const CustomComponentRenderer_1 = __importDefault(require("../../../../../components/CustomComponentRenderer"));
35
44
  const ux_1 = require("../../../../arcblock/ux");
45
+ const locale_1 = require("../../../../locale");
46
+ const PopperMenuButton_1 = __importDefault(require("../../components/PopperMenuButton"));
47
+ const LoadingMenuItem_1 = __importDefault(require("../../components/PopperMenuButton/LoadingMenuItem"));
36
48
  const RuntimeCommonProvider_1 = __importDefault(require("../../components/RuntimeCommonProvider"));
37
49
  const ScrollView_1 = __importDefault(require("../../components/ScrollView"));
38
50
  const constants_1 = require("../../constants");
@@ -47,7 +59,7 @@ exports.default = ChatBotButton;
47
59
  function ChatBotContent() {
48
60
  var _a, _b;
49
61
  const anchorEl = (0, react_2.useRef)(null);
50
- (0, session_1.useSessionState)({ autoLoad: true });
62
+ (0, session_1.useAutoLoadSessionState)();
51
63
  const { aid } = (0, runtime_1.useRuntimeState)();
52
64
  const { appearancePage } = (0, use_appearances_1.default)({ aid });
53
65
  const profile = (0, use_appearances_1.useProfile)({ aid });
@@ -61,7 +73,7 @@ function ChatBotContent() {
61
73
  '.aigne-layout': {
62
74
  px: 2,
63
75
  },
64
- }, children: (0, jsx_runtime_1.jsx)(react_2.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: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: componentId, properties: appearancePage === null || appearancePage === void 0 ? void 0 : appearancePage.componentProps, props: { scrollViewProps: { disabled: true } } }) }) }) }))] }));
76
+ }, children: (0, jsx_runtime_1.jsx)(react_2.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: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: componentId, properties: appearancePage === null || appearancePage === void 0 ? void 0 : appearancePage.componentProps, props: { scrollViewProps: { disabled: true }, hideHeaderMenuButton: true } }) }) }) }))] }));
65
77
  }
66
78
  function ResponsiveChatBotContainer({ open, anchorEl, children, onClose, }) {
67
79
  const theme = (0, material_1.useTheme)();
@@ -74,24 +86,29 @@ function ResponsiveChatBotContainer({ open, anchorEl, children, onClose, }) {
74
86
  return ((0, jsx_runtime_1.jsx)(ChatBotPopper, { anchorEl: anchorEl, title: profile.name, open: open, onClose: onClose, children: children }));
75
87
  }
76
88
  function ChatBotPopper({ title, anchorEl, open, children, onClose, }) {
77
- return ((0, jsx_runtime_1.jsx)(material_1.Popper, { anchorEl: anchorEl, open: open, disablePortal: true, placement: "top-end", sx: {
89
+ return ((0, jsx_runtime_1.jsx)(material_1.Popper, { anchorEl: anchorEl, open: open, disablePortal: true, placement: "top-end", transition: true, sx: {
78
90
  zIndex: 'modal',
79
91
  maxWidth: 500,
80
92
  maxHeight: 'min(calc(100vh - 128px), 1000px)',
81
93
  width: 500,
82
94
  height: '90vh',
83
- }, children: (0, jsx_runtime_1.jsx)(material_1.ClickAwayListener, { onClickAway: (e) => {
95
+ }, children: ({ TransitionProps }) => ((0, jsx_runtime_1.jsx)(material_1.ClickAwayListener, { onClickAway: (e) => {
84
96
  e.preventDefault();
85
97
  e.stopPropagation();
86
98
  onClose === null || onClose === void 0 ? void 0 : onClose();
87
- }, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { sx: {
88
- height: '100%',
89
- boxShadow: 1,
90
- position: 'relative',
91
- background: 'white',
92
- borderRadius: 1,
93
- }, children: [(0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", alignItems: "center", justifyContent: "space-between", borderBottom: 1, borderColor: "divider", p: 2, gap: 2, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", noWrap: true, children: title }), (0, jsx_runtime_1.jsx)(material_1.Button, { sx: { minWidth: 28, minHeight: 28, p: 0 }, onClick: onClose, children: (0, jsx_runtime_1.jsx)(react_1.Icon, { icon: "tabler:x", fontSize: 24, color: "rgba(75, 85, 99, 1)" }) })] }), children] }) }) }));
99
+ }, children: (0, jsx_runtime_1.jsx)(material_1.Grow, Object.assign({}, TransitionProps, { style: { transformOrigin: 'right bottom' }, timeout: 350, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { sx: {
100
+ height: '100%',
101
+ boxShadow: 1,
102
+ position: 'relative',
103
+ background: 'white',
104
+ borderRadius: 1,
105
+ }, children: [(0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", alignItems: "center", borderBottom: 1, borderColor: "divider", p: 2, gap: 2, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", noWrap: true, sx: { flex: 1, width: 1 }, children: title }), (0, jsx_runtime_1.jsx)(ChatMenuButton, {}), (0, jsx_runtime_1.jsx)(material_1.Button, { sx: { minWidth: 28, minHeight: 28, p: 0 }, onClick: onClose, children: (0, jsx_runtime_1.jsx)(react_1.Icon, { icon: "tabler:x", fontSize: 24, color: "rgba(75, 85, 99, 1)" }) })] }), children] }) })) })) }));
94
106
  }
95
107
  function ChatBotDialog({ title, open, children, onClose, }) {
96
- return ((0, jsx_runtime_1.jsxs)(material_1.Dialog, { open: open, onClose: onClose, fullScreen: true, children: [(0, jsx_runtime_1.jsx)(material_1.DialogTitle, { sx: { pl: 0 }, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", alignItems: "center", gap: 2, children: [(0, jsx_runtime_1.jsx)(material_1.IconButton, { size: "small", onClick: onClose, children: (0, jsx_runtime_1.jsx)(icons_material_1.ArrowBackIosNewRounded, { fontSize: "inherit" }) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", noWrap: true, children: title })] }) }), (0, jsx_runtime_1.jsx)(material_1.DialogContent, { sx: { p: 0 }, dividers: true, children: children })] }));
108
+ return ((0, jsx_runtime_1.jsxs)(material_1.Dialog, { open: open, onClose: onClose, fullScreen: true, children: [(0, jsx_runtime_1.jsx)(material_1.DialogTitle, { sx: { px: 1 }, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", alignItems: "center", gap: 2, children: [(0, jsx_runtime_1.jsx)(material_1.IconButton, { size: "small", onClick: onClose, children: (0, jsx_runtime_1.jsx)(icons_material_1.ArrowBackIosNewRounded, { fontSize: "inherit" }) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h6", noWrap: true, sx: { flex: 1, width: 1 }, children: title }), (0, jsx_runtime_1.jsx)(ChatMenuButton, {})] }) }), (0, jsx_runtime_1.jsx)(material_1.DialogContent, { sx: { p: 0 }, dividers: true, children: children })] }));
109
+ }
110
+ function ChatMenuButton() {
111
+ const { t } = (0, locale_1.useLocaleContext)();
112
+ const clearSession = (0, session_1.useSessionState)((s) => s.clearSession);
113
+ return ((0, jsx_runtime_1.jsx)(PopperMenuButton_1.default, { component: material_1.IconButton, PopperProps: { placement: 'bottom-end', sx: { zIndex: 'snackbar' } }, menus: (0, jsx_runtime_1.jsxs)(LoadingMenuItem_1.default, { onClick: () => __awaiter(this, void 0, void 0, function* () { return clearSession(); }), children: [(0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: (0, jsx_runtime_1.jsx)(react_1.Icon, { icon: "mingcute:broom-line" }) }), t('clearSession')] }), children: (0, jsx_runtime_1.jsx)(react_1.Icon, { icon: "tabler:dots" }) }));
97
114
  }
@@ -28,7 +28,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  const jsx_runtime_1 = require("react/jsx-runtime");
30
30
  const material_1 = require("@mui/material");
31
- const react_1 = require("react");
32
31
  const react_helmet_1 = require("react-helmet");
33
32
  const ufo_1 = require("ufo");
34
33
  const CustomComponentRenderer_1 = __importDefault(require("../../../../../components/CustomComponentRenderer"));
@@ -58,40 +57,30 @@ function RuntimeView() {
58
57
  const theme = (0, material_1.useTheme)();
59
58
  const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('sm'));
60
59
  const { locale } = (0, locale_1.useLocaleContext)();
61
- (0, react_1.useEffect)(() => {
62
- header_1.useHeaderState.setState((state) => {
63
- const logo = (0, ufo_1.joinURL)(window.location.origin, (0, utils_1.getComponentMountPoint)(constants_1.AI_STUDIO_DID), '/api/projects', agent.project.id, '/logo.png');
64
- state.logo = logo && ((0, jsx_runtime_1.jsx)(material_1.Box, { component: ux_1.Avatar, src: logo, did: blocklet === null || blocklet === void 0 ? void 0 : blocklet.appId, borderRadius: 1, size: logoSize, sx: {
60
+ (0, header_1.useHeader)(() => {
61
+ const logo = (0, ufo_1.joinURL)(window.location.origin, (0, utils_1.getComponentMountPoint)(constants_1.AI_STUDIO_DID), '/api/projects', agent.project.id, '/logo.png');
62
+ const shareContent = `${agent.name}
63
+
64
+ ${agent === null || agent === void 0 ? void 0 : agent.description}
65
+ `;
66
+ return {
67
+ logo: logo && ((0, jsx_runtime_1.jsx)(material_1.Box, { component: ux_1.Avatar, src: logo, did: blocklet === null || blocklet === void 0 ? void 0 : blocklet.appId, borderRadius: 1, size: logoSize, sx: {
65
68
  width: logoSize,
66
69
  height: logoSize,
67
- } }));
68
- if (!isMobile) {
69
- state.brand = ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
70
- height: 18,
71
- fontSize: 18,
72
- }, children: agent.project.name }));
73
- state.description = agent.createdBy && ((0, jsx_runtime_1.jsx)(RuntimeCommonProvider_1.RuntimeLocaleProvider, { children: (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
74
- display: 'inline-flex',
75
- alignItems: 'center',
76
- gap: 0.5,
77
- mt: 0.5,
78
- height: 12,
79
- fontSize: 12,
80
- }, children: (0, jsx_runtime_1.jsx)(AgentCreatedBy, { did: agent.project.createdBy }) }) }));
81
- }
82
- const shareContent = `${agent.name}
83
-
84
- ${agent === null || agent === void 0 ? void 0 : agent.description}
85
- `;
86
- state.addons = (...exists) => [(0, jsx_runtime_1.jsx)(SocialShare_1.default, { content: shareContent }), ...exists].filter(Boolean);
87
- });
88
- return () => {
89
- header_1.useHeaderState.setState((state) => {
90
- state.logo = undefined;
91
- state.brand = undefined;
92
- state.description = undefined;
93
- state.addons = (...exists) => [...exists];
94
- });
70
+ } })),
71
+ brand: !isMobile ? ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
72
+ height: 18,
73
+ fontSize: 18,
74
+ }, children: agent.project.name })) : undefined,
75
+ description: !isMobile && agent.createdBy ? ((0, jsx_runtime_1.jsx)(RuntimeCommonProvider_1.RuntimeLocaleProvider, { children: (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
76
+ display: 'inline-flex',
77
+ alignItems: 'center',
78
+ gap: 0.5,
79
+ mt: 0.5,
80
+ height: 12,
81
+ fontSize: 12,
82
+ }, children: (0, jsx_runtime_1.jsx)(AgentCreatedBy, { did: agent.project.createdBy }) }) })) : undefined,
83
+ addons: (...exists) => [(0, jsx_runtime_1.jsx)(SocialShare_1.default, { content: shareContent }), ...exists].filter(Boolean),
95
84
  };
96
85
  }, [locale, isMobile, agent]);
97
86
  const componentId = (_a = appearancePage === null || appearancePage === void 0 ? void 0 : appearancePage.componentId) !== null && _a !== void 0 ? _a : constants_1.DEFAULT_PAGE_COMPONENT_ID;
@@ -30,7 +30,7 @@ function AutoForm({ submitText, inlineLabel, autoFillLastForm = true, submitInQu
30
30
  const { t } = (0, locale_1.useLocaleContext)();
31
31
  const { aid, agent } = (0, CurrentAgent_1.useCurrentAgent)();
32
32
  const { execute } = (0, runtime_1.useRuntimeState)();
33
- const running = (0, session_1.useSessionState)()((s) => s.running);
33
+ const running = (0, session_1.useCurrentSessionState)((s) => s === null || s === void 0 ? void 0 : s.running);
34
34
  const parameters = (0, react_1.useMemo)(() => {
35
35
  var _a;
36
36
  return (_a = agent.parameters) === null || _a === void 0 ? void 0 : _a.filter(agent_inputs_1.isValidInput).map((i) => {
@@ -85,7 +85,7 @@ function AutoForm({ submitText, inlineLabel, autoFillLastForm = true, submitInQu
85
85
  exports.default = AutoForm;
86
86
  function useInitialFormValues() {
87
87
  const { agent } = (0, CurrentAgent_1.useCurrentAgent)();
88
- const lastMessage = (0, session_1.useSessionState)()((s) => { var _a; return (_a = s.messages) === null || _a === void 0 ? void 0 : _a.at(-1); });
88
+ const lastMessage = (0, session_1.useCurrentSessionState)((s) => { var _a; return (_a = s === null || s === void 0 ? void 0 : s.messages) === null || _a === void 0 ? void 0 : _a.at(-1); });
89
89
  const [lastInputs, setLastInputs] = (0, react_1.useState)();
90
90
  (0, react_1.useEffect)(() => {
91
91
  if (!lastInputs) {
@@ -57,7 +57,7 @@ const session_2 = require("../../state/session");
57
57
  const runtime_output_schema_1 = require("../../utils/runtime-output-schema");
58
58
  const MessageSuggestedQuestions_1 = __importStar(require("../ChatOutput/MessageSuggestedQuestions"));
59
59
  function MultiAgentsChat({ primaryColor, scrollViewProps = { scroll: 'window', initialScrollBehavior: 'auto' }, backgroundImage, }) {
60
- (0, session_2.useSessionState)({ autoLoad: true });
60
+ (0, session_2.useAutoLoadSessionState)();
61
61
  const inheritedTheme = (0, material_1.useTheme)();
62
62
  const theme = (0, react_1.useMemo)(() => {
63
63
  let { primary } = inheritedTheme.palette;
@@ -93,7 +93,7 @@ function MultiAgentsChat({ primaryColor, scrollViewProps = { scroll: 'window', i
93
93
  exports.default = MultiAgentsChat;
94
94
  function SimpleChatView() {
95
95
  // auto scroll to bottom when new message is sent
96
- const running = (0, session_2.useSessionState)()((s) => s.running);
96
+ const running = (0, session_2.useCurrentSessionState)((s) => s === null || s === void 0 ? void 0 : s.running);
97
97
  const scrollToBottom = (0, react_scroll_to_bottom_1.useScrollToBottom)();
98
98
  (0, react_1.useEffect)(() => {
99
99
  if (running)
@@ -135,10 +135,11 @@ function AgentInput() {
135
135
  }
136
136
  function OutputView(_a) {
137
137
  var { currentAgentId } = _a, props = __rest(_a, ["currentAgentId"]);
138
- const messages = (0, session_2.useSessionState)()((s) => s.messages);
139
- const loading = (0, session_2.useSessionState)()((s) => s.loading);
138
+ const messages = (0, session_2.useCurrentSessionState)((s) => s === null || s === void 0 ? void 0 : s.messages);
139
+ const loaded = (0, session_2.useSessionState)((s) => s.loaded);
140
+ const showOpening = (0, session_2.useCurrentSessionState)((s) => !s || (s === null || s === void 0 ? void 0 : s.loaded)) && loaded;
140
141
  const lastMessage = messages === null || messages === void 0 ? void 0 : messages.at(-1);
141
- return ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ gap: 2 }, props, { children: [(0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: currentAgentId, children: (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 && lastMessage.assistantId === currentAgentId && (0, jsx_runtime_1.jsx)(SuggestedQuestionsView, { message: lastMessage }), !loading && !(messages === null || messages === void 0 ? void 0 : messages.length) && ((0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: currentAgentId, children: (0, jsx_runtime_1.jsx)(OpeningQuestionsView, {}) }))] })));
142
+ return ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ gap: 2 }, props, { children: [showOpening && ((0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: currentAgentId, children: (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 && lastMessage.assistantId === currentAgentId && (0, jsx_runtime_1.jsx)(SuggestedQuestionsView, { message: lastMessage }), showOpening && !(messages === null || messages === void 0 ? void 0 : messages.length) && ((0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: currentAgentId, children: (0, jsx_runtime_1.jsx)(OpeningQuestionsView, {}) }))] })));
142
143
  }
143
144
  const OutputItemView = (0, react_1.memo)(({ message }) => {
144
145
  var _a, _b, _c, _d;
@@ -31,7 +31,7 @@ const session_1 = require("../../state/session");
31
31
  const map_right_1 = __importDefault(require("../../utils/map-right"));
32
32
  function PhotoGallery({ resultTitle, primaryColor }) {
33
33
  const { childAgentId } = (0, runtime_1.useRuntimeState)();
34
- (0, session_1.useSessionState)({ autoLoad: true });
34
+ (0, session_1.useAutoLoadSessionState)();
35
35
  const inheritedTheme = (0, material_1.useTheme)();
36
36
  const theme = (0, react_1.useMemo)(() => {
37
37
  let { primary } = inheritedTheme.palette;
@@ -64,15 +64,16 @@ 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." }) }));
65
65
  }
66
66
  function OutputView(_a) {
67
- var _b, _c, _d;
67
+ var _b, _c, _d, _e;
68
68
  var { resultTitle } = _a, props = __rest(_a, ["resultTitle"]);
69
69
  const { t } = (0, locale_1.useLocaleContext)();
70
70
  const ref = (0, react_1.useRef)(null);
71
- const { messages = [], running, loaded, noMoreMessage, loadMoreMessages } = (0, session_1.useSessionState)()();
71
+ const { messages = [], running, loaded, noMoreMessage } = (_b = (0, session_1.useCurrentSessionState)((s) => s)) !== null && _b !== void 0 ? _b : {};
72
+ const loadMoreMessages = (0, session_1.useSessionState)((s) => s.loadMoreMessages);
72
73
  return ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ width: "100%", alignItems: "center", px: { xs: 2, sm: 3 }, mt: { xs: 2, sm: 3 } }, props, { children: [resultTitle && ((0, jsx_runtime_1.jsx)(material_1.Typography, { width: "100%", component: "h2", fontSize: 36, fontWeight: 700, textAlign: "center", children: (0, jsx_runtime_1.jsx)(react_wrap_balancer_1.default, { children: resultTitle }) })), loaded && !messages.length && (0, jsx_runtime_1.jsx)(NoOutputs, {}), (0, jsx_runtime_1.jsxs)(lab_1.Masonry, { ref: ref, columns: { xs: 2, sm: 3, md: 4, lg: 5 }, spacing: 1, sequential: true, sx: { width: '100%', overflow: 'hidden', '> *': { borderRadius: 1 } }, children: [running && ((0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "rectangular", sx: {
73
74
  // FIXME: default using history height
74
- height: (_d = (_c = (_b = ref.current) === null || _b === void 0 ? void 0 : _b.querySelector('*')) === null || _c === void 0 ? void 0 : _c.clientHeight) !== null && _d !== void 0 ? _d : 200,
75
- } })), (0, map_right_1.default)(messages, (message) => ((0, jsx_runtime_1.jsx)(OutputItemView, { message: message }, message.taskId)))] }), (0, jsx_runtime_1.jsx)(material_1.Box, { my: 4, children: !!messages.length && !noMoreMessage && ((0, jsx_runtime_1.jsx)(LoadingButton_1.default, { variant: "outlined", onClick: loadMoreMessages, children: t('loadMore') })) })] })));
75
+ height: (_e = (_d = (_c = ref.current) === null || _c === void 0 ? void 0 : _c.querySelector('*')) === null || _d === void 0 ? void 0 : _d.clientHeight) !== null && _e !== void 0 ? _e : 200,
76
+ } })), (0, map_right_1.default)(messages, (message) => ((0, jsx_runtime_1.jsx)(OutputItemView, { message: message }, message.taskId)))] }), (0, jsx_runtime_1.jsx)(material_1.Box, { my: 4, children: !!messages.length && !noMoreMessage && ((0, jsx_runtime_1.jsx)(LoadingButton_1.default, { variant: "outlined", onClick: () => loadMoreMessages(), children: t('loadMore') })) })] })));
76
77
  }
77
78
  const OutputItemView = (0, react_1.memo)(({ message }) => {
78
79
  const { appearanceOutput } = (0, use_appearances_1.default)({ agentId: message.assistantId });
@@ -22,6 +22,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
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
+ };
25
34
  var __rest = (this && this.__rest) || function (s, e) {
26
35
  var t = {};
27
36
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
@@ -39,14 +48,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
39
48
  Object.defineProperty(exports, "__esModule", { value: true });
40
49
  const jsx_runtime_1 = require("react/jsx-runtime");
41
50
  const types_1 = require("@blocklet/ai-runtime/types");
51
+ const react_1 = require("@iconify/react");
42
52
  const material_1 = require("@mui/material");
43
- const react_1 = require("react");
53
+ const react_2 = require("react");
44
54
  const react_scroll_to_bottom_1 = require("react-scroll-to-bottom");
45
55
  const CustomComponentRenderer_1 = __importDefault(require("../../../../../components/CustomComponentRenderer"));
56
+ const locale_1 = require("../../../../locale");
57
+ const header_1 = require("../../../../page/header");
46
58
  const session_1 = require("../../../../session");
47
59
  const SimpleHeader_1 = __importDefault(require("../../components/Header/SimpleHeader"));
48
60
  const SimpleLayout_1 = __importDefault(require("../../components/Layout/SimpleLayout"));
49
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"));
50
64
  const ScrollView_1 = __importDefault(require("../../components/ScrollView"));
51
65
  const UserInfo_1 = __importDefault(require("../../components/UserInfo"));
52
66
  const CurrentAgent_1 = __importStar(require("../../contexts/CurrentAgent"));
@@ -55,10 +69,10 @@ const use_appearances_1 = __importStar(require("../../hooks/use-appearances"));
55
69
  const runtime_1 = require("../../state/runtime");
56
70
  const session_2 = require("../../state/session");
57
71
  const MessageSuggestedQuestions_1 = __importStar(require("../ChatOutput/MessageSuggestedQuestions"));
58
- function SimpleChat({ primaryColor, scrollViewProps = { scroll: 'window', initialScrollBehavior: 'auto' }, }) {
59
- (0, session_2.useSessionState)({ autoLoad: true });
72
+ function SimpleChat({ primaryColor, scrollViewProps = { scroll: 'window', initialScrollBehavior: 'auto' }, hideHeaderMenuButton, }) {
73
+ (0, session_2.useAutoLoadSessionState)();
60
74
  const inheritedTheme = (0, material_1.useTheme)();
61
- const theme = (0, react_1.useMemo)(() => {
75
+ const theme = (0, react_2.useMemo)(() => {
62
76
  let { primary } = inheritedTheme.palette;
63
77
  try {
64
78
  if (primaryColor) {
@@ -75,18 +89,28 @@ function SimpleChat({ primaryColor, scrollViewProps = { scroll: 'window', initia
75
89
  },
76
90
  });
77
91
  }, [inheritedTheme, primaryColor]);
78
- return ((0, jsx_runtime_1.jsx)(ScrollView_1.default, Object.assign({}, scrollViewProps, { children: (0, jsx_runtime_1.jsx)(material_1.ThemeProvider, { theme: theme, children: (0, jsx_runtime_1.jsx)(SimpleChatView, {}) }) })));
92
+ return ((0, jsx_runtime_1.jsx)(ScrollView_1.default, Object.assign({}, scrollViewProps, { children: (0, jsx_runtime_1.jsx)(material_1.ThemeProvider, { theme: theme, children: (0, jsx_runtime_1.jsx)(SimpleChatView, { hideHeaderMenuButton: hideHeaderMenuButton }) }) })));
79
93
  }
80
94
  exports.default = SimpleChat;
81
- function SimpleChatView() {
95
+ function SimpleChatView({ hideHeaderMenuButton }) {
96
+ const { t, locale } = (0, locale_1.useLocaleContext)();
82
97
  const { childAgentId } = (0, runtime_1.useRuntimeState)();
83
98
  // auto scroll to bottom when new message is sent
84
- const running = (0, session_2.useSessionState)()((s) => s.running);
99
+ const running = (0, session_2.useCurrentSessionState)((s) => s === null || s === void 0 ? void 0 : s.running);
85
100
  const scrollToBottom = (0, react_scroll_to_bottom_1.useScrollToBottom)();
86
- (0, react_1.useEffect)(() => {
101
+ (0, react_2.useEffect)(() => {
87
102
  if (running)
88
103
  scrollToBottom({ behavior: 'smooth' });
89
104
  }, [scrollToBottom, running]);
105
+ const clearSession = (0, session_2.useSessionState)((s) => s.clearSession);
106
+ (0, header_1.useHeader)(() => hideHeaderMenuButton
107
+ ? {}
108
+ : {
109
+ addons: (...exists) => [
110
+ (0, jsx_runtime_1.jsx)(PopperMenuButton_1.default, { component: material_1.IconButton, PopperProps: { placement: 'bottom-end', sx: { zIndex: 'appBar' } }, menus: (0, jsx_runtime_1.jsxs)(LoadingMenuItem_1.default, { onClick: () => __awaiter(this, void 0, void 0, function* () { return clearSession(); }), children: [(0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: (0, jsx_runtime_1.jsx)(react_1.Icon, { icon: "mingcute:broom-line" }) }), t('clearSession')] }), children: (0, jsx_runtime_1.jsx)(react_1.Icon, { icon: "tabler:dots" }) }),
111
+ ...exists,
112
+ ],
113
+ }, [locale, hideHeaderMenuButton]);
90
114
  return ((0, jsx_runtime_1.jsxs)(SimpleLayout_1.default, { children: [(0, jsx_runtime_1.jsx)(SimpleHeader_1.default, {}), (0, jsx_runtime_1.jsx)(OutputView, { className: "aigne-outputs aigne-simple-chat-outputs", flexGrow: 1, pb: 10 }), (0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: childAgentId, children: (0, jsx_runtime_1.jsx)(AgentInputRender, { className: "aigne-inputs aigne-simple-chat-inputs", sx: { position: 'sticky', bottom: 0, pt: 1, pb: 2, bgcolor: 'background.paper', zIndex: 10 } }) })] }));
91
115
  }
92
116
  function AgentInputRender(_a) {
@@ -98,12 +122,13 @@ function AgentInputRender(_a) {
98
122
  }
99
123
  function OutputView(_a) {
100
124
  var props = __rest(_a, []);
101
- const messages = (0, session_2.useSessionState)()((s) => s.messages);
102
- const loading = (0, session_2.useSessionState)()((s) => s.loading);
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;
103
128
  const lastMessage = messages === null || messages === void 0 ? void 0 : messages.at(-1);
104
- return ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ gap: 2 }, props, { children: [(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 }), !loading && !(messages === null || messages === void 0 ? void 0 : messages.length) && (0, jsx_runtime_1.jsx)(OpeningQuestionsView, {})] })));
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, {})] })));
105
130
  }
106
- const OutputItemView = (0, react_1.memo)(({ message }) => {
131
+ const OutputItemView = (0, react_2.memo)(({ message }) => {
107
132
  var _a, _b, _c, _d;
108
133
  const { session: authSession } = (0, session_1.useSessionContext)();
109
134
  const { appearanceOutput } = (0, use_appearances_1.default)({ agentId: message.assistantId });
@@ -119,7 +144,7 @@ const OutputItemView = (0, react_1.memo)(({ message }) => {
119
144
  function SuggestedQuestionsView({ message }) {
120
145
  const { aid } = (0, CurrentAgent_1.useCurrentAgent)({ agentId: message.assistantId });
121
146
  const { execute } = (0, runtime_1.useRuntimeState)();
122
- const suggestedQuestions = (0, react_1.useMemo)(() => {
147
+ const suggestedQuestions = (0, react_2.useMemo)(() => {
123
148
  var _a, _b, _c;
124
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];
125
150
  }, [message]);
@@ -127,7 +152,7 @@ function SuggestedQuestionsView({ message }) {
127
152
  execute({ aid, parameters: Object.assign(Object.assign({}, message.parameters), { question: item.question }) });
128
153
  } })) : null }));
129
154
  }
130
- const OpeningMessageView = (0, react_1.memo)(() => {
155
+ const OpeningMessageView = (0, react_2.memo)(() => {
131
156
  var _a;
132
157
  const { childAgentId } = (0, runtime_1.useRuntimeState)();
133
158
  const opening = (0, use_appearances_1.useOpeningMessage)({ agentId: childAgentId });
@@ -28,7 +28,7 @@ const runtime_1 = require("../../state/runtime");
28
28
  const session_1 = require("../../state/session");
29
29
  function SimplePage({ resultTitle, primaryColor }) {
30
30
  const { childAgentId } = (0, runtime_1.useRuntimeState)();
31
- (0, session_1.useSessionState)({ autoLoad: true });
31
+ (0, session_1.useAutoLoadSessionState)();
32
32
  const inheritedTheme = (0, material_1.useTheme)();
33
33
  const theme = (0, react_1.useMemo)(() => {
34
34
  let { primary } = inheritedTheme.palette;
@@ -59,7 +59,7 @@ function AgentInputRender(_a) {
59
59
  }
60
60
  function OutputView(_a) {
61
61
  var { resultTitle } = _a, props = __rest(_a, ["resultTitle"]);
62
- const lastMessage = (0, session_1.useSessionState)()((s) => { var _a; return (_a = s.messages) === null || _a === void 0 ? void 0 : _a.at(-1); });
62
+ const lastMessage = (0, session_1.useCurrentSessionState)((s) => { var _a; return (_a = s === null || s === void 0 ? void 0 : s.messages) === null || _a === void 0 ? void 0 : _a.at(-1); });
63
63
  return ((0, jsx_runtime_1.jsx)(material_1.Stack, Object.assign({ gap: 2, mt: 4 }, props, { children: lastMessage && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [resultTitle && ((0, jsx_runtime_1.jsx)(material_1.Typography, { width: "100%", 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)(OutputItemView, { message: lastMessage }) })] })) })));
64
64
  }
65
65
  const OutputItemView = (0, react_1.memo)(({ message }) => {
@@ -30,7 +30,7 @@ function AutoForm({ submitText, inlineLabel, autoFillLastForm = true, submitInQu
30
30
  const { t } = (0, locale_1.useLocaleContext)();
31
31
  const { aid, agent } = (0, CurrentAgent_1.useCurrentAgent)();
32
32
  const { execute } = (0, runtime_1.useRuntimeState)();
33
- const running = (0, session_1.useSessionState)()((s) => s.running);
33
+ const running = (0, session_1.useCurrentSessionState)((s) => s === null || s === void 0 ? void 0 : s.running);
34
34
  const parameters = (0, react_1.useMemo)(() => {
35
35
  var _a;
36
36
  return (_a = agent.parameters) === null || _a === void 0 ? void 0 : _a.filter(agent_inputs_1.isValidInput).map((i) => {
@@ -85,7 +85,7 @@ function AutoForm({ submitText, inlineLabel, autoFillLastForm = true, submitInQu
85
85
  exports.default = AutoForm;
86
86
  function useInitialFormValues() {
87
87
  const { agent } = (0, CurrentAgent_1.useCurrentAgent)();
88
- const lastMessage = (0, session_1.useSessionState)()((s) => { var _a; return (_a = s.messages) === null || _a === void 0 ? void 0 : _a.at(-1); });
88
+ const lastMessage = (0, session_1.useCurrentSessionState)((s) => { var _a; return (_a = s === null || s === void 0 ? void 0 : s.messages) === null || _a === void 0 ? void 0 : _a.at(-1); });
89
89
  const [lastInputs, setLastInputs] = (0, react_1.useState)();
90
90
  (0, react_1.useEffect)(() => {
91
91
  if (!lastInputs) {
@@ -58,9 +58,8 @@ function V0Page({ textColor = '#333', primaryColor }) {
58
58
  const [sessionId] = (0, react_1.useState)('1');
59
59
  const [message, setMessage] = (0, react_1.useState)();
60
60
  const { childAgentId } = (0, runtime_1.useRuntimeState)();
61
- const messagesList = (0, session_1.useSessionState)({
62
- autoLoad: true,
63
- })((s) => s.messages);
61
+ (0, session_1.useAutoLoadSessionState)();
62
+ const messagesList = (0, session_1.useCurrentSessionState)((s) => s === null || s === void 0 ? void 0 : s.messages);
64
63
  (0, react_1.useEffect)(() => {
65
64
  if (messagesList === null || messagesList === void 0 ? void 0 : messagesList.length) {
66
65
  const lastMessage = messagesList[messagesList.length - 1];