@blocklet/pages-kit 0.2.310 → 0.2.312

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 (29) hide show
  1. package/lib/cjs/builtin/async/ai-runtime/index.js +2 -0
  2. package/lib/cjs/builtin/async/ai-runtime/runtime/ChatBotButton/index.js +9 -9
  3. package/lib/cjs/builtin/async/ai-runtime/runtime-components/ChatOutput/MessageMetadataRenderer.js +8 -5
  4. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/Input.js +152 -0
  5. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/Output.js +79 -0
  6. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/Page.js +147 -0
  7. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/index.js +12 -0
  8. package/lib/cjs/builtin/mui/material.js +3 -2
  9. package/lib/cjs/tsconfig.tsbuildinfo +1 -0
  10. package/lib/cjs/utils/inject-global-components-dump-json.js +1167 -0
  11. package/lib/esm/builtin/async/ai-runtime/index.js +2 -0
  12. package/lib/esm/builtin/async/ai-runtime/runtime/ChatBotButton/index.js +10 -10
  13. package/lib/esm/builtin/async/ai-runtime/runtime-components/ChatOutput/MessageMetadataRenderer.js +8 -5
  14. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/Input.js +146 -0
  15. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/Output.js +73 -0
  16. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/Page.js +142 -0
  17. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/index.js +3 -0
  18. package/lib/esm/builtin/mui/material.js +1 -1
  19. package/lib/esm/tsconfig.tsbuildinfo +1 -0
  20. package/lib/esm/utils/inject-global-components-dump-json.js +1165 -0
  21. package/lib/types/builtin/async/ai-runtime/index.d.ts +1 -0
  22. package/lib/types/builtin/async/ai-runtime/runtime-components/V0/Input.d.ts +7 -0
  23. package/lib/types/builtin/async/ai-runtime/runtime-components/V0/Output.d.ts +1 -0
  24. package/lib/types/builtin/async/ai-runtime/runtime-components/V0/Page.d.ts +5 -0
  25. package/lib/types/builtin/async/ai-runtime/runtime-components/V0/index.d.ts +3 -0
  26. package/lib/types/builtin/mui/material.d.ts +1 -1
  27. package/lib/types/tsconfig.tsbuildinfo +1 -0
  28. package/lib/types/utils/inject-global-components-dump-json.d.ts +1 -0
  29. package/package.json +11 -7
@@ -14,3 +14,5 @@ export { default as AutoForm } from './runtime-components/AutoForm';
14
14
  export { default as SimpleOutput } from './runtime-components/SimpleOutput';
15
15
  export { default as ChatOutput } from './runtime-components/ChatOutput';
16
16
  export { default as PhotoGalleryItem } from './runtime-components/PhotoGalleryItem';
17
+ // only use to debug, should be removed when PR
18
+ export * from './runtime-components/V0';
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Icon } from '@iconify/react';
3
3
  import { ArrowBackIosNewRounded } from '@mui/icons-material';
4
- import { Box, Button, CircularProgress, ClickAwayListener, Dialog, DialogContent, DialogTitle, Fab, IconButton, Popper, Stack, Typography, useMediaQuery, useTheme, } from '@mui/material';
4
+ import { Box, Button, CircularProgress, ClickAwayListener, Dialog, DialogContent, DialogTitle, Fab, Grow, IconButton, Popper, Stack, Typography, useMediaQuery, useTheme, } from '@mui/material';
5
5
  import { Suspense, useRef, useState } from 'react';
6
6
  import CustomComponentRenderer from '../../../../../components/CustomComponentRenderer';
7
7
  import { Avatar } from '../../../../arcblock/ux';
@@ -45,23 +45,23 @@ function ResponsiveChatBotContainer({ open, anchorEl, children, onClose, }) {
45
45
  return (_jsx(ChatBotPopper, { anchorEl: anchorEl, title: profile.name, open: open, onClose: onClose, children: children }));
46
46
  }
47
47
  function ChatBotPopper({ title, anchorEl, open, children, onClose, }) {
48
- return (_jsx(Popper, { anchorEl: anchorEl, open: open, disablePortal: true, placement: "top-end", sx: {
48
+ return (_jsx(Popper, { anchorEl: anchorEl, open: open, disablePortal: true, placement: "top-end", transition: true, sx: {
49
49
  zIndex: 'modal',
50
50
  maxWidth: 500,
51
51
  maxHeight: 'min(calc(100vh - 128px), 1000px)',
52
52
  width: 500,
53
53
  height: '90vh',
54
- }, children: _jsx(ClickAwayListener, { onClickAway: (e) => {
54
+ }, children: ({ TransitionProps }) => (_jsx(ClickAwayListener, { onClickAway: (e) => {
55
55
  e.preventDefault();
56
56
  e.stopPropagation();
57
57
  onClose === null || onClose === void 0 ? void 0 : onClose();
58
- }, children: _jsxs(Stack, { sx: {
59
- height: '100%',
60
- boxShadow: 1,
61
- position: 'relative',
62
- background: 'white',
63
- borderRadius: 1,
64
- }, children: [_jsxs(Stack, { direction: "row", alignItems: "center", justifyContent: "space-between", borderBottom: 1, borderColor: "divider", p: 2, gap: 2, children: [_jsx(Typography, { variant: "h6", noWrap: true, children: title }), _jsx(Button, { sx: { minWidth: 28, minHeight: 28, p: 0 }, onClick: onClose, children: _jsx(Icon, { icon: "tabler:x", fontSize: 24, color: "rgba(75, 85, 99, 1)" }) })] }), children] }) }) }));
58
+ }, children: _jsx(Grow, Object.assign({}, TransitionProps, { style: { transformOrigin: 'right bottom' }, timeout: 350, children: _jsxs(Stack, { sx: {
59
+ height: '100%',
60
+ boxShadow: 1,
61
+ position: 'relative',
62
+ background: 'white',
63
+ borderRadius: 1,
64
+ }, children: [_jsxs(Stack, { direction: "row", alignItems: "center", justifyContent: "space-between", borderBottom: 1, borderColor: "divider", p: 2, gap: 2, children: [_jsx(Typography, { variant: "h6", noWrap: true, children: title }), _jsx(Button, { sx: { minWidth: 28, minHeight: 28, p: 0 }, onClick: onClose, children: _jsx(Icon, { icon: "tabler:x", fontSize: 24, color: "rgba(75, 85, 99, 1)" }) })] }), children] }) })) })) }));
65
65
  }
66
66
  function ChatBotDialog({ title, open, children, onClose, }) {
67
67
  return (_jsxs(Dialog, { open: open, onClose: onClose, fullScreen: true, children: [_jsx(DialogTitle, { sx: { pl: 0 }, children: _jsxs(Stack, { direction: "row", alignItems: "center", gap: 2, children: [_jsx(IconButton, { size: "small", onClick: onClose, children: _jsx(ArrowBackIosNewRounded, { fontSize: "inherit" }) }), _jsx(Typography, { variant: "h6", noWrap: true, children: title })] }) }), _jsx(DialogContent, { sx: { p: 0 }, dividers: true, children: children })] }));
@@ -6,10 +6,13 @@ import { useMemo } from 'react';
6
6
  import ReferenceLinks from './ReferenceLinks';
7
7
  export default function MessageMetadataRenderer({ object }) {
8
8
  const referenceLinks = object[RuntimeOutputVariable.referenceLinks];
9
- const images = useMemo(() => {
10
- const list = object[RuntimeOutputVariable.images];
11
- const images = (Array.isArray(list) ? list.map((i) => ({ src: i.url })) : []).filter((i) => typeof i.src === 'string');
12
- return images.length ? images : undefined;
9
+ // 方便后续添加 metadata
10
+ const formattedObject = useMemo(() => {
11
+ const imagesList = object[RuntimeOutputVariable.images];
12
+ const images = (Array.isArray(imagesList) ? imagesList.map((i) => ({ src: i.url })) : []).filter((i) => typeof i.src === 'string');
13
+ return {
14
+ images: (images === null || images === void 0 ? void 0 : images.length) ? images : undefined,
15
+ };
13
16
  }, [object]);
14
- return (_jsxs(_Fragment, { children: [Array.isArray(referenceLinks) && referenceLinks.length ? _jsx(ReferenceLinks, { links: referenceLinks }) : undefined, images && (_jsx(Stack, { gap: 1, children: _jsx(ImagePreview, { dataSource: images, itemWidth: 100 }) }))] }));
17
+ return (_jsxs(_Fragment, { children: [Array.isArray(referenceLinks) && referenceLinks.length ? _jsx(ReferenceLinks, { links: referenceLinks }) : undefined, (formattedObject === null || formattedObject === void 0 ? void 0 : formattedObject.images) && (_jsx(Stack, { gap: 1, children: _jsx(ImagePreview, { dataSource: formattedObject.images, itemWidth: 100 }) }))] }));
15
18
  }
@@ -0,0 +1,146 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
+ import { cx } from '@emotion/css';
12
+ import { Box, FormLabel, InputAdornment, Stack, ThemeProvider, createTheme, formLabelClasses, outlinedInputClasses, styled, useTheme, } from '@mui/material';
13
+ import isEmpty from 'lodash/isEmpty';
14
+ import omit from 'lodash/omit';
15
+ import { useEffect, useMemo, useState } from 'react';
16
+ import { Controller, useForm } from 'react-hook-form';
17
+ import { useLocaleContext } from '../../../../locale';
18
+ import AgentInputField from '../../components/AgentInputField';
19
+ import LoadingButton from '../../components/LoadingButton';
20
+ import { useCurrentAgent } from '../../contexts/CurrentAgent';
21
+ import { useRuntimeState } from '../../state/runtime';
22
+ import { useSessionState } from '../../state/session';
23
+ import { isValidInput } from '../../utils/agent-inputs';
24
+ export default function AutoForm({ submitText, inlineLabel, autoFillLastForm = true, submitInQuestionField, chatMode, }) {
25
+ const { t } = useLocaleContext();
26
+ const { aid, agent } = useCurrentAgent();
27
+ const { execute } = useRuntimeState();
28
+ const running = useSessionState()((s) => s.running);
29
+ const parameters = useMemo(() => {
30
+ var _a;
31
+ return (_a = agent.parameters) === null || _a === void 0 ? void 0 : _a.filter(isValidInput).map((i) => {
32
+ var _a;
33
+ return (Object.assign(Object.assign({}, i), { label: ((_a = i.label) === null || _a === void 0 ? void 0 : _a.trim()) || undefined }));
34
+ });
35
+ }, [agent.parameters]);
36
+ const defaultForm = useInitialFormValues();
37
+ const theme = useFormTheme();
38
+ const form = useForm({ defaultValues: defaultForm });
39
+ useEffect(() => {
40
+ if (autoFillLastForm && !form.formState.isSubmitted && !form.formState.isSubmitting) {
41
+ form.reset(chatMode ? omit(defaultForm, 'question') : defaultForm);
42
+ }
43
+ }, [defaultForm, autoFillLastForm, form, chatMode]);
44
+ const onSubmit = (parameters) => __awaiter(this, void 0, void 0, function* () {
45
+ yield execute({
46
+ aid,
47
+ parameters,
48
+ onResponseStart: () => {
49
+ if (chatMode)
50
+ form.resetField('question', { defaultValue: '' });
51
+ },
52
+ });
53
+ });
54
+ return (_jsx(ThemeProvider, { theme: theme, children: _jsxs(Form, { component: "form", className: cx('form', `label-position-${inlineLabel ? 'start' : 'top'}`), onSubmit: form.handleSubmit(onSubmit), children: [parameters === null || parameters === void 0 ? void 0 : parameters.map((parameter, index) => {
55
+ const { key, required } = parameter !== null && parameter !== void 0 ? parameter : {};
56
+ return (_jsx(Box, { children: _jsx(Controller, { control: form.control, name: key, rules: {
57
+ required,
58
+ min: parameter.type === 'number' && typeof parameter.min === 'number'
59
+ ? { value: parameter.min, message: '' }
60
+ : undefined,
61
+ max: parameter.type === 'number' && typeof parameter.max === 'number'
62
+ ? { value: parameter.max, message: '' }
63
+ : undefined,
64
+ minLength: parameter.type === 'string' && typeof parameter.minLength === 'number'
65
+ ? { value: parameter.minLength, message: '' }
66
+ : undefined,
67
+ maxLength: parameter.type === 'string' && typeof parameter.maxLength === 'number'
68
+ ? { value: parameter.maxLength, message: '' }
69
+ : undefined,
70
+ }, render: ({ field, fieldState }) => {
71
+ var _a;
72
+ return (_jsxs(Stack, { className: "form-item", children: [parameter.label && _jsx(FormLabel, { children: parameter.label }), _jsx(AgentInputField, { inputRef: field.ref, autoFocus: index === 0, size: "small", hiddenLabel: true, fullWidth: true, label: undefined, parameter: parameter, maxRows: !(parameter === null || parameter === void 0 ? void 0 : parameter.type) || (parameter === null || parameter === void 0 ? void 0 : parameter.type) === 'string' ? 5 : undefined, value: field.value || '', onChange: (value) => field.onChange({ target: { value } }), error: Boolean(fieldState.error), helperText: ((_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message) || (parameter === null || parameter === void 0 ? void 0 : parameter.helper), InputProps: parameter.key === 'question' && submitInQuestionField
73
+ ? {
74
+ endAdornment: (_jsx(InputAdornment, { position: "end", sx: { py: 3, mr: -0.75, alignSelf: 'flex-end' }, children: _jsx(LoadingButton, { type: "submit", variant: "contained", loading: running, sx: { borderRadius: 100 }, children: submitText }) })),
75
+ }
76
+ : undefined })] }));
77
+ } }) }, parameter.id));
78
+ }), !(submitInQuestionField && (parameters === null || parameters === void 0 ? void 0 : parameters.some((i) => i.key === 'question'))) && (_jsx(LoadingButton, { type: "submit", variant: "contained", loading: running, sx: { height: 40 }, children: submitText || t('generate') }))] }) }));
79
+ }
80
+ function useInitialFormValues() {
81
+ const { agent } = useCurrentAgent();
82
+ const lastMessage = useSessionState()((s) => { var _a; return (_a = s.messages) === null || _a === void 0 ? void 0 : _a.at(-1); });
83
+ const [lastInputs, setLastInputs] = useState();
84
+ useEffect(() => {
85
+ if (!lastInputs) {
86
+ const lastParameters = lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.parameters;
87
+ if (!isEmpty(lastParameters))
88
+ setLastInputs(lastParameters);
89
+ }
90
+ }, [lastMessage]);
91
+ return useMemo(() => {
92
+ var _a, _b;
93
+ if (lastInputs) {
94
+ return lastInputs;
95
+ }
96
+ return Object.fromEntries((_b = (_a = agent.parameters) === null || _a === void 0 ? void 0 : _a.map((parameter) => [parameter.key, parameter.defaultValue])) !== null && _b !== void 0 ? _b : []);
97
+ }, [lastInputs, agent]);
98
+ }
99
+ function useFormTheme() {
100
+ const theme = useTheme();
101
+ return useMemo(() => {
102
+ const themeOptions = {
103
+ shape: {
104
+ borderRadius: 8,
105
+ },
106
+ components: {
107
+ MuiTextField: {
108
+ styleOverrides: {
109
+ root: ({ theme }) => theme.unstable_sx({
110
+ [`.${outlinedInputClasses.root}`]: {
111
+ [`.${outlinedInputClasses.notchedOutline}`]: {
112
+ borderWidth: 2,
113
+ borderColor: 'primary.light',
114
+ },
115
+ ':hover': {
116
+ [`.${outlinedInputClasses.notchedOutline}`]: {
117
+ borderColor: 'primary.main',
118
+ },
119
+ },
120
+ },
121
+ }),
122
+ },
123
+ },
124
+ },
125
+ };
126
+ return createTheme(theme, themeOptions);
127
+ }, [theme]);
128
+ }
129
+ const Form = styled(Stack)(({ theme }) => theme.unstable_sx({
130
+ gap: 2,
131
+ '.form-item': {
132
+ gap: 0.5,
133
+ [`.${formLabelClasses.root}`]: {
134
+ fontWeight: 500,
135
+ color: 'text.primary',
136
+ },
137
+ },
138
+ '&.label-position-start': {
139
+ '.form-item': {
140
+ display: 'flex',
141
+ flexDirection: 'row',
142
+ alignItems: 'center',
143
+ gap: 1,
144
+ },
145
+ },
146
+ }));
@@ -0,0 +1,73 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Icon } from '@iconify/react';
3
+ import { Box, Drawer, IconButton, Skeleton, Stack } from '@mui/material';
4
+ import { useState } from 'react';
5
+ import CustomComponentRenderer from '../../../../../components/CustomComponentRenderer';
6
+ import MarkdownRenderer from '../../components/MarkdownRenderer';
7
+ import ShareActions from '../../components/ShareActions';
8
+ import { useCurrentMessage } from '../../contexts/CurrentMessage';
9
+ import MessageErrorView from '../ChatOutput/MessageErrorView';
10
+ import MessageMetadataRenderer from '../ChatOutput/MessageMetadataRenderer';
11
+ const codeField = 'code';
12
+ export default function V0Output() {
13
+ var _a, _b;
14
+ const { message } = useCurrentMessage();
15
+ const objects = (_a = message.result) === null || _a === void 0 ? void 0 : _a.objects;
16
+ const { error } = message;
17
+ const isMessageLoading = (message.loading || !message.result) && !message.error;
18
+ return (_jsxs(Stack, { gap: 2, sx: {
19
+ py: 2,
20
+ }, children: [error && _jsx(MessageErrorView, { error: error }), isMessageLoading && (_jsx(Stack, { sx: {
21
+ flex: 1,
22
+ }, children: _jsx(Skeleton, { variant: "rectangular", sx: {
23
+ height: 400,
24
+ borderRadius: 1,
25
+ } }) })), objects === null || objects === void 0 ? void 0 : objects.map((item) => {
26
+ // @ts-ignore
27
+ const code = item.data[codeField];
28
+ return (_jsx(Box, { flex: 1, sx: {
29
+ display: 'flex',
30
+ justifyContent: 'center',
31
+ alignItems: 'center',
32
+ }, children: _jsx(CodePreview, { code: code }) }));
33
+ }), objects === null || objects === void 0 ? void 0 : objects.map((item) => _jsx(MessageMetadataRenderer, { object: item.data })), !isMessageLoading && ((_b = message.result) === null || _b === void 0 ? void 0 : _b.content) && (_jsx(ShareActions, { direction: "row", justifyContent: "flex-end", sx: { mt: 2 } }))] }));
34
+ }
35
+ function CodePreview({ code }) {
36
+ const [showCode, setShowCode] = useState(false);
37
+ if (!code)
38
+ return null;
39
+ return (_jsxs(Stack, { sx: {
40
+ flex: 1,
41
+ }, children: [_jsx(Box, { sx: {
42
+ display: 'flex',
43
+ justifyContent: 'flex-end',
44
+ }, children: _jsx(IconButton, { onClick: () => setShowCode((prev) => !prev), sx: {
45
+ color: 'textColor',
46
+ }, children: _jsx(Icon, { icon: showCode ? 'tabler:layout-sidebar' : 'tabler:code' }) }) }), _jsx(Stack, { gap: 2, sx: {
47
+ display: 'flex',
48
+ flexDirection: 'row',
49
+ alignItems: 'center',
50
+ justifyContent: 'center',
51
+ }, children: _jsx(Box, { sx: {
52
+ display: 'flex',
53
+ justifyContent: 'center',
54
+ alignItems: 'center',
55
+ }, children: _jsx(CustomComponentRenderer, { componentId: "mock-dev-component", dev: {
56
+ components: {
57
+ 'mock-dev-component': {
58
+ data: {
59
+ id: 'mock-dev-component',
60
+ createdAt: '',
61
+ updatedAt: '',
62
+ renderer: {
63
+ type: 'react-component',
64
+ script: code,
65
+ },
66
+ },
67
+ },
68
+ },
69
+ } }) }) }), _jsx(Drawer, { anchor: "right", open: showCode, onClose: () => setShowCode(false), children: _jsx(Box, { sx: {
70
+ p: 2,
71
+ maxWidth: '40vw',
72
+ }, children: _jsx(MarkdownRenderer, { children: `\`\`\`typescript\n${code}\n\`\`\`` }) }) })] }));
73
+ }
@@ -0,0 +1,142 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { Box, Card, CardContent, Container, Grid, Stack, ThemeProvider, Typography, createTheme, useTheme, } from '@mui/material';
14
+ import dayjs from 'dayjs';
15
+ // import { useRuntimeState } from '@blocklet/pages-kit/builtin/async/ai-runtime';
16
+ // import { Icon } from 'iconify/react';
17
+ import { Suspense, useCallback, useEffect, useMemo, useState } from 'react';
18
+ import CustomComponentRenderer from '../../../../../components/CustomComponentRenderer';
19
+ import CurrentAgentProvider from '../../contexts/CurrentAgent';
20
+ import CurrentMessageProvider from '../../contexts/CurrentMessage';
21
+ import useAppearances from '../../hooks/use-appearances';
22
+ import { useRuntimeState } from '../../state/runtime';
23
+ import { useSessionState } from '../../state/session';
24
+ const getLineClamp = (count) => {
25
+ return {
26
+ display: '-webkit-box',
27
+ WebkitLineClamp: count,
28
+ WebkitBoxOrient: 'vertical',
29
+ overflow: 'hidden',
30
+ textOverflow: 'ellipsis',
31
+ };
32
+ };
33
+ function V0Page({ textColor = '#333', primaryColor }) {
34
+ var _a;
35
+ const inheritedTheme = useTheme();
36
+ const theme = useMemo(() => {
37
+ let { primary } = inheritedTheme.palette;
38
+ try {
39
+ if (primaryColor) {
40
+ primary = inheritedTheme.palette.augmentColor({ color: { main: primaryColor } });
41
+ }
42
+ }
43
+ catch (error) {
44
+ console.error('augment primary color error', { error });
45
+ }
46
+ return createTheme(inheritedTheme, {
47
+ palette: { primary, textColor },
48
+ shape: {
49
+ borderRadius: 8,
50
+ },
51
+ });
52
+ }, [inheritedTheme, primaryColor, textColor]);
53
+ const [sessionId] = useState('1');
54
+ const [message, setMessage] = useState();
55
+ const { childAgentId } = useRuntimeState();
56
+ const messagesList = useSessionState({
57
+ autoLoad: true,
58
+ })((s) => s.messages);
59
+ useEffect(() => {
60
+ if (messagesList === null || messagesList === void 0 ? void 0 : messagesList.length) {
61
+ const lastMessage = messagesList[messagesList.length - 1];
62
+ // @ts-ignore
63
+ setMessage(lastMessage);
64
+ }
65
+ }, [messagesList]);
66
+ const SliderRender = useCallback(({ message }) => {
67
+ // if is detail, return output
68
+ if (sessionId && (messagesList === null || messagesList === void 0 ? void 0 : messagesList.length)) {
69
+ return (_jsx(Box, { sx: {
70
+ width: 200,
71
+ p: 2,
72
+ position: 'sticky',
73
+ top: 64,
74
+ height: 'calc(100vh - 65px)',
75
+ overflowY: 'auto',
76
+ }, children: _jsx(Stack, { spacing: 2, justifyContent: "center", children: messagesList === null || messagesList === void 0 ? void 0 : messagesList.map((_, i) => {
77
+ var _a;
78
+ const isCurrent = _.taskId === (message === null || message === void 0 ? void 0 : message.taskId);
79
+ return (_jsxs(Box, { onClick: () => {
80
+ // @ts-ignore
81
+ setMessage(_);
82
+ }, sx: {
83
+ cursor: 'pointer',
84
+ backgroundColor: isCurrent ? 'primary.main' : 'rgba(0, 0, 0, 0.5)',
85
+ color: '#fff',
86
+ borderRadius: 1,
87
+ p: 1,
88
+ }, children: [_jsx(Typography, { variant: "caption", display: "block", sx: Object.assign({ color: 'rgba(255, 255, 255, 0.9)' }, getLineClamp(2)), children: (_a = _.parameters) === null || _a === void 0 ? void 0 : _a.question }), _jsx(Box, { children: _jsxs(Typography, { sx: {
89
+ textAlign: 'right',
90
+ fontWeight: 600,
91
+ fontSize: 12,
92
+ mt: 0.5,
93
+ display: 'flex',
94
+ justifyContent: 'space-between',
95
+ }, children: [_jsx("span", { style: {
96
+ color: 'rgba(255, 255, 255, 0.7)',
97
+ fontWeight: 400,
98
+ }, children: dayjs(_.updatedAt).format('MM-DD HH:mm') }), _jsx("span", { children: `V${i}` })] }) })] }, _.assistantId));
99
+ }) }) }, "slider"));
100
+ }
101
+ return null;
102
+ }, [JSON.stringify(messagesList)]);
103
+ const ContentRender = useCallback(() => {
104
+ // if is detail, return output
105
+ if (sessionId) {
106
+ return (_jsx(Box, { flex: 1, children: _jsx(AgentOutputRender, { message: message }) }));
107
+ }
108
+ return (_jsx(Box, { flex: 1, children: _jsx(Grid, { container: true, spacing: 2, justifyContent: "center", children: [...Array(3)].map((_, i) => (_jsx(Grid, { item: true, xs: 12, sm: 6, md: 4, children: _jsx(Card, { sx: { backgroundColor: 'rgba(0, 0, 0, 0.5)', color: '#fff' }, children: _jsxs(CardContent, { children: [_jsx(Typography, { variant: "body2", sx: { mb: 1 }, children: `Code Snippet ${i + 1}` }), _jsx(Typography, { variant: "caption", display: "block", sx: { color: 'rgba(255, 255, 255, 0.7)' }, children: `This is history requirement ${i + 1}` })] }) }) }, i))) }) }));
109
+ }, [JSON.stringify(message)]);
110
+ return (_jsx(ThemeProvider, { theme: theme, children: _jsx(CurrentAgentProvider, { agentId: childAgentId, children: _jsxs(Box, { sx: {
111
+ display: 'flex',
112
+ // background: 'linear-gradient(135deg, #1a237e 0%, #3c3f41 100%)',
113
+ }, children: [_jsx(SliderRender, { message: message }), _jsxs(Container, { sx: {
114
+ minHeight: 'calc(100vh - 64px - 1px)',
115
+ textAlign: 'center',
116
+ py: 2,
117
+ pt: 10,
118
+ gap: 2,
119
+ display: 'flex',
120
+ flexDirection: 'column',
121
+ }, children: [_jsx(Typography, { variant: "h2", color: "textColor", sx: { fontWeight: 'bold' }, children: "AIGNE V0" }), _jsx(Typography, { variant: "h5", color: "textColor", sx: Object.assign({}, getLineClamp(5)), children: ((_a = message === null || message === void 0 ? void 0 : message.parameters) === null || _a === void 0 ? void 0 : _a.question) || 'A v0 release to help you build code quickly' }), _jsx(ContentRender, {}), _jsx(Box, { sx: {
122
+ position: 'sticky',
123
+ bottom: 0,
124
+ backgroundColor: 'white',
125
+ pt: 4,
126
+ }, children: _jsx(AgentInputRender, {}) })] })] }) }) }));
127
+ }
128
+ export default V0Page;
129
+ function AgentInputRender(_a) {
130
+ var props = __rest(_a, []);
131
+ const { appearanceInput } = useAppearances();
132
+ if (!(appearanceInput === null || appearanceInput === void 0 ? void 0 : appearanceInput.componentId))
133
+ return null;
134
+ return (_jsx(Suspense, { children: _jsx(CustomComponentRenderer, Object.assign({ componentId: appearanceInput.componentId, properties: appearanceInput.componentProps }, props)) }));
135
+ }
136
+ function AgentOutputRender(_a) {
137
+ var { message } = _a, props = __rest(_a, ["message"]);
138
+ const { appearanceOutput } = useAppearances();
139
+ if (!(appearanceOutput === null || appearanceOutput === void 0 ? void 0 : appearanceOutput.componentId) || !message)
140
+ return null;
141
+ return (_jsx(CurrentAgentProvider, { agentId: message.assistantId, children: _jsx(CurrentMessageProvider, { message: message, children: _jsx(Suspense, { children: _jsx(CustomComponentRenderer, Object.assign({ componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProps }, props)) }) }) }));
142
+ }
@@ -0,0 +1,3 @@
1
+ export { default as V0Page } from './Page';
2
+ export { default as V0Output } from './Output';
3
+ export { default as V0Input } from './Input';
@@ -1 +1 @@
1
- export { Alert, AlertTitle, Autocomplete, Avatar, Box, Button, ButtonGroup, Card, CardActionArea, CardActions, CardContent, CardHeader, CardMedia, CircularProgress, ClickAwayListener, Collapse, Container, Dialog, DialogActions, DialogContent, DialogTitle, Divider, Fade, GlobalStyles, Grid, Grow, LinearProgress, Link, List, ListItem, ListItemAvatar, ListItemButton, ListItemIcon, ListItemSecondaryAction, ListSubheader, Menu, MenuItem, MenuList, Paper, Popper, Slide, Stack, Switch, TextField, ThemeProvider, Tooltip, Typography, Zoom, alpha, createTheme, styled, useMediaQuery, useTheme, } from '@mui/material';
1
+ export { Alert, AlertTitle, Autocomplete, Avatar, Box, Button, IconButton, ButtonGroup, Card, CardActionArea, CardActions, CardContent, CardHeader, CardMedia, CircularProgress, ClickAwayListener, Collapse, Container, Dialog, DialogActions, DialogContent, DialogTitle, Divider, Fade, GlobalStyles, Grid, Grow, LinearProgress, Link, List, ListItem, ListItemAvatar, ListItemButton, ListItemIcon, ListItemSecondaryAction, ListSubheader, Menu, MenuItem, MenuList, Paper, Popper, Slide, Stack, Switch, TextField, ThemeProvider, Tooltip, Typography, Zoom, alpha, createTheme, styled, useMediaQuery, useTheme, } from '@mui/material';