@blocklet/pages-kit 0.2.327 → 0.2.329

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 (42) hide show
  1. package/lib/cjs/builtin/async/ai-runtime/components/Header/SimpleHeader.js +1 -1
  2. package/lib/cjs/builtin/async/ai-runtime/components/ThemeProvider.js +47 -29
  3. package/lib/cjs/builtin/async/ai-runtime/components/UserInfo.js +4 -6
  4. package/lib/cjs/builtin/async/ai-runtime/locales/index.js +10 -4
  5. package/lib/cjs/builtin/async/ai-runtime/runtime-components/AutoForm/index.js +1 -1
  6. package/lib/cjs/builtin/async/ai-runtime/runtime-components/GoogleSearch/GoogleSearchRelatedQuestionsView.js +1 -1
  7. package/lib/cjs/builtin/async/ai-runtime/runtime-components/GoogleSearch/GoogleSearchSourcesView.js +16 -2
  8. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/BackgroundImage.js +10 -0
  9. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/MessageView.js +6 -4
  10. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/OpeningMessageView.js +3 -2
  11. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/index.js +4 -1
  12. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/Page.js +15 -6
  13. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/components/CodePreview.js +74 -19
  14. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/components/TransparentTooltip.js +25 -0
  15. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/components/UserQuestion.js +8 -3
  16. package/lib/cjs/components/CustomComponentRenderer/index.js +3 -2
  17. package/lib/cjs/tsconfig.tsbuildinfo +1 -1
  18. package/lib/esm/builtin/async/ai-runtime/components/Header/SimpleHeader.js +1 -1
  19. package/lib/esm/builtin/async/ai-runtime/components/ThemeProvider.js +48 -30
  20. package/lib/esm/builtin/async/ai-runtime/components/UserInfo.js +4 -6
  21. package/lib/esm/builtin/async/ai-runtime/locales/index.js +10 -4
  22. package/lib/esm/builtin/async/ai-runtime/runtime-components/AutoForm/index.js +1 -1
  23. package/lib/esm/builtin/async/ai-runtime/runtime-components/GoogleSearch/GoogleSearchRelatedQuestionsView.js +1 -1
  24. package/lib/esm/builtin/async/ai-runtime/runtime-components/GoogleSearch/GoogleSearchSourcesView.js +17 -3
  25. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/BackgroundImage.js +10 -0
  26. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/MessageView.js +6 -4
  27. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/OpeningMessageView.js +3 -2
  28. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/index.js +5 -2
  29. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/Page.js +15 -6
  30. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/components/CodePreview.js +73 -18
  31. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/components/TransparentTooltip.js +23 -0
  32. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/components/UserQuestion.js +8 -3
  33. package/lib/esm/components/CustomComponentRenderer/index.js +3 -2
  34. package/lib/esm/tsconfig.tsbuildinfo +1 -1
  35. package/lib/types/builtin/async/ai-runtime/api/agent.d.ts +9 -1
  36. package/lib/types/builtin/async/ai-runtime/components/UserInfo.d.ts +2 -1
  37. package/lib/types/builtin/async/ai-runtime/locales/index.d.ts +6 -0
  38. package/lib/types/builtin/async/ai-runtime/runtime-components/V0/components/CodePreview.d.ts +2 -1
  39. package/lib/types/builtin/async/ai-runtime/runtime-components/V0/components/TransparentTooltip.d.ts +3 -0
  40. package/lib/types/components/CustomComponentRenderer/index.d.ts +1 -0
  41. package/lib/types/tsconfig.tsbuildinfo +1 -1
  42. package/package.json +7 -6
@@ -44,6 +44,6 @@ function SimpleHeader(_a) {
44
44
  const { agent } = (0, runtime_1.useRuntimeState)();
45
45
  const title = agent.project.name;
46
46
  const { description } = agent.project;
47
- return ((0, jsx_runtime_1.jsx)(material_1.Stack, Object.assign({ gap: 2, mt: 8, mb: 4 }, props, { className: (0, css_1.cx)('aigne-header aigne-simple-header', props.className), children: (0, jsx_runtime_1.jsxs)(react_wrap_balancer_1.Provider, { children: [title && ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ width: "100%", component: "h5", fontSize: 30, fontWeight: 700, textAlign: "center" }, TitleProps, { children: (0, jsx_runtime_1.jsx)(react_wrap_balancer_1.default, { children: title }) }))), description && ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ width: "100%", textAlign: "center" }, DescriptionProps, { children: (0, jsx_runtime_1.jsx)(react_wrap_balancer_1.default, { children: description }) })))] }) })));
47
+ return ((0, jsx_runtime_1.jsx)(material_1.Stack, Object.assign({ gap: 2, mt: 8, mb: 4 }, props, { className: (0, css_1.cx)('aigne-header aigne-simple-header', props.className), children: (0, jsx_runtime_1.jsxs)(react_wrap_balancer_1.Provider, { children: [title && ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ width: "100%", variant: "h4", fontSize: 30, fontWeight: 700, textAlign: "center" }, TitleProps, { children: (0, jsx_runtime_1.jsx)(react_wrap_balancer_1.default, { children: title }) }))), description && ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ width: "100%", textAlign: "center" }, DescriptionProps, { children: (0, jsx_runtime_1.jsx)(react_wrap_balancer_1.default, { children: description }) })))] }) })));
48
48
  }
49
49
  exports.default = SimpleHeader;
@@ -21,18 +21,32 @@ const react_1 = require("react");
21
21
  const runtime_1 = require("../state/runtime");
22
22
  const GlobalLoading_1 = __importDefault(require("./GlobalLoading"));
23
23
  function ThemeProvider({ children }) {
24
- const { primaryColor } = (0, runtime_1.useRuntimeState)().agent.project;
24
+ const { appearance } = (0, runtime_1.useRuntimeState)().agent.project;
25
25
  const theme = (0, material_1.useTheme)();
26
26
  const newTheme = (0, react_1.useMemo)(() => {
27
+ var _a, _b, _c, _d, _e, _f;
27
28
  let { primary } = theme.palette;
28
29
  try {
29
- if (primaryColor) {
30
- primary = theme.palette.augmentColor({ color: { main: primaryColor } });
30
+ if (appearance === null || appearance === void 0 ? void 0 : appearance.primaryColor) {
31
+ primary = theme.palette.augmentColor({ color: { main: appearance === null || appearance === void 0 ? void 0 : appearance.primaryColor } });
31
32
  }
32
33
  }
33
34
  catch (error) {
34
35
  console.error('augment primary color error', { error });
35
36
  }
37
+ const { fontFamily } = theme.typography;
38
+ const headingFontFamily = [
39
+ ((_b = (_a = appearance === null || appearance === void 0 ? void 0 : appearance.typography) === null || _a === void 0 ? void 0 : _a.heading) === null || _b === void 0 ? void 0 : _b.fontFamily) && JSON.stringify((_d = (_c = appearance === null || appearance === void 0 ? void 0 : appearance.typography) === null || _c === void 0 ? void 0 : _c.heading) === null || _d === void 0 ? void 0 : _d.fontFamily),
40
+ fontFamily,
41
+ ]
42
+ .filter(Boolean)
43
+ .join(',');
44
+ const bodyFontFamily = [
45
+ ((_e = appearance === null || appearance === void 0 ? void 0 : appearance.typography) === null || _e === void 0 ? void 0 : _e.fontFamily) && JSON.stringify((_f = appearance === null || appearance === void 0 ? void 0 : appearance.typography) === null || _f === void 0 ? void 0 : _f.fontFamily),
46
+ fontFamily,
47
+ ]
48
+ .filter(Boolean)
49
+ .join(',');
36
50
  const themeOptions = {
37
51
  components: {
38
52
  MuiSelect: {
@@ -98,30 +112,28 @@ function ThemeProvider({ children }) {
98
112
  },
99
113
  },
100
114
  };
101
- const paletteTheme = (0, material_1.createTheme)({
115
+ const tempTheme = (0, material_1.createTheme)({
116
+ typography: Object.assign({ fontFamily: bodyFontFamily }, Object.fromEntries(new Array(5).fill(0).map((_, index) => [
117
+ `h${index + 1}`,
118
+ {
119
+ fontFamily: headingFontFamily,
120
+ },
121
+ ]))),
102
122
  palette: {
103
123
  primary,
104
124
  secondary: {
105
125
  main: '#010714',
106
126
  },
107
- text: {
108
- secondary: '#98A3B1',
109
- // @ts-ignore
110
- poweredBy: 'rgba(209, 213, 219, 1)',
111
- },
112
- // @ts-ignore custom `black` color
113
- black: {
114
- main: '#010714',
115
- },
116
127
  },
117
128
  });
118
129
  return (0, material_1.createTheme)(theme, themeOptions, {
130
+ typography: tempTheme.typography,
119
131
  palette: {
120
- primary: paletteTheme.palette.primary,
121
- secondary: paletteTheme.palette.secondary,
122
- text: paletteTheme.palette.text,
132
+ primary: tempTheme.palette.primary,
133
+ secondary: tempTheme.palette.secondary,
134
+ text: tempTheme.palette.text,
123
135
  // @ts-ignore
124
- black: paletteTheme.palette.black,
136
+ black: tempTheme.palette.black,
125
137
  background: {
126
138
  default: '#ffffff',
127
139
  },
@@ -133,20 +145,26 @@ function ThemeProvider({ children }) {
133
145
  'none',
134
146
  '0px 0px 0px 1px rgba(2, 7, 19, 0.08), 0px 1px 2px -1px rgba(2, 7, 19, 0.08), 0px 2px 4px 0px rgba(2, 7, 19, 0.04)',
135
147
  '0px 0px 0px 1px rgba(2, 7, 19, 0.08), 0px 1px 2px -1px rgba(2, 7, 19, 0.08), 0px 2px 8px 0px rgba(2, 7, 19, 0.10)',
136
- ...paletteTheme.shadows.slice(3),
148
+ ...tempTheme.shadows.slice(3),
137
149
  ],
138
150
  });
139
151
  }, [theme]);
140
- return ((0, jsx_runtime_1.jsxs)(material_1.ThemeProvider, { theme: newTheme, children: [(0, jsx_runtime_1.jsx)(material_1.GlobalStyles, { styles: {
141
- '.page-header': {
142
- borderBottom: '1px solid rgba(229, 231, 235, 1)',
143
- },
144
- '.white-tooltip .MuiTooltip-tooltip': {
145
- background: 'white !important',
146
- boxShadow: '0px 4px 8px 0px rgba(3, 7, 18, 0.08)',
147
- border: '1px solid rgba(229, 231, 235, 1)',
148
- padding: 4,
149
- },
150
- } }), (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.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 })] }));
152
+ return ((0, jsx_runtime_1.jsx)(material_1.ThemeProvider, { theme: newTheme, children: (0, jsx_runtime_1.jsxs)(material_1.CssBaseline, { children: [(0, jsx_runtime_1.jsx)(material_1.GlobalStyles, { styles: (theme) => theme.unstable_sx({
153
+ 'h1,h2,h3,h4,h5': {
154
+ fontFamily: `${theme.typography.h1.fontFamily} !important`,
155
+ },
156
+ body: {
157
+ fontFamily: `${theme.typography.fontFamily} !important`,
158
+ },
159
+ '.page-header': {
160
+ borderBottom: '1px solid rgba(229, 231, 235, 1)',
161
+ },
162
+ '.white-tooltip .MuiTooltip-tooltip': {
163
+ background: 'white !important',
164
+ boxShadow: '0px 4px 8px 0px rgba(3, 7, 18, 0.08)',
165
+ border: '1px solid rgba(229, 231, 235, 1)',
166
+ padding: 4,
167
+ },
168
+ }) }), (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.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 })] }) }));
151
169
  }
152
170
  exports.default = ThemeProvider;
@@ -22,18 +22,16 @@ const dayjs_1 = __importDefault(require("dayjs"));
22
22
  const react_1 = require("react");
23
23
  const ux_1 = require("../../../arcblock/ux");
24
24
  function UserInfo(_a) {
25
- var { avatar, showDID, did, name, time, children, reverse } = _a, restProps = __rest(_a, ["avatar", "showDID", "did", "name", "time", "children", "reverse"]);
25
+ var { avatar, showDID, did, name, time, children, reverse, UserNameProps } = _a, restProps = __rest(_a, ["avatar", "showDID", "did", "name", "time", "children", "reverse", "UserNameProps"]);
26
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
27
  display: 'flex',
28
28
  alignItems: 'center',
29
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: {
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, Object.assign({}, UserNameProps, { sx: Object.assign({ justifyContent: reverse ? 'flex-end' : 'flex-start' }, UserNameProps === null || UserNameProps === void 0 ? void 0 : UserNameProps.sx), children: [name || '', time && ((0, jsx_runtime_1.jsx)(UserTime, { time: time, sx: {
33
31
  fontSize: 12,
34
32
  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 })] })] })));
33
+ opacity: 0.8,
34
+ } }))] })), 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
35
  }
38
36
  exports.default = UserInfo;
39
37
  function UserName(_a) {
@@ -97,8 +97,8 @@ exports.translations = {
97
97
  session: 'Session',
98
98
  loadMore: 'Load More',
99
99
  v0: {
100
- title: 'AIGNE v0',
101
- description: 'AIGNE v0 is an AI-based code tool that can help you generate code quickly.',
100
+ title: 'Mock 0',
101
+ description: 'Mock 0 is an AI-based code tool that can help you generate code quickly.',
102
102
  noData: 'No conversation information yet, click the button below to start generating!',
103
103
  deleteSessionTitle: 'Delete Conversation Information',
104
104
  deleteSessionTip: 'Are you sure you want to delete this Conversation Information?',
@@ -109,6 +109,9 @@ exports.translations = {
109
109
  codePreviewTip: 'Here is the code preview, you can view the generated code, and editing is not supported yet.',
110
110
  hideSlider: 'Hide Versions',
111
111
  showSlider: 'Show Versions',
112
+ retryTip: 'Agent not enough power, please try again later...',
113
+ retry: 'Try Again',
114
+ errorCodeTip: 'Agent found some syntax errors in the code, and want to try again...',
112
115
  },
113
116
  },
114
117
  zh: {
@@ -206,8 +209,8 @@ exports.translations = {
206
209
  session: '会话',
207
210
  loadMore: '加载更多',
208
211
  v0: {
209
- title: 'AIGNE v0',
210
- description: 'AIGNE v0 是一个基于人工智能的代码工具,可以帮助您快速生成代码。',
212
+ title: 'Mock 0',
213
+ description: 'Mock 0 是一个基于人工智能的代码工具,可以帮助您快速生成代码。',
211
214
  noData: '暂无生成记录,点击下方按钮开始生成吧!',
212
215
  deleteSessionTitle: '删除生成记录',
213
216
  deleteSessionTip: '确定要删除此生成记录吗?',
@@ -218,6 +221,9 @@ exports.translations = {
218
221
  codePreviewTip: '以下是代码预览,您可以查看生成的代码,目前还不支持编辑。',
219
222
  hideSlider: '隐藏版本历史',
220
223
  showSlider: '显示版本历史',
224
+ retryTip: 'Agent 算力不足,请稍后重试...',
225
+ retry: '重试',
226
+ errorCodeTip: 'Agent 发现代码存在一些语法错误,请求重试...',
221
227
  },
222
228
  },
223
229
  };
@@ -76,7 +76,7 @@ function AutoForm({ submitText, inlineLabel, autoFillLastForm = true, submitInQu
76
76
  var _a;
77
77
  return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { className: "form-item", children: [parameter.label && (0, jsx_runtime_1.jsx)(material_1.FormLabel, { children: parameter.label }), (0, jsx_runtime_1.jsx)(AgentInputField_1.default, { inputRef: field.ref, autoFocus: index === 0, size: "small", hiddenLabel: true, fullWidth: true, label: undefined, parameter: parameter, maxRows: !(parameter === null || parameter === void 0 ? void 0 : parameter.type) || (parameter === null || parameter === void 0 ? void 0 : parameter.type) === 'string' ? 5 : undefined, value: field.value || '', onChange: (value) => field.onChange({ target: { value } }), error: Boolean(fieldState.error), helperText: ((_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message) || (parameter === null || parameter === void 0 ? void 0 : parameter.helper), InputProps: parameter.key === 'question' && submitInQuestionField
78
78
  ? {
79
- endAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, { position: "end", sx: { py: 3, mr: -0.75, alignSelf: 'flex-end' }, children: (0, jsx_runtime_1.jsx)(LoadingButton_1.default, { type: "submit", variant: "contained", loading: running, sx: { borderRadius: 100 }, children: submitText }) })),
79
+ endAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, { position: "end", sx: { py: 3, mr: -0.75, alignSelf: 'flex-end' }, children: (0, jsx_runtime_1.jsx)(LoadingButton_1.default, { type: "submit", variant: "contained", loading: running, sx: { borderRadius: 1.5 }, children: submitText }) })),
80
80
  }
81
81
  : undefined })] }));
82
82
  } }) }, parameter.id));
@@ -45,7 +45,7 @@ function GoogleSearchRelatedView({ output, outputValue, onlyLastMessage, }) {
45
45
  }, [outputValue]);
46
46
  if ((!isLastMessage && onlyLastMessage) || !((_b = result === null || result === void 0 ? void 0 : result.related_questions) === null || _b === void 0 ? void 0 : _b.length))
47
47
  return null;
48
- return ((0, jsx_runtime_1.jsx)(OutputFieldContainer_1.default, { output: output, children: (0, jsx_runtime_1.jsx)(material_1.List, { dense: true, disablePadding: true, children: result.related_questions.map((item) => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.ListItemButton, { onClick: () => __awaiter(this, void 0, void 0, function* () {
48
+ return ((0, jsx_runtime_1.jsx)(OutputFieldContainer_1.default, { output: output, children: (0, jsx_runtime_1.jsx)(material_1.List, { dense: true, disablePadding: true, children: result.related_questions.map((item) => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.ListItemButton, { sx: { py: 1, px: 2 }, onClick: () => __awaiter(this, void 0, void 0, function* () {
49
49
  if (submitting)
50
50
  return;
51
51
  setSubmitting(true);
@@ -7,6 +7,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
7
7
  const material_1 = require("@mui/material");
8
8
  const joi_1 = __importDefault(require("joi"));
9
9
  const react_1 = require("react");
10
+ const react_transition_group_1 = require("react-transition-group");
10
11
  const OutputFieldContainer_1 = __importDefault(require("../../components/OutputFieldContainer"));
11
12
  const CurrentMessage_1 = require("../../contexts/CurrentMessage");
12
13
  const searchResultSchema = joi_1.default.object({
@@ -21,26 +22,39 @@ const searchResultSchema = joi_1.default.object({
21
22
  function GoogleSearchSourcesView({ output, outputValue }) {
22
23
  var _a;
23
24
  const { message } = (_a = (0, CurrentMessage_1.useCurrentMessage)({ optional: true })) !== null && _a !== void 0 ? _a : {};
25
+ const [showAll, setShowAll] = (0, react_1.useState)(false);
24
26
  const searchResult = (0, react_1.useMemo)(() => {
25
27
  const result = searchResultSchema.validate(outputValue, { allowUnknown: true });
26
28
  if (result.error)
27
29
  return undefined;
28
30
  return result.value;
29
31
  }, [outputValue]);
32
+ const handleToggle = () => setShowAll(!showAll);
30
33
  if (!message || (!(searchResult === null || searchResult === void 0 ? void 0 : searchResult.organic_results.length) && !message.loading))
31
34
  return null;
32
- return ((0, jsx_runtime_1.jsx)(OutputFieldContainer_1.default, { output: output, children: (0, jsx_runtime_1.jsxs)(material_1.Grid, { container: true, spacing: 1.5, children: [message.loading && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, { item: true, xs: 4, sm: 3, md: 2, children: (0, jsx_runtime_1.jsx)(ItemSkeleton, {}) }), (0, jsx_runtime_1.jsx)(material_1.Grid, { item: true, xs: 4, sm: 3, md: 2, children: (0, jsx_runtime_1.jsx)(ItemSkeleton, {}) }), (0, jsx_runtime_1.jsx)(material_1.Grid, { item: true, xs: 4, sm: 3, md: 2, children: (0, jsx_runtime_1.jsx)(ItemSkeleton, {}) })] })), searchResult === null || searchResult === void 0 ? void 0 : searchResult.organic_results.map((item) => ((0, jsx_runtime_1.jsx)(material_1.Grid, { item: true, xs: 4, sm: 3, md: 2, children: (0, jsx_runtime_1.jsx)(ItemView, { item: item }) }, item.link)))] }) }));
35
+ const list = [...((searchResult === null || searchResult === void 0 ? void 0 : searchResult.organic_results) || [])];
36
+ const itemsToShow = showAll
37
+ ? [...((searchResult === null || searchResult === void 0 ? void 0 : searchResult.organic_results) || [])]
38
+ : [...((searchResult === null || searchResult === void 0 ? void 0 : searchResult.organic_results) || [])].slice(0, (list === null || list === void 0 ? void 0 : list.length) > 3 ? 2 : 3);
39
+ return ((0, jsx_runtime_1.jsx)(OutputFieldContainer_1.default, { output: output, children: (0, jsx_runtime_1.jsxs)(material_1.Grid, { container: true, spacing: 1.5, children: [message.loading && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, { item: true, xs: 4, sm: 4, md: 4, children: (0, jsx_runtime_1.jsx)(ItemSkeleton, {}) }), (0, jsx_runtime_1.jsx)(material_1.Grid, { item: true, xs: 4, sm: 4, md: 4, children: (0, jsx_runtime_1.jsx)(ItemSkeleton, {}) }), (0, jsx_runtime_1.jsx)(material_1.Grid, { item: true, xs: 4, sm: 4, md: 4, children: (0, jsx_runtime_1.jsx)(ItemSkeleton, {}) })] })), (0, jsx_runtime_1.jsx)(react_transition_group_1.TransitionGroup, { component: null, children: itemsToShow.map((item) => ((0, jsx_runtime_1.jsx)(react_transition_group_1.CSSTransition, { timeout: 500, classNames: "item", children: (0, jsx_runtime_1.jsx)(material_1.Grid, { item: true, xs: 4, sm: 4, md: 4, children: (0, jsx_runtime_1.jsx)(ItemView, { item: item }) }) }, item.link))) }), !showAll && list.length > 3 && ((0, jsx_runtime_1.jsx)(material_1.Grid, { item: true, xs: 4, sm: 4, md: 4, children: (0, jsx_runtime_1.jsx)(MoreItemView, { list: list, onMore: handleToggle }) }))] }) }));
33
40
  }
34
41
  exports.default = GoogleSearchSourcesView;
35
42
  function ItemView({ item }) {
36
43
  var _a;
37
44
  return ((0, jsx_runtime_1.jsx)(ItemContainer, { title: `${item.title} - ${item.source}`, favicon: (0, jsx_runtime_1.jsx)(material_1.Avatar, { src: item.favicon, sx: { width: 18, height: 18 }, children: (_a = item.source) === null || _a === void 0 ? void 0 : _a.slice(0, 1) }), link: item.link }));
38
45
  }
46
+ function MoreItemView({ list, onMore }) {
47
+ const current = list.splice(2);
48
+ return ((0, jsx_runtime_1.jsx)(material_1.Card, { sx: { height: '100px', cursor: 'pointer' }, onClick: onMore, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { sx: { py: 1.5, px: 2, gap: 1, height: '100%' }, children: [(0, jsx_runtime_1.jsx)(material_1.Box, { sx: { display: 'flex', flexWrap: 'wrap', gap: '7px', flexGrow: 1 }, children: current.map((item) => {
49
+ var _a;
50
+ return ((0, jsx_runtime_1.jsx)(material_1.Box, { width: 18, height: 18, children: (0, jsx_runtime_1.jsx)(material_1.Avatar, { src: item.favicon, sx: { width: 18, height: 18 }, children: (_a = item.source) === null || _a === void 0 ? void 0 : _a.slice(0, 1) }) }));
51
+ }) }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "caption", noWrap: true, sx: { width: 1, color: '#546C70', fontSize: 12, lineHeight: '18px' }, children: `View ${current.length} more` })] }) }));
52
+ }
39
53
  function ItemSkeleton() {
40
54
  return ((0, jsx_runtime_1.jsx)(ItemContainer, { title: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Skeleton, { width: "100%" }), (0, jsx_runtime_1.jsx)(material_1.Skeleton, { width: "40%" })] }), favicon: (0, jsx_runtime_1.jsx)(material_1.Skeleton, { width: 18, height: 18, variant: "circular" }), link: (0, jsx_runtime_1.jsx)(material_1.Skeleton, { width: "70%" }) }));
41
55
  }
42
56
  function ItemContainer({ title, favicon, link }) {
43
- return ((0, jsx_runtime_1.jsx)(material_1.Card, { sx: { height: '100%' }, children: (0, jsx_runtime_1.jsx)(material_1.CardActionArea, { component: "a", href: typeof link === 'string' ? link : undefined, target: "_blank", sx: { height: '100%' }, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { sx: { p: 1, gap: 1, height: '100%' }, children: [(0, jsx_runtime_1.jsx)(material_1.Box, { flexGrow: 1, children: (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", sx: {
57
+ return ((0, jsx_runtime_1.jsx)(material_1.Card, { sx: { height: '100px' }, children: (0, jsx_runtime_1.jsx)(material_1.CardActionArea, { component: "a", href: typeof link === 'string' ? link : undefined, target: "_blank", sx: { height: '100%' }, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { sx: { py: 1.5, px: 2, gap: 1, height: '100%' }, children: [(0, jsx_runtime_1.jsx)(material_1.Box, { flexGrow: 1, children: (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", sx: {
44
58
  display: '-webkit-box',
45
59
  WebkitBoxOrient: 'vertical',
46
60
  WebkitLineClamp: 2,
@@ -20,6 +20,16 @@ function BackgroundImage() {
20
20
  backgroundPosition: 'center',
21
21
  pointerEvents: 'none',
22
22
  zIndex: -1,
23
+ '&::after': {
24
+ content: '""',
25
+ position: 'absolute',
26
+ top: 0,
27
+ left: 0,
28
+ right: 0,
29
+ bottom: 0,
30
+ backgroundColor: 'rgba(0, 0, 0, 0.12)',
31
+ pointerEvents: 'none',
32
+ },
23
33
  } }));
24
34
  }
25
35
  exports.default = BackgroundImage;
@@ -50,15 +50,17 @@ const CurrentMessage_1 = __importDefault(require("../../contexts/CurrentMessage"
50
50
  const use_appearances_1 = __importStar(require("../../hooks/use-appearances"));
51
51
  const UserMessageView_1 = __importDefault(require("./UserMessageView"));
52
52
  const MessageView = (0, react_1.memo)(({ message }) => {
53
- var _a, _b, _c, _d, _e;
53
+ var _a, _b, _c, _d, _e, _f;
54
+ const preferences = (0, ComponentPreferences_1.useComponentPreferences)();
55
+ const hasBg = !!((_a = preferences === null || preferences === void 0 ? void 0 : preferences.backgroundImage) === null || _a === void 0 ? void 0 : _a.url);
54
56
  const { session: authSession } = (0, session_1.useSessionContext)();
55
57
  const { appearanceOutput } = (0, use_appearances_1.default)({ agentId: message.assistantId });
56
58
  const profile = (0, use_appearances_1.useProfile)({ agentId: message.assistantId });
57
- const { hideAgentAvatar, hideUserInputs } = (_a = (0, ComponentPreferences_1.useComponentPreferences)()) !== null && _a !== void 0 ? _a : {};
59
+ const { hideAgentAvatar, hideUserInputs } = (_b = (0, ComponentPreferences_1.useComponentPreferences)()) !== null && _b !== void 0 ? _b : {};
58
60
  if (!(appearanceOutput === null || appearanceOutput === void 0 ? void 0 : appearanceOutput.componentId))
59
61
  return null;
60
62
  const agentMessage = ((0, jsx_runtime_1.jsx)(MessageBodyContainer, { messageRole: "assistant", children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProperties }) }));
61
- return ((0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: message.assistantId, children: (0, jsx_runtime_1.jsx)(CurrentMessage_1.default, { message: message, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: 2, children: [!hideUserInputs && ((0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(UserInfo_1.default, { name: (_b = authSession.user) === null || _b === void 0 ? void 0 : _b.fullName, did: (_c = authSession.user) === null || _c === void 0 ? void 0 : _c.did, avatar: (_d = authSession.user) === null || _d === void 0 ? void 0 : _d.avatar, time: message.createdAt, reverse: true, alignItems: "flex-start", children: (0, jsx_runtime_1.jsx)(material_1.Stack, { sx: { alignItems: 'flex-end' }, children: (0, jsx_runtime_1.jsx)(MessageBodyContainer, { messageRole: "user", children: (0, jsx_runtime_1.jsx)(UserMessageView_1.default, {}) }) }) }) })), (0, jsx_runtime_1.jsx)(material_1.Box, { children: !hideAgentAvatar ? ((0, jsx_runtime_1.jsx)(UserInfo_1.default, { name: profile.name, did: (_e = globalThis.blocklet) === null || _e === void 0 ? void 0 : _e.appId, avatar: profile.avatar, time: message.createdAt, alignItems: "flex-start", children: agentMessage })) : (agentMessage) })] }) }) }));
63
+ return ((0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: message.assistantId, children: (0, jsx_runtime_1.jsx)(CurrentMessage_1.default, { message: message, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: 2, children: [!hideUserInputs && ((0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(UserInfo_1.default, { name: (_c = authSession.user) === null || _c === void 0 ? void 0 : _c.fullName, did: (_d = authSession.user) === null || _d === void 0 ? void 0 : _d.did, avatar: (_e = authSession.user) === null || _e === void 0 ? void 0 : _e.avatar, time: message.createdAt, reverse: true, alignItems: "flex-start", UserNameProps: { sx: { color: hasBg ? 'white' : undefined } }, children: (0, jsx_runtime_1.jsx)(material_1.Stack, { sx: { alignItems: 'flex-end' }, children: (0, jsx_runtime_1.jsx)(MessageBodyContainer, { messageRole: "user", children: (0, jsx_runtime_1.jsx)(UserMessageView_1.default, {}) }) }) }) })), (0, jsx_runtime_1.jsx)(material_1.Box, { children: !hideAgentAvatar ? ((0, jsx_runtime_1.jsx)(UserInfo_1.default, { name: profile.name, did: (_f = globalThis.blocklet) === null || _f === void 0 ? void 0 : _f.appId, avatar: profile.avatar, time: message.createdAt, alignItems: "flex-start", UserNameProps: { sx: { color: hasBg ? 'white' : undefined } }, children: agentMessage })) : (agentMessage) })] }) }) }));
62
64
  });
63
65
  exports.default = MessageView;
64
66
  function MessageBodyContainer(_a) {
@@ -68,6 +70,6 @@ function MessageBodyContainer(_a) {
68
70
  const hasBg = !!((_b = preferences === null || preferences === void 0 ? void 0 : preferences.backgroundImage) === null || _b === void 0 ? void 0 : _b.url);
69
71
  const hideUserMessage = preferences === null || preferences === void 0 ? void 0 : preferences.hideUserInputs;
70
72
  return ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({}, props, { sx: hasBg
71
- ? Object.assign({ borderRadius: 1, borderTopRightRadius: messageRole === 'user' ? 2 : undefined, borderTopLeftRadius: messageRole !== 'user' ? 2 : undefined, px: 2, py: 1, marginTop: 0.5, maxWidth: hideUserMessage ? 'unset' : 'calc(100% - 40px)', bgcolor: 'rgba(239, 246, 255, 1)' }, props.sx) : Object.assign({}, props.sx) })));
73
+ ? Object.assign({ borderRadius: 1, borderTopRightRadius: messageRole === 'user' ? 2 : undefined, borderTopLeftRadius: messageRole !== 'user' ? 2 : undefined, px: 2, py: 1, marginTop: 0.5, maxWidth: hideUserMessage ? 'unset' : 'calc(100% - 40px)', bgcolor: 'rgba(255, 255, 255, 0.8)', backdropFilter: 'blur(16px)' }, props.sx) : Object.assign({}, props.sx) })));
72
74
  }
73
75
  exports.MessageBodyContainer = MessageBodyContainer;
@@ -15,7 +15,8 @@ const use_appearances_1 = require("../../hooks/use-appearances");
15
15
  const MessageView_1 = require("./MessageView");
16
16
  const OpeningMessageView = (0, react_1.memo)(({ isMessagesEmpty }) => {
17
17
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
18
- const { hideAgentAvatar } = (_a = (0, ComponentPreferences_1.useComponentPreferences)()) !== null && _a !== void 0 ? _a : {};
18
+ const { hideAgentAvatar, backgroundImage } = (_a = (0, ComponentPreferences_1.useComponentPreferences)()) !== null && _a !== void 0 ? _a : {};
19
+ const hasBg = !!(backgroundImage === null || backgroundImage === void 0 ? void 0 : backgroundImage.url);
19
20
  const openingMessage = (0, use_appearances_1.useOpeningMessage)();
20
21
  const openingMessageOutput = (0, react_1.useMemo)(() => { var _a; return (_a = openingMessage === null || openingMessage === void 0 ? void 0 : openingMessage.agent.outputVariables) === null || _a === void 0 ? void 0 : _a.find((i) => i.name === types_1.RuntimeOutputVariable.openingMessage); }, [openingMessage === null || openingMessage === void 0 ? void 0 : openingMessage.agent]);
21
22
  const openingMessageComponentId = ((_b = openingMessageOutput === null || openingMessageOutput === void 0 ? void 0 : openingMessageOutput.appearance) === null || _b === void 0 ? void 0 : _b.componentId) ||
@@ -31,6 +32,6 @@ const OpeningMessageView = (0, react_1.memo)(({ isMessagesEmpty }) => {
31
32
  return null;
32
33
  }
33
34
  const children = ((0, jsx_runtime_1.jsxs)(MessageView_1.MessageBodyContainer, { children: [openingMessage && openingMessageOutput && openingMessageComponentId && ((0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { instanceId: openingMessageOutput.id, componentId: openingMessageComponentId, properties: (_f = openingMessageOutput.appearance) === null || _f === void 0 ? void 0 : _f.componentProperties, props: { output: openingMessageOutput, outputValue: openingMessage.message } })), isMessagesEmpty && openingQuestionsComponentId && ((0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { instanceId: agent.id, componentId: openingQuestionsComponentId, properties: (_g = openingQuestionsOutput === null || openingQuestionsOutput === void 0 ? void 0 : openingQuestionsOutput.appearance) === null || _g === void 0 ? void 0 : _g.componentProperties, props: { output: openingQuestionsOutput } }))] }));
34
- return hideAgentAvatar ? (children) : ((0, jsx_runtime_1.jsx)(UserInfo_1.default, { name: ((_h = openingMessage === null || openingMessage === void 0 ? void 0 : openingMessage.profile) !== null && _h !== void 0 ? _h : profile).name, did: (_j = globalThis.blocklet) === null || _j === void 0 ? void 0 : _j.appId, avatar: ((_k = openingMessage === null || openingMessage === void 0 ? void 0 : openingMessage.profile) !== null && _k !== void 0 ? _k : profile).avatar, alignItems: "flex-start", children: children }));
35
+ return hideAgentAvatar ? (children) : ((0, jsx_runtime_1.jsx)(UserInfo_1.default, { name: ((_h = openingMessage === null || openingMessage === void 0 ? void 0 : openingMessage.profile) !== null && _h !== void 0 ? _h : profile).name, did: (_j = globalThis.blocklet) === null || _j === void 0 ? void 0 : _j.appId, avatar: ((_k = openingMessage === null || openingMessage === void 0 ? void 0 : openingMessage.profile) !== null && _k !== void 0 ? _k : profile).avatar, alignItems: "flex-start", UserNameProps: { sx: { color: hasBg ? 'white' : undefined } }, children: children }));
35
36
  });
36
37
  exports.default = OpeningMessageView;
@@ -36,6 +36,9 @@ function SimpleChat(_a) {
36
36
  }
37
37
  exports.default = SimpleChat;
38
38
  function SimpleChatView() {
39
+ var _a;
40
+ const preferences = (0, ComponentPreferences_1.useComponentPreferences)();
41
+ const hasBg = !!((_a = preferences === null || preferences === void 0 ? void 0 : preferences.backgroundImage) === null || _a === void 0 ? void 0 : _a.url);
39
42
  const { activeAgentId } = (0, ActiveAgent_1.useActiveAgent)();
40
43
  // auto scroll to bottom when new message is sent
41
44
  const running = (0, session_1.useCurrentSessionState)((s) => s === null || s === void 0 ? void 0 : s.running);
@@ -48,7 +51,7 @@ function SimpleChatView() {
48
51
  const sessionLoading = (0, session_1.useCurrentSessionState)((s) => s === null || s === void 0 ? void 0 : s.loading);
49
52
  const loading = (0, session_1.useSessionState)((s) => s === null || s === void 0 ? void 0 : s.loading) || sessionLoading;
50
53
  (0, use_header_menu_1.useHeaderMenu)();
51
- return ((0, jsx_runtime_1.jsxs)(SimpleLayout_1.default, { px: 0, children: [(0, jsx_runtime_1.jsx)(SimpleHeader_1.default, { px: 4 }), loading ? ((0, jsx_runtime_1.jsx)(material_1.Box, { textAlign: "center", my: 10, children: (0, jsx_runtime_1.jsx)(material_1.CircularProgress, { size: 24 }) })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: activeAgentId, children: (0, jsx_runtime_1.jsx)(MessagesView_1.default, { className: "aigne-outputs aigne-simple-chat-outputs", flexGrow: (messages === null || messages === void 0 ? void 0 : messages.length) ? 1 : 0, pb: (messages === null || messages === void 0 ? void 0 : messages.length) ? 10 : 2, px: { xs: 2, sm: 3 } }) }), (0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: activeAgentId, children: (0, jsx_runtime_1.jsx)(InputsView_1.default, { className: "aigne-inputs aigne-simple-chat-inputs", sx: {
54
+ return ((0, jsx_runtime_1.jsxs)(SimpleLayout_1.default, { px: 0, children: [(0, jsx_runtime_1.jsx)(SimpleHeader_1.default, { px: 4, sx: { color: hasBg ? 'white' : undefined } }), loading ? ((0, jsx_runtime_1.jsx)(material_1.Box, { textAlign: "center", my: 10, children: (0, jsx_runtime_1.jsx)(material_1.CircularProgress, { size: 24 }) })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: activeAgentId, children: (0, jsx_runtime_1.jsx)(MessagesView_1.default, { className: "aigne-outputs aigne-simple-chat-outputs", flexGrow: (messages === null || messages === void 0 ? void 0 : messages.length) ? 1 : 0, pb: (messages === null || messages === void 0 ? void 0 : messages.length) ? 10 : 2, px: { xs: 2, sm: 3 } }) }), (0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: activeAgentId, children: (0, jsx_runtime_1.jsx)(InputsView_1.default, { className: "aigne-inputs aigne-simple-chat-inputs", sx: {
52
55
  position: 'sticky',
53
56
  bottom: 0,
54
57
  py: 2,
@@ -26,7 +26,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
26
  const jsx_runtime_1 = require("react/jsx-runtime");
27
27
  const Empty_1 = __importDefault(require("@arcblock/ux/lib/Empty"));
28
28
  const RelativeTime_1 = __importDefault(require("@arcblock/ux/lib/RelativeTime"));
29
- // import { useRuntimeState } from '@blocklet/pages-kit/builtin/async/ai-runtime';
30
29
  const react_1 = require("@iconify/react");
31
30
  const lab_1 = require("@mui/lab");
32
31
  const material_1 = require("@mui/material");
@@ -37,6 +36,7 @@ const ActiveAgent_1 = require("../../contexts/ActiveAgent");
37
36
  const CurrentAgent_1 = __importDefault(require("../../contexts/CurrentAgent"));
38
37
  const CurrentMessage_1 = __importDefault(require("../../contexts/CurrentMessage"));
39
38
  const use_appearances_1 = __importDefault(require("../../hooks/use-appearances"));
39
+ const runtime_1 = require("../../state/runtime");
40
40
  const session_1 = require("../../state/session");
41
41
  const CodePreview_1 = require("./components/CodePreview");
42
42
  const ConfirmDialog_1 = __importDefault(require("./components/ConfirmDialog"));
@@ -96,9 +96,11 @@ function Page() {
96
96
  }
97
97
  exports.default = Page;
98
98
  function V0ListRender() {
99
+ var _a, _b;
99
100
  const ConfirmDialogRef = (0, react_2.useRef)();
100
101
  const { sessions: sessionsList, setCurrentSessionId, loadLatestMessagesForAllSessions, sessionMap, deleteSession, loading, } = (0, session_1.useSessionState)((s) => s) || {};
101
102
  const { isMobile } = (0, V0Runtime_1.useV0RuntimeContext)();
103
+ const { agent } = (0, runtime_1.useRuntimeState)();
102
104
  const { t } = (0, locale_1.useLocaleContext)();
103
105
  (0, react_2.useEffect)(() => {
104
106
  const loadData = () => __awaiter(this, void 0, void 0, function* () {
@@ -108,7 +110,7 @@ function V0ListRender() {
108
110
  });
109
111
  loadData();
110
112
  }, [sessionsList === null || sessionsList === void 0 ? void 0 : sessionsList.length]);
111
- return ((0, jsx_runtime_1.jsxs)(material_1.Box, { flex: 1, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h2", color: "textColor", sx: { fontWeight: 'bold', mt: isMobile ? 3 : 6 }, children: t('v0.title') }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h5", color: "textColor", sx: Object.assign(Object.assign({}, (0, utils_1.getLineClamp)(5)), { mt: 2 }), children: t('v0.description') }), loading ? ((0, jsx_runtime_1.jsx)(Loading_1.default, { sx: {
113
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, { flex: 1, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h2", color: "textColor", sx: { fontWeight: 'bold', mt: isMobile ? 3 : 6 }, children: ((_a = agent === null || agent === void 0 ? void 0 : agent.project) === null || _a === void 0 ? void 0 : _a.name) || t('v0.title') }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h5", color: "textColor", sx: Object.assign(Object.assign({}, (0, utils_1.getLineClamp)(5)), { mt: 2 }), children: ((_b = agent === null || agent === void 0 ? void 0 : agent.project) === null || _b === void 0 ? void 0 : _b.description) || t('v0.description') }), loading ? ((0, jsx_runtime_1.jsx)(Loading_1.default, { sx: {
112
114
  position: 'relative',
113
115
  height: '40vh',
114
116
  width: '100%',
@@ -117,7 +119,7 @@ function V0ListRender() {
117
119
  display: 'flex',
118
120
  alignContent: 'center',
119
121
  justifyContent: 'center',
120
- }, children: [(sessionsList === null || sessionsList === void 0 ? void 0 : sessionsList.length) ? ((0, jsx_runtime_1.jsx)(lab_1.Masonry, { columns: { xs: 1, sm: 2, md: 4, lg: 4 }, sequential: true, spacing: 2, children: sessionsList === null || sessionsList === void 0 ? void 0 : sessionsList.map((item) => {
122
+ }, children: [(sessionsList === null || sessionsList === void 0 ? void 0 : sessionsList.length) ? ((0, jsx_runtime_1.jsx)(lab_1.Masonry, { columns: { xs: 1, sm: 2, md: 3, lg: 4 }, sequential: true, spacing: 2, children: sessionsList === null || sessionsList === void 0 ? void 0 : sessionsList.map((item) => {
121
123
  var _a, _b;
122
124
  const { name, id } = item;
123
125
  const latestMessage = (_b = (_a = sessionMap === null || sessionMap === void 0 ? void 0 : sessionMap[id]) === null || _a === void 0 ? void 0 : _a.messages) === null || _b === void 0 ? void 0 : _b.at(-1);
@@ -177,11 +179,18 @@ function V0ListRender() {
177
179
  }
178
180
  function V0DetailRender() {
179
181
  const { setCurrentSessionId } = (0, session_1.useSessionState)((s) => s) || {};
180
- const { messages: messagesList, loading } = (0, session_1.useCurrentSessionState)((s) => s) || {};
182
+ const { messages: messagesListOriginal, loading } = (0, session_1.useCurrentSessionState)((s) => s) || {};
181
183
  const { currentMessageTaskId, setCurrentMessageTaskId, propertiesValueMap, isMobile } = (0, V0Runtime_1.useV0RuntimeContext)();
182
184
  const [sliderOpenInMobile, setSliderOpenInMobile] = (0, react_2.useState)(!isMobile);
183
185
  const { t } = (0, locale_1.useLocaleContext)();
184
- const currentMessage = messagesList === null || messagesList === void 0 ? void 0 : messagesList.find((item) => item.taskId === currentMessageTaskId);
186
+ // FIXME: 现在临时把 error 的消息隐藏了,后续需要优化
187
+ const messagesList = messagesListOriginal === null || messagesListOriginal === void 0 ? void 0 : messagesListOriginal.filter((message, index) => {
188
+ var _a, _b;
189
+ return (!(message === null || message === void 0 ? void 0 : message.error) && ((_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.length)) ||
190
+ message.taskId === currentMessageTaskId ||
191
+ index === messagesListOriginal.length - 1;
192
+ });
193
+ const currentMessage = messagesList === null || messagesList === void 0 ? void 0 : messagesList.find((message) => message.taskId === currentMessageTaskId);
185
194
  (0, react_2.useEffect)(() => {
186
195
  if (messagesList === null || messagesList === void 0 ? void 0 : messagesList.length) {
187
196
  const latestMessage = messagesList === null || messagesList === void 0 ? void 0 : messagesList.at(-1);
@@ -241,7 +250,7 @@ function V0DetailRender() {
241
250
  justifyContent: 'center',
242
251
  flexDirection: 'column',
243
252
  gap: 1,
244
- }, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { onClick: () => {
253
+ }, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { id: taskId, onClick: () => {
245
254
  // @ts-ignore
246
255
  setCurrentMessageTaskId(item.taskId);
247
256
  }, sx: Object.assign({ cursor: 'pointer', color: 'textColor', borderRadius: 1, border: 1, borderColor: isCurrent ? 'primary.main' : 'background.block', backgroundColor: 'white', position: 'relative', transition: 'all 0.3s', '&:hover': {
@@ -1,4 +1,13 @@
1
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
+ };
2
11
  var __rest = (this && this.__rest) || function (s, e) {
3
12
  var t = {};
4
13
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
@@ -16,19 +25,74 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
16
25
  Object.defineProperty(exports, "__esModule", { value: true });
17
26
  exports.getCurrentCodeByTaskId = exports.CodeRenderByMessageMemo = exports.CodeRenderByMessage = exports.CodePreviewMemo = void 0;
18
27
  const jsx_runtime_1 = require("react/jsx-runtime");
28
+ const react_1 = require("@iconify/react");
19
29
  const material_1 = require("@mui/material");
20
- const react_1 = require("react");
30
+ const react_2 = require("react");
21
31
  const CustomComponentRenderer_1 = __importDefault(require("../../../../../../components/CustomComponentRenderer"));
22
32
  const locale_1 = require("../../../../../locale");
33
+ const LoadingButton_1 = __importDefault(require("../../../components/LoadingButton"));
34
+ const CurrentAgent_1 = require("../../../contexts/CurrentAgent");
35
+ const runtime_1 = require("../../../state/runtime");
23
36
  const MessageErrorView_1 = __importDefault(require("../../ChatOutput/MessageErrorView"));
37
+ const V0Runtime_1 = require("../contexts/V0Runtime");
24
38
  const Loading_1 = require("./Loading");
39
+ const TransparentTooltip_1 = __importDefault(require("./TransparentTooltip"));
25
40
  const codeField = 'code';
41
+ function RetryComponent({ message, tip }) {
42
+ const { t } = (0, locale_1.useLocaleContext)();
43
+ const { execute } = (0, runtime_1.useRuntimeState)();
44
+ const { aid } = (0, CurrentAgent_1.useCurrentAgent)();
45
+ const { setCurrentMessageTaskId } = (0, V0Runtime_1.useV0RuntimeContext)();
46
+ const [loading, setLoading] = (0, react_2.useState)(false);
47
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
48
+ width: '100%',
49
+ height: '100%',
50
+ display: 'flex',
51
+ flexDirection: 'column',
52
+ justifyContent: 'flex-start',
53
+ alignItems: 'center',
54
+ gap: 2,
55
+ p: 4,
56
+ }, children: [(0, jsx_runtime_1.jsx)(material_1.Box, { component: react_1.Icon, icon: "unjs:automd", sx: {
57
+ mt: 6,
58
+ fontSize: 120,
59
+ } }), (0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "h6", sx: {
60
+ display: 'flex',
61
+ alignItems: 'center',
62
+ }, children: [tip || t('v0.retryTip'), (0, jsx_runtime_1.jsx)(TransparentTooltip_1.default, { arrow: true, placement: "top", title: (0, jsx_runtime_1.jsx)(MessageErrorView_1.default, { error: (message === null || message === void 0 ? void 0 : message.error) || new Error('Empty response from AI or Code not found'), sx: {
63
+ mr: 0,
64
+ } }), children: (0, jsx_runtime_1.jsx)(material_1.Box, { component: react_1.Icon, icon: "akar-icons:info", sx: {
65
+ ml: 1,
66
+ } }) })] }), (0, jsx_runtime_1.jsx)(LoadingButton_1.default, { variant: "contained", loading: loading, color: "primary", onClick: () => __awaiter(this, void 0, void 0, function* () {
67
+ setLoading(true);
68
+ try {
69
+ const { parameters } = message || {};
70
+ // remove $ starting parameters object
71
+ const canUseParameters = Object.fromEntries(Object.entries(parameters || {}).filter(([key]) => !key.startsWith('$')));
72
+ yield execute({
73
+ aid,
74
+ parameters: canUseParameters,
75
+ onResponseStart: () => {
76
+ setCurrentMessageTaskId(undefined);
77
+ },
78
+ });
79
+ }
80
+ catch (error) {
81
+ console.error(error);
82
+ }
83
+ finally {
84
+ setLoading(false);
85
+ }
86
+ }), children: t('v0.retry') })] }));
87
+ }
26
88
  function CodePreview(_a) {
27
- var { componentId = 'mock-dev-component', code, propertiesValue } = _a, restProps = __rest(_a, ["componentId", "code", "propertiesValue"]);
28
- const { locale } = (0, locale_1.useLocaleContext)();
89
+ var { componentId = 'mock-dev-component', code, propertiesValue, message } = _a, restProps = __rest(_a, ["componentId", "code", "propertiesValue", "message"]);
90
+ const { t, locale } = (0, locale_1.useLocaleContext)();
29
91
  if (!code)
30
92
  return null;
31
- return ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ id: componentId, className: "code-preview-wrapper" }, restProps, { children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: componentId, locale: locale, props: propertiesValue || {}, dev: {
93
+ return ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ id: componentId, className: "code-preview-wrapper" }, restProps, { children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: componentId, locale: locale, props: propertiesValue || {},
94
+ // eslint-disable-next-line react/no-unstable-nested-components
95
+ fallbackRender: () => (0, jsx_runtime_1.jsx)(RetryComponent, { message: message, tip: t('v0.errorCodeTip') }), dev: {
32
96
  components: {
33
97
  [componentId]: {
34
98
  data: {
@@ -45,7 +109,7 @@ function CodePreview(_a) {
45
109
  } }) }), componentId));
46
110
  }
47
111
  exports.default = CodePreview;
48
- exports.CodePreviewMemo = (0, react_1.memo)(CodePreview);
112
+ exports.CodePreviewMemo = (0, react_2.memo)(CodePreview);
49
113
  function CodeRenderByMessage({ zoom, message, minHeight = 200, sx, propertiesValueMap, }) {
50
114
  var _a;
51
115
  const { locale } = (0, locale_1.useLocaleContext)();
@@ -56,7 +120,7 @@ function CodeRenderByMessage({ zoom, message, minHeight = 200, sx, propertiesVal
56
120
  },
57
121
  };
58
122
  const isMessageLoading = ((message === null || message === void 0 ? void 0 : message.loading) || !(message === null || message === void 0 ? void 0 : message.result)) && !(message === null || message === void 0 ? void 0 : message.error);
59
- const ContentRender = (0, react_1.useCallback)(() => {
123
+ const ContentRender = (0, react_2.useCallback)(() => {
60
124
  var _a, _b, _c, _d;
61
125
  if (isMessageLoading) {
62
126
  return ((0, jsx_runtime_1.jsx)(material_1.Box, { className: "code-message-loading", sx: {
@@ -66,24 +130,15 @@ function CodeRenderByMessage({ zoom, message, minHeight = 200, sx, propertiesVal
66
130
  alignItems: 'center',
67
131
  }, children: (0, jsx_runtime_1.jsx)(Loading_1.AIRunningLoading, {}) }));
68
132
  }
69
- if (message === null || message === void 0 ? void 0 : message.error) {
70
- return ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
71
- width: '100%',
72
- }, children: (0, jsx_runtime_1.jsx)(MessageErrorView_1.default, { error: message.error, sx: {
73
- mr: 0,
74
- } }) }));
75
- }
76
- if (!((_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.length)) {
77
- return ((0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(MessageErrorView_1.default, { error: new Error('Something error'), sx: {
78
- mr: 0,
79
- } }) }));
133
+ if ((message === null || message === void 0 ? void 0 : message.error) || !((_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.length)) {
134
+ return (0, jsx_runtime_1.jsx)(RetryComponent, { message: message });
80
135
  }
81
136
  return (_d = (_c = message === null || message === void 0 ? void 0 : message.result) === null || _c === void 0 ? void 0 : _c.objects) === null || _d === void 0 ? void 0 : _d.map((item) => {
82
137
  var _a, _b, _c;
83
138
  const { taskId } = item;
84
139
  // @ts-ignore
85
140
  const code = (_a = item === null || item === void 0 ? void 0 : item.data) === null || _a === void 0 ? void 0 : _a[codeField];
86
- return ((0, jsx_runtime_1.jsx)(exports.CodePreviewMemo, { componentId: `code-preview-${taskId}`, code: code, propertiesValue: ((_b = propertiesValueMap === null || propertiesValueMap === void 0 ? void 0 : propertiesValueMap[taskId]) === null || _b === void 0 ? void 0 : _b[locale]) || ((_c = propertiesValueMap === null || propertiesValueMap === void 0 ? void 0 : propertiesValueMap[taskId]) === null || _c === void 0 ? void 0 : _c.en) || {} }, item.taskId));
141
+ return ((0, jsx_runtime_1.jsx)(exports.CodePreviewMemo, { componentId: `code-preview-${taskId}`, code: code, propertiesValue: ((_b = propertiesValueMap === null || propertiesValueMap === void 0 ? void 0 : propertiesValueMap[taskId]) === null || _b === void 0 ? void 0 : _b[locale]) || ((_c = propertiesValueMap === null || propertiesValueMap === void 0 ? void 0 : propertiesValueMap[taskId]) === null || _c === void 0 ? void 0 : _c.en) || {}, message: message }, item.taskId));
87
142
  });
88
143
  // eslint-disable-next-line react-hooks/exhaustive-deps
89
144
  }, [isMessageLoading, (_a = message === null || message === void 0 ? void 0 : message.result) === null || _a === void 0 ? void 0 : _a.objects, propertiesValueMap, locale]);
@@ -92,7 +147,7 @@ function CodeRenderByMessage({ zoom, message, minHeight = 200, sx, propertiesVal
92
147
  } }), children: (0, jsx_runtime_1.jsx)(ContentRender, {}) }, message === null || message === void 0 ? void 0 : message.taskId));
93
148
  }
94
149
  exports.CodeRenderByMessage = CodeRenderByMessage;
95
- exports.CodeRenderByMessageMemo = (0, react_1.memo)(CodeRenderByMessage);
150
+ exports.CodeRenderByMessageMemo = (0, react_2.memo)(CodeRenderByMessage);
96
151
  function getCurrentCodeByTaskId(message, taskId) {
97
152
  var _a, _b, _c, _d;
98
153
  // @ts-ignore